@reqvire-org/ads 0.4.7 → 0.5.1
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 +268 -420
- package/dist/accessibility-declarations.mjs +43 -0
- package/dist/active-clock.d.mts +30 -0
- package/dist/active-clock.mjs +26 -17
- package/dist/ads-errors.mjs +3684 -0
- package/dist/ads-view-choices.mjs +17 -0
- package/dist/ads-views.mjs +12 -0
- package/dist/analysis/captured-content.mjs +16 -0
- package/dist/analysis/compiler-options.mjs +3 -7
- package/dist/analysis/context.mjs +14 -20
- package/dist/analysis/controller-gates.mjs +119 -0
- package/dist/analysis/design-usage.mjs +142 -0
- package/dist/analysis/file-tree.mjs +44 -29
- package/dist/analysis/framework-imports.mjs +62 -0
- package/dist/analysis/glyph-macros.mjs +103 -0
- package/dist/analysis/helpers.mjs +119 -91
- package/dist/analysis/impact.mjs +25 -12
- package/dist/analysis/inputs.mjs +19 -13
- package/dist/analysis/mock-check.mjs +99 -0
- package/dist/analysis/module-graph.mjs +156 -0
- package/dist/analysis/module-resolvers.mjs +30 -28
- package/dist/analysis/native-adapter.mjs +139 -146
- package/dist/analysis/native-boundary.mjs +52 -0
- package/dist/analysis/native-project.mjs +331 -231
- package/dist/analysis/native-session.mjs +20 -0
- package/dist/analysis/owner-accessibility.mjs +74 -0
- package/dist/analysis/owner-analysis-cache.mjs +125 -0
- package/dist/analysis/owner-analysis-key.mjs +114 -0
- package/dist/analysis/owner-choices.mjs +896 -0
- package/dist/analysis/owner-composition.mjs +636 -0
- package/dist/analysis/owner-controls.mjs +27 -0
- package/dist/analysis/owner-discovery.mjs +164 -0
- package/dist/analysis/owner-failures.mjs +19 -0
- package/dist/analysis/owner-outcomes.mjs +42 -0
- package/dist/analysis/owner-reuse.mjs +100 -0
- package/dist/analysis/owner-source.mjs +1555 -0
- package/dist/analysis/prose-owners.mjs +57 -0
- package/dist/analysis/public-imports.mjs +31 -0
- package/dist/analysis/queries.mjs +72 -54
- package/dist/analysis/runtime-setters.mjs +114 -0
- package/dist/analysis/scenario-keys.mjs +151 -0
- package/dist/analysis/service.mjs +111 -70
- package/dist/analysis/standalone.mjs +40 -37
- package/dist/analysis/styling-ownership.mjs +298 -0
- package/dist/analysis/svg-attributes.mjs +199 -0
- package/dist/analysis/syntax.mjs +82 -78
- package/dist/analysis/visual-bindings.mjs +68 -0
- package/dist/analysis/worker-protocol.mjs +302 -0
- package/dist/analysis/worker.mjs +234 -166
- package/dist/api-signature.mjs +53 -0
- package/dist/app-icon-checks.mjs +298 -0
- package/dist/app-icon-declaration.d.mts +53 -0
- package/dist/app-icon-declaration.mjs +66 -0
- package/dist/asset-binding.mjs +35 -0
- package/dist/asset-catalog.mjs +83 -0
- package/dist/asset-declaration.d.mts +42 -0
- package/dist/asset-declaration.mjs +108 -0
- package/dist/asset-macro.d.mts +63 -0
- package/dist/asset-macro.mjs +22 -0
- package/dist/asset-model.mjs +74 -0
- package/dist/asset-usage.mjs +14 -0
- package/dist/asset-view-facts.mjs +41 -0
- package/dist/authoring-macro.d.mts +11 -0
- package/dist/authoring-macro.mjs +21 -0
- package/dist/autocomplete-hints.mjs +31 -0
- package/dist/availability.mjs +9 -0
- package/dist/behavior-macro.d.mts +31 -0
- package/dist/behavior-macro.mjs +3 -0
- package/dist/behavior-registry.mjs +358 -0
- package/dist/boundaries.mjs +50 -212
- package/dist/browser-runtime.mjs +73 -0
- package/dist/browser-test.d.mts +3 -0
- package/dist/browser-test.mjs +2 -0
- package/dist/bun-bundler.mjs +10 -0
- package/dist/bun-compiler.mjs +30 -18
- package/dist/bun-runtime.mjs +4 -0
- package/dist/bun-worker.mjs +10 -4
- package/dist/capture/request.mjs +81 -0
- package/dist/capture/worker.mjs +69 -40
- package/dist/capture/worker.page.mjs +6 -0
- package/dist/capture-store.mjs +159 -75
- package/dist/capture.mjs +232 -95
- package/dist/check-service.mjs +27 -33
- package/dist/check.mjs +206 -904
- package/dist/cli-arguments.mjs +278 -0
- package/dist/cli.mjs +374 -304
- package/dist/color-values.mjs +294 -242
- package/dist/composed-contrast.mjs +648 -0
- package/dist/composed-keyline.mjs +107 -0
- package/dist/config.mjs +162 -468
- package/dist/construction-output.mjs +345 -0
- package/dist/construction-spec.d.mts +915 -0
- package/dist/construction-spec.mjs +1178 -0
- package/dist/corner-overpaint.mjs +53 -0
- package/dist/css-length.mjs +80 -0
- package/dist/css-quantity.mjs +173 -0
- package/dist/deletion-model.mjs +56 -0
- package/dist/deletion-plan.mjs +364 -0
- package/dist/dependency-manifest.mjs +56 -0
- package/dist/design-context-model.d.mts +61 -0
- package/dist/design-context-model.mjs +79 -0
- package/dist/design-contexts.mjs +105 -0
- package/dist/design-foundation.mjs +532 -0
- package/dist/design-inputs.mjs +156 -0
- package/dist/design-modules.mjs +27 -0
- package/dist/design-rejection.d.mts +23 -0
- package/dist/design-rejection.mjs +29 -0
- package/dist/design-system-closure.mjs +108 -0
- package/dist/design-usage.mjs +54 -0
- package/dist/development-modules.mjs +2 -0
- package/dist/development-runtime.mjs +0 -7
- package/dist/digest.mjs +2 -0
- package/dist/draft-boundary.mjs +1 -27
- package/dist/draft-workspace.mjs +11 -5
- package/dist/emit/accept.mjs +33 -0
- package/dist/emit/app-icon-emission.mjs +124 -0
- package/dist/emit/app-icon-render.mjs +126 -0
- package/dist/emit/asset-imports.mjs +18 -0
- package/dist/emit/cli-report.mjs +97 -0
- package/dist/emit/contract.mjs +136 -0
- package/dist/emit/emission.mjs +182 -0
- package/dist/emit/font-emission.mjs +111 -0
- package/dist/emit/foundation-sheet.mjs +56 -0
- package/dist/emit/icon-containers.mjs +46 -0
- package/dist/emit/integrity.mjs +61 -0
- package/dist/emit/lock.mjs +66 -0
- package/dist/emit/namespace.mjs +79 -0
- package/dist/emit/operation-reply.mjs +3 -0
- package/dist/emit/operation.mjs +36 -0
- package/dist/emit/output-location.mjs +20 -0
- package/dist/emit/output-package.mjs +7 -0
- package/dist/emit/owner-emission-cache.mjs +52 -0
- package/dist/emit/palette-module.mjs +19 -0
- package/dist/emit/palette-refresh.mjs +77 -0
- package/dist/emit/preview-emitter.mjs +110 -0
- package/dist/emit/preview-tree.mjs +174 -0
- package/dist/emit/scheduler.mjs +75 -0
- package/dist/emit/service.mjs +249 -0
- package/dist/emit/sync.mjs +38 -0
- package/dist/emit/watch.mjs +74 -0
- package/dist/emit/writer.mjs +102 -0
- package/dist/evidence.mjs +6 -8
- package/dist/example-babel.mjs +7 -0
- package/dist/example-literals.mjs +88 -0
- package/dist/finding-rules.mjs +78 -77
- package/dist/focus-checks.mjs +93 -0
- package/dist/font-checks.mjs +185 -0
- package/dist/font-declaration.d.mts +64 -0
- package/dist/font-declaration.mjs +99 -0
- package/dist/font-fallback.d.mts +37 -0
- package/dist/font-fallback.mjs +25 -0
- package/dist/font-macro.d.mts +42 -0
- package/dist/font-macro.mjs +6 -0
- package/dist/font-metrics.d.mts +34 -0
- package/dist/font-metrics.mjs +314 -0
- package/dist/font-model.mjs +63 -0
- package/dist/form-states.mjs +82 -0
- package/dist/foundation-macro.d.mts +108 -0
- package/dist/foundation-macro.mjs +6 -0
- package/dist/frame-regions.mjs +253 -0
- package/dist/glyph-set-declaration.d.mts +27 -0
- package/dist/glyph-set-declaration.mjs +36 -0
- package/dist/grid-checks.mjs +94 -0
- package/dist/grid-facts.mjs +148 -0
- package/dist/grid-lowering.mjs +263 -0
- package/dist/guard/cli.mjs +51 -0
- package/dist/guard/config.mjs +67 -0
- package/dist/guard/files.mjs +31 -0
- package/dist/guard/index.mjs +3 -0
- package/dist/guard/run.mjs +56 -0
- package/dist/guard/tsconfig.declarations.json +13 -0
- package/dist/index.mjs +2 -7
- package/dist/init-project.mjs +134 -0
- package/dist/init.mjs +217 -264
- package/dist/input-digests.mjs +109 -163
- package/dist/input-scope.mjs +18 -41
- package/dist/inspected-svg.d.mts +28 -0
- package/dist/inspected-svg.mjs +40 -0
- package/dist/inventories.mjs +149 -0
- package/dist/inventory-query.mjs +15 -0
- package/dist/investigations.mjs +177 -99
- package/dist/json.d.mts +10 -0
- package/dist/json.mjs +36 -0
- package/dist/linaria/atomic-processor.json +96 -0
- package/dist/linaria/atomic-processor.mjs +2452 -0
- package/dist/linaria/backend-identity.mjs +26 -0
- package/dist/linaria/compatibility.json +61 -0
- package/dist/linaria/css-shape.mjs +94 -0
- package/dist/linaria/custom-property-css.mjs +56 -0
- package/dist/linaria/delivery.mjs +111 -0
- package/dist/linaria/direct-extract.mjs +43 -0
- package/dist/linaria/extraction-cache.mjs +31 -0
- package/dist/linaria/extraction-model.mjs +5 -0
- package/dist/linaria/fingerprint.mjs +183 -0
- package/dist/linaria/pair-manifest.json +2315 -0
- package/dist/linaria/persisted-extraction-cache.mjs +352 -0
- package/dist/linaria/preservation.mjs +13 -0
- package/dist/linaria/priority-emitted-rank.mjs +40 -0
- package/dist/linaria/priority-manifest.mjs +87 -0
- package/dist/linaria/priority-table.mjs +47 -0
- package/dist/linaria/priority-tiers.mjs +27 -0
- package/dist/linaria/processor-host.mjs +42 -0
- package/dist/linaria/processor-runtime.mjs +36 -0
- package/dist/linaria-processor-NOTICES.md +147 -0
- package/dist/lowering-components.mjs +14 -0
- package/dist/lowering-effects.mjs +38 -0
- package/dist/lowering-emitter.mjs +29 -0
- package/dist/lowering-enter.mjs +31 -0
- package/dist/lowering-hidden.mjs +30 -0
- package/dist/lowering-layer.mjs +141 -0
- package/dist/lowering-motion.mjs +37 -0
- package/dist/lowering-normalize.mjs +194 -0
- package/dist/lowering-overlaps.mjs +328 -0
- package/dist/lowering-paint.mjs +32 -0
- package/dist/lowering-properties.mjs +165 -0
- package/dist/lowering-region-layout.mjs +225 -0
- package/dist/lowering-sequence.mjs +89 -0
- package/dist/lowering-serialize.mjs +40 -0
- package/dist/lowering-session.mjs +137 -0
- package/dist/lowering-tiers.mjs +23 -0
- package/dist/lowering-transitions.mjs +53 -0
- package/dist/mcp/ads-mcp.mjs +423 -0
- package/dist/mcp/apps.mjs +3 -25
- package/dist/mcp/behavior-pages.mjs +58 -51
- package/dist/mcp/build-status.mjs +233 -267
- package/dist/mcp/catalog.mjs +21 -128
- package/dist/mcp/compiler-channel.mjs +218 -83
- package/dist/mcp/context.mjs +50 -40
- package/dist/mcp/deletions.mjs +147 -0
- package/dist/mcp/draft-discovery.mjs +43 -38
- package/dist/mcp/drafts.mjs +635 -691
- package/dist/mcp/execution-context.mjs +33 -22
- package/dist/mcp/execution-coordinator.mjs +367 -354
- package/dist/mcp/execution-results.mjs +440 -173
- package/dist/mcp/mutation-limits.mjs +1 -2
- package/dist/mcp/mutations.mjs +515 -553
- package/dist/mcp/patch.mjs +117 -75
- package/dist/mcp/preview-http.bundle.js +3 -7
- package/dist/mcp/preview-http.mjs +220 -107
- package/dist/mcp/preview-owner-guard.mjs +81 -43
- package/dist/mcp/preview-watch.mjs +428 -365
- package/dist/mcp/preview-widget.bundle.js +42 -46
- package/dist/mcp/preview-work.mjs +25 -13
- package/dist/mcp/prompts.mjs +22 -16
- package/dist/mcp/resource-loader.js +1 -1
- package/dist/mcp/result-pages.mjs +94 -54
- package/dist/mcp/sandbox-host.mjs +41 -19
- package/dist/mcp/server-discovery.mjs +96 -0
- package/dist/mcp/server-guides.mjs +43 -0
- package/dist/mcp/server-host.mjs +203 -0
- package/dist/mcp/server-observation.mjs +225 -0
- package/dist/mcp/server-project.mjs +371 -0
- package/dist/mcp/server-resources.mjs +466 -0
- package/dist/mcp/server-shared.mjs +79 -0
- package/dist/mcp/server-tools.mjs +791 -0
- package/dist/mcp/server.mjs +2 -2813
- package/dist/mcp/showcase-host.mjs +209 -135
- package/dist/mcp/showcase-http.mjs +50 -28
- package/dist/mcp/skills.mjs +32 -36
- package/dist/mcp/text-diff.mjs +18 -36
- package/dist/measured-geometry.mjs +157 -0
- package/dist/motion-model.mjs +52 -0
- package/dist/non-text-contrast.mjs +118 -0
- package/dist/owner-analysis-check.mjs +711 -0
- package/dist/owner-design.mjs +15 -0
- package/dist/owner-errors.mjs +216 -0
- package/dist/owner-lowering.mjs +206 -0
- package/dist/owner-scenarios.mjs +854 -0
- package/dist/ownership-model.d.mts +6 -0
- package/dist/ownership-model.mjs +143 -0
- package/dist/package-declarations.mjs +34 -0
- package/dist/paint-contrast.mjs +186 -0
- package/dist/palette-generated.mjs +101 -116
- package/dist/pictogram-model.mjs +13 -51
- package/dist/placeholder-contrast.mjs +35 -0
- package/dist/platform-features.mjs +401 -0
- package/dist/press-scale.mjs +26 -0
- package/dist/preview-bun.mjs +334 -404
- package/dist/preview-compile-inputs.mjs +78 -0
- package/dist/preview-contexts.mjs +7 -0
- package/dist/preview-controls.mjs +35 -0
- package/dist/preview-failure.mjs +20 -10
- package/dist/preview-files.mjs +18 -36
- package/dist/preview-imports.mjs +76 -70
- package/dist/preview-incremental.mjs +322 -222
- package/dist/preview-inputs.mjs +26 -26
- package/dist/preview-manifest-update.mjs +67 -49
- package/dist/preview-requests.mjs +10 -17
- package/dist/preview-resources.mjs +275 -323
- package/dist/preview-scope.mjs +15 -17
- package/dist/preview-source.mjs +182 -0
- package/dist/preview-spatial.mjs +27 -0
- package/dist/profile-macro.d.mts +56 -0
- package/dist/profile-macro.mjs +6 -0
- package/dist/profile-model.d.mts +65 -0
- package/dist/profile-model.mjs +213 -0
- package/dist/profile-view-facts.mjs +93 -0
- package/dist/program-cache.mjs +9 -7
- package/dist/project-boundary.mjs +8 -13
- package/dist/project-documents.mjs +25 -29
- package/dist/property-registrations.mjs +44 -35
- package/dist/prose-model.d.mts +81 -0
- package/dist/prose-model.mjs +101 -0
- package/dist/public-catalog.mjs +76 -0
- package/dist/recipe-defaults.mjs +117 -0
- package/dist/recipe-macro.d.mts +502 -0
- package/dist/recipe-macro.mjs +23 -0
- package/dist/recipe-model.d.mts +26 -0
- package/dist/recipe-model.mjs +214 -0
- package/dist/region-lowering.mjs +723 -0
- package/dist/registration-css.mjs +41 -0
- package/dist/registration-roles.mjs +35 -0
- package/dist/render-audit/axe-run.page.mjs +28 -0
- package/dist/render-audit/corner-overpaint.page.mjs +54 -0
- package/dist/render-audit/first-render.page.mjs +35 -0
- package/dist/render-audit/image-shape.page.mjs +42 -0
- package/dist/render-audit/layout-overflow.page.mjs +240 -0
- package/dist/render-audit/layout-shift.page.mjs +36 -0
- package/dist/render-audit/non-text-contrast.page.mjs +138 -0
- package/dist/render-audit/render-states.mjs +66 -293
- package/dist/render-audit/render-states.page.mjs +177 -0
- package/dist/render-audit/text-scale.mjs +42 -0
- package/dist/render-audit/text-scale.page.mjs +25 -0
- package/dist/render-audit/worker.mjs +130 -112
- package/dist/render-audit/worker.page.mjs +21 -0
- package/dist/render-audit.mjs +490 -500
- package/dist/resource-limits.mjs +174 -223
- package/dist/result.d.mts +34 -0
- package/dist/result.mjs +60 -0
- package/dist/role-vocabulary.d.mts +260 -0
- package/dist/role-vocabulary.mjs +258 -0
- package/dist/runtime-paint-contrast.mjs +97 -0
- package/dist/runtime-paint.mjs +42 -0
- package/dist/runtime-requirements.mjs +10 -11
- package/dist/runtime-style.mjs +21 -0
- package/dist/scenario-groups.mjs +42 -33
- package/dist/scenario-inspector.mjs +4 -4
- package/dist/scenario-kit.d.mts +85 -0
- package/dist/scenario-kit.mjs +18 -0
- package/dist/scenario-registry-model.mjs +2 -0
- package/dist/scenario-registry.mjs +89 -108
- package/dist/scenarios-compiler.mjs +875 -662
- package/dist/scheme-switch.d.mts +8 -0
- package/dist/scheme-switch.mjs +1 -0
- package/dist/showcase/ads-views.mjs +166 -0
- package/dist/showcase/assets-view.mjs +252 -0
- package/dist/showcase/client.bundle.js +211 -48
- package/dist/showcase/guide-controls.d.mts +28 -0
- package/dist/showcase/guide-controls.mjs +31 -0
- package/dist/showcase/http-client.bundle.js +172 -9
- package/dist/showcase/index.html +1 -1
- package/dist/showcase/preview-frame.css +18 -0
- package/dist/showcase/preview-frame.d.mts +5 -0
- package/dist/showcase/preview-frame.mjs +4 -0
- package/dist/showcase/preview-root.d.mts +2 -0
- package/dist/showcase/preview-root.mjs +9 -0
- package/dist/showcase/profiles-view.mjs +321 -0
- package/dist/showcase/project-rules.mjs +9 -0
- package/dist/showcase/sandbox.bundle.js +1 -1
- package/dist/showcase/scenario-page.d.mts +49 -0
- package/dist/showcase/scenario-page.mjs +105 -0
- package/dist/showcase/style.css +2 -0
- package/dist/showcase/token-sample.mjs +89 -0
- package/dist/showcase/tokens-view.mjs +233 -0
- package/dist/showcase/ui/apple-touch-icon-9zwv3w79.png +0 -0
- package/dist/showcase/{favicon.ico → ui/favicon-c2c9kvtf.ico} +0 -0
- package/dist/showcase/ui/icon-192-t5zh7mxx.png +0 -0
- package/dist/showcase/ui/icon-512-ed6yz0n0.png +0 -0
- package/dist/showcase/ui/ui.css +1 -1353
- package/dist/showcase/ui/ui.js +165 -1064
- package/dist/showcase-http-routes.mjs +28 -21
- package/dist/skills/README.md +28 -28
- package/dist/skills/ads-designer/README.md +1 -1
- package/dist/skills/ads-designer/SKILL.md +313 -551
- package/dist/skills/ads-designer/references/accessibility.md +162 -114
- package/dist/skills/ads-designer/references/atomic-styles.md +72 -277
- package/dist/skills/ads-designer/references/behaviors.md +144 -280
- package/dist/skills/ads-designer/references/branding.md +137 -222
- package/dist/skills/ads-designer/references/captures.md +13 -7
- package/dist/skills/ads-designer/references/cli.md +80 -63
- package/dist/skills/ads-designer/references/contracts.md +225 -286
- package/dist/skills/ads-designer/references/design-craft.md +2 -2
- package/dist/skills/ads-designer/references/design-data.md +299 -323
- package/dist/skills/ads-designer/references/drafts.md +83 -22
- package/dist/skills/ads-designer/references/evidence.md +2 -1
- package/dist/skills/ads-designer/references/forms.md +199 -0
- package/dist/skills/ads-designer/references/guarded-editing.md +37 -48
- package/dist/skills/ads-designer/references/layers.md +64 -76
- package/dist/skills/ads-designer/references/layout.md +224 -330
- package/dist/skills/ads-designer/references/mobile.md +2 -2
- package/dist/skills/ads-designer/references/motion.md +66 -25
- package/dist/skills/ads-designer/references/performance.md +55 -50
- package/dist/skills/ads-designer/references/pictograms.md +62 -127
- package/dist/skills/ads-designer/references/recipes.md +368 -0
- package/dist/skills/ads-designer/references/review.md +51 -95
- package/dist/skills/ads-designer/references/runtimes.md +34 -33
- package/dist/skills/ads-designer/references/scenarios.md +256 -216
- package/dist/skills/ads-designer/references/stress-test.md +13 -5
- package/dist/skills/ads-designer/references/validation.md +28 -21
- package/dist/skills/ads-designer/references/workflows.md +7 -5
- package/dist/skills/ads-import/SKILL.md +29 -29
- package/dist/skills/ads-import/references/atomic-styles.md +72 -277
- package/dist/skills/ads-import/references/behaviors.md +144 -280
- package/dist/skills/ads-import/references/branding.md +24 -41
- package/dist/skills/ads-import/references/captures.md +13 -7
- package/dist/skills/ads-import/references/cli.md +80 -63
- package/dist/skills/ads-import/references/compatibility.md +3 -3
- package/dist/skills/ads-import/references/contracts.md +225 -286
- package/dist/skills/ads-import/references/design-data.md +299 -323
- package/dist/skills/ads-import/references/drafts.md +83 -22
- package/dist/skills/ads-import/references/evidence.md +2 -1
- package/dist/skills/ads-import/references/forms.md +199 -0
- package/dist/skills/ads-import/references/guarded-editing.md +37 -48
- package/dist/skills/ads-import/references/implementation.md +20 -20
- package/dist/skills/ads-import/references/layers.md +64 -76
- package/dist/skills/ads-import/references/layout.md +224 -330
- package/dist/skills/ads-import/references/recipes.md +368 -0
- package/dist/skills/ads-import/references/review.md +51 -95
- package/dist/skills/ads-import/references/runtimes.md +34 -33
- package/dist/skills/ads-import/references/scenarios.md +256 -216
- package/dist/skills/ads-import/references/tokens.md +26 -17
- package/dist/skills/ads-import/references/validation.md +28 -21
- package/dist/skills/ads-import/references/workflows.md +7 -5
- package/dist/skills/ads-migrate/SKILL.md +20 -5
- package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +6 -0
- package/dist/skills/ads-migrate/references/0.4.7-to-0.5.0-boundary.md +71 -0
- package/dist/skills/ads-migrate/references/0.4.7-to-0.5.0-grid.md +204 -0
- package/dist/skills/ads-migrate/references/0.4.7-to-0.5.0.md +727 -0
- package/dist/skills/ads-migrate/references/0.5.0-to-0.5.1.md +239 -0
- package/dist/skills/ads-port/SKILL.md +27 -28
- package/dist/skills/ads-port/references/atomic-styles.md +72 -277
- package/dist/skills/ads-port/references/behaviors.md +144 -280
- package/dist/skills/ads-port/references/captures.md +13 -7
- package/dist/skills/ads-port/references/cli.md +80 -63
- package/dist/skills/ads-port/references/contracts.md +225 -286
- package/dist/skills/ads-port/references/design-data.md +299 -323
- package/dist/skills/ads-port/references/drafts.md +83 -22
- package/dist/skills/ads-port/references/evidence.md +2 -1
- package/dist/skills/ads-port/references/forms.md +199 -0
- package/dist/skills/ads-port/references/guarded-editing.md +37 -48
- package/dist/skills/ads-port/references/layers.md +64 -76
- package/dist/skills/ads-port/references/layout.md +224 -330
- package/dist/skills/ads-port/references/lint-and-docs.md +2 -3
- package/dist/skills/ads-port/references/native-implementation.md +23 -33
- package/dist/skills/ads-port/references/recipes.md +368 -0
- package/dist/skills/ads-port/references/review.md +51 -95
- package/dist/skills/ads-port/references/runtimes.md +34 -33
- package/dist/skills/ads-port/references/scenarios.md +256 -216
- package/dist/skills/ads-port/references/validation.md +28 -21
- package/dist/skills/ads-port/references/workflows.md +7 -5
- package/dist/source-inventory.mjs +33 -0
- package/dist/source-values.mjs +272 -262
- package/dist/spatial-css.mjs +403 -0
- package/dist/spatial-metadata.mjs +11 -11
- package/dist/spatial-model.mjs +438 -0
- package/dist/spatial-reading.mjs +127 -0
- package/dist/stage-timing.mjs +27 -0
- package/dist/state-conditions.d.mts +80 -0
- package/dist/state-conditions.mjs +107 -0
- package/dist/static-values.mjs +94 -0
- package/dist/surface-contrast.mjs +252 -0
- package/dist/surface-effects.mjs +98 -0
- package/dist/target-size.mjs +177 -0
- package/dist/task-cache.mjs +142 -136
- package/dist/task-worker.mjs +18 -18
- package/dist/test-boundaries.mjs +50 -189
- package/dist/token-checks.mjs +21 -0
- package/dist/token-dtcg.mjs +136 -0
- package/dist/token-expression.mjs +19 -0
- package/dist/token-inventory.mjs +146 -0
- package/dist/token-operations.mjs +37 -0
- package/dist/token-overlap.mjs +29 -0
- package/dist/token-provenance.mjs +260 -0
- package/dist/token-references.mjs +71 -0
- package/dist/token-registrations.mjs +116 -0
- package/dist/token-resolution.mjs +38 -0
- package/dist/token-sections.mjs +123 -0
- package/dist/token-shapes.mjs +121 -0
- package/dist/token-sheet-check.mjs +54 -0
- package/dist/token-type-check.mjs +89 -0
- package/dist/token-view-facts.mjs +111 -0
- package/dist/tsconfig.declarations.json +24 -0
- package/dist/types/css-tree.d.ts +45 -0
- package/dist/ui-framework.mjs +34 -34
- package/dist/units.mjs +186 -226
- package/dist/unknown.d.mts +9 -0
- package/dist/unknown.mjs +13 -0
- package/dist/unreached-sources.mjs +5 -0
- package/dist/validation-checks.mjs +62 -71
- package/dist/validation-inputs.mjs +209 -279
- package/dist/validation.mjs +132 -159
- package/dist/verification/browser.d.mts +21 -25
- package/dist/verification/browser.mjs +281 -124
- package/dist/verification/browser.page.d.mts +22 -0
- package/dist/verification/browser.page.mjs +19 -0
- package/dist/verification/paint-audit.page.d.mts +55 -0
- package/dist/verification/paint-audit.page.mjs +144 -0
- package/dist/verification/playwright-reporter.mjs +160 -0
- package/dist/verification/preview-startup.d.mts +51 -0
- package/dist/verification/preview-startup.mjs +76 -0
- package/dist/verification/request.d.mts +28 -0
- package/dist/verification/request.mjs +30 -0
- package/dist/verification/unit-preload.mjs +37 -0
- package/dist/verification.mjs +574 -607
- package/docs/ADS.md +585 -565
- package/docs/ARCHITECTURE.md +2002 -1384
- package/docs/ASSETS.md +487 -0
- package/docs/BEHAVIORS.md +339 -370
- package/docs/CACHING.md +365 -154
- package/docs/CHANGELOG.md +462 -21
- package/docs/COMPARISON.md +21 -26
- package/docs/DESIGN-REFERENCES.md +40 -27
- package/docs/GUIDE.md +2473 -1292
- package/docs/LANGUAGE.md +1159 -0
- package/docs/LOWERING.md +180 -0
- package/docs/MCP.md +1461 -1179
- package/docs/MOTION.md +491 -0
- package/docs/PROFILE-KINDS.md +544 -0
- package/docs/PROFILES.md +176 -0
- package/docs/RULES.md +590 -0
- package/docs/TOKEN-ROLES.md +377 -0
- package/docs/benchmarks/README.md +26 -27
- package/package.json +59 -45
- package/dist/a11y.mjs +0 -187
- package/dist/assets.mjs +0 -159
- package/dist/atomic-composition.mjs +0 -337
- package/dist/atomic-trace.mjs +0 -162
- package/dist/behavior-libraries.mjs +0 -174
- package/dist/behaviors.mjs +0 -306
- package/dist/brand-assets.mjs +0 -458
- package/dist/brands.mjs +0 -141
- package/dist/component-contrast.mjs +0 -256
- package/dist/construction-styles.cjs +0 -10
- package/dist/contracts/foundation.json +0 -211
- package/dist/contracts/tokens.json +0 -52
- package/dist/contracts.d.mts +0 -30
- package/dist/contrast-composition.mjs +0 -80
- package/dist/contrast-styles.mjs +0 -88
- package/dist/control-padding.mjs +0 -113
- package/dist/css-values.mjs +0 -27
- package/dist/declarative-flow.mjs +0 -244
- package/dist/design-values.mjs +0 -173
- package/dist/font-rules.mjs +0 -108
- package/dist/fonts-generated.mjs +0 -112
- package/dist/foundation-views.mjs +0 -242
- package/dist/foundation.mjs +0 -154
- package/dist/generated-entries.mjs +0 -198
- package/dist/html.mjs +0 -30
- package/dist/icons.mjs +0 -154
- package/dist/image-attributes.mjs +0 -187
- package/dist/image-size.mjs +0 -28
- package/dist/layers.mjs +0 -461
- package/dist/layout-widths.mjs +0 -332
- package/dist/linaria/atomic-css.cjs +0 -2
- package/dist/linaria/atomic-styled.cjs +0 -2
- package/dist/linaria/preserve-values.cjs +0 -58
- package/dist/linaria/spatial-inputs.cjs +0 -56
- package/dist/linaria.d.mts +0 -1
- package/dist/linaria.mjs +0 -9
- package/dist/lockup-composition.mjs +0 -44
- package/dist/lockup-model.cjs +0 -64
- package/dist/paint-contracts.mjs +0 -216
- package/dist/pictograms.mjs +0 -52
- package/dist/public-api.mjs +0 -121
- package/dist/public-props.mjs +0 -91
- package/dist/render-audit/axe-run.mjs +0 -17
- package/dist/render-audit/first-render.mjs +0 -40
- package/dist/render-audit/image-shape.mjs +0 -46
- package/dist/render-audit/layout-overflow.mjs +0 -167
- package/dist/render-audit/layout-shift.mjs +0 -32
- package/dist/render-audit/non-text-contrast.mjs +0 -151
- package/dist/render-audit/pictograms.mjs +0 -88
- package/dist/render-color-probe.mjs +0 -202
- package/dist/render-composition.mjs +0 -186
- package/dist/runtime-contracts.mjs +0 -506
- package/dist/scenario-program.mjs +0 -19
- package/dist/scenario-selectors.mjs +0 -237
- package/dist/scenario-slots.mjs +0 -217
- package/dist/scenario-trace.mjs +0 -314
- package/dist/scenarios-vite.d.mts +0 -2
- package/dist/scenarios-vite.mjs +0 -2
- package/dist/scenarios.mjs +0 -616
- package/dist/selector-match.mjs +0 -94
- package/dist/showcase/comparison.js +0 -48
- package/dist/showcase/connection.js +0 -10
- package/dist/showcase/draft-navigation.js +0 -59
- package/dist/showcase/foundation-view.css +0 -58
- package/dist/showcase/foundation-view.mjs +0 -255
- package/dist/showcase/guide-controls.ads.review.mjs +0 -32
- package/dist/showcase/http-connection.js +0 -86
- package/dist/showcase/http-preview.js +0 -81
- package/dist/showcase/icons.js +0 -2
- package/dist/showcase/navigation.js +0 -13
- package/dist/showcase/pictogram-view.mjs +0 -53
- package/dist/showcase/preview-frame.ads.review.css +0 -46
- package/dist/showcase/preview-frame.ads.review.d.mts +0 -11
- package/dist/showcase/preview-frame.ads.review.mjs +0 -22
- package/dist/showcase/preview-state.js +0 -11
- package/dist/showcase/refresh-scheduler.js +0 -23
- package/dist/showcase/resource-reader.js +0 -37
- package/dist/showcase-coverage.mjs +0 -139
- package/dist/source-symbols.mjs +0 -4
- package/dist/spatial-composition.mjs +0 -322
- package/dist/spatial-contexts.cjs +0 -56
- package/dist/spatial-css.cjs +0 -351
- package/dist/spatial-inputs.cjs +0 -80
- package/dist/spatial-model.cjs +0 -322
- package/dist/spatial.mjs +0 -21
- package/dist/stage-timing.cjs +0 -21
- package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +0 -105
- package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +0 -275
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +0 -7
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +0 -10
- package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +0 -8
- package/dist/starters/preact/ds.config.json +0 -37
- package/dist/starters/preact/package.json +0 -35
- package/dist/starters/preact/src/vite-env.d.ts +0 -7
- package/dist/starters/preact/tsconfig.json +0 -35
- package/dist/starters/preact/vite.config.ts +0 -23
- package/dist/starters/react/ADS.md +0 -286
- package/dist/starters/react/README.md +0 -184
- package/dist/starters/react/biome.css.json +0 -21
- package/dist/starters/react/design-system/assets/brand/README.md +0 -41
- package/dist/starters/react/design-system/assets/brand/app-icon.svg +0 -4
- package/dist/starters/react/design-system/assets/brand/logo.dark.svg +0 -6
- package/dist/starters/react/design-system/assets/brand/logo.svg +0 -6
- package/dist/starters/react/design-system/assets/glyphs/README.md +0 -15
- package/dist/starters/react/design-system/assets/glyphs/aliases.json +0 -1
- package/dist/starters/react/design-system/assets/glyphs/check.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/chevron-down.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/chevron-right.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/close.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/external-link.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/info.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/menu.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/plus.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/search.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/warning.svg +0 -1
- package/dist/starters/react/design-system/assets/pictograms/catalog.ads.json +0 -13
- package/dist/starters/react/design-system/assets/pictograms/journey.dark.svg +0 -7
- package/dist/starters/react/design-system/assets/pictograms/journey.svg +0 -7
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.fixture.ts +0 -1
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.scenario.tsx +0 -13
- package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +0 -56
- package/dist/starters/react/design-system/components/Actions/Button/README.md +0 -12
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.fixture.ts +0 -9
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.scenario.tsx +0 -16
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +0 -60
- package/dist/starters/react/design-system/components/Actions/IconButton/README.md +0 -17
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +0 -6
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +0 -16
- package/dist/starters/react/design-system/components/Content/Icon/Icon.tsx +0 -42
- package/dist/starters/react/design-system/components/Content/Icon/README.md +0 -17
- package/dist/starters/react/design-system/components/Content/Icon/glyphs.ts +0 -17
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.fixture.ts +0 -2
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.scenario.tsx +0 -13
- package/dist/starters/react/design-system/components/Content/Image/Image.tsx +0 -51
- package/dist/starters/react/design-system/components/Content/Image/README.md +0 -20
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.fixture.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.scenario.tsx +0 -12
- package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +0 -35
- package/dist/starters/react/design-system/components/Content/Logo/README.md +0 -12
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.fixture.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.scenario.tsx +0 -7
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.tsx +0 -26
- package/dist/starters/react/design-system/components/Forms/TextField/README.md +0 -14
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.fixture.ts +0 -6
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.scenario.tsx +0 -13
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.tsx +0 -61
- package/dist/starters/react/design-system/composition/Search/SearchPage/README.md +0 -4
- package/dist/starters/react/design-system/composition/Search/SearchPage/SearchPage.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/composition/Search/SearchPage/SearchPage.ads.scenario.tsx +0 -16
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +0 -5
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +0 -13
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +0 -22
- package/dist/starters/react/design-system/controllers/Palette/Palette.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/controllers/Palette/Palette.ts +0 -164
- package/dist/starters/react/design-system/index.ts +0 -12
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +0 -15
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +0 -105
- package/dist/starters/react/design-system/patterns/Conversation/README.md +0 -9
- package/dist/starters/react/design-system/patterns/Search/SearchBar/README.md +0 -12
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.fixture.ts +0 -1
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.scenario.tsx +0 -11
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.tsx +0 -41
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +0 -5
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +0 -21
- package/dist/starters/react/design-system/patterns/Shell/README.md +0 -43
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +0 -5
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +0 -21
- package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +0 -274
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +0 -7
- package/dist/starters/react/design-system/review/index.ads.review.ts +0 -4
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +0 -6
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +0 -10
- package/dist/starters/react/design-system/showcase/mcp/main.ads.mount.tsx +0 -10
- package/dist/starters/react/design-system/styles.css +0 -7
- package/dist/starters/react/design-system/tokens/base.css +0 -36
- package/dist/starters/react/design-system/tokens/catalog.ads.json +0 -1221
- package/dist/starters/react/design-system/tokens/colors.css +0 -215
- package/dist/starters/react/design-system/tokens/elevation.css +0 -53
- package/dist/starters/react/design-system/tokens/spacing.css +0 -87
- package/dist/starters/react/design-system/tokens/spatial.ads.json +0 -70
- package/dist/starters/react/design-system/tokens/themes.generated.css +0 -142
- package/dist/starters/react/design-system/tokens/themes.generated.ts +0 -402
- package/dist/starters/react/design-system/tokens/typography.css +0 -31
- package/dist/starters/react/ds.config.json +0 -37
- package/dist/starters/react/gitignore.template +0 -8
- package/dist/starters/react/package.json +0 -39
- package/dist/starters/react/scripts/build-mcp-previews.mjs +0 -3
- package/dist/starters/react/src/vite-env.d.ts +0 -7
- package/dist/starters/react/tsconfig.build.json +0 -20
- package/dist/starters/react/tsconfig.json +0 -34
- package/dist/starters/react/vite.config.ts +0 -23
- package/dist/style-boundaries.mjs +0 -106
- package/dist/style-token-rules.mjs +0 -51
- package/dist/themes-generated.mjs +0 -161
- package/dist/themes-watch.mjs +0 -83
- package/dist/themes.mjs +0 -360
- package/dist/token-export.mjs +0 -94
- package/dist/token-origins.mjs +0 -24
- package/dist/token-policy.mjs +0 -26
- package/dist/token-quality.mjs +0 -149
- package/dist/token-samples.mjs +0 -19
- package/dist/tokens.mjs +0 -194
- package/dist/unit-contracts.mjs +0 -396
- package/dist/usage.mjs +0 -184
- package/dist/verification/playwright-reporter.cjs +0 -87
- package/docs/CONTRACTS.md +0 -285
- package/docs/HTTP-SHOWCASE-POC.md +0 -397
- package/docs/SPATIAL-CHECKS.md +0 -69
- package/docs/benchmarks/http-showcase-optimized.json +0 -1879
- package/docs/benchmarks/http-showcase-profile.json +0 -308
- package/docs/benchmarks/http-showcase.json +0 -3069
- /package/dist/{starters/react/design-system/assets/fonts/.gitkeep → analysis/semantic.mjs} +0 -0
- /package/dist/{starters/react/design-system/controllers/.gitkeep → lowering-model.mjs} +0 -0
- /package/dist/showcase/{favicon.svg → ui/favicon-scavmehf.svg} +0 -0
|
@@ -0,0 +1,1555 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import {
|
|
3
|
+
ScriptTarget,
|
|
4
|
+
SyntaxKind,
|
|
5
|
+
isBinaryExpression,
|
|
6
|
+
isBindingElement,
|
|
7
|
+
isBlock,
|
|
8
|
+
isCallExpression,
|
|
9
|
+
isComputedPropertyName,
|
|
10
|
+
isConditionalExpression,
|
|
11
|
+
isDoStatement,
|
|
12
|
+
isElementAccessExpression,
|
|
13
|
+
isForInStatement,
|
|
14
|
+
isForOfStatement,
|
|
15
|
+
isForStatement,
|
|
16
|
+
isFunctionLikeDeclaration,
|
|
17
|
+
isIdentifier,
|
|
18
|
+
isIfStatement,
|
|
19
|
+
isImportDeclaration,
|
|
20
|
+
isJsxAttribute,
|
|
21
|
+
isJsxElement,
|
|
22
|
+
isJsxExpression,
|
|
23
|
+
isJsxFragment,
|
|
24
|
+
isJsxOpeningElement,
|
|
25
|
+
isJsxSelfClosingElement,
|
|
26
|
+
isJsxSpreadAttribute,
|
|
27
|
+
isJsxText,
|
|
28
|
+
isObjectLiteralExpression,
|
|
29
|
+
isParameterDeclaration,
|
|
30
|
+
isParenthesizedExpression,
|
|
31
|
+
isPropertyAccessExpression,
|
|
32
|
+
isPropertyAssignment,
|
|
33
|
+
isReturnStatement,
|
|
34
|
+
isShorthandPropertyAssignment,
|
|
35
|
+
isStringLiteral,
|
|
36
|
+
isVariableDeclaration,
|
|
37
|
+
isVariableDeclarationList,
|
|
38
|
+
isWhileStatement
|
|
39
|
+
} from "typescript/ast";
|
|
40
|
+
import { JsxEmit, ModuleKind, ModuleResolutionKind } from "typescript/async";
|
|
41
|
+
import { compileDelivery } from "../linaria/delivery.mjs";
|
|
42
|
+
import { constructionId } from "../linaria/extraction-model.mjs";
|
|
43
|
+
import { attemptAsync, err, ok } from "../result.mjs";
|
|
44
|
+
import { resolveAsset } from "../asset-catalog.mjs";
|
|
45
|
+
import { DEPENDENCY_MANIFEST, dependencyManifest, serializeManifest } from "../dependency-manifest.mjs";
|
|
46
|
+
import { componentCellFinding, frameRegionFinding, keylineFinding, tileFrameFinding } from "../frame-regions.mjs";
|
|
47
|
+
import { combineRecipes } from "../recipe-model.mjs";
|
|
48
|
+
import { ownerDesign } from "../owner-design.mjs";
|
|
49
|
+
import { SourceAbsentError, cachedProgram, inRevision, location, memoResult, nodesOfKind, resolveModuleDetails, valueSymbolAt } from "./native-boundary.mjs";
|
|
50
|
+
import * as timing from "../stage-timing.mjs";
|
|
51
|
+
import { collectModuleGraph } from "./module-graph.mjs";
|
|
52
|
+
import { publicImports } from "./public-imports.mjs";
|
|
53
|
+
import { assetMacroUse, GLYPH_SUPPORT, GLYPH_SUPPORT_SOURCE } from "./glyph-macros.mjs";
|
|
54
|
+
import { checkSetKey, drawingsIdentity, referenceAssets, referenceForm, setLookupCode, setLookupForm } from "./visual-bindings.mjs";
|
|
55
|
+
import {
|
|
56
|
+
RECIPE_MODULE,
|
|
57
|
+
authoredAt,
|
|
58
|
+
choiceLimits,
|
|
59
|
+
mapCallback,
|
|
60
|
+
choiceValues,
|
|
61
|
+
classItems,
|
|
62
|
+
emitChoice,
|
|
63
|
+
failAt,
|
|
64
|
+
finiteType,
|
|
65
|
+
nameText
|
|
66
|
+
} from "./owner-choices.mjs";
|
|
67
|
+
import { lowerArtwork, lowerControl } from "../owner-lowering.mjs";
|
|
68
|
+
import { lowerGrid } from "../grid-lowering.mjs";
|
|
69
|
+
import { lowerRegion, regionConditionQuery, regionModalQuery } from "../region-lowering.mjs";
|
|
70
|
+
import { LIGHT } from "../construction-output.mjs";
|
|
71
|
+
import { selectedProfile, tokenCss } from "../design-foundation.mjs";
|
|
72
|
+
import { sectionsDeclared, tokenSectionCss } from "../token-sections.mjs";
|
|
73
|
+
import {
|
|
74
|
+
visualBinding,
|
|
75
|
+
declaredCells,
|
|
76
|
+
declaredMeasured,
|
|
77
|
+
declaredPaints,
|
|
78
|
+
interactionUses,
|
|
79
|
+
declaredParts,
|
|
80
|
+
elementTags,
|
|
81
|
+
parseConstruction,
|
|
82
|
+
CONTROL_TEXT_TAGS,
|
|
83
|
+
PSEUDO_HOSTS,
|
|
84
|
+
VECTOR_SHAPES
|
|
85
|
+
} from "../construction-spec.mjs";
|
|
86
|
+
import { recipeDefaults, visualBindingRedundancy } from "../recipe-defaults.mjs";
|
|
87
|
+
import { ownerScope } from "../runtime-style.mjs";
|
|
88
|
+
import { runtimePaintContrast } from "../runtime-paint-contrast.mjs";
|
|
89
|
+
import { paintUnion } from "../runtime-paint.mjs";
|
|
90
|
+
import { checkPaintValue, declaredNames as runtimeNames, paintTypeReads, runtimeChannel, runtimeDeclarations, runtimePaths, runtimeSetter, undeclared, unused } from "./runtime-setters.mjs";
|
|
91
|
+
import { digest } from "../digest.mjs";
|
|
92
|
+
import { FOUNDATION_DECLARATION } from "../design-contexts.mjs";
|
|
93
|
+
import { cornerOverpaint } from "../corner-overpaint.mjs";
|
|
94
|
+
import { inactiveSurfaceActive, stateContrast, surfacedElements, surfaceUses } from "../surface-contrast.mjs";
|
|
95
|
+
import { compositionFacts, plainPlacements } from "./owner-composition.mjs";
|
|
96
|
+
import { ownerControls } from "./owner-controls.mjs";
|
|
97
|
+
import { pressScaleReviews } from "../press-scale.mjs";
|
|
98
|
+
import { nonTextContrast } from "../non-text-contrast.mjs";
|
|
99
|
+
import { clickWithoutKeyboard, missingAutocomplete, namedByAttribute } from "./owner-accessibility.mjs";
|
|
100
|
+
import { formStateFailures } from "../form-states.mjs";
|
|
101
|
+
import { foundationSheet, withFoundationSheet } from "../emit/foundation-sheet.mjs";
|
|
102
|
+
import { fontEmission, withFontsModule } from "../emit/font-emission.mjs";
|
|
103
|
+
import { preloadedFaces } from "../font-checks.mjs";
|
|
104
|
+
import { appIconPlan, describeAppIcon } from "../app-icon-checks.mjs";
|
|
105
|
+
import { appIconEmission, withAppIconsModule } from "../emit/app-icon-emission.mjs";
|
|
106
|
+
import { withOutputPackage } from "../emit/output-package.mjs";
|
|
107
|
+
import { analyzedOwners, outcomeCounts, rowsRead } from "./owner-outcomes.mjs";
|
|
108
|
+
import { capturedTreeFiles } from "./helpers.mjs";
|
|
109
|
+
import { programGlobals } from "./owner-analysis-key.mjs";
|
|
110
|
+
import { isScenarioFile } from "../config.mjs";
|
|
111
|
+
import { frameworkMismatches } from "./framework-imports.mjs";
|
|
112
|
+
import { CONTROLLER_FOLDER, controllerGateFailures } from "./controller-gates.mjs";
|
|
113
|
+
import { isDevelopmentModule } from "../development-modules.mjs";
|
|
114
|
+
import { cssInJsImports, scriptAnimations, ownerStyleWrites, ownerStylesheetImports, plainModuleStyling, scenarioStyling, stylingFailure, unemittedStyling } from "./styling-ownership.mjs";
|
|
115
|
+
export const PUBLIC_BARREL = "index.ts", AMBIENT_DECLARATIONS = "env.d.ts", ownerCompilerOptions = (root, publicAlias, framework) => ({
|
|
116
|
+
target: ScriptTarget.ESNext,
|
|
117
|
+
module: ModuleKind.ESNext,
|
|
118
|
+
moduleResolution: ModuleResolutionKind.Bundler,
|
|
119
|
+
jsx: JsxEmit.ReactJSX,
|
|
120
|
+
...framework === "preact" ? { jsxImportSource: "preact" } : {},
|
|
121
|
+
strict: !0,
|
|
122
|
+
skipLibCheck: !0,
|
|
123
|
+
noEmit: !0,
|
|
124
|
+
types: [],
|
|
125
|
+
paths: { [publicAlias]: [path.join(root, PUBLIC_BARREL)] }
|
|
126
|
+
});
|
|
127
|
+
export async function programSource(program, file) {
|
|
128
|
+
const source = await program.getSourceFile(file);
|
|
129
|
+
if (source === void 0)
|
|
130
|
+
throw new SourceAbsentError(file);
|
|
131
|
+
return source;
|
|
132
|
+
}
|
|
133
|
+
export const ownerProgramRoots = (root, names) => {
|
|
134
|
+
const ambient = path.join(root, AMBIENT_DECLARATIONS);
|
|
135
|
+
return [...[...names].map((name) => path.join(root, name)), ...inRevision(ambient) ? [ambient] : []];
|
|
136
|
+
};
|
|
137
|
+
const openingOf = (node) => isJsxElement(node) ? node.openingElement : isJsxSelfClosingElement(node) ? node : null, elementOf = (opening) => isJsxOpeningElement(opening) ? opening.parent : opening, attr = (opening, name) => opening.attributes.properties.find((node) => isJsxAttribute(node) && nameText(node.name) === name);
|
|
138
|
+
function expression(attribute) {
|
|
139
|
+
const initializer = attribute?.initializer;
|
|
140
|
+
if (initializer === void 0)
|
|
141
|
+
return;
|
|
142
|
+
return isJsxExpression(initializer) ? initializer.expression : initializer;
|
|
143
|
+
}
|
|
144
|
+
const alwaysReturns = (statement) => {
|
|
145
|
+
if (isReturnStatement(statement))
|
|
146
|
+
return !0;
|
|
147
|
+
const last = isBlock(statement) ? statement.statements.at(-1) : void 0;
|
|
148
|
+
return last !== void 0 && isReturnStatement(last);
|
|
149
|
+
}, inside = (node, parent) => node.getStart() >= parent.getStart() && node.end <= parent.end;
|
|
150
|
+
function autoPlaced(spec, selector) {
|
|
151
|
+
if (spec.kind !== "grid")
|
|
152
|
+
return !1;
|
|
153
|
+
const cell = spec.cells.find((item) => item.selector === selector), start = (values) => values.find(([field]) => field === "start")?.[1];
|
|
154
|
+
return cell !== void 0 && start(cell.values) === "auto" && cell.at.every(([, values]) => [void 0, "auto"].includes(start(values)));
|
|
155
|
+
}
|
|
156
|
+
function callbackResult(mapped) {
|
|
157
|
+
const { body } = mapped.callback;
|
|
158
|
+
if (!isBlock(body))
|
|
159
|
+
return body;
|
|
160
|
+
const [only] = body.statements;
|
|
161
|
+
return body.statements.length === 1 && only !== void 0 && isReturnStatement(only) && only.expression !== void 0 ? only.expression : null;
|
|
162
|
+
}
|
|
163
|
+
function insideMap(node, ancestor) {
|
|
164
|
+
for (let current = node.parent;current !== void 0 && current !== ancestor; current = current.parent)
|
|
165
|
+
if (isFunctionLikeDeclaration(current) && current.parent !== void 0 && mapCallback(current.parent)?.callback === current)
|
|
166
|
+
return !0;
|
|
167
|
+
return !1;
|
|
168
|
+
}
|
|
169
|
+
const isLoop = (node) => isForStatement(node) || isForOfStatement(node) || isForInStatement(node) || isWhileStatement(node) || isDoStatement(node), lowercaseTag = (opening) => /^[a-z]/.test(opening.tagName.getText()), NO_CLASSES = { fragments: [], calls: [], markers: [], placement: [], bindings: [] };
|
|
170
|
+
function validateReferences(foundation, spec) {
|
|
171
|
+
if (typeof spec !== "object" || spec === null)
|
|
172
|
+
return null;
|
|
173
|
+
for (const [key, value] of Object.entries(spec))
|
|
174
|
+
if ((key === "profile" || key === "surface") && typeof value === "string") {
|
|
175
|
+
const selected = selectedProfile(foundation, value);
|
|
176
|
+
if (selected.kind === "err")
|
|
177
|
+
return selected.error;
|
|
178
|
+
} else if (typeof value === "object" && value !== null) {
|
|
179
|
+
const failure = validateReferences(foundation, value);
|
|
180
|
+
if (failure !== null)
|
|
181
|
+
return failure;
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
const entryFile = (entry) => {
|
|
186
|
+
switch (entry.kind) {
|
|
187
|
+
case "barrel":
|
|
188
|
+
return PUBLIC_BARREL;
|
|
189
|
+
case "owners-only":
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
async function moduleGraph(root, names, publicAlias, framework, entry, checked = []) {
|
|
194
|
+
const barrel = entryFile(entry), roots = new Set([...names, ...barrel === null ? [] : [barrel], ...checked]);
|
|
195
|
+
for (;; ) {
|
|
196
|
+
const program = await cachedProgram("owner-source-proof", ownerProgramRoots(root, roots), ownerCompilerOptions(root, publicAlias, framework)), checker = program.getTypeChecker(), resolutionOf = async (specifier) => {
|
|
197
|
+
if (!isStringLiteral(specifier))
|
|
198
|
+
return { kind: "unresolved" };
|
|
199
|
+
const resolved = await resolveModuleDetails(specifier.text, specifier.getSourceFile().fileName, ownerCompilerOptions(root, publicAlias, framework));
|
|
200
|
+
if (resolved === null) {
|
|
201
|
+
const symbol = await valueSymbolAt(checker, specifier), declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];
|
|
202
|
+
return declaration !== void 0 && declaration.kind !== SyntaxKind.SourceFile ? { kind: "ambient" } : { kind: "unresolved" };
|
|
203
|
+
}
|
|
204
|
+
if (resolved.external)
|
|
205
|
+
return { kind: "package" };
|
|
206
|
+
const relative = path.relative(root, resolved.file);
|
|
207
|
+
return relative.startsWith("..") || path.isAbsolute(relative) ? { kind: "outside", file: resolved.file } : { kind: "local", file: relative };
|
|
208
|
+
}, walk = await memoResult(program, `module-graph:${barrel ?? ""}:${names.join(`
|
|
209
|
+
`)}`, () => attemptAsync((reject) => collectModuleGraph({
|
|
210
|
+
root,
|
|
211
|
+
owners: names,
|
|
212
|
+
entry: barrel,
|
|
213
|
+
publicModule: publicAlias,
|
|
214
|
+
source: (file) => programSource(program, path.join(root, file)),
|
|
215
|
+
resolve: resolutionOf,
|
|
216
|
+
declarationPackage: async (specifier) => {
|
|
217
|
+
const symbol = await valueSymbolAt(checker, specifier), file = (symbol?.valueDeclaration ?? symbol?.declarations?.[0])?.getSourceFile().fileName ?? "";
|
|
218
|
+
return /[\\/]node_modules[\\/](@types[\\/][^\\/]+)[\\/]/.exec(file)?.[1]?.replace("\\", "/") ?? null;
|
|
219
|
+
},
|
|
220
|
+
publicFiles: async (source, file) => (await publicImports({ root, file, source, publicModule: publicAlias, symbolOf: (node) => valueSymbolAt(checker, node), emitted: null, fail: failAt(reject) })).files,
|
|
221
|
+
reject
|
|
222
|
+
}, roots)));
|
|
223
|
+
if (walk.kind === "err")
|
|
224
|
+
return walk;
|
|
225
|
+
if (walk.value.kind === "complete")
|
|
226
|
+
return ok({ program, graph: walk.value.graph });
|
|
227
|
+
for (const worker of walk.value.workers)
|
|
228
|
+
roots.add(worker);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
export async function analyzeOwners(root, names, options, entry = { kind: "owners-only" }) {
|
|
232
|
+
const { foundation, assets } = options, walked = await timing.timeStage("module-graph", () => moduleGraph(root, names, options.publicAlias, options.framework, entry));
|
|
233
|
+
if (walked.kind === "err")
|
|
234
|
+
return walked;
|
|
235
|
+
const { program, graph } = walked.value, emitted = new Set(graph.modules.keys()), assetIdentity = digest([[...assets.records].map(([name, asset]) => [name, asset.drawings]), [...assets.names], [...assets.sets].map(([name, set]) => [name, [...set.keys]])]);
|
|
236
|
+
return memoResult(program, `owner-source:${entry.kind}:${foundation.hash}:${assetIdentity}:${names.join(`
|
|
237
|
+
`)}`, () => attemptAsync(async (reject) => {
|
|
238
|
+
options.stats.analyses++;
|
|
239
|
+
const fail = failAt(reject), owners = new Map, rowsOf = (owner) => owners.get(owner)?.publicRows ?? null;
|
|
240
|
+
let plain = new Map;
|
|
241
|
+
await timing.timeStage("owner-facts", async () => {
|
|
242
|
+
for (const name of names)
|
|
243
|
+
owners.set(name, await analyzeOwner(root, emitted, name, program, options, rowsOf, fail));
|
|
244
|
+
plain = await plainModules(root, graph, program, options.publicAlias, emitted, options.assets, fail);
|
|
245
|
+
}, { owners: names.length });
|
|
246
|
+
const types = await typeDiagnostics(root, program);
|
|
247
|
+
if (types !== null)
|
|
248
|
+
return reject(types);
|
|
249
|
+
const compiled = compileOwners(owners, options);
|
|
250
|
+
if (compiled.kind === "err")
|
|
251
|
+
return reject(compiled.error);
|
|
252
|
+
return { owners, program, compiled: compiled.value, foundation, document: options.document, themes: options.themes, assets, fonts: options.fonts, appIcon: options.appIcon, graph, plain };
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
const TEXT_ENTRY_TYPES = new Set(["text", "email", "tel", "url", "password", "search", "number"]);
|
|
256
|
+
export async function checkOwners(root, names, options, reuse) {
|
|
257
|
+
const scenarios = (capturedTreeFiles(root) ?? []).filter((file) => isScenarioFile(file)).map((file) => path.relative(root, file).split(path.sep).join("/")).sort(), walked = await timing.timeStage("module-graph", () => moduleGraph(root, names, options.publicAlias, options.framework, { kind: "barrel" }, scenarios));
|
|
258
|
+
if (walked.kind === "err")
|
|
259
|
+
return walked;
|
|
260
|
+
const { program, graph } = walked.value, emitted = new Set(graph.modules.keys());
|
|
261
|
+
options.stats.analyses++;
|
|
262
|
+
const outcomes = new Map, facts = new Map, pass = await timing.timeStage("owner-keys", () => reuse.begin(program, graph));
|
|
263
|
+
let plain = { modules: new Map, failures: [], placements: [] }, unemitted = [];
|
|
264
|
+
await timing.timeStage("owner-facts", async () => {
|
|
265
|
+
for (const name of names) {
|
|
266
|
+
const analyze = (foundation) => checkedOwner(root, emitted, name, program, { ...options, foundation }, outcomes, (analyzed) => facts.set(name, analyzed));
|
|
267
|
+
outcomes.set(name, await pass.owner({ name, settled: outcomes, analyze }));
|
|
268
|
+
}
|
|
269
|
+
plain = await checkedPlainModules(root, graph, program, options.publicAlias, emitted, options.assets);
|
|
270
|
+
unemitted = [
|
|
271
|
+
...(await unemittedStyling(root, emitted)).map(stylingFailure),
|
|
272
|
+
...await frameworkMismatches(root, options.framework ?? null),
|
|
273
|
+
...await controllerGateFailures(root, options.publicAlias, options.framework)
|
|
274
|
+
];
|
|
275
|
+
for (const file of scenarios.filter((name) => !name.startsWith("mocks/")))
|
|
276
|
+
unemitted = [
|
|
277
|
+
...unemitted,
|
|
278
|
+
...await pass.scenarioStyling(file, async () => (await scenarioStyling(await programSource(program, path.join(root, file)), program, program.getTypeChecker())).map(stylingFailure))
|
|
279
|
+
];
|
|
280
|
+
}, { owners: names.length }, () => {
|
|
281
|
+
const { reused, analyzed } = pass.tally(), { failed, blocked } = outcomeCounts(outcomes.values());
|
|
282
|
+
return { reused: reused.length, analyzed: analyzed.length, failed, blocked };
|
|
283
|
+
});
|
|
284
|
+
const types = await typeDiagnostics(root, program), compiled = compileOwners(analyzedOwners(outcomes), options);
|
|
285
|
+
return ok({
|
|
286
|
+
outcomes,
|
|
287
|
+
program: [...plain.failures, ...unemitted, ...types === null ? [] : [types], ...compiled.kind === "err" ? [compiled.error] : []],
|
|
288
|
+
compiled: compiled.kind === "ok" ? compiled.value : null,
|
|
289
|
+
foundation: options.foundation,
|
|
290
|
+
graph,
|
|
291
|
+
globals: () => programGlobals(root, program),
|
|
292
|
+
checkProgram: program,
|
|
293
|
+
facts,
|
|
294
|
+
plain: plain.modules,
|
|
295
|
+
plainPlacements: plain.placements
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
async function checkedOwner(root, emitted, name, program, options, settled, retain) {
|
|
299
|
+
const blocked = await attemptAsync((block) => attemptAsync(async (reject) => {
|
|
300
|
+
const facts = await analyzeOwner(root, emitted, name, program, options, (owner, usage) => {
|
|
301
|
+
const read = rowsRead(settled.get(owner));
|
|
302
|
+
switch (read.kind) {
|
|
303
|
+
case "rows":
|
|
304
|
+
return read.rows;
|
|
305
|
+
case "unavailable": {
|
|
306
|
+
const at = location(usage);
|
|
307
|
+
return block({ needs: owner, at: { kind: "point", file: at.file, position: { line: at.line, column: at.column } } });
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}, failAt(reject));
|
|
311
|
+
retain(facts);
|
|
312
|
+
const composition = await timing.timeStage("composition-facts", () => compositionFacts({ root, source: facts.source, values: facts.values, checker: program.getTypeChecker(), foundation: options.foundation }));
|
|
313
|
+
return { styles: facts.styles, publicRows: facts.publicRows, controls: facts.controls, reviews: facts.reviews, artwork: facts.artwork, design: facts.design, composition };
|
|
314
|
+
}));
|
|
315
|
+
if (blocked.kind === "err")
|
|
316
|
+
return { kind: "blocked", ...blocked.error };
|
|
317
|
+
const analyzed = blocked.value;
|
|
318
|
+
switch (analyzed.kind) {
|
|
319
|
+
case "ok":
|
|
320
|
+
return { kind: "analyzed", owner: analyzed.value };
|
|
321
|
+
case "err":
|
|
322
|
+
return { kind: "failed", failure: analyzed.error };
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
async function plainModules(root, graph, program, publicAlias, emitted, catalog, fail) {
|
|
326
|
+
const plain = new Map;
|
|
327
|
+
for (const module of graph.modules.values()) {
|
|
328
|
+
if (module.role === "owner")
|
|
329
|
+
continue;
|
|
330
|
+
const [styling] = await plainStyling(root, module.file, program);
|
|
331
|
+
if (styling !== void 0)
|
|
332
|
+
return fail(styling.node, styling.problem);
|
|
333
|
+
plain.set(module.file, await plainModule(root, module.file, module.role, program, publicAlias, emitted, catalog, fail));
|
|
334
|
+
}
|
|
335
|
+
return plain;
|
|
336
|
+
}
|
|
337
|
+
async function checkedPlainModules(root, graph, program, publicAlias, emitted, catalog) {
|
|
338
|
+
const modules = new Map, failures = [], placements = [], checker = program.getTypeChecker();
|
|
339
|
+
for (const module of graph.modules.values()) {
|
|
340
|
+
if (module.role === "owner")
|
|
341
|
+
continue;
|
|
342
|
+
const { file, role } = module, controller = file.startsWith(`${CONTROLLER_FOLDER}/`);
|
|
343
|
+
failures.push(...(await plainStyling(root, file, program)).filter(({ problem }) => !(controller && problem.kind === "plain-markup")).map(stylingFailure));
|
|
344
|
+
const checked = await attemptAsync((reject) => plainModule(root, file, role, program, publicAlias, emitted, catalog, failAt(reject)));
|
|
345
|
+
switch (checked.kind) {
|
|
346
|
+
case "ok":
|
|
347
|
+
modules.set(file, checked.value);
|
|
348
|
+
placements.push(...await timing.timeStage("plain-placements", () => plainPlacements(root, checked.value.source, (node) => valueSymbolAt(checker, node))));
|
|
349
|
+
break;
|
|
350
|
+
case "err":
|
|
351
|
+
failures.push(checked.error);
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return { modules, failures, placements };
|
|
356
|
+
}
|
|
357
|
+
async function plainStyling(root, file, program) {
|
|
358
|
+
return plainModuleStyling(await programSource(program, path.join(root, file)), program, program.getTypeChecker());
|
|
359
|
+
}
|
|
360
|
+
async function plainModule(root, file, role, program, publicAlias, emitted, catalog, fail) {
|
|
361
|
+
const checker = program.getTypeChecker(), source = await programSource(program, path.join(root, file)), symbol = (node) => valueSymbolAt(checker, node), rewritten = await publicImports({ root, file, source, publicModule: publicAlias, symbolOf: symbol, emitted, fail }), macros = await assetMacroUse({ root, file, source, checker, symbol, catalog, fail }), artwork = { assets: [], sets: [], glyphs: macros.glyphs, support: macros.support };
|
|
362
|
+
return { source, role, imports: rewritten.imports, statements: rewritten.statements, edits: macros.edits, artwork };
|
|
363
|
+
}
|
|
364
|
+
async function typeDiagnostics(root, program) {
|
|
365
|
+
const diagnostics = (await timing.timeStage("type-diagnostics", () => program.getDiagnostics())).filter((diagnostic) => !previewAssetImport(root, diagnostic));
|
|
366
|
+
return diagnostics.length > 0 ? { kind: "typescript-diagnostics", diagnostics } : null;
|
|
367
|
+
}
|
|
368
|
+
const SCRIPT_MODULE = /\.[cm]?[jt]sx?$/, PREVIEW_ASSET = /\.(?:svg|png|jpe?g|gif|webp|avif|ico|bmp|woff2?|ttf|otf|eot|mp4|webm|mp3|wav|ogg|wasm|txt|md|json|css)$/i;
|
|
369
|
+
function previewAssetImport(root, diagnostic) {
|
|
370
|
+
if (diagnostic.code !== 2307 || diagnostic.fileName === void 0)
|
|
371
|
+
return !1;
|
|
372
|
+
const importer = path.relative(root, diagnostic.fileName).split(path.sep).join("/");
|
|
373
|
+
if (importer.startsWith("..") || !isDevelopmentModule(importer))
|
|
374
|
+
return !1;
|
|
375
|
+
const text = typeof diagnostic.messageText === "string" ? diagnostic.messageText : diagnostic.messageText.messageText, specifier = /'([^']+)'/.exec(text)?.[1];
|
|
376
|
+
if (specifier === void 0 || !specifier.startsWith("."))
|
|
377
|
+
return !1;
|
|
378
|
+
const named = specifier.replace(/[?#].*$/, "");
|
|
379
|
+
if (specifier !== named)
|
|
380
|
+
return !SCRIPT_MODULE.test(named) || inRevision(path.resolve(path.dirname(diagnostic.fileName), named));
|
|
381
|
+
return PREVIEW_ASSET.test(named);
|
|
382
|
+
}
|
|
383
|
+
function compileOwners(owners, options) {
|
|
384
|
+
const compiled = compileDelivery(new Map([...owners].map(([name, owner]) => [name, owner.styles])), options.cache === void 0 ? {} : { cache: options.cache });
|
|
385
|
+
return compiled.kind === "err" ? err({ kind: "compile", failure: compiled.error, origin: compileOrigin(owners, compiled.error) }) : compiled;
|
|
386
|
+
}
|
|
387
|
+
function compileOrigin(owners, failure) {
|
|
388
|
+
const located = (() => {
|
|
389
|
+
switch (failure.kind) {
|
|
390
|
+
case "extraction":
|
|
391
|
+
return [failure.failure.id, failure.owner];
|
|
392
|
+
case "origin-missing":
|
|
393
|
+
return [failure.id, failure.owner];
|
|
394
|
+
case "construction-conflict":
|
|
395
|
+
return [failure.id, failure.owners[0]];
|
|
396
|
+
case "keyframes-unreferenced":
|
|
397
|
+
case "keyframes-missing":
|
|
398
|
+
return [failure.id, null];
|
|
399
|
+
case "runtime-incompatible":
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
})();
|
|
403
|
+
if (located === null)
|
|
404
|
+
return null;
|
|
405
|
+
const [id, owner] = located, named = owner === null ? void 0 : owners.get(owner)?.styles.get(id)?.origins[0];
|
|
406
|
+
if (named !== void 0)
|
|
407
|
+
return named;
|
|
408
|
+
for (const facts of owners.values()) {
|
|
409
|
+
const origin = facts.styles.get(id)?.origins[0];
|
|
410
|
+
if (origin !== void 0)
|
|
411
|
+
return origin;
|
|
412
|
+
}
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail) {
|
|
416
|
+
const { foundation, assets, themes } = options, source = await programSource(program, path.join(root, name)), [cssInJs] = cssInJsImports(source);
|
|
417
|
+
if (cssInJs !== void 0)
|
|
418
|
+
return fail(cssInJs.node, cssInJs.problem);
|
|
419
|
+
const [stylesheet] = ownerStylesheetImports(source);
|
|
420
|
+
if (stylesheet !== void 0)
|
|
421
|
+
return fail(stylesheet.node, stylesheet.problem);
|
|
422
|
+
const values = await choiceValues({ program, source, root, validateSpec: (spec) => validateReferences(foundation, spec), fail }), checker = program.getTypeChecker(), [styleWrite] = await ownerStyleWrites(source, program, checker);
|
|
423
|
+
if (styleWrite !== void 0)
|
|
424
|
+
return fail(styleWrite.node, styleWrite.problem);
|
|
425
|
+
const [animation] = await scriptAnimations(source, program, checker);
|
|
426
|
+
if (animation !== void 0)
|
|
427
|
+
return fail(animation.node, animation.problem);
|
|
428
|
+
const scope = ownerScope(name), runtimeKey = (channel, valueName) => `${channel}:${valueName}`, declaredRuntime = new Map, macros = await assetMacroUse({ root, file: name, source, checker, symbol: values.symbol, catalog: assets, fail }), boundAssets = new Set, boundSets = new Set, references = new Set, carried = new Map, receivable = (glyph) => {
|
|
429
|
+
let known = carried.get(glyph);
|
|
430
|
+
if (known === void 0)
|
|
431
|
+
carried.set(glyph, known = referenceAssets(checker, assets, glyph, fail));
|
|
432
|
+
return known;
|
|
433
|
+
}, selections = [], restatements = new Map, restating = (at, redundancy) => {
|
|
434
|
+
if (at === null || restatements.get(at)?.kind === "changes")
|
|
435
|
+
return;
|
|
436
|
+
restatements.set(at, redundancy === null ? { kind: "changes" } : restatements.get(at) ?? { kind: "redundant", redundancy });
|
|
437
|
+
}, styles = new Map, exposedRows = new Map, publicRowsOf = async (component) => {
|
|
438
|
+
const declaration = (await values.symbol(component.tagName))?.valueDeclaration;
|
|
439
|
+
if (declaration === void 0)
|
|
440
|
+
return null;
|
|
441
|
+
return rowsOf(path.relative(root, declaration.getSourceFile().fileName), component);
|
|
442
|
+
}, takesAutocomplete = async (component) => {
|
|
443
|
+
const declaration = (await values.symbol(component.tagName))?.valueDeclaration, callable = declaration !== void 0 && isVariableDeclaration(declaration) ? declaration.initializer : declaration, parameter = callable !== void 0 && isFunctionLikeDeclaration(callable) ? callable.parameters[0] : void 0;
|
|
444
|
+
if (parameter === void 0)
|
|
445
|
+
return !1;
|
|
446
|
+
return await checker.getPropertyOfType(await checker.getTypeAtLocation(parameter), "autoComplete") !== void 0;
|
|
447
|
+
}, edits = [], artworkThemed = new Set, propsSpreads = new Set, openings = [
|
|
448
|
+
...nodesOfKind(source, SyntaxKind.JsxOpeningElement, isJsxOpeningElement),
|
|
449
|
+
...nodesOfKind(source, SyntaxKind.JsxSelfClosingElement, isJsxSelfClosingElement)
|
|
450
|
+
].sort((a, b) => a.pos - b.pos);
|
|
451
|
+
for (const opening of openings)
|
|
452
|
+
for (const attribute of opening.attributes.properties) {
|
|
453
|
+
if (isJsxSpreadAttribute(attribute)) {
|
|
454
|
+
if (!lowercaseTag(opening))
|
|
455
|
+
continue;
|
|
456
|
+
const spread = attribute.expression;
|
|
457
|
+
if (isCallExpression(spread) && isPropertyAccessExpression(spread.expression) && spread.expression.name.text === "props" && isPropertyAccessExpression(spread.expression.expression) && spread.expression.expression.name.text === "measured") {
|
|
458
|
+
propsSpreads.add(spread);
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
return fail(attribute, { kind: "spread-attribute" });
|
|
462
|
+
}
|
|
463
|
+
const attributeName = nameText(attribute.name);
|
|
464
|
+
if (attributeName === "style" || attributeName === "css")
|
|
465
|
+
return fail(attribute, { kind: "raw-style", attribute: attributeName });
|
|
466
|
+
}
|
|
467
|
+
async function markup(node, context, resolve) {
|
|
468
|
+
const opening = openingOf(node);
|
|
469
|
+
if (opening !== null)
|
|
470
|
+
return [opening];
|
|
471
|
+
if (isJsxFragment(node))
|
|
472
|
+
return (await Promise.all(node.children.map((child) => markup(child, context, resolve)))).flat();
|
|
473
|
+
if (isJsxExpression(node))
|
|
474
|
+
return node.expression === void 0 ? [] : markup(node.expression, context, resolve);
|
|
475
|
+
if (isParenthesizedExpression(node))
|
|
476
|
+
return markup(node.expression, context, resolve);
|
|
477
|
+
if (isConditionalExpression(node))
|
|
478
|
+
return markup(values.truthy(await resolve(node.condition, context), node.condition, context) ? node.whenTrue : node.whenFalse, context, resolve);
|
|
479
|
+
if (isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.AmpersandAmpersandToken)
|
|
480
|
+
return values.truthy(await resolve(node.left, context), node.left, context) ? markup(node.right, context, resolve) : [];
|
|
481
|
+
const mapped = mapCallback(node);
|
|
482
|
+
if (mapped !== null) {
|
|
483
|
+
const result = callbackResult(mapped);
|
|
484
|
+
return result === null ? fail(node, { kind: "helper-markup" }) : markup(result, context, resolve);
|
|
485
|
+
}
|
|
486
|
+
if (isCallExpression(node))
|
|
487
|
+
return fail(node, { kind: "helper-markup" });
|
|
488
|
+
return [];
|
|
489
|
+
}
|
|
490
|
+
const children = async (opening, context, resolve) => {
|
|
491
|
+
const element = elementOf(opening);
|
|
492
|
+
return isJsxElement(element) ? (await Promise.all(element.children.map((child) => markup(child, context, resolve)))).flat() : [];
|
|
493
|
+
};
|
|
494
|
+
function inlineSource(opening) {
|
|
495
|
+
const html = expression(attr(opening, "dangerouslySetInnerHTML")), [field] = html !== void 0 && isObjectLiteralExpression(html) && html.properties.length === 1 ? html.properties : [];
|
|
496
|
+
if (field === void 0 || !isPropertyAssignment(field) || nameText(field.name) !== "__html")
|
|
497
|
+
return fail(opening, { kind: "artwork-source-undeclared" });
|
|
498
|
+
return field.initializer;
|
|
499
|
+
}
|
|
500
|
+
async function intrinsicSource(opening, context, resolve) {
|
|
501
|
+
const images = await children(opening, context, resolve), [image] = images;
|
|
502
|
+
if (images.length !== 1 || image === void 0 || image.tagName.getText() !== "img")
|
|
503
|
+
return fail(opening, { kind: "intrinsic-image-count" });
|
|
504
|
+
const src = expression(attr(image, "src"));
|
|
505
|
+
if (src === void 0)
|
|
506
|
+
return fail(image, { kind: "intrinsic-src-missing" });
|
|
507
|
+
if (attr(image, "alt") === void 0)
|
|
508
|
+
return fail(image, { kind: "intrinsic-alt-missing" });
|
|
509
|
+
return src;
|
|
510
|
+
}
|
|
511
|
+
function split(value, node) {
|
|
512
|
+
const fragments = [], calls = [], markers = [], placement = [], bindings = [];
|
|
513
|
+
for (const item of classItems(value))
|
|
514
|
+
if (typeof item === "string")
|
|
515
|
+
markers.push(...item.split(/\s+/).filter(Boolean));
|
|
516
|
+
else if (item === void 0 || item === null || item === !1)
|
|
517
|
+
continue;
|
|
518
|
+
else if (typeof item === "object" && item.kind === "construction") {
|
|
519
|
+
fragments.push(item.handle.descriptor);
|
|
520
|
+
calls.push(item.handle.node);
|
|
521
|
+
} else if (typeof item === "object" && item.kind === "placement")
|
|
522
|
+
placement.push(item.expression);
|
|
523
|
+
else if (typeof item === "object" && item.kind === "asset-class")
|
|
524
|
+
bindings.push(item);
|
|
525
|
+
else
|
|
526
|
+
return fail(node, { kind: "class-expression-incomplete" });
|
|
527
|
+
if (placement.length > 1)
|
|
528
|
+
return fail(node, { kind: "placement-repeated" });
|
|
529
|
+
return { fragments, calls, markers, placement, bindings };
|
|
530
|
+
}
|
|
531
|
+
async function recipeHandle(node) {
|
|
532
|
+
let target = node;
|
|
533
|
+
while (isParenthesizedExpression(target))
|
|
534
|
+
target = target.expression;
|
|
535
|
+
if (values.macroCalls.has(target))
|
|
536
|
+
return !0;
|
|
537
|
+
if (!isIdentifier(target))
|
|
538
|
+
return !1;
|
|
539
|
+
const declaration = (await values.symbol(target))?.valueDeclaration, initializer = declaration !== void 0 && isVariableDeclaration(declaration) && declaration.getSourceFile() === source ? declaration.initializer : void 0;
|
|
540
|
+
return initializer !== void 0 && values.macroCalls.has(initializer);
|
|
541
|
+
}
|
|
542
|
+
const reviews = [];
|
|
543
|
+
function review(at, problem) {
|
|
544
|
+
const position = location(at);
|
|
545
|
+
if (reviews.some((item) => item.origin.position.line === position.line && item.origin.position.column === position.column && JSON.stringify(item.review) === JSON.stringify(problem)))
|
|
546
|
+
return;
|
|
547
|
+
reviews.push({ origin: { kind: "point", file: position.file, position: { line: position.line, column: position.column } }, review: problem });
|
|
548
|
+
}
|
|
549
|
+
let inspected = !1;
|
|
550
|
+
const descendants = (opening) => {
|
|
551
|
+
const element = elementOf(opening);
|
|
552
|
+
return openings.filter((other) => other !== opening && other.getStart() >= element.getStart() && other.end <= element.end);
|
|
553
|
+
}, FOCUSABLE_TAGS = ["a", "button", "input", "select", "textarea", "summary", "iframe"], focusable = (other) => FOCUSABLE_TAGS.includes(other.tagName.getText()) || attr(other, "tabIndex") !== void 0 || attr(other, "href") !== void 0;
|
|
554
|
+
async function textEntryElement(opening, partName, context, resolve) {
|
|
555
|
+
const expected = ['<input type="text|email|tel|url|password|search|number">', "<textarea>", "<select>"], tag = opening.tagName.getText();
|
|
556
|
+
if (tag === "textarea" || tag === "select")
|
|
557
|
+
return;
|
|
558
|
+
if (tag !== "input")
|
|
559
|
+
return fail(opening, { kind: "part-element-mismatch", part: partName, expected, actual: `<${tag}>` });
|
|
560
|
+
const type = attr(opening, "type"), value = type === void 0 ? "text" : await resolve(expression(type), context);
|
|
561
|
+
if (typeof value !== "string" || !TEXT_ENTRY_TYPES.has(value))
|
|
562
|
+
return fail(type ?? opening, { kind: "part-element-mismatch", part: partName, expected, actual: `<input type=${JSON.stringify(value ?? null)}>` });
|
|
563
|
+
}
|
|
564
|
+
async function nativeElement(opening, element, partName, parent, context, resolve) {
|
|
565
|
+
if (element === null)
|
|
566
|
+
return;
|
|
567
|
+
const tag = opening.tagName.getText(), tags = elementTags(element);
|
|
568
|
+
if (!tags.includes(tag))
|
|
569
|
+
return fail(opening, { kind: "part-element-mismatch", part: partName, expected: tags.map((expected) => `<${expected}>`), actual: `<${tag}>` });
|
|
570
|
+
switch (element.kind) {
|
|
571
|
+
case "input": {
|
|
572
|
+
const type = attr(opening, "type"), value = type === void 0 ? void 0 : await resolve(expression(type), context);
|
|
573
|
+
if (value !== element.type)
|
|
574
|
+
return fail(type ?? opening, { kind: "part-element-mismatch", part: partName, expected: [`<input type="${element.type}">`], actual: `<input type=${JSON.stringify(value ?? null)}>` });
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
case "summary": {
|
|
578
|
+
let host = parent === null ? elementOf(opening).parent : elementOf(parent);
|
|
579
|
+
while (host !== void 0 && !isJsxElement(host) && !isJsxSelfClosingElement(host) && (isJsxExpression(host) || isParenthesizedExpression(host) || isJsxFragment(host)))
|
|
580
|
+
host = host.parent;
|
|
581
|
+
if ((host === void 0 ? null : openingOf(host)?.tagName.getText() ?? null) !== "details")
|
|
582
|
+
return fail(opening, { kind: "summary-outside-details", part: partName });
|
|
583
|
+
if (element.marker === "none" && !descendants(opening).some((other) => !lowercaseTag(other) || other.tagName.getText() === "svg" || attr(other, "aria-hidden") !== void 0))
|
|
584
|
+
review(opening, { kind: "marker-none-unlabelled", part: partName });
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
case "iframe":
|
|
588
|
+
case "select":
|
|
589
|
+
case "table":
|
|
590
|
+
case "cell":
|
|
591
|
+
case "list":
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
async function pointerTransparent(opening, partName, context, resolve) {
|
|
596
|
+
if (focusable(opening) || attr(opening, "onClick") !== void 0)
|
|
597
|
+
return fail(opening, { kind: "pointer-transparent-interactive", part: partName });
|
|
598
|
+
const hidden = attr(opening, "aria-hidden");
|
|
599
|
+
if (!(hidden !== void 0 && (hidden.initializer === void 0 || [!0, "true"].includes(await resolve(expression(hidden), context)))) && descendants(opening).some((other) => !lowercaseTag(other) || focusable(other)))
|
|
600
|
+
return fail(opening, { kind: "pointer-transparent-interactive", part: partName });
|
|
601
|
+
}
|
|
602
|
+
async function pressedPairing(root, at, asset, state, context, resolve) {
|
|
603
|
+
const pressedAttribute = attr(root, "aria-pressed");
|
|
604
|
+
if (pressedAttribute === void 0 || !asset.states.includes("selected"))
|
|
605
|
+
return;
|
|
606
|
+
const value = expression(pressedAttribute);
|
|
607
|
+
if (value !== void 0 && finiteType(await checker.getTypeAtLocation(value)) === null)
|
|
608
|
+
return review(at, { kind: "pressed-state-unresolved", asset: asset.name, state });
|
|
609
|
+
const resolved = value === void 0 ? !0 : await resolve(value, context), pressed = resolved === !0 || resolved === "true" ? !0 : resolved === !1 || resolved === "false" ? !1 : null;
|
|
610
|
+
if (pressed === null) {
|
|
611
|
+
if (resolved !== void 0 && resolved !== "mixed")
|
|
612
|
+
review(at, { kind: "pressed-state-unresolved", asset: asset.name, state });
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
if (pressed !== (state === "selected"))
|
|
616
|
+
return fail(at, { kind: "pressed-state-mismatch", asset: asset.name, state, pressed });
|
|
617
|
+
}
|
|
618
|
+
function scrollReview(opening, partName, at) {
|
|
619
|
+
if (attr(opening, "tabIndex") !== void 0 || descendants(opening).some(focusable))
|
|
620
|
+
return;
|
|
621
|
+
review(at, { kind: "scroll-unreachable", part: partName });
|
|
622
|
+
}
|
|
623
|
+
async function enclosedByContainer(opening, context, resolve) {
|
|
624
|
+
const constructionOf = async (host) => {
|
|
625
|
+
const classAttribute = expression(attr(host, "className"));
|
|
626
|
+
if (classAttribute === void 0 || !lowercaseTag(host))
|
|
627
|
+
return null;
|
|
628
|
+
const classes = split(await resolve(classAttribute, context), classAttribute);
|
|
629
|
+
if (classes.fragments.length === 0)
|
|
630
|
+
return null;
|
|
631
|
+
const combined = combineRecipes(...classes.fragments), parsed = combined.kind === "ok" ? parseConstruction(combined.value.spec) : null;
|
|
632
|
+
return parsed?.kind === "ok" ? parsed.value : null;
|
|
633
|
+
};
|
|
634
|
+
let node = elementOf(opening), below = opening;
|
|
635
|
+
while (node.parent !== void 0) {
|
|
636
|
+
const parent = node.parent;
|
|
637
|
+
if (isFunctionLikeDeclaration(parent)) {
|
|
638
|
+
const call = parent.parent, mapped = call === void 0 ? null : mapCallback(call);
|
|
639
|
+
if (mapped === null || mapped.callback !== parent)
|
|
640
|
+
return !1;
|
|
641
|
+
node = mapped.call;
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
const host = isJsxElement(parent) ? openingOf(parent) : isJsxOpeningElement(parent) || isJsxSelfClosingElement(parent) ? parent : null;
|
|
645
|
+
if (host === null || host === below) {
|
|
646
|
+
node = parent;
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
const construction = await constructionOf(host);
|
|
650
|
+
if (construction?.kind === "region" && construction.frame?.container === !0)
|
|
651
|
+
return !0;
|
|
652
|
+
below = host;
|
|
653
|
+
node = parent;
|
|
654
|
+
}
|
|
655
|
+
return !1;
|
|
656
|
+
}
|
|
657
|
+
const touchDisabled = [], handovers = [];
|
|
658
|
+
let containerGrids = !1;
|
|
659
|
+
async function layerRoot(opening, layer, context, resolve) {
|
|
660
|
+
const tag = opening.tagName.getText(), named = attr(opening, "aria-label") !== void 0 || attr(opening, "aria-labelledby") !== void 0;
|
|
661
|
+
switch (layer.kind) {
|
|
662
|
+
case "modal-sheet": {
|
|
663
|
+
if (tag !== "dialog")
|
|
664
|
+
return fail(opening, { kind: "layer-element-mismatch", expected: "<dialog>", actual: `<${tag}>` });
|
|
665
|
+
const open = attr(opening, "open");
|
|
666
|
+
if (open !== void 0)
|
|
667
|
+
return fail(open, { kind: "layer-open-attribute" });
|
|
668
|
+
if (!named)
|
|
669
|
+
return fail(opening, { kind: "layer-name-missing", element: "dialog" });
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
case "anchored-popover":
|
|
673
|
+
case "measured-popover": {
|
|
674
|
+
const declared = attr(opening, "popover"), value = declared === void 0 ? void 0 : declared.initializer === void 0 ? "auto" : await resolve(expression(declared), context), state = value === "" ? "auto" : value;
|
|
675
|
+
if (state !== layer.popover)
|
|
676
|
+
return fail(declared ?? opening, { kind: "layer-element-mismatch", expected: `popover="${layer.popover}"`, actual: declared === void 0 ? `<${tag}> without popover` : `popover=${JSON.stringify(state)}` });
|
|
677
|
+
const role = attr(opening, "role");
|
|
678
|
+
if (role !== void 0 && await resolve(expression(role), context) === "dialog" && !named)
|
|
679
|
+
return fail(opening, { kind: "layer-name-missing", element: "popover dialog" });
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
async function rendered(opening, context, resolve) {
|
|
685
|
+
let node = elementOf(opening);
|
|
686
|
+
while (node.parent !== void 0) {
|
|
687
|
+
let parent = node.parent;
|
|
688
|
+
if (isFunctionLikeDeclaration(parent)) {
|
|
689
|
+
const call = parent.parent, mapped = call === void 0 ? null : mapCallback(call);
|
|
690
|
+
if (mapped === null || mapped.callback !== parent)
|
|
691
|
+
break;
|
|
692
|
+
node = mapped.call;
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
if (isLoop(parent))
|
|
696
|
+
return fail(parent, { kind: "loop-markup" });
|
|
697
|
+
if (isBinaryExpression(parent) && parent.operatorToken.kind === SyntaxKind.AmpersandAmpersandToken && node === parent.right && !values.truthy(await resolve(parent.left, context), parent.left, context))
|
|
698
|
+
return !1;
|
|
699
|
+
if (isConditionalExpression(parent) && node !== parent.condition && values.truthy(await resolve(parent.condition, context), parent.condition, context) !== (node === parent.whenTrue))
|
|
700
|
+
return !1;
|
|
701
|
+
if (isIfStatement(parent) && node !== parent.expression && values.truthy(await resolve(parent.expression, context), parent.expression, context) !== (node === parent.thenStatement))
|
|
702
|
+
return !1;
|
|
703
|
+
if (isBlock(parent)) {
|
|
704
|
+
for (const earlier of parent.statements.slice(0, parent.statements.indexOf(node)))
|
|
705
|
+
if (isIfStatement(earlier) && earlier.elseStatement === void 0 && alwaysReturns(earlier.thenStatement) && values.truthy(await resolve(earlier.expression, context), earlier.expression, context))
|
|
706
|
+
return !1;
|
|
707
|
+
}
|
|
708
|
+
node = parent;
|
|
709
|
+
}
|
|
710
|
+
return !0;
|
|
711
|
+
}
|
|
712
|
+
async function styledChoice(opening, node, classes, context, resolve) {
|
|
713
|
+
const combined = combineRecipes(...classes.fragments);
|
|
714
|
+
if (combined.kind === "err")
|
|
715
|
+
return fail(node, { kind: "recipe-rejected", rejection: combined.error });
|
|
716
|
+
const { spec } = combined.value, parsed = parseConstruction(spec);
|
|
717
|
+
if (parsed.kind === "err")
|
|
718
|
+
return fail(authoredAt(classes.calls, parsed.error.kind === "parts-unsupported" ? "recipe.parts" : parsed.error.path) ?? node, { kind: "spec", failure: parsed.error });
|
|
719
|
+
const defaults = recipeDefaults(foundation, parsed.value);
|
|
720
|
+
for (const { path: at, redundancy } of defaults.declarations)
|
|
721
|
+
restating(authoredAt(classes.calls, at), redundancy);
|
|
722
|
+
if (parsed.value.kind === "region" && parsed.value.layer !== null) {
|
|
723
|
+
await layerRoot(opening, parsed.value.layer, context, resolve);
|
|
724
|
+
if (parsed.value.layer.kind === "modal-sheet" && parsed.value.layer.modalBelow !== null)
|
|
725
|
+
handovers.push(node);
|
|
726
|
+
}
|
|
727
|
+
if (parsed.value.kind === "grid" && parsed.value.layout.some(([field, value]) => field === "context" && value === "container")) {
|
|
728
|
+
containerGrids = !0;
|
|
729
|
+
if (!await enclosedByContainer(opening, context, resolve))
|
|
730
|
+
return fail(node, { kind: "grid-container-missing" });
|
|
731
|
+
}
|
|
732
|
+
for (const use of interactionUses(parsed.value)) {
|
|
733
|
+
const at = authoredAt(classes.calls, use.path) ?? node;
|
|
734
|
+
if (use.property === "user-select" && use.value === "none" && use.text)
|
|
735
|
+
review(at, { kind: "user-select-text", element: use.element });
|
|
736
|
+
if (use.property === "touch-action" && use.value === "none")
|
|
737
|
+
touchDisabled.push({ at, element: use.element });
|
|
738
|
+
}
|
|
739
|
+
const construction = parsed.value, playing = construction.kind === "region" ? [["root", construction.plays]] : construction.kind === "control" ? [["root", construction.plays], ...construction.glyph === null ? [] : [[construction.glyph.name, construction.glyph.plays]]] : construction.kind === "artwork" ? [[construction.part.name, construction.part.plays]] : [];
|
|
740
|
+
for (const [part, plays] of playing)
|
|
741
|
+
for (const play of plays)
|
|
742
|
+
if (play.condition === null && (foundation.profiles.get(play.sequence)?.fields.repeat ?? "loop") !== "once")
|
|
743
|
+
review(authoredAt(classes.calls, play.path) ?? node, { kind: "motion-endless", part, sequence: play.sequence });
|
|
744
|
+
for (const { path, review: lurch } of pressScaleReviews(foundation, parsed.value))
|
|
745
|
+
review(authoredAt(classes.calls, path) ?? node, lurch);
|
|
746
|
+
for (const { path, failure } of formStateFailures(foundation, parsed.value))
|
|
747
|
+
return fail(authoredAt(classes.calls, path) ?? node, failure);
|
|
748
|
+
const writesInline = declaredMeasured(parsed.value).length > 0 || declaredPaints(parsed.value).length > 0;
|
|
749
|
+
for (const channel of ["measured", "paints"])
|
|
750
|
+
for (const [valueName, specPath] of runtimePaths(parsed.value, channel)) {
|
|
751
|
+
const key = runtimeKey(channel, valueName);
|
|
752
|
+
if (!declaredRuntime.has(key))
|
|
753
|
+
declaredRuntime.set(key, { channel, name: valueName, at: authoredAt(classes.calls, specPath) ?? node });
|
|
754
|
+
}
|
|
755
|
+
const childFacts = new Map, factsOf = async (parent) => {
|
|
756
|
+
const known = childFacts.get(parent);
|
|
757
|
+
if (known !== void 0)
|
|
758
|
+
return known;
|
|
759
|
+
const found = [];
|
|
760
|
+
for (const child of await children(parent, context, resolve)) {
|
|
761
|
+
const childClass = expression(attr(child, "className"));
|
|
762
|
+
found.push({
|
|
763
|
+
opening: child,
|
|
764
|
+
classes: childClass === void 0 ? NO_CLASSES : split(await resolve(childClass, context), childClass),
|
|
765
|
+
component: !lowercaseTag(child),
|
|
766
|
+
repeated: insideMap(elementOf(child), elementOf(parent))
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
childFacts.set(parent, found);
|
|
770
|
+
return found;
|
|
771
|
+
}, allFacts = await factsOf(opening);
|
|
772
|
+
let hasText = !1, visual;
|
|
773
|
+
const assetSources = [];
|
|
774
|
+
let drawings;
|
|
775
|
+
const hidden = attr(opening, "hidden") === void 0 ? [] : [{ kind: "root" }], guardChild = (fact, selector, within = []) => {
|
|
776
|
+
if (attr(fact.opening, "hidden") !== void 0 && fact.classes.fragments.length === 0)
|
|
777
|
+
hidden.push(within.length === 0 ? { kind: "part", selector } : { kind: "part", selector, within });
|
|
778
|
+
}, parts = declaredParts(parsed.value), declaredMarkers = new Set([...parts.map((part) => part.selector.slice(1)), ...declaredCells(parsed.value).map((cell) => cell.slice(1))]);
|
|
779
|
+
if (parsed.value.kind === "region") {
|
|
780
|
+
const region = parsed.value;
|
|
781
|
+
await nativeElement(opening, region.element, "&", null, context, resolve);
|
|
782
|
+
if (region.normalize.some(([property, value]) => property === "pointer-events" && value === "none"))
|
|
783
|
+
await pointerTransparent(opening, "&", context, resolve);
|
|
784
|
+
if (region.overflow.kind === "scroll")
|
|
785
|
+
scrollReview(opening, "&", node);
|
|
786
|
+
}
|
|
787
|
+
const matched = new Map([["", opening]]), tinted = new Set(parsed.value.kind === "region" ? surfacedElements(foundation, parsed.value).flatMap((element) => element.visual && (element.surface !== null || element.when.length > 0) ? [element.element] : []) : []), decorative = new Set;
|
|
788
|
+
let schemed = !1;
|
|
789
|
+
for (const part of parts) {
|
|
790
|
+
if (!/^\.[\w-]+$/.test(part.selector))
|
|
791
|
+
return fail(node, { kind: "part-selector-unresolved", part: part.name });
|
|
792
|
+
const parent = matched.get(part.within.join(" "));
|
|
793
|
+
if (parent === void 0)
|
|
794
|
+
continue;
|
|
795
|
+
const candidates = (await factsOf(parent)).filter((fact) => !fact.component);
|
|
796
|
+
for (const fact of candidates) {
|
|
797
|
+
const shared = fact.classes.markers.filter((marker) => declaredMarkers.has(marker));
|
|
798
|
+
if (shared.length > 1)
|
|
799
|
+
return fail(fact.opening, { kind: "markers-shared", markers: shared });
|
|
800
|
+
}
|
|
801
|
+
const matches = candidates.filter((fact) => fact.classes.markers.includes(part.selector.slice(1))), [match] = matches;
|
|
802
|
+
if (part.kind === "vector") {
|
|
803
|
+
if (part.required && match === void 0)
|
|
804
|
+
return fail(node, { kind: "part-missing-or-repeated", part: part.name });
|
|
805
|
+
for (const shape of matches) {
|
|
806
|
+
const tag = shape.opening.tagName.getText(), host = parent.tagName.getText();
|
|
807
|
+
if (!VECTOR_SHAPES.includes(tag) || host !== "svg")
|
|
808
|
+
return fail(shape.opening, { kind: "part-element-mismatch", part: part.name, expected: VECTOR_SHAPES.map((shapeTag) => `<svg> > <${shapeTag}>`), actual: `<${host}> > <${tag}>` });
|
|
809
|
+
}
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
if (matches.length > 1 || match?.repeated === !0 || part.required && match === void 0)
|
|
813
|
+
return fail(node, { kind: "part-missing-or-repeated", part: part.name });
|
|
814
|
+
if (match === void 0)
|
|
815
|
+
continue;
|
|
816
|
+
matched.set([...part.within, part.selector].join(" "), match.opening);
|
|
817
|
+
const ariaHidden = attr(match.opening, "aria-hidden");
|
|
818
|
+
if (tinted.has(part.name) && ariaHidden !== void 0 && (ariaHidden.initializer === void 0 || [!0, "true"].includes(await resolve(expression(ariaHidden), context))))
|
|
819
|
+
decorative.add(part.name);
|
|
820
|
+
const element = match.opening.tagName.getText(), hostless = part.pseudo.find((pseudo) => !PSEUDO_HOSTS[pseudo].includes(element));
|
|
821
|
+
if (hostless !== void 0)
|
|
822
|
+
return fail(match.opening, { kind: "pseudo-host-unsupported", part: part.name, pseudo: hostless, element });
|
|
823
|
+
await nativeElement(match.opening, part.element, part.name, parent, context, resolve);
|
|
824
|
+
if (part.declaresBoundary)
|
|
825
|
+
await textEntryElement(match.opening, part.name, context, resolve);
|
|
826
|
+
const normalized = parsed.value.kind === "region" ? parsed.value.normalizeWhen.find(([selector]) => selector === `& > ${part.selector}`) : void 0;
|
|
827
|
+
if (part.within.length === 0 && normalized?.[1].some(([property, value]) => property === "pointer-events" && value === "none"))
|
|
828
|
+
await pointerTransparent(match.opening, part.name, context, resolve);
|
|
829
|
+
if (part.resizes && element !== "textarea")
|
|
830
|
+
return fail(authoredAt(classes.calls, `${part.path}.normalize.resize`) ?? match.opening, { kind: "resize-not-textarea", part: part.name, element });
|
|
831
|
+
if (part.scrolls)
|
|
832
|
+
scrollReview(match.opening, part.name, node);
|
|
833
|
+
if (part.truncated && attr(match.opening, "title") === void 0)
|
|
834
|
+
review(node, { kind: "truncated-text-unnamed", part: part.name });
|
|
835
|
+
if (part.balanced && element === "p")
|
|
836
|
+
review(authoredAt(classes.calls, `${part.path}.wrap`) ?? node, { kind: "balance-on-paragraph", part: part.name });
|
|
837
|
+
for (const sequence of part.playsAlways)
|
|
838
|
+
if ((foundation.profiles.get(sequence)?.fields.repeat ?? "loop") !== "once")
|
|
839
|
+
review(authoredAt(classes.calls, `${part.path}.play`) ?? node, { kind: "motion-endless", part: part.name, sequence });
|
|
840
|
+
if (part.clamped) {
|
|
841
|
+
const enclosing = part.within.map((_, index) => matched.get(part.within.slice(0, index + 1).join(" "))), control = [match.opening, ...enclosing.reverse(), opening].find((element) => element !== void 0 && CONTROL_TEXT_TAGS.includes(element.tagName.getText()));
|
|
842
|
+
if (control !== void 0)
|
|
843
|
+
return fail(match.opening, { kind: "clamp-on-control", part: part.name, element: `<${control.tagName.getText()}>` });
|
|
844
|
+
}
|
|
845
|
+
guardChild(match, part.selector, part.within);
|
|
846
|
+
if (part.kind === "text")
|
|
847
|
+
hasText = !0;
|
|
848
|
+
if (part.kind !== "visual")
|
|
849
|
+
continue;
|
|
850
|
+
if (part.scheme !== null) {
|
|
851
|
+
if (element !== "img" || match.classes.bindings.length > 0)
|
|
852
|
+
return fail(match.opening, { kind: "scheme-image-element", part: part.name, element });
|
|
853
|
+
for (const attribute of ["width", "height"])
|
|
854
|
+
if (attr(match.opening, attribute) === void 0)
|
|
855
|
+
return fail(match.opening, { kind: "scheme-image-size-missing", part: part.name, attribute });
|
|
856
|
+
const defaultScheme = themes[0]?.scheme ?? "light";
|
|
857
|
+
if (part.scheme !== defaultScheme) {
|
|
858
|
+
const loading = attr(match.opening, "loading");
|
|
859
|
+
if (loading === void 0 || await resolve(expression(loading), context) !== "lazy")
|
|
860
|
+
return fail(loading ?? match.opening, { kind: "scheme-image-not-lazy", part: part.name, scheme: part.scheme, defaultScheme });
|
|
861
|
+
}
|
|
862
|
+
if (visual !== void 0 && !schemed)
|
|
863
|
+
return fail(match.opening, { kind: "visual-binding-count" });
|
|
864
|
+
schemed = !0;
|
|
865
|
+
visual = { kind: "content-media" };
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
868
|
+
if (visual !== void 0)
|
|
869
|
+
return fail(match.opening, { kind: "visual-binding-count" });
|
|
870
|
+
if (part.media === "inspected-svg") {
|
|
871
|
+
if (match.classes.bindings.length > 0)
|
|
872
|
+
return fail(match.opening, { kind: "visual-binding-count" });
|
|
873
|
+
const html = attr(match.opening, "dangerouslySetInnerHTML");
|
|
874
|
+
if (html !== void 0)
|
|
875
|
+
return fail(html, { kind: "inspected-svg-inline", part: part.name });
|
|
876
|
+
if ((await children(match.opening, context, resolve)).length > 0 || isJsxElement(elementOf(match.opening)) && elementOf(match.opening).children.some((child) => !isJsxText(child) || child.text.trim() !== ""))
|
|
877
|
+
return fail(match.opening, { kind: "inspected-svg-inline", part: part.name });
|
|
878
|
+
inspected = !0;
|
|
879
|
+
visual = { kind: "inspected-svg" };
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
if (match.classes.bindings.length === 0 && parsed.value.kind === "region" && match.opening.tagName.getText() === "img") {
|
|
883
|
+
visual = { kind: "content-media" };
|
|
884
|
+
continue;
|
|
885
|
+
}
|
|
886
|
+
const [binding] = match.classes.bindings, declared = binding === void 0 ? null : visualBinding(binding.part);
|
|
887
|
+
if (match.classes.bindings.length !== 1 || binding === void 0 || declared === null)
|
|
888
|
+
return fail(match.opening, { kind: "visual-binding-count" });
|
|
889
|
+
const restatedVisual = declared.visual === null ? null : visualBindingRedundancy(foundation, parsed.value, declared.visual);
|
|
890
|
+
if (restatedVisual !== null)
|
|
891
|
+
restating(authoredAt([binding.handle.node], `recipe.parts.${binding.name}.visual`), restatedVisual.redundancy);
|
|
892
|
+
const themeName = binding.handle.descriptor.spec.theme ?? "light", theme = themes.find((item) => item.name === themeName);
|
|
893
|
+
if (theme === void 0)
|
|
894
|
+
return fail(match.opening, { kind: "theme-unknown", theme: String(themeName) });
|
|
895
|
+
const bindingSource = async (target) => {
|
|
896
|
+
const selected = await resolve(target, context);
|
|
897
|
+
if (typeof selected !== "object" || selected === null || selected.kind !== "asset-source" || selected.handle.node !== binding.handle.node || selected.name !== binding.name)
|
|
898
|
+
return fail(target, { kind: "artwork-mismatch" });
|
|
899
|
+
};
|
|
900
|
+
switch (declared.kind) {
|
|
901
|
+
case "asset": {
|
|
902
|
+
const asset = resolveAsset(assets, declared.asset);
|
|
903
|
+
if (asset === void 0)
|
|
904
|
+
return fail(match.opening, { kind: "asset-unknown", asset: declared.asset });
|
|
905
|
+
visual = { kind: "asset", asset, state: declared.state, visualProfile: declared.visual, theme };
|
|
906
|
+
drawings = asset.name;
|
|
907
|
+
boundAssets.add(asset.name);
|
|
908
|
+
const target = asset.paint === "intrinsic" ? await intrinsicSource(match.opening, context, resolve) : inlineSource(match.opening);
|
|
909
|
+
await bindingSource(target);
|
|
910
|
+
await pressedPairing(opening, binding.handle.node, asset, declared.state, context, resolve);
|
|
911
|
+
assetSources.push({ kind: "drawing", target });
|
|
912
|
+
break;
|
|
913
|
+
}
|
|
914
|
+
case "set": {
|
|
915
|
+
const set = assets.sets.get(declared.set), representative = set === void 0 ? void 0 : assets.records.get(set.members[0] ?? "");
|
|
916
|
+
if (set === void 0 || representative === void 0)
|
|
917
|
+
return fail(match.opening, { kind: "glyph-set-unknown", set: declared.set });
|
|
918
|
+
const stateless = set.members.find((member) => !(assets.records.get(member)?.states.includes(declared.state) ?? !1));
|
|
919
|
+
if (stateless !== void 0)
|
|
920
|
+
return fail(match.opening, { kind: "glyph-set-state", set: set.name, state: declared.state, member: stateless });
|
|
921
|
+
const { lookup, key } = setLookupForm(inlineSource(match.opening), fail);
|
|
922
|
+
await bindingSource(lookup);
|
|
923
|
+
await pressedPairing(opening, binding.handle.node, representative, declared.state, context, resolve);
|
|
924
|
+
await checkSetKey(checker, set, key, fail);
|
|
925
|
+
visual = { kind: "asset", asset: representative, state: declared.state, visualProfile: declared.visual, theme };
|
|
926
|
+
drawings = drawingsIdentity(representative);
|
|
927
|
+
boundSets.add(set.name);
|
|
928
|
+
assetSources.push({ kind: "lookup", target: lookup, set, state: declared.state });
|
|
929
|
+
break;
|
|
930
|
+
}
|
|
931
|
+
case "reference": {
|
|
932
|
+
const glyph = referenceForm(inlineSource(match.opening), fail), [representative] = await receivable(glyph);
|
|
933
|
+
visual = { kind: "asset", asset: representative, state: "normal", visualProfile: declared.visual, theme };
|
|
934
|
+
drawings = drawingsIdentity(representative);
|
|
935
|
+
references.add(glyph);
|
|
936
|
+
break;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
for (const fact of allFacts) {
|
|
941
|
+
const shared = fact.classes.markers.filter((marker) => declaredMarkers.has(marker));
|
|
942
|
+
if (shared.length > 1)
|
|
943
|
+
return fail(fact.opening, { kind: "markers-shared", markers: shared });
|
|
944
|
+
}
|
|
945
|
+
if (parsed.value.kind === "control" && !hasText && visual !== void 0 && !await namedByAttribute(opening, async (condition) => values.truthy(await resolve(condition, context), condition, context)))
|
|
946
|
+
return fail(opening, { kind: "control-name-missing", element: opening.tagName.getText() });
|
|
947
|
+
const theme = visual?.kind === "asset" ? visual.theme : void 0, rootTheme = attr(opening, "data-theme");
|
|
948
|
+
if (rootTheme !== void 0 && theme !== void 0 && await resolve(expression(rootTheme), context) !== theme.name)
|
|
949
|
+
return fail(rootTheme, { kind: "data-theme-mismatch", expected: theme.name });
|
|
950
|
+
if (theme !== void 0)
|
|
951
|
+
artworkThemed.add(opening);
|
|
952
|
+
const inherited = new Map, aligned = new Map;
|
|
953
|
+
for (const selector of declaredCells(parsed.value)) {
|
|
954
|
+
const cells = allFacts.filter((fact) => fact.classes.markers.includes(selector.slice(1))), [cell] = cells, single = cells.length === 1 && cell?.repeated === !1;
|
|
955
|
+
if (!/^\.[\w-]+$/.test(selector) || cell === void 0 || !single && !autoPlaced(parsed.value, selector))
|
|
956
|
+
return fail(node, { kind: "cell-missing-or-repeated", cell: selector });
|
|
957
|
+
for (const each of cells)
|
|
958
|
+
guardChild(each, selector);
|
|
959
|
+
if (cell.classes.fragments.length === 0)
|
|
960
|
+
continue;
|
|
961
|
+
const cellSpec = combineRecipes(...cell.classes.fragments);
|
|
962
|
+
if (cellSpec.kind === "err")
|
|
963
|
+
continue;
|
|
964
|
+
const nested = parseConstruction(cellSpec.value.spec);
|
|
965
|
+
if (nested.kind === "ok" && nested.value.kind === "region" && nested.value.layer !== null)
|
|
966
|
+
return fail(cell.opening, { kind: "layer-in-grid-cell", cell: selector });
|
|
967
|
+
if (nested.kind === "ok" && nested.value.kind === "grid" && nested.value.mode === "inherited")
|
|
968
|
+
inherited.set(selector, nested.value);
|
|
969
|
+
}
|
|
970
|
+
if (parsed.value.kind === "grid")
|
|
971
|
+
for (const [selector, rows] of parsed.value.alignRows) {
|
|
972
|
+
const cell = allFacts.find((fact) => fact.classes.markers.includes(selector.slice(1))), exposed = cell?.component ? await publicRowsOf(cell.opening) : null;
|
|
973
|
+
if (exposed === null || exposed.rows.join(" ") !== rows.join(" "))
|
|
974
|
+
return fail(node, { kind: "align-rows-mismatch", cell: selector, expected: rows, exposed: exposed?.rows ?? null });
|
|
975
|
+
aligned.set(selector, exposed.gap);
|
|
976
|
+
}
|
|
977
|
+
const state = visual?.kind === "asset" ? visual.state : void 0, visualProfile = visual?.kind === "asset" ? visual.visualProfile ?? void 0 : void 0, identity = [
|
|
978
|
+
spec,
|
|
979
|
+
hasText,
|
|
980
|
+
drawings,
|
|
981
|
+
state,
|
|
982
|
+
...visualProfile === void 0 ? [] : [visualProfile],
|
|
983
|
+
...theme !== void 0 && theme.name !== "light" ? [theme.name] : [],
|
|
984
|
+
...visual?.kind === "content-media" || visual?.kind === "inspected-svg" ? [visual.kind] : [],
|
|
985
|
+
...inherited.size > 0 ? [[...inherited].map(([selector, nested]) => [selector, nested.source])] : [],
|
|
986
|
+
...aligned.size > 0 ? [[...aligned]] : [],
|
|
987
|
+
...writesInline ? [scope] : [],
|
|
988
|
+
...decorative.size > 0 ? [["decorative", ...decorative]] : []
|
|
989
|
+
], paintedBy = (element) => parsed.value.kind === "control" ? hasText ? "text" : "graphic" : element.visual ? decorative.has(element.element) ? "decorative" : "graphic" : "text", key = constructionId(digest(hidden.length > 0 ? [...identity, hidden] : identity));
|
|
990
|
+
let owned = styles.get(key);
|
|
991
|
+
if (owned === void 0) {
|
|
992
|
+
if (styles.size >= choiceLimits.alternatives)
|
|
993
|
+
return fail(node, { kind: "choice", problem: { kind: "construction-limit" } });
|
|
994
|
+
const lowered = lower(parsed.value, foundation, `owner_${key.slice(0, 16)}`, { visual: visual ?? null, hasText, hidden, inherited, aligned, scope });
|
|
995
|
+
if (lowered.kind === "err")
|
|
996
|
+
return fail(node, { kind: "construction", failure: lowered.error });
|
|
997
|
+
const misused = inactiveSurfaceActive(foundation, parsed.value);
|
|
998
|
+
if (misused !== null)
|
|
999
|
+
return fail(node, { kind: "construction", failure: misused });
|
|
1000
|
+
const contrast = stateContrast(foundation, parsed.value, paintedBy);
|
|
1001
|
+
if (contrast.kind === "err")
|
|
1002
|
+
return fail(node, { kind: "construction", failure: contrast.error });
|
|
1003
|
+
for (const unresolved of contrast.value)
|
|
1004
|
+
review(node, unresolved);
|
|
1005
|
+
const nonText = nonTextContrast(foundation, parsed.value);
|
|
1006
|
+
if (nonText.kind === "err")
|
|
1007
|
+
return fail(node, { kind: "construction", failure: nonText.error });
|
|
1008
|
+
for (const unresolved of nonText.value)
|
|
1009
|
+
review(node, unresolved);
|
|
1010
|
+
const overpaint = cornerOverpaint(foundation, parsed.value);
|
|
1011
|
+
if (overpaint !== null)
|
|
1012
|
+
return fail(authoredAt(classes.calls, `recipe.parts.${overpaint.part}`) ?? node, { kind: "construction", failure: overpaint });
|
|
1013
|
+
const painted = runtimePaintContrast(foundation, parsed.value);
|
|
1014
|
+
if (painted.kind === "err")
|
|
1015
|
+
return fail(node, { kind: "construction", failure: painted.error });
|
|
1016
|
+
for (const unresolved of painted.value)
|
|
1017
|
+
review(node, unresolved);
|
|
1018
|
+
owned = { ...lowered.value, origins: [], surfaceUses: surfaceUses(foundation, parsed.value, lowered.value.profiles, paintedBy) };
|
|
1019
|
+
styles.set(key, owned);
|
|
1020
|
+
}
|
|
1021
|
+
if (owned.facts.kind === "region" && owned.facts.exposed !== null)
|
|
1022
|
+
exposedRows.set(JSON.stringify(owned.facts.exposed), owned.facts.exposed);
|
|
1023
|
+
if (parsed.value.kind === "grid" && owned.facts.kind === "grid" && parsed.value.mode !== "inherited") {
|
|
1024
|
+
const regions = owned.facts.regions, keyline = owned.facts.keyline, tiles = parsed.value.mode === "fixed", moved = new Set(parsed.value.conditions.flatMap((condition) => condition.cells.map(([selector]) => selector))), constructionOf = async (host) => {
|
|
1025
|
+
const classAttribute = expression(attr(host, "className"));
|
|
1026
|
+
if (classAttribute === void 0)
|
|
1027
|
+
return null;
|
|
1028
|
+
const classes = split(await resolve(classAttribute, context), classAttribute);
|
|
1029
|
+
if (classes.fragments.length === 0)
|
|
1030
|
+
return null;
|
|
1031
|
+
const combined = combineRecipes(...classes.fragments), spec = combined.kind === "ok" ? parseConstruction(combined.value.spec) : null;
|
|
1032
|
+
return spec?.kind === "ok" ? spec.value : null;
|
|
1033
|
+
}, report = (finding, host) => {
|
|
1034
|
+
const at = expression(attr(host, "className")) ?? host;
|
|
1035
|
+
if (finding?.kind === "frame-exceeds-region")
|
|
1036
|
+
return fail(at, finding);
|
|
1037
|
+
if (finding?.kind === "frame-region-unresolved")
|
|
1038
|
+
review(at, finding);
|
|
1039
|
+
}, aligned = (place, spec, host) => {
|
|
1040
|
+
if (keyline === null || spec === null)
|
|
1041
|
+
return;
|
|
1042
|
+
const missed = keylineFinding(foundation, place, spec, keyline);
|
|
1043
|
+
if (missed !== null)
|
|
1044
|
+
fail(expression(attr(host, "className")) ?? host, missed);
|
|
1045
|
+
}, check = (place, spec, component) => tiles ? tileFrameFinding(foundation, place, spec, component, regions) : component !== null ? componentCellFinding(foundation, place.cell, component, regions) : spec === null ? null : frameRegionFinding(foundation, place, spec, regions, moved), inside = async (cell, host, path) => {
|
|
1046
|
+
for (const child of await children(host, context, resolve)) {
|
|
1047
|
+
const step = lowercaseTag(child) ? { kind: "element", tag: child.tagName.getText(), spec: await constructionOf(child) } : { kind: "component", name: child.tagName.getText() };
|
|
1048
|
+
if (step.kind === "element") {
|
|
1049
|
+
if (step.spec?.kind === "grid")
|
|
1050
|
+
continue;
|
|
1051
|
+
if (step.spec !== null)
|
|
1052
|
+
report(check({ cell, element: `<${step.tag}>`, path }, step.spec, null), child);
|
|
1053
|
+
aligned({ cell, element: `<${step.tag}>`, path }, step.spec, child);
|
|
1054
|
+
}
|
|
1055
|
+
await inside(cell, child, [...path, step]);
|
|
1056
|
+
}
|
|
1057
|
+
}, visit = async (cell, opening) => {
|
|
1058
|
+
if (!lowercaseTag(opening)) {
|
|
1059
|
+
report(check({ cell, element: null, path: [] }, null, opening.tagName.getText()), opening);
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
const own = await constructionOf(opening);
|
|
1063
|
+
report(check({ cell, element: null, path: [] }, own, null), opening);
|
|
1064
|
+
aligned({ cell, element: null, path: [] }, own, opening);
|
|
1065
|
+
if (own?.kind !== "grid")
|
|
1066
|
+
return inside(cell, opening, [{ kind: "element", tag: opening.tagName.getText(), spec: own }]);
|
|
1067
|
+
if (own.mode !== "inherited")
|
|
1068
|
+
return;
|
|
1069
|
+
for (const child of await children(opening, context, resolve)) {
|
|
1070
|
+
const classAttribute = expression(attr(child, "className")), markers = classAttribute === void 0 ? [] : split(await resolve(classAttribute, context), classAttribute).markers;
|
|
1071
|
+
for (const inner of own.cells)
|
|
1072
|
+
if (markers.includes(inner.selector.slice(1)))
|
|
1073
|
+
await visit(inner.selector, child);
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
if (tiles)
|
|
1077
|
+
for (const fact of allFacts)
|
|
1078
|
+
await visit(`a tile <${fact.opening.tagName.getText()}>`, fact.opening);
|
|
1079
|
+
else
|
|
1080
|
+
for (const selector of declaredCells(parsed.value))
|
|
1081
|
+
for (const fact of allFacts.filter((item) => item.classes.markers.includes(selector.slice(1))))
|
|
1082
|
+
await visit(selector, fact.opening);
|
|
1083
|
+
}
|
|
1084
|
+
const at = location(node);
|
|
1085
|
+
if (!owned.origins.some((origin) => origin.kind === "point" && origin.position.line === at.line && origin.position.column === at.column))
|
|
1086
|
+
owned.origins.push({ kind: "point", file: name, position: { line: at.line, column: at.column } });
|
|
1087
|
+
const lowered = owned, code = (pending) => {
|
|
1088
|
+
switch (pending.kind) {
|
|
1089
|
+
case "drawing":
|
|
1090
|
+
return JSON.stringify(artworkSource(lowered));
|
|
1091
|
+
case "lookup": {
|
|
1092
|
+
const drawing = placedArtwork(lowered)?.drawing;
|
|
1093
|
+
if (drawing === void 0 || theme === void 0)
|
|
1094
|
+
throw Error("A set binding's construction placed no artwork.");
|
|
1095
|
+
return setLookupCode(assets, pending.set, parsed.value.kind === "control" ? LIGHT : theme, drawing, pending.state);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
return { kind: "styled", markers: classes.markers, placement: classes.placement[0] ?? null, style: key, assetSources: assetSources.map((pending) => ({ target: pending.target, code: code(pending) })) };
|
|
1100
|
+
}
|
|
1101
|
+
for (const opening of openings) {
|
|
1102
|
+
const attribute = attr(opening, "className");
|
|
1103
|
+
if (attribute === void 0 || lowercaseTag(opening))
|
|
1104
|
+
continue;
|
|
1105
|
+
const node = expression(attribute);
|
|
1106
|
+
if (node === void 0)
|
|
1107
|
+
return fail(attribute, { kind: "class-expression-incomplete" });
|
|
1108
|
+
await values.choices(node, async (context, resolve) => {
|
|
1109
|
+
const classes = split(await resolve(node, context), node);
|
|
1110
|
+
if (classes.fragments.length > 0 || classes.bindings.length > 0 || classes.placement.length > 0)
|
|
1111
|
+
return fail(attribute, { kind: "foreign-interior" });
|
|
1112
|
+
return null;
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
for (const opening of openings) {
|
|
1116
|
+
const attribute = attr(opening, "className");
|
|
1117
|
+
if (attribute === void 0)
|
|
1118
|
+
continue;
|
|
1119
|
+
if (!lowercaseTag(opening))
|
|
1120
|
+
continue;
|
|
1121
|
+
const node = expression(attribute);
|
|
1122
|
+
if (node === void 0)
|
|
1123
|
+
return fail(attribute, { kind: "class-expression-incomplete" });
|
|
1124
|
+
const result = await values.choices(node, async (context, resolve) => {
|
|
1125
|
+
if (!await rendered(opening, context, resolve))
|
|
1126
|
+
return { kind: "absent" };
|
|
1127
|
+
const classes = split(await resolve(node, context), node);
|
|
1128
|
+
if (classes.fragments.length > 0)
|
|
1129
|
+
return styledChoice(opening, node, classes, context, resolve);
|
|
1130
|
+
if (classes.placement.length > 0)
|
|
1131
|
+
return fail(node, { kind: "placement-without-root" });
|
|
1132
|
+
return { kind: "unstyled", markers: classes.markers };
|
|
1133
|
+
});
|
|
1134
|
+
selections.push({ opening, node, result });
|
|
1135
|
+
}
|
|
1136
|
+
const [handover] = handovers;
|
|
1137
|
+
if (containerGrids && handover !== void 0)
|
|
1138
|
+
return fail(handover, { kind: "layer-modal-context", context: "container" });
|
|
1139
|
+
for (const access of nodesOfKind(source, SyntaxKind.PropertyAccessExpression, isPropertyAccessExpression)) {
|
|
1140
|
+
if (access.name.text !== "modalQuery" || !await recipeHandle(access.expression))
|
|
1141
|
+
continue;
|
|
1142
|
+
const handles = await values.choices(access.expression, (context, resolve) => resolve(access.expression, context)), queries = new Set;
|
|
1143
|
+
for (const leaf of handles.leaves) {
|
|
1144
|
+
const handle = leaf.value, parsed = typeof handle === "object" && handle !== null && handle.kind === "recipe" ? parseConstruction(handle.descriptor.spec) : null, sheet = parsed?.kind === "ok" && parsed.value.kind === "region" ? parsed.value : null, query = sheet === null ? null : regionModalQuery(sheet, foundation);
|
|
1145
|
+
if (query?.kind === "err")
|
|
1146
|
+
return fail(access, { kind: "construction", failure: query.error });
|
|
1147
|
+
if (query === null || query.value === null)
|
|
1148
|
+
return fail(access, { kind: "choice", problem: { kind: "recipe-access-unsupported", key: "modalQuery" } });
|
|
1149
|
+
queries.add(query.value);
|
|
1150
|
+
}
|
|
1151
|
+
const [query] = queries;
|
|
1152
|
+
if (queries.size !== 1 || query === void 0)
|
|
1153
|
+
return fail(access, { kind: "choice", problem: { kind: "recipe-access-unsupported", key: "modalQuery" } });
|
|
1154
|
+
edits.push({ node: access, text: JSON.stringify(query) });
|
|
1155
|
+
}
|
|
1156
|
+
for (const access of nodesOfKind(source, SyntaxKind.PropertyAccessExpression, isPropertyAccessExpression)) {
|
|
1157
|
+
if (access.name.text !== "conditionQuery" || !await recipeHandle(access.expression))
|
|
1158
|
+
continue;
|
|
1159
|
+
const read = access.parent, key = read !== void 0 && isElementAccessExpression(read) && read.expression === access && isStringLiteral(read.argumentExpression) ? read.argumentExpression.text : read !== void 0 && isPropertyAccessExpression(read) && read.expression === access ? read.name.text : null;
|
|
1160
|
+
if (key === null || read === void 0)
|
|
1161
|
+
return fail(access, { kind: "choice", problem: { kind: "recipe-access-unsupported", key: "conditionQuery" } });
|
|
1162
|
+
const handles = await values.choices(access.expression, (context, resolve) => resolve(access.expression, context)), queries = new Set;
|
|
1163
|
+
for (const leaf of handles.leaves) {
|
|
1164
|
+
const handle = leaf.value, parsed = typeof handle === "object" && handle !== null && handle.kind === "recipe" ? parseConstruction(handle.descriptor.spec) : null, region = parsed?.kind === "ok" && parsed.value.kind === "region" ? parsed.value : null, query = region === null ? null : regionConditionQuery(region, key, foundation);
|
|
1165
|
+
if (query?.kind === "err")
|
|
1166
|
+
return fail(read, { kind: "construction", failure: query.error });
|
|
1167
|
+
if (query === null || query.value === null)
|
|
1168
|
+
return fail(read, { kind: "choice", problem: { kind: "recipe-access-unsupported", key: `conditionQuery.${key}` } });
|
|
1169
|
+
queries.add(query.value);
|
|
1170
|
+
}
|
|
1171
|
+
const [query] = queries;
|
|
1172
|
+
if (queries.size !== 1 || query === void 0)
|
|
1173
|
+
return fail(read, { kind: "choice", problem: { kind: "recipe-access-unsupported", key: `conditionQuery.${key}` } });
|
|
1174
|
+
edits.push({ node: read, text: JSON.stringify(query) });
|
|
1175
|
+
}
|
|
1176
|
+
const setNames = new Set;
|
|
1177
|
+
for (const access of nodesOfKind(source, SyntaxKind.PropertyAccessExpression, isPropertyAccessExpression)) {
|
|
1178
|
+
const channel = runtimeChannel(access.name.text);
|
|
1179
|
+
if (channel === null || !await recipeHandle(access.expression))
|
|
1180
|
+
continue;
|
|
1181
|
+
const unsupported = (at, key) => fail(at, { kind: "choice", problem: { kind: "recipe-access-unsupported", key } }), member = access.parent, call = member?.parent;
|
|
1182
|
+
if (member === void 0 || !isPropertyAccessExpression(member) || member.expression !== access || call === void 0 || !isCallExpression(call) || call.expression !== member)
|
|
1183
|
+
return unsupported(access, channel);
|
|
1184
|
+
const method = member.name.text, spread = method === "props" && channel === "measured";
|
|
1185
|
+
if (method !== "set" && method !== "clear" && !spread)
|
|
1186
|
+
return unsupported(member, `${channel}.${method}`);
|
|
1187
|
+
if (spread && (call.parent === void 0 || !isJsxSpreadAttribute(call.parent)))
|
|
1188
|
+
return unsupported(call, `${channel}.props`);
|
|
1189
|
+
propsSpreads.delete(call);
|
|
1190
|
+
const handles = await values.choices(access.expression, (context, resolve) => resolve(access.expression, context)), declarations = new Set;
|
|
1191
|
+
let declared = null;
|
|
1192
|
+
for (const leaf of handles.leaves) {
|
|
1193
|
+
const handle = leaf.value, parsed = typeof handle === "object" && handle !== null && handle.kind === "recipe" ? parseConstruction(handle.descriptor.spec) : null;
|
|
1194
|
+
if (parsed === null)
|
|
1195
|
+
return unsupported(access, channel);
|
|
1196
|
+
if (parsed.kind === "err")
|
|
1197
|
+
return fail(access, { kind: "spec", failure: parsed.error });
|
|
1198
|
+
declared = runtimeDeclarations(parsed.value, channel);
|
|
1199
|
+
declarations.add(JSON.stringify(declared));
|
|
1200
|
+
}
|
|
1201
|
+
if (declarations.size !== 1 || declared === null)
|
|
1202
|
+
return unsupported(access, channel);
|
|
1203
|
+
const names = runtimeNames(declared);
|
|
1204
|
+
if (names.length === 0)
|
|
1205
|
+
return fail(access, undeclared(channel, null));
|
|
1206
|
+
if (method === "set" || spread) {
|
|
1207
|
+
const written = call.arguments[spread ? 0 : 1];
|
|
1208
|
+
if (call.arguments.length !== (spread ? 1 : 2) || written === void 0 || !isObjectLiteralExpression(written))
|
|
1209
|
+
return unsupported(call, `${channel}.${method}`);
|
|
1210
|
+
for (const property of written.properties) {
|
|
1211
|
+
if (!isPropertyAssignment(property) && !isShorthandPropertyAssignment(property))
|
|
1212
|
+
return fail(property, { kind: "choice", problem: { kind: "record-unsupported", detail: "spread-or-accessor" } });
|
|
1213
|
+
if (isComputedPropertyName(property.name))
|
|
1214
|
+
return fail(property, { kind: "choice", problem: { kind: "record-unsupported", detail: "computed-key" } });
|
|
1215
|
+
const key = nameText(property.name) ?? "";
|
|
1216
|
+
if (!names.includes(key))
|
|
1217
|
+
return fail(property, undeclared(channel, key));
|
|
1218
|
+
const paint = declared.channel === "paints" ? declared.values.find((value) => value.name === key) : void 0;
|
|
1219
|
+
if (paint !== void 0)
|
|
1220
|
+
await checkPaintValue(checker, property, paint, fail);
|
|
1221
|
+
setNames.add(runtimeKey(channel, key));
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
edits.push({ node: access, text: runtimeSetter(scope, declared) });
|
|
1225
|
+
}
|
|
1226
|
+
for (const call of propsSpreads)
|
|
1227
|
+
return fail(call.parent ?? call, { kind: "spread-attribute" });
|
|
1228
|
+
for (const [key, declaration] of declaredRuntime)
|
|
1229
|
+
if (!setNames.has(key))
|
|
1230
|
+
review(declaration.at, unused(declaration.channel, declaration.name));
|
|
1231
|
+
for (const read of paintTypeReads(source)) {
|
|
1232
|
+
if (!await recipeHandle(read.recipe))
|
|
1233
|
+
continue;
|
|
1234
|
+
const handles = await values.choices(read.recipe, (context, resolve) => resolve(read.recipe, context)), unions = new Set;
|
|
1235
|
+
for (const leaf of handles.leaves) {
|
|
1236
|
+
const handle = leaf.value, parsed = typeof handle === "object" && handle !== null && handle.kind === "recipe" ? parseConstruction(handle.descriptor.spec) : null;
|
|
1237
|
+
if (parsed === null)
|
|
1238
|
+
return fail(read.node, { kind: "choice", problem: { kind: "recipe-access-unsupported", key: "paints" } });
|
|
1239
|
+
if (parsed.kind === "err")
|
|
1240
|
+
return fail(read.node, { kind: "spec", failure: parsed.error });
|
|
1241
|
+
const paint = declaredPaints(parsed.value).find((value) => value.name === read.name);
|
|
1242
|
+
if (paint === void 0)
|
|
1243
|
+
return fail(read.node, { kind: "paint-undeclared", name: read.name });
|
|
1244
|
+
unions.add(paintUnion(paint));
|
|
1245
|
+
}
|
|
1246
|
+
const [union] = unions;
|
|
1247
|
+
if (unions.size !== 1 || union === void 0)
|
|
1248
|
+
return fail(read.node, { kind: "choice", problem: { kind: "recipe-access-unsupported", key: "paints" } });
|
|
1249
|
+
edits.push({ node: read.node, text: `(${union})` });
|
|
1250
|
+
}
|
|
1251
|
+
const redundant = [...restatements].filter((entry) => entry[1].kind === "redundant").sort(([a], [b]) => a.getStart() - b.getStart());
|
|
1252
|
+
for (const [at, { redundancy }] of redundant)
|
|
1253
|
+
return fail(at, { kind: "recipe-redundant", redundancy });
|
|
1254
|
+
const sections = sectionsDeclared(foundation);
|
|
1255
|
+
for (const opening of openings) {
|
|
1256
|
+
if (!lowercaseTag(opening))
|
|
1257
|
+
continue;
|
|
1258
|
+
const tag = opening.tagName.getText();
|
|
1259
|
+
if (tag === "img" && attr(opening, "alt") === void 0)
|
|
1260
|
+
return fail(opening, { kind: "image-alt-missing" });
|
|
1261
|
+
if (clickWithoutKeyboard(opening))
|
|
1262
|
+
review(opening, { kind: "click-without-keyboard", element: tag });
|
|
1263
|
+
if (!sections && !artworkThemed.has(opening))
|
|
1264
|
+
for (const attribute of ["data-theme", "data-brand"]) {
|
|
1265
|
+
const at = attr(opening, attribute);
|
|
1266
|
+
if (at !== void 0)
|
|
1267
|
+
review(at, { kind: "context-section-inactive", attribute, element: tag });
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
for (const opening of openings) {
|
|
1271
|
+
const component = !lowercaseTag(opening), suggestion = missingAutocomplete(opening, component);
|
|
1272
|
+
if (suggestion === null || component && !await takesAutocomplete(opening))
|
|
1273
|
+
continue;
|
|
1274
|
+
review(opening, { kind: "autocomplete-missing", element: opening.tagName.getText(), suggestion });
|
|
1275
|
+
}
|
|
1276
|
+
if (!openings.some((opening) => opening.attributes.properties.some((attribute) => isJsxAttribute(attribute) && /^on(?:Pointer|Touch)[A-Z]/.test(nameText(attribute.name) ?? ""))))
|
|
1277
|
+
for (const { at, element } of touchDisabled)
|
|
1278
|
+
review(at, { kind: "touch-action-unhandled", element });
|
|
1279
|
+
if (inspected) {
|
|
1280
|
+
const PARSERS = ["DOMParser", "innerHTML", "outerHTML", "insertAdjacentHTML", "createContextualFragment", "setHTMLUnsafe", "parseHTMLUnsafe"];
|
|
1281
|
+
for (const identifier of nodesOfKind(source, SyntaxKind.Identifier, isIdentifier))
|
|
1282
|
+
if (PARSERS.includes(identifier.text))
|
|
1283
|
+
return fail(identifier, { kind: "inspected-svg-parsed", api: identifier.text });
|
|
1284
|
+
}
|
|
1285
|
+
const glyphReads = new Set;
|
|
1286
|
+
for (const glyph of references)
|
|
1287
|
+
glyphReads.add(await values.symbol(glyph));
|
|
1288
|
+
if (glyphReads.size > 0)
|
|
1289
|
+
for (const identifier of nodesOfKind(source, SyntaxKind.Identifier, isIdentifier)) {
|
|
1290
|
+
if (references.has(identifier) || !glyphReads.has(await values.symbol(identifier)))
|
|
1291
|
+
continue;
|
|
1292
|
+
const declaration = identifier.parent;
|
|
1293
|
+
if (declaration !== void 0 && (isBindingElement(declaration) || isParameterDeclaration(declaration)) && declaration.name === identifier)
|
|
1294
|
+
continue;
|
|
1295
|
+
const passed = identifier.parent?.parent, tag = passed !== void 0 && isJsxAttribute(passed) ? passed.parent.parent : void 0, host = tag !== void 0 && (isJsxOpeningElement(tag) || isJsxSelfClosingElement(tag)) ? tag : null;
|
|
1296
|
+
if (!(identifier.parent !== void 0 && isJsxExpression(identifier.parent) && host !== null && !lowercaseTag(host)))
|
|
1297
|
+
return fail(identifier, { kind: "glyph-reference-read", name: identifier.text });
|
|
1298
|
+
}
|
|
1299
|
+
const assetEdits = new Map;
|
|
1300
|
+
for (const selection of selections)
|
|
1301
|
+
for (const leaf of selection.result.leaves)
|
|
1302
|
+
if (leaf.value.kind === "styled")
|
|
1303
|
+
for (const { target } of leaf.value.assetSources)
|
|
1304
|
+
assetEdits.set(target, selection);
|
|
1305
|
+
for (const statement of source.statements)
|
|
1306
|
+
if (isImportDeclaration(statement) && isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === RECIPE_MODULE)
|
|
1307
|
+
edits.push({ node: statement, text: "" });
|
|
1308
|
+
edits.push(...macros.edits);
|
|
1309
|
+
for (const call of values.macroCalls.keys()) {
|
|
1310
|
+
if ([...values.macroCalls.keys()].some((other) => other !== call && inside(call, other)))
|
|
1311
|
+
continue;
|
|
1312
|
+
const parent = call.parent, node = parent !== void 0 && isPropertyAccessExpression(parent) && parent.name.text === "root" ? parent : call;
|
|
1313
|
+
edits.push({ node, text: node === call ? "{}" : '""' });
|
|
1314
|
+
}
|
|
1315
|
+
const rewritten = await publicImports({ root, file: name, source, publicModule: options.publicAlias, symbolOf: values.symbol, emitted, fail }), imports = [...rewritten.imports];
|
|
1316
|
+
for (const statement of rewritten.statements)
|
|
1317
|
+
edits.push({ node: statement, text: "" });
|
|
1318
|
+
const coveredLeaves = selections.reduce((sum, { result }) => sum + result.leaves.filter((leaf) => leaf.value.kind === "styled").length, 0), [rows] = exposedRows.values(), publicRows = exposedRows.size === 1 && rows !== void 0 ? rows : null, artwork = { assets: [...boundAssets].sort(), sets: [...boundSets].sort(), glyphs: macros.glyphs, support: macros.support };
|
|
1319
|
+
return { source, values, selections, styles, edits, assetEdits, imports, coverage: { constructions: styles.size, coveredLeaves }, publicRows, controls: ownerControls(selections.flatMap((selection) => selection.result.axes)), reviews, artwork, design: ownerDesign([...styles.values()].flatMap((construction) => construction.profiles)) };
|
|
1320
|
+
}
|
|
1321
|
+
function lower(spec, foundation, root, input) {
|
|
1322
|
+
const asset = input.visual?.kind === "asset" ? input.visual : null;
|
|
1323
|
+
switch (spec.kind) {
|
|
1324
|
+
case "control":
|
|
1325
|
+
return lowerControl(spec, foundation, { root, asset: asset?.asset ?? null, state: asset?.state ?? "normal", hasText: input.hasText, hidden: input.hidden });
|
|
1326
|
+
case "artwork":
|
|
1327
|
+
return lowerArtwork(spec, foundation, {
|
|
1328
|
+
root,
|
|
1329
|
+
asset: asset?.asset ?? null,
|
|
1330
|
+
state: asset?.state ?? "normal",
|
|
1331
|
+
visualProfile: asset?.visualProfile ?? null,
|
|
1332
|
+
theme: asset?.theme ?? LIGHT,
|
|
1333
|
+
hidden: input.hidden
|
|
1334
|
+
});
|
|
1335
|
+
case "region":
|
|
1336
|
+
return lowerRegion(spec, foundation, { root, visual: input.visual, hidden: input.hidden, scope: input.scope });
|
|
1337
|
+
case "grid":
|
|
1338
|
+
return lowerGrid(spec, foundation, { root, hidden: input.hidden, inherited: input.inherited, aligned: input.aligned, scope: input.scope });
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
function placedArtwork(construction) {
|
|
1342
|
+
const { facts } = construction;
|
|
1343
|
+
switch (facts.kind) {
|
|
1344
|
+
case "control":
|
|
1345
|
+
return facts.artwork;
|
|
1346
|
+
case "artwork":
|
|
1347
|
+
return facts.artwork;
|
|
1348
|
+
case "region":
|
|
1349
|
+
return facts.artwork;
|
|
1350
|
+
case "grid":
|
|
1351
|
+
return null;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
const artworkSource = (construction) => placedArtwork(construction)?.source ?? "", AUTHORING_LEAK = /@reqvire-org\/ads|type:\s*"macro"|__adsRecipe/, jsxRuntime = (framework) => `${framework ?? "react"}/jsx-runtime`;
|
|
1355
|
+
export async function emitOwners(analysis, target = { kind: "compiled" }, dependencies = { packageManifest: null }) {
|
|
1356
|
+
const { foundation, compiled } = analysis, scoped = target.kind === "scoped";
|
|
1357
|
+
return attemptAsync(async (reject) => {
|
|
1358
|
+
const fail = failAt(reject), files = new Map, summary = [];
|
|
1359
|
+
for (const [name, owner] of analysis.owners) {
|
|
1360
|
+
const { selections } = owner, classOf = (style) => scoped ? owner.styles.get(style)?.root : compiled.entries.get(style), css = scoped ? [...owner.styles.values()].map((value) => value.css).join(`
|
|
1361
|
+
`) : compiled.sheets.get(name);
|
|
1362
|
+
if (css === void 0)
|
|
1363
|
+
throw Error(`No compiled sheet for owner ${name}`);
|
|
1364
|
+
files.set(name, await ownerModuleSource(name, owner, classOf, fail));
|
|
1365
|
+
const sheet = ownerSheet(name, owner.styles, css, foundation);
|
|
1366
|
+
if (sheet.kind === "err")
|
|
1367
|
+
return reject(sheet.error);
|
|
1368
|
+
files.set(ownerSheetName(name), sheet.value);
|
|
1369
|
+
summary.push({
|
|
1370
|
+
name,
|
|
1371
|
+
styles: owner.styles.size,
|
|
1372
|
+
css: scoped ? null : compiled.stats.get(name) ?? null,
|
|
1373
|
+
selections: selections.map(({ node, result }) => ({
|
|
1374
|
+
at: location(node),
|
|
1375
|
+
axes: result.axes.map((axis) => ({ expression: axis.expression, values: axis.domain })),
|
|
1376
|
+
branches: result.branches,
|
|
1377
|
+
leaves: result.leaves.length
|
|
1378
|
+
}))
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
for (const [name, module] of analysis.plain)
|
|
1382
|
+
files.set(name, plainModuleSource(name, module));
|
|
1383
|
+
withGlyphSupport(files, [...[...analysis.owners.values()].map((owner) => owner.artwork), ...[...analysis.plain.values()].map((module) => module.artwork)]);
|
|
1384
|
+
const fonts = fontEmission(analysis.fonts, preloadedFaces(foundation, analysis.document, analysis.fonts)), document = foundationSheet({ foundation, document: analysis.document, themes: analysis.themes, fonts: analysis.fonts, documents: ownerDocuments(analysis.owners.values()) });
|
|
1385
|
+
if (document.kind === "err")
|
|
1386
|
+
return reject({ kind: "token-css", owner: FOUNDATION_DECLARATION, failure: document.error });
|
|
1387
|
+
withFoundationSheet(files, document.value, PUBLIC_BARREL);
|
|
1388
|
+
withFontsModule(files, fonts, PUBLIC_BARREL);
|
|
1389
|
+
const icon = await appIconEmission(checkedAppIcon(analysis));
|
|
1390
|
+
withAppIconsModule(files, icon, PUBLIC_BARREL);
|
|
1391
|
+
files.set(DEPENDENCY_MANIFEST, dependencyManifestText(analysis.graph, dependencies));
|
|
1392
|
+
withOutputPackage(files);
|
|
1393
|
+
return { files, binaries: new Map([...fonts.files, ...icon.files]), summary };
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
function checkedAppIcon(analysis) {
|
|
1397
|
+
const [theme] = analysis.themes;
|
|
1398
|
+
if (analysis.appIcon === null || theme === void 0)
|
|
1399
|
+
return null;
|
|
1400
|
+
const reading = appIconPlan(analysis.appIcon, { assets: analysis.assets, foundation: analysis.foundation, theme });
|
|
1401
|
+
switch (reading.kind) {
|
|
1402
|
+
case "planned":
|
|
1403
|
+
return reading.plan;
|
|
1404
|
+
case "failed":
|
|
1405
|
+
throw Error(`Emission ran on a design system whose app icon checks fail: ${reading.findings.map(describeAppIcon).join(" ")}`);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
export const ownerSheetName = (owner) => owner.replace(/\.tsx?$/, ".css");
|
|
1409
|
+
export function ownerSheet(owner, styles, css, foundation, sections = !0) {
|
|
1410
|
+
const used = new Set([...styles.values()].flatMap((value) => [...value.used])), tokens = tokenCss(foundation, used);
|
|
1411
|
+
if (tokens.kind === "err")
|
|
1412
|
+
return err({ kind: "token-css", owner, failure: tokens.error });
|
|
1413
|
+
const nested = sections ? tokenSectionCss(foundation, tokens.value) : "";
|
|
1414
|
+
return ok([tokens.value, ...nested === "" ? [] : [nested], css].join(`
|
|
1415
|
+
`));
|
|
1416
|
+
}
|
|
1417
|
+
export const ownerDocuments = (owners) => [...owners].flatMap((owner) => [...owner.styles.values()].flatMap((value) => value.documents));
|
|
1418
|
+
export function plainModuleSource(name, module) {
|
|
1419
|
+
let text = module.source.text;
|
|
1420
|
+
const replacements = [...module.statements.map((node) => ({ node, text: "" })), ...module.edits];
|
|
1421
|
+
for (const edit of replacements.sort((a, b) => b.node.getStart(module.source) - a.node.getStart(module.source)))
|
|
1422
|
+
text = text.slice(0, edit.node.getStart(module.source)) + edit.text + text.slice(edit.node.end);
|
|
1423
|
+
if (module.imports.length > 0)
|
|
1424
|
+
text = `${module.imports.join(`
|
|
1425
|
+
`)}
|
|
1426
|
+
${text}`;
|
|
1427
|
+
if (AUTHORING_LEAK.test(text))
|
|
1428
|
+
throw Error(`Authoring leaked into emitted source: ${name}`);
|
|
1429
|
+
return text;
|
|
1430
|
+
}
|
|
1431
|
+
export function withGlyphSupport(files, artwork) {
|
|
1432
|
+
if (artwork.some((item) => item.support))
|
|
1433
|
+
files.set(GLYPH_SUPPORT, GLYPH_SUPPORT_SOURCE);
|
|
1434
|
+
}
|
|
1435
|
+
export function outputDependencyManifest(graph, dependencies) {
|
|
1436
|
+
const jsx = [...graph.modules.keys()].some((name) => /\.[jt]sx$/.test(name));
|
|
1437
|
+
return dependencyManifest({ graph, jsxRuntime: jsx ? jsxRuntime(dependencies.framework) : null, packageManifest: dependencies.packageManifest });
|
|
1438
|
+
}
|
|
1439
|
+
export function dependencyManifestText(graph, dependencies) {
|
|
1440
|
+
return serializeManifest(outputDependencyManifest(graph, dependencies));
|
|
1441
|
+
}
|
|
1442
|
+
export async function ownerModuleSource(name, owner, classOf, fail) {
|
|
1443
|
+
const { source, values, selections } = owner, edits = [...owner.edits], insertions = new Map, braced = new Set;
|
|
1444
|
+
let sequence = 0;
|
|
1445
|
+
const classFor = (value) => {
|
|
1446
|
+
if (value.kind === "unstyled")
|
|
1447
|
+
return value.markers.join(" ");
|
|
1448
|
+
const compiledClass = classOf(value.style);
|
|
1449
|
+
if (compiledClass === void 0)
|
|
1450
|
+
throw Error(`No compiled class for construction ${value.style}`);
|
|
1451
|
+
return [...value.markers, compiledClass].join(" ");
|
|
1452
|
+
};
|
|
1453
|
+
for (const { node, result } of selections) {
|
|
1454
|
+
let text = emitChoice(result.tree, (value) => value.kind === "absent" ? null : JSON.stringify(classFor(value))) ?? '""';
|
|
1455
|
+
const placements = [...new Set(result.leaves.flatMap((leaf) => leaf.value.kind === "styled" && leaf.value.placement !== null ? [leaf.value.placement] : []))], [placement] = placements;
|
|
1456
|
+
if (placements.length > 1)
|
|
1457
|
+
fail(node, { kind: "placement-repeated" });
|
|
1458
|
+
if (placement !== void 0) {
|
|
1459
|
+
let statement = node;
|
|
1460
|
+
const branch = (candidate) => isReturnStatement(candidate) && candidate.parent !== void 0 && isIfStatement(candidate.parent);
|
|
1461
|
+
while (statement.parent !== void 0 && !isBlock(statement.parent) && !branch(statement))
|
|
1462
|
+
statement = statement.parent;
|
|
1463
|
+
if (!isReturnStatement(statement))
|
|
1464
|
+
fail(node, { kind: "placement-statement" });
|
|
1465
|
+
const variable = `compiledClass${sequence++}`;
|
|
1466
|
+
if (nodesOfKind(source, SyntaxKind.Identifier, isIdentifier).some((identifier) => identifier.text === variable))
|
|
1467
|
+
fail(node, { kind: "local-name-collision", name: variable });
|
|
1468
|
+
if (branch(statement) && !insertions.has(statement))
|
|
1469
|
+
braced.add(statement);
|
|
1470
|
+
insertions.set(statement, `${insertions.get(statement) ?? ""}const ${variable} = ${text};
|
|
1471
|
+
`);
|
|
1472
|
+
text = `(${placement} ? ${variable} + " " + ${placement} : ${variable})`;
|
|
1473
|
+
}
|
|
1474
|
+
edits.push({ node, text: isStringLiteral(node) ? `{${text}}` : text });
|
|
1475
|
+
}
|
|
1476
|
+
for (const [targetNode, selection] of owner.assetEdits) {
|
|
1477
|
+
const text = emitChoice(selection.result.tree, (value) => {
|
|
1478
|
+
const item = value.kind === "styled" ? value.assetSources.find((candidate) => candidate.target === targetNode) : void 0;
|
|
1479
|
+
return item === void 0 ? null : item.code;
|
|
1480
|
+
});
|
|
1481
|
+
edits.push({ node: targetNode, text: text ?? '""' });
|
|
1482
|
+
}
|
|
1483
|
+
const runtimeAxes = new Set(selections.flatMap((selection) => selection.result.axes.map((axis) => axis.declaration))), bindings = new Map;
|
|
1484
|
+
for (const declaration of values.touched)
|
|
1485
|
+
if (declaration.parent.parent?.parent === source && isIdentifier(declaration.name))
|
|
1486
|
+
bindings.set(await values.symbol(declaration.name), declaration);
|
|
1487
|
+
const references = new Map([...bindings.values()].map((declaration) => [declaration, []]));
|
|
1488
|
+
for (const identifier of nodesOfKind(source, SyntaxKind.Identifier, isIdentifier)) {
|
|
1489
|
+
const declaration = bindings.get(await values.symbol(identifier));
|
|
1490
|
+
if (declaration !== void 0 && identifier !== declaration.name)
|
|
1491
|
+
references.get(declaration)?.push(identifier);
|
|
1492
|
+
}
|
|
1493
|
+
const statementOf = (declaration) => declaration.parent.parent ?? declaration.parent, removed = new Set;
|
|
1494
|
+
let changed = !0;
|
|
1495
|
+
while (changed) {
|
|
1496
|
+
changed = !1;
|
|
1497
|
+
for (const [declaration, refs] of references) {
|
|
1498
|
+
if (runtimeAxes.has(declaration) || removed.has(declaration))
|
|
1499
|
+
continue;
|
|
1500
|
+
if (!refs.every((ref) => edits.some((edit) => inside(ref, edit.node)) || [...removed].some((parent) => inside(ref, statementOf(parent)))))
|
|
1501
|
+
continue;
|
|
1502
|
+
const list = declaration.parent;
|
|
1503
|
+
if (!isVariableDeclarationList(list) || list.declarations.length !== 1)
|
|
1504
|
+
fail(declaration, { kind: "declaration-not-split" });
|
|
1505
|
+
removed.add(declaration);
|
|
1506
|
+
changed = !0;
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
for (const declaration of removed)
|
|
1510
|
+
edits.push({ node: statementOf(declaration), text: "" });
|
|
1511
|
+
const replacements = edits.filter((edit) => !edits.some((other) => other !== edit && other.node !== edit.node && inside(edit.node, other.node))).map((edit) => ({ start: edit.node.getStart(source), end: edit.node.end, text: edit.text }));
|
|
1512
|
+
for (const [node, text] of insertions)
|
|
1513
|
+
replacements.push({ start: node.getStart(source), end: node.getStart(source), text: braced.has(node) ? `{
|
|
1514
|
+
${text}` : text });
|
|
1515
|
+
for (const node of braced)
|
|
1516
|
+
replacements.push({ start: node.end, end: node.end, text: `
|
|
1517
|
+
}` });
|
|
1518
|
+
let emitted = source.text;
|
|
1519
|
+
for (const edit of replacements.sort((a, b) => b.start - a.start))
|
|
1520
|
+
emitted = emitted.slice(0, edit.start) + edit.text + emitted.slice(edit.end);
|
|
1521
|
+
emitted = `import ${JSON.stringify(`./${path.basename(ownerSheetName(name))}`)};
|
|
1522
|
+
${owner.imports.join(`
|
|
1523
|
+
`)}
|
|
1524
|
+
${emitted}`;
|
|
1525
|
+
if (AUTHORING_LEAK.test(emitted))
|
|
1526
|
+
throw Error(`Authoring leaked into emitted source: ${name}`);
|
|
1527
|
+
return emitted;
|
|
1528
|
+
}
|
|
1529
|
+
export async function emissionFacts(root, outcomes, selected, options) {
|
|
1530
|
+
if (selected.size === 0)
|
|
1531
|
+
return ok(new Map);
|
|
1532
|
+
const names = [...outcomes.keys()], walked = await moduleGraph(root, names, options.publicAlias, options.framework, { kind: "barrel" });
|
|
1533
|
+
if (walked.kind === "err")
|
|
1534
|
+
return walked;
|
|
1535
|
+
const { program, graph } = walked.value, emitted = new Set(graph.modules.keys());
|
|
1536
|
+
return attemptAsync(async (reject) => {
|
|
1537
|
+
const fail = failAt(reject), owners = new Map, settled = new Map;
|
|
1538
|
+
for (const [name, outcome] of outcomes) {
|
|
1539
|
+
if (selected.has(name)) {
|
|
1540
|
+
const before = new Map(settled), rowsOf = (owner) => {
|
|
1541
|
+
const read = rowsRead(before.get(owner));
|
|
1542
|
+
switch (read.kind) {
|
|
1543
|
+
case "rows":
|
|
1544
|
+
return read.rows;
|
|
1545
|
+
case "unavailable":
|
|
1546
|
+
throw Error(`Emission read the rows of ${owner}, which its check did not analyze.`);
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
owners.set(name, await analyzeOwner(root, emitted, name, program, options, rowsOf, fail));
|
|
1550
|
+
}
|
|
1551
|
+
settled.set(name, outcome);
|
|
1552
|
+
}
|
|
1553
|
+
return owners;
|
|
1554
|
+
});
|
|
1555
|
+
}
|