typescript 7.1.0-dev.20260924.1 → 7.1.0-dev.20260926.1
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/dist/api/async/api.d.ts +63 -3
- package/dist/api/async/api.d.ts.map +1 -1
- package/dist/api/async/api.js +169 -8
- package/dist/api/async/api.js.map +1 -1
- package/dist/api/fs.d.ts +1 -1
- package/dist/api/fs.d.ts.map +1 -1
- package/dist/api/fs.js +1 -1
- package/dist/api/fs.js.map +1 -1
- package/dist/api/node/node.d.ts +1 -1
- package/dist/api/node/node.d.ts.map +1 -1
- package/dist/api/node/node.infrastructure.d.ts +3 -2
- package/dist/api/node/node.infrastructure.d.ts.map +1 -1
- package/dist/api/node/node.infrastructure.js +13 -40
- package/dist/api/node/node.infrastructure.js.map +1 -1
- package/dist/api/node/node.js +1 -1
- package/dist/api/node/node.js.map +1 -1
- package/dist/api/node/protocol.d.ts +5 -2
- package/dist/api/node/protocol.d.ts.map +1 -1
- package/dist/api/node/protocol.js +5 -2
- package/dist/api/node/protocol.js.map +1 -1
- package/dist/api/proto.d.ts +3 -0
- package/dist/api/proto.d.ts.map +1 -1
- package/dist/api/proto.generated.d.ts +56 -2
- package/dist/api/proto.generated.d.ts.map +1 -1
- package/dist/api/proto.js.map +1 -1
- package/dist/api/sourceFileCache.d.ts +15 -6
- package/dist/api/sourceFileCache.d.ts.map +1 -1
- package/dist/api/sourceFileCache.js +59 -27
- package/dist/api/sourceFileCache.js.map +1 -1
- package/dist/api/sync/api.d.ts +86 -5
- package/dist/api/sync/api.d.ts.map +1 -1
- package/dist/api/sync/api.js +273 -15
- package/dist/api/sync/api.js.map +1 -1
- package/dist/ast/ast.generated.d.ts +1 -1
- package/dist/ast/ast.generated.d.ts.map +1 -1
- package/dist/ast/is.generated.js +1 -1
- package/dist/ast/is.generated.js.map +1 -1
- package/dist/ast/modifiers.d.ts +4 -0
- package/dist/ast/modifiers.d.ts.map +1 -0
- package/dist/ast/modifiers.js +41 -0
- package/dist/ast/modifiers.js.map +1 -0
- package/dist/ast/utils.d.ts +5 -1
- package/dist/ast/utils.d.ts.map +1 -1
- package/dist/ast/utils.js +220 -0
- package/dist/ast/utils.js.map +1 -1
- package/dist/enums/jsDeclarationKind.d.ts +2 -0
- package/dist/enums/jsDeclarationKind.d.ts.map +1 -0
- package/dist/enums/jsDeclarationKind.enum.d.ts +10 -0
- package/dist/enums/jsDeclarationKind.enum.d.ts.map +1 -0
- package/dist/enums/jsDeclarationKind.enum.js +12 -0
- package/dist/enums/jsDeclarationKind.enum.js.map +1 -0
- package/dist/enums/jsDeclarationKind.js +12 -0
- package/dist/enums/jsDeclarationKind.js.map +1 -0
- package/package.json +9 -9
package/dist/api/sync/api.js
CHANGED
|
@@ -21,7 +21,7 @@ import { TypePredicateKind } from "#enums/typePredicateKind";
|
|
|
21
21
|
import { ModifierFlags, unescapeLeadingUnderscores, } from "../../ast/index.js";
|
|
22
22
|
import { assertNever } from "../../internal/utils.js";
|
|
23
23
|
import { encodeNode, uint8ArrayToBase64, } from "../node/encoder.js";
|
|
24
|
-
import { decodeNode, getNodeId, parseNodeHandle, readParseOptionsKey, readSourceFileHash, RemoteSourceFile, } from "../node/node.js";
|
|
24
|
+
import { decodeNode, getNodeId, parseNodeHandle, readParseOptionsKey, readSourceFileHash, readSourceFileLease, RemoteSourceFile, } from "../node/node.js";
|
|
25
25
|
import { Wtf8Decoder } from "../node/wtf8.js";
|
|
26
26
|
import { createGetCanonicalFileName, toPath, } from "../path.js";
|
|
27
27
|
import { resolveFileName, toCreateSnapshotRequest, } from "../proto.js";
|
|
@@ -59,6 +59,8 @@ export class API {
|
|
|
59
59
|
initialized = false;
|
|
60
60
|
initializing;
|
|
61
61
|
activeSnapshots = new Map();
|
|
62
|
+
activeBuildOrchestrators = new Set();
|
|
63
|
+
activeSourceFileLeases = new Map();
|
|
62
64
|
printer;
|
|
63
65
|
internal;
|
|
64
66
|
constructor(options = {}) {
|
|
@@ -145,6 +147,34 @@ export class API {
|
|
|
145
147
|
getNewLine() {
|
|
146
148
|
return "\n";
|
|
147
149
|
}
|
|
150
|
+
get createBuildOrchestrator() {
|
|
151
|
+
const owner = this;
|
|
152
|
+
return cacheGeneratorMethod(owner, "createBuildOrchestrator", function (rootNames, buildOrchestratorOptions) {
|
|
153
|
+
owner.ensureInitialized();
|
|
154
|
+
const orchestratorResponse = owner.client.apiRequest("createBuildOrchestrator", {
|
|
155
|
+
...buildOrchestratorOptions,
|
|
156
|
+
...buildOrchestratorOptions.overrideCompilerOptions,
|
|
157
|
+
rootNames,
|
|
158
|
+
});
|
|
159
|
+
const orchestrator = new BuildOrchestrator(owner.client, orchestratorResponse, () => {
|
|
160
|
+
owner.activeBuildOrchestrators.delete(orchestrator);
|
|
161
|
+
});
|
|
162
|
+
owner.activeBuildOrchestrators.add(orchestrator);
|
|
163
|
+
return orchestrator;
|
|
164
|
+
}, function* (rootNames, buildOrchestratorOptions) {
|
|
165
|
+
yield* owner.ensureInitialized.gen();
|
|
166
|
+
const orchestratorResponse = yield* apiRequest("createBuildOrchestrator", {
|
|
167
|
+
...buildOrchestratorOptions,
|
|
168
|
+
...buildOrchestratorOptions.overrideCompilerOptions,
|
|
169
|
+
rootNames,
|
|
170
|
+
});
|
|
171
|
+
const orchestrator = new BuildOrchestrator(owner.client, orchestratorResponse, () => {
|
|
172
|
+
owner.activeBuildOrchestrators.delete(orchestrator);
|
|
173
|
+
});
|
|
174
|
+
owner.activeBuildOrchestrators.add(orchestrator);
|
|
175
|
+
return orchestrator;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
148
178
|
get parseConfigFile() {
|
|
149
179
|
const owner = this;
|
|
150
180
|
return cacheGeneratorMethod(owner, "parseConfigFile", function (file) {
|
|
@@ -185,6 +215,10 @@ export class API {
|
|
|
185
215
|
return yield* apiRequest("parseJsonConfigFileContent", { json, ...options });
|
|
186
216
|
});
|
|
187
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Create and retain a source file independently of a program.
|
|
220
|
+
* Dispose the returned lease when the source file no longer needs to remain available remotely.
|
|
221
|
+
*/
|
|
188
222
|
get createSourceFile() {
|
|
189
223
|
const owner = this;
|
|
190
224
|
return cacheGeneratorMethod(owner, "createSourceFile", function (fileName, sourceText, options = {}) {
|
|
@@ -193,16 +227,20 @@ export class API {
|
|
|
193
227
|
if (!data) {
|
|
194
228
|
throw new Error("createSourceFile returned no source file");
|
|
195
229
|
}
|
|
196
|
-
return
|
|
230
|
+
return owner.retainSourceFileResponse(data);
|
|
197
231
|
}, function* (fileName, sourceText, options = {}) {
|
|
198
232
|
yield* owner.ensureInitialized.gen();
|
|
199
233
|
const data = sourceFileResponseToUint8Array(yield* apiRequest("createSourceFile", { fileName, sourceText, options }));
|
|
200
234
|
if (!data) {
|
|
201
235
|
throw new Error("createSourceFile returned no source file");
|
|
202
236
|
}
|
|
203
|
-
return
|
|
237
|
+
return owner.retainSourceFileResponse(data);
|
|
204
238
|
});
|
|
205
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Read, create, and retain a source file independently of a program.
|
|
242
|
+
* Dispose the returned lease when the source file no longer needs to remain available remotely.
|
|
243
|
+
*/
|
|
206
244
|
get createSourceFileFromFile() {
|
|
207
245
|
const owner = this;
|
|
208
246
|
return cacheGeneratorMethod(owner, "createSourceFileFromFile", function (file, options = {}) {
|
|
@@ -211,16 +249,37 @@ export class API {
|
|
|
211
249
|
if (!data) {
|
|
212
250
|
throw new Error("createSourceFileFromFile returned no source file");
|
|
213
251
|
}
|
|
214
|
-
return
|
|
252
|
+
return owner.retainSourceFileResponse(data);
|
|
215
253
|
}, function* (file, options = {}) {
|
|
216
254
|
yield* owner.ensureInitialized.gen();
|
|
217
255
|
const data = sourceFileResponseToUint8Array(yield* apiRequest("createSourceFileFromFile", { fileName: resolveFileName(file), options }));
|
|
218
256
|
if (!data) {
|
|
219
257
|
throw new Error("createSourceFileFromFile returned no source file");
|
|
220
258
|
}
|
|
221
|
-
return
|
|
259
|
+
return owner.retainSourceFileResponse(data);
|
|
222
260
|
});
|
|
223
261
|
}
|
|
262
|
+
retainSourceFileResponse(data) {
|
|
263
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
264
|
+
const lease = readSourceFileLease(view);
|
|
265
|
+
try {
|
|
266
|
+
const decoded = new RemoteSourceFile(data, this.decoder, this.client.getTimingCollector());
|
|
267
|
+
const sourceFile = this.sourceFileCache.setForLease(decoded.path, decoded, readParseOptionsKey(view), readSourceFileHash(view), lease);
|
|
268
|
+
const retained = new RetainedSourceFile(sourceFile, lease, this.client, () => {
|
|
269
|
+
this.activeSourceFileLeases.delete(lease);
|
|
270
|
+
this.sourceFileCache.releaseLease(lease);
|
|
271
|
+
});
|
|
272
|
+
this.activeSourceFileLeases.set(lease, retained);
|
|
273
|
+
return retained;
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
try {
|
|
277
|
+
this.client.apiRequest("releaseSourceFile", { lease });
|
|
278
|
+
}
|
|
279
|
+
catch { }
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
224
283
|
get transpileModule() {
|
|
225
284
|
const owner = this;
|
|
226
285
|
return cacheGeneratorMethod(owner, "transpileModule", function (input, options = {}) {
|
|
@@ -420,26 +479,44 @@ export class API {
|
|
|
420
479
|
get close() {
|
|
421
480
|
const owner = this;
|
|
422
481
|
return cacheGeneratorMethod(owner, "close", function () {
|
|
423
|
-
// Dispose all active snapshots
|
|
424
482
|
try {
|
|
425
|
-
for (const
|
|
426
|
-
|
|
483
|
+
for (const retained of [...owner.activeSourceFileLeases.values()]) {
|
|
484
|
+
retained.dispose();
|
|
427
485
|
}
|
|
428
|
-
owner.sourceFileCache.clear();
|
|
429
486
|
}
|
|
430
487
|
finally {
|
|
431
|
-
|
|
488
|
+
try {
|
|
489
|
+
for (const orchestrator of [...owner.activeBuildOrchestrators]) {
|
|
490
|
+
orchestrator.dispose();
|
|
491
|
+
}
|
|
492
|
+
for (const snapshot of [...owner.activeSnapshots.values()]) {
|
|
493
|
+
snapshot.dispose();
|
|
494
|
+
}
|
|
495
|
+
owner.sourceFileCache.clear();
|
|
496
|
+
}
|
|
497
|
+
finally {
|
|
498
|
+
owner.client.close(); // always close the underlying connection
|
|
499
|
+
}
|
|
432
500
|
}
|
|
433
501
|
}, function* () {
|
|
434
|
-
// Dispose all active snapshots
|
|
435
502
|
try {
|
|
436
|
-
for (const
|
|
437
|
-
yield*
|
|
503
|
+
for (const retained of [...owner.activeSourceFileLeases.values()]) {
|
|
504
|
+
yield* retained.dispose.gen();
|
|
438
505
|
}
|
|
439
|
-
owner.sourceFileCache.clear();
|
|
440
506
|
}
|
|
441
507
|
finally {
|
|
442
|
-
|
|
508
|
+
try {
|
|
509
|
+
for (const orchestrator of [...owner.activeBuildOrchestrators]) {
|
|
510
|
+
yield* orchestrator.dispose.gen();
|
|
511
|
+
}
|
|
512
|
+
for (const snapshot of [...owner.activeSnapshots.values()]) {
|
|
513
|
+
yield* snapshot.dispose.gen();
|
|
514
|
+
}
|
|
515
|
+
owner.sourceFileCache.clear();
|
|
516
|
+
}
|
|
517
|
+
finally {
|
|
518
|
+
owner.client.close(); // always close the underlying connection
|
|
519
|
+
}
|
|
443
520
|
}
|
|
444
521
|
});
|
|
445
522
|
}
|
|
@@ -582,6 +659,56 @@ export class API {
|
|
|
582
659
|
});
|
|
583
660
|
}
|
|
584
661
|
}
|
|
662
|
+
/** An independently retained source file and its disposable remote-lifetime lease. */
|
|
663
|
+
export class RetainedSourceFile {
|
|
664
|
+
sourceFile;
|
|
665
|
+
lease;
|
|
666
|
+
client;
|
|
667
|
+
onDispose;
|
|
668
|
+
disposed = false;
|
|
669
|
+
disposePromise;
|
|
670
|
+
constructor(sourceFile, lease, client, onDispose) {
|
|
671
|
+
this.sourceFile = sourceFile;
|
|
672
|
+
this.lease = lease;
|
|
673
|
+
this.client = client;
|
|
674
|
+
this.onDispose = onDispose;
|
|
675
|
+
}
|
|
676
|
+
[globalThis.Symbol.dispose]() {
|
|
677
|
+
this.dispose();
|
|
678
|
+
}
|
|
679
|
+
get dispose() {
|
|
680
|
+
const owner = this;
|
|
681
|
+
return cacheGeneratorMethod(owner, "dispose", function () {
|
|
682
|
+
return owner.disposePromise ??= owner.disposeWorker();
|
|
683
|
+
}, function* () {
|
|
684
|
+
return owner.disposePromise ??= yield* owner.disposeWorker.gen();
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
get disposeWorker() {
|
|
688
|
+
const owner = this;
|
|
689
|
+
return cacheGeneratorMethod(owner, "disposeWorker", function () {
|
|
690
|
+
if (owner.disposed)
|
|
691
|
+
return;
|
|
692
|
+
owner.disposed = true;
|
|
693
|
+
try {
|
|
694
|
+
owner.client.apiRequest("releaseSourceFile", { lease: owner.lease });
|
|
695
|
+
}
|
|
696
|
+
finally {
|
|
697
|
+
owner.onDispose();
|
|
698
|
+
}
|
|
699
|
+
}, function* () {
|
|
700
|
+
if (owner.disposed)
|
|
701
|
+
return;
|
|
702
|
+
owner.disposed = true;
|
|
703
|
+
try {
|
|
704
|
+
yield* apiRequest("releaseSourceFile", { lease: owner.lease });
|
|
705
|
+
}
|
|
706
|
+
finally {
|
|
707
|
+
owner.onDispose();
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
}
|
|
585
712
|
export class InternalAPI {
|
|
586
713
|
client;
|
|
587
714
|
ensureInitialized;
|
|
@@ -2243,6 +2370,137 @@ export class Program {
|
|
|
2243
2370
|
return this.project;
|
|
2244
2371
|
}
|
|
2245
2372
|
}
|
|
2373
|
+
export class BuildOrchestrator {
|
|
2374
|
+
client;
|
|
2375
|
+
id;
|
|
2376
|
+
disposed = false;
|
|
2377
|
+
disposePromise;
|
|
2378
|
+
onDispose;
|
|
2379
|
+
constructor(client, orchestratorResponse, onDispose) {
|
|
2380
|
+
this.client = client;
|
|
2381
|
+
this.id = orchestratorResponse.buildOrchestratorID;
|
|
2382
|
+
this.onDispose = onDispose;
|
|
2383
|
+
}
|
|
2384
|
+
[globalThis.Symbol.dispose]() {
|
|
2385
|
+
void this.dispose();
|
|
2386
|
+
}
|
|
2387
|
+
get dispose() {
|
|
2388
|
+
const owner = this;
|
|
2389
|
+
return cacheGeneratorMethod(owner, "dispose", function () {
|
|
2390
|
+
return owner.disposePromise ??= owner.disposeWorker();
|
|
2391
|
+
}, function* () {
|
|
2392
|
+
return owner.disposePromise ??= yield* owner.disposeWorker.gen();
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
get disposeWorker() {
|
|
2396
|
+
const owner = this;
|
|
2397
|
+
return cacheGeneratorMethod(owner, "disposeWorker", function () {
|
|
2398
|
+
if (owner.disposed)
|
|
2399
|
+
return;
|
|
2400
|
+
owner.disposed = true;
|
|
2401
|
+
try {
|
|
2402
|
+
owner.client.apiRequest("disposeBuildOrchestrator", {
|
|
2403
|
+
buildOrchestratorID: owner.id,
|
|
2404
|
+
});
|
|
2405
|
+
}
|
|
2406
|
+
finally {
|
|
2407
|
+
owner.onDispose();
|
|
2408
|
+
}
|
|
2409
|
+
}, function* () {
|
|
2410
|
+
if (owner.disposed)
|
|
2411
|
+
return;
|
|
2412
|
+
owner.disposed = true;
|
|
2413
|
+
try {
|
|
2414
|
+
yield* apiRequest("disposeBuildOrchestrator", {
|
|
2415
|
+
buildOrchestratorID: owner.id,
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
finally {
|
|
2419
|
+
owner.onDispose();
|
|
2420
|
+
}
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2423
|
+
get build() {
|
|
2424
|
+
const owner = this;
|
|
2425
|
+
return cacheGeneratorMethod(owner, "build", function (project) {
|
|
2426
|
+
owner.ensureNotDisposed();
|
|
2427
|
+
const response = owner.client.apiRequest("build", {
|
|
2428
|
+
buildOrchestratorID: owner.id,
|
|
2429
|
+
...(project !== undefined ? { project } : {}),
|
|
2430
|
+
});
|
|
2431
|
+
return response;
|
|
2432
|
+
}, function* (project) {
|
|
2433
|
+
owner.ensureNotDisposed();
|
|
2434
|
+
const response = yield* apiRequest("build", {
|
|
2435
|
+
buildOrchestratorID: owner.id,
|
|
2436
|
+
...(project !== undefined ? { project } : {}),
|
|
2437
|
+
});
|
|
2438
|
+
return response;
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
get buildReferences() {
|
|
2442
|
+
const owner = this;
|
|
2443
|
+
return cacheGeneratorMethod(owner, "buildReferences", function (project) {
|
|
2444
|
+
owner.ensureNotDisposed();
|
|
2445
|
+
const response = owner.client.apiRequest("buildReferences", {
|
|
2446
|
+
buildOrchestratorID: owner.id,
|
|
2447
|
+
project,
|
|
2448
|
+
});
|
|
2449
|
+
return response;
|
|
2450
|
+
}, function* (project) {
|
|
2451
|
+
owner.ensureNotDisposed();
|
|
2452
|
+
const response = yield* apiRequest("buildReferences", {
|
|
2453
|
+
buildOrchestratorID: owner.id,
|
|
2454
|
+
project,
|
|
2455
|
+
});
|
|
2456
|
+
return response;
|
|
2457
|
+
});
|
|
2458
|
+
}
|
|
2459
|
+
get clean() {
|
|
2460
|
+
const owner = this;
|
|
2461
|
+
return cacheGeneratorMethod(owner, "clean", function (project) {
|
|
2462
|
+
owner.ensureNotDisposed();
|
|
2463
|
+
const response = owner.client.apiRequest("cleanBuild", {
|
|
2464
|
+
buildOrchestratorID: owner.id,
|
|
2465
|
+
...(project !== undefined ? { project } : {}),
|
|
2466
|
+
});
|
|
2467
|
+
return response;
|
|
2468
|
+
}, function* (project) {
|
|
2469
|
+
owner.ensureNotDisposed();
|
|
2470
|
+
const response = yield* apiRequest("cleanBuild", {
|
|
2471
|
+
buildOrchestratorID: owner.id,
|
|
2472
|
+
...(project !== undefined ? { project } : {}),
|
|
2473
|
+
});
|
|
2474
|
+
return response;
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
get cleanReferences() {
|
|
2478
|
+
const owner = this;
|
|
2479
|
+
return cacheGeneratorMethod(owner, "cleanReferences", function (project) {
|
|
2480
|
+
owner.ensureNotDisposed();
|
|
2481
|
+
const response = owner.client.apiRequest("cleanReferences", {
|
|
2482
|
+
buildOrchestratorID: owner.id,
|
|
2483
|
+
...(project !== undefined ? { project } : {}),
|
|
2484
|
+
});
|
|
2485
|
+
return response;
|
|
2486
|
+
}, function* (project) {
|
|
2487
|
+
owner.ensureNotDisposed();
|
|
2488
|
+
const response = yield* apiRequest("cleanReferences", {
|
|
2489
|
+
buildOrchestratorID: owner.id,
|
|
2490
|
+
...(project !== undefined ? { project } : {}),
|
|
2491
|
+
});
|
|
2492
|
+
return response;
|
|
2493
|
+
});
|
|
2494
|
+
}
|
|
2495
|
+
isDisposed() {
|
|
2496
|
+
return this.disposed;
|
|
2497
|
+
}
|
|
2498
|
+
ensureNotDisposed() {
|
|
2499
|
+
if (this.disposed) {
|
|
2500
|
+
throw new Error("Build orchestrator is disposed");
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2246
2504
|
function toEmitOutput(response) {
|
|
2247
2505
|
const outputFiles = new Map();
|
|
2248
2506
|
for (const { fileName, ...outputFile } of response.outputFiles) {
|