@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/ads-errors.mjs
CHANGED
|
@@ -149,7 +149,7 @@ export const choiceErrors = {
|
|
|
149
149
|
rule: "Design is selected from a finite set of choices ADS can enumerate, so every rendered combination can be checked.",
|
|
150
150
|
guides: [RECIPES, "ads://guides/atomic-styles"],
|
|
151
151
|
message: (problem) => problem.falsy === void 0 ? "A value that selects design does not come from a finite set of choices." : `\`${problem.falsy}\` selects design by a test that is not a finite choice: its type admits a given value that is falsy (\`0\`, \`""\`, \`false\` or \`null\`). Test \`!== undefined\`.`,
|
|
152
|
-
repair:
|
|
152
|
+
repair: 'Type the selecting prop or variable as a literal union (or a const record key) so every choice can be enumerated. A decision made from data (a count, an element, a lookup) is named as design state: `const overflow: "fits" | "overflows" = members.length > 3 ? \u2026`, or `const fourth: Member | undefined = members[3]`. An optional object, callback or node prop selects by whether it is given: test a node (or any type that admits text, a number or a boolean) with `!== undefined`, never by truthiness.'
|
|
153
153
|
},
|
|
154
154
|
"work-limit": {
|
|
155
155
|
group: "unanalyzable",
|
|
@@ -162,8 +162,8 @@ export const choiceErrors = {
|
|
|
162
162
|
group: "unanalyzable",
|
|
163
163
|
rule: "Choice analysis is bounded; a selection must stay small enough to be checked completely.",
|
|
164
164
|
guides: [RECIPES],
|
|
165
|
-
message: () =>
|
|
166
|
-
repair: "
|
|
165
|
+
message: (failure) => `Choice analysis exceeded its limit of ${failure.limit} branches. The selection branches on ${failure.axes.length} values: ${failure.axes.map((axis) => `${axis.name} (${axis.values})`).join(", ")}.`,
|
|
166
|
+
repair: "Every listed value multiplies the combinations checked. Make fewer of them select styling or markup together: replace conditional chains with one lookup over a const record keyed by the selecting value, merge props that always change together, or move a part with its own props into its own owner."
|
|
167
167
|
},
|
|
168
168
|
"construction-limit": {
|
|
169
169
|
group: "unanalyzable",
|
|
@@ -214,6 +214,13 @@ export const choiceErrors = {
|
|
|
214
214
|
message: (failure) => `Part "${failure.name}" is not declared by the recipe.`,
|
|
215
215
|
repair: "Declare the part in the recipe spec, or use one of the parts it already declares."
|
|
216
216
|
},
|
|
217
|
+
"part-ambiguous": {
|
|
218
|
+
group: "unresolved-reference",
|
|
219
|
+
rule: "A part inside another part is read by its name, so the name belongs to one nested part of the recipe.",
|
|
220
|
+
guides: [RECIPES],
|
|
221
|
+
message: (failure) => `Part "${failure.name}" names several parts inside the recipe's parts.`,
|
|
222
|
+
repair: "Give each nested part the owner reads its own name."
|
|
223
|
+
},
|
|
217
224
|
"property-unresolved": {
|
|
218
225
|
group: "unanalyzable",
|
|
219
226
|
rule: "Design values resolve to literals or const references inside the design system.",
|
|
@@ -539,10 +546,10 @@ export const choiceErrors = {
|
|
|
539
546
|
},
|
|
540
547
|
"part-missing-or-repeated": {
|
|
541
548
|
group: "structure-mismatch",
|
|
542
|
-
rule: "Each declared part renders exactly once per choice; optional parts are declared as not required.",
|
|
549
|
+
rule: "Each declared part renders exactly once per choice; optional parts are declared as not required, and a part rendered once per item of a list (`items.map(\u2026)`) is declared `repeat: true`.",
|
|
543
550
|
guides: [RECIPES],
|
|
544
551
|
message: (failure) => `Part "${failure.part}" is rendered zero or several times.`,
|
|
545
|
-
repair: "Render the part exactly once per choice,
|
|
552
|
+
repair: "Render the part exactly once per choice, mark it as not required in the spec, or declare it `repeat: true` when it renders once per item of a list."
|
|
546
553
|
},
|
|
547
554
|
"layer-element-mismatch": {
|
|
548
555
|
group: "structure-mismatch",
|
|
@@ -672,10 +679,10 @@ export const choiceErrors = {
|
|
|
672
679
|
},
|
|
673
680
|
"cell-missing-or-repeated": {
|
|
674
681
|
group: "structure-mismatch",
|
|
675
|
-
rule: "Each declared grid cell renders exactly once.",
|
|
682
|
+
rule: "Each declared grid cell renders exactly once; a cell declared `required: false` may be absent, and one declared `repeat: true` (or auto-placed at every tier) renders any number of times.",
|
|
676
683
|
guides: ["ads://guides/layout"],
|
|
677
684
|
message: (failure) => `Grid cell "${failure.cell}" is rendered zero or several times.`,
|
|
678
|
-
repair: "Render
|
|
685
|
+
repair: "Render the cell exactly once, declare it `required: false` when it may be absent, or `repeat: true` when it renders once per item of a list."
|
|
679
686
|
},
|
|
680
687
|
"markers-shared": {
|
|
681
688
|
group: "structure-mismatch",
|
|
@@ -686,10 +693,10 @@ export const choiceErrors = {
|
|
|
686
693
|
},
|
|
687
694
|
"visual-binding-count": {
|
|
688
695
|
group: "structure-mismatch",
|
|
689
|
-
rule: "A
|
|
696
|
+
rule: "A visual part binds exactly one declared asset. A control and standalone artwork have one visual part; a region may have several, each with its own binding.",
|
|
690
697
|
guides: ["ads://guides/branding", "ads://guides/pictograms"],
|
|
691
698
|
message: () => "A visual part does not have exactly one artwork binding.",
|
|
692
|
-
repair: "Bind exactly one declared asset to
|
|
699
|
+
repair: "Bind exactly one declared asset to each visual part; in a control or standalone artwork, declare one visual part."
|
|
693
700
|
},
|
|
694
701
|
"asset-unknown": {
|
|
695
702
|
group: "unresolved-reference",
|
|
@@ -1011,9 +1018,11 @@ export const constructionErrors = {
|
|
|
1011
1018
|
return `Surface ${failure.surface} declares groupShadow, but it is applied to a visual part, which has nothing inside it.`;
|
|
1012
1019
|
case "mask-on-container":
|
|
1013
1020
|
return `Surface ${failure.surface} declares mask, but it is applied to a container that does not scroll: its content, text included, would fade where it stands.`;
|
|
1021
|
+
case "brightness-off-visual":
|
|
1022
|
+
return `Surface ${failure.surface} declares brightness, but it is not applied to a visual part: the text it covers would change colour without a contrast check.`;
|
|
1014
1023
|
}
|
|
1015
1024
|
},
|
|
1016
|
-
repair: "On a visual part use `shapeShadow`; on a container use `boxShadow` for the shadow of its box, or `groupShadow` when one shadow for everything inside it is what you want. Put a `mask` on a visual part, or on an element whose `overflow` scrolls. Give each element its own surface profile where they differ."
|
|
1025
|
+
repair: "On a visual part use `shapeShadow`; on a container use `boxShadow` for the shadow of its box, or `groupShadow` when one shadow for everything inside it is what you want. Put a `mask` on a visual part, or on an element whose `overflow` scrolls. Put `brightness` on a visual part (the picture itself). Give each element its own surface profile where they differ."
|
|
1017
1026
|
},
|
|
1018
1027
|
"surface-shadow-layer": {
|
|
1019
1028
|
group: "wrong-value",
|
|
@@ -1031,13 +1040,6 @@ export const constructionErrors = {
|
|
|
1031
1040
|
},
|
|
1032
1041
|
repair: "Give the field its own shadow token with one layer and no spread, in every theme and brand, or use `boxShadow` for this shadow."
|
|
1033
1042
|
},
|
|
1034
|
-
"prose-contrast-insufficient": {
|
|
1035
|
-
group: "accessibility-semantics",
|
|
1036
|
-
rule: "Text in prose reaches the contrast minimum (WCAG 2.2 1.4.3: 4.5:1, or 3:1 for provably large text) on every surface it can sit on, in every theme and brand: each declared element's colour on the prose root's background and on the background of each declared element that can contain it (a link in a quote, text in a table cell or a code block), in its base and state surfaces.",
|
|
1037
|
-
guides: ["ads://guides/accessibility", RECIPES],
|
|
1038
|
-
message: (failure) => `Prose element ${failure.element} draws ${failure.foreground} on ${failure.background} (${failure.on}) under ${failure.context}: ${failure.ratio.toFixed(2)}:1, below ${failure.minimum}:1.`,
|
|
1039
|
-
repair: "Change the element's colour or the surface it sits on until the pair passes in every theme and brand; give an element inside a tinted container (a quote, a code block) its own colour there by tinting the container's surface, not by a one-off value."
|
|
1040
|
-
},
|
|
1041
1043
|
"condition-visual-unsupported": {
|
|
1042
1044
|
group: "unsupported",
|
|
1043
1045
|
rule: "A part's condition (`at`) may select another visual profile, so the drawing is another size in that range. The part is a visual part that draws registered artwork or contained application media, and both sizes select the same drawing: a condition is a media query and cannot swap the file.",
|
|
@@ -1145,26 +1147,19 @@ export const constructionErrors = {
|
|
|
1145
1147
|
message: (failure) => `Field ${failure.field} is supplied by both ${failure.providers[0]} and ${failure.providers[1]}.`,
|
|
1146
1148
|
repair: "Supply the field once: remove the explicit treatment or the slot provider."
|
|
1147
1149
|
},
|
|
1148
|
-
"parts-visual-repeated": {
|
|
1149
|
-
group: "structure-mismatch",
|
|
1150
|
-
rule: "A construction declares at most one visual part.",
|
|
1151
|
-
guides: [RECIPES],
|
|
1152
|
-
message: () => "The construction declares more than one visual part.",
|
|
1153
|
-
repair: "Declare a single visual part."
|
|
1154
|
-
},
|
|
1155
1150
|
"artwork-binding-missing": {
|
|
1156
1151
|
group: "structure-mismatch",
|
|
1157
1152
|
rule: "An artwork construction binds its visual part to a declared asset.",
|
|
1158
1153
|
guides: ["ads://guides/branding", "ads://guides/pictograms"],
|
|
1159
|
-
message: () => "An artwork construction has no asset binding.",
|
|
1160
|
-
repair:
|
|
1154
|
+
message: (failure) => failure.missing === "visual" ? "An artwork construction's binding names its asset but no visual profile, so the drawing has no size." : "An artwork construction has no asset binding.",
|
|
1155
|
+
repair: 'Bind the visual part to a declared asset and name its visual profile in the binding: recipe({ parts: { visual: { kind: "visual", asset: "<asset>", visual: "<visual profile>" } } }).'
|
|
1161
1156
|
},
|
|
1162
|
-
"paint-
|
|
1163
|
-
group: "
|
|
1164
|
-
rule: "
|
|
1165
|
-
guides: ["ads://guides/pictograms", "ads://guides/
|
|
1166
|
-
message: (failure) => `
|
|
1167
|
-
repair: "
|
|
1157
|
+
"artwork-paint-contrast-insufficient": {
|
|
1158
|
+
group: "accessibility-semantics",
|
|
1159
|
+
rule: "A control's artwork with paint slots stays recognizable on the control: in every theme, brand and state, at least one of its paints reaches 3:1 against the control's own background (WCAG 1.4.11). A drawing with its own colours (`paint: \"intrinsic\"`, a product's logo) is not checked.",
|
|
1160
|
+
guides: ["ads://guides/pictograms", "ads://guides/accessibility", "ads://guides/tokens"],
|
|
1161
|
+
message: (failure) => `No paint of artwork ${failure.asset} (${failure.paints.join(", ")}) reaches ${failure.minimum}:1 on the control's background ${failure.background}${failure.state === null ? "" : ` (state ${failure.state})`} under ${failure.context}: the best is ${failure.ratio}:1.`,
|
|
1162
|
+
repair: "Give the drawing one paint that reaches 3:1 on that background in that context (an outline or a darker fill), or adjust the token's value there."
|
|
1168
1163
|
},
|
|
1169
1164
|
"spatial-token-expected": {
|
|
1170
1165
|
group: "design-bypass",
|
|
@@ -1217,10 +1212,13 @@ export const constructionErrors = {
|
|
|
1217
1212
|
},
|
|
1218
1213
|
"pseudo-surface-unsupported": {
|
|
1219
1214
|
group: "wrong-value",
|
|
1220
|
-
rule: "A pseudo-element surface sets exactly one field
|
|
1215
|
+
rule: "A pseudo-element surface sets exactly one field: a placeholder's text colour (`color`), or a progress bar's fill (`background`). Other paints, borders and effects of a pseudo-element are not supported.",
|
|
1221
1216
|
guides: [RECIPES],
|
|
1222
|
-
message: (failure) =>
|
|
1223
|
-
|
|
1217
|
+
message: (failure) => {
|
|
1218
|
+
const field = failure.pseudo === "progressValue" ? "background" : "color";
|
|
1219
|
+
return failure.field === null ? `Surface ${failure.surface} on ${failure.pseudo} sets no ${field}.` : `Surface ${failure.surface} on ${failure.pseudo} sets ${failure.field}; only ${field} is supported.`;
|
|
1220
|
+
},
|
|
1221
|
+
repair: "Treat the pseudo-element with a surface profile that sets only that field: `color` for a placeholder, `background` for a progress fill."
|
|
1224
1222
|
},
|
|
1225
1223
|
"placeholder-contrast-insufficient": {
|
|
1226
1224
|
group: "accessibility-semantics",
|
|
@@ -1236,6 +1234,47 @@ export const constructionErrors = {
|
|
|
1236
1234
|
message: (failure) => `The placeholder contrast of part "${failure.part}" cannot be proven in ${failure.context} (placeholder state ${failure.states[0] ?? "base"}, background state ${failure.states[1] ?? "base"}): ${failure.reason}.`,
|
|
1237
1235
|
repair: "Give the part a surface with an opaque background colour token, and a placeholder colour that resolves to a colour token in every context."
|
|
1238
1236
|
},
|
|
1237
|
+
"state-geometry-unsupported": {
|
|
1238
|
+
group: "wrong-value",
|
|
1239
|
+
rule: "An owner state may select an element's geometry: another frame profile, another spacing profile, and whether a part is collapsed. The state's frame states every field the element's own frame writes; a listed geometry channel changes under some state; a `:hover` state has a focus or attribute state of the same geometry, so it is not for pointer users only; a collapsed part has no frame or arrangement of its own and sits in a stack or a row; a state's frame keeps the element's hit area; neighbouring targets do not overlap.",
|
|
1240
|
+
guides: [RECIPES, "ads://guides/layout"],
|
|
1241
|
+
message: (failure) => {
|
|
1242
|
+
const element = failure.element === "&" ? "The root" : `Part "${failure.element}"`;
|
|
1243
|
+
switch (failure.reason) {
|
|
1244
|
+
case "frame-missing":
|
|
1245
|
+
return `${element} selects frame ${failure.detail} under a state but has no frame of its own to change.`;
|
|
1246
|
+
case "field-dropped":
|
|
1247
|
+
return `${element}: the state's frame does not state ${failure.detail}, which the element's own frame writes.`;
|
|
1248
|
+
case "channel-unused":
|
|
1249
|
+
return `${element} lists geometry channel ${failure.detail}, but nothing of that channel changes under any state.`;
|
|
1250
|
+
case "hover-only":
|
|
1251
|
+
return `${element} changes geometry under ${failure.detail} only: keyboard users never reach it.`;
|
|
1252
|
+
case "collapsed-box":
|
|
1253
|
+
return `${element} is collapsible but has ${failure.detail} of its own, which would still take room.`;
|
|
1254
|
+
case "collapsed-parent":
|
|
1255
|
+
return `${element} is collapsible, but its parent is ${failure.detail}: a part collapses along a stack or a row.`;
|
|
1256
|
+
case "hit-area":
|
|
1257
|
+
return `${element}: frame ${failure.detail} states another hit area than the element's own frame. A target is the same size in every state.`;
|
|
1258
|
+
case "targets-overlap":
|
|
1259
|
+
return `${element} overlaps its neighbours, and ${failure.detail} are targets next to each other: a press there would reach two of them.`;
|
|
1260
|
+
}
|
|
1261
|
+
},
|
|
1262
|
+
repair: "Give the element a frame before a state changes it; state every field in the state's frame profile; list only channels that change; repeat a hover state's geometry under `:focus-visible`, `:focus-within` or an attribute state; put a collapsible part's box on the one element it holds."
|
|
1263
|
+
},
|
|
1264
|
+
"progress-contrast-insufficient": {
|
|
1265
|
+
group: "accessibility-semantics",
|
|
1266
|
+
rule: "A progress bar's fill has at least 3:1 contrast against its track, the part's own background, in every theme, brand and state (WCAG 1.4.11).",
|
|
1267
|
+
guides: [RECIPES, "ads://guides/accessibility", "ads://guides/tokens"],
|
|
1268
|
+
message: (failure) => `The progress fill of part "${failure.part}" has contrast ${failure.ratio}:1 (minimum ${failure.minimum}:1) against its track in ${failure.context}, fill state ${failure.states[0] ?? "base"}, track state ${failure.states[1] ?? "base"}.`,
|
|
1269
|
+
repair: "Choose a fill surface whose background token contrasts enough with the part's own background in that context, or adjust the token's value there."
|
|
1270
|
+
},
|
|
1271
|
+
"progress-contrast-unresolved": {
|
|
1272
|
+
group: "unanalyzable",
|
|
1273
|
+
rule: "A progress bar's contrast is proven from tokens: the fill and the track resolve to opaque colours in every theme, brand and state.",
|
|
1274
|
+
guides: [RECIPES, "ads://guides/accessibility", "ads://guides/tokens"],
|
|
1275
|
+
message: (failure) => `The progress fill contrast of part "${failure.part}" cannot be proven in ${failure.context} (fill state ${failure.states[0] ?? "base"}, track state ${failure.states[1] ?? "base"}): ${failure.reason}.`,
|
|
1276
|
+
repair: "Give the part a surface with an opaque background colour token for its track, and the fill a surface whose background resolves to a colour token in every context."
|
|
1277
|
+
},
|
|
1239
1278
|
"inactive-surface-active": {
|
|
1240
1279
|
group: "accessibility-semantics",
|
|
1241
1280
|
rule: 'A surface profile declaring `state: "inactive"` paints a disabled control: it has no contrast minimum (WCAG 2.2 1.4.3 exempts inactive components), so a construction selects it only under an inactive owner state (`:disabled`, `[aria-disabled="true"]`), never at rest or under another state.',
|
|
@@ -1245,26 +1284,26 @@ export const constructionErrors = {
|
|
|
1245
1284
|
},
|
|
1246
1285
|
"state-contrast-insufficient": {
|
|
1247
1286
|
group: "accessibility-semantics",
|
|
1248
|
-
rule: `An element's owner states keep it readable (text 4.5:1 or 3:1 when large; a visual part's or a text-less control's artwork 3:1; artwork hidden from assistive technology has no minimum): where a state's colour meets a background from another surface profile (a colour-only state over the base fill, a state fill under the base colour), the pair has at least 4.5:1 contrast in every theme, brand and condition, or 3:1 where the element's text profile makes its text large there (at least 24px, or 18.66px at weight 700); a state that holds only while the element is inactive (:disabled, [aria-disabled="true"]) has no minimum (WCAG 2.2 1.4.3). Two states that cannot hold on one root together (two values of one attribute, a state and its :not(), :disabled and :enabled) are not paired.`,
|
|
1287
|
+
rule: `An element's owner states keep it readable (text 4.5:1 or 3:1 when large; a visual part's or a text-less control's artwork 3:1; artwork hidden from assistive technology has no minimum, nor has a fully transparent colour, which draws nothing): where a state's colour meets a background from another surface profile (a colour-only state over the base fill, a state fill under the base colour), the pair has at least 4.5:1 contrast in every theme, brand and condition, or 3:1 where the element's text profile makes its text large there (at least 24px, or 18.66px at weight 700); a state that holds only while the element is inactive (:disabled, [aria-disabled="true"]) has no minimum (WCAG 2.2 1.4.3). Two states that cannot hold on one root together (two values of one attribute, a state and its :not(), :disabled and :enabled) are not paired.`,
|
|
1249
1288
|
guides: [RECIPES, "ads://guides/accessibility", "ads://guides/tokens"],
|
|
1250
1289
|
message: (failure) => `${failure.element === "&" ? "The root" : `Part "${failure.element}"`} pairs colour ${failure.foreground} (${failure.surfaces[0]}, state ${failure.states[0] ?? "base"}) with background ${failure.background} (${failure.surfaces[1]}, state ${failure.states[1] ?? "base"}) at ${failure.ratio}:1 under ${failure.context}; text needs ${failure.minimum}:1.`,
|
|
1251
1290
|
repair: "Treat the state with a surface that sets both its colour and background, or choose colour and background tokens that contrast in that context."
|
|
1252
1291
|
},
|
|
1253
1292
|
"target-size-below-minimum": {
|
|
1254
1293
|
group: "accessibility-semantics",
|
|
1255
|
-
rule:
|
|
1294
|
+
rule: "Every control construction and `frame: \"control\"` part is a pointer target of at least 24 \xD7 24 CSS px in every theme, brand and condition (WCAG 2.2 2.5.8), computed from its lowered box: min block = max(min-block-size, content + 2 (inset + border)), inline = 2 (padding-inline + border) + content; an enlarged hit area (min-target-inline-size, min-target-block-size) counts. Relative lengths are evaluated at the 16px reference root. The spacing exception holds for a smaller part of a stack or inline arrangement: a 24px circle centred on it reaches neither a neighbouring target's box nor, for a smaller neighbour, that neighbour's circle, at every gap the arrangement takes; a root or a part with no neighbouring target keeps the minimum.",
|
|
1256
1295
|
guides: [RECIPES, "ads://guides/accessibility", "ads://guides/tokens"],
|
|
1257
1296
|
message: (failure) => `${failure.element === "&" ? "The control" : `Part "${failure.element}"`} is ${failure.size.inlineExact ? "" : "at least "}${pixels(failure.size.inlinePx)} wide and ${pixels(failure.size.blockPx)} tall under ${contextNames(failure.contexts)}, ${[
|
|
1258
1297
|
...failure.size.inlineExact && failure.size.inlinePx < failure.minimumPx ? [`${pixels(failure.minimumPx - failure.size.inlinePx)} short inline`] : [],
|
|
1259
1298
|
...failure.size.blockPx < failure.minimumPx ? [`${pixels(failure.minimumPx - failure.size.blockPx)} short on the block axis`] : []
|
|
1260
1299
|
].join(" and ")}; a pointer target needs ${pixels(failure.minimumPx)} \xD7 ${pixels(failure.minimumPx)}.`,
|
|
1261
|
-
repair: "Raise the frame profile's min-block-size, padding-inline or the visual size in that context,
|
|
1300
|
+
repair: "Raise the frame profile's min-block-size, padding-inline or the visual size in that context, give the frame a min-target-inline-size / min-target-block-size hit area of at least 24px, or (for a part between targets) widen the arrangement's gap until 24px circles centred on the targets keep clear of each other."
|
|
1262
1301
|
},
|
|
1263
1302
|
"corner-overpaint": {
|
|
1264
1303
|
group: "conflict",
|
|
1265
1304
|
rule: "A rounded frame's corners stay rounded. A region root whose frame profile declares a `radius`, with visible overflow and no inset on a corner's edges, does not clip what it holds: a part that reaches that corner (the first or last part of a stack, a layer of a layered root) and paints a background of its own draws a square corner over the curve. ADS does not clip for the author, because clipping also cuts focus outlines, shadows and menus.",
|
|
1266
1305
|
guides: [RECIPES],
|
|
1267
|
-
message: (failure) => `Part "${failure.part}" paints the background of surface ${failure.surface}${failure.state === null ? "" : ` (state ${failure.state})`} over the root's rounded ${failure.corners.join(", ")} corner${failure.corners.length === 1 ? "" : "s"}: the root has a radius, visible overflow and no inset there.`,
|
|
1306
|
+
message: (failure) => `Part "${failure.part}" paints the background of surface ${failure.surface}${failure.state === null ? "" : ` (state ${failure.state})`} over the root's rounded ${failure.corners.join(", ")} corner${failure.corners.length === 1 ? "" : "s"}${failure.under === null ? "" : ` under ${failure.under}`}: the root has a radius, visible overflow and no inset there${failure.under === null ? "" : " with the frames that state selects"}.`,
|
|
1268
1307
|
repair: 'Choose one: clip the root (`overflow: "clip"`), inset it (padding in its frame profile), or round the part (a `frame: { profile }` whose frame profile has the matching radius). Name the rounded corners with `frame: { corners }` when only some are rounded.'
|
|
1269
1308
|
},
|
|
1270
1309
|
"non-text-contrast-insufficient": {
|
|
@@ -1365,6 +1404,13 @@ export const constructionErrors = {
|
|
|
1365
1404
|
message: (failure) => `${failure.element === "&" ? "The root" : `Part "${failure.element}"`} writes ${failure.property} from both ${failure.providers[0]} and ${failure.providers[1]}.`,
|
|
1366
1405
|
repair: "Keep one of the two constructs on this element, or move one to a wrapping part (a scrolling container around truncated text, say)."
|
|
1367
1406
|
},
|
|
1407
|
+
"space-parent-unsupported": {
|
|
1408
|
+
group: "unsupported",
|
|
1409
|
+
rule: "A part states its own space before or after (`spaceBefore`, `spaceAfter`) only in a `stack`, where it replaces the stack's gap on that side, or in the block flow of a parent without an arrangement (a list item); the larger of one part's space after and the next part's space before applies.",
|
|
1410
|
+
guides: [RECIPES, "ads://guides/layout"],
|
|
1411
|
+
message: (failure) => `Part "${failure.part}" states its own space, but its parent's layout is ${failure.layout}.`,
|
|
1412
|
+
repair: "Arrange the parent as a stack, or remove `spaceBefore` / `spaceAfter` (an inline row or a grid spaces its children evenly)."
|
|
1413
|
+
},
|
|
1368
1414
|
"extent-parent-unsupported": {
|
|
1369
1415
|
group: "unsupported",
|
|
1370
1416
|
rule: "A part fills its parent's main axis only in a `stack` or `inline` arrangement; a layered part already fills its area, and grids place cells.",
|
|
@@ -1636,6 +1682,13 @@ export const constructionErrors = {
|
|
|
1636
1682
|
message: (failure) => `${failure.profile}.${failure.field} references ${failure.token} (role ${failure.role ?? "none"}); expected ${list(failure.expected)}.`,
|
|
1637
1683
|
repair: "Reference a token of an admitted role, or register the token under the right role."
|
|
1638
1684
|
},
|
|
1685
|
+
"provided-role-self": {
|
|
1686
|
+
group: "conflict",
|
|
1687
|
+
rule: "A surface profile's `provides` re-binds tokens for the subtree of the element that takes it, the element itself included: a surface that provides a token its own fields read would repaint itself with the provided value.",
|
|
1688
|
+
guides: ["ads://guides/tokens", RECIPES],
|
|
1689
|
+
message: (failure) => `${failure.profile} provides ${failure.token} and its ${failure.field} reads ${failure.token}: the element would take the provided value itself.`,
|
|
1690
|
+
repair: "Read another token in the surface's own fields, or provide a role the surface itself does not read (a link ink, an icon ink)."
|
|
1691
|
+
},
|
|
1639
1692
|
"document-profile-kind": {
|
|
1640
1693
|
group: "wrong-value",
|
|
1641
1694
|
rule: "foundation.ads.ts's text names a text profile, its surface a surface profile and its focus a focus profile: they style the document and its default focus indicator.",
|
|
@@ -2056,7 +2109,7 @@ export const runtimeErrors = {
|
|
|
2056
2109
|
"a11y-target-size": {
|
|
2057
2110
|
group: "wrong-value",
|
|
2058
2111
|
severity: "error",
|
|
2059
|
-
rule: 'Pointer targets are at least 24 \xD7 24 CSS px (WCAG 2.2 2.5.8): every control construction and every frame: "control" part, computed from its lowered box in every theme, brand and condition (relative lengths at the 16px reference root), its enlarged hit area included; neighbouring hit areas in a stack or inline arrangement do not overlap.',
|
|
2112
|
+
rule: 'Pointer targets are at least 24 \xD7 24 CSS px (WCAG 2.2 2.5.8): every control construction and every frame: "control" part, computed from its lowered box in every theme, brand and condition (relative lengths at the 16px reference root), its enlarged hit area included, or a smaller part spaced from its neighbouring targets so that 24px circles centred on them keep clear (the spacing exception); neighbouring hit areas in a stack or inline arrangement do not overlap.',
|
|
2060
2113
|
guides: ["ads://guides/accessibility"],
|
|
2061
2114
|
repair: "Raise the frame profile's min-block-size, padding-inline or visual size in that context, or declare a min-target-inline-size / min-target-block-size hit area of at least 24px; widen the gap between overlapping hit areas.",
|
|
2062
2115
|
emitters: ["src/owner-analysis-check.mts"],
|
|
@@ -2847,7 +2900,31 @@ export const runtimeErrors = {
|
|
|
2847
2900
|
guides: ["ads://guides/accessibility"],
|
|
2848
2901
|
repair: "Usually none; if a target matters, make it reachable in the scenario (an aria-haspopup trigger that opens a dialog/menu/listbox and closes on Escape, a page that settles within 5 s) or split a scenario that exceeds the 3-overlay/6-control limit.",
|
|
2849
2902
|
emitters: ["src/render-audit.mts"],
|
|
2850
|
-
situations: "reason overlay-did-not-open, overlay-trigger-gone, overlay-left-open, overlay-timeout, overlay-detached, overlay-failed, overlay-cap, control-gone, control-timeout, control-detached, control-failed, control-cap, content-still-changing, focus-not-reachable. One finding per reason across the run."
|
|
2903
|
+
situations: "reason overlay-did-not-open, overlay-trigger-gone, overlay-left-open, overlay-timeout, overlay-detached, overlay-failed, overlay-cap, control-gone, control-timeout, control-detached, control-failed, control-cap, content-still-changing, focus-not-reachable, derived-state-unsupported, derived-state-not-applied, derived-timeout, derived-detached, derived-failed. One finding per reason across the run."
|
|
2904
|
+
},
|
|
2905
|
+
"render-audit-construction-unrendered": {
|
|
2906
|
+
group: "evidence-missing",
|
|
2907
|
+
severity: "review",
|
|
2908
|
+
rule: "The audit measures every owner state a construction declares on the elements the scenarios render (`derived` in the audit's coverage). A construction with states that no audited scenario renders is listed by owner and classes: what its states do once laid out is unmeasured.",
|
|
2909
|
+
guides: ["ads://guides/accessibility", "ads://guides/validation"],
|
|
2910
|
+
repair: "Render that variant in a scenario of its owner (or of a pattern that holds it), with the props that select it; its states are then measured without anything more.",
|
|
2911
|
+
emitters: ["src/render-audit.mts"]
|
|
2912
|
+
},
|
|
2913
|
+
"render-audit-state-forced": {
|
|
2914
|
+
group: "evidence-missing",
|
|
2915
|
+
severity: "review",
|
|
2916
|
+
rule: "The audit measures an attribute state by setting the attribute. Where owner analysis proves that the prop which sets that attribute also changes the owner's markup, the audit measured the state's CSS over the content at rest: what the component really shows in that state is unmeasured until a scenario renders it.",
|
|
2917
|
+
guides: ["ads://guides/accessibility", "ads://guides/validation"],
|
|
2918
|
+
repair: "Add a scenario specimen or state that renders the owner with that prop set; the item clears when a render shows the state for real.",
|
|
2919
|
+
emitters: ["src/render-audit.mts"]
|
|
2920
|
+
},
|
|
2921
|
+
"render-audit-state-derivable": {
|
|
2922
|
+
group: "evidence-missing",
|
|
2923
|
+
severity: "info",
|
|
2924
|
+
rule: "A scenario state that only shows an attribute state of an owner rendered elsewhere is measured by the audit without it: the audit derives the state from the recipe.",
|
|
2925
|
+
guides: ["ads://guides/validation"],
|
|
2926
|
+
repair: "Usually none. Remove the scenario state when it exists only for the audit and nobody needs to see it in the showcase; keep it when the component renders other content in that state.",
|
|
2927
|
+
emitters: ["src/render-audit.mts"]
|
|
2851
2928
|
},
|
|
2852
2929
|
"render-audit-unavailable": {
|
|
2853
2930
|
group: "environment",
|
|
@@ -3015,6 +3092,15 @@ export const runtimeErrors = {
|
|
|
3015
3092
|
repair: "Replace the symlink with a real file inside the design system.",
|
|
3016
3093
|
emitters: ["src/validation-inputs.mts"]
|
|
3017
3094
|
},
|
|
3095
|
+
"typescript-config-invalid": {
|
|
3096
|
+
group: "unresolved-reference",
|
|
3097
|
+
severity: "error",
|
|
3098
|
+
rule: "ADS analyses the design system with the compiler options of the project's tsconfig.json and every configuration it extends, read from the checked revision; each of them parses, and every extends target it names by path is part of that revision.",
|
|
3099
|
+
guides: [],
|
|
3100
|
+
repair: "Fix the reported configuration: correct its syntax or option, or point extends at a configuration file of this project (or an installed package).",
|
|
3101
|
+
emitters: ["src/check.mts"],
|
|
3102
|
+
situations: "at line 1 of the configuration file the problem is in (the project's tsconfig.json, or the configuration it extends)."
|
|
3103
|
+
},
|
|
3018
3104
|
"source-unavailable": {
|
|
3019
3105
|
group: "unresolved-reference",
|
|
3020
3106
|
severity: "error",
|
|
@@ -3045,9 +3131,9 @@ export const runtimeErrors = {
|
|
|
3045
3131
|
"surface-contrast": {
|
|
3046
3132
|
group: "accessibility-semantics",
|
|
3047
3133
|
severity: "error",
|
|
3048
|
-
rule: "A surface profile that sets both color and background meets WCAG 2.2 AA for text, 4.5:1, in every context (theme, brand, brand under theme and condition); its background-image gradient stops count as backgrounds. The minimum follows what the colour paints where the profile is used: a pair below 4.5:1 is accepted when every use of the profile in the design system is artwork (a visual part, or a control that renders no text: 3:1, WCAG 1.4.11), large text (at least 24px, or 18.66px at weight 700: 3:1) or artwork hidden from assistive technology (decoration: no minimum). A profile nothing uses, one a slot supplies, the document surface, and one the recipe also names for a pseudo-element, a
|
|
3134
|
+
rule: "A surface profile that sets both color and background meets WCAG 2.2 AA for text, 4.5:1, in every context (theme, brand, brand under theme and condition); its background-image gradient stops count as backgrounds. The minimum follows what the colour paints where the profile is used: a pair below 4.5:1 is accepted when every use of the profile in the design system is artwork (a visual part, or a control that renders no text: 3:1, WCAG 1.4.11), large text (at least 24px, or 18.66px at weight 700: 3:1) or artwork hidden from assistive technology (decoration: no minimum). A fully transparent colour draws nothing and has no minimum in the contexts where it is transparent (a glyph a control shows only on hover); the states that show it keep theirs. A profile nothing uses, one a slot supplies, the document surface, and one the recipe also names for a pseudo-element, a backdrop or an entrance keep 4.5:1.",
|
|
3049
3135
|
guides: ["ads://guides/accessibility", "ads://guides/tokens"],
|
|
3050
|
-
repair:
|
|
3136
|
+
repair: 'Adjust the colour or background token\'s value in the named context (or point the profile at a pair that contrasts), keeping the pair at 4.5:1 or more; a colour meant for artwork at 3:1 belongs to a surface profile that only visual parts or text-less controls select. A surface that paints a disabled element declares `state: "inactive"` among its fields: it has no minimum (WCAG 1.4.3 exempts inactive components) and may then be selected only under `:disabled` or `[aria-disabled="true"]`.',
|
|
3051
3137
|
emitters: ["src/owner-analysis-check.mts"],
|
|
3052
3138
|
situations: "located at the profile's declaration; profiles with identical paints (a profile and those composing it unchanged) are one finding naming them all. Owner states that pair one profile's colour with another's background are checked by owner analysis (construction/state-contrast-insufficient)."
|
|
3053
3139
|
},
|
|
@@ -3288,13 +3374,6 @@ export const runtimeErrors = {
|
|
|
3288
3374
|
message: (problem) => `The mock renders <${problem.tag}>, which is not imported from the design system.`,
|
|
3289
3375
|
repair: "Render public owners directly; an arrangement the screen needs belongs in a pattern."
|
|
3290
3376
|
},
|
|
3291
|
-
"prose-element-undeclared": {
|
|
3292
|
-
group: "design-bypass",
|
|
3293
|
-
rule: 'Plain flow markup inside a prose owner (a component whose recipe has `layout: "prose"`) is that owner\'s content. Each element used there is one the recipe declares in `elements`; an element it does not declare would be drawn without a design.',
|
|
3294
|
-
guides: ["ads://guides/scenarios", RECIPES],
|
|
3295
|
-
message: (problem) => `<${problem.tag}> is content of ${problem.owner}, whose prose recipe declares no such element.`,
|
|
3296
|
-
repair: "Declare the element in the owner's prose recipe (`elements`), or write the content with the elements it declares."
|
|
3297
|
-
},
|
|
3298
3377
|
"spread-props": {
|
|
3299
3378
|
group: "unanalyzable",
|
|
3300
3379
|
rule: "A mock passes explicit props: a spread could carry design ADS cannot see.",
|
|
@@ -3338,6 +3417,13 @@ export const runtimeErrors = {
|
|
|
3338
3417
|
message: (review) => `Summary ${review.part === "&" ? "root" : `part "${review.part}"`} removes its marker and renders no artwork.`,
|
|
3339
3418
|
repair: "Render a chevron (a visual part or a public Icon) chosen by the controlled open state, or keep the native marker."
|
|
3340
3419
|
},
|
|
3420
|
+
"hover-geometry-shift": {
|
|
3421
|
+
group: "conflict",
|
|
3422
|
+
rule: "Geometry an element in flow takes under `:hover` (another frame or spacing profile, a part that opens) moves what follows it whenever the pointer passes over it. ADS accepts it as the designer's choice and lists it for review; a layer of a layered parent draws over its neighbours instead and is not listed.",
|
|
3423
|
+
guides: [RECIPES, "ads://guides/layout"],
|
|
3424
|
+
message: (review) => `${review.element === "&" ? "The root" : `Part "${review.element}"`} changes its geometry under ${review.condition}: what follows it moves as the pointer passes.`,
|
|
3425
|
+
repair: "Keep it when the movement is wanted (a pile that spreads and pushes what follows). Otherwise draw the change over its neighbours: a layer of a layered parent, an outset backdrop, or a translate or scale effect, which move nothing else."
|
|
3426
|
+
},
|
|
3341
3427
|
"truncated-text-unnamed": {
|
|
3342
3428
|
group: "accessibility-semantics",
|
|
3343
3429
|
rule: "Truncated or clamped text keeps its full text available to sighted readers: a `title` with the same text, an expand control or the full content elsewhere (assistive technology reads the full text already). Analysis sees only a `title`.",
|
|
@@ -3345,6 +3431,13 @@ export const runtimeErrors = {
|
|
|
3345
3431
|
message: (review) => `Part "${review.part}" truncates its text without a title.`,
|
|
3346
3432
|
repair: "Set `title` on the truncated element to its full text; when an expand control or the full content elsewhere shows it, the note can be dismissed after review."
|
|
3347
3433
|
},
|
|
3434
|
+
"optional-cell-row": {
|
|
3435
|
+
group: "conflict",
|
|
3436
|
+
rule: "A grid cell that may be absent (`required: false`) and is pinned to a row (`row`) leaves that row empty whenever it is absent: the row's track and the gaps around it stay. ADS accepts it as the designer's choice and lists it for review.",
|
|
3437
|
+
guides: [RECIPES],
|
|
3438
|
+
message: (review) => `Grid cell "${review.cell}" may be absent, but it is pinned to a row: when it is absent the row stays, empty, with its gaps.`,
|
|
3439
|
+
repair: "Keep it when the empty row is wanted. Otherwise place the cell in auto rows (omit `row`), so the cells after it move up when it is absent."
|
|
3440
|
+
},
|
|
3348
3441
|
"balance-on-paragraph": {
|
|
3349
3442
|
group: "wrong-value",
|
|
3350
3443
|
rule: '`wrap: "balance"` evens out the line lengths of headings and short titles (browsers balance only a few lines); a paragraph is body text, whose breaks `wrap: "pretty"` improves. Analysis reads the rendered element, not the text\'s length.',
|
|
@@ -3530,7 +3623,6 @@ export const productGaps = {
|
|
|
3530
3623
|
expected: [
|
|
3531
3624
|
"spec/field-unsupported",
|
|
3532
3625
|
"construction/profile-field-unsupported",
|
|
3533
|
-
"construction/paint-unsupported",
|
|
3534
3626
|
"construction/spatial-clause-unsupported",
|
|
3535
3627
|
"registration/syntax-outside-role",
|
|
3536
3628
|
"registration/initial-out-of-bounds",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function relevantAxes(leaves) {
|
|
2
|
+
const axes = [...new Set(leaves.flatMap((leaf) => leaf.assignment.map(([id]) => id)))].sort(), index = new Map(axes.map((axis, position) => [axis, position]));
|
|
3
|
+
let current = leaves.map((leaf) => {
|
|
4
|
+
const values = Array.from({ length: axes.length }, () => {
|
|
5
|
+
return;
|
|
6
|
+
});
|
|
7
|
+
for (const [id, value] of leaf.assignment)
|
|
8
|
+
values[index.get(id) ?? 0] = JSON.stringify(value) ?? "undefined";
|
|
9
|
+
return { values, outcome: leaf.outcome };
|
|
10
|
+
});
|
|
11
|
+
const keyWithout = (values, skip) => values.map((value, position) => position === skip ? "" : value ?? "\x01").join("\x00"), relevant = new Set(axes);
|
|
12
|
+
axes.forEach((axis, position) => {
|
|
13
|
+
const domain = new Set;
|
|
14
|
+
for (const leaf of current) {
|
|
15
|
+
const value = leaf.values[position];
|
|
16
|
+
if (value !== void 0)
|
|
17
|
+
domain.add(value);
|
|
18
|
+
}
|
|
19
|
+
const groups = new Map;
|
|
20
|
+
for (const leaf of current) {
|
|
21
|
+
const value = leaf.values[position];
|
|
22
|
+
if (value === void 0)
|
|
23
|
+
continue;
|
|
24
|
+
const key = keyWithout(leaf.values, position);
|
|
25
|
+
let group = groups.get(key);
|
|
26
|
+
if (group === void 0)
|
|
27
|
+
groups.set(key, group = new Map);
|
|
28
|
+
const known = group.get(value);
|
|
29
|
+
if (known !== void 0 && known !== leaf.outcome)
|
|
30
|
+
return;
|
|
31
|
+
group.set(value, leaf.outcome);
|
|
32
|
+
for (const other of group.values())
|
|
33
|
+
if (other !== leaf.outcome)
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
for (const group of groups.values())
|
|
37
|
+
if (group.size !== domain.size)
|
|
38
|
+
return;
|
|
39
|
+
relevant.delete(axis);
|
|
40
|
+
const projected = new Map;
|
|
41
|
+
for (const leaf of current) {
|
|
42
|
+
const values = leaf.values.map((value, at) => at === position ? void 0 : value);
|
|
43
|
+
projected.set(`${keyWithout(values, -1)}\x02${leaf.outcome}`, { values, outcome: leaf.outcome });
|
|
44
|
+
}
|
|
45
|
+
current = [...projected.values()];
|
|
46
|
+
});
|
|
47
|
+
return relevant;
|
|
48
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { digest } from "../digest.mjs";
|
|
2
|
+
import { canonical, relocateOutcome, traceTokenReads } from "./owner-analysis-key.mjs";
|
|
3
|
+
import { designReadsMatch, traceDesignReads } from "./design-reads.mjs";
|
|
4
|
+
export const CONSTRUCTION_SCHEMA = "ads-construction/2";
|
|
5
|
+
|
|
6
|
+
export class ConstructionReuseMismatch extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("A reused construction differs from a fresh lowering (ADS_VERIFY_OWNER_REUSE=1).");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const verifying = () => process.env.ADS_VERIFY_OWNER_REUSE === "1", contextDigests = new WeakMap;
|
|
12
|
+
function contextsDigest(contexts) {
|
|
13
|
+
let known = contextDigests.get(contexts);
|
|
14
|
+
if (known === void 0)
|
|
15
|
+
contextDigests.set(contexts, known = digest(canonical(contexts)));
|
|
16
|
+
return known;
|
|
17
|
+
}
|
|
18
|
+
const readTokens = (foundation) => foundation.tokens;
|
|
19
|
+
export async function memoizedConstruction(memo, foundation, content, build) {
|
|
20
|
+
if (memo === void 0)
|
|
21
|
+
return build(foundation);
|
|
22
|
+
const run = () => {
|
|
23
|
+
const traced = traceTokenReads(foundation), design = traceDesignReads(traced.foundation, memo.catalog, memo.root, memo.whole);
|
|
24
|
+
return { ...build(design.foundation), tokens: traced.evidence(), design: design.evidence() };
|
|
25
|
+
}, key = digest([CONSTRUCTION_SCHEMA, contextsDigest(foundation.contexts), canonical(content)]), obtained = await memo.cache.obtain({ key, root: memo.root, tokens: memo.tokens }, async () => {
|
|
26
|
+
const outcome = run();
|
|
27
|
+
return { outcome, tokens: outcome.tokens, design: outcome.design };
|
|
28
|
+
}, { relocate: relocateOutcome, accept: (evidence) => evidence !== void 0 && designReadsMatch(evidence, foundation, memo.catalog, memo.root, memo.whole) }), outcome = obtained.outcome;
|
|
29
|
+
memo.tally[obtained.kind === "reused" ? "reused" : "built"]++;
|
|
30
|
+
if (obtained.kind === "reused") {
|
|
31
|
+
if (outcome.tokens.kind === "token-dependent")
|
|
32
|
+
readTokens(foundation);
|
|
33
|
+
const comparable = (stored) => canonical({ ...stored, design: { whole: stored.design.whole, reads: stored.design.reads } });
|
|
34
|
+
if (verifying() && comparable(run()) !== comparable(outcome))
|
|
35
|
+
throw new ConstructionReuseMismatch;
|
|
36
|
+
}
|
|
37
|
+
return outcome;
|
|
38
|
+
}
|
|
@@ -11,6 +11,25 @@ export function runAnalysis(root, run, providers = {}) {
|
|
|
11
11
|
export function currentAnalysis() {
|
|
12
12
|
return scope.getStore();
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
export class AnalysisCancelled extends Error {
|
|
16
|
+
code = "ADS_CANCELLED";
|
|
17
|
+
diagnostic = { rule: "mutation-cancelled", message: "Analysis cancelled." };
|
|
18
|
+
constructor() {
|
|
19
|
+
super("Analysis cancelled.");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function throwIfCancelled(signal = currentAnalysis()?.signal) {
|
|
23
|
+
if (signal?.aborted)
|
|
24
|
+
throw new AnalysisCancelled;
|
|
25
|
+
}
|
|
26
|
+
export function revisionText(file) {
|
|
27
|
+
const context = currentAnalysis(), resolved = path.resolve(file), readText = context?.readText;
|
|
28
|
+
if (context === void 0 || readText === void 0 || !resolved.startsWith(context.root + path.sep) || resolved.includes(`${path.sep}node_modules${path.sep}`))
|
|
29
|
+
return;
|
|
30
|
+
const read = () => readText(resolved) ?? null, key = `text:${resolved}`, revision = context.revision;
|
|
31
|
+
return { text: memoFact(context, key, () => revision ? memoProgram(revision, key, read) : read()) };
|
|
32
|
+
}
|
|
14
33
|
export function memoFact(owner, key, compute) {
|
|
15
34
|
const context = scope.getStore();
|
|
16
35
|
if (!context)
|