@niscorp/nova 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/dist/adapters/dom/components/index.cjs +4 -51
- package/dist/adapters/dom/components/index.cjs.map +1 -1
- package/dist/adapters/dom/index.cjs +22 -686
- package/dist/adapters/dom/index.cjs.map +1 -1
- package/dist/adapters/dom/index.js +3 -3
- package/dist/adapters/dom/server.cjs +14 -411
- package/dist/adapters/dom/server.cjs.map +1 -1
- package/dist/adapters/dom/server.js +3 -3
- package/dist/adapters/react/components/index.cjs +87 -562
- package/dist/adapters/react/components/index.cjs.map +1 -1
- package/dist/adapters/react/components/index.js +4 -4
- package/dist/adapters/react/index.cjs +97 -1815
- package/dist/adapters/react/index.cjs.map +1 -1
- package/dist/adapters/react/index.js +4 -4
- package/dist/adapters/tty/components/index.cjs +3 -44
- package/dist/adapters/tty/components/index.cjs.map +1 -1
- package/dist/adapters/tty/index.cjs +13 -5
- package/dist/adapters/tty/index.cjs.map +1 -1
- package/dist/adapters/tty/index.js +2 -2
- package/dist/adapters/vue/components/index.cjs +88 -639
- package/dist/adapters/vue/components/index.cjs.map +1 -1
- package/dist/adapters/vue/components/index.js +4 -4
- package/dist/adapters/vue/index.cjs +96 -962
- package/dist/adapters/vue/index.cjs.map +1 -1
- package/dist/adapters/vue/index.js +5 -5
- package/dist/agent/index.cjs +13 -151
- package/dist/agent/index.cjs.map +1 -1
- package/dist/chunk-5YQIAS4V.cjs +184 -0
- package/dist/chunk-5YQIAS4V.cjs.map +1 -0
- package/dist/{chunk-F2H7WP6R.js → chunk-7MATRNZZ.js} +5 -5
- package/dist/{chunk-F2H7WP6R.js.map → chunk-7MATRNZZ.js.map} +1 -1
- package/dist/chunk-AGEAMUQR.cjs +436 -0
- package/dist/chunk-AGEAMUQR.cjs.map +1 -0
- package/dist/chunk-D4PUWBN6.cjs +72 -0
- package/dist/chunk-D4PUWBN6.cjs.map +1 -0
- package/dist/chunk-ECFWPZGL.cjs +2117 -0
- package/dist/chunk-ECFWPZGL.cjs.map +1 -0
- package/dist/{chunk-VOD5JA4D.js → chunk-EG45GQOE.js} +3 -3
- package/dist/{chunk-VOD5JA4D.js.map → chunk-EG45GQOE.js.map} +1 -1
- package/dist/chunk-FSUMCJAR.cjs +646 -0
- package/dist/chunk-FSUMCJAR.cjs.map +1 -0
- package/dist/chunk-GV7UC3SS.cjs +33 -0
- package/dist/chunk-GV7UC3SS.cjs.map +1 -0
- package/dist/chunk-HYFNOF7Y.cjs +97 -0
- package/dist/chunk-HYFNOF7Y.cjs.map +1 -0
- package/dist/chunk-KOYRJXTI.cjs +123 -0
- package/dist/chunk-KOYRJXTI.cjs.map +1 -0
- package/dist/chunk-KW34ZKF5.cjs +12 -0
- package/dist/chunk-KW34ZKF5.cjs.map +1 -0
- package/dist/chunk-M3UFIUXK.cjs +318 -0
- package/dist/chunk-M3UFIUXK.cjs.map +1 -0
- package/dist/chunk-OE527MXF.cjs +49 -0
- package/dist/chunk-OE527MXF.cjs.map +1 -0
- package/dist/{chunk-DU2VIJAF.js → chunk-P5SJ3QXJ.js} +3 -3
- package/dist/{chunk-DU2VIJAF.js.map → chunk-P5SJ3QXJ.js.map} +1 -1
- package/dist/chunk-PBPUSZIQ.cjs +808 -0
- package/dist/chunk-PBPUSZIQ.cjs.map +1 -0
- package/dist/chunk-PMKWYOOX.cjs +64 -0
- package/dist/chunk-PMKWYOOX.cjs.map +1 -0
- package/dist/chunk-PNQY6OFB.cjs +132 -0
- package/dist/chunk-PNQY6OFB.cjs.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/{chunk-SVNK5NIK.js → chunk-QLFHYHJ2.js} +4 -4
- package/dist/{chunk-SVNK5NIK.js.map → chunk-QLFHYHJ2.js.map} +1 -1
- package/dist/{chunk-G4LSLLGI.js → chunk-RB4OMSPA.js} +5 -5
- package/dist/{chunk-G4LSLLGI.js.map → chunk-RB4OMSPA.js.map} +1 -1
- package/dist/chunk-UGG7MCX4.cjs +34 -0
- package/dist/chunk-UGG7MCX4.cjs.map +1 -0
- package/dist/chunk-WGZZKCJQ.cjs +157 -0
- package/dist/chunk-WGZZKCJQ.cjs.map +1 -0
- package/dist/{chunk-3JRTELLC.js → chunk-X5JTZ5LW.js} +3 -3
- package/dist/{chunk-3JRTELLC.js.map → chunk-X5JTZ5LW.js.map} +1 -1
- package/dist/{chunk-Y6XVPRYH.js → chunk-XUSKGJRI.js} +2 -2
- package/dist/chunk-XUSKGJRI.js.map +1 -0
- package/dist/chunk-Z7CS43ZT.cjs +808 -0
- package/dist/chunk-Z7CS43ZT.cjs.map +1 -0
- package/dist/chunk-ZYTWQZZC.cjs +623 -0
- package/dist/chunk-ZYTWQZZC.cjs.map +1 -0
- package/dist/devtools/index.cjs +13 -697
- package/dist/devtools/index.cjs.map +1 -1
- package/dist/devtools/index.js +2 -2
- package/dist/document/index.cjs +56 -301
- package/dist/document/index.cjs.map +1 -1
- package/dist/examples/index.cjs +6 -31
- package/dist/examples/index.cjs.map +1 -1
- package/dist/i18n/index.cjs +44 -292
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/index.cjs +335 -3954
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/migrations/index.cjs +7 -590
- package/dist/migrations/index.cjs.map +1 -1
- package/dist/reflect/index.cjs +85 -994
- package/dist/reflect/index.cjs.map +1 -1
- package/dist/reflect/index.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-Y6XVPRYH.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/react/context.ts","../../../src/shared/bindings/schemas.ts","../../../src/layout/schemas.ts","../../../src/shared/common.ts","../../../src/shared/bindings/paths.ts","../../../src/shared/errors.ts","../../../src/layout/guards.ts","../../../src/shared/bindings/scope.ts","../../../src/shared/bindings/resolve.ts","../../../src/i18n/phrases.ts","../../../src/i18n/swap.ts","../../../src/layout/head.ts","../../../src/layout/renderer.ts","../../../src/layout/adapter.ts","../../../src/layout/store.ts","../../../src/layout/registry.ts","../../../src/shared/event-bus/scope-dispatch.ts","../../../src/shell/slot-names.ts","../../../src/shell/head.ts","../../../src/shell/view.ts","../../../src/document/place-head.ts","../../../src/document/head-keeper.ts","../../../src/document/shell-head.ts","../../../src/adapters/react/head.tsx","../../../src/adapters/react/provider.tsx","../../../src/adapters/react/error-marker.tsx","../../../src/adapters/react/render-node.tsx","../../../src/adapters/react/render-tree.tsx","../../../src/adapters/react/error-boundary.tsx","../../../src/adapters/primitive-props.ts","../../../src/adapters/react/components/stack.tsx","../../../src/adapters/react/components/text.tsx","../../../src/adapters/react/components/input.tsx","../../../src/adapters/react/components/button.tsx","../../../src/adapters/react/components/box.tsx","../../../src/adapters/react/components/panel.tsx","../../../src/adapters/react/components/json-tree.tsx","../../../src/adapters/react/components/canvas-slot.tsx","../../../src/adapters/react/components/action-slot.tsx","../../../src/adapters/react/components/index.ts","../../../src/adapters/react/hooks/use-shell.ts","../../../src/adapters/react/hooks/use-canvas-render-tree.ts","../../../src/adapters/react/hooks/use-shell-render-tree.ts","../../../src/adapters/react/nova.tsx","../../../src/adapters/react/hooks/use-shell-state.ts","../../../src/adapters/react/hooks/use-canvas.ts","../../../src/adapters/react/hooks/use-action-data.ts","../../../src/adapters/react/hooks/use-action-status.ts","../../../src/adapters/react/hooks/use-render-tree.ts","../../../src/adapters/react/hooks/use-nova-dispatch.ts","../../../src/adapters/react/hooks/use-nova-publish.ts","../../../src/adapters/react/hooks/use-nova-registry.ts","../../../src/adapters/react/hooks/use-slot-wrapper.ts"],"names":["createContext","z","segments","evaluateSafe","exceedsDepth","depthRefusal","has","TAGS","useContext","useEffect","useMemo","jsx","Fragment","Component","createElement","useState","useRef","jsxs","EMPTY","useCallback","useSyncExternalStore"],"mappings":";;;;;;;;;AAgDO,IAAM,iBAAA,GAAoBA,oBAAk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,EAAM,OAAA,EAAS,IAAA,EAAK;AACzC,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,EAAG,CAAC,KAAA,EAAO,UAAU,CAAC,CAAA;AAKtB,EAAA,OAAOE,0BAAAA,CAAqB,SAAA,EAAW,WAAA,EAAa,WAAW,CAAA;AACjE;ACvDO,IAAM,kBAAkB,MAAoB;AACjD,EAAA,MAAM,GAAA,GAAMZ,iBAAW,iBAAiB,CAAA;AACxC,EAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,IAAA,MAAM,IAAI,MAAM,0DAA0D,CAAA;AAAA,EAC5E;AACA,EAAA,OAAO,GAAA,CAAI,QAAA;AACb;ACNO,IAAM,iBAAiB,MAAmB;AAC/C,EAAA,MAAM,GAAA,GAAMA,iBAAW,iBAAiB,CAAA;AACxC,EAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,IAAA,MAAM,IAAI,MAAM,yDAAyD,CAAA;AAAA,EAC3E;AACA,EAAA,OAAO,GAAA,CAAI,OAAA;AACb;ACFO,IAAM,kBAAkB,MAAwC;AACrE,EAAA,MAAM,GAAA,GAAMA,iBAAW,iBAAiB,CAAA;AACxC,EAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,IAAA,MAAM,IAAI,MAAM,0DAA0D,CAAA;AAAA,EAC5E;AACA,EAAA,OAAO,GAAA,CAAI,QAAA;AACb;ACPO,IAAM,cAAA,GAAiB,MAC5BA,gBAAAA,CAAW,iBAAiB,CAAA,EAAG","file":"index.cjs","sourcesContent":["import { createContext, type ComponentType, type FC, type ReactNode } from 'react';\nimport type { ActionDefinition } from '@action';\nimport type { ComponentRegistry } from '@layout';\nimport type { Shell } from '@shell';\nimport type { NovaComponent, NovaDispatch, NovaPublish } from './types';\n\n// ═══════════════════════════════════════════════════════════\n// Two React contexts:\n// - NovaRenderContext: registry + dispatch + publish (+ optional\n// slotWrapper). Required to render a layout. Does NOT require a shell.\n// - NovaShellContext: the shell itself. Consumers who want\n// shell-aware hooks (canvases, runtimes, state) need this.\n// ═══════════════════════════════════════════════════════════\n\n// An app-supplied component that wraps each action instance's rendered content\n// at the ActionSlot seam — the single pluggable point for cross-cutting\n// concerns: enter/leave animation, an auth/feature gate, logging, an error\n// boundary. Nova hands it IDENTITY (canvasId / instanceId / the action's\n// definition), never live state, and owns no timing — the wrapper (and whatever\n// it plugs in: framer-motion, react-transition-group, plain CSS) owns all of\n// that. The three identity fields are `undefined` while a slot is empty or\n// exiting; a presence-managing wrapper captured them when content was present.\nexport type SlotWrapperProps = {\n canvasId?: string;\n instanceId?: string;\n action?: ActionDefinition;\n children?: ReactNode;\n};\nexport type SlotWrapper = FC<SlotWrapperProps>;\n\nexport type NovaRenderContextValue = {\n registry: ComponentRegistry<NovaComponent>;\n dispatch: NovaDispatch;\n publish: NovaPublish;\n slotWrapper?: SlotWrapper;\n // used when a component name is unregistered — a permissive renderer (a\n // terminal on a reference kit) supplies one so unknown primitives render\n // their children instead of an error marker; strict consumers omit it.\n // Same seam as the DOM and TTY adapters' `fallback`.\n fallback?: NovaComponent;\n // host-specific leaf renderers. The DOM host renders a text node as a bare\n // string and an error node as a <span> — both crash a non-DOM react host\n // (ink requires every string inside <Text>). A host that isn't the DOM\n // supplies its own wrappers; browser consumers omit both.\n textWrapper?: ComponentType<{ children?: ReactNode }>;\n errorMarker?: ComponentType<{ code: string; message: string }>;\n};\n\nexport const NovaRenderContext = createContext<NovaRenderContextValue | undefined>(undefined);\nexport const NovaShellContext = createContext<Shell | undefined>(undefined);\n","import { z } from 'zod';\n\nexport const IfDirectiveSchema = z\n .object({\n $if: z.unknown().describe('Condition — resolved recursively, then checked for truthiness.'),\n $then: z.unknown().describe('Value when condition is truthy — resolved recursively.'),\n $else: z\n .unknown()\n .optional()\n .describe('Value when condition is falsy — resolved recursively.'),\n })\n .strict()\n .describe('Conditional value directive. Resolved at bind time.');\n\nexport type IfDirective = z.infer<typeof IfDirectiveSchema>;\n\nexport const ResolvableSchema = z\n .unknown()\n .describe(\n 'Any value. Strings support {{}} templates and bare $-paths. The data ROOT is '\n + '\"$.\" — a data key is ALWAYS \"$.key\" (\"{{$.rows.length}} found\", \"$.loading\"); '\n + '\"$key\" without the dot is INVALID. Loop variables (a `for` directive\\'s `as`) '\n + 'are \"$<name>.field\" (\"{{$row.title}}\"). Objects may be directives like '\n + '{$if,$then,$else}. Arrays and nested objects are walked recursively. '\n + 'Everything else is literal.',\n );\n","import { z } from 'zod';\nimport { ResolvableSchema } from '../shared/bindings/schemas';\n\n// ═══════════════════════════════════════════════════════════\n// Layout node schemas\n// ═══════════════════════════════════════════════════════════\n\nexport const LayoutPrimitiveSchema = z\n .union([z.string(), z.number(), z.boolean(), z.null()])\n .describe('A primitive layout value rendered as text.');\n\nexport type LayoutPrimitive = z.infer<typeof LayoutPrimitiveSchema>;\n\nexport type ComponentNode = {\n component: string;\n props?: Record<string, unknown>;\n children?: LayoutNode | LayoutNode[];\n ref?: string;\n model?: string;\n events?: Record<string, unknown>;\n};\n\nexport const ComponentNodeSchema: z.ZodType<ComponentNode> = z.lazy(() =>\n z\n .object({\n component: z.string().describe('The registry name of the component to render.'),\n props: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Component props; values may be bindings to be resolved at render time.'),\n children: z\n .union([LayoutNodeSchema, z.array(LayoutNodeSchema)])\n .optional()\n .describe('Child layout content (a single node or an array of nodes).'),\n ref: z.string().optional().describe('A stable identifier used to target this component from event handlers.'),\n model: z.string().optional().describe('A two-way binding path, e.g. \"$.name\".'),\n events: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Map of event name to event configuration handled by the action runtime.'),\n })\n .strict()\n .describe('A node that instantiates a component from the registry.'),\n);\n\nexport type ConditionalNode = {\n if: unknown;\n then: LayoutNode;\n else?: LayoutNode;\n};\n\nexport const ConditionalNodeSchema: z.ZodType<ConditionalNode> = z.lazy(() =>\n z\n .object({\n if: ResolvableSchema.describe('Resolvable value evaluated for truthiness.'),\n then: LayoutNodeSchema.describe('Layout to render when condition is truthy.'),\n else: LayoutNodeSchema.optional().describe('Layout to render when condition is falsy.'),\n })\n .strict()\n .describe('A node that conditionally renders one of two branches.'),\n);\n\nexport type LoopNode = {\n for: unknown;\n as: string;\n key?: string;\n do: LayoutNode;\n};\n\nexport const LoopNodeSchema: z.ZodType<LoopNode> = z.lazy(() =>\n z\n .object({\n for: ResolvableSchema.describe('Resolvable value that resolves to an iterable array.'),\n as: z.string().describe('Name to bind each iterated item under in the inner scope.'),\n key: z.string().optional().describe('Optional key path on each item used for stable identity.'),\n do: LayoutNodeSchema.describe('Layout rendered once per iterated item.'),\n })\n .strict()\n .describe('A node that iterates an array binding and renders a layout for each item.'),\n);\n\nexport const LayoutRefNodeSchema = z\n .object({\n ref: z.string().describe('Identifier of a layout stored in the layout store to inline at this position.'),\n })\n .strict()\n .describe('A reference to a stored layout, inlined during render.');\n\nexport type LayoutRefNode = z.infer<typeof LayoutRefNodeSchema>;\n\nexport const SlotNodeSchema = z\n .object({\n slot: z\n .string()\n .describe(\n 'Name of a slot placeholder. When an ActionFragment is composed with an action ' +\n '(a push/replace `with`), the fragment\\'s `{ slot: \"body\" }` node is replaced by ' +\n 'the composing action\\'s own layout. An unfilled slot renders nothing.',\n ),\n })\n .strict()\n .describe(\n 'A placeholder that a fragment-merge fills with a composing action\\'s layout. ' +\n 'Only meaningful inside an ActionFragment\\'s layout.',\n );\n\nexport type SlotNode = z.infer<typeof SlotNodeSchema>;\n\nexport type LayoutNode =\n | ComponentNode\n | ConditionalNode\n | LoopNode\n | LayoutRefNode\n | SlotNode\n | LayoutNode[]\n | LayoutPrimitive;\n\nexport const LayoutNodeSchema: z.ZodType<LayoutNode> = z.lazy(() =>\n z\n .union([\n ComponentNodeSchema,\n ConditionalNodeSchema,\n LoopNodeSchema,\n LayoutRefNodeSchema,\n SlotNodeSchema,\n z.array(LayoutNodeSchema),\n LayoutPrimitiveSchema,\n ])\n .describe('Any layout node: component, conditional, loop, layout ref, slot, array of nodes, or a primitive text value.'),\n);\n","// ═══════════════════════════════════════════════════════════\n// Shared primitives — common types + generic guards used to\n// narrow `unknown` across the package.\n// ═══════════════════════════════════════════════════════════\n\nexport type Unsubscribe = () => void;\n\nexport const isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isNumber = (value: unknown): value is number => typeof value === 'number';\n\nexport const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean';\n\nexport const isArray = (value: unknown): value is unknown[] => Array.isArray(value);\n\nexport const isNonNull = <T>(value: T | null | undefined): value is T =>\n value !== null && value !== undefined;\n\nexport const hasKey = <K extends string>(\n obj: unknown,\n key: K,\n): obj is Record<K, unknown> => isObject(obj) && key in obj;\n","import { isArray, isObject } from '../common';\n\n// ═══════════════════════════════════════════════════════════\n// Path helpers — get/set/delete on nested data structures.\n// Dot paths: \"a.b.0.c\". Numeric segments are array indices\n// when the parent is an array.\n// ═══════════════════════════════════════════════════════════\n\nconst splitPath = (path: string): string[] => {\n if (path.length === 0) return [];\n return path.split('.');\n};\n\nconst isIndex = (segment: string): boolean => /^\\d+$/.test(segment);\n\ntype Container = Record<string, unknown> | unknown[];\n\nconst cloneContainer = (value: unknown, nextSegment: string | undefined): Container => {\n if (isArray(value)) return value.slice();\n if (isObject(value)) return { ...value };\n if (nextSegment !== undefined && isIndex(nextSegment)) return [];\n return {};\n};\n\nconst writeSegment = (container: Container, segment: string, value: unknown): void => {\n if (isArray(container)) {\n if (isIndex(segment)) {\n const index = Number.parseInt(segment, 10);\n container[index] = value;\n }\n return;\n }\n container[segment] = value;\n};\n\nconst readSegment = (container: Container, segment: string): unknown => {\n if (isArray(container)) {\n if (!isIndex(segment)) return undefined;\n const index = Number.parseInt(segment, 10);\n return container[index];\n }\n return container[segment];\n};\n\nexport const getPath = (data: unknown, path: string): unknown => {\n const segments = splitPath(path);\n let current: unknown = data;\n for (const segment of segments) {\n if (current === undefined || current === null) return undefined;\n if (isArray(current)) {\n if (isIndex(segment)) {\n const index = Number.parseInt(segment, 10);\n current = current[index];\n continue;\n }\n if (segment === 'length') {\n current = current.length;\n continue;\n }\n return undefined;\n }\n if (isObject(current)) {\n if (segment in current) {\n current = current[segment];\n continue;\n }\n return undefined;\n }\n return undefined;\n }\n return current;\n};\n\nexport const setPath = (data: unknown, path: string, value: unknown): unknown => {\n const segments = splitPath(path);\n if (segments.length === 0) return value;\n\n const root = cloneContainer(data, segments[0]);\n let parent: Container = root;\n\n for (let i = 0; i < segments.length - 1; i += 1) {\n const segment = segments[i];\n const nextSegment = segments[i + 1];\n if (segment === undefined) continue;\n const existing = readSegment(parent, segment);\n const cloned = cloneContainer(existing, nextSegment);\n writeSegment(parent, segment, cloned);\n parent = cloned;\n }\n\n const last = segments[segments.length - 1];\n if (last !== undefined) writeSegment(parent, last, value);\n return root;\n};\n\nexport const deletePath = (data: unknown, path: string): unknown => {\n const segments = splitPath(path);\n if (segments.length === 0) return undefined;\n\n const root = cloneContainer(data, segments[0]);\n let parent: Container = root;\n\n for (let i = 0; i < segments.length - 1; i += 1) {\n const segment = segments[i];\n const nextSegment = segments[i + 1];\n if (segment === undefined) continue;\n const existing = readSegment(parent, segment);\n if (existing === undefined || existing === null) return root;\n const cloned = cloneContainer(existing, nextSegment);\n writeSegment(parent, segment, cloned);\n parent = cloned;\n }\n\n const last = segments[segments.length - 1];\n if (last === undefined) return root;\n if (isArray(parent)) {\n if (isIndex(last)) {\n const index = Number.parseInt(last, 10);\n parent.splice(index, 1);\n }\n } else {\n delete parent[last];\n }\n return root;\n};\n","import type { z } from 'zod';\n\n// ═══════════════════════════════════════════════════════════\n// Error codes\n// ═══════════════════════════════════════════════════════════\n\nexport const ErrorCodes = {\n render: 'RENDER_ERROR',\n componentNotFound: 'COMPONENT_NOT_FOUND',\n layoutRefNotFound: 'LAYOUT_REF_NOT_FOUND',\n definitionValidation: 'DEFINITION_VALIDATION_ERROR',\n unknownAction: 'UNKNOWN_ACTION',\n unknownFragment: 'UNKNOWN_FRAGMENT',\n unknownFunction: 'UNKNOWN_FUNCTION',\n shellDisposed: 'SHELL_DISPOSED',\n lifecycle: 'LIFECYCLE_ERROR',\n mutation: 'MUTATION_ERROR',\n runaway: 'RUNAWAY_CHAIN',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];\n\nexport type NovaErrorContext = Record<string, unknown>;\n\n// ═══════════════════════════════════════════════════════════\n// Base error — classes are permitted here because these are\n// the only thrown error types; identity + instanceof are needed.\n//\n// Subclasses are added when there is a real throw site. Do not\n// add dead exports.\n// ═══════════════════════════════════════════════════════════\n\nexport class NovaError extends Error {\n readonly code: ErrorCode;\n readonly context: NovaErrorContext | undefined;\n\n constructor(\n code: ErrorCode,\n message: string,\n context?: NovaErrorContext,\n options?: { cause?: unknown },\n ) {\n super(message, options);\n this.name = 'NovaError';\n this.code = code;\n this.context = context;\n }\n}\n\nexport class RenderError extends NovaError {\n constructor(message: string, context?: NovaErrorContext, options?: { cause?: unknown }) {\n super(ErrorCodes.render, message, context, options);\n this.name = 'RenderError';\n }\n}\n\nexport type ComponentNotFoundContext = NovaErrorContext & { name: string };\n\nexport class ComponentNotFoundError extends NovaError {\n constructor(\n message: string,\n context: ComponentNotFoundContext,\n options?: { cause?: unknown },\n ) {\n super(ErrorCodes.componentNotFound, message, context, options);\n this.name = 'ComponentNotFoundError';\n }\n}\n\nexport type LayoutRefNotFoundContext = NovaErrorContext & { ref: string };\n\nexport class LayoutRefNotFoundError extends NovaError {\n constructor(\n message: string,\n context: LayoutRefNotFoundContext,\n options?: { cause?: unknown },\n ) {\n super(ErrorCodes.layoutRefNotFound, message, context, options);\n this.name = 'LayoutRefNotFoundError';\n }\n}\n\nexport type DefinitionValidationFailure = {\n id: string;\n issues: z.core.$ZodIssue[];\n};\n\nexport type DefinitionValidationContext = NovaErrorContext & {\n failures: DefinitionValidationFailure[];\n};\n\nexport class DefinitionValidationError extends NovaError {\n constructor(\n message: string,\n context: DefinitionValidationContext,\n options?: { cause?: unknown },\n ) {\n super(ErrorCodes.definitionValidation, message, context, options);\n this.name = 'DefinitionValidationError';\n }\n}\n\nexport type UnknownActionContext = NovaErrorContext & { actionId: string };\n\nexport class UnknownActionError extends NovaError {\n constructor(\n message: string,\n context: UnknownActionContext,\n options?: { cause?: unknown },\n ) {\n super(ErrorCodes.unknownAction, message, context, options);\n this.name = 'UnknownActionError';\n }\n}\n\nexport type UnknownFragmentContext = NovaErrorContext & { fragmentId: string };\n\nexport class UnknownFragmentError extends NovaError {\n constructor(\n message: string,\n context: UnknownFragmentContext,\n options?: { cause?: unknown },\n ) {\n super(ErrorCodes.unknownFragment, message, context, options);\n this.name = 'UnknownFragmentError';\n }\n}\n\nexport class ShellDisposedError extends NovaError {\n constructor(message: string, context?: NovaErrorContext, options?: { cause?: unknown }) {\n super(ErrorCodes.shellDisposed, message, context, options);\n this.name = 'ShellDisposedError';\n }\n}\n\nexport type UnknownFunctionContext = NovaErrorContext & { name: string };\n\nexport class UnknownFunctionError extends NovaError {\n constructor(name: string, options?: { cause?: unknown }) {\n super(\n ErrorCodes.unknownFunction,\n `Unknown function: \"${name}\". Is it registered in shell config's \\`functions\\` map?`,\n { name },\n options,\n );\n this.name = 'UnknownFunctionError';\n }\n}\n\nexport type LifecycleHook = 'mount' | 'unmount' | 'suspend' | 'resume';\n\nexport type LifecycleErrorContext = NovaErrorContext & {\n hook?: LifecycleHook;\n instanceId?: string;\n};\n\nexport class LifecycleError extends NovaError {\n constructor(\n message: string,\n context?: LifecycleErrorContext,\n options?: { cause?: unknown },\n ) {\n super(ErrorCodes.lifecycle, message, context, options);\n this.name = 'LifecycleError';\n }\n}\n\nexport type MutationErrorContext = NovaErrorContext & {\n op: string;\n path: string;\n reason: 'missing' | 'wrong-type';\n};\n\nexport class MutationError extends NovaError {\n constructor(\n message: string,\n context: MutationErrorContext,\n options?: { cause?: unknown },\n ) {\n super(ErrorCodes.mutation, message, context, options);\n this.name = 'MutationError';\n }\n}\n","import { hasKey, isObject } from '../shared/common';\nimport type {\n ComponentNode,\n ConditionalNode,\n LayoutNode,\n LayoutPrimitive,\n LayoutRefNode,\n LoopNode,\n SlotNode,\n} from './schemas';\n\nexport const isLayoutPrimitive = (value: unknown): value is LayoutPrimitive =>\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean';\n\nexport const isComponentNode = (value: unknown): value is ComponentNode =>\n hasKey(value, 'component') && typeof value['component'] === 'string';\n\nexport const isConditionalNode = (value: unknown): value is ConditionalNode =>\n hasKey(value, 'if') && hasKey(value, 'then') && !hasKey(value, 'for');\n\nexport const isLoopNode = (value: unknown): value is LoopNode =>\n hasKey(value, 'for') && hasKey(value, 'as') && hasKey(value, 'do');\n\nexport const isLayoutRefNode = (value: unknown): value is LayoutRefNode =>\n isObject(value) &&\n hasKey(value, 'ref') &&\n typeof value['ref'] === 'string' &&\n !hasKey(value, 'component') &&\n Object.keys(value).length === 1;\n\nexport const isSlotNode = (value: unknown): value is SlotNode =>\n isObject(value) &&\n hasKey(value, 'slot') &&\n typeof value['slot'] === 'string' &&\n Object.keys(value).length === 1;\n\nexport const isLayoutNode = (value: unknown): value is LayoutNode =>\n isLayoutPrimitive(value) ||\n Array.isArray(value) ||\n isComponentNode(value) ||\n isConditionalNode(value) ||\n isLoopNode(value) ||\n isLayoutRefNode(value) ||\n isSlotNode(value);\n","import type { Scope, ScopeChain } from './types';\n\nexport const createScopeChain = (data: Scope): ScopeChain => [data];\n\nexport const pushScope = (chain: ScopeChain, scope: Scope): ScopeChain => [scope, ...chain];\n","import { evaluateSafe } from '@niscorp/prism';\nimport { hasKey, isArray, isObject } from '../common';\nimport { getPath } from './paths';\nimport type { ScopeChain } from './types';\n\n// ═══════════════════════════════════════════════════════════\n// Unified value resolver.\n//\n// One function — `resolve` — handles every binding site uniformly.\n//\n// String semantics:\n// 1. \"{{ expr }}\" (sole expression) → raw value of expr (type preserved)\n// 2. \"...{{expr}}...\" → interpolated string\n// 3. \"$.x\" or \"$ident...\" → raw value of path (type preserved)\n// 4. anything else → literal string\n//\n// Array → mapped recursively.\n// Object → walked recursively, OR treated as an `$if` directive.\n// Primitives → returned as-is.\n//\n// Path expressions resolve via `resolvePath`, which uses the ScopeChain\n// (innermost first). An optional `extras` map injects keyed scopes for\n// templates (e.g. `{ '@error': errObj }`); longest-prefix match wins.\n// ═══════════════════════════════════════════════════════════\n\nconst TEMPLATE_REGEX = /\\{\\{\\s*([^}]+?)\\s*\\}\\}/g;\nconst SOLE_TEMPLATE_REGEX = /^\\{\\{\\s*([^}]+?)\\s*\\}\\}$/;\nconst BARE_PATH_REGEX = /^\\$(\\.|[A-Za-z_]|$)/;\n\nexport type ExtraScopes = Record<string, unknown>;\n\nconst matchExtra = (expression: string, extras: ExtraScopes): string | undefined => {\n let matched: string | undefined;\n for (const key of Object.keys(extras)) {\n if (expression === key || expression.startsWith(`${key}.`)) {\n if (matched === undefined || key.length > matched.length) matched = key;\n }\n }\n return matched;\n};\n\nconst resolveExtraExpression = (\n expression: string,\n matchedKey: string,\n extras: ExtraScopes,\n): unknown => {\n const root = extras[matchedKey];\n if (expression === matchedKey) return root;\n const rest = expression.slice(matchedKey.length + 1);\n if (rest.length === 0) return root;\n return getPath(root, rest);\n};\n\nconst walkFromScopeHead = (head: unknown, restSegments: readonly string[]): unknown => {\n if (restSegments.length === 0) return head;\n return getPath(head, restSegments.join('.'));\n};\n\nexport const resolvePath = (\n path: string,\n chain: ScopeChain,\n extras: ExtraScopes = {},\n): unknown => {\n const extraKey = matchExtra(path, extras);\n if (extraKey !== undefined) return resolveExtraExpression(path, extraKey, extras);\n\n if (!path.startsWith('$')) return undefined;\n if (path === '$') return chain[0];\n\n const afterDollar = path.slice(1);\n\n if (afterDollar.startsWith('.')) {\n const rest = afterDollar.slice(1);\n if (rest.length === 0) return chain[0];\n const segments = rest.split('.');\n const head = segments[0];\n if (head === undefined) return undefined;\n for (const scope of chain) {\n if (hasKey(scope, head)) {\n return walkFromScopeHead(scope[head], segments.slice(1));\n }\n }\n return undefined;\n }\n\n const segments = afterDollar.split('.');\n const varName = segments[0];\n if (varName === undefined || varName.length === 0) return undefined;\n for (const scope of chain) {\n if (hasKey(scope, varName)) {\n return walkFromScopeHead(scope[varName], segments.slice(1));\n }\n }\n return undefined;\n};\n\nconst stringify = (value: unknown): string => {\n if (value === null || value === undefined) return '';\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n try {\n return JSON.stringify(value);\n } catch {\n return '';\n }\n};\n\nconst isTruthy = (value: unknown): boolean => {\n if (value === null || value === undefined) return false;\n if (value === false) return false;\n if (value === 0) return false;\n if (value === '') return false;\n if (isArray(value) && value.length === 0) return false;\n return true;\n};\n\n// Directives — evaluated objects keyed by an operator (`$if`, `$eq`, …). Each\n// resolves its operands and returns a value. Add an operator here and it works\n// everywhere bindings are resolved; later operators (`$gte`, `$and`, …) slot in\n// the same way.\ntype Directive = (node: Record<string, unknown>, chain: ScopeChain, extras: ExtraScopes) => unknown;\n\nconst DIRECTIVES: Record<string, Directive> = {\n $if: (node, chain, extras) => {\n if (isTruthy(resolve(node.$if, chain, extras))) return resolve(node.$then, chain, extras);\n if (hasKey(node, '$else')) return resolve(node.$else, chain, extras);\n return undefined;\n },\n $eq: (node, chain, extras) => {\n const args = isArray(node.$eq) ? node.$eq : [];\n return resolve(args[0], chain, extras) === resolve(args[1], chain, extras);\n },\n // True when the operand path resolves to a present value. The structural\n // counterpart to `$eq`: discriminate a union by which key a branch carries\n // (`{ $exists: \"$.shape.component\" }`) rather than a shared tag's value.\n $exists: (node, chain, extras) => resolve(node.$exists, chain, extras) !== undefined,\n // Read an array element by a (dynamic) index: `{ $at: [\"$.results\", \"$.i\"] }`.\n // An optional third arg pulls one field off the element: `[\"$.results\", \"$.i\",\n // \"id\"]`. Returns undefined when the array/index doesn't resolve.\n $at: (node, chain, extras) => {\n const args = isArray(node.$at) ? node.$at : [];\n const arr = resolve(args[0], chain, extras);\n const index = Number(resolve(args[1], chain, extras));\n if (!isArray(arr) || Number.isNaN(index)) return undefined;\n const element = arr[index];\n const field = args[2];\n return field !== undefined && isObject(element) ? element[String(field)] : element;\n },\n // THE WHOLE TRANSFORM GRAMMAR, BEHIND ONE EXPLICIT DOOR. The directives\n // above stay the small binding set; a value that needs a real transformation\n // — a join, a projection, a group — says so out loud: `{ $prism: <node> }`\n // evaluates the node with prism against the action's ROOT data. One grammar,\n // one evaluator, nothing ambient — a prism-shaped object OUTSIDE this\n // wrapper stays what it always was, a plain object walked for strings.\n //\n // The quiet failure this replaces was worse than a crash: an unrecognised\n // op-shaped value passed through `resolve` as structure, landed in data, and\n // rendered as garbage three screens later. Inside the wrapper, a bad node\n // resolves to undefined — absent, not wrong.\n $prism: (node, chain) => {\n const result = evaluateSafe(node.$prism as never, (chain[0] ?? {}) as never);\n return result.ok ? result.data : undefined;\n },\n};\n\nconst directiveOf = (value: Record<string, unknown>): Directive | undefined => {\n for (const key of Object.keys(value)) {\n const directive = DIRECTIVES[key];\n if (directive !== undefined) return directive;\n }\n return undefined;\n};\n\nconst resolveString = (value: string, chain: ScopeChain, extras: ExtraScopes): unknown => {\n const sole = value.match(SOLE_TEMPLATE_REGEX);\n if (sole !== null) {\n const expr = sole[1];\n if (expr === undefined) return value;\n return resolvePath(expr.trim(), chain, extras);\n }\n\n if (value.includes('{{')) {\n return value.replace(TEMPLATE_REGEX, (_match: string, expression: string): string => {\n const resolved = resolvePath(expression.trim(), chain, extras);\n return stringify(resolved);\n });\n }\n\n if (BARE_PATH_REGEX.test(value)) {\n return resolvePath(value, chain, extras);\n }\n\n if (matchExtra(value, extras) !== undefined) {\n return resolvePath(value, chain, extras);\n }\n\n return value;\n};\n\nexport const resolve = (\n value: unknown,\n chain: ScopeChain,\n extras: ExtraScopes = {},\n): unknown => {\n if (typeof value === 'string') return resolveString(value, chain, extras);\n if (isArray(value)) return value.map((entry) => resolve(entry, chain, extras));\n if (isObject(value)) {\n const directive = directiveOf(value);\n if (directive !== undefined) return directive(value, chain, extras);\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n out[key] = resolve(value[key], chain, extras);\n }\n return out;\n }\n return value;\n};\n","// ═══════════════════════════════════════════════════════════\n// NOVA IS LANGUAGE-BLIND, the same way it is surface-blind.\n//\n// The core renders a layout into a `RenderNode` tree and knows nothing about\n// what language the words in it are. This area adds one late pass over that\n// tree — swap the words, leave the structure — plus the harvester that tells\n// you which words there are to swap.\n//\n// WHY A LATE PASS AND NOT A `$t` IN THE LAYOUT. Both work; they cost\n// differently. A key-per-string layout (`label: '@t.people.add'`) is precise\n// and makes every layout in the application unreadable — the file stops saying\n// what it draws. A late pass leaves the layouts as the readable English they\n// already are and moves the whole problem to one walk, at the price of keying\n// the dictionary on the source string rather than on an invented id.\n//\n// The price is real and worth naming: English-as-key cannot distinguish two\n// senses of one word. \"Book\" the verb and \"Book\" the noun are one key here and\n// two words in German. When that bites, the answer is not to abandon the pass\n// — it is to disambiguate that one string at its author site, and a `$t`\n// directive is the natural place for it. The two compose; this is the layer\n// that makes the other one optional rather than mandatory.\n//\n// WHAT THIS PASS CANNOT DO, and where the rest of the work goes:\n// - Open-ended formatted values — dates, money, counts. \"Fri 14 Mar\" has\n// unbounded cardinality and no dictionary will ever hold it. Those are\n// formatted at their source with a locale (prism's `$localeDate`,\n// `$localeMoney`, `$localeNumber`).\n// - Anything not in the tree: a server error message, a notification body.\n// ═══════════════════════════════════════════════════════════\n\n/** Source phrase → the words a reader of this locale should see. */\nexport type Phrasebook = Readonly<Record<string, string>>;\n\n// WHICH STRINGS IN A TREE ARE PROSE, declared by the host rather than guessed.\n//\n// A render tree is mostly not prose. It carries person names, ids, css values,\n// tone words, icon names and row data, and a pass that translated every string\n// it found would rename a member called \"Pass\" the first time somebody bought\n// one. So the host names the carriers, and everything else is left alone.\nexport type PhraseKeys = {\n // Prop names whose string values are prose: `label`, `title`, `placeholder`.\n // Matched at ANY depth inside a prop value, which is what makes a spec prop\n // work — a `Table`'s `columns: [{ label }]` and a `Select`'s\n // `options: [{ label }]` are the same rule as a bare `label`.\n props?: readonly string[];\n // Suffixes marking a DATA field as a display string. An app that spells its\n // read-time display fields `status_display`, `term_display` declares\n // `['_display']` once here, and every closed-set word a query manufactures\n // becomes translatable without the app naming them one by one.\n //\n // Only for CLOSED sets. A `_display` field holding a formatted date or an\n // amount will simply miss, every time, and should be formatted with a locale\n // at its source instead.\n suffixes?: readonly string[];\n // Translate bare text nodes (a layout's literal children). Default: true.\n text?: boolean;\n};\n\nexport const DEFAULT_PHRASE_KEYS: Required<Pick<PhraseKeys, 'props' | 'text'>> = {\n // A starting set, not a standard — an app with its own vocabulary passes its\n // own. Deliberately absent: `name`, `value`, `id`, `icon`, `tone`, `variant`,\n // `key`. Those carry data or design tokens, and translating them is how a\n // person called \"Active\" gets renamed.\n props: [\n 'label',\n 'title',\n 'subtitle',\n 'heading',\n 'eyebrow',\n 'lead',\n 'blurb',\n 'placeholder',\n 'hint',\n 'help',\n 'message',\n 'empty',\n 'emptyHint',\n 'emptyLabel',\n 'noMatch',\n 'caption',\n 'description',\n 'confirmLabel',\n 'cancelLabel',\n 'alt',\n 'tooltip',\n ],\n text: true,\n};\n\nexport type PhraseKeyMatcher = {\n isProse: (key: string) => boolean;\n text: boolean;\n};\n\nexport const matcherFor = (keys: PhraseKeys | undefined): PhraseKeyMatcher => {\n const props = new Set(keys?.props ?? DEFAULT_PHRASE_KEYS.props);\n const suffixes = keys?.suffixes ?? [];\n return {\n isProse: (key: string): boolean => props.has(key) || suffixes.some((suffix) => key.endsWith(suffix)),\n text: keys?.text ?? DEFAULT_PHRASE_KEYS.text,\n };\n};\n\n// A string that is a BINDING resolves to data at render time, so it is never a\n// phrase: harvesting `'$.member.person_name'` would put a path in the\n// dictionary and translating it would do nothing.\n//\n// Three forms, matching what the resolver recognises\n// (`shared/bindings/resolve.ts`): a bare `$` path, a `{{ }}` template, and an\n// `@`-prefixed EXTRA scope. The last one is easy to forget and shows up\n// immediately — a trigger's `{ set: 'x', value: '@event.payload.theme_id' }`\n// is a step's plumbing, and a harvester without this rule fills a language\n// file with several dozen of them.\nconst BARE_PATH = /^\\$(\\.|[A-Za-z_]|$)/;\nconst EXTRA_SCOPE = /^@[A-Za-z_]/;\n\nexport const isBinding = (value: string): boolean =>\n BARE_PATH.test(value) || EXTRA_SCOPE.test(value) || value.includes('{{');\n\n// Worth translating at all: a non-empty string that is not a binding and is not\n// obviously machine vocabulary. The last clause is a cheap guard against\n// harvesting css values and tokens that happen to sit at an allowlisted key.\nexport const isPhrase = (value: string): boolean => {\n const trimmed = value.trim();\n if (trimmed === '' || isBinding(trimmed)) return false;\n // A phrase has a letter in it. '—', '18:30', '#fff', '100%' do not.\n return /\\p{L}/u.test(trimmed);\n};\n","import { isArray, isObject } from '../shared/common';\nimport { matcherFor } from './phrases';\nimport { isPhrase } from './phrases';\nimport type { PhraseKeys, Phrasebook } from './phrases';\n\n// ═══════════════════════════════════════════════════════════\n// The swap itself — over VALUES, knowing nothing about trees.\n//\n// Deliberately free of any layout import, because the renderer needs it and\n// the renderer is what layout IS. `translate.ts` (the tree walk) and\n// `layout/renderer.ts` (the mint) are two callers of this one engine, and the\n// whole point of the file is that they can never disagree about what a swap\n// means.\n// ═══════════════════════════════════════════════════════════\n\nexport type Pass = {\n phrases: Phrasebook;\n isProse: (key: string) => boolean;\n text: boolean;\n onMiss: ((phrase: string, where: string) => void) | undefined;\n};\n\nexport type PassOptions = {\n phrases?: Phrasebook;\n keys?: PhraseKeys;\n onMiss?: (phrase: string, where: string) => void;\n};\n\nconst EMPTY: Phrasebook = {};\n\n// ACTIVE OR ABSENT, decided once. A host that named neither a book nor a key\n// set is not doing i18n, and pays nothing: `undefined` here means the renderer\n// skips every branch below, and a `{ phrase, slots }` object passes through as\n// the object it is.\n//\n// A key set WITHOUT a book is the source language, and is NOT nothing: patterns\n// still have to be filled, because a counted phrase reaches the glass as a\n// structure and nobody downstream knows how to read it. That is the one job\n// this pass keeps doing when there is nothing to translate.\nexport const passFor = (options: PassOptions | undefined): Pass | undefined => {\n if (options === undefined) return undefined;\n if (options.phrases === undefined && options.keys === undefined) return undefined;\n const matcher = matcherFor(options.keys);\n return {\n phrases: options.phrases ?? EMPTY,\n isProse: matcher.isProse,\n text: matcher.text,\n onMiss: options.onMiss,\n };\n};\n\nexport const swap = (value: string, where: string, pass: Pass): string => {\n if (!isPhrase(value)) return value;\n const hit = pass.phrases[value];\n if (hit !== undefined) return hit;\n // Trailing/leading whitespace is a layout accident, not part of the phrase.\n // Trying the trimmed form keeps `'Save '` from being a second dictionary\n // entry nobody remembers to fill in.\n const trimmed = value.trim();\n if (trimmed !== value) {\n const onTrimmed = pass.phrases[trimmed];\n if (onTrimmed !== undefined) return value.replace(trimmed, onTrimmed);\n }\n pass.onMiss?.(trimmed, where);\n return value;\n};\n\n// A PATTERN: a counted phrase, translated WHOLE and filled here — the one\n// point that has the book. `{ phrase: '{n} of {total}', slots: { n: 1,\n// total: 12 } }` becomes `'1 von 12'`: the pattern is a dictionary row like\n// any other, so cardinality stays out of the book. A string slot is offered\n// to the book too — a composed sentence's fragments (\"somebody enquires\")\n// are vocabulary in their own right — and everything else interpolates as\n// itself. An empty book fills the holes and translates nothing, which is\n// exactly what a source-language session needs.\nconst isPattern = (value: Record<string, unknown>): value is { phrase: string; slots: Record<string, unknown> } =>\n typeof value['phrase'] === 'string' && isObject(value['slots']);\n\nconst fillPattern = (pattern: { phrase: string; slots: Record<string, unknown> }, where: string, pass: Pass): string =>\n swap(pattern.phrase, where, pass).replace(/\\{([A-Za-z_][A-Za-z0-9_]*)\\}/g, (hole, name: string) => {\n const slot = pattern.slots[name];\n if (slot === undefined || slot === null) return hole;\n return typeof slot === 'string' && isPhrase(slot) ? swap(slot, `${where}.${name}`, pass) : String(slot);\n });\n\n// A book that translates nothing — for filling a pattern outside a render,\n// which is the only thing left to do with one when there are no words to swap.\nconst SOURCE: Pass = { phrases: EMPTY, isProse: () => true, text: true, onMiss: undefined };\n\n// FILL A COUNTED PHRASE THAT NEVER WENT THROUGH A RENDER.\n//\n// The renderer fills patterns on the way to a screen, so nothing downstream of\n// it needs this. What does need it is everything UPSTREAM: a check that reads\n// an entry straight from the engine, a fixture, an exporter — anywhere a\n// `{ phrase, slots }` is held as data rather than shown as words. Nova defines\n// the shape, so nova reads it; a host writing its own copy of this loop is how\n// two spellings of one rule start drifting.\n//\n// Anything that is not a pattern comes back untouched, so it is safe to call\n// on a whole column of mixed values.\nexport const fillPhrase = (value: unknown): unknown => {\n if (!isObject(value) || !isPattern(value)) return value;\n return fillPattern(value, '', SOURCE);\n};\n\n// Walk a prop VALUE. Depth matters: a spec prop is where the repeated structure\n// of a screen lives (`columns: [{ label }]`, `options: [{ label }]`), so the\n// rule cannot be \"top-level props only\" without missing most of a table.\n//\n// Returns the value it was given when nothing under it changed. Identity is\n// load-bearing rather than tidy: a source-language render must produce the\n// props object it produced before this existed, or every untranslated session\n// pays a rebuild for a walk that did nothing.\nexport const walkValue = (value: unknown, prose: boolean, where: string, pass: Pass): unknown => {\n if (typeof value === 'string') return prose ? swap(value, where, pass) : value;\n if (isArray(value)) {\n let changed = false;\n const out = value.map((entry, index) => {\n // An array inherits its key's proseness — `options: ['Yes', 'No']` is as\n // much prose as `options: [{ label: 'Yes' }]`.\n const next = walkValue(entry, prose, `${where}[${String(index)}]`, pass);\n if (next !== entry) changed = true;\n return next;\n });\n return changed ? out : value;\n }\n if (isObject(value)) {\n if (prose && isPattern(value)) return fillPattern(value, where, pass);\n let changed = false;\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const next = walkValue(entry, pass.isProse(key), `${where}.${key}`, pass);\n if (next !== entry) changed = true;\n out[key] = next;\n }\n return changed ? out : value;\n }\n return value;\n};\n","// ═══════════════════════════════════════════════════════════\n// THE HEAD — `nova:head` is the document's <head>, as a node in a layout.\n//\n// A document has a part nobody sees on the screen: its title, the sentence\n// that describes it, the card shown where a link to it is pasted. That part\n// is written the way the rest of the screen is — a layout node, its children\n// bound to the action's data — and travels the way the rest does, in the\n// render tree.\n//\n// Its children are the elements a head holds, named as HTML names them:\n// `nova:title`, `nova:meta`, `nova:link`, `nova:script`. A child's props are\n// that element's ATTRIBUTES, written as given. Nova keeps no list of them, so\n// any `name`, `property` or `rel` there is — or will be — can be said without\n// nova learning it.\n//\n// Nothing here is drawn on the screen. No adapter builds an element for a head\n// or for anything in it, and no registry has to hold the names. Whoever writes\n// the document reads the elements off the tree (`headOf`) and writes them into\n// its <head>.\n//\n// WHAT A HEAD DOES NOT HOLD is what runs or styles: a script that executes, a\n// stylesheet, a <base>, an instruction to the browser (`http-equiv`), a handler\n// attribute. A layout is data, and data that reaches every page must not be\n// able to run. Those stay in the app's own index.html, which holds anything.\n//\n// This file holds no schema on purpose: a terminal that only reads a head off\n// the wire needs the names and the shape, and nothing to validate with.\n// ═══════════════════════════════════════════════════════════\n\n// Namespaced as a package's own in-layout components are (`loom:field`), so\n// none can be a name an app's kit already uses for something else.\nexport const HEAD_NAME = 'nova:head';\nexport const HEAD_TITLE_NAME = 'nova:title';\nexport const HEAD_META_NAME = 'nova:meta';\nexport const HEAD_LINK_NAME = 'nova:link';\nexport const HEAD_SCRIPT_NAME = 'nova:script';\n\n// The head and what it holds: the names a layout may use with no registry\n// entry behind them.\nexport const HEAD_NAMES: readonly string[] = [HEAD_NAME, HEAD_TITLE_NAME, HEAD_META_NAME, HEAD_LINK_NAME, HEAD_SCRIPT_NAME];\n\n// One element of a head, as data: what to write, wherever a head is written.\nexport type HeadElement = {\n tag: 'title' | 'meta' | 'link' | 'script';\n // as the layout gave them, in the order it gave them\n attributes: Record<string, string>;\n // a title's words; a script's data, as JSON\n text?: string;\n};\n\n// What two elements both say, when they say the same thing — the later one\n// then takes the earlier one's place. A document has one title, one <meta> of\n// a given name or property, one canonical address. Anything else stands beside\n// its like: two alternates, two data blocks.\nexport const headKeyOf = (element: Pick<HeadElement, 'tag' | 'attributes'>): string | undefined => {\n const said = (name: string): string | undefined => {\n const found = Object.entries(element.attributes).find(([key]) => key.toLowerCase() === name)?.[1].trim().toLowerCase();\n return found === undefined || found === '' ? undefined : found;\n };\n if (element.tag === 'title') return 'title';\n if (element.tag === 'meta') {\n const [name, property] = [said('name'), said('property')];\n if (name !== undefined) return `meta name ${name}`;\n return property === undefined ? undefined : `meta property ${property}`;\n }\n if (element.tag === 'link') return (said('rel') ?? '').split(/\\s+/).includes('canonical') ? 'link canonical' : undefined;\n return undefined;\n};\n","import { isArray } from '../shared/common';\nimport {\n ComponentNotFoundError,\n LayoutRefNotFoundError,\n NovaError,\n RenderError,\n} from '../shared/errors';\nimport { createScopeChain, getPath, pushScope, resolve } from '../shared/bindings';\nimport type { ScopeChain } from '../shared/bindings';\nimport { isBinding } from '../i18n/phrases';\nimport { passFor, swap, walkValue } from '../i18n/swap';\nimport type { Pass } from '../i18n/swap';\nimport {\n isComponentNode,\n isConditionalNode,\n isLayoutPrimitive,\n isLayoutRefNode,\n isLoopNode,\n isSlotNode,\n} from './guards';\nimport { HEAD_NAMES } from './head';\nimport type { ComponentNode, LayoutNode } from './schemas';\nimport type {\n DataStoreView,\n ModelBindingDescriptor,\n RenderContext,\n RenderErrorNode,\n RenderNode,\n RenderOnError,\n} from './types';\n\n// ═══════════════════════════════════════════════════════════\n// Renderer — converts a LayoutNode tree into a framework-agnostic\n// RenderNode[] tree. Renders children in try/catch boundaries so a\n// single broken subtree does not poison siblings, unless strict mode\n// is enabled. All errors flow through the ctx.onError telemetry hook.\n// ═══════════════════════════════════════════════════════════\n\nconst noopOnError: RenderOnError = (_error: NovaError): void => {\n // default — errors silently dropped if no handler provided\n};\n\ntype InternalRenderContext = {\n store: RenderContext['store'];\n registry: RenderContext['registry'];\n strict: boolean;\n onError: RenderOnError;\n scopePaths: string[];\n // Undefined when the host named no book and no keys — the whole language\n // apparatus is then absent rather than idling, and a `{ phrase, slots }`\n // object passes through as the object it is.\n pass: Pass | undefined;\n // Where a miss was found, coarse: the chain of component names above it.\n // Only maintained while a pass is active, since nothing else reads it.\n where: string;\n};\n\nconst textNode = (value: string): RenderNode => ({ type: 'text', value });\n\nconst fragment = (children: RenderNode[]): RenderNode => ({ type: 'fragment', children });\n\nconst errorNode = (\n error: NovaError,\n nodeRef: string | undefined,\n): RenderErrorNode => ({\n type: 'error',\n code: error.code,\n message: error.message,\n ...(nodeRef === undefined ? {} : { nodeRef }),\n});\n\nconst toRenderError = (err: unknown): NovaError => {\n if (err instanceof NovaError) return err;\n const message = err instanceof Error ? err.message : String(err);\n return new RenderError(message, {}, { cause: err });\n};\n\n// Resolve a `$.x.y` or `$loopVar.y` binding to an absolute data path\n// (used to construct stable model binding descriptors inside loops).\nconst resolveDataPath = (\n binding: string,\n scopePaths: string[],\n): string | undefined => {\n if (!binding.startsWith('$')) return undefined;\n const after = binding.slice(1);\n if (after.startsWith('.')) return after.slice(1);\n const segments = after.split('.');\n const head = segments[0];\n if (head === undefined || head.length === 0) return undefined;\n for (let i = scopePaths.length - 1; i >= 0; i -= 1) {\n const entry = scopePaths[i];\n if (entry === undefined) continue;\n const eq = entry.indexOf('=');\n if (eq < 0) continue;\n const key = entry.slice(0, eq);\n if (key !== head) continue;\n const rooted = entry.slice(eq + 1);\n const rest = segments.slice(1).join('.');\n if (rest.length === 0) return rooted;\n return `${rooted}.${rest}`;\n }\n return undefined;\n};\n\nconst makeAutoRef = (componentName: string, path: string): string =>\n `auto-${componentName}-${path}`;\n\nconst renderNode = (\n node: LayoutNode,\n chain: ScopeChain,\n ctx: InternalRenderContext,\n): RenderNode[] => {\n if (node === null) return [textNode('')];\n if (typeof node === 'string') {\n const resolved = resolve(node, chain);\n if (resolved === undefined || resolved === null) return [textNode('')];\n const value = String(resolved);\n // A LITERAL text child is prose; a BOUND one is data wearing a text\n // position, and offering it to the book is how a member called \"Pass\" gets\n // renamed. Nothing but the renderer can tell those apart — by the time a\n // tree exists both are the same plain string — which is why this rule\n // could not be written in `translateRenderTree` and can be written here.\n if (ctx.pass === undefined || !ctx.pass.text || isBinding(node)) return [textNode(value)];\n return [textNode(swap(value, `${ctx.where}#text`, ctx.pass))];\n }\n if (isLayoutPrimitive(node)) {\n return [textNode(String(node))];\n }\n if (isArray(node)) {\n const children = renderChildArray(node, chain, ctx);\n return [fragment(children)];\n }\n if (isLayoutRefNode(node)) {\n const target = ctx.store.get(node.ref);\n if (target === undefined) {\n throw new LayoutRefNotFoundError(`Layout ref not found: ${node.ref}`, { ref: node.ref });\n }\n return renderNode(target, chain, ctx);\n }\n if (isSlotNode(node)) {\n // A slot is filled at fragment-merge time (fillSlots). One that survives to\n // render was never filled — render nothing.\n return [];\n }\n if (isConditionalNode(node)) {\n const condition = resolve(node.if, chain);\n const truthy =\n condition !== undefined &&\n condition !== null &&\n condition !== false &&\n condition !== 0 &&\n condition !== '';\n const branchTruthy = isArray(condition) ? condition.length > 0 : truthy;\n if (branchTruthy) return renderNode(node.then, chain, ctx);\n if (node.else !== undefined) return renderNode(node.else, chain, ctx);\n return [];\n }\n if (isLoopNode(node)) {\n const items = resolve(node.for, chain);\n if (!isArray(items)) return [];\n const loopBasePath = typeof node.for === 'string'\n ? resolveDataPath(node.for, ctx.scopePaths)\n : undefined;\n const out: RenderNode[] = [];\n items.forEach((item, index) => {\n // Each iteration binds three reserved loop vars: the element (`$<as>`),\n // its position (`$index`), and the array itself (`$items`). `$items`\n // lets a control inside the loop edit the whole list — remove or reorder\n // an element — not just its own value. Both `index` and `items` are\n // reserved names; an `as` of `'index'` or `'items'` would shadow them.\n const innerChain = pushScope(chain, { [node.as]: item, index, items });\n // `$items` resolves to a *writable* path (so `model: \"$items\"` works) only\n // when the loop's source is itself a resolvable path; a literal-array loop\n // exposes the value but stays read-only, exactly as `$<as>` does.\n const nextScopePaths =\n loopBasePath === undefined\n ? ctx.scopePaths\n : [...ctx.scopePaths, `${node.as}=${loopBasePath}.${index}`, `items=${loopBasePath}`];\n const innerCtx: InternalRenderContext = { ...ctx, scopePaths: nextScopePaths };\n // Stamp a stable React-identity key on each item's output: the value at\n // `node.key` (e.g. the row id), or the index when no key path is given.\n // This is what lets looped rows share a `ref` (the trigger target) without\n // colliding as React keys. `withKey` (in render-tree) prefers it over ref.\n const idKey = node.key !== undefined ? getPath(item, node.key) : index;\n const rendered = safeRenderSingle(node.do, innerChain, innerCtx, undefined);\n rendered.forEach((rn, sub) => {\n out.push({ ...rn, key: rendered.length === 1 ? String(idKey) : `${String(idKey)}:${sub}` });\n });\n });\n return [fragment(out)];\n }\n if (isComponentNode(node)) {\n return [renderComponent(node, chain, ctx)];\n }\n return [];\n};\n\nconst renderComponent = (\n node: ComponentNode,\n chain: ScopeChain,\n ctx: InternalRenderContext,\n): RenderNode => {\n // A head and what it holds are drawn by nobody, so no kit has anything to\n // register for them.\n if (!HEAD_NAMES.includes(node.component) && !ctx.registry.has(node.component)) {\n throw new ComponentNotFoundError(\n `Component not found in registry: ${node.component}`,\n { name: node.component },\n );\n }\n // THE ONE PLACE A PROP BECOMES A WORD ON A SCREEN. The swap belongs here\n // rather than in a later walk over the finished tree: the value is already\n // in hand, so translating it costs one lookup instead of a second traversal\n // of everything that was just built.\n //\n // Unlike a text child, a BOUND prop is translated — that is the whole\n // `_display` mechanism, where a query manufactures a closed-set word and a\n // read puts it on the screen. What protects data here is the KEY: `label` is\n // prose, `name` is not, and no value ever votes on the question.\n const pass = ctx.pass;\n const at = pass === undefined ? '' : `${ctx.where}/${node.component}`;\n const props: Record<string, unknown> = Object.fromEntries(\n Object.entries(node.props ?? {}).map(([k, v]) => {\n const resolved = resolve(v, chain);\n if (pass === undefined) return [k, resolved];\n return [k, walkValue(resolved, pass.isProse(k), `${at}.${k}`, pass)];\n }),\n );\n const children = renderChildren(node.children, chain, pass === undefined ? ctx : { ...ctx, where: at });\n\n let model: ModelBindingDescriptor | undefined;\n if (node.model !== undefined) {\n const resolvedPath = resolveDataPath(node.model, ctx.scopePaths);\n if (resolvedPath !== undefined) {\n const ref = node.ref ?? makeAutoRef(node.component, resolvedPath);\n model = { path: resolvedPath, ref };\n // Two-way binding: if the component doesn't already have an explicit\n // `value` prop, auto-derive it from the model expression so the\n // displayed value tracks the data store. Without this, controlled\n // inputs always show their initial value because nothing updates the\n // `value` prop on re-render.\n if (!('value' in props)) {\n props['value'] = resolve(node.model, chain);\n }\n }\n }\n\n const component: RenderNode = {\n type: 'component',\n name: node.component,\n props,\n children,\n ...(node.ref === undefined ? {} : { ref: node.ref }),\n ...(model === undefined ? {} : { model }),\n };\n return component;\n};\n\nconst safeRenderSingle = (\n node: LayoutNode,\n chain: ScopeChain,\n ctx: InternalRenderContext,\n nodeRef: string | undefined,\n): RenderNode[] => {\n try {\n return renderNode(node, chain, ctx);\n } catch (err) {\n const novaError = toRenderError(err);\n if (ctx.strict) throw novaError;\n ctx.onError(novaError);\n return [errorNode(novaError, nodeRef)];\n }\n};\n\nconst renderChildArray = (\n nodes: LayoutNode[],\n chain: ScopeChain,\n ctx: InternalRenderContext,\n): RenderNode[] => {\n const out: RenderNode[] = [];\n for (const child of nodes) out.push(...safeRenderSingle(child, chain, ctx, undefined));\n return out;\n};\n\nconst renderChildren = (\n children: LayoutNode | LayoutNode[] | undefined,\n chain: ScopeChain,\n ctx: InternalRenderContext,\n): RenderNode[] => {\n if (children === undefined) return [];\n if (isArray(children)) return renderChildArray(children, chain, ctx);\n return safeRenderSingle(children, chain, ctx, undefined);\n};\n\nconst toInternal = (ctx: RenderContext): InternalRenderContext => ({\n store: ctx.store,\n registry: ctx.registry,\n strict: ctx.strict ?? false,\n onError: ctx.onError ?? noopOnError,\n scopePaths: [],\n // Built once per render call. The matcher compiles a Set and a suffix list,\n // and doing that per node would make the cheapest branch the expensive one.\n pass: passFor({\n ...(ctx.phrases === undefined ? {} : { phrases: ctx.phrases }),\n ...(ctx.phraseKeys === undefined ? {} : { keys: ctx.phraseKeys }),\n ...(ctx.onPhraseMiss === undefined ? {} : { onMiss: ctx.onPhraseMiss }),\n }),\n where: '',\n});\n\nexport const renderLayout = (\n node: LayoutNode,\n data: Record<string, unknown>,\n ctx: RenderContext,\n): RenderNode[] => {\n const internal = toInternal(ctx);\n return safeRenderSingle(node, createScopeChain(data), internal, undefined);\n};\n\n// Object-form alias for renderLayout. Same semantics, named parameters —\n// so the caller doesn't have to remember the positional order of\n// (layout, data, ctx) and so `data` can be omitted when the layout has\n// no resolvables.\nexport type RenderOptions = {\n layout: LayoutNode;\n data?: Record<string, unknown>;\n store: RenderContext['store'];\n registry: RenderContext['registry'];\n strict?: boolean;\n onError?: RenderOnError;\n phrases?: RenderContext['phrases'];\n phraseKeys?: RenderContext['phraseKeys'];\n onPhraseMiss?: RenderContext['onPhraseMiss'];\n};\n\nexport const render = (options: RenderOptions): RenderNode[] =>\n renderLayout(options.layout, options.data ?? {}, {\n store: options.store,\n registry: options.registry,\n ...(options.strict === undefined ? {} : { strict: options.strict }),\n ...(options.onError === undefined ? {} : { onError: options.onError }),\n ...(options.phrases === undefined ? {} : { phrases: options.phrases }),\n ...(options.phraseKeys === undefined ? {} : { phraseKeys: options.phraseKeys }),\n ...(options.onPhraseMiss === undefined ? {} : { onPhraseMiss: options.onPhraseMiss }),\n });\n\n// Render a layout reading its root data from a DataStore view. Used by the\n// action runtime so layout and action share a single data store instance.\nexport const renderLayoutFromStore = (\n node: LayoutNode,\n store: DataStoreView,\n ctx: RenderContext,\n): RenderNode[] => {\n const internal = toInternal(ctx);\n return safeRenderSingle(node, createScopeChain(store.get()), internal, undefined);\n};\n\nexport type { ScopeChain };\n","import type { RenderNode } from './types';\n\n// ═══════════════════════════════════════════════════════════\n// Adapter helpers — framework-agnostic pieces every adapter\n// (React, Vue, …) needs to render a RenderNode tree the same\n// way. See packages/nova/ADAPTER.md for the full contract.\n// ═══════════════════════════════════════════════════════════\n\n// Names of the props an adapter injects on rendered components:\n// `RenderNode.model` → NOVA_MODEL_PROP ({ ref, path }),\n// `RenderNode.ref` → NOVA_REF_PROP (string). Constants so all\n// adapters inject identically and components can rely on them.\nexport const NOVA_MODEL_PROP = 'novaModel';\nexport const NOVA_REF_PROP = 'novaRef';\n\n// Stable identity for a RenderNode within its sibling list.\n// Loop identity (stamped from LoopNode.key/index) wins over ref: a shared\n// `ref` across looped rows is an event-target id, not a list key.\nexport const renderNodeKey = (node: RenderNode, index: number): string => {\n if (node.key !== undefined) return `k:${node.key}`;\n if (node.type === 'component') {\n if (node.ref !== undefined) return `c:${node.ref}`;\n return `c:${node.name}:${index}`;\n }\n if (node.type === 'text') return `t:${index}`;\n if (node.type === 'fragment') return `f:${index}`;\n return `e:${node.code}:${index}`;\n};\n","import { DefinitionValidationError } from '../shared/errors';\nimport { depthRefusal, exceedsDepth } from '@niscorp/strata';\nimport {\n isComponentNode,\n isConditionalNode,\n isLayoutRefNode,\n isLoopNode,\n} from './guards';\nimport { LayoutNodeSchema, type LayoutNode } from './schemas';\nimport type { LayoutStore } from './types';\n\nexport const createLayoutStore = (): LayoutStore => {\n const layouts = new Map<string, LayoutNode>();\n\n const get = (id: string): LayoutNode | undefined => layouts.get(id);\n\n const set = (id: string, layout: LayoutNode): void => {\n // Before the schema: a deep enough layout overflows it (strata depth.ts).\n if (exceedsDepth(layout)) {\n throw new DefinitionValidationError(`Invalid layout for id \"${id}\"`, { failures: [{ id, issues: [{ code: 'custom', path: [], message: depthRefusal(), input: undefined }] }] });\n }\n const result = LayoutNodeSchema.safeParse(layout);\n if (!result.success) {\n throw new DefinitionValidationError(`Invalid layout for id \"${id}\"`, {\n failures: [{ id, issues: result.error.issues }],\n });\n }\n layouts.set(id, layout);\n };\n\n const remove = (id: string): void => {\n layouts.delete(id);\n };\n\n const list = (): string[] => Array.from(layouts.keys());\n\n const resolveReferences = (layout: LayoutNode): LayoutNode => {\n if (isLayoutRefNode(layout)) {\n const target = layouts.get(layout.ref);\n if (target === undefined) return layout;\n return resolveReferences(target);\n }\n if (Array.isArray(layout)) {\n return layout.map(resolveReferences);\n }\n if (isComponentNode(layout)) {\n const children = layout.children;\n let resolvedChildren: LayoutNode | LayoutNode[] | undefined;\n if (children === undefined) {\n resolvedChildren = undefined;\n } else if (Array.isArray(children)) {\n resolvedChildren = children.map(resolveReferences);\n } else {\n resolvedChildren = resolveReferences(children);\n }\n return {\n ...layout,\n ...(resolvedChildren === undefined ? {} : { children: resolvedChildren }),\n };\n }\n if (isConditionalNode(layout)) {\n return {\n ...layout,\n then: resolveReferences(layout.then),\n ...(layout.else === undefined ? {} : { else: resolveReferences(layout.else) }),\n };\n }\n if (isLoopNode(layout)) {\n return {\n ...layout,\n do: resolveReferences(layout.do),\n };\n }\n return layout;\n };\n\n return { get, set, delete: remove, list, resolveReferences };\n};\n","import type {\n ComponentEntry,\n ComponentMeta,\n ComponentRegistry,\n RegistrationInput,\n} from './types';\n\n// ═══════════════════════════════════════════════════════════\n// Component registry\n//\n// Stores `{component, meta}` entries keyed by name. Components\n// can carry a static `.meta` property; `registerAll` picks it up\n// automatically. Explicit meta passed to `register`/`registerAll`\n// wins over a component's static meta.\n// ═══════════════════════════════════════════════════════════\n\nconst hasOwn = (value: object, key: string): boolean =>\n Object.prototype.hasOwnProperty.call(value, key);\n\nconst isComponentMeta = (value: unknown): value is ComponentMeta => {\n if (typeof value !== 'object' || value === null) return false;\n // Meta is an open bag with optional fields; any plain object qualifies.\n return true;\n};\n\nconst extractStaticMeta = <TComponent>(component: TComponent): ComponentMeta | undefined => {\n if (typeof component !== 'function' && (typeof component !== 'object' || component === null)) {\n return undefined;\n }\n const host: object = component;\n if (!hasOwn(host, 'meta')) return undefined;\n const candidate = (host as { meta: unknown }).meta;\n if (!isComponentMeta(candidate)) return undefined;\n return candidate;\n};\n\nconst isEntryShape = <TComponent>(\n value: RegistrationInput<TComponent>,\n): value is { component: TComponent; meta?: ComponentMeta } => {\n if (typeof value !== 'object' || value === null) return false;\n return hasOwn(value, 'component');\n};\n\nexport const createComponentRegistry = <TComponent = unknown>(): ComponentRegistry<TComponent> => {\n const entries = new Map<string, ComponentEntry<TComponent>>();\n\n const register = (name: string, component: TComponent, meta?: ComponentMeta): void => {\n const staticMeta = extractStaticMeta(component);\n const merged: ComponentMeta = { ...(staticMeta ?? {}), ...(meta ?? {}) };\n entries.set(name, { component, meta: merged });\n };\n\n const registerAll = (batch: Record<string, RegistrationInput<TComponent>>): void => {\n for (const name of Object.keys(batch)) {\n const input = batch[name];\n if (input === undefined) continue;\n if (isEntryShape<TComponent>(input)) {\n register(name, input.component, input.meta);\n } else {\n register(name, input);\n }\n }\n };\n\n const get = (name: string): ComponentEntry<TComponent> | undefined => entries.get(name);\n\n const has = (name: string): boolean => entries.has(name);\n\n const list = (): string[] => Array.from(entries.keys());\n\n return { register, registerAll, get, has, list };\n};\n","import type { NovaEvent } from './schemas';\n\n// Wraps a dispatch function so every event passing through it gets stamped\n// with `origin` (the dispatching action instance's id) unless it already\n// carries one — a re-dispatch keeps its original origin. Adapters wrap the\n// dispatch they hand to an instance's rendered subtree with this, so the\n// runtime delivers UI events to that instance's own triggers only. This is\n// routing semantics: never reimplement it per adapter.\nexport const scopeDispatch = (\n dispatch: (event: NovaEvent) => void,\n origin: string,\n): ((event: NovaEvent) => void) => {\n return (event) => dispatch(event.origin === undefined ? { ...event, origin } : event);\n};\n","// ═══════════════════════════════════════════════════════════\n// Slot component name constants.\n//\n// Every framework adapter (React, future Vue/Svelte/etc.) must\n// register components under these names in its ComponentRegistry\n// to participate in shell/canvas layout rendering:\n//\n// CANVAS_SLOT_NAME — renders a canvas by id (props: canvasId?)\n// ACTION_SLOT_NAME — renders an action instance by id (props: instanceId?)\n//\n// The shell uses these names in its default layouts and when\n// flattening a render tree for non-React consumers (evaluators,\n// export, testing), so they are part of the package's public\n// contract — not React-only.\n// ═══════════════════════════════════════════════════════════\n\nexport const CANVAS_SLOT_NAME = 'CanvasSlot';\nexport const ACTION_SLOT_NAME = 'ActionSlot';\n","import { HEAD_LINK_NAME, HEAD_META_NAME, HEAD_NAME, HEAD_SCRIPT_NAME, HEAD_TITLE_NAME, headKeyOf } from '../layout/head';\nimport type { HeadElement } from '../layout/head';\nimport type { RenderNode } from '../layout';\nimport type { RenderApi } from './types';\nimport { ACTION_SLOT_NAME, CANVAS_SLOT_NAME } from './slot-names';\n\n// ═══════════════════════════════════════════════════════════\n// The head a screen has, read off its render tree.\n//\n// The frame is walked in the order it is drawn, into each canvas where its\n// slot stands and into each instance on it, and every `nova:head` it meets\n// gives its elements in turn. A screen can hold more than one head — the\n// shell's chrome says what holds on every screen, an action says its own, a\n// dialog opens over a page. An element that says the same thing as an earlier\n// one (the title, a <meta> of that name) takes its place; anything else stands\n// beside what came before.\n//\n// What a head may not hold is refused here, once, for every writer: the\n// element is left out and the reason is given. See ../layout/head.\n// ═══════════════════════════════════════════════════════════\n\nexport type ScreenHead = {\n // what the document's head is to hold, in the order the screen said it\n elements: HeadElement[];\n // the actions whose instances said any of it (none: only the shell's chrome did)\n actions: string[];\n // what a head held that it may not — left out, each with why\n refused: string[];\n};\n\ntype ComponentNode = Extract<RenderNode, { type: 'component' }>;\ntype Read = { element: HeadElement } | { refused: string } | undefined;\n\nconst ATTRIBUTE_NAME = /^[A-Za-z][A-Za-z0-9:._-]*$/;\n// a data block: a type no browser runs\nconst DATA_TYPE = /^application\\/([a-z0-9.-]+\\+)?json$/i;\n\n// A prop, as the attribute it is written as — or nothing, when it says nothing.\nconst written = (value: unknown): string | undefined => {\n if (typeof value === 'string') return value.trim() === '' ? undefined : value;\n if (typeof value === 'number') return String(value);\n return value === true ? '' : undefined;\n};\n\n// An element's attributes, from its props — or why it may not be written.\nconst attributesOf = (what: string, props: Record<string, unknown>, skip: readonly string[] = []): { attributes: Record<string, string> } | { refused: string } => {\n const attributes: Record<string, string> = {};\n for (const [name, value] of Object.entries(props)) {\n if (skip.includes(name)) continue;\n if (!ATTRIBUTE_NAME.test(name)) return { refused: `${what}: \"${name}\" is not an attribute’s name` };\n if (/^on/i.test(name)) return { refused: `${what}: \\`${name}\\` is a handler, and a layout does not run` };\n const text = written(value);\n if (text !== undefined) attributes[name] = text;\n }\n return { attributes };\n};\n\nconst has = (attributes: Record<string, string>, name: string): boolean => Object.keys(attributes).some((key) => key.toLowerCase() === name);\nconst valueOf = (attributes: Record<string, string>, name: string): string => Object.entries(attributes).find(([key]) => key.toLowerCase() === name)?.[1] ?? '';\n\nconst textOf = (nodes: readonly RenderNode[]): string =>\n nodes.map((node) => (node.type === 'text' ? node.value : node.type === 'fragment' ? textOf(node.children) : '')).join('');\n\nconst titleOf = (node: ComponentNode): Read => {\n const text = textOf(node.children).trim();\n return text === '' ? undefined : { element: { tag: 'title', attributes: {}, text } };\n};\n\nconst metaOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_META_NAME, node.props);\n if ('refused' in read) return read;\n if (has(read.attributes, 'http-equiv')) return { refused: `${HEAD_META_NAME}: \\`http-equiv\\` instructs the browser, and a layout does not` };\n // nothing to say yet: its value is not answered\n return has(read.attributes, 'content') ? { element: { tag: 'meta', attributes: read.attributes } } : undefined;\n};\n\nconst linkOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_LINK_NAME, node.props);\n if ('refused' in read) return read;\n if (valueOf(read.attributes, 'rel').toLowerCase().split(/\\s+/).includes('stylesheet')) return { refused: `${HEAD_LINK_NAME}: a stylesheet styles the page, and a layout does not` };\n return has(read.attributes, 'href') ? { element: { tag: 'link', attributes: read.attributes } } : undefined;\n};\n\nconst scriptOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_SCRIPT_NAME, node.props, ['data']);\n if ('refused' in read) return read;\n if (has(read.attributes, 'src')) return { refused: `${HEAD_SCRIPT_NAME}: a script with a \\`src\\` runs, and a layout does not` };\n const type = valueOf(read.attributes, 'type');\n if (!DATA_TYPE.test(type)) return { refused: `${HEAD_SCRIPT_NAME}: only a data block may be written (a JSON \\`type\\`), and \"${type}\" is not one` };\n const data = node.props['data'];\n if (data === undefined || data === null || data === '') return undefined;\n return { element: { tag: 'script', attributes: read.attributes, text: JSON.stringify(data) } };\n};\n\nconst READERS: Record<string, (node: ComponentNode) => Read> = {\n [HEAD_TITLE_NAME]: titleOf,\n [HEAD_META_NAME]: metaOf,\n [HEAD_LINK_NAME]: linkOf,\n [HEAD_SCRIPT_NAME]: scriptOf,\n};\n\nexport const isHeadNode = (node: RenderNode): boolean => node.type === 'component' && node.name === HEAD_NAME;\n\nexport const headOf = (api: Pick<RenderApi, 'frame' | 'canvasTree'>): ScreenHead | undefined => {\n let heads = 0;\n const said: { element: HeadElement; action: string | undefined }[] = [];\n const refused: string[] = [];\n // a canvas whose own tree names it again would never end\n const open = new Set<string>();\n\n const hold = (nodes: readonly RenderNode[], action: string | undefined): void => {\n for (const node of nodes) {\n if (node.type === 'fragment') {\n hold(node.children, action);\n continue;\n }\n if (node.type === 'error') {\n refused.push(`${HEAD_NAME}: ${node.message}`);\n continue;\n }\n // text between a head's elements is nothing\n if (node.type !== 'component') continue;\n const read = READERS[node.name];\n if (read === undefined) {\n refused.push(`${HEAD_NAME}: \"${node.name}\" is not something a head holds`);\n continue;\n }\n const found = read(node);\n if (found === undefined) continue;\n if ('refused' in found) {\n refused.push(found.refused);\n continue;\n }\n const key = headKeyOf(found.element);\n const earlier = key === undefined ? -1 : said.findIndex((other) => headKeyOf(other.element) === key);\n if (earlier >= 0) said.splice(earlier, 1);\n said.push({ element: found.element, action });\n }\n };\n\n const walk = (nodes: readonly RenderNode[], action: string | undefined): void => {\n for (const node of nodes) {\n if (node.type === 'fragment') {\n walk(node.children, action);\n continue;\n }\n if (node.type !== 'component') continue;\n if (node.name === HEAD_NAME) {\n heads += 1;\n hold(node.children, action);\n continue;\n }\n if (node.name === CANVAS_SLOT_NAME) {\n const canvasId = node.props['canvasId'];\n if (typeof canvasId !== 'string' || canvasId === '' || open.has(canvasId)) continue;\n open.add(canvasId);\n walk(api.canvasTree(canvasId), undefined);\n open.delete(canvasId);\n continue;\n }\n const definitionId = node.name === ACTION_SLOT_NAME ? node.props['definitionId'] : undefined;\n walk(node.children, typeof definitionId === 'string' ? definitionId : action);\n }\n };\n\n walk(api.frame(), undefined);\n if (heads === 0) return undefined;\n const actions = [...new Set(said.flatMap((one) => (one.action === undefined ? [] : [one.action])))];\n return { elements: said.map((one) => one.element), actions, refused };\n};\n","import type { RenderNode } from '../layout';\nimport type { RenderApi, Shell } from './types';\nimport { isHeadNode } from './head';\nimport { chainsInFlight } from './chains';\nimport { ACTION_SLOT_NAME } from './slot-names';\n\n// ═══════════════════════════════════════════════════════════\n// A shell, as something an adapter draws.\n//\n// Every adapter that draws a SERVED screen draws it through `RenderApi` — the\n// frame, a tree per canvas, events up, messages across — and has always been\n// handed one by a transport (moss's socket wire). A shell that lives in the\n// same process as its adapter is the other case that type was written for, and\n// this is it: the shell's own trees, read as they stand, and its own dispatch.\n// The DOM and TTY adapters draw a local shell through this exactly as they draw\n// a remote one; nothing about them knows the difference.\n//\n// It is also what makes a shell DRAWABLE AHEAD OF TIME. A build runs the app's\n// own boot, waits for the screen to be whole (`shellSettled`), and has an\n// adapter draw this view to markup; the browser runs the same boot and draws\n// the same view over that markup. Where the shell lives was never the\n// adapter's business.\n// ═══════════════════════════════════════════════════════════\n\nexport type ShellView = {\n api: RenderApi;\n // Called after the shell changed — coalesced, so a burst of changes (a press\n // that sets three keys) is one call. Returns the unsubscribe.\n subscribe: (listener: () => void) => () => void;\n};\n\n// NO VISIBLE CONTENT IS AN EMPTY TREE. A canvas whose layout renders nothing but\n// empty text and empty wrappers is handed to an adapter as `[]`, so an adapter\n// collapses the chrome around it on `length` alone, knowing nothing about node\n// shapes. An ActionSlot marker is a boundary, not content — what is inside it\n// decides — and a head is the document's, not something the screen shows.\n// One rule for a canvas that is served and one that is local, so a frame looks\n// the same over both.\nexport const hasVisibleContent = (nodes: readonly RenderNode[]): boolean =>\n nodes.some((node) => {\n if (node.type === 'text') return node.value !== '';\n if (node.type === 'fragment') return hasVisibleContent(node.children);\n if (node.type === 'component' && node.name === ACTION_SLOT_NAME) return hasVisibleContent(node.children);\n if (isHeadNode(node)) return false;\n return true;\n });\n\n// One canvas, as an adapter is handed it.\nexport const canvasTreeOf = (shell: Shell, canvasId: string): RenderNode[] => {\n const tree = shell.flattenRenderTree(shell.getCanvasRenderTree(canvasId));\n return hasVisibleContent(tree) ? tree : [];\n};\n\nexport const shellView = (shell: Shell): ShellView => ({\n api: {\n frame: () => shell.getShellRenderTree(),\n canvasTree: (canvasId) => canvasTreeOf(shell, canvasId),\n // An event that names no origin belongs to the canvas's ACTIVE instance — on\n // a card deck that is the only one drawn. One that names its own (an\n // adapter stamps it at the instance boundary, `scopeDispatch`) keeps it. A\n // canvas with nothing mounted dispatches unstamped.\n dispatch: (canvasId, event) => {\n const active = shell.getState().canvases[canvasId]?.active;\n shell.dispatch(event.origin === undefined && active !== undefined ? { ...event, origin: active.id } : event);\n },\n publish: (channel, payload) => shell.publish(channel, payload),\n },\n subscribe: (listener) => {\n let pending = false;\n let stopped = false;\n const changed = (): void => {\n if (pending || stopped) return;\n pending = true;\n queueMicrotask(() => {\n pending = false;\n if (!stopped) listener();\n });\n };\n const offState = shell.onStateChange(changed);\n const offData = shell.onDataChange(changed);\n return () => {\n stopped = true;\n offState();\n offData();\n };\n },\n});\n\n// A WAIT ON THE SHELL, shared by the two below. Resolves `true` once `isBusy`\n// answers no and still answers no a macrotask later — a mount can open another\n// action, which starts initializing in turn, so the question is asked again on\n// every change. Resolves `false` when `waitMs` runs out first, or `stopped`\n// says to give up.\ntype ShellWaitOptions = { waitMs?: number; stopped?: () => boolean };\n\nconst shellQuietWithin = async (shell: Shell, isBusy: () => boolean, options: ShellWaitOptions): Promise<boolean> => {\n const waitMs = options.waitMs ?? DEFAULT_SETTLE_WAIT_MS;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<boolean>((resolve) => {\n timer = setTimeout(() => resolve(false), waitMs);\n });\n const quiet = (async (): Promise<boolean> => {\n for (;;) {\n if (options.stopped?.() === true) return false;\n if (!isBusy()) {\n await new Promise<void>((resolve) => setTimeout(resolve, 0));\n if (!isBusy()) return true;\n }\n await new Promise<void>((resolve) => {\n const off = shell.onStateChange(() => {\n off();\n resolve();\n });\n // a change that lands with no notification must not leave this waiting\n setTimeout(() => {\n off();\n resolve();\n }, 10);\n });\n }\n })();\n const settled = await Promise.race([quiet, deadline]);\n clearTimeout(timer);\n return settled;\n};\n\nconst isMounting = (shell: Shell): boolean =>\n Object.values(shell.getState().canvases).some((canvas) => canvas.stack.some((instance) => instance.status === 'initializing'));\n\n// THE FIRST SCREEN IS WHOLE. An instance is `initializing` until its mount hook\n// — the loads, and whatever they chain to — has been awaited, so \"nothing is\n// initializing\" is the shell saying its opening screen is complete.\n//\n// Resolves `false` when `waitMs` runs out first: the screen is then drawn as it\n// stands, with whatever is still loading drawn as loading. Default 300ms — a\n// page should not hang on one slow endpoint.\n//\n// It asks about MOUNTS and nothing else, on purpose. A page is read whenever it\n// is asked for — also while a call somebody pressed minutes ago is still out —\n// and that read must not wait on it. `shellIdle` is the wider question.\nexport const DEFAULT_SETTLE_WAIT_MS = 300;\n\nexport const shellSettled = (shell: Shell, options: { waitMs?: number; stopped?: () => boolean } = {}): Promise<boolean> =>\n shellQuietWithin(shell, () => isMounting(shell), options);\n\n// NOTHING THE SHELL STARTED IS STILL RUNNING. Nothing is mounting, and no chain\n// is in flight (./chains.ts): no trigger's steps, no message on its way to its\n// listeners, no hook a navigation started. It is what a check awaits after it\n// presses something — the call the press made has answered, what that chained\n// to has run, and an action a `pop` revealed has re-read itself — and what\n// anything that runs an action for somebody else awaits before it reads the\n// screen.\n//\n// It is about THIS shell's own work. A followed read's next body arrives when\n// somebody else writes, and is not waited for; neither is anything outside the\n// shell that an endpoint set going. A call that never answers holds it until\n// the call's own timeout fails it (30s by default), so `waitMs` is what bounds\n// the wait — it resolves `false` when that runs out, as `shellSettled` does.\nexport const shellIdle = (shell: Shell, options: { waitMs?: number; stopped?: () => boolean } = {}): Promise<boolean> =>\n shellQuietWithin(shell, () => isMounting(shell) || chainsInFlight(shell) > 0, options);\n","import { headKeyOf } from '../layout/head';\nimport type { HeadElement } from '../layout/head';\n\n// ═══════════════════════════════════════════════════════════\n// A screen's head, written into an HTML document.\n//\n// The document is the app's own `index.html` with a screen already drawn into\n// it. Its <head> is what holds on every page; the screen's head elements are\n// what this page says. An element that says the same thing as a tag the\n// document already has — its <title>, a <meta> of that name or property, its\n// canonical address — takes that tag's place, where it stood. Anything else is\n// added after what is there. Everything the screen does not speak of is left\n// exactly as it was: the icon, the viewport, the stylesheet.\n//\n// TWO THINGS ARE KEPT FOR THE PAGE ITSELF, which goes on living after the file\n// is read (./head-keeper). What was written is marked (`data-nova-head`), so\n// the page can tell the screen's elements from the document's own. And a tag\n// that gave up its place is kept, inert, in a <template data-nova-own>: when\n// the screen moves on to one that no longer says it, the document's own comes\n// back.\n//\n// WHERE the document lives is known to whoever writes the file: the site plus\n// the path it was drawn at. With a `site`, every path is given its own\n// canonical address, whether or not its screen has a head. That address is the\n// document's own for this path — unmarked, and it stays when the screen moves\n// on. A screen that says a canonical address itself is taken at its word.\n//\n// With nothing to write, the document comes back untouched.\n// ═══════════════════════════════════════════════════════════\n\nexport type HeadPlace = {\n // The address the site is served at (\"https://example.com\"). With it, each\n // path's canonical address is written.\n site?: string;\n // The path this document was drawn at.\n path?: string;\n};\n\nexport const HEAD_MARK = 'data-nova-head';\nexport const OWN_MARK = 'data-nova-own';\n\nconst escapeAttribute = (value: string): string => value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<');\nconst escapeText = (value: string): string => value.replace(/&/g, '&').replace(/</g, '<');\n// Inside a <script>, the one thing that may not appear is the start of a tag.\n// The two separators end a line in a script though not in JSON, so they are\n// written as escapes too (named by code: the characters themselves would end\n// a line here as well).\nconst LINE_ENDS = [0x2028, 0x2029];\nconst escapeScript = (json: string): string =>\n LINE_ENDS.reduce((text, code) => text.split(String.fromCharCode(code)).join(`\\\\u${code.toString(16)}`), json.replace(/</g, '\\\\u003c'));\n\n// What stands in a head, read a tag at a time: comments and the bodies of\n// scripts, styles and templates are passed over whole, so a tag written inside\n// one is not mistaken for a tag.\nconst ATTRIBUTES = `((?:[^>\"']|\"[^\"]*\"|'[^']*')*)`;\nconst TAGS = new RegExp(`<!--[\\\\s\\\\S]*?-->|<(script|style|title|template)\\\\b${ATTRIBUTES}>([\\\\s\\\\S]*?)<\\\\/\\\\1\\\\s*>|<(meta|link)\\\\b${ATTRIBUTES}>`, 'gi');\nconst ATTRIBUTE = /([^\\s\"'=<>/]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?/g;\n\ntype Tag = { start: number; end: number; name: string; attributes: Record<string, string>; inner: string; text: string };\n\nconst attributesOf = (source: string): Record<string, string> => {\n const attributes: Record<string, string> = {};\n for (const match of source.matchAll(ATTRIBUTE)) {\n const name = match[1]?.toLowerCase();\n if (name === undefined || name in attributes) continue;\n attributes[name] = match[2] ?? match[3] ?? match[4] ?? '';\n }\n return attributes;\n};\n\nconst tagsOf = (section: string): Tag[] => {\n const tags: Tag[] = [];\n for (const match of section.matchAll(TAGS)) {\n const name = (match[1] ?? match[4])?.toLowerCase();\n if (name === undefined) continue;\n tags.push({ start: match.index, end: match.index + match[0].length, name, attributes: attributesOf(match[2] ?? match[5] ?? ''), inner: match[3] ?? '', text: match[0] });\n }\n return tags;\n};\n\n// What a tag in the document says, in the same terms as an element.\nconst keyOfTag = (tag: Tag): string | undefined =>\n tag.name === 'title' || tag.name === 'meta' || tag.name === 'link' ? headKeyOf({ tag: tag.name, attributes: tag.attributes }) : undefined;\n\n// An element, as the tag it is written as.\nconst markupOf = (element: HeadElement, marked: boolean): string => {\n const written = Object.entries(element.attributes).map(([name, value]) => (value === '' ? ` ${name}` : ` ${name}=\"${escapeAttribute(value)}\"`));\n const attributes = [...written, ...(marked ? [` ${HEAD_MARK}`] : [])].join('');\n if (element.tag === 'title') return `<title${attributes}>${escapeText(element.text ?? '')}</title>`;\n if (element.tag === 'script') return `<script${attributes}>${escapeScript(element.text ?? '')}</script>`;\n return `<${element.tag}${attributes}>`;\n};\n\n// Where the document lives, as elements: what a `site` and a path say.\nconst addressOf = (place: HeadPlace): HeadElement[] => {\n if (place.site === undefined || place.path === undefined) return [];\n const path = place.path.split(/[?#]/)[0] ?? '';\n const address = `${place.site.replace(/\\/+$/, '')}${path.startsWith('/') ? path : `/${path}`}`;\n return [\n { tag: 'link', attributes: { rel: 'canonical', href: address } },\n { tag: 'meta', attributes: { property: 'og:url', content: address } },\n ];\n};\n\nconst changed = (text: string, changes: readonly { start: number; end: number; text: string }[]): string =>\n [...changes].sort((a, b) => b.start - a.start).reduce((at, change) => `${at.slice(0, change.start)}${change.text}${at.slice(change.end)}`, text);\n\n// A head that was written before, put back as the document had it: what the\n// last screen said is taken out, and what the document gave up for it is given\n// back. A head never written comes back as it is.\nconst restored = (section: string): string =>\n changed(\n section,\n tagsOf(section).flatMap((tag) => {\n if (tag.name === 'template' && OWN_MARK in tag.attributes) return [{ start: tag.start, end: tag.end, text: tag.inner }];\n return HEAD_MARK in tag.attributes ? [{ start: tag.start, end: tag.end, text: '' }] : [];\n }),\n );\n\n// Elements, written into a head. `screen`: they are what a screen says — each\n// is marked, and a tag that gives up its place is kept for the page. Otherwise\n// they are the document's own from here on, and what they replace is gone.\nconst write = (section: string, elements: readonly HeadElement[], screen: boolean): string => {\n if (elements.length === 0) return section;\n const tags = tagsOf(section);\n const changes: { start: number; end: number; text: string }[] = [];\n const added: string[] = [];\n const own: string[] = [];\n for (const element of elements) {\n const key = headKeyOf(element);\n const [first, ...others] = key === undefined ? [] : tags.filter((tag) => keyOfTag(tag) === key);\n if (first === undefined) {\n added.push(markupOf(element, screen));\n continue;\n }\n changes.push({ start: first.start, end: first.end, text: markupOf(element, screen) });\n own.push(first.text);\n // said twice, the second would still say the old thing\n for (const other of others) {\n changes.push({ start: other.start, end: other.end, text: '' });\n own.push(other.text);\n }\n }\n if (screen && own.length > 0) added.push(`<template ${OWN_MARK}>${own.join('')}</template>`);\n\n const written = changed(section, changes);\n // What is added goes after the last thing in the head, a line each, indented\n // as that last thing is — or straight on, in a head written on one line.\n const tail = /\\s*$/.exec(written)?.[0] ?? '';\n const body = written.slice(0, written.length - tail.length);\n const indent = /(?:^|\\n)([ \\t]*)\\S[^\\n]*$/.exec(body)?.[1] ?? '';\n const lead = tail.includes('\\n') ? `\\n${indent}` : '';\n return `${body}${added.map((tag) => `${lead}${tag}`).join('')}${tail}`;\n};\n\nexport const placeHead = (html: string, elements: readonly HeadElement[] | undefined, place: HeadPlace = {}): string => {\n const opening = /<head\\b[^>]*>/i.exec(html);\n if (opening === null) return html;\n const from = opening.index + opening[0].length;\n const closing = html.slice(from).search(/<\\/head\\s*>/i);\n if (closing < 0) return html;\n // Where the document lives is the document's own, for this path: written\n // first and unmarked, so a screen that says an address of its own takes its\n // place — and gives it back.\n const located = write(restored(html.slice(from, from + closing)), addressOf(place), false);\n return `${html.slice(0, from)}${write(located, elements ?? [], true)}${html.slice(from + closing)}`;\n};\n","import { headKeyOf } from '../layout/head';\nimport type { HeadElement } from '../layout/head';\nimport { HEAD_MARK, OWN_MARK } from './place-head';\n\n// ═══════════════════════════════════════════════════════════\n// A page's <head>, kept on the screen.\n//\n// A drawn page arrives with its head written (`placeHead`). From then on the\n// shell is live and the screen moves without the page being fetched again, so\n// the head is kept on whatever the screen says now: its elements are put in\n// `document.head`, and taken out again when the screen stops saying them.\n//\n// THE DOCUMENT'S OWN TAGS GIVE WAY AND COME BACK. A tag the page was written\n// with — the title in index.html, its description — is taken out while the\n// screen says the same thing itself, and put back where it stood when the\n// screen no longer does. A drawn page has already given some up: they arrive\n// inert, in the <template data-nova-own> the writer left, and come back the\n// same way.\n//\n// A KEEPER THAT WAS NEVER HANDED AN ELEMENT NEVER WRITES. Two shells can share\n// a page (an inspector beside the app), and the one with nothing to say must\n// not touch what the other wrote — nor what the page arrived with.\n// ═══════════════════════════════════════════════════════════\n\nexport type HeadKeeper = (elements: readonly HeadElement[] | undefined) => void;\n\ntype Away = { key: string; node: Element; before: Node | null };\n\nconst TAGS = ['title', 'meta', 'link'];\n\n// What a tag standing in the page says, in the same terms as an element.\nconst keyOfNode = (node: Element): string | undefined => {\n const tag = TAGS.find((name) => name === node.tagName.toLowerCase());\n if (tag !== 'title' && tag !== 'meta' && tag !== 'link') return undefined;\n return headKeyOf({ tag, attributes: Object.fromEntries([...node.attributes].map((attribute) => [attribute.name, attribute.value])) });\n};\n\nexport const createHeadKeeper = (doc: Document): HeadKeeper => {\n // the screen's elements standing in the head\n let mine: Element[] = [];\n // the document's own tags that have given up their place\n let away: Away[] = [];\n let said: string | undefined;\n\n const built = (element: HeadElement): Element => {\n const node = doc.createElement(element.tag);\n for (const [name, value] of Object.entries(element.attributes)) node.setAttribute(name, value);\n node.setAttribute(HEAD_MARK, '');\n if (element.text !== undefined) node.textContent = element.text;\n return node;\n };\n\n // What the page arrived with: the elements a writer put there for the first\n // screen, and the tags that gave way to them.\n const adopt = (): void => {\n mine = [...doc.head.querySelectorAll(`[${HEAD_MARK}]`)];\n // the document's own window, not a global: a page's document is not always\n // the one the code was loaded in\n const view = doc.defaultView;\n for (const stash of doc.head.querySelectorAll(`template[${OWN_MARK}]`)) {\n if (view === null || !(stash instanceof view.HTMLTemplateElement)) continue;\n for (const child of [...stash.content.children]) {\n const key = keyOfNode(child);\n if (key !== undefined) away.push({ key, node: doc.importNode(child, true), before: null });\n }\n stash.remove();\n }\n };\n\n return (elements) => {\n const now = elements ?? [];\n const next = JSON.stringify(now);\n if (said === undefined) {\n if (now.length === 0) return;\n adopt();\n }\n if (next === said) return;\n said = next;\n\n for (const node of mine) node.remove();\n mine = now.map(built);\n const keys = new Set(now.flatMap((element) => headKeyOf(element) ?? []));\n\n // the document's own that now say what the screen says: out, each remembering where it stood\n for (const node of [...doc.head.children]) {\n const key = keyOfNode(node);\n if (key === undefined || !keys.has(key)) continue;\n away.push({ key, node, before: node.nextSibling });\n node.remove();\n }\n // Those the screen no longer says: back where each stood. The last to leave\n // goes back first — what stood after an earlier one may have left after it,\n // and has to be standing again for the earlier one to go in front of it.\n const [back, still] = [away.filter((gone) => !keys.has(gone.key)), away.filter((gone) => keys.has(gone.key))];\n for (const gone of [...back].reverse()) doc.head.insertBefore(gone.node, gone.before !== null && gone.before.parentNode === doc.head ? gone.before : null);\n away = still;\n\n doc.head.append(...mine);\n };\n};\n","import { headOf, shellView } from '../shell';\nimport type { Shell } from '../shell';\nimport { createHeadKeeper } from './head-keeper';\nimport type { HeadKeeper } from './head-keeper';\n\n// ═══════════════════════════════════════════════════════════\n// The page's head, for an adapter that draws a shell living in its own page\n// through a framework (react, vue).\n//\n// Such an adapter reads the shell's trees through its own subscriptions, so\n// there is no one render to read the head off: reading it means rendering the\n// shell's trees once more. That is worth doing only while a head is on the\n// screen. So a head node says when it arrives and when it goes (`enter`,\n// `leave`), and the shell is only read between the two.\n// ═══════════════════════════════════════════════════════════\n\nexport type ShellHead = {\n enter: () => void;\n leave: () => void;\n // follow the shell's changes; returns the stop\n watch: () => () => void;\n};\n\nexport const createShellHead = (shell: Shell): ShellHead => {\n const view = shellView(shell);\n let present = 0;\n let keep: HeadKeeper | undefined;\n let queued = false;\n // once a turn, however many heads came and went in it\n const read = (): void => {\n // nothing to keep where a screen is drawn to a string\n if (queued || typeof document === 'undefined') return;\n queued = true;\n queueMicrotask(() => {\n queued = false;\n keep ??= createHeadKeeper(document);\n keep(present > 0 ? headOf(view.api)?.elements : undefined);\n });\n };\n return {\n enter: () => {\n present += 1;\n read();\n },\n leave: () => {\n present -= 1;\n read();\n },\n watch: () =>\n view.subscribe(() => {\n if (present > 0) read();\n }),\n };\n};\n","import { createContext, useContext, useEffect, useMemo, type FC, type ReactNode } from 'react';\nimport type { Shell } from '@shell';\nimport { createShellHead, type ShellHead } from '../../document/shell-head';\n\n// ═══════════════════════════════════════════════════════════\n// A head node (`nova:head`), in React.\n//\n// It draws nothing, and neither does anything it holds. Where the shell lives\n// in this page it says that it is on the screen, so the page's head is read\n// off the shell only while there is one to read (document/shell-head). Under a\n// served screen there is no shell here and nothing to say to: the terminal\n// keeps the head off the wire.\n//\n// Effects do not run where a screen is drawn to a string, so none of this\n// touches a document that is not a browser's.\n// ═══════════════════════════════════════════════════════════\n\nconst ShellHeadContext = createContext<ShellHead | undefined>(undefined);\n\nexport const HeadMark: FC = () => {\n const head = useContext(ShellHeadContext);\n useEffect(() => {\n if (head === undefined) return undefined;\n head.enter();\n return head.leave;\n }, [head]);\n return null;\n};\n\nexport const ShellHeadProvider: FC<{ shell: Shell; children?: ReactNode }> = ({ shell, children }) => {\n const head = useMemo(() => createShellHead(shell), [shell]);\n useEffect(() => head.watch(), [head]);\n return <ShellHeadContext.Provider value={head}>{children}</ShellHeadContext.Provider>;\n};\n","import { useMemo, type ComponentType, type FC, type ReactNode } from 'react';\nimport type { ComponentRegistry } from '@layout';\nimport type { Shell } from '@shell';\nimport {\n NovaRenderContext,\n NovaShellContext,\n type NovaRenderContextValue,\n type SlotWrapper,\n} from './context';\nimport { ShellHeadProvider } from './head';\nimport type { NovaComponent, NovaDispatch, NovaPublish } from './types';\n\nconst noopDispatch: NovaDispatch = () => {};\nconst noopPublish: NovaPublish = () => {};\n\n// ═══════════════════════════════════════════════════════════\n// <NovaRenderProvider>\n//\n// The framework-agnostic renderer context. Pairs a component\n// registry with a dispatch and publish function. Works with no\n// shell — dispatch and publish default to no-ops so static\n// layouts can be rendered without any event infrastructure.\n// ═══════════════════════════════════════════════════════════\n\nexport type NovaRenderProviderProps = {\n registry: ComponentRegistry<NovaComponent>;\n dispatch?: NovaDispatch;\n publish?: NovaPublish;\n slotWrapper?: SlotWrapper;\n // renderer for unregistered component names; omit for strict error markers\n fallback?: NovaComponent;\n // host-specific leaf renderers (see NovaRenderContextValue) — a non-DOM\n // react host (ink) supplies both; browser consumers omit them\n textWrapper?: ComponentType<{ children?: ReactNode }>;\n errorMarker?: ComponentType<{ code: string; message: string }>;\n children?: ReactNode;\n};\n\nexport const NovaRenderProvider: FC<NovaRenderProviderProps> = ({\n registry,\n dispatch = noopDispatch,\n publish = noopPublish,\n slotWrapper,\n fallback,\n textWrapper,\n errorMarker,\n children,\n}) => {\n const value = useMemo<NovaRenderContextValue>(\n () => ({ registry, dispatch, publish, slotWrapper, fallback, textWrapper, errorMarker }),\n [registry, dispatch, publish, slotWrapper, fallback, textWrapper, errorMarker],\n );\n return <NovaRenderContext.Provider value={value}>{children}</NovaRenderContext.Provider>;\n};\n\n// ═══════════════════════════════════════════════════════════\n// <NovaShellProvider>\n//\n// A thin wrapper over <NovaRenderProvider> that also exposes the\n// shell via context. The registry defaults to `shell.registry` so\n// callers don't have to thread it through twice; pass an explicit\n// `registry` override only when the shell should render against a\n// different one (rare).\n// ═══════════════════════════════════════════════════════════\n\nexport type NovaShellProviderProps = {\n shell: Shell;\n registry?: ComponentRegistry<NovaComponent>;\n slotWrapper?: SlotWrapper;\n children?: ReactNode;\n};\n\nexport const NovaShellProvider: FC<NovaShellProviderProps> = ({\n shell,\n registry,\n slotWrapper,\n children,\n}) => {\n const dispatch = useMemo<NovaDispatch>(() => (event) => shell.dispatch(event), [shell]);\n const publish = useMemo<NovaPublish>(\n () => (channel, payload) => shell.publish(channel, payload),\n [shell],\n );\n const resolvedRegistry = (registry ?? shell.registry) as ComponentRegistry<NovaComponent>;\n return (\n <NovaShellContext.Provider value={shell}>\n <NovaRenderProvider\n registry={resolvedRegistry}\n dispatch={dispatch}\n publish={publish}\n slotWrapper={slotWrapper}\n >\n <ShellHeadProvider shell={shell}>{children}</ShellHeadProvider>\n </NovaRenderProvider>\n </NovaShellContext.Provider>\n );\n};\n","import type { FC } from 'react';\n\nexport type ErrorMarkerProps = {\n code: string;\n message: string;\n};\n\n// Renders error RenderNodes surfaced by the renderer in lax mode.\n// Consumers can style via the `data-nova-error` attribute.\nexport const ErrorMarker: FC<ErrorMarkerProps> = ({ code, message }) => (\n <span data-nova-error={code} role=\"alert\">\n {`[${code}] ${message}`}\n </span>\n);\n","import { Fragment, createElement, useContext, type FC, type ReactElement } from 'react';\nimport { NOVA_MODEL_PROP, NOVA_REF_PROP, renderNodeKey, type RenderNode } from '@layout';\nimport { isHeadNode } from '@shell';\nimport { NovaRenderContext } from './context';\nimport { ErrorMarker } from './error-marker';\nimport { HeadMark } from './head';\nimport { RenderTree } from './render-tree';\n\nexport type RenderNodeViewProps = {\n node: RenderNode;\n};\n\nexport const RenderNodeView: FC<RenderNodeViewProps> = ({ node }) => {\n const ctx = useContext(NovaRenderContext);\n if (ctx === undefined) {\n throw new Error('RenderNodeView must be used inside <NovaRenderProvider>');\n }\n\n if (node.type === 'text') {\n // a non-DOM host (ink) must wrap every string — bare text crashes it\n const TextWrap = ctx.textWrapper;\n return TextWrap === undefined ? <Fragment>{node.value}</Fragment> : <TextWrap>{node.value}</TextWrap>;\n }\n if (node.type === 'fragment') {\n return <RenderTree nodes={node.children} />;\n }\n if (node.type === 'error') {\n const Marker = ctx.errorMarker ?? ErrorMarker;\n return <Marker code={node.code} message={node.message} />;\n }\n\n // node.type === 'component'\n // a head is the document's, not the screen's: nothing is drawn for it or for what it holds\n if (isHeadNode(node)) return <HeadMark />;\n const entry = ctx.registry.get(node.name);\n const Component = entry !== undefined ? entry.component : ctx.fallback;\n if (Component === undefined) {\n return <ErrorMarker code=\"COMPONENT_NOT_FOUND\" message={node.name} />;\n }\n const props: Record<string, unknown> = { ...node.props };\n if (node.model !== undefined) {\n props[NOVA_MODEL_PROP] = { ref: node.model.ref, path: node.model.path };\n }\n if (node.ref !== undefined) {\n props[NOVA_REF_PROP] = node.ref;\n }\n // Children go in as a keyed ARRAY of per-child elements (not one RenderTree\n // wrapper) so a component can address them individually with React.Children —\n // a Grid wraps each in a weighted flex cell. React flattens the array the\n // same way it would the fragment; keys follow core's renderNodeKey.\n const viewOf = (child: RenderNode, i: number): ReactElement => <RenderNodeView key={renderNodeKey(child, i)} node={child} />;\n if (!node.children.some(isHeadNode)) {\n return createElement(Component, props, node.children.length === 0 ? undefined : node.children.map(viewOf));\n }\n // A head among them is not handed to the component — a kit that gives every\n // child a cell would give it an empty one. It stands beside the component.\n const views = node.children.map((child, i) => ({ head: isHeadNode(child), view: viewOf(child, i) }));\n const shown = views.filter((child) => !child.head).map((child) => child.view);\n return (\n <Fragment>\n {createElement(Component, props, shown.length === 0 ? undefined : shown)}\n {views.filter((child) => child.head).map((child) => child.view)}\n </Fragment>\n );\n};\n","import { Fragment, type FC } from 'react';\nimport { renderNodeKey, type RenderNode } from '@layout';\nimport { RenderNodeView } from './render-node';\n\nexport type RenderTreeProps = {\n nodes: RenderNode[];\n};\n\nexport const RenderTree: FC<RenderTreeProps> = ({ nodes }) => (\n <Fragment>\n {nodes.map((node, i) => (\n <RenderNodeView key={renderNodeKey(node, i)} node={node} />\n ))}\n </Fragment>\n);\n","import { Component, type ErrorInfo, type ReactNode } from 'react';\n\n// ═══════════════════════════════════════════════════════════\n// React error boundaries REQUIRE a class component as of React 19.\n// There is no functional alternative today. This is the ONLY class\n// in the package outside `shared/errors.ts`. Justified strictly by\n// the framework requirement — every other abstraction in nova uses\n// factory + closure.\n// ═══════════════════════════════════════════════════════════\n\nexport type NovaErrorBoundaryProps = {\n children?: ReactNode;\n fallback?: (error: Error) => ReactNode;\n onError?: (error: Error, info: ErrorInfo) => void;\n};\n\ntype NovaErrorBoundaryState = {\n error: Error | undefined;\n};\n\nexport class NovaErrorBoundary extends Component<NovaErrorBoundaryProps, NovaErrorBoundaryState> {\n state: NovaErrorBoundaryState = { error: undefined };\n\n static getDerivedStateFromError(error: Error): NovaErrorBoundaryState {\n return { error };\n }\n\n componentDidCatch(error: Error, info: ErrorInfo): void {\n const handler = this.props.onError;\n if (handler !== undefined) handler(error, info);\n }\n\n render(): ReactNode {\n const { error } = this.state;\n if (error !== undefined) {\n const fallback = this.props.fallback;\n if (fallback !== undefined) return fallback(error);\n return (\n <div data-nova-error-boundary=\"true\" role=\"alert\">\n {error.message}\n </div>\n );\n }\n return this.props.children;\n }\n}\n","import { z } from 'zod';\n\n// ═══════════════════════════════════════════════════════════\n// The headless primitive vocabulary's AUTHORING contracts — one Zod props\n// schema per primitive, framework-free, shared by every adapter kit that ships\n// the vocabulary (react, vue). A schema is what a layout node may set; the\n// kits differ in how they paint, never in what they accept, so the schema\n// lives once, here, and each kit's component carries it as its static `meta`.\n// ═══════════════════════════════════════════════════════════\n\n// ─── Stack ───\nexport const StackPropsSchema = z\n .object({\n direction: z\n .enum(['row', 'column'])\n .optional()\n .describe('Flex direction. Default: column.'),\n gap: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Gap between children in pixels. Default: 0.'),\n align: z\n .enum(['start', 'center', 'end', 'stretch'])\n .optional()\n .describe('Cross-axis alignment. Default: stretch.'),\n justify: z\n .enum(['start', 'center', 'end', 'between', 'around'])\n .optional()\n .describe('Main-axis justification. Default: start.'),\n padding: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Inner padding in pixels. Default: 0.'),\n wrap: z\n .boolean()\n .optional()\n .describe('Whether children wrap to a new line. Default: false.'),\n })\n .strict()\n .describe('Flex container that arranges children in a row or column.');\n\nexport type StackProps = z.infer<typeof StackPropsSchema>;\n\n// ─── Text ───\nexport const TextPropsSchema = z\n .object({\n as: z\n .enum(['span', 'p', 'h1', 'h2', 'h3', 'h4'])\n .optional()\n .describe('HTML element to render. Default: span.'),\n size: z\n .enum(['sm', 'md', 'lg', 'xl', '2xl'])\n .optional()\n .describe('Font size token. Default: md.'),\n weight: z\n .enum(['normal', 'medium', 'bold'])\n .optional()\n .describe('Font weight token. Default: normal.'),\n color: z\n .string()\n .optional()\n .describe('CSS color string (open set). Default: inherit.'),\n })\n .strict()\n .describe('Text element with semantic typography props.');\n\nexport type TextProps = z.infer<typeof TextPropsSchema>;\n\n// ─── Input ───\nexport const InputPropsSchema = z\n .object({\n type: z\n .enum(['text', 'number', 'email', 'password'])\n .optional()\n .describe('Input type. Default: text.'),\n placeholder: z\n .string()\n .optional()\n .describe('Placeholder text shown when empty.'),\n disabled: z\n .boolean()\n .optional()\n .describe('Whether the input is disabled. Default: false.'),\n value: z\n .string()\n .optional()\n .describe('Current value. Typically supplied via model binding.'),\n debounce: z\n .number()\n .optional()\n .describe('Milliseconds to coalesce keystrokes before dispatching ui:model. Default: 0 (every keystroke). Set it when the shell is remote to cut round-trips.'),\n })\n .strict()\n .describe('Text input bound to data via the `model` field on the layout node.');\n\nexport type InputProps = z.infer<typeof InputPropsSchema>;\n\n// ─── Button ───\nexport const ButtonPropsSchema = z\n .object({\n label: z\n .string()\n .optional()\n .describe('Button label. If absent, children are used.'),\n variant: z\n .enum(['primary', 'secondary', 'ghost'])\n .optional()\n .describe('Visual variant. Default: primary.'),\n disabled: z\n .boolean()\n .optional()\n .describe('Whether the button is disabled. Default: false.'),\n })\n .strict()\n .describe(\"Clickable button. Click events fire as `ui:click` with the layout node's ref.\");\n\nexport type ButtonProps = z.infer<typeof ButtonPropsSchema>;\n\n// ─── Box ───\nexport const BoxPropsSchema = z\n .object({\n padding: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Inner padding in pixels. Default: 0.'),\n background: z\n .string()\n .optional()\n .describe('CSS background color or value.'),\n border: z\n .boolean()\n .optional()\n .describe('Whether to show a 1px border. Default: false.'),\n radius: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Border radius in pixels. Default: 0.'),\n })\n .strict()\n .describe('Generic container with basic styling props. Use Stack for layout, Box for visual wrapping.');\n\nexport type BoxProps = z.infer<typeof BoxPropsSchema>;\n\n// ─── Panel ───\nexport const PanelPropsSchema = z\n .object({\n title: z.string().optional().describe('Optional header title.'),\n backRef: z.string().optional().describe('When set, the header grows a ← (before the title) that fires ui:click with this ref.'),\n closeRef: z.string().optional().describe('When set, the header grows a ✕ that fires ui:click with this ref.'),\n })\n .strict()\n .describe('A framed, elevated surface with an optional title.');\n\nexport type PanelProps = z.infer<typeof PanelPropsSchema>;\n\n// ─── JsonTree ───\nexport const JsonTreePropsSchema = z\n .object({\n value: z.unknown().optional().describe('The value to render.'),\n label: z.string().optional().describe('A name for the root node.'),\n })\n .strict()\n .describe('A collapsible view of any JSON value.');\n\nexport type JsonTreeProps = z.infer<typeof JsonTreePropsSchema>;\n\n// ─── CanvasSlot ───\nexport const CanvasSlotPropsSchema = z\n .object({\n canvasId: z\n .string()\n .optional()\n .describe('Id of the canvas to render. Usually bound from a loop, e.g. \"$.c.id\".'),\n })\n .strict()\n .describe('Renders a canvas by id, recursing into its actionLayout. Resolves to nothing when canvasId is missing.');\n\nexport type CanvasSlotProps = z.infer<typeof CanvasSlotPropsSchema>;\n\n// ─── ActionSlot ───\n// The AUTHORING contract: what a layout node may set on an ActionSlot —\n// instanceId only, strict. The identity props flattenRenderTree stamps on a\n// served marker (canvasId / definitionId) are runtime OUTPUT, never authored;\n// widening this schema would advertise them to the layout agent's palette.\nexport const ActionSlotPropsSchema = z\n .object({\n instanceId: z\n .string()\n .optional()\n .describe('Id of the action instance to render. Usually bound from canvas scope, e.g. \"$.active.id\" or \"$.i.id\".'),\n })\n .strict()\n .describe('Renders an action instance by id. Resolves to nothing when instanceId is missing.');\n\nexport type ActionSlotProps = z.infer<typeof ActionSlotPropsSchema>;\n\n","import type { CSSProperties } from 'react';\nimport { StackPropsSchema, type StackProps } from '../../primitive-props';\nimport type { NovaComponent, NovaComponentProps } from '@react';\n\n// ═══════════════════════════════════════════════════════════\n// Stack — flex container\n// ═══════════════════════════════════════════════════════════\n\nexport { StackPropsSchema, type StackProps };\n\nconst ALIGN_MAP = {\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n stretch: 'stretch',\n} as const;\n\nconst JUSTIFY_MAP = {\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n between: 'space-between',\n around: 'space-around',\n} as const;\n\nexport const Stack: NovaComponent<StackProps> = ({\n direction,\n gap,\n align,\n justify,\n padding,\n wrap,\n children,\n}: NovaComponentProps & StackProps) => {\n const style: CSSProperties = {\n display: 'flex',\n flexDirection: direction ?? 'column',\n gap: gap ?? 0,\n alignItems: ALIGN_MAP[align ?? 'stretch'],\n justifyContent: JUSTIFY_MAP[justify ?? 'start'],\n padding: padding ?? 0,\n flexWrap: wrap === true ? 'wrap' : 'nowrap',\n };\n return <div style={style}>{children}</div>;\n};\n\nStack.meta = {\n description: 'Flex container that arranges children in a row or column.',\n propsSchema: StackPropsSchema,\n};\n","import { createElement, type CSSProperties } from 'react';\nimport { TextPropsSchema, type TextProps } from '../../primitive-props';\nimport type { NovaComponent, NovaComponentProps } from '@react';\n\n// ═══════════════════════════════════════════════════════════\n// Text — typography element\n// ═══════════════════════════════════════════════════════════\n\nexport { TextPropsSchema, type TextProps };\n\nconst SIZE_MAP = {\n sm: '12px',\n md: '14px',\n lg: '16px',\n xl: '20px',\n '2xl': '24px',\n} as const;\n\nconst WEIGHT_MAP = {\n normal: 400,\n medium: 500,\n bold: 700,\n} as const;\n\nexport const Text: NovaComponent<TextProps> = ({\n as,\n size,\n weight,\n color,\n children,\n}: NovaComponentProps & TextProps) => {\n const tag = as ?? 'span';\n const style: CSSProperties = {\n fontSize: SIZE_MAP[size ?? 'md'],\n fontWeight: WEIGHT_MAP[weight ?? 'normal'],\n color: color ?? 'inherit',\n };\n return createElement(tag, { style }, children);\n};\n\nText.meta = {\n description: 'Text element with semantic typography props.',\n propsSchema: TextPropsSchema,\n};\n","import { useEffect, useRef, useState, type ChangeEvent, type CSSProperties } from 'react';\nimport { InputPropsSchema, type InputProps } from '../../primitive-props';\nimport { useNovaDispatch, type NovaComponent, type NovaComponentProps } from '@react';\n\n// ═══════════════════════════════════════════════════════════\n// Input — text input bound to model\n//\n// Number inputs still dispatch a string payload; mutation ops\n// handle parsing on the action side.\n//\n// Two remote round-trip obligations (ADAPTER.md §6), because the shell may be\n// authoritative over a socket:\n// - it holds local editing state while focused, so an async tree echo can't\n// clobber the value the user is mid-typing;\n// - it honours the layout's `debounce` prop, coalescing keystrokes before\n// they hit the wire. A local shell echoes synchronously and neither matters,\n// but a remote one drops keystrokes without them.\n// ═══════════════════════════════════════════════════════════\n\nexport { InputPropsSchema, type InputProps };\n\nconst computeStyle = (isDisabled: boolean, isFocused: boolean, isHovered: boolean): CSSProperties => {\n const borderColor = isDisabled\n ? '#d1d5db'\n : isFocused\n ? '#2563eb'\n : isHovered\n ? '#9ca3af'\n : '#d1d5db';\n return {\n padding: '8px 12px',\n border: `1px solid ${borderColor}`,\n borderRadius: 6,\n fontSize: 14,\n background: isDisabled ? '#f9fafb' : '#ffffff',\n color: isDisabled ? '#9ca3af' : 'inherit',\n cursor: isDisabled ? 'not-allowed' : 'text',\n minWidth: 240,\n outline: 'none',\n boxShadow: isFocused ? '0 0 0 3px rgba(37, 99, 235, 0.15)' : 'none',\n transition: 'border-color 150ms, box-shadow 150ms',\n };\n};\n\nexport const Input: NovaComponent<InputProps> = ({\n type,\n placeholder,\n disabled,\n value,\n debounce,\n novaModel,\n}: NovaComponentProps & InputProps) => {\n const dispatch = useNovaDispatch();\n const [isHovered, setIsHovered] = useState(false);\n // `draft` is the local editing value; `null` means \"not editing — the\n // server value is authoritative\". While editing (focused) the draft wins,\n // so an async tree echo arriving mid-type never resets what the user typed.\n const [draft, setDraft] = useState<string | null>(null);\n const isFocused = draft !== null;\n const shown = draft ?? value ?? '';\n const isDisabled = disabled ?? false;\n const debounceMs = debounce ?? 0;\n\n // A single pending debounced dispatch — cancelled on the next keystroke,\n // flushed on blur, dropped on unmount (a keystroke against a screen that has\n // gone is worse than a lost one — the same reasoning as the socket's).\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const clearPending = (): void => {\n if (timer.current !== undefined) {\n clearTimeout(timer.current);\n timer.current = undefined;\n }\n };\n useEffect(() => clearPending, []);\n\n const fire = (next: string): void => {\n if (novaModel === undefined) return;\n dispatch({ type: 'ui:model', ref: novaModel.ref, payload: next });\n };\n\n const onChange = (event: ChangeEvent<HTMLInputElement>): void => {\n const next = event.target.value;\n setDraft(next);\n if (debounceMs > 0) {\n clearPending();\n timer.current = setTimeout(() => {\n timer.current = undefined;\n fire(next);\n }, debounceMs);\n } else {\n fire(next);\n }\n };\n\n const onFocus = (): void => setDraft(value ?? '');\n const onBlur = (): void => {\n // Flush any pending keystroke now, then hand authority back to the server.\n if (timer.current !== undefined && draft !== null) {\n clearPending();\n fire(draft);\n }\n setDraft(null);\n };\n\n return (\n <input\n type={type ?? 'text'}\n placeholder={placeholder}\n disabled={isDisabled}\n value={shown}\n onChange={onChange}\n onFocus={onFocus}\n onBlur={onBlur}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n style={computeStyle(isDisabled, isFocused, isHovered)}\n />\n );\n};\n\nInput.meta = {\n description: 'Text input bound to data via the `model` field on the layout node.',\n propsSchema: InputPropsSchema,\n};\n","import { useState, type CSSProperties, type MouseEvent } from 'react';\nimport { ButtonPropsSchema, type ButtonProps } from '../../primitive-props';\nimport { useNovaDispatch, type NovaComponent, type NovaComponentProps } from '@react';\n\n// ═══════════════════════════════════════════════════════════\n// Button — clickable element\n//\n// Click events fire as `ui:click` carrying the layout node's\n// `ref` (injected as `novaRef`). Without a ref, clicks are no-ops.\n// ═══════════════════════════════════════════════════════════\n\nexport { ButtonPropsSchema, type ButtonProps };\n\ntype Variant = 'primary' | 'secondary' | 'ghost';\n\nconst BASE_STYLE: CSSProperties = {\n borderRadius: 6,\n fontSize: 14,\n fontWeight: 500,\n transition: 'background-color 100ms',\n};\n\nconst primaryStyle = (isDisabled: boolean, isHovered: boolean, isActive: boolean): CSSProperties => ({\n ...BASE_STYLE,\n padding: '8px 16px',\n border: 'none',\n color: '#ffffff',\n cursor: isDisabled ? 'not-allowed' : 'pointer',\n background: isDisabled\n ? '#93c5fd'\n : isActive\n ? '#1e40af'\n : isHovered\n ? '#1d4ed8'\n : '#2563eb',\n});\n\nconst secondaryStyle = (isDisabled: boolean, isHovered: boolean, isActive: boolean): CSSProperties => ({\n ...BASE_STYLE,\n padding: '8px 16px',\n border: `1px solid ${isDisabled ? '#e5e7eb' : isHovered ? '#9ca3af' : '#d1d5db'}`,\n color: isDisabled ? '#9ca3af' : '#1f2937',\n cursor: isDisabled ? 'not-allowed' : 'pointer',\n background: isDisabled\n ? '#ffffff'\n : isActive\n ? '#e5e7eb'\n : isHovered\n ? '#f3f4f6'\n : '#ffffff',\n});\n\nconst ghostStyle = (isDisabled: boolean, isHovered: boolean, isActive: boolean): CSSProperties => ({\n ...BASE_STYLE,\n padding: '8px 12px',\n border: 'none',\n color: isDisabled ? '#93c5fd' : '#2563eb',\n cursor: isDisabled ? 'not-allowed' : 'pointer',\n background: isDisabled\n ? 'transparent'\n : isActive\n ? '#dbeafe'\n : isHovered\n ? '#eff6ff'\n : 'transparent',\n});\n\nconst styleFor = (\n variant: Variant,\n isDisabled: boolean,\n isHovered: boolean,\n isActive: boolean,\n): CSSProperties => {\n if (variant === 'primary') return primaryStyle(isDisabled, isHovered, isActive);\n if (variant === 'secondary') return secondaryStyle(isDisabled, isHovered, isActive);\n return ghostStyle(isDisabled, isHovered, isActive);\n};\n\nexport const Button: NovaComponent<ButtonProps> = ({\n label,\n variant,\n disabled,\n novaRef,\n children,\n}: NovaComponentProps & ButtonProps) => {\n const dispatch = useNovaDispatch();\n const [isHovered, setIsHovered] = useState(false);\n const [isActive, setIsActive] = useState(false);\n const isDisabled = disabled ?? false;\n const style = styleFor(variant ?? 'primary', isDisabled, isHovered, isActive);\n const onClick = (_event: MouseEvent<HTMLButtonElement>): void => {\n if (isDisabled) return;\n if (novaRef === undefined) return;\n dispatch({ type: 'ui:click', ref: novaRef });\n };\n return (\n <button\n type=\"button\"\n disabled={isDisabled}\n style={style}\n onClick={onClick}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => {\n setIsHovered(false);\n setIsActive(false);\n }}\n onMouseDown={() => setIsActive(true)}\n onMouseUp={() => setIsActive(false)}\n >\n {label ?? children}\n </button>\n );\n};\n\nButton.meta = {\n description: \"Clickable button. Click events fire as `ui:click` with the layout node's ref.\",\n propsSchema: ButtonPropsSchema,\n};\n","import type { CSSProperties } from 'react';\nimport { BoxPropsSchema, type BoxProps } from '../../primitive-props';\nimport type { NovaComponent, NovaComponentProps } from '@react';\n\n// ═══════════════════════════════════════════════════════════\n// Box — generic styled container\n// ═══════════════════════════════════════════════════════════\n\nexport { BoxPropsSchema, type BoxProps };\n\nexport const Box: NovaComponent<BoxProps> = ({\n padding,\n background,\n border,\n radius,\n children,\n}: NovaComponentProps & BoxProps) => {\n const style: CSSProperties = {\n padding: padding ?? 0,\n background: background ?? 'transparent',\n border: border === true ? '1px solid #e5e7eb' : 'none',\n borderRadius: radius ?? 0,\n };\n return <div style={style}>{children}</div>;\n};\n\nBox.meta = {\n description: 'Generic container with basic styling props. Use Stack for layout, Box for visual wrapping.',\n propsSchema: BoxPropsSchema,\n};\n","import { PanelPropsSchema, type PanelProps } from '../../primitive-props';\nimport { useNovaDispatch } from '@react';\nimport type { NovaComponent, NovaComponentProps } from '@react';\n\n// ═══════════════════════════════════════════════════════════\n// Panel — a framed, elevated surface with an optional title header. The\n// generic version of a dashboard/devtools panel; used by nova/devtools.\n// `closeRef` grows a header ✕ firing ui:click with that ref (the same\n// prop-ref convention as Table's rowRef).\n// ═══════════════════════════════════════════════════════════\n\nexport { PanelPropsSchema, type PanelProps };\n\nexport const Panel: NovaComponent<PanelProps> = ({ title, backRef, closeRef, children }: NovaComponentProps & PanelProps) => {\n const dispatch = useNovaDispatch();\n return (\n <div style={{ border: '1px solid #d8dae0', borderRadius: 10, background: '#fff', boxShadow: '0 1px 3px rgba(0,0,0,.06)', padding: 12 }}>\n {title !== undefined && (\n <div style={{ display: 'flex', alignItems: 'center', gap: 6, fontWeight: 600, fontSize: 13, marginBottom: 8 }}>\n {backRef !== undefined && (\n <button\n type=\"button\"\n style={{ border: 'none', background: 'none', color: '#6b7280', cursor: 'pointer', fontSize: 13, lineHeight: 1, padding: 2 }}\n onClick={() => dispatch({ type: 'ui:click', ref: backRef })}\n >\n ←\n </button>\n )}\n <span style={{ flex: 1 }}>{title}</span>\n {closeRef !== undefined && (\n <button\n type=\"button\"\n style={{ border: 'none', background: 'none', color: '#6b7280', cursor: 'pointer', fontSize: 13, lineHeight: 1, padding: 2 }}\n onClick={() => dispatch({ type: 'ui:click', ref: closeRef })}\n >\n ✕\n </button>\n )}\n </div>\n )}\n {children}\n </div>\n );\n};\n\nPanel.meta = { description: 'A framed, elevated surface with an optional title; `closeRef` adds a header ✕.', propsSchema: PanelPropsSchema };\n","import type { FC } from 'react';\nimport { JsonTreePropsSchema, type JsonTreeProps } from '../../primitive-props';\nimport type { NovaComponent, NovaComponentProps } from '@react';\n\n// ═══════════════════════════════════════════════════════════\n// JsonTree — a collapsible view of any JSON value, via native <details> (no\n// state). The value arrives already resolved in props. Used by nova/devtools\n// to show data / endpoint configs / audit detail; useful anywhere.\n// ═══════════════════════════════════════════════════════════\n\nconst entriesOf = (value: object): Array<[string, unknown]> =>\n Array.isArray(value) ? value.map((item, index): [string, unknown] => [String(index), item]) : Object.entries(value);\n\nconst JsonNode: FC<{ value: unknown; name?: string }> = ({ value, name }) => {\n if (value !== null && typeof value === 'object') {\n const entries = entriesOf(value);\n const shape = Array.isArray(value) ? `[${entries.length}]` : `{${entries.length}}`;\n return (\n <details>\n <summary style={{ cursor: 'pointer', color: '#6b7280' }}>{name === undefined ? shape : `${name} ${shape}`}</summary>\n <div style={{ paddingLeft: 13, borderLeft: '1px solid #d8dae0', marginLeft: 3 }}>\n {entries.map(([key, child]) => (\n <JsonNode key={key} value={child} name={key} />\n ))}\n </div>\n </details>\n );\n }\n const text = name === undefined ? JSON.stringify(value) : `${name}: ${JSON.stringify(value)}`;\n return <div style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}>{text}</div>;\n};\n\nexport { JsonTreePropsSchema, type JsonTreeProps };\n\nexport const JsonTree: NovaComponent<JsonTreeProps> = ({ value, label }: NovaComponentProps & JsonTreeProps) => (\n <div style={{ fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace', fontSize: 12, lineHeight: 1.5 }}>\n <JsonNode value={value} name={label} />\n </div>\n);\n\nJsonTree.meta = { description: 'A collapsible view of any JSON value.', propsSchema: JsonTreePropsSchema };\n","import { CanvasSlotPropsSchema, type CanvasSlotProps } from '../../primitive-props';\nimport { RenderTree, useCanvasRenderTree } from '@react';\nimport type { NovaComponent, NovaComponentProps } from '@react';\n\n// ═══════════════════════════════════════════════════════════\n// CanvasSlot — structural component that renders a canvas's\n// actionLayout inside a shell's canvasLayout. Used as a leaf in\n// the shell-tier layout tree.\n// ═══════════════════════════════════════════════════════════\n\nexport { CanvasSlotPropsSchema, type CanvasSlotProps };\n\nexport const CanvasSlot: NovaComponent<CanvasSlotProps> = ({\n canvasId,\n}: NovaComponentProps & CanvasSlotProps) => {\n const tree = useCanvasRenderTree(canvasId);\n if (canvasId === undefined || canvasId === '') return null;\n return <RenderTree nodes={tree} />;\n};\n\nCanvasSlot.meta = {\n description: 'Renders a canvas by id, recursing into its actionLayout.',\n propsSchema: CanvasSlotPropsSchema,\n};\n","import { useContext, useMemo } from 'react';\nimport { ActionSlotPropsSchema, type ActionSlotProps } from '../../primitive-props';\nimport { scopeDispatch } from '@shared/event-bus';\nimport { RenderTree, useRenderTree, useShell, useSlotWrapper } from '@react';\nimport type { NovaComponent, NovaComponentProps, NovaRenderContextValue } from '@react';\nimport { NovaRenderContext } from '@react/context';\n\n// ═══════════════════════════════════════════════════════════\n// ActionSlot — structural component that renders a single action\n// instance inside a canvas's actionLayout. Resolves to nothing\n// when instanceId is missing (e.g. the canvas has no active).\n//\n// This is the one seam where an instance's content mounts/unmounts,\n// so it's where an app-supplied `slotWrapper` (if any) wraps the\n// content — for animation, gating, logging, etc. Nova owns none of\n// that; it just hands the wrapper identity and the rendered tree.\n// ═══════════════════════════════════════════════════════════\n\n// The authoring contract (instanceId only, strict) lives in ../../primitive-props.\nexport { ActionSlotPropsSchema, type ActionSlotProps };\n\nexport const ActionSlot: NovaComponent<ActionSlotProps> = ({\n instanceId,\n}: NovaComponentProps & ActionSlotProps) => {\n const tree = useRenderTree(instanceId ?? '');\n const slotWrapper = useSlotWrapper();\n const shell = useShell();\n const hasInstance = instanceId !== undefined && instanceId !== '';\n\n // Scope dispatch to THIS instance so the runtime delivers UI events from\n // its rendered subtree to this instance's own triggers only. The stamping\n // rule itself is core semantics — see scopeDispatch.\n const ctx = useContext(NovaRenderContext);\n const scoped = useMemo<NovaRenderContextValue | undefined>(() => {\n if (ctx === undefined || instanceId === undefined || instanceId === '') return ctx;\n return { ...ctx, dispatch: scopeDispatch(ctx.dispatch, instanceId) };\n }, [ctx, instanceId]);\n\n // No app-supplied wrapper → original behavior, plus the scoped dispatch.\n if (slotWrapper === undefined) {\n if (!hasInstance) return null;\n return (\n <NovaRenderContext.Provider value={scoped}>\n <RenderTree nodes={tree} />\n </NovaRenderContext.Provider>\n );\n }\n\n // With a wrapper, render it PERSISTENTLY (content or null) so a\n // presence-managing wrapper can animate an instance leaving. Identity\n // (canvasId / the ActionDefinition) resolves from the live runtime when one\n // is present; it is undefined while the slot is empty or exiting.\n const runtime = hasInstance ? shell.getRuntime(instanceId) : undefined;\n const Wrapper = slotWrapper;\n return (\n <Wrapper\n canvasId={runtime?.instance.canvasId}\n instanceId={hasInstance ? instanceId : undefined}\n action={runtime?.definition}\n >\n {hasInstance && tree.length ? (\n <NovaRenderContext.Provider value={scoped}>\n <RenderTree nodes={tree} />\n </NovaRenderContext.Provider>\n ) : null}\n </Wrapper>\n );\n};\n\nActionSlot.meta = {\n description: 'Renders an action instance by id. Used inside a canvas actionLayout.',\n propsSchema: ActionSlotPropsSchema,\n};\n","// ═══════════════════════════════════════════════════════════\n// @niscorp/nova/adapters/react/components\n//\n// Headless React component set for Nova layouts. All five\n// components carry static `.meta` (description + Zod props\n// schema). The `registerNovaReactComponents` helper batches\n// them into a registry via `registerAll`.\n// ═══════════════════════════════════════════════════════════\n\nimport type { ComponentRegistry } from '@layout';\nimport type { NovaComponent } from '@react';\nimport { Stack } from './stack';\nimport { Text } from './text';\nimport { Input } from './input';\nimport { Button } from './button';\nimport { Box } from './box';\nimport { Panel } from './panel';\nimport { JsonTree } from './json-tree';\nimport { CanvasSlot } from './canvas-slot';\nimport { ActionSlot } from './action-slot';\n\n// ─── Stack ─────────────────────────────────────────────────\nexport { Stack, StackPropsSchema, type StackProps } from './stack';\n\n// ─── Text ──────────────────────────────────────────────────\nexport { Text, TextPropsSchema, type TextProps } from './text';\n\n// ─── Input ─────────────────────────────────────────────────\nexport { Input, InputPropsSchema, type InputProps } from './input';\n\n// ─── Button ────────────────────────────────────────────────\nexport { Button, ButtonPropsSchema, type ButtonProps } from './button';\n\n// ─── Box ───────────────────────────────────────────────────\nexport { Box, BoxPropsSchema, type BoxProps } from './box';\n\n// ─── Introspection primitives (used by nova/devtools) ──────\nexport { Panel, PanelPropsSchema, type PanelProps } from './panel';\nexport { JsonTree, JsonTreePropsSchema, type JsonTreeProps } from './json-tree';\n\n// ─── Shell slots (react) ───────────────────────────────────\n// CanvasSlot / ActionSlot are shell-aware: they pull state from\n// the React shell context and must only be used inside a\n// <NovaShellProvider>. Non-React adapters register their own\n// equivalents implementing the same prop contract.\nexport { CanvasSlot, CanvasSlotPropsSchema, type CanvasSlotProps } from './canvas-slot';\nexport { ActionSlot, ActionSlotPropsSchema, type ActionSlotProps } from './action-slot';\n\n// ─── Bulk registration helper ──────────────────────────────\nexport const registerNovaReactComponents = (\n registry: ComponentRegistry<NovaComponent>,\n): void => {\n registry.registerAll({\n Stack,\n Text,\n Input,\n Button,\n Box,\n Panel,\n JsonTree,\n CanvasSlot,\n ActionSlot,\n });\n};\n","import { useContext } from 'react';\nimport type { Shell } from '@shell';\nimport { NovaShellContext } from '../context';\n\nexport const useShell = (): Shell => {\n const shell = useContext(NovaShellContext);\n if (shell === undefined) {\n throw new Error('useShell must be used inside <NovaShellProvider>');\n }\n return shell;\n};\n","import { useCallback, useRef, useSyncExternalStore } from 'react';\nimport type { RenderNode } from '@layout';\nimport type { Shell } from '@shell';\nimport { useShell } from './use-shell';\n\ntype Cache = {\n shell: Shell;\n canvasId: string | undefined;\n tree: RenderNode[];\n};\n\nconst EMPTY: RenderNode[] = [];\n\nexport const useCanvasRenderTree = (canvasId: string | undefined): RenderNode[] => {\n const shell = useShell();\n const cacheRef = useRef<Cache | undefined>(undefined);\n\n const subscribe = useCallback(\n (cb: () => void) =>\n shell.onStateChange(() => {\n const tree = canvasId === undefined ? EMPTY : shell.getCanvasRenderTree(canvasId);\n cacheRef.current = { shell, canvasId, tree };\n cb();\n }),\n [shell, canvasId],\n );\n\n const getSnapshot = useCallback((): RenderNode[] => {\n const cached = cacheRef.current;\n if (cached !== undefined && cached.shell === shell && cached.canvasId === canvasId) {\n return cached.tree;\n }\n const tree = canvasId === undefined ? EMPTY : shell.getCanvasRenderTree(canvasId);\n cacheRef.current = { shell, canvasId, tree };\n return tree;\n }, [shell, canvasId]);\n\n // The third argument is what a SERVER reads. The shell exists there too, with\n // a real state, so it is the same read — and without it React refuses to draw\n // this to markup at all (\"Missing getServerSnapshot\").\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n","import { useCallback, useRef, useSyncExternalStore } from 'react';\nimport type { RenderNode } from '@layout';\nimport type { Shell } from '@shell';\nimport { useShell } from './use-shell';\n\ntype Cache = {\n shell: Shell;\n tree: RenderNode[];\n};\n\nexport const useShellRenderTree = (): RenderNode[] => {\n const shell = useShell();\n const cacheRef = useRef<Cache | undefined>(undefined);\n\n const subscribe = useCallback(\n (cb: () => void) =>\n shell.onStateChange(() => {\n cacheRef.current = { shell, tree: shell.getShellRenderTree() };\n cb();\n }),\n [shell],\n );\n\n const getSnapshot = useCallback((): RenderNode[] => {\n const cached = cacheRef.current;\n if (cached === undefined || cached.shell !== shell) {\n const tree = shell.getShellRenderTree();\n cacheRef.current = { shell, tree };\n return tree;\n }\n return cached.tree;\n }, [shell]);\n\n // The third argument is what a SERVER reads. The shell exists there too, with\n // a real state, so it is the same read — and without it React refuses to draw\n // this to markup at all (\"Missing getServerSnapshot\").\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n","import { useMemo, useState, type FC, type ReactNode } from 'react';\nimport {\n createComponentRegistry,\n createLayoutStore,\n renderLayout,\n type ComponentRegistry,\n type LayoutNode,\n type LayoutStore,\n type RegistrationInput,\n type RenderContext,\n type RenderOnError,\n} from '@layout';\nimport type { Shell } from '@shell';\nimport { registerNovaReactComponents } from './components';\nimport type { SlotWrapper } from './context';\nimport { NovaRenderProvider, NovaShellProvider } from './provider';\nimport { RenderTree } from './render-tree';\nimport { useCanvasRenderTree } from './hooks/use-canvas-render-tree';\nimport { useShell } from './hooks/use-shell';\nimport { useShellRenderTree } from './hooks/use-shell-render-tree';\nimport type { NovaComponent } from './types';\n\n// ═══════════════════════════════════════════════════════════\n// <Nova.Layout> / <Nova.Shell> / <Nova.Canvas>\n//\n// The three mountable surfaces for Nova. Each hides the\n// registry/store/provider/render-tree wiring behind a single\n// component so stories and apps can stay declarative.\n//\n// <Nova.Layout layout data components? />\n// <Nova.Shell shell />\n// <Nova.Canvas shell? id />\n//\n// Lower-level primitives (NovaShellProvider, RenderTree, the\n// render-tree hooks) remain exported for advanced composition.\n// ═══════════════════════════════════════════════════════════\n\nconst ensureReactBuiltins = (registry: ComponentRegistry<NovaComponent>): void => {\n // Idempotent: the React adapter's slot components (CanvasSlot / ActionSlot)\n // are required for the shell's default layouts, and the primitive\n // components (Stack, Text, Input, Button, Box) are the authoring vocabulary\n // every demo expects. A single presence check short-circuits re-registration.\n if (registry.has('CanvasSlot')) return;\n registerNovaReactComponents(registry);\n};\n\n// ─── <Nova.Layout> ─────────────────────────────────────────\n\nexport type NovaLayoutProps = {\n // The layout tree to render. Inline LayoutNode or a LayoutStore id\n // (requires `store` to contain that id).\n layout: LayoutNode | string;\n // Data scope for resolvables (`$.x`, `{{x}}`). Defaults to `{}`.\n data?: Record<string, unknown>;\n // Extra components to register. Merged after builtins so they can\n // override (rare) or extend (common) the default set.\n components?: Record<string, RegistrationInput<NovaComponent>>;\n // Pass a pre-built registry instead of letting Nova create one.\n // When provided, `components` and `builtins` are ignored — the\n // caller is responsible for the registry's contents.\n registry?: ComponentRegistry<NovaComponent>;\n // Pass a pre-built layout store instead of letting Nova create one.\n store?: LayoutStore;\n // Register Nova's React builtins (Stack, Text, Input, Button, Box,\n // CanvasSlot, ActionSlot). Default true. Only applies when `registry`\n // was NOT provided.\n builtins?: boolean;\n strict?: boolean;\n onError?: RenderOnError;\n // The words this layout wears. Forwarded to the renderer, which is where a\n // language enters — this component translates nothing itself, and neither\n // does any other adapter.\n phrases?: RenderContext['phrases'];\n phraseKeys?: RenderContext['phraseKeys'];\n onPhraseMiss?: RenderContext['onPhraseMiss'];\n children?: ReactNode;\n};\n\nexport const NovaLayout: FC<NovaLayoutProps> = ({\n layout,\n data,\n components,\n registry: registryProp,\n store: storeProp,\n builtins = true,\n strict,\n onError,\n phrases,\n phraseKeys,\n onPhraseMiss,\n children,\n}) => {\n // A registry and store are stable for the lifetime of this component\n // instance. useState(init) fixes them on first render without the hazards\n // of registering during useMemo recomputation.\n const [registry] = useState<ComponentRegistry<NovaComponent>>(() => {\n if (registryProp !== undefined) return registryProp;\n const reg = createComponentRegistry<NovaComponent>();\n if (builtins) registerNovaReactComponents(reg);\n if (components !== undefined) reg.registerAll(components);\n return reg;\n });\n const [store] = useState<LayoutStore>(() => storeProp ?? createLayoutStore());\n\n const nodes = useMemo(() => {\n const resolved = typeof layout === 'string' ? store.get(layout) : layout;\n if (resolved === undefined) return [];\n return renderLayout(resolved, data ?? {}, {\n store,\n registry,\n ...(strict === undefined ? {} : { strict }),\n ...(onError === undefined ? {} : { onError }),\n ...(phrases === undefined ? {} : { phrases }),\n ...(phraseKeys === undefined ? {} : { phraseKeys }),\n ...(onPhraseMiss === undefined ? {} : { onPhraseMiss }),\n });\n }, [layout, data, store, registry, strict, onError, phrases, phraseKeys, onPhraseMiss]);\n\n return (\n <NovaRenderProvider registry={registry}>\n <RenderTree nodes={nodes} />\n {children}\n </NovaRenderProvider>\n );\n};\n\n// ─── <Nova.Shell> ──────────────────────────────────────────\n\nexport type NovaShellProps = {\n shell: Shell;\n // Override the registry used for rendering. Defaults to shell.registry.\n // Pass this only when the same shell should render against a different\n // component set (rare — typically for theming or A/B swaps).\n registry?: ComponentRegistry<NovaComponent>;\n // Optional app-supplied component that wraps every action instance's content\n // at the ActionSlot seam (animation, auth/feature gates, logging, …). Nova\n // owns none of that logic — see `SlotWrapper`. Omit for plain rendering.\n slotWrapper?: SlotWrapper;\n // Ensure the React adapter's slot components are registered on the\n // shell's registry. Default true. Safe to leave on — idempotent.\n builtins?: boolean;\n};\n\nconst ShellRenderTreeView: FC = () => {\n const nodes = useShellRenderTree();\n return <RenderTree nodes={nodes} />;\n};\n\nexport const NovaShell: FC<NovaShellProps> = ({ shell, registry, slotWrapper, builtins = true }) => {\n const resolvedRegistry = (registry ?? shell.registry) as ComponentRegistry<NovaComponent>;\n // Register React builtins onto the resolved registry on first render.\n // useState's lazy initializer gives us a synchronous, once-per-mount hook.\n useState(() => {\n if (builtins) ensureReactBuiltins(resolvedRegistry);\n return true;\n });\n return (\n <NovaShellProvider shell={shell} registry={resolvedRegistry} slotWrapper={slotWrapper}>\n <ShellRenderTreeView />\n </NovaShellProvider>\n );\n};\n\n// ─── <Nova.Canvas> ─────────────────────────────────────────\n\nexport type NovaCanvasProps = {\n // The canvas to render.\n id: string;\n // Optional: when provided, Nova.Canvas creates its own NovaShellProvider.\n // When omitted, Nova.Canvas must be nested inside an existing\n // <Nova.Shell> / <NovaShellProvider>.\n shell?: Shell;\n registry?: ComponentRegistry<NovaComponent>;\n builtins?: boolean;\n};\n\nconst CanvasRenderTreeView: FC<{ canvasId: string }> = ({ canvasId }) => {\n const nodes = useCanvasRenderTree(canvasId);\n return <RenderTree nodes={nodes} />;\n};\n\nconst CanvasInContext: FC<{ canvasId: string }> = ({ canvasId }) => {\n // Asserts we're inside a NovaShellProvider so useShell doesn't throw.\n useShell();\n return <CanvasRenderTreeView canvasId={canvasId} />;\n};\n\nconst CanvasStandalone: FC<{\n canvasId: string;\n shell: Shell;\n registry?: ComponentRegistry<NovaComponent>;\n builtins: boolean;\n}> = ({ canvasId, shell, registry, builtins }) => {\n const resolvedRegistry = (registry ?? shell.registry) as ComponentRegistry<NovaComponent>;\n useState(() => {\n if (builtins) ensureReactBuiltins(resolvedRegistry);\n return true;\n });\n return (\n <NovaShellProvider shell={shell} registry={resolvedRegistry}>\n <CanvasRenderTreeView canvasId={canvasId} />\n </NovaShellProvider>\n );\n};\n\nexport const NovaCanvas: FC<NovaCanvasProps> = ({ id, shell, registry, builtins = true }) => {\n if (shell === undefined) return <CanvasInContext canvasId={id} />;\n return (\n <CanvasStandalone\n canvasId={id}\n shell={shell}\n builtins={builtins}\n {...(registry === undefined ? {} : { registry })}\n />\n );\n};\n\n// ─── namespace ─────────────────────────────────────────────\n\nexport const Nova = {\n Layout: NovaLayout,\n Shell: NovaShell,\n Canvas: NovaCanvas,\n} as const;\n","import { useCallback, useRef, useSyncExternalStore } from 'react';\nimport type { Shell, StateSnapshot } from '@shell';\nimport { useShell } from './use-shell';\n\nexport const useShellState = (): StateSnapshot => {\n const shell = useShell();\n const cacheRef = useRef<{ shell: Shell; snapshot: StateSnapshot } | undefined>(undefined);\n if (cacheRef.current === undefined || cacheRef.current.shell !== shell) {\n cacheRef.current = { shell, snapshot: shell.getState() };\n }\n\n const subscribe = useCallback(\n (cb: () => void) =>\n shell.onStateChange((snapshot) => {\n cacheRef.current = { shell, snapshot };\n cb();\n }),\n [shell],\n );\n\n const getSnapshot = useCallback((): StateSnapshot => {\n const cached = cacheRef.current;\n if (cached === undefined || cached.shell !== shell) {\n const snapshot = shell.getState();\n cacheRef.current = { shell, snapshot };\n return snapshot;\n }\n return cached.snapshot;\n }, [shell]);\n\n // The third argument is what a SERVER reads. The shell exists there too, with\n // a real state, so it is the same read — and without it React refuses to draw\n // this to markup at all (\"Missing getServerSnapshot\").\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n","import { useCallback, useRef, useSyncExternalStore } from 'react';\nimport type { CanvasState, Shell } from '@shell';\nimport { useShell } from './use-shell';\n\ntype Cache = {\n shell: Shell;\n canvasId: string;\n state: CanvasState;\n};\n\nexport const useCanvas = (canvasId: string): CanvasState => {\n const shell = useShell();\n const cacheRef = useRef<Cache | undefined>(undefined);\n\n // The shell owns canvas-change equality — onCanvasChange only fires on\n // meaningful change, so no comparator lives here.\n const subscribe = useCallback(\n (cb: () => void) =>\n shell.onCanvasChange(canvasId, (next) => {\n cacheRef.current = { shell, canvasId, state: next };\n cb();\n }),\n [shell, canvasId],\n );\n\n const getSnapshot = useCallback((): CanvasState => {\n const cached = cacheRef.current;\n if (cached !== undefined && cached.shell === shell && cached.canvasId === canvasId) {\n return cached.state;\n }\n const state = shell.getCanvasState(canvasId);\n cacheRef.current = { shell, canvasId, state };\n return state;\n }, [shell, canvasId]);\n\n // The third argument is what a SERVER reads. The shell exists there too, with\n // a real state, so it is the same read — and without it React refuses to draw\n // this to markup at all (\"Missing getServerSnapshot\").\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n","import { useCallback, useRef, useSyncExternalStore } from 'react';\nimport { useShell } from './use-shell';\n\ntype DataSnapshot = Record<string, unknown> | undefined;\n\nexport const useActionData = (instanceId: string): DataSnapshot => {\n const shell = useShell();\n const cacheRef = useRef<DataSnapshot>(undefined);\n\n const subscribe = useCallback(\n (cb: () => void) => {\n const runtime = shell.getRuntime(instanceId);\n if (runtime === undefined) return () => {};\n return runtime.onDataChange((next) => {\n cacheRef.current = next;\n cb();\n });\n },\n [shell, instanceId],\n );\n\n const getSnapshot = useCallback((): DataSnapshot => {\n const runtime = shell.getRuntime(instanceId);\n if (runtime === undefined) {\n cacheRef.current = undefined;\n return undefined;\n }\n const current = runtime.getData();\n if (cacheRef.current !== current) cacheRef.current = current;\n return cacheRef.current;\n }, [shell, instanceId]);\n\n // The third argument is what a SERVER reads. The shell exists there too, with\n // a real state, so it is the same read — and without it React refuses to draw\n // this to markup at all (\"Missing getServerSnapshot\").\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n","import { useCallback, useRef, useSyncExternalStore } from 'react';\nimport type { ActionStatus } from '@action';\nimport { useShell } from './use-shell';\n\nexport const useActionStatus = (instanceId: string): ActionStatus | undefined => {\n const shell = useShell();\n const cacheRef = useRef<ActionStatus | undefined>(undefined);\n\n const subscribe = useCallback(\n (cb: () => void) => {\n const runtime = shell.getRuntime(instanceId);\n if (runtime === undefined) return () => {};\n return runtime.onStatusChange((next) => {\n cacheRef.current = next;\n cb();\n });\n },\n [shell, instanceId],\n );\n\n const getSnapshot = useCallback((): ActionStatus | undefined => {\n const runtime = shell.getRuntime(instanceId);\n if (runtime === undefined) {\n cacheRef.current = undefined;\n return undefined;\n }\n const current = runtime.instance.status;\n if (cacheRef.current !== current) cacheRef.current = current;\n return cacheRef.current;\n }, [shell, instanceId]);\n\n // The third argument is what a SERVER reads. The shell exists there too, with\n // a real state, so it is the same read — and without it React refuses to draw\n // this to markup at all (\"Missing getServerSnapshot\").\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n","import { useCallback, useRef, useSyncExternalStore } from 'react';\nimport type { RenderNode } from '@layout';\nimport type { Phrasebook } from '../../../i18n/phrases';\nimport { useShell } from './use-shell';\n\ntype Cache = {\n data: Record<string, unknown> | undefined;\n // WHAT ELSE A TREE DEPENDS ON. Data is not the only input to a render: the\n // renderer also reads the shell's book, and `setPhrases` changes it without\n // touching a single instance's data. Cached on data alone, an instance that\n // was already mounted when the language changed would go on showing the old\n // words until something unrelated happened to it — which is precisely the\n // failure `setPhrases` exists to prevent.\n phrases: Phrasebook | undefined;\n tree: RenderNode[];\n};\n\nconst EMPTY: RenderNode[] = [];\n\nexport const useRenderTree = (instanceId: string): RenderNode[] => {\n const shell = useShell();\n const cacheRef = useRef<Cache | undefined>(undefined);\n\n const subscribe = useCallback(\n (cb: () => void) => {\n // Two sources, because a tree has two inputs. Data changes come from the\n // runtime; a language change is shell-wide and arrives as a state change,\n // the same signal the canvas and shell trees already listen to.\n const offState = shell.onStateChange(() => cb());\n const runtime = shell.getRuntime(instanceId);\n if (runtime === undefined) return offState;\n const offData = runtime.onDataChange(() => cb());\n return (): void => {\n offData();\n offState();\n };\n },\n [shell, instanceId],\n );\n\n const getSnapshot = useCallback((): RenderNode[] => {\n const runtime = shell.getRuntime(instanceId);\n if (runtime === undefined) {\n cacheRef.current = undefined;\n return EMPTY;\n }\n const data = runtime.getData();\n const phrases = shell.getPhrases();\n const cached = cacheRef.current;\n if (cached !== undefined && cached.data === data && cached.phrases === phrases) return cached.tree;\n const tree = runtime.render();\n cacheRef.current = { data, phrases, tree };\n return tree;\n }, [shell, instanceId]);\n\n // The third argument is what a SERVER reads. The shell exists there too, with\n // a real state, so it is the same read — and without it React refuses to draw\n // this to markup at all (\"Missing getServerSnapshot\").\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n","import { useContext } from 'react';\nimport { NovaRenderContext } from '../context';\nimport type { NovaDispatch } from '../types';\n\nexport const useNovaDispatch = (): NovaDispatch => {\n const ctx = useContext(NovaRenderContext);\n if (ctx === undefined) {\n throw new Error('useNovaDispatch must be used inside <NovaRenderProvider>');\n }\n return ctx.dispatch;\n};\n","import { useContext } from 'react';\nimport { NovaRenderContext } from '../context';\nimport type { NovaPublish } from '../types';\n\nexport const useNovaPublish = (): NovaPublish => {\n const ctx = useContext(NovaRenderContext);\n if (ctx === undefined) {\n throw new Error('useNovaPublish must be used inside <NovaRenderProvider>');\n }\n return ctx.publish;\n};\n","import { useContext } from 'react';\nimport type { ComponentRegistry } from '@layout';\nimport { NovaRenderContext } from '../context';\nimport type { NovaComponent } from '../types';\n\n// Returns the component registry exposed via <NovaRenderProvider>.\n// Useful for components that need to introspect or look up other\n// registered components (for agent tooling, dev inspectors, etc).\nexport const useNovaRegistry = (): ComponentRegistry<NovaComponent> => {\n const ctx = useContext(NovaRenderContext);\n if (ctx === undefined) {\n throw new Error('useNovaRegistry must be used inside <NovaRenderProvider>');\n }\n return ctx.registry;\n};\n","import { useContext } from 'react';\nimport { NovaRenderContext, type SlotWrapper } from '../context';\n\n// Reads the optional app-supplied slotWrapper from render context. Returns\n// undefined when none was provided (or when called outside a provider) — the\n// caller then renders content directly (passthrough). Unlike the dispatch/\n// publish hooks this never throws: a missing slotWrapper is the common case.\nexport const useSlotWrapper = (): SlotWrapper | undefined =>\n useContext(NovaRenderContext)?.slotWrapper;\n"]}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|