@reqvire-org/ads 0.4.0 → 0.4.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/README.md +115 -87
- package/dist/a11y.mjs +133 -48
- package/dist/analysis/compiler-options.mjs +13 -0
- package/dist/analysis/context.mjs +46 -0
- package/dist/analysis/file-tree.mjs +52 -0
- package/dist/analysis/helpers.mjs +142 -0
- package/dist/analysis/impact.mjs +20 -0
- package/dist/analysis/inputs.mjs +22 -0
- package/dist/analysis/module-resolvers.mjs +46 -0
- package/dist/analysis/native-adapter.mjs +180 -0
- package/dist/analysis/native-project.mjs +323 -0
- package/dist/analysis/queries.mjs +133 -0
- package/dist/analysis/service.mjs +153 -0
- package/dist/analysis/standalone.mjs +57 -0
- package/dist/analysis/syntax.mjs +179 -0
- package/dist/analysis/worker.mjs +182 -0
- package/dist/assets.mjs +6 -6
- package/dist/atomic-composition.mjs +191 -70
- package/dist/atomic-trace.mjs +120 -50
- package/dist/behavior-libraries.mjs +106 -37
- package/dist/behaviors.mjs +219 -77
- package/dist/boundaries.mjs +140 -41
- package/dist/brand-assets.mjs +219 -47
- package/dist/brands.mjs +86 -27
- package/dist/bun-compiler.mjs +28 -14
- package/dist/bun-worker.mjs +7 -5
- package/dist/capture/worker.mjs +15 -4
- package/dist/capture-store.mjs +4 -2
- package/dist/capture.mjs +17 -14
- package/dist/check-service.mjs +44 -58
- package/dist/check.mjs +754 -188
- package/dist/cli.mjs +200 -99
- package/dist/color-values.mjs +21 -21
- package/dist/component-contrast.mjs +127 -9
- package/dist/config.mjs +303 -135
- package/dist/construction-styles.cjs +10 -0
- package/dist/contrast-composition.mjs +134 -0
- package/dist/control-padding.mjs +45 -25
- package/dist/css-values.mjs +3 -2
- package/dist/declarative-flow.mjs +209 -109
- package/dist/design-values.mjs +136 -51
- package/dist/development-runtime.mjs +4 -6
- package/dist/draft-boundary.mjs +11 -6
- package/dist/evidence.mjs +1 -1
- package/dist/finding-rules.mjs +9 -5
- package/dist/font-rules.mjs +22 -17
- package/dist/fonts-generated.mjs +23 -16
- package/dist/foundation-views.mjs +242 -0
- package/dist/foundation.mjs +63 -39
- package/dist/generated-entries.mjs +101 -34
- package/dist/icons.mjs +79 -32
- package/dist/image-attributes.mjs +143 -66
- package/dist/image-size.mjs +1 -1
- package/dist/index.mjs +0 -2
- package/dist/init.mjs +122 -41
- package/dist/investigations.mjs +2 -2
- package/dist/layers.mjs +298 -129
- package/dist/layout-widths.mjs +180 -85
- package/dist/linaria/preserve-values.cjs +7 -0
- package/dist/linaria/spatial-inputs.cjs +56 -0
- package/dist/lockup-composition.mjs +44 -0
- package/dist/lockup-model.cjs +64 -0
- package/dist/mcp/THIRD_PARTY_NOTICES.md +51 -1
- package/dist/mcp/apps.mjs +4 -30
- package/dist/mcp/behavior-pages.mjs +72 -24
- package/dist/mcp/build-status.mjs +257 -64
- package/dist/mcp/catalog.mjs +90 -26
- package/dist/mcp/context.mjs +17 -18
- package/dist/mcp/draft-discovery.mjs +44 -21
- package/dist/mcp/drafts.mjs +903 -281
- package/dist/mcp/execution-coordinator.mjs +417 -167
- package/dist/mcp/execution-results.mjs +7 -7
- package/dist/mcp/mutations.mjs +673 -234
- package/dist/mcp/preview-watch.mjs +448 -170
- package/dist/mcp/preview-widget.bundle.js +44 -50
- package/dist/mcp/prompts.mjs +5 -5
- package/dist/mcp/result-pages.mjs +1 -1
- package/dist/mcp/sandbox-host.mjs +1 -1
- package/dist/mcp/server.mjs +2409 -577
- package/dist/mcp/showcase-host.mjs +165 -41
- package/dist/mcp/skills.mjs +1 -1
- package/dist/mcp/text-diff.mjs +29 -10
- package/dist/paint-contracts.mjs +174 -81
- package/dist/palette-generated.mjs +2 -2
- package/dist/pictogram-model.mjs +59 -0
- package/dist/pictograms.mjs +52 -0
- package/dist/preview-bun.mjs +494 -187
- package/dist/preview-failure.mjs +1 -1
- package/dist/preview-files.mjs +13 -13
- package/dist/preview-imports.mjs +104 -55
- package/dist/preview-inputs.mjs +2 -2
- package/dist/preview-requests.mjs +24 -0
- package/dist/preview-resources.mjs +288 -147
- package/dist/preview-scope.mjs +5 -4
- package/dist/program-cache.mjs +8 -34
- package/dist/project-documents.mjs +1 -1
- package/dist/public-api.mjs +69 -31
- package/dist/public-props.mjs +39 -22
- package/dist/{browser-audit → render-audit}/axe-run.mjs +3 -3
- package/dist/{browser-audit → render-audit}/image-shape.mjs +15 -5
- package/dist/{browser-audit → render-audit}/layout-overflow.mjs +86 -23
- package/dist/{browser-audit → render-audit}/non-text-contrast.mjs +86 -27
- package/dist/render-audit/pictograms.mjs +88 -0
- package/dist/{browser-audit → render-audit}/render-states.mjs +208 -52
- package/dist/{browser-audit → render-audit}/worker.mjs +98 -30
- package/dist/render-audit.mjs +838 -0
- package/dist/render-color-probe.mjs +96 -42
- package/dist/render-composition.mjs +164 -0
- package/dist/resource-limits.mjs +229 -97
- package/dist/runtime-contracts.mjs +467 -185
- package/dist/scenario-groups.mjs +22 -10
- package/dist/scenario-inspector.mjs +6 -43
- package/dist/scenario-program.mjs +8 -25
- package/dist/scenario-registry.mjs +72 -30
- package/dist/scenario-selectors.mjs +161 -64
- package/dist/scenario-slots.mjs +149 -56
- package/dist/scenario-trace.mjs +215 -109
- package/dist/scenarios-compiler.mjs +719 -378
- package/dist/scenarios-vite.d.mts +1 -3
- package/dist/scenarios-vite.mjs +2 -81
- package/dist/scenarios.mjs +421 -157
- package/dist/selector-match.mjs +2 -2
- package/dist/showcase/client.bundle.js +57 -56
- package/dist/showcase/draft-navigation.js +21 -3
- package/dist/showcase/favicon.ico +0 -0
- package/dist/showcase/favicon.svg +1 -0
- package/dist/showcase/foundation-view.css +58 -0
- package/dist/showcase/foundation-view.mjs +255 -0
- package/dist/showcase/guide-controls.ads.review.mjs +32 -0
- package/dist/showcase/icons.js +1 -145
- package/dist/showcase/index.html +3 -31
- package/dist/showcase/pictogram-view.mjs +53 -0
- package/dist/showcase/preview-frame.ads.review.css +46 -0
- package/dist/showcase/preview-frame.ads.review.d.mts +11 -0
- package/dist/showcase/preview-frame.ads.review.mjs +22 -0
- package/dist/showcase/preview-state.js +0 -9
- package/dist/showcase/refresh-scheduler.js +23 -0
- package/dist/showcase/style.css +5 -47
- package/dist/showcase/ui/ui.css +1353 -0
- package/dist/showcase/ui/ui.js +1064 -0
- package/dist/showcase-coverage.mjs +58 -37
- package/dist/skills/README.md +24 -23
- package/dist/skills/ads-designer/README.md +8 -2
- package/dist/skills/ads-designer/SKILL.md +143 -120
- package/dist/skills/ads-designer/references/accessibility.md +78 -15
- package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
- package/dist/skills/ads-designer/references/behaviors.md +30 -27
- package/dist/skills/ads-designer/references/branding.md +101 -24
- package/dist/skills/ads-designer/references/captures.md +25 -0
- package/dist/skills/ads-designer/references/cli.md +21 -24
- package/dist/skills/ads-designer/references/contracts.md +7 -6
- package/dist/skills/ads-designer/references/design-data.md +49 -52
- package/dist/skills/ads-designer/references/drafts.md +20 -17
- package/dist/skills/ads-designer/references/evidence.md +1 -5
- package/dist/skills/ads-designer/references/guarded-editing.md +14 -18
- package/dist/skills/ads-designer/references/layers.md +1 -1
- package/dist/skills/ads-designer/references/layout.md +347 -0
- package/dist/skills/ads-designer/references/mobile.md +2 -1
- package/dist/skills/{ads-motion/references/performance.md → ads-designer/references/motion-performance.md} +5 -1
- package/dist/skills/{ads-motion/references/build.md → ads-designer/references/motion.md} +73 -5
- package/dist/skills/ads-designer/references/performance.md +3 -2
- package/dist/skills/ads-designer/references/pictograms.md +131 -0
- package/dist/skills/ads-designer/references/review.md +37 -34
- package/dist/skills/ads-designer/references/runtimes.md +33 -30
- package/dist/skills/ads-designer/references/scenarios.md +16 -18
- package/dist/skills/{ads-break-ui/references/catalog.md → ads-designer/references/stress-catalog.md} +3 -1
- package/dist/skills/ads-designer/references/stress-test.md +68 -0
- package/dist/skills/ads-designer/references/validation.md +83 -75
- package/dist/skills/ads-designer/references/workflows.md +8 -33
- package/dist/skills/ads-import/SKILL.md +43 -325
- package/dist/skills/ads-import/references/atomic-styles.md +4 -4
- package/dist/skills/ads-import/references/behaviors.md +30 -27
- package/dist/skills/ads-import/references/branding.md +5 -5
- package/dist/skills/ads-import/references/captures.md +25 -0
- package/dist/skills/ads-import/references/cli.md +21 -24
- package/dist/skills/ads-import/references/compatibility.md +1 -1
- package/dist/skills/ads-import/references/contracts.md +7 -6
- package/dist/skills/ads-import/references/design-data.md +49 -52
- package/dist/skills/ads-import/references/drafts.md +20 -17
- package/dist/skills/ads-import/references/evidence.md +1 -5
- package/dist/skills/ads-import/references/guarded-editing.md +14 -18
- package/dist/skills/ads-import/references/implementation.md +2 -1
- package/dist/skills/ads-import/references/layers.md +1 -1
- package/dist/skills/ads-import/references/layout.md +347 -0
- package/dist/skills/ads-import/references/review.md +37 -34
- package/dist/skills/ads-import/references/runtimes.md +33 -30
- package/dist/skills/ads-import/references/scenarios.md +16 -18
- package/dist/skills/ads-import/references/tokens.md +3 -3
- package/dist/skills/ads-import/references/validation.md +83 -75
- package/dist/skills/ads-import/references/workflows.md +8 -33
- package/dist/skills/ads-migrate/SKILL.md +56 -0
- package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +602 -0
- package/dist/skills/ads-port/SKILL.md +58 -344
- package/dist/skills/ads-port/references/atomic-styles.md +4 -4
- package/dist/skills/ads-port/references/behaviors.md +30 -27
- package/dist/skills/ads-port/references/captures.md +25 -0
- package/dist/skills/ads-port/references/cli.md +21 -24
- package/dist/skills/ads-port/references/contracts.md +7 -6
- package/dist/skills/ads-port/references/design-data.md +49 -52
- package/dist/skills/ads-port/references/drafts.md +20 -17
- package/dist/skills/ads-port/references/evidence.md +1 -5
- package/dist/skills/ads-port/references/guarded-editing.md +14 -18
- package/dist/skills/ads-port/references/layers.md +1 -1
- package/dist/skills/ads-port/references/layout.md +347 -0
- package/dist/skills/ads-port/references/lint-and-docs.md +8 -11
- package/dist/skills/ads-port/references/native-implementation.md +2 -1
- package/dist/skills/ads-port/references/review.md +37 -34
- package/dist/skills/ads-port/references/runtimes.md +33 -30
- package/dist/skills/ads-port/references/scenarios.md +16 -18
- package/dist/skills/ads-port/references/validation.md +83 -75
- package/dist/skills/ads-port/references/workflows.md +8 -33
- package/dist/source-symbols.mjs +1 -8
- package/dist/source-values.mjs +270 -129
- package/dist/spatial-composition.mjs +322 -0
- package/dist/spatial-contexts.cjs +56 -0
- package/dist/spatial-css.cjs +351 -0
- package/dist/spatial-inputs.cjs +80 -0
- package/dist/spatial-metadata.mjs +18 -0
- package/dist/spatial-model.cjs +322 -0
- package/dist/spatial.mjs +21 -0
- package/dist/stage-timing.cjs +20 -0
- package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +105 -0
- package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +275 -0
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
- package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +8 -0
- package/dist/starters/preact/ds.config.json +25 -6
- package/dist/starters/preact/package.json +4 -8
- package/dist/starters/preact/tsconfig.json +4 -5
- package/dist/starters/preact/vite.config.ts +3 -3
- package/dist/starters/react/ADS.md +42 -47
- package/dist/starters/react/README.md +47 -49
- package/dist/starters/react/design-system/assets/pictograms/catalog.ads.json +13 -0
- package/dist/starters/react/design-system/assets/pictograms/journey.dark.svg +7 -0
- package/dist/starters/react/design-system/assets/pictograms/journey.svg +7 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +18 -2
- package/dist/starters/react/design-system/components/Actions/IconButton/README.md +3 -0
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.fixture.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.scenario.tsx +7 -0
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.tsx +26 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +5 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +13 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +22 -0
- package/dist/starters/react/design-system/index.ts +2 -1
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +7 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +15 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +105 -0
- package/dist/starters/react/design-system/patterns/Conversation/README.md +9 -0
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +5 -0
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +21 -0
- package/dist/starters/react/design-system/patterns/Shell/README.md +43 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +5 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +21 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +274 -0
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -1
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
- package/dist/starters/react/design-system/review/index.ads.review.ts +4 -0
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +6 -0
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -1
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
- package/dist/starters/react/design-system/showcase/mcp/{main.tsx → main.ads.mount.tsx} +4 -2
- package/dist/starters/react/design-system/tokens/catalog.ads.json +1221 -0
- package/dist/starters/react/design-system/tokens/colors.css +1 -1
- package/dist/starters/react/design-system/tokens/spacing.css +22 -32
- package/dist/starters/react/design-system/tokens/spatial.ads.json +70 -0
- package/dist/starters/react/design-system/tokens/themes.generated.ts +1 -1
- package/dist/starters/react/ds.config.json +25 -6
- package/dist/starters/react/package.json +2 -6
- package/dist/starters/react/tsconfig.json +2 -3
- package/dist/starters/react/vite.config.ts +3 -3
- package/dist/style-boundaries.mjs +70 -25
- package/dist/task-cache.mjs +173 -72
- package/dist/task-worker.mjs +22 -11
- package/dist/test-boundaries.mjs +132 -59
- package/dist/themes-generated.mjs +1 -1
- package/dist/themes-watch.mjs +57 -22
- package/dist/themes.mjs +176 -73
- package/dist/token-export.mjs +39 -14
- package/dist/token-policy.mjs +6 -3
- package/dist/token-quality.mjs +6 -6
- package/dist/token-samples.mjs +16 -5
- package/dist/tokens.mjs +71 -26
- package/dist/ui-framework.mjs +16 -14
- package/dist/unit-contracts.mjs +251 -104
- package/dist/units.mjs +209 -99
- package/dist/usage.mjs +138 -38
- package/dist/validation-checks.mjs +115 -38
- package/dist/validation-inputs.mjs +191 -78
- package/dist/validation.mjs +268 -102
- package/dist/verification/browser.mjs +27 -5
- package/dist/verification.mjs +711 -187
- package/docs/ADS.md +96 -80
- package/docs/ARCHITECTURE.md +368 -137
- package/docs/BEHAVIORS.md +29 -25
- package/docs/CACHING.md +77 -17
- package/docs/CHANGELOG.md +332 -17
- package/docs/CONTRACTS.md +12 -4
- package/docs/DESIGN-REFERENCES.md +40 -0
- package/docs/GUIDE.md +300 -263
- package/docs/MCP.md +187 -324
- package/docs/SPATIAL-CHECKS.md +69 -0
- package/docs/benchmarks/README.md +39 -0
- package/package.json +43 -34
- package/dist/browser-audit.mjs +0 -429
- package/dist/create.mjs +0 -48
- package/dist/lint-config.mjs +0 -50
- package/dist/mcp/project-widget.bundle.js +0 -114
- package/dist/mcp/reports.mjs +0 -101
- package/dist/mcp/widget.bundle.js +0 -147
- package/dist/oxlint.mjs +0 -89
- package/dist/preview-builder.mjs +0 -133
- package/dist/preview-workers.mjs +0 -184
- package/dist/showcase.mjs +0 -77
- package/dist/skills/ads-break-ui/LICENSE.upstream +0 -21
- package/dist/skills/ads-break-ui/README.md +0 -16
- package/dist/skills/ads-break-ui/SKILL.md +0 -412
- package/dist/skills/ads-break-ui/agents/openai.yaml +0 -4
- package/dist/skills/ads-break-ui/references/atomic-styles.md +0 -293
- package/dist/skills/ads-break-ui/references/behaviors.md +0 -412
- package/dist/skills/ads-break-ui/references/captures.md +0 -135
- package/dist/skills/ads-break-ui/references/contracts.md +0 -317
- package/dist/skills/ads-break-ui/references/design-data.md +0 -354
- package/dist/skills/ads-break-ui/references/drafts.md +0 -194
- package/dist/skills/ads-break-ui/references/evidence.md +0 -128
- package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -165
- package/dist/skills/ads-break-ui/references/layers.md +0 -145
- package/dist/skills/ads-break-ui/references/reporting.md +0 -101
- package/dist/skills/ads-break-ui/references/review.md +0 -97
- package/dist/skills/ads-break-ui/references/runtimes.md +0 -203
- package/dist/skills/ads-break-ui/references/scenarios.md +0 -246
- package/dist/skills/ads-break-ui/references/validation.md +0 -166
- package/dist/skills/ads-break-ui/references/verification.md +0 -58
- package/dist/skills/ads-break-ui/references/workflows.md +0 -90
- package/dist/skills/ads-designer/references/reporting.md +0 -101
- package/dist/skills/ads-import/references/reporting.md +0 -101
- package/dist/skills/ads-motion/LICENSE.upstream +0 -21
- package/dist/skills/ads-motion/README.md +0 -22
- package/dist/skills/ads-motion/SKILL.md +0 -385
- package/dist/skills/ads-motion/agents/openai.yaml +0 -4
- package/dist/skills/ads-motion/references/atomic-styles.md +0 -293
- package/dist/skills/ads-motion/references/audit.md +0 -44
- package/dist/skills/ads-motion/references/behaviors.md +0 -412
- package/dist/skills/ads-motion/references/captures.md +0 -135
- package/dist/skills/ads-motion/references/contracts.md +0 -317
- package/dist/skills/ads-motion/references/design-data.md +0 -354
- package/dist/skills/ads-motion/references/drafts.md +0 -194
- package/dist/skills/ads-motion/references/evidence.md +0 -128
- package/dist/skills/ads-motion/references/guarded-editing.md +0 -165
- package/dist/skills/ads-motion/references/layers.md +0 -145
- package/dist/skills/ads-motion/references/motion-review.md +0 -35
- package/dist/skills/ads-motion/references/reporting.md +0 -101
- package/dist/skills/ads-motion/references/review.md +0 -97
- package/dist/skills/ads-motion/references/runtimes.md +0 -203
- package/dist/skills/ads-motion/references/scenarios.md +0 -246
- package/dist/skills/ads-motion/references/validation.md +0 -166
- package/dist/skills/ads-motion/references/verification.md +0 -39
- package/dist/skills/ads-motion/references/workflows.md +0 -90
- package/dist/skills/ads-port/references/reporting.md +0 -101
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +0 -76
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +0 -137
- package/dist/starters/preact/design-system/showcase/mcp/main.tsx +0 -6
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +0 -12
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +0 -17
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +0 -75
- package/dist/starters/react/design-system/components/Layout/Grid/README.md +0 -21
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +0 -112
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/starters/react/design-system/review/grid-cell/GridCell.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
- package/dist/starters/react/design-system/review/index.ts +0 -6
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +0 -137
- package/dist/starters/react/design-system/showcase/mcp/index.html +0 -1
- package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +0 -124
- package/dist/starters/react/design-system/tokens/Color.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +0 -39
- package/dist/starters/react/design-system/tokens/Layout.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +0 -18
- package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +0 -30
- package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +0 -37
- package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +0 -29
- package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +0 -4
- package/dist/starters/react/package-lock.json +0 -4707
- package/dist/token-fixtures.mjs +0 -30
- package/docs/benchmarks/bun-previews.md +0 -91
- package/docs/benchmarks/preview-memory.md +0 -147
- package/docs/benchmarks/turbo-poc.md +0 -284
- package/docs/plans/execution-coordination.md +0 -57
- /package/dist/{browser-audit → render-audit}/first-render.mjs +0 -0
- /package/dist/{browser-audit → render-audit}/layout-shift.mjs +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { eachChild } from "./analysis/queries.mjs";
|
|
1
2
|
import path from "node:path";
|
|
2
|
-
import ts from "
|
|
3
|
+
import ts from "./analysis/syntax.mjs";
|
|
3
4
|
import postcss from "postcss";
|
|
4
5
|
import valueParser from "postcss-value-parser";
|
|
5
6
|
import { isInside } from "./config.mjs";
|
|
@@ -11,14 +12,32 @@ export const atomicStyleGuide = "ads://guides/atomic-styles";
|
|
|
11
12
|
|
|
12
13
|
const sides = ["top", "right", "bottom", "left"];
|
|
13
14
|
const logicalSides = ["block-start", "block-end", "inline-start", "inline-end"];
|
|
14
|
-
const intersects = (a, b) => a.some(value => b.includes(value));
|
|
15
|
-
const previewValue = value => value.length > 200 ? value.slice(0, 197) + "..." : value;
|
|
15
|
+
const intersects = (a, b) => a.some((value) => b.includes(value));
|
|
16
|
+
const previewValue = (value) => (value.length > 200 ? value.slice(0, 197) + "..." : value);
|
|
16
17
|
const shorthands = {
|
|
17
|
-
background: [
|
|
18
|
+
background: [
|
|
19
|
+
"background-attachment",
|
|
20
|
+
"background-clip",
|
|
21
|
+
"background-color",
|
|
22
|
+
"background-image",
|
|
23
|
+
"background-origin",
|
|
24
|
+
"background-position",
|
|
25
|
+
"background-repeat",
|
|
26
|
+
"background-size",
|
|
27
|
+
],
|
|
18
28
|
"background-position": ["background-position-x", "background-position-y"],
|
|
19
29
|
"background-repeat": ["background-repeat-x", "background-repeat-y"],
|
|
20
30
|
font: ["font-family", "font-size", "font-stretch", "font-style", "font-variant", "font-weight", "line-height"],
|
|
21
|
-
animation: [
|
|
31
|
+
animation: [
|
|
32
|
+
"animation-name",
|
|
33
|
+
"animation-duration",
|
|
34
|
+
"animation-timing-function",
|
|
35
|
+
"animation-delay",
|
|
36
|
+
"animation-iteration-count",
|
|
37
|
+
"animation-direction",
|
|
38
|
+
"animation-fill-mode",
|
|
39
|
+
"animation-play-state",
|
|
40
|
+
],
|
|
22
41
|
transition: ["transition-property", "transition-duration", "transition-timing-function", "transition-delay", "transition-behavior"],
|
|
23
42
|
flex: ["flex-grow", "flex-shrink", "flex-basis"],
|
|
24
43
|
"flex-flow": ["flex-direction", "flex-wrap"],
|
|
@@ -29,12 +48,15 @@ const shorthands = {
|
|
|
29
48
|
"list-style": ["list-style-image", "list-style-position", "list-style-type"],
|
|
30
49
|
"text-decoration": ["text-decoration-color", "text-decoration-style", "text-decoration-line", "text-decoration-thickness"],
|
|
31
50
|
};
|
|
32
|
-
const expand = property => shorthands[property]?.flatMap(expand) ?? [property];
|
|
33
|
-
const longhands = new Map(Object.keys(shorthands).map(property => [property, expand(property)]));
|
|
51
|
+
const expand = (property) => shorthands[property]?.flatMap(expand) ?? [property];
|
|
52
|
+
const longhands = new Map(Object.keys(shorthands).map((property) => [property, expand(property)]));
|
|
34
53
|
|
|
35
54
|
// CSS-language relationships, independent of components, tokens and frameworks.
|
|
36
55
|
function footprint(property) {
|
|
37
|
-
const box =
|
|
56
|
+
const box =
|
|
57
|
+
/^(padding|margin|scroll-padding|scroll-margin|inset)(?:-(top|right|bottom|left|block|inline|block-start|block-end|inline-start|inline-end))?$/.exec(
|
|
58
|
+
property,
|
|
59
|
+
);
|
|
38
60
|
if (box) {
|
|
39
61
|
const side = box[2];
|
|
40
62
|
const logical = !!side && !sides.includes(side);
|
|
@@ -44,7 +66,13 @@ function footprint(property) {
|
|
|
44
66
|
const border = /^border(?:-(top|right|bottom|left|block|inline|block-start|block-end|inline-start|inline-end))?(?:-(color|style|width))?$/.exec(property);
|
|
45
67
|
if (border) {
|
|
46
68
|
const side = border[1];
|
|
47
|
-
return {
|
|
69
|
+
return {
|
|
70
|
+
family: "border",
|
|
71
|
+
logical: !!side && !sides.includes(side),
|
|
72
|
+
slots: !side ? logicalSides : /^(block|inline)$/.test(side) ? [`${side}-start`, `${side}-end`] : [side],
|
|
73
|
+
whole: !side,
|
|
74
|
+
fields: border[2] ? [border[2]] : ["color", "style", "width"],
|
|
75
|
+
};
|
|
48
76
|
}
|
|
49
77
|
const corner = /^border-(?:(top-left|top-right|bottom-left|bottom-right|start-start|start-end|end-start|end-end)-)?radius$/.exec(property);
|
|
50
78
|
if (corner) return { family: "radius", logical: /^(start|end)-/.test(corner[1] ?? ""), whole: !corner[1], slots: [corner[1]] };
|
|
@@ -57,8 +85,9 @@ function footprint(property) {
|
|
|
57
85
|
|
|
58
86
|
function overlaps(a, b) {
|
|
59
87
|
if (a === b || a.startsWith("--") || b.startsWith("--")) return false;
|
|
60
|
-
if ([a, b].includes("all")) return ![a, b].some(value => ["direction", "unicode-bidi"].includes(value));
|
|
61
|
-
const first = footprint(a),
|
|
88
|
+
if ([a, b].includes("all")) return ![a, b].some((value) => ["direction", "unicode-bidi"].includes(value));
|
|
89
|
+
const first = footprint(a),
|
|
90
|
+
second = footprint(b);
|
|
62
91
|
if (first && second && first.family === second.family) {
|
|
63
92
|
if (first.fields && !intersects(first.fields, second.fields)) return false;
|
|
64
93
|
return first.whole || second.whole || first.logical !== second.logical || intersects(first.slots, second.slots);
|
|
@@ -66,7 +95,7 @@ function overlaps(a, b) {
|
|
|
66
95
|
return intersects(longhands.get(a) ?? [a], longhands.get(b) ?? [b]);
|
|
67
96
|
}
|
|
68
97
|
|
|
69
|
-
const modes = ["horizontal-tb", "vertical-rl", "vertical-lr"].flatMap(mode => ["ltr", "rtl"].map(direction => ({ mode, direction })));
|
|
98
|
+
const modes = ["horizontal-tb", "vertical-rl", "vertical-lr"].flatMap((mode) => ["ltr", "rtl"].map((direction) => ({ mode, direction })));
|
|
70
99
|
function physicalSlots(property, { mode, direction }) {
|
|
71
100
|
const value = footprint(property);
|
|
72
101
|
if (!value) return null;
|
|
@@ -75,38 +104,59 @@ function physicalSlots(property, { mode, direction }) {
|
|
|
75
104
|
const axes = {
|
|
76
105
|
"block-start": horizontal ? "top" : mode === "vertical-rl" ? "right" : "left",
|
|
77
106
|
"block-end": horizontal ? "bottom" : mode === "vertical-rl" ? "left" : "right",
|
|
78
|
-
"inline-start": horizontal ? direction === "ltr" ? "left" : "right" : direction === "ltr" ? "top" : "bottom",
|
|
79
|
-
"inline-end": horizontal ? direction === "ltr" ? "right" : "left" : direction === "ltr" ? "bottom" : "top",
|
|
80
|
-
"inline-size": horizontal ? "width" : "height",
|
|
81
|
-
|
|
107
|
+
"inline-start": horizontal ? (direction === "ltr" ? "left" : "right") : direction === "ltr" ? "top" : "bottom",
|
|
108
|
+
"inline-end": horizontal ? (direction === "ltr" ? "right" : "left") : direction === "ltr" ? "bottom" : "top",
|
|
109
|
+
"inline-size": horizontal ? "width" : "height",
|
|
110
|
+
"block-size": horizontal ? "height" : "width",
|
|
111
|
+
inline: horizontal ? "x" : "y",
|
|
112
|
+
block: horizontal ? "y" : "x",
|
|
82
113
|
};
|
|
83
|
-
return value.slots.map(
|
|
114
|
+
return value.slots.map((slot) =>
|
|
115
|
+
value.family === "radius" && slot
|
|
116
|
+
? (/^(start|end)-/.test(slot) ? [axes[`block-${slot.split("-")[0]}`], axes[`inline-${slot.split("-")[1]}`]] : slot.split("-")).sort().join("-")
|
|
117
|
+
: (axes[slot] ?? slot),
|
|
118
|
+
);
|
|
84
119
|
}
|
|
85
120
|
function writingModeDependent(a, b) {
|
|
86
|
-
const first = footprint(a),
|
|
121
|
+
const first = footprint(a),
|
|
122
|
+
second = footprint(b);
|
|
87
123
|
if (!first || !second || first.family !== second.family || first.whole || second.whole || first.logical === second.logical) return false;
|
|
88
|
-
const matches = modes.map(mode => intersects(physicalSlots(a, mode), physicalSlots(b, mode)));
|
|
124
|
+
const matches = modes.map((mode) => intersects(physicalSlots(a, mode), physicalSlots(b, mode)));
|
|
89
125
|
return matches.some(Boolean) && !matches.every(Boolean);
|
|
90
126
|
}
|
|
91
127
|
function words(value) {
|
|
92
128
|
const nodes = valueParser(value).nodes;
|
|
93
|
-
return nodes.every(node => ["word", "space", "comment"].includes(node.type))
|
|
129
|
+
return nodes.every((node) => ["word", "space", "comment"].includes(node.type))
|
|
130
|
+
? nodes.filter((node) => node.type === "word").map((node) => node.value.toLowerCase())
|
|
131
|
+
: null;
|
|
94
132
|
}
|
|
95
133
|
function boxValues(entry, mode) {
|
|
96
|
-
const value = footprint(entry.property),
|
|
97
|
-
|
|
134
|
+
const value = footprint(entry.property),
|
|
135
|
+
parts = words(entry.value);
|
|
136
|
+
if (
|
|
137
|
+
!value ||
|
|
138
|
+
!["padding", "margin", "scroll-padding", "scroll-margin", "inset"].includes(value.family) ||
|
|
139
|
+
!parts?.length ||
|
|
140
|
+
parts.length > 4 ||
|
|
141
|
+
parts.some((part) => ["inherit", "initial", "unset", "revert", "revert-layer"].includes(part))
|
|
142
|
+
)
|
|
143
|
+
return null;
|
|
98
144
|
const slots = physicalSlots(entry.property, mode);
|
|
99
145
|
if (!value.whole && parts.length > slots.length) return null;
|
|
100
|
-
const expanded = value.whole
|
|
146
|
+
const expanded = value.whole
|
|
147
|
+
? [parts[0], parts[1] ?? parts[0], parts[2] ?? parts[0], parts[3] ?? parts[1] ?? parts[0]]
|
|
148
|
+
: slots.map((_slot, index) => parts[index] ?? parts[0]);
|
|
101
149
|
return new Map(slots.map((slot, index) => [slot, expanded[index]]));
|
|
102
150
|
}
|
|
103
151
|
function equivalent(a, b) {
|
|
104
152
|
// Only suppress values whose overlap can be established from literal source.
|
|
105
153
|
// var(), calc(), inheritance and token aliases still need rendered review.
|
|
106
|
-
const first = footprint(a.property),
|
|
154
|
+
const first = footprint(a.property),
|
|
155
|
+
second = footprint(b.property);
|
|
107
156
|
if (first && second && first.family === second.family && ["padding", "margin", "scroll-padding", "scroll-margin", "inset"].includes(first.family)) {
|
|
108
|
-
return modes.every(mode => {
|
|
109
|
-
const left = boxValues(a, mode),
|
|
157
|
+
return modes.every((mode) => {
|
|
158
|
+
const left = boxValues(a, mode),
|
|
159
|
+
right = boxValues(b, mode);
|
|
110
160
|
return left && right && [...left].every(([slot, value]) => !right.has(slot) || right.get(slot) === value);
|
|
111
161
|
});
|
|
112
162
|
}
|
|
@@ -114,103 +164,174 @@ function equivalent(a, b) {
|
|
|
114
164
|
const field = flex === a ? b : a;
|
|
115
165
|
if (flex && ["flex-grow", "flex-shrink", "flex-basis"].includes(field.property)) {
|
|
116
166
|
const parts = words(flex.value);
|
|
117
|
-
return
|
|
167
|
+
return (
|
|
168
|
+
parts?.length === 3 &&
|
|
169
|
+
/^\d+(?:\.\d+)?$/.test(parts[0]) &&
|
|
170
|
+
/^\d+(?:\.\d+)?$/.test(parts[1]) &&
|
|
171
|
+
/^(?:auto|0|\d+(?:\.\d+)?(?:px|rem|em|%))$/.test(parts[2]) &&
|
|
172
|
+
parts[["flex-grow", "flex-shrink", "flex-basis"].indexOf(field.property)] === field.value.trim().toLowerCase()
|
|
173
|
+
);
|
|
118
174
|
}
|
|
119
175
|
return false;
|
|
120
176
|
}
|
|
121
177
|
|
|
122
178
|
function valueModeDependent(a, b) {
|
|
123
|
-
const equal = modes.map(mode => {
|
|
124
|
-
const left = boxValues(a, mode),
|
|
179
|
+
const equal = modes.map((mode) => {
|
|
180
|
+
const left = boxValues(a, mode),
|
|
181
|
+
right = boxValues(b, mode);
|
|
125
182
|
return left && right ? [...left].every(([slot, value]) => !right.has(slot) || right.get(slot) === value) : null;
|
|
126
183
|
});
|
|
127
184
|
return !equal.includes(null) && equal.some(Boolean) && !equal.every(Boolean);
|
|
128
185
|
}
|
|
129
186
|
|
|
130
187
|
function unwrap(node) {
|
|
131
|
-
while (node && (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node)))
|
|
188
|
+
while (node && (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node)))
|
|
189
|
+
node = node.expression;
|
|
132
190
|
return node;
|
|
133
191
|
}
|
|
134
192
|
|
|
135
193
|
/** Review only: valid CSS can intentionally overlap. Never rewrite project CSS. */
|
|
136
194
|
export function createAtomicCompositionReview(program, options) {
|
|
137
|
-
const checker = program.getTypeChecker(),
|
|
138
|
-
|
|
195
|
+
const checker = program.getTypeChecker(),
|
|
196
|
+
templates = new Map();
|
|
197
|
+
async function imported(node, names, modules, seen = new Set()) {
|
|
139
198
|
node = unwrap(node);
|
|
140
199
|
if (!node || seen.has(node)) return false;
|
|
141
200
|
seen = new Set([...seen, node]);
|
|
142
201
|
const base = ts.isPropertyAccessExpression(node) ? node.expression : node;
|
|
143
|
-
const symbol = sourceSymbol(checker, base);
|
|
202
|
+
const symbol = await sourceSymbol(checker, base);
|
|
144
203
|
for (const item of symbol?.declarations ?? []) {
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
204
|
+
if (
|
|
205
|
+
ts.isImportSpecifier(item) &&
|
|
206
|
+
names.includes((item.propertyName ?? item.name).text) &&
|
|
207
|
+
modules.includes(item.parent.parent.parent.moduleSpecifier.text)
|
|
208
|
+
)
|
|
209
|
+
return true;
|
|
210
|
+
if (
|
|
211
|
+
ts.isNamespaceImport(item) &&
|
|
212
|
+
ts.isPropertyAccessExpression(node) &&
|
|
213
|
+
names.includes(node.name.text) &&
|
|
214
|
+
modules.includes(item.parent.parent.moduleSpecifier.text)
|
|
215
|
+
)
|
|
216
|
+
return true;
|
|
217
|
+
if (ts.isVariableDeclaration(item) && (await imported(item.initializer, names, modules, seen))) return true;
|
|
148
218
|
}
|
|
149
219
|
return false;
|
|
150
220
|
}
|
|
151
|
-
const isCx = node => imported(node, ["cx"], ["@linaria/atomic", "@linaria/core"]);
|
|
152
|
-
function isAtomic(tag) {
|
|
221
|
+
const isCx = async (node) => imported(node, ["cx"], ["@linaria/atomic", "@linaria/core"]);
|
|
222
|
+
async function isAtomic(tag) {
|
|
153
223
|
if (ts.isCallExpression(tag)) tag = tag.expression;
|
|
154
|
-
if (imported(tag, ["css", "styled"], ["@linaria/atomic"])) return true;
|
|
155
|
-
return ts.isPropertyAccessExpression(tag) && imported(tag.expression, ["styled"], ["@linaria/atomic"]);
|
|
224
|
+
if (await imported(tag, ["css", "styled"], ["@linaria/atomic"])) return true;
|
|
225
|
+
return ts.isPropertyAccessExpression(tag) && (await imported(tag.expression, ["styled"], ["@linaria/atomic"]));
|
|
156
226
|
}
|
|
157
227
|
function entries(node) {
|
|
158
228
|
if (templates.has(node)) return templates.get(node);
|
|
159
229
|
const result = [];
|
|
160
230
|
templates.set(node, result);
|
|
161
|
-
const source = node.getSourceFile(),
|
|
162
|
-
|
|
231
|
+
const source = node.getSourceFile(),
|
|
232
|
+
template = node.template;
|
|
233
|
+
const text = ts.isNoSubstitutionTemplateLiteral(template)
|
|
234
|
+
? template.text
|
|
235
|
+
: template.head.text +
|
|
236
|
+
template.templateSpans
|
|
237
|
+
.map((span) => `__ads_expression__${"\n".repeat(span.expression.getText(source).split("\n").length - 1)}${span.literal.text}`)
|
|
238
|
+
.join("");
|
|
163
239
|
const position = source.getLineAndCharacterOfPosition(template.getStart(source) + 1);
|
|
164
240
|
try {
|
|
165
|
-
postcss.parse(text).walkDecls(decl => {
|
|
166
|
-
const selectors = [],
|
|
241
|
+
postcss.parse(text).walkDecls((decl) => {
|
|
242
|
+
const selectors = [],
|
|
243
|
+
conditions = [];
|
|
167
244
|
for (let parent = decl.parent; parent?.type !== "root"; parent = parent?.parent) {
|
|
168
245
|
if (!parent) break;
|
|
169
246
|
if (parent.type === "rule") selectors.unshift(parent.selector.trim().replace(/\s+/g, " "));
|
|
170
247
|
if (parent.type === "atrule") conditions.unshift(`${parent.name} ${parent.params}`.trim().replace(/\s+/g, " "));
|
|
171
248
|
}
|
|
172
249
|
// Animation frames describe different instants, not combined classes.
|
|
173
|
-
if (conditions.some(condition => /^(?:(?:-\w+-)?keyframes|property)\b/.test(condition))) return;
|
|
174
|
-
result.push({
|
|
175
|
-
|
|
250
|
+
if (conditions.some((condition) => /^(?:(?:-\w+-)?keyframes|property)\b/.test(condition))) return;
|
|
251
|
+
result.push({
|
|
252
|
+
property: decl.prop.toLowerCase(),
|
|
253
|
+
value: decl.value,
|
|
254
|
+
important: !!decl.important,
|
|
255
|
+
selectors: JSON.stringify(selectors),
|
|
256
|
+
conditions: JSON.stringify(conditions),
|
|
257
|
+
file: path.relative(options.root, source.fileName).replaceAll("\\", "/"),
|
|
258
|
+
line: position.line + decl.source.start.line,
|
|
259
|
+
column: decl.source.start.column + (decl.source.start.line === 1 ? position.character : 0),
|
|
260
|
+
});
|
|
176
261
|
});
|
|
177
|
-
} catch {
|
|
262
|
+
} catch {
|
|
263
|
+
/* The core CSS syntax diagnostic owns malformed templates. */
|
|
264
|
+
}
|
|
178
265
|
return result;
|
|
179
266
|
}
|
|
180
267
|
const trace = createAtomicTrace(program, options, { entries, isAtomic, isCx });
|
|
181
|
-
return source => {
|
|
182
|
-
const warnings = new Map(),
|
|
183
|
-
|
|
268
|
+
return async (source) => {
|
|
269
|
+
const warnings = new Map(),
|
|
270
|
+
limits = new Map();
|
|
271
|
+
const relative = (entry) => ({ ...entry, file: path.relative(options.root, entry.file).replaceAll("\\", "/") });
|
|
184
272
|
function compare(first, second, location, context = {}) {
|
|
185
|
-
for (const a of first)
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
273
|
+
for (const a of first)
|
|
274
|
+
for (const b of second) {
|
|
275
|
+
if (
|
|
276
|
+
a === b ||
|
|
277
|
+
a.selectors !== b.selectors ||
|
|
278
|
+
a.conditions !== b.conditions ||
|
|
279
|
+
a.important !== b.important ||
|
|
280
|
+
!overlaps(a.property, b.property) ||
|
|
281
|
+
equivalent(a, b)
|
|
282
|
+
)
|
|
283
|
+
continue;
|
|
284
|
+
const key = JSON.stringify([a, b].map((entry) => [entry.file, entry.line, entry.column]).sort());
|
|
285
|
+
const composition = [
|
|
286
|
+
...new Map([...(context.path ?? []), ...(a.via ?? []), ...(b.via ?? [])].map((entry) => [JSON.stringify(entry), relative(entry)])).values(),
|
|
287
|
+
].slice(0, 16);
|
|
288
|
+
const previous = warnings.get(key);
|
|
289
|
+
if (previous && (previous.target || !context.target) && previous.composition.length >= composition.length) continue;
|
|
290
|
+
const position = source.getLineAndCharacterOfPosition(location.getStart(source));
|
|
291
|
+
const dependent = writingModeDependent(a.property, b.property) || valueModeDependent(a, b);
|
|
292
|
+
warnings.set(key, {
|
|
293
|
+
rule: "atomic-composition-review",
|
|
294
|
+
severity: findingSeverity("atomic-composition-review"),
|
|
295
|
+
line: position.line + 1,
|
|
296
|
+
column: position.character + 1,
|
|
297
|
+
message: `Atomic declarations ${a.property}: ${previewValue(a.value)} and ${b.property}: ${previewValue(b.value)} may overlap without matching cx merge keys.${context.target ? ` Source tracing reaches the same <${context.target.name}> className.` : " This is a source composition risk, not a confirmed rendered conflict."}${dependent ? " The overlap depends on writing mode or direction." : ""} Their winner can depend on extraction order, specificity or writing mode. Use consistent property names/granularity across the base and variants, compose with Linaria cx, and verify computed styles in the built preview. Review all affected variants; valid tokens do not establish cascade correctness. See ${atomicStyleGuide}.`,
|
|
298
|
+
guidanceUri: atomicStyleGuide,
|
|
299
|
+
writingModeDependent: dependent,
|
|
300
|
+
composition,
|
|
301
|
+
...(context.target ? { target: relative(context.target) } : {}),
|
|
302
|
+
...(context.limits?.length ? { analysisLimits: [...new Set(context.limits)].slice(0, 5) } : {}),
|
|
303
|
+
related: [a, b].map(({ selectors: _selectors, conditions: _conditions, important: _important, via: _via, ...entry }) => ({
|
|
304
|
+
...entry,
|
|
305
|
+
value: previewValue(entry.value),
|
|
306
|
+
})),
|
|
307
|
+
});
|
|
308
|
+
}
|
|
198
309
|
}
|
|
199
310
|
function limit(node, reasons, composition) {
|
|
200
311
|
const key = reasons.join("\n");
|
|
201
312
|
if (limits.has(key) || limits.size >= 5) return;
|
|
202
313
|
const position = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
203
|
-
limits.set(key, {
|
|
204
|
-
|
|
314
|
+
limits.set(key, {
|
|
315
|
+
rule: "atomic-composition-limit",
|
|
316
|
+
severity: findingSeverity("atomic-composition-limit"),
|
|
317
|
+
line: position.line + 1,
|
|
318
|
+
column: position.character + 1,
|
|
319
|
+
message: `Atomic source review is incomplete: ${[...new Set(reasons)].slice(0, 3).join(" ")} Review the actual DOM classes and computed styles in a built scenario. An unresolved path is not evidence that composition is safe. See ${atomicStyleGuide}.`,
|
|
320
|
+
guidanceUri: atomicStyleGuide,
|
|
321
|
+
composition: composition.slice(0, 16).map(relative),
|
|
322
|
+
});
|
|
205
323
|
}
|
|
206
|
-
function visit(node) {
|
|
207
|
-
if (ts.isTaggedTemplateExpression(node) && isAtomic(node.tag)) {
|
|
324
|
+
async function visit(node) {
|
|
325
|
+
if (ts.isTaggedTemplateExpression(node) && (await isAtomic(node.tag))) {
|
|
208
326
|
const declarations = entries(node);
|
|
209
327
|
for (let index = 0; index < declarations.length; index++) compare([declarations[index]], declarations.slice(index + 1), node);
|
|
210
328
|
}
|
|
211
|
-
|
|
329
|
+
await eachChild(node, visit);
|
|
330
|
+
}
|
|
331
|
+
if (isInside(options.dsRoot, source.fileName)) {
|
|
332
|
+
await visit(source);
|
|
333
|
+
await trace(source, { compare, limit });
|
|
212
334
|
}
|
|
213
|
-
if (isInside(options.dsRoot, source.fileName)) { visit(source); trace(source, { compare, limit }); }
|
|
214
335
|
return [...warnings.values(), ...limits.values()];
|
|
215
336
|
};
|
|
216
337
|
}
|
package/dist/atomic-trace.mjs
CHANGED
|
@@ -1,39 +1,65 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { eachChild, flatMapAsync, mapAsync, someAsync } from "./analysis/queries.mjs";
|
|
2
|
+
import ts from "./analysis/syntax.mjs";
|
|
2
3
|
import { createSourceValues, reference, literal, unknown, isFunction } from "./source-values.mjs";
|
|
3
4
|
|
|
4
5
|
/** Bounded symbolic composition review, sharing source evaluation with scenarios. */
|
|
5
6
|
export function createAtomicTrace(program, options, { entries, isAtomic, isCx }) {
|
|
6
7
|
const { state, next, at, resolve, get, arrays, returns } = createSourceValues(program, options, { preserveCall: isCx });
|
|
7
|
-
return function review(source, { compare, limit }) {
|
|
8
|
+
return async function review(source, { compare, limit }) {
|
|
8
9
|
const maxBranches = 32;
|
|
9
|
-
const unique =
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const unique = (branches) => [
|
|
11
|
+
...new Map(branches.map((branch) => [JSON.stringify(branch.map((entry) => [entry.file, entry.line, entry.column])), branch])).values(),
|
|
12
|
+
];
|
|
13
|
+
async function styles(input, context) {
|
|
14
|
+
const value = await resolve(input, next(context));
|
|
12
15
|
context = value.context ?? input.context ?? context;
|
|
13
16
|
if (value.kind === "unknown") return { branches: [[]], limits: value.reason ? [value.reason] : [] };
|
|
14
17
|
if (value.kind === "union") {
|
|
15
|
-
const results = value.values.slice(0, maxBranches)
|
|
16
|
-
const branches = unique(results.flatMap(item => item.branches));
|
|
17
|
-
return {
|
|
18
|
+
const results = await mapAsync(value.values.slice(0, maxBranches), async (item) => styles(item, next(context)));
|
|
19
|
+
const branches = unique(results.flatMap((item) => item.branches));
|
|
20
|
+
return {
|
|
21
|
+
branches: branches.slice(0, maxBranches),
|
|
22
|
+
limits: [
|
|
23
|
+
...results.flatMap((item) => item.limits),
|
|
24
|
+
...(value.values.length > maxBranches || branches.length > maxBranches ? ["Atomic source tracing reached its alternative limit."] : []),
|
|
25
|
+
],
|
|
26
|
+
};
|
|
18
27
|
}
|
|
19
28
|
if (value.kind !== "node") return { branches: [[]], limits: [] };
|
|
20
29
|
const { node, env, via } = value;
|
|
21
|
-
if (ts.isTaggedTemplateExpression(node) && isAtomic(node.tag))
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
if (ts.isTaggedTemplateExpression(node) && (await isAtomic(node.tag)))
|
|
31
|
+
return { branches: [entries(node).map((entry) => ({ ...entry, via }))], limits: [] };
|
|
32
|
+
if (ts.isCallExpression(node) && (await isCx(node.expression))) {
|
|
33
|
+
const inputs = await flatMapAsync(node.arguments, async (argument) =>
|
|
34
|
+
ts.isSpreadElement(argument)
|
|
35
|
+
? ((await arrays(reference(argument.expression, env, via), context)) ?? [unknown("A dynamic class argument spread could not be traced.")])
|
|
36
|
+
: [reference(argument, env, via)],
|
|
37
|
+
);
|
|
38
|
+
let branches = [[]];
|
|
39
|
+
const limits = [];
|
|
25
40
|
for (const argument of inputs) {
|
|
26
|
-
const result = styles(argument, next(context));
|
|
41
|
+
const result = await styles(argument, next(context));
|
|
27
42
|
limits.push(...result.limits);
|
|
28
|
-
const combined = new Map();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
const combined = new Map();
|
|
44
|
+
let truncated = false;
|
|
45
|
+
for (const first of branches)
|
|
46
|
+
for (const second of result.branches) {
|
|
47
|
+
// cx replaces exact property/selector/condition keys; shorthand
|
|
48
|
+
// expansion remains the CSS overlap review's responsibility.
|
|
49
|
+
const merged = new Map(
|
|
50
|
+
[...first, ...second.map((entry) => ({ ...entry, via: [...via, ...(entry.via ?? [])] }))].map((entry) => [
|
|
51
|
+
JSON.stringify([entry.property, entry.selectors, entry.conditions]),
|
|
52
|
+
entry,
|
|
53
|
+
]),
|
|
54
|
+
);
|
|
55
|
+
const branch = [...merged.values()],
|
|
56
|
+
key = JSON.stringify(branch.map((entry) => [entry.file, entry.line, entry.column]));
|
|
57
|
+
if (!combined.has(key) && combined.size >= maxBranches) {
|
|
58
|
+
truncated = true;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
combined.set(key, branch);
|
|
62
|
+
}
|
|
37
63
|
if (truncated) limits.push("Atomic source tracing reached its alternative limit.");
|
|
38
64
|
branches = [...combined.values()];
|
|
39
65
|
}
|
|
@@ -41,52 +67,96 @@ export function createAtomicTrace(program, options, { entries, isAtomic, isCx })
|
|
|
41
67
|
}
|
|
42
68
|
return { branches: [[]], limits: [] };
|
|
43
69
|
}
|
|
44
|
-
function inspect(value, node, context, target, path = []) {
|
|
45
|
-
const result = styles(value, context);
|
|
46
|
-
for (const branch of result.branches)
|
|
47
|
-
|
|
70
|
+
async function inspect(value, node, context, target, path = []) {
|
|
71
|
+
const result = await styles(value, context);
|
|
72
|
+
for (const branch of result.branches)
|
|
73
|
+
for (let index = 0; index < branch.length; index++) compare([branch[index]], branch.slice(index + 1), node, { target, path, limits: result.limits });
|
|
74
|
+
if (
|
|
75
|
+
result.limits.length &&
|
|
76
|
+
(result.branches.some((branch) => branch.length) ||
|
|
77
|
+
(ts.isCallExpression(node) &&
|
|
78
|
+
(await someAsync(node.arguments, async (argument) => (await styles(reference(argument), next(context))).branches.some((branch) => branch.length)))))
|
|
79
|
+
)
|
|
80
|
+
limit(node, result.limits, path);
|
|
48
81
|
return result;
|
|
49
82
|
}
|
|
50
83
|
function props(node, env, via) {
|
|
51
|
-
return {
|
|
84
|
+
return {
|
|
85
|
+
kind: "object",
|
|
86
|
+
layers: node.attributes.properties.map((attribute) =>
|
|
87
|
+
ts.isJsxSpreadAttribute(attribute)
|
|
88
|
+
? reference(attribute.expression, env, via)
|
|
89
|
+
: new Map([
|
|
90
|
+
[
|
|
91
|
+
attribute.name.text,
|
|
92
|
+
attribute.initializer
|
|
93
|
+
? ts.isJsxExpression(attribute.initializer)
|
|
94
|
+
? reference(attribute.initializer.expression, env, via)
|
|
95
|
+
: reference(attribute.initializer, env, via)
|
|
96
|
+
: literal(true),
|
|
97
|
+
],
|
|
98
|
+
]),
|
|
99
|
+
),
|
|
100
|
+
};
|
|
52
101
|
}
|
|
53
|
-
function render(input, location, context, path = [], pendingStyles = false) {
|
|
54
|
-
const value = resolve(input, next(context));
|
|
102
|
+
async function render(input, location, context, path = [], pendingStyles = false) {
|
|
103
|
+
const value = await resolve(input, next(context));
|
|
55
104
|
context = value.context ?? input.context ?? context;
|
|
56
|
-
if (value.kind === "union") {
|
|
57
|
-
|
|
105
|
+
if (value.kind === "union") {
|
|
106
|
+
for (const item of value.values.slice(0, maxBranches)) await render(item, location, next(context), path, pendingStyles);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (value.kind !== "node") {
|
|
110
|
+
if (value.reason && pendingStyles) limit(location, [value.reason], path);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
58
113
|
const { node, env, via } = value;
|
|
59
|
-
if (ts.isJsxExpression(node)) {
|
|
60
|
-
|
|
61
|
-
|
|
114
|
+
if (ts.isJsxExpression(node)) {
|
|
115
|
+
await render(reference(node.expression, env, via), location, next(context), path, pendingStyles);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (ts.isJsxFragment(node)) {
|
|
119
|
+
for (const child of node.children) await render(reference(child, env, via), location, next(context), path);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (ts.isArrayLiteralExpression(node)) {
|
|
123
|
+
for (const child of node.elements) await render(reference(child, env, via), location, next(context), path);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
62
126
|
if (!ts.isJsxElement(node) && !ts.isJsxSelfClosingElement(node)) return;
|
|
63
127
|
const opening = ts.isJsxElement(node) ? node.openingElement : node;
|
|
64
|
-
const attributes = props(opening, env, via),
|
|
128
|
+
const attributes = props(opening, env, via),
|
|
129
|
+
classValue = await get(attributes, "className", next(context));
|
|
65
130
|
const tag = opening.tagName.getText();
|
|
66
131
|
if (/^[a-z]/.test(tag) && !tag.includes(".")) {
|
|
67
|
-
inspect(classValue, location, context, at(opening, "element", tag), [...path, ...via]);
|
|
68
|
-
if (ts.isJsxElement(node)) for (const child of node.children) render(reference(child, env, via), location, next(context), path);
|
|
132
|
+
await inspect(classValue, location, context, at(opening, "element", tag), [...path, ...via]);
|
|
133
|
+
if (ts.isJsxElement(node)) for (const child of node.children) await render(reference(child, env, via), location, next(context), path);
|
|
69
134
|
return;
|
|
70
135
|
}
|
|
71
|
-
function componentTarget(component) {
|
|
72
|
-
if (component.kind === "union") {
|
|
136
|
+
async function componentTarget(component) {
|
|
137
|
+
if (component.kind === "union") {
|
|
138
|
+
for (const alternative of component.values.slice(0, maxBranches)) await componentTarget(await resolve(alternative, next(context)));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
73
141
|
if (component.kind === "literal" && typeof component.value === "string") {
|
|
74
|
-
inspect(classValue, location, context, at(opening, "element", component.value), [...path, ...via]);
|
|
142
|
+
await inspect(classValue, location, context, at(opening, "element", component.value), [...path, ...via]);
|
|
75
143
|
} else if (component.kind === "node" && isFunction(component.node)) {
|
|
76
|
-
const passed = pendingStyles || styles(classValue, context).branches.some(branch => branch.length);
|
|
77
|
-
for (const output of returns(component, [attributes], next(context), "component"))
|
|
144
|
+
const passed = pendingStyles || (await styles(classValue, context)).branches.some((branch) => branch.length);
|
|
145
|
+
for (const output of await returns(component, [attributes], next(context), "component"))
|
|
146
|
+
await render(output, location, output.context ?? next(context), [...path, at(opening, "component", tag)], passed);
|
|
78
147
|
} else {
|
|
79
|
-
const passed = styles(classValue, context);
|
|
80
|
-
if (passed.branches.some(branch => branch.length))
|
|
148
|
+
const passed = await styles(classValue, context);
|
|
149
|
+
if (passed.branches.some((branch) => branch.length))
|
|
150
|
+
limit(location, [`Component ${tag.slice(0, 80)} could not be traced to its DOM className target.`, ...passed.limits], path);
|
|
81
151
|
}
|
|
82
152
|
}
|
|
83
|
-
componentTarget(resolve(reference(opening.tagName, env, via), next(context)));
|
|
153
|
+
await componentTarget(await resolve(reference(opening.tagName, env, via), next(context)));
|
|
84
154
|
}
|
|
85
|
-
function visit(node) {
|
|
86
|
-
if (ts.isCallExpression(node)) inspect(reference(node), node, state());
|
|
87
|
-
if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) render(reference(node), node, state());
|
|
88
|
-
|
|
155
|
+
async function visit(node) {
|
|
156
|
+
if (ts.isCallExpression(node)) await inspect(reference(node), node, state());
|
|
157
|
+
if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) await render(reference(node), node, state());
|
|
158
|
+
await eachChild(node, visit);
|
|
89
159
|
}
|
|
90
|
-
visit(source);
|
|
160
|
+
await visit(source);
|
|
91
161
|
};
|
|
92
162
|
}
|