@ttsc/unplugin 0.28.5 → 0.28.6

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.
Files changed (86) hide show
  1. package/README.md +15 -11
  2. package/lib/api.js +10 -0
  3. package/lib/api.js.map +1 -1
  4. package/lib/api.mjs +3 -2
  5. package/lib/api.mjs.map +1 -1
  6. package/lib/bun-register.d.cts +10 -7
  7. package/lib/bun-register.d.mts +10 -7
  8. package/lib/bun-register.d.ts +10 -7
  9. package/lib/bun-register.js +90 -24
  10. package/lib/bun-register.js.map +1 -1
  11. package/lib/bun-register.mjs +90 -24
  12. package/lib/bun-register.mjs.map +1 -1
  13. package/lib/bun.d.cts +10 -8
  14. package/lib/bun.d.mts +10 -8
  15. package/lib/bun.d.ts +10 -8
  16. package/lib/bun.js +19 -17
  17. package/lib/bun.js.map +1 -1
  18. package/lib/bun.mjs +20 -18
  19. package/lib/bun.mjs.map +1 -1
  20. package/lib/core/index.d.cts +10 -8
  21. package/lib/core/index.d.mts +10 -8
  22. package/lib/core/index.d.ts +10 -8
  23. package/lib/core/index.js +88 -16
  24. package/lib/core/index.js.map +1 -1
  25. package/lib/core/index.mjs +81 -18
  26. package/lib/core/index.mjs.map +1 -1
  27. package/lib/core/projectDiscovery.d.cts +55 -0
  28. package/lib/core/projectDiscovery.d.mts +55 -0
  29. package/lib/core/projectDiscovery.d.ts +55 -0
  30. package/lib/core/projectDiscovery.js +187 -0
  31. package/lib/core/projectDiscovery.js.map +1 -0
  32. package/lib/core/projectDiscovery.mjs +182 -0
  33. package/lib/core/projectDiscovery.mjs.map +1 -0
  34. package/lib/core/sourceExtensions.d.cts +10 -0
  35. package/lib/core/sourceExtensions.d.mts +10 -0
  36. package/lib/core/sourceExtensions.d.ts +10 -0
  37. package/lib/core/sourceExtensions.js +38 -0
  38. package/lib/core/sourceExtensions.js.map +1 -0
  39. package/lib/core/sourceExtensions.mjs +32 -0
  40. package/lib/core/sourceExtensions.mjs.map +1 -0
  41. package/lib/core/transform.d.cts +96 -16
  42. package/lib/core/transform.d.mts +96 -16
  43. package/lib/core/transform.d.ts +96 -16
  44. package/lib/core/transform.js +1295 -309
  45. package/lib/core/transform.js.map +1 -1
  46. package/lib/core/transform.mjs +1290 -310
  47. package/lib/core/transform.mjs.map +1 -1
  48. package/lib/core/tsconfigPaths.d.cts +55 -3
  49. package/lib/core/tsconfigPaths.d.mts +55 -3
  50. package/lib/core/tsconfigPaths.d.ts +55 -3
  51. package/lib/core/tsconfigPaths.js +260 -46
  52. package/lib/core/tsconfigPaths.js.map +1 -1
  53. package/lib/core/tsconfigPaths.mjs +255 -47
  54. package/lib/core/tsconfigPaths.mjs.map +1 -1
  55. package/lib/core/viteServe.d.cts +18 -21
  56. package/lib/core/viteServe.d.mts +18 -21
  57. package/lib/core/viteServe.d.ts +18 -21
  58. package/lib/core/viteServe.js +88 -47
  59. package/lib/core/viteServe.js.map +1 -1
  60. package/lib/core/viteServe.mjs +89 -49
  61. package/lib/core/viteServe.mjs.map +1 -1
  62. package/lib/next.d.cts +7 -0
  63. package/lib/next.d.mts +7 -0
  64. package/lib/next.d.ts +7 -0
  65. package/lib/next.js +186 -54
  66. package/lib/next.js.map +1 -1
  67. package/lib/next.mjs +186 -55
  68. package/lib/next.mjs.map +1 -1
  69. package/lib/turbopack.d.cts +6 -4
  70. package/lib/turbopack.d.mts +6 -4
  71. package/lib/turbopack.d.ts +6 -4
  72. package/lib/turbopack.js +11 -10
  73. package/lib/turbopack.js.map +1 -1
  74. package/lib/turbopack.mjs +11 -10
  75. package/lib/turbopack.mjs.map +1 -1
  76. package/package.json +7 -4
  77. package/src/bun-register.ts +112 -25
  78. package/src/bun.ts +60 -50
  79. package/src/core/index.ts +114 -19
  80. package/src/core/projectDiscovery.ts +256 -0
  81. package/src/core/sourceExtensions.ts +47 -0
  82. package/src/core/transform.ts +1671 -361
  83. package/src/core/tsconfigPaths.ts +406 -46
  84. package/src/core/viteServe.ts +125 -74
  85. package/src/next.ts +230 -54
  86. package/src/turbopack.ts +11 -10
@@ -2,22 +2,24 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { createUnplugin } from 'unplugin';
4
4
  import { resolveOptions } from './options.mjs';
5
+ import { typescriptTransformSourcePattern } from './sourceExtensions.mjs';
5
6
  import { createTtscTransformCache, stripQuery, transformTtsc, beginTtscTransformBuild, resetTtscTransformCache, isDeclarationFile } from './transform.mjs';
6
- export { collectExternalInputHashes, collectProjectInputHashes, isProjectWalkPath } from './transform.mjs';
7
+ export { captureWatchInputBaseline, captureWatchInputFileBaseline, collectExternalInputHashes, collectProjectInputHashSnapshot, collectProjectInputHashes, isProjectWalkPath, isWatchInputKeyBaseline, watchInputEvidenceMatchesBaseline } from './transform.mjs';
7
8
  import { createViteServeMissingInputWatch } from './viteServe.mjs';
8
- export { mergeMembershipPolicyOverlay, readProjectMembershipPolicy } from './tsconfigPaths.mjs';
9
+ export { mergeMembershipPolicyOverlay, readProjectMembershipPolicy, readTsconfigSourceSnapshot } from './tsconfigPaths.mjs';
10
+ export { discoverNearestProjectTsconfig, findNearestProjectTsconfig, findProjectTsconfigs } from './projectDiscovery.mjs';
9
11
 
10
12
  const name = "ttsc-unplugin";
11
13
  /**
12
- * Matches the TypeScript source extensions the ttsc transform handles: `.ts`,
13
- * `.tsx`, `.mts`, `.cts` and their `x` forms. JavaScript is deliberately not
14
- * among them, so a `.js` module reaches no adapter's transform.
14
+ * Matches the exact TypeScript source extensions the ttsc transform handles:
15
+ * `.ts`, `.tsx`, `.mts`, and `.cts`. JavaScript and invented extension forms
16
+ * such as `.mtsx` are deliberately excluded.
15
17
  *
16
18
  * Shared with the Bun adapter (`bun.ts`) and the standalone Turbopack loader
17
19
  * (`turbopack.ts`) through {@link isTransformTarget}, so the filter is defined
18
20
  * once and every adapter answers the same way.
19
21
  */
20
- const sourceFilePattern = /\.[cm]?tsx?$/;
22
+ const sourceFilePattern = typescriptTransformSourcePattern;
21
23
  /** Matches any path segment that is a `node_modules` directory (cross-platform). */
22
24
  const nodeModulesPattern = /(?:^|[/\\])node_modules(?:[/\\]|$)/;
23
25
  /**
@@ -57,6 +59,13 @@ const unpluginFactory = (rawOptions = {}) => {
57
59
  // old containers cannot dispose a replacement's freshly initialized cache.
58
60
  let viteBuildOwners = new WeakSet();
59
61
  let viteBuildLifecycles = 0;
62
+ // esbuild schedules one-shot onDispose callbacks after it settles the build
63
+ // Promise. Acquire ownership only at onStart: plugin setup runs before build
64
+ // option validation, and a validation failure has no onDispose callback with
65
+ // which to release a setup-time owner. Once a build has actually started, the
66
+ // count keeps an older delayed callback from disposing its active generation.
67
+ const esbuildOwners = new WeakSet();
68
+ let esbuildLifecycles = 0;
60
69
  return {
61
70
  name,
62
71
  enforce: "pre",
@@ -111,13 +120,14 @@ const unpluginFactory = (rawOptions = {}) => {
111
120
  // project per edit (samchon/ttsc#1301). The watching build hands its
112
121
  // teardown to `closeWatcher` below instead.
113
122
  buildEnd() {
114
- missingInputs.dispose();
115
123
  if (viteBuildOwners.delete(this)) {
116
124
  viteBuildLifecycles -= 1;
117
125
  }
118
- if (viteBuildLifecycles === 0 &&
119
- (viteCommand === "serve" || !viteBuildWatching)) {
120
- resetTtscTransformCache(transformCache);
126
+ if (viteBuildLifecycles === 0) {
127
+ missingInputs.dispose();
128
+ if (viteCommand === "serve" || !viteBuildWatching) {
129
+ resetTtscTransformCache(transformCache);
130
+ }
121
131
  }
122
132
  },
123
133
  // The watching build's real teardown, and the only hook in a
@@ -137,6 +147,7 @@ const unpluginFactory = (rawOptions = {}) => {
137
147
  closeWatcher() {
138
148
  viteBuildOwners = new WeakSet();
139
149
  viteBuildLifecycles = 0;
150
+ missingInputs.dispose();
140
151
  resetTtscTransformCache(transformCache);
141
152
  },
142
153
  },
@@ -174,6 +185,38 @@ const unpluginFactory = (rawOptions = {}) => {
174
185
  resetTtscTransformCache(transformCache);
175
186
  },
176
187
  },
188
+ // These hosts map a top-level buildEnd to a per-compilation hook, so use
189
+ // their true compiler or context teardown instead. The custom callbacks
190
+ // are installed by unplugin alongside its ordinary transform wiring.
191
+ webpack(compiler) {
192
+ compiler.hooks.shutdown.tap(name, () => {
193
+ resetTtscTransformCache(transformCache);
194
+ });
195
+ },
196
+ rspack(compiler) {
197
+ compiler.hooks.shutdown.tap(name, () => {
198
+ resetTtscTransformCache(transformCache);
199
+ });
200
+ },
201
+ esbuild: {
202
+ setup(build) {
203
+ build.onStart(() => {
204
+ if (!esbuildOwners.has(build)) {
205
+ esbuildOwners.add(build);
206
+ esbuildLifecycles += 1;
207
+ }
208
+ });
209
+ build.onDispose(() => {
210
+ if (!esbuildOwners.delete(build)) {
211
+ return;
212
+ }
213
+ esbuildLifecycles -= 1;
214
+ if (esbuildLifecycles === 0) {
215
+ resetTtscTransformCache(transformCache);
216
+ }
217
+ });
218
+ },
219
+ },
177
220
  buildStart() {
178
221
  if (viteCommand !== undefined && !viteBuildOwners.has(this)) {
179
222
  viteBuildOwners.add(this);
@@ -220,19 +263,39 @@ const unpluginFactory = (rawOptions = {}) => {
220
263
  // invalidate this module in watch mode and persistent caches;
221
264
  // bundlers erase type-only imports from their own module graph and
222
265
  // would otherwise serve stale generated code. Under Vite serve a
223
- // missing input must not enter `addWatchFile`: import-analysis
224
- // resolves added imports and 500s on a path that is absent by design
225
- // (a superseding resolution candidate, a not-yet-generated
226
- // dependency), so those are watched on the filesystem instead and
227
- // invalidate this module when created.
266
+ // resolver input that is not proven to be a file must not enter
267
+ // `addWatchFile`: import-analysis resolves added imports and 500s on
268
+ // missing paths and directories, so those are watched against their
269
+ // compiler predicates instead and invalidate this module when the
270
+ // observation changes.
228
271
  addWatchFile: (watched, evidence) => {
229
272
  if (viteCommand === "serve" && missingInputs.serving()) {
273
+ const observation = evidence?.state?.codec === "predicates"
274
+ ? evidence.state.observation
275
+ : undefined;
276
+ const unsafePredicate = observation !== undefined &&
277
+ observation.fileExists !== true &&
278
+ observation.stat !== "file" &&
279
+ observation.readFile?.ok !== true
280
+ ? observation
281
+ : undefined;
282
+ if (unsafePredicate !== undefined) {
283
+ missingInputs.watch(watched, path.resolve(file), unsafePredicate);
284
+ return;
285
+ }
230
286
  // Trust the generation's recorded existence when it supplied one:
231
287
  // every cache hit revalidates it, and probing each input again
232
288
  // costs one `existsSync` per input per delivered module.
233
- const missing = evidence?.missing ?? !fs.existsSync(watched);
234
- if (missing) {
235
- missingInputs.watch(watched, path.resolve(file), evidence?.identity);
289
+ const unavailable = evidence?.unavailable ??
290
+ (evidence === undefined
291
+ ? !fs.existsSync(watched)
292
+ ? "missing"
293
+ : undefined
294
+ : evidence.missing
295
+ ? "missing"
296
+ : undefined);
297
+ if (unavailable !== undefined) {
298
+ missingInputs.watch(watched, path.resolve(file), unavailable === "not-file" ? "file" : "exists");
236
299
  return;
237
300
  }
238
301
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/core/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAoBA,MAAM,IAAI,GAAG,eAAe;AAC5B;;;;;;;;AAQG;AACI,MAAM,iBAAiB,GAAG;AACjC;AACA,MAAM,kBAAkB,GAAG,oCAAoC;AAC/D;;;AAGG;AACH,MAAM,oBAAoB,GAAG,IAAI;AAEjC;;;;;;;;;;;;;AAaG;AACH,MAAM,eAAe,GAGjB,CAAC,UAAU,GAAG,EAAE,KAAI;AACtB,IAAA,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC;AAC1C,IAAA,MAAM,cAAc,GAAG,wBAAwB,EAAE;AACjD,IAAA,MAAM,aAAa,GAAG,gCAAgC,EAAE;AACxD,IAAA,IAAI,OAAgB;AACpB,IAAA,IAAI,WAA+B;IACnC,IAAI,YAAY,GAAG,IAAI;;;;;IAKvB,IAAI,iBAAiB,GAAG,KAAK;;;;;AAK7B,IAAA,IAAI,eAAe,GAAG,IAAI,OAAO,EAAU;IAC3C,IAAI,mBAAmB,GAAG,CAAC;IAE3B,OAAO;QACL,IAAI;AACJ,QAAA,OAAO,EA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,wBAAA,MAAM,EAAE,SAAS,KAAK,QAAQ,EAC9B;wBACA,MAAM,CAAC,aAAa,EAAE,SAAS,GAAG,KAAK,CAAC;oBAC1C;gBACF,CAAC;AACF,aAAA,CAAC;QACJ,CAAC;KACF;AACH,CAAC;AAED,MAAM,QAAQ,GACZ,cAAc,CAAC,eAAe;AAwDhC;;;;;;;;;;;AAWG;AACG,SAAU,iBAAiB,CAAC,EAAU,EAAA;AAC1C,IAAA,QACE,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;AAC1B,QAAA,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,CAAC,iBAAiB,CAAC,EAAE,CAAC;AACtB,QAAA,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;AAEhC;;;;"}
@@ -0,0 +1,55 @@
1
+ import fs from "node:fs";
2
+ /** Filesystem facts required to discover an implicit TypeScript project. */
3
+ export interface TtscProjectDiscoveryFilesystem {
4
+ /** Override path parsing when the observed filesystem is not the host. */
5
+ platform?: NodeJS.Platform;
6
+ /** Read metadata while following links, like an ordinary config-file open. */
7
+ stat(location: string): Pick<fs.Stats, "isFile"> & Partial<Pick<fs.Stats, "isDirectory">>;
8
+ }
9
+ /** Directory enumeration required to discover every implicit child project. */
10
+ export interface TtscProjectTreeDiscoveryFilesystem extends TtscProjectDiscoveryFilesystem {
11
+ /** Enumerate one lexical directory and identify child directory links. */
12
+ readdir(location: string): readonly (Pick<fs.Dirent, "isDirectory" | "name"> & Partial<Pick<fs.Dirent, "isSymbolicLink">>)[];
13
+ /** Resolve physical directory identity for cycle-safe linked traversal. */
14
+ realpath?(location: string): string;
15
+ }
16
+ /** One exact file predicate consulted by nearest-project discovery. */
17
+ export interface TtscProjectTsconfigCandidate {
18
+ readonly file: string;
19
+ readonly fileExists: boolean;
20
+ }
21
+ /** The selected config and the predicates that selected it. */
22
+ export interface TtscProjectTsconfigDiscovery {
23
+ readonly candidates: readonly TtscProjectTsconfigCandidate[];
24
+ readonly file: string | undefined;
25
+ }
26
+ /** Directories deliberately outside the shared lexical project walk. */
27
+ export declare function isIgnoredProjectDirectory(name: string): boolean;
28
+ /**
29
+ * Find the nearest ancestor `tsconfig.json` that is proven to be a file.
30
+ *
31
+ * A directory, broken link, permission failure, or any other unprovable
32
+ * candidate cannot terminate the walk. `stat` deliberately follows links, so a
33
+ * link to a regular file retains its lexical config spelling.
34
+ */
35
+ export declare function findNearestProjectTsconfig(startDirectory: string, filesystem?: TtscProjectDiscoveryFilesystem): string | undefined;
36
+ /**
37
+ * Find the nearest config and retain the exact predicate observations used to
38
+ * select it. A cache host must not rediscover these candidates later: a file
39
+ * can disappear only for selection and return before that second observation.
40
+ */
41
+ export declare function discoverNearestProjectTsconfig(startDirectory: string, filesystem?: TtscProjectDiscoveryFilesystem): TtscProjectTsconfigDiscovery;
42
+ /**
43
+ * Find every regular `tsconfig.json` below one project root.
44
+ *
45
+ * The traversal retains lexical project spellings while following child
46
+ * directory links and junctions. A physical ancestor set cuts cycles without
47
+ * collapsing two independent aliases of the same project. An incomplete
48
+ * traversal is reported rather than returned as a complete project map, so a
49
+ * cache-key caller can refuse reuse.
50
+ */
51
+ export declare function findProjectTsconfigs(root: string, filesystem?: TtscProjectTreeDiscoveryFilesystem): {
52
+ candidates: string[];
53
+ complete: boolean;
54
+ files: string[];
55
+ };
@@ -0,0 +1,55 @@
1
+ import fs from "node:fs";
2
+ /** Filesystem facts required to discover an implicit TypeScript project. */
3
+ export interface TtscProjectDiscoveryFilesystem {
4
+ /** Override path parsing when the observed filesystem is not the host. */
5
+ platform?: NodeJS.Platform;
6
+ /** Read metadata while following links, like an ordinary config-file open. */
7
+ stat(location: string): Pick<fs.Stats, "isFile"> & Partial<Pick<fs.Stats, "isDirectory">>;
8
+ }
9
+ /** Directory enumeration required to discover every implicit child project. */
10
+ export interface TtscProjectTreeDiscoveryFilesystem extends TtscProjectDiscoveryFilesystem {
11
+ /** Enumerate one lexical directory and identify child directory links. */
12
+ readdir(location: string): readonly (Pick<fs.Dirent, "isDirectory" | "name"> & Partial<Pick<fs.Dirent, "isSymbolicLink">>)[];
13
+ /** Resolve physical directory identity for cycle-safe linked traversal. */
14
+ realpath?(location: string): string;
15
+ }
16
+ /** One exact file predicate consulted by nearest-project discovery. */
17
+ export interface TtscProjectTsconfigCandidate {
18
+ readonly file: string;
19
+ readonly fileExists: boolean;
20
+ }
21
+ /** The selected config and the predicates that selected it. */
22
+ export interface TtscProjectTsconfigDiscovery {
23
+ readonly candidates: readonly TtscProjectTsconfigCandidate[];
24
+ readonly file: string | undefined;
25
+ }
26
+ /** Directories deliberately outside the shared lexical project walk. */
27
+ export declare function isIgnoredProjectDirectory(name: string): boolean;
28
+ /**
29
+ * Find the nearest ancestor `tsconfig.json` that is proven to be a file.
30
+ *
31
+ * A directory, broken link, permission failure, or any other unprovable
32
+ * candidate cannot terminate the walk. `stat` deliberately follows links, so a
33
+ * link to a regular file retains its lexical config spelling.
34
+ */
35
+ export declare function findNearestProjectTsconfig(startDirectory: string, filesystem?: TtscProjectDiscoveryFilesystem): string | undefined;
36
+ /**
37
+ * Find the nearest config and retain the exact predicate observations used to
38
+ * select it. A cache host must not rediscover these candidates later: a file
39
+ * can disappear only for selection and return before that second observation.
40
+ */
41
+ export declare function discoverNearestProjectTsconfig(startDirectory: string, filesystem?: TtscProjectDiscoveryFilesystem): TtscProjectTsconfigDiscovery;
42
+ /**
43
+ * Find every regular `tsconfig.json` below one project root.
44
+ *
45
+ * The traversal retains lexical project spellings while following child
46
+ * directory links and junctions. A physical ancestor set cuts cycles without
47
+ * collapsing two independent aliases of the same project. An incomplete
48
+ * traversal is reported rather than returned as a complete project map, so a
49
+ * cache-key caller can refuse reuse.
50
+ */
51
+ export declare function findProjectTsconfigs(root: string, filesystem?: TtscProjectTreeDiscoveryFilesystem): {
52
+ candidates: string[];
53
+ complete: boolean;
54
+ files: string[];
55
+ };
@@ -0,0 +1,55 @@
1
+ import fs from "node:fs";
2
+ /** Filesystem facts required to discover an implicit TypeScript project. */
3
+ export interface TtscProjectDiscoveryFilesystem {
4
+ /** Override path parsing when the observed filesystem is not the host. */
5
+ platform?: NodeJS.Platform;
6
+ /** Read metadata while following links, like an ordinary config-file open. */
7
+ stat(location: string): Pick<fs.Stats, "isFile"> & Partial<Pick<fs.Stats, "isDirectory">>;
8
+ }
9
+ /** Directory enumeration required to discover every implicit child project. */
10
+ export interface TtscProjectTreeDiscoveryFilesystem extends TtscProjectDiscoveryFilesystem {
11
+ /** Enumerate one lexical directory and identify child directory links. */
12
+ readdir(location: string): readonly (Pick<fs.Dirent, "isDirectory" | "name"> & Partial<Pick<fs.Dirent, "isSymbolicLink">>)[];
13
+ /** Resolve physical directory identity for cycle-safe linked traversal. */
14
+ realpath?(location: string): string;
15
+ }
16
+ /** One exact file predicate consulted by nearest-project discovery. */
17
+ export interface TtscProjectTsconfigCandidate {
18
+ readonly file: string;
19
+ readonly fileExists: boolean;
20
+ }
21
+ /** The selected config and the predicates that selected it. */
22
+ export interface TtscProjectTsconfigDiscovery {
23
+ readonly candidates: readonly TtscProjectTsconfigCandidate[];
24
+ readonly file: string | undefined;
25
+ }
26
+ /** Directories deliberately outside the shared lexical project walk. */
27
+ export declare function isIgnoredProjectDirectory(name: string): boolean;
28
+ /**
29
+ * Find the nearest ancestor `tsconfig.json` that is proven to be a file.
30
+ *
31
+ * A directory, broken link, permission failure, or any other unprovable
32
+ * candidate cannot terminate the walk. `stat` deliberately follows links, so a
33
+ * link to a regular file retains its lexical config spelling.
34
+ */
35
+ export declare function findNearestProjectTsconfig(startDirectory: string, filesystem?: TtscProjectDiscoveryFilesystem): string | undefined;
36
+ /**
37
+ * Find the nearest config and retain the exact predicate observations used to
38
+ * select it. A cache host must not rediscover these candidates later: a file
39
+ * can disappear only for selection and return before that second observation.
40
+ */
41
+ export declare function discoverNearestProjectTsconfig(startDirectory: string, filesystem?: TtscProjectDiscoveryFilesystem): TtscProjectTsconfigDiscovery;
42
+ /**
43
+ * Find every regular `tsconfig.json` below one project root.
44
+ *
45
+ * The traversal retains lexical project spellings while following child
46
+ * directory links and junctions. A physical ancestor set cuts cycles without
47
+ * collapsing two independent aliases of the same project. An incomplete
48
+ * traversal is reported rather than returned as a complete project map, so a
49
+ * cache-key caller can refuse reuse.
50
+ */
51
+ export declare function findProjectTsconfigs(root: string, filesystem?: TtscProjectTreeDiscoveryFilesystem): {
52
+ candidates: string[];
53
+ complete: boolean;
54
+ files: string[];
55
+ };
@@ -0,0 +1,187 @@
1
+ 'use strict';
2
+
3
+ var fs = require('node:fs');
4
+ var path = require('node:path');
5
+
6
+ const HOST_PROJECT_DISCOVERY_FILESYSTEM = Object.freeze({
7
+ stat: fs.statSync,
8
+ });
9
+ const HOST_PROJECT_TREE_DISCOVERY_FILESYSTEM = Object.freeze({
10
+ readdir: (location) => fs.readdirSync(location, { withFileTypes: true }),
11
+ realpath: fs.realpathSync.native,
12
+ stat: fs.statSync,
13
+ });
14
+ /** Directories deliberately outside the shared lexical project walk. */
15
+ function isIgnoredProjectDirectory(name) {
16
+ // The residue of what used to be a fifteen-name list, kept to the VCS store,
17
+ // the package manager's tree, and ttsc's own plugin cache. Everything else
18
+ // is decided by the resolved project policy rather than a directory-name
19
+ // guess (samchon/ttsc#1307).
20
+ return name === ".git" || name === ".ttsc" || name === "node_modules";
21
+ }
22
+ /**
23
+ * Find the nearest ancestor `tsconfig.json` that is proven to be a file.
24
+ *
25
+ * A directory, broken link, permission failure, or any other unprovable
26
+ * candidate cannot terminate the walk. `stat` deliberately follows links, so a
27
+ * link to a regular file retains its lexical config spelling.
28
+ */
29
+ function findNearestProjectTsconfig(startDirectory, filesystem = HOST_PROJECT_DISCOVERY_FILESYSTEM) {
30
+ return findNearestProjectTsconfigImpl(startDirectory, filesystem);
31
+ }
32
+ /**
33
+ * Find the nearest config and retain the exact predicate observations used to
34
+ * select it. A cache host must not rediscover these candidates later: a file
35
+ * can disappear only for selection and return before that second observation.
36
+ */
37
+ function discoverNearestProjectTsconfig(startDirectory, filesystem = HOST_PROJECT_DISCOVERY_FILESYSTEM) {
38
+ const candidates = [];
39
+ return {
40
+ candidates,
41
+ file: findNearestProjectTsconfigImpl(startDirectory, filesystem, candidates),
42
+ };
43
+ }
44
+ /** Shared walk with optional observation retention for cache hosts. */
45
+ function findNearestProjectTsconfigImpl(startDirectory, filesystem, candidates) {
46
+ const paths = filesystem.platform === undefined
47
+ ? path
48
+ : filesystem.platform === "win32"
49
+ ? path.win32
50
+ : path.posix;
51
+ let current = paths.resolve(startDirectory);
52
+ while (true) {
53
+ const candidate = paths.join(current, "tsconfig.json");
54
+ let fileExists = false;
55
+ try {
56
+ fileExists = filesystem.stat(candidate).isFile();
57
+ }
58
+ catch {
59
+ // An implicit candidate is selectable only when its file kind is proven.
60
+ }
61
+ candidates?.push({ file: candidate, fileExists });
62
+ if (fileExists) {
63
+ return candidate;
64
+ }
65
+ const parent = paths.dirname(current);
66
+ if (parent === current) {
67
+ return undefined;
68
+ }
69
+ current = parent;
70
+ }
71
+ }
72
+ /**
73
+ * Find every regular `tsconfig.json` below one project root.
74
+ *
75
+ * The traversal retains lexical project spellings while following child
76
+ * directory links and junctions. A physical ancestor set cuts cycles without
77
+ * collapsing two independent aliases of the same project. An incomplete
78
+ * traversal is reported rather than returned as a complete project map, so a
79
+ * cache-key caller can refuse reuse.
80
+ */
81
+ function findProjectTsconfigs(root, filesystem = HOST_PROJECT_TREE_DISCOVERY_FILESYSTEM) {
82
+ const paths = filesystem.platform === undefined
83
+ ? path
84
+ : filesystem.platform === "win32"
85
+ ? path.win32
86
+ : path.posix;
87
+ const rootDirectory = paths.resolve(root);
88
+ const rootIdentity = projectDirectoryIdentity(rootDirectory, filesystem, paths);
89
+ const pending = [
90
+ {
91
+ ancestors: new Set([
92
+ rootIdentity ??
93
+ canonicalProjectPath(rootDirectory, filesystem.platform),
94
+ ]),
95
+ directory: rootDirectory,
96
+ physicalAncestorsComplete: filesystem.realpath === undefined || rootIdentity !== undefined,
97
+ },
98
+ ];
99
+ const candidates = [];
100
+ const files = [];
101
+ let complete = filesystem.realpath === undefined || rootIdentity !== undefined;
102
+ while (pending.length !== 0) {
103
+ const current = pending.pop();
104
+ const directory = current.directory;
105
+ let entries;
106
+ try {
107
+ entries = filesystem.readdir(directory);
108
+ }
109
+ catch {
110
+ complete = false;
111
+ continue;
112
+ }
113
+ for (const entry of entries) {
114
+ if (isIgnoredProjectDirectory(entry.name))
115
+ continue;
116
+ const child = paths.join(directory, entry.name);
117
+ const linked = entry.isSymbolicLink?.() === true;
118
+ let directoryEntry = entry.isDirectory();
119
+ if (!directoryEntry && linked) {
120
+ try {
121
+ directoryEntry = filesystem.stat(child).isDirectory?.() === true;
122
+ }
123
+ catch (error) {
124
+ const code = error.code;
125
+ if (code !== "ENOENT" && code !== "ENOTDIR")
126
+ complete = false;
127
+ continue;
128
+ }
129
+ }
130
+ if (!directoryEntry)
131
+ continue;
132
+ const identity = projectDirectoryIdentity(child, filesystem, paths);
133
+ const physicalAncestorsComplete = current.physicalAncestorsComplete &&
134
+ (filesystem.realpath === undefined || identity !== undefined);
135
+ if (filesystem.realpath !== undefined && identity === undefined) {
136
+ complete = false;
137
+ }
138
+ if (linked && (identity === undefined || !physicalAncestorsComplete)) {
139
+ complete = false;
140
+ continue;
141
+ }
142
+ const stableIdentity = identity ?? canonicalProjectPath(child, filesystem.platform);
143
+ if (current.ancestors.has(stableIdentity))
144
+ continue;
145
+ pending.push({
146
+ ancestors: new Set([...current.ancestors, stableIdentity]),
147
+ directory: child,
148
+ physicalAncestorsComplete,
149
+ });
150
+ }
151
+ const candidate = paths.join(directory, "tsconfig.json");
152
+ candidates.push(candidate);
153
+ try {
154
+ if (filesystem.stat(candidate).isFile()) {
155
+ files.push(candidate);
156
+ }
157
+ }
158
+ catch (error) {
159
+ const code = error.code;
160
+ if (code !== "ENOENT" && code !== "ENOTDIR") {
161
+ complete = false;
162
+ }
163
+ }
164
+ }
165
+ candidates.sort();
166
+ files.sort();
167
+ return { candidates, complete, files };
168
+ }
169
+ function projectDirectoryIdentity(directory, filesystem, paths) {
170
+ if (filesystem.realpath === undefined)
171
+ return undefined;
172
+ try {
173
+ return canonicalProjectPath(paths.resolve(filesystem.realpath(directory)), filesystem.platform);
174
+ }
175
+ catch {
176
+ return undefined;
177
+ }
178
+ }
179
+ function canonicalProjectPath(location, platform) {
180
+ return platform === "win32" ? location.toLowerCase() : location;
181
+ }
182
+
183
+ exports.discoverNearestProjectTsconfig = discoverNearestProjectTsconfig;
184
+ exports.findNearestProjectTsconfig = findNearestProjectTsconfig;
185
+ exports.findProjectTsconfigs = findProjectTsconfigs;
186
+ exports.isIgnoredProjectDirectory = isIgnoredProjectDirectory;
187
+ //# sourceMappingURL=projectDiscovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectDiscovery.js","sources":["../../src/core/projectDiscovery.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAoCA,MAAM,iCAAiC,GACrC,MAAM,CAAC,MAAM,CAAC;IACZ,IAAI,EAAE,EAAE,CAAC,QAAQ;AAClB,CAAA,CAAC;AAEJ,MAAM,sCAAsC,GAC1C,MAAM,CAAC,MAAM,CAAC;AACZ,IAAA,OAAO,EAAE,CAAC,QAAgB,KACxB,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AACnD,IAAA,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;IAChC,IAAI,EAAE,EAAE,CAAC,QAAQ;AAClB,CAAA,CAAC;AAEJ;AACM,SAAU,yBAAyB,CAAC,IAAY,EAAA;;;;;IAKpD,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,cAAc;AACvE;AAEA;;;;;;AAMG;SACa,0BAA0B,CACxC,cAAsB,EACtB,aAA6C,iCAAiC,EAAA;AAE9E,IAAA,OAAO,8BAA8B,CAAC,cAAc,EAAE,UAAU,CAAC;AACnE;AAEA;;;;AAIG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