@astryxdesign/cli 0.7.16 → 0.7.17-canary.g49a475f
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 +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/_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 +75 -0
- package/api/theme/build/build.mjs +243 -58
- package/api/theme/build/font-warning.d.mts +7 -0
- package/api/theme/build/font-warning.mjs +17 -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 +63 -2
- package/api/theme-edit/_adapter.mjs +771 -57
- package/api/theme-edit/_check.d.mts +40 -22
- package/api/theme-edit/_check.mjs +2029 -336
- 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.d.mts +3 -3
- package/api/theme-edit/_context.mjs +111 -48
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +18 -4
- package/api/theme-edit/_edit.mjs +1685 -155
- package/api/theme-edit/_how-commands.d.mts +65 -0
- package/api/theme-edit/_how-commands.mjs +633 -1
- package/api/theme-edit/_how-question.d.mts +84 -0
- package/api/theme-edit/_how-question.mjs +5124 -281
- package/api/theme-edit/_how.mjs +140 -29
- 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 +257 -0
- package/api/theme-edit/_normal.mjs +1252 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_parts.d.mts +10 -1
- package/api/theme-edit/_parts.mjs +179 -3
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +515 -148
- package/api/theme-edit/_preview.d.mts +100 -14
- package/api/theme-edit/_preview.mjs +549 -137
- package/api/theme-edit/_settings.d.mts +347 -30
- package/api/theme-edit/_settings.mjs +2971 -327
- 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.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/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 +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 +163 -28
- 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 +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/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 +209 -8
- 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-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 +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/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 +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
|
@@ -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
|
|
@@ -20,6 +20,7 @@ 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 {compareText} from '../text/compare-text.mjs';
|
|
23
24
|
|
|
24
25
|
const SKIP_DIRS = new Set(['node_modules', '__tests__']);
|
|
25
26
|
|
|
@@ -142,7 +143,7 @@ async function scanThemingTargets(coreSrc) {
|
|
|
142
143
|
const canonical = canonicalizeParentTargets(targets);
|
|
143
144
|
canonical.sort(
|
|
144
145
|
(a, b) =>
|
|
145
|
-
a.key
|
|
146
|
+
compareText(a.key, b.key) || compareText(a.component, b.component),
|
|
146
147
|
);
|
|
147
148
|
return canonical;
|
|
148
149
|
}
|
|
@@ -254,7 +255,7 @@ export async function collectThemingVars(coreSrc) {
|
|
|
254
255
|
|
|
255
256
|
await scan(coreSrc);
|
|
256
257
|
|
|
257
|
-
return [...vars.values()].sort((a, b) => a.name
|
|
258
|
+
return [...vars.values()].sort((a, b) => compareText(a.name, b.name));
|
|
258
259
|
}
|
|
259
260
|
|
|
260
261
|
/**
|
|
@@ -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()) {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {parseDoc} from '../../authoring/doctypes/parse.mjs';
|
|
14
|
+
import {storedParse} from './stored-docs.mjs';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* @param {unknown} input
|
|
@@ -25,5 +26,7 @@ export function parseReadableDoc(input, label = 'doc') {
|
|
|
25
26
|
if (type === 'theme') {
|
|
26
27
|
throw new Error(`${label} has unsupported type ${JSON.stringify(type)}.`);
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
// A doc Astryx ships was parsed at publish (scripts/generate-stored-docs.mjs):
|
|
30
|
+
// its stored parse is what parsing it gives.
|
|
31
|
+
return storedParse(input) ?? parseDoc(input, label);
|
|
29
32
|
}
|
|
@@ -21,6 +21,28 @@ export function storedKey(text: string | Buffer): string;
|
|
|
21
21
|
export function readStore(file: string): {
|
|
22
22
|
get: (key: string) => any;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Note that `value` is the `name` export of the stored doc `key`.
|
|
26
|
+
* @param {unknown} value
|
|
27
|
+
* @param {string} key
|
|
28
|
+
* @param {string} name
|
|
29
|
+
*/
|
|
30
|
+
export function noteStoredExport(value: unknown, key: string, name: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Where a stored doc's export, as the readers parse it, is stored at publish.
|
|
33
|
+
* @param {string} key the doc's key
|
|
34
|
+
* @param {string} name the export's name
|
|
35
|
+
* @returns {string}
|
|
36
|
+
*/
|
|
37
|
+
export function storedParseKey(key: string, name: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* The parse of `value`, read from the store, when `value` is a stored doc's
|
|
40
|
+
* export whose parse was stored at publish: a fresh value, as a parse gives.
|
|
41
|
+
* Undefined otherwise, or when the store cannot be read.
|
|
42
|
+
* @param {unknown} value
|
|
43
|
+
* @returns {any}
|
|
44
|
+
*/
|
|
45
|
+
export function storedParse(value: unknown): any;
|
|
24
46
|
/**
|
|
25
47
|
* Where the exports of the doc files Astryx ships (the CLI's and Core's) are
|
|
26
48
|
* stored: each doc that imports nothing, reads nothing of where it sits, and
|
|
@@ -96,3 +96,52 @@ function openStore(file) {
|
|
|
96
96
|
return new Map();
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Each export value of a stored doc's module (./import.mjs), with the doc's
|
|
102
|
+
* key and the export's name, so its parse can be answered from the store
|
|
103
|
+
* ({@link storedParse}).
|
|
104
|
+
* @type {WeakMap<object, {key: string, name: string}>}
|
|
105
|
+
*/
|
|
106
|
+
const storedExports = new WeakMap();
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Note that `value` is the `name` export of the stored doc `key`.
|
|
110
|
+
* @param {unknown} value
|
|
111
|
+
* @param {string} key
|
|
112
|
+
* @param {string} name
|
|
113
|
+
*/
|
|
114
|
+
export function noteStoredExport(value, key, name) {
|
|
115
|
+
if (value && typeof value === 'object') storedExports.set(value, {key, name});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Where a stored doc's export, as the readers parse it, is stored at publish.
|
|
120
|
+
* @param {string} key the doc's key
|
|
121
|
+
* @param {string} name the export's name
|
|
122
|
+
* @returns {string}
|
|
123
|
+
*/
|
|
124
|
+
export function storedParseKey(key, name) {
|
|
125
|
+
return `parsed:${name}:${key}`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The parse of `value`, read from the store, when `value` is a stored doc's
|
|
130
|
+
* export whose parse was stored at publish: a fresh value, as a parse gives.
|
|
131
|
+
* Undefined otherwise, or when the store cannot be read.
|
|
132
|
+
* @param {unknown} value
|
|
133
|
+
* @returns {any}
|
|
134
|
+
*/
|
|
135
|
+
export function storedParse(value) {
|
|
136
|
+
if (!value || typeof value !== 'object') return undefined;
|
|
137
|
+
const at = storedExports.get(value);
|
|
138
|
+
if (!at) return undefined;
|
|
139
|
+
try {
|
|
140
|
+
const parsed = readStore(STORED_DOCS_FILE).get(
|
|
141
|
+
storedParseKey(at.key, at.name),
|
|
142
|
+
);
|
|
143
|
+
return parsed != null && typeof parsed === 'object' ? parsed : undefined;
|
|
144
|
+
} catch {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* sandboxes where a smaller dependency surface is preferred.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
12
|
+
|
|
11
13
|
const SEMVER_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
12
14
|
|
|
13
15
|
/**
|
|
@@ -42,7 +44,7 @@ export function semverCompare(a, b) {
|
|
|
42
44
|
if (Number.isNaN(na) || Number.isNaN(nb)) {
|
|
43
45
|
// Fall back to lexicographic compare on garbage input rather than
|
|
44
46
|
// returning NaN, which would silently break sort/filter callers.
|
|
45
|
-
return String(a)
|
|
47
|
+
return compareText(String(a), String(b));
|
|
46
48
|
}
|
|
47
49
|
if (na !== nb) return na - nb;
|
|
48
50
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The families a stylesheet `@import` specifier loads, read from `fromDir`:
|
|
6
|
+
* an `@fontsource` package by its name, a font service URL by the
|
|
7
|
+
* `family=` it requests, a local stylesheet by its `@font-face` rules and
|
|
8
|
+
* its own imports.
|
|
9
|
+
* @param {string} spec
|
|
10
|
+
* @param {string} fromDir
|
|
11
|
+
* @param {Set<string>} [seen]
|
|
12
|
+
* @returns {Set<string>}
|
|
13
|
+
*/
|
|
14
|
+
export function importedFontFamilies(spec: string, fromDir: string, seen?: Set<string>): Set<string>;
|
|
15
|
+
/**
|
|
16
|
+
* The families a stylesheet file loads: its `@font-face` rules, and what
|
|
17
|
+
* each of its `@import`s loads.
|
|
18
|
+
* @param {string} file
|
|
19
|
+
* @param {Set<string>} [seen]
|
|
20
|
+
* @returns {Set<string>}
|
|
21
|
+
*/
|
|
22
|
+
export function stylesheetFontFamilies(file: string, seen?: Set<string>): Set<string>;
|
|
23
|
+
/**
|
|
24
|
+
* The values of the declarations in a stylesheet's text whose property
|
|
25
|
+
* matches `property` (custom properties included), in source order.
|
|
26
|
+
* @param {string} css
|
|
27
|
+
* @param {RegExp} property
|
|
28
|
+
* @returns {string[]}
|
|
29
|
+
*/
|
|
30
|
+
export function declarationValues(css: string, property: RegExp): string[];
|
|
31
|
+
export function fontKey(family: string): string;
|