@astryxdesign/cli 0.7.16 → 0.7.17-canary.g49a475f
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 +75 -0
- package/api/theme/build/build.mjs +243 -58
- package/api/theme/build/font-warning.d.mts +7 -0
- package/api/theme/build/font-warning.mjs +17 -0
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +63 -2
- package/api/theme-edit/_adapter.mjs +771 -57
- package/api/theme-edit/_check.d.mts +40 -22
- package/api/theme-edit/_check.mjs +2029 -336
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +49 -1
- package/api/theme-edit/_compiler.mjs +9 -0
- package/api/theme-edit/_context.d.mts +3 -3
- package/api/theme-edit/_context.mjs +111 -48
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +18 -4
- package/api/theme-edit/_edit.mjs +1685 -155
- package/api/theme-edit/_how-commands.d.mts +65 -0
- package/api/theme-edit/_how-commands.mjs +633 -1
- package/api/theme-edit/_how-question.d.mts +84 -0
- package/api/theme-edit/_how-question.mjs +5124 -281
- package/api/theme-edit/_how.mjs +140 -29
- 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 +257 -0
- package/api/theme-edit/_normal.mjs +1252 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_parts.d.mts +10 -1
- package/api/theme-edit/_parts.mjs +179 -3
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +515 -148
- package/api/theme-edit/_preview.d.mts +100 -14
- package/api/theme-edit/_preview.mjs +549 -137
- package/api/theme-edit/_settings.d.mts +347 -30
- package/api/theme-edit/_settings.mjs +2971 -327
- package/api/theme-edit/_tables.d.mts +6 -0
- package/api/theme-edit/_tables.mjs +44 -1
- package/api/theme-edit/_vet.d.mts +18 -0
- package/api/theme-edit/_vet.mjs +32 -0
- 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 +2 -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 +163 -28
- 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 +209 -8
- 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 +77 -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 +52 -0
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +3 -2
- 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/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +25 -4
- package/foundation/fs/gather-cache.mjs +164 -55
- 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/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 +316 -42
- 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
|
|
@@ -333,10 +338,12 @@ function realOrSelf(file) {
|
|
|
333
338
|
/**
|
|
334
339
|
* `target` spelled through real directories: the deepest ancestor that exists
|
|
335
340
|
* is resolved through its symlinks, and the missing rest is appended as given.
|
|
341
|
+
* The build confines its outputs by it, and the theme editor's compile guard
|
|
342
|
+
* reads paths through it too, so both read a path the same way.
|
|
336
343
|
* @param {string} target absolute path
|
|
337
344
|
* @returns {string}
|
|
338
345
|
*/
|
|
339
|
-
function realLocation(target) {
|
|
346
|
+
export function realLocation(target) {
|
|
340
347
|
/** @type {string[]} */
|
|
341
348
|
const missing = [];
|
|
342
349
|
let existing = target;
|
|
@@ -818,7 +825,7 @@ function confineOutputs(writes, root, remedy) {
|
|
|
818
825
|
}
|
|
819
826
|
|
|
820
827
|
/** @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) {
|
|
828
|
+
export function refusedOutput(dest, root) {
|
|
822
829
|
try {
|
|
823
830
|
confineOutput(dest, root, '');
|
|
824
831
|
return false;
|
|
@@ -925,6 +932,82 @@ function isDirectorySync(file) {
|
|
|
925
932
|
}
|
|
926
933
|
}
|
|
927
934
|
|
|
935
|
+
/**
|
|
936
|
+
* The marks a file's leading comment carries (see `generatedMark`): a theme
|
|
937
|
+
* build's output, or a file the theme editor writes, with the command it
|
|
938
|
+
* names. The one reader build and doctor share.
|
|
939
|
+
* @param {string} source the start of the file
|
|
940
|
+
* @param {string} [file] its path, for a mark that names no exact command
|
|
941
|
+
*/
|
|
942
|
+
export function fileMark(source, file) {
|
|
943
|
+
return generatedMark(source, GENERATED_MARKER, file);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* The command a file's leading comment says writes it, when another CLI
|
|
948
|
+
* command generates it (the theme editor's settings module or app copy):
|
|
949
|
+
* the exact command its mark names. Null for a theme build's own output and
|
|
950
|
+
* a file without a mark, such as a theme source of one's own.
|
|
951
|
+
* @param {string} file
|
|
952
|
+
* @returns {string | null}
|
|
953
|
+
*/
|
|
954
|
+
export function generatedFileCommand(file) {
|
|
955
|
+
const mark = fileMark(fileHead(file), file);
|
|
956
|
+
return mark?.kind === 'editor' ? mark.command : null;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* The command that writes a missing `file`: a file beside it carries
|
|
961
|
+
* another command's mark, and a file there names `file` (a build output's
|
|
962
|
+
* header names its source), so it is one that command writes. Null for any
|
|
963
|
+
* other name, such as a typo.
|
|
964
|
+
* @param {string} file
|
|
965
|
+
* @returns {string | null}
|
|
966
|
+
*/
|
|
967
|
+
function missingGeneratedCommand(file) {
|
|
968
|
+
const dir = path.dirname(file);
|
|
969
|
+
const base = path.basename(file);
|
|
970
|
+
let names;
|
|
971
|
+
try {
|
|
972
|
+
names = fs.readdirSync(dir).sort();
|
|
973
|
+
} catch {
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
976
|
+
/** @type {string | null} */
|
|
977
|
+
let by = null;
|
|
978
|
+
let named = false;
|
|
979
|
+
for (const n of names) {
|
|
980
|
+
const f = path.join(dir, n);
|
|
981
|
+
try {
|
|
982
|
+
if (!fs.statSync(f).isFile()) continue;
|
|
983
|
+
} catch {
|
|
984
|
+
continue;
|
|
985
|
+
}
|
|
986
|
+
by ??= generatedFileCommand(f);
|
|
987
|
+
if (!named)
|
|
988
|
+
try {
|
|
989
|
+
named = fs.readFileSync(f, 'utf8').slice(0, 4000).includes(base);
|
|
990
|
+
} catch {
|
|
991
|
+
// A file that does not read names nothing.
|
|
992
|
+
}
|
|
993
|
+
if (by && named) return by;
|
|
994
|
+
}
|
|
995
|
+
return null;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* The command that writes `file`: from its own mark, or, when it is
|
|
1000
|
+
* missing, from the files beside it (see `missingGeneratedCommand`); null
|
|
1001
|
+
* otherwise.
|
|
1002
|
+
* @param {string} file
|
|
1003
|
+
* @returns {string | null}
|
|
1004
|
+
*/
|
|
1005
|
+
export function generatedSourceCommand(file) {
|
|
1006
|
+
return fs.existsSync(file)
|
|
1007
|
+
? generatedFileCommand(file)
|
|
1008
|
+
: missingGeneratedCommand(file);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
928
1011
|
/** @param {string} file @returns {string} the start of a file, or '' when it cannot be read */
|
|
929
1012
|
function fileHead(file) {
|
|
930
1013
|
try {
|
|
@@ -1121,7 +1204,9 @@ function assertThemeSourceFile(filePath, cwd, mode = {}) {
|
|
|
1121
1204
|
* output must stay inside, for a scratch build; `commandWords` names the
|
|
1122
1205
|
* command in the rebuild hint; `prepareFamily`, `familyLoader`, and
|
|
1123
1206
|
* `familyInterception` make the build a family member's plan.
|
|
1124
|
-
*
|
|
1207
|
+
* `colorModes` is the one color mode a calling command knows the theme has
|
|
1208
|
+
* (the theme editor, from its settings), written into the built module.
|
|
1209
|
+
* @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}} ThemeBuildHandOff
|
|
1125
1210
|
*/
|
|
1126
1211
|
|
|
1127
1212
|
/**
|
|
@@ -1157,6 +1242,45 @@ export function setEditorFolderListener(listener) {
|
|
|
1157
1242
|
* @typedef {{glob?: boolean, family?: boolean, familyKey?: string}} SuggestionShape
|
|
1158
1243
|
*/
|
|
1159
1244
|
|
|
1245
|
+
/**
|
|
1246
|
+
* The refusal a build gives the file it is given before it reads it, or
|
|
1247
|
+
* null: a file that is not there, and a folder. The build throws it, and a
|
|
1248
|
+
* suggested build is checked by it before it is offered.
|
|
1249
|
+
* @param {string} file as typed, from cwd
|
|
1250
|
+
* @param {BuildMode} options
|
|
1251
|
+
* @param {string} cwd
|
|
1252
|
+
* @returns {AstryxError | null}
|
|
1253
|
+
*/
|
|
1254
|
+
export function buildInputProblem(file, options, cwd) {
|
|
1255
|
+
const filePath = path.resolve(cwd, file);
|
|
1256
|
+
if (!fs.existsSync(filePath))
|
|
1257
|
+
return new AstryxError(
|
|
1258
|
+
`File not found: ${filePath}`,
|
|
1259
|
+
themeSourceGuesses(file, cwd).map(guess => ({
|
|
1260
|
+
name: buildSuggestion(guess, options, cwd),
|
|
1261
|
+
reason: 'a theme source that exists',
|
|
1262
|
+
})),
|
|
1263
|
+
ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
1264
|
+
);
|
|
1265
|
+
if (fs.statSync(filePath).isDirectory())
|
|
1266
|
+
return new AstryxError(
|
|
1267
|
+
`${path.relative(cwd, filePath) || '.'} is a folder. Pass the theme file inside it.`,
|
|
1268
|
+
themeFilesIn(filePath).map(name => ({
|
|
1269
|
+
name: buildSuggestion(
|
|
1270
|
+
path
|
|
1271
|
+
.relative(cwd, path.join(filePath, name))
|
|
1272
|
+
.split(path.sep)
|
|
1273
|
+
.join('/'),
|
|
1274
|
+
options,
|
|
1275
|
+
cwd,
|
|
1276
|
+
),
|
|
1277
|
+
reason: 'a theme source in that folder',
|
|
1278
|
+
})),
|
|
1279
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
1280
|
+
);
|
|
1281
|
+
return null;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1160
1284
|
/**
|
|
1161
1285
|
* The `theme build` command for `source` with the caller's mode flags, so a
|
|
1162
1286
|
* suggestion never turns a check into a write or moves the outputs.
|
|
@@ -2630,9 +2754,13 @@ function isSyncLoaderLimitation(error) {
|
|
|
2630
2754
|
* source export and old-Core adaptation checks keep treating that path as
|
|
2631
2755
|
* degraded/fail-closed.
|
|
2632
2756
|
*
|
|
2757
|
+
* On Node 22.15 and later, on every path, a stylesheet that a module in the
|
|
2758
|
+
* theme's graph imports loads as an empty module (`withEmptyStylesheets`): a
|
|
2759
|
+
* base theme's module can import its own stylesheet for the app's bundler.
|
|
2760
|
+
*
|
|
2633
2761
|
* @param {string} filePath
|
|
2634
2762
|
* @param {import('./core-interception.mjs').CoreInterception} [interception]
|
|
2635
|
-
* @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
2763
|
+
* @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}, colorModes: ["light"] | ["dark"] | null}>}
|
|
2636
2764
|
*/
|
|
2637
2765
|
// prettier-ignore
|
|
2638
2766
|
async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined) {
|
|
@@ -2640,9 +2768,9 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2640
2768
|
loader ??
|
|
2641
2769
|
createJiti(import.meta.url, {
|
|
2642
2770
|
moduleCache: false,
|
|
2643
|
-
//
|
|
2644
|
-
//
|
|
2645
|
-
|
|
2771
|
+
// The per-user transpile cache: an edited theme is transpiled again,
|
|
2772
|
+
// and the folder stays within its size limit.
|
|
2773
|
+
...jitiCacheOptions(),
|
|
2646
2774
|
jsx: true,
|
|
2647
2775
|
extensions: THEME_MODULE_EXTENSIONS,
|
|
2648
2776
|
...(interception ? {virtualModules: interception.modules} : {}),
|
|
@@ -2659,7 +2787,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2659
2787
|
const commonJsPatch = interception.patchCommonJs(filePath);
|
|
2660
2788
|
try {
|
|
2661
2789
|
try {
|
|
2662
|
-
mod = jiti(filePath);
|
|
2790
|
+
mod = await withEmptyStylesheets(async () => jiti(filePath));
|
|
2663
2791
|
} catch (error) {
|
|
2664
2792
|
// Only a sync-loader limitation may fall back. Anything else is the
|
|
2665
2793
|
// theme's own failure and belongs to the caller unchanged.
|
|
@@ -2668,14 +2796,16 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2668
2796
|
// Force asynchronous transformation instead of native import: this
|
|
2669
2797
|
// keeps virtual Core interception active even when the module uses
|
|
2670
2798
|
// top-level await.
|
|
2671
|
-
mod = await
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2799
|
+
mod = await withEmptyStylesheets(() =>
|
|
2800
|
+
jiti.evalModule(fs.readFileSync(filePath, 'utf8'), {
|
|
2801
|
+
id: filePath,
|
|
2802
|
+
filename: filePath,
|
|
2803
|
+
ext: path.extname(filePath),
|
|
2804
|
+
cache: jiti.cache,
|
|
2805
|
+
async: true,
|
|
2806
|
+
forceTranspile: true,
|
|
2807
|
+
}),
|
|
2808
|
+
);
|
|
2679
2809
|
}
|
|
2680
2810
|
} finally {
|
|
2681
2811
|
// Read after the load: the root is wrapped when the load requires it.
|
|
@@ -2683,7 +2813,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2683
2813
|
commonJsPatch.undo();
|
|
2684
2814
|
}
|
|
2685
2815
|
} else {
|
|
2686
|
-
mod = await jiti.import(filePath);
|
|
2816
|
+
mod = await withEmptyStylesheets(() => jiti.import(filePath));
|
|
2687
2817
|
}
|
|
2688
2818
|
|
|
2689
2819
|
// Both loads hand back the module. The theme is read from the module's own
|
|
@@ -2692,15 +2822,22 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2692
2822
|
// `default` with the module), so the module can pass for the theme while
|
|
2693
2823
|
// its own keys hide the theme's fields.
|
|
2694
2824
|
const isModule = mod != null && typeof mod === 'object';
|
|
2825
|
+
// A theme with one color mode says so with a `colorModes` export beside
|
|
2826
|
+
// the theme (`['light']` or `['dark']`); the build carries it into the
|
|
2827
|
+
// built module.
|
|
2828
|
+
const colorModes = oneColorMode(
|
|
2829
|
+
isModule && Object.hasOwn(mod, 'colorModes') ? mod.colorModes : undefined,
|
|
2830
|
+
);
|
|
2695
2831
|
const hasDefault = isModule && Object.hasOwn(mod, 'default');
|
|
2696
2832
|
const defaultExport = hasDefault ? mod.default : undefined;
|
|
2697
2833
|
if (isThemeObject(defaultExport)) {
|
|
2698
|
-
return {theme: defaultExport, exportName: 'default', degraded};
|
|
2834
|
+
return {theme: defaultExport, exportName: 'default', degraded, colorModes};
|
|
2699
2835
|
}
|
|
2700
2836
|
if (isModule) {
|
|
2701
2837
|
for (const [exportName, value] of Object.entries(mod)) {
|
|
2702
2838
|
if (exportName === 'default' || exportName === 'module.exports') continue;
|
|
2703
|
-
if (isThemeObject(value))
|
|
2839
|
+
if (isThemeObject(value))
|
|
2840
|
+
return {theme: value, exportName, degraded, colorModes};
|
|
2704
2841
|
}
|
|
2705
2842
|
}
|
|
2706
2843
|
// The loader's interop answers a null default with the module itself, so
|
|
@@ -2722,7 +2859,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2722
2859
|
// be all it defines), or no name: the build's validation says what it
|
|
2723
2860
|
// lacks.
|
|
2724
2861
|
if (isPlainObject(defaultExport)) {
|
|
2725
|
-
return {theme: defaultExport, exportName: 'default', degraded};
|
|
2862
|
+
return {theme: defaultExport, exportName: 'default', degraded, colorModes};
|
|
2726
2863
|
}
|
|
2727
2864
|
// A CommonJS module whose exports are the theme (`module.exports =
|
|
2728
2865
|
// theme`) has no default of its own: interop answers `default` with
|
|
@@ -2731,7 +2868,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2731
2868
|
if (isModule && !hasDefault) {
|
|
2732
2869
|
const exportsObject = mod.default ?? mod;
|
|
2733
2870
|
if (isThemeObject(exportsObject)) {
|
|
2734
|
-
return {theme: exportsObject, exportName: 'default', degraded};
|
|
2871
|
+
return {theme: exportsObject, exportName: 'default', degraded, colorModes};
|
|
2735
2872
|
}
|
|
2736
2873
|
}
|
|
2737
2874
|
|
|
@@ -2800,7 +2937,7 @@ function isThemeObject(value) {
|
|
|
2800
2937
|
*
|
|
2801
2938
|
* @param {string} filePath
|
|
2802
2939
|
* @param {import('./core-interception.mjs').CoreInterception} [interception]
|
|
2803
|
-
* @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
|
|
2940
|
+
* @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}, colorModes?: ['light'] | ['dark'] | null}>}
|
|
2804
2941
|
*/
|
|
2805
2942
|
// prettier-ignore
|
|
2806
2943
|
async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined) {
|
|
@@ -2815,6 +2952,52 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
|
|
|
2815
2952
|
}
|
|
2816
2953
|
}
|
|
2817
2954
|
|
|
2955
|
+
/**
|
|
2956
|
+
* The Core interception a standalone build loads a theme module with: none
|
|
2957
|
+
* when the selected Core generates adaptations itself and the theme's folder
|
|
2958
|
+
* resolves a Core of its own; else imports of Core are handed the selected
|
|
2959
|
+
* Core.
|
|
2960
|
+
* @param {string} filePath
|
|
2961
|
+
*/
|
|
2962
|
+
function standaloneInterception(filePath) {
|
|
2963
|
+
return _generateAdaptationCSS && themeFolderResolvesCore(filePath)
|
|
2964
|
+
? undefined
|
|
2965
|
+
: interceptCore(_coreThemeModule, _coreRootModule);
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
/**
|
|
2969
|
+
* Load a theme module as a standalone build of it loads it (the Core the
|
|
2970
|
+
* build selects, the same loader and interception) and name the export the
|
|
2971
|
+
* build reads. Callers that must agree with the build on which theme a
|
|
2972
|
+
* module defines read it here, never from the module's text.
|
|
2973
|
+
* @param {string} file
|
|
2974
|
+
* @param {{cwd?: string}} [ctx]
|
|
2975
|
+
* @returns {Promise<{theme: any, exportName: string}>}
|
|
2976
|
+
*/
|
|
2977
|
+
export async function loadThemeExport(file, {cwd = process.cwd()} = {}) {
|
|
2978
|
+
const filePath = path.resolve(cwd, file);
|
|
2979
|
+
await selectCore(cwd, {projectOnly: false});
|
|
2980
|
+
const {theme, exportName} = await extractThemeDefinition(
|
|
2981
|
+
filePath,
|
|
2982
|
+
standaloneInterception(filePath),
|
|
2983
|
+
);
|
|
2984
|
+
return {theme, exportName: exportName ?? 'default'};
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
/**
|
|
2988
|
+
* A one-mode `colorModes` value (`['light']` or `['dark']`), or null for
|
|
2989
|
+
* anything else: a theme with both modes needs no export.
|
|
2990
|
+
* @param {unknown} value
|
|
2991
|
+
* @returns {['light'] | ['dark'] | null}
|
|
2992
|
+
*/
|
|
2993
|
+
export function oneColorMode(value) {
|
|
2994
|
+
return Array.isArray(value) &&
|
|
2995
|
+
value.length === 1 &&
|
|
2996
|
+
(value[0] === 'light' || value[0] === 'dark')
|
|
2997
|
+
? /** @type {['light'] | ['dark']} */ ([value[0]])
|
|
2998
|
+
: null;
|
|
2999
|
+
}
|
|
3000
|
+
|
|
2818
3001
|
/** Names a theme module's exports must take; ends a shape failure. */
|
|
2819
3002
|
const THEME_EXPORT_FIX =
|
|
2820
3003
|
"Export the theme object: `export default defineTheme({name: 'my-theme', tokens: {...}})`, or a plain `export default {name: 'my-theme', tokens: {...}}`.";
|
|
@@ -3739,21 +3922,32 @@ async function themeBuildInternal(
|
|
|
3739
3922
|
report = {},
|
|
3740
3923
|
handOff = {},
|
|
3741
3924
|
) {
|
|
3925
|
+
// A blank --out names no file: the build would write files named by the
|
|
3926
|
+
// spaces alone.
|
|
3927
|
+
if (
|
|
3928
|
+
typeof options.out === 'string' &&
|
|
3929
|
+
options.out !== '' &&
|
|
3930
|
+
!options.out.trim()
|
|
3931
|
+
)
|
|
3932
|
+
throw new AstryxError(
|
|
3933
|
+
'--out is blank; name a file or folder, or leave out --out to write beside the source.',
|
|
3934
|
+
[
|
|
3935
|
+
{
|
|
3936
|
+
name: buildSuggestion(file, {...options, out: undefined}, cwd),
|
|
3937
|
+
reason: 'do this instead',
|
|
3938
|
+
},
|
|
3939
|
+
],
|
|
3940
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
3941
|
+
);
|
|
3742
3942
|
// A backslash in --out separates folders on every platform, as it does in
|
|
3743
3943
|
// the other theme paths (a Windows path copied into a POSIX shell).
|
|
3744
3944
|
if (typeof options.out === 'string' && options.out.includes('\\'))
|
|
3745
3945
|
options = {...options, out: options.out.replace(/\\/g, '/')};
|
|
3746
3946
|
const filePath = path.resolve(cwd, file);
|
|
3747
3947
|
|
|
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
|
-
);
|
|
3948
|
+
{
|
|
3949
|
+
const problem = buildInputProblem(file, options, cwd);
|
|
3950
|
+
if (problem) throw problem;
|
|
3757
3951
|
}
|
|
3758
3952
|
|
|
3759
3953
|
// A theme the theme editor made is built from its settings by the editor;
|
|
@@ -3772,24 +3966,6 @@ async function themeBuildInternal(
|
|
|
3772
3966
|
);
|
|
3773
3967
|
}
|
|
3774
3968
|
|
|
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
3969
|
assertThemeSourceFile(filePath, cwd, options);
|
|
3794
3970
|
|
|
3795
3971
|
if (!report.compact) {
|
|
@@ -3814,10 +3990,7 @@ async function themeBuildInternal(
|
|
|
3814
3990
|
// shared loader so exact authored parent identity stays CLI-private instead
|
|
3815
3991
|
// of becoming a public DefinedTheme field.
|
|
3816
3992
|
const interception =
|
|
3817
|
-
handOff.familyInterception ??
|
|
3818
|
-
(_generateAdaptationCSS && themeFolderResolvesCore(filePath)
|
|
3819
|
-
? undefined
|
|
3820
|
-
: interceptCore(_coreThemeModule, _coreRootModule));
|
|
3993
|
+
handOff.familyInterception ?? standaloneInterception(filePath);
|
|
3821
3994
|
|
|
3822
3995
|
// Extract theme definition
|
|
3823
3996
|
let themeDef;
|
|
@@ -3825,6 +3998,9 @@ async function themeBuildInternal(
|
|
|
3825
3998
|
let themeExportName;
|
|
3826
3999
|
/** Paths through the load that interception could not fully observe. */
|
|
3827
4000
|
let loadDegradation;
|
|
4001
|
+
/** The one color mode the theme module exports, or null for both. */
|
|
4002
|
+
/** @type {['light'] | ['dark'] | null} */
|
|
4003
|
+
let colorModes;
|
|
3828
4004
|
/**
|
|
3829
4005
|
* The theme file's bytes as loaded: read before and after the load, and the
|
|
3830
4006
|
* registry scan below reads these rather than the file again. An editor's
|
|
@@ -3851,6 +4027,7 @@ async function themeBuildInternal(
|
|
|
3851
4027
|
themeDef = loaded.theme;
|
|
3852
4028
|
themeExportName = loaded.exportName;
|
|
3853
4029
|
loadDegradation = loaded.degraded;
|
|
4030
|
+
colorModes = handOff.colorModes ?? loaded.colorModes ?? null;
|
|
3854
4031
|
} catch (e) {
|
|
3855
4032
|
const err = /** @type {Error} */ (e);
|
|
3856
4033
|
const shown = path.relative(cwd, filePath) || filePath;
|
|
@@ -4482,10 +4659,18 @@ async function themeBuildInternal(
|
|
|
4482
4659
|
? {}
|
|
4483
4660
|
: {cssFileName: path.basename(outPath)}),
|
|
4484
4661
|
},
|
|
4485
|
-
)
|
|
4662
|
+
) +
|
|
4663
|
+
// The one color mode, beside the theme export (a two-mode theme
|
|
4664
|
+
// exports none, so its module is unchanged).
|
|
4665
|
+
(colorModes
|
|
4666
|
+
? `export const colorModes = [${JSON.stringify(colorModes[0])}];\n`
|
|
4667
|
+
: '');
|
|
4486
4668
|
const dtsContent =
|
|
4487
4669
|
generatedHeader(headerSource, 'ts', buildCommand, versions) +
|
|
4488
|
-
generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName)
|
|
4670
|
+
generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName) +
|
|
4671
|
+
(colorModes
|
|
4672
|
+
? `export declare const colorModes: readonly [${JSON.stringify(colorModes[0])}];\n`
|
|
4673
|
+
: '');
|
|
4489
4674
|
|
|
4490
4675
|
const unloadedFonts = [
|
|
4491
4676
|
...new Set([
|
|
@@ -4998,7 +5183,7 @@ function planFamilySources(files, cwd) {
|
|
|
4998
5183
|
// prettier-ignore
|
|
4999
5184
|
async function preloadFamilySource(filePath, loader, interception) {
|
|
5000
5185
|
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}); } }
|
|
5186
|
+
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
5187
|
finally { patch.undo(); }
|
|
5003
5188
|
}
|
|
5004
5189
|
|
|
@@ -5026,7 +5211,7 @@ export async function themeBuildFamily(
|
|
|
5026
5211
|
await selectCore(cwd);
|
|
5027
5212
|
const familyInterception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
5028
5213
|
// prettier-ignore
|
|
5029
|
-
const familyLoader = createJiti(import.meta.url, {moduleCache: true,
|
|
5214
|
+
const familyLoader = createJiti(import.meta.url, {moduleCache: true, ...jitiCacheOptions(), interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
|
|
5030
5215
|
/** @type {any[]} */
|
|
5031
5216
|
const prepared = [];
|
|
5032
5217
|
for (const source of planFamilySources(files, cwd)) {
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The font families a CSS font-family value names, without generics,
|
|
6
|
+
* CSS-wide keywords or `var()` references (system families included).
|
|
7
|
+
* @param {string} value
|
|
8
|
+
* @returns {string[]}
|
|
9
|
+
*/
|
|
10
|
+
export function namedFontFamilies(value: string): string[];
|
|
4
11
|
/**
|
|
5
12
|
* Collect the font families a resolved theme names but does not load —
|
|
6
13
|
* every `--font-family-*` token plus every component-override `fontFamily`,
|
|
@@ -60,6 +60,11 @@ const SYSTEM_FAMILIES = new Set([
|
|
|
60
60
|
'segoe ui',
|
|
61
61
|
'segoe ui emoji',
|
|
62
62
|
'segoe ui symbol',
|
|
63
|
+
// The weights Windows ships as families of their own.
|
|
64
|
+
'segoe ui light',
|
|
65
|
+
'segoe ui semilight',
|
|
66
|
+
'segoe ui semibold',
|
|
67
|
+
'segoe ui black',
|
|
63
68
|
'roboto',
|
|
64
69
|
'helvetica',
|
|
65
70
|
'helvetica neue',
|
|
@@ -129,6 +134,18 @@ function splitFamilies(value) {
|
|
|
129
134
|
return families;
|
|
130
135
|
}
|
|
131
136
|
|
|
137
|
+
/**
|
|
138
|
+
* The font families a CSS font-family value names, without generics,
|
|
139
|
+
* CSS-wide keywords or `var()` references (system families included).
|
|
140
|
+
* @param {string} value
|
|
141
|
+
* @returns {string[]}
|
|
142
|
+
*/
|
|
143
|
+
export function namedFontFamilies(value) {
|
|
144
|
+
return splitFamilies(value).filter(
|
|
145
|
+
family => !GENERIC_KEYWORDS.has(family.toLowerCase()),
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
132
149
|
/**
|
|
133
150
|
* Collect the font families a resolved theme names but does not load —
|
|
134
151
|
* every `--font-family-*` token plus every component-override `fontFamily`,
|
|
@@ -137,6 +137,12 @@ export type ThemeAppEntry = {
|
|
|
137
137
|
*/
|
|
138
138
|
fontStylesheet?: string | undefined;
|
|
139
139
|
source: "bundled" | "package" | "local";
|
|
140
|
+
/**
|
|
141
|
+
* the one color mode the theme has, when its
|
|
142
|
+
* built module exports one (`colorModes`); the generated module then lists
|
|
143
|
+
* it in `themeModes`. Absent for a theme with both modes.
|
|
144
|
+
*/
|
|
145
|
+
mode?: "light" | "dark" | undefined;
|
|
140
146
|
};
|
|
141
147
|
/**
|
|
142
148
|
* astryx --json theme add <slug> [--import] / remove / use
|
|
@@ -149,6 +155,9 @@ export type ThemeAppResponse = {
|
|
|
149
155
|
* `notes` is present only when the command did more than its change says:
|
|
150
156
|
* it chose between a local and a package theme with one slug, replaced a
|
|
151
157
|
* recorded owner, or dropped a recorded theme whose source is gone.
|
|
158
|
+
* `change.wireModes` is present when the module lists a theme's one color
|
|
159
|
+
* mode (`themeModes`) for the first time after the app was wired: the app's
|
|
160
|
+
* `Theme` then takes `mode={themeModes[defaultThemeSlug] ?? 'system'}`.
|
|
152
161
|
*/
|
|
153
162
|
package?: string | undefined;
|
|
154
163
|
data: {
|
|
@@ -160,6 +169,7 @@ export type ThemeAppResponse = {
|
|
|
160
169
|
slug: string;
|
|
161
170
|
changed: boolean;
|
|
162
171
|
firstAdd: boolean;
|
|
172
|
+
wireModes?: true;
|
|
163
173
|
};
|
|
164
174
|
notes?: string[];
|
|
165
175
|
};
|
package/api/theme/theme.type.mjs
CHANGED
|
@@ -92,6 +92,9 @@
|
|
|
92
92
|
* @property {string} stylesheet production stylesheet import
|
|
93
93
|
* @property {string} [fontStylesheet] package-owned font stylesheet import
|
|
94
94
|
* @property {'bundled'|'package'|'local'} source
|
|
95
|
+
* @property {'light'|'dark'} [mode] the one color mode the theme has, when its
|
|
96
|
+
* built module exports one (`colorModes`); the generated module then lists
|
|
97
|
+
* it in `themeModes`. Absent for a theme with both modes.
|
|
95
98
|
*/
|
|
96
99
|
|
|
97
100
|
/**
|
|
@@ -103,7 +106,10 @@
|
|
|
103
106
|
* `notes` is present only when the command did more than its change says:
|
|
104
107
|
* it chose between a local and a package theme with one slug, replaced a
|
|
105
108
|
* recorded owner, or dropped a recorded theme whose source is gone.
|
|
106
|
-
*
|
|
109
|
+
* `change.wireModes` is present when the module lists a theme's one color
|
|
110
|
+
* mode (`themeModes`) for the first time after the app was wired: the app's
|
|
111
|
+
* `Theme` then takes `mode={themeModes[defaultThemeSlug] ?? 'system'}`.
|
|
112
|
+
* @property {{themes: ThemeAppEntry[], default: string, modulePath: string, change: {action: 'add'|'remove'|'use', slug: string, changed: boolean, firstAdd: boolean, wireModes?: true}, notes?: string[]}} data
|
|
107
113
|
*/
|
|
108
114
|
|
|
109
115
|
/**
|