@niscorp/nova 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADAPTER.md +6 -0
- package/CHANGELOG.md +20 -0
- package/README.md +29 -1
- package/dist/adapters/dom/index.cjs +98 -4
- package/dist/adapters/dom/index.cjs.map +1 -1
- package/dist/adapters/dom/index.js +7 -7
- package/dist/adapters/dom/server.cjs +12 -1
- package/dist/adapters/dom/server.cjs.map +1 -1
- package/dist/adapters/dom/server.js +7 -7
- package/dist/adapters/react/components/index.cjs +32 -10
- package/dist/adapters/react/components/index.cjs.map +1 -1
- package/dist/adapters/react/components/index.d.cts +2 -2
- package/dist/adapters/react/components/index.d.ts +2 -2
- package/dist/adapters/react/components/index.js +9 -5
- package/dist/adapters/react/index.cjs +268 -97
- package/dist/adapters/react/index.cjs.map +1 -1
- package/dist/adapters/react/index.js +9 -5
- package/dist/adapters/tty/index.cjs +8 -1
- package/dist/adapters/tty/index.cjs.map +1 -1
- package/dist/adapters/tty/index.js +12 -1
- package/dist/adapters/tty/index.js.map +1 -1
- package/dist/adapters/vue/components/index.cjs +32 -1
- package/dist/adapters/vue/components/index.cjs.map +1 -1
- package/dist/adapters/vue/components/index.d.cts +1 -1
- package/dist/adapters/vue/components/index.d.ts +1 -1
- package/dist/adapters/vue/components/index.js +9 -5
- package/dist/adapters/vue/index.cjs +218 -23
- package/dist/adapters/vue/index.cjs.map +1 -1
- package/dist/adapters/vue/index.js +10 -9
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/{chunk-7S5BNPUS.js → chunk-4ERQYDF6.js} +36 -4
- package/dist/chunk-4ERQYDF6.js.map +1 -0
- package/dist/{chunk-FQAJ24KA.js → chunk-4I2PFMY7.js} +33 -8
- package/dist/chunk-4I2PFMY7.js.map +1 -0
- package/dist/{chunk-IGLCWXQ3.js → chunk-7PKS7UYL.js} +3 -3
- package/dist/{chunk-IGLCWXQ3.js.map → chunk-7PKS7UYL.js.map} +1 -1
- package/dist/{chunk-GVBBL36G.js → chunk-DIFE573X.js} +196 -4
- package/dist/chunk-DIFE573X.js.map +1 -0
- package/dist/chunk-EHHJJLRX.js +16 -0
- package/dist/chunk-EHHJJLRX.js.map +1 -0
- package/dist/{chunk-3HGE3VWK.js → chunk-KYQ4EAQH.js} +33 -11
- package/dist/chunk-KYQ4EAQH.js.map +1 -0
- package/dist/{chunk-V32EVEVM.js → chunk-RXECI7DE.js} +300 -5
- package/dist/chunk-RXECI7DE.js.map +1 -0
- package/dist/{chunk-4ZID7UX5.js → chunk-UUYXVOK2.js} +52 -8
- package/dist/chunk-UUYXVOK2.js.map +1 -0
- package/dist/chunk-UV5YGBHQ.js +62 -0
- package/dist/chunk-UV5YGBHQ.js.map +1 -0
- package/dist/{chunk-6N4WRC5V.js → chunk-WZVQ5PUB.js} +85 -12
- package/dist/chunk-WZVQ5PUB.js.map +1 -0
- package/dist/chunk-X7SSNSQC.js +6 -0
- package/dist/chunk-X7SSNSQC.js.map +1 -0
- package/dist/devtools/index.js +4 -5
- package/dist/devtools/index.js.map +1 -1
- package/dist/document/index.cjs +199 -0
- package/dist/document/index.cjs.map +1 -0
- package/dist/document/index.d.cts +20 -0
- package/dist/document/index.d.ts +20 -0
- package/dist/document/index.js +125 -0
- package/dist/document/index.js.map +1 -0
- package/dist/head-BNj8GwPO.d.cts +20 -0
- package/dist/head-CS6X6ZKr.d.ts +20 -0
- package/dist/index.cjs +77 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +5 -6
- package/dist/migrations/index.js +1 -2
- package/dist/migrations/index.js.map +1 -1
- package/dist/reflect/index.js +4 -5
- package/package.json +13 -3
- package/dist/chunk-3HGE3VWK.js.map +0 -1
- package/dist/chunk-4ZID7UX5.js.map +0 -1
- package/dist/chunk-6N4WRC5V.js.map +0 -1
- package/dist/chunk-7S5BNPUS.js.map +0 -1
- package/dist/chunk-FQAJ24KA.js.map +0 -1
- package/dist/chunk-GVBBL36G.js.map +0 -1
- package/dist/chunk-PF4OJTYU.js +0 -199
- package/dist/chunk-PF4OJTYU.js.map +0 -1
- package/dist/chunk-RQB4PRPV.js +0 -285
- package/dist/chunk-RQB4PRPV.js.map +0 -1
- package/dist/chunk-V32EVEVM.js.map +0 -1
- package/dist/chunk-ZITHBBF3.js +0 -85
- package/dist/chunk-ZITHBBF3.js.map +0 -1
- package/dist/{primitive-props-BH_EJWIe.d.ts → primitive-props-Cl5jiC8g.d.cts} +1 -1
- package/dist/{primitive-props-BH_EJWIe.d.cts → primitive-props-Cl5jiC8g.d.ts} +1 -1
|
@@ -1,57 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
4
|
var zod = require('zod');
|
|
6
5
|
var prism = require('@niscorp/prism');
|
|
7
6
|
var strata = require('@niscorp/strata');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
|
|
9
9
|
// src/adapters/react/provider.tsx
|
|
10
10
|
var NovaRenderContext = react.createContext(void 0);
|
|
11
11
|
var NovaShellContext = react.createContext(void 0);
|
|
12
|
-
var noopDispatch = () => {
|
|
13
|
-
};
|
|
14
|
-
var noopPublish = () => {
|
|
15
|
-
};
|
|
16
|
-
var NovaRenderProvider = ({
|
|
17
|
-
registry,
|
|
18
|
-
dispatch = noopDispatch,
|
|
19
|
-
publish = noopPublish,
|
|
20
|
-
slotWrapper,
|
|
21
|
-
fallback,
|
|
22
|
-
textWrapper,
|
|
23
|
-
errorMarker,
|
|
24
|
-
children
|
|
25
|
-
}) => {
|
|
26
|
-
const value = react.useMemo(
|
|
27
|
-
() => ({ registry, dispatch, publish, slotWrapper, fallback, textWrapper, errorMarker }),
|
|
28
|
-
[registry, dispatch, publish, slotWrapper, fallback, textWrapper, errorMarker]
|
|
29
|
-
);
|
|
30
|
-
return /* @__PURE__ */ jsxRuntime.jsx(NovaRenderContext.Provider, { value, children });
|
|
31
|
-
};
|
|
32
|
-
var NovaShellProvider = ({
|
|
33
|
-
shell,
|
|
34
|
-
registry,
|
|
35
|
-
slotWrapper,
|
|
36
|
-
children
|
|
37
|
-
}) => {
|
|
38
|
-
const dispatch = react.useMemo(() => (event) => shell.dispatch(event), [shell]);
|
|
39
|
-
const publish = react.useMemo(
|
|
40
|
-
() => (channel, payload) => shell.publish(channel, payload),
|
|
41
|
-
[shell]
|
|
42
|
-
);
|
|
43
|
-
const resolvedRegistry = registry ?? shell.registry;
|
|
44
|
-
return /* @__PURE__ */ jsxRuntime.jsx(NovaShellContext.Provider, { value: shell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
-
NovaRenderProvider,
|
|
46
|
-
{
|
|
47
|
-
registry: resolvedRegistry,
|
|
48
|
-
dispatch,
|
|
49
|
-
publish,
|
|
50
|
-
slotWrapper,
|
|
51
|
-
children
|
|
52
|
-
}
|
|
53
|
-
) });
|
|
54
|
-
};
|
|
55
12
|
zod.z.object({
|
|
56
13
|
$if: zod.z.unknown().describe("Condition \u2014 resolved recursively, then checked for truthiness."),
|
|
57
14
|
$then: zod.z.unknown().describe("Value when condition is truthy \u2014 resolved recursively."),
|
|
@@ -115,13 +72,40 @@ var isObject = (value) => typeof value === "object" && value !== null && !Array.
|
|
|
115
72
|
var isArray = (value) => Array.isArray(value);
|
|
116
73
|
var hasKey = (obj, key) => isObject(obj) && key in obj;
|
|
117
74
|
|
|
118
|
-
// src/
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
var
|
|
124
|
-
var
|
|
75
|
+
// src/shared/bindings/paths.ts
|
|
76
|
+
var splitPath = (path) => {
|
|
77
|
+
if (path.length === 0) return [];
|
|
78
|
+
return path.split(".");
|
|
79
|
+
};
|
|
80
|
+
var isIndex = (segment) => /^\d+$/.test(segment);
|
|
81
|
+
var getPath = (data, path) => {
|
|
82
|
+
const segments = splitPath(path);
|
|
83
|
+
let current = data;
|
|
84
|
+
for (const segment of segments) {
|
|
85
|
+
if (current === void 0 || current === null) return void 0;
|
|
86
|
+
if (isArray(current)) {
|
|
87
|
+
if (isIndex(segment)) {
|
|
88
|
+
const index = Number.parseInt(segment, 10);
|
|
89
|
+
current = current[index];
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (segment === "length") {
|
|
93
|
+
current = current.length;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
if (isObject(current)) {
|
|
99
|
+
if (segment in current) {
|
|
100
|
+
current = current[segment];
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
return current;
|
|
108
|
+
};
|
|
125
109
|
|
|
126
110
|
// src/shared/errors.ts
|
|
127
111
|
var ErrorCodes = {
|
|
@@ -164,44 +148,17 @@ var DefinitionValidationError = class extends NovaError {
|
|
|
164
148
|
}
|
|
165
149
|
};
|
|
166
150
|
|
|
151
|
+
// src/layout/guards.ts
|
|
152
|
+
var isLayoutPrimitive = (value) => value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
153
|
+
var isComponentNode = (value) => hasKey(value, "component") && typeof value["component"] === "string";
|
|
154
|
+
var isConditionalNode = (value) => hasKey(value, "if") && hasKey(value, "then") && !hasKey(value, "for");
|
|
155
|
+
var isLoopNode = (value) => hasKey(value, "for") && hasKey(value, "as") && hasKey(value, "do");
|
|
156
|
+
var isLayoutRefNode = (value) => isObject(value) && hasKey(value, "ref") && typeof value["ref"] === "string" && !hasKey(value, "component") && Object.keys(value).length === 1;
|
|
157
|
+
var isSlotNode = (value) => isObject(value) && hasKey(value, "slot") && typeof value["slot"] === "string" && Object.keys(value).length === 1;
|
|
158
|
+
|
|
167
159
|
// src/shared/bindings/scope.ts
|
|
168
160
|
var createScopeChain = (data) => [data];
|
|
169
161
|
var pushScope = (chain, scope) => [scope, ...chain];
|
|
170
|
-
|
|
171
|
-
// src/shared/bindings/paths.ts
|
|
172
|
-
var splitPath = (path) => {
|
|
173
|
-
if (path.length === 0) return [];
|
|
174
|
-
return path.split(".");
|
|
175
|
-
};
|
|
176
|
-
var isIndex = (segment) => /^\d+$/.test(segment);
|
|
177
|
-
var getPath = (data, path) => {
|
|
178
|
-
const segments = splitPath(path);
|
|
179
|
-
let current = data;
|
|
180
|
-
for (const segment of segments) {
|
|
181
|
-
if (current === void 0 || current === null) return void 0;
|
|
182
|
-
if (isArray(current)) {
|
|
183
|
-
if (isIndex(segment)) {
|
|
184
|
-
const index = Number.parseInt(segment, 10);
|
|
185
|
-
current = current[index];
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
if (segment === "length") {
|
|
189
|
-
current = current.length;
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
return void 0;
|
|
193
|
-
}
|
|
194
|
-
if (isObject(current)) {
|
|
195
|
-
if (segment in current) {
|
|
196
|
-
current = current[segment];
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
return void 0;
|
|
200
|
-
}
|
|
201
|
-
return void 0;
|
|
202
|
-
}
|
|
203
|
-
return current;
|
|
204
|
-
};
|
|
205
162
|
var TEMPLATE_REGEX = /\{\{\s*([^}]+?)\s*\}\}/g;
|
|
206
163
|
var SOLE_TEMPLATE_REGEX = /^\{\{\s*([^}]+?)\s*\}\}$/;
|
|
207
164
|
var BARE_PATH_REGEX = /^\$(\.|[A-Za-z_]|$)/;
|
|
@@ -461,6 +418,9 @@ var walkValue = (value, prose, where, pass) => {
|
|
|
461
418
|
return value;
|
|
462
419
|
};
|
|
463
420
|
|
|
421
|
+
// src/layout/head.ts
|
|
422
|
+
var HEAD_NAME = "nova:head";
|
|
423
|
+
|
|
464
424
|
// src/layout/renderer.ts
|
|
465
425
|
var noopOnError = (_error) => {
|
|
466
426
|
};
|
|
@@ -556,7 +516,7 @@ var renderNode = (node, chain, ctx) => {
|
|
|
556
516
|
return [];
|
|
557
517
|
};
|
|
558
518
|
var renderComponent = (node, chain, ctx) => {
|
|
559
|
-
if (!ctx.registry.has(node.component)) {
|
|
519
|
+
if (node.component !== HEAD_NAME && !ctx.registry.has(node.component)) {
|
|
560
520
|
throw new ComponentNotFoundError(
|
|
561
521
|
`Component not found in registry: ${node.component}`,
|
|
562
522
|
{ name: node.component }
|
|
@@ -750,6 +710,216 @@ var createComponentRegistry = () => {
|
|
|
750
710
|
const list = () => Array.from(entries.keys());
|
|
751
711
|
return { register, registerAll, get, has, list };
|
|
752
712
|
};
|
|
713
|
+
|
|
714
|
+
// src/shared/event-bus/scope-dispatch.ts
|
|
715
|
+
var scopeDispatch = (dispatch, origin) => {
|
|
716
|
+
return (event) => dispatch(event.origin === void 0 ? { ...event, origin } : event);
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
// src/shell/slot-names.ts
|
|
720
|
+
var CANVAS_SLOT_NAME = "CanvasSlot";
|
|
721
|
+
var ACTION_SLOT_NAME = "ActionSlot";
|
|
722
|
+
|
|
723
|
+
// src/shell/head.ts
|
|
724
|
+
var said = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
725
|
+
var isObject2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
726
|
+
var structuredOf = (value) => {
|
|
727
|
+
if (isObject2(value)) return value;
|
|
728
|
+
if (Array.isArray(value) && value.length > 0 && value.every(isObject2)) return value;
|
|
729
|
+
return void 0;
|
|
730
|
+
};
|
|
731
|
+
var headFrom = (props) => {
|
|
732
|
+
const [title, description, image] = [said(props["title"]), said(props["description"]), said(props["image"])];
|
|
733
|
+
const kind = props["kind"] === "website" || props["kind"] === "article" ? props["kind"] : void 0;
|
|
734
|
+
const structured = structuredOf(props["structured"]);
|
|
735
|
+
return {
|
|
736
|
+
...title !== void 0 ? { title } : {},
|
|
737
|
+
...description !== void 0 ? { description } : {},
|
|
738
|
+
...image !== void 0 ? { image } : {},
|
|
739
|
+
...kind !== void 0 ? { kind } : {},
|
|
740
|
+
...structured !== void 0 ? { structured } : {}
|
|
741
|
+
};
|
|
742
|
+
};
|
|
743
|
+
var isHeadNode = (node) => node.type === "component" && node.name === HEAD_NAME;
|
|
744
|
+
var headOf = (api) => {
|
|
745
|
+
const found = [];
|
|
746
|
+
const open = /* @__PURE__ */ new Set();
|
|
747
|
+
const walk = (nodes, action) => {
|
|
748
|
+
for (const node of nodes) {
|
|
749
|
+
if (node.type === "fragment") {
|
|
750
|
+
walk(node.children, action);
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
if (node.type !== "component") continue;
|
|
754
|
+
if (node.name === HEAD_NAME) {
|
|
755
|
+
found.push({ props: node.props, action });
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
if (node.name === CANVAS_SLOT_NAME) {
|
|
759
|
+
const canvasId = node.props["canvasId"];
|
|
760
|
+
if (typeof canvasId !== "string" || canvasId === "" || open.has(canvasId)) continue;
|
|
761
|
+
open.add(canvasId);
|
|
762
|
+
walk(api.canvasTree(canvasId), void 0);
|
|
763
|
+
open.delete(canvasId);
|
|
764
|
+
continue;
|
|
765
|
+
}
|
|
766
|
+
const definitionId = node.name === ACTION_SLOT_NAME ? node.props["definitionId"] : void 0;
|
|
767
|
+
walk(node.children, typeof definitionId === "string" ? definitionId : action);
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
walk(api.frame(), void 0);
|
|
771
|
+
const last = found[found.length - 1];
|
|
772
|
+
if (last === void 0) return void 0;
|
|
773
|
+
return { head: headFrom(last.props), ...last.action !== void 0 ? { action: last.action } : {} };
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
// src/shell/view.ts
|
|
777
|
+
var hasVisibleContent = (nodes) => nodes.some((node) => {
|
|
778
|
+
if (node.type === "text") return node.value !== "";
|
|
779
|
+
if (node.type === "fragment") return hasVisibleContent(node.children);
|
|
780
|
+
if (node.type === "component" && node.name === ACTION_SLOT_NAME) return hasVisibleContent(node.children);
|
|
781
|
+
if (isHeadNode(node)) return false;
|
|
782
|
+
return true;
|
|
783
|
+
});
|
|
784
|
+
var canvasTreeOf = (shell, canvasId) => {
|
|
785
|
+
const tree = shell.flattenRenderTree(shell.getCanvasRenderTree(canvasId));
|
|
786
|
+
return hasVisibleContent(tree) ? tree : [];
|
|
787
|
+
};
|
|
788
|
+
var shellView = (shell) => ({
|
|
789
|
+
api: {
|
|
790
|
+
frame: () => shell.getShellRenderTree(),
|
|
791
|
+
canvasTree: (canvasId) => canvasTreeOf(shell, canvasId),
|
|
792
|
+
// An event that names no origin belongs to the canvas's ACTIVE instance — on
|
|
793
|
+
// a card deck that is the only one drawn. One that names its own (an
|
|
794
|
+
// adapter stamps it at the instance boundary, `scopeDispatch`) keeps it. A
|
|
795
|
+
// canvas with nothing mounted dispatches unstamped.
|
|
796
|
+
dispatch: (canvasId, event) => {
|
|
797
|
+
const active = shell.getState().canvases[canvasId]?.active;
|
|
798
|
+
shell.dispatch(event.origin === void 0 && active !== void 0 ? { ...event, origin: active.id } : event);
|
|
799
|
+
},
|
|
800
|
+
publish: (channel, payload) => shell.publish(channel, payload)
|
|
801
|
+
},
|
|
802
|
+
subscribe: (listener) => {
|
|
803
|
+
let pending = false;
|
|
804
|
+
let stopped = false;
|
|
805
|
+
const changed = () => {
|
|
806
|
+
if (pending || stopped) return;
|
|
807
|
+
pending = true;
|
|
808
|
+
queueMicrotask(() => {
|
|
809
|
+
pending = false;
|
|
810
|
+
if (!stopped) listener();
|
|
811
|
+
});
|
|
812
|
+
};
|
|
813
|
+
const offState = shell.onStateChange(changed);
|
|
814
|
+
const offData = shell.onDataChange(changed);
|
|
815
|
+
return () => {
|
|
816
|
+
stopped = true;
|
|
817
|
+
offState();
|
|
818
|
+
offData();
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
// src/document/title.ts
|
|
824
|
+
var createTitleKeeper = (doc) => {
|
|
825
|
+
const own = doc.querySelector("title")?.getAttribute("data-own") ?? doc.title;
|
|
826
|
+
let said2;
|
|
827
|
+
return (head) => {
|
|
828
|
+
const title = head?.title;
|
|
829
|
+
if (title === said2) return;
|
|
830
|
+
said2 = title;
|
|
831
|
+
const next = title ?? own;
|
|
832
|
+
if (doc.title !== next) doc.title = next;
|
|
833
|
+
};
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
// src/document/shell-title.ts
|
|
837
|
+
var createShellTitle = (shell) => {
|
|
838
|
+
const view = shellView(shell);
|
|
839
|
+
let present = 0;
|
|
840
|
+
let keep;
|
|
841
|
+
let queued = false;
|
|
842
|
+
const read = () => {
|
|
843
|
+
if (queued || typeof document === "undefined") return;
|
|
844
|
+
queued = true;
|
|
845
|
+
queueMicrotask(() => {
|
|
846
|
+
queued = false;
|
|
847
|
+
keep ??= createTitleKeeper(document);
|
|
848
|
+
keep(present > 0 ? headOf(view.api)?.head : void 0);
|
|
849
|
+
});
|
|
850
|
+
};
|
|
851
|
+
return {
|
|
852
|
+
enter: () => {
|
|
853
|
+
present += 1;
|
|
854
|
+
read();
|
|
855
|
+
},
|
|
856
|
+
leave: () => {
|
|
857
|
+
present -= 1;
|
|
858
|
+
read();
|
|
859
|
+
},
|
|
860
|
+
watch: () => view.subscribe(() => {
|
|
861
|
+
if (present > 0) read();
|
|
862
|
+
})
|
|
863
|
+
};
|
|
864
|
+
};
|
|
865
|
+
var ShellTitleContext = react.createContext(void 0);
|
|
866
|
+
var HeadMark = () => {
|
|
867
|
+
const title = react.useContext(ShellTitleContext);
|
|
868
|
+
react.useEffect(() => {
|
|
869
|
+
if (title === void 0) return void 0;
|
|
870
|
+
title.enter();
|
|
871
|
+
return title.leave;
|
|
872
|
+
}, [title]);
|
|
873
|
+
return null;
|
|
874
|
+
};
|
|
875
|
+
var ShellTitleProvider = ({ shell, children }) => {
|
|
876
|
+
const title = react.useMemo(() => createShellTitle(shell), [shell]);
|
|
877
|
+
react.useEffect(() => title.watch(), [title]);
|
|
878
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ShellTitleContext.Provider, { value: title, children });
|
|
879
|
+
};
|
|
880
|
+
var noopDispatch = () => {
|
|
881
|
+
};
|
|
882
|
+
var noopPublish = () => {
|
|
883
|
+
};
|
|
884
|
+
var NovaRenderProvider = ({
|
|
885
|
+
registry,
|
|
886
|
+
dispatch = noopDispatch,
|
|
887
|
+
publish = noopPublish,
|
|
888
|
+
slotWrapper,
|
|
889
|
+
fallback,
|
|
890
|
+
textWrapper,
|
|
891
|
+
errorMarker,
|
|
892
|
+
children
|
|
893
|
+
}) => {
|
|
894
|
+
const value = react.useMemo(
|
|
895
|
+
() => ({ registry, dispatch, publish, slotWrapper, fallback, textWrapper, errorMarker }),
|
|
896
|
+
[registry, dispatch, publish, slotWrapper, fallback, textWrapper, errorMarker]
|
|
897
|
+
);
|
|
898
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NovaRenderContext.Provider, { value, children });
|
|
899
|
+
};
|
|
900
|
+
var NovaShellProvider = ({
|
|
901
|
+
shell,
|
|
902
|
+
registry,
|
|
903
|
+
slotWrapper,
|
|
904
|
+
children
|
|
905
|
+
}) => {
|
|
906
|
+
const dispatch = react.useMemo(() => (event) => shell.dispatch(event), [shell]);
|
|
907
|
+
const publish = react.useMemo(
|
|
908
|
+
() => (channel, payload) => shell.publish(channel, payload),
|
|
909
|
+
[shell]
|
|
910
|
+
);
|
|
911
|
+
const resolvedRegistry = registry ?? shell.registry;
|
|
912
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NovaShellContext.Provider, { value: shell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
913
|
+
NovaRenderProvider,
|
|
914
|
+
{
|
|
915
|
+
registry: resolvedRegistry,
|
|
916
|
+
dispatch,
|
|
917
|
+
publish,
|
|
918
|
+
slotWrapper,
|
|
919
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ShellTitleProvider, { shell, children })
|
|
920
|
+
}
|
|
921
|
+
) });
|
|
922
|
+
};
|
|
753
923
|
var ErrorMarker = ({ code, message }) => /* @__PURE__ */ jsxRuntime.jsx("span", { "data-nova-error": code, role: "alert", children: `[${code}] ${message}` });
|
|
754
924
|
var RenderNodeView = ({ node }) => {
|
|
755
925
|
const ctx = react.useContext(NovaRenderContext);
|
|
@@ -767,6 +937,7 @@ var RenderNodeView = ({ node }) => {
|
|
|
767
937
|
const Marker = ctx.errorMarker ?? ErrorMarker;
|
|
768
938
|
return /* @__PURE__ */ jsxRuntime.jsx(Marker, { code: node.code, message: node.message });
|
|
769
939
|
}
|
|
940
|
+
if (isHeadNode(node)) return /* @__PURE__ */ jsxRuntime.jsx(HeadMark, {});
|
|
770
941
|
const entry = ctx.registry.get(node.name);
|
|
771
942
|
const Component2 = entry !== void 0 ? entry.component : ctx.fallback;
|
|
772
943
|
if (Component2 === void 0) {
|
|
@@ -779,11 +950,16 @@ var RenderNodeView = ({ node }) => {
|
|
|
779
950
|
if (node.ref !== void 0) {
|
|
780
951
|
props[NOVA_REF_PROP] = node.ref;
|
|
781
952
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
props,
|
|
785
|
-
|
|
786
|
-
);
|
|
953
|
+
const viewOf = (child, i) => /* @__PURE__ */ jsxRuntime.jsx(RenderNodeView, { node: child }, renderNodeKey(child, i));
|
|
954
|
+
if (!node.children.some(isHeadNode)) {
|
|
955
|
+
return react.createElement(Component2, props, node.children.length === 0 ? void 0 : node.children.map(viewOf));
|
|
956
|
+
}
|
|
957
|
+
const views = node.children.map((child, i) => ({ head: isHeadNode(child), view: viewOf(child, i) }));
|
|
958
|
+
const shown = views.filter((child) => !child.head).map((child) => child.view);
|
|
959
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
960
|
+
react.createElement(Component2, props, shown.length === 0 ? void 0 : shown),
|
|
961
|
+
views.filter((child) => child.head).map((child) => child.view)
|
|
962
|
+
] });
|
|
787
963
|
};
|
|
788
964
|
var RenderTree = ({ nodes }) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: nodes.map((node, i) => /* @__PURE__ */ jsxRuntime.jsx(RenderNodeView, { node }, renderNodeKey(node, i))) });
|
|
789
965
|
var NovaErrorBoundary = class extends react.Component {
|
|
@@ -1151,11 +1327,6 @@ CanvasSlot.meta = {
|
|
|
1151
1327
|
description: "Renders a canvas by id, recursing into its actionLayout.",
|
|
1152
1328
|
propsSchema: CanvasSlotPropsSchema
|
|
1153
1329
|
};
|
|
1154
|
-
|
|
1155
|
-
// src/shared/event-bus/scope-dispatch.ts
|
|
1156
|
-
var scopeDispatch = (dispatch, origin) => {
|
|
1157
|
-
return (event) => dispatch(event.origin === void 0 ? { ...event, origin } : event);
|
|
1158
|
-
};
|
|
1159
1330
|
var ActionSlot = ({
|
|
1160
1331
|
instanceId
|
|
1161
1332
|
}) => {
|