@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,552 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var react = require('react');
6
+
7
+ // src/adapters/primitive-props.ts
8
+ var StackPropsSchema = zod.z.object({
9
+ direction: zod.z.enum(["row", "column"]).optional().describe("Flex direction. Default: column."),
10
+ gap: zod.z.number().int().min(0).optional().describe("Gap between children in pixels. Default: 0."),
11
+ align: zod.z.enum(["start", "center", "end", "stretch"]).optional().describe("Cross-axis alignment. Default: stretch."),
12
+ justify: zod.z.enum(["start", "center", "end", "between", "around"]).optional().describe("Main-axis justification. Default: start."),
13
+ padding: zod.z.number().int().min(0).optional().describe("Inner padding in pixels. Default: 0."),
14
+ wrap: zod.z.boolean().optional().describe("Whether children wrap to a new line. Default: false.")
15
+ }).strict().describe("Flex container that arranges children in a row or column.");
16
+ var TextPropsSchema = zod.z.object({
17
+ as: zod.z.enum(["span", "p", "h1", "h2", "h3", "h4"]).optional().describe("HTML element to render. Default: span."),
18
+ size: zod.z.enum(["sm", "md", "lg", "xl", "2xl"]).optional().describe("Font size token. Default: md."),
19
+ weight: zod.z.enum(["normal", "medium", "bold"]).optional().describe("Font weight token. Default: normal."),
20
+ color: zod.z.string().optional().describe("CSS color string (open set). Default: inherit.")
21
+ }).strict().describe("Text element with semantic typography props.");
22
+ var InputPropsSchema = zod.z.object({
23
+ type: zod.z.enum(["text", "number", "email", "password"]).optional().describe("Input type. Default: text."),
24
+ placeholder: zod.z.string().optional().describe("Placeholder text shown when empty."),
25
+ disabled: zod.z.boolean().optional().describe("Whether the input is disabled. Default: false."),
26
+ value: zod.z.string().optional().describe("Current value. Typically supplied via model binding."),
27
+ debounce: zod.z.number().optional().describe("Milliseconds to coalesce keystrokes before dispatching ui:model. Default: 0 (every keystroke). Set it when the shell is remote to cut round-trips.")
28
+ }).strict().describe("Text input bound to data via the `model` field on the layout node.");
29
+ var ButtonPropsSchema = zod.z.object({
30
+ label: zod.z.string().optional().describe("Button label. If absent, children are used."),
31
+ variant: zod.z.enum(["primary", "secondary", "ghost"]).optional().describe("Visual variant. Default: primary."),
32
+ disabled: zod.z.boolean().optional().describe("Whether the button is disabled. Default: false.")
33
+ }).strict().describe("Clickable button. Click events fire as `ui:click` with the layout node's ref.");
34
+ var BoxPropsSchema = zod.z.object({
35
+ padding: zod.z.number().int().min(0).optional().describe("Inner padding in pixels. Default: 0."),
36
+ background: zod.z.string().optional().describe("CSS background color or value."),
37
+ border: zod.z.boolean().optional().describe("Whether to show a 1px border. Default: false."),
38
+ radius: zod.z.number().int().min(0).optional().describe("Border radius in pixels. Default: 0.")
39
+ }).strict().describe("Generic container with basic styling props. Use Stack for layout, Box for visual wrapping.");
40
+ var PanelPropsSchema = zod.z.object({
41
+ title: zod.z.string().optional().describe("Optional header title."),
42
+ backRef: zod.z.string().optional().describe("When set, the header grows a \u2190 (before the title) that fires ui:click with this ref."),
43
+ closeRef: zod.z.string().optional().describe("When set, the header grows a \u2715 that fires ui:click with this ref.")
44
+ }).strict().describe("A framed, elevated surface with an optional title.");
45
+ var JsonTreePropsSchema = zod.z.object({
46
+ value: zod.z.unknown().optional().describe("The value to render."),
47
+ label: zod.z.string().optional().describe("A name for the root node.")
48
+ }).strict().describe("A collapsible view of any JSON value.");
49
+ var CanvasSlotPropsSchema = zod.z.object({
50
+ canvasId: zod.z.string().optional().describe('Id of the canvas to render. Usually bound from a loop, e.g. "$.c.id".')
51
+ }).strict().describe("Renders a canvas by id, recursing into its actionLayout. Resolves to nothing when canvasId is missing.");
52
+ var ActionSlotPropsSchema = zod.z.object({
53
+ instanceId: zod.z.string().optional().describe('Id of the action instance to render. Usually bound from canvas scope, e.g. "$.active.id" or "$.i.id".')
54
+ }).strict().describe("Renders an action instance by id. Resolves to nothing when instanceId is missing.");
55
+ var ALIGN_MAP = {
56
+ start: "flex-start",
57
+ center: "center",
58
+ end: "flex-end",
59
+ stretch: "stretch"
60
+ };
61
+ var JUSTIFY_MAP = {
62
+ start: "flex-start",
63
+ center: "center",
64
+ end: "flex-end",
65
+ between: "space-between",
66
+ around: "space-around"
67
+ };
68
+ var Stack = ({
69
+ direction,
70
+ gap,
71
+ align,
72
+ justify,
73
+ padding,
74
+ wrap,
75
+ children
76
+ }) => {
77
+ const style = {
78
+ display: "flex",
79
+ flexDirection: direction ?? "column",
80
+ gap: gap ?? 0,
81
+ alignItems: ALIGN_MAP[align ?? "stretch"],
82
+ justifyContent: JUSTIFY_MAP[justify ?? "start"],
83
+ padding: padding ?? 0,
84
+ flexWrap: wrap === true ? "wrap" : "nowrap"
85
+ };
86
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style, children });
87
+ };
88
+ Stack.meta = {
89
+ description: "Flex container that arranges children in a row or column.",
90
+ propsSchema: StackPropsSchema
91
+ };
92
+ var SIZE_MAP = {
93
+ sm: "12px",
94
+ md: "14px",
95
+ lg: "16px",
96
+ xl: "20px",
97
+ "2xl": "24px"
98
+ };
99
+ var WEIGHT_MAP = {
100
+ normal: 400,
101
+ medium: 500,
102
+ bold: 700
103
+ };
104
+ var Text = ({
105
+ as,
106
+ size,
107
+ weight,
108
+ color,
109
+ children
110
+ }) => {
111
+ const tag = as ?? "span";
112
+ const style = {
113
+ fontSize: SIZE_MAP[size ?? "md"],
114
+ fontWeight: WEIGHT_MAP[weight ?? "normal"],
115
+ color: color ?? "inherit"
116
+ };
117
+ return react.createElement(tag, { style }, children);
118
+ };
119
+ Text.meta = {
120
+ description: "Text element with semantic typography props.",
121
+ propsSchema: TextPropsSchema
122
+ };
123
+ var NovaRenderContext = react.createContext(void 0);
124
+ var NovaShellContext = react.createContext(void 0);
125
+
126
+ // src/layout/adapter.ts
127
+ var NOVA_MODEL_PROP = "novaModel";
128
+ var NOVA_REF_PROP = "novaRef";
129
+ var renderNodeKey = (node, index) => {
130
+ if (node.key !== void 0) return `k:${node.key}`;
131
+ if (node.type === "component") {
132
+ if (node.ref !== void 0) return `c:${node.ref}`;
133
+ return `c:${node.name}:${index}`;
134
+ }
135
+ if (node.type === "text") return `t:${index}`;
136
+ if (node.type === "fragment") return `f:${index}`;
137
+ return `e:${node.code}:${index}`;
138
+ };
139
+ var ErrorMarker = ({ code, message }) => /* @__PURE__ */ jsxRuntime.jsx("span", { "data-nova-error": code, role: "alert", children: `[${code}] ${message}` });
140
+ var RenderNodeView = ({ node }) => {
141
+ const ctx = react.useContext(NovaRenderContext);
142
+ if (ctx === void 0) {
143
+ throw new Error("RenderNodeView must be used inside <NovaRenderProvider>");
144
+ }
145
+ if (node.type === "text") {
146
+ const TextWrap = ctx.textWrapper;
147
+ return TextWrap === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: node.value }) : /* @__PURE__ */ jsxRuntime.jsx(TextWrap, { children: node.value });
148
+ }
149
+ if (node.type === "fragment") {
150
+ return /* @__PURE__ */ jsxRuntime.jsx(RenderTree, { nodes: node.children });
151
+ }
152
+ if (node.type === "error") {
153
+ const Marker = ctx.errorMarker ?? ErrorMarker;
154
+ return /* @__PURE__ */ jsxRuntime.jsx(Marker, { code: node.code, message: node.message });
155
+ }
156
+ const entry = ctx.registry.get(node.name);
157
+ const Component = entry !== void 0 ? entry.component : ctx.fallback;
158
+ if (Component === void 0) {
159
+ return /* @__PURE__ */ jsxRuntime.jsx(ErrorMarker, { code: "COMPONENT_NOT_FOUND", message: node.name });
160
+ }
161
+ const props = { ...node.props };
162
+ if (node.model !== void 0) {
163
+ props[NOVA_MODEL_PROP] = { ref: node.model.ref, path: node.model.path };
164
+ }
165
+ if (node.ref !== void 0) {
166
+ props[NOVA_REF_PROP] = node.ref;
167
+ }
168
+ return react.createElement(
169
+ Component,
170
+ props,
171
+ node.children.length === 0 ? void 0 : node.children.map((child, i) => /* @__PURE__ */ jsxRuntime.jsx(RenderNodeView, { node: child }, renderNodeKey(child, i)))
172
+ );
173
+ };
174
+ var RenderTree = ({ nodes }) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: nodes.map((node, i) => /* @__PURE__ */ jsxRuntime.jsx(RenderNodeView, { node }, renderNodeKey(node, i))) });
175
+ var useShell = () => {
176
+ const shell = react.useContext(NovaShellContext);
177
+ if (shell === void 0) {
178
+ throw new Error("useShell must be used inside <NovaShellProvider>");
179
+ }
180
+ return shell;
181
+ };
182
+
183
+ // src/adapters/react/hooks/use-canvas-render-tree.ts
184
+ var EMPTY = [];
185
+ var useCanvasRenderTree = (canvasId) => {
186
+ const shell = useShell();
187
+ const cacheRef = react.useRef(void 0);
188
+ const subscribe = react.useCallback(
189
+ (cb) => shell.onStateChange(() => {
190
+ const tree = canvasId === void 0 ? EMPTY : shell.getCanvasRenderTree(canvasId);
191
+ cacheRef.current = { shell, canvasId, tree };
192
+ cb();
193
+ }),
194
+ [shell, canvasId]
195
+ );
196
+ const getSnapshot = react.useCallback(() => {
197
+ const cached = cacheRef.current;
198
+ if (cached !== void 0 && cached.shell === shell && cached.canvasId === canvasId) {
199
+ return cached.tree;
200
+ }
201
+ const tree = canvasId === void 0 ? EMPTY : shell.getCanvasRenderTree(canvasId);
202
+ cacheRef.current = { shell, canvasId, tree };
203
+ return tree;
204
+ }, [shell, canvasId]);
205
+ return react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
206
+ };
207
+ var EMPTY2 = [];
208
+ var useRenderTree = (instanceId) => {
209
+ const shell = useShell();
210
+ const cacheRef = react.useRef(void 0);
211
+ const subscribe = react.useCallback(
212
+ (cb) => {
213
+ const offState = shell.onStateChange(() => cb());
214
+ const runtime = shell.getRuntime(instanceId);
215
+ if (runtime === void 0) return offState;
216
+ const offData = runtime.onDataChange(() => cb());
217
+ return () => {
218
+ offData();
219
+ offState();
220
+ };
221
+ },
222
+ [shell, instanceId]
223
+ );
224
+ const getSnapshot = react.useCallback(() => {
225
+ const runtime = shell.getRuntime(instanceId);
226
+ if (runtime === void 0) {
227
+ cacheRef.current = void 0;
228
+ return EMPTY2;
229
+ }
230
+ const data = runtime.getData();
231
+ const phrases = shell.getPhrases();
232
+ const cached = cacheRef.current;
233
+ if (cached !== void 0 && cached.data === data && cached.phrases === phrases) return cached.tree;
234
+ const tree = runtime.render();
235
+ cacheRef.current = { data, phrases, tree };
236
+ return tree;
237
+ }, [shell, instanceId]);
238
+ return react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
239
+ };
240
+ var useNovaDispatch = () => {
241
+ const ctx = react.useContext(NovaRenderContext);
242
+ if (ctx === void 0) {
243
+ throw new Error("useNovaDispatch must be used inside <NovaRenderProvider>");
244
+ }
245
+ return ctx.dispatch;
246
+ };
247
+ var useSlotWrapper = () => react.useContext(NovaRenderContext)?.slotWrapper;
248
+ var computeStyle = (isDisabled, isFocused, isHovered) => {
249
+ const borderColor = isDisabled ? "#d1d5db" : isFocused ? "#2563eb" : isHovered ? "#9ca3af" : "#d1d5db";
250
+ return {
251
+ padding: "8px 12px",
252
+ border: `1px solid ${borderColor}`,
253
+ borderRadius: 6,
254
+ fontSize: 14,
255
+ background: isDisabled ? "#f9fafb" : "#ffffff",
256
+ color: isDisabled ? "#9ca3af" : "inherit",
257
+ cursor: isDisabled ? "not-allowed" : "text",
258
+ minWidth: 240,
259
+ outline: "none",
260
+ boxShadow: isFocused ? "0 0 0 3px rgba(37, 99, 235, 0.15)" : "none",
261
+ transition: "border-color 150ms, box-shadow 150ms"
262
+ };
263
+ };
264
+ var Input = ({
265
+ type,
266
+ placeholder,
267
+ disabled,
268
+ value,
269
+ debounce,
270
+ novaModel
271
+ }) => {
272
+ const dispatch = useNovaDispatch();
273
+ const [isHovered, setIsHovered] = react.useState(false);
274
+ const [draft, setDraft] = react.useState(null);
275
+ const isFocused = draft !== null;
276
+ const shown = draft ?? value ?? "";
277
+ const isDisabled = disabled ?? false;
278
+ const debounceMs = debounce ?? 0;
279
+ const timer = react.useRef(void 0);
280
+ const clearPending = () => {
281
+ if (timer.current !== void 0) {
282
+ clearTimeout(timer.current);
283
+ timer.current = void 0;
284
+ }
285
+ };
286
+ react.useEffect(() => clearPending, []);
287
+ const fire = (next) => {
288
+ if (novaModel === void 0) return;
289
+ dispatch({ type: "ui:model", ref: novaModel.ref, payload: next });
290
+ };
291
+ const onChange = (event) => {
292
+ const next = event.target.value;
293
+ setDraft(next);
294
+ if (debounceMs > 0) {
295
+ clearPending();
296
+ timer.current = setTimeout(() => {
297
+ timer.current = void 0;
298
+ fire(next);
299
+ }, debounceMs);
300
+ } else {
301
+ fire(next);
302
+ }
303
+ };
304
+ const onFocus = () => setDraft(value ?? "");
305
+ const onBlur = () => {
306
+ if (timer.current !== void 0 && draft !== null) {
307
+ clearPending();
308
+ fire(draft);
309
+ }
310
+ setDraft(null);
311
+ };
312
+ return /* @__PURE__ */ jsxRuntime.jsx(
313
+ "input",
314
+ {
315
+ type: type ?? "text",
316
+ placeholder,
317
+ disabled: isDisabled,
318
+ value: shown,
319
+ onChange,
320
+ onFocus,
321
+ onBlur,
322
+ onMouseEnter: () => setIsHovered(true),
323
+ onMouseLeave: () => setIsHovered(false),
324
+ style: computeStyle(isDisabled, isFocused, isHovered)
325
+ }
326
+ );
327
+ };
328
+ Input.meta = {
329
+ description: "Text input bound to data via the `model` field on the layout node.",
330
+ propsSchema: InputPropsSchema
331
+ };
332
+ var BASE_STYLE = {
333
+ borderRadius: 6,
334
+ fontSize: 14,
335
+ fontWeight: 500,
336
+ transition: "background-color 100ms"
337
+ };
338
+ var primaryStyle = (isDisabled, isHovered, isActive) => ({
339
+ ...BASE_STYLE,
340
+ padding: "8px 16px",
341
+ border: "none",
342
+ color: "#ffffff",
343
+ cursor: isDisabled ? "not-allowed" : "pointer",
344
+ background: isDisabled ? "#93c5fd" : isActive ? "#1e40af" : isHovered ? "#1d4ed8" : "#2563eb"
345
+ });
346
+ var secondaryStyle = (isDisabled, isHovered, isActive) => ({
347
+ ...BASE_STYLE,
348
+ padding: "8px 16px",
349
+ border: `1px solid ${isDisabled ? "#e5e7eb" : isHovered ? "#9ca3af" : "#d1d5db"}`,
350
+ color: isDisabled ? "#9ca3af" : "#1f2937",
351
+ cursor: isDisabled ? "not-allowed" : "pointer",
352
+ background: isDisabled ? "#ffffff" : isActive ? "#e5e7eb" : isHovered ? "#f3f4f6" : "#ffffff"
353
+ });
354
+ var ghostStyle = (isDisabled, isHovered, isActive) => ({
355
+ ...BASE_STYLE,
356
+ padding: "8px 12px",
357
+ border: "none",
358
+ color: isDisabled ? "#93c5fd" : "#2563eb",
359
+ cursor: isDisabled ? "not-allowed" : "pointer",
360
+ background: isDisabled ? "transparent" : isActive ? "#dbeafe" : isHovered ? "#eff6ff" : "transparent"
361
+ });
362
+ var styleFor = (variant, isDisabled, isHovered, isActive) => {
363
+ if (variant === "primary") return primaryStyle(isDisabled, isHovered, isActive);
364
+ if (variant === "secondary") return secondaryStyle(isDisabled, isHovered, isActive);
365
+ return ghostStyle(isDisabled, isHovered, isActive);
366
+ };
367
+ var Button = ({
368
+ label,
369
+ variant,
370
+ disabled,
371
+ novaRef,
372
+ children
373
+ }) => {
374
+ const dispatch = useNovaDispatch();
375
+ const [isHovered, setIsHovered] = react.useState(false);
376
+ const [isActive, setIsActive] = react.useState(false);
377
+ const isDisabled = disabled ?? false;
378
+ const style = styleFor(variant ?? "primary", isDisabled, isHovered, isActive);
379
+ const onClick = (_event) => {
380
+ if (isDisabled) return;
381
+ if (novaRef === void 0) return;
382
+ dispatch({ type: "ui:click", ref: novaRef });
383
+ };
384
+ return /* @__PURE__ */ jsxRuntime.jsx(
385
+ "button",
386
+ {
387
+ type: "button",
388
+ disabled: isDisabled,
389
+ style,
390
+ onClick,
391
+ onMouseEnter: () => setIsHovered(true),
392
+ onMouseLeave: () => {
393
+ setIsHovered(false);
394
+ setIsActive(false);
395
+ },
396
+ onMouseDown: () => setIsActive(true),
397
+ onMouseUp: () => setIsActive(false),
398
+ children: label ?? children
399
+ }
400
+ );
401
+ };
402
+ Button.meta = {
403
+ description: "Clickable button. Click events fire as `ui:click` with the layout node's ref.",
404
+ propsSchema: ButtonPropsSchema
405
+ };
406
+ var Box = ({
407
+ padding,
408
+ background,
409
+ border,
410
+ radius,
411
+ children
412
+ }) => {
413
+ const style = {
414
+ padding: padding ?? 0,
415
+ background: background ?? "transparent",
416
+ border: border === true ? "1px solid #e5e7eb" : "none",
417
+ borderRadius: radius ?? 0
418
+ };
419
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style, children });
420
+ };
421
+ Box.meta = {
422
+ description: "Generic container with basic styling props. Use Stack for layout, Box for visual wrapping.",
423
+ propsSchema: BoxPropsSchema
424
+ };
425
+ var Panel = ({ title, backRef, closeRef, children }) => {
426
+ const dispatch = useNovaDispatch();
427
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { border: "1px solid #d8dae0", borderRadius: 10, background: "#fff", boxShadow: "0 1px 3px rgba(0,0,0,.06)", padding: 12 }, children: [
428
+ title !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6, fontWeight: 600, fontSize: 13, marginBottom: 8 }, children: [
429
+ backRef !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
430
+ "button",
431
+ {
432
+ type: "button",
433
+ style: { border: "none", background: "none", color: "#6b7280", cursor: "pointer", fontSize: 13, lineHeight: 1, padding: 2 },
434
+ onClick: () => dispatch({ type: "ui:click", ref: backRef }),
435
+ children: "\u2190"
436
+ }
437
+ ),
438
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { flex: 1 }, children: title }),
439
+ closeRef !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
440
+ "button",
441
+ {
442
+ type: "button",
443
+ style: { border: "none", background: "none", color: "#6b7280", cursor: "pointer", fontSize: 13, lineHeight: 1, padding: 2 },
444
+ onClick: () => dispatch({ type: "ui:click", ref: closeRef }),
445
+ children: "\u2715"
446
+ }
447
+ )
448
+ ] }),
449
+ children
450
+ ] });
451
+ };
452
+ Panel.meta = { description: "A framed, elevated surface with an optional title; `closeRef` adds a header \u2715.", propsSchema: PanelPropsSchema };
453
+ var entriesOf = (value) => Array.isArray(value) ? value.map((item, index) => [String(index), item]) : Object.entries(value);
454
+ var JsonNode = ({ value, name }) => {
455
+ if (value !== null && typeof value === "object") {
456
+ const entries = entriesOf(value);
457
+ const shape = Array.isArray(value) ? `[${entries.length}]` : `{${entries.length}}`;
458
+ return /* @__PURE__ */ jsxRuntime.jsxs("details", { children: [
459
+ /* @__PURE__ */ jsxRuntime.jsx("summary", { style: { cursor: "pointer", color: "#6b7280" }, children: name === void 0 ? shape : `${name} ${shape}` }),
460
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { paddingLeft: 13, borderLeft: "1px solid #d8dae0", marginLeft: 3 }, children: entries.map(([key, child]) => /* @__PURE__ */ jsxRuntime.jsx(JsonNode, { value: child, name: key }, key)) })
461
+ ] });
462
+ }
463
+ const text = name === void 0 ? JSON.stringify(value) : `${name}: ${JSON.stringify(value)}`;
464
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: text });
465
+ };
466
+ var JsonTree = ({ value, label }) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fontSize: 12, lineHeight: 1.5 }, children: /* @__PURE__ */ jsxRuntime.jsx(JsonNode, { value, name: label }) });
467
+ JsonTree.meta = { description: "A collapsible view of any JSON value.", propsSchema: JsonTreePropsSchema };
468
+ var CanvasSlot = ({
469
+ canvasId
470
+ }) => {
471
+ const tree = useCanvasRenderTree(canvasId);
472
+ if (canvasId === void 0 || canvasId === "") return null;
473
+ return /* @__PURE__ */ jsxRuntime.jsx(RenderTree, { nodes: tree });
474
+ };
475
+ CanvasSlot.meta = {
476
+ description: "Renders a canvas by id, recursing into its actionLayout.",
477
+ propsSchema: CanvasSlotPropsSchema
478
+ };
479
+
480
+ // src/shared/event-bus/scope-dispatch.ts
481
+ var scopeDispatch = (dispatch, origin) => {
482
+ return (event) => dispatch(event.origin === void 0 ? { ...event, origin } : event);
483
+ };
484
+ var ActionSlot = ({
485
+ instanceId
486
+ }) => {
487
+ const tree = useRenderTree(instanceId ?? "");
488
+ const slotWrapper = useSlotWrapper();
489
+ const shell = useShell();
490
+ const hasInstance = instanceId !== void 0 && instanceId !== "";
491
+ const ctx = react.useContext(NovaRenderContext);
492
+ const scoped = react.useMemo(() => {
493
+ if (ctx === void 0 || instanceId === void 0 || instanceId === "") return ctx;
494
+ return { ...ctx, dispatch: scopeDispatch(ctx.dispatch, instanceId) };
495
+ }, [ctx, instanceId]);
496
+ if (slotWrapper === void 0) {
497
+ if (!hasInstance) return null;
498
+ return /* @__PURE__ */ jsxRuntime.jsx(NovaRenderContext.Provider, { value: scoped, children: /* @__PURE__ */ jsxRuntime.jsx(RenderTree, { nodes: tree }) });
499
+ }
500
+ const runtime = hasInstance ? shell.getRuntime(instanceId) : void 0;
501
+ const Wrapper = slotWrapper;
502
+ return /* @__PURE__ */ jsxRuntime.jsx(
503
+ Wrapper,
504
+ {
505
+ canvasId: runtime?.instance.canvasId,
506
+ instanceId: hasInstance ? instanceId : void 0,
507
+ action: runtime?.definition,
508
+ children: hasInstance && tree.length ? /* @__PURE__ */ jsxRuntime.jsx(NovaRenderContext.Provider, { value: scoped, children: /* @__PURE__ */ jsxRuntime.jsx(RenderTree, { nodes: tree }) }) : null
509
+ }
510
+ );
511
+ };
512
+ ActionSlot.meta = {
513
+ description: "Renders an action instance by id. Used inside a canvas actionLayout.",
514
+ propsSchema: ActionSlotPropsSchema
515
+ };
516
+
517
+ // src/adapters/react/components/index.ts
518
+ var registerNovaReactComponents = (registry) => {
519
+ registry.registerAll({
520
+ Stack,
521
+ Text,
522
+ Input,
523
+ Button,
524
+ Box,
525
+ Panel,
526
+ JsonTree,
527
+ CanvasSlot,
528
+ ActionSlot
529
+ });
530
+ };
531
+
532
+ exports.ActionSlot = ActionSlot;
533
+ exports.ActionSlotPropsSchema = ActionSlotPropsSchema;
534
+ exports.Box = Box;
535
+ exports.BoxPropsSchema = BoxPropsSchema;
536
+ exports.Button = Button;
537
+ exports.ButtonPropsSchema = ButtonPropsSchema;
538
+ exports.CanvasSlot = CanvasSlot;
539
+ exports.CanvasSlotPropsSchema = CanvasSlotPropsSchema;
540
+ exports.Input = Input;
541
+ exports.InputPropsSchema = InputPropsSchema;
542
+ exports.JsonTree = JsonTree;
543
+ exports.JsonTreePropsSchema = JsonTreePropsSchema;
544
+ exports.Panel = Panel;
545
+ exports.PanelPropsSchema = PanelPropsSchema;
546
+ exports.Stack = Stack;
547
+ exports.StackPropsSchema = StackPropsSchema;
548
+ exports.Text = Text;
549
+ exports.TextPropsSchema = TextPropsSchema;
550
+ exports.registerNovaReactComponents = registerNovaReactComponents;
551
+ //# sourceMappingURL=index.cjs.map
552
+ //# sourceMappingURL=index.cjs.map