@astryxdesign/cli 0.6.5 → 0.6.6-canary.408ad59
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
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Regression coverage for icon registry preservation in theme builds.
|
|
5
|
+
* @input Real themeBuild calls, imported React icon registries, and source or
|
|
6
|
+
* built themes supplied to defineTheme's extends option.
|
|
7
|
+
* @output Checks generated ESM with Node's native loader, retained React
|
|
8
|
+
* elements, inherited paths and precedence, TypeScript binding provenance,
|
|
9
|
+
* and rejection before output writes.
|
|
10
|
+
* @position Direct API regression suite for the icon import bug in #5058.
|
|
11
|
+
* The node project's global setup supplies the compiled core package.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
15
|
+
import {execFileSync} from 'node:child_process';
|
|
16
|
+
import * as fs from 'node:fs';
|
|
17
|
+
import * as path from 'node:path';
|
|
18
|
+
import {themeBuild} from './build.mjs';
|
|
19
|
+
|
|
20
|
+
let tmpDir;
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
// Keeping fixtures under the CLI package makes real core/React imports
|
|
23
|
+
// resolve in both the theme loader and the native Node artifact check.
|
|
24
|
+
tmpDir = fs.mkdtempSync(
|
|
25
|
+
path.resolve(import.meta.dirname, '../../..', '.tmp-icon-preservation-'),
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function write(file, source) {
|
|
33
|
+
fs.writeFileSync(path.join(tmpDir, file), source);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function writeRegistry(file, exportName, icons) {
|
|
37
|
+
write(
|
|
38
|
+
file,
|
|
39
|
+
`import {createElement} from 'react';
|
|
40
|
+
const registry = {
|
|
41
|
+
${Object.entries(icons)
|
|
42
|
+
.map(
|
|
43
|
+
([key, label]) =>
|
|
44
|
+
` ${JSON.stringify(key)}: createElement('svg', {'data-icon': ${JSON.stringify(label)}}, createElement('path', {d: 'M0 0h1'})),`,
|
|
45
|
+
)
|
|
46
|
+
.join('\n')}
|
|
47
|
+
};
|
|
48
|
+
${exportName === 'default' ? 'export default registry;' : `export {registry as ${exportName}};`}
|
|
49
|
+
`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Load the artifact with native Node, without jiti/Vite resolving nonexistent
|
|
55
|
+
* imports or transforming its syntax. Valid React elements prove symbols and
|
|
56
|
+
* element contents survived, which JSON-only registry assertions cannot do.
|
|
57
|
+
*/
|
|
58
|
+
function readBuiltIcons(name, registryExport) {
|
|
59
|
+
const output = execFileSync(
|
|
60
|
+
process.execPath,
|
|
61
|
+
[
|
|
62
|
+
'--input-type=module',
|
|
63
|
+
'--eval',
|
|
64
|
+
`import assert from 'node:assert/strict';
|
|
65
|
+
import {isValidElement} from 'react';
|
|
66
|
+
const mod = await import(${JSON.stringify(`./${name}.js`)});
|
|
67
|
+
const theme = Object.values(mod).find(value => value?.name === ${JSON.stringify(name)});
|
|
68
|
+
assert.ok(theme?.icons, 'generated theme must retain its icons');
|
|
69
|
+
${registryExport ? `assert.equal(mod[${JSON.stringify(registryExport)}], theme.icons, 'registry re-export must match the theme');` : ''}
|
|
70
|
+
const icons = Object.fromEntries(Object.entries(theme.icons).map(([key, icon]) => {
|
|
71
|
+
assert.ok(isValidElement(icon), key + ' must remain a React element');
|
|
72
|
+
assert.equal(icon.type, 'svg');
|
|
73
|
+
assert.ok(isValidElement(icon.props.children));
|
|
74
|
+
assert.equal(icon.props.children.props.d, 'M0 0h1');
|
|
75
|
+
return [key, icon.props['data-icon']];
|
|
76
|
+
}));
|
|
77
|
+
process.stdout.write(JSON.stringify(icons));`,
|
|
78
|
+
],
|
|
79
|
+
{cwd: tmpDir, encoding: 'utf8', timeout: 10000},
|
|
80
|
+
);
|
|
81
|
+
return JSON.parse(output);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function buildAndCheck(file) {
|
|
85
|
+
const built = await themeBuild(file, {}, {cwd: tmpDir});
|
|
86
|
+
expect(built?.type).toBe('theme.build');
|
|
87
|
+
const checked = await themeBuild(file, {check: true}, {cwd: tmpDir});
|
|
88
|
+
expect(checked?.type).toBe('theme.build.check');
|
|
89
|
+
expect(checked?.data.upToDate).toBe(true);
|
|
90
|
+
expect(checked?.data.stale).toEqual([]);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
describe('themeBuild() — actual icon imports', () => {
|
|
94
|
+
it.each([
|
|
95
|
+
['named', 'liveIcons', "import {liveIcons} from './icons.mjs';"],
|
|
96
|
+
['default', 'default', "import liveIcons from './icons.mjs';"],
|
|
97
|
+
[
|
|
98
|
+
'aliased named',
|
|
99
|
+
'originalIcons',
|
|
100
|
+
"import {originalIcons as liveIcons} from './icons.mjs';",
|
|
101
|
+
],
|
|
102
|
+
])(
|
|
103
|
+
'preserves a %s registry import and its re-export',
|
|
104
|
+
async (_label, exportName, statement) => {
|
|
105
|
+
writeRegistry('icons.mjs', exportName, {close: 'close'});
|
|
106
|
+
write(
|
|
107
|
+
'live.mjs',
|
|
108
|
+
`${statement}
|
|
109
|
+
export default {name: 'live', tokens: {'--color-bg': '#fff'}, icons: liveIcons};
|
|
110
|
+
`,
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
await buildAndCheck('live.mjs');
|
|
114
|
+
|
|
115
|
+
expect(readBuiltIcons('live', 'liveIcons')).toEqual({close: 'close'});
|
|
116
|
+
if (exportName === 'liveIcons') {
|
|
117
|
+
const generated = fs.readFileSync(path.join(tmpDir, 'live.js'), 'utf8');
|
|
118
|
+
expect(generated).toContain("import { liveIcons } from './icons.mjs';");
|
|
119
|
+
expect(generated).toContain('icons: liveIcons,');
|
|
120
|
+
expect(generated).toContain('export { liveIcons };');
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
it('preserves a namespace used directly as the icon registry', async () => {
|
|
126
|
+
write(
|
|
127
|
+
'icons.mjs',
|
|
128
|
+
`import {createElement} from 'react';
|
|
129
|
+
export const close = createElement('svg', {'data-icon': 'close'}, createElement('path', {d: 'M0 0h1'}));
|
|
130
|
+
`,
|
|
131
|
+
);
|
|
132
|
+
write(
|
|
133
|
+
'live.mjs',
|
|
134
|
+
`import * as liveIcons from './icons.mjs';
|
|
135
|
+
export default {name: 'live', tokens: {'--color-bg': '#fff'}, icons: liveIcons};
|
|
136
|
+
`,
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
await buildAndCheck('live.mjs');
|
|
140
|
+
|
|
141
|
+
expect(readBuiltIcons('live', 'liveIcons')).toEqual({close: 'close'});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('uses the selected export instead of an unrelated earlier icons field', async () => {
|
|
145
|
+
writeRegistry('icons.mjs', 'liveIcons', {close: 'selected'});
|
|
146
|
+
write(
|
|
147
|
+
'selected.mjs',
|
|
148
|
+
`import {liveIcons} from './icons.mjs';
|
|
149
|
+
const inlineIcons = {close: 'unrelated'};
|
|
150
|
+
const metadata = {icons: inlineIcons};
|
|
151
|
+
export const otherTheme = {name: 'other', tokens: {}, icons: inlineIcons};
|
|
152
|
+
export default {name: 'selected', tokens: {'--color-bg': '#fff'}, icons: liveIcons};
|
|
153
|
+
`,
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
await buildAndCheck('selected.mjs');
|
|
157
|
+
|
|
158
|
+
expect(readBuiltIcons('selected', 'liveIcons')).toEqual({
|
|
159
|
+
close: 'selected',
|
|
160
|
+
});
|
|
161
|
+
expect(fs.existsSync(path.join(tmpDir, 'other.js'))).toBe(false);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('rejects the selected inline registry even when another theme imports icons', async () => {
|
|
165
|
+
writeRegistry('icons.mjs', 'liveIcons', {close: 'unselected'});
|
|
166
|
+
write(
|
|
167
|
+
'selected.mjs',
|
|
168
|
+
`import {liveIcons} from './icons.mjs';
|
|
169
|
+
export const otherTheme = {name: 'other', tokens: {}, icons: liveIcons};
|
|
170
|
+
const inlineIcons = {close: 'selected'};
|
|
171
|
+
export default {name: 'selected', tokens: {'--color-bg': '#fff'}, icons: inlineIcons};
|
|
172
|
+
`,
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
await expect(
|
|
176
|
+
themeBuild('selected.mjs', {}, {cwd: tmpDir}),
|
|
177
|
+
).rejects.toMatchObject({code: 'ERR_THEME_INVALID'});
|
|
178
|
+
expect(fs.readdirSync(tmpDir).sort()).toEqual([
|
|
179
|
+
'icons.mjs',
|
|
180
|
+
'selected.mjs',
|
|
181
|
+
]);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('unwraps TypeScript assertions around an aliased defineTheme call', async () => {
|
|
185
|
+
writeRegistry('icons.mjs', 'liveIcons', {close: 'wrapped-close'});
|
|
186
|
+
write(
|
|
187
|
+
'wrapped.ts',
|
|
188
|
+
`import {defineTheme as createTheme} from '@astryxdesign/core/theme';
|
|
189
|
+
import {liveIcons} from './icons.mjs';
|
|
190
|
+
export default createTheme(({
|
|
191
|
+
name: 'wrapped', tokens: {'--color-bg': '#fff'}, icons: liveIcons,
|
|
192
|
+
} as const) satisfies Parameters<typeof createTheme>[0]);
|
|
193
|
+
`,
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
await buildAndCheck('wrapped.ts');
|
|
197
|
+
|
|
198
|
+
expect(readBuiltIcons('wrapped', 'liveIcons')).toEqual({
|
|
199
|
+
close: 'wrapped-close',
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('ignores an icons field mentioned only in a string', async () => {
|
|
204
|
+
write(
|
|
205
|
+
'plain.mjs',
|
|
206
|
+
`const note = 'icons: retired';
|
|
207
|
+
export default {name: 'plain', tokens: {'--color-bg': '#fff'}};
|
|
208
|
+
`,
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
await buildAndCheck('plain.mjs');
|
|
212
|
+
|
|
213
|
+
const generated = fs.readFileSync(path.join(tmpDir, 'plain.js'), 'utf8');
|
|
214
|
+
expect(generated).not.toMatch(/^import /m);
|
|
215
|
+
expect(generated).not.toContain('icons:');
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('avoids collisions between the icon binding and the generated theme export', async () => {
|
|
219
|
+
writeRegistry('icons.mjs', 'collisionTheme', {close: 'collision-close'});
|
|
220
|
+
write(
|
|
221
|
+
'collision.mjs',
|
|
222
|
+
`import {collisionTheme} from './icons.mjs';
|
|
223
|
+
export default {name: 'collision', tokens: {'--color-bg': '#fff'}, icons: collisionTheme};
|
|
224
|
+
`,
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
await buildAndCheck('collision.mjs');
|
|
228
|
+
|
|
229
|
+
expect(readBuiltIcons('collision')).toEqual({close: 'collision-close'});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('does not treat a type-only import as a runtime icon binding', async () => {
|
|
233
|
+
writeRegistry('icons.mjs', 'inlineIcons', {close: 'type-only'});
|
|
234
|
+
write(
|
|
235
|
+
'inline.ts',
|
|
236
|
+
`import type {inlineIcons} from './icons.mjs';
|
|
237
|
+
const inlineIcons = {close: 'inline'};
|
|
238
|
+
export default {name: 'inline', tokens: {'--color-bg': '#fff'}, icons: inlineIcons};
|
|
239
|
+
`,
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
for (const check of [false, true]) {
|
|
243
|
+
await expect(
|
|
244
|
+
themeBuild('inline.ts', {check}, {cwd: tmpDir}),
|
|
245
|
+
).rejects.toMatchObject({code: 'ERR_THEME_INVALID'});
|
|
246
|
+
}
|
|
247
|
+
expect(fs.readdirSync(tmpDir).sort()).toEqual(['icons.mjs', 'inline.ts']);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it.each([
|
|
251
|
+
['an empty object', '{}'],
|
|
252
|
+
['only empty spreads', '{...null, ...undefined}'],
|
|
253
|
+
])(
|
|
254
|
+
'builds a root theme whose registry is %s without an icon import or field',
|
|
255
|
+
async (_label, registry) => {
|
|
256
|
+
write(
|
|
257
|
+
'empty.mjs',
|
|
258
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
259
|
+
export default defineTheme({
|
|
260
|
+
name: 'empty', tokens: {'--color-bg': '#fff'}, icons: ${registry},
|
|
261
|
+
});
|
|
262
|
+
`,
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
const fresh = await themeBuild('empty.mjs', {check: true}, {cwd: tmpDir});
|
|
266
|
+
expect(fresh?.data.upToDate).toBe(false);
|
|
267
|
+
await buildAndCheck('empty.mjs');
|
|
268
|
+
|
|
269
|
+
const generated = fs.readFileSync(path.join(tmpDir, 'empty.js'), 'utf8');
|
|
270
|
+
expect(generated).not.toMatch(/^import /m);
|
|
271
|
+
expect(generated).not.toContain('icons');
|
|
272
|
+
expect(
|
|
273
|
+
fs.readFileSync(path.join(tmpDir, 'empty.d.ts'), 'utf8'),
|
|
274
|
+
).not.toContain('IconRegistry');
|
|
275
|
+
},
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
describe.each([false, true])('fake icon imports (check: %s)', check => {
|
|
280
|
+
it.each([
|
|
281
|
+
[
|
|
282
|
+
'string',
|
|
283
|
+
`const note = "import { inlineIcons } from './ghost-icons.mjs'";`,
|
|
284
|
+
],
|
|
285
|
+
[
|
|
286
|
+
'template',
|
|
287
|
+
"const note = `import { inlineIcons } from './ghost-icons.mjs'`;",
|
|
288
|
+
],
|
|
289
|
+
[
|
|
290
|
+
'regular expression',
|
|
291
|
+
"const note = /import { inlineIcons } from 'ghost-icons.mjs'/;",
|
|
292
|
+
],
|
|
293
|
+
])(
|
|
294
|
+
'rejects an import inside a %s before creating or replacing outputs',
|
|
295
|
+
async (_label, decoy) => {
|
|
296
|
+
write(
|
|
297
|
+
'inline.mjs',
|
|
298
|
+
`${decoy}
|
|
299
|
+
const inlineIcons = {close: 'inline'};
|
|
300
|
+
export default {name: 'inline', tokens: {'--color-bg': '#fff'}, icons: inlineIcons};
|
|
301
|
+
`,
|
|
302
|
+
);
|
|
303
|
+
const originalFiles = fs.readdirSync(tmpDir);
|
|
304
|
+
await expect(
|
|
305
|
+
themeBuild(
|
|
306
|
+
'inline.mjs',
|
|
307
|
+
{check, out: 'dist/inline.css'},
|
|
308
|
+
{cwd: tmpDir},
|
|
309
|
+
),
|
|
310
|
+
).rejects.toMatchObject({code: 'ERR_THEME_INVALID'});
|
|
311
|
+
expect(fs.readdirSync(tmpDir)).toEqual(originalFiles);
|
|
312
|
+
|
|
313
|
+
fs.mkdirSync(path.join(tmpDir, 'dist'));
|
|
314
|
+
const outputs = ['inline.css', 'inline.js', 'inline.d.ts'];
|
|
315
|
+
for (const file of outputs) write(`dist/${file}`, `previous ${file}\n`);
|
|
316
|
+
await expect(
|
|
317
|
+
themeBuild(
|
|
318
|
+
'inline.mjs',
|
|
319
|
+
{check, out: 'dist/inline.css'},
|
|
320
|
+
{cwd: tmpDir},
|
|
321
|
+
),
|
|
322
|
+
).rejects.toMatchObject({code: 'ERR_THEME_INVALID'});
|
|
323
|
+
expect(fs.readdirSync(path.join(tmpDir, 'dist')).sort()).toEqual(
|
|
324
|
+
outputs.sort(),
|
|
325
|
+
);
|
|
326
|
+
for (const file of outputs) {
|
|
327
|
+
expect(fs.readFileSync(path.join(tmpDir, 'dist', file), 'utf8')).toBe(
|
|
328
|
+
`previous ${file}\n`,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
describe.each(['source', 'built'])(
|
|
336
|
+
'icons inherited from an imported %s base',
|
|
337
|
+
baseKind => {
|
|
338
|
+
async function writeBase() {
|
|
339
|
+
writeRegistry('base-icons.mjs', 'baseIcons', {
|
|
340
|
+
close: 'base-close',
|
|
341
|
+
check: 'base-check',
|
|
342
|
+
});
|
|
343
|
+
write(
|
|
344
|
+
'base.mjs',
|
|
345
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
346
|
+
import {baseIcons} from './base-icons.mjs';
|
|
347
|
+
export const baseTheme = defineTheme({
|
|
348
|
+
name: 'base', tokens: {'--color-bg': '#fff'}, icons: baseIcons,
|
|
349
|
+
});
|
|
350
|
+
`,
|
|
351
|
+
);
|
|
352
|
+
if (baseKind === 'built') await buildAndCheck('base.mjs');
|
|
353
|
+
return `./base.${baseKind === 'built' ? 'js' : 'mjs'}`;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
it('retains all base icons when the child has no local registry', async () => {
|
|
357
|
+
const baseSpecifier = await writeBase();
|
|
358
|
+
write(
|
|
359
|
+
'child.mjs',
|
|
360
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
361
|
+
import {baseTheme} from '${baseSpecifier}';
|
|
362
|
+
export default defineTheme({name: 'child', extends: baseTheme, tokens: {}});
|
|
363
|
+
`,
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
await buildAndCheck('child.mjs');
|
|
367
|
+
|
|
368
|
+
expect(readBuiltIcons('child')).toEqual({
|
|
369
|
+
close: 'base-close',
|
|
370
|
+
check: 'base-check',
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
it('keeps all base icons when the child sets an empty registry', async () => {
|
|
375
|
+
const baseSpecifier = await writeBase();
|
|
376
|
+
write(
|
|
377
|
+
'child.mjs',
|
|
378
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
379
|
+
import {baseTheme} from '${baseSpecifier}';
|
|
380
|
+
export default defineTheme({
|
|
381
|
+
name: 'child', extends: baseTheme, tokens: {}, icons: {},
|
|
382
|
+
});
|
|
383
|
+
`,
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
const fresh = await themeBuild('child.mjs', {check: true}, {cwd: tmpDir});
|
|
387
|
+
expect(fresh?.data.upToDate).toBe(false);
|
|
388
|
+
await buildAndCheck('child.mjs');
|
|
389
|
+
|
|
390
|
+
expect(readBuiltIcons('child')).toEqual({
|
|
391
|
+
close: 'base-close',
|
|
392
|
+
check: 'base-check',
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it('merges imported child icons over the base without dropping untouched keys', async () => {
|
|
397
|
+
const baseSpecifier = await writeBase();
|
|
398
|
+
writeRegistry('child-icons.mjs', 'childIcons', {
|
|
399
|
+
close: 'child-close',
|
|
400
|
+
add: 'child-add',
|
|
401
|
+
});
|
|
402
|
+
write(
|
|
403
|
+
'child.mjs',
|
|
404
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
405
|
+
import {baseTheme} from '${baseSpecifier}';
|
|
406
|
+
import {childIcons} from './child-icons.mjs';
|
|
407
|
+
export default defineTheme({
|
|
408
|
+
name: 'child', extends: baseTheme, tokens: {}, icons: childIcons,
|
|
409
|
+
});
|
|
410
|
+
`,
|
|
411
|
+
);
|
|
412
|
+
|
|
413
|
+
await buildAndCheck('child.mjs');
|
|
414
|
+
|
|
415
|
+
expect(readBuiltIcons('child')).toEqual({
|
|
416
|
+
close: 'child-close',
|
|
417
|
+
check: 'base-check',
|
|
418
|
+
add: 'child-add',
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
},
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
describe('themeBuild() — inherited icon module resolution', () => {
|
|
425
|
+
it.each(['named', 'namespace'])(
|
|
426
|
+
'redirects only the child registry when %s imports share a module',
|
|
427
|
+
async importKind => {
|
|
428
|
+
writeRegistry('base-icons.mjs', 'baseIcons', {
|
|
429
|
+
close: 'base-close',
|
|
430
|
+
check: 'base-check',
|
|
431
|
+
});
|
|
432
|
+
writeRegistry('child-icons.mjs', 'childIcons', {
|
|
433
|
+
close: 'child-close',
|
|
434
|
+
add: 'child-add',
|
|
435
|
+
});
|
|
436
|
+
write(
|
|
437
|
+
'icons.mjs',
|
|
438
|
+
`export {baseIcons} from './base-icons.mjs';
|
|
439
|
+
export {childIcons} from './child-icons.mjs';
|
|
440
|
+
`,
|
|
441
|
+
);
|
|
442
|
+
// The emitted child sidecar deliberately has no baseIcons export.
|
|
443
|
+
writeRegistry('built-icons.mjs', 'childIcons', {
|
|
444
|
+
close: 'child-close',
|
|
445
|
+
add: 'child-add',
|
|
446
|
+
});
|
|
447
|
+
write(
|
|
448
|
+
'child.mjs',
|
|
449
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
450
|
+
${importKind === 'named' ? "import {baseIcons, childIcons} from './icons.mjs';" : "import * as registries from './icons.mjs';"}
|
|
451
|
+
const baseTheme = defineTheme({
|
|
452
|
+
name: 'base', tokens: {'--color-bg': '#fff'}, icons: ${importKind === 'named' ? 'baseIcons' : 'registries.baseIcons'},
|
|
453
|
+
});
|
|
454
|
+
export default defineTheme({
|
|
455
|
+
name: 'child', extends: baseTheme, tokens: {}, icons: ${importKind === 'named' ? 'childIcons' : 'registries.childIcons'},
|
|
456
|
+
});
|
|
457
|
+
`,
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
const options = {iconsSpecifier: './built-icons.mjs'};
|
|
461
|
+
const built = await themeBuild('child.mjs', options, {cwd: tmpDir});
|
|
462
|
+
expect(built?.type).toBe('theme.build');
|
|
463
|
+
const checked = await themeBuild(
|
|
464
|
+
'child.mjs',
|
|
465
|
+
{...options, check: true},
|
|
466
|
+
{cwd: tmpDir},
|
|
467
|
+
);
|
|
468
|
+
expect(checked?.data.upToDate).toBe(true);
|
|
469
|
+
expect(readBuiltIcons('child')).toEqual({
|
|
470
|
+
close: 'child-close',
|
|
471
|
+
check: 'base-check',
|
|
472
|
+
add: 'child-add',
|
|
473
|
+
});
|
|
474
|
+
},
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
it('rebases a source base registry from its subdirectory to the child output', async () => {
|
|
478
|
+
fs.mkdirSync(path.join(tmpDir, 'brand'));
|
|
479
|
+
writeRegistry('brand/icons.mjs', 'brandIcons', {close: 'brand-close'});
|
|
480
|
+
write(
|
|
481
|
+
'brand/source.mjs',
|
|
482
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
483
|
+
import {brandIcons} from './icons.mjs';
|
|
484
|
+
export const brandTheme = defineTheme({
|
|
485
|
+
name: 'brand', tokens: {'--color-bg': '#fff'}, icons: brandIcons,
|
|
486
|
+
});
|
|
487
|
+
`,
|
|
488
|
+
);
|
|
489
|
+
write(
|
|
490
|
+
'child.mjs',
|
|
491
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
492
|
+
import {brandTheme} from './brand/source.mjs';
|
|
493
|
+
export default defineTheme({name: 'child', extends: brandTheme, tokens: {}});
|
|
494
|
+
`,
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
await buildAndCheck('child.mjs');
|
|
498
|
+
|
|
499
|
+
expect(readBuiltIcons('child')).toEqual({close: 'brand-close'});
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
it('resolves an extensionless TypeScript base before its generated JS sibling', async () => {
|
|
503
|
+
writeRegistry('icons.mjs', 'brandIcons', {close: 'source-close'});
|
|
504
|
+
write(
|
|
505
|
+
'base.ts',
|
|
506
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
507
|
+
import {brandIcons} from './icons.mjs';
|
|
508
|
+
export const brandTheme = defineTheme({
|
|
509
|
+
name: 'base', tokens: {'--color-bg': '#fff'}, icons: brandIcons,
|
|
510
|
+
});
|
|
511
|
+
`,
|
|
512
|
+
);
|
|
513
|
+
// The generated sibling exports baseTheme, while the source's public
|
|
514
|
+
// export is brandTheme. Selecting base.js would erase the child base.
|
|
515
|
+
await buildAndCheck('base.ts');
|
|
516
|
+
write(
|
|
517
|
+
'child.ts',
|
|
518
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
519
|
+
import {brandTheme} from './base';
|
|
520
|
+
export default defineTheme({name: 'child', extends: brandTheme, tokens: {}});
|
|
521
|
+
`,
|
|
522
|
+
);
|
|
523
|
+
|
|
524
|
+
await buildAndCheck('child.ts');
|
|
525
|
+
|
|
526
|
+
expect(readBuiltIcons('child')).toEqual({close: 'source-close'});
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
describe.each([false, true])(
|
|
531
|
+
'unsupported icon provenance (check: %s)',
|
|
532
|
+
check => {
|
|
533
|
+
it('fails to load a missing registry import instead of dropping its icons', async () => {
|
|
534
|
+
write(
|
|
535
|
+
'missing.mjs',
|
|
536
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
537
|
+
import {missingIcons} from './missing-icons.mjs';
|
|
538
|
+
export default defineTheme({
|
|
539
|
+
name: 'missing', tokens: {'--color-bg': '#fff'}, icons: missingIcons,
|
|
540
|
+
});
|
|
541
|
+
`,
|
|
542
|
+
);
|
|
543
|
+
|
|
544
|
+
await expect(
|
|
545
|
+
themeBuild(
|
|
546
|
+
'missing.mjs',
|
|
547
|
+
{check, out: 'dist/missing.css'},
|
|
548
|
+
{cwd: tmpDir},
|
|
549
|
+
),
|
|
550
|
+
).rejects.toMatchObject({code: 'ERR_THEME_LOAD'});
|
|
551
|
+
expect(fs.readdirSync(tmpDir)).toEqual(['missing.mjs']);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
it('rejects a registry mutated through a destructured theme alias before writing', async () => {
|
|
555
|
+
writeRegistry('icons.mjs', 'importedIcons', {
|
|
556
|
+
close: 'original-close',
|
|
557
|
+
check: 'retained-check',
|
|
558
|
+
});
|
|
559
|
+
write(
|
|
560
|
+
'mutated.mjs',
|
|
561
|
+
`import {importedIcons} from './icons.mjs';
|
|
562
|
+
const config = {
|
|
563
|
+
name: 'mutated', tokens: {'--color-bg': '#fff'}, icons: importedIcons,
|
|
564
|
+
};
|
|
565
|
+
const {icons} = config;
|
|
566
|
+
delete icons.close;
|
|
567
|
+
export default config;
|
|
568
|
+
`,
|
|
569
|
+
);
|
|
570
|
+
|
|
571
|
+
await expect(
|
|
572
|
+
themeBuild(
|
|
573
|
+
'mutated.mjs',
|
|
574
|
+
{check, out: 'dist/mutated.css'},
|
|
575
|
+
{cwd: tmpDir},
|
|
576
|
+
),
|
|
577
|
+
).rejects.toMatchObject({code: 'ERR_THEME_INVALID'});
|
|
578
|
+
expect(fs.readdirSync(tmpDir).sort()).toEqual([
|
|
579
|
+
'icons.mjs',
|
|
580
|
+
'mutated.mjs',
|
|
581
|
+
]);
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
it.each([
|
|
585
|
+
[
|
|
586
|
+
'a defineTheme argument',
|
|
587
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
588
|
+
import {config} from '@fixture/raw-theme';
|
|
589
|
+
export default defineTheme(config);
|
|
590
|
+
`,
|
|
591
|
+
],
|
|
592
|
+
[
|
|
593
|
+
'the selected re-export',
|
|
594
|
+
`export {config as default} from '@fixture/raw-theme';
|
|
595
|
+
`,
|
|
596
|
+
],
|
|
597
|
+
])(
|
|
598
|
+
'rejects an opaque package raw config used as %s before writing',
|
|
599
|
+
async (_label, source) => {
|
|
600
|
+
const packageDirectory = 'node_modules/@fixture/raw-theme';
|
|
601
|
+
fs.mkdirSync(path.join(tmpDir, packageDirectory), {recursive: true});
|
|
602
|
+
write(
|
|
603
|
+
`${packageDirectory}/package.json`,
|
|
604
|
+
JSON.stringify({
|
|
605
|
+
name: '@fixture/raw-theme',
|
|
606
|
+
type: 'module',
|
|
607
|
+
exports: './index.mjs',
|
|
608
|
+
}),
|
|
609
|
+
);
|
|
610
|
+
writeRegistry(`${packageDirectory}/icons.mjs`, 'baseIcons', {
|
|
611
|
+
close: 'inherited-close',
|
|
612
|
+
});
|
|
613
|
+
write(
|
|
614
|
+
`${packageDirectory}/index.mjs`,
|
|
615
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
616
|
+
import {baseIcons} from './icons.mjs';
|
|
617
|
+
const baseTheme = defineTheme({
|
|
618
|
+
name: 'package-base', tokens: {'--color-bg': '#fff'}, icons: baseIcons,
|
|
619
|
+
});
|
|
620
|
+
export const config = {name: 'raw-package', extends: baseTheme, tokens: {}};
|
|
621
|
+
`,
|
|
622
|
+
);
|
|
623
|
+
write('package-config.mjs', source);
|
|
624
|
+
|
|
625
|
+
await expect(
|
|
626
|
+
themeBuild(
|
|
627
|
+
'package-config.mjs',
|
|
628
|
+
{check, out: 'dist/raw-package.css'},
|
|
629
|
+
{cwd: tmpDir},
|
|
630
|
+
),
|
|
631
|
+
).rejects.toMatchObject({code: 'ERR_THEME_INVALID'});
|
|
632
|
+
expect(fs.readdirSync(tmpDir).sort()).toEqual([
|
|
633
|
+
'node_modules',
|
|
634
|
+
'package-config.mjs',
|
|
635
|
+
]);
|
|
636
|
+
},
|
|
637
|
+
);
|
|
638
|
+
},
|
|
639
|
+
);
|