@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,75 @@
1
+ import { z } from 'zod';
2
+ import { NovaComponent } from '@niscorp/nova/adapters/react';
3
+ import * as react from 'react';
4
+ import react__default, { FC } from 'react';
5
+
6
+ type EventMeta = {
7
+ description?: string;
8
+ payloadType?: string;
9
+ };
10
+ type ComponentMeta = {
11
+ description?: string;
12
+ propsSchema?: z.ZodTypeAny;
13
+ events?: Record<string, EventMeta>;
14
+ };
15
+ type ComponentEntry<TComponent = unknown> = {
16
+ component: TComponent;
17
+ meta: ComponentMeta;
18
+ };
19
+ type RegistrationInput<TComponent = unknown> = TComponent | {
20
+ component: TComponent;
21
+ meta?: ComponentMeta;
22
+ };
23
+ interface ComponentRegistry<TComponent = unknown> {
24
+ register(name: string, component: TComponent, meta?: ComponentMeta): void;
25
+ registerAll(entries: Record<string, RegistrationInput<TComponent>>): void;
26
+ get(name: string): ComponentEntry<TComponent> | undefined;
27
+ list(): string[];
28
+ has(name: string): boolean;
29
+ }
30
+
31
+ declare const defaultRegistry: () => ComponentRegistry<NovaComponent>;
32
+
33
+ declare const useActionable: (novaRef: string | undefined, value: unknown) => {
34
+ marker: number | undefined;
35
+ isFocused: boolean;
36
+ };
37
+ declare const TextWrap: FC<{
38
+ children?: react__default.ReactNode;
39
+ }>;
40
+ declare const ErrorMarker: FC<{
41
+ code: string;
42
+ message: string;
43
+ }>;
44
+ declare const Box: NovaComponent;
45
+ declare const Stack: NovaComponent;
46
+ declare const Row: NovaComponent;
47
+ declare const Grid: NovaComponent;
48
+ declare const Text: NovaComponent;
49
+ declare const Badge: NovaComponent;
50
+ declare const Button: NovaComponent;
51
+ declare const Input: NovaComponent;
52
+ declare const Checkbox: NovaComponent;
53
+ declare const Table: NovaComponent;
54
+ declare const Panel: NovaComponent;
55
+ declare const JsonTree: NovaComponent;
56
+ declare const ActionSlot: NovaComponent;
57
+ declare const fallback: NovaComponent;
58
+
59
+ type MarkerIdentity = {
60
+ value?: unknown;
61
+ occurrence?: number;
62
+ };
63
+ type MarkerResolve = (ref: string, identity?: MarkerIdentity) => number | undefined;
64
+ declare const CanvasMarkersContext: react.Context<MarkerResolve | undefined>;
65
+ type InkFrameControls = {
66
+ setTyping: (typing: boolean) => void;
67
+ };
68
+ declare const FrameControlsContext: react.Context<InkFrameControls | undefined>;
69
+ declare const useMarker: (ref: string | undefined, identity?: MarkerIdentity) => number | undefined;
70
+ declare const markerFocusId: (index: number) => string;
71
+ declare const Mark: FC<{
72
+ index?: number;
73
+ }>;
74
+
75
+ export { ActionSlot, Badge, Box, Button, CanvasMarkersContext, Checkbox, ErrorMarker, FrameControlsContext, Grid, type InkFrameControls, Input, JsonTree, Mark, type MarkerResolve, Panel, Row, Stack, Table, Text, TextWrap, defaultRegistry, fallback, markerFocusId, useActionable, useMarker };
@@ -0,0 +1,472 @@
1
+ import { createContext, useContext, Children, useEffect, useState, useRef } from 'react';
2
+ import { Text as Text$1, useFocus, useInput, Box as Box$1, Transform } from 'ink';
3
+ import TextInput from 'ink-text-input';
4
+ import { useNovaDispatch } from '@niscorp/nova/adapters/react';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+
7
+ // src/layout/registry.ts
8
+ var hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
9
+ var isComponentMeta = (value) => {
10
+ if (typeof value !== "object" || value === null) return false;
11
+ return true;
12
+ };
13
+ var extractStaticMeta = (component) => {
14
+ if (typeof component !== "function" && (typeof component !== "object" || component === null)) {
15
+ return void 0;
16
+ }
17
+ const host = component;
18
+ if (!hasOwn(host, "meta")) return void 0;
19
+ const candidate = host.meta;
20
+ if (!isComponentMeta(candidate)) return void 0;
21
+ return candidate;
22
+ };
23
+ var isEntryShape = (value) => {
24
+ if (typeof value !== "object" || value === null) return false;
25
+ return hasOwn(value, "component");
26
+ };
27
+ var createComponentRegistry = () => {
28
+ const entries = /* @__PURE__ */ new Map();
29
+ const register = (name, component, meta) => {
30
+ const staticMeta = extractStaticMeta(component);
31
+ const merged = { ...staticMeta ?? {}, ...meta ?? {} };
32
+ entries.set(name, { component, meta: merged });
33
+ };
34
+ const registerAll = (batch) => {
35
+ for (const name of Object.keys(batch)) {
36
+ const input = batch[name];
37
+ if (input === void 0) continue;
38
+ if (isEntryShape(input)) {
39
+ register(name, input.component, input.meta);
40
+ } else {
41
+ register(name, input);
42
+ }
43
+ }
44
+ };
45
+ const get = (name) => entries.get(name);
46
+ const has = (name) => entries.has(name);
47
+ const list = () => Array.from(entries.keys());
48
+ return { register, registerAll, get, has, list };
49
+ };
50
+
51
+ // src/adapters/tty/components/props.ts
52
+ var num = (props, key) => {
53
+ const value = props[key];
54
+ return typeof value === "number" ? value : void 0;
55
+ };
56
+ var str = (props, key) => {
57
+ const value = props[key];
58
+ return typeof value === "string" ? value : void 0;
59
+ };
60
+ var bool = (props, key) => props[key] === true;
61
+ var ICON = {
62
+ plus: "+",
63
+ bell: "\u{1F514}",
64
+ sparkles: "\u2728",
65
+ more: "\u22EF",
66
+ search: "\u{1F50D}",
67
+ check: "\u2713",
68
+ close: "\u2715",
69
+ settings: "\u2699"
70
+ };
71
+ var iconGlyph = (name) => ICON[name] ?? name;
72
+ var truncate = (text, width) => text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}\u2026`;
73
+ var pad = (text, width) => truncate(text, width).padEnd(width);
74
+
75
+ // src/adapters/tty/components/components.ts
76
+ var at = (row, key) => {
77
+ let cursor = row;
78
+ for (const segment of key.split(".")) {
79
+ if (cursor === null || typeof cursor !== "object") return void 0;
80
+ cursor = Reflect.get(cursor, segment);
81
+ }
82
+ return cursor;
83
+ };
84
+ var cellText = (value) => value === null || value === void 0 ? "" : String(value);
85
+ var columnsOf = (props) => {
86
+ const value = props["columns"];
87
+ if (!Array.isArray(value)) return [];
88
+ const out = [];
89
+ for (const item of value) if (item !== null && typeof item === "object") out.push(item);
90
+ return out;
91
+ };
92
+ var cellKey = (column) => typeof column.cell?.key === "string" ? column.cell.key : "";
93
+ var DEPTH_CAP = 4;
94
+ var ENTRY_CAP = 20;
95
+ var jsonLines = (value, key, depth) => {
96
+ const pfx = " ".repeat(depth);
97
+ if (value !== null && typeof value === "object") {
98
+ const entries = Array.isArray(value) ? value.map((item, i) => [String(i), item]) : Object.entries(value);
99
+ const shape = Array.isArray(value) ? `[${entries.length}]` : `{${entries.length}}`;
100
+ const summary = key === void 0 ? shape : `${key} ${shape}`;
101
+ if (depth >= DEPTH_CAP) return [`${pfx}${summary} \u2026`];
102
+ const shown = entries.slice(0, ENTRY_CAP);
103
+ return [
104
+ `${pfx}${summary}`,
105
+ ...shown.flatMap(([childKey, childValue]) => jsonLines(childValue, childKey, depth + 1)),
106
+ ...entries.length > ENTRY_CAP ? [`${" ".repeat(depth + 1)}\u2026 +${entries.length - ENTRY_CAP} more`] : []
107
+ ];
108
+ }
109
+ return [`${pfx}${key === void 0 ? "" : `${key}: `}${JSON.stringify(value)}`];
110
+ };
111
+ var JsonTree = ({ props }) => ({ lines: jsonLines(props["value"], str(props, "label"), 0) });
112
+ var CanvasMarkersContext = createContext(void 0);
113
+ var FrameControlsContext = createContext(void 0);
114
+ var useMarker = (ref, identity) => {
115
+ const resolve = useContext(CanvasMarkersContext);
116
+ if (resolve === void 0 || ref === void 0) return void 0;
117
+ return resolve(ref, identity);
118
+ };
119
+ var markerFocusId = (index) => `marker:${index}`;
120
+ var Mark = ({ index }) => index === void 0 ? null : /* @__PURE__ */ jsxs(Text$1, { color: "cyan", children: [
121
+ "[",
122
+ index,
123
+ "] "
124
+ ] });
125
+ var focusOpts = (active, marker) => ({
126
+ isActive: active,
127
+ ...marker !== void 0 ? { id: markerFocusId(marker) } : {}
128
+ });
129
+ var useActionable = (novaRef, value) => {
130
+ const dispatch = useNovaDispatch();
131
+ const marker = useMarker(novaRef, value !== void 0 ? { value } : void 0);
132
+ const { isFocused } = useFocus(focusOpts(novaRef !== void 0, marker));
133
+ useInput(
134
+ (_input, key) => {
135
+ if (novaRef === void 0 || !key.return) return;
136
+ dispatch(value === void 0 ? { type: "ui:click", ref: novaRef } : { type: "ui:click", ref: novaRef, payload: value });
137
+ },
138
+ { isActive: isFocused && novaRef !== void 0 }
139
+ );
140
+ return { marker, isFocused };
141
+ };
142
+ var actionGutter = (marker, isFocused, body) => /* @__PURE__ */ jsxs(Box$1, { flexDirection: "row", gap: 1, children: [
143
+ /* @__PURE__ */ jsxs(Text$1, { color: "cyan", dimColor: !isFocused, children: [
144
+ marker !== void 0 ? `[${marker}]` : "",
145
+ isFocused ? "\u25B8" : ""
146
+ ] }),
147
+ body
148
+ ] });
149
+ var TextWrap = ({ children }) => /* @__PURE__ */ jsx(Text$1, { children });
150
+ var ErrorMarker = ({ code, message }) => /* @__PURE__ */ jsx(Text$1, { color: "red", children: `[${code}] ${message}` });
151
+ var heavy = (p) => {
152
+ const weight = p["weight"];
153
+ return typeof weight === "number" && weight >= 600 || weight === "semibold" || weight === "bold";
154
+ };
155
+ var mutedColor = (p) => ["mute", "muted", "dim", "secondary"].includes(str(p, "color") ?? "");
156
+ var gapRows = (p) => (num(p, "gap") ?? 0) >= 12 ? 1 : 0;
157
+ var CELL_PX = 8;
158
+ var toWidth = (value) => typeof value === "string" ? value : typeof value === "number" ? Math.max(2, Math.round(value / CELL_PX)) : void 0;
159
+ var JUSTIFY = {
160
+ start: "flex-start",
161
+ center: "center",
162
+ end: "flex-end",
163
+ between: "space-between",
164
+ around: "space-around"
165
+ };
166
+ var ALIGN = { start: "flex-start", center: "center", end: "flex-end", stretch: "stretch" };
167
+ var boxProps = (p) => {
168
+ const border = p["border"];
169
+ const width = toWidth(p["w"] ?? p["width"]);
170
+ const pad2 = num(p, "p") ?? num(p, "padding");
171
+ return {
172
+ ...border === true ? { borderStyle: "single", borderDimColor: true } : {},
173
+ ...typeof border === "string" ? {
174
+ borderStyle: "single",
175
+ borderDimColor: true,
176
+ borderTop: border === "t",
177
+ borderBottom: border === "b",
178
+ borderLeft: border === "l",
179
+ borderRight: border === "r"
180
+ } : {},
181
+ ...width !== void 0 ? { width } : {},
182
+ ...(pad2 ?? 0) > 0 || num(p, "px") !== void 0 ? { paddingX: 1 } : {},
183
+ ...bool(p, "grow") ? { flexGrow: 1 } : {}
184
+ };
185
+ };
186
+ var Box = ({ children, novaRef, ...rest }) => {
187
+ const { marker, isFocused } = useActionable(novaRef, rest["value"]);
188
+ const body = /* @__PURE__ */ jsx(Box$1, { flexDirection: "column", ...boxProps(rest), children });
189
+ return novaRef === void 0 ? body : actionGutter(marker, isFocused, body);
190
+ };
191
+ var Stack = ({ children, novaRef, ...rest }) => {
192
+ const { marker, isFocused } = useActionable(novaRef, rest["value"]);
193
+ const body = /* @__PURE__ */ jsx(Box$1, { flexDirection: "column", gap: gapRows(rest), ...boxProps(rest), children });
194
+ return novaRef === void 0 ? body : actionGutter(marker, isFocused, body);
195
+ };
196
+ var Row = ({ children, novaRef, ...rest }) => {
197
+ const { marker, isFocused } = useActionable(novaRef, rest["value"]);
198
+ const justify = JUSTIFY[str(rest, "justify") ?? ""];
199
+ const align = ALIGN[str(rest, "align") ?? ""];
200
+ const body = /* @__PURE__ */ jsx(
201
+ Box$1,
202
+ {
203
+ flexDirection: "row",
204
+ gap: 1,
205
+ ...justify !== void 0 ? { justifyContent: justify, width: "100%" } : {},
206
+ ...align !== void 0 ? { alignItems: align } : {},
207
+ ...boxProps(rest),
208
+ children
209
+ }
210
+ );
211
+ return novaRef === void 0 ? body : actionGutter(marker, isFocused, body);
212
+ };
213
+ var Grid = ({ children, novaRef, ...rest }) => {
214
+ const { marker, isFocused } = useActionable(novaRef, rest["value"]);
215
+ const rawWeights = rest["weights"];
216
+ const weights = Array.isArray(rawWeights) ? rawWeights.map((w) => typeof w === "number" ? w : 1) : void 0;
217
+ const columns = num(rest, "columns");
218
+ const items = Children.toArray(children);
219
+ const body = weights !== void 0 ? /* @__PURE__ */ jsx(Box$1, { flexDirection: "row", gap: 1, width: "100%", ...boxProps(rest), children: items.map((child, i) => /* @__PURE__ */ jsx(Box$1, { flexDirection: "column", flexBasis: 0, flexGrow: weights[i % weights.length] ?? 1, children: child }, i)) }) : columns !== void 0 && columns > 0 ? /* @__PURE__ */ jsx(Box$1, { flexDirection: "row", flexWrap: "wrap", width: "100%", ...boxProps(rest), children: items.map((child, i) => /* @__PURE__ */ jsx(Box$1, { flexDirection: "column", width: `${Math.floor(100 / columns)}%`, children: child }, i)) }) : /* @__PURE__ */ jsx(Box$1, { flexDirection: "row", gap: 2, ...boxProps(rest), children });
220
+ return novaRef === void 0 ? body : actionGutter(marker, isFocused, body);
221
+ };
222
+ var TEXT_COLOR = {
223
+ accent: "cyan",
224
+ success: "green",
225
+ positive: "green",
226
+ danger: "red",
227
+ error: "red",
228
+ warning: "yellow"
229
+ };
230
+ var Text = ({ children, ...rest }) => {
231
+ if (children === void 0 || children === null) return null;
232
+ const body = bool(rest, "upper") ? /* @__PURE__ */ jsx(Transform, { transform: (s) => s.toUpperCase(), children }) : children;
233
+ const tone = TEXT_COLOR[str(rest, "color") ?? ""];
234
+ return /* @__PURE__ */ jsx(Text$1, { bold: heavy(rest), dimColor: mutedColor(rest), ...tone !== void 0 ? { color: tone } : {}, children: body });
235
+ };
236
+ var Badge = ({ children }) => children === void 0 || children === null ? null : /* @__PURE__ */ jsxs(Text$1, { inverse: true, children: [
237
+ " ",
238
+ children,
239
+ " "
240
+ ] });
241
+ var Button = ({ children, novaRef, ...rest }) => {
242
+ const { marker, isFocused } = useActionable(novaRef, rest["value"]);
243
+ const icon = str(rest, "icon");
244
+ const label = Children.count(children) > 0 ? children : icon !== void 0 ? iconGlyph(icon) : "";
245
+ return /* @__PURE__ */ jsx(Box$1, { flexShrink: 0, children: /* @__PURE__ */ jsxs(Text$1, { children: [
246
+ /* @__PURE__ */ jsx(Mark, { index: marker }),
247
+ /* @__PURE__ */ jsxs(Text$1, { inverse: isFocused, children: [
248
+ "( ",
249
+ label,
250
+ " )"
251
+ ] })
252
+ ] }) });
253
+ };
254
+ var Input = ({ novaModel, ...rest }) => {
255
+ const dispatch = useNovaDispatch();
256
+ const marker = useMarker(novaModel?.ref);
257
+ const { isFocused } = useFocus(focusOpts(novaModel !== void 0, marker));
258
+ const controls = useContext(FrameControlsContext);
259
+ useEffect(() => {
260
+ controls?.setTyping(isFocused);
261
+ return () => {
262
+ if (isFocused) controls?.setTyping(false);
263
+ };
264
+ }, [isFocused]);
265
+ const raw = rest["value"];
266
+ const server = typeof raw === "string" || typeof raw === "number" ? String(raw) : "";
267
+ const [draft, setDraft] = useState(null);
268
+ const debounceMs = num(rest, "debounce") ?? 0;
269
+ const timer = useRef(void 0);
270
+ const fire = (next) => {
271
+ if (novaModel !== void 0) dispatch({ type: "ui:model", ref: novaModel.ref, payload: next });
272
+ };
273
+ const clearPending = () => {
274
+ if (timer.current !== void 0) {
275
+ clearTimeout(timer.current);
276
+ timer.current = void 0;
277
+ }
278
+ };
279
+ useEffect(() => clearPending, []);
280
+ useEffect(() => {
281
+ if (isFocused) setDraft((current) => current ?? server);
282
+ else
283
+ setDraft((current) => {
284
+ if (current !== null && timer.current !== void 0) {
285
+ clearPending();
286
+ fire(current);
287
+ }
288
+ return null;
289
+ });
290
+ }, [isFocused]);
291
+ useInput(
292
+ (_input, key) => {
293
+ if (novaModel === void 0) return;
294
+ if (key.downArrow) dispatch({ type: "ui:key", ref: novaModel.ref, key: "ArrowDown" });
295
+ else if (key.upArrow) dispatch({ type: "ui:key", ref: novaModel.ref, key: "ArrowUp" });
296
+ },
297
+ { isActive: isFocused && novaModel !== void 0 }
298
+ );
299
+ const onChange = (next) => {
300
+ setDraft(next);
301
+ if (debounceMs > 0) {
302
+ clearPending();
303
+ timer.current = setTimeout(() => {
304
+ timer.current = void 0;
305
+ fire(next);
306
+ }, debounceMs);
307
+ } else fire(next);
308
+ };
309
+ const onSubmit = (next) => {
310
+ if (timer.current !== void 0) {
311
+ clearPending();
312
+ fire(next);
313
+ }
314
+ if (novaModel !== void 0) dispatch({ type: "ui:key", ref: novaModel.ref, key: "Enter" });
315
+ };
316
+ return /* @__PURE__ */ jsxs(Box$1, { children: [
317
+ /* @__PURE__ */ jsx(Mark, { index: marker }),
318
+ /* @__PURE__ */ jsx(Text$1, { dimColor: true, children: "\u27E8" }),
319
+ /* @__PURE__ */ jsx(
320
+ TextInput,
321
+ {
322
+ value: draft ?? server,
323
+ onChange,
324
+ onSubmit,
325
+ placeholder: str(rest, "placeholder") ?? "",
326
+ focus: isFocused,
327
+ ...str(rest, "type") === "password" ? { mask: "\u2022" } : {}
328
+ }
329
+ ),
330
+ /* @__PURE__ */ jsx(Text$1, { dimColor: true, children: "\u27E9" })
331
+ ] });
332
+ };
333
+ var Checkbox = ({ novaModel, ...rest }) => {
334
+ const dispatch = useNovaDispatch();
335
+ const marker = useMarker(novaModel?.ref);
336
+ const { isFocused } = useFocus(focusOpts(novaModel !== void 0, marker));
337
+ const checked = bool(rest, "value") || bool(rest, "checked");
338
+ useInput(
339
+ (input, key) => {
340
+ if (novaModel === void 0 || !key.return && input !== " ") return;
341
+ dispatch({ type: "ui:model", ref: novaModel.ref, payload: !checked });
342
+ },
343
+ { isActive: isFocused && novaModel !== void 0 }
344
+ );
345
+ return /* @__PURE__ */ jsxs(Text$1, { children: [
346
+ /* @__PURE__ */ jsx(Mark, { index: marker }),
347
+ /* @__PURE__ */ jsx(Text$1, { inverse: isFocused, ...checked ? { color: "green" } : {}, children: checked ? "\u2611" : "\u2610" })
348
+ ] });
349
+ };
350
+ var CELL_CAP = 28;
351
+ var TableRow = ({ line, refId, payload, occurrence }) => {
352
+ const dispatch = useNovaDispatch();
353
+ const marker = useMarker(refId, { value: payload, occurrence });
354
+ const { isFocused } = useFocus(focusOpts(refId !== void 0, marker));
355
+ useInput(
356
+ (_input, key) => {
357
+ if (refId === void 0 || !key.return) return;
358
+ dispatch(payload === void 0 ? { type: "ui:click", ref: refId } : { type: "ui:click", ref: refId, payload });
359
+ },
360
+ { isActive: isFocused && refId !== void 0 }
361
+ );
362
+ return /* @__PURE__ */ jsxs(Text$1, { children: [
363
+ /* @__PURE__ */ jsx(Mark, { index: marker }),
364
+ /* @__PURE__ */ jsx(Text$1, { inverse: isFocused, children: line })
365
+ ] });
366
+ };
367
+ var Table = ({ ...rest }) => {
368
+ const columns = columnsOf(rest);
369
+ const rows = Array.isArray(rest["rows"]) ? rest["rows"] : [];
370
+ const rowKey = str(rest, "rowKey") ?? "id";
371
+ const clickKey = str(rest, "clickKey") ?? rowKey;
372
+ const rowRef = str(rest, "rowRef");
373
+ if (rows.length === 0) return /* @__PURE__ */ jsx(Text$1, { dimColor: true, children: str(rest, "empty") ?? "Nothing here." });
374
+ const header = columns.map((column) => typeof column.label === "string" ? column.label : "");
375
+ const body = rows.map((row) => columns.map((column) => truncate(cellText(at(row, cellKey(column))), CELL_CAP)));
376
+ const widths = header.map((label, i) => Math.max(truncate(label, CELL_CAP).length, ...body.map((cells) => cells[i]?.length ?? 0)));
377
+ const line = (cells) => cells.map((cell, i) => pad(cell, widths[i] ?? 0)).join(" ").trimEnd();
378
+ return /* @__PURE__ */ jsxs(Box$1, { flexDirection: "column", children: [
379
+ /* @__PURE__ */ jsx(Text$1, { dimColor: true, children: line(header) }),
380
+ /* @__PURE__ */ jsx(Text$1, { dimColor: true, children: line(widths.map((width) => "\u2500".repeat(width))) }),
381
+ rows.map((row, i) => /* @__PURE__ */ jsx(
382
+ TableRow,
383
+ {
384
+ line: line(body[i] ?? []),
385
+ occurrence: i,
386
+ ...rowRef !== void 0 ? { refId: rowRef, payload: at(row, clickKey) } : {}
387
+ },
388
+ String(at(row, rowKey) ?? i)
389
+ ))
390
+ ] });
391
+ };
392
+ var HeaderButton = ({ glyph, refId }) => {
393
+ const dispatch = useNovaDispatch();
394
+ const marker = useMarker(refId);
395
+ const { isFocused } = useFocus(focusOpts(true, marker));
396
+ useInput(
397
+ (input, key) => {
398
+ if (key.return || input === " ") dispatch({ type: "ui:click", ref: refId });
399
+ },
400
+ { isActive: isFocused }
401
+ );
402
+ return /* @__PURE__ */ jsxs(Text$1, { children: [
403
+ /* @__PURE__ */ jsx(Mark, { index: marker }),
404
+ /* @__PURE__ */ jsx(Text$1, { inverse: isFocused, children: glyph })
405
+ ] });
406
+ };
407
+ var Panel = ({ children, ...rest }) => {
408
+ const title = str(rest, "title");
409
+ const backRef = str(rest, "backRef");
410
+ const closeRef = str(rest, "closeRef");
411
+ return /* @__PURE__ */ jsxs(Box$1, { flexDirection: "column", borderStyle: "round", paddingX: 1, children: [
412
+ title !== void 0 && /* @__PURE__ */ jsxs(Box$1, { gap: 1, children: [
413
+ backRef !== void 0 && /* @__PURE__ */ jsx(HeaderButton, { glyph: "\u2190", refId: backRef }),
414
+ /* @__PURE__ */ jsx(Text$1, { bold: true, children: title }),
415
+ closeRef !== void 0 && /* @__PURE__ */ jsx(HeaderButton, { glyph: "\u2715", refId: closeRef })
416
+ ] }),
417
+ children
418
+ ] });
419
+ };
420
+ var JsonTree2 = ({ ...rest }) => {
421
+ const block = JsonTree({ props: rest});
422
+ return /* @__PURE__ */ jsx(Box$1, { flexDirection: "column", children: block.lines.map((textLine, i) => /* @__PURE__ */ jsx(Text$1, { children: textLine }, i)) });
423
+ };
424
+ var ActionSlot = ({ children }) => /* @__PURE__ */ jsx(Box$1, { flexDirection: "column", children });
425
+ var fallback = ({ children, novaRef, ...rest }) => {
426
+ const { marker, isFocused } = useActionable(novaRef, rest["value"]);
427
+ if (Children.count(children) > 0) {
428
+ if (novaRef === void 0) return /* @__PURE__ */ jsx(Box$1, { flexDirection: "column", children });
429
+ return actionGutter(marker, isFocused, /* @__PURE__ */ jsx(Box$1, { flexDirection: "column", children }));
430
+ }
431
+ const label = str(rest, "label") ?? str(rest, "title");
432
+ if (label === void 0) return null;
433
+ const count = rest["count"];
434
+ const suffix = typeof count === "number" || typeof count === "string" && count !== "" ? ` (${String(count)})` : "";
435
+ return /* @__PURE__ */ jsxs(Text$1, { children: [
436
+ /* @__PURE__ */ jsx(Mark, { index: marker }),
437
+ /* @__PURE__ */ jsxs(Text$1, { inverse: isFocused, children: [
438
+ label,
439
+ suffix
440
+ ] })
441
+ ] });
442
+ };
443
+
444
+ // src/adapters/ink/registry.ts
445
+ var defaultRegistry = () => {
446
+ const registry = createComponentRegistry();
447
+ registry.registerAll({
448
+ Box,
449
+ Row,
450
+ Stack,
451
+ Grid,
452
+ Text,
453
+ Button,
454
+ Input,
455
+ Select: Input,
456
+ Textarea: Input,
457
+ Checkbox,
458
+ Switch: Checkbox,
459
+ Table,
460
+ Badge,
461
+ // introspection primitives (used by nova/devtools; useful anywhere)
462
+ Panel,
463
+ JsonTree: JsonTree2,
464
+ // the per-instance boundary from a flattened shell tree — pass-through
465
+ ActionSlot
466
+ });
467
+ return registry;
468
+ };
469
+
470
+ export { ActionSlot, Badge, Box, Button, CanvasMarkersContext, Checkbox, ErrorMarker, FrameControlsContext, Grid, Input, JsonTree2 as JsonTree, Mark, Panel, Row, Stack, Table, Text, TextWrap, defaultRegistry, fallback, markerFocusId, useActionable, useMarker };
471
+ //# sourceMappingURL=index.js.map
472
+ //# sourceMappingURL=index.js.map