@wireweave/core 4.0.0-beta.13 → 4.0.0-beta.15
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/dist/app.cjs +16 -15
- package/dist/app.d.cts +4 -144
- package/dist/app.d.ts +4 -144
- package/dist/app.js +2 -1
- package/dist/chunk-24W2GEKO.js +2342 -0
- package/dist/{chunk-IMUVIIJR.cjs → chunk-H2SWIUMU.cjs} +9 -3
- package/dist/chunk-KMZXXIM2.cjs +396 -0
- package/dist/chunk-NPDSIAWT.js +389 -0
- package/dist/{chunk-FS6A6EJ4.js → chunk-NZGEUVB4.js} +75 -1330
- package/dist/{chunk-3RWGG5EC.js → chunk-UGMDBW46.js} +9 -4
- package/dist/chunk-VCHXMPZL.cjs +2356 -0
- package/dist/{chunk-4UZBGIGJ.cjs → chunk-XODYFTKU.cjs} +136 -1392
- package/dist/index-CIfur9e3.d.cts +1031 -0
- package/dist/{index-DyXaMSgd.d.cts → index-DdQv4Bu5.d.cts} +149 -1
- package/dist/index-DwGsnD0n.d.ts +1031 -0
- package/dist/{index-BGU_4N4W.d.ts → index-c4FTW7XA.d.ts} +149 -1
- package/dist/index.cjs +245 -54
- package/dist/index.d.cts +11 -188
- package/dist/index.d.ts +11 -188
- package/dist/index.js +205 -18
- package/dist/parser.cjs +9 -9
- package/dist/parser.js +1 -1
- package/dist/renderer.cjs +8 -8
- package/dist/renderer.d.cts +4 -756
- package/dist/renderer.d.ts +4 -756
- package/dist/renderer.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-4TMDPWPR.cjs +0 -186
- package/dist/chunk-5DGRIQDU.cjs +0 -824
- package/dist/chunk-JJWAFHSV.js +0 -821
- package/dist/chunk-R5WBZWBC.js +0 -180
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkVCHXMPZL_cjs = require('./chunk-VCHXMPZL.cjs');
|
|
4
|
+
var chunkH2SWIUMU_cjs = require('./chunk-H2SWIUMU.cjs');
|
|
5
5
|
var chunkETV4XYOV_cjs = require('./chunk-ETV4XYOV.cjs');
|
|
6
6
|
|
|
7
7
|
// src/ast/component-parameters.ts
|
|
@@ -42,1315 +42,6 @@ function collectParameterReferences(children) {
|
|
|
42
42
|
return found;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// src/app/v4.ts
|
|
46
|
-
var bundleBrand = /* @__PURE__ */ Symbol("AppBundle");
|
|
47
|
-
var linkedBrand = /* @__PURE__ */ Symbol("LinkedApp");
|
|
48
|
-
var bundles = /* @__PURE__ */ new WeakMap();
|
|
49
|
-
var links = /* @__PURE__ */ new WeakMap();
|
|
50
|
-
var identifiers = /^[A-Za-z_][A-Za-z0-9_-]{0,127}$/;
|
|
51
|
-
var uuids = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
52
|
-
var containers = new Set(
|
|
53
|
-
"page header main footer sidebar section row col stack relative card modal drawer accordion popover form tab nav-group list-item annotation-item".split(
|
|
54
|
-
" "
|
|
55
|
-
)
|
|
56
|
-
);
|
|
57
|
-
function textValue(value) {
|
|
58
|
-
if (typeof value === "string") return value;
|
|
59
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
60
|
-
return value === void 0 || value === null ? "" : jcs(value);
|
|
61
|
-
}
|
|
62
|
-
function object(value) {
|
|
63
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
64
|
-
}
|
|
65
|
-
function isArray(value) {
|
|
66
|
-
return Array.isArray(value);
|
|
67
|
-
}
|
|
68
|
-
function diagnostic(code, messageKey, source, details = {}, phase = "link", path = "") {
|
|
69
|
-
var _a, _b, _c;
|
|
70
|
-
return {
|
|
71
|
-
severity: "error",
|
|
72
|
-
code,
|
|
73
|
-
phase,
|
|
74
|
-
sourceId: (_a = source == null ? void 0 : source.sourceId) != null ? _a : "app",
|
|
75
|
-
start: (_b = source == null ? void 0 : source.start) != null ? _b : 0,
|
|
76
|
-
end: (_c = source == null ? void 0 : source.end) != null ? _c : 0,
|
|
77
|
-
path,
|
|
78
|
-
messageKey,
|
|
79
|
-
details,
|
|
80
|
-
related: []
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function failed(diagnostics) {
|
|
84
|
-
const sorted = diagnostics.slice().sort(
|
|
85
|
-
(a, b) => (a.sourceId < b.sourceId ? -1 : a.sourceId > b.sourceId ? 1 : 0) || a.start - b.start || (a.phase < b.phase ? -1 : a.phase > b.phase ? 1 : 0) || (a.code < b.code ? -1 : a.code > b.code ? 1 : 0)
|
|
86
|
-
);
|
|
87
|
-
if (sorted.length > 1e3) {
|
|
88
|
-
const omitted = sorted.length - 999;
|
|
89
|
-
sorted.length = 999;
|
|
90
|
-
sorted.push(diagnostic("WW_DIAGNOSTIC_LIMIT", "app.diagnostic-limit", void 0, { omitted }));
|
|
91
|
-
}
|
|
92
|
-
return { ok: false, value: null, html: null, diagnostics: sorted };
|
|
93
|
-
}
|
|
94
|
-
function jcs(value, depth = 0, ancestors = /* @__PURE__ */ new Set()) {
|
|
95
|
-
if (depth > 512) throw new TypeError("JSON nesting limit");
|
|
96
|
-
if (value === null || typeof value === "boolean" || typeof value === "string")
|
|
97
|
-
return JSON.stringify(value);
|
|
98
|
-
if (typeof value === "number") {
|
|
99
|
-
if (!Number.isFinite(value)) throw new TypeError("Non-finite JSON number");
|
|
100
|
-
return JSON.stringify(value);
|
|
101
|
-
}
|
|
102
|
-
if (typeof value !== "object" || value === null || ancestors.has(value))
|
|
103
|
-
throw new TypeError("Invalid or cyclic JSON value");
|
|
104
|
-
ancestors.add(value);
|
|
105
|
-
try {
|
|
106
|
-
if (Array.isArray(value))
|
|
107
|
-
return `[${value.map((item) => jcs(item, depth + 1, ancestors)).join(",")}]`;
|
|
108
|
-
if (Object.prototype.toString.call(value) !== "[object Object]")
|
|
109
|
-
throw new TypeError("Invalid JSON object");
|
|
110
|
-
return `{${Object.keys(value).sort().map(
|
|
111
|
-
(key) => `${JSON.stringify(key)}:${jcs(value[key], depth + 1, ancestors)}`
|
|
112
|
-
).join(",")}}`;
|
|
113
|
-
} finally {
|
|
114
|
-
ancestors.delete(value);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function freeze(value) {
|
|
118
|
-
const stack = [value];
|
|
119
|
-
while (stack.length > 0) {
|
|
120
|
-
const current = stack.pop();
|
|
121
|
-
if (current !== null && typeof current === "object" && !Object.isFrozen(current)) {
|
|
122
|
-
for (const child of Object.values(current)) stack.push(child);
|
|
123
|
-
Object.freeze(current);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return value;
|
|
127
|
-
}
|
|
128
|
-
function dsl(value) {
|
|
129
|
-
if (Array.isArray(value)) return `[${value.map(dsl).join(",")}]`;
|
|
130
|
-
if (object(value))
|
|
131
|
-
return `{${Object.entries(value).map(([key, item]) => `${JSON.stringify(key)}=${dsl(item)}`).join(",")}}`;
|
|
132
|
-
return JSON.stringify(value);
|
|
133
|
-
}
|
|
134
|
-
function plain(value) {
|
|
135
|
-
return JSON.parse(jcs(value));
|
|
136
|
-
}
|
|
137
|
-
function sourceId(value) {
|
|
138
|
-
var _a;
|
|
139
|
-
return (_a = value.split(/[\\/]/).filter(Boolean).at(-1)) != null ? _a : "source.wf";
|
|
140
|
-
}
|
|
141
|
-
function sourceOf(value, fallback) {
|
|
142
|
-
var _a;
|
|
143
|
-
const found = (_a = chunkIMUVIIJR_cjs.getV4SourceSpan(value)) != null ? _a : fallback;
|
|
144
|
-
return found === void 0 ? { sourceId: "app", start: 0, end: 0, startLine: 1, startColumn: 1, endLine: 1, endColumn: 1 } : { ...found, sourceId: sourceId(found.sourceId) };
|
|
145
|
-
}
|
|
146
|
-
function createAppBundle(documents, options) {
|
|
147
|
-
if (!isArray(documents) || !object(options) || !object(options.moduleSources))
|
|
148
|
-
throw new TypeError("Parsed documents and explicit bundle options are required");
|
|
149
|
-
const diagnostics = [];
|
|
150
|
-
const modules = [];
|
|
151
|
-
const sourceByPath = /* @__PURE__ */ new Map();
|
|
152
|
-
try {
|
|
153
|
-
jcs(options);
|
|
154
|
-
if (!identifiers.test(options.id))
|
|
155
|
-
return failed([diagnostic("WW_SCHEMA", "app.invalid-id", void 0, {}, "schema")]);
|
|
156
|
-
const configuration = chunkIMUVIIJR_cjs.parseV4(
|
|
157
|
-
`app ${options.id} entry=${dsl(options.entry)} profile=${dsl(options.profile)} states=${dsl(options.states)} registry=${dsl(options.registry)} fixtures=${dsl(options.fixtures)} {}`,
|
|
158
|
-
{ languageVersion: "4.0.0", sourceId: "app" }
|
|
159
|
-
);
|
|
160
|
-
for (const document2 of documents) {
|
|
161
|
-
if (document2.languageVersion !== "4.0.0" || document2.schemaVersion !== "1.0.0" || !isArray(document2.modules)) {
|
|
162
|
-
diagnostics.push(
|
|
163
|
-
diagnostic("WW_UNSUPPORTED_VERSION", "app.document-version", void 0, {}, "schema")
|
|
164
|
-
);
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
for (const module of document2.modules) {
|
|
168
|
-
const bytes = options.moduleSources[module.id];
|
|
169
|
-
if (modules.some((prior) => prior.id === module.id)) {
|
|
170
|
-
diagnostics.push(
|
|
171
|
-
diagnostic("WW_DUPLICATE_ID", "app.duplicate-module", sourceOf(module), {
|
|
172
|
-
id: module.id
|
|
173
|
-
})
|
|
174
|
-
);
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (typeof bytes !== "string") {
|
|
178
|
-
diagnostics.push(
|
|
179
|
-
diagnostic(
|
|
180
|
-
"WW_IMPORT",
|
|
181
|
-
"app.missing-source-bytes",
|
|
182
|
-
sourceOf(module),
|
|
183
|
-
{ id: module.id },
|
|
184
|
-
"import"
|
|
185
|
-
)
|
|
186
|
-
);
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
const reparsed = chunkIMUVIIJR_cjs.parseV4(bytes, { languageVersion: "4.0.0", sourceId: `${module.id}.wf` });
|
|
190
|
-
if (chunkIMUVIIJR_cjs.digestV4(bytes) !== module.sourceDigest || reparsed.modules.length !== 1 || jcs(reparsed.modules[0]) !== jcs(module)) {
|
|
191
|
-
diagnostics.push(
|
|
192
|
-
diagnostic(
|
|
193
|
-
"WW_IMPORT",
|
|
194
|
-
"app.source-content-mismatch",
|
|
195
|
-
sourceOf(module),
|
|
196
|
-
{ id: module.id },
|
|
197
|
-
"import"
|
|
198
|
-
)
|
|
199
|
-
);
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
const stack = [
|
|
203
|
-
{ value: reparsed.modules[0], path: module.id, fallback: sourceOf(reparsed.modules[0]) }
|
|
204
|
-
];
|
|
205
|
-
while (stack.length > 0) {
|
|
206
|
-
const item = stack.pop();
|
|
207
|
-
if (item.value !== null && typeof item.value === "object") {
|
|
208
|
-
const span = sourceOf(item.value, item.fallback);
|
|
209
|
-
sourceByPath.set(item.path, span);
|
|
210
|
-
for (const [key, value] of Object.entries(item.value))
|
|
211
|
-
stack.push({ value, path: `${item.path}/${key}`, fallback: span });
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
modules.push(plain(module));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (modules.length === 0 || modules.length > 256)
|
|
218
|
-
diagnostics.push(diagnostic("WW_LIMIT", "app.module-count", void 0, {}, "schema"));
|
|
219
|
-
for (const id of Object.keys(options.moduleSources))
|
|
220
|
-
if (!modules.some((module) => module.id === id)) {
|
|
221
|
-
diagnostics.push(
|
|
222
|
-
diagnostic("WW_IMPORT", "app.unselected-source", void 0, { id }, "import")
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
if (diagnostics.length > 0) return failed(diagnostics);
|
|
226
|
-
const candidate = {
|
|
227
|
-
[bundleBrand]: true,
|
|
228
|
-
schemaVersion: "1.0.0",
|
|
229
|
-
languageVersion: "4.0.0",
|
|
230
|
-
id: configuration.app.id,
|
|
231
|
-
entry: configuration.app.entry,
|
|
232
|
-
profile: configuration.app.profile,
|
|
233
|
-
states: configuration.states,
|
|
234
|
-
registry: configuration.registry,
|
|
235
|
-
fixtures: configuration.fixtures,
|
|
236
|
-
modules
|
|
237
|
-
};
|
|
238
|
-
if (new TextEncoder().encode(jcs(candidate)).byteLength > 64 * 1024 * 1024)
|
|
239
|
-
return failed([diagnostic("WW_LIMIT", "app.bundle-byte-limit")]);
|
|
240
|
-
const bundle = freeze(candidate);
|
|
241
|
-
bundles.set(bundle, { sourceByPath });
|
|
242
|
-
return { ok: true, value: bundle, diagnostics: [] };
|
|
243
|
-
} catch (error) {
|
|
244
|
-
if (error instanceof chunkIMUVIIJR_cjs.V4ParseError)
|
|
245
|
-
return failed(error.diagnostics.map((item) => ({ ...item, phase: "schema" })));
|
|
246
|
-
if (error instanceof TypeError)
|
|
247
|
-
return failed([diagnostic("WW_SCHEMA", "app.invalid-json", void 0, {}, "schema")]);
|
|
248
|
-
throw error;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
var Linker = class {
|
|
252
|
-
constructor(bundle, data) {
|
|
253
|
-
chunkETV4XYOV_cjs.__publicField(this, "bundle", bundle);
|
|
254
|
-
chunkETV4XYOV_cjs.__publicField(this, "data", data);
|
|
255
|
-
chunkETV4XYOV_cjs.__publicField(this, "diagnostics", []);
|
|
256
|
-
chunkETV4XYOV_cjs.__publicField(this, "owners", /* @__PURE__ */ new Map());
|
|
257
|
-
chunkETV4XYOV_cjs.__publicField(this, "moduleById", /* @__PURE__ */ new Map());
|
|
258
|
-
chunkETV4XYOV_cjs.__publicField(this, "ownerByNode", /* @__PURE__ */ new WeakMap());
|
|
259
|
-
chunkETV4XYOV_cjs.__publicField(this, "pathByNode", /* @__PURE__ */ new WeakMap());
|
|
260
|
-
chunkETV4XYOV_cjs.__publicField(this, "expanded", []);
|
|
261
|
-
chunkETV4XYOV_cjs.__publicField(this, "screens", []);
|
|
262
|
-
chunkETV4XYOV_cjs.__publicField(this, "shells", []);
|
|
263
|
-
chunkETV4XYOV_cjs.__publicField(this, "moduleEdges", /* @__PURE__ */ new Map());
|
|
264
|
-
chunkETV4XYOV_cjs.__publicField(this, "definitionEdges", /* @__PURE__ */ new Map());
|
|
265
|
-
chunkETV4XYOV_cjs.__publicField(this, "registry", /* @__PURE__ */ new Map());
|
|
266
|
-
chunkETV4XYOV_cjs.__publicField(this, "expandedCount", 0);
|
|
267
|
-
chunkETV4XYOV_cjs.__publicField(this, "domIds", /* @__PURE__ */ new Set());
|
|
268
|
-
}
|
|
269
|
-
source(node) {
|
|
270
|
-
var _a, _b;
|
|
271
|
-
return (_b = this.data.sourceByPath.get((_a = this.pathByNode.get(node)) != null ? _a : "")) != null ? _b : sourceOf(node);
|
|
272
|
-
}
|
|
273
|
-
error(code, key, node, details = {}) {
|
|
274
|
-
var _a;
|
|
275
|
-
this.diagnostics.push(
|
|
276
|
-
diagnostic(
|
|
277
|
-
code,
|
|
278
|
-
key,
|
|
279
|
-
node === void 0 ? void 0 : this.source(node),
|
|
280
|
-
details,
|
|
281
|
-
code === "WW_IMPORT" ? "import" : "link",
|
|
282
|
-
node === void 0 ? "" : (_a = this.pathByNode.get(node)) != null ? _a : ""
|
|
283
|
-
)
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
key(namespace, kind, id) {
|
|
287
|
-
return `${namespace}/${kind}/${id}`;
|
|
288
|
-
}
|
|
289
|
-
walk(root, visit, rootPath) {
|
|
290
|
-
const stack = [{ node: root, path: rootPath }];
|
|
291
|
-
while (stack.length > 0) {
|
|
292
|
-
const { node, path } = stack.pop();
|
|
293
|
-
visit(node, path);
|
|
294
|
-
if (node.kind === "use") {
|
|
295
|
-
for (let i = node.fills.length - 1; i >= 0; i--)
|
|
296
|
-
for (let j = node.fills[i].children.length - 1; j >= 0; j--)
|
|
297
|
-
stack.push({
|
|
298
|
-
node: node.fills[i].children[j],
|
|
299
|
-
path: `${path}/fills/${i}/children/${j}`
|
|
300
|
-
});
|
|
301
|
-
} else if ("children" in node)
|
|
302
|
-
for (let i = node.children.length - 1; i >= 0; i--)
|
|
303
|
-
stack.push({ node: node.children[i], path: `${path}/children/${i}` });
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
index() {
|
|
307
|
-
const namespaces = /* @__PURE__ */ new Set();
|
|
308
|
-
for (const module of this.bundle.modules) {
|
|
309
|
-
this.pathByNode.set(module, module.id);
|
|
310
|
-
this.moduleById.set(module.id, module);
|
|
311
|
-
if (namespaces.has(module.namespace))
|
|
312
|
-
this.error("WW_DUPLICATE_ID", "app.duplicate-namespace", module, {
|
|
313
|
-
namespace: module.namespace
|
|
314
|
-
});
|
|
315
|
-
namespaces.add(module.namespace);
|
|
316
|
-
for (const [index, definition] of module.definitions.entries()) {
|
|
317
|
-
const id = definition.id;
|
|
318
|
-
if (id === void 0) {
|
|
319
|
-
this.error("WW_REFERENCE", "app.page-id-required", module);
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
const key = this.key(module.namespace, definition.kind, id);
|
|
323
|
-
const owner = { module, definition, key };
|
|
324
|
-
this.walk(
|
|
325
|
-
definition,
|
|
326
|
-
(node, path) => {
|
|
327
|
-
this.ownerByNode.set(node, owner);
|
|
328
|
-
this.pathByNode.set(node, path);
|
|
329
|
-
},
|
|
330
|
-
`${module.id}/definitions/${index}`
|
|
331
|
-
);
|
|
332
|
-
if (this.owners.has(key))
|
|
333
|
-
this.error("WW_DUPLICATE_ID", "app.duplicate-definition", definition, { id });
|
|
334
|
-
else this.owners.set(key, owner);
|
|
335
|
-
const localIds = /* @__PURE__ */ new Set();
|
|
336
|
-
this.walk(
|
|
337
|
-
definition,
|
|
338
|
-
(node) => {
|
|
339
|
-
if ("id" in node && node.id !== void 0) {
|
|
340
|
-
if (localIds.has(node.id))
|
|
341
|
-
this.error("WW_DUPLICATE_ID", "app.duplicate-local-id", node, { id: node.id });
|
|
342
|
-
localIds.add(node.id);
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
""
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
resolve(owner, kind, id, alias, node = owner.definition) {
|
|
351
|
-
let namespace = owner.module.namespace;
|
|
352
|
-
if (alias !== void 0) {
|
|
353
|
-
const imported = owner.module.imports.find((item) => item.namespace === alias);
|
|
354
|
-
const target2 = imported === void 0 ? void 0 : this.moduleById.get(imported.moduleId);
|
|
355
|
-
if (target2 === void 0 || imported === void 0 || !imported.symbols.some((symbol) => symbol.kind === kind && symbol.id === id)) {
|
|
356
|
-
this.error("WW_REFERENCE", "app.unimported-symbol", node, { kind, id, namespace: alias });
|
|
357
|
-
return void 0;
|
|
358
|
-
}
|
|
359
|
-
namespace = target2.namespace;
|
|
360
|
-
}
|
|
361
|
-
const target = this.owners.get(this.key(namespace, kind, id));
|
|
362
|
-
if (target === void 0)
|
|
363
|
-
this.error("WW_REFERENCE", "app.missing-symbol", node, { kind, id, namespace });
|
|
364
|
-
return target;
|
|
365
|
-
}
|
|
366
|
-
imports() {
|
|
367
|
-
for (const module of this.bundle.modules) {
|
|
368
|
-
const aliases = /* @__PURE__ */ new Set();
|
|
369
|
-
const edges = [];
|
|
370
|
-
for (const [index, imported] of module.imports.entries()) {
|
|
371
|
-
this.pathByNode.set(imported, `${module.id}/imports/${index}`);
|
|
372
|
-
if (aliases.has(imported.namespace))
|
|
373
|
-
this.error("WW_DUPLICATE_ID", "app.duplicate-import-alias", imported);
|
|
374
|
-
aliases.add(imported.namespace);
|
|
375
|
-
const target = this.moduleById.get(imported.moduleId);
|
|
376
|
-
if (target === void 0 || target.sourceDigest !== imported.digest) {
|
|
377
|
-
this.error("WW_IMPORT", "app.import-digest-or-module", imported);
|
|
378
|
-
continue;
|
|
379
|
-
}
|
|
380
|
-
edges.push(target.id);
|
|
381
|
-
const selected = /* @__PURE__ */ new Set();
|
|
382
|
-
for (const symbol of imported.symbols) {
|
|
383
|
-
const key = `${symbol.kind}/${symbol.id}`;
|
|
384
|
-
if (selected.has(key))
|
|
385
|
-
this.error("WW_DUPLICATE_ID", "app.duplicate-import-symbol", imported);
|
|
386
|
-
selected.add(key);
|
|
387
|
-
if (!target.exports.some((entry) => entry.kind === symbol.kind && entry.id === symbol.id))
|
|
388
|
-
this.error("WW_IMPORT", "app.unexported-symbol", imported, { symbol: key });
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
const exports = /* @__PURE__ */ new Set();
|
|
392
|
-
for (const item of module.exports) {
|
|
393
|
-
const key = this.key(module.namespace, item.kind, item.id);
|
|
394
|
-
if (exports.has(key)) this.error("WW_DUPLICATE_ID", "app.duplicate-export", module);
|
|
395
|
-
exports.add(key);
|
|
396
|
-
if (!this.owners.has(key))
|
|
397
|
-
this.error("WW_IMPORT", "app.missing-export", module, { id: item.id });
|
|
398
|
-
}
|
|
399
|
-
this.moduleEdges.set(module.id, edges);
|
|
400
|
-
}
|
|
401
|
-
this.cycles(this.moduleEdges, 64);
|
|
402
|
-
}
|
|
403
|
-
cycles(edges, depthLimit) {
|
|
404
|
-
var _a, _b, _c;
|
|
405
|
-
const colors = /* @__PURE__ */ new Map();
|
|
406
|
-
for (const start of edges.keys()) {
|
|
407
|
-
if (colors.has(start)) continue;
|
|
408
|
-
const frames = [{ id: start, cursor: 0 }];
|
|
409
|
-
colors.set(start, 1);
|
|
410
|
-
while (frames.length > 0) {
|
|
411
|
-
const current = frames[frames.length - 1];
|
|
412
|
-
const neighbors = (_a = edges.get(current.id)) != null ? _a : [];
|
|
413
|
-
if (current.cursor === neighbors.length) {
|
|
414
|
-
colors.set(current.id, 2);
|
|
415
|
-
frames.pop();
|
|
416
|
-
continue;
|
|
417
|
-
}
|
|
418
|
-
const next = neighbors[current.cursor++];
|
|
419
|
-
if (colors.get(next) === 1) {
|
|
420
|
-
this.error(
|
|
421
|
-
"WW_CYCLE",
|
|
422
|
-
"app.dependency-cycle",
|
|
423
|
-
(_c = (_b = this.owners.get(current.id)) == null ? void 0 : _b.definition) != null ? _c : this.moduleById.get(current.id),
|
|
424
|
-
{ from: current.id, to: next }
|
|
425
|
-
);
|
|
426
|
-
continue;
|
|
427
|
-
}
|
|
428
|
-
if (colors.has(next)) continue;
|
|
429
|
-
if (frames.length >= depthLimit) {
|
|
430
|
-
this.error("WW_LIMIT", "app.dependency-depth", void 0, { id: next });
|
|
431
|
-
continue;
|
|
432
|
-
}
|
|
433
|
-
colors.set(next, 1);
|
|
434
|
-
frames.push({ id: next, cursor: 0 });
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
references() {
|
|
439
|
-
for (const owner of this.owners.values()) {
|
|
440
|
-
const edges = [];
|
|
441
|
-
const slots = /* @__PURE__ */ new Set();
|
|
442
|
-
this.walk(
|
|
443
|
-
owner.definition,
|
|
444
|
-
(node) => {
|
|
445
|
-
var _a;
|
|
446
|
-
if (node.kind === "use") {
|
|
447
|
-
const target = this.resolve(owner, "component", node.name, node.namespace, node);
|
|
448
|
-
if (target !== void 0) edges.push(target.key);
|
|
449
|
-
}
|
|
450
|
-
if (node.kind === "slot") {
|
|
451
|
-
const name = (_a = node.name) != null ? _a : "";
|
|
452
|
-
if (slots.has(name)) this.error("WW_SLOT", "app.duplicate-slot", node);
|
|
453
|
-
slots.add(name);
|
|
454
|
-
if (owner.definition.kind === "component" && name === "")
|
|
455
|
-
this.error("WW_SLOT", "app.component-slot-name", node);
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
""
|
|
459
|
-
);
|
|
460
|
-
if (owner.definition.kind === "layout" && (slots.size !== 1 || !slots.has("")))
|
|
461
|
-
this.error("WW_SLOT", "app.layout-slot-cardinality", owner.definition);
|
|
462
|
-
const uses = owner.definition.attributes.uses;
|
|
463
|
-
if (typeof uses === "string") {
|
|
464
|
-
if (owner.definition.kind !== "page")
|
|
465
|
-
this.error("WW_REFERENCE", "app.layout-nesting", owner.definition);
|
|
466
|
-
const [alias, id] = uses.includes("::") ? uses.split("::") : [void 0, uses];
|
|
467
|
-
const target = this.resolve(owner, "layout", id, alias);
|
|
468
|
-
if (target !== void 0) edges.push(target.key);
|
|
469
|
-
}
|
|
470
|
-
this.definitionEdges.set(owner.key, edges);
|
|
471
|
-
}
|
|
472
|
-
this.cycles(this.definitionEdges, 1e4);
|
|
473
|
-
}
|
|
474
|
-
registryChecks() {
|
|
475
|
-
const entries = this.bundle.registry.entries;
|
|
476
|
-
const sorted = entries.slice().sort((a, b) => {
|
|
477
|
-
const left = `${textValue(a.kind)}\0${textValue(a.namespace)}\0${textValue(a.id)}`;
|
|
478
|
-
const right = `${textValue(b.kind)}\0${textValue(b.namespace)}\0${textValue(b.id)}`;
|
|
479
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
480
|
-
});
|
|
481
|
-
if (jcs(entries) !== jcs(sorted) || chunkIMUVIIJR_cjs.digestV4(jcs(entries)) !== this.bundle.registry.digest)
|
|
482
|
-
this.error("WW_REGISTRY", "app.registry-digest");
|
|
483
|
-
for (const entry of entries) {
|
|
484
|
-
if (typeof entry.id !== "string" || !uuids.test(entry.id) || typeof entry.namespace !== "string" || !["Requirement", "ImplementationObligation"].includes(textValue(entry.kind))) {
|
|
485
|
-
this.error("WW_REGISTRY", "app.registry-identity");
|
|
486
|
-
continue;
|
|
487
|
-
}
|
|
488
|
-
if (this.registry.has(entry.id))
|
|
489
|
-
this.error("WW_REGISTRY", "app.duplicate-registry-id", void 0, { id: entry.id });
|
|
490
|
-
this.registry.set(entry.id, entry);
|
|
491
|
-
if (typeof entry.title !== "string" || entry.title.length === 0 || !Array.isArray(entry.acceptance) || entry.acceptance.length === 0)
|
|
492
|
-
this.error("WW_REGISTRY", "app.incomplete-requirement", void 0, { id: entry.id });
|
|
493
|
-
if (entry.kind === "ImplementationObligation") {
|
|
494
|
-
for (const field of ["trigger", "authority"])
|
|
495
|
-
if (typeof entry[field] !== "string" || entry[field].length === 0)
|
|
496
|
-
this.error("WW_REGISTRY", "app.incomplete-obligation", void 0, {
|
|
497
|
-
id: entry.id,
|
|
498
|
-
field
|
|
499
|
-
});
|
|
500
|
-
for (const field of ["preconditions", "success", "failureCases", "requirementRefs"])
|
|
501
|
-
if (!Array.isArray(entry[field]) || field !== "preconditions" && entry[field].length === 0)
|
|
502
|
-
this.error("WW_REGISTRY", "app.incomplete-obligation", void 0, {
|
|
503
|
-
id: entry.id,
|
|
504
|
-
field
|
|
505
|
-
});
|
|
506
|
-
for (const field of ["request", "response"])
|
|
507
|
-
if (!object(entry[field]) || !["schema", "not-applicable"].includes(textValue(entry[field].mode)))
|
|
508
|
-
this.error("WW_REGISTRY", "app.incomplete-obligation", void 0, {
|
|
509
|
-
id: entry.id,
|
|
510
|
-
field
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
for (const entry of entries) {
|
|
515
|
-
for (const ref of Array.isArray(entry.requirementRefs) ? entry.requirementRefs : []) {
|
|
516
|
-
const target = object(ref) ? this.registry.get(textValue(ref.id)) : void 0;
|
|
517
|
-
if ((target == null ? void 0 : target.kind) !== "Requirement" || !object(ref) || ref.namespace !== target.namespace || ref.kind !== "Requirement")
|
|
518
|
-
this.error("WW_REGISTRY", "app.obligation-requirement-reference");
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
for (const owner of this.owners.values())
|
|
522
|
-
this.walk(
|
|
523
|
-
owner.definition,
|
|
524
|
-
(node) => {
|
|
525
|
-
if (!("attributes" in node)) return;
|
|
526
|
-
this.registryRefs(node.attributes, node);
|
|
527
|
-
for (const handler of asObjects(node.attributes.on))
|
|
528
|
-
for (const operation of asObjects(handler.operations))
|
|
529
|
-
this.registryRefs(operation, node);
|
|
530
|
-
},
|
|
531
|
-
""
|
|
532
|
-
);
|
|
533
|
-
}
|
|
534
|
-
registryRefs(value, node) {
|
|
535
|
-
var _a;
|
|
536
|
-
for (const [field, kind] of [
|
|
537
|
-
["requirementRefs", "Requirement"],
|
|
538
|
-
["obligationRefs", "ImplementationObligation"]
|
|
539
|
-
]) {
|
|
540
|
-
for (const id of Array.isArray(value[field]) ? value[field] : []) {
|
|
541
|
-
if (typeof id !== "string" || ((_a = this.registry.get(id)) == null ? void 0 : _a.kind) !== kind)
|
|
542
|
-
this.error("WW_REGISTRY", "app.unresolved-registry-reference", node, { field, id });
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
binding(value) {
|
|
547
|
-
if (!object(value)) {
|
|
548
|
-
this.error("WW_REGISTRY", "app.invalid-source-binding");
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
if (value.scope === "instance" && (!object(value.instanceRoot) || !Array.isArray(value.instancePath))) {
|
|
552
|
-
this.error("WW_REGISTRY", "app.invalid-instance-binding");
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
if (!["module", "definition", "instance", "app-state"].includes(textValue(value.scope))) {
|
|
556
|
-
this.error("WW_REGISTRY", "app.invalid-source-binding");
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
if (value.scope === "app-state") {
|
|
560
|
-
if (value.appId !== this.bundle.id || !this.bundle.states.some((state) => `app:${textValue(state.id)}` === value.stateRef))
|
|
561
|
-
this.error("WW_REGISTRY", "app.unresolved-source-binding");
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
const module = this.moduleById.get(textValue(value.moduleId));
|
|
565
|
-
if (module === void 0) {
|
|
566
|
-
this.error("WW_REGISTRY", "app.unresolved-source-binding");
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
569
|
-
if (value.scope === "module") return;
|
|
570
|
-
const owner = this.owners.get(
|
|
571
|
-
this.key(module.namespace, textValue(value.definitionKind), textValue(value.definitionId))
|
|
572
|
-
);
|
|
573
|
-
if (owner === void 0) {
|
|
574
|
-
this.error("WW_REGISTRY", "app.unresolved-source-binding");
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
if (value.scope === "instance" && (value.appId !== this.bundle.id || !this.expanded.some(
|
|
578
|
-
(entry) => entry.owner === owner && jcs(entry.identity.instanceRoot) === jcs(value.instanceRoot) && jcs(entry.identity.instancePath) === jcs(value.instancePath) && (!["element", "operation"].includes(textValue(value.targetKind)) || entry.node.id === value.elementId)
|
|
579
|
-
)))
|
|
580
|
-
this.error("WW_REGISTRY", "app.unresolved-instance-binding");
|
|
581
|
-
if (value.targetKind === "definition") return;
|
|
582
|
-
if (value.targetKind === "variant") {
|
|
583
|
-
if (!Array.isArray(owner.definition.attributes.variants) || !owner.definition.attributes.variants.includes(value.variantId))
|
|
584
|
-
this.error("WW_REGISTRY", "app.unresolved-source-binding");
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
if (value.targetKind === "state") {
|
|
588
|
-
const scope = owner.definition.kind === "page" ? "screen" : owner.definition.kind === "layout" ? "shell" : "component";
|
|
589
|
-
if (!asObjects(owner.definition.attributes.states).some(
|
|
590
|
-
(state) => value.stateRef === `${scope}:${textValue(state.id)}`
|
|
591
|
-
))
|
|
592
|
-
this.error("WW_REGISTRY", "app.unresolved-source-binding");
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
let found = false;
|
|
596
|
-
this.walk(
|
|
597
|
-
owner.definition,
|
|
598
|
-
(node) => {
|
|
599
|
-
if (!("id" in node) || node.id !== value.elementId || !("attributes" in node)) return;
|
|
600
|
-
found = value.targetKind === "element" || asObjects(node.attributes.on).some(
|
|
601
|
-
(handler) => asObjects(handler.operations).some((operation) => operation.id === value.operationId)
|
|
602
|
-
);
|
|
603
|
-
},
|
|
604
|
-
""
|
|
605
|
-
);
|
|
606
|
-
if (!found) this.error("WW_REGISTRY", "app.unresolved-source-binding");
|
|
607
|
-
}
|
|
608
|
-
route(reference, node, code = "WW_REFERENCE") {
|
|
609
|
-
const target = this.owners.get(this.key(reference.namespace, "page", reference.id));
|
|
610
|
-
if (target === void 0 || reference.variant !== void 0 && (!Array.isArray(target.definition.attributes.variants) || !target.definition.attributes.variants.includes(reference.variant))) {
|
|
611
|
-
this.error(code, "app.unresolved-route", node, {
|
|
612
|
-
namespace: reference.namespace,
|
|
613
|
-
id: reference.id
|
|
614
|
-
});
|
|
615
|
-
return void 0;
|
|
616
|
-
}
|
|
617
|
-
return target;
|
|
618
|
-
}
|
|
619
|
-
frame(owner) {
|
|
620
|
-
var _a;
|
|
621
|
-
const attrs = owner.definition.attributes;
|
|
622
|
-
const { width, height } = this.bundle.profile;
|
|
623
|
-
const pair = attrs.viewport === void 0 ? null : /^(\d+)(?:x(\d+))?$/.exec(textValue(attrs.viewport));
|
|
624
|
-
const presets = {
|
|
625
|
-
"desktop-sm": [1280, 800],
|
|
626
|
-
desktop: [1440, 900],
|
|
627
|
-
"desktop-lg": [1920, 1080],
|
|
628
|
-
"desktop-xl": [2560, 1440],
|
|
629
|
-
ipad: [1024, 768],
|
|
630
|
-
"ipad-portrait": [768, 1024],
|
|
631
|
-
"ipad-pro": [1366, 1024],
|
|
632
|
-
"ipad-pro-portrait": [1024, 1366],
|
|
633
|
-
"iphone-se": [375, 667],
|
|
634
|
-
iphone14: [390, 844],
|
|
635
|
-
"iphone14-pro": [393, 852],
|
|
636
|
-
"iphone14-pro-max": [430, 932],
|
|
637
|
-
android: [360, 800],
|
|
638
|
-
"android-lg": [412, 915]
|
|
639
|
-
};
|
|
640
|
-
const device = presets[textValue(attrs.device)];
|
|
641
|
-
if (attrs.viewport !== void 0 && (pair === null || Number(pair[1]) !== width || Number((_a = pair[2]) != null ? _a : 900) !== height) || attrs.device !== void 0 && (!device || device[0] !== width || device[1] !== height) || ["w", "width"].some(
|
|
642
|
-
(key) => attrs[key] !== void 0 && attrs[key] !== width && attrs[key] !== "screen" && attrs[key] !== "full"
|
|
643
|
-
) || ["h", "height"].some(
|
|
644
|
-
(key) => attrs[key] !== void 0 && attrs[key] !== height && attrs[key] !== "screen" && attrs[key] !== "full"
|
|
645
|
-
))
|
|
646
|
-
this.error("WW_VIEWPORT", "app.incompatible-frame", owner.definition);
|
|
647
|
-
}
|
|
648
|
-
expandAll() {
|
|
649
|
-
var _a;
|
|
650
|
-
this.route(this.bundle.entry, void 0, "WW_ROUTE");
|
|
651
|
-
const pages = [...this.owners.values()].filter((owner) => owner.definition.kind === "page");
|
|
652
|
-
if (pages.length === 0 || pages.length > 2e3) this.error("WW_LIMIT", "app.screen-count");
|
|
653
|
-
for (const owner of pages) {
|
|
654
|
-
this.frame(owner);
|
|
655
|
-
const screen = {
|
|
656
|
-
owner,
|
|
657
|
-
route: { namespace: owner.module.namespace, id: owner.definition.id },
|
|
658
|
-
children: []
|
|
659
|
-
};
|
|
660
|
-
const root = { kind: "screen", ...screen.route };
|
|
661
|
-
const uses = owner.definition.attributes.uses;
|
|
662
|
-
if (typeof uses === "string") {
|
|
663
|
-
const [alias, id] = uses.includes("::") ? uses.split("::") : [void 0, uses];
|
|
664
|
-
const layout = this.resolve(owner, "layout", id, alias);
|
|
665
|
-
if (layout !== void 0) {
|
|
666
|
-
screen.shell = layout.key;
|
|
667
|
-
if (!this.shells.some((shell) => shell.owner === layout)) {
|
|
668
|
-
this.frame(layout);
|
|
669
|
-
const shellRoot = {
|
|
670
|
-
kind: "shell",
|
|
671
|
-
namespace: layout.module.namespace,
|
|
672
|
-
id: layout.definition.id,
|
|
673
|
-
profileDigest: chunkIMUVIIJR_cjs.digestV4(jcs(this.bundle.profile))
|
|
674
|
-
};
|
|
675
|
-
const children = this.expandChildren([layout.definition], {
|
|
676
|
-
owner: layout,
|
|
677
|
-
root: shellRoot,
|
|
678
|
-
path: [],
|
|
679
|
-
bindings: {},
|
|
680
|
-
fills: /* @__PURE__ */ new Map(),
|
|
681
|
-
invocationSources: [],
|
|
682
|
-
depth: 0
|
|
683
|
-
});
|
|
684
|
-
const slot = this.expanded.find((node) => node.slot && node.owner === layout);
|
|
685
|
-
this.shells.push({ owner: layout, children, slotId: (_a = slot == null ? void 0 : slot.renderedId) != null ? _a : "" });
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
screen.children = this.expandChildren([owner.definition], {
|
|
690
|
-
owner,
|
|
691
|
-
root,
|
|
692
|
-
path: [],
|
|
693
|
-
bindings: {},
|
|
694
|
-
fills: /* @__PURE__ */ new Map(),
|
|
695
|
-
invocationSources: [],
|
|
696
|
-
depth: 0
|
|
697
|
-
});
|
|
698
|
-
this.screens.push(screen);
|
|
699
|
-
if (this.expandedCount > 1e6) break;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
expandChildren(nodes, context) {
|
|
703
|
-
var _a, _b, _c, _d, _e;
|
|
704
|
-
const result = [];
|
|
705
|
-
for (const node of nodes) {
|
|
706
|
-
if (++this.expandedCount > 1e6 || context.depth > 128) {
|
|
707
|
-
this.error("WW_LIMIT", "app.expansion-limit", node);
|
|
708
|
-
break;
|
|
709
|
-
}
|
|
710
|
-
if (node.kind === "use") {
|
|
711
|
-
const target = this.resolve(context.owner, "component", node.name, node.namespace, node);
|
|
712
|
-
if (target === void 0 || target.definition.kind !== "component") continue;
|
|
713
|
-
if (this.bundle.profile.id === "neutral-app" && this.source(node).authoredId === false)
|
|
714
|
-
this.error("WW_REFERENCE", "app.invocation-id-required", node);
|
|
715
|
-
const bindings = {};
|
|
716
|
-
const parameters = target.definition.parameters;
|
|
717
|
-
for (const name of Object.keys(node.inputs))
|
|
718
|
-
if (!parameters.some((parameter) => parameter.id === name))
|
|
719
|
-
this.error("WW_PARAMETER", "app.unknown-argument", node, { name });
|
|
720
|
-
for (const parameter of parameters) {
|
|
721
|
-
const input = node.inputs[parameter.id];
|
|
722
|
-
const value = input === void 0 ? parameter.default : "literal" in input ? input.literal : context.bindings[input.param];
|
|
723
|
-
if (!matchesType(value, parameter.type))
|
|
724
|
-
this.error("WW_PARAMETER", "app.argument-type", node, {
|
|
725
|
-
name: parameter.id,
|
|
726
|
-
type: parameter.type
|
|
727
|
-
});
|
|
728
|
-
else Object.defineProperty(bindings, parameter.id, { value, enumerable: true });
|
|
729
|
-
}
|
|
730
|
-
const slots = /* @__PURE__ */ new Set();
|
|
731
|
-
this.walk(
|
|
732
|
-
target.definition,
|
|
733
|
-
(child) => {
|
|
734
|
-
var _a2;
|
|
735
|
-
if (child.kind === "slot") slots.add((_a2 = child.name) != null ? _a2 : "");
|
|
736
|
-
},
|
|
737
|
-
""
|
|
738
|
-
);
|
|
739
|
-
const fills = /* @__PURE__ */ new Map();
|
|
740
|
-
for (const fill of node.fills) {
|
|
741
|
-
if (!slots.has(fill.name))
|
|
742
|
-
this.error("WW_SLOT", "app.unknown-fill", node, { name: fill.name });
|
|
743
|
-
if (fills.has(fill.name))
|
|
744
|
-
this.error("WW_SLOT", "app.duplicate-fill", node, { name: fill.name });
|
|
745
|
-
fills.set(fill.name, { nodes: fill.children, context });
|
|
746
|
-
}
|
|
747
|
-
if (this.diagnostics.length > 0) continue;
|
|
748
|
-
const children = this.expandChildren(target.definition.children, {
|
|
749
|
-
...context,
|
|
750
|
-
owner: target,
|
|
751
|
-
bindings,
|
|
752
|
-
fills,
|
|
753
|
-
path: [...context.path, { kind: "use", id: node.id }],
|
|
754
|
-
invocationSources: [...context.invocationSources, this.source(node)],
|
|
755
|
-
depth: context.depth + 1
|
|
756
|
-
});
|
|
757
|
-
for (const child of children) result.push(child);
|
|
758
|
-
} else if (node.kind === "repeat") {
|
|
759
|
-
if (this.bundle.profile.id === "neutral-app" && node.id === void 0)
|
|
760
|
-
this.error("WW_REFERENCE", "app.repeat-id-required", node);
|
|
761
|
-
if (node.count > 0 && node.count * node.children.length + this.expandedCount > 1e6) {
|
|
762
|
-
this.error("WW_LIMIT", "app.expansion-limit", node);
|
|
763
|
-
continue;
|
|
764
|
-
}
|
|
765
|
-
for (let index = 0; index < node.count; index++) {
|
|
766
|
-
const children = this.expandChildren(node.children, {
|
|
767
|
-
...context,
|
|
768
|
-
path: [
|
|
769
|
-
...context.path,
|
|
770
|
-
{ kind: "repeat", id: (_a = node.id) != null ? _a : `_repeat_${this.source(node).start}`, index }
|
|
771
|
-
],
|
|
772
|
-
depth: context.depth + 1
|
|
773
|
-
});
|
|
774
|
-
for (const child of children) result.push(child);
|
|
775
|
-
if (this.expandedCount > 1e6) break;
|
|
776
|
-
}
|
|
777
|
-
} else if (node.kind === "slot" && context.owner.definition.kind === "component") {
|
|
778
|
-
const fill = context.fills.get((_b = node.name) != null ? _b : "");
|
|
779
|
-
if (fill !== void 0) {
|
|
780
|
-
const children = this.expandChildren(fill.nodes, {
|
|
781
|
-
...fill.context,
|
|
782
|
-
root: context.root,
|
|
783
|
-
path: context.path,
|
|
784
|
-
invocationSources: context.invocationSources,
|
|
785
|
-
depth: context.depth + 1
|
|
786
|
-
});
|
|
787
|
-
for (const child of children) result.push(child);
|
|
788
|
-
}
|
|
789
|
-
} else {
|
|
790
|
-
if (node.kind === "component" || node.kind === "layout" && node !== context.owner.definition) {
|
|
791
|
-
this.error("WW_SCHEMA", "app.nested-definition", node);
|
|
792
|
-
continue;
|
|
793
|
-
}
|
|
794
|
-
const slot = node.kind === "slot";
|
|
795
|
-
const source = this.source(node);
|
|
796
|
-
const replacement = (value) => context.owner.definition.kind === "component" ? substitute(
|
|
797
|
-
value,
|
|
798
|
-
context.bindings,
|
|
799
|
-
(name) => this.error("WW_PARAMETER", "app.unbound-parameter", node, { name })
|
|
800
|
-
) : value;
|
|
801
|
-
const authored = node;
|
|
802
|
-
const primitive = slot ? { kind: "section", attributes: {}, children: [] } : {
|
|
803
|
-
...authored,
|
|
804
|
-
...node.kind === "layout" ? { kind: "section" } : {},
|
|
805
|
-
attributes: plain(replacement(authored.attributes)),
|
|
806
|
-
...authored.label === void 0 ? {} : { label: replacement(authored.label) },
|
|
807
|
-
children: []
|
|
808
|
-
};
|
|
809
|
-
this.pathByNode.set(primitive, (_c = this.pathByNode.get(node)) != null ? _c : "");
|
|
810
|
-
if (context.owner.definition.kind === "component") this.checkSubstituted(primitive, node);
|
|
811
|
-
const identity = {
|
|
812
|
-
namespace: context.owner.module.namespace,
|
|
813
|
-
definitionKind: context.owner.definition.kind,
|
|
814
|
-
definitionId: context.owner.definition.id,
|
|
815
|
-
instanceRoot: context.root,
|
|
816
|
-
instancePath: context.path,
|
|
817
|
-
localId: (_e = primitive.id) != null ? _e : slot ? "_slot" : `_node_${chunkIMUVIIJR_cjs.digestV4((_d = this.pathByNode.get(node)) != null ? _d : textValue(source.start)).slice(7)}`
|
|
818
|
-
};
|
|
819
|
-
const renderedId = `wf-${chunkIMUVIIJR_cjs.digestV4(jcs({ identity, projectionId: this.bundle.profile.id })).slice(7)}`;
|
|
820
|
-
if (this.domIds.has(renderedId))
|
|
821
|
-
this.error("WW_DUPLICATE_ID", "app.rendered-identity-collision", node);
|
|
822
|
-
this.domIds.add(renderedId);
|
|
823
|
-
const expanded = {
|
|
824
|
-
node: primitive,
|
|
825
|
-
owner: context.owner,
|
|
826
|
-
identity,
|
|
827
|
-
renderedId,
|
|
828
|
-
source,
|
|
829
|
-
invocationSources: context.invocationSources,
|
|
830
|
-
children: [],
|
|
831
|
-
stateBindings: {},
|
|
832
|
-
...slot ? { slot: true } : {}
|
|
833
|
-
};
|
|
834
|
-
this.expanded.push(expanded);
|
|
835
|
-
if (!slot && "children" in node) {
|
|
836
|
-
expanded.children = this.expandChildren(node.children, {
|
|
837
|
-
...context,
|
|
838
|
-
depth: context.depth + 1
|
|
839
|
-
});
|
|
840
|
-
for (const child of expanded.children) child.parent = expanded;
|
|
841
|
-
}
|
|
842
|
-
result.push(expanded);
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
return result;
|
|
846
|
-
}
|
|
847
|
-
checkSubstituted(node, source) {
|
|
848
|
-
const name = node.kind === "nav-item" || node.kind === "dropdown-item" || node.kind === "list-item" || node.kind === "annotation-item" ? "item" : node.kind === "nav-group" ? "group" : node.kind;
|
|
849
|
-
const label = node.label === void 0 ? "" : ` ${dsl(node.label)}`;
|
|
850
|
-
let snippet = `${name}${node.number === void 0 ? "" : ` ${node.number}`}${label} ${attrsDsl(node.attributes)}${containers.has(node.kind) ? " {}" : ""}`;
|
|
851
|
-
if (node.kind === "table") snippet = `table ${attrsDsl(node.attributes)} {}`;
|
|
852
|
-
const parent = {
|
|
853
|
-
"nav-item": "nav",
|
|
854
|
-
"nav-group": "nav",
|
|
855
|
-
"dropdown-item": "dropdown",
|
|
856
|
-
"list-item": "list",
|
|
857
|
-
tab: "tabs",
|
|
858
|
-
option: "select",
|
|
859
|
-
"annotation-item": "annotations"
|
|
860
|
-
}[node.kind];
|
|
861
|
-
if (parent !== void 0) snippet = `${parent} { ${snippet} }`;
|
|
862
|
-
try {
|
|
863
|
-
chunkIMUVIIJR_cjs.parseV4(`page { ${snippet} }`, { languageVersion: "4.0.0" });
|
|
864
|
-
} catch (error) {
|
|
865
|
-
if (error instanceof chunkIMUVIIJR_cjs.V4ParseError)
|
|
866
|
-
this.error("WW_PARAMETER", "app.substituted-attribute-domain", source);
|
|
867
|
-
else throw error;
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
state(ref, expanded) {
|
|
871
|
-
var _a, _b, _c;
|
|
872
|
-
const [scope, id] = ref.split(":");
|
|
873
|
-
let declarations = [];
|
|
874
|
-
if (scope === "app") declarations = this.bundle.states;
|
|
875
|
-
else if (scope === "component" && expanded.owner.definition.kind === "component")
|
|
876
|
-
declarations = asObjects(expanded.owner.definition.attributes.states);
|
|
877
|
-
else if (scope === "screen" && expanded.identity.instanceRoot.kind === "screen") {
|
|
878
|
-
const root = expanded.identity.instanceRoot;
|
|
879
|
-
const owner = this.owners.get(this.key(root.namespace, "page", root.id));
|
|
880
|
-
declarations = asObjects(owner == null ? void 0 : owner.definition.attributes.states);
|
|
881
|
-
} else if (scope === "shell") {
|
|
882
|
-
const root = expanded.identity.instanceRoot;
|
|
883
|
-
const screen = root.kind === "screen" ? this.screens.find(
|
|
884
|
-
(screen2) => screen2.route.namespace === root.namespace && screen2.route.id === root.id
|
|
885
|
-
) : void 0;
|
|
886
|
-
const owner = root.kind === "shell" ? this.owners.get(this.key(root.namespace, "layout", root.id)) : this.owners.get((_a = screen == null ? void 0 : screen.shell) != null ? _a : "");
|
|
887
|
-
declarations = asObjects(owner == null ? void 0 : owner.definition.attributes.states);
|
|
888
|
-
}
|
|
889
|
-
const state = declarations.find((state2) => state2.id === id);
|
|
890
|
-
if (state === void 0) this.error("WW_STATE", "app.unresolved-state", expanded.node, { ref });
|
|
891
|
-
else {
|
|
892
|
-
const root = expanded.identity.instanceRoot;
|
|
893
|
-
const shellOwner = root.kind === "shell" ? this.owners.get(this.key(root.namespace, "layout", root.id)) : this.owners.get(
|
|
894
|
-
(_c = (_b = this.screens.find(
|
|
895
|
-
(screen) => screen.route.namespace === root.namespace && screen.route.id === root.id
|
|
896
|
-
)) == null ? void 0 : _b.shell) != null ? _c : ""
|
|
897
|
-
);
|
|
898
|
-
const stateRoot = scope === "app" ? "app" : scope === "shell" ? `shell/${shellOwner == null ? void 0 : shellOwner.module.namespace}/${shellOwner == null ? void 0 : shellOwner.definition.id}` : `${root.kind}/${root.namespace}/${root.id}`;
|
|
899
|
-
const key = scope === "app" ? ref : scope === "component" ? `${expanded.owner.key}/${jcs(root)}/${jcs(componentPath(expanded.identity.instancePath))}/${id}` : scope === "screen" ? `screen/${root.namespace}/${root.id}/${id}` : `${stateRoot}/${id}`;
|
|
900
|
-
expanded.stateBindings[ref] = {
|
|
901
|
-
key,
|
|
902
|
-
initial: state.initial,
|
|
903
|
-
type: textValue(state.type),
|
|
904
|
-
lifetime: state.lifetime === "mount" ? "mount" : "session",
|
|
905
|
-
sensitive: state.sensitive === true,
|
|
906
|
-
root: stateRoot
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
|
-
return state;
|
|
910
|
-
}
|
|
911
|
-
semantics() {
|
|
912
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
913
|
-
for (const entry of this.bundle.registry.entries)
|
|
914
|
-
for (const binding of Array.isArray(entry.bindings) ? entry.bindings : [])
|
|
915
|
-
this.binding(binding);
|
|
916
|
-
if (asObjects(this.bundle.profile.assets).length > 0 || this.bundle.profile.fontAssetId !== void 0)
|
|
917
|
-
this.error("WW_ASSET", "app.asset-decoder-unavailable");
|
|
918
|
-
const scopes = [
|
|
919
|
-
{ node: void 0, states: this.bundle.states, app: true },
|
|
920
|
-
...[...this.owners.values()].map((owner) => ({
|
|
921
|
-
node: owner.definition,
|
|
922
|
-
states: asObjects(owner.definition.attributes.states),
|
|
923
|
-
app: false
|
|
924
|
-
}))
|
|
925
|
-
];
|
|
926
|
-
for (const scope of scopes) {
|
|
927
|
-
const ids = /* @__PURE__ */ new Set();
|
|
928
|
-
for (const state of scope.states) {
|
|
929
|
-
const id = textValue(state.id);
|
|
930
|
-
if (!matchesType(state.initial, textValue(state.type)))
|
|
931
|
-
this.error("WW_STATE", "app.state-initial-type", scope.node);
|
|
932
|
-
if (ids.has(id)) this.error("WW_DUPLICATE_ID", "app.duplicate-state", scope.node, { id });
|
|
933
|
-
ids.add(id);
|
|
934
|
-
if (scope.app && state.lifetime !== "session")
|
|
935
|
-
this.error("WW_STATE", "app.app-state-lifetime", scope.node);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
const fixtureIds = /* @__PURE__ */ new Set();
|
|
939
|
-
for (const fixture of this.bundle.fixtures) {
|
|
940
|
-
const id = textValue(fixture.id);
|
|
941
|
-
if (fixtureIds.has(id))
|
|
942
|
-
this.error("WW_DUPLICATE_ID", "app.duplicate-fixture", void 0, { id });
|
|
943
|
-
fixtureIds.add(id);
|
|
944
|
-
}
|
|
945
|
-
for (const expanded of this.expanded) {
|
|
946
|
-
const { node, owner } = expanded;
|
|
947
|
-
const attrs = node.attributes;
|
|
948
|
-
const strict = this.bundle.profile.id === "neutral-app";
|
|
949
|
-
if (["row", "col", "stack"].includes(node.kind) && ["left", "right", "justify"].includes(textValue(attrs.align)))
|
|
950
|
-
this.error("WW_LAYOUT", "app.container-alignment", node);
|
|
951
|
-
if (attrs.src !== void 0 && attrs.src !== true)
|
|
952
|
-
this.error("WW_ASSET", "app.unresolved-asset", node);
|
|
953
|
-
const interactive = [
|
|
954
|
-
"input",
|
|
955
|
-
"textarea",
|
|
956
|
-
"select",
|
|
957
|
-
"checkbox",
|
|
958
|
-
"radio",
|
|
959
|
-
"switch",
|
|
960
|
-
"slider",
|
|
961
|
-
"button",
|
|
962
|
-
"link",
|
|
963
|
-
"nav-item",
|
|
964
|
-
"dropdown-item"
|
|
965
|
-
];
|
|
966
|
-
const descendants = (root) => {
|
|
967
|
-
const result = [], pending = [...root.children];
|
|
968
|
-
while (pending.length) {
|
|
969
|
-
const child = pending.pop();
|
|
970
|
-
result.push(child);
|
|
971
|
-
pending.push(...child.children);
|
|
972
|
-
}
|
|
973
|
-
return result;
|
|
974
|
-
};
|
|
975
|
-
const descend = ["form", "card", "tooltip"].includes(node.kind) || attrs.initialFocus !== void 0 || attrs.order !== void 0 ? descendants(expanded) : [];
|
|
976
|
-
if (node.kind === "form") {
|
|
977
|
-
if (descend.some((child) => child.node.kind === "form"))
|
|
978
|
-
this.error("WW_FORM", "app.nested-form", node);
|
|
979
|
-
const names = /* @__PURE__ */ new Map();
|
|
980
|
-
for (const child of descend.filter(
|
|
981
|
-
(child2) => ["input", "textarea", "select", "checkbox", "radio", "switch", "slider"].includes(
|
|
982
|
-
child2.node.kind
|
|
983
|
-
)
|
|
984
|
-
)) {
|
|
985
|
-
const name = textValue((_a = child.node.attributes.name) != null ? _a : child.node.id);
|
|
986
|
-
const previous = names.get(name);
|
|
987
|
-
if (previous && !(previous.node.kind === "radio" && child.node.kind === "radio" && jcs(previous.node.attributes.bind) === jcs(child.node.attributes.bind) && jcs(previous.node.attributes.value) !== jcs(child.node.attributes.value)))
|
|
988
|
-
this.error("WW_FORM", "app.duplicate-field-name", child.node, { name });
|
|
989
|
-
names.set(name, child);
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
if (node.kind === "card" && (attrs.on !== void 0 || attrs.navigate !== void 0) && descend.some((child) => interactive.includes(child.node.kind)))
|
|
993
|
-
this.error("WW_ACCESSIBILITY", "app.nested-interactive-card", node);
|
|
994
|
-
if (attrs.role !== void 0) {
|
|
995
|
-
const natural = {
|
|
996
|
-
button: ["button"],
|
|
997
|
-
link: ["link"],
|
|
998
|
-
image: ["img"],
|
|
999
|
-
alert: ["alert", "status"],
|
|
1000
|
-
toast: ["status", "alert"],
|
|
1001
|
-
spinner: ["status"],
|
|
1002
|
-
section: ["region"]
|
|
1003
|
-
};
|
|
1004
|
-
if (!((_b = natural[node.kind]) != null ? _b : []).includes(textValue(attrs.role)))
|
|
1005
|
-
this.error("WW_ACCESSIBILITY", "app.incompatible-role", node);
|
|
1006
|
-
}
|
|
1007
|
-
if (attrs.initialFocus !== void 0 && !descend.some(
|
|
1008
|
-
(child) => child.node.id === attrs.initialFocus && interactive.includes(child.node.kind) && child.node.attributes.disabled !== true
|
|
1009
|
-
))
|
|
1010
|
-
this.error("WW_ACCESSIBILITY", "app.invalid-initial-focus", node);
|
|
1011
|
-
if (node.kind === "tooltip" && (expanded.children.length !== 1 || descend.slice(1).some((child) => interactive.includes(child.node.kind))))
|
|
1012
|
-
this.error("WW_ACCESSIBILITY", "app.tooltip-trigger", node);
|
|
1013
|
-
if (node.kind === "tabs" && (typeof attrs.active === "boolean" || Number((_c = attrs.active) != null ? _c : 0) >= expanded.children.filter((child) => child.node.kind === "tab").length || ((_e = expanded.children.filter((child) => child.node.kind === "tab")[Number((_d = attrs.active) != null ? _d : 0)]) == null ? void 0 : _e.node.attributes.disabled) === true))
|
|
1014
|
-
this.error("WW_ACCESSIBILITY", "app.tab-selection", node);
|
|
1015
|
-
if (attrs.order !== void 0 && attrs.order !== 0 && (interactive.includes(node.kind) || descend.some((child) => interactive.includes(child.node.kind))))
|
|
1016
|
-
this.error("WW_ACCESSIBILITY", "app.visual-focus-order", node);
|
|
1017
|
-
for (const key of ["p", "px", "py", "pt", "pr", "pb", "pl", "gap"])
|
|
1018
|
-
if (attrs[key] === "auto" || (typeof attrs[key] === "number" ? Number(attrs[key]) < 0 : object(attrs[key]) && Number(attrs[key].value) < 0))
|
|
1019
|
-
this.error("WW_LAYOUT", "app.invalid-spacing", node, { key });
|
|
1020
|
-
for (const key of ["m", "my", "mt", "mr", "mb", "ml"])
|
|
1021
|
-
if (attrs[key] === "auto") this.error("WW_LAYOUT", "app.invalid-spacing", node, { key });
|
|
1022
|
-
for (const [minimum, maximum] of [
|
|
1023
|
-
["minW", "maxW"],
|
|
1024
|
-
["minH", "maxH"],
|
|
1025
|
-
["minLength", "maxLength"],
|
|
1026
|
-
["min", "max"]
|
|
1027
|
-
])
|
|
1028
|
-
if (typeof attrs[minimum] === "number" && typeof attrs[maximum] === "number" && Number(attrs[minimum]) > Number(attrs[maximum]))
|
|
1029
|
-
this.error("WW_LAYOUT", "app.inverted-bounds", node, { minimum, maximum });
|
|
1030
|
-
for (const key of ["minW", "maxW", "minH", "maxH"])
|
|
1031
|
-
if (typeof attrs[key] === "string")
|
|
1032
|
-
this.error("WW_LAYOUT", "app.bound-keyword", node, { key });
|
|
1033
|
-
if (attrs.h === "fit" || typeof attrs.flex === "number" && attrs.flex < 0 || typeof attrs.step === "number" && attrs.step <= 0)
|
|
1034
|
-
this.error("WW_LAYOUT", "app.invalid-layout-value", node);
|
|
1035
|
-
if (attrs.bold === true && attrs.weight !== void 0 && attrs.weight !== "bold" || attrs.primary === true && attrs.secondary === true || attrs.outline === true && attrs.ghost === true)
|
|
1036
|
-
this.error("WW_LAYOUT", "app.conflicting-presentation", node);
|
|
1037
|
-
if (node.kind !== "page" && (attrs.x !== void 0 || attrs.y !== void 0 || attrs.anchor !== void 0)) {
|
|
1038
|
-
let parent = expanded.parent;
|
|
1039
|
-
while (parent && parent.node.kind !== "relative") parent = parent.parent;
|
|
1040
|
-
if (!parent) this.error("WW_LAYOUT", "app.missing-relative-container", node);
|
|
1041
|
-
}
|
|
1042
|
-
if (object(attrs.h) && attrs.h.unit === "%") {
|
|
1043
|
-
const height = (_h = (_f = expanded.parent) == null ? void 0 : _f.node.attributes.h) != null ? _h : (_g = expanded.parent) == null ? void 0 : _g.node.attributes.height;
|
|
1044
|
-
if (((_i = expanded.parent) == null ? void 0 : _i.node.kind) !== "page" && (height === void 0 || height === "auto"))
|
|
1045
|
-
this.error("WW_LAYOUT", "app.indefinite-percentage-height", node);
|
|
1046
|
-
}
|
|
1047
|
-
if (strict && ["input", "textarea", "select", "checkbox", "radio", "switch", "slider", "button"].includes(
|
|
1048
|
-
node.kind
|
|
1049
|
-
) && ![node.label, attrs.label, attrs.aria, attrs["aria-label"]].some(
|
|
1050
|
-
(label) => typeof label === "string" && label.trim().length > 0
|
|
1051
|
-
))
|
|
1052
|
-
this.error("WW_ACCESSIBILITY", "app.missing-control-name", node);
|
|
1053
|
-
if (attrs.aria !== void 0 && attrs["aria-label"] !== void 0 && attrs.aria !== attrs["aria-label"])
|
|
1054
|
-
this.error("WW_ACCESSIBILITY", "app.conflicting-name", node);
|
|
1055
|
-
if (node.kind === "button" && (attrs.buttonType === "submit" || attrs.action === "submit" || attrs.form !== void 0)) {
|
|
1056
|
-
let target = expanded.parent;
|
|
1057
|
-
if (typeof attrs.form === "string")
|
|
1058
|
-
target = this.element(
|
|
1059
|
-
{
|
|
1060
|
-
scope: owner.definition.kind === "component" ? "component" : owner.definition.kind === "layout" ? "shell" : "screen",
|
|
1061
|
-
id: attrs.form
|
|
1062
|
-
},
|
|
1063
|
-
expanded
|
|
1064
|
-
);
|
|
1065
|
-
else while (target !== void 0 && target.node.kind !== "form") target = target.parent;
|
|
1066
|
-
if ((target == null ? void 0 : target.node.kind) !== "form" || target.node.id === void 0)
|
|
1067
|
-
this.error("WW_REFERENCE", "app.missing-form", node);
|
|
1068
|
-
else expanded.formTarget = target.renderedId;
|
|
1069
|
-
if (attrs.action === "submit" && attrs.buttonType !== void 0 && attrs.buttonType !== "submit")
|
|
1070
|
-
this.error("WW_EVENT", "app.conflicting-submit-button", node);
|
|
1071
|
-
}
|
|
1072
|
-
if (strict && node.id === void 0 && ["on", "bind", "navigate", "opens", "toggles", "action"].some(
|
|
1073
|
-
(key) => attrs[key] !== void 0
|
|
1074
|
-
))
|
|
1075
|
-
this.error("WW_REFERENCE", "app.addressed-id-required", node);
|
|
1076
|
-
if (attrs.navigate !== void 0) {
|
|
1077
|
-
if (typeof attrs.navigate !== "string" || !attrs.navigate.includes("::") && /^[A-Za-z][A-Za-z0-9+.-]*:/.test(attrs.navigate))
|
|
1078
|
-
this.error("WW_REFERENCE", "app.explicit-url-required", node);
|
|
1079
|
-
else {
|
|
1080
|
-
const [alias, id] = attrs.navigate.includes("::") ? attrs.navigate.split("::") : [void 0, attrs.navigate];
|
|
1081
|
-
const target = this.resolve(owner, "page", id, alias, node);
|
|
1082
|
-
if (target !== void 0)
|
|
1083
|
-
expanded.route = { namespace: target.module.namespace, id: target.definition.id };
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
if (typeof attrs.href === "string" && !safeUrl(attrs.href))
|
|
1087
|
-
this.error("WW_REFERENCE", "app.unsafe-url", node);
|
|
1088
|
-
if (attrs.action !== void 0 && !["back", "close", "submit"].includes(textValue(attrs.action)))
|
|
1089
|
-
this.error("WW_REFERENCE", "app.unknown-action", node);
|
|
1090
|
-
const shorthand = ["navigate", "opens", "toggles"].filter((key) => attrs[key] !== void 0);
|
|
1091
|
-
if (attrs.action === "back" || attrs.action === "close") shorthand.push("action");
|
|
1092
|
-
if (shorthand.length > 1 || shorthand.length > 0 && asObjects(attrs.on).some((handler) => handler.event === "click"))
|
|
1093
|
-
this.error("WW_EVENT", "app.competing-click-handlers", node);
|
|
1094
|
-
if (shorthand.length === 1) {
|
|
1095
|
-
let effect;
|
|
1096
|
-
if (expanded.route)
|
|
1097
|
-
effect = {
|
|
1098
|
-
kind: "navigate",
|
|
1099
|
-
target: { kind: "screen", screen: { ...expanded.route } },
|
|
1100
|
-
history: "push"
|
|
1101
|
-
};
|
|
1102
|
-
else if (attrs.action === "back") effect = { kind: "navigateBack" };
|
|
1103
|
-
else {
|
|
1104
|
-
const scope = owner.definition.kind === "component" ? "component" : owner.definition.kind === "layout" ? "shell" : "screen";
|
|
1105
|
-
let id = textValue((_j = attrs.opens) != null ? _j : attrs.toggles);
|
|
1106
|
-
if (attrs.action === "close") {
|
|
1107
|
-
let parent = expanded.parent;
|
|
1108
|
-
while (parent && !["modal", "drawer", "popover", "dropdown"].includes(parent.node.kind))
|
|
1109
|
-
parent = parent.parent;
|
|
1110
|
-
if (!(parent == null ? void 0 : parent.node.id)) this.error("WW_REFERENCE", "app.missing-owning-overlay", node);
|
|
1111
|
-
else id = parent.node.id;
|
|
1112
|
-
}
|
|
1113
|
-
if (id)
|
|
1114
|
-
effect = {
|
|
1115
|
-
kind: attrs.action === "close" ? "close" : attrs.toggles === void 0 ? "open" : "toggleOverlay",
|
|
1116
|
-
target: { scope, id }
|
|
1117
|
-
};
|
|
1118
|
-
}
|
|
1119
|
-
if (effect)
|
|
1120
|
-
attrs.on = [
|
|
1121
|
-
...asObjects(attrs.on),
|
|
1122
|
-
{
|
|
1123
|
-
id: "shorthand_click",
|
|
1124
|
-
event: "click",
|
|
1125
|
-
concurrency: "drop",
|
|
1126
|
-
operations: [
|
|
1127
|
-
{
|
|
1128
|
-
id: "primary_click",
|
|
1129
|
-
executionClass: "executable",
|
|
1130
|
-
effect,
|
|
1131
|
-
after: [],
|
|
1132
|
-
onFailure: "stop",
|
|
1133
|
-
obligationRefs: []
|
|
1134
|
-
}
|
|
1135
|
-
]
|
|
1136
|
-
}
|
|
1137
|
-
];
|
|
1138
|
-
}
|
|
1139
|
-
const declarationScope = owner.definition.kind === "component" ? "component" : owner.definition.kind === "layout" ? "shell" : "screen";
|
|
1140
|
-
for (const declaration of asObjects(owner.definition.attributes.states))
|
|
1141
|
-
this.state(`${declarationScope}:${textValue(declaration.id)}`, expanded);
|
|
1142
|
-
const stack = [attrs];
|
|
1143
|
-
while (stack.length > 0) {
|
|
1144
|
-
const value = stack.pop();
|
|
1145
|
-
if (Array.isArray(value)) {
|
|
1146
|
-
for (const item of value) stack.push(item);
|
|
1147
|
-
continue;
|
|
1148
|
-
}
|
|
1149
|
-
if (!object(value)) continue;
|
|
1150
|
-
if (typeof value.state === "string") this.state(value.state, expanded);
|
|
1151
|
-
for (const key of ["resultState", "statusState", "errorState", "source", "target"])
|
|
1152
|
-
if (typeof value[key] === "string" && /^(app|shell|screen|component):/.test(value[key]))
|
|
1153
|
-
this.state(value[key], expanded);
|
|
1154
|
-
if (object(value.read) && Array.isArray(value.read.path) && value.read.path.some(
|
|
1155
|
-
(part) => ["__proto__", "constructor", "prototype"].includes(textValue(part))
|
|
1156
|
-
))
|
|
1157
|
-
this.error("WW_EFFECT", "app.unsafe-read-path", node);
|
|
1158
|
-
for (const [key, child] of Object.entries(value))
|
|
1159
|
-
if (!["literal", "initial", "states", "options"].includes(key)) stack.push(child);
|
|
1160
|
-
}
|
|
1161
|
-
if (object(attrs.bind)) {
|
|
1162
|
-
const state = this.state(textValue(attrs.bind.state), expanded);
|
|
1163
|
-
if (state !== void 0 && (attrs.bind.property === "checked" && state.type !== "boolean" || attrs.bind.property === "value" && !["number", "string", "boolean"].includes(textValue(state.type))))
|
|
1164
|
-
this.error("WW_STATE", "app.binding-type", node);
|
|
1165
|
-
}
|
|
1166
|
-
if (object(attrs.data) && typeof attrs.data.state === "string") {
|
|
1167
|
-
const state = this.state(attrs.data.state, expanded);
|
|
1168
|
-
if (state !== void 0) {
|
|
1169
|
-
const rows = state.initial;
|
|
1170
|
-
const columns = Array.isArray(attrs.columns) ? attrs.columns : [];
|
|
1171
|
-
if (!Array.isArray(rows) || node.kind === "table" && rows.some(
|
|
1172
|
-
(row) => !object(row) || columns.some(
|
|
1173
|
-
(column) => typeof column !== "string" || !Object.hasOwn(row, column) || row[column] !== null && !["string", "number", "boolean"].includes(typeof row[column])
|
|
1174
|
-
)
|
|
1175
|
-
))
|
|
1176
|
-
this.error("WW_STATE", "app.bound-data-shape", node);
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
const handlerIds = /* @__PURE__ */ new Set(), events = /* @__PURE__ */ new Set(), operationIds = /* @__PURE__ */ new Set();
|
|
1180
|
-
for (const handler of asObjects(attrs.on)) {
|
|
1181
|
-
const event = `${textValue(handler.event)}/${textValue((_k = handler.key) != null ? _k : "")}`;
|
|
1182
|
-
if (handlerIds.has(textValue(handler.id)) || events.has(event))
|
|
1183
|
-
this.error("WW_DUPLICATE_ID", "app.duplicate-handler", node);
|
|
1184
|
-
handlerIds.add(textValue(handler.id));
|
|
1185
|
-
events.add(event);
|
|
1186
|
-
const lifecycleOwner = node.kind === "page" || owner.definition.kind === "layout" && node.id === owner.definition.id;
|
|
1187
|
-
if (["enter", "exit"].includes(textValue(handler.event)) && !lifecycleOwner || handler.event === "submit" && node.kind !== "form")
|
|
1188
|
-
this.error("WW_EVENT", "app.event-owner", node);
|
|
1189
|
-
const previous = /* @__PURE__ */ new Set();
|
|
1190
|
-
for (const operation of asObjects(handler.operations)) {
|
|
1191
|
-
const id = textValue(operation.id);
|
|
1192
|
-
if (operationIds.has(id)) this.error("WW_DUPLICATE_ID", "app.duplicate-operation", node);
|
|
1193
|
-
operationIds.add(id);
|
|
1194
|
-
for (const dependency of Array.isArray(operation.after) ? operation.after : [])
|
|
1195
|
-
if (!previous.has(textValue(dependency)))
|
|
1196
|
-
this.error("WW_EFFECT", "app.operation-dependency", node, { id });
|
|
1197
|
-
previous.add(id);
|
|
1198
|
-
const effect = object(operation.effect) ? operation.effect : {};
|
|
1199
|
-
if (object(effect.target) && ["open", "close", "toggleOverlay", "focus", "validate"].includes(textValue(effect.kind))) {
|
|
1200
|
-
const target = this.element(effect.target, expanded);
|
|
1201
|
-
if (target === void 0 || effect.kind === "validate" && target.node.kind !== "form" || ["open", "close", "toggleOverlay"].includes(textValue(effect.kind)) && !["modal", "drawer", "popover", "dropdown", "tooltip"].includes(target.node.kind))
|
|
1202
|
-
this.error("WW_REFERENCE", "app.invalid-effect-target", node);
|
|
1203
|
-
else {
|
|
1204
|
-
(_l = expanded.effectTargets) != null ? _l : expanded.effectTargets = {};
|
|
1205
|
-
expanded.effectTargets[`${textValue(effect.target.scope)}:${textValue(effect.target.id)}`] = target.renderedId;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
if (handler.event === "exit" && (operation.executionClass !== "executable" || !["set", "reset", "toggle", "filter", "sort", "close"].includes(
|
|
1209
|
-
textValue(effect.kind)
|
|
1210
|
-
)))
|
|
1211
|
-
this.error("WW_EVENT", "app.exit-effect", node);
|
|
1212
|
-
if (effect.kind === "simulate") {
|
|
1213
|
-
const fixture = this.bundle.fixtures.find((fixture2) => fixture2.id === effect.fixtureRef);
|
|
1214
|
-
if (!fixtureIds.has(textValue(effect.fixtureRef)))
|
|
1215
|
-
this.error("WW_EFFECT", "app.missing-fixture", node);
|
|
1216
|
-
const result = expanded.stateBindings[textValue(effect.resultState)], status = expanded.stateBindings[textValue(effect.statusState)], error = expanded.stateBindings[textValue(effect.errorState)];
|
|
1217
|
-
if (!result || !status || !error || (/* @__PURE__ */ new Set([result.key, status.key, error.key])).size !== 3 || status.type !== "string" || status.initial !== "idle" || error.type !== "record" || jcs(error.initial) !== "{}")
|
|
1218
|
-
this.error("WW_EFFECT", "app.fixture-output-contract", node);
|
|
1219
|
-
else if (asObjects(fixture == null ? void 0 : fixture.steps).some(
|
|
1220
|
-
(step) => step.outcome === "success" && !matchesType(step.value, result.type)
|
|
1221
|
-
))
|
|
1222
|
-
this.error("WW_EFFECT", "app.fixture-result-type", node);
|
|
1223
|
-
}
|
|
1224
|
-
if (effect.kind === "navigate" && object(effect.target)) {
|
|
1225
|
-
if (effect.target.kind === "screen" && object(effect.target.screen))
|
|
1226
|
-
this.route(effect.target.screen, node);
|
|
1227
|
-
if (effect.target.kind === "url" && !safeUrl(textValue(effect.target.url)))
|
|
1228
|
-
this.error("WW_REFERENCE", "app.unsafe-url", node);
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
const stateKeys = new Set(this.bundle.states.map((state) => `app:${textValue(state.id)}`));
|
|
1234
|
-
for (const entry of this.expanded)
|
|
1235
|
-
for (const state of Object.values(entry.stateBindings)) stateKeys.add(state.key);
|
|
1236
|
-
if (stateKeys.size > 4096) this.error("WW_LIMIT", "app.state-count");
|
|
1237
|
-
for (const screen of this.screens) {
|
|
1238
|
-
const active = this.expanded.filter(
|
|
1239
|
-
(entry) => entry.identity.instanceRoot.kind === "screen" ? entry.identity.instanceRoot.namespace === screen.route.namespace && entry.identity.instanceRoot.id === screen.route.id : entry.owner.key === screen.shell
|
|
1240
|
-
);
|
|
1241
|
-
if (active.filter((entry) => entry.node.kind === "main").length > 1)
|
|
1242
|
-
this.error("WW_ACCESSIBILITY", "app.multiple-main-landmarks", (_m = screen.children[0]) == null ? void 0 : _m.node);
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
element(ref, source) {
|
|
1246
|
-
const kind = ref.scope === "screen" ? "page" : ref.scope === "shell" ? "layout" : "component";
|
|
1247
|
-
const candidates = this.expanded.filter(
|
|
1248
|
-
(entry) => entry.node.id === ref.id && entry.owner.definition.kind === kind && (kind === "component" ? entry.owner === source.owner : true) && jcs(entry.identity.instanceRoot) === jcs(source.identity.instanceRoot) && entry.identity.instancePath.length <= source.identity.instancePath.length && entry.identity.instancePath.every(
|
|
1249
|
-
(step, index) => jcs(step) === jcs(source.identity.instancePath[index])
|
|
1250
|
-
)
|
|
1251
|
-
);
|
|
1252
|
-
candidates.sort((a, b) => b.identity.instancePath.length - a.identity.instancePath.length);
|
|
1253
|
-
return candidates[0];
|
|
1254
|
-
}
|
|
1255
|
-
};
|
|
1256
|
-
function matchesType(value, type) {
|
|
1257
|
-
return type === "record" ? object(value) : type === "list" ? Array.isArray(value) : typeof value === type;
|
|
1258
|
-
}
|
|
1259
|
-
function componentPath(path) {
|
|
1260
|
-
for (let index = path.length - 1; index >= 0; index--)
|
|
1261
|
-
if (path[index].kind === "use") return path.slice(0, index + 1);
|
|
1262
|
-
return [];
|
|
1263
|
-
}
|
|
1264
|
-
function substitute(value, bindings, missing) {
|
|
1265
|
-
if (typeof value === "string") {
|
|
1266
|
-
if (value.startsWith("$$")) return value.slice(1);
|
|
1267
|
-
const match = /^\$([A-Za-z_][A-Za-z0-9_-]*)$/.exec(value);
|
|
1268
|
-
if (match === null) return value;
|
|
1269
|
-
if (!Object.hasOwn(bindings, match[1])) {
|
|
1270
|
-
missing(match[1]);
|
|
1271
|
-
return value;
|
|
1272
|
-
}
|
|
1273
|
-
return bindings[match[1]];
|
|
1274
|
-
}
|
|
1275
|
-
if (Array.isArray(value)) return value.map((item) => substitute(item, bindings, missing));
|
|
1276
|
-
if (object(value)) {
|
|
1277
|
-
if (typeof value.param === "string" && Object.keys(value).length === 1) {
|
|
1278
|
-
if (!Object.hasOwn(bindings, value.param)) {
|
|
1279
|
-
missing(value.param);
|
|
1280
|
-
return value;
|
|
1281
|
-
}
|
|
1282
|
-
return { literal: bindings[value.param] };
|
|
1283
|
-
}
|
|
1284
|
-
return Object.fromEntries(
|
|
1285
|
-
Object.entries(value).map(([key, item]) => [key, substitute(item, bindings, missing)])
|
|
1286
|
-
);
|
|
1287
|
-
}
|
|
1288
|
-
return value;
|
|
1289
|
-
}
|
|
1290
|
-
function attrsDsl(attrs) {
|
|
1291
|
-
return Object.entries(attrs).map(([key, value]) => `${key}=${dsl(value)}`).join(" ");
|
|
1292
|
-
}
|
|
1293
|
-
function safeUrl(value) {
|
|
1294
|
-
if ([...value].some((character) => character.charCodeAt(0) <= 32 || character.charCodeAt(0) === 127))
|
|
1295
|
-
return false;
|
|
1296
|
-
try {
|
|
1297
|
-
const url = new URL(value);
|
|
1298
|
-
return ["https:", "http:", "mailto:", "tel:"].includes(url.protocol) && !url.username && !url.password;
|
|
1299
|
-
} catch {
|
|
1300
|
-
return false;
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
function asObjects(value) {
|
|
1304
|
-
return Array.isArray(value) ? value.filter(object) : [];
|
|
1305
|
-
}
|
|
1306
|
-
function linkAppV4(bundle) {
|
|
1307
|
-
const data = typeof bundle === "object" && bundle !== null ? bundles.get(bundle) : void 0;
|
|
1308
|
-
if (data === void 0) return failed([diagnostic("WW_SCHEMA", "app.untrusted-bundle")]);
|
|
1309
|
-
const linker = new Linker(bundle, data);
|
|
1310
|
-
linker.index();
|
|
1311
|
-
linker.imports();
|
|
1312
|
-
linker.references();
|
|
1313
|
-
linker.registryChecks();
|
|
1314
|
-
if (linker.diagnostics.length > 0) return failed(linker.diagnostics);
|
|
1315
|
-
linker.expandAll();
|
|
1316
|
-
linker.semantics();
|
|
1317
|
-
if (linker.diagnostics.length > 0) return failed(linker.diagnostics);
|
|
1318
|
-
const sourceMap = linker.expanded.map((entry) => ({
|
|
1319
|
-
renderedId: entry.renderedId,
|
|
1320
|
-
identity: entry.identity,
|
|
1321
|
-
moduleId: entry.owner.module.id,
|
|
1322
|
-
source: entry.source,
|
|
1323
|
-
invocationSources: entry.invocationSources,
|
|
1324
|
-
requirementRefs: stringArray(entry.node.attributes.requirementRefs),
|
|
1325
|
-
obligationRefs: stringArray(entry.node.attributes.obligationRefs),
|
|
1326
|
-
operationIds: asObjects(entry.node.attributes.on).flatMap(
|
|
1327
|
-
(handler) => asObjects(handler.operations).map((operation) => textValue(operation.id))
|
|
1328
|
-
)
|
|
1329
|
-
}));
|
|
1330
|
-
const linked = freeze({
|
|
1331
|
-
[linkedBrand]: true,
|
|
1332
|
-
kind: "LinkedApp",
|
|
1333
|
-
languageVersion: "4.0.0",
|
|
1334
|
-
id: bundle.id,
|
|
1335
|
-
digest: chunkIMUVIIJR_cjs.digestV4(jcs(bundle)),
|
|
1336
|
-
sourceMap
|
|
1337
|
-
});
|
|
1338
|
-
links.set(linked, {
|
|
1339
|
-
bundle,
|
|
1340
|
-
screens: linker.screens,
|
|
1341
|
-
shells: linker.shells,
|
|
1342
|
-
nodes: linker.expanded,
|
|
1343
|
-
sourceMap
|
|
1344
|
-
});
|
|
1345
|
-
return { ok: true, value: linked, diagnostics: [] };
|
|
1346
|
-
}
|
|
1347
|
-
function stringArray(value) {
|
|
1348
|
-
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
1349
|
-
}
|
|
1350
|
-
function getLinkedAppData(linked) {
|
|
1351
|
-
return typeof linked === "object" && linked !== null ? links.get(linked) : void 0;
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
45
|
// src/app/linker.ts
|
|
1355
46
|
function createAppNodeId(namespace, kind, id) {
|
|
1356
47
|
return `${encodeURIComponent(namespace)}:${kind}:${encodeURIComponent(id)}`;
|
|
@@ -1714,7 +405,7 @@ function expandNode(node, path, context) {
|
|
|
1714
405
|
return clone;
|
|
1715
406
|
}
|
|
1716
407
|
function linkApp(input, modules) {
|
|
1717
|
-
if (modules === void 0) return linkAppV4(input);
|
|
408
|
+
if (modules === void 0) return chunkVCHXMPZL_cjs.linkAppV4(input);
|
|
1718
409
|
return linkLegacyApp(input, modules);
|
|
1719
410
|
}
|
|
1720
411
|
function linkLegacyApp(manifest, modules) {
|
|
@@ -1926,7 +617,7 @@ function compileApp(document2, options = {}) {
|
|
|
1926
617
|
type: "Document",
|
|
1927
618
|
children: [...document2.layouts.map(projectLayout), ...document2.screens.map(projectScreen)]
|
|
1928
619
|
};
|
|
1929
|
-
return
|
|
620
|
+
return chunkVCHXMPZL_cjs.renderSite(projected, { ...options, annotationStyle: "neutral" });
|
|
1930
621
|
}
|
|
1931
622
|
function linkAndCompileApp(input, modules, options = {}) {
|
|
1932
623
|
if (modules === void 0) {
|
|
@@ -1938,20 +629,20 @@ function linkAndCompileApp(input, modules, options = {}) {
|
|
|
1938
629
|
return { ...linked, html: compileApp(linked.document, options) };
|
|
1939
630
|
}
|
|
1940
631
|
function escape(value) {
|
|
1941
|
-
return textValue(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
632
|
+
return chunkVCHXMPZL_cjs.textValue(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1942
633
|
}
|
|
1943
634
|
function attribute(name, value) {
|
|
1944
635
|
return value === void 0 || value === false ? "" : ` ${name}="${escape(value === true ? "" : value)}"`;
|
|
1945
636
|
}
|
|
1946
637
|
function jsonBlock(value) {
|
|
1947
|
-
return jcs(value).replace(/</g, "\\u003c");
|
|
638
|
+
return chunkVCHXMPZL_cjs.jcs(value).replace(/</g, "\\u003c");
|
|
1948
639
|
}
|
|
1949
640
|
function address(route) {
|
|
1950
641
|
return `#wf/${encodeURIComponent(route.namespace)}/${encodeURIComponent(route.id)}${route.variant === void 0 ? "" : `?variant=${encodeURIComponent(route.variant)}`}`;
|
|
1951
642
|
}
|
|
1952
643
|
function hashBase64(value) {
|
|
1953
644
|
var _a, _b;
|
|
1954
|
-
const hex =
|
|
645
|
+
const hex = chunkH2SWIUMU_cjs.digestV4(value).slice(7), alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
1955
646
|
const bytes = Array.from(
|
|
1956
647
|
{ length: 32 },
|
|
1957
648
|
(_, index) => Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16)
|
|
@@ -1969,45 +660,47 @@ var HtmlArtifact = class {
|
|
|
1969
660
|
chunkETV4XYOV_cjs.__publicField(this, "program", program);
|
|
1970
661
|
chunkETV4XYOV_cjs.__publicField(this, "unsupported", []);
|
|
1971
662
|
chunkETV4XYOV_cjs.__publicField(this, "rules", []);
|
|
663
|
+
chunkETV4XYOV_cjs.__publicField(this, "assets");
|
|
664
|
+
this.assets = chunkVCHXMPZL_cjs.validateAppAssets(data.bundle.profile).assets;
|
|
1972
665
|
}
|
|
1973
666
|
node(entry) {
|
|
1974
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
667
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1975
668
|
const { node, renderedId } = entry;
|
|
1976
669
|
const attrs = node.attributes;
|
|
1977
|
-
const label = (_b = node.label) != null ? _b : textValue((_a = attrs.label) != null ? _a : "");
|
|
670
|
+
const label = (_b = node.label) != null ? _b : chunkVCHXMPZL_cjs.textValue((_a = attrs.label) != null ? _a : "");
|
|
1978
671
|
const children = () => entry.children.map((child) => this.node(child)).join("");
|
|
1979
|
-
let common = attribute("id", renderedId) + attribute("class", `wf-node wf-${node.kind} ${renderedId}`) + attribute("data-wf-kind", node.kind) + attribute("data-wf-source", entry.owner.module.id) + attribute("data-wf-identity", jcs(entry.identity)) + attribute(
|
|
672
|
+
let common = attribute("id", renderedId) + attribute("class", `wf-node wf-${node.kind} ${renderedId}`) + attribute("data-wf-kind", node.kind) + attribute("data-wf-source", entry.owner.module.id) + attribute("data-wf-identity", chunkVCHXMPZL_cjs.jcs(entry.identity)) + attribute(
|
|
1980
673
|
"data-wf-requirements",
|
|
1981
|
-
attrs.requirementRefs === void 0 ? void 0 : jcs(attrs.requirementRefs)
|
|
674
|
+
attrs.requirementRefs === void 0 ? void 0 : chunkVCHXMPZL_cjs.jcs(attrs.requirementRefs)
|
|
1982
675
|
) + attribute(
|
|
1983
676
|
"data-wf-obligations",
|
|
1984
|
-
attrs.obligationRefs === void 0 ? void 0 : jcs(attrs.obligationRefs)
|
|
1985
|
-
) + attribute("data-wf-on", attrs.on === void 0 ? void 0 : jcs(attrs.on)) + attribute("data-wf-bind", attrs.bind === void 0 ? void 0 : jcs(attrs.bind)) + attribute("data-wf-data", attrs.data === void 0 ? void 0 : jcs(attrs.data)) + attribute("data-wf-columns", attrs.columns === void 0 ? void 0 : jcs(attrs.columns)) + attribute(
|
|
677
|
+
attrs.obligationRefs === void 0 ? void 0 : chunkVCHXMPZL_cjs.jcs(attrs.obligationRefs)
|
|
678
|
+
) + attribute("data-wf-on", attrs.on === void 0 ? void 0 : chunkVCHXMPZL_cjs.jcs(attrs.on)) + attribute("data-wf-bind", attrs.bind === void 0 ? void 0 : chunkVCHXMPZL_cjs.jcs(attrs.bind)) + attribute("data-wf-data", attrs.data === void 0 ? void 0 : chunkVCHXMPZL_cjs.jcs(attrs.data)) + attribute("data-wf-columns", attrs.columns === void 0 ? void 0 : chunkVCHXMPZL_cjs.jcs(attrs.columns)) + attribute(
|
|
1986
679
|
"data-wf-targets",
|
|
1987
|
-
entry.effectTargets === void 0 ? void 0 : jcs(entry.effectTargets)
|
|
680
|
+
entry.effectTargets === void 0 ? void 0 : chunkVCHXMPZL_cjs.jcs(entry.effectTargets)
|
|
1988
681
|
) + attribute(
|
|
1989
682
|
"data-wf-visible-when",
|
|
1990
|
-
attrs.visibleWhen === void 0 ? void 0 : jcs(attrs.visibleWhen)
|
|
683
|
+
attrs.visibleWhen === void 0 ? void 0 : chunkVCHXMPZL_cjs.jcs(attrs.visibleWhen)
|
|
1991
684
|
) + attribute(
|
|
1992
685
|
"data-wf-enabled-when",
|
|
1993
|
-
attrs.enabledWhen === void 0 ? void 0 : jcs(attrs.enabledWhen)
|
|
1994
|
-
) + attribute("data-wf-when", attrs.when === void 0 ? void 0 : jcs(attrs.when)) + attribute("data-wf-state-bindings", jcs(entry.stateBindings)) + attribute("data-wf-navigate", entry.route === void 0 ? void 0 : address(entry.route)) + attribute("aria-label", (_c = attrs["aria-label"]) != null ? _c : attrs.aria) + attribute("aria-busy", attrs.loading === true ? "true" : void 0) + attribute(
|
|
686
|
+
attrs.enabledWhen === void 0 ? void 0 : chunkVCHXMPZL_cjs.jcs(attrs.enabledWhen)
|
|
687
|
+
) + attribute("data-wf-when", attrs.when === void 0 ? void 0 : chunkVCHXMPZL_cjs.jcs(attrs.when)) + attribute("data-wf-state-bindings", chunkVCHXMPZL_cjs.jcs(entry.stateBindings)) + attribute("data-wf-navigate", entry.route === void 0 ? void 0 : address(entry.route)) + attribute("aria-label", (_c = attrs["aria-label"]) != null ? _c : attrs.aria) + attribute("aria-busy", attrs.loading === true ? "true" : void 0) + attribute(
|
|
1995
688
|
"data-wf-disabled",
|
|
1996
689
|
attrs.disabled === true || attrs.loading === true ? true : void 0
|
|
1997
690
|
) + attribute("data-wf-action", attrs.action);
|
|
1998
|
-
for (const handler of asObjects(attrs.on))
|
|
1999
|
-
for (const operation of asObjects(handler.operations)) {
|
|
691
|
+
for (const handler of chunkVCHXMPZL_cjs.asObjects(attrs.on))
|
|
692
|
+
for (const operation of chunkVCHXMPZL_cjs.asObjects(handler.operations)) {
|
|
2000
693
|
if (operation.executionClass === "specified") {
|
|
2001
694
|
this.unsupported.push({
|
|
2002
695
|
renderedId,
|
|
2003
|
-
handlerId: textValue(handler.id),
|
|
2004
|
-
operationId: textValue(operation.id)
|
|
696
|
+
handlerId: chunkVCHXMPZL_cjs.textValue(handler.id),
|
|
697
|
+
operationId: chunkVCHXMPZL_cjs.textValue(operation.id)
|
|
2005
698
|
});
|
|
2006
699
|
}
|
|
2007
700
|
}
|
|
2008
701
|
if (entry.slot) return `<div${common} data-wf-slot="${escape(entry.owner.key)}"></div>`;
|
|
2009
702
|
this.layout(entry);
|
|
2010
|
-
const bound = object(attrs.bind) ? entry.stateBindings[textValue(attrs.bind.state)] : void 0;
|
|
703
|
+
const bound = chunkVCHXMPZL_cjs.object(attrs.bind) ? entry.stateBindings[chunkVCHXMPZL_cjs.textValue(attrs.bind.state)] : void 0;
|
|
2011
704
|
const value = (_d = bound == null ? void 0 : bound.initial) != null ? _d : attrs.value;
|
|
2012
705
|
const disabled = attrs.disabled === true || attrs.loading === true;
|
|
2013
706
|
const labelled = (control) => `<div class="wf-field" data-wf-field="${renderedId}">${label ? `<label for="${renderedId}">${escape(label)}</label>` : ""}${control}<span id="${renderedId}-error" role="alert" hidden></span></div>`;
|
|
@@ -2024,7 +717,7 @@ var HtmlArtifact = class {
|
|
|
2024
717
|
);
|
|
2025
718
|
if (node.kind === "select")
|
|
2026
719
|
return labelled(
|
|
2027
|
-
`<select${common}${scalarAttrs}>${asObjects(attrs.options).map(
|
|
720
|
+
`<select${common}${scalarAttrs}>${chunkVCHXMPZL_cjs.asObjects(attrs.options).map(
|
|
2028
721
|
(option) => `<option${attribute("value", option.value)}${attribute("selected", value === option.value)}${attribute("disabled", option.disabled)}>${escape(option.label)}</option>`
|
|
2029
722
|
).join("")}</select>`
|
|
2030
723
|
);
|
|
@@ -2045,12 +738,19 @@ var HtmlArtifact = class {
|
|
|
2045
738
|
return `<h${rank}${common}>${escape(label)}</h${rank}>`;
|
|
2046
739
|
}
|
|
2047
740
|
if (node.kind === "divider") return `<hr${common}>`;
|
|
2048
|
-
if (node.kind === "image")
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
741
|
+
if (node.kind === "image") {
|
|
742
|
+
const asset = typeof attrs.src === "string" ? this.assets.get(attrs.src) : void 0;
|
|
743
|
+
return asset === void 0 ? `<div${common} role="img"${attribute("aria-label", (_g = attrs.alt) != null ? _g : "Image placeholder")}></div>` : `<img${common}${attribute("src", `data:${asset.mediaType};base64,${asset.base64}`)}${attribute("alt", (_h = attrs.alt) != null ? _h : "")}>`;
|
|
744
|
+
}
|
|
745
|
+
if (node.kind === "avatar") {
|
|
746
|
+
const accessibleLabel = ((_j = (_i = attrs["aria-label"]) != null ? _i : attrs.aria) != null ? _j : label) || attrs.name || "Avatar";
|
|
747
|
+
const asset = typeof attrs.src === "string" ? this.assets.get(attrs.src) : void 0;
|
|
748
|
+
return asset === void 0 ? `<span${common}${attribute("role", "img")}${attrs["aria-label"] === void 0 && attrs.aria === void 0 ? attribute("aria-label", accessibleLabel) : ""}>${escape((_k = node.number) != null ? _k : label || attrs.name || "")}</span>` : `<span${common}${attribute("role", "img")}${attrs["aria-label"] === void 0 && attrs.aria === void 0 ? attribute("aria-label", accessibleLabel) : ""}><img${attribute("src", `data:${asset.mediaType};base64,${asset.base64}`)}${attribute("alt", accessibleLabel)}></span>`;
|
|
749
|
+
}
|
|
750
|
+
if (node.kind === "icon" || node.kind === "badge" || node.kind === "marker")
|
|
751
|
+
return `<span${common}>${escape((_l = node.number) != null ? _l : label || attrs.name || "")}</span>`;
|
|
2052
752
|
if (node.kind === "progress")
|
|
2053
|
-
return `<progress${common}${attribute("value", attrs.indeterminate === true ? void 0 : value != null ? value : 0)}${attribute("max", (
|
|
753
|
+
return `<progress${common}${attribute("value", attrs.indeterminate === true ? void 0 : value != null ? value : 0)}${attribute("max", (_m = attrs.max) != null ? _m : 100)}>${escape(label)}</progress>`;
|
|
2054
754
|
if (node.kind === "alert" || node.kind === "toast" || node.kind === "spinner")
|
|
2055
755
|
return `<p${common}${attribute("role", node.kind === "alert" ? "alert" : "status")}>${escape(label)}${attrs.dismissible === true ? `<button type="button" data-wf-event-owner="${renderedId}" aria-label="Dismiss ${escape(label)}">Dismiss</button>` : ""}</p>`;
|
|
2056
756
|
if (node.kind === "accordion")
|
|
@@ -2063,12 +763,12 @@ var HtmlArtifact = class {
|
|
|
2063
763
|
return `<div${common}>${children()}<span id="${renderedId}-tooltip" role="tooltip" hidden>${escape(label)}</span></div>`;
|
|
2064
764
|
if (node.kind === "table") {
|
|
2065
765
|
const columns = Array.isArray(attrs.columns) ? attrs.columns : [];
|
|
2066
|
-
let rows = (
|
|
2067
|
-
if (object(attrs.data)) {
|
|
2068
|
-
const initial = (
|
|
766
|
+
let rows = (_n = node.items) != null ? _n : [];
|
|
767
|
+
if (chunkVCHXMPZL_cjs.object(attrs.data)) {
|
|
768
|
+
const initial = (_o = entry.stateBindings[chunkVCHXMPZL_cjs.textValue(attrs.data.state)]) == null ? void 0 : _o.initial;
|
|
2069
769
|
if (Array.isArray(initial))
|
|
2070
770
|
rows = initial.map(
|
|
2071
|
-
(record) => columns.map((column) => object(record) ? record[textValue(column)] : null)
|
|
771
|
+
(record) => columns.map((column) => chunkVCHXMPZL_cjs.object(record) ? record[chunkVCHXMPZL_cjs.textValue(column)] : null)
|
|
2072
772
|
);
|
|
2073
773
|
}
|
|
2074
774
|
return `<table${common}><thead><tr>${columns.map((column) => `<th scope="col">${escape(column)}</th>`).join("")}</tr></thead><tbody>${rows.map((row) => `<tr>${(Array.isArray(row) ? row : []).map((cell) => `<td>${escape(cell != null ? cell : "")}</td>`).join("")}</tr>`).join("")}</tbody></table>`;
|
|
@@ -2086,7 +786,7 @@ var HtmlArtifact = class {
|
|
|
2086
786
|
}
|
|
2087
787
|
if (node.kind === "tab")
|
|
2088
788
|
return `<section${common} role="tabpanel" aria-labelledby="${renderedId}-tab" tabindex="0">${children()}</section>`;
|
|
2089
|
-
const tag = (
|
|
789
|
+
const tag = (_p = {
|
|
2090
790
|
header: "header",
|
|
2091
791
|
main: "main",
|
|
2092
792
|
footer: "footer",
|
|
@@ -2096,7 +796,7 @@ var HtmlArtifact = class {
|
|
|
2096
796
|
section: "section",
|
|
2097
797
|
page: "section",
|
|
2098
798
|
"annotation-item": "section"
|
|
2099
|
-
}[node.kind]) != null ?
|
|
799
|
+
}[node.kind]) != null ? _p : "div";
|
|
2100
800
|
if (node.kind === "page") common += ' tabindex="-1"';
|
|
2101
801
|
return `<${tag}${common}>${label ? `<span class="wf-label">${escape(label)}</span>` : ""}${children()}</${tag}>`;
|
|
2102
802
|
}
|
|
@@ -2106,9 +806,9 @@ var HtmlArtifact = class {
|
|
|
2106
806
|
const length = (value, axis, spacing = false) => {
|
|
2107
807
|
if (typeof value === "number")
|
|
2108
808
|
return `${spacing && [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20].includes(value) ? value * 4 : value}px`;
|
|
2109
|
-
if (object(value)) {
|
|
809
|
+
if (chunkVCHXMPZL_cjs.object(value)) {
|
|
2110
810
|
const amount = Number(value.value);
|
|
2111
|
-
return value.unit === "vh" ? `${amount * Number(profile.height) / 100}px` : value.unit === "vw" ? `${amount * Number(profile.width) / 100}px` : value.unit === "rem" ? `${amount * 16}px` : `${amount}${textValue(value.unit)}`;
|
|
811
|
+
return value.unit === "vh" ? `${amount * Number(profile.height) / 100}px` : value.unit === "vw" ? `${amount * Number(profile.width) / 100}px` : value.unit === "rem" ? `${amount * 16}px` : `${amount}${chunkVCHXMPZL_cjs.textValue(value.unit)}`;
|
|
2112
812
|
}
|
|
2113
813
|
return value === "full" ? "100%" : value === "screen" ? `${Number(profile[axis])}px` : value === "fit" ? "fit-content" : "auto";
|
|
2114
814
|
};
|
|
@@ -2145,10 +845,10 @@ var HtmlArtifact = class {
|
|
|
2145
845
|
if (["row", "col", "stack"].includes(kind)) {
|
|
2146
846
|
styles.push(
|
|
2147
847
|
"display:flex",
|
|
2148
|
-
`flex-direction:${textValue((_a = a.direction) != null ? _a : kind === "row" ? "row" : "column")}`,
|
|
848
|
+
`flex-direction:${chunkVCHXMPZL_cjs.textValue((_a = a.direction) != null ? _a : kind === "row" ? "row" : "column")}`,
|
|
2149
849
|
`flex-wrap:${a.wrap === true ? "wrap" : "nowrap"}`,
|
|
2150
|
-
`justify-content:${(_c = { start: "flex-start", end: "flex-end", between: "space-between", around: "space-around", evenly: "space-evenly" }[textValue(a.justify)]) != null ? _c : textValue((_b = a.justify) != null ? _b : "flex-start")}`,
|
|
2151
|
-
`align-items:${(_e = { start: "flex-start", end: "flex-end" }[textValue(a.align)]) != null ? _e : textValue((_d = a.align) != null ? _d : "stretch")}`
|
|
850
|
+
`justify-content:${(_c = { start: "flex-start", end: "flex-end", between: "space-between", around: "space-around", evenly: "space-evenly" }[chunkVCHXMPZL_cjs.textValue(a.justify)]) != null ? _c : chunkVCHXMPZL_cjs.textValue((_b = a.justify) != null ? _b : "flex-start")}`,
|
|
851
|
+
`align-items:${(_e = { start: "flex-start", end: "flex-end" }[chunkVCHXMPZL_cjs.textValue(a.align)]) != null ? _e : chunkVCHXMPZL_cjs.textValue((_d = a.align) != null ? _d : "stretch")}`
|
|
2152
852
|
);
|
|
2153
853
|
}
|
|
2154
854
|
if (a.flex !== void 0)
|
|
@@ -2166,7 +866,7 @@ var HtmlArtifact = class {
|
|
|
2166
866
|
if (a.order !== void 0) styles.push(`order:${Number(a.order)}`);
|
|
2167
867
|
if (a.scroll === true) styles.push("overflow:auto");
|
|
2168
868
|
if (kind !== "page" && (a.x !== void 0 || a.y !== void 0 || a.anchor !== void 0)) {
|
|
2169
|
-
const anchor = textValue((_i = a.anchor) != null ? _i : "top-left"), vertical = anchor === "center" ? "center" : anchor.split("-")[0], horizontal = anchor === "center" ? "center" : anchor.split("-")[1];
|
|
869
|
+
const anchor = chunkVCHXMPZL_cjs.textValue((_i = a.anchor) != null ? _i : "top-left"), vertical = anchor === "center" ? "center" : anchor.split("-")[0], horizontal = anchor === "center" ? "center" : anchor.split("-")[1];
|
|
2170
870
|
styles.push(
|
|
2171
871
|
"position:absolute",
|
|
2172
872
|
`left:calc(${horizontal === "center" ? "50%" : horizontal === "right" ? "100%" : "0%"} + ${Number((_j = a.x) != null ? _j : 0)}px)`,
|
|
@@ -2184,11 +884,11 @@ var HtmlArtifact = class {
|
|
|
2184
884
|
styles.push("background:#f4f4f5");
|
|
2185
885
|
if (a.shadow !== void 0 && a.shadow !== "none")
|
|
2186
886
|
styles.push(
|
|
2187
|
-
`box-shadow:0 ${{ sm: 1, md: 2, lg: 4, xl: 8 }[textValue(a.shadow)]}px ${{ sm: 1, md: 2, lg: 4, xl: 8 }[textValue(a.shadow)]}px #71717a`
|
|
887
|
+
`box-shadow:0 ${{ sm: 1, md: 2, lg: 4, xl: 8 }[chunkVCHXMPZL_cjs.textValue(a.shadow)]}px ${{ sm: 1, md: 2, lg: 4, xl: 8 }[chunkVCHXMPZL_cjs.textValue(a.shadow)]}px #71717a`
|
|
2188
888
|
);
|
|
2189
889
|
if (a.bold === true || a.weight !== void 0)
|
|
2190
890
|
styles.push(
|
|
2191
|
-
`font-weight:${a.bold === true ? 700 : { normal: 400, medium: 500, semibold: 600, bold: 700 }[textValue(a.weight)]}`
|
|
891
|
+
`font-weight:${a.bold === true ? 700 : { normal: 400, medium: 500, semibold: 600, bold: 700 }[chunkVCHXMPZL_cjs.textValue(a.weight)]}`
|
|
2192
892
|
);
|
|
2193
893
|
if (typeof a.size === "string") {
|
|
2194
894
|
const font = { xs: 12, sm: 14, base: 16, md: 16, lg: 18, xl: 20, "2xl": 24, "3xl": 30 }[a.size];
|
|
@@ -2201,7 +901,7 @@ var HtmlArtifact = class {
|
|
|
2201
901
|
);
|
|
2202
902
|
} else if (typeof a.size === "number") styles.push(`width:${a.size}px`, `height:${a.size}px`);
|
|
2203
903
|
if (["text", "title", "link"].includes(kind) && a.align !== void 0)
|
|
2204
|
-
styles.push(`text-align:${textValue(a.align)}`);
|
|
904
|
+
styles.push(`text-align:${chunkVCHXMPZL_cjs.textValue(a.align)}`);
|
|
2205
905
|
if (styles.length) this.rules.push(`#wireweave-app .${entry.renderedId}{${styles.join(";")}}`);
|
|
2206
906
|
}
|
|
2207
907
|
html() {
|
|
@@ -2218,7 +918,10 @@ var HtmlArtifact = class {
|
|
|
2218
918
|
return `<section data-wf-requirement="${escape(entry.id)}"><h3>${escape(entry.title)}</h3><p>${escape((_b = (_a = entry.behavior) != null ? _a : entry.trigger) != null ? _b : "")}</p></section>`;
|
|
2219
919
|
}
|
|
2220
920
|
).join("");
|
|
2221
|
-
const
|
|
921
|
+
const font = typeof bundle.profile.fontAssetId === "string" ? this.assets.get(bundle.profile.fontAssetId) : void 0;
|
|
922
|
+
const fontFace = font === void 0 ? "" : `@font-face{font-family:WireweaveProfile;src:url(data:${font.mediaType};base64,${font.base64}) format("woff2");font-display:swap}`;
|
|
923
|
+
const fontFamily = font === void 0 ? "system-ui,sans-serif" : "WireweaveProfile,system-ui,sans-serif";
|
|
924
|
+
const css = `${fontFace}#wireweave-app{font:16px/1.5 ${fontFamily};color:#18181b;background:white}#wireweave-app [hidden]{display:none!important}#wireweave-app *{box-sizing:border-box}#wireweave-app :focus-visible{outline:2px solid #18181b;outline-offset:2px}#wireweave-app button,#wireweave-app input,#wireweave-app select{min-height:24px;font:inherit}#wireweave-app .wf-row{display:flex;gap:0}#wireweave-app .wf-col{flex:1}#wireweave-app .wf-stack,#wireweave-app .wf-field{display:flex;flex-direction:column;gap:8px}#wireweave-app .wf-page,#wireweave-app [data-wf-shell]{width:${chunkVCHXMPZL_cjs.textValue(bundle.profile.width)}px;height:${chunkVCHXMPZL_cjs.textValue(bundle.profile.height)}px;overflow:auto}#wireweave-app .wf-card,#wireweave-app th,#wireweave-app td{border:1px solid #71717a;padding:8px}#wireweave-app .wf-relative{position:relative}#wireweave-app [data-wf-slot]{display:contents}${this.rules.join("")}#wireweave-app[data-wf-view=accessible] .wf-node,#wireweave-app[data-wf-view=accessible] [data-wf-shell]{position:static!important;transform:none!important;width:auto!important;height:auto!important;min-width:0!important;max-width:100%!important;min-height:0!important;overflow-wrap:anywhere;order:0!important}#wireweave-app[data-wf-view=accessible] .wf-row{flex-direction:column!important;flex-wrap:wrap!important}#wireweave-app[data-wf-view=accessible] .wf-col{flex-basis:auto!important}#wireweave-app .wf-field{min-width:0}#wireweave-app .wf-field input,#wireweave-app .wf-field textarea,#wireweave-app .wf-field select{max-width:100%}#wireweave-app [data-wf-field][hidden]{display:none!important}#wireweave-app [role=tablist]{display:flex;flex-wrap:wrap}#wireweave-app [role=tooltip]{background:#f4f4f5;border:1px solid #71717a}#wireweave-app dialog{color:#18181b;background:white;max-width:100%;max-height:100%;overflow:auto}`;
|
|
2222
925
|
const runtimeData = this.program;
|
|
2223
926
|
const csp = `default-src 'none'; script-src 'sha256-${hashBase64(NATIVE_RUNTIME)}'; style-src 'sha256-${hashBase64(css)}'; img-src data:; font-src data:; connect-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'; frame-src 'none'`;
|
|
2224
927
|
return `<!DOCTYPE html>
|
|
@@ -3602,6 +2305,7 @@ function runtimeEngine(program) {
|
|
|
3602
2305
|
append(state, null, null, null, { type: input.kind }, "busy", "history-compensation");
|
|
3603
2306
|
return state;
|
|
3604
2307
|
}
|
|
2308
|
+
state.diagnostic = null;
|
|
3605
2309
|
if (input.kind === "reset") {
|
|
3606
2310
|
reset(state);
|
|
3607
2311
|
drain(state);
|
|
@@ -3685,6 +2389,12 @@ function runtimeEngine(program) {
|
|
|
3685
2389
|
if (!node) throw Error("unknown-source");
|
|
3686
2390
|
if (!["click", "input", "change", "submit", "keydown", "focus", "blur"].includes(input.event))
|
|
3687
2391
|
throw Error("event-type");
|
|
2392
|
+
if ("value" in input) {
|
|
2393
|
+
if (input.value === void 0) throw Error("event-payload");
|
|
2394
|
+
bounded(input.value);
|
|
2395
|
+
}
|
|
2396
|
+
if ("checked" in input && typeof input.checked !== "boolean") throw Error("event-payload");
|
|
2397
|
+
if ("key" in input && typeof input.key !== "string") throw Error("event-payload");
|
|
3688
2398
|
if (input.event === "keydown" && (typeof input.key !== "string" || "value" in input || "checked" in input))
|
|
3689
2399
|
throw Error("event-payload");
|
|
3690
2400
|
if (!["input", "change", "keydown"].includes(input.event) && ("value" in input || "checked" in input || "key" in input))
|
|
@@ -3693,10 +2403,15 @@ function runtimeEngine(program) {
|
|
|
3693
2403
|
node.kind
|
|
3694
2404
|
))
|
|
3695
2405
|
throw Error("event-owner");
|
|
2406
|
+
if (["input", "change"].includes(input.event)) {
|
|
2407
|
+
const booleanControl = ["checkbox", "radio", "switch"].includes(node.kind);
|
|
2408
|
+
if ("key" in input) throw Error("event-payload");
|
|
2409
|
+
if (booleanControl && "value" in input) throw Error("event-payload");
|
|
2410
|
+
if (!booleanControl && "checked" in input) throw Error("event-payload");
|
|
2411
|
+
}
|
|
3696
2412
|
if (input.event === "submit" && node.kind !== "form") throw Error("event-owner");
|
|
3697
2413
|
const event = { type: input.event };
|
|
3698
2414
|
if (input.value !== void 0) {
|
|
3699
|
-
bounded(input.value);
|
|
3700
2415
|
event.value = input.value;
|
|
3701
2416
|
}
|
|
3702
2417
|
if (input.checked !== void 0) event.checked = input.checked;
|
|
@@ -3761,15 +2476,15 @@ var snapshotPrograms = /* @__PURE__ */ new WeakMap();
|
|
|
3761
2476
|
function runtimeProgram(linked) {
|
|
3762
2477
|
const cached = programCache.get(linked);
|
|
3763
2478
|
if (cached) return cached;
|
|
3764
|
-
const data = getLinkedAppData(linked);
|
|
2479
|
+
const data = chunkVCHXMPZL_cjs.getLinkedAppData(linked);
|
|
3765
2480
|
if (!data) throw new TypeError("Untrusted LinkedApp");
|
|
3766
2481
|
const states = {};
|
|
3767
2482
|
for (const state of data.bundle.states) {
|
|
3768
|
-
const key = `app:${textValue(state.id)}`;
|
|
2483
|
+
const key = `app:${chunkVCHXMPZL_cjs.textValue(state.id)}`;
|
|
3769
2484
|
states[key] = {
|
|
3770
2485
|
key,
|
|
3771
2486
|
initial: state.initial,
|
|
3772
|
-
type: textValue(state.type),
|
|
2487
|
+
type: chunkVCHXMPZL_cjs.textValue(state.type),
|
|
3773
2488
|
lifetime: "session",
|
|
3774
2489
|
sensitive: state.sensitive === true,
|
|
3775
2490
|
root: "app"
|
|
@@ -3781,14 +2496,14 @@ function runtimeProgram(linked) {
|
|
|
3781
2496
|
let form = entry.parent;
|
|
3782
2497
|
while (form && form.node.kind !== "form") form = form.parent;
|
|
3783
2498
|
const root = entry.identity.instanceRoot;
|
|
3784
|
-
const handlers = asObjects(entry.node.attributes.on).map((handler) => ({
|
|
3785
|
-
id: textValue(handler.id),
|
|
3786
|
-
event: textValue(handler.event),
|
|
3787
|
-
...handler.key === void 0 ? {} : { key: textValue(handler.key) },
|
|
2499
|
+
const handlers = chunkVCHXMPZL_cjs.asObjects(entry.node.attributes.on).map((handler) => ({
|
|
2500
|
+
id: chunkVCHXMPZL_cjs.textValue(handler.id),
|
|
2501
|
+
event: chunkVCHXMPZL_cjs.textValue(handler.event),
|
|
2502
|
+
...handler.key === void 0 ? {} : { key: chunkVCHXMPZL_cjs.textValue(handler.key) },
|
|
3788
2503
|
...handler.guard === void 0 ? {} : { guard: handler.guard },
|
|
3789
2504
|
concurrency: handler.concurrency === "queue" ? "queue" : "drop",
|
|
3790
|
-
operations: asObjects(handler.operations).map((operation) => ({
|
|
3791
|
-
id: textValue(operation.id),
|
|
2505
|
+
operations: chunkVCHXMPZL_cjs.asObjects(handler.operations).map((operation) => ({
|
|
2506
|
+
id: chunkVCHXMPZL_cjs.textValue(operation.id),
|
|
3792
2507
|
executionClass: operation.executionClass,
|
|
3793
2508
|
effect: operation.effect,
|
|
3794
2509
|
after: operation.after,
|
|
@@ -3823,11 +2538,16 @@ function runtimeProgram(linked) {
|
|
|
3823
2538
|
form: (_e = (_d = entry.formTarget) != null ? _d : form == null ? void 0 : form.renderedId) != null ? _e : null
|
|
3824
2539
|
};
|
|
3825
2540
|
});
|
|
3826
|
-
const
|
|
2541
|
+
const runtimeProfile = Object.fromEntries(
|
|
2542
|
+
Object.entries(data.bundle.profile).filter(
|
|
2543
|
+
([key]) => key !== "assets" && key !== "fontAssetId"
|
|
2544
|
+
)
|
|
2545
|
+
);
|
|
2546
|
+
const program = chunkVCHXMPZL_cjs.freeze({
|
|
3827
2547
|
appId: data.bundle.id,
|
|
3828
2548
|
modelDigest: linked.digest,
|
|
3829
|
-
profileDigest:
|
|
3830
|
-
profile:
|
|
2549
|
+
profileDigest: chunkH2SWIUMU_cjs.digestV4(chunkVCHXMPZL_cjs.jcs(data.bundle.profile)),
|
|
2550
|
+
profile: runtimeProfile,
|
|
3831
2551
|
entry: data.bundle.entry,
|
|
3832
2552
|
nodes: runtimeNodes,
|
|
3833
2553
|
states,
|
|
@@ -3846,11 +2566,11 @@ function runtimeProgram(linked) {
|
|
|
3846
2566
|
slot: shell.slotId
|
|
3847
2567
|
})),
|
|
3848
2568
|
fixtures: data.bundle.fixtures.map((fixture) => ({
|
|
3849
|
-
id: textValue(fixture.id),
|
|
3850
|
-
exhaustion: textValue(fixture.exhaustion),
|
|
3851
|
-
steps: asObjects(fixture.steps).map((step) => ({
|
|
2569
|
+
id: chunkVCHXMPZL_cjs.textValue(fixture.id),
|
|
2570
|
+
exhaustion: chunkVCHXMPZL_cjs.textValue(fixture.exhaustion),
|
|
2571
|
+
steps: chunkVCHXMPZL_cjs.asObjects(fixture.steps).map((step) => ({
|
|
3852
2572
|
delayMs: Number(step.delayMs),
|
|
3853
|
-
outcome: textValue(step.outcome),
|
|
2573
|
+
outcome: chunkVCHXMPZL_cjs.textValue(step.outcome),
|
|
3854
2574
|
value: step.value
|
|
3855
2575
|
}))
|
|
3856
2576
|
})),
|
|
@@ -3860,7 +2580,7 @@ function runtimeProgram(linked) {
|
|
|
3860
2580
|
return program;
|
|
3861
2581
|
}
|
|
3862
2582
|
function ownSnapshot(snapshot, program) {
|
|
3863
|
-
freeze(snapshot);
|
|
2583
|
+
chunkVCHXMPZL_cjs.freeze(snapshot);
|
|
3864
2584
|
snapshotPrograms.set(snapshot, program);
|
|
3865
2585
|
return snapshot;
|
|
3866
2586
|
}
|
|
@@ -3897,6 +2617,16 @@ function browserAdapter(engine, program) {
|
|
|
3897
2617
|
if ((node == null ? void 0 : node.kind) === "dropdown") return document.getElementById(id + "-trigger");
|
|
3898
2618
|
return element(id);
|
|
3899
2619
|
}
|
|
2620
|
+
function pendingFor(id) {
|
|
2621
|
+
for (const request of Object.values(state.requests)) {
|
|
2622
|
+
let owner2 = nodes.get(request.owner);
|
|
2623
|
+
while (owner2) {
|
|
2624
|
+
if (owner2.id === id) return true;
|
|
2625
|
+
owner2 = owner2.parent ? nodes.get(owner2.parent) : void 0;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
return false;
|
|
2629
|
+
}
|
|
3900
2630
|
function metadata(sequence) {
|
|
3901
2631
|
return { wireweave: { modelDigest: program.modelDigest, sequence } };
|
|
3902
2632
|
}
|
|
@@ -3958,11 +2688,23 @@ function browserAdapter(engine, program) {
|
|
|
3958
2688
|
root.querySelector("[data-wf-invalid-address]").textContent = state.address;
|
|
3959
2689
|
root.setAttribute("data-wf-route", state.route ? state.address : "error");
|
|
3960
2690
|
root.setAttribute("data-wf-view", state.viewMode);
|
|
3961
|
-
root.setAttribute(
|
|
2691
|
+
root.setAttribute(
|
|
2692
|
+
"aria-busy",
|
|
2693
|
+
String(state.suspended || Object.keys(state.requests).length > 0)
|
|
2694
|
+
);
|
|
3962
2695
|
for (const node of program.nodes) {
|
|
3963
2696
|
const el = element(node.id);
|
|
3964
2697
|
if (!el) continue;
|
|
3965
2698
|
el.hidden = view.visible[node.id] !== true;
|
|
2699
|
+
const pending = pendingFor(node.id);
|
|
2700
|
+
if (pending || node.attributes.loading === true) {
|
|
2701
|
+
el.setAttribute("aria-busy", "true");
|
|
2702
|
+
if (pending) el.setAttribute("data-wf-pending", "true");
|
|
2703
|
+
else el.removeAttribute("data-wf-pending");
|
|
2704
|
+
} else {
|
|
2705
|
+
el.removeAttribute("aria-busy");
|
|
2706
|
+
el.removeAttribute("data-wf-pending");
|
|
2707
|
+
}
|
|
3966
2708
|
const field = el.closest("[data-wf-field]");
|
|
3967
2709
|
if (field) field.hidden = el.hidden;
|
|
3968
2710
|
if (node.kind === "tab") {
|
|
@@ -4007,10 +2749,7 @@ function browserAdapter(engine, program) {
|
|
|
4007
2749
|
error.textContent = state.invalid[node.id] ? "Check the required input values." : "";
|
|
4008
2750
|
error.hidden = !state.invalid[node.id];
|
|
4009
2751
|
}
|
|
4010
|
-
el.setAttribute(
|
|
4011
|
-
"aria-busy",
|
|
4012
|
-
String(Object.values(state.requests).some((request) => request.owner === node.id))
|
|
4013
|
-
);
|
|
2752
|
+
el.setAttribute("aria-busy", String(pending || node.attributes.loading === true));
|
|
4014
2753
|
}
|
|
4015
2754
|
if (node.kind === "accordion")
|
|
4016
2755
|
el.open = state.expanded[node.id] === true;
|
|
@@ -4287,15 +3026,15 @@ function browserAdapter(engine, program) {
|
|
|
4287
3026
|
}
|
|
4288
3027
|
var NATIVE_RUNTIME = `(()=>{const program=JSON.parse(document.getElementById("wf-runtime-data").textContent);(${browserAdapter.toString()})((${runtimeEngine.toString()})(program),program);})();`;
|
|
4289
3028
|
function compileAppV4(linked) {
|
|
4290
|
-
const data = getLinkedAppData(linked);
|
|
3029
|
+
const data = chunkVCHXMPZL_cjs.getLinkedAppData(linked);
|
|
4291
3030
|
if (data === void 0)
|
|
4292
|
-
return failed([diagnostic("WW_SCHEMA", "app.untrusted-linked-model", void 0, {}, "compile")]);
|
|
3031
|
+
return chunkVCHXMPZL_cjs.failed([chunkVCHXMPZL_cjs.diagnostic("WW_SCHEMA", "app.untrusted-linked-model", void 0, {}, "compile")]);
|
|
4293
3032
|
if (data.artifact !== void 0) return { ok: true, value: data.artifact, diagnostics: [] };
|
|
4294
3033
|
const renderer = new HtmlArtifact(data, runtimeProgram(linked));
|
|
4295
3034
|
const html = renderer.html();
|
|
4296
3035
|
if (new TextEncoder().encode(html).byteLength > 64 * 1024 * 1024)
|
|
4297
|
-
return failed([diagnostic("WW_LIMIT", "app.html-byte-limit", void 0, {}, "compile")]);
|
|
4298
|
-
const artifact = freeze({
|
|
3036
|
+
return chunkVCHXMPZL_cjs.failed([chunkVCHXMPZL_cjs.diagnostic("WW_LIMIT", "app.html-byte-limit", void 0, {}, "compile")]);
|
|
3037
|
+
const artifact = chunkVCHXMPZL_cjs.freeze({
|
|
4299
3038
|
kind: "AppArtifact",
|
|
4300
3039
|
schemaVersion: "1.0.0",
|
|
4301
3040
|
languageVersion: "4.0.0",
|
|
@@ -4303,10 +3042,10 @@ function compileAppV4(linked) {
|
|
|
4303
3042
|
sourceMap: data.sourceMap,
|
|
4304
3043
|
mediaType: "text/html",
|
|
4305
3044
|
byteLength: new TextEncoder().encode(html).byteLength,
|
|
4306
|
-
digest:
|
|
3045
|
+
digest: chunkH2SWIUMU_cjs.digestV4(html),
|
|
4307
3046
|
modelDigest: linked.digest,
|
|
4308
|
-
profileDigest:
|
|
4309
|
-
runtimeDigest:
|
|
3047
|
+
profileDigest: chunkH2SWIUMU_cjs.digestV4(chunkVCHXMPZL_cjs.jcs(data.bundle.profile)),
|
|
3048
|
+
runtimeDigest: chunkH2SWIUMU_cjs.digestV4(NATIVE_RUNTIME),
|
|
4310
3049
|
registryDigest: data.bundle.registry.digest,
|
|
4311
3050
|
entry: data.bundle.entry,
|
|
4312
3051
|
screenIndex: data.screens.map((screen) => ({
|
|
@@ -4314,12 +3053,12 @@ function compileAppV4(linked) {
|
|
|
4314
3053
|
renderedId: screen.children[0].renderedId
|
|
4315
3054
|
})),
|
|
4316
3055
|
operationIndex: data.nodes.flatMap(
|
|
4317
|
-
(node) => asObjects(node.node.attributes.on).flatMap(
|
|
4318
|
-
(handler) => asObjects(handler.operations).map((operation) => ({
|
|
3056
|
+
(node) => chunkVCHXMPZL_cjs.asObjects(node.node.attributes.on).flatMap(
|
|
3057
|
+
(handler) => chunkVCHXMPZL_cjs.asObjects(handler.operations).map((operation) => ({
|
|
4319
3058
|
renderedId: node.renderedId,
|
|
4320
|
-
handlerId: textValue(handler.id),
|
|
4321
|
-
operationId: textValue(operation.id),
|
|
4322
|
-
executionClass: textValue(operation.executionClass),
|
|
3059
|
+
handlerId: chunkVCHXMPZL_cjs.textValue(handler.id),
|
|
3060
|
+
operationId: chunkVCHXMPZL_cjs.textValue(operation.id),
|
|
3061
|
+
executionClass: chunkVCHXMPZL_cjs.textValue(operation.executionClass),
|
|
4323
3062
|
operation
|
|
4324
3063
|
}))
|
|
4325
3064
|
)
|
|
@@ -4328,11 +3067,17 @@ function compileAppV4(linked) {
|
|
|
4328
3067
|
manifest: {
|
|
4329
3068
|
appId: data.bundle.id,
|
|
4330
3069
|
modelDigest: linked.digest,
|
|
4331
|
-
profileDigest:
|
|
3070
|
+
profileDigest: chunkH2SWIUMU_cjs.digestV4(chunkVCHXMPZL_cjs.jcs(data.bundle.profile)),
|
|
4332
3071
|
registryDigest: data.bundle.registry.digest,
|
|
4333
|
-
htmlDigest:
|
|
4334
|
-
runtimeDigest:
|
|
3072
|
+
htmlDigest: chunkH2SWIUMU_cjs.digestV4(html),
|
|
3073
|
+
runtimeDigest: chunkH2SWIUMU_cjs.digestV4(NATIVE_RUNTIME),
|
|
4335
3074
|
executionScope: "standard-1",
|
|
3075
|
+
assets: [...renderer.assets.values()].map(({ id, mediaType, digest, byteLength }) => ({
|
|
3076
|
+
id,
|
|
3077
|
+
mediaType,
|
|
3078
|
+
digest,
|
|
3079
|
+
byteLength
|
|
3080
|
+
})),
|
|
4336
3081
|
unsupportedOperations: renderer.unsupported
|
|
4337
3082
|
}
|
|
4338
3083
|
});
|
|
@@ -4347,7 +3092,6 @@ function renderSite2(bundle) {
|
|
|
4347
3092
|
exports.advanceClock = advanceClock;
|
|
4348
3093
|
exports.collectParameterReferences = collectParameterReferences;
|
|
4349
3094
|
exports.compileApp = compileApp;
|
|
4350
|
-
exports.createAppBundle = createAppBundle;
|
|
4351
3095
|
exports.createAppComponentInstanceId = createAppComponentInstanceId;
|
|
4352
3096
|
exports.createAppNodeId = createAppNodeId;
|
|
4353
3097
|
exports.createRuntime = createRuntime;
|