mwg API
    Preparing search index...

    Class AssetStream

    Game-directed background asset staging with bounded, least-recently-used eviction.

    It deliberately does not guess a player's next map: the game supplies bundles it considers likely. This works with compiled data URIs as a decode/GPU warm-up and with server or desktop hosts as ordinary asynchronous streaming.

    import { AssetStream } from '@datamoc/mw_games/assets';

    const stream = new AssetStream({ budgetBytes: 50_000_000 });

    // when a player enters a town, a likely-next zone starts loading in the background
    await stream.preload({ id: 'forest', paths: ['forest-tiles.png'], priority: 1 });
    Index
    • Preloads bundles in highest-priority-first order; callers may intentionally not await it. onProgress, when given, reports overall fraction across every bundle in bundles (each one weighted equally), for a caller that wants one progress figure across the whole list rather than per-bundle callbacks of its own.

      Parameters

      Returns Promise<void>

    • explicitly unloads one bundle, even when the configured budget has room

      Parameters

      • id: string

      Returns Promise<void>

    • marks a ready bundle as recently used at the moment a scene adopts it

      Parameters

      • id: string

      Returns boolean