@huukhanhnguyen/model / schema/ref
schema/ref
BufferLike
BufferLike = {
from: {toString:string; }; }
Methods
from()
from(
input,encoding): {toString:string; }
Parameters
input
string
encoding
string
Returns
{ toString: string; }
toString()
toString(
encoding):string
Parameters
encoding
string
Returns
string
ParsedRef
ParsedRef = {
raw:string;scheme:RefScheme;value:string; }
raw
raw:
string
The original ref string, untouched.
scheme
scheme:
RefScheme
value
value:
string
The resolver key. For platform/url it is the ref string verbatim (the bare id or the full url) — the host resolver gets exactly this. For inline it is the data: body decoded to a JSON model doc string (NOT the raw URI) so the engine can JSON.parse it directly.
RefScheme
RefScheme =
"platform"|"url"|"inline"
Model reference parsing — a HOST utility for resolving which document to open/fetch (a page's root model id, a catalog pick at install time). NOT a runtime nested-model mechanism: the engine never resolves references during evaluation — the editor resolves one of these refs ONCE when installing (share.ts's installModel folds the resolved doc into a components[] entry).
A reference is a URI STRING dispatched by scheme into one of three forms:
- platform (default, a BARE id like
"abc-123"): the canonical case — every model saved today uses a bare platform id. Resolved by the host (DB / R2 / extension dir) which receives the bare id. - url (
http://…/https://…): a sub-model fetched from an arbitrary origin. Delegated to the host resolver (which receives the FULL url and decides how to fetch). A bundle pre-fetches it into the inline snapshot, so after bundling a url ref resolves offline like any other. - inline (
data:…URI): a self-contained snapshot carries the sub-model JSON in the ref itself (data URI body) — resolved by the engine with NO host call, so it works offline. (bundleModelcan either inline each ref as adata:URI or, by default, stash the docs in a siblingmodelsmap and keep the ref a bare id; both serve offline. See bundle.ts.)