@astryxdesign/cli 0.7.18-canary.gfca8508 → 0.7.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +185 -19
- package/README.md +19 -19
- package/api/component/_adapter.d.mts +2 -1
- package/api/component/_adapter.mjs +2 -1
- package/api/docs/_adapter.d.mts +6 -5
- package/api/docs/_adapter.mjs +36 -5
- package/api/doctor/_adapter.d.mts +6 -3
- package/api/doctor/_adapter.mjs +13 -5
- package/api/doctor/doctor.mjs +2 -2
- package/api/doctor/font-packages.d.mts +36 -0
- package/api/doctor/font-packages.mjs +124 -0
- package/api/doctor/theme-checks.mjs +110 -49
- package/api/experimental.d.mts +0 -2
- package/api/experimental.mjs +0 -12
- package/api/icon/_adapter.d.mts +1 -1
- package/api/icon/_adapter.mjs +1 -0
- package/api/icon/_authoring.mjs +17 -8
- package/api/icon/_default-look.mjs +15 -15
- package/api/icon/add/add.mjs +9 -4
- package/api/icon/exportIconIndex.doc.mjs +1 -1
- package/api/icon/icon.doc.mjs +1 -1
- package/api/icon/icon.type.d.mts +33 -33
- package/api/icon/icon.type.mjs +45 -45
- package/api/icon/iconAdd.doc.mjs +1 -1
- package/api/icon/iconNewSet.doc.mjs +3 -3
- package/api/icon/iconUse.doc.mjs +5 -5
- package/api/icon/rankIconIndex.doc.mjs +1 -1
- package/api/icon/use/use.mjs +4 -4
- package/api/init/run/run.mjs +0 -1
- package/api/integration/add-helpers.mjs +1 -1
- package/api/render/_adapter.mjs +7 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_candidate-score.mjs +20 -0
- package/api/search/_words.d.mts +8 -0
- package/api/search/_words.mjs +15 -0
- package/api/template/template.type.d.mts +2 -2
- package/api/template/template.type.mjs +2 -2
- package/api/theme/_adapter.mjs +19 -11
- package/api/theme/build/build.d.mts +19 -51
- package/api/theme/build/build.mjs +195 -189
- package/api/theme/build/font-warning.d.mts +19 -2
- package/api/theme/build/font-warning.mjs +46 -5
- package/api/theme/generateTonalPalette.doc.mjs +1 -1
- package/api/theme/palette/generate/derive-look.mjs +108 -37
- package/api/theme/palette/generate/mapping.mjs +2 -0
- package/api/theme/template/template.d.mts +0 -17
- package/api/theme/template/template.mjs +1 -42
- package/api/theme/theme.type.d.mts +5 -4
- package/api/theme/theme.type.mjs +5 -4
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeRemove.doc.mjs +1 -1
- package/assets/codemods/transforms/v0.7.0/preserve-bottom-sheet-content-padding.mjs +3 -1
- package/assets/component-list.generated.json +1 -1
- package/assets/discover/official-packages.json +26 -2
- package/assets/docs/author-a-theme.doc.mjs +6 -5
- package/assets/docs/browser-support.doc.mjs +1 -0
- package/assets/docs/icons.doc.mjs +8 -7
- package/assets/docs/motion.doc.mjs +46 -0
- package/assets/docs/theme.doc.dense.mjs +6 -17
- package/assets/docs/theme.doc.mjs +6 -16
- package/assets/docs/theme.doc.zh.mjs +6 -16
- package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
- package/assets/docs/tree/font-setup.doc.mjs +30 -0
- package/assets/docs/tree/icon-sets.doc.mjs +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +3 -3
- package/assets/docs/tree/tokens-color.doc.mjs +5 -0
- package/assets/docs/tree/tokens.doc.mjs +4 -3
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/definitions/drag.doc.mjs +1 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Card/SelectableCardElevated.doc.mjs +1 -1
- package/assets/templates/blocks/components/Card/SelectableCardElevated.tsx +20 -10
- package/assets/templates/blocks/components/Card/SelectableCardShowcase.doc.mjs +1 -1
- package/assets/templates/blocks/components/Card/SelectableCardShowcase.tsx +36 -16
- package/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx +6 -0
- package/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx +6 -0
- package/assets/templates/blocks/components/Hooks/useIndicatorFocusRingHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useIndicatorFocusRingHookUsage.tsx +63 -0
- package/assets/templates/blocks/components/Hooks/useLongPressHookUsage.doc.mjs +29 -0
- package/assets/templates/blocks/components/Hooks/useLongPressHookUsage.tsx +237 -0
- package/assets/templates/blocks/components/SideNav/SideNavShowcase.tsx +10 -72
- package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.doc.mjs +1 -1
- package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.tsx +7 -7
- package/assets/templates/blocks/components/Table/TableCustomRowTable.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/TableCustomRowTable.tsx +96 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat-landing/page.tsx +4 -0
- package/assets/templates/pages/dashboard-scorecard/page.tsx +26 -7
- package/assets/templates/pages/editor/page.tsx +13 -3
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/butter/butterTheme.ts +12 -10
- package/assets/templates/themes/butter/icons.tsx +2 -0
- package/assets/templates/themes/chocolate/chocolateTheme.ts +1 -0
- package/assets/templates/themes/chocolate/icons.tsx +2 -0
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/gothic/gothicTheme.ts +1 -0
- package/assets/templates/themes/gothic/icons.tsx +2 -0
- package/assets/templates/themes/matcha/icons.tsx +2 -0
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/matcha/matchaTheme.ts +1 -0
- package/assets/templates/themes/neutral/icons.tsx +2 -0
- package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/neutral/neutralTheme.ts +1 -0
- package/assets/templates/themes/stone/icons.tsx +2 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/stone/stoneTheme.ts +1 -0
- package/assets/templates/themes/y2k/icons.tsx +2 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +1 -0
- package/assets/theme.template.ts +9 -5
- package/authoring/config/parse.mjs +1 -1
- package/authoring/doctypes/base/type.ts +2 -3
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/icon-set/icon-names.mjs +1 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/experimental/icon.mjs +7 -7
- package/clients/cli/commands/experimental/index.mjs +0 -5
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
- package/clients/cli/commands/experimental-icon-use.doc.mjs +4 -4
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental.doc.mjs +2 -6
- package/clients/cli/commands/template.mjs +1 -1
- package/clients/cli/commands/theme-build.doc.mjs +8 -1
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -1
- package/clients/cli/commands/theme-remove.doc.mjs +1 -1
- package/clients/cli/commands/theme.doc.mjs +1 -11
- package/clients/cli/commands/theme.mjs +110 -475
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/index.mjs +4 -34
- package/clients/cli/lib/base-gate.mjs +2 -3
- package/clients/cli/lib/cli-error.mjs +8 -72
- package/clients/cli/lib/define-command.mjs +0 -19
- package/clients/cli/lib/json-shim.mjs +11 -633
- package/clients/cli/lib/manifest.mjs +0 -4
- package/clients/cli/lib/stray-option.mjs +1 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/color/css-color.mjs +2 -3
- package/foundation/discovery/app-layout.d.mts +13 -0
- package/foundation/discovery/app-layout.mjs +35 -0
- package/foundation/discovery/fixture-refs.d.mts +51 -0
- package/foundation/discovery/fixture-refs.mjs +351 -0
- package/foundation/discovery/icon-definition-discovery.mjs +1 -1
- package/foundation/discovery/icon-ranking.mjs +2 -2
- package/foundation/discovery/icon-set-checks.mjs +1 -1
- package/foundation/discovery/icon-set-discovery.mjs +1 -1
- package/foundation/discovery/icon-set-writer.d.mts +24 -7
- package/foundation/discovery/icon-set-writer.mjs +66 -22
- package/foundation/discovery/static-descriptor.d.mts +49 -0
- package/foundation/discovery/static-descriptor.mjs +548 -0
- package/foundation/discovery/template-adapter.d.mts +0 -47
- package/foundation/discovery/template-adapter.mjs +1 -333
- package/foundation/discovery/theme-discovery.d.mts +6 -47
- package/foundation/discovery/theme-discovery.mjs +15 -537
- package/foundation/doc-compiler/import.mjs +1 -1
- package/foundation/env/user-dirs.d.mts +5 -2
- package/foundation/env/user-dirs.mjs +12 -5
- package/foundation/fonts/next-font.d.mts +26 -0
- package/foundation/fonts/next-font.mjs +149 -0
- package/foundation/fs/empty-folder.mjs +2 -2
- package/foundation/fs/read-record.mjs +11 -4
- package/foundation/pictures/pictures.d.mts +1 -45
- package/foundation/pictures/pictures.mjs +8 -8
- package/foundation/release/folder-lock.mjs +3 -2
- package/foundation/render/cut-short.d.mts +2 -2
- package/foundation/render/cut-short.mjs +2 -2
- package/foundation/render/drawn-contrast.d.mts +2 -2
- package/foundation/render/drawn-contrast.mjs +2 -2
- package/foundation/render/font-probe.d.mts +2 -2
- package/foundation/render/font-probe.mjs +2 -2
- package/foundation/render/layers.mjs +1 -2
- package/foundation/render/package-resolve-hooks.d.mts +25 -5
- package/foundation/render/package-resolve-hooks.mjs +77 -14
- package/foundation/render/page-worker.mjs +24 -12
- package/foundation/render/part-boxes.d.mts +2 -3
- package/foundation/render/part-boxes.mjs +2 -3
- package/foundation/render/picture-chrome.mjs +5 -0
- package/foundation/render/render-page.d.mts +1 -1
- package/foundation/render/render-page.mjs +4 -5
- package/foundation/render/single-copy-hooks.d.mts +2 -0
- package/foundation/render/single-copy-hooks.mjs +2 -0
- package/foundation/response/error-codes.doc.mjs +14 -14
- package/foundation/response/error-codes.mjs +13 -13
- package/foundation/response/response-types.doc.mjs +7 -68
- package/foundation/runtime/css-tree.mjs +2 -2
- package/foundation/runtime/word-table.d.mts +1 -1
- package/foundation/runtime/word-table.mjs +1 -1
- package/foundation/suggest/other-command.d.mts +52 -15
- package/foundation/suggest/other-command.mjs +168 -45
- package/foundation/text/suggest-order.d.mts +7 -0
- package/foundation/text/suggest-order.mjs +1 -1
- package/package.json +7 -8
- package/api/theme-edit/_adapter.d.mts +0 -228
- package/api/theme-edit/_adapter.mjs +0 -2025
- package/api/theme-edit/_catalog.d.mts +0 -172
- package/api/theme-edit/_catalog.mjs +0 -806
- package/api/theme-edit/_check.d.mts +0 -391
- package/api/theme-edit/_check.mjs +0 -9370
- package/api/theme-edit/_color.d.mts +0 -135
- package/api/theme-edit/_color.mjs +0 -480
- package/api/theme-edit/_compiler.d.mts +0 -77
- package/api/theme-edit/_compiler.mjs +0 -1053
- package/api/theme-edit/_context.d.mts +0 -399
- package/api/theme-edit/_context.mjs +0 -1778
- package/api/theme-edit/_css.d.mts +0 -169
- package/api/theme-edit/_css.mjs +0 -1167
- package/api/theme-edit/_edit.d.mts +0 -167
- package/api/theme-edit/_edit.mjs +0 -11220
- package/api/theme-edit/_how-commands.d.mts +0 -315
- package/api/theme-edit/_how-commands.mjs +0 -1664
- package/api/theme-edit/_how-question.d.mts +0 -341
- package/api/theme-edit/_how-question.mjs +0 -33339
- package/api/theme-edit/_how-sides.d.mts +0 -22
- package/api/theme-edit/_how-sides.mjs +0 -173
- package/api/theme-edit/_how-steps.d.mts +0 -42
- package/api/theme-edit/_how-steps.mjs +0 -208
- package/api/theme-edit/_how-values.d.mts +0 -29
- package/api/theme-edit/_how-values.mjs +0 -111
- package/api/theme-edit/_how-words.d.mts +0 -15
- package/api/theme-edit/_how-words.mjs +0 -239
- package/api/theme-edit/_how.d.mts +0 -55
- package/api/theme-edit/_how.mjs +0 -2388
- package/api/theme-edit/_importers.d.mts +0 -38
- package/api/theme-edit/_importers.mjs +0 -188
- package/api/theme-edit/_marks.d.mts +0 -39
- package/api/theme-edit/_marks.mjs +0 -67
- package/api/theme-edit/_missed.d.mts +0 -56
- package/api/theme-edit/_missed.mjs +0 -1128
- package/api/theme-edit/_name-rule.d.mts +0 -11
- package/api/theme-edit/_name-rule.mjs +0 -12
- package/api/theme-edit/_normal.d.mts +0 -365
- package/api/theme-edit/_normal.mjs +0 -1978
- package/api/theme-edit/_overview.d.mts +0 -9
- package/api/theme-edit/_overview.mjs +0 -293
- package/api/theme-edit/_palette.d.mts +0 -616
- package/api/theme-edit/_palette.mjs +0 -2776
- package/api/theme-edit/_part-pieces.d.mts +0 -54
- package/api/theme-edit/_part-pieces.mjs +0 -179
- package/api/theme-edit/_part-words.d.mts +0 -39
- package/api/theme-edit/_part-words.mjs +0 -242
- package/api/theme-edit/_parts.d.mts +0 -402
- package/api/theme-edit/_parts.mjs +0 -2322
- package/api/theme-edit/_picture-traits.d.mts +0 -259
- package/api/theme-edit/_picture-traits.mjs +0 -1030
- package/api/theme-edit/_png.d.mts +0 -94
- package/api/theme-edit/_png.mjs +0 -479
- package/api/theme-edit/_preview-app.d.mts +0 -172
- package/api/theme-edit/_preview-app.mjs +0 -6430
- package/api/theme-edit/_preview.d.mts +0 -484
- package/api/theme-edit/_preview.mjs +0 -2775
- package/api/theme-edit/_project.d.mts +0 -207
- package/api/theme-edit/_project.mjs +0 -643
- package/api/theme-edit/_resolved.d.mts +0 -46
- package/api/theme-edit/_resolved.mjs +0 -800
- package/api/theme-edit/_set-line.d.mts +0 -29
- package/api/theme-edit/_set-line.mjs +0 -100
- package/api/theme-edit/_settings.d.mts +0 -2426
- package/api/theme-edit/_settings.mjs +0 -18449
- package/api/theme-edit/_tables.d.mts +0 -227
- package/api/theme-edit/_tables.mjs +0 -1128
- package/api/theme-edit/_text-looks.d.mts +0 -78
- package/api/theme-edit/_text-looks.mjs +0 -376
- package/api/theme-edit/_vet.d.mts +0 -50
- package/api/theme-edit/_vet.mjs +0 -166
- package/api/theme-edit/how/how.d.mts +0 -17
- package/api/theme-edit/how/how.mjs +0 -28
- package/api/theme-edit/new/new.d.mts +0 -11
- package/api/theme-edit/new/new.mjs +0 -22
- package/api/theme-edit/preview-add/preview-add.d.mts +0 -14
- package/api/theme-edit/preview-add/preview-add.mjs +0 -25
- package/api/theme-edit/preview-app/preview-app.d.mts +0 -13
- package/api/theme-edit/preview-app/preview-app.mjs +0 -24
- package/api/theme-edit/preview-list/preview-list.d.mts +0 -10
- package/api/theme-edit/preview-list/preview-list.mjs +0 -21
- package/api/theme-edit/preview-remove/preview-remove.d.mts +0 -12
- package/api/theme-edit/preview-remove/preview-remove.mjs +0 -23
- package/api/theme-edit/set/set.d.mts +0 -13
- package/api/theme-edit/set/set.mjs +0 -24
- package/api/theme-edit/show/show.d.mts +0 -13
- package/api/theme-edit/show/show.mjs +0 -24
- package/api/theme-edit/theme-edit.d.mts +0 -12
- package/api/theme-edit/theme-edit.mjs +0 -36
- package/api/theme-edit/theme-edit.type.d.mts +0 -730
- package/api/theme-edit/theme-edit.type.mjs +0 -342
- package/api/theme-edit/themeEditHow.doc.d.mts +0 -6
- package/api/theme-edit/themeEditHow.doc.mjs +0 -105
- package/api/theme-edit/themeEditNew.doc.d.mts +0 -5
- package/api/theme-edit/themeEditNew.doc.mjs +0 -112
- package/api/theme-edit/themeEditPreviewAdd.doc.d.mts +0 -6
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +0 -121
- package/api/theme-edit/themeEditPreviewApp.doc.d.mts +0 -6
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +0 -87
- package/api/theme-edit/themeEditPreviewList.doc.d.mts +0 -6
- package/api/theme-edit/themeEditPreviewList.doc.mjs +0 -62
- package/api/theme-edit/themeEditPreviewRemove.doc.d.mts +0 -6
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +0 -96
- package/api/theme-edit/themeEditSet.doc.d.mts +0 -6
- package/api/theme-edit/themeEditSet.doc.mjs +0 -175
- package/api/theme-edit/themeEditShow.doc.d.mts +0 -6
- package/api/theme-edit/themeEditShow.doc.mjs +0 -118
- package/api/theme-edit/themeEditUndo.doc.d.mts +0 -6
- package/api/theme-edit/themeEditUndo.doc.mjs +0 -133
- package/api/theme-edit/undo/undo.d.mts +0 -13
- package/api/theme-edit/undo/undo.mjs +0 -24
- package/assets/preview-app/README.md +0 -6
- package/assets/preview-app/css.d.ts +0 -5
- package/assets/preview-app/gitignore +0 -4
- package/assets/preview-app/next.config.mjs +0 -12
- package/assets/preview-app/package.json +0 -24
- package/assets/preview-app/src/app/globals.css +0 -6
- package/assets/preview-app/src/app/layout.tsx +0 -21
- package/assets/preview-app/src/app/page.tsx +0 -94
- package/assets/preview-app/src/app/providers.tsx +0 -16
- package/assets/preview-app/tsconfig.json +0 -27
- package/clients/cli/commands/experimental/theme.mjs +0 -2990
- package/clients/cli/commands/experimental-theme-add.doc.mjs +0 -80
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +0 -98
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +0 -196
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +0 -174
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +0 -139
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +0 -77
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +0 -105
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +0 -49
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +0 -72
- package/clients/cli/commands/experimental-theme-list.doc.mjs +0 -49
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +0 -88
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +0 -61
- package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +0 -48
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +0 -59
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +0 -41
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +0 -57
- package/clients/cli/commands/experimental-theme-targets.doc.mjs +0 -62
- package/clients/cli/commands/experimental-theme-template.doc.mjs +0 -63
- package/clients/cli/commands/experimental-theme-use.doc.mjs +0 -57
- package/clients/cli/commands/experimental-theme.doc.mjs +0 -60
- package/foundation/fonts/fontsource-families.generated.d.mts +0 -5
- package/foundation/fonts/fontsource-families.generated.mjs +0 -2110
|
@@ -117,6 +117,10 @@ import {
|
|
|
117
117
|
formatBatchFontLoadingHelp,
|
|
118
118
|
formatFontLoadingHelp,
|
|
119
119
|
} from './font-warning.mjs';
|
|
120
|
+
import {
|
|
121
|
+
nextFontFix,
|
|
122
|
+
rootLayoutImportsNextFont,
|
|
123
|
+
} from '../../../foundation/fonts/next-font.mjs';
|
|
120
124
|
import {interceptCore, withVirtualModules} from './core-interception.mjs';
|
|
121
125
|
import {irregularFileKind} from '../../../foundation/fs/regular-file.mjs';
|
|
122
126
|
import {extendsOf, moduleBindings, themeObjectOf} from './theme-object.mjs';
|
|
@@ -168,7 +172,6 @@ import {resolveIconImports} from './icon-imports.mjs';
|
|
|
168
172
|
import {selfContainedImports} from './self-contained.mjs';
|
|
169
173
|
import {importSpecifier} from './import-specifier.mjs';
|
|
170
174
|
import {THEME_BUILD_MARKER} from '../../../foundation/config/theme-build-header.mjs';
|
|
171
|
-
import {generatedMark} from '../../theme-edit/_marks.mjs';
|
|
172
175
|
|
|
173
176
|
// Import shared theme processing from core. `astryx theme build` MUST produce the
|
|
174
177
|
// exact same CSS as the `<Theme>` runtime, so it has exactly one generation
|
|
@@ -445,8 +448,7 @@ function realOrSelf(file) {
|
|
|
445
448
|
/**
|
|
446
449
|
* `target` spelled through real directories: the deepest ancestor that exists
|
|
447
450
|
* is resolved through its symlinks, and the missing rest is appended as given.
|
|
448
|
-
* The build groups and locates its outputs by it
|
|
449
|
-
* compile guard reads paths through it too, so both read a path the same way.
|
|
451
|
+
* The build groups and locates its outputs by it.
|
|
450
452
|
* @param {string} target absolute path
|
|
451
453
|
* @returns {string}
|
|
452
454
|
*/
|
|
@@ -712,8 +714,8 @@ function resolveToolVersions(cwd) {
|
|
|
712
714
|
}
|
|
713
715
|
|
|
714
716
|
/**
|
|
715
|
-
* The command a stale check names, in the words of the
|
|
716
|
-
*
|
|
717
|
+
* The command a stale check names, in the words of the command that ran it;
|
|
718
|
+
* the generated headers keep `theme build`.
|
|
717
719
|
* @param {string} command
|
|
718
720
|
* @param {{group: string, build: string}} [words]
|
|
719
721
|
*/
|
|
@@ -1174,79 +1176,30 @@ function isDirectorySync(file) {
|
|
|
1174
1176
|
}
|
|
1175
1177
|
|
|
1176
1178
|
/**
|
|
1177
|
-
* The
|
|
1178
|
-
*
|
|
1179
|
-
* names. The one reader build and doctor share.
|
|
1180
|
-
* @param {string} source the start of the file
|
|
1181
|
-
* @param {string} [file] its path, for a mark that names no exact command
|
|
1182
|
-
*/
|
|
1183
|
-
export function fileMark(source, file) {
|
|
1184
|
-
return generatedMark(source, GENERATED_MARKER, file);
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
* The command a file's leading comment says writes it, when another CLI
|
|
1189
|
-
* command generates it (the theme editor's settings module or app copy):
|
|
1190
|
-
* the exact command its mark names. Null for a theme build's own output and
|
|
1191
|
-
* a file without a mark, such as a theme source of one's own.
|
|
1192
|
-
* @param {string} file
|
|
1193
|
-
* @returns {string | null}
|
|
1179
|
+
* The first words of the mark on a file the theme editor of an earlier CLI
|
|
1180
|
+
* wrote: its settings module, or a file of a theme's app copy.
|
|
1194
1181
|
*/
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
* The command that writes a missing `file`: a file beside it carries
|
|
1202
|
-
* another command's mark, and a file there names `file` (a build output's
|
|
1203
|
-
* header names its source), so it is one that command writes. Null for any
|
|
1204
|
-
* other name, such as a typo.
|
|
1205
|
-
* @param {string} file
|
|
1206
|
-
* @returns {string | null}
|
|
1207
|
-
*/
|
|
1208
|
-
function missingGeneratedCommand(file) {
|
|
1209
|
-
const dir = path.dirname(file);
|
|
1210
|
-
const base = path.basename(file);
|
|
1211
|
-
let names;
|
|
1212
|
-
try {
|
|
1213
|
-
names = fs.readdirSync(dir).sort();
|
|
1214
|
-
} catch {
|
|
1215
|
-
return null;
|
|
1216
|
-
}
|
|
1217
|
-
/** @type {string | null} */
|
|
1218
|
-
let by = null;
|
|
1219
|
-
let named = false;
|
|
1220
|
-
for (const n of names) {
|
|
1221
|
-
const f = path.join(dir, n);
|
|
1222
|
-
try {
|
|
1223
|
-
if (!fs.statSync(f).isFile()) continue;
|
|
1224
|
-
} catch {
|
|
1225
|
-
continue;
|
|
1226
|
-
}
|
|
1227
|
-
by ??= generatedFileCommand(f);
|
|
1228
|
-
if (!named)
|
|
1229
|
-
try {
|
|
1230
|
-
named = fs.readFileSync(f, 'utf8').slice(0, 4000).includes(base);
|
|
1231
|
-
} catch {
|
|
1232
|
-
// A file that does not read names nothing.
|
|
1233
|
-
}
|
|
1234
|
-
if (by && named) return by;
|
|
1235
|
-
}
|
|
1236
|
-
return null;
|
|
1237
|
-
}
|
|
1182
|
+
const EDITOR_MARKS = [
|
|
1183
|
+
'Generated by `astryx experimental theme editor',
|
|
1184
|
+
'Written by `astryx experimental theme editor',
|
|
1185
|
+
];
|
|
1238
1186
|
|
|
1239
1187
|
/**
|
|
1240
|
-
*
|
|
1241
|
-
*
|
|
1242
|
-
*
|
|
1243
|
-
*
|
|
1244
|
-
* @
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1188
|
+
* Who generated a file, from its leading comment: `build` for a theme
|
|
1189
|
+
* build's output, `editor` for a file the theme editor of an earlier CLI
|
|
1190
|
+
* wrote. Null for a file without such a mark, such as a theme source of
|
|
1191
|
+
* one's own. The one reader build and doctor share.
|
|
1192
|
+
* @param {string} source the start of the file
|
|
1193
|
+
* @returns {{kind: 'build' | 'editor'} | null}
|
|
1194
|
+
*/
|
|
1195
|
+
export function fileMark(source) {
|
|
1196
|
+
const leading =
|
|
1197
|
+
/^\s*(?:\/\*[\s\S]*?\*\/|(?:\/\/[^\n]*(?:\n|$)\s*)+)/.exec(source)?.[0] ??
|
|
1198
|
+
'';
|
|
1199
|
+
if (leading.includes(GENERATED_MARKER)) return {kind: 'build'};
|
|
1200
|
+
return EDITOR_MARKS.some(mark => leading.includes(mark))
|
|
1201
|
+
? {kind: 'editor'}
|
|
1202
|
+
: null;
|
|
1250
1203
|
}
|
|
1251
1204
|
|
|
1252
1205
|
/** @param {string} file @returns {string} the start of a file, or '' when it cannot be read (no regular file is opened) */
|
|
@@ -1482,36 +1435,27 @@ function assertThemeSourceFile(filePath, cwd, mode = {}) {
|
|
|
1482
1435
|
* output must stay inside, for a scratch build; `commandWords` names the
|
|
1483
1436
|
* command in the rebuild hint; `prepareFamily`, `familyLoader`, and
|
|
1484
1437
|
* `familyInterception` make the build a family member's plan.
|
|
1485
|
-
*
|
|
1486
|
-
* (the theme editor, from its settings), written into the built module.
|
|
1487
|
-
* `ownsOutputs` says the caller made the folder the outputs go into and owns
|
|
1488
|
-
* every file there named like one (the theme editor's theme folder), so a
|
|
1489
|
-
* damaged or half-written output is replaced, never refused.
|
|
1490
|
-
* `warnings` takes each warning message of the build, in check mode too,
|
|
1491
|
-
* where the receipt carries none (the theme editor, recording a source as
|
|
1492
|
-
* built without building it, keeps the warnings that build gives).
|
|
1493
|
-
* @typedef {{warnings?: string[], ownsOutputs?: boolean, prepareFamily?: boolean, familyLoader?: any, familyInterception?: any, writeRoot?: string, claimedOutputs?: Map<string, string>, deferredWrites?: Array<Array<{dest: string, content: string}>>, commandWords?: {group: string, build: string}, colorModes?: ['light'] | ['dark'] | null, fontHelp?: FontHelp | null, loadedFonts?: ((family: string) => boolean) | null, install?: string | null}} ThemeBuildHandOff
|
|
1438
|
+
* @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}, loadedFonts?: ((family: string) => boolean) | null}} ThemeBuildHandOff
|
|
1494
1439
|
*/
|
|
1495
1440
|
|
|
1496
1441
|
/**
|
|
1497
|
-
* How
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1442
|
+
* How to load a family the theme names and the app does not load, in place
|
|
1443
|
+
* of the generic help: the notice per family and the recipe (the next/font
|
|
1444
|
+
* fix, in an app whose root layout imports next/font).
|
|
1500
1445
|
* @typedef {{notice: (family: string) => string, recipe: (families: string[]) => string}} FontHelp
|
|
1501
1446
|
*/
|
|
1502
1447
|
|
|
1503
1448
|
/**
|
|
1504
|
-
* Who takes the
|
|
1505
|
-
*
|
|
1506
|
-
*
|
|
1507
|
-
*
|
|
1508
|
-
* themeBuild.
|
|
1449
|
+
* Who takes the warning about a folder the theme editor made instead of the
|
|
1450
|
+
* logger: the watcher's child build hands it to its parent, which prints it
|
|
1451
|
+
* once per session. Set only by the CLI (not part of the public API), and
|
|
1452
|
+
* never by an option of themeBuild.
|
|
1509
1453
|
* @type {((warning: string) => void) | null}
|
|
1510
1454
|
*/
|
|
1511
1455
|
let editorFolderListener = null;
|
|
1512
1456
|
|
|
1513
1457
|
/**
|
|
1514
|
-
* Hand the
|
|
1458
|
+
* Hand the editor-folder warnings of the builds in this process to
|
|
1515
1459
|
* `listener` instead of the logger. CLI-internal: the watch child's
|
|
1516
1460
|
* hand-off to its parent.
|
|
1517
1461
|
* @param {((warning: string) => void) | null} listener
|
|
@@ -1579,8 +1523,8 @@ export function buildInputProblem(file, options, cwd) {
|
|
|
1579
1523
|
* for a family (with `shape.familyKey`)
|
|
1580
1524
|
* @param {BuildMode} mode
|
|
1581
1525
|
* @param {string} cwd
|
|
1582
|
-
* @param {{group: string, build: string}} [words] the command's own words
|
|
1583
|
-
*
|
|
1526
|
+
* @param {{group: string, build: string}} [words] the command's own words,
|
|
1527
|
+
* else `theme build`
|
|
1584
1528
|
* @param {SuggestionShape} [shape]
|
|
1585
1529
|
* @returns {string}
|
|
1586
1530
|
*/
|
|
@@ -1620,24 +1564,22 @@ export function buildSuggestion(source, mode, cwd, words, shape = {}) {
|
|
|
1620
1564
|
/**
|
|
1621
1565
|
* Refuse a build that would replace a file it does not own. A build never
|
|
1622
1566
|
* writes over its input, two of its own outputs at one path, or an output
|
|
1623
|
-
* another theme in the same run already wrote.
|
|
1624
|
-
*
|
|
1625
|
-
*
|
|
1626
|
-
* another file such as the user's own stylesheet, `package.json` or app
|
|
1627
|
-
* source.
|
|
1567
|
+
* another theme in the same run already wrote. It also replaces only outputs
|
|
1568
|
+
* of a release of the build (isBuildOutput) and empty files, never another
|
|
1569
|
+
* file such as the user's own stylesheet, `package.json` or app source.
|
|
1628
1570
|
* @param {Array<{dest: string}>} writes
|
|
1629
1571
|
* @param {string} filePath the theme source
|
|
1630
1572
|
* @param {string} cwd
|
|
1631
|
-
* @param {{claimed?: Map<string, string>, rerun?: (out: string | null) => string,
|
|
1573
|
+
* @param {{claimed?: Map<string, string>, rerun?: (out: string | null) => string, warnUnmarked?: boolean, acceptLegacy?: boolean, elsewhere?: string, onEditorFolder?: (warning: string) => void, onWarning?: (message: string) => void}} [options]
|
|
1632
1574
|
* `claimed`: outputs written earlier in this run, by the source that wrote
|
|
1633
1575
|
* them; `rerun`: this build's command with another --out, or without one;
|
|
1634
1576
|
* `acceptLegacy`: an output of the CLI before it was named Astryx counts
|
|
1635
1577
|
* as the build's own (the default paths, where the build always replaced
|
|
1636
|
-
* them); `warnUnmarked
|
|
1637
|
-
*
|
|
1638
|
-
*
|
|
1639
|
-
*
|
|
1640
|
-
*
|
|
1578
|
+
* them); `warnUnmarked`: a header-less file is replaced with a warning
|
|
1579
|
+
* naming it, as a family build has always replaced one; `elsewhere`: the
|
|
1580
|
+
* option that moves the outputs; `onEditorFolder`: takes the editor-folder
|
|
1581
|
+
* warning instead of the logger (a watcher prints it once); `onWarning`:
|
|
1582
|
+
* each warning's message too, for the result
|
|
1641
1583
|
*/
|
|
1642
1584
|
function assertOutputsReplaceable(
|
|
1643
1585
|
writes,
|
|
@@ -1646,7 +1588,6 @@ function assertOutputsReplaceable(
|
|
|
1646
1588
|
{
|
|
1647
1589
|
claimed,
|
|
1648
1590
|
rerun,
|
|
1649
|
-
refuseUnmarked = false,
|
|
1650
1591
|
warnUnmarked = false,
|
|
1651
1592
|
acceptLegacy = false,
|
|
1652
1593
|
elsewhere = '--out',
|
|
@@ -1671,7 +1612,7 @@ function assertOutputsReplaceable(
|
|
|
1671
1612
|
// its own. A source inside the folder builds there as always; one outside
|
|
1672
1613
|
// it writes there too, with a warning.
|
|
1673
1614
|
let editorFolder = false;
|
|
1674
|
-
if (
|
|
1615
|
+
if (writes.length) {
|
|
1675
1616
|
const dir = path.resolve(path.dirname(writes[0].dest));
|
|
1676
1617
|
const record = editorThemeRecord(dir);
|
|
1677
1618
|
const fromDir = path.relative(dir, path.resolve(filePath));
|
|
@@ -1733,9 +1674,7 @@ function assertOutputsReplaceable(
|
|
|
1733
1674
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
1734
1675
|
);
|
|
1735
1676
|
}
|
|
1736
|
-
const otherSource =
|
|
1737
|
-
? builtFromOtherSource(write.dest, owner, cwd)
|
|
1738
|
-
: null;
|
|
1677
|
+
const otherSource = builtFromOtherSource(write.dest, owner, cwd);
|
|
1739
1678
|
if (otherSource && !OUT_REFUSES_OTHER_SOURCE) {
|
|
1740
1679
|
// One warning per build: every output of that source goes together.
|
|
1741
1680
|
// It is printed after every output passes, so it names a replacement
|
|
@@ -1754,7 +1693,7 @@ function assertOutputsReplaceable(
|
|
|
1754
1693
|
// A family build keeps its released rule: a file without the current
|
|
1755
1694
|
// mark is replaced with a warning naming it.
|
|
1756
1695
|
const ours = isBuildOutput(write.dest, {legacy: acceptLegacy});
|
|
1757
|
-
if (
|
|
1696
|
+
if (stat.size > 0 && !ours) {
|
|
1758
1697
|
if (warnUnmarked) {
|
|
1759
1698
|
unmarkedReplaced.push(rel(write.dest));
|
|
1760
1699
|
continue;
|
|
@@ -2142,7 +2081,7 @@ function hasAdaptationIntent(themeDef) {
|
|
|
2142
2081
|
/**
|
|
2143
2082
|
* The default viewport-width tier start points, in CSS px. A theme whose
|
|
2144
2083
|
* effective map is exactly this asked for nothing.
|
|
2145
|
-
* SYNC: packages/core/src/theme/
|
|
2084
|
+
* SYNC: packages/core/src/theme/breakpoints.ts (DEFAULT_WIDTH_BREAKPOINTS)
|
|
2146
2085
|
*/
|
|
2147
2086
|
const DEFAULT_WIDTH_BREAKPOINTS = Object.freeze({
|
|
2148
2087
|
sm: 640,
|
|
@@ -2671,26 +2610,78 @@ function hasNamedExport(/** @type {string} */ file, /** @type {string} */ name,
|
|
|
2671
2610
|
return esm ? unknown ? null : false : null;
|
|
2672
2611
|
}
|
|
2673
2612
|
// prettier-ignore
|
|
2674
|
-
async function validateRegistryGraphs(/** @type {Array<{specifier: string, exportName: string}>} */ registries, /** @type {string} */ aggregatePath) {
|
|
2675
|
-
|
|
2676
|
-
|
|
2613
|
+
async function validateRegistryGraphs(/** @type {Array<{specifier: string, exportName: string, compiledCopy?: string}>} */ registries, /** @type {string} */ aggregatePath) {
|
|
2614
|
+
// A registry the build compiles is checked by importing its compiled copy
|
|
2615
|
+
// with Node, as the family module imports it; that import also loads every
|
|
2616
|
+
// module the copy imports, so the walk below its source only reads them.
|
|
2617
|
+
/** @type {Array<{specifier: string, parent: string, commonJs: boolean, imports: string[], root?: {exportName: string, compiledCopy?: string}, compiled?: boolean}>} */ const pending = registries.map(root => ({specifier: root.specifier, parent: aggregatePath, commonJs: false, imports: [root.exportName], root, compiled: root.compiledCopy != null}));
|
|
2618
|
+
/** @type {Array<{file: string, exportName: string, load?: string}>} */ const runtimeChecks = []; const seen = new Set();
|
|
2677
2619
|
while (pending.length > 0) {
|
|
2678
|
-
const current = pending.pop(); if (!current) break; const {specifier, parent, commonJs, imports, root} = current;
|
|
2620
|
+
const current = pending.pop(); if (!current) break; const {specifier, parent, commonJs, imports, root, compiled} = current;
|
|
2679
2621
|
if (/\.css(?:$|[?#])/i.test(specifier)) throw registryGraphError(`Theme family registry graph imports CSS: ${specifier}`);
|
|
2680
2622
|
const file = resolveRegistryModule(specifier, parent, commonJs); if (!file) continue;
|
|
2681
2623
|
if (/\.css$/i.test(file)) throw registryGraphError(`Theme family registry graph imports CSS: ${file}`);
|
|
2682
2624
|
const external = file.split(path.sep).includes('node_modules');
|
|
2683
|
-
for (const name of imports) if (external) runtimeChecks.push({file, exportName: name}); else { const named = hasNamedExport(file, name); if (named === false) throw registryGraphError(`Family registry ${file} does not export "${name}".`); if (named === null) runtimeChecks.push({file, exportName: name}); }
|
|
2684
|
-
if (
|
|
2625
|
+
if (!compiled) for (const name of imports) if (external) runtimeChecks.push({file, exportName: name}); else { const named = hasNamedExport(file, name); if (named === false) throw registryGraphError(`Family registry ${file} does not export "${name}".`); if (named === null) runtimeChecks.push({file, exportName: name}); }
|
|
2626
|
+
else if (!external) for (const name of imports) if (hasNamedExport(file, name) === false) throw registryGraphError(`Family registry ${file} does not export "${name}".`);
|
|
2627
|
+
if (root) runtimeChecks.push({file, exportName: root.exportName, load: root.compiledCopy});
|
|
2685
2628
|
if (seen.has(file)) continue; seen.add(file);
|
|
2686
|
-
if (/\.[cm]?[jt]sx?$/i.test(file)) for (const edge of moduleDependencies(fs.readFileSync(file, 'utf8'), file)) pending.push({...edge, parent: file});
|
|
2629
|
+
if (/\.[cm]?[jt]sx?$/i.test(file)) for (const edge of moduleDependencies(fs.readFileSync(file, 'utf8'), file)) pending.push({...edge, parent: file, compiled});
|
|
2687
2630
|
}
|
|
2688
2631
|
for (const [index, root] of runtimeChecks.entries()) {
|
|
2689
|
-
let exports; try { exports = await import(`${pathToFileURL(root.file).href}?astryx-family-check=${Date.now()}-${index}`); }
|
|
2632
|
+
let exports; try { exports = await import(`${pathToFileURL(root.load ?? root.file).href}?astryx-family-check=${Date.now()}-${index}`); }
|
|
2690
2633
|
catch (error) { throw registryGraphError(`Cannot import family registry ${root.file}: ${error instanceof Error ? error.message : String(error)}`); }
|
|
2691
2634
|
if (!(root.exportName in exports)) throw registryGraphError(`Family registry ${root.file} does not export "${root.exportName}".`);
|
|
2692
2635
|
}
|
|
2693
2636
|
}
|
|
2637
|
+
/**
|
|
2638
|
+
* Check a family's registries before anything is written. The modules the
|
|
2639
|
+
* build compiles are written to a folder beside the modules folder, at its
|
|
2640
|
+
* depth, so each relative import in them resolves as it will from the modules
|
|
2641
|
+
* folder, and each compiled registry is imported from there with Node, as
|
|
2642
|
+
* the family module will import it. The folder is always removed.
|
|
2643
|
+
* @param {Array<{specifier: string, exportName: string, compiledCopy?: string}>} registries
|
|
2644
|
+
* @param {string} aggregatePath
|
|
2645
|
+
* With `--check` nothing is written: a compiled registry whose committed
|
|
2646
|
+
* copy matches this build's is imported from that copy, and one whose copy is
|
|
2647
|
+
* stale or missing is left to the comparison of the outputs, which reports it.
|
|
2648
|
+
* @param {{outDir: string, modulesDir: string, writes: Array<{dest: string, content: string}>, check?: boolean}} compiled
|
|
2649
|
+
*/
|
|
2650
|
+
async function checkFamilyRegistries(registries, aggregatePath, {outDir, modulesDir, writes, check}) {
|
|
2651
|
+
// A compiled copy this build does not write (a file of yours holds its
|
|
2652
|
+
// path) is not what the family module imports, so that registry is checked
|
|
2653
|
+
// from its source, as before.
|
|
2654
|
+
const written = new Set(writes.map(write => write.dest));
|
|
2655
|
+
registries = registries.map(({compiledCopy, ...registry}) => (compiledCopy && written.has(compiledCopy) ? {...registry, compiledCopy} : registry));
|
|
2656
|
+
if (check) {
|
|
2657
|
+
// The committed copies are imported only when every module this build
|
|
2658
|
+
// compiles matches its committed copy: a copy imports the others.
|
|
2659
|
+
const current = writes.every(write => path.relative(modulesDir, write.dest).startsWith('..') || (fs.existsSync(write.dest) && normalizeThemeBuildForCompare(fs.readFileSync(write.dest, 'utf8')) === normalizeThemeBuildForCompare(write.content)));
|
|
2660
|
+
return validateRegistryGraphs(current ? registries : registries.filter(registry => !registry.compiledCopy), aggregatePath);
|
|
2661
|
+
}
|
|
2662
|
+
if (!registries.some(registry => registry.compiledCopy)) return validateRegistryGraphs(registries, aggregatePath);
|
|
2663
|
+
const checkDir = fs.mkdtempSync(path.join(outDir, `.${path.basename(modulesDir)}-check-`));
|
|
2664
|
+
/** @param {string} file */
|
|
2665
|
+
const inCheck = file => path.join(checkDir, path.relative(modulesDir, file));
|
|
2666
|
+
try {
|
|
2667
|
+
for (const write of writes) {
|
|
2668
|
+
if (path.relative(modulesDir, write.dest).startsWith('..')) continue;
|
|
2669
|
+
fs.mkdirSync(path.dirname(inCheck(write.dest)), {recursive: true});
|
|
2670
|
+
fs.writeFileSync(inCheck(write.dest), write.content);
|
|
2671
|
+
}
|
|
2672
|
+
await validateRegistryGraphs(
|
|
2673
|
+
registries.map(registry =>
|
|
2674
|
+
registry.compiledCopy ? {...registry, compiledCopy: inCheck(registry.compiledCopy)} : registry,
|
|
2675
|
+
),
|
|
2676
|
+
aggregatePath,
|
|
2677
|
+
);
|
|
2678
|
+
} catch (error) {
|
|
2679
|
+
if (error instanceof Error) error.message = error.message.split(checkDir).join(modulesDir);
|
|
2680
|
+
throw error;
|
|
2681
|
+
} finally {
|
|
2682
|
+
fs.rmSync(checkDir, {recursive: true, force: true});
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2694
2685
|
/**
|
|
2695
2686
|
* Resolve inherited source with exactly the loader's extension precedence.
|
|
2696
2687
|
* This reads module locations only; icon discovery never executes a second load.
|
|
@@ -4785,8 +4776,7 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
|
|
|
4785
4776
|
/**
|
|
4786
4777
|
* The refusal of an option given an empty or blank value, which names
|
|
4787
4778
|
* nothing: what to give instead, and the command without it; null for any
|
|
4788
|
-
* other value.
|
|
4789
|
-
* editor's compile refuses an empty or blank --out and --icons-specifier.
|
|
4779
|
+
* other value. `theme build` refuses a blank --out with it.
|
|
4790
4780
|
* @param {string} flag
|
|
4791
4781
|
* @param {unknown} value
|
|
4792
4782
|
* @param {string} instead
|
|
@@ -4843,7 +4833,7 @@ async function themeBuildInternal(
|
|
|
4843
4833
|
) {
|
|
4844
4834
|
// A blank --out names no file: the build would write files named by the
|
|
4845
4835
|
// spaces alone. An empty one writes beside the source, as a build without
|
|
4846
|
-
// --out does
|
|
4836
|
+
// --out does.
|
|
4847
4837
|
if (options.out !== '') {
|
|
4848
4838
|
const blank = blankOptionProblem(
|
|
4849
4839
|
'--out',
|
|
@@ -4873,31 +4863,6 @@ async function themeBuildInternal(
|
|
|
4873
4863
|
if (problem) throw problem;
|
|
4874
4864
|
}
|
|
4875
4865
|
|
|
4876
|
-
// A theme the theme editor made is built from its settings by the editor;
|
|
4877
|
-
// a plain build reads its settings module as last written (released CLIs
|
|
4878
|
-
// built it, so it still does, and says so).
|
|
4879
|
-
{
|
|
4880
|
-
const dir = path.dirname(filePath);
|
|
4881
|
-
const slug = path.basename(dir);
|
|
4882
|
-
if (
|
|
4883
|
-
(!handOff.commandWords || handOff.commandWords.group === 'theme') &&
|
|
4884
|
-
path.basename(filePath) === `${slug}.theme.ts` &&
|
|
4885
|
-
editorThemeRecord(dir)
|
|
4886
|
-
)
|
|
4887
|
-
(editorFolderListener ?? (w => logger.warn(w)))(
|
|
4888
|
-
`Warning: ${path.relative(cwd, filePath)} is a theme the theme editor made (${slug}.settings.json is beside it). This build reads ${slug}.settings.ts as last written; to build it from its settings, run ${formatCliCommand(`experimental theme editor show ${shellWord(slug)}`, cwd)}.${
|
|
4889
|
-
// The app imports the theme's app copy, which only the editor's
|
|
4890
|
-
// own build writes (and its --check checks): this one neither
|
|
4891
|
-
// writes it nor ${options.check ? 'checks' : 'updates'} it.
|
|
4892
|
-
fs.existsSync(
|
|
4893
|
-
path.join(path.dirname(dir), '..', 'src', 'themes', slug),
|
|
4894
|
-
)
|
|
4895
|
-
? ` It ${options.check ? 'does not check' : 'does not write'} the app copy in src/themes/${slug}/, which the app imports; ${formatCliCommand(`experimental theme compile ${shellWord(path.relative(cwd, filePath).split(path.sep).join('/'))}${options.check ? ' --check' : ''}`, cwd)} ${options.check ? 'checks the build and the copy' : 'builds it and writes the copy'}.`
|
|
4896
|
-
: ''
|
|
4897
|
-
}`,
|
|
4898
|
-
);
|
|
4899
|
-
}
|
|
4900
|
-
|
|
4901
4866
|
assertThemeSourceFile(filePath, cwd, options);
|
|
4902
4867
|
|
|
4903
4868
|
if (!report.compact) {
|
|
@@ -4975,7 +4940,7 @@ async function themeBuildInternal(
|
|
|
4975
4940
|
unbuiltStylesheets = loaded.unbuiltStylesheets ?? [];
|
|
4976
4941
|
importedStylesheets = loaded.importedStylesheets ?? [];
|
|
4977
4942
|
loadDegradation = loaded.degraded;
|
|
4978
|
-
colorModes =
|
|
4943
|
+
colorModes = loaded.colorModes ?? null;
|
|
4979
4944
|
// Every value of the theme is read here, where a getter or Proxy of the
|
|
4980
4945
|
// module's that throws is a failed load naming the file and the field,
|
|
4981
4946
|
// never a failure of a check that reads it later.
|
|
@@ -5322,7 +5287,7 @@ async function themeBuildInternal(
|
|
|
5322
5287
|
// A typography value Core builds into something no browser uses (a font
|
|
5323
5288
|
// stack in one family, a quoted name with a space, a role weight with no
|
|
5324
5289
|
// type scale), or of a type the field does not take (a weight as a
|
|
5325
|
-
// number): warned at its line
|
|
5290
|
+
// number): warned at its line. Only what
|
|
5326
5291
|
// this file writes: a theme it extends is judged in its own file. A build
|
|
5327
5292
|
// that loads the project's own Core captures no input: the values the
|
|
5328
5293
|
// source writes are read from it.
|
|
@@ -5357,7 +5322,7 @@ async function themeBuildInternal(
|
|
|
5357
5322
|
});
|
|
5358
5323
|
|
|
5359
5324
|
// A radius scale missing a field builds every scaled corner as NaNpx:
|
|
5360
|
-
// warned at its line
|
|
5325
|
+
// warned at its line.
|
|
5361
5326
|
const radiusInput =
|
|
5362
5327
|
interception?.inputOf(themeDef)?.radius ??
|
|
5363
5328
|
// A plain-object theme is its own input.
|
|
@@ -6232,12 +6197,10 @@ async function themeBuildInternal(
|
|
|
6232
6197
|
cwd,
|
|
6233
6198
|
);
|
|
6234
6199
|
// Beside the source or at a path --out names, only build outputs are
|
|
6235
|
-
// replaced: a file of the user's own of the same name is kept.
|
|
6236
|
-
// that owns the output folder (the theme editor) repairs it instead.
|
|
6200
|
+
// replaced: a file of the user's own of the same name is kept.
|
|
6237
6201
|
assertOutputsReplaceable(writes, filePath, cwd, {
|
|
6238
6202
|
claimed: handOff.claimedOutputs,
|
|
6239
6203
|
rerun,
|
|
6240
|
-
refuseUnmarked: !handOff.ownsOutputs,
|
|
6241
6204
|
// At the default paths the build always replaced what was there, so an
|
|
6242
6205
|
// output of the CLI before it was named Astryx is still its own; a path
|
|
6243
6206
|
// --out names keeps its released rule (the current mark only).
|
|
@@ -6279,7 +6242,6 @@ async function themeBuildInternal(
|
|
|
6279
6242
|
);
|
|
6280
6243
|
}
|
|
6281
6244
|
warnMissingDeclarations(writes, cwd);
|
|
6282
|
-
handOff.warnings?.push(...warningMessages);
|
|
6283
6245
|
return /** @type {import('../theme.type.mjs').ThemeBuildCheckResponse} */ ({
|
|
6284
6246
|
type: 'theme.build.check',
|
|
6285
6247
|
data: {
|
|
@@ -6345,16 +6307,26 @@ async function themeBuildInternal(
|
|
|
6345
6307
|
// named only inside one needs the same notice as one named at the root.
|
|
6346
6308
|
// The result names the recipe's command bare, as every machine-read
|
|
6347
6309
|
// command is; the printed note starts it the way this project runs the CLI.
|
|
6310
|
+
// A next/font app loads each family under a name of its own, so its fix is
|
|
6311
|
+
// the font's CSS variable, not a <link> or @font-face. Its printed notes
|
|
6312
|
+
// name each family alone; the recipe printed after them carries the fix
|
|
6313
|
+
// once. The --json notices keep the fix in each one.
|
|
6314
|
+
const nextFont =
|
|
6315
|
+
unloadedFonts.length > 0 ? rootLayoutImportsNextFont(cwd) : false;
|
|
6316
|
+
const recipeTopic = nextFont ? 'docs font-setup' : 'docs typography';
|
|
6348
6317
|
/** @param {string} family @param {string} recipe */
|
|
6349
6318
|
const fontNotice = (family, recipe) =>
|
|
6350
|
-
|
|
6351
|
-
|
|
6319
|
+
nextFont
|
|
6320
|
+
? `Font "${family}" is named by this theme but not loaded. ${nextFontFix(recipe)}`
|
|
6321
|
+
: `Font "${family}" is named by this theme but not loaded; add a <link> or @font-face in your app (recipe: ${recipe})`;
|
|
6352
6322
|
/** @type {string[]} */
|
|
6353
6323
|
const fontNotices = [];
|
|
6354
6324
|
for (const family of unloadedFonts) {
|
|
6355
|
-
noticeMessages.push(fontNotice(family,
|
|
6325
|
+
noticeMessages.push(fontNotice(family, `astryx ${recipeTopic}`));
|
|
6356
6326
|
fontNotices.push(
|
|
6357
|
-
|
|
6327
|
+
nextFont
|
|
6328
|
+
? `Font "${family}" is named by this theme but not loaded.`
|
|
6329
|
+
: fontNotice(family, formatCliCommand(recipeTopic, cwd)),
|
|
6358
6330
|
);
|
|
6359
6331
|
}
|
|
6360
6332
|
|
|
@@ -6366,8 +6338,14 @@ async function themeBuildInternal(
|
|
|
6366
6338
|
cssImport,
|
|
6367
6339
|
unloadedFonts,
|
|
6368
6340
|
fontNotices,
|
|
6369
|
-
fontHelp:
|
|
6370
|
-
|
|
6341
|
+
fontHelp: nextFont
|
|
6342
|
+
? {
|
|
6343
|
+
notice: family =>
|
|
6344
|
+
fontNotice(family, formatCliCommand(recipeTopic, cwd)),
|
|
6345
|
+
recipe: () => `${nextFontFix(formatCliCommand(recipeTopic, cwd))}.`,
|
|
6346
|
+
}
|
|
6347
|
+
: null,
|
|
6348
|
+
nextFont,
|
|
6371
6349
|
};
|
|
6372
6350
|
// A batch or compact report prints this once for the whole run instead.
|
|
6373
6351
|
if (report.trailers) report.trailers.push(trailer);
|
|
@@ -6406,10 +6384,10 @@ async function themeBuildInternal(
|
|
|
6406
6384
|
* @property {string} cssImport Import specifier of the built CSS.
|
|
6407
6385
|
* @property {string[]} unloadedFonts Font families the theme names but does not load.
|
|
6408
6386
|
* @property {string[]} fontNotices One notice per unloaded font family, as printed.
|
|
6409
|
-
* @property {FontHelp | null} [fontHelp]
|
|
6410
|
-
*
|
|
6411
|
-
*
|
|
6412
|
-
*
|
|
6387
|
+
* @property {FontHelp | null} [fontHelp] The next/font recipe, when the app's
|
|
6388
|
+
* root layout imports next/font.
|
|
6389
|
+
* @property {boolean} [nextFont] Whether the app's root layout imports
|
|
6390
|
+
* next/font, directly or through a `geist/font` entry.
|
|
6413
6391
|
*/
|
|
6414
6392
|
|
|
6415
6393
|
/**
|
|
@@ -6417,9 +6395,7 @@ async function themeBuildInternal(
|
|
|
6417
6395
|
* @param {ThemeBuildTrailer} trailer
|
|
6418
6396
|
*/
|
|
6419
6397
|
function printBuildTrailer(trailer) {
|
|
6420
|
-
|
|
6421
|
-
else
|
|
6422
|
-
logger.log(`
|
|
6398
|
+
logger.log(`
|
|
6423
6399
|
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
6424
6400
|
|
|
6425
6401
|
import { Theme } from '@astryxdesign/core/theme';
|
|
@@ -6460,13 +6436,8 @@ Or with a <link> tag:
|
|
|
6460
6436
|
*/
|
|
6461
6437
|
export function printBatchTrailer(trailers) {
|
|
6462
6438
|
if (trailers.length === 0) return;
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
if (trailer.install) logger.log(`\n${trailer.install}\n`);
|
|
6466
|
-
const imported = trailers.filter(trailer => !trailer.install);
|
|
6467
|
-
const [first] = imported;
|
|
6468
|
-
if (first)
|
|
6469
|
-
logger.log(`
|
|
6439
|
+
const [first] = trailers;
|
|
6440
|
+
logger.log(`
|
|
6470
6441
|
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
6471
6442
|
|
|
6472
6443
|
import { Theme } from '@astryxdesign/core/theme';
|
|
@@ -6487,17 +6458,22 @@ Or with a <link> tag:
|
|
|
6487
6458
|
<App />
|
|
6488
6459
|
</Theme>
|
|
6489
6460
|
`);
|
|
6490
|
-
if (
|
|
6461
|
+
if (trailers.length > 1) {
|
|
6491
6462
|
logger.log('Each built theme imports the same way:');
|
|
6492
|
-
for (const trailer of
|
|
6463
|
+
for (const trailer of trailers) {
|
|
6493
6464
|
logger.log(
|
|
6494
6465
|
` import { ${trailer.exportName} } from '${trailer.jsImport}'; import '${trailer.cssImport}';`,
|
|
6495
6466
|
);
|
|
6496
6467
|
}
|
|
6497
6468
|
}
|
|
6498
6469
|
const fonts = groupUnloadedFonts(trailers);
|
|
6499
|
-
//
|
|
6500
|
-
|
|
6470
|
+
// The next/font recipe serves the batch only when every theme that leaves
|
|
6471
|
+
// a font unloaded takes it.
|
|
6472
|
+
const fontTrailers = trailers.filter(t => t.unloadedFonts.length > 0);
|
|
6473
|
+
const help =
|
|
6474
|
+
fontTrailers.length > 0 && fontTrailers.every(t => t.fontHelp)
|
|
6475
|
+
? fontTrailers[0].fontHelp
|
|
6476
|
+
: null;
|
|
6501
6477
|
if (fonts.length > 0)
|
|
6502
6478
|
logger.log(formatBatchFontLoadingHelp(fonts, help?.recipe));
|
|
6503
6479
|
}
|
|
@@ -6520,8 +6496,13 @@ export function printCompactTrailer(trailers, {hint = false} = {}) {
|
|
|
6520
6496
|
: `"${family}"`,
|
|
6521
6497
|
)
|
|
6522
6498
|
.join(', ');
|
|
6499
|
+
const nextFont = trailers
|
|
6500
|
+
.filter(trailer => trailer.unloadedFonts.length > 0)
|
|
6501
|
+
.every(trailer => trailer.nextFont);
|
|
6523
6502
|
logger.log(
|
|
6524
|
-
|
|
6503
|
+
nextFont
|
|
6504
|
+
? `[note] Fonts named but not loaded: ${named}. ${nextFontFix(formatCliCommand('docs font-setup'))}.`
|
|
6505
|
+
: `[note] Fonts named but not loaded: ${named}. Load them in your app (recipe: ${formatCliCommand('docs typography')}).`,
|
|
6525
6506
|
);
|
|
6526
6507
|
}
|
|
6527
6508
|
if (hint) {
|
|
@@ -6623,7 +6604,7 @@ function allocateFamilyBindings(members) {
|
|
|
6623
6604
|
* function, so its static values are written as JSON alone.
|
|
6624
6605
|
* @param {any} member
|
|
6625
6606
|
* @param {any} parent - The member's parent in the family, if any.
|
|
6626
|
-
* @param {{themeBinding: string | undefined, parentBinding: string | null | undefined, outDir: string, registryImports: Array<{specifier: string, exportName: string}>, expression: (own: string | null, inherited: string | null) => string | undefined, compileLocal?: (importPath: string, filePath: string) => {specifier: string, sourceFile: string} | null}} context
|
|
6607
|
+
* @param {{themeBinding: string | undefined, parentBinding: string | null | undefined, outDir: string, registryImports: Array<{specifier: string, exportName: string, compiledCopy?: string}>, expression: (own: string | null, inherited: string | null) => string | undefined, compileLocal?: (importPath: string, filePath: string) => {specifier: string, sourceFile: string} | null}} context
|
|
6627
6608
|
* @returns {{imports: Array<{importPath: string, importedName: string, localName: string}>, expression: string, mergeName?: string} | null}
|
|
6628
6609
|
*/
|
|
6629
6610
|
function familyComponentIcons(member, parent, context) {
|
|
@@ -6654,6 +6635,9 @@ function familyComponentIcons(member, parent, context) {
|
|
|
6654
6635
|
context.registryImports.push({
|
|
6655
6636
|
specifier: input.validate ?? importPath,
|
|
6656
6637
|
exportName: info.exportName,
|
|
6638
|
+
...(input.validate != null && input.specifier
|
|
6639
|
+
? {compiledCopy: path.resolve(context.outDir, input.specifier)}
|
|
6640
|
+
: {}),
|
|
6657
6641
|
});
|
|
6658
6642
|
} else {
|
|
6659
6643
|
// Without an import, a member's own slots are the ones that differ from
|
|
@@ -6922,7 +6906,7 @@ async function buildFamily(
|
|
|
6922
6906
|
const buildCommand = `astryx theme build --family ${headerSources.join(' ')} --family-key ${baseName}`;
|
|
6923
6907
|
const bindings = allocateFamilyBindings(members);
|
|
6924
6908
|
const css = generateFamilyCSS(members);
|
|
6925
|
-
/** @type {Array<{specifier: string, exportName: string}>} */
|
|
6909
|
+
/** @type {Array<{specifier: string, exportName: string, compiledCopy?: string}>} */
|
|
6926
6910
|
const registryImports = [];
|
|
6927
6911
|
// Each member's local TypeScript or JSX registry module is compiled under
|
|
6928
6912
|
// the family's output folder, all in one plan, so two members' modules of
|
|
@@ -7025,7 +7009,7 @@ async function buildFamily(
|
|
|
7025
7009
|
// prettier-ignore
|
|
7026
7010
|
const indicator = familyRegistryInput(member.indicatorInfo, member.filePath, outDir, undefined, compileLocal);
|
|
7027
7011
|
// prettier-ignore
|
|
7028
|
-
for (const registry of [icon, indicator]) if (registry.info) registryImports.push({specifier: registry.validate ?? registry.specifier ?? registry.info.importPath, exportName: registry.info.exportName});
|
|
7012
|
+
for (const registry of [icon, indicator]) if (registry.info) registryImports.push({specifier: registry.validate ?? registry.specifier ?? registry.info.importPath, exportName: registry.info.exportName, ...(registry.validate != null && registry.specifier ? {compiledCopy: path.resolve(outDir, registry.specifier)} : {})});
|
|
7029
7013
|
const ownIcons = icon.info ? `${themeBinding}Icons` : null;
|
|
7030
7014
|
// A parent with function entries keeps them in `__icons`; its `icons`
|
|
7031
7015
|
// is the node view.
|
|
@@ -7073,7 +7057,15 @@ async function buildFamily(
|
|
|
7073
7057
|
);
|
|
7074
7058
|
})
|
|
7075
7059
|
.join('\n');
|
|
7076
|
-
|
|
7060
|
+
/** @param {boolean} check */
|
|
7061
|
+
const checkRegistries = check =>
|
|
7062
|
+
checkFamilyRegistries(registryImports, jsPath, {
|
|
7063
|
+
outDir,
|
|
7064
|
+
modulesDir: modulesFolder(outDir, baseName),
|
|
7065
|
+
writes: [...localWrites.values()],
|
|
7066
|
+
check,
|
|
7067
|
+
});
|
|
7068
|
+
if (options.check) await checkRegistries(true);
|
|
7077
7069
|
const declarations = members
|
|
7078
7070
|
.map((member, index) =>
|
|
7079
7071
|
generateBuiltTypes(member.theme, member.iconInfo, null, {
|
|
@@ -7131,11 +7123,12 @@ async function buildFamily(
|
|
|
7131
7123
|
// naming it.
|
|
7132
7124
|
assertOutputsReplaceable(writes, root.filePath, cwd, {
|
|
7133
7125
|
elsewhere: '--family-key',
|
|
7134
|
-
refuseUnmarked: true,
|
|
7135
7126
|
warnUnmarked: true,
|
|
7136
7127
|
// The result's warnings carry what text prints.
|
|
7137
7128
|
onWarning: message => outputWarnings.push(message),
|
|
7138
7129
|
});
|
|
7130
|
+
// After the output checks refuse a build, before anything is written.
|
|
7131
|
+
await checkRegistries(false);
|
|
7139
7132
|
}
|
|
7140
7133
|
// Each member's settings that do not show as written, at the member's
|
|
7141
7134
|
// file when the member's own source writes them.
|
|
@@ -7249,21 +7242,34 @@ Or load the same stylesheet natively:
|
|
|
7249
7242
|
const unloadedFonts = [
|
|
7250
7243
|
...new Set(members.flatMap(member => member.unloadedFonts)),
|
|
7251
7244
|
];
|
|
7245
|
+
const nextFont =
|
|
7246
|
+
unloadedFonts.length > 0 ? rootLayoutImportsNextFont(cwd) : false;
|
|
7247
|
+
const recipeTopic = nextFont ? 'docs font-setup' : 'docs typography';
|
|
7252
7248
|
/** @param {string} family @param {string} recipe */
|
|
7253
7249
|
const familyNotice = (family, recipe) =>
|
|
7254
|
-
|
|
7250
|
+
nextFont
|
|
7251
|
+
? `Font "${family}" is named by this theme family but not loaded. ${nextFontFix(recipe)}`
|
|
7252
|
+
: `Font "${family}" is named by this theme family but not loaded; add a <link> or @font-face in your app (recipe: ${recipe})`;
|
|
7255
7253
|
// The result names the command bare; the printed note as this project
|
|
7256
7254
|
// runs the CLI.
|
|
7257
7255
|
const notices = [
|
|
7258
7256
|
...familySettingNotices,
|
|
7259
7257
|
...unloadedFonts.map(family =>
|
|
7260
|
-
familyNotice(family,
|
|
7258
|
+
familyNotice(family, `astryx ${recipeTopic}`),
|
|
7261
7259
|
),
|
|
7262
7260
|
];
|
|
7261
|
+
// In a next/font app each note names the family alone, and the fix prints
|
|
7262
|
+
// once after them.
|
|
7263
7263
|
for (const family of unloadedFonts)
|
|
7264
7264
|
logger.log(
|
|
7265
|
-
` note: ${
|
|
7265
|
+
` note: ${
|
|
7266
|
+
nextFont
|
|
7267
|
+
? `Font "${family}" is named by this theme family but not loaded.`
|
|
7268
|
+
: familyNotice(family, formatCliCommand(recipeTopic, cwd))
|
|
7269
|
+
}`,
|
|
7266
7270
|
);
|
|
7271
|
+
if (nextFont && unloadedFonts.length > 0)
|
|
7272
|
+
logger.log(` note: ${nextFontFix(formatCliCommand(recipeTopic, cwd))}.`);
|
|
7267
7273
|
return {
|
|
7268
7274
|
type: 'theme.build',
|
|
7269
7275
|
data: {
|