API reference / @jsprismarine/content / ComponentRegistry
Class: ComponentRegistry<H>
Defined in: packages/content/src/components.ts:88
The component names one domain implements, each bound to a schema and a factory.
Resolution goes through ComponentRegistry.bind, which parses the value and builds the handlers in one step so the parameter type never escapes the factory that declared it.
Type Parameters
H
H extends HookSignatures<H>
Constructors
Constructor
new ComponentRegistry<
H>():ComponentRegistry<H>
Returns
ComponentRegistry<H>
Methods
bind()
bind(
name,value,context):ParseResult<BoundComponent<H>>
Defined in: packages/content/src/components.ts:143
Parses one component's value and binds its handlers.
Parameters
name
string
value
unknown
context
Returns
ParseResult<BoundComponent<H>>
The bound component, or the schema's message when the value does not parse, or a message naming the component when nothing is registered under it.
Throws
When the factory returns a hook it does not declare.
has()
has(
name):boolean
Defined in: packages/content/src/components.ts:121
Whether a factory is registered under the name.
Parameters
name
string
Returns
boolean
hooksOf()
hooksOf(
name):ReadonlySet<string>
Defined in: packages/content/src/components.ts:126
Every hook a component may implement, empty when the name is unknown.
Parameters
name
string
Returns
ReadonlySet<string>
names()
names(): readonly
string[]
Defined in: packages/content/src/components.ts:131
Every registered component name, in registration order.
Returns
readonly string[]
register()
register<
P>(factory):void
Defined in: packages/content/src/components.ts:96
Adds one component name.
Type Parameters
P
P
Parameters
factory
ComponentFactory<H, P>
Returns
void
Throws
When the name is already registered.