@reqvire-org/ads 0.5.1 → 0.5.3
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/dist/ads-errors.mjs +143 -51
- package/dist/analysis/composition-axes.mjs +48 -0
- package/dist/analysis/construction-memo.mjs +38 -0
- package/dist/analysis/context.mjs +19 -0
- package/dist/analysis/design-reads.mjs +177 -0
- package/dist/analysis/design-usage.mjs +4 -20
- package/dist/analysis/factored-classes.mjs +90 -0
- package/dist/analysis/helpers.mjs +5 -7
- package/dist/analysis/mock-check.mjs +4 -5
- package/dist/analysis/native-project.mjs +12 -0
- package/dist/analysis/owner-accessibility.mjs +4 -4
- package/dist/analysis/owner-analysis-cache.mjs +86 -23
- package/dist/analysis/owner-analysis-key.mjs +42 -10
- package/dist/analysis/owner-choices.mjs +56 -7
- package/dist/analysis/owner-composition.mjs +179 -45
- package/dist/analysis/owner-reuse.mjs +8 -6
- package/dist/analysis/owner-source.mjs +304 -110
- package/dist/analysis/scenario-keys.mjs +10 -7
- package/dist/analysis/service.mjs +50 -3
- package/dist/analysis/standalone.mjs +7 -4
- package/dist/analysis/syntax.mjs +59 -1
- package/dist/analysis/worker-protocol.mjs +14 -2
- package/dist/analysis/worker.mjs +32 -10
- package/dist/architecture-report.mjs +26 -0
- package/dist/asset-view-facts.mjs +16 -2
- package/dist/boundaries.mjs +26 -10
- package/dist/bun-compiler.mjs +2 -2
- package/dist/check-service.mjs +29 -17
- package/dist/check.mjs +13 -6
- package/dist/cli.mjs +1 -1
- package/dist/composed-contrast.mjs +143 -62
- package/dist/composed-keyline.mjs +2 -2
- package/dist/config.mjs +2 -1
- package/dist/construction-output.mjs +9 -3
- package/dist/construction-spec.d.mts +145 -31
- package/dist/construction-spec.mjs +204 -74
- package/dist/corner-overpaint.mjs +20 -7
- package/dist/derived-states.mjs +182 -0
- package/dist/design-foundation.mjs +16 -0
- package/dist/design-inputs.mjs +18 -3
- package/dist/design-system-closure.mjs +12 -7
- package/dist/design-usage.mjs +2 -8
- package/dist/emit/contract.mjs +24 -5
- package/dist/emit/emission.mjs +6 -9
- package/dist/emit/integrity.mjs +8 -2
- package/dist/emit/output-watch.mjs +120 -0
- package/dist/emit/owner-emission-cache.mjs +4 -4
- package/dist/emit/preview-emitter.mjs +4 -2
- package/dist/emit/preview-tree.mjs +1 -1
- package/dist/emit/service.mjs +8 -2
- package/dist/finding-rules.mjs +3 -0
- package/dist/form-states.mjs +8 -0
- package/dist/frame-regions.mjs +29 -9
- package/dist/grid-lowering.mjs +3 -1
- package/dist/hover-geometry.mjs +15 -0
- package/dist/input-digests.mjs +17 -10
- package/dist/linaria/delivery.mjs +2 -0
- package/dist/lowering-enter.mjs +6 -6
- package/dist/lowering-properties.mjs +5 -0
- package/dist/lowering-region-layout.mjs +7 -2
- package/dist/lowering-session.mjs +10 -0
- package/dist/mcp/build-status.mjs +9 -1
- package/dist/mcp/compiler-channel.mjs +11 -4
- package/dist/mcp/mutations.mjs +1 -0
- package/dist/mcp/preview-http.bundle.js +1 -1
- package/dist/mcp/preview-watch.mjs +2 -1
- package/dist/mcp/preview-widget.bundle.js +1 -1
- package/dist/mcp/server-observation.mjs +6 -4
- package/dist/mcp/server-project.mjs +4 -1
- package/dist/motion-model.mjs +1 -1
- package/dist/owner-analysis-check.mjs +23 -6
- package/dist/owner-errors.mjs +6 -3
- package/dist/owner-lowering.mjs +78 -13
- package/dist/owner-scenarios.mjs +6 -23
- package/dist/ownership-model.mjs +24 -8
- package/dist/paint-contrast.mjs +6 -0
- package/dist/placeholder-contrast.mjs +17 -1
- package/dist/platform-features.mjs +10 -1
- package/dist/profile-macro.d.mts +7 -0
- package/dist/profile-view-facts.mjs +1 -1
- package/dist/recipe-macro.d.mts +103 -40
- package/dist/recipe-model.mjs +18 -13
- package/dist/region-lowering.mjs +266 -123
- package/dist/render-audit/layout-shift.page.mjs +24 -0
- package/dist/render-audit/render-states.mjs +122 -1
- package/dist/render-audit/render-states.page.mjs +140 -0
- package/dist/render-audit/worker.mjs +18 -3
- package/dist/render-audit.mjs +114 -1
- package/dist/role-vocabulary.d.mts +9 -0
- package/dist/role-vocabulary.mjs +16 -1
- package/dist/runtime-paint-contrast.mjs +5 -2
- package/dist/scenarios-compiler.mjs +20 -6
- package/dist/showcase/assets-view.mjs +29 -13
- package/dist/showcase/client.bundle.js +50 -50
- package/dist/showcase/http-client.bundle.js +15 -15
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +5 -5
- package/dist/skills/ads-designer/references/accessibility.md +10 -4
- package/dist/skills/ads-designer/references/branding.md +13 -3
- package/dist/skills/ads-designer/references/contracts.md +5 -2
- package/dist/skills/ads-designer/references/design-data.md +13 -7
- package/dist/skills/ads-designer/references/layout.md +12 -4
- package/dist/skills/ads-designer/references/motion.md +11 -2
- package/dist/skills/ads-designer/references/recipes.md +49 -15
- package/dist/skills/ads-import/references/contracts.md +5 -2
- package/dist/skills/ads-import/references/design-data.md +13 -7
- package/dist/skills/ads-import/references/layout.md +12 -4
- package/dist/skills/ads-import/references/recipes.md +49 -15
- package/dist/skills/ads-migrate/SKILL.md +2 -0
- package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
- package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
- package/dist/skills/ads-port/references/contracts.md +5 -2
- package/dist/skills/ads-port/references/design-data.md +13 -7
- package/dist/skills/ads-port/references/layout.md +12 -4
- package/dist/skills/ads-port/references/recipes.md +49 -15
- package/dist/spatial-model.mjs +2 -2
- package/dist/surface-contrast.mjs +7 -2
- package/dist/surface-effects.mjs +5 -3
- package/dist/target-size.mjs +21 -3
- package/dist/task-cache.mjs +8 -18
- package/dist/validation-checks.mjs +1 -1
- package/docs/ADS.md +9 -3
- package/docs/ARCHITECTURE.md +96 -30
- package/docs/CACHING.md +152 -24
- package/docs/CHANGELOG.md +307 -23
- package/docs/GUIDE.md +109 -20
- package/docs/LANGUAGE.md +262 -117
- package/docs/MCP.md +5 -1
- package/docs/MOTION.md +15 -4
- package/docs/PROFILE-KINDS.md +54 -4
- package/docs/RULES.md +34 -25
- package/docs/TOKEN-ROLES.md +7 -1
- package/package.json +1 -1
- package/dist/analysis/prose-owners.mjs +0 -57
- package/dist/prose-model.d.mts +0 -81
- package/dist/prose-model.mjs +0 -101
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { axeRun } from "./axe-run.page.mjs";
|
|
2
2
|
import { nonTextContrast } from "./non-text-contrast.page.mjs";
|
|
3
|
+
import { layoutOverflow } from "./layout-overflow.page.mjs";
|
|
4
|
+
import { cornerOverpaint } from "./corner-overpaint.page.mjs";
|
|
5
|
+
import { imageShape } from "./image-shape.page.mjs";
|
|
6
|
+
import { stateShift } from "./layout-shift.page.mjs";
|
|
3
7
|
import {
|
|
8
|
+
applyDerived,
|
|
9
|
+
findDerived,
|
|
10
|
+
restoreDerived,
|
|
11
|
+
setPaint,
|
|
12
|
+
swapDrawing,
|
|
13
|
+
boxOf,
|
|
4
14
|
clearState,
|
|
5
15
|
findTargets,
|
|
6
16
|
focusOutline,
|
|
@@ -36,7 +46,7 @@ export async function auditRenderStates({ page, frame, result, request, phoneWid
|
|
|
36
46
|
const { nodeLimit, tags } = request, declared = request.declared ?? [], desktop = page.viewportSize();
|
|
37
47
|
if (!desktop)
|
|
38
48
|
throw Error("The render audit page has no fixed viewport to restore after the phone width.");
|
|
39
|
-
const coverage = result.coverage = { overlays: 0, controls: 0, skipped: [] }, skip = (reason, name) => {
|
|
49
|
+
const coverage = result.coverage = { overlays: 0, controls: 0, derived: 0, rendered: [], held: [], measured: [], forced: [], skipped: [] }, skip = (reason, name) => {
|
|
40
50
|
coverage.skipped.push({ reason, name });
|
|
41
51
|
}, isClosed = () => frame.waitForFunction(overlayClosed, void 0, { timeout: 1000 }).then(() => !0, () => !1), unmark = () => frame.evaluate(unmarkOverlays), measureOverlay = async (label, reopen) => {
|
|
42
52
|
await frame.evaluate(settle);
|
|
@@ -134,4 +144,115 @@ export async function auditRenderStates({ page, frame, result, request, phoneWid
|
|
|
134
144
|
}
|
|
135
145
|
}
|
|
136
146
|
await page.mouse.move(desktop.width - 1, desktop.height - 1);
|
|
147
|
+
await auditDerivedStates({ frame, result, request, coverage, rest, pair, skip, desktopWidth: desktop.width });
|
|
148
|
+
}
|
|
149
|
+
async function auditDerivedStates({
|
|
150
|
+
frame,
|
|
151
|
+
result,
|
|
152
|
+
request,
|
|
153
|
+
coverage,
|
|
154
|
+
rest,
|
|
155
|
+
pair,
|
|
156
|
+
skip,
|
|
157
|
+
desktopWidth
|
|
158
|
+
}) {
|
|
159
|
+
const constructions = request.derived ?? [];
|
|
160
|
+
if (constructions.length === 0)
|
|
161
|
+
return;
|
|
162
|
+
const { nodeLimit, tags } = request, declared = request.declared ?? [], found = await frame.evaluate(findDerived, constructions);
|
|
163
|
+
coverage.rendered.push(...found.rendered);
|
|
164
|
+
coverage.held.push(...found.held);
|
|
165
|
+
const atRest = await frame.evaluate(layoutOverflow, { nodeLimit, width: desktopWidth }), known = new Set(atRest.issues.map((issue) => JSON.stringify(issue))), shapesAtRest = new Set((await frame.evaluate(imageShape, { nodeLimit })).issues.map((issue) => issue.selector)), cornersAtRest = new Set((await frame.evaluate(cornerOverpaint, { nodeLimit })).issues.map((issue) => issue.selector));
|
|
166
|
+
for (const target of found.targets) {
|
|
167
|
+
const construction = constructions.find((item) => item.owner === target.owner && item.classes === target.classes), selector = `[data-ads-derived="${target.index}"]`, measureContrast = async (label) => {
|
|
168
|
+
await frame.evaluate(settle);
|
|
169
|
+
const axe = await frame.evaluate(axeRun, { tags, nodeLimit, include: selector, rules: ["color-contrast"] }), fresh = (group) => ({ ...group, nodes: group.nodes.filter((node) => !rest.has(node.selector)) });
|
|
170
|
+
result.violations.push(...labelled(axe.violations.map(fresh).filter((group) => group.nodes.length), label));
|
|
171
|
+
const issues = (await frame.evaluate(nonTextContrast, { nodeLimit, scope: selector, declared })).issues.filter((issue) => !rest.has(pair(issue)));
|
|
172
|
+
result.nonText.issues.push(...named(issues, label));
|
|
173
|
+
for (const issue of issues)
|
|
174
|
+
result.nonText.counts[issue.kind] = (result.nonText.counts[issue.kind] ?? 0) + 1;
|
|
175
|
+
};
|
|
176
|
+
for (const paint of construction?.paints ?? [])
|
|
177
|
+
for (const value of paint.values) {
|
|
178
|
+
const label = `paint ${paint.name}: ${value} of ${target.owner}`;
|
|
179
|
+
try {
|
|
180
|
+
const before = await frame.evaluate(setPaint, { target: selector, property: paint.property, value: `var(${value})` });
|
|
181
|
+
await measureContrast(label);
|
|
182
|
+
await frame.evaluate(setPaint, { target: selector, property: paint.property, value: before });
|
|
183
|
+
coverage.derived++;
|
|
184
|
+
} catch (error) {
|
|
185
|
+
skip(`derived-${failure(error)}`, label);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
for (const glyph of construction?.glyphs ?? [])
|
|
189
|
+
for (const [member, html] of Object.entries(glyph.members)) {
|
|
190
|
+
const label = `glyph ${member} of ${target.owner}`;
|
|
191
|
+
try {
|
|
192
|
+
const before = await frame.evaluate(swapDrawing, { target: selector, part: glyph.part, html });
|
|
193
|
+
if (before === null) {
|
|
194
|
+
skip("derived-state-not-applied", `${label}: no ${glyph.part} inside`);
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
await measureContrast(label);
|
|
198
|
+
for (const issue of (await frame.evaluate(imageShape, { nodeLimit })).issues)
|
|
199
|
+
if (!shapesAtRest.has(issue.selector))
|
|
200
|
+
(result.derivedShapes ??= []).push({ ...issue, selector: `${label}: ${unmarked(issue.selector)}`, width: desktopWidth });
|
|
201
|
+
await frame.evaluate(swapDrawing, { target: selector, part: glyph.part, html: before });
|
|
202
|
+
coverage.derived++;
|
|
203
|
+
} catch (error) {
|
|
204
|
+
skip(`derived-${failure(error)}`, label);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
for (const state of construction?.states ?? []) {
|
|
208
|
+
const label = `state ${state.condition} of ${target.owner}`;
|
|
209
|
+
if (state.kind === "interaction")
|
|
210
|
+
continue;
|
|
211
|
+
if (state.kind === "unsupported") {
|
|
212
|
+
skip("derived-state-unsupported", `${label} (${target.name})`);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const before = await frame.evaluate(boxOf, selector), applied = await frame.evaluate(applyDerived, { target: selector, condition: state.condition });
|
|
217
|
+
if (!applied.applied) {
|
|
218
|
+
skip("derived-state-not-applied", `${label}: ${applied.reason}`);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
await frame.evaluate(settle);
|
|
222
|
+
const axe = await frame.evaluate(axeRun, { tags, nodeLimit, include: selector, rules: ["color-contrast"] }), fresh = (group) => ({ ...group, nodes: group.nodes.filter((node) => !rest.has(node.selector)) });
|
|
223
|
+
result.violations.push(...labelled(axe.violations.map(fresh).filter((group) => group.nodes.length), label));
|
|
224
|
+
const issues = (await frame.evaluate(nonTextContrast, { nodeLimit, scope: selector, declared })).issues.filter((issue) => !rest.has(pair(issue)));
|
|
225
|
+
result.nonText.issues.push(...named(issues, label));
|
|
226
|
+
for (const issue of issues)
|
|
227
|
+
result.nonText.counts[issue.kind] = (result.nonText.counts[issue.kind] ?? 0) + 1;
|
|
228
|
+
const moved = (await frame.evaluate(layoutOverflow, { nodeLimit, width: desktopWidth })).issues.filter((issue) => !known.has(JSON.stringify(issue)));
|
|
229
|
+
if (moved.length > 0) {
|
|
230
|
+
const counts = {};
|
|
231
|
+
for (const issue of moved)
|
|
232
|
+
counts[issue.kind] = (counts[issue.kind] ?? 0) + 1;
|
|
233
|
+
result.layout.push({ width: desktopWidth, issues: moved.map((issue) => ({ ...issue, selector: `${label}: ${unmarked(String(Reflect.get(issue, "selector") ?? ""))}` })), counts });
|
|
234
|
+
}
|
|
235
|
+
for (const issue of (await frame.evaluate(imageShape, { nodeLimit })).issues)
|
|
236
|
+
if (!shapesAtRest.has(issue.selector))
|
|
237
|
+
(result.derivedShapes ??= []).push({ ...issue, selector: `${label}: ${unmarked(issue.selector)}`, width: desktopWidth });
|
|
238
|
+
for (const issue of (await frame.evaluate(cornerOverpaint, { nodeLimit })).issues)
|
|
239
|
+
if (!cornersAtRest.has(issue.selector))
|
|
240
|
+
(result.derivedCorners ??= []).push({ ...issue, selector: `${label}: ${unmarked(issue.selector)}`, width: desktopWidth });
|
|
241
|
+
const after = await frame.evaluate(boxOf, selector);
|
|
242
|
+
if (JSON.stringify(before) !== JSON.stringify(after)) {
|
|
243
|
+
const shift = await frame.evaluate(stateShift, { nodeLimit, quietMs: 250 });
|
|
244
|
+
if (shift !== null && shift.value > 0.1)
|
|
245
|
+
(result.derivedShifts ??= []).push({ state: label, value: shift.value, nodes: shift.nodes });
|
|
246
|
+
}
|
|
247
|
+
await frame.evaluate(restoreDerived, { target: selector, restore: applied.restore });
|
|
248
|
+
await frame.evaluate(settle);
|
|
249
|
+
coverage.derived++;
|
|
250
|
+
coverage.measured.push(`${target.owner}\x00${target.classes}\x00${state.condition}`);
|
|
251
|
+
if (construction?.content?.some((attribute) => state.condition.includes(`[${attribute}`)) === !0)
|
|
252
|
+
coverage.forced.push(`${target.owner}\x00${state.condition}`);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
skip(`derived-${failure(error)}`, label);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
137
258
|
}
|
|
@@ -175,3 +175,143 @@ export async function focusOutline() {
|
|
|
175
175
|
const color = over(rgba(style.outlineColor), back), [a, b] = [lum(color), lum(back)], ratio = (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05), hex = (value) => `#${value.slice(0, 3).map((part) => Math.round(part).toString(16).padStart(2, "0")).join("")}`;
|
|
176
176
|
return ratio + 0.000000001 < 3 ? { ratio: Math.round(ratio * 100) / 100, foreground: hex(color), background: hex(back), html: element.outerHTML.replace(/\s+/g, " ").slice(0, 200) } : null;
|
|
177
177
|
}
|
|
178
|
+
export function findDerived(constructions) {
|
|
179
|
+
const root = document.querySelector("#root"), targets = [], rendered = [], held = [];
|
|
180
|
+
if (root === null)
|
|
181
|
+
return { targets, rendered, held };
|
|
182
|
+
for (const construction of constructions) {
|
|
183
|
+
const classes = construction.classes.split(/\s+/).filter((item) => item !== "");
|
|
184
|
+
if (classes.length === 0)
|
|
185
|
+
continue;
|
|
186
|
+
const owned = [...root.querySelectorAll(`.${classes.map((item) => CSS.escape(item)).join(".")}`)].filter((element) => {
|
|
187
|
+
const source = element.closest("[data-ads-source]")?.getAttribute("data-ads-source") ?? "";
|
|
188
|
+
return source === construction.owner || source.endsWith(`/${construction.owner}`);
|
|
189
|
+
});
|
|
190
|
+
if (owned.length === 0)
|
|
191
|
+
continue;
|
|
192
|
+
rendered.push(`${construction.owner}\x00${construction.classes}`);
|
|
193
|
+
for (const state of construction.states) {
|
|
194
|
+
if (state.kind !== "attribute")
|
|
195
|
+
continue;
|
|
196
|
+
const selector = state.condition.replace(/^&/, "");
|
|
197
|
+
try {
|
|
198
|
+
if (owned.some((element) => element.matches(selector)))
|
|
199
|
+
held.push(`${construction.owner}\x00${construction.classes}\x00${state.condition}`);
|
|
200
|
+
} catch {}
|
|
201
|
+
}
|
|
202
|
+
const visible = owned.find((element) => {
|
|
203
|
+
const box = element.getBoundingClientRect();
|
|
204
|
+
return box.width >= 1 && box.height >= 1 && element.checkVisibility({ checkOpacity: !1, checkVisibilityCSS: !0 });
|
|
205
|
+
});
|
|
206
|
+
if (visible === void 0)
|
|
207
|
+
continue;
|
|
208
|
+
const index = targets.length;
|
|
209
|
+
visible.setAttribute("data-ads-derived", String(index));
|
|
210
|
+
const name = (visible.getAttribute("aria-label") ?? visible.textContent ?? "").replace(/\s+/g, " ").trim().slice(0, 60) || visible.localName;
|
|
211
|
+
targets.push({ index, owner: construction.owner, classes: construction.classes, name });
|
|
212
|
+
}
|
|
213
|
+
return { targets, rendered, held };
|
|
214
|
+
}
|
|
215
|
+
export function applyDerived({ target, condition }) {
|
|
216
|
+
const element = document.querySelector(target);
|
|
217
|
+
if (element === null)
|
|
218
|
+
return { applied: !1, reason: "gone" };
|
|
219
|
+
const restore = [], setProperty = (on, selector, name, value) => {
|
|
220
|
+
if (!(name in on))
|
|
221
|
+
return !1;
|
|
222
|
+
restore.push([selector, "property", name, Reflect.get(on, name)]);
|
|
223
|
+
Reflect.set(on, name, value);
|
|
224
|
+
return !0;
|
|
225
|
+
}, body = condition.replace(/^&/, ""), parts = [];
|
|
226
|
+
let index = 0;
|
|
227
|
+
while (index < body.length) {
|
|
228
|
+
const begin = index;
|
|
229
|
+
if (body[index] === "[")
|
|
230
|
+
index = body.indexOf("]", index) + 1 || body.length;
|
|
231
|
+
else if (body[index] === ":") {
|
|
232
|
+
index++;
|
|
233
|
+
while (index < body.length && /[\w-]/.test(body[index] ?? ""))
|
|
234
|
+
index++;
|
|
235
|
+
if (body[index] === "(") {
|
|
236
|
+
let depth = 0;
|
|
237
|
+
for (;index < body.length; index++)
|
|
238
|
+
if (body[index] === "(")
|
|
239
|
+
depth++;
|
|
240
|
+
else if (body[index] === ")" && --depth === 0)
|
|
241
|
+
break;
|
|
242
|
+
index++;
|
|
243
|
+
}
|
|
244
|
+
} else
|
|
245
|
+
return { applied: !1, reason: body };
|
|
246
|
+
parts.push(body.slice(begin, index));
|
|
247
|
+
}
|
|
248
|
+
for (const part of parts) {
|
|
249
|
+
if (part.startsWith(":not("))
|
|
250
|
+
continue;
|
|
251
|
+
const attribute = /^\[([\w-]+)(?:([~|^$*]?=)"([^"]*)")?\]$/.exec(part);
|
|
252
|
+
if (attribute !== null) {
|
|
253
|
+
const [, name = "", operator, value] = attribute;
|
|
254
|
+
if (operator !== void 0 && operator !== "=")
|
|
255
|
+
return { applied: !1, reason: `attribute ${part}` };
|
|
256
|
+
restore.push([null, "attribute", name, element.getAttribute(name)]);
|
|
257
|
+
element.setAttribute(name, value ?? "");
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const property = /^:(disabled|checked|indeterminate)$/.exec(part);
|
|
261
|
+
if (property !== null) {
|
|
262
|
+
if (!setProperty(element, null, property[1], !0))
|
|
263
|
+
return { applied: !1, reason: `${part} on <${element.localName}>` };
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
const has = /^:has\(>\s*(\.[\w-]+)(?::(checked|indeterminate|disabled))?\)$/.exec(part);
|
|
267
|
+
if (has !== null) {
|
|
268
|
+
const selector = `:scope > ${has[1] ?? ""}`, child = element.querySelector(selector);
|
|
269
|
+
if (child === null)
|
|
270
|
+
return { applied: !1, reason: `no ${has[1] ?? ""} inside` };
|
|
271
|
+
if (has[2] !== void 0 && !setProperty(child, selector, has[2], !0))
|
|
272
|
+
return { applied: !1, reason: `${part} on <${child.localName}>` };
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
return { applied: !1, reason: part };
|
|
276
|
+
}
|
|
277
|
+
return { applied: !0, restore };
|
|
278
|
+
}
|
|
279
|
+
export function restoreDerived({ target, restore }) {
|
|
280
|
+
const element = document.querySelector(target);
|
|
281
|
+
if (element === null)
|
|
282
|
+
return;
|
|
283
|
+
for (const [selector, kind, name, value] of [...restore].reverse()) {
|
|
284
|
+
const on = selector === null ? element : element.querySelector(selector);
|
|
285
|
+
if (on === null)
|
|
286
|
+
continue;
|
|
287
|
+
if (kind === "property")
|
|
288
|
+
Reflect.set(on, name, value);
|
|
289
|
+
else if (value === null)
|
|
290
|
+
on.removeAttribute(name);
|
|
291
|
+
else
|
|
292
|
+
on.setAttribute(name, String(value));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
export function setPaint({ target, property, value }) {
|
|
296
|
+
const element = document.querySelector(target);
|
|
297
|
+
if (element === null)
|
|
298
|
+
return null;
|
|
299
|
+
const before = element.style.getPropertyValue(property);
|
|
300
|
+
if (value === null)
|
|
301
|
+
element.style.removeProperty(property);
|
|
302
|
+
else
|
|
303
|
+
element.style.setProperty(property, value);
|
|
304
|
+
return before === "" ? null : before;
|
|
305
|
+
}
|
|
306
|
+
export function swapDrawing({ target, part, html }) {
|
|
307
|
+
const element = document.querySelector(target), host = element === null ? null : element.matches(part) ? element : element.querySelector(part);
|
|
308
|
+
if (host === null)
|
|
309
|
+
return null;
|
|
310
|
+
const before = host.innerHTML;
|
|
311
|
+
host.innerHTML = html;
|
|
312
|
+
return before;
|
|
313
|
+
}
|
|
314
|
+
export function boxOf(target) {
|
|
315
|
+
const box = document.querySelector(target)?.getBoundingClientRect();
|
|
316
|
+
return box === void 0 ? null : [box.x, box.y, box.width, box.height];
|
|
317
|
+
}
|
|
@@ -171,18 +171,33 @@ try {
|
|
|
171
171
|
textScale.push(...await overridePasses(frame, { nodeLimit: request.nodeLimit, width, rest: measured }));
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
+
for (const width of request.conditionWidths ?? []) {
|
|
175
|
+
await page.setViewportSize({ width, height: request.viewport.height });
|
|
176
|
+
const measured = await frame.evaluate(layoutOverflow, { nodeLimit: request.nodeLimit, width });
|
|
177
|
+
layout.push({ width, ...overflowOnly(measured) });
|
|
178
|
+
for (const issue of (await frame.evaluate(imageShape, { nodeLimit: request.nodeLimit })).issues)
|
|
179
|
+
if (!shapes.has(issue.selector))
|
|
180
|
+
shapes.set(issue.selector, { ...issue, width });
|
|
181
|
+
for (const issue of (await frame.evaluate(cornerOverpaint, { nodeLimit: request.nodeLimit })).issues)
|
|
182
|
+
if (!covered.has(issue.selector))
|
|
183
|
+
covered.set(issue.selector, { ...issue, width });
|
|
184
|
+
}
|
|
185
|
+
if ((request.conditionWidths ?? []).length > 0)
|
|
186
|
+
await page.setViewportSize({ width: request.overflowWidths.at(-1) ?? request.viewport.width, height: request.viewport.height });
|
|
174
187
|
if (app.text) {
|
|
175
188
|
textScale.push(...await viewportPasses(page, frame, { nodeLimit: request.nodeLimit, widths: request.textWidths, height: request.viewport.height, rest }));
|
|
176
189
|
result.textScale = textScale;
|
|
177
190
|
}
|
|
178
191
|
const assigned = await turns[index] ?? { triggers: [], controls: [] };
|
|
179
192
|
await auditRenderStates({ page, frame, result, request, phoneWidth: request.overflowWidths[0], assigned });
|
|
180
|
-
const coverage = result.coverage ??= { overlays: 0, controls: 0, skipped: [] };
|
|
193
|
+
const coverage = result.coverage ??= { overlays: 0, controls: 0, derived: 0, rendered: [], held: [], measured: [], forced: [], skipped: [] };
|
|
181
194
|
if (!contentSettled)
|
|
182
195
|
coverage.skipped.push({ reason: "content-still-changing", name: "the page" });
|
|
183
196
|
coverage.claimed = [...assigned.triggers, ...assigned.controls].map((item) => item.claim);
|
|
184
|
-
result.imageShape = [...shapes.values()];
|
|
185
|
-
result.corners = [...covered.values()];
|
|
197
|
+
result.imageShape = [...shapes.values(), ...result.derivedShapes ?? []];
|
|
198
|
+
result.corners = [...covered.values(), ...result.derivedCorners ?? []];
|
|
199
|
+
delete result.derivedShapes;
|
|
200
|
+
delete result.derivedCorners;
|
|
186
201
|
if (app.container && !await frame.evaluate(hasMainLandmark)) {
|
|
187
202
|
await frame.addStyleTag({ content: `#root { inline-size: ${app.container}px; }` });
|
|
188
203
|
const options = { nodeLimit: request.nodeLimit, container: app.container, smallPart: request.smallPart };
|
package/dist/render-audit.mjs
CHANGED
|
@@ -13,6 +13,8 @@ import { discoverScenarioRegistry, parseScenarioRegistry } from "./scenario-regi
|
|
|
13
13
|
import { inspectUnits } from "./units.mjs";
|
|
14
14
|
import { notAvailable } from "./availability.mjs";
|
|
15
15
|
import { reportedDeclarations } from "./accessibility-declarations.mjs";
|
|
16
|
+
import { boundWidths, parseDerivedAudit } from "./derived-states.mjs";
|
|
17
|
+
import { PREVIEW_AUDIT_FILE, previewTreeDirectory } from "./emit/preview-tree.mjs";
|
|
16
18
|
import { isRecord } from "./unknown.mjs";
|
|
17
19
|
export const AUDIT_RULE = "a11y-axe", INCOMPLETE_RULE = "a11y-incomplete", NON_TEXT_RULE = "a11y-non-text-contrast", DECLARED_BOUNDARY_RULE = "a11y-boundary-declared", OVERFLOW_RULE = "layout-overflow", NARROW_RULE = "layout-overflow-narrow", TEXT_SCALE_RULE = "a11y-text-scale", TEXT_SPACING_RULE = "a11y-text-spacing-override", REFLOW_RULE = "a11y-reflow", textWidths = Object.freeze({ reflow: 320, zoom: 640 }), SHIFT_RULE = "layout-shift";
|
|
18
20
|
const shiftLimit = 0.1;
|
|
@@ -210,6 +212,11 @@ const skipReasons = {
|
|
|
210
212
|
"control-detached": "a control left the page while it was being measured",
|
|
211
213
|
"control-failed": "measuring a control failed",
|
|
212
214
|
"control-cap": "the limit of 6 controls per render was reached and no other scenario has them",
|
|
215
|
+
"derived-state-unsupported": "an owner state its recipe declares is one the audit cannot set (another pseudo-class or a sibling combinator)",
|
|
216
|
+
"derived-state-not-applied": "an owner state could not be set on the rendered element (a native property it does not have, a part it does not hold)",
|
|
217
|
+
"derived-timeout": "measuring a derived owner state took too long",
|
|
218
|
+
"derived-detached": "an element left the page while a derived owner state was measured",
|
|
219
|
+
"derived-failed": "measuring a derived owner state failed",
|
|
213
220
|
"content-still-changing": "the page kept changing past 5 s, so what it measured may be mid-change",
|
|
214
221
|
"focus-not-reachable": "a control a keyboard cannot reach (aria-hidden, inert, or tabindex -1 outside a roving widget): hover measured, focus not"
|
|
215
222
|
}, overflowKinds = {
|
|
@@ -400,12 +407,14 @@ export function auditCoverage(runs, capped, scenarios) {
|
|
|
400
407
|
renders: runs.length,
|
|
401
408
|
overlaysOpened: 0,
|
|
402
409
|
controlsMeasured: 0,
|
|
410
|
+
derivedMeasured: 0,
|
|
403
411
|
skipped: Object.fromEntries([...reasons].sort(([a], [b]) => a.localeCompare(b)))
|
|
404
412
|
}, empty = [];
|
|
405
413
|
for (const run of runs)
|
|
406
414
|
if (run.coverage) {
|
|
407
415
|
coverage.overlaysOpened += run.coverage.overlays;
|
|
408
416
|
coverage.controlsMeasured += run.coverage.controls;
|
|
417
|
+
coverage.derivedMeasured += run.coverage.derived ?? 0;
|
|
409
418
|
if (run.coverage.skipped.filter((item) => /^(?:overlay|control)-(?:gone|timeout|detached|failed)$/.test(item.reason)).length && !run.coverage.overlays && !run.coverage.controls)
|
|
410
419
|
empty.push(run);
|
|
411
420
|
}
|
|
@@ -575,6 +584,7 @@ async function runAuditWorker({
|
|
|
575
584
|
claimed,
|
|
576
585
|
pages,
|
|
577
586
|
declared,
|
|
587
|
+
derived,
|
|
578
588
|
evidence
|
|
579
589
|
}) {
|
|
580
590
|
const request = path.join(temporary, "request.json"), report = path.join(temporary, "report.json"), runId = randomUUID();
|
|
@@ -600,6 +610,8 @@ async function runAuditWorker({
|
|
|
600
610
|
apps,
|
|
601
611
|
output: temporary,
|
|
602
612
|
declared,
|
|
613
|
+
derived,
|
|
614
|
+
conditionWidths: boundWidths(derived.flatMap((construction) => construction.bounds ?? []), overflowWidths),
|
|
603
615
|
evidence
|
|
604
616
|
}));
|
|
605
617
|
const timeoutMs = Math.min(1800000, settings.timeoutMs + apps.length * Math.min(settings.timeoutMs, 15000));
|
|
@@ -706,6 +718,7 @@ export async function runRenderAudit(directory, { scenarios: selected, themes: s
|
|
|
706
718
|
};
|
|
707
719
|
if (!host?.url)
|
|
708
720
|
host = await startHost();
|
|
721
|
+
let derived = [];
|
|
709
722
|
const settings = { browser: "chromium", timeoutMs: 60000, ...options.config.mcp.capture }, firstTheme = themes[0], firstBrand = brands[0], wanted = themes.flatMap((theme) => (brands.length ? brands : [void 0]).flatMap((brand) => scenarios.flatMap((scenario) => ((scenario.states?.length) ? scenario.states : [void 0]).map((state) => ({ scenario, state }))).map(({ scenario, state }) => ({
|
|
710
723
|
scenario: scenario.id,
|
|
711
724
|
theme: theme.name,
|
|
@@ -751,7 +764,10 @@ export async function runRenderAudit(directory, { scenarios: selected, themes: s
|
|
|
751
764
|
if (app.brand)
|
|
752
765
|
url.searchParams.set("brand", app.brand);
|
|
753
766
|
return { ...app, url: url.href };
|
|
754
|
-
}) : []
|
|
767
|
+
}) : [];
|
|
768
|
+
if (apps.length > 0)
|
|
769
|
+
derived = derivedConstructions(root);
|
|
770
|
+
const reached = apps.length ? await runAuditWorker({
|
|
755
771
|
root,
|
|
756
772
|
temporary,
|
|
757
773
|
playwright,
|
|
@@ -761,6 +777,7 @@ export async function runRenderAudit(directory, { scenarios: selected, themes: s
|
|
|
761
777
|
pages: options.config.mcp.auditPages,
|
|
762
778
|
claimed: [...renders.values()].flatMap((render) => render.result?.coverage?.claimed ?? []),
|
|
763
779
|
declared,
|
|
780
|
+
derived,
|
|
764
781
|
evidence
|
|
765
782
|
}) : { runs: [], capped: [] };
|
|
766
783
|
for (const item of reached.capped)
|
|
@@ -789,6 +806,8 @@ export async function runRenderAudit(directory, { scenarios: selected, themes: s
|
|
|
789
806
|
return run ? [run] : [];
|
|
790
807
|
}), retries = all.flatMap(({ app, attempts, causes, result }) => result && attempts > 1 ? [{ scenario: app.scenario, theme: app.theme, ...app.brand ? { brand: app.brand } : {}, attempts, causes }] : []), { coverage, findings: coverageItems } = auditCoverage(all.flatMap((render) => render.result ? [render.result] : []), [...capped.values()], scenarios), findings = [
|
|
791
808
|
...coverageItems,
|
|
809
|
+
...selected === void 0 || selected.length === 0 ? unrenderedConstructionFindings(runs, derived, path.relative(root, options.dsRoot) || ".") : [],
|
|
810
|
+
...derivedStateFindings(runs, scenarios, path.relative(root, options.dsRoot) || "."),
|
|
792
811
|
...findingsByState(runs, (some) => auditFindings(some, scenarios)),
|
|
793
812
|
...findingsByState(runs, (some) => nonTextContrastFindings(some, scenarios)),
|
|
794
813
|
...findingsByState(runs, (some) => declaredBoundaryFindings(some, scenarios, root)),
|
|
@@ -807,6 +826,7 @@ export async function runRenderAudit(directory, { scenarios: selected, themes: s
|
|
|
807
826
|
incomplete: findings.filter((finding) => finding.rule === INCOMPLETE_RULE).length,
|
|
808
827
|
overlaysOpened: coverage.overlaysOpened,
|
|
809
828
|
controlsMeasured: coverage.controlsMeasured,
|
|
829
|
+
derivedMeasured: coverage.derivedMeasured,
|
|
810
830
|
coverage,
|
|
811
831
|
findings,
|
|
812
832
|
...retries.length ? { retries } : {},
|
|
@@ -826,3 +846,96 @@ function axeVersion() {
|
|
|
826
846
|
const value = JSON.parse(readFileSync(requireTool.resolve("axe-core/package.json"), "utf8"));
|
|
827
847
|
return isRecord(value) && typeof value.version === "string" ? value.version : "unknown";
|
|
828
848
|
}
|
|
849
|
+
export function derivedConstructions(root) {
|
|
850
|
+
const file = path.join(previewTreeDirectory(root), PREVIEW_AUDIT_FILE);
|
|
851
|
+
let text;
|
|
852
|
+
try {
|
|
853
|
+
text = readFileSync(file, "utf8");
|
|
854
|
+
} catch {
|
|
855
|
+
return [];
|
|
856
|
+
}
|
|
857
|
+
return Object.entries(parseDerivedAudit(text)).flatMap(([owner, list]) => list.map((construction) => ({ owner, ...construction })));
|
|
858
|
+
}
|
|
859
|
+
export function unrenderedConstructionFindings(runs, derived, designRoot) {
|
|
860
|
+
if (derived.length === 0 || runs.length === 0 || runs.some((run) => run.coverage !== void 0 && run.coverage.rendered === void 0))
|
|
861
|
+
return [];
|
|
862
|
+
const rendered = new Set(runs.flatMap((run) => run.coverage?.rendered ?? [])), missing = new Map;
|
|
863
|
+
for (const construction of derived) {
|
|
864
|
+
if (rendered.has(`${construction.owner}\x00${construction.classes}`))
|
|
865
|
+
continue;
|
|
866
|
+
missing.set(construction.owner, [...missing.get(construction.owner) ?? [], construction]);
|
|
867
|
+
}
|
|
868
|
+
return [...missing].map(([owner, list]) => ({
|
|
869
|
+
rule: "render-audit-construction-unrendered",
|
|
870
|
+
severity: findingSeverity("render-audit-construction-unrendered"),
|
|
871
|
+
file: path.join(designRoot, owner),
|
|
872
|
+
line: 1,
|
|
873
|
+
column: 1,
|
|
874
|
+
source: "ads",
|
|
875
|
+
count: list.length,
|
|
876
|
+
message: `${list.length} construction${list.length === 1 ? "" : "s"} of ${owner} with owner states ${list.length === 1 ? "is" : "are"} rendered by no audited scenario, so ${list.length === 1 ? "its" : "their"} states are unmeasured: ${list.slice(0, 3).map((item) => `${item.states.map((state) => state.condition).join(", ")}`).join("; ")}${list.length > 3 ? ` and ${list.length - 3} more` : ""}.`
|
|
877
|
+
}));
|
|
878
|
+
}
|
|
879
|
+
export function derivedStateFindings(runs, scenarios, designRoot) {
|
|
880
|
+
const files = fileMap(scenarios), findings = [], shifts = new Map;
|
|
881
|
+
for (const run of runs)
|
|
882
|
+
for (const shift of run.derivedShifts ?? []) {
|
|
883
|
+
const key = JSON.stringify([run.scenario, shift.state]), known = shifts.get(key) ?? { scenario: run.scenario, themes: [], value: 0, nodes: shift.nodes, state: shift.state };
|
|
884
|
+
if (!known.themes.includes(run.theme))
|
|
885
|
+
known.themes.push(run.theme);
|
|
886
|
+
known.value = Math.max(known.value, shift.value);
|
|
887
|
+
shifts.set(key, known);
|
|
888
|
+
}
|
|
889
|
+
for (const shift of shifts.values())
|
|
890
|
+
findings.push({
|
|
891
|
+
rule: SHIFT_RULE,
|
|
892
|
+
severity: findingSeverity(SHIFT_RULE),
|
|
893
|
+
file: files.get(shift.scenario) ?? shift.scenario,
|
|
894
|
+
line: 1,
|
|
895
|
+
column: 1,
|
|
896
|
+
source: "ads",
|
|
897
|
+
scenario: shift.scenario,
|
|
898
|
+
themes: shift.themes,
|
|
899
|
+
value: shift.value,
|
|
900
|
+
nodes: shift.nodes,
|
|
901
|
+
message: `Layout shift ${shift.value.toFixed(3)} in ${shift.scenario} under ${shift.state}, after the state had settled (threshold ${shiftLimit}): ${shift.nodes.slice(0, 3).join(", ")}.`
|
|
902
|
+
});
|
|
903
|
+
const held = new Set(runs.flatMap((run) => (run.coverage?.held ?? []).map((key) => key.split("\x00").filter((_, index) => index !== 1).join("\x00")))), forced = new Set(runs.flatMap((run) => run.coverage?.forced ?? []).filter((key) => !held.has(key)));
|
|
904
|
+
for (const key of forced) {
|
|
905
|
+
const [owner = "", condition = ""] = key.split("\x00");
|
|
906
|
+
findings.push({
|
|
907
|
+
rule: "render-audit-state-forced",
|
|
908
|
+
severity: findingSeverity("render-audit-state-forced"),
|
|
909
|
+
file: path.join(designRoot, owner),
|
|
910
|
+
line: 1,
|
|
911
|
+
column: 1,
|
|
912
|
+
source: "ads",
|
|
913
|
+
message: `The audit measured ${condition} of ${owner} by setting the attribute, but the owner renders other markup when the prop behind it is set: what it measured is that state's CSS over the content at rest.`
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
const measured = new Set(runs.flatMap((run) => run.coverage?.measured ?? [])), reported = new Set;
|
|
917
|
+
for (const run of runs) {
|
|
918
|
+
if (run.state === void 0)
|
|
919
|
+
continue;
|
|
920
|
+
for (const key of run.coverage?.held ?? []) {
|
|
921
|
+
const [owner = "", , condition = ""] = key.split("\x00");
|
|
922
|
+
if (!measured.has(key) || forced.has(`${owner}\x00${condition}`) || runs.some((other) => (other.coverage?.forced ?? []).includes(`${owner}\x00${condition}`)))
|
|
923
|
+
continue;
|
|
924
|
+
const id = JSON.stringify([run.scenario, run.state, key]);
|
|
925
|
+
if (reported.has(id))
|
|
926
|
+
continue;
|
|
927
|
+
reported.add(id);
|
|
928
|
+
findings.push({
|
|
929
|
+
rule: "render-audit-state-derivable",
|
|
930
|
+
severity: findingSeverity("render-audit-state-derivable"),
|
|
931
|
+
file: files.get(run.scenario) ?? run.scenario,
|
|
932
|
+
line: 1,
|
|
933
|
+
column: 1,
|
|
934
|
+
source: "ads",
|
|
935
|
+
scenario: run.scenario,
|
|
936
|
+
message: `Scenario state "${run.state}" of ${run.scenario} shows ${condition} of ${owner}, which the audit already measures by itself: keep the state only if people need to see it.`
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return findings;
|
|
941
|
+
}
|
|
@@ -112,6 +112,10 @@ declare const tokenRolesByKind: {
|
|
|
112
112
|
frame: {
|
|
113
113
|
"border-width": string[];
|
|
114
114
|
radius: string[];
|
|
115
|
+
"start-start-radius": string[];
|
|
116
|
+
"start-end-radius": string[];
|
|
117
|
+
"end-start-radius": string[];
|
|
118
|
+
"end-end-radius": string[];
|
|
115
119
|
padding: string[];
|
|
116
120
|
"padding-inline": string[];
|
|
117
121
|
"padding-block": string[];
|
|
@@ -143,6 +147,7 @@ declare const tokenRolesByKind: {
|
|
|
143
147
|
blur: string[];
|
|
144
148
|
"backdrop-blur": string[];
|
|
145
149
|
"backdrop-saturate": string[];
|
|
150
|
+
brightness: string[];
|
|
146
151
|
mask: string[];
|
|
147
152
|
"border-inline-start-color": string[];
|
|
148
153
|
"border-inline-end-color": string[];
|
|
@@ -158,6 +163,10 @@ declare const tokenRolesByKind: {
|
|
|
158
163
|
"meta-gap": string[];
|
|
159
164
|
"section-gap": string[];
|
|
160
165
|
indent: string[];
|
|
166
|
+
overlap: string[];
|
|
167
|
+
"anchor-gap": string[];
|
|
168
|
+
"outset-block": string[];
|
|
169
|
+
"outset-inline": string[];
|
|
161
170
|
};
|
|
162
171
|
visual: {
|
|
163
172
|
size: string[];
|
package/dist/role-vocabulary.mjs
CHANGED
|
@@ -45,6 +45,9 @@ export const tokenShapeGrammars = {
|
|
|
45
45
|
opacity: "number-zero-to-one",
|
|
46
46
|
blur: "nonnegative-length",
|
|
47
47
|
saturation: "nonnegative-percentage",
|
|
48
|
+
brightness: "nonnegative-percentage",
|
|
49
|
+
"box-share": "nonnegative-percentage",
|
|
50
|
+
overlap: "nonnegative-length",
|
|
48
51
|
"font-family": "font-family-list",
|
|
49
52
|
"font-size": "positive-text-length",
|
|
50
53
|
"line-height": "positive-text-length-or-multiplier",
|
|
@@ -82,6 +85,9 @@ export const tokenRoleGuides = Object.freeze({
|
|
|
82
85
|
opacity: { purpose: "A surface or effect opacity, or a colour's alpha.", write: "a number from 0 to 1" },
|
|
83
86
|
blur: { purpose: "A blur radius: a filter, a backdrop, a shadow's blur.", write: "px" },
|
|
84
87
|
saturation: { purpose: "How vivid colours are, as a filter: of what is behind a surface.", write: "a percentage: 100% leaves colours as they are, 0% is greyscale" },
|
|
88
|
+
brightness: { purpose: "How bright a drawing is shown, as a filter: a picture with no dark version, dimmed in the dark theme.", write: "a percentage: 100% leaves it as it is, below 100% dims it, 0% is black" },
|
|
89
|
+
"box-share": { purpose: "A share of an element's own box: how far a backdrop is drawn past it on an axis, growing with the box.", write: "a percentage of the box's size on that axis" },
|
|
90
|
+
overlap: { purpose: "How far neighbours of an arrangement overlap, in place of a gap between them.", write: "px or rem" },
|
|
85
91
|
"font-family": { purpose: "The text font and its fallbacks.", write: null },
|
|
86
92
|
"font-size": { purpose: "Text size. It follows the reader's text size.", write: "rem (enforced; px is a11y-text-resize)" },
|
|
87
93
|
"line-height": { purpose: "A line's height. It is independent of font-size tokens.", write: "a unitless multiplier, or rem/em" },
|
|
@@ -129,6 +135,10 @@ const tokenRolesByKind = {
|
|
|
129
135
|
frame: {
|
|
130
136
|
"border-width": ["border-width"],
|
|
131
137
|
radius: ["radius"],
|
|
138
|
+
"start-start-radius": ["radius"],
|
|
139
|
+
"start-end-radius": ["radius"],
|
|
140
|
+
"end-start-radius": ["radius"],
|
|
141
|
+
"end-end-radius": ["radius"],
|
|
132
142
|
padding: ["frame-inset"],
|
|
133
143
|
"padding-inline": ["frame-inset"],
|
|
134
144
|
"padding-block": ["frame-inset"],
|
|
@@ -160,6 +170,7 @@ const tokenRolesByKind = {
|
|
|
160
170
|
blur: ["blur"],
|
|
161
171
|
"backdrop-blur": ["blur"],
|
|
162
172
|
"backdrop-saturate": ["saturation"],
|
|
173
|
+
brightness: ["brightness"],
|
|
163
174
|
mask: ["gradient"],
|
|
164
175
|
"border-inline-start-color": ["paint"],
|
|
165
176
|
"border-inline-end-color": ["paint"],
|
|
@@ -174,7 +185,11 @@ const tokenRolesByKind = {
|
|
|
174
185
|
"details-gap": ["content-gap", "spacing"],
|
|
175
186
|
"meta-gap": ["content-gap", "spacing"],
|
|
176
187
|
"section-gap": ["content-gap", "spacing"],
|
|
177
|
-
indent: ["content-gap", "spacing"]
|
|
188
|
+
indent: ["content-gap", "spacing"],
|
|
189
|
+
overlap: ["overlap", "content-gap", "spacing"],
|
|
190
|
+
"anchor-gap": ["layout-size", "content-gap", "spacing"],
|
|
191
|
+
"outset-block": ["content-gap", "spacing", "box-share"],
|
|
192
|
+
"outset-inline": ["content-gap", "spacing", "box-share"]
|
|
178
193
|
},
|
|
179
194
|
visual: { size: ["visual-size"], "stroke-width": ["border-width"] },
|
|
180
195
|
motion: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { selectedProfile, tokenValueContexts } from "./design-foundation.mjs";
|
|
2
|
-
import { inactiveCondition, NON_TEXT_MINIMUM, paintContrast } from "./paint-contrast.mjs";
|
|
2
|
+
import { inactiveCondition, NON_TEXT_MINIMUM, paintContrast, unshown } from "./paint-contrast.mjs";
|
|
3
3
|
import { describeUnresolved, surfacedElements, textMinimum } from "./surface-contrast.mjs";
|
|
4
4
|
import { err, ok } from "./result.mjs";
|
|
5
5
|
import { isPaintProperty } from "./runtime-paint.mjs";
|
|
@@ -68,7 +68,10 @@ export function runtimePaintContrast(foundation, spec) {
|
|
|
68
68
|
}
|
|
69
69
|
for (const pair of checked)
|
|
70
70
|
for (const context of contexts) {
|
|
71
|
-
const minimum = pair.minimum(context)
|
|
71
|
+
const minimum = pair.minimum(context);
|
|
72
|
+
if (unshown(pair.paints.foreground, context))
|
|
73
|
+
continue;
|
|
74
|
+
const outcome = paintContrast(context, pair.paints, minimum);
|
|
72
75
|
switch (outcome.kind) {
|
|
73
76
|
case "sufficient":
|
|
74
77
|
break;
|