Hands resolve/has/paths a game's own path-to-URI map, in place of
tools/compile-resources's window.__MWG_ASSETS__ convention.
A game bundled by its own tool (Vite, say) that compiles its assets into data: URIs a
different way still wants resolve's single lookup and isCompiled's dev/build branch,
without also adopting window.__MWG_ASSETS__ as the wire format. Passing the map here
makes this file agnostic to how the map was built, only to its shape - { path: uri },
the same shape window.__MWG_ASSETS__ already is. undefined reverts to reading
window.__MWG_ASSETS__ (or dev-server mode, if that is unset too).
import { setAssetMap, isCompiled, resolve } from '@datamoc/mw_games/assets/paths';
setAssetMap({ 'tiles.png': 'data:image/png;base64,...' });
console.log(isCompiled()); // true
console.log(resolve('tiles.png')); // the data: URI handed in above
setAssetMap(undefined); // back to window.__MWG_ASSETS__ / dev-server mode
The
file://story, split by how renderer-specific each piece is.paths.tsresolves an asset path against the compileddata:URI map (or the dev server) and needs no renderer at all;binary.tscaches raw bytes the same renderer-free way, for anything (three-d's VOX loader, most directly) that wants anArrayBufferrather than a decoded texture;loader.tsfetches and decodes textures through Pixi specifically. This barrel exposes all three, soimport { load, resolve } from '@datamoc/mw_games/assets'is unchanged - but a game rendering through something else imports@datamoc/mw_games/assets/pathsor@datamoc/mw_games/assets/binaryinstead and pays nothing for Pixi.