@templatical/quality
Advanced tools
+196
-170
@@ -436,4 +436,4 @@ import { HEADING_LEVEL_FONT_SIZE as e, isButton as t, isHtml as n, isImage as r, isMenu as i, isParagraph as a, isSection as o, isSocialIcons as s, isTable as ee, isTitle as c, isVideo as te } from "@templatical/types"; | ||
| } | ||
| function N(e) { | ||
| let t = e.replace(/<!--[\s\S]*?-->/g, "").matchAll(/<\/?a\b[^>]*>/gi), n = 0; | ||
| function Ee(e) { | ||
| let t = De(e).matchAll(/<\/?a\b[^<>]*>/gi), n = 0; | ||
| for (let e of t) { | ||
@@ -449,3 +449,18 @@ if (e[0].startsWith("</")) { | ||
| } | ||
| function P(e) { | ||
| function De(e) { | ||
| let t = "", n = 0; | ||
| for (; n < e.length;) { | ||
| let r = e.indexOf("<!--", n); | ||
| if (r === -1) { | ||
| t += e.substring(n); | ||
| break; | ||
| } | ||
| t += e.substring(n, r); | ||
| let i = e.indexOf("-->", r + 4); | ||
| if (i === -1) break; | ||
| n = i + 3; | ||
| } | ||
| return t; | ||
| } | ||
| function N(e) { | ||
| let t = "", n = new l({ ontext(e) { | ||
@@ -456,3 +471,3 @@ t += e; | ||
| } | ||
| var Ee = { | ||
| var Oe = { | ||
| meta: { | ||
@@ -463,9 +478,9 @@ id: "a11y.heading-empty", | ||
| block(e) { | ||
| return !c(e) || P(e.content ?? "") !== "" ? null : { blockId: e.id }; | ||
| return !c(e) || N(e.content ?? "") !== "" ? null : { blockId: e.id }; | ||
| } | ||
| }, De = { | ||
| }, ke = { | ||
| id: "a11y.heading-skip-level", | ||
| severity: "error" | ||
| }; | ||
| function F(e, t) { | ||
| function P(e, t) { | ||
| for (let n of e) { | ||
@@ -476,10 +491,10 @@ if (c(n)) { | ||
| } | ||
| if (o(n)) for (let e of n.children) F(e, t); | ||
| if (o(n)) for (let e of n.children) P(e, t); | ||
| } | ||
| } | ||
| var Oe = { | ||
| meta: De, | ||
| var Ae = { | ||
| meta: ke, | ||
| template(e) { | ||
| let t = []; | ||
| F(e.blocks, t); | ||
| P(e.blocks, t); | ||
| let n = [], r = 0; | ||
@@ -495,7 +510,7 @@ for (let e of t) r !== 0 && e.level > r + 1 && n.push({ | ||
| } | ||
| }, ke = { | ||
| }, je = { | ||
| id: "a11y.heading-multiple-h1", | ||
| severity: "warning" | ||
| }; | ||
| function I(e, t) { | ||
| function F(e, t) { | ||
| for (let n of e) { | ||
@@ -506,37 +521,37 @@ if (c(n)) { | ||
| } | ||
| if (o(n)) for (let e of n.children) I(e, t); | ||
| if (o(n)) for (let e of n.children) F(e, t); | ||
| } | ||
| } | ||
| var Ae = { | ||
| meta: ke, | ||
| var Me = { | ||
| meta: je, | ||
| template(e) { | ||
| let t = []; | ||
| I(e.blocks, t); | ||
| F(e.blocks, t); | ||
| let n = t.filter((e) => e.level === 1); | ||
| return n.length <= 1 ? [] : n.slice(1).map((e) => ({ blockId: e.id })); | ||
| } | ||
| }, je = { | ||
| }, Ne = { | ||
| id: "a11y.link-empty", | ||
| severity: "error" | ||
| }; | ||
| function Me(e) { | ||
| function Pe(e) { | ||
| return a(e) || c(e) ? e.content : null; | ||
| } | ||
| var Ne = { | ||
| meta: je, | ||
| var Fe = { | ||
| meta: Ne, | ||
| block(e) { | ||
| let t = Me(e); | ||
| let t = Pe(e); | ||
| return t === null || !M(t).find((e) => e.text === "" && !e.hasImageWithAlt) ? null : { blockId: e.id }; | ||
| } | ||
| }, Pe = { | ||
| }, Ie = { | ||
| id: "a11y.link-vague-text", | ||
| severity: "warning" | ||
| }; | ||
| function Fe(e) { | ||
| function Le(e) { | ||
| return a(e) || c(e) ? e.content : null; | ||
| } | ||
| var Ie = { | ||
| meta: Pe, | ||
| var Re = { | ||
| meta: Ie, | ||
| block(e, t, n) { | ||
| let r = Fe(e); | ||
| let r = Le(e); | ||
| if (r === null) return null; | ||
@@ -552,13 +567,13 @@ let i = k(n.locale).vagueLinkText, a = M(r).find((e) => { | ||
| } | ||
| }, Le = { | ||
| }, ze = { | ||
| id: "a11y.link-href-empty", | ||
| severity: "error" | ||
| }; | ||
| function Re(e) { | ||
| function Be(e) { | ||
| return a(e) || c(e) ? e.content : null; | ||
| } | ||
| var ze = { | ||
| meta: Le, | ||
| var Ve = { | ||
| meta: ze, | ||
| block(e) { | ||
| let t = Re(e); | ||
| let t = Be(e); | ||
| return t === null || !M(t).find((e) => { | ||
@@ -569,10 +584,10 @@ let t = e.href.trim(); | ||
| } | ||
| }, Be = { | ||
| }, He = { | ||
| id: "a11y.link-target-blank-no-rel", | ||
| severity: "warning" | ||
| }; | ||
| function Ve(e) { | ||
| function Ue(e) { | ||
| return a(e) || c(e) ? e.content : null; | ||
| } | ||
| function He(e) { | ||
| function We(e) { | ||
| if (e === null) return !1; | ||
@@ -582,7 +597,7 @@ let t = e.toLowerCase().split(/\s+/); | ||
| } | ||
| var Ue = { | ||
| meta: Be, | ||
| var Ge = { | ||
| meta: He, | ||
| block(e) { | ||
| let t = Ve(e); | ||
| return t === null || !M(t).find((e) => e.target === "_blank" && !He(e.rel)) ? null : { | ||
| let t = Ue(e); | ||
| return t === null || !M(t).find((e) => e.target === "_blank" && !We(e.rel)) ? null : { | ||
| blockId: e.id, | ||
@@ -593,3 +608,3 @@ fix: { | ||
| if (!a(e) && !c(e)) return; | ||
| let n = Ke(e.content ?? ""); | ||
| let n = Je(e.content ?? ""); | ||
| t.updateBlock(e.id, { content: n }); | ||
@@ -600,5 +615,5 @@ } | ||
| } | ||
| }, L = /([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g; | ||
| function We(e) { | ||
| let t = [], n = new RegExp(L.source, L.flags), r; | ||
| }, I = /([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g; | ||
| function Ke(e) { | ||
| let t = [], n = new RegExp(I.source, I.flags), r; | ||
| for (; (r = n.exec(e)) !== null;) { | ||
@@ -615,9 +630,9 @@ let e = r[2] ?? r[3] ?? r[4] ?? null; | ||
| } | ||
| function Ge(e) { | ||
| function qe(e) { | ||
| return e.some((e) => e.name.toLowerCase() === "target" && e.value !== null && e.value.toLowerCase() === "_blank"); | ||
| } | ||
| function Ke(e) { | ||
| function Je(e) { | ||
| return e.replace(/<a\b([^>]*)>/gi, (e, t) => { | ||
| let n = We(t); | ||
| if (!Ge(n)) return e; | ||
| let n = Ke(t); | ||
| if (!qe(n)) return e; | ||
| let r = n.find((e) => e.name.toLowerCase() === "rel"); | ||
@@ -635,16 +650,16 @@ if (r) { | ||
| //#region src/accessibility/rules/link-nested-anchor.ts | ||
| var qe = { | ||
| var Ye = { | ||
| id: "a11y.link-nested-anchor", | ||
| severity: "error" | ||
| }; | ||
| function Je(e) { | ||
| function Xe(e) { | ||
| return a(e) || c(e) ? e.content : null; | ||
| } | ||
| var Ye = { | ||
| meta: qe, | ||
| var Ze = { | ||
| meta: Ye, | ||
| block(e) { | ||
| let t = Je(e); | ||
| return t === null || !N(t) ? null : { blockId: e.id }; | ||
| let t = Xe(e); | ||
| return t === null || !Ee(t) ? null : { blockId: e.id }; | ||
| } | ||
| }, Xe = { | ||
| }, Qe = { | ||
| meta: { | ||
@@ -656,6 +671,6 @@ id: "a11y.text-all-caps", | ||
| if (!a(e) && !c(e)) return null; | ||
| let r = P(e.content ?? "").replace(/[^\p{L}]/gu, ""); | ||
| let r = N(e.content ?? "").replace(/[^\p{L}]/gu, ""); | ||
| return r.length < n.thresholds.allCapsMinLength || r !== r.toLocaleUpperCase() ? null : { blockId: e.id }; | ||
| } | ||
| }, Ze = { | ||
| }, $e = { | ||
| meta: { | ||
@@ -676,7 +691,7 @@ id: "a11y.text-low-contrast", | ||
| } | ||
| }, Qe = { | ||
| }, et = { | ||
| id: "a11y.text-too-small", | ||
| severity: "warning" | ||
| }; | ||
| function $e(e) { | ||
| function tt(e) { | ||
| return i(e) || ee(e) ? e.fontSize : null; | ||
@@ -686,3 +701,3 @@ } | ||
| //#region src/accessibility/index.ts | ||
| var R = [ | ||
| var L = [ | ||
| pe, | ||
@@ -693,16 +708,16 @@ ge, | ||
| Te, | ||
| Ee, | ||
| Oe, | ||
| Ae, | ||
| Ne, | ||
| Ie, | ||
| ze, | ||
| Ue, | ||
| Ye, | ||
| Xe, | ||
| Me, | ||
| Fe, | ||
| Re, | ||
| Ve, | ||
| Ge, | ||
| Ze, | ||
| Qe, | ||
| $e, | ||
| { | ||
| meta: Qe, | ||
| meta: et, | ||
| block(e, t, n) { | ||
| let r = $e(e); | ||
| let r = tt(e); | ||
| return r === null || r >= n.thresholds.minFontSize ? null : { | ||
@@ -779,10 +794,10 @@ blockId: e.id, | ||
| ]; | ||
| function et(e, t = {}) { | ||
| function nt(e, t = {}) { | ||
| if (t.disabled === !0 || t.accessibility === !1) return []; | ||
| let n = t.accessibility ?? {}; | ||
| return b(e, R, oe(t.locale, n, R), (e, t, n) => E(e, t, n)); | ||
| return b(e, L, oe(t.locale, n, L), (e, t, n) => E(e, t, n)); | ||
| } | ||
| //#endregion | ||
| //#region src/structure/messages/de.ts | ||
| var tt = /* @__PURE__ */ d({ default: () => nt }), nt = { | ||
| var rt = /* @__PURE__ */ d({ default: () => it }), it = { | ||
| "structure.duplicate-block-id": "Block-ID erscheint {count}-mal im Baum. Jeder Block muss eine eindeutige ID haben.", | ||
@@ -793,3 +808,3 @@ "structure.section-column-mismatch": "Sektion verwendet Layout „{layout}\" (erwartet {expected} Spalten), hat aber {actual}. Deutet auf beschädigten Zustand hin.", | ||
| "structure.empty-column": "Spalte {columnIndex} dieser Sektion ist leer. Füge Inhalt hinzu oder reduziere die Spaltenanzahl." | ||
| }, rt = /* @__PURE__ */ d({ default: () => z }), z = { | ||
| }, at = /* @__PURE__ */ d({ default: () => R }), R = { | ||
| "structure.duplicate-block-id": "Block id appears {count} times in the tree. Each block must have a unique id.", | ||
@@ -800,18 +815,18 @@ "structure.section-column-mismatch": "Section uses layout \"{layout}\" (expects {expected} columns) but has {actual}. Indicates corrupted state.", | ||
| "structure.empty-column": "Column {columnIndex} of this section is empty. Add content or reduce the column count." | ||
| }, B = /* @__PURE__ */ Object.assign({ | ||
| "./de.ts": tt, | ||
| "./en.ts": rt | ||
| }), V = {}; | ||
| for (let e in B) { | ||
| }, z = /* @__PURE__ */ Object.assign({ | ||
| "./de.ts": rt, | ||
| "./en.ts": at | ||
| }), B = {}; | ||
| for (let e in z) { | ||
| let t = /\.\/([^/]+)\.ts$/.exec(e); | ||
| if (!t) continue; | ||
| let n = t[1]; | ||
| n !== "index" && (V[n] = B[e].default); | ||
| n !== "index" && (B[n] = z[e].default); | ||
| } | ||
| var it = Object.keys(V); | ||
| function H(e) { | ||
| return V[e.split("-")[0]?.toLowerCase() ?? "en"] ?? V.en ?? z; | ||
| var ot = Object.keys(B); | ||
| function V(e) { | ||
| return B[e.split("-")[0]?.toLowerCase() ?? "en"] ?? B.en ?? R; | ||
| } | ||
| function U(e, t, n) { | ||
| let r = H(e)[t] ?? z[t]; | ||
| function H(e, t, n) { | ||
| let r = V(e)[t] ?? R[t]; | ||
| return n ? r.replace(/\{(\w+)\}/g, (e, t) => { | ||
@@ -824,14 +839,14 @@ let r = n[t]; | ||
| //#region src/structure/rules/duplicate-block-id.ts | ||
| var at = { | ||
| var st = { | ||
| id: "structure.duplicate-block-id", | ||
| severity: "error" | ||
| }; | ||
| function W(e, t) { | ||
| for (let n of e) if (t.set(n.id, (t.get(n.id) ?? 0) + 1), o(n)) for (let e of n.children) W(e, t); | ||
| function U(e, t) { | ||
| for (let n of e) if (t.set(n.id, (t.get(n.id) ?? 0) + 1), o(n)) for (let e of n.children) U(e, t); | ||
| } | ||
| var ot = { | ||
| meta: at, | ||
| var ct = { | ||
| meta: st, | ||
| template(e) { | ||
| let t = /* @__PURE__ */ new Map(); | ||
| W(e.blocks, t); | ||
| U(e.blocks, t); | ||
| let n = []; | ||
@@ -844,7 +859,7 @@ for (let [e, r] of t) r > 1 && n.push({ | ||
| } | ||
| }, st = { | ||
| }, lt = { | ||
| id: "structure.empty-column", | ||
| severity: "warning" | ||
| }; | ||
| function G(e, t) { | ||
| function W(e, t) { | ||
| for (let n of e) { | ||
@@ -859,24 +874,24 @@ if (!o(n)) continue; | ||
| }); | ||
| for (let n of e.children) G(n, t); | ||
| for (let n of e.children) W(n, t); | ||
| } | ||
| } | ||
| var ct = { | ||
| meta: st, | ||
| var ut = { | ||
| meta: lt, | ||
| template(e) { | ||
| let t = []; | ||
| return G(e.blocks, t), t; | ||
| return W(e.blocks, t), t; | ||
| } | ||
| }, lt = { | ||
| }, dt = { | ||
| id: "structure.empty-section", | ||
| severity: "warning" | ||
| }; | ||
| function ut(e) { | ||
| function ft(e) { | ||
| return e.children.length === 0 ? !0 : e.children.every((e) => e.length === 0); | ||
| } | ||
| var dt = { | ||
| meta: lt, | ||
| var pt = { | ||
| meta: dt, | ||
| block(e) { | ||
| if (!o(e)) return null; | ||
| let t = e; | ||
| return ut(t) ? { | ||
| return ft(t) ? { | ||
| blockId: t.id, | ||
@@ -891,3 +906,3 @@ fix: { | ||
| } | ||
| }, ft = { | ||
| }, mt = { | ||
| meta: { | ||
@@ -905,7 +920,7 @@ id: "structure.nested-section", | ||
| } | ||
| }, pt = { | ||
| }, ht = { | ||
| id: "structure.section-column-mismatch", | ||
| severity: "error" | ||
| }; | ||
| function mt(e) { | ||
| function gt(e) { | ||
| return e === "1" ? 1 : e === "3" ? 3 : 2; | ||
@@ -915,12 +930,12 @@ } | ||
| //#region src/structure/index.ts | ||
| var K = [ | ||
| ot, | ||
| dt, | ||
| var G = [ | ||
| ct, | ||
| ft, | ||
| pt, | ||
| ut, | ||
| mt, | ||
| { | ||
| meta: pt, | ||
| meta: ht, | ||
| block(e) { | ||
| if (!o(e)) return null; | ||
| let t = e, n = mt(t.columns), r = t.children.length; | ||
| let t = e, n = gt(t.columns), r = t.children.length; | ||
| return r === n ? null : { | ||
@@ -937,11 +952,11 @@ blockId: t.id, | ||
| ]; | ||
| function ht(e, t = {}) { | ||
| function _t(e, t = {}) { | ||
| if (t.disabled === !0 || t.structure === !1) return []; | ||
| let n = t.structure ?? {}; | ||
| return b(e, K, se(t.locale, n, K), (e, t, n) => U(e, t, n)); | ||
| return b(e, G, se(t.locale, n, G), (e, t, n) => H(e, t, n)); | ||
| } | ||
| //#endregion | ||
| //#region src/links/messages/de.ts | ||
| var gt = /* @__PURE__ */ d({ default: () => _t }), _t = { | ||
| "link.javascript-protocol": "Die URL verwendet das „javascript:\"-Protokoll, das aus Sicherheitsgründen beim Rendern entfernt wird. Ersetze sie durch eine echte URL oder entferne sie.", | ||
| var vt = /* @__PURE__ */ d({ default: () => yt }), yt = { | ||
| "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.", | ||
| "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.", | ||
@@ -951,4 +966,4 @@ "link.malformed-mailto": "Der mailto:-Link ist fehlerhaft. Erwartet wird eine einzelne Empfängeradresse vor einer eventuellen Querystring (z. B. mailto:hallo@example.com).", | ||
| "link.localhost-or-staging": "Der URL-Host „{host}\" entspricht einem Nicht-Produktionsmuster. Ersetze ihn vor dem Versand durch die Produktions-URL." | ||
| }, vt = /* @__PURE__ */ d({ default: () => q }), q = { | ||
| "link.javascript-protocol": "URL uses the \"javascript:\" protocol, which is stripped at render time for safety. Replace it with a real link or remove the URL.", | ||
| }, bt = /* @__PURE__ */ d({ default: () => K }), K = { | ||
| "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.", | ||
| "link.unsupported-protocol": "URL uses the \"{protocol}\" protocol, which most email clients do not support. Use http, https, mailto, tel, or sms.", | ||
@@ -958,18 +973,18 @@ "link.malformed-mailto": "mailto: link is malformed. Expected a single recipient address before any query string (e.g. mailto:hello@example.com).", | ||
| "link.localhost-or-staging": "URL host \"{host}\" matches a non-production pattern. Replace with the production URL before sending." | ||
| }, J = /* @__PURE__ */ Object.assign({ | ||
| "./de.ts": gt, | ||
| "./en.ts": vt | ||
| }), Y = {}; | ||
| for (let e in J) { | ||
| }, q = /* @__PURE__ */ Object.assign({ | ||
| "./de.ts": vt, | ||
| "./en.ts": bt | ||
| }), J = {}; | ||
| for (let e in q) { | ||
| let t = /\.\/([^/]+)\.ts$/.exec(e); | ||
| if (!t) continue; | ||
| let n = t[1]; | ||
| n !== "index" && (Y[n] = J[e].default); | ||
| n !== "index" && (J[n] = q[e].default); | ||
| } | ||
| var yt = Object.keys(Y); | ||
| function X(e) { | ||
| return Y[e.split("-")[0]?.toLowerCase() ?? "en"] ?? Y.en ?? q; | ||
| var xt = Object.keys(J); | ||
| function Y(e) { | ||
| return J[e.split("-")[0]?.toLowerCase() ?? "en"] ?? J.en ?? K; | ||
| } | ||
| function Z(e, t, n) { | ||
| let r = X(e)[t] ?? q[t]; | ||
| function X(e, t, n) { | ||
| let r = Y(e)[t] ?? K[t]; | ||
| return n ? r.replace(/\{(\w+)\}/g, (e, t) => { | ||
@@ -982,3 +997,3 @@ let r = n[t]; | ||
| //#region src/url-walker.ts | ||
| function Q(e) { | ||
| function Z(e) { | ||
| let o = []; | ||
@@ -1044,22 +1059,33 @@ return y(e, (e) => { | ||
| //#region src/links/rules/javascript-protocol.ts | ||
| var bt = { | ||
| var St = { | ||
| id: "link.javascript-protocol", | ||
| severity: "error" | ||
| }; | ||
| function xt(e) { | ||
| if (!e) return !1; | ||
| }, Q = [ | ||
| "javascript", | ||
| "data", | ||
| "vbscript" | ||
| ]; | ||
| function Ct(e) { | ||
| if (!e) return null; | ||
| let t = e.replace(/\s+/g, ""); | ||
| return /^javascript:/i.test(t); | ||
| for (let e of Q) if (RegExp(`^${e}:`, "i").test(t)) return e; | ||
| return null; | ||
| } | ||
| var St = { | ||
| meta: bt, | ||
| var wt = { | ||
| meta: St, | ||
| template(e) { | ||
| let t = []; | ||
| for (let n of Q(e)) xt(n.url) && t.push({ blockId: n.blockId }); | ||
| for (let n of Z(e)) { | ||
| let e = Ct(n.url); | ||
| e !== null && t.push({ | ||
| blockId: n.blockId, | ||
| params: { protocol: e } | ||
| }); | ||
| } | ||
| return t; | ||
| } | ||
| }, Ct = { | ||
| }, Tt = { | ||
| id: "link.unsupported-protocol", | ||
| severity: "warning" | ||
| }, wt = new Set([ | ||
| }, Et = new Set([ | ||
| "http", | ||
@@ -1070,4 +1096,4 @@ "https", | ||
| "sms" | ||
| ]); | ||
| function Tt(e) { | ||
| ]), Dt = new Set(Q); | ||
| function Ot(e) { | ||
| if (!e) return null; | ||
@@ -1077,9 +1103,9 @@ let t = e.trim(), n = /^([a-z][a-z0-9+\-.]*):/i.exec(t); | ||
| } | ||
| var Et = { | ||
| meta: Ct, | ||
| var kt = { | ||
| meta: Tt, | ||
| template(e) { | ||
| let t = []; | ||
| for (let n of Q(e)) { | ||
| let e = Tt(n.url); | ||
| e !== null && e !== "javascript" && (wt.has(e) || t.push({ | ||
| for (let n of Z(e)) { | ||
| let e = Ot(n.url); | ||
| e !== null && (Dt.has(e) || Et.has(e) || t.push({ | ||
| blockId: n.blockId, | ||
@@ -1091,7 +1117,7 @@ params: { protocol: e } | ||
| } | ||
| }, Dt = { | ||
| }, At = { | ||
| id: "link.malformed-mailto", | ||
| severity: "warning" | ||
| }; | ||
| function Ot(e) { | ||
| function jt(e) { | ||
| let t = e.trim(); | ||
@@ -1111,14 +1137,14 @@ if (!/^mailto:/i.test(t)) return !1; | ||
| } | ||
| var kt = { | ||
| meta: Dt, | ||
| var Mt = { | ||
| meta: At, | ||
| template(e) { | ||
| let t = []; | ||
| for (let n of Q(e)) Ot(n.url) && t.push({ blockId: n.blockId }); | ||
| for (let n of Z(e)) jt(n.url) && t.push({ blockId: n.blockId }); | ||
| return t; | ||
| } | ||
| }, At = { | ||
| }, Nt = { | ||
| id: "link.malformed-tel", | ||
| severity: "warning" | ||
| }, jt = /^[+0-9\s().\-]+$/, Mt = /^[A-Za-z0-9-]+(=[^;]+)?$/; | ||
| function Nt(e) { | ||
| }, Pt = /^[+0-9\s().\-]+$/, Ft = /^[A-Za-z0-9-]+(=[^;]+)?$/; | ||
| function It(e) { | ||
| let t = e.trim(); | ||
@@ -1129,20 +1155,20 @@ if (!/^tel:/i.test(t)) return !1; | ||
| let [r, ...i] = n.split(";"); | ||
| return jt.test(r) ? i.some((e) => !Mt.test(e)) : !0; | ||
| return Pt.test(r) ? i.some((e) => !Ft.test(e)) : !0; | ||
| } | ||
| var Pt = { | ||
| meta: At, | ||
| var Lt = { | ||
| meta: Nt, | ||
| template(e) { | ||
| let t = []; | ||
| for (let n of Q(e)) Nt(n.url) && t.push({ blockId: n.blockId }); | ||
| for (let n of Z(e)) It(n.url) && t.push({ blockId: n.blockId }); | ||
| return t; | ||
| } | ||
| }, Ft = { | ||
| }, Rt = { | ||
| id: "link.localhost-or-staging", | ||
| severity: "warning" | ||
| }; | ||
| function It(e) { | ||
| function zt(e) { | ||
| let t = e.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*"); | ||
| return RegExp(`^${t}$`, "i"); | ||
| } | ||
| function Lt(e) { | ||
| function Bt(e) { | ||
| if (!e) return null; | ||
@@ -1160,14 +1186,14 @@ let t = e.trim(); | ||
| var $ = [ | ||
| St, | ||
| Et, | ||
| wt, | ||
| kt, | ||
| Pt, | ||
| Mt, | ||
| Lt, | ||
| { | ||
| meta: Ft, | ||
| meta: Rt, | ||
| template(e, t) { | ||
| let n = t.links.nonProductionHosts; | ||
| if (n.length === 0) return []; | ||
| let r = n.map(It), i = []; | ||
| for (let t of Q(e)) { | ||
| let e = Lt(t.url); | ||
| let r = n.map(zt), i = []; | ||
| for (let t of Z(e)) { | ||
| let e = Bt(t.url); | ||
| e !== null && r.some((t) => t.test(e)) && i.push({ | ||
@@ -1182,15 +1208,15 @@ blockId: t.blockId, | ||
| ]; | ||
| function Rt(e, t = {}) { | ||
| function Vt(e, t = {}) { | ||
| if (t.disabled === !0 || t.links === !1) return []; | ||
| let n = t.links ?? {}; | ||
| return b(e, $, ce(t.locale, n, $), (e, t, n) => Z(e, t, n)); | ||
| return b(e, $, ce(t.locale, n, $), (e, t, n) => X(e, t, n)); | ||
| } | ||
| //#endregion | ||
| //#region src/util.ts | ||
| function zt(e) { | ||
| function Ht(e) { | ||
| return e ? e.disabled === !0 ? !0 : e.accessibility === !1 && e.structure === !1 && e.links === !1 : !1; | ||
| } | ||
| //#endregion | ||
| export { R as ACCESSIBILITY_RULES, f as DEFAULT_A11Y_THRESHOLDS, p as DEFAULT_NON_PRODUCTION_HOSTS, $ as LINK_RULES, K as STRUCTURE_RULES, we as SUPPORTED_DICTIONARY_LOCALES, yt as SUPPORTED_LINK_MESSAGE_LOCALES, fe as SUPPORTED_MESSAGE_LOCALES, it as SUPPORTED_STRUCTURE_MESSAGE_LOCALES, M as extractAnchors, P as extractText, Z as formatLinkMessage, E as formatMessage, U as formatStructureMessage, m as getContrastRatio, k as getDictionary, X as getLinkMessages, T as getMessages, H as getStructureMessages, N as hasNestedAnchors, zt as isLintFullyDisabled, g as isOpaqueHex, et as lintAccessibility, Rt as lintLinks, ht as lintStructure, h as parseHex, y as walkBlocks, Q as walkUrls }; | ||
| export { L as ACCESSIBILITY_RULES, f as DEFAULT_A11Y_THRESHOLDS, p as DEFAULT_NON_PRODUCTION_HOSTS, $ as LINK_RULES, G as STRUCTURE_RULES, we as SUPPORTED_DICTIONARY_LOCALES, xt as SUPPORTED_LINK_MESSAGE_LOCALES, fe as SUPPORTED_MESSAGE_LOCALES, ot as SUPPORTED_STRUCTURE_MESSAGE_LOCALES, M as extractAnchors, N as extractText, X as formatLinkMessage, E as formatMessage, H as formatStructureMessage, m as getContrastRatio, k as getDictionary, Y as getLinkMessages, T as getMessages, V as getStructureMessages, Ee as hasNestedAnchors, Ht as isLintFullyDisabled, g as isOpaqueHex, nt as lintAccessibility, Vt as lintLinks, _t as lintStructure, h as parseHex, y as walkBlocks, Z as walkUrls }; | ||
| //# sourceMappingURL=index.js.map |
+2
-2
| { | ||
| "name": "@templatical/quality", | ||
| "description": "Accessibility linter for Templatical email templates", | ||
| "version": "0.8.4", | ||
| "version": "0.8.5", | ||
| "bugs": "https://github.com/templatical/sdk/issues", | ||
| "dependencies": { | ||
| "htmlparser2": "^12.0.0", | ||
| "@templatical/types": "0.8.4" | ||
| "@templatical/types": "0.8.5" | ||
| }, | ||
@@ -10,0 +10,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
150888
2.28%1524
1.74%+ Added
- Removed
Updated