@astryxdesign/cli 0.7.18-canary.gfacee17 → 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 +5 -5
- 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 +2 -2
- package/api/icon/_adapter.mjs +6 -2
- package/api/icon/_authoring.mjs +22 -13
- package/api/icon/_default-look.mjs +15 -15
- package/api/icon/add/add.mjs +14 -9
- package/api/icon/icon.doc.mjs +7 -7
- package/api/icon/icon.type.d.mts +33 -33
- package/api/icon/icon.type.mjs +45 -45
- package/api/icon/iconAdd.doc.mjs +9 -10
- package/api/icon/iconMap.doc.mjs +11 -12
- package/api/icon/iconNewDefinition.doc.mjs +8 -8
- package/api/icon/iconNewSet.doc.mjs +5 -5
- package/api/icon/map/map.mjs +7 -7
- 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/integration/validate-integration.type.d.mts +6 -6
- package/api/integration/validate-integration.type.mjs +6 -6
- package/api/render/_adapter.d.mts +5 -3
- package/api/render/_adapter.mjs +64 -4
- package/api/render/render.doc.mjs +9 -2
- package/api/render/render.mjs +5 -2
- package/api/render/render.type.d.mts +17 -0
- package/api/render/render.type.mjs +10 -0
- 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/data-colors-in-renderers.doc.mjs +400 -0
- package/assets/docs/tree/font-setup.doc.mjs +30 -0
- package/assets/docs/tree/icon-sets.doc.mjs +2 -2
- package/assets/docs/tree/share-a-page.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/tree/visualization.doc.mjs +30 -0
- 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/doctor.mjs +2 -2
- package/clients/cli/commands/experimental/export.mjs +2 -1
- package/clients/cli/commands/experimental/icon.mjs +17 -17
- package/clients/cli/commands/experimental/index.mjs +0 -5
- package/clients/cli/commands/experimental/render-output.mjs +9 -0
- package/clients/cli/commands/experimental-export.doc.mjs +6 -0
- package/clients/cli/commands/experimental-icon-add.doc.mjs +8 -8
- package/clients/cli/commands/experimental-icon-map.doc.mjs +6 -6
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +6 -6
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +3 -3
- package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +6 -6
- 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/cli-self-docs.mjs +4 -4
- package/foundation/discovery/fixture-refs.d.mts +51 -0
- package/foundation/discovery/fixture-refs.mjs +351 -0
- package/foundation/discovery/icon-definition-discovery.mjs +7 -7
- package/foundation/discovery/icon-ranking.mjs +2 -2
- package/foundation/discovery/icon-set-checks.mjs +6 -6
- package/foundation/discovery/icon-set-discovery.mjs +2 -2
- package/foundation/discovery/icon-set-writer.d.mts +24 -7
- package/foundation/discovery/icon-set-writer.mjs +75 -31
- 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/bundle.mjs +2 -2
- 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 +152 -0
- package/foundation/pictures/pictures.mjs +565 -0
- 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 +18 -15
- package/foundation/render/picture-playwright.mjs +10 -7
- package/foundation/render/picture-window.d.mts +13 -0
- package/foundation/render/picture-window.mjs +31 -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 +8 -69
- 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 -33291
- 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 -2294
- 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 -549
- package/api/theme-edit/_preview.mjs +0 -3264
- 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 -18435
- 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
|
@@ -23,21 +23,29 @@ import {lowerDoc} from '../doc-compiler/compile.mjs';
|
|
|
23
23
|
import {packageSource} from '../doc-compiler/source.mjs';
|
|
24
24
|
import {CLI_ROOT, realDir} from '../fs/paths.mjs';
|
|
25
25
|
import {persistedGather} from '../fs/gather-cache.mjs';
|
|
26
|
-
import {fileStamp, recordContentRead} from '../fs/read-record.mjs';
|
|
27
26
|
import {EXACT_CODEC} from '../fs/exact-codec.mjs';
|
|
28
27
|
import {listDirEntries} from '../fs/listing-cache.mjs';
|
|
29
28
|
import {formatCliCommand} from '../env/package-manager.mjs';
|
|
30
29
|
import {LOCAL_THEME_ROOT} from '../config/theme-state.mjs';
|
|
31
30
|
import {assertWithin, PathSafetyError} from '../fs/path-safety.mjs';
|
|
32
31
|
import {THEME_MODULE_EXTENSIONS} from './theme-module-extensions.mjs';
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
readStore,
|
|
36
|
-
storedKey,
|
|
37
|
-
STORED_DOCS_FILE,
|
|
38
|
-
} from '../doc-compiler/stored-docs.mjs';
|
|
32
|
+
import {jscodeshift} from '../runtime/lazy-dependencies.mjs';
|
|
39
33
|
import {compareText} from '../text/compare-text.mjs';
|
|
40
34
|
import {currentNonCoreBase} from '../bases/state.mjs';
|
|
35
|
+
import {
|
|
36
|
+
descriptorStoreKey,
|
|
37
|
+
isIgnoredThemeEntry,
|
|
38
|
+
readDescriptorSource,
|
|
39
|
+
readStaticDescriptorValue,
|
|
40
|
+
STATIC_DESCRIPTOR_TYPES,
|
|
41
|
+
} from './static-descriptor.mjs';
|
|
42
|
+
export {
|
|
43
|
+
descriptorStoreKey,
|
|
44
|
+
isIgnoredThemeEntry,
|
|
45
|
+
readDescriptorSource,
|
|
46
|
+
readStaticDescriptorValue,
|
|
47
|
+
STATIC_DESCRIPTOR_TYPES,
|
|
48
|
+
};
|
|
41
49
|
|
|
42
50
|
export const BUNDLED_THEME_PACKAGE = '@astryxdesign/cli';
|
|
43
51
|
|
|
@@ -555,96 +563,6 @@ function moduleExportsName(
|
|
|
555
563
|
return found;
|
|
556
564
|
}
|
|
557
565
|
|
|
558
|
-
/**
|
|
559
|
-
* An expression without the parentheses around it.
|
|
560
|
-
* @param {any} node
|
|
561
|
-
* @returns {any}
|
|
562
|
-
*/
|
|
563
|
-
function unparenthesized(node) {
|
|
564
|
-
let current = node;
|
|
565
|
-
while (current?.type === 'ParenthesizedExpression') {
|
|
566
|
-
current = current.expression;
|
|
567
|
-
}
|
|
568
|
-
return current;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Convert one static literal used by ThemeDoc. Theme descriptors intentionally
|
|
573
|
-
* contain data only so synchronous bundled-theme APIs stay synchronous.
|
|
574
|
-
* @param {any} node
|
|
575
|
-
* @param {string} label
|
|
576
|
-
* @returns {string | boolean}
|
|
577
|
-
*/
|
|
578
|
-
function staticThemeValue(node, label) {
|
|
579
|
-
if (node?.type === 'StringLiteral' || node?.type === 'BooleanLiteral') {
|
|
580
|
-
return node.value;
|
|
581
|
-
}
|
|
582
|
-
throw new Error(
|
|
583
|
-
`${label} must use static string and boolean values in its default export.`,
|
|
584
|
-
);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* Convert one static literal of a data descriptor (an icon definition): a
|
|
589
|
-
* string, a boolean, or an array or plain object of those.
|
|
590
|
-
* @param {any} node
|
|
591
|
-
* @param {string} label
|
|
592
|
-
* @returns {unknown}
|
|
593
|
-
*/
|
|
594
|
-
function staticDataValue(node, label) {
|
|
595
|
-
if (node?.type === 'StringLiteral' || node?.type === 'BooleanLiteral') {
|
|
596
|
-
return node.value;
|
|
597
|
-
}
|
|
598
|
-
if (node?.type === 'ArrayExpression') {
|
|
599
|
-
return node.elements.map((/** @type {any} */ element) =>
|
|
600
|
-
staticDataValue(unparenthesized(element), label),
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
if (node?.type === 'ObjectExpression') {
|
|
604
|
-
return staticObject(node, label, staticDataValue);
|
|
605
|
-
}
|
|
606
|
-
throw new Error(
|
|
607
|
-
`${label} must use static strings, booleans, arrays, and objects in its default export.`,
|
|
608
|
-
);
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* A static object literal, every value converted by `convert`.
|
|
613
|
-
* @param {any} object
|
|
614
|
-
* @param {string} label
|
|
615
|
-
* @param {(node: any, label: string) => unknown} convert
|
|
616
|
-
* @returns {Record<string, any>}
|
|
617
|
-
*/
|
|
618
|
-
function staticObject(object, label, convert) {
|
|
619
|
-
/** @type {Record<string, any>} */
|
|
620
|
-
const value = {};
|
|
621
|
-
for (const property of object.properties) {
|
|
622
|
-
if (property.type !== 'ObjectProperty' || property.computed) {
|
|
623
|
-
throw new Error(`${label} must contain only static object properties.`);
|
|
624
|
-
}
|
|
625
|
-
const key =
|
|
626
|
-
property.key.type === 'Identifier'
|
|
627
|
-
? property.key.name
|
|
628
|
-
: property.key.type === 'StringLiteral'
|
|
629
|
-
? property.key.value
|
|
630
|
-
: null;
|
|
631
|
-
if (key === null) {
|
|
632
|
-
throw new Error(`${label} has an invalid property name.`);
|
|
633
|
-
}
|
|
634
|
-
if (Object.hasOwn(value, key)) {
|
|
635
|
-
throw new Error(`${label} declares "${key}" more than once.`);
|
|
636
|
-
}
|
|
637
|
-
// Defined, not assigned, so `__proto__` stays a key the parser rejects.
|
|
638
|
-
Object.defineProperty(value, key, {
|
|
639
|
-
value: convert(unparenthesized(property.value), label),
|
|
640
|
-
enumerable: true,
|
|
641
|
-
writable: true,
|
|
642
|
-
configurable: true,
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
return value;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
566
|
/**
|
|
649
567
|
* How messages about a theme descriptor name it.
|
|
650
568
|
* @param {string} docPath
|
|
@@ -678,13 +596,6 @@ function readThemeDoc(docPath, owner) {
|
|
|
678
596
|
return node.doc;
|
|
679
597
|
}
|
|
680
598
|
|
|
681
|
-
/**
|
|
682
|
-
* Descriptor reads in this process, by path and label, reused while the file
|
|
683
|
-
* keeps its stamp (`fileStamp`).
|
|
684
|
-
* @type {Map<string, {stamp: string, read: {value: Record<string, any>} | {error: unknown}}>}
|
|
685
|
-
*/
|
|
686
|
-
const descriptorReads = new Map();
|
|
687
|
-
|
|
688
599
|
/**
|
|
689
600
|
* The static value a theme descriptor default-exports, read from its source
|
|
690
601
|
* without executing it. Throws when the file is not one static ThemeDoc
|
|
@@ -697,424 +608,6 @@ export function readThemeDescriptorValue(docPath, label) {
|
|
|
697
608
|
return readStaticDescriptorValue(docPath, label, 'ThemeDoc');
|
|
698
609
|
}
|
|
699
610
|
|
|
700
|
-
/**
|
|
701
|
-
* The static value a typed descriptor default-exports, read from its source
|
|
702
|
-
* without executing it. Throws when the file is not one static object typed
|
|
703
|
-
* with `typeName` from `@astryxdesign/cli/authoring`. Theme and icon-set
|
|
704
|
-
* descriptors share this reader.
|
|
705
|
-
* @param {string} docPath
|
|
706
|
-
* @param {string} label
|
|
707
|
-
* @param {string} typeName the public authoring type, such as `ThemeDoc`
|
|
708
|
-
* @param {{data?: boolean}} [options] `data`: also accept arrays and plain
|
|
709
|
-
* objects of static values (icon definitions)
|
|
710
|
-
* @returns {Record<string, any>}
|
|
711
|
-
*/
|
|
712
|
-
export function readStaticDescriptorValue(
|
|
713
|
-
docPath,
|
|
714
|
-
label,
|
|
715
|
-
typeName,
|
|
716
|
-
{data = false} = {},
|
|
717
|
-
) {
|
|
718
|
-
// A kept read still counts as a read of the file, so a kept catalog sees an
|
|
719
|
-
// edit to it.
|
|
720
|
-
recordContentRead(docPath);
|
|
721
|
-
const stamp = fileStamp(docPath);
|
|
722
|
-
// An absent path throws the error a stat gives.
|
|
723
|
-
if (stamp === '-') fs.statSync(docPath);
|
|
724
|
-
const key = `${docPath}\0${label}\0${typeName}\0${data}`;
|
|
725
|
-
let cached = descriptorReads.get(key);
|
|
726
|
-
if (cached?.stamp !== stamp) {
|
|
727
|
-
/** @type {{value: Record<string, any>} | {error: unknown}} */
|
|
728
|
-
let read;
|
|
729
|
-
try {
|
|
730
|
-
const source = fs.readFileSync(docPath, 'utf-8');
|
|
731
|
-
// A descriptor Astryx ships was read at publish, by the hash of its
|
|
732
|
-
// text (scripts/generate-stored-docs.mjs): the same text reads the
|
|
733
|
-
// same value without parsing. Any other text, or a store that cannot
|
|
734
|
-
// be read, is parsed.
|
|
735
|
-
let stored;
|
|
736
|
-
try {
|
|
737
|
-
stored = readStore(STORED_DOCS_FILE).get(
|
|
738
|
-
descriptorStoreKey(source, typeName, data),
|
|
739
|
-
);
|
|
740
|
-
} catch {
|
|
741
|
-
stored = undefined;
|
|
742
|
-
}
|
|
743
|
-
read = {
|
|
744
|
-
value:
|
|
745
|
-
stored != null && typeof stored === 'object'
|
|
746
|
-
? stored
|
|
747
|
-
: readDescriptorSource(source, label, typeName, data),
|
|
748
|
-
};
|
|
749
|
-
} catch (error) {
|
|
750
|
-
read = {error};
|
|
751
|
-
}
|
|
752
|
-
cached = {stamp, read};
|
|
753
|
-
// A file that appeared after its stamp is not kept: the entry would
|
|
754
|
-
// outlive its removal.
|
|
755
|
-
if (stamp !== '-') descriptorReads.set(key, cached);
|
|
756
|
-
}
|
|
757
|
-
if ('error' in cached.read) throw cached.read.error;
|
|
758
|
-
return data ? structuredClone(cached.read.value) : {...cached.read.value};
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
/**
|
|
762
|
-
* The typed descriptors read statically, each with whether plain data is
|
|
763
|
-
* accepted: what scripts/generate-stored-docs.mjs reads at publish.
|
|
764
|
-
* @type {ReadonlyArray<[string, boolean]>}
|
|
765
|
-
*/
|
|
766
|
-
export const STATIC_DESCRIPTOR_TYPES = [
|
|
767
|
-
['ThemeDoc', false],
|
|
768
|
-
['IconSetDoc', false],
|
|
769
|
-
['IconDefinitionDoc', true],
|
|
770
|
-
];
|
|
771
|
-
|
|
772
|
-
/**
|
|
773
|
-
* Where a descriptor's statically read value is stored at publish: by the
|
|
774
|
-
* hash of its text, the type it is read as, and whether plain data counts.
|
|
775
|
-
* @param {string} source
|
|
776
|
-
* @param {string} typeName
|
|
777
|
-
* @param {boolean} data
|
|
778
|
-
* @returns {string}
|
|
779
|
-
*/
|
|
780
|
-
export function descriptorStoreKey(source, typeName, data) {
|
|
781
|
-
return `descriptor:${typeName}:${data ? 'data' : 'object'}:${storedKey(source)}`;
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* The static value a descriptor's source default-exports (see
|
|
786
|
-
* {@link readStaticDescriptorValue}); throws when it is not one.
|
|
787
|
-
* @param {string} source
|
|
788
|
-
* @param {string} label
|
|
789
|
-
* @param {string} typeName
|
|
790
|
-
* @param {boolean} [data]
|
|
791
|
-
* @returns {Record<string, any>}
|
|
792
|
-
*/
|
|
793
|
-
export function readDescriptorSource(source, label, typeName, data = false) {
|
|
794
|
-
/** @type {any} */
|
|
795
|
-
let ast;
|
|
796
|
-
try {
|
|
797
|
-
ast = babelParser().parse(source, {
|
|
798
|
-
sourceType: 'module',
|
|
799
|
-
tokens: true,
|
|
800
|
-
createParenthesizedExpressions: true,
|
|
801
|
-
});
|
|
802
|
-
} catch (error) {
|
|
803
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
804
|
-
throw new Error(`${label} could not be parsed: ${message}`, {cause: error});
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
const statements = ast.program.body;
|
|
808
|
-
const defaults = statements.filter(
|
|
809
|
-
(/** @type {any} */ statement) =>
|
|
810
|
-
statement.type === 'ExportDefaultDeclaration',
|
|
811
|
-
);
|
|
812
|
-
const unsupported = statements.filter(
|
|
813
|
-
(/** @type {any} */ statement) =>
|
|
814
|
-
statement.type !== 'ExportDefaultDeclaration' &&
|
|
815
|
-
statement.type !== 'EmptyStatement',
|
|
816
|
-
);
|
|
817
|
-
if (unsupported.length > 0 || ast.program.directives.length > 0) {
|
|
818
|
-
throw new Error(
|
|
819
|
-
`${label} must contain only its static default-exported ${typeName} object.`,
|
|
820
|
-
);
|
|
821
|
-
}
|
|
822
|
-
const object =
|
|
823
|
-
defaults.length === 1 && unparenthesized(defaults[0].declaration);
|
|
824
|
-
if (object?.type !== 'ObjectExpression') {
|
|
825
|
-
throw new Error(
|
|
826
|
-
`${label} must default-export one static ${typeName} object.`,
|
|
827
|
-
);
|
|
828
|
-
}
|
|
829
|
-
if (!declaresDocType(ast, defaults[0], typeName)) {
|
|
830
|
-
throw new Error(
|
|
831
|
-
`${label} must declare its public ${typeName} type from @astryxdesign/cli/authoring.`,
|
|
832
|
-
);
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
return staticObject(object, label, data ? staticDataValue : staticThemeValue);
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
/**
|
|
839
|
-
* `import('@astryxdesign/cli/authoring').<typeName>`, without whitespace.
|
|
840
|
-
* @param {string} typeName
|
|
841
|
-
*/
|
|
842
|
-
const authoringTypeRe = typeName =>
|
|
843
|
-
new RegExp(
|
|
844
|
-
String.raw`^import\((['"])@astryxdesign\/cli\/authoring\1\)\.${typeName}$`,
|
|
845
|
-
'u',
|
|
846
|
-
);
|
|
847
|
-
|
|
848
|
-
/** @param {any} comment */
|
|
849
|
-
function isJsdoc(comment) {
|
|
850
|
-
return comment.type === 'CommentBlock' && comment.value.startsWith('*');
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
/** @param {string} ch */
|
|
854
|
-
const isSpace = ch => ch === ' ' || ch === '\t';
|
|
855
|
-
|
|
856
|
-
/**
|
|
857
|
-
* The tags of one JSDoc comment, found the way TypeScript's JSDoc scanner
|
|
858
|
-
* finds them: an `@` starts a tag at the start of a line (after the margin
|
|
859
|
-
* `*`), or after a space and before a non-space, never inside a backtick span
|
|
860
|
-
* of a tag's text. Each tag's text runs to the next tag, margins removed.
|
|
861
|
-
* @param {string} value the comment's body, as Babel gives it
|
|
862
|
-
* @returns {{name: string, text: string}[]}
|
|
863
|
-
*/
|
|
864
|
-
function jsdocTags(value) {
|
|
865
|
-
const body = value.slice(1);
|
|
866
|
-
/** @type {number[]} */
|
|
867
|
-
const starts = [];
|
|
868
|
-
let lineStart = true;
|
|
869
|
-
let sawAsterisk = true;
|
|
870
|
-
let inTag = false;
|
|
871
|
-
let backticks = false;
|
|
872
|
-
for (let index = 0; index < body.length; index++) {
|
|
873
|
-
const ch = body[index];
|
|
874
|
-
if (ch === '\n' || ch === '\r') {
|
|
875
|
-
lineStart = true;
|
|
876
|
-
sawAsterisk = false;
|
|
877
|
-
backticks = false;
|
|
878
|
-
continue;
|
|
879
|
-
}
|
|
880
|
-
if (lineStart) {
|
|
881
|
-
if (isSpace(ch)) continue;
|
|
882
|
-
if (ch === '*' && !sawAsterisk) {
|
|
883
|
-
sawAsterisk = true;
|
|
884
|
-
continue;
|
|
885
|
-
}
|
|
886
|
-
lineStart = false;
|
|
887
|
-
if (ch === '@') {
|
|
888
|
-
starts.push(index);
|
|
889
|
-
inTag = true;
|
|
890
|
-
continue;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
if (ch === '`' && inTag) {
|
|
894
|
-
backticks = !backticks;
|
|
895
|
-
} else if (
|
|
896
|
-
ch === '@' &&
|
|
897
|
-
!backticks &&
|
|
898
|
-
isSpace(body[index - 1] ?? '') &&
|
|
899
|
-
!/\s/u.test(body[index + 1] ?? ' ')
|
|
900
|
-
) {
|
|
901
|
-
starts.push(index);
|
|
902
|
-
inTag = true;
|
|
903
|
-
backticks = false;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
return starts.map((start, position) => {
|
|
907
|
-
const raw = body.slice(start + 1, starts[position + 1] ?? body.length);
|
|
908
|
-
const name = /^[\w$]*/u.exec(raw)?.[0] ?? '';
|
|
909
|
-
const text = raw.slice(name.length).replace(/(\r?\n)[ \t]*\*?/gu, '$1');
|
|
910
|
-
return {name, text};
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
/**
|
|
915
|
-
* The braced type at the start of a tag's text, and what follows it.
|
|
916
|
-
* @param {string} text
|
|
917
|
-
* @returns {{type: string, rest: string} | null}
|
|
918
|
-
*/
|
|
919
|
-
function bracedType(text) {
|
|
920
|
-
const open = text.search(/\S/u);
|
|
921
|
-
if (open === -1 || text[open] !== '{') return null;
|
|
922
|
-
let depth = 0;
|
|
923
|
-
/** @type {string | null} */
|
|
924
|
-
let quote = null;
|
|
925
|
-
for (let index = open; index < text.length; index++) {
|
|
926
|
-
const ch = text[index];
|
|
927
|
-
if (quote) {
|
|
928
|
-
if (ch === quote) quote = null;
|
|
929
|
-
} else if (ch === "'" || ch === '"' || ch === '`') {
|
|
930
|
-
quote = ch;
|
|
931
|
-
} else if (ch === '{') {
|
|
932
|
-
depth++;
|
|
933
|
-
} else if (ch === '}' && --depth === 0) {
|
|
934
|
-
return {
|
|
935
|
-
type: text.slice(open + 1, index).replace(/\s+/gu, ''),
|
|
936
|
-
rest: text.slice(index + 1),
|
|
937
|
-
};
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
return null;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
/**
|
|
944
|
-
* Split a type at top-level occurrences of one operator.
|
|
945
|
-
* @param {string} type
|
|
946
|
-
* @param {string} operator
|
|
947
|
-
*/
|
|
948
|
-
function splitType(type, operator) {
|
|
949
|
-
/** @type {string[]} */
|
|
950
|
-
const parts = [];
|
|
951
|
-
let depth = 0;
|
|
952
|
-
/** @type {string | null} */
|
|
953
|
-
let quote = null;
|
|
954
|
-
let last = 0;
|
|
955
|
-
for (let index = 0; index < type.length; index++) {
|
|
956
|
-
const ch = type[index];
|
|
957
|
-
if (quote) {
|
|
958
|
-
if (ch === quote) quote = null;
|
|
959
|
-
} else if (ch === "'" || ch === '"' || ch === '`') {
|
|
960
|
-
quote = ch;
|
|
961
|
-
} else if ('([{<'.includes(ch)) {
|
|
962
|
-
depth++;
|
|
963
|
-
} else if (')]}>'.includes(ch)) {
|
|
964
|
-
depth--;
|
|
965
|
-
} else if (ch === operator && depth === 0) {
|
|
966
|
-
parts.push(type.slice(last, index));
|
|
967
|
-
last = index + 1;
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
parts.push(type.slice(last));
|
|
971
|
-
return parts;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
/** @param {string} type */
|
|
975
|
-
function wrappedInParens(type) {
|
|
976
|
-
if (!type.startsWith('(') || !type.endsWith(')')) return false;
|
|
977
|
-
let depth = 0;
|
|
978
|
-
for (let index = 0; index < type.length; index++) {
|
|
979
|
-
if (type[index] === '(') depth++;
|
|
980
|
-
else if (type[index] === ')' && --depth === 0) {
|
|
981
|
-
return index === type.length - 1;
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
return false;
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
/**
|
|
988
|
-
* Whether a JSDoc type, whitespace removed, checks an object literal exactly
|
|
989
|
-
* as `typeName` does: the type or one of its aliases, optionally
|
|
990
|
-
* parenthesized, marked `!`, `?` or `=`, joined with `null` or `undefined`, or
|
|
991
|
-
* intersected with `{}`.
|
|
992
|
-
* @param {string} type
|
|
993
|
-
* @param {Map<string, string>} aliases alias name to the type it names
|
|
994
|
-
* @param {string} typeName
|
|
995
|
-
* @param {Set<string>} [seen]
|
|
996
|
-
* @returns {boolean}
|
|
997
|
-
*/
|
|
998
|
-
function isDocType(type, aliases, typeName, seen = new Set()) {
|
|
999
|
-
let current = type;
|
|
1000
|
-
for (;;) {
|
|
1001
|
-
if (/^[!?]/u.test(current)) current = current.slice(1);
|
|
1002
|
-
else if (current.endsWith('=')) current = current.slice(0, -1);
|
|
1003
|
-
else if (wrappedInParens(current)) current = current.slice(1, -1);
|
|
1004
|
-
else break;
|
|
1005
|
-
}
|
|
1006
|
-
const members = splitType(current, '|').filter(
|
|
1007
|
-
member => member !== 'null' && member !== 'undefined',
|
|
1008
|
-
);
|
|
1009
|
-
if (members.length !== 1) return false;
|
|
1010
|
-
if (members[0] !== current) {
|
|
1011
|
-
return isDocType(members[0], aliases, typeName, seen);
|
|
1012
|
-
}
|
|
1013
|
-
const parts = splitType(current, '&').filter(part => part !== '{}');
|
|
1014
|
-
if (parts.length !== 1) return false;
|
|
1015
|
-
if (parts[0] !== current) return isDocType(parts[0], aliases, typeName, seen);
|
|
1016
|
-
if (authoringTypeRe(typeName).test(current)) return true;
|
|
1017
|
-
const named = aliases.get(current);
|
|
1018
|
-
if (named === undefined || seen.has(current)) return false;
|
|
1019
|
-
seen.add(current);
|
|
1020
|
-
return isDocType(named, aliases, typeName, seen);
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
const AUTHORING = String.raw`(['"])@astryxdesign\/cli\/authoring\2`;
|
|
1024
|
-
|
|
1025
|
-
/**
|
|
1026
|
-
* The type names the file's JSDoc binds with `@typedef` or `@import`, from any
|
|
1027
|
-
* JSDoc comment in the module, as TypeScript reads them.
|
|
1028
|
-
* @param {any[]} comments
|
|
1029
|
-
* @param {string} typeName
|
|
1030
|
-
* @returns {Map<string, string>}
|
|
1031
|
-
*/
|
|
1032
|
-
function jsdocAliases(comments, typeName) {
|
|
1033
|
-
/** @type {Map<string, string>} */
|
|
1034
|
-
const aliases = new Map();
|
|
1035
|
-
const theme = `import('@astryxdesign/cli/authoring').${typeName}`;
|
|
1036
|
-
for (const comment of comments.filter(isJsdoc)) {
|
|
1037
|
-
for (const tag of jsdocTags(comment.value)) {
|
|
1038
|
-
if (tag.name === 'typedef') {
|
|
1039
|
-
const typed = bracedType(tag.text);
|
|
1040
|
-
const name = typed && /^\s*([$A-Z_a-z][$\w]*)/u.exec(typed.rest)?.[1];
|
|
1041
|
-
if (typed && name) aliases.set(name, typed.type);
|
|
1042
|
-
} else if (tag.name === 'import') {
|
|
1043
|
-
const named = new RegExp(
|
|
1044
|
-
String.raw`^\s*\{([^{}]*)\}\s*from\s*${AUTHORING}`,
|
|
1045
|
-
'u',
|
|
1046
|
-
).exec(tag.text);
|
|
1047
|
-
for (const specifier of named?.[1].split(',') ?? []) {
|
|
1048
|
-
const match = new RegExp(
|
|
1049
|
-
String.raw`^\s*(?:type\s+)?${typeName}(?:\s+as\s+([$A-Z_a-z][$\w]*))?\s*$`,
|
|
1050
|
-
'u',
|
|
1051
|
-
).exec(specifier);
|
|
1052
|
-
if (match) aliases.set(match[1] ?? typeName, theme);
|
|
1053
|
-
}
|
|
1054
|
-
const namespace = new RegExp(
|
|
1055
|
-
String.raw`^\s*\*\s*as\s+([$A-Z_a-z][$\w]*)\s+from\s*${AUTHORING}`,
|
|
1056
|
-
'u',
|
|
1057
|
-
).exec(tag.text)?.[1];
|
|
1058
|
-
if (namespace) aliases.set(`${namespace}.${typeName}`, theme);
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
return aliases;
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
/**
|
|
1066
|
-
* Whether the JSDoc TypeScript reads for the default export types it as the
|
|
1067
|
-
* public `typeName` (such as ThemeDoc): `@type` in the last JSDoc comment between the previous
|
|
1068
|
-
* token and `export`, or `@type` or `@satisfies` in the last one between the
|
|
1069
|
-
* previous token and the opening parenthesis of a JSDoc cast of the object.
|
|
1070
|
-
* Line comments, strings, code spans, and JSDoc anywhere else never type it.
|
|
1071
|
-
* @param {any} ast parsed with tokens and parenthesized expressions
|
|
1072
|
-
* @param {any} exportDefault
|
|
1073
|
-
* @param {string} typeName
|
|
1074
|
-
*/
|
|
1075
|
-
function declaresDocType(ast, exportDefault, typeName) {
|
|
1076
|
-
const tokens = ast.tokens.filter(
|
|
1077
|
-
(/** @type {any} */ token) => typeof token.type !== 'string',
|
|
1078
|
-
);
|
|
1079
|
-
const comments = ast.comments ?? [];
|
|
1080
|
-
/** @param {number} start */
|
|
1081
|
-
const jsdocBefore = start => {
|
|
1082
|
-
const after =
|
|
1083
|
-
tokens.filter((/** @type {any} */ token) => token.end <= start).at(-1)
|
|
1084
|
-
?.end ?? 0;
|
|
1085
|
-
return comments
|
|
1086
|
-
.filter(
|
|
1087
|
-
(/** @type {any} */ comment) =>
|
|
1088
|
-
isJsdoc(comment) && comment.start >= after && comment.end <= start,
|
|
1089
|
-
)
|
|
1090
|
-
.at(-1);
|
|
1091
|
-
};
|
|
1092
|
-
/** @type {Array<{comment: any, tags: string[]}>} */
|
|
1093
|
-
const attached = [
|
|
1094
|
-
{comment: jsdocBefore(exportDefault.start), tags: ['type']},
|
|
1095
|
-
];
|
|
1096
|
-
for (
|
|
1097
|
-
let node = exportDefault.declaration;
|
|
1098
|
-
node.type === 'ParenthesizedExpression';
|
|
1099
|
-
node = node.expression
|
|
1100
|
-
) {
|
|
1101
|
-
attached.push({
|
|
1102
|
-
comment: jsdocBefore(node.start),
|
|
1103
|
-
tags: ['type', 'satisfies'],
|
|
1104
|
-
});
|
|
1105
|
-
}
|
|
1106
|
-
const aliases = jsdocAliases(comments, typeName);
|
|
1107
|
-
return attached.some(({comment, tags}) => {
|
|
1108
|
-
if (!comment) return false;
|
|
1109
|
-
const found = jsdocTags(comment.value);
|
|
1110
|
-
return tags.some(name => {
|
|
1111
|
-
const tag = found.find(candidate => candidate.name === name);
|
|
1112
|
-
const typed = tag && bracedType(tag.text);
|
|
1113
|
-
return typed != null && isDocType(typed.type, aliases, typeName);
|
|
1114
|
-
});
|
|
1115
|
-
});
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
611
|
/**
|
|
1119
612
|
* Whether a file is the module `astryx theme build` writes rather than a
|
|
1120
613
|
* theme source: plain JavaScript that carries the build's generated header
|
|
@@ -1238,21 +731,6 @@ function confirmedThemeSource(sourceDir, built, slug, files) {
|
|
|
1238
731
|
/** A module named for the theme it exports, such as `oceanTheme.ts`. */
|
|
1239
732
|
const THEME_SOURCE_RE = /^[$A-Z_a-z][$\w]*Theme\.(?:mjs|js|mts|ts|tsx|jsx)$/u;
|
|
1240
733
|
|
|
1241
|
-
/**
|
|
1242
|
-
* Whether an entry at any depth of a themes root is outside every theme: a dot
|
|
1243
|
-
* entry, or a name npm never publishes (npm-packlist's defaults).
|
|
1244
|
-
* @param {string} name
|
|
1245
|
-
*/
|
|
1246
|
-
export function isIgnoredThemeEntry(name) {
|
|
1247
|
-
return (
|
|
1248
|
-
name.startsWith('.') ||
|
|
1249
|
-
name === 'node_modules' ||
|
|
1250
|
-
name === 'CVS' ||
|
|
1251
|
-
name === 'npm-debug.log' ||
|
|
1252
|
-
name.endsWith('.orig')
|
|
1253
|
-
);
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
734
|
/**
|
|
1257
735
|
* Every entry below one folder of a theme root, without following symlinks
|
|
1258
736
|
* and without {@link isIgnoredThemeEntry} entries.
|
|
@@ -246,11 +246,11 @@ export async function compileDocs(project, {lang = null} = {}) {
|
|
|
246
246
|
...(input.root === 'tree' ? {loader: 'native'} : {}),
|
|
247
247
|
...(input.root === 'icon-definitions'
|
|
248
248
|
? {
|
|
249
|
-
label: `Icon
|
|
249
|
+
label: `Icon meaning ${path.basename(input.file)} in ${input.owner}`,
|
|
250
250
|
readStatic: () =>
|
|
251
251
|
readStaticDescriptorValue(
|
|
252
252
|
input.file,
|
|
253
|
-
`Icon
|
|
253
|
+
`Icon meaning ${path.basename(input.file)} in ${input.owner}`,
|
|
254
254
|
'IconDefinitionDoc',
|
|
255
255
|
{data: true},
|
|
256
256
|
),
|
|
@@ -208,7 +208,7 @@ export function importTemplateModule(file) {
|
|
|
208
208
|
});
|
|
209
209
|
return jsxJiti.import(first);
|
|
210
210
|
}
|
|
211
|
-
return importInTurn(first,
|
|
211
|
+
return importInTurn(first, pathToFileURL(first).href);
|
|
212
212
|
},
|
|
213
213
|
changed =>
|
|
214
214
|
changed.endsWith('.ts')
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* An environment folder setting, when it names an absolute path
|
|
5
|
+
* An environment folder setting, when it names an absolute path on the given
|
|
6
|
+
* platform. A `win32` setting is read with Windows path rules on any host, so
|
|
7
|
+
* the Windows folders can be tested anywhere.
|
|
6
8
|
* @param {string | undefined} value
|
|
9
|
+
* @param {NodeJS.Platform} [platform]
|
|
7
10
|
* @returns {string | null}
|
|
8
11
|
*/
|
|
9
|
-
export function absoluteDirSetting(value: string | undefined): string | null;
|
|
12
|
+
export function absoluteDirSetting(value: string | undefined, platform?: NodeJS.Platform): string | null;
|
|
10
13
|
/**
|
|
11
14
|
* @typedef {object} UserDirOptions
|
|
12
15
|
* @property {string} [home] the home folder; defaults to the current user's
|
|
@@ -21,12 +21,17 @@ import * as os from 'node:os';
|
|
|
21
21
|
import * as path from 'node:path';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* An environment folder setting, when it names an absolute path
|
|
24
|
+
* An environment folder setting, when it names an absolute path on the given
|
|
25
|
+
* platform. A `win32` setting is read with Windows path rules on any host, so
|
|
26
|
+
* the Windows folders can be tested anywhere.
|
|
25
27
|
* @param {string | undefined} value
|
|
28
|
+
* @param {NodeJS.Platform} [platform]
|
|
26
29
|
* @returns {string | null}
|
|
27
30
|
*/
|
|
28
|
-
export function absoluteDirSetting(value) {
|
|
29
|
-
|
|
31
|
+
export function absoluteDirSetting(value, platform = process.platform) {
|
|
32
|
+
const isAbsolute =
|
|
33
|
+
platform === 'win32' ? path.win32.isAbsolute : path.isAbsolute;
|
|
34
|
+
return typeof value === 'string' && value !== '' && isAbsolute(value)
|
|
30
35
|
? value
|
|
31
36
|
: null;
|
|
32
37
|
}
|
|
@@ -53,7 +58,8 @@ export function userCacheDir({
|
|
|
53
58
|
const join = platform === 'win32' ? path.win32.join : path.join;
|
|
54
59
|
if (platform === 'win32') {
|
|
55
60
|
return join(
|
|
56
|
-
absoluteDirSetting(env.LOCALAPPDATA) ??
|
|
61
|
+
absoluteDirSetting(env.LOCALAPPDATA, platform) ??
|
|
62
|
+
join(home, 'AppData', 'Local'),
|
|
57
63
|
'astryx',
|
|
58
64
|
'Cache',
|
|
59
65
|
);
|
|
@@ -80,7 +86,8 @@ export function userConfigDir({
|
|
|
80
86
|
const join = platform === 'win32' ? path.win32.join : path.join;
|
|
81
87
|
if (platform === 'win32') {
|
|
82
88
|
return join(
|
|
83
|
-
absoluteDirSetting(env.APPDATA) ??
|
|
89
|
+
absoluteDirSetting(env.APPDATA, platform) ??
|
|
90
|
+
join(home, 'AppData', 'Roaming'),
|
|
84
91
|
'astryx',
|
|
85
92
|
);
|
|
86
93
|
}
|