@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
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
const postcss = require("postcss");
|
|
2
|
+
const { timeStage } = require("./stage-timing.cjs");
|
|
3
|
+
const { inspectSpatialCss } = require("./spatial-css.cjs");
|
|
4
|
+
|
|
5
|
+
const fail = message => { throw new Error(`ADS spatial: ${message}`); };
|
|
6
|
+
const tokenName = /^--[\w-]+$/;
|
|
7
|
+
const name = /^[a-z][\w-]*$/;
|
|
8
|
+
const closed = (value, keys, label) => {
|
|
9
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).some(key => !keys.includes(key))) fail(`${label} has unsupported fields.`);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/** Pure compile-time algebra. Never imported by a product runtime. */
|
|
13
|
+
function spatialModel(definition, values) {
|
|
14
|
+
closed(definition,["schemaVersion","miniUnit","fineUnit","scale","ratios","maxWidth","breakpoints","gutters"],"Spatial definition");
|
|
15
|
+
if (definition.schemaVersion !== 1) fail("Expected spatial schemaVersion 1.");
|
|
16
|
+
const resolve = (token, seen = new Set()) => {
|
|
17
|
+
if (!tokenName.test(token) || seen.has(token) || !values.has(token)) fail(`Undefined or cyclic spatial token ${token}.`);
|
|
18
|
+
const chain = new Set([...seen,token]);
|
|
19
|
+
let value = values.get(token).trim().replace(/var\(\s*(--[\w-]+)\s*\)/g,(_whole,ref)=>resolve(ref,chain));
|
|
20
|
+
// Geometry definitions intentionally accept a small, exact domain. Owner
|
|
21
|
+
// content can remain intrinsic; breakpoint algebra cannot depend on it.
|
|
22
|
+
const scaled = /^calc\(\s*([\d.]+)(px|rem)\s*([*/])\s*([\d.]+)\s*\)$/.exec(value);
|
|
23
|
+
if (scaled) value = `${scaled[3]==="*"?Number(scaled[1])*Number(scaled[4]):Number(scaled[1])/Number(scaled[4])}${scaled[2]}`;
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
const length = (token, positive=false) => {
|
|
27
|
+
const value=resolve(token), match=/^(\d*\.?\d+)(px|rem)?$/.exec(value);
|
|
28
|
+
if(!match || !match[2] && Number(match[1])!==0)fail(`${token} must resolve to a nonnegative px/rem length.`);
|
|
29
|
+
const px=Number(match[1])*(match[2]==="rem"?16:1);
|
|
30
|
+
if(!Number.isFinite(px) || positive && px<=0)fail(`${token} must be ${positive?"positive":"finite"}.`);
|
|
31
|
+
return px;
|
|
32
|
+
};
|
|
33
|
+
const mini=length(definition.miniUnit,true), fine=length(definition.fineUnit,true);
|
|
34
|
+
if(fine>mini || Math.abs(mini/fine-Math.round(mini/fine))>1e-7)fail("The fine unit must divide the mini unit.");
|
|
35
|
+
if(!Array.isArray(definition.scale) || !definition.scale.length)fail("Declare a fixed sizing scale.");
|
|
36
|
+
let previous=0;
|
|
37
|
+
for(const token of definition.scale){const size=length(token,true);if(size<=previous || Math.abs(size/mini-Math.round(size/mini))>1e-7)fail("Fixed sizes must increase and be mini-unit multiples.");previous=size;}
|
|
38
|
+
if(!Array.isArray(definition.ratios) || !definition.ratios.length || definition.ratios.some(ratio=>!/^\d+:[1-9]\d*$/.test(ratio)||Number(ratio.split(":")[0])<=0))fail("Ratios need positive width:height integers.");
|
|
39
|
+
const maxWidth=length(definition.maxWidth,true);
|
|
40
|
+
if(!Array.isArray(definition.breakpoints) || !definition.breakpoints.length)fail("Declare responsive breakpoints.");
|
|
41
|
+
const names=new Set();previous=-1;
|
|
42
|
+
const breakpoints=definition.breakpoints.map(point=>{
|
|
43
|
+
closed(point,["name","from","columns","margin"],"Breakpoint");
|
|
44
|
+
const from=length(point.from), count=Number(resolve(point.columns)), margin=length(point.margin);
|
|
45
|
+
if(!name.test(point.name)||names.has(point.name)||from<=previous||from>maxWidth||!Number.isInteger(count)||count<1||count>64||margin*2>=Math.max(from,1))fail(`Invalid breakpoint ${point.name}: ordered widths, 1–64 columns and positive content width are required.`);
|
|
46
|
+
names.add(point.name);previous=from;
|
|
47
|
+
return {...point,fromPx:from,count,marginPx:margin};
|
|
48
|
+
});
|
|
49
|
+
closed(definition.gutters,Object.keys(definition.gutters??{}),"Gutters");
|
|
50
|
+
if(!Object.keys(definition.gutters).length)fail("Declare gutter modes.");
|
|
51
|
+
for(const [mode,edges] of Object.entries(definition.gutters)){
|
|
52
|
+
if(!name.test(mode))fail(`Invalid gutter mode ${mode}.`);
|
|
53
|
+
closed(edges,["start","end"],"Gutter");
|
|
54
|
+
const inset=length(edges.start)+length(edges.end);
|
|
55
|
+
for(const point of breakpoints)if((point.fromPx-point.marginPx*2)/point.count<inset)fail(`${mode} cell insets exceed a track at ${point.name}.`);
|
|
56
|
+
}
|
|
57
|
+
const spacingRoots=new Set([definition.miniUnit,definition.fineUnit,...definition.scale]), spacingRoles=new Map();
|
|
58
|
+
function spacingRole(token,seen=new Set()) {
|
|
59
|
+
if(spacingRoles.has(token))return spacingRoles.get(token);
|
|
60
|
+
if(seen.has(token))return false;
|
|
61
|
+
const refs=[...(values.get(token)??"").matchAll(/var\(\s*(--[\w-]+)/g)].map(match=>match[1]);
|
|
62
|
+
const approved=spacingRoots.has(token)||/^--space-\d+$/.test(token)||refs.length>0&&refs.every(ref=>spacingRole(ref,new Set([...seen,token])));
|
|
63
|
+
spacingRoles.set(token,approved);
|
|
64
|
+
return approved;
|
|
65
|
+
}
|
|
66
|
+
const spacing=token=>{
|
|
67
|
+
const px=length(token);
|
|
68
|
+
if(px!==0&&!spacingRole(token))fail(`${token} is not a spacing role; use a shared spacing step or an alias of the spatial scale.`);
|
|
69
|
+
return px;
|
|
70
|
+
};
|
|
71
|
+
return { ...definition, breakpoints, maxWidthPx:maxWidth, length, spacing };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function declarations(node,allowed) {
|
|
75
|
+
const result={};
|
|
76
|
+
for(const child of node.nodes??[])if(child.type==="decl"){
|
|
77
|
+
if(!allowed.includes(child.prop)||child.important||Object.hasOwn(result,child.prop))fail(`Unsupported or repeated ${child.prop} in @${node.name}.`);
|
|
78
|
+
result[child.prop]=child.prop==="ratio"?child.value.trim().replace(/\s*\/\s*/g,":"):child.value.trim();
|
|
79
|
+
}else if(child.type!=="comment"&&!(child.type==="atrule"&&["ads-cell","ads-at","ads-layout"].includes(child.name)))fail(`Unsupported construction in @${node.name}.`);
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
const cssToken = token => token==="0" ? "0" : `var(${token})`;
|
|
83
|
+
const append = (node,property,value) => node.append(postcss.decl({prop:property,value:String(value)}));
|
|
84
|
+
const selector = value => /^\.[a-zA-Z_][\w-]*$|^\[data-[\w-]+=["'][\w-]+["']\]$/.test(value);
|
|
85
|
+
|
|
86
|
+
/** The one container name ADS layouts query. A cell declaring `container: region`
|
|
87
|
+
* establishes it; `context: container` layouts respond to the nearest one. */
|
|
88
|
+
const regionContainer = "ads-region";
|
|
89
|
+
const overlaySides = ["none","start","end"];
|
|
90
|
+
|
|
91
|
+
/** Check the actual local bound, not only the foundation's default geometry. */
|
|
92
|
+
function regionTracks(model, props, point, mode, tracks, fixedTracks) {
|
|
93
|
+
const count=Number(props.columns??point.count), margin=model.length(props.margin??point.margin);
|
|
94
|
+
const cap=props.bound==="full"?Infinity:model.length(!props.bound||props.bound==="system"?model.maxWidth:props.bound,true);
|
|
95
|
+
const width=Math.min(point.fromPx,cap)-2*margin;
|
|
96
|
+
if(width<=0)fail(`Region bounds and margins leave no content width at ${point.name}.`);
|
|
97
|
+
if(mode!=="hybrid")return Array(count).fill(width/count);
|
|
98
|
+
const fixedLength=token=>token===undefined||token==="0"?0:model.length(token,true);
|
|
99
|
+
const start=fixedLength(tracks.start), end=fixedLength(tracks.end), fluidCount=count-fixedTracks.length;
|
|
100
|
+
if(fluidCount<1||start+end>=width)fail(`Fixed tracks leave no fluid space at ${point.name}.`);
|
|
101
|
+
return [...(tracks.start===undefined?[]:[start]),...Array(fluidCount).fill((width-start-end)/fluidCount),...(tracks.end===undefined?[]:[end])];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Expand owned Linaria @ads-layout declarations into ordinary CSS. Cells are
|
|
105
|
+
* direct children by construction, with placement checked for every fallback. */
|
|
106
|
+
function expandSpatialStyles(css, model, options) {
|
|
107
|
+
return timeStage("spatial-expansion", () => {
|
|
108
|
+
if(model?.variants){
|
|
109
|
+
const tokens=new Set();
|
|
110
|
+
let construction=false;
|
|
111
|
+
css.walkAtRules("ads-layout",layout=>{
|
|
112
|
+
construction=true;
|
|
113
|
+
layout.walkDecls(decl=>{for(const match of decl.value.matchAll(/--[\w-]+/g))tokens.add(match[0]);});
|
|
114
|
+
});
|
|
115
|
+
if(construction)for(const variant of model.variants([...tokens]).slice(1))expand(css.clone(),variant);
|
|
116
|
+
}
|
|
117
|
+
const output=expand(css,model);
|
|
118
|
+
inspectSpatialCss(output,options);
|
|
119
|
+
return output;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function expand(css, model) {
|
|
123
|
+
let construction=false;
|
|
124
|
+
css.walkAtRules(/^ads-/,()=>{construction=true;return false;});
|
|
125
|
+
if(!construction)return css;
|
|
126
|
+
if(!model)fail("Add tokens/spatial.ads.json before using @ads-layout.");
|
|
127
|
+
function layout(node,inherited,parentContext) {
|
|
128
|
+
const mode=node.params.trim();
|
|
129
|
+
if(!["fluid","hybrid","fixed","flow","inherited"].includes(mode))fail(`Unknown layout ${mode}.`);
|
|
130
|
+
if(mode==="inherited"&&!inherited)fail("Inherited tracks must be inside a declared cell.");
|
|
131
|
+
const props=declarations(node,["columns","gutter","row-gap","margin","bound","tile","ratio","fixed-start","fixed-end","context","rows","align"]);
|
|
132
|
+
const fixedTracks=["fixed-start","fixed-end"].filter(key=>props[key]!==undefined);
|
|
133
|
+
if(mode==="hybrid"&&!fixedTracks.length)fail("A hybrid region needs a fixed-start or fixed-end token.");
|
|
134
|
+
if(mode!=="hybrid"&&fixedTracks.length||mode!=="fixed"&&props.tile)fail("Use fixed-start/fixed-end only for hybrid regions and tile only for fixed tiling.");
|
|
135
|
+
if(props.context!==undefined&&!["viewport","container"].includes(props.context))fail(`Unknown context ${props.context}; use viewport or container.`);
|
|
136
|
+
if(props.context!==undefined&&!["fluid","hybrid"].includes(mode))fail("Only fluid and hybrid roots choose a responsive context; inherited tracks follow their parent and fixed/flow layouts have no tiers.");
|
|
137
|
+
const context=mode==="inherited"?parentContext:props.context??"viewport";
|
|
138
|
+
if(["flow","fixed"].includes(mode)&&["columns","gutter","margin","bound","rows","align"].some(key=>props[key]))fail("Track counts, rows, cell gutters and region bounds belong to fluid/hybrid layouts.");
|
|
139
|
+
if(mode==="inherited"&&(props.rows||props.align))fail("Inherited tracks keep their parent's rows and alignment.");
|
|
140
|
+
// Rows stay content-sized unless declared: auto is the content's height,
|
|
141
|
+
// fill shares the remaining block size. Undeclared rows are implicit auto rows.
|
|
142
|
+
const rows=props.rows===undefined?null:props.rows.split(/\s+/);
|
|
143
|
+
if(rows&&(rows.length<1||rows.length>12||rows.some(row=>!["auto","fill"].includes(row))))fail("rows lists 1 to 12 entries of auto or fill.");
|
|
144
|
+
if(props.align!==undefined&&!["start","center","end"].includes(props.align))fail("align must be start, center or end.");
|
|
145
|
+
if(props.align!==undefined&&props.bound==="full")fail("A full-width region has nothing to align; align needs a capped bound.");
|
|
146
|
+
const cells=(node.nodes??[]).filter(child=>child.type==="atrule"&&child.name==="ads-cell");
|
|
147
|
+
const trackVariants=new Map();
|
|
148
|
+
for(const child of node.nodes??[])if(child.type==="atrule"&&child.name!=="ads-cell"){
|
|
149
|
+
if(child.name!=="ads-at"||mode!=="hybrid")fail("Responsive placement belongs inside @ads-cell; shared breakpoints own track counts. Only hybrid regions vary their fixed tracks with @ads-at.");
|
|
150
|
+
const tier=child.params.trim();
|
|
151
|
+
if(!model.breakpoints.some(point=>point.name===tier)||trackVariants.has(tier))fail(`Unknown or repeated breakpoint ${tier}.`);
|
|
152
|
+
if((child.nodes??[]).some(item=>item.type==="atrule"))fail("Responsive fixed tracks must be flat declarations.");
|
|
153
|
+
const variant=declarations(child,["fixed-start","fixed-end"]);
|
|
154
|
+
if(Object.keys(variant).some(key=>props[key]===undefined))fail(`Declare ${Object.keys(variant).join(" and ")} on the region before varying it at ${tier}; use 0 where the track starts empty.`);
|
|
155
|
+
trackVariants.set(tier,variant);
|
|
156
|
+
}
|
|
157
|
+
if(["flow","fixed"].includes(mode)&&cells.length)fail("Fixed/flow layouts auto-place children; named placement requires fluid or inherited tracks.");
|
|
158
|
+
if(props.columns!==undefined&&(!/^\d+$/.test(props.columns)||Number(props.columns)<1||Number(props.columns)>64))fail("Local column counts are integers from 1 to 64.");
|
|
159
|
+
if(mode==="inherited"&&(props.columns||props.margin||props.bound))fail("Inherited tracks keep their parent's span and bounds.");
|
|
160
|
+
const gutter=props.gutter??"wide", edges=gutter==="none"?null:model.gutters[gutter];
|
|
161
|
+
if(gutter!=="none"&&!edges)fail(`Unknown gutter ${gutter}.`);
|
|
162
|
+
const spacing=token=>{if(token!=="0")model.length(token);return cssToken(token);};
|
|
163
|
+
const spaceValue=token=>{if(token!=="0")model.spacing(token);return cssToken(token);};
|
|
164
|
+
const rowGap=spaceValue(props["row-gap"]??"0");
|
|
165
|
+
if(props.ratio&&!model.ratios.includes(props.ratio))fail(`Unsupported ratio ${props.ratio}.`);
|
|
166
|
+
const names=new Set();
|
|
167
|
+
const cellModels=cells.map(cell=>{
|
|
168
|
+
if(!selector(cell.params)||names.has(cell.params))fail(`Use a unique direct cell class or data selector: ${cell.params}.`);
|
|
169
|
+
names.add(cell.params);
|
|
170
|
+
const placementKeys=["start","span","end","overlay","row","row-span","visible"];
|
|
171
|
+
const base=declarations(cell,[...placementKeys,"padding","ratio","container"]), variants=new Map();
|
|
172
|
+
if(cell.nodes.some(child=>child.type==="atrule"&&!["ads-at","ads-layout"].includes(child.name)))fail("Nested cells require an inherited layout; a cell cannot contain @ads-cell directly.");
|
|
173
|
+
if(base.span!==undefined&&base.end!==undefined)fail(`${cell.params} sets span and end; use one.`);
|
|
174
|
+
for(const child of cell.nodes??[])if(child.type==="atrule"&&child.name==="ads-at"){
|
|
175
|
+
if(!model.breakpoints.some(point=>point.name===child.params)||variants.has(child.params))fail(`Unknown or repeated breakpoint ${child.params}.`);
|
|
176
|
+
const variant=declarations(child,placementKeys);
|
|
177
|
+
if(variant.span!==undefined&&variant.end!==undefined)fail(`${cell.params} sets span and end at ${child.params}; use one.`);
|
|
178
|
+
variants.set(child.params,variant);
|
|
179
|
+
if(child.nodes.some(node=>node.type==="atrule"))fail("Responsive placement must be a flat declaration.");
|
|
180
|
+
}
|
|
181
|
+
if(base.padding)spaceValue(base.padding);
|
|
182
|
+
if(base.ratio&&!model.ratios.includes(base.ratio))fail(`Unsupported ratio ${base.ratio}.`);
|
|
183
|
+
if(base.container!==undefined&&base.container!=="region")fail(`${cell.params} container must be region.`);
|
|
184
|
+
const nested=cell.nodes.filter(child=>child.type==="atrule"&&child.name==="ads-layout");
|
|
185
|
+
if(nested.length>1||nested.some(child=>child.params!=="inherited"))fail("A cell can declare one inherited layout; independent layouts belong to a child region.");
|
|
186
|
+
if(nested.length&&base.padding)fail("Apply content padding to a child of inherited tracks, preserving parent keylines.");
|
|
187
|
+
if(nested.length&&base.container)fail(`${cell.params} either continues its parent's tracks (inherited) or starts a region container for independent layouts, not both.`);
|
|
188
|
+
let state={start:"1",overlay:"none",row:"auto","row-span":"1",visible:"true",...base};
|
|
189
|
+
if(state.span===undefined&&state.end===undefined)state.span="full";
|
|
190
|
+
const integer=value=>/^[1-9]\d*$/.test(value)?Number(value):NaN;
|
|
191
|
+
const placements=model.breakpoints.map((point,index)=>{
|
|
192
|
+
const variant=variants.get(point.name)??{};
|
|
193
|
+
// span and end are alternatives: a breakpoint that sets one replaces the other.
|
|
194
|
+
state={...state,...variant};
|
|
195
|
+
if(variant.span!==undefined)delete state.end;
|
|
196
|
+
if(variant.end!==undefined)delete state.span;
|
|
197
|
+
const count=inherited?.[index]??Number(props.columns??point.count), auto=state.start==="auto";
|
|
198
|
+
const start=auto?1:integer(state.start);
|
|
199
|
+
if(auto&&(state.end!==undefined||state.span==="full"))fail(`${cell.params} auto placement needs a numeric span; end and full need a start line.`);
|
|
200
|
+
const span=state.end!==undefined?integer(state.end)-start:state.span==="full"?count-start+1:integer(state.span);
|
|
201
|
+
if(!Number.isInteger(start)||!Number.isInteger(span)||span<1||start+span-1>count)fail(`${cell.params} placement ${state.start}/${state.end!==undefined?`end ${state.end}`:state.span} exceeds ${count} columns at ${point.name}.`);
|
|
202
|
+
if(!overlaySides.includes(state.overlay))fail(`${cell.params} overlay must be none, start or end.`);
|
|
203
|
+
if(!["true","false"].includes(state.visible))fail(`${cell.params} visible must be true or false.`);
|
|
204
|
+
const row=state.row==="auto"?"auto":integer(state.row), rowSpan=integer(state["row-span"]);
|
|
205
|
+
if(row!=="auto"&&!Number.isInteger(row)||!Number.isInteger(rowSpan))fail(`${cell.params} row and row-span are positive integers (row may be auto).`);
|
|
206
|
+
if(rows&&(rowSpan>rows.length||row!=="auto"&&row+rowSpan-1>rows.length))fail(`${cell.params} row ${row}/span ${rowSpan} exceeds the ${rows.length} declared rows at ${point.name}.`);
|
|
207
|
+
return {start,span,auto,overlay:state.overlay,row,rowSpan,visible:state.visible==="true"};
|
|
208
|
+
});
|
|
209
|
+
const rowPlaced=[base,...variants.values()].some(value=>value.row!==undefined||value["row-span"]!==undefined);
|
|
210
|
+
const overlays=placements.some(value=>value.overlay!=="none");
|
|
211
|
+
if(overlays&&mode==="inherited")fail(`${cell.params} overlays belong to a root fluid or hybrid region, not inherited tracks.`);
|
|
212
|
+
if(overlays&&nested.length)fail(`${cell.params} leaves the tracks while it overlays, so it cannot carry inherited tracks.`);
|
|
213
|
+
return {cell,base,nested,placements,overlays,rowPlaced};
|
|
214
|
+
});
|
|
215
|
+
const output=postcss.root();
|
|
216
|
+
append(output,"min-inline-size","0");
|
|
217
|
+
append(output,"display",mode==="flow"?"flex":"grid");
|
|
218
|
+
if(mode==="flow")append(output,"flex-direction","column");
|
|
219
|
+
append(output,"row-gap",rowGap);
|
|
220
|
+
if(mode!=="flow")append(output,"column-gap",mode==="fixed"?rowGap:"0");
|
|
221
|
+
if(props.ratio)append(output,"aspect-ratio",props.ratio.replace(":"," / "));
|
|
222
|
+
if(rows)append(output,"grid-template-rows",rows.map(row=>row==="fill"?"minmax(0, 1fr)":"auto").join(" "));
|
|
223
|
+
if(mode==="fixed"){
|
|
224
|
+
if(!props.tile)fail("A fixed tiling layout needs a tile token.");model.length(props.tile,true);
|
|
225
|
+
append(output,"grid-template-columns",`repeat(auto-fill, min(100%, ${cssToken(props.tile)}))`);
|
|
226
|
+
}
|
|
227
|
+
const fluid=["fluid","hybrid","inherited"].includes(mode);
|
|
228
|
+
// Overlay cells are positioned against the region they cover.
|
|
229
|
+
if(cellModels.some(item=>item.overlays))append(output,"position","relative");
|
|
230
|
+
let tracks={start:props["fixed-start"],end:props["fixed-end"]};
|
|
231
|
+
if(fluid)for(const [index,point]of model.breakpoints.entries()){
|
|
232
|
+
// Each tier is an exclusive range. Atomic CSS does not keep rule order, so
|
|
233
|
+
// two open-ended tiers that both match would decide by chance.
|
|
234
|
+
const next=model.breakpoints[index+1];
|
|
235
|
+
const range=`(width >= ${point.fromPx/16}rem)${next?` and (width < ${next.fromPx/16}rem)`:""}`;
|
|
236
|
+
const condition=context==="container"?{name:"container",params:`${regionContainer} ${range}`}:{name:"media",params:range};
|
|
237
|
+
const rule=index===0?output:postcss.atRule(condition);
|
|
238
|
+
if(mode==="inherited")append(rule,"grid-template-columns","subgrid");
|
|
239
|
+
else {
|
|
240
|
+
const count=Number(props.columns??point.count), margin=spacing(props.margin??point.margin);
|
|
241
|
+
const variant=trackVariants.get(point.name)??{};
|
|
242
|
+
tracks={start:variant["fixed-start"]??tracks.start,end:variant["fixed-end"]??tracks.end};
|
|
243
|
+
const widths=regionTracks(model,props,point,mode,tracks,fixedTracks);
|
|
244
|
+
if(edges)for(const item of cellModels){
|
|
245
|
+
const placement=item.placements[index];
|
|
246
|
+
if(item.nested.length||placement.overlay!=="none")continue;
|
|
247
|
+
const width=placement.auto?Math.min(...Array.from({length:count-placement.span+1},(_,start)=>widths.slice(start,start+placement.span).reduce((sum,value)=>sum+value,0))):widths.slice(placement.start-1,placement.start-1+placement.span).reduce((sum,value)=>sum+value,0);
|
|
248
|
+
if(model.length(edges.start)+model.length(edges.end)>width)fail(`${item.cell.params} cell insets exceed its local span at ${point.name}.`);
|
|
249
|
+
}
|
|
250
|
+
if(mode==="hybrid"){
|
|
251
|
+
const fluidCount=count-fixedTracks.length;
|
|
252
|
+
append(rule,"grid-template-columns",[tracks.start===undefined?"":spacing(tracks.start),`repeat(${fluidCount}, minmax(0, 1fr))`,tracks.end===undefined?"":spacing(tracks.end)].filter(Boolean).join(" "));
|
|
253
|
+
}else append(rule,"grid-template-columns",`repeat(${count}, minmax(0, 1fr))`);
|
|
254
|
+
const bound=props.bound??"system", cap=bound==="full"?null:spacing(bound==="system"?model.maxWidth:bound);
|
|
255
|
+
// A capped region keeps its outer margin and places the remaining space by align.
|
|
256
|
+
if(!cap)append(rule,"margin-inline",margin);
|
|
257
|
+
else if((props.align??"center")==="center")append(rule,"margin-inline",`max(${margin}, calc((100% - ${cap}) / 2 + ${margin}))`);
|
|
258
|
+
else {
|
|
259
|
+
const rest=`max(${margin}, calc(100% - ${cap} + ${margin}))`;
|
|
260
|
+
append(rule,"margin-inline-start",props.align==="start"?margin:rest);
|
|
261
|
+
append(rule,"margin-inline-end",props.align==="start"?rest:margin);
|
|
262
|
+
}
|
|
263
|
+
append(rule,"max-inline-size",bound==="full"?"none":`calc(${spacing(bound==="system"?model.maxWidth:bound)} - ${spacing(props.margin??point.margin)} * 2)`);
|
|
264
|
+
}
|
|
265
|
+
for(const item of cellModels){
|
|
266
|
+
const child=postcss.rule({selector:`& > ${item.cell.params}`}), placement=item.placements[index];
|
|
267
|
+
append(child,"grid-column",placement.overlay!=="none"?"1 / -1":placement.auto?`span ${placement.span}`:`${placement.start} / span ${placement.span}`);
|
|
268
|
+
// An overlay keeps its row band, so it covers only the rows it was placed in.
|
|
269
|
+
if(item.rowPlaced)append(child,"grid-row",placement.row==="auto"?`span ${placement.rowSpan}`:`${placement.row} / span ${placement.rowSpan}`);
|
|
270
|
+
// Ranges are exclusive, so a tier states what differs from the base rule.
|
|
271
|
+
if(item.overlays&&(index===0||item.placements[0].overlay!==placement.overlay)){
|
|
272
|
+
// An overlay covers the region from one inline edge and leaves the
|
|
273
|
+
// other cells' tracks unchanged; in track tiers it returns to flow.
|
|
274
|
+
const covers=placement.overlay!=="none";
|
|
275
|
+
append(child,"position",covers?"absolute":"relative");
|
|
276
|
+
append(child,"inset-block-start",covers?"0":"auto");
|
|
277
|
+
append(child,"inset-block-end",covers?"0":"auto");
|
|
278
|
+
append(child,"inset-inline-start",placement.overlay==="start"?"0":"auto");
|
|
279
|
+
append(child,"inset-inline-end",placement.overlay==="end"?"0":"auto");
|
|
280
|
+
}
|
|
281
|
+
if(index===0){
|
|
282
|
+
append(child,"min-inline-size","0");
|
|
283
|
+
append(child,"margin-inline-start",item.nested.length||!edges?"0":spacing(edges.start));
|
|
284
|
+
append(child,"margin-inline-end",item.nested.length||!edges?"0":spacing(edges.end));
|
|
285
|
+
if(item.base.padding)append(child,"padding",spaceValue(item.base.padding));
|
|
286
|
+
if(item.base.ratio)append(child,"aspect-ratio",item.base.ratio.replace(":"," / "));
|
|
287
|
+
if(item.base.container){append(child,"container-type","inline-size");append(child,"container-name",regionContainer);}
|
|
288
|
+
if(item.nested.length)child.append(layout(item.nested[0],item.placements.map(value=>value.span),context).nodes);
|
|
289
|
+
}
|
|
290
|
+
rule.append(child);
|
|
291
|
+
}
|
|
292
|
+
if(index)output.append(rule);
|
|
293
|
+
}
|
|
294
|
+
// Hidden ranges compile to bounded queries, so a visible breakpoint never has
|
|
295
|
+
// to restore the owner's own display value.
|
|
296
|
+
if(fluid)for(const item of cellModels){
|
|
297
|
+
const tiers=model.breakpoints;
|
|
298
|
+
for(let first=0;first<tiers.length;first++){
|
|
299
|
+
if(item.placements[first].visible)continue;
|
|
300
|
+
let last=first;
|
|
301
|
+
while(last+1<tiers.length&&!item.placements[last+1].visible)last++;
|
|
302
|
+
const hide=postcss.rule({selector:`& > ${item.cell.params}`});append(hide,"display","none");
|
|
303
|
+
const bounds=[first>0&&`(width >= ${tiers[first].fromPx/16}rem)`,last<tiers.length-1&&`(width < ${tiers[last+1].fromPx/16}rem)`].filter(Boolean).join(" and ");
|
|
304
|
+
if(!bounds)output.append(hide);
|
|
305
|
+
else {
|
|
306
|
+
const range=postcss.atRule(context==="container"?{name:"container",params:`${regionContainer} ${bounds}`}:{name:"media",params:bounds});
|
|
307
|
+
range.append(hide);output.append(range);
|
|
308
|
+
}
|
|
309
|
+
first=last;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// Emitted geometry is validated here; source locations point at the
|
|
313
|
+
// construction, and later heuristics recognise it as compiler output.
|
|
314
|
+
output.walkDecls(decl=>{decl.source??=node.source;decl.adsSpatial=true;});
|
|
315
|
+
return output;
|
|
316
|
+
}
|
|
317
|
+
for(const node of css.nodes.slice())if(node.type==="atrule"&&node.name==="ads-layout")node.replaceWith(layout(node).nodes);
|
|
318
|
+
css.walkRules(rule=>{for(const child of rule.nodes.slice())if(child.type==="atrule"&&child.name==="ads-layout")child.replaceWith(layout(child).nodes);});
|
|
319
|
+
css.walkAtRules(/^ads-/,node=>fail(`@${node.name} is outside a supported layout construction.`));
|
|
320
|
+
return css;
|
|
321
|
+
}
|
|
322
|
+
module.exports={spatialModel,expandSpatialStyles};
|
package/dist/spatial.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { currentAnalysis } from "./analysis/context.mjs";
|
|
3
|
+
import { memoFact, memoProgram, optionalSourceText, sourceText, sourceCss, sourceDirectoryFiles } from "./analysis/helpers.mjs";
|
|
4
|
+
import inputs from "./spatial-inputs.cjs";
|
|
5
|
+
import timing from "./stage-timing.cjs";
|
|
6
|
+
|
|
7
|
+
/** One model per captured operation, shared by guards and foundation discovery. */
|
|
8
|
+
export function inspectSpatial(options) {
|
|
9
|
+
const directory = path.join(options.dsRoot, options.config.tokenDir);
|
|
10
|
+
const capture = () => timing.timeStage("spatial-inputs", () => {
|
|
11
|
+
const file = path.join(directory, "spatial.ads.json"), text = optionalSourceText(file);
|
|
12
|
+
if (text === null) return null;
|
|
13
|
+
const sheets = sourceDirectoryFiles(directory).filter(inputs.isSpatialSheet).map(file => ({ file, text: sourceText(file) }));
|
|
14
|
+
return inputs.spatialFromInputs({ file, text }, sheets, file => sourceCss(file));
|
|
15
|
+
});
|
|
16
|
+
const context = currentAnalysis();
|
|
17
|
+
// The native view's captured texts/membership never change. Reuse the model
|
|
18
|
+
// across requests on that view; weak ownership releases discarded drafts.
|
|
19
|
+
const key = `spatial:${directory}`;
|
|
20
|
+
return context ? memoFact(context, key, () => context.revision ? memoProgram(context.revision, key, capture) : capture()) : capture();
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const { appendFileSync } = require("node:fs");
|
|
2
|
+
const { performance } = require("node:perf_hooks");
|
|
3
|
+
|
|
4
|
+
/** Opt-in development tracing, inherited by compiler children. No output normally. */
|
|
5
|
+
function timeStage(stage, run) {
|
|
6
|
+
const output = process.env.ADS_PROFILE_STAGES;
|
|
7
|
+
if (!output) return run();
|
|
8
|
+
const started = performance.now();
|
|
9
|
+
const record = () => appendFileSync(output, JSON.stringify({ stage, pid: process.pid, ms: performance.now() - started }) + "\n");
|
|
10
|
+
let pending = false;
|
|
11
|
+
try {
|
|
12
|
+
const result = run();
|
|
13
|
+
if (result && typeof result.then === "function") {
|
|
14
|
+
pending = true;
|
|
15
|
+
return Promise.resolve(result).finally(record);
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
} finally { if (!pending) record(); }
|
|
19
|
+
}
|
|
20
|
+
module.exports = { timeStage };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { css, cx } from "@linaria/atomic";
|
|
2
|
+
import type { ComponentChildren as ReactNode } from "preact";
|
|
3
|
+
|
|
4
|
+
export interface ConversationProps {
|
|
5
|
+
messages: readonly { id: string; name: string; text: string; fromUser?: boolean }[];
|
|
6
|
+
composer?: ReactNode;
|
|
7
|
+
/** The leading avatar track is fixed (default), so text starts right after the avatar; false makes it one fluid column. */
|
|
8
|
+
fixedIndent?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const cells = `
|
|
12
|
+
@ads-cell .ux-conversation-message {
|
|
13
|
+
span: full;
|
|
14
|
+
@ads-layout inherited {
|
|
15
|
+
gutter: none;
|
|
16
|
+
@ads-cell .ux-conversation-avatar { span: 1; }
|
|
17
|
+
@ads-cell .ux-conversation-content { start: 2; span: 11; }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
@ads-cell .ux-conversation-prompt {
|
|
21
|
+
span: full;
|
|
22
|
+
@ads-at lg { start: 6; span: 9; }
|
|
23
|
+
}
|
|
24
|
+
@ads-cell .ux-conversation-composer { span: full; }
|
|
25
|
+
`;
|
|
26
|
+
const fluid = css`
|
|
27
|
+
@ads-layout fluid {
|
|
28
|
+
context: container;
|
|
29
|
+
columns: 14;
|
|
30
|
+
gutter: none;
|
|
31
|
+
margin: --space-0;
|
|
32
|
+
row-gap: --space-12;
|
|
33
|
+
${cells}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
const hybrid = css`
|
|
37
|
+
@ads-layout hybrid {
|
|
38
|
+
context: container;
|
|
39
|
+
columns: 14;
|
|
40
|
+
fixed-start: --space-16;
|
|
41
|
+
gutter: none;
|
|
42
|
+
margin: --space-0;
|
|
43
|
+
row-gap: --space-12;
|
|
44
|
+
${cells}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
// The conversation owns the region its tracks respond to: a container query measures an
|
|
48
|
+
// ancestor, never the grid element itself.
|
|
49
|
+
const region = css`
|
|
50
|
+
container-type: inline-size;
|
|
51
|
+
container-name: ads-region;
|
|
52
|
+
min-inline-size: 0;
|
|
53
|
+
`;
|
|
54
|
+
const avatar = css`
|
|
55
|
+
inline-size: var(--icon-lg);
|
|
56
|
+
max-inline-size: 100%;
|
|
57
|
+
aspect-ratio: 1;
|
|
58
|
+
border-radius: var(--radius-full);
|
|
59
|
+
background: var(--accent);
|
|
60
|
+
color: var(--accent-fg);
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
font-size: var(--text-xs);
|
|
65
|
+
font-weight: var(--weight-semibold);
|
|
66
|
+
`;
|
|
67
|
+
const content = css`
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
gap: var(--space-2);
|
|
71
|
+
overflow-wrap: anywhere;
|
|
72
|
+
color: var(--text-body);
|
|
73
|
+
font-size: var(--text-base);
|
|
74
|
+
line-height: var(--leading-normal);
|
|
75
|
+
`;
|
|
76
|
+
const name = css`font-weight: var(--weight-semibold); color: var(--text-strong);`;
|
|
77
|
+
const text = css`margin: 0;`;
|
|
78
|
+
const prompt = css`
|
|
79
|
+
padding: var(--space-8);
|
|
80
|
+
background: var(--bg-surface);
|
|
81
|
+
border-radius: var(--radius-lg);
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
/** A locally defined fourteen-track conversation that responds to its region's width; no layout wrapper components. */
|
|
85
|
+
export function Conversation({ messages, composer, fixedIndent = true }: ConversationProps) {
|
|
86
|
+
return (
|
|
87
|
+
<section aria-label="Conversation" className={region}>
|
|
88
|
+
<div className={fixedIndent ? hybrid : fluid}>
|
|
89
|
+
{messages.map(message => message.fromUser ? (
|
|
90
|
+
<article key={message.id} className={cx("ux-conversation-prompt", prompt, content)}>
|
|
91
|
+
<strong className={name}>{message.name}</strong><p className={text}>{message.text}</p>
|
|
92
|
+
</article>
|
|
93
|
+
) : (
|
|
94
|
+
<article key={message.id} className="ux-conversation-message">
|
|
95
|
+
<span aria-hidden="true" className={cx("ux-conversation-avatar", avatar)}>{message.name.slice(0, 1)}</span>
|
|
96
|
+
<div className={cx("ux-conversation-content", content)}>
|
|
97
|
+
<strong className={name}>{message.name}</strong><p className={text}>{message.text}</p>
|
|
98
|
+
</div>
|
|
99
|
+
</article>
|
|
100
|
+
))}
|
|
101
|
+
<div className="ux-conversation-composer">{composer}</div>
|
|
102
|
+
</div>
|
|
103
|
+
</section>
|
|
104
|
+
);
|
|
105
|
+
}
|