@ttsc/unplugin 0.28.2 → 0.28.4
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 +71 -7
- package/lib/api.js +3 -0
- package/lib/api.js.map +1 -1
- package/lib/api.mjs +1 -0
- package/lib/api.mjs.map +1 -1
- package/lib/core/index.d.cts +17 -6
- package/lib/core/index.d.mts +17 -6
- package/lib/core/index.d.ts +17 -6
- package/lib/core/index.js +131 -18
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +130 -19
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/transform.d.cts +116 -29
- package/lib/core/transform.d.mts +116 -29
- package/lib/core/transform.d.ts +116 -29
- package/lib/core/transform.js +1502 -222
- package/lib/core/transform.js.map +1 -1
- package/lib/core/transform.mjs +1503 -223
- package/lib/core/transform.mjs.map +1 -1
- package/lib/core/tsconfigPaths.d.cts +61 -0
- package/lib/core/tsconfigPaths.d.mts +61 -0
- package/lib/core/tsconfigPaths.d.ts +61 -0
- package/lib/core/tsconfigPaths.js +190 -7
- package/lib/core/tsconfigPaths.js.map +1 -1
- package/lib/core/tsconfigPaths.mjs +188 -8
- package/lib/core/tsconfigPaths.mjs.map +1 -1
- package/lib/next.d.cts +27 -10
- package/lib/next.d.mts +27 -10
- package/lib/next.d.ts +27 -10
- package/lib/next.js +229 -8
- package/lib/next.js.map +1 -1
- package/lib/next.mjs +229 -8
- package/lib/next.mjs.map +1 -1
- package/lib/turbopack.d.cts +5 -4
- package/lib/turbopack.d.mts +5 -4
- package/lib/turbopack.d.ts +5 -4
- package/lib/turbopack.js +13 -7
- package/lib/turbopack.js.map +1 -1
- package/lib/turbopack.mjs +14 -8
- package/lib/turbopack.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/index.ts +136 -18
- package/src/core/transform.ts +2070 -254
- package/src/core/tsconfigPaths.ts +254 -8
- package/src/next.ts +262 -10
- package/src/turbopack.ts +13 -9
package/lib/core/transform.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ITtscCompilerTransformation } from "ttsc";
|
|
|
3
3
|
import { type FilesystemPathIdentityContext, type FilesystemPathIdentityOperations } from "ttsc/path-identity";
|
|
4
4
|
import type { TransformResult } from "unplugin";
|
|
5
5
|
import type { ResolvedTtscUnpluginOptions } from "./options.mjs";
|
|
6
|
+
import { type ITtscProjectMembershipPolicy } from "./tsconfigPaths.mjs";
|
|
6
7
|
/**
|
|
7
8
|
* The normalised transform result type that this module produces.
|
|
8
9
|
*
|
|
@@ -11,26 +12,39 @@ import type { ResolvedTtscUnpluginOptions } from "./options.mjs";
|
|
|
11
12
|
* `undefined`.
|
|
12
13
|
*/
|
|
13
14
|
export type TtscTransformResult = Exclude<TransformResult, string | null | undefined>;
|
|
14
|
-
/**
|
|
15
|
-
* Normalised alias entry used when building the `paths` overlay for the
|
|
16
|
-
* generated tsconfig. Derived from either a Vite array alias or a webpack/
|
|
17
|
-
* Rspack object alias.
|
|
18
|
-
*/
|
|
19
|
-
export interface TtscTransformAlias {
|
|
20
|
-
/** The alias key (module specifier prefix). */
|
|
21
|
-
find: string;
|
|
22
|
-
/** Absolute or cwd-relative path that the alias points to. */
|
|
23
|
-
replacement: string;
|
|
24
|
-
}
|
|
25
|
-
/** One directory's cheap project-membership identity at generation time. */
|
|
15
|
+
/** One directory's project-membership identity at generation time. */
|
|
26
16
|
interface TtscProjectDirectorySnapshot {
|
|
27
17
|
/** Absolute directory spelling used by the project walk. */
|
|
28
18
|
path: string;
|
|
29
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Whether this directory's subtree can hold a program input.
|
|
21
|
+
*
|
|
22
|
+
* A directory that cannot is still walked and still watched, so a source
|
|
23
|
+
* appearing in it later is noticed, but it takes no part in the membership
|
|
24
|
+
* comparison. That is what lets a bundler create its output directory and
|
|
25
|
+
* fill it without voiding a generation no compiler input touched, for any
|
|
26
|
+
* output directory rather than for fifteen names (samchon/ttsc#1307).
|
|
27
|
+
*/
|
|
28
|
+
relevant: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Digest of the entries the walk itself considers: every immediate child the
|
|
31
|
+
* ignore list does not drop, with its kind.
|
|
32
|
+
*
|
|
33
|
+
* Deliberately not the directory's own metadata. A directory's stamp moves
|
|
34
|
+
* whenever _any_ entry is added or removed, including the ones the walk
|
|
35
|
+
* exists to ignore, so a bundler emitting into `dist/` — or merely creating
|
|
36
|
+
* that directory for the first time — moved the project root's stamp and
|
|
37
|
+
* voided a generation that no compiler input had touched. The ignore list
|
|
38
|
+
* only protects the generation if the membership proof honours it too.
|
|
39
|
+
*/
|
|
30
40
|
signature: string;
|
|
31
41
|
}
|
|
32
42
|
/** Generation-scoped directory watchers used to detect membership changes. */
|
|
33
43
|
interface TtscProjectMutationTracker {
|
|
44
|
+
/** Absolute paths named by generation-time mutation events. */
|
|
45
|
+
changes: Set<string>;
|
|
46
|
+
/** Whether additional event paths were discarded after the witness bound. */
|
|
47
|
+
changesOmitted: boolean;
|
|
34
48
|
close: () => void;
|
|
35
49
|
/**
|
|
36
50
|
* Absolute spellings whose creation, change or removal this tracker would
|
|
@@ -113,6 +127,28 @@ export interface TtscCachedProjectTransform {
|
|
|
113
127
|
* transform.
|
|
114
128
|
*/
|
|
115
129
|
inputHashes: Record<string, string>;
|
|
130
|
+
/**
|
|
131
|
+
* What the resolved configuration admitted into this generation's program.
|
|
132
|
+
*
|
|
133
|
+
* Recorded per generation rather than read per validation because it is a
|
|
134
|
+
* property of the configuration the compile ran under, so a later delivery
|
|
135
|
+
* must judge membership by the same rule the compile did. A tsconfig edit
|
|
136
|
+
* that changes the rule also changes a declared input, which replaces the
|
|
137
|
+
* generation and its policy together.
|
|
138
|
+
*/
|
|
139
|
+
membershipPolicy: ITtscProjectMembershipPolicy;
|
|
140
|
+
/**
|
|
141
|
+
* Files already reported as absent from the program, and the pass that
|
|
142
|
+
* reporting belongs to, so the notice is one per file per pass rather than
|
|
143
|
+
* one per delivery.
|
|
144
|
+
*/
|
|
145
|
+
missingOutputReported?: Set<string>;
|
|
146
|
+
missingOutputEpoch?: number;
|
|
147
|
+
/**
|
|
148
|
+
* The project config this generation compiled, so a module the program does
|
|
149
|
+
* not contain can be told which program that was.
|
|
150
|
+
*/
|
|
151
|
+
tsconfig: string;
|
|
116
152
|
/**
|
|
117
153
|
* Metadata signature of each {@link inputHashes} entry whose hash was proven
|
|
118
154
|
* against an unracing read of the file on disk, in a tick the observed
|
|
@@ -124,6 +160,13 @@ export interface TtscCachedProjectTransform {
|
|
|
124
160
|
* disk bytes against the recorded hash, and may record a signature then.
|
|
125
161
|
*/
|
|
126
162
|
inputSignatures?: Record<string, string>;
|
|
163
|
+
/**
|
|
164
|
+
* Raw source hash of every readable key in the transform output, keyed by
|
|
165
|
+
* filesystem identity. Unlike {@link inputHashes}, this includes source
|
|
166
|
+
* outputs outside the project walk without adding arbitrary output keys to
|
|
167
|
+
* the complete project snapshot.
|
|
168
|
+
*/
|
|
169
|
+
sourceHashes?: Record<string, string>;
|
|
127
170
|
/** Metadata snapshot of every directory in the stable generation walk. */
|
|
128
171
|
projectDirectories?: TtscProjectDirectorySnapshot[];
|
|
129
172
|
/** Live notification state for universal host-input changes. */
|
|
@@ -168,19 +211,50 @@ export interface TtscCachedProjectTransform {
|
|
|
168
211
|
projectRoot: string;
|
|
169
212
|
/** Raw compiler output returned by {@link TtscCompiler.transform}. */
|
|
170
213
|
result: ITtscCompilerTransformation;
|
|
214
|
+
/**
|
|
215
|
+
* The delivery epoch this generation is currently settled against, or
|
|
216
|
+
* `undefined` for a generation no epoch has proven.
|
|
217
|
+
*
|
|
218
|
+
* Set when the generation is compiled, and again whenever a later epoch's
|
|
219
|
+
* first delivery proves the whole generation still matches the filesystem.
|
|
220
|
+
* While it equals the cache's current epoch, each module's first delivery is
|
|
221
|
+
* settled by the supplied source alone, exactly as it was when every pass
|
|
222
|
+
* compiled its own generation (samchon/ttsc#1300).
|
|
223
|
+
*/
|
|
224
|
+
deliveryEpoch?: number;
|
|
225
|
+
/**
|
|
226
|
+
* Whether this generation's non-error diagnostics have been surfaced at all,
|
|
227
|
+
* and the epoch they were last surfaced in.
|
|
228
|
+
*
|
|
229
|
+
* The diagnostics describe one compile of one program, so they belong to the
|
|
230
|
+
* generation rather than to a delivery; a pass that reuses a retained
|
|
231
|
+
* generation still surfaces them once, because a build's warnings are part of
|
|
232
|
+
* what that build reports (samchon/ttsc#1304). The two fields are separate so
|
|
233
|
+
* a persistent host, whose epoch is `undefined`, still reports the first
|
|
234
|
+
* time.
|
|
235
|
+
*/
|
|
236
|
+
diagnosticsReported?: boolean;
|
|
237
|
+
diagnosticsEpoch?: number;
|
|
171
238
|
/**
|
|
172
239
|
* Files already delivered from this generation, keyed by filesystem identity.
|
|
173
|
-
*
|
|
174
|
-
* module's first delivery inside the current
|
|
240
|
+
* A cache with a delivery epoch uses this to skip persistent validation only
|
|
241
|
+
* for a module's first delivery inside the current pass; the set is cleared
|
|
242
|
+
* whenever a new epoch's gate re-proves the generation.
|
|
175
243
|
*/
|
|
176
244
|
servedFiles?: Set<string>;
|
|
245
|
+
/**
|
|
246
|
+
* Absolute path of the adapter-owned scratch directory used for this
|
|
247
|
+
* generation. It is disposed after compilation, so none of its compiler,
|
|
248
|
+
* resolver, or plugin artifacts can be a persistent cache or watch input.
|
|
249
|
+
*/
|
|
250
|
+
scratchDirectory?: string;
|
|
177
251
|
/**
|
|
178
252
|
* Absolute path of the generated temp-dir tsconfig this compile ran against,
|
|
179
253
|
* when an alias/compiler-options overlay required one. The compiler reports
|
|
180
254
|
* it in the envelope's `graph.configs` chain, but it is disposed right after
|
|
181
255
|
* the compile, so registering it as a watch input would invalidate every
|
|
182
|
-
* bundler cache snapshot on the next build; watch derivation must skip
|
|
183
|
-
*
|
|
256
|
+
* bundler cache snapshot on the next build; watch derivation must skip this
|
|
257
|
+
* path. {@link scratchDirectory} owns the wider disposable-input bound.
|
|
184
258
|
*/
|
|
185
259
|
temporaryTsconfig?: string;
|
|
186
260
|
}
|
|
@@ -234,20 +308,31 @@ export declare function normalizeHostInputName(name: string, caseSensitive: bool
|
|
|
234
308
|
/** Create an empty persistent transform cache with isolated filesystem reads. */
|
|
235
309
|
export declare function createTtscTransformCache(operations?: Partial<TtscTransformFilesystemOperations>): TtscTransformCache;
|
|
236
310
|
/**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
311
|
+
* Open a new delivery pass, enabling constant-time first delivery for every
|
|
312
|
+
* module this pass asks for.
|
|
313
|
+
*
|
|
314
|
+
* This deliberately retains the cached generation. The pass boundary is a
|
|
315
|
+
* statement about _deliveries_ — each module is requested at most once inside
|
|
316
|
+
* it — not about whether the compiled program is still correct, which the
|
|
317
|
+
* generation's own recorded snapshot answers and which
|
|
318
|
+
* {@link matchesCachedSource} proves once at the pass's first delivery. Clearing
|
|
319
|
+
* here instead made a host whose `buildStart` repeats recompile the whole
|
|
320
|
+
* project on every rebuild even when no compiler input had changed
|
|
321
|
+
* (samchon/ttsc#1300). Use {@link resetTtscTransformCache} to actually discard a
|
|
322
|
+
* generation and its watchers.
|
|
239
323
|
*
|
|
240
|
-
* Hosts without a guaranteed
|
|
241
|
-
*
|
|
324
|
+
* Hosts without a guaranteed pass boundary use persistent validation unless
|
|
325
|
+
* they have another immutable lifecycle. Bun runtime setup, for example,
|
|
242
326
|
* defines one process-scoped module-loading session.
|
|
243
327
|
*/
|
|
244
328
|
export declare function beginTtscTransformBuild(cache: TtscTransformCache): void;
|
|
245
329
|
/**
|
|
246
|
-
*
|
|
330
|
+
* Discard every generation, dispose its watchers, and return the cache to
|
|
331
|
+
* persistent validation mode.
|
|
247
332
|
*
|
|
248
|
-
* This is
|
|
249
|
-
*
|
|
250
|
-
*
|
|
333
|
+
* This is the unconditional lifecycle boundary, and it is distinct from
|
|
334
|
+
* {@link beginTtscTransformBuild}: a pass ending is not a reason to throw a
|
|
335
|
+
* proven compile away, while a session ending is.
|
|
251
336
|
*/
|
|
252
337
|
export declare function resetTtscTransformCache(cache: TtscTransformCache): void;
|
|
253
338
|
/**
|
|
@@ -365,8 +450,10 @@ interface TtscHostInputValidation {
|
|
|
365
450
|
*/
|
|
366
451
|
export declare function stripQuery(id: string): string;
|
|
367
452
|
/**
|
|
368
|
-
* Returns `true` for
|
|
369
|
-
* `.d.cts`
|
|
453
|
+
* Returns `true` for every declaration-file spelling TypeScript-Go accepts.
|
|
454
|
+
* Besides the standard `.d.ts`, `.d.mts`, and `.d.cts` forms, TypeScript-Go
|
|
455
|
+
* treats an arbitrary-extension source such as `styles.d.css.ts` as a
|
|
456
|
+
* declaration file too.
|
|
370
457
|
*/
|
|
371
458
|
export declare function isDeclarationFile(id: string): boolean;
|
|
372
459
|
/**
|
|
@@ -383,7 +470,7 @@ export declare function createTransformResult(source: string, code: string): Tts
|
|
|
383
470
|
* slash path. Exported so hosts without a per-build boundary (`@ttsc/metro`)
|
|
384
471
|
* can fold the identical input universe into their own cache fingerprints.
|
|
385
472
|
*/
|
|
386
|
-
export declare function collectProjectInputHashes(projectRoot: string, identities?: FilesystemPathIdentityContext, filesystem?: TtscTransformFilesystemOperations): Record<string, string>;
|
|
473
|
+
export declare function collectProjectInputHashes(projectRoot: string, identities?: FilesystemPathIdentityContext, filesystem?: TtscTransformFilesystemOperations, policy?: ITtscProjectMembershipPolicy): Record<string, string>;
|
|
387
474
|
/**
|
|
388
475
|
* Report whether an absolute `file` belongs to the project walk universe of
|
|
389
476
|
* `root`: it lies under `root`, every component exists without traversing a
|
|
@@ -393,7 +480,7 @@ export declare function collectProjectInputHashes(projectRoot: string, identitie
|
|
|
393
480
|
* Missing paths and files reached through symlinks or Windows junctions are
|
|
394
481
|
* out-of-walk inputs that only the reference graph can prove relevant.
|
|
395
482
|
*/
|
|
396
|
-
export declare function isProjectWalkPath(root: string, file: string, _identities?: FilesystemPathIdentityContext, filesystem?: TtscTransformFilesystemOperations): boolean;
|
|
483
|
+
export declare function isProjectWalkPath(root: string, file: string, _identities?: FilesystemPathIdentityContext, filesystem?: TtscTransformFilesystemOperations, policy?: ITtscProjectMembershipPolicy): boolean;
|
|
397
484
|
/**
|
|
398
485
|
* Hash a list of absolute out-of-walk input paths: content SHA-256 for a
|
|
399
486
|
* readable file, a stable directory-kind digest for a directory candidate, and
|
package/lib/core/transform.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ITtscCompilerTransformation } from "ttsc";
|
|
|
3
3
|
import { type FilesystemPathIdentityContext, type FilesystemPathIdentityOperations } from "ttsc/path-identity";
|
|
4
4
|
import type { TransformResult } from "unplugin";
|
|
5
5
|
import type { ResolvedTtscUnpluginOptions } from "./options";
|
|
6
|
+
import { type ITtscProjectMembershipPolicy } from "./tsconfigPaths";
|
|
6
7
|
/**
|
|
7
8
|
* The normalised transform result type that this module produces.
|
|
8
9
|
*
|
|
@@ -11,26 +12,39 @@ import type { ResolvedTtscUnpluginOptions } from "./options";
|
|
|
11
12
|
* `undefined`.
|
|
12
13
|
*/
|
|
13
14
|
export type TtscTransformResult = Exclude<TransformResult, string | null | undefined>;
|
|
14
|
-
/**
|
|
15
|
-
* Normalised alias entry used when building the `paths` overlay for the
|
|
16
|
-
* generated tsconfig. Derived from either a Vite array alias or a webpack/
|
|
17
|
-
* Rspack object alias.
|
|
18
|
-
*/
|
|
19
|
-
export interface TtscTransformAlias {
|
|
20
|
-
/** The alias key (module specifier prefix). */
|
|
21
|
-
find: string;
|
|
22
|
-
/** Absolute or cwd-relative path that the alias points to. */
|
|
23
|
-
replacement: string;
|
|
24
|
-
}
|
|
25
|
-
/** One directory's cheap project-membership identity at generation time. */
|
|
15
|
+
/** One directory's project-membership identity at generation time. */
|
|
26
16
|
interface TtscProjectDirectorySnapshot {
|
|
27
17
|
/** Absolute directory spelling used by the project walk. */
|
|
28
18
|
path: string;
|
|
29
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Whether this directory's subtree can hold a program input.
|
|
21
|
+
*
|
|
22
|
+
* A directory that cannot is still walked and still watched, so a source
|
|
23
|
+
* appearing in it later is noticed, but it takes no part in the membership
|
|
24
|
+
* comparison. That is what lets a bundler create its output directory and
|
|
25
|
+
* fill it without voiding a generation no compiler input touched, for any
|
|
26
|
+
* output directory rather than for fifteen names (samchon/ttsc#1307).
|
|
27
|
+
*/
|
|
28
|
+
relevant: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Digest of the entries the walk itself considers: every immediate child the
|
|
31
|
+
* ignore list does not drop, with its kind.
|
|
32
|
+
*
|
|
33
|
+
* Deliberately not the directory's own metadata. A directory's stamp moves
|
|
34
|
+
* whenever _any_ entry is added or removed, including the ones the walk
|
|
35
|
+
* exists to ignore, so a bundler emitting into `dist/` — or merely creating
|
|
36
|
+
* that directory for the first time — moved the project root's stamp and
|
|
37
|
+
* voided a generation that no compiler input had touched. The ignore list
|
|
38
|
+
* only protects the generation if the membership proof honours it too.
|
|
39
|
+
*/
|
|
30
40
|
signature: string;
|
|
31
41
|
}
|
|
32
42
|
/** Generation-scoped directory watchers used to detect membership changes. */
|
|
33
43
|
interface TtscProjectMutationTracker {
|
|
44
|
+
/** Absolute paths named by generation-time mutation events. */
|
|
45
|
+
changes: Set<string>;
|
|
46
|
+
/** Whether additional event paths were discarded after the witness bound. */
|
|
47
|
+
changesOmitted: boolean;
|
|
34
48
|
close: () => void;
|
|
35
49
|
/**
|
|
36
50
|
* Absolute spellings whose creation, change or removal this tracker would
|
|
@@ -113,6 +127,28 @@ export interface TtscCachedProjectTransform {
|
|
|
113
127
|
* transform.
|
|
114
128
|
*/
|
|
115
129
|
inputHashes: Record<string, string>;
|
|
130
|
+
/**
|
|
131
|
+
* What the resolved configuration admitted into this generation's program.
|
|
132
|
+
*
|
|
133
|
+
* Recorded per generation rather than read per validation because it is a
|
|
134
|
+
* property of the configuration the compile ran under, so a later delivery
|
|
135
|
+
* must judge membership by the same rule the compile did. A tsconfig edit
|
|
136
|
+
* that changes the rule also changes a declared input, which replaces the
|
|
137
|
+
* generation and its policy together.
|
|
138
|
+
*/
|
|
139
|
+
membershipPolicy: ITtscProjectMembershipPolicy;
|
|
140
|
+
/**
|
|
141
|
+
* Files already reported as absent from the program, and the pass that
|
|
142
|
+
* reporting belongs to, so the notice is one per file per pass rather than
|
|
143
|
+
* one per delivery.
|
|
144
|
+
*/
|
|
145
|
+
missingOutputReported?: Set<string>;
|
|
146
|
+
missingOutputEpoch?: number;
|
|
147
|
+
/**
|
|
148
|
+
* The project config this generation compiled, so a module the program does
|
|
149
|
+
* not contain can be told which program that was.
|
|
150
|
+
*/
|
|
151
|
+
tsconfig: string;
|
|
116
152
|
/**
|
|
117
153
|
* Metadata signature of each {@link inputHashes} entry whose hash was proven
|
|
118
154
|
* against an unracing read of the file on disk, in a tick the observed
|
|
@@ -124,6 +160,13 @@ export interface TtscCachedProjectTransform {
|
|
|
124
160
|
* disk bytes against the recorded hash, and may record a signature then.
|
|
125
161
|
*/
|
|
126
162
|
inputSignatures?: Record<string, string>;
|
|
163
|
+
/**
|
|
164
|
+
* Raw source hash of every readable key in the transform output, keyed by
|
|
165
|
+
* filesystem identity. Unlike {@link inputHashes}, this includes source
|
|
166
|
+
* outputs outside the project walk without adding arbitrary output keys to
|
|
167
|
+
* the complete project snapshot.
|
|
168
|
+
*/
|
|
169
|
+
sourceHashes?: Record<string, string>;
|
|
127
170
|
/** Metadata snapshot of every directory in the stable generation walk. */
|
|
128
171
|
projectDirectories?: TtscProjectDirectorySnapshot[];
|
|
129
172
|
/** Live notification state for universal host-input changes. */
|
|
@@ -168,19 +211,50 @@ export interface TtscCachedProjectTransform {
|
|
|
168
211
|
projectRoot: string;
|
|
169
212
|
/** Raw compiler output returned by {@link TtscCompiler.transform}. */
|
|
170
213
|
result: ITtscCompilerTransformation;
|
|
214
|
+
/**
|
|
215
|
+
* The delivery epoch this generation is currently settled against, or
|
|
216
|
+
* `undefined` for a generation no epoch has proven.
|
|
217
|
+
*
|
|
218
|
+
* Set when the generation is compiled, and again whenever a later epoch's
|
|
219
|
+
* first delivery proves the whole generation still matches the filesystem.
|
|
220
|
+
* While it equals the cache's current epoch, each module's first delivery is
|
|
221
|
+
* settled by the supplied source alone, exactly as it was when every pass
|
|
222
|
+
* compiled its own generation (samchon/ttsc#1300).
|
|
223
|
+
*/
|
|
224
|
+
deliveryEpoch?: number;
|
|
225
|
+
/**
|
|
226
|
+
* Whether this generation's non-error diagnostics have been surfaced at all,
|
|
227
|
+
* and the epoch they were last surfaced in.
|
|
228
|
+
*
|
|
229
|
+
* The diagnostics describe one compile of one program, so they belong to the
|
|
230
|
+
* generation rather than to a delivery; a pass that reuses a retained
|
|
231
|
+
* generation still surfaces them once, because a build's warnings are part of
|
|
232
|
+
* what that build reports (samchon/ttsc#1304). The two fields are separate so
|
|
233
|
+
* a persistent host, whose epoch is `undefined`, still reports the first
|
|
234
|
+
* time.
|
|
235
|
+
*/
|
|
236
|
+
diagnosticsReported?: boolean;
|
|
237
|
+
diagnosticsEpoch?: number;
|
|
171
238
|
/**
|
|
172
239
|
* Files already delivered from this generation, keyed by filesystem identity.
|
|
173
|
-
*
|
|
174
|
-
* module's first delivery inside the current
|
|
240
|
+
* A cache with a delivery epoch uses this to skip persistent validation only
|
|
241
|
+
* for a module's first delivery inside the current pass; the set is cleared
|
|
242
|
+
* whenever a new epoch's gate re-proves the generation.
|
|
175
243
|
*/
|
|
176
244
|
servedFiles?: Set<string>;
|
|
245
|
+
/**
|
|
246
|
+
* Absolute path of the adapter-owned scratch directory used for this
|
|
247
|
+
* generation. It is disposed after compilation, so none of its compiler,
|
|
248
|
+
* resolver, or plugin artifacts can be a persistent cache or watch input.
|
|
249
|
+
*/
|
|
250
|
+
scratchDirectory?: string;
|
|
177
251
|
/**
|
|
178
252
|
* Absolute path of the generated temp-dir tsconfig this compile ran against,
|
|
179
253
|
* when an alias/compiler-options overlay required one. The compiler reports
|
|
180
254
|
* it in the envelope's `graph.configs` chain, but it is disposed right after
|
|
181
255
|
* the compile, so registering it as a watch input would invalidate every
|
|
182
|
-
* bundler cache snapshot on the next build; watch derivation must skip
|
|
183
|
-
*
|
|
256
|
+
* bundler cache snapshot on the next build; watch derivation must skip this
|
|
257
|
+
* path. {@link scratchDirectory} owns the wider disposable-input bound.
|
|
184
258
|
*/
|
|
185
259
|
temporaryTsconfig?: string;
|
|
186
260
|
}
|
|
@@ -234,20 +308,31 @@ export declare function normalizeHostInputName(name: string, caseSensitive: bool
|
|
|
234
308
|
/** Create an empty persistent transform cache with isolated filesystem reads. */
|
|
235
309
|
export declare function createTtscTransformCache(operations?: Partial<TtscTransformFilesystemOperations>): TtscTransformCache;
|
|
236
310
|
/**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
311
|
+
* Open a new delivery pass, enabling constant-time first delivery for every
|
|
312
|
+
* module this pass asks for.
|
|
313
|
+
*
|
|
314
|
+
* This deliberately retains the cached generation. The pass boundary is a
|
|
315
|
+
* statement about _deliveries_ — each module is requested at most once inside
|
|
316
|
+
* it — not about whether the compiled program is still correct, which the
|
|
317
|
+
* generation's own recorded snapshot answers and which
|
|
318
|
+
* {@link matchesCachedSource} proves once at the pass's first delivery. Clearing
|
|
319
|
+
* here instead made a host whose `buildStart` repeats recompile the whole
|
|
320
|
+
* project on every rebuild even when no compiler input had changed
|
|
321
|
+
* (samchon/ttsc#1300). Use {@link resetTtscTransformCache} to actually discard a
|
|
322
|
+
* generation and its watchers.
|
|
239
323
|
*
|
|
240
|
-
* Hosts without a guaranteed
|
|
241
|
-
*
|
|
324
|
+
* Hosts without a guaranteed pass boundary use persistent validation unless
|
|
325
|
+
* they have another immutable lifecycle. Bun runtime setup, for example,
|
|
242
326
|
* defines one process-scoped module-loading session.
|
|
243
327
|
*/
|
|
244
328
|
export declare function beginTtscTransformBuild(cache: TtscTransformCache): void;
|
|
245
329
|
/**
|
|
246
|
-
*
|
|
330
|
+
* Discard every generation, dispose its watchers, and return the cache to
|
|
331
|
+
* persistent validation mode.
|
|
247
332
|
*
|
|
248
|
-
* This is
|
|
249
|
-
*
|
|
250
|
-
*
|
|
333
|
+
* This is the unconditional lifecycle boundary, and it is distinct from
|
|
334
|
+
* {@link beginTtscTransformBuild}: a pass ending is not a reason to throw a
|
|
335
|
+
* proven compile away, while a session ending is.
|
|
251
336
|
*/
|
|
252
337
|
export declare function resetTtscTransformCache(cache: TtscTransformCache): void;
|
|
253
338
|
/**
|
|
@@ -365,8 +450,10 @@ interface TtscHostInputValidation {
|
|
|
365
450
|
*/
|
|
366
451
|
export declare function stripQuery(id: string): string;
|
|
367
452
|
/**
|
|
368
|
-
* Returns `true` for
|
|
369
|
-
* `.d.cts`
|
|
453
|
+
* Returns `true` for every declaration-file spelling TypeScript-Go accepts.
|
|
454
|
+
* Besides the standard `.d.ts`, `.d.mts`, and `.d.cts` forms, TypeScript-Go
|
|
455
|
+
* treats an arbitrary-extension source such as `styles.d.css.ts` as a
|
|
456
|
+
* declaration file too.
|
|
370
457
|
*/
|
|
371
458
|
export declare function isDeclarationFile(id: string): boolean;
|
|
372
459
|
/**
|
|
@@ -383,7 +470,7 @@ export declare function createTransformResult(source: string, code: string): Tts
|
|
|
383
470
|
* slash path. Exported so hosts without a per-build boundary (`@ttsc/metro`)
|
|
384
471
|
* can fold the identical input universe into their own cache fingerprints.
|
|
385
472
|
*/
|
|
386
|
-
export declare function collectProjectInputHashes(projectRoot: string, identities?: FilesystemPathIdentityContext, filesystem?: TtscTransformFilesystemOperations): Record<string, string>;
|
|
473
|
+
export declare function collectProjectInputHashes(projectRoot: string, identities?: FilesystemPathIdentityContext, filesystem?: TtscTransformFilesystemOperations, policy?: ITtscProjectMembershipPolicy): Record<string, string>;
|
|
387
474
|
/**
|
|
388
475
|
* Report whether an absolute `file` belongs to the project walk universe of
|
|
389
476
|
* `root`: it lies under `root`, every component exists without traversing a
|
|
@@ -393,7 +480,7 @@ export declare function collectProjectInputHashes(projectRoot: string, identitie
|
|
|
393
480
|
* Missing paths and files reached through symlinks or Windows junctions are
|
|
394
481
|
* out-of-walk inputs that only the reference graph can prove relevant.
|
|
395
482
|
*/
|
|
396
|
-
export declare function isProjectWalkPath(root: string, file: string, _identities?: FilesystemPathIdentityContext, filesystem?: TtscTransformFilesystemOperations): boolean;
|
|
483
|
+
export declare function isProjectWalkPath(root: string, file: string, _identities?: FilesystemPathIdentityContext, filesystem?: TtscTransformFilesystemOperations, policy?: ITtscProjectMembershipPolicy): boolean;
|
|
397
484
|
/**
|
|
398
485
|
* Hash a list of absolute out-of-walk input paths: content SHA-256 for a
|
|
399
486
|
* readable file, a stable directory-kind digest for a directory candidate, and
|