@reqvire-org/ads 0.4.0 → 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 +105 -86
- 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 +5 -5
- package/dist/atomic-composition.mjs +191 -70
- package/dist/atomic-trace.mjs +120 -50
- package/dist/behavior-libraries.mjs +106 -37
- package/dist/behaviors.mjs +219 -77
- package/dist/boundaries.mjs +135 -38
- package/dist/brand-assets.mjs +219 -47
- package/dist/brands.mjs +86 -27
- package/dist/bun-compiler.mjs +28 -14
- package/dist/bun-worker.mjs +7 -5
- package/dist/capture/worker.mjs +15 -4
- package/dist/capture-store.mjs +4 -2
- package/dist/capture.mjs +17 -14
- package/dist/check-service.mjs +40 -57
- package/dist/check.mjs +749 -188
- package/dist/cli.mjs +200 -99
- package/dist/color-values.mjs +21 -21
- package/dist/component-contrast.mjs +2 -2
- package/dist/config.mjs +303 -135
- package/dist/construction-styles.cjs +10 -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 +2 -2
- package/dist/foundation-views.mjs +238 -0
- package/dist/foundation.mjs +63 -39
- package/dist/generated-entries.mjs +101 -34
- package/dist/icons.mjs +79 -32
- package/dist/image-attributes.mjs +109 -36
- package/dist/image-size.mjs +1 -1
- package/dist/index.mjs +0 -2
- package/dist/init.mjs +122 -41
- package/dist/investigations.mjs +2 -2
- package/dist/layers.mjs +298 -129
- package/dist/layout-widths.mjs +180 -85
- package/dist/linaria/preserve-values.cjs +7 -0
- package/dist/linaria/spatial-inputs.cjs +56 -0
- package/dist/lockup-composition.mjs +44 -0
- package/dist/lockup-model.cjs +64 -0
- package/dist/mcp/THIRD_PARTY_NOTICES.md +51 -1
- package/dist/mcp/apps.mjs +4 -30
- package/dist/mcp/behavior-pages.mjs +72 -24
- package/dist/mcp/build-status.mjs +257 -64
- package/dist/mcp/catalog.mjs +90 -26
- package/dist/mcp/context.mjs +17 -18
- package/dist/mcp/draft-discovery.mjs +44 -21
- package/dist/mcp/drafts.mjs +901 -281
- package/dist/mcp/execution-coordinator.mjs +417 -167
- package/dist/mcp/execution-results.mjs +7 -7
- package/dist/mcp/mutations.mjs +670 -234
- package/dist/mcp/preview-watch.mjs +448 -170
- package/dist/mcp/preview-widget.bundle.js +44 -50
- package/dist/mcp/prompts.mjs +5 -5
- package/dist/mcp/result-pages.mjs +1 -1
- package/dist/mcp/sandbox-host.mjs +1 -1
- package/dist/mcp/server.mjs +2402 -577
- package/dist/mcp/showcase-host.mjs +165 -41
- package/dist/mcp/skills.mjs +1 -1
- package/dist/mcp/text-diff.mjs +29 -10
- package/dist/paint-contracts.mjs +174 -81
- package/dist/palette-generated.mjs +2 -2
- package/dist/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 +8 -34
- package/dist/project-documents.mjs +1 -1
- package/dist/public-api.mjs +69 -31
- package/dist/public-props.mjs +39 -22
- package/dist/{browser-audit → render-audit}/axe-run.mjs +3 -3
- package/dist/{browser-audit → render-audit}/image-shape.mjs +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 +719 -378
- package/dist/scenarios-vite.d.mts +1 -3
- package/dist/scenarios-vite.mjs +2 -81
- package/dist/scenarios.mjs +421 -157
- package/dist/selector-match.mjs +2 -2
- package/dist/showcase/client.bundle.js +57 -56
- package/dist/showcase/draft-navigation.js +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 +130 -119
- package/dist/skills/ads-designer/references/accessibility.md +12 -13
- package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
- package/dist/skills/ads-designer/references/behaviors.md +30 -27
- package/dist/skills/ads-designer/references/branding.md +98 -10
- package/dist/skills/ads-designer/references/captures.md +25 -0
- package/dist/skills/ads-designer/references/cli.md +21 -24
- package/dist/skills/ads-designer/references/contracts.md +7 -6
- package/dist/skills/ads-designer/references/design-data.md +49 -52
- package/dist/skills/ads-designer/references/drafts.md +20 -17
- package/dist/skills/ads-designer/references/evidence.md +1 -5
- package/dist/skills/ads-designer/references/guarded-editing.md +14 -18
- package/dist/skills/ads-designer/references/layers.md +1 -1
- package/dist/skills/ads-designer/references/layout.md +347 -0
- package/dist/skills/ads-designer/references/mobile.md +2 -1
- package/dist/skills/{ads-motion/references/performance.md → ads-designer/references/motion-performance.md} +5 -1
- package/dist/skills/{ads-motion/references/build.md → ads-designer/references/motion.md} +73 -5
- package/dist/skills/ads-designer/references/review.md +37 -34
- package/dist/skills/ads-designer/references/runtimes.md +33 -30
- package/dist/skills/ads-designer/references/scenarios.md +16 -18
- package/dist/skills/{ads-break-ui/references/catalog.md → ads-designer/references/stress-catalog.md} +3 -1
- package/dist/skills/ads-designer/references/stress-test.md +68 -0
- package/dist/skills/ads-designer/references/validation.md +83 -75
- package/dist/skills/ads-designer/references/workflows.md +8 -33
- package/dist/skills/ads-import/SKILL.md +43 -325
- package/dist/skills/ads-import/references/atomic-styles.md +4 -4
- package/dist/skills/ads-import/references/behaviors.md +30 -27
- package/dist/skills/ads-import/references/branding.md +5 -5
- package/dist/skills/ads-import/references/captures.md +25 -0
- package/dist/skills/ads-import/references/cli.md +21 -24
- package/dist/skills/ads-import/references/compatibility.md +1 -1
- package/dist/skills/ads-import/references/contracts.md +7 -6
- package/dist/skills/ads-import/references/design-data.md +49 -52
- package/dist/skills/ads-import/references/drafts.md +20 -17
- package/dist/skills/ads-import/references/evidence.md +1 -5
- package/dist/skills/ads-import/references/guarded-editing.md +14 -18
- package/dist/skills/ads-import/references/implementation.md +2 -1
- package/dist/skills/ads-import/references/layers.md +1 -1
- package/dist/skills/ads-import/references/layout.md +347 -0
- package/dist/skills/ads-import/references/review.md +37 -34
- package/dist/skills/ads-import/references/runtimes.md +33 -30
- package/dist/skills/ads-import/references/scenarios.md +16 -18
- package/dist/skills/ads-import/references/tokens.md +3 -3
- package/dist/skills/ads-import/references/validation.md +83 -75
- package/dist/skills/ads-import/references/workflows.md +8 -33
- package/dist/skills/ads-migrate/SKILL.md +56 -0
- package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +602 -0
- package/dist/skills/ads-port/SKILL.md +54 -343
- package/dist/skills/ads-port/references/atomic-styles.md +4 -4
- package/dist/skills/ads-port/references/behaviors.md +30 -27
- package/dist/skills/ads-port/references/captures.md +25 -0
- package/dist/skills/ads-port/references/cli.md +21 -24
- package/dist/skills/ads-port/references/contracts.md +7 -6
- package/dist/skills/ads-port/references/design-data.md +49 -52
- package/dist/skills/ads-port/references/drafts.md +20 -17
- package/dist/skills/ads-port/references/evidence.md +1 -5
- package/dist/skills/ads-port/references/guarded-editing.md +14 -18
- package/dist/skills/ads-port/references/layers.md +1 -1
- package/dist/skills/ads-port/references/layout.md +347 -0
- package/dist/skills/ads-port/references/lint-and-docs.md +8 -11
- package/dist/skills/ads-port/references/native-implementation.md +2 -1
- package/dist/skills/ads-port/references/review.md +37 -34
- package/dist/skills/ads-port/references/runtimes.md +33 -30
- package/dist/skills/ads-port/references/scenarios.md +16 -18
- package/dist/skills/ads-port/references/validation.md +83 -75
- package/dist/skills/ads-port/references/workflows.md +8 -33
- package/dist/source-symbols.mjs +1 -8
- package/dist/source-values.mjs +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 +25 -6
- package/dist/starters/preact/package.json +4 -8
- package/dist/starters/preact/tsconfig.json +4 -5
- package/dist/starters/preact/vite.config.ts +3 -3
- package/dist/starters/react/ADS.md +42 -47
- package/dist/starters/react/README.md +47 -49
- package/dist/starters/react/design-system/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/composition/Workspace/WorkspacePage/README.md +5 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +13 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +22 -0
- package/dist/starters/react/design-system/index.ts +2 -1
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +7 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +15 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +105 -0
- package/dist/starters/react/design-system/patterns/Conversation/README.md +9 -0
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +5 -0
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +21 -0
- package/dist/starters/react/design-system/patterns/Shell/README.md +43 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +5 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +21 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +274 -0
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -1
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
- package/dist/starters/react/design-system/review/index.ads.review.ts +4 -0
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +6 -0
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -1
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
- package/dist/starters/react/design-system/showcase/mcp/{main.tsx → main.ads.mount.tsx} +4 -2
- package/dist/starters/react/design-system/tokens/catalog.ads.json +1221 -0
- package/dist/starters/react/design-system/tokens/colors.css +1 -1
- package/dist/starters/react/design-system/tokens/spacing.css +22 -32
- package/dist/starters/react/design-system/tokens/spatial.ads.json +70 -0
- package/dist/starters/react/design-system/tokens/themes.generated.ts +1 -1
- package/dist/starters/react/ds.config.json +25 -6
- package/dist/starters/react/package.json +2 -6
- package/dist/starters/react/tsconfig.json +2 -3
- package/dist/starters/react/vite.config.ts +3 -3
- package/dist/style-boundaries.mjs +70 -25
- package/dist/task-cache.mjs +173 -72
- package/dist/task-worker.mjs +22 -11
- package/dist/test-boundaries.mjs +132 -59
- package/dist/themes-generated.mjs +1 -1
- package/dist/themes-watch.mjs +57 -22
- package/dist/themes.mjs +176 -73
- package/dist/token-export.mjs +39 -14
- package/dist/token-policy.mjs +6 -3
- package/dist/token-quality.mjs +6 -6
- package/dist/token-samples.mjs +16 -5
- package/dist/tokens.mjs +71 -26
- package/dist/ui-framework.mjs +16 -14
- package/dist/unit-contracts.mjs +251 -104
- package/dist/units.mjs +208 -98
- package/dist/usage.mjs +138 -38
- package/dist/validation-checks.mjs +115 -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 +90 -79
- package/docs/ARCHITECTURE.md +294 -136
- package/docs/BEHAVIORS.md +29 -25
- package/docs/CACHING.md +52 -17
- package/docs/CHANGELOG.md +309 -17
- package/docs/CONTRACTS.md +12 -4
- package/docs/DESIGN-REFERENCES.md +40 -0
- package/docs/GUIDE.md +270 -258
- package/docs/MCP.md +181 -324
- 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 -429
- package/dist/create.mjs +0 -48
- package/dist/lint-config.mjs +0 -50
- package/dist/mcp/project-widget.bundle.js +0 -114
- package/dist/mcp/reports.mjs +0 -101
- package/dist/mcp/widget.bundle.js +0 -147
- package/dist/oxlint.mjs +0 -89
- package/dist/preview-builder.mjs +0 -133
- package/dist/preview-workers.mjs +0 -184
- package/dist/showcase.mjs +0 -77
- package/dist/skills/ads-break-ui/LICENSE.upstream +0 -21
- package/dist/skills/ads-break-ui/README.md +0 -16
- package/dist/skills/ads-break-ui/SKILL.md +0 -412
- package/dist/skills/ads-break-ui/agents/openai.yaml +0 -4
- package/dist/skills/ads-break-ui/references/atomic-styles.md +0 -293
- package/dist/skills/ads-break-ui/references/behaviors.md +0 -412
- package/dist/skills/ads-break-ui/references/captures.md +0 -135
- package/dist/skills/ads-break-ui/references/contracts.md +0 -317
- package/dist/skills/ads-break-ui/references/design-data.md +0 -354
- package/dist/skills/ads-break-ui/references/drafts.md +0 -194
- package/dist/skills/ads-break-ui/references/evidence.md +0 -128
- package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -165
- package/dist/skills/ads-break-ui/references/layers.md +0 -145
- package/dist/skills/ads-break-ui/references/reporting.md +0 -101
- package/dist/skills/ads-break-ui/references/review.md +0 -97
- package/dist/skills/ads-break-ui/references/runtimes.md +0 -203
- package/dist/skills/ads-break-ui/references/scenarios.md +0 -246
- package/dist/skills/ads-break-ui/references/validation.md +0 -166
- package/dist/skills/ads-break-ui/references/verification.md +0 -58
- package/dist/skills/ads-break-ui/references/workflows.md +0 -90
- package/dist/skills/ads-designer/references/reporting.md +0 -101
- package/dist/skills/ads-import/references/reporting.md +0 -101
- package/dist/skills/ads-motion/LICENSE.upstream +0 -21
- package/dist/skills/ads-motion/README.md +0 -22
- package/dist/skills/ads-motion/SKILL.md +0 -385
- package/dist/skills/ads-motion/agents/openai.yaml +0 -4
- package/dist/skills/ads-motion/references/atomic-styles.md +0 -293
- package/dist/skills/ads-motion/references/audit.md +0 -44
- package/dist/skills/ads-motion/references/behaviors.md +0 -412
- package/dist/skills/ads-motion/references/captures.md +0 -135
- package/dist/skills/ads-motion/references/contracts.md +0 -317
- package/dist/skills/ads-motion/references/design-data.md +0 -354
- package/dist/skills/ads-motion/references/drafts.md +0 -194
- package/dist/skills/ads-motion/references/evidence.md +0 -128
- package/dist/skills/ads-motion/references/guarded-editing.md +0 -165
- package/dist/skills/ads-motion/references/layers.md +0 -145
- package/dist/skills/ads-motion/references/motion-review.md +0 -35
- package/dist/skills/ads-motion/references/reporting.md +0 -101
- package/dist/skills/ads-motion/references/review.md +0 -97
- package/dist/skills/ads-motion/references/runtimes.md +0 -203
- package/dist/skills/ads-motion/references/scenarios.md +0 -246
- package/dist/skills/ads-motion/references/validation.md +0 -166
- package/dist/skills/ads-motion/references/verification.md +0 -39
- package/dist/skills/ads-motion/references/workflows.md +0 -90
- package/dist/skills/ads-port/references/reporting.md +0 -101
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +0 -76
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +0 -137
- package/dist/starters/preact/design-system/showcase/mcp/main.tsx +0 -6
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +0 -12
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +0 -17
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +0 -75
- package/dist/starters/react/design-system/components/Layout/Grid/README.md +0 -21
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +0 -112
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/starters/react/design-system/review/grid-cell/GridCell.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
- package/dist/starters/react/design-system/review/index.ts +0 -6
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +0 -137
- package/dist/starters/react/design-system/showcase/mcp/index.html +0 -1
- package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +0 -124
- package/dist/starters/react/design-system/tokens/Color.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +0 -39
- package/dist/starters/react/design-system/tokens/Layout.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +0 -18
- package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +0 -30
- package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +0 -37
- package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +0 -29
- package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +0 -4
- package/dist/starters/react/package-lock.json +0 -4707
- package/dist/token-fixtures.mjs +0 -30
- package/docs/benchmarks/bun-previews.md +0 -91
- package/docs/benchmarks/preview-memory.md +0 -147
- package/docs/benchmarks/turbo-poc.md +0 -284
- package/docs/plans/execution-coordination.md +0 -57
- /package/dist/{browser-audit → render-audit}/first-render.mjs +0 -0
- /package/dist/{browser-audit → render-audit}/layout-shift.mjs +0 -0
|
@@ -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;
|
|
@@ -54,15 +84,28 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
54
84
|
if (delegate || !command) return;
|
|
55
85
|
mkdirSync(path.join(root, ".ds"), { recursive: true });
|
|
56
86
|
const temporary = `${controlFile()}.tmp`;
|
|
57
|
-
writeFileSync(temporary, JSON.stringify({ drafts: [...drafts.values()] }));
|
|
87
|
+
writeFileSync(temporary, JSON.stringify({ drafts: [...drafts.values()] }));
|
|
88
|
+
renameSync(temporary, controlFile());
|
|
58
89
|
}
|
|
59
|
-
function request(file,force = false) {
|
|
60
|
-
if (!command || !force && requests.has(file) && active === file) return;
|
|
61
|
-
if (file) {
|
|
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
|
+
}
|
|
62
96
|
mkdirSync(path.dirname(requestFile), { recursive: true });
|
|
63
97
|
if (realpathSync(path.dirname(requestFile)) !== path.dirname(requestFile)) throw new Error("Preview requests cannot resolve through a symlink.");
|
|
64
98
|
const temporary = `${requestFile}.tmp`;
|
|
65
|
-
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
|
+
);
|
|
66
109
|
renameSync(temporary, requestFile);
|
|
67
110
|
}
|
|
68
111
|
|
|
@@ -72,9 +115,13 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
72
115
|
if (process.platform === "win32") {
|
|
73
116
|
// taskkill also terminates the compiler's own subprocesses.
|
|
74
117
|
const terminator = spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
75
|
-
terminator.on("error", () => {
|
|
118
|
+
terminator.on("error", () => {
|
|
119
|
+
child.kill(signal);
|
|
120
|
+
});
|
|
76
121
|
} else process.kill(-child.pid, signal);
|
|
77
|
-
} catch (failure) {
|
|
122
|
+
} catch (failure) {
|
|
123
|
+
if (failure.code !== "ESRCH") throw failure;
|
|
124
|
+
}
|
|
78
125
|
}
|
|
79
126
|
function start() {
|
|
80
127
|
if (disposed || suspended || state !== "idle") return;
|
|
@@ -93,9 +140,26 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
93
140
|
// No shell: configured arguments remain literal. Child stdin cannot consume
|
|
94
141
|
// the MCP channel, and both output streams go exclusively to diagnostics.
|
|
95
142
|
const executable = developmentExecutable(command.command);
|
|
96
|
-
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
|
+
};
|
|
97
154
|
try {
|
|
98
|
-
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
|
+
});
|
|
99
163
|
} catch (failure) {
|
|
100
164
|
state = "failed";
|
|
101
165
|
error = `Cannot start preview watcher: ${failure.message}`;
|
|
@@ -105,9 +169,11 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
105
169
|
if (child.pid) {
|
|
106
170
|
// A small independent guard owns a pipe from this MCP process. It can
|
|
107
171
|
// terminate the detached compiler group even if this process is SIGKILLed.
|
|
108
|
-
const guard = ownerGuard = spawn(process.execPath, [fileURLToPath(new URL("./preview-owner-guard.mjs", import.meta.url)), String(child.pid)], {
|
|
109
|
-
stdio: ["pipe", "ignore", "pipe"],
|
|
110
|
-
|
|
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
|
+
}));
|
|
111
177
|
guard.stdin.on("error", () => {}); // Owner shutdown can race guard exit.
|
|
112
178
|
diagnostics(guard.stderr);
|
|
113
179
|
function guardFailed(failure) {
|
|
@@ -121,21 +187,24 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
121
187
|
}
|
|
122
188
|
diagnostics(child.stdout);
|
|
123
189
|
diagnostics(child.stderr);
|
|
124
|
-
closed = new Promise((resolve) =>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
+
);
|
|
139
208
|
child.once("exit", () => {
|
|
140
209
|
// A failed launcher must not leave its compiler subprocesses alive.
|
|
141
210
|
if (state !== "stopping") {
|
|
@@ -143,51 +212,77 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
143
212
|
killTimer = setTimeout(() => kill("SIGKILL"), 1500);
|
|
144
213
|
}
|
|
145
214
|
});
|
|
146
|
-
child.once("error", (failure) => {
|
|
215
|
+
child.once("error", (failure) => {
|
|
216
|
+
error = `Cannot start preview watcher: ${failure.message}`;
|
|
217
|
+
});
|
|
147
218
|
if (active) request(active, true);
|
|
148
219
|
}
|
|
149
220
|
|
|
150
|
-
function restart() {
|
|
151
|
-
return restarting ??= (async () => {
|
|
221
|
+
async function restart() {
|
|
222
|
+
return (restarting ??= (async () => {
|
|
152
223
|
await stopChild();
|
|
153
224
|
if (disposed) return;
|
|
154
225
|
if (!delegate) rmSync(controlFile(), { force: true });
|
|
155
226
|
session = randomUUID();
|
|
156
227
|
requestFile = path.join(root, ".ds", `preview-requests-${session}.json`);
|
|
157
228
|
reportFile = path.join(root, ".ds", `build-status-${session}.json`);
|
|
158
|
-
state = "idle";
|
|
159
|
-
|
|
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;
|
|
160
237
|
start();
|
|
161
|
-
})().finally(() => {
|
|
238
|
+
})().finally(() => {
|
|
239
|
+
restarting = undefined;
|
|
240
|
+
}));
|
|
162
241
|
}
|
|
163
242
|
|
|
164
243
|
async function ensure(file, signal, { waitFor = "verified" } = {}) {
|
|
165
244
|
if (signal?.aborted) throw new Error("Preview request cancelled.");
|
|
166
245
|
if (suspended) {
|
|
167
|
-
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));
|
|
168
247
|
if (current?.current) return current;
|
|
169
|
-
if (waitFor === "compiled"
|
|
248
|
+
if (waitFor === "compiled") {
|
|
170
249
|
try {
|
|
171
250
|
const manifest = readPreviewManifest(withPreviewSession({ root, config: { mcp: config } }, resourceSession()));
|
|
172
|
-
const app = config.apps.find(entry => path.resolve(root, entry.file) === file);
|
|
173
|
-
if (manifest?.scenarios.some(entry => entry.id === app?.id)) return buildStatus().previews.find(entry => entry.id === app.id);
|
|
174
|
-
} 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
|
+
}
|
|
175
256
|
}
|
|
176
|
-
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
|
+
});
|
|
177
261
|
await waitForResume(signal);
|
|
178
262
|
}
|
|
179
263
|
if (state === "failed" || restarting || stalled) await restart();
|
|
180
264
|
if (disposed) throw new Error("Preview watcher is stopped.");
|
|
181
265
|
start();
|
|
182
266
|
if (prewarm) {
|
|
183
|
-
const selected=config.apps.find(app=>path.resolve(root,app.file)===file);
|
|
184
|
-
if(selected)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
+
}
|
|
189
281
|
}
|
|
190
|
-
request(
|
|
282
|
+
request(
|
|
283
|
+
file,
|
|
284
|
+
(await buildStatus()).previews.some((entry) => entry.diagnostics.some((item) => item.code === "ADS_PREVIEW_STALE_SOURCE")),
|
|
285
|
+
);
|
|
191
286
|
if (signal?.aborted) throw new Error("Preview request cancelled.");
|
|
192
287
|
const app = config.apps.find((entry) => path.resolve(root, entry.file) === file);
|
|
193
288
|
let baseline = baselines.get(file) ?? null;
|
|
@@ -197,57 +292,105 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
197
292
|
if (signal?.aborted) throw new Error("Preview request cancelled.");
|
|
198
293
|
if (suspended) {
|
|
199
294
|
const pausedAt = activeNow();
|
|
200
|
-
await waitForResume(signal);
|
|
295
|
+
await waitForResume(signal);
|
|
296
|
+
deadline += activeNow() - pausedAt;
|
|
201
297
|
if (disposed) throw new Error("Preview watcher is stopped.");
|
|
202
|
-
start();
|
|
298
|
+
start();
|
|
299
|
+
request(file, true);
|
|
300
|
+
baseline = baselines.get(file) ?? null;
|
|
203
301
|
}
|
|
204
|
-
const build = buildStatus().previews.find((entry) => entry.id === app?.id);
|
|
205
|
-
if (!restarted && build?.diagnostics.some(item => item.code === "ADS_PREVIEW_RESTART")) {
|
|
206
|
-
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;
|
|
207
309
|
}
|
|
208
310
|
// Interactive browsing may use compiled feedback or an earlier accepted
|
|
209
311
|
// view. It returns the actual non-current build status, never evidence.
|
|
210
|
-
if (waitFor === "compiled"
|
|
312
|
+
if (waitFor === "compiled") {
|
|
211
313
|
if (build?.live) return build;
|
|
212
314
|
try {
|
|
213
315
|
const manifest = readPreviewManifest(withPreviewSession({ root, config: { mcp: config } }, resourceSession()));
|
|
214
|
-
if (manifest && (!command || manifest.session === session) && manifest.scenarios.some(entry => entry.id === app?.id)) return build;
|
|
215
|
-
} 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
|
+
}
|
|
216
320
|
}
|
|
217
321
|
if (build?.state === "error") throw buildFailure(build);
|
|
218
322
|
if (command && state !== "running") throw new Error(error ?? "Preview watcher is stopped.");
|
|
219
|
-
|
|
323
|
+
if (delegate && delegate.status().state === "failed") throw new Error(delegate.status().error ?? "The project's preview compiler stopped.");
|
|
220
324
|
if (build?.current) return build;
|
|
221
325
|
if (build?.state === "unreported" && (!command || ready.has(file))) return build;
|
|
222
326
|
const current = stamp(file);
|
|
223
|
-
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
|
+
}
|
|
224
331
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
225
332
|
}
|
|
226
333
|
stalled = true;
|
|
227
|
-
const report = buildStatus();
|
|
228
|
-
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
|
+
);
|
|
229
341
|
}
|
|
230
342
|
|
|
231
|
-
const status = () => ({
|
|
232
|
-
|
|
233
|
-
|
|
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() } : {});
|
|
234
354
|
function clearOutput() {
|
|
235
|
-
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 });
|
|
236
357
|
}
|
|
237
358
|
|
|
238
359
|
async function stopChild({ preserve = false } = {}) {
|
|
239
360
|
rmSync(requestFile, { force: true });
|
|
240
361
|
if (stopping) return stopping;
|
|
241
|
-
const cleanup = () => {
|
|
242
|
-
|
|
243
|
-
|
|
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
|
+
}
|
|
244
381
|
if (state === "stopped") return;
|
|
245
382
|
state = "stopping";
|
|
383
|
+
// Publish the pending promise immediately so concurrent callers share cleanup.
|
|
246
384
|
stopping = (async () => {
|
|
247
385
|
kill("SIGTERM");
|
|
248
386
|
clearTimeout(killTimer);
|
|
249
387
|
const timer = setTimeout(() => kill("SIGKILL"), 1500);
|
|
250
|
-
try {
|
|
388
|
+
try {
|
|
389
|
+
await closed;
|
|
390
|
+
} finally {
|
|
391
|
+
clearTimeout(timer);
|
|
392
|
+
cleanup();
|
|
393
|
+
}
|
|
251
394
|
})();
|
|
252
395
|
return stopping;
|
|
253
396
|
}
|
|
@@ -255,124 +398,259 @@ export function createPreviewWatch(root, config, { log = process.stderr, buildTi
|
|
|
255
398
|
if (!suspended || disposed) return Promise.resolve();
|
|
256
399
|
if (signal?.aborted) return Promise.reject(new Error("Preview request cancelled."));
|
|
257
400
|
return new Promise((resolve, reject) => {
|
|
258
|
-
const abort = () => {
|
|
401
|
+
const abort = () => {
|
|
402
|
+
signal?.removeEventListener("abort", abort);
|
|
403
|
+
reject(new Error("Preview request cancelled."));
|
|
404
|
+
};
|
|
259
405
|
signal?.addEventListener("abort", abort, { once: true });
|
|
260
|
-
resuming.promise.then(() => {
|
|
406
|
+
resuming.promise.then(() => {
|
|
407
|
+
signal?.removeEventListener("abort", abort);
|
|
408
|
+
resolve();
|
|
409
|
+
});
|
|
261
410
|
});
|
|
262
411
|
}
|
|
263
412
|
function resume() {
|
|
264
|
-
if (suspending) {
|
|
413
|
+
if (suspending) {
|
|
414
|
+
void suspending.then(resume);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
265
417
|
if (!suspended) return;
|
|
266
|
-
suspended = false;
|
|
418
|
+
suspended = false;
|
|
419
|
+
immutablePark = false;
|
|
267
420
|
state = command ? "idle" : "disabled";
|
|
268
|
-
error = undefined;
|
|
269
|
-
|
|
421
|
+
error = undefined;
|
|
422
|
+
child = closed = stopping = undefined;
|
|
423
|
+
childClosed = false;
|
|
424
|
+
ready.clear();
|
|
425
|
+
baselines.clear();
|
|
270
426
|
// Requests are replayed on demand; publication keeps its existing session.
|
|
271
|
-
const previous = resuming;
|
|
427
|
+
const previous = resuming;
|
|
428
|
+
resuming = undefined;
|
|
429
|
+
previous.finish();
|
|
272
430
|
}
|
|
273
|
-
return {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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));
|
|
290
462
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
+
};
|
|
338
556
|
}
|
|
339
557
|
|
|
340
558
|
/** Keep one shared handle while validated project configuration replaces its compiler. */
|
|
341
559
|
export function createReconfigurablePreviewWatch(root, config, options) {
|
|
342
560
|
let current = createPreviewWatch(root, config, options);
|
|
343
561
|
let signature = JSON.stringify(config);
|
|
344
|
-
let apps = config.apps;
|
|
562
|
+
let apps = config.apps ?? [];
|
|
345
563
|
const drafts = new Map();
|
|
346
|
-
let pending = Promise.resolve(),
|
|
564
|
+
let pending = Promise.resolve(),
|
|
565
|
+
replacing = false,
|
|
566
|
+
stopped = false,
|
|
567
|
+
parked = false,
|
|
568
|
+
parkOptions;
|
|
347
569
|
return {
|
|
348
|
-
start() {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
async
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
+
},
|
|
363
629
|
reconfigure(next, force = false) {
|
|
364
630
|
const nextSignature = JSON.stringify(next);
|
|
365
631
|
if (!force && signature === nextSignature) return pending;
|
|
366
632
|
signature = nextSignature;
|
|
367
633
|
replacing = true;
|
|
368
|
-
pending = pending
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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
|
+
});
|
|
374
648
|
return pending;
|
|
375
649
|
},
|
|
376
|
-
async stop() {
|
|
650
|
+
async stop() {
|
|
651
|
+
stopped = true;
|
|
652
|
+
await pending;
|
|
653
|
+
await current.stop();
|
|
654
|
+
},
|
|
377
655
|
};
|
|
378
656
|
}
|