@templatical/quality 0.9.0 → 0.10.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/dist/index.d.ts +18 -0
- package/dist/index.js +194 -185
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var u = Object.defineProperty, d = (e, t) => {
|
|
|
13
13
|
minFontSize: 14,
|
|
14
14
|
allCapsMinLength: 20,
|
|
15
15
|
minTouchTargetPx: 44
|
|
16
|
-
},
|
|
16
|
+
}, ne = [
|
|
17
17
|
"localhost",
|
|
18
18
|
"127.0.0.1",
|
|
19
19
|
"0.0.0.0",
|
|
@@ -23,50 +23,50 @@ var u = Object.defineProperty, d = (e, t) => {
|
|
|
23
23
|
];
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/contrast.ts
|
|
26
|
-
function
|
|
27
|
-
let n =
|
|
26
|
+
function p(e, t) {
|
|
27
|
+
let n = m(e), r = m(t);
|
|
28
28
|
if (!n || !r) return NaN;
|
|
29
|
-
let i =
|
|
29
|
+
let i = oe(n), a = oe(r), o = Math.max(i, a), s = Math.min(i, a);
|
|
30
30
|
return (o + .05) / (s + .05);
|
|
31
31
|
}
|
|
32
|
-
var
|
|
33
|
-
function
|
|
32
|
+
var re = /^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i, ie = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i, ae = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i;
|
|
33
|
+
function m(e) {
|
|
34
34
|
if (typeof e != "string") return null;
|
|
35
|
-
let t = e.trim(), n =
|
|
35
|
+
let t = e.trim(), n = ae.exec(t);
|
|
36
36
|
if (n) return n[4].toLowerCase() === "ff" ? {
|
|
37
37
|
r: parseInt(n[1], 16),
|
|
38
38
|
g: parseInt(n[2], 16),
|
|
39
39
|
b: parseInt(n[3], 16)
|
|
40
40
|
} : null;
|
|
41
|
-
let r =
|
|
41
|
+
let r = ie.exec(t);
|
|
42
42
|
if (r) return {
|
|
43
43
|
r: parseInt(r[1], 16),
|
|
44
44
|
g: parseInt(r[2], 16),
|
|
45
45
|
b: parseInt(r[3], 16)
|
|
46
46
|
};
|
|
47
|
-
let i =
|
|
47
|
+
let i = re.exec(t);
|
|
48
48
|
return i ? {
|
|
49
49
|
r: parseInt(i[1] + i[1], 16),
|
|
50
50
|
g: parseInt(i[2] + i[2], 16),
|
|
51
51
|
b: parseInt(i[3] + i[3], 16)
|
|
52
52
|
} : null;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
return
|
|
54
|
+
function h(e) {
|
|
55
|
+
return m(e ?? "") !== null;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
let r =
|
|
57
|
+
function oe({ r: e, g: t, b: n }) {
|
|
58
|
+
let r = g(e / 255), i = g(t / 255), a = g(n / 255);
|
|
59
59
|
return .2126 * r + .7152 * i + .0722 * a;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function g(e) {
|
|
62
62
|
return e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
63
63
|
}
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/walk.ts
|
|
66
|
-
var
|
|
67
|
-
function
|
|
68
|
-
let n =
|
|
69
|
-
let i = e.styles?.backgroundColor, a =
|
|
66
|
+
var se = "#ffffff";
|
|
67
|
+
function _(e, t) {
|
|
68
|
+
let n = h(e.settings.backgroundColor) ? e.settings.backgroundColor.toLowerCase() : se, r = (e, n) => {
|
|
69
|
+
let i = e.styles?.backgroundColor, a = h(i) ? i.toLowerCase() : n.resolvedBackgroundColor;
|
|
70
70
|
t(e, a === n.resolvedBackgroundColor ? n : {
|
|
71
71
|
...n,
|
|
72
72
|
resolvedBackgroundColor: a
|
|
@@ -90,7 +90,7 @@ function y(e, t) {
|
|
|
90
90
|
}
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region src/run-rules.ts
|
|
93
|
-
function
|
|
93
|
+
function v(e, t, n, r) {
|
|
94
94
|
let i = [];
|
|
95
95
|
function a(e, t, i) {
|
|
96
96
|
return {
|
|
@@ -101,7 +101,7 @@ function b(e, t, n, r) {
|
|
|
101
101
|
fix: i.fix
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
_(e, (e, r) => {
|
|
105
105
|
for (let o of t) {
|
|
106
106
|
let t = n.severity(o.meta.id);
|
|
107
107
|
if (t === "off" || !o.block) continue;
|
|
@@ -117,11 +117,11 @@ function b(e, t, n, r) {
|
|
|
117
117
|
}
|
|
118
118
|
return i;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function y(e) {
|
|
121
121
|
let t = e.overrides ?? {}, n = {
|
|
122
122
|
...f,
|
|
123
123
|
...e.thresholds ?? {}
|
|
124
|
-
}, r = { nonProductionHosts: e.nonProductionHosts ??
|
|
124
|
+
}, r = { nonProductionHosts: e.nonProductionHosts ?? ne }, i = e.locale ?? "en", a = e.rules;
|
|
125
125
|
return {
|
|
126
126
|
locale: i,
|
|
127
127
|
rules: t,
|
|
@@ -133,8 +133,8 @@ function x(e) {
|
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
return
|
|
136
|
+
function ce(e, t, n) {
|
|
137
|
+
return y({
|
|
138
138
|
locale: e,
|
|
139
139
|
rules: n,
|
|
140
140
|
overrides: t.rules,
|
|
@@ -142,8 +142,8 @@ function oe(e, t, n) {
|
|
|
142
142
|
nonProductionHosts: void 0
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
return
|
|
145
|
+
function le(e, t, n) {
|
|
146
|
+
return y({
|
|
147
147
|
locale: e,
|
|
148
148
|
rules: n,
|
|
149
149
|
overrides: t.rules,
|
|
@@ -151,8 +151,8 @@ function se(e, t, n) {
|
|
|
151
151
|
nonProductionHosts: void 0
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
return
|
|
154
|
+
function ue(e, t, n) {
|
|
155
|
+
return y({
|
|
156
156
|
locale: e,
|
|
157
157
|
rules: n,
|
|
158
158
|
overrides: t.rules,
|
|
@@ -162,7 +162,7 @@ function ce(e, t, n) {
|
|
|
162
162
|
}
|
|
163
163
|
//#endregion
|
|
164
164
|
//#region src/accessibility/messages/de.ts
|
|
165
|
-
var
|
|
165
|
+
var de = /* @__PURE__ */ d({ default: () => fe }), fe = {
|
|
166
166
|
"a11y.img-missing-alt": "Bild ohne Alt-Text. Füge eine kurze Beschreibung hinzu oder markiere das Bild als dekorativ.",
|
|
167
167
|
"a11y.img-alt-is-filename": "Alt-Text sieht wie ein Dateiname aus (\"{alt}\"). Beschreibe stattdessen kurz, was das Bild zeigt.",
|
|
168
168
|
"a11y.img-alt-too-long": "Alt-Text ist {length} Zeichen lang; bleibe unter {max}.",
|
|
@@ -183,7 +183,7 @@ var le = /* @__PURE__ */ d({ default: () => ue }), ue = {
|
|
|
183
183
|
"a11y.button-touch-target": "Button ist etwa {height}px hoch; mindestens {min}px verwenden, um Fehltipper auf Mobilgeräten zu vermeiden.",
|
|
184
184
|
"a11y.button-low-contrast": "Buttontextkontrast beträgt {ratio}:1; WCAG AA verlangt mindestens {required}:1.",
|
|
185
185
|
"a11y.missing-preheader": "Kein Preheader-Text gesetzt. Postfächer zeigen sonst Bruchstücke des ersten Blocks an."
|
|
186
|
-
},
|
|
186
|
+
}, pe = /* @__PURE__ */ d({ default: () => b }), b = {
|
|
187
187
|
"a11y.img-missing-alt": "Image is missing alt text. Add a short description, or mark the image as decorative.",
|
|
188
188
|
"a11y.img-alt-is-filename": "Alt text looks like a filename (\"{alt}\"). Replace with a short description of what the image conveys.",
|
|
189
189
|
"a11y.img-alt-too-long": "Alt text is {length} characters; aim for under {max}.",
|
|
@@ -204,28 +204,28 @@ var le = /* @__PURE__ */ d({ default: () => ue }), ue = {
|
|
|
204
204
|
"a11y.button-touch-target": "Button is roughly {height}px tall; aim for at least {min}px to avoid mis-taps on mobile.",
|
|
205
205
|
"a11y.button-low-contrast": "Button text contrast is {ratio}:1; WCAG AA requires at least {required}:1.",
|
|
206
206
|
"a11y.missing-preheader": "No preheader text set. Inboxes will fall back to fragments of the first block."
|
|
207
|
-
},
|
|
208
|
-
"./de.ts":
|
|
209
|
-
"./en.ts":
|
|
210
|
-
}),
|
|
211
|
-
for (let e in
|
|
207
|
+
}, x = /* @__PURE__ */ Object.assign({
|
|
208
|
+
"./de.ts": de,
|
|
209
|
+
"./en.ts": pe
|
|
210
|
+
}), S = {};
|
|
211
|
+
for (let e in x) {
|
|
212
212
|
let t = /\.\/([^/]+)\.ts$/.exec(e);
|
|
213
213
|
if (!t) continue;
|
|
214
214
|
let n = t[1];
|
|
215
|
-
n !== "index" && (
|
|
215
|
+
n !== "index" && (S[n] = x[e].default);
|
|
216
216
|
}
|
|
217
|
-
var
|
|
218
|
-
function
|
|
219
|
-
return
|
|
217
|
+
var me = Object.keys(S);
|
|
218
|
+
function C(e) {
|
|
219
|
+
return S[e.split("-")[0]?.toLowerCase() ?? "en"] ?? S.en ?? b;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
let r =
|
|
221
|
+
function w(e, t, n) {
|
|
222
|
+
let r = C(e)[t] ?? b[t];
|
|
223
223
|
return n ? r.replace(/\{(\w+)\}/g, (e, t) => {
|
|
224
224
|
let r = n[t];
|
|
225
225
|
return r === void 0 ? `{${t}}` : String(r);
|
|
226
226
|
}) : r;
|
|
227
227
|
}
|
|
228
|
-
var
|
|
228
|
+
var he = {
|
|
229
229
|
meta: {
|
|
230
230
|
id: "a11y.img-missing-alt",
|
|
231
231
|
severity: "error"
|
|
@@ -233,26 +233,26 @@ var pe = {
|
|
|
233
233
|
block(e) {
|
|
234
234
|
return !r(e) || e.decorative === !0 || (e.alt?.trim() ?? "") !== "" || (e.src ?? "").trim() === "" ? null : { blockId: e.id };
|
|
235
235
|
}
|
|
236
|
-
},
|
|
236
|
+
}, ge = {
|
|
237
237
|
id: "a11y.img-alt-is-filename",
|
|
238
238
|
severity: "warning"
|
|
239
|
-
},
|
|
239
|
+
}, _e = [
|
|
240
240
|
/\.(jpe?g|png|gif|webp|svg)$/i,
|
|
241
241
|
/^IMG[_-]?\d+/i,
|
|
242
242
|
/^Untitled/i,
|
|
243
243
|
/^Screen[\s_-]?Shot/i,
|
|
244
244
|
/^DSC[_-]?\d+/i
|
|
245
|
-
],
|
|
246
|
-
meta:
|
|
245
|
+
], ve = {
|
|
246
|
+
meta: ge,
|
|
247
247
|
block(e) {
|
|
248
248
|
if (!r(e) || e.decorative === !0) return null;
|
|
249
249
|
let t = e.alt?.trim() ?? "";
|
|
250
|
-
return t === "" || !
|
|
250
|
+
return t === "" || !_e.some((e) => e.test(t)) ? null : {
|
|
251
251
|
blockId: e.id,
|
|
252
252
|
params: { alt: t }
|
|
253
253
|
};
|
|
254
254
|
}
|
|
255
|
-
},
|
|
255
|
+
}, ye = {
|
|
256
256
|
meta: {
|
|
257
257
|
id: "a11y.img-alt-too-long",
|
|
258
258
|
severity: "warning"
|
|
@@ -268,7 +268,7 @@ var pe = {
|
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
|
-
},
|
|
271
|
+
}, be = {
|
|
272
272
|
meta: {
|
|
273
273
|
id: "a11y.img-decorative-needs-empty-alt",
|
|
274
274
|
severity: "info"
|
|
@@ -282,7 +282,7 @@ var pe = {
|
|
|
282
282
|
}
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
|
-
},
|
|
285
|
+
}, xe = /* @__PURE__ */ d({ default: () => Se }), Se = {
|
|
286
286
|
vagueLinkText: [
|
|
287
287
|
"hier klicken",
|
|
288
288
|
"hier",
|
|
@@ -325,7 +325,7 @@ var pe = {
|
|
|
325
325
|
"anschauen",
|
|
326
326
|
"jetzt"
|
|
327
327
|
]
|
|
328
|
-
},
|
|
328
|
+
}, Ce = /* @__PURE__ */ d({ default: () => we }), we = {
|
|
329
329
|
vagueLinkText: [
|
|
330
330
|
"click here",
|
|
331
331
|
"here",
|
|
@@ -366,33 +366,33 @@ var pe = {
|
|
|
366
366
|
"redeem",
|
|
367
367
|
"watch"
|
|
368
368
|
]
|
|
369
|
-
},
|
|
370
|
-
"./de.ts":
|
|
371
|
-
"./en.ts":
|
|
372
|
-
}),
|
|
373
|
-
for (let e in
|
|
369
|
+
}, T = /* @__PURE__ */ Object.assign({
|
|
370
|
+
"./de.ts": xe,
|
|
371
|
+
"./en.ts": Ce
|
|
372
|
+
}), E = {};
|
|
373
|
+
for (let e in T) {
|
|
374
374
|
let t = /\.\/([^/]+)\.ts$/.exec(e);
|
|
375
375
|
if (!t) continue;
|
|
376
376
|
let n = t[1];
|
|
377
|
-
n !== "index" && (
|
|
377
|
+
n !== "index" && (E[n] = T[e].default);
|
|
378
378
|
}
|
|
379
|
-
function
|
|
380
|
-
return
|
|
379
|
+
function D(e) {
|
|
380
|
+
return Te;
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function O(e) {
|
|
383
383
|
let t = /* @__PURE__ */ new Set();
|
|
384
|
-
for (let n of Object.values(
|
|
384
|
+
for (let n of Object.values(E)) for (let r of e(n)) t.add(r);
|
|
385
385
|
return Array.from(t);
|
|
386
386
|
}
|
|
387
|
-
var
|
|
388
|
-
vagueLinkText:
|
|
389
|
-
vagueButtonLabels:
|
|
390
|
-
linkedImageActionHints:
|
|
391
|
-
},
|
|
392
|
-
function
|
|
387
|
+
var Te = {
|
|
388
|
+
vagueLinkText: O((e) => e.vagueLinkText),
|
|
389
|
+
vagueButtonLabels: O((e) => e.vagueButtonLabels),
|
|
390
|
+
linkedImageActionHints: O((e) => e.linkedImageActionHints)
|
|
391
|
+
}, Ee = Object.keys(E);
|
|
392
|
+
function k(e) {
|
|
393
393
|
return e.toLowerCase().replace(/\s+/g, " ").replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, "").trim();
|
|
394
394
|
}
|
|
395
|
-
var
|
|
395
|
+
var De = {
|
|
396
396
|
meta: {
|
|
397
397
|
id: "a11y.img-linked-no-context",
|
|
398
398
|
severity: "warning"
|
|
@@ -401,13 +401,13 @@ var Te = {
|
|
|
401
401
|
if (!r(e) || e.decorative === !0 || !e.linkUrl || e.linkUrl.trim() === "") return null;
|
|
402
402
|
let i = (e.alt ?? "").trim();
|
|
403
403
|
if (i === "") return null;
|
|
404
|
-
let a = i.toLocaleLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean), o =
|
|
404
|
+
let a = i.toLocaleLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean), o = D(n.locale).linkedImageActionHints;
|
|
405
405
|
return a.some((e) => o.includes(e)) ? null : { blockId: e.id };
|
|
406
406
|
}
|
|
407
407
|
};
|
|
408
408
|
//#endregion
|
|
409
409
|
//#region src/html-utils.ts
|
|
410
|
-
function
|
|
410
|
+
function A(e) {
|
|
411
411
|
let t = [], n = null, r = "", i = () => {
|
|
412
412
|
n !== null && (n.text = r.trim(), t.push(n), n = null, r = "");
|
|
413
413
|
}, a = new l({
|
|
@@ -433,8 +433,8 @@ function M(e) {
|
|
|
433
433
|
});
|
|
434
434
|
return a.write(e), a.end(), i(), t;
|
|
435
435
|
}
|
|
436
|
-
function
|
|
437
|
-
let t =
|
|
436
|
+
function j(e) {
|
|
437
|
+
let t = Oe(e).matchAll(/<\/?a\b[^<>]*>/gi), n = 0;
|
|
438
438
|
for (let e of t) {
|
|
439
439
|
if (e[0].startsWith("</")) {
|
|
440
440
|
n > 0 && n--;
|
|
@@ -445,7 +445,7 @@ function Ee(e) {
|
|
|
445
445
|
}
|
|
446
446
|
return !1;
|
|
447
447
|
}
|
|
448
|
-
function
|
|
448
|
+
function Oe(e) {
|
|
449
449
|
let t = "", n = 0;
|
|
450
450
|
for (; n < e.length;) {
|
|
451
451
|
let r = e.indexOf("<!--", n);
|
|
@@ -460,38 +460,38 @@ function De(e) {
|
|
|
460
460
|
}
|
|
461
461
|
return t;
|
|
462
462
|
}
|
|
463
|
-
function
|
|
463
|
+
function M(e) {
|
|
464
464
|
let t = "", n = new l({ ontext(e) {
|
|
465
465
|
t += e;
|
|
466
466
|
} });
|
|
467
467
|
return n.write(e), n.end(), t.trim();
|
|
468
468
|
}
|
|
469
|
-
var
|
|
469
|
+
var ke = {
|
|
470
470
|
meta: {
|
|
471
471
|
id: "a11y.heading-empty",
|
|
472
472
|
severity: "error"
|
|
473
473
|
},
|
|
474
474
|
block(e) {
|
|
475
|
-
return !c(e) ||
|
|
475
|
+
return !c(e) || M(e.content ?? "") !== "" ? null : { blockId: e.id };
|
|
476
476
|
}
|
|
477
|
-
},
|
|
477
|
+
}, Ae = {
|
|
478
478
|
id: "a11y.heading-skip-level",
|
|
479
479
|
severity: "error"
|
|
480
480
|
};
|
|
481
|
-
function
|
|
481
|
+
function N(e, t) {
|
|
482
482
|
for (let n of e) {
|
|
483
483
|
if (c(n)) {
|
|
484
484
|
t.push(n);
|
|
485
485
|
continue;
|
|
486
486
|
}
|
|
487
|
-
if (o(n)) for (let e of n.children)
|
|
487
|
+
if (o(n)) for (let e of n.children) N(e, t);
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
|
-
var
|
|
491
|
-
meta:
|
|
490
|
+
var je = {
|
|
491
|
+
meta: Ae,
|
|
492
492
|
template(e) {
|
|
493
493
|
let t = [];
|
|
494
|
-
|
|
494
|
+
N(e.blocks, t);
|
|
495
495
|
let n = [], r = 0;
|
|
496
496
|
for (let e of t) r !== 0 && e.level > r + 1 && n.push({
|
|
497
497
|
blockId: e.id,
|
|
@@ -502,54 +502,54 @@ var Ae = {
|
|
|
502
502
|
}), r = e.level;
|
|
503
503
|
return n;
|
|
504
504
|
}
|
|
505
|
-
},
|
|
505
|
+
}, Me = {
|
|
506
506
|
id: "a11y.heading-multiple-h1",
|
|
507
507
|
severity: "warning"
|
|
508
508
|
};
|
|
509
|
-
function
|
|
509
|
+
function P(e, t) {
|
|
510
510
|
for (let n of e) {
|
|
511
511
|
if (c(n)) {
|
|
512
512
|
t.push(n);
|
|
513
513
|
continue;
|
|
514
514
|
}
|
|
515
|
-
if (o(n)) for (let e of n.children)
|
|
515
|
+
if (o(n)) for (let e of n.children) P(e, t);
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
-
var
|
|
519
|
-
meta:
|
|
518
|
+
var Ne = {
|
|
519
|
+
meta: Me,
|
|
520
520
|
template(e) {
|
|
521
521
|
let t = [];
|
|
522
|
-
|
|
522
|
+
P(e.blocks, t);
|
|
523
523
|
let n = t.filter((e) => e.level === 1);
|
|
524
524
|
return n.length <= 1 ? [] : n.slice(1).map((e) => ({ blockId: e.id }));
|
|
525
525
|
}
|
|
526
|
-
},
|
|
526
|
+
}, Pe = {
|
|
527
527
|
id: "a11y.link-empty",
|
|
528
528
|
severity: "error"
|
|
529
529
|
};
|
|
530
|
-
function
|
|
530
|
+
function Fe(e) {
|
|
531
531
|
return a(e) || c(e) ? e.content : null;
|
|
532
532
|
}
|
|
533
|
-
var
|
|
534
|
-
meta:
|
|
533
|
+
var Ie = {
|
|
534
|
+
meta: Pe,
|
|
535
535
|
block(e) {
|
|
536
|
-
let t =
|
|
537
|
-
return t === null || !
|
|
536
|
+
let t = Fe(e);
|
|
537
|
+
return t === null || !A(t).find((e) => e.text === "" && !e.hasImageWithAlt) ? null : { blockId: e.id };
|
|
538
538
|
}
|
|
539
|
-
},
|
|
539
|
+
}, Le = {
|
|
540
540
|
id: "a11y.link-vague-text",
|
|
541
541
|
severity: "warning"
|
|
542
542
|
};
|
|
543
|
-
function
|
|
543
|
+
function Re(e) {
|
|
544
544
|
return a(e) || c(e) ? e.content : null;
|
|
545
545
|
}
|
|
546
|
-
var
|
|
547
|
-
meta:
|
|
546
|
+
var ze = {
|
|
547
|
+
meta: Le,
|
|
548
548
|
block(e, t, n) {
|
|
549
|
-
let r =
|
|
549
|
+
let r = Re(e);
|
|
550
550
|
if (r === null) return null;
|
|
551
|
-
let i =
|
|
552
|
-
let t =
|
|
551
|
+
let i = D(n.locale).vagueLinkText, a = A(r).find((e) => {
|
|
552
|
+
let t = k(e.text);
|
|
553
553
|
return t !== "" && i.includes(t);
|
|
554
554
|
});
|
|
555
555
|
return a ? {
|
|
@@ -557,53 +557,53 @@ var Re = {
|
|
|
557
557
|
params: { text: a.text }
|
|
558
558
|
} : null;
|
|
559
559
|
}
|
|
560
|
-
},
|
|
560
|
+
}, Be = {
|
|
561
561
|
id: "a11y.link-href-empty",
|
|
562
562
|
severity: "error"
|
|
563
563
|
};
|
|
564
|
-
function
|
|
564
|
+
function Ve(e) {
|
|
565
565
|
return a(e) || c(e) ? e.content : null;
|
|
566
566
|
}
|
|
567
|
-
var
|
|
568
|
-
meta:
|
|
567
|
+
var He = {
|
|
568
|
+
meta: Be,
|
|
569
569
|
block(e) {
|
|
570
|
-
let t =
|
|
571
|
-
return t === null || !
|
|
570
|
+
let t = Ve(e);
|
|
571
|
+
return t === null || !A(t).find((e) => {
|
|
572
572
|
let t = e.href.trim();
|
|
573
573
|
return t === "" || t === "#";
|
|
574
574
|
}) ? null : { blockId: e.id };
|
|
575
575
|
}
|
|
576
|
-
},
|
|
576
|
+
}, Ue = {
|
|
577
577
|
id: "a11y.link-target-blank-no-rel",
|
|
578
578
|
severity: "warning"
|
|
579
579
|
};
|
|
580
|
-
function
|
|
580
|
+
function We(e) {
|
|
581
581
|
return a(e) || c(e) ? e.content : null;
|
|
582
582
|
}
|
|
583
|
-
function
|
|
583
|
+
function Ge(e) {
|
|
584
584
|
if (e === null) return !1;
|
|
585
585
|
let t = e.toLowerCase().split(/\s+/);
|
|
586
586
|
return t.includes("noopener") || t.includes("noreferrer");
|
|
587
587
|
}
|
|
588
|
-
var
|
|
589
|
-
meta:
|
|
588
|
+
var Ke = {
|
|
589
|
+
meta: Ue,
|
|
590
590
|
block(e) {
|
|
591
|
-
let t =
|
|
592
|
-
return t === null || !
|
|
591
|
+
let t = We(e);
|
|
592
|
+
return t === null || !A(t).find((e) => e.target === "_blank" && !Ge(e.rel)) ? null : {
|
|
593
593
|
blockId: e.id,
|
|
594
594
|
fix: {
|
|
595
595
|
description: "Add rel=\"noopener\"",
|
|
596
596
|
apply: (t) => {
|
|
597
597
|
if (!a(e) && !c(e)) return;
|
|
598
|
-
let n =
|
|
598
|
+
let n = Ye(e.content ?? "");
|
|
599
599
|
t.updateBlock(e.id, { content: n });
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
602
|
};
|
|
603
603
|
}
|
|
604
|
-
},
|
|
605
|
-
function
|
|
606
|
-
let t = [], n = new RegExp(
|
|
604
|
+
}, F = /([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
|
|
605
|
+
function qe(e) {
|
|
606
|
+
let t = [], n = new RegExp(F.source, F.flags), r;
|
|
607
607
|
for (; (r = n.exec(e)) !== null;) {
|
|
608
608
|
let e = r[2] ?? r[3] ?? r[4] ?? null;
|
|
609
609
|
t.push({
|
|
@@ -615,13 +615,13 @@ function Ke(e) {
|
|
|
615
615
|
}
|
|
616
616
|
return t;
|
|
617
617
|
}
|
|
618
|
-
function
|
|
618
|
+
function Je(e) {
|
|
619
619
|
return e.some((e) => e.name.toLowerCase() === "target" && e.value !== null && e.value.toLowerCase() === "_blank");
|
|
620
620
|
}
|
|
621
|
-
function
|
|
621
|
+
function Ye(e) {
|
|
622
622
|
return e.replace(/<a\b([^>]*)>/gi, (e, t) => {
|
|
623
|
-
let n =
|
|
624
|
-
if (!
|
|
623
|
+
let n = qe(t);
|
|
624
|
+
if (!Je(n)) return e;
|
|
625
625
|
let r = n.find((e) => e.name.toLowerCase() === "rel");
|
|
626
626
|
if (r) {
|
|
627
627
|
let n = (r.value ?? "").toLowerCase().split(/\s+/);
|
|
@@ -634,37 +634,37 @@ function Je(e) {
|
|
|
634
634
|
}
|
|
635
635
|
//#endregion
|
|
636
636
|
//#region src/accessibility/rules/link-nested-anchor.ts
|
|
637
|
-
var
|
|
637
|
+
var Xe = {
|
|
638
638
|
id: "a11y.link-nested-anchor",
|
|
639
639
|
severity: "error"
|
|
640
640
|
};
|
|
641
|
-
function
|
|
641
|
+
function Ze(e) {
|
|
642
642
|
return a(e) || c(e) ? e.content : null;
|
|
643
643
|
}
|
|
644
|
-
var
|
|
645
|
-
meta:
|
|
644
|
+
var Qe = {
|
|
645
|
+
meta: Xe,
|
|
646
646
|
block(e) {
|
|
647
|
-
let t =
|
|
648
|
-
return t === null || !
|
|
647
|
+
let t = Ze(e);
|
|
648
|
+
return t === null || !j(t) ? null : { blockId: e.id };
|
|
649
649
|
}
|
|
650
|
-
},
|
|
650
|
+
}, $e = {
|
|
651
651
|
meta: {
|
|
652
652
|
id: "a11y.text-all-caps",
|
|
653
653
|
severity: "warning"
|
|
654
654
|
},
|
|
655
655
|
block(e, t, n) {
|
|
656
656
|
if (!a(e) && !c(e)) return null;
|
|
657
|
-
let r =
|
|
657
|
+
let r = M(e.content ?? "").replace(/[^\p{L}]/gu, "");
|
|
658
658
|
return r.length < n.thresholds.allCapsMinLength || r !== r.toLocaleUpperCase() ? null : { blockId: e.id };
|
|
659
659
|
}
|
|
660
|
-
},
|
|
660
|
+
}, et = {
|
|
661
661
|
meta: {
|
|
662
662
|
id: "a11y.text-low-contrast",
|
|
663
663
|
severity: "error"
|
|
664
664
|
},
|
|
665
665
|
block(t, n) {
|
|
666
|
-
if (!c(t) || !
|
|
667
|
-
let r = e[t.level] >= 24 ? 3 : 4.5, i =
|
|
666
|
+
if (!c(t) || !h(t.color) || !h(n.resolvedBackgroundColor)) return null;
|
|
667
|
+
let r = e[t.level] >= 24 ? 3 : 4.5, i = p(t.color, n.resolvedBackgroundColor);
|
|
668
668
|
return Number.isNaN(i) || i >= r ? null : {
|
|
669
669
|
blockId: t.id,
|
|
670
670
|
params: {
|
|
@@ -673,35 +673,35 @@ var Ze = {
|
|
|
673
673
|
}
|
|
674
674
|
};
|
|
675
675
|
}
|
|
676
|
-
},
|
|
676
|
+
}, tt = {
|
|
677
677
|
id: "a11y.text-too-small",
|
|
678
678
|
severity: "warning"
|
|
679
679
|
};
|
|
680
|
-
function
|
|
680
|
+
function nt(e) {
|
|
681
681
|
return i(e) || ee(e) ? e.fontSize : null;
|
|
682
682
|
}
|
|
683
683
|
//#endregion
|
|
684
684
|
//#region src/accessibility/index.ts
|
|
685
|
-
var
|
|
686
|
-
|
|
687
|
-
ge,
|
|
688
|
-
_e,
|
|
685
|
+
var I = [
|
|
686
|
+
he,
|
|
689
687
|
ve,
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
688
|
+
ye,
|
|
689
|
+
be,
|
|
690
|
+
De,
|
|
691
|
+
ke,
|
|
692
|
+
je,
|
|
693
|
+
Ne,
|
|
694
|
+
Ie,
|
|
695
|
+
ze,
|
|
696
|
+
He,
|
|
697
|
+
Ke,
|
|
699
698
|
Qe,
|
|
700
699
|
$e,
|
|
700
|
+
et,
|
|
701
701
|
{
|
|
702
|
-
meta:
|
|
702
|
+
meta: tt,
|
|
703
703
|
block(e, t, n) {
|
|
704
|
-
let r =
|
|
704
|
+
let r = nt(e);
|
|
705
705
|
return r === null || r >= n.thresholds.minFontSize ? null : {
|
|
706
706
|
blockId: e.id,
|
|
707
707
|
params: {
|
|
@@ -718,8 +718,8 @@ var L = [
|
|
|
718
718
|
},
|
|
719
719
|
block(e, n, r) {
|
|
720
720
|
if (!t(e)) return null;
|
|
721
|
-
let i =
|
|
722
|
-
return i === "" || !
|
|
721
|
+
let i = k(e.text ?? "");
|
|
722
|
+
return i === "" || !D(r.locale).vagueButtonLabels.includes(i) ? null : {
|
|
723
723
|
blockId: e.id,
|
|
724
724
|
params: { text: e.text }
|
|
725
725
|
};
|
|
@@ -751,7 +751,7 @@ var L = [
|
|
|
751
751
|
},
|
|
752
752
|
block(e) {
|
|
753
753
|
if (!t(e)) return null;
|
|
754
|
-
let n =
|
|
754
|
+
let n = p(e.textColor, e.backgroundColor);
|
|
755
755
|
if (Number.isNaN(n)) return null;
|
|
756
756
|
let r = e.fontSize >= 24 ? 3 : 4.5;
|
|
757
757
|
return n >= r ? null : {
|
|
@@ -773,10 +773,10 @@ var L = [
|
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
775
|
];
|
|
776
|
-
function
|
|
776
|
+
function L(e, t = {}) {
|
|
777
777
|
if (t.disabled === !0 || t.accessibility === !1) return [];
|
|
778
778
|
let n = t.accessibility ?? {};
|
|
779
|
-
return
|
|
779
|
+
return v(e, I, ce(t.locale, n, I), (e, t, n) => w(e, t, n));
|
|
780
780
|
}
|
|
781
781
|
//#endregion
|
|
782
782
|
//#region src/structure/messages/de.ts
|
|
@@ -922,41 +922,41 @@ var G = [
|
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
924
|
];
|
|
925
|
-
function
|
|
925
|
+
function K(e, t = {}) {
|
|
926
926
|
if (t.disabled === !0 || t.structure === !1) return [];
|
|
927
927
|
let n = t.structure ?? {};
|
|
928
|
-
return
|
|
928
|
+
return v(e, G, le(t.locale, n, G), (e, t, n) => H(e, t, n));
|
|
929
929
|
}
|
|
930
930
|
//#endregion
|
|
931
931
|
//#region src/links/messages/de.ts
|
|
932
|
-
var
|
|
932
|
+
var _t = /* @__PURE__ */ d({ default: () => vt }), vt = {
|
|
933
933
|
"link.javascript-protocol": "Die URL verwendet das Protokoll „{protocol}:\", das beliebigen Skriptcode ausführen kann und aus Sicherheitsgründen beim Rendern entfernt wird. Ersetze sie durch eine echte URL oder entferne sie.",
|
|
934
934
|
"link.unsupported-protocol": "Die URL verwendet das Protokoll „{protocol}\", das von den meisten E-Mail-Clients nicht unterstützt wird. Verwende http, https, mailto, tel oder sms.",
|
|
935
935
|
"link.malformed-mailto": "Der mailto:-Link ist fehlerhaft. Erwartet wird eine einzelne Empfängeradresse vor einer eventuellen Querystring (z. B. mailto:hallo@example.com).",
|
|
936
936
|
"link.malformed-tel": "Der tel:-Link enthält Zeichen, die keine Ziffern, +, Leerzeichen, Bindestriche, Klammern oder Punkte sind.",
|
|
937
937
|
"link.localhost-or-staging": "Der URL-Host „{host}\" entspricht einem Nicht-Produktionsmuster. Ersetze ihn vor dem Versand durch die Produktions-URL."
|
|
938
|
-
},
|
|
938
|
+
}, yt = /* @__PURE__ */ d({ default: () => q }), q = {
|
|
939
939
|
"link.javascript-protocol": "URL uses the \"{protocol}:\" protocol, which can execute arbitrary script and is stripped at render time for safety. Replace it with a real link or remove the URL.",
|
|
940
940
|
"link.unsupported-protocol": "URL uses the \"{protocol}\" protocol, which most email clients do not support. Use http, https, mailto, tel, or sms.",
|
|
941
941
|
"link.malformed-mailto": "mailto: link is malformed. Expected a single recipient address before any query string (e.g. mailto:hello@example.com).",
|
|
942
942
|
"link.malformed-tel": "tel: link contains characters that are not digits, +, spaces, dashes, parentheses, or dots.",
|
|
943
943
|
"link.localhost-or-staging": "URL host \"{host}\" matches a non-production pattern. Replace with the production URL before sending."
|
|
944
|
-
},
|
|
945
|
-
"./de.ts":
|
|
946
|
-
"./en.ts":
|
|
947
|
-
}),
|
|
948
|
-
for (let e in
|
|
944
|
+
}, J = /* @__PURE__ */ Object.assign({
|
|
945
|
+
"./de.ts": _t,
|
|
946
|
+
"./en.ts": yt
|
|
947
|
+
}), Y = {};
|
|
948
|
+
for (let e in J) {
|
|
949
949
|
let t = /\.\/([^/]+)\.ts$/.exec(e);
|
|
950
950
|
if (!t) continue;
|
|
951
951
|
let n = t[1];
|
|
952
|
-
n !== "index" && (
|
|
952
|
+
n !== "index" && (Y[n] = J[e].default);
|
|
953
953
|
}
|
|
954
|
-
var
|
|
955
|
-
function
|
|
956
|
-
return
|
|
954
|
+
var bt = Object.keys(Y);
|
|
955
|
+
function X(e) {
|
|
956
|
+
return Y[e.split("-")[0]?.toLowerCase() ?? "en"] ?? Y.en ?? q;
|
|
957
957
|
}
|
|
958
|
-
function
|
|
959
|
-
let r =
|
|
958
|
+
function Z(e, t, n) {
|
|
959
|
+
let r = X(e)[t] ?? q[t];
|
|
960
960
|
return n ? r.replace(/\{(\w+)\}/g, (e, t) => {
|
|
961
961
|
let r = n[t];
|
|
962
962
|
return r === void 0 ? `{${t}}` : String(r);
|
|
@@ -964,11 +964,11 @@ function X(e, t, n) {
|
|
|
964
964
|
}
|
|
965
965
|
//#endregion
|
|
966
966
|
//#region src/url-walker.ts
|
|
967
|
-
function
|
|
967
|
+
function Q(e) {
|
|
968
968
|
let o = [];
|
|
969
|
-
return
|
|
969
|
+
return _(e, (e) => {
|
|
970
970
|
if (c(e) || a(e) || n(e)) {
|
|
971
|
-
for (let t of
|
|
971
|
+
for (let t of A(e.content)) o.push({
|
|
972
972
|
url: t.href,
|
|
973
973
|
blockId: e.id,
|
|
974
974
|
source: "anchor",
|
|
@@ -1025,10 +1025,10 @@ function Z(e) {
|
|
|
1025
1025
|
}
|
|
1026
1026
|
//#endregion
|
|
1027
1027
|
//#region src/links/rules/javascript-protocol.ts
|
|
1028
|
-
var
|
|
1028
|
+
var xt = {
|
|
1029
1029
|
id: "link.javascript-protocol",
|
|
1030
1030
|
severity: "error"
|
|
1031
|
-
},
|
|
1031
|
+
}, St = [
|
|
1032
1032
|
"javascript",
|
|
1033
1033
|
"data",
|
|
1034
1034
|
"vbscript"
|
|
@@ -1036,14 +1036,14 @@ var St = {
|
|
|
1036
1036
|
function Ct(e) {
|
|
1037
1037
|
if (!e) return null;
|
|
1038
1038
|
let t = e.replace(/\s+/g, "");
|
|
1039
|
-
for (let e of
|
|
1039
|
+
for (let e of St) if (RegExp(`^${e}:`, "i").test(t)) return e;
|
|
1040
1040
|
return null;
|
|
1041
1041
|
}
|
|
1042
1042
|
var wt = {
|
|
1043
|
-
meta:
|
|
1043
|
+
meta: xt,
|
|
1044
1044
|
template(e) {
|
|
1045
1045
|
let t = [];
|
|
1046
|
-
for (let n of
|
|
1046
|
+
for (let n of Q(e)) {
|
|
1047
1047
|
let e = Ct(n.url);
|
|
1048
1048
|
e !== null && t.push({
|
|
1049
1049
|
blockId: n.blockId,
|
|
@@ -1061,7 +1061,7 @@ var wt = {
|
|
|
1061
1061
|
"mailto",
|
|
1062
1062
|
"tel",
|
|
1063
1063
|
"sms"
|
|
1064
|
-
]), Dt = new Set(
|
|
1064
|
+
]), Dt = new Set(St);
|
|
1065
1065
|
function Ot(e) {
|
|
1066
1066
|
if (!e) return null;
|
|
1067
1067
|
let t = e.trim(), n = /^([a-z][a-z0-9+\-.]*):/i.exec(t);
|
|
@@ -1071,7 +1071,7 @@ var kt = {
|
|
|
1071
1071
|
meta: Tt,
|
|
1072
1072
|
template(e) {
|
|
1073
1073
|
let t = [];
|
|
1074
|
-
for (let n of
|
|
1074
|
+
for (let n of Q(e)) {
|
|
1075
1075
|
let e = Ot(n.url);
|
|
1076
1076
|
e !== null && (Dt.has(e) || Et.has(e) || t.push({
|
|
1077
1077
|
blockId: n.blockId,
|
|
@@ -1103,7 +1103,7 @@ var Mt = {
|
|
|
1103
1103
|
meta: At,
|
|
1104
1104
|
template(e) {
|
|
1105
1105
|
let t = [];
|
|
1106
|
-
for (let n of
|
|
1106
|
+
for (let n of Q(e)) jt(n.url) && t.push({ blockId: n.blockId });
|
|
1107
1107
|
return t;
|
|
1108
1108
|
}
|
|
1109
1109
|
}, Nt = {
|
|
@@ -1122,7 +1122,7 @@ var Lt = {
|
|
|
1122
1122
|
meta: Nt,
|
|
1123
1123
|
template(e) {
|
|
1124
1124
|
let t = [];
|
|
1125
|
-
for (let n of
|
|
1125
|
+
for (let n of Q(e)) It(n.url) && t.push({ blockId: n.blockId });
|
|
1126
1126
|
return t;
|
|
1127
1127
|
}
|
|
1128
1128
|
}, Rt = {
|
|
@@ -1156,7 +1156,7 @@ var $ = [
|
|
|
1156
1156
|
let n = t.links.nonProductionHosts;
|
|
1157
1157
|
if (n.length === 0) return [];
|
|
1158
1158
|
let r = n.map(zt), i = [];
|
|
1159
|
-
for (let t of
|
|
1159
|
+
for (let t of Q(e)) {
|
|
1160
1160
|
let e = Bt(t.url);
|
|
1161
1161
|
e !== null && r.some((t) => t.test(e)) && i.push({
|
|
1162
1162
|
blockId: t.blockId,
|
|
@@ -1170,7 +1170,7 @@ var $ = [
|
|
|
1170
1170
|
function Vt(e, t = {}) {
|
|
1171
1171
|
if (t.disabled === !0 || t.links === !1) return [];
|
|
1172
1172
|
let n = t.links ?? {};
|
|
1173
|
-
return
|
|
1173
|
+
return v(e, $, ue(t.locale, n, $), (e, t, n) => Z(e, t, n));
|
|
1174
1174
|
}
|
|
1175
1175
|
//#endregion
|
|
1176
1176
|
//#region src/util.ts
|
|
@@ -1178,6 +1178,15 @@ function Ht(e) {
|
|
|
1178
1178
|
return e ? e.disabled === !0 ? !0 : e.accessibility === !1 && e.structure === !1 && e.links === !1 : !1;
|
|
1179
1179
|
}
|
|
1180
1180
|
//#endregion
|
|
1181
|
-
|
|
1181
|
+
//#region src/lint-template.ts
|
|
1182
|
+
function Ut(e, t = {}) {
|
|
1183
|
+
return Ht(t) ? [] : [
|
|
1184
|
+
...L(e, t),
|
|
1185
|
+
...K(e, t),
|
|
1186
|
+
...Vt(e, t)
|
|
1187
|
+
];
|
|
1188
|
+
}
|
|
1189
|
+
//#endregion
|
|
1190
|
+
export { I as ACCESSIBILITY_RULES, f as DEFAULT_A11Y_THRESHOLDS, ne as DEFAULT_NON_PRODUCTION_HOSTS, $ as LINK_RULES, G as STRUCTURE_RULES, Ee as SUPPORTED_DICTIONARY_LOCALES, bt as SUPPORTED_LINK_MESSAGE_LOCALES, me as SUPPORTED_MESSAGE_LOCALES, ot as SUPPORTED_STRUCTURE_MESSAGE_LOCALES, A as extractAnchors, M as extractText, Z as formatLinkMessage, w as formatMessage, H as formatStructureMessage, p as getContrastRatio, D as getDictionary, X as getLinkMessages, C as getMessages, V as getStructureMessages, j as hasNestedAnchors, Ht as isLintFullyDisabled, h as isOpaqueHex, L as lintAccessibility, Vt as lintLinks, K as lintStructure, Ut as lintTemplate, m as parseHex, _ as walkBlocks, Q as walkUrls };
|
|
1182
1191
|
|
|
1183
1192
|
//# sourceMappingURL=index.js.map
|