@niscorp/nova 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADAPTER.md +6 -6
- package/CHANGELOG.md +30 -0
- package/README.md +46 -21
- package/dist/adapters/dom/components/index.d.cts +2 -2
- package/dist/adapters/dom/components/index.d.ts +2 -2
- package/dist/adapters/dom/index.cjs +163 -34
- package/dist/adapters/dom/index.cjs.map +1 -1
- package/dist/adapters/dom/index.d.cts +2 -2
- package/dist/adapters/dom/index.d.ts +2 -2
- package/dist/adapters/dom/index.js +6 -6
- package/dist/adapters/dom/server.cjs +0 -2
- package/dist/adapters/dom/server.cjs.map +1 -1
- package/dist/adapters/dom/server.d.cts +2 -2
- package/dist/adapters/dom/server.d.ts +2 -2
- package/dist/adapters/dom/server.js +6 -6
- package/dist/adapters/react/components/index.cjs +6 -8
- package/dist/adapters/react/components/index.cjs.map +1 -1
- package/dist/adapters/react/components/index.d.cts +4 -4
- package/dist/adapters/react/components/index.d.ts +4 -4
- package/dist/adapters/react/components/index.js +7 -7
- package/dist/adapters/react/index.cjs +181 -51
- package/dist/adapters/react/index.cjs.map +1 -1
- package/dist/adapters/react/index.d.cts +4 -4
- package/dist/adapters/react/index.d.ts +4 -4
- package/dist/adapters/react/index.js +7 -7
- package/dist/adapters/tty/components/index.d.cts +2 -2
- package/dist/adapters/tty/components/index.d.ts +2 -2
- package/dist/adapters/tty/index.cjs +0 -2
- package/dist/adapters/tty/index.cjs.map +1 -1
- package/dist/adapters/tty/index.d.cts +2 -2
- package/dist/adapters/tty/index.d.ts +2 -2
- package/dist/adapters/tty/index.js +4 -4
- package/dist/adapters/tty/index.js.map +1 -1
- package/dist/adapters/vue/components/index.cjs +4 -6
- package/dist/adapters/vue/components/index.cjs.map +1 -1
- package/dist/adapters/vue/components/index.d.cts +9 -9
- package/dist/adapters/vue/components/index.d.ts +9 -9
- package/dist/adapters/vue/components/index.js +7 -7
- package/dist/adapters/vue/index.cjs +175 -46
- package/dist/adapters/vue/index.cjs.map +1 -1
- package/dist/adapters/vue/index.d.cts +4 -4
- package/dist/adapters/vue/index.d.ts +4 -4
- package/dist/adapters/vue/index.js +9 -9
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/agent/index.d.cts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/{chunk-7PKS7UYL.js → chunk-3JRTELLC.js} +3 -3
- package/dist/{chunk-7PKS7UYL.js.map → chunk-3JRTELLC.js.map} +1 -1
- package/dist/{chunk-4I2PFMY7.js → chunk-MHW5VEIM.js} +8 -8
- package/dist/chunk-MHW5VEIM.js.map +1 -0
- package/dist/chunk-OE4E6IBD.js +25 -0
- package/dist/chunk-OE4E6IBD.js.map +1 -0
- package/dist/{chunk-KYQ4EAQH.js → chunk-QXQCPH33.js} +17 -17
- package/dist/chunk-QXQCPH33.js.map +1 -0
- package/dist/chunk-RFBIGRCI.js +127 -0
- package/dist/chunk-RFBIGRCI.js.map +1 -0
- package/dist/{chunk-WZVQ5PUB.js → chunk-RYIIIXDX.js} +4 -4
- package/dist/{chunk-WZVQ5PUB.js.map → chunk-RYIIIXDX.js.map} +1 -1
- package/dist/{chunk-4ERQYDF6.js → chunk-UDCXGDLQ.js} +10 -10
- package/dist/chunk-UDCXGDLQ.js.map +1 -0
- package/dist/chunk-V4BPFFFV.js +152 -0
- package/dist/chunk-V4BPFFFV.js.map +1 -0
- package/dist/{chunk-UUYXVOK2.js → chunk-VU6NNCEJ.js} +16 -16
- package/dist/chunk-VU6NNCEJ.js.map +1 -0
- package/dist/{chunk-RXECI7DE.js → chunk-Y6XVPRYH.js} +33 -17
- package/dist/chunk-Y6XVPRYH.js.map +1 -0
- package/dist/devtools/index.d.cts +2 -2
- package/dist/devtools/index.d.ts +2 -2
- package/dist/devtools/index.js +3 -3
- package/dist/document/index.cjs +228 -119
- package/dist/document/index.cjs.map +1 -1
- package/dist/document/index.d.cts +10 -8
- package/dist/document/index.d.ts +10 -8
- package/dist/document/index.js +3 -122
- package/dist/document/index.js.map +1 -1
- package/dist/head-CAzfTnpV.d.cts +25 -0
- package/dist/head-DRpbbj-l.d.ts +25 -0
- package/dist/i18n/index.d.cts +2 -2
- package/dist/i18n/index.d.ts +2 -2
- package/dist/index.cjs +151 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -31
- package/dist/index.d.ts +19 -31
- package/dist/index.js +4 -4
- package/dist/{palette-Mx7XHYC6.d.ts → palette-CIpPH90W.d.ts} +1 -1
- package/dist/{palette-wbJB_svk.d.cts → palette-CvwZZCkx.d.cts} +1 -1
- package/dist/reflect/index.d.cts +2 -2
- package/dist/reflect/index.d.ts +2 -2
- package/dist/reflect/index.js +3 -3
- package/dist/{types-B-rjaUX0.d.ts → types-BSKx5MXW.d.ts} +1 -1
- package/dist/{types-B_nOtkyt.d.ts → types-BWc-olbY.d.ts} +1 -1
- package/dist/{types-mRKXqZPX.d.cts → types-C9734_lJ.d.cts} +1 -1
- package/dist/{types-BB9RXel5.d.ts → types-D23TRvqe.d.ts} +1 -1
- package/dist/{types-uk19d6KC.d.cts → types-DsWNYc7R.d.cts} +1 -1
- package/dist/{types-BLVRduoz.d.cts → types-j290XhCn.d.cts} +1 -1
- package/dist/{types-PDXOkvtK.d.cts → types-qkzTfSye.d.cts} +1 -1
- package/dist/{types-DE77Jl2W.d.ts → types-qnKMx0_V.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/chunk-4ERQYDF6.js.map +0 -1
- package/dist/chunk-4I2PFMY7.js.map +0 -1
- package/dist/chunk-EHHJJLRX.js +0 -16
- package/dist/chunk-EHHJJLRX.js.map +0 -1
- package/dist/chunk-KYQ4EAQH.js.map +0 -1
- package/dist/chunk-RXECI7DE.js.map +0 -1
- package/dist/chunk-UUYXVOK2.js.map +0 -1
- package/dist/chunk-UV5YGBHQ.js +0 -62
- package/dist/chunk-UV5YGBHQ.js.map +0 -1
- package/dist/chunk-X7SSNSQC.js +0 -6
- package/dist/chunk-X7SSNSQC.js.map +0 -1
- package/dist/head-BNj8GwPO.d.cts +0 -20
- package/dist/head-CS6X6ZKr.d.ts +0 -20
- package/dist/{primitive-props-Cl5jiC8g.d.cts → primitive-props-CGoJvmcH.d.cts} +5 -5
- package/dist/{primitive-props-Cl5jiC8g.d.ts → primitive-props-CGoJvmcH.d.ts} +5 -5
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { N as NovaComponent, a as NovaDispatch, b as NovaPublish } from '../../types-
|
|
2
|
-
export { c as NovaComponentProps, d as NovaModelBinding } from '../../types-
|
|
1
|
+
import { N as NovaComponent, a as NovaDispatch, b as NovaPublish } from '../../types-DsWNYc7R.cjs';
|
|
2
|
+
export { c as NovaComponentProps, d as NovaModelBinding } from '../../types-DsWNYc7R.cjs';
|
|
3
3
|
import { FC, ReactNode, ComponentType, Component, ErrorInfo } from 'react';
|
|
4
4
|
import { A as ActionDefinition } from '../../index-caZoXSwr.cjs';
|
|
5
|
-
import { C as ComponentRegistry, b as RenderNode, s as RegistrationInput, L as LayoutStore, a as RenderOnError, R as RenderContext } from '../../types-
|
|
6
|
-
import { a as Shell, q as StateSnapshot, d as CanvasState, b as ActionStatus } from '../../types-
|
|
5
|
+
import { C as ComponentRegistry, b as RenderNode, s as RegistrationInput, L as LayoutStore, a as RenderOnError, R as RenderContext } from '../../types-j290XhCn.cjs';
|
|
6
|
+
import { a as Shell, q as StateSnapshot, d as CanvasState, b as ActionStatus } from '../../types-qkzTfSye.cjs';
|
|
7
7
|
import { L as LayoutNode } from '../../schemas-DPdeFlCT.cjs';
|
|
8
8
|
import '../../schemas-pMyyuXV7.cjs';
|
|
9
9
|
import 'zod';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { N as NovaComponent, a as NovaDispatch, b as NovaPublish } from '../../types-
|
|
2
|
-
export { c as NovaComponentProps, d as NovaModelBinding } from '../../types-
|
|
1
|
+
import { N as NovaComponent, a as NovaDispatch, b as NovaPublish } from '../../types-BSKx5MXW.js';
|
|
2
|
+
export { c as NovaComponentProps, d as NovaModelBinding } from '../../types-BSKx5MXW.js';
|
|
3
3
|
import { FC, ReactNode, ComponentType, Component, ErrorInfo } from 'react';
|
|
4
4
|
import { A as ActionDefinition } from '../../index-CNfzSBe2.js';
|
|
5
|
-
import { C as ComponentRegistry, b as RenderNode, s as RegistrationInput, L as LayoutStore, a as RenderOnError, R as RenderContext } from '../../types-
|
|
6
|
-
import { a as Shell, q as StateSnapshot, d as CanvasState, b as ActionStatus } from '../../types-
|
|
5
|
+
import { C as ComponentRegistry, b as RenderNode, s as RegistrationInput, L as LayoutStore, a as RenderOnError, R as RenderContext } from '../../types-qnKMx0_V.js';
|
|
6
|
+
import { a as Shell, q as StateSnapshot, d as CanvasState, b as ActionStatus } from '../../types-D23TRvqe.js';
|
|
7
7
|
import { L as LayoutNode } from '../../schemas-DPdeFlCT.js';
|
|
8
8
|
import '../../schemas-pMyyuXV7.js';
|
|
9
9
|
import 'zod';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { ErrorMarker, Nova, NovaCanvas, NovaErrorBoundary, NovaLayout, NovaRenderProvider, NovaShell, NovaShellProvider, RenderNodeView, RenderTree, useActionData, useActionStatus, useCanvas, useCanvasRenderTree, useNovaDispatch, useNovaPublish, useNovaRegistry, useRenderTree, useShell, useShellRenderTree, useShellState, useSlotWrapper } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
1
|
+
export { ErrorMarker, Nova, NovaCanvas, NovaErrorBoundary, NovaLayout, NovaRenderProvider, NovaShell, NovaShellProvider, RenderNodeView, RenderTree, useActionData, useActionStatus, useCanvas, useCanvasRenderTree, useNovaDispatch, useNovaPublish, useNovaRegistry, useRenderTree, useShell, useShellRenderTree, useShellState, useSlotWrapper } from '../../chunk-QXQCPH33.js';
|
|
2
|
+
import '../../chunk-UDCXGDLQ.js';
|
|
3
|
+
import '../../chunk-V4BPFFFV.js';
|
|
4
|
+
import '../../chunk-RYIIIXDX.js';
|
|
5
|
+
import '../../chunk-RFBIGRCI.js';
|
|
6
|
+
import '../../chunk-Y6XVPRYH.js';
|
|
7
7
|
import '../../chunk-OGD5CCMZ.js';
|
|
8
8
|
import '../../chunk-7TS3YVQR.js';
|
|
9
|
-
import '../../chunk-
|
|
9
|
+
import '../../chunk-OE4E6IBD.js';
|
|
10
10
|
import '../../chunk-DIFE573X.js';
|
|
11
11
|
import '../../chunk-JI7ZRESP.js';
|
|
12
12
|
import '../../chunk-RBU5PHN4.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ComponentRegistry } from '../../../types-
|
|
1
|
+
import { C as ComponentRegistry } from '../../../types-j290XhCn.cjs';
|
|
2
2
|
import { TtyComponent, TtyBlock } from '../index.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../../../schemas-DPdeFlCT.cjs';
|
|
5
|
-
import '../../../types-
|
|
5
|
+
import '../../../types-qkzTfSye.cjs';
|
|
6
6
|
import '../../../index-caZoXSwr.cjs';
|
|
7
7
|
import '../../../effects-CndX9K7D.cjs';
|
|
8
8
|
import '../../../schemas-pMyyuXV7.cjs';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ComponentRegistry } from '../../../types-
|
|
1
|
+
import { C as ComponentRegistry } from '../../../types-qnKMx0_V.js';
|
|
2
2
|
import { TtyComponent, TtyBlock } from '../index.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../../../schemas-DPdeFlCT.js';
|
|
5
|
-
import '../../../types-
|
|
5
|
+
import '../../../types-D23TRvqe.js';
|
|
6
6
|
import '../../../index-CNfzSBe2.js';
|
|
7
7
|
import '../../../effects-CndX9K7D.js';
|
|
8
8
|
import '../../../schemas-pMyyuXV7.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layout/head.ts","../../../src/shell/head.ts","../../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,EACf;AACA,EAAA,OAAO,IAAI,CAAC,CAAA,EAAG,MAAK,KAAM,EAAA,MAAQ,KAAA,EAAM;AACxC,EAAA,OAAO,GAAA,CAAI,IAAI,MAAA,GAAS,CAAC,GAAG,IAAA,EAAK,KAAM,EAAA,EAAI,GAAA,CAAI,GAAA,EAAI;AACnD,EAAA,OAAO,GAAA;AACT,CAAA;AAEO,IAAM,gBAAgB,CAC3B,QAAA,EACA,GAAA,EACA,OAAA,GAAuC,EAAC,KAC5B;AACZ,EAAA,MAAM,SAAS,MAAgB;AAC7B,IAAA,MAAM,MAAwB,EAAC;AAG/B,IAAA,MAAM,MAAW,EAAE,QAAA,EAAU,MAAA,EAAQ,EAAA,EAAI,KAAK,GAAA,EAAK,GAAI,OAAA,CAAQ,QAAA,KAAa,SAAY,EAAE,QAAA,EAAU,QAAQ,QAAA,EAAS,GAAI,EAAC,EAAG;AAC7H,IAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,KAAA,EAAM,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS,UAAA,CAAW,IAAA,EAAM,GAAG,CAAA,CAAE,KAAK,CAAA;AACvE,IAAA,OAAO,EAAE,MAAM,IAAA,CAAK,KAAK,EAAE,IAAA,CAAK,IAAI,CAAA,EAAG,YAAA,EAAc,GAAA,EAAI;AAAA,EAC3D,CAAA;AACA,EAAA,OAAO,EAAE,MAAA,EAAO;AAClB","file":"index.cjs","sourcesContent":["// ═══════════════════════════════════════════════════════════\n// THE HEAD — what a screen says it is, as a node in its layout.\n//\n// A document has a part nobody sees on the screen: its title, the sentence\n// that describes it, the picture shown where a link to it is pasted. Those are\n// facts about what the screen shows, so they come from where everything else\n// on the screen comes from — a layout node, its props bound to the action's\n// data — and travel the way everything else does, in the render tree.\n//\n// The node draws nothing. No adapter builds an element for it and no registry\n// has to hold it. Whoever writes the document reads it off the tree (`headOf`)\n// and says it in the surface's own terms: a browser's <head>, a tab's title.\n//\n// The props say what the screen IS, from a closed set of names\n// (./head.schema). How that is spelled in tags is the writer's business, and\n// where the document lives (its address) is not the screen's to say at all — a\n// layout never holds a URL of its own page.\n//\n// This file holds no schema on purpose: a terminal that only reads a head off\n// the wire needs the name and the shape, and nothing to validate with.\n// ═══════════════════════════════════════════════════════════\n\n// Namespaced as a package's own in-layout components are (`loom:field`), so it\n// can never be a name an app's kit already uses for something else.\nexport const HEAD_NAME = 'nova:head';\n\n// What a head node said, once its bindings are resolved and anything it left\n// empty is gone.\nexport type Head = {\n title?: string;\n description?: string;\n image?: string;\n kind?: 'website' | 'article';\n structured?: Record<string, unknown> | Record<string, unknown>[];\n};\n","import { HEAD_NAME } from '../layout/head';\nimport type { Head } from '../layout/head';\nimport type { RenderNode } from '../layout';\nimport type { RenderApi } from './types';\nimport { ACTION_SLOT_NAME, CANVAS_SLOT_NAME } from './slot-names';\n\n// ═══════════════════════════════════════════════════════════\n// The head a screen has, read off its render tree.\n//\n// The frame is walked in the order it is drawn, into each canvas where its\n// slot stands and into each instance on it. A screen can hold more than one\n// head node — a dialog opened over a page — and then THE LAST ONE SPEAKS, whole:\n// two heads are two things, and a title from one beside a description from the\n// other describes neither.\n//\n// A node that says nothing (its bindings are not answered yet) is still the\n// one that speaks: the document keeps what it had rather than borrow from a\n// screen underneath.\n// ═══════════════════════════════════════════════════════════\n\nexport type ScreenHead = {\n head: Head;\n // the action whose instance the node stands in; absent for a node in the\n // frame or in a canvas's own layout\n action?: string;\n};\n\ntype Found = { props: Record<string, unknown>; action: string | undefined };\n\nconst said = (value: unknown): string | undefined => (typeof value === 'string' && value.trim() !== '' ? value : undefined);\n\nconst isObject = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst structuredOf = (value: unknown): Head['structured'] => {\n if (isObject(value)) return value;\n if (Array.isArray(value) && value.length > 0 && value.every(isObject)) return value;\n return undefined;\n};\n\n// A prop that is not one of the names, or holds something other than what its\n// name takes, is left out — the document keeps what it had there.\nconst headFrom = (props: Record<string, unknown>): Head => {\n const [title, description, image] = [said(props['title']), said(props['description']), said(props['image'])];\n const kind = props['kind'] === 'website' || props['kind'] === 'article' ? props['kind'] : undefined;\n const structured = structuredOf(props['structured']);\n return {\n ...(title !== undefined ? { title } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(image !== undefined ? { image } : {}),\n ...(kind !== undefined ? { kind } : {}),\n ...(structured !== undefined ? { structured } : {}),\n };\n};\n\nexport const isHeadNode = (node: RenderNode): boolean => node.type === 'component' && node.name === HEAD_NAME;\n\nexport const headOf = (api: Pick<RenderApi, 'frame' | 'canvasTree'>): ScreenHead | undefined => {\n const found: Found[] = [];\n // a canvas whose own tree names it again would never end\n const open = new Set<string>();\n\n const walk = (nodes: readonly RenderNode[], action: string | undefined): void => {\n for (const node of nodes) {\n if (node.type === 'fragment') {\n walk(node.children, action);\n continue;\n }\n if (node.type !== 'component') continue;\n if (node.name === HEAD_NAME) {\n found.push({ props: node.props, action });\n continue;\n }\n if (node.name === CANVAS_SLOT_NAME) {\n const canvasId = node.props['canvasId'];\n if (typeof canvasId !== 'string' || canvasId === '' || open.has(canvasId)) continue;\n open.add(canvasId);\n walk(api.canvasTree(canvasId), undefined);\n open.delete(canvasId);\n continue;\n }\n const definitionId = node.name === ACTION_SLOT_NAME ? node.props['definitionId'] : undefined;\n walk(node.children, typeof definitionId === 'string' ? definitionId : action);\n }\n };\n\n walk(api.frame(), undefined);\n const last = found[found.length - 1];\n if (last === undefined) return undefined;\n return { head: headFrom(last.props), ...(last.action !== undefined ? { action: last.action } : {}) };\n};\n","import type { ComponentRegistry, RenderNode } from '@layout/types';\nimport { isHeadNode } from '@shell';\nimport type { RenderApi } from '@shell';\n\n// ═══════════════════════════════════════════════════════════\n// @niscorp/nova/adapters/tty — a text adapter, the terminal sibling of\n// nova/dom. It turns a served RenderNode tree into lines of plain text plus a\n// numbered table of INTERACTIVES: every `ref`'d node prints with a `[n]`\n// marker and lands in the table, so a REPL host can map \"click 3\" / \"set 5 x\"\n// onto the same event vocabulary the DOM adapter wires by convention —\n// `ui:click` (payload = the node's `value` prop), `ui:model`, `ui:key`.\n// Origin is never stamped here — moss stamps the active instance server-side.\n//\n// No framework, no I/O, no node builtins: render() is a pure snapshot →\n// { text, interactives }. The host (moss's terminal/tty target) owns stdio,\n// prompts, and dispatch; this adapter only says what the screen IS and what\n// on it can be acted on. `CanvasSlot` is resolved here (the frame's markers →\n// per-canvas trees), the one piece of terminal structure the renderer owns.\n// See packages/nova/ADAPTER.md for the shared adapter contract.\n// ═══════════════════════════════════════════════════════════\n\n// A rendered block: lines of text, composed upward (a Stack stacks child\n// blocks, a Row joins single-line children inline, …).\nexport type TtyBlock = { lines: string[] };\n\n// What an interactive marker can be driven with — the REPL host maps these\n// to events: click/row → ui:click, model → ui:model (a typed value),\n// toggle → ui:model (a negated boolean).\nexport type TtyInteractiveKind = 'click' | 'row' | 'model' | 'toggle';\n\nexport type TtyInteractive = {\n // the printed `[n]` — 1-based, in registration order\n index: number;\n kind: TtyInteractiveKind;\n ref: string;\n // the canvas whose dispatch this belongs to; '' = frame chrome (dispatches\n // nothing, same as the DOM adapter's frame)\n canvas: string;\n // the action instance it sits in (the enclosing ActionSlot's instanceId) —\n // a list canvas renders several live instances at once, so the host stamps\n // this as the event's origin, exactly as the DOM adapter does. Absent\n // outside any instance.\n origin?: string;\n // what was printed — for the host's `refs` listing\n label: string;\n // click/row: the dispatch payload; model/toggle: the current value\n value?: unknown;\n // the model path, when model-bound — display only, the server owns meaning\n path?: string;\n};\n\nexport type TtyComponentContext = {\n props: Record<string, unknown>;\n // the node's children, already rendered — the component stacks or joins\n // them where it wants (leaves ignore them).\n children: TtyBlock[];\n // register an interactive and get its printed index — for data-driven\n // components with INTERNAL interactivity (a table's rows, a panel's ✕);\n // simple components let the renderer mark their `ref`/`model` by convention.\n register: (entry: { kind: TtyInteractiveKind; ref: string; label: string; value?: unknown; path?: string }) => number;\n};\n\n// A TTY component: props + rendered children in, one block of lines out.\nexport type TtyComponent = (ctx: TtyComponentContext) => TtyBlock;\n\n// What the terminal hands the view: core's `RenderApi` — the same single\n// definition the dom/react adapters and moss's terminal share.\nexport type TtyRenderApi = RenderApi;\n\n// One rendered frame: the full screen text and everything actionable on it.\nexport type TtyFrame = { text: string; interactives: TtyInteractive[] };\n\nexport type TtyView = {\n // render the current snapshot; call on every wire change\n render: () => TtyFrame;\n};\n\nconst CANVAS_SLOT = 'CanvasSlot';\nconst ACTION_SLOT = 'ActionSlot';\nconst RULE_WIDTH = 60;\n\n// The recursion context: the registry, the canvas in force (frame chrome is\n// ''; a CanvasSlot switches it), the interactive accumulator, the resolver.\ntype Ctx = {\n registry: ComponentRegistry<TtyComponent>;\n canvas: string;\n // the enclosing action instance, when inside one (an ActionSlot switches it)\n origin?: string;\n api: TtyRenderApi;\n out: TtyInteractive[];\n // used when a component name is unregistered — a permissive renderer (the\n // default kit) supplies one so unknown primitives render their children\n // instead of an error; strict consumers omit it.\n fallback?: TtyComponent;\n};\n\nconst errorBlock = (code: string, message: string): TtyBlock => ({ lines: [`!! ${code}: ${message}`] });\n\nconst labelOf = (block: TtyBlock, ref: string): string => {\n const first = block.lines[0]?.trim() ?? '';\n return first === '' ? ref : first.slice(0, 48);\n};\n\n// A canvas heading: `── main ─────…` — the one piece of chrome the renderer\n// prints itself, so a REPL reader can tell canvases apart.\nconst canvasRule = (id: string): string => {\n const head = `── ${id} `;\n return head + '─'.repeat(Math.max(0, RULE_WIDTH - head.length));\n};\n\nconst renderNode = (node: RenderNode, ctx: Ctx): TtyBlock => {\n if (node.type === 'text') return { lines: node.value.split('\\n') };\n if (node.type === 'fragment') return { lines: node.children.flatMap((child) => renderNode(child, ctx).lines) };\n if (node.type === 'error') return errorBlock(node.code, node.message);\n\n // component\n // a head is something the screen says, not something it shows\n if (isHeadNode(node)) return { lines: [] };\n if (node.name === CANVAS_SLOT) {\n const canvasId = typeof node.props['canvasId'] === 'string' ? (node.props['canvasId'] as string) : '';\n if (canvasId === '') return { lines: [] };\n const tree = ctx.api.canvasTree(canvasId);\n // an empty canvas collapses entirely — no heading for nothing\n if (tree.length === 0) return { lines: [] };\n // a canvas starts outside any instance, even one placed by an instance's layout\n const { origin: _outer, ...outside } = ctx;\n const canvasCtx: Ctx = { ...outside, canvas: canvasId };\n return { lines: [canvasRule(canvasId), ...tree.flatMap((child) => renderNode(child, canvasCtx).lines), ''] };\n }\n\n const entry = ctx.registry.get(node.name);\n const build = entry !== undefined ? entry.component : ctx.fallback;\n if (build === undefined) return errorBlock('COMPONENT_NOT_FOUND', node.name);\n\n // An ActionSlot is an instance boundary: what is inside it belongs to it.\n const instanceId = node.name === ACTION_SLOT ? node.props['instanceId'] : undefined;\n const inner: Ctx = typeof instanceId === 'string' && instanceId !== '' ? { ...ctx, origin: instanceId } : ctx;\n const children = node.children.filter((child) => !isHeadNode(child)).map((child) => renderNode(child, inner));\n const register: TtyComponentContext['register'] = (item) => {\n const interactive: TtyInteractive = { index: ctx.out.length + 1, canvas: ctx.canvas, ...(ctx.origin !== undefined ? { origin: ctx.origin } : {}), ...item };\n ctx.out.push(interactive);\n return interactive.index;\n };\n const block = build({ props: node.props, children, register });\n\n // Convention wiring, the TTY twin of the DOM adapter's listeners: a model'd\n // node is an input (`toggle` when its current value is a boolean), a bare\n // ref'd node is clickable (payload = its `value` prop). The marker lands on\n // the block's first line.\n if (node.model !== undefined) {\n const current = node.props['value'] ?? node.props['checked'];\n const kind: TtyInteractiveKind = typeof current === 'boolean' ? 'toggle' : 'model';\n const index = register({ kind, ref: node.model.ref, label: labelOf(block, node.model.ref), value: current, path: node.model.path });\n return { lines: [`[${index}] ${block.lines[0] ?? ''}`, ...block.lines.slice(1)] };\n }\n if (node.ref !== undefined) {\n const value = node.props['value'];\n const index = register({ kind: 'click', ref: node.ref, label: labelOf(block, node.ref), ...(value !== undefined ? { value } : {}) });\n return { lines: [`[${index}] ${block.lines[0] ?? ''}`, ...block.lines.slice(1)] };\n }\n return block;\n};\n\n// Collapse runs of blank lines so stacked empty canvases don't leave gaps.\nconst tidy = (lines: string[]): string[] => {\n const out: string[] = [];\n for (const line of lines) {\n if (line.trim() === '' && out[out.length - 1]?.trim() === '') continue;\n out.push(line);\n }\n while (out[0]?.trim() === '') out.shift();\n while (out[out.length - 1]?.trim() === '') out.pop();\n return out;\n};\n\nexport const createTtyView = (\n registry: ComponentRegistry<TtyComponent>,\n api: TtyRenderApi,\n options: { fallback?: TtyComponent } = {},\n): TtyView => {\n const render = (): TtyFrame => {\n const out: TtyInteractive[] = [];\n // The frame is chrome — its interactives belong to no canvas and the host\n // dispatches nothing for them, same as the DOM adapter's frame dispatch.\n const ctx: Ctx = { registry, canvas: '', api, out, ...(options.fallback !== undefined ? { fallback: options.fallback } : {}) };\n const lines = api.frame().flatMap((node) => renderNode(node, ctx).lines);\n return { text: tidy(lines).join('\\n'), interactives: out };\n };\n return { render };\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/layout/head.ts","../../../src/shell/head.ts","../../../src/adapters/tty/index.ts"],"names":[],"mappings":";;;AA+BO,IAAM,SAAA,GAAY,WAAA;ACsElB,IAAM,aAAa,CAAC,IAAA,KAA8B,KAAK,IAAA,KAAS,WAAA,IAAe,KAAK,IAAA,KAAS,SAAA;;;ACxBpG,IAAM,WAAA,GAAc,YAAA;AACpB,IAAM,WAAA,GAAc,YAAA;AACpB,IAAM,UAAA,GAAa,EAAA;AAiBnB,IAAM,UAAA,GAAa,CAAC,IAAA,EAAc,OAAA,MAA+B,EAAE,KAAA,EAAO,CAAC,CAAA,GAAA,EAAM,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE,CAAA,EAAE,CAAA;AAErG,IAAM,OAAA,GAAU,CAAC,KAAA,EAAiB,GAAA,KAAwB;AACxD,EAAA,MAAM,QAAQ,KAAA,CAAM,KAAA,CAAM,CAAC,CAAA,EAAG,MAAK,IAAK,EAAA;AACxC,EAAA,OAAO,UAAU,EAAA,GAAK,GAAA,GAAM,KAAA,CAAM,KAAA,CAAM,GAAG,EAAE,CAAA;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A,CAAW,IAAA,EAAM,GAAG,CAAA,CAAE,KAAK,CAAA;AACvE,IAAA,OAAO,EAAE,MAAM,IAAA,CAAK,KAAK,EAAE,IAAA,CAAK,IAAI,CAAA,EAAG,YAAA,EAAc,GAAA,EAAI;AAAA,EAC3D,CAAA;AACA,EAAA,OAAO,EAAE,MAAA,EAAO;AAClB","file":"index.cjs","sourcesContent":["// ═══════════════════════════════════════════════════════════\n// THE HEAD — `nova:head` is the document's <head>, as a node in a layout.\n//\n// A document has a part nobody sees on the screen: its title, the sentence\n// that describes it, the card shown where a link to it is pasted. That part\n// is written the way the rest of the screen is — a layout node, its children\n// bound to the action's data — and travels the way the rest does, in the\n// render tree.\n//\n// Its children are the elements a head holds, named as HTML names them:\n// `nova:title`, `nova:meta`, `nova:link`, `nova:script`. A child's props are\n// that element's ATTRIBUTES, written as given. Nova keeps no list of them, so\n// any `name`, `property` or `rel` there is — or will be — can be said without\n// nova learning it.\n//\n// Nothing here is drawn on the screen. No adapter builds an element for a head\n// or for anything in it, and no registry has to hold the names. Whoever writes\n// the document reads the elements off the tree (`headOf`) and writes them into\n// its <head>.\n//\n// WHAT A HEAD DOES NOT HOLD is what runs or styles: a script that executes, a\n// stylesheet, a <base>, an instruction to the browser (`http-equiv`), a handler\n// attribute. A layout is data, and data that reaches every page must not be\n// able to run. Those stay in the app's own index.html, which holds anything.\n//\n// This file holds no schema on purpose: a terminal that only reads a head off\n// the wire needs the names and the shape, and nothing to validate with.\n// ═══════════════════════════════════════════════════════════\n\n// Namespaced as a package's own in-layout components are (`loom:field`), so\n// none can be a name an app's kit already uses for something else.\nexport const HEAD_NAME = 'nova:head';\nexport const HEAD_TITLE_NAME = 'nova:title';\nexport const HEAD_META_NAME = 'nova:meta';\nexport const HEAD_LINK_NAME = 'nova:link';\nexport const HEAD_SCRIPT_NAME = 'nova:script';\n\n// The head and what it holds: the names a layout may use with no registry\n// entry behind them.\nexport const HEAD_NAMES: readonly string[] = [HEAD_NAME, HEAD_TITLE_NAME, HEAD_META_NAME, HEAD_LINK_NAME, HEAD_SCRIPT_NAME];\n\n// One element of a head, as data: what to write, wherever a head is written.\nexport type HeadElement = {\n tag: 'title' | 'meta' | 'link' | 'script';\n // as the layout gave them, in the order it gave them\n attributes: Record<string, string>;\n // a title's words; a script's data, as JSON\n text?: string;\n};\n\n// What two elements both say, when they say the same thing — the later one\n// then takes the earlier one's place. A document has one title, one <meta> of\n// a given name or property, one canonical address. Anything else stands beside\n// its like: two alternates, two data blocks.\nexport const headKeyOf = (element: Pick<HeadElement, 'tag' | 'attributes'>): string | undefined => {\n const said = (name: string): string | undefined => {\n const found = Object.entries(element.attributes).find(([key]) => key.toLowerCase() === name)?.[1].trim().toLowerCase();\n return found === undefined || found === '' ? undefined : found;\n };\n if (element.tag === 'title') return 'title';\n if (element.tag === 'meta') {\n const [name, property] = [said('name'), said('property')];\n if (name !== undefined) return `meta name ${name}`;\n return property === undefined ? undefined : `meta property ${property}`;\n }\n if (element.tag === 'link') return (said('rel') ?? '').split(/\\s+/).includes('canonical') ? 'link canonical' : undefined;\n return undefined;\n};\n","import { HEAD_LINK_NAME, HEAD_META_NAME, HEAD_NAME, HEAD_SCRIPT_NAME, HEAD_TITLE_NAME, headKeyOf } from '../layout/head';\nimport type { HeadElement } from '../layout/head';\nimport type { RenderNode } from '../layout';\nimport type { RenderApi } from './types';\nimport { ACTION_SLOT_NAME, CANVAS_SLOT_NAME } from './slot-names';\n\n// ═══════════════════════════════════════════════════════════\n// The head a screen has, read off its render tree.\n//\n// The frame is walked in the order it is drawn, into each canvas where its\n// slot stands and into each instance on it, and every `nova:head` it meets\n// gives its elements in turn. A screen can hold more than one head — the\n// shell's chrome says what holds on every screen, an action says its own, a\n// dialog opens over a page. An element that says the same thing as an earlier\n// one (the title, a <meta> of that name) takes its place; anything else stands\n// beside what came before.\n//\n// What a head may not hold is refused here, once, for every writer: the\n// element is left out and the reason is given. See ../layout/head.\n// ═══════════════════════════════════════════════════════════\n\nexport type ScreenHead = {\n // what the document's head is to hold, in the order the screen said it\n elements: HeadElement[];\n // the actions whose instances said any of it (none: only the shell's chrome did)\n actions: string[];\n // what a head held that it may not — left out, each with why\n refused: string[];\n};\n\ntype ComponentNode = Extract<RenderNode, { type: 'component' }>;\ntype Read = { element: HeadElement } | { refused: string } | undefined;\n\nconst ATTRIBUTE_NAME = /^[A-Za-z][A-Za-z0-9:._-]*$/;\n// a data block: a type no browser runs\nconst DATA_TYPE = /^application\\/([a-z0-9.-]+\\+)?json$/i;\n\n// A prop, as the attribute it is written as — or nothing, when it says nothing.\nconst written = (value: unknown): string | undefined => {\n if (typeof value === 'string') return value.trim() === '' ? undefined : value;\n if (typeof value === 'number') return String(value);\n return value === true ? '' : undefined;\n};\n\n// An element's attributes, from its props — or why it may not be written.\nconst attributesOf = (what: string, props: Record<string, unknown>, skip: readonly string[] = []): { attributes: Record<string, string> } | { refused: string } => {\n const attributes: Record<string, string> = {};\n for (const [name, value] of Object.entries(props)) {\n if (skip.includes(name)) continue;\n if (!ATTRIBUTE_NAME.test(name)) return { refused: `${what}: \"${name}\" is not an attribute’s name` };\n if (/^on/i.test(name)) return { refused: `${what}: \\`${name}\\` is a handler, and a layout does not run` };\n const text = written(value);\n if (text !== undefined) attributes[name] = text;\n }\n return { attributes };\n};\n\nconst has = (attributes: Record<string, string>, name: string): boolean => Object.keys(attributes).some((key) => key.toLowerCase() === name);\nconst valueOf = (attributes: Record<string, string>, name: string): string => Object.entries(attributes).find(([key]) => key.toLowerCase() === name)?.[1] ?? '';\n\nconst textOf = (nodes: readonly RenderNode[]): string =>\n nodes.map((node) => (node.type === 'text' ? node.value : node.type === 'fragment' ? textOf(node.children) : '')).join('');\n\nconst titleOf = (node: ComponentNode): Read => {\n const text = textOf(node.children).trim();\n return text === '' ? undefined : { element: { tag: 'title', attributes: {}, text } };\n};\n\nconst metaOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_META_NAME, node.props);\n if ('refused' in read) return read;\n if (has(read.attributes, 'http-equiv')) return { refused: `${HEAD_META_NAME}: \\`http-equiv\\` instructs the browser, and a layout does not` };\n // nothing to say yet: its value is not answered\n return has(read.attributes, 'content') ? { element: { tag: 'meta', attributes: read.attributes } } : undefined;\n};\n\nconst linkOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_LINK_NAME, node.props);\n if ('refused' in read) return read;\n if (valueOf(read.attributes, 'rel').toLowerCase().split(/\\s+/).includes('stylesheet')) return { refused: `${HEAD_LINK_NAME}: a stylesheet styles the page, and a layout does not` };\n return has(read.attributes, 'href') ? { element: { tag: 'link', attributes: read.attributes } } : undefined;\n};\n\nconst scriptOf = (node: ComponentNode): Read => {\n const read = attributesOf(HEAD_SCRIPT_NAME, node.props, ['data']);\n if ('refused' in read) return read;\n if (has(read.attributes, 'src')) return { refused: `${HEAD_SCRIPT_NAME}: a script with a \\`src\\` runs, and a layout does not` };\n const type = valueOf(read.attributes, 'type');\n if (!DATA_TYPE.test(type)) return { refused: `${HEAD_SCRIPT_NAME}: only a data block may be written (a JSON \\`type\\`), and \"${type}\" is not one` };\n const data = node.props['data'];\n if (data === undefined || data === null || data === '') return undefined;\n return { element: { tag: 'script', attributes: read.attributes, text: JSON.stringify(data) } };\n};\n\nconst READERS: Record<string, (node: ComponentNode) => Read> = {\n [HEAD_TITLE_NAME]: titleOf,\n [HEAD_META_NAME]: metaOf,\n [HEAD_LINK_NAME]: linkOf,\n [HEAD_SCRIPT_NAME]: scriptOf,\n};\n\nexport const isHeadNode = (node: RenderNode): boolean => node.type === 'component' && node.name === HEAD_NAME;\n\nexport const headOf = (api: Pick<RenderApi, 'frame' | 'canvasTree'>): ScreenHead | undefined => {\n let heads = 0;\n const said: { element: HeadElement; action: string | undefined }[] = [];\n const refused: string[] = [];\n // a canvas whose own tree names it again would never end\n const open = new Set<string>();\n\n const hold = (nodes: readonly RenderNode[], action: string | undefined): void => {\n for (const node of nodes) {\n if (node.type === 'fragment') {\n hold(node.children, action);\n continue;\n }\n if (node.type === 'error') {\n refused.push(`${HEAD_NAME}: ${node.message}`);\n continue;\n }\n // text between a head's elements is nothing\n if (node.type !== 'component') continue;\n const read = READERS[node.name];\n if (read === undefined) {\n refused.push(`${HEAD_NAME}: \"${node.name}\" is not something a head holds`);\n continue;\n }\n const found = read(node);\n if (found === undefined) continue;\n if ('refused' in found) {\n refused.push(found.refused);\n continue;\n }\n const key = headKeyOf(found.element);\n const earlier = key === undefined ? -1 : said.findIndex((other) => headKeyOf(other.element) === key);\n if (earlier >= 0) said.splice(earlier, 1);\n said.push({ element: found.element, action });\n }\n };\n\n const walk = (nodes: readonly RenderNode[], action: string | undefined): void => {\n for (const node of nodes) {\n if (node.type === 'fragment') {\n walk(node.children, action);\n continue;\n }\n if (node.type !== 'component') continue;\n if (node.name === HEAD_NAME) {\n heads += 1;\n hold(node.children, action);\n continue;\n }\n if (node.name === CANVAS_SLOT_NAME) {\n const canvasId = node.props['canvasId'];\n if (typeof canvasId !== 'string' || canvasId === '' || open.has(canvasId)) continue;\n open.add(canvasId);\n walk(api.canvasTree(canvasId), undefined);\n open.delete(canvasId);\n continue;\n }\n const definitionId = node.name === ACTION_SLOT_NAME ? node.props['definitionId'] : undefined;\n walk(node.children, typeof definitionId === 'string' ? definitionId : action);\n }\n };\n\n walk(api.frame(), undefined);\n if (heads === 0) return undefined;\n const actions = [...new Set(said.flatMap((one) => (one.action === undefined ? [] : [one.action])))];\n return { elements: said.map((one) => one.element), actions, refused };\n};\n","import type { ComponentRegistry, RenderNode } from '@layout/types';\nimport { isHeadNode } from '@shell';\nimport type { RenderApi } from '@shell';\n\n// ═══════════════════════════════════════════════════════════\n// @niscorp/nova/adapters/tty — a text adapter, the terminal sibling of\n// nova/dom. It turns a served RenderNode tree into lines of plain text plus a\n// numbered table of INTERACTIVES: every `ref`'d node prints with a `[n]`\n// marker and lands in the table, so a REPL host can map \"click 3\" / \"set 5 x\"\n// onto the same event vocabulary the DOM adapter wires by convention —\n// `ui:click` (payload = the node's `value` prop), `ui:model`, `ui:key`.\n// Origin is never stamped here — moss stamps the active instance server-side.\n//\n// No framework, no I/O, no node builtins: render() is a pure snapshot →\n// { text, interactives }. The host (moss's terminal/tty target) owns stdio,\n// prompts, and dispatch; this adapter only says what the screen IS and what\n// on it can be acted on. `CanvasSlot` is resolved here (the frame's markers →\n// per-canvas trees), the one piece of terminal structure the renderer owns.\n// See packages/nova/ADAPTER.md for the shared adapter contract.\n// ═══════════════════════════════════════════════════════════\n\n// A rendered block: lines of text, composed upward (a Stack stacks child\n// blocks, a Row joins single-line children inline, …).\nexport type TtyBlock = { lines: string[] };\n\n// What an interactive marker can be driven with — the REPL host maps these\n// to events: click/row → ui:click, model → ui:model (a typed value),\n// toggle → ui:model (a negated boolean).\nexport type TtyInteractiveKind = 'click' | 'row' | 'model' | 'toggle';\n\nexport type TtyInteractive = {\n // the printed `[n]` — 1-based, in registration order\n index: number;\n kind: TtyInteractiveKind;\n ref: string;\n // the canvas whose dispatch this belongs to; '' = frame chrome (dispatches\n // nothing, same as the DOM adapter's frame)\n canvas: string;\n // the action instance it sits in (the enclosing ActionSlot's instanceId) —\n // a list canvas renders several live instances at once, so the host stamps\n // this as the event's origin, exactly as the DOM adapter does. Absent\n // outside any instance.\n origin?: string;\n // what was printed — for the host's `refs` listing\n label: string;\n // click/row: the dispatch payload; model/toggle: the current value\n value?: unknown;\n // the model path, when model-bound — display only, the server owns meaning\n path?: string;\n};\n\nexport type TtyComponentContext = {\n props: Record<string, unknown>;\n // the node's children, already rendered — the component stacks or joins\n // them where it wants (leaves ignore them).\n children: TtyBlock[];\n // register an interactive and get its printed index — for data-driven\n // components with INTERNAL interactivity (a table's rows, a panel's ✕);\n // simple components let the renderer mark their `ref`/`model` by convention.\n register: (entry: { kind: TtyInteractiveKind; ref: string; label: string; value?: unknown; path?: string }) => number;\n};\n\n// A TTY component: props + rendered children in, one block of lines out.\nexport type TtyComponent = (ctx: TtyComponentContext) => TtyBlock;\n\n// What the terminal hands the view: core's `RenderApi` — the same single\n// definition the dom/react adapters and moss's terminal share.\nexport type TtyRenderApi = RenderApi;\n\n// One rendered frame: the full screen text and everything actionable on it.\nexport type TtyFrame = { text: string; interactives: TtyInteractive[] };\n\nexport type TtyView = {\n // render the current snapshot; call on every wire change\n render: () => TtyFrame;\n};\n\nconst CANVAS_SLOT = 'CanvasSlot';\nconst ACTION_SLOT = 'ActionSlot';\nconst RULE_WIDTH = 60;\n\n// The recursion context: the registry, the canvas in force (frame chrome is\n// ''; a CanvasSlot switches it), the interactive accumulator, the resolver.\ntype Ctx = {\n registry: ComponentRegistry<TtyComponent>;\n canvas: string;\n // the enclosing action instance, when inside one (an ActionSlot switches it)\n origin?: string;\n api: TtyRenderApi;\n out: TtyInteractive[];\n // used when a component name is unregistered — a permissive renderer (the\n // default kit) supplies one so unknown primitives render their children\n // instead of an error; strict consumers omit it.\n fallback?: TtyComponent;\n};\n\nconst errorBlock = (code: string, message: string): TtyBlock => ({ lines: [`!! ${code}: ${message}`] });\n\nconst labelOf = (block: TtyBlock, ref: string): string => {\n const first = block.lines[0]?.trim() ?? '';\n return first === '' ? ref : first.slice(0, 48);\n};\n\n// A canvas heading: `── main ─────…` — the one piece of chrome the renderer\n// prints itself, so a REPL reader can tell canvases apart.\nconst canvasRule = (id: string): string => {\n const head = `── ${id} `;\n return head + '─'.repeat(Math.max(0, RULE_WIDTH - head.length));\n};\n\nconst renderNode = (node: RenderNode, ctx: Ctx): TtyBlock => {\n if (node.type === 'text') return { lines: node.value.split('\\n') };\n if (node.type === 'fragment') return { lines: node.children.flatMap((child) => renderNode(child, ctx).lines) };\n if (node.type === 'error') return errorBlock(node.code, node.message);\n\n // component\n // a head is the document's, not the screen's: nothing is drawn for it or for what it holds\n if (isHeadNode(node)) return { lines: [] };\n if (node.name === CANVAS_SLOT) {\n const canvasId = typeof node.props['canvasId'] === 'string' ? (node.props['canvasId'] as string) : '';\n if (canvasId === '') return { lines: [] };\n const tree = ctx.api.canvasTree(canvasId);\n // an empty canvas collapses entirely — no heading for nothing\n if (tree.length === 0) return { lines: [] };\n // a canvas starts outside any instance, even one placed by an instance's layout\n const { origin: _outer, ...outside } = ctx;\n const canvasCtx: Ctx = { ...outside, canvas: canvasId };\n return { lines: [canvasRule(canvasId), ...tree.flatMap((child) => renderNode(child, canvasCtx).lines), ''] };\n }\n\n const entry = ctx.registry.get(node.name);\n const build = entry !== undefined ? entry.component : ctx.fallback;\n if (build === undefined) return errorBlock('COMPONENT_NOT_FOUND', node.name);\n\n // An ActionSlot is an instance boundary: what is inside it belongs to it.\n const instanceId = node.name === ACTION_SLOT ? node.props['instanceId'] : undefined;\n const inner: Ctx = typeof instanceId === 'string' && instanceId !== '' ? { ...ctx, origin: instanceId } : ctx;\n const children = node.children.filter((child) => !isHeadNode(child)).map((child) => renderNode(child, inner));\n const register: TtyComponentContext['register'] = (item) => {\n const interactive: TtyInteractive = { index: ctx.out.length + 1, canvas: ctx.canvas, ...(ctx.origin !== undefined ? { origin: ctx.origin } : {}), ...item };\n ctx.out.push(interactive);\n return interactive.index;\n };\n const block = build({ props: node.props, children, register });\n\n // Convention wiring, the TTY twin of the DOM adapter's listeners: a model'd\n // node is an input (`toggle` when its current value is a boolean), a bare\n // ref'd node is clickable (payload = its `value` prop). The marker lands on\n // the block's first line.\n if (node.model !== undefined) {\n const current = node.props['value'] ?? node.props['checked'];\n const kind: TtyInteractiveKind = typeof current === 'boolean' ? 'toggle' : 'model';\n const index = register({ kind, ref: node.model.ref, label: labelOf(block, node.model.ref), value: current, path: node.model.path });\n return { lines: [`[${index}] ${block.lines[0] ?? ''}`, ...block.lines.slice(1)] };\n }\n if (node.ref !== undefined) {\n const value = node.props['value'];\n const index = register({ kind: 'click', ref: node.ref, label: labelOf(block, node.ref), ...(value !== undefined ? { value } : {}) });\n return { lines: [`[${index}] ${block.lines[0] ?? ''}`, ...block.lines.slice(1)] };\n }\n return block;\n};\n\n// Collapse runs of blank lines so stacked empty canvases don't leave gaps.\nconst tidy = (lines: string[]): string[] => {\n const out: string[] = [];\n for (const line of lines) {\n if (line.trim() === '' && out[out.length - 1]?.trim() === '') continue;\n out.push(line);\n }\n while (out[0]?.trim() === '') out.shift();\n while (out[out.length - 1]?.trim() === '') out.pop();\n return out;\n};\n\nexport const createTtyView = (\n registry: ComponentRegistry<TtyComponent>,\n api: TtyRenderApi,\n options: { fallback?: TtyComponent } = {},\n): TtyView => {\n const render = (): TtyFrame => {\n const out: TtyInteractive[] = [];\n // The frame is chrome — its interactives belong to no canvas and the host\n // dispatches nothing for them, same as the DOM adapter's frame dispatch.\n const ctx: Ctx = { registry, canvas: '', api, out, ...(options.fallback !== undefined ? { fallback: options.fallback } : {}) };\n const lines = api.frame().flatMap((node) => renderNode(node, ctx).lines);\n return { text: tidy(lines).join('\\n'), interactives: out };\n };\n return { render };\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ComponentRegistry } from '../../types-
|
|
2
|
-
import { R as RenderApi } from '../../types-
|
|
1
|
+
import { C as ComponentRegistry } from '../../types-j290XhCn.cjs';
|
|
2
|
+
import { R as RenderApi } from '../../types-qkzTfSye.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../../schemas-DPdeFlCT.cjs';
|
|
5
5
|
import '../../index-caZoXSwr.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ComponentRegistry } from '../../types-
|
|
2
|
-
import { R as RenderApi } from '../../types-
|
|
1
|
+
import { C as ComponentRegistry } from '../../types-qnKMx0_V.js';
|
|
2
|
+
import { R as RenderApi } from '../../types-D23TRvqe.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../../schemas-DPdeFlCT.js';
|
|
5
5
|
import '../../index-CNfzSBe2.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import '../../chunk-
|
|
2
|
-
import { isHeadNode } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
1
|
+
import '../../chunk-RYIIIXDX.js';
|
|
2
|
+
import { isHeadNode } from '../../chunk-RFBIGRCI.js';
|
|
3
|
+
import '../../chunk-Y6XVPRYH.js';
|
|
4
4
|
import '../../chunk-OGD5CCMZ.js';
|
|
5
5
|
import '../../chunk-7TS3YVQR.js';
|
|
6
|
-
import '../../chunk-
|
|
6
|
+
import '../../chunk-OE4E6IBD.js';
|
|
7
7
|
import '../../chunk-DIFE573X.js';
|
|
8
8
|
import '../../chunk-JI7ZRESP.js';
|
|
9
9
|
import '../../chunk-RBU5PHN4.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/tty/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA6EA,IAAM,WAAA,GAAc,YAAA;AACpB,IAAM,WAAA,GAAc,YAAA;AACpB,IAAM,UAAA,GAAa,EAAA;AAiBnB,IAAM,UAAA,GAAa,CAAC,IAAA,EAAc,OAAA,MAA+B,EAAE,KAAA,EAAO,CAAC,CAAA,GAAA,EAAM,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE,CAAA,EAAE,CAAA;AAErG,IAAM,OAAA,GAAU,CAAC,KAAA,EAAiB,GAAA,KAAwB;AACxD,EAAA,MAAM,QAAQ,KAAA,CAAM,KAAA,CAAM,CAAC,CAAA,EAAG,MAAK,IAAK,EAAA;AACxC,EAAA,OAAO,UAAU,EAAA,GAAK,GAAA,GAAM,KAAA,CAAM,KAAA,CAAM,GAAG,EAAE,CAAA;AAC/C,CAAA;AAIA,IAAM,UAAA,GAAa,CAAC,EAAA,KAAuB;AACzC,EAAA,MAAM,IAAA,GAAO,gBAAM,EAAE,CAAA,CAAA,CAAA;AACrB,EAAA,OAAO,IAAA,GAAO,SAAI,MAAA,CAAO,IAAA,CAAK,IAAI,CAAA,EAAG,UAAA,GAAa,IAAA,CAAK,MAAM,CAAC,CAAA;AAChE,CAAA;AAEA,IAAM,UAAA,GAAa,CAAC,IAAA,EAAkB,GAAA,KAAuB;AAC3D,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,MAAA,EAAQ,OAAO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W,QAAQ,KAAA,EAAO;AACxB,IAAA,IAAI,IAAA,CAAK,IAAA,EAAK,KAAM,EAAA,IAAM,GAAA,CAAI,GAAA,CAAI,MAAA,GAAS,CAAC,CAAA,EAAG,IAAA,EAAK,KAAM,EAAA,EAAI;AAC9D,IAAA,GAAA,CAAI,KAAK,IAAI,CAAA;AAAA,EACf;AACA,EAAA,OAAO,IAAI,CAAC,CAAA,EAAG,MAAK,KAAM,EAAA,MAAQ,KAAA,EAAM;AACxC,EAAA,OAAO,GAAA,CAAI,IAAI,MAAA,GAAS,CAAC,GAAG,IAAA,EAAK,KAAM,EAAA,EAAI,GAAA,CAAI,GAAA,EAAI;AACnD,EAAA,OAAO,GAAA;AACT,CAAA;AAEO,IAAM,gBAAgB,CAC3B,QAAA,EACA,GAAA,EACA,OAAA,GAAuC,EAAC,KAC5B;AACZ,EAAA,MAAM,SAAS,MAAgB;AAC7B,IAAA,MAAM,MAAwB,EAAC;AAG/B,IAAA,MAAM,MAAW,EAAE,QAAA,EAAU,MAAA,EAAQ,EAAA,EAAI,KAAK,GAAA,EAAK,GAAI,OAAA,CAAQ,QAAA,KAAa,SAAY,EAAE,QAAA,EAAU,QAAQ,QAAA,EAAS,GAAI,EAAC,EAAG;AAC7H,IAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,KAAA,EAAM,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS,UAAA,CAAW,IAAA,EAAM,GAAG,CAAA,CAAE,KAAK,CAAA;AACvE,IAAA,OAAO,EAAE,MAAM,IAAA,CAAK,KAAK,EAAE,IAAA,CAAK,IAAI,CAAA,EAAG,YAAA,EAAc,GAAA,EAAI;AAAA,EAC3D,CAAA;AACA,EAAA,OAAO,EAAE,MAAA,EAAO;AAClB","file":"index.js","sourcesContent":["import type { ComponentRegistry, RenderNode } from '@layout/types';\nimport { isHeadNode } from '@shell';\nimport type { RenderApi } from '@shell';\n\n// ═══════════════════════════════════════════════════════════\n// @niscorp/nova/adapters/tty — a text adapter, the terminal sibling of\n// nova/dom. It turns a served RenderNode tree into lines of plain text plus a\n// numbered table of INTERACTIVES: every `ref`'d node prints with a `[n]`\n// marker and lands in the table, so a REPL host can map \"click 3\" / \"set 5 x\"\n// onto the same event vocabulary the DOM adapter wires by convention —\n// `ui:click` (payload = the node's `value` prop), `ui:model`, `ui:key`.\n// Origin is never stamped here — moss stamps the active instance server-side.\n//\n// No framework, no I/O, no node builtins: render() is a pure snapshot →\n// { text, interactives }. The host (moss's terminal/tty target) owns stdio,\n// prompts, and dispatch; this adapter only says what the screen IS and what\n// on it can be acted on. `CanvasSlot` is resolved here (the frame's markers →\n// per-canvas trees), the one piece of terminal structure the renderer owns.\n// See packages/nova/ADAPTER.md for the shared adapter contract.\n// ═══════════════════════════════════════════════════════════\n\n// A rendered block: lines of text, composed upward (a Stack stacks child\n// blocks, a Row joins single-line children inline, …).\nexport type TtyBlock = { lines: string[] };\n\n// What an interactive marker can be driven with — the REPL host maps these\n// to events: click/row → ui:click, model → ui:model (a typed value),\n// toggle → ui:model (a negated boolean).\nexport type TtyInteractiveKind = 'click' | 'row' | 'model' | 'toggle';\n\nexport type TtyInteractive = {\n // the printed `[n]` — 1-based, in registration order\n index: number;\n kind: TtyInteractiveKind;\n ref: string;\n // the canvas whose dispatch this belongs to; '' = frame chrome (dispatches\n // nothing, same as the DOM adapter's frame)\n canvas: string;\n // the action instance it sits in (the enclosing ActionSlot's instanceId) —\n // a list canvas renders several live instances at once, so the host stamps\n // this as the event's origin, exactly as the DOM adapter does. Absent\n // outside any instance.\n origin?: string;\n // what was printed — for the host's `refs` listing\n label: string;\n // click/row: the dispatch payload; model/toggle: the current value\n value?: unknown;\n // the model path, when model-bound — display only, the server owns meaning\n path?: string;\n};\n\nexport type TtyComponentContext = {\n props: Record<string, unknown>;\n // the node's children, already rendered — the component stacks or joins\n // them where it wants (leaves ignore them).\n children: TtyBlock[];\n // register an interactive and get its printed index — for data-driven\n // components with INTERNAL interactivity (a table's rows, a panel's ✕);\n // simple components let the renderer mark their `ref`/`model` by convention.\n register: (entry: { kind: TtyInteractiveKind; ref: string; label: string; value?: unknown; path?: string }) => number;\n};\n\n// A TTY component: props + rendered children in, one block of lines out.\nexport type TtyComponent = (ctx: TtyComponentContext) => TtyBlock;\n\n// What the terminal hands the view: core's `RenderApi` — the same single\n// definition the dom/react adapters and moss's terminal share.\nexport type TtyRenderApi = RenderApi;\n\n// One rendered frame: the full screen text and everything actionable on it.\nexport type TtyFrame = { text: string; interactives: TtyInteractive[] };\n\nexport type TtyView = {\n // render the current snapshot; call on every wire change\n render: () => TtyFrame;\n};\n\nconst CANVAS_SLOT = 'CanvasSlot';\nconst ACTION_SLOT = 'ActionSlot';\nconst RULE_WIDTH = 60;\n\n// The recursion context: the registry, the canvas in force (frame chrome is\n// ''; a CanvasSlot switches it), the interactive accumulator, the resolver.\ntype Ctx = {\n registry: ComponentRegistry<TtyComponent>;\n canvas: string;\n // the enclosing action instance, when inside one (an ActionSlot switches it)\n origin?: string;\n api: TtyRenderApi;\n out: TtyInteractive[];\n // used when a component name is unregistered — a permissive renderer (the\n // default kit) supplies one so unknown primitives render their children\n // instead of an error; strict consumers omit it.\n fallback?: TtyComponent;\n};\n\nconst errorBlock = (code: string, message: string): TtyBlock => ({ lines: [`!! ${code}: ${message}`] });\n\nconst labelOf = (block: TtyBlock, ref: string): string => {\n const first = block.lines[0]?.trim() ?? '';\n return first === '' ? ref : first.slice(0, 48);\n};\n\n// A canvas heading: `── main ─────…` — the one piece of chrome the renderer\n// prints itself, so a REPL reader can tell canvases apart.\nconst canvasRule = (id: string): string => {\n const head = `── ${id} `;\n return head + '─'.repeat(Math.max(0, RULE_WIDTH - head.length));\n};\n\nconst renderNode = (node: RenderNode, ctx: Ctx): TtyBlock => {\n if (node.type === 'text') return { lines: node.value.split('\\n') };\n if (node.type === 'fragment') return { lines: node.children.flatMap((child) => renderNode(child, ctx).lines) };\n if (node.type === 'error') return errorBlock(node.code, node.message);\n\n // component\n // a head is something the screen says, not something it shows\n if (isHeadNode(node)) return { lines: [] };\n if (node.name === CANVAS_SLOT) {\n const canvasId = typeof node.props['canvasId'] === 'string' ? (node.props['canvasId'] as string) : '';\n if (canvasId === '') return { lines: [] };\n const tree = ctx.api.canvasTree(canvasId);\n // an empty canvas collapses entirely — no heading for nothing\n if (tree.length === 0) return { lines: [] };\n // a canvas starts outside any instance, even one placed by an instance's layout\n const { origin: _outer, ...outside } = ctx;\n const canvasCtx: Ctx = { ...outside, canvas: canvasId };\n return { lines: [canvasRule(canvasId), ...tree.flatMap((child) => renderNode(child, canvasCtx).lines), ''] };\n }\n\n const entry = ctx.registry.get(node.name);\n const build = entry !== undefined ? entry.component : ctx.fallback;\n if (build === undefined) return errorBlock('COMPONENT_NOT_FOUND', node.name);\n\n // An ActionSlot is an instance boundary: what is inside it belongs to it.\n const instanceId = node.name === ACTION_SLOT ? node.props['instanceId'] : undefined;\n const inner: Ctx = typeof instanceId === 'string' && instanceId !== '' ? { ...ctx, origin: instanceId } : ctx;\n const children = node.children.filter((child) => !isHeadNode(child)).map((child) => renderNode(child, inner));\n const register: TtyComponentContext['register'] = (item) => {\n const interactive: TtyInteractive = { index: ctx.out.length + 1, canvas: ctx.canvas, ...(ctx.origin !== undefined ? { origin: ctx.origin } : {}), ...item };\n ctx.out.push(interactive);\n return interactive.index;\n };\n const block = build({ props: node.props, children, register });\n\n // Convention wiring, the TTY twin of the DOM adapter's listeners: a model'd\n // node is an input (`toggle` when its current value is a boolean), a bare\n // ref'd node is clickable (payload = its `value` prop). The marker lands on\n // the block's first line.\n if (node.model !== undefined) {\n const current = node.props['value'] ?? node.props['checked'];\n const kind: TtyInteractiveKind = typeof current === 'boolean' ? 'toggle' : 'model';\n const index = register({ kind, ref: node.model.ref, label: labelOf(block, node.model.ref), value: current, path: node.model.path });\n return { lines: [`[${index}] ${block.lines[0] ?? ''}`, ...block.lines.slice(1)] };\n }\n if (node.ref !== undefined) {\n const value = node.props['value'];\n const index = register({ kind: 'click', ref: node.ref, label: labelOf(block, node.ref), ...(value !== undefined ? { value } : {}) });\n return { lines: [`[${index}] ${block.lines[0] ?? ''}`, ...block.lines.slice(1)] };\n }\n return block;\n};\n\n// Collapse runs of blank lines so stacked empty canvases don't leave gaps.\nconst tidy = (lines: string[]): string[] => {\n const out: string[] = [];\n for (const line of lines) {\n if (line.trim() === '' && out[out.length - 1]?.trim() === '') continue;\n out.push(line);\n }\n while (out[0]?.trim() === '') out.shift();\n while (out[out.length - 1]?.trim() === '') out.pop();\n return out;\n};\n\nexport const createTtyView = (\n registry: ComponentRegistry<TtyComponent>,\n api: TtyRenderApi,\n options: { fallback?: TtyComponent } = {},\n): TtyView => {\n const render = (): TtyFrame => {\n const out: TtyInteractive[] = [];\n // The frame is chrome — its interactives belong to no canvas and the host\n // dispatches nothing for them, same as the DOM adapter's frame dispatch.\n const ctx: Ctx = { registry, canvas: '', api, out, ...(options.fallback !== undefined ? { fallback: options.fallback } : {}) };\n const lines = api.frame().flatMap((node) => renderNode(node, ctx).lines);\n return { text: tidy(lines).join('\\n'), interactives: out };\n };\n return { render };\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/tty/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA6EA,IAAM,WAAA,GAAc,YAAA;AACpB,IAAM,WAAA,GAAc,YAAA;AACpB,IAAM,UAAA,GAAa,EAAA;AAiBnB,IAAM,UAAA,GAAa,CAAC,IAAA,EAAc,OAAA,MAA+B,EAAE,KAAA,EAAO,CAAC,CAAA,GAAA,EAAM,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE,CAAA,EAAE,CAAA;AAErG,IAAM,OAAA,GAAU,CAAC,KAAA,EAAiB,GAAA,KAAwB;AACxD,EAAA,MAAM,QAAQ,KAAA,CAAM,KAAA,CAAM,CAAC,CAAA,EAAG,MAAK,IAAK,EAAA;AACxC,EAAA,OAAO,UAAU,EAAA,GAAK,GAAA,GAAM,KAAA,CAAM,KAAA,CAAM,GAAG,EAAE,CAA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AAA,CAAW,IAAA,EAAM,GAAG,CAAA,CAAE,KAAK,CAAA;AACvE,IAAA,OAAO,EAAE,MAAM,IAAA,CAAK,KAAK,EAAE,IAAA,CAAK,IAAI,CAAA,EAAG,YAAA,EAAc,GAAA,EAAI;AAAA,EAC3D,CAAA;AACA,EAAA,OAAO,EAAE,MAAA,EAAO;AAClB","file":"index.js","sourcesContent":["import type { ComponentRegistry, RenderNode } from '@layout/types';\nimport { isHeadNode } from '@shell';\nimport type { RenderApi } from '@shell';\n\n// ═══════════════════════════════════════════════════════════\n// @niscorp/nova/adapters/tty — a text adapter, the terminal sibling of\n// nova/dom. It turns a served RenderNode tree into lines of plain text plus a\n// numbered table of INTERACTIVES: every `ref`'d node prints with a `[n]`\n// marker and lands in the table, so a REPL host can map \"click 3\" / \"set 5 x\"\n// onto the same event vocabulary the DOM adapter wires by convention —\n// `ui:click` (payload = the node's `value` prop), `ui:model`, `ui:key`.\n// Origin is never stamped here — moss stamps the active instance server-side.\n//\n// No framework, no I/O, no node builtins: render() is a pure snapshot →\n// { text, interactives }. The host (moss's terminal/tty target) owns stdio,\n// prompts, and dispatch; this adapter only says what the screen IS and what\n// on it can be acted on. `CanvasSlot` is resolved here (the frame's markers →\n// per-canvas trees), the one piece of terminal structure the renderer owns.\n// See packages/nova/ADAPTER.md for the shared adapter contract.\n// ═══════════════════════════════════════════════════════════\n\n// A rendered block: lines of text, composed upward (a Stack stacks child\n// blocks, a Row joins single-line children inline, …).\nexport type TtyBlock = { lines: string[] };\n\n// What an interactive marker can be driven with — the REPL host maps these\n// to events: click/row → ui:click, model → ui:model (a typed value),\n// toggle → ui:model (a negated boolean).\nexport type TtyInteractiveKind = 'click' | 'row' | 'model' | 'toggle';\n\nexport type TtyInteractive = {\n // the printed `[n]` — 1-based, in registration order\n index: number;\n kind: TtyInteractiveKind;\n ref: string;\n // the canvas whose dispatch this belongs to; '' = frame chrome (dispatches\n // nothing, same as the DOM adapter's frame)\n canvas: string;\n // the action instance it sits in (the enclosing ActionSlot's instanceId) —\n // a list canvas renders several live instances at once, so the host stamps\n // this as the event's origin, exactly as the DOM adapter does. Absent\n // outside any instance.\n origin?: string;\n // what was printed — for the host's `refs` listing\n label: string;\n // click/row: the dispatch payload; model/toggle: the current value\n value?: unknown;\n // the model path, when model-bound — display only, the server owns meaning\n path?: string;\n};\n\nexport type TtyComponentContext = {\n props: Record<string, unknown>;\n // the node's children, already rendered — the component stacks or joins\n // them where it wants (leaves ignore them).\n children: TtyBlock[];\n // register an interactive and get its printed index — for data-driven\n // components with INTERNAL interactivity (a table's rows, a panel's ✕);\n // simple components let the renderer mark their `ref`/`model` by convention.\n register: (entry: { kind: TtyInteractiveKind; ref: string; label: string; value?: unknown; path?: string }) => number;\n};\n\n// A TTY component: props + rendered children in, one block of lines out.\nexport type TtyComponent = (ctx: TtyComponentContext) => TtyBlock;\n\n// What the terminal hands the view: core's `RenderApi` — the same single\n// definition the dom/react adapters and moss's terminal share.\nexport type TtyRenderApi = RenderApi;\n\n// One rendered frame: the full screen text and everything actionable on it.\nexport type TtyFrame = { text: string; interactives: TtyInteractive[] };\n\nexport type TtyView = {\n // render the current snapshot; call on every wire change\n render: () => TtyFrame;\n};\n\nconst CANVAS_SLOT = 'CanvasSlot';\nconst ACTION_SLOT = 'ActionSlot';\nconst RULE_WIDTH = 60;\n\n// The recursion context: the registry, the canvas in force (frame chrome is\n// ''; a CanvasSlot switches it), the interactive accumulator, the resolver.\ntype Ctx = {\n registry: ComponentRegistry<TtyComponent>;\n canvas: string;\n // the enclosing action instance, when inside one (an ActionSlot switches it)\n origin?: string;\n api: TtyRenderApi;\n out: TtyInteractive[];\n // used when a component name is unregistered — a permissive renderer (the\n // default kit) supplies one so unknown primitives render their children\n // instead of an error; strict consumers omit it.\n fallback?: TtyComponent;\n};\n\nconst errorBlock = (code: string, message: string): TtyBlock => ({ lines: [`!! ${code}: ${message}`] });\n\nconst labelOf = (block: TtyBlock, ref: string): string => {\n const first = block.lines[0]?.trim() ?? '';\n return first === '' ? ref : first.slice(0, 48);\n};\n\n// A canvas heading: `── main ─────…` — the one piece of chrome the renderer\n// prints itself, so a REPL reader can tell canvases apart.\nconst canvasRule = (id: string): string => {\n const head = `── ${id} `;\n return head + '─'.repeat(Math.max(0, RULE_WIDTH - head.length));\n};\n\nconst renderNode = (node: RenderNode, ctx: Ctx): TtyBlock => {\n if (node.type === 'text') return { lines: node.value.split('\\n') };\n if (node.type === 'fragment') return { lines: node.children.flatMap((child) => renderNode(child, ctx).lines) };\n if (node.type === 'error') return errorBlock(node.code, node.message);\n\n // component\n // a head is the document's, not the screen's: nothing is drawn for it or for what it holds\n if (isHeadNode(node)) return { lines: [] };\n if (node.name === CANVAS_SLOT) {\n const canvasId = typeof node.props['canvasId'] === 'string' ? (node.props['canvasId'] as string) : '';\n if (canvasId === '') return { lines: [] };\n const tree = ctx.api.canvasTree(canvasId);\n // an empty canvas collapses entirely — no heading for nothing\n if (tree.length === 0) return { lines: [] };\n // a canvas starts outside any instance, even one placed by an instance's layout\n const { origin: _outer, ...outside } = ctx;\n const canvasCtx: Ctx = { ...outside, canvas: canvasId };\n return { lines: [canvasRule(canvasId), ...tree.flatMap((child) => renderNode(child, canvasCtx).lines), ''] };\n }\n\n const entry = ctx.registry.get(node.name);\n const build = entry !== undefined ? entry.component : ctx.fallback;\n if (build === undefined) return errorBlock('COMPONENT_NOT_FOUND', node.name);\n\n // An ActionSlot is an instance boundary: what is inside it belongs to it.\n const instanceId = node.name === ACTION_SLOT ? node.props['instanceId'] : undefined;\n const inner: Ctx = typeof instanceId === 'string' && instanceId !== '' ? { ...ctx, origin: instanceId } : ctx;\n const children = node.children.filter((child) => !isHeadNode(child)).map((child) => renderNode(child, inner));\n const register: TtyComponentContext['register'] = (item) => {\n const interactive: TtyInteractive = { index: ctx.out.length + 1, canvas: ctx.canvas, ...(ctx.origin !== undefined ? { origin: ctx.origin } : {}), ...item };\n ctx.out.push(interactive);\n return interactive.index;\n };\n const block = build({ props: node.props, children, register });\n\n // Convention wiring, the TTY twin of the DOM adapter's listeners: a model'd\n // node is an input (`toggle` when its current value is a boolean), a bare\n // ref'd node is clickable (payload = its `value` prop). The marker lands on\n // the block's first line.\n if (node.model !== undefined) {\n const current = node.props['value'] ?? node.props['checked'];\n const kind: TtyInteractiveKind = typeof current === 'boolean' ? 'toggle' : 'model';\n const index = register({ kind, ref: node.model.ref, label: labelOf(block, node.model.ref), value: current, path: node.model.path });\n return { lines: [`[${index}] ${block.lines[0] ?? ''}`, ...block.lines.slice(1)] };\n }\n if (node.ref !== undefined) {\n const value = node.props['value'];\n const index = register({ kind: 'click', ref: node.ref, label: labelOf(block, node.ref), ...(value !== undefined ? { value } : {}) });\n return { lines: [`[${index}] ${block.lines[0] ?? ''}`, ...block.lines.slice(1)] };\n }\n return block;\n};\n\n// Collapse runs of blank lines so stacked empty canvases don't leave gaps.\nconst tidy = (lines: string[]): string[] => {\n const out: string[] = [];\n for (const line of lines) {\n if (line.trim() === '' && out[out.length - 1]?.trim() === '') continue;\n out.push(line);\n }\n while (out[0]?.trim() === '') out.shift();\n while (out[out.length - 1]?.trim() === '') out.pop();\n return out;\n};\n\nexport const createTtyView = (\n registry: ComponentRegistry<TtyComponent>,\n api: TtyRenderApi,\n options: { fallback?: TtyComponent } = {},\n): TtyView => {\n const render = (): TtyFrame => {\n const out: TtyInteractive[] = [];\n // The frame is chrome — its interactives belong to no canvas and the host\n // dispatches nothing for them, same as the DOM adapter's frame dispatch.\n const ctx: Ctx = { registry, canvas: '', api, out, ...(options.fallback !== undefined ? { fallback: options.fallback } : {}) };\n const lines = api.frame().flatMap((node) => renderNode(node, ctx).lines);\n return { text: tidy(lines).join('\\n'), interactives: out };\n };\n return { render };\n};\n"]}
|
|
@@ -472,21 +472,19 @@ var renderNodeKey = (node, index) => {
|
|
|
472
472
|
if (node.type === "fragment") return `f:${index}`;
|
|
473
473
|
return `e:${node.code}:${index}`;
|
|
474
474
|
};
|
|
475
|
-
|
|
476
|
-
// src/shell/head.ts
|
|
477
475
|
var isHeadNode = (node) => node.type === "component" && node.name === HEAD_NAME;
|
|
478
476
|
var ErrorMarker = vue.defineComponent(
|
|
479
477
|
(props) => () => vue.h("span", { "data-nova-error": props.code, role: "alert" }, `[${props.code}] ${props.message}`),
|
|
480
478
|
{ name: "NovaErrorMarker", props: ["code", "message"] }
|
|
481
479
|
);
|
|
482
|
-
var
|
|
480
|
+
var ShellHeadKey = /* @__PURE__ */ Symbol.for("@niscorp/nova/adapters/vue:head");
|
|
483
481
|
var HeadMark = vue.defineComponent(
|
|
484
482
|
() => {
|
|
485
|
-
const
|
|
483
|
+
const head = vue.inject(ShellHeadKey, void 0);
|
|
486
484
|
vue.onMounted(() => {
|
|
487
|
-
if (
|
|
485
|
+
if (head === void 0) return;
|
|
488
486
|
vue.watch(
|
|
489
|
-
|
|
487
|
+
head,
|
|
490
488
|
(current, _previous, onCleanup) => {
|
|
491
489
|
current.enter();
|
|
492
490
|
onCleanup(current.leave);
|