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 CHANGED
@@ -23,7 +23,7 @@ npx responsivelint http://localhost:5173
23
23
 
24
24
  The first run needs Chromium. If you see `ResponsiveLint could not find Chromium. Run: npx playwright install chromium`, run the install command and try again.
25
25
 
26
- If you are running ResponsiveLint via `npx` without installing it in your project, use the Playwright version that matches ResponsiveLint 0.1.0.
26
+ If you are running ResponsiveLint via `npx` without installing it in your project, use the Playwright version that matches ResponsiveLint 0.2.0.
27
27
 
28
28
  ```sh
29
29
  npx --yes --package=playwright@1.59.1 playwright install chromium
@@ -40,7 +40,7 @@ npx responsivelint ./dist --json report.json --html report.html
40
40
  Add this script to a local development page. The URL loads the browser build from npm through jsDelivr.
41
41
 
42
42
  ```html
43
- <script src="https://cdn.jsdelivr.net/npm/responsivelint@0.1.0/dist/responsivelint.js" data-ui data-sweep></script>
43
+ <script src="https://cdn.jsdelivr.net/npm/responsivelint@0.2.0/dist/responsivelint.js" data-ui data-sweep></script>
44
44
  ```
45
45
 
46
46
  - Findings appear once each in DevTools with a reference to the affected element.
@@ -50,6 +50,45 @@ Add this script to a local development page. The URL loads the browser build fro
50
50
 
51
51
  In DevTools, call `window.ResponsiveLint.check()` to check the current width, `await window.ResponsiveLint.sweep()` to sweep widths, or `window.ResponsiveLint.ui(false)` to close the panel. Read the results from `window.ResponsiveLint.findings`.
52
52
 
53
+ ## Replay a finding
54
+
55
+ A replay walks you to each problem. A bar at the bottom shows Previous, "3 of 7", Next and close, with the finding's title, where it happens, the first thing to try and its fix skill. Every step starts from zero: the page loads fresh at 1280 px, the clicks that led to the state are repeated, the width changes to one inside the finding's band, and the element is outlined with a pointer and a short label such as "Text covers other text · 720 px". The arrow keys move between findings and Escape closes the bar.
56
+
57
+ From the command line, the replay opens a visible Chromium window.
58
+
59
+ ```sh
60
+ npx responsivelint http://localhost:5173 --replay
61
+ npx responsivelint replay report.json
62
+ npx responsivelint replay report.json http://localhost:5174
63
+ ```
64
+
65
+ The first command checks the page, prints the report and then starts the replay. The second replays a saved `--json` report. Add a base URL, as in the third, when the dev server now runs at another address. A report of a folder serves that folder again. The replay keeps the check's safety rules: local and test hosts only unless `--allow-remote`, no POST, PUT, PATCH or DELETE requests, and no pages from other sites.
66
+
67
+ In the page, the replay shows each step in a visible copy of the page, in a frame set to the finding's width and scaled down when it is wider than the window.
68
+
69
+ ```html
70
+ <script src="https://cdn.jsdelivr.net/npm/responsivelint@0.2.0/dist/responsivelint.js" data-ui="replay" data-sweep></script>
71
+ <script src="https://cdn.jsdelivr.net/npm/responsivelint@0.2.0/dist/responsivelint.js" data-ui="replay" data-report="/report.json"></script>
72
+ ```
73
+
74
+ - `data-ui="replay"` starts the replay once the page's own check, and the sweep when asked for, has finished. The `data-ui` panel also has a Replay button.
75
+ - `data-report` replays a report from the command line instead. Its findings carry their clicks. Findings found on the live page have none, because clicks you made before are not recorded, so they replay in the starting state and the bar says so.
76
+ - `await window.ResponsiveLint.replay(findings)` starts it from DevTools. It returns `{go(i), close(), index, frame, steps}`.
77
+ - The frame shares this site's storage. The replay sets the report's `--storage` values while it runs and puts the old values back when it closes. Inside the frame it blocks POST, PUT, PATCH and DELETE requests made with `fetch` or `XMLHttpRequest`.
78
+
79
+ ## Slow apps and rate limits
80
+
81
+ These options control how long ResponsiveLint waits and how fast it acts. They apply to state discovery, the width sweep and the replay. The script tag accepts the same names as `data-` attributes. Values are in milliseconds.
82
+
83
+ | Command line | Script tag | What it does | Default |
84
+ | --- | --- | --- | --- |
85
+ | `--wait 300` | `data-wait="300"` | Pauses after the page loads. | 300 |
86
+ | `--click-wait 300` | `data-click-wait="300"` | Pauses after each click, once no requests are pending. The wait for pending requests stops after 5 s. | 300 |
87
+ | `--click-timeout 3000` | `data-click-timeout="3000"` | Sets how long to wait for a control to appear before giving up on it. | 3000 |
88
+ | `--pace 0` | `data-pace="0"` | Sets the least time between two page loads or clicks, for servers with rate limits. | 0 |
89
+
90
+ After a click, ResponsiveLint waits until the page has had no pending requests for 250 ms, then for fonts and animations, then for `--click-wait`. Raise `--click-wait` for a panel that opens on a timer. Use `--pace 1000` to load or click at most once a second. Raise `--wait` for an app that shows a loading screen or fades its controls in after it loads: controls that are still transparent then are reported as hidden. Some pages reload themselves when the width crosses a breakpoint. ResponsiveLint opens the state again at that width and names those widths in its log.
91
+
53
92
  ## What it checks
54
93
 
55
94
  - [text-overlap](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/text-overlap.md) finds visible text drawn over other text.
@@ -79,6 +118,8 @@ The default sweep checks widths from 320 to 1920 px in 48 px steps and includes
79
118
  | `--min-confidence high\|medium` | Hides findings below the chosen confidence level. |
80
119
  | `--strict` | Treats warnings as failures too. |
81
120
  | `--allow-remote` | Allows a target outside the local and test hosts. |
121
+ | `--wait`, `--click-wait`, `--click-timeout`, `--pace` | Timing for slow apps and rate limits. See [Slow apps and rate limits](#slow-apps-and-rate-limits). |
122
+ | `--replay` | Steps through the findings in a visible browser after the check. See [Replay a finding](#replay-a-finding). |
82
123
 
83
124
  Exit code `0` means no findings met the failure threshold. Code `1` means the report contains errors, or warnings with `--strict`. Code `2` means the command failed to run or received an unknown option.
84
125
 
@@ -102,7 +143,7 @@ jobs:
102
143
  - run: |
103
144
  npm run dev &
104
145
  curl --fail --retry 15 --retry-connrefused --retry-delay 1 http://localhost:5173 > /dev/null
105
- npx --yes responsivelint@0.1.0 http://localhost:5173 --html report.html
146
+ npx --yes responsivelint@0.2.0 http://localhost:5173 --html report.html
106
147
  - uses: actions/upload-artifact@v4
107
148
  if: always()
108
149
  with:
@@ -132,7 +173,7 @@ project's `.claude/skills/` or `.agents/skills/`, one folder per skill:
132
173
  cp -R node_modules/responsivelint/agents/skills/* .claude/skills/
133
174
  ```
134
175
 
135
- Run with `--json report.json`. The top-level `widths` and `states` say what was checked. Each finding has:
176
+ Run with `--json report.json`. The top-level `widths`, `states` and `timing` say what was checked and how. Each state lists the clicks that reach it in `actions`. Each finding has:
136
177
 
137
178
  | Field | Meaning |
138
179
  | --- | --- |
@@ -144,6 +185,7 @@ Run with `--json report.json`. The top-level `widths` and `states` say what was
144
185
  | `tries` | The usual causes and their fixes, most likely first, ordered by what was measured |
145
186
  | `skill` | The fix skill: `name`, `file` in the package, `url` |
146
187
  | `guide`, `suppress` | The rule guide, and the attribute that silences the rule when a layout is intended |
188
+ | `replay` | How to reproduce it from zero: load `url` at `startWidth` with `storage`, do the clicks in `actions`, then set `width` |
147
189
 
148
190
  ## Ignoring and safety
149
191
 
@@ -156,9 +198,10 @@ The command accepts local and test hosts by default. Use `--allow-remote` to che
156
198
  | Where | What you will find |
157
199
  | --- | --- |
158
200
  | [bin/](https://github.com/prajwalsouza/ResponsiveLint/tree/main/bin) | The terminal command and its options. |
159
- | [src/core/](https://github.com/prajwalsouza/ResponsiveLint/tree/main/src/core) | Page measurements and rules. |
160
- | [src/cli/](https://github.com/prajwalsouza/ResponsiveLint/tree/main/src/cli) | The browser runner and report writers. |
161
- | [src/browser/](https://github.com/prajwalsouza/ResponsiveLint/tree/main/src/browser) | The script tag entry point and page overlay. |
201
+ | [src/core/](https://github.com/prajwalsouza/ResponsiveLint/tree/main/src/core) | Page measurements, rules, the replay recipe, the highlighter and the replay bar. |
202
+ | [src/cli/](https://github.com/prajwalsouza/ResponsiveLint/tree/main/src/cli) | The browser runner, the command-line replay and report writers. |
203
+ | [src/browser/](https://github.com/prajwalsouza/ResponsiveLint/tree/main/src/browser) | The script tag entry point, page overlay and in-page replay. |
204
+ | [CHANGELOG.md](https://github.com/prajwalsouza/ResponsiveLint/blob/main/CHANGELOG.md) | What changed in each release. |
162
205
  | [docs/rules/](https://github.com/prajwalsouza/ResponsiveLint/tree/main/docs/rules) | A guide for each rule. |
163
206
  | [agents/skills/](https://github.com/prajwalsouza/ResponsiveLint/tree/main/agents/skills) | Agent Skills: running a check, and one fix skill per group of rules. |
164
207
  | [llms.txt](https://github.com/prajwalsouza/ResponsiveLint/blob/main/llms.txt) | A short reference for agents. |
@@ -28,8 +28,20 @@ Each finding has `rule`, `severity`, `confidence`, `elements` (a CSS selector in
28
28
  first), `skill` (the fix skill to load) and `guide`. The terminal report ends with the list of fix skills the
29
29
  findings need.
30
30
 
31
- Reproduce it before fixing: open the page at a width inside the band, repeat the click named in the state, and
32
- look at the element. Compare with a width just outside the band.
31
+ Reproduce it before fixing. Each finding has a `replay` recipe: load `replay.url` at `replay.startWidth` with
32
+ `replay.storage` in localStorage, click each selector in `replay.actions` in order, then set the width to
33
+ `replay.width` and look at the element. Compare with a width just outside the band. With Playwright, that is
34
+ `goto`, `click` for each action, then `setViewportSize`.
35
+
36
+ For a person, `npx responsivelint replay report.json` opens a visible browser that does this for each finding
37
+ and outlines the element, with Next and Previous in a bar. Use it to show someone the problem, not inside an
38
+ automated loop, because it waits for the window to close.
39
+
40
+ ## Slow or rate-limited apps
41
+
42
+ If a state that should exist is missing, the panel may open after a delay: raise `--click-wait` (for example
43
+ 2000). If controls take long to appear, raise `--click-timeout`. If the server limits requests, set `--pace`
44
+ to the least gap in milliseconds between page loads and clicks. `--wait` pauses after each load.
33
45
 
34
46
  ## Fix it
35
47
 
@@ -41,4 +53,5 @@ that is intended, never to hide a real problem.
41
53
 
42
54
  Add `<script src="…/responsivelint.js" data-ui></script>` to a local page. Findings appear once each in the
43
55
  console, with the element you can hover in DevTools, and `data-ui` outlines them on the page. `data-sweep`
44
- also sweeps widths in a hidden copy of the page.
56
+ also sweeps widths in a hidden copy of the page, and `data-ui="replay"` steps through the findings one at a
57
+ time.
@@ -1,11 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  // responsivelint <url | folder> [options]
3
- import {writeFile, mkdir} from 'node:fs/promises';
3
+ // responsivelint replay report.json [base-url] [options]
4
+ import {writeFile, mkdir, readFile} from 'node:fs/promises';
4
5
  import {dirname} from 'node:path';
5
6
  import {check} from '../src/cli/run.js';
6
7
  import {terminalReport, htmlReport} from '../src/cli/report.js';
8
+ import {replay} from '../src/cli/replay.js';
7
9
 
8
10
  const HELP = `responsivelint <url | folder> [options]
11
+ responsivelint replay report.json [base-url] [options]
9
12
 
10
13
  Checks a page at every width and in every state it can reach, and reports where the layout breaks.
11
14
 
@@ -21,12 +24,23 @@ Checks a page at every width and in every state it can reach, and reports where
21
24
  --min-confidence high|medium hide less certain findings
22
25
  --strict exit with status 1 on warnings as well as errors
23
26
  --allow-remote allow a host that is not local or a test host
27
+
28
+ Timing, for slow or rate-limited apps (milliseconds):
29
+ --wait 300 pause after the page loads
30
+ --click-wait 300 pause after each click, once the network is quiet (up to 5 s)
31
+ --click-timeout 3000 how long to wait for a control to appear before giving up
32
+ --pace 0 least time between page loads and clicks
33
+
34
+ Replay:
35
+ --replay after the check, step through the findings in a visible browser
36
+ replay report.json [base-url] step through a saved JSON report; base-url moves it to another server
24
37
  `;
25
38
 
26
39
  const args = process.argv.slice(2);
27
40
  if (!args.length || args.includes('--help') || args.includes('-h')) { console.log(HELP); process.exit(0); }
28
41
  const opt = {storage: {}};
29
- let target = null;
42
+ let target = null, replayFile = null, base = null;
43
+ if (args[0] === 'replay') { args.shift(); replayFile = args.shift(); if (!replayFile) { console.error(`replay needs a JSON report\n\n${HELP}`); process.exit(2); } }
30
44
  for (let i = 0; i < args.length; i++) {
31
45
  const a = args[i], v = () => args[++i];
32
46
  if (!a.startsWith('--')) { target = a; continue; }
@@ -44,16 +58,38 @@ for (let i = 0; i < args.length; i++) {
44
58
  case '--min-confidence': opt.minConfidence = v(); break;
45
59
  case '--strict': opt.strict = true; break;
46
60
  case '--allow-remote': opt.allowRemote = true; break;
47
- case '--wait': opt.wait = +v(); break;
61
+ case '--wait': opt.wait = ms(a, v()); break;
62
+ case '--click-wait': opt.clickWait = ms(a, v()); break;
63
+ case '--click-timeout': opt.clickTimeout = ms(a, v()); break;
64
+ case '--pace': opt.pace = ms(a, v()); break;
65
+ case '--replay': opt.replay = true; break;
48
66
  case '--route': opt.route = v(); break;
49
67
  case '--storage': { const s = v(); const k = s.indexOf('='); opt.storage[s.slice(0, k)] = s.slice(k + 1); break; }
50
68
  default: console.error(`Unknown option ${a}\n\n${HELP}`); process.exit(2);
51
69
  }
52
70
  }
71
+ function ms(name, value) {
72
+ const n = Number(value);
73
+ if (value == null || !Number.isFinite(n) || n < 0) { console.error(`${name} needs a number of milliseconds`); process.exit(2); }
74
+ return n;
75
+ }
53
76
  if (!Object.keys(opt.storage).length) delete opt.storage;
54
77
  if (opt.html && opt.evidence == null) opt.evidence = 12;
55
78
 
79
+ async function stepThrough(report) {
80
+ const n = report.findings.length;
81
+ if (!n) { process.stderr.write('Nothing to replay: the report has no findings.\n'); return; }
82
+ process.stderr.write(`Replaying ${n} finding${n === 1 ? '' : 's'} in a visible browser. Use Next and Previous in the bar, or the arrow keys; close the bar or the window to stop.\n`);
83
+ const session = await replay(report, {...opt, base, onStep: (s) => process.stderr.write(` ${s.index + 1} of ${n}: ${s.finding.title} at ${s.finding.replay.width} px${s.note ? ` (${s.note})` : ''}\n`)});
84
+ await session.done;
85
+ }
86
+
56
87
  try {
88
+ if (replayFile) {
89
+ const report = JSON.parse(await readFile(replayFile, 'utf8'));
90
+ await stepThrough(report);
91
+ process.exit(0);
92
+ }
57
93
  const report = await check(target, {...opt, log: (s) => process.stderr.write(s + '\n')});
58
94
  console.log(terminalReport(report));
59
95
  for (const [file, body] of [[opt.json, () => JSON.stringify(report, null, 2)], [opt.html, () => htmlReport(report)]]) {
@@ -62,6 +98,7 @@ try {
62
98
  await writeFile(file, body());
63
99
  process.stderr.write(`Wrote ${file}\n`);
64
100
  }
101
+ if (opt.replay) await stepThrough(report);
65
102
  const bad = report.findings.filter((f) => f.severity === 'error' || (opt.strict && f.severity === 'warning'));
66
103
  process.exit(bad.length ? 1 : 0);
67
104
  } catch (e) {
package/dist/core.iife.js CHANGED
@@ -12,12 +12,17 @@
12
12
  INTERACTIVE_SELECTOR: () => INTERACTIVE_SELECTOR,
13
13
  PACKS: () => PACKS,
14
14
  RULES: () => RULES,
15
+ START_WIDTH: () => START_WIDTH,
15
16
  analyze: () => analyze,
16
17
  bands: () => bands,
17
18
  checkNow: () => checkNow,
19
+ clearHighlight: () => clearHighlight,
18
20
  detectEnvironment: () => detectEnvironment,
19
21
  elementKey: () => elementKey,
22
+ findingLabel: () => findingLabel,
20
23
  fingerprint: () => fingerprint,
24
+ highlight: () => highlight,
25
+ recipe: () => recipe,
21
26
  skillFor: () => skillFor,
22
27
  sweepOutliers: () => sweepOutliers
23
28
  });
@@ -708,6 +713,88 @@
708
713
  return (h >>> 0).toString(36);
709
714
  }
710
715
 
716
+ // src/core/highlight.js
717
+ var TOKENS = {
718
+ error: "hsla(358, 75%, 59%, 1)",
719
+ warning: "hsla(38, 92%, 50%, 1)",
720
+ info: "hsla(220, 9%, 46%, 1)",
721
+ labelText: "hsla(0, 0%, 100%, 1)",
722
+ halo: "hsla(0, 0%, 100%, 0.85)"
723
+ };
724
+ var findingLabel = (finding, width) => `${finding.title} \xB7 ${width} px`;
725
+ function highlight(doc, finding, { width, rect: fallback } = {}) {
726
+ const win = doc.defaultView;
727
+ clearHighlight(doc);
728
+ const els = (finding.elements || []).map((e) => {
729
+ try {
730
+ return doc.querySelector(e.key);
731
+ } catch {
732
+ return null;
733
+ }
734
+ });
735
+ const main = els[0];
736
+ if (main) {
737
+ const b = main.getBoundingClientRect();
738
+ const left = b.left < 0 || b.right > win.innerWidth ? Math.max(0, win.scrollX + b.left - 16) : win.scrollX;
739
+ win.scrollTo(left, Math.max(0, win.scrollY + b.top - Math.max(48, (win.innerHeight - b.height) / 3)));
740
+ } else if (fallback) {
741
+ win.scrollTo(0, Math.max(0, fallback.top - win.innerHeight / 3));
742
+ }
743
+ const pageRect = (el) => {
744
+ const b = el.getBoundingClientRect();
745
+ return { left: b.left + win.scrollX, top: b.top + win.scrollY, right: b.right + win.scrollX, bottom: b.bottom + win.scrollY };
746
+ };
747
+ const r = main ? pageRect(main) : fallback;
748
+ if (!r) return { found: false, rect: null, remove: () => {
749
+ } };
750
+ const color = TOKENS[finding.severity] || TOKENS.error;
751
+ const host = doc.createElement("div");
752
+ host.setAttribute("data-rl-overlay", "highlight");
753
+ host.style.cssText = "all:initial;position:absolute;left:0;top:0;width:0;height:0;z-index:2147483646;pointer-events:none";
754
+ const root = host.attachShadow({ mode: "open" });
755
+ const box = (q, dashed) => {
756
+ const d = doc.createElement("div");
757
+ 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}`;
758
+ d.setAttribute("part", dashed ? "other" : "outline");
759
+ root.append(d);
760
+ };
761
+ box(r, false);
762
+ if (els[1] && els[1] !== main) box(pageRect(els[1]), true);
763
+ const above = r.top - win.scrollY > 56 || r.top > 56;
764
+ const x = Math.min(Math.max(r.left + 12, 12), win.scrollX + win.innerWidth - 24);
765
+ const arrow = doc.createElementNS("http://www.w3.org/2000/svg", "svg");
766
+ arrow.setAttribute("width", "16");
767
+ arrow.setAttribute("height", "10");
768
+ arrow.setAttribute("viewBox", "0 0 16 10");
769
+ arrow.setAttribute("part", "pointer");
770
+ arrow.style.cssText = `position:absolute;left:${x}px;top:${above ? r.top - 15 : r.bottom + 5}px;overflow:visible;${above ? "" : "transform:rotate(180deg)"}`;
771
+ arrow.innerHTML = `<path d="M0 0 L16 0 L8 10 Z" fill="${color}"/>`;
772
+ root.append(arrow);
773
+ const label2 = doc.createElement("div");
774
+ label2.setAttribute("part", "label");
775
+ label2.textContent = findingLabel(finding, width ?? win.innerWidth);
776
+ 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`;
777
+ root.append(label2);
778
+ doc.body.append(host);
779
+ return { found: !!main, rect: r, remove: () => host.remove() };
780
+ }
781
+ function clearHighlight(doc) {
782
+ for (const el of doc.querySelectorAll('[data-rl-overlay="highlight"]')) el.remove();
783
+ }
784
+
785
+ // src/core/recipe.js
786
+ var START_WIDTH = 1280;
787
+ function recipe(f, states, { url, route, storage, height }) {
788
+ const inst = f.instances[0];
789
+ const state = states.find((s) => s.id === inst?.state) || states[0];
790
+ const seen = f.instances.filter((i) => i.state === inst?.state).map((i) => i.width);
791
+ const band = f.bands.find(([a, b]) => seen.some((w) => w >= a && w <= b)) || f.bands[0];
792
+ const mid = (band[0] + band[1]) / 2;
793
+ const inBand = seen.filter((w) => w >= band[0] && w <= band[1]);
794
+ const width = (inBand.length ? inBand : seen.length ? seen : [Math.round(mid)]).reduce((best, w) => Math.abs(w - mid) < Math.abs(best - mid) ? w : best);
795
+ return { url, route, storage, width, height, startWidth: START_WIDTH, state: state.id, label: state.label, actions: state.actions || [] };
796
+ }
797
+
711
798
  // src/explore/page.js
712
799
  var DANGEROUS = /\b(delete|remove|destroy|erase|log ?out|sign ?out|unsubscribe|pay|purchase|buy|checkout|submit|send|publish|reset)\b/i;
713
800
  function discoverCandidates({ limit = 60 } = {}) {
@@ -768,6 +855,90 @@
768
855
  return { url: location.href, hash: location.hash, boxes: out };
769
856
  }
770
857
 
858
+ // src/core/bar.js
859
+ var T = {
860
+ bg: "hsla(222, 18%, 13%, 0.96)",
861
+ fg: "hsla(0, 0%, 100%, 0.95)",
862
+ muted: "hsla(220, 12%, 72%, 1)",
863
+ line: "hsla(0, 0%, 100%, 0.14)",
864
+ hover: "hsla(0, 0%, 100%, 0.08)",
865
+ link: "hsla(212, 92%, 72%, 1)",
866
+ shadow: "hsla(0, 0%, 0%, 0.28)"
867
+ };
868
+ var CSS = `
869
+ :host { all: initial; }
870
+ .bar { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 2147483647; box-sizing: border-box;
871
+ width: min(560px, calc(100vw - 16px)); background: ${T.bg}; color: ${T.fg}; border-radius: 12px; padding: 10px 12px;
872
+ box-shadow: 0 8px 28px ${T.shadow}; font: 13px/1.45 system-ui, -apple-system, sans-serif; }
873
+ .nav { display: flex; align-items: center; gap: 6px; }
874
+ button { all: unset; cursor: pointer; padding: 3px 10px; border-radius: 7px; border: 1px solid ${T.line}; color: ${T.fg}; font: inherit; }
875
+ button:hover:not([disabled]) { background: ${T.hover}; }
876
+ button[disabled] { opacity: .4; cursor: default; }
877
+ button.close { border-color: transparent; margin-left: auto; padding: 3px 8px; font-size: 16px; line-height: 1; }
878
+ .count { color: ${T.muted}; min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
879
+ .title { margin-top: 8px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
880
+ .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
881
+ .where, .note, .skill { color: ${T.muted}; margin-top: 2px; }
882
+ .try { margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
883
+ a { color: ${T.link}; text-decoration: none; }
884
+ a:hover { text-decoration: none; opacity: .85; }
885
+ [hidden] { display: none !important; }
886
+ `;
887
+ var fmtWhere = (f) => (f.bands || []).map(([a, b]) => a === b ? `${a}` : `${a}\u2013${b}`).join(", ") + " px";
888
+ function createBar(doc, { onPrev, onNext, onClose } = {}) {
889
+ const host = doc.createElement("div");
890
+ host.setAttribute("data-rl-overlay", "bar");
891
+ const root = host.attachShadow({ mode: "open" });
892
+ root.innerHTML = `<style>${CSS}</style><div class="bar" role="dialog" aria-label="ResponsiveLint replay">
893
+ <div class="nav"><button class="prev" type="button">\u2039 Previous</button><span class="count"></span><button class="next" type="button">Next \u203A</button>
894
+ <button class="close" type="button" aria-label="Close">\xD7</button></div>
895
+ <div class="title"><span class="dot"></span><span class="text"></span></div>
896
+ <div class="where"></div><div class="try"></div><div class="skill"></div><div class="note" hidden></div></div>`;
897
+ const $ = (s) => root.querySelector(s);
898
+ $(".prev").onclick = () => onPrev?.();
899
+ $(".next").onclick = () => onNext?.();
900
+ $(".close").onclick = () => onClose?.();
901
+ const key = (e) => {
902
+ if (e.target?.closest?.("input,textarea,select,[contenteditable]")) return;
903
+ if (e.key === "ArrowRight") onNext?.();
904
+ else if (e.key === "ArrowLeft") onPrev?.();
905
+ else if (e.key === "Escape") onClose?.();
906
+ else return;
907
+ e.preventDefault();
908
+ };
909
+ doc.addEventListener("keydown", key, true);
910
+ (doc.body || doc.documentElement).append(host);
911
+ return {
912
+ host,
913
+ update({ finding: f, index, total, width, note, busy }) {
914
+ $(".count").textContent = `${index + 1} of ${total}`;
915
+ $(".prev").disabled = busy || index <= 0;
916
+ $(".next").disabled = busy || index >= total - 1;
917
+ $(".dot").style.background = TOKENS[f.severity] || TOKENS.error;
918
+ $(".text").textContent = f.title;
919
+ const states = (f.states || []).join(" \xB7 ");
920
+ $(".where").textContent = `${fmtWhere(f)}${states ? " \xB7 " + states : ""}${width ? ` \xB7 shown at ${width} px` : ""}`;
921
+ $(".try").textContent = f.tries?.[0] ? "Try: " + f.tries[0] : "";
922
+ const sk = $(".skill");
923
+ sk.textContent = "";
924
+ if (f.skill?.url) {
925
+ const a = doc.createElement("a");
926
+ a.href = f.skill.url;
927
+ a.target = "_blank";
928
+ a.rel = "noopener";
929
+ a.textContent = f.skill.name;
930
+ sk.append("Fix skill: ", a);
931
+ }
932
+ $(".note").hidden = !(note || busy);
933
+ $(".note").textContent = busy ? "Loading from the start\u2026" : note || "";
934
+ },
935
+ remove() {
936
+ doc.removeEventListener("keydown", key, true);
937
+ host.remove();
938
+ }
939
+ };
940
+ }
941
+
771
942
  // src/core/inject.js
772
- globalThis.__ResponsiveLint = { ...index_exports, discoverCandidates, layoutSignature };
943
+ globalThis.__ResponsiveLint = { ...index_exports, discoverCandidates, layoutSignature, createBar };
773
944
  })();