@reqvire-org/ads 0.3.45 → 0.3.46
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 +3 -1
- package/dist/a11y.mjs +100 -0
- package/dist/assets.mjs +25 -1
- package/dist/capture/worker.mjs +1 -1
- package/dist/capture-store.mjs +2 -1
- package/dist/capture.mjs +5 -2
- package/dist/check.mjs +2 -1
- package/dist/cli.mjs +12 -0
- package/dist/config.mjs +3 -0
- package/dist/contracts/tokens.json +1 -1
- package/dist/design-values.mjs +8 -2
- package/dist/foundation.mjs +3 -0
- package/dist/mcp/apps.mjs +1 -1
- package/dist/mcp/preview-widget.bundle.js +19 -13
- package/dist/mcp/project-widget.bundle.js +25 -25
- package/dist/mcp/server.mjs +3 -1
- package/dist/mcp/widget.bundle.js +15 -15
- package/dist/preview-resources.mjs +1 -1
- package/dist/showcase/client.bundle.js +25 -25
- package/dist/showcase/index.html +1 -1
- package/dist/skills/ads-break-ui/references/captures.md +3 -2
- package/dist/skills/ads-break-ui/references/design-data.md +89 -0
- package/dist/skills/ads-designer/SKILL.md +13 -3
- package/dist/skills/ads-designer/references/accessibility.md +43 -0
- package/dist/skills/ads-designer/references/branding.md +28 -0
- package/dist/skills/ads-designer/references/captures.md +3 -2
- package/dist/skills/ads-designer/references/design-data.md +89 -0
- package/dist/skills/ads-import/references/captures.md +3 -2
- package/dist/skills/ads-import/references/design-data.md +89 -0
- package/dist/skills/ads-motion/references/build.md +33 -0
- package/dist/skills/ads-motion/references/captures.md +3 -2
- package/dist/skills/ads-motion/references/design-data.md +89 -0
- package/dist/skills/ads-motion/references/motion-review.md +2 -2
- package/dist/skills/ads-port/references/captures.md +3 -2
- package/dist/skills/ads-port/references/design-data.md +89 -0
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +76 -0
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +10 -1
- package/dist/starters/preact/ds.config.json +13 -1
- package/dist/starters/react/README.md +54 -7
- package/dist/starters/react/design-system/assets/glyphs/README.md +12 -0
- package/dist/starters/react/design-system/assets/glyphs/aliases.json +1 -0
- package/dist/starters/react/design-system/assets/glyphs/check.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/chevron-down.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/chevron-right.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/close.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/external-link.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/info.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/menu.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/plus.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/search.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/warning.svg +1 -0
- package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +11 -4
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.fixture.ts +9 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.scenario.tsx +16 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +44 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/README.md +14 -0
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +15 -0
- package/dist/starters/react/design-system/components/Content/Icon/Icon.tsx +42 -0
- package/dist/starters/react/design-system/components/Content/Icon/README.md +16 -0
- package/dist/starters/react/design-system/components/Content/Icon/glyphs.ts +17 -0
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.tsx +9 -5
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +12 -0
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +17 -0
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +75 -0
- package/dist/starters/react/design-system/components/Layout/Grid/README.md +21 -0
- package/dist/starters/react/design-system/index.ts +3 -0
- package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +18 -0
- package/dist/starters/react/design-system/review/index.ts +1 -0
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +10 -1
- package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +114 -8
- package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +23 -0
- package/dist/starters/react/design-system/tokens/{SpaceTypeMotion.ads.scenario.tsx → Layout.ads.scenario.tsx} +1 -1
- package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +18 -0
- package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +4 -0
- package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +30 -0
- package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +4 -0
- package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +37 -0
- package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +4 -0
- package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +29 -0
- package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +4 -0
- package/dist/starters/react/design-system/tokens/base.css +6 -3
- package/dist/starters/react/design-system/tokens/colors.css +220 -26
- package/dist/starters/react/design-system/tokens/elevation.css +51 -6
- package/dist/starters/react/design-system/tokens/spacing.css +67 -3
- package/dist/starters/react/design-system/tokens/typography.css +25 -7
- package/dist/starters/react/ds.config.json +13 -1
- package/dist/themes.mjs +106 -0
- package/dist/token-export.mjs +58 -0
- package/dist/token-quality.mjs +109 -0
- package/dist/tokens.mjs +9 -2
- package/docs/ADS.md +34 -5
- package/docs/ARCHITECTURE.md +49 -4
- package/docs/CHANGELOG.md +64 -12
- package/docs/GUIDE.md +31 -3
- package/docs/MCP.md +13 -4
- package/package.json +1 -1
- package/dist/starters/react/design-system/tokens/SpaceTypeMotion.ads.fixture.ts +0 -36
package/README.md
CHANGED
|
@@ -358,7 +358,9 @@ There are two different starting points in this checkout:
|
|
|
358
358
|
|
|
359
359
|
- [starters/react/](starters/react/README.md) is the React application starter, and
|
|
360
360
|
[starters/preact/](starters/preact/) the files that replace it for Preact:
|
|
361
|
-
token
|
|
361
|
+
a token foundation in six groups (AA contrast in both themes, a 2 px
|
|
362
|
+
rhythm), light and dark themes declared in `ds.config.json` that apply to the page or one
|
|
363
|
+
section, a column grid, an icon set, a brand preview with placeholder artwork, build
|
|
362
364
|
setup, example components, a pattern and a composition, development-only review
|
|
363
365
|
renderers, and a project preview compiler adapter. They ship in the npm package;
|
|
364
366
|
`ads create` copies them into a new project, and `ads init` uses their foundation
|
package/dist/a11y.mjs
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { isDevelopmentFile, isInside, sourceFiles } from "./config.mjs";
|
|
5
|
+
import { parseColor } from "./token-quality.mjs";
|
|
6
|
+
import { baseDefinition } from "./themes.mjs";
|
|
7
|
+
|
|
8
|
+
// Accessibility guards ADS can check without a browser: token values (WCAG target size,
|
|
9
|
+
// focus, text resize, reduced motion, text spacing) and runtime component source (text
|
|
10
|
+
// alternatives, keyboard reach, autoplaying motion). All are advisories with WCAG references.
|
|
11
|
+
|
|
12
|
+
const advisory = (rule, { file, line = 1, column = 1 }, message, tokens) => ({ rule, severity: "warning", file, line, column, ...(tokens ? { tokens } : {}), guidanceUri: "ads://guides/accessibility", message });
|
|
13
|
+
/** Pixels of a px/rem length, or null. */
|
|
14
|
+
const pixels = value => {
|
|
15
|
+
const match = value.trim().match(/^(\d*\.?\d+)(px|rem)$/);
|
|
16
|
+
return match ? Number(match[1]) * (match[2] === "rem" ? 16 : 1) : null;
|
|
17
|
+
};
|
|
18
|
+
const isAlias = value => value.trim().startsWith("var(");
|
|
19
|
+
|
|
20
|
+
/** Token-level guards over the inventory's definitions and the foundation sheet. */
|
|
21
|
+
export function a11yTokenAdvisories(tokens, { foundationFile, root } = {}) {
|
|
22
|
+
const advisories = [];
|
|
23
|
+
const base = baseDefinition;
|
|
24
|
+
for (const token of tokens) {
|
|
25
|
+
const root = base(token);
|
|
26
|
+
if (!root || isAlias(root.value)) continue;
|
|
27
|
+
if (token.name.startsWith("--control-height-")) {
|
|
28
|
+
const size = pixels(root.value);
|
|
29
|
+
if (size !== null && size < 24) advisories.push(advisory("a11y-target-size", root, `${token.name} is ${size}px; pointer targets need at least 24×24 px (WCAG 2.5.8), 44 px where touch is common.`, [token.name]));
|
|
30
|
+
}
|
|
31
|
+
if (token.name === "--focus-w") {
|
|
32
|
+
const size = pixels(root.value);
|
|
33
|
+
if (size !== null && size < 2) advisories.push(advisory("a11y-focus", root, `--focus-w is ${size}px; focus indicators need at least 2 px to stay visible (WCAG 2.4.7, 2.4.13).`, [token.name]));
|
|
34
|
+
}
|
|
35
|
+
// Font sizes, not text colors: a px size ignores the reader's browser font size.
|
|
36
|
+
if (token.name.startsWith("--text-") && !parseColor(root.value) && /\d(?:\.\d+)?px\b/.test(root.value) && !/\d(?:\.\d+)?r?em\b/.test(root.value)) {
|
|
37
|
+
advisories.push(advisory("a11y-text-resize", root, `${token.name} is ${root.value.trim()}; use rem so text follows the reader's font size (WCAG 1.4.4).`, [token.name]));
|
|
38
|
+
}
|
|
39
|
+
if (token.name.startsWith("--dur-") && !/^0(?:m?s)?$/.test(root.value.trim()) && !token.definitions.some(definition => /prefers-reduced-motion/.test(definition.scope))) {
|
|
40
|
+
advisories.push(advisory("a11y-reduced-motion", root, `${token.name} has no value under @media (prefers-reduced-motion: reduce); set it to 0ms there (WCAG 2.3.3).`, [token.name]));
|
|
41
|
+
}
|
|
42
|
+
if (token.name === "--leading-normal") {
|
|
43
|
+
const value = Number(root.value.trim());
|
|
44
|
+
if (Number.isFinite(value) && value < 1.5) advisories.push(advisory("a11y-text-spacing", root, `--leading-normal is ${value}; body text needs a line height of at least 1.5 (WCAG 1.4.8, 1.4.12).`, [token.name]));
|
|
45
|
+
}
|
|
46
|
+
if (token.name === "--content-max") {
|
|
47
|
+
const match = root.value.trim().match(/^(\d*\.?\d+)ch$/);
|
|
48
|
+
if (match && Number(match[1]) > 80) advisories.push(advisory("a11y-text-spacing", root, `--content-max is ${match[1]}ch; keep text lines under 80 characters (WCAG 1.4.8).`, [token.name]));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (foundationFile && existsSync(foundationFile) && !/:focus-visible\b/.test(readFileSync(foundationFile, "utf8"))) {
|
|
52
|
+
advisories.push(advisory("a11y-focus", { file: path.relative(root, foundationFile).replaceAll("\\", "/") }, "The foundation styles no :focus-visible indicator; keyboard users must see where focus is (WCAG 2.4.7)."));
|
|
53
|
+
}
|
|
54
|
+
return advisories;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const nonInteractive = new Set(["div", "span", "p", "li", "section", "article", "td", "img", "header", "footer", "main", "aside"]);
|
|
58
|
+
// Children of composite widgets: the container owns focus (aria-activedescendant or roving).
|
|
59
|
+
const managedRoles = new Set(["option", "menuitem", "menuitemcheckbox", "menuitemradio", "tab", "treeitem", "row", "gridcell"]);
|
|
60
|
+
/** Source guards over runtime components and patterns (not previews, fixtures or tests). */
|
|
61
|
+
export function a11ySourceAdvisories({ root, dsRoot }) {
|
|
62
|
+
const advisories = [];
|
|
63
|
+
const options = { root, dsRoot };
|
|
64
|
+
const files = sourceFiles(dsRoot).filter(file => /\.[jt]sx$/.test(file) && ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file)) && !isDevelopmentFile(file, options) && !/\.test\.|\.spec\./.test(file));
|
|
65
|
+
for (const file of files) {
|
|
66
|
+
const text = readFileSync(file, "utf8"), relative = path.relative(root, file).replaceAll("\\", "/");
|
|
67
|
+
const source = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
68
|
+
const at = node => { const { line, character } = source.getLineAndCharacterOfPosition(node.getStart(source)); return { file: relative, line: line + 1, column: character + 1 }; };
|
|
69
|
+
const visit = node => {
|
|
70
|
+
if (ts.isJsxSelfClosingElement(node) || ts.isJsxOpeningElement(node)) {
|
|
71
|
+
const tag = node.tagName.getText(source);
|
|
72
|
+
const attributes = node.attributes.properties;
|
|
73
|
+
const spread = attributes.some(ts.isJsxSpreadAttribute);
|
|
74
|
+
const names = new Set(attributes.filter(ts.isJsxAttribute).map(attribute => attribute.name.getText(source)));
|
|
75
|
+
if (tag === "img" && !spread && !names.has("alt")) advisories.push(advisory("a11y-image-alt", at(node), `<img> needs alt text, or alt="" when it is decorative (WCAG 1.1.1).`));
|
|
76
|
+
// A button or link whose only content is an icon, SVG or image has no accessible name.
|
|
77
|
+
if (ts.isJsxOpeningElement(node) && ["button", "a"].includes(tag) && !spread && !["aria-label", "aria-labelledby", "title"].some(name => names.has(name))) {
|
|
78
|
+
const children = node.parent.children.filter(child => !(ts.isJsxText(child) && !child.text.trim()));
|
|
79
|
+
const graphic = child => ts.isJsxSelfClosingElement(child) && (/Icon|Glyph|Svg/i.test(child.tagName.getText(source)) || ["svg", "img"].includes(child.tagName.getText(source)));
|
|
80
|
+
if (children.length && children.every(graphic)) advisories.push(advisory("a11y-icon-label", at(node), `<${tag}> shows only an icon and has no accessible name; add aria-label (or use IconButton with a label) (WCAG 4.1.2).`));
|
|
81
|
+
}
|
|
82
|
+
const attribute = name => attributes.find(item => ts.isJsxAttribute(item) && item.name.getText(source) === name);
|
|
83
|
+
const role = attribute("role")?.initializer?.getText(source).replace(/^["'{]+|["'}]+$/g, "");
|
|
84
|
+
// A backdrop that closes on its own click repeats Escape; it is not the keyboard path.
|
|
85
|
+
const backdrop = /currentTarget/.test(attribute("onClick")?.getText(source) ?? "");
|
|
86
|
+
if (nonInteractive.has(tag) && !spread && names.has("onClick") && !backdrop && !managedRoles.has(role) && !(role && names.has("tabIndex"))) {
|
|
87
|
+
advisories.push(advisory("a11y-keyboard", at(node), `<${tag} onClick> cannot be reached or used from the keyboard; use a <button>, or add role, tabIndex and a key handler (WCAG 2.1.1).`));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
ts.forEachChild(node, visit);
|
|
91
|
+
};
|
|
92
|
+
visit(source);
|
|
93
|
+
// Motion that never stops must yield to the reader's reduced-motion setting.
|
|
94
|
+
if (/animation(?:-iteration-count)?\s*:[^;`]*\binfinite\b/.test(text) && !/prefers-reduced-motion/.test(text)) {
|
|
95
|
+
const index = text.search(/\binfinite\b/), line = text.slice(0, index).split("\n").length;
|
|
96
|
+
advisories.push(advisory("a11y-reduced-motion", { file: relative, line }, "An infinite animation runs without a prefers-reduced-motion guard; stop it under @media (prefers-reduced-motion: reduce), or let the user pause it (WCAG 2.2.2, 2.3.3)."));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return advisories;
|
|
100
|
+
}
|
package/dist/assets.mjs
CHANGED
|
@@ -35,6 +35,30 @@ function sourceTexts(directories, skipped) {
|
|
|
35
35
|
return texts;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/** A glyph set draws in currentColor on one shared viewBox, so icons follow text color and size. */
|
|
39
|
+
function inspectGlyphs({ root, dsRoot, config }) {
|
|
40
|
+
const glyphs = config.assets.glyphs;
|
|
41
|
+
if (!glyphs) return [];
|
|
42
|
+
const directory = path.join(dsRoot, glyphs.source);
|
|
43
|
+
const files = assetFiles(directory).filter(file => file.toLowerCase().endsWith(".svg"));
|
|
44
|
+
const read = files.map(file => ({ file: path.join(directory, file), text: readFileSync(path.join(directory, file), "utf8") }));
|
|
45
|
+
const warn = (rule, file, message) => ({ rule, severity: "warning", file: path.relative(root, file).replaceAll("\\", "/"), line: 1, column: 1, guidanceUri: "ads://guides/branding", message });
|
|
46
|
+
const viewBox = text => text.match(/<svg\b[^>]*\bviewBox\s*=\s*["']([^"']+)["']/)?.[1]?.trim().replace(/\s+/g, " ") ?? null;
|
|
47
|
+
const counts = new Map();
|
|
48
|
+
for (const { text } of read) { const box = viewBox(text); if (box) counts.set(box, (counts.get(box) ?? 0) + 1); }
|
|
49
|
+
const shared = [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
50
|
+
const findings = [];
|
|
51
|
+
for (const { file, text } of read) {
|
|
52
|
+
const base = path.basename(file), box = viewBox(text);
|
|
53
|
+
if (!box) findings.push(warn("glyph-viewbox", file, `${base} has no viewBox; glyphs need one shared viewBox to draw at the same size.`));
|
|
54
|
+
else if (shared && box !== shared) findings.push(warn("glyph-viewbox", file, `${base} uses viewBox "${box}"; the set uses "${shared}", so it would draw at a different size.`));
|
|
55
|
+
// Any fill or stroke other than none or currentColor fixes the icon's color.
|
|
56
|
+
const colors = [...text.matchAll(/\b(fill|stroke)\s*[=:]\s*["']?\s*([^"';\s>]+)/g)].map(match => match[2]).filter(value => !/^(?:none|currentcolor|inherit)$/i.test(value) && !/^url\(/i.test(value));
|
|
57
|
+
if (colors.length) findings.push(warn("glyph-color", file, `${base} sets ${[...new Set(colors)].join(", ")}; draw glyphs in currentColor so they follow the text color and theme. A logo that must keep its colors (another product's mark) belongs in assets/brand/, shown as an image.`));
|
|
58
|
+
}
|
|
59
|
+
return findings;
|
|
60
|
+
}
|
|
61
|
+
|
|
38
62
|
/** Brand artwork is documented, licensed, previewed and used. Generated outputs match their masters. */
|
|
39
63
|
function inspectBrand({ root, dsRoot, config }) {
|
|
40
64
|
const diagnostics = [];
|
|
@@ -66,7 +90,7 @@ export function inspectAssets({ root, dsRoot, config, trackingRoot = root }) {
|
|
|
66
90
|
const diagnostics = [];
|
|
67
91
|
const sourceDiagnostic = brandSourceDiagnostic({ root, dsRoot, config });
|
|
68
92
|
if (sourceDiagnostic) diagnostics.push(sourceDiagnostic);
|
|
69
|
-
diagnostics.push(...inspectBrand({ root, dsRoot, config }));
|
|
93
|
+
diagnostics.push(...inspectBrand({ root, dsRoot, config }), ...inspectGlyphs({ root, dsRoot, config }));
|
|
70
94
|
function report(rule, file, message) { diagnostics.push({ rule, file: path.relative(root, file).replaceAll("\\", "/") || ".", line: 1, column: 1, message }); }
|
|
71
95
|
const assetRoot = path.join(dsRoot, "assets");
|
|
72
96
|
// Every mount is compared with the canonical ADS assets. Public mounts are
|
package/dist/capture/worker.mjs
CHANGED
|
@@ -11,7 +11,7 @@ try {
|
|
|
11
11
|
browser = await playwright[request.settings.browser].launch({ headless: true, ...(request.settings.channel ? { channel: request.settings.channel } : {}) });
|
|
12
12
|
const images = [];
|
|
13
13
|
for (const [index, app] of request.apps.entries()) {
|
|
14
|
-
const context = await browser.newContext({ viewport: app.viewport, deviceScaleFactor: 1, colorScheme: app.
|
|
14
|
+
const context = await browser.newContext({ viewport: app.viewport, deviceScaleFactor: 1, colorScheme: app.scheme });
|
|
15
15
|
try {
|
|
16
16
|
const page = await context.newPage(), timeout = request.settings.timeoutMs;
|
|
17
17
|
const frame = await openPreviewScenario(page, app.url, app.scenario, { timeout });
|
package/dist/capture-store.mjs
CHANGED
|
@@ -7,7 +7,8 @@ export const CAPTURES_URI = "ads://project/captures";
|
|
|
7
7
|
export const captureLimits = { selections: 8, imageBytes: 4 * 1024 * 1024, pixels: 8 * 1024 * 1024, storeBytes: 256 * 1024 * 1024, pairBytes: 12 * 1024 * 1024 };
|
|
8
8
|
export const captureSpec = z.object({
|
|
9
9
|
scenario: z.string().min(1).max(256), target: z.string().regex(/^[a-zA-Z0-9][\w.-]{0,79}$/).optional(),
|
|
10
|
-
theme
|
|
10
|
+
// A declared theme's name; the project's default theme when omitted.
|
|
11
|
+
theme: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/).optional(),
|
|
11
12
|
viewport: z.object({ width: z.number().int().min(100).max(4096), height: z.number().int().min(100).max(4096) }).strict().default({ width: 1280, height: 800 }),
|
|
12
13
|
animations: z.enum(["disabled", "allow"]).default("disabled"),
|
|
13
14
|
}).strict().refine(value => value.viewport.width * value.viewport.height <= captureLimits.pixels, "Capture viewport exceeds 8 megapixels.");
|
package/dist/capture.mjs
CHANGED
|
@@ -80,9 +80,12 @@ export function createCaptureController(root) {
|
|
|
80
80
|
const host = previewHosts[projectIndex] ?? await startAdsMcp(project.options.root, { stdio: false, showcase: true });
|
|
81
81
|
if(!previewHosts[projectIndex])ownedHosts.push(host);
|
|
82
82
|
hosts.push(host);
|
|
83
|
+
const themes = project.options.config.themes;
|
|
83
84
|
for (const selection of project.apps) {
|
|
84
|
-
const
|
|
85
|
-
|
|
85
|
+
const theme = themes.find(item => item.name === (selection.theme ?? themes[0].name));
|
|
86
|
+
if (!theme) throw new Error(`Unknown theme "${selection.theme}"; the project declares ${themes.map(item => item.name).join(", ")}.`);
|
|
87
|
+
const url = new URL(host.url); url.searchParams.set("scenario", selection.scenario); url.searchParams.set("capture", "1"); url.searchParams.set("theme", theme.name);
|
|
88
|
+
apps.push({ ...selection, theme: theme.name, scheme: theme.scheme, projectIndex, url: url.href });
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
const request = path.join(temporary, "request.json"), report = path.join(temporary, "report.json"), runId = randomUUID();
|
package/dist/check.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { importViolation, isInside, loadConfig, sourceFiles, isDevelopmentFile,
|
|
|
7
7
|
import { inspectTokens, references } from "./tokens.mjs";
|
|
8
8
|
import { foundationFiles, foundationImportTarget, isSharedToken } from "./token-policy.mjs";
|
|
9
9
|
import { inspectAssets } from "./assets.mjs";
|
|
10
|
+
import { a11ySourceAdvisories } from "./a11y.mjs";
|
|
10
11
|
import { appImportViolation, showcaseImportViolation, checkComponentVariable, importResolver, projectCompilerOptions, isUiCssProperties, styleWriteViolation } from "./boundaries.mjs";
|
|
11
12
|
import { inspectPublicProps } from "./public-props.mjs";
|
|
12
13
|
import { adsFileRole } from "./config.mjs";
|
|
@@ -338,7 +339,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
338
339
|
inspectDesignAliases(layerStyles,options,report);
|
|
339
340
|
// Bounded clients should see actionable warnings before source-analysis limits.
|
|
340
341
|
for (const { file, css, offset } of layerStyles) layers.inspectStyles(file, css, offset);
|
|
341
|
-
advisories.push(...(tokenInventory.advisories??[]), ...assetAdvisories);
|
|
342
|
+
advisories.push(...(tokenInventory.advisories??[]), ...assetAdvisories, ...a11ySourceAdvisories(options));
|
|
342
343
|
advisories.sort((first, second) => Number(first.severity === "info") - Number(second.severity === "info"));
|
|
343
344
|
const uniqueDiagnostics=[...new Map(diagnostics.map(diagnostic=>[JSON.stringify([diagnostic.file,diagnostic.rule,diagnostic.line,diagnostic.column,diagnostic.message]),diagnostic])).values()];
|
|
344
345
|
return architectureEvidence({ ok: uniqueDiagnostics.length === 0, diagnostics:uniqueDiagnostics, ...(advisories.length ? { advisories } : {}) });
|
package/dist/cli.mjs
CHANGED
|
@@ -21,6 +21,8 @@ Usage: ads create <directory> --framework react|preact New design-system proje
|
|
|
21
21
|
behaviors [dir] Inspect behavior contracts and current verification evidence
|
|
22
22
|
verify [directory] Run registered behavior checks (--unit and --check select)
|
|
23
23
|
tokens [directory] Inspect local token values and theme definitions
|
|
24
|
+
--format dtcg prints them as W3C Design Tokens JSON;
|
|
25
|
+
--theme <name> exports that theme's values (default: the first)
|
|
24
26
|
assets [directory] Generate standard web icons in .ds/assets from assets.iconSource
|
|
25
27
|
lint-config [dir] Generate .ds/oxlintrc.json with core and project plugins
|
|
26
28
|
mcp [directory] Serve stdio MCP tools/Apps and the local showcase website
|
|
@@ -53,6 +55,7 @@ async function main(args) {
|
|
|
53
55
|
let packageManager;
|
|
54
56
|
let framework;
|
|
55
57
|
let name;
|
|
58
|
+
let format, theme;
|
|
56
59
|
let port;
|
|
57
60
|
let unit;
|
|
58
61
|
const selectedChecks = [];
|
|
@@ -86,6 +89,12 @@ async function main(args) {
|
|
|
86
89
|
} else if (argument === "--package-manager") {
|
|
87
90
|
if (packageManager !== undefined || !args[index + 1] || args[index + 1].startsWith("-")) throw new Error("Specify one package manager after --package-manager: npm or bun.");
|
|
88
91
|
packageManager = args[++index];
|
|
92
|
+
} else if (argument === "--theme") {
|
|
93
|
+
if (theme !== undefined || !args[index + 1] || args[index + 1].startsWith("--")) throw new Error("Specify --theme <name>.");
|
|
94
|
+
theme = args[++index];
|
|
95
|
+
} else if (argument === "--format") {
|
|
96
|
+
if (format !== undefined || args[index + 1] !== "dtcg") throw new Error("Specify --format dtcg (the W3C Design Tokens format).");
|
|
97
|
+
format = args[++index];
|
|
89
98
|
} else if (argument === "--name") {
|
|
90
99
|
if (name !== undefined || !args[index + 1] || args[index + 1].startsWith("-")) throw new Error("Specify one package name after --name.");
|
|
91
100
|
name = args[++index];
|
|
@@ -115,6 +124,8 @@ async function main(args) {
|
|
|
115
124
|
if (packageManager !== undefined && !setup) throw new Error("--package-manager is supported only by create and init.");
|
|
116
125
|
if (framework !== undefined && !setup) throw new Error("--framework is supported only by create and init.");
|
|
117
126
|
if (name !== undefined && command !== "create") throw new Error("--name is supported only by create.");
|
|
127
|
+
if (format !== undefined && command !== "tokens") throw new Error("--format is supported only by tokens.");
|
|
128
|
+
if (theme !== undefined && format !== "dtcg") throw new Error("--theme is supported only by tokens --format dtcg.");
|
|
118
129
|
if (command === "create" && !directory) throw new Error("Name the new project's folder: ads create <directory> --framework react|preact.");
|
|
119
130
|
if (command === "init" && directory) throw new Error("Run ads init inside the project, without a directory argument.");
|
|
120
131
|
if ((unit || selectedChecks.length) && command !== "verify") throw new Error("--unit and --check are supported only by verify.");
|
|
@@ -138,6 +149,7 @@ async function main(args) {
|
|
|
138
149
|
}
|
|
139
150
|
else if (command === "behaviors") { const {behaviorStatus}=await import("./verification.mjs"); const {loadConfig}=await import("./config.mjs"); result=behaviorStatus(loadConfig(target)); }
|
|
140
151
|
else if (command === "verify") { const {createVerificationController}=await import("./verification.mjs"); const verification=createVerificationController(target); try {result=await verification.run({...(unit?{unit}:{}),...(selectedChecks.length?{checks:selectedChecks}:{})});} finally {await verification.close();} }
|
|
152
|
+
else if (command === "tokens" && format === "dtcg") { const { exportTokensDtcg } = await import("./token-export.mjs"); console.log(JSON.stringify(exportTokensDtcg(target, { theme }), null, 2)); return; }
|
|
141
153
|
else if (command === "tokens") result = inspectTokens(target);
|
|
142
154
|
else if (command === "assets") result = await generateBrandAssets(target);
|
|
143
155
|
else if (command === "lint-config") result = generateLintConfig(target);
|
package/dist/config.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { isDraftFile, draftImportViolation } from "./draft-boundary.mjs";
|
|
5
5
|
import { isSharedToken } from "./token-policy.mjs";
|
|
6
|
+
import { defaultThemes, validateThemes } from "./themes.mjs";
|
|
6
7
|
|
|
7
8
|
export const supportedFrameworks = ["react", "preact"];
|
|
8
9
|
|
|
@@ -18,6 +19,7 @@ export const defaultConfig = {
|
|
|
18
19
|
reviewEntry: "review/index.ts",
|
|
19
20
|
stylesEntry: "styles.css",
|
|
20
21
|
tokenDir: "tokens",
|
|
22
|
+
themes: defaultThemes,
|
|
21
23
|
inlineStyleFiles: [],
|
|
22
24
|
boundaries: { styleWrites: [], componentVariables: [] },
|
|
23
25
|
assets: { publicDirs: ["public/assets"], generatedPaths: ["dist", "dist-showcase", ".vite", ".ds"], generatedFiles: [], iconSource: null, targets: [], glyphs: null },
|
|
@@ -110,6 +112,7 @@ export function loadConfig(directory = process.cwd()) {
|
|
|
110
112
|
for (const key of Object.keys(user[field] ?? {})) if (!(key in defaultConfig[field])) throw new Error(`Unknown ${field} configuration field: ${key}`);
|
|
111
113
|
}
|
|
112
114
|
const config = { ...defaultConfig, ...user, boundaries: { ...defaultConfig.boundaries, ...user.boundaries }, assets: { ...defaultConfig.assets, ...user.assets }, oxlint: { ...defaultConfig.oxlint, ...user.oxlint }, acceptance: { ...defaultConfig.acceptance, ...user.acceptance }, validation: { ...defaultConfig.validation, ...user.validation }, mcp: { ...defaultConfig.mcp, ...user.mcp }, usage: { ...defaultConfig.usage, ...user.usage }, resources: { ...defaultConfig.resources, ...user.resources } };
|
|
115
|
+
validateThemes(config.themes);
|
|
113
116
|
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.");
|
|
114
117
|
if (!Array.isArray(config.usage.notifications) || config.usage.notifications.length > 100) throw new Error("usage.notifications must be an array of notification API registrations.");
|
|
115
118
|
const notificationNames = new Set();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 1,
|
|
3
3
|
"description": "Shared CSS token names, semantics, and value categories. Values belong to the project.",
|
|
4
4
|
"naming": {
|
|
5
|
-
"prefixes": ["--color-", "--slate-", "--warm-", "--rose-", "--bg-", "--text-", "--border-", "--font-", "--weight-", "--leading-", "--tracking-", "--type-", "--space-", "--radius-", "--control-", "--icon-", "--shadow-", "--ring-", "--filter-", "--ease-", "--dur-", "--z-", "--accent-", "--focus-", "--scroll-", "--success-", "--warning-", "--danger-", "--info-", "--side-pane-", "--toast-"],
|
|
5
|
+
"prefixes": ["--color-", "--slate-", "--warm-", "--rose-", "--bg-", "--text-", "--border-", "--font-", "--weight-", "--leading-", "--tracking-", "--type-", "--space-", "--radius-", "--control-", "--icon-", "--shadow-", "--ring-", "--filter-", "--ease-", "--dur-", "--z-", "--accent-", "--focus-", "--scroll-", "--success-", "--warning-", "--danger-", "--info-", "--side-pane-", "--container-", "--grid-", "--toast-"],
|
|
6
6
|
"names": ["--accent", "--success", "--warning", "--danger", "--info", "--inset-hairline", "--navigation-rail-width", "--app-header-height", "--content-max", "--row-height-compact", "--compact-column-min", "--stack-gap-compact"]
|
|
7
7
|
},
|
|
8
8
|
"tokens": {
|
package/dist/design-values.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { lexer, parse, generate } from "css-tree";
|
|
3
3
|
import valueParser from "postcss-value-parser";
|
|
4
4
|
import { isInside } from "./config.mjs";
|
|
5
|
+
import { tokenContract } from "./token-policy.mjs";
|
|
5
6
|
import { createSourceValues, reference } from "./source-values.mjs";
|
|
6
7
|
|
|
7
8
|
const colorCache = new Map();
|
|
@@ -63,14 +64,19 @@ export function inspectDesignAliases(styles, options, report) {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
const canonical=value=>{try{return generate(parse(value,{context:"value"}));}catch{return value.trim();}};
|
|
66
|
-
|
|
67
|
+
// A token's family: its shared prefix (--space-, --radius-) or, for a fixed name, the name itself.
|
|
68
|
+
const prefixes=[...tokenContract.naming.prefixes].sort((a,b)=>b.length-a.length);
|
|
69
|
+
const family=name=>prefixes.find(prefix=>name.startsWith(prefix)&&name.length>prefix.length)??name;
|
|
70
|
+
/** Equal definitions within one family invite review, not an automatic merge of different
|
|
71
|
+
* semantic roles. Equal values in different families (a radius and a spacing step) are scales
|
|
72
|
+
* meeting by design. */
|
|
67
73
|
export function tokenOverlapAdvisories(tokens) {
|
|
68
74
|
const groups=new Map();
|
|
69
75
|
for(const token of tokens) {
|
|
70
76
|
if(token.owner!=="tokens"||!token.definitions.length)continue;
|
|
71
77
|
const definitions=token.definitions.map(({scope,value})=>[scope,canonical(value)]).sort(([a],[b])=>a.localeCompare(b));
|
|
72
78
|
if(definitions.every(([,value])=>/^var\(--[\w-]+\)$/.test(value))||definitions.every(([,value])=>/^(?:0|1|none|auto|inherit|initial|unset|transparent)$/.test(value)))continue;
|
|
73
|
-
const signature=JSON.stringify(definitions);
|
|
79
|
+
const signature=JSON.stringify([family(token.name),definitions]);
|
|
74
80
|
if(!groups.has(signature))groups.set(signature,[]);
|
|
75
81
|
groups.get(signature).push(token);
|
|
76
82
|
}
|
package/dist/foundation.mjs
CHANGED
|
@@ -5,8 +5,11 @@ import { readFileSync } from "node:fs";
|
|
|
5
5
|
const policy = JSON.parse(readFileSync(new URL("./contracts/foundation.json", import.meta.url), "utf8"));
|
|
6
6
|
const cssWide = /^(?:inherit|initial|unset|revert|revert-layer)$/i;
|
|
7
7
|
|
|
8
|
+
// A theme scope ([data-theme] or [data-theme="name"]) anchors like the root: a theme can
|
|
9
|
+
// apply to the whole document or to one section of it.
|
|
8
10
|
function rootAnchor(nodes) {
|
|
9
11
|
return nodes.some(node => node.type === "tag" && !node.namespace && node.value.toLowerCase() === "html"
|
|
12
|
+
|| node.type === "attribute" && node.attribute === "data-theme" && (!node.operator || node.operator === "=")
|
|
10
13
|
|| node.type === "pseudo" && node.value.toLowerCase() === ":root"
|
|
11
14
|
|| node.type === "pseudo" && /^:(?:is|where)$/i.test(node.value) && node.nodes.length && node.nodes.every(selector => !selector.nodes.some(node => node.type === "combinator") && rootAnchor(selector.nodes)));
|
|
12
15
|
}
|
package/dist/mcp/apps.mjs
CHANGED
|
@@ -30,7 +30,7 @@ export function tokenWidgetData(inventory) {
|
|
|
30
30
|
export function tokensApp(data) {
|
|
31
31
|
return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>ADS tokens</title><style>
|
|
32
32
|
html{color-scheme:light dark;background:Canvas;color:CanvasText;font:13px/1.55 system-ui}html,body{height:100%}body{margin:0}#ads-token-root{padding:32px}#ads-scenario-root{height:100%}header{display:flex;gap:8px;flex-wrap:wrap;align-items:center}h1{font-size:18px;margin:0 auto 0 0}button,input,select{font:inherit;color:CanvasText;background:Canvas;border:1px solid GrayText;border-radius:4px;padding:6px 8px}ul{padding:0;list-style:none}li{margin:12px 0}summary{cursor:pointer;display:flex;gap:16px;align-items:baseline;flex-wrap:wrap}code{font:12px monospace;overflow-wrap:anywhere}dl{border:1px solid GrayText;padding:12px;overflow-wrap:anywhere}dt{font-weight:600}dd{margin:2px 0 12px}footer{display:flex;gap:8px;align-items:center}iframe{display:block;width:100%;height:100%;border:0}[hidden]{display:none!important}:root[data-theme="light"]{color-scheme:light}:root[data-theme="dark"]{color-scheme:dark}
|
|
33
|
-
</style></head><body><p id="ads-scenario-status" role="status" hidden></p><main id="ads-scenario-root" hidden></main><main id="ads-token-root"><header><h1>Token definitions</h1><input id="ads-token-search" type="search" aria-label="Find token" placeholder="Find a token"><select id="ads-token-theme" aria-label="Preview theme"
|
|
33
|
+
</style></head><body><p id="ads-scenario-status" role="status" hidden></p><main id="ads-scenario-root" hidden></main><main id="ads-token-root"><header><h1>Token definitions</h1><input id="ads-token-search" type="search" aria-label="Find token" placeholder="Find a token"><select id="ads-token-theme" aria-label="Preview theme"></select><button id="ads-token-refresh" type="button" disabled>Refresh</button></header><p id="ads-widget-status" role="status">Connecting to the Apps host…</p><ul id="ads-token-list"></ul><footer><button id="ads-token-prev" type="button">Previous</button><span id="ads-token-count"></span><button id="ads-token-next" type="button">Next</button></footer></main><script type="application/json" id="ads-token-seed">${safeJson(data)}</script><script type="module">${bridge()}</script></body></html>`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export function scenarioApp() {
|