stowkit-reader
v0.1.3
Published
WebAssembly-based reader for StowKit (.stow) asset pack files
Readme
@stowkit/reader
WebAssembly-based reader for StowKit (.stow) asset pack files. Read packed game assets directly in the browser with zero dependencies.
Features
- 🚀 Pure WASM - Fast, memory-safe asset reading
- 📦 Zero Dependencies - Just WebAssembly, no external libraries
- 🔍 Asset Inspection - Read metadata and binary data
- 🎮 Game-Ready - Supports textures (KTX2), meshes, audio, and more
- 📝 TypeScript Support - Full type definitions included
Installation
npm install @stowkit/readerUsage
import { StowKitReader } from '@stowkit/reader';
// Initialize the reader
const reader = new StowKitReader();
await reader.init();
// Open a .stow file
const response = await fetch('assets.stow');
const buffer = await response.arrayBuffer();
await reader.open(buffer);
// List all assets
const assets = reader.listAssets();
console.log(`Found ${assets.length} assets`);
// Read asset data
const textureData = reader.readAssetData(0);
const metadata = reader.readAssetMetadata(0);
// Parse texture metadata (for KTX2 textures)
if (metadata) {
const texInfo = reader.parseTextureMetadata(metadata);
console.log(`Texture: ${texInfo.width}x${texInfo.height}`);
console.log(`KTX2: ${texInfo.isKtx2 ? 'Yes' : 'No'}`);
}
// Clean up
reader.close();Asset Types
- 1 - Static Mesh (vertices, indices, normals, UVs)
- 2 - Texture 2D (KTX2 format with Basis Universal)
- 3 - Audio (OGG Vorbis)
API
new StowKitReader(wasmUrl?: string)
Create a new reader instance. Optionally specify the WASM file URL.
async init(): Promise<StowKitReader>
Initialize the WebAssembly module. Must be called before using the reader.
async open(file: ArrayBuffer | File): Promise<boolean>
Open a .stow file from an ArrayBuffer or File object.
getAssetCount(): number
Get the total number of assets in the pack.
listAssets(): AssetListItem[]
Get information about all assets including names, types, and sizes.
getAssetInfo(index: number): AssetInfo | null
Get detailed information about a specific asset.
readAssetData(index: number): Uint8Array | null
Read the binary data of an asset.
readAssetMetadata(index: number): Uint8Array | null
Read the metadata of an asset (if available).
parseTextureMetadata(metadata: Uint8Array): TextureMetadata | null
Parse texture metadata to get dimensions and format info.
close(): void
Close the current file and free resources.
License
MIT
