@astryxdesign/cli 0.7.9-canary.3b44b43 → 0.7.9-canary.6089ee6

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.
@@ -274,6 +274,11 @@ export function topicLinks(catalog: DocsCatalog, entry: import("../../foundation
274
274
  * decides.
275
275
  * @param {unknown} topic
276
276
  * @param {{cwd?: string}} [options]
277
+ * @param {DocsCatalog} [loaded] internal: a catalog the read already loaded,
278
+ * so the read and every part of it share one snapshot of the project's docs
279
+ * (and its memoized lowering) instead of loading the project again for each
280
+ * part. It is a separate argument, never an option, so no caller of the
281
+ * public `docs()` can set it
277
282
  * @returns {Promise<
278
283
  * | {kind: 'topic', catalog: DocsCatalog, entry: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry}
279
284
  * | {kind: 'node', catalog: DocsCatalog, tree: import('../../foundation/doc-compiler/tree.mjs').DocsTree, node: import('../../foundation/doc-compiler/tree.mjs').TreeNode}
@@ -282,7 +287,7 @@ export function topicLinks(catalog: DocsCatalog, entry: import("../../foundation
282
287
  */
283
288
  export function resolveDocsArgument(topic: unknown, { cwd }?: {
284
289
  cwd?: string;
285
- }): Promise<{
290
+ }, loaded?: DocsCatalog): Promise<{
286
291
  kind: "topic";
287
292
  catalog: DocsCatalog;
288
293
  entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry;
@@ -358,13 +363,14 @@ export function notLoaded(catalog: DocsCatalog): string;
358
363
  * and lower it for the topic readers.
359
364
  * @param {unknown} topic
360
365
  * @param {{lang?: string | null, zh?: boolean, dense?: boolean, cwd?: string}} [options]
366
+ * @param {DocsCatalog} [loaded] internal, as {@link resolveDocsArgument}
361
367
  */
362
368
  export function resolveTopicDocs(topic: unknown, options?: {
363
369
  lang?: string | null;
364
370
  zh?: boolean;
365
371
  dense?: boolean;
366
372
  cwd?: string;
367
- }): Promise<{
373
+ }, loaded?: DocsCatalog): Promise<{
368
374
  catalog: DocsCatalog;
369
375
  node: import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode;
370
376
  lang: string | null;
@@ -1721,14 +1721,19 @@ export async function topicLinks(catalog, entry) {
1721
1721
  * decides.
1722
1722
  * @param {unknown} topic
1723
1723
  * @param {{cwd?: string}} [options]
1724
+ * @param {DocsCatalog} [loaded] internal: a catalog the read already loaded,
1725
+ * so the read and every part of it share one snapshot of the project's docs
1726
+ * (and its memoized lowering) instead of loading the project again for each
1727
+ * part. It is a separate argument, never an option, so no caller of the
1728
+ * public `docs()` can set it
1724
1729
  * @returns {Promise<
1725
1730
  * | {kind: 'topic', catalog: DocsCatalog, entry: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry}
1726
1731
  * | {kind: 'node', catalog: DocsCatalog, tree: import('../../foundation/doc-compiler/tree.mjs').DocsTree, node: import('../../foundation/doc-compiler/tree.mjs').TreeNode}
1727
1732
  * | {kind: 'unknown', catalog: DocsCatalog}
1728
1733
  * >}
1729
1734
  */
1730
- export async function resolveDocsArgument(topic, {cwd} = {}) {
1731
- const catalog = await loadDocsCatalog(cwd);
1735
+ export async function resolveDocsArgument(topic, {cwd} = {}, loaded) {
1736
+ const catalog = loaded ?? (await loadDocsCatalog(cwd));
1732
1737
  if (typeof topic !== 'string' || topic === '')
1733
1738
  return {kind: 'unknown', catalog};
1734
1739
  const tree = await projectTree(catalog);
@@ -1942,13 +1947,14 @@ export function notLoaded(catalog) {
1942
1947
  * and lower it for the topic readers.
1943
1948
  * @param {unknown} topic
1944
1949
  * @param {{lang?: string | null, zh?: boolean, dense?: boolean, cwd?: string}} [options]
1950
+ * @param {DocsCatalog} [loaded] internal, as {@link resolveDocsArgument}
1945
1951
  */
1946
- export async function resolveTopicDocs(topic, options = {}) {
1952
+ export async function resolveTopicDocs(topic, options = {}, loaded) {
1947
1953
  const {lang = null, zh = false, dense = false, cwd} = options;
1948
1954
  const effectiveLang = lang || (dense ? 'dense' : zh ? 'zh' : null);
1949
1955
  // A public API caller could pass a non-string topic; it lands on the same
1950
1956
  // stable code as an unknown name rather than a raw TypeError.
1951
- const found = await resolveDocsArgument(topic, {cwd});
1957
+ const found = await resolveDocsArgument(topic, {cwd}, loaded);
1952
1958
  if (found.kind !== 'topic') {
1953
1959
  throw found.kind === 'node'
1954
1960
  ? new AstryxError(
@@ -30,14 +30,17 @@ export function section(topic: string, sectionName: string, options?: {
30
30
  * with the section its own section read returns for the query; when that
31
31
  * section's key (its `id`, else the key its title derives) is the query in
32
32
  * some guides, those guides answer first. No guide, or several, fail with ERR_UNKNOWN_SECTION, naming
33
- * the guides to read instead.
33
+ * the guides to read instead. Every guide is read from `catalog`, the one the
34
+ * namespace read loaded, so the read loads the project once, not once per
35
+ * guide below the namespace.
36
+ * @param {import('../../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
34
37
  * @param {import('../../../../foundation/doc-compiler/tree.mjs').DocsTree} tree
35
38
  * @param {import('../../../../foundation/doc-compiler/tree.mjs').TreeNode} namespace
36
39
  * @param {string} sectionName
37
40
  * @param {object} [options] as {@link section}
38
41
  * @returns {Promise<import('../../docs.type.mjs').DocsDetailSectionResponse>}
39
42
  */
40
- export function namespaceSection(tree: import("../../../../foundation/doc-compiler/tree.mjs").DocsTree, namespace: import("../../../../foundation/doc-compiler/tree.mjs").TreeNode, sectionName: string, options?: object): Promise<import("../../docs.type.mjs").DocsDetailSectionResponse>;
43
+ export function namespaceSection(catalog: import("../../../../foundation/discovery/docs-discovery.mjs").DocsCatalog, tree: import("../../../../foundation/doc-compiler/tree.mjs").DocsTree, namespace: import("../../../../foundation/doc-compiler/tree.mjs").TreeNode, sectionName: string, options?: object): Promise<import("../../docs.type.mjs").DocsDetailSectionResponse>;
41
44
  /**
42
45
  * The guide a namespace section read answers from, or null to ask. When the
43
46
  * query matches sections in several guides, the read asks the reader which
@@ -130,7 +130,10 @@ async function sectionResponse({catalog, node, lang, entry}, sections, match) {
130
130
  * with the section its own section read returns for the query; when that
131
131
  * section's key (its `id`, else the key its title derives) is the query in
132
132
  * some guides, those guides answer first. No guide, or several, fail with ERR_UNKNOWN_SECTION, naming
133
- * the guides to read instead.
133
+ * the guides to read instead. Every guide is read from `catalog`, the one the
134
+ * namespace read loaded, so the read loads the project once, not once per
135
+ * guide below the namespace.
136
+ * @param {import('../../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
134
137
  * @param {import('../../../../foundation/doc-compiler/tree.mjs').DocsTree} tree
135
138
  * @param {import('../../../../foundation/doc-compiler/tree.mjs').TreeNode} namespace
136
139
  * @param {string} sectionName
@@ -138,6 +141,7 @@ async function sectionResponse({catalog, node, lang, entry}, sections, match) {
138
141
  * @returns {Promise<import('../../docs.type.mjs').DocsDetailSectionResponse>}
139
142
  */
140
143
  export async function namespaceSection(
144
+ catalog,
141
145
  tree,
142
146
  namespace,
143
147
  sectionName,
@@ -148,7 +152,7 @@ export async function namespaceSection(
148
152
  /** @type {Omit<GuideMatch, 'match'>[]} */
149
153
  const reads = [];
150
154
  for (const guide of guides) {
151
- const resolved = await resolveTopicDocs(guide.route, options);
155
+ const resolved = await resolveTopicDocs(guide.route, options, catalog);
152
156
  reads.push({guide, resolved, sections: readerSections(resolved.node)});
153
157
  }
154
158
 
package/api/docs/docs.mjs CHANGED
@@ -155,7 +155,13 @@ async function docsRead(topic, section, options = {}) {
155
155
  // A namespace answers a section read from the one guide below it that
156
156
  // has the section (spec:AST-046 FR6). A typed doc is one read.
157
157
  if (found.node.kind === 'namespace') {
158
- return namespaceSection(found.tree, found.node, section, options);
158
+ return namespaceSection(
159
+ found.catalog,
160
+ found.tree,
161
+ found.node,
162
+ section,
163
+ options,
164
+ );
159
165
  }
160
166
  throw new AstryxError(
161
167
  `"${found.node.route}" has no sections. Read it whole: ${formatCliCommand(`docs ${found.node.route}`)}.`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.9-canary.3b44b43",
3
+ "version": "0.7.9-canary.6089ee6",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -124,10 +124,10 @@
124
124
  "zod": "^4.4.3"
125
125
  },
126
126
  "peerDependencies": {
127
- "@astryxdesign/charts": "0.7.9-canary.3b44b43",
128
- "@astryxdesign/core": "0.7.9-canary.3b44b43",
129
- "@astryxdesign/lab": "0.7.9-canary.3b44b43",
130
- "@astryxdesign/theme-neutral": "0.7.9-canary.3b44b43"
127
+ "@astryxdesign/charts": "0.7.9-canary.6089ee6",
128
+ "@astryxdesign/core": "0.7.9-canary.6089ee6",
129
+ "@astryxdesign/lab": "0.7.9-canary.6089ee6",
130
+ "@astryxdesign/theme-neutral": "0.7.9-canary.6089ee6"
131
131
  },
132
132
  "peerDependenciesMeta": {
133
133
  "@astryxdesign/charts": {
@@ -144,10 +144,10 @@
144
144
  }
145
145
  },
146
146
  "devDependencies": {
147
- "@astryxdesign/charts": "0.7.9-canary.3b44b43",
148
- "@astryxdesign/core": "0.7.9-canary.3b44b43",
149
- "@astryxdesign/lab": "0.7.9-canary.3b44b43",
150
- "@astryxdesign/theme-neutral": "0.7.9-canary.3b44b43",
147
+ "@astryxdesign/charts": "0.7.9-canary.6089ee6",
148
+ "@astryxdesign/core": "0.7.9-canary.6089ee6",
149
+ "@astryxdesign/lab": "0.7.9-canary.6089ee6",
150
+ "@astryxdesign/theme-neutral": "0.7.9-canary.6089ee6",
151
151
  "@heroicons/react": "^2.2.0",
152
152
  "@stylexjs/stylex": "^0.19.0",
153
153
  "@types/babel__core": "^7.20.5",