@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0135e03
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 +12 -0
- package/api/build/_adapter.mjs +51 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- 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 +4 -2
- package/api/build/kit/rank.mjs +125 -24
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +39 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +340 -43
- 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 +48 -0
- package/api/build/kit/words.mjs +90 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +1 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +26 -2
- package/api/docs/_adapter.mjs +219 -6
- 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 +27 -5
- package/api/doctor/_adapter.mjs +83 -10
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- 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/authoring-checks.mjs +6 -6
- 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/validate-integration.mjs +19 -1
- package/api/integration/validate-integration.type.d.mts +9 -0
- package/api/integration/validate-integration.type.mjs +1 -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 +52 -0
- package/api/render/render.type.mjs +31 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- package/api/search/_candidate-score.mjs +51 -32
- 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 +5 -0
- package/api/search/_lexical.mjs +8 -2
- 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/theme/_adapter.mjs +12 -1
- package/api/theme/build/build.d.mts +122 -1
- package/api/theme/build/build.mjs +412 -84
- 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 +23 -3
- package/api/theme/build/font-warning.mjs +54 -5
- package/api/theme/build/icon-imports.mjs +25 -2
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +103 -3
- package/api/theme-edit/_adapter.mjs +961 -82
- package/api/theme-edit/_catalog.mjs +19 -4
- package/api/theme-edit/_check.d.mts +63 -24
- package/api/theme-edit/_check.mjs +2467 -362
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +49 -1
- package/api/theme-edit/_compiler.mjs +89 -6
- package/api/theme-edit/_context.d.mts +3 -3
- package/api/theme-edit/_context.mjs +165 -54
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +31 -4
- package/api/theme-edit/_edit.mjs +2433 -204
- package/api/theme-edit/_how-commands.d.mts +72 -1
- package/api/theme-edit/_how-commands.mjs +759 -9
- package/api/theme-edit/_how-question.d.mts +82 -5
- package/api/theme-edit/_how-question.mjs +6473 -553
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +237 -41
- 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 +292 -0
- package/api/theme-edit/_normal.mjs +1454 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_part-words.d.mts +31 -0
- package/api/theme-edit/_part-words.mjs +126 -0
- package/api/theme-edit/_parts.d.mts +18 -1
- package/api/theme-edit/_parts.mjs +246 -23
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +776 -187
- package/api/theme-edit/_preview.d.mts +100 -14
- package/api/theme-edit/_preview.mjs +582 -139
- package/api/theme-edit/_project.d.mts +4 -0
- package/api/theme-edit/_project.mjs +3 -1
- package/api/theme-edit/_settings.d.mts +417 -42
- package/api/theme-edit/_settings.mjs +3262 -424
- package/api/theme-edit/_tables.d.mts +15 -0
- package/api/theme-edit/_tables.mjs +63 -1
- package/api/theme-edit/_vet.d.mts +20 -0
- package/api/theme-edit/_vet.mjs +47 -2
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -1
- 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/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/run-codemod.mjs +87 -7
- 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 +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +44 -3
- 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/use-a-theme.doc.mjs +1 -1
- 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/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/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/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- 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/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- 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/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -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/template.doc.mjs +2 -1
- 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/mixed-gallery/template.doc.mjs +2 -1
- 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/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/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/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- 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/template.doc.mjs +1 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- 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/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/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +32 -14
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +358 -63
- 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 +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- 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 +1 -1
- 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.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.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +317 -47
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- 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 +92 -21
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +56 -8
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +22 -8
- 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-doc-files.mjs +2 -1
- 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 +38 -18
- package/foundation/discovery/template-adapter.d.mts +53 -1
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +31 -4
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/discovery/theming-targets.mjs +3 -2
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +31 -0
- package/foundation/fonts/font-stylesheet.mjs +115 -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 +4 -3
- package/foundation/fs/gather-cache.d.mts +62 -4
- package/foundation/fs/gather-cache.mjs +512 -91
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -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/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +9 -0
- package/foundation/fs/read-record.mjs +19 -11
- 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/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/validate-contributions.mjs +17 -45
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +39 -7
- package/foundation/render/embedded-imports.mjs +66 -27
- 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/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +121 -13
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +185 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +34 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +35 -3
- package/foundation/render/render-page.mjs +641 -96
- 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 +2 -2
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +18 -4
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +15 -1
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
|
@@ -63,7 +63,7 @@ import * as path from 'node:path';
|
|
|
63
63
|
import {createRequire, isBuiltin} from 'node:module';
|
|
64
64
|
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
65
65
|
import {babelParse as parse} from '../../../foundation/runtime/lazy-dependencies.mjs';
|
|
66
|
-
import {
|
|
66
|
+
import {jitiCacheOptions} from '../../../foundation/fs/jiti-cache.mjs';
|
|
67
67
|
import {
|
|
68
68
|
formatCliCommand,
|
|
69
69
|
getCliInvocation,
|
|
@@ -92,6 +92,10 @@ import {applyWrites} from '../../integration/add-helpers.mjs';
|
|
|
92
92
|
import {logger} from '../../logger.mjs';
|
|
93
93
|
import {loadComponentDoc} from '../../../foundation/discovery/component-loader.mjs';
|
|
94
94
|
import {THEME_SOURCE_EXTENSIONS} from '../../../foundation/discovery/theme-module-extensions.mjs';
|
|
95
|
+
import {
|
|
96
|
+
createJiti,
|
|
97
|
+
withEmptyStylesheets,
|
|
98
|
+
} from '../../../foundation/fs/module-loader.mjs';
|
|
95
99
|
import {
|
|
96
100
|
collectThemingTargets,
|
|
97
101
|
targetsByKey,
|
|
@@ -108,6 +112,7 @@ import {
|
|
|
108
112
|
} from '../../../foundation/discovery/template-needs.mjs';
|
|
109
113
|
import {generateFamilyCSS, resolveThemeFamily} from './family.mjs';
|
|
110
114
|
import {resolveIconImports} from './icon-imports.mjs';
|
|
115
|
+
import {generatedMark} from '../../theme-edit/_marks.mjs';
|
|
111
116
|
|
|
112
117
|
// Import shared theme processing from core. `astryx theme build` MUST produce the
|
|
113
118
|
// exact same CSS as the `<Theme>` runtime, so it has exactly one generation
|
|
@@ -324,7 +329,9 @@ function importTarget(dir, subpath) {
|
|
|
324
329
|
/** @param {string} file @returns {string} its real path, or itself */
|
|
325
330
|
function realOrSelf(file) {
|
|
326
331
|
try {
|
|
327
|
-
|
|
332
|
+
// The native form spells a path as the disk does (its own case on a
|
|
333
|
+
// case-insensitive disk), so two spellings of one file compare equal.
|
|
334
|
+
return fs.realpathSync.native(file);
|
|
328
335
|
} catch {
|
|
329
336
|
return file;
|
|
330
337
|
}
|
|
@@ -333,10 +340,12 @@ function realOrSelf(file) {
|
|
|
333
340
|
/**
|
|
334
341
|
* `target` spelled through real directories: the deepest ancestor that exists
|
|
335
342
|
* is resolved through its symlinks, and the missing rest is appended as given.
|
|
343
|
+
* The build confines its outputs by it, and the theme editor's compile guard
|
|
344
|
+
* reads paths through it too, so both read a path the same way.
|
|
336
345
|
* @param {string} target absolute path
|
|
337
346
|
* @returns {string}
|
|
338
347
|
*/
|
|
339
|
-
function realLocation(target) {
|
|
348
|
+
export function realLocation(target) {
|
|
340
349
|
/** @type {string[]} */
|
|
341
350
|
const missing = [];
|
|
342
351
|
let existing = target;
|
|
@@ -818,7 +827,7 @@ function confineOutputs(writes, root, remedy) {
|
|
|
818
827
|
}
|
|
819
828
|
|
|
820
829
|
/** @param {string} dest absolute output path @param {string} root @returns {boolean} whether a build at `root` refuses to write `dest` */
|
|
821
|
-
function refusedOutput(dest, root) {
|
|
830
|
+
export function refusedOutput(dest, root) {
|
|
822
831
|
try {
|
|
823
832
|
confineOutput(dest, root, '');
|
|
824
833
|
return false;
|
|
@@ -925,6 +934,82 @@ function isDirectorySync(file) {
|
|
|
925
934
|
}
|
|
926
935
|
}
|
|
927
936
|
|
|
937
|
+
/**
|
|
938
|
+
* The marks a file's leading comment carries (see `generatedMark`): a theme
|
|
939
|
+
* build's output, or a file the theme editor writes, with the command it
|
|
940
|
+
* names. The one reader build and doctor share.
|
|
941
|
+
* @param {string} source the start of the file
|
|
942
|
+
* @param {string} [file] its path, for a mark that names no exact command
|
|
943
|
+
*/
|
|
944
|
+
export function fileMark(source, file) {
|
|
945
|
+
return generatedMark(source, GENERATED_MARKER, file);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* The command a file's leading comment says writes it, when another CLI
|
|
950
|
+
* command generates it (the theme editor's settings module or app copy):
|
|
951
|
+
* the exact command its mark names. Null for a theme build's own output and
|
|
952
|
+
* a file without a mark, such as a theme source of one's own.
|
|
953
|
+
* @param {string} file
|
|
954
|
+
* @returns {string | null}
|
|
955
|
+
*/
|
|
956
|
+
export function generatedFileCommand(file) {
|
|
957
|
+
const mark = fileMark(fileHead(file), file);
|
|
958
|
+
return mark?.kind === 'editor' ? mark.command : null;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* The command that writes a missing `file`: a file beside it carries
|
|
963
|
+
* another command's mark, and a file there names `file` (a build output's
|
|
964
|
+
* header names its source), so it is one that command writes. Null for any
|
|
965
|
+
* other name, such as a typo.
|
|
966
|
+
* @param {string} file
|
|
967
|
+
* @returns {string | null}
|
|
968
|
+
*/
|
|
969
|
+
function missingGeneratedCommand(file) {
|
|
970
|
+
const dir = path.dirname(file);
|
|
971
|
+
const base = path.basename(file);
|
|
972
|
+
let names;
|
|
973
|
+
try {
|
|
974
|
+
names = fs.readdirSync(dir).sort();
|
|
975
|
+
} catch {
|
|
976
|
+
return null;
|
|
977
|
+
}
|
|
978
|
+
/** @type {string | null} */
|
|
979
|
+
let by = null;
|
|
980
|
+
let named = false;
|
|
981
|
+
for (const n of names) {
|
|
982
|
+
const f = path.join(dir, n);
|
|
983
|
+
try {
|
|
984
|
+
if (!fs.statSync(f).isFile()) continue;
|
|
985
|
+
} catch {
|
|
986
|
+
continue;
|
|
987
|
+
}
|
|
988
|
+
by ??= generatedFileCommand(f);
|
|
989
|
+
if (!named)
|
|
990
|
+
try {
|
|
991
|
+
named = fs.readFileSync(f, 'utf8').slice(0, 4000).includes(base);
|
|
992
|
+
} catch {
|
|
993
|
+
// A file that does not read names nothing.
|
|
994
|
+
}
|
|
995
|
+
if (by && named) return by;
|
|
996
|
+
}
|
|
997
|
+
return null;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* The command that writes `file`: from its own mark, or, when it is
|
|
1002
|
+
* missing, from the files beside it (see `missingGeneratedCommand`); null
|
|
1003
|
+
* otherwise.
|
|
1004
|
+
* @param {string} file
|
|
1005
|
+
* @returns {string | null}
|
|
1006
|
+
*/
|
|
1007
|
+
export function generatedSourceCommand(file) {
|
|
1008
|
+
return fs.existsSync(file)
|
|
1009
|
+
? generatedFileCommand(file)
|
|
1010
|
+
: missingGeneratedCommand(file);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
928
1013
|
/** @param {string} file @returns {string} the start of a file, or '' when it cannot be read */
|
|
929
1014
|
function fileHead(file) {
|
|
930
1015
|
try {
|
|
@@ -1121,7 +1206,16 @@ function assertThemeSourceFile(filePath, cwd, mode = {}) {
|
|
|
1121
1206
|
* output must stay inside, for a scratch build; `commandWords` names the
|
|
1122
1207
|
* command in the rebuild hint; `prepareFamily`, `familyLoader`, and
|
|
1123
1208
|
* `familyInterception` make the build a family member's plan.
|
|
1124
|
-
*
|
|
1209
|
+
* `colorModes` is the one color mode a calling command knows the theme has
|
|
1210
|
+
* (the theme editor, from its settings), written into the built module.
|
|
1211
|
+
* @typedef {{prepareFamily?: boolean, familyLoader?: any, familyInterception?: any, writeRoot?: string, claimedOutputs?: Map<string, string>, deferredWrites?: Array<Array<{dest: string, content: string}>>, commandWords?: {group: string, build: string}, colorModes?: ['light'] | ['dark'] | null, fontHelp?: FontHelp | null, loadedFonts?: ((family: string) => boolean) | null}} ThemeBuildHandOff
|
|
1212
|
+
*/
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* How a caller that loads a theme's fonts itself (the editor's app copy)
|
|
1216
|
+
* says to load a family: the notice per family and the recipe in place of
|
|
1217
|
+
* the generic one.
|
|
1218
|
+
* @typedef {{notice: (family: string) => string, recipe: (families: string[]) => string}} FontHelp
|
|
1125
1219
|
*/
|
|
1126
1220
|
|
|
1127
1221
|
/**
|
|
@@ -1157,6 +1251,45 @@ export function setEditorFolderListener(listener) {
|
|
|
1157
1251
|
* @typedef {{glob?: boolean, family?: boolean, familyKey?: string}} SuggestionShape
|
|
1158
1252
|
*/
|
|
1159
1253
|
|
|
1254
|
+
/**
|
|
1255
|
+
* The refusal a build gives the file it is given before it reads it, or
|
|
1256
|
+
* null: a file that is not there, and a folder. The build throws it, and a
|
|
1257
|
+
* suggested build is checked by it before it is offered.
|
|
1258
|
+
* @param {string} file as typed, from cwd
|
|
1259
|
+
* @param {BuildMode} options
|
|
1260
|
+
* @param {string} cwd
|
|
1261
|
+
* @returns {AstryxError | null}
|
|
1262
|
+
*/
|
|
1263
|
+
export function buildInputProblem(file, options, cwd) {
|
|
1264
|
+
const filePath = path.resolve(cwd, file);
|
|
1265
|
+
if (!fs.existsSync(filePath))
|
|
1266
|
+
return new AstryxError(
|
|
1267
|
+
`File not found: ${filePath}`,
|
|
1268
|
+
themeSourceGuesses(file, cwd).map(guess => ({
|
|
1269
|
+
name: buildSuggestion(guess, options, cwd),
|
|
1270
|
+
reason: 'a theme source that exists',
|
|
1271
|
+
})),
|
|
1272
|
+
ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
1273
|
+
);
|
|
1274
|
+
if (fs.statSync(filePath).isDirectory())
|
|
1275
|
+
return new AstryxError(
|
|
1276
|
+
`${path.relative(cwd, filePath) || '.'} is a folder. Pass the theme file inside it.`,
|
|
1277
|
+
themeFilesIn(filePath).map(name => ({
|
|
1278
|
+
name: buildSuggestion(
|
|
1279
|
+
path
|
|
1280
|
+
.relative(cwd, path.join(filePath, name))
|
|
1281
|
+
.split(path.sep)
|
|
1282
|
+
.join('/'),
|
|
1283
|
+
options,
|
|
1284
|
+
cwd,
|
|
1285
|
+
),
|
|
1286
|
+
reason: 'a theme source in that folder',
|
|
1287
|
+
})),
|
|
1288
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
1289
|
+
);
|
|
1290
|
+
return null;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1160
1293
|
/**
|
|
1161
1294
|
* The `theme build` command for `source` with the caller's mode flags, so a
|
|
1162
1295
|
* suggestion never turns a check into a write or moves the outputs.
|
|
@@ -1212,11 +1345,12 @@ export function buildSuggestion(source, mode, cwd, words, shape = {}) {
|
|
|
1212
1345
|
* @param {Array<{dest: string}>} writes
|
|
1213
1346
|
* @param {string} filePath the theme source
|
|
1214
1347
|
* @param {string} cwd
|
|
1215
|
-
* @param {{claimed?: Map<string, string>, rerun?: (out: string | null) => string, refuseUnmarked?: boolean, elsewhere?: string, onEditorFolder?: (warning: string) => void}} [options]
|
|
1348
|
+
* @param {{claimed?: Map<string, string>, rerun?: (out: string | null) => string, refuseUnmarked?: boolean, elsewhere?: string, onEditorFolder?: (warning: string) => void, onWarning?: (message: string) => void}} [options]
|
|
1216
1349
|
* `claimed`: outputs written earlier in this run, by the source that wrote
|
|
1217
1350
|
* them; `rerun`: this build's command with another --out, or without one;
|
|
1218
1351
|
* `elsewhere`: the option that moves the outputs; `onEditorFolder`: takes
|
|
1219
|
-
* the editor-folder warning instead of the logger (a watcher prints it
|
|
1352
|
+
* the editor-folder warning instead of the logger (a watcher prints it
|
|
1353
|
+
* once); `onWarning`: each warning's message too, for the result
|
|
1220
1354
|
*/
|
|
1221
1355
|
function assertOutputsReplaceable(
|
|
1222
1356
|
writes,
|
|
@@ -1228,6 +1362,7 @@ function assertOutputsReplaceable(
|
|
|
1228
1362
|
refuseUnmarked = false,
|
|
1229
1363
|
elsewhere = '--out',
|
|
1230
1364
|
onEditorFolder,
|
|
1365
|
+
onWarning,
|
|
1231
1366
|
} = {},
|
|
1232
1367
|
) {
|
|
1233
1368
|
const rel = (/** @type {string} */ file) => path.relative(cwd, file);
|
|
@@ -1309,7 +1444,7 @@ function assertOutputsReplaceable(
|
|
|
1309
1444
|
// It is printed after every output passes, so it names a replacement
|
|
1310
1445
|
// that happens.
|
|
1311
1446
|
if (warnedOtherSource) continue;
|
|
1312
|
-
warnedOtherSource =
|
|
1447
|
+
warnedOtherSource = `${rel(write.dest)} was built from ${otherSource}; this build of ${rel(filePath)} replaces it.`;
|
|
1313
1448
|
} else if (otherSource) {
|
|
1314
1449
|
throw new AstryxError(
|
|
1315
1450
|
`${rel(write.dest)} is the build output of another theme source, ${otherSource}, so this build does not replace it. Pick another ${elsewhere}.`,
|
|
@@ -1346,12 +1481,16 @@ function assertOutputsReplaceable(
|
|
|
1346
1481
|
}
|
|
1347
1482
|
// Warned only once nothing refuses the build, so it names a write that
|
|
1348
1483
|
// happens.
|
|
1349
|
-
if (warnedOtherSource)
|
|
1484
|
+
if (warnedOtherSource) {
|
|
1485
|
+
logger.warn(`Warning: ${warnedOtherSource}`);
|
|
1486
|
+
onWarning?.(warnedOtherSource);
|
|
1487
|
+
}
|
|
1350
1488
|
if (editorFolder) {
|
|
1351
1489
|
const dir = path.dirname(writes[0].dest);
|
|
1352
|
-
const
|
|
1353
|
-
if (onEditorFolder) onEditorFolder(
|
|
1354
|
-
else logger.warn(
|
|
1490
|
+
const message = `${rel(dir) || '.'} is a folder the theme editor made, and ${rel(filePath)} is outside it; the build writes there anyway. Build beside the source, or pick another ${elsewhere}, to keep the editor's folder to its own theme.`;
|
|
1491
|
+
if (onEditorFolder) onEditorFolder(`Warning: ${message}`);
|
|
1492
|
+
else logger.warn(`Warning: ${message}`);
|
|
1493
|
+
onWarning?.(message);
|
|
1355
1494
|
}
|
|
1356
1495
|
}
|
|
1357
1496
|
|
|
@@ -1443,7 +1582,31 @@ function writeBuildOutputs(writes) {
|
|
|
1443
1582
|
})),
|
|
1444
1583
|
);
|
|
1445
1584
|
} catch (error) {
|
|
1446
|
-
const
|
|
1585
|
+
const e = /** @type {NodeJS.ErrnoException} */ (error);
|
|
1586
|
+
// A place the outputs cannot be written: name it and its fix (the
|
|
1587
|
+
// writes go through temporary files beside each output, whose names
|
|
1588
|
+
// help nobody).
|
|
1589
|
+
if (e.code === 'EACCES' || e.code === 'EPERM' || e.code === 'EROFS') {
|
|
1590
|
+
const failed = e.path ? path.resolve(e.path) : null;
|
|
1591
|
+
const output = writes.find(w => path.resolve(w.dest) === failed);
|
|
1592
|
+
const place = output
|
|
1593
|
+
? output.dest
|
|
1594
|
+
: failed
|
|
1595
|
+
? path.dirname(failed)
|
|
1596
|
+
: path.dirname(writes[0].dest);
|
|
1597
|
+
const shownPlace = path.relative(process.cwd(), place) || place;
|
|
1598
|
+
throw new AstryxError(
|
|
1599
|
+
`Could not write the theme's outputs: ${shownPlace} is not writable (${e.code}). Give yourself write permission on it (chmod u+w ${shellWord(shownPlace)}), then build again. Nothing was changed.`,
|
|
1600
|
+
[
|
|
1601
|
+
{
|
|
1602
|
+
name: `ls -ld ${shellWord(shownPlace)}`,
|
|
1603
|
+
reason: 'see its permissions',
|
|
1604
|
+
},
|
|
1605
|
+
],
|
|
1606
|
+
ERROR_CODES.ERR_WRITE_FAILED,
|
|
1607
|
+
);
|
|
1608
|
+
}
|
|
1609
|
+
const message = `Failed to write theme outputs: ${e.message}`;
|
|
1447
1610
|
throw new AstryxError(message, undefined, ERROR_CODES.ERR_WRITE_FAILED);
|
|
1448
1611
|
}
|
|
1449
1612
|
}
|
|
@@ -2630,19 +2793,23 @@ function isSyncLoaderLimitation(error) {
|
|
|
2630
2793
|
* source export and old-Core adaptation checks keep treating that path as
|
|
2631
2794
|
* degraded/fail-closed.
|
|
2632
2795
|
*
|
|
2796
|
+
* On Node 22.15 and later, on every path, a stylesheet that a module in the
|
|
2797
|
+
* theme's graph imports loads as an empty module (`withEmptyStylesheets`): a
|
|
2798
|
+
* base theme's module can import its own stylesheet for the app's bundler.
|
|
2799
|
+
*
|
|
2633
2800
|
* @param {string} filePath
|
|
2634
2801
|
* @param {import('./core-interception.mjs').CoreInterception} [interception]
|
|
2635
|
-
* @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
2802
|
+
* @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}, colorModes: ["light"] | ["dark"] | null}>}
|
|
2636
2803
|
*/
|
|
2637
2804
|
// prettier-ignore
|
|
2638
|
-
async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined) {
|
|
2805
|
+
async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined, /** @type {string | undefined} */ pick = undefined) {
|
|
2639
2806
|
const jiti =
|
|
2640
2807
|
loader ??
|
|
2641
2808
|
createJiti(import.meta.url, {
|
|
2642
2809
|
moduleCache: false,
|
|
2643
|
-
//
|
|
2644
|
-
//
|
|
2645
|
-
|
|
2810
|
+
// The per-user transpile cache: an edited theme is transpiled again,
|
|
2811
|
+
// and the folder stays within its size limit.
|
|
2812
|
+
...jitiCacheOptions(),
|
|
2646
2813
|
jsx: true,
|
|
2647
2814
|
extensions: THEME_MODULE_EXTENSIONS,
|
|
2648
2815
|
...(interception ? {virtualModules: interception.modules} : {}),
|
|
@@ -2659,7 +2826,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2659
2826
|
const commonJsPatch = interception.patchCommonJs(filePath);
|
|
2660
2827
|
try {
|
|
2661
2828
|
try {
|
|
2662
|
-
mod = jiti(filePath);
|
|
2829
|
+
mod = await withEmptyStylesheets(async () => jiti(filePath));
|
|
2663
2830
|
} catch (error) {
|
|
2664
2831
|
// Only a sync-loader limitation may fall back. Anything else is the
|
|
2665
2832
|
// theme's own failure and belongs to the caller unchanged.
|
|
@@ -2668,14 +2835,16 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2668
2835
|
// Force asynchronous transformation instead of native import: this
|
|
2669
2836
|
// keeps virtual Core interception active even when the module uses
|
|
2670
2837
|
// top-level await.
|
|
2671
|
-
mod = await
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2838
|
+
mod = await withEmptyStylesheets(() =>
|
|
2839
|
+
jiti.evalModule(fs.readFileSync(filePath, 'utf8'), {
|
|
2840
|
+
id: filePath,
|
|
2841
|
+
filename: filePath,
|
|
2842
|
+
ext: path.extname(filePath),
|
|
2843
|
+
cache: jiti.cache,
|
|
2844
|
+
async: true,
|
|
2845
|
+
forceTranspile: true,
|
|
2846
|
+
}),
|
|
2847
|
+
);
|
|
2679
2848
|
}
|
|
2680
2849
|
} finally {
|
|
2681
2850
|
// Read after the load: the root is wrapped when the load requires it.
|
|
@@ -2683,7 +2852,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2683
2852
|
commonJsPatch.undo();
|
|
2684
2853
|
}
|
|
2685
2854
|
} else {
|
|
2686
|
-
mod = await jiti.import(filePath);
|
|
2855
|
+
mod = await withEmptyStylesheets(() => jiti.import(filePath));
|
|
2687
2856
|
}
|
|
2688
2857
|
|
|
2689
2858
|
// Both loads hand back the module. The theme is read from the module's own
|
|
@@ -2692,15 +2861,28 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2692
2861
|
// `default` with the module), so the module can pass for the theme while
|
|
2693
2862
|
// its own keys hide the theme's fields.
|
|
2694
2863
|
const isModule = mod != null && typeof mod === 'object';
|
|
2864
|
+
// A theme with one color mode says so with a `colorModes` export beside
|
|
2865
|
+
// the theme (`['light']` or `['dark']`); the build carries it into the
|
|
2866
|
+
// built module.
|
|
2867
|
+
const colorModes = oneColorMode(
|
|
2868
|
+
isModule && Object.hasOwn(mod, 'colorModes') ? mod.colorModes : undefined,
|
|
2869
|
+
);
|
|
2695
2870
|
const hasDefault = isModule && Object.hasOwn(mod, 'default');
|
|
2696
2871
|
const defaultExport = hasDefault ? mod.default : undefined;
|
|
2872
|
+
// A caller that already knows which export a build reads (from a load
|
|
2873
|
+
// as the build loads it) reads that one.
|
|
2874
|
+
if (pick !== undefined && isModule && Object.hasOwn(mod, pick)) {
|
|
2875
|
+
if (isThemeObject(mod[pick]))
|
|
2876
|
+
return {theme: mod[pick], exportName: pick, degraded, colorModes};
|
|
2877
|
+
}
|
|
2697
2878
|
if (isThemeObject(defaultExport)) {
|
|
2698
|
-
return {theme: defaultExport, exportName: 'default', degraded};
|
|
2879
|
+
return {theme: defaultExport, exportName: 'default', degraded, colorModes};
|
|
2699
2880
|
}
|
|
2700
2881
|
if (isModule) {
|
|
2701
2882
|
for (const [exportName, value] of Object.entries(mod)) {
|
|
2702
2883
|
if (exportName === 'default' || exportName === 'module.exports') continue;
|
|
2703
|
-
if (isThemeObject(value))
|
|
2884
|
+
if (isThemeObject(value))
|
|
2885
|
+
return {theme: value, exportName, degraded, colorModes};
|
|
2704
2886
|
}
|
|
2705
2887
|
}
|
|
2706
2888
|
// The loader's interop answers a null default with the module itself, so
|
|
@@ -2722,7 +2904,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2722
2904
|
// be all it defines), or no name: the build's validation says what it
|
|
2723
2905
|
// lacks.
|
|
2724
2906
|
if (isPlainObject(defaultExport)) {
|
|
2725
|
-
return {theme: defaultExport, exportName: 'default', degraded};
|
|
2907
|
+
return {theme: defaultExport, exportName: 'default', degraded, colorModes};
|
|
2726
2908
|
}
|
|
2727
2909
|
// A CommonJS module whose exports are the theme (`module.exports =
|
|
2728
2910
|
// theme`) has no default of its own: interop answers `default` with
|
|
@@ -2731,7 +2913,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2731
2913
|
if (isModule && !hasDefault) {
|
|
2732
2914
|
const exportsObject = mod.default ?? mod;
|
|
2733
2915
|
if (isThemeObject(exportsObject)) {
|
|
2734
|
-
return {theme: exportsObject, exportName: 'default', degraded};
|
|
2916
|
+
return {theme: exportsObject, exportName: 'default', degraded, colorModes};
|
|
2735
2917
|
}
|
|
2736
2918
|
}
|
|
2737
2919
|
|
|
@@ -2800,12 +2982,12 @@ function isThemeObject(value) {
|
|
|
2800
2982
|
*
|
|
2801
2983
|
* @param {string} filePath
|
|
2802
2984
|
* @param {import('./core-interception.mjs').CoreInterception} [interception]
|
|
2803
|
-
* @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
2985
|
+
* @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}, colorModes?: ['light'] | ['dark'] | null}>}
|
|
2804
2986
|
*/
|
|
2805
2987
|
// prettier-ignore
|
|
2806
|
-
async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined) {
|
|
2988
|
+
async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined, /** @type {string | undefined} */ pick = undefined) {
|
|
2807
2989
|
try {
|
|
2808
|
-
return await importThemeModule(filePath, interception, loader);
|
|
2990
|
+
return await importThemeModule(filePath, interception, loader, pick);
|
|
2809
2991
|
} catch (jitiError) {
|
|
2810
2992
|
const je = /** @type {Error} */ (jitiError);
|
|
2811
2993
|
throw new Error(
|
|
@@ -2815,6 +2997,120 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
|
|
|
2815
2997
|
}
|
|
2816
2998
|
}
|
|
2817
2999
|
|
|
3000
|
+
/**
|
|
3001
|
+
* The Core interception a standalone build loads a theme module with: none
|
|
3002
|
+
* when the selected Core generates adaptations itself and the theme's folder
|
|
3003
|
+
* resolves a Core of its own; else imports of Core are handed the selected
|
|
3004
|
+
* Core.
|
|
3005
|
+
* @param {string} filePath
|
|
3006
|
+
*/
|
|
3007
|
+
function standaloneInterception(filePath) {
|
|
3008
|
+
return _generateAdaptationCSS && themeFolderResolvesCore(filePath)
|
|
3009
|
+
? undefined
|
|
3010
|
+
: interceptCore(_coreThemeModule, _coreRootModule);
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
/**
|
|
3014
|
+
* Load a theme module as a standalone build of it loads it (the Core the
|
|
3015
|
+
* build selects, the same loader and interception) and name the export the
|
|
3016
|
+
* build reads. Callers that must agree with the build on which theme a
|
|
3017
|
+
* module defines read it here, never from the module's text.
|
|
3018
|
+
*
|
|
3019
|
+
* With `base`, also whether the theme extends that module's export, by
|
|
3020
|
+
* identity, anywhere up its `extends` chain (`extendsBase`): the module is
|
|
3021
|
+
* loaded once, and the theme module's imports of it (by any of
|
|
3022
|
+
* `base.specifiers`) are handed that one load, so the answer is about the
|
|
3023
|
+
* very object, not one that only looks like it.
|
|
3024
|
+
* @param {string} file
|
|
3025
|
+
* @param {{cwd?: string, base?: {file: string, exportName: string, specifiers: string[]}}} [ctx]
|
|
3026
|
+
* @returns {Promise<{theme: any, exportName: string, extendsBase?: boolean}>}
|
|
3027
|
+
*/
|
|
3028
|
+
export async function loadThemeExport(file, {cwd = process.cwd(), base} = {}) {
|
|
3029
|
+
const filePath = path.resolve(cwd, file);
|
|
3030
|
+
await selectCore(cwd, {projectOnly: false});
|
|
3031
|
+
const {theme, exportName = 'default'} = await extractThemeDefinition(
|
|
3032
|
+
filePath,
|
|
3033
|
+
standaloneInterception(filePath),
|
|
3034
|
+
);
|
|
3035
|
+
if (!base) return {theme, exportName};
|
|
3036
|
+
const recorder = interceptCore(_coreThemeModule, _coreRootModule);
|
|
3037
|
+
const shared = (
|
|
3038
|
+
await extractThemeDefinition(
|
|
3039
|
+
path.resolve(cwd, base.file),
|
|
3040
|
+
recorder,
|
|
3041
|
+
undefined,
|
|
3042
|
+
base.exportName,
|
|
3043
|
+
)
|
|
3044
|
+
).theme;
|
|
3045
|
+
const withBase = {
|
|
3046
|
+
...recorder,
|
|
3047
|
+
modules: {
|
|
3048
|
+
...recorder.modules,
|
|
3049
|
+
...Object.fromEntries(
|
|
3050
|
+
base.specifiers.map(s => [s, {[base.exportName]: shared}]),
|
|
3051
|
+
),
|
|
3052
|
+
},
|
|
3053
|
+
};
|
|
3054
|
+
const again = await extractThemeDefinition(
|
|
3055
|
+
filePath,
|
|
3056
|
+
withBase,
|
|
3057
|
+
undefined,
|
|
3058
|
+
exportName,
|
|
3059
|
+
);
|
|
3060
|
+
let extendsBase = false;
|
|
3061
|
+
for (
|
|
3062
|
+
let at = recorder.parentOf(again.theme), depth = 0;
|
|
3063
|
+
at && depth < 64;
|
|
3064
|
+
at = recorder.parentOf(at), depth++
|
|
3065
|
+
)
|
|
3066
|
+
if (at === shared) {
|
|
3067
|
+
extendsBase = true;
|
|
3068
|
+
break;
|
|
3069
|
+
}
|
|
3070
|
+
return {theme, exportName, extendsBase};
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
/**
|
|
3074
|
+
* The input a theme module gives `defineTheme()` for the theme a build of
|
|
3075
|
+
* it reads, evaluated as the build evaluates the module (an import, an
|
|
3076
|
+
* expression, a spread or a computed key is its value), with the theme Core
|
|
3077
|
+
* made of it. When Core refuses the input, the input the module gave for
|
|
3078
|
+
* the named theme (else its last) and Core's error; null when the module
|
|
3079
|
+
* does not load at all.
|
|
3080
|
+
* @param {string} file
|
|
3081
|
+
* @param {{cwd?: string, name?: string}} [ctx]
|
|
3082
|
+
* @returns {Promise<{input: any, theme: any, error: Error | null} | null>}
|
|
3083
|
+
*/
|
|
3084
|
+
export async function loadThemeInput(file, {cwd = process.cwd(), name} = {}) {
|
|
3085
|
+
const filePath = path.resolve(cwd, file);
|
|
3086
|
+
await selectCore(cwd, {projectOnly: false});
|
|
3087
|
+
const interception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
3088
|
+
try {
|
|
3089
|
+
const {theme} = await extractThemeDefinition(filePath, interception);
|
|
3090
|
+
return {input: interception.inputOf(theme) ?? null, theme, error: null};
|
|
3091
|
+
} catch (e) {
|
|
3092
|
+
const given = interception.inputs;
|
|
3093
|
+
const input =
|
|
3094
|
+
given.filter(x => x && typeof x === 'object' && x.name === name).at(-1) ??
|
|
3095
|
+
given.at(-1);
|
|
3096
|
+
return input ? {input, theme: null, error: /** @type {Error} */ (e)} : null;
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
/**
|
|
3101
|
+
* A one-mode `colorModes` value (`['light']` or `['dark']`), or null for
|
|
3102
|
+
* anything else: a theme with both modes needs no export.
|
|
3103
|
+
* @param {unknown} value
|
|
3104
|
+
* @returns {['light'] | ['dark'] | null}
|
|
3105
|
+
*/
|
|
3106
|
+
export function oneColorMode(value) {
|
|
3107
|
+
return Array.isArray(value) &&
|
|
3108
|
+
value.length === 1 &&
|
|
3109
|
+
(value[0] === 'light' || value[0] === 'dark')
|
|
3110
|
+
? /** @type {['light'] | ['dark']} */ ([value[0]])
|
|
3111
|
+
: null;
|
|
3112
|
+
}
|
|
3113
|
+
|
|
2818
3114
|
/** Names a theme module's exports must take; ends a shape failure. */
|
|
2819
3115
|
const THEME_EXPORT_FIX =
|
|
2820
3116
|
"Export the theme object: `export default defineTheme({name: 'my-theme', tokens: {...}})`, or a plain `export default {name: 'my-theme', tokens: {...}}`.";
|
|
@@ -3739,21 +4035,32 @@ async function themeBuildInternal(
|
|
|
3739
4035
|
report = {},
|
|
3740
4036
|
handOff = {},
|
|
3741
4037
|
) {
|
|
4038
|
+
// A blank --out names no file: the build would write files named by the
|
|
4039
|
+
// spaces alone.
|
|
4040
|
+
if (
|
|
4041
|
+
typeof options.out === 'string' &&
|
|
4042
|
+
options.out !== '' &&
|
|
4043
|
+
!options.out.trim()
|
|
4044
|
+
)
|
|
4045
|
+
throw new AstryxError(
|
|
4046
|
+
'--out is blank; name a file or folder, or leave out --out to write beside the source.',
|
|
4047
|
+
[
|
|
4048
|
+
{
|
|
4049
|
+
name: buildSuggestion(file, {...options, out: undefined}, cwd),
|
|
4050
|
+
reason: 'do this instead',
|
|
4051
|
+
},
|
|
4052
|
+
],
|
|
4053
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
4054
|
+
);
|
|
3742
4055
|
// A backslash in --out separates folders on every platform, as it does in
|
|
3743
4056
|
// the other theme paths (a Windows path copied into a POSIX shell).
|
|
3744
4057
|
if (typeof options.out === 'string' && options.out.includes('\\'))
|
|
3745
4058
|
options = {...options, out: options.out.replace(/\\/g, '/')};
|
|
3746
4059
|
const filePath = path.resolve(cwd, file);
|
|
3747
4060
|
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
themeSourceGuesses(file, cwd).map(guess => ({
|
|
3752
|
-
name: buildSuggestion(guess, options, cwd),
|
|
3753
|
-
reason: 'a theme source that exists',
|
|
3754
|
-
})),
|
|
3755
|
-
ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
3756
|
-
);
|
|
4061
|
+
{
|
|
4062
|
+
const problem = buildInputProblem(file, options, cwd);
|
|
4063
|
+
if (problem) throw problem;
|
|
3757
4064
|
}
|
|
3758
4065
|
|
|
3759
4066
|
// A theme the theme editor made is built from its settings by the editor;
|
|
@@ -3772,24 +4079,6 @@ async function themeBuildInternal(
|
|
|
3772
4079
|
);
|
|
3773
4080
|
}
|
|
3774
4081
|
|
|
3775
|
-
if (fs.statSync(filePath).isDirectory()) {
|
|
3776
|
-
throw new AstryxError(
|
|
3777
|
-
`${path.relative(cwd, filePath) || '.'} is a folder. Pass the theme file inside it.`,
|
|
3778
|
-
themeFilesIn(filePath).map(name => ({
|
|
3779
|
-
name: buildSuggestion(
|
|
3780
|
-
path
|
|
3781
|
-
.relative(cwd, path.join(filePath, name))
|
|
3782
|
-
.split(path.sep)
|
|
3783
|
-
.join('/'),
|
|
3784
|
-
options,
|
|
3785
|
-
cwd,
|
|
3786
|
-
),
|
|
3787
|
-
reason: 'a theme source in that folder',
|
|
3788
|
-
})),
|
|
3789
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
3790
|
-
);
|
|
3791
|
-
}
|
|
3792
|
-
|
|
3793
4082
|
assertThemeSourceFile(filePath, cwd, options);
|
|
3794
4083
|
|
|
3795
4084
|
if (!report.compact) {
|
|
@@ -3814,10 +4103,7 @@ async function themeBuildInternal(
|
|
|
3814
4103
|
// shared loader so exact authored parent identity stays CLI-private instead
|
|
3815
4104
|
// of becoming a public DefinedTheme field.
|
|
3816
4105
|
const interception =
|
|
3817
|
-
handOff.familyInterception ??
|
|
3818
|
-
(_generateAdaptationCSS && themeFolderResolvesCore(filePath)
|
|
3819
|
-
? undefined
|
|
3820
|
-
: interceptCore(_coreThemeModule, _coreRootModule));
|
|
4106
|
+
handOff.familyInterception ?? standaloneInterception(filePath);
|
|
3821
4107
|
|
|
3822
4108
|
// Extract theme definition
|
|
3823
4109
|
let themeDef;
|
|
@@ -3825,6 +4111,9 @@ async function themeBuildInternal(
|
|
|
3825
4111
|
let themeExportName;
|
|
3826
4112
|
/** Paths through the load that interception could not fully observe. */
|
|
3827
4113
|
let loadDegradation;
|
|
4114
|
+
/** The one color mode the theme module exports, or null for both. */
|
|
4115
|
+
/** @type {['light'] | ['dark'] | null} */
|
|
4116
|
+
let colorModes;
|
|
3828
4117
|
/**
|
|
3829
4118
|
* The theme file's bytes as loaded: read before and after the load, and the
|
|
3830
4119
|
* registry scan below reads these rather than the file again. An editor's
|
|
@@ -3851,6 +4140,7 @@ async function themeBuildInternal(
|
|
|
3851
4140
|
themeDef = loaded.theme;
|
|
3852
4141
|
themeExportName = loaded.exportName;
|
|
3853
4142
|
loadDegradation = loaded.degraded;
|
|
4143
|
+
colorModes = handOff.colorModes ?? loaded.colorModes ?? null;
|
|
3854
4144
|
} catch (e) {
|
|
3855
4145
|
const err = /** @type {Error} */ (e);
|
|
3856
4146
|
const shown = path.relative(cwd, filePath) || filePath;
|
|
@@ -4403,9 +4693,10 @@ async function themeBuildInternal(
|
|
|
4403
4693
|
.join(path.dirname(options.out), `${stem}.css`)
|
|
4404
4694
|
.split(path.sep)
|
|
4405
4695
|
.join('/');
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
);
|
|
4696
|
+
// The result's warnings say it too, as text does.
|
|
4697
|
+
const w = `--out names the stylesheet, which is CSS; give it a .css name such as ${fixed}.`;
|
|
4698
|
+
warningMessages.push(w);
|
|
4699
|
+
logger.warn(`Warning: ${w}`);
|
|
4409
4700
|
}
|
|
4410
4701
|
// A build keeps the explicit output inside the write root, relative or
|
|
4411
4702
|
// absolute. Check mode writes nothing, so it refuses only a relative path
|
|
@@ -4482,11 +4773,21 @@ async function themeBuildInternal(
|
|
|
4482
4773
|
? {}
|
|
4483
4774
|
: {cssFileName: path.basename(outPath)}),
|
|
4484
4775
|
},
|
|
4485
|
-
)
|
|
4776
|
+
) +
|
|
4777
|
+
// The one color mode, beside the theme export (a two-mode theme
|
|
4778
|
+
// exports none, so its module is unchanged).
|
|
4779
|
+
(colorModes
|
|
4780
|
+
? `export const colorModes = [${JSON.stringify(colorModes[0])}];\n`
|
|
4781
|
+
: '');
|
|
4486
4782
|
const dtsContent =
|
|
4487
4783
|
generatedHeader(headerSource, 'ts', buildCommand, versions) +
|
|
4488
|
-
generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName)
|
|
4784
|
+
generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName) +
|
|
4785
|
+
(colorModes
|
|
4786
|
+
? `export declare const colorModes: readonly [${JSON.stringify(colorModes[0])}];\n`
|
|
4787
|
+
: '');
|
|
4489
4788
|
|
|
4789
|
+
// A family the caller knows the app loads (a font stylesheet it writes
|
|
4790
|
+
// for the theme) is not named as unloaded.
|
|
4490
4791
|
const unloadedFonts = [
|
|
4491
4792
|
...new Set([
|
|
4492
4793
|
...collectUnloadedFonts(resolvedTheme),
|
|
@@ -4494,7 +4795,7 @@ async function themeBuildInternal(
|
|
|
4494
4795
|
(/** @type {any} */ value) => collectUnloadedFonts(value),
|
|
4495
4796
|
),
|
|
4496
4797
|
]),
|
|
4497
|
-
];
|
|
4798
|
+
].filter(family => !handOff.loadedFonts?.(family));
|
|
4498
4799
|
|
|
4499
4800
|
if (handOff.prepareFamily) {
|
|
4500
4801
|
return {
|
|
@@ -4547,6 +4848,8 @@ async function themeBuildInternal(
|
|
|
4547
4848
|
rerun,
|
|
4548
4849
|
refuseUnmarked: Boolean(options.out),
|
|
4549
4850
|
onEditorFolder: editorFolderListener ?? undefined,
|
|
4851
|
+
// The result's warnings carry what text prints.
|
|
4852
|
+
onWarning: message => warningMessages.push(message),
|
|
4550
4853
|
});
|
|
4551
4854
|
}
|
|
4552
4855
|
|
|
@@ -4637,12 +4940,19 @@ async function themeBuildInternal(
|
|
|
4637
4940
|
// permanently in violation of its own "compiles with no warnings" guard).
|
|
4638
4941
|
// Adaptation rules are resolved theme writes in their own right, so a family
|
|
4639
4942
|
// named only inside one needs the same notice as one named at the root.
|
|
4943
|
+
// The result names the recipe's command bare, as every machine-read
|
|
4944
|
+
// command is; the printed note starts it the way this project runs the CLI.
|
|
4945
|
+
/** @param {string} family @param {string} recipe */
|
|
4946
|
+
const fontNotice = (family, recipe) =>
|
|
4947
|
+
handOff.fontHelp?.notice(family) ??
|
|
4948
|
+
`Font "${family}" is named by this theme but not loaded; add a <link> or @font-face in your app (recipe: ${recipe})`;
|
|
4640
4949
|
/** @type {string[]} */
|
|
4641
4950
|
const fontNotices = [];
|
|
4642
4951
|
for (const family of unloadedFonts) {
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4952
|
+
noticeMessages.push(fontNotice(family, 'astryx docs typography'));
|
|
4953
|
+
fontNotices.push(
|
|
4954
|
+
fontNotice(family, formatCliCommand('docs typography', cwd)),
|
|
4955
|
+
);
|
|
4646
4956
|
}
|
|
4647
4957
|
|
|
4648
4958
|
/** @type {ThemeBuildTrailer} */
|
|
@@ -4653,6 +4963,7 @@ async function themeBuildInternal(
|
|
|
4653
4963
|
cssImport,
|
|
4654
4964
|
unloadedFonts,
|
|
4655
4965
|
fontNotices,
|
|
4966
|
+
fontHelp: handOff.fontHelp ?? null,
|
|
4656
4967
|
};
|
|
4657
4968
|
// A batch or compact report prints this once for the whole run instead.
|
|
4658
4969
|
if (report.trailers) report.trailers.push(trailer);
|
|
@@ -4689,7 +5000,8 @@ async function themeBuildInternal(
|
|
|
4689
5000
|
* @property {string} jsImport Import specifier of the built JS module.
|
|
4690
5001
|
* @property {string} cssImport Import specifier of the built CSS.
|
|
4691
5002
|
* @property {string[]} unloadedFonts Font families the theme names but does not load.
|
|
4692
|
-
* @property {string[]} fontNotices One notice per unloaded font family.
|
|
5003
|
+
* @property {string[]} fontNotices One notice per unloaded font family, as printed.
|
|
5004
|
+
* @property {FontHelp | null} [fontHelp] How the caller loads fonts, when it does.
|
|
4693
5005
|
*/
|
|
4694
5006
|
|
|
4695
5007
|
/**
|
|
@@ -4720,7 +5032,13 @@ Or with a <link> tag:
|
|
|
4720
5032
|
`);
|
|
4721
5033
|
for (const msg of trailer.fontNotices) logger.log(` note: ${msg}`);
|
|
4722
5034
|
if (trailer.unloadedFonts.length > 0) {
|
|
4723
|
-
logger.log(
|
|
5035
|
+
logger.log(
|
|
5036
|
+
formatFontLoadingHelp(
|
|
5037
|
+
trailer.themeName,
|
|
5038
|
+
trailer.unloadedFonts,
|
|
5039
|
+
trailer.fontHelp?.recipe,
|
|
5040
|
+
),
|
|
5041
|
+
);
|
|
4724
5042
|
}
|
|
4725
5043
|
}
|
|
4726
5044
|
|
|
@@ -4763,7 +5081,10 @@ Or with a <link> tag:
|
|
|
4763
5081
|
}
|
|
4764
5082
|
}
|
|
4765
5083
|
const fonts = groupUnloadedFonts(trailers);
|
|
4766
|
-
|
|
5084
|
+
// One caller's recipe serves the batch only when every theme takes it.
|
|
5085
|
+
const help = trailers.every(t => t.fontHelp) ? trailers[0].fontHelp : null;
|
|
5086
|
+
if (fonts.length > 0)
|
|
5087
|
+
logger.log(formatBatchFontLoadingHelp(fonts, help?.recipe));
|
|
4767
5088
|
}
|
|
4768
5089
|
|
|
4769
5090
|
/**
|
|
@@ -4998,7 +5319,7 @@ function planFamilySources(files, cwd) {
|
|
|
4998
5319
|
// prettier-ignore
|
|
4999
5320
|
async function preloadFamilySource(filePath, loader, interception) {
|
|
5000
5321
|
const patch = interception.patchCommonJs(filePath);
|
|
5001
|
-
try { try { loader(filePath); } catch (error) { if (!isSyncLoaderLimitation(error)) throw error; await loader.evalModule(fs.readFileSync(filePath, 'utf8'), {id: filePath, filename: filePath, ext: path.extname(filePath), cache: loader.cache, async: true, forceTranspile: true}); } }
|
|
5322
|
+
try { try { await withEmptyStylesheets(async () => loader(filePath)); } catch (error) { if (!isSyncLoaderLimitation(error)) throw error; await withEmptyStylesheets(() => loader.evalModule(fs.readFileSync(filePath, 'utf8'), {id: filePath, filename: filePath, ext: path.extname(filePath), cache: loader.cache, async: true, forceTranspile: true})); } }
|
|
5002
5323
|
finally { patch.undo(); }
|
|
5003
5324
|
}
|
|
5004
5325
|
|
|
@@ -5026,7 +5347,7 @@ export async function themeBuildFamily(
|
|
|
5026
5347
|
await selectCore(cwd);
|
|
5027
5348
|
const familyInterception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
5028
5349
|
// prettier-ignore
|
|
5029
|
-
const familyLoader = createJiti(import.meta.url, {moduleCache: true,
|
|
5350
|
+
const familyLoader = createJiti(import.meta.url, {moduleCache: true, ...jitiCacheOptions(), interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
|
|
5030
5351
|
/** @type {any[]} */
|
|
5031
5352
|
const prepared = [];
|
|
5032
5353
|
for (const source of planFamilySources(files, cwd)) {
|
|
@@ -5318,11 +5639,18 @@ Or load the same stylesheet natively:
|
|
|
5318
5639
|
const unloadedFonts = [
|
|
5319
5640
|
...new Set(members.flatMap(member => member.unloadedFonts)),
|
|
5320
5641
|
];
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5642
|
+
/** @param {string} family @param {string} recipe */
|
|
5643
|
+
const familyNotice = (family, recipe) =>
|
|
5644
|
+
`Font "${family}" is named by this theme family but not loaded; add a <link> or @font-face in your app (recipe: ${recipe})`;
|
|
5645
|
+
// The result names the command bare; the printed note as this project
|
|
5646
|
+
// runs the CLI.
|
|
5647
|
+
const notices = unloadedFonts.map(family =>
|
|
5648
|
+
familyNotice(family, 'astryx docs typography'),
|
|
5324
5649
|
);
|
|
5325
|
-
for (const
|
|
5650
|
+
for (const family of unloadedFonts)
|
|
5651
|
+
logger.log(
|
|
5652
|
+
` note: ${familyNotice(family, formatCliCommand('docs typography', cwd))}`,
|
|
5653
|
+
);
|
|
5326
5654
|
return {
|
|
5327
5655
|
type: 'theme.build',
|
|
5328
5656
|
data: {
|