@astryxdesign/cli 0.6.3-canary.98a2e4e → 0.6.3-canary.a860a50
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 +32 -18
- package/api/build/build.doc.mjs +3 -3
- package/api/build/build.test.mjs +14 -3
- package/api/build/build.type.d.mts +36 -2
- package/api/build/build.type.mjs +25 -4
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/component.doc.mjs +11 -2
- package/api/component/component.mjs +29 -0
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +17 -7
- package/api/component/component.type.mjs +27 -20
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.type.d.mts +4 -4
- package/api/discover/discover.type.mjs +10 -10
- package/api/docs/_adapter.d.mts +30 -27
- package/api/docs/_adapter.mjs +154 -124
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.d.mts +0 -15
- package/api/docs/detail/detail.mjs +14 -78
- package/api/docs/detail/section/section.mjs +22 -18
- package/api/docs/detail/section/section.test.mjs +4 -3
- package/api/docs/docs.type.d.mts +4 -4
- package/api/docs/docs.type.mjs +10 -10
- package/api/docs/index/index.mjs +6 -5
- package/api/doctor/doctor.mjs +3 -7
- package/api/gap-report/gap-report.doc.mjs +7 -4
- package/api/hook/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- package/api/init/init.doc.mjs +4 -0
- package/api/init/init.test.mjs +41 -1
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +20 -10
- package/api/integration/add-contribution.component-names.test.mjs +120 -0
- package/api/integration/add-contribution.mjs +16 -3
- package/api/integration/add-contribution.test.mjs +84 -4
- package/api/integration/integrationAdd.doc.mjs +7 -4
- package/api/integration/integrationAddComponent.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +49 -7
- package/api/integration/pack-check.test.mjs +249 -0
- package/api/integration/validate-integration.mjs +2 -0
- package/api/integration/validate-integration.test.mjs +91 -0
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/parseResponse.doc.mjs +2 -2
- package/api/layout/expand/expand.mjs +7 -5
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.mjs +2 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search-return-type.test.mjs +54 -0
- package/api/search/search.d.mts +2 -9
- package/api/search/search.doc.mjs +5 -1
- package/api/search/search.mjs +15 -8
- package/api/search/search.test.mjs +34 -0
- package/api/search/search.type.d.mts +1 -1
- package/api/search/search.type.mjs +1 -1
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +1 -1
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/template.doc.mjs +2 -1
- package/api/template/template.type.d.mts +5 -5
- package/api/template/template.type.mjs +12 -12
- package/api/theme/add/add.binary.test.mjs +91 -0
- package/api/theme/add/add.mjs +15 -2
- package/api/theme/build/build.mjs +133 -42
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/build.receipt-doc.test.mjs +111 -0
- package/api/theme/build/build.test.mjs +127 -0
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +5 -2
- package/api/theme/palette/generate/generate.mjs +8 -3
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.d.mts +10 -13
- package/api/theme/palette/generate/generator.mjs +15 -4
- package/api/theme/palette/generate/generator.test.mjs +10 -0
- package/api/theme/template/template.mjs +11 -2
- package/api/theme/template/template.test.mjs +15 -0
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/theme/themeBuild.doc.mjs +7 -4
- package/api/theme/themeTemplate.doc.mjs +4 -1
- package/api/upgrade/_adapter.mjs +27 -4
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +2 -1
- package/api/upgrade/upgrade.type.d.mts +8 -4
- package/api/upgrade/upgrade.type.mjs +11 -10
- package/assets/codemods/integration-discovery.mjs +40 -2
- package/assets/codemods/integration-discovery.test.mjs +58 -0
- package/assets/codemods/term-log.mjs +32 -8
- package/assets/codemods/term-log.test.mjs +19 -1
- package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
- package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
- package/assets/docs/cli-integrations.doc.mjs +9 -0
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- package/assets/templates/pages/table-tree/page.tsx +1704 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
- package/authoring/_shared/contract.ts +22 -0
- package/authoring/codemod/codemod.doc.mjs +6 -1
- package/authoring/codemod/parse.d.mts +8 -8
- package/authoring/codemod/parse.mjs +8 -6
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +13 -13
- package/authoring/config/parse.mjs +8 -8
- package/authoring/config/type.ts +18 -6
- package/authoring/debug/parse.d.mts +4 -4
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +121 -11
- package/authoring/doctypes/_schema.mjs +144 -13
- package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
- package/authoring/doctypes/base/type.ts +8 -4
- package/authoring/doctypes/command/command.doc.mjs +3 -2
- package/authoring/doctypes/command/parse.d.mts +2 -2
- package/authoring/doctypes/command/parse.mjs +1 -1
- package/authoring/doctypes/command/type.ts +2 -2
- package/authoring/doctypes/component/component.doc.mjs +5 -2
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +1 -1
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +1 -1
- package/authoring/doctypes/function/function.doc.mjs +4 -0
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +1 -1
- package/authoring/doctypes/hook/hook.doc.mjs +4 -0
- package/authoring/doctypes/hook/parse.d.mts +2 -2
- package/authoring/doctypes/hook/parse.mjs +1 -1
- package/authoring/doctypes/hook/type.ts +1 -1
- package/authoring/doctypes/legacy.d.mts +6 -6
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/load-contract.test.mjs +207 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
- package/authoring/doctypes/namespace/parse.d.mts +2 -2
- package/authoring/doctypes/namespace/parse.mjs +1 -1
- package/authoring/doctypes/namespace/type.ts +2 -2
- package/authoring/doctypes/parse.d.mts +18 -18
- package/authoring/doctypes/parse.mjs +9 -9
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +1 -1
- package/authoring/doctypes/reference/reference.doc.mjs +6 -2
- package/authoring/doctypes/reference/type.ts +1 -1
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +2 -2
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +33 -1
- package/authoring/doctypes/template/template.doc.mjs +4 -0
- package/authoring/doctypes/template/type.ts +4 -1
- package/authoring/doctypes/types.ts +10 -10
- package/authoring/gap-report/parse.d.mts +9 -9
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.mjs +3 -2
- package/authoring/identity/type.ts +10 -10
- package/authoring/index.d.ts +19 -19
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/schema.d.mts +4 -4
- package/authoring/integration/schema.mjs +3 -3
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/command-load-failure.test.mjs +83 -0
- package/clients/cli/commands/blog.mjs +23 -8
- package/clients/cli/commands/blog.test.mjs +42 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
- package/clients/cli/commands/build-theme.mjs +5 -5
- package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
- package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
- package/clients/cli/commands/build.doc.mjs +4 -1
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +32 -47
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +40 -0
- package/clients/cli/commands/component/index.mjs +2 -7
- package/clients/cli/commands/component-package.test.mjs +18 -0
- package/clients/cli/commands/component-resolution.test.mjs +21 -0
- package/clients/cli/commands/component.test.mjs +19 -0
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +4 -2
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
- package/clients/cli/commands/doctor.mjs +6 -16
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +16 -5
- package/clients/cli/commands/gap-report.test.mjs +72 -0
- package/clients/cli/commands/hook/index.mjs +7 -17
- package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
- package/clients/cli/commands/init.doc.mjs +19 -8
- package/clients/cli/commands/init.flag-help.test.mjs +153 -0
- package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
- package/clients/cli/commands/integration-add.doc.mjs +21 -5
- package/clients/cli/commands/integration-authoring.test.mjs +13 -9
- package/clients/cli/commands/interactive-guard.test.mjs +101 -24
- package/clients/cli/commands/json-contract.test.mjs +33 -0
- package/clients/cli/commands/layout-check.doc.mjs +14 -3
- package/clients/cli/commands/layout-expand.doc.mjs +21 -4
- package/clients/cli/commands/layout.doc.mjs +2 -2
- package/clients/cli/commands/layout.mjs +21 -9
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +5 -2
- package/clients/cli/commands/search.mjs +13 -2
- package/clients/cli/commands/search.test.mjs +61 -0
- package/clients/cli/commands/swizzle.doc.mjs +2 -1
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +28 -6
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/theme-add.doc.mjs +2 -1
- package/clients/cli/commands/theme-build.doc.mjs +7 -6
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +17 -6
- package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
- package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
- package/clients/cli/index.mjs +13 -30
- package/clients/cli/latest-version-env.test.mjs +50 -0
- package/clients/cli/lib/cli-error.test.mjs +7 -0
- package/clients/cli/lib/component-format.mjs +9 -9
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +32 -6
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +97 -0
- package/clients/cli/lib/hook-format.mjs +5 -5
- package/clients/cli/lib/json-shim.mjs +38 -2
- package/clients/cli/lib/json-shim.test.mjs +83 -0
- package/clients/cli/lib/manifest.d.ts +2 -0
- package/clients/cli/lib/manifest.mjs +22 -0
- package/clients/cli/lib/manifest.test.mjs +17 -0
- package/foundation/agent-docs/agent-docs.d.mts +4 -0
- package/foundation/agent-docs/agent-docs.mjs +69 -3
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project.mjs +123 -9
- package/foundation/config/project.test.mjs +126 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +71 -12
- package/foundation/discovery/docs-discovery.d.mts +4 -0
- package/foundation/discovery/docs-discovery.mjs +16 -2
- package/foundation/discovery/docs-discovery.test.mjs +47 -11
- package/foundation/discovery/template-adapter.d.mts +14 -5
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
- package/foundation/discovery/template-adapter.mjs +292 -25
- package/foundation/discovery/theming-targets.test.mjs +4 -0
- package/foundation/doc-compiler/compile.d.mts +162 -0
- package/foundation/doc-compiler/compile.mjs +262 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +687 -0
- package/foundation/doc-compiler/ir.d.mts +9 -0
- package/foundation/doc-compiler/ir.mjs +287 -0
- package/foundation/doc-compiler/lenses.d.mts +33 -0
- package/foundation/doc-compiler/lenses.mjs +127 -0
- package/foundation/fs/module-loader.d.mts +1 -0
- package/foundation/fs/module-loader.mjs +50 -1
- package/foundation/fs/module-loader.stdout.test.mjs +332 -0
- package/foundation/fs/path-safety.d.mts +3 -2
- package/foundation/fs/path-safety.mjs +49 -19
- package/foundation/fs/path-safety.test.mjs +50 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
- package/foundation/integrations/autolink.mjs +6 -1
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.doc.mjs +1 -2
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/error-codes.test.mjs +83 -0
- package/foundation/response/json-contract.test.mjs +11 -0
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +3 -3
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +3 -2
- package/foundation/xle/expand.test.mjs +54 -0
- package/package.json +9 -11
- package/clients/cli/lib/update-check.mjs +0 -83
- package/clients/cli/lib/update-check.test.mjs +0 -137
- package/clients/cli/update-hint-commands.test.mjs +0 -54
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Colocated types for the `component` command — source of truth for the
|
|
5
5
|
* component command's JSON responses. These typedefs describe the `{type, data}`
|
|
6
|
-
* envelopes emitted by `
|
|
6
|
+
* envelopes emitted by `astryx --json component` and returned by the `component()`
|
|
7
7
|
* API; the `types/component.d.ts` barrel re-exports them for consumers.
|
|
8
8
|
*
|
|
9
9
|
* Detail-level contract for list views (brief < compact < full):
|
|
@@ -11,23 +11,23 @@
|
|
|
11
11
|
* --detail compact Names + 1-line description + import path.
|
|
12
12
|
* --detail full Full ComponentDoc per entry (props, theming, examples, etc.).
|
|
13
13
|
*
|
|
14
|
-
* Invocation
|
|
14
|
+
* Invocation -> type discriminator
|
|
15
15
|
* ------------------------------------------------------------------
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* (not found)
|
|
16
|
+
* astryx --json component -> component.list (data.detail='names')
|
|
17
|
+
* astryx --json component --list -> component.list (data.detail='names')
|
|
18
|
+
* astryx --json component --category Form -> component.list (filtered)
|
|
19
|
+
* astryx --json component --list --detail compact -> component.list (data.detail='compact')
|
|
20
|
+
* astryx --json component --list --detail full -> component.list (data.detail='full')
|
|
21
|
+
* astryx --json component Button -> component.detail
|
|
22
|
+
* astryx --json component Button --props -> component.detail.props
|
|
23
|
+
* astryx --json component Button --source -> component.detail.source
|
|
24
|
+
* astryx --json component Button --showcase -> component.detail.showcase
|
|
25
|
+
* astryx --json component Button --blocks -> component.detail.blocks
|
|
26
|
+
* (not found) -> CLIError
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* astryx --json component [--list] [--category X] [--detail names|compact|full]
|
|
31
31
|
*
|
|
32
32
|
* The list view emits ONE `component.list` type across all three detail levels;
|
|
33
33
|
* the depth is carried in `data.detail` and `data.components` holds the grouped
|
|
@@ -70,10 +70,17 @@
|
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* astryx --json component <name>
|
|
74
74
|
* @typedef {object} ComponentDetailResponse
|
|
75
75
|
* @property {'component.detail'} type
|
|
76
|
-
* @property {import('@astryxdesign/cli/authoring').ComponentDoc & ComponentOwnership} data
|
|
76
|
+
* @property {import('@astryxdesign/cli/authoring').ComponentDoc & ComponentOwnership & ComponentDetailScope} data
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Present only when the requested name is a sub-component documented inside a
|
|
81
|
+
* parent's doc (e.g. `HStack` in the `Stack` doc); the payload is scoped to it.
|
|
82
|
+
* @typedef {object} ComponentDetailScope
|
|
83
|
+
* @property {string} [parentDoc] - Name of the parent doc the payload was scoped from, e.g. 'Stack'.
|
|
77
84
|
*/
|
|
78
85
|
|
|
79
86
|
/**
|
|
@@ -87,28 +94,28 @@
|
|
|
87
94
|
*/
|
|
88
95
|
|
|
89
96
|
/**
|
|
90
|
-
*
|
|
97
|
+
* astryx --json component <name> --props
|
|
91
98
|
* @typedef {object} ComponentDetailPropsResponse
|
|
92
99
|
* @property {'component.detail.props'} type
|
|
93
100
|
* @property {import('@astryxdesign/cli/authoring').ComponentPropDoc[]} data
|
|
94
101
|
*/
|
|
95
102
|
|
|
96
103
|
/**
|
|
97
|
-
*
|
|
104
|
+
* astryx --json component <name> --source
|
|
98
105
|
* @typedef {object} ComponentDetailSourceResponse
|
|
99
106
|
* @property {'component.detail.source'} type
|
|
100
107
|
* @property {{component: string; source: string}} data
|
|
101
108
|
*/
|
|
102
109
|
|
|
103
110
|
/**
|
|
104
|
-
*
|
|
111
|
+
* astryx --json component <name> --showcase
|
|
105
112
|
* @typedef {object} ComponentDetailShowcaseResponse
|
|
106
113
|
* @property {'component.detail.showcase'} type
|
|
107
114
|
* @property {{component: string; aspectRatio: number; source: string}} data
|
|
108
115
|
*/
|
|
109
116
|
|
|
110
117
|
/**
|
|
111
|
-
*
|
|
118
|
+
* astryx --json component <name> --blocks
|
|
112
119
|
* @typedef {object} ComponentDetailBlocksResponse
|
|
113
120
|
* @property {'component.detail.blocks'} type
|
|
114
121
|
* @property {{component: string; showcase: BlockEntry | null; examples: BlockEntry[]; related: BlockEntry[]}} data
|
|
@@ -41,7 +41,7 @@ export const doc = {
|
|
|
41
41
|
name: 'options.components',
|
|
42
42
|
type: 'boolean',
|
|
43
43
|
description:
|
|
44
|
-
'
|
|
44
|
+
'In the CLI package list, print every component of each package instead of the first 10. A display flag for the CLI renderer; the programmatic response is unchanged.',
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
name: 'options.lang',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* astryx --json discover
|
|
6
6
|
*/
|
|
7
7
|
export type DiscoverListResponse = {
|
|
8
8
|
type: "discover.list";
|
|
@@ -25,21 +25,21 @@ export type DiscoverListEntry = {
|
|
|
25
25
|
displayName?: string | undefined;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* astryx --json discover
|
|
29
29
|
*/
|
|
30
30
|
export type DiscoverDetailResponse = {
|
|
31
31
|
type: "discover.detail";
|
|
32
32
|
data: DiscoverListEntry;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* astryx --json discover
|
|
36
36
|
*/
|
|
37
37
|
export type DiscoverDetailDocResponse = {
|
|
38
38
|
type: "discover.detail.doc";
|
|
39
39
|
data: import("@astryxdesign/cli/authoring").ComponentDoc;
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* astryx --json discover <searchterm> (multiple matches)
|
|
43
43
|
*/
|
|
44
44
|
export type DiscoverSearchResponse = {
|
|
45
45
|
type: "discover.search";
|
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Invocation -> type discriminator
|
|
8
8
|
* ------------------------------------------------------------------
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* (not found)
|
|
9
|
+
* astryx --json discover -> discover.list
|
|
10
|
+
* astryx --json discover @scope/name -> discover.detail
|
|
11
|
+
* astryx --json discover @scope/name/Component -> discover.detail.doc
|
|
12
|
+
* astryx --json discover <searchterm> (1 match) -> discover.detail.doc
|
|
13
|
+
* astryx --json discover <searchterm> (N matches) -> discover.search
|
|
14
|
+
* (not found) -> CLIError
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* astryx --json discover
|
|
19
19
|
* @typedef {object} DiscoverListResponse
|
|
20
20
|
* @property {'discover.list'} type
|
|
21
21
|
* @property {DiscoverListEntry[]} data
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* astryx --json discover @scope/name
|
|
39
39
|
* @typedef {object} DiscoverDetailResponse
|
|
40
40
|
* @property {'discover.detail'} type
|
|
41
41
|
* @property {DiscoverListEntry} data
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* astryx --json discover @scope/name/Component
|
|
46
46
|
* @typedef {object} DiscoverDetailDocResponse
|
|
47
47
|
* @property {'discover.detail.doc'} type
|
|
48
48
|
* @property {import('@astryxdesign/cli/authoring').ComponentDoc} data
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* astryx --json discover <searchterm> (multiple matches)
|
|
53
53
|
* @typedef {object} DiscoverSearchResponse
|
|
54
54
|
* @property {'discover.search'} type
|
|
55
55
|
* @property {{query: string, matches: DiscoverSearchEntry[]}} data
|
package/api/docs/_adapter.d.mts
CHANGED
|
@@ -16,40 +16,43 @@
|
|
|
16
16
|
*/
|
|
17
17
|
export function loadDocsCatalog(cwd?: string): Promise<DocsCatalog>;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {
|
|
21
|
-
* @returns {
|
|
19
|
+
* The overlay languages a topic ships for its own file or any extension.
|
|
20
|
+
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
21
|
+
* @returns {string[]}
|
|
22
22
|
*/
|
|
23
|
-
export function
|
|
24
|
-
lang?: string | null;
|
|
25
|
-
}): Promise<import("./docs.type.mjs").DocsDetailResponse["data"]>;
|
|
23
|
+
export function overlayLanguages(entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry): string[];
|
|
26
24
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* `--dense`/`--zh` (it replaces its own sections and leaves the rest
|
|
33
|
-
* translated) rather than being dropped.
|
|
34
|
-
*
|
|
25
|
+
* One topic, lowered for `lang`: overlaid, extensions merged, keys stamped.
|
|
26
|
+
* Memoized per catalog, so a read that references a topic twice loads it once.
|
|
27
|
+
* Every read of the catalog shares the memoized node, so it is frozen; the
|
|
28
|
+
* lenses hand readers copies.
|
|
29
|
+
* @param {DocsCatalog} catalog
|
|
35
30
|
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
36
|
-
* @param {
|
|
37
|
-
* @returns {Promise<import('
|
|
31
|
+
* @param {string | null} [lang]
|
|
32
|
+
* @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
|
|
38
33
|
*/
|
|
39
|
-
export function
|
|
40
|
-
lang?: string | null;
|
|
41
|
-
}): Promise<import("./docs.type.mjs").DocsDetailResponse["data"]>;
|
|
34
|
+
export function lowerTopic(catalog: DocsCatalog, entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry, lang?: string | null): Promise<import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode>;
|
|
42
35
|
/**
|
|
43
|
-
*
|
|
36
|
+
* How a token reference finds its target: the topic it names in `catalog`,
|
|
37
|
+
* lowered for the same language.
|
|
38
|
+
* @param {DocsCatalog} catalog
|
|
39
|
+
* @param {string | null} lang
|
|
40
|
+
* @returns {(topic: string) => Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode | null>}
|
|
41
|
+
*/
|
|
42
|
+
export function referenceTargets(catalog: DocsCatalog, lang: string | null): (topic: string) => Promise<import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode | null>;
|
|
43
|
+
/**
|
|
44
|
+
* One topic, compiled for `lang`: lowered, then every token reference linked.
|
|
45
|
+
* @param {DocsCatalog} catalog
|
|
44
46
|
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
45
|
-
* @
|
|
47
|
+
* @param {string | null} [lang]
|
|
48
|
+
* @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
|
|
46
49
|
*/
|
|
47
|
-
export function
|
|
50
|
+
export function compileTopic(catalog: DocsCatalog, entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry, lang?: string | null): Promise<import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode>;
|
|
48
51
|
/**
|
|
49
52
|
* Resolve `topic` against the project's catalog (throwing `ERR_UNKNOWN_TOPIC`
|
|
50
|
-
* when unmatched)
|
|
51
|
-
* integration extension applied. Shared by the
|
|
52
|
-
*
|
|
53
|
+
* when unmatched) and lower it with any --dense/--zh overlay and any
|
|
54
|
+
* integration extension applied. Shared by the leaves so topic normalization
|
|
55
|
+
* and unknown-topic handling live in exactly one place.
|
|
53
56
|
*
|
|
54
57
|
* @param {string} topic
|
|
55
58
|
* @param {object} [options]
|
|
@@ -59,7 +62,7 @@ export function overlayLanguages(entry: import("../../foundation/discovery/docs-
|
|
|
59
62
|
* @param {string} [options.cwd]
|
|
60
63
|
* @returns {Promise<{
|
|
61
64
|
* catalog: DocsCatalog,
|
|
62
|
-
*
|
|
65
|
+
* node: import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode,
|
|
63
66
|
* lang: string | null,
|
|
64
67
|
* }>}
|
|
65
68
|
*/
|
|
@@ -70,7 +73,7 @@ export function resolveTopicDocs(topic: string, options?: {
|
|
|
70
73
|
cwd?: string | undefined;
|
|
71
74
|
}): Promise<{
|
|
72
75
|
catalog: DocsCatalog;
|
|
73
|
-
|
|
76
|
+
node: import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode;
|
|
74
77
|
lang: string | null;
|
|
75
78
|
}>;
|
|
76
79
|
/** The localized overlays a docs read can apply. */
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -7,29 +7,24 @@
|
|
|
7
7
|
* packages/cli/assets/docs/{topic}.doc.mjs plus every topic the configured
|
|
8
8
|
* integrations contribute — and, when a --dense/--zh overlay is requested,
|
|
9
9
|
* the sibling {topic}.doc.dense.mjs / {topic}.doc.zh.mjs.
|
|
10
|
-
* @output Catalog access,
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @position Sits beside docs.mjs (api/docs/).
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* @output Catalog access, the compiler input for a topic, and the compiled
|
|
11
|
+
* node for it: lowered (overlaid, extensions merged, keys stamped) or linked
|
|
12
|
+
* (token references resolved too), memoized per catalog.
|
|
13
|
+
* @position Sits beside docs.mjs (api/docs/). Loads authored files and hands
|
|
14
|
+
* them to foundation/doc-compiler, so no leaf, doctor check or search loads,
|
|
15
|
+
* merges, or resolves docs on its own. Discovery itself lives in
|
|
16
|
+
* foundation/discovery/docs-discovery, which the catalog comes from.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import * as fs from 'node:fs';
|
|
20
20
|
import * as path from 'node:path';
|
|
21
21
|
import {pathToFileURL} from 'node:url';
|
|
22
22
|
import {Project} from '../../foundation/config/project.mjs';
|
|
23
|
+
import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';
|
|
23
24
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
withSourceTitle,
|
|
28
|
-
} from '../../foundation/discovery/docs-discovery.mjs';
|
|
29
|
-
import {
|
|
30
|
-
sectionKeyProblems,
|
|
31
|
-
withSectionKeys,
|
|
32
|
-
} from '../../foundation/discovery/docs-section-key.mjs';
|
|
25
|
+
linkReferenceTopic,
|
|
26
|
+
lowerReferenceTopic,
|
|
27
|
+
} from '../../foundation/doc-compiler/compile.mjs';
|
|
33
28
|
import {AstryxError} from '../error.mjs';
|
|
34
29
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
35
30
|
import {parseDoc} from '../../authoring/doctypes/parse.mjs';
|
|
@@ -56,108 +51,6 @@ export async function loadDocsCatalog(cwd = process.cwd()) {
|
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
53
|
|
|
59
|
-
/**
|
|
60
|
-
* @param {string} docPath
|
|
61
|
-
* @param {{lang?: string|null}} [opts]
|
|
62
|
-
* @returns {Promise<import('./docs.type.mjs').DocsDetailResponse['data']>}
|
|
63
|
-
*/
|
|
64
|
-
export async function loadReferenceDocs(docPath, {lang} = {}) {
|
|
65
|
-
const mod = await import(pathToFileURL(docPath).href);
|
|
66
|
-
const parsed = parseDoc(mod.docs ?? mod.default, path.basename(docPath));
|
|
67
|
-
if (!('sections' in parsed)) {
|
|
68
|
-
throw new Error(`${path.basename(docPath)} is not a reference document.`);
|
|
69
|
-
}
|
|
70
|
-
const problems = problemsInTopic(parsed);
|
|
71
|
-
if (problems.length > 0) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`${path.basename(docPath)} is invalid: ${problems.join('; ')}`,
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
const docs = parsed;
|
|
77
|
-
if (!lang || lang === 'en') return docs;
|
|
78
|
-
|
|
79
|
-
const translationPath = overlayPath(docPath, lang);
|
|
80
|
-
if (!fs.existsSync(translationPath)) return docs;
|
|
81
|
-
|
|
82
|
-
const translationMod = await import(pathToFileURL(translationPath).href);
|
|
83
|
-
const translation = translationMod.docsZh || translationMod.docsDense;
|
|
84
|
-
if (!translation) return docs;
|
|
85
|
-
|
|
86
|
-
// Overlays are keyed to a base section by title (`section`), not by array
|
|
87
|
-
// position. Position-keying silently grafted each overlay title onto whatever
|
|
88
|
-
// base section happened to share its index, so an overlay that omitted or
|
|
89
|
-
// reordered a section corrupted every section after it — `docs tokens --dense`
|
|
90
|
-
// printed the colour table under a "Spacing" heading (#2182). An overlay may
|
|
91
|
-
// now cover any subset of sections, in any order; sections it does not name
|
|
92
|
-
// keep their base content.
|
|
93
|
-
/** @type {Map<string, any>} */
|
|
94
|
-
const bySection = new Map();
|
|
95
|
-
for (const ts of translation.sections ?? []) {
|
|
96
|
-
if (ts?.section != null) bySection.set(ts.section, ts);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
...docs,
|
|
101
|
-
description: translation.description || docs.description,
|
|
102
|
-
sections: docs.sections.map(
|
|
103
|
-
(
|
|
104
|
-
/** @type {import('@astryxdesign/cli/authoring').ReferenceSection} */ section,
|
|
105
|
-
) => {
|
|
106
|
-
const ts = bySection.get(section.title);
|
|
107
|
-
if (!ts) return section;
|
|
108
|
-
const localized = {
|
|
109
|
-
...section,
|
|
110
|
-
title: ts.title || section.title,
|
|
111
|
-
content: section.content.map(
|
|
112
|
-
(
|
|
113
|
-
/** @type {import('@astryxdesign/cli/authoring').ReferenceContentBlock} */ block,
|
|
114
|
-
/** @type {number} */ bi,
|
|
115
|
-
) => {
|
|
116
|
-
const tb = ts.content?.[bi];
|
|
117
|
-
if (!tb) return block;
|
|
118
|
-
if (tb.type === 'prose' && block.type === 'prose')
|
|
119
|
-
return {...block, text: tb.text};
|
|
120
|
-
if (tb.type === 'list' && block.type === 'list')
|
|
121
|
-
return {...block, items: tb.items};
|
|
122
|
-
return block;
|
|
123
|
-
},
|
|
124
|
-
),
|
|
125
|
-
};
|
|
126
|
-
return withSourceTitle(localized, section.title);
|
|
127
|
-
},
|
|
128
|
-
),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Load one catalog entry: its own doc, plus any extension an integration
|
|
134
|
-
* merged onto it, in configuration order.
|
|
135
|
-
*
|
|
136
|
-
* A localization overlay applies to each file before the extensions are
|
|
137
|
-
* merged, so an extension written in the base language stays readable under
|
|
138
|
-
* `--dense`/`--zh` (it replaces its own sections and leaves the rest
|
|
139
|
-
* translated) rather than being dropped.
|
|
140
|
-
*
|
|
141
|
-
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
142
|
-
* @param {{lang?: string|null}} [opts]
|
|
143
|
-
* @returns {Promise<import('./docs.type.mjs').DocsDetailResponse['data']>}
|
|
144
|
-
*/
|
|
145
|
-
export async function loadTopicDoc(entry, {lang} = {}) {
|
|
146
|
-
let doc = await loadReferenceDocs(entry.path, {lang});
|
|
147
|
-
for (const extension of entry.extensions) {
|
|
148
|
-
doc = mergeTopic(doc, await loadReferenceDocs(extension.path, {lang}));
|
|
149
|
-
// Merging matches on keys, so this holds unless merge itself regresses.
|
|
150
|
-
const problems = sectionKeyProblems(doc.sections);
|
|
151
|
-
if (problems.length > 0) {
|
|
152
|
-
throw new Error(
|
|
153
|
-
`${path.basename(extension.path)}, extending ${entry.name}, leaves two sections with one key: ${problems.join('; ')}`,
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
// Derived keys are stamped only now, so they never take part in merging.
|
|
158
|
-
return withSectionKeys(doc);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
54
|
/** The localized overlays a docs read can apply. */
|
|
162
55
|
export const OVERLAY_LANGUAGES = ['zh', 'dense'];
|
|
163
56
|
|
|
@@ -186,11 +79,148 @@ export function overlayLanguages(entry) {
|
|
|
186
79
|
);
|
|
187
80
|
}
|
|
188
81
|
|
|
82
|
+
/**
|
|
83
|
+
* The overlay a read applies: none for the authored language.
|
|
84
|
+
* @param {string | null | undefined} lang
|
|
85
|
+
* @returns {string | null}
|
|
86
|
+
*/
|
|
87
|
+
function overlayLanguage(lang) {
|
|
88
|
+
return lang && lang !== 'en' ? lang : null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Load one authored file and the overlay for `lang`. A failure is recorded on
|
|
93
|
+
* the result, not thrown, so the compiler reports it in reading order.
|
|
94
|
+
* @param {string} docPath
|
|
95
|
+
* @param {string | null} lang
|
|
96
|
+
* @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').AuthoredFile>}
|
|
97
|
+
*/
|
|
98
|
+
async function loadAuthoredFile(docPath, lang) {
|
|
99
|
+
const file = path.basename(docPath);
|
|
100
|
+
let doc;
|
|
101
|
+
try {
|
|
102
|
+
const mod = await import(pathToFileURL(docPath).href);
|
|
103
|
+
doc = parseDoc(mod.docs ?? mod.default, file);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
return {file, error};
|
|
106
|
+
}
|
|
107
|
+
if (!lang) return {file, doc};
|
|
108
|
+
const translationPath = overlayPath(docPath, lang);
|
|
109
|
+
if (!fs.existsSync(translationPath)) return {file, doc};
|
|
110
|
+
try {
|
|
111
|
+
const translationMod = await import(pathToFileURL(translationPath).href);
|
|
112
|
+
return {
|
|
113
|
+
file,
|
|
114
|
+
doc,
|
|
115
|
+
overlay: translationMod.docsZh || translationMod.docsDense || null,
|
|
116
|
+
};
|
|
117
|
+
} catch (overlayError) {
|
|
118
|
+
return {file, doc, overlayError};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Everything the compiler needs for one topic, read from disk.
|
|
124
|
+
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
125
|
+
* @param {string | null} lang
|
|
126
|
+
* @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').ReferenceTopicInput>}
|
|
127
|
+
*/
|
|
128
|
+
async function loadCompilerInput(entry, lang) {
|
|
129
|
+
const extensions = [];
|
|
130
|
+
for (const extension of entry.extensions) {
|
|
131
|
+
extensions.push({
|
|
132
|
+
...(await loadAuthoredFile(extension.path, lang)),
|
|
133
|
+
provider: extension.package,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
id: entry.name,
|
|
138
|
+
provider: entry.package,
|
|
139
|
+
replaces: entry.replaces ?? null,
|
|
140
|
+
lang,
|
|
141
|
+
base: await loadAuthoredFile(entry.path, lang),
|
|
142
|
+
extensions,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** @type {WeakMap<DocsCatalog, Map<string, Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>>>} */
|
|
147
|
+
const loweredByCatalog = new WeakMap();
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* One topic, lowered for `lang`: overlaid, extensions merged, keys stamped.
|
|
151
|
+
* Memoized per catalog, so a read that references a topic twice loads it once.
|
|
152
|
+
* Every read of the catalog shares the memoized node, so it is frozen; the
|
|
153
|
+
* lenses hand readers copies.
|
|
154
|
+
* @param {DocsCatalog} catalog
|
|
155
|
+
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
156
|
+
* @param {string | null} [lang]
|
|
157
|
+
* @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
|
|
158
|
+
*/
|
|
159
|
+
export function lowerTopic(catalog, entry, lang = null) {
|
|
160
|
+
const overlay = overlayLanguage(lang);
|
|
161
|
+
let cache = loweredByCatalog.get(catalog);
|
|
162
|
+
if (!cache) {
|
|
163
|
+
cache = new Map();
|
|
164
|
+
loweredByCatalog.set(catalog, cache);
|
|
165
|
+
}
|
|
166
|
+
const key = `${entry.name.toLowerCase()}\u0000${overlay ?? ''}`;
|
|
167
|
+
let lowered = cache.get(key);
|
|
168
|
+
if (!lowered) {
|
|
169
|
+
lowered = loadCompilerInput(entry, overlay).then(input =>
|
|
170
|
+
deepFreeze(lowerReferenceTopic(input)),
|
|
171
|
+
);
|
|
172
|
+
cache.set(key, lowered);
|
|
173
|
+
}
|
|
174
|
+
return lowered;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Freeze a value and everything in it.
|
|
179
|
+
* @template T
|
|
180
|
+
* @param {T} value
|
|
181
|
+
* @returns {T}
|
|
182
|
+
*/
|
|
183
|
+
function deepFreeze(value) {
|
|
184
|
+
if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
185
|
+
Object.freeze(value);
|
|
186
|
+
for (const child of Object.values(value)) deepFreeze(child);
|
|
187
|
+
}
|
|
188
|
+
return value;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* How a token reference finds its target: the topic it names in `catalog`,
|
|
193
|
+
* lowered for the same language.
|
|
194
|
+
* @param {DocsCatalog} catalog
|
|
195
|
+
* @param {string | null} lang
|
|
196
|
+
* @returns {(topic: string) => Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode | null>}
|
|
197
|
+
*/
|
|
198
|
+
export function referenceTargets(catalog, lang) {
|
|
199
|
+
return async topic => {
|
|
200
|
+
const target = catalog.resolve(topic);
|
|
201
|
+
return target ? lowerTopic(catalog, target, lang) : null;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* One topic, compiled for `lang`: lowered, then every token reference linked.
|
|
207
|
+
* @param {DocsCatalog} catalog
|
|
208
|
+
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
209
|
+
* @param {string | null} [lang]
|
|
210
|
+
* @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
|
|
211
|
+
*/
|
|
212
|
+
export async function compileTopic(catalog, entry, lang = null) {
|
|
213
|
+
return linkReferenceTopic(
|
|
214
|
+
await lowerTopic(catalog, entry, lang),
|
|
215
|
+
referenceTargets(catalog, lang),
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
189
219
|
/**
|
|
190
220
|
* Resolve `topic` against the project's catalog (throwing `ERR_UNKNOWN_TOPIC`
|
|
191
|
-
* when unmatched)
|
|
192
|
-
* integration extension applied. Shared by the
|
|
193
|
-
*
|
|
221
|
+
* when unmatched) and lower it with any --dense/--zh overlay and any
|
|
222
|
+
* integration extension applied. Shared by the leaves so topic normalization
|
|
223
|
+
* and unknown-topic handling live in exactly one place.
|
|
194
224
|
*
|
|
195
225
|
* @param {string} topic
|
|
196
226
|
* @param {object} [options]
|
|
@@ -200,7 +230,7 @@ export function overlayLanguages(entry) {
|
|
|
200
230
|
* @param {string} [options.cwd]
|
|
201
231
|
* @returns {Promise<{
|
|
202
232
|
* catalog: DocsCatalog,
|
|
203
|
-
*
|
|
233
|
+
* node: import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode,
|
|
204
234
|
* lang: string | null,
|
|
205
235
|
* }>}
|
|
206
236
|
*/
|
|
@@ -221,6 +251,6 @@ export async function resolveTopicDocs(topic, options = {}) {
|
|
|
221
251
|
);
|
|
222
252
|
}
|
|
223
253
|
|
|
224
|
-
const
|
|
225
|
-
return {catalog,
|
|
254
|
+
const node = await lowerTopic(catalog, entry, effectiveLang);
|
|
255
|
+
return {catalog, node, lang: effectiveLang};
|
|
226
256
|
}
|