@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,48 +1,149 @@
|
|
|
1
|
+
import { mapAsync } from "../analysis/queries.mjs";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
1
3
|
import { createServer } from "node:http";
|
|
2
4
|
import { readFile } from "node:fs/promises";
|
|
3
5
|
import { Readable } from "node:stream";
|
|
4
|
-
import { createMcpHandler } from "@modelcontextprotocol/server";
|
|
6
|
+
import { createMcpHandler, isLegacyRequest, WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/server";
|
|
5
7
|
import { startSandboxHost } from "./sandbox-host.mjs";
|
|
6
8
|
|
|
9
|
+
const maxRequestBodySize = 2 * 1024 * 1024,
|
|
10
|
+
maxLegacySessions = 64;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One MCP endpoint serving every protocol version ADS supports, as stdio does: 2026-07-28
|
|
14
|
+
* per request, and 2025-era clients over the sessionful Streamable HTTP transport (a session
|
|
15
|
+
* per client, with its GET stream for server notifications). Each session's server is created
|
|
16
|
+
* with `{ era: "legacy", session: true }`, so it observes the project like a stdio connection.
|
|
17
|
+
*/
|
|
18
|
+
function createEndpoint(factory) {
|
|
19
|
+
const modern = createMcpHandler(factory, { legacy: "reject", maxRequestBodySize });
|
|
20
|
+
const sessions = new Map();
|
|
21
|
+
async function legacy(request) {
|
|
22
|
+
const id = request.headers.get("mcp-session-id");
|
|
23
|
+
if (id) {
|
|
24
|
+
const session = sessions.get(id);
|
|
25
|
+
if (!session) return Response.json({ jsonrpc: "2.0", error: { code: -32001, message: "Session not found" }, id: null }, { status: 404 });
|
|
26
|
+
return session.transport.handleRequest(request);
|
|
27
|
+
}
|
|
28
|
+
const session = {};
|
|
29
|
+
session.transport = new WebStandardStreamableHTTPServerTransport({
|
|
30
|
+
sessionIdGenerator: randomUUID,
|
|
31
|
+
onsessioninitialized: (sessionId) => {
|
|
32
|
+
sessions.set(sessionId, session);
|
|
33
|
+
// Beyond the limit, the oldest session closes; its client reconnects with a new one.
|
|
34
|
+
if (sessions.size > maxLegacySessions)
|
|
35
|
+
void sessions
|
|
36
|
+
.values()
|
|
37
|
+
.next()
|
|
38
|
+
.value.server.close()
|
|
39
|
+
.catch(() => {});
|
|
40
|
+
},
|
|
41
|
+
onsessionclosed: (sessionId) => {
|
|
42
|
+
sessions.delete(sessionId);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
session.transport.onclose = () => {
|
|
46
|
+
if (session.transport.sessionId) sessions.delete(session.transport.sessionId);
|
|
47
|
+
};
|
|
48
|
+
session.server = await factory({ era: "legacy", session: true, requestInfo: request });
|
|
49
|
+
await session.server.connect(session.transport);
|
|
50
|
+
const response = await session.transport.handleRequest(request);
|
|
51
|
+
// Only an initialize request opens a session; anything else is answered and closed.
|
|
52
|
+
if (!session.transport.sessionId) await session.server.close();
|
|
53
|
+
return response;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
notify: modern.notify,
|
|
57
|
+
async fetch(request) {
|
|
58
|
+
return (await isLegacyRequest(request, undefined, { maxRequestBodySize })) ? await legacy(request) : modern.fetch(request);
|
|
59
|
+
},
|
|
60
|
+
async close() {
|
|
61
|
+
const open = [...sessions.values()];
|
|
62
|
+
sessions.clear();
|
|
63
|
+
await Promise.allSettled([modern.close(), ...open.map((session) => session.server.close())]);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
7
68
|
/** A loopback HTTP MCP transport and static client; neither renders project UI. */
|
|
8
69
|
export async function startShowcaseHost(factory, { port = 0, observe } = {}) {
|
|
9
|
-
const assets = new Map(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
70
|
+
const assets = new Map(
|
|
71
|
+
await Promise.all(
|
|
72
|
+
await mapAsync(
|
|
73
|
+
[
|
|
74
|
+
["/", "index.html", "text/html"],
|
|
75
|
+
["/client.js", "client.bundle.js", "text/javascript"],
|
|
76
|
+
["/style.css", "style.css", "text/css"],
|
|
77
|
+
["/ui.css", "ui/ui.css", "text/css"],
|
|
78
|
+
["/favicon.svg", "favicon.svg", "image/svg+xml"],
|
|
79
|
+
["/favicon.ico", "favicon.ico", "image/x-icon"],
|
|
80
|
+
],
|
|
81
|
+
async ([route, file, type]) => [route, { type, bytes: await readFile(new URL(`../showcase/${file}`, import.meta.url)) }],
|
|
82
|
+
),
|
|
83
|
+
),
|
|
84
|
+
);
|
|
85
|
+
const handler = createEndpoint(factory);
|
|
13
86
|
// Draft previews are served from this same host under /draft/<id>/: the same client, with that
|
|
14
87
|
// draft's own MCP endpoint. No other port or process.
|
|
15
88
|
const mounts = new Map();
|
|
16
|
-
const observer = observe?.(handler.notify);
|
|
89
|
+
const observer = await observe?.(handler.notify);
|
|
17
90
|
const requests = new Set();
|
|
18
91
|
let sandbox;
|
|
19
92
|
const web = createServer(async (req, res) => {
|
|
20
93
|
const origin = `http://127.0.0.1:${web.address().port}`;
|
|
21
|
-
if (req.headers.host !== new URL(origin).host || req.headers["sec-fetch-site"] === "cross-site" || req.headers.origin && req.headers.origin !== origin) {
|
|
22
|
-
res.writeHead(403);
|
|
94
|
+
if (req.headers.host !== new URL(origin).host || req.headers["sec-fetch-site"] === "cross-site" || (req.headers.origin && req.headers.origin !== origin)) {
|
|
95
|
+
res.writeHead(403);
|
|
96
|
+
res.end("Only the local showcase may access this host.");
|
|
97
|
+
return;
|
|
23
98
|
}
|
|
24
99
|
const url = new URL(req.url, origin);
|
|
25
100
|
const mount = [...mounts].find(([prefix]) => url.pathname.startsWith(prefix));
|
|
26
|
-
const route = mount ? `/${url.pathname.slice(mount[0].length)}` : url.pathname,
|
|
27
|
-
|
|
101
|
+
const route = mount ? `/${url.pathname.slice(mount[0].length)}` : url.pathname,
|
|
102
|
+
target = mount ? mount[1] : handler;
|
|
103
|
+
if (mount && url.pathname === mount[0].slice(0, -1)) {
|
|
104
|
+
res.writeHead(308, { Location: mount[0] + url.search });
|
|
105
|
+
res.end();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
28
108
|
if (route === "/host.json" && req.method === "GET") {
|
|
29
109
|
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
30
|
-
res.end(JSON.stringify({ sandboxUrl: sandbox?.url }));
|
|
110
|
+
res.end(JSON.stringify({ sandboxUrl: sandbox?.url }));
|
|
111
|
+
return;
|
|
31
112
|
}
|
|
32
113
|
const asset = assets.get(route);
|
|
33
|
-
if (req.method === "GET" &&
|
|
34
|
-
res.writeHead(
|
|
35
|
-
|
|
114
|
+
if (req.method === "GET" && asset) {
|
|
115
|
+
res.writeHead(200, {
|
|
116
|
+
"Content-Type": asset.type,
|
|
117
|
+
"Cache-Control": "no-store",
|
|
118
|
+
"X-Content-Type-Options": "nosniff",
|
|
119
|
+
"Content-Security-Policy": `default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; frame-src ${sandbox ? new URL(sandbox.url).origin : "'none'"};connect-src 'self';object-src 'none'`,
|
|
120
|
+
});
|
|
121
|
+
res.end(asset?.bytes);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (route !== "/mcp") {
|
|
125
|
+
res.writeHead(404);
|
|
126
|
+
res.end("Not found");
|
|
127
|
+
return;
|
|
36
128
|
}
|
|
37
|
-
if (route !== "/mcp") { res.writeHead(404); res.end("Not found"); return; }
|
|
38
129
|
const abort = new AbortController();
|
|
39
130
|
requests.add(abort);
|
|
40
|
-
res.once("close", () => {
|
|
131
|
+
res.once("close", () => {
|
|
132
|
+
requests.delete(abort);
|
|
133
|
+
abort.abort();
|
|
134
|
+
});
|
|
41
135
|
try {
|
|
42
|
-
const request = new Request(url, {
|
|
43
|
-
|
|
136
|
+
const request = new Request(url, {
|
|
137
|
+
method: req.method,
|
|
138
|
+
headers: req.headers,
|
|
139
|
+
signal: abort.signal,
|
|
140
|
+
...(req.method === "POST" ? { body: Readable.toWeb(req), duplex: "half" } : {}),
|
|
141
|
+
});
|
|
44
142
|
const response = await target.fetch(request);
|
|
45
143
|
res.writeHead(response.status, Object.fromEntries(response.headers));
|
|
144
|
+
// Send the headers now: an event stream (such as a 2025-era session's notification
|
|
145
|
+
// stream) may have nothing to write yet, and its client waits for the response to start.
|
|
146
|
+
res.flushHeaders();
|
|
46
147
|
if (response.body) {
|
|
47
148
|
const stream = Readable.fromWeb(response.body);
|
|
48
149
|
stream.on("error", () => res.destroy());
|
|
@@ -50,40 +151,63 @@ export async function startShowcaseHost(factory, { port = 0, observe } = {}) {
|
|
|
50
151
|
stream.pipe(res);
|
|
51
152
|
} else res.end();
|
|
52
153
|
} catch (error) {
|
|
53
|
-
if (!res.headersSent) {
|
|
54
|
-
|
|
154
|
+
if (!res.headersSent) {
|
|
155
|
+
res.writeHead(500);
|
|
156
|
+
res.end(error.message);
|
|
157
|
+
} else res.destroy();
|
|
55
158
|
}
|
|
56
159
|
});
|
|
57
160
|
try {
|
|
58
|
-
await new Promise((resolve, reject) => {
|
|
161
|
+
await new Promise((resolve, reject) => {
|
|
162
|
+
web.once("error", reject);
|
|
163
|
+
web.listen(port, "127.0.0.1", resolve);
|
|
164
|
+
}).catch((error) => {
|
|
59
165
|
// Commonly the project's ADS MCP (\`ads mcp --port\`), which serves its own showcase there.
|
|
60
|
-
if (error?.code === "EADDRINUSE" || /in use/i.test(error?.message ?? ""))
|
|
166
|
+
if (error?.code === "EADDRINUSE" || /in use/i.test(error?.message ?? ""))
|
|
167
|
+
throw Object.assign(
|
|
168
|
+
new Error(
|
|
169
|
+
`Port ${port} is already in use, often by another ADS showcase or the project's ADS MCP (it serves the showcase on its own --port). Open that showcase, or give this one another --port.`,
|
|
170
|
+
),
|
|
171
|
+
{ code: "EADDRINUSE" },
|
|
172
|
+
);
|
|
61
173
|
throw error;
|
|
62
174
|
});
|
|
63
175
|
sandbox = await startSandboxHost(`http://127.0.0.1:${web.address().port}`);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
web.close();
|
|
178
|
+
await observer?.close();
|
|
179
|
+
await handler.close();
|
|
180
|
+
throw error;
|
|
64
181
|
}
|
|
65
|
-
catch (error) { web.close(); await observer?.close(); await handler.close(); throw error; }
|
|
66
182
|
let closing;
|
|
67
|
-
return {
|
|
183
|
+
return {
|
|
184
|
+
url: `http://127.0.0.1:${web.address().port}/`,
|
|
68
185
|
/** Serve another MCP server's showcase under a path prefix such as /draft/<id>/. */
|
|
69
186
|
mount(prefix, mountFactory) {
|
|
70
|
-
const mounted =
|
|
187
|
+
const mounted = createEndpoint(mountFactory);
|
|
71
188
|
mounts.set(prefix, mounted);
|
|
72
|
-
return async () => {
|
|
189
|
+
return async () => {
|
|
190
|
+
if (mounts.get(prefix) === mounted) mounts.delete(prefix);
|
|
191
|
+
await mounted.close();
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
async close() {
|
|
195
|
+
return (closing ??= await (async () => {
|
|
196
|
+
// Close sockets first: live subscriptions and preview requests must not
|
|
197
|
+
// hold shutdown open while protocol instances wait for cancellation.
|
|
198
|
+
const stopped = new Promise((resolve) => web.close(resolve));
|
|
199
|
+
for (const request of requests) request.abort();
|
|
200
|
+
web.closeAllConnections();
|
|
201
|
+
const results = await Promise.allSettled([
|
|
202
|
+
stopped,
|
|
203
|
+
Promise.resolve().then(async () => observer?.close()),
|
|
204
|
+
handler.close(),
|
|
205
|
+
sandbox?.close(),
|
|
206
|
+
...[...mounts.values()].map((mounted) => mounted.close()),
|
|
207
|
+
]);
|
|
208
|
+
const errors = results.filter((result) => result.status === "rejected").map((result) => result.reason);
|
|
209
|
+
if (errors.length) throw new AggregateError(errors, "Showcase shutdown failed");
|
|
210
|
+
})());
|
|
73
211
|
},
|
|
74
|
-
|
|
75
|
-
return closing ??= (async () => {
|
|
76
|
-
// Close sockets first: live subscriptions and preview requests must not
|
|
77
|
-
// hold shutdown open while protocol instances wait for cancellation.
|
|
78
|
-
const stopped = new Promise(resolve => web.close(resolve));
|
|
79
|
-
for (const request of requests) request.abort();
|
|
80
|
-
web.closeAllConnections();
|
|
81
|
-
const results = await Promise.allSettled([stopped,
|
|
82
|
-
Promise.resolve().then(() => observer?.close()),
|
|
83
|
-
handler.close(), sandbox?.close(), ...[...mounts.values()].map(mounted => mounted.close()),
|
|
84
|
-
]);
|
|
85
|
-
const errors = results.filter(result => result.status === "rejected").map(result => result.reason);
|
|
86
|
-
if (errors.length) throw new AggregateError(errors, "Showcase shutdown failed");
|
|
87
|
-
})();
|
|
88
|
-
} };
|
|
212
|
+
};
|
|
89
213
|
}
|
package/dist/mcp/skills.mjs
CHANGED
|
@@ -21,7 +21,7 @@ export function page(items, cursor, namespace, size = 25) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/** A packaged, immutable snapshot: the bytes read match the advertised manifest. */
|
|
24
|
-
export function createSkillStore(directory
|
|
24
|
+
export function createSkillStore(directory ) {if(directory===undefined)directory=fileURLToPath(new URL("../skills/",import.meta.url));
|
|
25
25
|
const files = new Map();
|
|
26
26
|
const directories = new Map([[SKILLS_ROOT, []]]);
|
|
27
27
|
const skills = [];
|
package/dist/mcp/text-diff.mjs
CHANGED
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
/** One exact Git-style hunk, retaining only shared context around the change. */
|
|
2
2
|
export function textDiff(file, before, after) {
|
|
3
3
|
if (before === after) return "";
|
|
4
|
-
const lines = value => value?.match(/[^\n]*\n|[^\n]+$/g) ?? [];
|
|
4
|
+
const lines = (value) => value?.match(/[^\n]*\n|[^\n]+$/g) ?? [];
|
|
5
5
|
const emit = (prefix, line) => prefix + line.replace(/\n$/, "") + "\n" + (line.endsWith("\n") ? "" : "\\n");
|
|
6
|
-
const left = lines(before),
|
|
7
|
-
|
|
6
|
+
const left = lines(before),
|
|
7
|
+
right = lines(after);
|
|
8
|
+
let common = 0,
|
|
9
|
+
suffix = 0;
|
|
8
10
|
while (common < left.length && common < right.length && left[common] === right[common]) common++;
|
|
9
11
|
while (suffix < left.length - common && suffix < right.length - common && left.at(-suffix - 1) === right.at(-suffix - 1)) suffix++;
|
|
10
|
-
const start = Math.max(0, common - 3),
|
|
11
|
-
|
|
12
|
+
const start = Math.max(0, common - 3),
|
|
13
|
+
tail = Math.min(3, suffix);
|
|
14
|
+
const oldCount = left.length - suffix + tail - start,
|
|
15
|
+
newCount = right.length - suffix + tail - start;
|
|
12
16
|
const headers = `--- ${before === null ? "/dev/null" : "a/" + file}\n+++ ${after === null ? "/dev/null" : "b/" + file}\n`;
|
|
13
17
|
if (!oldCount && !newCount) return headers;
|
|
14
|
-
return
|
|
15
|
-
+
|
|
16
|
-
+
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
return (
|
|
19
|
+
headers +
|
|
20
|
+
`@@ -${oldCount ? start + 1 : start},${oldCount} +${newCount ? start + 1 : start},${newCount} @@\n` +
|
|
21
|
+
left
|
|
22
|
+
.slice(start, common)
|
|
23
|
+
.map((line) => emit(" ", line))
|
|
24
|
+
.join("") +
|
|
25
|
+
left
|
|
26
|
+
.slice(common, left.length - suffix)
|
|
27
|
+
.map((line) => emit("-", line))
|
|
28
|
+
.join("") +
|
|
29
|
+
right
|
|
30
|
+
.slice(common, right.length - suffix)
|
|
31
|
+
.map((line) => emit("+", line))
|
|
32
|
+
.join("") +
|
|
33
|
+
left
|
|
34
|
+
.slice(left.length - suffix, left.length - suffix + tail)
|
|
35
|
+
.map((line) => emit(" ", line))
|
|
36
|
+
.join("")
|
|
37
|
+
);
|
|
19
38
|
}
|
package/dist/paint-contracts.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { memoFact, currentAnalysis } from "./analysis/context.mjs";
|
|
2
|
+
import { withProjectAnalysis } from "./analysis/standalone.mjs";
|
|
3
|
+
import { eachChild, flatMapAsync, mapAsync } from "./analysis/queries.mjs";
|
|
1
4
|
import path from "node:path";
|
|
2
|
-
import ts from "
|
|
5
|
+
import ts from "./analysis/syntax.mjs";
|
|
3
6
|
import valueParser from "postcss-value-parser";
|
|
4
7
|
import { isSharedToken } from "./token-policy.mjs";
|
|
5
8
|
import { isContractFile, isInside } from "./config.mjs";
|
|
@@ -8,116 +11,206 @@ import { createSourceValues, reference } from "./source-values.mjs";
|
|
|
8
11
|
|
|
9
12
|
export function paintReference(text) {
|
|
10
13
|
if (typeof text !== "string" || text.length > 1000) return null;
|
|
11
|
-
text=text.trim();
|
|
12
|
-
if (["none", "currentColor"].includes(text)) return {kind:"keyword",value:text};
|
|
13
|
-
const nodes = valueParser(text).nodes.filter(node => !["space","comment"].includes(node.type));
|
|
14
|
+
text = text.trim();
|
|
15
|
+
if (["none", "currentColor"].includes(text)) return { kind: "keyword", value: text };
|
|
16
|
+
const nodes = valueParser(text).nodes.filter((node) => !["space", "comment"].includes(node.type));
|
|
14
17
|
if (nodes.length !== 1 || nodes[0].type !== "function" || nodes[0].unclosed) return null;
|
|
15
|
-
const node=nodes[0],
|
|
16
|
-
|
|
17
|
-
if (node.value === "
|
|
18
|
+
const node = nodes[0],
|
|
19
|
+
children = node.nodes.filter((item) => !["space", "comment"].includes(item.type));
|
|
20
|
+
if (node.value === "var" && children.length === 1 && children[0].type === "word" && /^--[\w-]+$/.test(children[0].value))
|
|
21
|
+
return { kind: "variable", name: children[0].value };
|
|
22
|
+
if (node.value === "url" && children.length === 1 && ["word", "string"].includes(children[0].type) && /^#[^\s"'()#\\\p{Cc}]+$/u.test(children[0].value))
|
|
23
|
+
return { kind: "resource", id: children[0].value.slice(1) };
|
|
18
24
|
return null;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
function supportedType(type, seen = new Set()) {
|
|
22
28
|
if (!type || seen.has(type)) return false;
|
|
23
|
-
seen=new Set([...seen,type]);
|
|
29
|
+
seen = new Set([...seen, type]);
|
|
24
30
|
if (type.flags & ts.TypeFlags.Undefined) return true;
|
|
25
31
|
if (type.flags & ts.TypeFlags.StringLiteral) return !!paintReference(type.value);
|
|
26
|
-
if (type.isUnion()) return type.types.every(item=>supportedType(item,seen));
|
|
27
|
-
if (type.flags & ts.TypeFlags.TemplateLiteral)
|
|
32
|
+
if (type.isUnion()) return type.types.every((item) => supportedType(item, seen));
|
|
33
|
+
if (type.flags & ts.TypeFlags.TemplateLiteral)
|
|
34
|
+
return (
|
|
35
|
+
type.texts.length === 2 &&
|
|
36
|
+
(type.texts[0] === "var(--" || type.texts[0] === "url(#") &&
|
|
37
|
+
type.texts[1] === ")" &&
|
|
38
|
+
type.types.every((item) => !!(item.flags & (ts.TypeFlags.String | ts.TypeFlags.StringLiteral)))
|
|
39
|
+
);
|
|
28
40
|
return false;
|
|
29
41
|
}
|
|
30
42
|
|
|
31
|
-
export function inspectPaintContracts(options) {
|
|
32
|
-
if(options.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
export async function inspectPaintContracts(options) {
|
|
44
|
+
if (!currentAnalysis()?.provideProgram) return withProjectAnalysis(options.root, () => inspectPaintContracts(options));
|
|
45
|
+
return memoFact(options, "paint-contracts", () => discoverPaintContracts(options));
|
|
46
|
+
}
|
|
47
|
+
async function discoverPaintContracts(options) {
|
|
48
|
+
const declarations = await inspectUnitContracts(options),
|
|
49
|
+
result = { allowedProperties: new Set(), diagnostics: [], contracts: declarations.contracts };
|
|
50
|
+
if (!declarations.program) return result;
|
|
36
51
|
// TypeScript source identities use absolute paths, independently of process cwd.
|
|
37
|
-
for(const contract of declarations.contracts)
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
for (const contract of declarations.contracts)
|
|
53
|
+
for (const input of contract.paintInputs ?? []) {
|
|
54
|
+
const checker = declarations.program.getTypeChecker();
|
|
55
|
+
const source = await declarations.program.getSourceFile(path.resolve(options.root, input.api.source));
|
|
56
|
+
let declaration;
|
|
57
|
+
function find(node) {
|
|
58
|
+
if (node.pos === input.api.position && (ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node) || ts.isClassDeclaration(node)))
|
|
59
|
+
declaration = node;
|
|
60
|
+
else ts.forEachChild(node, find);
|
|
61
|
+
}
|
|
62
|
+
if (source) find(source);
|
|
63
|
+
const signature = declaration && (await (await checker.getTypeAtLocation(declaration.name)).getCallSignatures())[0];
|
|
64
|
+
let values = signature?.parameters[0] ? [{ type: await checker.getTypeOfSymbolAtLocation(signature.parameters[0], declaration) }] : [];
|
|
65
|
+
for (const segment of input.property.split(".")) {
|
|
66
|
+
const next = [];
|
|
67
|
+
for (const item of values)
|
|
68
|
+
for (const type of item.type.isUnion() ? item.type.types : [item.type]) {
|
|
69
|
+
if (type.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Null)) continue;
|
|
70
|
+
if (segment === "*") {
|
|
71
|
+
const indexed = (await type.getStringIndexType()) ?? (await type.getNumberIndexType());
|
|
72
|
+
if (indexed) next.push({ type: indexed });
|
|
73
|
+
else
|
|
74
|
+
for (const prop of await type.getProperties())
|
|
75
|
+
next.push({ type: await checker.getTypeOfSymbolAtLocation(prop, prop.valueDeclaration ?? declaration), symbol: prop });
|
|
76
|
+
} else {
|
|
77
|
+
const prop = await type.getProperty(segment);
|
|
78
|
+
if (prop) next.push({ type: await checker.getTypeOfSymbolAtLocation(prop, prop.valueDeclaration ?? declaration), symbol: prop });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
values = next;
|
|
53
82
|
}
|
|
54
|
-
values
|
|
83
|
+
if (!values.length || values.some((value) => !supportedType(value.type)))
|
|
84
|
+
result.diagnostics.push({
|
|
85
|
+
file: contract.file,
|
|
86
|
+
rule: "paint-contract",
|
|
87
|
+
line: 1,
|
|
88
|
+
column: 1,
|
|
89
|
+
message: `${input.apiName}.${input.property} must resolve to constrained token/local-resource paint references, not string, any or unknown. A declared role does not waive the actual type contract.`,
|
|
90
|
+
});
|
|
91
|
+
else
|
|
92
|
+
for (const value of values)
|
|
93
|
+
for (const node of value.symbol?.declarations ?? []) result.allowedProperties.add(`${node.getSourceFile().fileName}:${node.pos}`);
|
|
55
94
|
}
|
|
56
|
-
if(!values.length||values.some(value=>!supportedType(value.type)))result.diagnostics.push({file:contract.file,rule:"paint-contract",line:1,column:1,message:`${input.apiName}.${input.property} must resolve to constrained token/local-resource paint references, not string, any or unknown. A declared role does not waive the actual type contract.`});
|
|
57
|
-
else for(const value of values)for(const node of value.symbol?.declarations??[])result.allowedProperties.add(`${node.getSourceFile().fileName}:${node.pos}`);
|
|
58
|
-
}
|
|
59
95
|
return result;
|
|
60
96
|
}
|
|
61
97
|
|
|
62
|
-
const paintProp
|
|
98
|
+
const paintProp = /^(?:background(?:Color)?|color|fill|stroke|stopColor|stop-color|floodColor|flood-color|(?:\w+)?ColorToken)$/i;
|
|
63
99
|
|
|
64
100
|
/** Check resolved values at the consuming source, so exports cannot launder privacy. */
|
|
65
|
-
export function inspectTokenValueFlows(program, options, inventory, units, report) {
|
|
66
|
-
const values=createSourceValues(program,options),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if(value.kind==="
|
|
72
|
-
if(value.kind==="
|
|
73
|
-
|
|
74
|
-
|
|
101
|
+
export async function inspectTokenValueFlows(program, options, inventory, units, report) {
|
|
102
|
+
const values = createSourceValues(program, options),
|
|
103
|
+
checker = program.getTypeChecker();
|
|
104
|
+
const declarations = (await inspectUnitContracts(options)).contracts;
|
|
105
|
+
async function strings(input, context = values.state()) {
|
|
106
|
+
const value = await values.resolve(input, context);
|
|
107
|
+
if (value.kind === "literal") return typeof value.value === "string" ? [value.value] : [];
|
|
108
|
+
if (value.kind === "union") return flatMapAsync(value.values.slice(0, 32), async (item) => strings(item, values.next(context)));
|
|
109
|
+
if (value.kind === "node" && ts.isTemplateExpression(value.node)) {
|
|
110
|
+
let result = [value.node.head.text];
|
|
111
|
+
for (const span of value.node.templateSpans) {
|
|
112
|
+
const parts = await strings(reference(span.expression, value.env, value.via), values.next(context));
|
|
113
|
+
result = result.flatMap((prefix) => parts.map((part) => prefix + part + span.literal.text)).slice(0, 32);
|
|
114
|
+
}
|
|
75
115
|
return result;
|
|
76
116
|
}
|
|
77
|
-
if(value.kind==="node"&&ts.isBinaryExpression(value.node)&&value.node.operatorToken.kind===ts.SyntaxKind.PlusToken) {
|
|
78
|
-
const left=strings(reference(value.node.left,value.env,value.via),values.next(context)),
|
|
79
|
-
|
|
117
|
+
if (value.kind === "node" && ts.isBinaryExpression(value.node) && value.node.operatorToken.kind === ts.SyntaxKind.PlusToken) {
|
|
118
|
+
const left = await strings(reference(value.node.left, value.env, value.via), values.next(context)),
|
|
119
|
+
right = await strings(reference(value.node.right, value.env, value.via), values.next(context));
|
|
120
|
+
return left.flatMap((first) => right.map((second) => first + second)).slice(0, 32);
|
|
80
121
|
}
|
|
81
122
|
return [];
|
|
82
123
|
}
|
|
83
|
-
for(const source of program.getSourceFiles()) {
|
|
84
|
-
if(!isInside(options.root,source.fileName)||source.fileName.includes(`${path.sep}node_modules${path.sep}`)||isContractFile(source.fileName))continue;
|
|
85
|
-
const owner=units.owner(units.relative(path.relative(options.root,source.fileName)));
|
|
86
|
-
const emitted=new Set();
|
|
87
|
-
function check(node,text,bare=false,requirePaint=false,allowedBindings=null) {
|
|
88
|
-
const names=
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
124
|
+
for (const source of await program.getSourceFiles()) {
|
|
125
|
+
if (!isInside(options.root, source.fileName) || source.fileName.includes(`${path.sep}node_modules${path.sep}`) || isContractFile(source.fileName)) continue;
|
|
126
|
+
const owner = units.owner(units.relative(path.relative(options.root, source.fileName)));
|
|
127
|
+
const emitted = new Set();
|
|
128
|
+
async function check(node, text, bare = false, requirePaint = false, allowedBindings = null) {
|
|
129
|
+
const names =
|
|
130
|
+
bare && /^--[\w-]+$/.test(text)
|
|
131
|
+
? [text]
|
|
132
|
+
: valueParser(text)
|
|
133
|
+
.nodes.flatMap(function walk(value) {
|
|
134
|
+
return value.type === "function" && value.value === "var"
|
|
135
|
+
? [value.nodes.find((item) => item.type === "word")?.value]
|
|
136
|
+
: value.nodes
|
|
137
|
+
? value.nodes.flatMap(walk)
|
|
138
|
+
: [];
|
|
139
|
+
})
|
|
140
|
+
.filter(Boolean);
|
|
141
|
+
for (const name of names) {
|
|
142
|
+
const binding = await runtimeBindingOwner(options, name);
|
|
143
|
+
const issue =
|
|
144
|
+
binding && (binding.unit !== owner || (allowedBindings && !allowedBindings.includes(binding.id)))
|
|
145
|
+
? `${name} is an instance binding private to ${binding.unit} and is not permitted by this consuming paint input.`
|
|
146
|
+
: !binding &&
|
|
147
|
+
((!isSharedToken(name) && !/^--(?:ds|ux|showcase)-/.test(name)) || (requirePaint && !inventory.tokens.some((token) => token.name === name)))
|
|
148
|
+
? `Undefined paint reference ${name}. Declare a real accessible token or a scoped runtime binding.`
|
|
149
|
+
: null;
|
|
150
|
+
if (issue && !emitted.has(`${node.pos}:${name}`)) {
|
|
151
|
+
emitted.add(`${node.pos}:${name}`);
|
|
152
|
+
const p = source.getLineAndCharacterOfPosition(node.getStart());
|
|
153
|
+
report(source.fileName, "token-reference", issue, p.line + 1, p.character + 1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (requirePaint && !paintReference(text)) {
|
|
157
|
+
const p = source.getLineAndCharacterOfPosition(node.getStart());
|
|
158
|
+
report(
|
|
159
|
+
source.fileName,
|
|
160
|
+
"paint-reference",
|
|
161
|
+
`Invalid paint reference ${JSON.stringify(text)}. Use an accessible token, declared scoped binding, local SVG paint resource, none or currentColor.`,
|
|
162
|
+
p.line + 1,
|
|
163
|
+
p.character + 1,
|
|
164
|
+
);
|
|
93
165
|
}
|
|
94
|
-
if(requirePaint&&!paintReference(text)) {const p=source.getLineAndCharacterOfPosition(node.getStart());report(source.fileName,"paint-reference",`Invalid paint reference ${JSON.stringify(text)}. Use an accessible token, declared scoped binding, local SVG paint resource, none or currentColor.`,p.line+1,p.character+1);}
|
|
95
166
|
}
|
|
96
|
-
function visit(node) {
|
|
97
|
-
if(
|
|
98
|
-
|
|
99
|
-
|
|
167
|
+
async function visit(node) {
|
|
168
|
+
if (
|
|
169
|
+
ts.isCallExpression(node) &&
|
|
170
|
+
ts.isPropertyAccessExpression(node.expression) &&
|
|
171
|
+
["getPropertyValue", "setProperty", "removeProperty"].includes(node.expression.name.text)
|
|
172
|
+
) {
|
|
173
|
+
for (const text of await strings(reference(node.arguments[0]))) await check(node, text, true);
|
|
174
|
+
if (node.expression.name.text === "setProperty") for (const text of await strings(reference(node.arguments[1]))) await check(node, text);
|
|
100
175
|
}
|
|
101
|
-
if
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
176
|
+
if (
|
|
177
|
+
ts.isBinaryExpression(node) &&
|
|
178
|
+
node.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
|
|
179
|
+
ts.isPropertyAccessExpression(node.left) &&
|
|
180
|
+
ts.isPropertyAccessExpression(node.left.expression) &&
|
|
181
|
+
node.left.expression.name.text === "style"
|
|
182
|
+
)
|
|
183
|
+
for (const text of await strings(reference(node.right))) await check(node, text);
|
|
184
|
+
if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
|
|
185
|
+
const attributes = values.props(node, new Map(), []);
|
|
186
|
+
for (const property of await values.keys(attributes, values.state())) {
|
|
187
|
+
if (paintProp.test(property)) for (const text of await strings(await values.get(attributes, property, values.state()))) await check(node, text);
|
|
188
|
+
if (property === "style") {
|
|
189
|
+
const styles = await values.get(attributes, "style", values.state());
|
|
190
|
+
for (const property of await values.keys(styles, values.state()))
|
|
191
|
+
for (const text of await strings(await values.get(styles, property, values.state()))) await check(node, text);
|
|
109
192
|
}
|
|
110
193
|
}
|
|
111
|
-
let symbol=checker.getSymbolAtLocation(node.tagName);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
for(const
|
|
116
|
-
|
|
117
|
-
|
|
194
|
+
let symbol = await checker.getSymbolAtLocation(node.tagName);
|
|
195
|
+
if (symbol?.flags & ts.SymbolFlags.Alias) symbol = await checker.getAliasedSymbol(symbol);
|
|
196
|
+
const declaration = symbol?.valueDeclaration;
|
|
197
|
+
if (declaration)
|
|
198
|
+
for (const contract of declarations)
|
|
199
|
+
for (const input of contract.paintInputs ?? [])
|
|
200
|
+
if (input.api.identity === implementationIdentity(declaration, options.root)) {
|
|
201
|
+
let current = [values.props(node, new Map(), [])];
|
|
202
|
+
for (const segment of input.property.split("."))
|
|
203
|
+
current = await flatMapAsync(current, async (value) =>
|
|
204
|
+
segment === "*"
|
|
205
|
+
? ((await values.arrays(value, values.state())) ??
|
|
206
|
+
(await mapAsync((await values.keys(value, values.state())) ?? [], async (key) => values.get(value, key, values.state()))))
|
|
207
|
+
: [await values.get(value, segment, values.state())],
|
|
208
|
+
);
|
|
209
|
+
for (const value of current) for (const text of await strings(value)) await check(node, text, false, true, input.bindings ?? []);
|
|
210
|
+
}
|
|
118
211
|
}
|
|
119
|
-
|
|
212
|
+
await eachChild(node, visit);
|
|
120
213
|
}
|
|
121
|
-
visit(source);
|
|
214
|
+
await visit(source);
|
|
122
215
|
}
|
|
123
216
|
}
|