@niscorp/nova 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +56 -13
- package/SHELL_DOCS.md +13 -4
- package/dist/adapters/dom/index.cjs.map +1 -1
- package/dist/adapters/dom/index.js +2 -2
- package/dist/adapters/dom/server.js +2 -2
- package/dist/adapters/react/components/index.js +3 -3
- package/dist/adapters/react/index.cjs.map +1 -1
- package/dist/adapters/react/index.js +3 -3
- package/dist/adapters/tty/index.js +1 -1
- package/dist/adapters/vue/components/index.js +3 -3
- package/dist/adapters/vue/index.cjs.map +1 -1
- package/dist/adapters/vue/index.js +4 -4
- package/dist/{chunk-RYIIIXDX.js → chunk-DU2VIJAF.js} +57 -15
- package/dist/chunk-DU2VIJAF.js.map +1 -0
- package/dist/{chunk-VU6NNCEJ.js → chunk-F2H7WP6R.js} +4 -4
- package/dist/{chunk-VU6NNCEJ.js.map → chunk-F2H7WP6R.js.map} +1 -1
- package/dist/{chunk-QXQCPH33.js → chunk-G4LSLLGI.js} +4 -4
- package/dist/{chunk-QXQCPH33.js.map → chunk-G4LSLLGI.js.map} +1 -1
- package/dist/{chunk-MHW5VEIM.js → chunk-SVNK5NIK.js} +3 -3
- package/dist/{chunk-MHW5VEIM.js.map → chunk-SVNK5NIK.js.map} +1 -1
- package/dist/{chunk-UDCXGDLQ.js → chunk-VOD5JA4D.js} +3 -3
- package/dist/{chunk-UDCXGDLQ.js.map → chunk-VOD5JA4D.js.map} +1 -1
- package/dist/chunk-XQTI4Q4I.js +178 -0
- package/dist/chunk-XQTI4Q4I.js.map +1 -0
- package/dist/examples/index.cjs +1186 -0
- package/dist/examples/index.cjs.map +1 -0
- package/dist/examples/index.d.cts +63 -0
- package/dist/examples/index.d.ts +63 -0
- package/dist/examples/index.js +1158 -0
- package/dist/examples/index.js.map +1 -0
- package/dist/i18n/index.js +2 -176
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.cjs +55 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/package.json +19 -8
- package/dist/chunk-RYIIIXDX.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layout/adapter.ts","../../../src/layout/head.ts","../../../src/shell/slot-names.ts","../../../src/shell/head.ts","../../../src/shell/view.ts","../../../src/document/place-head.ts","../../../src/document/head-keeper.ts","../../../src/adapters/dom/index.ts"],"names":["TAGS","before"],"mappings":";;;AAkBO,IAAM,aAAA,GAAgB,CAAC,IAAA,EAAkB,KAAA,KAA0B;AACxE,EAAA,IAAI,KAAK,GAAA,KAAQ,MAAA,EAAW,OAAO,CAAA,EAAA,EAAK,KAAK,GAAG,CAAA,CAAA;AAChD,EAAA,IAAI,IAAA,CAAK,SAAS,WAAA,EAAa;AAC7B,IAAA,IAAI,KAAK,GAAA,KAAQ,MAAA,EAAW,OAAO,CAAA,EAAA,EAAK,KAAK,GAAG,CAAA,CAAA;AAChD,IAAA,OAAO,CAAA,EAAA,EAAK,IAAA,CAAK,IAAI,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AAAA,EAChC;AACA,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,MAAA,EAAQ,OAAO,KAAK,KAAK,CAAA,CAAA;AAC3C,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,UAAA,EAAY,OAAO,KAAK,KAAK,CAAA,CAAA;AAC/C,EAAA,OAAO,CAAA,EAAA,EAAK,IAAA,CAAK,IAAI,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AAChC,CAAA;;;ACIO,IAAM,SAAA,GAAY,WAAA;AAClB,IAAM,eAAA,GAAkB,YAAA;AACxB,IAAM,cAAA,GAAiB,WAAA;AACvB,IAAM,cAAA,GAAiB,WAAA;AACvB,IAAM,gBAAA,GAAmB,aAAA;AAmBzB,IAAM,SAAA,GAAY,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n\n// ═══════════════════════════════════════════════════════════\n// Adapter helpers — framework-agnostic pieces every adapter\n// (React, Vue, …) needs to render a RenderNode tree the same\n// way. See packages/nova/ADAPTER.md for the full contract.\n// ═══════════════════════════════════════════════════════════\n\n// Names of the props an adapter injects on rendered components:\n// `RenderNode.model` → NOVA_MODEL_PROP ({ ref, path }),\n// `RenderNode.ref` → NOVA_REF_PROP (string). Constants so all\n// adapters inject identically and components can rely on them.\nexport const NOVA_MODEL_PROP = 'novaModel';\nexport const NOVA_REF_PROP = 'novaRef';\n\n// Stable identity for a RenderNode within its sibling list.\n// Loop identity (stamped from LoopNode.key/index) wins over ref: a shared\n// `ref` across looped rows is an event-target id, not a list key.\nexport const renderNodeKey = (node: RenderNode, index: number): string => {\n if (node.key !== undefined) return `k:${node.key}`;\n if (node.type === 'component') {\n if (node.ref !== undefined) return `c:${node.ref}`;\n return `c:${node.name}:${index}`;\n }\n if (node.type === 'text') return `t:${index}`;\n if (node.type === 'fragment') return `f:${index}`;\n return `e:${node.code}:${index}`;\n};\n","// ═══════════════════════════════════════════════════════════\n// THE HEAD — `nova:head` is the document's <head>, as a node in a layout.\n//\n// A document has a part nobody sees on the screen: its title, the sentence\n// that describes it, the card shown where a link to it is pasted. That part\n// is written the way the rest of the screen is — a layout node, its children\n// bound to the action's data — and travels the way the rest does, in the\n// render tree.\n//\n// Its children are the elements a head holds, named as HTML names them:\n// `nova:title`, `nova:meta`, `nova:link`, `nova:script`. A child's props are\n// that element's ATTRIBUTES, written as given. Nova keeps no list of them, so\n// any `name`, `property` or `rel` there is — or will be — can be said without\n// nova learning it.\n//\n// Nothing here is drawn on the screen. No adapter builds an element for a head\n// or for anything in it, and no registry has to hold the names. Whoever writes\n// the document reads the elements off the tree (`headOf`) and writes them into\n// its <head>.\n//\n// WHAT A HEAD DOES NOT HOLD is what runs or styles: a script that executes, a\n// stylesheet, a <base>, an instruction to the browser (`http-equiv`), a handler\n// attribute. A layout is data, and data that reaches every page must not be\n// able to run. Those stay in the app's own index.html, which holds anything.\n//\n// This file holds no schema on purpose: a terminal that only reads a head off\n// the wire needs the names and the shape, and nothing to validate with.\n// ═══════════════════════════════════════════════════════════\n\n// Namespaced as a package's own in-layout components are (`loom:field`), so\n// none can be a name an app's kit already uses for something else.\nexport const HEAD_NAME = 'nova:head';\nexport const HEAD_TITLE_NAME = 'nova:title';\nexport const HEAD_META_NAME = 'nova:meta';\nexport const HEAD_LINK_NAME = 'nova:link';\nexport const HEAD_SCRIPT_NAME = 'nova:script';\n\n// The head and what it holds: the names a layout may use with no registry\n// entry behind them.\nexport const HEAD_NAMES: readonly string[] = [HEAD_NAME, HEAD_TITLE_NAME, HEAD_META_NAME, HEAD_LINK_NAME, HEAD_SCRIPT_NAME];\n\n// One element of a head, as data: what to write, wherever a head is written.\nexport type HeadElement = {\n tag: 'title' | 'meta' | 'link' | 'script';\n // as the layout gave them, in the order it gave them\n attributes: Record<string, string>;\n // a title's words; a script's data, as JSON\n text?: string;\n};\n\n// What two elements both say, when they say the same thing — the later one\n// then takes the earlier one's place. A document has one title, one <meta> of\n// a given name or property, one canonical address. Anything else stands beside\n// its like: two alternates, two data blocks.\nexport const headKeyOf = (element: Pick<HeadElement, 'tag' | 'attributes'>): string | undefined => {\n const said = (name: string): string | undefined => {\n const found = Object.entries(element.attributes).find(([key]) => key.toLowerCase() === name)?.[1].trim().toLowerCase();\n return found === undefined || found === '' ? undefined : found;\n };\n if (element.tag === 'title') return 'title';\n if (element.tag === 'meta') {\n const [name, property] = [said('name'), said('property')];\n if (name !== undefined) return `meta name ${name}`;\n return property === undefined ? undefined : `meta property ${property}`;\n }\n if (element.tag === 'link') return (said('rel') ?? '').split(/\\s+/).includes('canonical') ? 'link canonical' : undefined;\n return undefined;\n};\n","// ═══════════════════════════════════════════════════════════\n// Slot component name constants.\n//\n// Every framework adapter (React, future Vue/Svelte/etc.) must\n// register components under these names in its ComponentRegistry\n// to participate in shell/canvas layout rendering:\n//\n// CANVAS_SLOT_NAME — renders a canvas by id (props: canvasId?)\n// ACTION_SLOT_NAME — renders an action instance by id (props: instanceId?)\n//\n// The shell uses these names in its default layouts and when\n// flattening a render tree for non-React consumers (evaluators,\n// export, testing), so they are part of the package's public\n// contract — not React-only.\n// ═══════════════════════════════════════════════════════════\n\nexport const CANVAS_SLOT_NAME = 'CanvasSlot';\nexport const ACTION_SLOT_NAME = 'ActionSlot';\n","import { HEAD_LINK_NAME, HEAD_META_NAME, HEAD_NAME, HEAD_SCRIPT_NAME, HEAD_TITLE_NAME, headKeyOf } from '../layout/head';\nimport type { HeadElement } from '../layout/head';\nimport type { RenderNode } from '../layout';\nimport type { RenderApi } from './types';\nimport { ACTION_SLOT_NAME, CANVAS_SLOT_NAME } from './slot-names';\n\n// ═══════════════════════════════════════════════════════════\n// The head a screen has, read off its render tree.\n//\n// The frame is walked in the order it is drawn, into each canvas where its\n// slot stands and into each instance on it, and every `nova:head` it meets\n// gives its elements in turn. A screen can hold more than one head — the\n// shell's chrome says what holds on every screen, an action says its own, a\n// dialog opens over a page. An element that says the same thing as an earlier\n// one (the title, a <meta> of that name) takes its place; anything else stands\n// beside what came before.\n//\n// What a head may not hold is refused here, once, for every writer: the\n// element is left out and the reason is given. See ../layout/head.\n// ═══════════════════════════════════════════════════════════\n\nexport type ScreenHead = {\n // what the document's head is to hold, in the order the screen said it\n elements: HeadElement[];\n // the actions whose instances said any of it (none: only the shell's chrome did)\n actions: string[];\n // what a head held that it may not — left out, each with why\n refused: string[];\n};\n\ntype ComponentNode = Extract<RenderNode, { type: 'component' }>;\ntype Read = { element: HeadElement } | { refused: string } | undefined;\n\nconst ATTRIBUTE_NAME = /^[A-Za-z][A-Za-z0-9:._-]*$/;\n// a data block: a type no browser runs\nconst DATA_TYPE = /^application\\/([a-z0-9.-]+\\+)?json$/i;\n\n// A prop, as the attribute it is written as — or nothing, when it says nothing.\nconst written = (value: unknown): string | undefined => {\n if (typeof value === 'string') return value.trim() === '' ? undefined : value;\n if (typeof value === 'number') return String(value);\n return value === true ? '' : undefined;\n};\n\n// An element's attributes, from its props — or why it may not be written.\nconst attributesOf = (what: string, props: Record<string, unknown>, skip: readonly string[] = []): { attributes: Record<string, string> } | { refused: string } => {\n const attributes: Record<string, string> = {};\n for (const [name, value] of Object.entries(props)) {\n if (skip.includes(name)) continue;\n if (!ATTRIBUTE_NAME.test(name)) return { refused: `${what}: \"${name}\" is not an attribute’s name` };\n if (/^on/i.test(name)) return { refused: `${what}: \\`${name}\\` is a handler, and a layout does not run` };\n const text = written(value);\n if (text !== undefined) attributes[name] = text;\n }\n return { attributes };\n};\n\nconst has = (attributes: Record<string, string>, name: string): boolean => Object.keys(attributes).some((key) => key.toLowerCase() === name);\nconst valueOf = (attributes: Record<string, string>, name: string): string => Object.entries(attributes).find(([key]) => key.toLowerCase() === name)?.[1] ?? '';\n\nconst textOf = (nodes: readonly RenderNode[]): string =>\n nodes.map((node) => (node.type === 'text' ? node.value : node.type === 'fragment' ? textOf(node.children) : '')).join('');\n\nconst titleOf = (node: ComponentNode): Read => {\n const text = textOf(node.children).trim();\n return text === '' ? undefined : { element: { tag: 'title', attributes: {}, text } };\n};\n\nconst metaOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_META_NAME, node.props);\n if ('refused' in read) return read;\n if (has(read.attributes, 'http-equiv')) return { refused: `${HEAD_META_NAME}: \\`http-equiv\\` instructs the browser, and a layout does not` };\n // nothing to say yet: its value is not answered\n return has(read.attributes, 'content') ? { element: { tag: 'meta', attributes: read.attributes } } : undefined;\n};\n\nconst linkOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_LINK_NAME, node.props);\n if ('refused' in read) return read;\n if (valueOf(read.attributes, 'rel').toLowerCase().split(/\\s+/).includes('stylesheet')) return { refused: `${HEAD_LINK_NAME}: a stylesheet styles the page, and a layout does not` };\n return has(read.attributes, 'href') ? { element: { tag: 'link', attributes: read.attributes } } : undefined;\n};\n\nconst scriptOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_SCRIPT_NAME, node.props, ['data']);\n if ('refused' in read) return read;\n if (has(read.attributes, 'src')) return { refused: `${HEAD_SCRIPT_NAME}: a script with a \\`src\\` runs, and a layout does not` };\n const type = valueOf(read.attributes, 'type');\n if (!DATA_TYPE.test(type)) return { refused: `${HEAD_SCRIPT_NAME}: only a data block may be written (a JSON \\`type\\`), and \"${type}\" is not one` };\n const data = node.props['data'];\n if (data === undefined || data === null || data === '') return undefined;\n return { element: { tag: 'script', attributes: read.attributes, text: JSON.stringify(data) } };\n};\n\nconst READERS: Record<string, (node: ComponentNode) => Read> = {\n [HEAD_TITLE_NAME]: titleOf,\n [HEAD_META_NAME]: metaOf,\n [HEAD_LINK_NAME]: linkOf,\n [HEAD_SCRIPT_NAME]: scriptOf,\n};\n\nexport const isHeadNode = (node: RenderNode): boolean => node.type === 'component' && node.name === HEAD_NAME;\n\nexport const headOf = (api: Pick<RenderApi, 'frame' | 'canvasTree'>): ScreenHead | undefined => {\n let heads = 0;\n const said: { element: HeadElement; action: string | undefined }[] = [];\n const refused: string[] = [];\n // a canvas whose own tree names it again would never end\n const open = new Set<string>();\n\n const hold = (nodes: readonly RenderNode[], action: string | undefined): void => {\n for (const node of nodes) {\n if (node.type === 'fragment') {\n hold(node.children, action);\n continue;\n }\n if (node.type === 'error') {\n refused.push(`${HEAD_NAME}: ${node.message}`);\n continue;\n }\n // text between a head's elements is nothing\n if (node.type !== 'component') continue;\n const read = READERS[node.name];\n if (read === undefined) {\n refused.push(`${HEAD_NAME}: \"${node.name}\" is not something a head holds`);\n continue;\n }\n const found = read(node);\n if (found === undefined) continue;\n if ('refused' in found) {\n refused.push(found.refused);\n continue;\n }\n const key = headKeyOf(found.element);\n const earlier = key === undefined ? -1 : said.findIndex((other) => headKeyOf(other.element) === key);\n if (earlier >= 0) said.splice(earlier, 1);\n said.push({ element: found.element, action });\n }\n };\n\n const walk = (nodes: readonly RenderNode[], action: string | undefined): void => {\n for (const node of nodes) {\n if (node.type === 'fragment') {\n walk(node.children, action);\n continue;\n }\n if (node.type !== 'component') continue;\n if (node.name === HEAD_NAME) {\n heads += 1;\n hold(node.children, action);\n continue;\n }\n if (node.name === CANVAS_SLOT_NAME) {\n const canvasId = node.props['canvasId'];\n if (typeof canvasId !== 'string' || canvasId === '' || open.has(canvasId)) continue;\n open.add(canvasId);\n walk(api.canvasTree(canvasId), undefined);\n open.delete(canvasId);\n continue;\n }\n const definitionId = node.name === ACTION_SLOT_NAME ? node.props['definitionId'] : undefined;\n walk(node.children, typeof definitionId === 'string' ? definitionId : action);\n }\n };\n\n walk(api.frame(), undefined);\n if (heads === 0) return undefined;\n const actions = [...new Set(said.flatMap((one) => (one.action === undefined ? [] : [one.action])))];\n return { elements: said.map((one) => one.element), actions, refused };\n};\n","import type { RenderNode } from '../layout';\nimport type { RenderApi, Shell } from './types';\nimport { isHeadNode } from './head';\nimport { ACTION_SLOT_NAME } from './slot-names';\n\n// ═══════════════════════════════════════════════════════════\n// A shell, as something an adapter draws.\n//\n// Every adapter that draws a SERVED screen draws it through `RenderApi` — the\n// frame, a tree per canvas, events up, messages across — and has always been\n// handed one by a transport (moss's socket wire). A shell that lives in the\n// same process as its adapter is the other case that type was written for, and\n// this is it: the shell's own trees, read as they stand, and its own dispatch.\n// The DOM and TTY adapters draw a local shell through this exactly as they draw\n// a remote one; nothing about them knows the difference.\n//\n// It is also what makes a shell DRAWABLE AHEAD OF TIME. A build runs the app's\n// own boot, waits for the screen to be whole (`shellSettled`), and has an\n// adapter draw this view to markup; the browser runs the same boot and draws\n// the same view over that markup. Where the shell lives was never the\n// adapter's business.\n// ═══════════════════════════════════════════════════════════\n\nexport type ShellView = {\n api: RenderApi;\n // Called after the shell changed — coalesced, so a burst of changes (a press\n // that sets three keys) is one call. Returns the unsubscribe.\n subscribe: (listener: () => void) => () => void;\n};\n\n// NO VISIBLE CONTENT IS AN EMPTY TREE. A canvas whose layout renders nothing but\n// empty text and empty wrappers is handed to an adapter as `[]`, so an adapter\n// collapses the chrome around it on `length` alone, knowing nothing about node\n// shapes. An ActionSlot marker is a boundary, not content — what is inside it\n// decides — and a head is the document's, not something the screen shows.\n// One rule for a canvas that is served and one that is local, so a frame looks\n// the same over both.\nexport const hasVisibleContent = (nodes: readonly RenderNode[]): boolean =>\n nodes.some((node) => {\n if (node.type === 'text') return node.value !== '';\n if (node.type === 'fragment') return hasVisibleContent(node.children);\n if (node.type === 'component' && node.name === ACTION_SLOT_NAME) return hasVisibleContent(node.children);\n if (isHeadNode(node)) return false;\n return true;\n });\n\n// One canvas, as an adapter is handed it.\nexport const canvasTreeOf = (shell: Shell, canvasId: string): RenderNode[] => {\n const tree = shell.flattenRenderTree(shell.getCanvasRenderTree(canvasId));\n return hasVisibleContent(tree) ? tree : [];\n};\n\nexport const shellView = (shell: Shell): ShellView => ({\n api: {\n frame: () => shell.getShellRenderTree(),\n canvasTree: (canvasId) => canvasTreeOf(shell, canvasId),\n // An event that names no origin belongs to the canvas's ACTIVE instance — on\n // a card deck that is the only one drawn. One that names its own (an\n // adapter stamps it at the instance boundary, `scopeDispatch`) keeps it. A\n // canvas with nothing mounted dispatches unstamped.\n dispatch: (canvasId, event) => {\n const active = shell.getState().canvases[canvasId]?.active;\n shell.dispatch(event.origin === undefined && active !== undefined ? { ...event, origin: active.id } : event);\n },\n publish: (channel, payload) => shell.publish(channel, payload),\n },\n subscribe: (listener) => {\n let pending = false;\n let stopped = false;\n const changed = (): void => {\n if (pending || stopped) return;\n pending = true;\n queueMicrotask(() => {\n pending = false;\n if (!stopped) listener();\n });\n };\n const offState = shell.onStateChange(changed);\n const offData = shell.onDataChange(changed);\n return () => {\n stopped = true;\n offState();\n offData();\n };\n },\n});\n\n// THE FIRST SCREEN IS WHOLE. An instance is `initializing` until its mount hook\n// — the loads, and whatever they chain to — has been awaited, so \"nothing is\n// initializing\" is the shell saying its opening screen is complete. A mount can\n// open another action, which starts initializing in turn, so the question is\n// asked again on every change and answered true only when it still holds a\n// macrotask later.\n//\n// Resolves `false` when `waitMs` runs out first: the screen is then drawn as it\n// stands, with whatever is still loading drawn as loading. Default 300ms — a\n// page should not hang on one slow endpoint.\nexport const DEFAULT_SETTLE_WAIT_MS = 300;\n\nexport const shellSettled = async (shell: Shell, options: { waitMs?: number; stopped?: () => boolean } = {}): Promise<boolean> => {\n const waitMs = options.waitMs ?? DEFAULT_SETTLE_WAIT_MS;\n const mounting = (): boolean =>\n Object.values(shell.getState().canvases).some((canvas) => canvas.stack.some((instance) => instance.status === 'initializing'));\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<boolean>((resolve) => {\n timer = setTimeout(() => resolve(false), waitMs);\n });\n const quiet = (async (): Promise<boolean> => {\n for (;;) {\n if (options.stopped?.() === true) return false;\n if (!mounting()) {\n await new Promise<void>((resolve) => setTimeout(resolve, 0));\n if (!mounting()) return true;\n }\n await new Promise<void>((resolve) => {\n const off = shell.onStateChange(() => {\n off();\n resolve();\n });\n // a change that lands with no notification must not leave this waiting\n setTimeout(() => {\n off();\n resolve();\n }, 10);\n });\n }\n })();\n const settled = await Promise.race([quiet, deadline]);\n clearTimeout(timer);\n return settled;\n};\n","import { headKeyOf } from '../layout/head';\nimport type { HeadElement } from '../layout/head';\n\n// ═══════════════════════════════════════════════════════════\n// A screen's head, written into an HTML document.\n//\n// The document is the app's own `index.html` with a screen already drawn into\n// it. Its <head> is what holds on every page; the screen's head elements are\n// what this page says. An element that says the same thing as a tag the\n// document already has — its <title>, a <meta> of that name or property, its\n// canonical address — takes that tag's place, where it stood. Anything else is\n// added after what is there. Everything the screen does not speak of is left\n// exactly as it was: the icon, the viewport, the stylesheet.\n//\n// TWO THINGS ARE KEPT FOR THE PAGE ITSELF, which goes on living after the file\n// is read (./head-keeper). What was written is marked (`data-nova-head`), so\n// the page can tell the screen's elements from the document's own. And a tag\n// that gave up its place is kept, inert, in a <template data-nova-own>: when\n// the screen moves on to one that no longer says it, the document's own comes\n// back.\n//\n// WHERE the document lives is known to whoever writes the file: the site plus\n// the path it was drawn at. With a `site`, every path is given its own\n// canonical address, whether or not its screen has a head. That address is the\n// document's own for this path — unmarked, and it stays when the screen moves\n// on. A screen that says a canonical address itself is taken at its word.\n//\n// With nothing to write, the document comes back untouched.\n// ═══════════════════════════════════════════════════════════\n\nexport type HeadPlace = {\n // The address the site is served at (\"https://example.com\"). With it, each\n // path's canonical address is written.\n site?: string;\n // The path this document was drawn at.\n path?: string;\n};\n\nexport const HEAD_MARK = 'data-nova-head';\nexport const OWN_MARK = 'data-nova-own';\n\nconst escapeAttribute = (value: string): string => value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<');\nconst escapeText = (value: string): string => value.replace(/&/g, '&').replace(/</g, '<');\n// Inside a <script>, the one thing that may not appear is the start of a tag.\n// The two separators end a line in a script though not in JSON, so they are\n// written as escapes too (named by code: the characters themselves would end\n// a line here as well).\nconst LINE_ENDS = [0x2028, 0x2029];\nconst escapeScript = (json: string): string =>\n LINE_ENDS.reduce((text, code) => text.split(String.fromCharCode(code)).join(`\\\\u${code.toString(16)}`), json.replace(/</g, '\\\\u003c'));\n\n// What stands in a head, read a tag at a time: comments and the bodies of\n// scripts, styles and templates are passed over whole, so a tag written inside\n// one is not mistaken for a tag.\nconst ATTRIBUTES = `((?:[^>\"']|\"[^\"]*\"|'[^']*')*)`;\nconst TAGS = new RegExp(`<!--[\\\\s\\\\S]*?-->|<(script|style|title|template)\\\\b${ATTRIBUTES}>([\\\\s\\\\S]*?)<\\\\/\\\\1\\\\s*>|<(meta|link)\\\\b${ATTRIBUTES}>`, 'gi');\nconst ATTRIBUTE = /([^\\s\"'=<>/]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?/g;\n\ntype Tag = { start: number; end: number; name: string; attributes: Record<string, string>; inner: string; text: string };\n\nconst attributesOf = (source: string): Record<string, string> => {\n const attributes: Record<string, string> = {};\n for (const match of source.matchAll(ATTRIBUTE)) {\n const name = match[1]?.toLowerCase();\n if (name === undefined || name in attributes) continue;\n attributes[name] = match[2] ?? match[3] ?? match[4] ?? '';\n }\n return attributes;\n};\n\nconst tagsOf = (section: string): Tag[] => {\n const tags: Tag[] = [];\n for (const match of section.matchAll(TAGS)) {\n const name = (match[1] ?? match[4])?.toLowerCase();\n if (name === undefined) continue;\n tags.push({ start: match.index, end: match.index + match[0].length, name, attributes: attributesOf(match[2] ?? match[5] ?? ''), inner: match[3] ?? '', text: match[0] });\n }\n return tags;\n};\n\n// What a tag in the document says, in the same terms as an element.\nconst keyOfTag = (tag: Tag): string | undefined =>\n tag.name === 'title' || tag.name === 'meta' || tag.name === 'link' ? headKeyOf({ tag: tag.name, attributes: tag.attributes }) : undefined;\n\n// An element, as the tag it is written as.\nconst markupOf = (element: HeadElement, marked: boolean): string => {\n const written = Object.entries(element.attributes).map(([name, value]) => (value === '' ? ` ${name}` : ` ${name}=\"${escapeAttribute(value)}\"`));\n const attributes = [...written, ...(marked ? [` ${HEAD_MARK}`] : [])].join('');\n if (element.tag === 'title') return `<title${attributes}>${escapeText(element.text ?? '')}</title>`;\n if (element.tag === 'script') return `<script${attributes}>${escapeScript(element.text ?? '')}</script>`;\n return `<${element.tag}${attributes}>`;\n};\n\n// Where the document lives, as elements: what a `site` and a path say.\nconst addressOf = (place: HeadPlace): HeadElement[] => {\n if (place.site === undefined || place.path === undefined) return [];\n const path = place.path.split(/[?#]/)[0] ?? '';\n const address = `${place.site.replace(/\\/+$/, '')}${path.startsWith('/') ? path : `/${path}`}`;\n return [\n { tag: 'link', attributes: { rel: 'canonical', href: address } },\n { tag: 'meta', attributes: { property: 'og:url', content: address } },\n ];\n};\n\nconst changed = (text: string, changes: readonly { start: number; end: number; text: string }[]): string =>\n [...changes].sort((a, b) => b.start - a.start).reduce((at, change) => `${at.slice(0, change.start)}${change.text}${at.slice(change.end)}`, text);\n\n// A head that was written before, put back as the document had it: what the\n// last screen said is taken out, and what the document gave up for it is given\n// back. A head never written comes back as it is.\nconst restored = (section: string): string =>\n changed(\n section,\n tagsOf(section).flatMap((tag) => {\n if (tag.name === 'template' && OWN_MARK in tag.attributes) return [{ start: tag.start, end: tag.end, text: tag.inner }];\n return HEAD_MARK in tag.attributes ? [{ start: tag.start, end: tag.end, text: '' }] : [];\n }),\n );\n\n// Elements, written into a head. `screen`: they are what a screen says — each\n// is marked, and a tag that gives up its place is kept for the page. Otherwise\n// they are the document's own from here on, and what they replace is gone.\nconst write = (section: string, elements: readonly HeadElement[], screen: boolean): string => {\n if (elements.length === 0) return section;\n const tags = tagsOf(section);\n const changes: { start: number; end: number; text: string }[] = [];\n const added: string[] = [];\n const own: string[] = [];\n for (const element of elements) {\n const key = headKeyOf(element);\n const [first, ...others] = key === undefined ? [] : tags.filter((tag) => keyOfTag(tag) === key);\n if (first === undefined) {\n added.push(markupOf(element, screen));\n continue;\n }\n changes.push({ start: first.start, end: first.end, text: markupOf(element, screen) });\n own.push(first.text);\n // said twice, the second would still say the old thing\n for (const other of others) {\n changes.push({ start: other.start, end: other.end, text: '' });\n own.push(other.text);\n }\n }\n if (screen && own.length > 0) added.push(`<template ${OWN_MARK}>${own.join('')}</template>`);\n\n const written = changed(section, changes);\n // What is added goes after the last thing in the head, a line each, indented\n // as that last thing is — or straight on, in a head written on one line.\n const tail = /\\s*$/.exec(written)?.[0] ?? '';\n const body = written.slice(0, written.length - tail.length);\n const indent = /(?:^|\\n)([ \\t]*)\\S[^\\n]*$/.exec(body)?.[1] ?? '';\n const lead = tail.includes('\\n') ? `\\n${indent}` : '';\n return `${body}${added.map((tag) => `${lead}${tag}`).join('')}${tail}`;\n};\n\nexport const placeHead = (html: string, elements: readonly HeadElement[] | undefined, place: HeadPlace = {}): string => {\n const opening = /<head\\b[^>]*>/i.exec(html);\n if (opening === null) return html;\n const from = opening.index + opening[0].length;\n const closing = html.slice(from).search(/<\\/head\\s*>/i);\n if (closing < 0) return html;\n // Where the document lives is the document's own, for this path: written\n // first and unmarked, so a screen that says an address of its own takes its\n // place — and gives it back.\n const located = write(restored(html.slice(from, from + closing)), addressOf(place), false);\n return `${html.slice(0, from)}${write(located, elements ?? [], true)}${html.slice(from + closing)}`;\n};\n","import { headKeyOf } from '../layout/head';\nimport type { HeadElement } from '../layout/head';\nimport { HEAD_MARK, OWN_MARK } from './place-head';\n\n// ═══════════════════════════════════════════════════════════\n// A page's <head>, kept on the screen.\n//\n// A drawn page arrives with its head written (`placeHead`). From then on the\n// shell is live and the screen moves without the page being fetched again, so\n// the head is kept on whatever the screen says now: its elements are put in\n// `document.head`, and taken out again when the screen stops saying them.\n//\n// THE DOCUMENT'S OWN TAGS GIVE WAY AND COME BACK. A tag the page was written\n// with — the title in index.html, its description — is taken out while the\n// screen says the same thing itself, and put back where it stood when the\n// screen no longer does. A drawn page has already given some up: they arrive\n// inert, in the <template data-nova-own> the writer left, and come back the\n// same way.\n//\n// A KEEPER THAT WAS NEVER HANDED AN ELEMENT NEVER WRITES. Two shells can share\n// a page (an inspector beside the app), and the one with nothing to say must\n// not touch what the other wrote — nor what the page arrived with.\n// ═══════════════════════════════════════════════════════════\n\nexport type HeadKeeper = (elements: readonly HeadElement[] | undefined) => void;\n\ntype Away = { key: string; node: Element; before: Node | null };\n\nconst TAGS = ['title', 'meta', 'link'];\n\n// What a tag standing in the page says, in the same terms as an element.\nconst keyOfNode = (node: Element): string | undefined => {\n const tag = TAGS.find((name) => name === node.tagName.toLowerCase());\n if (tag !== 'title' && tag !== 'meta' && tag !== 'link') return undefined;\n return headKeyOf({ tag, attributes: Object.fromEntries([...node.attributes].map((attribute) => [attribute.name, attribute.value])) });\n};\n\nexport const createHeadKeeper = (doc: Document): HeadKeeper => {\n // the screen's elements standing in the head\n let mine: Element[] = [];\n // the document's own tags that have given up their place\n let away: Away[] = [];\n let said: string | undefined;\n\n const built = (element: HeadElement): Element => {\n const node = doc.createElement(element.tag);\n for (const [name, value] of Object.entries(element.attributes)) node.setAttribute(name, value);\n node.setAttribute(HEAD_MARK, '');\n if (element.text !== undefined) node.textContent = element.text;\n return node;\n };\n\n // What the page arrived with: the elements a writer put there for the first\n // screen, and the tags that gave way to them.\n const adopt = (): void => {\n mine = [...doc.head.querySelectorAll(`[${HEAD_MARK}]`)];\n // the document's own window, not a global: a page's document is not always\n // the one the code was loaded in\n const view = doc.defaultView;\n for (const stash of doc.head.querySelectorAll(`template[${OWN_MARK}]`)) {\n if (view === null || !(stash instanceof view.HTMLTemplateElement)) continue;\n for (const child of [...stash.content.children]) {\n const key = keyOfNode(child);\n if (key !== undefined) away.push({ key, node: doc.importNode(child, true), before: null });\n }\n stash.remove();\n }\n };\n\n return (elements) => {\n const now = elements ?? [];\n const next = JSON.stringify(now);\n if (said === undefined) {\n if (now.length === 0) return;\n adopt();\n }\n if (next === said) return;\n said = next;\n\n for (const node of mine) node.remove();\n mine = now.map(built);\n const keys = new Set(now.flatMap((element) => headKeyOf(element) ?? []));\n\n // the document's own that now say what the screen says: out, each remembering where it stood\n for (const node of [...doc.head.children]) {\n const key = keyOfNode(node);\n if (key === undefined || !keys.has(key)) continue;\n away.push({ key, node, before: node.nextSibling });\n node.remove();\n }\n // Those the screen no longer says: back where each stood. The last to leave\n // goes back first — what stood after an earlier one may have left after it,\n // and has to be standing again for the earlier one to go in front of it.\n const [back, still] = [away.filter((gone) => !keys.has(gone.key)), away.filter((gone) => keys.has(gone.key))];\n for (const gone of [...back].reverse()) doc.head.insertBefore(gone.node, gone.before !== null && gone.before.parentNode === doc.head ? gone.before : null);\n away = still;\n\n doc.head.append(...mine);\n };\n};\n","import { renderNodeKey } from '@layout/adapter';\nimport type { ComponentRegistry, RenderNode } from '@layout/types';\nimport type { NovaEvent } from '@shared/event-bus/schemas';\nimport { headOf, isHeadNode, shellView } from '@shell';\nimport type { RenderApi, Shell } from '@shell';\nimport { createHeadKeeper } from '../../document/head-keeper';\n\n// ═══════════════════════════════════════════════════════════\n// @niscorp/nova/adapters/dom — a vanilla-DOM adapter, the platform sibling of\n// nova/react. It turns a served RenderNode tree into DOM: registry lookup →\n// element, recurse children, and wire events BY CONVENTION — a `ref`'d\n// element dispatches `ui:click`, a `model`'d element dispatches `ui:model`\n// (+ `ui:key`), the payload of a click is the node's `value` prop. Origin is\n// never stamped here — moss stamps the active instance server-side.\n//\n// No framework: the registry maps a component name to a function that builds\n// an element from props + already-rendered children. `CanvasSlot` is resolved\n// here (the frame's markers → per-canvas trees), the one piece of terminal\n// structure the renderer owns; the terminal hands in `canvasTree`/`dispatch`.\n//\n// WHAT DID NOT CHANGE IS NOT DRAWN AGAIN. The view keeps the tree it drew\n// beside the DOM that tree produced, and a render walks the two together: a\n// node that is the same as last time keeps its element — the same DOM node,\n// never taken off the page — and only what differs is built. An element that\n// stays keeps everything the tree does not hold: focus, scroll, selection, an\n// open <details>, a running animation, a timer its component started.\n// See packages/nova/ADAPTER.md for the shared adapter contract, and \"The DOM\n// adapter keeps what did not change\" there for the rules a kit can rely on.\n// ═══════════════════════════════════════════════════════════\n\nexport type DomComponentContext = {\n props: Record<string, unknown>;\n // the node's children, already rendered — the component appends them where\n // it wants (most append to their own element; leaves ignore them).\n children: Node[];\n // the dispatch in force here (canvas-scoped inside a CanvasSlot) — for\n // data-driven components with INTERNAL interactivity (a table's row clicks,\n // an inline checkbox); simple components ignore it and let the renderer wire\n // their `ref`/`model` by convention.\n dispatch: (event: NovaEvent) => void;\n // The other end of anything the component starts — a timer, an observer, a\n // subscription. `cleanup` runs once, when the element this call returns\n // leaves the page for good: it was removed, it was replaced because its own\n // props changed, or the view was destroyed. An element that stays is not\n // asked again, so what it started keeps running until then.\n onRemove: (cleanup: () => void) => void;\n // Say that what this component drew depends on its children — it marked\n // them, counted them, treated the first unlike the rest — rather than only\n // holding them. A component that only holds its children has them patched in\n // place under the element it returned; one that says this is asked again\n // whenever it would be handed different children, and is handed the ones that\n // stayed as it left them, so what it does to them it must be able to do twice.\n dependsOnChildren: () => void;\n};\n\n// A DOM component: props + rendered children in, one element out.\nexport type DomComponent = (ctx: DomComponentContext) => HTMLElement;\n\n// What the terminal hands the view: core's `RenderApi` (the frame, per-canvas\n// trees, a canvas-scoped dispatch, publish). Aliased, not redeclared, so the\n// dom adapter, the react adapter, and moss's terminal share ONE definition —\n// drift is impossible. CanvasSlot resolution + event routing ride these; the\n// renderer never touches the wire directly.\nexport type DomRenderApi = RenderApi;\n\nexport type DomView = {\n // (re)render from the current snapshot; call on every wire change\n render: () => void;\n destroy: () => void;\n};\n\nconst CANVAS_SLOT = 'CanvasSlot';\nconst ACTION_SLOT = 'ActionSlot';\n\ntype ComponentRenderNode = Extract<RenderNode, { type: 'component' }>;\ntype Dispatch = (event: NovaEvent) => void;\n\n// The recursion context: the registry, the dispatch in force (frame chrome\n// dispatches nothing; a CanvasSlot switches it to that canvas's), publish,\n// and the canvas resolver.\ntype Ctx = {\n registry: ComponentRegistry<DomComponent>;\n dispatch: Dispatch;\n api: DomRenderApi;\n // used when a component name is unregistered — a permissive renderer (the\n // html terminal's default kit) supplies one so unknown primitives render\n // their children instead of an error; strict consumers omit it.\n fallback?: DomComponent;\n};\n\n// One node of the tree as it was last drawn, beside the DOM it produced.\ntype Mount = {\n node: RenderNode;\n // the context this node's children are drawn in\n ctx: Ctx;\n // its top-level DOM nodes: one for a component, a text or an error; a\n // fragment has no element of its own, so its are its children's\n dom: Node[];\n kids: Mount[];\n // Where the kids' nodes can be patched in place: the element itself, when it\n // holds exactly them (`holdsExactly`), or a canvas's own host. `undefined`\n // when the component put them anywhere else — a change to which nodes it has\n // then asks the component again.\n host: HTMLElement | undefined;\n cleanups: (() => void)[];\n // a bound field that may not show what the tree says: it was typed in, or the\n // tree's value changed while it was being typed in\n field: { stale: boolean };\n};\n\nconst errorEl = (code: string, message: string): HTMLElement => {\n const el = document.createElement('div');\n el.setAttribute('data-nova-error', code);\n el.textContent = `${code}: ${message}`;\n return el;\n};\n\n// A tree is JSON, so sameness is structural.\nconst equal = (a: unknown, b: unknown): boolean => {\n if (Object.is(a, b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every((key) => Object.hasOwn(b, key) && equal(Reflect.get(a, key), Reflect.get(b, key)));\n};\n\nconst withoutValue = (props: Record<string, unknown>): Record<string, unknown> => {\n const { value: _value, ...rest } = props;\n return rest;\n};\n\nconst sameNodes = (a: Node[], b: Node[]): boolean => a.length === b.length && a.every((node, i) => node === b[i]);\n\n// (Plain indexed loops on purpose: this runs twice for every component on every\n// render, and measured in Chrome it is what a render of a long list spends its\n// time in. `flatMap` is slower once warm; `for…of` is twice as slow while cold,\n// which is when a first draw happens.)\nconst flat = (kids: Mount[]): Node[] => {\n const nodes: Node[] = [];\n for (let i = 0; i < kids.length; i += 1) {\n const dom = kids[i]?.dom ?? [];\n for (let j = 0; j < dom.length; j += 1) {\n const node = dom[j];\n if (node !== undefined) nodes.push(node);\n }\n }\n return nodes;\n};\n\nconst canvasIdOf = (node: ComponentRenderNode): string => {\n const canvasId = node.props['canvasId'];\n return typeof canvasId === 'string' ? canvasId : '';\n};\n\n// Which canvas or which instance a slot stands for. A different one in the\n// same place is a different screen, however alike the two look.\nconst slotOf = (node: ComponentRenderNode): unknown => {\n if (node.name === CANVAS_SLOT) return node.props['canvasId'];\n if (node.name === ACTION_SLOT) return node.props['instanceId'];\n return undefined;\n};\n\n// Core's `renderNodeKey` names a node among its siblings. Two siblings that\n// share a name (looped rows that share a `ref` and carry no key) are told\n// apart by which of them comes first.\nconst keyed = <T>(items: readonly T[], nodeOf: (item: T) => RenderNode): [string, T][] => {\n const seen = new Map<string, number>();\n return items.map((item, i) => {\n const key = renderNodeKey(nodeOf(item), i);\n const count = seen.get(key) ?? 0;\n seen.set(key, count + 1);\n return [count === 0 ? key : `${key}#${count}`, item];\n });\n};\n\n// Whether two nodes at the same index would be given the same key by core's\n// `renderNodeKey` — asked without building the key. Siblings mostly stay where\n// they are from one render to the next, and then nothing has to be looked up.\nconst samePlace = (a: RenderNode, b: RenderNode): boolean => {\n if (a.key !== undefined || b.key !== undefined) return a.key === b.key;\n if (a.type === 'component' && b.type === 'component') return a.ref !== undefined || b.ref !== undefined ? a.ref === b.ref : a.name === b.name;\n if (a.type === 'error' && b.type === 'error') return a.code === b.code;\n return a.type === b.type;\n};\n\nconst gathered = (nodes: Node[]): DocumentFragment => {\n const fragment = document.createDocumentFragment();\n for (const node of nodes) fragment.appendChild(node);\n return fragment;\n};\n\n// Whether a component's children can be patched where they stand: only when the\n// element it returned holds exactly the nodes it was handed, in order, and\n// nothing else. Then adding one, taking one out or moving one is what the\n// component would have drawn anyway. Anything else — a wrapper inside, a cell\n// around each, a heading of its own before them — and the adapter cannot know\n// what the component would do with one child more (a kit that wraps each child\n// looks, with a single child, exactly like one that wraps them all), so it asks.\n// What the shape of the element cannot show — a component that marks or counts\n// the children it holds — the component says itself (`dependsOnChildren`).\nconst holdsExactly = (el: Node, nodes: Node[]): boolean => nodes.length > 0 && el.childNodes.length === nodes.length && nodes.every((node, i) => el.childNodes[i] === node);\n\n// Of the nodes wanted, the longest run that already stands in the wanted order\n// — given where each stood before (-1: it is new). Those stay where they are\n// and the rest are put around them, so a reorder moves as few elements as it\n// can: taking an element out of the page, even to put it straight back,\n// restarts its animations and drops its scroll.\nconst standing = (stoodAt: number[]): Set<number> => {\n // ends[k]: the wanted index that ends the best run of length k + 1\n const ends: number[] = [];\n const before: number[] = [];\n stoodAt.forEach((stood, i) => {\n before[i] = -1;\n if (stood < 0) return;\n let lo = 0;\n let hi = ends.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if ((stoodAt[ends[mid] ?? 0] ?? 0) < stood) lo = mid + 1;\n else hi = mid;\n }\n before[i] = lo > 0 ? (ends[lo - 1] ?? -1) : -1;\n ends[lo] = i;\n });\n const run = new Set<number>();\n let at = ends[ends.length - 1] ?? -1;\n while (at >= 0) {\n run.add(at);\n at = before[at] ?? -1;\n }\n return run;\n};\n\n// Read the model value off an event target — a checkbox reports `checked`,\n// everything else `value`.\nconst readValue = (target: EventTarget | null): unknown => {\n if (target instanceof HTMLInputElement && target.type === 'checkbox') return target.checked;\n if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement) return target.value;\n return '';\n};\n\n// Attach the conventional listeners: a model'd element is an input (dispatch\n// ui:model on change, ui:key on keydown); a bare ref'd element is clickable\n// (dispatch ui:click, payload = its `value` prop). Uniform across every\n// component — the event vocabulary is the convention, not per-component code.\n//\n// The listeners close over the node they were wired for. That is safe because\n// an element is only ever kept for a node that says the same: a different\n// `ref`, `model`, or prop builds a new element with new listeners (a bound\n// field's `value` aside, which no listener reads).\nconst wireEvents = (el: HTMLElement, node: ComponentRenderNode, dispatch: Dispatch, field: { stale: boolean }): void => {\n if (node.model !== undefined) {\n const ref = node.model.ref;\n const wait = node.props['debounce'];\n const debounce = typeof wait === 'number' ? wait : 0;\n let pending: { value: unknown; timer: ReturnType<typeof setTimeout> } | undefined;\n const fire = (value: unknown): void => dispatch({ type: 'ui:model', ref, payload: value });\n el.addEventListener('input', (e) => {\n field.stale = true;\n const value = readValue(e.target);\n if (debounce <= 0) {\n fire(value);\n return;\n }\n if (pending !== undefined) clearTimeout(pending.timer);\n const timer = setTimeout(() => {\n pending = undefined;\n fire(value);\n }, debounce);\n pending = { value, timer };\n });\n // Leaving the field sends what was still waiting (ADAPTER.md, obligation 6).\n // Caught on the way down: blur does not bubble, and the field may sit\n // inside the component's element rather than be it.\n el.addEventListener(\n 'blur',\n () => {\n if (pending === undefined) return;\n clearTimeout(pending.timer);\n const { value } = pending;\n pending = undefined;\n fire(value);\n },\n true,\n );\n el.addEventListener('keydown', (e) => {\n if (e instanceof KeyboardEvent) dispatch({ type: 'ui:key', ref, key: e.key });\n });\n return;\n }\n if (node.ref !== undefined) {\n const ref = node.ref;\n el.addEventListener('click', (e) => {\n e.stopPropagation();\n const value = node.props['value'];\n dispatch(value === undefined ? { type: 'ui:click', ref } : { type: 'ui:click', ref, payload: value });\n });\n }\n};\n\n// The per-instance boundary a served tree carries. A list canvas renders\n// several live instances at once, so a click inside THIS boundary must reach\n// THIS instance: its events carry it as their origin (the server's\n// active-instance fallback only holds for a card-deck canvas). An event that\n// already has an origin keeps it — moss's react terminal does the same.\nconst inInstance = (node: RenderNode, ctx: Ctx): Ctx => {\n if (node.type !== 'component' || node.name !== ACTION_SLOT) return ctx;\n const instanceId = node.props['instanceId'];\n if (typeof instanceId !== 'string' || instanceId === '') return ctx;\n const outer = ctx.dispatch;\n return { ...ctx, dispatch: (event) => outer(event.origin === undefined ? { ...event, origin: instanceId } : event) };\n};\n\n// A field a person types in — where what is being typed must not be written\n// over. A checkbox or a radio has no \"being typed\": it is on or off, and the\n// tree's answer shows at once.\nconst isTypedIn = (el: Element | null): el is HTMLInputElement | HTMLTextAreaElement =>\n el instanceof HTMLTextAreaElement || (el instanceof HTMLInputElement && el.type !== 'checkbox' && el.type !== 'radio');\n\n// What such a field holds that is not in the tree: what is being typed, and\n// where the caret is.\ntype Typing = { value: string; start: number | null; end: number | null };\n\nconst typingIn = (el: Element | null): Typing | undefined => (isTypedIn(el) ? { value: el.value, start: el.selectionStart, end: el.selectionEnd } : undefined);\n\nconst placeCaret = (el: HTMLInputElement | HTMLTextAreaElement, typing: Typing): void => {\n try {\n el.setSelectionRange(typing.start ?? el.value.length, typing.end ?? el.value.length);\n } catch {\n /* selectionRange throws on some input types — harmless */\n }\n};\n\n// Where a node sits under `root`, as the child index at each level — and the\n// node that sits there. Markup drawn ahead of time and the first render over it\n// are the same elements in the same places, so this is how an element of the\n// one finds its twin in the other.\nconst placeUnder = (root: Node, node: Node): number[] | undefined => {\n const place: number[] = [];\n let at: Node = node;\n while (at !== root) {\n const parent = at.parentNode;\n if (parent === null) return undefined;\n const child = at;\n place.unshift([...parent.childNodes].findIndex((sibling) => sibling === child));\n at = parent;\n }\n return place;\n};\n\nconst nodeUnder = (root: Node, place: number[]): Node | undefined => place.reduce<Node | undefined>((at, index) => at?.childNodes[index], root);\n\nexport const createDomView = (\n root: HTMLElement,\n registry: ComponentRegistry<DomComponent>,\n api: DomRenderApi,\n options: { fallback?: DomComponent } = {},\n): DomView => {\n // The frame dispatches nothing (chrome); only a CanvasSlot's subtree does.\n const top: Ctx = { registry, dispatch: () => undefined, api, ...(options.fallback !== undefined ? { fallback: options.fallback } : {}) };\n let mounts: Mount[] = [];\n // Whatever is in the root before the first render is not this view's: markup\n // that arrived with the page is replaced by the first render, once.\n let drawn = false;\n // Counts every node built and every write to the page, so a component can\n // tell \"nothing below me changed\" from \"something did\".\n let writes = 0;\n // Focus is the element's, so it follows the element: `from` held it when the\n // render began, `to` is what was built in its place if it had to be.\n const refocus: { from: Element | null; to: HTMLElement | undefined } = { from: null, to: undefined };\n // a bound component's field state (Mount.field), found from its element\n const fields = new WeakMap<Node, { stale: boolean }>();\n\n const builderOf = (node: ComponentRenderNode, ctx: Ctx): DomComponent | undefined => ctx.registry.get(node.name)?.component ?? ctx.fallback;\n\n const leaf = (node: RenderNode, ctx: Ctx, el: Node): Mount => ({ node, ctx, dom: [el], kids: [], host: undefined, cleanups: [], field: { stale: false } });\n\n // The element is going: whatever its component started stops. Its kids are\n // not touched — they may be living on under the element built in its place.\n const leave = (mount: Mount): void => {\n if (mount.cleanups.length === 0) return;\n for (const cleanup of mount.cleanups.splice(0)) cleanup();\n };\n\n const drop = (mount: Mount): void => {\n leave(mount);\n for (const kid of mount.kids) drop(kid);\n };\n\n // Ask the component for its element. Children go in as they always have: one\n // Node per child, a fragment child (a loop) as a DocumentFragment. Kids that\n // were on the page already are moved into the new element by the component.\n const assemble = (node: ComponentRenderNode, ctx: Ctx, kids: Mount[], replaced?: Mount): Mount => {\n if (replaced !== undefined) leave(replaced);\n const builder = builderOf(node, ctx);\n if (builder === undefined) {\n for (const kid of kids) drop(kid);\n return leaf(node, ctx, errorEl('COMPONENT_NOT_FOUND', node.name));\n }\n // a head among them draws nothing, so the component is not handed one\n const children = kids.filter((kid) => !isHeadNode(kid.node)).map((kid): Node => {\n const [only] = kid.dom;\n if (kid.node.type !== 'fragment' && only !== undefined) return only;\n const fragment = document.createDocumentFragment();\n fragment.append(...kid.dom);\n return fragment;\n });\n const cleanups: (() => void)[] = [];\n const field = { stale: false };\n let holdsOnly = true;\n writes += 1;\n const el = builder({\n props: node.props,\n children,\n dispatch: ctx.dispatch,\n onRemove: (cleanup) => void cleanups.push(cleanup),\n dependsOnChildren: () => {\n holdsOnly = false;\n },\n });\n el.setAttribute('data-component', node.name);\n if (node.ref !== undefined) el.setAttribute('data-ref', node.ref);\n wireEvents(el, node, ctx.dispatch, field);\n if (node.model !== undefined) fields.set(el, field);\n if (replaced !== undefined && refocus.from !== null && replaced.dom[0] === refocus.from) refocus.to = el;\n return { node, ctx, dom: [el], kids, host: holdsOnly && holdsExactly(el, flat(kids)) ? el : undefined, cleanups, field };\n };\n\n const build = (node: RenderNode, parent: Ctx): Mount => {\n const ctx = inInstance(node, parent);\n writes += 1;\n if (node.type === 'text') return leaf(node, ctx, document.createTextNode(node.value));\n if (node.type === 'error') return leaf(node, ctx, errorEl(node.code, node.message));\n if (node.type === 'fragment') {\n const kids = node.children.map((child) => build(child, ctx));\n return { node, ctx, dom: flat(kids), kids, host: undefined, cleanups: [], field: { stale: false } };\n }\n if (node.name === CANVAS_SLOT) {\n const canvasId = canvasIdOf(node);\n const host = document.createElement('div');\n host.setAttribute('data-canvas', canvasId);\n // Switch dispatch to this canvas's; the server stamps origin, so the\n // terminal just tags the canvas.\n const canvasCtx: Ctx = { ...ctx, dispatch: (event) => ctx.api.dispatch(canvasId, event) };\n const kids = canvasId === '' ? [] : ctx.api.canvasTree(canvasId).map((child) => build(child, canvasCtx));\n host.append(...flat(kids));\n return { node, ctx: canvasCtx, dom: [host], kids, host, cleanups: [], field: { stale: false } };\n }\n // A head is the document's, not the screen's: no element, for it or for what it holds.\n if (isHeadNode(node)) return { node, ctx, dom: [], kids: [], host: undefined, cleanups: [], field: { stale: false } };\n if (builderOf(node, ctx) === undefined) return leaf(node, ctx, errorEl('COMPONENT_NOT_FOUND', node.name));\n return assemble(node, ctx, node.children.map((child) => build(child, ctx)));\n };\n\n // Make `host` hold `after` where it held `before`: what left is taken out,\n // what is new is put in, and a node that already stands where it belongs is\n // not touched. The writes are as few as they can be: nodes that go in side by\n // side go in together, and a host none of whose nodes stay is refilled in one.\n const place = (host: HTMLElement, before: Node[], after: Node[]): void => {\n if (sameNodes(before, after)) return;\n const wanted = new Set(after);\n if (host.childNodes.length === before.length && !before.some((node) => wanted.has(node))) {\n host.replaceChildren(gathered(after));\n writes += 1;\n return;\n }\n for (const node of before) {\n if (wanted.has(node) || node.parentNode !== host) continue;\n host.removeChild(node);\n writes += 1;\n }\n const stoodAt = new Map(before.map((node, i) => [node, i]));\n const stays = standing(after.map((node) => stoodAt.get(node) ?? -1));\n // right to left: what goes in between two nodes that stay is gathered, and\n // put in before the one on its right\n let anchor: Node | null = null;\n let run: Node[] = [];\n const putIn = (): void => {\n const [only] = run;\n if (only === undefined) return;\n host.insertBefore(run.length === 1 ? only : gathered(run.reverse()), anchor);\n writes += 1;\n run = [];\n };\n for (let i = after.length - 1; i >= 0; i -= 1) {\n const node = after[i];\n if (node === undefined) continue;\n if (stays.has(i)) {\n putIn();\n anchor = node;\n } else run.push(node);\n }\n putIn();\n };\n\n // Siblings are matched by key. A match is patched, a node with no match is\n // built, and what was drawn and has no match any more is let go.\n const reconcile = (olds: Mount[], nexts: readonly RenderNode[], ctx: Ctx): Mount[] => {\n // the usual case: the same siblings in the same places\n if (olds.length === nexts.length && olds.every((old, i) => samePlace(old.node, nexts[i] ?? old.node))) {\n return olds.map((old, i) => patch(old, nexts[i] ?? old.node, ctx));\n }\n const drawnBy = new Map(keyed(olds, (old) => old.node));\n const kids = keyed(nexts, (next) => next).map(([key, next]) => {\n const old = drawnBy.get(key);\n if (old === undefined) return build(next, ctx);\n drawnBy.delete(key);\n return patch(old, next, ctx);\n });\n for (const gone of drawnBy.values()) drop(gone);\n return kids;\n };\n\n const patch = (old: Mount, next: RenderNode, parent: Ctx): Mount => {\n const prev = old.node;\n const afresh = (): Mount => {\n drop(old);\n return build(next, parent);\n };\n if (prev.type === 'text' && next.type === 'text') {\n const [node] = old.dom;\n if (prev.value !== next.value && node !== undefined) {\n node.nodeValue = next.value;\n writes += 1;\n }\n old.node = next;\n return old;\n }\n if (prev.type === 'fragment' && next.type === 'fragment') {\n // no element of its own: the host above it puts its nodes in place\n old.kids = reconcile(old.kids, next.children, old.ctx);\n old.dom = flat(old.kids);\n old.node = next;\n return old;\n }\n if (prev.type !== 'component' || next.type !== 'component') return equal(prev, next) ? old : afresh();\n // A different component, or a different canvas or instance in the same\n // place: nothing of the old one is kept. Its listeners dispatch as the old\n // instance; kept, a press would reach an instance that is no longer here.\n if (prev.name !== next.name || !Object.is(slotOf(prev), slotOf(next))) return afresh();\n\n if (isHeadNode(next)) {\n old.node = next;\n return old;\n }\n\n if (next.name === CANVAS_SLOT) {\n const host = old.host;\n if (host === undefined) return afresh();\n const canvasId = canvasIdOf(next);\n const before = flat(old.kids);\n old.kids = reconcile(old.kids, canvasId === '' ? [] : old.ctx.api.canvasTree(canvasId), old.ctx);\n place(host, before, flat(old.kids));\n old.node = next;\n return old;\n }\n\n const [el] = old.dom;\n if (el === undefined) return afresh();\n let own = equal(prev.props, next.props) && prev.ref === next.ref && equal(prev.model, next.model);\n if (next.model !== undefined) {\n const active = el.ownerDocument?.activeElement ?? null;\n if (isTypedIn(active) && el.contains(active)) {\n // WHILE A BOUND FIELD IS BEING TYPED IN, what the person is typing wins\n // over the tree (ADAPTER.md, obligation 6) — so a tree that differs only\n // in the field's value is not a reason to build another field. The one\n // being typed in stays, with its caret, its composition and its pending\n // debounce; it is marked as showing something the tree does not say.\n if (!own && prev.ref === next.ref && equal(prev.model, next.model) && equal(withoutValue(prev.props), withoutValue(next.props))) {\n old.field.stale = true;\n own = true;\n }\n } else if (old.field.stale) {\n // Released — or never a field one types in (a checkbox that was\n // pressed): the tree's value is the field's again. How a value is shown\n // is the kit's business, so the kit is asked for the field afresh.\n own = false;\n }\n }\n\n // what the component was handed, child by child — asked only of one that\n // did something of its own with its children\n const handed = old.host === undefined ? old.kids.map((kid) => kid.dom) : undefined;\n const before = flat(old.kids);\n const mark = writes;\n const kids = reconcile(old.kids, next.children, old.ctx);\n const after = flat(kids);\n const kept = (): Mount => {\n old.kids = kids;\n old.node = next;\n return old;\n };\n if (own) {\n if (old.host !== undefined) {\n // Its element holds exactly its children's nodes, so they are put in\n // place there. (Down to none at all is left to the component: it may\n // draw itself differently when empty.)\n if (after.length > 0) {\n place(old.host, before, after);\n return kept();\n }\n } else if (handed !== undefined && handed.length === kids.length && kids.every((kid, i) => sameNodes(handed[i] ?? [], kid.dom))) {\n // It did something of its own with its children, and it would be handed\n // the same nodes, child for child, so it would draw the same. Whatever\n // changed further down was patched where it stands — which is on the\n // page only if this component put its children on the page.\n if (writes === mark || after.every((node) => el.contains(node))) return kept();\n }\n }\n // Its own props changed, or its children changed where they cannot be\n // reached: ask the component again. What is below was reconciled all the\n // same, so a descendant that did not change is the same node in the new\n // element — moved, not rebuilt.\n return assemble(next, old.ctx, kids, old);\n };\n\n const render = (): void => {\n const doc = root.ownerDocument;\n const active = doc.activeElement !== null && root.contains(doc.activeElement) ? doc.activeElement : null;\n const typing = typingIn(active);\n // The first render replaces markup that arrived with the page. Somebody may\n // already be in it — in a field, typing — so where they are is noted, to be\n // found again in the elements drawn over it.\n const adopted = !drawn && active !== null ? placeUnder(root, active) : undefined;\n refocus.from = active;\n refocus.to = undefined;\n if (!drawn) root.replaceChildren();\n drawn = true;\n const before = flat(mounts);\n mounts = reconcile(mounts, api.frame(), top);\n place(root, before, flat(mounts));\n const twin = adopted === undefined ? undefined : nodeUnder(root, adopted);\n // An element that stayed where it was still has focus. One that was moved\n // lost it in the move, and one that was built again never had it: give it\n // back — and to a field built again, what was being typed in the one it\n // replaced, because the in-progress value wins over the tree's.\n const rebuilt = refocus.to ?? (twin instanceof HTMLElement && twin.tagName === active?.tagName ? twin : undefined);\n const target = rebuilt ?? (active instanceof HTMLElement && active.isConnected ? active : undefined);\n refocus.from = null;\n refocus.to = undefined;\n if (target === undefined || doc.activeElement === target) return;\n if (rebuilt !== undefined && typing !== undefined && isTypedIn(target)) {\n target.value = typing.value;\n const field = fields.get(target);\n if (field !== undefined) field.stale = true;\n }\n target.focus({ preventScroll: true });\n if (typing !== undefined && isTypedIn(target)) placeCaret(target, typing);\n };\n\n const destroy = (): void => {\n for (const mount of mounts) drop(mount);\n mounts = [];\n drawn = false;\n root.replaceChildren();\n };\n\n return { render, destroy };\n};\n\n// A SHELL THAT LIVES IN THIS PAGE, drawn into `root` and kept current: the\n// shell's own view (`shellView`), this adapter over it, and a render on every\n// change — which touches only what that change touched. The whole of a browser\n// entry for an app whose shell runs in the browser:\n//\n// mountShell(root, registry, await boot());\n//\n// A `root` that already holds the same screen as markup — drawn ahead of time\n// by `renderToString` (./server) from the same boot — is picked up by the first\n// render: it replaces those elements with the same elements in one step, so\n// nothing can disagree with them. From the second render on, elements stay.\nexport const mountShell = (\n root: HTMLElement,\n registry: ComponentRegistry<DomComponent>,\n shell: Shell,\n options: { fallback?: DomComponent } = {},\n): { destroy: () => void } => {\n const view = shellView(shell);\n // ONE READING OF THE SHELL PER RENDER. The view draws from it and the page's\n // head is read off the same trees, so keeping the head costs a walk over\n // what was just drawn and never a second render of the shell.\n let read: { frame?: RenderNode[]; trees: Map<string, RenderNode[]> } = { trees: new Map() };\n const api: DomRenderApi = {\n ...view.api,\n frame: () => (read.frame ??= view.api.frame()),\n canvasTree: (canvasId) => {\n const held = read.trees.get(canvasId);\n if (held !== undefined) return held;\n const tree = view.api.canvasTree(canvasId);\n read.trees.set(canvasId, tree);\n return tree;\n },\n };\n const dom = createDomView(root, registry, api, options);\n const keepHead = createHeadKeeper(root.ownerDocument);\n const render = (): void => {\n read = { trees: new Map() };\n dom.render();\n // a root that is not on a page has no head to keep\n if (root.isConnected) keepHead(headOf(api)?.elements);\n };\n render();\n const stop = view.subscribe(render);\n return {\n destroy: () => {\n stop();\n dom.destroy();\n },\n };\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/layout/adapter.ts","../../../src/layout/head.ts","../../../src/shell/slot-names.ts","../../../src/shell/head.ts","../../../src/shell/view.ts","../../../src/document/place-head.ts","../../../src/document/head-keeper.ts","../../../src/adapters/dom/index.ts"],"names":["TAGS","before"],"mappings":";;;AAkBO,IAAM,aAAA,GAAgB,CAAC,IAAA,EAAkB,KAAA,KAA0B;AACxE,EAAA,IAAI,KAAK,GAAA,KAAQ,MAAA,EAAW,OAAO,CAAA,EAAA,EAAK,KAAK,GAAG,CAAA,CAAA;AAChD,EAAA,IAAI,IAAA,CAAK,SAAS,WAAA,EAAa;AAC7B,IAAA,IAAI,KAAK,GAAA,KAAQ,MAAA,EAAW,OAAO,CAAA,EAAA,EAAK,KAAK,GAAG,CAAA,CAAA;AAChD,IAAA,OAAO,CAAA,EAAA,EAAK,IAAA,CAAK,IAAI,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AAAA,EAChC;AACA,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,MAAA,EAAQ,OAAO,KAAK,KAAK,CAAA,CAAA;AAC3C,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,UAAA,EAAY,OAAO,KAAK,KAAK,CAAA,CAAA;AAC/C,EAAA,OAAO,CAAA,EAAA,EAAK,IAAA,CAAK,IAAI,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AAChC,CAAA;;;ACIO,IAAM,SAAA,GAAY,WAAA;AAClB,IAAM,eAAA,GAAkB,YAAA;AACxB,IAAM,cAAA,GAAiB,WAAA;AACvB,IAAM,cAAA,GAAiB,WAAA;AACvB,IAAM,gBAAA,GAAmB,aAAA;AAmBzB,IAAM,SAAA,GAAY,CAAC,OAAA,KAAyE;AACjG,EAAA,MAAM,IAAA,GAAO,CAAC,IAAA,KAAqC;AACjD,IAAA,MAAM,KAAA,GAAQ,OAAO,OAAA,CAAQ,OAAA,CAAQ,UAAU,CA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;AAAA,IACR,OAAO,MAAO,IAAA,CAAK,KAAA,KAAU,IAAA,CAAK,IAAI,KAAA,EAAM;AAAA,IAC5C,UAAA,EAAY,CAAC,QAAA,KAAa;AACxB,MAAA,MAAM,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,QAAQ,CAAA;AACpC,MAAA,IAAI,IAAA,KAAS,QAAW,OAAO,IAAA;AAC/B,MAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,CAAI,UAAA,CAAW,QAAQ,CAAA;AACzC,MAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,QAAA,EAAU,IAAI,CAAA;AAC7B,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,GACF;AACA,EAAA,MAAM,GAAA,GAAM,aAAA,CAAc,IAAA,EAAM,QAAA,EAAU,KAAK,OAAO,CAAA;AACtD,EAAA,MAAM,QAAA,GAAW,gBAAA,CAAiB,IAAA,CAAK,aAAa,CAAA;AACpD,EAAA,MAAM,SAAS,MAAY;AACzB,IAAA,IAAA,GAAO,EAAE,KAAA,kBAAO,IAAI,GAAA,EAAI,EAAE;AAC1B,IAAA,GAAA,CAAI,MAAA,EAAO;AAEX,IAAA,IAAI,KAAK,WAAA,EAAa,QAAA,CAAS,MAAA,CAAO,GAAG,GAAG,QAAQ,CAAA;AAAA,EACtD,CAAA;AACA,EAAA,MAAA,EAAO;AACP,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,SAAA,CAAU,MAAM,CAAA;AAClC,EAAA,OAAO;AAAA,IACL,SAAS,MAAM;AACb,MAAA,IAAA,EAAK;AACL,MAAA,GAAA,CAAI,OAAA,EAAQ;AAAA,IACd;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["import type { RenderNode } from './types';\n\n// ═══════════════════════════════════════════════════════════\n// Adapter helpers — framework-agnostic pieces every adapter\n// (React, Vue, …) needs to render a RenderNode tree the same\n// way. See packages/nova/ADAPTER.md for the full contract.\n// ═══════════════════════════════════════════════════════════\n\n// Names of the props an adapter injects on rendered components:\n// `RenderNode.model` → NOVA_MODEL_PROP ({ ref, path }),\n// `RenderNode.ref` → NOVA_REF_PROP (string). Constants so all\n// adapters inject identically and components can rely on them.\nexport const NOVA_MODEL_PROP = 'novaModel';\nexport const NOVA_REF_PROP = 'novaRef';\n\n// Stable identity for a RenderNode within its sibling list.\n// Loop identity (stamped from LoopNode.key/index) wins over ref: a shared\n// `ref` across looped rows is an event-target id, not a list key.\nexport const renderNodeKey = (node: RenderNode, index: number): string => {\n if (node.key !== undefined) return `k:${node.key}`;\n if (node.type === 'component') {\n if (node.ref !== undefined) return `c:${node.ref}`;\n return `c:${node.name}:${index}`;\n }\n if (node.type === 'text') return `t:${index}`;\n if (node.type === 'fragment') return `f:${index}`;\n return `e:${node.code}:${index}`;\n};\n","// ═══════════════════════════════════════════════════════════\n// THE HEAD — `nova:head` is the document's <head>, as a node in a layout.\n//\n// A document has a part nobody sees on the screen: its title, the sentence\n// that describes it, the card shown where a link to it is pasted. That part\n// is written the way the rest of the screen is — a layout node, its children\n// bound to the action's data — and travels the way the rest does, in the\n// render tree.\n//\n// Its children are the elements a head holds, named as HTML names them:\n// `nova:title`, `nova:meta`, `nova:link`, `nova:script`. A child's props are\n// that element's ATTRIBUTES, written as given. Nova keeps no list of them, so\n// any `name`, `property` or `rel` there is — or will be — can be said without\n// nova learning it.\n//\n// Nothing here is drawn on the screen. No adapter builds an element for a head\n// or for anything in it, and no registry has to hold the names. Whoever writes\n// the document reads the elements off the tree (`headOf`) and writes them into\n// its <head>.\n//\n// WHAT A HEAD DOES NOT HOLD is what runs or styles: a script that executes, a\n// stylesheet, a <base>, an instruction to the browser (`http-equiv`), a handler\n// attribute. A layout is data, and data that reaches every page must not be\n// able to run. Those stay in the app's own index.html, which holds anything.\n//\n// This file holds no schema on purpose: a terminal that only reads a head off\n// the wire needs the names and the shape, and nothing to validate with.\n// ═══════════════════════════════════════════════════════════\n\n// Namespaced as a package's own in-layout components are (`loom:field`), so\n// none can be a name an app's kit already uses for something else.\nexport const HEAD_NAME = 'nova:head';\nexport const HEAD_TITLE_NAME = 'nova:title';\nexport const HEAD_META_NAME = 'nova:meta';\nexport const HEAD_LINK_NAME = 'nova:link';\nexport const HEAD_SCRIPT_NAME = 'nova:script';\n\n// The head and what it holds: the names a layout may use with no registry\n// entry behind them.\nexport const HEAD_NAMES: readonly string[] = [HEAD_NAME, HEAD_TITLE_NAME, HEAD_META_NAME, HEAD_LINK_NAME, HEAD_SCRIPT_NAME];\n\n// One element of a head, as data: what to write, wherever a head is written.\nexport type HeadElement = {\n tag: 'title' | 'meta' | 'link' | 'script';\n // as the layout gave them, in the order it gave them\n attributes: Record<string, string>;\n // a title's words; a script's data, as JSON\n text?: string;\n};\n\n// What two elements both say, when they say the same thing — the later one\n// then takes the earlier one's place. A document has one title, one <meta> of\n// a given name or property, one canonical address. Anything else stands beside\n// its like: two alternates, two data blocks.\nexport const headKeyOf = (element: Pick<HeadElement, 'tag' | 'attributes'>): string | undefined => {\n const said = (name: string): string | undefined => {\n const found = Object.entries(element.attributes).find(([key]) => key.toLowerCase() === name)?.[1].trim().toLowerCase();\n return found === undefined || found === '' ? undefined : found;\n };\n if (element.tag === 'title') return 'title';\n if (element.tag === 'meta') {\n const [name, property] = [said('name'), said('property')];\n if (name !== undefined) return `meta name ${name}`;\n return property === undefined ? undefined : `meta property ${property}`;\n }\n if (element.tag === 'link') return (said('rel') ?? '').split(/\\s+/).includes('canonical') ? 'link canonical' : undefined;\n return undefined;\n};\n","// ═══════════════════════════════════════════════════════════\n// Slot component name constants.\n//\n// Every framework adapter (React, future Vue/Svelte/etc.) must\n// register components under these names in its ComponentRegistry\n// to participate in shell/canvas layout rendering:\n//\n// CANVAS_SLOT_NAME — renders a canvas by id (props: canvasId?)\n// ACTION_SLOT_NAME — renders an action instance by id (props: instanceId?)\n//\n// The shell uses these names in its default layouts and when\n// flattening a render tree for non-React consumers (evaluators,\n// export, testing), so they are part of the package's public\n// contract — not React-only.\n// ═══════════════════════════════════════════════════════════\n\nexport const CANVAS_SLOT_NAME = 'CanvasSlot';\nexport const ACTION_SLOT_NAME = 'ActionSlot';\n","import { HEAD_LINK_NAME, HEAD_META_NAME, HEAD_NAME, HEAD_SCRIPT_NAME, HEAD_TITLE_NAME, headKeyOf } from '../layout/head';\nimport type { HeadElement } from '../layout/head';\nimport type { RenderNode } from '../layout';\nimport type { RenderApi } from './types';\nimport { ACTION_SLOT_NAME, CANVAS_SLOT_NAME } from './slot-names';\n\n// ═══════════════════════════════════════════════════════════\n// The head a screen has, read off its render tree.\n//\n// The frame is walked in the order it is drawn, into each canvas where its\n// slot stands and into each instance on it, and every `nova:head` it meets\n// gives its elements in turn. A screen can hold more than one head — the\n// shell's chrome says what holds on every screen, an action says its own, a\n// dialog opens over a page. An element that says the same thing as an earlier\n// one (the title, a <meta> of that name) takes its place; anything else stands\n// beside what came before.\n//\n// What a head may not hold is refused here, once, for every writer: the\n// element is left out and the reason is given. See ../layout/head.\n// ═══════════════════════════════════════════════════════════\n\nexport type ScreenHead = {\n // what the document's head is to hold, in the order the screen said it\n elements: HeadElement[];\n // the actions whose instances said any of it (none: only the shell's chrome did)\n actions: string[];\n // what a head held that it may not — left out, each with why\n refused: string[];\n};\n\ntype ComponentNode = Extract<RenderNode, { type: 'component' }>;\ntype Read = { element: HeadElement } | { refused: string } | undefined;\n\nconst ATTRIBUTE_NAME = /^[A-Za-z][A-Za-z0-9:._-]*$/;\n// a data block: a type no browser runs\nconst DATA_TYPE = /^application\\/([a-z0-9.-]+\\+)?json$/i;\n\n// A prop, as the attribute it is written as — or nothing, when it says nothing.\nconst written = (value: unknown): string | undefined => {\n if (typeof value === 'string') return value.trim() === '' ? undefined : value;\n if (typeof value === 'number') return String(value);\n return value === true ? '' : undefined;\n};\n\n// An element's attributes, from its props — or why it may not be written.\nconst attributesOf = (what: string, props: Record<string, unknown>, skip: readonly string[] = []): { attributes: Record<string, string> } | { refused: string } => {\n const attributes: Record<string, string> = {};\n for (const [name, value] of Object.entries(props)) {\n if (skip.includes(name)) continue;\n if (!ATTRIBUTE_NAME.test(name)) return { refused: `${what}: \"${name}\" is not an attribute’s name` };\n if (/^on/i.test(name)) return { refused: `${what}: \\`${name}\\` is a handler, and a layout does not run` };\n const text = written(value);\n if (text !== undefined) attributes[name] = text;\n }\n return { attributes };\n};\n\nconst has = (attributes: Record<string, string>, name: string): boolean => Object.keys(attributes).some((key) => key.toLowerCase() === name);\nconst valueOf = (attributes: Record<string, string>, name: string): string => Object.entries(attributes).find(([key]) => key.toLowerCase() === name)?.[1] ?? '';\n\nconst textOf = (nodes: readonly RenderNode[]): string =>\n nodes.map((node) => (node.type === 'text' ? node.value : node.type === 'fragment' ? textOf(node.children) : '')).join('');\n\nconst titleOf = (node: ComponentNode): Read => {\n const text = textOf(node.children).trim();\n return text === '' ? undefined : { element: { tag: 'title', attributes: {}, text } };\n};\n\nconst metaOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_META_NAME, node.props);\n if ('refused' in read) return read;\n if (has(read.attributes, 'http-equiv')) return { refused: `${HEAD_META_NAME}: \\`http-equiv\\` instructs the browser, and a layout does not` };\n // nothing to say yet: its value is not answered\n return has(read.attributes, 'content') ? { element: { tag: 'meta', attributes: read.attributes } } : undefined;\n};\n\nconst linkOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_LINK_NAME, node.props);\n if ('refused' in read) return read;\n if (valueOf(read.attributes, 'rel').toLowerCase().split(/\\s+/).includes('stylesheet')) return { refused: `${HEAD_LINK_NAME}: a stylesheet styles the page, and a layout does not` };\n return has(read.attributes, 'href') ? { element: { tag: 'link', attributes: read.attributes } } : undefined;\n};\n\nconst scriptOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_SCRIPT_NAME, node.props, ['data']);\n if ('refused' in read) return read;\n if (has(read.attributes, 'src')) return { refused: `${HEAD_SCRIPT_NAME}: a script with a \\`src\\` runs, and a layout does not` };\n const type = valueOf(read.attributes, 'type');\n if (!DATA_TYPE.test(type)) return { refused: `${HEAD_SCRIPT_NAME}: only a data block may be written (a JSON \\`type\\`), and \"${type}\" is not one` };\n const data = node.props['data'];\n if (data === undefined || data === null || data === '') return undefined;\n return { element: { tag: 'script', attributes: read.attributes, text: JSON.stringify(data) } };\n};\n\nconst READERS: Record<string, (node: ComponentNode) => Read> = {\n [HEAD_TITLE_NAME]: titleOf,\n [HEAD_META_NAME]: metaOf,\n [HEAD_LINK_NAME]: linkOf,\n [HEAD_SCRIPT_NAME]: scriptOf,\n};\n\nexport const isHeadNode = (node: RenderNode): boolean => node.type === 'component' && node.name === HEAD_NAME;\n\nexport const headOf = (api: Pick<RenderApi, 'frame' | 'canvasTree'>): ScreenHead | undefined => {\n let heads = 0;\n const said: { element: HeadElement; action: string | undefined }[] = [];\n const refused: string[] = [];\n // a canvas whose own tree names it again would never end\n const open = new Set<string>();\n\n const hold = (nodes: readonly RenderNode[], action: string | undefined): void => {\n for (const node of nodes) {\n if (node.type === 'fragment') {\n hold(node.children, action);\n continue;\n }\n if (node.type === 'error') {\n refused.push(`${HEAD_NAME}: ${node.message}`);\n continue;\n }\n // text between a head's elements is nothing\n if (node.type !== 'component') continue;\n const read = READERS[node.name];\n if (read === undefined) {\n refused.push(`${HEAD_NAME}: \"${node.name}\" is not something a head holds`);\n continue;\n }\n const found = read(node);\n if (found === undefined) continue;\n if ('refused' in found) {\n refused.push(found.refused);\n continue;\n }\n const key = headKeyOf(found.element);\n const earlier = key === undefined ? -1 : said.findIndex((other) => headKeyOf(other.element) === key);\n if (earlier >= 0) said.splice(earlier, 1);\n said.push({ element: found.element, action });\n }\n };\n\n const walk = (nodes: readonly RenderNode[], action: string | undefined): void => {\n for (const node of nodes) {\n if (node.type === 'fragment') {\n walk(node.children, action);\n continue;\n }\n if (node.type !== 'component') continue;\n if (node.name === HEAD_NAME) {\n heads += 1;\n hold(node.children, action);\n continue;\n }\n if (node.name === CANVAS_SLOT_NAME) {\n const canvasId = node.props['canvasId'];\n if (typeof canvasId !== 'string' || canvasId === '' || open.has(canvasId)) continue;\n open.add(canvasId);\n walk(api.canvasTree(canvasId), undefined);\n open.delete(canvasId);\n continue;\n }\n const definitionId = node.name === ACTION_SLOT_NAME ? node.props['definitionId'] : undefined;\n walk(node.children, typeof definitionId === 'string' ? definitionId : action);\n }\n };\n\n walk(api.frame(), undefined);\n if (heads === 0) return undefined;\n const actions = [...new Set(said.flatMap((one) => (one.action === undefined ? [] : [one.action])))];\n return { elements: said.map((one) => one.element), actions, refused };\n};\n","import type { RenderNode } from '../layout';\nimport type { RenderApi, Shell } from './types';\nimport { isHeadNode } from './head';\nimport { chainsInFlight } from './chains';\nimport { ACTION_SLOT_NAME } from './slot-names';\n\n// ═══════════════════════════════════════════════════════════\n// A shell, as something an adapter draws.\n//\n// Every adapter that draws a SERVED screen draws it through `RenderApi` — the\n// frame, a tree per canvas, events up, messages across — and has always been\n// handed one by a transport (moss's socket wire). A shell that lives in the\n// same process as its adapter is the other case that type was written for, and\n// this is it: the shell's own trees, read as they stand, and its own dispatch.\n// The DOM and TTY adapters draw a local shell through this exactly as they draw\n// a remote one; nothing about them knows the difference.\n//\n// It is also what makes a shell DRAWABLE AHEAD OF TIME. A build runs the app's\n// own boot, waits for the screen to be whole (`shellSettled`), and has an\n// adapter draw this view to markup; the browser runs the same boot and draws\n// the same view over that markup. Where the shell lives was never the\n// adapter's business.\n// ═══════════════════════════════════════════════════════════\n\nexport type ShellView = {\n api: RenderApi;\n // Called after the shell changed — coalesced, so a burst of changes (a press\n // that sets three keys) is one call. Returns the unsubscribe.\n subscribe: (listener: () => void) => () => void;\n};\n\n// NO VISIBLE CONTENT IS AN EMPTY TREE. A canvas whose layout renders nothing but\n// empty text and empty wrappers is handed to an adapter as `[]`, so an adapter\n// collapses the chrome around it on `length` alone, knowing nothing about node\n// shapes. An ActionSlot marker is a boundary, not content — what is inside it\n// decides — and a head is the document's, not something the screen shows.\n// One rule for a canvas that is served and one that is local, so a frame looks\n// the same over both.\nexport const hasVisibleContent = (nodes: readonly RenderNode[]): boolean =>\n nodes.some((node) => {\n if (node.type === 'text') return node.value !== '';\n if (node.type === 'fragment') return hasVisibleContent(node.children);\n if (node.type === 'component' && node.name === ACTION_SLOT_NAME) return hasVisibleContent(node.children);\n if (isHeadNode(node)) return false;\n return true;\n });\n\n// One canvas, as an adapter is handed it.\nexport const canvasTreeOf = (shell: Shell, canvasId: string): RenderNode[] => {\n const tree = shell.flattenRenderTree(shell.getCanvasRenderTree(canvasId));\n return hasVisibleContent(tree) ? tree : [];\n};\n\nexport const shellView = (shell: Shell): ShellView => ({\n api: {\n frame: () => shell.getShellRenderTree(),\n canvasTree: (canvasId) => canvasTreeOf(shell, canvasId),\n // An event that names no origin belongs to the canvas's ACTIVE instance — on\n // a card deck that is the only one drawn. One that names its own (an\n // adapter stamps it at the instance boundary, `scopeDispatch`) keeps it. A\n // canvas with nothing mounted dispatches unstamped.\n dispatch: (canvasId, event) => {\n const active = shell.getState().canvases[canvasId]?.active;\n shell.dispatch(event.origin === undefined && active !== undefined ? { ...event, origin: active.id } : event);\n },\n publish: (channel, payload) => shell.publish(channel, payload),\n },\n subscribe: (listener) => {\n let pending = false;\n let stopped = false;\n const changed = (): void => {\n if (pending || stopped) return;\n pending = true;\n queueMicrotask(() => {\n pending = false;\n if (!stopped) listener();\n });\n };\n const offState = shell.onStateChange(changed);\n const offData = shell.onDataChange(changed);\n return () => {\n stopped = true;\n offState();\n offData();\n };\n },\n});\n\n// A WAIT ON THE SHELL, shared by the two below. Resolves `true` once `isBusy`\n// answers no and still answers no a macrotask later — a mount can open another\n// action, which starts initializing in turn, so the question is asked again on\n// every change. Resolves `false` when `waitMs` runs out first, or `stopped`\n// says to give up.\ntype ShellWaitOptions = { waitMs?: number; stopped?: () => boolean };\n\nconst shellQuietWithin = async (shell: Shell, isBusy: () => boolean, options: ShellWaitOptions): Promise<boolean> => {\n const waitMs = options.waitMs ?? DEFAULT_SETTLE_WAIT_MS;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<boolean>((resolve) => {\n timer = setTimeout(() => resolve(false), waitMs);\n });\n const quiet = (async (): Promise<boolean> => {\n for (;;) {\n if (options.stopped?.() === true) return false;\n if (!isBusy()) {\n await new Promise<void>((resolve) => setTimeout(resolve, 0));\n if (!isBusy()) return true;\n }\n await new Promise<void>((resolve) => {\n const off = shell.onStateChange(() => {\n off();\n resolve();\n });\n // a change that lands with no notification must not leave this waiting\n setTimeout(() => {\n off();\n resolve();\n }, 10);\n });\n }\n })();\n const settled = await Promise.race([quiet, deadline]);\n clearTimeout(timer);\n return settled;\n};\n\nconst isMounting = (shell: Shell): boolean =>\n Object.values(shell.getState().canvases).some((canvas) => canvas.stack.some((instance) => instance.status === 'initializing'));\n\n// THE FIRST SCREEN IS WHOLE. An instance is `initializing` until its mount hook\n// — the loads, and whatever they chain to — has been awaited, so \"nothing is\n// initializing\" is the shell saying its opening screen is complete.\n//\n// Resolves `false` when `waitMs` runs out first: the screen is then drawn as it\n// stands, with whatever is still loading drawn as loading. Default 300ms — a\n// page should not hang on one slow endpoint.\n//\n// It asks about MOUNTS and nothing else, on purpose. A page is read whenever it\n// is asked for — also while a call somebody pressed minutes ago is still out —\n// and that read must not wait on it. `shellIdle` is the wider question.\nexport const DEFAULT_SETTLE_WAIT_MS = 300;\n\nexport const shellSettled = (shell: Shell, options: { waitMs?: number; stopped?: () => boolean } = {}): Promise<boolean> =>\n shellQuietWithin(shell, () => isMounting(shell), options);\n\n// NOTHING THE SHELL STARTED IS STILL RUNNING. Nothing is mounting, and no chain\n// is in flight (./chains.ts): no trigger's steps, no message on its way to its\n// listeners, no hook a navigation started. It is what a check awaits after it\n// presses something — the call the press made has answered, what that chained\n// to has run, and an action a `pop` revealed has re-read itself — and what\n// anything that runs an action for somebody else awaits before it reads the\n// screen.\n//\n// It is about THIS shell's own work. A followed read's next body arrives when\n// somebody else writes, and is not waited for; neither is anything outside the\n// shell that an endpoint set going. A call that never answers holds it until\n// the call's own timeout fails it (30s by default), so `waitMs` is what bounds\n// the wait — it resolves `false` when that runs out, as `shellSettled` does.\nexport const shellIdle = (shell: Shell, options: { waitMs?: number; stopped?: () => boolean } = {}): Promise<boolean> =>\n shellQuietWithin(shell, () => isMounting(shell) || chainsInFlight(shell) > 0, options);\n","import { headKeyOf } from '../layout/head';\nimport type { HeadElement } from '../layout/head';\n\n// ═══════════════════════════════════════════════════════════\n// A screen's head, written into an HTML document.\n//\n// The document is the app's own `index.html` with a screen already drawn into\n// it. Its <head> is what holds on every page; the screen's head elements are\n// what this page says. An element that says the same thing as a tag the\n// document already has — its <title>, a <meta> of that name or property, its\n// canonical address — takes that tag's place, where it stood. Anything else is\n// added after what is there. Everything the screen does not speak of is left\n// exactly as it was: the icon, the viewport, the stylesheet.\n//\n// TWO THINGS ARE KEPT FOR THE PAGE ITSELF, which goes on living after the file\n// is read (./head-keeper). What was written is marked (`data-nova-head`), so\n// the page can tell the screen's elements from the document's own. And a tag\n// that gave up its place is kept, inert, in a <template data-nova-own>: when\n// the screen moves on to one that no longer says it, the document's own comes\n// back.\n//\n// WHERE the document lives is known to whoever writes the file: the site plus\n// the path it was drawn at. With a `site`, every path is given its own\n// canonical address, whether or not its screen has a head. That address is the\n// document's own for this path — unmarked, and it stays when the screen moves\n// on. A screen that says a canonical address itself is taken at its word.\n//\n// With nothing to write, the document comes back untouched.\n// ═══════════════════════════════════════════════════════════\n\nexport type HeadPlace = {\n // The address the site is served at (\"https://example.com\"). With it, each\n // path's canonical address is written.\n site?: string;\n // The path this document was drawn at.\n path?: string;\n};\n\nexport const HEAD_MARK = 'data-nova-head';\nexport const OWN_MARK = 'data-nova-own';\n\nconst escapeAttribute = (value: string): string => value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<');\nconst escapeText = (value: string): string => value.replace(/&/g, '&').replace(/</g, '<');\n// Inside a <script>, the one thing that may not appear is the start of a tag.\n// The two separators end a line in a script though not in JSON, so they are\n// written as escapes too (named by code: the characters themselves would end\n// a line here as well).\nconst LINE_ENDS = [0x2028, 0x2029];\nconst escapeScript = (json: string): string =>\n LINE_ENDS.reduce((text, code) => text.split(String.fromCharCode(code)).join(`\\\\u${code.toString(16)}`), json.replace(/</g, '\\\\u003c'));\n\n// What stands in a head, read a tag at a time: comments and the bodies of\n// scripts, styles and templates are passed over whole, so a tag written inside\n// one is not mistaken for a tag.\nconst ATTRIBUTES = `((?:[^>\"']|\"[^\"]*\"|'[^']*')*)`;\nconst TAGS = new RegExp(`<!--[\\\\s\\\\S]*?-->|<(script|style|title|template)\\\\b${ATTRIBUTES}>([\\\\s\\\\S]*?)<\\\\/\\\\1\\\\s*>|<(meta|link)\\\\b${ATTRIBUTES}>`, 'gi');\nconst ATTRIBUTE = /([^\\s\"'=<>/]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?/g;\n\ntype Tag = { start: number; end: number; name: string; attributes: Record<string, string>; inner: string; text: string };\n\nconst attributesOf = (source: string): Record<string, string> => {\n const attributes: Record<string, string> = {};\n for (const match of source.matchAll(ATTRIBUTE)) {\n const name = match[1]?.toLowerCase();\n if (name === undefined || name in attributes) continue;\n attributes[name] = match[2] ?? match[3] ?? match[4] ?? '';\n }\n return attributes;\n};\n\nconst tagsOf = (section: string): Tag[] => {\n const tags: Tag[] = [];\n for (const match of section.matchAll(TAGS)) {\n const name = (match[1] ?? match[4])?.toLowerCase();\n if (name === undefined) continue;\n tags.push({ start: match.index, end: match.index + match[0].length, name, attributes: attributesOf(match[2] ?? match[5] ?? ''), inner: match[3] ?? '', text: match[0] });\n }\n return tags;\n};\n\n// What a tag in the document says, in the same terms as an element.\nconst keyOfTag = (tag: Tag): string | undefined =>\n tag.name === 'title' || tag.name === 'meta' || tag.name === 'link' ? headKeyOf({ tag: tag.name, attributes: tag.attributes }) : undefined;\n\n// An element, as the tag it is written as.\nconst markupOf = (element: HeadElement, marked: boolean): string => {\n const written = Object.entries(element.attributes).map(([name, value]) => (value === '' ? ` ${name}` : ` ${name}=\"${escapeAttribute(value)}\"`));\n const attributes = [...written, ...(marked ? [` ${HEAD_MARK}`] : [])].join('');\n if (element.tag === 'title') return `<title${attributes}>${escapeText(element.text ?? '')}</title>`;\n if (element.tag === 'script') return `<script${attributes}>${escapeScript(element.text ?? '')}</script>`;\n return `<${element.tag}${attributes}>`;\n};\n\n// Where the document lives, as elements: what a `site` and a path say.\nconst addressOf = (place: HeadPlace): HeadElement[] => {\n if (place.site === undefined || place.path === undefined) return [];\n const path = place.path.split(/[?#]/)[0] ?? '';\n const address = `${place.site.replace(/\\/+$/, '')}${path.startsWith('/') ? path : `/${path}`}`;\n return [\n { tag: 'link', attributes: { rel: 'canonical', href: address } },\n { tag: 'meta', attributes: { property: 'og:url', content: address } },\n ];\n};\n\nconst changed = (text: string, changes: readonly { start: number; end: number; text: string }[]): string =>\n [...changes].sort((a, b) => b.start - a.start).reduce((at, change) => `${at.slice(0, change.start)}${change.text}${at.slice(change.end)}`, text);\n\n// A head that was written before, put back as the document had it: what the\n// last screen said is taken out, and what the document gave up for it is given\n// back. A head never written comes back as it is.\nconst restored = (section: string): string =>\n changed(\n section,\n tagsOf(section).flatMap((tag) => {\n if (tag.name === 'template' && OWN_MARK in tag.attributes) return [{ start: tag.start, end: tag.end, text: tag.inner }];\n return HEAD_MARK in tag.attributes ? [{ start: tag.start, end: tag.end, text: '' }] : [];\n }),\n );\n\n// Elements, written into a head. `screen`: they are what a screen says — each\n// is marked, and a tag that gives up its place is kept for the page. Otherwise\n// they are the document's own from here on, and what they replace is gone.\nconst write = (section: string, elements: readonly HeadElement[], screen: boolean): string => {\n if (elements.length === 0) return section;\n const tags = tagsOf(section);\n const changes: { start: number; end: number; text: string }[] = [];\n const added: string[] = [];\n const own: string[] = [];\n for (const element of elements) {\n const key = headKeyOf(element);\n const [first, ...others] = key === undefined ? [] : tags.filter((tag) => keyOfTag(tag) === key);\n if (first === undefined) {\n added.push(markupOf(element, screen));\n continue;\n }\n changes.push({ start: first.start, end: first.end, text: markupOf(element, screen) });\n own.push(first.text);\n // said twice, the second would still say the old thing\n for (const other of others) {\n changes.push({ start: other.start, end: other.end, text: '' });\n own.push(other.text);\n }\n }\n if (screen && own.length > 0) added.push(`<template ${OWN_MARK}>${own.join('')}</template>`);\n\n const written = changed(section, changes);\n // What is added goes after the last thing in the head, a line each, indented\n // as that last thing is — or straight on, in a head written on one line.\n const tail = /\\s*$/.exec(written)?.[0] ?? '';\n const body = written.slice(0, written.length - tail.length);\n const indent = /(?:^|\\n)([ \\t]*)\\S[^\\n]*$/.exec(body)?.[1] ?? '';\n const lead = tail.includes('\\n') ? `\\n${indent}` : '';\n return `${body}${added.map((tag) => `${lead}${tag}`).join('')}${tail}`;\n};\n\nexport const placeHead = (html: string, elements: readonly HeadElement[] | undefined, place: HeadPlace = {}): string => {\n const opening = /<head\\b[^>]*>/i.exec(html);\n if (opening === null) return html;\n const from = opening.index + opening[0].length;\n const closing = html.slice(from).search(/<\\/head\\s*>/i);\n if (closing < 0) return html;\n // Where the document lives is the document's own, for this path: written\n // first and unmarked, so a screen that says an address of its own takes its\n // place — and gives it back.\n const located = write(restored(html.slice(from, from + closing)), addressOf(place), false);\n return `${html.slice(0, from)}${write(located, elements ?? [], true)}${html.slice(from + closing)}`;\n};\n","import { headKeyOf } from '../layout/head';\nimport type { HeadElement } from '../layout/head';\nimport { HEAD_MARK, OWN_MARK } from './place-head';\n\n// ═══════════════════════════════════════════════════════════\n// A page's <head>, kept on the screen.\n//\n// A drawn page arrives with its head written (`placeHead`). From then on the\n// shell is live and the screen moves without the page being fetched again, so\n// the head is kept on whatever the screen says now: its elements are put in\n// `document.head`, and taken out again when the screen stops saying them.\n//\n// THE DOCUMENT'S OWN TAGS GIVE WAY AND COME BACK. A tag the page was written\n// with — the title in index.html, its description — is taken out while the\n// screen says the same thing itself, and put back where it stood when the\n// screen no longer does. A drawn page has already given some up: they arrive\n// inert, in the <template data-nova-own> the writer left, and come back the\n// same way.\n//\n// A KEEPER THAT WAS NEVER HANDED AN ELEMENT NEVER WRITES. Two shells can share\n// a page (an inspector beside the app), and the one with nothing to say must\n// not touch what the other wrote — nor what the page arrived with.\n// ═══════════════════════════════════════════════════════════\n\nexport type HeadKeeper = (elements: readonly HeadElement[] | undefined) => void;\n\ntype Away = { key: string; node: Element; before: Node | null };\n\nconst TAGS = ['title', 'meta', 'link'];\n\n// What a tag standing in the page says, in the same terms as an element.\nconst keyOfNode = (node: Element): string | undefined => {\n const tag = TAGS.find((name) => name === node.tagName.toLowerCase());\n if (tag !== 'title' && tag !== 'meta' && tag !== 'link') return undefined;\n return headKeyOf({ tag, attributes: Object.fromEntries([...node.attributes].map((attribute) => [attribute.name, attribute.value])) });\n};\n\nexport const createHeadKeeper = (doc: Document): HeadKeeper => {\n // the screen's elements standing in the head\n let mine: Element[] = [];\n // the document's own tags that have given up their place\n let away: Away[] = [];\n let said: string | undefined;\n\n const built = (element: HeadElement): Element => {\n const node = doc.createElement(element.tag);\n for (const [name, value] of Object.entries(element.attributes)) node.setAttribute(name, value);\n node.setAttribute(HEAD_MARK, '');\n if (element.text !== undefined) node.textContent = element.text;\n return node;\n };\n\n // What the page arrived with: the elements a writer put there for the first\n // screen, and the tags that gave way to them.\n const adopt = (): void => {\n mine = [...doc.head.querySelectorAll(`[${HEAD_MARK}]`)];\n // the document's own window, not a global: a page's document is not always\n // the one the code was loaded in\n const view = doc.defaultView;\n for (const stash of doc.head.querySelectorAll(`template[${OWN_MARK}]`)) {\n if (view === null || !(stash instanceof view.HTMLTemplateElement)) continue;\n for (const child of [...stash.content.children]) {\n const key = keyOfNode(child);\n if (key !== undefined) away.push({ key, node: doc.importNode(child, true), before: null });\n }\n stash.remove();\n }\n };\n\n return (elements) => {\n const now = elements ?? [];\n const next = JSON.stringify(now);\n if (said === undefined) {\n if (now.length === 0) return;\n adopt();\n }\n if (next === said) return;\n said = next;\n\n for (const node of mine) node.remove();\n mine = now.map(built);\n const keys = new Set(now.flatMap((element) => headKeyOf(element) ?? []));\n\n // the document's own that now say what the screen says: out, each remembering where it stood\n for (const node of [...doc.head.children]) {\n const key = keyOfNode(node);\n if (key === undefined || !keys.has(key)) continue;\n away.push({ key, node, before: node.nextSibling });\n node.remove();\n }\n // Those the screen no longer says: back where each stood. The last to leave\n // goes back first — what stood after an earlier one may have left after it,\n // and has to be standing again for the earlier one to go in front of it.\n const [back, still] = [away.filter((gone) => !keys.has(gone.key)), away.filter((gone) => keys.has(gone.key))];\n for (const gone of [...back].reverse()) doc.head.insertBefore(gone.node, gone.before !== null && gone.before.parentNode === doc.head ? gone.before : null);\n away = still;\n\n doc.head.append(...mine);\n };\n};\n","import { renderNodeKey } from '@layout/adapter';\nimport type { ComponentRegistry, RenderNode } from '@layout/types';\nimport type { NovaEvent } from '@shared/event-bus/schemas';\nimport { headOf, isHeadNode, shellView } from '@shell';\nimport type { RenderApi, Shell } from '@shell';\nimport { createHeadKeeper } from '../../document/head-keeper';\n\n// ═══════════════════════════════════════════════════════════\n// @niscorp/nova/adapters/dom — a vanilla-DOM adapter, the platform sibling of\n// nova/react. It turns a served RenderNode tree into DOM: registry lookup →\n// element, recurse children, and wire events BY CONVENTION — a `ref`'d\n// element dispatches `ui:click`, a `model`'d element dispatches `ui:model`\n// (+ `ui:key`), the payload of a click is the node's `value` prop. Origin is\n// never stamped here — moss stamps the active instance server-side.\n//\n// No framework: the registry maps a component name to a function that builds\n// an element from props + already-rendered children. `CanvasSlot` is resolved\n// here (the frame's markers → per-canvas trees), the one piece of terminal\n// structure the renderer owns; the terminal hands in `canvasTree`/`dispatch`.\n//\n// WHAT DID NOT CHANGE IS NOT DRAWN AGAIN. The view keeps the tree it drew\n// beside the DOM that tree produced, and a render walks the two together: a\n// node that is the same as last time keeps its element — the same DOM node,\n// never taken off the page — and only what differs is built. An element that\n// stays keeps everything the tree does not hold: focus, scroll, selection, an\n// open <details>, a running animation, a timer its component started.\n// See packages/nova/ADAPTER.md for the shared adapter contract, and \"The DOM\n// adapter keeps what did not change\" there for the rules a kit can rely on.\n// ═══════════════════════════════════════════════════════════\n\nexport type DomComponentContext = {\n props: Record<string, unknown>;\n // the node's children, already rendered — the component appends them where\n // it wants (most append to their own element; leaves ignore them).\n children: Node[];\n // the dispatch in force here (canvas-scoped inside a CanvasSlot) — for\n // data-driven components with INTERNAL interactivity (a table's row clicks,\n // an inline checkbox); simple components ignore it and let the renderer wire\n // their `ref`/`model` by convention.\n dispatch: (event: NovaEvent) => void;\n // The other end of anything the component starts — a timer, an observer, a\n // subscription. `cleanup` runs once, when the element this call returns\n // leaves the page for good: it was removed, it was replaced because its own\n // props changed, or the view was destroyed. An element that stays is not\n // asked again, so what it started keeps running until then.\n onRemove: (cleanup: () => void) => void;\n // Say that what this component drew depends on its children — it marked\n // them, counted them, treated the first unlike the rest — rather than only\n // holding them. A component that only holds its children has them patched in\n // place under the element it returned; one that says this is asked again\n // whenever it would be handed different children, and is handed the ones that\n // stayed as it left them, so what it does to them it must be able to do twice.\n dependsOnChildren: () => void;\n};\n\n// A DOM component: props + rendered children in, one element out.\nexport type DomComponent = (ctx: DomComponentContext) => HTMLElement;\n\n// What the terminal hands the view: core's `RenderApi` (the frame, per-canvas\n// trees, a canvas-scoped dispatch, publish). Aliased, not redeclared, so the\n// dom adapter, the react adapter, and moss's terminal share ONE definition —\n// drift is impossible. CanvasSlot resolution + event routing ride these; the\n// renderer never touches the wire directly.\nexport type DomRenderApi = RenderApi;\n\nexport type DomView = {\n // (re)render from the current snapshot; call on every wire change\n render: () => void;\n destroy: () => void;\n};\n\nconst CANVAS_SLOT = 'CanvasSlot';\nconst ACTION_SLOT = 'ActionSlot';\n\ntype ComponentRenderNode = Extract<RenderNode, { type: 'component' }>;\ntype Dispatch = (event: NovaEvent) => void;\n\n// The recursion context: the registry, the dispatch in force (frame chrome\n// dispatches nothing; a CanvasSlot switches it to that canvas's), publish,\n// and the canvas resolver.\ntype Ctx = {\n registry: ComponentRegistry<DomComponent>;\n dispatch: Dispatch;\n api: DomRenderApi;\n // used when a component name is unregistered — a permissive renderer (the\n // html terminal's default kit) supplies one so unknown primitives render\n // their children instead of an error; strict consumers omit it.\n fallback?: DomComponent;\n};\n\n// One node of the tree as it was last drawn, beside the DOM it produced.\ntype Mount = {\n node: RenderNode;\n // the context this node's children are drawn in\n ctx: Ctx;\n // its top-level DOM nodes: one for a component, a text or an error; a\n // fragment has no element of its own, so its are its children's\n dom: Node[];\n kids: Mount[];\n // Where the kids' nodes can be patched in place: the element itself, when it\n // holds exactly them (`holdsExactly`), or a canvas's own host. `undefined`\n // when the component put them anywhere else — a change to which nodes it has\n // then asks the component again.\n host: HTMLElement | undefined;\n cleanups: (() => void)[];\n // a bound field that may not show what the tree says: it was typed in, or the\n // tree's value changed while it was being typed in\n field: { stale: boolean };\n};\n\nconst errorEl = (code: string, message: string): HTMLElement => {\n const el = document.createElement('div');\n el.setAttribute('data-nova-error', code);\n el.textContent = `${code}: ${message}`;\n return el;\n};\n\n// A tree is JSON, so sameness is structural.\nconst equal = (a: unknown, b: unknown): boolean => {\n if (Object.is(a, b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every((key) => Object.hasOwn(b, key) && equal(Reflect.get(a, key), Reflect.get(b, key)));\n};\n\nconst withoutValue = (props: Record<string, unknown>): Record<string, unknown> => {\n const { value: _value, ...rest } = props;\n return rest;\n};\n\nconst sameNodes = (a: Node[], b: Node[]): boolean => a.length === b.length && a.every((node, i) => node === b[i]);\n\n// (Plain indexed loops on purpose: this runs twice for every component on every\n// render, and measured in Chrome it is what a render of a long list spends its\n// time in. `flatMap` is slower once warm; `for…of` is twice as slow while cold,\n// which is when a first draw happens.)\nconst flat = (kids: Mount[]): Node[] => {\n const nodes: Node[] = [];\n for (let i = 0; i < kids.length; i += 1) {\n const dom = kids[i]?.dom ?? [];\n for (let j = 0; j < dom.length; j += 1) {\n const node = dom[j];\n if (node !== undefined) nodes.push(node);\n }\n }\n return nodes;\n};\n\nconst canvasIdOf = (node: ComponentRenderNode): string => {\n const canvasId = node.props['canvasId'];\n return typeof canvasId === 'string' ? canvasId : '';\n};\n\n// Which canvas or which instance a slot stands for. A different one in the\n// same place is a different screen, however alike the two look.\nconst slotOf = (node: ComponentRenderNode): unknown => {\n if (node.name === CANVAS_SLOT) return node.props['canvasId'];\n if (node.name === ACTION_SLOT) return node.props['instanceId'];\n return undefined;\n};\n\n// Core's `renderNodeKey` names a node among its siblings. Two siblings that\n// share a name (looped rows that share a `ref` and carry no key) are told\n// apart by which of them comes first.\nconst keyed = <T>(items: readonly T[], nodeOf: (item: T) => RenderNode): [string, T][] => {\n const seen = new Map<string, number>();\n return items.map((item, i) => {\n const key = renderNodeKey(nodeOf(item), i);\n const count = seen.get(key) ?? 0;\n seen.set(key, count + 1);\n return [count === 0 ? key : `${key}#${count}`, item];\n });\n};\n\n// Whether two nodes at the same index would be given the same key by core's\n// `renderNodeKey` — asked without building the key. Siblings mostly stay where\n// they are from one render to the next, and then nothing has to be looked up.\nconst samePlace = (a: RenderNode, b: RenderNode): boolean => {\n if (a.key !== undefined || b.key !== undefined) return a.key === b.key;\n if (a.type === 'component' && b.type === 'component') return a.ref !== undefined || b.ref !== undefined ? a.ref === b.ref : a.name === b.name;\n if (a.type === 'error' && b.type === 'error') return a.code === b.code;\n return a.type === b.type;\n};\n\nconst gathered = (nodes: Node[]): DocumentFragment => {\n const fragment = document.createDocumentFragment();\n for (const node of nodes) fragment.appendChild(node);\n return fragment;\n};\n\n// Whether a component's children can be patched where they stand: only when the\n// element it returned holds exactly the nodes it was handed, in order, and\n// nothing else. Then adding one, taking one out or moving one is what the\n// component would have drawn anyway. Anything else — a wrapper inside, a cell\n// around each, a heading of its own before them — and the adapter cannot know\n// what the component would do with one child more (a kit that wraps each child\n// looks, with a single child, exactly like one that wraps them all), so it asks.\n// What the shape of the element cannot show — a component that marks or counts\n// the children it holds — the component says itself (`dependsOnChildren`).\nconst holdsExactly = (el: Node, nodes: Node[]): boolean => nodes.length > 0 && el.childNodes.length === nodes.length && nodes.every((node, i) => el.childNodes[i] === node);\n\n// Of the nodes wanted, the longest run that already stands in the wanted order\n// — given where each stood before (-1: it is new). Those stay where they are\n// and the rest are put around them, so a reorder moves as few elements as it\n// can: taking an element out of the page, even to put it straight back,\n// restarts its animations and drops its scroll.\nconst standing = (stoodAt: number[]): Set<number> => {\n // ends[k]: the wanted index that ends the best run of length k + 1\n const ends: number[] = [];\n const before: number[] = [];\n stoodAt.forEach((stood, i) => {\n before[i] = -1;\n if (stood < 0) return;\n let lo = 0;\n let hi = ends.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if ((stoodAt[ends[mid] ?? 0] ?? 0) < stood) lo = mid + 1;\n else hi = mid;\n }\n before[i] = lo > 0 ? (ends[lo - 1] ?? -1) : -1;\n ends[lo] = i;\n });\n const run = new Set<number>();\n let at = ends[ends.length - 1] ?? -1;\n while (at >= 0) {\n run.add(at);\n at = before[at] ?? -1;\n }\n return run;\n};\n\n// Read the model value off an event target — a checkbox reports `checked`,\n// everything else `value`.\nconst readValue = (target: EventTarget | null): unknown => {\n if (target instanceof HTMLInputElement && target.type === 'checkbox') return target.checked;\n if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement) return target.value;\n return '';\n};\n\n// Attach the conventional listeners: a model'd element is an input (dispatch\n// ui:model on change, ui:key on keydown); a bare ref'd element is clickable\n// (dispatch ui:click, payload = its `value` prop). Uniform across every\n// component — the event vocabulary is the convention, not per-component code.\n//\n// The listeners close over the node they were wired for. That is safe because\n// an element is only ever kept for a node that says the same: a different\n// `ref`, `model`, or prop builds a new element with new listeners (a bound\n// field's `value` aside, which no listener reads).\nconst wireEvents = (el: HTMLElement, node: ComponentRenderNode, dispatch: Dispatch, field: { stale: boolean }): void => {\n if (node.model !== undefined) {\n const ref = node.model.ref;\n const wait = node.props['debounce'];\n const debounce = typeof wait === 'number' ? wait : 0;\n let pending: { value: unknown; timer: ReturnType<typeof setTimeout> } | undefined;\n const fire = (value: unknown): void => dispatch({ type: 'ui:model', ref, payload: value });\n el.addEventListener('input', (e) => {\n field.stale = true;\n const value = readValue(e.target);\n if (debounce <= 0) {\n fire(value);\n return;\n }\n if (pending !== undefined) clearTimeout(pending.timer);\n const timer = setTimeout(() => {\n pending = undefined;\n fire(value);\n }, debounce);\n pending = { value, timer };\n });\n // Leaving the field sends what was still waiting (ADAPTER.md, obligation 6).\n // Caught on the way down: blur does not bubble, and the field may sit\n // inside the component's element rather than be it.\n el.addEventListener(\n 'blur',\n () => {\n if (pending === undefined) return;\n clearTimeout(pending.timer);\n const { value } = pending;\n pending = undefined;\n fire(value);\n },\n true,\n );\n el.addEventListener('keydown', (e) => {\n if (e instanceof KeyboardEvent) dispatch({ type: 'ui:key', ref, key: e.key });\n });\n return;\n }\n if (node.ref !== undefined) {\n const ref = node.ref;\n el.addEventListener('click', (e) => {\n e.stopPropagation();\n const value = node.props['value'];\n dispatch(value === undefined ? { type: 'ui:click', ref } : { type: 'ui:click', ref, payload: value });\n });\n }\n};\n\n// The per-instance boundary a served tree carries. A list canvas renders\n// several live instances at once, so a click inside THIS boundary must reach\n// THIS instance: its events carry it as their origin (the server's\n// active-instance fallback only holds for a card-deck canvas). An event that\n// already has an origin keeps it — moss's react terminal does the same.\nconst inInstance = (node: RenderNode, ctx: Ctx): Ctx => {\n if (node.type !== 'component' || node.name !== ACTION_SLOT) return ctx;\n const instanceId = node.props['instanceId'];\n if (typeof instanceId !== 'string' || instanceId === '') return ctx;\n const outer = ctx.dispatch;\n return { ...ctx, dispatch: (event) => outer(event.origin === undefined ? { ...event, origin: instanceId } : event) };\n};\n\n// A field a person types in — where what is being typed must not be written\n// over. A checkbox or a radio has no \"being typed\": it is on or off, and the\n// tree's answer shows at once.\nconst isTypedIn = (el: Element | null): el is HTMLInputElement | HTMLTextAreaElement =>\n el instanceof HTMLTextAreaElement || (el instanceof HTMLInputElement && el.type !== 'checkbox' && el.type !== 'radio');\n\n// What such a field holds that is not in the tree: what is being typed, and\n// where the caret is.\ntype Typing = { value: string; start: number | null; end: number | null };\n\nconst typingIn = (el: Element | null): Typing | undefined => (isTypedIn(el) ? { value: el.value, start: el.selectionStart, end: el.selectionEnd } : undefined);\n\nconst placeCaret = (el: HTMLInputElement | HTMLTextAreaElement, typing: Typing): void => {\n try {\n el.setSelectionRange(typing.start ?? el.value.length, typing.end ?? el.value.length);\n } catch {\n /* selectionRange throws on some input types — harmless */\n }\n};\n\n// Where a node sits under `root`, as the child index at each level — and the\n// node that sits there. Markup drawn ahead of time and the first render over it\n// are the same elements in the same places, so this is how an element of the\n// one finds its twin in the other.\nconst placeUnder = (root: Node, node: Node): number[] | undefined => {\n const place: number[] = [];\n let at: Node = node;\n while (at !== root) {\n const parent = at.parentNode;\n if (parent === null) return undefined;\n const child = at;\n place.unshift([...parent.childNodes].findIndex((sibling) => sibling === child));\n at = parent;\n }\n return place;\n};\n\nconst nodeUnder = (root: Node, place: number[]): Node | undefined => place.reduce<Node | undefined>((at, index) => at?.childNodes[index], root);\n\nexport const createDomView = (\n root: HTMLElement,\n registry: ComponentRegistry<DomComponent>,\n api: DomRenderApi,\n options: { fallback?: DomComponent } = {},\n): DomView => {\n // The frame dispatches nothing (chrome); only a CanvasSlot's subtree does.\n const top: Ctx = { registry, dispatch: () => undefined, api, ...(options.fallback !== undefined ? { fallback: options.fallback } : {}) };\n let mounts: Mount[] = [];\n // Whatever is in the root before the first render is not this view's: markup\n // that arrived with the page is replaced by the first render, once.\n let drawn = false;\n // Counts every node built and every write to the page, so a component can\n // tell \"nothing below me changed\" from \"something did\".\n let writes = 0;\n // Focus is the element's, so it follows the element: `from` held it when the\n // render began, `to` is what was built in its place if it had to be.\n const refocus: { from: Element | null; to: HTMLElement | undefined } = { from: null, to: undefined };\n // a bound component's field state (Mount.field), found from its element\n const fields = new WeakMap<Node, { stale: boolean }>();\n\n const builderOf = (node: ComponentRenderNode, ctx: Ctx): DomComponent | undefined => ctx.registry.get(node.name)?.component ?? ctx.fallback;\n\n const leaf = (node: RenderNode, ctx: Ctx, el: Node): Mount => ({ node, ctx, dom: [el], kids: [], host: undefined, cleanups: [], field: { stale: false } });\n\n // The element is going: whatever its component started stops. Its kids are\n // not touched — they may be living on under the element built in its place.\n const leave = (mount: Mount): void => {\n if (mount.cleanups.length === 0) return;\n for (const cleanup of mount.cleanups.splice(0)) cleanup();\n };\n\n const drop = (mount: Mount): void => {\n leave(mount);\n for (const kid of mount.kids) drop(kid);\n };\n\n // Ask the component for its element. Children go in as they always have: one\n // Node per child, a fragment child (a loop) as a DocumentFragment. Kids that\n // were on the page already are moved into the new element by the component.\n const assemble = (node: ComponentRenderNode, ctx: Ctx, kids: Mount[], replaced?: Mount): Mount => {\n if (replaced !== undefined) leave(replaced);\n const builder = builderOf(node, ctx);\n if (builder === undefined) {\n for (const kid of kids) drop(kid);\n return leaf(node, ctx, errorEl('COMPONENT_NOT_FOUND', node.name));\n }\n // a head among them draws nothing, so the component is not handed one\n const children = kids.filter((kid) => !isHeadNode(kid.node)).map((kid): Node => {\n const [only] = kid.dom;\n if (kid.node.type !== 'fragment' && only !== undefined) return only;\n const fragment = document.createDocumentFragment();\n fragment.append(...kid.dom);\n return fragment;\n });\n const cleanups: (() => void)[] = [];\n const field = { stale: false };\n let holdsOnly = true;\n writes += 1;\n const el = builder({\n props: node.props,\n children,\n dispatch: ctx.dispatch,\n onRemove: (cleanup) => void cleanups.push(cleanup),\n dependsOnChildren: () => {\n holdsOnly = false;\n },\n });\n el.setAttribute('data-component', node.name);\n if (node.ref !== undefined) el.setAttribute('data-ref', node.ref);\n wireEvents(el, node, ctx.dispatch, field);\n if (node.model !== undefined) fields.set(el, field);\n if (replaced !== undefined && refocus.from !== null && replaced.dom[0] === refocus.from) refocus.to = el;\n return { node, ctx, dom: [el], kids, host: holdsOnly && holdsExactly(el, flat(kids)) ? el : undefined, cleanups, field };\n };\n\n const build = (node: RenderNode, parent: Ctx): Mount => {\n const ctx = inInstance(node, parent);\n writes += 1;\n if (node.type === 'text') return leaf(node, ctx, document.createTextNode(node.value));\n if (node.type === 'error') return leaf(node, ctx, errorEl(node.code, node.message));\n if (node.type === 'fragment') {\n const kids = node.children.map((child) => build(child, ctx));\n return { node, ctx, dom: flat(kids), kids, host: undefined, cleanups: [], field: { stale: false } };\n }\n if (node.name === CANVAS_SLOT) {\n const canvasId = canvasIdOf(node);\n const host = document.createElement('div');\n host.setAttribute('data-canvas', canvasId);\n // Switch dispatch to this canvas's; the server stamps origin, so the\n // terminal just tags the canvas.\n const canvasCtx: Ctx = { ...ctx, dispatch: (event) => ctx.api.dispatch(canvasId, event) };\n const kids = canvasId === '' ? [] : ctx.api.canvasTree(canvasId).map((child) => build(child, canvasCtx));\n host.append(...flat(kids));\n return { node, ctx: canvasCtx, dom: [host], kids, host, cleanups: [], field: { stale: false } };\n }\n // A head is the document's, not the screen's: no element, for it or for what it holds.\n if (isHeadNode(node)) return { node, ctx, dom: [], kids: [], host: undefined, cleanups: [], field: { stale: false } };\n if (builderOf(node, ctx) === undefined) return leaf(node, ctx, errorEl('COMPONENT_NOT_FOUND', node.name));\n return assemble(node, ctx, node.children.map((child) => build(child, ctx)));\n };\n\n // Make `host` hold `after` where it held `before`: what left is taken out,\n // what is new is put in, and a node that already stands where it belongs is\n // not touched. The writes are as few as they can be: nodes that go in side by\n // side go in together, and a host none of whose nodes stay is refilled in one.\n const place = (host: HTMLElement, before: Node[], after: Node[]): void => {\n if (sameNodes(before, after)) return;\n const wanted = new Set(after);\n if (host.childNodes.length === before.length && !before.some((node) => wanted.has(node))) {\n host.replaceChildren(gathered(after));\n writes += 1;\n return;\n }\n for (const node of before) {\n if (wanted.has(node) || node.parentNode !== host) continue;\n host.removeChild(node);\n writes += 1;\n }\n const stoodAt = new Map(before.map((node, i) => [node, i]));\n const stays = standing(after.map((node) => stoodAt.get(node) ?? -1));\n // right to left: what goes in between two nodes that stay is gathered, and\n // put in before the one on its right\n let anchor: Node | null = null;\n let run: Node[] = [];\n const putIn = (): void => {\n const [only] = run;\n if (only === undefined) return;\n host.insertBefore(run.length === 1 ? only : gathered(run.reverse()), anchor);\n writes += 1;\n run = [];\n };\n for (let i = after.length - 1; i >= 0; i -= 1) {\n const node = after[i];\n if (node === undefined) continue;\n if (stays.has(i)) {\n putIn();\n anchor = node;\n } else run.push(node);\n }\n putIn();\n };\n\n // Siblings are matched by key. A match is patched, a node with no match is\n // built, and what was drawn and has no match any more is let go.\n const reconcile = (olds: Mount[], nexts: readonly RenderNode[], ctx: Ctx): Mount[] => {\n // the usual case: the same siblings in the same places\n if (olds.length === nexts.length && olds.every((old, i) => samePlace(old.node, nexts[i] ?? old.node))) {\n return olds.map((old, i) => patch(old, nexts[i] ?? old.node, ctx));\n }\n const drawnBy = new Map(keyed(olds, (old) => old.node));\n const kids = keyed(nexts, (next) => next).map(([key, next]) => {\n const old = drawnBy.get(key);\n if (old === undefined) return build(next, ctx);\n drawnBy.delete(key);\n return patch(old, next, ctx);\n });\n for (const gone of drawnBy.values()) drop(gone);\n return kids;\n };\n\n const patch = (old: Mount, next: RenderNode, parent: Ctx): Mount => {\n const prev = old.node;\n const afresh = (): Mount => {\n drop(old);\n return build(next, parent);\n };\n if (prev.type === 'text' && next.type === 'text') {\n const [node] = old.dom;\n if (prev.value !== next.value && node !== undefined) {\n node.nodeValue = next.value;\n writes += 1;\n }\n old.node = next;\n return old;\n }\n if (prev.type === 'fragment' && next.type === 'fragment') {\n // no element of its own: the host above it puts its nodes in place\n old.kids = reconcile(old.kids, next.children, old.ctx);\n old.dom = flat(old.kids);\n old.node = next;\n return old;\n }\n if (prev.type !== 'component' || next.type !== 'component') return equal(prev, next) ? old : afresh();\n // A different component, or a different canvas or instance in the same\n // place: nothing of the old one is kept. Its listeners dispatch as the old\n // instance; kept, a press would reach an instance that is no longer here.\n if (prev.name !== next.name || !Object.is(slotOf(prev), slotOf(next))) return afresh();\n\n if (isHeadNode(next)) {\n old.node = next;\n return old;\n }\n\n if (next.name === CANVAS_SLOT) {\n const host = old.host;\n if (host === undefined) return afresh();\n const canvasId = canvasIdOf(next);\n const before = flat(old.kids);\n old.kids = reconcile(old.kids, canvasId === '' ? [] : old.ctx.api.canvasTree(canvasId), old.ctx);\n place(host, before, flat(old.kids));\n old.node = next;\n return old;\n }\n\n const [el] = old.dom;\n if (el === undefined) return afresh();\n let own = equal(prev.props, next.props) && prev.ref === next.ref && equal(prev.model, next.model);\n if (next.model !== undefined) {\n const active = el.ownerDocument?.activeElement ?? null;\n if (isTypedIn(active) && el.contains(active)) {\n // WHILE A BOUND FIELD IS BEING TYPED IN, what the person is typing wins\n // over the tree (ADAPTER.md, obligation 6) — so a tree that differs only\n // in the field's value is not a reason to build another field. The one\n // being typed in stays, with its caret, its composition and its pending\n // debounce; it is marked as showing something the tree does not say.\n if (!own && prev.ref === next.ref && equal(prev.model, next.model) && equal(withoutValue(prev.props), withoutValue(next.props))) {\n old.field.stale = true;\n own = true;\n }\n } else if (old.field.stale) {\n // Released — or never a field one types in (a checkbox that was\n // pressed): the tree's value is the field's again. How a value is shown\n // is the kit's business, so the kit is asked for the field afresh.\n own = false;\n }\n }\n\n // what the component was handed, child by child — asked only of one that\n // did something of its own with its children\n const handed = old.host === undefined ? old.kids.map((kid) => kid.dom) : undefined;\n const before = flat(old.kids);\n const mark = writes;\n const kids = reconcile(old.kids, next.children, old.ctx);\n const after = flat(kids);\n const kept = (): Mount => {\n old.kids = kids;\n old.node = next;\n return old;\n };\n if (own) {\n if (old.host !== undefined) {\n // Its element holds exactly its children's nodes, so they are put in\n // place there. (Down to none at all is left to the component: it may\n // draw itself differently when empty.)\n if (after.length > 0) {\n place(old.host, before, after);\n return kept();\n }\n } else if (handed !== undefined && handed.length === kids.length && kids.every((kid, i) => sameNodes(handed[i] ?? [], kid.dom))) {\n // It did something of its own with its children, and it would be handed\n // the same nodes, child for child, so it would draw the same. Whatever\n // changed further down was patched where it stands — which is on the\n // page only if this component put its children on the page.\n if (writes === mark || after.every((node) => el.contains(node))) return kept();\n }\n }\n // Its own props changed, or its children changed where they cannot be\n // reached: ask the component again. What is below was reconciled all the\n // same, so a descendant that did not change is the same node in the new\n // element — moved, not rebuilt.\n return assemble(next, old.ctx, kids, old);\n };\n\n const render = (): void => {\n const doc = root.ownerDocument;\n const active = doc.activeElement !== null && root.contains(doc.activeElement) ? doc.activeElement : null;\n const typing = typingIn(active);\n // The first render replaces markup that arrived with the page. Somebody may\n // already be in it — in a field, typing — so where they are is noted, to be\n // found again in the elements drawn over it.\n const adopted = !drawn && active !== null ? placeUnder(root, active) : undefined;\n refocus.from = active;\n refocus.to = undefined;\n if (!drawn) root.replaceChildren();\n drawn = true;\n const before = flat(mounts);\n mounts = reconcile(mounts, api.frame(), top);\n place(root, before, flat(mounts));\n const twin = adopted === undefined ? undefined : nodeUnder(root, adopted);\n // An element that stayed where it was still has focus. One that was moved\n // lost it in the move, and one that was built again never had it: give it\n // back — and to a field built again, what was being typed in the one it\n // replaced, because the in-progress value wins over the tree's.\n const rebuilt = refocus.to ?? (twin instanceof HTMLElement && twin.tagName === active?.tagName ? twin : undefined);\n const target = rebuilt ?? (active instanceof HTMLElement && active.isConnected ? active : undefined);\n refocus.from = null;\n refocus.to = undefined;\n if (target === undefined || doc.activeElement === target) return;\n if (rebuilt !== undefined && typing !== undefined && isTypedIn(target)) {\n target.value = typing.value;\n const field = fields.get(target);\n if (field !== undefined) field.stale = true;\n }\n target.focus({ preventScroll: true });\n if (typing !== undefined && isTypedIn(target)) placeCaret(target, typing);\n };\n\n const destroy = (): void => {\n for (const mount of mounts) drop(mount);\n mounts = [];\n drawn = false;\n root.replaceChildren();\n };\n\n return { render, destroy };\n};\n\n// A SHELL THAT LIVES IN THIS PAGE, drawn into `root` and kept current: the\n// shell's own view (`shellView`), this adapter over it, and a render on every\n// change — which touches only what that change touched. The whole of a browser\n// entry for an app whose shell runs in the browser:\n//\n// mountShell(root, registry, await boot());\n//\n// A `root` that already holds the same screen as markup — drawn ahead of time\n// by `renderToString` (./server) from the same boot — is picked up by the first\n// render: it replaces those elements with the same elements in one step, so\n// nothing can disagree with them. From the second render on, elements stay.\nexport const mountShell = (\n root: HTMLElement,\n registry: ComponentRegistry<DomComponent>,\n shell: Shell,\n options: { fallback?: DomComponent } = {},\n): { destroy: () => void } => {\n const view = shellView(shell);\n // ONE READING OF THE SHELL PER RENDER. The view draws from it and the page's\n // head is read off the same trees, so keeping the head costs a walk over\n // what was just drawn and never a second render of the shell.\n let read: { frame?: RenderNode[]; trees: Map<string, RenderNode[]> } = { trees: new Map() };\n const api: DomRenderApi = {\n ...view.api,\n frame: () => (read.frame ??= view.api.frame()),\n canvasTree: (canvasId) => {\n const held = read.trees.get(canvasId);\n if (held !== undefined) return held;\n const tree = view.api.canvasTree(canvasId);\n read.trees.set(canvasId, tree);\n return tree;\n },\n };\n const dom = createDomView(root, registry, api, options);\n const keepHead = createHeadKeeper(root.ownerDocument);\n const render = (): void => {\n read = { trees: new Map() };\n dom.render();\n // a root that is not on a page has no head to keep\n if (root.isConnected) keepHead(headOf(api)?.elements);\n };\n render();\n const stop = view.subscribe(render);\n return {\n destroy: () => {\n stop();\n dom.destroy();\n },\n };\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createDomView, mountShell } from '../../chunk-
|
|
1
|
+
export { createDomView, mountShell } from '../../chunk-SVNK5NIK.js';
|
|
2
2
|
import '../../chunk-V4BPFFFV.js';
|
|
3
|
-
import '../../chunk-
|
|
3
|
+
import '../../chunk-DU2VIJAF.js';
|
|
4
4
|
import '../../chunk-RFBIGRCI.js';
|
|
5
5
|
import '../../chunk-Y6XVPRYH.js';
|
|
6
6
|
import '../../chunk-OGD5CCMZ.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createDomView } from '../../chunk-
|
|
1
|
+
import { createDomView } from '../../chunk-SVNK5NIK.js';
|
|
2
2
|
import '../../chunk-V4BPFFFV.js';
|
|
3
|
-
import '../../chunk-
|
|
3
|
+
import '../../chunk-DU2VIJAF.js';
|
|
4
4
|
import '../../chunk-RFBIGRCI.js';
|
|
5
5
|
import '../../chunk-Y6XVPRYH.js';
|
|
6
6
|
import '../../chunk-OGD5CCMZ.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { ActionSlot, Box, Button, CanvasSlot, Input, JsonTree, Panel, Stack, Text, registerNovaReactComponents } from '../../../chunk-
|
|
2
|
-
export { ActionSlotPropsSchema, BoxPropsSchema, ButtonPropsSchema, CanvasSlotPropsSchema, InputPropsSchema, JsonTreePropsSchema, PanelPropsSchema, StackPropsSchema, TextPropsSchema } from '../../../chunk-
|
|
1
|
+
export { ActionSlot, Box, Button, CanvasSlot, Input, JsonTree, Panel, Stack, Text, registerNovaReactComponents } from '../../../chunk-G4LSLLGI.js';
|
|
2
|
+
export { ActionSlotPropsSchema, BoxPropsSchema, ButtonPropsSchema, CanvasSlotPropsSchema, InputPropsSchema, JsonTreePropsSchema, PanelPropsSchema, StackPropsSchema, TextPropsSchema } from '../../../chunk-VOD5JA4D.js';
|
|
3
3
|
import '../../../chunk-V4BPFFFV.js';
|
|
4
|
-
import '../../../chunk-
|
|
4
|
+
import '../../../chunk-DU2VIJAF.js';
|
|
5
5
|
import '../../../chunk-RFBIGRCI.js';
|
|
6
6
|
import '../../../chunk-Y6XVPRYH.js';
|
|
7
7
|
import '../../../chunk-OGD5CCMZ.js';
|