@brad-frost-web/eddie-render 0.73.0 → 0.74.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/cdn/eddie-render.js +144 -126
- package/cdn/eddie-render.js.map +1 -1
- package/dist/validate/a11y-rules.d.ts +37 -0
- package/dist/validate/a11y-rules.d.ts.map +1 -0
- package/dist/validate/a11y-rules.js +46 -0
- package/dist/validate/a11y-rules.js.map +1 -0
- package/dist/validate/index.d.ts +1 -0
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +17 -19
- package/dist/validate/index.js.map +1 -1
- package/package.json +1 -1
package/cdn/eddie-render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const C = /* @__PURE__ */ new Set(["component", "children", "slots", "accessibility", "action", "metadata", "catalogId", "id"]), U = "Text";
|
|
2
2
|
function R(i) {
|
|
3
3
|
return String(i).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
4
4
|
}
|
|
@@ -20,20 +20,20 @@ function j(i, e) {
|
|
|
20
20
|
function z(i, e) {
|
|
21
21
|
const t = [];
|
|
22
22
|
for (const [n, o] of Object.entries(i)) {
|
|
23
|
-
if (
|
|
23
|
+
if (C.has(n)) continue;
|
|
24
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 B(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
31
|
const c = j(e[s], t);
|
|
32
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 Y(i, e) {
|
|
37
37
|
const t = [];
|
|
38
38
|
let n = "";
|
|
39
39
|
const o = /* @__PURE__ */ new Set(), r = (s, c) => {
|
|
@@ -61,17 +61,17 @@ function B(i, e) {
|
|
|
61
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 A = y.eddie_slotAttrs?.[g] ?? g;
|
|
65
|
+
for (const L of p) r(String(L), A);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
if (y.eddie_kind === "composition") {
|
|
69
|
-
const { before: g, after: p } =
|
|
69
|
+
const { before: g, after: p } = B(f, c, i.dataModel);
|
|
70
70
|
n += d ? g.replace(/^(<[a-zA-Z][^>\s]*)/, `$1${u}`) : g, w(), n += p;
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
const
|
|
74
|
-
n += `<${y.eddie_tag}${
|
|
73
|
+
const x = z(c, i.dataModel).map(([g, p]) => p === !0 ? ` ${g}` : p === !1 ? "" : ` ${g}="${R(p)}"`).join("");
|
|
74
|
+
n += `<${y.eddie_tag}${x}${u}>`, w(), n += `</${y.eddie_tag}>`;
|
|
75
75
|
};
|
|
76
76
|
return i.root && r(i.root), {
|
|
77
77
|
markup: n,
|
|
@@ -85,7 +85,7 @@ function B(i, e) {
|
|
|
85
85
|
function V() {
|
|
86
86
|
return { root: null, elements: {}, dataModel: {} };
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function T(i) {
|
|
89
89
|
return JSON.parse(JSON.stringify(i));
|
|
90
90
|
}
|
|
91
91
|
const ne = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
@@ -181,7 +181,7 @@ function oe(i) {
|
|
|
181
181
|
for (n && (t += '"'); o.length; ) t += o.pop();
|
|
182
182
|
return _(t);
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function ve() {
|
|
185
185
|
let i = "";
|
|
186
186
|
const e = [], t = (n) => {
|
|
187
187
|
const o = _(n);
|
|
@@ -210,7 +210,7 @@ function me() {
|
|
|
210
210
|
}
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function be(i, e) {
|
|
214
214
|
const t = Array.isArray(e) ? e : e.split(`
|
|
215
215
|
`), n = [], o = [];
|
|
216
216
|
for (const r of t) {
|
|
@@ -289,27 +289,27 @@ function H(i) {
|
|
|
289
289
|
};
|
|
290
290
|
return i.root && n(i.root), t;
|
|
291
291
|
}
|
|
292
|
-
class
|
|
292
|
+
class E 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
|
|
297
|
+
const G = /^(?:ed-[a-z0-9-]+|h[1-6]|a|p|img|button|span|div|ul|ol|li)$/, q = /^[a-zA-Z][\w-]*$/;
|
|
298
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 E(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 E(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 (!q.test(c)) throw new E(e, `bad slot name "${a[1]}"`);
|
|
312
|
+
if (r.slot) throw new E(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,37 +318,37 @@ function se(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 (!q.test(f)) throw new E(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 E(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 E(e, `unexpected "${t}"`);
|
|
331
331
|
}
|
|
332
332
|
if (r.tag === "*" && r.not.length === 0 && !r.slot)
|
|
333
|
-
throw new
|
|
333
|
+
throw new E(e, '"*" alone matches everything; qualify it with [slot=] or :not()');
|
|
334
334
|
return r;
|
|
335
335
|
}
|
|
336
336
|
function ie(i) {
|
|
337
337
|
const e = i.trim().replace(/\s+/g, " ");
|
|
338
|
-
if (!e) throw new
|
|
338
|
+
if (!e) throw new E(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 E(e, '">" needs a compound on both sides');
|
|
344
344
|
r = !0, a = !0;
|
|
345
345
|
continue;
|
|
346
346
|
}
|
|
347
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 E(e, "selector ends with a combinator");
|
|
350
350
|
if (n.length < 2)
|
|
351
|
-
throw new
|
|
351
|
+
throw new E(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
354
|
const ae = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]), K = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][\w:-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)(\/?)>/g;
|
|
@@ -410,7 +410,26 @@ function fe(i, e) {
|
|
|
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 ue = /^h([1-6])$/;
|
|
413
|
+
const ue = /^h([1-6])$/, he = /^ed-(text|textarea|select|checkbox|radio|datepicker)-field$/;
|
|
414
|
+
function pe(i) {
|
|
415
|
+
const e = i?.trim().toLowerCase().match(ue);
|
|
416
|
+
return e ? Number(e[1]) : null;
|
|
417
|
+
}
|
|
418
|
+
function me(i, e) {
|
|
419
|
+
const t = [];
|
|
420
|
+
let n = null;
|
|
421
|
+
for (const o of i) {
|
|
422
|
+
if (o.level === null) {
|
|
423
|
+
n = null;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
n !== null && o.level > n + 1 && t.push({ from: n, to: o.level, ref: o.ref }), n = o.level;
|
|
427
|
+
}
|
|
428
|
+
return t;
|
|
429
|
+
}
|
|
430
|
+
function ge(i) {
|
|
431
|
+
return i.filter((e) => e.level === 1).length;
|
|
432
|
+
}
|
|
414
433
|
function J(i, e, t = {}) {
|
|
415
434
|
const n = [];
|
|
416
435
|
let o;
|
|
@@ -453,8 +472,8 @@ function J(i, e, t = {}) {
|
|
|
453
472
|
});
|
|
454
473
|
continue;
|
|
455
474
|
}
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
475
|
+
const b = c(h.component);
|
|
476
|
+
if (!b) {
|
|
458
477
|
s({
|
|
459
478
|
code: "UNKNOWN_COMPONENT",
|
|
460
479
|
severity: "error",
|
|
@@ -465,12 +484,12 @@ function J(i, e, t = {}) {
|
|
|
465
484
|
});
|
|
466
485
|
continue;
|
|
467
486
|
}
|
|
468
|
-
const O =
|
|
469
|
-
for (const m of
|
|
487
|
+
const O = b.properties ?? {};
|
|
488
|
+
for (const m of b.required ?? [])
|
|
470
489
|
if (m !== "component") {
|
|
471
490
|
if (m === "children") {
|
|
472
|
-
const
|
|
473
|
-
!t.streaming && (
|
|
491
|
+
const v = h.children;
|
|
492
|
+
!t.streaming && (v === void 0 || Array.isArray(v) && v.length === 0) && s({
|
|
474
493
|
code: "VALIDATION_FAILED",
|
|
475
494
|
severity: "error",
|
|
476
495
|
id: l,
|
|
@@ -482,10 +501,10 @@ function J(i, e, t = {}) {
|
|
|
482
501
|
}
|
|
483
502
|
h[m] === void 0 && s({ code: "VALIDATION_FAILED", severity: "error", id: l, message: `"${h.component}" requires "${m}".`, path: `/elements/${l}/${m}` });
|
|
484
503
|
}
|
|
485
|
-
for (const [m,
|
|
486
|
-
if (
|
|
487
|
-
const
|
|
488
|
-
if (!
|
|
504
|
+
for (const [m, v] of Object.entries(h)) {
|
|
505
|
+
if (C.has(m)) continue;
|
|
506
|
+
const k = O[m];
|
|
507
|
+
if (!k) {
|
|
489
508
|
s({
|
|
490
509
|
code: "UNKNOWN_PROP",
|
|
491
510
|
severity: "warning",
|
|
@@ -495,31 +514,31 @@ function J(i, e, t = {}) {
|
|
|
495
514
|
}), t.autoFix && (delete r.elements[l][m], a = !0);
|
|
496
515
|
continue;
|
|
497
516
|
}
|
|
498
|
-
if (
|
|
499
|
-
if (Array.isArray(
|
|
517
|
+
if (v && typeof v == "object" && "path" in v) continue;
|
|
518
|
+
if (Array.isArray(k.enum) && !k.enum.includes(v)) {
|
|
500
519
|
s({
|
|
501
520
|
code: "VALIDATION_FAILED",
|
|
502
521
|
severity: "error",
|
|
503
522
|
id: l,
|
|
504
|
-
message: `"${m}" on "${h.component}" must be one of ${
|
|
523
|
+
message: `"${m}" on "${h.component}" must be one of ${k.enum.map(String).join(", ")}; got ${JSON.stringify(v)}.`,
|
|
505
524
|
path: `/elements/${l}/${m}`
|
|
506
525
|
});
|
|
507
526
|
continue;
|
|
508
527
|
}
|
|
509
|
-
const
|
|
510
|
-
|
|
528
|
+
const S = k.type;
|
|
529
|
+
S === "string" && typeof v != "string" && s({
|
|
511
530
|
code: "VALIDATION_FAILED",
|
|
512
531
|
severity: "error",
|
|
513
532
|
id: l,
|
|
514
533
|
message: `"${m}" on "${h.component}" must be a string.`,
|
|
515
534
|
path: `/elements/${l}/${m}`
|
|
516
|
-
}),
|
|
535
|
+
}), S === "number" && typeof v != "number" && s({
|
|
517
536
|
code: "VALIDATION_FAILED",
|
|
518
537
|
severity: "error",
|
|
519
538
|
id: l,
|
|
520
539
|
message: `"${m}" on "${h.component}" must be a number.`,
|
|
521
540
|
path: `/elements/${l}/${m}`
|
|
522
|
-
}),
|
|
541
|
+
}), S === "boolean" && typeof v != "boolean" && s({
|
|
523
542
|
code: "VALIDATION_FAILED",
|
|
524
543
|
severity: "error",
|
|
525
544
|
id: l,
|
|
@@ -527,14 +546,14 @@ function J(i, e, t = {}) {
|
|
|
527
546
|
path: `/elements/${l}/${m}`
|
|
528
547
|
});
|
|
529
548
|
}
|
|
530
|
-
const
|
|
549
|
+
const $ = O.slots?.properties ?? {};
|
|
531
550
|
for (const m of Object.keys(h.slots ?? {}))
|
|
532
|
-
|
|
551
|
+
$[m] || s({
|
|
533
552
|
code: "UNKNOWN_SLOT",
|
|
534
553
|
severity: "error",
|
|
535
554
|
id: l,
|
|
536
555
|
message: `"${h.component}" has no slot "${m}"; slotted content would be silently dropped.`,
|
|
537
|
-
fix: Object.keys(
|
|
556
|
+
fix: Object.keys($).length ? `Use one of: ${Object.keys($).join(", ")}, or put the content in children.` : "This node has no named slots; put the content in children.",
|
|
538
557
|
path: `/elements/${l}/slots/${m}`
|
|
539
558
|
});
|
|
540
559
|
h.children !== void 0 && !Array.isArray(h.children) && s({
|
|
@@ -545,7 +564,7 @@ function J(i, e, t = {}) {
|
|
|
545
564
|
path: `/elements/${l}/children`
|
|
546
565
|
});
|
|
547
566
|
}
|
|
548
|
-
const d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(), y = (l, h,
|
|
567
|
+
const d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(), y = (l, h, b = "root") => {
|
|
549
568
|
if (d.has(l)) {
|
|
550
569
|
s({
|
|
551
570
|
code: "CYCLE",
|
|
@@ -562,15 +581,15 @@ function J(i, e, t = {}) {
|
|
|
562
581
|
code: "DUPLICATE_REFERENCE",
|
|
563
582
|
severity: "error",
|
|
564
583
|
id: l,
|
|
565
|
-
message: `"${l}" is placed twice: ${O}, and ${
|
|
584
|
+
message: `"${l}" is placed twice: ${O}, and ${b}. A node can sit in one place only.`,
|
|
566
585
|
fix: `Keep "${l}" in one position and remove the other reference.`,
|
|
567
586
|
path: h ? `/elements/${h}` : void 0
|
|
568
587
|
});
|
|
569
588
|
return;
|
|
570
589
|
}
|
|
571
|
-
if (u.set(l,
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
590
|
+
if (u.set(l, b), f.has(l)) return;
|
|
591
|
+
const $ = r.elements[l];
|
|
592
|
+
if (!$) {
|
|
574
593
|
if (t.streaming) return;
|
|
575
594
|
s({
|
|
576
595
|
code: "DANGLING_CHILD",
|
|
@@ -583,64 +602,54 @@ function J(i, e, t = {}) {
|
|
|
583
602
|
return;
|
|
584
603
|
}
|
|
585
604
|
d.add(l);
|
|
586
|
-
const m = c(
|
|
605
|
+
const m = c($.component), v = h ? r.elements[h] : void 0, k = v ? v.component : "Surface";
|
|
587
606
|
if (m) {
|
|
588
|
-
m.allowedParents && !m.allowedParents.includes(
|
|
607
|
+
m.allowedParents && !m.allowedParents.includes(k) && s({
|
|
589
608
|
code: "UNALLOWED_PARENT",
|
|
590
609
|
severity: "error",
|
|
591
610
|
id: l,
|
|
592
|
-
message: `"${
|
|
611
|
+
message: `"${$.component}" may only sit under ${m.allowedParents.join(", ")}; it is under "${k}".`,
|
|
593
612
|
fix: m.allowedParents.includes("Surface") ? `Make "${l}" the root, or move it under an allowed parent.` : `Move "${l}" under one of: ${m.allowedParents.join(", ")}.`
|
|
594
613
|
});
|
|
595
|
-
const
|
|
596
|
-
|
|
614
|
+
const S = v ? c(v.component) : void 0;
|
|
615
|
+
S?.allowedChildren && !S.allowedChildren.includes($.component) && s({
|
|
597
616
|
code: "UNALLOWED_CHILD",
|
|
598
617
|
severity: "error",
|
|
599
618
|
id: l,
|
|
600
|
-
message: `"${
|
|
601
|
-
fix: `Use one of the nodes "${
|
|
619
|
+
message: `"${k}" does not allow "${$.component}" inside it.`,
|
|
620
|
+
fix: `Use one of the nodes "${k}" allows (${S.allowedChildren.slice(0, 8).join(", ")}${S.allowedChildren.length > 8 ? ", …" : ""}), or a different page shape.`,
|
|
602
621
|
path: `/elements/${h}/children`
|
|
603
622
|
});
|
|
604
623
|
}
|
|
605
|
-
for (const
|
|
606
|
-
for (const [
|
|
607
|
-
for (const ee of Q) y(String(ee), l, `in "${l}" slot "${
|
|
624
|
+
for (const S of $.children ?? []) y(String(S), l, `in "${l}" children`);
|
|
625
|
+
for (const [S, Q] of Object.entries($.slots ?? {}))
|
|
626
|
+
for (const ee of Q) y(String(ee), l, `in "${l}" slot "${S}"`);
|
|
608
627
|
d.delete(l), f.add(l);
|
|
609
628
|
};
|
|
610
629
|
r.root && y(r.root, null);
|
|
611
630
|
const w = new Set(H(r));
|
|
612
631
|
for (const l of Object.keys(r.elements))
|
|
613
632
|
w.has(l) || s({ code: "ORPHAN", severity: "warning", id: l, message: `"${l}" is not reachable from the root and will not render.` });
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
616
|
-
const { markup: l, idOf: h } =
|
|
617
|
-
for (const
|
|
633
|
+
const x = e.antiPatterns ?? [], g = n.some((l) => l.code === "CYCLE");
|
|
634
|
+
if (x.length && !g && r.root && r.elements[r.root]) {
|
|
635
|
+
const { markup: l, idOf: h } = Y(r, e);
|
|
636
|
+
for (const b of fe(l, x))
|
|
618
637
|
s({
|
|
619
638
|
code: "ANTI_PATTERN",
|
|
620
|
-
severity:
|
|
621
|
-
id: h(
|
|
622
|
-
message: `${
|
|
623
|
-
fix:
|
|
639
|
+
severity: b.pattern.severity,
|
|
640
|
+
id: h(b.index),
|
|
641
|
+
message: `${b.pattern.selector}: ${b.pattern.reason}`,
|
|
642
|
+
fix: b.pattern.fix
|
|
624
643
|
});
|
|
625
644
|
}
|
|
626
645
|
const p = [];
|
|
627
|
-
let S = 0;
|
|
628
646
|
for (const l of H(r)) {
|
|
629
|
-
const h = r.elements[l], O = c(h.component)?.metadata.extensions.eddie_tag,
|
|
630
|
-
if (O === "ed-heading" &&
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
const v = Number(b[1]);
|
|
634
|
-
v === 1 && S++, p.length && v > p[p.length - 1] + 1 && s({
|
|
635
|
-
code: "A11Y",
|
|
636
|
-
severity: "warning",
|
|
637
|
-
id: l,
|
|
638
|
-
message: `Heading level jumps from h${p[p.length - 1]} to h${v}.`,
|
|
639
|
-
fix: "Step heading levels by one."
|
|
640
|
-
}), p.push(v);
|
|
641
|
-
}
|
|
647
|
+
const h = r.elements[l], O = c(h.component)?.metadata.extensions.eddie_tag, $ = typeof h.tagName == "string" ? h.tagName : void 0;
|
|
648
|
+
if (O === "ed-heading" && $) {
|
|
649
|
+
const v = pe($);
|
|
650
|
+
v !== null && p.push({ level: v, ref: l });
|
|
642
651
|
}
|
|
643
|
-
O &&
|
|
652
|
+
O && he.test(O) && !h.label && !h.slots?.label && s({
|
|
644
653
|
code: "A11Y",
|
|
645
654
|
severity: "warning",
|
|
646
655
|
id: l,
|
|
@@ -656,11 +665,20 @@ function J(i, e, t = {}) {
|
|
|
656
665
|
path: "/elements//text"
|
|
657
666
|
});
|
|
658
667
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
668
|
+
for (const l of me(p))
|
|
669
|
+
s({
|
|
670
|
+
code: "A11Y",
|
|
671
|
+
severity: "warning",
|
|
672
|
+
id: l.ref,
|
|
673
|
+
message: `Heading level jumps from h${l.from} to h${l.to}.`,
|
|
674
|
+
fix: "Step heading levels by one."
|
|
675
|
+
});
|
|
676
|
+
const A = ge(p);
|
|
677
|
+
A > 1 && s({ code: "A11Y", severity: "warning", message: `${A} h1 headings; a page has one.`, fix: "Keep one h1 and demote the rest." });
|
|
678
|
+
const N = { ok: !n.some((l) => l.severity === "error"), issues: n };
|
|
679
|
+
return t.autoFix && a && (N.fixed = r), N;
|
|
662
680
|
}
|
|
663
|
-
function
|
|
681
|
+
function $e(i, e) {
|
|
664
682
|
return i.filter((t) => t.severity === "error").map((t) => ({
|
|
665
683
|
version: "v1.0",
|
|
666
684
|
error: {
|
|
@@ -671,8 +689,8 @@ function ye(i, e) {
|
|
|
671
689
|
}
|
|
672
690
|
}));
|
|
673
691
|
}
|
|
674
|
-
const
|
|
675
|
-
class
|
|
692
|
+
const ye = "data-eddie-pending", D = "data-eddie-id";
|
|
693
|
+
class we extends EventTarget {
|
|
676
694
|
element;
|
|
677
695
|
surfaceId;
|
|
678
696
|
ready;
|
|
@@ -688,7 +706,7 @@ class pe extends EventTarget {
|
|
|
688
706
|
}
|
|
689
707
|
/** The committed (rendered, canonical) spec. A copy; mutate through a turn. */
|
|
690
708
|
get spec() {
|
|
691
|
-
return
|
|
709
|
+
return T(this.committed);
|
|
692
710
|
}
|
|
693
711
|
get catalogDocument() {
|
|
694
712
|
return this.catalog;
|
|
@@ -712,7 +730,7 @@ class pe extends EventTarget {
|
|
|
712
730
|
this.committed = V(), this.render(this.committed, { provisional: !1 }), this.clearRefusals();
|
|
713
731
|
}
|
|
714
732
|
beginTurn() {
|
|
715
|
-
const e = this.requireCatalog(), t =
|
|
733
|
+
const e = this.requireCatalog(), t = T(this.committed);
|
|
716
734
|
let n = !0;
|
|
717
735
|
const o = /* @__PURE__ */ new Set();
|
|
718
736
|
let r = !1;
|
|
@@ -749,13 +767,13 @@ class pe extends EventTarget {
|
|
|
749
767
|
end: () => {
|
|
750
768
|
if (!n) throw new Error("Turn already ended");
|
|
751
769
|
if (n = !1, r)
|
|
752
|
-
return this.reset(), this.dispatchEvent(new CustomEvent("render", { detail: { spec:
|
|
770
|
+
return this.reset(), this.dispatchEvent(new CustomEvent("render", { detail: { spec: T(this.committed), issues: [], touched: [] } })), { ok: !0, issues: [], outcome: "committed", touched: [] };
|
|
753
771
|
const s = J(t, e);
|
|
754
772
|
if (s.ok) {
|
|
755
773
|
this.committed = t;
|
|
756
774
|
for (const d of this.render(t, { provisional: !1 })) o.add(d);
|
|
757
775
|
const c = [...o];
|
|
758
|
-
return this.clearRefusals(), this.dispatchEvent(new CustomEvent("render", { detail: { spec:
|
|
776
|
+
return this.clearRefusals(), this.dispatchEvent(new CustomEvent("render", { detail: { spec: T(t), issues: s.issues, touched: c } })), { ...s, outcome: "committed", touched: c };
|
|
759
777
|
}
|
|
760
778
|
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: [] };
|
|
761
779
|
},
|
|
@@ -784,21 +802,21 @@ class pe extends EventTarget {
|
|
|
784
802
|
const y = e.elements[f], w = this.mounted.get(f);
|
|
785
803
|
if (!y) {
|
|
786
804
|
if (w?.kind === "pending") return w.el;
|
|
787
|
-
const
|
|
788
|
-
return
|
|
805
|
+
const A = o.createElement("span");
|
|
806
|
+
return A.setAttribute(ye, f), A.hidden = !0, this.mounted.set(f, { el: A, key: "pending", childHost: null, anchor: null, kind: "pending" }), A;
|
|
789
807
|
}
|
|
790
|
-
const
|
|
808
|
+
const x = n.components[y.component], g = this.keyFor(y, c, u);
|
|
791
809
|
let p = w;
|
|
792
|
-
if ((!p || p.key !== g || p.kind === "pending") && (p = this.create(o, f, y,
|
|
793
|
-
const
|
|
794
|
-
|
|
810
|
+
if ((!p || p.key !== g || p.kind === "pending") && (p = this.create(o, f, y, x, 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) {
|
|
811
|
+
const A = [], L = (N) => {
|
|
812
|
+
N && A.push(N);
|
|
795
813
|
};
|
|
796
|
-
for (const
|
|
797
|
-
for (const [
|
|
798
|
-
const h =
|
|
799
|
-
for (const
|
|
814
|
+
for (const N of y.children ?? []) L(d(String(N)));
|
|
815
|
+
for (const [N, l] of Object.entries(y.slots ?? {})) {
|
|
816
|
+
const h = x?.metadata.extensions.eddie_slotAttrs?.[N] ?? N;
|
|
817
|
+
for (const b of l) L(d(String(b), h));
|
|
800
818
|
}
|
|
801
|
-
this.syncChildren(p.childHost, p.anchor,
|
|
819
|
+
this.syncChildren(p.childHost, p.anchor, A);
|
|
802
820
|
}
|
|
803
821
|
return p.el;
|
|
804
822
|
};
|
|
@@ -813,7 +831,7 @@ class pe extends EventTarget {
|
|
|
813
831
|
keyFor(e, t, n) {
|
|
814
832
|
const o = {};
|
|
815
833
|
for (const [r, a] of Object.entries(e))
|
|
816
|
-
r === "children" || r === "slots" || (o[r] =
|
|
834
|
+
r === "children" || r === "slots" || (o[r] = C.has(r) ? a : t(a));
|
|
817
835
|
return JSON.stringify([o, n ?? ""]);
|
|
818
836
|
}
|
|
819
837
|
create(e, t, n, o, r, a) {
|
|
@@ -829,18 +847,18 @@ class pe extends EventTarget {
|
|
|
829
847
|
return u.textContent = d, u.setAttribute(D, t), { el: u, key: a, childHost: null, anchor: null, kind: "text" };
|
|
830
848
|
}
|
|
831
849
|
if (s.eddie_kind === "composition") {
|
|
832
|
-
const { before: d, after: f } =
|
|
850
|
+
const { before: d, after: f } = B(o, n, this.resolvedProps(n, r)), u = e.createElement("template");
|
|
833
851
|
u.innerHTML = `${d}<!--eddie:children-->${f}`;
|
|
834
852
|
const y = u.content;
|
|
835
853
|
let w;
|
|
836
854
|
y.children.length === 1 ? w = y.firstElementChild : (w = e.createElement("div"), w.append(y));
|
|
837
|
-
const
|
|
855
|
+
const x = e.createTreeWalker(
|
|
838
856
|
w,
|
|
839
857
|
128
|
|
840
858
|
/* NodeFilter.SHOW_COMMENT */
|
|
841
859
|
);
|
|
842
860
|
let g = null;
|
|
843
|
-
for (let p =
|
|
861
|
+
for (let p = x.nextNode(); p; p = x.nextNode())
|
|
844
862
|
if (p.nodeValue === "eddie:children") {
|
|
845
863
|
g = p;
|
|
846
864
|
break;
|
|
@@ -854,7 +872,7 @@ class pe extends EventTarget {
|
|
|
854
872
|
u === !0 ? c.setAttribute(d, "") : u === !1 || u === void 0 || u === null ? c.removeAttribute(d) : c.setAttribute(d, String(u));
|
|
855
873
|
}
|
|
856
874
|
for (const [d, f] of Object.entries(n)) {
|
|
857
|
-
if (
|
|
875
|
+
if (C.has(d)) continue;
|
|
858
876
|
const u = r(f);
|
|
859
877
|
u && typeof u == "object" && (c[d] = u);
|
|
860
878
|
}
|
|
@@ -862,7 +880,7 @@ class pe extends EventTarget {
|
|
|
862
880
|
}
|
|
863
881
|
resolvedProps(e, t) {
|
|
864
882
|
const n = {};
|
|
865
|
-
for (const [o, r] of Object.entries(e))
|
|
883
|
+
for (const [o, r] of Object.entries(e)) C.has(o) || (n[o] = t(r));
|
|
866
884
|
return n;
|
|
867
885
|
}
|
|
868
886
|
applyCommon(e, t) {
|
|
@@ -944,24 +962,24 @@ class pe extends EventTarget {
|
|
|
944
962
|
}
|
|
945
963
|
/** The committed surface as markup (what the validator's anti-pattern pass sees). */
|
|
946
964
|
toMarkup() {
|
|
947
|
-
return
|
|
965
|
+
return Y(this.committed, this.requireCatalog()).markup;
|
|
948
966
|
}
|
|
949
967
|
}
|
|
950
|
-
function
|
|
951
|
-
return new
|
|
968
|
+
function Ae(i, e) {
|
|
969
|
+
return new we(i, e);
|
|
952
970
|
}
|
|
953
971
|
export {
|
|
954
|
-
|
|
955
|
-
|
|
972
|
+
C as RESERVED_KEYS,
|
|
973
|
+
we as SurfaceHost,
|
|
956
974
|
U as TEXT_NODE,
|
|
957
975
|
re as applyMessage,
|
|
958
|
-
|
|
976
|
+
be as applyPatchLines,
|
|
959
977
|
F as applyPatchOp,
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
978
|
+
T as cloneSpec,
|
|
979
|
+
ve as createSpecStreamCompiler,
|
|
980
|
+
Ae as createSurfaceHost,
|
|
963
981
|
V as emptySpec,
|
|
964
|
-
|
|
982
|
+
B as expand,
|
|
965
983
|
M as getAtPointer,
|
|
966
984
|
oe as healJsonLine,
|
|
967
985
|
W as normaliseWireComponent,
|
|
@@ -969,9 +987,9 @@ export {
|
|
|
969
987
|
Z as parsePointer,
|
|
970
988
|
H as reachableIds,
|
|
971
989
|
j as resolveValue,
|
|
972
|
-
|
|
990
|
+
Y as serializeSpec,
|
|
973
991
|
I as setAtPointer,
|
|
974
|
-
|
|
992
|
+
$e as toA2uiErrors,
|
|
975
993
|
J as validateSpec
|
|
976
994
|
};
|
|
977
995
|
//# sourceMappingURL=eddie-render.js.map
|