@niscorp/nova 0.1.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.
Files changed (170) hide show
  1. package/ACTION_DOCS.md +552 -0
  2. package/ADAPTER.md +170 -0
  3. package/DESIGN.md +719 -0
  4. package/I18N_DOCS.md +224 -0
  5. package/LAYOUT_DOCS.md +505 -0
  6. package/LICENSE +202 -0
  7. package/REACT_DOCS.md +562 -0
  8. package/README.md +379 -0
  9. package/SHELL_DOCS.md +615 -0
  10. package/TERMINAL_DOCS.md +124 -0
  11. package/dist/adapters/dom/components/index.cjs +473 -0
  12. package/dist/adapters/dom/components/index.cjs.map +1 -0
  13. package/dist/adapters/dom/components/index.d.cts +48 -0
  14. package/dist/adapters/dom/components/index.d.ts +48 -0
  15. package/dist/adapters/dom/components/index.js +420 -0
  16. package/dist/adapters/dom/components/index.js.map +1 -0
  17. package/dist/adapters/dom/index.cjs +171 -0
  18. package/dist/adapters/dom/index.cjs.map +1 -0
  19. package/dist/adapters/dom/index.d.cts +29 -0
  20. package/dist/adapters/dom/index.d.ts +29 -0
  21. package/dist/adapters/dom/index.js +15 -0
  22. package/dist/adapters/dom/index.js.map +1 -0
  23. package/dist/adapters/dom/server.cjs +129 -0
  24. package/dist/adapters/dom/server.cjs.map +1 -0
  25. package/dist/adapters/dom/server.d.cts +15 -0
  26. package/dist/adapters/dom/server.d.ts +15 -0
  27. package/dist/adapters/dom/server.js +37 -0
  28. package/dist/adapters/dom/server.js.map +1 -0
  29. package/dist/adapters/ink/index.d.ts +75 -0
  30. package/dist/adapters/ink/index.js +472 -0
  31. package/dist/adapters/ink/index.js.map +1 -0
  32. package/dist/adapters/react/components/index.cjs +552 -0
  33. package/dist/adapters/react/components/index.cjs.map +1 -0
  34. package/dist/adapters/react/components/index.d.cts +30 -0
  35. package/dist/adapters/react/components/index.d.ts +30 -0
  36. package/dist/adapters/react/components/index.js +12 -0
  37. package/dist/adapters/react/components/index.js.map +1 -0
  38. package/dist/adapters/react/index.cjs +1526 -0
  39. package/dist/adapters/react/index.cjs.map +1 -0
  40. package/dist/adapters/react/index.d.cts +149 -0
  41. package/dist/adapters/react/index.d.ts +149 -0
  42. package/dist/adapters/react/index.js +12 -0
  43. package/dist/adapters/react/index.js.map +1 -0
  44. package/dist/adapters/tty/components/index.cjs +255 -0
  45. package/dist/adapters/tty/components/index.cjs.map +1 -0
  46. package/dist/adapters/tty/components/index.d.cts +40 -0
  47. package/dist/adapters/tty/components/index.d.ts +40 -0
  48. package/dist/adapters/tty/components/index.js +187 -0
  49. package/dist/adapters/tty/components/index.js.map +1 -0
  50. package/dist/adapters/tty/index.cjs +76 -0
  51. package/dist/adapters/tty/index.cjs.map +1 -0
  52. package/dist/adapters/tty/index.d.cts +47 -0
  53. package/dist/adapters/tty/index.d.ts +47 -0
  54. package/dist/adapters/tty/index.js +76 -0
  55. package/dist/adapters/tty/index.js.map +1 -0
  56. package/dist/adapters/vue/components/index.cjs +619 -0
  57. package/dist/adapters/vue/components/index.cjs.map +1 -0
  58. package/dist/adapters/vue/components/index.d.cts +224 -0
  59. package/dist/adapters/vue/components/index.d.ts +224 -0
  60. package/dist/adapters/vue/components/index.js +12 -0
  61. package/dist/adapters/vue/components/index.js.map +1 -0
  62. package/dist/adapters/vue/index.cjs +747 -0
  63. package/dist/adapters/vue/index.cjs.map +1 -0
  64. package/dist/adapters/vue/index.d.cts +98 -0
  65. package/dist/adapters/vue/index.d.ts +98 -0
  66. package/dist/adapters/vue/index.js +127 -0
  67. package/dist/adapters/vue/index.js.map +1 -0
  68. package/dist/agent/index.cjs +178 -0
  69. package/dist/agent/index.cjs.map +1 -0
  70. package/dist/agent/index.d.cts +28 -0
  71. package/dist/agent/index.d.ts +28 -0
  72. package/dist/agent/index.js +30 -0
  73. package/dist/agent/index.js.map +1 -0
  74. package/dist/chunk-2MNLEL45.js +47 -0
  75. package/dist/chunk-2MNLEL45.js.map +1 -0
  76. package/dist/chunk-3HGE3VWK.js +753 -0
  77. package/dist/chunk-3HGE3VWK.js.map +1 -0
  78. package/dist/chunk-4ZID7UX5.js +549 -0
  79. package/dist/chunk-4ZID7UX5.js.map +1 -0
  80. package/dist/chunk-7B3RDENH.js +1982 -0
  81. package/dist/chunk-7B3RDENH.js.map +1 -0
  82. package/dist/chunk-7S5BNPUS.js +54 -0
  83. package/dist/chunk-7S5BNPUS.js.map +1 -0
  84. package/dist/chunk-7TS3YVQR.js +114 -0
  85. package/dist/chunk-7TS3YVQR.js.map +1 -0
  86. package/dist/chunk-EG2RUXJN.js +266 -0
  87. package/dist/chunk-EG2RUXJN.js.map +1 -0
  88. package/dist/chunk-GVBBL36G.js +429 -0
  89. package/dist/chunk-GVBBL36G.js.map +1 -0
  90. package/dist/chunk-I5D2R5UA.js +753 -0
  91. package/dist/chunk-I5D2R5UA.js.map +1 -0
  92. package/dist/chunk-IGLCWXQ3.js +304 -0
  93. package/dist/chunk-IGLCWXQ3.js.map +1 -0
  94. package/dist/chunk-JI7ZRESP.js +64 -0
  95. package/dist/chunk-JI7ZRESP.js.map +1 -0
  96. package/dist/chunk-L5223LLX.js +31 -0
  97. package/dist/chunk-L5223LLX.js.map +1 -0
  98. package/dist/chunk-LA3BSEMX.js +1905 -0
  99. package/dist/chunk-LA3BSEMX.js.map +1 -0
  100. package/dist/chunk-OAMC6R6E.js +121 -0
  101. package/dist/chunk-OAMC6R6E.js.map +1 -0
  102. package/dist/chunk-OGD5CCMZ.js +62 -0
  103. package/dist/chunk-OGD5CCMZ.js.map +1 -0
  104. package/dist/chunk-PF4OJTYU.js +199 -0
  105. package/dist/chunk-PF4OJTYU.js.map +1 -0
  106. package/dist/chunk-PZ5AY32C.js +9 -0
  107. package/dist/chunk-PZ5AY32C.js.map +1 -0
  108. package/dist/chunk-RBU5PHN4.js +8 -0
  109. package/dist/chunk-RBU5PHN4.js.map +1 -0
  110. package/dist/chunk-RQB4PRPV.js +285 -0
  111. package/dist/chunk-RQB4PRPV.js.map +1 -0
  112. package/dist/chunk-V32EVEVM.js +464 -0
  113. package/dist/chunk-V32EVEVM.js.map +1 -0
  114. package/dist/chunk-ZITHBBF3.js +85 -0
  115. package/dist/chunk-ZITHBBF3.js.map +1 -0
  116. package/dist/devtools/index.cjs +1088 -0
  117. package/dist/devtools/index.cjs.map +1 -0
  118. package/dist/devtools/index.d.cts +33 -0
  119. package/dist/devtools/index.d.ts +33 -0
  120. package/dist/devtools/index.js +399 -0
  121. package/dist/devtools/index.js.map +1 -0
  122. package/dist/effects-CndX9K7D.d.cts +123 -0
  123. package/dist/effects-CndX9K7D.d.ts +123 -0
  124. package/dist/endpoints-CD-6Jl-H.d.ts +36 -0
  125. package/dist/endpoints-Dem-EdRx.d.cts +36 -0
  126. package/dist/i18n/index.cjs +299 -0
  127. package/dist/i18n/index.cjs.map +1 -0
  128. package/dist/i18n/index.d.cts +28 -0
  129. package/dist/i18n/index.d.ts +28 -0
  130. package/dist/i18n/index.js +180 -0
  131. package/dist/i18n/index.js.map +1 -0
  132. package/dist/index-CNfzSBe2.d.ts +93 -0
  133. package/dist/index-caZoXSwr.d.cts +93 -0
  134. package/dist/index.cjs +3723 -0
  135. package/dist/index.cjs.map +1 -0
  136. package/dist/index.d.cts +144 -0
  137. package/dist/index.d.ts +144 -0
  138. package/dist/index.js +15 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/migrations/index.cjs +635 -0
  141. package/dist/migrations/index.cjs.map +1 -0
  142. package/dist/migrations/index.d.cts +97 -0
  143. package/dist/migrations/index.d.ts +97 -0
  144. package/dist/migrations/index.js +50 -0
  145. package/dist/migrations/index.js.map +1 -0
  146. package/dist/palette-CP0wd3bE.d.ts +15 -0
  147. package/dist/palette-lm0bU9i5.d.cts +15 -0
  148. package/dist/primitive-props-BH_EJWIe.d.cts +100 -0
  149. package/dist/primitive-props-BH_EJWIe.d.ts +100 -0
  150. package/dist/primitive-props-CGoJvmcH.d.cts +100 -0
  151. package/dist/primitive-props-CGoJvmcH.d.ts +100 -0
  152. package/dist/reflect/index.cjs +998 -0
  153. package/dist/reflect/index.cjs.map +1 -0
  154. package/dist/reflect/index.d.cts +125 -0
  155. package/dist/reflect/index.d.ts +125 -0
  156. package/dist/reflect/index.js +13 -0
  157. package/dist/reflect/index.js.map +1 -0
  158. package/dist/schemas-DPdeFlCT.d.cts +38 -0
  159. package/dist/schemas-DPdeFlCT.d.ts +38 -0
  160. package/dist/schemas-pMyyuXV7.d.cts +47 -0
  161. package/dist/schemas-pMyyuXV7.d.ts +47 -0
  162. package/dist/types-Boh9ckdG.d.ts +194 -0
  163. package/dist/types-Brc7v_pS.d.ts +198 -0
  164. package/dist/types-ByNSwtUV.d.cts +20 -0
  165. package/dist/types-DdltMfw7.d.ts +20 -0
  166. package/dist/types-De0KpxfI.d.cts +198 -0
  167. package/dist/types-DhHL0twe.d.ts +20 -0
  168. package/dist/types-Dv6JLmgo.d.cts +194 -0
  169. package/dist/types-Q80YtOQt.d.cts +20 -0
  170. package/package.json +237 -0
@@ -0,0 +1,40 @@
1
+ import { C as ComponentRegistry } from '../../../types-De0KpxfI.cjs';
2
+ import { TtyComponent, TtyBlock } from '../index.cjs';
3
+ import 'zod';
4
+ import '../../../schemas-DPdeFlCT.cjs';
5
+ import '../../../types-Dv6JLmgo.cjs';
6
+ import '../../../index-caZoXSwr.cjs';
7
+ import '../../../effects-CndX9K7D.cjs';
8
+ import '../../../schemas-pMyyuXV7.cjs';
9
+
10
+ declare const defaultRegistry: () => ComponentRegistry<TtyComponent>;
11
+
12
+ declare const Box: TtyComponent;
13
+ declare const Stack: TtyComponent;
14
+ declare const Row: TtyComponent;
15
+ declare const Grid: TtyComponent;
16
+ declare const Text: TtyComponent;
17
+ declare const Button: TtyComponent;
18
+ declare const Input: TtyComponent;
19
+ declare const Textarea: TtyComponent;
20
+ declare const Checkbox: TtyComponent;
21
+ declare const Badge: TtyComponent;
22
+ declare const Table: TtyComponent;
23
+ declare const Panel: TtyComponent;
24
+ declare const JsonTree: TtyComponent;
25
+ declare const ActionSlot: TtyComponent;
26
+ declare const fallback: TtyComponent;
27
+
28
+ type Props = Record<string, unknown>;
29
+ declare const num: (props: Props, key: string) => number | undefined;
30
+ declare const str: (props: Props, key: string) => string | undefined;
31
+ declare const bool: (props: Props, key: string) => boolean;
32
+ declare const iconGlyph: (name: string) => string;
33
+ declare const stack: (children: TtyBlock[]) => TtyBlock;
34
+ declare const inline: (children: TtyBlock[], separator?: string) => TtyBlock;
35
+ declare const inlineText: (children: TtyBlock[]) => string;
36
+ declare const truncate: (text: string, width: number) => string;
37
+ declare const pad: (text: string, width: number) => string;
38
+ declare const indent: (block: TtyBlock, prefix?: string) => TtyBlock;
39
+
40
+ export { ActionSlot, Badge, Box, Button, Checkbox, Grid, Input, JsonTree, Panel, type Props, Row, Stack, Table, Text, Textarea, bool, defaultRegistry, fallback, iconGlyph, indent, inline, inlineText, num, pad, stack, str, truncate };
@@ -0,0 +1,40 @@
1
+ import { C as ComponentRegistry } from '../../../types-Brc7v_pS.js';
2
+ import { TtyComponent, TtyBlock } from '../index.js';
3
+ import 'zod';
4
+ import '../../../schemas-DPdeFlCT.js';
5
+ import '../../../types-Boh9ckdG.js';
6
+ import '../../../index-CNfzSBe2.js';
7
+ import '../../../effects-CndX9K7D.js';
8
+ import '../../../schemas-pMyyuXV7.js';
9
+
10
+ declare const defaultRegistry: () => ComponentRegistry<TtyComponent>;
11
+
12
+ declare const Box: TtyComponent;
13
+ declare const Stack: TtyComponent;
14
+ declare const Row: TtyComponent;
15
+ declare const Grid: TtyComponent;
16
+ declare const Text: TtyComponent;
17
+ declare const Button: TtyComponent;
18
+ declare const Input: TtyComponent;
19
+ declare const Textarea: TtyComponent;
20
+ declare const Checkbox: TtyComponent;
21
+ declare const Badge: TtyComponent;
22
+ declare const Table: TtyComponent;
23
+ declare const Panel: TtyComponent;
24
+ declare const JsonTree: TtyComponent;
25
+ declare const ActionSlot: TtyComponent;
26
+ declare const fallback: TtyComponent;
27
+
28
+ type Props = Record<string, unknown>;
29
+ declare const num: (props: Props, key: string) => number | undefined;
30
+ declare const str: (props: Props, key: string) => string | undefined;
31
+ declare const bool: (props: Props, key: string) => boolean;
32
+ declare const iconGlyph: (name: string) => string;
33
+ declare const stack: (children: TtyBlock[]) => TtyBlock;
34
+ declare const inline: (children: TtyBlock[], separator?: string) => TtyBlock;
35
+ declare const inlineText: (children: TtyBlock[]) => string;
36
+ declare const truncate: (text: string, width: number) => string;
37
+ declare const pad: (text: string, width: number) => string;
38
+ declare const indent: (block: TtyBlock, prefix?: string) => TtyBlock;
39
+
40
+ export { ActionSlot, Badge, Box, Button, Checkbox, Grid, Input, JsonTree, Panel, type Props, Row, Stack, Table, Text, Textarea, bool, defaultRegistry, fallback, iconGlyph, indent, inline, inlineText, num, pad, stack, str, truncate };
@@ -0,0 +1,187 @@
1
+ import { createComponentRegistry } from '../../../chunk-2MNLEL45.js';
2
+ import '../../../chunk-PZ5AY32C.js';
3
+
4
+ // src/adapters/tty/components/props.ts
5
+ var num = (props, key) => {
6
+ const value = props[key];
7
+ return typeof value === "number" ? value : void 0;
8
+ };
9
+ var str = (props, key) => {
10
+ const value = props[key];
11
+ return typeof value === "string" ? value : void 0;
12
+ };
13
+ var bool = (props, key) => props[key] === true;
14
+ var ICON = {
15
+ plus: "+",
16
+ bell: "\u{1F514}",
17
+ sparkles: "\u2728",
18
+ more: "\u22EF",
19
+ search: "\u{1F50D}",
20
+ check: "\u2713",
21
+ close: "\u2715",
22
+ settings: "\u2699"
23
+ };
24
+ var iconGlyph = (name) => ICON[name] ?? name;
25
+ var stack = (children) => ({ lines: children.flatMap((child) => child.lines) });
26
+ var inline = (children, separator = " ") => {
27
+ const flat = children.filter((child) => child.lines.length > 0);
28
+ if (flat.every((child) => child.lines.length === 1)) {
29
+ const line = flat.map((child) => child.lines[0]).join(separator).trim();
30
+ return { lines: line === "" ? [] : [line] };
31
+ }
32
+ return stack(flat);
33
+ };
34
+ var inlineText = (children) => inline(children, " ").lines.join(" ").trim();
35
+ var truncate = (text, width) => text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}\u2026`;
36
+ var pad = (text, width) => truncate(text, width).padEnd(width);
37
+ var indent = (block, prefix = " ") => ({ lines: block.lines.map((line) => `${prefix}${line}`) });
38
+
39
+ // src/adapters/tty/components/components.ts
40
+ var Box = ({ children }) => stack(children);
41
+ var Stack = ({ children }) => stack(children);
42
+ var Row = ({ children }) => inline(children);
43
+ var Grid = ({ children }) => inline(children);
44
+ var Text = ({ props, children }) => {
45
+ const block = inline(children, " ");
46
+ return bool(props, "upper") ? { lines: block.lines.map((line) => line.toUpperCase()) } : block;
47
+ };
48
+ var Button = ({ props, children }) => {
49
+ const label = inlineText(children);
50
+ const icon = str(props, "icon");
51
+ const text = label !== "" ? label : icon !== void 0 ? icon : "";
52
+ return { lines: [`(${text})`] };
53
+ };
54
+ var Input = ({ props }) => {
55
+ const raw = props["value"];
56
+ const value = typeof raw === "string" || typeof raw === "number" ? String(raw) : "";
57
+ const shown = str(props, "type") === "password" ? "\u2022".repeat(value.length) : value;
58
+ const placeholder = str(props, "placeholder") ?? "";
59
+ return { lines: [`\u27E8${shown !== "" ? shown : placeholder}\u27E9`] };
60
+ };
61
+ var Textarea = ({ props }) => {
62
+ const raw = props["value"];
63
+ const value = typeof raw === "string" || typeof raw === "number" ? String(raw) : "";
64
+ if (value === "") return { lines: [`\u27E8${str(props, "placeholder") ?? ""}\u27E9`] };
65
+ return { lines: value.split("\n").map((line) => `\u27E8 ${line}`) };
66
+ };
67
+ var Checkbox = ({ props }) => ({
68
+ lines: [bool(props, "value") || bool(props, "checked") ? "\u2611" : "\u2610"]
69
+ });
70
+ var Badge = ({ children }) => {
71
+ const text = inlineText(children);
72
+ return { lines: text === "" ? [] : [`\u2039${text}\u203A`] };
73
+ };
74
+ var at = (row, key) => {
75
+ let cursor = row;
76
+ for (const segment of key.split(".")) {
77
+ if (cursor === null || typeof cursor !== "object") return void 0;
78
+ cursor = Reflect.get(cursor, segment);
79
+ }
80
+ return cursor;
81
+ };
82
+ var cellText = (value) => value === null || value === void 0 ? "" : String(value);
83
+ var columnsOf = (props) => {
84
+ const value = props["columns"];
85
+ if (!Array.isArray(value)) return [];
86
+ const out = [];
87
+ for (const item of value) if (item !== null && typeof item === "object") out.push(item);
88
+ return out;
89
+ };
90
+ var cellKey = (column) => typeof column.cell?.key === "string" ? column.cell.key : "";
91
+ var CELL_CAP = 28;
92
+ var Table = ({ props, register }) => {
93
+ const columns = columnsOf(props);
94
+ const rows = Array.isArray(props["rows"]) ? props["rows"] : [];
95
+ const rowKey = str(props, "rowKey") ?? "id";
96
+ const clickKey = str(props, "clickKey") ?? rowKey;
97
+ const rowRef = str(props, "rowRef");
98
+ if (rows.length === 0) return { lines: [str(props, "empty") ?? "Nothing here."] };
99
+ const header = columns.map((column) => typeof column.label === "string" ? column.label : "");
100
+ const body = rows.map((row) => columns.map((column) => truncate(cellText(at(row, cellKey(column))), CELL_CAP)));
101
+ const widths = header.map((label, i) => Math.max(truncate(label, CELL_CAP).length, ...body.map((cells) => cells[i]?.length ?? 0)));
102
+ const markers = rowRef === void 0 ? rows.map(() => "") : rows.map((row, i) => `[${register({ kind: "row", ref: rowRef, label: body[i]?.[0] ?? rowRef, value: at(row, clickKey) })}] `);
103
+ const markerWidth = Math.max(0, ...markers.map((marker) => marker.length));
104
+ const layout = (marker, cells) => (marker.padStart(markerWidth) + cells.map((cell, i) => pad(cell, widths[i] ?? 0)).join(" ")).trimEnd();
105
+ return {
106
+ lines: [
107
+ layout("".padStart(markerWidth), header.map((label, i) => pad(label, widths[i] ?? 0))),
108
+ layout("".padStart(markerWidth), widths.map((width) => "\u2500".repeat(width))),
109
+ ...body.map((cells, i) => layout(markers[i] ?? "", cells))
110
+ ]
111
+ };
112
+ };
113
+ var Panel = ({ props, children, register }) => {
114
+ const title = str(props, "title");
115
+ const lines = [];
116
+ if (title !== void 0) {
117
+ const parts = [];
118
+ const backRef = str(props, "backRef");
119
+ if (backRef !== void 0) parts.push(`[${register({ kind: "click", ref: backRef, label: "\u2190 back" })}] \u2190`);
120
+ parts.push(title);
121
+ const closeRef = str(props, "closeRef");
122
+ if (closeRef !== void 0) parts.push(`[${register({ kind: "click", ref: closeRef, label: "\u2715 close" })}] \u2715`);
123
+ const head = `\u250C\u2500 ${parts.join(" ")} `;
124
+ lines.push(head + "\u2500".repeat(Math.max(0, 48 - head.length)));
125
+ }
126
+ lines.push(...indent(stack(children), title === void 0 ? "" : "\u2502 ").lines);
127
+ return { lines };
128
+ };
129
+ var DEPTH_CAP = 4;
130
+ var ENTRY_CAP = 20;
131
+ var jsonLines = (value, key, depth) => {
132
+ const pfx = " ".repeat(depth);
133
+ if (value !== null && typeof value === "object") {
134
+ const entries = Array.isArray(value) ? value.map((item, i) => [String(i), item]) : Object.entries(value);
135
+ const shape = Array.isArray(value) ? `[${entries.length}]` : `{${entries.length}}`;
136
+ const summary = key === void 0 ? shape : `${key} ${shape}`;
137
+ if (depth >= DEPTH_CAP) return [`${pfx}${summary} \u2026`];
138
+ const shown = entries.slice(0, ENTRY_CAP);
139
+ return [
140
+ `${pfx}${summary}`,
141
+ ...shown.flatMap(([childKey, childValue]) => jsonLines(childValue, childKey, depth + 1)),
142
+ ...entries.length > ENTRY_CAP ? [`${" ".repeat(depth + 1)}\u2026 +${entries.length - ENTRY_CAP} more`] : []
143
+ ];
144
+ }
145
+ return [`${pfx}${key === void 0 ? "" : `${key}: `}${JSON.stringify(value)}`];
146
+ };
147
+ var JsonTree = ({ props }) => ({ lines: jsonLines(props["value"], str(props, "label"), 0) });
148
+ var ActionSlot = ({ children }) => stack(children);
149
+ var fallback = ({ props, children }) => {
150
+ const block = stack(children);
151
+ if (block.lines.length > 0) return block;
152
+ const label = str(props, "label") ?? str(props, "title");
153
+ if (label === void 0) return { lines: [] };
154
+ const count = props["count"];
155
+ const suffix = typeof count === "number" || typeof count === "string" && count !== "" ? ` (${String(count)})` : "";
156
+ return { lines: [`${label}${suffix}`] };
157
+ };
158
+
159
+ // src/adapters/tty/components/registry.ts
160
+ var defaultRegistry = () => {
161
+ const registry = createComponentRegistry();
162
+ registry.registerAll({
163
+ Box,
164
+ Row,
165
+ Stack,
166
+ Grid,
167
+ Text,
168
+ Button,
169
+ Input,
170
+ Select: Input,
171
+ Textarea,
172
+ Checkbox,
173
+ Switch: Checkbox,
174
+ Table,
175
+ Badge,
176
+ // introspection primitives (used by nova/devtools; useful anywhere)
177
+ Panel,
178
+ JsonTree,
179
+ // the per-instance boundary from a flattened shell tree — pass-through
180
+ ActionSlot
181
+ });
182
+ return registry;
183
+ };
184
+
185
+ export { ActionSlot, Badge, Box, Button, Checkbox, Grid, Input, JsonTree, Panel, Row, Stack, Table, Text, Textarea, bool, defaultRegistry, fallback, iconGlyph, indent, inline, inlineText, num, pad, stack, str, truncate };
186
+ //# sourceMappingURL=index.js.map
187
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/adapters/tty/components/props.ts","../../../../src/adapters/tty/components/components.ts","../../../../src/adapters/tty/components/registry.ts"],"names":[],"mappings":";;;;AAUO,IAAM,GAAA,GAAM,CAAC,KAAA,EAAc,GAAA,KAAoC;AACpE,EAAA,MAAM,KAAA,GAAQ,MAAM,GAAG,CAAA;AACvB,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,GAAW,KAAA,GAAQ,MAAA;AAC7C;AAEO,IAAM,GAAA,GAAM,CAAC,KAAA,EAAc,GAAA,KAAoC;AACpE,EAAA,MAAM,KAAA,GAAQ,MAAM,GAAG,CAAA;AACvB,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,GAAW,KAAA,GAAQ,MAAA;AAC7C;AAEO,IAAM,OAAO,CAAC,KAAA,EAAc,GAAA,KAAyB,KAAA,CAAM,GAAG,CAAA,KAAM;AAG3E,IAAM,IAAA,GAA+B;AAAA,EACnC,IAAA,EAAM,GAAA;AAAA,EAAK,IAAA,EAAM,WAAA;AAAA,EAAa,QAAA,EAAU,QAAA;AAAA,EAAK,IAAA,EAA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AC,EAAE;AAC5C,EAAA,MAAM,KAAA,GAAQ,MAAM,OAAO,CAAA;AAC3B,EAAA,MAAM,MAAA,GAAS,OAAO,KAAA,KAAU,QAAA,IAAa,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,EAAA,GAAM,CAAA,EAAA,EAAK,MAAA,CAAO,KAAK,CAAC,CAAA,CAAA,CAAA,GAAM,EAAA;AAClH,EAAA,OAAO,EAAE,OAAO,CAAC,CAAA,EAAG,KAAK,CAAA,EAAG,MAAM,EAAE,CAAA,EAAE;AACxC;;;ACxKO,IAAM,kBAAkB,MAAuC;AACpE,EAAA,MAAM,WAAW,uBAAA,EAAsC;AACvD,EAAA,QAAA,CAAS,WAAA,CAAY;AAAA,IACnB,GAAA;AAAA,IACA,GAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA,EAAQ,KAAA;AAAA,IACR,QAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA,EAAQ,QAAA;AAAA,IACR,KAAA;AAAA,IACA,KAAA;AAAA;AAAA,IAEA,KAAA;AAAA,IACA,QAAA;AAAA;AAAA,IAEA;AAAA,GACD,CAAA;AACD,EAAA,OAAO,QAAA;AACT","file":"index.js","sourcesContent":["// ═══════════════════════════════════════════════════════════\n// Prop readers + line arithmetic for the TTY kit. The readers mirror the DOM\n// kit's (narrow `unknown` with `typeof`, no casts); the line helpers are what\n// a terminal has instead of CSS — stack, inline-join, pad, truncate.\n// ═══════════════════════════════════════════════════════════\n\nimport type { TtyBlock } from '../index';\n\nexport type Props = Record<string, unknown>;\n\nexport const num = (props: Props, key: string): number | undefined => {\n const value = props[key];\n return typeof value === 'number' ? value : undefined;\n};\n\nexport const str = (props: Props, key: string): string | undefined => {\n const value = props[key];\n return typeof value === 'string' ? value : undefined;\n};\n\nexport const bool = (props: Props, key: string): boolean => props[key] === true;\n\n// A handful of icon names → a glyph, so icon-only buttons show something.\nconst ICON: Record<string, string> = {\n plus: '+', bell: '\\u{1F514}', sparkles: '✨', more: '⋯', search: '\\u{1F50D}', check: '✓', close: '✕', settings: '⚙',\n};\nexport const iconGlyph = (name: string): string => ICON[name] ?? name;\n\n// Stack child blocks vertically — the terminal's default flow.\nexport const stack = (children: TtyBlock[]): TtyBlock => ({ lines: children.flatMap((child) => child.lines) });\n\n// Join children on one line when every child IS one line ('a b c');\n// a multi-line child degrades the row to a stack — columns are not worth\n// faking with padding at this altitude.\nexport const inline = (children: TtyBlock[], separator = ' '): TtyBlock => {\n const flat = children.filter((child) => child.lines.length > 0);\n if (flat.every((child) => child.lines.length === 1)) {\n const line = flat.map((child) => child.lines[0]).join(separator).trim();\n return { lines: line === '' ? [] : [line] };\n }\n return stack(flat);\n};\n\n// The inline TEXT of children, for leaves that want a string (Button label).\nexport const inlineText = (children: TtyBlock[]): string => inline(children, ' ').lines.join(' ').trim();\n\nexport const truncate = (text: string, width: number): string =>\n text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}…`;\n\nexport const pad = (text: string, width: number): string => truncate(text, width).padEnd(width);\n\nexport const indent = (block: TtyBlock, prefix = ' '): TtyBlock => ({ lines: block.lines.map((line) => `${prefix}${line}`) });\n","import type { TtyBlock, TtyComponent } from '../index';\nimport { str, bool, stack, inline, inlineText, truncate, pad, indent } from './props';\n\n// ═══════════════════════════════════════════════════════════\n// The TTY reference kit — the same domain-blind vocabulary as the DOM kit\n// (same names, same props), interpreted for a line terminal. Interpretation\n// is the target's freedom: a Row joins single-line children inline, a Table\n// aligns padded columns, an Input prints `⟨value⟩`. What a terminal can't do\n// it doesn't fake — layout weights, colors, and drag are simply absent.\n// Unmapped names fall back to their children (fallback), so any app's tree\n// still renders its content.\n// ═══════════════════════════════════════════════════════════\n\n// ── containers: the terminal's only axis is vertical, so Box and Stack\n// stack; Row and Grid join inline while their children are single lines.\nexport const Box: TtyComponent = ({ children }) => stack(children);\nexport const Stack: TtyComponent = ({ children }) => stack(children);\nexport const Row: TtyComponent = ({ children }) => inline(children);\nexport const Grid: TtyComponent = ({ children }) => inline(children);\n\nexport const Text: TtyComponent = ({ props, children }) => {\n const block = inline(children, ' ');\n return bool(props, 'upper') ? { lines: block.lines.map((line) => line.toUpperCase()) } : block;\n};\n\n// A button is its label in parens — the renderer's `[n]` marker makes it\n// actionable; this just makes it legible.\nexport const Button: TtyComponent = ({ props, children }) => {\n const label = inlineText(children);\n const icon = str(props, 'icon');\n const text = label !== '' ? label : icon !== undefined ? icon : '';\n return { lines: [`(${text})`] };\n};\n\nexport const Input: TtyComponent = ({ props }) => {\n const raw = props['value'];\n const value = typeof raw === 'string' || typeof raw === 'number' ? String(raw) : '';\n const shown = str(props, 'type') === 'password' ? '•'.repeat(value.length) : value;\n const placeholder = str(props, 'placeholder') ?? '';\n return { lines: [`⟨${shown !== '' ? shown : placeholder}⟩`] };\n};\n\nexport const Textarea: TtyComponent = ({ props }) => {\n const raw = props['value'];\n const value = typeof raw === 'string' || typeof raw === 'number' ? String(raw) : '';\n if (value === '') return { lines: [`⟨${str(props, 'placeholder') ?? ''}⟩`] };\n return { lines: value.split('\\n').map((line) => `⟨ ${line}`) };\n};\n\nexport const Checkbox: TtyComponent = ({ props }) => ({\n lines: [bool(props, 'value') || bool(props, 'checked') ? '☑' : '☐'],\n});\n\nexport const Badge: TtyComponent = ({ children }) => {\n const text = inlineText(children);\n return { lines: text === '' ? [] : [`‹${text}›`] };\n};\n\n// ── the data-driven table: padded columns, a `[n]` marker per row when\n// `rowRef` is set (the marker column keeps the grid aligned).\n\n// Dotted-path field access, same as the DOM kit. Exported for the ink kit,\n// which shares the table's data contract but renders focusable rows.\nexport const at = (row: unknown, key: string): unknown => {\n let cursor: unknown = row;\n for (const segment of key.split('.')) {\n if (cursor === null || typeof cursor !== 'object') return undefined;\n cursor = Reflect.get(cursor, segment);\n }\n return cursor;\n};\nexport const cellText = (value: unknown): string => (value === null || value === undefined ? '' : String(value));\n\ntype Column = { label?: unknown; cell?: { key?: unknown } };\n\nexport const columnsOf = (props: Record<string, unknown>): Column[] => {\n const value = props['columns'];\n if (!Array.isArray(value)) return [];\n const out: Column[] = [];\n for (const item of value) if (item !== null && typeof item === 'object') out.push(item);\n return out;\n};\nexport const cellKey = (column: Column): string => (typeof column.cell?.key === 'string' ? column.cell.key : '');\n\nconst CELL_CAP = 28;\n\nexport const Table: TtyComponent = ({ props, register }) => {\n const columns = columnsOf(props);\n const rows = Array.isArray(props['rows']) ? props['rows'] : [];\n const rowKey = str(props, 'rowKey') ?? 'id';\n const clickKey = str(props, 'clickKey') ?? rowKey;\n const rowRef = str(props, 'rowRef');\n\n if (rows.length === 0) return { lines: [str(props, 'empty') ?? 'Nothing here.'] };\n\n const header = columns.map((column) => (typeof column.label === 'string' ? column.label : ''));\n const body = rows.map((row) => columns.map((column) => truncate(cellText(at(row, cellKey(column))), CELL_CAP)));\n const widths = header.map((label, i) => Math.max(truncate(label, CELL_CAP).length, ...body.map((cells) => cells[i]?.length ?? 0)));\n\n // Register every row first so the marker column width is known before any\n // line is laid out — markers pad to the widest ('[9] ' vs '[12] ').\n const markers = rowRef === undefined\n ? rows.map(() => '')\n : rows.map((row, i) => `[${register({ kind: 'row', ref: rowRef, label: body[i]?.[0] ?? rowRef, value: at(row, clickKey) })}] `);\n const markerWidth = Math.max(0, ...markers.map((marker) => marker.length));\n\n const layout = (marker: string, cells: string[]): string =>\n (marker.padStart(markerWidth) + cells.map((cell, i) => pad(cell, widths[i] ?? 0)).join(' ')).trimEnd();\n\n return {\n lines: [\n layout(''.padStart(markerWidth), header.map((label, i) => pad(label, widths[i] ?? 0))),\n layout(''.padStart(markerWidth), widths.map((width) => '─'.repeat(width))),\n ...body.map((cells, i) => layout(markers[i] ?? '', cells)),\n ],\n };\n};\n\n// Panel — a framed block with an optional title rule; `backRef`/`closeRef`\n// register as `←`/`✕` interactives in the header, same prop-ref convention\n// as Table's rowRef.\nexport const Panel: TtyComponent = ({ props, children, register }) => {\n const title = str(props, 'title');\n const lines: string[] = [];\n if (title !== undefined) {\n const parts: string[] = [];\n const backRef = str(props, 'backRef');\n if (backRef !== undefined) parts.push(`[${register({ kind: 'click', ref: backRef, label: '← back' })}] ←`);\n parts.push(title);\n const closeRef = str(props, 'closeRef');\n if (closeRef !== undefined) parts.push(`[${register({ kind: 'click', ref: closeRef, label: '✕ close' })}] ✕`);\n const head = `┌─ ${parts.join(' ')} `;\n lines.push(head + '─'.repeat(Math.max(0, 48 - head.length)));\n }\n lines.push(...indent(stack(children), title === undefined ? '' : '│ ').lines);\n return { lines };\n};\n\n// JsonTree — the value printed as an indented tree, depth- and width-capped\n// so a devtools state dump stays readable instead of scrolling forever.\nconst DEPTH_CAP = 4;\nconst ENTRY_CAP = 20;\n\nconst jsonLines = (value: unknown, key: string | undefined, depth: number): string[] => {\n const pfx = ' '.repeat(depth);\n if (value !== null && typeof value === 'object') {\n const entries = Array.isArray(value) ? value.map((item, i): [string, unknown] => [String(i), item] ) : Object.entries(value);\n const shape = Array.isArray(value) ? `[${entries.length}]` : `{${entries.length}}`;\n // container summary is `key {N}` — colon is for leaves, same as the DOM kit\n const summary = key === undefined ? shape : `${key} ${shape}`;\n if (depth >= DEPTH_CAP) return [`${pfx}${summary} …`];\n const shown = entries.slice(0, ENTRY_CAP);\n return [\n `${pfx}${summary}`,\n ...shown.flatMap(([childKey, childValue]) => jsonLines(childValue, childKey, depth + 1)),\n ...(entries.length > ENTRY_CAP ? [`${' '.repeat(depth + 1)}… +${entries.length - ENTRY_CAP} more`] : []),\n ];\n }\n return [`${pfx}${key === undefined ? '' : `${key}: `}${JSON.stringify(value)}`];\n};\n\nexport const JsonTree: TtyComponent = ({ props }) => ({ lines: jsonLines(props['value'], str(props, 'label'), 0) });\n\n// The per-instance boundary marker a flattened shell tree carries — the TTY\n// target has no wrapper concept, so it passes the content straight through.\nexport const ActionSlot: TtyComponent = ({ children }) => stack(children);\n\n// Unmapped primitives (an app's own NavItem, KanbanBoard, …) render their\n// children — content shows, and a `ref` still gets its marker from the\n// renderer. When a prop-driven component carries NO children, surface its\n// primary text prop (label / title) plus a `count` — a legible degrade, not\n// a full port; what the terminal can't do, it doesn't fake.\nexport const fallback: TtyComponent = ({ props, children }) => {\n const block = stack(children);\n if (block.lines.length > 0) return block;\n const label = str(props, 'label') ?? str(props, 'title');\n if (label === undefined) return { lines: [] };\n const count = props['count'];\n const suffix = typeof count === 'number' || (typeof count === 'string' && count !== '') ? ` (${String(count)})` : '';\n return { lines: [`${label}${suffix}`] };\n};\n\nexport type { TtyBlock };\n","import { createComponentRegistry } from '@layout/registry';\nimport type { ComponentRegistry } from '@layout/types';\nimport type { TtyComponent } from '../index';\nimport { ActionSlot, Badge, Box, Row, Stack, Grid, Text, Button, Input, Checkbox, Textarea, Table, Panel, JsonTree } from './components';\n\n// ═══════════════════════════════════════════════════════════\n// The default registry — the same domain-blind vocabulary as the DOM kit\n// (plus Badge, which the devtools dock leans on), registered for the line\n// terminal. An app's own component names fall back to their children (see\n// the renderer's `fallback`).\n// ═══════════════════════════════════════════════════════════\n\nexport const defaultRegistry = (): ComponentRegistry<TtyComponent> => {\n const registry = createComponentRegistry<TtyComponent>();\n registry.registerAll({\n Box,\n Row,\n Stack,\n Grid,\n Text,\n Button,\n Input,\n Select: Input,\n Textarea,\n Checkbox,\n Switch: Checkbox,\n Table,\n Badge,\n // introspection primitives (used by nova/devtools; useful anywhere)\n Panel,\n JsonTree,\n // the per-instance boundary from a flattened shell tree — pass-through\n ActionSlot,\n });\n return registry;\n};\n"]}
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ // src/adapters/tty/index.ts
4
+ var CANVAS_SLOT = "CanvasSlot";
5
+ var ACTION_SLOT = "ActionSlot";
6
+ var RULE_WIDTH = 60;
7
+ var errorBlock = (code, message) => ({ lines: [`!! ${code}: ${message}`] });
8
+ var labelOf = (block, ref) => {
9
+ const first = block.lines[0]?.trim() ?? "";
10
+ return first === "" ? ref : first.slice(0, 48);
11
+ };
12
+ var canvasRule = (id) => {
13
+ const head = `\u2500\u2500 ${id} `;
14
+ return head + "\u2500".repeat(Math.max(0, RULE_WIDTH - head.length));
15
+ };
16
+ var renderNode = (node, ctx) => {
17
+ if (node.type === "text") return { lines: node.value.split("\n") };
18
+ if (node.type === "fragment") return { lines: node.children.flatMap((child) => renderNode(child, ctx).lines) };
19
+ if (node.type === "error") return errorBlock(node.code, node.message);
20
+ if (node.name === CANVAS_SLOT) {
21
+ const canvasId = typeof node.props["canvasId"] === "string" ? node.props["canvasId"] : "";
22
+ if (canvasId === "") return { lines: [] };
23
+ const tree = ctx.api.canvasTree(canvasId);
24
+ if (tree.length === 0) return { lines: [] };
25
+ const { origin: _outer, ...outside } = ctx;
26
+ const canvasCtx = { ...outside, canvas: canvasId };
27
+ return { lines: [canvasRule(canvasId), ...tree.flatMap((child) => renderNode(child, canvasCtx).lines), ""] };
28
+ }
29
+ const entry = ctx.registry.get(node.name);
30
+ const build = entry !== void 0 ? entry.component : ctx.fallback;
31
+ if (build === void 0) return errorBlock("COMPONENT_NOT_FOUND", node.name);
32
+ const instanceId = node.name === ACTION_SLOT ? node.props["instanceId"] : void 0;
33
+ const inner = typeof instanceId === "string" && instanceId !== "" ? { ...ctx, origin: instanceId } : ctx;
34
+ const children = node.children.map((child) => renderNode(child, inner));
35
+ const register = (item) => {
36
+ const interactive = { index: ctx.out.length + 1, canvas: ctx.canvas, ...ctx.origin !== void 0 ? { origin: ctx.origin } : {}, ...item };
37
+ ctx.out.push(interactive);
38
+ return interactive.index;
39
+ };
40
+ const block = build({ props: node.props, children, register });
41
+ if (node.model !== void 0) {
42
+ const current = node.props["value"] ?? node.props["checked"];
43
+ const kind = typeof current === "boolean" ? "toggle" : "model";
44
+ const index = register({ kind, ref: node.model.ref, label: labelOf(block, node.model.ref), value: current, path: node.model.path });
45
+ return { lines: [`[${index}] ${block.lines[0] ?? ""}`, ...block.lines.slice(1)] };
46
+ }
47
+ if (node.ref !== void 0) {
48
+ const value = node.props["value"];
49
+ const index = register({ kind: "click", ref: node.ref, label: labelOf(block, node.ref), ...value !== void 0 ? { value } : {} });
50
+ return { lines: [`[${index}] ${block.lines[0] ?? ""}`, ...block.lines.slice(1)] };
51
+ }
52
+ return block;
53
+ };
54
+ var tidy = (lines) => {
55
+ const out = [];
56
+ for (const line of lines) {
57
+ if (line.trim() === "" && out[out.length - 1]?.trim() === "") continue;
58
+ out.push(line);
59
+ }
60
+ while (out[0]?.trim() === "") out.shift();
61
+ while (out[out.length - 1]?.trim() === "") out.pop();
62
+ return out;
63
+ };
64
+ var createTtyView = (registry, api, options = {}) => {
65
+ const render = () => {
66
+ const out = [];
67
+ const ctx = { registry, canvas: "", api, out, ...options.fallback !== void 0 ? { fallback: options.fallback } : {} };
68
+ const lines = api.frame().flatMap((node) => renderNode(node, ctx).lines);
69
+ return { text: tidy(lines).join("\n"), interactives: out };
70
+ };
71
+ return { render };
72
+ };
73
+
74
+ exports.createTtyView = createTtyView;
75
+ //# sourceMappingURL=index.cjs.map
76
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/adapters/tty/index.ts"],"names":[],"mappings":";;;AA4EA,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,UA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AI;AAAA,EAC3D,CAAA;AACA,EAAA,OAAO,EAAE,MAAA,EAAO;AAClB","file":"index.cjs","sourcesContent":["import type { ComponentRegistry, RenderNode } from '@layout/types';\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 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.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"]}
@@ -0,0 +1,47 @@
1
+ import { C as ComponentRegistry } from '../../types-De0KpxfI.cjs';
2
+ import { R as RenderApi } from '../../types-Dv6JLmgo.cjs';
3
+ import 'zod';
4
+ import '../../schemas-DPdeFlCT.cjs';
5
+ import '../../index-caZoXSwr.cjs';
6
+ import '../../effects-CndX9K7D.cjs';
7
+ import '../../schemas-pMyyuXV7.cjs';
8
+
9
+ type TtyBlock = {
10
+ lines: string[];
11
+ };
12
+ type TtyInteractiveKind = 'click' | 'row' | 'model' | 'toggle';
13
+ type TtyInteractive = {
14
+ index: number;
15
+ kind: TtyInteractiveKind;
16
+ ref: string;
17
+ canvas: string;
18
+ origin?: string;
19
+ label: string;
20
+ value?: unknown;
21
+ path?: string;
22
+ };
23
+ type TtyComponentContext = {
24
+ props: Record<string, unknown>;
25
+ children: TtyBlock[];
26
+ register: (entry: {
27
+ kind: TtyInteractiveKind;
28
+ ref: string;
29
+ label: string;
30
+ value?: unknown;
31
+ path?: string;
32
+ }) => number;
33
+ };
34
+ type TtyComponent = (ctx: TtyComponentContext) => TtyBlock;
35
+ type TtyRenderApi = RenderApi;
36
+ type TtyFrame = {
37
+ text: string;
38
+ interactives: TtyInteractive[];
39
+ };
40
+ type TtyView = {
41
+ render: () => TtyFrame;
42
+ };
43
+ declare const createTtyView: (registry: ComponentRegistry<TtyComponent>, api: TtyRenderApi, options?: {
44
+ fallback?: TtyComponent;
45
+ }) => TtyView;
46
+
47
+ export { type TtyBlock, type TtyComponent, type TtyComponentContext, type TtyFrame, type TtyInteractive, type TtyInteractiveKind, type TtyRenderApi, type TtyView, createTtyView };
@@ -0,0 +1,47 @@
1
+ import { C as ComponentRegistry } from '../../types-Brc7v_pS.js';
2
+ import { R as RenderApi } from '../../types-Boh9ckdG.js';
3
+ import 'zod';
4
+ import '../../schemas-DPdeFlCT.js';
5
+ import '../../index-CNfzSBe2.js';
6
+ import '../../effects-CndX9K7D.js';
7
+ import '../../schemas-pMyyuXV7.js';
8
+
9
+ type TtyBlock = {
10
+ lines: string[];
11
+ };
12
+ type TtyInteractiveKind = 'click' | 'row' | 'model' | 'toggle';
13
+ type TtyInteractive = {
14
+ index: number;
15
+ kind: TtyInteractiveKind;
16
+ ref: string;
17
+ canvas: string;
18
+ origin?: string;
19
+ label: string;
20
+ value?: unknown;
21
+ path?: string;
22
+ };
23
+ type TtyComponentContext = {
24
+ props: Record<string, unknown>;
25
+ children: TtyBlock[];
26
+ register: (entry: {
27
+ kind: TtyInteractiveKind;
28
+ ref: string;
29
+ label: string;
30
+ value?: unknown;
31
+ path?: string;
32
+ }) => number;
33
+ };
34
+ type TtyComponent = (ctx: TtyComponentContext) => TtyBlock;
35
+ type TtyRenderApi = RenderApi;
36
+ type TtyFrame = {
37
+ text: string;
38
+ interactives: TtyInteractive[];
39
+ };
40
+ type TtyView = {
41
+ render: () => TtyFrame;
42
+ };
43
+ declare const createTtyView: (registry: ComponentRegistry<TtyComponent>, api: TtyRenderApi, options?: {
44
+ fallback?: TtyComponent;
45
+ }) => TtyView;
46
+
47
+ export { type TtyBlock, type TtyComponent, type TtyComponentContext, type TtyFrame, type TtyInteractive, type TtyInteractiveKind, type TtyRenderApi, type TtyView, createTtyView };
@@ -0,0 +1,76 @@
1
+ import '../../chunk-PZ5AY32C.js';
2
+
3
+ // src/adapters/tty/index.ts
4
+ var CANVAS_SLOT = "CanvasSlot";
5
+ var ACTION_SLOT = "ActionSlot";
6
+ var RULE_WIDTH = 60;
7
+ var errorBlock = (code, message) => ({ lines: [`!! ${code}: ${message}`] });
8
+ var labelOf = (block, ref) => {
9
+ const first = block.lines[0]?.trim() ?? "";
10
+ return first === "" ? ref : first.slice(0, 48);
11
+ };
12
+ var canvasRule = (id) => {
13
+ const head = `\u2500\u2500 ${id} `;
14
+ return head + "\u2500".repeat(Math.max(0, RULE_WIDTH - head.length));
15
+ };
16
+ var renderNode = (node, ctx) => {
17
+ if (node.type === "text") return { lines: node.value.split("\n") };
18
+ if (node.type === "fragment") return { lines: node.children.flatMap((child) => renderNode(child, ctx).lines) };
19
+ if (node.type === "error") return errorBlock(node.code, node.message);
20
+ if (node.name === CANVAS_SLOT) {
21
+ const canvasId = typeof node.props["canvasId"] === "string" ? node.props["canvasId"] : "";
22
+ if (canvasId === "") return { lines: [] };
23
+ const tree = ctx.api.canvasTree(canvasId);
24
+ if (tree.length === 0) return { lines: [] };
25
+ const { origin: _outer, ...outside } = ctx;
26
+ const canvasCtx = { ...outside, canvas: canvasId };
27
+ return { lines: [canvasRule(canvasId), ...tree.flatMap((child) => renderNode(child, canvasCtx).lines), ""] };
28
+ }
29
+ const entry = ctx.registry.get(node.name);
30
+ const build = entry !== void 0 ? entry.component : ctx.fallback;
31
+ if (build === void 0) return errorBlock("COMPONENT_NOT_FOUND", node.name);
32
+ const instanceId = node.name === ACTION_SLOT ? node.props["instanceId"] : void 0;
33
+ const inner = typeof instanceId === "string" && instanceId !== "" ? { ...ctx, origin: instanceId } : ctx;
34
+ const children = node.children.map((child) => renderNode(child, inner));
35
+ const register = (item) => {
36
+ const interactive = { index: ctx.out.length + 1, canvas: ctx.canvas, ...ctx.origin !== void 0 ? { origin: ctx.origin } : {}, ...item };
37
+ ctx.out.push(interactive);
38
+ return interactive.index;
39
+ };
40
+ const block = build({ props: node.props, children, register });
41
+ if (node.model !== void 0) {
42
+ const current = node.props["value"] ?? node.props["checked"];
43
+ const kind = typeof current === "boolean" ? "toggle" : "model";
44
+ const index = register({ kind, ref: node.model.ref, label: labelOf(block, node.model.ref), value: current, path: node.model.path });
45
+ return { lines: [`[${index}] ${block.lines[0] ?? ""}`, ...block.lines.slice(1)] };
46
+ }
47
+ if (node.ref !== void 0) {
48
+ const value = node.props["value"];
49
+ const index = register({ kind: "click", ref: node.ref, label: labelOf(block, node.ref), ...value !== void 0 ? { value } : {} });
50
+ return { lines: [`[${index}] ${block.lines[0] ?? ""}`, ...block.lines.slice(1)] };
51
+ }
52
+ return block;
53
+ };
54
+ var tidy = (lines) => {
55
+ const out = [];
56
+ for (const line of lines) {
57
+ if (line.trim() === "" && out[out.length - 1]?.trim() === "") continue;
58
+ out.push(line);
59
+ }
60
+ while (out[0]?.trim() === "") out.shift();
61
+ while (out[out.length - 1]?.trim() === "") out.pop();
62
+ return out;
63
+ };
64
+ var createTtyView = (registry, api, options = {}) => {
65
+ const render = () => {
66
+ const out = [];
67
+ const ctx = { registry, canvas: "", api, out, ...options.fallback !== void 0 ? { fallback: options.fallback } : {} };
68
+ const lines = api.frame().flatMap((node) => renderNode(node, ctx).lines);
69
+ return { text: tidy(lines).join("\n"), interactives: out };
70
+ };
71
+ return { render };
72
+ };
73
+
74
+ export { createTtyView };
75
+ //# sourceMappingURL=index.js.map
76
+ //# sourceMapping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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 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 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.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"]}