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.
- package/dist/bin.cjs +1 -1
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +1 -1
- package/dist/bin.js.map +1 -1
- package/dist/{compile-DsNJm9IJ.d.cts → compile-CTA4MLX6.d.cts} +1 -1
- package/dist/{compile-DsNJm9IJ.d.ts → compile-CTA4MLX6.d.ts} +1 -1
- package/dist/create-bin.cjs +1 -1
- package/dist/create-bin.cjs.map +1 -1
- package/dist/create-bin.js +1 -1
- package/dist/create-bin.js.map +1 -1
- package/dist/{hydration-diagnostics-OFIDPD15.d.cts → hydration-diagnostics-Cu2ZRxL1.d.cts} +1 -1
- package/dist/{hydration-diagnostics-BN1S-fbq.d.ts → hydration-diagnostics-DqkNk4EU.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{server-BYXgNCQK.d.cts → server-BeFSjxkL.d.cts} +1 -1
- package/dist/{server-BYdG0sP_.d.ts → server-CtHBgrxf.d.ts} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +3 -3
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/testing.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing.ts","../../core/src/identity.ts","../../core/src/lifecycle.ts","../../core/src/diagnostics.ts","../../compiler/src/validation/validator.ts","../../compiler/src/transform/transform.ts","../../compiler/src/compile.ts","../../dom/src/browser-adapter.ts","../../dom/src/server-node.ts","../../dom/src/server-adapter.ts","../../renderer/src/render-context.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","../../renderer/src/hydration-diagnostics.ts","../../renderer/src/hydrate.ts","../../renderer/src/render-handle.ts","../../renderer/src/renderer.ts","../../renderer/src/ssr.ts","../../testing/src/test-renderer.ts","../../scheduler/src/scheduler.ts","../../testing/src/helpers.ts","../../compiler/src/analysis/analyze.ts","../../compiler/src/analysis/inspect.ts","../src/version.ts"],"sourcesContent":["/**\n * `streetui/testing` — testing utilities for StreetUI applications.\n *\n * A curated entry for the already-implemented testing helpers (render,\n * findByRole, waitFor, renderServerThenHydrate, …). It lives on its own subpath\n * so that test-only helpers stay out of the main runtime barrel — and so the\n * one cross-package name collision (`RenderResult`, shared with the CLI's render\n * types) is resolved cleanly: the testing `RenderResult` is reachable only from\n * here.\n *\n * ```ts\n * import { render, findByRole, waitFor } from 'streetui/testing';\n * ```\n */\nexport * from '@streetui/testing';\n\n// Opt-in compiler diagnostics (spec §14): static-graph analysis + inspection.\n// Exposed on the diagnostic subpath so they stay OUT of the runtime barrel\n// (`streetui`), keeping the shipped client bundle lean (§6/§7).\nexport * from '@streetui/compiler/diagnostics';\n\n// Re-export the framework version for parity with the main entry.\nexport { VERSION } from './version.js';\n","/**\n * Node and application identity utilities.\n * Every node in the semantic graph has a stable, unique identity.\n */\n\nlet _counter = 0;\n\n/** Generate a framework-internal monotonic integer ID. */\nexport function nextId(): number {\n return ++_counter;\n}\n\n/** Reset the counter (test use only). */\nexport function resetIdCounter(): void {\n _counter = 0;\n}\n\n/** Opaque branded type for node IDs. */\nexport type NodeId = string & { readonly __brand: 'NodeId' };\n\n/** Create a NodeId from a string (must be unique at call site). */\nexport function createNodeId(value: string): NodeId {\n return value as NodeId;\n}\n\n/** Generate a fresh, unique NodeId. */\nexport function generateNodeId(prefix: string = 'node'): NodeId {\n return createNodeId(`${prefix}:${nextId()}`);\n}\n\n/** Parse the prefix from a NodeId. */\nexport function nodeIdPrefix(id: NodeId): string {\n const colon = id.indexOf(':');\n return colon === -1 ? id : id.slice(0, colon);\n}\n\n/** Branded type for application IDs. */\nexport type ApplicationId = string & { readonly __brand: 'ApplicationId' };\n\n/** Generate a fresh application ID. */\nexport function generateApplicationId(name: string): ApplicationId {\n return `app:${name}:${nextId()}` as ApplicationId;\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 * Framework diagnostics — structured errors, warnings, and hints\n * that flow through the compiler, validator, and runtime.\n */\n\nexport type DiagnosticSeverity = 'error' | 'warning' | 'info';\n\nexport interface DiagnosticLocation {\n readonly file?: string;\n readonly line?: number;\n readonly column?: number;\n readonly nodeId?: string;\n}\n\nexport interface Diagnostic {\n readonly severity: DiagnosticSeverity;\n readonly code: string;\n readonly message: string;\n readonly location: DiagnosticLocation | undefined;\n readonly cause: unknown;\n}\n\nexport class DiagnosticError extends Error {\n readonly diagnostics: readonly Diagnostic[];\n\n constructor(diagnostics: readonly Diagnostic[]) {\n const summary = diagnostics\n .filter(d => d.severity === 'error')\n .map(d => `[${d.code}] ${d.message}`)\n .join('\\n');\n super(`StreetUI diagnostics:\\n${summary}`);\n this.name = 'DiagnosticError';\n this.diagnostics = diagnostics;\n }\n}\n\nexport class DiagnosticCollector {\n private readonly _diagnostics: Diagnostic[] = [];\n\n get diagnostics(): readonly Diagnostic[] {\n return this._diagnostics;\n }\n\n get hasErrors(): boolean {\n return this._diagnostics.some(d => d.severity === 'error');\n }\n\n get hasWarnings(): boolean {\n return this._diagnostics.some(d => d.severity === 'warning');\n }\n\n error(\n code: string,\n message: string,\n location?: DiagnosticLocation,\n cause?: unknown,\n ): void {\n this._diagnostics.push({ severity: 'error', code, message, location: location ?? undefined, cause: cause ?? undefined });\n }\n\n warn(\n code: string,\n message: string,\n location?: DiagnosticLocation,\n ): void {\n this._diagnostics.push({ severity: 'warning', code, message, location: location ?? undefined, cause: undefined });\n }\n\n info(\n code: string,\n message: string,\n location?: DiagnosticLocation,\n ): void {\n this._diagnostics.push({ severity: 'info', code, message, location: location ?? undefined, cause: undefined });\n }\n\n merge(other: DiagnosticCollector): void {\n for (const d of other.diagnostics) {\n this._diagnostics.push(d);\n }\n }\n\n throwIfErrors(): void {\n if (this.hasErrors) {\n throw new DiagnosticError(this._diagnostics);\n }\n }\n\n clear(): void {\n this._diagnostics.length = 0;\n }\n}\n\n/** Format a single diagnostic as a human-readable string. */\nexport function formatDiagnostic(d: Diagnostic): string {\n const loc = d.location !== undefined\n ? ` (${[d.location.file, d.location.line, d.location.column]\n .filter(Boolean)\n .join(':')})`\n : '';\n return `[${d.severity.toUpperCase()}] ${d.code}: ${d.message}${loc}`;\n}\n","/**\n * Compiler-phase validation of the ApplicationGraph.\n *\n * This runs after the DSL has built the graph but before the runtime\n * receives a CompiledApplication. More checks live here than in the\n * graph's own validate() because the compiler has broader context.\n */\n\nimport { DiagnosticCollector } from '@streetui/core';\nimport { ApplicationGraph, GraphNode } from '@streetui/graph';\n\nexport function validateGraph(graph: ApplicationGraph): DiagnosticCollector {\n const dc = new DiagnosticCollector();\n\n // Merge built-in graph validations\n dc.merge(graph.validate());\n\n // Must have at least one page\n const pages = graph.findByType('page');\n if (pages.length === 0) {\n dc.warn(\n 'COMPILER_NO_PAGES',\n 'Application has no pages defined. At least one page is recommended.',\n );\n }\n\n // Walk and validate individual nodes\n graph.walk((node) => {\n validateNode(node, dc);\n });\n\n return dc;\n}\n\nfunction validateNode(node: GraphNode, dc: DiagnosticCollector): void {\n switch (node.type) {\n case 'heading': {\n const text = node.getProp('text');\n if (text === undefined || text === '') {\n dc.warn('COMPILER_EMPTY_HEADING', `Heading node \"${node.id}\" has no text content`, {\n nodeId: node.id,\n });\n }\n break;\n }\n case 'image': {\n const src = node.getProp('src');\n const alt = node.getProp('alt');\n if (!src) {\n dc.error('COMPILER_IMAGE_NO_SRC', `Image node \"${node.id}\" is missing src`, {\n nodeId: node.id,\n });\n }\n if (!alt) {\n dc.warn('COMPILER_IMAGE_NO_ALT', `Image node \"${node.id}\" is missing alt text`, {\n nodeId: node.id,\n });\n }\n break;\n }\n case 'link': {\n const href = node.getProp('href');\n if (!href) {\n dc.error('COMPILER_LINK_NO_HREF', `Link node \"${node.id}\" is missing href`, {\n nodeId: node.id,\n });\n }\n break;\n }\n default:\n break;\n }\n}\n","/**\n * Graph transformation pass.\n *\n * After validation, the transformer prepares the graph for the runtime by:\n * - Resolving implicit defaults (e.g. heading level defaults to 1)\n * - Normalizing prop names\n * - Assigning deterministic render keys where missing\n * - Flattening / hoisting where beneficial\n */\n\nimport { ApplicationGraph, GraphNode } from '@streetui/graph';\n\nexport function transformGraph(graph: ApplicationGraph): void {\n graph.walk((node, depth) => {\n applyDefaults(node);\n ensureRenderKey(node, depth);\n });\n}\n\nfunction applyDefaults(node: GraphNode): void {\n switch (node.type) {\n case 'heading': {\n if (node.getProp('level') === undefined) {\n node.setProp('level', 1);\n }\n break;\n }\n case 'input': {\n if (node.getProp('inputType') === undefined) {\n node.setProp('inputType', 'text');\n }\n break;\n }\n case 'link': {\n if (node.getProp('external') === undefined) {\n node.setProp('external', false);\n }\n break;\n }\n default:\n break;\n }\n}\n\nfunction ensureRenderKey(node: GraphNode, depth: number): void {\n if (node.getProp('_renderKey') === undefined) {\n const key = node.key ?? `${node.type}:${node.id}:${depth}`;\n node.setProp('_renderKey', key);\n }\n}\n","/**\n * StreetUI compiler entry point.\n *\n * Pipeline:\n * StreetApp (DSL)\n * → ApplicationGraph (build)\n * → validate\n * → transform\n * → CompiledApplication\n */\n\nimport { DiagnosticCollector } from '@streetui/core';\nimport { type ApplicationGraph } from '@streetui/graph';\nimport { type StreetApp } from '@streetui/dsl';\nimport { validateGraph } from './validation/validator.js';\nimport { transformGraph } from './transform/transform.js';\n\nexport interface CompiledApplication {\n /** The fully built, validated, and transformed graph. */\n readonly graph: ApplicationGraph;\n /** Diagnostics accumulated during compilation. */\n readonly diagnostics: DiagnosticCollector;\n /** Metadata */\n readonly name: string;\n readonly version: string;\n readonly compiledAt: number;\n}\n\nexport interface CompileOptions {\n /** If true, compilation throws on errors. Defaults to true. */\n readonly strict?: boolean;\n /** If true, also throw on warnings. Defaults to false. */\n readonly strictWarnings?: boolean;\n}\n\n/**\n * Compile a StreetApp DSL definition into a CompiledApplication\n * ready for the runtime to execute.\n */\nexport function compile(\n app: StreetApp,\n options: CompileOptions = {},\n): CompiledApplication {\n const strict = options.strict ?? true;\n const strictWarnings = options.strictWarnings ?? false;\n const dc = new DiagnosticCollector();\n\n // 1. Build the graph from the DSL\n const graph = app.graph;\n\n // 2. Validate\n const validationDc = validateGraph(graph);\n dc.merge(validationDc);\n\n if (strict && dc.hasErrors) {\n dc.throwIfErrors();\n }\n if (strictWarnings && dc.hasWarnings) {\n throw new Error(\n `[StreetUI Compiler] Compilation failed: warnings treated as errors.\\n` +\n dc.diagnostics\n .filter(d => d.severity === 'warning')\n .map(d => ` [${d.code}] ${d.message}`)\n .join('\\n'),\n );\n }\n\n // 3. Transform\n transformGraph(graph);\n\n return {\n graph,\n diagnostics: dc,\n name: graph.name,\n version: graph.version,\n compiledAt: Date.now(),\n };\n}\n\n/**\n * Compile from a pre-built ApplicationGraph (used when the graph\n * was constructed programmatically rather than through the DSL).\n */\nexport function compileGraph(\n graph: ApplicationGraph,\n options: CompileOptions = {},\n): CompiledApplication {\n const strict = options.strict ?? true;\n const dc = new DiagnosticCollector();\n\n const validationDc = validateGraph(graph);\n dc.merge(validationDc);\n\n if (strict && dc.hasErrors) {\n dc.throwIfErrors();\n }\n\n transformGraph(graph);\n\n return {\n graph,\n diagnostics: dc,\n name: graph.name,\n version: graph.version,\n compiledAt: Date.now(),\n };\n}\n","/**\n * Browser implementation of DOMAdapter — delegates directly to browser APIs.\n */\n\nimport type { DOMAdapter } from './adapter.js';\n\nexport class BrowserDOMAdapter implements DOMAdapter {\n createElement(tag: string, ns?: string): Element {\n if (ns !== undefined) {\n return document.createElementNS(ns, tag);\n }\n return document.createElement(tag);\n }\n\n createTextNode(data: string): Text {\n return document.createTextNode(data);\n }\n\n createComment(data: string): Comment {\n return document.createComment(data);\n }\n\n createFragment(): DocumentFragment {\n return document.createDocumentFragment();\n }\n\n appendChild(parent: Node, child: Node): void {\n parent.appendChild(child);\n }\n\n insertBefore(parent: Node, child: Node, reference: Node | null): void {\n parent.insertBefore(child, reference);\n }\n\n removeChild(parent: Node, child: Node): void {\n parent.removeChild(child);\n }\n\n replaceChild(parent: Node, newChild: Node, oldChild: Node): void {\n parent.replaceChild(newChild, oldChild);\n }\n\n setAttribute(element: Element, name: string, value: string): void {\n element.setAttribute(name, value);\n }\n\n removeAttribute(element: Element, name: string): void {\n element.removeAttribute(name);\n }\n\n getAttribute(element: Element, name: string): string | null {\n return element.getAttribute(name);\n }\n\n setProperty(element: Element, name: string, value: unknown): void {\n (element as unknown as Record<string, unknown>)[name] = value;\n }\n\n setTextContent(node: Node, text: string): void {\n node.textContent = text;\n }\n\n getTextContent(node: Node): string | null {\n return node.textContent;\n }\n\n addEventListener(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions,\n ): void {\n target.addEventListener(type, handler, options);\n }\n\n removeEventListener(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: EventListenerOptions,\n ): void {\n target.removeEventListener(type, handler, options);\n }\n\n querySelector(root: Element | Document, selector: string): Element | null {\n return root.querySelector(selector);\n }\n\n querySelectorAll(root: Element | Document, selector: string): NodeListOf<Element> {\n return root.querySelectorAll(selector);\n }\n\n getElementById(id: string): Element | null {\n return document.getElementById(id);\n }\n\n focus(element: Element): void {\n (element as unknown as { focus?: () => void }).focus?.();\n }\n\n isElement(node: Node): node is Element {\n return node.nodeType === Node.ELEMENT_NODE;\n }\n\n isTextNode(node: Node): node is Text {\n return node.nodeType === Node.TEXT_NODE;\n }\n\n tagName(element: Element): string {\n return element.tagName.toLowerCase();\n }\n\n parentNode(node: Node): Node | null {\n return node.parentNode;\n }\n\n nextSibling(node: Node): Node | null {\n return node.nextSibling;\n }\n\n firstChild(node: Node): Node | null {\n return node.firstChild;\n }\n\n childNodes(node: Node): Node[] {\n return Array.from(node.childNodes);\n }\n}\n\nexport const browserDOMAdapter = new BrowserDOMAdapter();\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, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n}\n\n/** Escape a double-quoted attribute value. */\nexport function escapeHtmlAttr(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\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 * 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 * 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 * Hydration diagnostics — dev-only, opt-in explanations of hydration mismatches.\n *\n * Hydration is self-repairing: when the server-rendered DOM does not match the\n * graph at a position, the renderer mounts a fresh subtree in place and drops\n * the offending element (see `hydrateChildren` in `hydrate.ts`). That recovery\n * is silent by design — a local mismatch must never tear down the whole app.\n *\n * During development, though, a silent repair hides a real problem (usually a\n * server/client divergence). A `HydrationDiagnosticSink` can be attached to the\n * renderer to *observe* those repairs without changing them: for every mismatch\n * the renderer reports what it expected, what it found, where, and what it did\n * to recover. Nothing is thrown, nothing is mutated differently, and when no\n * sink is attached there is zero additional work on the hydration path.\n */\n\n/** What kind of divergence the hydrator encountered at a position. */\nexport type HydrationMismatchType =\n | 'tag-mismatch' // an element existed but was the wrong tag\n | 'missing-element' // the graph expected a child the DOM did not provide\n | 'surplus-element'; // the DOM had a child the graph no longer expects\n\n/** A single, fully-described hydration divergence and the repair taken. */\nexport interface HydrationDiagnostic {\n /** The category of mismatch. */\n readonly type: HydrationMismatchType;\n /** The tag the graph expected at this position (null for a surplus element). */\n readonly expected: string | null;\n /** The tag actually found in the server DOM (null for a missing element). */\n readonly found: string | null;\n /** A human-readable path to the position, e.g. `app / page[0] / section[1]`. */\n readonly path: string;\n /** The graph node id involved, when one exists (null for surplus DOM). */\n readonly nodeId: string | null;\n /** The semantic node type involved, when one exists (null for surplus DOM). */\n readonly nodeType: string | null;\n /** The recovery action the renderer performed. */\n readonly action: string;\n /** A single-line, developer-facing summary of the whole diagnostic. */\n readonly message: string;\n}\n\n/**\n * Receives hydration diagnostics as they are discovered. Kept intentionally\n * tiny so any logger — `console`, a test collector, a `DiagnosticSink` — can\n * satisfy it. Implementations must not throw.\n */\nexport interface HydrationDiagnosticSink {\n report(diagnostic: HydrationDiagnostic): void;\n}\n\n/** Build the canonical one-line message for a diagnostic. */\nexport function formatHydrationDiagnostic(\n d: Omit<HydrationDiagnostic, 'message'>,\n): string {\n const at = ` at ${d.path}`;\n switch (d.type) {\n case 'tag-mismatch':\n return `Hydration mismatch${at} — Expected: ${d.expected} / Found: ${d.found} / Action: ${d.action}`;\n case 'missing-element':\n return `Hydration mismatch${at} — Expected: ${d.expected} / Found: (nothing) / Action: ${d.action}`;\n case 'surplus-element':\n return `Hydration mismatch${at} — Expected: (nothing) / Found: ${d.found} / Action: ${d.action}`;\n }\n}\n\n/**\n * A ready-made sink that accumulates diagnostics into an array — the shape most\n * useful for tests and for a DevTools panel. The returned `diagnostics` array is\n * appended to in-place as repairs happen.\n */\nexport function createHydrationDiagnosticCollector(): {\n readonly sink: HydrationDiagnosticSink;\n readonly diagnostics: HydrationDiagnostic[];\n} {\n const diagnostics: HydrationDiagnostic[] = [];\n return {\n diagnostics,\n sink: {\n report(d) {\n diagnostics.push(d);\n },\n },\n };\n}\n\n/**\n * A sink that forwards each diagnostic to a `console`-like logger as a single\n * warning line. Handy default when you just want the messages surfaced in dev.\n */\nexport function consoleHydrationDiagnosticSink(\n logger: { warn(message: string): void } = console,\n): HydrationDiagnosticSink {\n return {\n report(d) {\n logger.warn(d.message);\n },\n };\n}\n","/**\n * Hydration — attach a live StreetUI runtime to server-rendered HTML.\n *\n * `hydrate` walks the semantic application graph top-down against the DOM that\n * the server already produced. For every graph node it *adopts* the matching\n * existing element (creating a `NodeInstance` that points at it) and attaches\n * behavior — event listeners and signal subscriptions — using the exact same\n * helpers the browser mount path uses (`wireEvents`, `wireSignalBindings`,\n * `wireReactiveList`, and the per-type update factories). Nothing is recreated\n * when the DOM matches.\n *\n * Matching is positional and works because every non-application graph node\n * maps to exactly one element (see mount.ts). When the element at a position\n * does not match the expected tag (or is missing), only that subtree is\n * repaired: the fresh subtree is mounted and spliced into place, leaving the\n * rest of the hydrated tree untouched. A local mismatch never tears down the\n * whole app.\n */\n\nimport type { GraphNode } from '@streetui/graph';\nimport type { RenderContext } from './render-context.js';\nimport { NodeInstance } from './node-instance.js';\nimport { wireEvents } from './events.js';\nimport { resolveTag } from './tag-map.js';\nimport { formatHydrationDiagnostic } from './hydration-diagnostics.js';\nimport {\n mountNode,\n wireSignalBindings,\n wireReactiveList,\n textUpdate,\n headingUpdate,\n inputUpdate,\n buttonUpdate,\n} from './mount.js';\n\n/** Hydrate the whole application graph against `ctx.container`. */\nexport function hydrateGraph(ctx: RenderContext): NodeInstance {\n const root = ctx.graph.root;\n // The application root maps to the container itself (no element of its own),\n // exactly as in mountNode.\n const instance = new NodeInstance(root, ctx.container);\n ctx.instances.set(root.id, instance);\n hydrateChildren(ctx, root, instance, ctx.container, 'app');\n return instance;\n}\n\n/**\n * Adopt `domNode` as the live element for `graphNode` and attach behavior.\n * The caller has already verified `domNode` matches `graphNode` (right tag).\n * `path` is the human-readable position used only for dev diagnostics.\n */\nfunction hydrateNode(\n ctx: RenderContext,\n graphNode: GraphNode,\n domNode: Element,\n path: string,\n): NodeInstance {\n const { dom, graph } = ctx;\n\n switch (graphNode.type) {\n case 'text': {\n // <span> with an inner text node. Adopt the text node (or create one if\n // the server markup somehow lacks it).\n let textNode = dom.firstChild(domNode);\n if (textNode === null || !dom.isTextNode(textNode)) {\n const created = dom.createTextNode(String(graphNode.getProp('text') ?? ''));\n dom.appendChild(domNode, created);\n textNode = created;\n }\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, domNode, instance);\n // Only build the per-type update closure when the node actually has\n // reactive bindings. wireSignalBindings early-returns on an empty\n // stateRefs list, so for a static node the `textUpdate(...)` closure would\n // be allocated and immediately discarded — pure GC pressure on the hot\n // hydration path, where the vast majority of nodes are static.\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, textUpdate(dom, domNode, textNode as Text));\n }\n return instance;\n }\n\n case 'heading': {\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, domNode, instance);\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, headingUpdate(dom, domNode));\n }\n return instance;\n }\n\n case 'input': {\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n // The controlled value is already present in the server HTML (reflected as\n // the `value` attribute). Re-assert it as a live property so the element's\n // current value matches the bound signal exactly.\n const value = graphNode.getProp('value');\n if (value !== undefined) dom.setProperty(domNode, 'value', String(value));\n wireEvents(dom, graph, graphNode, domNode, instance);\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, inputUpdate(dom, domNode));\n }\n return instance;\n }\n\n case 'button': {\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, domNode, instance);\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, buttonUpdate(dom, domNode));\n }\n return instance;\n }\n\n case 'image':\n case 'link': {\n // Leaf elements with no reactive bindings or events beyond what the markup\n // already encodes; links may still carry click handlers.\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n if (graphNode.type === 'link') wireEvents(dom, graph, graphNode, domNode, instance);\n return instance;\n }\n\n case 'reactive-list':\n case 'conditional': {\n // The server rendered the initial children (built into the graph at\n // compile time from the initial signal state). Adopt them positionally,\n // then subscribe for future signal changes — the same keyed reconciler as\n // the browser drives subsequent updates against the adopted instances.\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n hydrateChildren(ctx, graphNode, instance, domNode, path);\n wireReactiveList(ctx, graphNode, instance, domNode);\n return instance;\n }\n\n default: {\n // Structural nodes: container / section / page / form / list / list-item.\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n if (graphNode.type === 'form') {\n wireEvents(dom, graph, graphNode, domNode, instance);\n }\n // Hydration boundary (a \"slot\" such as the router outlet): adopt the\n // element itself but leave its existing children untouched — neither\n // hydrated by this pass nor removed as surplus. Something else (e.g. the\n // router) owns and will hydrate the content already inside it. Without\n // this, an empty-in-the-graph slot would strip the server-rendered\n // content it is meant to preserve.\n if (graphNode.getProp('_hydrationBoundary') === true) {\n return instance;\n }\n hydrateChildren(ctx, graphNode, instance, domNode, path);\n return instance;\n }\n }\n}\n\n// ── Child matching + local mismatch recovery ───────────────────────────────────\n\n/**\n * Positionally match a parent's expected child graph nodes against the actual\n * child *elements* in the DOM. Matching children are hydrated in place; a\n * mismatch (wrong tag or a missing element) triggers a local repair — the fresh\n * subtree is mounted and spliced into the correct position — without disturbing\n * sibling subtrees. Surplus DOM elements are removed.\n */\nfunction hydrateChildren(\n ctx: RenderContext,\n parentGraphNode: GraphNode,\n parentInstance: NodeInstance,\n parentDom: Element,\n parentPath: string,\n): void {\n const expected = parentGraphNode.children;\n const actual = elementChildren(ctx, parentDom);\n let cursor = 0;\n\n // The human-readable `path` is only ever consumed by hydration diagnostics,\n // which are inert unless a sink is attached. Building the\n // `${parentPath} / ${type}[${i}]` string for every child would allocate one\n // throwaway string per node on the hot path (10k+ on a large tree) for output\n // that is discarded in production. Gate the construction on the sink being\n // present; when it is absent, thread the (meaningless-but-unused) parent path\n // through unchanged so nested calls stay allocation-free too.\n const diag = ctx.hydrationDiagnostics !== undefined;\n\n for (let i = 0; i < expected.length; i++) {\n const childNode = expected[i]!;\n const want = expectedTag(ctx, childNode);\n const childPath = diag ? `${parentPath} / ${childNode.type}[${i}]` : parentPath;\n const actualEl = actual[cursor];\n\n if (\n actualEl !== undefined &&\n ctx.dom.isElement(actualEl) &&\n ctx.dom.tagName(actualEl) === want\n ) {\n // Match — adopt the existing element.\n const inst = hydrateNode(ctx, childNode, actualEl, childPath);\n parentInstance.addChild(inst);\n cursor++;\n } else {\n // Mismatch or missing — repair only this subtree. Mount fresh, then move\n // it into the correct position ahead of the offending/absent node.\n const ref = actualEl ?? null;\n const inst = mountFreshAt(ctx, childNode, parentDom, ref);\n parentInstance.addChild(inst);\n if (actualEl !== undefined) {\n // Drop the mismatched element that the fresh node replaces.\n const found = ctx.dom.isElement(actualEl) ? ctx.dom.tagName(actualEl) : null;\n reportHydrationDiagnostic(ctx, {\n type: 'tag-mismatch',\n expected: want,\n found,\n path: childPath,\n nodeId: childNode.id,\n nodeType: childNode.type,\n action: 'mounted fresh subtree in place',\n });\n ctx.dom.removeChild(parentDom, actualEl);\n cursor++;\n } else {\n reportHydrationDiagnostic(ctx, {\n type: 'missing-element',\n expected: want,\n found: null,\n path: childPath,\n nodeId: childNode.id,\n nodeType: childNode.type,\n action: 'mounted fresh subtree',\n });\n }\n }\n }\n\n // Remove any surplus server elements the graph no longer expects.\n for (let i = cursor; i < actual.length; i++) {\n const surplus = actual[i]!;\n reportHydrationDiagnostic(ctx, {\n type: 'surplus-element',\n expected: null,\n found: ctx.dom.isElement(surplus) ? ctx.dom.tagName(surplus) : null,\n path: `${parentPath} / [surplus ${i}]`,\n nodeId: null,\n nodeType: null,\n action: 'removed surplus server element',\n });\n ctx.dom.removeChild(parentDom, surplus);\n }\n}\n\n/**\n * Emit a hydration diagnostic through the (optional) sink. When no sink is\n * attached this is a single cheap `undefined` check — the production default.\n */\nfunction reportHydrationDiagnostic(\n ctx: RenderContext,\n d: {\n type: 'tag-mismatch' | 'missing-element' | 'surplus-element';\n expected: string | null;\n found: string | null;\n path: string;\n nodeId: string | null;\n nodeType: string | null;\n action: string;\n },\n): void {\n const sink = ctx.hydrationDiagnostics;\n if (sink === undefined) return;\n sink.report({ ...d, message: formatHydrationDiagnostic(d) });\n}\n\n/** Mount a fresh subtree for `node` and splice it before `ref` (or append). */\nfunction mountFreshAt(\n ctx: RenderContext,\n node: GraphNode,\n parentDom: Element,\n ref: Node | null,\n): NodeInstance {\n // mountNode appends the new subtree at the end of parentDom.\n const inst = mountNode(ctx, node, parentDom);\n if (ref !== null) {\n ctx.dom.insertBefore(parentDom, inst.domNode, ref);\n }\n return inst;\n}\n\n/** The element (not text/comment) children of a node, in order. */\nfunction elementChildren(ctx: RenderContext, parent: Element): Element[] {\n const out: Element[] = [];\n for (const node of ctx.dom.childNodes(parent)) {\n if (ctx.dom.isElement(node)) out.push(node);\n }\n return out;\n}\n\n/** The HTML tag a graph node is expected to occupy in the DOM. */\nfunction expectedTag(ctx: RenderContext, graphNode: GraphNode): string {\n switch (graphNode.type) {\n case 'text':\n return 'span';\n case 'heading': {\n const level = (graphNode.getProp('level') as number | undefined) ?? 1;\n return `h${level}`;\n }\n case 'input':\n return 'input';\n case 'image':\n return 'img';\n case 'link':\n return 'a';\n case 'button':\n return 'button';\n default:\n // reactive-list → ul, conditional → div, structural → resolveTag.\n return resolveTag(graphNode.type);\n }\n}\n","/**\n * StreetRenderHandle — the live handle returned by both `mount` and `hydrate`.\n *\n * Owns teardown for a mounted/hydrated application: disposes every NodeInstance\n * (removing event listeners and signal subscriptions) and clears the container\n * through the DOM adapter (never raw browser globals), so the same handle works\n * for browser and — in principle — server-driven teardown.\n */\n\nimport type { RenderHandle } from '@streetui/runtime';\nimport type { RenderContext } from './render-context.js';\nimport type { NodeInstance } from './node-instance.js';\n\nexport class StreetRenderHandle implements RenderHandle {\n private _disposed = false;\n private readonly _ctx: RenderContext;\n private readonly _rootInstance: NodeInstance;\n\n constructor(ctx: RenderContext, rootInstance: NodeInstance) {\n this._ctx = ctx;\n this._rootInstance = rootInstance;\n }\n\n flush(): void {\n if (this._disposed) return;\n // Signal subscriptions fire synchronously in StreetUI's state system;\n // flush() is a no-op at the renderer level — the DOM is already up to date\n // unless the scheduler is batching, in which case the scheduler calls\n // flush() after draining its queue.\n }\n\n unmount(): void {\n if (this._disposed) return;\n this._disposed = true;\n\n // Dispose all node instances (removes event listeners, signal subscriptions).\n this._rootInstance.dispose();\n\n // Remove all children from the container. Routed through the DOM adapter\n // (never `container.firstChild`/`removeChild`) so the teardown path is\n // server-safe.\n const dom = this._ctx.dom;\n const container = this._ctx.container;\n for (const child of dom.childNodes(container)) {\n dom.removeChild(container, child);\n }\n\n this._ctx.instances.clear();\n }\n}\n","/**\n * StreetUI Renderer — framework-owned DOM renderer.\n *\n * No React. No Vue. No virtual-dom. No external rendering library.\n *\n * Pipeline:\n * CompiledApplication\n * → mountGraph (creates all DOM nodes)\n * → signal subscriptions drive patchNode (targeted updates)\n * → flush() propagates any pending scheduler jobs\n * → unmount() disposes everything\n */\n\nimport type { DOMAdapter } from '@streetui/dom';\nimport { BrowserDOMAdapter } from '@streetui/dom';\nimport type { CompiledApplication } from '@streetui/compiler';\nimport type { StreetRenderer, RenderHandle } from '@streetui/runtime';\nimport { createRenderContext } from './render-context.js';\nimport { mountGraph } from './mount.js';\nimport { hydrateGraph } from './hydrate.js';\nimport { StreetRenderHandle } from './render-handle.js';\nimport type { NodeInstance } from './node-instance.js';\nimport type { HydrationDiagnosticSink } from './hydration-diagnostics.js';\n\nexport interface StreetRendererOptions {\n /** Override the DOM adapter (e.g. for testing). Defaults to BrowserDOMAdapter. */\n readonly domAdapter?: DOMAdapter;\n /**\n * Optional dev-only sink that observes hydration mismatch repairs. Attach one\n * to surface server/client divergences during development; leave it unset in\n * production so hydration does no extra work.\n */\n readonly hydrationDiagnostics?: HydrationDiagnosticSink;\n}\n\nexport class StreetRendererImpl implements StreetRenderer {\n private readonly _dom: DOMAdapter;\n private readonly _hydrationDiagnostics?: HydrationDiagnosticSink;\n\n constructor(options: StreetRendererOptions = {}) {\n this._dom = options.domAdapter ?? new BrowserDOMAdapter();\n if (options.hydrationDiagnostics !== undefined) {\n this._hydrationDiagnostics = options.hydrationDiagnostics;\n }\n }\n\n mount(compiled: CompiledApplication, container: Element): RenderHandle {\n const ctx = createRenderContext(this._dom, compiled.graph, container);\n\n // Initial mount — creates the full DOM tree\n const rootInstance = mountGraph(ctx);\n\n // Wire all signal subscriptions so that signal → DOM patches happen automatically\n this._wireSignals(ctx, rootInstance);\n\n return new StreetRenderHandle(ctx, rootInstance);\n }\n\n /**\n * Hydrate a container that already holds server-rendered HTML for this\n * application. Instead of recreating the DOM, it walks the semantic graph\n * against the existing nodes, adopting matching elements and attaching\n * behavior (events + signal subscriptions). Mismatched subtrees are locally\n * replaced. Returns the same handle type as `mount`.\n */\n hydrate(compiled: CompiledApplication, container: Element): RenderHandle {\n const ctx = createRenderContext(\n this._dom,\n compiled.graph,\n container,\n this._hydrationDiagnostics,\n );\n const rootInstance = hydrateGraph(ctx);\n this._wireSignals(ctx, rootInstance);\n return new StreetRenderHandle(ctx, rootInstance);\n }\n\n private _wireSignals(\n ctx: ReturnType<typeof createRenderContext>,\n rootInstance: NodeInstance,\n ): void {\n // Each NodeInstance already wired its own signals in mountNode via wireSignalBindings.\n // This method is a hook for any cross-cutting signal concerns at the renderer level.\n // Currently no-op — individual mount calls handle their own subscriptions.\n void ctx;\n void rootInstance;\n }\n}\n\n/**\n * Create the default StreetUI renderer using the browser's DOM APIs.\n */\nexport function createRenderer(options?: StreetRendererOptions): StreetRendererImpl {\n return new StreetRendererImpl(options);\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 * StreetUI Test Renderer.\n *\n * Renders a StreetApp into a real (happy-dom / jsdom) DOM container\n * and exposes query helpers so tests can assert on structure/content\n * without importing the browser renderer directly.\n */\n\nimport { resetIdCounter } from '@streetui/core';\nimport { compile } from '@streetui/compiler';\nimport type { StreetApp } from '@streetui/dsl';\nimport { BrowserDOMAdapter } from '@streetui/dom';\nimport { createRenderer } from '@streetui/renderer';\nimport type { RenderHandle } from '@streetui/runtime';\n\nexport interface RenderResult {\n /** The root container element that was rendered into. */\n readonly container: HTMLElement;\n /** Unmount and clean up the render. */\n unmount(): void;\n /** Query a single element (throws if missing). */\n getByTag<K extends keyof HTMLElementTagNameMap>(tag: K): HTMLElementTagNameMap[K];\n /** Query all elements by tag. */\n getAllByTag<K extends keyof HTMLElementTagNameMap>(tag: K): Array<HTMLElementTagNameMap[K]>;\n /** Query by text content (partial match). */\n getByText(text: string): Element;\n /** Query all elements whose text content includes the given string. */\n getAllByText(text: string): Element[];\n /** Raw querySelector. */\n query(selector: string): Element | null;\n /** Raw querySelectorAll. */\n queryAll(selector: string): Element[];\n /** Assert element exists; return it. */\n find(selector: string): Element;\n /** Force a flush of any pending scheduler work. */\n flush(): void;\n /** The underlying render handle. */\n readonly handle: RenderHandle;\n}\n\n/**\n * Render a StreetApp into a detached DOM container.\n * Uses the real StreetUI renderer backed by happy-dom/jsdom.\n */\nexport function render(app: StreetApp): RenderResult {\n const compiled = compile(app);\n const container = document.createElement('div');\n document.body.appendChild(container);\n\n const renderer = createRenderer({ domAdapter: new BrowserDOMAdapter() });\n const handle = renderer.mount(compiled, container);\n\n return {\n container,\n handle,\n unmount() {\n handle.unmount();\n if (container.parentNode !== null) {\n container.parentNode.removeChild(container);\n }\n },\n flush() {\n handle.flush();\n },\n getByTag<K extends keyof HTMLElementTagNameMap>(tag: K): HTMLElementTagNameMap[K] {\n const el = container.querySelector(tag);\n if (el === null) {\n throw new Error(`[StreetUI Testing] Element <${tag}> not found in render output`);\n }\n return el as HTMLElementTagNameMap[K];\n },\n getAllByTag<K extends keyof HTMLElementTagNameMap>(tag: K): Array<HTMLElementTagNameMap[K]> {\n return Array.from(container.querySelectorAll(tag)) as Array<HTMLElementTagNameMap[K]>;\n },\n getByText(text: string): Element {\n const all = Array.from(container.querySelectorAll('*'));\n const match = all.find(el =>\n el.children.length === 0 && el.textContent?.includes(text),\n );\n if (match === undefined) {\n throw new Error(`[StreetUI Testing] No element with text \"${text}\" found`);\n }\n return match;\n },\n getAllByText(text: string): Element[] {\n return Array.from(container.querySelectorAll('*')).filter(el =>\n el.textContent?.includes(text),\n );\n },\n query(selector: string): Element | null {\n return container.querySelector(selector);\n },\n queryAll(selector: string): Element[] {\n return Array.from(container.querySelectorAll(selector));\n },\n find(selector: string): Element {\n const el = container.querySelector(selector);\n if (el === null) {\n throw new Error(`[StreetUI Testing] Selector \"${selector}\" matched nothing`);\n }\n return el;\n },\n };\n}\n\n/** Render and automatically clean up after the test. */\nexport function renderOnce(\n app: StreetApp,\n testFn: (result: RenderResult) => void | Promise<void>,\n): Promise<void> {\n const result = render(app);\n return Promise.resolve(testFn(result)).finally(() => {\n result.unmount();\n resetIdCounter();\n });\n}\n","/**\n * StreetUI update scheduler.\n *\n * Responsibilities:\n * - Queue update callbacks\n * - Batch synchronous enqueues into a single microtask flush\n * - Guarantee ordering: higher priority jobs flush first\n * - Prevent duplicate work for the same job key\n * - Allow synchronous flush for tests\n */\n\nexport type Priority = 'immediate' | 'normal' | 'idle';\n\nconst PRIORITY_ORDER: Record<Priority, number> = {\n immediate: 0,\n normal: 1,\n idle: 2,\n};\n\nexport interface Job {\n /** Unique key — if another job with the same key is already queued, it is replaced. */\n readonly key: string;\n readonly priority: Priority;\n readonly fn: () => void;\n}\n\n/**\n * Optional error-reporting hook (v0.9 §26/§27). Structurally compatible with\n * `@streetui/core`'s `DiagnosticSink` (the `error` method) so an application can\n * route swallowed scheduler-job failures through its own logger instead of the\n * default `console.error`. Kept as a local structural type so the scheduler\n * stays dependency-free; no network, no telemetry. When unset, behaviour is\n * exactly as before.\n */\nexport interface SchedulerDiagnostics {\n error?(message: string, context?: unknown): void;\n}\n\nexport class Scheduler {\n private readonly _queue: Map<string, Job> = new Map();\n private _flushScheduled = false;\n private _flushing = false;\n private _diagnostics: SchedulerDiagnostics | undefined = undefined;\n\n /**\n * Install an optional diagnostic sink for swallowed job errors. Pass\n * `undefined` to restore the default `console.error` reporting. Additive and\n * opt-in — the scheduler never sends anything anywhere on its own.\n */\n setDiagnostics(sink: SchedulerDiagnostics | undefined): void {\n this._diagnostics = sink;\n }\n\n /** Total jobs currently queued. */\n get size(): number {\n return this._queue.size;\n }\n\n /** True if a flush has been scheduled but not yet executed. */\n get isPending(): boolean {\n return this._flushScheduled;\n }\n\n /**\n * Enqueue a job. If a job with the same key exists, the new one replaces it\n * (allowing callers to coalesce repeated updates for the same node).\n */\n schedule(job: Job): void {\n this._queue.set(job.key, job);\n if (!this._flushScheduled && !this._flushing) {\n this._flushScheduled = true;\n this._scheduleMicrotask();\n }\n }\n\n /** Schedule multiple jobs atomically. */\n scheduleAll(jobs: readonly Job[]): void {\n for (const job of jobs) {\n this._queue.set(job.key, job);\n }\n if (!this._flushScheduled && !this._flushing && this._queue.size > 0) {\n this._flushScheduled = true;\n this._scheduleMicrotask();\n }\n }\n\n /**\n * Cancel a queued job by key. No-op if not queued.\n */\n cancel(key: string): void {\n this._queue.delete(key);\n }\n\n /**\n * Synchronously flush all queued jobs (sorted by priority).\n * Useful in tests and for immediate rendering.\n */\n flush(): void {\n if (this._flushing) return;\n this._flushScheduled = false;\n this._flushing = true;\n\n const jobs = Array.from(this._queue.values()).sort(\n (a, b) => PRIORITY_ORDER[a.priority] - PRIORITY_ORDER[b.priority],\n );\n this._queue.clear();\n\n try {\n for (const job of jobs) {\n try {\n job.fn();\n } catch (err) {\n // Isolate job failures — report and continue so remaining jobs still run.\n if (this._diagnostics?.error) {\n this._diagnostics.error(`Scheduler job \"${job.key}\" threw`, err);\n } else {\n console.error(`[Scheduler] Job \"${job.key}\" threw:`, err);\n }\n }\n }\n } finally {\n this._flushing = false;\n }\n }\n\n /** Clear all pending jobs without executing them. */\n clear(): void {\n this._queue.clear();\n this._flushScheduled = false;\n }\n\n private _scheduleMicrotask(): void {\n Promise.resolve().then(() => {\n if (this._flushScheduled) {\n this.flush();\n }\n });\n }\n}\n\n/** The shared global scheduler instance. */\nexport const scheduler = new Scheduler();\n\n/** Convenience: schedule a normal-priority job. */\nexport function scheduleUpdate(key: string, fn: () => void): void {\n scheduler.schedule({ key, priority: 'normal', fn });\n}\n\n/** Convenience: schedule an immediate-priority job. */\nexport function scheduleImmediate(key: string, fn: () => void): void {\n scheduler.schedule({ key, priority: 'immediate', fn });\n}\n\n/** Convenience: flush the global scheduler synchronously. */\nexport function flushSync(): void {\n scheduler.flush();\n}\n","/**\n * Higher-level testing helpers: role/text queries, update flushing, async\n * waiting, and a first-class SSR → hydrate → assert workflow.\n *\n * These build on the same real renderer the app uses — no private-graph access,\n * no second assertion framework. They exist so a test does not have to\n * reimplement server-render/hydrate plumbing or poll for async resource state\n * by hand.\n */\n\nimport { resetIdCounter } from '@streetui/core';\nimport { flushSync } from '@streetui/scheduler';\nimport { compile } from '@streetui/compiler';\nimport type { StreetApp } from '@streetui/dsl';\nimport { BrowserDOMAdapter } from '@streetui/dom';\nimport {\n createRenderer,\n renderToString,\n type HydrationDiagnostic,\n createHydrationDiagnosticCollector,\n} from '@streetui/renderer';\nimport type { RenderHandle } from '@streetui/runtime';\n\n// ── Update flushing & async waiting ─────────────────────────────────────────\n\n/**\n * Flush all pending scheduler work, then yield once to the microtask queue so\n * promise-driven updates (e.g. a resolved `resource` loader) are applied. Await\n * this after triggering a change that schedules a DOM patch.\n */\nexport async function flushUpdates(): Promise<void> {\n flushSync();\n await Promise.resolve();\n flushSync();\n}\n\nexport interface WaitForOptions {\n /** Give up after this many milliseconds (default 1000). */\n readonly timeout?: number;\n /** Delay between attempts in milliseconds (default 10). */\n readonly interval?: number;\n}\n\n/**\n * Poll `check` until it returns a truthy value (or stops throwing), flushing\n * updates between attempts. Rejects with the last error/tiemout after the\n * deadline. Use for assertions that become true only after async work settles.\n */\nexport async function waitFor<T>(\n check: () => T,\n options: WaitForOptions = {},\n): Promise<T> {\n const timeout = options.timeout ?? 1000;\n const interval = options.interval ?? 10;\n const deadline = Date.now() + timeout;\n let lastError: unknown;\n\n for (;;) {\n await flushUpdates();\n try {\n const result = check();\n if (result) return result;\n lastError = new Error('[StreetUI Testing] waitFor: condition was falsy');\n } catch (err) {\n lastError = err;\n }\n if (Date.now() >= deadline) {\n throw lastError instanceof Error\n ? lastError\n : new Error(String(lastError));\n }\n await new Promise((resolve) => setTimeout(resolve, interval));\n }\n}\n\n// ── Text / role queries (container-scoped) ──────────────────────────────────\n\n/** Find the first leaf element whose text content includes `text`. */\nexport function findByText(container: Element, text: string): Element {\n const match = Array.from(container.querySelectorAll('*')).find(\n (el) => el.children.length === 0 && (el.textContent?.includes(text) ?? false),\n );\n if (match === undefined) {\n throw new Error(`[StreetUI Testing] No element with text \"${text}\" found`);\n }\n return match;\n}\n\nexport interface ByRoleOptions {\n /** Restrict to elements whose accessible name includes this string. */\n readonly name?: string;\n}\n\n/** The implicit ARIA role for a plain HTML element, when it has one. */\nfunction implicitRole(el: Element): string | null {\n const tag = el.tagName.toLowerCase();\n switch (tag) {\n case 'button':\n return 'button';\n case 'a':\n return el.hasAttribute('href') ? 'link' : null;\n case 'nav':\n return 'navigation';\n case 'h1':\n case 'h2':\n case 'h3':\n case 'h4':\n case 'h5':\n case 'h6':\n return 'heading';\n case 'input': {\n const type = (el.getAttribute('type') ?? 'text').toLowerCase();\n if (type === 'checkbox') return 'checkbox';\n if (type === 'radio') return 'radio';\n if (type === 'button' || type === 'submit') return 'button';\n return 'textbox';\n }\n case 'form':\n return 'form';\n default:\n return null;\n }\n}\n\n/** The accessible name approximation for an element (aria-label or text). */\nfunction accessibleName(el: Element): string {\n return (el.getAttribute('aria-label') ?? el.textContent ?? '').trim();\n}\n\n/**\n * Find all elements matching an ARIA `role` — explicit `role=\"…\"` first, then\n * the element's implicit role. Optionally filter by accessible name.\n */\nexport function findAllByRole(\n container: Element,\n role: string,\n options: ByRoleOptions = {},\n): Element[] {\n const all = Array.from(container.querySelectorAll('*'));\n return all.filter((el) => {\n const explicit = el.getAttribute('role');\n const matches = explicit === role || (explicit === null && implicitRole(el) === role);\n if (!matches) return false;\n if (options.name !== undefined) {\n return accessibleName(el).includes(options.name);\n }\n return true;\n });\n}\n\n/** Find the single element matching a role (throws if none/ambiguous). */\nexport function findByRole(\n container: Element,\n role: string,\n options: ByRoleOptions = {},\n): Element {\n const matches = findAllByRole(container, role, options);\n if (matches.length === 0) {\n const named = options.name !== undefined ? ` with name \"${options.name}\"` : '';\n throw new Error(`[StreetUI Testing] No element with role \"${role}\"${named} found`);\n }\n if (matches.length > 1) {\n throw new Error(\n `[StreetUI Testing] Found ${matches.length} elements with role \"${role}\" — refine with { name }`,\n );\n }\n return matches[0]!;\n}\n\n// ── First-class SSR → hydrate → assert workflow ─────────────────────────────\n\nexport interface HydrateTestOptions {\n /** Collect hydration mismatch diagnostics (dev-style) during hydration. */\n readonly collectDiagnostics?: boolean;\n}\n\nexport interface HydrateTestResult {\n /** The container holding the server HTML, now hydrated live. */\n readonly container: HTMLElement;\n /** The server-produced HTML string (before hydration). */\n readonly serverHtml: string;\n /** The live render handle from hydration. */\n readonly handle: RenderHandle;\n /** Hydration mismatch diagnostics (empty unless collectDiagnostics + a real mismatch). */\n readonly diagnostics: readonly HydrationDiagnostic[];\n /** Flush pending scheduler work. */\n flush(): void;\n /** Unmount and detach the container. */\n unmount(): void;\n}\n\n/**\n * Render `build` on the \"server\" to HTML, mount that HTML into a container,\n * then hydrate the SAME app against it — exactly the production SSR path. The\n * builder is invoked twice (server then client) with `resetIdCounter` between,\n * so deterministic ids line up. Assert node identity, behavior, and (optionally)\n * that hydration reported no mismatches.\n */\nexport function renderServerThenHydrate(\n build: () => StreetApp,\n options: HydrateTestOptions = {},\n): HydrateTestResult {\n resetIdCounter();\n const serverHtml = renderToString(compile(build()));\n\n const container = document.createElement('div');\n container.innerHTML = serverHtml;\n document.body.appendChild(container);\n\n const collector = options.collectDiagnostics === true\n ? createHydrationDiagnosticCollector()\n : undefined;\n\n resetIdCounter();\n const renderer = createRenderer({\n domAdapter: new BrowserDOMAdapter(),\n ...(collector !== undefined ? { hydrationDiagnostics: collector.sink } : {}),\n });\n const handle = renderer.hydrate(compile(build()), container);\n\n return {\n container,\n serverHtml,\n handle,\n diagnostics: collector?.diagnostics ?? [],\n flush() {\n handle.flush();\n },\n unmount() {\n handle.unmount();\n if (container.parentNode !== null) container.parentNode.removeChild(container);\n },\n };\n}\n","/**\n * Static graph analysis (v1.2, spec §3/§12/§14).\n *\n * A single post-order walk over the Semantic Application Graph that classifies\n * every node as static (no bound signals, no events, not a reactive\n * region) or dynamic, and rolls that up into whole-static-subtree flags. This\n * is COMPILE-TIME metadata only — it introduces no virtual DOM, no second tree\n * and no runtime reactive system. It is consumed by:\n * - the hydration path, to skip per-node attribute/text re-verification on\n * provably-static subtrees (§12), and\n * - the diagnostic compiler-inspection report (§14).\n *\n * The renderer's initial-mount fast path does not need this map: it already\n * skips reactive wiring per node via cheap `events.length`/`stateRefs.length`\n * guards. Keeping the analysis out of the mount hot path avoids adding lookup\n * cost (and keeps the shipped runtime lean).\n */\n\nimport type { NodeId } from '@streetui/core';\nimport type { ApplicationGraph, GraphNode } from '@streetui/graph';\n\n/** Prop keys whose bound signal drives text content rather than an attribute. */\nconst TEXT_PROP_KEYS: ReadonlySet<string> = new Set(['text', 'label', 'value']);\n\nexport interface NodeAnalysis {\n /** No bound signals, no events, and not a reactive-list/conditional region. */\n readonly isStatic: boolean;\n /** This node is static AND every descendant is a static subtree. */\n readonly isStaticSubtree: boolean;\n /** A signal is bound to this node's text/label/value content. */\n readonly hasDynamicText: boolean;\n /** A signal is bound to a non-content prop (a reactive attribute). */\n readonly hasDynamicAttr: boolean;\n /** This node wires one or more DOM event handlers. */\n readonly hasEvents: boolean;\n /** This node is a keyed reactive list. */\n readonly isList: boolean;\n /** This node is a conditional (0..1 branch) region. */\n readonly isConditional: boolean;\n}\n\nexport interface GraphAnalysisSummary {\n readonly totalNodes: number;\n readonly staticNodes: number;\n readonly staticSubtrees: number;\n readonly dynamicTextNodes: number;\n readonly dynamicAttrNodes: number;\n readonly eventNodes: number;\n readonly lists: number;\n readonly conditionals: number;\n}\n\nexport interface GraphAnalysis {\n readonly nodes: ReadonlyMap<NodeId, NodeAnalysis>;\n readonly summary: GraphAnalysisSummary;\n}\n\n/**\n * Analyze a fully-built graph. O(n) single post-order pass; allocates one small\n * record per node. Safe to skip entirely when neither hydration nor diagnostics\n * need it.\n */\nexport function analyzeGraph(graph: ApplicationGraph): GraphAnalysis {\n const nodes = new Map<NodeId, NodeAnalysis>();\n const summary = {\n totalNodes: 0, staticNodes: 0, staticSubtrees: 0, dynamicTextNodes: 0,\n dynamicAttrNodes: 0, eventNodes: 0, lists: 0, conditionals: 0,\n };\n\n const visit = (node: GraphNode): boolean => {\n // Post-order: children first so subtree rollup is exact.\n let allChildrenStatic = true;\n for (const child of node.children) {\n const childSubtreeStatic = visit(child);\n if (!childSubtreeStatic) allChildrenStatic = false;\n }\n\n let hasDynamicText = false;\n let hasDynamicAttr = false;\n for (const ref of node.stateRefs) {\n if (TEXT_PROP_KEYS.has(ref.propKey)) hasDynamicText = true;\n else hasDynamicAttr = true;\n }\n const hasEvents = node.events.length > 0;\n const isList = node.type === 'reactive-list';\n const isConditional = node.type === 'conditional';\n const isStatic =\n node.stateRefs.length === 0 && !hasEvents && !isList && !isConditional;\n const isStaticSubtree = isStatic && allChildrenStatic;\n\n nodes.set(node.id, {\n isStatic, isStaticSubtree, hasDynamicText, hasDynamicAttr,\n hasEvents, isList, isConditional,\n });\n\n summary.totalNodes += 1;\n if (isStatic) summary.staticNodes += 1;\n if (isStaticSubtree) summary.staticSubtrees += 1;\n if (hasDynamicText) summary.dynamicTextNodes += 1;\n if (hasDynamicAttr) summary.dynamicAttrNodes += 1;\n if (hasEvents) summary.eventNodes += 1;\n if (isList) summary.lists += 1;\n if (isConditional) summary.conditionals += 1;\n\n return isStaticSubtree;\n };\n\n visit(graph.root);\n return { nodes, summary };\n}\n","/**\n * Diagnostic compiler-inspection mode (v1.2, spec §14).\n *\n * Produces a machine-readable (and optionally text-formatted) description of\n * what the compiler understands about an application: which nodes are static\n * vs dynamic, which carry dynamic text or attributes, which wire events, and\n * which are conditional regions or keyed lists — plus the hydration metadata\n * derived from that classification.\n *\n * This is a DIAGNOSTIC tool. It is not part of the runtime, is not consulted\n * during mount, and is tree-shakeable out of any app that never calls it.\n */\n\nimport type { ApplicationGraph, GraphNode } from '@streetui/graph';\nimport { analyzeGraph, type GraphAnalysisSummary } from './analyze.js';\n\nexport interface InspectedCompilationNode {\n readonly id: string;\n readonly type: string;\n readonly depth: number;\n readonly classification: 'static' | 'static-subtree-root' | 'dynamic';\n readonly dynamicText: boolean;\n readonly dynamicAttrs: boolean;\n readonly events: readonly string[];\n readonly boundProps: readonly string[];\n readonly isList: boolean;\n readonly isConditional: boolean;\n /** Hydration hint: how the hydration path should treat this node. */\n readonly hydration: 'adopt-static' | 'verify-dynamic';\n}\n\nexport interface CompilerInspection {\n readonly name: string;\n readonly version: string;\n readonly summary: GraphAnalysisSummary & {\n /** Fraction of nodes provably static (0..1). */\n readonly staticRatio: number;\n };\n readonly nodes: readonly InspectedCompilationNode[];\n}\n\n/**\n * Inspect a compiled/built graph and return a structured diagnostic report.\n * Purely observational — never mutates the graph.\n */\nexport function inspectCompilation(graph: ApplicationGraph): CompilerInspection {\n const analysis = analyzeGraph(graph);\n const nodes: InspectedCompilationNode[] = [];\n\n const walk = (node: GraphNode, depth: number): void => {\n const a = analysis.nodes.get(node.id);\n if (a !== undefined) {\n const classification: InspectedCompilationNode['classification'] = a.isStaticSubtree\n ? 'static-subtree-root'\n : a.isStatic\n ? 'static'\n : 'dynamic';\n nodes.push({\n id: node.id,\n type: node.type,\n depth,\n classification,\n dynamicText: a.hasDynamicText,\n dynamicAttrs: a.hasDynamicAttr,\n events: node.events.map((e) => e.type),\n boundProps: node.stateRefs.map((r) => r.propKey),\n isList: a.isList,\n isConditional: a.isConditional,\n hydration: a.isStaticSubtree ? 'adopt-static' : 'verify-dynamic',\n });\n }\n for (const child of node.children) walk(child, depth + 1);\n };\n walk(graph.root, 0);\n\n const staticRatio =\n analysis.summary.totalNodes === 0\n ? 0\n : analysis.summary.staticNodes / analysis.summary.totalNodes;\n\n return {\n name: graph.name,\n version: graph.version,\n summary: { ...analysis.summary, staticRatio: +staticRatio.toFixed(4) },\n nodes,\n };\n}\n\n/** Render an inspection as a compact human-readable text report. */\nexport function formatInspection(inspection: CompilerInspection): string {\n const s = inspection.summary;\n const lines: string[] = [];\n lines.push(`StreetUI compiler inspection — ${inspection.name} v${inspection.version}`);\n lines.push(\n ` nodes=${s.totalNodes} static=${s.staticNodes} ` +\n `staticSubtrees=${s.staticSubtrees} dynamicText=${s.dynamicTextNodes} ` +\n `dynamicAttrs=${s.dynamicAttrNodes} events=${s.eventNodes} ` +\n `lists=${s.lists} conditionals=${s.conditionals} ` +\n `staticRatio=${(s.staticRatio * 100).toFixed(1)}%`,\n );\n for (const n of inspection.nodes) {\n const flags: string[] = [];\n if (n.dynamicText) flags.push('text');\n if (n.dynamicAttrs) flags.push('attr:' + n.boundProps.join(','));\n if (n.events.length > 0) flags.push('on:' + n.events.join(','));\n if (n.isList) flags.push('list');\n if (n.isConditional) flags.push('cond');\n lines.push(\n ` ${' '.repeat(n.depth)}${n.type}#${n.id} [${n.classification}]` +\n (flags.length > 0 ? ` {${flags.join(' ')}}` : ''),\n );\n }\n return lines.join('\\n');\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAI,WAAW;AAQR,SAAS,iBAAuB;AACrC,aAAW;AACb;;;ACqDO,IAAM,kBAAN,MAAsB;AAAA,EACV,OAA0B,CAAC;AAAA,EAE5C,IAAI,IAAsB;AACxB,SAAK,KAAK,KAAK,EAAE;AAAA,EACnB;AAAA,EAEA,MAAY;AACV,eAAW,MAAM,K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B,EAAE,gBAAgB,iBACpD,EAAE,gBAAgB,WAAW,EAAE,UAAU,UAChD,EAAE,KAAK,iBAAiB,EAAE,YAAY,iBAC/B,EAAE,cAAc,KAAK,QAAQ,CAAC,CAAC;EACnD;AACA,aAAW,KAAK,WAAW,OAAO;AAChC,UAAM,QAAkB,CAAC;AACzB,QAAI,EAAE,YAAa,OAAM,KAAK,MAAM;AACpC,QAAI,EAAE,aAAc,OAAM,KAAK,UAAU,EAAE,WAAW,KAAK,GAAG,CAAC;AAC/D,QAAI,EAAE,OAAO,SAAS,EAAG,OAAM,KAAK,QAAQ,EAAE,OAAO,KAAK,GAAG,CAAC;AAC9D,QAAI,EAAE,OAAQ,OAAM,KAAK,MAAM;AAC/B,QAAI,EAAE,cAAe,OAAM,KAAK,MAAM;AACtC,UAAM;MACJ,KAAK,KAAK,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE,KAAK,EAAE,cAAc,OAC5D,MAAM,SAAS,IAAI,KAAK,MAAM,KAAK,GAAG,CAAC,MAAM;IAClD;EACF;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;;;ACxGO,IAAM,UAAU;","names":["instance","el","tag"]}
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts","../../core/src/identity.ts","../../core/src/lifecycle.ts","../../core/src/diagnostics.ts","../../compiler/src/validation/validator.ts","../../compiler/src/transform/transform.ts","../../compiler/src/compile.ts","../../dom/src/browser-adapter.ts","../../dom/src/server-node.ts","../../dom/src/server-adapter.ts","../../renderer/src/render-context.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","../../renderer/src/hydration-diagnostics.ts","../../renderer/src/hydrate.ts","../../renderer/src/render-handle.ts","../../renderer/src/renderer.ts","../../renderer/src/ssr.ts","../../testing/src/test-renderer.ts","../../scheduler/src/scheduler.ts","../../testing/src/helpers.ts","../../compiler/src/analysis/analyze.ts","../../compiler/src/analysis/inspect.ts","../src/version.ts"],"sourcesContent":["/**\n * `streetui/testing` — testing utilities for StreetUI applications.\n *\n * A curated entry for the already-implemented testing helpers (render,\n * findByRole, waitFor, renderServerThenHydrate, …). It lives on its own subpath\n * so that test-only helpers stay out of the main runtime barrel — and so the\n * one cross-package name collision (`RenderResult`, shared with the CLI's render\n * types) is resolved cleanly: the testing `RenderResult` is reachable only from\n * here.\n *\n * ```ts\n * import { render, findByRole, waitFor } from 'streetui/testing';\n * ```\n */\nexport * from '@streetui/testing';\n\n// Opt-in compiler diagnostics (spec §14): static-graph analysis + inspection.\n// Exposed on the diagnostic subpath so they stay OUT of the runtime barrel\n// (`streetui`), keeping the shipped client bundle lean (§6/§7).\nexport * from '@streetui/compiler/diagnostics';\n\n// Re-export the framework version for parity with the main entry.\nexport { VERSION } from './version.js';\n","/**\n * Node and application identity utilities.\n * Every node in the semantic graph has a stable, unique identity.\n */\n\nlet _counter = 0;\n\n/** Generate a framework-internal monotonic integer ID. */\nexport function nextId(): number {\n return ++_counter;\n}\n\n/** Reset the counter (test use only). */\nexport function resetIdCounter(): void {\n _counter = 0;\n}\n\n/** Opaque branded type for node IDs. */\nexport type NodeId = string & { readonly __brand: 'NodeId' };\n\n/** Create a NodeId from a string (must be unique at call site). */\nexport function createNodeId(value: string): NodeId {\n return value as NodeId;\n}\n\n/** Generate a fresh, unique NodeId. */\nexport function generateNodeId(prefix: string = 'node'): NodeId {\n return createNodeId(`${prefix}:${nextId()}`);\n}\n\n/** Parse the prefix from a NodeId. */\nexport function nodeIdPrefix(id: NodeId): string {\n const colon = id.indexOf(':');\n return colon === -1 ? id : id.slice(0, colon);\n}\n\n/** Branded type for application IDs. */\nexport type ApplicationId = string & { readonly __brand: 'ApplicationId' };\n\n/** Generate a fresh application ID. */\nexport function generateApplicationId(name: string): ApplicationId {\n return `app:${name}:${nextId()}` as ApplicationId;\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 * Framework diagnostics — structured errors, warnings, and hints\n * that flow through the compiler, validator, and runtime.\n */\n\nexport type DiagnosticSeverity = 'error' | 'warning' | 'info';\n\nexport interface DiagnosticLocation {\n readonly file?: string;\n readonly line?: number;\n readonly column?: number;\n readonly nodeId?: string;\n}\n\nexport interface Diagnostic {\n readonly severity: DiagnosticSeverity;\n readonly code: string;\n readonly message: string;\n readonly location: DiagnosticLocation | undefined;\n readonly cause: unknown;\n}\n\nexport class DiagnosticError extends Error {\n readonly diagnostics: readonly Diagnostic[];\n\n constructor(diagnostics: readonly Diagnostic[]) {\n const summary = diagnostics\n .filter(d => d.severity === 'error')\n .map(d => `[${d.code}] ${d.message}`)\n .join('\\n');\n super(`StreetUI diagnostics:\\n${summary}`);\n this.name = 'DiagnosticError';\n this.diagnostics = diagnostics;\n }\n}\n\nexport class DiagnosticCollector {\n private readonly _diagnostics: Diagnostic[] = [];\n\n get diagnostics(): readonly Diagnostic[] {\n return this._diagnostics;\n }\n\n get hasErrors(): boolean {\n return this._diagnostics.some(d => d.severity === 'error');\n }\n\n get hasWarnings(): boolean {\n return this._diagnostics.some(d => d.severity === 'warning');\n }\n\n error(\n code: string,\n message: string,\n location?: DiagnosticLocation,\n cause?: unknown,\n ): void {\n this._diagnostics.push({ severity: 'error', code, message, location: location ?? undefined, cause: cause ?? undefined });\n }\n\n warn(\n code: string,\n message: string,\n location?: DiagnosticLocation,\n ): void {\n this._diagnostics.push({ severity: 'warning', code, message, location: location ?? undefined, cause: undefined });\n }\n\n info(\n code: string,\n message: string,\n location?: DiagnosticLocation,\n ): void {\n this._diagnostics.push({ severity: 'info', code, message, location: location ?? undefined, cause: undefined });\n }\n\n merge(other: DiagnosticCollector): void {\n for (const d of other.diagnostics) {\n this._diagnostics.push(d);\n }\n }\n\n throwIfErrors(): void {\n if (this.hasErrors) {\n throw new DiagnosticError(this._diagnostics);\n }\n }\n\n clear(): void {\n this._diagnostics.length = 0;\n }\n}\n\n/** Format a single diagnostic as a human-readable string. */\nexport function formatDiagnostic(d: Diagnostic): string {\n const loc = d.location !== undefined\n ? ` (${[d.location.file, d.location.line, d.location.column]\n .filter(Boolean)\n .join(':')})`\n : '';\n return `[${d.severity.toUpperCase()}] ${d.code}: ${d.message}${loc}`;\n}\n","/**\n * Compiler-phase validation of the ApplicationGraph.\n *\n * This runs after the DSL has built the graph but before the runtime\n * receives a CompiledApplication. More checks live here than in the\n * graph's own validate() because the compiler has broader context.\n */\n\nimport { DiagnosticCollector } from '@streetui/core';\nimport { ApplicationGraph, GraphNode } from '@streetui/graph';\n\nexport function validateGraph(graph: ApplicationGraph): DiagnosticCollector {\n const dc = new DiagnosticCollector();\n\n // Merge built-in graph validations\n dc.merge(graph.validate());\n\n // Must have at least one page\n const pages = graph.findByType('page');\n if (pages.length === 0) {\n dc.warn(\n 'COMPILER_NO_PAGES',\n 'Application has no pages defined. At least one page is recommended.',\n );\n }\n\n // Walk and validate individual nodes\n graph.walk((node) => {\n validateNode(node, dc);\n });\n\n return dc;\n}\n\nfunction validateNode(node: GraphNode, dc: DiagnosticCollector): void {\n switch (node.type) {\n case 'heading': {\n const text = node.getProp('text');\n if (text === undefined || text === '') {\n dc.warn('COMPILER_EMPTY_HEADING', `Heading node \"${node.id}\" has no text content`, {\n nodeId: node.id,\n });\n }\n break;\n }\n case 'image': {\n const src = node.getProp('src');\n const alt = node.getProp('alt');\n if (!src) {\n dc.error('COMPILER_IMAGE_NO_SRC', `Image node \"${node.id}\" is missing src`, {\n nodeId: node.id,\n });\n }\n if (!alt) {\n dc.warn('COMPILER_IMAGE_NO_ALT', `Image node \"${node.id}\" is missing alt text`, {\n nodeId: node.id,\n });\n }\n break;\n }\n case 'link': {\n const href = node.getProp('href');\n if (!href) {\n dc.error('COMPILER_LINK_NO_HREF', `Link node \"${node.id}\" is missing href`, {\n nodeId: node.id,\n });\n }\n break;\n }\n default:\n break;\n }\n}\n","/**\n * Graph transformation pass.\n *\n * After validation, the transformer prepares the graph for the runtime by:\n * - Resolving implicit defaults (e.g. heading level defaults to 1)\n * - Normalizing prop names\n * - Assigning deterministic render keys where missing\n * - Flattening / hoisting where beneficial\n */\n\nimport { ApplicationGraph, GraphNode } from '@streetui/graph';\n\nexport function transformGraph(graph: ApplicationGraph): void {\n graph.walk((node, depth) => {\n applyDefaults(node);\n ensureRenderKey(node, depth);\n });\n}\n\nfunction applyDefaults(node: GraphNode): void {\n switch (node.type) {\n case 'heading': {\n if (node.getProp('level') === undefined) {\n node.setProp('level', 1);\n }\n break;\n }\n case 'input': {\n if (node.getProp('inputType') === undefined) {\n node.setProp('inputType', 'text');\n }\n break;\n }\n case 'link': {\n if (node.getProp('external') === undefined) {\n node.setProp('external', false);\n }\n break;\n }\n default:\n break;\n }\n}\n\nfunction ensureRenderKey(node: GraphNode, depth: number): void {\n if (node.getProp('_renderKey') === undefined) {\n const key = node.key ?? `${node.type}:${node.id}:${depth}`;\n node.setProp('_renderKey', key);\n }\n}\n","/**\n * StreetUI compiler entry point.\n *\n * Pipeline:\n * StreetApp (DSL)\n * → ApplicationGraph (build)\n * → validate\n * → transform\n * → CompiledApplication\n */\n\nimport { DiagnosticCollector } from '@streetui/core';\nimport { type ApplicationGraph } from '@streetui/graph';\nimport { type StreetApp } from '@streetui/dsl';\nimport { validateGraph } from './validation/validator.js';\nimport { transformGraph } from './transform/transform.js';\n\nexport interface CompiledApplication {\n /** The fully built, validated, and transformed graph. */\n readonly graph: ApplicationGraph;\n /** Diagnostics accumulated during compilation. */\n readonly diagnostics: DiagnosticCollector;\n /** Metadata */\n readonly name: string;\n readonly version: string;\n readonly compiledAt: number;\n}\n\nexport interface CompileOptions {\n /** If true, compilation throws on errors. Defaults to true. */\n readonly strict?: boolean;\n /** If true, also throw on warnings. Defaults to false. */\n readonly strictWarnings?: boolean;\n}\n\n/**\n * Compile a StreetApp DSL definition into a CompiledApplication\n * ready for the runtime to execute.\n */\nexport function compile(\n app: StreetApp,\n options: CompileOptions = {},\n): CompiledApplication {\n const strict = options.strict ?? true;\n const strictWarnings = options.strictWarnings ?? false;\n const dc = new DiagnosticCollector();\n\n // 1. Build the graph from the DSL\n const graph = app.graph;\n\n // 2. Validate\n const validationDc = validateGraph(graph);\n dc.merge(validationDc);\n\n if (strict && dc.hasErrors) {\n dc.throwIfErrors();\n }\n if (strictWarnings && dc.hasWarnings) {\n throw new Error(\n `[StreetUI Compiler] Compilation failed: warnings treated as errors.\\n` +\n dc.diagnostics\n .filter(d => d.severity === 'warning')\n .map(d => ` [${d.code}] ${d.message}`)\n .join('\\n'),\n );\n }\n\n // 3. Transform\n transformGraph(graph);\n\n return {\n graph,\n diagnostics: dc,\n name: graph.name,\n version: graph.version,\n compiledAt: Date.now(),\n };\n}\n\n/**\n * Compile from a pre-built ApplicationGraph (used when the graph\n * was constructed programmatically rather than through the DSL).\n */\nexport function compileGraph(\n graph: ApplicationGraph,\n options: CompileOptions = {},\n): CompiledApplication {\n const strict = options.strict ?? true;\n const dc = new DiagnosticCollector();\n\n const validationDc = validateGraph(graph);\n dc.merge(validationDc);\n\n if (strict && dc.hasErrors) {\n dc.throwIfErrors();\n }\n\n transformGraph(graph);\n\n return {\n graph,\n diagnostics: dc,\n name: graph.name,\n version: graph.version,\n compiledAt: Date.now(),\n };\n}\n","/**\n * Browser implementation of DOMAdapter — delegates directly to browser APIs.\n */\n\nimport type { DOMAdapter } from './adapter.js';\n\nexport class BrowserDOMAdapter implements DOMAdapter {\n createElement(tag: string, ns?: string): Element {\n if (ns !== undefined) {\n return document.createElementNS(ns, tag);\n }\n return document.createElement(tag);\n }\n\n createTextNode(data: string): Text {\n return document.createTextNode(data);\n }\n\n createComment(data: string): Comment {\n return document.createComment(data);\n }\n\n createFragment(): DocumentFragment {\n return document.createDocumentFragment();\n }\n\n appendChild(parent: Node, child: Node): void {\n parent.appendChild(child);\n }\n\n insertBefore(parent: Node, child: Node, reference: Node | null): void {\n parent.insertBefore(child, reference);\n }\n\n removeChild(parent: Node, child: Node): void {\n parent.removeChild(child);\n }\n\n replaceChild(parent: Node, newChild: Node, oldChild: Node): void {\n parent.replaceChild(newChild, oldChild);\n }\n\n setAttribute(element: Element, name: string, value: string): void {\n element.setAttribute(name, value);\n }\n\n removeAttribute(element: Element, name: string): void {\n element.removeAttribute(name);\n }\n\n getAttribute(element: Element, name: string): string | null {\n return element.getAttribute(name);\n }\n\n setProperty(element: Element, name: string, value: unknown): void {\n (element as unknown as Record<string, unknown>)[name] = value;\n }\n\n setTextContent(node: Node, text: string): void {\n node.textContent = text;\n }\n\n getTextContent(node: Node): string | null {\n return node.textContent;\n }\n\n addEventListener(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions,\n ): void {\n target.addEventListener(type, handler, options);\n }\n\n removeEventListener(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: EventListenerOptions,\n ): void {\n target.removeEventListener(type, handler, options);\n }\n\n querySelector(root: Element | Document, selector: string): Element | null {\n return root.querySelector(selector);\n }\n\n querySelectorAll(root: Element | Document, selector: string): NodeListOf<Element> {\n return root.querySelectorAll(selector);\n }\n\n getElementById(id: string): Element | null {\n return document.getElementById(id);\n }\n\n focus(element: Element): void {\n (element as unknown as { focus?: () => void }).focus?.();\n }\n\n isElement(node: Node): node is Element {\n return node.nodeType === Node.ELEMENT_NODE;\n }\n\n isTextNode(node: Node): node is Text {\n return node.nodeType === Node.TEXT_NODE;\n }\n\n tagName(element: Element): string {\n return element.tagName.toLowerCase();\n }\n\n parentNode(node: Node): Node | null {\n return node.parentNode;\n }\n\n nextSibling(node: Node): Node | null {\n return node.nextSibling;\n }\n\n firstChild(node: Node): Node | null {\n return node.firstChild;\n }\n\n childNodes(node: Node): Node[] {\n return Array.from(node.childNodes);\n }\n}\n\nexport const browserDOMAdapter = new BrowserDOMAdapter();\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, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n}\n\n/** Escape a double-quoted attribute value. */\nexport function escapeHtmlAttr(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\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 * 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 * 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 * Hydration diagnostics — dev-only, opt-in explanations of hydration mismatches.\n *\n * Hydration is self-repairing: when the server-rendered DOM does not match the\n * graph at a position, the renderer mounts a fresh subtree in place and drops\n * the offending element (see `hydrateChildren` in `hydrate.ts`). That recovery\n * is silent by design — a local mismatch must never tear down the whole app.\n *\n * During development, though, a silent repair hides a real problem (usually a\n * server/client divergence). A `HydrationDiagnosticSink` can be attached to the\n * renderer to *observe* those repairs without changing them: for every mismatch\n * the renderer reports what it expected, what it found, where, and what it did\n * to recover. Nothing is thrown, nothing is mutated differently, and when no\n * sink is attached there is zero additional work on the hydration path.\n */\n\n/** What kind of divergence the hydrator encountered at a position. */\nexport type HydrationMismatchType =\n | 'tag-mismatch' // an element existed but was the wrong tag\n | 'missing-element' // the graph expected a child the DOM did not provide\n | 'surplus-element'; // the DOM had a child the graph no longer expects\n\n/** A single, fully-described hydration divergence and the repair taken. */\nexport interface HydrationDiagnostic {\n /** The category of mismatch. */\n readonly type: HydrationMismatchType;\n /** The tag the graph expected at this position (null for a surplus element). */\n readonly expected: string | null;\n /** The tag actually found in the server DOM (null for a missing element). */\n readonly found: string | null;\n /** A human-readable path to the position, e.g. `app / page[0] / section[1]`. */\n readonly path: string;\n /** The graph node id involved, when one exists (null for surplus DOM). */\n readonly nodeId: string | null;\n /** The semantic node type involved, when one exists (null for surplus DOM). */\n readonly nodeType: string | null;\n /** The recovery action the renderer performed. */\n readonly action: string;\n /** A single-line, developer-facing summary of the whole diagnostic. */\n readonly message: string;\n}\n\n/**\n * Receives hydration diagnostics as they are discovered. Kept intentionally\n * tiny so any logger — `console`, a test collector, a `DiagnosticSink` — can\n * satisfy it. Implementations must not throw.\n */\nexport interface HydrationDiagnosticSink {\n report(diagnostic: HydrationDiagnostic): void;\n}\n\n/** Build the canonical one-line message for a diagnostic. */\nexport function formatHydrationDiagnostic(\n d: Omit<HydrationDiagnostic, 'message'>,\n): string {\n const at = ` at ${d.path}`;\n switch (d.type) {\n case 'tag-mismatch':\n return `Hydration mismatch${at} — Expected: ${d.expected} / Found: ${d.found} / Action: ${d.action}`;\n case 'missing-element':\n return `Hydration mismatch${at} — Expected: ${d.expected} / Found: (nothing) / Action: ${d.action}`;\n case 'surplus-element':\n return `Hydration mismatch${at} — Expected: (nothing) / Found: ${d.found} / Action: ${d.action}`;\n }\n}\n\n/**\n * A ready-made sink that accumulates diagnostics into an array — the shape most\n * useful for tests and for a DevTools panel. The returned `diagnostics` array is\n * appended to in-place as repairs happen.\n */\nexport function createHydrationDiagnosticCollector(): {\n readonly sink: HydrationDiagnosticSink;\n readonly diagnostics: HydrationDiagnostic[];\n} {\n const diagnostics: HydrationDiagnostic[] = [];\n return {\n diagnostics,\n sink: {\n report(d) {\n diagnostics.push(d);\n },\n },\n };\n}\n\n/**\n * A sink that forwards each diagnostic to a `console`-like logger as a single\n * warning line. Handy default when you just want the messages surfaced in dev.\n */\nexport function consoleHydrationDiagnosticSink(\n logger: { warn(message: string): void } = console,\n): HydrationDiagnosticSink {\n return {\n report(d) {\n logger.warn(d.message);\n },\n };\n}\n","/**\n * Hydration — attach a live StreetUI runtime to server-rendered HTML.\n *\n * `hydrate` walks the semantic application graph top-down against the DOM that\n * the server already produced. For every graph node it *adopts* the matching\n * existing element (creating a `NodeInstance` that points at it) and attaches\n * behavior — event listeners and signal subscriptions — using the exact same\n * helpers the browser mount path uses (`wireEvents`, `wireSignalBindings`,\n * `wireReactiveList`, and the per-type update factories). Nothing is recreated\n * when the DOM matches.\n *\n * Matching is positional and works because every non-application graph node\n * maps to exactly one element (see mount.ts). When the element at a position\n * does not match the expected tag (or is missing), only that subtree is\n * repaired: the fresh subtree is mounted and spliced into place, leaving the\n * rest of the hydrated tree untouched. A local mismatch never tears down the\n * whole app.\n */\n\nimport type { GraphNode } from '@streetui/graph';\nimport type { RenderContext } from './render-context.js';\nimport { NodeInstance } from './node-instance.js';\nimport { wireEvents } from './events.js';\nimport { resolveTag } from './tag-map.js';\nimport { formatHydrationDiagnostic } from './hydration-diagnostics.js';\nimport {\n mountNode,\n wireSignalBindings,\n wireReactiveList,\n textUpdate,\n headingUpdate,\n inputUpdate,\n buttonUpdate,\n} from './mount.js';\n\n/** Hydrate the whole application graph against `ctx.container`. */\nexport function hydrateGraph(ctx: RenderContext): NodeInstance {\n const root = ctx.graph.root;\n // The application root maps to the container itself (no element of its own),\n // exactly as in mountNode.\n const instance = new NodeInstance(root, ctx.container);\n ctx.instances.set(root.id, instance);\n hydrateChildren(ctx, root, instance, ctx.container, 'app');\n return instance;\n}\n\n/**\n * Adopt `domNode` as the live element for `graphNode` and attach behavior.\n * The caller has already verified `domNode` matches `graphNode` (right tag).\n * `path` is the human-readable position used only for dev diagnostics.\n */\nfunction hydrateNode(\n ctx: RenderContext,\n graphNode: GraphNode,\n domNode: Element,\n path: string,\n): NodeInstance {\n const { dom, graph } = ctx;\n\n switch (graphNode.type) {\n case 'text': {\n // <span> with an inner text node. Adopt the text node (or create one if\n // the server markup somehow lacks it).\n let textNode = dom.firstChild(domNode);\n if (textNode === null || !dom.isTextNode(textNode)) {\n const created = dom.createTextNode(String(graphNode.getProp('text') ?? ''));\n dom.appendChild(domNode, created);\n textNode = created;\n }\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, domNode, instance);\n // Only build the per-type update closure when the node actually has\n // reactive bindings. wireSignalBindings early-returns on an empty\n // stateRefs list, so for a static node the `textUpdate(...)` closure would\n // be allocated and immediately discarded — pure GC pressure on the hot\n // hydration path, where the vast majority of nodes are static.\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, textUpdate(dom, domNode, textNode as Text));\n }\n return instance;\n }\n\n case 'heading': {\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, domNode, instance);\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, headingUpdate(dom, domNode));\n }\n return instance;\n }\n\n case 'input': {\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n // The controlled value is already present in the server HTML (reflected as\n // the `value` attribute). Re-assert it as a live property so the element's\n // current value matches the bound signal exactly.\n const value = graphNode.getProp('value');\n if (value !== undefined) dom.setProperty(domNode, 'value', String(value));\n wireEvents(dom, graph, graphNode, domNode, instance);\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, inputUpdate(dom, domNode));\n }\n return instance;\n }\n\n case 'button': {\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n wireEvents(dom, graph, graphNode, domNode, instance);\n if (graphNode.stateRefs.length !== 0) {\n wireSignalBindings(ctx, graphNode, instance, buttonUpdate(dom, domNode));\n }\n return instance;\n }\n\n case 'image':\n case 'link': {\n // Leaf elements with no reactive bindings or events beyond what the markup\n // already encodes; links may still carry click handlers.\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n if (graphNode.type === 'link') wireEvents(dom, graph, graphNode, domNode, instance);\n return instance;\n }\n\n case 'reactive-list':\n case 'conditional': {\n // The server rendered the initial children (built into the graph at\n // compile time from the initial signal state). Adopt them positionally,\n // then subscribe for future signal changes — the same keyed reconciler as\n // the browser drives subsequent updates against the adopted instances.\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n hydrateChildren(ctx, graphNode, instance, domNode, path);\n wireReactiveList(ctx, graphNode, instance, domNode);\n return instance;\n }\n\n default: {\n // Structural nodes: container / section / page / form / list / list-item.\n const instance = new NodeInstance(graphNode, domNode);\n ctx.instances.set(graphNode.id, instance);\n if (graphNode.type === 'form') {\n wireEvents(dom, graph, graphNode, domNode, instance);\n }\n // Hydration boundary (a \"slot\" such as the router outlet): adopt the\n // element itself but leave its existing children untouched — neither\n // hydrated by this pass nor removed as surplus. Something else (e.g. the\n // router) owns and will hydrate the content already inside it. Without\n // this, an empty-in-the-graph slot would strip the server-rendered\n // content it is meant to preserve.\n if (graphNode.getProp('_hydrationBoundary') === true) {\n return instance;\n }\n hydrateChildren(ctx, graphNode, instance, domNode, path);\n return instance;\n }\n }\n}\n\n// ── Child matching + local mismatch recovery ───────────────────────────────────\n\n/**\n * Positionally match a parent's expected child graph nodes against the actual\n * child *elements* in the DOM. Matching children are hydrated in place; a\n * mismatch (wrong tag or a missing element) triggers a local repair — the fresh\n * subtree is mounted and spliced into the correct position — without disturbing\n * sibling subtrees. Surplus DOM elements are removed.\n */\nfunction hydrateChildren(\n ctx: RenderContext,\n parentGraphNode: GraphNode,\n parentInstance: NodeInstance,\n parentDom: Element,\n parentPath: string,\n): void {\n const expected = parentGraphNode.children;\n const actual = elementChildren(ctx, parentDom);\n let cursor = 0;\n\n // The human-readable `path` is only ever consumed by hydration diagnostics,\n // which are inert unless a sink is attached. Building the\n // `${parentPath} / ${type}[${i}]` string for every child would allocate one\n // throwaway string per node on the hot path (10k+ on a large tree) for output\n // that is discarded in production. Gate the construction on the sink being\n // present; when it is absent, thread the (meaningless-but-unused) parent path\n // through unchanged so nested calls stay allocation-free too.\n const diag = ctx.hydrationDiagnostics !== undefined;\n\n for (let i = 0; i < expected.length; i++) {\n const childNode = expected[i]!;\n const want = expectedTag(ctx, childNode);\n const childPath = diag ? `${parentPath} / ${childNode.type}[${i}]` : parentPath;\n const actualEl = actual[cursor];\n\n if (\n actualEl !== undefined &&\n ctx.dom.isElement(actualEl) &&\n ctx.dom.tagName(actualEl) === want\n ) {\n // Match — adopt the existing element.\n const inst = hydrateNode(ctx, childNode, actualEl, childPath);\n parentInstance.addChild(inst);\n cursor++;\n } else {\n // Mismatch or missing — repair only this subtree. Mount fresh, then move\n // it into the correct position ahead of the offending/absent node.\n const ref = actualEl ?? null;\n const inst = mountFreshAt(ctx, childNode, parentDom, ref);\n parentInstance.addChild(inst);\n if (actualEl !== undefined) {\n // Drop the mismatched element that the fresh node replaces.\n const found = ctx.dom.isElement(actualEl) ? ctx.dom.tagName(actualEl) : null;\n reportHydrationDiagnostic(ctx, {\n type: 'tag-mismatch',\n expected: want,\n found,\n path: childPath,\n nodeId: childNode.id,\n nodeType: childNode.type,\n action: 'mounted fresh subtree in place',\n });\n ctx.dom.removeChild(parentDom, actualEl);\n cursor++;\n } else {\n reportHydrationDiagnostic(ctx, {\n type: 'missing-element',\n expected: want,\n found: null,\n path: childPath,\n nodeId: childNode.id,\n nodeType: childNode.type,\n action: 'mounted fresh subtree',\n });\n }\n }\n }\n\n // Remove any surplus server elements the graph no longer expects.\n for (let i = cursor; i < actual.length; i++) {\n const surplus = actual[i]!;\n reportHydrationDiagnostic(ctx, {\n type: 'surplus-element',\n expected: null,\n found: ctx.dom.isElement(surplus) ? ctx.dom.tagName(surplus) : null,\n path: `${parentPath} / [surplus ${i}]`,\n nodeId: null,\n nodeType: null,\n action: 'removed surplus server element',\n });\n ctx.dom.removeChild(parentDom, surplus);\n }\n}\n\n/**\n * Emit a hydration diagnostic through the (optional) sink. When no sink is\n * attached this is a single cheap `undefined` check — the production default.\n */\nfunction reportHydrationDiagnostic(\n ctx: RenderContext,\n d: {\n type: 'tag-mismatch' | 'missing-element' | 'surplus-element';\n expected: string | null;\n found: string | null;\n path: string;\n nodeId: string | null;\n nodeType: string | null;\n action: string;\n },\n): void {\n const sink = ctx.hydrationDiagnostics;\n if (sink === undefined) return;\n sink.report({ ...d, message: formatHydrationDiagnostic(d) });\n}\n\n/** Mount a fresh subtree for `node` and splice it before `ref` (or append). */\nfunction mountFreshAt(\n ctx: RenderContext,\n node: GraphNode,\n parentDom: Element,\n ref: Node | null,\n): NodeInstance {\n // mountNode appends the new subtree at the end of parentDom.\n const inst = mountNode(ctx, node, parentDom);\n if (ref !== null) {\n ctx.dom.insertBefore(parentDom, inst.domNode, ref);\n }\n return inst;\n}\n\n/** The element (not text/comment) children of a node, in order. */\nfunction elementChildren(ctx: RenderContext, parent: Element): Element[] {\n const out: Element[] = [];\n for (const node of ctx.dom.childNodes(parent)) {\n if (ctx.dom.isElement(node)) out.push(node);\n }\n return out;\n}\n\n/** The HTML tag a graph node is expected to occupy in the DOM. */\nfunction expectedTag(ctx: RenderContext, graphNode: GraphNode): string {\n switch (graphNode.type) {\n case 'text':\n return 'span';\n case 'heading': {\n const level = (graphNode.getProp('level') as number | undefined) ?? 1;\n return `h${level}`;\n }\n case 'input':\n return 'input';\n case 'image':\n return 'img';\n case 'link':\n return 'a';\n case 'button':\n return 'button';\n default:\n // reactive-list → ul, conditional → div, structural → resolveTag.\n return resolveTag(graphNode.type);\n }\n}\n","/**\n * StreetRenderHandle — the live handle returned by both `mount` and `hydrate`.\n *\n * Owns teardown for a mounted/hydrated application: disposes every NodeInstance\n * (removing event listeners and signal subscriptions) and clears the container\n * through the DOM adapter (never raw browser globals), so the same handle works\n * for browser and — in principle — server-driven teardown.\n */\n\nimport type { RenderHandle } from '@streetui/runtime';\nimport type { RenderContext } from './render-context.js';\nimport type { NodeInstance } from './node-instance.js';\n\nexport class StreetRenderHandle implements RenderHandle {\n private _disposed = false;\n private readonly _ctx: RenderContext;\n private readonly _rootInstance: NodeInstance;\n\n constructor(ctx: RenderContext, rootInstance: NodeInstance) {\n this._ctx = ctx;\n this._rootInstance = rootInstance;\n }\n\n flush(): void {\n if (this._disposed) return;\n // Signal subscriptions fire synchronously in StreetUI's state system;\n // flush() is a no-op at the renderer level — the DOM is already up to date\n // unless the scheduler is batching, in which case the scheduler calls\n // flush() after draining its queue.\n }\n\n unmount(): void {\n if (this._disposed) return;\n this._disposed = true;\n\n // Dispose all node instances (removes event listeners, signal subscriptions).\n this._rootInstance.dispose();\n\n // Remove all children from the container. Routed through the DOM adapter\n // (never `container.firstChild`/`removeChild`) so the teardown path is\n // server-safe.\n const dom = this._ctx.dom;\n const container = this._ctx.container;\n for (const child of dom.childNodes(container)) {\n dom.removeChild(container, child);\n }\n\n this._ctx.instances.clear();\n }\n}\n","/**\n * StreetUI Renderer — framework-owned DOM renderer.\n *\n * No React. No Vue. No virtual-dom. No external rendering library.\n *\n * Pipeline:\n * CompiledApplication\n * → mountGraph (creates all DOM nodes)\n * → signal subscriptions drive patchNode (targeted updates)\n * → flush() propagates any pending scheduler jobs\n * → unmount() disposes everything\n */\n\nimport type { DOMAdapter } from '@streetui/dom';\nimport { BrowserDOMAdapter } from '@streetui/dom';\nimport type { CompiledApplication } from '@streetui/compiler';\nimport type { StreetRenderer, RenderHandle } from '@streetui/runtime';\nimport { createRenderContext } from './render-context.js';\nimport { mountGraph } from './mount.js';\nimport { hydrateGraph } from './hydrate.js';\nimport { StreetRenderHandle } from './render-handle.js';\nimport type { NodeInstance } from './node-instance.js';\nimport type { HydrationDiagnosticSink } from './hydration-diagnostics.js';\n\nexport interface StreetRendererOptions {\n /** Override the DOM adapter (e.g. for testing). Defaults to BrowserDOMAdapter. */\n readonly domAdapter?: DOMAdapter;\n /**\n * Optional dev-only sink that observes hydration mismatch repairs. Attach one\n * to surface server/client divergences during development; leave it unset in\n * production so hydration does no extra work.\n */\n readonly hydrationDiagnostics?: HydrationDiagnosticSink;\n}\n\nexport class StreetRendererImpl implements StreetRenderer {\n private readonly _dom: DOMAdapter;\n private readonly _hydrationDiagnostics?: HydrationDiagnosticSink;\n\n constructor(options: StreetRendererOptions = {}) {\n this._dom = options.domAdapter ?? new BrowserDOMAdapter();\n if (options.hydrationDiagnostics !== undefined) {\n this._hydrationDiagnostics = options.hydrationDiagnostics;\n }\n }\n\n mount(compiled: CompiledApplication, container: Element): RenderHandle {\n const ctx = createRenderContext(this._dom, compiled.graph, container);\n\n // Initial mount — creates the full DOM tree\n const rootInstance = mountGraph(ctx);\n\n // Wire all signal subscriptions so that signal → DOM patches happen automatically\n this._wireSignals(ctx, rootInstance);\n\n return new StreetRenderHandle(ctx, rootInstance);\n }\n\n /**\n * Hydrate a container that already holds server-rendered HTML for this\n * application. Instead of recreating the DOM, it walks the semantic graph\n * against the existing nodes, adopting matching elements and attaching\n * behavior (events + signal subscriptions). Mismatched subtrees are locally\n * replaced. Returns the same handle type as `mount`.\n */\n hydrate(compiled: CompiledApplication, container: Element): RenderHandle {\n const ctx = createRenderContext(\n this._dom,\n compiled.graph,\n container,\n this._hydrationDiagnostics,\n );\n const rootInstance = hydrateGraph(ctx);\n this._wireSignals(ctx, rootInstance);\n return new StreetRenderHandle(ctx, rootInstance);\n }\n\n private _wireSignals(\n ctx: ReturnType<typeof createRenderContext>,\n rootInstance: NodeInstance,\n ): void {\n // Each NodeInstance already wired its own signals in mountNode via wireSignalBindings.\n // This method is a hook for any cross-cutting signal concerns at the renderer level.\n // Currently no-op — individual mount calls handle their own subscriptions.\n void ctx;\n void rootInstance;\n }\n}\n\n/**\n * Create the default StreetUI renderer using the browser's DOM APIs.\n */\nexport function createRenderer(options?: StreetRendererOptions): StreetRendererImpl {\n return new StreetRendererImpl(options);\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 * StreetUI Test Renderer.\n *\n * Renders a StreetApp into a real (happy-dom / jsdom) DOM container\n * and exposes query helpers so tests can assert on structure/content\n * without importing the browser renderer directly.\n */\n\nimport { resetIdCounter } from '@streetui/core';\nimport { compile } from '@streetui/compiler';\nimport type { StreetApp } from '@streetui/dsl';\nimport { BrowserDOMAdapter } from '@streetui/dom';\nimport { createRenderer } from '@streetui/renderer';\nimport type { RenderHandle } from '@streetui/runtime';\n\nexport interface RenderResult {\n /** The root container element that was rendered into. */\n readonly container: HTMLElement;\n /** Unmount and clean up the render. */\n unmount(): void;\n /** Query a single element (throws if missing). */\n getByTag<K extends keyof HTMLElementTagNameMap>(tag: K): HTMLElementTagNameMap[K];\n /** Query all elements by tag. */\n getAllByTag<K extends keyof HTMLElementTagNameMap>(tag: K): Array<HTMLElementTagNameMap[K]>;\n /** Query by text content (partial match). */\n getByText(text: string): Element;\n /** Query all elements whose text content includes the given string. */\n getAllByText(text: string): Element[];\n /** Raw querySelector. */\n query(selector: string): Element | null;\n /** Raw querySelectorAll. */\n queryAll(selector: string): Element[];\n /** Assert element exists; return it. */\n find(selector: string): Element;\n /** Force a flush of any pending scheduler work. */\n flush(): void;\n /** The underlying render handle. */\n readonly handle: RenderHandle;\n}\n\n/**\n * Render a StreetApp into a detached DOM container.\n * Uses the real StreetUI renderer backed by happy-dom/jsdom.\n */\nexport function render(app: StreetApp): RenderResult {\n const compiled = compile(app);\n const container = document.createElement('div');\n document.body.appendChild(container);\n\n const renderer = createRenderer({ domAdapter: new BrowserDOMAdapter() });\n const handle = renderer.mount(compiled, container);\n\n return {\n container,\n handle,\n unmount() {\n handle.unmount();\n if (container.parentNode !== null) {\n container.parentNode.removeChild(container);\n }\n },\n flush() {\n handle.flush();\n },\n getByTag<K extends keyof HTMLElementTagNameMap>(tag: K): HTMLElementTagNameMap[K] {\n const el = container.querySelector(tag);\n if (el === null) {\n throw new Error(`[StreetUI Testing] Element <${tag}> not found in render output`);\n }\n return el as HTMLElementTagNameMap[K];\n },\n getAllByTag<K extends keyof HTMLElementTagNameMap>(tag: K): Array<HTMLElementTagNameMap[K]> {\n return Array.from(container.querySelectorAll(tag)) as Array<HTMLElementTagNameMap[K]>;\n },\n getByText(text: string): Element {\n const all = Array.from(container.querySelectorAll('*'));\n const match = all.find(el =>\n el.children.length === 0 && el.textContent?.includes(text),\n );\n if (match === undefined) {\n throw new Error(`[StreetUI Testing] No element with text \"${text}\" found`);\n }\n return match;\n },\n getAllByText(text: string): Element[] {\n return Array.from(container.querySelectorAll('*')).filter(el =>\n el.textContent?.includes(text),\n );\n },\n query(selector: string): Element | null {\n return container.querySelector(selector);\n },\n queryAll(selector: string): Element[] {\n return Array.from(container.querySelectorAll(selector));\n },\n find(selector: string): Element {\n const el = container.querySelector(selector);\n if (el === null) {\n throw new Error(`[StreetUI Testing] Selector \"${selector}\" matched nothing`);\n }\n return el;\n },\n };\n}\n\n/** Render and automatically clean up after the test. */\nexport function renderOnce(\n app: StreetApp,\n testFn: (result: RenderResult) => void | Promise<void>,\n): Promise<void> {\n const result = render(app);\n return Promise.resolve(testFn(result)).finally(() => {\n result.unmount();\n resetIdCounter();\n });\n}\n","/**\n * StreetUI update scheduler.\n *\n * Responsibilities:\n * - Queue update callbacks\n * - Batch synchronous enqueues into a single microtask flush\n * - Guarantee ordering: higher priority jobs flush first\n * - Prevent duplicate work for the same job key\n * - Allow synchronous flush for tests\n */\n\nexport type Priority = 'immediate' | 'normal' | 'idle';\n\nconst PRIORITY_ORDER: Record<Priority, number> = {\n immediate: 0,\n normal: 1,\n idle: 2,\n};\n\nexport interface Job {\n /** Unique key — if another job with the same key is already queued, it is replaced. */\n readonly key: string;\n readonly priority: Priority;\n readonly fn: () => void;\n}\n\n/**\n * Optional error-reporting hook (v0.9 §26/§27). Structurally compatible with\n * `@streetui/core`'s `DiagnosticSink` (the `error` method) so an application can\n * route swallowed scheduler-job failures through its own logger instead of the\n * default `console.error`. Kept as a local structural type so the scheduler\n * stays dependency-free; no network, no telemetry. When unset, behaviour is\n * exactly as before.\n */\nexport interface SchedulerDiagnostics {\n error?(message: string, context?: unknown): void;\n}\n\nexport class Scheduler {\n private readonly _queue: Map<string, Job> = new Map();\n private _flushScheduled = false;\n private _flushing = false;\n private _diagnostics: SchedulerDiagnostics | undefined = undefined;\n\n /**\n * Install an optional diagnostic sink for swallowed job errors. Pass\n * `undefined` to restore the default `console.error` reporting. Additive and\n * opt-in — the scheduler never sends anything anywhere on its own.\n */\n setDiagnostics(sink: SchedulerDiagnostics | undefined): void {\n this._diagnostics = sink;\n }\n\n /** Total jobs currently queued. */\n get size(): number {\n return this._queue.size;\n }\n\n /** True if a flush has been scheduled but not yet executed. */\n get isPending(): boolean {\n return this._flushScheduled;\n }\n\n /**\n * Enqueue a job. If a job with the same key exists, the new one replaces it\n * (allowing callers to coalesce repeated updates for the same node).\n */\n schedule(job: Job): void {\n this._queue.set(job.key, job);\n if (!this._flushScheduled && !this._flushing) {\n this._flushScheduled = true;\n this._scheduleMicrotask();\n }\n }\n\n /** Schedule multiple jobs atomically. */\n scheduleAll(jobs: readonly Job[]): void {\n for (const job of jobs) {\n this._queue.set(job.key, job);\n }\n if (!this._flushScheduled && !this._flushing && this._queue.size > 0) {\n this._flushScheduled = true;\n this._scheduleMicrotask();\n }\n }\n\n /**\n * Cancel a queued job by key. No-op if not queued.\n */\n cancel(key: string): void {\n this._queue.delete(key);\n }\n\n /**\n * Synchronously flush all queued jobs (sorted by priority).\n * Useful in tests and for immediate rendering.\n */\n flush(): void {\n if (this._flushing) return;\n this._flushScheduled = false;\n this._flushing = true;\n\n const jobs = Array.from(this._queue.values()).sort(\n (a, b) => PRIORITY_ORDER[a.priority] - PRIORITY_ORDER[b.priority],\n );\n this._queue.clear();\n\n try {\n for (const job of jobs) {\n try {\n job.fn();\n } catch (err) {\n // Isolate job failures — report and continue so remaining jobs still run.\n if (this._diagnostics?.error) {\n this._diagnostics.error(`Scheduler job \"${job.key}\" threw`, err);\n } else {\n console.error(`[Scheduler] Job \"${job.key}\" threw:`, err);\n }\n }\n }\n } finally {\n this._flushing = false;\n }\n }\n\n /** Clear all pending jobs without executing them. */\n clear(): void {\n this._queue.clear();\n this._flushScheduled = false;\n }\n\n private _scheduleMicrotask(): void {\n Promise.resolve().then(() => {\n if (this._flushScheduled) {\n this.flush();\n }\n });\n }\n}\n\n/** The shared global scheduler instance. */\nexport const scheduler = new Scheduler();\n\n/** Convenience: schedule a normal-priority job. */\nexport function scheduleUpdate(key: string, fn: () => void): void {\n scheduler.schedule({ key, priority: 'normal', fn });\n}\n\n/** Convenience: schedule an immediate-priority job. */\nexport function scheduleImmediate(key: string, fn: () => void): void {\n scheduler.schedule({ key, priority: 'immediate', fn });\n}\n\n/** Convenience: flush the global scheduler synchronously. */\nexport function flushSync(): void {\n scheduler.flush();\n}\n","/**\n * Higher-level testing helpers: role/text queries, update flushing, async\n * waiting, and a first-class SSR → hydrate → assert workflow.\n *\n * These build on the same real renderer the app uses — no private-graph access,\n * no second assertion framework. They exist so a test does not have to\n * reimplement server-render/hydrate plumbing or poll for async resource state\n * by hand.\n */\n\nimport { resetIdCounter } from '@streetui/core';\nimport { flushSync } from '@streetui/scheduler';\nimport { compile } from '@streetui/compiler';\nimport type { StreetApp } from '@streetui/dsl';\nimport { BrowserDOMAdapter } from '@streetui/dom';\nimport {\n createRenderer,\n renderToString,\n type HydrationDiagnostic,\n createHydrationDiagnosticCollector,\n} from '@streetui/renderer';\nimport type { RenderHandle } from '@streetui/runtime';\n\n// ── Update flushing & async waiting ─────────────────────────────────────────\n\n/**\n * Flush all pending scheduler work, then yield once to the microtask queue so\n * promise-driven updates (e.g. a resolved `resource` loader) are applied. Await\n * this after triggering a change that schedules a DOM patch.\n */\nexport async function flushUpdates(): Promise<void> {\n flushSync();\n await Promise.resolve();\n flushSync();\n}\n\nexport interface WaitForOptions {\n /** Give up after this many milliseconds (default 1000). */\n readonly timeout?: number;\n /** Delay between attempts in milliseconds (default 10). */\n readonly interval?: number;\n}\n\n/**\n * Poll `check` until it returns a truthy value (or stops throwing), flushing\n * updates between attempts. Rejects with the last error/tiemout after the\n * deadline. Use for assertions that become true only after async work settles.\n */\nexport async function waitFor<T>(\n check: () => T,\n options: WaitForOptions = {},\n): Promise<T> {\n const timeout = options.timeout ?? 1000;\n const interval = options.interval ?? 10;\n const deadline = Date.now() + timeout;\n let lastError: unknown;\n\n for (;;) {\n await flushUpdates();\n try {\n const result = check();\n if (result) return result;\n lastError = new Error('[StreetUI Testing] waitFor: condition was falsy');\n } catch (err) {\n lastError = err;\n }\n if (Date.now() >= deadline) {\n throw lastError instanceof Error\n ? lastError\n : new Error(String(lastError));\n }\n await new Promise((resolve) => setTimeout(resolve, interval));\n }\n}\n\n// ── Text / role queries (container-scoped) ──────────────────────────────────\n\n/** Find the first leaf element whose text content includes `text`. */\nexport function findByText(container: Element, text: string): Element {\n const match = Array.from(container.querySelectorAll('*')).find(\n (el) => el.children.length === 0 && (el.textContent?.includes(text) ?? false),\n );\n if (match === undefined) {\n throw new Error(`[StreetUI Testing] No element with text \"${text}\" found`);\n }\n return match;\n}\n\nexport interface ByRoleOptions {\n /** Restrict to elements whose accessible name includes this string. */\n readonly name?: string;\n}\n\n/** The implicit ARIA role for a plain HTML element, when it has one. */\nfunction implicitRole(el: Element): string | null {\n const tag = el.tagName.toLowerCase();\n switch (tag) {\n case 'button':\n return 'button';\n case 'a':\n return el.hasAttribute('href') ? 'link' : null;\n case 'nav':\n return 'navigation';\n case 'h1':\n case 'h2':\n case 'h3':\n case 'h4':\n case 'h5':\n case 'h6':\n return 'heading';\n case 'input': {\n const type = (el.getAttribute('type') ?? 'text').toLowerCase();\n if (type === 'checkbox') return 'checkbox';\n if (type === 'radio') return 'radio';\n if (type === 'button' || type === 'submit') return 'button';\n return 'textbox';\n }\n case 'form':\n return 'form';\n default:\n return null;\n }\n}\n\n/** The accessible name approximation for an element (aria-label or text). */\nfunction accessibleName(el: Element): string {\n return (el.getAttribute('aria-label') ?? el.textContent ?? '').trim();\n}\n\n/**\n * Find all elements matching an ARIA `role` — explicit `role=\"…\"` first, then\n * the element's implicit role. Optionally filter by accessible name.\n */\nexport function findAllByRole(\n container: Element,\n role: string,\n options: ByRoleOptions = {},\n): Element[] {\n const all = Array.from(container.querySelectorAll('*'));\n return all.filter((el) => {\n const explicit = el.getAttribute('role');\n const matches = explicit === role || (explicit === null && implicitRole(el) === role);\n if (!matches) return false;\n if (options.name !== undefined) {\n return accessibleName(el).includes(options.name);\n }\n return true;\n });\n}\n\n/** Find the single element matching a role (throws if none/ambiguous). */\nexport function findByRole(\n container: Element,\n role: string,\n options: ByRoleOptions = {},\n): Element {\n const matches = findAllByRole(container, role, options);\n if (matches.length === 0) {\n const named = options.name !== undefined ? ` with name \"${options.name}\"` : '';\n throw new Error(`[StreetUI Testing] No element with role \"${role}\"${named} found`);\n }\n if (matches.length > 1) {\n throw new Error(\n `[StreetUI Testing] Found ${matches.length} elements with role \"${role}\" — refine with { name }`,\n );\n }\n return matches[0]!;\n}\n\n// ── First-class SSR → hydrate → assert workflow ─────────────────────────────\n\nexport interface HydrateTestOptions {\n /** Collect hydration mismatch diagnostics (dev-style) during hydration. */\n readonly collectDiagnostics?: boolean;\n}\n\nexport interface HydrateTestResult {\n /** The container holding the server HTML, now hydrated live. */\n readonly container: HTMLElement;\n /** The server-produced HTML string (before hydration). */\n readonly serverHtml: string;\n /** The live render handle from hydration. */\n readonly handle: RenderHandle;\n /** Hydration mismatch diagnostics (empty unless collectDiagnostics + a real mismatch). */\n readonly diagnostics: readonly HydrationDiagnostic[];\n /** Flush pending scheduler work. */\n flush(): void;\n /** Unmount and detach the container. */\n unmount(): void;\n}\n\n/**\n * Render `build` on the \"server\" to HTML, mount that HTML into a container,\n * then hydrate the SAME app against it — exactly the production SSR path. The\n * builder is invoked twice (server then client) with `resetIdCounter` between,\n * so deterministic ids line up. Assert node identity, behavior, and (optionally)\n * that hydration reported no mismatches.\n */\nexport function renderServerThenHydrate(\n build: () => StreetApp,\n options: HydrateTestOptions = {},\n): HydrateTestResult {\n resetIdCounter();\n const serverHtml = renderToString(compile(build()));\n\n const container = document.createElement('div');\n container.innerHTML = serverHtml;\n document.body.appendChild(container);\n\n const collector = options.collectDiagnostics === true\n ? createHydrationDiagnosticCollector()\n : undefined;\n\n resetIdCounter();\n const renderer = createRenderer({\n domAdapter: new BrowserDOMAdapter(),\n ...(collector !== undefined ? { hydrationDiagnostics: collector.sink } : {}),\n });\n const handle = renderer.hydrate(compile(build()), container);\n\n return {\n container,\n serverHtml,\n handle,\n diagnostics: collector?.diagnostics ?? [],\n flush() {\n handle.flush();\n },\n unmount() {\n handle.unmount();\n if (container.parentNode !== null) container.parentNode.removeChild(container);\n },\n };\n}\n","/**\n * Static graph analysis (v1.2, spec §3/§12/§14).\n *\n * A single post-order walk over the Semantic Application Graph that classifies\n * every node as static (no bound signals, no events, not a reactive\n * region) or dynamic, and rolls that up into whole-static-subtree flags. This\n * is COMPILE-TIME metadata only — it introduces no virtual DOM, no second tree\n * and no runtime reactive system. It is consumed by:\n * - the hydration path, to skip per-node attribute/text re-verification on\n * provably-static subtrees (§12), and\n * - the diagnostic compiler-inspection report (§14).\n *\n * The renderer's initial-mount fast path does not need this map: it already\n * skips reactive wiring per node via cheap `events.length`/`stateRefs.length`\n * guards. Keeping the analysis out of the mount hot path avoids adding lookup\n * cost (and keeps the shipped runtime lean).\n */\n\nimport type { NodeId } from '@streetui/core';\nimport type { ApplicationGraph, GraphNode } from '@streetui/graph';\n\n/** Prop keys whose bound signal drives text content rather than an attribute. */\nconst TEXT_PROP_KEYS: ReadonlySet<string> = new Set(['text', 'label', 'value']);\n\nexport interface NodeAnalysis {\n /** No bound signals, no events, and not a reactive-list/conditional region. */\n readonly isStatic: boolean;\n /** This node is static AND every descendant is a static subtree. */\n readonly isStaticSubtree: boolean;\n /** A signal is bound to this node's text/label/value content. */\n readonly hasDynamicText: boolean;\n /** A signal is bound to a non-content prop (a reactive attribute). */\n readonly hasDynamicAttr: boolean;\n /** This node wires one or more DOM event handlers. */\n readonly hasEvents: boolean;\n /** This node is a keyed reactive list. */\n readonly isList: boolean;\n /** This node is a conditional (0..1 branch) region. */\n readonly isConditional: boolean;\n}\n\nexport interface GraphAnalysisSummary {\n readonly totalNodes: number;\n readonly staticNodes: number;\n readonly staticSubtrees: number;\n readonly dynamicTextNodes: number;\n readonly dynamicAttrNodes: number;\n readonly eventNodes: number;\n readonly lists: number;\n readonly conditionals: number;\n}\n\nexport interface GraphAnalysis {\n readonly nodes: ReadonlyMap<NodeId, NodeAnalysis>;\n readonly summary: GraphAnalysisSummary;\n}\n\n/**\n * Analyze a fully-built graph. O(n) single post-order pass; allocates one small\n * record per node. Safe to skip entirely when neither hydration nor diagnostics\n * need it.\n */\nexport function analyzeGraph(graph: ApplicationGraph): GraphAnalysis {\n const nodes = new Map<NodeId, NodeAnalysis>();\n const summary = {\n totalNodes: 0, staticNodes: 0, staticSubtrees: 0, dynamicTextNodes: 0,\n dynamicAttrNodes: 0, eventNodes: 0, lists: 0, conditionals: 0,\n };\n\n const visit = (node: GraphNode): boolean => {\n // Post-order: children first so subtree rollup is exact.\n let allChildrenStatic = true;\n for (const child of node.children) {\n const childSubtreeStatic = visit(child);\n if (!childSubtreeStatic) allChildrenStatic = false;\n }\n\n let hasDynamicText = false;\n let hasDynamicAttr = false;\n for (const ref of node.stateRefs) {\n if (TEXT_PROP_KEYS.has(ref.propKey)) hasDynamicText = true;\n else hasDynamicAttr = true;\n }\n const hasEvents = node.events.length > 0;\n const isList = node.type === 'reactive-list';\n const isConditional = node.type === 'conditional';\n const isStatic =\n node.stateRefs.length === 0 && !hasEvents && !isList && !isConditional;\n const isStaticSubtree = isStatic && allChildrenStatic;\n\n nodes.set(node.id, {\n isStatic, isStaticSubtree, hasDynamicText, hasDynamicAttr,\n hasEvents, isList, isConditional,\n });\n\n summary.totalNodes += 1;\n if (isStatic) summary.staticNodes += 1;\n if (isStaticSubtree) summary.staticSubtrees += 1;\n if (hasDynamicText) summary.dynamicTextNodes += 1;\n if (hasDynamicAttr) summary.dynamicAttrNodes += 1;\n if (hasEvents) summary.eventNodes += 1;\n if (isList) summary.lists += 1;\n if (isConditional) summary.conditionals += 1;\n\n return isStaticSubtree;\n };\n\n visit(graph.root);\n return { nodes, summary };\n}\n","/**\n * Diagnostic compiler-inspection mode (v1.2, spec §14).\n *\n * Produces a machine-readable (and optionally text-formatted) description of\n * what the compiler understands about an application: which nodes are static\n * vs dynamic, which carry dynamic text or attributes, which wire events, and\n * which are conditional regions or keyed lists — plus the hydration metadata\n * derived from that classification.\n *\n * This is a DIAGNOSTIC tool. It is not part of the runtime, is not consulted\n * during mount, and is tree-shakeable out of any app that never calls it.\n */\n\nimport type { ApplicationGraph, GraphNode } from '@streetui/graph';\nimport { analyzeGraph, type GraphAnalysisSummary } from './analyze.js';\n\nexport interface InspectedCompilationNode {\n readonly id: string;\n readonly type: string;\n readonly depth: number;\n readonly classification: 'static' | 'static-subtree-root' | 'dynamic';\n readonly dynamicText: boolean;\n readonly dynamicAttrs: boolean;\n readonly events: readonly string[];\n readonly boundProps: readonly string[];\n readonly isList: boolean;\n readonly isConditional: boolean;\n /** Hydration hint: how the hydration path should treat this node. */\n readonly hydration: 'adopt-static' | 'verify-dynamic';\n}\n\nexport interface CompilerInspection {\n readonly name: string;\n readonly version: string;\n readonly summary: GraphAnalysisSummary & {\n /** Fraction of nodes provably static (0..1). */\n readonly staticRatio: number;\n };\n readonly nodes: readonly InspectedCompilationNode[];\n}\n\n/**\n * Inspect a compiled/built graph and return a structured diagnostic report.\n * Purely observational — never mutates the graph.\n */\nexport function inspectCompilation(graph: ApplicationGraph): CompilerInspection {\n const analysis = analyzeGraph(graph);\n const nodes: InspectedCompilationNode[] = [];\n\n const walk = (node: GraphNode, depth: number): void => {\n const a = analysis.nodes.get(node.id);\n if (a !== undefined) {\n const classification: InspectedCompilationNode['classification'] = a.isStaticSubtree\n ? 'static-subtree-root'\n : a.isStatic\n ? 'static'\n : 'dynamic';\n nodes.push({\n id: node.id,\n type: node.type,\n depth,\n classification,\n dynamicText: a.hasDynamicText,\n dynamicAttrs: a.hasDynamicAttr,\n events: node.events.map((e) => e.type),\n boundProps: node.stateRefs.map((r) => r.propKey),\n isList: a.isList,\n isConditional: a.isConditional,\n hydration: a.isStaticSubtree ? 'adopt-static' : 'verify-dynamic',\n });\n }\n for (const child of node.children) walk(child, depth + 1);\n };\n walk(graph.root, 0);\n\n const staticRatio =\n analysis.summary.totalNodes === 0\n ? 0\n : analysis.summary.staticNodes / analysis.summary.totalNodes;\n\n return {\n name: graph.name,\n version: graph.version,\n summary: { ...analysis.summary, staticRatio: +staticRatio.toFixed(4) },\n nodes,\n };\n}\n\n/** Render an inspection as a compact human-readable text report. */\nexport function formatInspection(inspection: CompilerInspection): string {\n const s = inspection.summary;\n const lines: string[] = [];\n lines.push(`StreetUI compiler inspection — ${inspection.name} v${inspection.version}`);\n lines.push(\n ` nodes=${s.totalNodes} static=${s.staticNodes} ` +\n `staticSubtrees=${s.staticSubtrees} dynamicText=${s.dynamicTextNodes} ` +\n `dynamicAttrs=${s.dynamicAttrNodes} events=${s.eventNodes} ` +\n `lists=${s.lists} conditionals=${s.conditionals} ` +\n `staticRatio=${(s.staticRatio * 100).toFixed(1)}%`,\n );\n for (const n of inspection.nodes) {\n const flags: string[] = [];\n if (n.dynamicText) flags.push('text');\n if (n.dynamicAttrs) flags.push('attr:' + n.boundProps.join(','));\n if (n.events.length > 0) flags.push('on:' + n.events.join(','));\n if (n.isList) flags.push('list');\n if (n.isConditional) flags.push('cond');\n lines.push(\n ` ${' '.repeat(n.depth)}${n.type}#${n.id} [${n.classification}]` +\n (flags.length > 0 ? ` {${flags.join(' ')}}` : ''),\n );\n }\n return lines.join('\\n');\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAI,WAAW;AAQR,SAAS,iBAAuB;AACrC,aAAW;AACb;;;ACqDO,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;;;AC/DO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAChC;AAAA,EAET,YAAY,aAAoC;AAC9C,UAAM,UAAU,YACb,OAAO,OAAK,EAAE,aAAa,OAAO,EAClC,IAAI,OAAK,IAAI,EAAE,IAAI,KAAK,EAAE,OAAO,EAAE,EACnC,KAAK,IAAI;AACZ,UAAM;AAAA,EAA0B,OAAO,EAAE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