npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stowkit/phaser-loader

v0.1.16

Published

Phaser loader for StowKit asset packs with KTX2/Basis Universal compressed texture support

Readme

@stowkit/phaser-loader

Phaser.js loader for StowKit asset packs. Supports loading compressed textures (KTX2/Basis Universal) and audio from .stow files.

Features

  • Compressed Texture Support: Automatically decodes KTX2 textures to GPU-compressed formats (BC3/DXT5, BC1/DXT1, ASTC, ETC2, etc.)
  • Audio Loading: Loads audio assets as Web Audio buffers or HTML5 audio elements
  • Multiple Packs: Load multiple .stow files simultaneously with isolated state
  • Phaser Integration: Textures are registered with Phaser's texture manager and work with all Phaser game objects
  • Efficient: Textures remain compressed on the GPU, reducing memory usage

Installation

npm install @stowkit/phaser-loader

Quick Start

import Phaser from 'phaser';
import { StowKitPhaserLoader } from '@stowkit/phaser-loader';

class GameScene extends Phaser.Scene {
    constructor() {
        super('GameScene');
    }

    async create() {
        // Load the .stow pack
        const pack = await StowKitPhaserLoader.load('/assets/game.stow', {
            basisPath: '/basis/',
            wasmPath: '/stowkit_reader.wasm'
        });
        
        // Load textures into Phaser
        await pack.loadTexture('characters/player', this);
        await pack.loadTexture('ui/button', this);
        
        // Use textures with Phaser game objects
        const player = this.add.sprite(400, 300, 'characters/player');
        const button = this.add.image(100, 50, 'ui/button');
        
        // Load audio
        const bgmBuffer = await pack.loadAudio('sounds/bgm');
        // Use with Web Audio API or convert to Phaser sound
    }
}

const config = {
    type: Phaser.WEBGL,
    width: 800,
    height: 600,
    scene: GameScene
};

const game = new Phaser.Game(config);

API Reference

StowKitPhaserLoader

Static loader class for opening .stow pack files.

StowKitPhaserLoader.load(url, options?)

Loads a .stow pack from a URL.

Parameters:

  • url (string): Path to the .stow file
  • options (object, optional):
    • basisPath (string): Path to Basis Universal transcoder files (default: /basis/)
    • wasmPath (string): Path to StowKit WASM module (default: /stowkit/stowkit_reader.wasm)

Returns: Promise<StowKitPhaserPack>

StowKitPhaserPack

Represents an opened .stow pack file.

pack.loadTexture(assetPath, scene)

Loads a texture by its canonical path and registers it with Phaser's texture manager.

Parameters:

  • assetPath (string): The canonical path of the texture (e.g., "characters/player")
  • scene (Phaser.Scene): The Phaser scene instance

Returns: Promise<Phaser.Textures.Texture>

Important: Must be called after the Phaser scene is initialized (in or after create()).

await pack.loadTexture('textures/player', this);
this.add.sprite(100, 100, 'textures/player');

pack.getPhaserTexture(index, scene)

Loads a texture by index (useful for asset browsing/previews).

Parameters:

  • index (number): Asset index
  • scene (Phaser.Scene): The Phaser scene instance

Returns: Promise<Phaser.Textures.Texture>

pack.loadAudio(assetPath, audioContext?)

Loads audio by path as an AudioBuffer.

Parameters:

  • assetPath (string): The canonical path of the audio asset
  • audioContext (AudioContext, optional): Web Audio context to use

Returns: Promise<AudioBuffer>

pack.loadAudioByIndex(index, audioContext?)

Loads audio by index.

pack.createAudioPreview(index)

Creates an HTML5 audio element for preview.

Returns: Promise<HTMLAudioElement>

pack.listAssets()

Returns array of all assets in the pack.

pack.getAssetCount()

Returns total number of assets.

pack.getAssetInfo(index)

Get asset info by index.

pack.getTextureMetadata(index)

Get texture metadata (dimensions, format, tags, etc.).

pack.getAudioMetadata(index)

Get audio metadata.

pack.dispose()

Closes the pack and frees resources.

Loading Multiple Packs

Each pack is fully isolated with its own state. You can load multiple packs simultaneously:

class GameScene extends Phaser.Scene {
    async create() {
        // Load multiple packs at once
        const [uiPack, levelPack, characterPack] = await Promise.all([
            StowKitPhaserLoader.load('/assets/ui.stow'),
            StowKitPhaserLoader.load('/assets/level1.stow'),
            StowKitPhaserLoader.load('/assets/characters.stow')
        ]);
        
        // Load textures from different packs
        await uiPack.loadTexture('button', this);
        await levelPack.loadTexture('background', this);
        await characterPack.loadTexture('player', this);
        
        // Use textures as normal
        this.add.image(100, 50, 'button');
        this.add.image(0, 0, 'background');
        this.add.sprite(400, 300, 'player');
        
        // Each pack maintains its own asset catalog
        console.log(`UI Pack: ${uiPack.getAssetCount()} assets`);
        console.log(`Level Pack: ${levelPack.getAssetCount()} assets`);
        console.log(`Character Pack: ${characterPack.getAssetCount()} assets`);
    }
}

Note: Each pack creates its own WASM instance for isolated state. Dispose packs when no longer needed:

uiPack.dispose();

Compressed Texture Formats

The loader automatically transcodes KTX2 textures to the best format supported by the device:

Desktop (DXT/BC formats):

  • BC7 (BPTC) - Highest quality for UASTC textures with alpha (requires WebGL2 + EXT_texture_compression_bptc)
  • BC3 (DXT5) - High quality for textures with alpha
  • BC1 (DXT1) - For textures without alpha or ETC1S encoded textures

Mobile:

  • ASTC 4x4 - Highest quality (iOS, Android with GPU support)
  • ETC2 - Good quality (WebGL2 required)
  • ETC1 - Legacy Android support
  • PVRTC - iOS fallback

Fallback:

  • RGBA32 - Uncompressed fallback if no compressed formats are supported

Limitations

  • No 3D Model Support: This loader only handles 2D textures and audio. For 3D models, use @stowkit/three-loader
  • Phaser 3.60+: Compressed texture support requires Phaser 3.60 or later
  • Scene Required: Textures must be loaded within or after a Phaser scene is initialized

License

MIT