@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0404a74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -86
- package/api/build/_adapter.d.mts +17 -0
- package/api/build/_adapter.mjs +53 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +199 -10
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.d.mts +6 -4
- package/api/build/kit/rank.mjs +132 -28
- package/api/build/kit/signals.d.mts +7 -1
- package/api/build/kit/signals.mjs +21 -10
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +14 -9
- package/api/build/kit/weights.d.mts +39 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +351 -46
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +86 -0
- package/api/build/kit/words.mjs +241 -1
- package/api/build/tree.mjs +1 -1
- package/api/component/__fixtures__/resolutions/modules.txt +5 -6
- package/api/component/_adapter.d.mts +26 -2
- package/api/component/_adapter.mjs +135 -8
- package/api/component/component.mjs +14 -1
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +11 -1
- package/api/discover/_adapter.mjs +95 -1
- package/api/discover/detail/item/item.mjs +5 -0
- package/api/discover/discover.mjs +12 -3
- package/api/discover/discover.type.d.mts +16 -3
- package/api/discover/discover.type.mjs +13 -3
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +57 -2
- package/api/docs/_adapter.mjs +266 -33
- package/api/docs/_entry-names-lazily.d.mts +22 -0
- package/api/docs/_entry-names-lazily.mjs +25 -0
- package/api/docs/_entry-names.d.mts +23 -0
- package/api/docs/_entry-names.mjs +105 -0
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +54 -5
- package/api/doctor/_adapter.mjs +162 -11
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +15 -3
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +31 -7
- package/api/doctor/theme-checks.d.mts +35 -3
- package/api/doctor/theme-checks.mjs +377 -29
- package/api/hook/_adapter.d.mts +10 -4
- package/api/hook/_adapter.mjs +41 -5
- package/api/hook/detail/detail.mjs +5 -2
- package/api/hook/detail/params/params.mjs +10 -3
- package/api/icon/_records.mjs +2 -1
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/integration/_adapter.d.mts +44 -0
- package/api/integration/_adapter.mjs +77 -1
- package/api/integration/add-helpers.mjs +10 -0
- package/api/integration/authoring-checks.mjs +11 -8
- package/api/integration/example-scope.d.mts +14 -0
- package/api/integration/example-scope.mjs +44 -0
- package/api/integration/example-scope.type.d.mts +29 -0
- package/api/integration/example-scope.type.mjs +25 -0
- package/api/integration/integrationExampleScope.doc.d.mts +11 -0
- package/api/integration/integrationExampleScope.doc.mjs +59 -0
- package/api/integration/pack-check.mjs +16 -1
- package/api/integration/validate-integration.d.mts +18 -6
- package/api/integration/validate-integration.mjs +129 -15
- package/api/integration/validate-integration.type.d.mts +22 -0
- package/api/integration/validate-integration.type.mjs +2 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.mjs +591 -195
- package/api/render/render.doc.mjs +11 -3
- package/api/render/render.type.d.mts +53 -1
- package/api/render/render.type.mjs +32 -2
- package/api/search/ORDERING.md +2 -2
- package/api/search/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- package/api/search/_candidate-score.d.mts +9 -4
- package/api/search/_candidate-score.mjs +133 -46
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +14 -0
- package/api/search/_lexical.mjs +93 -11
- package/api/search/_result.d.mts +11 -9
- package/api/search/_result.mjs +4 -4
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search-index.mjs +7 -1
- package/api/search/search.d.mts +1 -1
- package/api/template/_adapter.d.mts +16 -0
- package/api/template/_adapter.mjs +39 -2
- package/api/template/cdn/cdn.mjs +37 -8
- package/api/template/copy/copy.d.mts +6 -3
- package/api/template/copy/copy.mjs +40 -8
- package/api/template/template.doc.mjs +3 -3
- package/api/template/template.mjs +63 -11
- package/api/template/template.type.d.mts +1 -0
- package/api/template/template.type.mjs +1 -0
- package/api/theme/_adapter.d.mts +12 -1
- package/api/theme/_adapter.mjs +132 -13
- package/api/theme/_app-provider.d.mts +31 -0
- package/api/theme/_app-provider.mjs +135 -0
- package/api/theme/add/add.mjs +3 -1
- package/api/theme/build/build.d.mts +142 -1
- package/api/theme/build/build.mjs +692 -284
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +10 -0
- package/api/theme/build/font-warning.d.mts +80 -5
- package/api/theme/build/font-warning.mjs +323 -55
- package/api/theme/build/icon-imports.mjs +51 -9
- package/api/theme/build/null-values.d.mts +28 -0
- package/api/theme/build/null-values.mjs +191 -0
- package/api/theme/list/list.mjs +17 -1
- package/api/theme/remove/remove.d.mts +2 -1
- package/api/theme/remove/remove.mjs +7 -3
- package/api/theme/theme.type.d.mts +78 -1
- package/api/theme/theme.type.mjs +38 -2
- package/api/theme/themeAdd.doc.mjs +1 -1
- package/api/theme/themeListAvailable.doc.mjs +1 -1
- package/api/theme/themeRemove.doc.mjs +8 -5
- package/api/theme-edit/_adapter.d.mts +116 -4
- package/api/theme-edit/_adapter.mjs +1058 -93
- package/api/theme-edit/_catalog.d.mts +46 -2
- package/api/theme-edit/_catalog.mjs +115 -14
- package/api/theme-edit/_check.d.mts +133 -24
- package/api/theme-edit/_check.mjs +3392 -531
- package/api/theme-edit/_color.d.mts +26 -0
- package/api/theme-edit/_color.mjs +92 -2
- package/api/theme-edit/_compiler.d.mts +5 -1
- package/api/theme-edit/_compiler.mjs +141 -17
- package/api/theme-edit/_context.d.mts +74 -6
- package/api/theme-edit/_context.mjs +468 -76
- package/api/theme-edit/_css.d.mts +21 -0
- package/api/theme-edit/_css.mjs +87 -14
- package/api/theme-edit/_edit.d.mts +74 -7
- package/api/theme-edit/_edit.mjs +4426 -319
- package/api/theme-edit/_how-commands.d.mts +76 -1
- package/api/theme-edit/_how-commands.mjs +793 -9
- package/api/theme-edit/_how-question.d.mts +97 -6
- package/api/theme-edit/_how-question.mjs +9184 -747
- package/api/theme-edit/_how.d.mts +5 -2
- package/api/theme-edit/_how.mjs +255 -46
- package/api/theme-edit/_importers.d.mts +38 -0
- package/api/theme-edit/_importers.mjs +188 -0
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_name-rule.d.mts +11 -0
- package/api/theme-edit/_name-rule.mjs +12 -0
- package/api/theme-edit/_normal.d.mts +322 -0
- package/api/theme-edit/_normal.mjs +1630 -0
- package/api/theme-edit/_palette.d.mts +49 -0
- package/api/theme-edit/_palette.mjs +180 -38
- package/api/theme-edit/_part-words.d.mts +39 -0
- package/api/theme-edit/_part-words.mjs +152 -0
- package/api/theme-edit/_parts.d.mts +55 -3
- package/api/theme-edit/_parts.mjs +421 -36
- package/api/theme-edit/_preview-app.d.mts +7 -13
- package/api/theme-edit/_preview-app.mjs +1108 -599
- package/api/theme-edit/_preview.d.mts +156 -19
- package/api/theme-edit/_preview.mjs +809 -180
- package/api/theme-edit/_project.d.mts +61 -1
- package/api/theme-edit/_project.mjs +177 -6
- package/api/theme-edit/_settings.d.mts +619 -48
- package/api/theme-edit/_settings.mjs +4910 -617
- package/api/theme-edit/_tables.d.mts +41 -0
- package/api/theme-edit/_tables.mjs +261 -41
- package/api/theme-edit/_vet.d.mts +31 -0
- package/api/theme-edit/_vet.mjs +114 -8
- package/api/theme-edit/theme-edit.type.d.mts +34 -2
- package/api/theme-edit/theme-edit.type.mjs +18 -3
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
- package/api/theme-edit/themeEditNew.doc.mjs +7 -4
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/api/upgrade/upgrade.mjs +16 -1
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/integration-runner.mjs +1 -1
- package/assets/codemods/jscodeshift.d.ts +1 -1
- package/assets/codemods/run-codemod.mjs +151 -18
- package/assets/codemods/runner.mjs +1 -4
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/component-list.generated.json +1 -0
- package/assets/docs/author-a-theme.doc.mjs +2 -0
- package/assets/docs/theme.doc.dense.mjs +76 -7
- package/assets/docs/theme.doc.mjs +66 -2
- package/assets/docs/theme.doc.zh.mjs +51 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/font-setup.doc.mjs +1 -1
- package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
- package/assets/docs/tree/render-pages.doc.mjs +46 -5
- package/assets/docs/tree/share-a-page.doc.mjs +157 -0
- package/assets/docs/tree/single-component.doc.mjs +4 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/docs-routes.generated.json +1 -0
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.tsx +43 -0
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
- package/assets/templates/pages/ai-chat-landing/page.tsx +31 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +1 -1
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +1 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-comparison/page.tsx +2 -2
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/page.tsx +1 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/page.tsx +60 -7
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/page.tsx +13 -13
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/page.tsx +14 -2
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/page.tsx +9 -0
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/form-wizard-vertical/page.tsx +23 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +33 -2
- package/assets/templates/pages/kanban-board/page.tsx +12 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/page.tsx +16 -0
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/page.tsx +19 -6
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/messaging-shell/template.doc.mjs +6 -0
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/payment-form/page.tsx +30 -4
- package/assets/templates/pages/product-detail/page.tsx +26 -2
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/page.tsx +162 -12
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/page.tsx +11 -3
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/page.tsx +9 -0
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/page.tsx +161 -133
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/page.tsx +14 -1
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/page.tsx +47 -7
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +9 -2
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +9 -9
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/authoring/example/example.doc.d.mts +12 -0
- package/authoring/example/example.doc.mjs +69 -0
- package/authoring/example/preview.d.mts +92 -0
- package/authoring/example/preview.mjs +994 -0
- package/authoring/example/type.ts +102 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +3 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +24 -1
- package/authoring/integration/schema.mjs +126 -4
- package/authoring/integration/type.ts +14 -0
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +22 -3
- package/clients/cli/commands/discover.mjs +70 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +44 -6
- package/clients/cli/commands/doctor.mjs +84 -16
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +1032 -134
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +4 -4
- package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.doc.mjs +1 -1
- package/clients/cli/commands/template.mjs +15 -2
- package/clients/cli/commands/theme-add.doc.mjs +1 -1
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme-list.doc.mjs +1 -1
- package/clients/cli/commands/theme-remove.doc.mjs +13 -5
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +849 -441
- package/clients/cli/commands/upgrade.mjs +46 -8
- package/clients/cli/index.mjs +9 -19
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/lib/json-shim.mjs +265 -29
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/lib/stray-option.mjs +478 -0
- package/clients/cli/lib/unknown-command.mjs +353 -0
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/project.d.mts +8 -0
- package/foundation/config/project.mjs +26 -29
- package/foundation/config/theme-state.d.mts +31 -2
- package/foundation/config/theme-state.mjs +140 -8
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/cli-self-doc-names.d.mts +13 -0
- package/foundation/discovery/cli-self-doc-names.mjs +51 -0
- package/foundation/discovery/cli-self-docs.d.mts +0 -2
- package/foundation/discovery/cli-self-docs.mjs +2 -15
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +59 -10
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/core-component-docs.d.mts +29 -0
- package/foundation/discovery/core-component-docs.mjs +83 -0
- package/foundation/discovery/core-theme-facts.d.mts +70 -0
- package/foundation/discovery/core-theme-facts.mjs +384 -0
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/docs-discovery.d.mts +66 -9
- package/foundation/discovery/docs-discovery.mjs +126 -60
- package/foundation/discovery/entry-name-files.d.mts +106 -0
- package/foundation/discovery/entry-name-files.mjs +354 -0
- package/foundation/discovery/hook-discovery.d.mts +18 -2
- package/foundation/discovery/hook-discovery.mjs +93 -42
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-component-views.d.mts +15 -0
- package/foundation/discovery/integration-component-views.mjs +91 -0
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/module-exports.d.mts +26 -1
- package/foundation/discovery/module-exports.mjs +114 -40
- package/foundation/discovery/name-roots.d.mts +38 -0
- package/foundation/discovery/name-roots.mjs +108 -0
- package/foundation/discovery/next-routes.d.mts +48 -0
- package/foundation/discovery/next-routes.mjs +181 -0
- package/foundation/discovery/package-exports.d.mts +10 -0
- package/foundation/discovery/package-exports.mjs +56 -3
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/stored-component-list.d.mts +43 -0
- package/foundation/discovery/stored-component-list.mjs +90 -0
- package/foundation/discovery/stored-search-catalog.d.mts +115 -0
- package/foundation/discovery/stored-search-catalog.mjs +297 -0
- package/foundation/discovery/stored-self-audit.d.mts +26 -10
- package/foundation/discovery/stored-self-audit.mjs +40 -18
- package/foundation/discovery/template-adapter.d.mts +49 -29
- package/foundation/discovery/template-adapter.mjs +89 -99
- package/foundation/discovery/template-destination.d.mts +28 -0
- package/foundation/discovery/template-destination.mjs +104 -0
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/template-ids.d.mts +69 -0
- package/foundation/discovery/template-ids.mjs +199 -0
- package/foundation/discovery/theme-discovery.d.mts +12 -0
- package/foundation/discovery/theme-discovery.mjs +34 -4
- package/foundation/discovery/theme-imports.d.mts +24 -0
- package/foundation/discovery/theme-imports.mjs +61 -4
- package/foundation/discovery/theming-targets.d.mts +13 -5
- package/foundation/discovery/theming-targets.mjs +41 -47
- package/foundation/doc-compiler/generated-levels.d.mts +43 -0
- package/foundation/doc-compiler/generated-levels.mjs +72 -0
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/literal-doc.d.mts +12 -0
- package/foundation/doc-compiler/literal-doc.mjs +322 -0
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +29 -0
- package/foundation/doc-compiler/stored-docs.mjs +63 -1
- package/foundation/doc-compiler/tree.d.mts +4 -84
- package/foundation/doc-compiler/tree.mjs +4 -62
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +46 -0
- package/foundation/fonts/font-stylesheet.mjs +173 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/exact-codec.d.mts +12 -2
- package/foundation/fs/exact-codec.mjs +23 -6
- package/foundation/fs/file-protection.mjs +16 -5
- package/foundation/fs/gather-cache.d.mts +94 -4
- package/foundation/fs/gather-cache.mjs +671 -106
- package/foundation/fs/glob.d.mts +16 -0
- package/foundation/fs/glob.mjs +105 -0
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +80 -0
- package/foundation/fs/kept-tree.mjs +240 -0
- package/foundation/fs/listing-cache.d.mts +7 -0
- package/foundation/fs/listing-cache.mjs +10 -0
- package/foundation/fs/module-loader.d.mts +24 -2
- package/foundation/fs/module-loader.mjs +94 -21
- package/foundation/fs/path-safety.d.mts +11 -2
- package/foundation/fs/path-safety.mjs +108 -18
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +56 -7
- package/foundation/fs/read-record.mjs +280 -56
- package/foundation/fs/regular-file.d.mts +29 -0
- package/foundation/fs/regular-file.mjs +77 -0
- package/foundation/fs/stop-cleanup.d.mts +12 -0
- package/foundation/fs/stop-cleanup.mjs +66 -0
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/example-code.d.mts +63 -0
- package/foundation/integrations/example-code.mjs +416 -0
- package/foundation/integrations/integrations.d.mts +23 -1
- package/foundation/integrations/integrations.mjs +18 -1
- package/foundation/integrations/pack-state.d.mts +75 -0
- package/foundation/integrations/pack-state.mjs +314 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/shipped-imports.d.mts +122 -0
- package/foundation/integrations/shipped-imports.mjs +497 -0
- package/foundation/integrations/validate-contributions.d.mts +0 -17
- package/foundation/integrations/validate-contributions.mjs +59 -333
- package/foundation/render/assets.mjs +52 -7
- package/foundation/render/charts.d.mts +78 -27
- package/foundation/render/charts.mjs +266 -90
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +70 -7
- package/foundation/render/embedded-imports.mjs +132 -41
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/layers.d.mts +30 -0
- package/foundation/render/layers.mjs +158 -0
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/offline.d.mts +32 -0
- package/foundation/render/offline.mjs +56 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +354 -21
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +192 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +46 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +79 -5
- package/foundation/render/render-page.mjs +735 -109
- package/foundation/render/source-block.d.mts +85 -6
- package/foundation/render/source-block.mjs +211 -20
- package/foundation/render/ts-paths.d.mts +69 -6
- package/foundation/render/ts-paths.mjs +326 -40
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +6 -6
- package/foundation/suggest/name-index.d.mts +148 -0
- package/foundation/suggest/name-index.mjs +317 -0
- package/foundation/suggest/other-command.d.mts +140 -0
- package/foundation/suggest/other-command.mjs +756 -0
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/css-escape.d.mts +18 -0
- package/foundation/text/css-escape.mjs +35 -0
- package/foundation/text/entry-names.d.mts +14 -0
- package/foundation/text/entry-names.mjs +14 -0
- package/foundation/text/string-utils.d.mts +46 -6
- package/foundation/text/string-utils.mjs +118 -20
- package/foundation/text/suggest-order.d.mts +47 -4
- package/foundation/text/suggest-order.mjs +174 -5
- package/foundation/xle/browser.d.mts +2 -2
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
package/api/theme/_adapter.mjs
CHANGED
|
@@ -33,15 +33,18 @@ import {
|
|
|
33
33
|
import {
|
|
34
34
|
ThemeImportError,
|
|
35
35
|
resolveThemeImports,
|
|
36
|
+
themePackageDir,
|
|
36
37
|
} from '../../foundation/discovery/theme-imports.mjs';
|
|
37
38
|
import {
|
|
38
39
|
findThemeProject,
|
|
39
40
|
editorThemeRecord,
|
|
40
41
|
isLocalThemeOwner,
|
|
42
|
+
isUneditedThemeModule,
|
|
41
43
|
LOCAL_THEME_ROOT,
|
|
42
44
|
ThemeStateError,
|
|
43
45
|
planThemeAppWrite,
|
|
44
46
|
readThemeState,
|
|
47
|
+
resolveThemeModule,
|
|
45
48
|
} from '../../foundation/config/theme-state.mjs';
|
|
46
49
|
import {AstryxError} from '../error.mjs';
|
|
47
50
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
@@ -61,6 +64,7 @@ import {
|
|
|
61
64
|
import {fsErrorMessage} from '../../foundation/fs/fs-error.mjs';
|
|
62
65
|
import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
|
|
63
66
|
import {analyzeTemplateNeeds} from '../../foundation/discovery/template-needs.mjs';
|
|
67
|
+
import {compareText} from '../../foundation/text/compare-text.mjs';
|
|
64
68
|
|
|
65
69
|
export {BUNDLED_THEME_PACKAGE, THEMES_DIR};
|
|
66
70
|
|
|
@@ -72,6 +76,19 @@ export function themeRecordOwner(theme) {
|
|
|
72
76
|
return themeImportPackage(theme);
|
|
73
77
|
}
|
|
74
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Whether a theme's owner is installed, by the rule `theme add` applies
|
|
81
|
+
* (`themePackageDir`): a local theme is in the project, and a package
|
|
82
|
+
* theme's package (a bundled theme's own, such as
|
|
83
|
+
* `@astryxdesign/theme-neutral`) is installed. A local theme `theme add`
|
|
84
|
+
* still refuses until it is built.
|
|
85
|
+
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
|
|
86
|
+
* @param {string} projectDir
|
|
87
|
+
*/
|
|
88
|
+
export function themeOwnerInstalled(theme, projectDir) {
|
|
89
|
+
return theme.source === 'local' || themePackageDir(theme, projectDir) != null;
|
|
90
|
+
}
|
|
91
|
+
|
|
75
92
|
/**
|
|
76
93
|
* Whether `--package <name>` selects a theme. It takes either name the CLI
|
|
77
94
|
* shows for it: the package that provides it (`@astryxdesign/cli` for a
|
|
@@ -1005,7 +1022,7 @@ export function themeCommandsFor(command, slug, available, cwd) {
|
|
|
1005
1022
|
(a, b) =>
|
|
1006
1023
|
levenshteinDistance(needle, a.slug.toLowerCase()) -
|
|
1007
1024
|
levenshteinDistance(needle, b.slug.toLowerCase()) ||
|
|
1008
|
-
a.slug
|
|
1025
|
+
compareText(a.slug, b.slug),
|
|
1009
1026
|
)
|
|
1010
1027
|
.slice(0, 5)
|
|
1011
1028
|
.map(theme => ({
|
|
@@ -1186,6 +1203,7 @@ async function writeThemeApp(
|
|
|
1186
1203
|
stylesheet: theme.stylesheet,
|
|
1187
1204
|
...(theme.fontStylesheet ? {fontStylesheet: theme.fontStylesheet} : {}),
|
|
1188
1205
|
source: theme.source,
|
|
1206
|
+
...(theme.mode ? {mode: theme.mode} : {}),
|
|
1189
1207
|
})),
|
|
1190
1208
|
default: defaultSlug,
|
|
1191
1209
|
modulePath: prepared.module.path,
|
|
@@ -1194,6 +1212,15 @@ async function writeThemeApp(
|
|
|
1194
1212
|
slug,
|
|
1195
1213
|
changed,
|
|
1196
1214
|
firstAdd: action === 'add' && !state.configured,
|
|
1215
|
+
// The module lists one-mode themes' modes for the first time, after
|
|
1216
|
+
// the app was wired without them: the wiring takes the mode now.
|
|
1217
|
+
...(state.configured &&
|
|
1218
|
+
/\bexport const themeModes\b/.test(prepared.moduleContents) &&
|
|
1219
|
+
!/\bexport const themeModes\b/.test(
|
|
1220
|
+
String(prepared.module.expectedOriginal ?? ''),
|
|
1221
|
+
)
|
|
1222
|
+
? {wireModes: true}
|
|
1223
|
+
: {}),
|
|
1197
1224
|
},
|
|
1198
1225
|
...(notes.length > 0 ? {notes} : {}),
|
|
1199
1226
|
},
|
|
@@ -1404,7 +1431,8 @@ function recordedThemeSlug(state, slug) {
|
|
|
1404
1431
|
}
|
|
1405
1432
|
|
|
1406
1433
|
/**
|
|
1407
|
-
* Remove one
|
|
1434
|
+
* Remove one added theme from the app record. The default is removed only
|
|
1435
|
+
* when it is the only added theme: that deletes the generated module.
|
|
1408
1436
|
* @param {string} slug
|
|
1409
1437
|
* @param {{cwd?: string}} [options]
|
|
1410
1438
|
* @returns {Promise<import('./theme.type.mjs').ThemeAppResponse>}
|
|
@@ -1425,22 +1453,14 @@ async function removeThemeFromAppLocked(slug, cwd) {
|
|
|
1425
1453
|
const others = Object.keys(state.themes).filter(
|
|
1426
1454
|
other => other !== recordedSlug,
|
|
1427
1455
|
);
|
|
1456
|
+
if (others.length === 0) return await removeLastTheme(state, recordedSlug);
|
|
1428
1457
|
const uses = others.slice(0, 3).map(other => ({
|
|
1429
1458
|
name: formatCliCommand(`theme use ${other}`, state.projectDir),
|
|
1430
1459
|
reason: `make ${other} the default`,
|
|
1431
1460
|
}));
|
|
1432
1461
|
throw new AstryxError(
|
|
1433
|
-
uses.
|
|
1434
|
-
|
|
1435
|
-
: `Theme "${recordedSlug}" is the default and the only added theme. Add another theme and make it the default before removing it.`,
|
|
1436
|
-
uses.length > 0
|
|
1437
|
-
? uses
|
|
1438
|
-
: [
|
|
1439
|
-
{
|
|
1440
|
-
name: formatCliCommand('theme list', state.projectDir),
|
|
1441
|
-
reason: 'the themes you can add',
|
|
1442
|
-
},
|
|
1443
|
-
],
|
|
1462
|
+
`Theme "${recordedSlug}" is the default. Run \`${uses[0].name}\` before removing it.`,
|
|
1463
|
+
uses,
|
|
1444
1464
|
ERROR_CODES.ERR_THEME_INVALID,
|
|
1445
1465
|
);
|
|
1446
1466
|
}
|
|
@@ -1473,6 +1493,105 @@ async function removeThemeFromAppLocked(slug, cwd) {
|
|
|
1473
1493
|
);
|
|
1474
1494
|
}
|
|
1475
1495
|
|
|
1496
|
+
/**
|
|
1497
|
+
* Remove the only added theme by deleting the generated module, which is the
|
|
1498
|
+
* app's whole theme record. A module with changes the CLI did not write stays,
|
|
1499
|
+
* and the error says how to finish by hand.
|
|
1500
|
+
* @param {ReturnType<typeof readThemeState>} state
|
|
1501
|
+
* @param {string} slug
|
|
1502
|
+
* @returns {Promise<import('./theme.type.mjs').ThemeAppResponse>}
|
|
1503
|
+
*/
|
|
1504
|
+
async function removeLastTheme(state, slug) {
|
|
1505
|
+
let module;
|
|
1506
|
+
try {
|
|
1507
|
+
// The project-root check every theme write runs: a `src` that is a
|
|
1508
|
+
// symlink to a folder outside the project must not lose a file there.
|
|
1509
|
+
module = resolveThemeModule(state.projectDir, {forWrite: true});
|
|
1510
|
+
} catch (error) {
|
|
1511
|
+
throw asThemeError(error);
|
|
1512
|
+
}
|
|
1513
|
+
const original = module.expectedOriginal;
|
|
1514
|
+
const source = original?.toString('utf-8') ?? '';
|
|
1515
|
+
if (original == null || !(await isUneditedModule(state, source))) {
|
|
1516
|
+
// A module the CLI wrote whose imports differ from what it writes now (a
|
|
1517
|
+
// theme package upgrade moves them) is rewritten by `theme use`.
|
|
1518
|
+
const use = formatCliCommand(`theme use ${slug}`, state.projectDir);
|
|
1519
|
+
const rewritable =
|
|
1520
|
+
original != null && isUneditedThemeModule(source, module.typescript);
|
|
1521
|
+
throw new AstryxError(
|
|
1522
|
+
rewritable
|
|
1523
|
+
? `Theme "${slug}" is the only added theme, and ${module.path} differs from what the CLI writes for it now, as after a theme package upgrade, so the CLI leaves it. Run \`${use}\` to rewrite it, then remove the theme again.`
|
|
1524
|
+
: `Theme "${slug}" is the only added theme, and ${module.path} has changes the CLI did not write, so the CLI leaves it. To stop using app themes, delete ${module.path} and remove its import and the Theme wrapper from the app root.`,
|
|
1525
|
+
rewritable
|
|
1526
|
+
? [{name: use, reason: 'rewrite the module, then remove the theme'}]
|
|
1527
|
+
: undefined,
|
|
1528
|
+
ERROR_CODES.ERR_THEME_INVALID,
|
|
1529
|
+
);
|
|
1530
|
+
}
|
|
1531
|
+
try {
|
|
1532
|
+
if (fs.lstatSync(module.file).isSymbolicLink()) {
|
|
1533
|
+
throw new Error(`${module.path} is a symlink`);
|
|
1534
|
+
}
|
|
1535
|
+
if (!fs.readFileSync(module.file).equals(original)) {
|
|
1536
|
+
throw new Error(`${module.path} changed while the command ran`);
|
|
1537
|
+
}
|
|
1538
|
+
fs.unlinkSync(module.file);
|
|
1539
|
+
} catch (error) {
|
|
1540
|
+
throw new AstryxError(
|
|
1541
|
+
`Failed to delete the generated theme module: ${fsErrorMessage(error, module.path) ?? (error instanceof Error ? error.message : String(error))}`,
|
|
1542
|
+
undefined,
|
|
1543
|
+
ERROR_CODES.ERR_WRITE_FAILED,
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
return {
|
|
1547
|
+
type: 'theme.app',
|
|
1548
|
+
data: {
|
|
1549
|
+
themes: [],
|
|
1550
|
+
default: '',
|
|
1551
|
+
modulePath: module.path,
|
|
1552
|
+
change: {
|
|
1553
|
+
action: 'remove',
|
|
1554
|
+
slug,
|
|
1555
|
+
changed: true,
|
|
1556
|
+
firstAdd: false,
|
|
1557
|
+
moduleRemoved: true,
|
|
1558
|
+
...(/\bexport const themeModes\b/u.test(source)
|
|
1559
|
+
? {themeModes: true}
|
|
1560
|
+
: {}),
|
|
1561
|
+
},
|
|
1562
|
+
},
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* Is the module exactly what the CLI writes for its record? While the recorded
|
|
1568
|
+
* themes resolve, it must equal the module the CLI would write now. When one
|
|
1569
|
+
* no longer resolves (its package is already uninstalled), the module is
|
|
1570
|
+
* re-rendered from its own imports, which must still come from the recorded
|
|
1571
|
+
* owners.
|
|
1572
|
+
* @param {ReturnType<typeof readThemeState>} state
|
|
1573
|
+
* @param {string} source
|
|
1574
|
+
*/
|
|
1575
|
+
async function isUneditedModule(state, source) {
|
|
1576
|
+
let resolved;
|
|
1577
|
+
try {
|
|
1578
|
+
resolved = resolveRecordedThemes(
|
|
1579
|
+
state,
|
|
1580
|
+
await listAvailableThemes(state.projectDir),
|
|
1581
|
+
);
|
|
1582
|
+
} catch {
|
|
1583
|
+
return isUneditedThemeModule(source, state.module.typescript);
|
|
1584
|
+
}
|
|
1585
|
+
try {
|
|
1586
|
+
return (
|
|
1587
|
+
planThemeAppWrite(state, state.themes, state.defaultSlug ?? '', resolved)
|
|
1588
|
+
.moduleContents === source
|
|
1589
|
+
);
|
|
1590
|
+
} catch {
|
|
1591
|
+
return false;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1476
1595
|
/**
|
|
1477
1596
|
* Select one added theme as the app default.
|
|
1478
1597
|
* @param {string} slug
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {{export: string, from: string, themeProp?: string, modeProp?: string}} AppProvider
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A receipt with its `appProvider` (theme.type.mjs ThemeAppResponse) when an
|
|
9
|
+
* installed package names a provider and the receipt shows wiring.
|
|
10
|
+
*
|
|
11
|
+
* - First add: `wire` says the app may already get its theme from each such
|
|
12
|
+
* provider, naming the props it takes. With exactly one provider, and that
|
|
13
|
+
* one taking a theme object (`themeProp`), the wiring is that provider
|
|
14
|
+
* with the theme passed (`line`, its opening JSX); otherwise each
|
|
15
|
+
* provider's trade-off follows and the `Theme` wiring stays.
|
|
16
|
+
* - A later add that first lists `themeModes`, or the removal of the last
|
|
17
|
+
* theme: only when that one provider takes the theme, `wire` and `line`
|
|
18
|
+
* say how its wiring changes.
|
|
19
|
+
*
|
|
20
|
+
* @template {import('./theme.type.mjs').ThemeAppResponse} R
|
|
21
|
+
* @param {R} result
|
|
22
|
+
* @param {string} cwd
|
|
23
|
+
* @returns {Promise<R>}
|
|
24
|
+
*/
|
|
25
|
+
export function withAppProvider<R extends import("./theme.type.mjs").ThemeAppResponse>(result: R, cwd: string): Promise<R>;
|
|
26
|
+
export type AppProvider = {
|
|
27
|
+
export: string;
|
|
28
|
+
from: string;
|
|
29
|
+
themeProp?: string;
|
|
30
|
+
modeProp?: string;
|
|
31
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The provider an installed integration names as the one that wires
|
|
5
|
+
* its themes (its manifest's `themeProvider`), on the receipts that show the
|
|
6
|
+
* app's wiring: the first add, a later add that first lists `themeModes`,
|
|
7
|
+
* and the removal of the last theme.
|
|
8
|
+
*
|
|
9
|
+
* Read from the packages' manifests, never from the app's source. The
|
|
10
|
+
* receipt says how Themes nest and never says to replace a provider, which
|
|
11
|
+
* may do more than theming. Shared by `theme add` and `theme remove`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {listAvailableThemeState} from './_adapter.mjs';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {{export: string, from: string, themeProp?: string, modeProp?: string}} AppProvider
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A receipt with its `appProvider` (theme.type.mjs ThemeAppResponse) when an
|
|
22
|
+
* installed package names a provider and the receipt shows wiring.
|
|
23
|
+
*
|
|
24
|
+
* - First add: `wire` says the app may already get its theme from each such
|
|
25
|
+
* provider, naming the props it takes. With exactly one provider, and that
|
|
26
|
+
* one taking a theme object (`themeProp`), the wiring is that provider
|
|
27
|
+
* with the theme passed (`line`, its opening JSX); otherwise each
|
|
28
|
+
* provider's trade-off follows and the `Theme` wiring stays.
|
|
29
|
+
* - A later add that first lists `themeModes`, or the removal of the last
|
|
30
|
+
* theme: only when that one provider takes the theme, `wire` and `line`
|
|
31
|
+
* say how its wiring changes.
|
|
32
|
+
*
|
|
33
|
+
* @template {import('./theme.type.mjs').ThemeAppResponse} R
|
|
34
|
+
* @param {R} result
|
|
35
|
+
* @param {string} cwd
|
|
36
|
+
* @returns {Promise<R>}
|
|
37
|
+
*/
|
|
38
|
+
export async function withAppProvider(result, cwd) {
|
|
39
|
+
const change = result.data.change;
|
|
40
|
+
const kind = change.moduleRemoved
|
|
41
|
+
? 'removed'
|
|
42
|
+
: change.firstAdd
|
|
43
|
+
? 'first'
|
|
44
|
+
: change.wireModes
|
|
45
|
+
? 'modes'
|
|
46
|
+
: null;
|
|
47
|
+
if (!kind) return result;
|
|
48
|
+
const {themes} = await listAvailableThemeState(cwd);
|
|
49
|
+
/** Each provider once, with the package that declares it. @type {Map<string, {provider: AppProvider, owner: string}>} */
|
|
50
|
+
const byProvider = new Map();
|
|
51
|
+
for (const theme of themes)
|
|
52
|
+
if (theme.provider)
|
|
53
|
+
byProvider.set(`${theme.provider.export}\0${theme.provider.from}`, {
|
|
54
|
+
provider: {
|
|
55
|
+
export: theme.provider.export,
|
|
56
|
+
from: theme.provider.from,
|
|
57
|
+
...(theme.provider.themeProp
|
|
58
|
+
? {themeProp: theme.provider.themeProp}
|
|
59
|
+
: {}),
|
|
60
|
+
...(theme.provider.themeProp && theme.provider.modeProp
|
|
61
|
+
? {modeProp: theme.provider.modeProp}
|
|
62
|
+
: {}),
|
|
63
|
+
},
|
|
64
|
+
owner: String(theme.package ?? theme.provider.from),
|
|
65
|
+
});
|
|
66
|
+
const found = [...byProvider.values()];
|
|
67
|
+
// Only one applicable provider gets the provider form: with two, which
|
|
68
|
+
// one wires the app is not ours to say.
|
|
69
|
+
const taking =
|
|
70
|
+
found.length === 1 && found[0].provider.themeProp ? found[0] : null;
|
|
71
|
+
if (!found.length || (kind !== 'first' && !taking)) return result;
|
|
72
|
+
// The wiring passes a mode when the provider takes one and an added theme
|
|
73
|
+
// has one color mode, as the Theme wiring does.
|
|
74
|
+
const oneMode =
|
|
75
|
+
kind === 'modes'
|
|
76
|
+
? true
|
|
77
|
+
: kind === 'removed'
|
|
78
|
+
? Boolean(change.themeModes)
|
|
79
|
+
: result.data.themes.some(t => t.mode);
|
|
80
|
+
const modeProp = oneMode ? taking?.provider.modeProp : undefined;
|
|
81
|
+
const line = taking
|
|
82
|
+
? `<${taking.provider.export} ${taking.provider.themeProp}={themes[defaultThemeSlug]}${modeProp ? ` ${modeProp}={themeModes[defaultThemeSlug]}` : ''}>`
|
|
83
|
+
: null;
|
|
84
|
+
const name = taking?.provider.export;
|
|
85
|
+
let wire;
|
|
86
|
+
if (kind === 'first') {
|
|
87
|
+
const named = found
|
|
88
|
+
.map(({provider, owner}) => {
|
|
89
|
+
const props = [
|
|
90
|
+
...(provider.themeProp ? [`the theme as ${provider.themeProp}`] : []),
|
|
91
|
+
...(provider.modeProp ? [`the mode as ${provider.modeProp}`] : []),
|
|
92
|
+
];
|
|
93
|
+
return `${provider.export} (from ${provider.from}, declared by ${owner}${props.length ? `; it takes ${props.join(' and ')}` : ''})`;
|
|
94
|
+
})
|
|
95
|
+
.join(' or ');
|
|
96
|
+
const from = `This app may already get its theme from ${named}.`;
|
|
97
|
+
wire = taking
|
|
98
|
+
? `${from} Pass this theme to it in the app root:`
|
|
99
|
+
: [
|
|
100
|
+
from,
|
|
101
|
+
...found.map(
|
|
102
|
+
({provider}) =>
|
|
103
|
+
`Replacing ${provider.export} applies this theme everywhere but also drops anything else it sets up; a Theme inside it themes only what it wraps.`,
|
|
104
|
+
),
|
|
105
|
+
].join(' ');
|
|
106
|
+
} else if (kind === 'modes')
|
|
107
|
+
wire = modeProp
|
|
108
|
+
? `The theme module now exports themeModes. Pass the selected theme's mode to ${name} in the app root:`
|
|
109
|
+
: `The theme module now exports themeModes; ${name} (from ${taking?.provider.from}), which takes the theme as ${taking?.provider.themeProp}, takes no mode, so its wiring stays as it is.`;
|
|
110
|
+
else
|
|
111
|
+
wire = `Undo its wiring in the app root: delete the module's import and the props that pass its theme to ${name}, and keep ${name}, which may set up more than the theme:`;
|
|
112
|
+
return {
|
|
113
|
+
...result,
|
|
114
|
+
data: {
|
|
115
|
+
...result.data,
|
|
116
|
+
appProvider: {
|
|
117
|
+
// A later receipt names only the props its wiring uses: a mode prop
|
|
118
|
+
// the line does not pass is left out, as the text leaves it out.
|
|
119
|
+
wiredBy: found.map(({provider}) =>
|
|
120
|
+
kind === 'first' || modeProp
|
|
121
|
+
? provider
|
|
122
|
+
: {
|
|
123
|
+
export: provider.export,
|
|
124
|
+
from: provider.from,
|
|
125
|
+
...(provider.themeProp ? {themeProp: provider.themeProp} : {}),
|
|
126
|
+
},
|
|
127
|
+
),
|
|
128
|
+
wire,
|
|
129
|
+
...(taking && line && (kind !== 'modes' || modeProp)
|
|
130
|
+
? {themeProp: String(taking.provider.themeProp), line}
|
|
131
|
+
: {}),
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
package/api/theme/add/add.mjs
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import {addThemeToApp} from '../_adapter.mjs';
|
|
12
|
+
import {withAppProvider} from '../_app-provider.mjs';
|
|
12
13
|
import {AstryxError} from '../../error.mjs';
|
|
13
14
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
14
15
|
|
|
@@ -36,5 +37,6 @@ export async function themeAdd(slug, options = {}) {
|
|
|
36
37
|
ERROR_CODES.ERR_THEME_INVALID,
|
|
37
38
|
);
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
const result = await addThemeToApp(slug, options);
|
|
41
|
+
return withAppProvider(result, options.cwd ?? process.cwd());
|
|
40
42
|
}
|
|
@@ -26,6 +26,15 @@
|
|
|
26
26
|
* @returns {() => any}
|
|
27
27
|
*/
|
|
28
28
|
export function lazyRootModule(resolveFile: () => string | null): () => any;
|
|
29
|
+
/**
|
|
30
|
+
* `target` spelled through real directories: the deepest ancestor that exists
|
|
31
|
+
* is resolved through its symlinks, and the missing rest is appended as given.
|
|
32
|
+
* The build groups and locates its outputs by it, and the theme editor's
|
|
33
|
+
* compile guard reads paths through it too, so both read a path the same way.
|
|
34
|
+
* @param {string} target absolute path
|
|
35
|
+
* @returns {string}
|
|
36
|
+
*/
|
|
37
|
+
export function realLocation(target: string): string;
|
|
29
38
|
/**
|
|
30
39
|
* Why `theme build` has no Core to generate with, and the fix for where it
|
|
31
40
|
* ran: the Astryx repository builds Core, an app installs it, and an installed
|
|
@@ -49,6 +58,8 @@ export function coreUnavailableMessage(cwd: string, importError: any): string;
|
|
|
49
58
|
* @returns {string}
|
|
50
59
|
*/
|
|
51
60
|
export function normalizeThemeBuildForCompare(content: string): string;
|
|
61
|
+
/** @param {string} dest absolute output path @param {string} root @returns {boolean} whether a build at `root` refuses to write `dest` */
|
|
62
|
+
export function refusedOutput(dest: string, root: string): boolean;
|
|
52
63
|
/**
|
|
53
64
|
* Whether `error` is a build's refusal of a theme that sets a private var
|
|
54
65
|
* (which `doctor` reports in its own check, not as a stale output).
|
|
@@ -57,6 +68,34 @@ export function normalizeThemeBuildForCompare(content: string): string;
|
|
|
57
68
|
* @returns {boolean}
|
|
58
69
|
*/
|
|
59
70
|
export function isPrivateVarRefusal(error: unknown): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The marks a file's leading comment carries (see `generatedMark`): a theme
|
|
73
|
+
* build's output, or a file the theme editor writes, with the command it
|
|
74
|
+
* names. The one reader build and doctor share.
|
|
75
|
+
* @param {string} source the start of the file
|
|
76
|
+
* @param {string} [file] its path, for a mark that names no exact command
|
|
77
|
+
*/
|
|
78
|
+
export function fileMark(source: string, file?: string): {
|
|
79
|
+
kind: "build" | "editor";
|
|
80
|
+
command: string;
|
|
81
|
+
} | null;
|
|
82
|
+
/**
|
|
83
|
+
* The command a file's leading comment says writes it, when another CLI
|
|
84
|
+
* command generates it (the theme editor's settings module or app copy):
|
|
85
|
+
* the exact command its mark names. Null for a theme build's own output and
|
|
86
|
+
* a file without a mark, such as a theme source of one's own.
|
|
87
|
+
* @param {string} file
|
|
88
|
+
* @returns {string | null}
|
|
89
|
+
*/
|
|
90
|
+
export function generatedFileCommand(file: string): string | null;
|
|
91
|
+
/**
|
|
92
|
+
* The command that writes `file`: from its own mark, or, when it is
|
|
93
|
+
* missing, from the files beside it (see `missingGeneratedCommand`); null
|
|
94
|
+
* otherwise.
|
|
95
|
+
* @param {string} file
|
|
96
|
+
* @returns {string | null}
|
|
97
|
+
*/
|
|
98
|
+
export function generatedSourceCommand(file: string): string | null;
|
|
60
99
|
/**
|
|
61
100
|
* The files a theme source is made of: the source and every local file it
|
|
62
101
|
* imports, directly or through other local files, read from their import
|
|
@@ -94,6 +133,16 @@ export function setEditorFolderListener(listener: ((warning: string) => void) |
|
|
|
94
133
|
* and `familyKey` names its key (a family run never takes --out).
|
|
95
134
|
* @typedef {{glob?: boolean, family?: boolean, familyKey?: string}} SuggestionShape
|
|
96
135
|
*/
|
|
136
|
+
/**
|
|
137
|
+
* The refusal a build gives the file it is given before it reads it, or
|
|
138
|
+
* null: a file that is not there, and a folder. The build throws it, and a
|
|
139
|
+
* suggested build is checked by it before it is offered.
|
|
140
|
+
* @param {string} file as typed, from cwd
|
|
141
|
+
* @param {BuildMode} options
|
|
142
|
+
* @param {string} cwd
|
|
143
|
+
* @returns {AstryxError | null}
|
|
144
|
+
*/
|
|
145
|
+
export function buildInputProblem(file: string, options: BuildMode, cwd: string): AstryxError | null;
|
|
97
146
|
/**
|
|
98
147
|
* The `theme build` command for `source` with the caller's mode flags, so a
|
|
99
148
|
* suggestion never turns a check into a write or moves the outputs.
|
|
@@ -129,12 +178,78 @@ export function writeDeferredBuildOutputs(deferred: Array<Array<{
|
|
|
129
178
|
* @returns {string}
|
|
130
179
|
*/
|
|
131
180
|
export function importSpecifier(relDir: string, base: string): string;
|
|
181
|
+
/**
|
|
182
|
+
* Load a theme module as a standalone build of it loads it (the Core the
|
|
183
|
+
* build selects, the same loader and interception) and name the export the
|
|
184
|
+
* build reads. Callers that must agree with the build on which theme a
|
|
185
|
+
* module defines read it here, never from the module's text.
|
|
186
|
+
*
|
|
187
|
+
* With `base`, also whether the theme extends that module's export, by
|
|
188
|
+
* identity, anywhere up its `extends` chain (`extendsBase`): the module is
|
|
189
|
+
* loaded once, and the theme module's imports of it (by any of
|
|
190
|
+
* `base.specifiers`) are handed that one load, so the answer is about the
|
|
191
|
+
* very object, not one that only looks like it.
|
|
192
|
+
* @param {string} file
|
|
193
|
+
* @param {{cwd?: string, base?: {file: string, exportName: string, specifiers: string[]}}} [ctx]
|
|
194
|
+
* @returns {Promise<{theme: any, exportName: string, extendsBase?: boolean}>}
|
|
195
|
+
*/
|
|
196
|
+
export function loadThemeExport(file: string, { cwd, base }?: {
|
|
197
|
+
cwd?: string;
|
|
198
|
+
base?: {
|
|
199
|
+
file: string;
|
|
200
|
+
exportName: string;
|
|
201
|
+
specifiers: string[];
|
|
202
|
+
};
|
|
203
|
+
}): Promise<{
|
|
204
|
+
theme: any;
|
|
205
|
+
exportName: string;
|
|
206
|
+
extendsBase?: boolean;
|
|
207
|
+
}>;
|
|
208
|
+
/**
|
|
209
|
+
* The input a theme module gives `defineTheme()` for the theme a build of
|
|
210
|
+
* it reads, evaluated as the build evaluates the module (an import, an
|
|
211
|
+
* expression, a spread or a computed key is its value), with the theme Core
|
|
212
|
+
* made of it. When Core refuses the input, the input the module gave for
|
|
213
|
+
* the named theme (else its last) and Core's error; null when the module
|
|
214
|
+
* does not load at all.
|
|
215
|
+
* `chain` holds the inputs of the themes it extends, nearest first, as far
|
|
216
|
+
* as each was made by a `defineTheme()` call this load saw.
|
|
217
|
+
* @param {string} file
|
|
218
|
+
* @param {{cwd?: string, name?: string}} [ctx]
|
|
219
|
+
* @returns {Promise<{input: any, theme: any, error: Error | null, chain: any[]} | null>}
|
|
220
|
+
*/
|
|
221
|
+
export function loadThemeInput(file: string, { cwd, name }?: {
|
|
222
|
+
cwd?: string;
|
|
223
|
+
name?: string;
|
|
224
|
+
}): Promise<{
|
|
225
|
+
input: any;
|
|
226
|
+
theme: any;
|
|
227
|
+
error: Error | null;
|
|
228
|
+
chain: any[];
|
|
229
|
+
} | null>;
|
|
230
|
+
/**
|
|
231
|
+
* A one-mode `colorModes` value (`['light']` or `['dark']`), or null for
|
|
232
|
+
* anything else: a theme with both modes needs no export.
|
|
233
|
+
* @param {unknown} value
|
|
234
|
+
* @returns {['light'] | ['dark'] | null}
|
|
235
|
+
*/
|
|
236
|
+
export function oneColorMode(value: unknown): ["light"] | ["dark"] | null;
|
|
132
237
|
/**
|
|
133
238
|
* The package a theme load failed on because it is not installed.
|
|
134
239
|
* @param {unknown} error
|
|
135
240
|
* @returns {string | null}
|
|
136
241
|
*/
|
|
137
242
|
export function missingThemePackage(error: unknown): string | null;
|
|
243
|
+
/**
|
|
244
|
+
* The package an import specifier names, or undefined when it names none:
|
|
245
|
+
* a relative or absolute path, a `#` subpath import, or a path alias such
|
|
246
|
+
* as `@/lib/c` or `~/lib/c`, which a bundler or tsconfig maps and the
|
|
247
|
+
* theme loader does not. A package name is `name` or `@scope/name`, of
|
|
248
|
+
* the characters npm takes, never starting with `.` or `_`.
|
|
249
|
+
* @param {string} specifier
|
|
250
|
+
* @returns {string | undefined}
|
|
251
|
+
*/
|
|
252
|
+
export function packageNameOf(specifier: string): string | undefined;
|
|
138
253
|
/**
|
|
139
254
|
* Load one theme through the build's real module loader and validate the raw
|
|
140
255
|
* input captured from its defineTheme lineage. Used by doctor so it applies the
|
|
@@ -346,9 +461,19 @@ export type ThemeBuildTrailer = {
|
|
|
346
461
|
*/
|
|
347
462
|
unloadedFonts: string[];
|
|
348
463
|
/**
|
|
349
|
-
* One notice per unloaded font family.
|
|
464
|
+
* One notice per unloaded font family, as printed.
|
|
350
465
|
*/
|
|
351
466
|
fontNotices: string[];
|
|
467
|
+
/**
|
|
468
|
+
* How the caller loads fonts, when it does.
|
|
469
|
+
*/
|
|
470
|
+
fontHelp?: FontHelp | null | undefined;
|
|
471
|
+
/**
|
|
472
|
+
* How the app takes the theme, when the
|
|
473
|
+
* caller wires it another way than importing these outputs (the editor's
|
|
474
|
+
* app copy).
|
|
475
|
+
*/
|
|
476
|
+
install?: string | null | undefined;
|
|
352
477
|
};
|
|
353
478
|
/**
|
|
354
479
|
* What the CLI hands a build beyond themeBuild's options. CLI-internal, never
|
|
@@ -359,6 +484,8 @@ export type ThemeBuildTrailer = {
|
|
|
359
484
|
* output must stay inside, for a scratch build; `commandWords` names the
|
|
360
485
|
* command in the rebuild hint; `prepareFamily`, `familyLoader`, and
|
|
361
486
|
* `familyInterception` make the build a family member's plan.
|
|
487
|
+
* `colorModes` is the one color mode a calling command knows the theme has
|
|
488
|
+
* (the theme editor, from its settings), written into the built module.
|
|
362
489
|
*/
|
|
363
490
|
export type ThemeBuildHandOff = {
|
|
364
491
|
prepareFamily?: boolean;
|
|
@@ -374,4 +501,18 @@ export type ThemeBuildHandOff = {
|
|
|
374
501
|
group: string;
|
|
375
502
|
build: string;
|
|
376
503
|
};
|
|
504
|
+
colorModes?: ["light"] | ["dark"] | null;
|
|
505
|
+
fontHelp?: FontHelp | null;
|
|
506
|
+
loadedFonts?: ((family: string) => boolean) | null;
|
|
507
|
+
install?: string | null;
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* How a caller that loads a theme's fonts itself (the editor's app copy)
|
|
511
|
+
* says to load a family: the notice per family and the recipe in place of
|
|
512
|
+
* the generic one.
|
|
513
|
+
*/
|
|
514
|
+
export type FontHelp = {
|
|
515
|
+
notice: (family: string) => string;
|
|
516
|
+
recipe: (families: string[]) => string;
|
|
377
517
|
};
|
|
518
|
+
import { AstryxError } from '../../error.mjs';
|