Interface: Registry
Defined in: packages/core/src/registry.types.ts:30
The resolved block set — what compile and a renderer ask when a node names a block. Build one
with createRegistry; it holds a snapshot of the array it was given, so adding a block means
building a new registry rather than writing into this one.
Example
import { createRegistry, defineBlock } from "@nubbin/core";
import type { Registry } from "@nubbin/core";
import { z } from "zod";
const registry: Registry = createRegistry([
defineBlock({
name: "Hero",
schema: z.object({ title: z.string() }),
component: null,
version: 1,
slots: {},
}),
]);
const hero = registry.get("Hero");
if (hero !== undefined) {
hero.version; // 1
}
Methods
get()
get(
name):Block<StandardSchemaV1<unknown,unknown>,unknown> |undefined
Defined in: packages/core/src/registry.types.ts:38
Resolves one block by the name a document node carries.
Parameters
name
string
The block name, matched exactly — casing included.
Returns
Block<StandardSchemaV1<unknown, unknown>, unknown> | undefined
The registered block, or undefined when nothing carries that name. An unknown name
is a value to handle here; compile is where it becomes an unknown-block fault.
names()
names():
string[]
Defined in: packages/core/src/registry.types.ts:45
Lists what the registry holds — the names a palette or a compatibility check enumerates.
Returns
string[]
Every registered name, in the order the blocks were given to createRegistry. A
fresh array each call, so writing to it changes nothing.