streetui 1.2.0 → 1.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.
@@ -1,4 +1,4 @@
1
- import { C as CompiledApplication } from './compile-DsNJm9IJ.cjs';
1
+ import { C as CompiledApplication } from './compile-CTA4MLX6.cjs';
2
2
 
3
3
  /**
4
4
  * DOMAdapter — framework-owned abstraction over DOM operations.
@@ -1,4 +1,4 @@
1
- import { C as CompiledApplication } from './compile-DsNJm9IJ.js';
1
+ import { C as CompiledApplication } from './compile-CTA4MLX6.js';
2
2
 
3
3
  /**
4
4
  * DOMAdapter — framework-owned abstraction over DOM operations.
package/dist/server.cjs CHANGED
@@ -1101,7 +1101,7 @@ function renderToString(compiled, options = {}) {
1101
1101
  }
1102
1102
 
1103
1103
  // src/version.ts
1104
- var VERSION = "1.2.0";
1104
+ var VERSION = "1.3.0";
1105
1105
  // Annotate the CommonJS export names for ESM import in node:
1106
1106
  0 && (module.exports = {
1107
1107
  STATE_MARKER_ATTR,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts","../../renderer/src/render-context.ts","../../core/src/lifecycle.ts","../../renderer/src/node-instance.ts","../../renderer/src/attributes.ts","../../renderer/src/events.ts","../../renderer/src/tag-map.ts","../../renderer/src/patch.ts","../../renderer/src/reconciliation.ts","../../renderer/src/mount.ts","../../dom/src/server-node.ts","../../dom/src/server-adapter.ts","../../renderer/src/dehydrate.ts","../../renderer/src/ssr.ts","../src/version.ts"],"sourcesContent":["/**\n * `streetui/server` — server-only rendering helpers.\n *\n * This is a *curated subset* of the same framework that powers `streetui`; it\n * does not introduce a second renderer or SSR implementation. It re-exports the\n * already-implemented server-side rendering surface so server entry points can\n * import exactly what they need without pulling in browser-only concerns.\n *\n * ```ts\n * import { renderToString, serializeState, ServerDOMAdapter } from 'streetui/server';\n * ```\n *\n * Client-side hydration (`hydrate` / `createRenderer`) is available from the\n * main `streetui` entry.\n */\n\n// Server-side rendering: compiled app → HTML string, with hydration state.\nexport {\n renderToString,\n serializeState,\n readState,\n STATE_MARKER_ATTR,\n} from '@streetui/renderer';\nexport type { RenderToStringOptions } from '@streetui/renderer';\n\n// The DOM adapter used to render on the server (no live browser DOM).\nexport { ServerDOMAdapter } from '@streetui/dom';\n\n// Re-export the framework version for parity with the main entry.\nexport { VERSION } from './version.js';\n","/**\n * RenderContext — shared state for a single mount operation.\n *\n * Passed through the render pipeline so every sub-function has access\n * to the DOM adapter, graph, and instance map without prop-drilling.\n */\n\nimport type { DOMAdapter } from '@streetui/dom';\nimport type { ApplicationGraph, GraphNode } from '@streetui/graph';\nimport type { NodeInstance } from './node-instance.js';\nimport type { HydrationDiagnosticSink } from './hydration-diagnostics.js';\n\nexport interface RenderContext {\n readonly dom: DOMAdapter;\n readonly graph: ApplicationGraph;\n /** Maps GraphNode.id → its live NodeInstance */\n readonly instances: Map<string, NodeInstance>;\n /** The root container element. */\n readonly container: Element;\n /**\n * Optional dev-only sink that observes hydration mismatch repairs. When\n * absent (the default) the hydration path does no extra work — this is how\n * DevTools/diagnostics stay off the production runtime path.\n */\n readonly hydrationDiagnostics?: HydrationDiagnosticSink;\n}\n\nexport function createRenderContext(\n dom: DOMAdapter,\n graph: ApplicationGraph,\n container: Element,\n hydrationDiagnostics?: HydrationDiagnosticSink,\n): RenderContext {\n return {\n dom,\n graph,\n instances: new Map(),\n container,\n ...(hydrationDiagnostics !== undefined ? { hydrationDiagnostics } : {}),\n };\n}\n","/**\n * Application and component lifecycle primitives.\n *\n * Lifecycle phases:\n * created → mounted → active ⇄ updating → unmounting → destroyed\n */\n\nexport type LifecyclePhase =\n | 'created'\n | 'mounted'\n | 'active'\n | 'updating'\n | 'unmounting'\n | 'destroyed';\n\nexport type LifecycleHook = () => void | Promise<void>;\n\nexport class Lifecycle {\n private _phase: LifecyclePhase = 'created';\n private readonly _hooks: Map<LifecyclePhase, LifecycleHook[]> = new Map();\n\n get phase(): LifecyclePhase {\n return this._phase;\n }\n\n get isMounted(): boolean {\n return this._phase === 'mounted' || this._phase === 'active' || this._phase === 'updating';\n }\n\n get isDestroyed(): boolean {\n return this._phase === 'destroyed';\n }\n\n on(phase: LifecyclePhase, hook: LifecycleHook): () => void {\n const hooks = this._hooks.get(phase) ?? [];\n hooks.push(hook);\n this._hooks.set(phase, hooks);\n return () => {\n const current = this._hooks.get(phase);\n if (current !== undefined) {\n const idx = current.indexOf(hook);\n if (idx !== -1) current.splice(idx, 1);\n }\n };\n }\n\n async transition(to: LifecyclePhase): Promise<void> {\n this._phase = to;\n const hooks = this._hooks.get(to) ?? [];\n for (const hook of hooks) {\n await hook();\n }\n }\n\n onMount(hook: LifecycleHook): () => void {\n return this.on('mounted', hook);\n }\n\n onUnmount(hook: LifecycleHook): () => void {\n return this.on('unmounting', hook);\n }\n\n onDestroy(hook: LifecycleHook): () => void {\n return this.on('destroyed', hook);\n }\n}\n\n/** A simple cleanup registry — collect teardown functions and run them all at once. */\nexport class CleanupRegistry {\n private readonly _fns: Array<() => void> = [];\n\n add(fn: () => void): void {\n this._fns.push(fn);\n }\n\n run(): void {\n for (const fn of this._fns) {\n try {\n fn();\n } catch {\n // Best-effort cleanup; don't let one failure block others\n }\n }\n this._fns.length = 0;\n }\n}\n","/**\n * NodeInstance — the renderer's live counterpart to a GraphNode.\n *\n * Tracks the actual DOM node(s), all signal subscriptions that drive\n * targeted DOM updates, and DOM event listener teardowns.\n */\n\nimport { CleanupRegistry } from '@streetui/core';\nimport type { GraphNode } from '@streetui/graph';\nimport type { ReadonlySignal } from '@streetui/state';\n\nexport class NodeInstance {\n readonly graphNode: GraphNode;\n /** The primary DOM node for this instance (element or text node). */\n domNode: Node;\n readonly children: NodeInstance[] = [];\n readonly cleanup: CleanupRegistry = new CleanupRegistry();\n\n constructor(graphNode: GraphNode, domNode: Node) {\n this.graphNode = graphNode;\n this.domNode = domNode;\n }\n\n addChild(child: NodeInstance): void {\n this.children.push(child);\n }\n\n /** Subscribe to a signal; auto-cleanup on unmount. */\n trackSignal<T>(sig: ReadonlySignal<T>, handler: (v: T) => void): void {\n const unsub = sig.subscribe(handler);\n this.cleanup.add(unsub);\n }\n\n /** Register a raw cleanup fn (DOM event removal, etc.). */\n trackCleanup(fn: () => void): void {\n this.cleanup.add(fn);\n }\n\n dispose(): void {\n for (const child of this.children) {\n child.dispose();\n }\n this.cleanup.run();\n }\n}\n","/**\n * Attribute and property application helpers.\n *\n * Decides whether a prop should be set as a DOM attribute or a JS property,\n * handling special cases (boolean attrs, event-like props, style, class).\n */\n\nimport type { DOMAdapter } from '@streetui/dom';\n\n// Properties that must be set as JS object properties, not HTML attributes\nconst DOM_PROPERTIES = new Set([\n 'value', 'checked', 'selected', 'indeterminate',\n 'innerHTML', 'textContent', 'innerText',\n 'scrollTop', 'scrollLeft',\n]);\n\n// Boolean attributes — present means true, absent means false\nconst BOOLEAN_ATTRS = new Set([\n 'disabled', 'readonly', 'required', 'checked', 'selected',\n 'multiple', 'autofocus', 'autoplay', 'controls', 'default',\n 'defer', 'formnovalidate', 'hidden', 'ismap', 'loop',\n 'novalidate', 'open', 'reversed', 'scoped', 'seamless',\n]);\n\nexport function applyProp(\n dom: DOMAdapter,\n element: Element,\n name: string,\n value: unknown,\n): void {\n // Skip internal renderer metadata\n if (name.startsWith('_')) return;\n // Skip event handlers (handled separately)\n if (name.startsWith('on')) return;\n\n if (DOM_PROPERTIES.has(name)) {\n dom.setProperty(element, name, value);\n return;\n }\n\n if (BOOLEAN_ATTRS.has(name)) {\n if (value === true || value === '' || value === name) {\n dom.setAttribute(element, name, '');\n } else {\n dom.removeAttribute(element, name);\n }\n return;\n }\n\n if (name === 'class' || name === 'className') {\n dom.setAttribute(element, 'class', String(value ?? ''));\n return;\n }\n\n if (name === 'style' && typeof value === 'object' && value !== null) {\n const el = element as HTMLElement;\n const styles = value as Record<string, string>;\n for (const [k, v] of Object.entries(styles)) {\n el.style.setProperty(k, v);\n }\n return;\n }\n\n if (value === null || value === undefined || value === false) {\n dom.removeAttribute(element, name);\n return;\n }\n\n dom.setAttribute(element, name, String(value));\n}\n\nexport function patchProp(\n dom: DOMAdapter,\n element: Element,\n name: string,\n oldValue: unknown,\n newValue: unknown,\n): void {\n if (Object.is(oldValue, newValue)) return;\n applyProp(dom, element, name, newValue);\n}\n","/**\n * Event wiring for the renderer.\n *\n * Given a GraphNode with event descriptors, this wires DOM listeners\n * that call the handlers stored in the graph's handler registry.\n */\n\nimport type { DOMAdapter } from '@streetui/dom';\nimport type { ApplicationGraph, GraphNode } from '@streetui/graph';\nimport type { NodeInstance } from './node-instance.js';\n\nexport function wireEvents(\n dom: DOMAdapter,\n graph: ApplicationGraph,\n node: GraphNode,\n element: Element,\n instance: NodeInstance,\n): void {\n // Fast exit for event-free nodes — avoids allocating a for-of iterator over\n // an empty array on every node during a large mount/hydrate.\n if (node.events.length === 0) return;\n for (const eventDesc of node.events) {\n const handler = graph.getHandler(eventDesc.handlerKey);\n if (handler === undefined) continue;\n\n const domListener: EventListener = (domEvent: Event) => {\n // For input events, pass the current value as first arg\n if (eventDesc.type === 'input' || eventDesc.type === 'change') {\n const input = domEvent.target as HTMLInputElement;\n (handler as (v: string) => void)(input.value);\n } else if (eventDesc.type === 'submit') {\n domEvent.preventDefault();\n (handler as (e: Event) => void)(domEvent);\n } else {\n (handler as () => void)();\n }\n };\n\n dom.addEventListener(element, eventDesc.type, domListener);\n instance.trackCleanup(() => {\n dom.removeEventListener(element, eventDesc.type, domListener);\n });\n }\n}\n","/**\n * Maps semantic node types to HTML tag names.\n */\n\nimport type { SemanticNodeType } from '@streetui/core';\n\nconst TAG_MAP: Partial<Record<SemanticNodeType, string>> = {\n application: 'div',\n page: 'div',\n section: 'section',\n container: 'div',\n heading: 'h1',\n text: 'span',\n button: 'button',\n input: 'input',\n form: 'form',\n list: 'ul',\n 'list-item': 'li',\n image: 'img',\n link: 'a',\n component: 'div',\n slot: 'div',\n fragment: 'div',\n 'reactive-list': 'ul',\n};\n\nexport function resolveTag(type: SemanticNodeType): string {\n return TAG_MAP[type] ?? 'div';\n}\n","/**\n * Patch — targeted DOM updates driven by signal changes.\n *\n * When a signal fires, we look up the NodeInstance and apply\n * only the changed prop — no full re-render, no tree diffing.\n */\n\nimport type { RenderContext } from './render-context.js';\nimport type { GraphNode } from '@streetui/graph';\nimport { applyProp, patchProp } from './attributes.js';\n\nexport function patchNode(\n ctx: RenderContext,\n graphNode: GraphNode,\n propKey: string,\n newValue: unknown,\n): void {\n const instance = ctx.instances.get(graphNode.id);\n if (instance === undefined) return;\n\n const domNode = instance.domNode;\n if (!ctx.dom.isElement(domNode)) return;\n\n const oldValue = graphNode.getProp(propKey);\n\n switch (propKey) {\n case 'text':\n if (!Object.is(oldValue, newValue)) {\n ctx.dom.setTextContent(domNode, String(newValue ?? ''));\n graphNode.setProp('text', String(newValue ?? ''));\n }\n break;\n case 'label':\n if (!Object.is(oldValue, newValue)) {\n ctx.dom.setTextContent(domNode, String(newValue ?? ''));\n graphNode.setProp('label', String(newValue ?? ''));\n }\n break;\n case 'disabled':\n if (newValue === true) {\n ctx.dom.setAttribute(domNode, 'disabled', '');\n } else {\n ctx.dom.removeAttribute(domNode, 'disabled');\n }\n graphNode.setProp('disabled', Boolean(newValue));\n break;\n case 'value':\n if (!Object.is(oldValue, newValue)) {\n ctx.dom.setProperty(domNode, 'value', String(newValue ?? ''));\n graphNode.setProp('value', String(newValue ?? ''));\n }\n break;\n default:\n patchProp(ctx.dom, domNode, propKey, oldValue, newValue);\n graphNode.setProp(propKey, newValue as string);\n break;\n }\n}\n","/**\n * Reconciliation — diff-based child list updates.\n *\n * When the children of a node change (e.g. a list driven by state),\n * this reconciler:\n * 1. Matches old instances to new graph nodes by key\n * 2. Reuses matched instances (updates their props)\n * 3. Applies a targeted content update to a reused item whose data changed\n * 4. Creates new instances for additions\n * 5. Removes stale instances (and prunes their handler registrations)\n * 6. Moves DOM nodes to match new order\n *\n * This is keyed reconciliation over the semantic graph — there is no virtual\n * DOM. A reused item keeps its own DOM element; only its changed content is\n * updated in place (falling back to remounting a subtree only where its shape\n * actually changed).\n */\n\nimport type { RenderContext } from './render-context.js';\nimport type { GraphNode } from '@streetui/graph';\nimport type { NodeInstance } from './node-instance.js';\nimport { patchNode } from './patch.js';\n\nexport type MountFn = (node: GraphNode, parent: Element) => NodeInstance;\n\nexport interface ReconcileResult {\n /** Instances in the new order. */\n instances: NodeInstance[];\n /** Instances that were removed and must be disposed. */\n removed: NodeInstance[];\n /**\n * GraphNodes freshly materialised during this reconcile (new rows + rebuilt\n * changed rows). The caller detaches any of these that were not adopted as a\n * live instance's graph node, so no orphan subtree lingers in the graph index.\n */\n built?: GraphNode[];\n}\n\n/**\n * A lazy reconciliation descriptor for one reactive-list row (mirrors the DSL's\n * `ListPlanEntry`). `sig()` and `build()` are only invoked for rows that are\n * genuinely new or whose source reference changed — the whole point of the\n * plan path (spec §15).\n */\nexport interface PlanEntry {\n readonly key: string;\n readonly item: unknown;\n readonly sig: () => string;\n readonly build: () => GraphNode;\n}\n\n/**\n * Reconcile children of a container element against a new list of graph nodes.\n *\n * @param ctx Render context\n * @param parentDom The DOM parent element\n * @param oldInstances Current child instances (in order)\n * @param newNodes New graph children (in desired order)\n * @param mountFn Factory to create a new NodeInstance for a graph node\n */\nexport function reconcileChildren(\n ctx: RenderContext,\n parentDom: Element,\n oldInstances: NodeInstance[],\n newNodes: readonly GraphNode[],\n mountFn: MountFn,\n): ReconcileResult {\n // Build key → old instance map\n const oldByKey = new Map<string, NodeInstance>();\n for (const inst of oldInstances) {\n const key = inst.graphNode.key ?? inst.graphNode.id;\n oldByKey.set(key, inst);\n }\n\n const newInstances: NodeInstance[] = [];\n const usedKeys = new Set<string>();\n\n for (const newNode of newNodes) {\n const key = newNode.key ?? newNode.id;\n const existing = oldByKey.get(key);\n\n if (existing !== undefined) {\n // Reuse — identity is stable, so the DOM element is preserved.\n usedKeys.add(key);\n const oldSig = existing.graphNode.getProp('_sig');\n const newSig = newNode.getProp('_sig');\n patchExistingInstance(ctx, existing, newNode);\n // Data changed but identity did not → targeted content update in place.\n if (!Object.is(oldSig, newSig)) {\n reconcileItemChildren(ctx, existing, newNode, mountFn);\n }\n newInstances.push(existing);\n } else {\n // New — create and mount\n const inst = mountFn(newNode, parentDom);\n newInstances.push(inst);\n }\n }\n\n // Determine removed instances\n const removed: NodeInstance[] = [];\n for (const inst of oldInstances) {\n const key = inst.graphNode.key ?? inst.graphNode.id;\n if (!usedKeys.has(key)) {\n removed.push(inst);\n }\n }\n\n // Remove stale DOM nodes\n for (const inst of removed) {\n const parent = ctx.dom.parentNode(inst.domNode);\n if (parent !== null) {\n ctx.dom.removeChild(parent, inst.domNode);\n }\n inst.dispose();\n }\n\n // Reorder DOM nodes to match new order\n reorderDom(ctx, parentDom, newInstances);\n\n return { instances: newInstances, removed };\n}\n\n/**\n * Plan-based keyed reconciliation (spec §15 — the optimised reactive-list path).\n *\n * Identical observable result to {@link reconcileChildren}, but driven by lazy\n * {@link PlanEntry} descriptors instead of a pre-built array of GraphNodes:\n *\n * - a reused row whose `item` reference is unchanged does **zero** work — no\n * signature hash, no subtree build, no prop patch (the common case for\n * append / prepend / remove / reorder / reverse, where existing item objects\n * keep their identity);\n * - a reused row whose reference changed hashes lazily and, only on a real\n * signature change, materialises a fresh subtree for a targeted in-place\n * content update;\n * - a genuinely new key builds + mounts exactly one subtree.\n *\n * DOM reordering uses a longest-increasing-subsequence pass so the number of\n * moves is minimal (e.g. a prepend into a 10k list moves 1 node, not 10k).\n */\nexport function reconcileChildrenByPlan(\n ctx: RenderContext,\n parentDom: Element,\n oldInstances: NodeInstance[],\n plan: readonly PlanEntry[],\n mountFn: MountFn,\n): ReconcileResult {\n const oldByKey = new Map<string, NodeInstance>();\n for (const inst of oldInstances) {\n oldByKey.set(inst.graphNode.key ?? inst.graphNode.id, inst);\n }\n\n const newInstances: NodeInstance[] = [];\n const usedKeys = new Set<string>();\n const built: GraphNode[] = [];\n\n for (const entry of plan) {\n const existing = oldByKey.get(entry.key);\n if (existing !== undefined) {\n usedKeys.add(entry.key);\n const oldItem = existing.graphNode.getProp('_item');\n // Identity short-circuit: same reference ⇒ data cannot have changed.\n if (!Object.is(oldItem, entry.item)) {\n const newSig = entry.sig();\n const oldSig = existing.graphNode.getProp('_sig');\n if (!Object.is(oldSig, newSig)) {\n const freshNode = entry.build();\n built.push(freshNode);\n patchExistingInstance(ctx, existing, freshNode);\n reconcileItemChildren(ctx, existing, freshNode, mountFn);\n existing.graphNode.setProp('_sig', newSig);\n }\n // Cache the new reference so the next pass can short-circuit again.\n existing.graphNode.setProp('_item', entry.item as never);\n }\n newInstances.push(existing);\n } else {\n const freshNode = entry.build();\n built.push(freshNode);\n const inst = mountFn(freshNode, parentDom);\n newInstances.push(inst);\n }\n }\n\n // Determine + remove stale instances.\n const removed: NodeInstance[] = [];\n for (const inst of oldInstances) {\n const key = inst.graphNode.key ?? inst.graphNode.id;\n if (!usedKeys.has(key)) removed.push(inst);\n }\n for (const inst of removed) {\n const parent = ctx.dom.parentNode(inst.domNode);\n if (parent !== null) ctx.dom.removeChild(parent, inst.domNode);\n inst.dispose();\n }\n\n // Minimal-move reorder to the desired order.\n reorderDomMinimal(ctx, parentDom, oldInstances, newInstances);\n\n return { instances: newInstances, removed, built };\n}\n\n/**\n * Minimal-move DOM reorder.\n *\n * Reused nodes retain their previous DOM slots and newly-mounted nodes sit at\n * the end. We compute the longest increasing subsequence of the reused nodes'\n * previous positions; those are already in correct relative order and stay put.\n * Every other node is inserted before its right-hand neighbour, walking\n * right-to-left. This yields exactly (n − |LIS|) `insertBefore` calls — the\n * minimum — instead of the O(n) sweep the naive reorder performs on a prepend.\n */\nfunction reorderDomMinimal(\n ctx: RenderContext,\n parentDom: Element,\n oldInstances: NodeInstance[],\n newInstances: NodeInstance[],\n): void {\n const n = newInstances.length;\n if (n === 0) return;\n\n const oldIndexOf = new Map<NodeInstance, number>();\n for (let i = 0; i < oldInstances.length; i++) oldIndexOf.set(oldInstances[i]!, i);\n\n const source = new Array<number>(n);\n let moved = false;\n let lastSeen = -1;\n for (let i = 0; i < n; i++) {\n const oi = oldIndexOf.get(newInstances[i]!);\n if (oi === undefined) {\n source[i] = -1; // freshly mounted row\n moved = true;\n } else {\n source[i] = oi;\n if (oi < lastSeen) moved = true; // an out-of-order reused row exists\n else lastSeen = oi;\n }\n }\n\n // Fast path: nothing is out of order and there are no new rows to reposition.\n if (!moved) return;\n\n const keep = longestIncreasingSubsequence(source);\n\n let refNode: Node | null = null;\n for (let i = n - 1; i >= 0; i--) {\n const domNode = newInstances[i]!.domNode;\n if (source[i] === -1 || !keep.has(i)) {\n if (ctx.dom.nextSibling(domNode) !== refNode) {\n ctx.dom.insertBefore(parentDom, domNode, refNode);\n }\n }\n refNode = domNode;\n }\n}\n\n/**\n * Indices (into `source`) forming a longest strictly-increasing subsequence,\n * ignoring `-1` entries (new rows, which always move). O(n log n) with\n * predecessor reconstruction.\n */\nfunction longestIncreasingSubsequence(source: readonly number[]): Set<number> {\n const keep = new Set<number>();\n const n = source.length;\n const tails: number[] = []; // tails[k] = source-index of smallest tail of an LIS of length k+1\n const prev = new Array<number>(n).fill(-1);\n\n for (let i = 0; i < n; i++) {\n const v = source[i]!;\n if (v < 0) continue;\n let lo = 0;\n let hi = tails.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (source[tails[mid]!]! < v) lo = mid + 1;\n else hi = mid;\n }\n if (lo > 0) prev[i] = tails[lo - 1]!;\n tails[lo] = i;\n }\n\n let idx = tails.length > 0 ? tails[tails.length - 1]! : -1;\n while (idx >= 0) {\n keep.add(idx);\n idx = prev[idx]!;\n }\n return keep;\n}\n\n/**\n * Targeted in-place content update for a reused list item whose data changed.\n *\n * The item's DOM element is kept; only its contents are updated. Children are\n * matched positionally against the freshly-built subtree:\n * - same node type at a position → the existing child is reused and its props\n * are patched in place (e.g. a text node's text is rewritten), then we\n * recurse into its children;\n * - different type / new position → the fresh child node is reparented onto the\n * live item node and mounted;\n * - surplus old children → disposed, with DOM, subscriptions, listeners and\n * handler registrations all torn down.\n *\n * This deliberately reuses the same keyed/positional strategy rather than a\n * virtual DOM, and never destroys the item element itself.\n */\nfunction reconcileItemChildren(\n ctx: RenderContext,\n itemInstance: NodeInstance,\n newItemNode: GraphNode,\n mountFn: MountFn,\n): void {\n const el = itemInstance.domNode;\n if (!ctx.dom.isElement(el)) return;\n\n const oldChildren = [...itemInstance.children];\n const newChildNodes = [...newItemNode.children];\n const nextChildren: NodeInstance[] = [];\n const kept = new Set<NodeInstance>();\n\n for (let i = 0; i < newChildNodes.length; i++) {\n const newChild = newChildNodes[i]!;\n const oldChild = oldChildren[i];\n\n if (oldChild !== undefined && oldChild.graphNode.type === newChild.type) {\n // Reuse in place — patch this node's props and recurse into descendants.\n patchExistingInstance(ctx, oldChild, newChild);\n reconcileItemChildren(ctx, oldChild, newChild, mountFn);\n nextChildren.push(oldChild);\n kept.add(oldChild);\n } else {\n // Structural change at this position — mount the fresh child. Reparent it\n // out of the freshly-built subtree so the wholesale detach of the\n // unadopted item node (in mount.ts) does not remove this now-live node.\n itemInstance.graphNode.appendChild(newChild);\n const inst = mountFn(newChild, el);\n nextChildren.push(inst);\n }\n }\n\n // Dispose old children that were not reused (surplus or type-mismatched).\n for (const old of oldChildren) {\n if (kept.has(old)) continue;\n const parent = ctx.dom.parentNode(old.domNode);\n if (parent !== null) ctx.dom.removeChild(parent, old.domNode);\n old.dispose();\n forgetInstanceTree(ctx, old);\n ctx.graph.detachNode(old.graphNode);\n }\n\n // Restore correct DOM order within the item element.\n reorderDom(ctx, el, nextChildren);\n\n // Sync the live instance's children.\n itemInstance.children.length = 0;\n for (const c of nextChildren) itemInstance.children.push(c);\n\n // Keep the graph model's item children consistent with the reconciled order.\n for (const c of [...itemInstance.graphNode.children]) {\n itemInstance.graphNode.removeChild(c);\n }\n for (const c of nextChildren) itemInstance.graphNode.appendChild(c.graphNode);\n}\n\n/** Move a parent's DOM children to match the given instance order (minimal moves). */\nfunction reorderDom(\n ctx: RenderContext,\n parentDom: Element,\n instances: NodeInstance[],\n): void {\n let referenceNode: Node | null = null;\n for (let i = instances.length - 1; i >= 0; i--) {\n const inst = instances[i];\n if (inst === undefined) continue;\n const domNode = inst.domNode;\n const currentNext = ctx.dom.nextSibling(domNode);\n if (currentNext !== referenceNode) {\n ctx.dom.insertBefore(parentDom, domNode, referenceNode);\n }\n referenceNode = domNode;\n }\n}\n\n/** Recursively drop an instance subtree from the renderer's instance index. */\nfunction forgetInstanceTree(ctx: RenderContext, instance: NodeInstance): void {\n ctx.instances.delete(instance.graphNode.id);\n for (const child of instance.children) forgetInstanceTree(ctx, child);\n}\n\nfunction patchExistingInstance(\n ctx: RenderContext,\n instance: NodeInstance,\n newNode: GraphNode,\n): void {\n const oldNode = instance.graphNode;\n for (const [key, newVal] of Object.entries(newNode.props)) {\n const oldVal = oldNode.getProp(key);\n if (!Object.is(oldVal, newVal)) {\n patchNode(ctx, instance.graphNode, key, newVal);\n }\n }\n}\n","/**\n * Initial mount — creates DOM nodes for every GraphNode and\n * attaches them into the container.\n *\n * This is a recursive depth-first walk. For each GraphNode:\n * 1. Create the DOM element (or text node)\n * 2. Apply props/attributes\n * 3. Wire events\n * 4. Wire signal subscriptions for reactive props\n * 5. Recurse into children\n * 6. Insert into the DOM\n */\n\nimport type { GraphNode, ApplicationGraph } from '@streetui/graph';\nimport type { DOMAdapter } from '@streetui/dom';\nimport type { RenderContext } from './render-context.js';\nimport { NodeInstance } from './node-instance.js';\nimport { applyProp } from './attributes.js';\nimport { wireEvents } from './events.js';\nimport { resolveTag } from './tag-map.js';\nimport {\n reconcileChildren,\n reconcileChildrenByPlan,\n type PlanEntry,\n} from './reconciliation.js';\n\n/**\n * Prop keys handled by the per-type mount branches (or reserved internals), so\n * `applyNodeProps` must skip them to avoid double-applying. This set is\n * invariant across nodes, so it is hoisted to module scope: allocating it once\n * (rather than per node) removes N Set allocations per mount/SSR pass and the\n * GC pressure they create. Treat as read-only — never mutate.\n */\nconst SKIP_PROP_KEYS: ReadonlySet<string> = new Set([\n 'text', 'label', 'level', 'inputType', 'src', 'alt', 'href', 'external',\n 'value', 'placeholder', 'disabled', '_renderKey', 'key', 'name',\n]);\n\nexport function mountGraph(ctx: RenderContext): NodeInstance {\n return mountNode(ctx, ctx.graph.root, ctx.container);\n}\n\nexport function mountNode(\n ctx: RenderContext,\n graphNode: GraphNode,\n parentDom: Node,\n): NodeInstance {\n const { dom, graph } = ctx;\n\n // The application root node maps to the container itself — don't create a duplicate element\n if (graphNode.type === 'application') {\n const instance = new NodeInstance(graphNode, parentDom);\n ctx.instances.set(graphNode.id, instance);\n for (const child of graphNode.children) {\n const childInstance = mountNode(ctx, child, parentDom);\n instance.addChild(childInstance);\n }\n return instance;\n }\n\n // Text-only nodes render as a <span> containing a text node\n if (graphNode.type === 'text') {\n const text = String(graphNode.getProp('text') ?? '');\n const el = dom.createElement('span');\n const textNode = dom.createTextNode(text);\n dom.appendChild(el, textNode);\n applyNodeProps(ctx, graphNode, el);\n\n // Create the live instance up front and reuse it for event wiring. The\n // previous code allocated a throwaway NodeInstance solely to satisfy\n // wireEvents' signature, wasting one NodeInstance (+ its children array and\n // CleanupRegistry) per text node — pure GC pressure on the hottest mount\n // path. wireEvents/wireSignalBindings each early-return on empty arrays.\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, el, instance);\n\n // Reactive text binding — only build the update closure when the node has\n // bindings. wireSignalBindings early-returns on empty stateRefs, so for a\n // static text node (the common case in a large initial render) the\n // textUpdate closure would be allocated and thrown away: avoidable GC\n // pressure on the hottest mount path.\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, textUpdate(dom, el, textNode));\n }\n\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Heading nodes\n if (graphNode.type === 'heading') {\n const level = (graphNode.getProp('level') as number | undefined) ?? 1;\n const tag = `h${level}` as string;\n const el = dom.createElement(tag);\n const text = String(graphNode.getProp('text') ?? '');\n dom.setTextContent(el, text);\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, el, instance);\n\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, headingUpdate(dom, el));\n }\n\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Input nodes\n if (graphNode.type === 'input') {\n const el = dom.createElement('input') as HTMLInputElement;\n const inputType = String(graphNode.getProp('inputType') ?? 'text');\n dom.setAttribute(el, 'type', inputType);\n const placeholder = graphNode.getProp('placeholder');\n if (placeholder !== undefined) dom.setAttribute(el, 'placeholder', String(placeholder));\n const value = graphNode.getProp('value');\n if (value !== undefined) dom.setProperty(el, 'value', String(value));\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, el, instance);\n\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, inputUpdate(dom, el));\n }\n\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Image nodes\n if (graphNode.type === 'image') {\n const el = dom.createElement('img') as HTMLImageElement;\n const src = graphNode.getProp('src');\n const alt = graphNode.getProp('alt');\n if (src !== undefined) dom.setAttribute(el, 'src', String(src));\n if (alt !== undefined) dom.setAttribute(el, 'alt', String(alt));\n const width = graphNode.getProp('width');\n const height = graphNode.getProp('height');\n if (width !== undefined) dom.setAttribute(el, 'width', String(width));\n if (height !== undefined) dom.setAttribute(el, 'height', String(height));\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Link nodes\n if (graphNode.type === 'link') {\n const el = dom.createElement('a') as HTMLAnchorElement;\n const href = graphNode.getProp('href');\n const label = graphNode.getProp('label');\n const external = graphNode.getProp('external');\n if (href !== undefined) dom.setAttribute(el, 'href', String(href));\n if (label !== undefined) dom.setTextContent(el, String(label));\n if (external === true) {\n dom.setAttribute(el, 'target', '_blank');\n dom.setAttribute(el, 'rel', 'noopener noreferrer');\n }\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, el, instance);\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Button nodes\n if (graphNode.type === 'button') {\n const el = dom.createElement('button') as HTMLButtonElement;\n const label = graphNode.getProp('label');\n if (label !== undefined) dom.setTextContent(el, String(label));\n const disabled = graphNode.getProp('disabled');\n if (disabled === true) dom.setAttribute(el, 'disabled', '');\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, el, instance);\n\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, buttonUpdate(dom, el));\n }\n\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Reactive list / conditional — a container whose children are driven by a\n // Signal. Initial child subtrees are already built into the graph by the DSL;\n // on signal change we reconcile the freshly-built desired children against the\n // live DOM using the keyed reconciler (no virtual DOM). A `conditional` uses\n // the identical machinery but renders as a neutral <div> holding 0..1 branch.\n if (graphNode.type === 'reactive-list' || graphNode.type === 'conditional') {\n const tag = resolveTag(graphNode.type);\n const el = dom.createElement(tag);\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n\n for (const child of graphNode.children) {\n const childInstance = mountNode(ctx, child, el);\n instance.addChild(childInstance);\n }\n\n dom.appendChild(parentDom, el);\n wireReactiveList(ctx, graphNode, instance, el);\n return instance;\n }\n\n // Container / section / page / form / list / list-item — structural nodes\n const tag = resolveTag(graphNode.type);\n const el = dom.createElement(tag);\n applyNodeProps(ctx, graphNode, el);\n\n // Surface a reactive-list item's stable, identity-only reconciliation key as a\n // public `data-streetui-key` attribute (e.g. \"id:1\"). This exposes only the\n // identity part — never the internal `_sig` value signature, signal ids or\n // graph node ids — so a row is directly selectable and its identity is\n // inspectable across reorders and in-place data updates.\n if (graphNode.type === 'list-item') {\n const itemKey = graphNode.getProp('key');\n if (itemKey !== undefined) {\n dom.setAttribute(el, 'data-streetui-key', String(itemKey));\n }\n }\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n\n // wire form submit (reuse the live instance rather than a throwaway)\n if (graphNode.type === 'form') {\n wireEvents(dom, graph, graphNode, el, instance);\n }\n\n // Recurse into children\n for (const child of graphNode.children) {\n const childInstance = mountNode(ctx, child, el);\n instance.addChild(childInstance);\n }\n\n dom.appendChild(parentDom, el);\n return instance;\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────────────\n\n/**\n * Per-node-type reactive-binding factories. Each returns the `onUpdate`\n * callback that `wireSignalBindings` invokes when a bound signal changes.\n * Extracted so both the browser mount path and the hydration path apply the\n * exact same DOM mutation semantics for each prop — no duplicated rendering\n * logic.\n */\nexport function textUpdate(\n dom: DOMAdapter,\n el: Element,\n textNode: Text,\n): (propKey: string, value: unknown) => void {\n return (propKey, value) => {\n if (propKey === 'text') {\n dom.setTextContent(textNode, String(value ?? ''));\n } else {\n applyProp(dom, el, propKey, value);\n }\n };\n}\n\nexport function headingUpdate(\n dom: DOMAdapter,\n el: Element,\n): (propKey: string, value: unknown) => void {\n return (propKey, value) => {\n if (propKey === 'text') {\n dom.setTextContent(el, String(value ?? ''));\n } else {\n applyProp(dom, el, propKey, value);\n }\n };\n}\n\nexport function inputUpdate(\n dom: DOMAdapter,\n el: Element,\n): (propKey: string, value: unknown) => void {\n return (propKey, value) => {\n if (propKey === 'value') {\n dom.setProperty(el, 'value', String(value ?? ''));\n } else {\n applyProp(dom, el, propKey, value);\n }\n };\n}\n\nexport function buttonUpdate(\n dom: DOMAdapter,\n el: Element,\n): (propKey: string, value: unknown) => void {\n return (propKey, value) => {\n if (propKey === 'label') {\n dom.setTextContent(el, String(value ?? ''));\n } else if (propKey === 'disabled') {\n if (value === true) {\n dom.setAttribute(el, 'disabled', '');\n } else {\n dom.removeAttribute(el, 'disabled');\n }\n } else {\n applyProp(dom, el, propKey, value);\n }\n };\n}\n\nexport function applyNodeProps(ctx: RenderContext, graphNode: GraphNode, el: Element): void {\n // Iterate own enumerable keys directly rather than via Object.entries, which\n // allocates a wrapper array plus one [key,value] tuple per prop — measurable\n // GC pressure when multiplied across every node in a large initial render.\n const props = graphNode.props;\n for (const key in props) {\n if (!Object.hasOwn(props, key)) continue;\n if (SKIP_PROP_KEYS.has(key)) continue;\n applyProp(ctx.dom, el, key, props[key]);\n }\n}\n\nexport function wireSignalBindings(\n ctx: RenderContext,\n graphNode: GraphNode,\n instance: NodeInstance,\n onUpdate: (propKey: string, value: unknown) => void,\n): void {\n // Fast exit for the common non-reactive node — avoids allocating a for-of\n // iterator over an empty stateRefs array on every static node.\n if (graphNode.stateRefs.length === 0) return;\n for (const stateRef of graphNode.stateRefs) {\n const signalKey = `__signal__${stateRef.signalId}`;\n const maybeSig = ctx.graph.getHandler(signalKey) as\n | { subscribe: (fn: (v: unknown) => void) => () => void; peek: () => unknown }\n | undefined;\n if (maybeSig === undefined || typeof maybeSig.subscribe !== 'function') continue;\n\n // Subscribe directly — avoids the ReadonlySignal<T> generic variance issue\n const unsub = maybeSig.subscribe((value) => {\n onUpdate(stateRef.propKey, value);\n });\n instance.trackCleanup(unsub);\n }\n}\n\n// ── Reactive list wiring ────────────────────────────────────────────────────────\n\ntype ListBuildFn = (items: unknown) => GraphNode[];\ntype ListPlanFn = (items: unknown) => PlanEntry[];\n\n/**\n * Subscribe a reactive-list instance to its driving signal. On each change the\n * DSL-registered plan factory produces lightweight per-row descriptors, which\n * are reconciled against the live DOM with the keyed, minimal-move reconciler\n * (spec §15). A `conditional` node has no plan handler and falls back to the\n * eager build factory (it only ever renders 0..1 branch, so eager is fine).\n */\nexport function wireReactiveList(\n ctx: RenderContext,\n graphNode: GraphNode,\n instance: NodeInstance,\n el: Element,\n): void {\n const plan = ctx.graph.getHandler(`__listplan__${graphNode.id}`) as\n | ListPlanFn\n | undefined;\n const build = ctx.graph.getHandler(`__listbuild__${graphNode.id}`) as\n | ListBuildFn\n | undefined;\n if (plan === undefined && build === undefined) return;\n\n for (const stateRef of graphNode.stateRefs) {\n if (stateRef.propKey !== 'items') continue;\n const sig = ctx.graph.getHandler(`__signal__${stateRef.signalId}`) as\n | { subscribe: (fn: (v: unknown) => void) => () => void }\n | undefined;\n if (sig === undefined || typeof sig.subscribe !== 'function') continue;\n\n const unsub = sig.subscribe((value) => {\n if (plan !== undefined) {\n reconcileReactiveListByPlan(ctx, graphNode, instance, el, plan(value));\n } else {\n reconcileReactiveList(ctx, graphNode, instance, el, build!(value));\n }\n });\n instance.trackCleanup(unsub);\n }\n}\n\nfunction reconcileReactiveListByPlan(\n ctx: RenderContext,\n listNode: GraphNode,\n listInstance: NodeInstance,\n listEl: Element,\n plan: PlanEntry[],\n): void {\n const oldInstances = [...listInstance.children];\n const result = reconcileChildrenByPlan(\n ctx,\n listEl,\n oldInstances,\n plan,\n (node, parent) => mountNode(ctx, node, parent),\n );\n\n // Sync the live instance's children to the reconciled order.\n listInstance.children.length = 0;\n for (const inst of result.instances) listInstance.children.push(inst);\n\n // Forget removed instances, and drop their graph nodes.\n for (const removed of result.removed) {\n forgetInstance(ctx, removed);\n ctx.graph.detachNode(removed.graphNode);\n }\n // Detach any freshly-built subtree that was not adopted as a live instance\n // (e.g. the top node of a rebuilt changed row, whose live instance keeps its\n // original graph node).\n const adopted = new Set(result.instances.map((i) => i.graphNode));\n for (const node of result.built ?? []) {\n if (!adopted.has(node)) ctx.graph.detachNode(node);\n }\n\n // Keep the graph model consistent: list node children match the new order.\n for (const child of [...listNode.children]) listNode.removeChild(child);\n for (const inst of result.instances) listNode.appendChild(inst.graphNode);\n}\n\nfunction reconcileReactiveList(\n ctx: RenderContext,\n listNode: GraphNode,\n listInstance: NodeInstance,\n listEl: Element,\n newNodes: GraphNode[],\n): void {\n const oldInstances = [...listInstance.children];\n const result = reconcileChildren(\n ctx,\n listEl,\n oldInstances,\n newNodes,\n (node, parent) => mountNode(ctx, node, parent),\n );\n\n // Sync the live instance's children to the reconciled order.\n listInstance.children.length = 0;\n for (const inst of result.instances) listInstance.children.push(inst);\n\n // Forget removed instances from the renderer index, and drop their graph\n // nodes (and any un-adopted freshly-built duplicates) from the graph index.\n for (const removed of result.removed) {\n forgetInstance(ctx, removed);\n ctx.graph.detachNode(removed.graphNode);\n }\n const adopted = new Set(result.instances.map((i) => i.graphNode));\n for (const built of newNodes) {\n if (!adopted.has(built)) ctx.graph.detachNode(built);\n }\n\n // Keep the graph model consistent: list node children match the new order.\n for (const child of [...listNode.children]) listNode.removeChild(child);\n for (const inst of result.instances) listNode.appendChild(inst.graphNode);\n}\n\n/** Recursively remove an instance subtree from the renderer's instance index. */\nfunction forgetInstance(ctx: RenderContext, instance: NodeInstance): void {\n ctx.instances.delete(instance.graphNode.id);\n for (const child of instance.children) forgetInstance(ctx, child);\n}\n","/**\n * Server-side DOM node model.\n *\n * A tiny, dependency-free tree of plain objects that mirrors just enough of the\n * browser DOM for StreetUI's renderer to build a tree on the server and\n * serialize it to an HTML string. There is NO browser global here — these are\n * ordinary classes usable in any JavaScript environment (Node, workers, tests).\n *\n * The renderer never touches these types directly; it goes through the\n * `DOMAdapter` interface, and `ServerDOMAdapter` translates adapter calls into\n * operations on this model.\n */\n\nexport type ServerNodeKind = 'element' | 'text' | 'comment' | 'fragment';\n\nexport interface ServerNode {\n readonly kind: ServerNodeKind;\n parent: ServerParent | null;\n}\n\nexport type ServerParent = ServerElement | ServerFragment;\n\n/** A minimal inline-style holder mirroring `element.style.setProperty`. */\nexport class ServerStyle {\n readonly declarations = new Map<string, string>();\n setProperty(name: string, value: string): void {\n this.declarations.set(name, value);\n }\n get isEmpty(): boolean {\n return this.declarations.size === 0;\n }\n toCss(): string {\n return [...this.declarations.entries()].map(([k, v]) => `${k}: ${v}`).join('; ');\n }\n}\n\nexport class ServerText implements ServerNode {\n readonly kind = 'text' as const;\n parent: ServerParent | null = null;\n data: string;\n constructor(data: string) {\n this.data = data;\n }\n}\n\nexport class ServerComment implements ServerNode {\n readonly kind = 'comment' as const;\n parent: ServerParent | null = null;\n data: string;\n constructor(data: string) {\n this.data = data;\n }\n}\n\nexport class ServerFragment implements ServerNode {\n readonly kind = 'fragment' as const;\n parent: ServerParent | null = null;\n readonly children: ServerNode[] = [];\n}\n\nexport class ServerElement implements ServerNode {\n readonly kind = 'element' as const;\n parent: ServerParent | null = null;\n readonly tagName: string;\n readonly attributes = new Map<string, string>();\n /** JS properties set via `setProperty` (e.g. input `value`, `checked`). */\n readonly properties = new Map<string, unknown>();\n readonly children: ServerNode[] = [];\n readonly style = new ServerStyle();\n\n constructor(tagName: string) {\n this.tagName = tagName.toLowerCase();\n }\n}\n\n// ── HTML serialization ─────────────────────────────────────────────────────────\n\n/**\n * HTML \"void\" elements — self-closing, never given a closing tag or children.\n */\nconst VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr',\n]);\n\n/**\n * Element properties that should be reflected into the serialized HTML so the\n * hydrated DOM carries the same initial state. `value`/`checked` matter for\n * form controls whose live state is a JS property, not an attribute.\n */\nconst SERIALIZED_PROPERTIES: Record<string, 'attr' | 'boolean'> = {\n value: 'attr',\n checked: 'boolean',\n selected: 'boolean',\n};\n\n/** Escape text node content. */\nexport function escapeHtmlText(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;');\n}\n\n/** Escape a double-quoted attribute value. */\nexport function escapeHtmlAttr(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;');\n}\n\nfunction serializeAttributes(el: ServerElement): string {\n const parts: string[] = [];\n\n for (const [name, value] of el.attributes) {\n if (value === '') {\n parts.push(` ${name}`);\n } else {\n parts.push(` ${name}=\"${escapeHtmlAttr(value)}\"`);\n }\n }\n\n for (const [name, kind] of Object.entries(SERIALIZED_PROPERTIES)) {\n if (!el.properties.has(name)) continue;\n if (el.attributes.has(name)) continue; // an explicit attribute already won\n const raw = el.properties.get(name);\n if (kind === 'boolean') {\n if (raw === true) parts.push(` ${name}`);\n } else {\n if (raw !== undefined && raw !== null) {\n parts.push(` ${name}=\"${escapeHtmlAttr(String(raw))}\"`);\n }\n }\n }\n\n if (!el.style.isEmpty && !el.attributes.has('style')) {\n parts.push(` style=\"${escapeHtmlAttr(el.style.toCss())}\"`);\n }\n\n return parts.join('');\n}\n\n/** Serialize a single server node (element/text/comment/fragment) to HTML. */\nexport function serializeServerNode(node: ServerNode): string {\n switch (node.kind) {\n case 'text':\n return escapeHtmlText((node as ServerText).data);\n case 'comment':\n return `<!--${(node as ServerComment).data}-->`;\n case 'fragment':\n return serializeChildren(node as ServerFragment);\n case 'element': {\n const el = node as ServerElement;\n const tag = el.tagName;\n const attrs = serializeAttributes(el);\n if (VOID_ELEMENTS.has(tag)) {\n return `<${tag}${attrs}>`;\n }\n return `<${tag}${attrs}>${serializeChildren(el)}</${tag}>`;\n }\n }\n}\n\n/** Serialize the children of an element or fragment (its \"inner HTML\"). */\nexport function serializeChildren(node: ServerElement | ServerFragment): string {\n let out = '';\n for (const child of node.children) {\n out += serializeServerNode(child);\n }\n return out;\n}\n","/**\n * Server implementation of `DOMAdapter`.\n *\n * Builds a lightweight in-memory tree (see `server-node.ts`) instead of touching\n * a real browser DOM, then lets the caller serialize it to an HTML string. It is\n * completely free of browser globals, so the exact same renderer that runs in\n * the browser can produce HTML on the server.\n *\n * The `DOMAdapter` interface is typed against the lib DOM types (`Element`,\n * `Node`, `Text`, …). Our server nodes structurally stand in for those at\n * runtime, so the boundary uses `as unknown as` casts in one place. Everything\n * inside operates on the real server-node model.\n */\n\nimport type { DOMAdapter } from './adapter.js';\nimport {\n ServerElement,\n ServerText,\n ServerComment,\n ServerFragment,\n serializeChildren,\n serializeServerNode,\n type ServerNode,\n type ServerParent,\n} from './server-node.js';\n\nfunction asServer(node: unknown): ServerNode {\n return node as unknown as ServerNode;\n}\nfunction asParent(node: unknown): ServerParent {\n return node as unknown as ServerParent;\n}\n\nexport class ServerDOMAdapter implements DOMAdapter {\n createElement(tag: string, _ns?: string): Element {\n return new ServerElement(tag) as unknown as Element;\n }\n\n createTextNode(data: string): Text {\n return new ServerText(data) as unknown as Text;\n }\n\n createComment(data: string): Comment {\n return new ServerComment(data) as unknown as Comment;\n }\n\n createFragment(): DocumentFragment {\n return new ServerFragment() as unknown as DocumentFragment;\n }\n\n appendChild(parent: Node, child: Node): void {\n const p = asParent(parent);\n const c = asServer(child);\n this._detach(c);\n c.parent = p;\n p.children.push(c);\n }\n\n insertBefore(parent: Node, child: Node, reference: Node | null): void {\n const p = asParent(parent);\n const c = asServer(child);\n this._detach(c);\n c.parent = p;\n if (reference === null) {\n p.children.push(c);\n return;\n }\n const ref = asServer(reference);\n const idx = p.children.indexOf(ref);\n if (idx === -1) p.children.push(c);\n else p.children.splice(idx, 0, c);\n }\n\n removeChild(parent: Node, child: Node): void {\n const p = asParent(parent);\n const c = asServer(child);\n const idx = p.children.indexOf(c);\n if (idx !== -1) {\n p.children.splice(idx, 1);\n c.parent = null;\n }\n }\n\n replaceChild(parent: Node, newChild: Node, oldChild: Node): void {\n const p = asParent(parent);\n const nc = asServer(newChild);\n const oc = asServer(oldChild);\n const idx = p.children.indexOf(oc);\n if (idx === -1) return;\n this._detach(nc);\n nc.parent = p;\n p.children.splice(idx, 1, nc);\n oc.parent = null;\n }\n\n private _detach(node: ServerNode): void {\n if (node.parent !== null) {\n const siblings = node.parent.children;\n const idx = siblings.indexOf(node);\n if (idx !== -1) siblings.splice(idx, 1);\n node.parent = null;\n }\n }\n\n setAttribute(element: Element, name: string, value: string): void {\n (element as unknown as ServerElement).attributes.set(name, value);\n }\n\n removeAttribute(element: Element, name: string): void {\n (element as unknown as ServerElement).attributes.delete(name);\n }\n\n getAttribute(element: Element, name: string): string | null {\n return (element as unknown as ServerElement).attributes.get(name) ?? null;\n }\n\n setProperty(element: Element, name: string, value: unknown): void {\n (element as unknown as ServerElement).properties.set(name, value);\n }\n\n setTextContent(node: Node, text: string): void {\n const n = asServer(node);\n if (n.kind === 'element' || n.kind === 'fragment') {\n const el = n as ServerElement | ServerFragment;\n el.children.length = 0;\n const t = new ServerText(text);\n t.parent = el;\n el.children.push(t);\n } else if (n.kind === 'text') {\n (n as ServerText).data = text;\n }\n }\n\n getTextContent(node: Node): string | null {\n const n = asServer(node);\n if (n.kind === 'text') return (n as ServerText).data;\n if (n.kind === 'element' || n.kind === 'fragment') {\n let out = '';\n for (const c of (n as ServerElement | ServerFragment).children) {\n out += this.getTextContent(c as unknown as Node) ?? '';\n }\n return out;\n }\n return null;\n }\n\n // Server nodes never dispatch events — listeners are a no-op on the server.\n addEventListener(): void {\n /* no-op on the server */\n }\n removeEventListener(): void {\n /* no-op on the server */\n }\n\n querySelector(): Element | null {\n return null;\n }\n querySelectorAll(): NodeListOf<Element> {\n return [] as unknown as NodeListOf<Element>;\n }\n getElementById(): Element | null {\n return null;\n }\n\n focus(): void {\n // No focus concept on the server — intentional no-op (SSR-safe).\n }\n\n isElement(node: Node): node is Element {\n return asServer(node).kind === 'element';\n }\n\n isTextNode(node: Node): node is Text {\n return asServer(node).kind === 'text';\n }\n\n tagName(element: Element): string {\n return (element as unknown as ServerElement).tagName;\n }\n\n parentNode(node: Node): Node | null {\n return (asServer(node).parent as unknown as Node | null) ?? null;\n }\n\n nextSibling(node: Node): Node | null {\n const n = asServer(node);\n const parent = n.parent;\n if (parent === null) return null;\n const idx = parent.children.indexOf(n);\n if (idx === -1 || idx + 1 >= parent.children.length) return null;\n return parent.children[idx + 1] as unknown as Node;\n }\n\n firstChild(node: Node): Node | null {\n const n = asServer(node);\n if (n.kind === 'element' || n.kind === 'fragment') {\n const el = n as ServerElement | ServerFragment;\n return (el.children[0] as unknown as Node) ?? null;\n }\n return null;\n }\n\n childNodes(node: Node): Node[] {\n const n = asServer(node);\n if (n.kind === 'element' || n.kind === 'fragment') {\n return (n as ServerElement | ServerFragment).children as unknown as Node[];\n }\n return [];\n }\n\n // ── Server-only ────────────────────────────────────────────────────────────\n\n /** Serialize a node's children (\"inner HTML\") to an HTML string. */\n serializeInner(node: Node): string {\n const n = asServer(node);\n if (n.kind === 'element' || n.kind === 'fragment') {\n return serializeChildren(n as ServerElement | ServerFragment);\n }\n return '';\n }\n\n /** Serialize a node (including itself) to an HTML string. */\n serializeOuter(node: Node): string {\n return serializeServerNode(asServer(node));\n }\n}\n\nexport const serverDOMAdapter = new ServerDOMAdapter();\n","/**\n * SSR state transfer (dehydration) — move server-resolved data to the client.\n *\n * When the server resolves resources before rendering, their data must reach\n * the client so hydration can seed them (via `resource({ initialData })`)\n * instead of refetching. StreetUI does this with a single, framework-scoped\n * `<script>` payload rather than blindly interpolating `JSON.stringify` into\n * markup.\n *\n * Safety (v0.4 rule #16): the JSON is emitted into a\n * `<script type=\"application/json\">` block — an inert data island the browser\n * never executes — and every character that could terminate that block or be\n * reinterpreted by the HTML/JS parser is escaped to its `\\uXXXX` form. Because\n * `<` inside JSON parses back to `<`, the payload round-trips exactly\n * while being impossible to break out of. This is deterministic (stable key\n * order is the caller's responsibility) and typed at the boundary as\n * `Record<string, unknown>` — never `any`.\n */\n\nimport type { DOMAdapter } from '@streetui/dom';\n\n/** Attribute marking StreetUI's state island so the client can find it. */\nexport const STATE_MARKER_ATTR = 'data-streetui-state';\n\n/**\n * Escape a JSON string for safe embedding inside a `<script>` element:\n * < > & → HTML / `</script>` breakout and entity ambiguity\n * U+2028 / U+2029 → invalid raw in JS string literals\n * Uses code-point checks so no raw separator characters live in this source.\n */\nfunction escapeForScript(json: string): string {\n let out = '';\n for (const ch of json) {\n const code = ch.charCodeAt(0);\n if (ch === '<') out += '\\\\u003c';\n else if (ch === '>') out += '\\\\u003e';\n else if (ch === '&') out += '\\\\u0026';\n else if (code === 0x2028) out += '\\\\u2028';\n else if (code === 0x2029) out += '\\\\u2029';\n else out += ch;\n }\n return out;\n}\n\n/**\n * Serialize a state map to an HTML `<script>` island for inclusion in the\n * server-rendered document (typically just before the closing tag of the\n * mount container). Returns an empty string for an empty map.\n */\nexport function serializeState(state: Record<string, unknown>): string {\n if (Object.keys(state).length === 0) return '';\n const json = escapeForScript(JSON.stringify(state));\n return `<script type=\"application/json\" ${STATE_MARKER_ATTR}>${json}</script>`;\n}\n\n/**\n * Read the state island back on the client. Searches `root` for StreetUI's\n * state `<script>` and parses it. Returns an empty object when absent or\n * unparseable (hydration then proceeds as a cold client render). Routed through\n * the DOM adapter so it is testable and never assumes a global `document`.\n */\nexport function readState(\n dom: DOMAdapter,\n root: Element | Document,\n): Record<string, unknown> {\n const el = dom.querySelector(root, `script[${STATE_MARKER_ATTR}]`);\n if (el === null) return {};\n const text = dom.getTextContent(el);\n if (text === null || text.length === 0) return {};\n try {\n const parsed: unknown = JSON.parse(text);\n if (parsed !== null && typeof parsed === 'object') {\n return parsed as Record<string, unknown>;\n }\n return {};\n } catch {\n return {};\n }\n}\n","/**\n * Server-side rendering — `renderToString`.\n *\n * Runs the *exact same* mount pipeline used in the browser (`mountGraph`), but\n * against a `ServerDOMAdapter` that builds a lightweight in-memory node tree\n * instead of a real browser DOM. The tree is then serialized to a normal HTML\n * string. Because both browser and server share the DSL → Compiler → Graph →\n * Runtime → Renderer pipeline, there is no second, SSR-specific renderer and no\n * virtual DOM.\n *\n * Lifecycle (v0.4 rule #20): the initial synchronous mount may open signal\n * subscriptions (via `wireSignalBindings`/`wireReactiveList`). On the server\n * those would be live forever, so once the HTML is serialized we dispose the\n * root instance — tearing down every subscription and listener. SSR therefore\n * has a *render* lifecycle only; the live *runtime* lifecycle is established\n * later on the client by `hydrate`.\n */\n\nimport { ServerDOMAdapter } from '@streetui/dom';\nimport type { CompiledApplication } from '@streetui/compiler';\nimport { createRenderContext } from './render-context.js';\nimport { mountGraph } from './mount.js';\n\nexport interface RenderToStringOptions {\n /**\n * Override the server DOM adapter (rarely needed). Defaults to a fresh\n * `ServerDOMAdapter` per call so concurrent renders never share state.\n */\n readonly domAdapter?: ServerDOMAdapter;\n}\n\n/**\n * Render a compiled StreetUI application to an HTML string.\n *\n * The returned markup contains only the application's own elements (the\n * synthetic container is not emitted), so callers embed it wherever they mount\n * on the client — e.g. inside `<div id=\"app\">…</div>`.\n */\nexport function renderToString(\n compiled: CompiledApplication,\n options: RenderToStringOptions = {},\n): string {\n const dom = options.domAdapter ?? new ServerDOMAdapter();\n\n // Synthetic container — the application root maps onto it, and the app's\n // top-level nodes are appended directly into it (mirroring browser mount).\n const container = dom.createElement('div');\n\n const ctx = createRenderContext(dom, compiled.graph, container);\n const rootInstance = mountGraph(ctx);\n\n const html = dom.serializeInner(container);\n\n // Tear down any subscriptions/listeners opened during mount — the server has\n // no live runtime. (rule #20)\n rootInstance.dispose();\n ctx.instances.clear();\n\n return html;\n}\n","/**\n * The single authoritative StreetUI framework version.\n *\n * This constant is the one source of truth for the version of the shipped\n * `streetui` package. It is kept in lock-step with this package's\n * `package.json` `version` field and with the bundled CLI's reported version\n * (`streetui --version`) — the consolidated test-suite pins all three to the\n * same coordinated release so they can never silently drift apart.\n */\nexport const VERSION = '1.2.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2BO,SAAS,oBACd,KACA,OACA,WACA,sBACe;AACf,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,WAAW,oBAAI,IAAI;AAAA,IACnB;AAAA,IACA,GAAI,yBAAyB,SAAY,EAAE,qBAAqB,IAAI,CAAC;AAAA,EACvE;AACF;;;AC4BO,IAAM,kBAAN,MAAsB;AAAA,EACV,OAA0B,CAAC;AAAA,EAE5C,IAAI,IAA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UAAU,MAAM;AAEpB,SAAO;AACT;;;AClDO,IAAM,UAAU;","names":["instance","el","tag"]}
1
+ {"version":3,"sources":["../src/server.ts","../../renderer/src/render-context.ts","../../core/src/lifecycle.ts","../../renderer/src/node-instance.ts","../../renderer/src/attributes.ts","../../renderer/src/events.ts","../../renderer/src/tag-map.ts","../../renderer/src/patch.ts","../../renderer/src/reconciliation.ts","../../renderer/src/mount.ts","../../dom/src/server-node.ts","../../dom/src/server-adapter.ts","../../renderer/src/dehydrate.ts","../../renderer/src/ssr.ts","../src/version.ts"],"sourcesContent":["/**\n * `streetui/server` — server-only rendering helpers.\n *\n * This is a *curated subset* of the same framework that powers `streetui`; it\n * does not introduce a second renderer or SSR implementation. It re-exports the\n * already-implemented server-side rendering surface so server entry points can\n * import exactly what they need without pulling in browser-only concerns.\n *\n * ```ts\n * import { renderToString, serializeState, ServerDOMAdapter } from 'streetui/server';\n * ```\n *\n * Client-side hydration (`hydrate` / `createRenderer`) is available from the\n * main `streetui` entry.\n */\n\n// Server-side rendering: compiled app → HTML string, with hydration state.\nexport {\n renderToString,\n serializeState,\n readState,\n STATE_MARKER_ATTR,\n} from '@streetui/renderer';\nexport type { RenderToStringOptions } from '@streetui/renderer';\n\n// The DOM adapter used to render on the server (no live browser DOM).\nexport { ServerDOMAdapter } from '@streetui/dom';\n\n// Re-export the framework version for parity with the main entry.\nexport { VERSION } from './version.js';\n","/**\n * RenderContext — shared state for a single mount operation.\n *\n * Passed through the render pipeline so every sub-function has access\n * to the DOM adapter, graph, and instance map without prop-drilling.\n */\n\nimport type { DOMAdapter } from '@streetui/dom';\nimport type { ApplicationGraph, GraphNode } from '@streetui/graph';\nimport type { NodeInstance } from './node-instance.js';\nimport type { HydrationDiagnosticSink } from './hydration-diagnostics.js';\n\nexport interface RenderContext {\n readonly dom: DOMAdapter;\n readonly graph: ApplicationGraph;\n /** Maps GraphNode.id → its live NodeInstance */\n readonly instances: Map<string, NodeInstance>;\n /** The root container element. */\n readonly container: Element;\n /**\n * Optional dev-only sink that observes hydration mismatch repairs. When\n * absent (the default) the hydration path does no extra work — this is how\n * DevTools/diagnostics stay off the production runtime path.\n */\n readonly hydrationDiagnostics?: HydrationDiagnosticSink;\n}\n\nexport function createRenderContext(\n dom: DOMAdapter,\n graph: ApplicationGraph,\n container: Element,\n hydrationDiagnostics?: HydrationDiagnosticSink,\n): RenderContext {\n return {\n dom,\n graph,\n instances: new Map(),\n container,\n ...(hydrationDiagnostics !== undefined ? { hydrationDiagnostics } : {}),\n };\n}\n","/**\n * Application and component lifecycle primitives.\n *\n * Lifecycle phases:\n * created → mounted → active ⇄ updating → unmounting → destroyed\n */\n\nexport type LifecyclePhase =\n | 'created'\n | 'mounted'\n | 'active'\n | 'updating'\n | 'unmounting'\n | 'destroyed';\n\nexport type LifecycleHook = () => void | Promise<void>;\n\nexport class Lifecycle {\n private _phase: LifecyclePhase = 'created';\n private readonly _hooks: Map<LifecyclePhase, LifecycleHook[]> = new Map();\n\n get phase(): LifecyclePhase {\n return this._phase;\n }\n\n get isMounted(): boolean {\n return this._phase === 'mounted' || this._phase === 'active' || this._phase === 'updating';\n }\n\n get isDestroyed(): boolean {\n return this._phase === 'destroyed';\n }\n\n on(phase: LifecyclePhase, hook: LifecycleHook): () => void {\n const hooks = this._hooks.get(phase) ?? [];\n hooks.push(hook);\n this._hooks.set(phase, hooks);\n return () => {\n const current = this._hooks.get(phase);\n if (current !== undefined) {\n const idx = current.indexOf(hook);\n if (idx !== -1) current.splice(idx, 1);\n }\n };\n }\n\n async transition(to: LifecyclePhase): Promise<void> {\n this._phase = to;\n const hooks = this._hooks.get(to) ?? [];\n for (const hook of hooks) {\n await hook();\n }\n }\n\n onMount(hook: LifecycleHook): () => void {\n return this.on('mounted', hook);\n }\n\n onUnmount(hook: LifecycleHook): () => void {\n return this.on('unmounting', hook);\n }\n\n onDestroy(hook: LifecycleHook): () => void {\n return this.on('destroyed', hook);\n }\n}\n\n/** A simple cleanup registry — collect teardown functions and run them all at once. */\nexport class CleanupRegistry {\n private readonly _fns: Array<() => void> = [];\n\n add(fn: () => void): void {\n this._fns.push(fn);\n }\n\n run(): void {\n for (const fn of this._fns) {\n try {\n fn();\n } catch {\n // Best-effort cleanup; don't let one failure block others\n }\n }\n this._fns.length = 0;\n }\n}\n","/**\n * NodeInstance — the renderer's live counterpart to a GraphNode.\n *\n * Tracks the actual DOM node(s), all signal subscriptions that drive\n * targeted DOM updates, and DOM event listener teardowns.\n */\n\nimport { CleanupRegistry } from '@streetui/core';\nimport type { GraphNode } from '@streetui/graph';\nimport type { ReadonlySignal } from '@streetui/state';\n\nexport class NodeInstance {\n readonly graphNode: GraphNode;\n /** The primary DOM node for this instance (element or text node). */\n domNode: Node;\n readonly children: NodeInstance[] = [];\n readonly cleanup: CleanupRegistry = new CleanupRegistry();\n\n constructor(graphNode: GraphNode, domNode: Node) {\n this.graphNode = graphNode;\n this.domNode = domNode;\n }\n\n addChild(child: NodeInstance): void {\n this.children.push(child);\n }\n\n /** Subscribe to a signal; auto-cleanup on unmount. */\n trackSignal<T>(sig: ReadonlySignal<T>, handler: (v: T) => void): void {\n const unsub = sig.subscribe(handler);\n this.cleanup.add(unsub);\n }\n\n /** Register a raw cleanup fn (DOM event removal, etc.). */\n trackCleanup(fn: () => void): void {\n this.cleanup.add(fn);\n }\n\n dispose(): void {\n for (const child of this.children) {\n child.dispose();\n }\n this.cleanup.run();\n }\n}\n","/**\n * Attribute and property application helpers.\n *\n * Decides whether a prop should be set as a DOM attribute or a JS property,\n * handling special cases (boolean attrs, event-like props, style, class).\n */\n\nimport type { DOMAdapter } from '@streetui/dom';\n\n// Properties that must be set as JS object properties, not HTML attributes\nconst DOM_PROPERTIES = new Set([\n 'value', 'checked', 'selected', 'indeterminate',\n 'innerHTML', 'textContent', 'innerText',\n 'scrollTop', 'scrollLeft',\n]);\n\n// Boolean attributes — present means true, absent means false\nconst BOOLEAN_ATTRS = new Set([\n 'disabled', 'readonly', 'required', 'checked', 'selected',\n 'multiple', 'autofocus', 'autoplay', 'controls', 'default',\n 'defer', 'formnovalidate', 'hidden', 'ismap', 'loop',\n 'novalidate', 'open', 'reversed', 'scoped', 'seamless',\n]);\n\nexport function applyProp(\n dom: DOMAdapter,\n element: Element,\n name: string,\n value: unknown,\n): void {\n // Skip internal renderer metadata\n if (name.startsWith('_')) return;\n // Skip event handlers (handled separately)\n if (name.startsWith('on')) return;\n\n if (DOM_PROPERTIES.has(name)) {\n dom.setProperty(element, name, value);\n return;\n }\n\n if (BOOLEAN_ATTRS.has(name)) {\n if (value === true || value === '' || value === name) {\n dom.setAttribute(element, name, '');\n } else {\n dom.removeAttribute(element, name);\n }\n return;\n }\n\n if (name === 'class' || name === 'className') {\n dom.setAttribute(element, 'class', String(value ?? ''));\n return;\n }\n\n if (name === 'style' && typeof value === 'object' && value !== null) {\n const el = element as HTMLElement;\n const styles = value as Record<string, string>;\n for (const [k, v] of Object.entries(styles)) {\n el.style.setProperty(k, v);\n }\n return;\n }\n\n if (value === null || value === undefined || value === false) {\n dom.removeAttribute(element, name);\n return;\n }\n\n dom.setAttribute(element, name, String(value));\n}\n\nexport function patchProp(\n dom: DOMAdapter,\n element: Element,\n name: string,\n oldValue: unknown,\n newValue: unknown,\n): void {\n if (Object.is(oldValue, newValue)) return;\n applyProp(dom, element, name, newValue);\n}\n","/**\n * Event wiring for the renderer.\n *\n * Given a GraphNode with event descriptors, this wires DOM listeners\n * that call the handlers stored in the graph's handler registry.\n */\n\nimport type { DOMAdapter } from '@streetui/dom';\nimport type { ApplicationGraph, GraphNode } from '@streetui/graph';\nimport type { NodeInstance } from './node-instance.js';\n\nexport function wireEvents(\n dom: DOMAdapter,\n graph: ApplicationGraph,\n node: GraphNode,\n element: Element,\n instance: NodeInstance,\n): void {\n // Fast exit for event-free nodes — avoids allocating a for-of iterator over\n // an empty array on every node during a large mount/hydrate.\n if (node.events.length === 0) return;\n for (const eventDesc of node.events) {\n const handler = graph.getHandler(eventDesc.handlerKey);\n if (handler === undefined) continue;\n\n const domListener: EventListener = (domEvent: Event) => {\n // For input events, pass the current value as first arg\n if (eventDesc.type === 'input' || eventDesc.type === 'change') {\n const input = domEvent.target as HTMLInputElement;\n (handler as (v: string) => void)(input.value);\n } else if (eventDesc.type === 'submit') {\n domEvent.preventDefault();\n (handler as (e: Event) => void)(domEvent);\n } else {\n (handler as () => void)();\n }\n };\n\n dom.addEventListener(element, eventDesc.type, domListener);\n instance.trackCleanup(() => {\n dom.removeEventListener(element, eventDesc.type, domListener);\n });\n }\n}\n","/**\n * Maps semantic node types to HTML tag names.\n */\n\nimport type { SemanticNodeType } from '@streetui/core';\n\nconst TAG_MAP: Partial<Record<SemanticNodeType, string>> = {\n application: 'div',\n page: 'div',\n section: 'section',\n container: 'div',\n heading: 'h1',\n text: 'span',\n button: 'button',\n input: 'input',\n form: 'form',\n list: 'ul',\n 'list-item': 'li',\n image: 'img',\n link: 'a',\n component: 'div',\n slot: 'div',\n fragment: 'div',\n 'reactive-list': 'ul',\n};\n\nexport function resolveTag(type: SemanticNodeType): string {\n return TAG_MAP[type] ?? 'div';\n}\n","/**\n * Patch — targeted DOM updates driven by signal changes.\n *\n * When a signal fires, we look up the NodeInstance and apply\n * only the changed prop — no full re-render, no tree diffing.\n */\n\nimport type { RenderContext } from './render-context.js';\nimport type { GraphNode } from '@streetui/graph';\nimport { applyProp, patchProp } from './attributes.js';\n\nexport function patchNode(\n ctx: RenderContext,\n graphNode: GraphNode,\n propKey: string,\n newValue: unknown,\n): void {\n const instance = ctx.instances.get(graphNode.id);\n if (instance === undefined) return;\n\n const domNode = instance.domNode;\n if (!ctx.dom.isElement(domNode)) return;\n\n const oldValue = graphNode.getProp(propKey);\n\n switch (propKey) {\n case 'text':\n if (!Object.is(oldValue, newValue)) {\n ctx.dom.setTextContent(domNode, String(newValue ?? ''));\n graphNode.setProp('text', String(newValue ?? ''));\n }\n break;\n case 'label':\n if (!Object.is(oldValue, newValue)) {\n ctx.dom.setTextContent(domNode, String(newValue ?? ''));\n graphNode.setProp('label', String(newValue ?? ''));\n }\n break;\n case 'disabled':\n if (newValue === true) {\n ctx.dom.setAttribute(domNode, 'disabled', '');\n } else {\n ctx.dom.removeAttribute(domNode, 'disabled');\n }\n graphNode.setProp('disabled', Boolean(newValue));\n break;\n case 'value':\n if (!Object.is(oldValue, newValue)) {\n ctx.dom.setProperty(domNode, 'value', String(newValue ?? ''));\n graphNode.setProp('value', String(newValue ?? ''));\n }\n break;\n default:\n patchProp(ctx.dom, domNode, propKey, oldValue, newValue);\n graphNode.setProp(propKey, newValue as string);\n break;\n }\n}\n","/**\n * Reconciliation — diff-based child list updates.\n *\n * When the children of a node change (e.g. a list driven by state),\n * this reconciler:\n * 1. Matches old instances to new graph nodes by key\n * 2. Reuses matched instances (updates their props)\n * 3. Applies a targeted content update to a reused item whose data changed\n * 4. Creates new instances for additions\n * 5. Removes stale instances (and prunes their handler registrations)\n * 6. Moves DOM nodes to match new order\n *\n * This is keyed reconciliation over the semantic graph — there is no virtual\n * DOM. A reused item keeps its own DOM element; only its changed content is\n * updated in place (falling back to remounting a subtree only where its shape\n * actually changed).\n */\n\nimport type { RenderContext } from './render-context.js';\nimport type { GraphNode } from '@streetui/graph';\nimport type { NodeInstance } from './node-instance.js';\nimport { patchNode } from './patch.js';\n\nexport type MountFn = (node: GraphNode, parent: Element) => NodeInstance;\n\nexport interface ReconcileResult {\n /** Instances in the new order. */\n instances: NodeInstance[];\n /** Instances that were removed and must be disposed. */\n removed: NodeInstance[];\n /**\n * GraphNodes freshly materialised during this reconcile (new rows + rebuilt\n * changed rows). The caller detaches any of these that were not adopted as a\n * live instance's graph node, so no orphan subtree lingers in the graph index.\n */\n built?: GraphNode[];\n}\n\n/**\n * A lazy reconciliation descriptor for one reactive-list row (mirrors the DSL's\n * `ListPlanEntry`). `sig()` and `build()` are only invoked for rows that are\n * genuinely new or whose source reference changed — the whole point of the\n * plan path (spec §15).\n */\nexport interface PlanEntry {\n readonly key: string;\n readonly item: unknown;\n readonly sig: () => string;\n readonly build: () => GraphNode;\n}\n\n/**\n * Reconcile children of a container element against a new list of graph nodes.\n *\n * @param ctx Render context\n * @param parentDom The DOM parent element\n * @param oldInstances Current child instances (in order)\n * @param newNodes New graph children (in desired order)\n * @param mountFn Factory to create a new NodeInstance for a graph node\n */\nexport function reconcileChildren(\n ctx: RenderContext,\n parentDom: Element,\n oldInstances: NodeInstance[],\n newNodes: readonly GraphNode[],\n mountFn: MountFn,\n): ReconcileResult {\n // Build key → old instance map\n const oldByKey = new Map<string, NodeInstance>();\n for (const inst of oldInstances) {\n const key = inst.graphNode.key ?? inst.graphNode.id;\n oldByKey.set(key, inst);\n }\n\n const newInstances: NodeInstance[] = [];\n const usedKeys = new Set<string>();\n\n for (const newNode of newNodes) {\n const key = newNode.key ?? newNode.id;\n const existing = oldByKey.get(key);\n\n if (existing !== undefined) {\n // Reuse — identity is stable, so the DOM element is preserved.\n usedKeys.add(key);\n const oldSig = existing.graphNode.getProp('_sig');\n const newSig = newNode.getProp('_sig');\n patchExistingInstance(ctx, existing, newNode);\n // Data changed but identity did not → targeted content update in place.\n if (!Object.is(oldSig, newSig)) {\n reconcileItemChildren(ctx, existing, newNode, mountFn);\n }\n newInstances.push(existing);\n } else {\n // New — create and mount\n const inst = mountFn(newNode, parentDom);\n newInstances.push(inst);\n }\n }\n\n // Determine removed instances\n const removed: NodeInstance[] = [];\n for (const inst of oldInstances) {\n const key = inst.graphNode.key ?? inst.graphNode.id;\n if (!usedKeys.has(key)) {\n removed.push(inst);\n }\n }\n\n // Remove stale DOM nodes\n for (const inst of removed) {\n const parent = ctx.dom.parentNode(inst.domNode);\n if (parent !== null) {\n ctx.dom.removeChild(parent, inst.domNode);\n }\n inst.dispose();\n }\n\n // Reorder DOM nodes to match new order\n reorderDom(ctx, parentDom, newInstances);\n\n return { instances: newInstances, removed };\n}\n\n/**\n * Plan-based keyed reconciliation (spec §15 — the optimised reactive-list path).\n *\n * Identical observable result to {@link reconcileChildren}, but driven by lazy\n * {@link PlanEntry} descriptors instead of a pre-built array of GraphNodes:\n *\n * - a reused row whose `item` reference is unchanged does **zero** work — no\n * signature hash, no subtree build, no prop patch (the common case for\n * append / prepend / remove / reorder / reverse, where existing item objects\n * keep their identity);\n * - a reused row whose reference changed hashes lazily and, only on a real\n * signature change, materialises a fresh subtree for a targeted in-place\n * content update;\n * - a genuinely new key builds + mounts exactly one subtree.\n *\n * DOM reordering uses a longest-increasing-subsequence pass so the number of\n * moves is minimal (e.g. a prepend into a 10k list moves 1 node, not 10k).\n */\nexport function reconcileChildrenByPlan(\n ctx: RenderContext,\n parentDom: Element,\n oldInstances: NodeInstance[],\n plan: readonly PlanEntry[],\n mountFn: MountFn,\n): ReconcileResult {\n const oldByKey = new Map<string, NodeInstance>();\n for (const inst of oldInstances) {\n oldByKey.set(inst.graphNode.key ?? inst.graphNode.id, inst);\n }\n\n const newInstances: NodeInstance[] = [];\n const usedKeys = new Set<string>();\n const built: GraphNode[] = [];\n\n for (const entry of plan) {\n const existing = oldByKey.get(entry.key);\n if (existing !== undefined) {\n usedKeys.add(entry.key);\n const oldItem = existing.graphNode.getProp('_item');\n // Identity short-circuit: same reference ⇒ data cannot have changed.\n if (!Object.is(oldItem, entry.item)) {\n const newSig = entry.sig();\n const oldSig = existing.graphNode.getProp('_sig');\n if (!Object.is(oldSig, newSig)) {\n const freshNode = entry.build();\n built.push(freshNode);\n patchExistingInstance(ctx, existing, freshNode);\n reconcileItemChildren(ctx, existing, freshNode, mountFn);\n existing.graphNode.setProp('_sig', newSig);\n }\n // Cache the new reference so the next pass can short-circuit again.\n existing.graphNode.setProp('_item', entry.item as never);\n }\n newInstances.push(existing);\n } else {\n const freshNode = entry.build();\n built.push(freshNode);\n const inst = mountFn(freshNode, parentDom);\n newInstances.push(inst);\n }\n }\n\n // Determine + remove stale instances.\n const removed: NodeInstance[] = [];\n for (const inst of oldInstances) {\n const key = inst.graphNode.key ?? inst.graphNode.id;\n if (!usedKeys.has(key)) removed.push(inst);\n }\n for (const inst of removed) {\n const parent = ctx.dom.parentNode(inst.domNode);\n if (parent !== null) ctx.dom.removeChild(parent, inst.domNode);\n inst.dispose();\n }\n\n // Minimal-move reorder to the desired order.\n reorderDomMinimal(ctx, parentDom, oldInstances, newInstances);\n\n return { instances: newInstances, removed, built };\n}\n\n/**\n * Minimal-move DOM reorder.\n *\n * Reused nodes retain their previous DOM slots and newly-mounted nodes sit at\n * the end. We compute the longest increasing subsequence of the reused nodes'\n * previous positions; those are already in correct relative order and stay put.\n * Every other node is inserted before its right-hand neighbour, walking\n * right-to-left. This yields exactly (n − |LIS|) `insertBefore` calls — the\n * minimum — instead of the O(n) sweep the naive reorder performs on a prepend.\n */\nfunction reorderDomMinimal(\n ctx: RenderContext,\n parentDom: Element,\n oldInstances: NodeInstance[],\n newInstances: NodeInstance[],\n): void {\n const n = newInstances.length;\n if (n === 0) return;\n\n const oldIndexOf = new Map<NodeInstance, number>();\n for (let i = 0; i < oldInstances.length; i++) oldIndexOf.set(oldInstances[i]!, i);\n\n const source = new Array<number>(n);\n let moved = false;\n let lastSeen = -1;\n for (let i = 0; i < n; i++) {\n const oi = oldIndexOf.get(newInstances[i]!);\n if (oi === undefined) {\n source[i] = -1; // freshly mounted row\n moved = true;\n } else {\n source[i] = oi;\n if (oi < lastSeen) moved = true; // an out-of-order reused row exists\n else lastSeen = oi;\n }\n }\n\n // Fast path: nothing is out of order and there are no new rows to reposition.\n if (!moved) return;\n\n const keep = longestIncreasingSubsequence(source);\n\n let refNode: Node | null = null;\n for (let i = n - 1; i >= 0; i--) {\n const domNode = newInstances[i]!.domNode;\n if (source[i] === -1 || !keep.has(i)) {\n if (ctx.dom.nextSibling(domNode) !== refNode) {\n ctx.dom.insertBefore(parentDom, domNode, refNode);\n }\n }\n refNode = domNode;\n }\n}\n\n/**\n * Indices (into `source`) forming a longest strictly-increasing subsequence,\n * ignoring `-1` entries (new rows, which always move). O(n log n) with\n * predecessor reconstruction.\n */\nfunction longestIncreasingSubsequence(source: readonly number[]): Set<number> {\n const keep = new Set<number>();\n const n = source.length;\n const tails: number[] = []; // tails[k] = source-index of smallest tail of an LIS of length k+1\n const prev = new Array<number>(n).fill(-1);\n\n for (let i = 0; i < n; i++) {\n const v = source[i]!;\n if (v < 0) continue;\n let lo = 0;\n let hi = tails.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (source[tails[mid]!]! < v) lo = mid + 1;\n else hi = mid;\n }\n if (lo > 0) prev[i] = tails[lo - 1]!;\n tails[lo] = i;\n }\n\n let idx = tails.length > 0 ? tails[tails.length - 1]! : -1;\n while (idx >= 0) {\n keep.add(idx);\n idx = prev[idx]!;\n }\n return keep;\n}\n\n/**\n * Targeted in-place content update for a reused list item whose data changed.\n *\n * The item's DOM element is kept; only its contents are updated. Children are\n * matched positionally against the freshly-built subtree:\n * - same node type at a position → the existing child is reused and its props\n * are patched in place (e.g. a text node's text is rewritten), then we\n * recurse into its children;\n * - different type / new position → the fresh child node is reparented onto the\n * live item node and mounted;\n * - surplus old children → disposed, with DOM, subscriptions, listeners and\n * handler registrations all torn down.\n *\n * This deliberately reuses the same keyed/positional strategy rather than a\n * virtual DOM, and never destroys the item element itself.\n */\nfunction reconcileItemChildren(\n ctx: RenderContext,\n itemInstance: NodeInstance,\n newItemNode: GraphNode,\n mountFn: MountFn,\n): void {\n const el = itemInstance.domNode;\n if (!ctx.dom.isElement(el)) return;\n\n const oldChildren = [...itemInstance.children];\n const newChildNodes = [...newItemNode.children];\n const nextChildren: NodeInstance[] = [];\n const kept = new Set<NodeInstance>();\n\n for (let i = 0; i < newChildNodes.length; i++) {\n const newChild = newChildNodes[i]!;\n const oldChild = oldChildren[i];\n\n if (oldChild !== undefined && oldChild.graphNode.type === newChild.type) {\n // Reuse in place — patch this node's props and recurse into descendants.\n patchExistingInstance(ctx, oldChild, newChild);\n reconcileItemChildren(ctx, oldChild, newChild, mountFn);\n nextChildren.push(oldChild);\n kept.add(oldChild);\n } else {\n // Structural change at this position — mount the fresh child. Reparent it\n // out of the freshly-built subtree so the wholesale detach of the\n // unadopted item node (in mount.ts) does not remove this now-live node.\n itemInstance.graphNode.appendChild(newChild);\n const inst = mountFn(newChild, el);\n nextChildren.push(inst);\n }\n }\n\n // Dispose old children that were not reused (surplus or type-mismatched).\n for (const old of oldChildren) {\n if (kept.has(old)) continue;\n const parent = ctx.dom.parentNode(old.domNode);\n if (parent !== null) ctx.dom.removeChild(parent, old.domNode);\n old.dispose();\n forgetInstanceTree(ctx, old);\n ctx.graph.detachNode(old.graphNode);\n }\n\n // Restore correct DOM order within the item element.\n reorderDom(ctx, el, nextChildren);\n\n // Sync the live instance's children.\n itemInstance.children.length = 0;\n for (const c of nextChildren) itemInstance.children.push(c);\n\n // Keep the graph model's item children consistent with the reconciled order.\n for (const c of [...itemInstance.graphNode.children]) {\n itemInstance.graphNode.removeChild(c);\n }\n for (const c of nextChildren) itemInstance.graphNode.appendChild(c.graphNode);\n}\n\n/** Move a parent's DOM children to match the given instance order (minimal moves). */\nfunction reorderDom(\n ctx: RenderContext,\n parentDom: Element,\n instances: NodeInstance[],\n): void {\n let referenceNode: Node | null = null;\n for (let i = instances.length - 1; i >= 0; i--) {\n const inst = instances[i];\n if (inst === undefined) continue;\n const domNode = inst.domNode;\n const currentNext = ctx.dom.nextSibling(domNode);\n if (currentNext !== referenceNode) {\n ctx.dom.insertBefore(parentDom, domNode, referenceNode);\n }\n referenceNode = domNode;\n }\n}\n\n/** Recursively drop an instance subtree from the renderer's instance index. */\nfunction forgetInstanceTree(ctx: RenderContext, instance: NodeInstance): void {\n ctx.instances.delete(instance.graphNode.id);\n for (const child of instance.children) forgetInstanceTree(ctx, child);\n}\n\nfunction patchExistingInstance(\n ctx: RenderContext,\n instance: NodeInstance,\n newNode: GraphNode,\n): void {\n const oldNode = instance.graphNode;\n for (const [key, newVal] of Object.entries(newNode.props)) {\n const oldVal = oldNode.getProp(key);\n if (!Object.is(oldVal, newVal)) {\n patchNode(ctx, instance.graphNode, key, newVal);\n }\n }\n}\n","/**\n * Initial mount — creates DOM nodes for every GraphNode and\n * attaches them into the container.\n *\n * This is a recursive depth-first walk. For each GraphNode:\n * 1. Create the DOM element (or text node)\n * 2. Apply props/attributes\n * 3. Wire events\n * 4. Wire signal subscriptions for reactive props\n * 5. Recurse into children\n * 6. Insert into the DOM\n */\n\nimport type { GraphNode, ApplicationGraph } from '@streetui/graph';\nimport type { DOMAdapter } from '@streetui/dom';\nimport type { RenderContext } from './render-context.js';\nimport { NodeInstance } from './node-instance.js';\nimport { applyProp } from './attributes.js';\nimport { wireEvents } from './events.js';\nimport { resolveTag } from './tag-map.js';\nimport {\n reconcileChildren,\n reconcileChildrenByPlan,\n type PlanEntry,\n} from './reconciliation.js';\n\n/**\n * Prop keys handled by the per-type mount branches (or reserved internals), so\n * `applyNodeProps` must skip them to avoid double-applying. This set is\n * invariant across nodes, so it is hoisted to module scope: allocating it once\n * (rather than per node) removes N Set allocations per mount/SSR pass and the\n * GC pressure they create. Treat as read-only — never mutate.\n */\nconst SKIP_PROP_KEYS: ReadonlySet<string> = new Set([\n 'text', 'label', 'level', 'inputType', 'src', 'alt', 'href', 'external',\n 'value', 'placeholder', 'disabled', '_renderKey', 'key', 'name',\n]);\n\nexport function mountGraph(ctx: RenderContext): NodeInstance {\n return mountNode(ctx, ctx.graph.root, ctx.container);\n}\n\nexport function mountNode(\n ctx: RenderContext,\n graphNode: GraphNode,\n parentDom: Node,\n): NodeInstance {\n const { dom, graph } = ctx;\n\n // The application root node maps to the container itself — don't create a duplicate element\n if (graphNode.type === 'application') {\n const instance = new NodeInstance(graphNode, parentDom);\n ctx.instances.set(graphNode.id, instance);\n for (const child of graphNode.children) {\n const childInstance = mountNode(ctx, child, parentDom);\n instance.addChild(childInstance);\n }\n return instance;\n }\n\n // Text-only nodes render as a <span> containing a text node\n if (graphNode.type === 'text') {\n const text = String(graphNode.getProp('text') ?? '');\n const el = dom.createElement('span');\n const textNode = dom.createTextNode(text);\n dom.appendChild(el, textNode);\n applyNodeProps(ctx, graphNode, el);\n\n // Create the live instance up front and reuse it for event wiring. The\n // previous code allocated a throwaway NodeInstance solely to satisfy\n // wireEvents' signature, wasting one NodeInstance (+ its children array and\n // CleanupRegistry) per text node — pure GC pressure on the hottest mount\n // path. wireEvents/wireSignalBindings each early-return on empty arrays.\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, el, instance);\n\n // Reactive text binding — only build the update closure when the node has\n // bindings. wireSignalBindings early-returns on empty stateRefs, so for a\n // static text node (the common case in a large initial render) the\n // textUpdate closure would be allocated and thrown away: avoidable GC\n // pressure on the hottest mount path.\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, textUpdate(dom, el, textNode));\n }\n\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Heading nodes\n if (graphNode.type === 'heading') {\n const level = (graphNode.getProp('level') as number | undefined) ?? 1;\n const tag = `h${level}` as string;\n const el = dom.createElement(tag);\n const text = String(graphNode.getProp('text') ?? '');\n dom.setTextContent(el, text);\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, el, instance);\n\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, headingUpdate(dom, el));\n }\n\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Input nodes\n if (graphNode.type === 'input') {\n const el = dom.createElement('input') as HTMLInputElement;\n const inputType = String(graphNode.getProp('inputType') ?? 'text');\n dom.setAttribute(el, 'type', inputType);\n const placeholder = graphNode.getProp('placeholder');\n if (placeholder !== undefined) dom.setAttribute(el, 'placeholder', String(placeholder));\n const value = graphNode.getProp('value');\n if (value !== undefined) dom.setProperty(el, 'value', String(value));\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, el, instance);\n\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, inputUpdate(dom, el));\n }\n\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Image nodes\n if (graphNode.type === 'image') {\n const el = dom.createElement('img') as HTMLImageElement;\n const src = graphNode.getProp('src');\n const alt = graphNode.getProp('alt');\n if (src !== undefined) dom.setAttribute(el, 'src', String(src));\n if (alt !== undefined) dom.setAttribute(el, 'alt', String(alt));\n const width = graphNode.getProp('width');\n const height = graphNode.getProp('height');\n if (width !== undefined) dom.setAttribute(el, 'width', String(width));\n if (height !== undefined) dom.setAttribute(el, 'height', String(height));\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Link nodes\n if (graphNode.type === 'link') {\n const el = dom.createElement('a') as HTMLAnchorElement;\n const href = graphNode.getProp('href');\n const label = graphNode.getProp('label');\n const external = graphNode.getProp('external');\n if (href !== undefined) dom.setAttribute(el, 'href', String(href));\n if (label !== undefined) dom.setTextContent(el, String(label));\n if (external === true) {\n dom.setAttribute(el, 'target', '_blank');\n dom.setAttribute(el, 'rel', 'noopener noreferrer');\n }\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, el, instance);\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Button nodes\n if (graphNode.type === 'button') {\n const el = dom.createElement('button') as HTMLButtonElement;\n const label = graphNode.getProp('label');\n if (label !== undefined) dom.setTextContent(el, String(label));\n const disabled = graphNode.getProp('disabled');\n if (disabled === true) dom.setAttribute(el, 'disabled', '');\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, el, instance);\n\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, buttonUpdate(dom, el));\n }\n\n dom.appendChild(parentDom, el);\n return instance;\n }\n\n // Reactive list / conditional — a container whose children are driven by a\n // Signal. Initial child subtrees are already built into the graph by the DSL;\n // on signal change we reconcile the freshly-built desired children against the\n // live DOM using the keyed reconciler (no virtual DOM). A `conditional` uses\n // the identical machinery but renders as a neutral <div> holding 0..1 branch.\n if (graphNode.type === 'reactive-list' || graphNode.type === 'conditional') {\n const tag = resolveTag(graphNode.type);\n const el = dom.createElement(tag);\n applyNodeProps(ctx, graphNode, el);\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n\n for (const child of graphNode.children) {\n const childInstance = mountNode(ctx, child, el);\n instance.addChild(childInstance);\n }\n\n dom.appendChild(parentDom, el);\n wireReactiveList(ctx, graphNode, instance, el);\n return instance;\n }\n\n // Container / section / page / form / list / list-item — structural nodes\n const tag = resolveTag(graphNode.type);\n const el = dom.createElement(tag);\n applyNodeProps(ctx, graphNode, el);\n\n // Surface a reactive-list item's stable, identity-only reconciliation key as a\n // public `data-streetui-key` attribute (e.g. \"id:1\"). This exposes only the\n // identity part — never the internal `_sig` value signature, signal ids or\n // graph node ids — so a row is directly selectable and its identity is\n // inspectable across reorders and in-place data updates.\n if (graphNode.type === 'list-item') {\n const itemKey = graphNode.getProp('key');\n if (itemKey !== undefined) {\n dom.setAttribute(el, 'data-streetui-key', String(itemKey));\n }\n }\n\n const instance = new NodeInstance(graphNode, el);\n ctx.instances.set(graphNode.id, instance);\n\n // wire form submit (reuse the live instance rather than a throwaway)\n if (graphNode.type === 'form') {\n wireEvents(dom, graph, graphNode, el, instance);\n }\n\n // Recurse into children\n for (const child of graphNode.children) {\n const childInstance = mountNode(ctx, child, el);\n instance.addChild(childInstance);\n }\n\n dom.appendChild(parentDom, el);\n return instance;\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────────────\n\n/**\n * Per-node-type reactive-binding factories. Each returns the `onUpdate`\n * callback that `wireSignalBindings` invokes when a bound signal changes.\n * Extracted so both the browser mount path and the hydration path apply the\n * exact same DOM mutation semantics for each prop — no duplicated rendering\n * logic.\n */\nexport function textUpdate(\n dom: DOMAdapter,\n el: Element,\n textNode: Text,\n): (propKey: string, value: unknown) => void {\n return (propKey, value) => {\n if (propKey === 'text') {\n dom.setTextContent(textNode, String(value ?? ''));\n } else {\n applyProp(dom, el, propKey, value);\n }\n };\n}\n\nexport function headingUpdate(\n dom: DOMAdapter,\n el: Element,\n): (propKey: string, value: unknown) => void {\n return (propKey, value) => {\n if (propKey === 'text') {\n dom.setTextContent(el, String(value ?? ''));\n } else {\n applyProp(dom, el, propKey, value);\n }\n };\n}\n\nexport function inputUpdate(\n dom: DOMAdapter,\n el: Element,\n): (propKey: string, value: unknown) => void {\n return (propKey, value) => {\n if (propKey === 'value') {\n dom.setProperty(el, 'value', String(value ?? ''));\n } else {\n applyProp(dom, el, propKey, value);\n }\n };\n}\n\nexport function buttonUpdate(\n dom: DOMAdapter,\n el: Element,\n): (propKey: string, value: unknown) => void {\n return (propKey, value) => {\n if (propKey === 'label') {\n dom.setTextContent(el, String(value ?? ''));\n } else if (propKey === 'disabled') {\n if (value === true) {\n dom.setAttribute(el, 'disabled', '');\n } else {\n dom.removeAttribute(el, 'disabled');\n }\n } else {\n applyProp(dom, el, propKey, value);\n }\n };\n}\n\nexport function applyNodeProps(ctx: RenderContext, graphNode: GraphNode, el: Element): void {\n // Iterate own enumerable keys directly rather than via Object.entries, which\n // allocates a wrapper array plus one [key,value] tuple per prop — measurable\n // GC pressure when multiplied across every node in a large initial render.\n const props = graphNode.props;\n for (const key in props) {\n if (!Object.hasOwn(props, key)) continue;\n if (SKIP_PROP_KEYS.has(key)) continue;\n applyProp(ctx.dom, el, key, props[key]);\n }\n}\n\nexport function wireSignalBindings(\n ctx: RenderContext,\n graphNode: GraphNode,\n instance: NodeInstance,\n onUpdate: (propKey: string, value: unknown) => void,\n): void {\n // Fast exit for the common non-reactive node — avoids allocating a for-of\n // iterator over an empty stateRefs array on every static node.\n if (graphNode.stateRefs.length === 0) return;\n for (const stateRef of graphNode.stateRefs) {\n const signalKey = `__signal__${stateRef.signalId}`;\n const maybeSig = ctx.graph.getHandler(signalKey) as\n | { subscribe: (fn: (v: unknown) => void) => () => void; peek: () => unknown }\n | undefined;\n if (maybeSig === undefined || typeof maybeSig.subscribe !== 'function') continue;\n\n // Subscribe directly — avoids the ReadonlySignal<T> generic variance issue\n const unsub = maybeSig.subscribe((value) => {\n onUpdate(stateRef.propKey, value);\n });\n instance.trackCleanup(unsub);\n }\n}\n\n// ── Reactive list wiring ────────────────────────────────────────────────────────\n\ntype ListBuildFn = (items: unknown) => GraphNode[];\ntype ListPlanFn = (items: unknown) => PlanEntry[];\n\n/**\n * Subscribe a reactive-list instance to its driving signal. On each change the\n * DSL-registered plan factory produces lightweight per-row descriptors, which\n * are reconciled against the live DOM with the keyed, minimal-move reconciler\n * (spec §15). A `conditional` node has no plan handler and falls back to the\n * eager build factory (it only ever renders 0..1 branch, so eager is fine).\n */\nexport function wireReactiveList(\n ctx: RenderContext,\n graphNode: GraphNode,\n instance: NodeInstance,\n el: Element,\n): void {\n const plan = ctx.graph.getHandler(`__listplan__${graphNode.id}`) as\n | ListPlanFn\n | undefined;\n const build = ctx.graph.getHandler(`__listbuild__${graphNode.id}`) as\n | ListBuildFn\n | undefined;\n if (plan === undefined && build === undefined) return;\n\n for (const stateRef of graphNode.stateRefs) {\n if (stateRef.propKey !== 'items') continue;\n const sig = ctx.graph.getHandler(`__signal__${stateRef.signalId}`) as\n | { subscribe: (fn: (v: unknown) => void) => () => void }\n | undefined;\n if (sig === undefined || typeof sig.subscribe !== 'function') continue;\n\n const unsub = sig.subscribe((value) => {\n if (plan !== undefined) {\n reconcileReactiveListByPlan(ctx, graphNode, instance, el, plan(value));\n } else {\n reconcileReactiveList(ctx, graphNode, instance, el, build!(value));\n }\n });\n instance.trackCleanup(unsub);\n }\n}\n\nfunction reconcileReactiveListByPlan(\n ctx: RenderContext,\n listNode: GraphNode,\n listInstance: NodeInstance,\n listEl: Element,\n plan: PlanEntry[],\n): void {\n const oldInstances = [...listInstance.children];\n const result = reconcileChildrenByPlan(\n ctx,\n listEl,\n oldInstances,\n plan,\n (node, parent) => mountNode(ctx, node, parent),\n );\n\n // Sync the live instance's children to the reconciled order.\n listInstance.children.length = 0;\n for (const inst of result.instances) listInstance.children.push(inst);\n\n // Forget removed instances, and drop their graph nodes.\n for (const removed of result.removed) {\n forgetInstance(ctx, removed);\n ctx.graph.detachNode(removed.graphNode);\n }\n // Detach any freshly-built subtree that was not adopted as a live instance\n // (e.g. the top node of a rebuilt changed row, whose live instance keeps its\n // original graph node).\n const adopted = new Set(result.instances.map((i) => i.graphNode));\n for (const node of result.built ?? []) {\n if (!adopted.has(node)) ctx.graph.detachNode(node);\n }\n\n // Keep the graph model consistent: list node children match the new order.\n for (const child of [...listNode.children]) listNode.removeChild(child);\n for (const inst of result.instances) listNode.appendChild(inst.graphNode);\n}\n\nfunction reconcileReactiveList(\n ctx: RenderContext,\n listNode: GraphNode,\n listInstance: NodeInstance,\n listEl: Element,\n newNodes: GraphNode[],\n): void {\n const oldInstances = [...listInstance.children];\n const result = reconcileChildren(\n ctx,\n listEl,\n oldInstances,\n newNodes,\n (node, parent) => mountNode(ctx, node, parent),\n );\n\n // Sync the live instance's children to the reconciled order.\n listInstance.children.length = 0;\n for (const inst of result.instances) listInstance.children.push(inst);\n\n // Forget removed instances from the renderer index, and drop their graph\n // nodes (and any un-adopted freshly-built duplicates) from the graph index.\n for (const removed of result.removed) {\n forgetInstance(ctx, removed);\n ctx.graph.detachNode(removed.graphNode);\n }\n const adopted = new Set(result.instances.map((i) => i.graphNode));\n for (const built of newNodes) {\n if (!adopted.has(built)) ctx.graph.detachNode(built);\n }\n\n // Keep the graph model consistent: list node children match the new order.\n for (const child of [...listNode.children]) listNode.removeChild(child);\n for (const inst of result.instances) listNode.appendChild(inst.graphNode);\n}\n\n/** Recursively remove an instance subtree from the renderer's instance index. */\nfunction forgetInstance(ctx: RenderContext, instance: NodeInstance): void {\n ctx.instances.delete(instance.graphNode.id);\n for (const child of instance.children) forgetInstance(ctx, child);\n}\n","/**\n * Server-side DOM node model.\n *\n * A tiny, dependency-free tree of plain objects that mirrors just enough of the\n * browser DOM for StreetUI's renderer to build a tree on the server and\n * serialize it to an HTML string. There is NO browser global here — these are\n * ordinary classes usable in any JavaScript environment (Node, workers, tests).\n *\n * The renderer never touches these types directly; it goes through the\n * `DOMAdapter` interface, and `ServerDOMAdapter` translates adapter calls into\n * operations on this model.\n */\n\nexport type ServerNodeKind = 'element' | 'text' | 'comment' | 'fragment';\n\nexport interface ServerNode {\n readonly kind: ServerNodeKind;\n parent: ServerParent | null;\n}\n\nexport type ServerParent = ServerElement | ServerFragment;\n\n/** A minimal inline-style holder mirroring `element.style.setProperty`. */\nexport class ServerStyle {\n readonly declarations = new Map<string, string>();\n setProperty(name: string, value: string): void {\n this.declarations.set(name, value);\n }\n get isEmpty(): boolean {\n return this.declarations.size === 0;\n }\n toCss(): string {\n return [...this.declarations.entries()].map(([k, v]) => `${k}: ${v}`).join('; ');\n }\n}\n\nexport class ServerText implements ServerNode {\n readonly kind = 'text' as const;\n parent: ServerParent | null = null;\n data: string;\n constructor(data: string) {\n this.data = data;\n }\n}\n\nexport class ServerComment implements ServerNode {\n readonly kind = 'comment' as const;\n parent: ServerParent | null = null;\n data: string;\n constructor(data: string) {\n this.data = data;\n }\n}\n\nexport class ServerFragment implements ServerNode {\n readonly kind = 'fragment' as const;\n parent: ServerParent | null = null;\n readonly children: ServerNode[] = [];\n}\n\nexport class ServerElement implements ServerNode {\n readonly kind = 'element' as const;\n parent: ServerParent | null = null;\n readonly tagName: string;\n readonly attributes = new Map<string, string>();\n /** JS properties set via `setProperty` (e.g. input `value`, `checked`). */\n readonly properties = new Map<string, unknown>();\n readonly children: ServerNode[] = [];\n readonly style = new ServerStyle();\n\n constructor(tagName: string) {\n this.tagName = tagName.toLowerCase();\n }\n}\n\n// ── HTML serialization ─────────────────────────────────────────────────────────\n\n/**\n * HTML \"void\" elements — self-closing, never given a closing tag or children.\n */\nconst VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr',\n]);\n\n/**\n * Element properties that should be reflected into the serialized HTML so the\n * hydrated DOM carries the same initial state. `value`/`checked` matter for\n * form controls whose live state is a JS property, not an attribute.\n */\nconst SERIALIZED_PROPERTIES: Record<string, 'attr' | 'boolean'> = {\n value: 'attr',\n checked: 'boolean',\n selected: 'boolean',\n};\n\n/** Escape text node content. */\nexport function escapeHtmlText(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;');\n}\n\n/** Escape a double-quoted attribute value. */\nexport function escapeHtmlAttr(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;');\n}\n\nfunction serializeAttributes(el: ServerElement): string {\n const parts: string[] = [];\n\n for (const [name, value] of el.attributes) {\n if (value === '') {\n parts.push(` ${name}`);\n } else {\n parts.push(` ${name}=\"${escapeHtmlAttr(value)}\"`);\n }\n }\n\n for (const [name, kind] of Object.entries(SERIALIZED_PROPERTIES)) {\n if (!el.properties.has(name)) continue;\n if (el.attributes.has(name)) continue; // an explicit attribute already won\n const raw = el.properties.get(name);\n if (kind === 'boolean') {\n if (raw === true) parts.push(` ${name}`);\n } else {\n if (raw !== undefined && raw !== null) {\n parts.push(` ${name}=\"${escapeHtmlAttr(String(raw))}\"`);\n }\n }\n }\n\n if (!el.style.isEmpty && !el.attributes.has('style')) {\n parts.push(` style=\"${escapeHtmlAttr(el.style.toCss())}\"`);\n }\n\n return parts.join('');\n}\n\n/** Serialize a single server node (element/text/comment/fragment) to HTML. */\nexport function serializeServerNode(node: ServerNode): string {\n switch (node.kind) {\n case 'text':\n return escapeHtmlText((node as ServerText).data);\n case 'comment':\n return `<!--${(node as ServerComment).data}-->`;\n case 'fragment':\n return serializeChildren(node as ServerFragment);\n case 'element': {\n const el = node as ServerElement;\n const tag = el.tagName;\n const attrs = serializeAttributes(el);\n if (VOID_ELEMENTS.has(tag)) {\n return `<${tag}${attrs}>`;\n }\n return `<${tag}${attrs}>${serializeChildren(el)}</${tag}>`;\n }\n }\n}\n\n/** Serialize the children of an element or fragment (its \"inner HTML\"). */\nexport function serializeChildren(node: ServerElement | ServerFragment): string {\n let out = '';\n for (const child of node.children) {\n out += serializeServerNode(child);\n }\n return out;\n}\n","/**\n * Server implementation of `DOMAdapter`.\n *\n * Builds a lightweight in-memory tree (see `server-node.ts`) instead of touching\n * a real browser DOM, then lets the caller serialize it to an HTML string. It is\n * completely free of browser globals, so the exact same renderer that runs in\n * the browser can produce HTML on the server.\n *\n * The `DOMAdapter` interface is typed against the lib DOM types (`Element`,\n * `Node`, `Text`, …). Our server nodes structurally stand in for those at\n * runtime, so the boundary uses `as unknown as` casts in one place. Everything\n * inside operates on the real server-node model.\n */\n\nimport type { DOMAdapter } from './adapter.js';\nimport {\n ServerElement,\n ServerText,\n ServerComment,\n ServerFragment,\n serializeChildren,\n serializeServerNode,\n type ServerNode,\n type ServerParent,\n} from './server-node.js';\n\nfunction asServer(node: unknown): ServerNode {\n return node as unknown as ServerNode;\n}\nfunction asParent(node: unknown): ServerParent {\n return node as unknown as ServerParent;\n}\n\nexport class ServerDOMAdapter implements DOMAdapter {\n createElement(tag: string, _ns?: string): Element {\n return new ServerElement(tag) as unknown as Element;\n }\n\n createTextNode(data: string): Text {\n return new ServerText(data) as unknown as Text;\n }\n\n createComment(data: string): Comment {\n return new ServerComment(data) as unknown as Comment;\n }\n\n createFragment(): DocumentFragment {\n return new ServerFragment() as unknown as DocumentFragment;\n }\n\n appendChild(parent: Node, child: Node): void {\n const p = asParent(parent);\n const c = asServer(child);\n this._detach(c);\n c.parent = p;\n p.children.push(c);\n }\n\n insertBefore(parent: Node, child: Node, reference: Node | null): void {\n const p = asParent(parent);\n const c = asServer(child);\n this._detach(c);\n c.parent = p;\n if (reference === null) {\n p.children.push(c);\n return;\n }\n const ref = asServer(reference);\n const idx = p.children.indexOf(ref);\n if (idx === -1) p.children.push(c);\n else p.children.splice(idx, 0, c);\n }\n\n removeChild(parent: Node, child: Node): void {\n const p = asParent(parent);\n const c = asServer(child);\n const idx = p.children.indexOf(c);\n if (idx !== -1) {\n p.children.splice(idx, 1);\n c.parent = null;\n }\n }\n\n replaceChild(parent: Node, newChild: Node, oldChild: Node): void {\n const p = asParent(parent);\n const nc = asServer(newChild);\n const oc = asServer(oldChild);\n const idx = p.children.indexOf(oc);\n if (idx === -1) return;\n this._detach(nc);\n nc.parent = p;\n p.children.splice(idx, 1, nc);\n oc.parent = null;\n }\n\n private _detach(node: ServerNode): void {\n if (node.parent !== null) {\n const siblings = node.parent.children;\n const idx = siblings.indexOf(node);\n if (idx !== -1) siblings.splice(idx, 1);\n node.parent = null;\n }\n }\n\n setAttribute(element: Element, name: string, value: string): void {\n (element as unknown as ServerElement).attributes.set(name, value);\n }\n\n removeAttribute(element: Element, name: string): void {\n (element as unknown as ServerElement).attributes.delete(name);\n }\n\n getAttribute(element: Element, name: string): string | null {\n return (element as unknown as ServerElement).attributes.get(name) ?? null;\n }\n\n setProperty(element: Element, name: string, value: unknown): void {\n (element as unknown as ServerElement).properties.set(name, value);\n }\n\n setTextContent(node: Node, text: string): void {\n const n = asServer(node);\n if (n.kind === 'element' || n.kind === 'fragment') {\n const el = n as ServerElement | ServerFragment;\n el.children.length = 0;\n const t = new ServerText(text);\n t.parent = el;\n el.children.push(t);\n } else if (n.kind === 'text') {\n (n as ServerText).data = text;\n }\n }\n\n getTextContent(node: Node): string | null {\n const n = asServer(node);\n if (n.kind === 'text') return (n as ServerText).data;\n if (n.kind === 'element' || n.kind === 'fragment') {\n let out = '';\n for (const c of (n as ServerElement | ServerFragment).children) {\n out += this.getTextContent(c as unknown as Node) ?? '';\n }\n return out;\n }\n return null;\n }\n\n // Server nodes never dispatch events — listeners are a no-op on the server.\n addEventListener(): void {\n /* no-op on the server */\n }\n removeEventListener(): void {\n /* no-op on the server */\n }\n\n querySelector(): Element | null {\n return null;\n }\n querySelectorAll(): NodeListOf<Element> {\n return [] as unknown as NodeListOf<Element>;\n }\n getElementById(): Element | null {\n return null;\n }\n\n focus(): void {\n // No focus concept on the server — intentional no-op (SSR-safe).\n }\n\n isElement(node: Node): node is Element {\n return asServer(node).kind === 'element';\n }\n\n isTextNode(node: Node): node is Text {\n return asServer(node).kind === 'text';\n }\n\n tagName(element: Element): string {\n return (element as unknown as ServerElement).tagName;\n }\n\n parentNode(node: Node): Node | null {\n return (asServer(node).parent as unknown as Node | null) ?? null;\n }\n\n nextSibling(node: Node): Node | null {\n const n = asServer(node);\n const parent = n.parent;\n if (parent === null) return null;\n const idx = parent.children.indexOf(n);\n if (idx === -1 || idx + 1 >= parent.children.length) return null;\n return parent.children[idx + 1] as unknown as Node;\n }\n\n firstChild(node: Node): Node | null {\n const n = asServer(node);\n if (n.kind === 'element' || n.kind === 'fragment') {\n const el = n as ServerElement | ServerFragment;\n return (el.children[0] as unknown as Node) ?? null;\n }\n return null;\n }\n\n childNodes(node: Node): Node[] {\n const n = asServer(node);\n if (n.kind === 'element' || n.kind === 'fragment') {\n return (n as ServerElement | ServerFragment).children as unknown as Node[];\n }\n return [];\n }\n\n // ── Server-only ────────────────────────────────────────────────────────────\n\n /** Serialize a node's children (\"inner HTML\") to an HTML string. */\n serializeInner(node: Node): string {\n const n = asServer(node);\n if (n.kind === 'element' || n.kind === 'fragment') {\n return serializeChildren(n as ServerElement | ServerFragment);\n }\n return '';\n }\n\n /** Serialize a node (including itself) to an HTML string. */\n serializeOuter(node: Node): string {\n return serializeServerNode(asServer(node));\n }\n}\n\nexport const serverDOMAdapter = new ServerDOMAdapter();\n","/**\n * SSR state transfer (dehydration) — move server-resolved data to the client.\n *\n * When the server resolves resources before rendering, their data must reach\n * the client so hydration can seed them (via `resource({ initialData })`)\n * instead of refetching. StreetUI does this with a single, framework-scoped\n * `<script>` payload rather than blindly interpolating `JSON.stringify` into\n * markup.\n *\n * Safety (v0.4 rule #16): the JSON is emitted into a\n * `<script type=\"application/json\">` block — an inert data island the browser\n * never executes — and every character that could terminate that block or be\n * reinterpreted by the HTML/JS parser is escaped to its `\\uXXXX` form. Because\n * `<` inside JSON parses back to `<`, the payload round-trips exactly\n * while being impossible to break out of. This is deterministic (stable key\n * order is the caller's responsibility) and typed at the boundary as\n * `Record<string, unknown>` — never `any`.\n */\n\nimport type { DOMAdapter } from '@streetui/dom';\n\n/** Attribute marking StreetUI's state island so the client can find it. */\nexport const STATE_MARKER_ATTR = 'data-streetui-state';\n\n/**\n * Escape a JSON string for safe embedding inside a `<script>` element:\n * < > & → HTML / `</script>` breakout and entity ambiguity\n * U+2028 / U+2029 → invalid raw in JS string literals\n * Uses code-point checks so no raw separator characters live in this source.\n */\nfunction escapeForScript(json: string): string {\n let out = '';\n for (const ch of json) {\n const code = ch.charCodeAt(0);\n if (ch === '<') out += '\\\\u003c';\n else if (ch === '>') out += '\\\\u003e';\n else if (ch === '&') out += '\\\\u0026';\n else if (code === 0x2028) out += '\\\\u2028';\n else if (code === 0x2029) out += '\\\\u2029';\n else out += ch;\n }\n return out;\n}\n\n/**\n * Serialize a state map to an HTML `<script>` island for inclusion in the\n * server-rendered document (typically just before the closing tag of the\n * mount container). Returns an empty string for an empty map.\n */\nexport function serializeState(state: Record<string, unknown>): string {\n if (Object.keys(state).length === 0) return '';\n const json = escapeForScript(JSON.stringify(state));\n return `<script type=\"application/json\" ${STATE_MARKER_ATTR}>${json}</script>`;\n}\n\n/**\n * Read the state island back on the client. Searches `root` for StreetUI's\n * state `<script>` and parses it. Returns an empty object when absent or\n * unparseable (hydration then proceeds as a cold client render). Routed through\n * the DOM adapter so it is testable and never assumes a global `document`.\n */\nexport function readState(\n dom: DOMAdapter,\n root: Element | Document,\n): Record<string, unknown> {\n const el = dom.querySelector(root, `script[${STATE_MARKER_ATTR}]`);\n if (el === null) return {};\n const text = dom.getTextContent(el);\n if (text === null || text.length === 0) return {};\n try {\n const parsed: unknown = JSON.parse(text);\n if (parsed !== null && typeof parsed === 'object') {\n return parsed as Record<string, unknown>;\n }\n return {};\n } catch {\n return {};\n }\n}\n","/**\n * Server-side rendering — `renderToString`.\n *\n * Runs the *exact same* mount pipeline used in the browser (`mountGraph`), but\n * against a `ServerDOMAdapter` that builds a lightweight in-memory node tree\n * instead of a real browser DOM. The tree is then serialized to a normal HTML\n * string. Because both browser and server share the DSL → Compiler → Graph →\n * Runtime → Renderer pipeline, there is no second, SSR-specific renderer and no\n * virtual DOM.\n *\n * Lifecycle (v0.4 rule #20): the initial synchronous mount may open signal\n * subscriptions (via `wireSignalBindings`/`wireReactiveList`). On the server\n * those would be live forever, so once the HTML is serialized we dispose the\n * root instance — tearing down every subscription and listener. SSR therefore\n * has a *render* lifecycle only; the live *runtime* lifecycle is established\n * later on the client by `hydrate`.\n */\n\nimport { ServerDOMAdapter } from '@streetui/dom';\nimport type { CompiledApplication } from '@streetui/compiler';\nimport { createRenderContext } from './render-context.js';\nimport { mountGraph } from './mount.js';\n\nexport interface RenderToStringOptions {\n /**\n * Override the server DOM adapter (rarely needed). Defaults to a fresh\n * `ServerDOMAdapter` per call so concurrent renders never share state.\n */\n readonly domAdapter?: ServerDOMAdapter;\n}\n\n/**\n * Render a compiled StreetUI application to an HTML string.\n *\n * The returned markup contains only the application's own elements (the\n * synthetic container is not emitted), so callers embed it wherever they mount\n * on the client — e.g. inside `<div id=\"app\">…</div>`.\n */\nexport function renderToString(\n compiled: CompiledApplication,\n options: RenderToStringOptions = {},\n): string {\n const dom = options.domAdapter ?? new ServerDOMAdapter();\n\n // Synthetic container — the application root maps onto it, and the app's\n // top-level nodes are appended directly into it (mirroring browser mount).\n const container = dom.createElement('div');\n\n const ctx = createRenderContext(dom, compiled.graph, container);\n const rootInstance = mountGraph(ctx);\n\n const html = dom.serializeInner(container);\n\n // Tear down any subscriptions/listeners opened during mount — the server has\n // no live runtime. (rule #20)\n rootInstance.dispose();\n ctx.instances.clear();\n\n return html;\n}\n","/**\n * The single authoritative StreetUI framework version.\n *\n * This constant is the one source of truth for the version of the shipped\n * `streetui` package. It is kept in lock-step with this package's\n * `package.json` `version` field and with the bundled CLI's reported version\n * (`streetui --version`) — the consolidated test-suite pins all three to the\n * same coordinated release so they can never silently drift apart.\n */\nexport const VERSION = '1.3.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2BO,SAAS,oBACd,KACA,OACA,WACA,sBACe;AACf,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,WAAW,oBAAI,IAAI;AAAA,IACnB;AAAA,IACA,GAAI,yBAAyB,SAAY,EAAE,qBAAqB,IAAI,CAAC;AAAA,EACvE;AACF;;;AC4BO,IAAM,kBAAN,MAAsB;AAAA,EACV,OAA0B,CAAC;AAAA,EAE5C,IAAI,IAAsB;AACxB,SAAK,KAAK,KAAK,EAAE;AAAA,EACnB;AAAA,EAEA,MAAY;AACV,eAAW,MAAM,KAAK,MAAM;AAC1B,UAAI;AACF,WAAG;AAAA,MACL,QAAQ;AAAA,MAER;AAAA,IACF;AACA,SAAK,KAAK,SAAS;AAAA,EACrB;AACF;;;AC1EO,IAAM,eAAN,MAAmB;AAAA,EACf;AAAA;AAAA,EAET;AAAA,EACS,WAA2B,CAAC;AAAA,EAC5B,UAA2B,IAAI,gBAAgB;AAAA,EAExD,YAAY,WAAsB,SAAe;AAC/C,SAAK,YAAY;AACjB,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,SAAS,OAA2B;AAClC,SAAK,SAAS,KAAK,KAAK;AAAA,EAC1B;AAAA;AAAA,EAGA,YAAe,KAAwB,SAA+B;AACpE,UAAM,QAAQ,IAAI,UAAU,OAAO;AACnC,SAAK,QAAQ,IAAI,KAAK;AAAA,EACxB;AAAA;A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ACzB,QAAM,KAAK,IAAI,cAAc,MAAM,UAAU,iBAAiB,GAAG;AACjE,MAAI,OAAO,KAAM,QAAO,CAAC;AACzB,QAAM,OAAO,IAAI,eAAe,EAAE;AAClC,MAAI,SAAS,QAAQ,KAAK,WAAW,EAAG,QAAO,CAAC;AAChD,MAAI;AACF,UAAM,SAAkB,KAAK,MAAM,IAAI;AACvC,QAAI,WAAW,QAAQ,OAAO,WAAW,UAAU;AACjD,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;;;ACxCO,SAAS,eACd,UACA,UAAiC,CAAC,GAC1B;AACR,QAAM,MAAM,QAAQ,cAAc,IAAI,iBAAiB;AAIvD,QAAM,YAAY,IAAI,cAAc,KAAK;AAEzC,QAAM,MAAM,oBAAoB,KAAK,SAAS,OAAO,SAAS;AAC9D,QAAM,eAAe,WAAW,GAAG;AAEnC,QAAM,OAAO,IAAI,eAAe,SAAS;AAIzC,eAAa,QAAQ;AACrB,MAAI,UAAU,MAAM;AAEpB,SAAO;AACT;;;AClDO,IAAM,UAAU;","names":["instance","el","tag"]}
package/dist/server.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- export { R as RenderToStringOptions, S as STATE_MARKER_ATTR, a as ServerDOMAdapter, r as readState, b as renderToString, s as serializeState } from './server-BYXgNCQK.cjs';
2
- export { V as VERSION } from './compile-DsNJm9IJ.cjs';
1
+ export { R as RenderToStringOptions, S as STATE_MARKER_ATTR, a as ServerDOMAdapter, r as readState, b as renderToString, s as serializeState } from './server-BeFSjxkL.cjs';
2
+ export { V as VERSION } from './compile-CTA4MLX6.cjs';
package/dist/server.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { R as RenderToStringOptions, S as STATE_MARKER_ATTR, a as ServerDOMAdapter, r as readState, b as renderToString, s as serializeState } from './server-BYdG0sP_.js';
2
- export { V as VERSION } from './compile-DsNJm9IJ.js';
1
+ export { R as RenderToStringOptions, S as STATE_MARKER_ATTR, a as ServerDOMAdapter, r as readState, b as renderToString, s as serializeState } from './server-CtHBgrxf.js';
2
+ export { V as VERSION } from './compile-CTA4MLX6.js';
package/dist/server.js CHANGED
@@ -1070,7 +1070,7 @@ function renderToString(compiled, options = {}) {
1070
1070
  }
1071
1071
 
1072
1072
  // src/version.ts
1073
- var VERSION = "1.2.0";
1073
+ var VERSION = "1.3.0";
1074
1074
  export {
1075
1075
  STATE_MARKER_ATTR,
1076
1076
  ServerDOMAdapter,