@astryxdesign/cli 0.7.16 → 0.7.17-canary.g335a172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -86
- package/api/build/_adapter.d.mts +12 -0
- package/api/build/_adapter.mjs +51 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +199 -10
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.mjs +69 -16
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +16 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +251 -35
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +48 -0
- package/api/build/kit/words.mjs +90 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +1 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +26 -2
- package/api/docs/_adapter.mjs +219 -6
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +27 -5
- package/api/doctor/_adapter.mjs +83 -10
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- package/api/icon/_records.mjs +2 -1
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/integration/_adapter.d.mts +44 -0
- package/api/integration/_adapter.mjs +77 -1
- package/api/integration/authoring-checks.mjs +6 -6
- package/api/integration/example-scope.d.mts +14 -0
- package/api/integration/example-scope.mjs +44 -0
- package/api/integration/example-scope.type.d.mts +29 -0
- package/api/integration/example-scope.type.mjs +25 -0
- package/api/integration/integrationExampleScope.doc.d.mts +11 -0
- package/api/integration/integrationExampleScope.doc.mjs +59 -0
- package/api/integration/validate-integration.mjs +19 -1
- package/api/integration/validate-integration.type.d.mts +9 -0
- package/api/integration/validate-integration.type.mjs +1 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.mjs +591 -195
- package/api/render/render.doc.mjs +11 -3
- package/api/render/render.type.d.mts +52 -0
- package/api/render/render.type.mjs +31 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_candidate-score.mjs +51 -32
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +5 -0
- package/api/search/_lexical.mjs +8 -2
- package/api/search/_result.d.mts +11 -9
- package/api/search/_result.mjs +4 -4
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search-index.mjs +7 -1
- package/api/search/search.d.mts +1 -1
- package/api/theme/_adapter.mjs +12 -1
- package/api/theme/build/build.d.mts +60 -0
- package/api/theme/build/build.mjs +210 -54
- package/api/theme/build/font-warning.d.mts +8 -0
- package/api/theme/build/font-warning.mjs +19 -0
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +55 -0
- package/api/theme-edit/_adapter.mjs +673 -42
- package/api/theme-edit/_check.d.mts +28 -22
- package/api/theme-edit/_check.mjs +1858 -312
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +49 -1
- package/api/theme-edit/_compiler.mjs +9 -0
- package/api/theme-edit/_context.mjs +60 -3
- package/api/theme-edit/_css.mjs +21 -1
- package/api/theme-edit/_edit.d.mts +22 -0
- package/api/theme-edit/_edit.mjs +1533 -92
- package/api/theme-edit/_how-commands.d.mts +57 -0
- package/api/theme-edit/_how-commands.mjs +587 -1
- package/api/theme-edit/_how-question.d.mts +78 -0
- package/api/theme-edit/_how-question.mjs +4716 -235
- package/api/theme-edit/_how.mjs +134 -8
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_normal.d.mts +219 -0
- package/api/theme-edit/_normal.mjs +1041 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +103 -2
- package/api/theme-edit/_playwright-picture.d.mts +4 -0
- package/api/theme-edit/_playwright-picture.mjs +34 -0
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +394 -74
- package/api/theme-edit/_preview.d.mts +69 -8
- package/api/theme-edit/_preview.mjs +531 -108
- package/api/theme-edit/_settings.d.mts +243 -6
- package/api/theme-edit/_settings.mjs +2415 -147
- package/api/theme-edit/_tables.d.mts +6 -0
- package/api/theme-edit/_tables.mjs +44 -1
- package/api/theme-edit/_vet.d.mts +18 -0
- package/api/theme-edit/_vet.mjs +32 -0
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -1
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/run-codemod.mjs +87 -7
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/component-list.generated.json +1 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +44 -3
- package/assets/docs/tree/single-component.doc.mjs +4 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/authoring/example/example.doc.d.mts +12 -0
- package/authoring/example/example.doc.mjs +69 -0
- package/authoring/example/preview.d.mts +92 -0
- package/authoring/example/preview.mjs +994 -0
- package/authoring/example/type.ts +102 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +3 -1
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +22 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +32 -14
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +145 -16
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +183 -6
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/lib/json-shim.mjs +77 -21
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +56 -8
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +22 -8
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/package-exports.d.mts +10 -0
- package/foundation/discovery/package-exports.mjs +56 -3
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/stored-component-list.d.mts +43 -0
- package/foundation/discovery/stored-component-list.mjs +90 -0
- package/foundation/discovery/stored-self-audit.d.mts +26 -10
- package/foundation/discovery/stored-self-audit.mjs +38 -18
- package/foundation/discovery/template-adapter.d.mts +52 -0
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +3 -2
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/discovery/theming-targets.mjs +3 -2
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +31 -0
- package/foundation/fonts/font-stylesheet.mjs +115 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +25 -4
- package/foundation/fs/gather-cache.mjs +164 -55
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -0
- package/foundation/fs/listing-cache.d.mts +7 -0
- package/foundation/fs/listing-cache.mjs +10 -0
- package/foundation/fs/module-loader.d.mts +24 -2
- package/foundation/fs/module-loader.mjs +94 -21
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/example-code.d.mts +63 -0
- package/foundation/integrations/example-code.mjs +416 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/validate-contributions.mjs +17 -45
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +39 -7
- package/foundation/render/embedded-imports.mjs +66 -27
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +121 -13
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +35 -3
- package/foundation/render/render-page.mjs +316 -42
- package/foundation/render/source-block.d.mts +85 -6
- package/foundation/render/source-block.mjs +211 -20
- package/foundation/render/ts-paths.d.mts +69 -6
- package/foundation/render/ts-paths.mjs +326 -40
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +18 -4
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +15 -1
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Core's component list and each listed component's import, as worked
|
|
5
|
+
* out at publish for the Core the CLI was published with
|
|
6
|
+
* (scripts/generate-component-list.mjs), with the state of every file and
|
|
7
|
+
* folder that work read.
|
|
8
|
+
*
|
|
9
|
+
* @input `storedComponentList(coreDir)`.
|
|
10
|
+
* @output The stored groups and imports while every recorded file and folder
|
|
11
|
+
* under `coreDir` is in its recorded state, else null: any edit, addition or
|
|
12
|
+
* removal, a patched install or another Core version reads Core live.
|
|
13
|
+
* @position Read by component discovery (component-discovery.mjs): the list
|
|
14
|
+
* checks the store, and an import lookup in the same operation reuses that
|
|
15
|
+
* check.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
import {CLI_ROOT} from '../fs/paths.mjs';
|
|
20
|
+
import {onceComputed, oncePerListing} from '../fs/listing-cache.mjs';
|
|
21
|
+
import {readStore} from '../doc-compiler/stored-docs.mjs';
|
|
22
|
+
import {inputsUnchanged} from './stored-self-audit.mjs';
|
|
23
|
+
|
|
24
|
+
/** Where the stored component list is written at `prepack`. */
|
|
25
|
+
export const COMPONENT_LIST_FILE = path.join(
|
|
26
|
+
CLI_ROOT,
|
|
27
|
+
'assets',
|
|
28
|
+
'component-list.generated.json',
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Folder entries an install adds beside Core's own files: only `node_modules`.
|
|
33
|
+
* Every other name counts, so a file added anywhere the list reads misses the
|
|
34
|
+
* store.
|
|
35
|
+
*/
|
|
36
|
+
export const CORE_FOLDER_SKIP = /^node_modules$/;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {object} StoredComponentList
|
|
40
|
+
* @property {Record<string, string[]>} groups - discoverComponents' answer.
|
|
41
|
+
* @property {Record<string, string>} imports - resolveImportPath's answer
|
|
42
|
+
* for each listed component.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The stored list for the Core in `coreDir`, while every file and folder its
|
|
47
|
+
* work read is unchanged; checked once per operation.
|
|
48
|
+
* @param {string} coreDir
|
|
49
|
+
* @returns {StoredComponentList | null}
|
|
50
|
+
*/
|
|
51
|
+
export function storedComponentList(coreDir) {
|
|
52
|
+
return oncePerListing(storeKey(coreDir), () => {
|
|
53
|
+
/** @type {any} */
|
|
54
|
+
let entry;
|
|
55
|
+
try {
|
|
56
|
+
entry = readStore(COMPONENT_LIST_FILE).get('core');
|
|
57
|
+
} catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (
|
|
61
|
+
!entry ||
|
|
62
|
+
typeof entry.inputs !== 'object' ||
|
|
63
|
+
typeof entry.groups !== 'object' ||
|
|
64
|
+
typeof entry.imports !== 'object'
|
|
65
|
+
) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return inputsUnchanged(coreDir, entry.inputs, CORE_FOLDER_SKIP)
|
|
69
|
+
? {groups: entry.groups, imports: entry.imports}
|
|
70
|
+
: null;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The stored list for `coreDir` when this operation has already checked it,
|
|
76
|
+
* without checking it: one lookup never pays for the check, which costs more
|
|
77
|
+
* than the lookup.
|
|
78
|
+
* @param {string} coreDir
|
|
79
|
+
* @returns {StoredComponentList | null}
|
|
80
|
+
*/
|
|
81
|
+
export function checkedComponentList(coreDir) {
|
|
82
|
+
return (
|
|
83
|
+
/** @type {StoredComponentList | null | undefined} */ (
|
|
84
|
+
onceComputed(storeKey(coreDir))
|
|
85
|
+
) ?? null
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** @param {string} coreDir */
|
|
90
|
+
const storeKey = coreDir => `stored-component-list\0${coreDir}`;
|
|
@@ -4,22 +4,30 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* A file's or folder's state as an audit read it: a file by its content
|
|
6
6
|
* (package.json by its packer-stable fields), a folder by the names it holds
|
|
7
|
-
* (but PACKING_NAMES), `-` when
|
|
7
|
+
* (but the names `skip` matches: PACKING_NAMES unless given), `-` when
|
|
8
|
+
* absent.
|
|
8
9
|
* @param {string} file
|
|
10
|
+
* @param {RegExp} [skip] - Folder entries a packer or installer adds or drops.
|
|
9
11
|
* @returns {string}
|
|
10
12
|
*/
|
|
11
|
-
export function inputState(file: string): string;
|
|
13
|
+
export function inputState(file: string, skip?: RegExp): string;
|
|
12
14
|
/**
|
|
13
|
-
* The inputs
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* are not inputs.
|
|
19
|
-
* @param {Iterable<string>} files every path the
|
|
15
|
+
* The inputs a stored answer's work read, by path under `root` (`.` for
|
|
16
|
+
* `root` itself), with their state. Code in a node_modules folder under
|
|
17
|
+
* `root` is the package's dependencies, not its own files. Paths outside
|
|
18
|
+
* `root` are where the work runs (the package manager is found from the
|
|
19
|
+
* working folder, to spell commands in rendered docs); the generator proves
|
|
20
|
+
* the answer is the same wherever it runs, so they are not inputs.
|
|
21
|
+
* @param {Iterable<string>} files every path the work read
|
|
22
|
+
* @param {{root?: string, skip?: RegExp}} [options] - The package folder
|
|
23
|
+
* (the CLI's unless given) and, as for {@link inputState}, the folder
|
|
24
|
+
* entries to skip.
|
|
20
25
|
* @returns {Record<string, string>}
|
|
21
26
|
*/
|
|
22
|
-
export function selfAuditInputs(files: Iterable<string
|
|
27
|
+
export function selfAuditInputs(files: Iterable<string>, { root, skip }?: {
|
|
28
|
+
root?: string;
|
|
29
|
+
skip?: RegExp;
|
|
30
|
+
}): Record<string, string>;
|
|
23
31
|
/**
|
|
24
32
|
* The stored value of the audit `name`, while every file and folder it read
|
|
25
33
|
* is unchanged, else undefined.
|
|
@@ -27,5 +35,13 @@ export function selfAuditInputs(files: Iterable<string>): Record<string, string>
|
|
|
27
35
|
* @returns {unknown}
|
|
28
36
|
*/
|
|
29
37
|
export function storedSelfAudit(name: string): unknown;
|
|
38
|
+
/**
|
|
39
|
+
* Whether every recorded input under `root` is in its recorded state.
|
|
40
|
+
* @param {string} root
|
|
41
|
+
* @param {Record<string, string>} inputs - State by path under `root`.
|
|
42
|
+
* @param {RegExp} [skip] - As for {@link inputState}.
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
export function inputsUnchanged(root: string, inputs: Record<string, string>, skip?: RegExp): boolean;
|
|
30
46
|
/** Where the stored audits are, in the published package. */
|
|
31
47
|
export const SELF_AUDIT_FILE: string;
|
|
@@ -50,16 +50,18 @@ const PACKAGE_FIELDS = [
|
|
|
50
50
|
/**
|
|
51
51
|
* A file's or folder's state as an audit read it: a file by its content
|
|
52
52
|
* (package.json by its packer-stable fields), a folder by the names it holds
|
|
53
|
-
* (but PACKING_NAMES), `-` when
|
|
53
|
+
* (but the names `skip` matches: PACKING_NAMES unless given), `-` when
|
|
54
|
+
* absent.
|
|
54
55
|
* @param {string} file
|
|
56
|
+
* @param {RegExp} [skip] - Folder entries a packer or installer adds or drops.
|
|
55
57
|
* @returns {string}
|
|
56
58
|
*/
|
|
57
|
-
export function inputState(file) {
|
|
59
|
+
export function inputState(file, skip = PACKING_NAMES) {
|
|
58
60
|
try {
|
|
59
61
|
if (fs.statSync(file).isDirectory()) {
|
|
60
62
|
const names = fs
|
|
61
63
|
.readdirSync(file)
|
|
62
|
-
.filter(name => !
|
|
64
|
+
.filter(name => !skip.test(name))
|
|
63
65
|
.sort();
|
|
64
66
|
return `dir:${storedKey(names.join('\n'))}`;
|
|
65
67
|
}
|
|
@@ -79,23 +81,30 @@ export function inputState(file) {
|
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
/**
|
|
82
|
-
* The inputs
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* are not inputs.
|
|
88
|
-
* @param {Iterable<string>} files every path the
|
|
84
|
+
* The inputs a stored answer's work read, by path under `root` (`.` for
|
|
85
|
+
* `root` itself), with their state. Code in a node_modules folder under
|
|
86
|
+
* `root` is the package's dependencies, not its own files. Paths outside
|
|
87
|
+
* `root` are where the work runs (the package manager is found from the
|
|
88
|
+
* working folder, to spell commands in rendered docs); the generator proves
|
|
89
|
+
* the answer is the same wherever it runs, so they are not inputs.
|
|
90
|
+
* @param {Iterable<string>} files every path the work read
|
|
91
|
+
* @param {{root?: string, skip?: RegExp}} [options] - The package folder
|
|
92
|
+
* (the CLI's unless given) and, as for {@link inputState}, the folder
|
|
93
|
+
* entries to skip.
|
|
89
94
|
* @returns {Record<string, string>}
|
|
90
95
|
*/
|
|
91
|
-
export function selfAuditInputs(
|
|
96
|
+
export function selfAuditInputs(
|
|
97
|
+
files,
|
|
98
|
+
{root = CLI_ROOT, skip = PACKING_NAMES} = {},
|
|
99
|
+
) {
|
|
92
100
|
/** @type {Record<string, string>} */
|
|
93
101
|
const inputs = {};
|
|
94
102
|
for (const file of [...files].sort()) {
|
|
95
|
-
|
|
96
|
-
const rel = path.relative(CLI_ROOT, file);
|
|
103
|
+
const rel = path.relative(root, file);
|
|
97
104
|
if (rel.startsWith('..') || path.isAbsolute(rel)) continue;
|
|
98
|
-
|
|
105
|
+
const parts = rel === '' ? [] : rel.split(path.sep);
|
|
106
|
+
if (parts.includes('node_modules')) continue;
|
|
107
|
+
inputs[parts.join('/') || '.'] = inputState(file, skip);
|
|
99
108
|
}
|
|
100
109
|
return inputs;
|
|
101
110
|
}
|
|
@@ -110,10 +119,21 @@ export function storedSelfAudit(name) {
|
|
|
110
119
|
/** @type {{inputs: Record<string, string>, value: unknown} | undefined} */
|
|
111
120
|
const entry = readStore(SELF_AUDIT_FILE).get(name);
|
|
112
121
|
if (!entry) return undefined;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
return inputsUnchanged(CLI_ROOT, entry.inputs) ? entry.value : undefined;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Whether every recorded input under `root` is in its recorded state.
|
|
127
|
+
* @param {string} root
|
|
128
|
+
* @param {Record<string, string>} inputs - State by path under `root`.
|
|
129
|
+
* @param {RegExp} [skip] - As for {@link inputState}.
|
|
130
|
+
* @returns {boolean}
|
|
131
|
+
*/
|
|
132
|
+
export function inputsUnchanged(root, inputs, skip = PACKING_NAMES) {
|
|
133
|
+
for (const [rel, state] of Object.entries(inputs)) {
|
|
134
|
+
if (inputState(path.join(root, ...rel.split('/')), skip) !== state) {
|
|
135
|
+
return false;
|
|
116
136
|
}
|
|
117
137
|
}
|
|
118
|
-
return
|
|
138
|
+
return true;
|
|
119
139
|
}
|
|
@@ -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,
|
|
@@ -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
|
/**
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
storedKey,
|
|
35
35
|
STORED_DOCS_FILE,
|
|
36
36
|
} from '../doc-compiler/stored-docs.mjs';
|
|
37
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
37
38
|
|
|
38
39
|
export const BUNDLED_THEME_PACKAGE = '@astryxdesign/cli';
|
|
39
40
|
export const THEMES_DIR = path.join(CLI_ROOT, 'assets', 'templates', 'themes');
|
|
@@ -1328,7 +1329,7 @@ export function discoverUnmigratedThemeCopies(
|
|
|
1328
1329
|
.filter(entry => entry.isDirectory() && !isIgnoredThemeEntry(entry.name))
|
|
1329
1330
|
.map(entry => unmigratedThemeCopy(path.join(root, entry.name)))
|
|
1330
1331
|
.filter(copy => copy !== null)
|
|
1331
|
-
.sort((a, b) => a.slug
|
|
1332
|
+
.sort((a, b) => compareText(a.slug, b.slug));
|
|
1332
1333
|
}
|
|
1333
1334
|
|
|
1334
1335
|
/** @param {string[]} files */
|
|
@@ -1434,7 +1435,7 @@ export function discoverThemeDirectory(
|
|
|
1434
1435
|
}
|
|
1435
1436
|
const directories = rootEntries
|
|
1436
1437
|
.filter(entry => entry.isDirectory())
|
|
1437
|
-
.sort((a, b) => a.name
|
|
1438
|
+
.sort((a, b) => compareText(a.name, b.name));
|
|
1438
1439
|
|
|
1439
1440
|
for (const directory of directories) {
|
|
1440
1441
|
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
|