ExtensionRegistry
Defined in: packages/core/src/extensions/registry.ts:91
A registry of x-* extension namespaces.
Remarks
Section titled “Remarks”Deliberately an instance rather than a module singleton: a host embedding two documents from different trust domains may want different registries, and a test wants a fresh one. The library ships no global registrations.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ExtensionRegistry():
ExtensionRegistry
Returns
Section titled “Returns”ExtensionRegistry
Methods
Section titled “Methods”extract()
Section titled “extract()”extract(
document):ExtractResult
Defined in: packages/core/src/extensions/registry.ts:139
Extract every extension block from a parsed document.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
document | unknown |
Returns
Section titled “Returns”Remarks
Section titled “Remarks”Walks schema-known object nodes — the document root, layers, sources — and
never descends into an opaque data payload, so a GeoJSON feature property
named x-anything is author data, not an extension block. This mirrors the
boundary the emitter’s projection uses; the two agree on where document
structure ends.
Every extension key is accounted for: a registered one is validated, normalized, and returned; an unregistered one is dropped with a warning; an invalid one is dropped with a warning naming the failure. Nothing is partially delivered.
has(
namespace):boolean
Defined in: packages/core/src/extensions/registry.ts:120
Whether a namespace has a registered schema.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
namespace | string |
Returns
Section titled “Returns”boolean
register()
Section titled “register()”register<
T>(namespace,definition):void
Defined in: packages/core/src/extensions/registry.ts:103
Register a namespace.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
namespace | string |
definition | ExtensionDefinition<T> |
Returns
Section titled “Returns”void
Throws
Section titled “Throws”if the namespace is already registered — a silent last-wins would let one registration quietly shadow another, and the whole point is that the trust contract for a namespace is unambiguous.
Throws
Section titled “Throws”if the namespace does not begin with x-, since only x-* keys
are passthrough; a non-x- namespace names a key the schema would reject.