@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
package/dist/themes-watch.mjs
CHANGED
|
@@ -4,45 +4,80 @@ import { loadConfig } from "./config.mjs";
|
|
|
4
4
|
import { inspectTokens } from "./tokens.mjs";
|
|
5
5
|
import { generatedThemeFiles, generatedThemesFile, writeThemesCss } from "./themes-generated.mjs";
|
|
6
6
|
import { isExportsFile, writeGeneratedEntries } from "./generated-entries.mjs";
|
|
7
|
+
import { analyze } from "./analysis/service.mjs";
|
|
7
8
|
|
|
8
9
|
/** Rewrites the project's themes.generated.css and themes.generated.ts from its token sheets and config when stale. */
|
|
9
|
-
export function refreshThemesCss(directory) {
|
|
10
|
+
export async function refreshThemesCss(directory) {
|
|
10
11
|
const options = loadConfig(directory);
|
|
11
|
-
return { ...writeThemesCss(options, inspectTokens(directory, options)), root: options.root };
|
|
12
|
+
return { ...writeThemesCss(options, await inspectTokens(directory, options)), root: options.root };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function refreshThemesCssAsync(directory) {
|
|
16
|
+
const options = loadConfig(directory);
|
|
17
|
+
return { ...writeThemesCss(options, await analyze(options.root, "tokens")), root: options.root };
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
/** Keeps themes.generated.css and .ts current on every token sheet or config change, and the
|
|
15
21
|
* generated barrels current on every exports file change: once now, then on each change. */
|
|
16
22
|
export function watchThemesCss(directory, { log = () => {} } = {}) {
|
|
17
23
|
const watchers = [];
|
|
18
|
-
let timer
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
let timer,
|
|
25
|
+
closed = false,
|
|
26
|
+
queue = Promise.resolve();
|
|
27
|
+
const refresh = () =>
|
|
28
|
+
(queue = queue.then(async () => {
|
|
29
|
+
if (closed) return;
|
|
30
|
+
try {
|
|
31
|
+
const result = await refreshThemesCssAsync(directory);
|
|
32
|
+
for (const item of result.files ?? []) if (item.written) log(`ADS wrote ${path.relative(result.root, item.file).replaceAll("\\", "/")}`);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
log(`ADS could not write ${generatedThemesFile}: ${error.message}`);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const options = loadConfig(directory);
|
|
38
|
+
for (const item of (await writeGeneratedEntries(options)).files)
|
|
39
|
+
if (item.changed) log(`ADS wrote ${path.relative(options.root, item.file).replaceAll("\\", "/")}`);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
log(`ADS could not write the generated entries: ${error.message}`);
|
|
42
|
+
}
|
|
43
|
+
}));
|
|
44
|
+
const changed = (file) => {
|
|
30
45
|
const name = path.basename(String(file ?? ""));
|
|
31
|
-
if (generatedThemeFiles.some(generated => name === generated || name.startsWith(`${generated}.`))) return;
|
|
46
|
+
if (generatedThemeFiles.some((generated) => name === generated || name.startsWith(`${generated}.`))) return;
|
|
32
47
|
clearTimeout(timer);
|
|
33
48
|
timer = setTimeout(refresh, 50);
|
|
34
49
|
timer.unref?.();
|
|
35
50
|
};
|
|
36
|
-
refresh();
|
|
51
|
+
const ready = refresh();
|
|
37
52
|
try {
|
|
38
53
|
const { root, dsRoot, config } = loadConfig(directory);
|
|
39
|
-
for (const [folder, filter] of [
|
|
54
|
+
for (const [folder, filter] of [
|
|
55
|
+
[path.join(dsRoot, config.tokenDir), (file) => String(file).endsWith(".css")],
|
|
56
|
+
[root, (file) => String(file) === "ds.config.json"],
|
|
57
|
+
[dsRoot, (file) => isExportsFile(String(file))],
|
|
58
|
+
]) {
|
|
40
59
|
try {
|
|
41
|
-
const watcher = watch(folder, { recursive: folder !== root }, (_event, file) => {
|
|
42
|
-
|
|
60
|
+
const watcher = watch(folder, { recursive: folder !== root }, (_event, file) => {
|
|
61
|
+
if (file && filter(file)) changed(file);
|
|
62
|
+
});
|
|
63
|
+
watcher.unref();
|
|
64
|
+
watcher.on("error", () => watcher.close());
|
|
43
65
|
watchers.push(watcher);
|
|
44
|
-
} catch {
|
|
66
|
+
} catch {
|
|
67
|
+
/* A missing token folder has nothing to generate from. */
|
|
68
|
+
}
|
|
45
69
|
}
|
|
46
|
-
} catch {
|
|
47
|
-
|
|
70
|
+
} catch {
|
|
71
|
+
/* An invalid configuration is reported by the server itself. */
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
ready,
|
|
75
|
+
refresh,
|
|
76
|
+
async close() {
|
|
77
|
+
closed = true;
|
|
78
|
+
clearTimeout(timer);
|
|
79
|
+
for (const watcher of watchers) watcher.close();
|
|
80
|
+
await queue;
|
|
81
|
+
},
|
|
82
|
+
};
|
|
48
83
|
}
|
package/dist/themes.mjs
CHANGED
|
@@ -9,7 +9,10 @@ import { findingSeverity } from "./finding-rules.mjs";
|
|
|
9
9
|
// and a resolver that picks the active theme's half on every themed or branded element, so
|
|
10
10
|
// themes and brands nest at any depth, each following its nearest ancestor.
|
|
11
11
|
|
|
12
|
-
export const defaultThemes = [
|
|
12
|
+
export const defaultThemes = [
|
|
13
|
+
{ name: "light", scheme: "light" },
|
|
14
|
+
{ name: "dark", scheme: "dark" },
|
|
15
|
+
];
|
|
13
16
|
|
|
14
17
|
export function validateThemes(themes) {
|
|
15
18
|
if (!Array.isArray(themes) || !themes.length || themes.length > 8) throw new Error("themes must list 1–8 themes; the first is the default.");
|
|
@@ -17,18 +20,20 @@ export function validateThemes(themes) {
|
|
|
17
20
|
for (const [index, theme] of themes.entries()) {
|
|
18
21
|
const field = `themes[${index}]`;
|
|
19
22
|
if (!theme || typeof theme !== "object" || Array.isArray(theme)) throw new Error(`${field} must be an object with name and scheme.`);
|
|
20
|
-
const unknown = Object.keys(theme).filter(key => !["name", "scheme"].includes(key));
|
|
23
|
+
const unknown = Object.keys(theme).filter((key) => !["name", "scheme"].includes(key));
|
|
21
24
|
if (unknown.length) throw new Error(`${field} has unknown keys: ${unknown.join(", ")}.`);
|
|
22
|
-
if (typeof theme.name !== "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(theme.name))
|
|
23
|
-
|
|
25
|
+
if (typeof theme.name !== "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(theme.name))
|
|
26
|
+
throw new Error(`${field}.name must be a lowercase name such as "dark" or "high-contrast".`);
|
|
27
|
+
if (!["light", "dark"].includes(theme.scheme))
|
|
28
|
+
throw new Error(`${field}.scheme must be "light" or "dark": the color scheme browsers use for native controls.`);
|
|
24
29
|
if (names.has(theme.name)) throw new Error(`Theme "${theme.name}" is declared twice.`);
|
|
25
30
|
names.add(theme.name);
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
const cache = new Map();
|
|
30
|
-
const rootNode = node => node.type === "pseudo" && node.value.toLowerCase() === ":root" || node.type === "tag" && node.value.toLowerCase() === "html";
|
|
31
|
-
const unquote = value => value.replace(/^["']|["']$/g, "");
|
|
35
|
+
const rootNode = (node) => (node.type === "pseudo" && node.value.toLowerCase() === ":root") || (node.type === "tag" && node.value.toLowerCase() === "html");
|
|
36
|
+
const unquote = (value) => value.replace(/^["']|["']$/g, "");
|
|
32
37
|
|
|
33
38
|
/** Where a token declaration applies: the default brand ({ kind: "root" }: :root or html, or the
|
|
34
39
|
* default brand's [data-brand]), one brand ({ kind: "brand", brand }), the old theme form
|
|
@@ -42,9 +47,10 @@ export function classifyScope(scope, defaultBrand) {
|
|
|
42
47
|
else if (scope.includes("@") || scope.includes(" > ")) result = { kind: "conditional" };
|
|
43
48
|
else {
|
|
44
49
|
try {
|
|
45
|
-
let old = false,
|
|
50
|
+
let old = false,
|
|
51
|
+
other = false;
|
|
46
52
|
const brands = [];
|
|
47
|
-
selectorParser(root => {
|
|
53
|
+
selectorParser((root) => {
|
|
48
54
|
for (const selector of root.nodes) {
|
|
49
55
|
let brand = null;
|
|
50
56
|
for (const node of selector.nodes) {
|
|
@@ -60,15 +66,24 @@ export function classifyScope(scope, defaultBrand) {
|
|
|
60
66
|
brands.push(brand === defaultBrand ? null : brand);
|
|
61
67
|
}
|
|
62
68
|
}).processSync(scope);
|
|
63
|
-
result = old
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
result = old
|
|
70
|
+
? { kind: "old" }
|
|
71
|
+
: other
|
|
72
|
+
? { kind: "conditional" }
|
|
73
|
+
: new Set(brands).size > 1
|
|
74
|
+
? { kind: "old" }
|
|
75
|
+
: brands[0] === null
|
|
76
|
+
? { kind: "root" }
|
|
77
|
+
: { kind: "brand", brand: brands[0] };
|
|
78
|
+
} catch {
|
|
79
|
+
result = { kind: "conditional" };
|
|
80
|
+
}
|
|
66
81
|
}
|
|
67
82
|
cache.set(key, result);
|
|
68
83
|
return result;
|
|
69
84
|
}
|
|
70
85
|
|
|
71
|
-
const plainScope = where => where.kind === "root" || where.kind === "brand";
|
|
86
|
+
const plainScope = (where) => where.kind === "root" || where.kind === "brand";
|
|
72
87
|
|
|
73
88
|
/** Token definitions from the token sheets' custom property declarations ({ prop, value, file,
|
|
74
89
|
* line, column, scope }, in source order). A name ending in a declared theme's name is a half
|
|
@@ -77,13 +92,13 @@ const plainScope = where => where.kind === "root" || where.kind === "brand";
|
|
|
77
92
|
* default brand); a half's value names other halves of its own theme by their token name, and
|
|
78
93
|
* keeps the authored text and property. */
|
|
79
94
|
export function buildTokens(declarations, { themes = defaultThemes, brands = [] } = {}) {
|
|
80
|
-
const names = themes.map(theme => theme.name).sort((a, b) => b.length - a.length);
|
|
81
|
-
const split = prop => {
|
|
95
|
+
const names = themes.map((theme) => theme.name).sort((a, b) => b.length - a.length);
|
|
96
|
+
const split = (prop) => {
|
|
82
97
|
if (themes.length < 2) return null;
|
|
83
98
|
for (const name of names) if (prop.endsWith(`-${name}`) && prop.length > name.length + 3) return { base: prop.slice(0, -name.length - 1), theme: name };
|
|
84
99
|
return null;
|
|
85
100
|
};
|
|
86
|
-
const entries = declarations.map(declaration => ({ ...declaration, where: classifyScope(declaration.scope, brands[0]?.name) }));
|
|
101
|
+
const entries = declarations.map((declaration) => ({ ...declaration, where: classifyScope(declaration.scope, brands[0]?.name) }));
|
|
87
102
|
const halves = new Map();
|
|
88
103
|
for (const entry of entries) {
|
|
89
104
|
const half = plainScope(entry.where) && split(entry.prop);
|
|
@@ -92,12 +107,15 @@ export function buildTokens(declarations, { themes = defaultThemes, brands = []
|
|
|
92
107
|
halves.get(half.base).add(half.theme);
|
|
93
108
|
}
|
|
94
109
|
const themed = new Set([...halves].filter(([, set]) => set.size > 1).map(([base]) => base));
|
|
95
|
-
const halfOf = prop => {
|
|
110
|
+
const halfOf = (prop) => {
|
|
111
|
+
const half = split(prop);
|
|
112
|
+
return half && themed.has(half.base) ? half : null;
|
|
113
|
+
};
|
|
96
114
|
const normalize = (value, theme) => {
|
|
97
115
|
const parsed = valueParser(value);
|
|
98
|
-
parsed.walk(node => {
|
|
116
|
+
parsed.walk((node) => {
|
|
99
117
|
if (node.type !== "function" || node.value !== "var") return;
|
|
100
|
-
const word = node.nodes.find(child => child.type === "word");
|
|
118
|
+
const word = node.nodes.find((child) => child.type === "word");
|
|
101
119
|
const half = word && halfOf(word.value);
|
|
102
120
|
if (half?.theme === theme) word.value = half.base;
|
|
103
121
|
});
|
|
@@ -105,32 +123,44 @@ export function buildTokens(declarations, { themes = defaultThemes, brands = []
|
|
|
105
123
|
};
|
|
106
124
|
const tokens = new Map();
|
|
107
125
|
for (const entry of entries) {
|
|
108
|
-
const half = halfOf(entry.prop),
|
|
109
|
-
|
|
110
|
-
|
|
126
|
+
const half = halfOf(entry.prop),
|
|
127
|
+
name = half ? half.base : entry.prop;
|
|
128
|
+
const definition = {
|
|
129
|
+
file: entry.file,
|
|
130
|
+
line: entry.line,
|
|
131
|
+
column: entry.column,
|
|
132
|
+
scope: entry.scope,
|
|
133
|
+
value: half ? normalize(entry.value, half.theme) : entry.value,
|
|
134
|
+
theme: half?.theme ?? null,
|
|
135
|
+
brand: entry.where.kind === "brand" ? entry.where.brand : null,
|
|
111
136
|
...(half ? { property: entry.prop, authored: entry.value } : {}),
|
|
112
|
-
...(entry.where.kind === "conditional" ? { conditional: true } : entry.where.kind === "old" ? { conditional: true, old: true } : {})
|
|
137
|
+
...(entry.where.kind === "conditional" ? { conditional: true } : entry.where.kind === "old" ? { conditional: true, old: true } : {}),
|
|
138
|
+
};
|
|
113
139
|
if (!tokens.has(name)) tokens.set(name, []);
|
|
114
140
|
tokens.get(name).push(definition);
|
|
115
141
|
}
|
|
116
|
-
return [...tokens]
|
|
142
|
+
return [...tokens]
|
|
143
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
144
|
+
.map(([name, definitions]) => ({ name, ...(themed.has(name) ? { themed: true } : {}), definitions }));
|
|
117
145
|
}
|
|
118
146
|
|
|
119
|
-
const applies = definition => !definition.conditional;
|
|
147
|
+
const applies = (definition) => !definition.conditional;
|
|
120
148
|
|
|
121
149
|
/** A token's definition where a theme and a brand apply: the brand's own one, else the default
|
|
122
150
|
* brand's; within a brand the theme's half, else the single value. Undefined brand = default. */
|
|
123
151
|
export function contextDefinition(token, { theme, brand } = {}) {
|
|
124
|
-
const matches = definition => applies(definition) && (definition.theme === null || definition.theme === theme);
|
|
125
|
-
return (
|
|
126
|
-
|
|
152
|
+
const matches = (definition) => applies(definition) && (definition.theme === null || definition.theme === theme);
|
|
153
|
+
return (
|
|
154
|
+
(brand !== undefined && brand !== null ? token.definitions.findLast((definition) => definition.brand === brand && matches(definition)) : undefined) ??
|
|
155
|
+
token.definitions.findLast((definition) => definition.brand === null && matches(definition))
|
|
156
|
+
);
|
|
127
157
|
}
|
|
128
158
|
|
|
129
159
|
/** A token's default-brand definition: its single value, else its half for the named theme
|
|
130
160
|
* (the first half when no theme is named). */
|
|
131
161
|
export function baseDefinition(token, theme) {
|
|
132
|
-
const own = token.definitions.filter(definition => applies(definition) && definition.brand === null);
|
|
133
|
-
return own.findLast(definition => definition.theme === null) ?? own.find(definition => theme === undefined || definition.theme === theme);
|
|
162
|
+
const own = token.definitions.filter((definition) => applies(definition) && definition.brand === null);
|
|
163
|
+
return own.findLast((definition) => definition.theme === null) ?? own.find((definition) => theme === undefined || definition.theme === theme);
|
|
134
164
|
}
|
|
135
165
|
|
|
136
166
|
/** A token's default-brand definition in one theme. */
|
|
@@ -161,78 +191,144 @@ export function resolveValue(values, name, seen = new Set()) {
|
|
|
161
191
|
return values.has(reference[1]) ? resolveValue(values, reference[1], new Set([...seen, name])) : reference[2]?.trim() || null;
|
|
162
192
|
}
|
|
163
193
|
|
|
164
|
-
export const referencedTokens = value => {
|
|
194
|
+
export const referencedTokens = (value) => {
|
|
165
195
|
const names = [];
|
|
166
|
-
valueParser(value).walk(
|
|
196
|
+
valueParser(value).walk((node) => {
|
|
197
|
+
if (node.type === "function" && node.value === "var") {
|
|
198
|
+
const word = node.nodes.find((child) => child.type === "word");
|
|
199
|
+
if (word?.value.startsWith("--")) names.push(word.value);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
167
202
|
return names;
|
|
168
203
|
};
|
|
169
204
|
|
|
170
205
|
/** Tokens that follow the theme: themed tokens and every default single value that refers to
|
|
171
206
|
* one, directly or through other tokens. The generated resolver re-resolves them per element. */
|
|
172
207
|
export function themeDependents(tokens) {
|
|
173
|
-
const dependent = new Set(tokens.filter(token => token.themed).map(token => token.name));
|
|
174
|
-
for (let changed = true; changed;) {
|
|
208
|
+
const dependent = new Set(tokens.filter((token) => token.themed).map((token) => token.name));
|
|
209
|
+
for (let changed = true; changed; ) {
|
|
175
210
|
changed = false;
|
|
176
211
|
for (const token of tokens) {
|
|
177
212
|
if (dependent.has(token.name)) continue;
|
|
178
213
|
const base = baseDefinition(token);
|
|
179
|
-
if (base && base.theme === null && referencedTokens(base.value).some(name => dependent.has(name))) {
|
|
214
|
+
if (base && base.theme === null && referencedTokens(base.value).some((name) => dependent.has(name))) {
|
|
215
|
+
dependent.add(token.name);
|
|
216
|
+
changed = true;
|
|
217
|
+
}
|
|
180
218
|
}
|
|
181
219
|
}
|
|
182
220
|
return dependent;
|
|
183
221
|
}
|
|
184
222
|
|
|
185
|
-
export const nameList = names => names.length === 1 ? names[0] : `${names.length} tokens (${names.slice(0, 3).join(", ")}${names.length > 3 ? ", …" : ""})
|
|
223
|
+
export const nameList = (names) => (names.length === 1 ? names[0] : `${names.length} tokens (${names.slice(0, 3).join(", ")}${names.length > 3 ? ", …" : ""})`);
|
|
186
224
|
|
|
187
225
|
/** The theme form: old [data-theme] value blocks are errors; a themed token has a default half
|
|
188
226
|
* for every declared theme, only halves, and halves that refer to other halves. */
|
|
189
227
|
export function themeFindings(tokens, themes, { dsDir } = {}) {
|
|
190
|
-
const diagnostics = [],
|
|
191
|
-
|
|
192
|
-
const
|
|
228
|
+
const diagnostics = [],
|
|
229
|
+
advisories = [];
|
|
230
|
+
const error = (rule, at, message, names) =>
|
|
231
|
+
diagnostics.push({ rule, file: at.file, line: at.line, column: at.column, ...(names ? { tokens: names } : {}), message });
|
|
232
|
+
const finding = (rule, at, message, names) =>
|
|
233
|
+
(findingSeverity(rule) === "error" ? diagnostics : advisories).push({
|
|
234
|
+
rule,
|
|
235
|
+
severity: findingSeverity(rule),
|
|
236
|
+
file: at.file,
|
|
237
|
+
line: at.line,
|
|
238
|
+
column: at.column,
|
|
239
|
+
...(names ? { tokens: names } : {}),
|
|
240
|
+
guidanceUri: "ads://guides/tokens",
|
|
241
|
+
message,
|
|
242
|
+
});
|
|
193
243
|
// One finding per old rule, naming what it sets.
|
|
194
244
|
const old = new Map();
|
|
195
|
-
for (const token of tokens)
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
245
|
+
for (const token of tokens)
|
|
246
|
+
for (const definition of token.definitions.filter((definition) => definition.old)) {
|
|
247
|
+
const key = `${definition.file}\0${definition.scope}`;
|
|
248
|
+
if (!old.has(key)) old.set(key, { at: definition, names: [] });
|
|
249
|
+
old.get(key).names.push(token.name);
|
|
250
|
+
}
|
|
200
251
|
for (const { at, names } of [...old.values()].sort((a, b) => a.at.file.localeCompare(b.at.file) || a.at.line - b.at.line)) {
|
|
201
|
-
const theme =
|
|
202
|
-
|
|
252
|
+
const theme =
|
|
253
|
+
at.scope.match(/data-theme\s*=\s*["']?([\w-]+)/)?.[1] ??
|
|
254
|
+
(/prefers-color-scheme\s*:\s*dark/.test(at.scope) ? "dark" : (themes[1]?.name ?? themes[0].name));
|
|
255
|
+
error(
|
|
256
|
+
"theme-old-form",
|
|
257
|
+
at,
|
|
258
|
+
`Old theme form: ${at.scope} sets ${nameList(names)}. Write per-theme halves on :root (or [data-brand="<name>"]) instead, such as ${names[0]}-${theme}; ADS generates the theme switches.`,
|
|
259
|
+
names,
|
|
260
|
+
);
|
|
203
261
|
}
|
|
204
262
|
if (themes.length < 2) return { diagnostics, advisories };
|
|
205
263
|
const dependent = themeDependents(tokens);
|
|
206
|
-
for (const token of tokens.filter(token => token.themed)) {
|
|
207
|
-
const own = token.definitions.filter(definition => applies(definition) && definition.brand === null);
|
|
208
|
-
const single = own.find(definition => definition.theme === null);
|
|
209
|
-
if (single)
|
|
210
|
-
|
|
211
|
-
|
|
264
|
+
for (const token of tokens.filter((token) => token.themed)) {
|
|
265
|
+
const own = token.definitions.filter((definition) => applies(definition) && definition.brand === null);
|
|
266
|
+
const single = own.find((definition) => definition.theme === null);
|
|
267
|
+
if (single)
|
|
268
|
+
error(
|
|
269
|
+
"theme-half-conflict",
|
|
270
|
+
single,
|
|
271
|
+
`${token.name} is set both as one value and as per-theme halves (${token.definitions.find((definition) => definition.property)?.property}, …); keep only the halves.`,
|
|
272
|
+
[token.name],
|
|
273
|
+
);
|
|
274
|
+
const missing = own.length ? themes.filter((theme) => !own.some((definition) => definition.theme === theme.name)).map((theme) => theme.name) : [];
|
|
275
|
+
if (missing.length)
|
|
276
|
+
error(
|
|
277
|
+
"theme-coverage",
|
|
278
|
+
own.find((definition) => definition.theme !== null) ?? own[0],
|
|
279
|
+
`${token.name} has no ${missing.map((name) => `${token.name}-${name}`).join(", ")} on :root; a themed token needs a half for every declared theme, or it is unset in ${missing.join(", ")}.`,
|
|
280
|
+
[token.name],
|
|
281
|
+
);
|
|
212
282
|
}
|
|
213
283
|
// A half is resolved where it is declared, on :root or a brand: it names halves, not tokens that follow the theme.
|
|
214
|
-
const byName = new Map(tokens.map(token => [token.name, token]));
|
|
284
|
+
const byName = new Map(tokens.map((token) => [token.name, token]));
|
|
215
285
|
// The half a theme-following alias stands for: --accent → --color-accent-9 → --color-accent-9-dark.
|
|
216
286
|
const halfFor = (name, theme, seen = new Set()) => {
|
|
217
287
|
const token = byName.get(name);
|
|
218
288
|
if (token?.themed) return `${name}-${theme}`;
|
|
219
|
-
const alias =
|
|
289
|
+
const alias =
|
|
290
|
+
!seen.has(name) &&
|
|
291
|
+
baseDefinition(token ?? { definitions: [] })
|
|
292
|
+
?.value.trim()
|
|
293
|
+
.match(/^var\(\s*(--[\w-]+)\s*\)$/)?.[1];
|
|
220
294
|
return alias ? halfFor(alias, theme, new Set([...seen, name])) : null;
|
|
221
295
|
};
|
|
222
|
-
for (const token of tokens.filter(token => token.themed))
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
296
|
+
for (const token of tokens.filter((token) => token.themed))
|
|
297
|
+
for (const definition of token.definitions.filter((definition) => applies(definition) && definition.authored)) {
|
|
298
|
+
const wrong = referencedTokens(definition.authored).filter((name) => dependent.has(name));
|
|
299
|
+
if (wrong.length)
|
|
300
|
+
error(
|
|
301
|
+
"theme-half-reference",
|
|
302
|
+
definition,
|
|
303
|
+
`${definition.property} refers to ${wrong.join(", ")}, which follows the theme; a half is resolved where it is declared, so refer to ${wrong.map((name) => halfFor(name, definition.theme) ?? `halves of ${name}`).join(", ")}.`,
|
|
304
|
+
[token.name],
|
|
305
|
+
);
|
|
306
|
+
}
|
|
226
307
|
// A lone half-like name: the other themes' halves are missing, so it is a plain token.
|
|
227
|
-
const declared = new Set(tokens.map(token => token.name));
|
|
228
|
-
for (const token of tokens.filter(token => !token.themed)) {
|
|
229
|
-
const theme = themes.slice(1).find(theme => token.name.endsWith(`-${theme.name}`));
|
|
308
|
+
const declared = new Set(tokens.map((token) => token.name));
|
|
309
|
+
for (const token of tokens.filter((token) => !token.themed)) {
|
|
310
|
+
const theme = themes.slice(1).find((theme) => token.name.endsWith(`-${theme.name}`));
|
|
230
311
|
const base = theme && token.name.slice(0, -theme.name.length - 1);
|
|
231
312
|
const at = token.definitions.find(applies);
|
|
232
|
-
if (base && at && !declared.has(base))
|
|
313
|
+
if (base && at && !declared.has(base))
|
|
314
|
+
finding(
|
|
315
|
+
"theme-new-token",
|
|
316
|
+
at,
|
|
317
|
+
`${token.name} reads as the ${theme.name} half of ${base}, but no other theme gives ${base}; add ${themes
|
|
318
|
+
.filter((item) => item !== theme)
|
|
319
|
+
.map((item) => `${base}-${item.name}`)
|
|
320
|
+
.join(", ")} on :root, or rename it.`,
|
|
321
|
+
[token.name],
|
|
322
|
+
);
|
|
233
323
|
}
|
|
234
324
|
// While the old form remains, theme-old-form already names what to write.
|
|
235
|
-
if (!tokens.some(token => token.themed) && !old.size && dsDir)
|
|
325
|
+
if (!tokens.some((token) => token.themed) && !old.size && dsDir)
|
|
326
|
+
for (const theme of themes.slice(1))
|
|
327
|
+
finding(
|
|
328
|
+
"theme-empty",
|
|
329
|
+
{ file: dsDir, line: 1, column: 1 },
|
|
330
|
+
`Theme "${theme.name}" is declared but no token has a ${theme.name} half; give the tokens that change per theme halves such as --color-accent-9-${themes[0].name} and --color-accent-9-${theme.name}, or remove it from ds.config.json.`,
|
|
331
|
+
);
|
|
236
332
|
return { diagnostics, advisories };
|
|
237
333
|
}
|
|
238
334
|
|
|
@@ -242,16 +338,23 @@ export function themeFindings(tokens, themes, { dsDir } = {}) {
|
|
|
242
338
|
export function themeAncestorSelector(selector) {
|
|
243
339
|
let found = false;
|
|
244
340
|
try {
|
|
245
|
-
selectorParser(root =>
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
341
|
+
selectorParser((root) =>
|
|
342
|
+
root.walkAttributes((node) => {
|
|
343
|
+
if (!["data-theme", "data-brand"].includes(node.attribute)) return;
|
|
344
|
+
// The selector's own subject compound (&[data-theme="dark"]) is the section itself.
|
|
345
|
+
let top = node;
|
|
346
|
+
while (top.parent && top.parent.type !== "root") top = top.parent;
|
|
347
|
+
const compound = top.nodes,
|
|
348
|
+
index = compound.indexOf(node);
|
|
349
|
+
const own =
|
|
350
|
+
index >= 0 &&
|
|
351
|
+
!compound.slice(index).some((part) => part.type === "combinator") &&
|
|
352
|
+
!compound.some((part) => part.type === "pseudo" && part.value.toLowerCase() === ":root");
|
|
353
|
+
if (!own) found = true;
|
|
354
|
+
}),
|
|
355
|
+
).processSync(selector);
|
|
356
|
+
} catch {
|
|
357
|
+
/* CSS syntax diagnostics are owned by the parser/build. */
|
|
358
|
+
}
|
|
256
359
|
return found;
|
|
257
360
|
}
|
package/dist/token-export.mjs
CHANGED
|
@@ -11,10 +11,11 @@ const extension = "org.reqvire.ads";
|
|
|
11
11
|
|
|
12
12
|
/** A token's path in the export: its family, then the rest of its name. */
|
|
13
13
|
function tokenPath(name) {
|
|
14
|
-
const bare = name.slice(2),
|
|
14
|
+
const bare = name.slice(2),
|
|
15
|
+
dash = bare.indexOf("-");
|
|
15
16
|
return dash < 0 ? [bare, "$root"] : [bare.slice(0, dash), bare.slice(dash + 1)];
|
|
16
17
|
}
|
|
17
|
-
const reference = name => `{${tokenPath(name).join(".")}}`;
|
|
18
|
+
const reference = (name) => `{${tokenPath(name).join(".")}}`;
|
|
18
19
|
|
|
19
20
|
/** A CSS value as a DTCG value and type, or null when the format cannot express it. */
|
|
20
21
|
function typed(name, value) {
|
|
@@ -23,8 +24,19 @@ function typed(name, value) {
|
|
|
23
24
|
if (alias) return { $value: reference(alias[1]) };
|
|
24
25
|
const color = parseColor(text);
|
|
25
26
|
if (color && !/^(?:--font-|--weight-|--leading-|--z-)/.test(name)) {
|
|
26
|
-
const hex = `#${color
|
|
27
|
-
|
|
27
|
+
const hex = `#${color
|
|
28
|
+
.slice(0, 3)
|
|
29
|
+
.map((channel) => Math.round(channel).toString(16).padStart(2, "0"))
|
|
30
|
+
.join("")}`;
|
|
31
|
+
return {
|
|
32
|
+
$type: "color",
|
|
33
|
+
$value: {
|
|
34
|
+
colorSpace: "srgb",
|
|
35
|
+
components: color.slice(0, 3).map((channel) => Number((channel / 255).toFixed(4))),
|
|
36
|
+
...(color[3] < 1 ? { alpha: color[3] } : {}),
|
|
37
|
+
hex,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
28
40
|
}
|
|
29
41
|
let match = text.match(/^(-?\d*\.?\d+)(px|rem)$/);
|
|
30
42
|
if (match) return { $type: "dimension", $value: { value: Number(match[1]), unit: match[2] } };
|
|
@@ -32,7 +44,7 @@ function typed(name, value) {
|
|
|
32
44
|
if (match) return { $type: "duration", $value: { value: Number(match[1]), unit: match[2] } };
|
|
33
45
|
match = text.match(/^cubic-bezier\(([^)]*)\)$/);
|
|
34
46
|
if (match) return { $type: "cubicBezier", $value: match[1].split(",").map(Number) };
|
|
35
|
-
if (name.startsWith("--font-")) return { $type: "fontFamily", $value: text.split(",").map(family => family.trim().replace(/^["']|["']$/g, "")) };
|
|
47
|
+
if (name.startsWith("--font-")) return { $type: "fontFamily", $value: text.split(",").map((family) => family.trim().replace(/^["']|["']$/g, "")) };
|
|
36
48
|
if (name.startsWith("--weight-") && /^\d+$/.test(text)) return { $type: "fontWeight", $value: Number(text) };
|
|
37
49
|
if (/^-?\d*\.?\d+$/.test(text)) return { $type: "number", $value: Number(text) };
|
|
38
50
|
return null;
|
|
@@ -40,12 +52,18 @@ function typed(name, value) {
|
|
|
40
52
|
|
|
41
53
|
/** The project's tokens as one DTCG document, with the values of one theme and one brand
|
|
42
54
|
* (default: the first of each). */
|
|
43
|
-
export function exportTokensDtcg(directory, { theme, brand } = {}) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
export async function exportTokensDtcg(directory, { theme, brand } = {}, inventory) {
|
|
56
|
+
if (inventory === undefined) inventory = await inspectTokens(directory);
|
|
57
|
+
const { tokens, themes, brands = [] } = inventory;
|
|
58
|
+
if (theme !== undefined && !themes.some((item) => item.name === theme))
|
|
59
|
+
throw new Error(`Unknown theme "${theme}"; the project declares ${themes.map((item) => item.name).join(", ")}.`);
|
|
60
|
+
if (brand !== undefined && !brands.some((item) => item.name === brand))
|
|
61
|
+
throw new Error(
|
|
62
|
+
`Unknown brand "${brand}"; ${brands.length ? `the project declares ${brands.map((item) => item.name).join(", ")}` : "the project declares no brands"}.`,
|
|
63
|
+
);
|
|
64
|
+
const selected = theme ?? themes[0].name,
|
|
65
|
+
own = brand === brands[0]?.name ? undefined : brand;
|
|
66
|
+
const names = new Set(tokens.map((token) => token.name));
|
|
49
67
|
let values;
|
|
50
68
|
const document = {};
|
|
51
69
|
for (const token of tokens) {
|
|
@@ -53,13 +71,20 @@ export function exportTokensDtcg(directory, { theme, brand } = {}) {
|
|
|
53
71
|
if (!base) continue;
|
|
54
72
|
// A half that names another theme's half has no DTCG alias; export its resolved value.
|
|
55
73
|
const alias = base.value.trim().match(/^var\(\s*(--[\w-]+)\s*\)$/)?.[1];
|
|
56
|
-
const value =
|
|
74
|
+
const value =
|
|
75
|
+
alias && !names.has(alias)
|
|
76
|
+
? (resolveValue((values ??= contextValues(tokens, { theme: selected, brand: own, themes })), token.name) ?? base.value)
|
|
77
|
+
: base.value;
|
|
57
78
|
const entry = typed(token.name, value) ?? { $value: value.trim() };
|
|
58
79
|
if (!("$type" in entry) && !entry.$value.toString().startsWith("{")) entry.$extensions = { [extension]: { css: value.trim() } };
|
|
59
80
|
if (token.meaning) entry.$description = token.meaning;
|
|
60
81
|
// The other contexts: a theme ("dark"), a brand ("acme") or both ("acme/dark"), or a condition.
|
|
61
|
-
const label = definition => definition.conditional ? definition.scope : [definition.brand, definition.theme].filter(Boolean).join("/") || "default";
|
|
62
|
-
const others = Object.fromEntries(
|
|
82
|
+
const label = (definition) => (definition.conditional ? definition.scope : [definition.brand, definition.theme].filter(Boolean).join("/") || "default");
|
|
83
|
+
const others = Object.fromEntries(
|
|
84
|
+
token.definitions
|
|
85
|
+
.filter((definition) => definition !== base)
|
|
86
|
+
.map((definition) => [label(definition), (typed(token.name, definition.value) ?? { $value: definition.value.trim() }).$value]),
|
|
87
|
+
);
|
|
63
88
|
if (Object.keys(others).length) entry.$extensions = { ...entry.$extensions, [extension]: { ...entry.$extensions?.[extension], values: others } };
|
|
64
89
|
const [group, key] = tokenPath(token.name);
|
|
65
90
|
document[group] ??= {};
|
package/dist/token-policy.mjs
CHANGED
|
@@ -5,8 +5,11 @@ import valueParser from "postcss-value-parser";
|
|
|
5
5
|
export const tokenContract = JSON.parse(readFileSync(new URL("./contracts/tokens.json", import.meta.url), "utf8"));
|
|
6
6
|
|
|
7
7
|
export function isSharedToken(name) {
|
|
8
|
-
return
|
|
9
|
-
|
|
8
|
+
return (
|
|
9
|
+
name in tokenContract.tokens ||
|
|
10
|
+
tokenContract.naming.names.includes(name) ||
|
|
11
|
+
tokenContract.naming.prefixes.some((prefix) => name.startsWith(prefix) && name.length > prefix.length)
|
|
12
|
+
);
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
// The foundation sheets in import order; themes.generated.css comes last, after every sheet it re-applies.
|
|
@@ -15,7 +18,7 @@ export const foundationFiles = ["fonts.css", "colors.css", "typography.css", "sp
|
|
|
15
18
|
/** The foundation entry accepts only a single, unconditional local import. */
|
|
16
19
|
export function foundationImportTarget(node, file) {
|
|
17
20
|
if (node.type !== "atrule" || node.name !== "import" || node.nodes) return null;
|
|
18
|
-
const parts = valueParser(node.params).nodes.filter(part => part.type !== "space" && part.type !== "comment");
|
|
21
|
+
const parts = valueParser(node.params).nodes.filter((part) => part.type !== "space" && part.type !== "comment");
|
|
19
22
|
if (parts.length !== 1) return null;
|
|
20
23
|
const part = parts[0];
|
|
21
24
|
const value = part.type === "string" ? part.value : part.type === "function" && part.value === "url" && part.nodes.length === 1 ? part.nodes[0].value : null;
|