@brad-frost-web/eddie-render 0.67.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/cdn/eddie-render.js +242 -226
- package/cdn/eddie-render.js.map +1 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +14 -3
- package/dist/render.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +22 -4
- package/dist/validate/index.js.map +1 -1
- package/package.json +1 -1
package/cdn/eddie-render.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
1
|
+
const D = /* @__PURE__ */ new Set(["component", "children", "slots", "accessibility", "action", "metadata", "catalogId", "id"]), U = "Text";
|
|
2
|
+
function R(i) {
|
|
3
3
|
return String(i).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function te(i) {
|
|
6
6
|
return String(i).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function j(i, e) {
|
|
9
9
|
if (i && typeof i == "object" && !Array.isArray(i) && "path" in i) {
|
|
10
10
|
const t = String(i.path);
|
|
11
11
|
let n = e;
|
|
@@ -17,23 +17,23 @@ function L(i, e) {
|
|
|
17
17
|
}
|
|
18
18
|
return i;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function z(i, e) {
|
|
21
21
|
const t = [];
|
|
22
22
|
for (const [n, o] of Object.entries(i)) {
|
|
23
|
-
if (
|
|
24
|
-
const r =
|
|
23
|
+
if (D.has(n)) continue;
|
|
24
|
+
const r = j(o, e);
|
|
25
25
|
r != null && (typeof r == "string" || typeof r == "number" || typeof r == "boolean") && t.push([n, r]);
|
|
26
26
|
}
|
|
27
27
|
return t;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function Y(i, e, t) {
|
|
30
30
|
const o = (i.metadata.extensions.eddie_expansion ?? `<${i.metadata.extensions.eddie_tag}>{{children}}</${i.metadata.extensions.eddie_tag}>`).replace(/\{\{(?!children\}\})([a-zA-Z_][\w]*)\}\}/g, (a, s) => {
|
|
31
|
-
const c =
|
|
32
|
-
return c == null ? "" :
|
|
31
|
+
const c = j(e[s], t);
|
|
32
|
+
return c == null ? "" : R(c);
|
|
33
33
|
}), r = o.indexOf("{{children}}");
|
|
34
34
|
return r === -1 ? { before: o, after: "" } : { before: o.slice(0, r), after: o.slice(r + 12) };
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function B(i, e) {
|
|
37
37
|
const t = [];
|
|
38
38
|
let n = "";
|
|
39
39
|
const o = /* @__PURE__ */ new Set(), r = (s, c) => {
|
|
@@ -47,31 +47,31 @@ function Y(i, e) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}, a = (s, c, d) => {
|
|
50
|
-
const f = e.components[c.component], u = d ? ` slot="${
|
|
50
|
+
const f = e.components[c.component], u = d ? ` slot="${R(d)}"` : "";
|
|
51
51
|
if (t.push({ start: n.length, id: s }), !f) {
|
|
52
|
-
n += `<unknown data-eddie-id="${
|
|
52
|
+
n += `<unknown data-eddie-id="${R(s)}"${u}></unknown>`;
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
const g = typeof c.tagName == "string" ? c.tagName : "", p =
|
|
55
|
+
const y = f.metadata.extensions;
|
|
56
|
+
if (y.eddie_kind === "text" || c.component === U) {
|
|
57
|
+
const g = typeof c.tagName == "string" ? c.tagName : "", p = te(j(c.text, i.dataModel) ?? "");
|
|
58
58
|
n += g ? `<${g}${u}>${p}</${g}>` : p;
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
const
|
|
61
|
+
const w = () => {
|
|
62
62
|
for (const g of c.children ?? []) r(String(g));
|
|
63
63
|
for (const [g, p] of Object.entries(c.slots ?? {})) {
|
|
64
|
-
const
|
|
65
|
-
for (const
|
|
64
|
+
const S = y.eddie_slotAttrs?.[g] ?? g;
|
|
65
|
+
for (const C of p) r(String(C), S);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
if (
|
|
69
|
-
const { before: g, after: p } =
|
|
70
|
-
n += d ? g.replace(/^(<[a-zA-Z][^>\s]*)/, `$1${u}`) : g,
|
|
68
|
+
if (y.eddie_kind === "composition") {
|
|
69
|
+
const { before: g, after: p } = Y(f, c, i.dataModel);
|
|
70
|
+
n += d ? g.replace(/^(<[a-zA-Z][^>\s]*)/, `$1${u}`) : g, w(), n += p;
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
const N =
|
|
74
|
-
n += `<${
|
|
73
|
+
const N = z(c, i.dataModel).map(([g, p]) => p === !0 ? ` ${g}` : p === !1 ? "" : ` ${g}="${R(p)}"`).join("");
|
|
74
|
+
n += `<${y.eddie_tag}${N}${u}>`, w(), n += `</${y.eddie_tag}>`;
|
|
75
75
|
};
|
|
76
76
|
return i.root && r(i.root), {
|
|
77
77
|
markup: n,
|
|
@@ -82,31 +82,31 @@ function Y(i, e) {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function V() {
|
|
86
86
|
return { root: null, elements: {}, dataModel: {} };
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function L(i) {
|
|
89
89
|
return JSON.parse(JSON.stringify(i));
|
|
90
90
|
}
|
|
91
|
-
const
|
|
92
|
-
function
|
|
91
|
+
const ne = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
92
|
+
function Z(i) {
|
|
93
93
|
if (i === "" || i === "/") return [];
|
|
94
94
|
if (!i.startsWith("/")) throw new Error(`Invalid JSON Pointer "${i}": must start with "/"`);
|
|
95
95
|
const e = i.slice(1).split("/").map((t) => t.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
96
96
|
for (const t of e)
|
|
97
|
-
if (
|
|
97
|
+
if (ne.has(t)) throw new Error(`Refusing JSON Pointer segment "${t}"`);
|
|
98
98
|
return e;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function M(i, e) {
|
|
101
101
|
let t = i;
|
|
102
|
-
for (const n of
|
|
102
|
+
for (const n of Z(e)) {
|
|
103
103
|
if (t === null || typeof t != "object") return;
|
|
104
104
|
t = Array.isArray(t) ? t[Number(n)] : t[n];
|
|
105
105
|
}
|
|
106
106
|
return t;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
const n =
|
|
108
|
+
function I(i, e, t) {
|
|
109
|
+
const n = Z(e);
|
|
110
110
|
if (n.length === 0) throw new Error("Cannot set the document root by pointer");
|
|
111
111
|
let o = i;
|
|
112
112
|
for (let a = 0; a < n.length - 1; a++) {
|
|
@@ -117,7 +117,7 @@ function O(i, e, t) {
|
|
|
117
117
|
const r = n[n.length - 1];
|
|
118
118
|
Array.isArray(o) ? t === void 0 ? o.splice(Number(r), 1) : r === "-" ? o.push(t) : o[Number(r)] = t : t === void 0 ? delete o[r] : o[r] = t;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function H(i, e) {
|
|
121
121
|
const t = i;
|
|
122
122
|
switch (e.op) {
|
|
123
123
|
case "noop":
|
|
@@ -125,34 +125,34 @@ function J(i, e) {
|
|
|
125
125
|
case "add":
|
|
126
126
|
case "replace":
|
|
127
127
|
if (!e.path) throw new Error(`${e.op} needs a path`);
|
|
128
|
-
|
|
128
|
+
I(t, e.path, e.value);
|
|
129
129
|
return;
|
|
130
130
|
case "remove":
|
|
131
131
|
if (!e.path) throw new Error("remove needs a path");
|
|
132
|
-
|
|
132
|
+
I(t, e.path, void 0);
|
|
133
133
|
return;
|
|
134
134
|
case "move": {
|
|
135
135
|
if (!e.path || !e.from) throw new Error("move needs from and path");
|
|
136
|
-
const n =
|
|
137
|
-
|
|
136
|
+
const n = M(t, e.from);
|
|
137
|
+
I(t, e.from, void 0), I(t, e.path, n);
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
case "copy": {
|
|
141
141
|
if (!e.path || !e.from) throw new Error("copy needs from and path");
|
|
142
|
-
const n =
|
|
143
|
-
|
|
142
|
+
const n = M(t, e.from);
|
|
143
|
+
I(t, e.path, n === void 0 ? void 0 : JSON.parse(JSON.stringify(n)));
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
146
|
case "test": {
|
|
147
147
|
if (!e.path) throw new Error("test needs a path");
|
|
148
|
-
if (JSON.stringify(
|
|
148
|
+
if (JSON.stringify(M(t, e.path)) !== JSON.stringify(e.value)) throw new Error(`test failed at ${e.path}`);
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
default:
|
|
152
152
|
throw new Error(`Unknown patch op "${e.op}"`);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function _(i) {
|
|
156
156
|
const e = i.trim();
|
|
157
157
|
if (!e || !e.startsWith("{")) return null;
|
|
158
158
|
try {
|
|
@@ -162,8 +162,8 @@ function I(i) {
|
|
|
162
162
|
return null;
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
function
|
|
166
|
-
const e =
|
|
165
|
+
function oe(i) {
|
|
166
|
+
const e = _(i);
|
|
167
167
|
if (e) return e;
|
|
168
168
|
let t = i.trim();
|
|
169
169
|
if (!t.startsWith("{")) return null;
|
|
@@ -179,12 +179,12 @@ function ee(i) {
|
|
|
179
179
|
a === '"' ? n = !0 : a === "{" ? o.push("}") : a === "[" ? o.push("]") : (a === "}" || a === "]") && o.pop();
|
|
180
180
|
}
|
|
181
181
|
for (n && (t += '"'); o.length; ) t += o.pop();
|
|
182
|
-
return
|
|
182
|
+
return _(t);
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function me() {
|
|
185
185
|
let i = "";
|
|
186
186
|
const e = [], t = (n) => {
|
|
187
|
-
const o =
|
|
187
|
+
const o = _(n);
|
|
188
188
|
return !o && n.trim() && e.push(n), o;
|
|
189
189
|
};
|
|
190
190
|
return {
|
|
@@ -205,26 +205,26 @@ function ue() {
|
|
|
205
205
|
end() {
|
|
206
206
|
const n = i;
|
|
207
207
|
if (i = "", !n.trim()) return [];
|
|
208
|
-
const o =
|
|
208
|
+
const o = _(n) ?? oe(n);
|
|
209
209
|
return o ? [o] : (e.push(n), []);
|
|
210
210
|
}
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function ge(i, e) {
|
|
214
214
|
const t = Array.isArray(e) ? e : e.split(`
|
|
215
215
|
`), n = [], o = [];
|
|
216
216
|
for (const r of t) {
|
|
217
|
-
const a =
|
|
217
|
+
const a = _(r);
|
|
218
218
|
if (a)
|
|
219
219
|
try {
|
|
220
|
-
|
|
220
|
+
H(i, a), n.push(a);
|
|
221
221
|
} catch (s) {
|
|
222
222
|
o.push({ op: a, error: s instanceof Error ? s.message : String(s) });
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
return { applied: n, failed: o };
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function W(i) {
|
|
228
228
|
const { id: e, component: t, ...n } = i;
|
|
229
229
|
if (typeof t == "string")
|
|
230
230
|
return [e, { component: t, ...n }];
|
|
@@ -233,13 +233,13 @@ function V(i) {
|
|
|
233
233
|
c && typeof c == "object" && "literalString" in c ? a[s] = c.literalString : c && typeof c == "object" && "explicitList" in c ? a[s] = c.explicitList : a[s] = c;
|
|
234
234
|
return a.child !== void 0 && a.children === void 0 && (a.children = [String(a.child)], delete a.child), [e, a];
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function re(i, e) {
|
|
237
237
|
if (e.createSurface) {
|
|
238
238
|
const n = e.createSurface;
|
|
239
239
|
i.root = null, i.elements = {}, i.dataModel = n.dataModel ? JSON.parse(JSON.stringify(n.dataModel)) : {};
|
|
240
240
|
const o = [];
|
|
241
241
|
for (const a of n.components ?? []) {
|
|
242
|
-
const [s, c] =
|
|
242
|
+
const [s, c] = W(a);
|
|
243
243
|
i.elements[s] = c, o.push(s);
|
|
244
244
|
}
|
|
245
245
|
const r = n.metadata?.extensions ?? {};
|
|
@@ -253,30 +253,30 @@ function te(i, e) {
|
|
|
253
253
|
if (t) {
|
|
254
254
|
const n = [];
|
|
255
255
|
for (const o of t.components ?? []) {
|
|
256
|
-
const [r, a] =
|
|
256
|
+
const [r, a] = W(o);
|
|
257
257
|
i.elements[r] = a, n.push(r);
|
|
258
258
|
}
|
|
259
259
|
return i.root === null && n.includes("root") && (i.root = "root"), { kind: "updateComponents", surfaceId: t.surfaceId, ids: n };
|
|
260
260
|
}
|
|
261
261
|
if (e.updateDataModel) {
|
|
262
262
|
const { path: n, value: o, surfaceId: r } = e.updateDataModel;
|
|
263
|
-
return !n || n === "/" || n === "" ? i.dataModel = o && typeof o == "object" ? JSON.parse(JSON.stringify(o)) : {} :
|
|
263
|
+
return !n || n === "/" || n === "" ? i.dataModel = o && typeof o == "object" ? JSON.parse(JSON.stringify(o)) : {} : I(i.dataModel, n, o === null ? void 0 : o), { kind: "updateDataModel", surfaceId: r, ids: [] };
|
|
264
264
|
}
|
|
265
265
|
if (e.dataModelUpdate) {
|
|
266
266
|
const { path: n, value: o, contents: r, surfaceId: a } = e.dataModelUpdate;
|
|
267
267
|
if (Array.isArray(r))
|
|
268
268
|
for (const s of r) {
|
|
269
269
|
const c = String(s.key), d = s.valueString ?? s.valueNumber ?? s.valueBoolean ?? s.valueMap;
|
|
270
|
-
|
|
270
|
+
I(i.dataModel, `${n ?? ""}/${c}`, d);
|
|
271
271
|
}
|
|
272
|
-
else n &&
|
|
272
|
+
else n && I(i.dataModel, n, o);
|
|
273
273
|
return { kind: "updateDataModel", surfaceId: a, ids: [] };
|
|
274
274
|
}
|
|
275
275
|
if (e.deleteSurface)
|
|
276
276
|
return i.root = null, i.elements = {}, i.dataModel = {}, { kind: "deleteSurface", surfaceId: e.deleteSurface.surfaceId, ids: [] };
|
|
277
277
|
throw new Error(`Unrecognised A2UI message: ${Object.keys(e).join(", ") || "empty"}`);
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function F(i) {
|
|
280
280
|
const e = /* @__PURE__ */ new Set(), t = [], n = (o) => {
|
|
281
281
|
if (e.has(o)) return;
|
|
282
282
|
e.add(o);
|
|
@@ -289,27 +289,27 @@ function H(i) {
|
|
|
289
289
|
};
|
|
290
290
|
return i.root && n(i.root), t;
|
|
291
291
|
}
|
|
292
|
-
class
|
|
292
|
+
class x extends Error {
|
|
293
293
|
constructor(e, t) {
|
|
294
294
|
super(`Invalid anti-pattern selector "${e}": ${t}`), this.name = "SelectorSyntaxError";
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
const
|
|
298
|
-
function
|
|
297
|
+
const G = /^(?:ed-[a-z0-9-]+|h[1-6]|a|p|img|button|span|div|ul|ol|li)$/, K = /^[a-zA-Z][\w-]*$/;
|
|
298
|
+
function se(i, e) {
|
|
299
299
|
let t = i.trim();
|
|
300
300
|
const n = t.match(/^(\*|[a-z][a-z0-9-]*)/);
|
|
301
|
-
if (!n) throw new
|
|
301
|
+
if (!n) throw new x(e, `expected a tag or "*" at "${t}"`);
|
|
302
302
|
const o = n[1];
|
|
303
|
-
if (o !== "*" && !
|
|
304
|
-
throw new
|
|
303
|
+
if (o !== "*" && !G.test(o))
|
|
304
|
+
throw new x(e, `"${o}" is not an Eddie tag or an allowed native element`);
|
|
305
305
|
t = t.slice(o.length);
|
|
306
306
|
const r = { tag: o, not: [] };
|
|
307
307
|
for (; t.length > 0; ) {
|
|
308
308
|
const a = t.match(/^\[slot=([^\]]*)\]/);
|
|
309
309
|
if (a) {
|
|
310
310
|
const c = a[1].replace(/^["']|["']$/g, "");
|
|
311
|
-
if (!
|
|
312
|
-
if (r.slot) throw new
|
|
311
|
+
if (!K.test(c)) throw new x(e, `bad slot name "${a[1]}"`);
|
|
312
|
+
if (r.slot) throw new x(e, "a compound may carry one [slot=] clause");
|
|
313
313
|
r.slot = c, t = t.slice(a[0].length);
|
|
314
314
|
continue;
|
|
315
315
|
}
|
|
@@ -318,52 +318,52 @@ function ne(i, e) {
|
|
|
318
318
|
const c = s[1].trim(), d = c.match(/^\[slot=([^\]]*)\]$/);
|
|
319
319
|
if (d) {
|
|
320
320
|
const f = d[1].replace(/^["']|["']$/g, "");
|
|
321
|
-
if (!
|
|
321
|
+
if (!K.test(f)) throw new x(e, `bad slot name in :not(): "${c}"`);
|
|
322
322
|
r.not.push({ slot: f });
|
|
323
|
-
} else if (
|
|
323
|
+
} else if (G.test(c))
|
|
324
324
|
r.not.push({ tag: c });
|
|
325
325
|
else
|
|
326
|
-
throw new
|
|
326
|
+
throw new x(e, `:not() accepts one tag or one [slot=name], got "${c}"`);
|
|
327
327
|
t = t.slice(s[0].length);
|
|
328
328
|
continue;
|
|
329
329
|
}
|
|
330
|
-
throw new
|
|
330
|
+
throw new x(e, `unexpected "${t}"`);
|
|
331
331
|
}
|
|
332
332
|
if (r.tag === "*" && r.not.length === 0 && !r.slot)
|
|
333
|
-
throw new
|
|
333
|
+
throw new x(e, '"*" alone matches everything; qualify it with [slot=] or :not()');
|
|
334
334
|
return r;
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function ie(i) {
|
|
337
337
|
const e = i.trim().replace(/\s+/g, " ");
|
|
338
|
-
if (!e) throw new
|
|
338
|
+
if (!e) throw new x(i, "empty selector");
|
|
339
339
|
const t = e.split(" ").filter(Boolean), n = [], o = [];
|
|
340
340
|
let r = !1, a = !0;
|
|
341
341
|
for (const s of t) {
|
|
342
342
|
if (s === ">") {
|
|
343
|
-
if (a) throw new
|
|
343
|
+
if (a) throw new x(e, '">" needs a compound on both sides');
|
|
344
344
|
r = !0, a = !0;
|
|
345
345
|
continue;
|
|
346
346
|
}
|
|
347
|
-
a ? n.length > 0 && o.push(r ? "child" : "descendant") : o.push("descendant"), n.push(
|
|
347
|
+
a ? n.length > 0 && o.push(r ? "child" : "descendant") : o.push("descendant"), n.push(se(s, e)), r = !1, a = !1;
|
|
348
348
|
}
|
|
349
|
-
if (a) throw new
|
|
349
|
+
if (a) throw new x(e, "selector ends with a combinator");
|
|
350
350
|
if (n.length < 2)
|
|
351
|
-
throw new
|
|
351
|
+
throw new x(e, "an anti-pattern describes a relationship: it needs a parent and a child");
|
|
352
352
|
return { text: e, compounds: n, combinators: o };
|
|
353
353
|
}
|
|
354
|
-
const
|
|
355
|
-
function
|
|
354
|
+
const ae = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]), q = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][\w:-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)(\/?)>/g;
|
|
355
|
+
function ce(i) {
|
|
356
356
|
const e = i.match(/\bslot\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i);
|
|
357
357
|
if (e)
|
|
358
358
|
return (e[1] ?? e[2] ?? e[3]).trim();
|
|
359
359
|
}
|
|
360
|
-
function
|
|
360
|
+
function le(i) {
|
|
361
361
|
const e = [], t = [];
|
|
362
362
|
q.lastIndex = 0;
|
|
363
363
|
let n;
|
|
364
364
|
for (; (n = q.exec(i)) !== null; ) {
|
|
365
365
|
if (n[0].startsWith("<!--")) continue;
|
|
366
|
-
const o = n[1] === "/", r = n[2].toLowerCase(), a = n[3] ?? "", s = n[4] === "/" ||
|
|
366
|
+
const o = n[1] === "/", r = n[2].toLowerCase(), a = n[3] ?? "", s = n[4] === "/" || ae.has(r);
|
|
367
367
|
if (o) {
|
|
368
368
|
for (let u = t.length - 1; u >= 0; u--)
|
|
369
369
|
if (t[u].tag === r) {
|
|
@@ -372,46 +372,46 @@ function ie(i) {
|
|
|
372
372
|
}
|
|
373
373
|
continue;
|
|
374
374
|
}
|
|
375
|
-
const c = { tag: r, index: n.index, children: [] }, d =
|
|
375
|
+
const c = { tag: r, index: n.index, children: [] }, d = ce(a);
|
|
376
376
|
d !== void 0 && (c.slot = d);
|
|
377
377
|
const f = t[t.length - 1];
|
|
378
378
|
f ? (c.parent = f, f.children.push(c)) : e.push(c), s || t.push(c);
|
|
379
379
|
}
|
|
380
380
|
return e;
|
|
381
381
|
}
|
|
382
|
-
function*
|
|
382
|
+
function* X(i) {
|
|
383
383
|
for (const e of i)
|
|
384
|
-
yield e, yield*
|
|
384
|
+
yield e, yield* X(e.children);
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function P(i, e) {
|
|
387
387
|
if (i.tag !== "*" && i.tag !== e.tag || i.slot !== void 0 && e.slot !== i.slot) return !1;
|
|
388
388
|
for (const t of i.not)
|
|
389
389
|
if (t.tag !== void 0 && e.tag === t.tag || t.slot !== void 0 && e.slot === t.slot) return !1;
|
|
390
390
|
return !0;
|
|
391
391
|
}
|
|
392
|
-
function
|
|
392
|
+
function de(i, e) {
|
|
393
393
|
const { compounds: t, combinators: n } = i, o = t.length - 1;
|
|
394
|
-
if (!
|
|
394
|
+
if (!P(t[o], e)) return !1;
|
|
395
395
|
const r = (a, s) => {
|
|
396
396
|
if (a < 0) return !0;
|
|
397
397
|
if (n[a] === "child")
|
|
398
|
-
return !!s &&
|
|
398
|
+
return !!s && P(t[a], s) && r(a - 1, s.parent);
|
|
399
399
|
for (let d = s; d; d = d.parent)
|
|
400
|
-
if (
|
|
400
|
+
if (P(t[a], d) && r(a - 1, d.parent)) return !0;
|
|
401
401
|
return !1;
|
|
402
402
|
};
|
|
403
403
|
return r(o - 1, e.parent);
|
|
404
404
|
}
|
|
405
|
-
function
|
|
405
|
+
function fe(i, e) {
|
|
406
406
|
if (e.length === 0) return [];
|
|
407
|
-
const t = e.map((o) => ({ pattern: o, selector:
|
|
408
|
-
for (const o of
|
|
407
|
+
const t = e.map((o) => ({ pattern: o, selector: ie(o.selector) })), n = [];
|
|
408
|
+
for (const o of X(le(i)))
|
|
409
409
|
for (const { pattern: r, selector: a } of t)
|
|
410
|
-
|
|
410
|
+
de(a, o) && n.push({ pattern: r, node: o, index: o.index });
|
|
411
411
|
return n.sort((o, r) => o.index - r.index);
|
|
412
412
|
}
|
|
413
|
-
const
|
|
414
|
-
function
|
|
413
|
+
const ue = /^h([1-6])$/;
|
|
414
|
+
function J(i, e, t = {}) {
|
|
415
415
|
const n = [];
|
|
416
416
|
let o;
|
|
417
417
|
try {
|
|
@@ -453,8 +453,8 @@ function P(i, e, t = {}) {
|
|
|
453
453
|
});
|
|
454
454
|
continue;
|
|
455
455
|
}
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
456
|
+
const $ = c(h.component);
|
|
457
|
+
if (!$) {
|
|
458
458
|
s({
|
|
459
459
|
code: "UNKNOWN_COMPONENT",
|
|
460
460
|
severity: "error",
|
|
@@ -465,13 +465,13 @@ function P(i, e, t = {}) {
|
|
|
465
465
|
});
|
|
466
466
|
continue;
|
|
467
467
|
}
|
|
468
|
-
const
|
|
469
|
-
for (const m of
|
|
468
|
+
const O = $.properties ?? {};
|
|
469
|
+
for (const m of $.required ?? [])
|
|
470
470
|
m === "component" || m === "children" || h[m] === void 0 && s({ code: "VALIDATION_FAILED", severity: "error", id: l, message: `"${h.component}" requires "${m}".`, path: `/elements/${l}/${m}` });
|
|
471
|
-
for (const [m,
|
|
472
|
-
if (
|
|
473
|
-
const
|
|
474
|
-
if (!
|
|
471
|
+
for (const [m, b] of Object.entries(h)) {
|
|
472
|
+
if (D.has(m)) continue;
|
|
473
|
+
const v = O[m];
|
|
474
|
+
if (!v) {
|
|
475
475
|
s({
|
|
476
476
|
code: "UNKNOWN_PROP",
|
|
477
477
|
severity: "warning",
|
|
@@ -481,31 +481,31 @@ function P(i, e, t = {}) {
|
|
|
481
481
|
}), t.autoFix && (delete r.elements[l][m], a = !0);
|
|
482
482
|
continue;
|
|
483
483
|
}
|
|
484
|
-
if (
|
|
485
|
-
if (Array.isArray(
|
|
484
|
+
if (b && typeof b == "object" && "path" in b) continue;
|
|
485
|
+
if (Array.isArray(v.enum) && !v.enum.includes(b)) {
|
|
486
486
|
s({
|
|
487
487
|
code: "VALIDATION_FAILED",
|
|
488
488
|
severity: "error",
|
|
489
489
|
id: l,
|
|
490
|
-
message: `"${m}" on "${h.component}" must be one of ${
|
|
490
|
+
message: `"${m}" on "${h.component}" must be one of ${v.enum.map(String).join(", ")}; got ${JSON.stringify(b)}.`,
|
|
491
491
|
path: `/elements/${l}/${m}`
|
|
492
492
|
});
|
|
493
493
|
continue;
|
|
494
494
|
}
|
|
495
|
-
const
|
|
496
|
-
|
|
495
|
+
const E = v.type;
|
|
496
|
+
E === "string" && typeof b != "string" && s({
|
|
497
497
|
code: "VALIDATION_FAILED",
|
|
498
498
|
severity: "error",
|
|
499
499
|
id: l,
|
|
500
500
|
message: `"${m}" on "${h.component}" must be a string.`,
|
|
501
501
|
path: `/elements/${l}/${m}`
|
|
502
|
-
}),
|
|
502
|
+
}), E === "number" && typeof b != "number" && s({
|
|
503
503
|
code: "VALIDATION_FAILED",
|
|
504
504
|
severity: "error",
|
|
505
505
|
id: l,
|
|
506
506
|
message: `"${m}" on "${h.component}" must be a number.`,
|
|
507
507
|
path: `/elements/${l}/${m}`
|
|
508
|
-
}),
|
|
508
|
+
}), E === "boolean" && typeof b != "boolean" && s({
|
|
509
509
|
code: "VALIDATION_FAILED",
|
|
510
510
|
severity: "error",
|
|
511
511
|
id: l,
|
|
@@ -513,14 +513,14 @@ function P(i, e, t = {}) {
|
|
|
513
513
|
path: `/elements/${l}/${m}`
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
|
-
const
|
|
516
|
+
const A = O.slots?.properties ?? {};
|
|
517
517
|
for (const m of Object.keys(h.slots ?? {}))
|
|
518
|
-
|
|
518
|
+
A[m] || s({
|
|
519
519
|
code: "UNKNOWN_SLOT",
|
|
520
520
|
severity: "error",
|
|
521
521
|
id: l,
|
|
522
522
|
message: `"${h.component}" has no slot "${m}"; slotted content would be silently dropped.`,
|
|
523
|
-
fix: Object.keys(
|
|
523
|
+
fix: Object.keys(A).length ? `Use one of: ${Object.keys(A).join(", ")}, or put the content in children.` : "This node has no named slots; put the content in children.",
|
|
524
524
|
path: `/elements/${l}/slots/${m}`
|
|
525
525
|
});
|
|
526
526
|
h.children !== void 0 && !Array.isArray(h.children) && s({
|
|
@@ -531,7 +531,7 @@ function P(i, e, t = {}) {
|
|
|
531
531
|
path: `/elements/${l}/children`
|
|
532
532
|
});
|
|
533
533
|
}
|
|
534
|
-
const d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), u = (l, h) => {
|
|
534
|
+
const d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(), y = (l, h, $ = "root") => {
|
|
535
535
|
if (d.has(l)) {
|
|
536
536
|
s({
|
|
537
537
|
code: "CYCLE",
|
|
@@ -542,9 +542,21 @@ function P(i, e, t = {}) {
|
|
|
542
542
|
});
|
|
543
543
|
return;
|
|
544
544
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
545
|
+
const O = u.get(l);
|
|
546
|
+
if (O !== void 0) {
|
|
547
|
+
s({
|
|
548
|
+
code: "DUPLICATE_REFERENCE",
|
|
549
|
+
severity: "error",
|
|
550
|
+
id: l,
|
|
551
|
+
message: `"${l}" is placed twice: ${O}, and ${$}. A node can sit in one place only.`,
|
|
552
|
+
fix: `Keep "${l}" in one position and remove the other reference.`,
|
|
553
|
+
path: h ? `/elements/${h}` : void 0
|
|
554
|
+
});
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (u.set(l, $), f.has(l)) return;
|
|
558
|
+
const A = r.elements[l];
|
|
559
|
+
if (!A) {
|
|
548
560
|
if (t.streaming) return;
|
|
549
561
|
s({
|
|
550
562
|
code: "DANGLING_CHILD",
|
|
@@ -557,63 +569,64 @@ function P(i, e, t = {}) {
|
|
|
557
569
|
return;
|
|
558
570
|
}
|
|
559
571
|
d.add(l);
|
|
560
|
-
const
|
|
561
|
-
if (
|
|
562
|
-
|
|
572
|
+
const m = c(A.component), b = h ? r.elements[h] : void 0, v = b ? b.component : "Surface";
|
|
573
|
+
if (m) {
|
|
574
|
+
m.allowedParents && !m.allowedParents.includes(v) && s({
|
|
563
575
|
code: "UNALLOWED_PARENT",
|
|
564
576
|
severity: "error",
|
|
565
577
|
id: l,
|
|
566
|
-
message: `"${
|
|
567
|
-
fix:
|
|
578
|
+
message: `"${A.component}" may only sit under ${m.allowedParents.join(", ")}; it is under "${v}".`,
|
|
579
|
+
fix: m.allowedParents.includes("Surface") ? `Make "${l}" the root, or move it under an allowed parent.` : `Move "${l}" under one of: ${m.allowedParents.join(", ")}.`
|
|
568
580
|
});
|
|
569
|
-
const
|
|
570
|
-
|
|
581
|
+
const E = b ? c(b.component) : void 0;
|
|
582
|
+
E?.allowedChildren && !E.allowedChildren.includes(A.component) && s({
|
|
571
583
|
code: "UNALLOWED_CHILD",
|
|
572
584
|
severity: "error",
|
|
573
585
|
id: l,
|
|
574
|
-
message: `"${
|
|
575
|
-
fix: `Use one of the nodes "${
|
|
586
|
+
message: `"${v}" does not allow "${A.component}" inside it.`,
|
|
587
|
+
fix: `Use one of the nodes "${v}" allows (${E.allowedChildren.slice(0, 8).join(", ")}${E.allowedChildren.length > 8 ? ", …" : ""}), or a different page shape.`,
|
|
576
588
|
path: `/elements/${h}/children`
|
|
577
589
|
});
|
|
578
590
|
}
|
|
579
|
-
for (const
|
|
580
|
-
for (const
|
|
591
|
+
for (const E of A.children ?? []) y(String(E), l, `in "${l}" children`);
|
|
592
|
+
for (const [E, Q] of Object.entries(A.slots ?? {}))
|
|
593
|
+
for (const ee of Q) y(String(ee), l, `in "${l}" slot "${E}"`);
|
|
581
594
|
d.delete(l), f.add(l);
|
|
582
595
|
};
|
|
583
|
-
r.root &&
|
|
584
|
-
const w = new Set(
|
|
596
|
+
r.root && y(r.root, null);
|
|
597
|
+
const w = new Set(F(r));
|
|
585
598
|
for (const l of Object.keys(r.elements))
|
|
586
599
|
w.has(l) || s({ code: "ORPHAN", severity: "warning", id: l, message: `"${l}" is not reachable from the root and will not render.` });
|
|
587
|
-
const
|
|
588
|
-
if (
|
|
589
|
-
const { markup: l, idOf: h } =
|
|
590
|
-
for (const
|
|
600
|
+
const N = e.antiPatterns ?? [], g = n.some((l) => l.code === "CYCLE");
|
|
601
|
+
if (N.length && !g && r.root && r.elements[r.root]) {
|
|
602
|
+
const { markup: l, idOf: h } = B(r, e);
|
|
603
|
+
for (const $ of fe(l, N))
|
|
591
604
|
s({
|
|
592
605
|
code: "ANTI_PATTERN",
|
|
593
|
-
severity:
|
|
594
|
-
id: h(
|
|
595
|
-
message: `${
|
|
596
|
-
fix:
|
|
606
|
+
severity: $.pattern.severity,
|
|
607
|
+
id: h($.index),
|
|
608
|
+
message: `${$.pattern.selector}: ${$.pattern.reason}`,
|
|
609
|
+
fix: $.pattern.fix
|
|
597
610
|
});
|
|
598
611
|
}
|
|
599
|
-
const
|
|
600
|
-
let
|
|
601
|
-
for (const l of
|
|
602
|
-
const h = r.elements[l],
|
|
603
|
-
if (
|
|
604
|
-
const
|
|
605
|
-
if (
|
|
606
|
-
const
|
|
607
|
-
|
|
612
|
+
const p = [];
|
|
613
|
+
let S = 0;
|
|
614
|
+
for (const l of F(r)) {
|
|
615
|
+
const h = r.elements[l], O = c(h.component)?.metadata.extensions.eddie_tag, A = typeof h.tagName == "string" ? h.tagName : void 0;
|
|
616
|
+
if (O === "ed-heading" && A) {
|
|
617
|
+
const b = A.match(ue);
|
|
618
|
+
if (b) {
|
|
619
|
+
const v = Number(b[1]);
|
|
620
|
+
v === 1 && S++, p.length && v > p[p.length - 1] + 1 && s({
|
|
608
621
|
code: "A11Y",
|
|
609
622
|
severity: "warning",
|
|
610
623
|
id: l,
|
|
611
|
-
message: `Heading level jumps from h${
|
|
624
|
+
message: `Heading level jumps from h${p[p.length - 1]} to h${v}.`,
|
|
612
625
|
fix: "Step heading levels by one."
|
|
613
|
-
}),
|
|
626
|
+
}), p.push(v);
|
|
614
627
|
}
|
|
615
628
|
}
|
|
616
|
-
|
|
629
|
+
O && /^ed-(text|textarea|select|checkbox|radio)-field$/.test(O) && !h.label && !h.slots?.label && s({
|
|
617
630
|
code: "A11Y",
|
|
618
631
|
severity: "warning",
|
|
619
632
|
id: l,
|
|
@@ -621,7 +634,7 @@ function P(i, e, t = {}) {
|
|
|
621
634
|
fix: "Set the `label` prop so the field is announced."
|
|
622
635
|
});
|
|
623
636
|
const m = h.text && typeof h.text == "object" && "path" in h.text;
|
|
624
|
-
h.component ===
|
|
637
|
+
h.component === U && typeof h.text != "string" && !m && s({
|
|
625
638
|
code: "VALIDATION_FAILED",
|
|
626
639
|
severity: "error",
|
|
627
640
|
id: l,
|
|
@@ -629,11 +642,11 @@ function P(i, e, t = {}) {
|
|
|
629
642
|
path: "/elements//text"
|
|
630
643
|
});
|
|
631
644
|
}
|
|
632
|
-
|
|
645
|
+
S > 1 && s({ code: "A11Y", severity: "warning", message: `${S} h1 headings; a page has one.`, fix: "Keep one h1 and demote the rest." });
|
|
633
646
|
const k = { ok: !n.some((l) => l.severity === "error"), issues: n };
|
|
634
647
|
return t.autoFix && a && (k.fixed = r), k;
|
|
635
648
|
}
|
|
636
|
-
function
|
|
649
|
+
function ye(i, e) {
|
|
637
650
|
return i.filter((t) => t.severity === "error").map((t) => ({
|
|
638
651
|
version: "v1.0",
|
|
639
652
|
error: {
|
|
@@ -644,13 +657,13 @@ function pe(i, e) {
|
|
|
644
657
|
}
|
|
645
658
|
}));
|
|
646
659
|
}
|
|
647
|
-
const
|
|
648
|
-
class
|
|
660
|
+
const he = "data-eddie-pending", T = "data-eddie-id";
|
|
661
|
+
class pe extends EventTarget {
|
|
649
662
|
element;
|
|
650
663
|
surfaceId;
|
|
651
664
|
ready;
|
|
652
665
|
catalog = null;
|
|
653
|
-
committed =
|
|
666
|
+
committed = V();
|
|
654
667
|
mounted = /* @__PURE__ */ new Map();
|
|
655
668
|
surfaceRoot = null;
|
|
656
669
|
refusalRegion;
|
|
@@ -661,14 +674,14 @@ class fe extends EventTarget {
|
|
|
661
674
|
}
|
|
662
675
|
/** The committed (rendered, canonical) spec. A copy; mutate through a turn. */
|
|
663
676
|
get spec() {
|
|
664
|
-
return
|
|
677
|
+
return L(this.committed);
|
|
665
678
|
}
|
|
666
679
|
get catalogDocument() {
|
|
667
680
|
return this.catalog;
|
|
668
681
|
}
|
|
669
682
|
/** Validate a spec against this host's catalog without touching the surface. */
|
|
670
683
|
validate(e) {
|
|
671
|
-
return
|
|
684
|
+
return J(e, this.requireCatalog());
|
|
672
685
|
}
|
|
673
686
|
/** Apply messages as one turn: validate strictly, then commit or refuse. */
|
|
674
687
|
apply(e) {
|
|
@@ -682,15 +695,15 @@ class fe extends EventTarget {
|
|
|
682
695
|
}
|
|
683
696
|
/** Clear the surface (a `deleteSurface`). */
|
|
684
697
|
reset() {
|
|
685
|
-
this.committed =
|
|
698
|
+
this.committed = V(), this.render(this.committed, { provisional: !1 }), this.clearRefusals();
|
|
686
699
|
}
|
|
687
700
|
beginTurn() {
|
|
688
|
-
const e = this.requireCatalog(), t =
|
|
701
|
+
const e = this.requireCatalog(), t = L(this.committed);
|
|
689
702
|
let n = !0;
|
|
690
703
|
const o = /* @__PURE__ */ new Set();
|
|
691
704
|
let r = !1;
|
|
692
705
|
const a = () => {
|
|
693
|
-
if (!
|
|
706
|
+
if (!J(t, e, { streaming: !0 }).issues.some((c) => c.severity === "error" && c.code !== "DANGLING_CHILD" && c.code !== "MISSING_ROOT"))
|
|
694
707
|
for (const c of this.render(t, { provisional: !0 })) o.add(c);
|
|
695
708
|
};
|
|
696
709
|
return {
|
|
@@ -700,10 +713,10 @@ class fe extends EventTarget {
|
|
|
700
713
|
const c = Array.isArray(s) ? s : s.split(`
|
|
701
714
|
`), d = [];
|
|
702
715
|
for (const f of c) {
|
|
703
|
-
const u =
|
|
716
|
+
const u = _(f);
|
|
704
717
|
if (u)
|
|
705
718
|
try {
|
|
706
|
-
|
|
719
|
+
H(t, u), d.push(u);
|
|
707
720
|
} catch {
|
|
708
721
|
}
|
|
709
722
|
}
|
|
@@ -711,24 +724,24 @@ class fe extends EventTarget {
|
|
|
711
724
|
},
|
|
712
725
|
pushOp: (s) => {
|
|
713
726
|
if (!n) throw new Error("Turn already ended");
|
|
714
|
-
|
|
727
|
+
H(t, s), a();
|
|
715
728
|
},
|
|
716
729
|
message: (s) => {
|
|
717
730
|
if (!n) throw new Error("Turn already ended");
|
|
718
731
|
for (const c of Array.isArray(s) ? s : [s])
|
|
719
|
-
|
|
732
|
+
re(t, c).kind === "deleteSurface" ? r = !0 : r = !1;
|
|
720
733
|
r || a();
|
|
721
734
|
},
|
|
722
735
|
end: () => {
|
|
723
736
|
if (!n) throw new Error("Turn already ended");
|
|
724
737
|
if (n = !1, r)
|
|
725
|
-
return this.reset(), this.dispatchEvent(new CustomEvent("render", { detail: { spec:
|
|
726
|
-
const s =
|
|
738
|
+
return this.reset(), this.dispatchEvent(new CustomEvent("render", { detail: { spec: L(this.committed), issues: [], touched: [] } })), { ok: !0, issues: [], outcome: "committed", touched: [] };
|
|
739
|
+
const s = J(t, e);
|
|
727
740
|
if (s.ok) {
|
|
728
741
|
this.committed = t;
|
|
729
742
|
for (const d of this.render(t, { provisional: !1 })) o.add(d);
|
|
730
743
|
const c = [...o];
|
|
731
|
-
return this.clearRefusals(), this.dispatchEvent(new CustomEvent("render", { detail: { spec:
|
|
744
|
+
return this.clearRefusals(), this.dispatchEvent(new CustomEvent("render", { detail: { spec: L(t), issues: s.issues, touched: c } })), { ...s, outcome: "committed", touched: c };
|
|
732
745
|
}
|
|
733
746
|
return this.render(this.committed, { provisional: !1 }), this.showRefusals(s.issues), this.dispatchEvent(new CustomEvent("refusal", { detail: { issues: s.issues, surfaceId: this.surfaceId } })), { ...s, outcome: "refused", touched: [] };
|
|
734
747
|
},
|
|
@@ -745,30 +758,33 @@ class fe extends EventTarget {
|
|
|
745
758
|
const n = this.requireCatalog(), o = this.element.ownerDocument, r = [], a = /* @__PURE__ */ new Set();
|
|
746
759
|
this.opts.scripts !== !1 && this.ensureScripts(e, n);
|
|
747
760
|
const s = e.dataModel, c = (f) => {
|
|
748
|
-
const u =
|
|
761
|
+
const u = j(f, s);
|
|
749
762
|
if (u && typeof u == "object" && !Array.isArray(u) && u.bind === "client") {
|
|
750
|
-
const
|
|
751
|
-
return this.opts.bind ? this.opts.bind(
|
|
763
|
+
const y = typeof f == "object" && f && "path" in f ? String(f.path) : "";
|
|
764
|
+
return this.opts.bind ? this.opts.bind(y) : void 0;
|
|
752
765
|
}
|
|
753
766
|
return u;
|
|
754
767
|
}, d = (f, u) => {
|
|
768
|
+
if (a.has(f)) return null;
|
|
755
769
|
a.add(f);
|
|
756
|
-
const
|
|
757
|
-
if (!
|
|
758
|
-
if (
|
|
759
|
-
const
|
|
760
|
-
return
|
|
770
|
+
const y = e.elements[f], w = this.mounted.get(f);
|
|
771
|
+
if (!y) {
|
|
772
|
+
if (w?.kind === "pending") return w.el;
|
|
773
|
+
const S = o.createElement("span");
|
|
774
|
+
return S.setAttribute(he, f), S.hidden = !0, this.mounted.set(f, { el: S, key: "pending", childHost: null, anchor: null, kind: "pending" }), S;
|
|
761
775
|
}
|
|
762
|
-
const N = n.components[
|
|
763
|
-
let p =
|
|
764
|
-
if ((!p || p.key !== g || p.kind === "pending") && (p = this.create(o, f,
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
776
|
+
const N = n.components[y.component], g = this.keyFor(y, c, u);
|
|
777
|
+
let p = w;
|
|
778
|
+
if ((!p || p.key !== g || p.kind === "pending") && (p = this.create(o, f, y, N, c, g), w && w.el.parentNode && w.el.replaceWith(p.el), this.mounted.set(f, p), r.push(f)), p.el instanceof Element && (u ? p.el.setAttribute("slot", u) : p.el.removeAttribute("slot")), p.childHost) {
|
|
779
|
+
const S = [], C = (k) => {
|
|
780
|
+
k && S.push(k);
|
|
781
|
+
};
|
|
782
|
+
for (const k of y.children ?? []) C(d(String(k)));
|
|
783
|
+
for (const [k, l] of Object.entries(y.slots ?? {})) {
|
|
768
784
|
const h = N?.metadata.extensions.eddie_slotAttrs?.[k] ?? k;
|
|
769
|
-
for (const
|
|
785
|
+
for (const $ of l) C(d(String($), h));
|
|
770
786
|
}
|
|
771
|
-
this.syncChildren(p.childHost, p.anchor,
|
|
787
|
+
this.syncChildren(p.childHost, p.anchor, S);
|
|
772
788
|
}
|
|
773
789
|
return p.el;
|
|
774
790
|
};
|
|
@@ -783,29 +799,29 @@ class fe extends EventTarget {
|
|
|
783
799
|
keyFor(e, t, n) {
|
|
784
800
|
const o = {};
|
|
785
801
|
for (const [r, a] of Object.entries(e))
|
|
786
|
-
r === "children" || r === "slots" || (o[r] =
|
|
802
|
+
r === "children" || r === "slots" || (o[r] = D.has(r) ? a : t(a));
|
|
787
803
|
return JSON.stringify([o, n ?? ""]);
|
|
788
804
|
}
|
|
789
805
|
create(e, t, n, o, r, a) {
|
|
790
806
|
if (!o) {
|
|
791
807
|
const d = e.createElement("span");
|
|
792
|
-
return d.setAttribute(
|
|
808
|
+
return d.setAttribute(T, t), d.setAttribute("data-eddie-unknown", n.component), d.hidden = !0, { el: d, key: a, childHost: null, anchor: null, kind: "unknown" };
|
|
793
809
|
}
|
|
794
810
|
const s = o.metadata.extensions;
|
|
795
|
-
if (s.eddie_kind === "text" || n.component ===
|
|
811
|
+
if (s.eddie_kind === "text" || n.component === U) {
|
|
796
812
|
const d = String(r(n.text) ?? ""), f = typeof n.tagName == "string" ? n.tagName : "";
|
|
797
813
|
if (!f) return { el: e.createTextNode(d), key: a, childHost: null, anchor: null, kind: "text" };
|
|
798
814
|
const u = e.createElement(f);
|
|
799
|
-
return u.textContent = d, u.setAttribute(
|
|
815
|
+
return u.textContent = d, u.setAttribute(T, t), { el: u, key: a, childHost: null, anchor: null, kind: "text" };
|
|
800
816
|
}
|
|
801
817
|
if (s.eddie_kind === "composition") {
|
|
802
|
-
const { before: d, after: f } =
|
|
818
|
+
const { before: d, after: f } = Y(o, n, this.resolvedProps(n, r)), u = e.createElement("template");
|
|
803
819
|
u.innerHTML = `${d}<!--eddie:children-->${f}`;
|
|
804
|
-
const
|
|
805
|
-
let
|
|
806
|
-
|
|
820
|
+
const y = u.content;
|
|
821
|
+
let w;
|
|
822
|
+
y.children.length === 1 ? w = y.firstElementChild : (w = e.createElement("div"), w.append(y));
|
|
807
823
|
const N = e.createTreeWalker(
|
|
808
|
-
|
|
824
|
+
w,
|
|
809
825
|
128
|
|
810
826
|
/* NodeFilter.SHOW_COMMENT */
|
|
811
827
|
);
|
|
@@ -815,16 +831,16 @@ class fe extends EventTarget {
|
|
|
815
831
|
g = p;
|
|
816
832
|
break;
|
|
817
833
|
}
|
|
818
|
-
return
|
|
834
|
+
return w.setAttribute(T, t), this.applyCommon(w, n), { el: w, key: a, childHost: g?.parentElement ?? w, anchor: g, kind: "composition" };
|
|
819
835
|
}
|
|
820
836
|
const c = e.createElement(s.eddie_tag);
|
|
821
|
-
c.setAttribute(
|
|
822
|
-
for (const [d, f] of
|
|
837
|
+
c.setAttribute(T, t);
|
|
838
|
+
for (const [d, f] of z(n, {})) {
|
|
823
839
|
const u = r(f);
|
|
824
840
|
u === !0 ? c.setAttribute(d, "") : u === !1 || u === void 0 || u === null ? c.removeAttribute(d) : c.setAttribute(d, String(u));
|
|
825
841
|
}
|
|
826
842
|
for (const [d, f] of Object.entries(n)) {
|
|
827
|
-
if (
|
|
843
|
+
if (D.has(d)) continue;
|
|
828
844
|
const u = r(f);
|
|
829
845
|
u && typeof u == "object" && (c[d] = u);
|
|
830
846
|
}
|
|
@@ -832,7 +848,7 @@ class fe extends EventTarget {
|
|
|
832
848
|
}
|
|
833
849
|
resolvedProps(e, t) {
|
|
834
850
|
const n = {};
|
|
835
|
-
for (const [o, r] of Object.entries(e))
|
|
851
|
+
for (const [o, r] of Object.entries(e)) D.has(o) || (n[o] = t(r));
|
|
836
852
|
return n;
|
|
837
853
|
}
|
|
838
854
|
applyCommon(e, t) {
|
|
@@ -875,7 +891,7 @@ class fe extends EventTarget {
|
|
|
875
891
|
onActivate(e) {
|
|
876
892
|
const n = e.target?.closest?.("[data-eddie-action]");
|
|
877
893
|
if (!n || !this.element.contains(n)) return;
|
|
878
|
-
const o = n.getAttribute(
|
|
894
|
+
const o = n.getAttribute(T), r = o ? this.committed.elements[o] : void 0;
|
|
879
895
|
if (!o || !r?.action) return;
|
|
880
896
|
const a = {
|
|
881
897
|
name: r.action.name,
|
|
@@ -888,7 +904,7 @@ class fe extends EventTarget {
|
|
|
888
904
|
}
|
|
889
905
|
ensureScripts(e, t) {
|
|
890
906
|
const n = this.element.ownerDocument;
|
|
891
|
-
for (const o of
|
|
907
|
+
for (const o of F(e)) {
|
|
892
908
|
const a = t.components[e.elements[o]?.component ?? ""]?.metadata.extensions.eddie_scriptTag;
|
|
893
909
|
if (a)
|
|
894
910
|
for (const s of a.matchAll(/src="([^"]+)"/g)) {
|
|
@@ -914,34 +930,34 @@ class fe extends EventTarget {
|
|
|
914
930
|
}
|
|
915
931
|
/** The committed surface as markup (what the validator's anti-pattern pass sees). */
|
|
916
932
|
toMarkup() {
|
|
917
|
-
return
|
|
933
|
+
return B(this.committed, this.requireCatalog()).markup;
|
|
918
934
|
}
|
|
919
935
|
}
|
|
920
|
-
function
|
|
921
|
-
return new
|
|
936
|
+
function we(i, e) {
|
|
937
|
+
return new pe(i, e);
|
|
922
938
|
}
|
|
923
939
|
export {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
940
|
+
D as RESERVED_KEYS,
|
|
941
|
+
pe as SurfaceHost,
|
|
942
|
+
U as TEXT_NODE,
|
|
943
|
+
re as applyMessage,
|
|
944
|
+
ge as applyPatchLines,
|
|
945
|
+
H as applyPatchOp,
|
|
946
|
+
L as cloneSpec,
|
|
947
|
+
me as createSpecStreamCompiler,
|
|
948
|
+
we as createSurfaceHost,
|
|
949
|
+
V as emptySpec,
|
|
950
|
+
Y as expand,
|
|
951
|
+
M as getAtPointer,
|
|
952
|
+
oe as healJsonLine,
|
|
953
|
+
W as normaliseWireComponent,
|
|
954
|
+
_ as parsePatchLine,
|
|
955
|
+
Z as parsePointer,
|
|
956
|
+
F as reachableIds,
|
|
957
|
+
j as resolveValue,
|
|
958
|
+
B as serializeSpec,
|
|
959
|
+
I as setAtPointer,
|
|
960
|
+
ye as toA2uiErrors,
|
|
961
|
+
J as validateSpec
|
|
946
962
|
};
|
|
947
963
|
//# sourceMappingURL=eddie-render.js.map
|