@reqvire-org/ads 0.3.49 → 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.
- package/README.md +36 -6
- package/dist/active-clock.mjs +34 -0
- package/dist/assets.mjs +20 -2
- package/dist/boundaries.mjs +2 -0
- package/dist/browser-audit/layout-overflow.mjs +57 -0
- package/dist/browser-audit/layout-shift.mjs +32 -0
- package/dist/browser-audit/non-text-contrast.mjs +87 -0
- package/dist/browser-audit/worker.mjs +36 -7
- package/dist/browser-audit.mjs +198 -22
- package/dist/check.mjs +14 -1
- package/dist/cli.mjs +7 -4
- package/dist/component-contrast.mjs +138 -0
- package/dist/config.mjs +12 -6
- package/dist/finding-rules.mjs +11 -1
- package/dist/fonts-generated.mjs +85 -0
- package/dist/image-attributes.mjs +110 -0
- package/dist/init.mjs +2 -0
- package/dist/layout-widths.mjs +184 -0
- package/dist/mcp/context.mjs +1 -1
- package/dist/mcp/mutations.mjs +7 -5
- package/dist/mcp/preview-watch.mjs +9 -8
- package/dist/mcp/server.mjs +6 -4
- package/dist/preview-files.mjs +3 -0
- package/dist/project-boundary.mjs +23 -0
- package/dist/project-documents.mjs +2 -1
- package/dist/scenarios-compiler.mjs +23 -3
- package/dist/showcase/client.bundle.js +11 -11
- package/dist/showcase/icons.js +5 -5
- package/dist/showcase/style.css +1 -1
- package/dist/skills/ads-break-ui/SKILL.md +8 -0
- package/dist/skills/ads-break-ui/references/atomic-styles.md +2 -0
- package/dist/skills/ads-break-ui/references/design-data.md +39 -0
- package/dist/skills/ads-break-ui/references/drafts.md +1 -1
- package/dist/skills/ads-break-ui/references/guarded-editing.md +1 -1
- package/dist/skills/ads-break-ui/references/validation.md +9 -5
- package/dist/skills/ads-designer/SKILL.md +24 -4
- package/dist/skills/ads-designer/references/accessibility.md +30 -13
- package/dist/skills/ads-designer/references/atomic-styles.md +2 -0
- package/dist/skills/ads-designer/references/branding.md +10 -5
- package/dist/skills/ads-designer/references/cli.md +2 -1
- package/dist/skills/ads-designer/references/design-data.md +39 -0
- package/dist/skills/ads-designer/references/drafts.md +1 -1
- package/dist/skills/ads-designer/references/guarded-editing.md +1 -1
- package/dist/skills/ads-designer/references/mobile.md +3 -0
- package/dist/skills/ads-designer/references/performance.md +89 -0
- package/dist/skills/ads-designer/references/validation.md +9 -5
- package/dist/skills/ads-import/references/atomic-styles.md +2 -0
- package/dist/skills/ads-import/references/cli.md +2 -1
- package/dist/skills/ads-import/references/design-data.md +39 -0
- package/dist/skills/ads-import/references/drafts.md +1 -1
- package/dist/skills/ads-import/references/guarded-editing.md +1 -1
- package/dist/skills/ads-import/references/validation.md +9 -5
- package/dist/skills/ads-motion/references/atomic-styles.md +2 -0
- package/dist/skills/ads-motion/references/design-data.md +39 -0
- package/dist/skills/ads-motion/references/drafts.md +1 -1
- package/dist/skills/ads-motion/references/guarded-editing.md +1 -1
- package/dist/skills/ads-motion/references/validation.md +9 -5
- package/dist/skills/ads-port/references/atomic-styles.md +2 -0
- package/dist/skills/ads-port/references/cli.md +2 -1
- package/dist/skills/ads-port/references/design-data.md +39 -0
- package/dist/skills/ads-port/references/drafts.md +1 -1
- package/dist/skills/ads-port/references/guarded-editing.md +1 -1
- package/dist/skills/ads-port/references/validation.md +9 -5
- package/dist/starters/preact/ds.config.json +1 -0
- package/dist/starters/preact/package.json +1 -0
- package/dist/starters/react/ADS.md +1 -1
- package/dist/starters/react/README.md +14 -2
- package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +1 -1
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.fixture.ts +2 -0
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.scenario.tsx +13 -0
- package/dist/starters/react/design-system/components/Content/Image/Image.tsx +48 -0
- package/dist/starters/react/design-system/components/Content/Image/README.md +20 -0
- package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +2 -2
- package/dist/starters/react/design-system/index.ts +1 -0
- package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +16 -0
- package/dist/starters/react/design-system/tokens/spacing.css +18 -0
- package/dist/starters/react/ds.config.json +1 -0
- package/dist/starters/react/package-lock.json +47 -0
- package/dist/starters/react/package.json +2 -1
- package/dist/test-boundaries.mjs +30 -1
- package/dist/themes-generated.mjs +15 -4
- package/dist/token-quality.mjs +27 -17
- package/dist/units.mjs +2 -1
- package/dist/validation-checks.mjs +5 -4
- package/dist/validation.mjs +1 -1
- package/dist/verification/browser.mjs +28 -2
- package/dist/verification.mjs +5 -4
- package/docs/ADS.md +4 -1
- package/docs/ARCHITECTURE.md +13 -3
- package/docs/CHANGELOG.md +92 -12
- package/docs/GUIDE.md +208 -14
- package/docs/MCP.md +14 -10
- package/package.json +1 -1
package/dist/test-boundaries.mjs
CHANGED
|
@@ -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" ||
|
|
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
|
|
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
|
-
|
|
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
|
}
|
package/dist/token-quality.mjs
CHANGED
|
@@ -40,7 +40,7 @@ const luminance = ([r, g, b]) => {
|
|
|
40
40
|
const channel = value => { value /= 255; return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4; };
|
|
41
41
|
return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
|
|
42
42
|
};
|
|
43
|
-
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);
|
|
44
44
|
/** WCAG 2 contrast ratio of a foreground over an opaque background. */
|
|
45
45
|
export function contrastRatio(foreground, background) {
|
|
46
46
|
const [a, b] = [luminance(over(foreground, background)), luminance(background)];
|
|
@@ -50,7 +50,7 @@ export function contrastRatio(foreground, background) {
|
|
|
50
50
|
const textBackgrounds = ["--bg-canvas", "--bg-surface", "--bg-raised", "--bg-field", "--bg-hover"];
|
|
51
51
|
/** The roles that meet on screen. Text needs 4.5:1 (WCAG 1.4.3); focus indicators and the
|
|
52
52
|
* borders that identify controls need 3:1 (1.4.11). */
|
|
53
|
-
function contrastPairs(names) {
|
|
53
|
+
export function contrastPairs(names) {
|
|
54
54
|
const pairs = [];
|
|
55
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]);
|
|
56
56
|
pairs.push(["--accent-fg", "--accent", 4.5], ["--accent-fg", "--accent-hover", 4.5]);
|
|
@@ -59,9 +59,28 @@ function contrastPairs(names) {
|
|
|
59
59
|
return pairs.filter(([foreground, background]) => names.has(foreground) && names.has(background));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const
|
|
62
|
+
export const contrastLabel = ({ theme, brand }) => brand === undefined ? `the ${theme.name} theme` : `the ${theme.name} theme of brand "${brand}"`;
|
|
63
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
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
|
+
|
|
65
84
|
/** WCAG contrast of every role pair in every theme of every brand. Colors resolve the way the
|
|
66
85
|
* generated palette resolves them (resolveColorToken: the per-theme halves, aliases and var()
|
|
67
86
|
* fallbacks, light-dark() by the theme's scheme, every CSS color syntax and color-mix(), clipped
|
|
@@ -75,35 +94,26 @@ export function tokenContrastAdvisories(tokens, themes = defaultThemes, brands =
|
|
|
75
94
|
const names = new Set(tokens.map(token => token.name));
|
|
76
95
|
const advisories = [], unresolved = new Map();
|
|
77
96
|
const pairs = contrastPairs(names);
|
|
78
|
-
const
|
|
79
|
-
for (const context of paletteContexts({ themes, brands })) {
|
|
80
|
-
const { theme, brand } = context, scheme = theme.scheme;
|
|
81
|
-
const own = brand === undefined;
|
|
82
|
-
const values = own ? defaults.get(theme.name) : contextValues(tokens, { theme: theme.name, brand, themes });
|
|
83
|
-
const resolved = new Map(), base = new Map();
|
|
84
|
-
const color = (name, from = values, cache = resolved) => { if (!cache.has(name)) cache.set(name, resolveColorToken(from, name, scheme)); return cache.get(name); };
|
|
85
|
-
const canvasEntry = color("--bg-canvas");
|
|
86
|
-
const canvas = canvasEntry?.color ? over(canvasEntry.color, [255, 255, 255, 1]) : [255, 255, 255, 1];
|
|
97
|
+
for (const { label, values, color, changed, opaque } of contrastContexts(tokens, themes, brands)) {
|
|
87
98
|
for (const [foreground, background, minimum] of pairs) {
|
|
88
99
|
const front = color(foreground), back = color(background);
|
|
89
100
|
if (!front || !back) continue;
|
|
90
|
-
if (!
|
|
101
|
+
if (!changed(foreground) && !changed(background)) continue;
|
|
91
102
|
const missing = [[foreground, front, background], [background, back, foreground]].filter(([, entry]) => !entry.color);
|
|
92
103
|
for (const [name, entry, partner] of missing) {
|
|
93
104
|
const key = `${name}\u0000${entry.value}`;
|
|
94
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() };
|
|
95
|
-
item.contexts.add(label
|
|
106
|
+
item.contexts.add(label); item.partners.add(partner);
|
|
96
107
|
unresolved.set(key, item);
|
|
97
108
|
}
|
|
98
109
|
if (missing.length) continue;
|
|
99
|
-
const
|
|
100
|
-
const ratio = contrastRatio(front.color, opaqueBack);
|
|
110
|
+
const ratio = contrastRatio(front.color, opaque(back, background));
|
|
101
111
|
if (ratio + 1e-9 >= minimum) continue;
|
|
102
112
|
const at = values.get(foreground);
|
|
103
113
|
if (!at) continue;
|
|
104
114
|
const { file, line, column } = at;
|
|
105
115
|
advisories.push({ rule: "token-contrast", severity: findingSeverity("token-contrast"), file, line, column, tokens: [foreground, background], guidanceUri: "ads://guides/tokens",
|
|
106
|
-
message: `${foreground} on ${background} is ${ratio.toFixed(2)}:1 in ${label
|
|
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)"}.` });
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
119
|
for (const { name, value, reason, at, contexts, partners } of unresolved.values()) {
|
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=
|
|
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 =
|
|
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
|
-
|
|
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:
|
|
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"})};
|
package/dist/validation.mjs
CHANGED
|
@@ -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:`
|
|
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 =
|
|
187
|
-
while (
|
|
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;
|
package/dist/verification.mjs
CHANGED
|
@@ -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 =
|
|
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 =
|
|
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();
|
|
224
|
+
done = true; kill(); timeout.clear(); signal.removeEventListener("abort", abort);
|
|
224
225
|
try{await finishExecutionGuard(guard);}catch(error){failure??=error;}
|
|
225
|
-
const elapsedMs =
|
|
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
|
-
`
|
|
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).
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -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
|
|
751
|
-
|
|
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
|
|
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.
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -1,34 +1,114 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.3.
|
|
3
|
+
## 0.3.50
|
|
4
4
|
|
|
5
5
|
<!-- ads-local-tests:start -->
|
|
6
|
-
Local verification: **
|
|
7
|
-
Tested commit: `
|
|
8
|
-
Completed 2026-
|
|
6
|
+
Local verification: **749/749 passed** with `ADS_TEST_BUN=1 npm test`.
|
|
7
|
+
Tested commit: `1c5feb7757a66ac1554f9b5a30a2281c1a722912`; Node v24.13.0, Bun 1.4.1.
|
|
8
|
+
Completed 2026-11-01T14:41:43.097Z (10116 seconds).
|
|
9
9
|
|
|
10
10
|
<!-- ads-local-test-proof
|
|
11
11
|
{
|
|
12
12
|
"schema": 1,
|
|
13
|
-
"version": "0.3.
|
|
14
|
-
"commit": "
|
|
15
|
-
"sourceSha256": "
|
|
13
|
+
"version": "0.3.50",
|
|
14
|
+
"commit": "1c5feb7757a66ac1554f9b5a30a2281c1a722912",
|
|
15
|
+
"sourceSha256": "66fffd1f9221e62bdf6239b4c197287a0591222d59f801293c4087a72ba566b0",
|
|
16
16
|
"command": "ADS_TEST_BUN=1 npm test",
|
|
17
17
|
"result": "pass",
|
|
18
|
-
"tests":
|
|
19
|
-
"pass":
|
|
18
|
+
"tests": 749,
|
|
19
|
+
"pass": 749,
|
|
20
20
|
"fail": 0,
|
|
21
21
|
"cancelled": 0,
|
|
22
22
|
"skipped": 0,
|
|
23
23
|
"node": "v24.13.0",
|
|
24
24
|
"bun": "1.4.1",
|
|
25
|
-
"completedAt": "2026-
|
|
26
|
-
"durationMs":
|
|
27
|
-
"logSha256": "
|
|
25
|
+
"completedAt": "2026-11-01T14:41:43.097Z",
|
|
26
|
+
"durationMs": 10116397,
|
|
27
|
+
"logSha256": "946ed64845491a398ddef1f17189fc9024b8959fbc67071d4e3c5e6c8da4adb0"
|
|
28
28
|
}
|
|
29
29
|
-->
|
|
30
30
|
<!-- ads-local-tests:end -->
|
|
31
31
|
|
|
32
|
+
- **Images reserve space and choose how they load.** New `img-attributes` error for a raw `<img>`
|
|
33
|
+
without `loading`, or without dimensions, in components, patterns and compositions. A spread or
|
|
34
|
+
a class from elsewhere is an `img-attributes-unresolved` info item. A `srcset` with width
|
|
35
|
+
descriptors and no `sizes` is an error too, on `<img>` and the project's `Image`. Starters gain
|
|
36
|
+
an `Image` component, lazy by default, with `priority` for the view's main visible image and
|
|
37
|
+
optional `srcset` and `sizes`.
|
|
38
|
+
- **Image budgets.** New `asset-image-budget` error for images in `assets/`: SVG 100 KB, WebP and
|
|
39
|
+
AVIF 300 KB, JPEG 400 KB, PNG and GIF 500 KB. `assets.imageBudgetKb` sets one limit for all.
|
|
40
|
+
- **Layout shift in the audit.** New `layout-shift` error above 0.1 Cumulative Layout Shift on a
|
|
41
|
+
scenario's first render, with `worstLayoutShift` in the result.
|
|
42
|
+
- **Font preloads.** When body or heading text uses a font from `tokens/fonts.css`, `ads assets`
|
|
43
|
+
writes `tokens/fonts.preload.generated.ts` with those files; call `preloadFonts()` in the app
|
|
44
|
+
entry. Run `ads assets` after upgrading: `ads check` fails while it is missing or stale.
|
|
45
|
+
- **Performance guide.** `ads://guides/performance` covers image formats, responsive images, the
|
|
46
|
+
priority rule and image preloads, font loading, CSS delivery, layout shift, and what stays with
|
|
47
|
+
the application and Lighthouse. ADS generates no images and no image preloads.
|
|
48
|
+
- **The browser accessibility audit is on by default.** `acceptance.browserAudit` and
|
|
49
|
+
`validation.browserAudit` default to `true`: `ads validate` (both policies), `ads_validate`,
|
|
50
|
+
`ads_accept`, `ads_apply_patch` and `ads_apply_transaction` run the axe-core audit, and
|
|
51
|
+
any `a11y-axe` error fails them. Set `"browserAudit": false` in a policy to turn its audit
|
|
52
|
+
off. Projects that relied on the old default now see `a11y-axe` errors; fix each in the
|
|
53
|
+
component that renders the failing element.
|
|
54
|
+
- **A missing browser fails with what to install.** Without project Playwright the
|
|
55
|
+
`browser-audit` error says to run `npm install -D @playwright/test` and
|
|
56
|
+
`npx playwright install chromium` (Bun: `bun add -d @playwright/test` and
|
|
57
|
+
`bunx playwright install chromium`); without Playwright's browser it says to run
|
|
58
|
+
`npx playwright install chromium` or to select an installed Chrome with
|
|
59
|
+
`mcp.capture.channel "chrome"`.
|
|
60
|
+
- **New projects declare Playwright.** Both starters list `@playwright/test` in
|
|
61
|
+
`devDependencies`, and `ads init` adds it when the project has neither `@playwright/test`
|
|
62
|
+
nor `playwright`. After `npm install`, run `npx playwright install chromium` once;
|
|
63
|
+
`ads create` prints that step in its next commands.
|
|
64
|
+
- **Components' own color pairs are checked.** New `component-contrast` error: where a
|
|
65
|
+
component or pattern style block (including a nested state such as `&:hover` or
|
|
66
|
+
`&[aria-selected="true"]`) sets both `color` and `background` to tokens, the pair needs
|
|
67
|
+
4.5:1 in every theme and brand, such as `--success` as text on `--success-bg`. Disabled
|
|
68
|
+
states are exempt; a side that names no color token is a `component-contrast-unresolved`
|
|
69
|
+
info item. Fix with `--x-text` on `--x-bg` or `--x-fg` on `--x`.
|
|
70
|
+
- **The audit checks non-text contrast (WCAG 1.4.11).** New `a11y-non-text-contrast` error,
|
|
71
|
+
which axe does not cover: a field or other control without its own text or icon, whose
|
|
72
|
+
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
|
|
73
|
+
against its background. Disabled controls are exempt. Outline fields and controls with
|
|
74
|
+
`--border-strong`.
|
|
75
|
+
- **Widths are fluid on the grid.** New `layout-fixed-width` error: in component, pattern and
|
|
76
|
+
composition styles, a width, `flex-basis` or grid track fixed above 48 px, by arithmetic on
|
|
77
|
+
spacing tokens or not, fails `ads check`. New `layout.widthTokens` names allowed width
|
|
78
|
+
tokens, which must be fluid (a fixed `--container-*` or `--content-max` token is a cap, valid
|
|
79
|
+
only as a maximum), and `layout.fixedWidthUnits` names owners with fixed widths, such as overlays.
|
|
80
|
+
Projects with fixed widths now see errors; use a `--grid-span-N` token in a container query,
|
|
81
|
+
`%` or `fr`, or a `ch` measure.
|
|
82
|
+
- **The audit finds horizontal overflow.** New `layout-overflow` error: every UI scenario is
|
|
83
|
+
resized to 390, 768 and 1280 px, and page overflow, elements past the viewport and clipped
|
|
84
|
+
content fail it. Scrollers and `text-overflow: ellipsis` are exempt.
|
|
85
|
+
- **Starters have grid-span tokens.** `--grid-span-1` to `--grid-span-16` are fluid widths of N
|
|
86
|
+
of 16 columns, and both starters declare `layout.widthTokens`.
|
|
87
|
+
- **Other products' logos are shown as they are.** The showcase's Icons tab shows each file in
|
|
88
|
+
`assets/logos/` unchanged, on a white and a black tile, with no muted version. The guides now say:
|
|
89
|
+
never mute, tint or recolor another product's logo; use a one-color version only where its
|
|
90
|
+
owner's published rules allow it and in the colors they name; a quieter version needs the
|
|
91
|
+
owner's rule or written permission; record each file's source and rule in
|
|
92
|
+
`assets/logos/README.md`.
|
|
93
|
+
- **Nested projects stay separate.** A subfolder with its own `ds.config.json` is its own
|
|
94
|
+
project: check, validation, audits, previews, watches and token and scenario discovery stop
|
|
95
|
+
there.
|
|
96
|
+
- **Fewer false findings on files that do not run.** A declaration file (`.d.ts`, `.d.mts`) no
|
|
97
|
+
longer fails `showcase-import`, and `@ads:` text marks a test only in a test call's title or
|
|
98
|
+
tag, not in data, comments or a generated fixture's source. Indirect tags still count.
|
|
99
|
+
- **One flaky preview no longer ends an audit.** A render that fails because the preview dropped
|
|
100
|
+
or was slow is retried on its own, up to 3 attempts, and the rest keep their results. Retried
|
|
101
|
+
passes are listed under `retries`. A scenario that still fails is a `browser-audit` error
|
|
102
|
+
naming it and the last cause, beside any findings, in `ads audit`, `ads validate` and MCP
|
|
103
|
+
acceptance.
|
|
104
|
+
- **Time limits ignore sleep.** Build, command, behavior-check and readiness budgets count time
|
|
105
|
+
the machine is awake, so a laptop suspended during a build no longer fails it.
|
|
106
|
+
- The [guide](GUIDE.md#checks-and-guards) has a **Checks and guards** section: finding
|
|
107
|
+
kinds, gates, the browser audit and how to turn it off, contrast pairs and thresholds,
|
|
108
|
+
themes and brands, tokens, architecture and behavior.
|
|
109
|
+
|
|
110
|
+
## 0.3.49
|
|
111
|
+
|
|
32
112
|
- **`token-contrast` checks every CSS color syntax.** It used to read only hex, `rgb()` and
|
|
33
113
|
`hsl()` and skipped every other value without a word, so projects whose ramps are `oklch()`
|
|
34
114
|
got no static contrast checking. It now resolves each pair the way the generated palette
|