struct as it is written here: carrying the latest loaded version of
its schema (DXN.md §4.8), whatever version it says itself. A
struct whose name has no schema keeps its own version, or none.
Every writer goes through this — text, the formatter and binary — so
encoding never writes a version other than the latest, and never
writes one no schema stands behind.
a shallow copy, ready for one field to be overwritten.
The reverse of fetchStructModule: given an application value's
own class, finds the schema name it was registered under (if
any) — what lets automatic encode-time validation recognize a
plain JS class instance as "this is a Foo" without being told so
explicitly.
Looks up a compiled schema by struct name: the latest version, or
with version exactly that one. A name not loaded at all consults
the lazy resolver (if any), which loads every version it finds. Whether schemas
are all compiled up front or resolved on demand (a resolver reading
a file, calling a schema service, ...) is entirely the caller's
choice — this is what makes both paths look identical to
everything else. A named version never falls back to another:
a struct is only ever read with the schema it was written against.
Optionalversion: numberA lazy source of schemas, asked on a miss for a name: every version
it finds -- one compiled schema or a list of them, all loaded -- or
undefined. It throws (schema/compile) when the schemas it found
cannot be used: two files with one version, a file that is not the
version its name says, ...
Marks this registry as decoding strictly: a schema-backed struct
that carries a field its schema does not declare is refused
(schema/undeclared-field, DXN.md §4.7) instead of keeping it as
an extra field. A config loader decodes strictly; a message consumer
does not. decode/decodeBinary take it as strict: true.
The schema's materializer (DXN.md §4.8): called for every decoded
struct of name, whatever the version, with the schema's name, the
version the fields were read with and the fields keyed by string; it
answers the application's latest-version value, which is checked
against the latest schema, or throws.
Declares which JS class a schema's data is expected to be — used
only for {:reference, name} checks during encode-time
validation. Decode-time reference checks don't need this: they
carry an internal provenance marker regardless of materializer
shape (schema/validated.cjs).
compiled as version compiled.version of the schema name,
whether or not that version was loaded already — the unchecked
setter a resolver's answer goes through. Loading a document's
schemas goes through addStructSchema, a hot swap through
replaceStructSchema.
The reverse of putTag: registers how to turn an application
value (keyed by its constructor) back into @name value on
encode — decode-side dispatch happens by wire tag name, encode
needs to dispatch by JS class instead, so the two directions need
separate tables.
Marks (or unmarks) this registry as decoding a trusted source, vs.
an untrusted one -- the default. Currently the one thing this
affects is keyword: untrusted (the default) decodes it as
DXNKeyword, so no decode path is ever forced through the global
symbol registry's never-garbage-collected interning by the input;
trusted decodes it as a real, global Symbol.for. A decode's own
trusted: option wins over this.
symbol is deliberately unaffected either way.
Loads
compiledas a new version of the schemaname. A version that is already loaded is refused asschema/duplicate-version(DXN.md§4.8): two documents both claiming to beUserv3 is a mistake, not an update.