@astryxdesign/cli 0.7.16 → 0.7.17-canary.g16fe6a8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -86
- package/api/build/_adapter.d.mts +12 -0
- package/api/build/_adapter.mjs +51 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +199 -10
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.d.mts +4 -2
- package/api/build/kit/rank.mjs +125 -24
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +39 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +340 -43
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +48 -0
- package/api/build/kit/words.mjs +90 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +1 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +28 -2
- package/api/docs/_adapter.mjs +249 -10
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +27 -5
- package/api/doctor/_adapter.mjs +83 -10
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- package/api/icon/_records.mjs +2 -1
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/integration/_adapter.d.mts +44 -0
- package/api/integration/_adapter.mjs +77 -1
- package/api/integration/authoring-checks.mjs +6 -6
- package/api/integration/example-scope.d.mts +14 -0
- package/api/integration/example-scope.mjs +44 -0
- package/api/integration/example-scope.type.d.mts +29 -0
- package/api/integration/example-scope.type.mjs +25 -0
- package/api/integration/integrationExampleScope.doc.d.mts +11 -0
- package/api/integration/integrationExampleScope.doc.mjs +59 -0
- package/api/integration/validate-integration.mjs +19 -1
- package/api/integration/validate-integration.type.d.mts +9 -0
- package/api/integration/validate-integration.type.mjs +1 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.mjs +591 -195
- package/api/render/render.doc.mjs +11 -3
- package/api/render/render.type.d.mts +52 -0
- package/api/render/render.type.mjs +31 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- package/api/search/_candidate-score.mjs +51 -32
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +5 -0
- package/api/search/_lexical.mjs +8 -2
- package/api/search/_result.d.mts +11 -9
- package/api/search/_result.mjs +4 -4
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search-index.mjs +7 -1
- package/api/search/search.d.mts +1 -1
- package/api/theme/_adapter.mjs +12 -1
- package/api/theme/build/build.d.mts +132 -1
- package/api/theme/build/build.mjs +482 -157
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +10 -0
- package/api/theme/build/font-warning.d.mts +44 -5
- package/api/theme/build/font-warning.mjs +118 -10
- package/api/theme/build/icon-imports.mjs +51 -9
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +115 -4
- package/api/theme-edit/_adapter.mjs +997 -83
- package/api/theme-edit/_catalog.d.mts +20 -2
- package/api/theme-edit/_catalog.mjs +50 -10
- package/api/theme-edit/_check.d.mts +75 -24
- package/api/theme-edit/_check.mjs +2672 -422
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +54 -1
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +133 -15
- package/api/theme-edit/_context.d.mts +14 -3
- package/api/theme-edit/_context.mjs +225 -65
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +54 -4
- package/api/theme-edit/_edit.mjs +2966 -286
- package/api/theme-edit/_how-commands.d.mts +72 -1
- package/api/theme-edit/_how-commands.mjs +770 -9
- package/api/theme-edit/_how-question.d.mts +82 -5
- package/api/theme-edit/_how-question.mjs +6983 -701
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +237 -41
- package/api/theme-edit/_importers.d.mts +38 -0
- package/api/theme-edit/_importers.mjs +188 -0
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_name-rule.d.mts +11 -0
- package/api/theme-edit/_name-rule.mjs +12 -0
- package/api/theme-edit/_normal.d.mts +303 -0
- package/api/theme-edit/_normal.mjs +1517 -0
- package/api/theme-edit/_palette.d.mts +12 -0
- package/api/theme-edit/_palette.mjs +37 -4
- package/api/theme-edit/_part-words.d.mts +31 -0
- package/api/theme-edit/_part-words.mjs +126 -0
- package/api/theme-edit/_parts.d.mts +28 -2
- package/api/theme-edit/_parts.mjs +267 -31
- package/api/theme-edit/_preview-app.d.mts +7 -13
- package/api/theme-edit/_preview-app.mjs +814 -406
- package/api/theme-edit/_preview.d.mts +116 -16
- package/api/theme-edit/_preview.mjs +649 -152
- package/api/theme-edit/_project.d.mts +22 -1
- package/api/theme-edit/_project.mjs +83 -3
- package/api/theme-edit/_settings.d.mts +467 -42
- package/api/theme-edit/_settings.mjs +3527 -468
- package/api/theme-edit/_tables.d.mts +21 -0
- package/api/theme-edit/_tables.mjs +97 -3
- package/api/theme-edit/_vet.d.mts +31 -0
- package/api/theme-edit/_vet.mjs +114 -8
- package/api/theme-edit/theme-edit.type.d.mts +16 -2
- package/api/theme-edit/theme-edit.type.mjs +6 -3
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
- package/api/theme-edit/themeEditNew.doc.mjs +7 -4
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/run-codemod.mjs +87 -7
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/component-list.generated.json +1 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +44 -3
- package/assets/docs/tree/share-a-page.doc.mjs +157 -0
- package/assets/docs/tree/single-component.doc.mjs +4 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/authoring/example/example.doc.d.mts +12 -0
- package/authoring/example/example.doc.mjs +69 -0
- package/authoring/example/preview.d.mts +92 -0
- package/authoring/example/preview.mjs +994 -0
- package/authoring/example/type.ts +102 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +3 -1
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +22 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +32 -14
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +573 -119
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +718 -438
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/lib/json-shim.mjs +132 -24
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +56 -8
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/core-component-docs.d.mts +29 -0
- package/foundation/discovery/core-component-docs.mjs +83 -0
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +22 -8
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/package-exports.d.mts +10 -0
- package/foundation/discovery/package-exports.mjs +56 -3
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/stored-component-list.d.mts +43 -0
- package/foundation/discovery/stored-component-list.mjs +90 -0
- package/foundation/discovery/stored-search-catalog.d.mts +115 -0
- package/foundation/discovery/stored-search-catalog.mjs +297 -0
- package/foundation/discovery/stored-self-audit.d.mts +26 -10
- package/foundation/discovery/stored-self-audit.mjs +38 -18
- package/foundation/discovery/template-adapter.d.mts +53 -1
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +31 -4
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/discovery/theming-targets.d.mts +6 -5
- package/foundation/discovery/theming-targets.mjs +31 -47
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +38 -0
- package/foundation/fonts/font-stylesheet.mjs +141 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/exact-codec.d.mts +12 -2
- package/foundation/fs/exact-codec.mjs +23 -6
- package/foundation/fs/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +62 -4
- package/foundation/fs/gather-cache.mjs +517 -91
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -0
- package/foundation/fs/listing-cache.d.mts +7 -0
- package/foundation/fs/listing-cache.mjs +10 -0
- package/foundation/fs/module-loader.d.mts +24 -2
- package/foundation/fs/module-loader.mjs +94 -21
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +9 -0
- package/foundation/fs/read-record.mjs +19 -11
- package/foundation/fs/stop-cleanup.d.mts +12 -0
- package/foundation/fs/stop-cleanup.mjs +66 -0
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/example-code.d.mts +63 -0
- package/foundation/integrations/example-code.mjs +416 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/validate-contributions.mjs +17 -45
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +39 -7
- package/foundation/render/embedded-imports.mjs +66 -27
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +121 -13
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +185 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +34 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +35 -3
- package/foundation/render/render-page.mjs +641 -96
- package/foundation/render/source-block.d.mts +85 -6
- package/foundation/render/source-block.mjs +211 -20
- package/foundation/render/ts-paths.d.mts +69 -6
- package/foundation/render/ts-paths.mjs +326 -40
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/css-escape.d.mts +18 -0
- package/foundation/text/css-escape.mjs +35 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +18 -4
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +15 -1
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
|
@@ -158,6 +158,31 @@ export function listTemplates(): string[];
|
|
|
158
158
|
* @returns {string | null}
|
|
159
159
|
*/
|
|
160
160
|
export function findPageDocFile(dirPath: string): string | null;
|
|
161
|
+
/**
|
|
162
|
+
* The ids of Core's templates that `keep` accepts, read from file names: each
|
|
163
|
+
* page folder, and each block doc that has its same-stem source. Discovery
|
|
164
|
+
* gives Core's templates exactly these ids. Only a kept block's source is
|
|
165
|
+
* looked for.
|
|
166
|
+
* @param {(id: string) => boolean} [keep]
|
|
167
|
+
* @returns {string[]}
|
|
168
|
+
*/
|
|
169
|
+
export function coreTemplateIds(keep?: (id: string) => boolean): string[];
|
|
170
|
+
/**
|
|
171
|
+
* Which template files can give an id that folds to `wanted`, read from a
|
|
172
|
+
* kept summary of file names: `blocks` false means {@link coreTemplateIds}
|
|
173
|
+
* gives no block id that folds to it, and `listed` says whether any of the
|
|
174
|
+
* integrations ships a template doc whose id ({@link integrationTemplateIds})
|
|
175
|
+
* folds to it.
|
|
176
|
+
* @param {Array<{templates?: string}>} integrations
|
|
177
|
+
* @param {string} wanted a folded name
|
|
178
|
+
* @returns {{blocks: boolean, listed: boolean}}
|
|
179
|
+
*/
|
|
180
|
+
export function templateFilesNaming(integrations: Array<{
|
|
181
|
+
templates?: string;
|
|
182
|
+
}>, wanted: string): {
|
|
183
|
+
blocks: boolean;
|
|
184
|
+
listed: boolean;
|
|
185
|
+
};
|
|
161
186
|
/**
|
|
162
187
|
* Discover only the templates built into @astryxdesign/core. Integration
|
|
163
188
|
* authoring checks use this narrower surface so a broken project config or a
|
|
@@ -214,6 +239,33 @@ export function discoverAllWithErrors(cwd?: string): Promise<{
|
|
|
214
239
|
templates: DiscoveredTemplate[];
|
|
215
240
|
errors: Array<TemplateDiscoveryError | TemplateReplacementError>;
|
|
216
241
|
}>;
|
|
242
|
+
/**
|
|
243
|
+
* The id of each template doc an integration ships, valid or not, read from
|
|
244
|
+
* file names alone.
|
|
245
|
+
* @param {{templates?: string}} integration
|
|
246
|
+
* @returns {string[]}
|
|
247
|
+
*/
|
|
248
|
+
export function integrationTemplateIds(integration: {
|
|
249
|
+
templates?: string;
|
|
250
|
+
}): string[];
|
|
251
|
+
/**
|
|
252
|
+
* Whether any template doc an integration ships can declare a replacement,
|
|
253
|
+
* read from its text without loading it.
|
|
254
|
+
* @param {{templates?: string}} integration
|
|
255
|
+
* @returns {boolean}
|
|
256
|
+
*/
|
|
257
|
+
export function integrationMayReplaceTemplate(integration: {
|
|
258
|
+
templates?: string;
|
|
259
|
+
}): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Whether any template doc any of the integrations ships can declare a
|
|
262
|
+
* replacement, read from a kept summary of the docs' text.
|
|
263
|
+
* @param {Array<{templates?: string}>} integrations
|
|
264
|
+
* @returns {boolean}
|
|
265
|
+
*/
|
|
266
|
+
export function integrationsMayReplaceTemplate(integrations: Array<{
|
|
267
|
+
templates?: string;
|
|
268
|
+
}>): boolean;
|
|
217
269
|
/**
|
|
218
270
|
* Discover the templates contributed by a SINGLE integration. Same per-template
|
|
219
271
|
* rules as {@link discoverIntegrationTemplates} (same-stem source required,
|
|
@@ -376,7 +428,7 @@ export type TemplateDiscoveryError = {
|
|
|
376
428
|
template?: string | undefined;
|
|
377
429
|
message: string;
|
|
378
430
|
code?: string | undefined;
|
|
379
|
-
severity?: "
|
|
431
|
+
severity?: "warning" | "error" | undefined;
|
|
380
432
|
/**
|
|
381
433
|
* Core target whose replacement set is invalid
|
|
382
434
|
*/
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import * as fs from 'node:fs';
|
|
26
26
|
import * as path from 'node:path';
|
|
27
|
+
import {fileURLToPath} from 'node:url';
|
|
27
28
|
import {readDocView} from '../doc-compiler/read.mjs';
|
|
28
29
|
import {importDocModule} from '../doc-compiler/import.mjs';
|
|
29
30
|
import {readStore, storedKey} from '../doc-compiler/stored-docs.mjs';
|
|
@@ -40,9 +41,11 @@ import {
|
|
|
40
41
|
TEMPLATE_COMPONENTS_FILE,
|
|
41
42
|
} from './template-source-tree.mjs';
|
|
42
43
|
import {persistedGather} from '../fs/gather-cache.mjs';
|
|
44
|
+
import {hasNameLine, keptTreeSummary, nameLines} from '../fs/kept-tree.mjs';
|
|
45
|
+
import {foldEntryName} from './entry-name-files.mjs';
|
|
43
46
|
import {EXACT_CODEC} from '../fs/exact-codec.mjs';
|
|
44
|
-
import {hostedRun} from '../runtime/package-root.mjs';
|
|
45
47
|
import {babelParser} from '../runtime/lazy-dependencies.mjs';
|
|
48
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
46
49
|
|
|
47
50
|
/** Identity used for core (built-in) templates in package-scoped listings. */
|
|
48
51
|
const CORE_PACKAGE = CORE_PROVIDER_ID;
|
|
@@ -1251,6 +1254,99 @@ async function discoverBlocks() {
|
|
|
1251
1254
|
return blocks;
|
|
1252
1255
|
}
|
|
1253
1256
|
|
|
1257
|
+
/**
|
|
1258
|
+
* The ids of Core's templates that `keep` accepts, read from file names: each
|
|
1259
|
+
* page folder, and each block doc that has its same-stem source. Discovery
|
|
1260
|
+
* gives Core's templates exactly these ids. Only a kept block's source is
|
|
1261
|
+
* looked for.
|
|
1262
|
+
* @param {(id: string) => boolean} [keep]
|
|
1263
|
+
* @returns {string[]}
|
|
1264
|
+
*/
|
|
1265
|
+
export function coreTemplateIds(keep = () => true) {
|
|
1266
|
+
const ids = listTemplates().filter(keep);
|
|
1267
|
+
/** @param {string} dir */
|
|
1268
|
+
const walk = dir => {
|
|
1269
|
+
let entries;
|
|
1270
|
+
try {
|
|
1271
|
+
entries = fs.readdirSync(dir, {withFileTypes: true});
|
|
1272
|
+
} catch {
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
for (const entry of entries) {
|
|
1276
|
+
const full = path.join(dir, entry.name);
|
|
1277
|
+
if (entry.isDirectory()) {
|
|
1278
|
+
walk(full);
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
if (!TEMPLATE_SUFFIX_RE.test(entry.name)) continue;
|
|
1282
|
+
const suffix = matchedTemplateSuffix(entry.name);
|
|
1283
|
+
if (!suffix) continue;
|
|
1284
|
+
const basename = entry.name.slice(0, -suffix.length);
|
|
1285
|
+
if (keep(basename) && fs.existsSync(path.join(dir, basename + '.tsx'))) {
|
|
1286
|
+
ids.push(basename);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
walk(BLOCKS_DIR);
|
|
1291
|
+
return ids;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/** This module's own file: its code decides the kept summaries' shape. */
|
|
1295
|
+
const OWN_FILE = fileURLToPath(import.meta.url);
|
|
1296
|
+
|
|
1297
|
+
/** The file of foldEntryName, which decides the template-ids summary too. */
|
|
1298
|
+
const FOLD_FILE = fileURLToPath(
|
|
1299
|
+
new URL('./entry-name-files.mjs', import.meta.url),
|
|
1300
|
+
);
|
|
1301
|
+
|
|
1302
|
+
/**
|
|
1303
|
+
* Which template files can give an id that folds to `wanted`, read from a
|
|
1304
|
+
* kept summary of file names: `blocks` false means {@link coreTemplateIds}
|
|
1305
|
+
* gives no block id that folds to it, and `listed` says whether any of the
|
|
1306
|
+
* integrations ships a template doc whose id ({@link integrationTemplateIds})
|
|
1307
|
+
* folds to it.
|
|
1308
|
+
* @param {Array<{templates?: string}>} integrations
|
|
1309
|
+
* @param {string} wanted a folded name
|
|
1310
|
+
* @returns {{blocks: boolean, listed: boolean}}
|
|
1311
|
+
*/
|
|
1312
|
+
export function templateFilesNaming(integrations, wanted) {
|
|
1313
|
+
const roots = integrations.flatMap(integration =>
|
|
1314
|
+
typeof integration?.templates === 'string' && integration.templates !== ''
|
|
1315
|
+
? [integration.templates]
|
|
1316
|
+
: [],
|
|
1317
|
+
);
|
|
1318
|
+
/** @type {Array<string | string[]>} */
|
|
1319
|
+
const [blocks, ...listed] = keptTreeSummary(
|
|
1320
|
+
{
|
|
1321
|
+
kind: 'template-ids',
|
|
1322
|
+
roots: [BLOCKS_DIR, ...roots],
|
|
1323
|
+
code: [OWN_FILE, FOLD_FILE],
|
|
1324
|
+
},
|
|
1325
|
+
trees =>
|
|
1326
|
+
trees.map(({folders}, at) => {
|
|
1327
|
+
const folded = new Set();
|
|
1328
|
+
for (const {rel, entries} of folders) {
|
|
1329
|
+
for (const {name, isDir} of entries) {
|
|
1330
|
+
if (isDir) continue;
|
|
1331
|
+
const suffix = matchedTemplateSuffix(name);
|
|
1332
|
+
if (!suffix) continue;
|
|
1333
|
+
// Core's block ids are stems; an integration's are paths.
|
|
1334
|
+
const id =
|
|
1335
|
+
at === 0
|
|
1336
|
+
? name.slice(0, -suffix.length)
|
|
1337
|
+
: path.join(rel, name).slice(0, -suffix.length);
|
|
1338
|
+
folded.add(foldEntryName(id.split(path.sep).join('/')));
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
return nameLines(folded);
|
|
1342
|
+
}),
|
|
1343
|
+
);
|
|
1344
|
+
return {
|
|
1345
|
+
blocks: hasNameLine(blocks, wanted),
|
|
1346
|
+
listed: listed.some(ids => hasNameLine(ids, wanted)),
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1254
1350
|
/**
|
|
1255
1351
|
* Discover blocks from external packages that declare `astryx.blocks` in
|
|
1256
1352
|
* their package.json. Same shape as discoverBlocks() output.
|
|
@@ -1522,7 +1618,7 @@ export function applyTemplateReplacements(templates, declarationErrors = []) {
|
|
|
1522
1618
|
});
|
|
1523
1619
|
|
|
1524
1620
|
return {
|
|
1525
|
-
templates: effective.sort((a, b) => a.name
|
|
1621
|
+
templates: effective.sort((a, b) => compareText(a.name, b.name)),
|
|
1526
1622
|
errors,
|
|
1527
1623
|
};
|
|
1528
1624
|
}
|
|
@@ -1553,7 +1649,7 @@ async function discoverAllSources(cwd = process.cwd()) {
|
|
|
1553
1649
|
*/
|
|
1554
1650
|
export async function discoverAllUnresolved(cwd = process.cwd()) {
|
|
1555
1651
|
return (await discoverAllSources(cwd)).templates.sort((a, b) =>
|
|
1556
|
-
a.name
|
|
1652
|
+
compareText(a.name, b.name),
|
|
1557
1653
|
);
|
|
1558
1654
|
}
|
|
1559
1655
|
|
|
@@ -1580,15 +1676,10 @@ async function resolveAllSources(cwd = process.cwd()) {
|
|
|
1580
1676
|
// a later run with every one unchanged reads the records back.
|
|
1581
1677
|
return /** @type {Awaited<ReturnType<typeof resolveAllSourcesNow>>} */ (
|
|
1582
1678
|
await persistedGather(
|
|
1583
|
-
// The folder, and the copy of the CLI that answers
|
|
1584
|
-
// integrations
|
|
1585
|
-
//
|
|
1586
|
-
[
|
|
1587
|
-
'template-sources',
|
|
1588
|
-
realDir(cwd),
|
|
1589
|
-
CLI_ROOT,
|
|
1590
|
-
hostedRun()?.integrations ?? [],
|
|
1591
|
-
],
|
|
1679
|
+
// The folder, and the copy of the CLI that answers: outside a project
|
|
1680
|
+
// the integrations beside the answering copy load too. A host's inputs
|
|
1681
|
+
// are in every entry's key (gather-cache.mjs).
|
|
1682
|
+
['template-sources', realDir(cwd), CLI_ROOT],
|
|
1592
1683
|
() => resolveAllSourcesNow(cwd),
|
|
1593
1684
|
TEMPLATE_SOURCES_CODEC,
|
|
1594
1685
|
)
|
|
@@ -1681,6 +1772,79 @@ function findIntegrationDocFiles(root) {
|
|
|
1681
1772
|
return results;
|
|
1682
1773
|
}
|
|
1683
1774
|
|
|
1775
|
+
/**
|
|
1776
|
+
* Code that lets a template doc declare a replacement: the field itself, or an
|
|
1777
|
+
* import, a require or a spread that can bring it in. Comments do not count.
|
|
1778
|
+
*/
|
|
1779
|
+
const MAY_REPLACE_RE =
|
|
1780
|
+
/\breplaces\b|^\s*import\b|\bimport\s*\(|\brequire\s*\(|\.\.\.\s*[A-Za-z_$]/m;
|
|
1781
|
+
|
|
1782
|
+
/**
|
|
1783
|
+
* The id of each template doc an integration ships, valid or not, read from
|
|
1784
|
+
* file names alone.
|
|
1785
|
+
* @param {{templates?: string}} integration
|
|
1786
|
+
* @returns {string[]}
|
|
1787
|
+
*/
|
|
1788
|
+
export function integrationTemplateIds(integration) {
|
|
1789
|
+
const root = integration?.templates;
|
|
1790
|
+
if (!root) return [];
|
|
1791
|
+
return findIntegrationDocFiles(root).flatMap(docPath => {
|
|
1792
|
+
const suffix = matchedTemplateSuffix(docPath);
|
|
1793
|
+
if (!suffix) return [];
|
|
1794
|
+
return [
|
|
1795
|
+
path
|
|
1796
|
+
.relative(root, docPath)
|
|
1797
|
+
.slice(0, -suffix.length)
|
|
1798
|
+
.split(path.sep)
|
|
1799
|
+
.join('/'),
|
|
1800
|
+
];
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* Whether any template doc an integration ships can declare a replacement,
|
|
1806
|
+
* read from its text without loading it.
|
|
1807
|
+
* @param {{templates?: string}} integration
|
|
1808
|
+
* @returns {boolean}
|
|
1809
|
+
*/
|
|
1810
|
+
export function integrationMayReplaceTemplate(integration) {
|
|
1811
|
+
return integrationsMayReplaceTemplate([integration]);
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
/**
|
|
1815
|
+
* Whether any template doc any of the integrations ships can declare a
|
|
1816
|
+
* replacement, read from a kept summary of the docs' text.
|
|
1817
|
+
* @param {Array<{templates?: string}>} integrations
|
|
1818
|
+
* @returns {boolean}
|
|
1819
|
+
*/
|
|
1820
|
+
export function integrationsMayReplaceTemplate(integrations) {
|
|
1821
|
+
const roots = integrations.flatMap(integration =>
|
|
1822
|
+
typeof integration?.templates === 'string' && integration.templates !== ''
|
|
1823
|
+
? [integration.templates]
|
|
1824
|
+
: [],
|
|
1825
|
+
);
|
|
1826
|
+
if (roots.length === 0) return false;
|
|
1827
|
+
return keptTreeSummary(
|
|
1828
|
+
{kind: 'integration-template-replaces', roots, code: [OWN_FILE]},
|
|
1829
|
+
trees =>
|
|
1830
|
+
trees.some(({folders, readText}) =>
|
|
1831
|
+
folders.some(({rel, entries}) =>
|
|
1832
|
+
entries.some(({name, isDir}) => {
|
|
1833
|
+
if (isDir || !matchedTemplateSuffix(name)) return false;
|
|
1834
|
+
try {
|
|
1835
|
+
const code = readText(rel === '' ? name : path.join(rel, name))
|
|
1836
|
+
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
1837
|
+
.replace(/^\s*\/\/.*$/gm, '');
|
|
1838
|
+
return MAY_REPLACE_RE.test(code);
|
|
1839
|
+
} catch {
|
|
1840
|
+
return true;
|
|
1841
|
+
}
|
|
1842
|
+
}),
|
|
1843
|
+
),
|
|
1844
|
+
),
|
|
1845
|
+
);
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1684
1848
|
/**
|
|
1685
1849
|
* Discover templates contributed by configured integrations.
|
|
1686
1850
|
*
|
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
import {definitionsByIcon, iconUseCommand} from './icon-set-discovery.mjs';
|
|
62
62
|
import {astryxDefinitionsByName} from './icon-definition-discovery.mjs';
|
|
63
63
|
import {generatedOrigins} from './icon-set-writer.mjs';
|
|
64
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
64
65
|
|
|
65
66
|
/** @typedef {import('./icon-set-discovery.mjs').DiscoveredIconSet} DiscoveredIconSet */
|
|
66
67
|
/** @typedef {import('./icon-set-discovery.mjs').IconSetChoice} IconSetChoice */
|
|
@@ -665,7 +666,7 @@ export function sharedTemplateMeanings(declared) {
|
|
|
665
666
|
return [...byDefinition]
|
|
666
667
|
.filter(([, icons]) => icons.size > 1)
|
|
667
668
|
.map(([definition, icons]) => ({definition, keys: [...icons.values()]}))
|
|
668
|
-
.sort((a, b) => a.definition
|
|
669
|
+
.sort((a, b) => compareText(a.definition, b.definition));
|
|
669
670
|
}
|
|
670
671
|
|
|
671
672
|
/**
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import * as fs from 'node:fs';
|
|
20
20
|
import * as path from 'node:path';
|
|
21
|
+
import {createHash} from 'node:crypto';
|
|
21
22
|
import {lowerDoc} from '../doc-compiler/compile.mjs';
|
|
22
23
|
import {packageSource} from '../doc-compiler/source.mjs';
|
|
23
24
|
import {CLI_ROOT, realDir} from '../fs/paths.mjs';
|
|
@@ -34,6 +35,7 @@ import {
|
|
|
34
35
|
storedKey,
|
|
35
36
|
STORED_DOCS_FILE,
|
|
36
37
|
} from '../doc-compiler/stored-docs.mjs';
|
|
38
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
37
39
|
|
|
38
40
|
export const BUNDLED_THEME_PACKAGE = '@astryxdesign/cli';
|
|
39
41
|
export const THEMES_DIR = path.join(CLI_ROOT, 'assets', 'templates', 'themes');
|
|
@@ -156,8 +158,33 @@ class ThemeRuntimeExportError extends Error {}
|
|
|
156
158
|
*/
|
|
157
159
|
function moduleSpecifiers(file, jscodeshift, {withRequire = false} = {}) {
|
|
158
160
|
const parser = /\.(?:ts|tsx|mts|cts)$/u.test(file) ? 'tsx' : 'babel';
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
+
const text = fs.readFileSync(file, 'utf-8');
|
|
162
|
+
// A module's specifiers follow from its text: one parse per text read
|
|
163
|
+
// (a command reads the same built theme module several times).
|
|
164
|
+
const key = `${parser}\0${withRequire}\0${createHash('sha256').update(text).digest('hex')}`;
|
|
165
|
+
const known = SPECIFIERS.get(key);
|
|
166
|
+
if (known) return [...known];
|
|
167
|
+
const found = parsedSpecifiers(text, jscodeshift.withParser(parser), {
|
|
168
|
+
withRequire,
|
|
169
|
+
});
|
|
170
|
+
if (SPECIFIERS.size >= 256) SPECIFIERS.clear();
|
|
171
|
+
SPECIFIERS.set(key, found);
|
|
172
|
+
return [...found];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** The specifiers each module text read names, by parser, mode and text. @type {Map<string, string[]>} */
|
|
176
|
+
const SPECIFIERS = new Map();
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The module specifiers a module's text names (imports, re-exports,
|
|
180
|
+
* import() calls, and with `withRequire` require() calls).
|
|
181
|
+
* @param {string} text
|
|
182
|
+
* @param {any} j jscodeshift with its parser
|
|
183
|
+
* @param {{withRequire: boolean}} options
|
|
184
|
+
* @returns {string[]}
|
|
185
|
+
*/
|
|
186
|
+
function parsedSpecifiers(text, j, {withRequire}) {
|
|
187
|
+
const root = j(text);
|
|
161
188
|
/** @type {string[]} */
|
|
162
189
|
const specifiers = [];
|
|
163
190
|
root.find(j.ImportDeclaration).forEach((/** @type {any} */ importPath) => {
|
|
@@ -1328,7 +1355,7 @@ export function discoverUnmigratedThemeCopies(
|
|
|
1328
1355
|
.filter(entry => entry.isDirectory() && !isIgnoredThemeEntry(entry.name))
|
|
1329
1356
|
.map(entry => unmigratedThemeCopy(path.join(root, entry.name)))
|
|
1330
1357
|
.filter(copy => copy !== null)
|
|
1331
|
-
.sort((a, b) => a.slug
|
|
1358
|
+
.sort((a, b) => compareText(a.slug, b.slug));
|
|
1332
1359
|
}
|
|
1333
1360
|
|
|
1334
1361
|
/** @param {string[]} files */
|
|
@@ -1434,7 +1461,7 @@ export function discoverThemeDirectory(
|
|
|
1434
1461
|
}
|
|
1435
1462
|
const directories = rootEntries
|
|
1436
1463
|
.filter(entry => entry.isDirectory())
|
|
1437
|
-
.sort((a, b) => a.name
|
|
1464
|
+
.sort((a, b) => compareText(a.name, b.name));
|
|
1438
1465
|
|
|
1439
1466
|
for (const directory of directories) {
|
|
1440
1467
|
const slug = directory.name;
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* `{mode}` for a built theme module that exports one color mode
|
|
6
|
+
* (`export const colorModes = ["light"];`, which `theme build` writes beside
|
|
7
|
+
* the theme export), read without running it; nothing for a module with
|
|
8
|
+
* both modes, which exports none.
|
|
9
|
+
* @param {string | null | undefined} moduleFile
|
|
10
|
+
* @param {string} [exportName] the theme's export: a module that re-exports
|
|
11
|
+
* only the theme by name (`export {oceanTheme} from './ocean.js'`) is
|
|
12
|
+
* read where the theme is declared
|
|
13
|
+
* @returns {{mode?: 'light' | 'dark'}}
|
|
14
|
+
*/
|
|
15
|
+
export function builtColorMode(moduleFile: string | null | undefined, exportName?: string): {
|
|
16
|
+
mode?: "light" | "dark";
|
|
17
|
+
};
|
|
4
18
|
/**
|
|
5
19
|
* Resolve a discovered theme to app imports.
|
|
6
20
|
* @param {import('./theme-discovery.mjs').DiscoveredTheme} theme
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import * as fs from 'node:fs';
|
|
16
16
|
import * as path from 'node:path';
|
|
17
17
|
import {findInstalledPackage} from '../fs/paths.mjs';
|
|
18
|
-
import {moduleExportsName} from './module-exports.mjs';
|
|
18
|
+
import {moduleExportSource, moduleExportsName} from './module-exports.mjs';
|
|
19
19
|
import {inspectPackageExport} from './package-exports.mjs';
|
|
20
20
|
import {themeImportPackage} from './theme-discovery.mjs';
|
|
21
21
|
import {isLocalThemeOwner, projectPath} from '../config/theme-state.mjs';
|
|
@@ -101,6 +101,7 @@ function resolveLocalTheme(theme, cwd) {
|
|
|
101
101
|
stylesheetFile,
|
|
102
102
|
...(fs.existsSync(fontStylesheetFile) ? {fontStylesheetFile} : {}),
|
|
103
103
|
source: /** @type {const} */ ('local'),
|
|
104
|
+
...builtColorMode(moduleFile, theme.exportName),
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
107
|
|
|
@@ -228,9 +229,50 @@ function resolvePackageTheme(theme, cwd, ownerThemeCount) {
|
|
|
228
229
|
/** @type {any} */ (theme).source === 'bundled' || theme.bundled
|
|
229
230
|
? /** @type {const} */ ('bundled')
|
|
230
231
|
: /** @type {const} */ ('package'),
|
|
232
|
+
...builtColorMode(selected.module.target, theme.exportName),
|
|
231
233
|
};
|
|
232
234
|
}
|
|
233
235
|
|
|
236
|
+
/**
|
|
237
|
+
* `{mode}` for a built theme module that exports one color mode
|
|
238
|
+
* (`export const colorModes = ["light"];`, which `theme build` writes beside
|
|
239
|
+
* the theme export), read without running it; nothing for a module with
|
|
240
|
+
* both modes, which exports none.
|
|
241
|
+
* @param {string | null | undefined} moduleFile
|
|
242
|
+
* @param {string} [exportName] the theme's export: a module that re-exports
|
|
243
|
+
* only the theme by name (`export {oceanTheme} from './ocean.js'`) is
|
|
244
|
+
* read where the theme is declared
|
|
245
|
+
* @returns {{mode?: 'light' | 'dark'}}
|
|
246
|
+
*/
|
|
247
|
+
export function builtColorMode(moduleFile, exportName) {
|
|
248
|
+
if (!moduleFile) return {};
|
|
249
|
+
// The file that declares it: the module, or the built module it re-exports
|
|
250
|
+
// (`export * from './ocean.js'`); else the built module that declares the
|
|
251
|
+
// theme the module re-exports by name.
|
|
252
|
+
const declaring =
|
|
253
|
+
moduleExportSource(moduleFile, 'colorModes') ??
|
|
254
|
+
(exportName
|
|
255
|
+
? (() => {
|
|
256
|
+
const theme = moduleExportSource(moduleFile, exportName);
|
|
257
|
+
return theme && theme !== moduleFile
|
|
258
|
+
? moduleExportSource(theme, 'colorModes')
|
|
259
|
+
: null;
|
|
260
|
+
})()
|
|
261
|
+
: null);
|
|
262
|
+
if (!declaring) return {};
|
|
263
|
+
let text;
|
|
264
|
+
try {
|
|
265
|
+
text = fs.readFileSync(declaring, 'utf8');
|
|
266
|
+
} catch {
|
|
267
|
+
return {};
|
|
268
|
+
}
|
|
269
|
+
const m =
|
|
270
|
+
/^export const colorModes = \[\s*["'](light|dark)["']\s*\];?\s*$/m.exec(
|
|
271
|
+
text,
|
|
272
|
+
);
|
|
273
|
+
return m ? {mode: /** @type {'light' | 'dark'} */ (m[1])} : {};
|
|
274
|
+
}
|
|
275
|
+
|
|
234
276
|
/**
|
|
235
277
|
* Resolve a discovered theme to app imports.
|
|
236
278
|
* @param {import('./theme-discovery.mjs').DiscoveredTheme} theme
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
* Unreadable docs are skipped rather than fatal — a single malformed doc must
|
|
12
12
|
* not take out theme validation or the listing.
|
|
13
13
|
*
|
|
14
|
-
* The scan
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* The scan reads every component doc under `src` (core-component-docs.mjs,
|
|
15
|
+
* which theme build's other views of Core's docs share). A process scans each
|
|
16
|
+
* Core once. It reuses that scan while every folder and doc it read is
|
|
17
|
+
* unchanged, as the docs and search catalogs do. A `src` reached through a
|
|
18
|
+
* symlink, as a project's node_modules reaches Core, shares the scan of its
|
|
19
|
+
* real path. Each call gets its own copy of the rows.
|
|
19
20
|
*
|
|
20
21
|
* @param {string} coreSrc - absolute path to `<core>/src`
|
|
21
22
|
* @returns {Promise<ThemingTarget[]>}
|
|
@@ -20,6 +20,8 @@ import * as fs from 'node:fs';
|
|
|
20
20
|
import * as path from 'node:path';
|
|
21
21
|
import {reusedWhileUnchanged} from '../fs/read-record.mjs';
|
|
22
22
|
import {loadComponentDoc} from './component-loader.mjs';
|
|
23
|
+
import {coreComponentDocs} from './core-component-docs.mjs';
|
|
24
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
23
25
|
|
|
24
26
|
const SKIP_DIRS = new Set(['node_modules', '__tests__']);
|
|
25
27
|
|
|
@@ -56,11 +58,12 @@ function targetKey(className) {
|
|
|
56
58
|
* Unreadable docs are skipped rather than fatal — a single malformed doc must
|
|
57
59
|
* not take out theme validation or the listing.
|
|
58
60
|
*
|
|
59
|
-
* The scan
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
61
|
+
* The scan reads every component doc under `src` (core-component-docs.mjs,
|
|
62
|
+
* which theme build's other views of Core's docs share). A process scans each
|
|
63
|
+
* Core once. It reuses that scan while every folder and doc it read is
|
|
64
|
+
* unchanged, as the docs and search catalogs do. A `src` reached through a
|
|
65
|
+
* symlink, as a project's node_modules reaches Core, shares the scan of its
|
|
66
|
+
* real path. Each call gets its own copy of the rows.
|
|
64
67
|
*
|
|
65
68
|
* @param {string} coreSrc - absolute path to `<core>/src`
|
|
66
69
|
* @returns {Promise<ThemingTarget[]>}
|
|
@@ -95,54 +98,35 @@ async function scanThemingTargets(coreSrc) {
|
|
|
95
98
|
/** @type {Array<ThemingTarget & {parent: string|null}>} */
|
|
96
99
|
const targets = [];
|
|
97
100
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
if (!entry.name.endsWith('.doc.mjs')) continue;
|
|
108
|
-
|
|
109
|
-
/** @type {any} */
|
|
110
|
-
let doc;
|
|
111
|
-
try {
|
|
112
|
-
doc = await loadComponentDoc(full);
|
|
113
|
-
} catch {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const component =
|
|
118
|
-
typeof doc?.name === 'string' && doc.name
|
|
119
|
-
? doc.name
|
|
120
|
-
: path.basename(path.dirname(full));
|
|
101
|
+
for (const read of await coreComponentDocs(coreSrc)) {
|
|
102
|
+
if ('error' in read) continue;
|
|
103
|
+
const {file, doc} = read;
|
|
104
|
+
const component =
|
|
105
|
+
typeof doc?.name === 'string' && doc.name
|
|
106
|
+
? doc.name
|
|
107
|
+
: path.basename(path.dirname(file));
|
|
121
108
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
109
|
+
for (const target of doc?.theming?.targets || []) {
|
|
110
|
+
const className = target?.className;
|
|
111
|
+
if (typeof className !== 'string') continue;
|
|
112
|
+
const key = targetKey(className);
|
|
113
|
+
if (!key) continue;
|
|
114
|
+
targets.push({
|
|
115
|
+
key,
|
|
116
|
+
className,
|
|
117
|
+
component,
|
|
118
|
+
parent:
|
|
119
|
+
typeof doc?.subComponentOf === 'string' ? doc.subComponentOf : null,
|
|
120
|
+
props: stringList(target.visualProps),
|
|
121
|
+
states: stringList(target.states),
|
|
122
|
+
});
|
|
137
123
|
}
|
|
138
124
|
}
|
|
139
125
|
|
|
140
|
-
await scan(coreSrc);
|
|
141
|
-
|
|
142
126
|
const canonical = canonicalizeParentTargets(targets);
|
|
143
127
|
canonical.sort(
|
|
144
128
|
(a, b) =>
|
|
145
|
-
a.key
|
|
129
|
+
compareText(a.key, b.key) || compareText(a.component, b.component),
|
|
146
130
|
);
|
|
147
131
|
return canonical;
|
|
148
132
|
}
|
|
@@ -254,7 +238,7 @@ export async function collectThemingVars(coreSrc) {
|
|
|
254
238
|
|
|
255
239
|
await scan(coreSrc);
|
|
256
240
|
|
|
257
|
-
return [...vars.values()].sort((a, b) => a.name
|
|
241
|
+
return [...vars.values()].sort((a, b) => compareText(a.name, b.name));
|
|
258
242
|
}
|
|
259
243
|
|
|
260
244
|
/**
|
|
@@ -35,7 +35,12 @@ import {
|
|
|
35
35
|
readInTurn,
|
|
36
36
|
} from '../fs/module-loader.mjs';
|
|
37
37
|
import {fileStamp, recordContentRead} from '../fs/read-record.mjs';
|
|
38
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
noteStoredExport,
|
|
40
|
+
readStore,
|
|
41
|
+
storedKey,
|
|
42
|
+
STORED_DOCS_FILE,
|
|
43
|
+
} from './stored-docs.mjs';
|
|
39
44
|
|
|
40
45
|
const requireFromHere = createRequire(import.meta.url);
|
|
41
46
|
|
|
@@ -132,6 +137,7 @@ function storedModule(file) {
|
|
|
132
137
|
enumerable: true,
|
|
133
138
|
writable: true,
|
|
134
139
|
});
|
|
140
|
+
noteStoredExport(exports[name], key, name);
|
|
135
141
|
}
|
|
136
142
|
Object.defineProperty(module, Symbol.toStringTag, {value: 'Module'});
|
|
137
143
|
Object.preventExtensions(module);
|
|
@@ -27,6 +27,7 @@ import {astryxIconDefinitions} from '../discovery/icon-definition-discovery.mjs'
|
|
|
27
27
|
import {CLI_ROOT, findCoreDir} from '../fs/paths.mjs';
|
|
28
28
|
import {packageSource} from './source.mjs';
|
|
29
29
|
import {treeDocFiles} from './tree.mjs';
|
|
30
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
30
31
|
|
|
31
32
|
export {packageSource};
|
|
32
33
|
|
|
@@ -203,7 +204,7 @@ function unlistedCoreComponentDocs(coreDir, list) {
|
|
|
203
204
|
const walk = dir => {
|
|
204
205
|
const entries = fs
|
|
205
206
|
.readdirSync(dir, {withFileTypes: true})
|
|
206
|
-
.sort((a, b) => a.name
|
|
207
|
+
.sort((a, b) => compareText(a.name, b.name));
|
|
207
208
|
for (const entry of entries) {
|
|
208
209
|
const full = path.join(dir, entry.name);
|
|
209
210
|
if (entry.isDirectory()) {
|
|
@@ -235,7 +236,7 @@ export function selfDocFiles() {
|
|
|
235
236
|
const walk = dir => {
|
|
236
237
|
const entries = fs
|
|
237
238
|
.readdirSync(dir, {withFileTypes: true})
|
|
238
|
-
.sort((a, b) => a.name
|
|
239
|
+
.sort((a, b) => compareText(a.name, b.name));
|
|
239
240
|
for (const entry of entries) {
|
|
240
241
|
const full = path.join(dir, entry.name);
|
|
241
242
|
if (entry.isDirectory()) {
|