typescript 7.1.0-dev.20260917.1 → 7.1.0-dev.20260919.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 +95 -39
- package/dist/api/async/api.d.ts.map +1 -1
- package/dist/api/async/api.js +144 -93
- package/dist/api/async/api.js.map +1 -1
- package/dist/api/async/types.d.ts +2 -2
- package/dist/api/async/types.d.ts.map +1 -1
- package/dist/api/fs.d.ts +11 -11
- package/dist/api/fs.d.ts.map +1 -1
- package/dist/api/fs.js +5 -5
- package/dist/api/fs.js.map +1 -1
- package/dist/api/node/encoder.d.ts +3 -0
- package/dist/api/node/encoder.d.ts.map +1 -1
- package/dist/api/node/encoder.js +17 -14
- package/dist/api/node/encoder.js.map +1 -1
- package/dist/api/node/msgpack.d.ts.map +1 -1
- package/dist/api/node/msgpack.js +2 -3
- package/dist/api/node/msgpack.js.map +1 -1
- package/dist/api/node/node.generated.d.ts +3 -1
- package/dist/api/node/node.generated.d.ts.map +1 -1
- package/dist/api/node/node.generated.js +31 -0
- package/dist/api/node/node.generated.js.map +1 -1
- package/dist/api/node/node.infrastructure.d.ts +1 -1
- package/dist/api/node/node.infrastructure.d.ts.map +1 -1
- package/dist/api/node/wtf8.d.ts +2 -1
- package/dist/api/node/wtf8.d.ts.map +1 -1
- package/dist/api/node/wtf8.js +69 -0
- package/dist/api/node/wtf8.js.map +1 -1
- package/dist/api/options.d.ts +7 -7
- package/dist/api/options.d.ts.map +1 -1
- package/dist/api/proto.d.ts +6 -15
- package/dist/api/proto.d.ts.map +1 -1
- package/dist/api/proto.generated.d.ts +189 -147
- package/dist/api/proto.generated.d.ts.map +1 -1
- package/dist/api/proto.generated.js +2 -0
- package/dist/api/proto.generated.js.map +1 -1
- package/dist/api/proto.js +2 -3
- package/dist/api/proto.js.map +1 -1
- package/dist/api/sourceFileCache.js.map +1 -1
- package/dist/api/sync/api.d.ts +120 -53
- package/dist/api/sync/api.d.ts.map +1 -1
- package/dist/api/sync/api.js +255 -169
- package/dist/api/sync/api.js.map +1 -1
- package/dist/api/sync/types.d.ts +2 -2
- package/dist/api/sync/types.d.ts.map +1 -1
- package/dist/api/timing.d.ts +2 -2
- package/dist/api/timing.d.ts.map +1 -1
- package/dist/ast/ast.d.ts +1 -0
- package/dist/ast/ast.d.ts.map +1 -1
- package/dist/ast/factory.generated.d.ts +1 -0
- package/dist/ast/factory.generated.d.ts.map +1 -1
- package/dist/ast/factory.generated.js +2651 -1
- package/dist/ast/factory.generated.js.map +1 -1
- package/dist/ast/visitor.d.ts +2 -0
- package/dist/ast/visitor.d.ts.map +1 -1
- package/dist/ast/visitor.js +40 -0
- package/dist/ast/visitor.js.map +1 -1
- package/package.json +9 -9
package/dist/api/async/api.js
CHANGED
|
@@ -10,6 +10,7 @@ import { ModuleResolutionKind } from "#enums/moduleResolutionKind";
|
|
|
10
10
|
import { NewLineKind } from "#enums/newLineKind";
|
|
11
11
|
import { NodeBuilderFlags } from "#enums/nodeBuilderFlags";
|
|
12
12
|
import { ObjectFlags } from "#enums/objectFlags";
|
|
13
|
+
import { ScriptKind } from "#enums/scriptKind";
|
|
13
14
|
import { SignatureFlags } from "#enums/signatureFlags";
|
|
14
15
|
import { SignatureKind } from "#enums/signatureKind";
|
|
15
16
|
import { SymbolFlags } from "#enums/symbolFlags";
|
|
@@ -22,30 +23,33 @@ import { encodeNode, uint8ArrayToBase64, } from "../node/encoder.js";
|
|
|
22
23
|
import { decodeNode, getNodeId, parseNodeHandle, readParseOptionsKey, readSourceFileHash, RemoteSourceFile, } from "../node/node.js";
|
|
23
24
|
import { Wtf8Decoder } from "../node/wtf8.js";
|
|
24
25
|
import { createGetCanonicalFileName, toPath, } from "../path.js";
|
|
25
|
-
import { resolveFileName,
|
|
26
|
+
import { resolveFileName, toCreateSnapshotRequest, } from "../proto.js";
|
|
26
27
|
import { SourceFileCache } from "../sourceFileCache.js";
|
|
27
28
|
import { Client, } from "./client.js";
|
|
28
29
|
export { formatDiagnostics, formatDiagnosticsWithColorAndContext } from "../diagnosticFormatter.js";
|
|
29
30
|
export { documentURIToFileName, fileNameToDocumentURI } from "../path.js";
|
|
30
|
-
export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, IndexKind, JsxEmit, ModifierFlags, ModuleKind, ModuleResolutionKind, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypeFormatFlags, TypePredicateKind };
|
|
31
|
+
export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, IndexKind, JsxEmit, ModifierFlags, ModuleKind, ModuleResolutionKind, NodeBuilderFlags, ObjectFlags, ScriptKind, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypeFormatFlags, TypePredicateKind };
|
|
31
32
|
// @sync-only-start
|
|
32
33
|
// export { all, defer, type APIRequestGenerator, type AnyAPIRequestGenerator, type AllAPIRequestGenerator, type DeferredAPIRequestGenerator, type ExecutedGeneratorsResults } from "./generatorSupport.ts";
|
|
33
34
|
// import {executeRequestGenerators, type ExecutedGeneratorsResults, type AnyAPIRequestGenerator} from "./generatorSupport.ts";
|
|
35
|
+
// import { sourceFileResponseToUint8Array } from "../node/encoder.ts";
|
|
34
36
|
// @sync-only-end
|
|
35
37
|
export class API {
|
|
36
38
|
client;
|
|
37
39
|
sourceFileCache;
|
|
38
40
|
toPath;
|
|
39
41
|
currentDirectory;
|
|
42
|
+
decoder = new Wtf8Decoder();
|
|
40
43
|
getCanonicalFileNameWorker;
|
|
41
44
|
initialized = false;
|
|
42
45
|
initializing;
|
|
43
46
|
activeSnapshots = new Set();
|
|
44
|
-
|
|
47
|
+
printer;
|
|
45
48
|
internal;
|
|
46
49
|
constructor(options = {}) {
|
|
47
50
|
this.client = new Client(options);
|
|
48
51
|
this.sourceFileCache = new SourceFileCache();
|
|
52
|
+
this.printer = new Printer(this.client);
|
|
49
53
|
this.internal = new InternalAPI(this.client, () => this.ensureInitialized()); // @sync: this.internal = new InternalAPI(this.client, this.ensureInitialized);
|
|
50
54
|
}
|
|
51
55
|
/**
|
|
@@ -118,6 +122,22 @@ export class API {
|
|
|
118
122
|
await this.ensureInitialized();
|
|
119
123
|
return this.client.apiRequest("parseJsonConfigFileContent", { json, ...options });
|
|
120
124
|
}
|
|
125
|
+
async createSourceFile(fileName, sourceText, options = {}) {
|
|
126
|
+
await this.ensureInitialized();
|
|
127
|
+
const data = await this.client.apiRequestBinary("createSourceFile", { fileName, sourceText, options });
|
|
128
|
+
if (!data) {
|
|
129
|
+
throw new Error("createSourceFile returned no source file");
|
|
130
|
+
}
|
|
131
|
+
return new RemoteSourceFile(data, this.decoder, this.client.getTimingCollector());
|
|
132
|
+
}
|
|
133
|
+
async createSourceFileFromFile(file, options = {}) {
|
|
134
|
+
await this.ensureInitialized();
|
|
135
|
+
const data = await this.client.apiRequestBinary("createSourceFileFromFile", { fileName: resolveFileName(file), options });
|
|
136
|
+
if (!data) {
|
|
137
|
+
throw new Error("createSourceFileFromFile returned no source file");
|
|
138
|
+
}
|
|
139
|
+
return new RemoteSourceFile(data, this.decoder, this.client.getTimingCollector());
|
|
140
|
+
}
|
|
121
141
|
async transpileModule(input, options = {}) {
|
|
122
142
|
await this.ensureInitialized();
|
|
123
143
|
return this.client.apiRequest("transpileModule", { input, options });
|
|
@@ -134,39 +154,60 @@ export class API {
|
|
|
134
154
|
await this.ensureInitialized();
|
|
135
155
|
return this.client.apiRequest("transpileDeclarationFromFile", { fileName: resolveFileName(file), options });
|
|
136
156
|
}
|
|
137
|
-
async
|
|
138
|
-
|
|
157
|
+
async createSnapshot(params) {
|
|
158
|
+
await this.ensureInitialized();
|
|
159
|
+
const requestParams = toCreateSnapshotRequest(params);
|
|
160
|
+
const data = await this.client.apiRequest("createSnapshot", requestParams);
|
|
161
|
+
const snapshot = new Snapshot(data, this.client, this.sourceFileCache, this.toPath, this, () => {
|
|
162
|
+
this.activeSnapshots.delete(snapshot);
|
|
163
|
+
this.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
164
|
+
}, this.createSnapshotUpdater(() => snapshot), undefined);
|
|
165
|
+
this.activeSnapshots.add(snapshot);
|
|
166
|
+
return snapshot;
|
|
139
167
|
}
|
|
140
|
-
|
|
141
|
-
|
|
168
|
+
async updateSnapshot(baseSnapshot, params) {
|
|
169
|
+
await this.ensureInitialized();
|
|
142
170
|
if (!this.activeSnapshots.has(baseSnapshot) || baseSnapshot.isDisposed()) {
|
|
143
171
|
throw new Error("Cannot update an inactive snapshot");
|
|
144
172
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
173
|
+
const data = await this.client.apiRequest("updateSnapshot", {
|
|
174
|
+
snapshot: baseSnapshot.id,
|
|
175
|
+
changes: toCreateSnapshotRequest(params),
|
|
176
|
+
});
|
|
177
|
+
this.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
178
|
+
const snapshot = new Snapshot(data, this.client, this.sourceFileCache, this.toPath, this, () => {
|
|
179
|
+
this.activeSnapshots.delete(snapshot);
|
|
180
|
+
this.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
181
|
+
}, this.createSnapshotUpdater(() => snapshot), baseSnapshot);
|
|
182
|
+
this.activeSnapshots.add(snapshot);
|
|
183
|
+
return snapshot;
|
|
151
184
|
}
|
|
152
|
-
|
|
185
|
+
createSnapshotUpdater(getSnapshot) {
|
|
186
|
+
const update = params => this.updateSnapshot(getSnapshot(), params); // @sync: const update = ((params: CreateSnapshotParams) => this.updateSnapshot(getSnapshot(), params)) as SnapshotUpdater;
|
|
187
|
+
// @sync-only-start
|
|
188
|
+
// const owner = this;
|
|
189
|
+
// update.gen = function* (params: CreateSnapshotParams) { return yield* owner.updateSnapshot.gen(getSnapshot(), params); };
|
|
190
|
+
// @sync-only-end
|
|
191
|
+
return update;
|
|
192
|
+
}
|
|
193
|
+
async getCurrentLanguageServerSnapshot(...args) {
|
|
153
194
|
await this.ensureInitialized();
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
195
|
+
const changes = args[0];
|
|
196
|
+
const baseSnapshot = args[1];
|
|
197
|
+
if (baseSnapshot && (!this.activeSnapshots.has(baseSnapshot) || baseSnapshot.isDisposed())) {
|
|
198
|
+
throw new Error("Cannot use an inactive snapshot as a response base");
|
|
199
|
+
}
|
|
200
|
+
const data = await this.client.apiRequest("getCurrentLanguageServerSnapshot", {
|
|
201
|
+
baseSnapshot: baseSnapshot?.id,
|
|
202
|
+
changes,
|
|
203
|
+
});
|
|
204
|
+
if (baseSnapshot) {
|
|
205
|
+
this.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
162
206
|
}
|
|
163
207
|
const snapshot = new Snapshot(data, this.client, this.sourceFileCache, this.toPath, this, () => {
|
|
164
208
|
this.activeSnapshots.delete(snapshot);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
this.latestSnapshot = snapshot;
|
|
209
|
+
this.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
210
|
+
}, this.createSnapshotUpdater(() => snapshot), baseSnapshot);
|
|
170
211
|
this.activeSnapshots.add(snapshot);
|
|
171
212
|
return snapshot;
|
|
172
213
|
}
|
|
@@ -180,11 +221,6 @@ export class API {
|
|
|
180
221
|
for (const snapshot of [...this.activeSnapshots]) {
|
|
181
222
|
await snapshot.dispose();
|
|
182
223
|
}
|
|
183
|
-
// Release the latest snapshot's cache refs if still held
|
|
184
|
-
if (this.latestSnapshot) {
|
|
185
|
-
this.sourceFileCache.releaseSnapshot(this.latestSnapshot.id);
|
|
186
|
-
this.latestSnapshot = undefined;
|
|
187
|
-
}
|
|
188
224
|
this.sourceFileCache.clear();
|
|
189
225
|
}
|
|
190
226
|
finally {
|
|
@@ -199,16 +235,13 @@ export class API {
|
|
|
199
235
|
if (!this.activeSnapshots.has(baseSnapshot) || baseSnapshot.isDisposed()) {
|
|
200
236
|
throw new Error("Cannot run a temporary file update on an inactive snapshot");
|
|
201
237
|
}
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this.activeSnapshots.delete(snapshot);
|
|
209
|
-
this.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
238
|
+
const snapshot = await baseSnapshot.update({
|
|
239
|
+
fileSystem: {
|
|
240
|
+
kind: "layer",
|
|
241
|
+
files: { [resolveFileName(file)]: newText },
|
|
242
|
+
},
|
|
243
|
+
ensurePrograms: true,
|
|
210
244
|
});
|
|
211
|
-
this.activeSnapshots.add(snapshot);
|
|
212
245
|
try {
|
|
213
246
|
await cb(snapshot);
|
|
214
247
|
}
|
|
@@ -234,42 +267,18 @@ export class API {
|
|
|
234
267
|
resetTimingInfo() {
|
|
235
268
|
return this.client.resetTimingInfo();
|
|
236
269
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
for (const snapshot of this.activeSnapshots) {
|
|
240
|
-
if (!snapshot.isDisposed() && snapshot.getProject(project.configFileName)?.program === program) {
|
|
241
|
-
return true;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Creates a program from current filesystem state, or derives one from oldProgram after applying fileChanges.
|
|
248
|
-
*/
|
|
249
|
-
async createProgram(rootFiles, createProgramOptions, oldProgram, fileChanges) {
|
|
270
|
+
/** Creates a program from current filesystem state. */
|
|
271
|
+
async createProgram(rootFiles, compilerOptions, createProgramOptions) {
|
|
250
272
|
await this.ensureInitialized();
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
if (oldProgram && !this.isProgramActive(oldProgram)) {
|
|
255
|
-
throw new Error("oldProgram must belong to this API instance and reference an active snapshot");
|
|
256
|
-
}
|
|
257
|
-
const data = await this.client.apiRequest("createProgram", {
|
|
258
|
-
rootFiles,
|
|
259
|
-
createProgramOptions,
|
|
260
|
-
oldProgram: oldProgram ? { snapshot: oldProgram.snapshotId, project: oldProgram.getProject().id } : undefined,
|
|
261
|
-
fileChanges,
|
|
273
|
+
const snapshot = await this.createSnapshot({
|
|
274
|
+
createPrograms: [{ rootFiles, compilerOptions, options: createProgramOptions }],
|
|
262
275
|
});
|
|
263
|
-
|
|
276
|
+
const program = snapshot.operation.createdPrograms[0];
|
|
277
|
+
if (!program) {
|
|
278
|
+
await snapshot.dispose();
|
|
264
279
|
throw new Error("createProgram did not return a project");
|
|
265
280
|
}
|
|
266
|
-
const snapshot = new Snapshot({ snapshot: data.snapshot, projects: [data.project] }, this.client, this.sourceFileCache, this.toPath, this, () => {
|
|
267
|
-
this.activeSnapshots.delete(snapshot);
|
|
268
|
-
this.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
269
|
-
});
|
|
270
|
-
const program = snapshot.getProjects()[0].program;
|
|
271
281
|
program.setOwnedSnapshot(snapshot);
|
|
272
|
-
this.activeSnapshots.add(snapshot);
|
|
273
282
|
return program;
|
|
274
283
|
}
|
|
275
284
|
}
|
|
@@ -298,37 +307,68 @@ export class InternalAPI {
|
|
|
298
307
|
}
|
|
299
308
|
export class Snapshot {
|
|
300
309
|
id;
|
|
310
|
+
operation;
|
|
301
311
|
projectMap;
|
|
302
312
|
toPath;
|
|
303
313
|
client;
|
|
304
314
|
disposed = false;
|
|
305
315
|
disposePromise;
|
|
306
316
|
onDispose;
|
|
307
|
-
api;
|
|
308
317
|
snapshotRegistry;
|
|
318
|
+
projectDataMap;
|
|
319
|
+
updateSnapshot;
|
|
309
320
|
internal;
|
|
310
|
-
constructor(data, client, sourceFileCache, toPath,
|
|
321
|
+
constructor(data, client, sourceFileCache, toPath, formatDiagnosticsHost, onDispose, updateSnapshot, baseSnapshot) {
|
|
311
322
|
this.id = data.snapshot;
|
|
312
323
|
this.client = client;
|
|
313
324
|
this.toPath = toPath;
|
|
314
|
-
this.api = api;
|
|
315
325
|
this.onDispose = onDispose;
|
|
326
|
+
this.updateSnapshot = updateSnapshot;
|
|
316
327
|
this.projectMap = new Map();
|
|
328
|
+
const projectDataMap = new Map(baseSnapshot?.projectDataMap);
|
|
329
|
+
for (const projectId of data.changes?.removedProjects ?? []) {
|
|
330
|
+
projectDataMap.delete(projectId);
|
|
331
|
+
}
|
|
332
|
+
for (const projectData of data.projects) {
|
|
333
|
+
projectDataMap.set(projectData.id, projectData);
|
|
334
|
+
}
|
|
335
|
+
this.projectDataMap = new Map([...projectDataMap].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
317
336
|
this.snapshotRegistry = new SnapshotObjectRegistry(client, this.id, projectId => this.projectMap.get(projectId));
|
|
318
|
-
for (const projData of
|
|
319
|
-
const project = new Project(projData, this.id, client, sourceFileCache, toPath,
|
|
320
|
-
this.projectMap.set(
|
|
337
|
+
for (const projData of this.projectDataMap.values()) {
|
|
338
|
+
const project = new Project(projData, this.id, client, sourceFileCache, toPath, formatDiagnosticsHost, this.snapshotRegistry);
|
|
339
|
+
this.projectMap.set(projData.id, project);
|
|
321
340
|
}
|
|
341
|
+
this.operation = {
|
|
342
|
+
createdPrograms: data.operation.createdPrograms?.map(projectId => this.requireProject(projectId).program),
|
|
343
|
+
openedFiles: data.operation.openedFiles?.map(result => ({ project: this.requireProject(result.project) })),
|
|
344
|
+
};
|
|
322
345
|
this.internal = new SnapshotInternalAPI(this.id, client);
|
|
323
346
|
}
|
|
324
347
|
getProjects() {
|
|
325
348
|
this.ensureNotDisposed();
|
|
326
349
|
return [...this.projectMap.values()];
|
|
327
350
|
}
|
|
328
|
-
|
|
351
|
+
getConfiguredProject(configFileName) {
|
|
329
352
|
this.ensureNotDisposed();
|
|
330
353
|
return this.projectMap.get(this.toPath(configFileName));
|
|
331
354
|
}
|
|
355
|
+
getProject(projectId) {
|
|
356
|
+
this.ensureNotDisposed();
|
|
357
|
+
return this.projectMap.get(projectId);
|
|
358
|
+
}
|
|
359
|
+
getProgram(projectId) {
|
|
360
|
+
return this.getProject(projectId)?.program;
|
|
361
|
+
}
|
|
362
|
+
update(params) {
|
|
363
|
+
this.ensureNotDisposed();
|
|
364
|
+
return this.updateSnapshot(params);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Gets the default project for a given file from the configured projects and
|
|
368
|
+
* inferred project already loaded in the snapshot. Synthetic projects are not
|
|
369
|
+
* considered. Files that have been opened with `openFiles` are guaranteed to
|
|
370
|
+
* have a result.
|
|
371
|
+
*/
|
|
332
372
|
async getDefaultProjectForFile(file) {
|
|
333
373
|
this.ensureNotDisposed();
|
|
334
374
|
const data = await this.client.apiRequest("getDefaultProjectForFile", {
|
|
@@ -337,15 +377,7 @@ export class Snapshot {
|
|
|
337
377
|
});
|
|
338
378
|
if (!data)
|
|
339
379
|
return undefined;
|
|
340
|
-
return this.projectMap.get(
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Creates the next snapshot, layering its filesystem over this snapshot's
|
|
344
|
-
* filesystem. This snapshot must still be active and be the latest snapshot.
|
|
345
|
-
*/
|
|
346
|
-
async update(params) {
|
|
347
|
-
this.ensureNotDisposed();
|
|
348
|
-
return this.api.updateSnapshotFrom(this, params);
|
|
380
|
+
return this.projectMap.get(data.id);
|
|
349
381
|
}
|
|
350
382
|
[globalThis.Symbol.dispose]() {
|
|
351
383
|
void this.dispose();
|
|
@@ -377,6 +409,13 @@ export class Snapshot {
|
|
|
377
409
|
throw new Error("Snapshot is disposed");
|
|
378
410
|
}
|
|
379
411
|
}
|
|
412
|
+
requireProject(projectId) {
|
|
413
|
+
const project = this.projectMap.get(projectId);
|
|
414
|
+
if (!project) {
|
|
415
|
+
throw new Error(`Snapshot operation returned unknown project '${projectId}'`);
|
|
416
|
+
}
|
|
417
|
+
return project;
|
|
418
|
+
}
|
|
380
419
|
}
|
|
381
420
|
class SnapshotObjectRegistry {
|
|
382
421
|
symbols = new Map();
|
|
@@ -388,7 +427,7 @@ class SnapshotObjectRegistry {
|
|
|
388
427
|
this.snapshotId = snapshotId;
|
|
389
428
|
this.resolveProject = resolveProject;
|
|
390
429
|
}
|
|
391
|
-
/** Resolve a project
|
|
430
|
+
/** Resolve a project ID to its Project within this snapshot. */
|
|
392
431
|
getProject(projectId) {
|
|
393
432
|
return this.resolveProject(projectId);
|
|
394
433
|
}
|
|
@@ -639,6 +678,7 @@ export class Project {
|
|
|
639
678
|
id;
|
|
640
679
|
configFileName;
|
|
641
680
|
currentDirectory;
|
|
681
|
+
dirty;
|
|
642
682
|
parsedCommandLine;
|
|
643
683
|
/** @deprecated Use `parsedCommandLine.options`. */
|
|
644
684
|
compilerOptions;
|
|
@@ -646,7 +686,6 @@ export class Project {
|
|
|
646
686
|
rootFiles;
|
|
647
687
|
program;
|
|
648
688
|
checker;
|
|
649
|
-
emitter;
|
|
650
689
|
languageService;
|
|
651
690
|
client;
|
|
652
691
|
snapshotId;
|
|
@@ -654,6 +693,7 @@ export class Project {
|
|
|
654
693
|
this.id = data.id;
|
|
655
694
|
this.configFileName = data.configFileName;
|
|
656
695
|
this.currentDirectory = data.currentDirectory;
|
|
696
|
+
this.dirty = data.dirty;
|
|
657
697
|
if (!data.parsedCommandLine?.options) {
|
|
658
698
|
throw new Error(`Project '${data.configFileName}' has no parsed command line`);
|
|
659
699
|
}
|
|
@@ -665,7 +705,6 @@ export class Project {
|
|
|
665
705
|
this.program = new Program(snapshotId, this, client, sourceFileCache, toPath, formatDiagnosticsHost);
|
|
666
706
|
const objectRegistry = new ProjectObjectRegistry(client, snapshotId, this, snapshotRegistry);
|
|
667
707
|
this.checker = new Checker(snapshotId, this, client, objectRegistry);
|
|
668
|
-
this.emitter = new Emitter(client);
|
|
669
708
|
this.languageService = new LanguageService(snapshotId, this, client, objectRegistry);
|
|
670
709
|
}
|
|
671
710
|
/** @deprecated Use `languageService.getImportAdderEdits`. */
|
|
@@ -777,6 +816,7 @@ export class LanguageService {
|
|
|
777
816
|
export class Program {
|
|
778
817
|
/** @internal */
|
|
779
818
|
snapshotId;
|
|
819
|
+
id;
|
|
780
820
|
project;
|
|
781
821
|
client;
|
|
782
822
|
sourceFileCache;
|
|
@@ -788,6 +828,7 @@ export class Program {
|
|
|
788
828
|
disposePromise;
|
|
789
829
|
constructor(snapshotId, project, client, sourceFileCache, toPath, formatDiagnosticsHost) {
|
|
790
830
|
this.snapshotId = snapshotId;
|
|
831
|
+
this.id = project.id;
|
|
791
832
|
this.project = project;
|
|
792
833
|
this.client = client;
|
|
793
834
|
this.sourceFileCache = sourceFileCache;
|
|
@@ -1108,7 +1149,7 @@ export class Program {
|
|
|
1108
1149
|
emitSkipped: response.emitSkipped,
|
|
1109
1150
|
diagnostics: response.diagnostics,
|
|
1110
1151
|
emittedFiles: response.emittedFiles,
|
|
1111
|
-
|
|
1152
|
+
fileSystem,
|
|
1112
1153
|
};
|
|
1113
1154
|
}
|
|
1114
1155
|
/**
|
|
@@ -1898,7 +1939,7 @@ export class Checker {
|
|
|
1898
1939
|
return data ? data.map(d => this.objectRegistry.getOrCreateType(d)) : [];
|
|
1899
1940
|
}
|
|
1900
1941
|
}
|
|
1901
|
-
export class
|
|
1942
|
+
export class Printer {
|
|
1902
1943
|
client;
|
|
1903
1944
|
constructor(client) {
|
|
1904
1945
|
this.client = client;
|
|
@@ -1913,6 +1954,16 @@ export class Emitter {
|
|
|
1913
1954
|
terminateUnterminatedLiterals: options.terminateUnterminatedLiterals,
|
|
1914
1955
|
});
|
|
1915
1956
|
}
|
|
1957
|
+
async printFile(sourceFile, options = {}) {
|
|
1958
|
+
const encoded = encodeNode(sourceFile);
|
|
1959
|
+
const base64 = uint8ArrayToBase64(encoded);
|
|
1960
|
+
return this.client.apiRequest("printNode", {
|
|
1961
|
+
data: base64,
|
|
1962
|
+
preserveSourceNewlines: options.preserveSourceNewlines,
|
|
1963
|
+
neverAsciiEscape: options.neverAsciiEscape,
|
|
1964
|
+
terminateUnterminatedLiterals: options.terminateUnterminatedLiterals,
|
|
1965
|
+
});
|
|
1966
|
+
}
|
|
1916
1967
|
}
|
|
1917
1968
|
export class SnapshotInternalAPI {
|
|
1918
1969
|
snapshotId;
|