@niscorp/nova 0.2.1 → 0.2.2
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/CHANGELOG.md +13 -0
- package/dist/adapters/dom/components/index.cjs +4 -51
- package/dist/adapters/dom/components/index.cjs.map +1 -1
- package/dist/adapters/dom/index.cjs +22 -686
- package/dist/adapters/dom/index.cjs.map +1 -1
- package/dist/adapters/dom/server.cjs +14 -411
- package/dist/adapters/dom/server.cjs.map +1 -1
- package/dist/adapters/react/components/index.cjs +87 -562
- 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/index.cjs +97 -1815
- package/dist/adapters/react/index.cjs.map +1 -1
- package/dist/adapters/tty/components/index.cjs +3 -44
- package/dist/adapters/tty/components/index.cjs.map +1 -1
- package/dist/adapters/tty/index.cjs +13 -5
- package/dist/adapters/tty/index.cjs.map +1 -1
- package/dist/adapters/vue/components/index.cjs +88 -639
- package/dist/adapters/vue/components/index.cjs.map +1 -1
- package/dist/adapters/vue/components/index.d.cts +10 -10
- package/dist/adapters/vue/components/index.d.ts +10 -10
- package/dist/adapters/vue/index.cjs +96 -962
- package/dist/adapters/vue/index.cjs.map +1 -1
- package/dist/agent/index.cjs +13 -151
- package/dist/agent/index.cjs.map +1 -1
- package/dist/chunk-3IPM5QBT.cjs +436 -0
- package/dist/chunk-3IPM5QBT.cjs.map +1 -0
- package/dist/chunk-5AF72LOE.cjs +97 -0
- package/dist/chunk-5AF72LOE.cjs.map +1 -0
- package/dist/chunk-5YQIAS4V.cjs +184 -0
- package/dist/chunk-5YQIAS4V.cjs.map +1 -0
- package/dist/chunk-D4PUWBN6.cjs +72 -0
- package/dist/chunk-D4PUWBN6.cjs.map +1 -0
- package/dist/chunk-FSUMCJAR.cjs +646 -0
- package/dist/chunk-FSUMCJAR.cjs.map +1 -0
- package/dist/chunk-GV7UC3SS.cjs +33 -0
- package/dist/chunk-GV7UC3SS.cjs.map +1 -0
- package/dist/chunk-IZ2UU5UL.cjs +808 -0
- package/dist/chunk-IZ2UU5UL.cjs.map +1 -0
- package/dist/chunk-KOYRJXTI.cjs +123 -0
- package/dist/chunk-KOYRJXTI.cjs.map +1 -0
- package/dist/chunk-KW34ZKF5.cjs +12 -0
- package/dist/chunk-KW34ZKF5.cjs.map +1 -0
- package/dist/chunk-OE527MXF.cjs +49 -0
- package/dist/chunk-OE527MXF.cjs.map +1 -0
- package/dist/chunk-OO247V4J.cjs +2117 -0
- package/dist/chunk-OO247V4J.cjs.map +1 -0
- package/dist/chunk-PMKWYOOX.cjs +64 -0
- package/dist/chunk-PMKWYOOX.cjs.map +1 -0
- package/dist/chunk-PNQY6OFB.cjs +132 -0
- package/dist/chunk-PNQY6OFB.cjs.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/chunk-TMLNVU5W.cjs +318 -0
- package/dist/chunk-TMLNVU5W.cjs.map +1 -0
- package/dist/chunk-TRJYDVWK.cjs +623 -0
- package/dist/chunk-TRJYDVWK.cjs.map +1 -0
- package/dist/chunk-UGG7MCX4.cjs +34 -0
- package/dist/chunk-UGG7MCX4.cjs.map +1 -0
- package/dist/chunk-WGPFR7MN.cjs +808 -0
- package/dist/chunk-WGPFR7MN.cjs.map +1 -0
- package/dist/chunk-WGZZKCJQ.cjs +157 -0
- package/dist/chunk-WGZZKCJQ.cjs.map +1 -0
- package/dist/devtools/index.cjs +13 -697
- package/dist/devtools/index.cjs.map +1 -1
- package/dist/document/index.cjs +56 -301
- package/dist/document/index.cjs.map +1 -1
- package/dist/examples/index.cjs +6 -31
- package/dist/examples/index.cjs.map +1 -1
- package/dist/i18n/index.cjs +44 -292
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/index.cjs +335 -3954
- package/dist/index.cjs.map +1 -1
- package/dist/migrations/index.cjs +7 -590
- package/dist/migrations/index.cjs.map +1 -1
- package/dist/reflect/index.cjs +85 -994
- package/dist/reflect/index.cjs.map +1 -1
- package/package.json +5 -5
- package/dist/{primitive-props-CGoJvmcH.d.cts → primitive-props-Cl5jiC8g.d.cts} +5 -5
- package/dist/{primitive-props-CGoJvmcH.d.ts → primitive-props-Cl5jiC8g.d.ts} +5 -5
package/dist/reflect/index.cjs
CHANGED
|
@@ -1,998 +1,89 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
if (segment === "length") {
|
|
90
|
-
current = current.length;
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
return void 0;
|
|
94
|
-
}
|
|
95
|
-
if (isObject(current)) {
|
|
96
|
-
if (segment in current) {
|
|
97
|
-
current = current[segment];
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
return void 0;
|
|
101
|
-
}
|
|
102
|
-
return void 0;
|
|
103
|
-
}
|
|
104
|
-
return current;
|
|
105
|
-
};
|
|
106
|
-
var setPath = (data, path, value) => {
|
|
107
|
-
const segments = splitPath(path);
|
|
108
|
-
if (segments.length === 0) return value;
|
|
109
|
-
const root = cloneContainer(data, segments[0]);
|
|
110
|
-
let parent = root;
|
|
111
|
-
for (let i = 0; i < segments.length - 1; i += 1) {
|
|
112
|
-
const segment = segments[i];
|
|
113
|
-
const nextSegment = segments[i + 1];
|
|
114
|
-
if (segment === void 0) continue;
|
|
115
|
-
const existing = readSegment(parent, segment);
|
|
116
|
-
const cloned = cloneContainer(existing, nextSegment);
|
|
117
|
-
writeSegment(parent, segment, cloned);
|
|
118
|
-
parent = cloned;
|
|
119
|
-
}
|
|
120
|
-
const last = segments[segments.length - 1];
|
|
121
|
-
if (last !== void 0) writeSegment(parent, last, value);
|
|
122
|
-
return root;
|
|
123
|
-
};
|
|
124
|
-
var deletePath = (data, path) => {
|
|
125
|
-
const segments = splitPath(path);
|
|
126
|
-
if (segments.length === 0) return void 0;
|
|
127
|
-
const root = cloneContainer(data, segments[0]);
|
|
128
|
-
let parent = root;
|
|
129
|
-
for (let i = 0; i < segments.length - 1; i += 1) {
|
|
130
|
-
const segment = segments[i];
|
|
131
|
-
const nextSegment = segments[i + 1];
|
|
132
|
-
if (segment === void 0) continue;
|
|
133
|
-
const existing = readSegment(parent, segment);
|
|
134
|
-
if (existing === void 0 || existing === null) return root;
|
|
135
|
-
const cloned = cloneContainer(existing, nextSegment);
|
|
136
|
-
writeSegment(parent, segment, cloned);
|
|
137
|
-
parent = cloned;
|
|
138
|
-
}
|
|
139
|
-
const last = segments[segments.length - 1];
|
|
140
|
-
if (last === void 0) return root;
|
|
141
|
-
if (isArray(parent)) {
|
|
142
|
-
if (isIndex(last)) {
|
|
143
|
-
const index = Number.parseInt(last, 10);
|
|
144
|
-
parent.splice(index, 1);
|
|
145
|
-
}
|
|
146
|
-
} else {
|
|
147
|
-
delete parent[last];
|
|
148
|
-
}
|
|
149
|
-
return root;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
// src/action/mutations/ops/set.ts
|
|
153
|
-
var SetByValueSchema = zod.z.object({
|
|
154
|
-
set: zod.z.string().describe('Data path to write to, e.g. "user.name" or "items.0.title".'),
|
|
155
|
-
value: zod.z.unknown().describe("Literal value to write at the path.")
|
|
156
|
-
}).strict().describe("Set a field at a path to a literal value.");
|
|
157
|
-
var SetByFromSchema = zod.z.object({
|
|
158
|
-
set: zod.z.string().describe("Data path to write to."),
|
|
159
|
-
from: zod.z.string().describe("Data path (or template path) to read the value from.")
|
|
160
|
-
}).strict().describe("Set a field at a path by copying from another path.");
|
|
161
|
-
var setValueOp = {
|
|
162
|
-
key: "set",
|
|
163
|
-
schema: SetByValueSchema,
|
|
164
|
-
match: (mutation) => hasKey(mutation, "set") && hasKey(mutation, "value"),
|
|
165
|
-
apply: (data, mutation) => {
|
|
166
|
-
const next = setPath(data, mutation.set, mutation.value);
|
|
167
|
-
return isObject(next) ? next : data;
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
var setFromOp = {
|
|
171
|
-
key: "set",
|
|
172
|
-
schema: SetByFromSchema,
|
|
173
|
-
match: (mutation) => hasKey(mutation, "set") && hasKey(mutation, "from"),
|
|
174
|
-
apply: (data, mutation) => {
|
|
175
|
-
const value = getPath(data, mutation.from);
|
|
176
|
-
const next = setPath(data, mutation.set, value);
|
|
177
|
-
return isObject(next) ? next : data;
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
var ToggleSchema = zod.z.object({
|
|
181
|
-
toggle: zod.z.string().describe("Boolean data path to flip.")
|
|
182
|
-
}).strict().describe("Flip a boolean at the given path.");
|
|
183
|
-
var toggleOp = {
|
|
184
|
-
key: "toggle",
|
|
185
|
-
schema: ToggleSchema,
|
|
186
|
-
apply: (data, mutation) => {
|
|
187
|
-
const current = getPath(data, mutation.toggle);
|
|
188
|
-
const flipped = !(current === true);
|
|
189
|
-
const next = setPath(data, mutation.toggle, flipped);
|
|
190
|
-
return isObject(next) ? next : data;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
var IncrementSchema = zod.z.object({
|
|
194
|
-
increment: zod.z.string().describe("Numeric data path to increment."),
|
|
195
|
-
by: zod.z.number().optional().describe("Amount to increment by; defaults to 1.")
|
|
196
|
-
}).strict().describe("Increment a numeric field.");
|
|
197
|
-
var incrementOp = {
|
|
198
|
-
key: "increment",
|
|
199
|
-
schema: IncrementSchema,
|
|
200
|
-
apply: (data, mutation) => {
|
|
201
|
-
const current = getPath(data, mutation.increment);
|
|
202
|
-
const base = typeof current === "number" ? current : 0;
|
|
203
|
-
const by = mutation.by ?? 1;
|
|
204
|
-
const next = setPath(data, mutation.increment, base + by);
|
|
205
|
-
return isObject(next) ? next : data;
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
var DecrementSchema = zod.z.object({
|
|
209
|
-
decrement: zod.z.string().describe("Numeric data path to decrement."),
|
|
210
|
-
by: zod.z.number().optional().describe("Amount to decrement by; defaults to 1.")
|
|
211
|
-
}).strict().describe("Decrement a numeric field.");
|
|
212
|
-
var decrementOp = {
|
|
213
|
-
key: "decrement",
|
|
214
|
-
schema: DecrementSchema,
|
|
215
|
-
apply: (data, mutation) => {
|
|
216
|
-
const current = getPath(data, mutation.decrement);
|
|
217
|
-
const base = typeof current === "number" ? current : 0;
|
|
218
|
-
const by = mutation.by ?? 1;
|
|
219
|
-
const next = setPath(data, mutation.decrement, base - by);
|
|
220
|
-
return isObject(next) ? next : data;
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
// src/shared/errors.ts
|
|
225
|
-
var ErrorCodes = {
|
|
226
|
-
mutation: "MUTATION_ERROR"};
|
|
227
|
-
var NovaError = class extends Error {
|
|
228
|
-
code;
|
|
229
|
-
context;
|
|
230
|
-
constructor(code, message, context, options) {
|
|
231
|
-
super(message, options);
|
|
232
|
-
this.name = "NovaError";
|
|
233
|
-
this.code = code;
|
|
234
|
-
this.context = context;
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
var MutationError = class extends NovaError {
|
|
238
|
-
constructor(message, context, options) {
|
|
239
|
-
super(ErrorCodes.mutation, message, context, options);
|
|
240
|
-
this.name = "MutationError";
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
// src/action/mutations/ops/push.ts
|
|
245
|
-
var PushSchema = zod.z.object({
|
|
246
|
-
push: zod.z.string().describe("Array data path to append to."),
|
|
247
|
-
value: zod.z.unknown().optional().describe("Value to append.")
|
|
248
|
-
}).strict().describe("Append a value to an array field.");
|
|
249
|
-
var pushOp = {
|
|
250
|
-
key: "push",
|
|
251
|
-
schema: PushSchema,
|
|
252
|
-
// Guard against the PushEffect navigation effect whose `push` is an object.
|
|
253
|
-
match: (mutation) => typeof mutation.push === "string",
|
|
254
|
-
apply: (data, mutation, ctx) => {
|
|
255
|
-
const current = getPath(data, mutation.push);
|
|
256
|
-
if (current !== void 0 && !isArray(current)) {
|
|
257
|
-
if (ctx.strict) {
|
|
258
|
-
throw new MutationError(
|
|
259
|
-
`push: path "${mutation.push}" is not an array`,
|
|
260
|
-
{ op: "push", path: mutation.push, reason: "wrong-type" }
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
return data;
|
|
264
|
-
}
|
|
265
|
-
if (current === void 0 && ctx.strict) {
|
|
266
|
-
throw new MutationError(
|
|
267
|
-
`push: path "${mutation.push}" does not exist`,
|
|
268
|
-
{ op: "push", path: mutation.push, reason: "missing" }
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
const arr = isArray(current) ? current.slice() : [];
|
|
272
|
-
arr.push(mutation.value);
|
|
273
|
-
const next = setPath(data, mutation.push, arr);
|
|
274
|
-
return isObject(next) ? next : data;
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
var PopSchema = zod.z.object({
|
|
278
|
-
pop: zod.z.string().describe("Array data path to remove the last element from.")
|
|
279
|
-
}).strict().describe("Remove the last element from an array field.");
|
|
280
|
-
var popOp = {
|
|
281
|
-
key: "pop",
|
|
282
|
-
schema: PopSchema,
|
|
283
|
-
// Guard against the PopEffect whose `pop` is the literal `true`.
|
|
284
|
-
match: (mutation) => typeof mutation.pop === "string",
|
|
285
|
-
apply: (data, mutation, ctx) => {
|
|
286
|
-
const current = getPath(data, mutation.pop);
|
|
287
|
-
if (!isArray(current)) {
|
|
288
|
-
if (ctx.strict) {
|
|
289
|
-
throw new MutationError(
|
|
290
|
-
`pop: path "${mutation.pop}" ${current === void 0 ? "does not exist" : "is not an array"}`,
|
|
291
|
-
{ op: "pop", path: mutation.pop, reason: current === void 0 ? "missing" : "wrong-type" }
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
return data;
|
|
295
|
-
}
|
|
296
|
-
const arr = current.slice();
|
|
297
|
-
arr.pop();
|
|
298
|
-
const next = setPath(data, mutation.pop, arr);
|
|
299
|
-
return isObject(next) ? next : data;
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
var RemoveAtSchema = zod.z.object({
|
|
303
|
-
removeAt: zod.z.string().describe("Array data path to remove an element from."),
|
|
304
|
-
index: zod.z.union([zod.z.number().int(), zod.z.string()]).describe('Index to remove. A string is a template (e.g. "{{@event.payload}}") resolved before applying.')
|
|
305
|
-
}).strict().describe("Remove an element at a specific index of an array field.");
|
|
306
|
-
var removeAtOp = {
|
|
307
|
-
key: "removeAt",
|
|
308
|
-
schema: RemoveAtSchema,
|
|
309
|
-
apply: (data, mutation, ctx) => {
|
|
310
|
-
const current = getPath(data, mutation.removeAt);
|
|
311
|
-
if (!isArray(current)) {
|
|
312
|
-
if (ctx.strict) {
|
|
313
|
-
throw new MutationError(
|
|
314
|
-
`removeAt: path "${mutation.removeAt}" ${current === void 0 ? "does not exist" : "is not an array"}`,
|
|
315
|
-
{
|
|
316
|
-
op: "removeAt",
|
|
317
|
-
path: mutation.removeAt,
|
|
318
|
-
reason: current === void 0 ? "missing" : "wrong-type"
|
|
319
|
-
}
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
return data;
|
|
323
|
-
}
|
|
324
|
-
const index = Number(mutation.index);
|
|
325
|
-
if (!Number.isInteger(index)) return data;
|
|
326
|
-
const arr = current.slice();
|
|
327
|
-
arr.splice(index, 1);
|
|
328
|
-
const next = setPath(data, mutation.removeAt, arr);
|
|
329
|
-
return isObject(next) ? next : data;
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
var MoveSchema = zod.z.object({
|
|
333
|
-
move: zod.z.string().describe("Array data path to reorder within."),
|
|
334
|
-
from: zod.z.union([zod.z.number().int(), zod.z.string()]).describe('Index to move. A string is a template (e.g. "{{@event.payload}}") resolved before applying.'),
|
|
335
|
-
to: zod.z.union([zod.z.number().int(), zod.z.string()]).describe("Destination index. A string is a template resolved before applying.")
|
|
336
|
-
}).strict().describe("Move an array element from one index to another.");
|
|
337
|
-
var moveOp = {
|
|
338
|
-
key: "move",
|
|
339
|
-
schema: MoveSchema,
|
|
340
|
-
apply: (data, mutation, ctx) => {
|
|
341
|
-
const current = getPath(data, mutation.move);
|
|
342
|
-
if (!isArray(current)) {
|
|
343
|
-
if (ctx.strict) {
|
|
344
|
-
throw new MutationError(
|
|
345
|
-
`move: path "${mutation.move}" ${current === void 0 ? "does not exist" : "is not an array"}`,
|
|
346
|
-
{
|
|
347
|
-
op: "move",
|
|
348
|
-
path: mutation.move,
|
|
349
|
-
reason: current === void 0 ? "missing" : "wrong-type"
|
|
350
|
-
}
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
return data;
|
|
354
|
-
}
|
|
355
|
-
const from = Number(mutation.from);
|
|
356
|
-
const to = Number(mutation.to);
|
|
357
|
-
if (!Number.isInteger(from) || !Number.isInteger(to)) return data;
|
|
358
|
-
if (from < 0 || from >= current.length) return data;
|
|
359
|
-
const arr = current.slice();
|
|
360
|
-
const [item] = arr.splice(from, 1);
|
|
361
|
-
arr.splice(Math.max(0, Math.min(to, arr.length)), 0, item);
|
|
362
|
-
const next = setPath(data, mutation.move, arr);
|
|
363
|
-
return isObject(next) ? next : data;
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
var ClearSchema = zod.z.object({
|
|
367
|
-
clear: zod.z.string().describe("Array or object data path to clear.")
|
|
368
|
-
}).strict().describe("Clear an array or object field.");
|
|
369
|
-
var clearOp = {
|
|
370
|
-
key: "clear",
|
|
371
|
-
schema: ClearSchema,
|
|
372
|
-
apply: (data, mutation, ctx) => {
|
|
373
|
-
const current = getPath(data, mutation.clear);
|
|
374
|
-
if (isArray(current)) {
|
|
375
|
-
const next2 = setPath(data, mutation.clear, []);
|
|
376
|
-
return isObject(next2) ? next2 : data;
|
|
377
|
-
}
|
|
378
|
-
if (isObject(current)) {
|
|
379
|
-
const next2 = setPath(data, mutation.clear, {});
|
|
380
|
-
return isObject(next2) ? next2 : data;
|
|
381
|
-
}
|
|
382
|
-
if (ctx.strict) {
|
|
383
|
-
throw new MutationError(
|
|
384
|
-
`clear: path "${mutation.clear}" ${current === void 0 ? "does not exist" : "is not an array or object"}`,
|
|
385
|
-
{
|
|
386
|
-
op: "clear",
|
|
387
|
-
path: mutation.clear,
|
|
388
|
-
reason: current === void 0 ? "missing" : "wrong-type"
|
|
389
|
-
}
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
const next = deletePath(data, mutation.clear);
|
|
393
|
-
return isObject(next) ? next : data;
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
var ResetSchema = zod.z.object({
|
|
397
|
-
reset: zod.z.string().describe("Data path to reset to its initial (definition.data) value.")
|
|
398
|
-
}).strict().describe("Reset a field to its initial value from the action definition.");
|
|
399
|
-
var resetOp = {
|
|
400
|
-
key: "reset",
|
|
401
|
-
schema: ResetSchema,
|
|
402
|
-
apply: (data, mutation, ctx) => {
|
|
403
|
-
const initialValue = getPath(ctx.initial, mutation.reset);
|
|
404
|
-
const next = setPath(data, mutation.reset, initialValue);
|
|
405
|
-
return isObject(next) ? next : data;
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
// src/action/mutations/ops/index.ts
|
|
410
|
-
var OPS = [
|
|
411
|
-
setValueOp,
|
|
412
|
-
setFromOp,
|
|
413
|
-
toggleOp,
|
|
414
|
-
incrementOp,
|
|
415
|
-
decrementOp,
|
|
416
|
-
pushOp,
|
|
417
|
-
popOp,
|
|
418
|
-
removeAtOp,
|
|
419
|
-
moveOp,
|
|
420
|
-
clearOp,
|
|
421
|
-
resetOp
|
|
422
|
-
];
|
|
423
|
-
zod.z.union(
|
|
424
|
-
OPS.map((op) => op.schema)
|
|
425
|
-
).describe("A single immutable mutation applied to the action data.");
|
|
426
|
-
|
|
427
|
-
// src/agent/affordances.ts
|
|
428
|
-
var KEY_PATTERN = /\$\.([A-Za-z_][A-Za-z0-9_]*)/g;
|
|
429
|
-
var VAR_PATTERN = /\$([A-Za-z_][A-Za-z0-9_]*)\./g;
|
|
430
|
-
var collectInteractive = (layout) => {
|
|
431
|
-
const refs = [];
|
|
432
|
-
const models = [];
|
|
433
|
-
const boundKeys = /* @__PURE__ */ new Set();
|
|
434
|
-
const suspects = /* @__PURE__ */ new Set();
|
|
435
|
-
let componentCount = 0;
|
|
436
|
-
const scanString = (value, scope) => {
|
|
437
|
-
for (const match of value.matchAll(KEY_PATTERN)) {
|
|
438
|
-
const key = match[1];
|
|
439
|
-
if (key !== void 0) boundKeys.add(key);
|
|
440
|
-
}
|
|
441
|
-
for (const match of value.matchAll(VAR_PATTERN)) {
|
|
442
|
-
const name = match[1];
|
|
443
|
-
if (name !== void 0 && !scope.has(name)) suspects.add(`$${name}.`);
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
const walk = (node, scope) => {
|
|
447
|
-
if (typeof node === "string") return scanString(node, scope);
|
|
448
|
-
if (Array.isArray(node)) {
|
|
449
|
-
for (const child of node) walk(child, scope);
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
if (node === null || typeof node !== "object") return;
|
|
453
|
-
const record = node;
|
|
454
|
-
const loopVar = record["for"] !== void 0 && typeof record["as"] === "string" ? record["as"] : void 0;
|
|
455
|
-
const childScope = loopVar !== void 0 ? /* @__PURE__ */ new Set([...scope, loopVar]) : scope;
|
|
456
|
-
const component = typeof record["component"] === "string" ? record["component"] : void 0;
|
|
457
|
-
if (component !== void 0) {
|
|
458
|
-
componentCount += 1;
|
|
459
|
-
if (typeof record["ref"] === "string" && record["ref"].length > 0) {
|
|
460
|
-
refs.push({ ref: record["ref"], component, via: "ref" });
|
|
461
|
-
}
|
|
462
|
-
if (typeof record["model"] === "string" && record["model"].length > 0) {
|
|
463
|
-
models.push({ path: record["model"], component });
|
|
464
|
-
}
|
|
465
|
-
const props = record["props"];
|
|
466
|
-
if (props !== null && typeof props === "object" && !Array.isArray(props)) {
|
|
467
|
-
for (const [key, value] of Object.entries(props)) {
|
|
468
|
-
if (key.endsWith("Ref") && typeof value === "string" && value.length > 0) {
|
|
469
|
-
refs.push({ ref: value, component, via: key });
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
for (const value of Object.values(record)) walk(value, childScope);
|
|
475
|
-
};
|
|
476
|
-
walk(layout, /* @__PURE__ */ new Set());
|
|
477
|
-
return {
|
|
478
|
-
refs,
|
|
479
|
-
models,
|
|
480
|
-
boundKeys: [...boundKeys].sort(),
|
|
481
|
-
suspectBindings: [...suspects].sort(),
|
|
482
|
-
componentCount
|
|
483
|
-
};
|
|
484
|
-
};
|
|
485
|
-
|
|
486
|
-
// src/action/grammar.ts
|
|
487
|
-
var MUTATION_KEYS = [...new Set(OPS.map((op) => op.key))];
|
|
488
|
-
var MATCHERS = OPS.map((op) => op.match ?? ((step) => op.key in step));
|
|
489
|
-
var isMutationStep = (step) => MATCHERS.some((match) => match(step));
|
|
490
|
-
var mutationPaths = (steps) => {
|
|
491
|
-
const found = [];
|
|
492
|
-
const walk = (node) => {
|
|
493
|
-
if (Array.isArray(node)) {
|
|
494
|
-
for (const item of node) walk(item);
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
if (node === null || typeof node !== "object") return;
|
|
498
|
-
const step = node;
|
|
499
|
-
if (isMutationStep(step)) {
|
|
500
|
-
for (const key of MUTATION_KEYS) {
|
|
501
|
-
const value = step[key];
|
|
502
|
-
if (typeof value === "string") found.push(value);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
walk(step["onSuccess"]);
|
|
506
|
-
walk(step["onError"]);
|
|
507
|
-
};
|
|
508
|
-
walk(steps);
|
|
509
|
-
return found;
|
|
510
|
-
};
|
|
511
|
-
var rootOf = (path) => path.split(".")[0] ?? path;
|
|
512
|
-
|
|
513
|
-
// src/action/audit.ts
|
|
514
|
-
var collectChannels = (definition) => {
|
|
515
|
-
const emits = /* @__PURE__ */ new Set();
|
|
516
|
-
const listens = /* @__PURE__ */ new Set();
|
|
517
|
-
const walkSteps = (list) => {
|
|
518
|
-
if (!Array.isArray(list)) return;
|
|
519
|
-
for (const step of list) {
|
|
520
|
-
if (!isRecord2(step)) continue;
|
|
521
|
-
const emit = step["emit"];
|
|
522
|
-
if (isRecord2(emit) && typeof emit["channel"] === "string") emits.add(emit["channel"]);
|
|
523
|
-
if (typeof step["call"] === "string") {
|
|
524
|
-
walkSteps(step["onSuccess"]);
|
|
525
|
-
walkSteps(step["onError"]);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
for (const trigger of definition.triggers ?? []) {
|
|
530
|
-
if (typeof trigger.message === "string") listens.add(trigger.message);
|
|
531
|
-
walkSteps(trigger.do);
|
|
532
|
-
}
|
|
533
|
-
for (const hook of Object.values(definition.lifecycle ?? {})) walkSteps(hook);
|
|
534
|
-
return { emits: [...emits].sort(), listens: [...listens].sort() };
|
|
535
|
-
};
|
|
536
|
-
var firstSegment = (path) => {
|
|
537
|
-
const segment = path.split(".")[0];
|
|
538
|
-
return segment === void 0 || segment.length === 0 ? path : segment;
|
|
539
|
-
};
|
|
540
|
-
var isRecord2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
541
|
-
var navTargetOf = (step) => {
|
|
542
|
-
for (const key of ["push", "replace", "resetTo"]) {
|
|
543
|
-
const value = step[key];
|
|
544
|
-
if (isRecord2(value) && typeof value["action"] === "string") {
|
|
545
|
-
const input = value["input"];
|
|
546
|
-
return { action: value["action"], ...isRecord2(input) ? { input } : {} };
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
return void 0;
|
|
550
|
-
};
|
|
551
|
-
var auditAction = (definition, options) => {
|
|
552
|
-
const issues = [];
|
|
553
|
-
const dataKeys = new Set(Object.keys(definition.data ?? {}));
|
|
554
|
-
const endpointNames = new Set(Object.keys(definition.endpoints ?? {}));
|
|
555
|
-
const steps = [];
|
|
556
|
-
const pushSteps = (list) => {
|
|
557
|
-
if (!Array.isArray(list)) return;
|
|
558
|
-
for (const step of list) {
|
|
559
|
-
if (!isRecord2(step)) continue;
|
|
560
|
-
steps.push(step);
|
|
561
|
-
if (typeof step["call"] === "string") {
|
|
562
|
-
pushSteps(step["onSuccess"]);
|
|
563
|
-
pushSteps(step["onError"]);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
};
|
|
567
|
-
for (const trigger of definition.triggers ?? []) pushSteps(trigger.do);
|
|
568
|
-
for (const hook of Object.values(definition.lifecycle ?? {})) pushSteps(hook);
|
|
569
|
-
for (const step of steps) {
|
|
570
|
-
const call = step["call"];
|
|
571
|
-
if (typeof call === "string" && !endpointNames.has(call)) {
|
|
572
|
-
issues.push(`step calls endpoint "${call}" but endpoints has no "${call}"`);
|
|
573
|
-
}
|
|
574
|
-
for (const key of MUTATION_KEYS) {
|
|
575
|
-
const path = step[key];
|
|
576
|
-
if (typeof path === "string" && path.length > 0 && !dataKeys.has(firstSegment(path))) {
|
|
577
|
-
issues.push(`step "${key}: ${path}" writes a key with no default in data`);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
const nav = navTargetOf(step);
|
|
581
|
-
if (nav !== void 0 && options?.catalog !== void 0) {
|
|
582
|
-
const entry = options.catalog.find((candidate) => candidate.id === nav.action);
|
|
583
|
-
if (entry === void 0 && nav.action !== definition.id) {
|
|
584
|
-
issues.push(`step pushes action "${nav.action}" which is not in the catalog`);
|
|
585
|
-
continue;
|
|
586
|
-
}
|
|
587
|
-
const properties = entry?.input?.["properties"];
|
|
588
|
-
if (nav.input !== void 0 && isRecord2(properties)) {
|
|
589
|
-
for (const key of Object.keys(nav.input)) {
|
|
590
|
-
if (!(key in properties)) {
|
|
591
|
-
issues.push(`push to "${nav.action}" seeds input key "${key}" which is not in its input contract`);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
for (const [name, endpoint] of Object.entries(definition.endpoints ?? {})) {
|
|
598
|
-
for (const field of ["target", "errorTarget"]) {
|
|
599
|
-
const target = endpoint[field];
|
|
600
|
-
if (typeof target === "string" && target.length > 0 && !dataKeys.has(firstSegment(target))) {
|
|
601
|
-
issues.push(`endpoint "${name}" ${field} "${target}" has no default in data`);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
if (options?.channels !== void 0) {
|
|
606
|
-
const known = new Set(options.channels);
|
|
607
|
-
const usage = collectChannels(definition);
|
|
608
|
-
for (const channel of usage.listens) {
|
|
609
|
-
if (!known.has(channel) && !usage.emits.includes(channel)) {
|
|
610
|
-
issues.push(`trigger listens on channel "${channel}" which nothing is known to emit`);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
for (const channel of usage.emits) {
|
|
614
|
-
if (!known.has(channel) && !usage.listens.includes(channel)) {
|
|
615
|
-
issues.push(`step emits channel "${channel}" which nothing is known to listen on`);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
if (definition.layout !== void 0 && typeof definition.layout !== "string") {
|
|
620
|
-
const surface = collectInteractive(definition.layout);
|
|
621
|
-
for (const key of surface.boundKeys) {
|
|
622
|
-
if (!dataKeys.has(key)) {
|
|
623
|
-
issues.push(`layout binds "$.${key}" but data has no "${key}" default`);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
for (const suspect of surface.suspectBindings) {
|
|
627
|
-
issues.push(
|
|
628
|
-
`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`
|
|
629
|
-
);
|
|
630
|
-
}
|
|
631
|
-
const layoutRefs = new Set(surface.refs.map((entry) => entry.ref));
|
|
632
|
-
const triggerRefs = new Set(
|
|
633
|
-
(definition.triggers ?? []).map((trigger) => trigger.ref).filter((ref) => typeof ref === "string")
|
|
634
|
-
);
|
|
635
|
-
for (const ref of layoutRefs) {
|
|
636
|
-
if (!triggerRefs.has(ref)) {
|
|
637
|
-
issues.push(`layout ref "${ref}" has no trigger \u2014 dead chrome`);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
for (const ref of triggerRefs) {
|
|
641
|
-
if (!layoutRefs.has(ref)) {
|
|
642
|
-
issues.push(`trigger listens on ref "${ref}" but no layout node carries it`);
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
return { ok: issues.length === 0, issues };
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
// src/reflect/audit.ts
|
|
650
|
-
var classifyAudit = (issue, definition) => {
|
|
651
|
-
const layout = typeof definition.layout === "object" ? definition.layout : void 0;
|
|
652
|
-
const bind = issue.match(/binds "\$\.([\w.]+)"/);
|
|
653
|
-
if (bind !== null) {
|
|
654
|
-
const root = (bind[1] ?? "").split(".")[0] ?? "";
|
|
655
|
-
if (root === "index" || root === "items") {
|
|
656
|
-
return { kind: "info", tag: "loop scope", reason: `\`${root}\` is a renderer-reserved loop variable` };
|
|
657
|
-
}
|
|
658
|
-
if (loopVarsOf(layout).has(root)) {
|
|
659
|
-
return { kind: "info", tag: "loop var", reason: `\`${root}\` is a loop \`as:\` variable \u2014 in scope at runtime` };
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
const ref = issue.match(/ref "([^"]+)"/);
|
|
663
|
-
if (ref !== null && issue.includes("listens") && refsOf(layout).has(ref[1] ?? "")) {
|
|
664
|
-
return { kind: "info", tag: "prop ref", reason: "dispatched by a component from a props value (e.g. Table rowRef / cell.ref)" };
|
|
665
|
-
}
|
|
666
|
-
if (issue.includes("{{")) {
|
|
667
|
-
return { kind: "info", tag: "template", reason: "target resolves from data at runtime \u2014 statically unknowable" };
|
|
668
|
-
}
|
|
669
|
-
return { kind: "address" };
|
|
670
|
-
};
|
|
671
|
-
var auditCatalog = (definitions) => {
|
|
672
|
-
const defs = Array.isArray(definitions) ? [...definitions] : Object.values(definitions);
|
|
673
|
-
const catalog = defs.map((definition) => ({ id: definition.id, ...definition.input !== void 0 ? { input: definition.input } : {} }));
|
|
674
|
-
const channels = [
|
|
675
|
-
...new Set(
|
|
676
|
-
defs.flatMap((definition) => {
|
|
677
|
-
const usage = collectChannels(definition);
|
|
678
|
-
return [...usage.emits, ...usage.listens];
|
|
679
|
-
})
|
|
680
|
-
)
|
|
681
|
-
];
|
|
682
|
-
return defs.map((definition) => {
|
|
683
|
-
const issues = auditAction(definition, { catalog, channels }).issues.map((issue) => ({ issue, ...classifyAudit(issue, definition) }));
|
|
684
|
-
issues.sort((a, b) => Number(a.kind === "info") - Number(b.kind === "info"));
|
|
685
|
-
return { id: definition.id, address: issues.filter((issue) => issue.kind === "address").length, issues };
|
|
686
|
-
}).filter((row) => row.issues.length > 0).sort((a, b) => b.address - a.address);
|
|
687
|
-
};
|
|
688
|
-
|
|
689
|
-
// src/reflect/shell.ts
|
|
690
|
-
var snapshotShell = (shell, exclude = []) => {
|
|
691
|
-
const state = shell.getState();
|
|
692
|
-
const canvases = Object.values(state.canvases).filter((canvas) => !exclude.includes(canvas.id)).map((canvas) => ({
|
|
693
|
-
id: canvas.id,
|
|
694
|
-
depth: canvas.stack.length,
|
|
695
|
-
items: [...canvas.stack].reverse().map((instance) => ({
|
|
696
|
-
definitionId: instance.definitionId,
|
|
697
|
-
instanceId: instance.id,
|
|
698
|
-
status: instance.status,
|
|
699
|
-
active: instance.id === canvas.active?.id
|
|
700
|
-
}))
|
|
701
|
-
}));
|
|
702
|
-
return { canvases, layouts: shell.layoutStore.list(), components: shell.registry.list() };
|
|
703
|
-
};
|
|
704
|
-
var compact = (value, over, head) => {
|
|
705
|
-
if (Array.isArray(value)) {
|
|
706
|
-
return over === 0 || value.length <= over ? value.map((item) => compact(item, over, head)) : [...value.slice(0, head).map((item) => compact(item, over, head)), `\u2026${value.length - head} more`];
|
|
707
|
-
}
|
|
708
|
-
if (value === null || typeof value !== "object") return value;
|
|
709
|
-
const out = {};
|
|
710
|
-
for (const [key, inner] of Object.entries(value)) out[key] = compact(inner, over, head);
|
|
711
|
-
return out;
|
|
712
|
-
};
|
|
713
|
-
var describeShell = (shell, options = {}) => {
|
|
714
|
-
const { only, mark, collapseOver = 5, head = 3, clean } = options;
|
|
715
|
-
const lines = [];
|
|
716
|
-
for (const [canvasId, canvas] of Object.entries(shell.getState().canvases)) {
|
|
717
|
-
if (only !== void 0 && !only.includes(canvasId)) continue;
|
|
718
|
-
if (canvas.active === void 0) {
|
|
719
|
-
lines.push(` ${canvasId}: (empty)`);
|
|
720
|
-
continue;
|
|
721
|
-
}
|
|
722
|
-
lines.push(` ${canvasId}: ${canvas.stack.map((item, index) => `${item.definitionId}${index === canvas.stack.length - 1 ? "*" : ""}`).join(" \u203A ")}`);
|
|
723
|
-
for (const item of canvas.stack) {
|
|
724
|
-
const runtime = shell.getRuntime(item.id);
|
|
725
|
-
const note = mark?.(item.id);
|
|
726
|
-
const data = runtime === void 0 ? void 0 : (clean ?? ((value) => value))(runtime.getData());
|
|
727
|
-
lines.push(` ${item.definitionId}${note === void 0 ? "" : ` ${note}`} data: ${data === void 0 ? "{}" : JSON.stringify(compact(data, collapseOver, head))}`);
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
return lines.join("\n");
|
|
731
|
-
};
|
|
732
|
-
var describeInstance = (shell, instanceId) => {
|
|
733
|
-
const runtime = shell.getRuntime(instanceId);
|
|
734
|
-
if (runtime === void 0) return void 0;
|
|
735
|
-
const definition = runtime.definition;
|
|
736
|
-
const layout = definition.layout;
|
|
737
|
-
const layoutNode = typeof layout === "string" ? shell.layoutStore.get(layout) : layout;
|
|
738
|
-
const issues = auditAction(definition).issues.map((issue) => ({ issue, ...classifyAudit(issue, definition) }));
|
|
739
|
-
return {
|
|
740
|
-
id: definition.id,
|
|
741
|
-
instanceId,
|
|
742
|
-
canvasId: runtime.instance.canvasId,
|
|
743
|
-
status: runtime.instance.status,
|
|
744
|
-
title: definition.title ?? "",
|
|
745
|
-
data: runtime.getData(),
|
|
746
|
-
endpoints: Object.entries(definition.endpoints ?? {}).map(([name, config]) => ({ name, config })),
|
|
747
|
-
triggers: definition.triggers ?? [],
|
|
748
|
-
lifecycle: definition.lifecycle ?? {},
|
|
749
|
-
layoutKind: typeof layout === "string" ? "store" : "inline",
|
|
750
|
-
layout: layoutNode,
|
|
751
|
-
input: definition.input,
|
|
752
|
-
issues
|
|
753
|
-
};
|
|
754
|
-
};
|
|
755
|
-
|
|
756
|
-
// src/reflect/grammar.ts
|
|
757
|
-
var gesturedKeys = (definition) => [
|
|
758
|
-
...new Set(
|
|
759
|
-
(definition.triggers ?? []).filter((trigger) => typeof trigger.event === "string" && trigger.event.startsWith("ui:")).flatMap((trigger) => mutationPaths(trigger.do)).map(rootOf)
|
|
760
|
-
)
|
|
761
|
-
];
|
|
762
|
-
var declaredKeys = (definition) => Object.keys(definition.input?.properties ?? {});
|
|
763
|
-
var loadedKeys = (definition) => {
|
|
764
|
-
const loaded = /* @__PURE__ */ new Set();
|
|
765
|
-
for (const endpoint of Object.values(definition.endpoints ?? {})) {
|
|
766
|
-
const spec = endpoint;
|
|
767
|
-
if (spec.target !== void 0) loaded.add(rootOf(spec.target));
|
|
768
|
-
if (spec.errorTarget !== void 0) loaded.add(rootOf(spec.errorTarget));
|
|
769
|
-
}
|
|
770
|
-
return [...loaded];
|
|
771
|
-
};
|
|
772
|
-
var lifecycleKeys = (definition) => [
|
|
773
|
-
...new Set(
|
|
774
|
-
Object.values(definition.lifecycle ?? {}).flatMap(mutationPaths).map(rootOf)
|
|
775
|
-
)
|
|
776
|
-
];
|
|
777
|
-
var mountCalls = (definition) => {
|
|
778
|
-
const names = /* @__PURE__ */ new Set();
|
|
779
|
-
const walk = (node) => {
|
|
780
|
-
if (Array.isArray(node)) {
|
|
781
|
-
for (const item of node) walk(item);
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
if (node === null || typeof node !== "object") return;
|
|
785
|
-
const step = node;
|
|
786
|
-
if (typeof step["call"] === "string") names.add(step["call"]);
|
|
787
|
-
walk(step["onSuccess"]);
|
|
788
|
-
walk(step["onError"]);
|
|
789
|
-
};
|
|
790
|
-
walk(definition.lifecycle?.mount);
|
|
791
|
-
return names;
|
|
792
|
-
};
|
|
793
|
-
var requestKeys = (request) => {
|
|
794
|
-
const found = [];
|
|
795
|
-
const walk = (node) => {
|
|
796
|
-
if (typeof node === "string") {
|
|
797
|
-
if (node.startsWith("$.")) found.push(rootOf(node.slice(2)));
|
|
798
|
-
return;
|
|
799
|
-
}
|
|
800
|
-
if (Array.isArray(node)) {
|
|
801
|
-
for (const item of node) walk(item);
|
|
802
|
-
return;
|
|
803
|
-
}
|
|
804
|
-
if (node === null || typeof node !== "object") return;
|
|
805
|
-
for (const value of Object.values(node)) walk(value);
|
|
806
|
-
};
|
|
807
|
-
walk(request);
|
|
808
|
-
return found.filter((key) => key !== "");
|
|
809
|
-
};
|
|
810
|
-
var mountInputCache = /* @__PURE__ */ new WeakMap();
|
|
811
|
-
var mountInputKeys = (definition) => {
|
|
812
|
-
const cached = mountInputCache.get(definition);
|
|
813
|
-
if (cached !== void 0) return cached;
|
|
814
|
-
const called = mountCalls(definition);
|
|
815
|
-
const declared = new Set(declaredKeys(definition));
|
|
816
|
-
const keys = /* @__PURE__ */ new Set();
|
|
817
|
-
for (const [name, endpoint] of Object.entries(definition.endpoints ?? {})) {
|
|
818
|
-
if (!called.has(name)) continue;
|
|
819
|
-
for (const key of requestKeys(endpoint.request)) if (declared.has(key)) keys.add(key);
|
|
820
|
-
}
|
|
821
|
-
mountInputCache.set(definition, keys);
|
|
822
|
-
return keys;
|
|
823
|
-
};
|
|
824
|
-
|
|
825
|
-
// src/reflect/graph.ts
|
|
826
|
-
var navTargetsOf = (definition) => {
|
|
827
|
-
const out = /* @__PURE__ */ new Set();
|
|
828
|
-
const scan = (value) => walkNodes(value, (record) => {
|
|
829
|
-
for (const key of ["push", "replace", "resetTo"]) {
|
|
830
|
-
const target = record[key];
|
|
831
|
-
if (isRecord(target) && typeof target["action"] === "string") out.add(target["action"]);
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
scan(definition.triggers ?? []);
|
|
835
|
-
scan(definition.lifecycle ?? {});
|
|
836
|
-
return [...out].sort();
|
|
837
|
-
};
|
|
838
|
-
var actionGraph = (definitions) => {
|
|
839
|
-
const defs = Array.isArray(definitions) ? [...definitions] : Object.values(definitions);
|
|
840
|
-
const known = new Set(defs.map((definition) => definition.id));
|
|
841
|
-
const dangling = /* @__PURE__ */ new Set();
|
|
842
|
-
const nodes = defs.map((definition) => {
|
|
843
|
-
const pushes = navTargetsOf(definition);
|
|
844
|
-
for (const target of pushes) if (!target.includes("{{") && !known.has(target)) dangling.add(target);
|
|
845
|
-
const usage = collectChannels(definition);
|
|
846
|
-
return { id: definition.id, pushes, emits: usage.emits, listens: usage.listens };
|
|
847
|
-
});
|
|
848
|
-
return { nodes, dangling: [...dangling].sort() };
|
|
849
|
-
};
|
|
850
|
-
|
|
851
|
-
// src/reflect/cycles.ts
|
|
852
|
-
var NAV_KEYS = ["push", "replace", "resetTo"];
|
|
853
|
-
var isLiteral = (value) => typeof value === "string" && value !== "" && !value.includes("{{");
|
|
854
|
-
var edgesOf = (definition, from, steps, known, out) => {
|
|
855
|
-
if (!Array.isArray(steps)) return;
|
|
856
|
-
for (const step of steps) {
|
|
857
|
-
if (!isRecord(step)) continue;
|
|
858
|
-
const emit = step["emit"];
|
|
859
|
-
if (isRecord(emit) && isLiteral(emit["channel"])) out.push({ from, to: `channel:${emit["channel"]}`, action: definition.id, via: "emit" });
|
|
860
|
-
if (step["reload"] === true) out.push({ from, to: `mount:${definition.id}`, action: definition.id, via: "reload" });
|
|
861
|
-
for (const key of NAV_KEYS) {
|
|
862
|
-
const nav = step[key];
|
|
863
|
-
if (isRecord(nav) && isLiteral(nav["action"]) && known.has(nav["action"])) out.push({ from, to: `mount:${nav["action"]}`, action: definition.id, via: key });
|
|
864
|
-
}
|
|
865
|
-
if (typeof step["call"] === "string") {
|
|
866
|
-
edgesOf(definition, from, step["onSuccess"], known, out);
|
|
867
|
-
edgesOf(definition, from, step["onError"], known, out);
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
};
|
|
871
|
-
var label = (node) => node.startsWith("channel:") ? node.slice("channel:".length) : `mount ${node.slice("mount:".length)}`;
|
|
872
|
-
var chainCycles = (definitions) => {
|
|
873
|
-
const defs = Array.isArray(definitions) ? [...definitions] : Object.values(definitions);
|
|
874
|
-
const known = new Set(defs.map((definition) => definition.id));
|
|
875
|
-
const edges = [];
|
|
876
|
-
for (const definition of defs) {
|
|
877
|
-
for (const trigger of definition.triggers ?? []) {
|
|
878
|
-
if (isLiteral(trigger.message)) edgesOf(definition, `channel:${trigger.message}`, trigger.do, known, edges);
|
|
879
|
-
}
|
|
880
|
-
edgesOf(definition, `mount:${definition.id}`, definition.lifecycle?.mount, known, edges);
|
|
881
|
-
}
|
|
882
|
-
const outgoing = /* @__PURE__ */ new Map();
|
|
883
|
-
for (const edge of edges) outgoing.set(edge.from, [...outgoing.get(edge.from) ?? [], edge]);
|
|
884
|
-
const index = /* @__PURE__ */ new Map();
|
|
885
|
-
const low = /* @__PURE__ */ new Map();
|
|
886
|
-
const onStack = /* @__PURE__ */ new Set();
|
|
887
|
-
const stack = [];
|
|
888
|
-
const components = [];
|
|
889
|
-
let counter = 0;
|
|
890
|
-
const connect = (node) => {
|
|
891
|
-
index.set(node, counter);
|
|
892
|
-
low.set(node, counter);
|
|
893
|
-
counter += 1;
|
|
894
|
-
stack.push(node);
|
|
895
|
-
onStack.add(node);
|
|
896
|
-
for (const edge of outgoing.get(node) ?? []) {
|
|
897
|
-
if (!index.has(edge.to)) {
|
|
898
|
-
connect(edge.to);
|
|
899
|
-
low.set(node, Math.min(low.get(node) ?? 0, low.get(edge.to) ?? 0));
|
|
900
|
-
} else if (onStack.has(edge.to)) {
|
|
901
|
-
low.set(node, Math.min(low.get(node) ?? 0, index.get(edge.to) ?? 0));
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
if (low.get(node) !== index.get(node)) return;
|
|
905
|
-
const component = [];
|
|
906
|
-
for (let top = stack.pop(); top !== void 0; top = stack.pop()) {
|
|
907
|
-
onStack.delete(top);
|
|
908
|
-
component.push(top);
|
|
909
|
-
if (top === node) break;
|
|
910
|
-
}
|
|
911
|
-
components.push(component);
|
|
912
|
-
};
|
|
913
|
-
for (const node of [...outgoing.keys()].sort()) if (!index.has(node)) connect(node);
|
|
914
|
-
const cycleIn = (component) => {
|
|
915
|
-
const members = new Set(component);
|
|
916
|
-
const start = [...component].sort()[0];
|
|
917
|
-
if (start === void 0) return void 0;
|
|
918
|
-
const via = /* @__PURE__ */ new Map();
|
|
919
|
-
const queue = [start];
|
|
920
|
-
for (let node = queue.shift(); node !== void 0; node = queue.shift()) {
|
|
921
|
-
for (const edge of outgoing.get(node) ?? []) {
|
|
922
|
-
if (!members.has(edge.to)) continue;
|
|
923
|
-
if (edge.to === start) {
|
|
924
|
-
const steps = [edge];
|
|
925
|
-
for (let back = via.get(node); back !== void 0; back = via.get(back.from)) steps.unshift(back);
|
|
926
|
-
return steps;
|
|
927
|
-
}
|
|
928
|
-
if (via.has(edge.to)) continue;
|
|
929
|
-
via.set(edge.to, edge);
|
|
930
|
-
queue.push(edge.to);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
return void 0;
|
|
934
|
-
};
|
|
935
|
-
return components.map(cycleIn).filter((steps) => steps !== void 0).map((steps) => ({
|
|
936
|
-
steps,
|
|
937
|
-
path: [label(steps[0]?.from ?? ""), ...steps.map((step) => `\u2014${step.via} (${step.action})\u2192 ${label(step.to)}`)].join(" ")
|
|
938
|
-
})).sort((a, b) => a.path.localeCompare(b.path));
|
|
939
|
-
};
|
|
940
|
-
|
|
941
|
-
// src/reflect/liveness.ts
|
|
942
|
-
var callsIn = (steps) => {
|
|
943
|
-
const names = /* @__PURE__ */ new Set();
|
|
944
|
-
walkNodes(steps, (record) => {
|
|
945
|
-
if (typeof record["call"] === "string") names.add(record["call"]);
|
|
946
|
-
});
|
|
947
|
-
return names;
|
|
948
|
-
};
|
|
949
|
-
var livenessOf = (definition) => {
|
|
950
|
-
const triggers = definition.triggers ?? [];
|
|
951
|
-
const layout = definition.layout;
|
|
952
|
-
let bound = false;
|
|
953
|
-
if (layout !== void 0 && typeof layout !== "string") {
|
|
954
|
-
walkNodes(layout, (record) => {
|
|
955
|
-
if (typeof record["component"] === "string" && record["model"] !== void 0) bound = true;
|
|
956
|
-
});
|
|
957
|
-
}
|
|
958
|
-
const opening = callsIn(definition.lifecycle ?? {});
|
|
959
|
-
const afterwards = callsIn(triggers.map((trigger) => trigger.do));
|
|
960
|
-
const endpoints = Object.entries(definition.endpoints ?? {}).map(([name, config]) => {
|
|
961
|
-
const spec = config;
|
|
962
|
-
const use = { name, onOpen: opening.has(name), later: afterwards.has(name) };
|
|
963
|
-
if (isRecord(spec) && typeof spec["fn"] === "string") return { ...use, kind: "fn" };
|
|
964
|
-
return {
|
|
965
|
-
...use,
|
|
966
|
-
kind: "http",
|
|
967
|
-
...isRecord(spec) && typeof spec["url"] === "string" ? { url: spec["url"] } : {},
|
|
968
|
-
...isRecord(spec) && spec["request"] !== void 0 ? { request: spec["request"] } : {}
|
|
969
|
-
};
|
|
970
|
-
});
|
|
971
|
-
return {
|
|
972
|
-
gestures: bound || triggers.some((trigger) => typeof trigger.event === "string"),
|
|
973
|
-
listens: [...new Set(triggers.map((trigger) => trigger.message).filter((channel) => typeof channel === "string"))].sort(),
|
|
974
|
-
endpoints,
|
|
975
|
-
opaqueLayout: typeof layout === "string"
|
|
976
|
-
};
|
|
977
|
-
};
|
|
978
|
-
|
|
979
|
-
exports.actionGraph = actionGraph;
|
|
980
|
-
exports.auditCatalog = auditCatalog;
|
|
981
|
-
exports.chainCycles = chainCycles;
|
|
982
|
-
exports.classifyAudit = classifyAudit;
|
|
983
|
-
exports.componentsOf = componentsOf;
|
|
984
|
-
exports.declaredKeys = declaredKeys;
|
|
985
|
-
exports.describeInstance = describeInstance;
|
|
986
|
-
exports.describeShell = describeShell;
|
|
987
|
-
exports.gesturedKeys = gesturedKeys;
|
|
988
|
-
exports.isRecord = isRecord;
|
|
989
|
-
exports.lifecycleKeys = lifecycleKeys;
|
|
990
|
-
exports.livenessOf = livenessOf;
|
|
991
|
-
exports.loadedKeys = loadedKeys;
|
|
992
|
-
exports.loopVarsOf = loopVarsOf;
|
|
993
|
-
exports.mountInputKeys = mountInputKeys;
|
|
994
|
-
exports.refsOf = refsOf;
|
|
995
|
-
exports.snapshotShell = snapshotShell;
|
|
996
|
-
exports.walkNodes = walkNodes;
|
|
3
|
+
var chunkTMLNVU5W_cjs = require('../chunk-TMLNVU5W.cjs');
|
|
4
|
+
var chunkIZ2UU5UL_cjs = require('../chunk-IZ2UU5UL.cjs');
|
|
5
|
+
require('../chunk-PMKWYOOX.cjs');
|
|
6
|
+
require('../chunk-KOYRJXTI.cjs');
|
|
7
|
+
require('../chunk-GV7UC3SS.cjs');
|
|
8
|
+
require('../chunk-FSUMCJAR.cjs');
|
|
9
|
+
require('../chunk-D4PUWBN6.cjs');
|
|
10
|
+
require('../chunk-KW34ZKF5.cjs');
|
|
11
|
+
require('../chunk-OE527MXF.cjs');
|
|
12
|
+
require('../chunk-Q7SFCCGT.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Object.defineProperty(exports, "actionGraph", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkTMLNVU5W_cjs.actionGraph; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "auditCatalog", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkTMLNVU5W_cjs.auditCatalog; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "chainCycles", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunkTMLNVU5W_cjs.chainCycles; }
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "classifyAudit", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return chunkTMLNVU5W_cjs.classifyAudit; }
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "componentsOf", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return chunkTMLNVU5W_cjs.componentsOf; }
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "describeInstance", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () { return chunkTMLNVU5W_cjs.describeInstance; }
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, "describeShell", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () { return chunkTMLNVU5W_cjs.describeShell; }
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "isRecord", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () { return chunkTMLNVU5W_cjs.isRecord; }
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "livenessOf", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () { return chunkTMLNVU5W_cjs.livenessOf; }
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, "loopVarsOf", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () { return chunkTMLNVU5W_cjs.loopVarsOf; }
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "refsOf", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () { return chunkTMLNVU5W_cjs.refsOf; }
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "snapshotShell", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () { return chunkTMLNVU5W_cjs.snapshotShell; }
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, "walkNodes", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () { return chunkTMLNVU5W_cjs.walkNodes; }
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "declaredKeys", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () { return chunkIZ2UU5UL_cjs.declaredKeys; }
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "gesturedKeys", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () { return chunkIZ2UU5UL_cjs.gesturedKeys; }
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, "lifecycleKeys", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () { return chunkIZ2UU5UL_cjs.lifecycleKeys; }
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "loadedKeys", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () { return chunkIZ2UU5UL_cjs.loadedKeys; }
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "mountInputKeys", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () { return chunkIZ2UU5UL_cjs.mountInputKeys; }
|
|
87
|
+
});
|
|
997
88
|
//# sourceMappingURL=index.cjs.map
|
|
998
89
|
//# sourceMappingURL=index.cjs.map
|