@reqvire-org/ads 0.3.53 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -94
- package/dist/a11y.mjs +108 -29
- 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 +140 -0
- package/dist/analysis/impact.mjs +20 -0
- package/dist/analysis/inputs.mjs +15 -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 +146 -0
- package/dist/analysis/standalone.mjs +57 -0
- package/dist/analysis/syntax.mjs +164 -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 +222 -79
- package/dist/boundaries.mjs +137 -40
- package/dist/brand-assets.mjs +219 -47
- package/dist/brands.mjs +86 -27
- package/dist/bun-compiler.mjs +34 -13
- 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 +66 -0
- package/dist/check.mjs +756 -196
- package/dist/cli.mjs +203 -100
- package/dist/color-values.mjs +21 -21
- package/dist/component-contrast.mjs +2 -2
- package/dist/config.mjs +308 -163
- package/dist/construction-styles.cjs +10 -0
- package/dist/contracts.d.mts +9 -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 +7 -5
- package/dist/font-rules.mjs +2 -2
- package/dist/fonts-generated.mjs +4 -2
- package/dist/foundation-views.mjs +238 -0
- package/dist/foundation.mjs +63 -39
- package/dist/generated-entries.mjs +198 -0
- package/dist/icons.mjs +80 -33
- package/dist/image-attributes.mjs +109 -36
- package/dist/image-size.mjs +1 -1
- package/dist/index.mjs +0 -2
- package/dist/init.mjs +128 -68
- package/dist/investigations.mjs +2 -2
- package/dist/layers.mjs +300 -127
- 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 +91 -26
- package/dist/mcp/context.mjs +17 -18
- package/dist/mcp/draft-discovery.mjs +44 -21
- package/dist/mcp/drafts.mjs +978 -343
- package/dist/mcp/execution-coordinator.mjs +417 -167
- package/dist/mcp/execution-results.mjs +7 -7
- package/dist/mcp/mutations.mjs +701 -219
- package/dist/mcp/preview-watch.mjs +465 -161
- package/dist/mcp/preview-widget.bundle.js +44 -50
- package/dist/mcp/prompts.mjs +6 -6
- package/dist/mcp/result-pages.mjs +1 -1
- package/dist/mcp/sandbox-host.mjs +1 -1
- package/dist/mcp/server.mjs +2436 -570
- package/dist/mcp/showcase-host.mjs +176 -39
- 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/preview-bun.mjs +493 -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 +10 -0
- package/dist/project-documents.mjs +1 -1
- package/dist/public-api.mjs +70 -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 +2 -2
- 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/{browser-audit → render-audit}/render-states.mjs +208 -52
- package/dist/{browser-audit → render-audit}/worker.mjs +86 -30
- package/dist/render-audit.mjs +828 -0
- package/dist/render-color-probe.mjs +96 -42
- 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 +768 -359
- package/dist/scenarios-vite.d.mts +1 -3
- package/dist/scenarios-vite.mjs +2 -81
- package/dist/scenarios.mjs +424 -159
- package/dist/selector-match.mjs +2 -2
- package/dist/showcase/client.bundle.js +57 -56
- package/dist/showcase/draft-navigation.js +18 -0
- package/dist/showcase/favicon.ico +0 -0
- package/dist/showcase/favicon.svg +1 -0
- package/dist/showcase/foundation-view.css +55 -0
- package/dist/showcase/foundation-view.mjs +252 -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/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 +1062 -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 +152 -144
- package/dist/skills/ads-designer/references/accessibility.md +14 -11
- package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
- package/dist/skills/ads-designer/references/behaviors.md +34 -30
- package/dist/skills/ads-designer/references/branding.md +98 -10
- package/dist/skills/ads-designer/references/captures.md +31 -31
- package/dist/skills/ads-designer/references/cli.md +21 -20
- package/dist/skills/ads-designer/references/contracts.md +63 -29
- package/dist/skills/ads-designer/references/design-data.md +49 -52
- package/dist/skills/ads-designer/references/drafts.md +71 -52
- package/dist/skills/ads-designer/references/evidence.md +1 -5
- package/dist/skills/ads-designer/references/guarded-editing.md +58 -51
- 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/review.md +42 -38
- package/dist/skills/ads-designer/references/runtimes.md +33 -30
- package/dist/skills/ads-designer/references/scenarios.md +17 -19
- 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 -71
- package/dist/skills/ads-designer/references/workflows.md +19 -37
- package/dist/skills/ads-import/SKILL.md +43 -328
- package/dist/skills/ads-import/references/atomic-styles.md +4 -4
- package/dist/skills/ads-import/references/behaviors.md +34 -30
- package/dist/skills/ads-import/references/branding.md +5 -5
- package/dist/skills/ads-import/references/captures.md +31 -31
- package/dist/skills/ads-import/references/cli.md +21 -20
- package/dist/skills/ads-import/references/compatibility.md +1 -1
- package/dist/skills/ads-import/references/contracts.md +63 -29
- package/dist/skills/ads-import/references/design-data.md +49 -52
- package/dist/skills/ads-import/references/drafts.md +71 -52
- package/dist/skills/ads-import/references/evidence.md +1 -5
- package/dist/skills/ads-import/references/guarded-editing.md +58 -51
- 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 +42 -38
- package/dist/skills/ads-import/references/runtimes.md +33 -30
- package/dist/skills/ads-import/references/scenarios.md +17 -19
- package/dist/skills/ads-import/references/tokens.md +3 -3
- package/dist/skills/ads-import/references/validation.md +83 -71
- package/dist/skills/ads-import/references/workflows.md +19 -37
- 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 +54 -346
- package/dist/skills/ads-port/references/atomic-styles.md +4 -4
- package/dist/skills/ads-port/references/behaviors.md +34 -30
- package/dist/skills/ads-port/references/captures.md +31 -31
- package/dist/skills/ads-port/references/cli.md +21 -20
- package/dist/skills/ads-port/references/contracts.md +63 -29
- package/dist/skills/ads-port/references/design-data.md +49 -52
- package/dist/skills/ads-port/references/drafts.md +71 -52
- package/dist/skills/ads-port/references/evidence.md +1 -5
- package/dist/skills/ads-port/references/guarded-editing.md +58 -51
- 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 +8 -7
- package/dist/skills/ads-port/references/review.md +42 -38
- package/dist/skills/ads-port/references/runtimes.md +33 -30
- package/dist/skills/ads-port/references/scenarios.md +17 -19
- package/dist/skills/ads-port/references/validation.md +83 -71
- package/dist/skills/ads-port/references/workflows.md +19 -37
- package/dist/source-symbols.mjs +1 -8
- package/dist/source-values.mjs +266 -128
- 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 +24 -19
- 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 +54 -52
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +1 -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/Icon/Icon.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +1 -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/controllers/Palette/Palette.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/index.ts +5 -8
- 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/Search/SearchBar/SearchBar.ads.exports.ts +1 -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 -0
- 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 -0
- 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/styles.css +1 -0
- 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 +24 -19
- 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 +73 -27
- package/dist/task-cache.mjs +173 -72
- package/dist/task-worker.mjs +22 -11
- package/dist/test-boundaries.mjs +133 -60
- package/dist/themes-generated.mjs +1 -1
- package/dist/themes-watch.mjs +60 -19
- 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 +270 -89
- package/dist/units.mjs +215 -180
- package/dist/usage.mjs +138 -38
- package/dist/validation-checks.mjs +121 -38
- package/dist/validation-inputs.mjs +187 -78
- package/dist/validation.mjs +268 -102
- package/dist/verification/browser.mjs +27 -5
- package/dist/verification.mjs +711 -187
- package/docs/ADS.md +100 -89
- package/docs/ARCHITECTURE.md +353 -159
- package/docs/BEHAVIORS.md +33 -28
- package/docs/CACHING.md +55 -11
- package/docs/CHANGELOG.md +358 -17
- package/docs/COMPARISON.md +1 -1
- package/docs/CONTRACTS.md +22 -29
- package/docs/DESIGN-REFERENCES.md +40 -0
- package/docs/GUIDE.md +313 -292
- package/docs/MCP.md +261 -439
- package/docs/SPATIAL-CHECKS.md +69 -0
- package/docs/benchmarks/README.md +39 -0
- package/package.json +42 -34
- package/dist/browser-audit.mjs +0 -424
- package/dist/contract-migration.mjs +0 -110
- package/dist/create.mjs +0 -48
- package/dist/lint-config.mjs +0 -48
- package/dist/mcp/draft-exports.mjs +0 -40
- package/dist/mcp/edit-preparation.mjs +0 -115
- 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 -88
- 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 -415
- 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 -411
- package/dist/skills/ads-break-ui/references/captures.md +0 -160
- package/dist/skills/ads-break-ui/references/contracts.md +0 -284
- package/dist/skills/ads-break-ui/references/design-data.md +0 -354
- package/dist/skills/ads-break-ui/references/drafts.md +0 -178
- package/dist/skills/ads-break-ui/references/evidence.md +0 -128
- package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -154
- 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 -96
- 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 -162
- package/dist/skills/ads-break-ui/references/verification.md +0 -58
- package/dist/skills/ads-break-ui/references/workflows.md +0 -83
- 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 -388
- 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 -411
- package/dist/skills/ads-motion/references/captures.md +0 -160
- package/dist/skills/ads-motion/references/contracts.md +0 -284
- package/dist/skills/ads-motion/references/design-data.md +0 -354
- package/dist/skills/ads-motion/references/drafts.md +0 -178
- package/dist/skills/ads-motion/references/evidence.md +0 -128
- package/dist/skills/ads-motion/references/guarded-editing.md +0 -154
- 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 -96
- 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 -162
- package/dist/skills/ads-motion/references/verification.md +0 -39
- package/dist/skills/ads-motion/references/workflows.md +0 -83
- package/dist/skills/ads-port/references/reporting.md +0 -101
- 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.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.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.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.tsx +0 -18
- package/dist/starters/react/design-system/review/index.ts +0 -5
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- 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/scenarios.mjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { withProjectAnalysis } from "./analysis/standalone.mjs";
|
|
2
|
+
import { currentAnalysis } from "./analysis/context.mjs";
|
|
3
|
+
import { eachChild, filterAsync, mapAsync } from "./analysis/queries.mjs";
|
|
1
4
|
import path from "node:path";
|
|
2
5
|
import { existsSync } from "node:fs";
|
|
3
|
-
import ts from "
|
|
6
|
+
import ts from "./analysis/syntax.mjs";
|
|
4
7
|
import { publicApi, scenarioApi } from "./public-api.mjs";
|
|
5
8
|
import { uiOperation } from "./ui-framework.mjs";
|
|
6
9
|
import { isDevelopmentFile, isInside, isScenarioFile, scenarioIdentity, sourceFiles } from "./config.mjs";
|
|
10
|
+
import { cachedProgram } from "./program-cache.mjs";
|
|
7
11
|
import { projectCompilerOptions } from "./boundaries.mjs";
|
|
8
12
|
import { inspectTokens } from "./tokens.mjs";
|
|
9
13
|
import { isSharedToken } from "./token-policy.mjs";
|
|
@@ -14,211 +18,423 @@ import { inspectRuntimeContracts } from "./runtime-contracts.mjs";
|
|
|
14
18
|
import { inspectUnitContracts } from "./unit-contracts.mjs";
|
|
15
19
|
import { inspectPaintContracts } from "./paint-contracts.mjs";
|
|
16
20
|
import { createScenarioGroups } from "./scenario-groups.mjs";
|
|
21
|
+
import { foundationViews } from "./foundation-views.mjs";
|
|
17
22
|
|
|
18
23
|
export const scenarioArtifact = (root, id) => path.join(root, ".ds/scenarios", id, "index.html");
|
|
19
24
|
|
|
20
|
-
function literal(node, checker, seen = new Set()) {
|
|
25
|
+
async function literal(node, checker, seen = new Set()) {
|
|
21
26
|
while (node && (ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isParenthesizedExpression(node))) node = node.expression;
|
|
22
27
|
if (!node || seen.has(node)) return undefined;
|
|
23
28
|
seen = new Set([...seen, node]);
|
|
24
29
|
if (node && ts.isStringLiteralLike(node)) return node.text;
|
|
25
30
|
if (node?.kind === ts.SyntaxKind.TrueKeyword) return true;
|
|
26
31
|
if (node?.kind === ts.SyntaxKind.FalseKeyword) return false;
|
|
27
|
-
if (node && ts.isArrayLiteralExpression(node)) return node.elements
|
|
28
|
-
if (node && ts.isObjectLiteralExpression(node))
|
|
32
|
+
if (node && ts.isArrayLiteralExpression(node)) return mapAsync(node.elements, async (item) => literal(item, checker, seen));
|
|
33
|
+
if (node && ts.isObjectLiteralExpression(node))
|
|
34
|
+
return Object.fromEntries(
|
|
35
|
+
await mapAsync(node.properties, async (item) =>
|
|
36
|
+
ts.isPropertyAssignment(item) && item.name && (ts.isIdentifier(item.name) || ts.isStringLiteralLike(item.name))
|
|
37
|
+
? [item.name.text, await literal(item.initializer, checker, seen)]
|
|
38
|
+
: ["invalid", undefined],
|
|
39
|
+
),
|
|
40
|
+
);
|
|
29
41
|
if (checker && (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node))) {
|
|
30
|
-
let symbol = checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node);
|
|
31
|
-
if (symbol?.flags & ts.SymbolFlags.Alias) symbol = checker.getAliasedSymbol(symbol);
|
|
42
|
+
let symbol = await checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node);
|
|
43
|
+
if (symbol?.flags & ts.SymbolFlags.Alias) symbol = await checker.getAliasedSymbol(symbol);
|
|
32
44
|
const declaration = symbol?.valueDeclaration;
|
|
33
|
-
if (declaration && (ts.isPropertyAssignment(declaration) || ts.isVariableDeclaration(declaration) && declaration.parent.flags & ts.NodeFlags.Const))
|
|
45
|
+
if (declaration && (ts.isPropertyAssignment(declaration) || (ts.isVariableDeclaration(declaration) && declaration.parent.flags & ts.NodeFlags.Const)))
|
|
46
|
+
return literal(declaration.initializer, checker, seen);
|
|
34
47
|
}
|
|
35
48
|
return undefined;
|
|
36
49
|
}
|
|
37
50
|
|
|
38
|
-
export function publicUi(program, options) {
|
|
39
|
-
return publicApi(program, options).filter(item => item.kind !== "controllers");
|
|
51
|
+
export async function publicUi(program, options) {
|
|
52
|
+
return (await publicApi(program, options)).filter((item) => item.kind !== "controllers");
|
|
40
53
|
}
|
|
41
54
|
|
|
42
55
|
/** Discover metadata statically. The MCP process never imports scenario modules. */
|
|
43
|
-
export function inspectScenarios(options, suppliedProgram) {
|
|
56
|
+
export async function inspectScenarios(options, suppliedProgram) {
|
|
57
|
+
if (!currentAnalysis()?.provideProgram) return withProjectAnalysis(options.root, async () => inspectScenarios(options, suppliedProgram));
|
|
44
58
|
const { root, dsRoot } = options;
|
|
45
59
|
const files = sourceFiles(dsRoot).filter(isScenarioFile);
|
|
46
|
-
const contracts = inspectUnitContracts(options, suppliedProgram);
|
|
47
|
-
const program =
|
|
48
|
-
|
|
60
|
+
const contracts = await inspectUnitContracts(options, suppliedProgram);
|
|
61
|
+
const program =
|
|
62
|
+
suppliedProgram ??
|
|
63
|
+
contracts.program ??
|
|
64
|
+
(await cachedProgram(
|
|
65
|
+
`scenarios:${options.root}`,
|
|
66
|
+
[path.join(dsRoot, options.config.publicEntry), path.join(dsRoot, options.config.reviewEntry), ...files],
|
|
67
|
+
{ ...(await projectCompilerOptions(options)), allowJs: true },
|
|
68
|
+
));
|
|
69
|
+
const apis = await scenarioApi(program, options);
|
|
49
70
|
const duplicate = apis.find((item, index) => apis.some((other, otherIndex) => index !== otherIndex && item.name === other.name));
|
|
50
|
-
const known = new Map(apis.filter(item => item.kind !== "controllers").map((item) => [item.name, item]));
|
|
71
|
+
const known = new Map(apis.filter((item) => item.kind !== "controllers").map((item) => [item.name, item]));
|
|
51
72
|
const checker = program.getTypeChecker();
|
|
52
|
-
const declarativeParts = inspectRuntimeContracts(options, program).parts;
|
|
53
|
-
const contractDeclarations=inspectUnitContracts(options).contracts;
|
|
54
|
-
const bindingTrace = contractDeclarations.some(contract=>contract.paintInputs?.length) ? createScenarioTrace(program, options) : null;
|
|
55
|
-
const behaviorApis = new Map(publicApi(program, options).filter(item => !item.renderable && item.behavioral).map(item => [item.name, item]));
|
|
56
|
-
const tokenInventory = inspectTokens(root, options);
|
|
57
|
-
const tokenNames = new Set(tokenInventory.tokens.map(token => token.name));
|
|
58
|
-
const units = inspectUnits(options);
|
|
73
|
+
const declarativeParts = (await inspectRuntimeContracts(options, program)).parts;
|
|
74
|
+
const contractDeclarations = (await inspectUnitContracts(options)).contracts;
|
|
75
|
+
const bindingTrace = contractDeclarations.some((contract) => contract.paintInputs?.length) ? await createScenarioTrace(program, options) : null;
|
|
76
|
+
const behaviorApis = new Map((await publicApi(program, options)).filter((item) => !item.renderable && item.behavioral).map((item) => [item.name, item]));
|
|
77
|
+
const tokenInventory = await inspectTokens(root, options);
|
|
78
|
+
const tokenNames = new Set(tokenInventory.tokens.map((token) => token.name));
|
|
79
|
+
const units = await inspectUnits(options);
|
|
59
80
|
const scenarioGroup = createScenarioGroups(options);
|
|
60
81
|
const scenarios = [];
|
|
61
|
-
const diagnostics = [
|
|
82
|
+
const diagnostics = [
|
|
83
|
+
...(await inspectUnitContracts(options)).diagnostics,
|
|
84
|
+
...(await inspectRuntimeContracts(options, program)).diagnostics,
|
|
85
|
+
...(await inspectPaintContracts(options)).diagnostics,
|
|
86
|
+
];
|
|
62
87
|
const ids = new Set();
|
|
63
88
|
function report(file, message, node, detail = {}) {
|
|
64
89
|
const position = node?.getSourceFile().getLineAndCharacterOfPosition(node.getStart());
|
|
65
|
-
diagnostics.push({
|
|
90
|
+
diagnostics.push({
|
|
91
|
+
file: path.relative(root, file).replaceAll("\\", "/"),
|
|
92
|
+
rule: "scenario-contract",
|
|
93
|
+
line: (position?.line ?? 0) + 1,
|
|
94
|
+
column: (position?.character ?? 0) + 1,
|
|
95
|
+
message,
|
|
96
|
+
...detail,
|
|
97
|
+
});
|
|
66
98
|
}
|
|
67
|
-
if (duplicate)
|
|
99
|
+
if (duplicate)
|
|
100
|
+
report(
|
|
101
|
+
path.join(dsRoot, options.config.reviewEntry),
|
|
102
|
+
`Review export ${duplicate.name} collides with the production API. Use a distinct development export so scenario coverage is unambiguous.`,
|
|
103
|
+
);
|
|
68
104
|
for (const file of files) {
|
|
69
105
|
const relative = path.relative(dsRoot, file).replaceAll("\\", "/");
|
|
70
106
|
let kind = isInside(path.join(dsRoot, options.config.tokenDir), file) ? "tokens" : relative.split("/")[0];
|
|
71
|
-
if (!["brand", "tokens", "components", "patterns", "composition"].includes(kind)) {
|
|
107
|
+
if (!["brand", "tokens", "components", "patterns", "composition"].includes(kind)) {
|
|
108
|
+
report(file, "Scenarios live under brand/, beside tokens/components/patterns or under composition/, not inside showcase pages.");
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
72
111
|
let id = scenarioIdentity(file, dsRoot);
|
|
73
|
-
const source = program.getSourceFile(file);
|
|
74
|
-
if (!source) {
|
|
112
|
+
const source = await program.getSourceFile(file);
|
|
113
|
+
if (!source) {
|
|
114
|
+
report(file, "Cannot inspect scenario source.");
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
75
117
|
let metadata, metadataExpression;
|
|
76
118
|
let entry = false;
|
|
77
119
|
for (const node of source.statements) {
|
|
78
120
|
if (ts.isExportAssignment(node) || node.modifiers?.some((item) => item.kind === ts.SyntaxKind.DefaultKeyword)) entry = true;
|
|
79
121
|
if (ts.isVariableStatement(node) && node.modifiers?.some((item) => item.kind === ts.SyntaxKind.ExportKeyword)) {
|
|
80
|
-
for (const declaration of node.declarationList.declarations)
|
|
122
|
+
for (const declaration of node.declarationList.declarations)
|
|
123
|
+
if (ts.isIdentifier(declaration.name) && declaration.name.text === "scenario") {
|
|
124
|
+
metadataExpression = declaration.initializer;
|
|
125
|
+
metadata = await literal(metadataExpression, checker);
|
|
126
|
+
}
|
|
81
127
|
}
|
|
82
128
|
}
|
|
83
|
-
if(metadata?.id!==undefined) {
|
|
84
|
-
const owner=units.owner(relative);
|
|
85
|
-
if
|
|
86
|
-
|
|
129
|
+
if (metadata?.id !== undefined) {
|
|
130
|
+
const owner = units.owner(relative);
|
|
131
|
+
if (
|
|
132
|
+
typeof metadata.id !== "string" ||
|
|
133
|
+
metadata.id.length > 256 ||
|
|
134
|
+
!/^[\w-]+(?:[/.][\w-]+)*$/.test(metadata.id) ||
|
|
135
|
+
!owner ||
|
|
136
|
+
!(metadata.id === owner || metadata.id.startsWith(owner + "/") || metadata.id.startsWith(owner + "."))
|
|
137
|
+
)
|
|
138
|
+
report(file, "Scenario id must be a safe stable identity inside this owner; it cannot capture another layer/owner.", metadataExpression, {
|
|
139
|
+
entry: "id",
|
|
140
|
+
});
|
|
141
|
+
else id = metadata.id;
|
|
142
|
+
}
|
|
143
|
+
if (id.length > 256) {
|
|
144
|
+
report(file, "Scenario paths must fit within 256 characters.");
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (ids.has(id)) {
|
|
148
|
+
report(file, `Duplicate scenario id ${id}. Use one entrypoint per identity.`);
|
|
149
|
+
continue;
|
|
87
150
|
}
|
|
88
|
-
if (id.length > 256) { report(file, "Scenario paths must fit within 256 characters."); continue; }
|
|
89
|
-
if (ids.has(id)) { report(file, `Duplicate scenario id ${id}. Use one entrypoint per identity.`); continue; }
|
|
90
151
|
ids.add(id);
|
|
91
152
|
if (metadata?.kind !== undefined) {
|
|
92
153
|
const owner = units.owner(relative);
|
|
93
|
-
if (metadata.kind !== "tokens" || owner !== "tokens")
|
|
154
|
+
if (metadata.kind !== "tokens" || owner !== "tokens")
|
|
155
|
+
report(
|
|
156
|
+
file,
|
|
157
|
+
"Token previews belong in the shared Data token directory. Components and patterns map shared tokens; they do not own independent token catalogues.",
|
|
158
|
+
await entryNode("kind"),
|
|
159
|
+
{ entry: "kind" },
|
|
160
|
+
);
|
|
94
161
|
else kind = "tokens";
|
|
95
162
|
}
|
|
96
163
|
if (!entry) report(file, "Export a default independently mountable scenario entrypoint.");
|
|
97
|
-
const module = checker.getSymbolAtLocation(source);
|
|
98
|
-
const defaultExport = module && checker.getExportsOfModule(module).find(item => item.name === "default");
|
|
164
|
+
const module = await checker.getSymbolAtLocation(source);
|
|
165
|
+
const defaultExport = module && (await checker.getExportsOfModule(module)).find((item) => item.name === "default");
|
|
99
166
|
if (defaultExport) {
|
|
100
|
-
const type = checker.getTypeOfSymbolAtLocation(defaultExport, source);
|
|
101
|
-
const calls = [...type.getCallSignatures(), ...type.getConstructSignatures()];
|
|
102
|
-
if (!calls.length && !(type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)))
|
|
167
|
+
const type = await checker.getTypeOfSymbolAtLocation(defaultExport, source);
|
|
168
|
+
const calls = [...(await type.getCallSignatures()), ...(await type.getConstructSignatures())];
|
|
169
|
+
if (!calls.length && !(type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)))
|
|
170
|
+
report(file, "Export a mountable component as default, not an already-created element or data object.");
|
|
103
171
|
for (const call of calls) {
|
|
104
172
|
const props = call.parameters[0];
|
|
105
|
-
const optional = props?.declarations?.some(item => item.initializer || item.questionToken);
|
|
106
|
-
if (
|
|
173
|
+
const optional = props?.declarations?.some((item) => item.initializer || item.questionToken);
|
|
174
|
+
if (
|
|
175
|
+
props &&
|
|
176
|
+
!optional &&
|
|
177
|
+
(await (await checker.getTypeOfSymbolAtLocation(props, source)).getProperties()).some((item) => !(item.flags & ts.SymbolFlags.Optional))
|
|
178
|
+
)
|
|
179
|
+
report(file, "Scenario entrypoints cannot require caller props. Supply required inputs in the colocated fixture adapter.");
|
|
107
180
|
}
|
|
108
181
|
}
|
|
109
|
-
const fixtureBase =
|
|
110
|
-
const fixture = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs", ".json"].map(extension => fixtureBase + extension).find(existsSync);
|
|
111
|
-
if (!fixture) report(file, "Keep this scenario's inputs beside it
|
|
112
|
-
function entryNode(field, index) {
|
|
182
|
+
const fixtureBase = file.replace(/\.ads\.scenario\.[^.]+$/, ".ads.fixture");
|
|
183
|
+
const fixture = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs", ".json"].map((extension) => fixtureBase + extension).find(existsSync);
|
|
184
|
+
if (!fixture) report(file, "Keep this scenario's inputs beside it in <Owner>.ads.fixture.ts. An empty fixture is valid for a component without inputs.");
|
|
185
|
+
async function entryNode(field, index) {
|
|
113
186
|
let value = metadataExpression;
|
|
114
187
|
const seen = new Set();
|
|
115
188
|
while (value && !seen.has(value)) {
|
|
116
189
|
seen.add(value);
|
|
117
190
|
if (ts.isSatisfiesExpression(value) || ts.isAsExpression(value) || ts.isParenthesizedExpression(value)) value = value.expression;
|
|
118
|
-
else if (ts.isIdentifier(value)) {
|
|
119
|
-
|
|
191
|
+
else if (ts.isIdentifier(value)) {
|
|
192
|
+
let symbol = await checker.getSymbolAtLocation(value);
|
|
193
|
+
if (symbol?.flags & ts.SymbolFlags.Alias) symbol = await checker.getAliasedSymbol(symbol);
|
|
194
|
+
value = symbol?.valueDeclaration?.initializer;
|
|
195
|
+
} else break;
|
|
120
196
|
}
|
|
121
|
-
const property =
|
|
122
|
-
|
|
197
|
+
const property =
|
|
198
|
+
value &&
|
|
199
|
+
ts.isObjectLiteralExpression(value) &&
|
|
200
|
+
value.properties.find(
|
|
201
|
+
(item) => ts.isPropertyAssignment(item) && (ts.isIdentifier(item.name) || ts.isStringLiteralLike(item.name)) && item.name.text === field,
|
|
202
|
+
);
|
|
203
|
+
return index !== undefined && property && ts.isArrayLiteralExpression(property.initializer)
|
|
204
|
+
? property.initializer.elements[index]
|
|
205
|
+
: (property?.initializer ?? metadataExpression);
|
|
123
206
|
}
|
|
124
207
|
if (!metadata) {
|
|
125
|
-
report(
|
|
208
|
+
report(
|
|
209
|
+
file,
|
|
210
|
+
"Scenario metadata is not statically readable. Render coverage is not established until this prerequisite is repaired.",
|
|
211
|
+
metadataExpression,
|
|
212
|
+
{ coverage: "not-established", owner: units.owner(relative) },
|
|
213
|
+
);
|
|
126
214
|
continue;
|
|
127
215
|
}
|
|
128
|
-
for(const field of Object.keys(metadata))
|
|
216
|
+
for (const field of Object.keys(metadata))
|
|
217
|
+
if (!["id", "title", "kind", "covers", "exercises", "tokens", "samples", "captureTargets"].includes(field))
|
|
218
|
+
report(file, `Unknown scenario field ${field}.`, await entryNode(field), { entry: field });
|
|
129
219
|
const group = scenarioGroup(file, units.owner(relative));
|
|
130
|
-
if(typeof metadata.title!=="string"
|
|
131
|
-
report(file,"Scenario title must be a nonempty static string; independent render evidence is retained.",entryNode("title"),{entry:"title"});
|
|
132
|
-
metadata.title=id;
|
|
220
|
+
if (typeof metadata.title !== "string" || !metadata.title.trim()) {
|
|
221
|
+
report(file, "Scenario title must be a nonempty static string; independent render evidence is retained.", await entryNode("title"), { entry: "title" });
|
|
222
|
+
metadata.title = id;
|
|
133
223
|
}
|
|
134
|
-
if(!Array.isArray(metadata.covers)
|
|
135
|
-
report(
|
|
136
|
-
|
|
224
|
+
if (!Array.isArray(metadata.covers) || !metadata.covers.length) {
|
|
225
|
+
report(
|
|
226
|
+
file,
|
|
227
|
+
"Scenario covers must be a nonempty static array naming rendered public UI. Coverage is not established until repaired.",
|
|
228
|
+
await entryNode("covers"),
|
|
229
|
+
{ entry: "covers", coverage: "not-established", owner: units.owner(relative) },
|
|
230
|
+
);
|
|
231
|
+
metadata.covers = [];
|
|
137
232
|
}
|
|
138
|
-
if
|
|
139
|
-
|
|
233
|
+
if (
|
|
234
|
+
Object.hasOwn(metadata, "tokens") &&
|
|
235
|
+
(!Array.isArray(metadata.tokens) || metadata.tokens.some((name) => typeof name !== "string" || !name.startsWith("--")))
|
|
236
|
+
) {
|
|
237
|
+
report(file, "Scenario tokens must be a static list of real token names.", await entryNode("tokens"), { entry: "tokens" });
|
|
238
|
+
metadata.tokens = [];
|
|
140
239
|
}
|
|
141
|
-
if(
|
|
142
|
-
|
|
240
|
+
if (
|
|
241
|
+
(kind === "tokens" && Object.hasOwn(metadata, "tokens")) ||
|
|
242
|
+
(kind === "tokens" && !validTokenSamples(metadata.samples)) ||
|
|
243
|
+
(Object.hasOwn(metadata, "samples") && !validTokenSamples(metadata.samples))
|
|
244
|
+
) {
|
|
245
|
+
report(
|
|
246
|
+
file,
|
|
247
|
+
"Token scenarios need samples: fixture.samples, a literal list of { token, property, probe } real CSS bindings. Printing values or covers: [] is incomplete.",
|
|
248
|
+
await entryNode("samples"),
|
|
249
|
+
{ entry: "samples" },
|
|
250
|
+
);
|
|
251
|
+
delete metadata.samples;
|
|
143
252
|
}
|
|
144
253
|
const covers = [];
|
|
145
254
|
for (const [index, name] of metadata.covers.entries()) {
|
|
146
255
|
const api = typeof name === "string" && known.get(name);
|
|
147
|
-
if (!api?.renderable || declarativeParts.some(part=>part.apiName
|
|
256
|
+
if (!api?.renderable || declarativeParts.some((part) => part.apiName === name))
|
|
257
|
+
report(
|
|
258
|
+
file,
|
|
259
|
+
`Scenario covers[${index}] ${JSON.stringify(name) ?? "(unresolved)"} ${api ? "is not independently rendered UI. Use exercises for a behavioral or registered declarative API." : "does not name a known public UI export."} Independent valid render evidence is retained.`,
|
|
260
|
+
await entryNode("covers", index),
|
|
261
|
+
{ entry: `covers[${index}]`, ...(typeof name === "string" ? { api: name } : {}), reason: api ? "wrong-api-role" : "unknown-api" },
|
|
262
|
+
);
|
|
148
263
|
else covers.push(name);
|
|
149
264
|
}
|
|
150
265
|
metadata = { ...metadata, covers };
|
|
151
|
-
if (kind === "tokens" && !covers.some(name => ["patterns", "review"].includes(known.get(name)?.kind)))
|
|
266
|
+
if (kind === "tokens" && !covers.some((name) => ["patterns", "review"].includes(known.get(name)?.kind)))
|
|
267
|
+
report(file, "Token covers must name the real development review renderer or product pattern consuming samples.", await entryNode("covers"));
|
|
152
268
|
// A bad behavioral entry must fail validation without erasing independent
|
|
153
269
|
// render evidence and manufacturing missing-coverage errors for real UI.
|
|
154
270
|
const exercises = [];
|
|
155
271
|
let captureTargets;
|
|
156
272
|
if (Object.hasOwn(metadata, "captureTargets")) {
|
|
157
|
-
if (
|
|
273
|
+
if (
|
|
274
|
+
!metadata.captureTargets ||
|
|
275
|
+
typeof metadata.captureTargets !== "object" ||
|
|
276
|
+
Array.isArray(metadata.captureTargets) ||
|
|
277
|
+
Object.keys(metadata.captureTargets).length > 20 ||
|
|
278
|
+
Object.entries(metadata.captureTargets).some(
|
|
279
|
+
([name, selector]) => !/^[a-zA-Z0-9][\w.-]{0,79}$/.test(name) || typeof selector !== "string" || !selector.trim() || selector.length > 500,
|
|
280
|
+
)
|
|
281
|
+
)
|
|
282
|
+
report(
|
|
283
|
+
file,
|
|
284
|
+
"captureTargets must map up to 20 named targets to nonempty CSS selectors (max 500 characters), scoped to this scenario's App iframe. Each selected target must resolve to exactly one visible element at capture time.",
|
|
285
|
+
);
|
|
158
286
|
else captureTargets = metadata.captureTargets;
|
|
159
287
|
}
|
|
160
288
|
if (Object.hasOwn(metadata, "exercises")) {
|
|
161
289
|
if (!Array.isArray(metadata.exercises)) report(file, "Scenario exercises must be a static array naming public behavioral APIs.");
|
|
162
|
-
else
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
290
|
+
else
|
|
291
|
+
for (const [index, name] of metadata.exercises.entries()) {
|
|
292
|
+
if (typeof name !== "string")
|
|
293
|
+
report(
|
|
294
|
+
file,
|
|
295
|
+
`Scenario exercises[${index}] must name a public behavioral API, not ${JSON.stringify(name) ?? "an unresolved value"}.`,
|
|
296
|
+
await entryNode("exercises", index),
|
|
297
|
+
{ entry: `exercises[${index}]` },
|
|
298
|
+
);
|
|
299
|
+
else if (!behaviorApis.has(name) && !declarativeParts.some((part) => part.apiName === name))
|
|
300
|
+
report(
|
|
301
|
+
file,
|
|
302
|
+
`Scenario exercises[${index}] ${JSON.stringify(name)} is not a recognized public behavioral API. Use a public callable function, hook or controller; rendered UI belongs in covers. Discover the project's exports before declaring exercises.`,
|
|
303
|
+
await entryNode("exercises", index),
|
|
304
|
+
{ entry: `exercises[${index}]`, api: name },
|
|
305
|
+
);
|
|
306
|
+
else exercises.push(name);
|
|
307
|
+
}
|
|
167
308
|
}
|
|
168
|
-
if (!["composition", "tokens", "brand"].includes(kind) && metadata.covers.some((name) => known.get(name).kind !== kind))
|
|
169
|
-
|
|
170
|
-
|
|
309
|
+
if (!["composition", "tokens", "brand"].includes(kind) && metadata.covers.some((name) => known.get(name).kind !== kind))
|
|
310
|
+
report(file, "Component scenarios cover primitives; pattern scenarios cover patterns. Use composition/ for larger interfaces.");
|
|
311
|
+
const tokens = [...new Set([...(metadata.tokens ?? []), ...(metadata.samples ?? []).map((sample) => sample.token)])];
|
|
312
|
+
for (const name of tokens)
|
|
313
|
+
if (!tokenNames.has(name))
|
|
314
|
+
diagnostics.push({
|
|
315
|
+
file: path.relative(root, file).replaceAll("\\", "/"),
|
|
316
|
+
rule: "token-scenario-reference",
|
|
317
|
+
line: 1,
|
|
318
|
+
column: 1,
|
|
319
|
+
message: `Scenario references undeclared token ${name}. Use a real token from its defining owner.`,
|
|
320
|
+
});
|
|
171
321
|
if (kind === "tokens") {
|
|
172
322
|
const owner = units.owner(relative);
|
|
173
|
-
for (const name of tokens)
|
|
323
|
+
for (const name of tokens)
|
|
324
|
+
if (tokenInventory.tokens.find((token) => token.name === name)?.owner !== owner)
|
|
325
|
+
report(
|
|
326
|
+
file,
|
|
327
|
+
`Token ${name} needs a preview beside its defining owner. All design tokens and their previews belong under the configured shared token directory.`,
|
|
328
|
+
);
|
|
174
329
|
}
|
|
175
330
|
|
|
176
331
|
const reachable = new Set(metadata.covers);
|
|
177
|
-
function findBindings(node) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
332
|
+
async function findBindings(node) {
|
|
333
|
+
if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) for (const name of (await bindingTrace.traceRenders(node)).rendered) reachable.add(name);
|
|
334
|
+
await eachChild(node, findBindings);
|
|
335
|
+
}
|
|
336
|
+
if (bindingTrace) await findBindings(source);
|
|
337
|
+
const paintBindings = (await inspectRuntimeContracts(options, program)).bindings
|
|
338
|
+
.filter((binding) => reachable.has(binding.scope.apiName))
|
|
339
|
+
.map((binding) => ({
|
|
340
|
+
owner: binding.unit,
|
|
341
|
+
name: binding.name,
|
|
342
|
+
scope: binding.scope.selector,
|
|
343
|
+
prefix: binding.prefix,
|
|
344
|
+
suffix: binding.suffix,
|
|
345
|
+
themes: options.config.themes.map((theme) => theme.name),
|
|
346
|
+
tokens: tokenInventory.tokens.filter((token) => !token.owner || token.owner === "tokens" || token.owner === binding.unit).map((token) => token.name),
|
|
347
|
+
}));
|
|
348
|
+
const paintAudit = contractDeclarations.some((contract) => contract.paintInputs?.some((input) => reachable.has(input.apiName)));
|
|
349
|
+
scenarios.push({
|
|
350
|
+
id,
|
|
351
|
+
kind,
|
|
352
|
+
title: metadata.title,
|
|
353
|
+
...(group ? { group } : {}),
|
|
354
|
+
...(fixture ? { fixture: path.relative(root, fixture).replaceAll("\\", "/") } : {}),
|
|
355
|
+
covers: [...new Set(metadata.covers)],
|
|
356
|
+
// The owner folders of the covered component/pattern APIs. Previews mark
|
|
357
|
+
// what these owners render as the subject; everything else is framing.
|
|
358
|
+
subjects: [
|
|
359
|
+
...new Set(
|
|
360
|
+
metadata.covers
|
|
361
|
+
.map((name) => known.get(name))
|
|
362
|
+
.filter((api) => api?.renderable && ["components", "patterns"].includes(api.kind))
|
|
363
|
+
.map((api) => {
|
|
364
|
+
// A folder owner (Owner/Owner.tsx or Owner/index.tsx) is its folder;
|
|
365
|
+
// a flat owner (components/Box.tsx) is its file without extension.
|
|
366
|
+
const file = path.relative(root, api.file).replaceAll("\\", "/"), folder = path.posix.dirname(file);
|
|
367
|
+
const base = path.posix.basename(file).replace(/\.[^.]+$/, "");
|
|
368
|
+
return base === "index" || base === path.posix.basename(folder) ? folder : file.replace(/\.[^.]+$/, "");
|
|
369
|
+
}),
|
|
370
|
+
),
|
|
371
|
+
],
|
|
372
|
+
...(captureTargets ? { captureTargets } : {}),
|
|
373
|
+
...(Object.hasOwn(metadata, "exercises") ? { exercises: [...new Set(exercises)] } : {}),
|
|
374
|
+
tokens,
|
|
375
|
+
...(metadata.samples ? { samples: metadata.samples } : {}),
|
|
376
|
+
...(paintBindings.length ? { paintBindings } : {}),
|
|
377
|
+
...(paintAudit ? { paintAudit: true } : {}),
|
|
378
|
+
file: path.relative(root, file).replaceAll("\\", "/"),
|
|
379
|
+
artifact: path.relative(root, scenarioArtifact(root, id)).replaceAll("\\", "/"),
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
const foundations = foundationViews(options, tokenInventory);
|
|
383
|
+
diagnostics.push(...foundations.diagnostics);
|
|
384
|
+
for (const view of foundations.views) {
|
|
385
|
+
if (ids.has(view.id))
|
|
386
|
+
report(
|
|
387
|
+
path.join(root, scenarios.find((item) => item.id === view.id).file),
|
|
388
|
+
`Remove the render-only ${view.id} scenario. ADS owns this foundation view from definitions and catalog.ads.json.`,
|
|
389
|
+
);
|
|
390
|
+
else scenarios.push(view);
|
|
182
391
|
}
|
|
183
|
-
return { scenarios: scenarios.sort((a, b) => a.id.localeCompare(b.id)), diagnostics };
|
|
392
|
+
return { scenarios: scenarios.sort((a, b) => (a.sortKey ?? a.id).localeCompare(b.sortKey ?? b.id)), diagnostics };
|
|
184
393
|
}
|
|
185
394
|
|
|
186
|
-
export function inspectScenarioCoverage(options, program, report, advise = () => {}, trace
|
|
187
|
-
|
|
188
|
-
|
|
395
|
+
export async function inspectScenarioCoverage(options, program, report, advise = () => {}, trace) {
|
|
396
|
+
if (trace === undefined) trace = await createScenarioTrace(program, options);
|
|
397
|
+
const registry = await inspectScenarios(options, program);
|
|
398
|
+
for (const { file, rule, message, line, column, ...detail } of registry.diagnostics)
|
|
399
|
+
report(path.join(options.root, file), rule, message, line, column, detail);
|
|
189
400
|
const checker = program.getTypeChecker();
|
|
190
|
-
const ui = publicUi(program, options);
|
|
191
|
-
const parts = inspectRuntimeContracts(options, program).parts;
|
|
192
|
-
function symbolOf(expression) {
|
|
193
|
-
while (
|
|
401
|
+
const ui = await publicUi(program, options);
|
|
402
|
+
const parts = (await inspectRuntimeContracts(options, program)).parts;
|
|
403
|
+
async function symbolOf(expression) {
|
|
404
|
+
while (
|
|
405
|
+
expression &&
|
|
406
|
+
(ts.isParenthesizedExpression(expression) || ts.isAsExpression(expression) || ts.isSatisfiesExpression(expression) || ts.isNonNullExpression(expression))
|
|
407
|
+
)
|
|
408
|
+
expression = expression.expression;
|
|
194
409
|
if (!expression) return null;
|
|
195
410
|
if (ts.isElementAccessExpression(expression) && expression.argumentExpression && ts.isStringLiteralLike(expression.argumentExpression)) {
|
|
196
|
-
return checker.getPropertyOfType(checker.getTypeAtLocation(expression.expression), expression.argumentExpression.text);
|
|
411
|
+
return checker.getPropertyOfType(await checker.getTypeAtLocation(expression.expression), expression.argumentExpression.text);
|
|
197
412
|
}
|
|
198
413
|
return checker.getSymbolAtLocation(expression);
|
|
199
414
|
}
|
|
200
|
-
function canonical(symbol, seen = new Set()) {
|
|
415
|
+
async function canonical(symbol, seen = new Set()) {
|
|
201
416
|
if (!symbol || seen.has(symbol)) return null;
|
|
202
417
|
seen.add(symbol);
|
|
203
|
-
if (symbol.flags & ts.SymbolFlags.Alias) return canonical(checker.getAliasedSymbol(symbol), seen);
|
|
418
|
+
if (symbol.flags & ts.SymbolFlags.Alias) return canonical(await checker.getAliasedSymbol(symbol), seen);
|
|
204
419
|
for (const declaration of symbol.declarations ?? []) {
|
|
205
420
|
if (ts.isVariableDeclaration(declaration) && declaration.initializer) {
|
|
206
|
-
const target = symbolOf(declaration.initializer);
|
|
421
|
+
const target = await symbolOf(declaration.initializer);
|
|
207
422
|
if (target) return canonical(target, seen);
|
|
208
423
|
}
|
|
209
424
|
if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent) && ts.isVariableDeclaration(declaration.parent.parent)) {
|
|
210
425
|
const initializer = declaration.parent.parent.initializer;
|
|
211
426
|
const key = declaration.propertyName ?? declaration.name;
|
|
212
427
|
if (initializer && (ts.isIdentifier(key) || ts.isStringLiteralLike(key))) {
|
|
213
|
-
const target = checker.getPropertyOfType(checker.getTypeAtLocation(initializer), key.text);
|
|
428
|
+
const target = await checker.getPropertyOfType(await checker.getTypeAtLocation(initializer), key.text);
|
|
214
429
|
if (target) return canonical(target, seen);
|
|
215
430
|
}
|
|
216
431
|
}
|
|
217
432
|
}
|
|
218
433
|
return symbol.declarations?.length ? symbol : null;
|
|
219
434
|
}
|
|
220
|
-
const identities = new Map(),
|
|
221
|
-
|
|
435
|
+
const identities = new Map(),
|
|
436
|
+
behaviorIdentities = new Set();
|
|
437
|
+
for (const item of await scenarioApi(program, options)) {
|
|
222
438
|
if (!identities.has(item.declaration)) identities.set(item.declaration, new Set());
|
|
223
439
|
identities.get(item.declaration).add(item.name);
|
|
224
440
|
if (item.behavioral && !item.renderable) behaviorIdentities.add(item.declaration);
|
|
@@ -226,52 +442,77 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
|
|
|
226
442
|
|
|
227
443
|
const covered = new Set();
|
|
228
444
|
const coveredTokens = new Set();
|
|
229
|
-
const tokenInventory = inspectTokens(options.root, options);
|
|
230
|
-
const declaredTokens = new Set(tokenInventory.tokens.map(token => token.name));
|
|
445
|
+
const tokenInventory = await inspectTokens(options.root, options);
|
|
446
|
+
const declaredTokens = new Set(tokenInventory.tokens.map((token) => token.name));
|
|
231
447
|
for (const scenario of registry.scenarios) {
|
|
232
|
-
|
|
448
|
+
if (scenario.foundation) {
|
|
449
|
+
for (const name of scenario.tokens) coveredTokens.add(name);
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
const source = await program.getSourceFile(path.join(options.root, scenario.file));
|
|
233
453
|
const rendered = new Set();
|
|
234
|
-
const exercised = new Set(),
|
|
454
|
+
const exercised = new Set(),
|
|
455
|
+
referencedApis = new Set(),
|
|
456
|
+
declarative = new Set();
|
|
235
457
|
const referencedTokens = new Set();
|
|
236
458
|
let samplesPassed = false;
|
|
237
459
|
const renderLimits = new Set();
|
|
238
460
|
const visited = new Set();
|
|
239
|
-
function visit(node, reached = false) {
|
|
461
|
+
async function visit(node, reached = false) {
|
|
240
462
|
if (!node || visited.has(node)) return;
|
|
241
463
|
if (!reached && ts.isFunctionDeclaration(node)) return;
|
|
242
464
|
// Calls/construction in a mounted adapter execute even when only a result
|
|
243
465
|
// property is read later. Unused literal fixture fields still do not count.
|
|
244
|
-
if (!reached && ts.isVariableDeclaration(node) && !(node.initializer && (ts.isCallExpression(node.initializer) || ts.isNewExpression(node.initializer))))
|
|
245
|
-
|
|
466
|
+
if (!reached && ts.isVariableDeclaration(node) && !(node.initializer && (ts.isCallExpression(node.initializer) || ts.isNewExpression(node.initializer))))
|
|
467
|
+
return;
|
|
468
|
+
if (!reached && (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && !ts.isCallExpression(node.parent) && !ts.isJsxExpression(node.parent))
|
|
469
|
+
return;
|
|
246
470
|
visited.add(node);
|
|
247
471
|
if (ts.isStringLiteralLike(node) && (isSharedToken(node.text) || scenario.tokens.includes(node.text))) referencedTokens.add(node.text);
|
|
248
472
|
let expression;
|
|
249
473
|
if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) expression = node.tagName;
|
|
250
|
-
if (ts.isCallExpression(node) && uiOperation(node.expression, checker) === "createElement") expression = node.arguments[0];
|
|
474
|
+
if (ts.isCallExpression(node) && (await uiOperation(node.expression, checker)) === "createElement") expression = node.arguments[0];
|
|
251
475
|
if (expression) {
|
|
252
476
|
const site = ts.isJsxOpeningElement(node) ? node.parent : node;
|
|
253
|
-
const evidence = trace.traceRenders(site);
|
|
477
|
+
const evidence = await trace.traceRenders(site);
|
|
254
478
|
for (const name of evidence.rendered) rendered.add(name);
|
|
255
479
|
for (const reason of evidence.limits) renderLimits.add(reason);
|
|
256
|
-
const symbol = canonical(symbolOf(expression));
|
|
480
|
+
const symbol = await canonical(await symbolOf(expression));
|
|
257
481
|
const names = identities.get(symbol?.valueDeclaration ?? symbol?.declarations?.[0]);
|
|
258
|
-
for (const name of names ?? []) {
|
|
259
|
-
|
|
260
|
-
|
|
482
|
+
for (const name of names ?? []) {
|
|
483
|
+
rendered.add(name);
|
|
484
|
+
exercised.add(name);
|
|
485
|
+
}
|
|
486
|
+
if (scenario.kind === "tokens" && [...(names ?? [])].some((name) => scenario.covers.includes(name))) {
|
|
487
|
+
const attributes = ts.isCallExpression(node)
|
|
488
|
+
? await literal(node.arguments[1], checker)
|
|
489
|
+
: Object.assign(
|
|
490
|
+
{},
|
|
491
|
+
...(await mapAsync(node.attributes.properties, async (attribute) =>
|
|
492
|
+
ts.isJsxSpreadAttribute(attribute)
|
|
493
|
+
? await literal(attribute.expression, checker)
|
|
494
|
+
: ts.isJsxAttribute(attribute) && ts.isIdentifier(attribute.name) && attribute.initializer && ts.isJsxExpression(attribute.initializer)
|
|
495
|
+
? { [attribute.name.text]: await literal(attribute.initializer.expression, checker) }
|
|
496
|
+
: {},
|
|
497
|
+
)),
|
|
498
|
+
);
|
|
261
499
|
if (JSON.stringify(attributes?.samples) === JSON.stringify(scenario.samples)) samplesPassed = true;
|
|
262
500
|
}
|
|
263
501
|
}
|
|
264
502
|
if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
265
503
|
let expression = node.expression;
|
|
266
504
|
if (ts.isPropertyAccessExpression(expression) && ["call", "apply"].includes(expression.name.text)) expression = expression.expression;
|
|
267
|
-
const symbol = canonical(symbolOf(expression));
|
|
505
|
+
const symbol = await canonical(await symbolOf(expression));
|
|
268
506
|
for (const name of identities.get(symbol?.valueDeclaration ?? symbol?.declarations?.[0]) ?? []) exercised.add(name);
|
|
269
507
|
// A call on an attached method exercises its public behavioral receiver.
|
|
270
508
|
// Follow symbol identities through aliases, namespaces and re-exports;
|
|
271
509
|
// a property read or an unused callback still does not establish a call.
|
|
272
|
-
while (
|
|
510
|
+
while (
|
|
511
|
+
ts.isPropertyAccessExpression(expression) ||
|
|
512
|
+
(ts.isElementAccessExpression(expression) && expression.argumentExpression && ts.isStringLiteralLike(expression.argumentExpression))
|
|
513
|
+
) {
|
|
273
514
|
expression = expression.expression;
|
|
274
|
-
const receiver = canonical(symbolOf(expression));
|
|
515
|
+
const receiver = await canonical(await symbolOf(expression));
|
|
275
516
|
const owner = receiver?.valueDeclaration ?? receiver?.declarations?.[0];
|
|
276
517
|
if (behaviorIdentities.has(owner)) for (const name of identities.get(owner) ?? []) exercised.add(name);
|
|
277
518
|
}
|
|
@@ -279,73 +520,97 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
|
|
|
279
520
|
// Follow local adapters reachable from the default entry. Production
|
|
280
521
|
// children get evidence only from bounded returned-JSX tracing above,
|
|
281
522
|
// never by scanning every reference in their implementation.
|
|
282
|
-
if (
|
|
283
|
-
|
|
523
|
+
if (
|
|
524
|
+
ts.isPropertyAccessExpression(node) ||
|
|
525
|
+
ts.isElementAccessExpression(node) ||
|
|
526
|
+
(ts.isIdentifier(node) && !(ts.isPropertyAccessExpression(node.parent) || ts.isElementAccessExpression(node.parent)))
|
|
527
|
+
) {
|
|
528
|
+
const symbol = await canonical(await symbolOf(node));
|
|
284
529
|
const declaration = symbol?.valueDeclaration;
|
|
285
530
|
for (const name of identities.get(declaration ?? symbol?.declarations?.[0]) ?? []) referencedApis.add(name);
|
|
286
|
-
if (declaration && isDevelopmentFile(declaration.getSourceFile().fileName, options)) visit(declaration, true);
|
|
531
|
+
if (declaration && isDevelopmentFile(declaration.getSourceFile().fileName, options)) await visit(declaration, true);
|
|
287
532
|
}
|
|
288
|
-
|
|
533
|
+
await eachChild(node, async (child) => visit(child, reached && (ts.isExportAssignment(node) || ts.isVariableDeclaration(node))));
|
|
289
534
|
}
|
|
290
|
-
for (const node of source.statements)
|
|
291
|
-
|
|
535
|
+
for (const node of source.statements)
|
|
536
|
+
if (ts.isExportAssignment(node) || node.modifiers?.some((item) => item.kind === ts.SyntaxKind.DefaultKeyword)) await visit(node, true);
|
|
537
|
+
if (parts.some((part) => scenario.exercises?.includes(part.apiName)))
|
|
538
|
+
for (const name of (await trace.traceEntry(source, { exercise: true })).declarative) declarative.add(name);
|
|
292
539
|
for (const name of scenario.covers) {
|
|
293
|
-
if (!rendered.has(name))
|
|
540
|
+
if (!rendered.has(name))
|
|
541
|
+
report(
|
|
542
|
+
source.fileName,
|
|
543
|
+
"scenario-render",
|
|
544
|
+
`${name} is declared in covers but has no reachable public render reference. Render it directly or through a traced parent with fixture props/defaults selecting that child. Imports, unused JSX and unknown conditional paths do not establish coverage.${renderLimits.size ? ` Source tracing could not establish: ${[...renderLimits].slice(0, 2).join(" ")}` : ""} Review the real scenario in a browser; do not hide a valid public part just to avoid coverage. See ads://guides/scenarios.`,
|
|
545
|
+
);
|
|
294
546
|
else covered.add(name);
|
|
295
547
|
}
|
|
296
548
|
for (const name of scenario.exercises ?? []) {
|
|
297
|
-
if (parts.some(part=>part.apiName===name) && !declarative.has(name))
|
|
298
|
-
|
|
299
|
-
|
|
549
|
+
if (parts.some((part) => part.apiName === name) && !declarative.has(name))
|
|
550
|
+
report(
|
|
551
|
+
source.fileName,
|
|
552
|
+
"scenario-exercise",
|
|
553
|
+
`${name} is a registered declarative API, but its child does not reach the declared consumer through a rendered parent. Imports, unused children and unrelated parent renders do not establish consumption.`,
|
|
554
|
+
);
|
|
555
|
+
else if (!exercised.has(name) && !referencedApis.has(name))
|
|
556
|
+
report(
|
|
557
|
+
source.fileName,
|
|
558
|
+
"scenario-exercise",
|
|
559
|
+
`${name} is declared in exercises but has no reachable behavioral use. Imports and unused adapters do not count.`,
|
|
560
|
+
);
|
|
561
|
+
else if (!exercised.has(name))
|
|
562
|
+
advise(
|
|
563
|
+
source.fileName,
|
|
564
|
+
"scenario-exercise-review",
|
|
565
|
+
`${name} is referenced dynamically. Verify its invocation in the registered browser/behavior checks; a reference alone does not prove execution.`,
|
|
566
|
+
);
|
|
300
567
|
}
|
|
301
|
-
for (const name of referencedTokens)
|
|
302
|
-
|
|
568
|
+
for (const name of referencedTokens)
|
|
569
|
+
if (!declaredTokens.has(name)) report(source.fileName, "token-scenario-reference", `Reachable scenario input references undeclared token ${name}.`);
|
|
570
|
+
if (scenario.kind === "tokens" && !samplesPassed)
|
|
571
|
+
report(
|
|
572
|
+
source.fileName,
|
|
573
|
+
"token-scenario-render",
|
|
574
|
+
"Pass the declared fixture.samples into a rendered review renderer's samples prop. Printing token names or reading unused fixtures is not sample coverage.",
|
|
575
|
+
);
|
|
303
576
|
for (const name of scenario.tokens) {
|
|
304
|
-
if (!referencedTokens.has(name))
|
|
577
|
+
if (!referencedTokens.has(name))
|
|
578
|
+
report(
|
|
579
|
+
source.fileName,
|
|
580
|
+
"token-scenario-render",
|
|
581
|
+
`${name} is declared in tokens but has no reachable reference from the default scenario entry. Consume the real token fixture; metadata alone does not count.`,
|
|
582
|
+
);
|
|
305
583
|
else if (scenario.kind === "tokens" && samplesPassed && declaredTokens.has(name)) coveredTokens.add(name);
|
|
306
584
|
}
|
|
307
585
|
}
|
|
308
|
-
const blockedOwners=new Set(registry.diagnostics.filter(item=>item.coverage==="not-established").map(item=>item.owner));
|
|
309
|
-
for (const item of
|
|
310
|
-
|
|
586
|
+
const blockedOwners = new Set(registry.diagnostics.filter((item) => item.coverage === "not-established").map((item) => item.owner));
|
|
587
|
+
for (const item of await filterAsync(
|
|
588
|
+
ui,
|
|
589
|
+
async (item) =>
|
|
590
|
+
item.renderable &&
|
|
591
|
+
!covered.has(item.name) &&
|
|
592
|
+
!blockedOwners.has((await inspectUnits(options)).owner((await inspectUnits(options)).relative(path.relative(options.root, item.file)))),
|
|
593
|
+
))
|
|
594
|
+
report(
|
|
595
|
+
item.file,
|
|
596
|
+
"scenario-coverage",
|
|
597
|
+
`Public UI ${item.name} needs a colocated, registered scenario render reference. Related parts may share a scenario.`,
|
|
598
|
+
);
|
|
599
|
+
for (const token of tokenInventory.tokens.filter((token) => !coveredTokens.has(token.name))) {
|
|
311
600
|
const definition = token.definitions[0];
|
|
312
|
-
report(
|
|
601
|
+
report(
|
|
602
|
+
path.join(options.root, definition.file),
|
|
603
|
+
"token-scenario-coverage",
|
|
604
|
+
`Token ${token.name} needs a registered scenario with a reachable token fixture reference.`,
|
|
605
|
+
definition.line,
|
|
606
|
+
definition.column,
|
|
607
|
+
);
|
|
313
608
|
}
|
|
314
609
|
}
|
|
315
610
|
|
|
316
|
-
export function writeScenarioRegistry(options, write) {
|
|
317
|
-
const registry = inspectScenarios(options);
|
|
611
|
+
export async function writeScenarioRegistry(options, write) {
|
|
612
|
+
const registry = await inspectScenarios(options);
|
|
318
613
|
if (registry.diagnostics.length) throw new Error(registry.diagnostics.map((item) => `${item.file}: ${item.message}`).join("\n"));
|
|
319
614
|
write({ schemaVersion: 1, scenarios: registry.scenarios });
|
|
320
615
|
return registry.scenarios;
|
|
321
616
|
}
|
|
322
|
-
|
|
323
|
-
/** Locate the actual consumed array, rather than regenerating a whole fixture. */
|
|
324
|
-
export function tokenSampleSource(options, scenario) {
|
|
325
|
-
const file = path.join(options.root, scenario.file);
|
|
326
|
-
const program = ts.createProgram([file], { ...projectCompilerOptions(options), allowJs:true, resolveJsonModule:true });
|
|
327
|
-
const checker = program.getTypeChecker(), source = program.getSourceFile(file);
|
|
328
|
-
function resolve(node, seen = new Set()) {
|
|
329
|
-
while (node && (ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isParenthesizedExpression(node))) node = node.expression;
|
|
330
|
-
if (!node || seen.has(node)) return null;
|
|
331
|
-
if (ts.isArrayLiteralExpression(node) || ts.isObjectLiteralExpression(node)) return node;
|
|
332
|
-
let symbol = checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node);
|
|
333
|
-
if (symbol?.flags & ts.SymbolFlags.Alias) symbol = checker.getAliasedSymbol(symbol);
|
|
334
|
-
const declaration = symbol?.valueDeclaration;
|
|
335
|
-
return declaration?.initializer ? resolve(declaration.initializer, new Set([...seen,node])) : null;
|
|
336
|
-
}
|
|
337
|
-
for (const statement of source.statements) if (ts.isVariableStatement(statement)) for (const declaration of statement.declarationList.declarations) {
|
|
338
|
-
if (!ts.isIdentifier(declaration.name) || declaration.name.text !== "scenario") continue;
|
|
339
|
-
const metadata = resolve(declaration.initializer);
|
|
340
|
-
const property = metadata && ts.isObjectLiteralExpression(metadata) && metadata.properties.find(node => ts.isPropertyAssignment(node) && (ts.isIdentifier(node.name) || ts.isStringLiteralLike(node.name)) && node.name.text === "samples");
|
|
341
|
-
const array = property && resolve(property.initializer);
|
|
342
|
-
if (array && ts.isArrayLiteralExpression(array)) {
|
|
343
|
-
const source = array.getSourceFile();
|
|
344
|
-
const units = inspectUnits(options), owner = units.owner(units.relative(scenario.file));
|
|
345
|
-
const relative = path.relative(options.root, source.fileName).replaceAll("\\", "/");
|
|
346
|
-
if (!isDevelopmentFile(source.fileName, options) || units.owner(units.relative(relative)) !== owner) throw new Error("The consumed samples array must live in this scenario's own development fixture.");
|
|
347
|
-
return {file:relative, content:source.text, start:array.getStart(source), end:array.end};
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
throw new Error("Cannot locate a literal consumed samples array. Keep fixture.samples statically inspectable; edit other fixture shapes with a normal owner patch.");
|
|
351
|
-
}
|