/** * @fileoverview Block registry: maps block types to their definitions, with uniqueness enforcement and O(1) lookup. */ import type { AnyBlockDefinition, BlockDefinition, Registry } from "./types.js"; /** * Build a Registry from a readonly array of block definitions. * * Enforces type-key uniqueness — throws on duplicate `type` values. The * resulting object has O(1) lookup via an internal `Map`; the `list()` result * is frozen to prevent mutation. Accepts mutable arrays too — `readonly` here * is a minimum constraint (no mutation required), not a demand for immutability. * * @param definitions - Block definitions to register; each must have a unique `type`. * @returns A frozen `Registry` with `find`, `has`, `list`, and `size`. * @example * ```ts * import { createRegistry, builtinBlocks, defineBlock } from "pressedslip"; * import { z } from "zod"; * * const customBlock = defineBlock({ * type: "weather", * schema: z.object({ temp: z.number() }), * render: ({ data }) =>