responsivelint 0.1.0 → 0.2.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 +50 -7
- package/agents/skills/responsivelint/SKILL.md +16 -3
- package/bin/responsivelint.mjs +40 -3
- package/dist/core.iife.js +172 -1
- package/dist/responsivelint.js +399 -5
- package/dist/responsivelint.min.js +25 -3
- package/llms.txt +10 -3
- package/package.json +1 -1
- package/src/browser/entry.js +205 -6
- package/src/cli/replay.js +86 -0
- package/src/cli/run.js +109 -45
- package/src/core/bar.js +78 -0
- package/src/core/highlight.js +73 -0
- package/src/core/index.js +2 -0
- package/src/core/inject.js +2 -1
- package/src/core/recipe.js +19 -0
- package/src/index.js +1 -0
package/dist/responsivelint.js
CHANGED
|
@@ -684,6 +684,172 @@
|
|
|
684
684
|
return (h >>> 0).toString(36);
|
|
685
685
|
}
|
|
686
686
|
|
|
687
|
+
// src/core/highlight.js
|
|
688
|
+
var TOKENS = {
|
|
689
|
+
error: "hsla(358, 75%, 59%, 1)",
|
|
690
|
+
warning: "hsla(38, 92%, 50%, 1)",
|
|
691
|
+
info: "hsla(220, 9%, 46%, 1)",
|
|
692
|
+
labelText: "hsla(0, 0%, 100%, 1)",
|
|
693
|
+
halo: "hsla(0, 0%, 100%, 0.85)"
|
|
694
|
+
};
|
|
695
|
+
var findingLabel = (finding, width) => `${finding.title} \xB7 ${width} px`;
|
|
696
|
+
function highlight(doc, finding, { width, rect: fallback } = {}) {
|
|
697
|
+
const win = doc.defaultView;
|
|
698
|
+
clearHighlight(doc);
|
|
699
|
+
const els = (finding.elements || []).map((e) => {
|
|
700
|
+
try {
|
|
701
|
+
return doc.querySelector(e.key);
|
|
702
|
+
} catch {
|
|
703
|
+
return null;
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
const main = els[0];
|
|
707
|
+
if (main) {
|
|
708
|
+
const b = main.getBoundingClientRect();
|
|
709
|
+
const left = b.left < 0 || b.right > win.innerWidth ? Math.max(0, win.scrollX + b.left - 16) : win.scrollX;
|
|
710
|
+
win.scrollTo(left, Math.max(0, win.scrollY + b.top - Math.max(48, (win.innerHeight - b.height) / 3)));
|
|
711
|
+
} else if (fallback) {
|
|
712
|
+
win.scrollTo(0, Math.max(0, fallback.top - win.innerHeight / 3));
|
|
713
|
+
}
|
|
714
|
+
const pageRect = (el) => {
|
|
715
|
+
const b = el.getBoundingClientRect();
|
|
716
|
+
return { left: b.left + win.scrollX, top: b.top + win.scrollY, right: b.right + win.scrollX, bottom: b.bottom + win.scrollY };
|
|
717
|
+
};
|
|
718
|
+
const r = main ? pageRect(main) : fallback;
|
|
719
|
+
if (!r) return { found: false, rect: null, remove: () => {
|
|
720
|
+
} };
|
|
721
|
+
const color = TOKENS[finding.severity] || TOKENS.error;
|
|
722
|
+
const host = doc.createElement("div");
|
|
723
|
+
host.setAttribute("data-rl-overlay", "highlight");
|
|
724
|
+
host.style.cssText = "all:initial;position:absolute;left:0;top:0;width:0;height:0;z-index:2147483646;pointer-events:none";
|
|
725
|
+
const root = host.attachShadow({ mode: "open" });
|
|
726
|
+
const box = (q, dashed) => {
|
|
727
|
+
const d = doc.createElement("div");
|
|
728
|
+
d.style.cssText = `position:absolute;box-sizing:border-box;left:${q.left - 3}px;top:${q.top - 3}px;width:${q.right - q.left + 6}px;height:${q.bottom - q.top + 6}px;border:2px ${dashed ? "dashed" : "solid"} ${color};border-radius:4px;box-shadow:0 0 0 2px ${TOKENS.halo}`;
|
|
729
|
+
d.setAttribute("part", dashed ? "other" : "outline");
|
|
730
|
+
root.append(d);
|
|
731
|
+
};
|
|
732
|
+
box(r, false);
|
|
733
|
+
if (els[1] && els[1] !== main) box(pageRect(els[1]), true);
|
|
734
|
+
const above = r.top - win.scrollY > 56 || r.top > 56;
|
|
735
|
+
const x = Math.min(Math.max(r.left + 12, 12), win.scrollX + win.innerWidth - 24);
|
|
736
|
+
const arrow = doc.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
737
|
+
arrow.setAttribute("width", "16");
|
|
738
|
+
arrow.setAttribute("height", "10");
|
|
739
|
+
arrow.setAttribute("viewBox", "0 0 16 10");
|
|
740
|
+
arrow.setAttribute("part", "pointer");
|
|
741
|
+
arrow.style.cssText = `position:absolute;left:${x}px;top:${above ? r.top - 15 : r.bottom + 5}px;overflow:visible;${above ? "" : "transform:rotate(180deg)"}`;
|
|
742
|
+
arrow.innerHTML = `<path d="M0 0 L16 0 L8 10 Z" fill="${color}"/>`;
|
|
743
|
+
root.append(arrow);
|
|
744
|
+
const label2 = doc.createElement("div");
|
|
745
|
+
label2.setAttribute("part", "label");
|
|
746
|
+
label2.textContent = findingLabel(finding, width ?? win.innerWidth);
|
|
747
|
+
label2.style.cssText = `position:absolute;left:${Math.max(4, x - 8)}px;top:${above ? r.top - 15 : r.bottom + 15}px;transform:${above ? "translateY(-100%)" : "none"};max-width:${Math.max(160, win.innerWidth - 24)}px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:${color};color:${TOKENS.labelText};font:600 12px/1.4 system-ui,-apple-system,sans-serif;padding:3px 8px;border-radius:5px`;
|
|
748
|
+
root.append(label2);
|
|
749
|
+
doc.body.append(host);
|
|
750
|
+
return { found: !!main, rect: r, remove: () => host.remove() };
|
|
751
|
+
}
|
|
752
|
+
function clearHighlight(doc) {
|
|
753
|
+
for (const el of doc.querySelectorAll('[data-rl-overlay="highlight"]')) el.remove();
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// src/core/bar.js
|
|
757
|
+
var T = {
|
|
758
|
+
bg: "hsla(222, 18%, 13%, 0.96)",
|
|
759
|
+
fg: "hsla(0, 0%, 100%, 0.95)",
|
|
760
|
+
muted: "hsla(220, 12%, 72%, 1)",
|
|
761
|
+
line: "hsla(0, 0%, 100%, 0.14)",
|
|
762
|
+
hover: "hsla(0, 0%, 100%, 0.08)",
|
|
763
|
+
link: "hsla(212, 92%, 72%, 1)",
|
|
764
|
+
shadow: "hsla(0, 0%, 0%, 0.28)"
|
|
765
|
+
};
|
|
766
|
+
var CSS = `
|
|
767
|
+
:host { all: initial; }
|
|
768
|
+
.bar { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 2147483647; box-sizing: border-box;
|
|
769
|
+
width: min(560px, calc(100vw - 16px)); background: ${T.bg}; color: ${T.fg}; border-radius: 12px; padding: 10px 12px;
|
|
770
|
+
box-shadow: 0 8px 28px ${T.shadow}; font: 13px/1.45 system-ui, -apple-system, sans-serif; }
|
|
771
|
+
.nav { display: flex; align-items: center; gap: 6px; }
|
|
772
|
+
button { all: unset; cursor: pointer; padding: 3px 10px; border-radius: 7px; border: 1px solid ${T.line}; color: ${T.fg}; font: inherit; }
|
|
773
|
+
button:hover:not([disabled]) { background: ${T.hover}; }
|
|
774
|
+
button[disabled] { opacity: .4; cursor: default; }
|
|
775
|
+
button.close { border-color: transparent; margin-left: auto; padding: 3px 8px; font-size: 16px; line-height: 1; }
|
|
776
|
+
.count { color: ${T.muted}; min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
|
|
777
|
+
.title { margin-top: 8px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
|
|
778
|
+
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
|
|
779
|
+
.where, .note, .skill { color: ${T.muted}; margin-top: 2px; }
|
|
780
|
+
.try { margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
|
781
|
+
a { color: ${T.link}; text-decoration: none; }
|
|
782
|
+
a:hover { text-decoration: none; opacity: .85; }
|
|
783
|
+
[hidden] { display: none !important; }
|
|
784
|
+
`;
|
|
785
|
+
var fmtWhere = (f) => (f.bands || []).map(([a, b]) => a === b ? `${a}` : `${a}\u2013${b}`).join(", ") + " px";
|
|
786
|
+
function createBar(doc, { onPrev, onNext, onClose } = {}) {
|
|
787
|
+
const host = doc.createElement("div");
|
|
788
|
+
host.setAttribute("data-rl-overlay", "bar");
|
|
789
|
+
const root = host.attachShadow({ mode: "open" });
|
|
790
|
+
root.innerHTML = `<style>${CSS}</style><div class="bar" role="dialog" aria-label="ResponsiveLint replay">
|
|
791
|
+
<div class="nav"><button class="prev" type="button">\u2039 Previous</button><span class="count"></span><button class="next" type="button">Next \u203A</button>
|
|
792
|
+
<button class="close" type="button" aria-label="Close">\xD7</button></div>
|
|
793
|
+
<div class="title"><span class="dot"></span><span class="text"></span></div>
|
|
794
|
+
<div class="where"></div><div class="try"></div><div class="skill"></div><div class="note" hidden></div></div>`;
|
|
795
|
+
const $ = (s) => root.querySelector(s);
|
|
796
|
+
$(".prev").onclick = () => onPrev?.();
|
|
797
|
+
$(".next").onclick = () => onNext?.();
|
|
798
|
+
$(".close").onclick = () => onClose?.();
|
|
799
|
+
const key = (e) => {
|
|
800
|
+
if (e.target?.closest?.("input,textarea,select,[contenteditable]")) return;
|
|
801
|
+
if (e.key === "ArrowRight") onNext?.();
|
|
802
|
+
else if (e.key === "ArrowLeft") onPrev?.();
|
|
803
|
+
else if (e.key === "Escape") onClose?.();
|
|
804
|
+
else return;
|
|
805
|
+
e.preventDefault();
|
|
806
|
+
};
|
|
807
|
+
doc.addEventListener("keydown", key, true);
|
|
808
|
+
(doc.body || doc.documentElement).append(host);
|
|
809
|
+
return {
|
|
810
|
+
host,
|
|
811
|
+
update({ finding: f, index, total, width, note, busy }) {
|
|
812
|
+
$(".count").textContent = `${index + 1} of ${total}`;
|
|
813
|
+
$(".prev").disabled = busy || index <= 0;
|
|
814
|
+
$(".next").disabled = busy || index >= total - 1;
|
|
815
|
+
$(".dot").style.background = TOKENS[f.severity] || TOKENS.error;
|
|
816
|
+
$(".text").textContent = f.title;
|
|
817
|
+
const states = (f.states || []).join(" \xB7 ");
|
|
818
|
+
$(".where").textContent = `${fmtWhere(f)}${states ? " \xB7 " + states : ""}${width ? ` \xB7 shown at ${width} px` : ""}`;
|
|
819
|
+
$(".try").textContent = f.tries?.[0] ? "Try: " + f.tries[0] : "";
|
|
820
|
+
const sk = $(".skill");
|
|
821
|
+
sk.textContent = "";
|
|
822
|
+
if (f.skill?.url) {
|
|
823
|
+
const a = doc.createElement("a");
|
|
824
|
+
a.href = f.skill.url;
|
|
825
|
+
a.target = "_blank";
|
|
826
|
+
a.rel = "noopener";
|
|
827
|
+
a.textContent = f.skill.name;
|
|
828
|
+
sk.append("Fix skill: ", a);
|
|
829
|
+
}
|
|
830
|
+
$(".note").hidden = !(note || busy);
|
|
831
|
+
$(".note").textContent = busy ? "Loading from the start\u2026" : note || "";
|
|
832
|
+
},
|
|
833
|
+
remove() {
|
|
834
|
+
doc.removeEventListener("keydown", key, true);
|
|
835
|
+
host.remove();
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// src/core/recipe.js
|
|
841
|
+
var START_WIDTH = 1280;
|
|
842
|
+
function recipe(f, states, { url, route, storage, height }) {
|
|
843
|
+
const inst = f.instances[0];
|
|
844
|
+
const state = states.find((s) => s.id === inst?.state) || states[0];
|
|
845
|
+
const seen = f.instances.filter((i) => i.state === inst?.state).map((i) => i.width);
|
|
846
|
+
const band = f.bands.find(([a, b]) => seen.some((w) => w >= a && w <= b)) || f.bands[0];
|
|
847
|
+
const mid = (band[0] + band[1]) / 2;
|
|
848
|
+
const inBand = seen.filter((w) => w >= band[0] && w <= band[1]);
|
|
849
|
+
const width = (inBand.length ? inBand : seen.length ? seen : [Math.round(mid)]).reduce((best, w) => Math.abs(w - mid) < Math.abs(best - mid) ? w : best);
|
|
850
|
+
return { url, route, storage, width, height, startWidth: START_WIDTH, state: state.id, label: state.label, actions: state.actions || [] };
|
|
851
|
+
}
|
|
852
|
+
|
|
687
853
|
// src/browser/entry.js
|
|
688
854
|
var FRAME = "responsivelint-frame";
|
|
689
855
|
var script = document.currentScript;
|
|
@@ -694,15 +860,99 @@
|
|
|
694
860
|
const local = /^(localhost|127\.0\.0\.1|\[::1\]|.+\.localhost|.+\.test)$/.test(location.hostname) || location.protocol === "file:";
|
|
695
861
|
const api2 = window.ResponsiveLint = createApi();
|
|
696
862
|
if (local || "anywhere" in opts) {
|
|
697
|
-
const start = () => {
|
|
863
|
+
const start = async () => {
|
|
698
864
|
api2.check();
|
|
699
|
-
|
|
700
|
-
if ("
|
|
865
|
+
const replaying = opts.ui === "replay";
|
|
866
|
+
if ("ui" in opts && !replaying) api2.ui(true);
|
|
867
|
+
if ("sweep" in opts && (!replaying || !opts.report)) await api2.sweep();
|
|
868
|
+
if (replaying) api2.replay();
|
|
701
869
|
};
|
|
702
870
|
if (document.readyState === "complete") setTimeout(start, 50);
|
|
703
871
|
else addEventListener("load", () => setTimeout(start, 50));
|
|
704
872
|
}
|
|
705
873
|
}
|
|
874
|
+
var TIMING = { wait: 300, clickWait: 300, clickTimeout: 3e3, pace: 0 };
|
|
875
|
+
var NETWORK_CAP = 5e3;
|
|
876
|
+
var NETWORK_IDLE = 250;
|
|
877
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
878
|
+
var frames = (win, n = 2) => new Promise((r) => {
|
|
879
|
+
const step = (k) => k ? win.requestAnimationFrame(() => step(k - 1)) : r();
|
|
880
|
+
step(n);
|
|
881
|
+
});
|
|
882
|
+
function timing(o = {}) {
|
|
883
|
+
const t = { ...TIMING };
|
|
884
|
+
for (const k of Object.keys(TIMING)) {
|
|
885
|
+
const v = o[k] ?? opts[k];
|
|
886
|
+
if (v != null && v !== "" && Number.isFinite(+v) && +v >= 0) t[k] = +v;
|
|
887
|
+
}
|
|
888
|
+
return t;
|
|
889
|
+
}
|
|
890
|
+
async function settle(win, extra = 0) {
|
|
891
|
+
try {
|
|
892
|
+
await win.document.fonts?.ready;
|
|
893
|
+
await frames(win);
|
|
894
|
+
const anims = (win.document.getAnimations?.() || []).filter((a) => a.playState === "running" && a.effect?.getTiming?.().iterations !== Infinity);
|
|
895
|
+
await Promise.race([Promise.all(anims.map((a) => a.finished.catch(() => {
|
|
896
|
+
}))), sleep(600)]);
|
|
897
|
+
} catch {
|
|
898
|
+
}
|
|
899
|
+
if (extra) await sleep(extra);
|
|
900
|
+
}
|
|
901
|
+
function trackRequests(win) {
|
|
902
|
+
let open = 0, last = 0;
|
|
903
|
+
const bump = (d) => {
|
|
904
|
+
open = Math.max(0, open + d);
|
|
905
|
+
last = Date.now();
|
|
906
|
+
};
|
|
907
|
+
const read = (m) => String(m || "GET").toUpperCase();
|
|
908
|
+
const safe = (m) => ["GET", "HEAD", "OPTIONS"].includes(read(m));
|
|
909
|
+
try {
|
|
910
|
+
const f = win.fetch;
|
|
911
|
+
if (f) win.fetch = function(input, init) {
|
|
912
|
+
const method = init?.method || input && typeof input === "object" && input.method;
|
|
913
|
+
if (!safe(method)) return Promise.reject(new TypeError("ResponsiveLint replay blocks " + read(method) + " requests"));
|
|
914
|
+
bump(1);
|
|
915
|
+
return f.call(this, input, init).finally(() => bump(-1));
|
|
916
|
+
};
|
|
917
|
+
const X = win.XMLHttpRequest?.prototype;
|
|
918
|
+
if (X) {
|
|
919
|
+
const xopen = X.open, send = X.send;
|
|
920
|
+
X.open = function(method, ...rest) {
|
|
921
|
+
this.__rlMethod = method;
|
|
922
|
+
return xopen.call(this, method, ...rest);
|
|
923
|
+
};
|
|
924
|
+
X.send = function(...a) {
|
|
925
|
+
if (!safe(this.__rlMethod)) {
|
|
926
|
+
this.abort();
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
bump(1);
|
|
930
|
+
this.addEventListener("loadend", () => bump(-1), { once: true });
|
|
931
|
+
return send.apply(this, a);
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
} catch {
|
|
935
|
+
}
|
|
936
|
+
return async () => {
|
|
937
|
+
const end = Date.now() + NETWORK_CAP;
|
|
938
|
+
while (Date.now() < end) {
|
|
939
|
+
if (!open && Date.now() - last >= NETWORK_IDLE) return;
|
|
940
|
+
await sleep(40);
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
async function waitFor(doc, selector, timeout) {
|
|
945
|
+
const end = Date.now() + timeout;
|
|
946
|
+
for (; ; ) {
|
|
947
|
+
const el = doc.querySelector(selector);
|
|
948
|
+
if (el) {
|
|
949
|
+
const r = el.getBoundingClientRect();
|
|
950
|
+
if (r.width && r.height && doc.defaultView.getComputedStyle(el).visibility !== "hidden") return el;
|
|
951
|
+
}
|
|
952
|
+
if (Date.now() > end) throw new Error(`no visible ${selector} after ${timeout} ms`);
|
|
953
|
+
await sleep(50);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
706
956
|
function createApi() {
|
|
707
957
|
const logged = /* @__PURE__ */ new Set();
|
|
708
958
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -765,6 +1015,7 @@
|
|
|
765
1015
|
});
|
|
766
1016
|
const win = frame.contentWindow;
|
|
767
1017
|
if (!win.__ResponsiveLintFrame) throw new Error("the page does not load this script in a frame");
|
|
1018
|
+
await settle(win, timing().wait);
|
|
768
1019
|
const snaps = [];
|
|
769
1020
|
for (let w = from; w <= to; w += step) {
|
|
770
1021
|
frame.style.width = w + "px";
|
|
@@ -803,8 +1054,10 @@
|
|
|
803
1054
|
}
|
|
804
1055
|
const panel = document.createElement("div");
|
|
805
1056
|
panel.style.cssText = "position:fixed;right:12px;bottom:12px;max-width:360px;max-height:50vh;overflow:auto;pointer-events:auto;background:hsla(0,0%,100%,.97);color:#1d1f24;border-radius:10px;box-shadow:0 6px 24px hsla(0,0%,0%,.18);font:12px/1.45 system-ui,sans-serif;padding:10px 12px";
|
|
806
|
-
panel.innerHTML = `<div style="display:flex;
|
|
807
|
-
panel.querySelector("
|
|
1057
|
+
panel.innerHTML = `<div style="display:flex;align-items:center;gap:8px;margin-bottom:6px"><b style="margin-right:auto">ResponsiveLint \xB7 ${all.length} finding${all.length === 1 ? "" : "s"}</b>${all.length ? '<button type="button" data-act="replay" style="border:1px solid hsla(220,15%,85%,1);border-radius:6px;background:none;cursor:pointer;font:inherit;padding:1px 8px">Replay</button>' : ""}<button type="button" data-act="close" style="border:0;background:none;cursor:pointer;font:inherit">\xD7</button></div>`;
|
|
1058
|
+
panel.querySelector("[data-act=close]").onclick = () => api.ui(false);
|
|
1059
|
+
const rb = panel.querySelector("[data-act=replay]");
|
|
1060
|
+
if (rb) rb.onclick = () => api.replay(all);
|
|
808
1061
|
for (const f of all) {
|
|
809
1062
|
const row = document.createElement("div");
|
|
810
1063
|
row.style.cssText = "padding:5px 0;border-top:1px solid hsla(220,15%,90%,1);cursor:pointer";
|
|
@@ -815,11 +1068,152 @@
|
|
|
815
1068
|
panel.append(row);
|
|
816
1069
|
}
|
|
817
1070
|
layer.append(panel);
|
|
1071
|
+
if (session) layer.style.display = "none";
|
|
818
1072
|
document.body.append(layer);
|
|
819
1073
|
}
|
|
1074
|
+
let session = null;
|
|
1075
|
+
async function loadReport(url) {
|
|
1076
|
+
const res = await fetch(url, { cache: "no-store" });
|
|
1077
|
+
if (!res.ok) throw new Error(`${url}: ${res.status}`);
|
|
1078
|
+
const r = await res.json();
|
|
1079
|
+
return r.findings || [];
|
|
1080
|
+
}
|
|
1081
|
+
async function replay(list, o = {}) {
|
|
1082
|
+
if (!list) {
|
|
1083
|
+
try {
|
|
1084
|
+
list = opts.report ? await loadReport(opts.report) : [...current, ...sweepFindings.filter((f) => !current.some((c) => c.id === f.id))];
|
|
1085
|
+
} catch (e) {
|
|
1086
|
+
console.info("ResponsiveLint: could not load the report (" + e.message + ").");
|
|
1087
|
+
return null;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
if (!list.length) {
|
|
1091
|
+
console.info("ResponsiveLint: nothing to replay.");
|
|
1092
|
+
return null;
|
|
1093
|
+
}
|
|
1094
|
+
session?.close();
|
|
1095
|
+
if (layer) layer.style.display = "none";
|
|
1096
|
+
const t = timing(o);
|
|
1097
|
+
const steps = list.map((f) => ({ finding: f, recipe: f.replay || recipe(f, [{ id: f.instances?.[0]?.state || "live", label: "live page", actions: [] }], { url: location.href, route: null, storage: {}, height: innerHeight }) }));
|
|
1098
|
+
const saved = /* @__PURE__ */ new Map();
|
|
1099
|
+
const store = (k, v) => {
|
|
1100
|
+
try {
|
|
1101
|
+
if (!saved.has(k)) saved.set(k, localStorage.getItem(k));
|
|
1102
|
+
localStorage.setItem(k, v);
|
|
1103
|
+
} catch {
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
let index = -1, frame = null, token = 0, last = 0, closed = false;
|
|
1107
|
+
const paced = async () => {
|
|
1108
|
+
const gap = last + t.pace - Date.now();
|
|
1109
|
+
if (gap > 0) await sleep(gap);
|
|
1110
|
+
last = Date.now();
|
|
1111
|
+
};
|
|
1112
|
+
const shade = document.createElement("div");
|
|
1113
|
+
shade.setAttribute("data-rl-overlay", "replay");
|
|
1114
|
+
shade.style.cssText = "position:fixed;inset:0;z-index:2147483645;background:hsla(222,18%,10%,0.55)";
|
|
1115
|
+
const stage = document.createElement("div");
|
|
1116
|
+
stage.style.cssText = "position:absolute;left:0;top:0;transform-origin:0 0;box-shadow:0 8px 32px hsla(0,0%,0%,0.35);background:hsla(0,0%,100%,1)";
|
|
1117
|
+
shade.append(stage);
|
|
1118
|
+
document.body.append(shade);
|
|
1119
|
+
const bar = createBar(document, { onPrev: () => go(index - 1), onNext: () => go(index + 1), onClose: () => close() });
|
|
1120
|
+
const BAR_SPACE = 204, GAP = 12;
|
|
1121
|
+
const fit = (w, h) => {
|
|
1122
|
+
const s = Math.min(1, (innerWidth - 2 * GAP) / w, (innerHeight - BAR_SPACE - GAP) / h);
|
|
1123
|
+
frame.style.width = w + "px";
|
|
1124
|
+
frame.style.height = h + "px";
|
|
1125
|
+
stage.style.width = w + "px";
|
|
1126
|
+
stage.style.height = h + "px";
|
|
1127
|
+
stage.style.transform = `translate(${Math.round((innerWidth - w * s) / 2)}px, ${GAP}px) scale(${s})`;
|
|
1128
|
+
stage.dataset.scale = s.toFixed(3);
|
|
1129
|
+
};
|
|
1130
|
+
function url(r) {
|
|
1131
|
+
const u = new URL(r.url, location.href);
|
|
1132
|
+
return u.origin === location.origin ? u.href : location.origin + u.pathname + u.search + u.hash;
|
|
1133
|
+
}
|
|
1134
|
+
async function go(i) {
|
|
1135
|
+
if (closed || i < 0 || i >= steps.length) return null;
|
|
1136
|
+
const my = ++token;
|
|
1137
|
+
index = i;
|
|
1138
|
+
const { finding: f, recipe: r } = steps[i];
|
|
1139
|
+
const h = r.height || innerHeight;
|
|
1140
|
+
bar.update({ finding: f, index: i, total: steps.length, width: r.width, busy: true });
|
|
1141
|
+
frame?.remove();
|
|
1142
|
+
for (const [k, v] of Object.entries(r.storage || {})) store(k, v);
|
|
1143
|
+
await paced();
|
|
1144
|
+
if (my !== token) return null;
|
|
1145
|
+
frame = document.createElement("iframe");
|
|
1146
|
+
frame.name = FRAME;
|
|
1147
|
+
frame.setAttribute("data-rl-overlay", "replay-frame");
|
|
1148
|
+
frame.title = "ResponsiveLint replay";
|
|
1149
|
+
frame.style.cssText = "display:block;border:0;background:hsla(0,0%,100%,1)";
|
|
1150
|
+
stage.append(frame);
|
|
1151
|
+
fit(r.startWidth || START_WIDTH, h);
|
|
1152
|
+
let note = "";
|
|
1153
|
+
try {
|
|
1154
|
+
await new Promise((ok, fail) => {
|
|
1155
|
+
frame.onload = ok;
|
|
1156
|
+
setTimeout(() => fail(new Error("the page took over 20 s to load")), 2e4);
|
|
1157
|
+
frame.src = url(r);
|
|
1158
|
+
});
|
|
1159
|
+
if (my !== token) return null;
|
|
1160
|
+
const win = frame.contentWindow, doc = frame.contentDocument;
|
|
1161
|
+
if (!doc) throw new Error("the frame is not on the same site");
|
|
1162
|
+
const quiet = trackRequests(win);
|
|
1163
|
+
await settle(win, t.wait);
|
|
1164
|
+
for (const a of r.actions || []) {
|
|
1165
|
+
const el = await waitFor(doc, a.click, t.clickTimeout);
|
|
1166
|
+
if (my !== token) return null;
|
|
1167
|
+
await paced();
|
|
1168
|
+
el.click();
|
|
1169
|
+
await quiet();
|
|
1170
|
+
await settle(win, 150);
|
|
1171
|
+
if (t.clickWait) await sleep(t.clickWait);
|
|
1172
|
+
}
|
|
1173
|
+
fit(r.width, h);
|
|
1174
|
+
await settle(win);
|
|
1175
|
+
if (my !== token) return null;
|
|
1176
|
+
const inst = (f.instances || []).find((x) => x.width === r.width && x.state === r.state && x.rect);
|
|
1177
|
+
const shown = highlight(doc, f, { width: r.width, rect: inst?.rect });
|
|
1178
|
+
if (!shown.found) note = "The element is not on the page at this width.";
|
|
1179
|
+
if (!(r.actions || []).length && !f.replay) note = note || "Shown in the starting state: clicks made on the live page are not recorded.";
|
|
1180
|
+
} catch (e) {
|
|
1181
|
+
note = "Could not repeat the steps: " + e.message;
|
|
1182
|
+
}
|
|
1183
|
+
if (my !== token) return null;
|
|
1184
|
+
bar.update({ finding: f, index: i, total: steps.length, width: r.width, note });
|
|
1185
|
+
shade.dataset.step = String(i);
|
|
1186
|
+
return { index: i, note, frame };
|
|
1187
|
+
}
|
|
1188
|
+
function close() {
|
|
1189
|
+
if (closed) return;
|
|
1190
|
+
closed = true;
|
|
1191
|
+
token++;
|
|
1192
|
+
bar.remove();
|
|
1193
|
+
shade.remove();
|
|
1194
|
+
for (const [k, v] of saved) try {
|
|
1195
|
+
v == null ? localStorage.removeItem(k) : localStorage.setItem(k, v);
|
|
1196
|
+
} catch {
|
|
1197
|
+
}
|
|
1198
|
+
if (session === api_) {
|
|
1199
|
+
session = null;
|
|
1200
|
+
draw();
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
const api_ = { go, close, get index() {
|
|
1204
|
+
return index;
|
|
1205
|
+
}, get frame() {
|
|
1206
|
+
return frame;
|
|
1207
|
+
}, steps: steps.map((s) => s.recipe), done: null };
|
|
1208
|
+
session = api_;
|
|
1209
|
+
api_.done = go(o.start || 0);
|
|
1210
|
+
await api_.done;
|
|
1211
|
+
return api_;
|
|
1212
|
+
}
|
|
820
1213
|
return {
|
|
821
1214
|
check,
|
|
822
1215
|
sweep,
|
|
1216
|
+
replay,
|
|
823
1217
|
ui(on = true) {
|
|
824
1218
|
uiOn = !!on;
|
|
825
1219
|
draw();
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
(()=>{var R=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","TITLE","OPTION","HEAD","META","LINK"]),F=["button","a[href]","summary","select","textarea","input:not([type=hidden])","[role=button]","[role=tab]","[role=link]","[role=menuitem]","[role=switch]","[role=checkbox]","[role=option]",'[tabindex]:not([tabindex="-1"])'].join(",");function k(l){let n=[];for(let s=l;s&&s.nodeType===1&&s!==document.body&&s!==document.documentElement;s=s.parentElement){if(s.id&&/^[A-Za-z][\w-]*$/.test(s.id))return n.unshift("#"+s.id),n.join(">");let u=s.parentElement,c=u?Array.prototype.indexOf.call(u.children,s)+1:1;n.unshift(s.tagName.toLowerCase()+":nth-child("+c+")")}return n.unshift("body"),n.join(">")}function E(l){let n=new Set;for(let s=l;s&&s.nodeType===1;s=s.parentElement){let u=s.getAttribute&&s.getAttribute("data-rl-ignore");u!=null&&(u===""||u==="all"?n.add("all"):u.split(/[\s,]+/).forEach(c=>n.add(c)))}return n}function I(){let l=new Map,n=new Map,s=new Map,u=new Map,c=t=>{let i=l.get(t);return i||(i=getComputedStyle(t),l.set(t,i)),i};function a(t){if(!t||t.nodeType!==1)return 1;if(n.has(t))return n.get(t);let i=parseFloat(c(t).opacity||"1")*a(t.parentElement);return n.set(t,i),i}function h(t){if(!t||t.nodeType!==1)return!1;if(u.has(t))return u.get(t);let i=c(t).position,p=i==="fixed"||i==="sticky"||h(t.parentElement);return u.set(t,p),p}function m(t){if(!t||t.nodeType!==1||t===document.documentElement)return{left:-1e9,top:-1e9,right:1e9,bottom:1e9};if(s.has(t))return s.get(t);let i=m(t.parentElement),p=c(t),g=i;if(t!==document.body&&(p.overflowX!=="visible"||p.overflowY!=="visible")){let d=t.getBoundingClientRect(),e={left:d.left+scrollX+t.clientLeft,top:d.top+scrollY+t.clientTop};e.right=e.left+t.clientWidth,e.bottom=e.top+t.clientHeight,g={left:p.overflowX==="visible"?i.left:Math.max(i.left,e.left),right:p.overflowX==="visible"?i.right:Math.min(i.right,e.right),top:p.overflowY==="visible"?i.top:Math.max(i.top,e.top),bottom:p.overflowY==="visible"?i.bottom:Math.min(i.bottom,e.bottom)}}return p.position==="fixed"&&(g={left:-1e9,top:-1e9,right:1e9,bottom:1e9}),s.set(t,g),g}function w(t){for(let p=t;p&&p.nodeType===1;p=p.parentElement)if(p.getAttribute("aria-hidden")==="true"||p.hasAttribute("inert")||p.hidden)return!0;let i=c(t);return i.visibility!=="visible"||i.display==="none"||i.contentVisibility==="hidden"}return{cs:c,effectiveOpacity:a,isPinned:h,clipRect:m,hidden:w}}var L=(l,n)=>({left:Math.max(l.left,n.left),top:Math.max(l.top,n.top),right:Math.min(l.right,n.right),bottom:Math.min(l.bottom,n.bottom)}),T=l=>Math.max(0,l.right-l.left)*Math.max(0,l.bottom-l.top);function O(l,n){let s=[],u="",c=n.clipRect(l);for(let a of l.childNodes){if(a.nodeType!==3||!a.textContent.trim())continue;u+=a.textContent;let h=document.createRange();h.selectNodeContents(a);for(let m of h.getClientRects()){if(m.width<1||m.height<1)continue;let w={left:m.left+scrollX,top:m.top+scrollY,right:m.right+scrollX,bottom:m.bottom+scrollY},t=L(w,c);T(t)>0&&s.push(t)}}return{text:u.replace(/\s+/g," ").trim(),rects:s}}function q(l){let n=l.map(c=>(c.top+c.bottom)/2).sort((c,a)=>c-a),s=0,u=-1e9;for(let c of n)c-u>3&&(s++,u=c);return s}function M(l,n){return(l.getAttribute("aria-label")||n||l.getAttribute("title")||l.getAttribute("alt")||"").replace(/\s+/g," ").trim().slice(0,60)}var P=4e3,N=2500;function C(){let l=globalThis,n=[];l.__THREE__&&n.push("three.js r"+l.__THREE__),l.AFRAME&&n.push("A-Frame "+(l.AFRAME.version||"")),l.BABYLON&&n.push("Babylon.js "+(l.BABYLON.Engine?.Version||"")),l.pc&&l.pc.version&&n.push("PlayCanvas "+l.pc.version),[...document.querySelectorAll("canvas")].some(c=>c.__r3f||c.parentElement?.__r3f)&&n.push("React Three Fiber");let s=l.__rlContexts||{},u=document.querySelectorAll("canvas").length;return{frameworks:n.map(c=>c.trim()),webgl:(s.webgl||0)+(s.webgl2||0),webgpu:s.webgpu||0,canvases:u,xr:!!l.__rlXR||!!navigator.xr&&n.length>0,is3D:n.length>0||(s.webgl||0)+(s.webgl2||0)+(s.webgpu||0)>0}}function $(l={}){let n=null;l.revealSkipped&&(n=document.createElement("style"),n.textContent="*{content-visibility:visible!important}",document.head.append(n));try{return K(l)}finally{n?.remove()}}function K(l){let n=I(),s={width:innerWidth,height:innerHeight},u=[],c=e=>u.push(e),a=[],h=[],m=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT);for(let e=m.currentNode;e&&!(a.length>=P);e=m.nextNode()){if(!(e instanceof HTMLElement)||R.has(e.tagName)||e.closest("[data-rl-overlay]"))continue;let{text:o,rects:r}=O(e,n);if(!o||!r.length||n.hidden(e)||n.effectiveOpacity(e)<.05||!l.revealSkipped&&e.checkVisibility&&!e.checkVisibility({contentVisibilityAuto:!0}))continue;let f=e.getBoundingClientRect();if(f.width<=2||f.height<=2)continue;let x=E(e);a.push({el:e,key:k(e),text:o,rects:r,ignore:x,pinned:n.isPinned(e)})}let w=[];a.forEach((e,o)=>e.rects.forEach(r=>w.push({i:o,r}))),w.sort((e,o)=>e.r.top-o.r.top);let t=new Set,i=[],p=0;for(let e=0;e<w.length;e++){let o=w[e];for(;p<e&&w[p].r.bottom<=o.r.top;)p++;for(let r=p;r<e;r++){let f=w[r];if(o.i===f.i||f.r.bottom<=o.r.top)continue;let x=a[o.i],b=a[f.i];if(x.pinned!==b.pinned||x.el.contains(b.el)||b.el.contains(x.el)||x.ignore.has("all")||x.ignore.has("text-overlap")||b.ignore.has("all")||b.ignore.has("text-overlap"))continue;let y=L(o.r,f.r),v=Math.min(T(o.r),T(f.r)),A=Math.min(o.r.bottom-o.r.top,f.r.bottom-f.r.top);if(T(y)<.25*v||y.bottom-y.top<.4*A)continue;let X=o.i<f.i?o.i+":"+f.i:f.i+":"+o.i;t.has(X)||(t.add(X),i.push({ta:x,tb:b,cut:y,share:Math.round(100*T(y)/v)}))}}for(let e of V(i)){let{ta:o,tb:r,cut:f,share:x,top:b}=e;c({rule:"text-overlap",keys:[o.key,r.key].sort(),elements:[{key:o.key,text:o.text.slice(0,60)},{key:r.key,text:r.text.slice(0,60)}],rect:f,onTop:b,measured:{overlap:x+"% of the smaller line",...b?{onTop:b.summary}:{}}})}for(let e of a){let o=e.text.split(/\s+/).filter(Boolean).length,r=q(e.rects);if(h.length<N&&e.text.length>=6){let f=Math.min(...e.rects.map(v=>v.left)),x=Math.max(...e.rects.map(v=>v.right)),b=Math.min(...e.rects.map(v=>v.top)),y=Math.max(...e.rects.map(v=>v.bottom));h.push({key:e.key,kind:"text",text:e.text.slice(0,60),words:o,lines:r,w:Math.round(x-f),rect:{left:f,top:b,right:x,bottom:y}})}if(!(e.ignore.has("all")||e.ignore.has("squashed-text"))&&o>=3&&r>=3&&o/r<=1.25&&e.text.length>=15){let f=Math.min(...e.rects.map(v=>v.left)),x=Math.max(...e.rects.map(v=>v.right)),b=Math.min(...e.rects.map(v=>v.top)),y=Math.max(...e.rects.map(v=>v.bottom));c({rule:"squashed-text",keys:[e.key],elements:[{key:e.key,text:e.text.slice(0,60)}],rect:{left:f,top:b,right:x,bottom:y},measured:{width:Math.round(x-f),lines:r,words:o}})}}let g=new Set;for(let e of a)for(let o=e.el;o&&o!==document.body;o=o.parentElement){let r=n.cs(o),f=r.overflowX==="hidden"||r.overflowX==="clip",x=r.overflowY==="hidden"||r.overflowY==="clip";if(!f&&!x)continue;if(g.has(o)||(g.add(o),o.clientWidth<2||o.clientHeight<2||n.hidden(o))||r.webkitLineClamp&&r.webkitLineClamp!=="none"||!(f&&o.scrollWidth>o.clientWidth+2||x&&o.scrollHeight>o.clientHeight+2))break;let y=o.getBoundingClientRect(),v={left:y.left+scrollX,top:y.top+scrollY,right:y.left+scrollX+o.clientWidth,bottom:y.top+scrollY+o.clientHeight},A=E(o);!A.has("all")&&!A.has("clipped-text")&&c({rule:"clipped-text",keys:[k(o)],elements:[{key:k(o),text:M(o,e.text)}],rect:v,ellipsis:r.textOverflow==="ellipsis",measured:{contentWidth:o.scrollWidth,boxWidth:o.clientWidth,contentHeight:o.scrollHeight,boxHeight:o.clientHeight}});break}let d=document.documentElement.scrollWidth;if(d>s.width+1&&!E(document.body).has("page-overflow")){let e=[],o=document.body.querySelectorAll("*");for(let r of o){if(e.length>=5)break;if(!(r instanceof HTMLElement)||R.has(r.tagName)||n.hidden(r))continue;let f=r.getBoundingClientRect();f.right+scrollX<=s.width+1||f.width===0||n.clipRect(r.parentElement).right<=s.width+1||r.parentElement.getBoundingClientRect().right+scrollX>s.width+1&&r.parentElement!==document.body||e.push({key:k(r),text:M(r,(r.textContent||"").trim())||r.tagName.toLowerCase(),right:Math.round(f.right+scrollX)})}c({rule:"page-overflow",keys:e.map(r=>r.key).sort().slice(0,1),elements:e,rect:null,measured:{pageWidth:d,viewport:s.width,by:d-s.width}})}for(let e of document.body.querySelectorAll(F)){if(!(e instanceof HTMLElement)||e.closest("[data-rl-overlay]"))continue;let o=n.cs(e);if(o.display==="none"||e.disabled||e.closest("[aria-hidden=true],[inert],[hidden]"))continue;let r=e.getBoundingClientRect();if(r.width<4||r.height<4)continue;let f={left:r.left+scrollX,top:r.top+scrollY,right:r.right+scrollX,bottom:r.bottom+scrollY};if(T(L(f,n.clipRect(e.parentElement)))<4)continue;let x=n.effectiveOpacity(e),b=x<.1&&o.visibility==="visible"&&o.pointerEvents!=="none";if(h.length<N+500&&h.push({key:k(e),kind:"control",text:M(e,(e.textContent||"").trim()),visible:!b,rect:f}),!b||e.matches("input[type=checkbox],input[type=radio],input[type=file],input[type=range]")&&(e.labels?.length||e.closest("label")))continue;let y=E(e);y.has("all")||y.has("hidden-control")||c({rule:"hidden-control",keys:[k(e)],elements:[{key:k(e),text:M(e,(e.textContent||"").trim())||e.tagName.toLowerCase()}],rect:f,measured:{opacity:+x.toFixed(2)}})}return{width:s.width,height:s.height,env:C(),findings:u,measures:h}}function V(l){if(!l.length)return[];let n=document.createElement("style");n.textContent="*{pointer-events:auto!important}",document.head.append(n);let s=scrollX,u=scrollY,c=[];try{for(let a of l){let h=(a.cut.left+a.cut.right)/2,m=(a.cut.top+a.cut.bottom)/2,w=a.ta.pinned&&a.tb.pinned,t=h-scrollX,i=m-scrollY;!w&&(t<0||i<0||t>=innerWidth||i>=innerHeight)&&(window.scrollTo({left:Math.max(0,h-innerWidth/2),top:Math.max(0,m-innerHeight/2),behavior:"instant"}),t=h-scrollX,i=m-scrollY),w&&(t=h-s,i=m-u);let p=document.elementsFromPoint(t,i),g=r=>p.findIndex(f=>f===r||r.contains(f)),d=g(a.ta.el),e=g(a.tb.el);if(d<0&&e<0)continue;let o=d<0?a.tb.el:e<0||d<=e?a.ta.el:a.tb.el;c.push({...a,top:D(o)})}}finally{n.remove(),(scrollX!==s||scrollY!==u)&&window.scrollTo({left:s,top:u,behavior:"instant"})}return c}function D(l){let n=l;for(let a=l;a&&a!==document.body;a=a.parentElement){let h=getComputedStyle(a);if(h.position!=="static"||h.zIndex!=="auto"||h.transform!=="none"){n=a;break}}let s=getComputedStyle(n),u=[s.position!=="static"?"position: "+s.position:"",s.zIndex!=="auto"?"z-index: "+s.zIndex:"",s.transform!=="none"?"transformed":""].filter(Boolean),c=(l.textContent||"").replace(/\s+/g," ").trim().slice(0,40);return{key:k(n),text:c,position:s.position,zIndex:s.zIndex,summary:`"${c}"`+(u.length?" ("+u.join(", ")+")":" (normal flow)")}}var Y="https://github.com/prajwalsouza/ResponsiveLint/blob/main/",W={"responsivelint-fix-overlap":{title:"Fix text drawn over other text",rules:["text-overlap"]},"responsivelint-fix-cramped-text":{title:"Fix text that is squeezed or cut off",rules:["squashed-text","clipped-text","width-outlier"]},"responsivelint-fix-overflow":{title:"Fix a page that scrolls sideways",rules:["page-overflow"]},"responsivelint-fix-controls":{title:"Fix controls that are invisible or go missing",rules:["hidden-control","disappears-in-band"]}},U=l=>{let n=Object.keys(W).find(u=>W[u].rules.includes(l))||"responsivelint-fix",s=`agents/skills/${n}/SKILL.md`;return{name:n,file:s,url:Y+s}},S={"text-overlap":{pack:"text",severity:"error",confidence:"high",title:"Text covers other text",why:"Two pieces of visible text are drawn in the same place, so neither can be read.",tries:["An element with position: absolute or fixed sits on text that wraps at this width: place it with flex or grid instead, or move it off the text. Changing z-index only swaps which text is hidden.","A box has a fixed height, so its text spills out when it wraps: remove height, or use min-height.","A negative margin or a transform pulls one element onto another: remove it at these widths.","A toast, tooltip or badge is placed on a toolbar: place it above or beside the toolbar."]},"squashed-text":{pack:"text",severity:"warning",confidence:"high",title:"Text squeezed to about one word per line",why:"The text has become so narrow that almost every word sits on its own line.",tries:["A neighbour in the same row does not wrap (white-space: nowrap, flex-shrink: 0, an auto grid column full of buttons): let it wrap with flex-wrap: wrap, or put it on its own line with grid-template-columns: 1fr.","The row keeps two columns at a width where one fits better: stack them below this width with a media or container query.","Nothing stops the text from shrinking: give it min-width: 12em (or similar)."]},"clipped-text":{pack:"text",severity:"warning",confidence:"medium",title:"Text cut off by its box",why:"A box with overflow hidden is smaller than the text inside it, so part of the text is not shown.",tries:["The box has a fixed width or height: remove it, or use min-width or min-height, so the box grows with its text.","The text is not allowed to wrap (white-space: nowrap): allow wrapping.","The cut is intended: add text-overflow: ellipsis and a title with the full text, so the finding becomes a note."]},"page-overflow":{pack:"overflow",severity:"error",confidence:"high",title:"The page scrolls sideways",why:"Something is wider than the screen, so the whole page can be dragged sideways.",tries:["The named element has a fixed width in pixels: use max-width: 100%, or a width in % or fr.","A row of controls or a long word or URL does not wrap: add flex-wrap: wrap, or overflow-wrap: anywhere for long words.","A wide table, code block or image: wrap it in a box with overflow-x: auto, or give images max-width: 100%.","Do not hide the problem with overflow-x: hidden on body or html; it cuts content off instead."]},"hidden-control":{pack:"visibility",severity:"warning",confidence:"medium",title:"A control takes space but cannot be seen",why:"A button, link or tab is laid out, clickable and focusable, but fully transparent in its resting state, so people do not know it is there.",tries:["It appears only on hover (opacity: 0 until :hover): show it at rest, perhaps quieter, because touch screens have no hover.","It should stay hidden until something happens: hide it properly with display: none, visibility: hidden or the hidden attribute until then, so it leaves the tab order too.","Keyboard users cannot find it: also show it on :focus-visible and :focus-within."]},"width-outlier":{pack:"sweep",severity:"warning",confidence:"high",title:"Breaks only in a narrow band of widths",why:"This element looks normal at the widths on both sides, but changes sharply inside this band, which is how layout bugs between breakpoints show up.",tries:["One part of the layout switches at a breakpoint before another does (a sidebar appears before the content stacks): line the two media queries up, or switch the content to a container query.","A neighbour stops wrapping inside the band and takes the width: let it wrap, or stack it below this width.","A fixed size takes over inside the band: replace it with min(), max() or clamp()."]},"disappears-in-band":{pack:"sweep",severity:"warning",confidence:"medium",title:"A control disappears in a narrow band of widths",why:"The control is visible at the widths on both sides but not inside this band.",tries:["Two media queries hand over at different widths (one hides the desktop control, the other shows the mobile one a few pixels later): use the same width for both, or one query.","max-width and min-width both use the same number, so one pixel shows neither: use max-width: 767px with min-width: 768px, or a range query.","The control is pushed out of its row and clipped: let the row wrap."]}};for(let l of Object.values(S))l.fix=l.tries[0];function G(l,n){let s=[...new Set(l)].sort((a,h)=>a-h),u=new Map(n.map((a,h)=>[a,h])),c=[];for(let a of s){let h=c[c.length-1];h&&u.get(a)===u.get(h[1])+1?h[1]=a:c.push([a,a])}return c}var B=l=>{let n=[...l].sort((s,u)=>s-u);return n.length?n[Math.floor(n.length/2)]:0};function Z(l,n,s){let u=[];for(let[c,a]of l){let h=n.map(i=>a.get(i));if(h.filter(Boolean).length<5)continue;let m=h.find(Boolean).kind,w=new Array(h.length).fill(!1);for(let i=0;i<h.length;i++){let p=h[i],g=[];for(let d=1;d<=3;d++)h[i-d]&&g.push(h[i-d]),h[i+d]&&g.push(h[i+d]);if(!(g.length<3)){if(m==="text"){if(!p)continue;let d=B(g.map(r=>r.lines)),e=B(g.map(r=>r.words/Math.max(1,r.lines))),o=p.words/Math.max(1,p.lines);w[i]=p.words>=3&&p.lines>=Math.max(3,2*d,d+2)&&o<=.5*e&&o<=2.5}else if(m==="control"){let d=g.filter(e=>e.visible).length;w[i]=(!p||!p.visible)&&d>=g.length-1}}}let t=0;for(;t<h.length;){if(!w[t]){t++;continue}let i=t;for(;i+1<h.length&&w[i+1];)i++;let p=h.slice(0,t).some((e,o)=>e&&!w[o]),g=h.slice(i+1).some((e,o)=>e&&!w[i+1+o]),d=i-t+1<=Math.max(1,Math.floor(.35*h.length));if(p&&g&&d){let e=h[t]||h.slice(t,i+1).find(Boolean),o=h.slice(0,t).reverse().find(Boolean),r=m==="text"?"width-outlier":"disappears-in-band";u.push({rule:r,keys:[c],state:s,widths:n.slice(t,i+1),elements:[{key:c,text:(e||o)?.text||""}],rect:e?.rect||o?.rect,goodWidth:n[n.indexOf(n[t])-1],measured:m==="text"&&e?{lines:e.lines,wordsPerLine:+(e.words/e.lines).toFixed(1)}:{visible:!1},expected:m==="text"&&o?{lines:o.lines,wordsPerLine:+(o.words/Math.max(1,o.lines)).toFixed(1)}:{visible:!0}})}t=i+1}}return u}function _(l,n={}){let s=[...new Set(l.map(t=>t.width))].sort((t,i)=>t-i),u=[];for(let t of l)for(let i of t.findings)u.push({...i,state:t.state,widths:[t.width]});let c=new Map;for(let t of l)c.has(t.state.id)||c.set(t.state.id,{state:t.state,snaps:[]}),c.get(t.state.id).snaps.push(t);for(let{state:t,snaps:i}of c.values()){if(i.length<5)continue;let p=new Map;for(let d of i)for(let e of d.measures)p.has(e.key+"|"+e.kind)||p.set(e.key+"|"+e.kind,new Map),p.get(e.key+"|"+e.kind).set(d.width,e);let g=new Map([...p].map(([d,e])=>[d.split("|")[0],e]));u.push(...Z(g,i.map(d=>d.width).sort((d,e)=>d-e),t))}let a=new Map;for(let t of u){let i=t.rule+"|"+t.keys.join("+");a.has(i)||a.set(i,{...t,widths:[],states:[],instances:[]});let p=a.get(i);p.widths.push(...t.widths),p.states.some(g=>g.id===t.state.id)||p.states.push(t.state),p.instances.push({state:t.state.id,width:t.widths[0],rect:t.rect,measured:t.measured})}Q(a);let h={error:0,warning:1,info:2},m={high:0,medium:1,low:2},w=[];for(let[t,i]of a){let p=S[i.rule];if(n.only&&!n.only.includes(p.pack)&&!n.only.includes(i.rule)||n.skip&&(n.skip.includes(p.pack)||n.skip.includes(i.rule)))continue;let g=p.severity,d=p.confidence;i.rule==="clipped-text"&&i.ellipsis&&(g="info");let e=[...new Set(i.widths)].sort((r,f)=>r-f),o=J(i,p);w.push({id:ee(t),rule:i.rule,pack:p.pack,severity:g,confidence:d,title:p.title,elements:i.elements,widths:e,bands:G(e,s),everyWidth:e.length===s.length,states:i.states.map(r=>r.label),measured:i.measured,expected:i.expected,why:p.why,fix:o[0],tries:o,guide:Y+"docs/rules/"+i.rule+".md",skill:U(i.rule),suppress:`data-rl-ignore="${i.rule}"`,instances:i.instances.slice(0,50),goodWidth:i.goodWidth})}return n.minConfidence&&w.splice(0,w.length,...w.filter(t=>m[t.confidence]<=m[n.minConfidence])),w.sort((t,i)=>h[t.severity]-h[i.severity]||m[t.confidence]-m[i.confidence]||i.widths.length-t.widths.length),{widths:s,findings:w}}function J(l,n){let s=[...n.tries],u=(a,h)=>{let[m]=s.splice(a,1);s.unshift(h||m)},c=l.measured||{};if(l.rule==="text-overlap"){let a=l.onTop;a&&["absolute","fixed","sticky"].includes(a.position)?u(0,`The text on top, ${a.summary}, is taken out of the normal layout: place it with flex or grid instead, or move it so it does not sit on the text. Changing z-index only swaps which text is hidden. (${a.key})`):a&&a.position==="static"&&u(1)}else l.rule==="clipped-text"&&(l.ellipsis?u(2,"The cut is marked with an ellipsis, so it looks intended: make sure a title or tooltip gives the full text."):c.contentWidth>c.boxWidth&&!(c.contentHeight>c.boxHeight)&&u(1));return s}function Q(l){let n=c=>c.includes(">")?c.slice(0,c.lastIndexOf(">")):c,s=new Map;for(let[c,a]of l){if(a.rule!=="text-overlap")continue;let[h,m]=a.keys;for(let[w,t]of[[h,m],[m,h]]){let i=w+"~"+n(t);s.has(i)||s.set(i,[]),s.get(i).push({id:c,shared:w,other:t})}}let u=new Set;for(let[c,a]of[...s].sort((h,m)=>m[1].length-h[1].length)){let h=a.filter(d=>!u.has(d.id)&&l.has(d.id));if(h.length<2)continue;let m=l.get(h[0].id),w=h[0].shared,t=n(h[0].other),i=m.elements.find(d=>d.key===w),p=h.map(d=>l.get(d.id).elements.find(e=>e.key===d.other)?.text).filter(Boolean),g={...m,keys:[w,t],widths:[],states:[],instances:[],elements:[i,{key:t,text:p.join(" \xB7 ").slice(0,60)}]};for(let d of h){let e=l.get(d.id);g.widths.push(...e.widths);for(let o of e.states)g.states.some(r=>r.id===o.id)||g.states.push(o);g.instances.push(...e.instances),l.delete(d.id),u.add(d.id)}l.set("text-overlap|"+w+"+"+t,g)}}function ee(l){let n=2166136261;for(let s=0;s<l.length;s++)n^=l.charCodeAt(s),n=Math.imul(n,16777619);return(n>>>0).toString(36)}var z="responsivelint-frame",j=document.currentScript,H=j?j.dataset:{};if(window.name===z)window.__ResponsiveLintFrame={checkNow:$};else{let l=/^(localhost|127\.0\.0\.1|\[::1\]|.+\.localhost|.+\.test)$/.test(location.hostname)||location.protocol==="file:",n=window.ResponsiveLint=te();if(l||"anywhere"in H){let s=()=>{n.check(),"ui"in H&&n.ui(!0),"sweep"in H&&n.sweep()};document.readyState==="complete"?setTimeout(s,50):addEventListener("load",()=>setTimeout(s,50))}}function te(){let l=new Set,n=new Set,s=[],u=[],c=!1,a=0,h=d=>n.forEach(e=>{try{e(d)}catch{}});function m(d){for(let e of d){if(l.has(e.id))continue;l.add(e.id),h(e);let o=e.severity==="error"?"#e5484d":e.severity==="warning"?"#d08a12":"#888";console.groupCollapsed(`%cResponsiveLint%c ${e.severity==="error"?"\u2716":"\u25B2"} ${e.rule}: ${e.title}`,"font-weight:700",`color:${o}`);for(let r of e.elements)console.log(r.text?`\u201C${r.text}\u201D`:r.key,document.querySelector(r.key)||r.key);console.log("where:",e.bands.map(([r,f])=>r===f?r:`${r}\u2013${f}`).join(", ")+" px",e.states.join(" \xB7 ")),e.measured&&console.log("measured:",e.measured,e.expected?["neighbours:",e.expected]:""),console.log("why:",e.why),console.log(`try:
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
(()=>{var J=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","TITLE","OPTION","HEAD","META","LINK"]),lt=["button","a[href]","summary","select","textarea","input:not([type=hidden])","[role=button]","[role=tab]","[role=link]","[role=menuitem]","[role=switch]","[role=checkbox]","[role=option]",'[tabindex]:not([tabindex="-1"])'].join(",");function R(n){let e=[];for(let i=n;i&&i.nodeType===1&&i!==document.body&&i!==document.documentElement;i=i.parentElement){if(i.id&&/^[A-Za-z][\w-]*$/.test(i.id))return e.unshift("#"+i.id),e.join(">");let h=i.parentElement,r=h?Array.prototype.indexOf.call(h.children,i)+1:1;e.unshift(i.tagName.toLowerCase()+":nth-child("+r+")")}return e.unshift("body"),e.join(">")}function P(n){let e=new Set;for(let i=n;i&&i.nodeType===1;i=i.parentElement){let h=i.getAttribute&&i.getAttribute("data-rl-ignore");h!=null&&(h===""||h==="all"?e.add("all"):h.split(/[\s,]+/).forEach(r=>e.add(r)))}return e}function ct(){let n=new Map,e=new Map,i=new Map,h=new Map,r=o=>{let s=n.get(o);return s||(s=getComputedStyle(o),n.set(o,s)),s};function p(o){if(!o||o.nodeType!==1)return 1;if(e.has(o))return e.get(o);let s=parseFloat(r(o).opacity||"1")*p(o.parentElement);return e.set(o,s),s}function c(o){if(!o||o.nodeType!==1)return!1;if(h.has(o))return h.get(o);let s=r(o).position,u=s==="fixed"||s==="sticky"||c(o.parentElement);return h.set(o,u),u}function g(o){if(!o||o.nodeType!==1||o===document.documentElement)return{left:-1e9,top:-1e9,right:1e9,bottom:1e9};if(i.has(o))return i.get(o);let s=g(o.parentElement),u=r(o),b=s;if(o!==document.body&&(u.overflowX!=="visible"||u.overflowY!=="visible")){let m=o.getBoundingClientRect(),t={left:m.left+scrollX+o.clientLeft,top:m.top+scrollY+o.clientTop};t.right=t.left+o.clientWidth,t.bottom=t.top+o.clientHeight,b={left:u.overflowX==="visible"?s.left:Math.max(s.left,t.left),right:u.overflowX==="visible"?s.right:Math.min(s.right,t.right),top:u.overflowY==="visible"?s.top:Math.max(s.top,t.top),bottom:u.overflowY==="visible"?s.bottom:Math.min(s.bottom,t.bottom)}}return u.position==="fixed"&&(b={left:-1e9,top:-1e9,right:1e9,bottom:1e9}),i.set(o,b),b}function f(o){for(let u=o;u&&u.nodeType===1;u=u.parentElement)if(u.getAttribute("aria-hidden")==="true"||u.hasAttribute("inert")||u.hidden)return!0;let s=r(o);return s.visibility!=="visible"||s.display==="none"||s.contentVisibility==="hidden"}return{cs:r,effectiveOpacity:p,isPinned:c,clipRect:g,hidden:f}}var z=(n,e)=>({left:Math.max(n.left,e.left),top:Math.max(n.top,e.top),right:Math.min(n.right,e.right),bottom:Math.min(n.bottom,e.bottom)}),I=n=>Math.max(0,n.right-n.left)*Math.max(0,n.bottom-n.top);function dt(n,e){let i=[],h="",r=e.clipRect(n);for(let p of n.childNodes){if(p.nodeType!==3||!p.textContent.trim())continue;h+=p.textContent;let c=document.createRange();c.selectNodeContents(p);for(let g of c.getClientRects()){if(g.width<1||g.height<1)continue;let f={left:g.left+scrollX,top:g.top+scrollY,right:g.right+scrollX,bottom:g.bottom+scrollY},o=z(f,r);I(o)>0&&i.push(o)}}return{text:h.replace(/\s+/g," ").trim(),rects:i}}function ht(n){let e=n.map(r=>(r.top+r.bottom)/2).sort((r,p)=>r-p),i=0,h=-1e9;for(let r of e)r-h>3&&(i++,h=r);return i}function Y(n,e){return(n.getAttribute("aria-label")||e||n.getAttribute("title")||n.getAttribute("alt")||"").replace(/\s+/g," ").trim().slice(0,60)}var $t=4e3,pt=2500;function Q(){let n=globalThis,e=[];n.__THREE__&&e.push("three.js r"+n.__THREE__),n.AFRAME&&e.push("A-Frame "+(n.AFRAME.version||"")),n.BABYLON&&e.push("Babylon.js "+(n.BABYLON.Engine?.Version||"")),n.pc&&n.pc.version&&e.push("PlayCanvas "+n.pc.version),[...document.querySelectorAll("canvas")].some(r=>r.__r3f||r.parentElement?.__r3f)&&e.push("React Three Fiber");let i=n.__rlContexts||{},h=document.querySelectorAll("canvas").length;return{frameworks:e.map(r=>r.trim()),webgl:(i.webgl||0)+(i.webgl2||0),webgpu:i.webgpu||0,canvases:h,xr:!!n.__rlXR||!!navigator.xr&&e.length>0,is3D:e.length>0||(i.webgl||0)+(i.webgl2||0)+(i.webgpu||0)>0}}function tt(n={}){let e=null;n.revealSkipped&&(e=document.createElement("style"),e.textContent="*{content-visibility:visible!important}",document.head.append(e));try{return At(n)}finally{e?.remove()}}function At(n){let e=ct(),i={width:innerWidth,height:innerHeight},h=[],r=t=>h.push(t),p=[],c=[],g=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT);for(let t=g.currentNode;t&&!(p.length>=$t);t=g.nextNode()){if(!(t instanceof HTMLElement)||J.has(t.tagName)||t.closest("[data-rl-overlay]"))continue;let{text:d,rects:a}=dt(t,e);if(!d||!a.length||e.hidden(t)||e.effectiveOpacity(t)<.05||!n.revealSkipped&&t.checkVisibility&&!t.checkVisibility({contentVisibilityAuto:!0}))continue;let l=t.getBoundingClientRect();if(l.width<=2||l.height<=2)continue;let x=P(t);p.push({el:t,key:R(t),text:d,rects:a,ignore:x,pinned:e.isPinned(t)})}let f=[];p.forEach((t,d)=>t.rects.forEach(a=>f.push({i:d,r:a}))),f.sort((t,d)=>t.r.top-d.r.top);let o=new Set,s=[],u=0;for(let t=0;t<f.length;t++){let d=f[t];for(;u<t&&f[u].r.bottom<=d.r.top;)u++;for(let a=u;a<t;a++){let l=f[a];if(d.i===l.i||l.r.bottom<=d.r.top)continue;let x=p[d.i],w=p[l.i];if(x.pinned!==w.pinned||x.el.contains(w.el)||w.el.contains(x.el)||x.ignore.has("all")||x.ignore.has("text-overlap")||w.ignore.has("all")||w.ignore.has("text-overlap"))continue;let y=z(d.r,l.r),k=Math.min(I(d.r),I(l.r)),E=Math.min(d.r.bottom-d.r.top,l.r.bottom-l.r.top);if(I(y)<.25*k||y.bottom-y.top<.4*E)continue;let T=d.i<l.i?d.i+":"+l.i:l.i+":"+d.i;o.has(T)||(o.add(T),s.push({ta:x,tb:w,cut:y,share:Math.round(100*I(y)/k)}))}}for(let t of St(s)){let{ta:d,tb:a,cut:l,share:x,top:w}=t;r({rule:"text-overlap",keys:[d.key,a.key].sort(),elements:[{key:d.key,text:d.text.slice(0,60)},{key:a.key,text:a.text.slice(0,60)}],rect:l,onTop:w,measured:{overlap:x+"% of the smaller line",...w?{onTop:w.summary}:{}}})}for(let t of p){let d=t.text.split(/\s+/).filter(Boolean).length,a=ht(t.rects);if(c.length<pt&&t.text.length>=6){let l=Math.min(...t.rects.map(k=>k.left)),x=Math.max(...t.rects.map(k=>k.right)),w=Math.min(...t.rects.map(k=>k.top)),y=Math.max(...t.rects.map(k=>k.bottom));c.push({key:t.key,kind:"text",text:t.text.slice(0,60),words:d,lines:a,w:Math.round(x-l),rect:{left:l,top:w,right:x,bottom:y}})}if(!(t.ignore.has("all")||t.ignore.has("squashed-text"))&&d>=3&&a>=3&&d/a<=1.25&&t.text.length>=15){let l=Math.min(...t.rects.map(k=>k.left)),x=Math.max(...t.rects.map(k=>k.right)),w=Math.min(...t.rects.map(k=>k.top)),y=Math.max(...t.rects.map(k=>k.bottom));r({rule:"squashed-text",keys:[t.key],elements:[{key:t.key,text:t.text.slice(0,60)}],rect:{left:l,top:w,right:x,bottom:y},measured:{width:Math.round(x-l),lines:a,words:d}})}}let b=new Set;for(let t of p)for(let d=t.el;d&&d!==document.body;d=d.parentElement){let a=e.cs(d),l=a.overflowX==="hidden"||a.overflowX==="clip",x=a.overflowY==="hidden"||a.overflowY==="clip";if(!l&&!x)continue;if(b.has(d)||(b.add(d),d.clientWidth<2||d.clientHeight<2||e.hidden(d))||a.webkitLineClamp&&a.webkitLineClamp!=="none"||!(l&&d.scrollWidth>d.clientWidth+2||x&&d.scrollHeight>d.clientHeight+2))break;let y=d.getBoundingClientRect(),k={left:y.left+scrollX,top:y.top+scrollY,right:y.left+scrollX+d.clientWidth,bottom:y.top+scrollY+d.clientHeight},E=P(d);!E.has("all")&&!E.has("clipped-text")&&r({rule:"clipped-text",keys:[R(d)],elements:[{key:R(d),text:Y(d,t.text)}],rect:k,ellipsis:a.textOverflow==="ellipsis",measured:{contentWidth:d.scrollWidth,boxWidth:d.clientWidth,contentHeight:d.scrollHeight,boxHeight:d.clientHeight}});break}let m=document.documentElement.scrollWidth;if(m>i.width+1&&!P(document.body).has("page-overflow")){let t=[],d=document.body.querySelectorAll("*");for(let a of d){if(t.length>=5)break;if(!(a instanceof HTMLElement)||J.has(a.tagName)||e.hidden(a))continue;let l=a.getBoundingClientRect();l.right+scrollX<=i.width+1||l.width===0||e.clipRect(a.parentElement).right<=i.width+1||a.parentElement.getBoundingClientRect().right+scrollX>i.width+1&&a.parentElement!==document.body||t.push({key:R(a),text:Y(a,(a.textContent||"").trim())||a.tagName.toLowerCase(),right:Math.round(l.right+scrollX)})}r({rule:"page-overflow",keys:t.map(a=>a.key).sort().slice(0,1),elements:t,rect:null,measured:{pageWidth:m,viewport:i.width,by:m-i.width}})}for(let t of document.body.querySelectorAll(lt)){if(!(t instanceof HTMLElement)||t.closest("[data-rl-overlay]"))continue;let d=e.cs(t);if(d.display==="none"||t.disabled||t.closest("[aria-hidden=true],[inert],[hidden]"))continue;let a=t.getBoundingClientRect();if(a.width<4||a.height<4)continue;let l={left:a.left+scrollX,top:a.top+scrollY,right:a.right+scrollX,bottom:a.bottom+scrollY};if(I(z(l,e.clipRect(t.parentElement)))<4)continue;let x=e.effectiveOpacity(t),w=x<.1&&d.visibility==="visible"&&d.pointerEvents!=="none";if(c.length<pt+500&&c.push({key:R(t),kind:"control",text:Y(t,(t.textContent||"").trim()),visible:!w,rect:l}),!w||t.matches("input[type=checkbox],input[type=radio],input[type=file],input[type=range]")&&(t.labels?.length||t.closest("label")))continue;let y=P(t);y.has("all")||y.has("hidden-control")||r({rule:"hidden-control",keys:[R(t)],elements:[{key:R(t),text:Y(t,(t.textContent||"").trim())||t.tagName.toLowerCase()}],rect:l,measured:{opacity:+x.toFixed(2)}})}return{width:i.width,height:i.height,env:Q(),findings:h,measures:c}}function St(n){if(!n.length)return[];let e=document.createElement("style");e.textContent="*{pointer-events:auto!important}",document.head.append(e);let i=scrollX,h=scrollY,r=[];try{for(let p of n){let c=(p.cut.left+p.cut.right)/2,g=(p.cut.top+p.cut.bottom)/2,f=p.ta.pinned&&p.tb.pinned,o=c-scrollX,s=g-scrollY;!f&&(o<0||s<0||o>=innerWidth||s>=innerHeight)&&(window.scrollTo({left:Math.max(0,c-innerWidth/2),top:Math.max(0,g-innerHeight/2),behavior:"instant"}),o=c-scrollX,s=g-scrollY),f&&(o=c-i,s=g-h);let u=document.elementsFromPoint(o,s),b=a=>u.findIndex(l=>l===a||a.contains(l)),m=b(p.ta.el),t=b(p.tb.el);if(m<0&&t<0)continue;let d=m<0?p.tb.el:t<0||m<=t?p.ta.el:p.tb.el;r.push({...p,top:Rt(d)})}}finally{e.remove(),(scrollX!==i||scrollY!==h)&&window.scrollTo({left:i,top:h,behavior:"instant"})}return r}function Rt(n){let e=n;for(let p=n;p&&p!==document.body;p=p.parentElement){let c=getComputedStyle(p);if(c.position!=="static"||c.zIndex!=="auto"||c.transform!=="none"){e=p;break}}let i=getComputedStyle(e),h=[i.position!=="static"?"position: "+i.position:"",i.zIndex!=="auto"?"z-index: "+i.zIndex:"",i.transform!=="none"?"transformed":""].filter(Boolean),r=(n.textContent||"").replace(/\s+/g," ").trim().slice(0,40);return{key:R(e),text:r,position:i.position,zIndex:i.zIndex,summary:`"${r}"`+(h.length?" ("+h.join(", ")+")":" (normal flow)")}}var mt="https://github.com/prajwalsouza/ResponsiveLint/blob/main/",ut={"responsivelint-fix-overlap":{title:"Fix text drawn over other text",rules:["text-overlap"]},"responsivelint-fix-cramped-text":{title:"Fix text that is squeezed or cut off",rules:["squashed-text","clipped-text","width-outlier"]},"responsivelint-fix-overflow":{title:"Fix a page that scrolls sideways",rules:["page-overflow"]},"responsivelint-fix-controls":{title:"Fix controls that are invisible or go missing",rules:["hidden-control","disappears-in-band"]}},Lt=n=>{let e=Object.keys(ut).find(h=>ut[h].rules.includes(n))||"responsivelint-fix",i=`agents/skills/${e}/SKILL.md`;return{name:e,file:i,url:mt+i}},D={"text-overlap":{pack:"text",severity:"error",confidence:"high",title:"Text covers other text",why:"Two pieces of visible text are drawn in the same place, so neither can be read.",tries:["An element with position: absolute or fixed sits on text that wraps at this width: place it with flex or grid instead, or move it off the text. Changing z-index only swaps which text is hidden.","A box has a fixed height, so its text spills out when it wraps: remove height, or use min-height.","A negative margin or a transform pulls one element onto another: remove it at these widths.","A toast, tooltip or badge is placed on a toolbar: place it above or beside the toolbar."]},"squashed-text":{pack:"text",severity:"warning",confidence:"high",title:"Text squeezed to about one word per line",why:"The text has become so narrow that almost every word sits on its own line.",tries:["A neighbour in the same row does not wrap (white-space: nowrap, flex-shrink: 0, an auto grid column full of buttons): let it wrap with flex-wrap: wrap, or put it on its own line with grid-template-columns: 1fr.","The row keeps two columns at a width where one fits better: stack them below this width with a media or container query.","Nothing stops the text from shrinking: give it min-width: 12em (or similar)."]},"clipped-text":{pack:"text",severity:"warning",confidence:"medium",title:"Text cut off by its box",why:"A box with overflow hidden is smaller than the text inside it, so part of the text is not shown.",tries:["The box has a fixed width or height: remove it, or use min-width or min-height, so the box grows with its text.","The text is not allowed to wrap (white-space: nowrap): allow wrapping.","The cut is intended: add text-overflow: ellipsis and a title with the full text, so the finding becomes a note."]},"page-overflow":{pack:"overflow",severity:"error",confidence:"high",title:"The page scrolls sideways",why:"Something is wider than the screen, so the whole page can be dragged sideways.",tries:["The named element has a fixed width in pixels: use max-width: 100%, or a width in % or fr.","A row of controls or a long word or URL does not wrap: add flex-wrap: wrap, or overflow-wrap: anywhere for long words.","A wide table, code block or image: wrap it in a box with overflow-x: auto, or give images max-width: 100%.","Do not hide the problem with overflow-x: hidden on body or html; it cuts content off instead."]},"hidden-control":{pack:"visibility",severity:"warning",confidence:"medium",title:"A control takes space but cannot be seen",why:"A button, link or tab is laid out, clickable and focusable, but fully transparent in its resting state, so people do not know it is there.",tries:["It appears only on hover (opacity: 0 until :hover): show it at rest, perhaps quieter, because touch screens have no hover.","It should stay hidden until something happens: hide it properly with display: none, visibility: hidden or the hidden attribute until then, so it leaves the tab order too.","Keyboard users cannot find it: also show it on :focus-visible and :focus-within."]},"width-outlier":{pack:"sweep",severity:"warning",confidence:"high",title:"Breaks only in a narrow band of widths",why:"This element looks normal at the widths on both sides, but changes sharply inside this band, which is how layout bugs between breakpoints show up.",tries:["One part of the layout switches at a breakpoint before another does (a sidebar appears before the content stacks): line the two media queries up, or switch the content to a container query.","A neighbour stops wrapping inside the band and takes the width: let it wrap, or stack it below this width.","A fixed size takes over inside the band: replace it with min(), max() or clamp()."]},"disappears-in-band":{pack:"sweep",severity:"warning",confidence:"medium",title:"A control disappears in a narrow band of widths",why:"The control is visible at the widths on both sides but not inside this band.",tries:["Two media queries hand over at different widths (one hides the desktop control, the other shows the mobile one a few pixels later): use the same width for both, or one query.","max-width and min-width both use the same number, so one pixel shows neither: use max-width: 767px with min-width: 768px, or a range query.","The control is pushed out of its row and clipped: let the row wrap."]}};for(let n of Object.values(D))n.fix=n.tries[0];function Ct(n,e){let i=[...new Set(n)].sort((p,c)=>p-c),h=new Map(e.map((p,c)=>[p,c])),r=[];for(let p of i){let c=r[r.length-1];c&&h.get(p)===h.get(c[1])+1?c[1]=p:r.push([p,p])}return r}var ft=n=>{let e=[...n].sort((i,h)=>i-h);return e.length?e[Math.floor(e.length/2)]:0};function _t(n,e,i){let h=[];for(let[r,p]of n){let c=e.map(s=>p.get(s));if(c.filter(Boolean).length<5)continue;let g=c.find(Boolean).kind,f=new Array(c.length).fill(!1);for(let s=0;s<c.length;s++){let u=c[s],b=[];for(let m=1;m<=3;m++)c[s-m]&&b.push(c[s-m]),c[s+m]&&b.push(c[s+m]);if(!(b.length<3)){if(g==="text"){if(!u)continue;let m=ft(b.map(a=>a.lines)),t=ft(b.map(a=>a.words/Math.max(1,a.lines))),d=u.words/Math.max(1,u.lines);f[s]=u.words>=3&&u.lines>=Math.max(3,2*m,m+2)&&d<=.5*t&&d<=2.5}else if(g==="control"){let m=b.filter(t=>t.visible).length;f[s]=(!u||!u.visible)&&m>=b.length-1}}}let o=0;for(;o<c.length;){if(!f[o]){o++;continue}let s=o;for(;s+1<c.length&&f[s+1];)s++;let u=c.slice(0,o).some((t,d)=>t&&!f[d]),b=c.slice(s+1).some((t,d)=>t&&!f[s+1+d]),m=s-o+1<=Math.max(1,Math.floor(.35*c.length));if(u&&b&&m){let t=c[o]||c.slice(o,s+1).find(Boolean),d=c.slice(0,o).reverse().find(Boolean),a=g==="text"?"width-outlier":"disappears-in-band";h.push({rule:a,keys:[r],state:i,widths:e.slice(o,s+1),elements:[{key:r,text:(t||d)?.text||""}],rect:t?.rect||d?.rect,goodWidth:e[e.indexOf(e[o])-1],measured:g==="text"&&t?{lines:t.lines,wordsPerLine:+(t.words/t.lines).toFixed(1)}:{visible:!1},expected:g==="text"&&d?{lines:d.lines,wordsPerLine:+(d.words/Math.max(1,d.lines)).toFixed(1)}:{visible:!0}})}o=s+1}}return h}function et(n,e={}){let i=[...new Set(n.map(o=>o.width))].sort((o,s)=>o-s),h=[];for(let o of n)for(let s of o.findings)h.push({...s,state:o.state,widths:[o.width]});let r=new Map;for(let o of n)r.has(o.state.id)||r.set(o.state.id,{state:o.state,snaps:[]}),r.get(o.state.id).snaps.push(o);for(let{state:o,snaps:s}of r.values()){if(s.length<5)continue;let u=new Map;for(let m of s)for(let t of m.measures)u.has(t.key+"|"+t.kind)||u.set(t.key+"|"+t.kind,new Map),u.get(t.key+"|"+t.kind).set(m.width,t);let b=new Map([...u].map(([m,t])=>[m.split("|")[0],t]));h.push(..._t(b,s.map(m=>m.width).sort((m,t)=>m-t),o))}let p=new Map;for(let o of h){let s=o.rule+"|"+o.keys.join("+");p.has(s)||p.set(s,{...o,widths:[],states:[],instances:[]});let u=p.get(s);u.widths.push(...o.widths),u.states.some(b=>b.id===o.state.id)||u.states.push(o.state),u.instances.push({state:o.state.id,width:o.widths[0],rect:o.rect,measured:o.measured})}Ht(p);let c={error:0,warning:1,info:2},g={high:0,medium:1,low:2},f=[];for(let[o,s]of p){let u=D[s.rule];if(e.only&&!e.only.includes(u.pack)&&!e.only.includes(s.rule)||e.skip&&(e.skip.includes(u.pack)||e.skip.includes(s.rule)))continue;let b=u.severity,m=u.confidence;s.rule==="clipped-text"&&s.ellipsis&&(b="info");let t=[...new Set(s.widths)].sort((a,l)=>a-l),d=Wt(s,u);f.push({id:It(o),rule:s.rule,pack:u.pack,severity:b,confidence:m,title:u.title,elements:s.elements,widths:t,bands:Ct(t,i),everyWidth:t.length===i.length,states:s.states.map(a=>a.label),measured:s.measured,expected:s.expected,why:u.why,fix:d[0],tries:d,guide:mt+"docs/rules/"+s.rule+".md",skill:Lt(s.rule),suppress:`data-rl-ignore="${s.rule}"`,instances:s.instances.slice(0,50),goodWidth:s.goodWidth})}return e.minConfidence&&f.splice(0,f.length,...f.filter(o=>g[o.confidence]<=g[e.minConfidence])),f.sort((o,s)=>c[o.severity]-c[s.severity]||g[o.confidence]-g[s.confidence]||s.widths.length-o.widths.length),{widths:i,findings:f}}function Wt(n,e){let i=[...e.tries],h=(p,c)=>{let[g]=i.splice(p,1);i.unshift(c||g)},r=n.measured||{};if(n.rule==="text-overlap"){let p=n.onTop;p&&["absolute","fixed","sticky"].includes(p.position)?h(0,`The text on top, ${p.summary}, is taken out of the normal layout: place it with flex or grid instead, or move it so it does not sit on the text. Changing z-index only swaps which text is hidden. (${p.key})`):p&&p.position==="static"&&h(1)}else n.rule==="clipped-text"&&(n.ellipsis?h(2,"The cut is marked with an ellipsis, so it looks intended: make sure a title or tooltip gives the full text."):r.contentWidth>r.boxWidth&&!(r.contentHeight>r.boxHeight)&&h(1));return i}function Ht(n){let e=r=>r.includes(">")?r.slice(0,r.lastIndexOf(">")):r,i=new Map;for(let[r,p]of n){if(p.rule!=="text-overlap")continue;let[c,g]=p.keys;for(let[f,o]of[[c,g],[g,c]]){let s=f+"~"+e(o);i.has(s)||i.set(s,[]),i.get(s).push({id:r,shared:f,other:o})}}let h=new Set;for(let[r,p]of[...i].sort((c,g)=>g[1].length-c[1].length)){let c=p.filter(m=>!h.has(m.id)&&n.has(m.id));if(c.length<2)continue;let g=n.get(c[0].id),f=c[0].shared,o=e(c[0].other),s=g.elements.find(m=>m.key===f),u=c.map(m=>n.get(m.id).elements.find(t=>t.key===m.other)?.text).filter(Boolean),b={...g,keys:[f,o],widths:[],states:[],instances:[],elements:[s,{key:o,text:u.join(" \xB7 ").slice(0,60)}]};for(let m of c){let t=n.get(m.id);b.widths.push(...t.widths);for(let d of t.states)b.states.some(a=>a.id===d.id)||b.states.push(d);b.instances.push(...t.instances),n.delete(m.id),h.add(m.id)}n.set("text-overlap|"+f+"+"+o,b)}}function It(n){let e=2166136261;for(let i=0;i<n.length;i++)e^=n.charCodeAt(i),e=Math.imul(e,16777619);return(e>>>0).toString(36)}var X={error:"hsla(358, 75%, 59%, 1)",warning:"hsla(38, 92%, 50%, 1)",info:"hsla(220, 9%, 46%, 1)",labelText:"hsla(0, 0%, 100%, 1)",halo:"hsla(0, 0%, 100%, 0.85)"},Xt=(n,e)=>`${n.title} \xB7 ${e} px`;function wt(n,e,{width:i,rect:h}={}){let r=n.defaultView;Nt(n);let p=(e.elements||[]).map(l=>{try{return n.querySelector(l.key)}catch{return null}}),c=p[0];if(c){let l=c.getBoundingClientRect(),x=l.left<0||l.right>r.innerWidth?Math.max(0,r.scrollX+l.left-16):r.scrollX;r.scrollTo(x,Math.max(0,r.scrollY+l.top-Math.max(48,(r.innerHeight-l.height)/3)))}else h&&r.scrollTo(0,Math.max(0,h.top-r.innerHeight/3));let g=l=>{let x=l.getBoundingClientRect();return{left:x.left+r.scrollX,top:x.top+r.scrollY,right:x.right+r.scrollX,bottom:x.bottom+r.scrollY}},f=c?g(c):h;if(!f)return{found:!1,rect:null,remove:()=>{}};let o=X[e.severity]||X.error,s=n.createElement("div");s.setAttribute("data-rl-overlay","highlight"),s.style.cssText="all:initial;position:absolute;left:0;top:0;width:0;height:0;z-index:2147483646;pointer-events:none";let u=s.attachShadow({mode:"open"}),b=(l,x)=>{let w=n.createElement("div");w.style.cssText=`position:absolute;box-sizing:border-box;left:${l.left-3}px;top:${l.top-3}px;width:${l.right-l.left+6}px;height:${l.bottom-l.top+6}px;border:2px ${x?"dashed":"solid"} ${o};border-radius:4px;box-shadow:0 0 0 2px ${X.halo}`,w.setAttribute("part",x?"other":"outline"),u.append(w)};b(f,!1),p[1]&&p[1]!==c&&b(g(p[1]),!0);let m=f.top-r.scrollY>56||f.top>56,t=Math.min(Math.max(f.left+12,12),r.scrollX+r.innerWidth-24),d=n.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("width","16"),d.setAttribute("height","10"),d.setAttribute("viewBox","0 0 16 10"),d.setAttribute("part","pointer"),d.style.cssText=`position:absolute;left:${t}px;top:${m?f.top-15:f.bottom+5}px;overflow:visible;${m?"":"transform:rotate(180deg)"}`,d.innerHTML=`<path d="M0 0 L16 0 L8 10 Z" fill="${o}"/>`,u.append(d);let a=n.createElement("div");return a.setAttribute("part","label"),a.textContent=Xt(e,i??r.innerWidth),a.style.cssText=`position:absolute;left:${Math.max(4,t-8)}px;top:${m?f.top-15:f.bottom+15}px;transform:${m?"translateY(-100%)":"none"};max-width:${Math.max(160,r.innerWidth-24)}px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:${o};color:${X.labelText};font:600 12px/1.4 system-ui,-apple-system,sans-serif;padding:3px 8px;border-radius:5px`,u.append(a),n.body.append(s),{found:!!c,rect:f,remove:()=>s.remove()}}function Nt(n){for(let e of n.querySelectorAll('[data-rl-overlay="highlight"]'))e.remove()}var L={bg:"hsla(222, 18%, 13%, 0.96)",fg:"hsla(0, 0%, 100%, 0.95)",muted:"hsla(220, 12%, 72%, 1)",line:"hsla(0, 0%, 100%, 0.14)",hover:"hsla(0, 0%, 100%, 0.08)",link:"hsla(212, 92%, 72%, 1)",shadow:"hsla(0, 0%, 0%, 0.28)"},Ot=`
|
|
2
|
+
:host { all: initial; }
|
|
3
|
+
.bar { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 2147483647; box-sizing: border-box;
|
|
4
|
+
width: min(560px, calc(100vw - 16px)); background: ${L.bg}; color: ${L.fg}; border-radius: 12px; padding: 10px 12px;
|
|
5
|
+
box-shadow: 0 8px 28px ${L.shadow}; font: 13px/1.45 system-ui, -apple-system, sans-serif; }
|
|
6
|
+
.nav { display: flex; align-items: center; gap: 6px; }
|
|
7
|
+
button { all: unset; cursor: pointer; padding: 3px 10px; border-radius: 7px; border: 1px solid ${L.line}; color: ${L.fg}; font: inherit; }
|
|
8
|
+
button:hover:not([disabled]) { background: ${L.hover}; }
|
|
9
|
+
button[disabled] { opacity: .4; cursor: default; }
|
|
10
|
+
button.close { border-color: transparent; margin-left: auto; padding: 3px 8px; font-size: 16px; line-height: 1; }
|
|
11
|
+
.count { color: ${L.muted}; min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
|
|
12
|
+
.title { margin-top: 8px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
|
|
13
|
+
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
|
|
14
|
+
.where, .note, .skill { color: ${L.muted}; margin-top: 2px; }
|
|
15
|
+
.try { margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
|
16
|
+
a { color: ${L.link}; text-decoration: none; }
|
|
17
|
+
a:hover { text-decoration: none; opacity: .85; }
|
|
18
|
+
[hidden] { display: none !important; }
|
|
19
|
+
`,Ft=n=>(n.bands||[]).map(([e,i])=>e===i?`${e}`:`${e}\u2013${i}`).join(", ")+" px";function gt(n,{onPrev:e,onNext:i,onClose:h}={}){let r=n.createElement("div");r.setAttribute("data-rl-overlay","bar");let p=r.attachShadow({mode:"open"});p.innerHTML=`<style>${Ot}</style><div class="bar" role="dialog" aria-label="ResponsiveLint replay">
|
|
20
|
+
<div class="nav"><button class="prev" type="button">\u2039 Previous</button><span class="count"></span><button class="next" type="button">Next \u203A</button>
|
|
21
|
+
<button class="close" type="button" aria-label="Close">\xD7</button></div>
|
|
22
|
+
<div class="title"><span class="dot"></span><span class="text"></span></div>
|
|
23
|
+
<div class="where"></div><div class="try"></div><div class="skill"></div><div class="note" hidden></div></div>`;let c=f=>p.querySelector(f);c(".prev").onclick=()=>e?.(),c(".next").onclick=()=>i?.(),c(".close").onclick=()=>h?.();let g=f=>{if(!f.target?.closest?.("input,textarea,select,[contenteditable]")){if(f.key==="ArrowRight")i?.();else if(f.key==="ArrowLeft")e?.();else if(f.key==="Escape")h?.();else return;f.preventDefault()}};return n.addEventListener("keydown",g,!0),(n.body||n.documentElement).append(r),{host:r,update({finding:f,index:o,total:s,width:u,note:b,busy:m}){c(".count").textContent=`${o+1} of ${s}`,c(".prev").disabled=m||o<=0,c(".next").disabled=m||o>=s-1,c(".dot").style.background=X[f.severity]||X.error,c(".text").textContent=f.title;let t=(f.states||[]).join(" \xB7 ");c(".where").textContent=`${Ft(f)}${t?" \xB7 "+t:""}${u?` \xB7 shown at ${u} px`:""}`,c(".try").textContent=f.tries?.[0]?"Try: "+f.tries[0]:"";let d=c(".skill");if(d.textContent="",f.skill?.url){let a=n.createElement("a");a.href=f.skill.url,a.target="_blank",a.rel="noopener",a.textContent=f.skill.name,d.append("Fix skill: ",a)}c(".note").hidden=!(b||m),c(".note").textContent=m?"Loading from the start\u2026":b||""},remove(){n.removeEventListener("keydown",g,!0),r.remove()}}}function xt(n,e,{url:i,route:h,storage:r,height:p}){let c=n.instances[0],g=e.find(m=>m.id===c?.state)||e[0],f=n.instances.filter(m=>m.state===c?.state).map(m=>m.width),o=n.bands.find(([m,t])=>f.some(d=>d>=m&&d<=t))||n.bands[0],s=(o[0]+o[1])/2,u=f.filter(m=>m>=o[0]&&m<=o[1]),b=(u.length?u:f.length?f:[Math.round(s)]).reduce((m,t)=>Math.abs(t-s)<Math.abs(m-s)?t:m);return{url:i,route:h,storage:r,width:b,height:p,startWidth:1280,state:g.id,label:g.label,actions:g.actions||[]}}var nt="responsivelint-frame",bt=document.currentScript,_=bt?bt.dataset:{};if(window.name===nt)window.__ResponsiveLintFrame={checkNow:tt};else{let n=/^(localhost|127\.0\.0\.1|\[::1\]|.+\.localhost|.+\.test)$/.test(location.hostname)||location.protocol==="file:",e=window.ResponsiveLint=Dt();if(n||"anywhere"in _){let i=async()=>{e.check();let h=_.ui==="replay";"ui"in _&&!h&&e.ui(!0),"sweep"in _&&(!h||!_.report)&&await e.sweep(),h&&e.replay()};document.readyState==="complete"?setTimeout(i,50):addEventListener("load",()=>setTimeout(i,50))}}var yt={wait:300,clickWait:300,clickTimeout:3e3,pace:0},Bt=5e3,Pt=250,F=n=>new Promise(e=>setTimeout(e,n)),Yt=(n,e=2)=>new Promise(i=>{let h=r=>r?n.requestAnimationFrame(()=>h(r-1)):i();h(e)});function vt(n={}){let e={...yt};for(let i of Object.keys(yt)){let h=n[i]??_[i];h!=null&&h!==""&&Number.isFinite(+h)&&+h>=0&&(e[i]=+h)}return e}async function K(n,e=0){try{await n.document.fonts?.ready,await Yt(n);let i=(n.document.getAnimations?.()||[]).filter(h=>h.playState==="running"&&h.effect?.getTiming?.().iterations!==1/0);await Promise.race([Promise.all(i.map(h=>h.finished.catch(()=>{}))),F(600)])}catch{}e&&await F(e)}function jt(n){let e=0,i=0,h=c=>{e=Math.max(0,e+c),i=Date.now()},r=c=>String(c||"GET").toUpperCase(),p=c=>["GET","HEAD","OPTIONS"].includes(r(c));try{let c=n.fetch;c&&(n.fetch=function(f,o){let s=o?.method||f&&typeof f=="object"&&f.method;return p(s)?(h(1),c.call(this,f,o).finally(()=>h(-1))):Promise.reject(new TypeError("ResponsiveLint replay blocks "+r(s)+" requests"))});let g=n.XMLHttpRequest?.prototype;if(g){let f=g.open,o=g.send;g.open=function(s,...u){return this.__rlMethod=s,f.call(this,s,...u)},g.send=function(...s){if(!p(this.__rlMethod)){this.abort();return}return h(1),this.addEventListener("loadend",()=>h(-1),{once:!0}),o.apply(this,s)}}}catch{}return async()=>{let c=Date.now()+Bt;for(;Date.now()<c;){if(!e&&Date.now()-i>=Pt)return;await F(40)}}}async function zt(n,e,i){let h=Date.now()+i;for(;;){let r=n.querySelector(e);if(r){let p=r.getBoundingClientRect();if(p.width&&p.height&&n.defaultView.getComputedStyle(r).visibility!=="hidden")return r}if(Date.now()>h)throw new Error(`no visible ${e} after ${i} ms`);await F(50)}}function Dt(){let n=new Set,e=new Set,i=[],h=[],r=!1,p=0,c=a=>e.forEach(l=>{try{l(a)}catch{}});function g(a){for(let l of a){if(n.has(l.id))continue;n.add(l.id),c(l);let x=l.severity==="error"?"#e5484d":l.severity==="warning"?"#d08a12":"#888";console.groupCollapsed(`%cResponsiveLint%c ${l.severity==="error"?"\u2716":"\u25B2"} ${l.rule}: ${l.title}`,"font-weight:700",`color:${x}`);for(let w of l.elements)console.log(w.text?`\u201C${w.text}\u201D`:w.key,document.querySelector(w.key)||w.key);console.log("where:",l.bands.map(([w,y])=>w===y?w:`${w}\u2013${y}`).join(", ")+" px",l.states.join(" \xB7 ")),l.measured&&console.log("measured:",l.measured,l.expected?["neighbours:",l.expected]:""),console.log("why:",l.why),console.log(`try:
|
|
24
|
+
`+l.tries.map((w,y)=>`${y+1}. ${w}`).join(`
|
|
25
|
+
`)),console.log("skill:",l.skill.name,l.skill.url),console.log("silence:",l.suppress),console.groupEnd()}}function f(){let a=tt(),l=Q();return i=et([{state:{id:"live",label:"live page"},width:a.width,findings:a.findings,measures:[]}]).findings,g(i),l.is3D&&!n.has("3d")&&(n.add("3d"),console.info("ResponsiveLint: 3D detected ("+(l.frameworks.join(", ")||"WebGL")+"). The 3D rule pack is not implemented yet.")),r&&b(),i}let o=()=>{clearTimeout(p),p=setTimeout(f,500)};addEventListener("resize",o),addEventListener("click",o,!0),new MutationObserver(a=>{a.some(l=>!(l.target instanceof Element&&l.target.closest("[data-rl-overlay]")))&&o()}).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-expanded","open"]});async function s({from:a=320,to:l=1920,step:x=48}={}){let w=document.createElement("iframe");w.name=nt,w.src=location.href,w.setAttribute("data-rl-overlay",""),w.style.cssText=`position:fixed;left:-20000px;top:0;height:${innerHeight}px;width:1280px;border:0;visibility:hidden`,document.body.append(w);try{await new Promise((E,T)=>{w.onload=E,setTimeout(()=>T(new Error("timeout")),2e4)});let y=w.contentWindow;if(!y.__ResponsiveLintFrame)throw new Error("the page does not load this script in a frame");await K(y,vt().wait);let k=[];for(let E=a;E<=l;E+=x){w.style.width=E+"px",await new Promise($=>y.requestAnimationFrame(()=>y.requestAnimationFrame(()=>setTimeout($,120))));let T=y.__ResponsiveLintFrame.checkNow();k.push({state:{id:"sweep",label:"width sweep"},width:E,findings:T.findings,measures:T.measures})}return h=et(k).findings,g(h),r&&b(),h}catch(y){return console.info("ResponsiveLint: the width sweep could not run ("+y.message+"). Use the command line, npx responsivelint, for a full sweep."),[]}finally{w.remove()}}let u=null;function b(){if(u?.remove(),!r)return;u=document.createElement("div"),u.setAttribute("data-rl-overlay",""),u.style.cssText="position:absolute;left:0;top:0;width:0;height:0;z-index:2147483646;pointer-events:none";let a=[...i,...h.filter(w=>!i.some(y=>y.id===w.id))];for(let w of i)for(let y of w.instances){let k=y.rect;if(!k)continue;let E=document.createElement("div");E.style.cssText=`position:absolute;left:${k.left}px;top:${k.top}px;width:${k.right-k.left}px;height:${k.bottom-k.top}px;outline:2px solid ${w.severity==="error"?"#e5484d":"#d08a12"};outline-offset:1px;border-radius:2px`,E.title=w.title,u.append(E)}let l=document.createElement("div");l.style.cssText="position:fixed;right:12px;bottom:12px;max-width:360px;max-height:50vh;overflow:auto;pointer-events:auto;background:hsla(0,0%,100%,.97);color:#1d1f24;border-radius:10px;box-shadow:0 6px 24px hsla(0,0%,0%,.18);font:12px/1.45 system-ui,sans-serif;padding:10px 12px",l.innerHTML=`<div style="display:flex;align-items:center;gap:8px;margin-bottom:6px"><b style="margin-right:auto">ResponsiveLint \xB7 ${a.length} finding${a.length===1?"":"s"}</b>${a.length?'<button type="button" data-act="replay" style="border:1px solid hsla(220,15%,85%,1);border-radius:6px;background:none;cursor:pointer;font:inherit;padding:1px 8px">Replay</button>':""}<button type="button" data-act="close" style="border:0;background:none;cursor:pointer;font:inherit">\xD7</button></div>`,l.querySelector("[data-act=close]").onclick=()=>api.ui(!1);let x=l.querySelector("[data-act=replay]");x&&(x.onclick=()=>api.replay(a));for(let w of a){let y=document.createElement("div");y.style.cssText="padding:5px 0;border-top:1px solid hsla(220,15%,90%,1);cursor:pointer";let k=w.bands.map(([T,$])=>T===$?T:`${T}\u2013${$}`).join(", ")+" px",E=T=>String(T).replace(/[&<>"]/g,$=>({"&":"&","<":"<",">":">",'"':"""})[$]);y.innerHTML=`<span style="color:${w.severity==="error"?"#e5484d":"#b37400"}">${w.severity==="error"?"\u2716":"\u25B2"}</span> ${E(w.title)}<br><span style="color:#6b7280">${E((w.elements[0]?.text||w.elements[0]?.key||"").slice(0,50))} \xB7 ${k}</span><br><span style="color:#374151">Try: ${E(w.tries[0])}</span> <a href="${E(w.skill.url)}" target="_blank" rel="noopener" style="color:hsla(220,70%,45%,1);text-decoration:none">${E(w.skill.name)}</a>`,y.onclick=()=>document.querySelector(w.elements[0]?.key)?.scrollIntoView({block:"center",behavior:"smooth"}),l.append(y)}u.append(l),m&&(u.style.display="none"),document.body.append(u)}let m=null;async function t(a){let l=await fetch(a,{cache:"no-store"});if(!l.ok)throw new Error(`${a}: ${l.status}`);return(await l.json()).findings||[]}async function d(a,l={}){if(!a)try{a=_.report?await t(_.report):[...i,...h.filter(v=>!i.some(M=>M.id===v.id))]}catch(v){return console.info("ResponsiveLint: could not load the report ("+v.message+")."),null}if(!a.length)return console.info("ResponsiveLint: nothing to replay."),null;m?.close(),u&&(u.style.display="none");let x=vt(l),w=a.map(v=>({finding:v,recipe:v.replay||xt(v,[{id:v.instances?.[0]?.state||"live",label:"live page",actions:[]}],{url:location.href,route:null,storage:{},height:innerHeight})})),y=new Map,k=(v,M)=>{try{y.has(v)||y.set(v,localStorage.getItem(v)),localStorage.setItem(v,M)}catch{}},E=-1,T=null,$=0,ot=0,V=!1,it=async()=>{let v=ot+x.pace-Date.now();v>0&&await F(v),ot=Date.now()},N=document.createElement("div");N.setAttribute("data-rl-overlay","replay"),N.style.cssText="position:fixed;inset:0;z-index:2147483645;background:hsla(222,18%,10%,0.55)";let W=document.createElement("div");W.style.cssText="position:absolute;left:0;top:0;transform-origin:0 0;box-shadow:0 8px 32px hsla(0,0%,0%,0.35);background:hsla(0,0%,100%,1)",N.append(W),document.body.append(N);let G=gt(document,{onPrev:()=>j(E-1),onNext:()=>j(E+1),onClose:()=>rt()}),kt=204,U=12,st=(v,M)=>{let S=Math.min(1,(innerWidth-2*U)/v,(innerHeight-kt-U)/M);T.style.width=v+"px",T.style.height=M+"px",W.style.width=v+"px",W.style.height=M+"px",W.style.transform=`translate(${Math.round((innerWidth-v*S)/2)}px, ${U}px) scale(${S})`,W.dataset.scale=S.toFixed(3)};function Tt(v){let M=new URL(v.url,location.href);return M.origin===location.origin?M.href:location.origin+M.pathname+M.search+M.hash}async function j(v){if(V||v<0||v>=w.length)return null;let M=++$;E=v;let{finding:S,recipe:A}=w[v],at=A.height||innerHeight;G.update({finding:S,index:v,total:w.length,width:A.width,busy:!0}),T?.remove();for(let[C,B]of Object.entries(A.storage||{}))k(C,B);if(await it(),M!==$)return null;T=document.createElement("iframe"),T.name=nt,T.setAttribute("data-rl-overlay","replay-frame"),T.title="ResponsiveLint replay",T.style.cssText="display:block;border:0;background:hsla(0,0%,100%,1)",W.append(T),st(A.startWidth||1280,at);let O="";try{if(await new Promise((H,Z)=>{T.onload=H,setTimeout(()=>Z(new Error("the page took over 20 s to load")),2e4),T.src=Tt(A)}),M!==$)return null;let C=T.contentWindow,B=T.contentDocument;if(!B)throw new Error("the frame is not on the same site");let Et=jt(C);await K(C,x.wait);for(let H of A.actions||[]){let Z=await zt(B,H.click,x.clickTimeout);if(M!==$)return null;await it(),Z.click(),await Et(),await K(C,150),x.clickWait&&await F(x.clickWait)}if(st(A.width,at),await K(C),M!==$)return null;let Mt=(S.instances||[]).find(H=>H.width===A.width&&H.state===A.state&&H.rect);wt(B,S,{width:A.width,rect:Mt?.rect}).found||(O="The element is not on the page at this width."),!(A.actions||[]).length&&!S.replay&&(O=O||"Shown in the starting state: clicks made on the live page are not recorded.")}catch(C){O="Could not repeat the steps: "+C.message}return M!==$?null:(G.update({finding:S,index:v,total:w.length,width:A.width,note:O}),N.dataset.step=String(v),{index:v,note:O,frame:T})}function rt(){if(!V){V=!0,$++,G.remove(),N.remove();for(let[v,M]of y)try{M==null?localStorage.removeItem(v):localStorage.setItem(v,M)}catch{}m===q&&(m=null,b())}}let q={go:j,close:rt,get index(){return E},get frame(){return T},steps:w.map(v=>v.recipe),done:null};return m=q,q.done=j(l.start||0),await q.done,q}return{check:f,sweep:s,replay:d,ui(a=!0){return r=!!a,b(),r},on(a,l){return a==="finding"&&e.add(l),()=>e.delete(l)},get findings(){return[...i,...h]},rules:D}}})();
|