@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
|
@@ -1,20 +1,29 @@
|
|
|
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 render format a file that carries these files says, the page first.
|
|
6
|
+
* @param {{path: string}[]} files
|
|
7
|
+
* @returns {number}
|
|
8
|
+
*/
|
|
9
|
+
export function formatFor(files: {
|
|
10
|
+
path: string;
|
|
11
|
+
}[]): number;
|
|
4
12
|
/**
|
|
5
13
|
* The data block for a page's files.
|
|
6
14
|
* @param {string} entry the page's file name
|
|
7
15
|
* @param {{path: string, bytes: Buffer}[]} files the page first
|
|
16
|
+
* @param {RenderRecord} [record] what the render records about itself
|
|
8
17
|
* @returns {string}
|
|
9
18
|
*/
|
|
10
19
|
export function sourceBlock(entry: string, files: {
|
|
11
20
|
path: string;
|
|
12
21
|
bytes: Buffer;
|
|
13
|
-
}[]): string;
|
|
22
|
+
}[], record?: RenderRecord): string;
|
|
14
23
|
/**
|
|
15
24
|
* Read the embedded source from a rendered file.
|
|
16
25
|
* @param {string} html
|
|
17
|
-
* @returns {{found: false} | {found: true, source: EmbeddedSource} | {found: true, damaged: string}}
|
|
26
|
+
* @returns {{found: false} | {found: true, source: EmbeddedSource} | {found: true, damaged: string} | {found: true, newer: {format: number, cli: string | null}}}
|
|
18
27
|
*/
|
|
19
28
|
export function readSourceBlock(html: string): {
|
|
20
29
|
found: false;
|
|
@@ -24,10 +33,49 @@ export function readSourceBlock(html: string): {
|
|
|
24
33
|
} | {
|
|
25
34
|
found: true;
|
|
26
35
|
damaged: string;
|
|
36
|
+
} | {
|
|
37
|
+
found: true;
|
|
38
|
+
newer: {
|
|
39
|
+
format: number;
|
|
40
|
+
cli: string | null;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The markup between `<body>` and the embedded source: what a render wrote
|
|
45
|
+
* there, unless someone changed it since. Null when the file no longer has
|
|
46
|
+
* that shape.
|
|
47
|
+
* @param {string} html
|
|
48
|
+
* @returns {string | null}
|
|
49
|
+
*/
|
|
50
|
+
export function renderedMarkupOf(html: string): string | null;
|
|
51
|
+
/**
|
|
52
|
+
* The title and the <style> element a render wrote in <head>, unless someone
|
|
53
|
+
* changed them since.
|
|
54
|
+
* @param {string} html
|
|
55
|
+
* @returns {{title: string | null, style: string | null}}
|
|
56
|
+
*/
|
|
57
|
+
export function renderedHeadOf(html: string): {
|
|
58
|
+
title: string | null;
|
|
59
|
+
style: string | null;
|
|
27
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* The title and the runs of text a record keeps, or null when the record
|
|
63
|
+
* keeps none or they do not decode.
|
|
64
|
+
* @param {{text?: unknown}} markup
|
|
65
|
+
* @returns {{title: string | null, runs: string[]} | null}
|
|
66
|
+
*/
|
|
67
|
+
export function recordedText(markup: {
|
|
68
|
+
text?: unknown;
|
|
69
|
+
}): {
|
|
70
|
+
title: string | null;
|
|
71
|
+
runs: string[];
|
|
72
|
+
} | null;
|
|
28
73
|
/** The script type of the embedded-source block. */
|
|
29
74
|
export const SOURCE_TYPE: "application/x-astryx-source";
|
|
30
|
-
|
|
75
|
+
/** The newest render format this CLI reads, and the newest it writes. */
|
|
76
|
+
export const RENDER_FORMAT: 2;
|
|
77
|
+
export function sha256(bytes: Buffer | string): string;
|
|
78
|
+
export function asParsed(text: string): string;
|
|
31
79
|
export type EmbeddedFile = {
|
|
32
80
|
/**
|
|
33
81
|
* - Path relative to the folder that holds every embedded file, `/`-separated; the page itself first.
|
|
@@ -42,11 +90,42 @@ export type EmbeddedFile = {
|
|
|
42
90
|
*/
|
|
43
91
|
base64: string;
|
|
44
92
|
};
|
|
45
|
-
|
|
46
|
-
|
|
93
|
+
/**
|
|
94
|
+
* What the render records about itself beside the files. Every field is
|
|
95
|
+
* optional: files from older CLIs have none of them.
|
|
96
|
+
*/
|
|
97
|
+
export type RenderRecord = {
|
|
98
|
+
/**
|
|
99
|
+
* - The version of the CLI that rendered the file.
|
|
100
|
+
*/
|
|
101
|
+
cli?: string | undefined;
|
|
47
102
|
/**
|
|
48
|
-
* - The page's
|
|
103
|
+
* - The page's path from its project's root, `/`-separated; outside a project, its path among the files it carries.
|
|
49
104
|
*/
|
|
105
|
+
page?: string | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* - The title given with --title, which a render again needs too.
|
|
108
|
+
*/
|
|
109
|
+
title?: string | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* - The packages the page rendered with, by name: their versions.
|
|
112
|
+
*/
|
|
113
|
+
packages?: Record<string, string> | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* - Each path-alias import a carried module makes that cannot be a package name (`@/…`, `~/…`), as written (without a query), with the embedded path of the carried file it names, so a reverse where no alias names it still finds the file.
|
|
116
|
+
*/
|
|
117
|
+
aliases?: Record<string, string> | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* - The page as rendered, so a reverse can tell what changed after the render: the SHA-256 of the markup in <body> and of the <style> element, and `text`, the base64 of the JSON `{title, runs}` (the title and the markup's runs of text in order). The text stays encoded so that a find-and-replace over the page's text cannot change the record too.
|
|
120
|
+
*/
|
|
121
|
+
markup?: {
|
|
122
|
+
sha256: string;
|
|
123
|
+
style?: string;
|
|
124
|
+
text?: string;
|
|
125
|
+
} | undefined;
|
|
126
|
+
};
|
|
127
|
+
export type EmbeddedSource = RenderRecord & {
|
|
128
|
+
version: number;
|
|
50
129
|
entry: string;
|
|
51
130
|
files: EmbeddedFile[];
|
|
52
131
|
};
|
|
@@ -7,14 +7,63 @@
|
|
|
7
7
|
* it, and its JSON holds each file base64-encoded with its SHA-256, so no text
|
|
8
8
|
* in the source (`</script>` included) can end the block early.
|
|
9
9
|
*
|
|
10
|
+
* The block's `version` is the render format. A CLI reads every format up to
|
|
11
|
+
* its own. The number goes up only when a CLI that reads the current number
|
|
12
|
+
* would read a new file wrong; a new optional field keeps the number, so older
|
|
13
|
+
* CLIs keep reading newer files. A CLI that meets a higher number refuses and
|
|
14
|
+
* names the CLI version that wrote the file.
|
|
15
|
+
*
|
|
10
16
|
* @position foundation/render — used by render-page.mjs and the render subject
|
|
11
17
|
*/
|
|
12
18
|
|
|
13
19
|
import {createHash} from 'node:crypto';
|
|
20
|
+
import {isValidSemver} from '../env/semver.mjs';
|
|
21
|
+
import {decode, readTag, scanHtml} from './html-reader.mjs';
|
|
14
22
|
|
|
15
23
|
/** The script type of the embedded-source block. */
|
|
16
24
|
export const SOURCE_TYPE = 'application/x-astryx-source';
|
|
17
25
|
|
|
26
|
+
/** The newest render format this CLI reads, and the newest it writes. */
|
|
27
|
+
export const RENDER_FORMAT = 2;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* What a format 1 reader refuses besides the page, as a kind no render
|
|
31
|
+
* embeds, and format 2 carries: an `.mts`, `.cts` or `.cjs` module; JSON
|
|
32
|
+
* whose name holds `config`, ends in `rc` or `lock`, or names a manifest;
|
|
33
|
+
* and a module named `config.*` or with a stem that ends in `rc`. A file
|
|
34
|
+
* that carries one says format 2, so a CLI that reads render formats names
|
|
35
|
+
* the CLI that reads it instead of calling the file damaged; every other
|
|
36
|
+
* file says format 1, which every CLI that reads render files opens. The
|
|
37
|
+
* rules stay as format 1 readers have them: a kind a later CLI adds needs a
|
|
38
|
+
* format of its own.
|
|
39
|
+
*/
|
|
40
|
+
const FORMAT_1_REFUSED_MODULE = /\.(?:mts|cts|cjs)$/i;
|
|
41
|
+
const FORMAT_1_CONFIG_JSON =
|
|
42
|
+
/^(package|package-lock|composer|deno|turbo|vercel|nx|lerna|app|bower|now|netlify|firebase|renovate|project|workspace|angular|biome|components)\.jsonc?$|config|(^|[._-])rc\.jsonc?$|(^|[._-])lock\.jsonc?$/i;
|
|
43
|
+
const FORMAT_1_CONFIG_MODULE = /(^|\.)config\.[cm]?[jt]sx?$|^[a-z0-9-]+rc\.[cm]?[jt]s$/i;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether a format 1 reader refuses a carried file other than the page.
|
|
47
|
+
* @param {string} p its path in the file, `/`-separated
|
|
48
|
+
*/
|
|
49
|
+
function format1Refuses(p) {
|
|
50
|
+
const name = p.slice(p.lastIndexOf('/') + 1);
|
|
51
|
+
return (
|
|
52
|
+
FORMAT_1_REFUSED_MODULE.test(name) ||
|
|
53
|
+
(/\.jsonc?$/i.test(name) && FORMAT_1_CONFIG_JSON.test(name)) ||
|
|
54
|
+
FORMAT_1_CONFIG_MODULE.test(name)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The render format a file that carries these files says, the page first.
|
|
60
|
+
* @param {{path: string}[]} files
|
|
61
|
+
* @returns {number}
|
|
62
|
+
*/
|
|
63
|
+
export function formatFor(files) {
|
|
64
|
+
return files.slice(1).some(f => format1Refuses(f.path)) ? 2 : 1;
|
|
65
|
+
}
|
|
66
|
+
|
|
18
67
|
/**
|
|
19
68
|
* @typedef {object} EmbeddedFile
|
|
20
69
|
* @property {string} path - Path relative to the folder that holds every embedded file, `/`-separated; the page itself first.
|
|
@@ -23,31 +72,55 @@ export const SOURCE_TYPE = 'application/x-astryx-source';
|
|
|
23
72
|
*/
|
|
24
73
|
|
|
25
74
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @
|
|
29
|
-
* @property {
|
|
75
|
+
* What the render records about itself beside the files. Every field is
|
|
76
|
+
* optional: files from older CLIs have none of them.
|
|
77
|
+
* @typedef {object} RenderRecord
|
|
78
|
+
* @property {string} [cli] - The version of the CLI that rendered the file.
|
|
79
|
+
* @property {string} [page] - The page's path from its project's root, `/`-separated; outside a project, its path among the files it carries.
|
|
80
|
+
* @property {string} [title] - The title given with --title, which a render again needs too.
|
|
81
|
+
* @property {Record<string, string>} [packages] - The packages the page rendered with, by name: their versions.
|
|
82
|
+
* @property {Record<string, string>} [aliases] - Each path-alias import a carried module makes that cannot be a package name (`@/…`, `~/…`), as written (without a query), with the embedded path of the carried file it names, so a reverse where no alias names it still finds the file.
|
|
83
|
+
* @property {{sha256: string, style?: string, text?: string}} [markup] - The page as rendered, so a reverse can tell what changed after the render: the SHA-256 of the markup in <body> and of the <style> element, and `text`, the base64 of the JSON `{title, runs}` (the title and the markup's runs of text in order). The text stays encoded so that a find-and-replace over the page's text cannot change the record too.
|
|
30
84
|
*/
|
|
31
85
|
|
|
32
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* @typedef {RenderRecord & {version: number, entry: string, files: EmbeddedFile[]}} EmbeddedSource
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/** @param {Buffer | string} bytes */
|
|
33
91
|
export const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
34
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Text as a browser's HTML parser reads it: a CR LF pair or a lone CR is a
|
|
95
|
+
* line feed. A copy whose line ends a mailer, an editor or git changed reads
|
|
96
|
+
* the same.
|
|
97
|
+
* @param {string} text
|
|
98
|
+
*/
|
|
99
|
+
export const asParsed = text => text.replace(/\r\n?/g, '\n');
|
|
100
|
+
|
|
35
101
|
/**
|
|
36
102
|
* The data block for a page's files.
|
|
37
103
|
* @param {string} entry the page's file name
|
|
38
104
|
* @param {{path: string, bytes: Buffer}[]} files the page first
|
|
105
|
+
* @param {RenderRecord} [record] what the render records about itself
|
|
39
106
|
* @returns {string}
|
|
40
107
|
*/
|
|
41
|
-
export function sourceBlock(entry, files) {
|
|
108
|
+
export function sourceBlock(entry, files, record = {}) {
|
|
42
109
|
/** @type {EmbeddedSource} */
|
|
43
110
|
const payload = {
|
|
44
|
-
version:
|
|
111
|
+
version: formatFor(files),
|
|
45
112
|
entry,
|
|
113
|
+
...(record.cli ? {cli: record.cli} : {}),
|
|
114
|
+
...(record.page ? {page: record.page} : {}),
|
|
115
|
+
...(record.title === undefined ? {} : {title: record.title}),
|
|
116
|
+
...(record.packages ? {packages: record.packages} : {}),
|
|
117
|
+
...(record.aliases ? {aliases: record.aliases} : {}),
|
|
46
118
|
files: files.map(f => ({
|
|
47
119
|
path: f.path,
|
|
48
120
|
sha256: sha256(f.bytes),
|
|
49
121
|
base64: f.bytes.toString('base64'),
|
|
50
122
|
})),
|
|
123
|
+
...(record.markup ? {markup: record.markup} : {}),
|
|
51
124
|
};
|
|
52
125
|
const json = JSON.stringify(payload)
|
|
53
126
|
.replace(/</g, '\\u003c')
|
|
@@ -56,33 +129,107 @@ export function sourceBlock(entry, files) {
|
|
|
56
129
|
return `<script type="${SOURCE_TYPE}">${json}</script>`;
|
|
57
130
|
}
|
|
58
131
|
|
|
132
|
+
/**
|
|
133
|
+
* The parts of a rendered file a reverse reads, found as a browser finds them:
|
|
134
|
+
* outside comments (the note is one, and it may quote a path that looks like
|
|
135
|
+
* a tag) and outside the text of a style, script, title or textarea element
|
|
136
|
+
* (a stylesheet may hold any text).
|
|
137
|
+
* @param {string} html
|
|
138
|
+
* @returns {{title: string | null, style: string | null, body: number}} the
|
|
139
|
+
* text of the first title and the first style element before <body>, and
|
|
140
|
+
* where the content of <body> starts (-1 without a <body> tag)
|
|
141
|
+
*/
|
|
142
|
+
function pageParts(html) {
|
|
143
|
+
/** @type {string | null} */
|
|
144
|
+
let title = null;
|
|
145
|
+
/** @type {string | null} */
|
|
146
|
+
let style = null;
|
|
147
|
+
let styleStart = -1;
|
|
148
|
+
let titleNext = false;
|
|
149
|
+
for (const token of scanHtml(html)) {
|
|
150
|
+
if (token.kind === 'start') {
|
|
151
|
+
if (token.tag === 'body') return {title, style, body: token.end};
|
|
152
|
+
titleNext = token.tag === 'title' && title === null;
|
|
153
|
+
if (token.tag === 'style' && styleStart < 0) styleStart = token.start;
|
|
154
|
+
} else if (token.kind === 'raw' && titleNext) {
|
|
155
|
+
title = html.slice(token.start, token.end);
|
|
156
|
+
titleNext = false;
|
|
157
|
+
} else if (token.kind === 'end' && token.tag === 'style' && styleStart >= 0 && style === null) {
|
|
158
|
+
style = html.slice(styleStart, token.end);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return {title, style, body: -1};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Whether a script tag's attributes give it the source type. A MIME type is
|
|
166
|
+
* matched without regard to letter case.
|
|
167
|
+
* @param {Array<[string, string]>} attrs
|
|
168
|
+
*/
|
|
169
|
+
const isSourceType = attrs => {
|
|
170
|
+
const type = attrs.find(([name]) => name === 'type')?.[1];
|
|
171
|
+
return type !== undefined && decode(type).trim().toLowerCase() === SOURCE_TYPE;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Every embedded-source block in a file's body, in order: each script
|
|
176
|
+
* element whose type is the source type, its tag read as a browser reads a
|
|
177
|
+
* tag, with its attributes in any order, quoted or not, in any letter case
|
|
178
|
+
* (a minifier rewrites it so). Every `<script` from the start of the body on
|
|
179
|
+
* is read this way, inside a comment or other text too, so a hand edit that
|
|
180
|
+
* leaves a comment or a textarea open before the block does not hide it. The
|
|
181
|
+
* note in <head> may quote a title or a path with any text, so the search
|
|
182
|
+
* starts at <body>.
|
|
183
|
+
* @param {string} html
|
|
184
|
+
* @returns {{index: number, json: string, closed: boolean}[]} where each
|
|
185
|
+
* opening tag starts, the text of the block, and whether its end tag is
|
|
186
|
+
* there (a file cut inside the block has none)
|
|
187
|
+
*/
|
|
188
|
+
const blocksIn = html => {
|
|
189
|
+
/** @type {{index: number, json: string, closed: boolean}[]} */
|
|
190
|
+
const blocks = [];
|
|
191
|
+
const opening = /<script(?=[\t\n\f\r />])/gi;
|
|
192
|
+
opening.lastIndex = Math.max(0, pageParts(html).body);
|
|
193
|
+
for (let m = opening.exec(html); m; m = opening.exec(html)) {
|
|
194
|
+
const tag = readTag(html, m.index + 1);
|
|
195
|
+
if (typeof tag !== 'object' || !isSourceType(tag.attrs)) continue;
|
|
196
|
+
const closing = /<\/script/gi;
|
|
197
|
+
closing.lastIndex = tag.end;
|
|
198
|
+
const end = closing.exec(html)?.index;
|
|
199
|
+
blocks.push({index: m.index, json: html.slice(tag.end, end ?? html.length), closed: end !== undefined});
|
|
200
|
+
opening.lastIndex = end ?? html.length;
|
|
201
|
+
}
|
|
202
|
+
return blocks;
|
|
203
|
+
};
|
|
204
|
+
|
|
59
205
|
/**
|
|
60
206
|
* Read the embedded source from a rendered file.
|
|
61
207
|
* @param {string} html
|
|
62
|
-
* @returns {{found: false} | {found: true, source: EmbeddedSource} | {found: true, damaged: string}}
|
|
208
|
+
* @returns {{found: false} | {found: true, source: EmbeddedSource} | {found: true, damaged: string} | {found: true, newer: {format: number, cli: string | null}}}
|
|
63
209
|
*/
|
|
64
210
|
export function readSourceBlock(html) {
|
|
65
|
-
const all = [
|
|
66
|
-
...html.matchAll(
|
|
67
|
-
new RegExp(
|
|
68
|
-
`<script\\s+type=["']${SOURCE_TYPE.replace(/[/+.-]/g, c => `\\${c}`)}["'][^>]*>([\\s\\S]*?)</script>`,
|
|
69
|
-
'gi',
|
|
70
|
-
),
|
|
71
|
-
),
|
|
72
|
-
];
|
|
73
211
|
// The block is written last in the body; a page's own markup cannot end
|
|
74
212
|
// it, so the last one is the CLI's.
|
|
75
|
-
const
|
|
76
|
-
if (!
|
|
213
|
+
const block = blocksIn(html).at(-1);
|
|
214
|
+
if (!block) return {found: false};
|
|
215
|
+
if (!block.closed) return {found: true, damaged: 'its embedded source is cut short: the file ends inside it'};
|
|
77
216
|
/** @type {any} */
|
|
78
217
|
let payload;
|
|
79
218
|
try {
|
|
80
|
-
payload = JSON.parse(
|
|
219
|
+
payload = JSON.parse(block.json);
|
|
81
220
|
} catch {
|
|
82
221
|
return {found: true, damaged: 'its embedded source is not valid JSON'};
|
|
83
222
|
}
|
|
223
|
+
// A CLI version that is not a semantic version is never a render's: the
|
|
224
|
+
// file was changed, and the value would reach a printed command.
|
|
225
|
+
if (payload?.cli !== undefined && !isValidSemver(payload.cli)) {
|
|
226
|
+
return {found: true, damaged: 'its embedded source names a CLI version that is not a release version'};
|
|
227
|
+
}
|
|
228
|
+
if (Number.isInteger(payload?.version) && payload.version > RENDER_FORMAT) {
|
|
229
|
+
return {found: true, newer: {format: payload.version, cli: isValidSemver(payload.cli) ? payload.cli : null}};
|
|
230
|
+
}
|
|
84
231
|
if (
|
|
85
|
-
payload?.version
|
|
232
|
+
!(Number.isInteger(payload?.version) && payload.version >= 1) ||
|
|
86
233
|
typeof payload.entry !== 'string' ||
|
|
87
234
|
!Array.isArray(payload.files) ||
|
|
88
235
|
payload.files.length === 0
|
|
@@ -104,3 +251,47 @@ export function readSourceBlock(html) {
|
|
|
104
251
|
}
|
|
105
252
|
return {found: true, source: payload};
|
|
106
253
|
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The markup between `<body>` and the embedded source: what a render wrote
|
|
257
|
+
* there, unless someone changed it since. Null when the file no longer has
|
|
258
|
+
* that shape.
|
|
259
|
+
* @param {string} html
|
|
260
|
+
* @returns {string | null}
|
|
261
|
+
*/
|
|
262
|
+
export function renderedMarkupOf(html) {
|
|
263
|
+
const block = blocksIn(html).at(-1);
|
|
264
|
+
if (!block) return null;
|
|
265
|
+
const start = pageParts(html).body;
|
|
266
|
+
return start < 0 || start > block.index ? null : html.slice(start, block.index);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* The title and the <style> element a render wrote in <head>, unless someone
|
|
271
|
+
* changed them since.
|
|
272
|
+
* @param {string} html
|
|
273
|
+
* @returns {{title: string | null, style: string | null}}
|
|
274
|
+
*/
|
|
275
|
+
export function renderedHeadOf(html) {
|
|
276
|
+
const {title, style} = pageParts(html);
|
|
277
|
+
return {title, style};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* The title and the runs of text a record keeps, or null when the record
|
|
282
|
+
* keeps none or they do not decode.
|
|
283
|
+
* @param {{text?: unknown}} markup
|
|
284
|
+
* @returns {{title: string | null, runs: string[]} | null}
|
|
285
|
+
*/
|
|
286
|
+
export function recordedText(markup) {
|
|
287
|
+
if (typeof markup.text !== 'string') return null;
|
|
288
|
+
try {
|
|
289
|
+
const parsed = JSON.parse(Buffer.from(markup.text, 'base64').toString('utf8'));
|
|
290
|
+
return {
|
|
291
|
+
title: typeof parsed?.title === 'string' ? parsed.title : null,
|
|
292
|
+
runs: Array.isArray(parsed?.runs) ? parsed.runs.filter((/** @type {unknown} */ r) => typeof r === 'string') : [],
|
|
293
|
+
};
|
|
294
|
+
} catch {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
@@ -2,12 +2,27 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The path patterns
|
|
6
|
-
*
|
|
7
|
-
* @param {string}
|
|
8
|
-
* @returns {PathPattern[]
|
|
5
|
+
* The path patterns that apply to a file, which need not exist yet: those of
|
|
6
|
+
* the config TypeScript reads for it (see configFor).
|
|
7
|
+
* @param {string} file absolute
|
|
8
|
+
* @returns {PathPattern[]}
|
|
9
9
|
*/
|
|
10
|
-
export function
|
|
10
|
+
export function pathsFor(file: string): PathPattern[];
|
|
11
|
+
/**
|
|
12
|
+
* Where `paths` entries for a file belong: the config TypeScript reads for
|
|
13
|
+
* it, else a new `tsconfig.json` in `fallbackDir`; the folder the entries'
|
|
14
|
+
* targets resolve from there (its `baseUrl`, else that config's own folder,
|
|
15
|
+
* which writes the entries); and the patterns it has now, its own or
|
|
16
|
+
* inherited through `extends` (a `paths` of its own replaces inherited ones).
|
|
17
|
+
* @param {string} file absolute, which need not exist yet
|
|
18
|
+
* @param {string} fallbackDir absolute: where a project with no config would add one
|
|
19
|
+
* @returns {{config: string, base: string, current: PathPattern[]}}
|
|
20
|
+
*/
|
|
21
|
+
export function pathsHomeFor(file: string, fallbackDir: string): {
|
|
22
|
+
config: string;
|
|
23
|
+
base: string;
|
|
24
|
+
current: PathPattern[];
|
|
25
|
+
};
|
|
11
26
|
/**
|
|
12
27
|
* The pattern a specifier matches by TypeScript's rules, and what its `*`
|
|
13
28
|
* matched: an exact key first, else the wildcard key with the longest prefix.
|
|
@@ -23,9 +38,10 @@ export function matchPath(patterns: PathPattern[], spec: string): {
|
|
|
23
38
|
* The file a candidate path stands for: itself, with an extension, or its
|
|
24
39
|
* folder's index; null when none exists.
|
|
25
40
|
* @param {string} candidate
|
|
41
|
+
* @param {readonly string[]} [extensions] the extensions to try, in order (default: TypeScript's)
|
|
26
42
|
* @returns {string | null}
|
|
27
43
|
*/
|
|
28
|
-
export function existingFile(candidate: string): string | null;
|
|
44
|
+
export function existingFile(candidate: string, extensions?: readonly string[]): string | null;
|
|
29
45
|
/**
|
|
30
46
|
* Resolve a specifier through path patterns: the first target that names an
|
|
31
47
|
* existing file wins.
|
|
@@ -35,10 +51,57 @@ export function existingFile(candidate: string): string | null;
|
|
|
35
51
|
* pattern or no target exists
|
|
36
52
|
*/
|
|
37
53
|
export function resolvePath(patterns: PathPattern[], spec: string): string | null;
|
|
54
|
+
/** The extensions the render's module loader tries for an extensionless import, in its order. */
|
|
55
|
+
export const LOAD_EXTENSIONS: string[];
|
|
38
56
|
export function candidatesOf(match: {
|
|
39
57
|
pattern: PathPattern;
|
|
40
58
|
capture: string;
|
|
41
59
|
}): string[];
|
|
60
|
+
export type ReadConfig = {
|
|
61
|
+
/**
|
|
62
|
+
* - Compiler options, the extending config's winning key by key.
|
|
63
|
+
*/
|
|
64
|
+
options: Record<string, unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* - The folder of the config that writes `baseUrl`.
|
|
67
|
+
*/
|
|
68
|
+
baseUrlDir: string;
|
|
69
|
+
/**
|
|
70
|
+
* - The folder of the config that writes `paths`.
|
|
71
|
+
*/
|
|
72
|
+
pathsDir: string;
|
|
73
|
+
/**
|
|
74
|
+
* - The config that writes `paths`, if any does.
|
|
75
|
+
*/
|
|
76
|
+
pathsFile: string | null;
|
|
77
|
+
/**
|
|
78
|
+
* - `files`, from the nearest config that writes it, with that config's folder.
|
|
79
|
+
*/
|
|
80
|
+
files: {
|
|
81
|
+
list: unknown[];
|
|
82
|
+
dir: string;
|
|
83
|
+
} | null;
|
|
84
|
+
/**
|
|
85
|
+
* - `include`, likewise.
|
|
86
|
+
*/
|
|
87
|
+
include: {
|
|
88
|
+
list: unknown[];
|
|
89
|
+
dir: string;
|
|
90
|
+
} | null;
|
|
91
|
+
/**
|
|
92
|
+
* - `exclude`, likewise.
|
|
93
|
+
*/
|
|
94
|
+
exclude: {
|
|
95
|
+
list: unknown[];
|
|
96
|
+
dir: string;
|
|
97
|
+
} | null;
|
|
98
|
+
/**
|
|
99
|
+
* - The config's own `references`.
|
|
100
|
+
*/
|
|
101
|
+
references: {
|
|
102
|
+
path?: unknown;
|
|
103
|
+
}[];
|
|
104
|
+
};
|
|
42
105
|
export type PathPattern = {
|
|
43
106
|
/**
|
|
44
107
|
* - The key as written.
|