@astryxdesign/cli 0.7.6-canary.3d44c58 → 0.7.6-canary.3dec8e7

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.
@@ -26,6 +26,16 @@
26
26
 
27
27
  import * as fs from 'node:fs';
28
28
  import * as path from 'node:path';
29
+ import {fileStamp, recordContentRead} from '../fs/read-record.mjs';
30
+
31
+ /**
32
+ * What `isAmbient` found for each file, per TypeScript, kept while the
33
+ * file's stamp (`fileStamp`) is the same. A process that compares a package
34
+ * more than once reads the same config each time, and reading a file the way
35
+ * TypeScript does costs far more than a stat.
36
+ * @type {WeakMap<object, Map<string, {stamp: string, ambient: boolean}>>}
37
+ */
38
+ const ambientByFile = new WeakMap();
29
39
 
30
40
  /**
31
41
  * Whether a file the config includes declares types every file sees: a
@@ -36,6 +46,30 @@ import * as path from 'node:path';
36
46
  */
37
47
  function isAmbient(ts, file) {
38
48
  if (/\.d\.[cm]?ts$/.test(file)) return true;
49
+ // A kept answer still counts as reading the file, so an operation that
50
+ // keeps its own result while what it read is unchanged sees a change to it.
51
+ recordContentRead(file);
52
+ const stamp = fileStamp(file);
53
+ if (stamp === '-') return false;
54
+ let known = ambientByFile.get(ts);
55
+ if (known == null) {
56
+ known = new Map();
57
+ ambientByFile.set(ts, known);
58
+ }
59
+ const key = path.resolve(file);
60
+ const seen = known.get(key);
61
+ if (seen && seen.stamp === stamp) return seen.ambient;
62
+ const ambient = readAmbient(ts, file);
63
+ known.set(key, {stamp, ambient});
64
+ return ambient;
65
+ }
66
+
67
+ /**
68
+ * `isAmbient` for a file that is not a declaration file, read afresh.
69
+ * @param {any} ts
70
+ * @param {string} file
71
+ */
72
+ function readAmbient(ts, file) {
39
73
  let text;
40
74
  try {
41
75
  text = fs.readFileSync(file, 'utf8');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.6-canary.3d44c58",
3
+ "version": "0.7.6-canary.3dec8e7",
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.6-canary.3d44c58",
128
- "@astryxdesign/core": "0.7.6-canary.3d44c58",
129
- "@astryxdesign/lab": "0.7.6-canary.3d44c58",
130
- "@astryxdesign/theme-neutral": "0.7.6-canary.3d44c58"
127
+ "@astryxdesign/charts": "0.7.6-canary.3dec8e7",
128
+ "@astryxdesign/core": "0.7.6-canary.3dec8e7",
129
+ "@astryxdesign/lab": "0.7.6-canary.3dec8e7",
130
+ "@astryxdesign/theme-neutral": "0.7.6-canary.3dec8e7"
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.6-canary.3d44c58",
148
- "@astryxdesign/core": "0.7.6-canary.3d44c58",
149
- "@astryxdesign/lab": "0.7.6-canary.3d44c58",
150
- "@astryxdesign/theme-neutral": "0.7.6-canary.3d44c58",
147
+ "@astryxdesign/charts": "0.7.6-canary.3dec8e7",
148
+ "@astryxdesign/core": "0.7.6-canary.3dec8e7",
149
+ "@astryxdesign/lab": "0.7.6-canary.3dec8e7",
150
+ "@astryxdesign/theme-neutral": "0.7.6-canary.3dec8e7",
151
151
  "@heroicons/react": "^2.2.0",
152
152
  "@stylexjs/stylex": "^0.19.0",
153
153
  "@types/babel__core": "^7.20.5",