@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
package/dist/motion-model.mjs
CHANGED
|
@@ -5,7 +5,7 @@ const OPERATIONS = {
|
|
|
5
5
|
"scale-inline": { channel: "scale", field: "scale", neutral: 1 },
|
|
6
6
|
"scale-block": { channel: "scale", field: "scale", neutral: 1 },
|
|
7
7
|
rotate: { channel: "rotate", field: "angle", neutral: 0 }
|
|
8
|
-
}, isProperty = (value) => Object.hasOwn(OPERATIONS, value), CHANNELS = ["translate", "scale", "rotate"], CONDITIONS = new Set(["&:hover:not(:disabled)", "&:active:not(:disabled)", '&[aria-busy="true"]']), declarationsOf = (node) => (node.nodes ?? []).filter((child) => child.type === "decl");
|
|
8
|
+
}, isProperty = (value) => Object.hasOwn(OPERATIONS, value), CHANNELS = ["translate", "scale", "rotate"], CONDITIONS = new Set(["&:hover:not(:disabled)", "&:active:not(:disabled)", '&[aria-busy="true"]', '&[aria-expanded="true"]', '&[aria-pressed="true"]', '&[aria-checked="true"]', '&[aria-selected="true"]']), declarationsOf = (node) => (node.nodes ?? []).filter((child) => child.type === "decl");
|
|
9
9
|
export const inspectMotion = (part, motionProfiles, { complete = !0 } = {}) => rejecting(() => {
|
|
10
10
|
const children = part.nodes ?? [], transitions = children.filter((node) => node.type === "decl" && node.prop === "transition"), whens = children.filter((node) => node.type === "atrule" && node.name === "ads-when" && declarationsOf(node).some((field) => isProperty(field.prop) || field.prop === "repeat"));
|
|
11
11
|
if (transitions.length === 0 && whens.length === 0)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { currentAnalysis, memoFact, memoProgram } from "./analysis/context.mjs";
|
|
3
3
|
import { capturedTreeFiles, optionalSourceText } from "./analysis/helpers.mjs";
|
|
4
|
-
import { projectOwnerCache, projectScenarioCache } from "./analysis/owner-analysis-cache.mjs";
|
|
4
|
+
import { projectConstructionCache, projectOwnerCache, projectScenarioCache } from "./analysis/owner-analysis-cache.mjs";
|
|
5
|
+
import { wholeDesignDigests } from "./analysis/design-reads.mjs";
|
|
6
|
+
import { scenarioWork } from "./analysis/scenario-keys.mjs";
|
|
5
7
|
import { designDigests } from "./analysis/owner-analysis-key.mjs";
|
|
6
8
|
import { barrelDeclarations, checkDesignSystem } from "./analysis/owner-discovery.mjs";
|
|
7
9
|
import { ownerReuse } from "./analysis/owner-reuse.mjs";
|
|
@@ -115,7 +117,14 @@ async function analyzeRevision(inputs, captured, settings) {
|
|
|
115
117
|
const reads = designInputs.stats.reads, design = timing.timeStage("design-inputs", () => designInputs.read(captured, settings), void 0, () => ({ reused: designInputs.stats.reads === reads }));
|
|
116
118
|
if (design.kind === "err")
|
|
117
119
|
return { report: { diagnostics: findingsOf(inputs, { kind: "design-inputs", failure: design.error }), advisories: [], contexts: [], palette: [], tokens: [], fonts: [], appIcon: [], assets: [], composed: [], packages: [] }, checked: null };
|
|
118
|
-
const { foundation, assets, contexts } = design.value, texts = designTexts(captured), contextFindings = design.value.undefinedContexts.map((item) => undefinedContextFinding(inputs, texts, item)), palette = paletteFindings(inputs, foundation, contexts, design.value.palette), tokens = timing.timeStage("token-checks", () => tokenFindings(inputs, texts, foundation, design.value.document)), missing = missingTokenFindings(inputs, texts, foundation), fonts = timing.timeStage("font-checks", () => fontFindings(inputs, texts, foundation, design.value.document, design.value.fonts)), icon = await timing.timeStage("app-icon-checks", () => appIconReading(design.value.appIcon, { assets, foundation, contexts })), appIcon = icon.findings.map((finding) => appIconFinding(inputs, texts, finding)),
|
|
120
|
+
const { foundation, assets, contexts } = design.value, texts = designTexts(captured), contextFindings = design.value.undefinedContexts.map((item) => undefinedContextFinding(inputs, texts, item)), palette = paletteFindings(inputs, foundation, contexts, design.value.palette), tokens = timing.timeStage("token-checks", () => tokenFindings(inputs, texts, foundation, design.value.document)), missing = missingTokenFindings(inputs, texts, foundation), fonts = timing.timeStage("font-checks", () => fontFindings(inputs, texts, foundation, design.value.document, design.value.fonts)), icon = await timing.timeStage("app-icon-checks", () => appIconReading(design.value.appIcon, { assets, foundation, contexts })), appIcon = icon.findings.map((finding) => appIconFinding(inputs, texts, finding)), digests = designDigests(texts, assets, inputs.dsRoot), constructions = {
|
|
121
|
+
cache: projectConstructionCache(inputs.cacheOwner),
|
|
122
|
+
root: inputs.dsRoot,
|
|
123
|
+
catalog: assets,
|
|
124
|
+
whole: wholeDesignDigests(foundation, digests.assets),
|
|
125
|
+
tokens: digests.tokens,
|
|
126
|
+
tally: { reused: 0, built: 0 }
|
|
127
|
+
}, reuse = ownerReuse({
|
|
119
128
|
cache: projectOwnerCache(inputs.cacheOwner),
|
|
120
129
|
scenarios: projectScenarioCache(inputs.cacheOwner),
|
|
121
130
|
root: inputs.dsRoot,
|
|
@@ -123,7 +132,8 @@ async function analyzeRevision(inputs, captured, settings) {
|
|
|
123
132
|
framework: inputs.framework ?? null,
|
|
124
133
|
contexts,
|
|
125
134
|
foundation,
|
|
126
|
-
|
|
135
|
+
assets,
|
|
136
|
+
design: digests,
|
|
127
137
|
environment: revisionEnvironment()
|
|
128
138
|
}), options = {
|
|
129
139
|
foundation,
|
|
@@ -135,8 +145,12 @@ async function analyzeRevision(inputs, captured, settings) {
|
|
|
135
145
|
publicAlias: inputs.publicAlias,
|
|
136
146
|
framework: inputs.framework ?? null,
|
|
137
147
|
stats: analysis,
|
|
138
|
-
cache: extractionCache(inputs.cacheOwner, inputs.cacheLimits)
|
|
139
|
-
|
|
148
|
+
cache: extractionCache(inputs.cacheOwner, inputs.cacheLimits),
|
|
149
|
+
constructions
|
|
150
|
+
}, styling = { ...scenarioWork.styling }, analyzed = await checkDesignSystem(inputs.dsRoot, options, reuse.owners);
|
|
151
|
+
timing.recordStage("construction-reuse", 0, { ...constructions.tally });
|
|
152
|
+
timing.recordStage("scenario-styling", 0, { computed: scenarioWork.styling.computed - styling.computed, reused: scenarioWork.styling.reused - styling.reused });
|
|
153
|
+
const tally = reuse.tally();
|
|
140
154
|
owners.last = tally;
|
|
141
155
|
if (tally !== null) {
|
|
142
156
|
owners.analyzed += tally.analyzed.length;
|
|
@@ -292,11 +306,13 @@ async function composedFindings(inputs, captured, check, foundation, document) {
|
|
|
292
306
|
const declarations = await barrelDeclarations(inputs.dsRoot, inputs.publicAlias, inputs.framework ?? null), publics = new Set([...declarations?.values() ?? []].flatMap((item) => item === null ? [] : [`${item.file}#${item.declaration}`])), owners = new Map;
|
|
293
307
|
for (const [name, owner] of analyzedOwners(check.outcomes))
|
|
294
308
|
owners.set(name, owner.composition);
|
|
309
|
+
for (const [name, facts] of check.plainComposition)
|
|
310
|
+
owners.set(name, facts);
|
|
295
311
|
const findings = composedContrastFindings({
|
|
296
312
|
foundation,
|
|
297
313
|
document: { surface: document.names.surface, text: { fontSize: document.text.get("font-size") ?? null, fontWeight: document.text.get("font-weight") ?? null } },
|
|
298
314
|
owners,
|
|
299
|
-
discovered: new Set(check.outcomes.keys()),
|
|
315
|
+
discovered: new Set([...check.outcomes.keys(), ...check.plainComposition.keys()]),
|
|
300
316
|
publics,
|
|
301
317
|
plain: check.plainPlacements
|
|
302
318
|
}), text = (name) => captured.get(name) ?? null, at = (site) => {
|
|
@@ -608,6 +624,7 @@ function designInputPosition(inputs, failure) {
|
|
|
608
624
|
return sitePositionIn(inputs, revisionDesignText(inputs), { kind: "macro-field", file: inner.file, macro: "profile", declaration: inner.declaration, path: inner.path });
|
|
609
625
|
case "profile-rejected":
|
|
610
626
|
case "token-role":
|
|
627
|
+
case "provided-role-self":
|
|
611
628
|
return foundationPosition(inputs);
|
|
612
629
|
case "document-profile-kind":
|
|
613
630
|
return designFile(inputs, FOUNDATION_DECLARATION);
|
package/dist/owner-errors.mjs
CHANGED
|
@@ -64,6 +64,7 @@ export function foundationError(failure) {
|
|
|
64
64
|
case "profile-argument-default":
|
|
65
65
|
case "profile-field-unknown":
|
|
66
66
|
case "token-role":
|
|
67
|
+
case "provided-role-self":
|
|
67
68
|
case "document-profile-kind":
|
|
68
69
|
return { code: `foundation/${failure.kind}`, ...entry(foundationErrors, failure.kind, failure) };
|
|
69
70
|
}
|
|
@@ -95,9 +96,8 @@ export function constructionError(failure) {
|
|
|
95
96
|
case "surface-shadow-layer":
|
|
96
97
|
case "content-missing":
|
|
97
98
|
case "profile-provider-conflict":
|
|
98
|
-
case "parts-visual-repeated":
|
|
99
99
|
case "artwork-binding-missing":
|
|
100
|
-
case "paint-
|
|
100
|
+
case "artwork-paint-contrast-insufficient":
|
|
101
101
|
case "spatial-token-expected":
|
|
102
102
|
case "spatial-bound-unit":
|
|
103
103
|
case "spatial-clause-unsupported":
|
|
@@ -107,7 +107,6 @@ export function constructionError(failure) {
|
|
|
107
107
|
case "drawn-height-below-minimum":
|
|
108
108
|
case "paint-transition-redundant":
|
|
109
109
|
case "paint-transition-effect-unsupported":
|
|
110
|
-
case "prose-contrast-insufficient":
|
|
111
110
|
case "condition-visual-unsupported":
|
|
112
111
|
case "sequence-steps-invalid":
|
|
113
112
|
case "sequence-not-seamless":
|
|
@@ -121,8 +120,11 @@ export function constructionError(failure) {
|
|
|
121
120
|
case "enter-surface-unsupported":
|
|
122
121
|
case "enter-property-conflict":
|
|
123
122
|
case "pseudo-surface-unsupported":
|
|
123
|
+
case "state-geometry-unsupported":
|
|
124
124
|
case "placeholder-contrast-insufficient":
|
|
125
125
|
case "placeholder-contrast-unresolved":
|
|
126
|
+
case "progress-contrast-insufficient":
|
|
127
|
+
case "progress-contrast-unresolved":
|
|
126
128
|
case "state-contrast-insufficient":
|
|
127
129
|
case "inactive-surface-active":
|
|
128
130
|
case "target-size-below-minimum":
|
|
@@ -142,6 +144,7 @@ export function constructionError(failure) {
|
|
|
142
144
|
case "rule-paint-missing":
|
|
143
145
|
case "extent-conflict":
|
|
144
146
|
case "extent-parent-unsupported":
|
|
147
|
+
case "space-parent-unsupported":
|
|
145
148
|
case "extent-row-hugs":
|
|
146
149
|
case "layered-parts-missing":
|
|
147
150
|
case "condition-unknown":
|
package/dist/owner-lowering.mjs
CHANGED
|
@@ -3,7 +3,9 @@ import { reducedMotionPolicy } from "./lowering-motion.mjs";
|
|
|
3
3
|
import { attempt } from "./result.mjs";
|
|
4
4
|
import { tokenValueContexts } from "./design-foundation.mjs";
|
|
5
5
|
import { lengthPx } from "./css-length.mjs";
|
|
6
|
+
import { inactiveCondition, NON_TEXT_MINIMUM, paintContrast, unshown } from "./paint-contrast.mjs";
|
|
6
7
|
import { normalizedDeclarations, scaleValue } from "./construction-spec.mjs";
|
|
8
|
+
import { frameValues } from "./region-lowering.mjs";
|
|
7
9
|
import { FRAME_INSET_FIELDS } from "./lowering-region-layout.mjs";
|
|
8
10
|
import {
|
|
9
11
|
HIT_AREA_FIELDS,
|
|
@@ -51,7 +53,7 @@ export function controlEnvelope(spec, line, visual, gap) {
|
|
|
51
53
|
}
|
|
52
54
|
export function lowerControl(spec, foundation, input) {
|
|
53
55
|
return attempt((reject) => {
|
|
54
|
-
const profile = profiles(foundation, reject), selected = profile.select(spec.profile, spec.select), slots = Object.fromEntries(selected.fields), text = profile.of(spec.text ?? slots["text-profile"], "text", spec.profile), frame = profile.of(slots["frame-profile"], "frame", spec.profile), spacing = profile.of(slots["spacing-profile"], "spacing", spec.profile), visual = profile.of(slots["visual-profile"], "visual", spec.profile), focus = profile.of(slots["focus-profile"], "focus", spec.profile), animated = spec.glyph !== null && (spec.glyph.transition.length > 0 || spec.glyph.when.length > 0), pressed = spec.press.when.length > 0, motion = animated || pressed || slots["motion-profile"] !== void 0 ? profile.of(slots["motion-profile"], "motion", spec.profile) : {};
|
|
56
|
+
const profile = profiles(foundation, reject), selected = profile.select(spec.profile, spec.select), slots = Object.fromEntries(selected.fields), text = profile.of(spec.text ?? slots["text-profile"], "text", spec.profile), frame = profile.of(slots["frame-profile"], "frame", spec.profile), spacing = profile.of(slots["spacing-profile"], "spacing", spec.profile), visual = profile.of(slots["visual-profile"], "visual", spec.profile), focus = profile.of(slots["focus-profile"], "focus", spec.profile), animated = spec.glyph !== null && (spec.glyph.transition.length > 0 || spec.glyph.when.length > 0) || spec.decor.some((box) => box.when.some(([, , effects]) => effects.length > 0)), pressed = spec.press.when.length > 0, motion = animated || pressed || slots["motion-profile"] !== void 0 ? profile.of(slots["motion-profile"], "motion", spec.profile) : {};
|
|
55
57
|
if (animated || pressed || slots["motion-profile"] !== void 0) {
|
|
56
58
|
const reduced = reducedMotionPolicy(motion.reduced);
|
|
57
59
|
if (reduced.kind === "unsupported")
|
|
@@ -70,11 +72,11 @@ export function lowerControl(spec, foundation, input) {
|
|
|
70
72
|
if (line !== void 0 && spec.normalize.some(([property]) => property === "border-style"))
|
|
71
73
|
return reject({ kind: "extent-conflict", element: "&", property: "border-style", providers: ["frame profile", "normalize"] });
|
|
72
74
|
const minInline = frame["min-inline-size"], { asset, hasText } = input;
|
|
73
|
-
if (!hasText && asset === null)
|
|
75
|
+
if (!hasText && asset === null && spec.decor.length === 0)
|
|
74
76
|
return reject({ kind: "content-missing" });
|
|
75
|
-
if (asset !== null && asset.paint
|
|
76
|
-
|
|
77
|
-
const geometry = asset === null ? null : visualPart(asset, visual, input.state, LIGHT, reject), at = (fields, name, owner) => profile.field(fields, owner, name), lineHeight = at(text, "line-height", "text"), gap = at(spacing, "content-gap", "spacing"), box = controlBox(frame, controlEnvelope(spec, hasText ? LINE_BOX : null, geometry?.extent ?? null, gap), profile.field, reject), keepsWidth = hasText && spec.label
|
|
77
|
+
if (asset !== null && asset.paint === "slots")
|
|
78
|
+
slotArtworkContrast(foundation, asset, spec, (name) => profile.of(name, "surface"), reject);
|
|
79
|
+
const geometry = asset === null ? null : visualPart(asset, visual, input.state, input.theme ?? LIGHT, reject), at = (fields, name, owner) => profile.field(fields, owner, name), lineHeight = at(text, "line-height", "text"), gap = at(spacing, "content-gap", "spacing"), box = controlBox(frame, controlEnvelope(spec, hasText ? LINE_BOX : null, geometry?.extent ?? null, gap), profile.field, reject), keepsWidth = hasText && spec.label?.wrap === "never";
|
|
78
80
|
out.rule("&", {
|
|
79
81
|
...controlArrangement(spec),
|
|
80
82
|
...spec.extent === "container" && spec.layout !== "native" ? { display: "flex", "inline-size": "100%" } : {},
|
|
@@ -114,17 +116,23 @@ export function lowerControl(spec, foundation, input) {
|
|
|
114
116
|
"outline-style": "solid"
|
|
115
117
|
});
|
|
116
118
|
const { label, glyph } = spec;
|
|
117
|
-
|
|
119
|
+
for (const box of spec.decor)
|
|
120
|
+
lowerDecor(out, box, profile, motion, reject);
|
|
121
|
+
if (hasText && label !== null) {
|
|
118
122
|
const trim = label.textEdge.length === 0 ? {} : { "text-box-trim": "trim-both", "text-box-edge": label.textEdge.join(" ") }, wrap = label.wrap === "never" ? { "white-space": "nowrap" } : { "min-inline-size": "0", "overflow-wrap": label.wrap === "anywhere" ? "anywhere" : "break-word" };
|
|
119
|
-
|
|
123
|
+
if (label.extent === "fill" && spec.layout !== "inline")
|
|
124
|
+
return reject({ kind: "profile-field-unsupported", profile: "recipe", field: `parts.${label.name}.extent`, value: spec.layout });
|
|
125
|
+
const fill = label.extent === "fill" ? { "flex-grow": "1", "flex-basis": "0%", "min-inline-size": "0" } : {};
|
|
126
|
+
out.rule(`& > ${label.selector}`, { ...wrap, ...fill, ...trim, ...label.align === null ? {} : { "text-align": label.align } });
|
|
120
127
|
}
|
|
121
128
|
if (geometry !== null && glyph !== null) {
|
|
122
|
-
const part = `& > ${glyph.selector}
|
|
129
|
+
const part = `& > ${glyph.selector}`, turns = glyph.when.some(([, effects]) => effects.some((effect) => effect.effect === "rotate"));
|
|
123
130
|
out.rule(part, {
|
|
124
131
|
...geometry.part,
|
|
125
132
|
...animated ? {
|
|
126
133
|
translate: "0px",
|
|
127
134
|
scale: "1",
|
|
135
|
+
...turns ? { rotate: "0deg" } : {},
|
|
128
136
|
...glyph.transition.length > 0 ? {
|
|
129
137
|
"transition-property": glyph.transition.join(", "),
|
|
130
138
|
"transition-duration": at(motion, "duration", "motion"),
|
|
@@ -133,12 +141,16 @@ export function lowerControl(spec, foundation, input) {
|
|
|
133
141
|
} : {}
|
|
134
142
|
} : {}
|
|
135
143
|
});
|
|
136
|
-
out.rule(`${part} >
|
|
144
|
+
out.rule(`${part} > ${geometry.element}`, geometry.media);
|
|
145
|
+
if (asset !== null && asset.paint === "slots")
|
|
146
|
+
out.paint(glyph.selector, [...asset.slots].map(([slot, value]) => ({ slot, paint: value === "currentColor" ? { kind: "current-color" } : { kind: "token", name: value } })));
|
|
137
147
|
for (const [condition, effects] of glyph.when) {
|
|
138
148
|
const values = {};
|
|
139
149
|
for (const effect of effects)
|
|
140
150
|
if (effect.effect === "translate-inline")
|
|
141
151
|
values.translate = at(motion, effect.field, "motion");
|
|
152
|
+
else if (effect.effect === "rotate")
|
|
153
|
+
values.rotate = at(motion, effect.field, "motion");
|
|
142
154
|
else
|
|
143
155
|
values.scale = scaleValue(effect.effect, at(motion, effect.field, "motion"));
|
|
144
156
|
out.rule(`${condition} > ${glyph.selector}`, values);
|
|
@@ -149,12 +161,64 @@ export function lowerControl(spec, foundation, input) {
|
|
|
149
161
|
if (inline !== void 0)
|
|
150
162
|
out.rule(`${condition}:dir(rtl) > ${glyph.selector}`, { translate: "0px" }, reduced);
|
|
151
163
|
}
|
|
152
|
-
const moved = [...new Set(glyph.when.flatMap(([, effects]) => effects.map((effect) => effect.effect === "translate-inline" ? "translate" : "scale")))];
|
|
164
|
+
const moved = [...new Set(glyph.when.flatMap(([, effects]) => effects.map((effect) => effect.effect === "translate-inline" ? "translate" : effect.effect === "rotate" ? "rotate" : "scale")))];
|
|
153
165
|
writePlays(out, profile, foundation, glyph.name, glyph.plays, part, moved, reject);
|
|
154
166
|
}
|
|
155
167
|
return out.finish({ kind: "control", artwork: geometry === null ? null : placed(geometry), targets: { elements: [target], neighbours: [] } }, input.hidden);
|
|
156
168
|
});
|
|
157
169
|
}
|
|
170
|
+
function lowerDecor(out, box, profile, motion, reject) {
|
|
171
|
+
const path = `& > ${box.selector}`, base = box.surface === null ? {} : profile.of(box.surface, "surface"), moved = new Set(box.when.flatMap(([, , effects]) => effects.map((effect) => effect.effect === "translate-inline" ? "translate" : "scale"))), timing = box.transition.length === 0 ? {} : {
|
|
172
|
+
"transition-property": box.transition.join(", "),
|
|
173
|
+
"transition-duration": profile.field(motion, "motion", "duration"),
|
|
174
|
+
...motion.delay === void 0 ? {} : { "transition-delay": motion.delay },
|
|
175
|
+
"transition-timing-function": profile.field(motion, "motion", "easing")
|
|
176
|
+
};
|
|
177
|
+
out.rule(path, {
|
|
178
|
+
"box-sizing": "border-box",
|
|
179
|
+
"flex-grow": "0",
|
|
180
|
+
"flex-shrink": "0",
|
|
181
|
+
"flex-basis": "auto",
|
|
182
|
+
...frameValues(profile.of(box.box, "frame"), profile, reject),
|
|
183
|
+
...settled(base, !1),
|
|
184
|
+
...moved.has("translate") ? { translate: "0px" } : {},
|
|
185
|
+
...moved.has("scale") ? { scale: "1" } : {},
|
|
186
|
+
...timing
|
|
187
|
+
});
|
|
188
|
+
for (const [condition, surface, effects] of box.when) {
|
|
189
|
+
const values = surface === null ? {} : { ...settled(profile.of(surface, "surface"), !1) };
|
|
190
|
+
for (const effect of effects) {
|
|
191
|
+
const value = profile.field(motion, "motion", effect.field);
|
|
192
|
+
if (effect.effect === "translate-inline")
|
|
193
|
+
values.translate = value;
|
|
194
|
+
else if (effect.effect !== "rotate")
|
|
195
|
+
values.scale = scaleValue(effect.effect, value);
|
|
196
|
+
}
|
|
197
|
+
out.rule(`${condition} > ${box.selector}`, values);
|
|
198
|
+
const inline = effects.find((effect) => effect.effect === "translate-inline");
|
|
199
|
+
if (inline !== void 0)
|
|
200
|
+
out.rule(`${condition}:dir(rtl) > ${box.selector}`, { translate: `calc(${profile.field(motion, "motion", inline.field)} * -1)` });
|
|
201
|
+
}
|
|
202
|
+
if (box.transition.length > 0)
|
|
203
|
+
out.rule(path, { "transition-duration": "0s", "transition-delay": "0s" }, ["media", "(prefers-reduced-motion: reduce)"]);
|
|
204
|
+
}
|
|
205
|
+
function slotArtworkContrast(foundation, asset, spec, surface, reject) {
|
|
206
|
+
const base = surface(spec.surface), states = [[null, base], ...spec.when.filter(([condition]) => !inactiveCondition(condition)).map(([condition, name]) => [condition, surface(name)])];
|
|
207
|
+
for (const context of tokenValueContexts(foundation))
|
|
208
|
+
for (const [condition, fields] of states) {
|
|
209
|
+
const background = fields.background ?? base.background;
|
|
210
|
+
if (background === void 0)
|
|
211
|
+
continue;
|
|
212
|
+
const paints = [...asset.slots.values()].map((value) => value === "currentColor" ? fields.color ?? base.color ?? null : `var(${value})`).filter((value) => value !== null), shown = paints.filter((foreground) => !unshown(foreground, context));
|
|
213
|
+
if (shown.length === 0)
|
|
214
|
+
continue;
|
|
215
|
+
const outcomes = shown.map((foreground) => paintContrast(context, { foreground, background }, NON_TEXT_MINIMUM));
|
|
216
|
+
if (outcomes.some((outcome) => outcome.kind !== "insufficient"))
|
|
217
|
+
continue;
|
|
218
|
+
const ratio = Math.max(...outcomes.map((outcome) => outcome.kind === "insufficient" ? outcome.ratio : 0));
|
|
219
|
+
return reject({ kind: "artwork-paint-contrast-insufficient", asset: asset.name, context: context.label, state: condition, background, paints, ratio, minimum: NON_TEXT_MINIMUM });
|
|
220
|
+
}
|
|
221
|
+
}
|
|
158
222
|
function drawnHeight(foundation, asset, visual, reject) {
|
|
159
223
|
const minimum = asset.spec.minDrawnHeight;
|
|
160
224
|
if (minimum === void 0)
|
|
@@ -177,9 +241,10 @@ export function lowerArtwork(spec, foundation, input) {
|
|
|
177
241
|
return attempt((reject) => {
|
|
178
242
|
const profile = profiles(foundation, reject), { asset, visualProfile, theme } = input;
|
|
179
243
|
if (asset === null || visualProfile === null)
|
|
180
|
-
return reject({ kind: "artwork-binding-missing" });
|
|
181
|
-
const visual = profile.of(visualProfile, "visual"), geometry = visualPart(asset, visual, input.state, theme, reject), out = output(input.root, "lowerArtwork", reject, profile), height = drawnHeight(foundation, asset, visual, reject), { part } = spec;
|
|
182
|
-
|
|
244
|
+
return reject({ kind: "artwork-binding-missing", missing: asset === null ? "asset" : "visual" });
|
|
245
|
+
const visual = profile.of(visualProfile, "visual"), geometry = visualPart(asset, visual, input.state, theme, reject), out = output(input.root, "lowerArtwork", reject, profile), height = drawnHeight(foundation, asset, visual, reject), { part } = spec, tone = spec.surface === null ? {} : profile.of(spec.surface, "surface");
|
|
246
|
+
profile.only(tone, "surface", ["color"]);
|
|
247
|
+
out.rule("&", { display: "inline-flex", "align-items": spec.align, "justify-content": "center", "min-inline-size": "0", ...tone.color === void 0 ? {} : { color: tone.color } });
|
|
183
248
|
out.rule(`& > ${part.selector}`, geometry.part);
|
|
184
249
|
out.rule(`& > ${part.selector} > ${geometry.element}`, geometry.media);
|
|
185
250
|
if (asset.paint === "slots")
|
package/dist/owner-scenarios.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { throwIfCancelled } from "./analysis/context.mjs";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import { isAuthoring, publicExports } from "./analysis/owner-discovery.mjs";
|
|
3
4
|
import { location, memoProgram, symbolAt, unalias, valueSymbolAt, walk } from "./analysis/helpers.mjs";
|
|
@@ -9,8 +10,6 @@ import { PUBLIC_BARREL, ownerCompilerOptions, ownerProgramRoots, programSource }
|
|
|
9
10
|
import ts from "./analysis/syntax.mjs";
|
|
10
11
|
import { isScenarioFile, scenarioIdentity, sourceFiles } from "./config.mjs";
|
|
11
12
|
import { isDevelopmentModule } from "./development-modules.mjs";
|
|
12
|
-
import { publicProse } from "./analysis/prose-owners.mjs";
|
|
13
|
-
import { isProseTag } from "./prose-model.mjs";
|
|
14
13
|
import { findingRules } from "./finding-rules.mjs";
|
|
15
14
|
import { err, ok } from "./result.mjs";
|
|
16
15
|
import { createScenarioGroups } from "./scenario-groups.mjs";
|
|
@@ -174,7 +173,7 @@ async function registrationOf(options, program, checker, file) {
|
|
|
174
173
|
for (const problem of subjects.problems)
|
|
175
174
|
report(problem.rule, problem.message, problem.node ?? record.nodes.get(problem.field) ?? metadata?.node, problem.entry);
|
|
176
175
|
if (kind !== "mocks")
|
|
177
|
-
for (const problem of markupProblems(dsRoot, source
|
|
176
|
+
for (const problem of markupProblems(dsRoot, source))
|
|
178
177
|
report("scenario-markup", problem.message, problem.node);
|
|
179
178
|
let valid = !entry && subjects.renders.length > 0;
|
|
180
179
|
for (const [name, node] of record.nodes)
|
|
@@ -594,7 +593,7 @@ const specimenRenders = (checker, source) => memoProgram(source, "owner-scenario
|
|
|
594
593
|
const { metadata } = scenarioExports(source), record = metadata?.initializer === void 0 ? void 0 : await recordOf(checker, metadata.initializer, new Set, SUBJECT_FIELDS);
|
|
595
594
|
return record === void 0 ? [] : (await specimensOf(checker, record)).renders;
|
|
596
595
|
});
|
|
597
|
-
function markupProblems(dsRoot, source
|
|
596
|
+
function markupProblems(dsRoot, source) {
|
|
598
597
|
const problems = [], development = new Map;
|
|
599
598
|
for (const statement of source.statements) {
|
|
600
599
|
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier) || !statement.moduleSpecifier.text.startsWith("."))
|
|
@@ -623,12 +622,6 @@ function markupProblems(dsRoot, source, prose) {
|
|
|
623
622
|
problems.push({ node: attribute, message: "A scenario does not style what it shows: remove `style`. A size or a position the subject needs comes from the scenario kit's Container, or from the owner's own props." });
|
|
624
623
|
const tag = node.tagName, name = tag.getText();
|
|
625
624
|
if (ts.isIdentifier(tag) && /^[a-z]/.test(name)) {
|
|
626
|
-
const owner = isProseTag(name) ? proseOwnerOf(node, prose) : void 0;
|
|
627
|
-
if (owner !== void 0) {
|
|
628
|
-
if (!owner.tags.has(name))
|
|
629
|
-
problems.push({ node: tag, message: `<${name}> is content of ${owner.name}, whose prose recipe declares no such element: it would be drawn without a design. Declare the element in the recipe's \`elements\`, or write the content with the elements it declares.` });
|
|
630
|
-
return;
|
|
631
|
-
}
|
|
632
625
|
problems.push({ node: tag, message: `A scenario renders public owners and the scenario kit, not <${name}>. ADS draws the page: put text in \`title\`, \`description\` and each specimen's \`title\` and \`note\`, choose its \`arrangement\` and \`width\`, and use the kit (Container, Placeholder, Anchor, EventLog) around a subject that needs one.` });
|
|
633
626
|
return;
|
|
634
627
|
}
|
|
@@ -641,18 +634,6 @@ function markupProblems(dsRoot, source, prose) {
|
|
|
641
634
|
});
|
|
642
635
|
return problems;
|
|
643
636
|
}
|
|
644
|
-
function proseOwnerOf(node, prose) {
|
|
645
|
-
for (let current = node.parent;current !== void 0; current = current.parent) {
|
|
646
|
-
if (!ts.isJsxElement(current) || current.openingElement === node)
|
|
647
|
-
continue;
|
|
648
|
-
const tag = current.openingElement.tagName;
|
|
649
|
-
if (ts.isIdentifier(tag) && isProseTag(tag.text))
|
|
650
|
-
continue;
|
|
651
|
-
const tags = ts.isIdentifier(tag) ? prose.get(tag.text) : void 0;
|
|
652
|
-
return tags === void 0 ? void 0 : { name: tag.getText(), tags };
|
|
653
|
-
}
|
|
654
|
-
return;
|
|
655
|
-
}
|
|
656
637
|
const defaultExportNode = (source) => source.statements.find((statement) => ts.isExportAssignment(statement) || ts.isFunctionDeclaration(statement) && hasModifier(statement, ts.SyntaxKind.DefaultKeyword));
|
|
657
638
|
async function renderedNames(checker, dsRoot, entries, exported) {
|
|
658
639
|
const rendered = new Set, visited = new Set, pending = [...entries];
|
|
@@ -818,8 +799,10 @@ export async function scenarioFindings(options, reuse = null) {
|
|
|
818
799
|
const files = sourceFiles(options.dsRoot, options).filter(isScenarioFile).sort();
|
|
819
800
|
let program;
|
|
820
801
|
const compute = async (file) => factsOf(options, await (program ??= reuse === null ? scenarioProgram(options, files) : Promise.resolve(reuse.program)), file), keys = reuse === null ? null : await revisionScenarioKeys({ dsRoot: options.dsRoot, publicAlias: options.config.publicAlias, framework: options.config.framework ?? null, graph: reuse.graph, globals: reuse.globals }), cache = reuse === null || keys === null ? null : projectScenarioCache(reuse.cacheOwner), facts = [];
|
|
821
|
-
for (const file of files)
|
|
802
|
+
for (const file of files) {
|
|
803
|
+
throwIfCancelled();
|
|
822
804
|
facts.push(await obtainScenarioResult(cache, options.dsRoot, keys?.get(path.relative(options.dsRoot, file).split(path.sep).join("/")), "facts", () => compute(file)));
|
|
805
|
+
}
|
|
823
806
|
const { diagnostics, registered } = assemble(options, files, facts.map((fact) => fact.registration)), unreadable = diagnostics.some((diagnostic) => diagnostic.rule === "scenario-metadata"), scenarios = registered.filter(({ entry }) => entry.kind !== "mocks").map(({ file, entry }) => ({ file: projectPath(options, file), covers: [...entry.covers] })), coverage = scenarioCoverage(options, { scenarios }, exports.value).filter((finding) => !(unreadable && finding.rule === "scenario-coverage")), unrendered = new Map(files.map((file, index) => [file, facts[index]?.unrendered ?? null])), renders = registered.flatMap(({ file }) => (unrendered.get(file) ?? []).filter(({ name }) => exports.value.names.has(name)).map(({ name, line, column }) => ({
|
|
824
807
|
rule: "scenario-render",
|
|
825
808
|
file: projectPath(options, file),
|
package/dist/ownership-model.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fail, rejecting } from "./design-rejection.mjs";
|
|
2
|
-
import { CURSORS, ELEMENT_NAMES, FRAME_CORNERS, FRAME_SIDES, OVERFLOW_VALUES, PAINT_CHANNELS, RESIZES, SNAP_ALIGNS, SNAP_TYPES, TEXT_ALIGNS, TEXT_WRAPS, TOUCH_ACTIONS, USER_SELECTS } from "./construction-spec.mjs";
|
|
3
|
-
const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[a-z][\w-]*(?:,\s*[a-z][\w-]*:\s*[a-z][\w-]*)*\))?$/, binding = (value) => profile.test(value) || /^profile\([\w-]+-profile\)$/.test(value), wordList = (value) => value.split(/\s+/).every((word) => identifier.test(word)), positive = (value) => /^[1-9]\d*$/.test(value) && Number(value) <= 64, oneOf = (...values) => (value) => values.includes(value), metric = (slot, fields) => (value) => fields.some((field) => value === `profile(${slot}-profile.${field})`), spacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent"]), placement = {
|
|
2
|
+
import { CURSORS, ELEMENT_NAMES, FRAME_CORNERS, FRAME_SIDES, GEOMETRY_CHANNELS, OVERFLOW_VALUES, PAINT_CHANNELS, RESIZES, SNAP_ALIGNS, SNAP_TYPES, TEXT_ALIGNS, TEXT_WRAPS, TOUCH_ACTIONS, USER_SELECTS } from "./construction-spec.mjs";
|
|
3
|
+
const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[a-z][\w-]*(?:,\s*[a-z][\w-]*:\s*[a-z][\w-]*)*\))?$/, binding = (value) => profile.test(value) || /^profile\([\w-]+-profile\)$/.test(value), wordList = (value) => value.split(/\s+/).every((word) => identifier.test(word)), positive = (value) => /^[1-9]\d*$/.test(value) && Number(value) <= 64, oneOf = (...values) => (value) => values.includes(value), metric = (slot, fields) => (value) => fields.some((field) => value === `profile(${slot}-profile.${field})`), spacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent"]), outsetSpacing = metric("spacing", ["content-gap", "label-gap", "details-gap", "meta-gap", "section-gap", "indent", "outset-block", "outset-inline"]), anchorClear = (value) => value === "profile(layer-profile.clear-block-start)" || value === "profile(spacing-profile.anchor-gap)", overlapSpacing = metric("spacing", ["overlap"]), placement = {
|
|
4
4
|
start: (value) => value === "auto" || positive(value),
|
|
5
5
|
end: positive,
|
|
6
6
|
span: (value) => value === "full" || positive(value),
|
|
@@ -20,7 +20,8 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
|
|
|
20
20
|
extent: oneOf("content", "container"),
|
|
21
21
|
gap: spacing,
|
|
22
22
|
"row-gap": spacing,
|
|
23
|
-
|
|
23
|
+
overlap: overlapSpacing,
|
|
24
|
+
"anchor-clear": anchorClear,
|
|
24
25
|
columns: positive,
|
|
25
26
|
weights: (value) => value.split(/\s+/).length <= 64 && value.split(/\s+/).every((weight) => /^\d+(\.\d+)?$/.test(weight) && Number(weight) > 0),
|
|
26
27
|
rows: (value) => value.split(/\s+/).length <= 12 && value.split(/\s+/).every((row) => ["auto", "fill"].includes(row)),
|
|
@@ -36,13 +37,19 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
|
|
|
36
37
|
transition: oneOf("scale")
|
|
37
38
|
},
|
|
38
39
|
"ads-part": {
|
|
39
|
-
kind: oneOf("text", "visual", "vector"),
|
|
40
|
+
kind: oneOf("text", "visual", "vector", "component"),
|
|
41
|
+
"space-before": spacing,
|
|
42
|
+
"space-after": spacing,
|
|
40
43
|
scheme: oneOf("light", "dark"),
|
|
41
44
|
selector: (value) => /^\.[a-z][\w-]*$/.test(value),
|
|
42
45
|
required: oneOf("true", "false"),
|
|
43
46
|
wrap: oneOf("true", "false", ...TEXT_WRAPS),
|
|
44
47
|
"text-align": TEXT_ALIGN,
|
|
45
48
|
"reserve-lines": oneOf("1", "2", "3"),
|
|
49
|
+
collapsed: oneOf("true", "false"),
|
|
50
|
+
repeat: oneOf("true", "false"),
|
|
51
|
+
"drawn-by": (value) => /^[a-z][\w-]*$/i.test(value),
|
|
52
|
+
"anchor-clear": anchorClear,
|
|
46
53
|
lines: oneOf("2", "3"),
|
|
47
54
|
overflow: OVERFLOW,
|
|
48
55
|
extent: oneOf("fill", "fill-both"),
|
|
@@ -81,12 +88,19 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
|
|
|
81
88
|
},
|
|
82
89
|
motion: binding
|
|
83
90
|
},
|
|
84
|
-
"ads-
|
|
91
|
+
"ads-geometry-transition": {
|
|
92
|
+
channels: (value) => {
|
|
93
|
+
const channels = value.split(/\s+/);
|
|
94
|
+
return new Set(channels).size === channels.length && channels.every((channel) => GEOMETRY_CHANNELS.includes(channel));
|
|
95
|
+
},
|
|
96
|
+
motion: binding
|
|
97
|
+
},
|
|
98
|
+
"ads-enter": { surface: binding, motion: binding, translate: metric("motion", ["distance"]), translateInline: metric("motion", ["distance"]), scale: metric("motion", ["scale"]), rotate: metric("motion", ["angle"]) },
|
|
85
99
|
"ads-pseudo": { surface: binding },
|
|
86
100
|
"ads-accessibility": { boundary: () => !0, reason: () => !0 },
|
|
87
|
-
"ads-
|
|
101
|
+
"ads-focus": { of: () => !0 },
|
|
88
102
|
"ads-play": { sequence: binding, order: (value) => /^(?:[0-9]|[12][0-9]|3[0-2])$/.test(value) },
|
|
89
|
-
"ads-outset": { block:
|
|
103
|
+
"ads-outset": { block: outsetSpacing, inline: outsetSpacing },
|
|
90
104
|
"ads-sticky": { edge: oneOf("block-start", "block-end"), clear: oneOf("none", "block-start") },
|
|
91
105
|
"ads-snap": { type: oneOf(...SNAP_TYPES), align: oneOf(...SNAP_ALIGNS) },
|
|
92
106
|
"ads-layer": {
|
|
@@ -102,11 +116,13 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
|
|
|
102
116
|
clear: oneOf("none", "block-start"),
|
|
103
117
|
placement: oneOf("measured")
|
|
104
118
|
},
|
|
105
|
-
"ads-cell": placement,
|
|
119
|
+
"ads-cell": { ...placement, required: oneOf("true", "false"), repeat: oneOf("true", "false") },
|
|
106
120
|
"ads-at": placement,
|
|
107
121
|
"ads-align": { rows: wordList },
|
|
108
122
|
"ads-when": {
|
|
109
123
|
surface: binding,
|
|
124
|
+
spacing: binding,
|
|
125
|
+
collapsed: oneOf("true", "false"),
|
|
110
126
|
text: binding,
|
|
111
127
|
repeat: oneOf("continuous"),
|
|
112
128
|
"translate-inline": metric("motion", ["distance"]),
|
package/dist/paint-contrast.mjs
CHANGED
|
@@ -84,6 +84,12 @@ function gradientStops(value, context) {
|
|
|
84
84
|
}
|
|
85
85
|
return { kind: "stops", stops };
|
|
86
86
|
}
|
|
87
|
+
export function unshown(foreground, context) {
|
|
88
|
+
if (foreground === null)
|
|
89
|
+
return !1;
|
|
90
|
+
const read = readColor(foreground, context);
|
|
91
|
+
return read.kind === "color" && read.rgba[3] === 0;
|
|
92
|
+
}
|
|
87
93
|
export function opaque(value, context) {
|
|
88
94
|
const resolved = resolveTokenValue(value, context.values);
|
|
89
95
|
if (resolved.kind === "unresolved")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inactiveCondition, paintContrast, reachablePairs, TEXT_MINIMUM } from "./paint-contrast.mjs";
|
|
1
|
+
import { inactiveCondition, NON_TEXT_MINIMUM, paintContrast, reachablePairs, TEXT_MINIMUM } from "./paint-contrast.mjs";
|
|
2
2
|
import { tokenValueContexts } from "./design-foundation.mjs";
|
|
3
3
|
import { err, ok } from "./result.mjs";
|
|
4
4
|
export const PLACEHOLDER_MINIMUM = TEXT_MINIMUM;
|
|
@@ -33,3 +33,19 @@ export function checkPlaceholderContrast(foundation, part, foreground, backgroun
|
|
|
33
33
|
}
|
|
34
34
|
return ok(null);
|
|
35
35
|
}
|
|
36
|
+
export function checkProgressContrast(foundation, part, fill, track) {
|
|
37
|
+
const pairs = reachablePairs(fill, track).filter((pair) => !inactiveCondition(pair.foreground.condition) && !inactiveCondition(pair.background.condition));
|
|
38
|
+
for (const context of tokenValueContexts(foundation))
|
|
39
|
+
for (const pair of pairs) {
|
|
40
|
+
const states = [pair.foreground.condition, pair.background.condition], outcome = paintContrast(context, { foreground: pair.foreground.value, background: pair.background.value }, NON_TEXT_MINIMUM);
|
|
41
|
+
switch (outcome.kind) {
|
|
42
|
+
case "sufficient":
|
|
43
|
+
continue;
|
|
44
|
+
case "insufficient":
|
|
45
|
+
return err({ kind: "progress-contrast-insufficient", part, context: context.label, states, ratio: outcome.ratio, minimum: outcome.minimum });
|
|
46
|
+
case "unresolved":
|
|
47
|
+
return err({ kind: "progress-contrast-unresolved", part, context: context.label, states, reason: outcome.unresolved.kind === "paint-missing" ? outcome.unresolved.paint === "background" ? "the part sets no background for its track" : "the fill's surface sets no background" : placeholderReason(outcome.unresolved) });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return ok(null);
|
|
51
|
+
}
|
|
@@ -32,8 +32,14 @@ export const PLATFORM_FEATURES = [
|
|
|
32
32
|
prefixed: ["::-webkit-details-marker"],
|
|
33
33
|
degrades: "None expected: the standard list-style-type: none hides a summary's marker; the prefixed pseudo-element hides it where the engine draws it as a separate box."
|
|
34
34
|
},
|
|
35
|
+
{
|
|
36
|
+
id: "progress-parts",
|
|
37
|
+
css: ["appearance"],
|
|
38
|
+
prefixed: ["-webkit-appearance", "::-webkit-progress-bar", "::-webkit-progress-value", "::-moz-progress-bar"],
|
|
39
|
+
degrades: "A progress bar keeps the engine's own drawing: its track and fill are not the design's paints. Each engine reads only its own pseudo-element; there is no standard one."
|
|
40
|
+
},
|
|
35
41
|
{ id: "dir-pseudo-class", css: [":dir()"], degrades: "Right-to-left overrides do not apply: mirrored offsets and motion keep their left-to-right direction." },
|
|
36
|
-
{ id: "filter-effects", css: ["filter", "blur()", "drop-shadow()", "saturate()"], degrades: "A surface's blur and its shape or group shadow do not apply: the element is drawn sharp and without that shadow." },
|
|
42
|
+
{ id: "filter-effects", css: ["filter", "blur()", "drop-shadow()", "saturate()", "brightness()"], degrades: "A surface's brightness, blur and its shape or group shadow do not apply: the element is drawn as it is, sharp and without that shadow." },
|
|
37
43
|
{ id: "focus-visible", css: [":focus-visible"], degrades: "Required for focus indicators: rules selecting :focus-visible are dropped, so keyboard focus is not drawn." },
|
|
38
44
|
{ id: "has-pseudo-class", css: [":has()"], degrades: "Rules that select by a descendant are dropped: the page keeps scrolling behind an open modal dialog, and a part does not show its native part's state (a checkbox's drawn box stays unchecked)." },
|
|
39
45
|
{ id: "individual-transforms", css: ["translate", "rotate", "scale"], degrades: "Press scale, glyph offsets and their transitions and keyframes do not apply; elements stay at rest." },
|
|
@@ -69,6 +75,8 @@ export const PLATFORM_FEATURES = [
|
|
|
69
75
|
{ id: "prefers-reduced-motion", css: ["@media (prefers-reduced-motion)"], degrades: "Motion is not reduced for users who ask for less: transitions and animations run at full length." },
|
|
70
76
|
{ id: "interaction-media", css: ["@media (hover)", "@media (any-hover)", "@media (pointer)", "@media (any-pointer)"], degrades: "Input-dependent rules do not apply." },
|
|
71
77
|
{ id: "registered-custom-properties", css: ["@property"], degrades: "Registered custom properties behave as unregistered ones: no type checking, no interpolation, and they inherit." },
|
|
78
|
+
{ id: "interpolate-size", css: ["interpolate-size"], degrades: "A collapsed part opens and closes at once instead of growing: its size and what it shows are the same, without the animation." },
|
|
79
|
+
{ id: "scroll-margin", css: ["scroll-margin-block-start"], degrades: "A jump to an anchor puts its target at the very top of the scroll container, under whatever is stuck there." },
|
|
72
80
|
{ id: "scroll-snap", css: ["scroll-snap-type", "scroll-snap-align"], degrades: "Scrolling does not snap: a scrolled track stops wherever the scroll ends." },
|
|
73
81
|
{ id: "subgrid", css: ["grid-template-columns: subgrid", "grid-template-rows: subgrid"], degrades: "A subgrid cell lays out its items on its own tracks: parts no longer align across siblings." },
|
|
74
82
|
{ id: "starting-style", css: ["@starting-style"], degrades: "Entry animations are skipped: the element appears in its open state at once." },
|
|
@@ -143,6 +151,7 @@ export const PLATFORM_FEATURES = [
|
|
|
143
151
|
"overflow-wrap",
|
|
144
152
|
"pointer-events",
|
|
145
153
|
"position",
|
|
154
|
+
"visibility",
|
|
146
155
|
"text-align",
|
|
147
156
|
"text-decoration-line",
|
|
148
157
|
"font-stretch",
|
package/dist/profile-macro.d.mts
CHANGED
|
@@ -34,6 +34,13 @@ export interface ProfileSpec {
|
|
|
34
34
|
readonly below?: Token;
|
|
35
35
|
readonly above?: Token;
|
|
36
36
|
}>>;
|
|
37
|
+
/**
|
|
38
|
+
* A `surface` profile's contextual roles: paint tokens it re-binds for the subtree of every element that takes
|
|
39
|
+
* it (base or a state), each to another paint token. `{ "--link-ink": "--heading-ink" }` on a heading's
|
|
40
|
+
* surface: a link inside it reads the heading's ink, with no prop and no rule on the link. Checked where it
|
|
41
|
+
* applies: what can sit inside is proven with the provided values on that element's background.
|
|
42
|
+
*/
|
|
43
|
+
readonly provides?: Readonly<Record<`--${string}`, Token>>;
|
|
37
44
|
/**
|
|
38
45
|
* A `sequence` profile's steps, each at a whole percentage of the run from 0 to 100. A step states
|
|
39
46
|
* what the part looks like there: `opacity`, travel (`translateInline`, `translateBlock`), one scale
|
|
@@ -29,7 +29,7 @@ export function profileApplied(profile, selected, tokenValue) {
|
|
|
29
29
|
const sources = profile.kind === "composite" ? profile.fields.flatMap((field) => Object.hasOwn(SLOT_KINDS, field.field) && field.profile !== null ? [selected(field.profile)].flatMap((item) => item === void 0 ? [] : [item]) : []) : [profile], of = (kind) => sources.find((source) => source.kind === kind), stated = (kind, field) => of(kind)?.fields.find((item) => item.field === field)?.value, declarations = (kind) => {
|
|
30
30
|
const properties = APPLIED_PROPERTIES[kind] ?? {};
|
|
31
31
|
return (of(kind)?.fields ?? []).flatMap((field) => Object.hasOwn(properties, field.field) ? [[properties[field.field] ?? "", field.value]] : []);
|
|
32
|
-
}, css = (value) => /^--[\w-]+$/.test(value) ? `var(${value})` : value, frame = declarations("frame"), surface = declarations("surface"), shadow = stated("surface", "shapeShadow") ?? stated("surface", "groupShadow"), filter = [...stated("surface", "blur") === void 0 ? [] : [`blur(${css(stated("surface", "blur") ?? "")})`], ...shadow === void 0 ? [] : [`drop-shadow(${css(shadow)})`]], backdrop = [...stated("surface", "backdropBlur") === void 0 ? [] : [`blur(${css(stated("surface", "backdropBlur") ?? "")})`], ...stated("surface", "backdropSaturate") === void 0 ? [] : [`saturate(${css(stated("surface", "backdropSaturate") ?? "")})`]];
|
|
32
|
+
}, css = (value) => /^--[\w-]+$/.test(value) ? `var(${value})` : value, frame = declarations("frame"), surface = declarations("surface"), shadow = stated("surface", "shapeShadow") ?? stated("surface", "groupShadow"), filter = [...stated("surface", "brightness") === void 0 ? [] : [`brightness(${css(stated("surface", "brightness") ?? "")})`], ...stated("surface", "blur") === void 0 ? [] : [`blur(${css(stated("surface", "blur") ?? "")})`], ...shadow === void 0 ? [] : [`drop-shadow(${css(shadow)})`]], backdrop = [...stated("surface", "backdropBlur") === void 0 ? [] : [`blur(${css(stated("surface", "backdropBlur") ?? "")})`], ...stated("surface", "backdropSaturate") === void 0 ? [] : [`saturate(${css(stated("surface", "backdropSaturate") ?? "")})`]];
|
|
33
33
|
if (filter.length > 0)
|
|
34
34
|
surface.push(["filter", filter.join(" ")]);
|
|
35
35
|
if (backdrop.length > 0)
|