@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
|
@@ -9,16 +9,33 @@ import { previewSessionDirectories, withPreviewSession } from "../preview-scope.
|
|
|
9
9
|
import { developmentExecutable } from "../development-runtime.mjs";
|
|
10
10
|
import { readPreviewManifest } from "../preview-resources.mjs";
|
|
11
11
|
import { activeNow } from "../active-clock.mjs";
|
|
12
|
+
import { loadConfig } from "../config.mjs";
|
|
13
|
+
|
|
14
|
+
/** ADS's own preview compiler, the one way previews are built: Bun, watching the project. */
|
|
15
|
+
export function adsPreviewCompiler() {
|
|
16
|
+
return { command: "bun", args: [fileURLToPath(new URL("../bun-compiler.mjs", import.meta.url)), "--watch"] };
|
|
17
|
+
}
|
|
12
18
|
|
|
13
19
|
function stamp(file) {
|
|
14
|
-
try {
|
|
15
|
-
|
|
20
|
+
try {
|
|
21
|
+
const stat = statSync(file);
|
|
22
|
+
return `${stat.mtimeMs}:${stat.ctimeMs}:${stat.size}`;
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
/** One project-owned compiler process, shared by all protocol instances. */
|
|
19
|
-
export function createPreviewWatch(
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
export function createPreviewWatch(
|
|
30
|
+
root,
|
|
31
|
+
config,
|
|
32
|
+
{ log = process.stderr, buildTimeout = config.previewBuildTimeoutMs ?? 300000, prewarm = false, despitePolicy = false, delegate, compiler } = {},
|
|
33
|
+
) {
|
|
34
|
+
// apps: the scenario artifacts this watcher serves, set by the server from the scenario registry.
|
|
35
|
+
config = { ...config, apps: [...(config.apps ?? [])] };
|
|
36
|
+
// A project with a framework compiles with ADS's compiler. `compiler` lets ADS's own tests
|
|
37
|
+
// substitute an instrumented build process; it is not project configuration.
|
|
38
|
+
const command = compiler !== undefined ? compiler : loadConfig(root).config.framework ? adsPreviewCompiler() : null;
|
|
22
39
|
let session = randomUUID();
|
|
23
40
|
let state = command ? "idle" : "disabled";
|
|
24
41
|
let child;
|
|
@@ -31,15 +48,28 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
31
48
|
let restarting;
|
|
32
49
|
let disposed = false;
|
|
33
50
|
let stalled = false;
|
|
34
|
-
let suspended = false,
|
|
51
|
+
let suspended = false,
|
|
52
|
+
immutablePark = false,
|
|
53
|
+
resuming,
|
|
54
|
+
suspending;
|
|
35
55
|
const baselines = new Map();
|
|
36
56
|
const ready = new Set();
|
|
37
57
|
const requests = new Set();
|
|
38
|
-
function diagnostics(stream){
|
|
58
|
+
function diagnostics(stream) {
|
|
39
59
|
// A private writable keeps each pipe's lifecycle/backpressure listeners off
|
|
40
60
|
// the shared stderr socket when several draft/capture compilers are warm.
|
|
41
|
-
const output=new Writable({
|
|
42
|
-
|
|
61
|
+
const output = new Writable({
|
|
62
|
+
write(chunk, encoding, done) {
|
|
63
|
+
log.write(chunk, encoding, done);
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
output.on("error", (failure) => {
|
|
67
|
+
error ??= `Preview diagnostics failed: ${failure.message}`;
|
|
68
|
+
if (state === "running") {
|
|
69
|
+
state = "failed";
|
|
70
|
+
kill("SIGKILL");
|
|
71
|
+
}
|
|
72
|
+
});
|
|
43
73
|
stream.pipe(output);
|
|
44
74
|
}
|
|
45
75
|
let active;
|
|
@@ -47,13 +77,35 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
47
77
|
let invalidation;
|
|
48
78
|
let requestFile = path.join(root, ".ds", `preview-requests-${session}.json`);
|
|
49
79
|
let reportFile = path.join(root, ".ds", `build-status-${session}.json`);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
// Draft workspaces compile inside this watcher's process; the control file lists them.
|
|
81
|
+
const drafts = new Map();
|
|
82
|
+
const controlFile = () => path.join(root, ".ds", `draft-compilers-${session}.json`);
|
|
83
|
+
function writeControl() {
|
|
84
|
+
if (delegate || !command) return;
|
|
85
|
+
mkdirSync(path.join(root, ".ds"), { recursive: true });
|
|
86
|
+
const temporary = `${controlFile()}.tmp`;
|
|
87
|
+
writeFileSync(temporary, JSON.stringify({ drafts: [...drafts.values()] }));
|
|
88
|
+
renameSync(temporary, controlFile());
|
|
89
|
+
}
|
|
90
|
+
function request(file, force = false) {
|
|
91
|
+
if (!command || (!force && requests.has(file) && active === file)) return;
|
|
92
|
+
if (file) {
|
|
93
|
+
requests.add(file);
|
|
94
|
+
active = file;
|
|
95
|
+
}
|
|
53
96
|
mkdirSync(path.dirname(requestFile), { recursive: true });
|
|
54
97
|
if (realpathSync(path.dirname(requestFile)) !== path.dirname(requestFile)) throw new Error("Preview requests cannot resolve through a symlink.");
|
|
55
98
|
const temporary = `${requestFile}.tmp`;
|
|
56
|
-
writeFileSync(
|
|
99
|
+
writeFileSync(
|
|
100
|
+
temporary,
|
|
101
|
+
JSON.stringify({
|
|
102
|
+
session,
|
|
103
|
+
active: active ? path.relative(root, active).replaceAll("\\", "/") : null,
|
|
104
|
+
files: [...requests].map((file) => path.relative(root, file).replaceAll("\\", "/")),
|
|
105
|
+
...(invalidation ? { invalidation } : {}),
|
|
106
|
+
...(full ? { full } : {}),
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
57
109
|
renameSync(temporary, requestFile);
|
|
58
110
|
}
|
|
59
111
|
|
|
@@ -63,9 +115,13 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
63
115
|
if (process.platform === "win32") {
|
|
64
116
|
// taskkill also terminates the compiler's own subprocesses.
|
|
65
117
|
const terminator = spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
66
|
-
terminator.on("error", () => {
|
|
118
|
+
terminator.on("error", () => {
|
|
119
|
+
child.kill(signal);
|
|
120
|
+
});
|
|
67
121
|
} else process.kill(-child.pid, signal);
|
|
68
|
-
} catch (failure) {
|
|
122
|
+
} catch (failure) {
|
|
123
|
+
if (failure.code !== "ESRCH") throw failure;
|
|
124
|
+
}
|
|
69
125
|
}
|
|
70
126
|
function start() {
|
|
71
127
|
if (disposed || suspended || state !== "idle") return;
|
|
@@ -74,12 +130,36 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
74
130
|
baselines.set(file, stamp(file));
|
|
75
131
|
}
|
|
76
132
|
state = "running";
|
|
133
|
+
// A draft workspace has no compiler process of its own: the project's compiler hosts it.
|
|
134
|
+
if (delegate) {
|
|
135
|
+
delegate.attachDraft({ root, session, requestFile, statusFile: reportFile });
|
|
136
|
+
if (active) request(active, true);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
writeControl();
|
|
77
140
|
// No shell: configured arguments remain literal. Child stdin cannot consume
|
|
78
141
|
// the MCP channel, and both output streams go exclusively to diagnostics.
|
|
79
142
|
const executable = developmentExecutable(command.command);
|
|
80
|
-
const env = {
|
|
143
|
+
const env = {
|
|
144
|
+
...process.env,
|
|
145
|
+
ADS_MCP_BUILD_SESSION: session,
|
|
146
|
+
ADS_MCP_BUILD_STATUS: reportFile,
|
|
147
|
+
ADS_MCP_REQUEST_FILE: requestFile,
|
|
148
|
+
ADS_MCP_DRAFT_CONTROL: controlFile(),
|
|
149
|
+
ADS_WARM_CHECKS: "1",
|
|
150
|
+
ADS_MCP_PREWARM_VIEWS: prewarm ? "1" : "0",
|
|
151
|
+
ADS_PREVIEW_DESPITE_POLICY: despitePolicy ? "1" : "0",
|
|
152
|
+
PATH: [path.join(root, "node_modules/.bin"), path.dirname(process.execPath), process.env.PATH ?? ""].join(path.delimiter),
|
|
153
|
+
};
|
|
81
154
|
try {
|
|
82
|
-
child = spawn(executable, command.args, {
|
|
155
|
+
child = spawn(executable, command.args, {
|
|
156
|
+
cwd: root,
|
|
157
|
+
env,
|
|
158
|
+
shell: false,
|
|
159
|
+
detached: process.platform !== "win32",
|
|
160
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
161
|
+
windowsHide: true,
|
|
162
|
+
});
|
|
83
163
|
} catch (failure) {
|
|
84
164
|
state = "failed";
|
|
85
165
|
error = `Cannot start preview watcher: ${failure.message}`;
|
|
@@ -89,9 +169,11 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
89
169
|
if (child.pid) {
|
|
90
170
|
// A small independent guard owns a pipe from this MCP process. It can
|
|
91
171
|
// terminate the detached compiler group even if this process is SIGKILLed.
|
|
92
|
-
const guard = ownerGuard = spawn(process.execPath, [fileURLToPath(new URL("./preview-owner-guard.mjs", import.meta.url)), String(child.pid)], {
|
|
93
|
-
stdio: ["pipe", "ignore", "pipe"],
|
|
94
|
-
|
|
172
|
+
const guard = (ownerGuard = spawn(process.execPath, [fileURLToPath(new URL("./preview-owner-guard.mjs", import.meta.url)), String(child.pid)], {
|
|
173
|
+
stdio: ["pipe", "ignore", "pipe"],
|
|
174
|
+
detached: process.platform !== "win32",
|
|
175
|
+
windowsHide: true,
|
|
176
|
+
}));
|
|
95
177
|
guard.stdin.on("error", () => {}); // Owner shutdown can race guard exit.
|
|
96
178
|
diagnostics(guard.stderr);
|
|
97
179
|
function guardFailed(failure) {
|
|
@@ -105,21 +187,24 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
105
187
|
}
|
|
106
188
|
diagnostics(child.stdout);
|
|
107
189
|
diagnostics(child.stderr);
|
|
108
|
-
closed = new Promise((resolve) =>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
190
|
+
closed = new Promise((resolve) =>
|
|
191
|
+
child.once("close", (code, signal) => {
|
|
192
|
+
// Closing the launcher's pipes does not prove every compiler exited.
|
|
193
|
+
// Finish cleanup now, before discarding the owned process-group ID.
|
|
194
|
+
kill("SIGKILL");
|
|
195
|
+
childClosed = true;
|
|
196
|
+
const guard = ownerGuard;
|
|
197
|
+
ownerGuard = undefined;
|
|
198
|
+
guard?.stdin.end("disarm\n");
|
|
199
|
+
clearTimeout(killTimer);
|
|
200
|
+
if (state !== "stopping") {
|
|
201
|
+
state = "failed";
|
|
202
|
+
error ??= `Preview watcher exited (${signal ?? code}). Fix the builder and invoke the preview again to restart it; MCP inspection remains available.`;
|
|
203
|
+
log.write(`ads mcp: ${error}\n`);
|
|
204
|
+
} else state = "stopped";
|
|
205
|
+
resolve();
|
|
206
|
+
}),
|
|
207
|
+
);
|
|
123
208
|
child.once("exit", () => {
|
|
124
209
|
// A failed launcher must not leave its compiler subprocesses alive.
|
|
125
210
|
if (state !== "stopping") {
|
|
@@ -127,50 +212,77 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
127
212
|
killTimer = setTimeout(() => kill("SIGKILL"), 1500);
|
|
128
213
|
}
|
|
129
214
|
});
|
|
130
|
-
child.once("error", (failure) => {
|
|
215
|
+
child.once("error", (failure) => {
|
|
216
|
+
error = `Cannot start preview watcher: ${failure.message}`;
|
|
217
|
+
});
|
|
131
218
|
if (active) request(active, true);
|
|
132
219
|
}
|
|
133
220
|
|
|
134
|
-
function restart() {
|
|
135
|
-
return restarting ??= (async () => {
|
|
221
|
+
async function restart() {
|
|
222
|
+
return (restarting ??= (async () => {
|
|
136
223
|
await stopChild();
|
|
137
224
|
if (disposed) return;
|
|
225
|
+
if (!delegate) rmSync(controlFile(), { force: true });
|
|
138
226
|
session = randomUUID();
|
|
139
227
|
requestFile = path.join(root, ".ds", `preview-requests-${session}.json`);
|
|
140
228
|
reportFile = path.join(root, ".ds", `build-status-${session}.json`);
|
|
141
|
-
state = "idle";
|
|
142
|
-
|
|
229
|
+
state = "idle";
|
|
230
|
+
error = undefined;
|
|
231
|
+
child = closed = stopping = undefined;
|
|
232
|
+
childClosed = false;
|
|
233
|
+
ready.clear();
|
|
234
|
+
baselines.clear();
|
|
235
|
+
active = undefined;
|
|
236
|
+
stalled = false;
|
|
143
237
|
start();
|
|
144
|
-
})().finally(() => {
|
|
238
|
+
})().finally(() => {
|
|
239
|
+
restarting = undefined;
|
|
240
|
+
}));
|
|
145
241
|
}
|
|
146
242
|
|
|
147
243
|
async function ensure(file, signal, { waitFor = "verified" } = {}) {
|
|
148
244
|
if (signal?.aborted) throw new Error("Preview request cancelled.");
|
|
149
245
|
if (suspended) {
|
|
150
|
-
const current = buildStatus().previews.find(entry=>config.apps.some(app=>path.resolve(root,app.file)===file && app.id===entry.id));
|
|
246
|
+
const current = (await buildStatus()).previews.find((entry) => config.apps.some((app) => path.resolve(root, app.file) === file && app.id === entry.id));
|
|
151
247
|
if (current?.current) return current;
|
|
152
|
-
if (waitFor === "compiled"
|
|
248
|
+
if (waitFor === "compiled") {
|
|
153
249
|
try {
|
|
154
250
|
const manifest = readPreviewManifest(withPreviewSession({ root, config: { mcp: config } }, resourceSession()));
|
|
155
|
-
const app = config.apps.find(entry => path.resolve(root, entry.file) === file);
|
|
156
|
-
if (manifest?.scenarios.some(entry => entry.id === app?.id)) return buildStatus().previews.find(entry => entry.id === app.id);
|
|
157
|
-
} catch {
|
|
251
|
+
const app = config.apps.find((entry) => path.resolve(root, entry.file) === file);
|
|
252
|
+
if (manifest?.scenarios.some((entry) => entry.id === app?.id)) return (await buildStatus()).previews.find((entry) => entry.id === app.id);
|
|
253
|
+
} catch {
|
|
254
|
+
/* No retained preview: queue this request until validation ends. */
|
|
255
|
+
}
|
|
158
256
|
}
|
|
159
|
-
if(immutablePark)
|
|
257
|
+
if (immutablePark)
|
|
258
|
+
throw Object.assign(new Error("Candidate inputs changed after the production build; rerun validation."), {
|
|
259
|
+
build: { code: "ADS_CANDIDATE_PREVIEW_STALE" },
|
|
260
|
+
});
|
|
160
261
|
await waitForResume(signal);
|
|
161
262
|
}
|
|
162
263
|
if (state === "failed" || restarting || stalled) await restart();
|
|
163
264
|
if (disposed) throw new Error("Preview watcher is stopped.");
|
|
164
265
|
start();
|
|
165
266
|
if (prewarm) {
|
|
166
|
-
const selected=config.apps.find(app=>path.resolve(root,app.file)===file);
|
|
167
|
-
if(selected)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
267
|
+
const selected = config.apps.find((app) => path.resolve(root, app.file) === file);
|
|
268
|
+
if (selected)
|
|
269
|
+
try {
|
|
270
|
+
const directory = path.join(root, ".ds"),
|
|
271
|
+
target = path.join(directory, "last-preview.json"),
|
|
272
|
+
temporary = target + ".tmp";
|
|
273
|
+
mkdirSync(directory, { recursive: true });
|
|
274
|
+
if (realpathSync(directory) === directory) {
|
|
275
|
+
writeFileSync(temporary, JSON.stringify({ scenario: selected.id }));
|
|
276
|
+
renameSync(temporary, target);
|
|
277
|
+
}
|
|
278
|
+
} catch {
|
|
279
|
+
/* Remembering navigation must not prevent read-only previews. */
|
|
280
|
+
}
|
|
172
281
|
}
|
|
173
|
-
request(
|
|
282
|
+
request(
|
|
283
|
+
file,
|
|
284
|
+
(await buildStatus()).previews.some((entry) => entry.diagnostics.some((item) => item.code === "ADS_PREVIEW_STALE_SOURCE")),
|
|
285
|
+
);
|
|
174
286
|
if (signal?.aborted) throw new Error("Preview request cancelled.");
|
|
175
287
|
const app = config.apps.find((entry) => path.resolve(root, entry.file) === file);
|
|
176
288
|
let baseline = baselines.get(file) ?? null;
|
|
@@ -180,55 +292,105 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
180
292
|
if (signal?.aborted) throw new Error("Preview request cancelled.");
|
|
181
293
|
if (suspended) {
|
|
182
294
|
const pausedAt = activeNow();
|
|
183
|
-
await waitForResume(signal);
|
|
295
|
+
await waitForResume(signal);
|
|
296
|
+
deadline += activeNow() - pausedAt;
|
|
184
297
|
if (disposed) throw new Error("Preview watcher is stopped.");
|
|
185
|
-
start();
|
|
298
|
+
start();
|
|
299
|
+
request(file, true);
|
|
300
|
+
baseline = baselines.get(file) ?? null;
|
|
186
301
|
}
|
|
187
|
-
const build = buildStatus().previews.find((entry) => entry.id === app?.id);
|
|
188
|
-
if (!restarted && build?.diagnostics.some(item => item.code === "ADS_PREVIEW_RESTART")) {
|
|
189
|
-
restarted = true;
|
|
302
|
+
const build = (await buildStatus()).previews.find((entry) => entry.id === app?.id);
|
|
303
|
+
if (!restarted && build?.diagnostics.some((item) => item.code === "ADS_PREVIEW_RESTART")) {
|
|
304
|
+
restarted = true;
|
|
305
|
+
await restart();
|
|
306
|
+
request(file);
|
|
307
|
+
baseline = baselines.get(file) ?? null;
|
|
308
|
+
continue;
|
|
190
309
|
}
|
|
191
310
|
// Interactive browsing may use compiled feedback or an earlier accepted
|
|
192
311
|
// view. It returns the actual non-current build status, never evidence.
|
|
193
|
-
if (waitFor === "compiled"
|
|
312
|
+
if (waitFor === "compiled") {
|
|
194
313
|
if (build?.live) return build;
|
|
195
314
|
try {
|
|
196
315
|
const manifest = readPreviewManifest(withPreviewSession({ root, config: { mcp: config } }, resourceSession()));
|
|
197
|
-
if (manifest && (!command || manifest.session === session) && manifest.scenarios.some(entry => entry.id === app?.id)) return build;
|
|
198
|
-
} catch {
|
|
316
|
+
if (manifest && (!command || manifest.session === session) && manifest.scenarios.some((entry) => entry.id === app?.id)) return build;
|
|
317
|
+
} catch {
|
|
318
|
+
/* No retained graph: wait for compilation or its error. */
|
|
319
|
+
}
|
|
199
320
|
}
|
|
200
321
|
if (build?.state === "error") throw buildFailure(build);
|
|
201
322
|
if (command && state !== "running") throw new Error(error ?? "Preview watcher is stopped.");
|
|
323
|
+
if (delegate && delegate.status().state === "failed") throw new Error(delegate.status().error ?? "The project's preview compiler stopped.");
|
|
202
324
|
if (build?.current) return build;
|
|
203
325
|
if (build?.state === "unreported" && (!command || ready.has(file))) return build;
|
|
204
326
|
const current = stamp(file);
|
|
205
|
-
if (build?.state === "unreported" && current !== null && current !== baseline) {
|
|
327
|
+
if (build?.state === "unreported" && current !== null && current !== baseline) {
|
|
328
|
+
ready.add(file);
|
|
329
|
+
return build;
|
|
330
|
+
}
|
|
206
331
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
207
332
|
}
|
|
208
333
|
stalled = true;
|
|
209
|
-
const report = buildStatus();
|
|
210
|
-
throw Object.assign(
|
|
334
|
+
const report = await buildStatus();
|
|
335
|
+
throw Object.assign(
|
|
336
|
+
new Error(
|
|
337
|
+
`Preview build is still pending${report.progress ? ` in ${report.progress.phase} for ${Math.round((Date.now() - Date.parse(report.progress.updatedAt)) / 1000)}s` : ""}. Inspect ads://project/build and builder logs. Invoke the preview again to restart the timed-out builder within this MCP session.`,
|
|
338
|
+
),
|
|
339
|
+
{ build: { ...report, watcher: status(), code: "ADS_PREVIEW_PENDING" } },
|
|
340
|
+
);
|
|
211
341
|
}
|
|
212
342
|
|
|
213
|
-
const status = () => ({
|
|
214
|
-
|
|
215
|
-
|
|
343
|
+
const status = () => ({
|
|
344
|
+
state,
|
|
345
|
+
buildTimeoutMs: buildTimeout,
|
|
346
|
+
...(stalled ? { stalled: true } : {}),
|
|
347
|
+
...(child?.pid ? { pid: child.pid } : {}),
|
|
348
|
+
...(ownerGuard?.pid ? { guardPid: ownerGuard.pid } : {}),
|
|
349
|
+
...(error ? { error } : {}),
|
|
350
|
+
});
|
|
351
|
+
const resourceSession = () => (command ? session : undefined);
|
|
352
|
+
const buildStatus = async () =>
|
|
353
|
+
inspectBuildStatus(root, config, command ? { session, previewSession: resourceSession(), file: reportFile, processState: status() } : {});
|
|
216
354
|
function clearOutput() {
|
|
217
|
-
for (const directory of previewSessionDirectories(withPreviewSession({ root, config: { mcp: config } }, resourceSession())))
|
|
355
|
+
for (const directory of previewSessionDirectories(withPreviewSession({ root, config: { mcp: config } }, resourceSession())))
|
|
356
|
+
rmSync(directory, { recursive: true, force: true });
|
|
218
357
|
}
|
|
219
358
|
|
|
220
359
|
async function stopChild({ preserve = false } = {}) {
|
|
221
360
|
rmSync(requestFile, { force: true });
|
|
222
361
|
if (stopping) return stopping;
|
|
223
|
-
const cleanup = () => {
|
|
224
|
-
|
|
362
|
+
const cleanup = () => {
|
|
363
|
+
if (!preserve) {
|
|
364
|
+
rmSync(reportFile, { force: true });
|
|
365
|
+
rmSync(path.join(root, ".ds", `full-build-${session}.json`), { force: true });
|
|
366
|
+
clearOutput();
|
|
367
|
+
}
|
|
368
|
+
if (!delegate) rmSync(controlFile(), { force: true });
|
|
369
|
+
};
|
|
370
|
+
if (delegate) {
|
|
371
|
+
delegate.detachDraft(session);
|
|
372
|
+
state = "stopped";
|
|
373
|
+
cleanup();
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (!child || childClosed) {
|
|
377
|
+
if (command) state = "stopped";
|
|
378
|
+
cleanup();
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
225
381
|
if (state === "stopped") return;
|
|
226
382
|
state = "stopping";
|
|
383
|
+
// Publish the pending promise immediately so concurrent callers share cleanup.
|
|
227
384
|
stopping = (async () => {
|
|
228
385
|
kill("SIGTERM");
|
|
229
386
|
clearTimeout(killTimer);
|
|
230
387
|
const timer = setTimeout(() => kill("SIGKILL"), 1500);
|
|
231
|
-
try {
|
|
388
|
+
try {
|
|
389
|
+
await closed;
|
|
390
|
+
} finally {
|
|
391
|
+
clearTimeout(timer);
|
|
392
|
+
cleanup();
|
|
393
|
+
}
|
|
232
394
|
})();
|
|
233
395
|
return stopping;
|
|
234
396
|
}
|
|
@@ -236,117 +398,259 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
236
398
|
if (!suspended || disposed) return Promise.resolve();
|
|
237
399
|
if (signal?.aborted) return Promise.reject(new Error("Preview request cancelled."));
|
|
238
400
|
return new Promise((resolve, reject) => {
|
|
239
|
-
const abort = () => {
|
|
401
|
+
const abort = () => {
|
|
402
|
+
signal?.removeEventListener("abort", abort);
|
|
403
|
+
reject(new Error("Preview request cancelled."));
|
|
404
|
+
};
|
|
240
405
|
signal?.addEventListener("abort", abort, { once: true });
|
|
241
|
-
resuming.promise.then(() => {
|
|
406
|
+
resuming.promise.then(() => {
|
|
407
|
+
signal?.removeEventListener("abort", abort);
|
|
408
|
+
resolve();
|
|
409
|
+
});
|
|
242
410
|
});
|
|
243
411
|
}
|
|
244
412
|
function resume() {
|
|
245
|
-
if (suspending) {
|
|
413
|
+
if (suspending) {
|
|
414
|
+
void suspending.then(resume);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
246
417
|
if (!suspended) return;
|
|
247
|
-
suspended = false;
|
|
418
|
+
suspended = false;
|
|
419
|
+
immutablePark = false;
|
|
248
420
|
state = command ? "idle" : "disabled";
|
|
249
|
-
error = undefined;
|
|
250
|
-
|
|
421
|
+
error = undefined;
|
|
422
|
+
child = closed = stopping = undefined;
|
|
423
|
+
childClosed = false;
|
|
424
|
+
ready.clear();
|
|
425
|
+
baselines.clear();
|
|
251
426
|
// Requests are replayed on demand; publication keeps its existing session.
|
|
252
|
-
const previous = resuming;
|
|
427
|
+
const previous = resuming;
|
|
428
|
+
resuming = undefined;
|
|
429
|
+
previous.finish();
|
|
253
430
|
}
|
|
254
|
-
return {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
if (
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
431
|
+
return {
|
|
432
|
+
start,
|
|
433
|
+
ensure,
|
|
434
|
+
async buildAll(signal, { timeoutMs = 300000 } = {}) {
|
|
435
|
+
await waitForResume(signal);
|
|
436
|
+
if (!command || disposed) throw new Error("Preview builds need a framework in ds.config.json.");
|
|
437
|
+
if (state === "failed" || restarting || stalled) await restart();
|
|
438
|
+
start();
|
|
439
|
+
full = randomUUID();
|
|
440
|
+
request(active, true);
|
|
441
|
+
const token = full,
|
|
442
|
+
deadline = activeNow() + timeoutMs;
|
|
443
|
+
while (activeNow() < deadline) {
|
|
444
|
+
if (signal?.aborted) throw new Error("Preview build cancelled.");
|
|
445
|
+
if (state !== "running") throw new Error(error ?? "Preview compiler stopped during full build.");
|
|
446
|
+
let result;
|
|
447
|
+
try {
|
|
448
|
+
result = JSON.parse(readFileSync(path.join(root, ".ds", `full-build-${session}.json`), "utf8"));
|
|
449
|
+
} catch {
|
|
450
|
+
/* Waiting for this request. */
|
|
451
|
+
}
|
|
452
|
+
if (result?.token === token) {
|
|
453
|
+
const report = await buildStatus();
|
|
454
|
+
if (!result.ok)
|
|
455
|
+
throw buildFailure({ ...report, diagnostics: [...(report.diagnostics ?? []), ...report.previews.flatMap((entry) => entry.diagnostics)] });
|
|
456
|
+
const scenarios = report.previews.filter((entry) => entry.id.includes("/"));
|
|
457
|
+
if (!scenarios.length || scenarios.some((entry) => !entry.current))
|
|
458
|
+
throw new Error("Full preview build is stale or incomplete; retry against current source.");
|
|
459
|
+
return report;
|
|
460
|
+
}
|
|
461
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
271
462
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
463
|
+
stalled = true;
|
|
464
|
+
throw new Error("Full preview build exceeded its command budget.");
|
|
465
|
+
},
|
|
466
|
+
async initialize() {
|
|
467
|
+
if (disposed || !command) return;
|
|
468
|
+
if (immutablePark) return;
|
|
469
|
+
await waitForResume();
|
|
470
|
+
if (disposed) return;
|
|
471
|
+
if (state === "failed" || restarting || stalled) await restart();
|
|
472
|
+
start();
|
|
473
|
+
const deadline = activeNow() + buildTimeout;
|
|
474
|
+
while (!disposed && state === "running" && activeNow() < deadline) {
|
|
475
|
+
try {
|
|
476
|
+
if (JSON.parse(readFileSync(reportFile, "utf8")).session === session) return;
|
|
477
|
+
} catch {
|
|
478
|
+
/* Waiting for compiler initialization, without requesting a graph. */
|
|
479
|
+
}
|
|
480
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
481
|
+
}
|
|
482
|
+
if (!disposed) throw new Error(error ?? "Preview compiler initialization timed out.");
|
|
483
|
+
},
|
|
484
|
+
invalidate() {
|
|
485
|
+
invalidation = randomUUID();
|
|
486
|
+
if (active) request(active, true);
|
|
487
|
+
},
|
|
488
|
+
async warm(files) {
|
|
489
|
+
if (disposed || !command || !files.length) return;
|
|
490
|
+
if (immutablePark)
|
|
491
|
+
throw Object.assign(new Error("Candidate inputs changed after the production build; rerun validation."), {
|
|
492
|
+
build: { code: "ADS_CANDIDATE_PREVIEW_STALE" },
|
|
493
|
+
});
|
|
494
|
+
await waitForResume();
|
|
495
|
+
const selected = active;
|
|
496
|
+
if (state === "failed" || restarting || stalled) await restart();
|
|
497
|
+
if (disposed) return;
|
|
498
|
+
start();
|
|
499
|
+
for (const file of files) requests.add(file);
|
|
500
|
+
// Preparing a graph must not replace the user's active selection.
|
|
501
|
+
request(active ?? selected ?? files[0], true);
|
|
502
|
+
},
|
|
503
|
+
async suspend({ immutable = false } = {}) {
|
|
504
|
+
if (disposed || !command) return;
|
|
505
|
+
immutablePark = immutable;
|
|
506
|
+
if (suspended) return suspending;
|
|
507
|
+
suspended = true;
|
|
508
|
+
let finish;
|
|
509
|
+
resuming = {
|
|
510
|
+
promise: new Promise((resolve) => {
|
|
511
|
+
finish = resolve;
|
|
512
|
+
}),
|
|
513
|
+
finish: () => finish(),
|
|
514
|
+
};
|
|
515
|
+
// Shutdown must await parking before resume can clear the owned child handle.
|
|
516
|
+
suspending = (async () => {
|
|
517
|
+
await restarting;
|
|
518
|
+
await stopChild({ preserve: true });
|
|
519
|
+
if (!disposed) state = "suspended";
|
|
520
|
+
})();
|
|
521
|
+
try {
|
|
522
|
+
await suspending;
|
|
523
|
+
} finally {
|
|
524
|
+
suspending = undefined;
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
resume,
|
|
528
|
+
async stop() {
|
|
529
|
+
disposed = true;
|
|
530
|
+
await restarting;
|
|
531
|
+
await suspending;
|
|
532
|
+
resume();
|
|
533
|
+
return stopChild();
|
|
534
|
+
},
|
|
535
|
+
kill: () => kill("SIGKILL"),
|
|
536
|
+
status,
|
|
537
|
+
resourceSession,
|
|
538
|
+
buildStatus,
|
|
539
|
+
/** Host a draft workspace's compiler instance in this watcher's process, starting it if needed. */
|
|
540
|
+
attachDraft(entry) {
|
|
541
|
+
drafts.set(entry.session, entry);
|
|
542
|
+
if (state === "running") writeControl();
|
|
543
|
+
else start();
|
|
544
|
+
},
|
|
545
|
+
detachDraft(id) {
|
|
546
|
+
if (drafts.delete(id) && state === "running") writeControl();
|
|
547
|
+
},
|
|
548
|
+
setApps(apps) {
|
|
549
|
+
for (const app of apps) {
|
|
550
|
+
const file = path.resolve(root, app.file);
|
|
551
|
+
if (!baselines.has(file)) baselines.set(file, stamp(file));
|
|
552
|
+
}
|
|
553
|
+
config.apps = apps;
|
|
554
|
+
},
|
|
555
|
+
};
|
|
315
556
|
}
|
|
316
557
|
|
|
317
558
|
/** Keep one shared handle while validated project configuration replaces its compiler. */
|
|
318
559
|
export function createReconfigurablePreviewWatch(root, config, options) {
|
|
319
560
|
let current = createPreviewWatch(root, config, options);
|
|
320
561
|
let signature = JSON.stringify(config);
|
|
321
|
-
let apps = config.apps;
|
|
322
|
-
|
|
562
|
+
let apps = config.apps ?? [];
|
|
563
|
+
const drafts = new Map();
|
|
564
|
+
let pending = Promise.resolve(),
|
|
565
|
+
replacing = false,
|
|
566
|
+
stopped = false,
|
|
567
|
+
parked = false,
|
|
568
|
+
parkOptions;
|
|
323
569
|
return {
|
|
324
|
-
start() {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
async
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
570
|
+
start() {
|
|
571
|
+
if (!stopped && !replacing && !parked) current.start();
|
|
572
|
+
},
|
|
573
|
+
async initialize() {
|
|
574
|
+
await pending;
|
|
575
|
+
if (!stopped) return current.initialize();
|
|
576
|
+
},
|
|
577
|
+
async ensure(file, signal, options) {
|
|
578
|
+
await pending;
|
|
579
|
+
if (stopped) throw new Error("Preview watcher is stopped.");
|
|
580
|
+
return current.ensure(file, signal, options);
|
|
581
|
+
},
|
|
582
|
+
status() {
|
|
583
|
+
return replacing ? { state: "reconfiguring" } : current.status();
|
|
584
|
+
},
|
|
585
|
+
resourceSession() {
|
|
586
|
+
return current.resourceSession();
|
|
587
|
+
},
|
|
588
|
+
async buildStatus() {
|
|
589
|
+
return current.buildStatus();
|
|
590
|
+
},
|
|
591
|
+
async invalidate() {
|
|
592
|
+
await pending;
|
|
593
|
+
if (!stopped) current.invalidate();
|
|
594
|
+
},
|
|
595
|
+
async warm(files) {
|
|
596
|
+
await pending;
|
|
597
|
+
if (!stopped) return current.warm(files);
|
|
598
|
+
},
|
|
599
|
+
async buildAll(signal, options) {
|
|
600
|
+
await pending;
|
|
601
|
+
if (stopped) throw new Error("Preview watcher is stopped.");
|
|
602
|
+
return current.buildAll(signal, options);
|
|
603
|
+
},
|
|
604
|
+
async suspend(options) {
|
|
605
|
+
parked = true;
|
|
606
|
+
parkOptions = options;
|
|
607
|
+
await pending;
|
|
608
|
+
if (!stopped && parked) return current.suspend(options);
|
|
609
|
+
},
|
|
610
|
+
resume() {
|
|
611
|
+
parked = false;
|
|
612
|
+
current.resume();
|
|
613
|
+
},
|
|
614
|
+
setApps(next) {
|
|
615
|
+
apps = next;
|
|
616
|
+
current.setApps(next);
|
|
617
|
+
},
|
|
618
|
+
attachDraft(entry) {
|
|
619
|
+
drafts.set(entry.session, entry);
|
|
620
|
+
if (!replacing && !stopped) current.attachDraft(entry);
|
|
621
|
+
},
|
|
622
|
+
detachDraft(id) {
|
|
623
|
+
drafts.delete(id);
|
|
624
|
+
current.detachDraft(id);
|
|
625
|
+
},
|
|
626
|
+
kill() {
|
|
627
|
+
current.kill();
|
|
628
|
+
},
|
|
337
629
|
reconfigure(next, force = false) {
|
|
338
630
|
const nextSignature = JSON.stringify(next);
|
|
339
631
|
if (!force && signature === nextSignature) return pending;
|
|
340
632
|
signature = nextSignature;
|
|
341
633
|
replacing = true;
|
|
342
|
-
pending = pending
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
634
|
+
pending = pending
|
|
635
|
+
.then(async () => {
|
|
636
|
+
await current.stop();
|
|
637
|
+
if (stopped) return;
|
|
638
|
+
current = createPreviewWatch(root, { ...next, apps }, options);
|
|
639
|
+
if (parked) await current.suspend(parkOptions);
|
|
640
|
+
else {
|
|
641
|
+
current.start();
|
|
642
|
+
for (const entry of drafts.values()) current.attachDraft(entry);
|
|
643
|
+
}
|
|
644
|
+
})
|
|
645
|
+
.finally(() => {
|
|
646
|
+
replacing = false;
|
|
647
|
+
});
|
|
348
648
|
return pending;
|
|
349
649
|
},
|
|
350
|
-
async stop() {
|
|
650
|
+
async stop() {
|
|
651
|
+
stopped = true;
|
|
652
|
+
await pending;
|
|
653
|
+
await current.stop();
|
|
654
|
+
},
|
|
351
655
|
};
|
|
352
656
|
}
|