@astryxdesign/cli 0.7.2-canary.9da2d0b → 0.7.2-canary.a3f5dbf
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 +7 -7
- package/api/component/_adapter.d.mts +41 -1
- package/api/component/_adapter.mjs +93 -7
- package/api/component/component.mjs +22 -5
- package/api/component/component.test.mjs +80 -0
- package/api/component/integration-export-name.test.mjs +644 -0
- package/api/component/list/list.mjs +42 -4
- package/api/docs/_adapter.mjs +207 -1
- package/api/docs/integrationDocs.test.mjs +124 -0
- package/api/gap-report/gap-report.mjs +67 -4
- package/api/integration/_adapter.d.mts +12 -0
- package/api/integration/_adapter.mjs +54 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/authoring-checks.mjs +11 -2
- package/api/integration/authoring-checks.test.mjs +39 -0
- package/api/integration/authoring-checks.type.d.mts +9 -0
- package/api/integration/authoring-checks.type.mjs +14 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +21 -5
- package/api/integration/pack-check.mjs +61 -107
- package/api/integration/pack-check.test.mjs +359 -0
- package/api/integration/validate-integration.test.mjs +11 -0
- package/api/search/search.d.mts +9 -0
- package/api/search/search.mjs +108 -16
- package/api/search/search.test.mjs +36 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/theme/build/build.family.test.mjs +16 -0
- package/api/theme/build/build.mjs +77 -18
- package/api/theme/themeBuild.doc.mjs +3 -3
- package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
- package/assets/docs/tree/add-a-component.doc.mjs +10 -0
- package/assets/docs/tree/check-the-props.doc.mjs +145 -0
- package/assets/docs/tree/checks.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +5 -1
- package/assets/docs/tree/component-imports.doc.mjs +8 -0
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/links.doc.mjs +2 -2
- package/assets/docs/tree/single-component.doc.mjs +3 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +9 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -0
- package/assets/docs/working-with-ai.doc.mjs +43 -4
- package/authoring/doctypes/component/component.doc.mjs +2 -2
- package/authoring/doctypes/component/type.ts +6 -3
- package/authoring/integration/integration.doc.mjs +8 -1
- package/authoring/integration/parse.test.mjs +10 -0
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +4 -0
- package/clients/cli/commands/build-theme.path-safety.test.mjs +84 -0
- package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
- package/clients/cli/commands/doctor-integration-components.doc.mjs +9 -3
- package/clients/cli/commands/doctor-integration.test.mjs +392 -0
- package/clients/cli/commands/doctor.mjs +74 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/foundation/config/project.mjs +82 -0
- package/foundation/discovery/component-discovery.d.mts +190 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +864 -56
- package/foundation/discovery/component-discovery.test.mjs +96 -0
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +40 -0
- package/foundation/discovery/docs-discovery.d.mts +81 -0
- package/foundation/discovery/docs-discovery.mjs +57 -0
- package/foundation/discovery/module-exports.d.mts +27 -0
- package/foundation/discovery/module-exports.mjs +356 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/discovery/package-tsconfig.d.mts +14 -0
- package/foundation/discovery/package-tsconfig.mjs +228 -0
- package/foundation/discovery/package-tsconfig.test.mjs +210 -0
- package/foundation/discovery/project-typescript.d.mts +23 -0
- package/foundation/discovery/project-typescript.mjs +61 -0
- package/foundation/discovery/prop-drift.d.mts +220 -0
- package/foundation/discovery/prop-drift.mjs +1765 -0
- package/foundation/discovery/prop-drift.test.mjs +1197 -0
- package/foundation/discovery/type-match.d.mts +53 -0
- package/foundation/discovery/type-match.mjs +660 -0
- package/foundation/discovery/type-match.test.mjs +169 -0
- package/foundation/discovery/type-text.d.mts +68 -0
- package/foundation/discovery/type-text.mjs +658 -0
- package/foundation/discovery/type-text.test.mjs +196 -0
- package/foundation/discovery/unresolved-references.d.mts +62 -0
- package/foundation/discovery/unresolved-references.mjs +790 -0
- package/foundation/discovery/unresolved-references.test.mjs +567 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +8 -0
- package/foundation/doc-compiler/inputs.mjs +23 -0
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/links.d.mts +9 -5
- package/foundation/doc-compiler/links.mjs +4 -2
- package/foundation/integrations/contribution-inventory.mjs +6 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/xle/registry.mjs +4 -0
- package/foundation/xle/registry.test.mjs +28 -0
- package/package.json +9 -9
|
@@ -16,6 +16,7 @@ import {fileURLToPath} from 'node:url';
|
|
|
16
16
|
import {
|
|
17
17
|
CORE_PACKAGE,
|
|
18
18
|
discoverComponents,
|
|
19
|
+
familyMember,
|
|
19
20
|
findComponentReadme,
|
|
20
21
|
findComponentSource,
|
|
21
22
|
resolveImportPath,
|
|
@@ -121,6 +122,91 @@ describe('discoverComponents (real core)', () => {
|
|
|
121
122
|
expect(discoverComponents(core)).toEqual({});
|
|
122
123
|
});
|
|
123
124
|
|
|
125
|
+
it('lists HStack, VStack and Heading, whose docs live in their family folders', () => {
|
|
126
|
+
// Each has its own folder and import path; Stack's doc documents HStack and
|
|
127
|
+
// VStack as members, and Heading's own doc sits in the Text folder.
|
|
128
|
+
const comps = discoverComponents(CORE);
|
|
129
|
+
expect(comps.Layout).toEqual(expect.arrayContaining(['HStack', 'Stack', 'VStack']));
|
|
130
|
+
expect(comps.Heading).toEqual(['Heading']);
|
|
131
|
+
expect(findComponentReadme(CORE, 'VStack')).toMatch(/[\\/]Stack[\\/]Stack\.doc\.mjs$/);
|
|
132
|
+
expect(findComponentReadme(CORE, 'HStack')).toMatch(/[\\/]Stack[\\/]Stack\.doc\.mjs$/);
|
|
133
|
+
expect(findComponentReadme(CORE, 'Heading')).toMatch(/[\\/]Text[\\/]Heading\.doc\.mjs$/);
|
|
134
|
+
expect(resolveImportPath(CORE, 'VStack')).toBe('@astryxdesign/core/VStack');
|
|
135
|
+
expect(resolveImportPath(CORE, 'Heading')).toBe('@astryxdesign/core/Heading');
|
|
136
|
+
}, SLOW);
|
|
137
|
+
|
|
138
|
+
it('lists a component folder with no doc when its family doc lists it as a member', () => {
|
|
139
|
+
const core = mkTmp('as-cd-family-');
|
|
140
|
+
const write = (rel, text) => {
|
|
141
|
+
fs.mkdirSync(path.dirname(path.join(core, 'src', rel)), {recursive: true});
|
|
142
|
+
fs.writeFileSync(path.join(core, 'src', rel), text);
|
|
143
|
+
};
|
|
144
|
+
write('Stack/Stack.tsx', 'x');
|
|
145
|
+
write('VStack/VStack.tsx', "import {Stack} from '../Stack/Stack';\n");
|
|
146
|
+
write('Prose/Prose.tsx', "import {Stack} from '../Stack/Stack';\n");
|
|
147
|
+
// Listed by Stack's doc, but builds on nothing in Stack's folder.
|
|
148
|
+
write('Orphan/Orphan.tsx', "import {x} from '../utils';\n");
|
|
149
|
+
write(
|
|
150
|
+
'Stack/Stack.doc.mjs',
|
|
151
|
+
'export const docs = {\n' +
|
|
152
|
+
" name: 'Stack',\n" +
|
|
153
|
+
" group: 'Layout',\n" +
|
|
154
|
+
" relatedComponents: ['Prose'],\n" +
|
|
155
|
+
" usage: {description: 'Pair with Prose.', examples: [{code: \"<Prose label='Prose' />\"}]},\n" +
|
|
156
|
+
" components: [{name: 'Stack'}, {name: 'VStack', description: 'Vertical.'}, {name: 'Orphan'}],\n" +
|
|
157
|
+
'};\n',
|
|
158
|
+
);
|
|
159
|
+
expect(discoverComponents(core)).toEqual({Layout: ['Stack', 'VStack']});
|
|
160
|
+
expect(findComponentReadme(core, 'VStack')).toBe(
|
|
161
|
+
path.join(core, 'src', 'Stack', 'Stack.doc.mjs'),
|
|
162
|
+
);
|
|
163
|
+
// Named only in relatedComponents, prose, and an example: not documented.
|
|
164
|
+
expect(findComponentReadme(core, 'Prose')).toBeNull();
|
|
165
|
+
// A family doc is read only from the folders the component imports.
|
|
166
|
+
expect(findComponentReadme(core, 'Orphan')).toBeNull();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('lists a component folder with no doc when its own doc sits in a family folder', () => {
|
|
170
|
+
const core = mkTmp('as-cd-sibling-');
|
|
171
|
+
for (const dir of ['Text', 'Heading']) {
|
|
172
|
+
fs.mkdirSync(path.join(core, 'src', dir), {recursive: true});
|
|
173
|
+
}
|
|
174
|
+
fs.writeFileSync(path.join(core, 'src', 'Text', 'Text.tsx'), 'x');
|
|
175
|
+
fs.writeFileSync(path.join(core, 'src', 'Heading', 'Heading.tsx'), 'x');
|
|
176
|
+
fs.writeFileSync(
|
|
177
|
+
path.join(core, 'src', 'Text', 'Text.doc.mjs'),
|
|
178
|
+
"export const docs = {name: 'Text', components: [{name: 'Heading'}]};\n",
|
|
179
|
+
);
|
|
180
|
+
fs.writeFileSync(
|
|
181
|
+
path.join(core, 'src', 'Text', 'Heading.doc.mjs'),
|
|
182
|
+
"export const docs = {name: 'Heading'};\n",
|
|
183
|
+
);
|
|
184
|
+
expect(discoverComponents(core)).toEqual({Heading: ['Heading'], Text: ['Text']});
|
|
185
|
+
expect(findComponentReadme(core, 'Heading')).toBe(
|
|
186
|
+
path.join(core, 'src', 'Text', 'Heading.doc.mjs'),
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('keeps a member its family hides, and a context folder, unlisted', () => {
|
|
191
|
+
const core = mkTmp('as-cd-family-hidden-');
|
|
192
|
+
for (const dir of ['Stack', 'VStack', 'SizeContext']) {
|
|
193
|
+
fs.mkdirSync(path.join(core, 'src', dir), {recursive: true});
|
|
194
|
+
fs.writeFileSync(
|
|
195
|
+
path.join(core, 'src', dir, `${dir}.tsx`),
|
|
196
|
+
"import {Stack} from '../Stack/Stack';\n",
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
fs.writeFileSync(
|
|
200
|
+
path.join(core, 'src', 'Stack', 'Stack.doc.mjs'),
|
|
201
|
+
'export const docs = {\n' +
|
|
202
|
+
" name: 'Stack',\n" +
|
|
203
|
+
" hiddenComponents: ['VStack'],\n" +
|
|
204
|
+
" components: [{name: 'Stack'}, {name: 'VStack'}, {name: 'SizeContext'}],\n" +
|
|
205
|
+
'};\n',
|
|
206
|
+
);
|
|
207
|
+
expect(discoverComponents(core)).toEqual({Stack: ['Stack']});
|
|
208
|
+
});
|
|
209
|
+
|
|
124
210
|
it('returns {} for an empty src/ dir', () => {
|
|
125
211
|
const core = mkTmp('as-cd-emptysrc-');
|
|
126
212
|
fs.mkdirSync(path.join(core, 'src'));
|
|
@@ -133,6 +219,16 @@ describe('discoverComponents (real core)', () => {
|
|
|
133
219
|
});
|
|
134
220
|
});
|
|
135
221
|
|
|
222
|
+
describe('familyMember', () => {
|
|
223
|
+
it("returns a family doc's entry for a member, and null for a component's own doc", () => {
|
|
224
|
+
const stack = {name: 'Stack', components: [{name: 'Stack'}, {name: 'VStack', description: 'v'}]};
|
|
225
|
+
expect(familyMember(stack, 'VStack')).toEqual({name: 'VStack', description: 'v'});
|
|
226
|
+
expect(familyMember(stack, 'Stack')).toBeNull();
|
|
227
|
+
expect(familyMember({name: 'Button'}, 'Button')).toBeNull();
|
|
228
|
+
expect(familyMember(stack, 'HStack')).toBeNull();
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
136
232
|
describe('findComponentReadme / findComponentSource / resolveImportPath', () => {
|
|
137
233
|
it('finds the doc + source for a top-level component', () => {
|
|
138
234
|
expect(findComponentReadme(CORE, 'Button')).toMatch(/Button\.doc\.mjs$/);
|
|
@@ -161,6 +161,24 @@ export async function resolveComponentReplacements(
|
|
|
161
161
|
typeof name === 'string' ? byTarget.get(name) : undefined,
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
// A first read under file names alone settles the common case, no
|
|
165
|
+
// declaration anywhere, without reading the names docs document.
|
|
166
|
+
let declares = false;
|
|
167
|
+
for (const integration of loadedIntegrations) {
|
|
168
|
+
if (declares || !integration?.components || integration.__loadError)
|
|
169
|
+
continue;
|
|
170
|
+
try {
|
|
171
|
+
const {components} = await discoverValidIntegrationComponents(
|
|
172
|
+
integration,
|
|
173
|
+
{documentedNames: false},
|
|
174
|
+
);
|
|
175
|
+
declares = components.some(record => record.replaces !== undefined);
|
|
176
|
+
} catch {
|
|
177
|
+
// Read again below, where a root that cannot be read is skipped.
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (!declares) return result;
|
|
181
|
+
|
|
164
182
|
/** @type {Declaration[]} */
|
|
165
183
|
const declarations = [];
|
|
166
184
|
/** @type {Array<{name: string, package: string}>} */
|
|
@@ -259,6 +259,46 @@ describe('resolveComponentReplacements', () => {
|
|
|
259
259
|
]);
|
|
260
260
|
});
|
|
261
261
|
|
|
262
|
+
it('applies a replacement under the export a doc names when its file is named otherwise', async () => {
|
|
263
|
+
// Nav.doc.mjs documents AcmeSideNav, the export of a Nav.tsx that exports
|
|
264
|
+
// nothing named Nav.
|
|
265
|
+
const acme = integrationWithDocSource(
|
|
266
|
+
'@acme/nav',
|
|
267
|
+
'Nav',
|
|
268
|
+
BASE_DOC.replace("name: 'AcmeNav'", "name: 'AcmeSideNav'"),
|
|
269
|
+
);
|
|
270
|
+
fs.writeFileSync(
|
|
271
|
+
path.join(acme.components, 'Nav.tsx'),
|
|
272
|
+
'export function AcmeSideNav() { return null; }\n',
|
|
273
|
+
);
|
|
274
|
+
const result = await resolveComponentReplacements(CORE_DIR, [acme]);
|
|
275
|
+
expect(result.findings).toEqual([]);
|
|
276
|
+
expect(result.forTarget('SideNav')).toMatchObject({
|
|
277
|
+
name: 'AcmeSideNav',
|
|
278
|
+
package: '@acme/nav',
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it("counts a doc's replaces once when the doc lists its own name as a member", async () => {
|
|
283
|
+
// Chip.doc.mjs documents AcmeChip beside a Chip.tsx that exports both, and
|
|
284
|
+
// lists itself first, as the component-family guide asks.
|
|
285
|
+
const acme = integrationWithDocSource(
|
|
286
|
+
'@acme/chips',
|
|
287
|
+
'Chip',
|
|
288
|
+
`export default {type: 'component', name: 'AcmeChip', replaces: 'Badge', usage: {description: 'Acme chip.'}, components: [{name: 'AcmeChip', description: 'A chip.', props: []}]};\n`,
|
|
289
|
+
);
|
|
290
|
+
fs.writeFileSync(
|
|
291
|
+
path.join(acme.components, 'Chip.tsx'),
|
|
292
|
+
'export function Chip() { return null; }\nexport function AcmeChip() { return null; }\n',
|
|
293
|
+
);
|
|
294
|
+
const result = await resolveComponentReplacements(CORE_DIR, [acme]);
|
|
295
|
+
expect(result.findings).toEqual([]);
|
|
296
|
+
expect(result.forTarget('Badge')).toMatchObject({
|
|
297
|
+
name: 'Chip',
|
|
298
|
+
package: '@acme/chips',
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
|
|
262
302
|
it('lets a replacement keep the Core name it replaces', async () => {
|
|
263
303
|
const acme = integration(
|
|
264
304
|
'@acme/nav',
|
|
@@ -132,6 +132,35 @@ export const GRAPH_BLOCK_TYPES: Set<string>;
|
|
|
132
132
|
* load; a guide the tree places may set `placement` (spec:AST-046).
|
|
133
133
|
*/
|
|
134
134
|
export const GRAPH_ONLY_FIELDS: string[];
|
|
135
|
+
/**
|
|
136
|
+
* A component a link can name: its owner's provider id, package, and name,
|
|
137
|
+
* and the doc file that describes it.
|
|
138
|
+
* @typedef {object} LinkableComponent
|
|
139
|
+
* @property {string} providerId
|
|
140
|
+
* @property {string} package
|
|
141
|
+
* @property {string} name
|
|
142
|
+
* @property {string | null} docPath
|
|
143
|
+
* @property {string} [replaces] the Core component whose name it answers to
|
|
144
|
+
* in unqualified lookups (spec:AST-035 FR11)
|
|
145
|
+
*/
|
|
146
|
+
/**
|
|
147
|
+
* A page or block template a link can name, by the id `astryx template` takes.
|
|
148
|
+
* @typedef {object} LinkableTemplate
|
|
149
|
+
* @property {string} providerId
|
|
150
|
+
* @property {string} package
|
|
151
|
+
* @property {'page' | 'block'} type
|
|
152
|
+
* @property {string} id
|
|
153
|
+
* @property {string} name
|
|
154
|
+
* @property {string} [displayName]
|
|
155
|
+
* @property {string} [description]
|
|
156
|
+
* @property {string} [replaces] the Core template id it answers to in
|
|
157
|
+
* unqualified lookups
|
|
158
|
+
*/
|
|
159
|
+
/**
|
|
160
|
+
* The component and template docs links can name (spec:AST-047 FR9). No docs
|
|
161
|
+
* tree holds them, so a catalog carries the records the project reads.
|
|
162
|
+
* @typedef {{components: LinkableComponent[], templates: LinkableTemplate[]}} LinkableContributions
|
|
163
|
+
*/
|
|
135
164
|
/**
|
|
136
165
|
* Every topic a project can read, and the relationships between them.
|
|
137
166
|
*
|
|
@@ -181,6 +210,18 @@ export class DocsCatalog {
|
|
|
181
210
|
namespaces: import("../doc-compiler/tree.mjs").TreeNamespaceInput[];
|
|
182
211
|
guides: import("../doc-compiler/tree.mjs").TreeDocInput[];
|
|
183
212
|
}>;
|
|
213
|
+
/**
|
|
214
|
+
* Say where links find component, page, and block docs: the records
|
|
215
|
+
* `astryx component` and `astryx template` read, loaded on first use.
|
|
216
|
+
* @param {() => Promise<LinkableContributions>} load
|
|
217
|
+
*/
|
|
218
|
+
setContributions(load: () => Promise<LinkableContributions>): void;
|
|
219
|
+
/**
|
|
220
|
+
* The component and template docs links can name, or null when nothing set
|
|
221
|
+
* them, so no link to one resolves.
|
|
222
|
+
* @returns {Promise<LinkableContributions | null>}
|
|
223
|
+
*/
|
|
224
|
+
contributions(): Promise<LinkableContributions | null>;
|
|
184
225
|
/**
|
|
185
226
|
* Add one integration-contributed doc, honoring what it declares. Returns
|
|
186
227
|
* the issue it caused, or null when it applied cleanly — the caller owns
|
|
@@ -290,4 +331,44 @@ export type DocsTopicEntry = {
|
|
|
290
331
|
*/
|
|
291
332
|
tree?: boolean | undefined;
|
|
292
333
|
};
|
|
334
|
+
/**
|
|
335
|
+
* A component a link can name: its owner's provider id, package, and name,
|
|
336
|
+
* and the doc file that describes it.
|
|
337
|
+
*/
|
|
338
|
+
export type LinkableComponent = {
|
|
339
|
+
providerId: string;
|
|
340
|
+
package: string;
|
|
341
|
+
name: string;
|
|
342
|
+
docPath: string | null;
|
|
343
|
+
/**
|
|
344
|
+
* the Core component whose name it answers to
|
|
345
|
+
* in unqualified lookups (spec:AST-035 FR11)
|
|
346
|
+
*/
|
|
347
|
+
replaces?: string | undefined;
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* A page or block template a link can name, by the id `astryx template` takes.
|
|
351
|
+
*/
|
|
352
|
+
export type LinkableTemplate = {
|
|
353
|
+
providerId: string;
|
|
354
|
+
package: string;
|
|
355
|
+
type: "page" | "block";
|
|
356
|
+
id: string;
|
|
357
|
+
name: string;
|
|
358
|
+
displayName?: string | undefined;
|
|
359
|
+
description?: string | undefined;
|
|
360
|
+
/**
|
|
361
|
+
* the Core template id it answers to in
|
|
362
|
+
* unqualified lookups
|
|
363
|
+
*/
|
|
364
|
+
replaces?: string | undefined;
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* The component and template docs links can name (spec:AST-047 FR9). No docs
|
|
368
|
+
* tree holds them, so a catalog carries the records the project reads.
|
|
369
|
+
*/
|
|
370
|
+
export type LinkableContributions = {
|
|
371
|
+
components: LinkableComponent[];
|
|
372
|
+
templates: LinkableTemplate[];
|
|
373
|
+
};
|
|
293
374
|
import { withSourceTitle } from './docs-section-key.mjs';
|
|
@@ -633,6 +633,38 @@ function findMergeTarget(sections, section) {
|
|
|
633
633
|
return sections.findIndex(candidate => candidate.id === key);
|
|
634
634
|
}
|
|
635
635
|
|
|
636
|
+
/**
|
|
637
|
+
* A component a link can name: its owner's provider id, package, and name,
|
|
638
|
+
* and the doc file that describes it.
|
|
639
|
+
* @typedef {object} LinkableComponent
|
|
640
|
+
* @property {string} providerId
|
|
641
|
+
* @property {string} package
|
|
642
|
+
* @property {string} name
|
|
643
|
+
* @property {string | null} docPath
|
|
644
|
+
* @property {string} [replaces] the Core component whose name it answers to
|
|
645
|
+
* in unqualified lookups (spec:AST-035 FR11)
|
|
646
|
+
*/
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* A page or block template a link can name, by the id `astryx template` takes.
|
|
650
|
+
* @typedef {object} LinkableTemplate
|
|
651
|
+
* @property {string} providerId
|
|
652
|
+
* @property {string} package
|
|
653
|
+
* @property {'page' | 'block'} type
|
|
654
|
+
* @property {string} id
|
|
655
|
+
* @property {string} name
|
|
656
|
+
* @property {string} [displayName]
|
|
657
|
+
* @property {string} [description]
|
|
658
|
+
* @property {string} [replaces] the Core template id it answers to in
|
|
659
|
+
* unqualified lookups
|
|
660
|
+
*/
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* The component and template docs links can name (spec:AST-047 FR9). No docs
|
|
664
|
+
* tree holds them, so a catalog carries the records the project reads.
|
|
665
|
+
* @typedef {{components: LinkableComponent[], templates: LinkableTemplate[]}} LinkableContributions
|
|
666
|
+
*/
|
|
667
|
+
|
|
636
668
|
/**
|
|
637
669
|
* Every topic a project can read, and the relationships between them.
|
|
638
670
|
*
|
|
@@ -644,6 +676,10 @@ function findMergeTarget(sections, section) {
|
|
|
644
676
|
export class DocsCatalog {
|
|
645
677
|
/** @type {Map<string, DocsTopicEntry>} */
|
|
646
678
|
#topics = new Map();
|
|
679
|
+
/** @type {(() => Promise<LinkableContributions>) | null} */
|
|
680
|
+
#contributions = null;
|
|
681
|
+
/** @type {Promise<LinkableContributions> | null} */
|
|
682
|
+
#contributionsLoaded = null;
|
|
647
683
|
/** @type {Map<string, string>} old topic name → the name that replaced it */
|
|
648
684
|
#aliases = new Map();
|
|
649
685
|
/** @type {Array<{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>} */
|
|
@@ -687,6 +723,27 @@ export class DocsCatalog {
|
|
|
687
723
|
return this.#treeInputs;
|
|
688
724
|
}
|
|
689
725
|
|
|
726
|
+
/**
|
|
727
|
+
* Say where links find component, page, and block docs: the records
|
|
728
|
+
* `astryx component` and `astryx template` read, loaded on first use.
|
|
729
|
+
* @param {() => Promise<LinkableContributions>} load
|
|
730
|
+
*/
|
|
731
|
+
setContributions(load) {
|
|
732
|
+
this.#contributions = load;
|
|
733
|
+
this.#contributionsLoaded = null;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* The component and template docs links can name, or null when nothing set
|
|
738
|
+
* them, so no link to one resolves.
|
|
739
|
+
* @returns {Promise<LinkableContributions | null>}
|
|
740
|
+
*/
|
|
741
|
+
contributions() {
|
|
742
|
+
if (!this.#contributions) return Promise.resolve(null);
|
|
743
|
+
this.#contributionsLoaded ??= this.#contributions();
|
|
744
|
+
return this.#contributionsLoaded;
|
|
745
|
+
}
|
|
746
|
+
|
|
690
747
|
/**
|
|
691
748
|
* Seed a catalog with the CLI's own topics.
|
|
692
749
|
* @param {Record<string, string>} [builtins] topic name → absolute path
|
|
@@ -6,5 +6,32 @@
|
|
|
6
6
|
* @param {string} file
|
|
7
7
|
* @param {string} exportName
|
|
8
8
|
* @param {Set<string>} [seen]
|
|
9
|
+
* @returns {boolean}
|
|
9
10
|
*/
|
|
10
11
|
export function moduleExportsName(file: string, exportName: string, seen?: Set<string>): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The file that declares a module's runtime export, without executing it (the
|
|
14
|
+
* module, or where a local re-export leads); null when it cannot be proved.
|
|
15
|
+
* @param {string} file
|
|
16
|
+
* @param {string} exportName
|
|
17
|
+
* @param {Set<string>} [seen]
|
|
18
|
+
* @returns {string | null}
|
|
19
|
+
*/
|
|
20
|
+
export function moduleExportSource(file: string, exportName: string, seen?: Set<string>): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* The object a module exports, as plain data, read without running it: the
|
|
23
|
+
* first of `exportNames` it exports, an object literal in place or a top-level
|
|
24
|
+
* binding (under `satisfies` or `as` too). Only literal values are kept;
|
|
25
|
+
* anything computed, or overridable by a later spread, is left out.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} file
|
|
28
|
+
* @param {readonly string[]} exportNames `default` or named exports, in order
|
|
29
|
+
* @returns {Record<string, unknown> | null}
|
|
30
|
+
*/
|
|
31
|
+
export function staticExportObject(file: string, exportNames: readonly string[]): Record<string, unknown> | null;
|
|
32
|
+
/**
|
|
33
|
+
* Marks an object {@link staticExportObject} returns (or one inside it) whose
|
|
34
|
+
* source also has properties or spreads it could not read as literals. Not
|
|
35
|
+
* enumerable, so the object compares and serializes as its literal properties.
|
|
36
|
+
*/
|
|
37
|
+
export const HAS_COMPUTED: unique symbol;
|