@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0135e03
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 +122 -1
- package/api/theme/build/build.mjs +412 -84
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +10 -0
- package/api/theme/build/font-warning.d.mts +23 -3
- package/api/theme/build/font-warning.mjs +54 -5
- package/api/theme/build/icon-imports.mjs +25 -2
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +103 -3
- package/api/theme-edit/_adapter.mjs +961 -82
- package/api/theme-edit/_catalog.mjs +19 -4
- package/api/theme-edit/_check.d.mts +63 -24
- package/api/theme-edit/_check.mjs +2467 -362
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +49 -1
- package/api/theme-edit/_compiler.mjs +89 -6
- package/api/theme-edit/_context.d.mts +3 -3
- package/api/theme-edit/_context.mjs +165 -54
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +31 -4
- package/api/theme-edit/_edit.mjs +2433 -204
- package/api/theme-edit/_how-commands.d.mts +72 -1
- package/api/theme-edit/_how-commands.mjs +759 -9
- package/api/theme-edit/_how-question.d.mts +82 -5
- package/api/theme-edit/_how-question.mjs +6473 -553
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +237 -41
- 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 +292 -0
- package/api/theme-edit/_normal.mjs +1454 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_part-words.d.mts +31 -0
- package/api/theme-edit/_part-words.mjs +126 -0
- package/api/theme-edit/_parts.d.mts +18 -1
- package/api/theme-edit/_parts.mjs +246 -23
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +776 -187
- package/api/theme-edit/_preview.d.mts +100 -14
- package/api/theme-edit/_preview.mjs +582 -139
- package/api/theme-edit/_project.d.mts +4 -0
- package/api/theme-edit/_project.mjs +3 -1
- package/api/theme-edit/_settings.d.mts +417 -42
- package/api/theme-edit/_settings.mjs +3262 -424
- package/api/theme-edit/_tables.d.mts +15 -0
- package/api/theme-edit/_tables.mjs +63 -1
- package/api/theme-edit/_vet.d.mts +20 -0
- package/api/theme-edit/_vet.mjs +47 -2
- 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 +5 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/authoring/example/example.doc.d.mts +12 -0
- package/authoring/example/example.doc.mjs +69 -0
- package/authoring/example/preview.d.mts +92 -0
- package/authoring/example/preview.mjs +994 -0
- package/authoring/example/type.ts +102 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +3 -1
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +22 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +32 -14
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +358 -63
- 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 +317 -47
- 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 +92 -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 +53 -1
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +31 -4
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/discovery/theming-targets.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/exact-codec.d.mts +12 -2
- package/foundation/fs/exact-codec.mjs +23 -6
- package/foundation/fs/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +62 -4
- package/foundation/fs/gather-cache.mjs +512 -91
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -0
- package/foundation/fs/listing-cache.d.mts +7 -0
- package/foundation/fs/listing-cache.mjs +10 -0
- package/foundation/fs/module-loader.d.mts +24 -2
- package/foundation/fs/module-loader.mjs +94 -21
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +9 -0
- package/foundation/fs/read-record.mjs +19 -11
- package/foundation/fs/stop-cleanup.d.mts +12 -0
- package/foundation/fs/stop-cleanup.mjs +66 -0
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/example-code.d.mts +63 -0
- package/foundation/integrations/example-code.mjs +416 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/validate-contributions.mjs +17 -45
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +39 -7
- package/foundation/render/embedded-imports.mjs +66 -27
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +121 -13
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +185 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +34 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +35 -3
- package/foundation/render/render-page.mjs +641 -96
- package/foundation/render/source-block.d.mts +85 -6
- package/foundation/render/source-block.mjs +211 -20
- package/foundation/render/ts-paths.d.mts +69 -6
- package/foundation/render/ts-paths.mjs +326 -40
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/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,264 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Whether a component or hook can carry a name, read without loading
|
|
5
|
+
* any doc: from Core's file and folder names, and from integrations' doc file
|
|
6
|
+
* names and the words in those docs' text. Each is a summary kept between
|
|
7
|
+
* runs while those folders and docs are unchanged (../fs/kept-tree.mjs).
|
|
8
|
+
*
|
|
9
|
+
* @input Core's folder or integrations' components folders, and a name
|
|
10
|
+
* folded as a reader may type it ({@link foldEntryName})
|
|
11
|
+
* @output false only when discovery lists no component or hook there whose
|
|
12
|
+
* folded name is that name; for Core, the top folders that can hold one
|
|
13
|
+
* @position foundation/discovery: lets the docs not-found error skip
|
|
14
|
+
* component and hook discovery for a name no Core file or folder name, and
|
|
15
|
+
* no integration doc's file name or text, carries
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import * as fs from 'node:fs';
|
|
19
|
+
import * as path from 'node:path';
|
|
20
|
+
import {fileURLToPath} from 'node:url';
|
|
21
|
+
import {hasNameLine, keptTreeSummary, nameLines} from '../fs/kept-tree.mjs';
|
|
22
|
+
|
|
23
|
+
/** A component doc's suffix, as integration discovery reads it. */
|
|
24
|
+
const INTEGRATION_DOC_RE = /\.doc\.(ts|mjs|js)$/;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A name as a reader may type it: case, spaces and hyphens do not count.
|
|
28
|
+
* @param {string} name
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
export function foldEntryName(name) {
|
|
32
|
+
return name.toLowerCase().replace(/[\s-]+/g, '');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Visit each file and folder under `dir`, outside `node_modules`, until
|
|
37
|
+
* `visit` returns true.
|
|
38
|
+
* @param {string} dir
|
|
39
|
+
* @param {(name: string, dir: string, isDir: boolean) => boolean} visit
|
|
40
|
+
* @returns {boolean} whether a visit returned true
|
|
41
|
+
*/
|
|
42
|
+
function walkUntil(dir, visit) {
|
|
43
|
+
let entries;
|
|
44
|
+
try {
|
|
45
|
+
entries = fs.readdirSync(dir, {withFileTypes: true});
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
if (entry.name === 'node_modules') continue;
|
|
51
|
+
const isDir = entry.isDirectory();
|
|
52
|
+
if (visit(entry.name, dir, isDir)) return true;
|
|
53
|
+
if (isDir && walkUntil(path.join(dir, entry.name), visit)) return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** This module's own file: its code decides the kept summaries' shape. */
|
|
59
|
+
const OWN_FILE = fileURLToPath(import.meta.url);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The folded names Core's files and folders give, each with a top folder of
|
|
63
|
+
* `src` that holds one, as lines ({@link nameLines}) of `<kind><name>\t<top>`:
|
|
64
|
+
* kind `t` for a `.tsx` stem (a component), `o` for a `.doc.mjs` stem (a
|
|
65
|
+
* hook), `d` for a folder name (a component). A file directly in `src` is
|
|
66
|
+
* under the top folder `''`, and a top folder under its own name. A folded
|
|
67
|
+
* name holds no white space, so a tab ends it.
|
|
68
|
+
* @param {string} coreDir
|
|
69
|
+
* @returns {string | string[]}
|
|
70
|
+
*/
|
|
71
|
+
function coreNameIndex(coreDir) {
|
|
72
|
+
return keptTreeSummary(
|
|
73
|
+
{
|
|
74
|
+
kind: 'core-entry-names',
|
|
75
|
+
roots: [path.join(coreDir, 'src')],
|
|
76
|
+
code: [OWN_FILE],
|
|
77
|
+
skip: name => name === 'node_modules',
|
|
78
|
+
},
|
|
79
|
+
([{folders}]) => {
|
|
80
|
+
/** @type {string[]} */
|
|
81
|
+
const lines = [];
|
|
82
|
+
for (const {rel, entries} of folders) {
|
|
83
|
+
const top = rel === '' ? '' : rel.split(path.sep)[0];
|
|
84
|
+
for (const {name, isDir} of entries) {
|
|
85
|
+
if (isDir) {
|
|
86
|
+
if (name !== 'node_modules') {
|
|
87
|
+
lines.push(`d${foldEntryName(name)}\t${rel === '' ? name : top}`);
|
|
88
|
+
}
|
|
89
|
+
} else if (name.endsWith('.doc.mjs')) {
|
|
90
|
+
const stem = name.slice(0, -'.doc.mjs'.length);
|
|
91
|
+
lines.push(`o${foldEntryName(stem)}\t${top}`);
|
|
92
|
+
} else if (name.endsWith('.tsx')) {
|
|
93
|
+
lines.push(
|
|
94
|
+
`t${foldEntryName(name.slice(0, -'.tsx'.length))}\t${top}`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return nameLines(lines);
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The tops the index lines that start with `prefix` name.
|
|
106
|
+
* @param {string | string[]} lines
|
|
107
|
+
* @param {string} prefix
|
|
108
|
+
* @returns {string[]}
|
|
109
|
+
*/
|
|
110
|
+
function topsAfter(lines, prefix) {
|
|
111
|
+
if (typeof lines !== 'string') {
|
|
112
|
+
return lines
|
|
113
|
+
.filter(line => line.startsWith(prefix))
|
|
114
|
+
.map(line => line.slice(prefix.length));
|
|
115
|
+
}
|
|
116
|
+
const needle = `\n${prefix}`;
|
|
117
|
+
const tops = [];
|
|
118
|
+
for (
|
|
119
|
+
let at = lines.indexOf(needle);
|
|
120
|
+
at >= 0;
|
|
121
|
+
at = lines.indexOf(needle, at + 1)
|
|
122
|
+
) {
|
|
123
|
+
const start = at + needle.length;
|
|
124
|
+
tops.push(lines.slice(start, lines.indexOf('\n', start)));
|
|
125
|
+
}
|
|
126
|
+
return tops;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Which Core entries can fold to `wanted`. Every Core component takes its
|
|
131
|
+
* name from a `.tsx` file (without an `XDS` prefix) or a folder, and every
|
|
132
|
+
* hook from its doc's file name, so a name no such file carries is neither.
|
|
133
|
+
* @param {string} coreDir
|
|
134
|
+
* @param {string} wanted a folded name
|
|
135
|
+
* @returns {{component: boolean, hook: boolean, componentTops: Set<string>, hookTops: Set<string>}}
|
|
136
|
+
* `hook` also counts a hook named `use` + `wanted`; the tops are the top
|
|
137
|
+
* folders of `src` that hold such a file or folder
|
|
138
|
+
*/
|
|
139
|
+
export function coreFilesNaming(coreDir, wanted) {
|
|
140
|
+
const index = coreNameIndex(coreDir);
|
|
141
|
+
const componentTops = new Set([
|
|
142
|
+
...topsAfter(index, `t${wanted}\t`),
|
|
143
|
+
...topsAfter(index, `txds${wanted}\t`),
|
|
144
|
+
...topsAfter(index, `d${wanted}\t`),
|
|
145
|
+
]);
|
|
146
|
+
const hookTops = new Set([
|
|
147
|
+
...topsAfter(index, `o${wanted}\t`),
|
|
148
|
+
...topsAfter(index, `ouse${wanted}\t`),
|
|
149
|
+
]);
|
|
150
|
+
return {
|
|
151
|
+
component: componentTops.size > 0,
|
|
152
|
+
hook: hookTops.size > 0,
|
|
153
|
+
componentTops,
|
|
154
|
+
hookTops,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** A name a doc's text can spell: a run of word characters. */
|
|
159
|
+
const WORD_RE = /[A-Za-z0-9_$]+/g;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* What each integration's component docs can name: each doc's folded file
|
|
163
|
+
* stem, and each word in its text, in lower case. `unreadable` when a doc
|
|
164
|
+
* could not be read.
|
|
165
|
+
* @param {string[]} componentsDirs
|
|
166
|
+
* @returns {Array<{stems: string | string[], words: string | string[], unreadable: boolean}>}
|
|
167
|
+
*/
|
|
168
|
+
function integrationNameIndexes(componentsDirs) {
|
|
169
|
+
return keptTreeSummary(
|
|
170
|
+
{
|
|
171
|
+
kind: 'integration-component-names',
|
|
172
|
+
roots: componentsDirs,
|
|
173
|
+
code: [OWN_FILE],
|
|
174
|
+
// Integration discovery reads no doc in these folders.
|
|
175
|
+
skip: name => name === 'node_modules' || name === '__tests__',
|
|
176
|
+
},
|
|
177
|
+
trees =>
|
|
178
|
+
trees.map(({folders, readText}) => {
|
|
179
|
+
const stems = new Set();
|
|
180
|
+
const words = new Set();
|
|
181
|
+
let unreadable = false;
|
|
182
|
+
for (const {rel, entries} of folders) {
|
|
183
|
+
for (const {name, isDir} of entries) {
|
|
184
|
+
if (isDir || !INTEGRATION_DOC_RE.test(name)) continue;
|
|
185
|
+
stems.add(foldEntryName(name.replace(INTEGRATION_DOC_RE, '')));
|
|
186
|
+
let text;
|
|
187
|
+
try {
|
|
188
|
+
text = readText(rel === '' ? name : path.join(rel, name));
|
|
189
|
+
} catch {
|
|
190
|
+
unreadable = true;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
for (const word of text.match(WORD_RE) ?? []) {
|
|
194
|
+
words.add(word.toLowerCase());
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return {stems: nameLines(stems), words: nameLines(words), unreadable};
|
|
199
|
+
}),
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Whether an integration component can fold to `wanted`, for each
|
|
205
|
+
* components folder in order. Integration discovery names a component after
|
|
206
|
+
* its doc's file, or after a name the doc spells out (its export, or a family
|
|
207
|
+
* member), so a doc whose file name and text both lack the name lists no
|
|
208
|
+
* such component.
|
|
209
|
+
* @param {Array<string | undefined>} componentsDirs
|
|
210
|
+
* @param {string} wanted a folded name
|
|
211
|
+
* @returns {boolean[]}
|
|
212
|
+
*/
|
|
213
|
+
export function integrationsFilesNaming(componentsDirs, wanted) {
|
|
214
|
+
// A name of word characters alone is a whole word of the text exactly when
|
|
215
|
+
// it is one of the text's words: the kept index answers it.
|
|
216
|
+
if (!/^[a-z0-9_$]+$/.test(wanted)) {
|
|
217
|
+
return componentsDirs.map(dir => !!dir && docsSpell(dir, wanted));
|
|
218
|
+
}
|
|
219
|
+
const dirs = componentsDirs.flatMap(dir => (dir ? [dir] : []));
|
|
220
|
+
const indexes = dirs.length > 0 ? integrationNameIndexes(dirs) : [];
|
|
221
|
+
let at = 0;
|
|
222
|
+
return componentsDirs.map(dir => {
|
|
223
|
+
if (!dir) return false;
|
|
224
|
+
const {stems, words, unreadable} = indexes[at++];
|
|
225
|
+
return (
|
|
226
|
+
unreadable || hasNameLine(stems, wanted) || hasNameLine(words, wanted)
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* {@link integrationsFilesNaming} for one components folder.
|
|
233
|
+
* @param {string | undefined} componentsDir
|
|
234
|
+
* @param {string} wanted a folded name
|
|
235
|
+
* @returns {boolean}
|
|
236
|
+
*/
|
|
237
|
+
export function integrationFilesNaming(componentsDir, wanted) {
|
|
238
|
+
return integrationsFilesNaming([componentsDir], wanted)[0];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Whether a component doc under `componentsDir` has a file stem that folds to
|
|
243
|
+
* `wanted`, or text that holds it as a whole word, read from the disk.
|
|
244
|
+
* @param {string} componentsDir
|
|
245
|
+
* @param {string} wanted a folded name
|
|
246
|
+
* @returns {boolean}
|
|
247
|
+
*/
|
|
248
|
+
function docsSpell(componentsDir, wanted) {
|
|
249
|
+
const token = new RegExp(
|
|
250
|
+
`(?<![\\w$])${wanted.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w$])`,
|
|
251
|
+
'i',
|
|
252
|
+
);
|
|
253
|
+
return walkUntil(componentsDir, (name, dir, isDir) => {
|
|
254
|
+
if (isDir || !INTEGRATION_DOC_RE.test(name)) return false;
|
|
255
|
+
if (foldEntryName(name.replace(INTEGRATION_DOC_RE, '')) === wanted) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
try {
|
|
259
|
+
return token.test(fs.readFileSync(path.join(dir, name), 'utf8'));
|
|
260
|
+
} catch {
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
@@ -7,9 +7,13 @@
|
|
|
7
7
|
* Categories from HookDoc.category: focus, layout, animation, interaction, data, media, streaming
|
|
8
8
|
* Hooks without a category go in 'Other'.
|
|
9
9
|
* @param {string} coreDir
|
|
10
|
+
* @param {(name: string) => boolean} [keep] the hooks to read; the others are
|
|
11
|
+
* left out, and their docs are not read
|
|
12
|
+
* @param {Set<string>} [tops] the top folders of `src` outside `hooks` to
|
|
13
|
+
* read, when only these can hold a hook `keep` accepts
|
|
10
14
|
* @returns {Record<string, string[]>}
|
|
11
15
|
*/
|
|
12
|
-
export function discoverHooks(coreDir: string): Record<string, string[]>;
|
|
16
|
+
export function discoverHooks(coreDir: string, keep?: (name: string) => boolean, tops?: Set<string>): Record<string, string[]>;
|
|
13
17
|
/**
|
|
14
18
|
* Find the .doc.mjs file for a hook by name.
|
|
15
19
|
* Searches hooks/ directory and component directories.
|
|
@@ -23,6 +27,8 @@ export function findHookDoc(coreDir: string, name: string): string | null;
|
|
|
23
27
|
/**
|
|
24
28
|
* Get all discovered hook names as a flat array (for fuzzy matching).
|
|
25
29
|
* @param {string} coreDir
|
|
30
|
+
* @param {(name: string) => boolean} [keep] as for {@link discoverHooks}
|
|
31
|
+
* @param {Set<string>} [tops] as for {@link discoverHooks}
|
|
26
32
|
* @returns {string[]}
|
|
27
33
|
*/
|
|
28
|
-
export function getAllHookNames(coreDir: string): string[];
|
|
34
|
+
export function getAllHookNames(coreDir: string, keep?: (name: string) => boolean, tops?: Set<string>): string[];
|
|
@@ -9,6 +9,7 @@ import * as path from 'node:path';
|
|
|
9
9
|
import {listDir, listDirEntries, pathExists} from '../fs/listing-cache.mjs';
|
|
10
10
|
import {existsCaseExact} from '../fs/paths.mjs';
|
|
11
11
|
import {levenshteinDistance} from '../text/string-utils.mjs';
|
|
12
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
12
13
|
|
|
13
14
|
const SKIP_DIRS = new Set(['utils', '__tests__', 'node_modules']);
|
|
14
15
|
|
|
@@ -74,9 +75,13 @@ function hookNameFromFile(fileName) {
|
|
|
74
75
|
* Categories from HookDoc.category: focus, layout, animation, interaction, data, media, streaming
|
|
75
76
|
* Hooks without a category go in 'Other'.
|
|
76
77
|
* @param {string} coreDir
|
|
78
|
+
* @param {(name: string) => boolean} [keep] the hooks to read; the others are
|
|
79
|
+
* left out, and their docs are not read
|
|
80
|
+
* @param {Set<string>} [tops] the top folders of `src` outside `hooks` to
|
|
81
|
+
* read, when only these can hold a hook `keep` accepts
|
|
77
82
|
* @returns {Record<string, string[]>}
|
|
78
83
|
*/
|
|
79
|
-
export function discoverHooks(coreDir) {
|
|
84
|
+
export function discoverHooks(coreDir, keep = () => true, tops) {
|
|
80
85
|
const srcDir = path.join(coreDir, 'src');
|
|
81
86
|
const hooksDir = path.join(srcDir, 'hooks');
|
|
82
87
|
|
|
@@ -90,6 +95,7 @@ export function discoverHooks(coreDir) {
|
|
|
90
95
|
if (!entry.isFile()) continue;
|
|
91
96
|
if (!entry.name.endsWith('.doc.mjs')) continue;
|
|
92
97
|
const hookName = hookNameFromFile(entry.name);
|
|
98
|
+
if (!keep(hookName)) continue;
|
|
93
99
|
const docPath = path.join(hooksDir, entry.name);
|
|
94
100
|
const {category} = readHookMeta(docPath);
|
|
95
101
|
hookCategories.set(hookName, category || 'Other');
|
|
@@ -102,8 +108,9 @@ export function discoverHooks(coreDir) {
|
|
|
102
108
|
const topEntries = listDirEntries(srcDir);
|
|
103
109
|
for (const entry of topEntries) {
|
|
104
110
|
if (!entry.isDirectory() || SKIP_DIRS.has(entry.name) || entry.name === 'hooks') continue;
|
|
111
|
+
if (tops && !tops.has(entry.name)) continue;
|
|
105
112
|
const dirPath = path.join(srcDir, entry.name);
|
|
106
|
-
scanDirForHookDocs(dirPath, hookCategories);
|
|
113
|
+
scanDirForHookDocs(dirPath, hookCategories, keep);
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
|
|
@@ -124,7 +131,7 @@ export function discoverHooks(coreDir) {
|
|
|
124
131
|
const sortedEntries = Array.from(groups.entries()).sort((a, b) => {
|
|
125
132
|
if (a[0] === 'Other') return 1;
|
|
126
133
|
if (b[0] === 'Other') return -1;
|
|
127
|
-
return a[0]
|
|
134
|
+
return compareText(a[0], b[0]);
|
|
128
135
|
});
|
|
129
136
|
|
|
130
137
|
/** @type {Record<string, string[]>} */
|
|
@@ -140,17 +147,22 @@ export function discoverHooks(coreDir) {
|
|
|
140
147
|
* Recursively scan a directory for use*.doc.mjs files.
|
|
141
148
|
* @param {string} dirPath
|
|
142
149
|
* @param {Map<string, string>} hookCategories
|
|
150
|
+
* @param {(name: string) => boolean} keep
|
|
143
151
|
*/
|
|
144
|
-
function scanDirForHookDocs(dirPath, hookCategories) {
|
|
152
|
+
function scanDirForHookDocs(dirPath, hookCategories, keep) {
|
|
145
153
|
if (!pathExists(dirPath)) return;
|
|
146
154
|
const entries = listDirEntries(dirPath);
|
|
147
155
|
for (const entry of entries) {
|
|
148
156
|
if (entry.isDirectory() && !SKIP_DIRS.has(entry.name)) {
|
|
149
|
-
scanDirForHookDocs(path.join(dirPath, entry.name), hookCategories);
|
|
157
|
+
scanDirForHookDocs(path.join(dirPath, entry.name), hookCategories, keep);
|
|
150
158
|
} else if (entry.isFile() && HOOK_DOC_FILE_RE.test(entry.name)) {
|
|
151
159
|
const hookName = hookNameFromFile(entry.name);
|
|
152
160
|
const docPath = path.join(dirPath, entry.name);
|
|
153
|
-
if (
|
|
161
|
+
if (
|
|
162
|
+
keep(hookName) &&
|
|
163
|
+
!hookCategories.has(hookName) &&
|
|
164
|
+
!isBesideOwnHook(docPath, hookName)
|
|
165
|
+
) {
|
|
154
166
|
const {category} = readHookMeta(docPath);
|
|
155
167
|
hookCategories.set(hookName, category || 'Other');
|
|
156
168
|
}
|
|
@@ -258,9 +270,11 @@ function searchDirForHookDoc(dirPath, candidates) {
|
|
|
258
270
|
/**
|
|
259
271
|
* Get all discovered hook names as a flat array (for fuzzy matching).
|
|
260
272
|
* @param {string} coreDir
|
|
273
|
+
* @param {(name: string) => boolean} [keep] as for {@link discoverHooks}
|
|
274
|
+
* @param {Set<string>} [tops] as for {@link discoverHooks}
|
|
261
275
|
* @returns {string[]}
|
|
262
276
|
*/
|
|
263
|
-
export function getAllHookNames(coreDir) {
|
|
264
|
-
const hooks = discoverHooks(coreDir);
|
|
277
|
+
export function getAllHookNames(coreDir, keep, tops) {
|
|
278
|
+
const hooks = discoverHooks(coreDir, keep, tops);
|
|
265
279
|
return Object.values(hooks).flat();
|
|
266
280
|
}
|
|
@@ -20,6 +20,7 @@ import {parseIconDefinition} from '../../authoring/doctypes/icon-definition/pars
|
|
|
20
20
|
import {CLI_ROOT} from '../fs/paths.mjs';
|
|
21
21
|
import {listDirEntries} from '../fs/listing-cache.mjs';
|
|
22
22
|
import {readStaticDescriptorValue} from './theme-discovery.mjs';
|
|
23
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
23
24
|
|
|
24
25
|
/** @typedef {import('../../authoring/doctypes/icon-definition/type').IconDefinitionDoc} IconDefinitionDoc */
|
|
25
26
|
|
|
@@ -60,7 +61,7 @@ export function readDefinitionsDir(dir, owner) {
|
|
|
60
61
|
} catch {
|
|
61
62
|
return {definitions, errors};
|
|
62
63
|
}
|
|
63
|
-
for (const entry of entries.sort((a, b) => a.name
|
|
64
|
+
for (const entry of entries.sort((a, b) => compareText(a.name, b.name))) {
|
|
64
65
|
if (!entry.name.endsWith('.doc.mjs')) continue;
|
|
65
66
|
const file = path.join(dir, entry.name);
|
|
66
67
|
const label = `Icon definition ${entry.name} in ${owner}`;
|
|
@@ -79,6 +79,7 @@ import {
|
|
|
79
79
|
issueError,
|
|
80
80
|
issueWarning,
|
|
81
81
|
} from '../integrations/validate-contributions.mjs';
|
|
82
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
82
83
|
|
|
83
84
|
/** @typedef {import('../integrations/issue').AstryxIntegrationIssue} Issue */
|
|
84
85
|
/** @typedef {import('./icon-set-discovery.mjs').DiscoveredIconSet} DiscoveredIconSet */
|
|
@@ -1106,7 +1107,7 @@ function lookRewriteCommand(set, variant, origins) {
|
|
|
1106
1107
|
if (from) counts.set(from, (counts.get(from) ?? 0) + 1);
|
|
1107
1108
|
}
|
|
1108
1109
|
const module = [...counts].sort(
|
|
1109
|
-
(a, b) => b[1] - a[1] || a[0]
|
|
1110
|
+
(a, b) => b[1] - a[1] || compareText(a[0], b[0]),
|
|
1110
1111
|
)[0]?.[0];
|
|
1111
1112
|
return `astryx experimental icon add --variant ${shellArg(variant)} --from ${module ? shellArg(module) : '<module>'} --all --set ${shellArg(set.name)}`;
|
|
1112
1113
|
}
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
isIgnoredThemeEntry,
|
|
35
35
|
readStaticDescriptorValue,
|
|
36
36
|
} from './theme-discovery.mjs';
|
|
37
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
37
38
|
|
|
38
39
|
/** @typedef {import('../../authoring/doctypes/icon-set/type').IconSetData} IconSetData */
|
|
39
40
|
/** @typedef {import('../../authoring/doctypes/icon-set/type').IconSetIcon} IconSetIcon */
|
|
@@ -149,7 +150,7 @@ export function discoverIconSetDirectory(root, owner) {
|
|
|
149
150
|
} catch {
|
|
150
151
|
return {sets, errors};
|
|
151
152
|
}
|
|
152
|
-
for (const entry of entries.sort((a, b) => a.name
|
|
153
|
+
for (const entry of entries.sort((a, b) => compareText(a.name, b.name))) {
|
|
153
154
|
if (isIgnoredThemeEntry(entry.name) || !entry.isDirectory()) continue;
|
|
154
155
|
// Only a lower-kebab directory is a set (FR1).
|
|
155
156
|
if (!SET_NAME_RE.test(entry.name)) continue;
|
|
@@ -40,6 +40,7 @@ import {discoverIntegrationTemplatesForOne} from './template-adapter.mjs';
|
|
|
40
40
|
import {discoverThemeDirectory} from './theme-discovery.mjs';
|
|
41
41
|
import {discoverIconSetDirectory} from './icon-set-discovery.mjs';
|
|
42
42
|
import {rootProblem} from '../integrations/validate-contributions.mjs';
|
|
43
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
43
44
|
|
|
44
45
|
/** @typedef {import('./doc-types.mjs').DocFile} DocFile */
|
|
45
46
|
/** @typedef {import('./doc-types.mjs').DocRoot} DocRoot */
|
|
@@ -176,7 +177,7 @@ export async function integrationDocFiles(integration) {
|
|
|
176
177
|
return {
|
|
177
178
|
files: [...owners]
|
|
178
179
|
.map(([file, {root}]) => ({path: file, root}))
|
|
179
|
-
.sort((a, b) => a.path
|
|
180
|
+
.sort((a, b) => compareText(a.path, b.path)),
|
|
180
181
|
unread,
|
|
181
182
|
fixtures,
|
|
182
183
|
};
|
|
@@ -1,6 +1,16 @@
|
|
|
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
|
+
* The target one subpath of a package's exports maps to under a list of
|
|
6
|
+
* conditions, its wildcard filled in, as written in the package (`./x`).
|
|
7
|
+
* Null when the package exports no such subpath.
|
|
8
|
+
* @param {unknown} exportsField
|
|
9
|
+
* @param {string} subpath `.` or a `./`-prefixed subpath
|
|
10
|
+
* @param {readonly string[]} conditions
|
|
11
|
+
* @returns {string|null}
|
|
12
|
+
*/
|
|
13
|
+
export function conditionalExportTarget(exportsField: unknown, subpath: string, conditions: readonly string[]): string | null;
|
|
4
14
|
/**
|
|
5
15
|
* The file a subpath's `source` condition names, when that file is in the
|
|
6
16
|
* package. A package that ships its source (or a workspace package before it
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* their legacy public deep paths and are resolved from files on disk.
|
|
9
9
|
*
|
|
10
10
|
* @input Parsed package.json, package directory, and a public subpath
|
|
11
|
-
* @output The public specifier and confined target file, when exported,
|
|
12
|
-
*
|
|
11
|
+
* @output The public specifier and confined target file, when exported, the
|
|
12
|
+
* file a subpath's `source` condition names, when the package has it, and
|
|
13
|
+
* the target a subpath maps to under given conditions
|
|
13
14
|
* @position packages/cli/foundation/discovery — shared package import metadata
|
|
14
15
|
*/
|
|
15
16
|
|
|
@@ -61,6 +62,16 @@ function targetString(value) {
|
|
|
61
62
|
return null;
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
/**
|
|
66
|
+
* The order Node and TypeScript try export patterns in: the longer part
|
|
67
|
+
* before the `*` first, then the longer key.
|
|
68
|
+
* @param {string} a
|
|
69
|
+
* @param {string} b
|
|
70
|
+
*/
|
|
71
|
+
function patternKeyCompare(a, b) {
|
|
72
|
+
return b.indexOf('*') - a.indexOf('*') || b.length - a.length;
|
|
73
|
+
}
|
|
74
|
+
|
|
64
75
|
/**
|
|
65
76
|
* Find an exact or one-star subpath mapping and the wildcard value it matched.
|
|
66
77
|
* @param {Record<string, unknown>} map
|
|
@@ -72,7 +83,7 @@ function subpathValue(map, subpath) {
|
|
|
72
83
|
}
|
|
73
84
|
const patterns = Object.keys(map)
|
|
74
85
|
.filter(key => key.startsWith('./') && key.split('*').length === 2)
|
|
75
|
-
.sort(
|
|
86
|
+
.sort(patternKeyCompare);
|
|
76
87
|
for (const pattern of patterns) {
|
|
77
88
|
const star = pattern.indexOf('*');
|
|
78
89
|
const prefix = pattern.slice(0, star);
|
|
@@ -186,6 +197,48 @@ function rawExportValue(exportsField, subpath) {
|
|
|
186
197
|
: null;
|
|
187
198
|
}
|
|
188
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Select one string target under a list of conditions, matched in the order
|
|
202
|
+
* the export object lists them, as Node and TypeScript match them; `default`
|
|
203
|
+
* always matches.
|
|
204
|
+
* @param {unknown} value
|
|
205
|
+
* @param {readonly string[]} conditions
|
|
206
|
+
* @returns {string|null}
|
|
207
|
+
*/
|
|
208
|
+
function conditionTarget(value, conditions) {
|
|
209
|
+
if (typeof value === 'string') return value;
|
|
210
|
+
if (Array.isArray(value)) {
|
|
211
|
+
for (const item of value) {
|
|
212
|
+
const selected = conditionTarget(item, conditions);
|
|
213
|
+
if (selected) return selected;
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
if (!isRecord(value)) return null;
|
|
218
|
+
for (const [key, item] of Object.entries(value)) {
|
|
219
|
+
if (key !== 'default' && !conditions.includes(key)) continue;
|
|
220
|
+
const selected = conditionTarget(item, conditions);
|
|
221
|
+
if (selected) return selected;
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* The target one subpath of a package's exports maps to under a list of
|
|
228
|
+
* conditions, its wildcard filled in, as written in the package (`./x`).
|
|
229
|
+
* Null when the package exports no such subpath.
|
|
230
|
+
* @param {unknown} exportsField
|
|
231
|
+
* @param {string} subpath `.` or a `./`-prefixed subpath
|
|
232
|
+
* @param {readonly string[]} conditions
|
|
233
|
+
* @returns {string|null}
|
|
234
|
+
*/
|
|
235
|
+
export function conditionalExportTarget(exportsField, subpath, conditions) {
|
|
236
|
+
const selected = rawExportValue(exportsField, subpath);
|
|
237
|
+
if (!selected) return null;
|
|
238
|
+
const target = conditionTarget(selected.value, conditions);
|
|
239
|
+
return target === null ? null : target.replaceAll('*', selected.wildcard);
|
|
240
|
+
}
|
|
241
|
+
|
|
189
242
|
/**
|
|
190
243
|
* The file a subpath's `source` condition names, when that file is in the
|
|
191
244
|
* package. A package that ships its source (or a workspace package before it
|
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
unresolvedGlobals,
|
|
62
62
|
unresolvedReference,
|
|
63
63
|
} from './unresolved-references.mjs';
|
|
64
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* @typedef {'not_in_code' | 'not_in_doc' | 'required_mismatch' | 'type_mismatch' | 'default_mismatch'} PropDriftKind
|
|
@@ -762,7 +763,7 @@ function inDeclaredOrder(ts, checker, type, symbol) {
|
|
|
762
763
|
/** @type {(t: any) => string} */
|
|
763
764
|
const text = t => checker.typeToString(t);
|
|
764
765
|
return [...type.types].sort(
|
|
765
|
-
(a, b) => place(a) - place(b) || text(a)
|
|
766
|
+
(a, b) => place(a) - place(b) || compareText(text(a), text(b)),
|
|
766
767
|
);
|
|
767
768
|
}
|
|
768
769
|
|
|
@@ -1792,7 +1793,7 @@ export function comparePropTables(tables, options) {
|
|
|
1792
1793
|
reason: `the package's TypeScript config has an error, so props were not read (${project.error})`,
|
|
1793
1794
|
});
|
|
1794
1795
|
}
|
|
1795
|
-
unchecked.sort((a, b) => a.component
|
|
1796
|
+
unchecked.sort((a, b) => compareText(a.component, b.component));
|
|
1796
1797
|
return {
|
|
1797
1798
|
status: 'checked',
|
|
1798
1799
|
typescript: version,
|
|
@@ -2213,15 +2214,14 @@ export function comparePropTables(tables, options) {
|
|
|
2213
2214
|
// sort one component's findings among another's that shares its prefix.
|
|
2214
2215
|
findings.sort(
|
|
2215
2216
|
(a, b) =>
|
|
2216
|
-
a.component
|
|
2217
|
-
a.prop
|
|
2218
|
-
a.kind
|
|
2217
|
+
compareText(a.component, b.component) ||
|
|
2218
|
+
compareText(a.prop, b.prop) ||
|
|
2219
|
+
compareText(a.kind, b.kind),
|
|
2219
2220
|
);
|
|
2220
|
-
unchecked.sort((a, b) => a.component
|
|
2221
|
+
unchecked.sort((a, b) => compareText(a.component, b.component));
|
|
2221
2222
|
typesNotCompared.sort(
|
|
2222
2223
|
(a, b) =>
|
|
2223
|
-
a.component
|
|
2224
|
-
a.reason.localeCompare(b.reason),
|
|
2224
|
+
compareText(a.component, b.component) || compareText(a.reason, b.reason),
|
|
2225
2225
|
);
|
|
2226
2226
|
return {
|
|
2227
2227
|
status: 'checked',
|
|
@@ -2428,7 +2428,7 @@ export async function comparePropDocs(components, options) {
|
|
|
2428
2428
|
return {
|
|
2429
2429
|
...report,
|
|
2430
2430
|
unchecked: [...unchecked, ...report.unchecked].sort((a, b) =>
|
|
2431
|
-
a.component
|
|
2431
|
+
compareText(a.component, b.component),
|
|
2432
2432
|
),
|
|
2433
2433
|
};
|
|
2434
2434
|
}
|
|
@@ -32,6 +32,7 @@ export const RUNNER_COMMAND_ALLOWLIST: Readonly<{
|
|
|
32
32
|
'packages/cli/assets/docs/tree/cli-command.doc.mjs': "explains how printed commands start, the pinned `npx @astryxdesign/cli@<version>` among them";
|
|
33
33
|
'packages/cli/assets/docs/tree/who-answers.doc.mjs': "explains how printed commands start, the pinned `npx @astryxdesign/cli@<version>` among them";
|
|
34
34
|
'packages/cli/assets/docs/tree/project-global-or-both.doc.mjs': "compares running the CLI with npx to installing it, and is found by searching for that command";
|
|
35
|
+
'packages/cli/assets/docs/tree/render-pages.doc.mjs': "quotes the note a rendered file opens with, whose commands are pinned to `npx @astryxdesign/cli@<version>`";
|
|
35
36
|
'packages/cli/assets/docs/tree/install-once.doc.mjs': "names a pinned release, `npx @astryxdesign/cli@<version>`, which answers as that version";
|
|
36
37
|
'packages/cli/assets/docs/tree/doc-syntax.doc.mjs': "shows what each doc token renders as, in every package manager";
|
|
37
38
|
'packages/cli/assets/docs/tree/add-a-topic.doc.mjs': "shows what a reader sees for a command token, with their runner";
|
|
@@ -43,6 +43,8 @@ export const RUNNER_COMMAND_ALLOWLIST = Object.freeze({
|
|
|
43
43
|
'explains how printed commands start, the pinned `npx @astryxdesign/cli@<version>` among them',
|
|
44
44
|
'packages/cli/assets/docs/tree/project-global-or-both.doc.mjs':
|
|
45
45
|
'compares running the CLI with npx to installing it, and is found by searching for that command',
|
|
46
|
+
'packages/cli/assets/docs/tree/render-pages.doc.mjs':
|
|
47
|
+
'quotes the note a rendered file opens with, whose commands are pinned to `npx @astryxdesign/cli@<version>`',
|
|
46
48
|
'packages/cli/assets/docs/tree/install-once.doc.mjs':
|
|
47
49
|
'names a pinned release, `npx @astryxdesign/cli@<version>`, which answers as that version',
|
|
48
50
|
'packages/cli/assets/docs/tree/doc-syntax.doc.mjs':
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
* @typedef {object} StoredComponentList
|
|
6
|
+
* @property {Record<string, string[]>} groups - discoverComponents' answer.
|
|
7
|
+
* @property {Record<string, string>} imports - resolveImportPath's answer
|
|
8
|
+
* for each listed component.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The stored list for the Core in `coreDir`, while every file and folder its
|
|
12
|
+
* work read is unchanged; checked once per operation.
|
|
13
|
+
* @param {string} coreDir
|
|
14
|
+
* @returns {StoredComponentList | null}
|
|
15
|
+
*/
|
|
16
|
+
export function storedComponentList(coreDir: string): StoredComponentList | null;
|
|
17
|
+
/**
|
|
18
|
+
* The stored list for `coreDir` when this operation has already checked it,
|
|
19
|
+
* without checking it: one lookup never pays for the check, which costs more
|
|
20
|
+
* than the lookup.
|
|
21
|
+
* @param {string} coreDir
|
|
22
|
+
* @returns {StoredComponentList | null}
|
|
23
|
+
*/
|
|
24
|
+
export function checkedComponentList(coreDir: string): StoredComponentList | null;
|
|
25
|
+
/** Where the stored component list is written at `prepack`. */
|
|
26
|
+
export const COMPONENT_LIST_FILE: string;
|
|
27
|
+
/**
|
|
28
|
+
* Folder entries an install adds beside Core's own files: only `node_modules`.
|
|
29
|
+
* Every other name counts, so a file added anywhere the list reads misses the
|
|
30
|
+
* store.
|
|
31
|
+
*/
|
|
32
|
+
export const CORE_FOLDER_SKIP: RegExp;
|
|
33
|
+
export type StoredComponentList = {
|
|
34
|
+
/**
|
|
35
|
+
* - discoverComponents' answer.
|
|
36
|
+
*/
|
|
37
|
+
groups: Record<string, string[]>;
|
|
38
|
+
/**
|
|
39
|
+
* - resolveImportPath's answer
|
|
40
|
+
* for each listed component.
|
|
41
|
+
*/
|
|
42
|
+
imports: Record<string, string>;
|
|
43
|
+
};
|