@reqvire-org/ads 0.3.48 → 0.3.50

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 (94) hide show
  1. package/README.md +36 -6
  2. package/dist/active-clock.mjs +34 -0
  3. package/dist/assets.mjs +20 -2
  4. package/dist/boundaries.mjs +2 -0
  5. package/dist/browser-audit/layout-overflow.mjs +57 -0
  6. package/dist/browser-audit/layout-shift.mjs +32 -0
  7. package/dist/browser-audit/non-text-contrast.mjs +87 -0
  8. package/dist/browser-audit/worker.mjs +36 -7
  9. package/dist/browser-audit.mjs +198 -22
  10. package/dist/check.mjs +14 -1
  11. package/dist/cli.mjs +7 -4
  12. package/dist/component-contrast.mjs +138 -0
  13. package/dist/config.mjs +12 -6
  14. package/dist/finding-rules.mjs +13 -1
  15. package/dist/fonts-generated.mjs +85 -0
  16. package/dist/image-attributes.mjs +110 -0
  17. package/dist/init.mjs +2 -0
  18. package/dist/layout-widths.mjs +184 -0
  19. package/dist/mcp/context.mjs +1 -1
  20. package/dist/mcp/mutations.mjs +7 -5
  21. package/dist/mcp/preview-watch.mjs +9 -8
  22. package/dist/mcp/server.mjs +6 -4
  23. package/dist/palette-generated.mjs +6 -3
  24. package/dist/preview-files.mjs +3 -0
  25. package/dist/project-boundary.mjs +23 -0
  26. package/dist/project-documents.mjs +2 -1
  27. package/dist/scenarios-compiler.mjs +23 -3
  28. package/dist/showcase/client.bundle.js +11 -11
  29. package/dist/showcase/icons.js +5 -5
  30. package/dist/showcase/style.css +1 -1
  31. package/dist/skills/ads-break-ui/SKILL.md +8 -0
  32. package/dist/skills/ads-break-ui/references/atomic-styles.md +2 -0
  33. package/dist/skills/ads-break-ui/references/design-data.md +47 -1
  34. package/dist/skills/ads-break-ui/references/drafts.md +1 -1
  35. package/dist/skills/ads-break-ui/references/guarded-editing.md +1 -1
  36. package/dist/skills/ads-break-ui/references/validation.md +9 -5
  37. package/dist/skills/ads-designer/SKILL.md +24 -4
  38. package/dist/skills/ads-designer/references/accessibility.md +31 -14
  39. package/dist/skills/ads-designer/references/atomic-styles.md +2 -0
  40. package/dist/skills/ads-designer/references/branding.md +10 -5
  41. package/dist/skills/ads-designer/references/cli.md +2 -1
  42. package/dist/skills/ads-designer/references/design-data.md +47 -1
  43. package/dist/skills/ads-designer/references/drafts.md +1 -1
  44. package/dist/skills/ads-designer/references/guarded-editing.md +1 -1
  45. package/dist/skills/ads-designer/references/mobile.md +3 -0
  46. package/dist/skills/ads-designer/references/performance.md +89 -0
  47. package/dist/skills/ads-designer/references/validation.md +9 -5
  48. package/dist/skills/ads-import/references/atomic-styles.md +2 -0
  49. package/dist/skills/ads-import/references/cli.md +2 -1
  50. package/dist/skills/ads-import/references/design-data.md +47 -1
  51. package/dist/skills/ads-import/references/drafts.md +1 -1
  52. package/dist/skills/ads-import/references/guarded-editing.md +1 -1
  53. package/dist/skills/ads-import/references/validation.md +9 -5
  54. package/dist/skills/ads-motion/references/atomic-styles.md +2 -0
  55. package/dist/skills/ads-motion/references/design-data.md +47 -1
  56. package/dist/skills/ads-motion/references/drafts.md +1 -1
  57. package/dist/skills/ads-motion/references/guarded-editing.md +1 -1
  58. package/dist/skills/ads-motion/references/validation.md +9 -5
  59. package/dist/skills/ads-port/references/atomic-styles.md +2 -0
  60. package/dist/skills/ads-port/references/cli.md +2 -1
  61. package/dist/skills/ads-port/references/design-data.md +47 -1
  62. package/dist/skills/ads-port/references/drafts.md +1 -1
  63. package/dist/skills/ads-port/references/guarded-editing.md +1 -1
  64. package/dist/skills/ads-port/references/validation.md +9 -5
  65. package/dist/starters/preact/ds.config.json +1 -0
  66. package/dist/starters/preact/package.json +1 -0
  67. package/dist/starters/react/ADS.md +1 -1
  68. package/dist/starters/react/README.md +14 -2
  69. package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +1 -1
  70. package/dist/starters/react/design-system/components/Content/Image/Image.ads.fixture.ts +2 -0
  71. package/dist/starters/react/design-system/components/Content/Image/Image.ads.scenario.tsx +13 -0
  72. package/dist/starters/react/design-system/components/Content/Image/Image.tsx +48 -0
  73. package/dist/starters/react/design-system/components/Content/Image/README.md +20 -0
  74. package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +2 -2
  75. package/dist/starters/react/design-system/index.ts +1 -0
  76. package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +16 -0
  77. package/dist/starters/react/design-system/tokens/spacing.css +18 -0
  78. package/dist/starters/react/ds.config.json +1 -0
  79. package/dist/starters/react/package-lock.json +47 -0
  80. package/dist/starters/react/package.json +2 -1
  81. package/dist/test-boundaries.mjs +30 -1
  82. package/dist/themes-generated.mjs +15 -4
  83. package/dist/token-quality.mjs +61 -24
  84. package/dist/units.mjs +2 -1
  85. package/dist/validation-checks.mjs +5 -4
  86. package/dist/validation.mjs +1 -1
  87. package/dist/verification/browser.mjs +28 -2
  88. package/dist/verification.mjs +5 -4
  89. package/docs/ADS.md +4 -1
  90. package/docs/ARCHITECTURE.md +13 -3
  91. package/docs/CHANGELOG.md +111 -12
  92. package/docs/GUIDE.md +208 -14
  93. package/docs/MCP.md +14 -10
  94. package/package.json +1 -1
@@ -67,6 +67,24 @@
67
67
  --grid-margin-sm: var(--space-0);
68
68
  --grid-margin-md: var(--space-8);
69
69
  --grid-margin-lg: var(--space-12);
70
+ /* A width of N of 16 columns, fluid in its container: set it inside a container query.
71
+ --container-* are fixed caps, for max-inline-size only. */
72
+ --grid-span-1: calc((100% + var(--grid-gutter)) * 1 / 16 - var(--grid-gutter));
73
+ --grid-span-2: calc((100% + var(--grid-gutter)) * 2 / 16 - var(--grid-gutter));
74
+ --grid-span-3: calc((100% + var(--grid-gutter)) * 3 / 16 - var(--grid-gutter));
75
+ --grid-span-4: calc((100% + var(--grid-gutter)) * 4 / 16 - var(--grid-gutter));
76
+ --grid-span-5: calc((100% + var(--grid-gutter)) * 5 / 16 - var(--grid-gutter));
77
+ --grid-span-6: calc((100% + var(--grid-gutter)) * 6 / 16 - var(--grid-gutter));
78
+ --grid-span-7: calc((100% + var(--grid-gutter)) * 7 / 16 - var(--grid-gutter));
79
+ --grid-span-8: calc((100% + var(--grid-gutter)) * 8 / 16 - var(--grid-gutter));
80
+ --grid-span-9: calc((100% + var(--grid-gutter)) * 9 / 16 - var(--grid-gutter));
81
+ --grid-span-10: calc((100% + var(--grid-gutter)) * 10 / 16 - var(--grid-gutter));
82
+ --grid-span-11: calc((100% + var(--grid-gutter)) * 11 / 16 - var(--grid-gutter));
83
+ --grid-span-12: calc((100% + var(--grid-gutter)) * 12 / 16 - var(--grid-gutter));
84
+ --grid-span-13: calc((100% + var(--grid-gutter)) * 13 / 16 - var(--grid-gutter));
85
+ --grid-span-14: calc((100% + var(--grid-gutter)) * 14 / 16 - var(--grid-gutter));
86
+ --grid-span-15: calc((100% + var(--grid-gutter)) * 15 / 16 - var(--grid-gutter));
87
+ --grid-span-16: calc((100% + var(--grid-gutter)) * 16 / 16 - var(--grid-gutter));
70
88
 
71
89
  --content-max: 72ch;
72
90
  --container-sm: 40rem;
@@ -7,6 +7,7 @@
7
7
  "mcp": {
8
8
  "previewManifest": ".ds/preview/manifest.json"
9
9
  },
10
+ "layout": { "widthTokens": ["--grid-span-*", "--container-*"] },
10
11
  "boundaries": {
11
12
  "styleWrites": [
12
13
  {
@@ -12,6 +12,7 @@
12
12
  "@babel/preset-typescript": "7.29.7",
13
13
  "@biomejs/biome": "2.5.15",
14
14
  "@linaria/atomic": "8.0.0",
15
+ "@playwright/test": "1.64.1",
15
16
  "@types/node": "25.9.4",
16
17
  "@types/react": "19.2.17",
17
18
  "@types/react-dom": "19.2.3",
@@ -24,6 +25,7 @@
24
25
  "vite": "6.4.3"
25
26
  },
26
27
  "engines": {
28
+ "bun": ">=1.4.1",
27
29
  "node": ">=22.12.0"
28
30
  }
29
31
  },
@@ -2768,6 +2770,22 @@
2768
2770
  "node": "^20.19.0 || >=22.12.0"
2769
2771
  }
2770
2772
  },
2773
+ "node_modules/@playwright/test": {
2774
+ "version": "1.64.1",
2775
+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz",
2776
+ "integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==",
2777
+ "dev": true,
2778
+ "license": "Apache-2.0",
2779
+ "dependencies": {
2780
+ "playwright": "1.64.1"
2781
+ },
2782
+ "bin": {
2783
+ "playwright": "cli.js"
2784
+ },
2785
+ "engines": {
2786
+ "node": ">=20"
2787
+ }
2788
+ },
2771
2789
  "node_modules/@rolldown/pluginutils": {
2772
2790
  "version": "1.0.0-beta.27",
2773
2791
  "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz",
@@ -4171,6 +4189,35 @@
4171
4189
  "dev": true,
4172
4190
  "license": "ISC"
4173
4191
  },
4192
+ "node_modules/playwright": {
4193
+ "version": "1.64.1",
4194
+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz",
4195
+ "integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==",
4196
+ "dev": true,
4197
+ "license": "Apache-2.0",
4198
+ "dependencies": {
4199
+ "playwright-core": "1.64.1"
4200
+ },
4201
+ "bin": {
4202
+ "playwright": "cli.js"
4203
+ },
4204
+ "engines": {
4205
+ "node": ">=20"
4206
+ }
4207
+ },
4208
+ "node_modules/playwright-core": {
4209
+ "version": "1.64.1",
4210
+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz",
4211
+ "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==",
4212
+ "dev": true,
4213
+ "license": "Apache-2.0",
4214
+ "bin": {
4215
+ "playwright-core": "cli.js"
4216
+ },
4217
+ "engines": {
4218
+ "node": ">=20"
4219
+ }
4220
+ },
4174
4221
  "node_modules/postcss": {
4175
4222
  "version": "8.5.29",
4176
4223
  "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.29.tgz",
@@ -24,10 +24,11 @@
24
24
  "build:mcp-previews": "ads compile ."
25
25
  },
26
26
  "devDependencies": {
27
- "@biomejs/biome": "2.5.15",
28
27
  "@babel/preset-react": "7.29.7",
29
28
  "@babel/preset-typescript": "7.29.7",
29
+ "@biomejs/biome": "2.5.15",
30
30
  "@linaria/atomic": "8.0.0",
31
+ "@playwright/test": "1.64.1",
31
32
  "@types/node": "25.9.4",
32
33
  "@types/react": "19.2.17",
33
34
  "@types/react-dom": "19.2.3",
@@ -14,6 +14,35 @@ export function inspectTestBoundaries(options, inventory, contracts, program) {
14
14
  if (!parsed.has(file)) parsed.set(file,program?.getSourceFile(file) ?? ts.createSourceFile(file,readFileSync(file,"utf8"),ts.ScriptTarget.Latest,true));
15
15
  return parsed.get(file);
16
16
  }
17
+ /** A case tag marks a test only where it tags one: in a test call's title or options. The
18
+ * same text as data or inside a generated fixture's source tags nothing. */
19
+ function caseTagged(ast) {
20
+ const tag = /@ads:[\w.-]+/;
21
+ let found = false;
22
+ function argument(node) {
23
+ if (found || ts.isFunctionLike(node)) return;
24
+ if (ts.isStringLiteralLike(node) && tag.test(node.text)) found = true;
25
+ else if (ts.isTemplateExpression(node) && tag.test(node.getText(ast))) found = true;
26
+ // An indirect tag cannot be read from source, so the file's text decides.
27
+ else if ((ts.isPropertyAssignment(node) || ts.isShorthandPropertyAssignment(node)) && node.name.getText(ast) === "tag" && !(ts.isPropertyAssignment(node) && (ts.isStringLiteralLike(node.initializer) || ts.isArrayLiteralExpression(node.initializer))) && tag.test(ast.text)) found = true;
28
+ else ts.forEachChild(node, argument);
29
+ }
30
+ function visit(node) {
31
+ if (found) return;
32
+ if (ts.isCallExpression(node)) {
33
+ let base = node.expression;
34
+ while (ts.isPropertyAccessExpression(base) || ts.isCallExpression(base)) base = base.expression;
35
+ if (ts.isIdentifier(base) && ["test","it","describe"].includes(base.text)) {
36
+ const [title] = node.arguments;
37
+ if (title && ts.isIdentifier(title) && tag.test(ast.text)) found = true;
38
+ for (const value of node.arguments) argument(value);
39
+ }
40
+ }
41
+ ts.forEachChild(node, visit);
42
+ }
43
+ visit(ast);
44
+ return found;
45
+ }
17
46
  function walk(directory) {
18
47
  for (const entry of readdirSync(directory,{withFileTypes:true})) {
19
48
  const file = path.join(directory,entry.name);
@@ -53,7 +82,7 @@ export function inspectTestBoundaries(options, inventory, contracts, program) {
53
82
  for (const file of tests) {
54
83
  const own = owner(file), inside = isInside(options.dsRoot,file);
55
84
  const edges = imports(file);
56
- const marked = adsFileRole(file) === "behavior.spec" || /@ads:[\w.-]+/.test(source(file).text);
85
+ const marked = adsFileRole(file) === "behavior.spec" || caseTagged(source(file));
57
86
  if (marked && !registered.has(file)) report(file,"test-registration","ADS behavior specs must be registered by their owning contract. Register this file or remove the obsolete spec.");
58
87
  if (inside) {
59
88
  const unit = inventory.units.find(unit=>unit.id===own);
@@ -1,7 +1,8 @@
1
1
  import { existsSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
2
2
  import path from "node:path";
3
- import { classifyScope, referencedTokens, themeDependents } from "./themes.mjs";
3
+ import { classifyScope, contextValues, referencedTokens, themeDependents } from "./themes.mjs";
4
4
  import { generatedPaletteFile, paletteTs } from "./palette-generated.mjs";
5
+ import { fontPreloadText, generatedFontsFile } from "./fonts-generated.mjs";
5
6
 
6
7
  // themes.generated.css: the theme switches and per-element resolvers ADS writes from the token
7
8
  // sheets' per-theme halves and ds.config.json themes/brands. The showcase and MCP server write
@@ -27,9 +28,14 @@ export const generatedThemesFile = "themes.generated.css";
27
28
  export const themesCssPath = ({ dsRoot, config }) => path.join(dsRoot, config.tokenDir, generatedThemesFile);
28
29
  export { generatedPaletteFile };
29
30
  /** Both generated files, written and checked together: the theme sheet and the renderer palette. */
30
- export const generatedThemeFiles = [generatedThemesFile, generatedPaletteFile];
31
+ export const generatedThemeFiles = [generatedThemesFile, generatedPaletteFile, generatedFontsFile];
31
32
  export const paletteTsPath = ({ dsRoot, config }) => path.join(dsRoot, config.tokenDir, generatedPaletteFile);
32
- const generatedTexts = (options, tokens) => [{ file: themesCssPath(options), text: themesCss(tokens, options.config) }, { file: paletteTsPath(options), text: paletteTs(tokens, options.config) }];
33
+ const fontsFile = ({ dsRoot, config }) => path.join(dsRoot, config.tokenDir, generatedFontsFile);
34
+ const fontsText = (options, tokens) => fontPreloadText(options, contextValues(tokens, { theme: options.config.themes[0].name, themes: options.config.themes }));
35
+ const generatedTexts = (options, tokens) => {
36
+ const fonts = fontsText(options, tokens);
37
+ return [{ file: themesCssPath(options), text: themesCss(tokens, options.config) }, { file: paletteTsPath(options), text: paletteTs(tokens, options.config) }, ...(fonts ? [{ file: fontsFile(options), text: fonts }] : [])];
38
+ };
33
39
  const header = "/* Generated by ADS from the token sheets' per-theme halves and ds.config.json themes and brands.\n The showcase and MCP server rewrite it when they change; do not edit it. */\n";
34
40
 
35
41
  const declaration = definition => ({ property: definition.property ?? definition.name, value: (definition.authored ?? definition.value).trim() });
@@ -132,6 +138,8 @@ export function themesCssDiagnostics(options, inventory) {
132
138
  if (!existsSync(file)) diagnostics.push({ ...at, message: `${relative} is missing. ADS writes it from the token sheets; run \`ads assets\` or start the showcase or MCP server.` });
133
139
  else if (readFileSync(file, "utf8") !== text) diagnostics.push({ ...at, message: `${relative} is out of date with the token sheets or ds.config.json themes and brands; run \`ads assets\` or start the showcase or MCP server.` });
134
140
  }
141
+ const fonts = fontsFile(options);
142
+ if (!fontsText(options, inventory.tokens) && existsSync(fonts)) { const relative = path.relative(options.root, fonts).replaceAll("\\", "/"); diagnostics.push({ rule: "themes-generated", file: relative, line: 1, column: 1, message: `${relative} preloads fonts the first text no longer uses; run \`ads assets\` or start the showcase or MCP server.` }); }
135
143
  return diagnostics;
136
144
  }
137
145
 
@@ -146,5 +154,8 @@ export function writeThemesCss(options, inventory) {
146
154
  try { writeFileSync(staged, text); renameSync(staged, file); } finally { rmSync(staged, { force: true }); }
147
155
  return { file, written: true, text };
148
156
  });
149
- return { ...files[0], written: files.some(item => item.written), files };
157
+ const fonts = fontsFile(options);
158
+ const removed = !fontsText(options, inventory.tokens) && existsSync(fonts);
159
+ if (removed) rmSync(fonts);
160
+ return { ...files[0], written: removed || files.some(item => item.written), files };
150
161
  }
@@ -1,8 +1,10 @@
1
- import { contextValues, defaultThemes, resolveValue } from "./themes.mjs";
1
+ import { contextValues, defaultThemes } from "./themes.mjs";
2
+ import { paletteContexts, resolveColorToken } from "./palette-generated.mjs";
2
3
  import { findingSeverity } from "./finding-rules.mjs";
3
4
 
4
5
  /** Accessibility and rhythm reviews of token values: WCAG contrast between the roles that
5
- * meet on screen, in every theme, and spacing steps on the 2 px grid. Both are errors. */
6
+ * meet on screen, in every theme and brand, and spacing steps on the 2 px grid. Both are
7
+ * errors; a contrast pair ADS cannot resolve statically is an info item. */
6
8
 
7
9
  const named = { white: [255, 255, 255, 1], black: [0, 0, 0, 1] };
8
10
 
@@ -38,7 +40,7 @@ const luminance = ([r, g, b]) => {
38
40
  const channel = value => { value /= 255; return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4; };
39
41
  return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
40
42
  };
41
- const over = (top, bottom) => [0, 1, 2].map(index => top[index] * top[3] + bottom[index] * (1 - top[3])).concat(1);
43
+ export const over = (top, bottom) => [0, 1, 2].map(index => top[index] * top[3] + bottom[index] * (1 - top[3])).concat(1);
42
44
  /** WCAG 2 contrast ratio of a foreground over an opaque background. */
43
45
  export function contrastRatio(foreground, background) {
44
46
  const [a, b] = [luminance(over(foreground, background)), luminance(background)];
@@ -48,7 +50,7 @@ export function contrastRatio(foreground, background) {
48
50
  const textBackgrounds = ["--bg-canvas", "--bg-surface", "--bg-raised", "--bg-field", "--bg-hover"];
49
51
  /** The roles that meet on screen. Text needs 4.5:1 (WCAG 1.4.3); focus indicators and the
50
52
  * borders that identify controls need 3:1 (1.4.11). */
51
- function contrastPairs(names) {
53
+ export function contrastPairs(names) {
52
54
  const pairs = [];
53
55
  for (const text of ["--text-strong", "--text-body", "--text-muted", "--text-link", "--accent-text"]) for (const background of textBackgrounds) pairs.push([text, background, 4.5]);
54
56
  pairs.push(["--accent-fg", "--accent", 4.5], ["--accent-fg", "--accent-hover", 4.5]);
@@ -57,32 +59,67 @@ function contrastPairs(names) {
57
59
  return pairs.filter(([foreground, background]) => names.has(foreground) && names.has(background));
58
60
  }
59
61
 
62
+ export const contrastLabel = ({ theme, brand }) => brand === undefined ? `the ${theme.name} theme` : `the ${theme.name} theme of brand "${brand}"`;
63
+ const sameEntry = (first, second) => first?.color && second?.color ? first.color.every((value, index) => value === second.color[index]) : !first?.color && !second?.color && first?.value === second?.value;
64
+
65
+ /** Every theme × brand context with a cached color resolver. `color(name)` resolves in the
66
+ * context; `changed(name)` tells whether a brand other than the default changes the token from
67
+ * the theme's default value (always true for the default brand); `canvas` is the opaque
68
+ * --bg-canvas a translucent background composites over; `opaque(entry, name)` composites it. */
69
+ export function contrastContexts(tokens, themes = defaultThemes, brands = []) {
70
+ const defaults = new Map(themes.map(theme => [theme.name, contextValues(tokens, { theme: theme.name, themes })]));
71
+ return paletteContexts({ themes, brands }).map(context => {
72
+ const { theme, brand } = context, scheme = theme.scheme, own = brand === undefined;
73
+ const values = own ? defaults.get(theme.name) : contextValues(tokens, { theme: theme.name, brand, themes });
74
+ const resolved = new Map(), base = new Map();
75
+ const color = (name, from = values, cache = resolved) => { if (!cache.has(name)) cache.set(name, resolveColorToken(from, name, scheme)); return cache.get(name); };
76
+ const canvasEntry = color("--bg-canvas");
77
+ const canvas = canvasEntry?.color ? over(canvasEntry.color, [255, 255, 255, 1]) : [255, 255, 255, 1];
78
+ return { context, label: contrastLabel(context), own, values, color: name => color(name),
79
+ changed: name => own || !sameEntry(color(name), color(name, defaults.get(theme.name), base)),
80
+ canvas, opaque: (entry, name) => entry.color[3] < 1 ? over(entry.color, name === "--bg-canvas" ? [255, 255, 255, 1] : canvas) : entry.color };
81
+ });
82
+ }
83
+
84
+ /** WCAG contrast of every role pair in every theme of every brand. Colors resolve the way the
85
+ * generated palette resolves them (resolveColorToken: the per-theme halves, aliases and var()
86
+ * fallbacks, light-dark() by the theme's scheme, every CSS color syntax and color-mix(), clipped
87
+ * to sRGB). WCAG compares opaque colors, so alpha is composited as the page paints it: a
88
+ * translucent background over --bg-canvas (the canvas itself over white), then a translucent
89
+ * foreground over that background. A brand other than the default reports only the pairs whose
90
+ * colors it changes. A pair color that cannot be resolved statically (currentColor, relative
91
+ * color syntax, a system color, a non-color value) is reported once per token and value as a
92
+ * token-contrast-unresolved info item instead of being checked. */
60
93
  export function tokenContrastAdvisories(tokens, themes = defaultThemes, brands = []) {
61
94
  const names = new Set(tokens.map(token => token.name));
62
- const advisories = [];
95
+ const advisories = [], unresolved = new Map();
63
96
  const pairs = contrastPairs(names);
64
- // Every brand in every theme; a brand other than the default reports only the pairs it changes.
65
- for (const { name: scope } of themes) {
66
- const defaults = contextValues(tokens, { theme: scope, themes });
67
- for (const brand of brands.length ? brands.map(item => item.name) : [undefined]) {
68
- const own = brand === undefined || brand === brands[0].name;
69
- const values = own ? defaults : contextValues(tokens, { theme: scope, brand, themes });
70
- for (const [foreground, background, minimum] of pairs) {
71
- const fore = resolveValue(values, foreground), backValue = resolveValue(values, background);
72
- const front = parseColor(fore ?? ""), back = parseColor(backValue ?? "");
73
- if (!front || !back) continue;
74
- if (!own && fore === resolveValue(defaults, foreground) && backValue === resolveValue(defaults, background)) continue;
75
- const ratio = contrastRatio(front, back[3] < 1 ? over(back, [255, 255, 255, 1]) : back);
76
- if (ratio + 1e-9 >= minimum) continue;
77
- const at = values.get(foreground);
78
- if (!at) continue;
79
- const { file, line, column } = at;
80
- const where = own ? `the ${scope} theme` : `the ${scope} theme of brand "${brand}"`;
81
- advisories.push({ rule: "token-contrast", severity: findingSeverity("token-contrast"), file, line, column, tokens: [foreground, background], guidanceUri: "ads://guides/tokens",
82
- message: `${foreground} on ${background} is ${ratio.toFixed(2)}:1 in ${where}; ${minimum === 4.5 ? "text needs 4.5:1 (WCAG 1.4.3)" : "focus indicators and control borders need 3:1 (WCAG 1.4.11)"}.` });
97
+ for (const { label, values, color, changed, opaque } of contrastContexts(tokens, themes, brands)) {
98
+ for (const [foreground, background, minimum] of pairs) {
99
+ const front = color(foreground), back = color(background);
100
+ if (!front || !back) continue;
101
+ if (!changed(foreground) && !changed(background)) continue;
102
+ const missing = [[foreground, front, background], [background, back, foreground]].filter(([, entry]) => !entry.color);
103
+ for (const [name, entry, partner] of missing) {
104
+ const key = `${name}\u0000${entry.value}`;
105
+ const item = unresolved.get(key) ?? { name, value: entry.value, reason: entry.unresolved ?? "not a color", at: values.get(name), contexts: new Set(), partners: new Set() };
106
+ item.contexts.add(label); item.partners.add(partner);
107
+ unresolved.set(key, item);
83
108
  }
109
+ if (missing.length) continue;
110
+ const ratio = contrastRatio(front.color, opaque(back, background));
111
+ if (ratio + 1e-9 >= minimum) continue;
112
+ const at = values.get(foreground);
113
+ if (!at) continue;
114
+ const { file, line, column } = at;
115
+ advisories.push({ rule: "token-contrast", severity: findingSeverity("token-contrast"), file, line, column, tokens: [foreground, background], guidanceUri: "ads://guides/tokens",
116
+ message: `${foreground} on ${background} is ${ratio.toFixed(2)}:1 in ${label}; ${minimum === 4.5 ? "text needs 4.5:1 (WCAG 1.4.3)" : "focus indicators and control borders need 3:1 (WCAG 1.4.11)"}.` });
84
117
  }
85
118
  }
119
+ for (const { name, value, reason, at, contexts, partners } of unresolved.values()) {
120
+ advisories.push({ rule: "token-contrast-unresolved", severity: findingSeverity("token-contrast-unresolved"), ...(at ? { file: at.file, line: at.line, column: at.column } : {}), tokens: [name, ...partners], guidanceUri: "ads://guides/tokens",
121
+ message: `${name} is ${value} in ${[...contexts].join(", ")}, which ADS cannot resolve to a color statically (${reason}), so its contrast with ${[...partners].join(", ")} is not checked. Set it to a color or a ramp step, or check the pages that use it with ads audit.` });
122
+ }
86
123
  return advisories;
87
124
  }
88
125
 
package/dist/units.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readFileSync, readdirSync } from "node:fs";
2
2
  import path from "node:path";
3
+ import { hasProjectConfig } from "./project-boundary.mjs";
3
4
  import ts from "typescript";
4
5
  import postcss from "postcss";
5
6
  import { adsFileRole, isDevelopmentFile, isInside, scenarioIdentity } from "./config.mjs";
@@ -112,7 +113,7 @@ export function inspectUnits(options) {
112
113
  for (const entry of readdirSync(directory, { withFileTypes: true })) {
113
114
  if (entry.name.startsWith(".") || ["node_modules", "dist", "coverage"].includes(entry.name)) continue;
114
115
  const file = path.join(directory, entry.name);
115
- if (entry.isDirectory()) walk(file);
116
+ if (entry.isDirectory()) { if (!hasProjectConfig(file)) walk(file); }
116
117
  else if (entry.isFile()) files.push(slash(path.relative(dsRoot, file)));
117
118
  }
118
119
  }
@@ -4,6 +4,7 @@ import { mkdtempSync, readFileSync, rmSync } from "node:fs";
4
4
  import { tmpdir } from "node:os";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import path from "node:path";
7
+ import { activeNow, setActiveTimeout } from "./active-clock.mjs";
7
8
  import { projectContext } from "./mcp/context.mjs";
8
9
  import { packageScriptCommand } from "./development-runtime.mjs";
9
10
  import { failure as evidenceFailure } from "./evidence.mjs";
@@ -24,7 +25,7 @@ export function checkCommand(command, args, cwd, signal, input, gate = {category
24
25
  const child = spawn(command, args, { cwd, shell: false, detached: process.platform !== "win32", windowsHide: true, stdio: [input === undefined ? "ignore" : "pipe", "pipe", "pipe"],
25
26
  env: { ...process.env, ...environment, PATH: [path.join(cwd, "node_modules/.bin"), path.dirname(process.execPath), process.env.PATH ?? ""].join(path.delimiter) } });
26
27
  let output = "", failure, guard, done = false;
27
- const startedAt=Date.now();
28
+ const startedAt=activeNow();
28
29
  if (input !== undefined) { child.stdin.on("error", () => {}); child.stdin.end(input); }
29
30
  function kill() {
30
31
  if (!child.pid) return;
@@ -42,15 +43,15 @@ export function checkCommand(command, args, cwd, signal, input, gate = {category
42
43
  }
43
44
  const abort = () => { failure = fail("mutation-cancelled", "Mutation cancelled during validation."); kill(); };
44
45
  signal?.addEventListener("abort", abort, { once: true });
45
- const timer = setTimeout(() => { failure = fail("mutation-check", `${path.basename(command)} ${args.join(" ")} exceeded its ${timeoutMs} ms command budget.`); failure.code="ADS_COMMAND_TIMEOUT"; kill(); }, timeoutMs);
46
+ const timer = setActiveTimeout(() => { failure = fail("mutation-check", `${path.basename(command)} ${args.join(" ")} exceeded its ${timeoutMs} ms command budget.`); failure.code="ADS_COMMAND_TIMEOUT"; kill(); }, timeoutMs);
46
47
  for (const stream of [child.stdout, child.stderr]) stream.on("data", chunk => { output = (output + chunk.toString()).slice(-12000); });
47
48
  child.once("error", error => { failure = error; });
48
49
  child.once("exit", kill); // Also clean up descendants of a finished launcher.
49
50
  child.once("close", async code => {
50
51
  done = true;
51
- clearTimeout(timer); signal?.removeEventListener("abort", abort);
52
+ timer.clear(); signal?.removeEventListener("abort", abort);
52
53
  try{await finishExecutionGuard(guard);}catch(error){failure??=error;}
53
- const detail={command:path.basename(command),args,timeoutMs,elapsedMs:Date.now()-startedAt,exitCode:code};
54
+ const detail={command:path.basename(command),args,timeoutMs,elapsedMs:Math.round(activeNow()-startedAt),exitCode:code};
54
55
  if (failure || code !== 0) {
55
56
  const error=failure??fail("mutation-check", `${path.basename(command)} ${args.join(" ")} failed (${code}).\n${output}`);
56
57
  error.diagnostic={...(error.diagnostic??{rule:"mutation-check",message:error.message}),...detail,output:output.slice(-4000),failure:evidenceFailure(failure?"runner":gate.category,gate.phase,failure?.code??(failure?"ADS_COMMAND_INTERRUPTED":"ADS_COMMAND_EXIT"),{certainty:"observed-boundary"})};
@@ -134,7 +134,7 @@ export function createValidationController(directory, { previewWork } = {}) {
134
134
  checks.push({name:"browser-accessibility-audit",passed:false});
135
135
  diagnostics.push({rule:"browser-audit",message:error.message});
136
136
  }
137
- } else checks.push({name:"browser-accessibility-audit",skipped:true,reason:`Not enabled by ${policy}.browserAudit.`});
137
+ } else checks.push({name:"browser-accessibility-audit",skipped:true,reason:`Turned off by ${policy}.browserAudit: false.`});
138
138
  } catch (error) { diagnostics.push(error.diagnostic ?? {rule:signal.aborted ? "validation-cancelled" : "validation-execution",message:error.message}); }
139
139
  finally { try { await previewHost?.close(); } finally { releasePreview?.();active=undefined;progress=undefined;finish(); } }
140
140
  return complete();
@@ -129,6 +129,32 @@ function auditPaintBindings({ container = document.getElementById("root"), bindi
129
129
  return { ok: !diagnostics.length, complete: !limits.length, verified, diagnostics: diagnostics.slice(0, 40), limits: limits.slice(0, 20), scope: "observed App instances and current input; repeat after updates" };
130
130
  }
131
131
 
132
+ // src/active-clock.mjs
133
+ var realNow = () => performance.now();
134
+ function createActiveClock({ now = realNow, countsSuspend = process.platform !== "linux", beatMs = 1000, jumpMs = 30000 } = {}) {
135
+ let last, suspended = 0, heartbeat;
136
+ const tick = () => {
137
+ const time = now();
138
+ if (last !== undefined && time - last > jumpMs)
139
+ suspended += time - last - beatMs;
140
+ last = time;
141
+ };
142
+ return {
143
+ now() {
144
+ if (!countsSuspend)
145
+ return now();
146
+ if (!heartbeat) {
147
+ heartbeat = setInterval(tick, beatMs);
148
+ heartbeat.unref?.();
149
+ }
150
+ tick();
151
+ return now() - suspended;
152
+ }
153
+ };
154
+ }
155
+ var activeClock = createActiveClock();
156
+ var activeNow = () => activeClock.now();
157
+
132
158
  // src/verification/browser.mjs
133
159
  async function auditBehaviorPaints(frame) {
134
160
  const bindings = await frame.locator("#root").getAttribute("data-ads-paint-bindings");
@@ -183,8 +209,8 @@ async function openPreviewScenario(page, url, scenario, { timeout = 30000 } = {}
183
209
  const verified = new URL(url);
184
210
  verified.searchParams.set("waitFor", "verified");
185
211
  await page.goto(verified.href, { waitUntil: "load", timeout });
186
- const end = Date.now() + timeout;
187
- while (Date.now() < end) {
212
+ const end = activeNow() + timeout;
213
+ while (activeNow() < end) {
188
214
  for (const frame of page.frames().filter((frame) => frame !== page.mainFrame())) {
189
215
  const state = await frame.evaluate(() => {
190
216
  const data = document.documentElement.dataset;
@@ -8,6 +8,7 @@ import ts from "typescript";
8
8
  import postcss from "postcss";
9
9
  import valueParser from "postcss-value-parser";
10
10
  import { loadConfig, sourceFiles, isInside } from "./config.mjs";
11
+ import { activeNow, setActiveTimeout } from "./active-clock.mjs";
11
12
  import { importResolver } from "./boundaries.mjs";
12
13
  import { inspectUnits, configurationFiles } from "./units.mjs";
13
14
  import { inspectBehaviors } from "./behaviors.mjs";
@@ -197,7 +198,7 @@ export function executeDevelopmentCommand(profile, args, root, env, signal) {
197
198
  return new Promise((resolve, reject) => {
198
199
  const label = profile.label ?? "Behavior verification";
199
200
  if (signal.aborted) { reject(new Error(`${label} cancelled.`)); return; }
200
- const startedAt = Date.now(), timeoutMs = profile.timeoutMs ?? 60000;
201
+ const startedAt = activeNow(), timeoutMs = profile.timeoutMs ?? 60000;
201
202
  let output = "", failure, child, guard, done = false;
202
203
  const kill = () => {
203
204
  if (!child?.pid) return;
@@ -215,14 +216,14 @@ export function executeDevelopmentCommand(profile, args, root, env, signal) {
215
216
  }
216
217
  const abort = () => { failure = Object.assign(new Error(`${label} cancelled.`), { reason: "cancelled" }); kill(); };
217
218
  signal.addEventListener("abort", abort, { once: true });
218
- const timeout = setTimeout(() => { failure = Object.assign(new Error(`${label} timed out after ${timeoutMs} ms for the complete profile run, not each check.`), { reason: "timeout", timeoutMs }); kill(); }, timeoutMs);
219
+ const timeout = setActiveTimeout(() => { failure = Object.assign(new Error(`${label} timed out after ${timeoutMs} ms for the complete profile run, not each check.`), { reason: "timeout", timeoutMs }); kill(); }, timeoutMs);
219
220
  for (const stream of [child.stdout, child.stderr]) stream.on("data", chunk => { output = (output + chunk.toString()).slice(-12000); });
220
221
  child.once("error", error => { failure = error; });
221
222
  child.once("exit", kill);
222
223
  child.once("close", async code => {
223
- done = true; kill(); clearTimeout(timeout); signal.removeEventListener("abort", abort);
224
+ done = true; kill(); timeout.clear(); signal.removeEventListener("abort", abort);
224
225
  try{await finishExecutionGuard(guard);}catch(error){failure??=error;}
225
- const elapsedMs = Date.now() - startedAt;
226
+ const elapsedMs = Math.round(activeNow() - startedAt);
226
227
  if (failure) reject(Object.assign(failure, { output, elapsedMs }));
227
228
  else resolve({ code, output, elapsedMs });
228
229
  });
package/docs/ADS.md CHANGED
@@ -280,7 +280,10 @@ properties/probes; it does not invent missing semantics.
280
280
  screen, in every theme and brand, through aliases) and `token-rhythm` (`--space-N` = N × 2
281
281
  px) are errors; `token-overlap-review` (equal values within one token family) is a review
282
282
  item. The accessibility guards (`a11y-*`) read tokens and runtime component source;
283
- `ads audit` adds axe-core in the rendered scenarios (`a11y-axe`). `ads tokens
283
+ `component-contrast` checks the color pairs components set themselves, and
284
+ `layout-fixed-width` fails fixed widths built from spacing tokens. `ads audit` adds axe-core
285
+ in the rendered scenarios (`a11y-axe`), non-text contrast (`a11y-non-text-contrast`) and
286
+ overflow at 390, 768 and 1280 px (`layout-overflow`). `ads tokens
284
287
  --format dtcg` exports the tokens as W3C Design Tokens JSON. See the
285
288
  [token guide](../skills/ads-designer/references/design-data.md) and the
286
289
  [accessibility guide](../skills/ads-designer/references/accessibility.md).
@@ -747,8 +747,9 @@ their size with text, and an icon-only button always has a label. The showcase r
747
747
  glyph set itself in its Icons tab, from the folder and the same default attributes the
748
748
  module uses, so a set is reviewed without a project scenario. Other products' logos
749
749
  live in `assets/logos/`, outside both the brand artwork and the glyph set: they keep their
750
- owners' colors, render as images (or a mask silhouette for a muted use), and ADS generates
751
- and checks nothing there.
750
+ owners' colors, render as images, and are never muted, tinted or recolored (a one-color mask
751
+ only where the owner's rules allow it, in the colors they name). ADS generates and checks
752
+ nothing there.
752
753
 
753
754
  ## Build checks keep the architecture in place
754
755
 
@@ -783,7 +784,8 @@ instead of asking the browser to normalize a color per drawn item.
783
784
  ADS findings are errors, review items or info items. An error is a rule ADS can decide: it
784
785
  fails `ads check`, validation and acceptance, and no setting turns it off. Token, theme, brand,
785
786
  glyph and accessibility rules read from tokens and source are errors: contrast between the
786
- roles that meet on screen in every theme and brand, the 2 px spacing rhythm, theme and brand
787
+ roles that meet on screen and the color pairs components set themselves, in every theme and
788
+ brand, the 2 px spacing rhythm, fixed widths built from spacing tokens, theme and brand
787
789
  coverage, brand artwork that is undescribed, unlicensed or unpreviewed, glyphs off the
788
790
  shared viewBox or with fixed colors, controls padded off their size, target size, focus,
789
791
  text resize, reduced motion, text spacing, image alternatives and icon-only controls. A
@@ -792,6 +794,14 @@ equal token values with possibly different roles, keyboard reach, unused artwork
792
794
  in a render path); it is shown with guidance and never blocks. An info item notes an analysis
793
795
  limit. Stale or hand-edited generated outputs are errors, since they ship.
794
796
 
797
+ Widths are fluid on the grid. A fixed length above the 48 px control and icon range, by
798
+ arithmetic on spacing tokens or not, is an error wherever a component, pattern or composition
799
+ sets a width. A project names its width tokens (`layout.widthTokens`) and the owners
800
+ that float above the layout (`layout.fixedWidthUnits`) in `ds.config.json`; ADS knows a unit's
801
+ layer, not whether it is an overlay, and there is no per-declaration exception. The browser
802
+ audit adds what source cannot show: axe-core, non-text contrast of control borders and icons,
803
+ and horizontal overflow at 390, 768 and 1280 px, by resizing each rendered scenario.
804
+
795
805
  Static checks establish the policies and source formats they cover. Behavior
796
806
  tests and browser review verify the resulting accessibility, layout, themes,
797
807
  states, and motion. Both forms of verification support agent-driven iteration.