@astryxdesign/cli 0.6.5 → 0.6.6-canary.e1dda17
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/CHANGELOG.md +87 -0
- package/README.md +58 -55
- package/api/build/_adapter.d.mts +55 -2
- package/api/build/_adapter.mjs +100 -10
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.test.mjs +111 -2
- package/api/build/build.type.d.mts +8 -0
- package/api/build/build.type.mjs +2 -0
- package/api/build/kit/kit.mjs +99 -22
- package/api/build/kit/rank.d.mts +32 -8
- package/api/build/kit/rank.mjs +291 -97
- package/api/build/kit/rank.test.mjs +231 -48
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +603 -0
- package/api/component/component.mjs +49 -15
- package/api/component/component.test.mjs +32 -0
- package/api/component/component.type.d.mts +33 -3
- package/api/component/component.type.mjs +10 -3
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +5 -2
- package/api/component/detail/detail.mjs +5 -1
- package/api/component/detail/props/props.d.mts +2 -1
- package/api/component/detail/props/props.mjs +3 -2
- package/api/component/detail/showcase/showcase.d.mts +3 -1
- package/api/component/detail/showcase/showcase.mjs +3 -1
- package/api/component/detail/source/source.d.mts +3 -2
- package/api/component/detail/source/source.mjs +7 -3
- package/api/component/list/list.mjs +128 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +25 -0
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.mjs +7 -1
- package/api/docs/docOverlays.test.mjs +10 -6
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +134 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +46 -1
- package/api/docs/docs.test.mjs +279 -0
- package/api/docs/docs.type.d.mts +81 -4
- package/api/docs/docs.type.mjs +41 -4
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +572 -0
- package/api/docs/integrationDocs.test.mjs +337 -0
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +149 -23
- package/api/doctor/_adapter.d.mts +43 -0
- package/api/doctor/_adapter.mjs +142 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +6 -123
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +1117 -0
- package/api/doctor/theme-checks.test.mjs +526 -0
- package/api/error.d.mts +22 -0
- package/api/error.mjs +42 -0
- package/api/gap-report/gap-report.d.mts +3 -1
- package/api/gap-report/gap-report.mjs +27 -3
- package/api/gap-report/gap-report.test.mjs +106 -0
- package/api/hook/_adapter.d.mts +1 -0
- package/api/hook/_adapter.mjs +3 -0
- package/api/hook/detail/detail.mjs +2 -2
- package/api/hook/detail/params/params.mjs +2 -2
- package/api/hook/hook.type.d.mts +12 -0
- package/api/hook/hook.type.mjs +3 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/hook/list/list.mjs +8 -8
- package/api/index.d.mts +1 -1
- package/api/index.mjs +4 -0
- package/api/init/run/run.d.mts +3 -5
- package/api/init/run/run.mjs +10 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/add-contribution.test.mjs +3 -3
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +354 -28
- package/api/integration/add-theme.test.mjs +380 -16
- package/api/integration/authoring-checks.mjs +31 -8
- package/api/integration/authoring-checks.type.d.mts +8 -0
- package/api/integration/authoring-checks.type.mjs +7 -3
- package/api/integration/integration-authoring.type.d.mts +4 -1
- package/api/integration/integration-authoring.type.mjs +6 -1
- package/api/integration/integrationAdd.doc.mjs +6 -0
- package/api/integration/integrationAddTheme.doc.mjs +10 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
- package/api/integration/pack-check.component-replaces.test.mjs +126 -0
- package/api/integration/pack-check.d.mts +10 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
- package/api/integration/pack-check.mjs +495 -4
- package/api/integration/pack-check.test.mjs +619 -10
- package/api/integration/validate-integration.d.mts +4 -2
- package/api/integration/validate-integration.mjs +7 -2
- package/api/integration/validate-integration.test.mjs +55 -0
- package/api/integration/validate-integration.type.d.mts +5 -0
- package/api/integration/validate-integration.type.mjs +5 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/layout/expand/expand.mjs +12 -7
- package/api/layout/expand/expand.receipt.test.mjs +74 -0
- package/api/layout/layout.type.d.mts +1 -0
- package/api/layout/layout.type.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search.d.mts +39 -8
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +248 -66
- package/api/search/search.test.mjs +829 -0
- package/api/search/search.type.d.mts +6 -6
- package/api/search/search.type.mjs +5 -5
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +23 -0
- package/api/swizzle/copy/copy.d.mts +5 -6
- package/api/swizzle/copy/copy.mjs +95 -13
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +4 -0
- package/api/swizzle/swizzle.test.mjs +55 -5
- package/api/swizzle/swizzle.type.d.mts +8 -0
- package/api/swizzle/swizzle.type.mjs +2 -0
- package/api/template/copy/copy.mjs +15 -8
- package/api/template/copy/copy.receipt.test.mjs +77 -0
- package/api/template/show/show.mjs +17 -4
- package/api/template/show/show.test.mjs +76 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template-integration.test.mjs +14 -0
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +6 -2
- package/api/template/template.mjs +2 -0
- package/api/template/template.type.d.mts +14 -0
- package/api/template/template.type.mjs +5 -0
- package/api/theme/_adapter.d.mts +106 -6
- package/api/theme/_adapter.mjs +687 -18
- package/api/theme/add/add.binary.test.mjs +76 -3
- package/api/theme/add/add.d.mts +5 -9
- package/api/theme/add/add.mjs +87 -64
- package/api/theme/add/add.rollback.test.mjs +9 -9
- package/api/theme/add/add.staging.test.mjs +9 -9
- package/api/theme/add/add.test.mjs +461 -55
- package/api/theme/add/add.types.test.mjs +151 -0
- package/api/theme/build/build.d.mts +50 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.icon-lineage.test.mjs +117 -0
- package/api/theme/build/build.icon-preservation.test.mjs +639 -0
- package/api/theme/build/build.mjs +463 -155
- package/api/theme/build/build.project-core.test.mjs +165 -0
- package/api/theme/build/build.test.mjs +220 -1
- package/api/theme/build/icon-imports.d.mts +47 -0
- package/api/theme/build/icon-imports.mjs +691 -0
- package/api/theme/eject/eject.binary.test.mjs +90 -0
- package/api/theme/eject/eject.d.mts +17 -0
- package/api/theme/eject/eject.mjs +65 -0
- package/api/theme/eject/eject.rollback.test.mjs +158 -0
- package/api/theme/eject/eject.staging.test.mjs +83 -0
- package/api/theme/eject/eject.test.mjs +160 -0
- package/api/theme/integration-themes.test.mjs +30 -6
- package/api/theme/list/list.d.mts +10 -0
- package/api/theme/list/list.mjs +75 -7
- package/api/theme/list/list.test.mjs +155 -4
- package/api/theme/remove/remove.d.mts +12 -0
- package/api/theme/remove/remove.mjs +15 -0
- package/api/theme/remove/remove.test.mjs +94 -0
- package/api/theme/template/template.mjs +3 -4
- package/api/theme/theme.d.mts +5 -2
- package/api/theme/theme.mjs +13 -8
- package/api/theme/theme.type.d.mts +106 -2
- package/api/theme/theme.type.mjs +54 -5
- package/api/theme/themeAdd.doc.d.mts +1 -3
- package/api/theme/themeAdd.doc.mjs +35 -22
- package/api/theme/themeBuild.doc.d.mts +4 -1
- package/api/theme/themeBuild.doc.mjs +15 -4
- package/api/theme/themeEject.doc.d.mts +8 -0
- package/api/theme/themeEject.doc.mjs +89 -0
- package/api/theme/themeListAvailable.doc.mjs +4 -4
- package/api/theme/themeListCopySources.doc.d.mts +8 -0
- package/api/theme/themeListCopySources.doc.mjs +60 -0
- package/api/theme/themeRemove.doc.d.mts +6 -0
- package/api/theme/themeRemove.doc.mjs +50 -0
- package/api/theme/themeTemplate.doc.mjs +4 -3
- package/api/theme/themeUse.doc.d.mts +6 -0
- package/api/theme/themeUse.doc.mjs +47 -0
- package/api/theme/use/use.d.mts +12 -0
- package/api/theme/use/use.mjs +15 -0
- package/api/theme/use/use.test.mjs +98 -0
- package/api/upgrade/_adapter.d.mts +1 -0
- package/api/upgrade/_adapter.mjs +3 -0
- package/api/upgrade/list/list.mjs +9 -3
- package/api/upgrade/run/run.mjs +20 -3
- package/api/upgrade/run/run.test.mjs +45 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +5 -0
- package/api/upgrade/upgrade.type.mjs +2 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/next/index.mjs +14 -1
- package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +161 -0
- package/assets/docs/getting-started.doc.mjs +59 -15
- package/assets/docs/icons.doc.mjs +1 -0
- package/assets/docs/principles.doc.dense.mjs +2 -2
- package/assets/docs/principles.doc.mjs +2 -2
- package/assets/docs/principles.doc.zh.mjs +2 -2
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/styling.doc.mjs +2 -2
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -770
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tokens.doc.mjs +4 -4
- package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +6 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +32 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/responsive.doc.mjs +102 -0
- package/assets/docs/tree/scaffold.doc.mjs +145 -0
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/side-panels.doc.mjs +82 -0
- package/assets/docs/tree/structure.doc.mjs +144 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +11 -7
- package/assets/docs/use-a-theme.doc.mjs +97 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
- package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
- package/assets/templates/pages/blank/template.doc.mjs +3 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
- package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
- package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
- package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
- package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
- package/assets/templates/pages/documentation/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
- package/assets/templates/pages/editor/template.doc.mjs +9 -1
- package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
- package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
- package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
- package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
- package/assets/templates/pages/ide/template.doc.mjs +9 -1
- package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
- package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
- package/assets/templates/pages/library/template.doc.mjs +15 -1
- package/assets/templates/pages/login/template.doc.mjs +10 -1
- package/assets/templates/pages/login-card/template.doc.mjs +11 -1
- package/assets/templates/pages/login-split/template.doc.mjs +10 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
- package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
- package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/settings/template.doc.mjs +3 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/table/template.doc.mjs +11 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
- package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
- package/assets/templates/pages/table-comparison/page.tsx +1449 -0
- package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
- package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
- package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
- package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
- package/assets/templates/pages/table-page/template.doc.mjs +20 -1
- package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
- package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
- package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
- package/assets/templates/themes/butter/icons.tsx +2 -0
- package/assets/templates/themes/chocolate/icons.tsx +2 -0
- package/assets/templates/themes/gothic/icons.tsx +2 -0
- package/assets/templates/themes/matcha/icons.tsx +2 -0
- package/assets/templates/themes/neutral/icons.tsx +2 -0
- package/assets/templates/themes/stone/icons.tsx +2 -0
- package/assets/templates/themes/y2k/icons.tsx +2 -0
- package/authoring/doctypes/command/command.doc.mjs +5 -0
- package/authoring/doctypes/command/type.ts +2 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -4
- package/authoring/doctypes/template/parse.d.mts +2 -0
- package/authoring/doctypes/template/parse.mjs +1 -0
- package/authoring/doctypes/template/parse.test.mjs +21 -0
- package/authoring/doctypes/template/template.doc.mjs +6 -0
- package/authoring/doctypes/template/type.ts +10 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.mjs +279 -30
- package/clients/cli/commands/build.mjs +7 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +88 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/discover.mjs +29 -1
- package/clients/cli/commands/discover.no-source.test.mjs +75 -0
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +273 -16
- package/clients/cli/commands/docs.test.mjs +382 -0
- package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +4 -4
- package/clients/cli/commands/doctor.test.mjs +9 -51
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/gap-report.mjs +12 -0
- package/clients/cli/commands/gap-report.test.mjs +63 -0
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-add.doc.mjs +10 -0
- package/clients/cli/commands/integration-authoring.test.mjs +12 -2
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/integration.mjs +3 -1
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +4 -1
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
- package/clients/cli/commands/layout.mjs +61 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.doc.mjs +5 -4
- package/clients/cli/commands/search.mjs +30 -6
- package/clients/cli/commands/search.test.mjs +63 -17
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
- package/clients/cli/commands/template.mjs +70 -6
- package/clients/cli/commands/template.show-media.test.mjs +62 -0
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
- package/clients/cli/commands/theme-remove.doc.mjs +22 -0
- package/clients/cli/commands/theme-template.doc.mjs +4 -3
- package/clients/cli/commands/theme-use.doc.mjs +22 -0
- package/clients/cli/commands/theme.doc.mjs +21 -16
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/commands/write-failure.test.mjs +175 -0
- package/clients/cli/index.mjs +4 -1
- package/clients/cli/lib/component-format.mjs +19 -2
- package/clients/cli/lib/manifest.mjs +44 -165
- package/clients/cli/lib/manifest.test.mjs +98 -7
- package/clients/cli/lib/resolve-theme.mjs +80 -78
- package/clients/cli/lib/resolve-theme.test.mjs +523 -27
- package/foundation/agent-docs/agent-docs.mjs +31 -28
- package/foundation/agent-docs/agent-docs.test.mjs +1163 -0
- package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
- package/foundation/config/project.d.mts +20 -5
- package/foundation/config/project.mjs +43 -6
- package/foundation/config/theme-private-vars.d.mts +12 -0
- package/foundation/config/theme-private-vars.mjs +107 -0
- package/foundation/config/theme-private-vars.test.mjs +55 -0
- package/foundation/config/theme-state.d.mts +145 -0
- package/foundation/config/theme-state.mjs +417 -0
- package/foundation/config/theme-state.test.mjs +182 -0
- package/foundation/discovery/component-discovery.d.mts +5 -2
- package/foundation/discovery/component-discovery.mjs +12 -6
- package/foundation/discovery/component-replacement.d.mts +91 -0
- package/foundation/discovery/component-replacement.mjs +417 -0
- package/foundation/discovery/component-replacement.test.mjs +480 -0
- package/foundation/discovery/docs-output-budget.d.mts +6 -2
- package/foundation/discovery/docs-output-budget.mjs +2 -1
- package/foundation/discovery/docs-section-key.d.mts +4 -2
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/module-exports.d.mts +10 -0
- package/foundation/discovery/module-exports.mjs +146 -0
- package/foundation/discovery/package-exports.d.mts +29 -0
- package/foundation/discovery/package-exports.mjs +200 -0
- package/foundation/discovery/template-adapter.d.mts +14 -0
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
- package/foundation/discovery/template-adapter.mjs +21 -1
- package/foundation/discovery/theme-discovery.d.mts +78 -5
- package/foundation/discovery/theme-discovery.mjs +143 -18
- package/foundation/discovery/theme-discovery.test.mjs +9 -3
- package/foundation/discovery/theme-imports.d.mts +15 -0
- package/foundation/discovery/theme-imports.mjs +217 -0
- package/foundation/discovery/theme-imports.test.mjs +173 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +18 -8
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/tree.test.mjs +649 -0
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +79 -13
- package/foundation/integrations/cli-requirement.mjs +115 -22
- package/foundation/integrations/cli-requirement.test.mjs +205 -8
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/response/base.d.ts +9 -3
- package/foundation/response/json.d.mts +7 -4
- package/foundation/response/json.mjs +10 -6
- package/foundation/response/response-types.doc.d.mts +5 -5
- package/foundation/response/response-types.doc.mjs +50 -35
- package/foundation/response/response.doc.mjs +18 -4
- package/foundation/text/copyright-header.mjs +1 -1
- package/foundation/text/copyright-header.test.mjs +1 -1
- package/package.json +9 -9
- package/assets/docs/layout.doc.dense.mjs +0 -388
- package/assets/docs/layout.doc.mjs +0 -550
|
@@ -2,21 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file theme build API — compile standalone themes or one selected family.
|
|
5
|
+
* @input JS/TS theme modules, build/check options, and the installed Core.
|
|
6
|
+
* @output Generated artifacts preserving imported and inherited icon registries.
|
|
7
|
+
* @position CLI theme compiler; standalone icon provenance is icon-imports.mjs.
|
|
5
8
|
*
|
|
6
9
|
* `themeBuild` and `themeBuildFamily` share the same loader, compiler,
|
|
7
10
|
* serializers, check, and writer. They read defineTheme() sources and, via
|
|
8
11
|
* @astryxdesign/core's shared generator (the SINGLE source of truth so the
|
|
9
12
|
* build emits the exact CSS the `<Theme>` runtime does), writes:
|
|
10
13
|
* - A CSS file with token overrides and component styles
|
|
14
|
+
* - A CSS declaration module for strict side-effect imports
|
|
11
15
|
* - A JS module that re-exports the built theme (+ icon registry)
|
|
12
16
|
* - A .d.ts (plus an optional .variants.d.ts for custom prop values)
|
|
13
17
|
*
|
|
14
18
|
* It performs the writes and returns a `theme.build` receipt — its `warnings`
|
|
15
|
-
* carry override problems
|
|
16
|
-
* its value could not stay one CSS declaration
|
|
17
|
-
* but does not load (font-warning.mjs) — or `null` when the
|
|
18
|
-
* CSS (nothing to build).
|
|
19
|
-
*
|
|
19
|
+
* carry override problems and every declaration core's generator dropped
|
|
20
|
+
* because its value could not stay one CSS declaration; `notices` carry fonts
|
|
21
|
+
* the theme names but does not load (font-warning.mjs) — or `null` when the
|
|
22
|
+
* theme produced no CSS (nothing to build). Standalone icon imports come from
|
|
23
|
+
* the selected theme's parsed bindings and inheritance, never from comment or
|
|
24
|
+
* string contents. A registry that cannot be preserved fails before output
|
|
25
|
+
* generation, including in check mode. Errors throw AstryxError (with a stable
|
|
26
|
+
* code). Human progress is emitted through the shared `logger`
|
|
20
27
|
* (silent by default), so the CLI keeps its exact output while a programmatic
|
|
21
28
|
* caller stays quiet.
|
|
22
29
|
*
|
|
@@ -35,7 +42,9 @@
|
|
|
35
42
|
* `theme.build.check` receipt listing any stale or missing outputs. This is
|
|
36
43
|
* the CI guard for committed, generated theme CSS: the source of truth is
|
|
37
44
|
* `<theme>.ts`, and `theme build --check` fails when the committed
|
|
38
|
-
* `<theme>.css`/`.js`/`.d.ts` no longer match it.
|
|
45
|
+
* `<theme>.css`/`.js`/`.d.ts` no longer match it. Builds also write a
|
|
46
|
+
* `<theme>.css.d.ts` import stub; check mode tolerates that one file being absent
|
|
47
|
+
* so output sets from the released CLI stay valid after an upgrade.
|
|
39
48
|
*/
|
|
40
49
|
|
|
41
50
|
import * as fs from 'node:fs';
|
|
@@ -45,13 +54,18 @@ import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
|
45
54
|
import {parse} from '@babel/parser';
|
|
46
55
|
import {createJiti} from 'jiti';
|
|
47
56
|
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
48
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
CLI_ROOT,
|
|
59
|
+
findCoreDir,
|
|
60
|
+
findInstalledPackage,
|
|
61
|
+
} from '../../../foundation/fs/paths.mjs';
|
|
49
62
|
import {
|
|
50
63
|
assertWithin,
|
|
51
64
|
sanitizeName,
|
|
52
65
|
PathSafetyError,
|
|
53
66
|
} from '../../../foundation/fs/path-safety.mjs';
|
|
54
67
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
68
|
+
import {validatePrivateVars} from '../../../foundation/config/theme-private-vars.mjs';
|
|
55
69
|
import {AstryxError} from '../../error.mjs';
|
|
56
70
|
import {applyWrites} from '../../integration/add-helpers.mjs';
|
|
57
71
|
import {logger} from '../../logger.mjs';
|
|
@@ -63,6 +77,7 @@ import {
|
|
|
63
77
|
import {collectUnloadedFonts, formatFontLoadingHelp} from './font-warning.mjs';
|
|
64
78
|
import {interceptCore} from './core-interception.mjs';
|
|
65
79
|
import {generateFamilyCSS, resolveThemeFamily} from './family.mjs';
|
|
80
|
+
import {resolveIconImports} from './icon-imports.mjs';
|
|
66
81
|
|
|
67
82
|
// Import shared theme processing from core. `astryx theme build` MUST produce the
|
|
68
83
|
// exact same CSS as the `<Theme>` runtime, so it has exactly one generation
|
|
@@ -125,6 +140,232 @@ try {
|
|
|
125
140
|
_coreImportError = e;
|
|
126
141
|
}
|
|
127
142
|
|
|
143
|
+
/**
|
|
144
|
+
* The bindings one Core provides: the namespaces interception spreads, the
|
|
145
|
+
* functions the build calls, and why the import failed, if it did.
|
|
146
|
+
* @typedef {{
|
|
147
|
+
* themeModule: any,
|
|
148
|
+
* rootModule: any,
|
|
149
|
+
* importError: any,
|
|
150
|
+
* defineTheme: any,
|
|
151
|
+
* generateThemeRulesSplit: any,
|
|
152
|
+
* generateOnMediaCSS: any,
|
|
153
|
+
* generateAdaptationCSS: any,
|
|
154
|
+
* dataTokenDefaults: any,
|
|
155
|
+
* }} CoreBindings
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The bindings exactly as the CLI's own import left them, kept so each build
|
|
160
|
+
* can choose between them and the project's installed Core.
|
|
161
|
+
* @type {CoreBindings}
|
|
162
|
+
*/
|
|
163
|
+
const _cliCore = {
|
|
164
|
+
themeModule: _coreThemeModule,
|
|
165
|
+
rootModule: _coreRootModule,
|
|
166
|
+
importError: _coreImportError,
|
|
167
|
+
defineTheme: _defineTheme,
|
|
168
|
+
generateThemeRulesSplit: _generateThemeRulesSplit,
|
|
169
|
+
generateOnMediaCSS: _generateOnMediaCSS,
|
|
170
|
+
generateAdaptationCSS: _generateAdaptationCSS,
|
|
171
|
+
dataTokenDefaults: _dataTokenDefaults,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Point the build at one Core: the module-level bindings every step reads.
|
|
176
|
+
* @param {CoreBindings} core
|
|
177
|
+
*/
|
|
178
|
+
function setCore(core) {
|
|
179
|
+
_coreThemeModule = core.themeModule;
|
|
180
|
+
_coreRootModule = core.rootModule;
|
|
181
|
+
_coreImportError = core.importError;
|
|
182
|
+
_defineTheme = core.defineTheme;
|
|
183
|
+
_generateThemeRulesSplit = core.generateThemeRulesSplit;
|
|
184
|
+
_generateOnMediaCSS = core.generateOnMediaCSS;
|
|
185
|
+
_generateAdaptationCSS = core.generateAdaptationCSS;
|
|
186
|
+
_dataTokenDefaults = core.dataTokenDefaults;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The file an `import` of `subpath` reaches through a package's `exports` map,
|
|
191
|
+
* or null when the map has no entry for it. Conditions are taken in the map's
|
|
192
|
+
* own order, as Node does, accepting the ones an import matches here: `node`,
|
|
193
|
+
* `import`, and `default` (so `source` and `types` are skipped).
|
|
194
|
+
*
|
|
195
|
+
* @param {string} dir - The package directory.
|
|
196
|
+
* @param {string} subpath - `'.'` or a subpath such as `'./theme'`.
|
|
197
|
+
* @returns {string|null}
|
|
198
|
+
*/
|
|
199
|
+
function importTarget(dir, subpath) {
|
|
200
|
+
let pkg;
|
|
201
|
+
try {
|
|
202
|
+
pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
|
|
203
|
+
} catch {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
const map = pkg?.exports;
|
|
207
|
+
const bySubpath =
|
|
208
|
+
map &&
|
|
209
|
+
typeof map === 'object' &&
|
|
210
|
+
!Array.isArray(map) &&
|
|
211
|
+
Object.keys(map).some(key => key.startsWith('.'));
|
|
212
|
+
const entry = bySubpath ? map[subpath] : subpath === '.' ? map : undefined;
|
|
213
|
+
/** @param {any} value @returns {string|null} */
|
|
214
|
+
const pick = value => {
|
|
215
|
+
if (typeof value === 'string') return value;
|
|
216
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
217
|
+
return null;
|
|
218
|
+
for (const [condition, target] of Object.entries(value)) {
|
|
219
|
+
if (
|
|
220
|
+
condition !== 'node' &&
|
|
221
|
+
condition !== 'import' &&
|
|
222
|
+
condition !== 'default'
|
|
223
|
+
)
|
|
224
|
+
continue;
|
|
225
|
+
const picked = pick(target);
|
|
226
|
+
if (picked) return picked;
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
229
|
+
};
|
|
230
|
+
const target = pick(entry);
|
|
231
|
+
return target ? path.resolve(dir, target) : null;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** @param {string} file @returns {string} its real path, or itself */
|
|
235
|
+
function realOrSelf(file) {
|
|
236
|
+
try {
|
|
237
|
+
return fs.realpathSync(file);
|
|
238
|
+
} catch {
|
|
239
|
+
return file;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The Core the project at `cwd` installed, when it differs from the one the
|
|
245
|
+
* CLI's own import found and loads. The app's `<Theme>` runs on the app's
|
|
246
|
+
* Core, so building with it keeps the CSS identical; and a CLI run one-off
|
|
247
|
+
* (`npx @astryxdesign/cli`) has no Core beside it at all. Null when there is
|
|
248
|
+
* nothing better than the CLI's own import: no installed Core (the Astryx
|
|
249
|
+
* repository, a bare directory), the same Core, or one that does not load.
|
|
250
|
+
*
|
|
251
|
+
* @param {string} cwd
|
|
252
|
+
* @returns {Promise<CoreBindings | null>}
|
|
253
|
+
*/
|
|
254
|
+
async function loadProjectCore(cwd) {
|
|
255
|
+
const dir = findInstalledPackage(cwd, '@astryxdesign/core');
|
|
256
|
+
const themeFile = dir ? importTarget(dir, './theme') : null;
|
|
257
|
+
if (!dir || !themeFile) return null;
|
|
258
|
+
if (_cliCore.themeModule) {
|
|
259
|
+
try {
|
|
260
|
+
const own = fileURLToPath(
|
|
261
|
+
import.meta.resolve('@astryxdesign/core/theme'),
|
|
262
|
+
);
|
|
263
|
+
if (realOrSelf(own) === realOrSelf(themeFile)) return null;
|
|
264
|
+
} catch {
|
|
265
|
+
// The CLI's own Core cannot be located; load the project's.
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
let themeModule;
|
|
269
|
+
try {
|
|
270
|
+
themeModule = await import(pathToFileURL(themeFile).href);
|
|
271
|
+
} catch {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
if (!themeModule.defineTheme || !themeModule.generateThemeRulesSplit)
|
|
275
|
+
return null;
|
|
276
|
+
let rootModule = null;
|
|
277
|
+
const rootFile = importTarget(dir, '.');
|
|
278
|
+
if (rootFile) {
|
|
279
|
+
try {
|
|
280
|
+
rootModule = await import(pathToFileURL(rootFile).href);
|
|
281
|
+
} catch {
|
|
282
|
+
// As with the CLI's own import, the theme namespace stands in for it.
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
themeModule,
|
|
287
|
+
rootModule,
|
|
288
|
+
importError: null,
|
|
289
|
+
defineTheme: themeModule.defineTheme,
|
|
290
|
+
generateThemeRulesSplit: themeModule.generateThemeRulesSplit,
|
|
291
|
+
generateOnMediaCSS: themeModule.generateOnMediaCSS,
|
|
292
|
+
generateAdaptationCSS: themeModule.generateAdaptationCSS,
|
|
293
|
+
dataTokenDefaults: themeModule.dataTokenDefaults,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** @type {Map<string, Awaited<ReturnType<typeof loadProjectCore>>>} */
|
|
298
|
+
const _projectCores = new Map();
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Choose the Core this build generates with: the project's installed one when
|
|
302
|
+
* {@link loadProjectCore} finds it, else the CLI's own.
|
|
303
|
+
* @param {string} cwd
|
|
304
|
+
*/
|
|
305
|
+
async function selectCore(cwd) {
|
|
306
|
+
if (!_projectCores.has(cwd))
|
|
307
|
+
_projectCores.set(cwd, await loadProjectCore(cwd));
|
|
308
|
+
setCore(_projectCores.get(cwd) ?? _cliCore);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Whether `cwd` sits in the Astryx repository, where Core is built from
|
|
313
|
+
* source rather than installed.
|
|
314
|
+
* @param {string} cwd
|
|
315
|
+
*/
|
|
316
|
+
function inAstryxRepository(cwd) {
|
|
317
|
+
let dir = cwd;
|
|
318
|
+
for (let i = 0; i < 6; i++) {
|
|
319
|
+
try {
|
|
320
|
+
const pkg = JSON.parse(
|
|
321
|
+
fs.readFileSync(
|
|
322
|
+
path.join(dir, 'packages', 'core', 'package.json'),
|
|
323
|
+
'utf-8',
|
|
324
|
+
),
|
|
325
|
+
);
|
|
326
|
+
if (pkg?.name === '@astryxdesign/core') return true;
|
|
327
|
+
} catch {
|
|
328
|
+
// Not here; keep walking up.
|
|
329
|
+
}
|
|
330
|
+
const parent = path.dirname(dir);
|
|
331
|
+
if (parent === dir) break;
|
|
332
|
+
dir = parent;
|
|
333
|
+
}
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Why `theme build` has no Core to generate with, and the fix for where it
|
|
339
|
+
* ran: the Astryx repository builds Core, an app installs it, and an installed
|
|
340
|
+
* Core that will not load is named.
|
|
341
|
+
*
|
|
342
|
+
* @param {string} cwd
|
|
343
|
+
* @param {any} importError - Why the import failed, when it threw.
|
|
344
|
+
* @returns {string}
|
|
345
|
+
*/
|
|
346
|
+
export function coreUnavailableMessage(cwd, importError) {
|
|
347
|
+
const why =
|
|
348
|
+
'`astryx theme build` generates CSS with @astryxdesign/core, the same code the runtime <Theme> uses';
|
|
349
|
+
const detail = importError ? `\n Import error: ${importError.message}` : '';
|
|
350
|
+
if (inAstryxRepository(cwd)) {
|
|
351
|
+
return (
|
|
352
|
+
`Could not load @astryxdesign/core/theme: ${why}. Build @astryxdesign/core ` +
|
|
353
|
+
`first (e.g. \`pnpm -F @astryxdesign/core build\`).${detail}`
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
const installed = findInstalledPackage(cwd, '@astryxdesign/core');
|
|
357
|
+
if (installed) {
|
|
358
|
+
return (
|
|
359
|
+
`Could not load the @astryxdesign/core installed at ` +
|
|
360
|
+
`${path.relative(cwd, installed) || '.'}: ${why}. Reinstall it.${detail}`
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
return (
|
|
364
|
+
`This project does not have @astryxdesign/core installed: ${why}. Install ` +
|
|
365
|
+
`it: \`npm install @astryxdesign/core\` (or yarn/pnpm/bun).${detail}`
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
128
369
|
/**
|
|
129
370
|
* Read a package's `version` from a resolved directory. Returns `'unknown'`
|
|
130
371
|
* when it can't be read so the header always has a value.
|
|
@@ -194,7 +435,7 @@ function generatedHeader(sourceFile, lang = 'js', command, versions) {
|
|
|
194
435
|
* @param {string} content
|
|
195
436
|
* @returns {string}
|
|
196
437
|
*/
|
|
197
|
-
function
|
|
438
|
+
export function normalizeThemeBuildForCompare(content) {
|
|
198
439
|
return content
|
|
199
440
|
.split('\n')
|
|
200
441
|
.filter(line => {
|
|
@@ -204,24 +445,36 @@ function normalizeForCompare(content) {
|
|
|
204
445
|
.join('\n');
|
|
205
446
|
}
|
|
206
447
|
|
|
207
|
-
/** @param {Array<{dest: string, content: string}>} writes @param {string} cwd @returns {Array<{path: string, reason: 'missing' | 'outdated'}>} */
|
|
448
|
+
/** @param {Array<{dest: string, content: string, allowMissingInCheck?: boolean}>} writes @param {string} cwd @returns {Array<{path: string, reason: 'missing' | 'outdated'}>} */
|
|
208
449
|
function staleBuildOutputs(writes, cwd) {
|
|
209
450
|
/** @type {Array<{path: string, reason: 'missing' | 'outdated'}>} */
|
|
210
451
|
const stale = [];
|
|
211
452
|
for (const write of writes) {
|
|
212
453
|
const rel = path.relative(cwd, write.dest);
|
|
213
454
|
if (!fs.existsSync(write.dest)) {
|
|
214
|
-
|
|
455
|
+
if (!write.allowMissingInCheck) {
|
|
456
|
+
stale.push({path: rel, reason: 'missing'});
|
|
457
|
+
}
|
|
215
458
|
continue;
|
|
216
459
|
}
|
|
217
460
|
const onDisk = fs.readFileSync(write.dest, 'utf8');
|
|
218
|
-
if (
|
|
461
|
+
if (
|
|
462
|
+
normalizeThemeBuildForCompare(onDisk) !==
|
|
463
|
+
normalizeThemeBuildForCompare(write.content)
|
|
464
|
+
) {
|
|
219
465
|
stale.push({path: rel, reason: 'outdated'});
|
|
220
466
|
}
|
|
221
467
|
}
|
|
222
468
|
return stale;
|
|
223
469
|
}
|
|
224
470
|
|
|
471
|
+
/** @param {Array<{dest: string, allowMissingInCheck?: boolean}>} writes @param {string} cwd */
|
|
472
|
+
function checkedBuildOutputs(writes, cwd) {
|
|
473
|
+
return writes
|
|
474
|
+
.filter(write => !write.allowMissingInCheck || fs.existsSync(write.dest))
|
|
475
|
+
.map(write => path.relative(cwd, write.dest));
|
|
476
|
+
}
|
|
477
|
+
|
|
225
478
|
/** @param {Array<{dest: string, content: string}>} writes */
|
|
226
479
|
function writeBuildOutputs(writes) {
|
|
227
480
|
if (writes.length === 0) return;
|
|
@@ -278,8 +531,6 @@ function toIdentifier(name) {
|
|
|
278
531
|
* from the cwd-relative dir (most consumers import from a file under src/) but
|
|
279
532
|
* keeps the rest of the path (e.g. `themes/gothic`). Callers note the path is
|
|
280
533
|
* relative to the consumer's file.
|
|
281
|
-
* Exported (not just used by `themeBuild`'s install instructions) because the
|
|
282
|
-
* thin CLI's `theme add` action reuses it for its own scaffold instructions.
|
|
283
534
|
* @param {string} relDir
|
|
284
535
|
* @param {string} base
|
|
285
536
|
* @returns {string}
|
|
@@ -869,30 +1120,6 @@ function assertAdaptationCapability(
|
|
|
869
1120
|
);
|
|
870
1121
|
}
|
|
871
1122
|
|
|
872
|
-
/**
|
|
873
|
-
* Every `[component, rules]` pair a theme may emit, including ordered
|
|
874
|
-
* adaptation rules. Validators, private-variable checks, and notices must see
|
|
875
|
-
* rule-only values even though variant augmentation is root-owned.
|
|
876
|
-
*
|
|
877
|
-
* @param {Record<string, any>} themeDef
|
|
878
|
-
* @returns {[string, Record<string, any>][]}
|
|
879
|
-
*/
|
|
880
|
-
function themedComponentEntries(themeDef) {
|
|
881
|
-
const maps = [
|
|
882
|
-
themeDef.components,
|
|
883
|
-
...adaptationRuleValues(themeDef).map(
|
|
884
|
-
(/** @type {any} */ value) => value.components,
|
|
885
|
-
),
|
|
886
|
-
];
|
|
887
|
-
|
|
888
|
-
/** @type {[string, Record<string, any>][]} */
|
|
889
|
-
const entries = [];
|
|
890
|
-
for (const map of maps) {
|
|
891
|
-
if (map) entries.push(...Object.entries(map));
|
|
892
|
-
}
|
|
893
|
-
return entries;
|
|
894
|
-
}
|
|
895
|
-
|
|
896
1123
|
/**
|
|
897
1124
|
* Root component entries are the only surface allowed to introduce variants.
|
|
898
1125
|
* @param {Record<string, any>} themeDef
|
|
@@ -1276,6 +1503,19 @@ async function validateRegistryGraphs(/** @type {Array<{specifier: string, expor
|
|
|
1276
1503
|
if (!(root.exportName in exports)) throw registryGraphError(`Family registry ${root.file} does not export "${root.exportName}".`);
|
|
1277
1504
|
}
|
|
1278
1505
|
}
|
|
1506
|
+
/**
|
|
1507
|
+
* Resolve inherited source with exactly the loader's extension precedence.
|
|
1508
|
+
* This reads module locations only; icon discovery never executes a second load.
|
|
1509
|
+
* @param {string} specifier
|
|
1510
|
+
* @param {string} fromFile
|
|
1511
|
+
* @returns {string}
|
|
1512
|
+
*/
|
|
1513
|
+
function resolveThemeModule(specifier, fromFile) {
|
|
1514
|
+
return createJiti(fromFile, {extensions: THEME_MODULE_EXTENSIONS}).resolve(
|
|
1515
|
+
specifier,
|
|
1516
|
+
);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1279
1519
|
/**
|
|
1280
1520
|
* Errors that mean "the synchronous loader cannot evaluate this module", as
|
|
1281
1521
|
* opposed to "this module is broken". Only the former may fall back to the
|
|
@@ -1323,7 +1563,7 @@ function isSyncLoaderLimitation(error) {
|
|
|
1323
1563
|
*
|
|
1324
1564
|
* @param {string} filePath
|
|
1325
1565
|
* @param {import('./core-interception.mjs').CoreInterception} [interception]
|
|
1326
|
-
* @returns {Promise<{theme: any, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
1566
|
+
* @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
1327
1567
|
*/
|
|
1328
1568
|
// prettier-ignore
|
|
1329
1569
|
async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined) {
|
|
@@ -1373,12 +1613,14 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
1373
1613
|
mod = await jiti.import(filePath, {default: true});
|
|
1374
1614
|
}
|
|
1375
1615
|
|
|
1376
|
-
if (isThemeObject(mod)) return {theme: mod, degraded};
|
|
1616
|
+
if (isThemeObject(mod)) return {theme: mod, exportName: 'default', degraded};
|
|
1377
1617
|
|
|
1378
1618
|
if (mod && typeof mod === 'object') {
|
|
1379
|
-
if (isThemeObject(mod.default))
|
|
1380
|
-
|
|
1381
|
-
|
|
1619
|
+
if (isThemeObject(mod.default)) {
|
|
1620
|
+
return {theme: mod.default, exportName: 'default', degraded};
|
|
1621
|
+
}
|
|
1622
|
+
for (const [exportName, value] of Object.entries(mod)) {
|
|
1623
|
+
if (isThemeObject(value)) return {theme: value, exportName, degraded};
|
|
1382
1624
|
}
|
|
1383
1625
|
}
|
|
1384
1626
|
|
|
@@ -1412,7 +1654,7 @@ function isThemeObject(value) {
|
|
|
1412
1654
|
*
|
|
1413
1655
|
* @param {string} filePath
|
|
1414
1656
|
* @param {import('./core-interception.mjs').CoreInterception} [interception]
|
|
1415
|
-
* @returns {Promise<{theme: any, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
1657
|
+
* @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
1416
1658
|
*/
|
|
1417
1659
|
// prettier-ignore
|
|
1418
1660
|
async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined) {
|
|
@@ -1434,9 +1676,51 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
|
|
|
1434
1676
|
}
|
|
1435
1677
|
}
|
|
1436
1678
|
|
|
1679
|
+
/**
|
|
1680
|
+
* Load one theme through the build's real module loader and validate the raw
|
|
1681
|
+
* input captured from its defineTheme lineage. Used by doctor so it applies the
|
|
1682
|
+
* same direct-input rule as theme build without mistaking compiler output for
|
|
1683
|
+
* authored input.
|
|
1684
|
+
*
|
|
1685
|
+
* @param {string} file
|
|
1686
|
+
* @param {{cwd?: string}} [ctx]
|
|
1687
|
+
* @returns {Promise<string[]>}
|
|
1688
|
+
*/
|
|
1689
|
+
export async function validateThemePrivateInputs(
|
|
1690
|
+
file,
|
|
1691
|
+
{cwd = process.cwd()} = {},
|
|
1692
|
+
) {
|
|
1693
|
+
const filePath = path.resolve(cwd, file);
|
|
1694
|
+
if (!fs.existsSync(filePath)) {
|
|
1695
|
+
throw new AstryxError(
|
|
1696
|
+
`File not found: ${filePath}`,
|
|
1697
|
+
undefined,
|
|
1698
|
+
ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
1699
|
+
);
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
const interception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
1703
|
+
let theme;
|
|
1704
|
+
try {
|
|
1705
|
+
theme = (await extractThemeDefinition(filePath, interception)).theme;
|
|
1706
|
+
} catch (error) {
|
|
1707
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1708
|
+
throw new AstryxError(message, undefined, ERROR_CODES.ERR_THEME_LOAD);
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
const inputs = interception.lineageOf(theme);
|
|
1712
|
+
try {
|
|
1713
|
+
return [...new Set(inputs.flatMap(input => validatePrivateVars(input)))];
|
|
1714
|
+
} finally {
|
|
1715
|
+
interception.strip(theme);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1437
1719
|
/**
|
|
1438
1720
|
* Fallback extraction via regex + eval.
|
|
1439
1721
|
* Only works for plain object literals — can't follow imports or variables.
|
|
1722
|
+
* Never erase icon references: an unresolved registry must preserve the loader
|
|
1723
|
+
* error instead of turning an incomplete theme into a successful build.
|
|
1440
1724
|
* @param {string} filePath
|
|
1441
1725
|
* @returns {any}
|
|
1442
1726
|
*/
|
|
@@ -1458,10 +1742,6 @@ function extractThemeDefinitionLegacy(filePath) {
|
|
|
1458
1742
|
|
|
1459
1743
|
let objStr = defineMatch[1];
|
|
1460
1744
|
objStr = objStr.replace(/\s+as\s+const/g, '');
|
|
1461
|
-
objStr = objStr.replace(
|
|
1462
|
-
/icons:\s*[a-zA-Z_][a-zA-Z0-9_]*/g,
|
|
1463
|
-
'icons: undefined',
|
|
1464
|
-
);
|
|
1465
1745
|
|
|
1466
1746
|
try {
|
|
1467
1747
|
return eval(`(${objStr})`);
|
|
@@ -1476,30 +1756,19 @@ function extractThemeDefinitionLegacy(filePath) {
|
|
|
1476
1756
|
}
|
|
1477
1757
|
|
|
1478
1758
|
/**
|
|
1479
|
-
* Extract
|
|
1480
|
-
* Returns { importPath, exportName } or null
|
|
1759
|
+
* Extract a family member's named registry import from its source file.
|
|
1760
|
+
* Returns { importPath, exportName } or null when the theme names none.
|
|
1761
|
+
* Standalone builds resolve icons through `resolveIconImports` instead.
|
|
1481
1762
|
*
|
|
1482
1763
|
* Looks for patterns like:
|
|
1483
1764
|
* import { defaultIconRegistry } from './icons';
|
|
1484
1765
|
* icons: defaultIconRegistry,
|
|
1485
1766
|
* @param {string} filePath
|
|
1767
|
+
* @param {'icons' | 'indicators'} field
|
|
1486
1768
|
* @returns {{exportName: string, importPath: string} | null}
|
|
1487
1769
|
*/
|
|
1488
|
-
function extractRegistryInfo(filePath, field
|
|
1770
|
+
function extractRegistryInfo(filePath, field) {
|
|
1489
1771
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
1490
|
-
if (!familyMode) {
|
|
1491
|
-
const fieldMatch = content.match(
|
|
1492
|
-
new RegExp(`${field}:\\s*([a-zA-Z_][a-zA-Z0-9_]*)`),
|
|
1493
|
-
);
|
|
1494
|
-
if (!fieldMatch) return null;
|
|
1495
|
-
const varName = fieldMatch[1];
|
|
1496
|
-
const match = content.match(
|
|
1497
|
-
new RegExp(
|
|
1498
|
-
`import\\s*{[^}]*\\b${varName}\\b[^}]*}\\s*from\\s*['"]([^'"]+)['"]`,
|
|
1499
|
-
),
|
|
1500
|
-
);
|
|
1501
|
-
return match ? {exportName: varName, importPath: match[1]} : null;
|
|
1502
|
-
}
|
|
1503
1772
|
const defineIndex = content.indexOf('defineTheme(');
|
|
1504
1773
|
if (defineIndex < 0) return null;
|
|
1505
1774
|
const themeSource = content.slice(defineIndex);
|
|
@@ -1539,17 +1808,18 @@ function extractRegistryInfo(filePath, field = 'icons', familyMode = false) {
|
|
|
1539
1808
|
* override it had.
|
|
1540
1809
|
*
|
|
1541
1810
|
* The icon registry is imported rather than inlined because it holds React
|
|
1542
|
-
* elements, which cannot be serialized. `
|
|
1543
|
-
*
|
|
1811
|
+
* elements, which cannot be serialized. `resolveIconImports` reads actual
|
|
1812
|
+
* imports from the selected theme's source, where extensionless `./icons` uses
|
|
1544
1813
|
* the TypeScript resolver — but the artifact here is ESM JavaScript, which
|
|
1545
1814
|
* requires a fully specified path. Only the caller knows what its own build
|
|
1546
1815
|
* will emit and under what name, so `iconsSpecifier` lets it say. When it is
|
|
1547
|
-
* not given,
|
|
1816
|
+
* not given, direct registry specifiers are preserved, and inherited relative
|
|
1817
|
+
* imports are rebased from the base module to the theme entry's directory.
|
|
1548
1818
|
*
|
|
1549
1819
|
* @param {any} themeDef
|
|
1550
|
-
* @param {
|
|
1551
|
-
* @param {string} [iconsSpecifier] - Overrides the
|
|
1552
|
-
* @param {{themeBinding?: string,
|
|
1820
|
+
* @param {import('./icon-imports.mjs').IconImports | null} iconInfo
|
|
1821
|
+
* @param {string} [iconsSpecifier] - Overrides the selected registry specifier.
|
|
1822
|
+
* @param {{themeBinding?: string, iconsExpression?: string, indicatorsExpression?: string, artifactBaseName?: string, exportIcons?: boolean}} [moduleOptions]
|
|
1553
1823
|
* @returns {string}
|
|
1554
1824
|
*/
|
|
1555
1825
|
function generateBuiltModule(
|
|
@@ -1560,29 +1830,46 @@ function generateBuiltModule(
|
|
|
1560
1830
|
) {
|
|
1561
1831
|
const themeBinding =
|
|
1562
1832
|
moduleOptions.themeBinding ?? `${toIdentifier(themeDef.name)}Theme`;
|
|
1563
|
-
const iconBinding = moduleOptions.iconBinding ?? iconInfo?.exportName;
|
|
1564
1833
|
const artifactBaseName = moduleOptions.artifactBaseName ?? themeDef.name;
|
|
1565
1834
|
const exportIcons = moduleOptions.exportIcons ?? true;
|
|
1566
|
-
//
|
|
1567
|
-
//
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1835
|
+
// Keep ordinary direct named imports byte-compatible, while encoding paths
|
|
1836
|
+
// with quotes/escapes and retaining default, namespace, and aliased bindings.
|
|
1837
|
+
const iconImport = (iconInfo?.imports ?? [])
|
|
1838
|
+
.map(({importPath, importedName, localName}) => {
|
|
1839
|
+
const overridden =
|
|
1840
|
+
iconsSpecifier !== undefined &&
|
|
1841
|
+
importPath === iconInfo?.iconsSpecifierImportPath &&
|
|
1842
|
+
localName === iconInfo?.iconsSpecifierLocalName;
|
|
1843
|
+
const specifier = overridden
|
|
1844
|
+
? JSON.stringify(iconsSpecifier)
|
|
1845
|
+
: /['\\\r\n]/u.test(importPath)
|
|
1846
|
+
? JSON.stringify(importPath)
|
|
1847
|
+
: `'${importPath}'`;
|
|
1848
|
+
const imported = /^[$\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u.test(
|
|
1849
|
+
importedName,
|
|
1850
|
+
)
|
|
1851
|
+
? importedName
|
|
1852
|
+
: JSON.stringify(importedName);
|
|
1853
|
+
const binding =
|
|
1854
|
+
importedName === 'default'
|
|
1855
|
+
? localName
|
|
1856
|
+
: importedName === '*'
|
|
1857
|
+
? `* as ${localName}`
|
|
1858
|
+
: `{ ${imported}${importedName === localName ? '' : ` as ${localName}`} }`;
|
|
1859
|
+
return `import ${binding} from ${specifier};\n`;
|
|
1860
|
+
})
|
|
1861
|
+
.join('');
|
|
1862
|
+
const iconDeclaration =
|
|
1863
|
+
iconInfo && iconInfo.expression !== iconInfo.exportName
|
|
1864
|
+
? `const ${iconInfo.exportName} = ${iconInfo.expression};\n`
|
|
1865
|
+
: '';
|
|
1866
|
+
const iconsExpression = moduleOptions.iconsExpression ?? iconInfo?.exportName;
|
|
1578
1867
|
const iconsField = iconsExpression ? ` icons: ${iconsExpression},` : '';
|
|
1579
1868
|
const indicatorsField = moduleOptions.indicatorsExpression
|
|
1580
1869
|
? `\n indicators: ${moduleOptions.indicatorsExpression},`
|
|
1581
1870
|
: '';
|
|
1582
1871
|
const iconReExport =
|
|
1583
|
-
iconInfo && exportIcons
|
|
1584
|
-
? `\nexport { ${iconBinding}${iconBinding === iconInfo.exportName ? '' : ` as ${iconInfo.exportName}`} };\n`
|
|
1585
|
-
: '';
|
|
1872
|
+
iconInfo && exportIcons ? `\nexport { ${iconInfo.exportName} };\n` : '';
|
|
1586
1873
|
|
|
1587
1874
|
// Resolve token values — tuples become light-dark() strings
|
|
1588
1875
|
/** @type {Record<string, unknown>} */
|
|
@@ -1641,7 +1928,7 @@ function generateBuiltModule(
|
|
|
1641
1928
|
serializeField('__adaptations', themeDef.__adaptations) +
|
|
1642
1929
|
serializeField('__axes', themeDef.__axes ?? {}, true);
|
|
1643
1930
|
|
|
1644
|
-
return `${iconImport}/**
|
|
1931
|
+
return `${iconImport}${iconDeclaration}/**
|
|
1645
1932
|
* ${themeDef.name} theme — built by \`${getCliInvocation()} theme build\`
|
|
1646
1933
|
* Import the CSS file alongside this module:
|
|
1647
1934
|
*
|
|
@@ -1660,7 +1947,7 @@ ${iconReExport}`;
|
|
|
1660
1947
|
/**
|
|
1661
1948
|
* Generate TypeScript declarations for a built theme module.
|
|
1662
1949
|
* @param {any} themeDef
|
|
1663
|
-
* @param {{exportName: string
|
|
1950
|
+
* @param {{exportName: string} | null} iconInfo - The re-exported registry, if any.
|
|
1664
1951
|
* @param {string | null} variantsFileName
|
|
1665
1952
|
* @param {{themeBinding?: string, includeIconExport?: boolean, includeThemeImport?: boolean}} [typeOptions]
|
|
1666
1953
|
* @returns {string}
|
|
@@ -1835,48 +2122,6 @@ async function validateComponentOverrides(themeDef) {
|
|
|
1835
2122
|
: validateComponentOverridesAgainstRegistry(themeDef, knownComponents);
|
|
1836
2123
|
}
|
|
1837
2124
|
|
|
1838
|
-
/**
|
|
1839
|
-
* Validate that themes don't set private (--_*) CSS custom properties directly.
|
|
1840
|
-
* Private vars are internal implementation details managed by the derived var
|
|
1841
|
-
* expansion pipeline. Theme authors should write standard CSS properties
|
|
1842
|
-
* (e.g. borderRadius, padding) instead.
|
|
1843
|
-
*
|
|
1844
|
-
* Returns array of error strings.
|
|
1845
|
-
* @param {{components?: Record<string, Record<string, Record<string, unknown>>>}} themeDef
|
|
1846
|
-
* @returns {string[]}
|
|
1847
|
-
*/
|
|
1848
|
-
function validatePrivateVars(themeDef) {
|
|
1849
|
-
/** @type {string[]} */
|
|
1850
|
-
const errors = [];
|
|
1851
|
-
|
|
1852
|
-
for (const [component, rules] of themedComponentEntries(themeDef)) {
|
|
1853
|
-
for (const [key, styles] of Object.entries(rules)) {
|
|
1854
|
-
/**
|
|
1855
|
-
* @param {unknown} value
|
|
1856
|
-
* @param {string[]} [path]
|
|
1857
|
-
*/
|
|
1858
|
-
const visit = (value, path = []) => {
|
|
1859
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) return;
|
|
1860
|
-
for (const [prop, nested] of Object.entries(value)) {
|
|
1861
|
-
if (prop.startsWith('--_')) {
|
|
1862
|
-
errors.push(
|
|
1863
|
-
`Component "${component}" (${[key, ...path].join(' ')}) sets private var "${prop}". ` +
|
|
1864
|
-
`Private vars (--_*) are internal; use standard CSS properties ` +
|
|
1865
|
-
`(e.g. borderRadius, padding) instead. The pipeline expands them automatically.`,
|
|
1866
|
-
);
|
|
1867
|
-
}
|
|
1868
|
-
visit(nested, [...path, prop]);
|
|
1869
|
-
}
|
|
1870
|
-
};
|
|
1871
|
-
visit(styles);
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
// One entry per distinct message: a component declared both at the root and
|
|
1876
|
-
// in one or more adaptations would otherwise report the same problem twice.
|
|
1877
|
-
return [...new Set(errors)];
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
2125
|
const BUILTIN_HEADING_TYPES = new Set(['display-1', 'display-2', 'display-3']);
|
|
1881
2126
|
|
|
1882
2127
|
/**
|
|
@@ -2075,8 +2320,8 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
|
|
|
2075
2320
|
}
|
|
2076
2321
|
|
|
2077
2322
|
/**
|
|
2078
|
-
* Compile a defineTheme file to CSS + JS + .d.ts (and an
|
|
2079
|
-
* `.variants.d.ts`). Performs the writes and returns a `theme.build` receipt,
|
|
2323
|
+
* Compile a defineTheme file to CSS + CSS .d.ts + JS + JS .d.ts (and an
|
|
2324
|
+
* optional `.variants.d.ts`). Performs the writes and returns a `theme.build` receipt,
|
|
2080
2325
|
* or `null` when the theme produced no CSS (nothing to build). Throws
|
|
2081
2326
|
* AstryxError (stable code) on failure. Progress is emitted through the shared
|
|
2082
2327
|
* `logger` (silent by default).
|
|
@@ -2086,7 +2331,7 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
|
|
|
2086
2331
|
* `out` overrides the output CSS path; `check` compares against on-disk outputs
|
|
2087
2332
|
* instead of writing. `iconsSpecifier` overrides the icon registry import
|
|
2088
2333
|
* specifier in the generated module (e.g. `./icons.mjs`); when omitted, the
|
|
2089
|
-
*
|
|
2334
|
+
* direct registry specifiers from the theme source are emitted unchanged.
|
|
2090
2335
|
* @param {{cwd?: string}} [ctx]
|
|
2091
2336
|
* @returns {Promise<any>}
|
|
2092
2337
|
*/
|
|
@@ -2107,6 +2352,8 @@ async function themeBuildInternal(
|
|
|
2107
2352
|
|
|
2108
2353
|
logger.log(`\nBuilding theme from ${path.relative(cwd, filePath)}...`);
|
|
2109
2354
|
|
|
2355
|
+
await selectCore(cwd);
|
|
2356
|
+
|
|
2110
2357
|
// Standalone builds only need interception when an older Core could erase
|
|
2111
2358
|
// adaptations. Family preparation always supplies the same recorder as its
|
|
2112
2359
|
// shared loader so exact authored parent identity stays CLI-private instead
|
|
@@ -2119,6 +2366,8 @@ async function themeBuildInternal(
|
|
|
2119
2366
|
|
|
2120
2367
|
// Extract theme definition
|
|
2121
2368
|
let themeDef;
|
|
2369
|
+
/** The export actually selected by the loader, not the first AST match. */
|
|
2370
|
+
let themeExportName;
|
|
2122
2371
|
/** Paths through the load that interception could not fully observe. */
|
|
2123
2372
|
let loadDegradation;
|
|
2124
2373
|
try {
|
|
@@ -2128,6 +2377,7 @@ async function themeBuildInternal(
|
|
|
2128
2377
|
options.__familyLoader,
|
|
2129
2378
|
);
|
|
2130
2379
|
themeDef = loaded.theme;
|
|
2380
|
+
themeExportName = loaded.exportName;
|
|
2131
2381
|
loadDegradation = loaded.degraded;
|
|
2132
2382
|
} catch (e) {
|
|
2133
2383
|
const err = /** @type {Error} */ (e);
|
|
@@ -2193,6 +2443,25 @@ async function themeBuildInternal(
|
|
|
2193
2443
|
throw err;
|
|
2194
2444
|
}
|
|
2195
2445
|
|
|
2446
|
+
// A generated module must preserve the registry through an import: it may
|
|
2447
|
+
// contain React elements, which cannot be serialized. Validate before CSS
|
|
2448
|
+
// generation so neither the no-CSS return nor --check can bypass the error.
|
|
2449
|
+
// Family preparation keeps its own named-import registry contract, which
|
|
2450
|
+
// themeBuildFamily checks against the selected members' graph.
|
|
2451
|
+
const standaloneIcons = !options.__prepareFamily;
|
|
2452
|
+
const iconResolution = {
|
|
2453
|
+
readSource: (/** @type {string} */ file) => fs.readFileSync(file, 'utf8'),
|
|
2454
|
+
resolveModule: resolveThemeModule,
|
|
2455
|
+
reservedNames: [`${toIdentifier(themeDef.name)}Theme`],
|
|
2456
|
+
rawInput: 'extends' in themeDef,
|
|
2457
|
+
hasIcons:
|
|
2458
|
+
Object.keys(themeDef.icons ?? {}).length > 0 ||
|
|
2459
|
+
Object.keys(themeDef.extends?.icons ?? {}).length > 0,
|
|
2460
|
+
};
|
|
2461
|
+
let iconInfo = standaloneIcons
|
|
2462
|
+
? await resolveIconImports(filePath, themeExportName, iconResolution)
|
|
2463
|
+
: null;
|
|
2464
|
+
|
|
2196
2465
|
// Validate component overrides
|
|
2197
2466
|
const warnings = await validateComponentOverrides(themeDef);
|
|
2198
2467
|
const warningMessages = [];
|
|
@@ -2233,13 +2502,7 @@ async function themeBuildInternal(
|
|
|
2233
2502
|
// capability exports are checked against what the theme actually asks for.
|
|
2234
2503
|
if (!_defineTheme || !_generateThemeRulesSplit) {
|
|
2235
2504
|
throw new AstryxError(
|
|
2236
|
-
|
|
2237
|
-
'built, resolvable @astryxdesign/core so it emits the same CSS as the ' +
|
|
2238
|
-
'runtime <Theme>. Build @astryxdesign/core first (e.g. `pnpm -F @astryxdesign/core ' +
|
|
2239
|
-
'build`)' +
|
|
2240
|
-
(_coreImportError
|
|
2241
|
-
? `.\n Import error: ${_coreImportError.message}`
|
|
2242
|
-
: '.'),
|
|
2505
|
+
coreUnavailableMessage(cwd, _coreImportError),
|
|
2243
2506
|
undefined,
|
|
2244
2507
|
ERROR_CODES.ERR_CORE_NOT_FOUND,
|
|
2245
2508
|
);
|
|
@@ -2305,6 +2568,40 @@ async function themeBuildInternal(
|
|
|
2305
2568
|
resolvedTheme = themeDef;
|
|
2306
2569
|
}
|
|
2307
2570
|
|
|
2571
|
+
// Raw object exports can acquire icons only when Core resolves `extends`.
|
|
2572
|
+
// Recheck an unresolved provenance result before any generator runs.
|
|
2573
|
+
if (
|
|
2574
|
+
standaloneIcons &&
|
|
2575
|
+
!iconInfo &&
|
|
2576
|
+
Object.keys(resolvedTheme.icons ?? {}).length > 0
|
|
2577
|
+
) {
|
|
2578
|
+
iconInfo = await resolveIconImports(filePath, themeExportName, {
|
|
2579
|
+
...iconResolution,
|
|
2580
|
+
hasIcons: true,
|
|
2581
|
+
});
|
|
2582
|
+
}
|
|
2583
|
+
// An opaque package base can legitimately have no icons. Its .icons
|
|
2584
|
+
// reference is unnecessary; direct empty registry imports remain intact.
|
|
2585
|
+
if (
|
|
2586
|
+
iconInfo &&
|
|
2587
|
+
iconInfo.iconsSpecifierLocalName === undefined &&
|
|
2588
|
+
Object.keys(resolvedTheme.icons ?? {}).length === 0
|
|
2589
|
+
) {
|
|
2590
|
+
iconInfo = null;
|
|
2591
|
+
}
|
|
2592
|
+
if (
|
|
2593
|
+
iconInfo &&
|
|
2594
|
+
options.iconsSpecifier !== undefined &&
|
|
2595
|
+
iconInfo.iconsSpecifierImportPath === undefined
|
|
2596
|
+
) {
|
|
2597
|
+
throw new AstryxError(
|
|
2598
|
+
'The icon registry is inherited through a theme import. ' +
|
|
2599
|
+
'To use --icons-specifier, import the registry directly and set icons to that binding.',
|
|
2600
|
+
undefined,
|
|
2601
|
+
ERROR_CODES.ERR_THEME_INVALID,
|
|
2602
|
+
);
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2308
2605
|
// Cores that predate adaptations can still resolve typography, color,
|
|
2309
2606
|
// radius, and motion into root tokens, but they do not retain the raw axis
|
|
2310
2607
|
// inputs. Keep the effective metadata captured from the same defineTheme
|
|
@@ -2527,18 +2824,10 @@ async function themeBuildInternal(
|
|
|
2527
2824
|
// was left as orphaned half-built output. Stage-then-commit avoids
|
|
2528
2825
|
// that.
|
|
2529
2826
|
const outDir = path.dirname(outPath);
|
|
2827
|
+
const cssDtsPath = `${outPath}.d.ts`;
|
|
2530
2828
|
const jsPath = path.join(outDir, `${baseName}.js`);
|
|
2531
2829
|
const dtsPath = path.join(outDir, `${baseName}.d.ts`);
|
|
2532
2830
|
|
|
2533
|
-
const iconInfo = extractRegistryInfo(
|
|
2534
|
-
filePath,
|
|
2535
|
-
'icons',
|
|
2536
|
-
options.__prepareFamily,
|
|
2537
|
-
);
|
|
2538
|
-
const indicatorInfo = options.__prepareFamily
|
|
2539
|
-
? extractRegistryInfo(filePath, 'indicators', true)
|
|
2540
|
-
: null;
|
|
2541
|
-
|
|
2542
2831
|
// Type augmentation .d.ts if theme has custom prop values. Computed
|
|
2543
2832
|
// before the main .d.ts so the latter can reference it (see below).
|
|
2544
2833
|
const augmentationSource = resolvedTheme || themeDef;
|
|
@@ -2559,6 +2848,9 @@ async function themeBuildInternal(
|
|
|
2559
2848
|
// importing the theme also loads the custom-variant augmentations.
|
|
2560
2849
|
const cssContent =
|
|
2561
2850
|
generatedHeader(sourceRelative, 'css', buildCommand, versions) + css;
|
|
2851
|
+
const cssDtsContent =
|
|
2852
|
+
generatedHeader(sourceRelative, 'ts', buildCommand, versions) +
|
|
2853
|
+
'export {};\n';
|
|
2562
2854
|
const jsContent =
|
|
2563
2855
|
generatedHeader(sourceRelative, 'js', buildCommand, versions) +
|
|
2564
2856
|
generateBuiltModule(
|
|
@@ -2586,8 +2878,8 @@ async function themeBuildInternal(
|
|
|
2586
2878
|
theme: displayTheme,
|
|
2587
2879
|
sourceTheme: themeDef,
|
|
2588
2880
|
sourceParent,
|
|
2589
|
-
iconInfo,
|
|
2590
|
-
indicatorInfo,
|
|
2881
|
+
iconInfo: extractRegistryInfo(filePath, 'icons'),
|
|
2882
|
+
indicatorInfo: extractRegistryInfo(filePath, 'indicators'),
|
|
2591
2883
|
variantDecl,
|
|
2592
2884
|
css: cssPlan,
|
|
2593
2885
|
versions,
|
|
@@ -2600,6 +2892,7 @@ async function themeBuildInternal(
|
|
|
2600
2892
|
|
|
2601
2893
|
const writes = [
|
|
2602
2894
|
{dest: outPath, content: cssContent},
|
|
2895
|
+
{dest: cssDtsPath, content: cssDtsContent, allowMissingInCheck: true},
|
|
2603
2896
|
{dest: jsPath, content: jsContent},
|
|
2604
2897
|
{dest: dtsPath, content: dtsContent},
|
|
2605
2898
|
];
|
|
@@ -2633,7 +2926,7 @@ async function themeBuildInternal(
|
|
|
2633
2926
|
name: themeDef.name,
|
|
2634
2927
|
upToDate,
|
|
2635
2928
|
stale,
|
|
2636
|
-
checked: writes
|
|
2929
|
+
checked: checkedBuildOutputs(writes, cwd),
|
|
2637
2930
|
},
|
|
2638
2931
|
};
|
|
2639
2932
|
}
|
|
@@ -2641,6 +2934,7 @@ async function themeBuildInternal(
|
|
|
2641
2934
|
writeBuildOutputs(writes);
|
|
2642
2935
|
|
|
2643
2936
|
logger.log(`\n[ok] ${path.relative(cwd, outPath)}`);
|
|
2937
|
+
logger.log(`[ok] ${path.relative(cwd, cssDtsPath)}`);
|
|
2644
2938
|
logger.log(
|
|
2645
2939
|
` ${tokenCount} token overrides, ${componentCount} component overrides`,
|
|
2646
2940
|
);
|
|
@@ -2709,6 +3003,7 @@ Or with a <link> tag:
|
|
|
2709
3003
|
sizeKB: parseFloat(size),
|
|
2710
3004
|
outputs: {
|
|
2711
3005
|
css: path.relative(cwd, outPath),
|
|
3006
|
+
cssDts: path.relative(cwd, cssDtsPath),
|
|
2712
3007
|
js: path.relative(cwd, jsPath),
|
|
2713
3008
|
dts: path.relative(cwd, dtsPath),
|
|
2714
3009
|
...(variantDecl && variantDtsPath
|
|
@@ -2807,6 +3102,7 @@ export async function themeBuildFamily(
|
|
|
2807
3102
|
error instanceof Error ? error.message : 'Invalid family key.';
|
|
2808
3103
|
throw new AstryxError(message, undefined, ERROR_CODES.ERR_THEME_INVALID);
|
|
2809
3104
|
}
|
|
3105
|
+
await selectCore(cwd);
|
|
2810
3106
|
const familyInterception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
2811
3107
|
// prettier-ignore
|
|
2812
3108
|
const familyLoader = createJiti(import.meta.url, {moduleCache: true, interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
|
|
@@ -2873,6 +3169,7 @@ export async function themeBuildFamily(
|
|
|
2873
3169
|
const root = members[0];
|
|
2874
3170
|
const outDir = path.dirname(root.filePath);
|
|
2875
3171
|
const outPath = path.join(outDir, `${baseName}.css`);
|
|
3172
|
+
const cssDtsPath = `${outPath}.d.ts`;
|
|
2876
3173
|
const jsPath = path.join(outDir, `${baseName}.js`);
|
|
2877
3174
|
const dtsPath = path.join(outDir, `${baseName}.d.ts`);
|
|
2878
3175
|
const sources = new Set(
|
|
@@ -2882,7 +3179,7 @@ export async function themeBuildFamily(
|
|
|
2882
3179
|
),
|
|
2883
3180
|
),
|
|
2884
3181
|
);
|
|
2885
|
-
const collision = [outPath, jsPath, dtsPath].find(output => {
|
|
3182
|
+
const collision = [outPath, cssDtsPath, jsPath, dtsPath].find(output => {
|
|
2886
3183
|
const candidates = [path.resolve(output)];
|
|
2887
3184
|
if (fs.existsSync(output)) candidates.push(fs.realpathSync(output));
|
|
2888
3185
|
return candidates.some(value => sources.has(value.toLowerCase()));
|
|
@@ -2930,11 +3227,14 @@ export async function themeBuildFamily(
|
|
|
2930
3227
|
const indicatorImport = indicator.info
|
|
2931
3228
|
? `import { ${indicator.info.exportName} as ${ownIndicators} } from ${JSON.stringify(indicator.specifier ?? indicator.info.importPath)};\n`
|
|
2932
3229
|
: '';
|
|
3230
|
+
// The member's own registry import, bound to its family-unique name; a
|
|
3231
|
+
// rebased or overridden specifier replaces the scraped one.
|
|
3232
|
+
// prettier-ignore
|
|
3233
|
+
const iconImports = icon.info && ownIcons ? {imports: [{importPath: icon.info.importPath, importedName: icon.info.exportName, localName: ownIcons}], expression: ownIcons, exportName: ownIcons, iconsSpecifierImportPath: icon.info.importPath, iconsSpecifierLocalName: ownIcons} : null;
|
|
2933
3234
|
return (
|
|
2934
3235
|
indicatorImport +
|
|
2935
|
-
generateBuiltModule(member.theme,
|
|
3236
|
+
generateBuiltModule(member.theme, iconImports, icon.specifier, {
|
|
2936
3237
|
themeBinding,
|
|
2937
|
-
iconBinding: ownIcons ?? undefined,
|
|
2938
3238
|
iconsExpression: expression(ownIcons, inheritedIcons),
|
|
2939
3239
|
indicatorsExpression: expression(ownIndicators, inheritedIndicators),
|
|
2940
3240
|
artifactBaseName: baseName,
|
|
@@ -2963,6 +3263,13 @@ export async function themeBuildFamily(
|
|
|
2963
3263
|
generatedHeader(sourceRelative, 'css', buildCommand, root.versions) +
|
|
2964
3264
|
css,
|
|
2965
3265
|
},
|
|
3266
|
+
{
|
|
3267
|
+
dest: cssDtsPath,
|
|
3268
|
+
allowMissingInCheck: true,
|
|
3269
|
+
content:
|
|
3270
|
+
generatedHeader(sourceRelative, 'ts', buildCommand, root.versions) +
|
|
3271
|
+
'export {};\n',
|
|
3272
|
+
},
|
|
2966
3273
|
{
|
|
2967
3274
|
dest: jsPath,
|
|
2968
3275
|
content:
|
|
@@ -2978,6 +3285,7 @@ export async function themeBuildFamily(
|
|
|
2978
3285
|
];
|
|
2979
3286
|
const outputs = {
|
|
2980
3287
|
css: path.relative(cwd, outPath),
|
|
3288
|
+
cssDts: path.relative(cwd, cssDtsPath),
|
|
2981
3289
|
js: path.relative(cwd, jsPath),
|
|
2982
3290
|
dts: path.relative(cwd, dtsPath),
|
|
2983
3291
|
};
|
|
@@ -3005,7 +3313,7 @@ export async function themeBuildFamily(
|
|
|
3005
3313
|
name: root.theme.name,
|
|
3006
3314
|
upToDate,
|
|
3007
3315
|
stale,
|
|
3008
|
-
checked: writes
|
|
3316
|
+
checked: checkedBuildOutputs(writes, cwd),
|
|
3009
3317
|
},
|
|
3010
3318
|
};
|
|
3011
3319
|
}
|