@astryxdesign/cli 0.7.13-canary.802938b → 0.7.13-canary.9b5fdf5

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.
@@ -11,6 +11,12 @@
11
11
  * Unreadable docs are skipped rather than fatal — a single malformed doc must
12
12
  * not take out theme validation or the listing.
13
13
  *
14
+ * The scan walks every folder under `src` and reads every component doc. A
15
+ * process scans each Core once. It reuses that scan while every folder and
16
+ * doc it read is unchanged, as the docs and search catalogs do. A `src`
17
+ * reached through a symlink, as a project's node_modules reaches Core, shares
18
+ * the scan of its real path. Each call gets its own copy of the rows.
19
+ *
14
20
  * @param {string} coreSrc - absolute path to `<core>/src`
15
21
  * @returns {Promise<ThemingTarget[]>}
16
22
  */
@@ -12,10 +12,13 @@
12
12
  * <Name>` prints; nothing here is a second registry, so the list a
13
13
  * theme author can enumerate and the set the compiler accepts cannot
14
14
  * drift from the components or from each other.
15
+ * A process reuses its target scan of a Core while the folders and
16
+ * docs it read are unchanged.
15
17
  */
16
18
 
17
19
  import * as fs from 'node:fs';
18
20
  import * as path from 'node:path';
21
+ import {reusedWhileUnchanged} from '../fs/read-record.mjs';
19
22
  import {loadComponentDoc} from './component-loader.mjs';
20
23
 
21
24
  const SKIP_DIRS = new Set(['node_modules', '__tests__']);
@@ -53,12 +56,42 @@ function targetKey(className) {
53
56
  * Unreadable docs are skipped rather than fatal — a single malformed doc must
54
57
  * not take out theme validation or the listing.
55
58
  *
59
+ * The scan walks every folder under `src` and reads every component doc. A
60
+ * process scans each Core once. It reuses that scan while every folder and
61
+ * doc it read is unchanged, as the docs and search catalogs do. A `src`
62
+ * reached through a symlink, as a project's node_modules reaches Core, shares
63
+ * the scan of its real path. Each call gets its own copy of the rows.
64
+ *
56
65
  * @param {string} coreSrc - absolute path to `<core>/src`
57
66
  * @returns {Promise<ThemingTarget[]>}
58
67
  */
59
68
  export async function collectThemingTargets(coreSrc) {
60
69
  if (!coreSrc || !fs.existsSync(coreSrc)) return [];
70
+ const real = fs.realpathSync(coreSrc);
71
+ let scan = targetScans.get(real);
72
+ if (scan == null) {
73
+ scan = reusedWhileUnchanged(() => scanThemingTargets(real));
74
+ targetScans.set(real, scan);
75
+ }
76
+ return (await scan()).map(target => ({
77
+ ...target,
78
+ props: [...target.props],
79
+ states: [...target.states],
80
+ }));
81
+ }
61
82
 
83
+ /**
84
+ * The target scan of each Core `src`, by its real path.
85
+ * @type {Map<string, () => Promise<ThemingTarget[]>>}
86
+ */
87
+ const targetScans = new Map();
88
+
89
+ /**
90
+ * Every theming target under `coreSrc`, read from its component docs.
91
+ * @param {string} coreSrc - real path to `<core>/src`
92
+ * @returns {Promise<ThemingTarget[]>}
93
+ */
94
+ async function scanThemingTargets(coreSrc) {
62
95
  /** @type {Array<ThemingTarget & {parent: string|null}>} */
63
96
  const targets = [];
64
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.13-canary.802938b",
3
+ "version": "0.7.13-canary.9b5fdf5",
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",
@@ -125,7 +125,7 @@
125
125
  "zod": "^4.6.7"
126
126
  },
127
127
  "peerDependencies": {
128
- "@astryxdesign/core": "0.7.13-canary.802938b"
128
+ "@astryxdesign/core": "0.7.13-canary.9b5fdf5"
129
129
  },
130
130
  "peerDependenciesMeta": {
131
131
  "@astryxdesign/core": {
@@ -133,10 +133,10 @@
133
133
  }
134
134
  },
135
135
  "devDependencies": {
136
- "@astryxdesign/charts": "0.7.13-canary.802938b",
137
- "@astryxdesign/core": "0.7.13-canary.802938b",
138
- "@astryxdesign/lab": "0.7.13-canary.802938b",
139
- "@astryxdesign/theme-neutral": "0.7.13-canary.802938b",
136
+ "@astryxdesign/charts": "0.7.13-canary.9b5fdf5",
137
+ "@astryxdesign/core": "0.7.13-canary.9b5fdf5",
138
+ "@astryxdesign/lab": "0.7.13-canary.9b5fdf5",
139
+ "@astryxdesign/theme-neutral": "0.7.13-canary.9b5fdf5",
140
140
  "@heroicons/react": "^2.2.0",
141
141
  "@stylexjs/stylex": "^0.19.1",
142
142
  "@types/babel__core": "^7.20.5",