@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.
Files changed (40) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +56 -13
  3. package/SHELL_DOCS.md +13 -4
  4. package/dist/adapters/dom/index.cjs.map +1 -1
  5. package/dist/adapters/dom/index.js +2 -2
  6. package/dist/adapters/dom/server.js +2 -2
  7. package/dist/adapters/react/components/index.js +3 -3
  8. package/dist/adapters/react/index.cjs.map +1 -1
  9. package/dist/adapters/react/index.js +3 -3
  10. package/dist/adapters/tty/index.js +1 -1
  11. package/dist/adapters/vue/components/index.js +3 -3
  12. package/dist/adapters/vue/index.cjs.map +1 -1
  13. package/dist/adapters/vue/index.js +4 -4
  14. package/dist/{chunk-RYIIIXDX.js → chunk-DU2VIJAF.js} +57 -15
  15. package/dist/chunk-DU2VIJAF.js.map +1 -0
  16. package/dist/{chunk-VU6NNCEJ.js → chunk-F2H7WP6R.js} +4 -4
  17. package/dist/{chunk-VU6NNCEJ.js.map → chunk-F2H7WP6R.js.map} +1 -1
  18. package/dist/{chunk-QXQCPH33.js → chunk-G4LSLLGI.js} +4 -4
  19. package/dist/{chunk-QXQCPH33.js.map → chunk-G4LSLLGI.js.map} +1 -1
  20. package/dist/{chunk-MHW5VEIM.js → chunk-SVNK5NIK.js} +3 -3
  21. package/dist/{chunk-MHW5VEIM.js.map → chunk-SVNK5NIK.js.map} +1 -1
  22. package/dist/{chunk-UDCXGDLQ.js → chunk-VOD5JA4D.js} +3 -3
  23. package/dist/{chunk-UDCXGDLQ.js.map → chunk-VOD5JA4D.js.map} +1 -1
  24. package/dist/chunk-XQTI4Q4I.js +178 -0
  25. package/dist/chunk-XQTI4Q4I.js.map +1 -0
  26. package/dist/examples/index.cjs +1186 -0
  27. package/dist/examples/index.cjs.map +1 -0
  28. package/dist/examples/index.d.cts +63 -0
  29. package/dist/examples/index.d.ts +63 -0
  30. package/dist/examples/index.js +1158 -0
  31. package/dist/examples/index.js.map +1 -0
  32. package/dist/i18n/index.js +2 -176
  33. package/dist/i18n/index.js.map +1 -1
  34. package/dist/index.cjs +55 -12
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +5 -1
  37. package/dist/index.d.ts +5 -1
  38. package/dist/index.js +1 -1
  39. package/package.json +19 -8
  40. package/dist/chunk-RYIIIXDX.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/adapters/dom/index.ts"],"names":["before"],"mappings":";;;;;;AAuEA,IAAM,WAAA,GAAc,YAAA;AACpB,IAAM,WAAA,GAAc,YAAA;AAsCpB,IAAM,OAAA,GAAU,CAAC,IAAA,EAAc,OAAA,KAAiC;AAC9D,EAAA,MAAM,EAAA,GAAK,QAAA,CAAS,aAAA,CAAc,KAAK,CAAA;AACvC,EAAA,EAAA,CAAG,YAAA,CAAa,mBAAmB,IAAI,CAAA;AACvC,EAAA,EAAA,CAAG,WAAA,GAAc,CAAA,EAAG,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,CAAA;AACpC,EAAA,OAAO,EAAA;AACT,CAAA;AAGA,IAAM,KAAA,GAAQ,CAAC,CAAA,EAAY,CAAA,KAAwB;AACjD,EAAA,IAAI,MAAA,CAAO,EAAA,CAAG,CAAA,EAAG,CAAC,GAAG,OAAO,IAAA;AAC5B,EAAA,IAAI,OAAO,CAAA,KAAM,QAAA,IAAY,OAAO,CAAA,KAAM,YAAY,CAAA,KAAM,IAAA,IAAQ,CAAA,KAAM,IAAA,EAAM,OAAO,KAAA;AACvF,EAAA,IAAI,KAAA,CAAM,QAAQ,CAAC,CAAA,KAAM,MAAM,OAAA,CAAQ,CAAC,GAAG,OAAO,KAAA;AAClD,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA;AAC1B,EAAA,IAAI,KAAK,MAAA,KAAW,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,QAAQ,OAAO,KAA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} 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/adapters/dom/index.ts"],"names":["before"],"mappings":";;;;;;AAuEA,IAAM,WAAA,GAAc,YAAA;AACpB,IAAM,WAAA,GAAc,YAAA;AAsCpB,IAAM,OAAA,GAAU,CAAC,IAAA,EAAc,OAAA,KAAiC;AAC9D,EAAA,MAAM,EAAA,GAAK,QAAA,CAAS,aAAA,CAAc,KAAK,CAAA;AACvC,EAAA,EAAA,CAAG,YAAA,CAAa,mBAAmB,IAAI,CAAA;AACvC,EAAA,EAAA,CAAG,WAAA,GAAc,CAAA,EAAG,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,CAAA;AACpC,EAAA,OAAO,EAAA;AACT,CAAA;AAGA,IAAM,KAAA,GAAQ,CAAC,CAAA,EAAY,CAAA,KAAwB;AACjD,EAAA,IAAI,MAAA,CAAO,EAAA,CAAG,CAAA,EAAG,CAAC,GAAG,OAAO,IAAA;AAC5B,EAAA,IAAI,OAAO,CAAA,KAAM,QAAA,IAAY,OAAO,CAAA,KAAM,YAAY,CAAA,KAAM,IAAA,IAAQ,CAAA,KAAM,IAAA,EAAM,OAAO,KAAA;AACvF,EAAA,IAAI,KAAA,CAAM,QAAQ,CAAC,CAAA,KAAM,MAAM,OAAA,CAAQ,CAAC,GAAG,OAAO,KAAA;AAClD,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA;AAC1B,EAAA,IAAI,KAAK,MAAA,KAAW,MAAA,CA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derNodeKey } 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,5 +1,5 @@
1
1
  import { createHeadKeeper } from './chunk-V4BPFFFV.js';
2
- import { shellView } from './chunk-RYIIIXDX.js';
2
+ import { shellView } from './chunk-DU2VIJAF.js';
3
3
  import { headOf } from './chunk-RFBIGRCI.js';
4
4
  import { z } from 'zod';
5
5
 
@@ -82,5 +82,5 @@ var createShellHead = (shell) => {
82
82
  };
83
83
 
84
84
  export { ActionSlotPropsSchema, BoxPropsSchema, ButtonPropsSchema, CanvasSlotPropsSchema, InputPropsSchema, JsonTreePropsSchema, PanelPropsSchema, StackPropsSchema, TextPropsSchema, createShellHead };
85
- //# sourceMappingURL=chunk-UDCXGDLQ.js.map
86
- //# sourceMappingURL=chunk-UDCXGDLQ.js.map
85
+ //# sourceMappingURL=chunk-VOD5JA4D.js.map
86
+ //# sourceMappingURL=chunk-VOD5JA4D.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/adapters/primitive-props.ts","../src/document/shell-head.ts"],"names":[],"mappings":";;;;;AAWO,IAAM,gBAAA,GAAmB,EAC7B,MAAA,CAAO;AAAA,EACN,SAAA,EAAW,CAAA,CACR,IAAA,CAAK,CAAC,KAAA,EAAO,QAAQ,CAAC,CAAA,CACtB,QAAA,EAAS,CACT,QAAA,CAAS,kCAAkC,CAAA;AAAA,EAC9C,GAAA,EAAK,CAAA,CACF,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,G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,SAAS,uGAAuG;AACrH,CAAC,CAAA,CACA,MAAA,EAAO,CACP,QAAA,CAAS,mFAAmF;;;ACjLxF,IAAM,eAAA,GAAkB,CAAC,KAAA,KAA4B;AAC1D,EAAA,MAAM,IAAA,GAAO,UAAU,KAAK,CAAA;AAC5B,EAAA,IAAI,OAAA,GAAU,CAAA;AACd,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI,MAAA,GAAS,KAAA;AAEb,EAAA,MAAM,OAAO,MAAY;AAEvB,IAAA,IAAI,MAAA,IAAU,OAAO,QAAA,KAAa,WAAA,EAAa;AAC/C,IAAA,MAAA,GAAS,IAAA;AACT,IAAA,cAAA,CAAe,MAAM;AACnB,MAAA,MAAA,GAAS,KAAA;AACT,MAAA,IAAA,KAAS,iBAAiB,QAAQ,CAAA;AAClC,MAAA,IAAA,CAAK,UAAU,CAAA,GAAI,MAAA,CAAO,KAAK,GAAG,CAAA,EAAG,WAAW,MAAS,CAAA;AAAA,IAC3D,CAAC,CAAA;AAAA,EACH,CAAA;AACA,EAAA,OAAO;AAAA,IACL,OAAO,MAAM;AACX,MAAA,OAAA,IAAW,CAAA;AACX,MAAA,IAAA,EAAK;AAAA,IACP,CAAA;AAAA,IACA,OAAO,MAAM;AACX,MAAA,OAAA,IAAW,CAAA;AACX,MAAA,IAAA,EAAK;AAAA,IACP,CAAA;AAAA,IACA,KAAA,EAAO,MACL,IAAA,CAAK,SAAA,CAAU,MAAM;AACnB,MAAA,IAAI,OAAA,GAAU,GAAG,IAAA,EAAK;AAAA,IACxB,CAAC;AAAA,GACL;AACF","file":"chunk-UDCXGDLQ.js","sourcesContent":["import { z } from 'zod';\n\n// ═══════════════════════════════════════════════════════════\n// The headless primitive vocabulary's AUTHORING contracts — one Zod props\n// schema per primitive, framework-free, shared by every adapter kit that ships\n// the vocabulary (react, vue). A schema is what a layout node may set; the\n// kits differ in how they paint, never in what they accept, so the schema\n// lives once, here, and each kit's component carries it as its static `meta`.\n// ═══════════════════════════════════════════════════════════\n\n// ─── Stack ───\nexport const StackPropsSchema = z\n .object({\n direction: z\n .enum(['row', 'column'])\n .optional()\n .describe('Flex direction. Default: column.'),\n gap: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Gap between children in pixels. Default: 0.'),\n align: z\n .enum(['start', 'center', 'end', 'stretch'])\n .optional()\n .describe('Cross-axis alignment. Default: stretch.'),\n justify: z\n .enum(['start', 'center', 'end', 'between', 'around'])\n .optional()\n .describe('Main-axis justification. Default: start.'),\n padding: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Inner padding in pixels. Default: 0.'),\n wrap: z\n .boolean()\n .optional()\n .describe('Whether children wrap to a new line. Default: false.'),\n })\n .strict()\n .describe('Flex container that arranges children in a row or column.');\n\nexport type StackProps = z.infer<typeof StackPropsSchema>;\n\n// ─── Text ───\nexport const TextPropsSchema = z\n .object({\n as: z\n .enum(['span', 'p', 'h1', 'h2', 'h3', 'h4'])\n .optional()\n .describe('HTML element to render. Default: span.'),\n size: z\n .enum(['sm', 'md', 'lg', 'xl', '2xl'])\n .optional()\n .describe('Font size token. Default: md.'),\n weight: z\n .enum(['normal', 'medium', 'bold'])\n .optional()\n .describe('Font weight token. Default: normal.'),\n color: z\n .string()\n .optional()\n .describe('CSS color string (open set). Default: inherit.'),\n })\n .strict()\n .describe('Text element with semantic typography props.');\n\nexport type TextProps = z.infer<typeof TextPropsSchema>;\n\n// ─── Input ───\nexport const InputPropsSchema = z\n .object({\n type: z\n .enum(['text', 'number', 'email', 'password'])\n .optional()\n .describe('Input type. Default: text.'),\n placeholder: z\n .string()\n .optional()\n .describe('Placeholder text shown when empty.'),\n disabled: z\n .boolean()\n .optional()\n .describe('Whether the input is disabled. Default: false.'),\n value: z\n .string()\n .optional()\n .describe('Current value. Typically supplied via model binding.'),\n debounce: z\n .number()\n .optional()\n .describe('Milliseconds to coalesce keystrokes before dispatching ui:model. Default: 0 (every keystroke). Set it when the shell is remote to cut round-trips.'),\n })\n .strict()\n .describe('Text input bound to data via the `model` field on the layout node.');\n\nexport type InputProps = z.infer<typeof InputPropsSchema>;\n\n// ─── Button ───\nexport const ButtonPropsSchema = z\n .object({\n label: z\n .string()\n .optional()\n .describe('Button label. If absent, children are used.'),\n variant: z\n .enum(['primary', 'secondary', 'ghost'])\n .optional()\n .describe('Visual variant. Default: primary.'),\n disabled: z\n .boolean()\n .optional()\n .describe('Whether the button is disabled. Default: false.'),\n })\n .strict()\n .describe(\"Clickable button. Click events fire as `ui:click` with the layout node's ref.\");\n\nexport type ButtonProps = z.infer<typeof ButtonPropsSchema>;\n\n// ─── Box ───\nexport const BoxPropsSchema = z\n .object({\n padding: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Inner padding in pixels. Default: 0.'),\n background: z\n .string()\n .optional()\n .describe('CSS background color or value.'),\n border: z\n .boolean()\n .optional()\n .describe('Whether to show a 1px border. Default: false.'),\n radius: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Border radius in pixels. Default: 0.'),\n })\n .strict()\n .describe('Generic container with basic styling props. Use Stack for layout, Box for visual wrapping.');\n\nexport type BoxProps = z.infer<typeof BoxPropsSchema>;\n\n// ─── Panel ───\nexport const PanelPropsSchema = z\n .object({\n title: z.string().optional().describe('Optional header title.'),\n backRef: z.string().optional().describe('When set, the header grows a ← (before the title) that fires ui:click with this ref.'),\n closeRef: z.string().optional().describe('When set, the header grows a ✕ that fires ui:click with this ref.'),\n })\n .strict()\n .describe('A framed, elevated surface with an optional title.');\n\nexport type PanelProps = z.infer<typeof PanelPropsSchema>;\n\n// ─── JsonTree ───\nexport const JsonTreePropsSchema = z\n .object({\n value: z.unknown().optional().describe('The value to render.'),\n label: z.string().optional().describe('A name for the root node.'),\n })\n .strict()\n .describe('A collapsible view of any JSON value.');\n\nexport type JsonTreeProps = z.infer<typeof JsonTreePropsSchema>;\n\n// ─── CanvasSlot ───\nexport const CanvasSlotPropsSchema = z\n .object({\n canvasId: z\n .string()\n .optional()\n .describe('Id of the canvas to render. Usually bound from a loop, e.g. \"$.c.id\".'),\n })\n .strict()\n .describe('Renders a canvas by id, recursing into its actionLayout. Resolves to nothing when canvasId is missing.');\n\nexport type CanvasSlotProps = z.infer<typeof CanvasSlotPropsSchema>;\n\n// ─── ActionSlot ───\n// The AUTHORING contract: what a layout node may set on an ActionSlot —\n// instanceId only, strict. The identity props flattenRenderTree stamps on a\n// served marker (canvasId / definitionId) are runtime OUTPUT, never authored;\n// widening this schema would advertise them to the layout agent's palette.\nexport const ActionSlotPropsSchema = z\n .object({\n instanceId: z\n .string()\n .optional()\n .describe('Id of the action instance to render. Usually bound from canvas scope, e.g. \"$.active.id\" or \"$.i.id\".'),\n })\n .strict()\n .describe('Renders an action instance by id. Resolves to nothing when instanceId is missing.');\n\nexport type ActionSlotProps = z.infer<typeof ActionSlotPropsSchema>;\n\n","import { headOf, shellView } from '../shell';\nimport type { Shell } from '../shell';\nimport { createHeadKeeper } from './head-keeper';\nimport type { HeadKeeper } from './head-keeper';\n\n// ═══════════════════════════════════════════════════════════\n// The page's head, for an adapter that draws a shell living in its own page\n// through a framework (react, vue).\n//\n// Such an adapter reads the shell's trees through its own subscriptions, so\n// there is no one render to read the head off: reading it means rendering the\n// shell's trees once more. That is worth doing only while a head is on the\n// screen. So a head node says when it arrives and when it goes (`enter`,\n// `leave`), and the shell is only read between the two.\n// ═══════════════════════════════════════════════════════════\n\nexport type ShellHead = {\n enter: () => void;\n leave: () => void;\n // follow the shell's changes; returns the stop\n watch: () => () => void;\n};\n\nexport const createShellHead = (shell: Shell): ShellHead => {\n const view = shellView(shell);\n let present = 0;\n let keep: HeadKeeper | undefined;\n let queued = false;\n // once a turn, however many heads came and went in it\n const read = (): void => {\n // nothing to keep where a screen is drawn to a string\n if (queued || typeof document === 'undefined') return;\n queued = true;\n queueMicrotask(() => {\n queued = false;\n keep ??= createHeadKeeper(document);\n keep(present > 0 ? headOf(view.api)?.elements : undefined);\n });\n };\n return {\n enter: () => {\n present += 1;\n read();\n },\n leave: () => {\n present -= 1;\n read();\n },\n watch: () =>\n view.subscribe(() => {\n if (present > 0) read();\n }),\n };\n};\n"]}
1
+ {"version":3,"sources":["../src/adapters/primitive-props.ts","../src/document/shell-head.ts"],"names":[],"mappings":";;;;;AAWO,IAAM,gBAAA,GAAmB,EAC7B,MAAA,CAAO;AAAA,EACN,SAAA,EAAW,CAAA,CACR,IAAA,CAAK,CAAC,KAAA,EAAO,QAAQ,CAAC,CAAA,CACtB,QAAA,EAAS,CACT,QAAA,CAAS,kCAAkC,CAAA;AAAA,EAC9C,GAAA,EAAK,CAAA,CACF,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,GAAA,CAAI,CAAC,CAAA,CACL,QAAA,EAAS,CACT,QAAA,CAAS,6CAA6C,CAAA;AAAA,EACzD,KAAA,EAAO,CAAA,CACJ,IAAA,CAAK,CAAC,OAAA,EAAS,QAAA,EAAU,KAAA,EAAO,SAAS,CAAC,CAAA,CAC1C,QAAA,EAAS,CACT,SAAS,yCAAyC,CAAA;AAAA,EACrD,OAAA,EAAS,CAAA,CACN,IAAA,CAAK,CAAC,SAAS,QAAA,EAAU,KAAA,EAAO,SAAA,EAAW,QAAQ,CAAC,CAAA,CACpD,QAAA,EAAS,CACT,SAAS,0CAA0C,CAAA;AAAA,EACtD,OAAA,EAAS,CAAA,CACN,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,GAAA,CAAI,CAAC,CAAA,CACL,QAAA,EAAS,CACT,QAAA,CAAS,sCAAsC,CAAA;AAAA,EAClD,MAAM,CAAA,CACH,OAAA,GACA,QAAA,EAAS,CACT,SAAS,sDAAsD;AACpE,CAAC,CAAA,CACA,MAAA,EAAO,CACP,QAAA,CAAS,2DAA2D;AAKhE,IAAM,eAAA,GAAkB,EAC5B,MAAA,CAAO;AAAA,EACN,EAAA,EAAI,CAAA,CACD,IAAA,CAAK,CAAC,QAAQ,GAAA,EAAK,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAI,CAAC,CAAA,CAC1C,QAAA,EAAS,C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KAAA,EAAO,MACL,IAAA,CAAK,SAAA,CAAU,MAAM;AACnB,MAAA,IAAI,OAAA,GAAU,GAAG,IAAA,EAAK;AAAA,IACxB,CAAC;AAAA,GACL;AACF","file":"chunk-VOD5JA4D.js","sourcesContent":["import { z } from 'zod';\n\n// ═══════════════════════════════════════════════════════════\n// The headless primitive vocabulary's AUTHORING contracts — one Zod props\n// schema per primitive, framework-free, shared by every adapter kit that ships\n// the vocabulary (react, vue). A schema is what a layout node may set; the\n// kits differ in how they paint, never in what they accept, so the schema\n// lives once, here, and each kit's component carries it as its static `meta`.\n// ═══════════════════════════════════════════════════════════\n\n// ─── Stack ───\nexport const StackPropsSchema = z\n .object({\n direction: z\n .enum(['row', 'column'])\n .optional()\n .describe('Flex direction. Default: column.'),\n gap: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Gap between children in pixels. Default: 0.'),\n align: z\n .enum(['start', 'center', 'end', 'stretch'])\n .optional()\n .describe('Cross-axis alignment. Default: stretch.'),\n justify: z\n .enum(['start', 'center', 'end', 'between', 'around'])\n .optional()\n .describe('Main-axis justification. Default: start.'),\n padding: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Inner padding in pixels. Default: 0.'),\n wrap: z\n .boolean()\n .optional()\n .describe('Whether children wrap to a new line. Default: false.'),\n })\n .strict()\n .describe('Flex container that arranges children in a row or column.');\n\nexport type StackProps = z.infer<typeof StackPropsSchema>;\n\n// ─── Text ───\nexport const TextPropsSchema = z\n .object({\n as: z\n .enum(['span', 'p', 'h1', 'h2', 'h3', 'h4'])\n .optional()\n .describe('HTML element to render. Default: span.'),\n size: z\n .enum(['sm', 'md', 'lg', 'xl', '2xl'])\n .optional()\n .describe('Font size token. Default: md.'),\n weight: z\n .enum(['normal', 'medium', 'bold'])\n .optional()\n .describe('Font weight token. Default: normal.'),\n color: z\n .string()\n .optional()\n .describe('CSS color string (open set). Default: inherit.'),\n })\n .strict()\n .describe('Text element with semantic typography props.');\n\nexport type TextProps = z.infer<typeof TextPropsSchema>;\n\n// ─── Input ───\nexport const InputPropsSchema = z\n .object({\n type: z\n .enum(['text', 'number', 'email', 'password'])\n .optional()\n .describe('Input type. Default: text.'),\n placeholder: z\n .string()\n .optional()\n .describe('Placeholder text shown when empty.'),\n disabled: z\n .boolean()\n .optional()\n .describe('Whether the input is disabled. Default: false.'),\n value: z\n .string()\n .optional()\n .describe('Current value. Typically supplied via model binding.'),\n debounce: z\n .number()\n .optional()\n .describe('Milliseconds to coalesce keystrokes before dispatching ui:model. Default: 0 (every keystroke). Set it when the shell is remote to cut round-trips.'),\n })\n .strict()\n .describe('Text input bound to data via the `model` field on the layout node.');\n\nexport type InputProps = z.infer<typeof InputPropsSchema>;\n\n// ─── Button ───\nexport const ButtonPropsSchema = z\n .object({\n label: z\n .string()\n .optional()\n .describe('Button label. If absent, children are used.'),\n variant: z\n .enum(['primary', 'secondary', 'ghost'])\n .optional()\n .describe('Visual variant. Default: primary.'),\n disabled: z\n .boolean()\n .optional()\n .describe('Whether the button is disabled. Default: false.'),\n })\n .strict()\n .describe(\"Clickable button. Click events fire as `ui:click` with the layout node's ref.\");\n\nexport type ButtonProps = z.infer<typeof ButtonPropsSchema>;\n\n// ─── Box ───\nexport const BoxPropsSchema = z\n .object({\n padding: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Inner padding in pixels. Default: 0.'),\n background: z\n .string()\n .optional()\n .describe('CSS background color or value.'),\n border: z\n .boolean()\n .optional()\n .describe('Whether to show a 1px border. Default: false.'),\n radius: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Border radius in pixels. Default: 0.'),\n })\n .strict()\n .describe('Generic container with basic styling props. Use Stack for layout, Box for visual wrapping.');\n\nexport type BoxProps = z.infer<typeof BoxPropsSchema>;\n\n// ─── Panel ───\nexport const PanelPropsSchema = z\n .object({\n title: z.string().optional().describe('Optional header title.'),\n backRef: z.string().optional().describe('When set, the header grows a ← (before the title) that fires ui:click with this ref.'),\n closeRef: z.string().optional().describe('When set, the header grows a ✕ that fires ui:click with this ref.'),\n })\n .strict()\n .describe('A framed, elevated surface with an optional title.');\n\nexport type PanelProps = z.infer<typeof PanelPropsSchema>;\n\n// ─── JsonTree ───\nexport const JsonTreePropsSchema = z\n .object({\n value: z.unknown().optional().describe('The value to render.'),\n label: z.string().optional().describe('A name for the root node.'),\n })\n .strict()\n .describe('A collapsible view of any JSON value.');\n\nexport type JsonTreeProps = z.infer<typeof JsonTreePropsSchema>;\n\n// ─── CanvasSlot ───\nexport const CanvasSlotPropsSchema = z\n .object({\n canvasId: z\n .string()\n .optional()\n .describe('Id of the canvas to render. Usually bound from a loop, e.g. \"$.c.id\".'),\n })\n .strict()\n .describe('Renders a canvas by id, recursing into its actionLayout. Resolves to nothing when canvasId is missing.');\n\nexport type CanvasSlotProps = z.infer<typeof CanvasSlotPropsSchema>;\n\n// ─── ActionSlot ───\n// The AUTHORING contract: what a layout node may set on an ActionSlot —\n// instanceId only, strict. The identity props flattenRenderTree stamps on a\n// served marker (canvasId / definitionId) are runtime OUTPUT, never authored;\n// widening this schema would advertise them to the layout agent's palette.\nexport const ActionSlotPropsSchema = z\n .object({\n instanceId: z\n .string()\n .optional()\n .describe('Id of the action instance to render. Usually bound from canvas scope, e.g. \"$.active.id\" or \"$.i.id\".'),\n })\n .strict()\n .describe('Renders an action instance by id. Resolves to nothing when instanceId is missing.');\n\nexport type ActionSlotProps = z.infer<typeof ActionSlotPropsSchema>;\n\n","import { headOf, shellView } from '../shell';\nimport type { Shell } from '../shell';\nimport { createHeadKeeper } from './head-keeper';\nimport type { HeadKeeper } from './head-keeper';\n\n// ═══════════════════════════════════════════════════════════\n// The page's head, for an adapter that draws a shell living in its own page\n// through a framework (react, vue).\n//\n// Such an adapter reads the shell's trees through its own subscriptions, so\n// there is no one render to read the head off: reading it means rendering the\n// shell's trees once more. That is worth doing only while a head is on the\n// screen. So a head node says when it arrives and when it goes (`enter`,\n// `leave`), and the shell is only read between the two.\n// ═══════════════════════════════════════════════════════════\n\nexport type ShellHead = {\n enter: () => void;\n leave: () => void;\n // follow the shell's changes; returns the stop\n watch: () => () => void;\n};\n\nexport const createShellHead = (shell: Shell): ShellHead => {\n const view = shellView(shell);\n let present = 0;\n let keep: HeadKeeper | undefined;\n let queued = false;\n // once a turn, however many heads came and went in it\n const read = (): void => {\n // nothing to keep where a screen is drawn to a string\n if (queued || typeof document === 'undefined') return;\n queued = true;\n queueMicrotask(() => {\n queued = false;\n keep ??= createHeadKeeper(document);\n keep(present > 0 ? headOf(view.api)?.elements : undefined);\n });\n };\n return {\n enter: () => {\n present += 1;\n read();\n },\n leave: () => {\n present -= 1;\n read();\n },\n watch: () =>\n view.subscribe(() => {\n if (present > 0) read();\n }),\n };\n};\n"]}
@@ -0,0 +1,178 @@
1
+ import { passFor, matcherFor, isPhrase, swap, walkValue } from './chunk-7TS3YVQR.js';
2
+ import { isObject, isArray } from './chunk-RBU5PHN4.js';
3
+
4
+ // src/i18n/translate.ts
5
+ var walkNode = (node, where, pass) => {
6
+ if (node.type === "text") {
7
+ if (!pass.text) return node;
8
+ const value = swap(node.value, where, pass);
9
+ return value === node.value ? node : { ...node, value };
10
+ }
11
+ if (node.type === "fragment") {
12
+ const children2 = walkNodes(node.children, where, pass);
13
+ return children2 === node.children ? node : { ...node, children: children2 };
14
+ }
15
+ if (node.type === "error") return node;
16
+ const at = node.ref === void 0 ? `${where}/${node.name}` : `${where}/${node.name}#${node.ref}`;
17
+ let props = node.props;
18
+ let propsChanged = false;
19
+ const nextProps = {};
20
+ for (const [key, value] of Object.entries(node.props)) {
21
+ const next = walkValue(value, pass.isProse(key), `${at}.${key}`, pass);
22
+ if (next !== value) propsChanged = true;
23
+ nextProps[key] = next;
24
+ }
25
+ if (propsChanged) props = nextProps;
26
+ const children = walkNodes(node.children, at, pass);
27
+ if (!propsChanged && children === node.children) return node;
28
+ return { ...node, props, children };
29
+ };
30
+ var walkNodes = (nodes, where, pass) => {
31
+ let changed = false;
32
+ const out = nodes.map((node) => {
33
+ const next = walkNode(node, where, pass);
34
+ if (next !== node) changed = true;
35
+ return next;
36
+ });
37
+ return changed ? out : nodes;
38
+ };
39
+ var translateRenderTree = (tree, options) => {
40
+ if (Object.keys(options.phrases).length === 0) return tree;
41
+ const pass = passFor({
42
+ phrases: options.phrases,
43
+ ...options.keys === void 0 ? {} : { keys: options.keys },
44
+ ...options.onMiss === void 0 ? {} : { onMiss: options.onMiss }
45
+ });
46
+ if (pass === void 0) return tree;
47
+ return walkNodes(tree, "", pass);
48
+ };
49
+
50
+ // src/i18n/harvest.ts
51
+ var sinkInto = (found, keys) => {
52
+ const matcher = matcherFor(keys);
53
+ return {
54
+ add: (phrase, where) => {
55
+ const trimmed = phrase.trim();
56
+ if (!isPhrase(trimmed)) return;
57
+ const sites = found.get(trimmed);
58
+ if (sites === void 0) found.set(trimmed, /* @__PURE__ */ new Set([where]));
59
+ else sites.add(where);
60
+ },
61
+ isProse: matcher.isProse,
62
+ text: matcher.text
63
+ };
64
+ };
65
+ var harvestWithin = (value, where, sink) => {
66
+ if (typeof value === "string") {
67
+ sink.add(value, where);
68
+ return;
69
+ }
70
+ if (isArray(value)) {
71
+ value.forEach((entry, index) => harvestWithin(entry, `${where}[${String(index)}]`, sink));
72
+ return;
73
+ }
74
+ if (isObject(value)) {
75
+ for (const [key, entry] of Object.entries(value)) harvestWithin(entry, `${where}.${key}`, sink);
76
+ }
77
+ };
78
+ var harvestProps = (props, where, sink) => {
79
+ for (const [key, value] of Object.entries(props)) {
80
+ if (sink.isProse(key)) {
81
+ harvestWithin(value, `${where}.${key}`, sink);
82
+ continue;
83
+ }
84
+ if (isObject(value) || isArray(value)) harvestNested(value, `${where}.${key}`, sink);
85
+ }
86
+ };
87
+ var harvestNested = (value, where, sink) => {
88
+ if (isArray(value)) {
89
+ value.forEach((entry, index) => harvestNested(entry, `${where}[${String(index)}]`, sink));
90
+ return;
91
+ }
92
+ if (!isObject(value)) return;
93
+ for (const [key, entry] of Object.entries(value)) {
94
+ if (sink.isProse(key)) harvestWithin(entry, `${where}.${key}`, sink);
95
+ else harvestNested(entry, `${where}.${key}`, sink);
96
+ }
97
+ };
98
+ var harvestNode = (node, where, sink) => {
99
+ if (node === null || node === void 0) return;
100
+ if (typeof node === "string") {
101
+ if (sink.text) sink.add(node, where);
102
+ return;
103
+ }
104
+ if (typeof node === "number" || typeof node === "boolean") return;
105
+ if (isArray(node)) {
106
+ node.forEach((child, index) => harvestNode(child, `${where}[${String(index)}]`, sink));
107
+ return;
108
+ }
109
+ if (!isObject(node)) return;
110
+ const component = node["component"];
111
+ if (component === void 0) {
112
+ if ("ref" in node || "slot" in node) return;
113
+ if ("if" in node) {
114
+ harvestNode(node["then"], `${where}.then`, sink);
115
+ harvestNode(node["else"], `${where}.else`, sink);
116
+ return;
117
+ }
118
+ if ("for" in node && "do" in node) {
119
+ harvestNode(node["do"], `${where}.do`, sink);
120
+ return;
121
+ }
122
+ return;
123
+ }
124
+ const at = `${where}/${String(component)}`;
125
+ const props = node["props"];
126
+ if (isObject(props)) harvestProps(props, at, sink);
127
+ harvestNode(node["children"], `${at}.children`, sink);
128
+ };
129
+ var toList = (found) => [...found.entries()].map(([phrase, sites]) => ({ phrase, where: [...sites].sort() })).sort((a, b) => a.phrase.localeCompare(b.phrase));
130
+ var harvestLayout = (layout, keys) => {
131
+ const found = /* @__PURE__ */ new Map();
132
+ harvestNode(layout, "", sinkInto(found, keys));
133
+ return toList(found);
134
+ };
135
+ var harvestSteps = (value, where, sink) => {
136
+ if (isArray(value)) {
137
+ value.forEach((entry, index) => harvestSteps(entry, `${where}[${String(index)}]`, sink));
138
+ return;
139
+ }
140
+ if (!isObject(value)) return;
141
+ const target = value["set"];
142
+ const written = value["value"];
143
+ if (typeof target === "string" && typeof written === "string") sink.add(written, `${where}.set:${target}`);
144
+ for (const [key, entry] of Object.entries(value)) {
145
+ if (key === "set" || key === "value") continue;
146
+ harvestSteps(entry, `${where}.${key}`, sink);
147
+ }
148
+ };
149
+ var harvestDefinition = (definition, keys) => {
150
+ const found = /* @__PURE__ */ new Map();
151
+ const sink = sinkInto(found, keys);
152
+ const id = definition.id;
153
+ if (typeof definition.title === "string") sink.add(definition.title, `${id}.title`);
154
+ for (const [key, value] of Object.entries(definition.data ?? {})) {
155
+ if (typeof value === "string") sink.add(value, `${id}.data.${key}`);
156
+ else if (isObject(value) || isArray(value)) harvestNested(value, `${id}.data.${key}`, sink);
157
+ }
158
+ if (definition.layout !== void 0) harvestNode(definition.layout, id, sink);
159
+ if (definition.triggers !== void 0) harvestSteps(definition.triggers, `${id}.triggers`, sink);
160
+ if (definition.lifecycle !== void 0) harvestSteps(definition.lifecycle, `${id}.lifecycle`, sink);
161
+ return toList(found);
162
+ };
163
+ var harvestDefinitions = (definitions, keys) => {
164
+ const found = /* @__PURE__ */ new Map();
165
+ for (const definition of Object.values(definitions)) {
166
+ for (const entry of harvestDefinition(definition, keys)) {
167
+ const sites = found.get(entry.phrase);
168
+ if (sites === void 0) found.set(entry.phrase, new Set(entry.where));
169
+ else for (const site of entry.where) sites.add(site);
170
+ }
171
+ }
172
+ return toList(found);
173
+ };
174
+ var missingFrom = (harvested, phrases) => harvested.filter((entry) => phrases[entry.phrase] === void 0);
175
+
176
+ export { harvestDefinition, harvestDefinitions, harvestLayout, missingFrom, translateRenderTree };
177
+ //# sourceMappingURL=chunk-XQTI4Q4I.js.map
178
+ //# sourceMappingURL=chunk-XQTI4Q4I.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/i18n/translate.ts","../src/i18n/harvest.ts"],"names":["children"],"mappings":";;;;AAoCA,IAAM,QAAA,GAAW,CAAC,IAAA,EAAkB,KAAA,EAAe,IAAA,KAA2B;AAC5E,EAAA,IAAI,IAAA,CAAK,SAAS,MAAA,EAAQ;AACxB,IAAA,IAAI,CAAC,IAAA,CAAK,IAAA,EAAM,OAAO,IAAA;AACvB,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,IAAA,CAAK,KAAA,EAAO,OAAO,IAAI,CAAA;AAC1C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AACA,EAAA,OAAO,OAAO,KAAK,CAAA;AACrB;AAGO,IAAM,WAAA,GAAc,CACzB,SAAA,EACA,OAAA,KACsB,SAAA,CAAU,MAAA,CAAO,CAAC,KAAA,KAAU,OAAA,CAAQ,KAAA,CAAM,MAAM,CAAA,KAAM,MAAS","file":"chunk-XQTI4Q4I.js","sourcesContent":["import type { RenderNode } from '../layout';\nimport { passFor, swap, walkValue } from './swap';\nimport type { Pass } from './swap';\nimport type { PhraseKeys, Phrasebook } from './phrases';\n\n// ═══════════════════════════════════════════════════════════\n// translateRenderTree — the late pass, for whoever holds a tree they did not\n// render.\n//\n// NOT the main road any more. Since the swap moved into the renderer\n// (`layout/renderer.ts`), a tree that came out of a nova shell is already in\n// the reader's language and this pass would find nothing to do. What is left\n// for it is every tree that arrived from somewhere else: a frame replayed from\n// a cache, an exporter's fixture, a test that builds nodes by hand.\n//\n// Structure in, same structure out, with prose swapped. A phrase with no entry\n// passes through unchanged — the only sane failure, since a missing\n// translation should show the source language, never an empty box and never a\n// key. `onMiss` is how a check turns those into a list.\n//\n// One deliberate difference from the renderer: an EMPTY book short-circuits\n// here and returns the very same tree, patterns included. The renderer fills\n// patterns even with no book, because a source-language session has nobody\n// else to do it; a tree-holder with no book has nothing to say about a tree it\n// did not make.\n// ═══════════════════════════════════════════════════════════\n\nexport type TranslateOptions = {\n phrases: Phrasebook;\n keys?: PhraseKeys;\n // Called once per untranslated phrase, with where it was found. For a dev\n // check that has to answer \"what did we forget\" without a human reading every\n // screen. Never call it from a hot path — it is a reporting seam.\n onMiss?: (phrase: string, where: string) => void;\n};\n\nconst walkNode = (node: RenderNode, where: string, pass: Pass): RenderNode => {\n if (node.type === 'text') {\n if (!pass.text) return node;\n const value = swap(node.value, where, pass);\n return value === node.value ? node : { ...node, value };\n }\n\n if (node.type === 'fragment') {\n const children = walkNodes(node.children, where, pass);\n return children === node.children ? node : { ...node, children };\n }\n\n // An error node's message is a diagnostic for whoever is on call, not product\n // copy — left in the language the stack throws in, deliberately.\n if (node.type === 'error') return node;\n\n const at = node.ref === undefined ? `${where}/${node.name}` : `${where}/${node.name}#${node.ref}`;\n let props = node.props;\n let propsChanged = false;\n const nextProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(node.props)) {\n const next = walkValue(value, pass.isProse(key), `${at}.${key}`, pass);\n if (next !== value) propsChanged = true;\n nextProps[key] = next;\n }\n if (propsChanged) props = nextProps;\n\n const children = walkNodes(node.children, at, pass);\n if (!propsChanged && children === node.children) return node;\n return { ...node, props, children };\n};\n\n// Identity is returned when nothing under a node changed. Not an optimisation\n// for its own sake: an untranslated locale (the source language) must produce\n// the byte-identical frame it produced before this pass existed, or every\n// English session pays a delta rebuild for a walk that did nothing.\nconst walkNodes = (nodes: RenderNode[], where: string, pass: Pass): RenderNode[] => {\n let changed = false;\n const out = nodes.map((node) => {\n const next = walkNode(node, where, pass);\n if (next !== node) changed = true;\n return next;\n });\n return changed ? out : nodes;\n};\n\nexport const translateRenderTree = (tree: RenderNode[], options: TranslateOptions): RenderNode[] => {\n // An empty phrasebook is the source language. Skip the walk entirely rather\n // than doing it and finding nothing.\n if (Object.keys(options.phrases).length === 0) return tree;\n const pass = passFor({\n phrases: options.phrases,\n ...(options.keys === undefined ? {} : { keys: options.keys }),\n ...(options.onMiss === undefined ? {} : { onMiss: options.onMiss }),\n });\n if (pass === undefined) return tree;\n return walkNodes(tree, '', pass);\n};\n","import { isArray, isObject } from '../shared/common';\nimport type { ActionDefinition } from '../action';\nimport type { LayoutNode } from '../layout';\nimport { isPhrase, matcherFor } from './phrases';\nimport type { PhraseKeys } from './phrases';\n\n// ═══════════════════════════════════════════════════════════\n// harvest — read every phrase an action could put on a screen, without\n// running it.\n//\n// The other half of the late pass. Keying a dictionary on source strings only\n// works if there is a mechanical way to enumerate them; otherwise \"translate\n// the app\" means a human reading every layout, and the second language is\n// permanently 90% done.\n//\n// This walks the AUTHORED artifacts — definitions and layouts — not a rendered\n// tree, and that is the point: what comes back is exactly the set of strings a\n// person wrote, never a value that arrived from the database. A member called\n// \"Pass\" can therefore never enter the dictionary by being on screen the day\n// somebody ran the harvest.\n// ═══════════════════════════════════════════════════════════\n\nexport type HarvestedPhrase = {\n phrase: string;\n /** Every author site it came from — sorted, deduped. */\n where: readonly string[];\n};\n\ntype Sink = {\n add: (phrase: string, where: string) => void;\n isProse: (key: string) => boolean;\n text: boolean;\n};\n\nconst sinkInto = (found: Map<string, Set<string>>, keys: PhraseKeys | undefined): Sink => {\n const matcher = matcherFor(keys);\n return {\n add: (phrase, where) => {\n const trimmed = phrase.trim();\n if (!isPhrase(trimmed)) return;\n const sites = found.get(trimmed);\n if (sites === undefined) found.set(trimmed, new Set([where]));\n else sites.add(where);\n },\n isProse: matcher.isProse,\n text: matcher.text,\n };\n};\n\n// Inside an allowlisted prop, EVERY reachable literal is a phrase. A `label`\n// holding `{ $if: …, $then: 'Save', $else: 'Create' }` has two of them, and a\n// harvester that only accepted a direct string would silently drop the branch\n// nobody was looking at.\nconst harvestWithin = (value: unknown, where: string, sink: Sink): void => {\n if (typeof value === 'string') {\n sink.add(value, where);\n return;\n }\n if (isArray(value)) {\n value.forEach((entry, index) => harvestWithin(entry, `${where}[${String(index)}]`, sink));\n return;\n }\n if (isObject(value)) {\n for (const [key, entry] of Object.entries(value)) harvestWithin(entry, `${where}.${key}`, sink);\n }\n};\n\nconst harvestProps = (props: Record<string, unknown>, where: string, sink: Sink): void => {\n for (const [key, value] of Object.entries(props)) {\n if (sink.isProse(key)) {\n harvestWithin(value, `${where}.${key}`, sink);\n continue;\n }\n // Not a prose key itself — but a nested object under it may hold one\n // (`cell: { label }` inside a column spec). Keep descending; only the KEY\n // decides, never the depth.\n if (isObject(value) || isArray(value)) harvestNested(value, `${where}.${key}`, sink);\n }\n};\n\nconst harvestNested = (value: unknown, where: string, sink: Sink): void => {\n if (isArray(value)) {\n value.forEach((entry, index) => harvestNested(entry, `${where}[${String(index)}]`, sink));\n return;\n }\n if (!isObject(value)) return;\n for (const [key, entry] of Object.entries(value)) {\n if (sink.isProse(key)) harvestWithin(entry, `${where}.${key}`, sink);\n else harvestNested(entry, `${where}.${key}`, sink);\n }\n};\n\n// Takes `unknown` rather than `LayoutNode`: the walk discriminates the node\n// kinds structurally, and narrowing a union by `in` checks fights the compiler\n// for no benefit here — every branch reads what it needs and guards it.\nconst harvestNode = (node: unknown, where: string, sink: Sink): void => {\n if (node === null || node === undefined) return;\n if (typeof node === 'string') {\n // A text position: the layout's literal children.\n if (sink.text) sink.add(node, where);\n return;\n }\n if (typeof node === 'number' || typeof node === 'boolean') return;\n if (isArray(node)) {\n node.forEach((child, index) => harvestNode(child, `${where}[${String(index)}]`, sink));\n return;\n }\n if (!isObject(node)) return;\n\n const component = node['component'];\n if (component === undefined) {\n // A stored-layout reference and a fragment slot are ids, never words.\n if ('ref' in node || 'slot' in node) return;\n if ('if' in node) {\n harvestNode(node['then'], `${where}.then`, sink);\n harvestNode(node['else'], `${where}.else`, sink);\n return;\n }\n if ('for' in node && 'do' in node) {\n harvestNode(node['do'], `${where}.do`, sink);\n return;\n }\n return;\n }\n\n const at = `${where}/${String(component)}`;\n const props = node['props'];\n if (isObject(props)) harvestProps(props, at, sink);\n harvestNode(node['children'], `${at}.children`, sink);\n};\n\nconst toList = (found: Map<string, Set<string>>): HarvestedPhrase[] =>\n [...found.entries()]\n .map(([phrase, sites]) => ({ phrase, where: [...sites].sort() }))\n .sort((a, b) => a.phrase.localeCompare(b.phrase));\n\nexport const harvestLayout = (layout: LayoutNode, keys?: PhraseKeys): HarvestedPhrase[] => {\n const found = new Map<string, Set<string>>();\n harvestNode(layout, '', sinkInto(found, keys));\n return toList(found);\n};\n\n// A `{ set: '<key>', value: '<literal>' }` step writes words into data, and\n// data lands in props. An error message a trigger sets is as much product copy\n// as a heading, and is otherwise invisible to a harvester that only reads\n// layouts.\nconst harvestSteps = (value: unknown, where: string, sink: Sink): void => {\n if (isArray(value)) {\n value.forEach((entry, index) => harvestSteps(entry, `${where}[${String(index)}]`, sink));\n return;\n }\n if (!isObject(value)) return;\n const target = value['set'];\n const written = value['value'];\n if (typeof target === 'string' && typeof written === 'string') sink.add(written, `${where}.set:${target}`);\n for (const [key, entry] of Object.entries(value)) {\n if (key === 'set' || key === 'value') continue;\n harvestSteps(entry, `${where}.${key}`, sink);\n }\n};\n\nexport const harvestDefinition = (definition: ActionDefinition, keys?: PhraseKeys): HarvestedPhrase[] => {\n const found = new Map<string, Set<string>>();\n const sink = sinkInto(found, keys);\n const id = definition.id;\n\n // The title is chrome's words — a Sheet header, a catalog entry — and reaches\n // the tree as a prop rather than from the layout.\n if (typeof definition.title === 'string') sink.add(definition.title, `${id}.title`);\n\n // Defaulted data is a screen's opening text: the 'Stock' in a theme name, the\n // placeholder a list shows before its first read lands.\n //\n // TWO RULES, because `data` is two things at once.\n //\n // A top-level string is taken WHOLE, whatever its key. Where it lands decides\n // whether it is prose, and only the LAYOUT knows that: `runningHint` is not a\n // prose key and reaches the glass as a text child, so a matcher applied here\n // would drop a sentence the pass goes on to translate. The cost of taking\n // them all is enum values and ids in the report, which a host filters by name.\n //\n // Anything NESTED is walked by the matcher instead, and that is the rule that\n // reaches an options array — `views: [{ value: 'running', label: 'Running' }]`\n // yields `Running` and never `running`. Without it a tab strip built in data\n // is not merely untranslatable but UNCOUNTED, which is the worse half: the\n // harvest reports a full book while the words are missing from the screen.\n for (const [key, value] of Object.entries(definition.data ?? {})) {\n if (typeof value === 'string') sink.add(value, `${id}.data.${key}`);\n else if (isObject(value) || isArray(value)) harvestNested(value, `${id}.data.${key}`, sink);\n }\n\n if (definition.layout !== undefined) harvestNode(definition.layout, id, sink);\n if (definition.triggers !== undefined) harvestSteps(definition.triggers, `${id}.triggers`, sink);\n if (definition.lifecycle !== undefined) harvestSteps(definition.lifecycle, `${id}.lifecycle`, sink);\n\n return toList(found);\n};\n\nexport const harvestDefinitions = (\n definitions: Record<string, ActionDefinition>,\n keys?: PhraseKeys,\n): HarvestedPhrase[] => {\n const found = new Map<string, Set<string>>();\n for (const definition of Object.values(definitions)) {\n for (const entry of harvestDefinition(definition, keys)) {\n const sites = found.get(entry.phrase);\n if (sites === undefined) found.set(entry.phrase, new Set(entry.where));\n else for (const site of entry.where) sites.add(site);\n }\n }\n return toList(found);\n};\n\n/** Phrases with no entry in the book — what a language is still missing. */\nexport const missingFrom = (\n harvested: readonly HarvestedPhrase[],\n phrases: Readonly<Record<string, string>>,\n): HarvestedPhrase[] => harvested.filter((entry) => phrases[entry.phrase] === undefined);\n"]}