@reqvire-org/ads 0.5.1 → 0.5.2
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 +110 -25
- 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/factored-classes.mjs +90 -0
- package/dist/analysis/helpers.mjs +5 -7
- package/dist/analysis/native-project.mjs +12 -0
- package/dist/analysis/owner-analysis-cache.mjs +86 -23
- package/dist/analysis/owner-analysis-key.mjs +42 -10
- package/dist/analysis/owner-choices.mjs +23 -4
- package/dist/analysis/owner-composition.mjs +118 -33
- package/dist/analysis/owner-reuse.mjs +8 -6
- package/dist/analysis/owner-source.mjs +253 -76
- 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-keyline.mjs +2 -2
- package/dist/config.mjs +2 -1
- package/dist/construction-output.mjs +3 -2
- package/dist/construction-spec.d.mts +111 -6
- package/dist/construction-spec.mjs +172 -30
- package/dist/corner-overpaint.mjs +16 -4
- package/dist/derived-states.mjs +182 -0
- package/dist/design-inputs.mjs +18 -3
- package/dist/design-system-closure.mjs +12 -7
- package/dist/emit/contract.mjs +24 -5
- package/dist/emit/emission.mjs +6 -4
- 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/hover-geometry.mjs +15 -0
- package/dist/input-digests.mjs +17 -10
- package/dist/linaria/delivery.mjs +2 -0
- package/dist/lowering-properties.mjs +5 -0
- package/dist/lowering-region-layout.mjs +7 -2
- 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/motion-model.mjs +1 -1
- package/dist/owner-analysis-check.mjs +19 -5
- package/dist/owner-errors.mjs +4 -2
- package/dist/owner-lowering.mjs +71 -12
- package/dist/owner-scenarios.mjs +4 -1
- package/dist/ownership-model.mjs +18 -4
- package/dist/placeholder-contrast.mjs +17 -1
- package/dist/platform-features.mjs +10 -1
- package/dist/profile-view-facts.mjs +1 -1
- package/dist/recipe-macro.d.mts +72 -13
- package/dist/recipe-model.mjs +9 -5
- package/dist/region-lowering.mjs +238 -40
- 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 +5 -0
- package/dist/role-vocabulary.mjs +12 -1
- package/dist/scenarios-compiler.mjs +20 -6
- package/dist/showcase/assets-view.mjs +29 -13
- package/dist/showcase/client.bundle.js +32 -32
- package/dist/showcase/http-client.bundle.js +15 -15
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +4 -4
- package/dist/skills/ads-designer/references/accessibility.md +7 -0
- 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 +1 -1
- package/dist/skills/ads-designer/references/layout.md +5 -1
- package/dist/skills/ads-designer/references/motion.md +9 -1
- package/dist/skills/ads-designer/references/recipes.md +27 -3
- package/dist/skills/ads-import/references/contracts.md +5 -2
- package/dist/skills/ads-import/references/design-data.md +1 -1
- package/dist/skills/ads-import/references/layout.md +5 -1
- package/dist/skills/ads-import/references/recipes.md +27 -3
- package/dist/skills/ads-migrate/SKILL.md +1 -0
- package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
- package/dist/skills/ads-port/references/contracts.md +5 -2
- package/dist/skills/ads-port/references/design-data.md +1 -1
- package/dist/skills/ads-port/references/layout.md +5 -1
- package/dist/skills/ads-port/references/recipes.md +27 -3
- package/dist/surface-contrast.mjs +1 -0
- package/dist/surface-effects.mjs +5 -3
- package/dist/task-cache.mjs +8 -18
- package/dist/validation-checks.mjs +1 -1
- package/docs/ARCHITECTURE.md +63 -7
- package/docs/CACHING.md +152 -24
- package/docs/CHANGELOG.md +200 -23
- package/docs/GUIDE.md +45 -1
- package/docs/LANGUAGE.md +146 -8
- package/docs/MOTION.md +10 -2
- package/docs/PROFILE-KINDS.md +9 -1
- package/docs/RULES.md +22 -14
- package/docs/TOKEN-ROLES.md +7 -1
- package/package.json +1 -1
package/dist/ads-errors.mjs
CHANGED
|
@@ -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.",
|
|
@@ -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",
|
|
@@ -1145,13 +1154,6 @@ export const constructionErrors = {
|
|
|
1145
1154
|
message: (failure) => `Field ${failure.field} is supplied by both ${failure.providers[0]} and ${failure.providers[1]}.`,
|
|
1146
1155
|
repair: "Supply the field once: remove the explicit treatment or the slot provider."
|
|
1147
1156
|
},
|
|
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
1157
|
"artwork-binding-missing": {
|
|
1156
1158
|
group: "structure-mismatch",
|
|
1157
1159
|
rule: "An artwork construction binds its visual part to a declared asset.",
|
|
@@ -1159,12 +1161,12 @@ export const constructionErrors = {
|
|
|
1159
1161
|
message: () => "An artwork construction has no asset binding.",
|
|
1160
1162
|
repair: "Bind the visual part to a declared asset."
|
|
1161
1163
|
},
|
|
1162
|
-
"paint-
|
|
1163
|
-
group: "
|
|
1164
|
-
rule: "
|
|
1165
|
-
guides: ["ads://guides/pictograms", "ads://guides/
|
|
1166
|
-
message: (failure) => `
|
|
1167
|
-
repair: "
|
|
1164
|
+
"artwork-paint-contrast-insufficient": {
|
|
1165
|
+
group: "accessibility-semantics",
|
|
1166
|
+
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.",
|
|
1167
|
+
guides: ["ads://guides/pictograms", "ads://guides/accessibility", "ads://guides/tokens"],
|
|
1168
|
+
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.`,
|
|
1169
|
+
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
1170
|
},
|
|
1169
1171
|
"spatial-token-expected": {
|
|
1170
1172
|
group: "design-bypass",
|
|
@@ -1217,10 +1219,13 @@ export const constructionErrors = {
|
|
|
1217
1219
|
},
|
|
1218
1220
|
"pseudo-surface-unsupported": {
|
|
1219
1221
|
group: "wrong-value",
|
|
1220
|
-
rule: "A pseudo-element surface sets exactly one field
|
|
1222
|
+
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
1223
|
guides: [RECIPES],
|
|
1222
|
-
message: (failure) =>
|
|
1223
|
-
|
|
1224
|
+
message: (failure) => {
|
|
1225
|
+
const field = failure.pseudo === "progressValue" ? "background" : "color";
|
|
1226
|
+
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.`;
|
|
1227
|
+
},
|
|
1228
|
+
repair: "Treat the pseudo-element with a surface profile that sets only that field: `color` for a placeholder, `background` for a progress fill."
|
|
1224
1229
|
},
|
|
1225
1230
|
"placeholder-contrast-insufficient": {
|
|
1226
1231
|
group: "accessibility-semantics",
|
|
@@ -1236,6 +1241,47 @@ export const constructionErrors = {
|
|
|
1236
1241
|
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
1242
|
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
1243
|
},
|
|
1244
|
+
"state-geometry-unsupported": {
|
|
1245
|
+
group: "wrong-value",
|
|
1246
|
+
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.",
|
|
1247
|
+
guides: [RECIPES, "ads://guides/layout"],
|
|
1248
|
+
message: (failure) => {
|
|
1249
|
+
const element = failure.element === "&" ? "The root" : `Part "${failure.element}"`;
|
|
1250
|
+
switch (failure.reason) {
|
|
1251
|
+
case "frame-missing":
|
|
1252
|
+
return `${element} selects frame ${failure.detail} under a state but has no frame of its own to change.`;
|
|
1253
|
+
case "field-dropped":
|
|
1254
|
+
return `${element}: the state's frame does not state ${failure.detail}, which the element's own frame writes.`;
|
|
1255
|
+
case "channel-unused":
|
|
1256
|
+
return `${element} lists geometry channel ${failure.detail}, but nothing of that channel changes under any state.`;
|
|
1257
|
+
case "hover-only":
|
|
1258
|
+
return `${element} changes geometry under ${failure.detail} only: keyboard users never reach it.`;
|
|
1259
|
+
case "collapsed-box":
|
|
1260
|
+
return `${element} is collapsible but has ${failure.detail} of its own, which would still take room.`;
|
|
1261
|
+
case "collapsed-parent":
|
|
1262
|
+
return `${element} is collapsible, but its parent is ${failure.detail}: a part collapses along a stack or a row.`;
|
|
1263
|
+
case "hit-area":
|
|
1264
|
+
return `${element}: frame ${failure.detail} states another hit area than the element's own frame. A target is the same size in every state.`;
|
|
1265
|
+
case "targets-overlap":
|
|
1266
|
+
return `${element} overlaps its neighbours, and ${failure.detail} are targets next to each other: a press there would reach two of them.`;
|
|
1267
|
+
}
|
|
1268
|
+
},
|
|
1269
|
+
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."
|
|
1270
|
+
},
|
|
1271
|
+
"progress-contrast-insufficient": {
|
|
1272
|
+
group: "accessibility-semantics",
|
|
1273
|
+
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).",
|
|
1274
|
+
guides: [RECIPES, "ads://guides/accessibility", "ads://guides/tokens"],
|
|
1275
|
+
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"}.`,
|
|
1276
|
+
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."
|
|
1277
|
+
},
|
|
1278
|
+
"progress-contrast-unresolved": {
|
|
1279
|
+
group: "unanalyzable",
|
|
1280
|
+
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.",
|
|
1281
|
+
guides: [RECIPES, "ads://guides/accessibility", "ads://guides/tokens"],
|
|
1282
|
+
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}.`,
|
|
1283
|
+
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."
|
|
1284
|
+
},
|
|
1239
1285
|
"inactive-surface-active": {
|
|
1240
1286
|
group: "accessibility-semantics",
|
|
1241
1287
|
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.',
|
|
@@ -1264,7 +1310,7 @@ export const constructionErrors = {
|
|
|
1264
1310
|
group: "conflict",
|
|
1265
1311
|
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
1312
|
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.`,
|
|
1313
|
+
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
1314
|
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
1315
|
},
|
|
1270
1316
|
"non-text-contrast-insufficient": {
|
|
@@ -2847,7 +2893,31 @@ export const runtimeErrors = {
|
|
|
2847
2893
|
guides: ["ads://guides/accessibility"],
|
|
2848
2894
|
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
2895
|
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."
|
|
2896
|
+
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."
|
|
2897
|
+
},
|
|
2898
|
+
"render-audit-construction-unrendered": {
|
|
2899
|
+
group: "evidence-missing",
|
|
2900
|
+
severity: "review",
|
|
2901
|
+
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.",
|
|
2902
|
+
guides: ["ads://guides/accessibility", "ads://guides/validation"],
|
|
2903
|
+
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.",
|
|
2904
|
+
emitters: ["src/render-audit.mts"]
|
|
2905
|
+
},
|
|
2906
|
+
"render-audit-state-forced": {
|
|
2907
|
+
group: "evidence-missing",
|
|
2908
|
+
severity: "review",
|
|
2909
|
+
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.",
|
|
2910
|
+
guides: ["ads://guides/accessibility", "ads://guides/validation"],
|
|
2911
|
+
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.",
|
|
2912
|
+
emitters: ["src/render-audit.mts"]
|
|
2913
|
+
},
|
|
2914
|
+
"render-audit-state-derivable": {
|
|
2915
|
+
group: "evidence-missing",
|
|
2916
|
+
severity: "info",
|
|
2917
|
+
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.",
|
|
2918
|
+
guides: ["ads://guides/validation"],
|
|
2919
|
+
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.",
|
|
2920
|
+
emitters: ["src/render-audit.mts"]
|
|
2851
2921
|
},
|
|
2852
2922
|
"render-audit-unavailable": {
|
|
2853
2923
|
group: "environment",
|
|
@@ -3015,6 +3085,15 @@ export const runtimeErrors = {
|
|
|
3015
3085
|
repair: "Replace the symlink with a real file inside the design system.",
|
|
3016
3086
|
emitters: ["src/validation-inputs.mts"]
|
|
3017
3087
|
},
|
|
3088
|
+
"typescript-config-invalid": {
|
|
3089
|
+
group: "unresolved-reference",
|
|
3090
|
+
severity: "error",
|
|
3091
|
+
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.",
|
|
3092
|
+
guides: [],
|
|
3093
|
+
repair: "Fix the reported configuration: correct its syntax or option, or point extends at a configuration file of this project (or an installed package).",
|
|
3094
|
+
emitters: ["src/check.mts"],
|
|
3095
|
+
situations: "at line 1 of the configuration file the problem is in (the project's tsconfig.json, or the configuration it extends)."
|
|
3096
|
+
},
|
|
3018
3097
|
"source-unavailable": {
|
|
3019
3098
|
group: "unresolved-reference",
|
|
3020
3099
|
severity: "error",
|
|
@@ -3047,7 +3126,7 @@ export const runtimeErrors = {
|
|
|
3047
3126
|
severity: "error",
|
|
3048
3127
|
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 prose element, a backdrop or an entrance keep 4.5:1.",
|
|
3049
3128
|
guides: ["ads://guides/accessibility", "ads://guides/tokens"],
|
|
3050
|
-
repair:
|
|
3129
|
+
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
3130
|
emitters: ["src/owner-analysis-check.mts"],
|
|
3052
3131
|
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
3132
|
},
|
|
@@ -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`.",
|
|
@@ -3530,7 +3616,6 @@ export const productGaps = {
|
|
|
3530
3616
|
expected: [
|
|
3531
3617
|
"spec/field-unsupported",
|
|
3532
3618
|
"construction/profile-field-unsupported",
|
|
3533
|
-
"construction/paint-unsupported",
|
|
3534
3619
|
"construction/spatial-clause-unsupported",
|
|
3535
3620
|
"registration/syntax-outside-role",
|
|
3536
3621
|
"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)
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { digest } from "../digest.mjs";
|
|
2
|
+
import { canonical, rootRelative } from "./owner-analysis-key.mjs";
|
|
3
|
+
const ABSORB = Symbol("design-reads.absorb"), groupOf = (map) => map === "profiles" ? "profiles" : "assets", valueDigests = new WeakMap;
|
|
4
|
+
export function designValueDigest(value, root) {
|
|
5
|
+
return digestOf(value, root);
|
|
6
|
+
}
|
|
7
|
+
function digestOf(value, root) {
|
|
8
|
+
if (value === null || typeof value !== "object")
|
|
9
|
+
return digest(canonical(value === void 0 ? { $undefined: !0 } : value));
|
|
10
|
+
const byRoot = valueDigests.get(value) ?? new Map;
|
|
11
|
+
valueDigests.set(value, byRoot);
|
|
12
|
+
if (byRoot.has(root))
|
|
13
|
+
return byRoot.get(root) ?? null;
|
|
14
|
+
let computed;
|
|
15
|
+
try {
|
|
16
|
+
computed = digest(rootRelative(canonical(value), root));
|
|
17
|
+
} catch {
|
|
18
|
+
computed = null;
|
|
19
|
+
}
|
|
20
|
+
byRoot.set(root, computed);
|
|
21
|
+
return computed;
|
|
22
|
+
}
|
|
23
|
+
const profilesDigests = new WeakMap;
|
|
24
|
+
export function wholeDesignDigests(foundation, assetsDigest) {
|
|
25
|
+
let profiles = profilesDigests.get(foundation.profiles);
|
|
26
|
+
if (profiles === void 0)
|
|
27
|
+
profilesDigests.set(foundation.profiles, profiles = digest(canonical(foundation.profiles)));
|
|
28
|
+
return { profiles, assets: assetsDigest };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class RecordingMap {
|
|
32
|
+
inner;
|
|
33
|
+
note;
|
|
34
|
+
all;
|
|
35
|
+
constructor(inner, note, all) {
|
|
36
|
+
this.inner = inner;
|
|
37
|
+
this.note = note;
|
|
38
|
+
this.all = all;
|
|
39
|
+
}
|
|
40
|
+
get(key) {
|
|
41
|
+
const value = this.inner.get(key);
|
|
42
|
+
this.note("get", key, value);
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
has(key) {
|
|
46
|
+
const value = this.inner.has(key);
|
|
47
|
+
this.note("has", key, value);
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
get size() {
|
|
51
|
+
this.all();
|
|
52
|
+
return this.inner.size;
|
|
53
|
+
}
|
|
54
|
+
forEach(callback, thisArg) {
|
|
55
|
+
this.all();
|
|
56
|
+
this.inner.forEach((value, key) => callback.call(thisArg, value, key, this));
|
|
57
|
+
}
|
|
58
|
+
entries() {
|
|
59
|
+
this.all();
|
|
60
|
+
return this.inner.entries();
|
|
61
|
+
}
|
|
62
|
+
keys() {
|
|
63
|
+
this.all();
|
|
64
|
+
return this.inner.keys();
|
|
65
|
+
}
|
|
66
|
+
values() {
|
|
67
|
+
this.all();
|
|
68
|
+
return this.inner.values();
|
|
69
|
+
}
|
|
70
|
+
[Symbol.iterator]() {
|
|
71
|
+
return this.entries();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function traceDesignReads(foundation, assets, root, whole) {
|
|
75
|
+
const reads = new Map, wholes = {}, readAll = (group) => {
|
|
76
|
+
wholes[group] = whole[group];
|
|
77
|
+
}, noteMap = (map) => (op, key, value) => {
|
|
78
|
+
const id = `map:${map}:${op}:${key}`;
|
|
79
|
+
if (!reads.has(id) && wholes[groupOf(map)] === void 0)
|
|
80
|
+
reads.set(id, { kind: "map", map, op, key, value });
|
|
81
|
+
}, modelRead = (op, args, run) => {
|
|
82
|
+
const value = run(), id = `model:${op}:${args}`;
|
|
83
|
+
if (!reads.has(id) && wholes.profiles === void 0)
|
|
84
|
+
reads.set(id, { kind: "model", op, args, value });
|
|
85
|
+
return value;
|
|
86
|
+
}, catalogMap = (map, inner) => new RecordingMap(inner, noteMap(map), () => readAll("assets")), view = {
|
|
87
|
+
get hash() {
|
|
88
|
+
readAll("profiles");
|
|
89
|
+
return foundation.hash;
|
|
90
|
+
},
|
|
91
|
+
get defaults() {
|
|
92
|
+
return foundation.defaults;
|
|
93
|
+
},
|
|
94
|
+
get tokens() {
|
|
95
|
+
return foundation.tokens;
|
|
96
|
+
},
|
|
97
|
+
get sheets() {
|
|
98
|
+
return foundation.sheets;
|
|
99
|
+
},
|
|
100
|
+
get registrations() {
|
|
101
|
+
return foundation.registrations;
|
|
102
|
+
},
|
|
103
|
+
contexts: foundation.contexts,
|
|
104
|
+
profiles: new RecordingMap(foundation.profiles, noteMap("profiles"), () => readAll("profiles")),
|
|
105
|
+
model: {
|
|
106
|
+
compose: (name) => modelRead("compose", name, () => foundation.model.compose(name)),
|
|
107
|
+
select: (reference, bindings) => modelRead("select", JSON.stringify([reference, bindings ?? null]), () => foundation.model.select(reference, bindings)),
|
|
108
|
+
variants: (reference) => modelRead("variants", reference, () => foundation.model.variants(reference))
|
|
109
|
+
}
|
|
110
|
+
}, catalog = {
|
|
111
|
+
records: catalogMap("records", assets.records),
|
|
112
|
+
names: catalogMap("names", assets.names),
|
|
113
|
+
sites: catalogMap("sites", assets.sites),
|
|
114
|
+
sets: catalogMap("sets", assets.sets)
|
|
115
|
+
}, absorb = (evidence, group) => {
|
|
116
|
+
if (evidence.whole[group] !== void 0)
|
|
117
|
+
readAll(group);
|
|
118
|
+
if (wholes[group] !== void 0)
|
|
119
|
+
return;
|
|
120
|
+
for (const read of evidence.reads) {
|
|
121
|
+
if ((read.kind === "model" ? "profiles" : groupOf(read.map)) !== group)
|
|
122
|
+
continue;
|
|
123
|
+
const id = read.kind === "model" ? `model:${read.op}:${read.args}` : `map:${read.map}:${read.op}:${read.key}`;
|
|
124
|
+
if (!reads.has(id))
|
|
125
|
+
reads.set(id, read);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
Object.defineProperty(view, ABSORB, { value: absorb });
|
|
129
|
+
Object.defineProperty(catalog, ABSORB, { value: absorb });
|
|
130
|
+
return {
|
|
131
|
+
foundation: view,
|
|
132
|
+
assets: catalog,
|
|
133
|
+
evidence: () => ({
|
|
134
|
+
whole: { ...wholes },
|
|
135
|
+
reads: [...reads.values()].filter((read) => wholes[read.kind === "model" ? "profiles" : groupOf(read.map)] === void 0),
|
|
136
|
+
at: whole,
|
|
137
|
+
root
|
|
138
|
+
})
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const readWhole = (map) => map.size;
|
|
142
|
+
export function designReadsMatch(evidence, foundation, assets, root, whole) {
|
|
143
|
+
const unchanged = (group) => evidence.at[group] === whole[group];
|
|
144
|
+
for (const group of ["profiles", "assets"]) {
|
|
145
|
+
if (!unchanged(group))
|
|
146
|
+
continue;
|
|
147
|
+
(group === "profiles" ? foundation : assets)[ABSORB]?.(evidence, group);
|
|
148
|
+
}
|
|
149
|
+
for (const group of ["profiles", "assets"]) {
|
|
150
|
+
if (unchanged(group))
|
|
151
|
+
continue;
|
|
152
|
+
const recorded = evidence.whole[group];
|
|
153
|
+
if (recorded === void 0)
|
|
154
|
+
continue;
|
|
155
|
+
readWhole(group === "profiles" ? foundation.profiles : assets.records);
|
|
156
|
+
if (recorded !== whole[group])
|
|
157
|
+
return !1;
|
|
158
|
+
}
|
|
159
|
+
for (const read of evidence.reads) {
|
|
160
|
+
if (unchanged(read.kind === "model" ? "profiles" : groupOf(read.map)))
|
|
161
|
+
continue;
|
|
162
|
+
const value = (() => {
|
|
163
|
+
if (read.kind === "model") {
|
|
164
|
+
if (read.op === "select") {
|
|
165
|
+
const [reference, bindings] = JSON.parse(read.args);
|
|
166
|
+
return foundation.model.select(reference, bindings ?? void 0);
|
|
167
|
+
}
|
|
168
|
+
return read.op === "compose" ? foundation.model.compose(read.args) : foundation.model.variants(read.args);
|
|
169
|
+
}
|
|
170
|
+
const map = read.map === "profiles" ? foundation.profiles : assets[read.map];
|
|
171
|
+
return read.op === "get" ? map.get(read.key) : map.has(read.key);
|
|
172
|
+
})(), now = digestOf(value, root);
|
|
173
|
+
if (now === null || now !== digestOf(read.value, evidence.root))
|
|
174
|
+
return !1;
|
|
175
|
+
}
|
|
176
|
+
return !0;
|
|
177
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const key = (values) => JSON.stringify(values);
|
|
2
|
+
export function factorClasses(all, declared) {
|
|
3
|
+
const leaves = all.filter((leaf) => leaf.value !== null), [sample] = leaves;
|
|
4
|
+
if (sample === void 0)
|
|
5
|
+
return null;
|
|
6
|
+
const assignedIds = new Set(sample.assignment.map(([id]) => id)), axes = declared.filter((axis) => assignedIds.has(axis.id));
|
|
7
|
+
if (leaves.length < 2 || axes.length < 2)
|
|
8
|
+
return null;
|
|
9
|
+
const ids = axes.map((axis) => axis.id), rows = [];
|
|
10
|
+
for (const leaf of leaves) {
|
|
11
|
+
if (leaf.value === null)
|
|
12
|
+
return null;
|
|
13
|
+
const assigned = new Map(leaf.assignment);
|
|
14
|
+
if (ids.some((id) => !assigned.has(id)) || assigned.size !== ids.length)
|
|
15
|
+
return null;
|
|
16
|
+
rows.push({ values: ids.map((id) => assigned.get(id)), classes: new Set(leaf.value.split(/\s+/).filter((item) => item !== "")) });
|
|
17
|
+
}
|
|
18
|
+
const [first] = rows;
|
|
19
|
+
if (first === void 0)
|
|
20
|
+
return null;
|
|
21
|
+
const base = [...first.classes].filter((item) => rows.every((row) => row.classes.has(item))), varying = [...new Set(rows.flatMap((row) => [...row.classes]))].filter((item) => !base.includes(item)), support = new Map;
|
|
22
|
+
for (const item of varying)
|
|
23
|
+
support.set(item, new Set);
|
|
24
|
+
for (let axis = 0;axis < ids.length; axis++) {
|
|
25
|
+
const others = new Map;
|
|
26
|
+
for (const row of rows) {
|
|
27
|
+
const rest = key(row.values.filter((_, index) => index !== axis));
|
|
28
|
+
others.set(rest, [...others.get(rest) ?? [], row]);
|
|
29
|
+
}
|
|
30
|
+
for (const group of others.values()) {
|
|
31
|
+
if (group.length < 2)
|
|
32
|
+
continue;
|
|
33
|
+
for (const item of varying) {
|
|
34
|
+
const present = group.map((row) => row.classes.has(item));
|
|
35
|
+
if (present.some((value) => value !== present[0]))
|
|
36
|
+
support.get(item)?.add(axis);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const parent = ids.map((_, index) => index), find = (index) => parent[index] === index ? index : parent[index] = find(parent[index] ?? index);
|
|
41
|
+
for (const axesOf of support.values()) {
|
|
42
|
+
const [head, ...rest] = [...axesOf];
|
|
43
|
+
if (head === void 0)
|
|
44
|
+
return null;
|
|
45
|
+
for (const other of rest)
|
|
46
|
+
parent[find(other)] = find(head);
|
|
47
|
+
}
|
|
48
|
+
const components = new Map;
|
|
49
|
+
for (const axesOf of support.values())
|
|
50
|
+
for (const axis of axesOf)
|
|
51
|
+
components.set(find(axis), [...new Set([...components.get(find(axis)) ?? [], ...axesOf])]);
|
|
52
|
+
const groups = [...components.values()].map((members) => members.sort((a, b) => a - b));
|
|
53
|
+
if (groups.length < 2)
|
|
54
|
+
return null;
|
|
55
|
+
const tables = groups.map((members) => {
|
|
56
|
+
const owned = varying.filter((item) => [...support.get(item) ?? []].every((axis) => members.includes(axis))), table = new Map;
|
|
57
|
+
for (const row of rows) {
|
|
58
|
+
const values = key(members.map((axis) => row.values[axis])), classes = owned.filter((item) => row.classes.has(item)).join(" "), known = table.get(values);
|
|
59
|
+
if (known !== void 0 && known !== classes)
|
|
60
|
+
return null;
|
|
61
|
+
table.set(values, classes);
|
|
62
|
+
}
|
|
63
|
+
return { members, owned, table };
|
|
64
|
+
});
|
|
65
|
+
if (tables.some((table) => table === null))
|
|
66
|
+
return null;
|
|
67
|
+
const complete = tables;
|
|
68
|
+
for (const row of rows) {
|
|
69
|
+
const rebuilt = new Set([...base, ...complete.flatMap(({ members, table }) => (table.get(key(members.map((axis) => row.values[axis]))) ?? "").split(" ").filter((item) => item !== ""))]);
|
|
70
|
+
if (rebuilt.size !== row.classes.size || [...row.classes].some((item) => !rebuilt.has(item)))
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
base: base.join(" "),
|
|
75
|
+
groups: complete.map(({ members, table }) => {
|
|
76
|
+
const groupAxes = members.map((axis) => axes[axis]), build = (depth, prefix) => {
|
|
77
|
+
if (depth === members.length) {
|
|
78
|
+
const classes = table.get(key(prefix));
|
|
79
|
+
return classes === void 0 ? null : { kind: "leaf", value: classes, assignment: [] };
|
|
80
|
+
}
|
|
81
|
+
const axis = groupAxes[depth], options = axis.domain.flatMap((value) => {
|
|
82
|
+
const child = build(depth + 1, [...prefix, value]);
|
|
83
|
+
return child === null ? [] : [[value, child]];
|
|
84
|
+
});
|
|
85
|
+
return options.length === 0 ? null : { kind: "choice", axis, options };
|
|
86
|
+
};
|
|
87
|
+
return { axes: groupAxes, tree: build(0, []) ?? { kind: "leaf", value: "", assignment: [] } };
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -2,7 +2,7 @@ import { readFileSync, readdirSync } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import postcss from "postcss";
|
|
4
4
|
import ts from "./syntax.mjs";
|
|
5
|
-
import { currentAnalysis, memoFact, memoProgram } from "./context.mjs";
|
|
5
|
+
import { currentAnalysis, memoFact, memoProgram, revisionText } from "./context.mjs";
|
|
6
6
|
import { binaryContentBytes, isAnalysisBinary } from "./captured-content.mjs";
|
|
7
7
|
export { memoFact, memoProgram } from "./context.mjs";
|
|
8
8
|
|
|
@@ -22,13 +22,11 @@ export function sourceText(file) {
|
|
|
22
22
|
return text;
|
|
23
23
|
}
|
|
24
24
|
export function optionalSourceText(file) {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
return memoFact(context, key, () => revision ? memoProgram(revision, key, read) : read());
|
|
29
|
-
}
|
|
25
|
+
const captured = revisionText(file);
|
|
26
|
+
if (captured !== void 0)
|
|
27
|
+
return captured.text;
|
|
30
28
|
try {
|
|
31
|
-
return readFileSync(
|
|
29
|
+
return readFileSync(path.resolve(file), "utf8");
|
|
32
30
|
} catch (error) {
|
|
33
31
|
if (isMissing(error))
|
|
34
32
|
return null;
|