@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import ts from "
|
|
3
|
+
import ts from "./analysis/syntax.mjs";
|
|
4
4
|
import postcss from "postcss";
|
|
5
5
|
import { isDevelopmentFile, isInside, isTestFile, sourceFiles } from "./config.mjs";
|
|
6
6
|
import { findingSeverity } from "./finding-rules.mjs";
|
|
@@ -13,29 +13,40 @@ import { findingSeverity } from "./finding-rules.mjs";
|
|
|
13
13
|
* A srcset with width descriptors needs sizes, on <img> and on the project's Image. */
|
|
14
14
|
|
|
15
15
|
const guidance = "ads://guides/performance";
|
|
16
|
-
const sized =
|
|
16
|
+
const sized = (declarations) =>
|
|
17
|
+
/^(?:absolute|fixed)$/.test(declarations.get("position") ?? "") ||
|
|
18
|
+
declarations.has("aspect-ratio") ||
|
|
19
|
+
(["width", "inline-size"].some((name) => declarations.get(name) && declarations.get(name) !== "auto") &&
|
|
20
|
+
["height", "block-size"].some((name) => declarations.get(name) && declarations.get(name) !== "auto"));
|
|
17
21
|
|
|
18
22
|
/** What this file's css templates set: per variable, per class and on img selectors. */
|
|
19
23
|
function fileStyles(source) {
|
|
20
|
-
const variables = new Map(),
|
|
24
|
+
const variables = new Map(),
|
|
25
|
+
classes = new Map();
|
|
21
26
|
let imgRule = false;
|
|
22
27
|
const read = (name, template) => {
|
|
23
|
-
const text = ts.isNoSubstitutionTemplateLiteral(template)
|
|
28
|
+
const text = ts.isNoSubstitutionTemplateLiteral(template)
|
|
29
|
+
? template.text
|
|
30
|
+
: `${template.head.text}${template.templateSpans.map((span) => `__ads__${span.literal.text}`).join("")}`;
|
|
24
31
|
try {
|
|
25
|
-
const css = postcss.parse(text),
|
|
32
|
+
const css = postcss.parse(text),
|
|
33
|
+
own = new Map();
|
|
26
34
|
for (const node of css.nodes) if (node.type === "decl") own.set(node.prop.toLowerCase(), node.value.trim());
|
|
27
35
|
if (name) variables.set(name, own);
|
|
28
|
-
css.walkRules(rule => {
|
|
36
|
+
css.walkRules((rule) => {
|
|
29
37
|
const declarations = new Map();
|
|
30
38
|
for (const node of rule.nodes) if (node.type === "decl") declarations.set(node.prop.toLowerCase(), node.value.trim());
|
|
31
39
|
if (!sized(declarations)) return;
|
|
32
40
|
if (/(?:^|[\s,>+~(])img\b/.test(rule.selector)) imgRule = true;
|
|
33
41
|
for (const [, name] of rule.selector.matchAll(/\.([\w-]+)/g)) classes.set(name, declarations);
|
|
34
42
|
});
|
|
35
|
-
} catch {
|
|
43
|
+
} catch {
|
|
44
|
+
/* The core CSS syntax diagnostic owns malformed templates. */
|
|
45
|
+
}
|
|
36
46
|
};
|
|
37
|
-
const visit = node => {
|
|
38
|
-
if (ts.isTaggedTemplateExpression(node) && /(?:^|\.)css$|^styled/.test(node.tag.getText(source)))
|
|
47
|
+
const visit = (node) => {
|
|
48
|
+
if (ts.isTaggedTemplateExpression(node) && /(?:^|\.)css$|^styled/.test(node.tag.getText(source)))
|
|
49
|
+
read(ts.isVariableDeclaration(node.parent) ? node.parent.name.getText(source) : undefined, node.template);
|
|
39
50
|
ts.forEachChild(node, visit);
|
|
40
51
|
};
|
|
41
52
|
visit(source);
|
|
@@ -44,30 +55,47 @@ function fileStyles(source) {
|
|
|
44
55
|
|
|
45
56
|
/** Whether a className expression sizes the image: true, false, or null when it cannot tell. */
|
|
46
57
|
function classSize(expression, { variables, classes }) {
|
|
47
|
-
let found = false,
|
|
48
|
-
|
|
49
|
-
const
|
|
58
|
+
let found = false,
|
|
59
|
+
unknown = false;
|
|
60
|
+
const words = (text) => {
|
|
61
|
+
for (const name of text.split(/\s+/)) if (classes.has(name)) found = true;
|
|
62
|
+
};
|
|
63
|
+
const visit = (node) => {
|
|
50
64
|
if (ts.isStringLiteralLike(node)) words(node.text);
|
|
51
|
-
else if (ts.isIdentifier(node)) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
else if (ts.
|
|
55
|
-
else if (ts.
|
|
56
|
-
|
|
65
|
+
else if (ts.isIdentifier(node)) {
|
|
66
|
+
if (!variables.has(node.text)) unknown = true;
|
|
67
|
+
else if (sized(variables.get(node.text))) found = true;
|
|
68
|
+
} else if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "cx") node.arguments.forEach(visit);
|
|
69
|
+
else if (ts.isConditionalExpression(node)) {
|
|
70
|
+
visit(node.whenTrue);
|
|
71
|
+
visit(node.whenFalse);
|
|
72
|
+
} else if (ts.isBinaryExpression(node)) {
|
|
73
|
+
if (node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) visit(node.right);
|
|
74
|
+
else {
|
|
75
|
+
visit(node.left);
|
|
76
|
+
visit(node.right);
|
|
77
|
+
}
|
|
78
|
+
} else if (ts.isParenthesizedExpression(node) || ts.isJsxExpression(node)) {
|
|
79
|
+
if (node.expression) visit(node.expression);
|
|
80
|
+
} else unknown = true;
|
|
57
81
|
};
|
|
58
82
|
visit(expression);
|
|
59
83
|
return found ? true : unknown ? null : false;
|
|
60
84
|
}
|
|
61
85
|
|
|
62
|
-
export function imageAttributeFindings({ root, dsRoot }) {
|
|
63
|
-
const options = { root, dsRoot },
|
|
64
|
-
|
|
65
|
-
|
|
86
|
+
export async function imageAttributeFindings({ root, dsRoot }) {
|
|
87
|
+
const options = { root, dsRoot },
|
|
88
|
+
findings = [];
|
|
89
|
+
const inScope = (file) =>
|
|
90
|
+
(isInside(path.join(dsRoot, "composition"), file) && !isTestFile(file)) ||
|
|
91
|
+
(["components", "patterns"].some((layer) => isInside(path.join(dsRoot, layer), file)) && !isDevelopmentFile(file, options));
|
|
92
|
+
for (const file of sourceFiles(dsRoot).filter((file) => /\.[jt]sx$/.test(file) && inScope(file))) {
|
|
66
93
|
const text = readFileSync(file, "utf8");
|
|
67
94
|
if (!/<(?:img|Image)\b/.test(text)) continue;
|
|
68
|
-
const source = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX),
|
|
95
|
+
const source = await ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX),
|
|
96
|
+
relative = path.relative(root, file).replaceAll("\\", "/");
|
|
69
97
|
const styles = fileStyles(source);
|
|
70
|
-
const visit = node => {
|
|
98
|
+
const visit = (node) => {
|
|
71
99
|
if (ts.isJsxSelfClosingElement(node) || ts.isJsxOpeningElement(node)) {
|
|
72
100
|
const tag = node.tagName.getText(source);
|
|
73
101
|
if (tag === "img" || tag === "Image") inspectCandidates(node, tag);
|
|
@@ -78,31 +106,76 @@ export function imageAttributeFindings({ root, dsRoot }) {
|
|
|
78
106
|
/** Width descriptors say nothing about display size, so sizes must. */
|
|
79
107
|
const inspectCandidates = (node, tag) => {
|
|
80
108
|
const attributes = node.attributes.properties;
|
|
81
|
-
const attribute = name => attributes.find(item => ts.isJsxAttribute(item) && item.name.getText(source) === name);
|
|
109
|
+
const attribute = (name) => attributes.find((item) => ts.isJsxAttribute(item) && item.name.getText(source) === name);
|
|
82
110
|
const candidates = attribute("srcset") ?? attribute("srcSet");
|
|
83
111
|
if (!candidates || attribute("sizes")) return;
|
|
84
112
|
const { line, character } = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
85
|
-
const add = (rule, message) =>
|
|
113
|
+
const add = (rule, message) =>
|
|
114
|
+
findings.push({
|
|
115
|
+
rule,
|
|
116
|
+
severity: findingSeverity(rule),
|
|
117
|
+
file: relative,
|
|
118
|
+
line: line + 1,
|
|
119
|
+
column: character + 1,
|
|
120
|
+
guidanceUri: guidance,
|
|
121
|
+
message: `${relative}:${line + 1} ${message}`,
|
|
122
|
+
});
|
|
86
123
|
let value = candidates.initializer;
|
|
87
124
|
if (value && ts.isJsxExpression(value)) value = value.expression;
|
|
88
125
|
const literal = value && ts.isStringLiteralLike(value) ? value.text : null;
|
|
89
|
-
if (attributes.some(ts.isJsxSpreadAttribute) || literal === null)
|
|
90
|
-
|
|
126
|
+
if (attributes.some(ts.isJsxSpreadAttribute) || literal === null)
|
|
127
|
+
add(
|
|
128
|
+
"img-attributes-unresolved",
|
|
129
|
+
`<${tag}> has a srcset ADS cannot read or spread props that may hold sizes. With width descriptors it needs sizes, the width it displays at.`,
|
|
130
|
+
);
|
|
131
|
+
else if (/\d\s*w\s*(?:,|$)/.test(literal.trim()))
|
|
132
|
+
add(
|
|
133
|
+
"img-attributes",
|
|
134
|
+
`<${tag}> has a srcset with width descriptors and no sizes, so the browser assumes the full viewport width and can pick a larger file than it shows. Add sizes, such as "(min-width: 1024px) 50vw, 100vw".`,
|
|
135
|
+
);
|
|
91
136
|
};
|
|
92
|
-
const inspect = node => {
|
|
137
|
+
const inspect = (node) => {
|
|
93
138
|
const { line, character } = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
94
|
-
const add = (rule, message) =>
|
|
95
|
-
|
|
96
|
-
|
|
139
|
+
const add = (rule, message) =>
|
|
140
|
+
findings.push({
|
|
141
|
+
rule,
|
|
142
|
+
severity: findingSeverity(rule),
|
|
143
|
+
file: relative,
|
|
144
|
+
line: line + 1,
|
|
145
|
+
column: character + 1,
|
|
146
|
+
guidanceUri: guidance,
|
|
147
|
+
message: `${relative}:${line + 1} ${message}`,
|
|
148
|
+
});
|
|
149
|
+
const attributes = node.attributes.properties,
|
|
150
|
+
spread = attributes.some(ts.isJsxSpreadAttribute);
|
|
151
|
+
const attribute = (name) => attributes.find((item) => ts.isJsxAttribute(item) && item.name.getText(source) === name);
|
|
97
152
|
const styleText = attribute("style")?.initializer?.getText(source) ?? "";
|
|
98
153
|
const className = attribute("className") ?? attribute("class");
|
|
99
154
|
let size = !!(attribute("width") && attribute("height")) || /\baspectRatio\b|aspect-ratio/.test(styleText) || styles.imgRule;
|
|
100
155
|
if (!size && className?.initializer) size = classSize(className.initializer, styles);
|
|
101
156
|
const loading = !!attribute("loading");
|
|
102
|
-
if (spread && (size !== true || !loading)) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
157
|
+
if (spread && (size !== true || !loading)) {
|
|
158
|
+
add(
|
|
159
|
+
"img-attributes-unresolved",
|
|
160
|
+
`spreads props onto <img>, so ADS cannot see its dimensions or loading. Pass width, height and loading explicitly so the page reserves the space and the load order is a choice.`,
|
|
161
|
+
);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (size === null)
|
|
165
|
+
add(
|
|
166
|
+
"img-attributes-unresolved",
|
|
167
|
+
`styles <img> with a class ADS cannot read here, so its size is not checked. Set width and height so the page reserves the space.`,
|
|
168
|
+
);
|
|
169
|
+
if (size === false)
|
|
170
|
+
add(
|
|
171
|
+
"img-attributes",
|
|
172
|
+
`<img> has no width and height or a visible aspect-ratio, so the page shifts when it loads. Set the file's width and height, or a sized aspect-ratio in its style.`,
|
|
173
|
+
);
|
|
174
|
+
if (!loading)
|
|
175
|
+
add(
|
|
176
|
+
"img-attributes",
|
|
177
|
+
`<img> has no loading attribute. Use loading="lazy" below the fold; the page's main visible image uses loading="eager" with fetchpriority="high", or the project's image component with priority.`,
|
|
178
|
+
);
|
|
106
179
|
};
|
|
107
180
|
visit(source);
|
|
108
181
|
}
|
package/dist/image-size.mjs
CHANGED
|
@@ -20,7 +20,7 @@ export function imageSize(bytes) {
|
|
|
20
20
|
if (chunk === "VP8 ") return { width: bytes.readUInt16LE(26) & 0x3fff, height: bytes.readUInt16LE(28) & 0x3fff };
|
|
21
21
|
if (chunk === "VP8L") {
|
|
22
22
|
const bits = bytes.readUInt32LE(21);
|
|
23
|
-
return { width: (bits & 0x3fff) + 1, height:
|
|
23
|
+
return { width: (bits & 0x3fff) + 1, height: ((bits>>14)&0x3fff) + 1 };
|
|
24
24
|
}
|
|
25
25
|
if (chunk === "VP8X") return { width: 1 + bytes.readUIntLE(24, 3), height: 1 + bytes.readUIntLE(27, 3) };
|
|
26
26
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export { initProject } from "./init.mjs";
|
|
2
|
-
export { createProject } from "./create.mjs";
|
|
3
2
|
export { checkProject } from "./check.mjs";
|
|
4
3
|
export { inspectTokens, tokenContract } from "./tokens.mjs";
|
|
5
4
|
export { inspectTokenOrigins } from "./token-origins.mjs";
|
|
6
|
-
export { generateLintConfig } from "./lint-config.mjs";
|
|
7
5
|
export { generateBrandAssets } from "./brand-assets.mjs";
|
|
8
6
|
// Development-only helpers for registered project lint extensions. They reuse the
|
|
9
7
|
// same validated configuration and property boundary as the core checker.
|
package/dist/init.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, rmdirSync, writeFileSync, chmodSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import
|
|
5
|
-
import { isInside, loadConfig, sourceFiles, supportedFrameworks } from "./config.mjs";
|
|
4
|
+
import { isInside, loadConfig, sourceFiles, supportedFrameworks, fixedLayout } from "./config.mjs";
|
|
6
5
|
import { foundationFiles } from "./token-policy.mjs";
|
|
7
6
|
import { generatedPaletteFile } from "./palette-generated.mjs";
|
|
7
|
+
import { generatedEntries } from "./generated-entries.mjs";
|
|
8
8
|
import { assertFrameworkCompiler } from "./ui-framework.mjs";
|
|
9
9
|
|
|
10
10
|
const tool = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
@@ -27,17 +27,18 @@ function dependencySpec(value) {
|
|
|
27
27
|
return value;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
/** The package manager the project declares: packageManager in package.json, else its lockfile. */
|
|
31
|
+
function detectManager(root, pkg) {
|
|
32
32
|
if (typeof pkg.packageManager === "string") return pkg.packageManager.split("@")[0];
|
|
33
33
|
const bun = ["bun.lock", "bun.lockb"].some((name) => existsSync(path.join(root, name)));
|
|
34
34
|
const npm = existsSync(path.join(root, "package-lock.json"));
|
|
35
|
-
if (bun && npm) throw new Error(
|
|
35
|
+
if (bun && npm) throw new Error('Both Bun and npm lockfiles exist. Keep the one the project uses, or set "packageManager" in package.json.');
|
|
36
36
|
if (bun) return "bun";
|
|
37
37
|
if (npm) return "npm";
|
|
38
38
|
if (["pnpm-lock.yaml", "yarn.lock"].some((name) => existsSync(path.join(root, name)))) throw new Error("This version supports npm and Bun projects.");
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
throw new Error(
|
|
40
|
+
'The project declares no package manager. Set "packageManager" in package.json (such as "npm@11.7.0" or "bun@1.4.1"), or install its dependencies with npm or Bun so its lockfile exists, then run ads init.',
|
|
41
|
+
);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
function assertLocalFile(root, file) {
|
|
@@ -69,7 +70,8 @@ function commit(root, updates) {
|
|
|
69
70
|
try {
|
|
70
71
|
for (const [index, entry] of entries.entries()) {
|
|
71
72
|
const current = existsSync(entry.file) ? readFileSync(entry.file) : null;
|
|
72
|
-
if ((current === null) !== (entry.before === null) || (current && !current.equals(entry.before)))
|
|
73
|
+
if ((current === null) !== (entry.before === null) || (current && !current.equals(entry.before)))
|
|
74
|
+
throw new Error(`Project file changed during init: ${entry.file}`);
|
|
73
75
|
const temporary = path.join(staging, String(index));
|
|
74
76
|
writeFileSync(temporary, entry.content);
|
|
75
77
|
if (entry.mode !== undefined) chmodSync(temporary, entry.mode);
|
|
@@ -94,7 +96,7 @@ function commit(root, updates) {
|
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
|
|
97
|
-
export function initProject(directory = process.cwd(), { toolPackage,
|
|
99
|
+
export async function initProject(directory = process.cwd(), { toolPackage, framework, includeStarter = false } = {}) {
|
|
98
100
|
const root = path.resolve(directory);
|
|
99
101
|
const packageFile = path.join(root, "package.json");
|
|
100
102
|
assertLocalFile(root, packageFile);
|
|
@@ -103,34 +105,68 @@ export function initProject(directory = process.cwd(), { toolPackage, packageMan
|
|
|
103
105
|
const pkg = JSON.parse(originalPackage);
|
|
104
106
|
if (!pkg || typeof pkg !== "object" || Array.isArray(pkg)) throw new Error("package.json must be an object.");
|
|
105
107
|
for (const field of ["scripts", "dependencies", "devDependencies"]) {
|
|
106
|
-
if (pkg[field] !== undefined && (!pkg[field] || typeof pkg[field] !== "object" || Array.isArray(pkg[field])))
|
|
108
|
+
if (pkg[field] !== undefined && (!pkg[field] || typeof pkg[field] !== "object" || Array.isArray(pkg[field])))
|
|
109
|
+
throw new Error(`package.json ${field} must be an object.`);
|
|
107
110
|
}
|
|
108
111
|
for (const [name, script] of Object.entries(pkg.scripts ?? {})) {
|
|
109
112
|
if (typeof script !== "string") throw new Error(`package.json script ${name} must be a string.`);
|
|
110
113
|
}
|
|
111
|
-
const manager = detectManager(root, pkg
|
|
114
|
+
const manager = detectManager(root, pkg);
|
|
112
115
|
if (!["npm", "bun"].includes(manager)) throw new Error("packageManager must be npm or bun.");
|
|
113
116
|
const run = manager === "bun" ? "bun run" : "npm run";
|
|
114
117
|
const ads = manager === "bun" ? "bun run ads" : "ads";
|
|
115
118
|
const spec = dependencySpec(toolPackage ?? pkg.devDependencies?.[tool.name] ?? pkg.dependencies?.[tool.name] ?? tool.version);
|
|
116
119
|
const { config, dsRoot } = loadConfig(root);
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
+
// ADS generates the barrels and the styles entry. A hand-written one stops init before any write.
|
|
121
|
+
for (const entry of [config.publicEntry, config.reviewEntry, config.stylesEntry]) {
|
|
122
|
+
const file = path.join(dsRoot, entry);
|
|
123
|
+
if (existsSync(file) && !/^(?:\/\/|\/\*) Generated by ADS/.test(readFileSync(file, "utf8")))
|
|
124
|
+
throw new Error(
|
|
125
|
+
`${path.relative(root, file).replaceAll("\\", "/")} is hand-written, but ADS generates it. Move each public export into its owner's <Owner>.ads.exports.ts (token sheets feed the styles entry), delete the file and run ads init again.`,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
120
128
|
if (framework !== undefined && !supportedFrameworks.includes(framework)) throw new Error("framework must be react or preact.");
|
|
121
|
-
if (framework !== undefined && config.framework !== null && framework !== config.framework)
|
|
129
|
+
if (framework !== undefined && config.framework !== null && framework !== config.framework)
|
|
130
|
+
throw new Error(
|
|
131
|
+
`ADS is configured for ${config.framework}; --framework ${framework} would change it. Migrate the project and update ds.config.json explicitly before running init.`,
|
|
132
|
+
);
|
|
122
133
|
const selectedFramework = framework ?? config.framework;
|
|
123
|
-
if (selectedFramework === null)
|
|
124
|
-
|
|
134
|
+
if (selectedFramework === null)
|
|
135
|
+
throw new Error("Specify --framework react or --framework preact on first init, including when adopting an existing ADS config without a framework.");
|
|
136
|
+
await assertFrameworkCompiler(root, selectedFramework);
|
|
125
137
|
config.framework = selectedFramework;
|
|
126
138
|
const lint = `${ads} check .`;
|
|
139
|
+
// --include-starter: the starter's package settings, scripts and dev dependencies the project lacks.
|
|
140
|
+
if (includeStarter) {
|
|
141
|
+
const starterPackage = JSON.parse(readFileSync(starterFile(selectedFramework, "package.json"), "utf8"));
|
|
142
|
+
for (const field of ["type", "sideEffects"]) if (pkg[field] === undefined && starterPackage[field] !== undefined) pkg[field] = starterPackage[field];
|
|
143
|
+
pkg.scripts = {
|
|
144
|
+
...Object.fromEntries(Object.entries(starterPackage.scripts).map(([name, command]) => [name, command.replaceAll("npm run ", `${run} `)])),
|
|
145
|
+
...pkg.scripts,
|
|
146
|
+
};
|
|
147
|
+
pkg.devDependencies = {
|
|
148
|
+
...Object.fromEntries(Object.entries(starterPackage.devDependencies).filter(([name]) => !pkg.dependencies?.[name])),
|
|
149
|
+
...pkg.devDependencies,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
127
152
|
const scripts = { ...pkg.scripts };
|
|
128
|
-
if (
|
|
153
|
+
if (
|
|
154
|
+
scripts["lint:ds"] &&
|
|
155
|
+
scripts["lint:ds"] !== lint &&
|
|
156
|
+
!["ads check .", "bun run ads check .", "bun --bun run ads check ."].some((prefix) => scripts["lint:ds"].startsWith(prefix))
|
|
157
|
+
)
|
|
158
|
+
throw new Error("An existing custom lint:ds script would conflict. Rename it or integrate ADS checks before running init.");
|
|
129
159
|
scripts["lint:ds"] = lint;
|
|
130
|
-
if (scripts["assets:ds"] && !["ads assets", "
|
|
160
|
+
if (scripts["assets:ds"] && !["ads assets", "bun run ads assets", "bun --bun run ads assets"].includes(scripts["assets:ds"]))
|
|
161
|
+
throw new Error("An existing custom assets:ds script would conflict. Rename it or integrate ADS asset generation before running init.");
|
|
131
162
|
scripts["assets:ds"] = `${ads} assets`;
|
|
132
|
-
for (const [name, command] of [
|
|
133
|
-
|
|
163
|
+
for (const [name, command] of [
|
|
164
|
+
["dev:showcase", "showcase"],
|
|
165
|
+
["ads-mcp", "mcp --mutations"],
|
|
166
|
+
["ads-read-mcp", "mcp"],
|
|
167
|
+
]) {
|
|
168
|
+
if (!scripts[name] || [`ads ${command}`, `bun run ads ${command}`, `bun --bun run ads ${command}`].includes(scripts[name]))
|
|
169
|
+
scripts[name] = `${ads} ${command}`;
|
|
134
170
|
}
|
|
135
171
|
const managedBuild = /^(?:npm|bun(?: --bun)?) run lint:ds(?: && (?:npm|bun(?: --bun)?) run assets:ds)?$/.test(scripts.build ?? "");
|
|
136
172
|
if (scripts.build && !managedBuild) {
|
|
@@ -145,55 +181,31 @@ export function initProject(directory = process.cwd(), { toolPackage, packageMan
|
|
|
145
181
|
}
|
|
146
182
|
pkg.scripts = scripts;
|
|
147
183
|
pkg.devDependencies = { ...pkg.devDependencies, [tool.name]: spec };
|
|
148
|
-
//
|
|
149
|
-
if (!["@playwright/test", "playwright"].some(name => pkg.devDependencies[name] ?? pkg.dependencies?.[name]))
|
|
184
|
+
// ads validate and draft acceptance run the render audit, which needs project Playwright.
|
|
185
|
+
if (!["@playwright/test", "playwright"].some((name) => pkg.devDependencies[name] ?? pkg.dependencies?.[name]))
|
|
186
|
+
pkg.devDependencies["@playwright/test"] = tool.devDependencies["@playwright/test"];
|
|
150
187
|
if (pkg.dependencies?.[tool.name]) delete pkg.dependencies[tool.name];
|
|
151
188
|
|
|
152
189
|
const updates = new Map();
|
|
153
|
-
function addMissing(file, content) {
|
|
190
|
+
function addMissing(file, content) {
|
|
191
|
+
assertLocalFile(root, file);
|
|
192
|
+
if (!existsSync(file)) updates.set(file, content);
|
|
193
|
+
}
|
|
154
194
|
const tokenRoot = path.join(dsRoot, config.tokenDir);
|
|
155
195
|
const existingTokens = sourceFiles(tokenRoot).filter((file) => file.endsWith(".css"));
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
return file;
|
|
160
|
-
});
|
|
196
|
+
if (!existingTokens.length)
|
|
197
|
+
for (const name of foundationFiles.filter((name) => existsSync(path.join(starter, "design-system/tokens", name))))
|
|
198
|
+
addMissing(path.join(tokenRoot, name), readFileSync(path.join(starter, "design-system/tokens", name)));
|
|
161
199
|
if (!existingTokens.length) {
|
|
162
200
|
// The renderer palette generated from the starter's token sheets, beside its theme sheet.
|
|
163
201
|
addMissing(path.join(tokenRoot, generatedPaletteFile), readFileSync(path.join(starter, "design-system/tokens", generatedPaletteFile)));
|
|
164
|
-
//
|
|
165
|
-
for (const name of readdirSync(path.join(starter, "design-system/tokens"))
|
|
166
|
-
|
|
202
|
+
// Foundation definitions/metadata are shared; ADS owns their presentation.
|
|
203
|
+
for (const name of readdirSync(path.join(starter, "design-system/tokens"))
|
|
204
|
+
.filter((name) => name.endsWith(".ads.json"))
|
|
205
|
+
.sort()) {
|
|
206
|
+
const content = readFileSync(path.join(starter, "design-system/tokens", name), "utf8");
|
|
167
207
|
addMissing(path.join(tokenRoot, name), content);
|
|
168
208
|
}
|
|
169
|
-
for (const name of ["TokenPreview.tsx"]) {
|
|
170
|
-
const content = readFileSync(starterFile(selectedFramework, `design-system/review/token-preview/${name}`), "utf8");
|
|
171
|
-
addMissing(path.join(dsRoot, "review/token-preview", name), content.replaceAll('"@ds"', JSON.stringify(config.publicAlias)));
|
|
172
|
-
}
|
|
173
|
-
const reviewFile = path.relative(root, path.join(dsRoot, "review/token-preview/TokenPreview.tsx")).replaceAll("\\", "/");
|
|
174
|
-
if (!config.boundaries.styleWrites.some(item => item.file === reviewFile)) config.boundaries.styleWrites.push({ file: reviewFile, properties: ["--ux-token-preview-value"] });
|
|
175
|
-
}
|
|
176
|
-
tokenFiles.sort((a, b) => foundationFiles.indexOf(path.basename(a)) - foundationFiles.indexOf(path.basename(b)) || a.localeCompare(b));
|
|
177
|
-
const stylesFile = path.join(dsRoot, config.stylesEntry);
|
|
178
|
-
const relativeImport = (from, to) => {
|
|
179
|
-
const relative = path.relative(path.dirname(from), to).split(path.sep).join("/");
|
|
180
|
-
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
181
|
-
};
|
|
182
|
-
addMissing(stylesFile, tokenFiles.map((file) => `@import ${JSON.stringify(relativeImport(stylesFile, file))};`).join("\n") + "\n");
|
|
183
|
-
const entryFile = path.join(dsRoot, config.publicEntry);
|
|
184
|
-
addMissing(entryFile, `// Export your project's public components and types here.\nimport ${JSON.stringify(relativeImport(entryFile, stylesFile))};\n`);
|
|
185
|
-
if (!existingTokens.length) {
|
|
186
|
-
const reviewEntry = path.join(dsRoot, config.reviewEntry);
|
|
187
|
-
const reviewExport = `export { TokenPreview } from ${JSON.stringify(relativeImport(reviewEntry, path.join(dsRoot, "review/token-preview/TokenPreview")))};\n`;
|
|
188
|
-
addMissing(reviewEntry, reviewExport);
|
|
189
|
-
if (existsSync(reviewEntry) && !readFileSync(reviewEntry, "utf8").includes("token-preview/TokenPreview")) throw new Error("The project owns an existing review entry. Add the new token renderer through that development API before initializing the foundation.");
|
|
190
|
-
if (existsSync(entryFile)) {
|
|
191
|
-
let current = readFileSync(entryFile, "utf8");
|
|
192
|
-
const ast = ts.createSourceFile(entryFile, current, ts.ScriptTarget.Latest, true);
|
|
193
|
-
for (const statement of [...ast.statements].reverse()) if (ts.isExportDeclaration(statement) && !statement.moduleSpecifier && statement.exportClause && ts.isNamedExports(statement.exportClause) && !statement.exportClause.elements.length) current = current.slice(0, statement.getStart(ast)) + current.slice(statement.end);
|
|
194
|
-
if (!ast.statements.some(statement => ts.isImportDeclaration(statement) || statement.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.ExportKeyword))) current += `\nimport ${JSON.stringify(relativeImport(entryFile, stylesFile))};\n`;
|
|
195
|
-
if (current !== readFileSync(entryFile, "utf8")) updates.set(entryFile, current);
|
|
196
|
-
}
|
|
197
209
|
}
|
|
198
210
|
// Keeps a section folder that has nothing in it yet.
|
|
199
211
|
for (const section of ["components", "patterns", "controllers", "composition"]) {
|
|
@@ -204,24 +216,72 @@ export function initProject(directory = process.cwd(), { toolPackage, packageMan
|
|
|
204
216
|
addMissing(path.join(dsRoot, "assets/fonts/.gitkeep"), "");
|
|
205
217
|
const configFile = path.join(root, "ds.config.json");
|
|
206
218
|
assertLocalFile(root, configFile);
|
|
207
|
-
|
|
208
|
-
|
|
219
|
+
// The fixed layout is ADS's own; a new config records only the project's choices.
|
|
220
|
+
if (!existsSync(configFile)) {
|
|
221
|
+
// A complete starter needs its glyph/brand configuration as well as its files.
|
|
222
|
+
// Existing project configuration is never replaced by starter defaults.
|
|
223
|
+
const choices = includeStarter
|
|
224
|
+
? JSON.parse(readFileSync(starterFile(selectedFramework, "ds.config.json"), "utf8"))
|
|
225
|
+
: Object.fromEntries(Object.entries(config).filter(([key]) => !(key in fixedLayout)));
|
|
226
|
+
updates.set(configFile, `${JSON.stringify(choices, null, 2)}\n`);
|
|
227
|
+
} else {
|
|
209
228
|
const original = readFileSync(configFile, "utf8");
|
|
210
229
|
const saved = JSON.parse(original);
|
|
211
|
-
if (saved.framework === undefined || !existingTokens.length
|
|
230
|
+
if (saved.framework === undefined || !existingTokens.length) {
|
|
212
231
|
const indent = original.match(/\n([\t ]+)"/)?.[1] ?? " ";
|
|
213
|
-
updates.set(configFile, `${JSON.stringify({ ...saved, framework: selectedFramework
|
|
232
|
+
updates.set(configFile, `${JSON.stringify({ ...saved, framework: selectedFramework }, null, indent)}\n`);
|
|
214
233
|
}
|
|
215
234
|
}
|
|
216
235
|
// The framework's scenario mount, as the starter has it.
|
|
217
|
-
addMissing(
|
|
236
|
+
addMissing(
|
|
237
|
+
path.join(dsRoot, "showcase/mcp/main.ads.mount.tsx"),
|
|
238
|
+
readFileSync(starterFile(selectedFramework, "design-system/showcase/mcp/main.ads.mount.tsx"), "utf8"),
|
|
239
|
+
);
|
|
240
|
+
// --include-starter: the starter's example design system and app files, where the project has none.
|
|
241
|
+
// The project's own package files and ADS's generated entries are never copied.
|
|
242
|
+
if (includeStarter) {
|
|
243
|
+
const skipped = new Set([
|
|
244
|
+
"package.json",
|
|
245
|
+
"package-lock.json",
|
|
246
|
+
"ds.config.json",
|
|
247
|
+
".gitignore",
|
|
248
|
+
"gitignore.template",
|
|
249
|
+
"design-system/index.ts",
|
|
250
|
+
"design-system/review/index.ads.review.ts",
|
|
251
|
+
"design-system/styles.css",
|
|
252
|
+
]);
|
|
253
|
+
const files = new Map();
|
|
254
|
+
for (const base of [starter, ...(selectedFramework === "react" ? [] : [fileURLToPath(new URL(`./starters/${selectedFramework}/`, import.meta.url))])])
|
|
255
|
+
for (const entry of readdirSync(base, { recursive: true, withFileTypes: true })) {
|
|
256
|
+
if (!entry.isFile()) continue;
|
|
257
|
+
const relative = path.relative(base, path.join(entry.parentPath, entry.name)).replaceAll("\\", "/");
|
|
258
|
+
if (!skipped.has(relative) && !relative.startsWith("node_modules/")) files.set(relative, path.join(base, relative));
|
|
259
|
+
}
|
|
260
|
+
for (const [relative, source] of files)
|
|
261
|
+
addMissing(
|
|
262
|
+
relative.startsWith("design-system/") ? path.join(dsRoot, relative.slice("design-system/".length)) : path.join(root, relative),
|
|
263
|
+
readFileSync(source),
|
|
264
|
+
);
|
|
265
|
+
}
|
|
218
266
|
const ignoreFile = path.join(root, ".gitignore");
|
|
219
267
|
assertLocalFile(root, ignoreFile);
|
|
220
|
-
|
|
221
|
-
|
|
268
|
+
// A project without .gitignore takes the starter's with --include-starter (npm ships it as gitignore.template).
|
|
269
|
+
const starterIgnore = [".gitignore", "gitignore.template"].map((name) => path.join(starter, name)).find((file) => existsSync(file));
|
|
270
|
+
const ignore = existsSync(ignoreFile) ? readFileSync(ignoreFile, "utf8") : includeStarter && starterIgnore ? readFileSync(starterIgnore, "utf8") : "";
|
|
271
|
+
const ignoresDs = ignore.split(/\r?\n/).some((line) => [".ds/", ".ds", "/.ds/", "/.ds"].includes(line));
|
|
272
|
+
if (!ignoresDs) updates.set(ignoreFile, `${ignore}${ignore && !ignore.endsWith("\n") ? "\n" : ""}.ds/\n`);
|
|
273
|
+
else if (!existsSync(ignoreFile)) updates.set(ignoreFile, ignore);
|
|
222
274
|
const indent = originalPackage.match(/\n([\t ]+)"/)?.[1] ?? " ";
|
|
223
275
|
const nextPackage = `${JSON.stringify(pkg, null, indent)}\n`;
|
|
224
276
|
if (nextPackage !== originalPackage) updates.set(packageFile, nextPackage);
|
|
225
277
|
commit(root, updates);
|
|
226
|
-
|
|
278
|
+
// The styles entry and the barrels are generated from the token sheets and exports files.
|
|
279
|
+
commit(root, new Map((await generatedEntries(loadConfig(root))).map((entry) => [entry.file, entry.text])));
|
|
280
|
+
return {
|
|
281
|
+
directory: root,
|
|
282
|
+
framework: selectedFramework,
|
|
283
|
+
packageManager: manager,
|
|
284
|
+
toolDependency: { name: tool.name, spec },
|
|
285
|
+
updatedFiles: [...updates.keys()],
|
|
286
|
+
};
|
|
227
287
|
}
|
package/dist/investigations.mjs
CHANGED
|
@@ -10,7 +10,7 @@ export const investigationUri = entry => `ads://investigations/${encodeURICompon
|
|
|
10
10
|
const ordinary = file => { try { return realpathSync(file)===path.resolve(file)&&lstatSync(file).isFile()&&lstatSync(file).nlink===1; } catch { return false; } };
|
|
11
11
|
const digest = bytes => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
|
|
12
12
|
function saved(root,runId) {
|
|
13
|
-
if(runId!==undefined &&
|
|
13
|
+
if(runId!==undefined &&( typeof runId!=="string" || !/^[a-zA-Z0-9_-]{1,100}$/.test(runId)))throw new Error("Invalid investigation run ID.");
|
|
14
14
|
const file=runId===undefined?indexFile(root):path.join(root,".ds/investigation-runs",`${runId}.json`);
|
|
15
15
|
if(!ordinary(file)||lstatSync(file).size>2*1024*1024)return {};
|
|
16
16
|
try {const value=JSON.parse(readFileSync(file,"utf8"));return value.schemaVersion===1&&value.bundles&&typeof value.bundles==="object"&&!Array.isArray(value.bundles)?value.bundles:{};}catch{return {};}
|
|
@@ -52,7 +52,7 @@ export function readInvestigation(root,{unit,check,runId}) {
|
|
|
52
52
|
const latest=saved(root)[identity({unit,check})];
|
|
53
53
|
const bundle=runId===undefined||latest?.runId===runId?latest:saved(root,runId)[identity({unit,check})];
|
|
54
54
|
if(!bundle)throw new Error("No retained investigation exists for this check/run. It may have expired; discover current evidence with ads_behaviors.");
|
|
55
|
-
return {...bundle,artifacts:(bundle.artifacts??[]).map(artifact=>({...artifact,available:!!artifactPath(root,artifact.path)}))};
|
|
55
|
+
return {...bundle,artifacts:(bundle.artifacts??[]).map( (artifact )=>({...artifact,available:!!artifactPath(root,artifact.path)}))};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export const investigationSections=["summary","details","requests","browserErrors","artifacts"];
|