@reqvire-org/ads 0.3.51 → 0.3.52

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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * One axe-core run inside the scenario document, cut down to what a report keeps. `include` is the
3
+ * selector to audit, `rules` narrows it to named rules. It must stay self-contained: Playwright
4
+ * serializes the function into the page.
5
+ */
6
+ export async function axeRun({ tags, nodeLimit, include = "#root", rules }) {
7
+ // Asking for a group is what keeps its nodes: axe cuts every other group to one.
8
+ const runOnly = rules ? { type: "rule", values: rules } : { type: "tag", values: tags };
9
+ const outcome = await window.axe.run({ include: [[include]], exclude: [["#ads-preview-status"]] }, { runOnly, resultTypes: ["violations", "incomplete"], elementRef: false, ancestry: false });
10
+ const clip = (text, size) => typeof text === "string" ? text.replace(/\s+/g, " ").trim().slice(0, size) : "";
11
+ const selector = node => clip(node.target.flat().join(" "), 300), html = node => clip(node.html, 200);
12
+ const group = item => ({ id: item.id, impact: item.impact, tags: item.tags, help: clip(item.help, 300), helpUrl: clip(item.helpUrl, 300), nodeCount: item.nodes.length });
13
+ // axe's own key for why it could not decide, such as bgGradient or pseudoContent.
14
+ const reason = node => { const check = [...node.any, ...node.all, ...node.none].find(item => item.data?.messageKey) ?? [...node.any, ...node.all, ...node.none][0]; return clip(check?.data?.messageKey ?? check?.id ?? "", 80); };
15
+ return { violations: outcome.violations.map(violation => ({ ...group(violation), nodes: violation.nodes.slice(0, nodeLimit).map(node => ({ selector: selector(node), html: html(node), summary: clip(node.failureSummary, 500) })) })),
16
+ incomplete: outcome.incomplete.map(item => ({ ...group(item), nodes: item.nodes.slice(0, nodeLimit).map(node => ({ selector: selector(node), html: html(node), reason: reason(node) })) })) };
17
+ }
@@ -11,8 +11,8 @@
11
11
  * a small part's limit. A row of buttons that is simply too long for a pane is not reported.
12
12
  * - "clipped": an element with overflow-x hidden or clip whose content is more than 4 px wider
13
13
  * than its box, so content is cut off (a small negative margin cuts nothing).
14
- * Intended scrollers (overflow-x auto or scroll) and their content, text-overflow: ellipsis,
15
- * carousels (aria-roledescription="carousel"),
14
+ * Intended scrollers (overflow-x auto or scroll, other than the outermost window-tall one) and their content, text-overflow: ellipsis,
15
+ * carousels (aria-roledescription="carousel"), pannable widgets (role="application"),
16
16
  * native text fields, visually hidden content (a box of 1 px or less, clip or clip-path) and
17
17
  * fixed-position layers are exempt.
18
18
  *
@@ -68,8 +68,14 @@ export async function layoutOverflow({ nodeLimit, width: expected, container, sm
68
68
  return element.getBoundingClientRect().width > smallPart && element.checkVisibility() && (wide("width") || wide("min-width") || wide("flex-basis") && getComputedStyle(element).flexShrink === "0");
69
69
  }
70
70
  const forced = element => !container || setWide(element) || [...element.querySelectorAll("*")].some(inner => !excluded(inner.parentElement) && setWide(inner));
71
- // In the narrowed render, a box as tall as the window is the project's preview frame, not the scenario's own scroller or clip.
72
- const frame = element => !!container && Math.abs(element.getBoundingClientRect().height - window.innerHeight) <= 1;
71
+ // The outermost box as tall as the window is the page or the project's preview frame, not an
72
+ // intended scroller or clip: overflow-y: auto computes overflow-x to auto, and a page that scrolls
73
+ // sideways is what this check is for. A scroller inside it is a real one.
74
+ const frame = element => {
75
+ if (Math.abs(element.getBoundingClientRect().height - window.innerHeight) > 1) return false;
76
+ for (let node = element.parentElement; node && node !== root; node = node.parentElement) if (/^(?:auto|scroll)$/.test(getComputedStyle(node).overflowX)) return false;
77
+ return true;
78
+ };
73
79
  /** Whether an element is inside an intended scroller, a fixed layer or hidden content. */
74
80
  function excluded(element) {
75
81
  if (!element || element === root) return false;
@@ -90,7 +96,7 @@ export async function layoutOverflow({ nodeLimit, width: expected, container, sm
90
96
  const contained = () => { for (let node = element.parentElement; node && node !== root; node = node.parentElement) if (/^(?:hidden|clip)$/.test(getComputedStyle(node).overflowX) && !frame(node)) return true; return false; };
91
97
  const parent = element.parentElement === root ? pane : element.parentElement.getBoundingClientRect();
92
98
  if ((box.right > pane.right + 1 || box.left < pane.left - 1) && !(parent.right > pane.right + 1 || parent.left < pane.left - 1) && !contained() && forced(element)) report(edge, element, { overflow: Math.round(Math.max(box.right - pane.right, pane.left - box.left)) });
93
- if (/^(?:hidden|clip)$/.test(style.overflowX) && element.scrollWidth > element.clientWidth + 4 && style.textOverflow !== "ellipsis" && !element.closest('[aria-roledescription="carousel"]') && !/^(?:input|textarea|select)$/.test(element.localName) && style.clip === "auto" && style.clipPath === "none" && forced(element))
99
+ if (/^(?:hidden|clip)$/.test(style.overflowX) && element.scrollWidth > element.clientWidth + 4 && style.textOverflow !== "ellipsis" && !element.closest('[aria-roledescription="carousel"], [role="application"]') && !/^(?:input|textarea|select)$/.test(element.localName) && style.clip === "auto" && style.clipPath === "none" && forced(element))
94
100
  report("clipped", element, { overflow: element.scrollWidth - element.clientWidth });
95
101
  }
96
102
  return { issues, counts };
@@ -10,14 +10,16 @@
10
10
  * surrounding background ("border"). A button, link or tab with text or an icon is exempt: WCAG
11
11
  * 1.4.11 needs no boundary when that content identifies the control.
12
12
  * An icon-only control (an svg and no text) needs its icon's paint at 3:1 against the control's
13
- * effective background ("icon").
13
+ * effective background ("icon"). A busy control (aria-busy="true") is checked even when disabled,
14
+ * and its icon even when it has text: the spinner is the state it reports.
14
15
  * A control whose background contrasts 3:1 with its surroundings is identified by its background;
15
16
  * an icon-only one is still checked against that background. Disabled controls are exempt.
16
17
  * Browser-drawn native checkboxes, radios and ranges and backgrounds under an image or gradient
17
18
  * are skipped. Colors are read through a 1×1 canvas, so every CSS color syntax resolves to sRGB.
19
+ * `scope` measures one element and what is in it instead of #root.
18
20
  */
19
- export function nonTextContrast({ nodeLimit }) {
20
- const root = document.querySelector("#root");
21
+ export function nonTextContrast({ nodeLimit, scope }) {
22
+ const root = document.querySelector(scope ?? "#root");
21
23
  if (!root) return { issues: [], counts: {} };
22
24
  const canvas = document.createElement("canvas"); canvas.width = canvas.height = 1;
23
25
  const context = canvas.getContext("2d", { willReadFrequently: true }), cache = new Map();
@@ -48,12 +50,15 @@ export function nonTextContrast({ nodeLimit }) {
48
50
  const siblings = [...node.parentElement.children].filter(child => child.localName === node.localName);
49
51
  parts.unshift(`${node.localName}${siblings.length > 1 ? `:nth-of-type(${siblings.indexOf(node) + 1})` : ""}`);
50
52
  }
51
- return ["#root", ...parts].join(" > ");
53
+ return [scope ? root.localName : "#root", ...parts].join(" > ");
52
54
  };
53
55
  const native = /^(?:checkbox|radio|range|color|file|hidden)$/;
54
56
  const issues = [], counts = { border: 0, icon: 0 };
55
- for (const element of root.querySelectorAll('button, input, select, textarea, a[href], [role="switch"], [role="checkbox"], [role="radio"], [role="slider"], [role="tab"]')) {
56
- if (element.closest("#ads-preview-status") || element.matches(":disabled") || element.closest('[aria-disabled="true"], [inert]')) continue;
57
+ const controls = 'button, input, select, textarea, a[href], [role="switch"], [role="checkbox"], [role="radio"], [role="slider"], [role="tab"]';
58
+ for (const element of [...(scope && root.matches(controls) ? [root] : []), ...root.querySelectorAll(controls)]) {
59
+ // A busy control is disabled while it works, and its spinner still has to be seen.
60
+ const busy = element.getAttribute("aria-busy") === "true";
61
+ if (element.closest("#ads-preview-status") || !busy && element.matches(":disabled") || !busy && element.closest('[aria-disabled="true"]') || element.closest("[inert]")) continue;
57
62
  if (!element.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true })) continue;
58
63
  const box = element.getBoundingClientRect();
59
64
  if (box.width < 1 || box.height < 1) continue;
@@ -72,7 +77,7 @@ export function nonTextContrast({ nodeLimit }) {
72
77
  if (best[0] + 1e-9 < 3) report("border", best[0], over(best[1], around), around);
73
78
  }
74
79
  }
75
- const icon = !text(element) && [...element.querySelectorAll("svg")].find(svg => svg.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }));
80
+ const icon = (busy || !text(element)) && [...element.querySelectorAll("svg")].find(svg => svg.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }));
76
81
  if (icon) {
77
82
  const shape = [...icon.querySelectorAll("path, circle, rect, ellipse, line, polyline, polygon, use, text")].find(node => { const paint = getComputedStyle(node); return paint.stroke !== "none" && rgba(paint.stroke)[3] > 0 || paint.fill !== "none" && !paint.fill.startsWith("url(") && rgba(paint.fill)[3] > 0; });
78
83
  if (shape) {
@@ -0,0 +1,182 @@
1
+ import { axeRun } from "./axe-run.mjs";
2
+ import { nonTextContrast } from "./non-text-contrast.mjs";
3
+
4
+ /**
5
+ * Renders what a scenario shows only after someone acts on it, and measures it with the same checks.
6
+ *
7
+ * Overlays: each control marked aria-haspopup is clicked, up to `overlayLimit` not yet opened, and what
8
+ * opens is audited by axe and non-text contrast, then held to the phone viewport. Fixed layers are
9
+ * exempt from the overflow check of the page, so this is the only place their width is measured. An
10
+ * overlay a scenario renders open is measured the same way. Accessibility trees are read through
11
+ * ARIA, not names: a trigger with no aria-haspopup is not found, and its scenario can render it open.
12
+ *
13
+ * Hover and keyboard focus: up to `stateLimit` controls not yet measured in this theme are hovered with the real mouse and
14
+ * focused as the keyboard would, for contrast only: axe color-contrast when a quick reading looks
15
+ * wrong, non-text contrast in that state, and the focus outline against what is around it. What
16
+ * already fails at rest is not repeated.
17
+ *
18
+ * Results join the render's own, with selectors that say which state they were found in.
19
+ */
20
+ const overlays = '[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], dialog[open], [popover]:popover-open';
21
+
22
+ function markTargets({ selector, attribute, limit, signature, known = [] }) {
23
+ const seen = new Set(known), targets = [], keys = [];
24
+ for (const element of document.querySelector("#root").querySelectorAll(selector)) {
25
+ if (targets.length >= limit) break;
26
+ const box = element.getBoundingClientRect();
27
+ if (box.width < 1 || box.height < 1 || element.closest('#ads-preview-status, [inert], [aria-disabled="true"]') || element.matches(":disabled") || !element.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true })) continue;
28
+ const name = (element.getAttribute("aria-label") ?? element.textContent ?? "").replace(/\s+/g, " ").trim().slice(0, 60) || element.localName;
29
+ const key = `${signature.map(name => element.getAttribute(name) ?? "").join("|")}|${element.localName}|${attribute === "data-ads-audit-trigger" ? name : getComputedStyle(element.parentElement).backgroundColor}`;
30
+ if (seen.has(key)) continue;
31
+ seen.add(key); keys.push(key);
32
+ element.setAttribute(attribute, String(targets.length));
33
+ targets.push(name);
34
+ }
35
+ return { targets, keys };
36
+ }
37
+ const settle = () => new Promise(resolve => requestAnimationFrame(() => { for (const animation of document.getAnimations()) { try { animation.finish(); } catch { /* An endless one has no end to reach. */ } } requestAnimationFrame(resolve); }));
38
+
39
+ /** A quick reading of a hovered control's text against its background, so axe, which sets up the whole
40
+ * document on every run, only confirms what looks wrong. Unreadable backgrounds go to axe too. */
41
+ function hoverTextSuspect(selector) {
42
+ const element = document.querySelector(selector);
43
+ const canvas = document.createElement("canvas"); canvas.width = canvas.height = 1;
44
+ const context = canvas.getContext("2d", { willReadFrequently: true });
45
+ const rgba = value => { context.clearRect(0, 0, 1, 1); context.fillStyle = "#000"; context.fillStyle = value; context.fillRect(0, 0, 1, 1); const [r, g, b, a] = context.getImageData(0, 0, 1, 1).data; return [r, g, b, a / 255]; };
46
+ const over = (top, bottom) => [0, 1, 2].map(index => top[index] * top[3] + bottom[index] * (1 - top[3])).concat(1);
47
+ const lum = ([r, g, b]) => { const channel = value => { value /= 255; return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4; }; return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b); };
48
+ const behind = node => { if (!node) return [255, 255, 255, 1]; const style = getComputedStyle(node); if (style.backgroundImage !== "none") return null; const below = behind(node.parentElement); return below && over(rgba(style.backgroundColor), below); };
49
+ const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
50
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
51
+ if (!node.data.trim() || !node.parentElement.checkVisibility()) continue;
52
+ const back = behind(node.parentElement);
53
+ if (!back) return true;
54
+ const [a, b] = [lum(over(rgba(getComputedStyle(node.parentElement).color), back)), lum(back)];
55
+ if ((Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05) < 4.5) return true;
56
+ }
57
+ return false;
58
+ }
59
+
60
+ /** Marks the overlay that is open and was not known before; true when there is one. */
61
+ function markOpened({ overlays, known }) {
62
+ for (const element of document.querySelectorAll(overlays)) {
63
+ if (element.closest("#ads-preview-status") || known && element.hasAttribute("data-ads-audit-known") || !element.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true })) continue;
64
+ const box = element.getBoundingClientRect();
65
+ if (box.width < 1 || box.height < 1) continue;
66
+ element.setAttribute("data-ads-audit-overlay", "");
67
+ return true;
68
+ }
69
+ return false;
70
+ }
71
+ function overlayPastViewport() {
72
+ const element = document.querySelector("[data-ads-audit-overlay]");
73
+ if (!element) return null;
74
+ const box = element.getBoundingClientRect(), width = document.documentElement.clientWidth, past = Math.round(Math.max(box.right - width, -box.left));
75
+ return past > 1 ? { overflow: past, html: element.outerHTML.replace(/\s+/g, " ").slice(0, 200) } : null;
76
+ }
77
+ /** The focus outline's contrast with what is around it, when the focus shows as an outline. */
78
+ function focusOutline() {
79
+ const element = document.querySelector("[data-ads-audit-state]");
80
+ element.focus({ focusVisible: true });
81
+ if (document.activeElement !== element || !element.matches(":focus-visible")) return null;
82
+ const style = getComputedStyle(element);
83
+ // A ring drawn with box-shadow is not read, so an outline beside one is not taken for the only indicator.
84
+ if (style.outlineStyle === "none" || parseFloat(style.outlineWidth) <= 0 || style.boxShadow !== "none") return null;
85
+ const canvas = document.createElement("canvas"); canvas.width = canvas.height = 1;
86
+ const context = canvas.getContext("2d", { willReadFrequently: true });
87
+ const rgba = value => { context.clearRect(0, 0, 1, 1); context.fillStyle = "#000"; context.fillStyle = value; context.fillRect(0, 0, 1, 1); const [r, g, b, a] = context.getImageData(0, 0, 1, 1).data; return [r, g, b, a / 255]; };
88
+ const over = (top, bottom) => [0, 1, 2].map(index => top[index] * top[3] + bottom[index] * (1 - top[3])).concat(1);
89
+ const lum = ([r, g, b]) => { const channel = value => { value /= 255; return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4; }; return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b); };
90
+ const around = element => { if (!element) return [255, 255, 255, 1]; const parent = getComputedStyle(element); if (parent.backgroundImage !== "none") return null; const below = around(element.parentElement); return below && over(rgba(parent.backgroundColor), below); };
91
+ const back = around(element.parentElement);
92
+ if (!back) return null;
93
+ const color = over(rgba(style.outlineColor), back), [a, b] = [lum(color), lum(back)], ratio = (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
94
+ const hex = value => `#${value.slice(0, 3).map(part => Math.round(part).toString(16).padStart(2, "0")).join("")}`;
95
+ return ratio + 1e-9 < 3 ? { ratio: Math.round(ratio * 100) / 100, foreground: hex(color), background: hex(back), html: element.outerHTML.replace(/\s+/g, " ").slice(0, 200) } : null;
96
+ }
97
+
98
+ const unmarked = text => text?.replace(/\[?data-ads-audit-[a-z.]+(?:="[^"]*")?\]?/g, "").replace(/\s+>/g, " >").trim();
99
+ const named = (nodes, label) => nodes.map(node => ({ ...node, selector: `${label}: ${unmarked(node.selector)}`.slice(0, 300), ...(node.html ? { html: unmarked(node.html) } : {}) }));
100
+ const labelled = (groups, label) => groups.map(group => ({ ...group, nodes: named(group.nodes, label) }));
101
+
102
+ /** Runs both, adding what it finds to `result`. One failing control ends only its own part. */
103
+ export async function auditRenderStates({ page, frame, result, request, phoneWidth, measuredControls }) {
104
+ const { nodeLimit, tags, overlayLimit, stateLimit } = request, desktop = page.viewportSize();
105
+ const isClosed = () => frame.waitForFunction(() => { const element = document.querySelector("[data-ads-audit-overlay]"); return !element || !element.checkVisibility(); }, undefined, { timeout: 1000 }).then(() => true, () => false);
106
+ const unmark = () => frame.evaluate(() => { for (const element of document.querySelectorAll("[data-ads-audit-overlay]")) element.removeAttribute("data-ads-audit-overlay"); });
107
+ const measureOverlay = async (label, reopen) => {
108
+ await frame.evaluate(settle);
109
+ const found = await frame.evaluate(axeRun, { tags, nodeLimit, include: "[data-ads-audit-overlay]" });
110
+ result.violations.push(...labelled(found.violations, label)); result.incomplete.push(...labelled(found.incomplete, label));
111
+ const nonText = await frame.evaluate(nonTextContrast, { nodeLimit, scope: "[data-ads-audit-overlay]" });
112
+ result.nonText.issues.push(...named(nonText.issues, label));
113
+ for (const [kind, count] of Object.entries(nonText.counts)) result.nonText.counts[kind] = (result.nonText.counts[kind] ?? 0) + count;
114
+ await page.setViewportSize({ width: phoneWidth, height: desktop.height });
115
+ await frame.evaluate(settle);
116
+ let past = await frame.evaluate(overlayPastViewport);
117
+ // A menu is placed when it opens, so one opened on the desktop may be stale: open it here to be sure.
118
+ if (past && reopen) {
119
+ await page.keyboard.press("Escape");
120
+ if (await isClosed()) { await unmark(); past = await reopen() ? await frame.evaluate(settle).then(() => frame.evaluate(overlayPastViewport)) : null; }
121
+ }
122
+ if (past) result.layout.push({ width: phoneWidth, issues: [{ kind: "viewport", selector: label, ...past }], counts: { viewport: 1 } });
123
+ await page.setViewportSize(desktop);
124
+ await frame.evaluate(settle);
125
+ result.overlays = (result.overlays ?? 0) + 1;
126
+ };
127
+ // Already open: nothing to click, and nothing to close.
128
+ if (await frame.evaluate(markOpened, { overlays, known: false })) {
129
+ await measureOverlay("open overlay");
130
+ await unmark();
131
+ }
132
+ // A shell repeated across scenarios opens the same menu in each: one audit measures it once per theme and brand.
133
+ const { targets: triggers, keys: triggerKeys } = await frame.evaluate(markTargets, { selector: '[aria-haspopup]:not([aria-haspopup="false"])', attribute: "data-ads-audit-trigger", limit: overlayLimit, signature: ["aria-haspopup", "class"], known: [...measuredControls] });
134
+ for (const key of triggerKeys) measuredControls.add(key);
135
+ for (const [index, name] of triggers.entries()) {
136
+ try {
137
+ await frame.evaluate(overlays => { for (const element of document.querySelectorAll(overlays)) element.setAttribute("data-ads-audit-known", ""); }, overlays);
138
+ const open = async () => {
139
+ await frame.locator(`[data-ads-audit-trigger="${index}"]`).click({ timeout: 2000 });
140
+ return frame.waitForFunction(markOpened, { overlays, known: true }, { timeout: 1500 }).then(() => true, () => false);
141
+ };
142
+ if (!await open()) continue;
143
+ await measureOverlay(`open overlay "${name}"`, open);
144
+ await page.keyboard.press("Escape");
145
+ const closed = await isClosed();
146
+ await unmark();
147
+ // One that stays open covers the page, so the next trigger cannot be reached.
148
+ if (!closed) break;
149
+ } catch { /* A trigger that cannot be used says nothing about what it opens. */ }
150
+ }
151
+ // What already fails at rest: axe names elements the same way each run, and non-text findings are the same colors.
152
+ const pair = issue => JSON.stringify([issue.kind, issue.foreground, issue.background]);
153
+ const rest = new Set([...result.nonText.issues.map(pair), ...result.violations.filter(item => item.id === "color-contrast").flatMap(item => item.nodes.map(node => node.selector))]);
154
+ // The same control on the same surface measures the same everywhere, so one audit measures it once per theme and brand.
155
+ const { targets, keys } = await frame.evaluate(markTargets, { selector: 'button, a[href], input:not([type="hidden"]), select, textarea, [role="switch"], [role="checkbox"], [role="radio"], [role="slider"], [role="tab"]', attribute: "data-ads-audit-control", limit: stateLimit, signature: ["class", "role", "type"], known: [...measuredControls] });
156
+ for (const key of keys) measuredControls.add(key);
157
+ for (const [index] of targets.entries()) {
158
+ const target = `[data-ads-audit-control="${index}"]`;
159
+ try {
160
+ await frame.locator(target).hover({ timeout: 1000, force: true });
161
+ await frame.evaluate(target => document.querySelector(target).setAttribute("data-ads-audit-state", ""), target);
162
+ await frame.evaluate(settle);
163
+ if (await frame.evaluate(hoverTextSuspect, target)) {
164
+ const found = await frame.evaluate(axeRun, { tags, nodeLimit, include: target, rules: ["color-contrast"] });
165
+ const fresh = group => ({ ...group, nodes: group.nodes.filter(node => !rest.has(node.selector)) });
166
+ result.violations.push(...labelled(found.violations.map(fresh).filter(group => group.nodes.length), "hover"));
167
+ }
168
+ const nonText = await frame.evaluate(nonTextContrast, { nodeLimit, scope: target });
169
+ const issues = nonText.issues.filter(issue => !rest.has(pair(issue)));
170
+ result.nonText.issues.push(...named(issues, "hover"));
171
+ for (const issue of issues) result.nonText.counts[issue.kind] = (result.nonText.counts[issue.kind] ?? 0) + 1;
172
+ const outline = await frame.evaluate(focusOutline);
173
+ if (outline) {
174
+ result.nonText.issues.push({ kind: "focus", selector: `focus: ${await frame.locator(target).evaluate(element => element.localName)}`, ...outline });
175
+ result.nonText.counts.focus = (result.nonText.counts.focus ?? 0) + 1;
176
+ }
177
+ await frame.evaluate(target => { const element = document.querySelector(target); element.removeAttribute("data-ads-audit-state"); element.blur(); }, target);
178
+ } catch { /* A control that cannot be reached has no state to measure. */ }
179
+ }
180
+ await page.mouse.move(desktop.width - 1, desktop.height - 1);
181
+ result.controls = (result.controls ?? 0) + targets.length;
182
+ }
@@ -2,10 +2,12 @@ import { readFileSync, renameSync, writeFileSync } from "node:fs";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
4
  import { openPreviewScenario } from "../verification/browser.mjs";
5
+ import { axeRun } from "./axe-run.mjs";
5
6
  import { firstRender } from "./first-render.mjs";
6
7
  import { nonTextContrast } from "./non-text-contrast.mjs";
7
8
  import { layoutOverflow } from "./layout-overflow.mjs";
8
9
  import { layoutShift } from "./layout-shift.mjs";
10
+ import { auditRenderStates } from "./render-states.mjs";
9
11
 
10
12
  // Runs only as an owned child, using the receiving project's browser dependency.
11
13
  const request = JSON.parse(readFileSync(process.argv[2], "utf8"));
@@ -26,6 +28,7 @@ try {
26
28
  const apps = request.apps.filter(app => app.theme === theme);
27
29
  // The audit injects its own script; bypassCSP keeps project CSP from blocking it.
28
30
  const context = await browser.newContext({ viewport: request.viewport, deviceScaleFactor: 1, colorScheme: apps[0].scheme, bypassCSP: true, reducedMotion: "reduce" });
31
+ const measuredControls = new Set();
29
32
  try {
30
33
  // A bounded number of pages render at once; results keep request order.
31
34
  const results = [];
@@ -47,22 +50,13 @@ try {
47
50
  const frame = await openPreviewScenario(page, app.url, app.scenario, { timeout });
48
51
  await frame.waitForFunction(theme => document.documentElement.dataset.theme === theme, app.theme, { timeout });
49
52
  if (app.brand) await frame.waitForFunction(brand => document.documentElement.dataset.brand === brand, app.brand, { timeout });
53
+ // Nothing is hovered at rest: the mouse starts over whatever sits at the page's corner.
54
+ await page.mouse.move(request.viewport.width - 1, request.viewport.height - 1);
50
55
  await frame.evaluate(firstRender);
51
56
  // Before the audit touches the page: resizing below would shift it.
52
57
  partial.layoutShift = await frame.evaluate(layoutShift, { nodeLimit: request.nodeLimit });
53
58
  if (!await frame.evaluate(() => !!window.axe)) await frame.addScriptTag({ content: axe });
54
- const result = await frame.evaluate(async ({ tags, nodeLimit }) => {
55
- // Scenario content only: the preview status aside and document-level chrome are ADS-owned.
56
- // Asking for a group is what keeps its nodes: axe cuts every other group to one.
57
- const outcome = await window.axe.run({ include: [["#root"]], exclude: [["#ads-preview-status"]] }, { runOnly: { type: "tag", values: tags }, resultTypes: ["violations", "incomplete"], elementRef: false, ancestry: false });
58
- const clip = (text, size) => typeof text === "string" ? text.replace(/\s+/g, " ").trim().slice(0, size) : "";
59
- const selector = node => clip(node.target.flat().join(" "), 300), html = node => clip(node.html, 200);
60
- const group = item => ({ id: item.id, impact: item.impact, tags: item.tags, help: clip(item.help, 300), helpUrl: clip(item.helpUrl, 300), nodeCount: item.nodes.length });
61
- // axe's own key for why it could not decide, such as bgGradient or pseudoContent.
62
- const reason = node => { const check = [...node.any, ...node.all, ...node.none].find(item => item.data?.messageKey) ?? [...node.any, ...node.all, ...node.none][0]; return clip(check?.data?.messageKey ?? check?.id ?? "", 80); };
63
- return { violations: outcome.violations.map(violation => ({ ...group(violation), nodes: violation.nodes.slice(0, nodeLimit).map(node => ({ selector: selector(node), html: html(node), summary: clip(node.failureSummary, 500) })) })),
64
- incomplete: outcome.incomplete.map(item => ({ ...group(item), nodes: item.nodes.slice(0, nodeLimit).map(node => ({ selector: selector(node), html: html(node), reason: reason(node) })) })) };
65
- }, { tags: request.tags, nodeLimit: request.nodeLimit });
59
+ const result = await frame.evaluate(axeRun, { tags: request.tags, nodeLimit: request.nodeLimit });
66
60
  result.layoutShift = partial.layoutShift;
67
61
  Object.assign(partial, result);
68
62
  result.nonText = await frame.evaluate(nonTextContrast, { nodeLimit: request.nodeLimit });
@@ -72,11 +66,20 @@ try {
72
66
  await page.setViewportSize({ width, height: request.viewport.height });
73
67
  result.layout.push({ width, ...await frame.evaluate(layoutOverflow, { nodeLimit: request.nodeLimit, width }) });
74
68
  }
69
+ await auditRenderStates({ page, frame, result, request, phoneWidth: request.overflowWidths[0], measuredControls });
75
70
  // Last: it narrows #root for good, at the widest viewport, as a pane in a window would be.
76
71
  // A scenario with the main landmark is a whole page, which no pane hosts.
77
72
  if (app.container && !await frame.evaluate(() => !!document.querySelector('main, [role="main"]'))) {
78
73
  await frame.addStyleTag({ content: `#root { inline-size: ${app.container}px; }` });
79
- result.layout.push({ width: app.container, container: true, ...await frame.evaluate(layoutOverflow, { nodeLimit: request.nodeLimit, width: request.overflowWidths.at(-1), container: app.container, smallPart: request.smallPart }) });
74
+ const options = { nodeLimit: request.nodeLimit, container: app.container, smallPart: request.smallPart };
75
+ let narrowed = await frame.evaluate(layoutOverflow, { ...options, width: request.overflowWidths.at(-1) });
76
+ // What clears at the phone viewport folds on a media query, as full-width site chrome does.
77
+ if (narrowed.issues.length) {
78
+ await page.setViewportSize({ width: request.overflowWidths[0], height: request.viewport.height });
79
+ const folded = await frame.evaluate(layoutOverflow, { ...options, width: request.overflowWidths[0] });
80
+ if (!folded.issues.length) narrowed = folded;
81
+ }
82
+ result.layout.push({ width: app.container, container: true, ...narrowed });
80
83
  }
81
84
  if (await frame.locator("html").getAttribute("data-ads-preview-state") !== "ready") throw new Error(`Scenario ${app.scenario} stopped being ready during the audit.`);
82
85
  return { scenario: app.scenario, theme: app.theme, ...(app.brand ? { brand: app.brand } : {}), ...result };
@@ -43,7 +43,8 @@ export const containerWidth = 240;
43
43
  export const containerKinds = Object.freeze(["components", "patterns"]);
44
44
  /** Attempts for one render, against a dropped preview connection or a slow preview. */
45
45
  export const auditAttempts = 3;
46
- const limits = { scenarios: 500, nodes: 5, findings: 2000, reportBytes: 8 * 1024 * 1024, pages: 4 };
46
+ /** overlays and controls bound what each render opens and hovers: distinct ones, in document order. */
47
+ const limits = { scenarios: 500, nodes: 5, findings: 2000, reportBytes: 8 * 1024 * 1024, pages: 4, overlays: 3, controls: 6 };
47
48
 
48
49
  /** WCAG success criteria named by axe tags such as wcag143 or wcag1412. */
49
50
  export function wcagCriteria(tags) {
@@ -95,6 +96,7 @@ export function incompleteFindings(runs, scenarios) {
95
96
  const nonTextKinds = {
96
97
  border: { what: count => count === 1 ? "control's border is its only boundary and has" : "controls' borders are their only boundary and have", against: "the background around it", fix: "Give the boundary a border token with 3:1 against the surface it sits on, such as --border-strong, or a background with 3:1 against it." },
97
98
  icon: { what: count => count === 1 ? "icon-only control's icon has" : "icon-only controls' icons have", against: "its control's background", fix: "Paint the icon with a text or foreground token that has 3:1 against the control's background." },
99
+ focus: { what: count => count === 1 ? "control's focus outline has" : "controls' focus outlines have", against: "the background around it", fix: "Paint the focus outline with --border-focus or a token with 3:1 against the surface it sits on." },
98
100
  };
99
101
 
100
102
  /** Collapse per-brand, per-theme non-text contrast issues into ADS errors: one per scenario, kind
@@ -246,7 +248,7 @@ async function warmScenariosApart(host, ids, signal) {
246
248
  async function runAuditWorker({ root, temporary, playwright, settings, apps, signal }) {
247
249
  const request = path.join(temporary, "request.json"), report = path.join(temporary, "report.json"), runId = randomUUID();
248
250
  rmSync(report, { force: true });
249
- writeFileSync(request, JSON.stringify({ schemaVersion: 1, runId, playwright, axe: requireTool.resolve("axe-core/axe.min.js"), settings, viewport, overflowWidths, smallPart: smallPartLimitPx, tags: auditTags, nodeLimit: limits.nodes, concurrency: limits.pages, apps, output: temporary }));
251
+ writeFileSync(request, JSON.stringify({ schemaVersion: 1, runId, playwright, axe: requireTool.resolve("axe-core/axe.min.js"), settings, viewport, overflowWidths, smallPart: smallPartLimitPx, overlayLimit: limits.overlays, stateLimit: limits.controls, tags: auditTags, nodeLimit: limits.nodes, concurrency: limits.pages, apps, output: temporary }));
250
252
  const timeoutMs = Math.min(30 * 60 * 1000, settings.timeoutMs + apps.length * Math.min(settings.timeoutMs, 15000));
251
253
  let cause;
252
254
  try {
@@ -313,7 +315,7 @@ export async function runBrowserAudit(root, { scenarios: selected, themes: selec
313
315
  let host = previewHost;
314
316
  try {
315
317
  onProgress?.({ stage: "browser-audit", message: `Accessibility audit: building ${scenarios.length} scenario previews.`, elapsedMs: Date.now() - startedAt });
316
- const startHost = async () => { const { startAdsMcp } = await import("./mcp/server.mjs"); return startAdsMcp(root, { stdio: false, showcase: true }); };
318
+ const startHost = async () => { const { startAdsMcp } = await import("./mcp/server.mjs"); return startAdsMcp(root, { stdio: false, showcase: true, despitePolicy: true }); };
317
319
  if (!host?.url) host = await startHost();
318
320
  const settings = { browser: "chromium", timeoutMs: 60000, ...options.config.mcp.capture };
319
321
  const floating = floatingScenarios(options, scenarios);
@@ -354,7 +356,7 @@ export async function runBrowserAudit(root, { scenarios: selected, themes: selec
354
356
  const retries = all.filter(render => render.result && render.attempts > 1).map(({ app, attempts, causes }) => ({ scenario: app.scenario, theme: app.theme, ...(app.brand ? { brand: app.brand } : {}), attempts, causes }));
355
357
  const findings = [...auditFindings(runs, scenarios), ...nonTextContrastFindings(runs, scenarios), ...layoutOverflowFindings(runs, scenarios), ...layoutShiftFindings(runs, scenarios), ...unauditedFindings(all.filter(render => !render.result), scenarios), ...incompleteFindings(runs, scenarios)];
356
358
  const shifts = runs.filter(run => run.layoutShift).sort((a, b) => b.layoutShift.value - a.layoutShift.value);
357
- return { ...summary, ...(shifts.length ? { worstLayoutShift: { value: shifts[0].layoutShift.value, scenario: shifts[0].scenario } } : {}), runs: all.filter(render => render.result).length, incomplete: findings.filter(finding => finding.rule === INCOMPLETE_RULE).length, findings, ...(retries.length ? { retries } : {}), elapsedMs: Date.now() - startedAt };
359
+ return { ...summary, ...(shifts.length ? { worstLayoutShift: { value: shifts[0].layoutShift.value, scenario: shifts[0].scenario } } : {}), runs: all.filter(render => render.result).length, incomplete: findings.filter(finding => finding.rule === INCOMPLETE_RULE).length, overlaysOpened: runs.reduce((sum, run) => sum + (run.overlays ?? 0), 0), controlsMeasured: runs.reduce((sum, run) => sum + (run.controls ?? 0), 0), findings, ...(retries.length ? { retries } : {}), elapsedMs: Date.now() - startedAt };
358
360
  } finally {
359
361
  try { if (host !== previewHost) await host?.close(); } finally { rmSync(temporary, { recursive: true, force: true }); }
360
362
  }
@@ -5,12 +5,20 @@ import { loadConfig } from "./config.mjs";
5
5
  import { withPreviewSession } from "./preview-scope.mjs";
6
6
  import { createBunPreviewBuilder } from "./preview-bun.mjs";
7
7
  import { checkCandidate } from "./validation-checks.mjs";
8
+ import { renderStoppingRules } from "./finding-rules.mjs";
8
9
 
9
10
  /** The same ADS-owned Bun compiler serves MCP, standalone builds and CI. */
10
11
  export async function compilePreviews(directory=process.cwd(),{watched=false}={}) {
11
12
  const root=path.resolve(directory);
12
13
  const compilerFiles=[import.meta.filename,...["preview-bun.mjs","preview-imports.mjs","bun-worker.mjs"].map(file=>fileURLToPath(new URL(file,import.meta.url)))];
13
- async function validate(){const result=await checkCandidate(root);if(!result.ok)throw Object.assign(new Error("ADS project validation failed."),{diagnostics:result.diagnostics});}
14
+ async function validate(){
15
+ const result=await checkCandidate(root);
16
+ if(result.ok)return true;
17
+ // A session the audit started renders despite policy errors and reports them; it records no pass.
18
+ const stopping=process.env.ADS_PREVIEW_DESPITE_POLICY==="1"?result.diagnostics.filter(item=>renderStoppingRules.has(item.rule)):result.diagnostics;
19
+ if(stopping.length)throw Object.assign(new Error("ADS project validation failed."),{diagnostics:stopping});
20
+ return false;
21
+ }
14
22
  if(!watched){const restored=await restoreCompiledPreviews(withPreviewSession(loadConfig(root),process.env.ADS_MCP_BUILD_SESSION),compilerFiles);if(restored)return restored;}
15
23
  return runScenarioCompiler(root,{watched,compilerFiles,validate,buildGraph:createBunPreviewBuilder()});
16
24
  }
package/dist/cli.mjs CHANGED
@@ -171,11 +171,16 @@ async function main(args) {
171
171
  const controller = new AbortController(), abort = () => controller.abort();
172
172
  process.once("SIGINT", abort); process.once("SIGTERM", abort);
173
173
  try {
174
- const { routeFindings } = await import("./finding-rules.mjs");
174
+ const { renderStoppingRules, routeFindings } = await import("./finding-rules.mjs");
175
+ // Policy errors do not stop the render: they are reported with the audit's and fail it the same.
176
+ const { checkCandidate } = await import("./validation-checks.mjs");
177
+ const core = await checkCandidate(target, controller.signal);
178
+ const stopping = core.diagnostics.filter(item => renderStoppingRules.has(item.rule));
179
+ if (stopping.length) throw new Error(`Project validation failed; nothing can be rendered. ${stopping.slice(0, 5).map(item => `${item.file ?? ""}:${item.line ?? 1}: ${item.rule}: ${item.message}`).join(" ")}`);
175
180
  const audit = await runBrowserAudit(target, { scenarios: selectedScenarios, themes: theme ? [theme] : undefined, brands: brand ? [brand] : undefined, signal: controller.signal });
176
181
  // a11y-axe findings are errors, as in validation; any review-class finding stays nonblocking.
177
- const routed = routeFindings([], audit.findings);
178
- result = { ...audit, ok: !routed.diagnostics.length, findings: routed.advisories, diagnostics: routed.diagnostics };
182
+ const routed = routeFindings(core.diagnostics, audit.findings);
183
+ result = { ...audit, ok: !routed.diagnostics.length, staticErrors: core.diagnostics.length, findings: routed.advisories, diagnostics: routed.diagnostics };
179
184
  }
180
185
  finally { process.removeListener("SIGINT", abort); process.removeListener("SIGTERM", abort); }
181
186
  }
@@ -48,6 +48,12 @@ export const findingRules = Object.freeze({
48
48
  "token-overlap-review": "review",
49
49
  });
50
50
 
51
+ /** Static errors that stop a preview from rendering: a file that does not parse, a project that is
52
+ * not laid out, a scenario that cannot be registered. Everything else is policy: it fails ads check,
53
+ * validation and the audit's exit code, but the audit still renders and reports it. A broken import
54
+ * stops only the builds that reach it, which then fail as unaudited scenarios. */
55
+ export const renderStoppingRules = Object.freeze(new Set(["css-syntax", "project-structure", "scenario-contract", "source-syntax", "styles-entry"]));
56
+
51
57
  const severities = new Set(["error", "review", "info"]);
52
58
 
53
59
  /** A classified finding's severity; throws for an id missing from the registry. */
@@ -19,9 +19,10 @@ import { findingSeverity } from "./finding-rules.mjs";
19
19
  export const smallPartLimitPx = 96;
20
20
  const widthProperties = new Set(["width", "min-width", "inline-size", "min-inline-size", "flex-basis", "flex", "grid-template-columns"]);
21
21
  const fluidUnits = /^(?:%|fr|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max))$/i;
22
- /** Lengths in px; a font-relative one at the 16 px root font, as an estimate. It is still fixed. */
23
- const absoluteUnits = { px: 1, pt: 4 / 3, pc: 16, in: 96, cm: 96 / 2.54, mm: 96 / 25.4, q: 96 / 101.6 };
24
- const fontUnits = { rem: 16, em: 16, ic: 16, ch: 8, ex: 8, cap: 11, lh: 24, rlh: 24 };
22
+ /** Lengths in px. A font-relative one is estimated at the rule's font-size, or 16 px. It is still fixed. */
23
+ const absoluteUnits = { px: 1, pt: 4 / 3, pc: 16, in: 96, cm: 96 / 2.54, mm: 96 / 25.4, q: 96 / 101.6, rem: 16, rlh: 24 };
24
+ /** Per px of the element's font size, as estimates. */
25
+ const fontUnits = { em: 1, ic: 1, ch: 0.5, ex: 0.5, cap: 0.7, lh: 1.5 };
25
26
  const keywords = /^(?:auto|none|min-content|max-content|fit-content|stretch|inherit|initial|unset|revert|revert-layer|content|subgrid)$/i;
26
27
  const fluid = { low: 0, high: Infinity }, neutral = { neutral: true }, unknown = { unknown: true };
27
28
  const isLength = part => part.low !== undefined;
@@ -75,7 +76,7 @@ export function createLayoutWidths(tokens, { themes, layout }) {
75
76
  if (!unit) return number === 0 ? fixedAt(0) : { number };
76
77
  if (number === 0) return fixedAt(0);
77
78
  if (fluidUnits.test(unit)) return fluid;
78
- const size = absoluteUnits[unit] ?? fontUnits[unit];
79
+ const size = absoluteUnits[unit] ?? (fontUnits[unit] ? fontUnits[unit] * (scope.fontPx ?? 16) : undefined);
79
80
  return size ? fixedAt(number * size) : unknown;
80
81
  }
81
82
  if (node.type !== "function") return unknown;
@@ -87,8 +88,12 @@ export function createLayoutWidths(tokens, { themes, layout }) {
87
88
  if (name === "max") return largest(splitArguments(node.nodes).map(part => sequence(part, scope)));
88
89
  if (name !== "clamp") return unknown;
89
90
  const [floor, preferred, ceiling] = splitArguments(node.nodes).map(part => sequence(part, scope));
90
- if (floor?.neutral) return ceiling?.neutral || !ceiling ? preferred ?? unknown : smallest([preferred, ceiling]);
91
- return largest([floor, !ceiling || ceiling.neutral ? preferred : smallest([preferred, ceiling])]);
91
+ const value = floor?.neutral ? (ceiling?.neutral || !ceiling ? preferred ?? unknown : smallest([preferred, ceiling]))
92
+ // A preferred value that cannot be read still leaves the floor: it cannot shrink below that.
93
+ : isLength(floor) && !isLength(preferred ?? unknown) ? { low: floor.low, high: Infinity }
94
+ : largest([floor, !ceiling || ceiling.neutral ? preferred : smallest([preferred, ceiling])]);
95
+ // A resizable part: every value is a declared width, each listed for review.
96
+ return floor?.declared && preferred?.declared && ceiling?.declared ? { ...(isLength(value) ? value : neutral), declared: "clamp" } : value;
92
97
  }
93
98
  /** min(): a part that reaches zero lets the whole shrink, whatever the others are. */
94
99
  function smallest(parts) {
@@ -188,7 +193,11 @@ export function createLayoutWidths(tokens, { themes, layout }) {
188
193
  css.walkDecls(decl => {
189
194
  const property = decl.prop.toLowerCase();
190
195
  if (!widthProperties.has(property) || decl.value.includes("__ds_expression__")) return;
191
- const declared = new Set(), scope = { seen: new Set(), locals, declared }, found = judge(property, decl.value, scope);
196
+ // ch and em follow a font size set in the same rule, read through its token; an em font size is taken against 16 px.
197
+ const fontSize = decl.parent.nodes.findLast(sibling => sibling.type === "decl" && sibling.prop.toLowerCase() === "font-size");
198
+ const font = fontSize && sequence(valueParser(fontSize.value).nodes, { seen: new Set(), locals });
199
+ const fontPx = font?.low !== undefined && font.low === font.high && font.low > 0 ? font.low : undefined;
200
+ const declared = new Set(), scope = { seen: new Set(), locals, declared, fontPx }, found = judge(property, decl.value, scope);
192
201
  for (const token of declared) declaredUses.set(token, (declaredUses.get(token) ?? 0) + 1);
193
202
  if (!found) return;
194
203
  // width: 280px with max-width: 100% in the same rule is min(100%, 280px).
@@ -196,7 +205,7 @@ export function createLayoutWidths(tokens, { themes, layout }) {
196
205
  const line = offset.line + decl.source.start.line - 1, column = decl.source.start.column + (decl.source.start.line === 1 ? offset.column - 1 : 0);
197
206
  if (found.review !== undefined) {
198
207
  findings.push({ rule: "layout-width-noop", severity: findingSeverity("layout-width-noop"), file, line, column, property, value: decl.value, guidanceUri: "ads://guides/tokens",
199
- message: `${file}:${line} sets ${property}: ${decl.value}. It never exceeds ${found.review}px, within the ${smallPartLimitPx}px a small part may use plainly, so the fluid part does nothing. Write the plain size.` });
208
+ message: `${file}:${line} sets ${property}: ${decl.value}. It never exceeds ${found.review}px, within the ${smallPartLimitPx}px a small part may use plainly, so it does not protect against overflow, and a plain size is clearer. In a flex or grid parent the percentage can still affect wrapping, so compare the scenario after changing it.` });
200
209
  return;
201
210
  }
202
211
  findings.push({ rule: "layout-fixed-width", severity: findingSeverity("layout-fixed-width"), file, line, column, property, value: decl.value, guidanceUri: "ads://guides/tokens",
@@ -16,7 +16,7 @@ function stamp(file) {
16
16
  }
17
17
 
18
18
  /** One project-owned compiler process, shared by all protocol instances. */
19
- export function createPreviewWatch(root, config, { log = process.stderr, buildTimeout = 30000, prewarm = false } = {}) {
19
+ export function createPreviewWatch(root, config, { log = process.stderr, buildTimeout = 30000, prewarm = false, despitePolicy = false } = {}) {
20
20
  config = { ...config, apps: [...config.apps] };
21
21
  const command = config.previewWatch;
22
22
  let session = randomUUID();
@@ -77,7 +77,7 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
77
77
  // No shell: configured arguments remain literal. Child stdin cannot consume
78
78
  // the MCP channel, and both output streams go exclusively to diagnostics.
79
79
  const executable = developmentExecutable(command.command);
80
- const env = { ...process.env, ADS_MCP_BUILD_SESSION: session, ADS_MCP_BUILD_STATUS: reportFile, ADS_MCP_REQUEST_FILE: requestFile, ADS_MCP_PREWARM_VIEWS: prewarm ? "1" : "0", PATH: [path.join(root, "node_modules/.bin"), path.dirname(process.execPath), process.env.PATH ?? ""].join(path.delimiter) };
80
+ const env = { ...process.env, ADS_MCP_BUILD_SESSION: session, ADS_MCP_BUILD_STATUS: reportFile, ADS_MCP_REQUEST_FILE: requestFile, ADS_MCP_PREWARM_VIEWS: prewarm ? "1" : "0", ADS_PREVIEW_DESPITE_POLICY: despitePolicy ? "1" : "0", PATH: [path.join(root, "node_modules/.bin"), path.dirname(process.execPath), process.env.PATH ?? ""].join(path.delimiter) };
81
81
  try {
82
82
  child = spawn(executable, command.args, { cwd: root, env, shell: false, detached: process.platform !== "win32", stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
83
83
  } catch (failure) {
@@ -786,14 +786,14 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
786
786
  return { server, refresh, warmScenarios, buildAll(signal, options) { previewWatch.setApps(allApps()); return previewWatch.buildAll(signal, options); }, readResource:read, async callTool(name,args,signal){const tool=tools().find(tool=>tool.name===name);if(!tool)throw new Error("Unknown preview tool.");return tool.call(tool.schema.parse(args),signal);}, async close() { executionObservers.delete(executionChanged);stopObservation(); if (!inspection) { await coordinator.close(); await cache.registryInspector?.close(); await drafts.close(); await validation.close(); await verification.close(); await captures.close(); } await server.close(); } };
787
787
  }
788
788
 
789
- export async function startAdsMcp(directory = process.cwd(), { stdio = true, showcase = true, port = 0, mutations = false, previewWork = createPreviewWork(), previewBuildTimeoutMs = 30000, prewarm = stdio } = {}) {
789
+ export async function startAdsMcp(directory = process.cwd(), { stdio = true, despitePolicy = false, showcase = true, port = 0, mutations = false, previewWork = createPreviewWork(), previewBuildTimeoutMs = 30000, prewarm = stdio } = {}) {
790
790
  if (process.versions.bun) assertBunRuntime();
791
791
  // Fail before opening the transport for configuration/distribution errors.
792
792
  const { root, config } = loadConfig(directory);
793
793
  // The generated theme sheet follows the token sheets and ds.config.json from startup on.
794
794
  const themesWatch = watchThemesCss(root, { log: message => process.stderr.write(`${message}\n`) });
795
795
  const inspection = { skills: createSkillStore(), previewWork };
796
- const previewWatch = createReconfigurablePreviewWatch(root, config.mcp, {buildTimeout:previewBuildTimeoutMs,prewarm});
796
+ const previewWatch = createReconfigurablePreviewWatch(root, config.mcp, {buildTimeout:previewBuildTimeoutMs,prewarm,despitePolicy});
797
797
  let host, api;
798
798
  let buildWatcher, buildChangeTimer;
799
799
  const buildListeners = new Set();
@@ -76,7 +76,10 @@ function resourceUris(prepared) {
76
76
  node.dependencies.map(file => { const child = nodes.get(file); return [file, child.group === group ? null : fingerprint(child.group)]; }),
77
77
  ])));
78
78
  }
79
- return new Map([...nodes].map(([file, node]) => [file, `ads://assets/${hash("ads-preview-v3\n" + file + "\n" + fingerprint(node.group))}.${file.split(".").pop()}`]));
79
+ // A file with nothing rewritten in it is named by its bytes, so a font a stylesheet and a preload
80
+ // both reach, through different build paths, is one resource and one download.
81
+ const leaf = (file, node) => !node.dependencies.length && !/\.(?:[cm]?js|css|map)$/.test(file);
82
+ return new Map([...nodes].map(([file, node]) => [file, `ads://assets/${hash("ads-preview-v3\n" + (leaf(file, node) ? `asset\n${node.digest}` : `${file}\n${fingerprint(node.group)}`))}.${file.split(".").pop()}`]));
80
83
  }
81
84
 
82
85
  /** Convert compiler output to registered MCP resources without evaluating project code. */
@@ -282,9 +282,9 @@ export async function runScenarioCompiler(directory, { watched = false, validate
282
282
  function gate(stamp) {
283
283
  if (isDraftPreviewWorkspace(root)) return Promise.resolve();
284
284
  if (cache.validated(stamp)) return Promise.resolve();
285
- return validation ??= Promise.resolve().then(validate).then(() => {
285
+ return validation ??= Promise.resolve().then(validate).then(valid => {
286
286
  if (stamp !== cache.inputs()) throw new Error("Sources changed during preview validation. Waiting for the current build.");
287
- cache.validate(stamp);
287
+ if (valid !== false) cache.validate(stamp);
288
288
  }).catch(error=>{throw scopedPreviewFailure(error,"project","validation");});
289
289
  }
290
290
  async function checkedBuild(stamp, build) {
@@ -167,19 +167,26 @@ When it fires, pick the fix by what the element is:
167
167
  | A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
168
168
  | A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
169
169
  | A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
170
+ | A resizable part | A `clamp()` of three such tokens; a runtime variable needs a declared fallback: `clamp(var(--pane-min), var(--ux-pane, var(--pane)), var(--pane-max))` |
170
171
  | An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
171
172
 
172
173
  These do not fix it:
173
174
 
174
175
  - Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
176
+ `ch` and `em` are measured at the rule's `font-size`, or 16 px.
175
177
  - `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
176
178
  their fixed part.
177
- - `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
179
+ - `min(100%, 64px)` around a small part. `layout-width-noop` asks for the plain size; in a flex or
180
+ grid parent the percentage can affect wrapping, so compare the scenario after changing it.
178
181
  - A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
179
182
 
180
183
  `ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
181
184
  per-declaration exception.
182
185
 
186
+ `ads audit` opens each control with `aria-haspopup` and measures what opens, hovers and focuses
187
+ controls for contrast, and checks a control with `aria-busy="true"`. So give overlay triggers
188
+ `aria-haspopup`, or render the overlay open in its scenario, and render a busy example.
189
+
183
190
  `layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
184
191
  horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
185
192
  scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
@@ -167,19 +167,26 @@ When it fires, pick the fix by what the element is:
167
167
  | A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
168
168
  | A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
169
169
  | A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
170
+ | A resizable part | A `clamp()` of three such tokens; a runtime variable needs a declared fallback: `clamp(var(--pane-min), var(--ux-pane, var(--pane)), var(--pane-max))` |
170
171
  | An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
171
172
 
172
173
  These do not fix it:
173
174
 
174
175
  - Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
176
+ `ch` and `em` are measured at the rule's `font-size`, or 16 px.
175
177
  - `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
176
178
  their fixed part.
177
- - `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
179
+ - `min(100%, 64px)` around a small part. `layout-width-noop` asks for the plain size; in a flex or
180
+ grid parent the percentage can affect wrapping, so compare the scenario after changing it.
178
181
  - A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
179
182
 
180
183
  `ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
181
184
  per-declaration exception.
182
185
 
186
+ `ads audit` opens each control with `aria-haspopup` and measures what opens, hovers and focuses
187
+ controls for contrast, and checks a control with `aria-busy="true"`. So give overlay triggers
188
+ `aria-haspopup`, or render the overlay open in its scenario, and render a busy example.
189
+
183
190
  `layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
184
191
  horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
185
192
  scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
@@ -167,19 +167,26 @@ When it fires, pick the fix by what the element is:
167
167
  | A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
168
168
  | A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
169
169
  | A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
170
+ | A resizable part | A `clamp()` of three such tokens; a runtime variable needs a declared fallback: `clamp(var(--pane-min), var(--ux-pane, var(--pane)), var(--pane-max))` |
170
171
  | An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
171
172
 
172
173
  These do not fix it:
173
174
 
174
175
  - Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
176
+ `ch` and `em` are measured at the rule's `font-size`, or 16 px.
175
177
  - `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
176
178
  their fixed part.
177
- - `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
179
+ - `min(100%, 64px)` around a small part. `layout-width-noop` asks for the plain size; in a flex or
180
+ grid parent the percentage can affect wrapping, so compare the scenario after changing it.
178
181
  - A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
179
182
 
180
183
  `ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
181
184
  per-declaration exception.
182
185
 
186
+ `ads audit` opens each control with `aria-haspopup` and measures what opens, hovers and focuses
187
+ controls for contrast, and checks a control with `aria-busy="true"`. So give overlay triggers
188
+ `aria-haspopup`, or render the overlay open in its scenario, and render a busy example.
189
+
183
190
  `layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
184
191
  horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
185
192
  scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
@@ -167,19 +167,26 @@ When it fires, pick the fix by what the element is:
167
167
  | A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
168
168
  | A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
169
169
  | A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
170
+ | A resizable part | A `clamp()` of three such tokens; a runtime variable needs a declared fallback: `clamp(var(--pane-min), var(--ux-pane, var(--pane)), var(--pane-max))` |
170
171
  | An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
171
172
 
172
173
  These do not fix it:
173
174
 
174
175
  - Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
176
+ `ch` and `em` are measured at the rule's `font-size`, or 16 px.
175
177
  - `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
176
178
  their fixed part.
177
- - `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
179
+ - `min(100%, 64px)` around a small part. `layout-width-noop` asks for the plain size; in a flex or
180
+ grid parent the percentage can affect wrapping, so compare the scenario after changing it.
178
181
  - A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
179
182
 
180
183
  `ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
181
184
  per-declaration exception.
182
185
 
186
+ `ads audit` opens each control with `aria-haspopup` and measures what opens, hovers and focuses
187
+ controls for contrast, and checks a control with `aria-busy="true"`. So give overlay triggers
188
+ `aria-haspopup`, or render the overlay open in its scenario, and render a busy example.
189
+
183
190
  `layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
184
191
  horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
185
192
  scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
@@ -167,19 +167,26 @@ When it fires, pick the fix by what the element is:
167
167
  | A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
168
168
  | A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
169
169
  | A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
170
+ | A resizable part | A `clamp()` of three such tokens; a runtime variable needs a declared fallback: `clamp(var(--pane-min), var(--ux-pane, var(--pane)), var(--pane-max))` |
170
171
  | An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
171
172
 
172
173
  These do not fix it:
173
174
 
174
175
  - Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
176
+ `ch` and `em` are measured at the rule's `font-size`, or 16 px.
175
177
  - `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
176
178
  their fixed part.
177
- - `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
179
+ - `min(100%, 64px)` around a small part. `layout-width-noop` asks for the plain size; in a flex or
180
+ grid parent the percentage can affect wrapping, so compare the scenario after changing it.
178
181
  - A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
179
182
 
180
183
  `ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
181
184
  per-declaration exception.
182
185
 
186
+ `ads audit` opens each control with `aria-haspopup` and measures what opens, hovers and focuses
187
+ controls for contrast, and checks a control with `aria-busy="true"`. So give overlay triggers
188
+ `aria-haspopup`, or render the overlay open in its scenario, and render a busy example.
189
+
183
190
  `layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
184
191
  horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
185
192
  scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
package/docs/CHANGELOG.md CHANGED
@@ -1,34 +1,68 @@
1
1
  # Changelog
2
2
 
3
- ## 0.3.51
3
+ ## 0.3.52
4
4
 
5
5
  <!-- ads-local-tests:start -->
6
- Local verification: **761/761 passed** with `ADS_TEST_BUN=1 npm test`.
7
- Tested commit: `cae074c849f112f2fdc8990f8c031ad8f78f9067`; Node v24.13.0, Bun 1.4.1.
8
- Completed 2026-11-02T11:24:28.751Z (1176 seconds).
6
+ Local verification: **770/770 passed** with `ADS_TEST_BUN=1 npm test`.
7
+ Tested commit: `adeddf07a52742b7c59489af892386db40d2cffa`; Node v24.13.0, Bun 1.4.1.
8
+ Completed 2026-11-02T14:52:08.397Z (1076 seconds).
9
9
 
10
10
  <!-- ads-local-test-proof
11
11
  {
12
12
  "schema": 1,
13
- "version": "0.3.51",
14
- "commit": "cae074c849f112f2fdc8990f8c031ad8f78f9067",
15
- "sourceSha256": "c849cba78c92ca5eb0383308ff7f15f012a5f8dad6ddd49e2e9ce644041e85b6",
13
+ "version": "0.3.52",
14
+ "commit": "adeddf07a52742b7c59489af892386db40d2cffa",
15
+ "sourceSha256": "50d65df97db4e4f86ab1f1973d7ec5fa0d5fb80facece575484116781df60e6c",
16
16
  "command": "ADS_TEST_BUN=1 npm test",
17
17
  "result": "pass",
18
- "tests": 761,
19
- "pass": 761,
18
+ "tests": 770,
19
+ "pass": 770,
20
20
  "fail": 0,
21
21
  "cancelled": 0,
22
22
  "skipped": 0,
23
23
  "node": "v24.13.0",
24
24
  "bun": "1.4.1",
25
- "completedAt": "2026-11-02T11:24:28.751Z",
26
- "durationMs": 1175664,
27
- "logSha256": "5042dab0442851693b09d13d7068acaaa84d62ddff3f169ecbda29af3df988f2"
25
+ "completedAt": "2026-11-02T14:52:08.397Z",
26
+ "durationMs": 1075944,
27
+ "logSha256": "b4c0f94cc4bfca21785e7f71b1042daa23d922a0ab5e0056b575e06054e83ba7"
28
28
  }
29
29
  -->
30
30
  <!-- ads-local-tests:end -->
31
31
 
32
+ - **The audit opens overlays.** It clicks each distinct `aria-haspopup` control, up to 3 per render,
33
+ and runs axe, non-text contrast and a phone-width check on what opens, in every theme. An overlay a
34
+ scenario renders open is measured the same way. Results name the state, such as
35
+ `open overlay "Edit": button`. New `overlaysOpened` in the audit result.
36
+ - **The audit measures hover, keyboard focus and busy.** Up to 6 distinct controls per render are
37
+ hovered and focused: axe `color-contrast` and non-text contrast under hover, and a focus outline at
38
+ 3:1 against what is around it (`a11y-non-text-contrast`, kind `focus`). What already fails at rest
39
+ is not repeated. A control with `aria-busy="true"` is checked even when disabled, and its spinner
40
+ even when it has text, if the scenario renders it busy. New `controlsMeasured` in the result.
41
+ - **Nothing is hovered at rest.** The audit parks the mouse first: an element at the page's corner
42
+ was measured in its hover state.
43
+ - **A font preloaded in a preview is one download.** The Bun preview compiler named one file twice
44
+ when a stylesheet and a `?url` import both reached it. Files with nothing rewritten in them are now
45
+ named by their bytes.
46
+ - **`layout-overflow-narrow` leaves out what folds on a viewport query.** A finding that clears at the
47
+ phone viewport, still in the 240 px container, is site chrome that responds to the window.
48
+ - **The viewport overflow check sees inside a preview frame.** The outermost box as tall as the window no
49
+ longer counts as an intended scroller or clip, so `overflow-y: auto` on a project's frame stops
50
+ exempting everything in it. This can surface new `layout-overflow` errors on upgrade.
51
+ - **`ch` and `em` follow the rule's font size.** `layout-fixed-width` measures them at a `font-size`
52
+ set in the same rule, through its token. Otherwise it stays at 16 px.
53
+ - **A resizable part has a route.** `layout-fixed-width` accepts a `clamp()` whose three values are
54
+ all `layout.widthTokens` tokens, also through a local variable, and each stays listed for review. A
55
+ runtime variable there needs a declared fallback. With no fallback, the clamp's floor is measured.
56
+ - **`layout-width-noop` is more careful.** It says the value does not protect against overflow and a
57
+ plain size is clearer, and to compare the scenario after changing it, since the percentage can
58
+ affect wrapping in a flex or grid parent.
59
+ - **Policy errors no longer stop `ads audit`.** It renders every scenario and reports them with its
60
+ own findings, and exits 1. Only errors that stop rendering block it: `source-syntax`, `css-syntax`,
61
+ `project-structure`, `styles-entry`, `scenario-contract`. `ads check`, `ads compile` and
62
+ `ads validate` are unchanged, and the audit's result gains `staticErrors`.
63
+
64
+ ## 0.3.51
65
+
32
66
  - **The audit lists what axe could not decide.** New `a11y-incomplete` info item, one per scenario,
33
67
  axe rule and element set, with the elements and axe's reason, such as `bgGradient`: check it by
34
68
  hand. It fails nothing. `incomplete` in the audit result now counts these items, and the text
package/docs/GUIDE.md CHANGED
@@ -596,14 +596,14 @@ so what counts is whether it can shrink.
596
596
  | Value | Result |
597
597
  |---|---|
598
598
  | 96 px or less, in any unit, raw, through a token or by arithmetic: `64px`, `12ch`, `var(--control-height-lg)` | Pass: a small part may use a plain size |
599
- | Fixed above 96 px, in any unit: `280px`, `32.5ch`, `20rem`, `var(--space-80)`, `calc(var(--space-32) * 10)` | Error. `ch`, `em`, `ex`, `lh` and `rem` are fixed lengths, estimated at a 16 px font |
599
+ | Fixed above 96 px, in any unit: `280px`, `32.5ch`, `20rem`, `var(--space-80)`, `calc(var(--space-32) * 10)` | Error. `ch`, `em`, `ex`, `lh` and `rem` are fixed lengths, estimated at the same rule's `font-size`, or 16 px |
600
600
  | Unable to shrink below 96 px: `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`, a `minmax(200px, 1fr)` track | Error |
601
601
  | Able to shrink: `min(100%, 280px)`, `calc(100% - 200px)`, `50cqi`, a `minmax(0, 280px)` track, `width: 280px` with `max-width: 100%` in the same rule | Pass |
602
602
  | A flex item that grows and shrinks: `flex: 1 1 280px` | Pass |
603
603
  | A track repeated with `auto-fill` or `auto-fit`: `repeat(auto-fit, minmax(200px, 1fr))` | Pass: it wraps |
604
604
  | `%`, `fr`, viewport and container units, `auto`, `min-content`, `max-content`, `fit-content` | Pass |
605
605
  | `max-width`, `max-inline-size`, in any unit: `max-width: 1400px` | Not read: a maximum cannot force overflow |
606
- | A token named by `layout.widthTokens`, used plainly | Pass, and listed for review when it is fixed |
606
+ | A token named by `layout.widthTokens`, used plainly, or a `clamp()` whose three values all are, such as a resizable pane: `clamp(var(--pane-min), var(--ux-pane, var(--pane)), var(--pane-max))` | Pass, and each is listed for review when it is fixed. A runtime variable there needs a declared fallback |
607
607
  | A variable with no definition ADS can read: `var(--set-at-runtime)` | Pass: `layout-overflow` renders it |
608
608
 
609
609
  No token name is exempt: `var(--side-pane-width)` is 280 px whatever it is called.
@@ -631,8 +631,9 @@ The fix depends on the part:
631
631
 
632
632
  `layout-declared-width` is a review item for each fixed `widthTokens` token, with how many widths
633
633
  use it, and for each `fixedWidthUnits` file that sets a fixed width. `layout-width-noop` is a
634
- review item for a `min()` or `clamp()` that never exceeds 96 px, such as `min(100%, 64px)`: write
635
- the plain size. An entry that matches no token, unit or file is a `layout-config` error, and an
634
+ review item for a `min()` or `clamp()` that never exceeds 96 px, such as `min(100%, 64px)`. It does
635
+ not protect against overflow and a plain size is clearer, but in a flex or grid parent the percentage
636
+ can affect wrapping, so compare the scenario after changing it. An entry that matches no token, unit or file is a `layout-config` error, and an
636
637
  entry cannot name every token or unit.
637
638
 
638
639
  `layout-overflow` (browser audit) resizes each rendered scenario, in every theme and brand, to
@@ -642,12 +643,27 @@ entry cannot name every token or unit.
642
643
  - An element reaches past the viewport's edge; the outermost such element is named.
643
644
  - An element with `overflow-x: hidden` or `clip` cuts off content more than 4 px wider.
644
645
 
645
- Exempt: `overflow-x: auto` or `scroll` scrollers and their content, `text-overflow: ellipsis`,
646
- carousels (`aria-roledescription="carousel"`), native text fields, fixed-position layers and visually hidden content.
646
+ Exempt: `overflow-x: auto` or `scroll` scrollers and their content, except the outermost one as tall as the window, which is the page or a preview frame; `text-overflow: ellipsis`,
647
+ carousels (`aria-roledescription="carousel"`), pannable widgets (`role="application"`), native text fields, fixed-position layers and visually hidden content.
647
648
 
648
649
  Each measurement waits for layout to stop moving, so a component that refits after a resize is
649
650
  measured after it refits.
650
651
 
652
+ The audit also renders what a scenario shows after someone acts on it, in every theme and brand.
653
+ Findings name the state in the selector, such as `open overlay "Edit": button` or `hover: button`.
654
+
655
+ - **Overlays.** It clicks each distinct control with `aria-haspopup`, up to 3 per render, once per
656
+ theme and brand across the audit. What opens
657
+ (`dialog`, `alertdialog`, `menu`, `listbox` roles, an open `<dialog>` or popover) gets axe, non-text
658
+ contrast, and must fit the 390 px viewport. Give a trigger `aria-haspopup`, or render the overlay
659
+ open in its scenario. Tooltips are not opened.
660
+ - **Hover and focus.** Up to 6 controls per render, in document order, each distinct control once per
661
+ theme and brand on the same surface. Under hover it runs axe
662
+ `color-contrast` and the non-text check. A `:focus-visible` outline needs 3:1 against what is around
663
+ it. A focus ring drawn with `box-shadow` is not read, and an outline beside one is left alone.
664
+ - **Busy.** A control with `aria-busy="true"` is checked even when disabled, and its icon even when it
665
+ has text. Render the busy state in the scenario: the audit does not press buttons to reach it.
666
+
651
667
  It also renders each component and pattern scenario with its container narrowed to 240 px, inside
652
668
  the 1280 px viewport, once per brand, to show what would not fit a side pane. These are
653
669
  `layout-overflow-narrow` review items: fix the part if it can sit in a pane, or change a scenario's
@@ -658,6 +674,8 @@ demo frame to a maximum.
658
674
  by its content, or by parts of 96 px or less, is not reported.
659
675
  - Not rendered this way: compositions, scenarios with a `main` landmark, which are pages, and owners
660
676
  in `layout.fixedWidthUnits`, which float above the layout.
677
+ - A finding that clears at the 390 px viewport, still in the 240 px container, is left out: it folds
678
+ on a viewport media query, such as a full-width site header.
661
679
 
662
680
  **Web performance.** MCP serves this as `ads://guides/performance`.
663
681
 
@@ -967,7 +985,13 @@ preview, and its **Icons** tab shows the glyph set: every glyph at the size used
967
985
  text, each one on its grid at every `--icon-*` size with its aliases and glyph errors, and
968
986
  each file in `assets/logos/` as it is, on a white and a black tile.
969
987
 
970
- `ads audit` adds a rendered check: axe-core (WCAG A/AA rules) in every component, pattern
988
+ `ads audit` runs `ads check` first. A policy error such as `layout-fixed-width` or `img-attributes`
989
+ does not stop it: it renders every scenario and reports those errors with its own, and exits 1. Only
990
+ an error that stops rendering blocks it (`source-syntax`, `css-syntax`, `project-structure`,
991
+ `styles-entry`, `scenario-contract`); a broken import fails the scenarios that reach it. `ads check`,
992
+ `ads compile` and `ads validate` stop on every error, as before.
993
+
994
+ It adds a rendered check: axe-core (WCAG A/AA rules) in every component, pattern
971
995
  and composition scenario, once per declared brand and theme (`--scenario`, `--theme` and
972
996
  `--brand` narrow it). Each violation is an `a11y-axe` error naming the axe rule, WCAG
973
997
  criterion, themes and brands, failing elements and help link, and `ads audit` exits 1. It
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reqvire-org/ads",
3
- "version": "0.3.51",
3
+ "version": "0.3.52",
4
4
  "type": "module",
5
5
  "description": "A design system your agent can see and shape. Your components. Your look. Your code.",
6
6
  "repository": {