@astryxdesign/cli 0.7.16 → 0.7.17-canary.g335a172
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.mjs +69 -16
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +16 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +251 -35
- 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/_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 +60 -0
- package/api/theme/build/build.mjs +210 -54
- package/api/theme/build/font-warning.d.mts +8 -0
- package/api/theme/build/font-warning.mjs +19 -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 +55 -0
- package/api/theme-edit/_adapter.mjs +673 -42
- package/api/theme-edit/_check.d.mts +28 -22
- package/api/theme-edit/_check.mjs +1858 -312
- 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.mjs +60 -3
- package/api/theme-edit/_css.mjs +21 -1
- package/api/theme-edit/_edit.d.mts +22 -0
- package/api/theme-edit/_edit.mjs +1533 -92
- package/api/theme-edit/_how-commands.d.mts +57 -0
- package/api/theme-edit/_how-commands.mjs +587 -1
- package/api/theme-edit/_how-question.d.mts +78 -0
- package/api/theme-edit/_how-question.mjs +4716 -235
- package/api/theme-edit/_how.mjs +134 -8
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_normal.d.mts +219 -0
- package/api/theme-edit/_normal.mjs +1041 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +103 -2
- package/api/theme-edit/_playwright-picture.d.mts +4 -0
- package/api/theme-edit/_playwright-picture.mjs +34 -0
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +394 -74
- package/api/theme-edit/_preview.d.mts +69 -8
- package/api/theme-edit/_preview.mjs +531 -108
- package/api/theme-edit/_settings.d.mts +243 -6
- package/api/theme-edit/_settings.mjs +2415 -147
- 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.mjs +1 -1
- 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/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 +145 -16
- 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 +2 -2
- 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/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 +183 -6
- 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-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/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,20 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
|
|
|
2815
2952
|
}
|
|
2816
2953
|
}
|
|
2817
2954
|
|
|
2955
|
+
/**
|
|
2956
|
+
* A one-mode `colorModes` value (`['light']` or `['dark']`), or null for
|
|
2957
|
+
* anything else: a theme with both modes needs no export.
|
|
2958
|
+
* @param {unknown} value
|
|
2959
|
+
* @returns {['light'] | ['dark'] | null}
|
|
2960
|
+
*/
|
|
2961
|
+
export function oneColorMode(value) {
|
|
2962
|
+
return Array.isArray(value) &&
|
|
2963
|
+
value.length === 1 &&
|
|
2964
|
+
(value[0] === 'light' || value[0] === 'dark')
|
|
2965
|
+
? /** @type {['light'] | ['dark']} */ ([value[0]])
|
|
2966
|
+
: null;
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2818
2969
|
/** Names a theme module's exports must take; ends a shape failure. */
|
|
2819
2970
|
const THEME_EXPORT_FIX =
|
|
2820
2971
|
"Export the theme object: `export default defineTheme({name: 'my-theme', tokens: {...}})`, or a plain `export default {name: 'my-theme', tokens: {...}}`.";
|
|
@@ -3739,21 +3890,32 @@ async function themeBuildInternal(
|
|
|
3739
3890
|
report = {},
|
|
3740
3891
|
handOff = {},
|
|
3741
3892
|
) {
|
|
3893
|
+
// A blank --out names no file: the build would write files named by the
|
|
3894
|
+
// spaces alone.
|
|
3895
|
+
if (
|
|
3896
|
+
typeof options.out === 'string' &&
|
|
3897
|
+
options.out !== '' &&
|
|
3898
|
+
!options.out.trim()
|
|
3899
|
+
)
|
|
3900
|
+
throw new AstryxError(
|
|
3901
|
+
'--out is blank; name a file or folder, or leave out --out to write beside the source.',
|
|
3902
|
+
[
|
|
3903
|
+
{
|
|
3904
|
+
name: buildSuggestion(file, {...options, out: undefined}, cwd),
|
|
3905
|
+
reason: 'do this instead',
|
|
3906
|
+
},
|
|
3907
|
+
],
|
|
3908
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
3909
|
+
);
|
|
3742
3910
|
// A backslash in --out separates folders on every platform, as it does in
|
|
3743
3911
|
// the other theme paths (a Windows path copied into a POSIX shell).
|
|
3744
3912
|
if (typeof options.out === 'string' && options.out.includes('\\'))
|
|
3745
3913
|
options = {...options, out: options.out.replace(/\\/g, '/')};
|
|
3746
3914
|
const filePath = path.resolve(cwd, file);
|
|
3747
3915
|
|
|
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
|
-
);
|
|
3916
|
+
{
|
|
3917
|
+
const problem = buildInputProblem(file, options, cwd);
|
|
3918
|
+
if (problem) throw problem;
|
|
3757
3919
|
}
|
|
3758
3920
|
|
|
3759
3921
|
// A theme the theme editor made is built from its settings by the editor;
|
|
@@ -3772,24 +3934,6 @@ async function themeBuildInternal(
|
|
|
3772
3934
|
);
|
|
3773
3935
|
}
|
|
3774
3936
|
|
|
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
3937
|
assertThemeSourceFile(filePath, cwd, options);
|
|
3794
3938
|
|
|
3795
3939
|
if (!report.compact) {
|
|
@@ -3825,6 +3969,9 @@ async function themeBuildInternal(
|
|
|
3825
3969
|
let themeExportName;
|
|
3826
3970
|
/** Paths through the load that interception could not fully observe. */
|
|
3827
3971
|
let loadDegradation;
|
|
3972
|
+
/** The one color mode the theme module exports, or null for both. */
|
|
3973
|
+
/** @type {['light'] | ['dark'] | null} */
|
|
3974
|
+
let colorModes;
|
|
3828
3975
|
/**
|
|
3829
3976
|
* The theme file's bytes as loaded: read before and after the load, and the
|
|
3830
3977
|
* registry scan below reads these rather than the file again. An editor's
|
|
@@ -3851,6 +3998,7 @@ async function themeBuildInternal(
|
|
|
3851
3998
|
themeDef = loaded.theme;
|
|
3852
3999
|
themeExportName = loaded.exportName;
|
|
3853
4000
|
loadDegradation = loaded.degraded;
|
|
4001
|
+
colorModes = handOff.colorModes ?? loaded.colorModes ?? null;
|
|
3854
4002
|
} catch (e) {
|
|
3855
4003
|
const err = /** @type {Error} */ (e);
|
|
3856
4004
|
const shown = path.relative(cwd, filePath) || filePath;
|
|
@@ -4482,10 +4630,18 @@ async function themeBuildInternal(
|
|
|
4482
4630
|
? {}
|
|
4483
4631
|
: {cssFileName: path.basename(outPath)}),
|
|
4484
4632
|
},
|
|
4485
|
-
)
|
|
4633
|
+
) +
|
|
4634
|
+
// The one color mode, beside the theme export (a two-mode theme
|
|
4635
|
+
// exports none, so its module is unchanged).
|
|
4636
|
+
(colorModes
|
|
4637
|
+
? `export const colorModes = [${JSON.stringify(colorModes[0])}];\n`
|
|
4638
|
+
: '');
|
|
4486
4639
|
const dtsContent =
|
|
4487
4640
|
generatedHeader(headerSource, 'ts', buildCommand, versions) +
|
|
4488
|
-
generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName)
|
|
4641
|
+
generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName) +
|
|
4642
|
+
(colorModes
|
|
4643
|
+
? `export declare const colorModes: readonly [${JSON.stringify(colorModes[0])}];\n`
|
|
4644
|
+
: '');
|
|
4489
4645
|
|
|
4490
4646
|
const unloadedFonts = [
|
|
4491
4647
|
...new Set([
|
|
@@ -4998,7 +5154,7 @@ function planFamilySources(files, cwd) {
|
|
|
4998
5154
|
// prettier-ignore
|
|
4999
5155
|
async function preloadFamilySource(filePath, loader, interception) {
|
|
5000
5156
|
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}); } }
|
|
5157
|
+
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
5158
|
finally { patch.undo(); }
|
|
5003
5159
|
}
|
|
5004
5160
|
|
|
@@ -5026,7 +5182,7 @@ export async function themeBuildFamily(
|
|
|
5026
5182
|
await selectCore(cwd);
|
|
5027
5183
|
const familyInterception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
5028
5184
|
// prettier-ignore
|
|
5029
|
-
const familyLoader = createJiti(import.meta.url, {moduleCache: true,
|
|
5185
|
+
const familyLoader = createJiti(import.meta.url, {moduleCache: true, ...jitiCacheOptions(), interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
|
|
5030
5186
|
/** @type {any[]} */
|
|
5031
5187
|
const prepared = [];
|
|
5032
5188
|
for (const source of planFamilySources(files, cwd)) {
|
|
@@ -1,6 +1,14 @@
|
|
|
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 that something has to
|
|
6
|
+
* load: its names without generics, CSS-wide keywords, `var()` references
|
|
7
|
+
* or known system families.
|
|
8
|
+
* @param {string} value
|
|
9
|
+
* @returns {string[]}
|
|
10
|
+
*/
|
|
11
|
+
export function loadableFontFamilies(value: string): string[];
|
|
4
12
|
/**
|
|
5
13
|
* Collect the font families a resolved theme names but does not load —
|
|
6
14
|
* 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,20 @@ function splitFamilies(value) {
|
|
|
129
134
|
return families;
|
|
130
135
|
}
|
|
131
136
|
|
|
137
|
+
/**
|
|
138
|
+
* The font families a CSS font-family value names that something has to
|
|
139
|
+
* load: its names without generics, CSS-wide keywords, `var()` references
|
|
140
|
+
* or known system families.
|
|
141
|
+
* @param {string} value
|
|
142
|
+
* @returns {string[]}
|
|
143
|
+
*/
|
|
144
|
+
export function loadableFontFamilies(value) {
|
|
145
|
+
return splitFamilies(value).filter(family => {
|
|
146
|
+
const key = family.toLowerCase();
|
|
147
|
+
return !GENERIC_KEYWORDS.has(key) && !SYSTEM_FAMILIES.has(key);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
132
151
|
/**
|
|
133
152
|
* Collect the font families a resolved theme names but does not load —
|
|
134
153
|
* 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
|
/**
|
|
@@ -30,6 +30,25 @@ export function projectRoot(cwd: string): string;
|
|
|
30
30
|
* @returns {AstryxError | null}
|
|
31
31
|
*/
|
|
32
32
|
export function editorThemeRefusal(err: AstryxError, cwd: string): AstryxError | null;
|
|
33
|
+
/**
|
|
34
|
+
* The editor themes of the app the folder `cwd` is in, by name; none when
|
|
35
|
+
* the folder is in no app or its themes cannot be read.
|
|
36
|
+
* @param {string} cwd
|
|
37
|
+
* @returns {string[]}
|
|
38
|
+
*/
|
|
39
|
+
export function editorThemesAt(cwd: string): string[];
|
|
40
|
+
/**
|
|
41
|
+
* A refused compile whose first suggestion is another compile: that compile
|
|
42
|
+
* is run through compile's own checks before it is offered (in memory,
|
|
43
|
+
* nothing built), and each repair a refusal of it offers is folded into the
|
|
44
|
+
* one line. An --out outside the working folder is dropped, and the reason
|
|
45
|
+
* says why; when the rest cannot be repaired, the reason says so. A line
|
|
46
|
+
* that starts with `cd` runs elsewhere, so it is not checked from here.
|
|
47
|
+
* @param {AstryxError} err
|
|
48
|
+
* @param {string} cwd
|
|
49
|
+
* @returns {Promise<AstryxError>}
|
|
50
|
+
*/
|
|
51
|
+
export function editorFollowCompile(err: AstryxError, cwd: string): Promise<AstryxError>;
|
|
33
52
|
/**
|
|
34
53
|
* A refusal before `compile` runs on an editor theme's files, or null: the
|
|
35
54
|
* editor's generated settings are not a theme source, `--family` does not
|
|
@@ -59,6 +78,42 @@ export function editorCompileProblem(files: string[], { cwd, check, family, icon
|
|
|
59
78
|
export function editorThemeHold(files: string[], { cwd }: {
|
|
60
79
|
cwd: string;
|
|
61
80
|
}): Promise<() => Promise<void>>;
|
|
81
|
+
/**
|
|
82
|
+
* For `compile` of an editor theme: `appCopyStale` for its result data when
|
|
83
|
+
* the app copy is behind (the same line set and show give); null for any
|
|
84
|
+
* other file or a current copy.
|
|
85
|
+
* @param {string} file the path as given
|
|
86
|
+
* @param {string} cwd
|
|
87
|
+
* @param {{check: boolean, upToDate?: boolean}} opts `upToDate`: the
|
|
88
|
+
* check's own verdict on the theme's outputs
|
|
89
|
+
* @returns {Promise<Record<string, unknown> | null>}
|
|
90
|
+
*/
|
|
91
|
+
export function editorBuildExtra(file: string, cwd: string, opts: {
|
|
92
|
+
check: boolean;
|
|
93
|
+
upToDate?: boolean;
|
|
94
|
+
}): Promise<Record<string, unknown> | null>;
|
|
95
|
+
/**
|
|
96
|
+
* For `compile` of an editor theme's own source (themes/<t>/<t>.theme.ts):
|
|
97
|
+
* the one color mode a light-only or dark-only theme has, which its source
|
|
98
|
+
* cannot say, for the build to write into the built module. Null for any
|
|
99
|
+
* other file (the app copy's source re-exports it from its build).
|
|
100
|
+
* @param {string} file the path as given
|
|
101
|
+
* @param {string} cwd
|
|
102
|
+
* @returns {['light'] | ['dark'] | null}
|
|
103
|
+
*/
|
|
104
|
+
export function editorColorModes(file: string, cwd: string): ["light"] | ["dark"] | null;
|
|
105
|
+
/**
|
|
106
|
+
* For `compile` of an editor theme (themes/<t>/ or its app copy's source):
|
|
107
|
+
* whether a font family is loaded by the app copy's font stylesheet as
|
|
108
|
+
* this compile writes it (src/themes/<t>/<t>.fonts.css, from the fonts the
|
|
109
|
+
* theme loads now: an @fontsource package by its name, a stylesheet by the
|
|
110
|
+
* `family=` it requests), so the build's "named but not loaded" notice
|
|
111
|
+
* leaves it out. Null for any other file.
|
|
112
|
+
* @param {string} file the path as given
|
|
113
|
+
* @param {string} cwd
|
|
114
|
+
* @returns {Promise<((family: string) => boolean) | null>}
|
|
115
|
+
*/
|
|
116
|
+
export function editorLoadedFonts(file: string, cwd: string): Promise<((family: string) => boolean) | null>;
|
|
62
117
|
/**
|
|
63
118
|
* For `compile` of a file that is not there: when it is an editor theme's
|
|
64
119
|
* own source (`themes/<t>/<t>.theme.ts` beside its settings), the command
|