@niscorp/nova 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADAPTER.md +6 -0
- package/CHANGELOG.md +44 -0
- package/README.md +53 -0
- package/dist/adapters/dom/components/index.d.cts +2 -2
- package/dist/adapters/dom/components/index.d.ts +2 -2
- package/dist/adapters/dom/index.cjs +227 -4
- package/dist/adapters/dom/index.cjs.map +1 -1
- package/dist/adapters/dom/index.d.cts +2 -2
- package/dist/adapters/dom/index.d.ts +2 -2
- package/dist/adapters/dom/index.js +7 -7
- package/dist/adapters/dom/server.cjs +10 -1
- package/dist/adapters/dom/server.cjs.map +1 -1
- package/dist/adapters/dom/server.d.cts +2 -2
- package/dist/adapters/dom/server.d.ts +2 -2
- package/dist/adapters/dom/server.js +7 -7
- package/dist/adapters/react/components/index.cjs +30 -10
- package/dist/adapters/react/components/index.cjs.map +1 -1
- package/dist/adapters/react/components/index.d.cts +4 -4
- package/dist/adapters/react/components/index.d.ts +4 -4
- package/dist/adapters/react/components/index.js +9 -5
- package/dist/adapters/react/index.cjs +400 -99
- package/dist/adapters/react/index.cjs.map +1 -1
- package/dist/adapters/react/index.d.cts +4 -4
- package/dist/adapters/react/index.d.ts +4 -4
- package/dist/adapters/react/index.js +9 -5
- package/dist/adapters/tty/components/index.d.cts +2 -2
- package/dist/adapters/tty/components/index.d.ts +2 -2
- package/dist/adapters/tty/index.cjs +6 -1
- package/dist/adapters/tty/index.cjs.map +1 -1
- package/dist/adapters/tty/index.d.cts +2 -2
- package/dist/adapters/tty/index.d.ts +2 -2
- package/dist/adapters/tty/index.js +12 -1
- package/dist/adapters/tty/index.js.map +1 -1
- package/dist/adapters/vue/components/index.cjs +30 -1
- package/dist/adapters/vue/components/index.cjs.map +1 -1
- package/dist/adapters/vue/components/index.d.cts +9 -9
- package/dist/adapters/vue/components/index.d.ts +9 -9
- package/dist/adapters/vue/components/index.js +9 -5
- package/dist/adapters/vue/index.cjs +347 -23
- package/dist/adapters/vue/index.cjs.map +1 -1
- package/dist/adapters/vue/index.d.cts +4 -4
- package/dist/adapters/vue/index.d.ts +4 -4
- package/dist/adapters/vue/index.js +10 -9
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/agent/index.d.cts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/{chunk-IGLCWXQ3.js → chunk-3JRTELLC.js} +3 -3
- package/dist/{chunk-IGLCWXQ3.js.map → chunk-3JRTELLC.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-FQAJ24KA.js → chunk-MHW5VEIM.js} +33 -8
- package/dist/chunk-MHW5VEIM.js.map +1 -0
- package/dist/chunk-OE4E6IBD.js +25 -0
- package/dist/chunk-OE4E6IBD.js.map +1 -0
- package/dist/{chunk-3HGE3VWK.js → chunk-QXQCPH33.js} +33 -11
- package/dist/chunk-QXQCPH33.js.map +1 -0
- package/dist/chunk-RFBIGRCI.js +127 -0
- package/dist/chunk-RFBIGRCI.js.map +1 -0
- package/dist/{chunk-6N4WRC5V.js → chunk-RYIIIXDX.js} +85 -12
- package/dist/chunk-RYIIIXDX.js.map +1 -0
- package/dist/{chunk-7S5BNPUS.js → chunk-UDCXGDLQ.js} +36 -4
- package/dist/chunk-UDCXGDLQ.js.map +1 -0
- package/dist/chunk-V4BPFFFV.js +152 -0
- package/dist/chunk-V4BPFFFV.js.map +1 -0
- package/dist/{chunk-4ZID7UX5.js → chunk-VU6NNCEJ.js} +52 -8
- package/dist/{chunk-4ZID7UX5.js.map → chunk-VU6NNCEJ.js.map} +1 -1
- package/dist/{chunk-V32EVEVM.js → chunk-Y6XVPRYH.js} +316 -5
- package/dist/chunk-Y6XVPRYH.js.map +1 -0
- package/dist/devtools/index.d.cts +2 -2
- package/dist/devtools/index.d.ts +2 -2
- package/dist/devtools/index.js +4 -5
- package/dist/devtools/index.js.map +1 -1
- package/dist/document/index.cjs +308 -0
- package/dist/document/index.cjs.map +1 -0
- package/dist/document/index.d.cts +22 -0
- package/dist/document/index.d.ts +22 -0
- package/dist/document/index.js +6 -0
- package/dist/document/index.js.map +1 -0
- package/dist/head-CAzfTnpV.d.cts +25 -0
- package/dist/head-DRpbbj-l.d.ts +25 -0
- package/dist/i18n/index.d.cts +2 -2
- package/dist/i18n/index.d.ts +2 -2
- package/dist/index.cjs +191 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/index.js +5 -6
- package/dist/migrations/index.js +1 -2
- package/dist/migrations/index.js.map +1 -1
- package/dist/{palette-Mx7XHYC6.d.ts → palette-CIpPH90W.d.ts} +1 -1
- package/dist/{palette-wbJB_svk.d.cts → palette-CvwZZCkx.d.cts} +1 -1
- package/dist/reflect/index.d.cts +2 -2
- package/dist/reflect/index.d.ts +2 -2
- package/dist/reflect/index.js +4 -5
- package/dist/{types-B-rjaUX0.d.ts → types-BSKx5MXW.d.ts} +1 -1
- package/dist/{types-B_nOtkyt.d.ts → types-BWc-olbY.d.ts} +1 -1
- package/dist/{types-mRKXqZPX.d.cts → types-C9734_lJ.d.cts} +1 -1
- package/dist/{types-BB9RXel5.d.ts → types-D23TRvqe.d.ts} +1 -1
- package/dist/{types-uk19d6KC.d.cts → types-DsWNYc7R.d.cts} +1 -1
- package/dist/{types-BLVRduoz.d.cts → types-j290XhCn.d.cts} +1 -1
- package/dist/{types-PDXOkvtK.d.cts → types-qkzTfSye.d.cts} +1 -1
- package/dist/{types-DE77Jl2W.d.ts → types-qnKMx0_V.d.ts} +1 -1
- package/package.json +13 -3
- package/dist/chunk-3HGE3VWK.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-CGoJvmcH.d.cts} +4 -4
- package/dist/{primitive-props-BH_EJWIe.d.cts → primitive-props-CGoJvmcH.d.ts} +4 -4
|
@@ -9,6 +9,345 @@ var isNovaComponent = (value) => typeof value === "function" || typeof value ===
|
|
|
9
9
|
// src/adapters/vue/context.ts
|
|
10
10
|
var NovaRenderKey = /* @__PURE__ */ Symbol.for("@niscorp/nova/adapters/vue:render");
|
|
11
11
|
var NovaShellKey = /* @__PURE__ */ Symbol.for("@niscorp/nova/adapters/vue:shell");
|
|
12
|
+
|
|
13
|
+
// src/layout/head.ts
|
|
14
|
+
var HEAD_NAME = "nova:head";
|
|
15
|
+
var HEAD_TITLE_NAME = "nova:title";
|
|
16
|
+
var HEAD_META_NAME = "nova:meta";
|
|
17
|
+
var HEAD_LINK_NAME = "nova:link";
|
|
18
|
+
var HEAD_SCRIPT_NAME = "nova:script";
|
|
19
|
+
var headKeyOf = (element) => {
|
|
20
|
+
const said = (name) => {
|
|
21
|
+
const found = Object.entries(element.attributes).find(([key]) => key.toLowerCase() === name)?.[1].trim().toLowerCase();
|
|
22
|
+
return found === void 0 || found === "" ? void 0 : found;
|
|
23
|
+
};
|
|
24
|
+
if (element.tag === "title") return "title";
|
|
25
|
+
if (element.tag === "meta") {
|
|
26
|
+
const [name, property] = [said("name"), said("property")];
|
|
27
|
+
if (name !== void 0) return `meta name ${name}`;
|
|
28
|
+
return property === void 0 ? void 0 : `meta property ${property}`;
|
|
29
|
+
}
|
|
30
|
+
if (element.tag === "link") return (said("rel") ?? "").split(/\s+/).includes("canonical") ? "link canonical" : void 0;
|
|
31
|
+
return void 0;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/layout/adapter.ts
|
|
35
|
+
var NOVA_MODEL_PROP = "novaModel";
|
|
36
|
+
var NOVA_REF_PROP = "novaRef";
|
|
37
|
+
var renderNodeKey = (node, index) => {
|
|
38
|
+
if (node.key !== void 0) return `k:${node.key}`;
|
|
39
|
+
if (node.type === "component") {
|
|
40
|
+
if (node.ref !== void 0) return `c:${node.ref}`;
|
|
41
|
+
return `c:${node.name}:${index}`;
|
|
42
|
+
}
|
|
43
|
+
if (node.type === "text") return `t:${index}`;
|
|
44
|
+
if (node.type === "fragment") return `f:${index}`;
|
|
45
|
+
return `e:${node.code}:${index}`;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/shared/event-bus/scope-dispatch.ts
|
|
49
|
+
var scopeDispatch = (dispatch, origin) => {
|
|
50
|
+
return (event) => dispatch(event.origin === void 0 ? { ...event, origin } : event);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/shell/slot-names.ts
|
|
54
|
+
var CANVAS_SLOT_NAME = "CanvasSlot";
|
|
55
|
+
var ACTION_SLOT_NAME = "ActionSlot";
|
|
56
|
+
|
|
57
|
+
// src/shell/head.ts
|
|
58
|
+
var ATTRIBUTE_NAME = /^[A-Za-z][A-Za-z0-9:._-]*$/;
|
|
59
|
+
var DATA_TYPE = /^application\/([a-z0-9.-]+\+)?json$/i;
|
|
60
|
+
var written = (value) => {
|
|
61
|
+
if (typeof value === "string") return value.trim() === "" ? void 0 : value;
|
|
62
|
+
if (typeof value === "number") return String(value);
|
|
63
|
+
return value === true ? "" : void 0;
|
|
64
|
+
};
|
|
65
|
+
var attributesOf = (what, props, skip = []) => {
|
|
66
|
+
const attributes = {};
|
|
67
|
+
for (const [name, value] of Object.entries(props)) {
|
|
68
|
+
if (skip.includes(name)) continue;
|
|
69
|
+
if (!ATTRIBUTE_NAME.test(name)) return { refused: `${what}: "${name}" is not an attribute\u2019s name` };
|
|
70
|
+
if (/^on/i.test(name)) return { refused: `${what}: \`${name}\` is a handler, and a layout does not run` };
|
|
71
|
+
const text = written(value);
|
|
72
|
+
if (text !== void 0) attributes[name] = text;
|
|
73
|
+
}
|
|
74
|
+
return { attributes };
|
|
75
|
+
};
|
|
76
|
+
var has = (attributes, name) => Object.keys(attributes).some((key) => key.toLowerCase() === name);
|
|
77
|
+
var valueOf = (attributes, name) => Object.entries(attributes).find(([key]) => key.toLowerCase() === name)?.[1] ?? "";
|
|
78
|
+
var textOf = (nodes) => nodes.map((node) => node.type === "text" ? node.value : node.type === "fragment" ? textOf(node.children) : "").join("");
|
|
79
|
+
var titleOf = (node) => {
|
|
80
|
+
const text = textOf(node.children).trim();
|
|
81
|
+
return text === "" ? void 0 : { element: { tag: "title", attributes: {}, text } };
|
|
82
|
+
};
|
|
83
|
+
var metaOf = (node) => {
|
|
84
|
+
const read = attributesOf(HEAD_META_NAME, node.props);
|
|
85
|
+
if ("refused" in read) return read;
|
|
86
|
+
if (has(read.attributes, "http-equiv")) return { refused: `${HEAD_META_NAME}: \`http-equiv\` instructs the browser, and a layout does not` };
|
|
87
|
+
return has(read.attributes, "content") ? { element: { tag: "meta", attributes: read.attributes } } : void 0;
|
|
88
|
+
};
|
|
89
|
+
var linkOf = (node) => {
|
|
90
|
+
const read = attributesOf(HEAD_LINK_NAME, node.props);
|
|
91
|
+
if ("refused" in read) return read;
|
|
92
|
+
if (valueOf(read.attributes, "rel").toLowerCase().split(/\s+/).includes("stylesheet")) return { refused: `${HEAD_LINK_NAME}: a stylesheet styles the page, and a layout does not` };
|
|
93
|
+
return has(read.attributes, "href") ? { element: { tag: "link", attributes: read.attributes } } : void 0;
|
|
94
|
+
};
|
|
95
|
+
var scriptOf = (node) => {
|
|
96
|
+
const read = attributesOf(HEAD_SCRIPT_NAME, node.props, ["data"]);
|
|
97
|
+
if ("refused" in read) return read;
|
|
98
|
+
if (has(read.attributes, "src")) return { refused: `${HEAD_SCRIPT_NAME}: a script with a \`src\` runs, and a layout does not` };
|
|
99
|
+
const type = valueOf(read.attributes, "type");
|
|
100
|
+
if (!DATA_TYPE.test(type)) return { refused: `${HEAD_SCRIPT_NAME}: only a data block may be written (a JSON \`type\`), and "${type}" is not one` };
|
|
101
|
+
const data = node.props["data"];
|
|
102
|
+
if (data === void 0 || data === null || data === "") return void 0;
|
|
103
|
+
return { element: { tag: "script", attributes: read.attributes, text: JSON.stringify(data) } };
|
|
104
|
+
};
|
|
105
|
+
var READERS = {
|
|
106
|
+
[HEAD_TITLE_NAME]: titleOf,
|
|
107
|
+
[HEAD_META_NAME]: metaOf,
|
|
108
|
+
[HEAD_LINK_NAME]: linkOf,
|
|
109
|
+
[HEAD_SCRIPT_NAME]: scriptOf
|
|
110
|
+
};
|
|
111
|
+
var isHeadNode = (node) => node.type === "component" && node.name === HEAD_NAME;
|
|
112
|
+
var headOf = (api) => {
|
|
113
|
+
let heads = 0;
|
|
114
|
+
const said = [];
|
|
115
|
+
const refused = [];
|
|
116
|
+
const open = /* @__PURE__ */ new Set();
|
|
117
|
+
const hold = (nodes, action) => {
|
|
118
|
+
for (const node of nodes) {
|
|
119
|
+
if (node.type === "fragment") {
|
|
120
|
+
hold(node.children, action);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (node.type === "error") {
|
|
124
|
+
refused.push(`${HEAD_NAME}: ${node.message}`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (node.type !== "component") continue;
|
|
128
|
+
const read = READERS[node.name];
|
|
129
|
+
if (read === void 0) {
|
|
130
|
+
refused.push(`${HEAD_NAME}: "${node.name}" is not something a head holds`);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const found = read(node);
|
|
134
|
+
if (found === void 0) continue;
|
|
135
|
+
if ("refused" in found) {
|
|
136
|
+
refused.push(found.refused);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const key = headKeyOf(found.element);
|
|
140
|
+
const earlier = key === void 0 ? -1 : said.findIndex((other) => headKeyOf(other.element) === key);
|
|
141
|
+
if (earlier >= 0) said.splice(earlier, 1);
|
|
142
|
+
said.push({ element: found.element, action });
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const walk = (nodes, action) => {
|
|
146
|
+
for (const node of nodes) {
|
|
147
|
+
if (node.type === "fragment") {
|
|
148
|
+
walk(node.children, action);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (node.type !== "component") continue;
|
|
152
|
+
if (node.name === HEAD_NAME) {
|
|
153
|
+
heads += 1;
|
|
154
|
+
hold(node.children, action);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (node.name === CANVAS_SLOT_NAME) {
|
|
158
|
+
const canvasId = node.props["canvasId"];
|
|
159
|
+
if (typeof canvasId !== "string" || canvasId === "" || open.has(canvasId)) continue;
|
|
160
|
+
open.add(canvasId);
|
|
161
|
+
walk(api.canvasTree(canvasId), void 0);
|
|
162
|
+
open.delete(canvasId);
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const definitionId = node.name === ACTION_SLOT_NAME ? node.props["definitionId"] : void 0;
|
|
166
|
+
walk(node.children, typeof definitionId === "string" ? definitionId : action);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
walk(api.frame(), void 0);
|
|
170
|
+
if (heads === 0) return void 0;
|
|
171
|
+
const actions = [...new Set(said.flatMap((one) => one.action === void 0 ? [] : [one.action]))];
|
|
172
|
+
return { elements: said.map((one) => one.element), actions, refused };
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// src/shell/view.ts
|
|
176
|
+
var hasVisibleContent = (nodes) => nodes.some((node) => {
|
|
177
|
+
if (node.type === "text") return node.value !== "";
|
|
178
|
+
if (node.type === "fragment") return hasVisibleContent(node.children);
|
|
179
|
+
if (node.type === "component" && node.name === ACTION_SLOT_NAME) return hasVisibleContent(node.children);
|
|
180
|
+
if (isHeadNode(node)) return false;
|
|
181
|
+
return true;
|
|
182
|
+
});
|
|
183
|
+
var canvasTreeOf = (shell, canvasId) => {
|
|
184
|
+
const tree = shell.flattenRenderTree(shell.getCanvasRenderTree(canvasId));
|
|
185
|
+
return hasVisibleContent(tree) ? tree : [];
|
|
186
|
+
};
|
|
187
|
+
var shellView = (shell) => ({
|
|
188
|
+
api: {
|
|
189
|
+
frame: () => shell.getShellRenderTree(),
|
|
190
|
+
canvasTree: (canvasId) => canvasTreeOf(shell, canvasId),
|
|
191
|
+
// An event that names no origin belongs to the canvas's ACTIVE instance — on
|
|
192
|
+
// a card deck that is the only one drawn. One that names its own (an
|
|
193
|
+
// adapter stamps it at the instance boundary, `scopeDispatch`) keeps it. A
|
|
194
|
+
// canvas with nothing mounted dispatches unstamped.
|
|
195
|
+
dispatch: (canvasId, event) => {
|
|
196
|
+
const active = shell.getState().canvases[canvasId]?.active;
|
|
197
|
+
shell.dispatch(event.origin === void 0 && active !== void 0 ? { ...event, origin: active.id } : event);
|
|
198
|
+
},
|
|
199
|
+
publish: (channel, payload) => shell.publish(channel, payload)
|
|
200
|
+
},
|
|
201
|
+
subscribe: (listener) => {
|
|
202
|
+
let pending = false;
|
|
203
|
+
let stopped = false;
|
|
204
|
+
const changed = () => {
|
|
205
|
+
if (pending || stopped) return;
|
|
206
|
+
pending = true;
|
|
207
|
+
queueMicrotask(() => {
|
|
208
|
+
pending = false;
|
|
209
|
+
if (!stopped) listener();
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
const offState = shell.onStateChange(changed);
|
|
213
|
+
const offData = shell.onDataChange(changed);
|
|
214
|
+
return () => {
|
|
215
|
+
stopped = true;
|
|
216
|
+
offState();
|
|
217
|
+
offData();
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// src/document/place-head.ts
|
|
223
|
+
var HEAD_MARK = "data-nova-head";
|
|
224
|
+
var OWN_MARK = "data-nova-own";
|
|
225
|
+
|
|
226
|
+
// src/document/head-keeper.ts
|
|
227
|
+
var TAGS2 = ["title", "meta", "link"];
|
|
228
|
+
var keyOfNode = (node) => {
|
|
229
|
+
const tag = TAGS2.find((name) => name === node.tagName.toLowerCase());
|
|
230
|
+
if (tag !== "title" && tag !== "meta" && tag !== "link") return void 0;
|
|
231
|
+
return headKeyOf({ tag, attributes: Object.fromEntries([...node.attributes].map((attribute) => [attribute.name, attribute.value])) });
|
|
232
|
+
};
|
|
233
|
+
var createHeadKeeper = (doc) => {
|
|
234
|
+
let mine = [];
|
|
235
|
+
let away = [];
|
|
236
|
+
let said;
|
|
237
|
+
const built = (element) => {
|
|
238
|
+
const node = doc.createElement(element.tag);
|
|
239
|
+
for (const [name, value] of Object.entries(element.attributes)) node.setAttribute(name, value);
|
|
240
|
+
node.setAttribute(HEAD_MARK, "");
|
|
241
|
+
if (element.text !== void 0) node.textContent = element.text;
|
|
242
|
+
return node;
|
|
243
|
+
};
|
|
244
|
+
const adopt = () => {
|
|
245
|
+
mine = [...doc.head.querySelectorAll(`[${HEAD_MARK}]`)];
|
|
246
|
+
const view = doc.defaultView;
|
|
247
|
+
for (const stash of doc.head.querySelectorAll(`template[${OWN_MARK}]`)) {
|
|
248
|
+
if (view === null || !(stash instanceof view.HTMLTemplateElement)) continue;
|
|
249
|
+
for (const child of [...stash.content.children]) {
|
|
250
|
+
const key = keyOfNode(child);
|
|
251
|
+
if (key !== void 0) away.push({ key, node: doc.importNode(child, true), before: null });
|
|
252
|
+
}
|
|
253
|
+
stash.remove();
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
return (elements) => {
|
|
257
|
+
const now = elements ?? [];
|
|
258
|
+
const next = JSON.stringify(now);
|
|
259
|
+
if (said === void 0) {
|
|
260
|
+
if (now.length === 0) return;
|
|
261
|
+
adopt();
|
|
262
|
+
}
|
|
263
|
+
if (next === said) return;
|
|
264
|
+
said = next;
|
|
265
|
+
for (const node of mine) node.remove();
|
|
266
|
+
mine = now.map(built);
|
|
267
|
+
const keys = new Set(now.flatMap((element) => headKeyOf(element) ?? []));
|
|
268
|
+
for (const node of [...doc.head.children]) {
|
|
269
|
+
const key = keyOfNode(node);
|
|
270
|
+
if (key === void 0 || !keys.has(key)) continue;
|
|
271
|
+
away.push({ key, node, before: node.nextSibling });
|
|
272
|
+
node.remove();
|
|
273
|
+
}
|
|
274
|
+
const [back, still] = [away.filter((gone) => !keys.has(gone.key)), away.filter((gone) => keys.has(gone.key))];
|
|
275
|
+
for (const gone of [...back].reverse()) doc.head.insertBefore(gone.node, gone.before !== null && gone.before.parentNode === doc.head ? gone.before : null);
|
|
276
|
+
away = still;
|
|
277
|
+
doc.head.append(...mine);
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// src/document/shell-head.ts
|
|
282
|
+
var createShellHead = (shell) => {
|
|
283
|
+
const view = shellView(shell);
|
|
284
|
+
let present = 0;
|
|
285
|
+
let keep;
|
|
286
|
+
let queued = false;
|
|
287
|
+
const read = () => {
|
|
288
|
+
if (queued || typeof document === "undefined") return;
|
|
289
|
+
queued = true;
|
|
290
|
+
queueMicrotask(() => {
|
|
291
|
+
queued = false;
|
|
292
|
+
keep ??= createHeadKeeper(document);
|
|
293
|
+
keep(present > 0 ? headOf(view.api)?.elements : void 0);
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
return {
|
|
297
|
+
enter: () => {
|
|
298
|
+
present += 1;
|
|
299
|
+
read();
|
|
300
|
+
},
|
|
301
|
+
leave: () => {
|
|
302
|
+
present -= 1;
|
|
303
|
+
read();
|
|
304
|
+
},
|
|
305
|
+
watch: () => view.subscribe(() => {
|
|
306
|
+
if (present > 0) read();
|
|
307
|
+
})
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// src/adapters/vue/head.ts
|
|
312
|
+
var ShellHeadKey = /* @__PURE__ */ Symbol.for("@niscorp/nova/adapters/vue:head");
|
|
313
|
+
var HeadMark = vue.defineComponent(
|
|
314
|
+
() => {
|
|
315
|
+
const head = vue.inject(ShellHeadKey, void 0);
|
|
316
|
+
vue.onMounted(() => {
|
|
317
|
+
if (head === void 0) return;
|
|
318
|
+
vue.watch(
|
|
319
|
+
head,
|
|
320
|
+
(current, _previous, onCleanup) => {
|
|
321
|
+
current.enter();
|
|
322
|
+
onCleanup(current.leave);
|
|
323
|
+
},
|
|
324
|
+
{ immediate: true }
|
|
325
|
+
);
|
|
326
|
+
});
|
|
327
|
+
return () => null;
|
|
328
|
+
},
|
|
329
|
+
{ name: "NovaHeadMark" }
|
|
330
|
+
);
|
|
331
|
+
var provideShellHead = (shell) => {
|
|
332
|
+
let held = shell();
|
|
333
|
+
const head = vue.shallowRef(createShellHead(held));
|
|
334
|
+
vue.provide(ShellHeadKey, head);
|
|
335
|
+
vue.onMounted(() => {
|
|
336
|
+
vue.watch(
|
|
337
|
+
shell,
|
|
338
|
+
(next, _previous, onCleanup) => {
|
|
339
|
+
if (next !== held) {
|
|
340
|
+
held = next;
|
|
341
|
+
head.value = createShellHead(next);
|
|
342
|
+
}
|
|
343
|
+
onCleanup(head.value.watch());
|
|
344
|
+
},
|
|
345
|
+
{ immediate: true }
|
|
346
|
+
);
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// src/adapters/vue/provider.ts
|
|
12
351
|
var noopDispatch = () => {
|
|
13
352
|
};
|
|
14
353
|
var noopPublish = () => {
|
|
@@ -45,6 +384,7 @@ var NovaShellProvider = vue.defineComponent(
|
|
|
45
384
|
}
|
|
46
385
|
};
|
|
47
386
|
vue.provide(NovaShellKey, source);
|
|
387
|
+
provideShellHead(() => props.shell);
|
|
48
388
|
const dispatch = (event) => props.shell.dispatch(event);
|
|
49
389
|
const publish = (channel, payload) => props.shell.publish(channel, payload);
|
|
50
390
|
return () => vue.h(
|
|
@@ -55,20 +395,6 @@ var NovaShellProvider = vue.defineComponent(
|
|
|
55
395
|
},
|
|
56
396
|
{ name: "NovaShellProvider", props: ["shell", "registry", "slotWrapper"] }
|
|
57
397
|
);
|
|
58
|
-
|
|
59
|
-
// src/layout/adapter.ts
|
|
60
|
-
var NOVA_MODEL_PROP = "novaModel";
|
|
61
|
-
var NOVA_REF_PROP = "novaRef";
|
|
62
|
-
var renderNodeKey = (node, index) => {
|
|
63
|
-
if (node.key !== void 0) return `k:${node.key}`;
|
|
64
|
-
if (node.type === "component") {
|
|
65
|
-
if (node.ref !== void 0) return `c:${node.ref}`;
|
|
66
|
-
return `c:${node.name}:${index}`;
|
|
67
|
-
}
|
|
68
|
-
if (node.type === "text") return `t:${index}`;
|
|
69
|
-
if (node.type === "fragment") return `f:${index}`;
|
|
70
|
-
return `e:${node.code}:${index}`;
|
|
71
|
-
};
|
|
72
398
|
var ErrorMarker = vue.defineComponent(
|
|
73
399
|
(props) => () => vue.h("span", { "data-nova-error": props.code, role: "alert" }, `[${props.code}] ${props.message}`),
|
|
74
400
|
{ name: "NovaErrorMarker", props: ["code", "message"] }
|
|
@@ -80,6 +406,7 @@ var renderNode = (ctx, node) => {
|
|
|
80
406
|
if (node.type === "text") return vue.createTextVNode(node.value);
|
|
81
407
|
if (node.type === "fragment") return vue.h(RenderTree, { nodes: node.children });
|
|
82
408
|
if (node.type === "error") return vue.h(ErrorMarker, { code: node.code, message: node.message });
|
|
409
|
+
if (isHeadNode(node)) return vue.h(HeadMark);
|
|
83
410
|
const registered = ctx.registry.get(node.name)?.component;
|
|
84
411
|
const component = isNovaComponent(registered) ? registered : ctx.fallback;
|
|
85
412
|
if (component === void 0) return vue.h(ErrorMarker, { code: "COMPONENT_NOT_FOUND", message: node.name });
|
|
@@ -88,7 +415,12 @@ var renderNode = (ctx, node) => {
|
|
|
88
415
|
if (node.ref !== void 0) props[NOVA_REF_PROP] = node.ref;
|
|
89
416
|
const { children } = node;
|
|
90
417
|
if (children.length === 0) return vue.h(component, props);
|
|
91
|
-
return vue.h(component, props, { default: () => childViews(children) });
|
|
418
|
+
if (!children.some(isHeadNode)) return vue.h(component, props, { default: () => childViews(children) });
|
|
419
|
+
const shown = children.filter((child) => !isHeadNode(child));
|
|
420
|
+
return vue.h(vue.Fragment, [
|
|
421
|
+
shown.length === 0 ? vue.h(component, props) : vue.h(component, props, { default: () => childViews(shown) }),
|
|
422
|
+
...children.filter(isHeadNode).map((_head, i) => vue.h(HeadMark, { key: `head:${i}` }))
|
|
423
|
+
]);
|
|
92
424
|
};
|
|
93
425
|
var RenderNodeView = vue.defineComponent(
|
|
94
426
|
(props) => {
|
|
@@ -122,14 +454,6 @@ var NovaErrorBoundary = vue.defineComponent(
|
|
|
122
454
|
},
|
|
123
455
|
{ name: "NovaErrorBoundary", props: ["fallback", "onError"] }
|
|
124
456
|
);
|
|
125
|
-
|
|
126
|
-
// src/shared/event-bus/scope-dispatch.ts
|
|
127
|
-
var scopeDispatch = (dispatch, origin) => {
|
|
128
|
-
return (event) => dispatch(event.origin === void 0 ? { ...event, origin } : event);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// src/shell/slot-names.ts
|
|
132
|
-
var CANVAS_SLOT_NAME = "CanvasSlot";
|
|
133
457
|
var StackPropsSchema = zod.z.object({
|
|
134
458
|
direction: zod.z.enum(["row", "column"]).optional().describe("Flex direction. Default: column."),
|
|
135
459
|
gap: zod.z.number().int().min(0).optional().describe("Gap between children in pixels. Default: 0."),
|