@astryxdesign/cli 0.6.5 → 0.6.6-canary.0d27f83
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 +91 -88
- package/api/build/_adapter.d.mts +70 -2
- package/api/build/_adapter.mjs +122 -10
- package/api/build/build.doc.mjs +3 -3
- package/api/build/build.test.mjs +111 -2
- package/api/build/build.type.d.mts +12 -0
- package/api/build/build.type.mjs +3 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +110 -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 +50 -0
- package/api/doctor/_adapter.mjs +190 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +8 -123
- package/api/doctor/theme-checks.d.mts +24 -0
- package/api/doctor/theme-checks.mjs +1231 -0
- package/api/doctor/theme-checks.test.mjs +667 -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 +11 -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/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +13 -7
- package/api/layout/expand/expand.receipt.test.mjs +74 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layout.type.d.mts +1 -0
- package/api/layout/layout.type.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +2 -2
- package/api/layout/layoutGrammar.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 +27 -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 +17 -0
- package/api/template/template.type.mjs +8 -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 +120 -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 +667 -195
- package/api/theme/build/build.project-core.test.mjs +165 -0
- package/api/theme/build/build.test.mjs +220 -1
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- 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 +166 -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-overview.doc.mjs +211 -0
- 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 +52 -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 +212 -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/page.tsx +1 -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 +11 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +346 -47
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +8 -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 +383 -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 +26 -52
- 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 +28 -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 +2 -0
- package/clients/cli/commands/layout-expand.doc.mjs +5 -1
- package/clients/cli/commands/layout-grammar.doc.mjs +2 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +2 -0
- package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
- package/clients/cli/commands/layout.mjs +56 -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 +69 -19
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
- package/clients/cli/commands/template.mjs +71 -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 +135 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- 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.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/commands/write-failure.test.mjs +175 -0
- package/clients/cli/index.mjs +5 -2
- package/clients/cli/lib/component-format.mjs +19 -2
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- 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 +34 -28
- package/foundation/agent-docs/agent-docs.test.mjs +1181 -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/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- 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/env/package-manager.d.mts +28 -8
- package/foundation/env/package-manager.mjs +49 -10
- package/foundation/env/package-manager.test.mjs +93 -1
- 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 +52 -37
- 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';
|
|
@@ -60,9 +74,14 @@ import {
|
|
|
60
74
|
collectThemingTargets,
|
|
61
75
|
targetValidationRegistry,
|
|
62
76
|
} from '../../../foundation/discovery/theming-targets.mjs';
|
|
63
|
-
import {
|
|
77
|
+
import {
|
|
78
|
+
collectUnloadedFonts,
|
|
79
|
+
formatBatchFontLoadingHelp,
|
|
80
|
+
formatFontLoadingHelp,
|
|
81
|
+
} from './font-warning.mjs';
|
|
64
82
|
import {interceptCore} from './core-interception.mjs';
|
|
65
83
|
import {generateFamilyCSS, resolveThemeFamily} from './family.mjs';
|
|
84
|
+
import {resolveIconImports} from './icon-imports.mjs';
|
|
66
85
|
|
|
67
86
|
// Import shared theme processing from core. `astryx theme build` MUST produce the
|
|
68
87
|
// exact same CSS as the `<Theme>` runtime, so it has exactly one generation
|
|
@@ -125,6 +144,232 @@ try {
|
|
|
125
144
|
_coreImportError = e;
|
|
126
145
|
}
|
|
127
146
|
|
|
147
|
+
/**
|
|
148
|
+
* The bindings one Core provides: the namespaces interception spreads, the
|
|
149
|
+
* functions the build calls, and why the import failed, if it did.
|
|
150
|
+
* @typedef {{
|
|
151
|
+
* themeModule: any,
|
|
152
|
+
* rootModule: any,
|
|
153
|
+
* importError: any,
|
|
154
|
+
* defineTheme: any,
|
|
155
|
+
* generateThemeRulesSplit: any,
|
|
156
|
+
* generateOnMediaCSS: any,
|
|
157
|
+
* generateAdaptationCSS: any,
|
|
158
|
+
* dataTokenDefaults: any,
|
|
159
|
+
* }} CoreBindings
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The bindings exactly as the CLI's own import left them, kept so each build
|
|
164
|
+
* can choose between them and the project's installed Core.
|
|
165
|
+
* @type {CoreBindings}
|
|
166
|
+
*/
|
|
167
|
+
const _cliCore = {
|
|
168
|
+
themeModule: _coreThemeModule,
|
|
169
|
+
rootModule: _coreRootModule,
|
|
170
|
+
importError: _coreImportError,
|
|
171
|
+
defineTheme: _defineTheme,
|
|
172
|
+
generateThemeRulesSplit: _generateThemeRulesSplit,
|
|
173
|
+
generateOnMediaCSS: _generateOnMediaCSS,
|
|
174
|
+
generateAdaptationCSS: _generateAdaptationCSS,
|
|
175
|
+
dataTokenDefaults: _dataTokenDefaults,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Point the build at one Core: the module-level bindings every step reads.
|
|
180
|
+
* @param {CoreBindings} core
|
|
181
|
+
*/
|
|
182
|
+
function setCore(core) {
|
|
183
|
+
_coreThemeModule = core.themeModule;
|
|
184
|
+
_coreRootModule = core.rootModule;
|
|
185
|
+
_coreImportError = core.importError;
|
|
186
|
+
_defineTheme = core.defineTheme;
|
|
187
|
+
_generateThemeRulesSplit = core.generateThemeRulesSplit;
|
|
188
|
+
_generateOnMediaCSS = core.generateOnMediaCSS;
|
|
189
|
+
_generateAdaptationCSS = core.generateAdaptationCSS;
|
|
190
|
+
_dataTokenDefaults = core.dataTokenDefaults;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The file an `import` of `subpath` reaches through a package's `exports` map,
|
|
195
|
+
* or null when the map has no entry for it. Conditions are taken in the map's
|
|
196
|
+
* own order, as Node does, accepting the ones an import matches here: `node`,
|
|
197
|
+
* `import`, and `default` (so `source` and `types` are skipped).
|
|
198
|
+
*
|
|
199
|
+
* @param {string} dir - The package directory.
|
|
200
|
+
* @param {string} subpath - `'.'` or a subpath such as `'./theme'`.
|
|
201
|
+
* @returns {string|null}
|
|
202
|
+
*/
|
|
203
|
+
function importTarget(dir, subpath) {
|
|
204
|
+
let pkg;
|
|
205
|
+
try {
|
|
206
|
+
pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
|
|
207
|
+
} catch {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
const map = pkg?.exports;
|
|
211
|
+
const bySubpath =
|
|
212
|
+
map &&
|
|
213
|
+
typeof map === 'object' &&
|
|
214
|
+
!Array.isArray(map) &&
|
|
215
|
+
Object.keys(map).some(key => key.startsWith('.'));
|
|
216
|
+
const entry = bySubpath ? map[subpath] : subpath === '.' ? map : undefined;
|
|
217
|
+
/** @param {any} value @returns {string|null} */
|
|
218
|
+
const pick = value => {
|
|
219
|
+
if (typeof value === 'string') return value;
|
|
220
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
221
|
+
return null;
|
|
222
|
+
for (const [condition, target] of Object.entries(value)) {
|
|
223
|
+
if (
|
|
224
|
+
condition !== 'node' &&
|
|
225
|
+
condition !== 'import' &&
|
|
226
|
+
condition !== 'default'
|
|
227
|
+
)
|
|
228
|
+
continue;
|
|
229
|
+
const picked = pick(target);
|
|
230
|
+
if (picked) return picked;
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
};
|
|
234
|
+
const target = pick(entry);
|
|
235
|
+
return target ? path.resolve(dir, target) : null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** @param {string} file @returns {string} its real path, or itself */
|
|
239
|
+
function realOrSelf(file) {
|
|
240
|
+
try {
|
|
241
|
+
return fs.realpathSync(file);
|
|
242
|
+
} catch {
|
|
243
|
+
return file;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* The Core the project at `cwd` installed, when it differs from the one the
|
|
249
|
+
* CLI's own import found and loads. The app's `<Theme>` runs on the app's
|
|
250
|
+
* Core, so building with it keeps the CSS identical; and a CLI run one-off
|
|
251
|
+
* (`npx @astryxdesign/cli`) has no Core beside it at all. Null when there is
|
|
252
|
+
* nothing better than the CLI's own import: no installed Core (the Astryx
|
|
253
|
+
* repository, a bare directory), the same Core, or one that does not load.
|
|
254
|
+
*
|
|
255
|
+
* @param {string} cwd
|
|
256
|
+
* @returns {Promise<CoreBindings | null>}
|
|
257
|
+
*/
|
|
258
|
+
async function loadProjectCore(cwd) {
|
|
259
|
+
const dir = findInstalledPackage(cwd, '@astryxdesign/core');
|
|
260
|
+
const themeFile = dir ? importTarget(dir, './theme') : null;
|
|
261
|
+
if (!dir || !themeFile) return null;
|
|
262
|
+
if (_cliCore.themeModule) {
|
|
263
|
+
try {
|
|
264
|
+
const own = fileURLToPath(
|
|
265
|
+
import.meta.resolve('@astryxdesign/core/theme'),
|
|
266
|
+
);
|
|
267
|
+
if (realOrSelf(own) === realOrSelf(themeFile)) return null;
|
|
268
|
+
} catch {
|
|
269
|
+
// The CLI's own Core cannot be located; load the project's.
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
let themeModule;
|
|
273
|
+
try {
|
|
274
|
+
themeModule = await import(pathToFileURL(themeFile).href);
|
|
275
|
+
} catch {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
if (!themeModule.defineTheme || !themeModule.generateThemeRulesSplit)
|
|
279
|
+
return null;
|
|
280
|
+
let rootModule = null;
|
|
281
|
+
const rootFile = importTarget(dir, '.');
|
|
282
|
+
if (rootFile) {
|
|
283
|
+
try {
|
|
284
|
+
rootModule = await import(pathToFileURL(rootFile).href);
|
|
285
|
+
} catch {
|
|
286
|
+
// As with the CLI's own import, the theme namespace stands in for it.
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
themeModule,
|
|
291
|
+
rootModule,
|
|
292
|
+
importError: null,
|
|
293
|
+
defineTheme: themeModule.defineTheme,
|
|
294
|
+
generateThemeRulesSplit: themeModule.generateThemeRulesSplit,
|
|
295
|
+
generateOnMediaCSS: themeModule.generateOnMediaCSS,
|
|
296
|
+
generateAdaptationCSS: themeModule.generateAdaptationCSS,
|
|
297
|
+
dataTokenDefaults: themeModule.dataTokenDefaults,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** @type {Map<string, Awaited<ReturnType<typeof loadProjectCore>>>} */
|
|
302
|
+
const _projectCores = new Map();
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Choose the Core this build generates with: the project's installed one when
|
|
306
|
+
* {@link loadProjectCore} finds it, else the CLI's own.
|
|
307
|
+
* @param {string} cwd
|
|
308
|
+
*/
|
|
309
|
+
async function selectCore(cwd) {
|
|
310
|
+
if (!_projectCores.has(cwd))
|
|
311
|
+
_projectCores.set(cwd, await loadProjectCore(cwd));
|
|
312
|
+
setCore(_projectCores.get(cwd) ?? _cliCore);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Whether `cwd` sits in the Astryx repository, where Core is built from
|
|
317
|
+
* source rather than installed.
|
|
318
|
+
* @param {string} cwd
|
|
319
|
+
*/
|
|
320
|
+
function inAstryxRepository(cwd) {
|
|
321
|
+
let dir = cwd;
|
|
322
|
+
for (let i = 0; i < 6; i++) {
|
|
323
|
+
try {
|
|
324
|
+
const pkg = JSON.parse(
|
|
325
|
+
fs.readFileSync(
|
|
326
|
+
path.join(dir, 'packages', 'core', 'package.json'),
|
|
327
|
+
'utf-8',
|
|
328
|
+
),
|
|
329
|
+
);
|
|
330
|
+
if (pkg?.name === '@astryxdesign/core') return true;
|
|
331
|
+
} catch {
|
|
332
|
+
// Not here; keep walking up.
|
|
333
|
+
}
|
|
334
|
+
const parent = path.dirname(dir);
|
|
335
|
+
if (parent === dir) break;
|
|
336
|
+
dir = parent;
|
|
337
|
+
}
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Why `theme build` has no Core to generate with, and the fix for where it
|
|
343
|
+
* ran: the Astryx repository builds Core, an app installs it, and an installed
|
|
344
|
+
* Core that will not load is named.
|
|
345
|
+
*
|
|
346
|
+
* @param {string} cwd
|
|
347
|
+
* @param {any} importError - Why the import failed, when it threw.
|
|
348
|
+
* @returns {string}
|
|
349
|
+
*/
|
|
350
|
+
export function coreUnavailableMessage(cwd, importError) {
|
|
351
|
+
const why =
|
|
352
|
+
'`astryx theme build` generates CSS with @astryxdesign/core, the same code the runtime <Theme> uses';
|
|
353
|
+
const detail = importError ? `\n Import error: ${importError.message}` : '';
|
|
354
|
+
if (inAstryxRepository(cwd)) {
|
|
355
|
+
return (
|
|
356
|
+
`Could not load @astryxdesign/core/theme: ${why}. Build @astryxdesign/core ` +
|
|
357
|
+
`first (e.g. \`pnpm -F @astryxdesign/core build\`).${detail}`
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
const installed = findInstalledPackage(cwd, '@astryxdesign/core');
|
|
361
|
+
if (installed) {
|
|
362
|
+
return (
|
|
363
|
+
`Could not load the @astryxdesign/core installed at ` +
|
|
364
|
+
`${path.relative(cwd, installed) || '.'}: ${why}. Reinstall it.${detail}`
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
return (
|
|
368
|
+
`This project does not have @astryxdesign/core installed: ${why}. Install ` +
|
|
369
|
+
`it: \`npm install @astryxdesign/core\` (or yarn/pnpm/bun).${detail}`
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
|
|
128
373
|
/**
|
|
129
374
|
* Read a package's `version` from a resolved directory. Returns `'unknown'`
|
|
130
375
|
* when it can't be read so the header always has a value.
|
|
@@ -194,7 +439,7 @@ function generatedHeader(sourceFile, lang = 'js', command, versions) {
|
|
|
194
439
|
* @param {string} content
|
|
195
440
|
* @returns {string}
|
|
196
441
|
*/
|
|
197
|
-
function
|
|
442
|
+
export function normalizeThemeBuildForCompare(content) {
|
|
198
443
|
return content
|
|
199
444
|
.split('\n')
|
|
200
445
|
.filter(line => {
|
|
@@ -204,24 +449,36 @@ function normalizeForCompare(content) {
|
|
|
204
449
|
.join('\n');
|
|
205
450
|
}
|
|
206
451
|
|
|
207
|
-
/** @param {Array<{dest: string, content: string}>} writes @param {string} cwd @returns {Array<{path: string, reason: 'missing' | 'outdated'}>} */
|
|
452
|
+
/** @param {Array<{dest: string, content: string, allowMissingInCheck?: boolean}>} writes @param {string} cwd @returns {Array<{path: string, reason: 'missing' | 'outdated'}>} */
|
|
208
453
|
function staleBuildOutputs(writes, cwd) {
|
|
209
454
|
/** @type {Array<{path: string, reason: 'missing' | 'outdated'}>} */
|
|
210
455
|
const stale = [];
|
|
211
456
|
for (const write of writes) {
|
|
212
457
|
const rel = path.relative(cwd, write.dest);
|
|
213
458
|
if (!fs.existsSync(write.dest)) {
|
|
214
|
-
|
|
459
|
+
if (!write.allowMissingInCheck) {
|
|
460
|
+
stale.push({path: rel, reason: 'missing'});
|
|
461
|
+
}
|
|
215
462
|
continue;
|
|
216
463
|
}
|
|
217
464
|
const onDisk = fs.readFileSync(write.dest, 'utf8');
|
|
218
|
-
if (
|
|
465
|
+
if (
|
|
466
|
+
normalizeThemeBuildForCompare(onDisk) !==
|
|
467
|
+
normalizeThemeBuildForCompare(write.content)
|
|
468
|
+
) {
|
|
219
469
|
stale.push({path: rel, reason: 'outdated'});
|
|
220
470
|
}
|
|
221
471
|
}
|
|
222
472
|
return stale;
|
|
223
473
|
}
|
|
224
474
|
|
|
475
|
+
/** @param {Array<{dest: string, allowMissingInCheck?: boolean}>} writes @param {string} cwd */
|
|
476
|
+
function checkedBuildOutputs(writes, cwd) {
|
|
477
|
+
return writes
|
|
478
|
+
.filter(write => !write.allowMissingInCheck || fs.existsSync(write.dest))
|
|
479
|
+
.map(write => path.relative(cwd, write.dest));
|
|
480
|
+
}
|
|
481
|
+
|
|
225
482
|
/** @param {Array<{dest: string, content: string}>} writes */
|
|
226
483
|
function writeBuildOutputs(writes) {
|
|
227
484
|
if (writes.length === 0) return;
|
|
@@ -278,8 +535,6 @@ function toIdentifier(name) {
|
|
|
278
535
|
* from the cwd-relative dir (most consumers import from a file under src/) but
|
|
279
536
|
* keeps the rest of the path (e.g. `themes/gothic`). Callers note the path is
|
|
280
537
|
* 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
538
|
* @param {string} relDir
|
|
284
539
|
* @param {string} base
|
|
285
540
|
* @returns {string}
|
|
@@ -869,30 +1124,6 @@ function assertAdaptationCapability(
|
|
|
869
1124
|
);
|
|
870
1125
|
}
|
|
871
1126
|
|
|
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
1127
|
/**
|
|
897
1128
|
* Root component entries are the only surface allowed to introduce variants.
|
|
898
1129
|
* @param {Record<string, any>} themeDef
|
|
@@ -1276,6 +1507,19 @@ async function validateRegistryGraphs(/** @type {Array<{specifier: string, expor
|
|
|
1276
1507
|
if (!(root.exportName in exports)) throw registryGraphError(`Family registry ${root.file} does not export "${root.exportName}".`);
|
|
1277
1508
|
}
|
|
1278
1509
|
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Resolve inherited source with exactly the loader's extension precedence.
|
|
1512
|
+
* This reads module locations only; icon discovery never executes a second load.
|
|
1513
|
+
* @param {string} specifier
|
|
1514
|
+
* @param {string} fromFile
|
|
1515
|
+
* @returns {string}
|
|
1516
|
+
*/
|
|
1517
|
+
function resolveThemeModule(specifier, fromFile) {
|
|
1518
|
+
return createJiti(fromFile, {extensions: THEME_MODULE_EXTENSIONS}).resolve(
|
|
1519
|
+
specifier,
|
|
1520
|
+
);
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1279
1523
|
/**
|
|
1280
1524
|
* Errors that mean "the synchronous loader cannot evaluate this module", as
|
|
1281
1525
|
* opposed to "this module is broken". Only the former may fall back to the
|
|
@@ -1323,7 +1567,7 @@ function isSyncLoaderLimitation(error) {
|
|
|
1323
1567
|
*
|
|
1324
1568
|
* @param {string} filePath
|
|
1325
1569
|
* @param {import('./core-interception.mjs').CoreInterception} [interception]
|
|
1326
|
-
* @returns {Promise<{theme: any, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
1570
|
+
* @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
1327
1571
|
*/
|
|
1328
1572
|
// prettier-ignore
|
|
1329
1573
|
async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined) {
|
|
@@ -1373,12 +1617,14 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
1373
1617
|
mod = await jiti.import(filePath, {default: true});
|
|
1374
1618
|
}
|
|
1375
1619
|
|
|
1376
|
-
if (isThemeObject(mod)) return {theme: mod, degraded};
|
|
1620
|
+
if (isThemeObject(mod)) return {theme: mod, exportName: 'default', degraded};
|
|
1377
1621
|
|
|
1378
1622
|
if (mod && typeof mod === 'object') {
|
|
1379
|
-
if (isThemeObject(mod.default))
|
|
1380
|
-
|
|
1381
|
-
|
|
1623
|
+
if (isThemeObject(mod.default)) {
|
|
1624
|
+
return {theme: mod.default, exportName: 'default', degraded};
|
|
1625
|
+
}
|
|
1626
|
+
for (const [exportName, value] of Object.entries(mod)) {
|
|
1627
|
+
if (isThemeObject(value)) return {theme: value, exportName, degraded};
|
|
1382
1628
|
}
|
|
1383
1629
|
}
|
|
1384
1630
|
|
|
@@ -1412,7 +1658,7 @@ function isThemeObject(value) {
|
|
|
1412
1658
|
*
|
|
1413
1659
|
* @param {string} filePath
|
|
1414
1660
|
* @param {import('./core-interception.mjs').CoreInterception} [interception]
|
|
1415
|
-
* @returns {Promise<{theme: any, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
1661
|
+
* @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
1416
1662
|
*/
|
|
1417
1663
|
// prettier-ignore
|
|
1418
1664
|
async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined) {
|
|
@@ -1434,9 +1680,51 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
|
|
|
1434
1680
|
}
|
|
1435
1681
|
}
|
|
1436
1682
|
|
|
1683
|
+
/**
|
|
1684
|
+
* Load one theme through the build's real module loader and validate the raw
|
|
1685
|
+
* input captured from its defineTheme lineage. Used by doctor so it applies the
|
|
1686
|
+
* same direct-input rule as theme build without mistaking compiler output for
|
|
1687
|
+
* authored input.
|
|
1688
|
+
*
|
|
1689
|
+
* @param {string} file
|
|
1690
|
+
* @param {{cwd?: string}} [ctx]
|
|
1691
|
+
* @returns {Promise<string[]>}
|
|
1692
|
+
*/
|
|
1693
|
+
export async function validateThemePrivateInputs(
|
|
1694
|
+
file,
|
|
1695
|
+
{cwd = process.cwd()} = {},
|
|
1696
|
+
) {
|
|
1697
|
+
const filePath = path.resolve(cwd, file);
|
|
1698
|
+
if (!fs.existsSync(filePath)) {
|
|
1699
|
+
throw new AstryxError(
|
|
1700
|
+
`File not found: ${filePath}`,
|
|
1701
|
+
undefined,
|
|
1702
|
+
ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
1703
|
+
);
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
const interception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
1707
|
+
let theme;
|
|
1708
|
+
try {
|
|
1709
|
+
theme = (await extractThemeDefinition(filePath, interception)).theme;
|
|
1710
|
+
} catch (error) {
|
|
1711
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1712
|
+
throw new AstryxError(message, undefined, ERROR_CODES.ERR_THEME_LOAD);
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
const inputs = interception.lineageOf(theme);
|
|
1716
|
+
try {
|
|
1717
|
+
return [...new Set(inputs.flatMap(input => validatePrivateVars(input)))];
|
|
1718
|
+
} finally {
|
|
1719
|
+
interception.strip(theme);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1437
1723
|
/**
|
|
1438
1724
|
* Fallback extraction via regex + eval.
|
|
1439
1725
|
* Only works for plain object literals — can't follow imports or variables.
|
|
1726
|
+
* Never erase icon references: an unresolved registry must preserve the loader
|
|
1727
|
+
* error instead of turning an incomplete theme into a successful build.
|
|
1440
1728
|
* @param {string} filePath
|
|
1441
1729
|
* @returns {any}
|
|
1442
1730
|
*/
|
|
@@ -1458,10 +1746,6 @@ function extractThemeDefinitionLegacy(filePath) {
|
|
|
1458
1746
|
|
|
1459
1747
|
let objStr = defineMatch[1];
|
|
1460
1748
|
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
1749
|
|
|
1466
1750
|
try {
|
|
1467
1751
|
return eval(`(${objStr})`);
|
|
@@ -1476,30 +1760,19 @@ function extractThemeDefinitionLegacy(filePath) {
|
|
|
1476
1760
|
}
|
|
1477
1761
|
|
|
1478
1762
|
/**
|
|
1479
|
-
* Extract
|
|
1480
|
-
* Returns { importPath, exportName } or null
|
|
1763
|
+
* Extract a family member's named registry import from its source file.
|
|
1764
|
+
* Returns { importPath, exportName } or null when the theme names none.
|
|
1765
|
+
* Standalone builds resolve icons through `resolveIconImports` instead.
|
|
1481
1766
|
*
|
|
1482
1767
|
* Looks for patterns like:
|
|
1483
1768
|
* import { defaultIconRegistry } from './icons';
|
|
1484
1769
|
* icons: defaultIconRegistry,
|
|
1485
1770
|
* @param {string} filePath
|
|
1771
|
+
* @param {'icons' | 'indicators'} field
|
|
1486
1772
|
* @returns {{exportName: string, importPath: string} | null}
|
|
1487
1773
|
*/
|
|
1488
|
-
function extractRegistryInfo(filePath, field
|
|
1774
|
+
function extractRegistryInfo(filePath, field) {
|
|
1489
1775
|
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
1776
|
const defineIndex = content.indexOf('defineTheme(');
|
|
1504
1777
|
if (defineIndex < 0) return null;
|
|
1505
1778
|
const themeSource = content.slice(defineIndex);
|
|
@@ -1539,17 +1812,18 @@ function extractRegistryInfo(filePath, field = 'icons', familyMode = false) {
|
|
|
1539
1812
|
* override it had.
|
|
1540
1813
|
*
|
|
1541
1814
|
* The icon registry is imported rather than inlined because it holds React
|
|
1542
|
-
* elements, which cannot be serialized. `
|
|
1543
|
-
*
|
|
1815
|
+
* elements, which cannot be serialized. `resolveIconImports` reads actual
|
|
1816
|
+
* imports from the selected theme's source, where extensionless `./icons` uses
|
|
1544
1817
|
* the TypeScript resolver — but the artifact here is ESM JavaScript, which
|
|
1545
1818
|
* requires a fully specified path. Only the caller knows what its own build
|
|
1546
1819
|
* will emit and under what name, so `iconsSpecifier` lets it say. When it is
|
|
1547
|
-
* not given,
|
|
1820
|
+
* not given, direct registry specifiers are preserved, and inherited relative
|
|
1821
|
+
* imports are rebased from the base module to the theme entry's directory.
|
|
1548
1822
|
*
|
|
1549
1823
|
* @param {any} themeDef
|
|
1550
|
-
* @param {
|
|
1551
|
-
* @param {string} [iconsSpecifier] - Overrides the
|
|
1552
|
-
* @param {{themeBinding?: string,
|
|
1824
|
+
* @param {import('./icon-imports.mjs').IconImports | null} iconInfo
|
|
1825
|
+
* @param {string} [iconsSpecifier] - Overrides the selected registry specifier.
|
|
1826
|
+
* @param {{themeBinding?: string, iconsExpression?: string, indicatorsExpression?: string, artifactBaseName?: string, exportIcons?: boolean}} [moduleOptions]
|
|
1553
1827
|
* @returns {string}
|
|
1554
1828
|
*/
|
|
1555
1829
|
function generateBuiltModule(
|
|
@@ -1560,29 +1834,46 @@ function generateBuiltModule(
|
|
|
1560
1834
|
) {
|
|
1561
1835
|
const themeBinding =
|
|
1562
1836
|
moduleOptions.themeBinding ?? `${toIdentifier(themeDef.name)}Theme`;
|
|
1563
|
-
const iconBinding = moduleOptions.iconBinding ?? iconInfo?.exportName;
|
|
1564
1837
|
const artifactBaseName = moduleOptions.artifactBaseName ?? themeDef.name;
|
|
1565
1838
|
const exportIcons = moduleOptions.exportIcons ?? true;
|
|
1566
|
-
//
|
|
1567
|
-
//
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1839
|
+
// Keep ordinary direct named imports byte-compatible, while encoding paths
|
|
1840
|
+
// with quotes/escapes and retaining default, namespace, and aliased bindings.
|
|
1841
|
+
const iconImport = (iconInfo?.imports ?? [])
|
|
1842
|
+
.map(({importPath, importedName, localName}) => {
|
|
1843
|
+
const overridden =
|
|
1844
|
+
iconsSpecifier !== undefined &&
|
|
1845
|
+
importPath === iconInfo?.iconsSpecifierImportPath &&
|
|
1846
|
+
localName === iconInfo?.iconsSpecifierLocalName;
|
|
1847
|
+
const specifier = overridden
|
|
1848
|
+
? JSON.stringify(iconsSpecifier)
|
|
1849
|
+
: /['\\\r\n]/u.test(importPath)
|
|
1850
|
+
? JSON.stringify(importPath)
|
|
1851
|
+
: `'${importPath}'`;
|
|
1852
|
+
const imported = /^[$\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u.test(
|
|
1853
|
+
importedName,
|
|
1854
|
+
)
|
|
1855
|
+
? importedName
|
|
1856
|
+
: JSON.stringify(importedName);
|
|
1857
|
+
const binding =
|
|
1858
|
+
importedName === 'default'
|
|
1859
|
+
? localName
|
|
1860
|
+
: importedName === '*'
|
|
1861
|
+
? `* as ${localName}`
|
|
1862
|
+
: `{ ${imported}${importedName === localName ? '' : ` as ${localName}`} }`;
|
|
1863
|
+
return `import ${binding} from ${specifier};\n`;
|
|
1864
|
+
})
|
|
1865
|
+
.join('');
|
|
1866
|
+
const iconDeclaration =
|
|
1867
|
+
iconInfo && iconInfo.expression !== iconInfo.exportName
|
|
1868
|
+
? `const ${iconInfo.exportName} = ${iconInfo.expression};\n`
|
|
1869
|
+
: '';
|
|
1870
|
+
const iconsExpression = moduleOptions.iconsExpression ?? iconInfo?.exportName;
|
|
1578
1871
|
const iconsField = iconsExpression ? ` icons: ${iconsExpression},` : '';
|
|
1579
1872
|
const indicatorsField = moduleOptions.indicatorsExpression
|
|
1580
1873
|
? `\n indicators: ${moduleOptions.indicatorsExpression},`
|
|
1581
1874
|
: '';
|
|
1582
1875
|
const iconReExport =
|
|
1583
|
-
iconInfo && exportIcons
|
|
1584
|
-
? `\nexport { ${iconBinding}${iconBinding === iconInfo.exportName ? '' : ` as ${iconInfo.exportName}`} };\n`
|
|
1585
|
-
: '';
|
|
1876
|
+
iconInfo && exportIcons ? `\nexport { ${iconInfo.exportName} };\n` : '';
|
|
1586
1877
|
|
|
1587
1878
|
// Resolve token values — tuples become light-dark() strings
|
|
1588
1879
|
/** @type {Record<string, unknown>} */
|
|
@@ -1641,7 +1932,7 @@ function generateBuiltModule(
|
|
|
1641
1932
|
serializeField('__adaptations', themeDef.__adaptations) +
|
|
1642
1933
|
serializeField('__axes', themeDef.__axes ?? {}, true);
|
|
1643
1934
|
|
|
1644
|
-
return `${iconImport}/**
|
|
1935
|
+
return `${iconImport}${iconDeclaration}/**
|
|
1645
1936
|
* ${themeDef.name} theme — built by \`${getCliInvocation()} theme build\`
|
|
1646
1937
|
* Import the CSS file alongside this module:
|
|
1647
1938
|
*
|
|
@@ -1660,7 +1951,7 @@ ${iconReExport}`;
|
|
|
1660
1951
|
/**
|
|
1661
1952
|
* Generate TypeScript declarations for a built theme module.
|
|
1662
1953
|
* @param {any} themeDef
|
|
1663
|
-
* @param {{exportName: string
|
|
1954
|
+
* @param {{exportName: string} | null} iconInfo - The re-exported registry, if any.
|
|
1664
1955
|
* @param {string | null} variantsFileName
|
|
1665
1956
|
* @param {{themeBinding?: string, includeIconExport?: boolean, includeThemeImport?: boolean}} [typeOptions]
|
|
1666
1957
|
* @returns {string}
|
|
@@ -1835,48 +2126,6 @@ async function validateComponentOverrides(themeDef) {
|
|
|
1835
2126
|
: validateComponentOverridesAgainstRegistry(themeDef, knownComponents);
|
|
1836
2127
|
}
|
|
1837
2128
|
|
|
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
2129
|
const BUILTIN_HEADING_TYPES = new Set(['display-1', 'display-2', 'display-3']);
|
|
1881
2130
|
|
|
1882
2131
|
/**
|
|
@@ -2075,8 +2324,8 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
|
|
|
2075
2324
|
}
|
|
2076
2325
|
|
|
2077
2326
|
/**
|
|
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,
|
|
2327
|
+
* Compile a defineTheme file to CSS + CSS .d.ts + JS + JS .d.ts (and an
|
|
2328
|
+
* optional `.variants.d.ts`). Performs the writes and returns a `theme.build` receipt,
|
|
2080
2329
|
* or `null` when the theme produced no CSS (nothing to build). Throws
|
|
2081
2330
|
* AstryxError (stable code) on failure. Progress is emitted through the shared
|
|
2082
2331
|
* `logger` (silent by default).
|
|
@@ -2086,7 +2335,7 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
|
|
|
2086
2335
|
* `out` overrides the output CSS path; `check` compares against on-disk outputs
|
|
2087
2336
|
* instead of writing. `iconsSpecifier` overrides the icon registry import
|
|
2088
2337
|
* specifier in the generated module (e.g. `./icons.mjs`); when omitted, the
|
|
2089
|
-
*
|
|
2338
|
+
* direct registry specifiers from the theme source are emitted unchanged.
|
|
2090
2339
|
* @param {{cwd?: string}} [ctx]
|
|
2091
2340
|
* @returns {Promise<any>}
|
|
2092
2341
|
*/
|
|
@@ -2094,6 +2343,7 @@ async function themeBuildInternal(
|
|
|
2094
2343
|
file,
|
|
2095
2344
|
options = {},
|
|
2096
2345
|
{cwd = process.cwd()} = {},
|
|
2346
|
+
/** @type {{compact?: boolean, trailers?: ThemeBuildTrailer[]}} */ report = {},
|
|
2097
2347
|
) {
|
|
2098
2348
|
const filePath = path.resolve(cwd, file);
|
|
2099
2349
|
|
|
@@ -2105,7 +2355,13 @@ async function themeBuildInternal(
|
|
|
2105
2355
|
);
|
|
2106
2356
|
}
|
|
2107
2357
|
|
|
2108
|
-
|
|
2358
|
+
if (!report.compact) {
|
|
2359
|
+
logger.log(`\nBuilding theme from ${path.relative(cwd, filePath)}...`);
|
|
2360
|
+
}
|
|
2361
|
+
// A compact report has no per-theme heading, so each warning names its file.
|
|
2362
|
+
const source = report.compact ? `${path.relative(cwd, filePath)}: ` : '';
|
|
2363
|
+
|
|
2364
|
+
await selectCore(cwd);
|
|
2109
2365
|
|
|
2110
2366
|
// Standalone builds only need interception when an older Core could erase
|
|
2111
2367
|
// adaptations. Family preparation always supplies the same recorder as its
|
|
@@ -2119,6 +2375,8 @@ async function themeBuildInternal(
|
|
|
2119
2375
|
|
|
2120
2376
|
// Extract theme definition
|
|
2121
2377
|
let themeDef;
|
|
2378
|
+
/** The export actually selected by the loader, not the first AST match. */
|
|
2379
|
+
let themeExportName;
|
|
2122
2380
|
/** Paths through the load that interception could not fully observe. */
|
|
2123
2381
|
let loadDegradation;
|
|
2124
2382
|
try {
|
|
@@ -2128,6 +2386,7 @@ async function themeBuildInternal(
|
|
|
2128
2386
|
options.__familyLoader,
|
|
2129
2387
|
);
|
|
2130
2388
|
themeDef = loaded.theme;
|
|
2389
|
+
themeExportName = loaded.exportName;
|
|
2131
2390
|
loadDegradation = loaded.degraded;
|
|
2132
2391
|
} catch (e) {
|
|
2133
2392
|
const err = /** @type {Error} */ (e);
|
|
@@ -2193,6 +2452,25 @@ async function themeBuildInternal(
|
|
|
2193
2452
|
throw err;
|
|
2194
2453
|
}
|
|
2195
2454
|
|
|
2455
|
+
// A generated module must preserve the registry through an import: it may
|
|
2456
|
+
// contain React elements, which cannot be serialized. Validate before CSS
|
|
2457
|
+
// generation so neither the no-CSS return nor --check can bypass the error.
|
|
2458
|
+
// Family preparation keeps its own named-import registry contract, which
|
|
2459
|
+
// themeBuildFamily checks against the selected members' graph.
|
|
2460
|
+
const standaloneIcons = !options.__prepareFamily;
|
|
2461
|
+
const iconResolution = {
|
|
2462
|
+
readSource: (/** @type {string} */ file) => fs.readFileSync(file, 'utf8'),
|
|
2463
|
+
resolveModule: resolveThemeModule,
|
|
2464
|
+
reservedNames: [`${toIdentifier(themeDef.name)}Theme`],
|
|
2465
|
+
rawInput: 'extends' in themeDef,
|
|
2466
|
+
hasIcons:
|
|
2467
|
+
Object.keys(themeDef.icons ?? {}).length > 0 ||
|
|
2468
|
+
Object.keys(themeDef.extends?.icons ?? {}).length > 0,
|
|
2469
|
+
};
|
|
2470
|
+
let iconInfo = standaloneIcons
|
|
2471
|
+
? await resolveIconImports(filePath, themeExportName, iconResolution)
|
|
2472
|
+
: null;
|
|
2473
|
+
|
|
2196
2474
|
// Validate component overrides
|
|
2197
2475
|
const warnings = await validateComponentOverrides(themeDef);
|
|
2198
2476
|
const warningMessages = [];
|
|
@@ -2200,18 +2478,18 @@ async function themeBuildInternal(
|
|
|
2200
2478
|
const noticeMessages = [];
|
|
2201
2479
|
for (const w of warnings) {
|
|
2202
2480
|
warningMessages.push(w);
|
|
2203
|
-
logger.warn(` [warn] ${w}`);
|
|
2481
|
+
logger.warn(` [warn] ${source}${w}`);
|
|
2204
2482
|
}
|
|
2205
2483
|
|
|
2206
2484
|
// Validate no private vars are set directly
|
|
2207
2485
|
const privateVarErrors = validatePrivateVars(themeDef);
|
|
2208
2486
|
for (const e of privateVarErrors) {
|
|
2209
2487
|
warningMessages.push(e);
|
|
2210
|
-
logger.error(` [error] ${e}`);
|
|
2488
|
+
logger.error(` [error] ${source}${e}`);
|
|
2211
2489
|
}
|
|
2212
2490
|
if (privateVarErrors.length > 0) {
|
|
2213
2491
|
logger.error(
|
|
2214
|
-
`\n ${privateVarErrors.length} private var error(s). Use standard CSS properties instead.`,
|
|
2492
|
+
`\n ${source}${privateVarErrors.length} private var error(s). Use standard CSS properties instead.`,
|
|
2215
2493
|
);
|
|
2216
2494
|
}
|
|
2217
2495
|
|
|
@@ -2233,13 +2511,7 @@ async function themeBuildInternal(
|
|
|
2233
2511
|
// capability exports are checked against what the theme actually asks for.
|
|
2234
2512
|
if (!_defineTheme || !_generateThemeRulesSplit) {
|
|
2235
2513
|
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
|
-
: '.'),
|
|
2514
|
+
coreUnavailableMessage(cwd, _coreImportError),
|
|
2243
2515
|
undefined,
|
|
2244
2516
|
ERROR_CODES.ERR_CORE_NOT_FOUND,
|
|
2245
2517
|
);
|
|
@@ -2305,6 +2577,40 @@ async function themeBuildInternal(
|
|
|
2305
2577
|
resolvedTheme = themeDef;
|
|
2306
2578
|
}
|
|
2307
2579
|
|
|
2580
|
+
// Raw object exports can acquire icons only when Core resolves `extends`.
|
|
2581
|
+
// Recheck an unresolved provenance result before any generator runs.
|
|
2582
|
+
if (
|
|
2583
|
+
standaloneIcons &&
|
|
2584
|
+
!iconInfo &&
|
|
2585
|
+
Object.keys(resolvedTheme.icons ?? {}).length > 0
|
|
2586
|
+
) {
|
|
2587
|
+
iconInfo = await resolveIconImports(filePath, themeExportName, {
|
|
2588
|
+
...iconResolution,
|
|
2589
|
+
hasIcons: true,
|
|
2590
|
+
});
|
|
2591
|
+
}
|
|
2592
|
+
// An opaque package base can legitimately have no icons. Its .icons
|
|
2593
|
+
// reference is unnecessary; direct empty registry imports remain intact.
|
|
2594
|
+
if (
|
|
2595
|
+
iconInfo &&
|
|
2596
|
+
iconInfo.iconsSpecifierLocalName === undefined &&
|
|
2597
|
+
Object.keys(resolvedTheme.icons ?? {}).length === 0
|
|
2598
|
+
) {
|
|
2599
|
+
iconInfo = null;
|
|
2600
|
+
}
|
|
2601
|
+
if (
|
|
2602
|
+
iconInfo &&
|
|
2603
|
+
options.iconsSpecifier !== undefined &&
|
|
2604
|
+
iconInfo.iconsSpecifierImportPath === undefined
|
|
2605
|
+
) {
|
|
2606
|
+
throw new AstryxError(
|
|
2607
|
+
'The icon registry is inherited through a theme import. ' +
|
|
2608
|
+
'To use --icons-specifier, import the registry directly and set icons to that binding.',
|
|
2609
|
+
undefined,
|
|
2610
|
+
ERROR_CODES.ERR_THEME_INVALID,
|
|
2611
|
+
);
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2308
2614
|
// Cores that predate adaptations can still resolve typography, color,
|
|
2309
2615
|
// radius, and motion into root tokens, but they do not retain the raw axis
|
|
2310
2616
|
// inputs. Keep the effective metadata captured from the same defineTheme
|
|
@@ -2422,7 +2728,7 @@ async function themeBuildInternal(
|
|
|
2422
2728
|
for (const message of droppedDeclarations) {
|
|
2423
2729
|
const w = `Declaration ${message}. The generated CSS omits it; fix the value in the theme source.`;
|
|
2424
2730
|
warningMessages.push(w);
|
|
2425
|
-
logger.warn(` [warn] ${w}`);
|
|
2731
|
+
logger.warn(` [warn] ${source}${w}`);
|
|
2426
2732
|
}
|
|
2427
2733
|
const unemittedHeadingTypes = headingTypesWithoutEmittedRule(
|
|
2428
2734
|
customHeadingTypes(themeDef),
|
|
@@ -2444,7 +2750,7 @@ async function themeBuildInternal(
|
|
|
2444
2750
|
);
|
|
2445
2751
|
}
|
|
2446
2752
|
if (cssParts.length === 0) {
|
|
2447
|
-
logger.log(
|
|
2753
|
+
logger.log(`${source}No overrides found; nothing to build.`);
|
|
2448
2754
|
return null;
|
|
2449
2755
|
}
|
|
2450
2756
|
// The data-token defaults are theme-independent and go in @layer
|
|
@@ -2527,18 +2833,10 @@ async function themeBuildInternal(
|
|
|
2527
2833
|
// was left as orphaned half-built output. Stage-then-commit avoids
|
|
2528
2834
|
// that.
|
|
2529
2835
|
const outDir = path.dirname(outPath);
|
|
2836
|
+
const cssDtsPath = `${outPath}.d.ts`;
|
|
2530
2837
|
const jsPath = path.join(outDir, `${baseName}.js`);
|
|
2531
2838
|
const dtsPath = path.join(outDir, `${baseName}.d.ts`);
|
|
2532
2839
|
|
|
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
2840
|
// Type augmentation .d.ts if theme has custom prop values. Computed
|
|
2543
2841
|
// before the main .d.ts so the latter can reference it (see below).
|
|
2544
2842
|
const augmentationSource = resolvedTheme || themeDef;
|
|
@@ -2559,6 +2857,9 @@ async function themeBuildInternal(
|
|
|
2559
2857
|
// importing the theme also loads the custom-variant augmentations.
|
|
2560
2858
|
const cssContent =
|
|
2561
2859
|
generatedHeader(sourceRelative, 'css', buildCommand, versions) + css;
|
|
2860
|
+
const cssDtsContent =
|
|
2861
|
+
generatedHeader(sourceRelative, 'ts', buildCommand, versions) +
|
|
2862
|
+
'export {};\n';
|
|
2562
2863
|
const jsContent =
|
|
2563
2864
|
generatedHeader(sourceRelative, 'js', buildCommand, versions) +
|
|
2564
2865
|
generateBuiltModule(
|
|
@@ -2586,8 +2887,8 @@ async function themeBuildInternal(
|
|
|
2586
2887
|
theme: displayTheme,
|
|
2587
2888
|
sourceTheme: themeDef,
|
|
2588
2889
|
sourceParent,
|
|
2589
|
-
iconInfo,
|
|
2590
|
-
indicatorInfo,
|
|
2890
|
+
iconInfo: extractRegistryInfo(filePath, 'icons'),
|
|
2891
|
+
indicatorInfo: extractRegistryInfo(filePath, 'indicators'),
|
|
2591
2892
|
variantDecl,
|
|
2592
2893
|
css: cssPlan,
|
|
2593
2894
|
versions,
|
|
@@ -2600,6 +2901,7 @@ async function themeBuildInternal(
|
|
|
2600
2901
|
|
|
2601
2902
|
const writes = [
|
|
2602
2903
|
{dest: outPath, content: cssContent},
|
|
2904
|
+
{dest: cssDtsPath, content: cssDtsContent, allowMissingInCheck: true},
|
|
2603
2905
|
{dest: jsPath, content: jsContent},
|
|
2604
2906
|
{dest: dtsPath, content: dtsContent},
|
|
2605
2907
|
];
|
|
@@ -2633,25 +2935,28 @@ async function themeBuildInternal(
|
|
|
2633
2935
|
name: themeDef.name,
|
|
2634
2936
|
upToDate,
|
|
2635
2937
|
stale,
|
|
2636
|
-
checked: writes
|
|
2938
|
+
checked: checkedBuildOutputs(writes, cwd),
|
|
2637
2939
|
},
|
|
2638
2940
|
};
|
|
2639
2941
|
}
|
|
2640
2942
|
|
|
2641
2943
|
writeBuildOutputs(writes);
|
|
2642
2944
|
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
`
|
|
2646
|
-
);
|
|
2647
|
-
logger.log(` ${size} KB`);
|
|
2648
|
-
logger.log(`[ok] ${path.relative(cwd, jsPath)}`);
|
|
2649
|
-
logger.log(`[ok] ${path.relative(cwd, dtsPath)}`);
|
|
2650
|
-
if (variantDtsPath && variantDecl) {
|
|
2651
|
-
const augCount = (variantDecl.match(/': true;/g) || []).length;
|
|
2945
|
+
if (!report.compact) {
|
|
2946
|
+
logger.log(`\n[ok] ${path.relative(cwd, outPath)}`);
|
|
2947
|
+
logger.log(`[ok] ${path.relative(cwd, cssDtsPath)}`);
|
|
2652
2948
|
logger.log(
|
|
2653
|
-
`
|
|
2949
|
+
` ${tokenCount} token overrides, ${componentCount} component overrides`,
|
|
2654
2950
|
);
|
|
2951
|
+
logger.log(` ${size} KB`);
|
|
2952
|
+
logger.log(`[ok] ${path.relative(cwd, jsPath)}`);
|
|
2953
|
+
logger.log(`[ok] ${path.relative(cwd, dtsPath)}`);
|
|
2954
|
+
if (variantDtsPath && variantDecl) {
|
|
2955
|
+
const augCount = (variantDecl.match(/': true;/g) || []).length;
|
|
2956
|
+
logger.log(
|
|
2957
|
+
`[ok] ${path.relative(cwd, variantDtsPath)} (${augCount} type augmentations)`,
|
|
2958
|
+
);
|
|
2959
|
+
}
|
|
2655
2960
|
}
|
|
2656
2961
|
|
|
2657
2962
|
const relOutDir = path.relative(cwd, outDir) || '.';
|
|
@@ -2659,25 +2964,6 @@ async function themeBuildInternal(
|
|
|
2659
2964
|
const jsImport = importSpecifier(relOutDir, baseName);
|
|
2660
2965
|
const cssImport = importSpecifier(relOutDir, cssBase) + '.css';
|
|
2661
2966
|
const exportName = `${toIdentifier(baseName)}Theme`;
|
|
2662
|
-
logger.log(`
|
|
2663
|
-
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
2664
|
-
|
|
2665
|
-
import { ${exportName} } from '${jsImport}';
|
|
2666
|
-
import '${cssImport}';
|
|
2667
|
-
|
|
2668
|
-
<Theme theme={${exportName}}>
|
|
2669
|
-
<App />
|
|
2670
|
-
</Theme>
|
|
2671
|
-
|
|
2672
|
-
Or with a <link> tag:
|
|
2673
|
-
|
|
2674
|
-
import { ${exportName} } from '${jsImport}';
|
|
2675
|
-
|
|
2676
|
-
<link rel="stylesheet" href="${cssImport}" />
|
|
2677
|
-
<Theme theme={${exportName}}>
|
|
2678
|
-
<App />
|
|
2679
|
-
</Theme>
|
|
2680
|
-
`);
|
|
2681
2967
|
|
|
2682
2968
|
// Fonts the theme names but nothing loads (#5015). Resolved tokens and
|
|
2683
2969
|
// component overrides carry the final font-family values on both load
|
|
@@ -2691,15 +2977,27 @@ Or with a <link> tag:
|
|
|
2691
2977
|
// permanently in violation of its own "compiles with no warnings" guard).
|
|
2692
2978
|
// Adaptation rules are resolved theme writes in their own right, so a family
|
|
2693
2979
|
// named only inside one needs the same notice as one named at the root.
|
|
2980
|
+
/** @type {string[]} */
|
|
2981
|
+
const fontNotices = [];
|
|
2694
2982
|
for (const family of unloadedFonts) {
|
|
2695
2983
|
const msg = `Font "${family}" is named by this theme but not loaded; add a <link> or @font-face in your app (recipe: astryx docs typography)`;
|
|
2696
2984
|
noticeMessages.push(msg);
|
|
2697
|
-
|
|
2698
|
-
}
|
|
2699
|
-
if (unloadedFonts.length > 0) {
|
|
2700
|
-
logger.log(formatFontLoadingHelp(themeDef.name, unloadedFonts));
|
|
2985
|
+
fontNotices.push(msg);
|
|
2701
2986
|
}
|
|
2702
2987
|
|
|
2988
|
+
/** @type {ThemeBuildTrailer} */
|
|
2989
|
+
const trailer = {
|
|
2990
|
+
themeName: themeDef.name,
|
|
2991
|
+
exportName,
|
|
2992
|
+
jsImport,
|
|
2993
|
+
cssImport,
|
|
2994
|
+
unloadedFonts,
|
|
2995
|
+
fontNotices,
|
|
2996
|
+
};
|
|
2997
|
+
// A batch or compact report prints this once for the whole run instead.
|
|
2998
|
+
if (report.trailers) report.trailers.push(trailer);
|
|
2999
|
+
else printBuildTrailer(trailer);
|
|
3000
|
+
|
|
2703
3001
|
return {
|
|
2704
3002
|
type: 'theme.build',
|
|
2705
3003
|
data: {
|
|
@@ -2709,6 +3007,7 @@ Or with a <link> tag:
|
|
|
2709
3007
|
sizeKB: parseFloat(size),
|
|
2710
3008
|
outputs: {
|
|
2711
3009
|
css: path.relative(cwd, outPath),
|
|
3010
|
+
cssDts: path.relative(cwd, cssDtsPath),
|
|
2712
3011
|
js: path.relative(cwd, jsPath),
|
|
2713
3012
|
dts: path.relative(cwd, dtsPath),
|
|
2714
3013
|
...(variantDecl && variantDtsPath
|
|
@@ -2721,6 +3020,166 @@ Or with a <link> tag:
|
|
|
2721
3020
|
};
|
|
2722
3021
|
}
|
|
2723
3022
|
|
|
3023
|
+
/**
|
|
3024
|
+
* What a standalone build prints after its [ok] lines, kept as data so a
|
|
3025
|
+
* batch can print it once for every theme.
|
|
3026
|
+
* @typedef {object} ThemeBuildTrailer
|
|
3027
|
+
* @property {string} themeName The theme's name.
|
|
3028
|
+
* @property {string} exportName The built module's theme export.
|
|
3029
|
+
* @property {string} jsImport Import specifier of the built JS module.
|
|
3030
|
+
* @property {string} cssImport Import specifier of the built CSS.
|
|
3031
|
+
* @property {string[]} unloadedFonts Font families the theme names but does not load.
|
|
3032
|
+
* @property {string[]} fontNotices One notice per unloaded font family.
|
|
3033
|
+
*/
|
|
3034
|
+
|
|
3035
|
+
/**
|
|
3036
|
+
* Print a standalone build's install snippet and font guidance.
|
|
3037
|
+
* @param {ThemeBuildTrailer} trailer
|
|
3038
|
+
*/
|
|
3039
|
+
function printBuildTrailer(trailer) {
|
|
3040
|
+
logger.log(`
|
|
3041
|
+
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
3042
|
+
|
|
3043
|
+
import { Theme } from '@astryxdesign/core';
|
|
3044
|
+
import { ${trailer.exportName} } from '${trailer.jsImport}';
|
|
3045
|
+
import '${trailer.cssImport}';
|
|
3046
|
+
|
|
3047
|
+
<Theme theme={${trailer.exportName}}>
|
|
3048
|
+
<App />
|
|
3049
|
+
</Theme>
|
|
3050
|
+
|
|
3051
|
+
Or with a <link> tag:
|
|
3052
|
+
|
|
3053
|
+
import { Theme } from '@astryxdesign/core';
|
|
3054
|
+
import { ${trailer.exportName} } from '${trailer.jsImport}';
|
|
3055
|
+
|
|
3056
|
+
<link rel="stylesheet" href="${trailer.cssImport}" />
|
|
3057
|
+
<Theme theme={${trailer.exportName}}>
|
|
3058
|
+
<App />
|
|
3059
|
+
</Theme>
|
|
3060
|
+
`);
|
|
3061
|
+
for (const msg of trailer.fontNotices) logger.log(` note: ${msg}`);
|
|
3062
|
+
if (trailer.unloadedFonts.length > 0) {
|
|
3063
|
+
logger.log(formatFontLoadingHelp(trailer.themeName, trailer.unloadedFonts));
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
/**
|
|
3068
|
+
* Print the install snippet and font guidance once for a batch: the first
|
|
3069
|
+
* theme as the full example, one import line per built theme, and one font
|
|
3070
|
+
* recipe naming every family the themes do not load.
|
|
3071
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
3072
|
+
*/
|
|
3073
|
+
export function printBatchTrailer(trailers) {
|
|
3074
|
+
if (trailers.length === 0) return;
|
|
3075
|
+
const [first] = trailers;
|
|
3076
|
+
logger.log(`
|
|
3077
|
+
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
3078
|
+
|
|
3079
|
+
import { Theme } from '@astryxdesign/core';
|
|
3080
|
+
import { ${first.exportName} } from '${first.jsImport}';
|
|
3081
|
+
import '${first.cssImport}';
|
|
3082
|
+
|
|
3083
|
+
<Theme theme={${first.exportName}}>
|
|
3084
|
+
<App />
|
|
3085
|
+
</Theme>
|
|
3086
|
+
|
|
3087
|
+
Or with a <link> tag:
|
|
3088
|
+
|
|
3089
|
+
import { Theme } from '@astryxdesign/core';
|
|
3090
|
+
import { ${first.exportName} } from '${first.jsImport}';
|
|
3091
|
+
|
|
3092
|
+
<link rel="stylesheet" href="${first.cssImport}" />
|
|
3093
|
+
<Theme theme={${first.exportName}}>
|
|
3094
|
+
<App />
|
|
3095
|
+
</Theme>
|
|
3096
|
+
`);
|
|
3097
|
+
if (trailers.length > 1) {
|
|
3098
|
+
logger.log('Each built theme imports the same way:');
|
|
3099
|
+
for (const trailer of trailers) {
|
|
3100
|
+
logger.log(
|
|
3101
|
+
` import { ${trailer.exportName} } from '${trailer.jsImport}'; import '${trailer.cssImport}';`,
|
|
3102
|
+
);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
const fonts = groupUnloadedFonts(trailers);
|
|
3106
|
+
if (fonts.length > 0) logger.log(formatBatchFontLoadingHelp(fonts));
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
/**
|
|
3110
|
+
* Print what a short report keeps after its one line per theme: one line
|
|
3111
|
+
* naming the fonts the themes do not load, and, when the caller chose no
|
|
3112
|
+
* detail level, where the install example and font recipe are.
|
|
3113
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
3114
|
+
* @param {{hint?: boolean}} [options]
|
|
3115
|
+
*/
|
|
3116
|
+
export function printCompactTrailer(trailers, {hint = false} = {}) {
|
|
3117
|
+
if (trailers.length === 0) return;
|
|
3118
|
+
const fonts = groupUnloadedFonts(trailers);
|
|
3119
|
+
if (fonts.length > 0) {
|
|
3120
|
+
const named = fonts
|
|
3121
|
+
.map(({family, themes}) =>
|
|
3122
|
+
trailers.length > 1
|
|
3123
|
+
? `"${family}" (${themes.join(', ')})`
|
|
3124
|
+
: `"${family}"`,
|
|
3125
|
+
)
|
|
3126
|
+
.join(', ');
|
|
3127
|
+
logger.log(
|
|
3128
|
+
`[note] Fonts named but not loaded: ${named}. Load them in your app (recipe: astryx docs typography).`,
|
|
3129
|
+
);
|
|
3130
|
+
}
|
|
3131
|
+
if (hint) {
|
|
3132
|
+
logger.log(
|
|
3133
|
+
'Run with --detail full for the install example and font recipe.',
|
|
3134
|
+
);
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
/**
|
|
3139
|
+
* Each font family the themes name but do not load, with the themes that
|
|
3140
|
+
* name it, in first-seen order.
|
|
3141
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
3142
|
+
* @returns {Array<{family: string, themes: string[]}>}
|
|
3143
|
+
*/
|
|
3144
|
+
function groupUnloadedFonts(trailers) {
|
|
3145
|
+
/** @type {Map<string, {family: string, themes: string[]}>} */
|
|
3146
|
+
const byFamily = new Map();
|
|
3147
|
+
for (const trailer of trailers) {
|
|
3148
|
+
for (const family of trailer.unloadedFonts) {
|
|
3149
|
+
const key = family.toLowerCase();
|
|
3150
|
+
const entry = byFamily.get(key) ?? {family, themes: []};
|
|
3151
|
+
entry.themes.push(trailer.themeName);
|
|
3152
|
+
byFamily.set(key, entry);
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
return [...byFamily.values()];
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3158
|
+
/**
|
|
3159
|
+
* Build one theme for a batch or compact CLI report. Same build, outputs, and
|
|
3160
|
+
* receipt as {@link themeBuild}; the install snippet and font guidance come
|
|
3161
|
+
* back as `trailer` instead of being printed, and `compact` leaves out the
|
|
3162
|
+
* per-file progress lines. CLI-internal: not exported from the API entry.
|
|
3163
|
+
* @param {string} file
|
|
3164
|
+
* @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options]
|
|
3165
|
+
* @param {{cwd?: string}} [ctx]
|
|
3166
|
+
* @param {{compact?: boolean}} [report]
|
|
3167
|
+
* @returns {Promise<{receipt: import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null, trailer: ThemeBuildTrailer | null}>}
|
|
3168
|
+
*/
|
|
3169
|
+
export async function themeBuildForReport(
|
|
3170
|
+
file,
|
|
3171
|
+
options = {},
|
|
3172
|
+
ctx = {},
|
|
3173
|
+
{compact = false} = {},
|
|
3174
|
+
) {
|
|
3175
|
+
/** @type {ThemeBuildTrailer[]} */
|
|
3176
|
+
const trailers = [];
|
|
3177
|
+
const receipt = /** @type {any} */ (
|
|
3178
|
+
await themeBuildInternal(file, options, ctx, {compact, trailers})
|
|
3179
|
+
);
|
|
3180
|
+
return {receipt, trailer: trailers[0] ?? null};
|
|
3181
|
+
}
|
|
3182
|
+
|
|
2724
3183
|
/** @param {string} file @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options] @param {{cwd?: string}} [ctx] @returns {Promise<import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null>} */
|
|
2725
3184
|
export async function themeBuild(file, options = {}, ctx = {}) {
|
|
2726
3185
|
return /** @type {any} */ (themeBuildInternal(file, options, ctx));
|
|
@@ -2807,6 +3266,7 @@ export async function themeBuildFamily(
|
|
|
2807
3266
|
error instanceof Error ? error.message : 'Invalid family key.';
|
|
2808
3267
|
throw new AstryxError(message, undefined, ERROR_CODES.ERR_THEME_INVALID);
|
|
2809
3268
|
}
|
|
3269
|
+
await selectCore(cwd);
|
|
2810
3270
|
const familyInterception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
2811
3271
|
// prettier-ignore
|
|
2812
3272
|
const familyLoader = createJiti(import.meta.url, {moduleCache: true, interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
|
|
@@ -2873,6 +3333,7 @@ export async function themeBuildFamily(
|
|
|
2873
3333
|
const root = members[0];
|
|
2874
3334
|
const outDir = path.dirname(root.filePath);
|
|
2875
3335
|
const outPath = path.join(outDir, `${baseName}.css`);
|
|
3336
|
+
const cssDtsPath = `${outPath}.d.ts`;
|
|
2876
3337
|
const jsPath = path.join(outDir, `${baseName}.js`);
|
|
2877
3338
|
const dtsPath = path.join(outDir, `${baseName}.d.ts`);
|
|
2878
3339
|
const sources = new Set(
|
|
@@ -2882,7 +3343,7 @@ export async function themeBuildFamily(
|
|
|
2882
3343
|
),
|
|
2883
3344
|
),
|
|
2884
3345
|
);
|
|
2885
|
-
const collision = [outPath, jsPath, dtsPath].find(output => {
|
|
3346
|
+
const collision = [outPath, cssDtsPath, jsPath, dtsPath].find(output => {
|
|
2886
3347
|
const candidates = [path.resolve(output)];
|
|
2887
3348
|
if (fs.existsSync(output)) candidates.push(fs.realpathSync(output));
|
|
2888
3349
|
return candidates.some(value => sources.has(value.toLowerCase()));
|
|
@@ -2930,11 +3391,14 @@ export async function themeBuildFamily(
|
|
|
2930
3391
|
const indicatorImport = indicator.info
|
|
2931
3392
|
? `import { ${indicator.info.exportName} as ${ownIndicators} } from ${JSON.stringify(indicator.specifier ?? indicator.info.importPath)};\n`
|
|
2932
3393
|
: '';
|
|
3394
|
+
// The member's own registry import, bound to its family-unique name; a
|
|
3395
|
+
// rebased or overridden specifier replaces the scraped one.
|
|
3396
|
+
// prettier-ignore
|
|
3397
|
+
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
3398
|
return (
|
|
2934
3399
|
indicatorImport +
|
|
2935
|
-
generateBuiltModule(member.theme,
|
|
3400
|
+
generateBuiltModule(member.theme, iconImports, icon.specifier, {
|
|
2936
3401
|
themeBinding,
|
|
2937
|
-
iconBinding: ownIcons ?? undefined,
|
|
2938
3402
|
iconsExpression: expression(ownIcons, inheritedIcons),
|
|
2939
3403
|
indicatorsExpression: expression(ownIndicators, inheritedIndicators),
|
|
2940
3404
|
artifactBaseName: baseName,
|
|
@@ -2963,6 +3427,13 @@ export async function themeBuildFamily(
|
|
|
2963
3427
|
generatedHeader(sourceRelative, 'css', buildCommand, root.versions) +
|
|
2964
3428
|
css,
|
|
2965
3429
|
},
|
|
3430
|
+
{
|
|
3431
|
+
dest: cssDtsPath,
|
|
3432
|
+
allowMissingInCheck: true,
|
|
3433
|
+
content:
|
|
3434
|
+
generatedHeader(sourceRelative, 'ts', buildCommand, root.versions) +
|
|
3435
|
+
'export {};\n',
|
|
3436
|
+
},
|
|
2966
3437
|
{
|
|
2967
3438
|
dest: jsPath,
|
|
2968
3439
|
content:
|
|
@@ -2978,6 +3449,7 @@ export async function themeBuildFamily(
|
|
|
2978
3449
|
];
|
|
2979
3450
|
const outputs = {
|
|
2980
3451
|
css: path.relative(cwd, outPath),
|
|
3452
|
+
cssDts: path.relative(cwd, cssDtsPath),
|
|
2981
3453
|
js: path.relative(cwd, jsPath),
|
|
2982
3454
|
dts: path.relative(cwd, dtsPath),
|
|
2983
3455
|
};
|
|
@@ -3005,7 +3477,7 @@ export async function themeBuildFamily(
|
|
|
3005
3477
|
name: root.theme.name,
|
|
3006
3478
|
upToDate,
|
|
3007
3479
|
stale,
|
|
3008
|
-
checked: writes
|
|
3480
|
+
checked: checkedBuildOutputs(writes, cwd),
|
|
3009
3481
|
},
|
|
3010
3482
|
};
|
|
3011
3483
|
}
|