@reqvire-org/ads 0.5.2 → 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 +33 -26
- package/dist/analysis/design-usage.mjs +4 -20
- package/dist/analysis/mock-check.mjs +4 -5
- package/dist/analysis/owner-accessibility.mjs +4 -4
- package/dist/analysis/owner-analysis-key.mjs +1 -1
- package/dist/analysis/owner-choices.mjs +33 -3
- package/dist/analysis/owner-composition.mjs +61 -12
- package/dist/analysis/owner-source.mjs +52 -35
- package/dist/composed-contrast.mjs +143 -62
- package/dist/construction-output.mjs +6 -1
- package/dist/construction-spec.d.mts +53 -44
- package/dist/construction-spec.mjs +64 -76
- package/dist/corner-overpaint.mjs +5 -4
- package/dist/design-foundation.mjs +16 -0
- package/dist/design-usage.mjs +2 -8
- package/dist/emit/emission.mjs +0 -5
- package/dist/grid-lowering.mjs +3 -1
- package/dist/lowering-enter.mjs +6 -6
- package/dist/lowering-session.mjs +10 -0
- package/dist/mcp/server-observation.mjs +6 -4
- package/dist/mcp/server-project.mjs +4 -1
- package/dist/owner-analysis-check.mjs +4 -1
- package/dist/owner-errors.mjs +2 -1
- package/dist/owner-lowering.mjs +10 -4
- package/dist/owner-scenarios.mjs +2 -22
- package/dist/ownership-model.mjs +7 -5
- package/dist/paint-contrast.mjs +6 -0
- package/dist/profile-macro.d.mts +7 -0
- package/dist/recipe-macro.d.mts +46 -42
- package/dist/recipe-model.mjs +12 -11
- package/dist/region-lowering.mjs +54 -109
- package/dist/role-vocabulary.d.mts +4 -0
- package/dist/role-vocabulary.mjs +4 -0
- package/dist/runtime-paint-contrast.mjs +5 -2
- package/dist/showcase/client.bundle.js +48 -48
- package/dist/showcase/http-client.bundle.js +13 -13
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +5 -5
- package/dist/skills/ads-designer/references/accessibility.md +3 -4
- package/dist/skills/ads-designer/references/design-data.md +12 -6
- package/dist/skills/ads-designer/references/layout.md +7 -3
- package/dist/skills/ads-designer/references/motion.md +2 -1
- package/dist/skills/ads-designer/references/recipes.md +28 -18
- package/dist/skills/ads-import/references/design-data.md +12 -6
- package/dist/skills/ads-import/references/layout.md +7 -3
- package/dist/skills/ads-import/references/recipes.md +28 -18
- package/dist/skills/ads-migrate/SKILL.md +1 -0
- package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
- package/dist/skills/ads-port/references/design-data.md +12 -6
- package/dist/skills/ads-port/references/layout.md +7 -3
- package/dist/skills/ads-port/references/recipes.md +28 -18
- package/dist/spatial-model.mjs +2 -2
- package/dist/surface-contrast.mjs +6 -2
- package/dist/target-size.mjs +21 -3
- package/docs/ADS.md +9 -3
- package/docs/ARCHITECTURE.md +33 -23
- package/docs/CACHING.md +1 -1
- package/docs/CHANGELOG.md +128 -21
- package/docs/GUIDE.md +64 -19
- package/docs/LANGUAGE.md +141 -134
- package/docs/MCP.md +5 -1
- package/docs/MOTION.md +5 -2
- package/docs/PROFILE-KINDS.md +46 -4
- package/docs/RULES.md +16 -15
- 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",
|
|
@@ -546,10 +546,10 @@ export const choiceErrors = {
|
|
|
546
546
|
},
|
|
547
547
|
"part-missing-or-repeated": {
|
|
548
548
|
group: "structure-mismatch",
|
|
549
|
-
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`.",
|
|
550
550
|
guides: [RECIPES],
|
|
551
551
|
message: (failure) => `Part "${failure.part}" is rendered zero or several times.`,
|
|
552
|
-
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."
|
|
553
553
|
},
|
|
554
554
|
"layer-element-mismatch": {
|
|
555
555
|
group: "structure-mismatch",
|
|
@@ -679,10 +679,10 @@ export const choiceErrors = {
|
|
|
679
679
|
},
|
|
680
680
|
"cell-missing-or-repeated": {
|
|
681
681
|
group: "structure-mismatch",
|
|
682
|
-
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.",
|
|
683
683
|
guides: ["ads://guides/layout"],
|
|
684
684
|
message: (failure) => `Grid cell "${failure.cell}" is rendered zero or several times.`,
|
|
685
|
-
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."
|
|
686
686
|
},
|
|
687
687
|
"markers-shared": {
|
|
688
688
|
group: "structure-mismatch",
|
|
@@ -1040,13 +1040,6 @@ export const constructionErrors = {
|
|
|
1040
1040
|
},
|
|
1041
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."
|
|
1042
1042
|
},
|
|
1043
|
-
"prose-contrast-insufficient": {
|
|
1044
|
-
group: "accessibility-semantics",
|
|
1045
|
-
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.",
|
|
1046
|
-
guides: ["ads://guides/accessibility", RECIPES],
|
|
1047
|
-
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.`,
|
|
1048
|
-
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."
|
|
1049
|
-
},
|
|
1050
1043
|
"condition-visual-unsupported": {
|
|
1051
1044
|
group: "unsupported",
|
|
1052
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.",
|
|
@@ -1158,8 +1151,8 @@ export const constructionErrors = {
|
|
|
1158
1151
|
group: "structure-mismatch",
|
|
1159
1152
|
rule: "An artwork construction binds its visual part to a declared asset.",
|
|
1160
1153
|
guides: ["ads://guides/branding", "ads://guides/pictograms"],
|
|
1161
|
-
message: () => "An artwork construction has no asset binding.",
|
|
1162
|
-
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>" } } }).'
|
|
1163
1156
|
},
|
|
1164
1157
|
"artwork-paint-contrast-insufficient": {
|
|
1165
1158
|
group: "accessibility-semantics",
|
|
@@ -1291,20 +1284,20 @@ export const constructionErrors = {
|
|
|
1291
1284
|
},
|
|
1292
1285
|
"state-contrast-insufficient": {
|
|
1293
1286
|
group: "accessibility-semantics",
|
|
1294
|
-
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.`,
|
|
1295
1288
|
guides: [RECIPES, "ads://guides/accessibility", "ads://guides/tokens"],
|
|
1296
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.`,
|
|
1297
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."
|
|
1298
1291
|
},
|
|
1299
1292
|
"target-size-below-minimum": {
|
|
1300
1293
|
group: "accessibility-semantics",
|
|
1301
|
-
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.",
|
|
1302
1295
|
guides: [RECIPES, "ads://guides/accessibility", "ads://guides/tokens"],
|
|
1303
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)}, ${[
|
|
1304
1297
|
...failure.size.inlineExact && failure.size.inlinePx < failure.minimumPx ? [`${pixels(failure.minimumPx - failure.size.inlinePx)} short inline`] : [],
|
|
1305
1298
|
...failure.size.blockPx < failure.minimumPx ? [`${pixels(failure.minimumPx - failure.size.blockPx)} short on the block axis`] : []
|
|
1306
1299
|
].join(" and ")}; a pointer target needs ${pixels(failure.minimumPx)} \xD7 ${pixels(failure.minimumPx)}.`,
|
|
1307
|
-
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."
|
|
1308
1301
|
},
|
|
1309
1302
|
"corner-overpaint": {
|
|
1310
1303
|
group: "conflict",
|
|
@@ -1411,6 +1404,13 @@ export const constructionErrors = {
|
|
|
1411
1404
|
message: (failure) => `${failure.element === "&" ? "The root" : `Part "${failure.element}"`} writes ${failure.property} from both ${failure.providers[0]} and ${failure.providers[1]}.`,
|
|
1412
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)."
|
|
1413
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
|
+
},
|
|
1414
1414
|
"extent-parent-unsupported": {
|
|
1415
1415
|
group: "unsupported",
|
|
1416
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.",
|
|
@@ -1682,6 +1682,13 @@ export const constructionErrors = {
|
|
|
1682
1682
|
message: (failure) => `${failure.profile}.${failure.field} references ${failure.token} (role ${failure.role ?? "none"}); expected ${list(failure.expected)}.`,
|
|
1683
1683
|
repair: "Reference a token of an admitted role, or register the token under the right role."
|
|
1684
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
|
+
},
|
|
1685
1692
|
"document-profile-kind": {
|
|
1686
1693
|
group: "wrong-value",
|
|
1687
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.",
|
|
@@ -2102,7 +2109,7 @@ export const runtimeErrors = {
|
|
|
2102
2109
|
"a11y-target-size": {
|
|
2103
2110
|
group: "wrong-value",
|
|
2104
2111
|
severity: "error",
|
|
2105
|
-
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.',
|
|
2106
2113
|
guides: ["ads://guides/accessibility"],
|
|
2107
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.",
|
|
2108
2115
|
emitters: ["src/owner-analysis-check.mts"],
|
|
@@ -3124,7 +3131,7 @@ export const runtimeErrors = {
|
|
|
3124
3131
|
"surface-contrast": {
|
|
3125
3132
|
group: "accessibility-semantics",
|
|
3126
3133
|
severity: "error",
|
|
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
|
|
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.",
|
|
3128
3135
|
guides: ["ads://guides/accessibility", "ads://guides/tokens"],
|
|
3129
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"]`.',
|
|
3130
3137
|
emitters: ["src/owner-analysis-check.mts"],
|
|
@@ -3367,13 +3374,6 @@ export const runtimeErrors = {
|
|
|
3367
3374
|
message: (problem) => `The mock renders <${problem.tag}>, which is not imported from the design system.`,
|
|
3368
3375
|
repair: "Render public owners directly; an arrangement the screen needs belongs in a pattern."
|
|
3369
3376
|
},
|
|
3370
|
-
"prose-element-undeclared": {
|
|
3371
|
-
group: "design-bypass",
|
|
3372
|
-
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.',
|
|
3373
|
-
guides: ["ads://guides/scenarios", RECIPES],
|
|
3374
|
-
message: (problem) => `<${problem.tag}> is content of ${problem.owner}, whose prose recipe declares no such element.`,
|
|
3375
|
-
repair: "Declare the element in the owner's prose recipe (`elements`), or write the content with the elements it declares."
|
|
3376
|
-
},
|
|
3377
3377
|
"spread-props": {
|
|
3378
3378
|
group: "unanalyzable",
|
|
3379
3379
|
rule: "A mock passes explicit props: a spread could carry design ADS cannot see.",
|
|
@@ -3431,6 +3431,13 @@ export const runtimeErrors = {
|
|
|
3431
3431
|
message: (review) => `Part "${review.part}" truncates its text without a title.`,
|
|
3432
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."
|
|
3433
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
|
+
},
|
|
3434
3441
|
"balance-on-paragraph": {
|
|
3435
3442
|
group: "wrong-value",
|
|
3436
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.',
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
isStringLiteral,
|
|
21
21
|
isVariableDeclaration
|
|
22
22
|
} from "typescript/ast";
|
|
23
|
-
import { isProseTag } from "../prose-model.mjs";
|
|
24
23
|
function walk(node, visit) {
|
|
25
24
|
visit(node);
|
|
26
25
|
node.forEachChild((child) => walk(child, visit));
|
|
@@ -89,7 +88,7 @@ function isMetadata(node) {
|
|
|
89
88
|
return !0;
|
|
90
89
|
return !node.attributes.properties.some((attribute) => isJsxAttribute(attribute) && attribute.name.getText() === "rel" && attribute.initializer !== void 0 && /stylesheet/.test(attribute.initializer.getText()));
|
|
91
90
|
}
|
|
92
|
-
export function designUsageProblems(source, { publicEntry, patterns
|
|
91
|
+
export function designUsageProblems(source, { publicEntry, patterns }, allowance = {}) {
|
|
93
92
|
const problems = [], { names, namespaces } = designSystemImports(source, publicEntry), allowed = allowedImports(source, allowance.components ?? new Map), isAllowed = (node) => isIdentifier(node) && allowed.has(node.text) || allowance.metadata === !0 && isMetadata(node.parent), exportedName = (tag) => isIdentifier(tag) ? names.get(tag.text) : isPropertyAccessExpression(tag) && isIdentifier(tag.expression) && namespaces.has(tag.expression.text) ? tag.name.text : void 0, fromDesignSystem = (tag) => exportedName(tag) !== void 0, isPattern = (tag) => tag !== void 0 && patterns.has(exportedName(tag) ?? ""), insidePattern = (node) => {
|
|
94
93
|
for (let current = node.parent;current !== void 0; current = current.parent) {
|
|
95
94
|
if (isJsxElement(current) && current.openingElement === node)
|
|
@@ -98,17 +97,6 @@ export function designUsageProblems(source, { publicEntry, patterns, prose = new
|
|
|
98
97
|
return !0;
|
|
99
98
|
}
|
|
100
99
|
return !1;
|
|
101
|
-
}, proseOwner = (node) => {
|
|
102
|
-
for (let current = node.parent;current !== void 0; current = current.parent) {
|
|
103
|
-
if (!isJsxElement(current) || current.openingElement === node)
|
|
104
|
-
continue;
|
|
105
|
-
const tag = current.openingElement.tagName;
|
|
106
|
-
if (isIdentifier(tag) && isProseTag(tag.text))
|
|
107
|
-
continue;
|
|
108
|
-
const name = exportedName(tag), tags = name === void 0 ? void 0 : prose.get(name);
|
|
109
|
-
return name === void 0 || tags === void 0 ? void 0 : { name, tags };
|
|
110
|
-
}
|
|
111
|
-
return;
|
|
112
100
|
};
|
|
113
101
|
for (const statement of source.statements)
|
|
114
102
|
if (isImportDeclaration(statement) && isStringLiteral(statement.moduleSpecifier) && statement.importClause?.phaseModifier !== SyntaxKind.TypeKeyword && authorsDesign(statement.moduleSpecifier.text))
|
|
@@ -117,13 +105,9 @@ export function designUsageProblems(source, { publicEntry, patterns, prose = new
|
|
|
117
105
|
if (isJsxOpeningElement(node) || isJsxSelfClosingElement(node)) {
|
|
118
106
|
if (isAllowed(node.tagName))
|
|
119
107
|
;
|
|
120
|
-
else if (!fromDesignSystem(node.tagName))
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
problems.push({ node, problem: { kind: "local-markup", tag } });
|
|
124
|
-
else if (!owner.tags.has(tag))
|
|
125
|
-
problems.push({ node, problem: { kind: "prose-element-undeclared", tag, owner: owner.name } });
|
|
126
|
-
} else if (!isPattern(node.tagName) && !insidePattern(node) && inScreenFunction(node))
|
|
108
|
+
else if (!fromDesignSystem(node.tagName))
|
|
109
|
+
problems.push({ node, problem: { kind: "local-markup", tag: node.tagName.getText() } });
|
|
110
|
+
else if (!isPattern(node.tagName) && !insidePattern(node) && inScreenFunction(node))
|
|
127
111
|
problems.push({ node, problem: { kind: "component-outside-pattern", name: exportedName(node.tagName) ?? node.tagName.getText() } });
|
|
128
112
|
for (const attribute of node.attributes.properties)
|
|
129
113
|
if (isJsxSpreadAttribute(attribute))
|
|
@@ -3,7 +3,6 @@ import { isTestFile } from "../config.mjs";
|
|
|
3
3
|
import { SyntaxKind, isCallExpression, isExportDeclaration, isIdentifier, isImportDeclaration, isNamedExports, isNewExpression, isStringLiteral, isTaggedTemplateExpression } from "typescript/ast";
|
|
4
4
|
import { PUBLIC_BARREL } from "./owner-source.mjs";
|
|
5
5
|
import { designUsageProblems } from "./design-usage.mjs";
|
|
6
|
-
import { publicProse } from "./prose-owners.mjs";
|
|
7
6
|
import { capturedTreeFiles, inRevision, location, sourceAst, walk } from "./helpers.mjs";
|
|
8
7
|
export const MOCK_FOLDER = "mocks";
|
|
9
8
|
const PUBLIC_ENTRY = "@ds", DYNAMIC_CALLS = ["require", "eval", "Function"], MEDIA = /\.(svg|png|jpe?g|webp|avif)$/, SCRIPT = /\.[cm]?[jt]sx?$/;
|
|
@@ -34,7 +33,7 @@ function mockMedia(dsRoot, file, statement, specifier) {
|
|
|
34
33
|
const target = path.resolve(path.dirname(file), specifier), clause = statement.importClause;
|
|
35
34
|
return MEDIA.test(target) && target.startsWith(path.join(dsRoot, MOCK_FOLDER) + path.sep) && target.split(path.sep).includes("media") && clause !== void 0 && clause.phaseModifier !== SyntaxKind.TypeKeyword && clause.name !== void 0 && clause.namedBindings === void 0;
|
|
36
35
|
}
|
|
37
|
-
async function checkFile(dsRoot, file, patterns,
|
|
36
|
+
async function checkFile(dsRoot, file, patterns, helpers) {
|
|
38
37
|
const source = await sourceAst(file), findings = [], report = (node, problem) => {
|
|
39
38
|
const at = location(node);
|
|
40
39
|
findings.push({ file, line: at.line, column: at.column, problem });
|
|
@@ -76,7 +75,7 @@ async function checkFile(dsRoot, file, patterns, prose, helpers) {
|
|
|
76
75
|
report(node, { kind: "dynamic-dependency", form: "Function" });
|
|
77
76
|
return;
|
|
78
77
|
});
|
|
79
|
-
for (const { node, problem } of designUsageProblems(source, { publicEntry: PUBLIC_ENTRY, patterns
|
|
78
|
+
for (const { node, problem } of designUsageProblems(source, { publicEntry: PUBLIC_ENTRY, patterns }))
|
|
80
79
|
report(node, problem);
|
|
81
80
|
return findings.sort((a, b) => a.line - b.line || a.column - b.column);
|
|
82
81
|
}
|
|
@@ -87,13 +86,13 @@ export async function mockFindings(dsRoot) {
|
|
|
87
86
|
const test = (file) => isTestFile(path.relative(dsRoot, file)), entries = listed.filter((file) => SCRIPT.test(file) && !file.endsWith(".d.ts") && !test(file)).sort();
|
|
88
87
|
if (entries.length === 0)
|
|
89
88
|
return [];
|
|
90
|
-
const patterns = await publicPatterns(dsRoot),
|
|
89
|
+
const patterns = await publicPatterns(dsRoot), pending = [...entries], visited = new Set, findings = [];
|
|
91
90
|
while (pending.length > 0) {
|
|
92
91
|
const file = pending.shift();
|
|
93
92
|
if (file === void 0 || visited.has(file) || test(file))
|
|
94
93
|
continue;
|
|
95
94
|
visited.add(file);
|
|
96
|
-
findings.push(...await checkFile(dsRoot, file, patterns,
|
|
95
|
+
findings.push(...await checkFile(dsRoot, file, patterns, (helper) => void pending.push(helper)));
|
|
97
96
|
}
|
|
98
97
|
return findings;
|
|
99
98
|
}
|
|
@@ -24,19 +24,19 @@ function literal(opening, name) {
|
|
|
24
24
|
return value !== void 0 && (isStringLiteral(value) || isNoSubstitutionTemplateLiteral(value)) ? value.text : null;
|
|
25
25
|
}
|
|
26
26
|
const literalRole = (opening) => literal(opening, "role"), NOT_TEXT = new Set(["checkbox", "radio", "file", "range", "color", "date", "datetime-local", "month", "time", "week", "button", "submit", "reset", "hidden", "image", "number"]);
|
|
27
|
-
export function missingAutocomplete(opening, component) {
|
|
27
|
+
export function missingAutocomplete(opening, component, tag = opening.tagName.getText()) {
|
|
28
28
|
if (attribute(opening, "autoComplete") !== void 0)
|
|
29
29
|
return null;
|
|
30
|
-
const
|
|
30
|
+
const type = literal(opening, "type");
|
|
31
31
|
if (!component && tag !== "textarea" && !(tag === "input" && (type === null || !NOT_TEXT.has(type.toLowerCase()))))
|
|
32
32
|
return null;
|
|
33
33
|
if (!component && tag === "input" && type === null && attribute(opening, "type") !== void 0)
|
|
34
34
|
return null;
|
|
35
35
|
return suggestedAutocomplete({ name: literal(opening, "name"), id: literal(opening, "id"), type });
|
|
36
36
|
}
|
|
37
|
-
export function clickWithoutKeyboard(opening) {
|
|
37
|
+
export function clickWithoutKeyboard(opening, tag = opening.tagName.getText()) {
|
|
38
38
|
const click = attribute(opening, "onClick");
|
|
39
|
-
if (click === void 0 || !NON_INTERACTIVE.has(
|
|
39
|
+
if (click === void 0 || !NON_INTERACTIVE.has(tag))
|
|
40
40
|
return !1;
|
|
41
41
|
if (/\bcurrentTarget\b/.test(click.getText()))
|
|
42
42
|
return !1;
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { SyntaxKind, isExportAssignment, isExportDeclaration, isImportDeclaration } from "typescript/ast";
|
|
3
3
|
import { digest } from "../digest.mjs";
|
|
4
4
|
import { memoProgram } from "./context.mjs";
|
|
5
|
-
export const OWNER_ANALYSIS_SCHEMA = "ads-owner-analysis/
|
|
5
|
+
export const OWNER_ANALYSIS_SCHEMA = "ads-owner-analysis/12";
|
|
6
6
|
export function canonical(value) {
|
|
7
7
|
return JSON.stringify(value, (_key, item) => {
|
|
8
8
|
if (item instanceof Map)
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
isElementAccessExpression,
|
|
13
13
|
isFunctionExpression,
|
|
14
14
|
isIdentifier,
|
|
15
|
+
isJsxOpeningElement,
|
|
16
|
+
isJsxSelfClosingElement,
|
|
15
17
|
isImportDeclaration,
|
|
16
18
|
isNamedImports,
|
|
17
19
|
isNumericLiteral,
|
|
@@ -213,7 +215,7 @@ const compiledString = (node) => {
|
|
|
213
215
|
return !0;
|
|
214
216
|
const queries = isElementAccessExpression(read) || isPropertyAccessExpression(read) ? unwrapNode(read.expression) : null;
|
|
215
217
|
return queries !== null && isPropertyAccessExpression(queries) && queries.name.text === "conditionQuery";
|
|
216
|
-
}
|
|
218
|
+
}, ELEMENT_NAME = /^[a-z][a-z0-9]*$/, HEADING_LEVEL = /^h[1-6]$/;
|
|
217
219
|
export async function choiceValues({ program, source, root, validateSpec, fail }) {
|
|
218
220
|
const checker = program.getTypeChecker(), roots = { root, dsRoot: root }, symbols = new Map, types = new Map, specs = new Map, macros = new Map, axes = new Map, touched = new Set, macroCalls = new Map, mutable = new Set, escaped = new Set, traced = sourceValues(program, roots), failIn = (context) => context?.fail ?? fail, incomplete = (context, node, problem) => failIn(context)(node, { kind: "choice", problem }), touch = (declaration, context) => {
|
|
219
221
|
if (context.fail === void 0)
|
|
@@ -298,6 +300,13 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
298
300
|
context.trail?.push([item.id, value]);
|
|
299
301
|
return value;
|
|
300
302
|
};
|
|
303
|
+
async function declaredState(declaration) {
|
|
304
|
+
const declared = await type(declaration.name), finite = finiteType(declared);
|
|
305
|
+
if (finite !== null)
|
|
306
|
+
return finite.length > 1;
|
|
307
|
+
const presence = presenceDomain(declared);
|
|
308
|
+
return presence !== null && presence.opaque && presence.classes.length > 1;
|
|
309
|
+
}
|
|
301
310
|
async function bindingAxis(node, declaration, context) {
|
|
302
311
|
const binding = await symbol(node);
|
|
303
312
|
if (binding === void 0)
|
|
@@ -336,7 +345,8 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
336
345
|
declaration,
|
|
337
346
|
parameter,
|
|
338
347
|
name,
|
|
339
|
-
defaultNode: parameter !== null ? initializer : void 0
|
|
348
|
+
defaultNode: parameter !== null ? initializer : void 0,
|
|
349
|
+
...parameter !== null && name !== null ? { omitted: { value: initial !== void 0 ? defaulted : test === "text" ? "absent" : void 0 } } : {}
|
|
340
350
|
};
|
|
341
351
|
axes.set(binding, item);
|
|
342
352
|
}
|
|
@@ -583,6 +593,11 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
583
593
|
const domain = finiteType(await type(declaration.name));
|
|
584
594
|
if (domain !== null && domain.length > 0 && domain.every((value) => typeof value === "boolean"))
|
|
585
595
|
return bindingAxis(node, declaration, context);
|
|
596
|
+
if (declaration.type !== void 0 && await declaredState(declaration)) {
|
|
597
|
+
const initializer = declaration.initializer, { trail: _, ...outer } = context;
|
|
598
|
+
if ((await attemptAsync((reject) => evaluate(initializer, { ...outer, fail: () => reject(null), memo: new Map }))).kind === "err")
|
|
599
|
+
return bindingAxis(node, declaration, context);
|
|
600
|
+
}
|
|
586
601
|
const result = await evaluate(declaration.initializer, context);
|
|
587
602
|
if (escaped.has(binding) && tagged(result) && (result.kind === "record" || result.kind === "recipe"))
|
|
588
603
|
return incomplete(context, node, { kind: "record-escapes" });
|
|
@@ -865,7 +880,22 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
865
880
|
return failure(node, { kind: "choice", problem: { kind: "no-reachable-choice" } });
|
|
866
881
|
return { tree, leaves, axes: [...selectedAxes.values()], branches };
|
|
867
882
|
}
|
|
868
|
-
|
|
883
|
+
const tags = new Map;
|
|
884
|
+
for (const opening of [...nodesOfKind(source, SyntaxKind.JsxOpeningElement, isJsxOpeningElement), ...nodesOfKind(source, SyntaxKind.JsxSelfClosingElement, isJsxSelfClosingElement)]) {
|
|
885
|
+
const tagName = opening.tagName;
|
|
886
|
+
if (!isIdentifier(tagName) || !/^[A-Z]/.test(tagName.text))
|
|
887
|
+
continue;
|
|
888
|
+
const declared = (await symbol(tagName))?.valueDeclaration;
|
|
889
|
+
if (!(declared !== void 0 && (isBindingElement(declared) || isParameterDeclaration(declared) || isVariableDeclaration(declared) && declared.initializer !== void 0 && !isArrowFunction(declared.initializer) && !isFunctionExpression(declared.initializer))))
|
|
890
|
+
continue;
|
|
891
|
+
const domain = finiteType(await type(tagName)), names = domain?.filter((value) => typeof value === "string" && ELEMENT_NAME.test(value)) ?? [];
|
|
892
|
+
if (domain === null || names.length === 0 || names.length !== domain.length)
|
|
893
|
+
continue;
|
|
894
|
+
const [first] = names;
|
|
895
|
+
if (first !== void 0 && (names.length === 1 || names.every((name) => HEADING_LEVEL.test(name))))
|
|
896
|
+
tags.set(tagName, first);
|
|
897
|
+
}
|
|
898
|
+
return { source, evaluate, choices, truthy, symbol, touched, macroCalls, tag: (opening) => tags.get(opening.tagName) ?? opening.tagName.getText() };
|
|
869
899
|
}
|
|
870
900
|
function test(axis, value) {
|
|
871
901
|
switch (axis.test) {
|
|
@@ -80,7 +80,7 @@ export async function plainPlacements(root, source, symbol) {
|
|
|
80
80
|
}
|
|
81
81
|
return placements;
|
|
82
82
|
}
|
|
83
|
-
const LEAF_LIMIT = 512, elementOf = (opening) => isJsxOpeningElement(opening) ? opening.parent : opening
|
|
83
|
+
const LEAF_LIMIT = 512, elementOf = (opening) => isJsxOpeningElement(opening) ? opening.parent : opening;
|
|
84
84
|
function expression(attribute) {
|
|
85
85
|
const initializer = attribute?.initializer;
|
|
86
86
|
if (initializer === void 0)
|
|
@@ -92,9 +92,25 @@ const unwrap = (node) => {
|
|
|
92
92
|
while (isParenthesizedExpression(current) || isAsExpression(current) || isSatisfiesExpression(current) || isNonNullExpression(current))
|
|
93
93
|
current = current.expression;
|
|
94
94
|
return current;
|
|
95
|
-
}, isLoop = (node) => isForStatement(node) || isForOfStatement(node) || isForInStatement(node) || isWhileStatement(node) || isDoStatement(node), TRANSPARENT_STATEMENTS = new Set([SyntaxKind.CaseClause, SyntaxKind.DefaultClause, SyntaxKind.CaseBlock, SyntaxKind.SwitchStatement, SyntaxKind.TryStatement, SyntaxKind.CatchClause, SyntaxKind.LabeledStatement]), transparentTag = (tag) => tag === "Fragment" || tag.endsWith(".Fragment") || tag.endsWith(".Provider"), DISABLEABLE = new Set(["button", "fieldset", "input", "select", "textarea", "optgroup", "option"]);
|
|
95
|
+
}, isLoop = (node) => isForStatement(node) || isForOfStatement(node) || isForInStatement(node) || isWhileStatement(node) || isDoStatement(node), TRANSPARENT_STATEMENTS = new Set([SyntaxKind.CaseClause, SyntaxKind.DefaultClause, SyntaxKind.CaseBlock, SyntaxKind.SwitchStatement, SyntaxKind.TryStatement, SyntaxKind.CatchClause, SyntaxKind.LabeledStatement]), transparentTag = (tag) => tag === "Fragment" || tag.endsWith(".Fragment") || tag.endsWith(".Provider"), DISABLEABLE = new Set(["button", "fieldset", "input", "select", "textarea", "optgroup", "option"]), ATTRIBUTE_TEST = /\[([\w-]+)(?:="([^"]*)")?\]/g;
|
|
96
|
+
export function reachableSurfaces(surfaces, attributes) {
|
|
97
|
+
if (attributes === "open")
|
|
98
|
+
return surfaces;
|
|
99
|
+
const holds = (condition) => {
|
|
100
|
+
const positive = condition.replace(/:not\((?:[^()]|\([^()]*\))*\)/g, "");
|
|
101
|
+
for (const [, name, expected] of positive.matchAll(ATTRIBUTE_TEST)) {
|
|
102
|
+
if (name === void 0 || !attributes.has(name))
|
|
103
|
+
continue;
|
|
104
|
+
const rendered = attributes.get(name) ?? null;
|
|
105
|
+
if (rendered === null || expected !== void 0 && rendered !== expected)
|
|
106
|
+
return !1;
|
|
107
|
+
}
|
|
108
|
+
return !0;
|
|
109
|
+
}, kept = surfaces.filter((state) => state.condition === null || holds(state.condition));
|
|
110
|
+
return kept.length === surfaces.length ? surfaces : kept;
|
|
111
|
+
}
|
|
96
112
|
export async function compositionFacts(inputs) {
|
|
97
|
-
const { root, source, values, checker, foundation } = inputs, points = new Map, point = (node) => {
|
|
113
|
+
const { root, source, values, checker, foundation } = inputs, lowercase = (opening) => /^[a-z]/.test(values.tag(opening)), points = new Map, point = (node) => {
|
|
98
114
|
let known = points.get(node);
|
|
99
115
|
if (known === void 0) {
|
|
100
116
|
const at = location(node);
|
|
@@ -104,7 +120,7 @@ export async function compositionFacts(inputs) {
|
|
|
104
120
|
}, tags = new Map, tagOf = (opening) => {
|
|
105
121
|
let known = tags.get(opening);
|
|
106
122
|
if (known === void 0)
|
|
107
|
-
tags.set(opening, known =
|
|
123
|
+
tags.set(opening, known = values.tag(opening));
|
|
108
124
|
return known;
|
|
109
125
|
}, attributes = new Map, attributeOf = (opening, name) => {
|
|
110
126
|
let known = attributes.get(opening);
|
|
@@ -256,7 +272,7 @@ export async function compositionFacts(inputs) {
|
|
|
256
272
|
const opening = parent.openingElement;
|
|
257
273
|
if (lowercase(opening))
|
|
258
274
|
steps.push({ kind: "element", opening });
|
|
259
|
-
else if (!transparentTag(
|
|
275
|
+
else if (!transparentTag(values.tag(opening)))
|
|
260
276
|
steps.push({ kind: "slot", opening, prop: "children" });
|
|
261
277
|
node = parent;
|
|
262
278
|
continue;
|
|
@@ -412,8 +428,36 @@ export async function compositionFacts(inputs) {
|
|
|
412
428
|
if (read.value === void 0 || read.value === null || read.value === !1)
|
|
413
429
|
return null;
|
|
414
430
|
return typeof read.value === "string" ? read.value : "open";
|
|
415
|
-
}, theme = await named("data-theme"), brand = await named("data-brand");
|
|
416
|
-
|
|
431
|
+
}, theme = await named("data-theme"), brand = await named("data-brand"), subtree = theme === "open" || brand === "open" ? "open" : theme === null && brand === null ? null : { theme, brand }, tested = new Set;
|
|
432
|
+
for (const fragment of classes?.fragments ?? [])
|
|
433
|
+
for (const [, name] of JSON.stringify(fragment.spec).matchAll(/\[((?:aria|data)-[\w-]+)/g))
|
|
434
|
+
if (name !== void 0)
|
|
435
|
+
tested.add(name);
|
|
436
|
+
let attributes = new Map;
|
|
437
|
+
for (const property of tested.size === 0 ? [] : opening.attributes.properties) {
|
|
438
|
+
if (isJsxSpreadAttribute(property)) {
|
|
439
|
+
attributes = "open";
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
if (!isJsxAttribute(property))
|
|
443
|
+
continue;
|
|
444
|
+
const name = property.name.getText(source);
|
|
445
|
+
if (!tested.has(name))
|
|
446
|
+
continue;
|
|
447
|
+
if (property.initializer === void 0) {
|
|
448
|
+
attributes.set(name, "true");
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
const read = await optional(expression(property), context, evaluate);
|
|
452
|
+
if (!read.known)
|
|
453
|
+
continue;
|
|
454
|
+
const { value } = read;
|
|
455
|
+
if (value === void 0 || value === null)
|
|
456
|
+
attributes.set(name, null);
|
|
457
|
+
else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
458
|
+
attributes.set(name, String(value));
|
|
459
|
+
}
|
|
460
|
+
return { opening, classes, exempt: hidden ? "hidden" : inactive ? "inactive" : null, context: subtree, attributes };
|
|
417
461
|
}
|
|
418
462
|
async function resolveLeaf(pathed, context, evaluate) {
|
|
419
463
|
const steps = [];
|
|
@@ -536,15 +580,19 @@ export async function compositionFacts(inputs) {
|
|
|
536
580
|
function chainElements(raws) {
|
|
537
581
|
const elements = [];
|
|
538
582
|
let parent = null;
|
|
583
|
+
const rootAttributes = new Map;
|
|
539
584
|
for (let index = raws.length - 1;index >= 0; index--) {
|
|
540
585
|
const raw = raws[index];
|
|
541
586
|
if (raw === void 0)
|
|
542
587
|
continue;
|
|
543
588
|
const role = roleOf(raw, parent);
|
|
589
|
+
if (role.scope !== null && role.scope === String(raw.opening.getStart(source)))
|
|
590
|
+
rootAttributes.set(role.scope, raw.attributes);
|
|
591
|
+
const tested = role.scope === null ? void 0 : rootAttributes.get(role.scope);
|
|
544
592
|
elements.push({
|
|
545
593
|
tag: tagOf(raw.opening),
|
|
546
594
|
at: point(raw.opening),
|
|
547
|
-
surfaces: role.surfaces,
|
|
595
|
+
surfaces: role.surfaces === null || tested === void 0 ? role.surfaces : reachableSurfaces(role.surfaces, tested),
|
|
548
596
|
scope: role.scope,
|
|
549
597
|
text: role.text,
|
|
550
598
|
flow: role.flow,
|
|
@@ -584,14 +632,14 @@ export async function compositionFacts(inputs) {
|
|
|
584
632
|
const bare = unwrap(value), scalar = isStringLiteral(bare) || isNoSubstitutionTemplateLiteral(bare) ? { known: !0, value: bare.text } : isNumericLiteral(bare) ? { known: !0, value: Number(bare.text) } : bare.kind === SyntaxKind.TrueKeyword ? { known: !0, value: !0 } : bare.kind === SyntaxKind.FalseKeyword ? { known: !0, value: !1 } : bare.kind === SyntaxKind.NullKeyword ? { known: !0, value: null } : isIdentifier(bare) && bare.text === "undefined" ? { known: !0, value: void 0 } : { known: !1, value: void 0 }, renders = /^on[A-Z]/.test(prop) ? [] : await rendersOf(value, fn), forwardedProp = renders.find((item) => item.kind === "forward")?.prop ?? null, text = renders.some((item) => item.kind === "text" && item.certain) ? "text" : forwardedProp !== null ? "forward" : renders.some((item) => item.kind === "text") ? "maybe-text" : "none";
|
|
585
633
|
args.push({ prop, value: scalar.known ? { kind: "literal", value: literal(scalar.value) } : { kind: "open", given: await certainlyGiven(bare) }, text, forwards: text === "forward" ? forwardedProp : null, at: located });
|
|
586
634
|
}
|
|
587
|
-
return { kind: "placement", tag:
|
|
635
|
+
return { kind: "placement", tag: values.tag(opening), target: await targetOf(opening), args, spread };
|
|
588
636
|
}
|
|
589
|
-
const pending = [], insideSvg = (pathed) => pathed.steps.some((step) => step.kind === "element" && ["svg", "style", "script", "template"].includes(step.opening
|
|
637
|
+
const pending = [], insideSvg = (pathed) => pathed.steps.some((step) => step.kind === "element" && ["svg", "style", "script", "template"].includes(values.tag(step.opening))), openings = [
|
|
590
638
|
...nodesOfKind(source, SyntaxKind.JsxOpeningElement, isJsxOpeningElement),
|
|
591
639
|
...nodesOfKind(source, SyntaxKind.JsxSelfClosingElement, isJsxSelfClosingElement)
|
|
592
640
|
].sort((a, b) => a.pos - b.pos);
|
|
593
641
|
for (const opening of openings) {
|
|
594
|
-
if (lowercase(opening) || transparentTag(
|
|
642
|
+
if (lowercase(opening) || transparentTag(values.tag(opening)))
|
|
595
643
|
continue;
|
|
596
644
|
const element = elementOf(opening), pathed = pathOf(element);
|
|
597
645
|
if (insideSvg(pathed))
|
|
@@ -693,7 +741,8 @@ export async function compositionFacts(inputs) {
|
|
|
693
741
|
const axis = axes.get(id);
|
|
694
742
|
if (!relevant.has(id) || axis === void 0 || axis.name === null || props === null || axis.parameter !== props)
|
|
695
743
|
continue;
|
|
696
|
-
|
|
744
|
+
const omitted = axis.test === "presence" || axis.omitted === void 0 ? {} : { omitted: Object.is(axis.omitted.value, value) };
|
|
745
|
+
leafProps.push({ prop: axis.name, test: axis.test, value: literal(value), ...omitted });
|
|
697
746
|
}
|
|
698
747
|
const fact = { segments, props: leafProps };
|
|
699
748
|
leaves.set(`${chain.text}\x00${JSON.stringify(leafProps)}`, fact);
|