@reqvire-org/ads 0.3.50 → 0.3.51

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.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/dist/browser-audit/first-render.mjs +18 -0
  3. package/dist/browser-audit/layout-overflow.mjs +80 -39
  4. package/dist/browser-audit/worker.mjs +16 -8
  5. package/dist/browser-audit.mjs +52 -11
  6. package/dist/capture/worker.mjs +2 -5
  7. package/dist/check.mjs +5 -3
  8. package/dist/cli.mjs +3 -2
  9. package/dist/config.mjs +2 -2
  10. package/dist/finding-rules.mjs +5 -0
  11. package/dist/layout-widths.mjs +123 -79
  12. package/dist/skills/ads-break-ui/SKILL.md +2 -1
  13. package/dist/skills/ads-break-ui/references/design-data.md +27 -14
  14. package/dist/skills/ads-break-ui/references/validation.md +1 -1
  15. package/dist/skills/ads-designer/SKILL.md +6 -4
  16. package/dist/skills/ads-designer/references/design-data.md +27 -14
  17. package/dist/skills/ads-designer/references/validation.md +1 -1
  18. package/dist/skills/ads-import/references/design-data.md +27 -14
  19. package/dist/skills/ads-import/references/validation.md +1 -1
  20. package/dist/skills/ads-motion/references/design-data.md +27 -14
  21. package/dist/skills/ads-motion/references/validation.md +1 -1
  22. package/dist/skills/ads-port/references/design-data.md +27 -14
  23. package/dist/skills/ads-port/references/validation.md +1 -1
  24. package/dist/starters/preact/ds.config.json +0 -1
  25. package/dist/starters/react/README.md +6 -4
  26. package/dist/starters/react/design-system/components/Content/Image/Image.tsx +7 -4
  27. package/dist/starters/react/design-system/components/Content/Image/README.md +2 -2
  28. package/dist/starters/react/design-system/tokens/spacing.css +1 -1
  29. package/dist/starters/react/ds.config.json +0 -1
  30. package/docs/ADS.md +2 -2
  31. package/docs/ARCHITECTURE.md +9 -6
  32. package/docs/CHANGELOG.md +47 -12
  33. package/docs/GUIDE.md +50 -20
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -78,7 +78,7 @@ There is no warning level.
78
78
  | **Rendered accessibility** | `ads audit` runs axe-core (WCAG 2.2 AA rules) in every rendered UI scenario, once per theme and brand, plus ADS's own non-text contrast check (WCAG 1.4.11, which axe does not cover): a field or other control without its own text or icon, whose border is its only boundary, needs that border at 3:1 against the background around it, and an icon-only control needs its icon at 3:1 against its background. The audit gates `ads validate` by default, and MCP draft acceptance and guarded patches audit the candidate's affected scenarios (all of them after configuration, foundation, token or asset changes); `browserAudit: false` in a policy turns it off. It needs the project's Playwright and browser (`npx playwright install chromium`); without them the policy fails and names what to install. |
79
79
  | **Static accessibility** | Focus styles, icon-only labels, image alt text, reduced motion, target size, text resize and text spacing are checked from source and tokens, without a browser. |
80
80
  | **Contrast** | `token-contrast` checks the role pairs that meet on screen (text on surfaces, fills with their foreground, status text on tints, focus indicators and control borders) in every theme and brand. `component-contrast` checks the pairs components and patterns make themselves: a style block (including a nested state such as `&:hover` or `&[aria-selected="true"]`) that sets both `color` and `background` to tokens, such as a status color as text on its own tint. Both resolve every CSS color syntax, including `oklch()` and `color-mix()`, and composite translucent fills over the canvas. Text needs 4.5:1; focus indicators and control borders need 3:1; disabled states are exempt. |
81
- | **Layout** | Widths are fluid on the grid. `layout-fixed-width` fails a width, `max-width`, `flex-basis` or grid track fixed above 48 px, whether raw, from a token or by arithmetic on spacing tokens; `%`, `fr`, `ch` measures and declared `layout.widthTokens` pass. `layout-overflow` renders every UI scenario at 390, 768 and 1280 px and fails on horizontal page overflow and clipped content; scrollers and ellipsis are exempt. |
81
+ | **Layout** | Widths are fluid on the grid. `layout-fixed-width` fails a width, `flex-basis` or grid track that cannot shrink below 96 px, in any unit, whether raw, from a token or by arithmetic; small parts use plain sizes, `min(100%, 280px)` and `%` shrink, a maximum is not read, and widths declared in `layout.widthTokens` pass and are listed for review. `layout-overflow` renders every UI scenario at 390, 768 and 1280 px and fails on horizontal page overflow and clipped content, and renders components and patterns in a 240 px container, where a set width above 96 px must fit; scrollers and ellipsis are exempt. |
82
82
  | **Web performance** | `img-attributes` fails a raw `<img>` without dimensions or a `loading` choice, and a `srcset` with width descriptors and no `sizes`; `asset-image-budget` fails oversized images in `assets/` (SVG 100 KB, WebP and AVIF 300 KB, JPEG 400 KB, PNG and GIF 500 KB, or `assets.imageBudgetKb`); `layout-shift` fails a rendered scenario above 0.1. `ads assets` generates preloads for the fonts the first text uses, on the URLs the stylesheet requests. Page metadata, sitemaps, hosting and Lighthouse stay with the application. |
83
83
  | **Themes and brands** | One mechanism: per-theme halves (`--x-light`, `--x-dark`) and brands on `[data-brand]`. `ads assets` generates `themes.generated.css` and `.ts`; missing or conflicting halves, empty themes, stale generated files, `light-dark()` and ancestor theme selectors are errors. |
84
84
  | **Tokens** | Ownership, naming, rhythm, missing and scenario references; equal values in different roles are flagged for review. |
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Waits for a rendered scenario's first render: its fonts, the images it is loading, and two frames.
3
+ * A lazy image outside the viewport or not rendered has not started loading, and decode() on it
4
+ * never settles, so it is not waited on. It cannot shift the first view either: the browser scores
5
+ * only movement inside the viewport. One overall limit stops a slow file from holding the audit up;
6
+ * what arrives after it is simply not measured.
7
+ * It must stay self-contained: Playwright serializes the function into the page.
8
+ */
9
+ export async function firstRender() {
10
+ const started = image => {
11
+ if (image.loading !== "lazy") return true;
12
+ const box = image.getBoundingClientRect();
13
+ return image.checkVisibility() && box.bottom >= 0 && box.right >= 0 && box.top <= window.innerHeight && box.left <= window.innerWidth;
14
+ };
15
+ const ready = Promise.all([document.fonts.ready, ...[...document.images].filter(started).map(image => image.decode().catch(() => {}))]);
16
+ await Promise.race([ready, new Promise(resolve => setTimeout(resolve, 5000))]);
17
+ await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
18
+ }
@@ -1,57 +1,98 @@
1
1
  /**
2
- * ADS's rendered layout check, run in the scenario document once per audited viewport width.
2
+ * ADS's rendered layout check, run in the scenario document once per audited viewport width, and
3
+ * once with #root narrowed to `container` px wide by the worker, as a pane would.
3
4
  * It must stay self-contained: Playwright serializes the function into the page.
4
5
  *
5
6
  * - "document": the scenario document scrolls horizontally (scrollWidth > clientWidth).
6
7
  * - "viewport": an element in #root reaches past the viewport's inline edges while its parent
7
8
  * does not, the element that pushes content out.
9
+ * - "container": the same, past the edges of the narrowed #root. In this render, "container" and
10
+ * "clipped" need a width that forces it: the element or something in it has a fixed width above
11
+ * a small part's limit. A row of buttons that is simply too long for a pane is not reported.
8
12
  * - "clipped": an element with overflow-x hidden or clip whose content is more than 4 px wider
9
13
  * than its box, so content is cut off (a small negative margin cuts nothing).
10
14
  * Intended scrollers (overflow-x auto or scroll) and their content, text-overflow: ellipsis,
11
15
  * carousels (aria-roledescription="carousel"),
12
16
  * native text fields, visually hidden content (a box of 1 px or less, clip or clip-path) and
13
17
  * fixed-position layers are exempt.
18
+ *
19
+ * A resize reaches the frame a frame later, and a component that refits through ResizeObserver and
20
+ * requestAnimationFrame refits later still. So layout is measured once it has stopped moving for a
21
+ * few frames, bounded for a page that never stops. A page that looks wrong gets more frames, for a
22
+ * refit on a timer: only a change in layout can clear what was found.
14
23
  */
15
- export async function layoutOverflow({ nodeLimit, width: expected }) {
16
- // The resized frame lays out on its next frames.
17
- await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
18
- if (window.innerWidth !== expected) throw new Error(`The scenario document is ${window.innerWidth} px wide, not the audited ${expected} px.`);
24
+ export async function layoutOverflow({ nodeLimit, width: expected, container, smallPart }) {
19
25
  const root = document.querySelector("#root");
20
- if (!root) return { issues: [], counts: {} };
21
- const width = document.documentElement.clientWidth, issues = [], counts = { document: 0, viewport: 0, clipped: 0 };
22
- const selector = element => {
23
- const parts = [];
24
- for (let node = element; node && node !== root; node = node.parentElement) {
25
- const siblings = [...node.parentElement.children].filter(child => child.localName === node.localName);
26
- parts.unshift(`${node.localName}${siblings.length > 1 ? `:nth-of-type(${siblings.indexOf(node) + 1})` : ""}`);
26
+ // A frame, or a time limit for a document that has stopped getting frames.
27
+ const nextFrame = () => new Promise(resolve => { const limit = setTimeout(resolve, 500); requestAnimationFrame(() => { clearTimeout(limit); resolve(); }); });
28
+ // Layout boxes only: a transform, such as a spinner's, is not layout moving.
29
+ const layout = () => { let sum = document.documentElement.scrollWidth; for (const element of root?.querySelectorAll("*") ?? []) if (element.offsetWidth !== undefined) sum = (sum * 31 + element.offsetWidth * 7 + element.offsetLeft) | 0; return sum; };
30
+ async function settled() {
31
+ let previous, quiet = 0;
32
+ for (let count = 0; count < 20 && (quiet < 2 || window.innerWidth !== expected); count++) {
33
+ await nextFrame();
34
+ const current = layout();
35
+ quiet = current === previous ? quiet + 1 : 0;
36
+ previous = current;
27
37
  }
28
- return ["#root", ...parts].join(" > ");
29
- };
30
- const report = (kind, element, detail) => { if (counts[kind]++ < nodeLimit) issues.push({ kind, selector: element === document.documentElement ? "html" : selector(element).slice(0, 300), html: element === document.documentElement ? "" : element.outerHTML.replace(/\s+/g, " ").slice(0, 200), ...detail }); };
31
- if (document.documentElement.scrollWidth > width + 1) report("document", document.documentElement, { overflow: document.documentElement.scrollWidth - width });
32
- const exempt = new Map();
33
- /** Whether an element is inside an intended scroller, a fixed layer or hidden content. */
34
- function excluded(element) {
35
- if (!element || element === root) return false;
36
- if (exempt.has(element)) return exempt.get(element);
37
- const style = getComputedStyle(element), box = element.getBoundingClientRect();
38
- const value = /^(?:auto|scroll)$/.test(style.overflowX) || style.position === "fixed" || style.clip !== "auto" && style.position === "absolute" || style.clipPath !== "none"
39
- || (box.width <= 1 || box.height <= 1) && style.overflow !== "visible" || excluded(element.parentElement);
40
- exempt.set(element, value); return value;
41
38
  }
42
- for (const element of root.querySelectorAll("*")) {
43
- if (element.closest("#ads-preview-status") || element.closest("svg") && element.localName !== "svg") continue;
44
- if (excluded(element.parentElement)) continue;
45
- const style = getComputedStyle(element);
46
- if (style.position === "fixed" || !element.checkVisibility({ visibilityProperty: true })) continue;
47
- const box = element.getBoundingClientRect();
48
- if (box.width <= 1 || box.height <= 1) continue;
49
- // A clipping ancestor already reports the content it cuts off, and nothing paints past it.
50
- const contained = () => { for (let node = element.parentElement; node && node !== root; node = node.parentElement) if (/^(?:hidden|clip)$/.test(getComputedStyle(node).overflowX)) return true; return false; };
51
- const parent = element.parentElement === root ? { left: 0, right: width } : element.parentElement.getBoundingClientRect();
52
- if ((box.right > width + 1 || box.left < -1) && !(parent.right > width + 1 || parent.left < -1) && !contained()) report("viewport", element, { overflow: Math.round(Math.max(box.right - width, -box.left)) });
53
- 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")
54
- report("clipped", element, { overflow: element.scrollWidth - element.clientWidth });
39
+ await settled();
40
+ if (window.innerWidth !== expected) throw new Error(`The scenario document is ${window.innerWidth} px wide, not the audited ${expected} px.`);
41
+ if (!root) return { issues: [], counts: {} };
42
+ const found = measure();
43
+ if (!found.issues.length) return found;
44
+ const seen = layout();
45
+ for (let count = 0; count < 12; count++) {
46
+ await nextFrame();
47
+ if (layout() !== seen) { await settled(); return measure(); }
48
+ }
49
+ return found;
50
+ function measure() {
51
+ const width = document.documentElement.clientWidth, issues = [], counts = { document: 0, viewport: 0, container: 0, clipped: 0 };
52
+ const pane = container ? root.getBoundingClientRect() : { left: 0, right: width }, edge = container ? "container" : "viewport";
53
+ const selector = element => {
54
+ const parts = [];
55
+ for (let node = element; node && node !== root; node = node.parentElement) {
56
+ const siblings = [...node.parentElement.children].filter(child => child.localName === node.localName);
57
+ parts.unshift(`${node.localName}${siblings.length > 1 ? `:nth-of-type(${siblings.indexOf(node) + 1})` : ""}`);
58
+ }
59
+ return ["#root", ...parts].join(" > ");
60
+ };
61
+ const report = (kind, element, detail) => { if (counts[kind]++ < nodeLimit) issues.push({ kind, selector: element === document.documentElement ? "html" : selector(element).slice(0, 300), html: element === document.documentElement ? "" : element.outerHTML.replace(/\s+/g, " ").slice(0, 200), ...detail }); };
62
+ if (!container && document.documentElement.scrollWidth > width + 1) report("document", document.documentElement, { overflow: document.documentElement.scrollWidth - width });
63
+ const exempt = new Map();
64
+ /** Whether a set width, not content, holds this element open: a length above the small-part limit. */
65
+ function setWide(element) {
66
+ if (!element.computedStyleMap) return true;
67
+ const wide = property => { const value = element.computedStyleMap().get(property); return value instanceof CSSUnitValue && value.unit === "px" && value.value > smallPart; };
68
+ return element.getBoundingClientRect().width > smallPart && element.checkVisibility() && (wide("width") || wide("min-width") || wide("flex-basis") && getComputedStyle(element).flexShrink === "0");
69
+ }
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;
73
+ /** Whether an element is inside an intended scroller, a fixed layer or hidden content. */
74
+ function excluded(element) {
75
+ if (!element || element === root) return false;
76
+ if (exempt.has(element)) return exempt.get(element);
77
+ const style = getComputedStyle(element), box = element.getBoundingClientRect();
78
+ const value = /^(?:auto|scroll)$/.test(style.overflowX) && !frame(element) || style.position === "fixed" || style.clip !== "auto" && style.position === "absolute" || style.clipPath !== "none"
79
+ || (box.width <= 1 || box.height <= 1) && style.overflow !== "visible" || excluded(element.parentElement);
80
+ exempt.set(element, value); return value;
81
+ }
82
+ for (const element of root.querySelectorAll("*")) {
83
+ if (element.closest("#ads-preview-status") || element.closest("svg") && element.localName !== "svg") continue;
84
+ if (excluded(element.parentElement)) continue;
85
+ const style = getComputedStyle(element);
86
+ if (style.position === "fixed" || !element.checkVisibility({ visibilityProperty: true })) continue;
87
+ const box = element.getBoundingClientRect();
88
+ if (box.width <= 1 || box.height <= 1) continue;
89
+ // A clipping ancestor already reports the content it cuts off, and nothing paints past it.
90
+ 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
+ const parent = element.parentElement === root ? pane : element.parentElement.getBoundingClientRect();
92
+ 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))
94
+ report("clipped", element, { overflow: element.scrollWidth - element.clientWidth });
95
+ }
96
+ return { issues, counts };
55
97
  }
56
- return { issues, counts };
57
98
  }
@@ -2,6 +2,7 @@ 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 { firstRender } from "./first-render.mjs";
5
6
  import { nonTextContrast } from "./non-text-contrast.mjs";
6
7
  import { layoutOverflow } from "./layout-overflow.mjs";
7
8
  import { layoutShift } from "./layout-shift.mjs";
@@ -46,20 +47,21 @@ try {
46
47
  const frame = await openPreviewScenario(page, app.url, app.scenario, { timeout });
47
48
  await frame.waitForFunction(theme => document.documentElement.dataset.theme === theme, app.theme, { timeout });
48
49
  if (app.brand) await frame.waitForFunction(brand => document.documentElement.dataset.brand === brand, app.brand, { timeout });
49
- await frame.evaluate(async () => {
50
- await document.fonts.ready;
51
- await Promise.all([...document.images].map(image => image.decode().catch(() => {})));
52
- await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
53
- });
50
+ await frame.evaluate(firstRender);
54
51
  // Before the audit touches the page: resizing below would shift it.
55
52
  partial.layoutShift = await frame.evaluate(layoutShift, { nodeLimit: request.nodeLimit });
56
53
  if (!await frame.evaluate(() => !!window.axe)) await frame.addScriptTag({ content: axe });
57
54
  const result = await frame.evaluate(async ({ tags, nodeLimit }) => {
58
55
  // Scenario content only: the preview status aside and document-level chrome are ADS-owned.
59
- const outcome = await window.axe.run({ include: [["#root"]], exclude: [["#ads-preview-status"]] }, { runOnly: { type: "tag", values: tags }, resultTypes: ["violations"], elementRef: false, ancestry: false });
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 });
60
58
  const clip = (text, size) => typeof text === "string" ? text.replace(/\s+/g, " ").trim().slice(0, size) : "";
61
- return { violations: outcome.violations.map(violation => ({ id: violation.id, impact: violation.impact, tags: violation.tags, help: clip(violation.help, 300), helpUrl: clip(violation.helpUrl, 300), nodeCount: violation.nodes.length,
62
- nodes: violation.nodes.slice(0, nodeLimit).map(node => ({ selector: clip(node.target.flat().join(" "), 300), html: clip(node.html, 200), summary: clip(node.failureSummary, 500) })) })), incomplete: outcome.incomplete.length };
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) })) })) };
63
65
  }, { tags: request.tags, nodeLimit: request.nodeLimit });
64
66
  result.layoutShift = partial.layoutShift;
65
67
  Object.assign(partial, result);
@@ -70,6 +72,12 @@ try {
70
72
  await page.setViewportSize({ width, height: request.viewport.height });
71
73
  result.layout.push({ width, ...await frame.evaluate(layoutOverflow, { nodeLimit: request.nodeLimit, width }) });
72
74
  }
75
+ // Last: it narrows #root for good, at the widest viewport, as a pane in a window would be.
76
+ // A scenario with the main landmark is a whole page, which no pane hosts.
77
+ if (app.container && !await frame.evaluate(() => !!document.querySelector('main, [role="main"]'))) {
78
+ 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 }) });
80
+ }
73
81
  if (await frame.locator("html").getAttribute("data-ads-preview-state") !== "ready") throw new Error(`Scenario ${app.scenario} stopped being ready during the audit.`);
74
82
  return { scenario: app.scenario, theme: app.theme, ...(app.brand ? { brand: app.brand } : {}), ...result };
75
83
  } finally { await page.close().catch(() => {}); }
@@ -9,6 +9,7 @@ import { executeDevelopmentCommand } from "./verification.mjs";
9
9
  import { findingSeverity, routeFindings } from "./finding-rules.mjs";
10
10
  import { inspectScenarios } from "./scenarios.mjs";
11
11
  import { inspectUnits } from "./units.mjs";
12
+ import { globMatcher, smallPartLimitPx } from "./layout-widths.mjs";
12
13
  import { affectedScenarios } from "./verification.mjs";
13
14
 
14
15
  // Browser accessibility audit: axe-core (Deque, MPL-2.0, an unmodified ADS dependency
@@ -19,10 +20,13 @@ import { affectedScenarios } from "./verification.mjs";
19
20
  // which audit by default (browserAudit: false turns a policy's audit off). Automated rules catch a subset of WCAG failures; passing proves nothing more.
20
21
 
21
22
  export const AUDIT_RULE = "a11y-axe";
23
+ /** What axe could not decide on its own, such as contrast over a gradient: to check by hand. */
24
+ export const INCOMPLETE_RULE = "a11y-incomplete";
22
25
  /** ADS's own rendered check: WCAG 1.4.11 non-text contrast of control boundaries and icons (axe does not check it). */
23
26
  export const NON_TEXT_RULE = "a11y-non-text-contrast";
24
27
  /** ADS's own rendered layout check: horizontal overflow at each of overflowWidths. */
25
28
  export const OVERFLOW_RULE = "layout-overflow";
29
+ export const NARROW_RULE = "layout-overflow-narrow";
26
30
  /** ADS's own rendered check: a scenario's layout shift above the Core Web Vitals 0.1 threshold. */
27
31
  export const SHIFT_RULE = "layout-shift";
28
32
  const shiftLimit = 0.1;
@@ -32,6 +36,11 @@ const viewport = { width: 1280, height: 800 };
32
36
  /** Viewport widths layout-overflow renders every scenario at: phone, tablet and desktop. */
33
37
  export const overflowWidths = Object.freeze([390, 768, 1280]);
34
38
  export const auditedKinds = Object.freeze(["components", "patterns", "composition"]);
39
+ /** The width layout-overflow also renders scenarios of these kinds at, inside the widest viewport
40
+ * and in the first theme, since layout does not follow color: a narrow side pane. A composition is
41
+ * a whole screen, and is never hosted in one. */
42
+ export const containerWidth = 240;
43
+ export const containerKinds = Object.freeze(["components", "patterns"]);
35
44
  /** Attempts for one render, against a dropped preview connection or a slow preview. */
36
45
  export const auditAttempts = 3;
37
46
  const limits = { scenarios: 500, nodes: 5, findings: 2000, reportBytes: 8 * 1024 * 1024, pages: 4 };
@@ -64,6 +73,25 @@ export function auditFindings(runs, scenarios) {
64
73
  });
65
74
  }
66
75
 
76
+ /** One info item per scenario, axe rule and element set, across brands and themes. */
77
+ export function incompleteFindings(runs, scenarios) {
78
+ const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), groups = new Map();
79
+ const add = (list, value) => { if (value !== undefined && !list.includes(value)) list.push(value); };
80
+ for (const run of runs) for (const item of run.incomplete ?? []) {
81
+ const key = JSON.stringify([run.scenario, item.id, item.nodes.map(node => node.selector).sort()]);
82
+ const group = groups.get(key) ?? { scenario: run.scenario, themes: [], brands: [], item };
83
+ groups.set(key, group); add(group.themes, run.theme); add(group.brands, run.brand);
84
+ }
85
+ return [...groups.values()].slice(0, limits.findings).map(({ scenario, themes, brands, item }) => {
86
+ const where = item.nodes.slice(0, 3).map(node => `${node.selector}${node.reason ? ` (${node.reason})` : ""}`).join(", ") + (item.nodeCount > 3 ? ` and ${item.nodeCount - 3} more` : "");
87
+ return {
88
+ rule: INCOMPLETE_RULE, severity: findingSeverity(INCOMPLETE_RULE), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "axe-core", axeRule: item.id, impact: item.impact ?? null, scenario, themes, ...(brands.length ? { brands } : {}),
89
+ nodes: item.nodes, nodeCount: item.nodeCount, helpUrl: item.helpUrl, guidanceUri: "ads://guides/accessibility",
90
+ message: `axe could not decide ${item.id} in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: check it by hand. ${item.help}. ${item.nodeCount} element${item.nodeCount === 1 ? "" : "s"}: ${where}. ${item.helpUrl}`,
91
+ };
92
+ });
93
+ }
94
+
67
95
  const nonTextKinds = {
68
96
  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." },
69
97
  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." },
@@ -100,6 +128,7 @@ export function nonTextContrastFindings(runs, scenarios) {
100
128
  const overflowKinds = {
101
129
  document: { what: "the page scrolls horizontally", fix: "Find the element wider than its container; use fluid widths, min-width: 0 on flex and grid children, and let long text wrap." },
102
130
  viewport: { what: "content reaches past the viewport", fix: "Make the element fluid (%, fr, a --grid-span-N token in a container query), wrap it, or put it in an overflow-x: auto scroller." },
131
+ container: { what: "content reaches past its container", fix: "Make the element fluid (%, fr, min(100%, ...)), wrap it, or put it in an overflow-x: auto scroller. A width that truly stays this wide only fits an overlay: list its owner in layout.fixedWidthUnits." },
103
132
  clipped: { what: "content is cut off by overflow hidden or clip", fix: "Make the content fit, truncate it with text-overflow: ellipsis, or use overflow-x: auto if it should scroll." },
104
133
  };
105
134
 
@@ -108,22 +137,22 @@ const overflowKinds = {
108
137
  export function layoutOverflowFindings(runs, scenarios) {
109
138
  const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), groups = new Map();
110
139
  const add = (list, value) => { if (value !== undefined && !list.includes(value)) list.push(value); };
111
- for (const run of runs) for (const { width, issues = [], counts = {} } of run.layout ?? []) for (const kind of Object.keys(overflowKinds)) {
140
+ for (const run of runs) for (const { width, container = false, issues = [], counts = {} } of run.layout ?? []) for (const kind of Object.keys(overflowKinds)) {
112
141
  const found = issues.filter(issue => issue.kind === kind);
113
142
  if (!found.length) continue;
114
- const key = JSON.stringify([run.scenario, kind, found.map(issue => issue.selector).sort()]);
115
- const group = groups.get(key) ?? { scenario: run.scenario, kind, widths: [], themes: [], brands: [], nodes: new Map(), nodeCount: 0 };
143
+ const key = JSON.stringify([run.scenario, kind, container, found.map(issue => issue.selector).sort()]);
144
+ const group = groups.get(key) ?? { scenario: run.scenario, kind, container, widths: [], themes: [], brands: [], nodes: new Map(), nodeCount: 0 };
116
145
  groups.set(key, group); add(group.widths, width); add(group.themes, run.theme); add(group.brands, run.brand);
117
146
  group.nodeCount = Math.max(group.nodeCount, counts[kind] ?? found.length);
118
147
  for (const issue of found) if (!(group.nodes.get(issue.selector)?.overflow >= issue.overflow)) group.nodes.set(issue.selector, { ...issue, width });
119
148
  }
120
- return [...groups.values()].slice(0, limits.findings).map(({ scenario, kind, widths, themes, brands, nodes, nodeCount }) => {
149
+ return [...groups.values()].slice(0, limits.findings).map(({ scenario, kind, container, widths, themes, brands, nodes, nodeCount }) => {
121
150
  const list = [...nodes.values()], sorted = [...widths].sort((a, b) => a - b);
122
151
  const where = list.slice(0, 3).map(node => `${node.selector} (${node.overflow}px at ${node.width}px)`).join(", ") + (nodeCount > 3 ? ` and ${nodeCount - 3} more` : "");
123
152
  return {
124
- rule: OVERFLOW_RULE, severity: findingSeverity(OVERFLOW_RULE), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "ads", kind, scenario, widths: sorted, themes, ...(brands.length ? { brands } : {}),
153
+ rule: container ? NARROW_RULE : OVERFLOW_RULE, severity: findingSeverity(container ? NARROW_RULE : OVERFLOW_RULE), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "ads", kind, ...(container ? { container: sorted[0] } : { widths: sorted }), scenario, themes, ...(brands.length ? { brands } : {}),
125
154
  nodes: list, nodeCount, guidanceUri: "ads://guides/tokens",
126
- message: `Layout overflow in ${scenario} at ${sorted.join(", ")} px wide [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${overflowKinds[kind].what}: ${where}. ${overflowKinds[kind].fix}`,
155
+ message: `Layout overflow in ${scenario} ${container ? `in a ${sorted[0]} px container` : `at ${sorted.join(", ")} px wide`} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${overflowKinds[kind].what}: ${where}. ${overflowKinds[kind].fix}`,
127
156
  };
128
157
  });
129
158
  }
@@ -169,7 +198,7 @@ export function auditScenarioSelection(options, changedFiles) {
169
198
  export function auditCheck(audit, extra = {}) {
170
199
  const routed = routeFindings([], audit.findings);
171
200
  return { routed, check: { name: "browser-accessibility-audit", passed: !routed.diagnostics.length, engine: audit.engine, scenarios: audit.scenarios, themes: audit.themes, ...(audit.brands ? { brands: audit.brands } : {}),
172
- renders: audit.runs, ...(audit.retries ? { retries: audit.retries } : {}), errors: routed.diagnostics.length, reviews: routed.advisories.length, elapsedMs: audit.elapsedMs, ...extra } };
201
+ renders: audit.runs, ...(audit.retries ? { retries: audit.retries } : {}), errors: routed.diagnostics.length, reviews: routed.advisories.filter(item => item.severity === "review").length, infos: routed.advisories.filter(item => item.severity === "info").length, elapsedMs: audit.elapsedMs, ...extra } };
173
202
  }
174
203
 
175
204
  function projectPlaywright(root) {
@@ -183,6 +212,17 @@ const installHint = "`npm install -D @playwright/test` and `npx playwright insta
183
212
  /** Whether the project can run the audit: project-local Playwright, as for captures. */
184
213
  export const browserAuditAvailable = root => !!projectPlaywright(path.resolve(root));
185
214
 
215
+ /** Scenarios of an owner in layout.fixedWidthUnits float above the layout, and have no container to fit. */
216
+ function floatingScenarios(options, scenarios) {
217
+ const globs = options.config.layout.fixedWidthUnits, floating = globMatcher(globs);
218
+ if (!globs.length) return new Set();
219
+ const inventory = inspectUnits(options);
220
+ return new Set(scenarios.filter(scenario => {
221
+ const owner = inventory.owner(inventory.relative(scenario.file));
222
+ return owner && (floating(owner) || inventory.units.find(unit => unit.id === owner)?.files.some(floating));
223
+ }).map(scenario => scenario.id));
224
+ }
225
+
186
226
  const renderKey = ({ scenario, theme, brand }) => JSON.stringify([scenario, theme, brand ?? null]);
187
227
  const clipCause = text => String(text).replace(/\s+/g, " ").trim().slice(0, 500);
188
228
 
@@ -206,7 +246,7 @@ async function warmScenariosApart(host, ids, signal) {
206
246
  async function runAuditWorker({ root, temporary, playwright, settings, apps, signal }) {
207
247
  const request = path.join(temporary, "request.json"), report = path.join(temporary, "report.json"), runId = randomUUID();
208
248
  rmSync(report, { force: true });
209
- writeFileSync(request, JSON.stringify({ schemaVersion: 1, runId, playwright, axe: requireTool.resolve("axe-core/axe.min.js"), settings, viewport, overflowWidths, tags: auditTags, nodeLimit: limits.nodes, concurrency: limits.pages, apps, output: temporary }));
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 }));
210
250
  const timeoutMs = Math.min(30 * 60 * 1000, settings.timeoutMs + apps.length * Math.min(settings.timeoutMs, 15000));
211
251
  let cause;
212
252
  try {
@@ -276,7 +316,8 @@ export async function runBrowserAudit(root, { scenarios: selected, themes: selec
276
316
  const startHost = async () => { const { startAdsMcp } = await import("./mcp/server.mjs"); return startAdsMcp(root, { stdio: false, showcase: true }); };
277
317
  if (!host?.url) host = await startHost();
278
318
  const settings = { browser: "chromium", timeoutMs: 60000, ...options.config.mcp.capture };
279
- const wanted = themes.flatMap(theme => (brands.length ? brands : [undefined]).flatMap(brand => scenarios.map(scenario => ({ scenario: scenario.id, theme: theme.name, ...(brand ? { brand: brand.name } : {}), scheme: theme.scheme }))));
319
+ const floating = floatingScenarios(options, scenarios);
320
+ const wanted = themes.flatMap(theme => (brands.length ? brands : [undefined]).flatMap(brand => scenarios.map(scenario => ({ scenario: scenario.id, theme: theme.name, ...(brand ? { brand: brand.name } : {}), scheme: theme.scheme, ...(theme === themes[0] && containerKinds.includes(scenario.kind) && !floating.has(scenario.id) ? { container: containerWidth } : {}) }))));
280
321
  const renders = new Map(wanted.map(app => [renderKey(app), { app, attempts: 0, causes: [] }]));
281
322
  onProgress?.({ stage: "browser-audit", message: `Accessibility audit: ${wanted.length} renders (${scenarios.length} scenarios × ${themes.length} themes${brands.length ? ` × ${brands.length} brands` : ""}).`, elapsedMs: Date.now() - startedAt });
282
323
  for (let attempt = 1; attempt <= auditAttempts; attempt++) {
@@ -311,9 +352,9 @@ export async function runBrowserAudit(root, { scenarios: selected, themes: selec
311
352
  }
312
353
  const all = [...renders.values()], runs = all.map(render => render.result ?? render.partial).filter(Boolean);
313
354
  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 }));
314
- const findings = [...auditFindings(runs, scenarios), ...nonTextContrastFindings(runs, scenarios), ...layoutOverflowFindings(runs, scenarios), ...layoutShiftFindings(runs, scenarios), ...unauditedFindings(all.filter(render => !render.result), scenarios)];
355
+ const findings = [...auditFindings(runs, scenarios), ...nonTextContrastFindings(runs, scenarios), ...layoutOverflowFindings(runs, scenarios), ...layoutShiftFindings(runs, scenarios), ...unauditedFindings(all.filter(render => !render.result), scenarios), ...incompleteFindings(runs, scenarios)];
315
356
  const shifts = runs.filter(run => run.layoutShift).sort((a, b) => b.layoutShift.value - a.layoutShift.value);
316
- return { ...summary, ...(shifts.length ? { worstLayoutShift: { value: shifts[0].layoutShift.value, scenario: shifts[0].scenario } } : {}), runs: all.filter(render => render.result).length, incomplete: runs.reduce((sum, item) => sum + (item.incomplete ?? 0), 0), findings, ...(retries.length ? { retries } : {}), elapsedMs: Date.now() - startedAt };
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 };
317
358
  } finally {
318
359
  try { if (host !== previewHost) await host?.close(); } finally { rmSync(temporary, { recursive: true, force: true }); }
319
360
  }
@@ -1,6 +1,7 @@
1
1
  import { readFileSync, writeFileSync } from "node:fs";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
+ import { firstRender } from "../browser-audit/first-render.mjs";
4
5
  import { openPreviewScenario } from "../verification/browser.mjs";
5
6
 
6
7
  // Runs only as an owned child, using the receiving project's browser dependency.
@@ -18,11 +19,7 @@ try {
18
19
  await frame.locator("html").waitFor({ state: "visible", timeout });
19
20
  await frame.waitForFunction(theme => document.documentElement.dataset.theme === theme, app.theme, { timeout });
20
21
  if (app.brand) await frame.waitForFunction(brand => document.documentElement.dataset.brand === brand, app.brand, { timeout });
21
- await frame.evaluate(async () => {
22
- await document.fonts.ready;
23
- await Promise.all([...document.images].map(image => image.decode().catch(() => {})));
24
- await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
25
- });
22
+ await frame.evaluate(firstRender);
26
23
  const actualViewport = await frame.evaluate(() => ({ width: innerWidth, height: innerHeight }));
27
24
  if (actualViewport.width !== app.viewport.width || actualViewport.height !== app.viewport.height) throw new Error(`App viewport differs from requested capture settings: ${JSON.stringify(actualViewport)}`);
28
25
  const target = frame.locator(app.selector);
package/dist/check.mjs CHANGED
@@ -112,7 +112,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
112
112
  const layoutWidths = createLayoutWidths(tokenInventory.tokens, config), fixedWidthOwner = globMatcher(config.layout.fixedWidthUnits);
113
113
  for (const glob of config.layout.widthTokens) if (!tokenInventory.tokens.some(token => globMatcher([glob])(token.name))) diagnostics.push({ rule: "layout-config", file: "ds.config.json", line: 1, column: 1, message: `layout.widthTokens entry ${glob} matches no declared token. Remove it or declare the token.` });
114
114
  for (const glob of config.layout.fixedWidthUnits) if (!units.units.some(unit => globMatcher([glob])(unit.id) || unit.files.some(file => globMatcher([glob])(file)))) diagnostics.push({ rule: "layout-config", file: "ds.config.json", line: 1, column: 1, message: `layout.fixedWidthUnits entry ${glob} matches no unit or owned file. Remove it or correct the path.` });
115
- advisories.push(...layoutWidths.tokenFindings());
115
+ const ownerFixedWidths = [];
116
116
  function checkRegistrations(file,css,offset={line:1}){
117
117
  css.walkAtRules(/^property$/i,rule=>{
118
118
  const line=offset.line+(rule.source?.start.line??1)-1;
@@ -152,7 +152,9 @@ export function checkProject(directory, { trackingRoot } = {}) {
152
152
  if (!foundation && !isDevelopmentFile(file, options) && ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file))) componentContrast.collect(path.relative(root, file).replaceAll("\\", "/"), css, offset);
153
153
  if (!foundation && (isInside(path.join(dsRoot, "composition"), file) || !isDevelopmentFile(file, options) && ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file)))) {
154
154
  const relative = path.relative(root, file).replaceAll("\\", "/"), owner = units.owner(units.relative(path.relative(root, file)));
155
- if (!fixedWidthOwner(relative) && !(owner && fixedWidthOwner(owner))) advisories.push(...layoutWidths.inspect(css, relative, offset));
155
+ const widths = layoutWidths.inspect(css, relative, offset);
156
+ if (!fixedWidthOwner(relative) && !(owner && fixedWidthOwner(owner))) advisories.push(...widths);
157
+ else ownerFixedWidths.push(...widths.filter(finding => finding.rule === "layout-fixed-width"));
156
158
  }
157
159
  // Linaria templates are checked once per resolved interpolation variant.
158
160
  if (!foundation) for (const finding of controlPaddingAdvisories(css, { tokens: declaredTokens, file: path.relative(root, file).replaceAll("\\", "/"), offset })) {
@@ -381,7 +383,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
381
383
  }
382
384
  inspectDesignAliases(layerStyles,options,report);
383
385
  for (const { file, css, offset } of layerStyles) layers.inspectStyles(file, css, offset);
384
- advisories.push(...(tokenInventory.advisories??[]), ...assetAdvisories, ...a11ySourceAdvisories(options), ...imageAttributeFindings(options), ...componentContrast.findings());
386
+ advisories.push(...(tokenInventory.advisories??[]), ...assetAdvisories, ...a11ySourceAdvisories(options), ...imageAttributeFindings(options), ...componentContrast.findings(), ...layoutWidths.declaredWidths(ownerFixedWidths));
385
387
  // Errors block by class; bounded clients see review items before informational limits.
386
388
  const routed=routeFindings(diagnostics,advisories);
387
389
  const uniqueDiagnostics=[...new Map(routed.diagnostics.map(diagnostic=>[JSON.stringify([diagnostic.file,diagnostic.rule,diagnostic.line,diagnostic.column,diagnostic.message]),diagnostic])).values()];
package/dist/cli.mjs CHANGED
@@ -184,7 +184,8 @@ async function main(args) {
184
184
  else if (command === "assets") { const { refreshThemesCss } = await import("./themes-watch.mjs"); const themes = refreshThemesCss(target); result = { ...await generateBrandAssets(target), themes: { file: themes.file, written: themes.files[0]?.written ?? false, ...(themes.skipped ? { skipped: themes.skipped } : {}) }, ...(themes.files[1] ? { palette: { file: themes.files[1].file, written: themes.files[1].written }, ...(themes.files[2] ? { fontPreloads: { file: themes.files[2].file, written: themes.files[2].written } } : {}) } : {}) }; }
185
185
  else if (command === "lint-config") result = generateLintConfig(target);
186
186
  else throw new Error(`Unknown command: ${command}. Run ads --help.`);
187
- if (json) console.log(JSON.stringify(result, null, 2));
187
+ // Bun ends a piped stdout at its buffer unless the write is awaited.
188
+ if (json) await new Promise(resolve => process.stdout.write(`${JSON.stringify(result, null, 2)}\n`, resolve));
188
189
  else if (command === "create") console.log(`Created ${result.name} in ${target}\nFramework: ${result.framework}\nNext: cd ${((folder) => /[\s'"$`\\]/.test(folder) ? JSON.stringify(folder) : folder)(path.relative(process.cwd(), target) || ".")} && ${result.packageManager} install && ${result.packageManager === "bun" ? "bunx" : "npx"} playwright install chromium && ${result.packageManager} run build && ${result.packageManager} run dev:showcase`);
189
190
  else if (command === "init") console.log(`Initialized ${target}\nFramework: ${result.framework}\nAdded ${result.toolDependency.name} (${result.toolDependency.spec}) as a development dependency.\nRun ${result.packageManager} install and ${result.packageManager} run build; the build runs ADS checks and generates configured brand assets automatically.`);
190
191
  else if (command === "assets") {
@@ -196,7 +197,7 @@ async function main(args) {
196
197
  }
197
198
  else if (command === "lint-config") console.log(`Generated ${result.file}\nUse this optional configuration only in the project linter you choose to run.`);
198
199
  else if (command === "behaviors") console.log(JSON.stringify(result, null, 2));
199
- else if (command === "audit") { const { findingCounts } = await import("./finding-rules.mjs"); console.log(`ADS accessibility audit (${result.engine}): ${findingCounts(result.diagnostics.length, result.findings.length)} across ${result.scenarios} scenarios × ${result.themes.length} themes (${result.themes.join(", ")})${result.brands ? ` × ${result.brands.length} brands (${result.brands.join(", ")})` : ""}.`); if (result.retries) console.log(`Retried ${result.retries.length} render${result.retries.length === 1 ? "" : "s"} that then passed: ${result.retries.map(retry => `${retry.scenario} [${[retry.theme, retry.brand].filter(Boolean).join(", ")}] in ${retry.attempts} attempts`).join("; ")}.`); for (const finding of result.findings) console.error(`${finding.file}:${finding.line}:${finding.column} [${finding.severity}:${finding.rule}] ${finding.message}`); }
200
+ else if (command === "audit") { const { findingCounts } = await import("./finding-rules.mjs"); console.log(`ADS accessibility audit (${result.engine}): ${findingCounts(result.diagnostics.length, result.findings.filter(finding => finding.severity === "review").length)}, ${result.incomplete ?? 0} that axe could not decide across ${result.scenarios} scenarios × ${result.themes.length} themes (${result.themes.join(", ")})${result.brands ? ` × ${result.brands.length} brands (${result.brands.join(", ")})` : ""}.`); if (result.retries) console.log(`Retried ${result.retries.length} render${result.retries.length === 1 ? "" : "s"} that then passed: ${result.retries.map(retry => `${retry.scenario} [${[retry.theme, retry.brand].filter(Boolean).join(", ")}] in ${retry.attempts} attempts`).join("; ")}.`); for (const finding of result.findings) console.error(`${finding.file}:${finding.line}:${finding.column} [${finding.severity}:${finding.rule}] ${finding.message}`); }
200
201
  else if (command === "verify") { for (const item of result.results) console.log(`${item.unit}#${item.check}: ${item.status} (${item.profile})`); }
201
202
  else if (command === "validate") {console.log(`ADS ${result.policy} ${result.ok?"passed":"failed"}: ${result.scope}${result.fallback?` (${result.fallback})`:""}`);for(const check of result.checks)console.log(`${check.name}: ${check.skipped?"skipped":check.passed?"passed":"failed"}${check.reason?` (${check.reason})`:""}`);}
202
203
  else if (command === "tokens") {
package/dist/config.mjs CHANGED
@@ -131,8 +131,8 @@ export function loadConfig(directory = process.cwd()) {
131
131
  for (const brand of config.brands) if (config.themes.some(theme => theme.name === `brand-${brand.name}`)) throw new Error(`Theme "brand-${brand.name}" and brand "${brand.name}" would share the display switch --display-brand-${brand.name}; rename one.`);
132
132
  if(config.resources.memoryLimitMb!==null&&(!Number.isInteger(config.resources.memoryLimitMb)||config.resources.memoryLimitMb<64||config.resources.memoryLimitMb>1048576))throw new Error("resources.memoryLimitMb must be null (automatic) or an integer from 64 to 1048576 MiB.");
133
133
  if (config.assets.imageBudgetKb !== null && (!Number.isInteger(config.assets.imageBudgetKb) || config.assets.imageBudgetKb < 1 || config.assets.imageBudgetKb > 1048576)) throw new Error("assets.imageBudgetKb must be null (a limit per format) or a positive whole number of KB for every format.");
134
- if (!Array.isArray(config.layout.widthTokens) || config.layout.widthTokens.length > 200 || new Set(config.layout.widthTokens).size !== config.layout.widthTokens.length || config.layout.widthTokens.some(name => typeof name !== "string" || !/^--[\w*-]+$/.test(name))) throw new Error("layout.widthTokens must contain distinct token names or globs such as --grid-span-*.");
135
- if (!Array.isArray(config.layout.fixedWidthUnits) || config.layout.fixedWidthUnits.length > 200 || new Set(config.layout.fixedWidthUnits).size !== config.layout.fixedWidthUnits.length || config.layout.fixedWidthUnits.some(glob => typeof glob !== "string" || !glob || glob.includes("\\") || glob.startsWith("/") || glob.split("/").includes(".."))) throw new Error("layout.fixedWidthUnits must contain distinct unit ids or project-relative globs such as components/Overlay/*.");
134
+ if (!Array.isArray(config.layout.widthTokens) || config.layout.widthTokens.length > 200 || new Set(config.layout.widthTokens).size !== config.layout.widthTokens.length || config.layout.widthTokens.some(name => typeof name !== "string" || !/^--[\w-][\w*-]*$/.test(name))) throw new Error("layout.widthTokens must contain distinct token names or globs such as --panel-*, and cannot name every token.");
135
+ if (!Array.isArray(config.layout.fixedWidthUnits) || config.layout.fixedWidthUnits.length > 200 || new Set(config.layout.fixedWidthUnits).size !== config.layout.fixedWidthUnits.length || config.layout.fixedWidthUnits.some(glob => typeof glob !== "string" || !glob || glob.includes("\\") || glob.startsWith("/") || glob.split("/").includes("..") || !/[^*/]/.test(glob))) throw new Error("layout.fixedWidthUnits must contain distinct unit ids or project-relative globs such as components/Overlay/*, and cannot name every unit.");
136
136
  if (!Array.isArray(config.usage.notifications) || config.usage.notifications.length > 100) throw new Error("usage.notifications must be an array of notification API registrations.");
137
137
  const notificationNames = new Set();
138
138
  for (const entry of config.usage.notifications) {
@@ -11,6 +11,8 @@ export const findingRules = Object.freeze({
11
11
  "a11y-non-text-contrast": "error", "a11y-target-size": "error", "a11y-text-resize": "error", "a11y-text-spacing": "error",
12
12
  // A click handler on a non-control may be reachable through a delegated or wrapping control.
13
13
  "a11y-keyboard": "review",
14
+ // What axe reports it could not decide: nothing fails, and someone checks it by hand.
15
+ "a11y-incomplete": "info",
14
16
  // Atomic styles: the composition analysis is heuristic; its limits are informational.
15
17
  "atomic-composition-review": "review", "atomic-composition-limit": "info",
16
18
  // Text and background a component style block pairs itself; a side that names no color token is informational.
@@ -22,6 +24,9 @@ export const findingRules = Object.freeze({
22
24
  "control-padding": "error",
23
25
  // Widths are fluid on the grid: fixed widths from source, and overflow where the audit renders.
24
26
  "layout-fixed-width": "error", "layout-overflow": "error",
27
+ // Whether a declared width must stay fixed, a fluid wrapper does anything, or a part ever sits in
28
+ // a narrow pane takes judgement.
29
+ "layout-declared-width": "review", "layout-width-noop": "review", "layout-overflow-narrow": "review",
25
30
  // Images reserve their space and choose how they load; a spread or foreign class cannot be read.
26
31
  "img-attributes": "error", "img-attributes-unresolved": "info",
27
32
  "asset-image-budget": "error",