@niscorp/nova 0.1.3 → 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 +14 -0
- package/README.md +28 -0
- 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 +12 -2
- 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
package/dist/chunk-RQB4PRPV.js
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { collectInteractive } from './chunk-OGD5CCMZ.js';
|
|
2
|
-
import { OPS } from './chunk-GVBBL36G.js';
|
|
3
|
-
import { fillSlots } from './chunk-V32EVEVM.js';
|
|
4
|
-
|
|
5
|
-
// src/action/compose.ts
|
|
6
|
-
var HOOKS = ["mount", "unmount", "suspend", "resume"];
|
|
7
|
-
var composeAction = (action, fragments) => {
|
|
8
|
-
if (fragments.length === 0) return action;
|
|
9
|
-
let layout = action.layout;
|
|
10
|
-
for (const frag of fragments) {
|
|
11
|
-
const wrap = frag.layout;
|
|
12
|
-
if (wrap === void 0) continue;
|
|
13
|
-
if (typeof wrap === "string") {
|
|
14
|
-
layout = wrap;
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
layout = fillSlots(wrap, layout === void 0 ? {} : { body: layout });
|
|
18
|
-
}
|
|
19
|
-
const data = {};
|
|
20
|
-
for (const frag of fragments) Object.assign(data, frag.data ?? {});
|
|
21
|
-
Object.assign(data, action.data ?? {});
|
|
22
|
-
const triggers = [
|
|
23
|
-
...fragments.flatMap((f) => f.triggers ?? []),
|
|
24
|
-
...action.triggers ?? []
|
|
25
|
-
];
|
|
26
|
-
const endpoints = {};
|
|
27
|
-
for (const frag of fragments) Object.assign(endpoints, frag.endpoints ?? {});
|
|
28
|
-
Object.assign(endpoints, action.endpoints ?? {});
|
|
29
|
-
const lifecycle = {};
|
|
30
|
-
for (const hook of HOOKS) {
|
|
31
|
-
const steps = [
|
|
32
|
-
...fragments.flatMap((f) => f.lifecycle?.[hook] ?? []),
|
|
33
|
-
...action.lifecycle?.[hook] ?? []
|
|
34
|
-
];
|
|
35
|
-
if (steps.length > 0) lifecycle[hook] = steps;
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
id: action.id,
|
|
39
|
-
...action.name === void 0 ? {} : { name: action.name },
|
|
40
|
-
...action.description === void 0 ? {} : { description: action.description },
|
|
41
|
-
...action.title === void 0 ? {} : { title: action.title },
|
|
42
|
-
...action.input === void 0 ? {} : { input: action.input },
|
|
43
|
-
...layout === void 0 ? {} : { layout },
|
|
44
|
-
...Object.keys(data).length > 0 ? { data } : {},
|
|
45
|
-
...triggers.length > 0 ? { triggers } : {},
|
|
46
|
-
...Object.keys(endpoints).length > 0 ? { endpoints } : {},
|
|
47
|
-
...Object.keys(lifecycle).length > 0 ? { lifecycle } : {}
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// src/action/grammar.ts
|
|
52
|
-
var MUTATION_KEYS = [...new Set(OPS.map((op) => op.key))];
|
|
53
|
-
var MATCHERS = OPS.map((op) => op.match ?? ((step) => op.key in step));
|
|
54
|
-
var isMutationStep = (step) => MATCHERS.some((match) => match(step));
|
|
55
|
-
var mutationPaths = (steps) => {
|
|
56
|
-
const found = [];
|
|
57
|
-
const walk = (node) => {
|
|
58
|
-
if (Array.isArray(node)) {
|
|
59
|
-
for (const item of node) walk(item);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (node === null || typeof node !== "object") return;
|
|
63
|
-
const step = node;
|
|
64
|
-
if (isMutationStep(step)) {
|
|
65
|
-
for (const key of MUTATION_KEYS) {
|
|
66
|
-
const value = step[key];
|
|
67
|
-
if (typeof value === "string") found.push(value);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
walk(step["onSuccess"]);
|
|
71
|
-
walk(step["onError"]);
|
|
72
|
-
};
|
|
73
|
-
walk(steps);
|
|
74
|
-
return found;
|
|
75
|
-
};
|
|
76
|
-
var rootOf = (path) => path.split(".")[0] ?? path;
|
|
77
|
-
|
|
78
|
-
// src/action/audit.ts
|
|
79
|
-
var collectChannels = (definition) => {
|
|
80
|
-
const emits = /* @__PURE__ */ new Set();
|
|
81
|
-
const listens = /* @__PURE__ */ new Set();
|
|
82
|
-
const walkSteps = (list) => {
|
|
83
|
-
if (!Array.isArray(list)) return;
|
|
84
|
-
for (const step of list) {
|
|
85
|
-
if (!isRecord(step)) continue;
|
|
86
|
-
const emit = step["emit"];
|
|
87
|
-
if (isRecord(emit) && typeof emit["channel"] === "string") emits.add(emit["channel"]);
|
|
88
|
-
if (typeof step["call"] === "string") {
|
|
89
|
-
walkSteps(step["onSuccess"]);
|
|
90
|
-
walkSteps(step["onError"]);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
for (const trigger of definition.triggers ?? []) {
|
|
95
|
-
if (typeof trigger.message === "string") listens.add(trigger.message);
|
|
96
|
-
walkSteps(trigger.do);
|
|
97
|
-
}
|
|
98
|
-
for (const hook of Object.values(definition.lifecycle ?? {})) walkSteps(hook);
|
|
99
|
-
return { emits: [...emits].sort(), listens: [...listens].sort() };
|
|
100
|
-
};
|
|
101
|
-
var firstSegment = (path) => {
|
|
102
|
-
const segment = path.split(".")[0];
|
|
103
|
-
return segment === void 0 || segment.length === 0 ? path : segment;
|
|
104
|
-
};
|
|
105
|
-
var isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
106
|
-
var navTargetOf = (step) => {
|
|
107
|
-
for (const key of ["push", "replace", "resetTo"]) {
|
|
108
|
-
const value = step[key];
|
|
109
|
-
if (isRecord(value) && typeof value["action"] === "string") {
|
|
110
|
-
const input = value["input"];
|
|
111
|
-
return { action: value["action"], ...isRecord(input) ? { input } : {} };
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return void 0;
|
|
115
|
-
};
|
|
116
|
-
var auditAction = (definition, options) => {
|
|
117
|
-
const issues = [];
|
|
118
|
-
const dataKeys = new Set(Object.keys(definition.data ?? {}));
|
|
119
|
-
const endpointNames = new Set(Object.keys(definition.endpoints ?? {}));
|
|
120
|
-
const steps = [];
|
|
121
|
-
const pushSteps = (list) => {
|
|
122
|
-
if (!Array.isArray(list)) return;
|
|
123
|
-
for (const step of list) {
|
|
124
|
-
if (!isRecord(step)) continue;
|
|
125
|
-
steps.push(step);
|
|
126
|
-
if (typeof step["call"] === "string") {
|
|
127
|
-
pushSteps(step["onSuccess"]);
|
|
128
|
-
pushSteps(step["onError"]);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
for (const trigger of definition.triggers ?? []) pushSteps(trigger.do);
|
|
133
|
-
for (const hook of Object.values(definition.lifecycle ?? {})) pushSteps(hook);
|
|
134
|
-
for (const step of steps) {
|
|
135
|
-
const call = step["call"];
|
|
136
|
-
if (typeof call === "string" && !endpointNames.has(call)) {
|
|
137
|
-
issues.push(`step calls endpoint "${call}" but endpoints has no "${call}"`);
|
|
138
|
-
}
|
|
139
|
-
for (const key of MUTATION_KEYS) {
|
|
140
|
-
const path = step[key];
|
|
141
|
-
if (typeof path === "string" && path.length > 0 && !dataKeys.has(firstSegment(path))) {
|
|
142
|
-
issues.push(`step "${key}: ${path}" writes a key with no default in data`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
const nav = navTargetOf(step);
|
|
146
|
-
if (nav !== void 0 && options?.catalog !== void 0) {
|
|
147
|
-
const entry = options.catalog.find((candidate) => candidate.id === nav.action);
|
|
148
|
-
if (entry === void 0 && nav.action !== definition.id) {
|
|
149
|
-
issues.push(`step pushes action "${nav.action}" which is not in the catalog`);
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
const properties = entry?.input?.["properties"];
|
|
153
|
-
if (nav.input !== void 0 && isRecord(properties)) {
|
|
154
|
-
for (const key of Object.keys(nav.input)) {
|
|
155
|
-
if (!(key in properties)) {
|
|
156
|
-
issues.push(`push to "${nav.action}" seeds input key "${key}" which is not in its input contract`);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
for (const [name, endpoint] of Object.entries(definition.endpoints ?? {})) {
|
|
163
|
-
for (const field of ["target", "errorTarget"]) {
|
|
164
|
-
const target = endpoint[field];
|
|
165
|
-
if (typeof target === "string" && target.length > 0 && !dataKeys.has(firstSegment(target))) {
|
|
166
|
-
issues.push(`endpoint "${name}" ${field} "${target}" has no default in data`);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (options?.channels !== void 0) {
|
|
171
|
-
const known = new Set(options.channels);
|
|
172
|
-
const usage = collectChannels(definition);
|
|
173
|
-
for (const channel of usage.listens) {
|
|
174
|
-
if (!known.has(channel) && !usage.emits.includes(channel)) {
|
|
175
|
-
issues.push(`trigger listens on channel "${channel}" which nothing is known to emit`);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
for (const channel of usage.emits) {
|
|
179
|
-
if (!known.has(channel) && !usage.listens.includes(channel)) {
|
|
180
|
-
issues.push(`step emits channel "${channel}" which nothing is known to listen on`);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (definition.layout !== void 0 && typeof definition.layout !== "string") {
|
|
185
|
-
const surface = collectInteractive(definition.layout);
|
|
186
|
-
for (const key of surface.boundKeys) {
|
|
187
|
-
if (!dataKeys.has(key)) {
|
|
188
|
-
issues.push(`layout binds "$.${key}" but data has no "${key}" default`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
for (const suspect of surface.suspectBindings) {
|
|
192
|
-
issues.push(
|
|
193
|
-
`layout binding "${suspect}\u2026" is malformed \u2014 the data root is "$." ("$.key"), and "$name." is only legal for a loop variable declared by an enclosing for/as`
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
const layoutRefs = new Set(surface.refs.map((entry) => entry.ref));
|
|
197
|
-
const triggerRefs = new Set(
|
|
198
|
-
(definition.triggers ?? []).map((trigger) => trigger.ref).filter((ref) => typeof ref === "string")
|
|
199
|
-
);
|
|
200
|
-
for (const ref of layoutRefs) {
|
|
201
|
-
if (!triggerRefs.has(ref)) {
|
|
202
|
-
issues.push(`layout ref "${ref}" has no trigger \u2014 dead chrome`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
for (const ref of triggerRefs) {
|
|
206
|
-
if (!layoutRefs.has(ref)) {
|
|
207
|
-
issues.push(`trigger listens on ref "${ref}" but no layout node carries it`);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return { ok: issues.length === 0, issues };
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
// src/reflect/grammar.ts
|
|
215
|
-
var gesturedKeys = (definition) => [
|
|
216
|
-
...new Set(
|
|
217
|
-
(definition.triggers ?? []).filter((trigger) => typeof trigger.event === "string" && trigger.event.startsWith("ui:")).flatMap((trigger) => mutationPaths(trigger.do)).map(rootOf)
|
|
218
|
-
)
|
|
219
|
-
];
|
|
220
|
-
var declaredKeys = (definition) => Object.keys(definition.input?.properties ?? {});
|
|
221
|
-
var loadedKeys = (definition) => {
|
|
222
|
-
const loaded = /* @__PURE__ */ new Set();
|
|
223
|
-
for (const endpoint of Object.values(definition.endpoints ?? {})) {
|
|
224
|
-
const spec = endpoint;
|
|
225
|
-
if (spec.target !== void 0) loaded.add(rootOf(spec.target));
|
|
226
|
-
if (spec.errorTarget !== void 0) loaded.add(rootOf(spec.errorTarget));
|
|
227
|
-
}
|
|
228
|
-
return [...loaded];
|
|
229
|
-
};
|
|
230
|
-
var lifecycleKeys = (definition) => [
|
|
231
|
-
...new Set(
|
|
232
|
-
Object.values(definition.lifecycle ?? {}).flatMap(mutationPaths).map(rootOf)
|
|
233
|
-
)
|
|
234
|
-
];
|
|
235
|
-
var mountCalls = (definition) => {
|
|
236
|
-
const names = /* @__PURE__ */ new Set();
|
|
237
|
-
const walk = (node) => {
|
|
238
|
-
if (Array.isArray(node)) {
|
|
239
|
-
for (const item of node) walk(item);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
if (node === null || typeof node !== "object") return;
|
|
243
|
-
const step = node;
|
|
244
|
-
if (typeof step["call"] === "string") names.add(step["call"]);
|
|
245
|
-
walk(step["onSuccess"]);
|
|
246
|
-
walk(step["onError"]);
|
|
247
|
-
};
|
|
248
|
-
walk(definition.lifecycle?.mount);
|
|
249
|
-
return names;
|
|
250
|
-
};
|
|
251
|
-
var requestKeys = (request) => {
|
|
252
|
-
const found = [];
|
|
253
|
-
const walk = (node) => {
|
|
254
|
-
if (typeof node === "string") {
|
|
255
|
-
if (node.startsWith("$.")) found.push(rootOf(node.slice(2)));
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
if (Array.isArray(node)) {
|
|
259
|
-
for (const item of node) walk(item);
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
if (node === null || typeof node !== "object") return;
|
|
263
|
-
for (const value of Object.values(node)) walk(value);
|
|
264
|
-
};
|
|
265
|
-
walk(request);
|
|
266
|
-
return found.filter((key) => key !== "");
|
|
267
|
-
};
|
|
268
|
-
var mountInputCache = /* @__PURE__ */ new WeakMap();
|
|
269
|
-
var mountInputKeys = (definition) => {
|
|
270
|
-
const cached = mountInputCache.get(definition);
|
|
271
|
-
if (cached !== void 0) return cached;
|
|
272
|
-
const called = mountCalls(definition);
|
|
273
|
-
const declared = new Set(declaredKeys(definition));
|
|
274
|
-
const keys = /* @__PURE__ */ new Set();
|
|
275
|
-
for (const [name, endpoint] of Object.entries(definition.endpoints ?? {})) {
|
|
276
|
-
if (!called.has(name)) continue;
|
|
277
|
-
for (const key of requestKeys(endpoint.request)) if (declared.has(key)) keys.add(key);
|
|
278
|
-
}
|
|
279
|
-
mountInputCache.set(definition, keys);
|
|
280
|
-
return keys;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
export { auditAction, collectChannels, composeAction, declaredKeys, gesturedKeys, isMutationStep, lifecycleKeys, loadedKeys, mountInputKeys };
|
|
284
|
-
//# sourceMappingURL=chunk-RQB4PRPV.js.map
|
|
285
|
-
//# sourceMappingURL=chunk-RQB4PRPV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/action/compose.ts","../src/action/grammar.ts","../src/action/audit.ts","../src/reflect/grammar.ts"],"names":[],"mappings":";;;;;AA2BA,IAAM,KAAA,GAAQ,CAAC,OAAA,EAAS,SAAA,EAAW,WAAW,QAAQ,CAAA;AAE/C,IAAM,aAAA,GAAgB,CAC3B,MAAA,EACA,SAAA,KACqB;AACrB,EAAA,IAAI,SAAA,CAAU,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AAGnC,EAAA,IAAI,SAAS,MAAA,CAAO,MAAA;AACpB,EAAA,KAAA,MAAW,QAAQ,SAAA,EAAW;AAC5B,IAAA,MAAM,OAAO,IAAA,CAAK,MAAA;AAClB,IAAA,IAAI,SAAS,MAAA,EAAW;AACxB,IAAA,IAAI,OAAO,SAAS,QAAA,EAAU;AAC5B,MAAA,MAAA,GAAS,IAAA;AACT,MAAA;AAAA,IACF;AACA,IAAA,MAAA,GAAS,SAAA,CAAU,MAAM,MAAA,KAAW,MAAA,GAAY,EAAC,GAAI,EAAE,IAAA,EAAM,MAAA,EAAsB,CAAA;AAAA,EACrF;AAGA,EAAA,MAAM,OAAgC,EAAC;AACvC,EAAA,KAAA,MAAW,IAAA,IAAQ,WAAW,MAAA,CAAO,MAAA,CAAO,MAAM,IAAA,CAAK,IAAA,IAAQ,EAAE,CAAA;AACjE,EAAA,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,MAAA,CAAO,IAAA,IAAQ,EAAE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MAAA,GAAS,WAAW,UAAU,CAAA;AACpC,EAAA,MAAM,QAAA,GAAW,IAAI,GAAA,CAAI,YAAA,CAAa,UAAU,CAAC,CAAA;AACjD,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAY;AAC7B,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,QAAQ,CAAA,IAAK,MAAA,CAAO,QAAQ,UAAA,CAAW,SAAA,IAAa,EAAE,CAAA,EAAG;AACzE,IAAA,IAAI,CAAC,MAAA,CAAO,GAAA,CAAI,IAAI,CAAA,EAAG;AACvB,IAAA,KAAA,MAAW,GAAA,IAAO,WAAA,CAAa,QAAA,CAAmC,OAAO,CAAA,EAAG,IAAI,QAAA,CAAS,GAAA,CAAI,GAAG,CAAA,EAAG,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA;AAAA,EACjH;AACA,EAAA,eAAA,CAAgB,GAAA,CAAI,YAAY,IAAI,CAAA;AACpC,EAAA,OAAO,IAAA;AACT","file":"chunk-RQB4PRPV.js","sourcesContent":["import { fillSlots } from '@layout';\nimport type { LayoutNode } from '@layout';\nimport type {\n ActionDefinition,\n ActionFragment,\n EndpointConfig,\n Step,\n TriggerConfig,\n} from './schemas';\n\n// ═══════════════════════════════════════════════════════════\n// composeAction — merge a concrete action with the fragments listed in a\n// push/replace `with`, producing the effective ActionDefinition to instantiate.\n// Composition, not inheritance: the action ALWAYS wins on conflict.\n//\n// - layout: each fragment WRAPS the layout so far — its `{ slot: 'body' }`\n// is filled with the action's own layout (innermost). Fragments\n// fold in array order, so the last listed is the outermost wrap.\n// (Wrapping fragments must use an inline layout, not a store id.)\n// - data: shallow-merge, action wins.\n// - triggers: concat — fragment triggers first, then the action's.\n// - endpoints: merge, action wins on a name clash.\n// - lifecycle: per-hook concat — fragment steps run before the action's.\n// - id/name/description/title/input: the action's (fragments have no say).\n// The result is a plain ActionDefinition.\n// ═══════════════════════════════════════════════════════════\n\nconst HOOKS = ['mount', 'unmount', 'suspend', 'resume'] as const;\n\nexport const composeAction = (\n action: ActionDefinition,\n fragments: ActionFragment[],\n): ActionDefinition => {\n if (fragments.length === 0) return action;\n\n // Layout — wrap the action's layout in each fragment's slot.\n let layout = action.layout;\n for (const frag of fragments) {\n const wrap = frag.layout;\n if (wrap === undefined) continue;\n if (typeof wrap === 'string') {\n layout = wrap; // stored-layout fragment: can't slot-fill, replaces\n continue;\n }\n layout = fillSlots(wrap, layout === undefined ? {} : { body: layout as LayoutNode });\n }\n\n // Data — fragments (in order), then the action on top.\n const data: Record<string, unknown> = {};\n for (const frag of fragments) Object.assign(data, frag.data ?? {});\n Object.assign(data, action.data ?? {});\n\n // Triggers — fragment triggers first, then the action's.\n const triggers: TriggerConfig[] = [\n ...fragments.flatMap((f) => f.triggers ?? []),\n ...(action.triggers ?? []),\n ];\n\n // Endpoints — fragments, then the action (action wins on a name clash).\n const endpoints: Record<string, EndpointConfig> = {};\n for (const frag of fragments) Object.assign(endpoints, frag.endpoints ?? {});\n Object.assign(endpoints, action.endpoints ?? {});\n\n // Lifecycle — per hook, fragment steps before the action's.\n const lifecycle: Record<string, Step[]> = {};\n for (const hook of HOOKS) {\n const steps: Step[] = [\n ...fragments.flatMap((f) => f.lifecycle?.[hook] ?? []),\n ...(action.lifecycle?.[hook] ?? []),\n ];\n if (steps.length > 0) lifecycle[hook] = steps;\n }\n\n return {\n id: action.id,\n ...(action.name === undefined ? {} : { name: action.name }),\n ...(action.description === undefined ? {} : { description: action.description }),\n ...(action.title === undefined ? {} : { title: action.title }),\n ...(action.input === undefined ? {} : { input: action.input }),\n ...(layout === undefined ? {} : { layout }),\n ...(Object.keys(data).length > 0 ? { data } : {}),\n ...(triggers.length > 0 ? { triggers } : {}),\n ...(Object.keys(endpoints).length > 0 ? { endpoints } : {}),\n ...(Object.keys(lifecycle).length > 0 ? { lifecycle } : {}),\n } as ActionDefinition;\n};\n","import { OPS } from './mutations/ops';\nimport type { Mutation, Step } from './schemas';\n\n// What a step list WRITES, derived from the op registry.\n//\n// Three places needed this and each kept its own copy of the op names: the\n// runtime (which steps are mutations), the audit (which data paths a definition\n// fills), and anything reflecting over a definition. `OPS` is already the single\n// source of truth for operations, so it is the source of truth here too — adding\n// an op stays a one-line change in ops/index.ts.\n\n// Every mutation op's key. Derived, so it cannot drift from the ops themselves.\nexport const MUTATION_KEYS: readonly string[] = [...new Set(OPS.map((op) => op.key))];\n\n// Each op's own discrimination. `push` and `pop` are the interesting ones: as a\n// string they name a data path (a mutation), as anything else they are the\n// navigation effect.\nconst MATCHERS = OPS.map((op) => op.match ?? ((step: Record<string, unknown>) => op.key in step));\n\nexport const isMutationStep = (step: Step): step is Mutation => MATCHERS.some((match) => match(step as unknown as Record<string, unknown>));\n\n// Every data path a step list writes, at any depth. `call` branches nest their\n// own steps, so one trigger can load and then set.\nexport const mutationPaths = (steps: unknown): string[] => {\n const found: string[] = [];\n const walk = (node: unknown): void => {\n if (Array.isArray(node)) {\n for (const item of node) walk(item);\n return;\n }\n if (node === null || typeof node !== 'object') return;\n const step = node as Record<string, unknown>;\n if (isMutationStep(step as unknown as Step)) {\n for (const key of MUTATION_KEYS) {\n const value = step[key];\n if (typeof value === 'string') found.push(value);\n }\n }\n walk(step['onSuccess']);\n walk(step['onError']);\n };\n walk(steps);\n return found;\n};\n\n// `openIssue.issue_id` and `openIssue` are one key: both point the card at an\n// issue. Every reading below compares at this level.\nexport const rootOf = (path: string): string => path.split('.')[0] ?? path;\n","import { collectInteractive } from '../agent/affordances';\nimport { MUTATION_KEYS } from './grammar';\nimport type { ActionDefinition } from './schemas';\n\n// ═══════════════════════════════════════════════════════════\n// auditAction — static analysis of an ActionDefinition's internal wiring.\n//\n// A definition can parse, mount, and render politely while being broken in\n// every way that matters: a table bound to a key no endpoint fills, a search\n// box whose trigger re-calls a load that never reads it, a ref with no\n// trigger (dead chrome), a push into an action that doesn't exist. None of\n// that is visible to a schema parse or a mount probe — it IS visible in the\n// artifact. This audits the definition deterministically: every claim is a\n// cross-reference inside the definition (plus an optional catalog), so there\n// are no heuristics and no false authority.\n//\n// Scope: SELF-CONTAINED definitions with an inline layout — generated\n// actions above all. Hand-authored actions that receive triggers from\n// fragments (`with: [...]`) or bind stored layouts will report issues that\n// composition would resolve; audit the COMPOSED definition instead, or skip.\n// ═══════════════════════════════════════════════════════════\n\nexport type AuditCatalogEntry = {\n id: string;\n // The action's openable-input contract (a JSON Schema). When it carries\n // `properties`, seeded push input keys are checked against them.\n input?: Record<string, unknown>;\n};\n\nexport type AuditOptions = {\n // Known pushable action ids. When given, every push/replace/resetTo\n // target must be one of them (or the definition's own id), with input\n // keys from its contract.\n catalog?: ReadonlyArray<AuditCatalogEntry>;\n // Known message channels (derive them from the registered definitions —\n // see collectChannels). When given, a `message:` listen must name a known\n // channel or one this definition emits itself; an `emit` must name a known\n // channel or one this definition listens on. Catches the silent\n // never-fires class (\"tasks:changed\" vs \"tasks-changed\").\n channels?: ReadonlyArray<string>;\n};\n\nexport type AuditResult = { ok: boolean; issues: string[] };\n\n// The channels a definition talks on — every `message:` trigger (listens)\n// and every `emit` step (emits), nested steps included. Walk a whole\n// registry's definitions to derive the app's live channel vocabulary.\nexport type ChannelUsage = { emits: string[]; listens: string[] };\n\nexport const collectChannels = (definition: ActionDefinition): ChannelUsage => {\n const emits = new Set<string>();\n const listens = new Set<string>();\n\n const walkSteps = (list: unknown): void => {\n if (!Array.isArray(list)) return;\n for (const step of list) {\n if (!isRecord(step)) continue;\n const emit = step['emit'];\n if (isRecord(emit) && typeof emit['channel'] === 'string') emits.add(emit['channel']);\n if (typeof step['call'] === 'string') {\n walkSteps(step['onSuccess']);\n walkSteps(step['onError']);\n }\n }\n };\n for (const trigger of definition.triggers ?? []) {\n if (typeof trigger.message === 'string') listens.add(trigger.message);\n walkSteps(trigger.do);\n }\n for (const hook of Object.values(definition.lifecycle ?? {})) walkSteps(hook);\n\n return { emits: [...emits].sort(), listens: [...listens].sort() };\n};\n\n// Mutation ops whose value is a data PATH (see action/mutations/ops). The\nconst firstSegment = (path: string): string => {\n const segment = path.split('.')[0];\n return segment === undefined || segment.length === 0 ? path : segment;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\ntype NavTarget = { action: string; input?: Record<string, unknown> };\n\nconst navTargetOf = (step: Record<string, unknown>): NavTarget | undefined => {\n for (const key of ['push', 'replace', 'resetTo']) {\n const value = step[key];\n if (isRecord(value) && typeof value['action'] === 'string') {\n const input = value['input'];\n return { action: value['action'], ...(isRecord(input) ? { input } : {}) };\n }\n }\n return undefined;\n};\n\nexport const auditAction = (definition: ActionDefinition, options?: AuditOptions): AuditResult => {\n const issues: string[] = [];\n const dataKeys = new Set(Object.keys(definition.data ?? {}));\n const endpointNames = new Set(Object.keys(definition.endpoints ?? {}));\n\n // ── collect every step (structurally — nested onSuccess/onError included),\n // wherever steps live: triggers and lifecycle hooks ──\n const steps: Record<string, unknown>[] = [];\n const pushSteps = (list: unknown): void => {\n if (!Array.isArray(list)) return;\n for (const step of list) {\n if (!isRecord(step)) continue;\n steps.push(step);\n if (typeof step['call'] === 'string') {\n pushSteps(step['onSuccess']);\n pushSteps(step['onError']);\n }\n }\n };\n for (const trigger of definition.triggers ?? []) pushSteps(trigger.do);\n for (const hook of Object.values(definition.lifecycle ?? {})) pushSteps(hook);\n\n // ── steps: calls name real endpoints; mutations write declared keys;\n // navigation targets exist in the catalog with legal input keys ──\n for (const step of steps) {\n const call = step['call'];\n if (typeof call === 'string' && !endpointNames.has(call)) {\n issues.push(`step calls endpoint \"${call}\" but endpoints has no \"${call}\"`);\n }\n\n for (const key of MUTATION_KEYS) {\n const path = step[key];\n if (typeof path === 'string' && path.length > 0 && !dataKeys.has(firstSegment(path))) {\n issues.push(`step \"${key}: ${path}\" writes a key with no default in data`);\n }\n }\n\n const nav = navTargetOf(step);\n if (nav !== undefined && options?.catalog !== undefined) {\n const entry = options.catalog.find((candidate) => candidate.id === nav.action);\n if (entry === undefined && nav.action !== definition.id) {\n issues.push(`step pushes action \"${nav.action}\" which is not in the catalog`);\n continue;\n }\n const properties = entry?.input?.['properties'];\n if (nav.input !== undefined && isRecord(properties)) {\n for (const key of Object.keys(nav.input)) {\n if (!(key in properties)) {\n issues.push(`push to \"${nav.action}\" seeds input key \"${key}\" which is not in its input contract`);\n }\n }\n }\n }\n }\n\n // ── endpoints: targets land on declared keys ──\n for (const [name, endpoint] of Object.entries(definition.endpoints ?? {})) {\n for (const field of ['target', 'errorTarget'] as const) {\n const target = endpoint[field];\n if (typeof target === 'string' && target.length > 0 && !dataKeys.has(firstSegment(target))) {\n issues.push(`endpoint \"${name}\" ${field} \"${target}\" has no default in data`);\n }\n }\n }\n\n // ── message channels (when the app's vocabulary is provided) ──\n if (options?.channels !== undefined) {\n const known = new Set(options.channels);\n const usage = collectChannels(definition);\n for (const channel of usage.listens) {\n if (!known.has(channel) && !usage.emits.includes(channel)) {\n issues.push(`trigger listens on channel \"${channel}\" which nothing is known to emit`);\n }\n }\n for (const channel of usage.emits) {\n if (!known.has(channel) && !usage.listens.includes(channel)) {\n issues.push(`step emits channel \"${channel}\" which nothing is known to listen on`);\n }\n }\n }\n\n // ── layout ↔ data ↔ triggers (inline layouts only) ──\n if (definition.layout !== undefined && typeof definition.layout !== 'string') {\n const surface = collectInteractive(definition.layout);\n\n for (const key of surface.boundKeys) {\n if (!dataKeys.has(key)) {\n issues.push(`layout binds \"$.${key}\" but data has no \"${key}\" default`);\n }\n }\n\n for (const suspect of surface.suspectBindings) {\n issues.push(\n `layout binding \"${suspect}…\" is malformed — the data root is \"$.\" (\"$.key\"), and \"$name.\" is only legal for a loop variable declared by an enclosing for/as`,\n );\n }\n\n const layoutRefs = new Set(surface.refs.map((entry) => entry.ref));\n const triggerRefs = new Set(\n (definition.triggers ?? [])\n .map((trigger) => trigger.ref)\n .filter((ref): ref is string => typeof ref === 'string'),\n );\n for (const ref of layoutRefs) {\n if (!triggerRefs.has(ref)) {\n issues.push(`layout ref \"${ref}\" has no trigger — dead chrome`);\n }\n }\n for (const ref of triggerRefs) {\n if (!layoutRefs.has(ref)) {\n issues.push(`trigger listens on ref \"${ref}\" but no layout node carries it`);\n }\n }\n }\n\n return { ok: issues.length === 0, issues };\n};\n","import type { ActionDefinition } from '@action';\nimport { mutationPaths, rootOf } from '@action/grammar';\n\n// What an action does with its DATA KEYS, read off its own definition.\n//\n// Four questions, each a pure function of the artifact and each with more than\n// one consumer: an audit asking whether declared state is reachable, an agent\n// asking whether a change was a person or a re-read, a devtools pane asking what\n// fills a field. Every one of them was being re-derived outside nova, which is\n// how a hand-copied list of mutation ops ended up in an application.\n\n// What a FINGER can write: every data path a `ui:` trigger sets.\nexport const gesturedKeys = (definition: ActionDefinition): readonly string[] => [\n ...new Set(\n (definition.triggers ?? [])\n .filter((trigger) => typeof trigger.event === 'string' && trigger.event.startsWith('ui:'))\n .flatMap((trigger) => mutationPaths(trigger.do))\n .map(rootOf),\n ),\n];\n\n// What an OPENER may set: the declared input contract.\nexport const declaredKeys = (definition: ActionDefinition): readonly string[] =>\n Object.keys((definition.input as { properties?: Record<string, unknown> } | undefined)?.properties ?? {});\n\n// What the DATABASE writes: every endpoint's landing place.\nexport const loadedKeys = (definition: ActionDefinition): readonly string[] => {\n const loaded = new Set<string>();\n for (const endpoint of Object.values(definition.endpoints ?? {})) {\n const spec = endpoint as { target?: string; errorTarget?: string };\n if (spec.target !== undefined) loaded.add(rootOf(spec.target));\n if (spec.errorTarget !== undefined) loaded.add(rootOf(spec.errorTarget));\n }\n return [...loaded];\n};\n\n// What a surface writes to ITSELF when it opens or resumes: a loading flag\n// clearing, a working flag resetting.\nexport const lifecycleKeys = (definition: ActionDefinition): readonly string[] => [\n ...new Set(\n Object.values((definition.lifecycle ?? {}) as Record<string, unknown>)\n .flatMap(mutationPaths)\n .map(rootOf),\n ),\n];\n\n// Endpoint names a `mount` step calls, at any depth.\nconst mountCalls = (definition: ActionDefinition): Set<string> => {\n const names = new Set<string>();\n const walk = (node: unknown): void => {\n if (Array.isArray(node)) {\n for (const item of node) walk(item);\n return;\n }\n if (node === null || typeof node !== 'object') return;\n const step = node as Record<string, unknown>;\n if (typeof step['call'] === 'string') names.add(step['call']);\n walk(step['onSuccess']);\n walk(step['onError']);\n };\n walk((definition.lifecycle as { mount?: unknown } | undefined)?.mount);\n return names;\n};\n\n// Every `$.<key>` an endpoint's request reads. `{ id: { $ref: '$.issueId' } }`\n// and the bare form `'$.issueId'` both count.\nconst requestKeys = (request: unknown): string[] => {\n const found: string[] = [];\n const walk = (node: unknown): void => {\n if (typeof node === 'string') {\n if (node.startsWith('$.')) found.push(rootOf(node.slice(2)));\n return;\n }\n if (Array.isArray(node)) {\n for (const item of node) walk(item);\n return;\n }\n if (node === null || typeof node !== 'object') return;\n for (const value of Object.values(node as Record<string, unknown>)) walk(value);\n };\n walk(request);\n return found.filter((key) => key !== '');\n};\n\nconst mountInputCache = new WeakMap<ActionDefinition, ReadonlySet<string>>();\n\n// Input keys the surface consumes WHEN IT OPENS: an id its own mount-time load\n// sends. Writing one into a live instance leaves the previous record's data on\n// screen, so a caller that wants to re-aim must re-mount instead.\n//\n// Cached per definition object: definitions are read on every telemetry event,\n// and a bundle sync replaces them wholesale, so identity is the right key.\nexport const mountInputKeys = (definition: ActionDefinition): ReadonlySet<string> => {\n const cached = mountInputCache.get(definition);\n if (cached !== undefined) return cached;\n const called = mountCalls(definition);\n const declared = new Set(declaredKeys(definition));\n const keys = new Set<string>();\n for (const [name, endpoint] of Object.entries(definition.endpoints ?? {})) {\n if (!called.has(name)) continue;\n for (const key of requestKeys((endpoint as { request?: unknown }).request)) if (declared.has(key)) keys.add(key);\n }\n mountInputCache.set(definition, keys);\n return keys;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/shared/bindings/scope.ts","../src/shared/bindings/resolve.ts","../src/layout/guards.ts","../src/layout/renderer.ts","../src/layout/compose.ts","../src/layout/adapter.ts","../src/layout/store.ts"],"names":["segments"],"mappings":";;;;;;;;AAEO,IA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GAAY,EAAC,GAAI,EAAE,UAAU,gBAAA;AAAiB,OACzE;AAAA,IACF;AACA,IAAA,IAAI,iBAAA,CAAkB,MAAM,CAAA,EAAG;AAC7B,MAAA,OAAO;AAAA,QACL,GAAG,MAAA;AAAA,QACH,IAAA,EAAM,iBAAA,CAAkB,MAAA,CAAO,IAAI,CAAA;AAAA,QACnC,GAAI,MAAA,CAAO,IAAA,KAAS,MAAA,GAAY,EAAC,GAAI,EAAE,IAAA,EAAM,iBAAA,CAAkB,MAAA,CAAO,IAAI,CAAA;AAAE,OAC9E;AAAA,IACF;AACA,IAAA,IAAI,UAAA,CAAW,MAAM,CAAA,EAAG;AACtB,MAAA,OAAO;AAAA,QACL,GAAG,MAAA;AAAA,QACH,EAAA,EAAI,iBAAA,CAAkB,MAAA,CAAO,EAAE;AAAA,OACjC;AAAA,IACF;AACA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AAEA,EAAA,OAAO,EAAE,GAAA,EAAK,GAAA,EAAK,MAAA,EAAQ,MAAA,EAAQ,MAAM,iBAAA,EAAkB;AAC7D","file":"chunk-V32EVEVM.js","sourcesContent":["import type { Scope, ScopeChain } from './types';\n\nexport const createScopeChain = (data: Scope): ScopeChain => [data];\n\nexport const pushScope = (chain: ScopeChain, scope: Scope): ScopeChain => [scope, ...chain];\n","import { evaluateSafe } from '@niscorp/prism';\nimport { hasKey, isArray, isObject } from '../common';\nimport { getPath } from './paths';\nimport type { ScopeChain } from './types';\n\n// ═══════════════════════════════════════════════════════════\n// Unified value resolver.\n//\n// One function — `resolve` — handles every binding site uniformly.\n//\n// String semantics:\n// 1. \"{{ expr }}\" (sole expression) → raw value of expr (type preserved)\n// 2. \"...{{expr}}...\" → interpolated string\n// 3. \"$.x\" or \"$ident...\" → raw value of path (type preserved)\n// 4. anything else → literal string\n//\n// Array → mapped recursively.\n// Object → walked recursively, OR treated as an `$if` directive.\n// Primitives → returned as-is.\n//\n// Path expressions resolve via `resolvePath`, which uses the ScopeChain\n// (innermost first). An optional `extras` map injects keyed scopes for\n// templates (e.g. `{ '@error': errObj }`); longest-prefix match wins.\n// ═══════════════════════════════════════════════════════════\n\nconst TEMPLATE_REGEX = /\\{\\{\\s*([^}]+?)\\s*\\}\\}/g;\nconst SOLE_TEMPLATE_REGEX = /^\\{\\{\\s*([^}]+?)\\s*\\}\\}$/;\nconst BARE_PATH_REGEX = /^\\$(\\.|[A-Za-z_]|$)/;\n\nexport type ExtraScopes = Record<string, unknown>;\n\nconst matchExtra = (expression: string, extras: ExtraScopes): string | undefined => {\n let matched: string | undefined;\n for (const key of Object.keys(extras)) {\n if (expression === key || expression.startsWith(`${key}.`)) {\n if (matched === undefined || key.length > matched.length) matched = key;\n }\n }\n return matched;\n};\n\nconst resolveExtraExpression = (\n expression: string,\n matchedKey: string,\n extras: ExtraScopes,\n): unknown => {\n const root = extras[matchedKey];\n if (expression === matchedKey) return root;\n const rest = expression.slice(matchedKey.length + 1);\n if (rest.length === 0) return root;\n return getPath(root, rest);\n};\n\nconst walkFromScopeHead = (head: unknown, restSegments: readonly string[]): unknown => {\n if (restSegments.length === 0) return head;\n return getPath(head, restSegments.join('.'));\n};\n\nexport const resolvePath = (\n path: string,\n chain: ScopeChain,\n extras: ExtraScopes = {},\n): unknown => {\n const extraKey = matchExtra(path, extras);\n if (extraKey !== undefined) return resolveExtraExpression(path, extraKey, extras);\n\n if (!path.startsWith('$')) return undefined;\n if (path === '$') return chain[0];\n\n const afterDollar = path.slice(1);\n\n if (afterDollar.startsWith('.')) {\n const rest = afterDollar.slice(1);\n if (rest.length === 0) return chain[0];\n const segments = rest.split('.');\n const head = segments[0];\n if (head === undefined) return undefined;\n for (const scope of chain) {\n if (hasKey(scope, head)) {\n return walkFromScopeHead(scope[head], segments.slice(1));\n }\n }\n return undefined;\n }\n\n const segments = afterDollar.split('.');\n const varName = segments[0];\n if (varName === undefined || varName.length === 0) return undefined;\n for (const scope of chain) {\n if (hasKey(scope, varName)) {\n return walkFromScopeHead(scope[varName], segments.slice(1));\n }\n }\n return undefined;\n};\n\nconst stringify = (value: unknown): string => {\n if (value === null || value === undefined) return '';\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n try {\n return JSON.stringify(value);\n } catch {\n return '';\n }\n};\n\nconst isTruthy = (value: unknown): boolean => {\n if (value === null || value === undefined) return false;\n if (value === false) return false;\n if (value === 0) return false;\n if (value === '') return false;\n if (isArray(value) && value.length === 0) return false;\n return true;\n};\n\n// Directives — evaluated objects keyed by an operator (`$if`, `$eq`, …). Each\n// resolves its operands and returns a value. Add an operator here and it works\n// everywhere bindings are resolved; later operators (`$gte`, `$and`, …) slot in\n// the same way.\ntype Directive = (node: Record<string, unknown>, chain: ScopeChain, extras: ExtraScopes) => unknown;\n\nconst DIRECTIVES: Record<string, Directive> = {\n $if: (node, chain, extras) => {\n if (isTruthy(resolve(node.$if, chain, extras))) return resolve(node.$then, chain, extras);\n if (hasKey(node, '$else')) return resolve(node.$else, chain, extras);\n return undefined;\n },\n $eq: (node, chain, extras) => {\n const args = isArray(node.$eq) ? node.$eq : [];\n return resolve(args[0], chain, extras) === resolve(args[1], chain, extras);\n },\n // True when the operand path resolves to a present value. The structural\n // counterpart to `$eq`: discriminate a union by which key a branch carries\n // (`{ $exists: \"$.shape.component\" }`) rather than a shared tag's value.\n $exists: (node, chain, extras) => resolve(node.$exists, chain, extras) !== undefined,\n // Read an array element by a (dynamic) index: `{ $at: [\"$.results\", \"$.i\"] }`.\n // An optional third arg pulls one field off the element: `[\"$.results\", \"$.i\",\n // \"id\"]`. Returns undefined when the array/index doesn't resolve.\n $at: (node, chain, extras) => {\n const args = isArray(node.$at) ? node.$at : [];\n const arr = resolve(args[0], chain, extras);\n const index = Number(resolve(args[1], chain, extras));\n if (!isArray(arr) || Number.isNaN(index)) return undefined;\n const element = arr[index];\n const field = args[2];\n return field !== undefined && isObject(element) ? element[String(field)] : element;\n },\n // THE WHOLE TRANSFORM GRAMMAR, BEHIND ONE EXPLICIT DOOR. The directives\n // above stay the small binding set; a value that needs a real transformation\n // — a join, a projection, a group — says so out loud: `{ $prism: <node> }`\n // evaluates the node with prism against the action's ROOT data. One grammar,\n // one evaluator, nothing ambient — a prism-shaped object OUTSIDE this\n // wrapper stays what it always was, a plain object walked for strings.\n //\n // The quiet failure this replaces was worse than a crash: an unrecognised\n // op-shaped value passed through `resolve` as structure, landed in data, and\n // rendered as garbage three screens later. Inside the wrapper, a bad node\n // resolves to undefined — absent, not wrong.\n $prism: (node, chain) => {\n const result = evaluateSafe(node.$prism as never, (chain[0] ?? {}) as never);\n return result.ok ? result.data : undefined;\n },\n};\n\nconst directiveOf = (value: Record<string, unknown>): Directive | undefined => {\n for (const key of Object.keys(value)) {\n const directive = DIRECTIVES[key];\n if (directive !== undefined) return directive;\n }\n return undefined;\n};\n\nconst resolveString = (value: string, chain: ScopeChain, extras: ExtraScopes): unknown => {\n const sole = value.match(SOLE_TEMPLATE_REGEX);\n if (sole !== null) {\n const expr = sole[1];\n if (expr === undefined) return value;\n return resolvePath(expr.trim(), chain, extras);\n }\n\n if (value.includes('{{')) {\n return value.replace(TEMPLATE_REGEX, (_match: string, expression: string): string => {\n const resolved = resolvePath(expression.trim(), chain, extras);\n return stringify(resolved);\n });\n }\n\n if (BARE_PATH_REGEX.test(value)) {\n return resolvePath(value, chain, extras);\n }\n\n if (matchExtra(value, extras) !== undefined) {\n return resolvePath(value, chain, extras);\n }\n\n return value;\n};\n\nexport const resolve = (\n value: unknown,\n chain: ScopeChain,\n extras: ExtraScopes = {},\n): unknown => {\n if (typeof value === 'string') return resolveString(value, chain, extras);\n if (isArray(value)) return value.map((entry) => resolve(entry, chain, extras));\n if (isObject(value)) {\n const directive = directiveOf(value);\n if (directive !== undefined) return directive(value, chain, extras);\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n out[key] = resolve(value[key], chain, extras);\n }\n return out;\n }\n return value;\n};\n","import { hasKey, isObject } from '../shared/common';\nimport type {\n ComponentNode,\n ConditionalNode,\n LayoutNode,\n LayoutPrimitive,\n LayoutRefNode,\n LoopNode,\n SlotNode,\n} from './schemas';\n\nexport const isLayoutPrimitive = (value: unknown): value is LayoutPrimitive =>\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean';\n\nexport const isComponentNode = (value: unknown): value is ComponentNode =>\n hasKey(value, 'component') && typeof value['component'] === 'string';\n\nexport const isConditionalNode = (value: unknown): value is ConditionalNode =>\n hasKey(value, 'if') && hasKey(value, 'then') && !hasKey(value, 'for');\n\nexport const isLoopNode = (value: unknown): value is LoopNode =>\n hasKey(value, 'for') && hasKey(value, 'as') && hasKey(value, 'do');\n\nexport const isLayoutRefNode = (value: unknown): value is LayoutRefNode =>\n isObject(value) &&\n hasKey(value, 'ref') &&\n typeof value['ref'] === 'string' &&\n !hasKey(value, 'component') &&\n Object.keys(value).length === 1;\n\nexport const isSlotNode = (value: unknown): value is SlotNode =>\n isObject(value) &&\n hasKey(value, 'slot') &&\n typeof value['slot'] === 'string' &&\n Object.keys(value).length === 1;\n\nexport const isLayoutNode = (value: unknown): value is LayoutNode =>\n isLayoutPrimitive(value) ||\n Array.isArray(value) ||\n isComponentNode(value) ||\n isConditionalNode(value) ||\n isLoopNode(value) ||\n isLayoutRefNode(value) ||\n isSlotNode(value);\n","import { isArray } from '../shared/common';\nimport {\n ComponentNotFoundError,\n LayoutRefNotFoundError,\n NovaError,\n RenderError,\n} from '../shared/errors';\nimport { createScopeChain, getPath, pushScope, resolve } from '../shared/bindings';\nimport type { ScopeChain } from '../shared/bindings';\nimport { isBinding } from '../i18n/phrases';\nimport { passFor, swap, walkValue } from '../i18n/swap';\nimport type { Pass } from '../i18n/swap';\nimport {\n isComponentNode,\n isConditionalNode,\n isLayoutPrimitive,\n isLayoutRefNode,\n isLoopNode,\n isSlotNode,\n} from './guards';\nimport type { ComponentNode, LayoutNode } from './schemas';\nimport type {\n DataStoreView,\n ModelBindingDescriptor,\n RenderContext,\n RenderErrorNode,\n RenderNode,\n RenderOnError,\n} from './types';\n\n// ═══════════════════════════════════════════════════════════\n// Renderer — converts a LayoutNode tree into a framework-agnostic\n// RenderNode[] tree. Renders children in try/catch boundaries so a\n// single broken subtree does not poison siblings, unless strict mode\n// is enabled. All errors flow through the ctx.onError telemetry hook.\n// ═══════════════════════════════════════════════════════════\n\nconst noopOnError: RenderOnError = (_error: NovaError): void => {\n // default — errors silently dropped if no handler provided\n};\n\ntype InternalRenderContext = {\n store: RenderContext['store'];\n registry: RenderContext['registry'];\n strict: boolean;\n onError: RenderOnError;\n scopePaths: string[];\n // Undefined when the host named no book and no keys — the whole language\n // apparatus is then absent rather than idling, and a `{ phrase, slots }`\n // object passes through as the object it is.\n pass: Pass | undefined;\n // Where a miss was found, coarse: the chain of component names above it.\n // Only maintained while a pass is active, since nothing else reads it.\n where: string;\n};\n\nconst textNode = (value: string): RenderNode => ({ type: 'text', value });\n\nconst fragment = (children: RenderNode[]): RenderNode => ({ type: 'fragment', children });\n\nconst errorNode = (\n error: NovaError,\n nodeRef: string | undefined,\n): RenderErrorNode => ({\n type: 'error',\n code: error.code,\n message: error.message,\n ...(nodeRef === undefined ? {} : { nodeRef }),\n});\n\nconst toRenderError = (err: unknown): NovaError => {\n if (err instanceof NovaError) return err;\n const message = err instanceof Error ? err.message : String(err);\n return new RenderError(message, {}, { cause: err });\n};\n\n// Resolve a `$.x.y` or `$loopVar.y` binding to an absolute data path\n// (used to construct stable model binding descriptors inside loops).\nconst resolveDataPath = (\n binding: string,\n scopePaths: string[],\n): string | undefined => {\n if (!binding.startsWith('$')) return undefined;\n const after = binding.slice(1);\n if (after.startsWith('.')) return after.slice(1);\n const segments = after.split('.');\n const head = segments[0];\n if (head === undefined || head.length === 0) return undefined;\n for (let i = scopePaths.length - 1; i >= 0; i -= 1) {\n const entry = scopePaths[i];\n if (entry === undefined) continue;\n const eq = entry.indexOf('=');\n if (eq < 0) continue;\n const key = entry.slice(0, eq);\n if (key !== head) continue;\n const rooted = entry.slice(eq + 1);\n const rest = segments.slice(1).join('.');\n if (rest.length === 0) return rooted;\n return `${rooted}.${rest}`;\n }\n return undefined;\n};\n\nconst makeAutoRef = (componentName: string, path: string): string =>\n `auto-${componentName}-${path}`;\n\nconst renderNode = (\n node: LayoutNode,\n chain: ScopeChain,\n ctx: InternalRenderContext,\n): RenderNode[] => {\n if (node === null) return [textNode('')];\n if (typeof node === 'string') {\n const resolved = resolve(node, chain);\n if (resolved === undefined || resolved === null) return [textNode('')];\n const value = String(resolved);\n // A LITERAL text child is prose; a BOUND one is data wearing a text\n // position, and offering it to the book is how a member called \"Pass\" gets\n // renamed. Nothing but the renderer can tell those apart — by the time a\n // tree exists both are the same plain string — which is why this rule\n // could not be written in `translateRenderTree` and can be written here.\n if (ctx.pass === undefined || !ctx.pass.text || isBinding(node)) return [textNode(value)];\n return [textNode(swap(value, `${ctx.where}#text`, ctx.pass))];\n }\n if (isLayoutPrimitive(node)) {\n return [textNode(String(node))];\n }\n if (isArray(node)) {\n const children = renderChildArray(node, chain, ctx);\n return [fragment(children)];\n }\n if (isLayoutRefNode(node)) {\n const target = ctx.store.get(node.ref);\n if (target === undefined) {\n throw new LayoutRefNotFoundError(`Layout ref not found: ${node.ref}`, { ref: node.ref });\n }\n return renderNode(target, chain, ctx);\n }\n if (isSlotNode(node)) {\n // A slot is filled at fragment-merge time (fillSlots). One that survives to\n // render was never filled — render nothing.\n return [];\n }\n if (isConditionalNode(node)) {\n const condition = resolve(node.if, chain);\n const truthy =\n condition !== undefined &&\n condition !== null &&\n condition !== false &&\n condition !== 0 &&\n condition !== '';\n const branchTruthy = isArray(condition) ? condition.length > 0 : truthy;\n if (branchTruthy) return renderNode(node.then, chain, ctx);\n if (node.else !== undefined) return renderNode(node.else, chain, ctx);\n return [];\n }\n if (isLoopNode(node)) {\n const items = resolve(node.for, chain);\n if (!isArray(items)) return [];\n const loopBasePath = typeof node.for === 'string'\n ? resolveDataPath(node.for, ctx.scopePaths)\n : undefined;\n const out: RenderNode[] = [];\n items.forEach((item, index) => {\n // Each iteration binds three reserved loop vars: the element (`$<as>`),\n // its position (`$index`), and the array itself (`$items`). `$items`\n // lets a control inside the loop edit the whole list — remove or reorder\n // an element — not just its own value. Both `index` and `items` are\n // reserved names; an `as` of `'index'` or `'items'` would shadow them.\n const innerChain = pushScope(chain, { [node.as]: item, index, items });\n // `$items` resolves to a *writable* path (so `model: \"$items\"` works) only\n // when the loop's source is itself a resolvable path; a literal-array loop\n // exposes the value but stays read-only, exactly as `$<as>` does.\n const nextScopePaths =\n loopBasePath === undefined\n ? ctx.scopePaths\n : [...ctx.scopePaths, `${node.as}=${loopBasePath}.${index}`, `items=${loopBasePath}`];\n const innerCtx: InternalRenderContext = { ...ctx, scopePaths: nextScopePaths };\n // Stamp a stable React-identity key on each item's output: the value at\n // `node.key` (e.g. the row id), or the index when no key path is given.\n // This is what lets looped rows share a `ref` (the trigger target) without\n // colliding as React keys. `withKey` (in render-tree) prefers it over ref.\n const idKey = node.key !== undefined ? getPath(item, node.key) : index;\n const rendered = safeRenderSingle(node.do, innerChain, innerCtx, undefined);\n rendered.forEach((rn, sub) => {\n out.push({ ...rn, key: rendered.length === 1 ? String(idKey) : `${String(idKey)}:${sub}` });\n });\n });\n return [fragment(out)];\n }\n if (isComponentNode(node)) {\n return [renderComponent(node, chain, ctx)];\n }\n return [];\n};\n\nconst renderComponent = (\n node: ComponentNode,\n chain: ScopeChain,\n ctx: InternalRenderContext,\n): RenderNode => {\n if (!ctx.registry.has(node.component)) {\n throw new ComponentNotFoundError(\n `Component not found in registry: ${node.component}`,\n { name: node.component },\n );\n }\n // THE ONE PLACE A PROP BECOMES A WORD ON A SCREEN. The swap belongs here\n // rather than in a later walk over the finished tree: the value is already\n // in hand, so translating it costs one lookup instead of a second traversal\n // of everything that was just built.\n //\n // Unlike a text child, a BOUND prop is translated — that is the whole\n // `_display` mechanism, where a query manufactures a closed-set word and a\n // read puts it on the screen. What protects data here is the KEY: `label` is\n // prose, `name` is not, and no value ever votes on the question.\n const pass = ctx.pass;\n const at = pass === undefined ? '' : `${ctx.where}/${node.component}`;\n const props: Record<string, unknown> = Object.fromEntries(\n Object.entries(node.props ?? {}).map(([k, v]) => {\n const resolved = resolve(v, chain);\n if (pass === undefined) return [k, resolved];\n return [k, walkValue(resolved, pass.isProse(k), `${at}.${k}`, pass)];\n }),\n );\n const children = renderChildren(node.children, chain, pass === undefined ? ctx : { ...ctx, where: at });\n\n let model: ModelBindingDescriptor | undefined;\n if (node.model !== undefined) {\n const resolvedPath = resolveDataPath(node.model, ctx.scopePaths);\n if (resolvedPath !== undefined) {\n const ref = node.ref ?? makeAutoRef(node.component, resolvedPath);\n model = { path: resolvedPath, ref };\n // Two-way binding: if the component doesn't already have an explicit\n // `value` prop, auto-derive it from the model expression so the\n // displayed value tracks the data store. Without this, controlled\n // inputs always show their initial value because nothing updates the\n // `value` prop on re-render.\n if (!('value' in props)) {\n props['value'] = resolve(node.model, chain);\n }\n }\n }\n\n const component: RenderNode = {\n type: 'component',\n name: node.component,\n props,\n children,\n ...(node.ref === undefined ? {} : { ref: node.ref }),\n ...(model === undefined ? {} : { model }),\n };\n return component;\n};\n\nconst safeRenderSingle = (\n node: LayoutNode,\n chain: ScopeChain,\n ctx: InternalRenderContext,\n nodeRef: string | undefined,\n): RenderNode[] => {\n try {\n return renderNode(node, chain, ctx);\n } catch (err) {\n const novaError = toRenderError(err);\n if (ctx.strict) throw novaError;\n ctx.onError(novaError);\n return [errorNode(novaError, nodeRef)];\n }\n};\n\nconst renderChildArray = (\n nodes: LayoutNode[],\n chain: ScopeChain,\n ctx: InternalRenderContext,\n): RenderNode[] => {\n const out: RenderNode[] = [];\n for (const child of nodes) out.push(...safeRenderSingle(child, chain, ctx, undefined));\n return out;\n};\n\nconst renderChildren = (\n children: LayoutNode | LayoutNode[] | undefined,\n chain: ScopeChain,\n ctx: InternalRenderContext,\n): RenderNode[] => {\n if (children === undefined) return [];\n if (isArray(children)) return renderChildArray(children, chain, ctx);\n return safeRenderSingle(children, chain, ctx, undefined);\n};\n\nconst toInternal = (ctx: RenderContext): InternalRenderContext => ({\n store: ctx.store,\n registry: ctx.registry,\n strict: ctx.strict ?? false,\n onError: ctx.onError ?? noopOnError,\n scopePaths: [],\n // Built once per render call. The matcher compiles a Set and a suffix list,\n // and doing that per node would make the cheapest branch the expensive one.\n pass: passFor({\n ...(ctx.phrases === undefined ? {} : { phrases: ctx.phrases }),\n ...(ctx.phraseKeys === undefined ? {} : { keys: ctx.phraseKeys }),\n ...(ctx.onPhraseMiss === undefined ? {} : { onMiss: ctx.onPhraseMiss }),\n }),\n where: '',\n});\n\nexport const renderLayout = (\n node: LayoutNode,\n data: Record<string, unknown>,\n ctx: RenderContext,\n): RenderNode[] => {\n const internal = toInternal(ctx);\n return safeRenderSingle(node, createScopeChain(data), internal, undefined);\n};\n\n// Object-form alias for renderLayout. Same semantics, named parameters —\n// so the caller doesn't have to remember the positional order of\n// (layout, data, ctx) and so `data` can be omitted when the layout has\n// no resolvables.\nexport type RenderOptions = {\n layout: LayoutNode;\n data?: Record<string, unknown>;\n store: RenderContext['store'];\n registry: RenderContext['registry'];\n strict?: boolean;\n onError?: RenderOnError;\n phrases?: RenderContext['phrases'];\n phraseKeys?: RenderContext['phraseKeys'];\n onPhraseMiss?: RenderContext['onPhraseMiss'];\n};\n\nexport const render = (options: RenderOptions): RenderNode[] =>\n renderLayout(options.layout, options.data ?? {}, {\n store: options.store,\n registry: options.registry,\n ...(options.strict === undefined ? {} : { strict: options.strict }),\n ...(options.onError === undefined ? {} : { onError: options.onError }),\n ...(options.phrases === undefined ? {} : { phrases: options.phrases }),\n ...(options.phraseKeys === undefined ? {} : { phraseKeys: options.phraseKeys }),\n ...(options.onPhraseMiss === undefined ? {} : { onPhraseMiss: options.onPhraseMiss }),\n });\n\n// Render a layout reading its root data from a DataStore view. Used by the\n// action runtime so layout and action share a single data store instance.\nexport const renderLayoutFromStore = (\n node: LayoutNode,\n store: DataStoreView,\n ctx: RenderContext,\n): RenderNode[] => {\n const internal = toInternal(ctx);\n return safeRenderSingle(node, createScopeChain(store.get()), internal, undefined);\n};\n\nexport type { ScopeChain };\n","import { isComponentNode, isConditionalNode, isLoopNode, isSlotNode } from './guards';\nimport type { LayoutNode } from './schemas';\n\n// ═══════════════════════════════════════════════════════════\n// fillSlots — replace every `{ slot: name }` placeholder in a layout tree with\n// the layout in `fills[name]`. Used by the ActionFragment merge: a fragment's\n// chrome layout has a `{ slot: 'body' }`, and the composing action's own layout\n// is dropped into it. A slot whose name has no fill is left in place — the\n// renderer renders an unfilled slot as nothing.\n//\n// A pure tree-walk modelled on the layout store's `resolveReferences`: recurse\n// through children / then / else / do / arrays, rebuilding the tree.\n// ═══════════════════════════════════════════════════════════\n\nexport const fillSlots = (layout: LayoutNode, fills: Record<string, LayoutNode>): LayoutNode => {\n if (isSlotNode(layout)) {\n const fill = fills[layout.slot];\n return fill === undefined ? layout : fill;\n }\n if (Array.isArray(layout)) {\n return layout.map((node) => fillSlots(node, fills));\n }\n if (isComponentNode(layout)) {\n const { children } = layout;\n if (children === undefined) return layout;\n const next = Array.isArray(children)\n ? children.map((child) => fillSlots(child, fills))\n : fillSlots(children, fills);\n return { ...layout, children: next };\n }\n if (isConditionalNode(layout)) {\n return {\n ...layout,\n then: fillSlots(layout.then, fills),\n ...(layout.else === undefined ? {} : { else: fillSlots(layout.else, fills) }),\n };\n }\n if (isLoopNode(layout)) {\n return { ...layout, do: fillSlots(layout.do, fills) };\n }\n // primitives, layout refs, slot-less nodes — unchanged\n return layout;\n};\n","import type { RenderNode } from './types';\n\n// ═══════════════════════════════════════════════════════════\n// Adapter helpers — framework-agnostic pieces every adapter\n// (React, Vue, …) needs to render a RenderNode tree the same\n// way. See packages/nova/ADAPTER.md for the full contract.\n// ═══════════════════════════════════════════════════════════\n\n// Names of the props an adapter injects on rendered components:\n// `RenderNode.model` → NOVA_MODEL_PROP ({ ref, path }),\n// `RenderNode.ref` → NOVA_REF_PROP (string). Constants so all\n// adapters inject identically and components can rely on them.\nexport const NOVA_MODEL_PROP = 'novaModel';\nexport const NOVA_REF_PROP = 'novaRef';\n\n// Stable identity for a RenderNode within its sibling list.\n// Loop identity (stamped from LoopNode.key/index) wins over ref: a shared\n// `ref` across looped rows is an event-target id, not a list key.\nexport const renderNodeKey = (node: RenderNode, index: number): string => {\n if (node.key !== undefined) return `k:${node.key}`;\n if (node.type === 'component') {\n if (node.ref !== undefined) return `c:${node.ref}`;\n return `c:${node.name}:${index}`;\n }\n if (node.type === 'text') return `t:${index}`;\n if (node.type === 'fragment') return `f:${index}`;\n return `e:${node.code}:${index}`;\n};\n","import { DefinitionValidationError } from '../shared/errors';\nimport { depthRefusal, exceedsDepth } from '@niscorp/strata';\nimport {\n isComponentNode,\n isConditionalNode,\n isLayoutRefNode,\n isLoopNode,\n} from './guards';\nimport { LayoutNodeSchema, type LayoutNode } from './schemas';\nimport type { LayoutStore } from './types';\n\nexport const createLayoutStore = (): LayoutStore => {\n const layouts = new Map<string, LayoutNode>();\n\n const get = (id: string): LayoutNode | undefined => layouts.get(id);\n\n const set = (id: string, layout: LayoutNode): void => {\n // Before the schema: a deep enough layout overflows it (strata depth.ts).\n if (exceedsDepth(layout)) {\n throw new DefinitionValidationError(`Invalid layout for id \"${id}\"`, { failures: [{ id, issues: [{ code: 'custom', path: [], message: depthRefusal(), input: undefined }] }] });\n }\n const result = LayoutNodeSchema.safeParse(layout);\n if (!result.success) {\n throw new DefinitionValidationError(`Invalid layout for id \"${id}\"`, {\n failures: [{ id, issues: result.error.issues }],\n });\n }\n layouts.set(id, layout);\n };\n\n const remove = (id: string): void => {\n layouts.delete(id);\n };\n\n const list = (): string[] => Array.from(layouts.keys());\n\n const resolveReferences = (layout: LayoutNode): LayoutNode => {\n if (isLayoutRefNode(layout)) {\n const target = layouts.get(layout.ref);\n if (target === undefined) return layout;\n return resolveReferences(target);\n }\n if (Array.isArray(layout)) {\n return layout.map(resolveReferences);\n }\n if (isComponentNode(layout)) {\n const children = layout.children;\n let resolvedChildren: LayoutNode | LayoutNode[] | undefined;\n if (children === undefined) {\n resolvedChildren = undefined;\n } else if (Array.isArray(children)) {\n resolvedChildren = children.map(resolveReferences);\n } else {\n resolvedChildren = resolveReferences(children);\n }\n return {\n ...layout,\n ...(resolvedChildren === undefined ? {} : { children: resolvedChildren }),\n };\n }\n if (isConditionalNode(layout)) {\n return {\n ...layout,\n then: resolveReferences(layout.then),\n ...(layout.else === undefined ? {} : { else: resolveReferences(layout.else) }),\n };\n }\n if (isLoopNode(layout)) {\n return {\n ...layout,\n do: resolveReferences(layout.do),\n };\n }\n return layout;\n };\n\n return { get, set, delete: remove, list, resolveReferences };\n};\n"]}
|
package/dist/chunk-ZITHBBF3.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
// src/shared/event-bus/schemas.ts
|
|
4
|
-
var uiEvent = (type, extra = {}) => z.object({
|
|
5
|
-
type: z.literal(type).describe("Event type discriminator."),
|
|
6
|
-
ref: z.string().optional().describe("Target component ref."),
|
|
7
|
-
payload: z.unknown().optional().describe("Optional event payload."),
|
|
8
|
-
origin: z.string().optional().describe(
|
|
9
|
-
"Id of the action instance that dispatched this event. Stamped automatically for events dispatched from within an instance\u2019s layout; used to deliver UI events to that instance\u2019s own triggers only. Absent on programmatic (global) dispatch."
|
|
10
|
-
),
|
|
11
|
-
...extra
|
|
12
|
-
}).strict();
|
|
13
|
-
var UiClickSchema = uiEvent("ui:click").describe("A UI click event.");
|
|
14
|
-
var UiSubmitSchema = uiEvent("ui:submit").describe("A UI submit event.");
|
|
15
|
-
var UiInputSchema = uiEvent("ui:input").describe("A UI input event.");
|
|
16
|
-
var UiFocusSchema = uiEvent("ui:focus").describe("A UI focus event.");
|
|
17
|
-
var UiBlurSchema = uiEvent("ui:blur").describe("A UI blur event.");
|
|
18
|
-
var UiModelSchema = uiEvent("ui:model").describe("A two-way-bound model update event.");
|
|
19
|
-
var UiKeySchema = uiEvent("ui:key", {
|
|
20
|
-
key: z.string().describe('The key pressed, e.g. "ArrowDown", "Enter", "Escape".')
|
|
21
|
-
}).describe("A keyboard key event. A trigger filters it by `key` (and optionally `ref`).");
|
|
22
|
-
var UiDropSchema = uiEvent("ui:drop").describe(
|
|
23
|
-
'A drag-and-drop "drop" event \u2014 the semantic outcome of a drag gesture, dispatched by a drop zone. The gesture mechanics stay in the component; only the drop reaches Nova.'
|
|
24
|
-
);
|
|
25
|
-
var NovaEventSchema = z.discriminatedUnion("type", [
|
|
26
|
-
UiClickSchema,
|
|
27
|
-
UiSubmitSchema,
|
|
28
|
-
UiInputSchema,
|
|
29
|
-
UiFocusSchema,
|
|
30
|
-
UiBlurSchema,
|
|
31
|
-
UiModelSchema,
|
|
32
|
-
UiKeySchema,
|
|
33
|
-
UiDropSchema
|
|
34
|
-
]).describe("Discriminated union of the built-in Nova UI events.");
|
|
35
|
-
|
|
36
|
-
// src/shared/event-bus/scope-dispatch.ts
|
|
37
|
-
var scopeDispatch = (dispatch, origin) => {
|
|
38
|
-
return (event) => dispatch(event.origin === void 0 ? { ...event, origin } : event);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// src/shared/event-bus/event-bus.ts
|
|
42
|
-
var typeMatches = (matcher, type) => {
|
|
43
|
-
if (typeof matcher === "string") return matcher === type;
|
|
44
|
-
return matcher.test(type);
|
|
45
|
-
};
|
|
46
|
-
var createChildBus = (parent) => {
|
|
47
|
-
const subscriptions = [];
|
|
48
|
-
const emit = (event) => {
|
|
49
|
-
for (const sub of subscriptions.slice()) {
|
|
50
|
-
if (!typeMatches(sub.matcher, event.type)) continue;
|
|
51
|
-
try {
|
|
52
|
-
sub.handler(event);
|
|
53
|
-
} catch {
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (parent !== void 0) parent.emit(event);
|
|
57
|
-
};
|
|
58
|
-
const on = (matcher, handler) => {
|
|
59
|
-
const sub = { matcher, handler };
|
|
60
|
-
subscriptions.push(sub);
|
|
61
|
-
return () => {
|
|
62
|
-
const idx = subscriptions.indexOf(sub);
|
|
63
|
-
if (idx >= 0) subscriptions.splice(idx, 1);
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
const once = (matcher, handler) => {
|
|
67
|
-
const off = on(matcher, (event) => {
|
|
68
|
-
off();
|
|
69
|
-
handler(event);
|
|
70
|
-
});
|
|
71
|
-
return off;
|
|
72
|
-
};
|
|
73
|
-
const bus = {
|
|
74
|
-
emit,
|
|
75
|
-
on,
|
|
76
|
-
once,
|
|
77
|
-
scoped: () => createChildBus(bus)
|
|
78
|
-
};
|
|
79
|
-
return bus;
|
|
80
|
-
};
|
|
81
|
-
var createEventBus = () => createChildBus(void 0);
|
|
82
|
-
|
|
83
|
-
export { NovaEventSchema, createEventBus, scopeDispatch };
|
|
84
|
-
//# sourceMappingURL=chunk-ZITHBBF3.js.map
|
|
85
|
-
//# sourceMappingURL=chunk-ZITHBBF3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/shared/event-bus/schemas.ts","../src/shared/event-bus/scope-dispatch.ts","../src/shared/event-bus/event-bus.ts"],"names":[],"mappings":";;;AAgBA,IAAM,UAAU,CACd,IAAA,EACA,QAAW,EAAC,KAEZ,EACG,MAAA,CAAO;AAAA,EACN,MAAM,CAAA,CAAE,OAAA,CAAQ,IAAI,CAAA,CAAE,SAAS,2BAA2B,CAAA;AAAA,EAC1D,KAAK,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,uBAAuB,CAAA;AAAA,EAC3D,SAAS,CAAA,CAAE,OAAA,GAAU,QAAA,EAAS,CAAE,SAAS,yBAAyB,CAAA;AAAA,EAClE,MAAA,EAAQ,CAAA,CACL,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA,EACF,GAAG;AACL,CAAC,EACA,MAAA,EAAO;AAEZ,IAAM,aAAA,GAAgB,OAAA,CAAQ,UAAU,CAAA,C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AAA,IACA,EAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA,EAAQ,MAAM,cAAA,CAAuB,GAAG;AAAA,GAC1C;AAEA,EAAA,OAAO,GAAA;AACT,CAAA;AAEO,IAAM,cAAA,GAAiB,MAEL,cAAA,CAAuB,MAAS","file":"chunk-ZITHBBF3.js","sourcesContent":["import { z } from 'zod';\n\n// ═══════════════════════════════════════════════════════════\n// NovaEvent — the built-in discriminated union of UI events.\n// Consumers may supply their own union to createEventBus<T>.\n//\n// Every UI event shares the same envelope: a `type` discriminator, an optional\n// target `ref`, an optional `payload`, and an optional `origin` — the id of the\n// action instance that dispatched it. `origin` is stamped automatically when an\n// event is dispatched from inside an instance's rendered layout (see ActionSlot),\n// and lets the runtime deliver a UI event to that instance's OWN triggers only,\n// so two instances of the same action (e.g. a list on `main` and on `aside`)\n// don't both react to one click. Events dispatched programmatically\n// (`shell.dispatch`) carry no `origin` and stay global.\n// ═══════════════════════════════════════════════════════════\n\nconst uiEvent = <T extends string, E extends z.ZodRawShape = Record<never, never>>(\n type: T,\n extra: E = {} as E,\n) =>\n z\n .object({\n type: z.literal(type).describe('Event type discriminator.'),\n ref: z.string().optional().describe('Target component ref.'),\n payload: z.unknown().optional().describe('Optional event payload.'),\n origin: z\n .string()\n .optional()\n .describe(\n 'Id of the action instance that dispatched this event. Stamped automatically for events dispatched from within an instance’s layout; used to deliver UI events to that instance’s own triggers only. Absent on programmatic (global) dispatch.',\n ),\n ...extra,\n })\n .strict();\n\nconst UiClickSchema = uiEvent('ui:click').describe('A UI click event.');\nconst UiSubmitSchema = uiEvent('ui:submit').describe('A UI submit event.');\nconst UiInputSchema = uiEvent('ui:input').describe('A UI input event.');\nconst UiFocusSchema = uiEvent('ui:focus').describe('A UI focus event.');\nconst UiBlurSchema = uiEvent('ui:blur').describe('A UI blur event.');\nconst UiModelSchema = uiEvent('ui:model').describe('A two-way-bound model update event.');\nconst UiKeySchema = uiEvent('ui:key', {\n key: z.string().describe('The key pressed, e.g. \"ArrowDown\", \"Enter\", \"Escape\".'),\n}).describe('A keyboard key event. A trigger filters it by `key` (and optionally `ref`).');\nconst UiDropSchema = uiEvent('ui:drop').describe(\n 'A drag-and-drop \"drop\" event — the semantic outcome of a drag gesture, dispatched by a drop zone. The gesture mechanics stay in the component; only the drop reaches Nova.',\n);\n\nexport const NovaEventSchema = z\n .discriminatedUnion('type', [\n UiClickSchema,\n UiSubmitSchema,\n UiInputSchema,\n UiFocusSchema,\n UiBlurSchema,\n UiModelSchema,\n UiKeySchema,\n UiDropSchema,\n ])\n .describe('Discriminated union of the built-in Nova UI events.');\n\nexport type NovaEvent = z.infer<typeof NovaEventSchema>;\n","import type { NovaEvent } from './schemas';\n\n// Wraps a dispatch function so every event passing through it gets stamped\n// with `origin` (the dispatching action instance's id) unless it already\n// carries one — a re-dispatch keeps its original origin. Adapters wrap the\n// dispatch they hand to an instance's rendered subtree with this, so the\n// runtime delivers UI events to that instance's own triggers only. This is\n// routing semantics: never reimplement it per adapter.\nexport const scopeDispatch = (\n dispatch: (event: NovaEvent) => void,\n origin: string,\n): ((event: NovaEvent) => void) => {\n return (event) => dispatch(event.origin === undefined ? { ...event, origin } : event);\n};\n","import type { Unsubscribe } from '../common';\nimport type { EventBus, EventHandler, EventMatcher } from './types';\nimport type { NovaEvent } from './schemas';\n\n// ═══════════════════════════════════════════════════════════\n// Typed event bus. Factory function.\n//\n// Generic over TEvent (a discriminated union of events, defaulting\n// to NovaEvent). The bus only ever inspects `event.type` for matching.\n//\n// `scoped()` returns a child bus that forwards every event it emits\n// to its parent. No type mangling, no string prefixing — if you want\n// namespacing, put it in your event payload.\n// ═══════════════════════════════════════════════════════════\n\ntype Subscription<TEvent extends { type: string }> = {\n matcher: EventMatcher;\n handler: EventHandler<TEvent>;\n};\n\nconst typeMatches = (matcher: EventMatcher, type: string): boolean => {\n if (typeof matcher === 'string') return matcher === type;\n return matcher.test(type);\n};\n\nconst createChildBus = <TEvent extends { type: string }>(\n parent: EventBus<TEvent> | undefined,\n): EventBus<TEvent> => {\n const subscriptions: Subscription<TEvent>[] = [];\n\n const emit = (event: TEvent): void => {\n for (const sub of subscriptions.slice()) {\n if (!typeMatches(sub.matcher, event.type)) continue;\n try {\n sub.handler(event);\n } catch {\n // handler failures must not crash the bus\n }\n }\n if (parent !== undefined) parent.emit(event);\n };\n\n const on = (matcher: EventMatcher, handler: EventHandler<TEvent>): Unsubscribe => {\n const sub: Subscription<TEvent> = { matcher, handler };\n subscriptions.push(sub);\n return (): void => {\n const idx = subscriptions.indexOf(sub);\n if (idx >= 0) subscriptions.splice(idx, 1);\n };\n };\n\n const once = (matcher: EventMatcher, handler: EventHandler<TEvent>): Unsubscribe => {\n const off = on(matcher, (event) => {\n off();\n handler(event);\n });\n return off;\n };\n\n const bus: EventBus<TEvent> = {\n emit,\n on,\n once,\n scoped: () => createChildBus<TEvent>(bus),\n };\n\n return bus;\n};\n\nexport const createEventBus = <\n TEvent extends { type: string } = NovaEvent,\n>(): EventBus<TEvent> => createChildBus<TEvent>(undefined);\n"]}
|
|
@@ -25,12 +25,12 @@ declare const StackPropsSchema: z.ZodObject<{
|
|
|
25
25
|
type StackProps = z.infer<typeof StackPropsSchema>;
|
|
26
26
|
declare const TextPropsSchema: z.ZodObject<{
|
|
27
27
|
as: z.ZodOptional<z.ZodEnum<{
|
|
28
|
-
span: "span";
|
|
29
28
|
h1: "h1";
|
|
30
29
|
h2: "h2";
|
|
31
30
|
h3: "h3";
|
|
32
31
|
h4: "h4";
|
|
33
32
|
p: "p";
|
|
33
|
+
span: "span";
|
|
34
34
|
}>>;
|
|
35
35
|
size: z.ZodOptional<z.ZodEnum<{
|
|
36
36
|
sm: "sm";
|
|
@@ -25,12 +25,12 @@ declare const StackPropsSchema: z.ZodObject<{
|
|
|
25
25
|
type StackProps = z.infer<typeof StackPropsSchema>;
|
|
26
26
|
declare const TextPropsSchema: z.ZodObject<{
|
|
27
27
|
as: z.ZodOptional<z.ZodEnum<{
|
|
28
|
-
span: "span";
|
|
29
28
|
h1: "h1";
|
|
30
29
|
h2: "h2";
|
|
31
30
|
h3: "h3";
|
|
32
31
|
h4: "h4";
|
|
33
32
|
p: "p";
|
|
33
|
+
span: "span";
|
|
34
34
|
}>>;
|
|
35
35
|
size: z.ZodOptional<z.ZodEnum<{
|
|
36
36
|
sm: "sm";
|