Model - Store
API reference for src/schema/store, src/Store on @huukhanhnguyen/model, reachable from ..
See the Guide for the ModelJSON / evaluate pipeline.
API reference
Signatures are generated from the live package .d.ts - not hand-written.
AssetFailure
type
One failed fetch/decode from the async pre-load phase. The sync graph stays fail-soft on its own (a missing font falls back, the texture image op reports at resolve) — this record exists so a HOST can surface "asset X didn't load" instead of degrading silently.
type AssetFailure
// = {
type: "font" | "image" | "glb";
/** The registration key — for a font, its url (fonts are keyed by URL,
* same as images). */
name?: string;
url: string;
message: string;
}Store
class
Per-session asset registry. Every consumer builds its own instance — new Store() — there is no shared singleton.
Responsibilities (JSON-level only, never instantiates a Model):
- Store raw model JSONs by ID (host-facing lookup, e.g. catalog opens).
- Scan a document's
parameterslane (root AND each components[] entry's ownparameters, 2026-07-22 — a component may carry its OWN attached files, share.ts's law) for url-method parameters (an attached file IS such a parameter — type inferred from the url via assetTypeOf: font/image/glb) plus thetextures[]lane'simageops → pre-load by URL. All three maps are keyed by URL.
Typical session flow: const assets = new Store() assets.registerFromModel(json) // scan parameters/textures lanes await assets.loadFonts() // ASYNC phase (+ loadImages/loadGlbs) const model = await Model.fromJSON(json, { store: assets })
class StoreMembers: getFont, getGlb, getImage, getModel, loadFonts, loadGlbs, loadImages, queueGlb, queueImage, registerFont, registerFromModel, registerGlb, registerImage, reset