typescript 7.1.0-dev.20260923.1 → 7.1.0-dev.20260925.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 +79 -6
- package/dist/api/async/api.d.ts.map +1 -1
- package/dist/api/async/api.js +200 -29
- package/dist/api/async/api.js.map +1 -1
- package/dist/api/async/client.d.ts +1 -0
- package/dist/api/async/client.d.ts.map +1 -1
- package/dist/api/async/client.js +7 -0
- package/dist/api/async/client.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 +1 -0
- package/dist/api/node/node.infrastructure.d.ts.map +1 -1
- package/dist/api/node/node.infrastructure.js +11 -1
- 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.generated.d.ts +47 -3
- package/dist/api/proto.generated.d.ts.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 +95 -8
- package/dist/api/sync/api.d.ts.map +1 -1
- package/dist/api/sync/api.js +288 -56
- package/dist/api/sync/api.js.map +1 -1
- package/dist/api/sync/client.d.ts +1 -0
- package/dist/api/sync/client.d.ts.map +1 -1
- package/dist/api/sync/client.js +4 -0
- package/dist/api/sync/client.js.map +1 -1
- package/dist/api/syncChannel.d.ts +1 -0
- package/dist/api/syncChannel.d.ts.map +1 -1
- package/dist/api/syncChannel.js +3 -0
- package/dist/api/syncChannel.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Builds a composite ref key from a snapshot ID and project ID.
|
|
3
3
|
*/
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function snapshotRefKey(snapshotId, projectId) {
|
|
5
|
+
return `snapshot:${snapshotId}:${projectId}`;
|
|
6
|
+
}
|
|
7
|
+
function leaseRefKey(leaseId) {
|
|
8
|
+
return `lease:${leaseId}`;
|
|
6
9
|
}
|
|
7
10
|
/**
|
|
8
|
-
* Client-side cache for source files keyed by (path, parseOptionsKey, contentHash).
|
|
11
|
+
* Client-side cache for source files keyed by (path, fileName, scriptKind, parseOptionsKey, contentHash).
|
|
9
12
|
*
|
|
10
13
|
* Supports multiple versions of the same file at the same path (e.g., from
|
|
11
14
|
* different snapshots with different file contents). Each version is identified
|
|
12
|
-
* by its content hash and parse options key.
|
|
15
|
+
* by its script kind, content hash, and parse options key.
|
|
13
16
|
*
|
|
14
|
-
* Entries are ref-counted by (snapshot, project) pairs
|
|
15
|
-
*
|
|
16
|
-
* and entries with no remaining references are evicted.
|
|
17
|
+
* Entries are ref-counted by (snapshot, project) pairs and direct source-file
|
|
18
|
+
* leases. Releasing an owner evicts entries with no remaining references.
|
|
17
19
|
*
|
|
18
20
|
* When a new snapshot is created, unchanged cache entries from the previous
|
|
19
21
|
* snapshot are retained per-project. Only files within changed or removed
|
|
@@ -24,6 +26,8 @@ export class SourceFileCache {
|
|
|
24
26
|
cache = new Map();
|
|
25
27
|
/** Map from snapshotId to (projectId → Set of paths fetched through that project) */
|
|
26
28
|
snapshotProjectPaths = new Map();
|
|
29
|
+
/** Map from direct lease ID to its retained path */
|
|
30
|
+
leasePaths = new Map();
|
|
27
31
|
/**
|
|
28
32
|
* Get a cached source file already retained for the given (snapshot, project) pair.
|
|
29
33
|
* This does not require a content hash or parse options key — it returns the entry
|
|
@@ -37,7 +41,7 @@ export class SourceFileCache {
|
|
|
37
41
|
const entries = this.cache.get(path);
|
|
38
42
|
if (!entries)
|
|
39
43
|
return undefined;
|
|
40
|
-
const key =
|
|
44
|
+
const key = snapshotRefKey(snapshotId, projectId);
|
|
41
45
|
const entry = entries.find(e => e.refs.has(key));
|
|
42
46
|
return entry?.file;
|
|
43
47
|
}
|
|
@@ -46,21 +50,38 @@ export class SourceFileCache {
|
|
|
46
50
|
* Returns the cached file — which may be an existing entry if the hash matches.
|
|
47
51
|
*/
|
|
48
52
|
set(path, file, parseOptionsKey, contentHash, snapshotId, projectId) {
|
|
53
|
+
const result = this.setWithRef(path, file, parseOptionsKey, contentHash, snapshotRefKey(snapshotId, projectId));
|
|
54
|
+
this.trackPath(snapshotId, projectId, path);
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Store a source file in the cache and retain it for a direct lease.
|
|
59
|
+
* Returns the cached file so leased and program-owned files share identity.
|
|
60
|
+
*/
|
|
61
|
+
setForLease(path, file, parseOptionsKey, contentHash, leaseId) {
|
|
62
|
+
if (this.leasePaths.has(leaseId)) {
|
|
63
|
+
throw new Error(`Source file lease ${leaseId} is already cached`);
|
|
64
|
+
}
|
|
65
|
+
const result = this.setWithRef(path, file, parseOptionsKey, contentHash, leaseRefKey(leaseId));
|
|
66
|
+
this.leasePaths.set(leaseId, path);
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
setWithRef(path, file, parseOptionsKey, contentHash, ref) {
|
|
49
70
|
let entries = this.cache.get(path);
|
|
50
71
|
if (!entries) {
|
|
51
72
|
entries = [];
|
|
52
73
|
this.cache.set(path, entries);
|
|
53
74
|
}
|
|
54
|
-
const ref = refKey(snapshotId, projectId);
|
|
55
75
|
// Check if we already have this exact version
|
|
56
|
-
const existing = entries.find(e => e.
|
|
76
|
+
const existing = entries.find(e => e.file.fileName === file.fileName &&
|
|
77
|
+
e.file.scriptKind === file.scriptKind &&
|
|
78
|
+
e.parseOptionsKey === parseOptionsKey &&
|
|
79
|
+
e.contentHash === contentHash);
|
|
57
80
|
if (existing) {
|
|
58
81
|
existing.refs.add(ref);
|
|
59
|
-
this.trackPath(snapshotId, projectId, path);
|
|
60
82
|
return existing.file;
|
|
61
83
|
}
|
|
62
84
|
entries.push({ file, contentHash, parseOptionsKey, refs: new Set([ref]) });
|
|
63
|
-
this.trackPath(snapshotId, projectId, path);
|
|
64
85
|
return file;
|
|
65
86
|
}
|
|
66
87
|
/**
|
|
@@ -88,8 +109,8 @@ export class SourceFileCache {
|
|
|
88
109
|
for (const p of projectChanges.deletedFiles ?? [])
|
|
89
110
|
invalidPaths.add(p);
|
|
90
111
|
}
|
|
91
|
-
const prevRef =
|
|
92
|
-
const newRef =
|
|
112
|
+
const prevRef = snapshotRefKey(previousSnapshotId, projectId);
|
|
113
|
+
const newRef = snapshotRefKey(newSnapshotId, projectId);
|
|
93
114
|
for (const path of paths) {
|
|
94
115
|
if (invalidPaths?.has(path))
|
|
95
116
|
continue;
|
|
@@ -115,24 +136,34 @@ export class SourceFileCache {
|
|
|
115
136
|
if (!projectMap)
|
|
116
137
|
return;
|
|
117
138
|
for (const [projectId, paths] of projectMap) {
|
|
118
|
-
const key =
|
|
139
|
+
const key = snapshotRefKey(snapshotId, projectId);
|
|
119
140
|
for (const path of paths) {
|
|
120
|
-
|
|
121
|
-
if (!entries)
|
|
122
|
-
continue;
|
|
123
|
-
for (let i = entries.length - 1; i >= 0; i--) {
|
|
124
|
-
entries[i].refs.delete(key);
|
|
125
|
-
if (entries[i].refs.size === 0) {
|
|
126
|
-
entries.splice(i, 1);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (entries.length === 0) {
|
|
130
|
-
this.cache.delete(path);
|
|
131
|
-
}
|
|
141
|
+
this.releaseRef(path, key);
|
|
132
142
|
}
|
|
133
143
|
}
|
|
134
144
|
this.snapshotProjectPaths.delete(snapshotId);
|
|
135
145
|
}
|
|
146
|
+
releaseLease(leaseId) {
|
|
147
|
+
const path = this.leasePaths.get(leaseId);
|
|
148
|
+
if (path === undefined)
|
|
149
|
+
return;
|
|
150
|
+
this.releaseRef(path, leaseRefKey(leaseId));
|
|
151
|
+
this.leasePaths.delete(leaseId);
|
|
152
|
+
}
|
|
153
|
+
releaseRef(path, ref) {
|
|
154
|
+
const entries = this.cache.get(path);
|
|
155
|
+
if (!entries)
|
|
156
|
+
return;
|
|
157
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
158
|
+
entries[i].refs.delete(ref);
|
|
159
|
+
if (entries[i].refs.size === 0) {
|
|
160
|
+
entries.splice(i, 1);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (entries.length === 0) {
|
|
164
|
+
this.cache.delete(path);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
136
167
|
trackPath(snapshotId, projectId, path) {
|
|
137
168
|
let projectMap = this.snapshotProjectPaths.get(snapshotId);
|
|
138
169
|
if (!projectMap) {
|
|
@@ -152,6 +183,7 @@ export class SourceFileCache {
|
|
|
152
183
|
clear() {
|
|
153
184
|
this.cache.clear();
|
|
154
185
|
this.snapshotProjectPaths.clear();
|
|
186
|
+
this.leasePaths.clear();
|
|
155
187
|
}
|
|
156
188
|
/**
|
|
157
189
|
* Get the number of unique paths in the cache.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourceFileCache.js","sourceRoot":"","sources":["../../src/api/sourceFileCache.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,SAAS,
|
|
1
|
+
{"version":3,"file":"sourceFileCache.js","sourceRoot":"","sources":["../../src/api/sourceFileCache.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,SAAS,cAAc,CAAC,UAAkB,EAAE,SAAiB;IACzD,OAAO,YAAY,UAAU,IAAI,SAAS,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,WAAW,CAAC,OAAe;IAChC,OAAO,SAAS,OAAO,EAAE,CAAC;AAC9B,CAAC;AAgBD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,eAAe;IACxB,wDAAwD;IAChD,KAAK,GAAkC,IAAI,GAAG,EAAE,C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;;OAEG;IACH,GAAG,CAAC,IAAU;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACJ"}
|
package/dist/api/sync/api.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { TypeFormatFlags } from "#enums/typeFormatFlags";
|
|
|
19
19
|
import { TypePredicateKind } from "#enums/typePredicateKind";
|
|
20
20
|
import { type __String, type CallLikeExpression, type Declaration, type Expression, type FileReference, type Identifier, ModifierFlags, type NamedTupleMember, type Node, type ParameterDeclaration, type Path, type SourceFile, type StringLiteralLikeNode, type SyntaxKind, type TypeNode } from "../../ast/index.ts";
|
|
21
21
|
import type { APIOptions, LSPConnectionOptions } from "../options.ts";
|
|
22
|
-
import type { CompilerOptions, ConfiguredProjectId, CreateProgramOptions, CreateSnapshotParams, CreateSnapshotResponse, CreateSourceFileOptions, Diagnostic, DocumentIdentifier, DocumentPosition, FileNotifications, InferredProjectId, LanguageServerSnapshotChanges, PackageId, ParsedCommandLine, ProjectId, ProjectReference, ProjectResponse, ReadConfigFileResponse, ResolvedModule, ResolvedTypeReferenceDirective, SignaturePropertyMethod, SignatureResponse, SourceFileMetadata, SymbolPropertyMethod, SymbolResponse, SymbolsPropertyMethod, SyntheticProjectId, TextEdit, TypeAcquisition, TypePropertyMethod, TypeResponse, TypesPropertyMethod } from "../proto.ts";
|
|
22
|
+
import type { CompilerOptions, ConfiguredProjectId, CreateProgramOptions as ProtocolCreateProgramOptions, CreateSnapshotParams as ProtocolCreateSnapshotParams, CreateSnapshotProgramParams as ProtocolCreateSnapshotProgramParams, CreateSnapshotResponse, CreateSourceFileOptions, Diagnostic, DocumentIdentifier, DocumentPosition, FileNotifications, InferredProjectId, LanguageServerSnapshotChanges as ProtocolLanguageServerSnapshotChanges, ModuleResolutionEntry, ModuleResolutionSpec, PackageId, ParsedCommandLine, ProjectId, ProjectReference, ProjectResponse, ReadConfigFileResponse, ReconfigureSnapshotProgramParams as ProtocolReconfigureSnapshotProgramParams, ResolutionMode, ResolvedModule, ResolvedTypeReferenceDirective, ResolveModuleNameResult, SignaturePropertyMethod, SignatureResponse, SourceFileMetadata, StaticModuleResolution, SymbolPropertyMethod, SymbolResponse, SymbolsPropertyMethod, SyntheticProjectId, TextEdit, TypeAcquisition, TypePropertyMethod, TypeResponse, TypesPropertyMethod } from "../proto.ts";
|
|
23
23
|
import { SourceFileCache } from "../sourceFileCache.ts";
|
|
24
24
|
import type { RequestTiming, TimingAccumulators, TimingInfo } from "../timing.ts";
|
|
25
25
|
import { Client, type ClientSocketOptions, type ClientSpawnOptions } from "./client.ts";
|
|
@@ -27,7 +27,36 @@ import type { AssertsIdentifierTypePredicate, AssertsThisTypePredicate, BigIntLi
|
|
|
27
27
|
export { formatDiagnostics, formatDiagnosticsWithColorAndContext } from "../diagnosticFormatter.ts";
|
|
28
28
|
export { documentURIToFileName, fileNameToDocumentURI } from "../path.ts";
|
|
29
29
|
export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, IndexKind, JsxEmit, ModifierFlags, ModuleKind, ModuleResolutionKind, NodeBuilderFlags, ObjectFlags, ScriptKind, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypeFormatFlags, TypePredicateKind };
|
|
30
|
-
export type { APIImportAdderAction as ImportAdderAction, APIOptions, AssertsIdentifierTypePredicate, AssertsThisTypePredicate, BigIntLiteralType, BooleanLiteralType, ClientSocketOptions, ClientSpawnOptions, CompilerOptions, CompletionEntry, CompletionInfo, CompletionOptions, ConditionalType, ConfiguredProjectId,
|
|
30
|
+
export type { APIImportAdderAction as ImportAdderAction, APIOptions, AssertsIdentifierTypePredicate, AssertsThisTypePredicate, BigIntLiteralType, BooleanLiteralType, ClientSocketOptions, ClientSpawnOptions, CompilerOptions, CompletionEntry, CompletionInfo, CompletionOptions, ConditionalType, ConfiguredProjectId, CreateSourceFileOptions, Diagnostic, DocumentIdentifier, DocumentPosition, EmitOutput, EmitOutputFile, EmitResult, FileNotifications, FormatDiagnosticsHost, FreshableType, GenericType, GetImportEditsForSymbolsOptions, IdentifierTypePredicate, IndexedAccessType, IndexInfo, IndexType, InferredProjectId, InterfaceType, IntersectionType, IntrinsicType, JSDocTagInfo, LiteralType, LSPConnectionOptions, MappedType, ModuleResolutionEntry, ModuleResolutionSpec, NumberLiteralType, ObjectType, PackageId, ParsedCommandLine, ProjectId, ProjectReference, ReadConfigFileResponse, RequestTiming, ResolutionMode, ResolvedModule, ResolvedTypeReferenceDirective, ResolveModuleNameResult, SourceFileMetadata, StaticModuleResolution, StringLiteralType, StringMappingType, StructuredType, SubstitutionType, SyntheticProjectId, TemplateLiteralType, TextEdit, ThisTypePredicate, TimingAccumulators, TimingInfo, TupleType, TupleTypeReference, Type, TypeAcquisition, TypeParameter, TypePredicate, TypePredicateBase, TypeReference, UnionOrIntersectionType, UnionType, };
|
|
31
|
+
export interface ModuleResolverOptions {
|
|
32
|
+
moduleResolutions?: ModuleResolutionSpec | undefined;
|
|
33
|
+
resolveModuleName?: ResolveModuleNameCallback | undefined;
|
|
34
|
+
}
|
|
35
|
+
export interface ResolveModuleNameCallbackOptions {
|
|
36
|
+
snapshot: Snapshot | InProgressSnapshot | undefined;
|
|
37
|
+
}
|
|
38
|
+
declare const inProgressSnapshotBrand: unique symbol;
|
|
39
|
+
export type InProgressSnapshot = number & {
|
|
40
|
+
readonly [inProgressSnapshotBrand]: never;
|
|
41
|
+
};
|
|
42
|
+
export type ResolveModuleNameCallback = (moduleName: string, containingDirectory: string, resolutionMode: ResolutionMode | undefined, options: ResolveModuleNameCallbackOptions) => StaticModuleResolution | undefined;
|
|
43
|
+
export type CreateProgramOptions = Omit<ProtocolCreateProgramOptions, "moduleResolver"> & {
|
|
44
|
+
moduleResolver?: ModuleResolver | undefined;
|
|
45
|
+
};
|
|
46
|
+
export type CreateSnapshotProgramParams = Omit<ProtocolCreateSnapshotProgramParams, "options"> & {
|
|
47
|
+
options?: CreateProgramOptions | undefined;
|
|
48
|
+
};
|
|
49
|
+
export type ReconfigureSnapshotProgramParams = Omit<ProtocolReconfigureSnapshotProgramParams, "options"> & {
|
|
50
|
+
options?: CreateProgramOptions | undefined;
|
|
51
|
+
};
|
|
52
|
+
export type CreateSnapshotParams = Omit<ProtocolCreateSnapshotParams, "createPrograms" | "reconfigurePrograms"> & {
|
|
53
|
+
createPrograms?: readonly CreateSnapshotProgramParams[] | undefined;
|
|
54
|
+
reconfigurePrograms?: readonly ReconfigureSnapshotProgramParams[] | undefined;
|
|
55
|
+
};
|
|
56
|
+
export type LanguageServerSnapshotChanges = Omit<ProtocolLanguageServerSnapshotChanges, "createPrograms" | "reconfigurePrograms"> & {
|
|
57
|
+
createPrograms?: readonly CreateSnapshotProgramParams[] | undefined;
|
|
58
|
+
reconfigurePrograms?: readonly ReconfigureSnapshotProgramParams[] | undefined;
|
|
59
|
+
};
|
|
31
60
|
export interface TranspileOptions {
|
|
32
61
|
compilerOptions?: CompilerOptions | undefined;
|
|
33
62
|
fileName?: string | undefined;
|
|
@@ -50,6 +79,7 @@ export declare class API<FromLSP extends boolean = false> implements FormatDiagn
|
|
|
50
79
|
private initialized;
|
|
51
80
|
private initializing;
|
|
52
81
|
private activeSnapshots;
|
|
82
|
+
private activeSourceFileLeases;
|
|
53
83
|
readonly printer: Printer;
|
|
54
84
|
readonly internal: InternalAPI;
|
|
55
85
|
constructor(options?: APIOptions | LSPConnectionOptions);
|
|
@@ -95,14 +125,23 @@ export declare class API<FromLSP extends boolean = false> implements FormatDiagn
|
|
|
95
125
|
configDirectory?: never;
|
|
96
126
|
}): Generator<ProtocolRequest, ParsedCommandLine, ProtocolResponse["result"]>;
|
|
97
127
|
};
|
|
128
|
+
/**
|
|
129
|
+
* Create and retain a source file independently of a program.
|
|
130
|
+
* Dispose the returned lease when the source file no longer needs to remain available remotely.
|
|
131
|
+
*/
|
|
98
132
|
get createSourceFile(): {
|
|
99
|
-
(fileName: string, sourceText: string, options?: CreateSourceFileOptions):
|
|
100
|
-
gen(fileName: string, sourceText: string, options?: CreateSourceFileOptions): Generator<ProtocolRequest,
|
|
133
|
+
(fileName: string, sourceText: string, options?: CreateSourceFileOptions): RetainedSourceFile;
|
|
134
|
+
gen(fileName: string, sourceText: string, options?: CreateSourceFileOptions): Generator<ProtocolRequest, RetainedSourceFile, ProtocolResponse["result"]>;
|
|
101
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* Read, create, and retain a source file independently of a program.
|
|
138
|
+
* Dispose the returned lease when the source file no longer needs to remain available remotely.
|
|
139
|
+
*/
|
|
102
140
|
get createSourceFileFromFile(): {
|
|
103
|
-
(file: DocumentIdentifier, options?: CreateSourceFileOptions):
|
|
104
|
-
gen(file: DocumentIdentifier, options?: CreateSourceFileOptions): Generator<ProtocolRequest,
|
|
141
|
+
(file: DocumentIdentifier, options?: CreateSourceFileOptions): RetainedSourceFile;
|
|
142
|
+
gen(file: DocumentIdentifier, options?: CreateSourceFileOptions): Generator<ProtocolRequest, RetainedSourceFile, ProtocolResponse["result"]>;
|
|
105
143
|
};
|
|
144
|
+
private retainSourceFileResponse;
|
|
106
145
|
get transpileModule(): {
|
|
107
146
|
(input: string, options?: TranspileOptions): TranspileOutput;
|
|
108
147
|
gen(input: string, options?: TranspileOptions): Generator<ProtocolRequest, TranspileOutput, ProtocolResponse["result"]>;
|
|
@@ -126,6 +165,8 @@ export declare class API<FromLSP extends boolean = false> implements FormatDiagn
|
|
|
126
165
|
gen(): Generator<ProtocolRequest, Snapshot, ProtocolResponse["result"]>;
|
|
127
166
|
};
|
|
128
167
|
private get updateSnapshot();
|
|
168
|
+
private prepareCreateSnapshotParams;
|
|
169
|
+
private prepareLanguageServerSnapshotChanges;
|
|
129
170
|
private createSnapshotUpdater;
|
|
130
171
|
/**
|
|
131
172
|
* Returns the language server's current canonical snapshot after atomically
|
|
@@ -142,6 +183,10 @@ export declare class API<FromLSP extends boolean = false> implements FormatDiagn
|
|
|
142
183
|
(): void;
|
|
143
184
|
gen(): Generator<ProtocolRequest, void, ProtocolResponse["result"]>;
|
|
144
185
|
};
|
|
186
|
+
get createModuleResolver(): {
|
|
187
|
+
(compilerOptions: CompilerOptions, options?: ModuleResolverOptions): ModuleResolver;
|
|
188
|
+
gen(compilerOptions: CompilerOptions, options?: ModuleResolverOptions): Generator<ProtocolRequest, ModuleResolver, ProtocolResponse["result"]>;
|
|
189
|
+
};
|
|
145
190
|
clearSourceFileCache(): void;
|
|
146
191
|
get runWithTemporaryFileUpdate(): {
|
|
147
192
|
(baseSnapshot: Snapshot, file: DocumentIdentifier, newText: string, cb: (newSnapshot: Snapshot) => void): void;
|
|
@@ -176,6 +221,22 @@ export declare class API<FromLSP extends boolean = false> implements FormatDiagn
|
|
|
176
221
|
type EnsureInitialized = (() => void) & {
|
|
177
222
|
gen(): Generator<ProtocolRequest, void, ProtocolResponse["result"]>;
|
|
178
223
|
};
|
|
224
|
+
/** An independently retained source file and its disposable remote-lifetime lease. */
|
|
225
|
+
export declare class RetainedSourceFile {
|
|
226
|
+
readonly sourceFile: SourceFile;
|
|
227
|
+
private readonly lease;
|
|
228
|
+
private readonly client;
|
|
229
|
+
private readonly onDispose;
|
|
230
|
+
private disposed;
|
|
231
|
+
private disposePromise;
|
|
232
|
+
constructor(sourceFile: SourceFile, lease: number, client: Client, onDispose: () => void);
|
|
233
|
+
[globalThis.Symbol.dispose](): void;
|
|
234
|
+
get dispose(): {
|
|
235
|
+
(): void;
|
|
236
|
+
gen(): Generator<ProtocolRequest, void, ProtocolResponse["result"]>;
|
|
237
|
+
};
|
|
238
|
+
private get disposeWorker();
|
|
239
|
+
}
|
|
179
240
|
export declare class InternalAPI {
|
|
180
241
|
private client;
|
|
181
242
|
private ensureInitialized;
|
|
@@ -217,7 +278,10 @@ type ContextualizeTuple<Tuple extends readonly unknown[] | undefined, Elements e
|
|
|
217
278
|
readonly [Index in keyof Tuple]: NonNullable<Elements>[number];
|
|
218
279
|
};
|
|
219
280
|
/** Substitutes the operation arrays with contextually typed, tuple-preserving versions. */
|
|
220
|
-
type SnapshotOperationParams<Params extends
|
|
281
|
+
type SnapshotOperationParams<Params extends {
|
|
282
|
+
createPrograms?: readonly unknown[] | undefined;
|
|
283
|
+
openFiles?: readonly unknown[] | undefined;
|
|
284
|
+
}, CreatePrograms extends Params["createPrograms"], OpenFiles extends Params["openFiles"]> = Omit<Params, "createPrograms" | "openFiles"> & {
|
|
221
285
|
createPrograms?: ContextualizeTuple<CreatePrograms, Params["createPrograms"]> | undefined;
|
|
222
286
|
openFiles?: ContextualizeTuple<OpenFiles, Params["openFiles"]> | undefined;
|
|
223
287
|
};
|
|
@@ -225,7 +289,7 @@ type SnapshotOperationParams<Params extends CreateSnapshotParams, CreatePrograms
|
|
|
225
289
|
* Refines a snapshot's operation results to required tuples when the corresponding
|
|
226
290
|
* operation arrays were supplied, preserving their lengths for indexed access.
|
|
227
291
|
*/
|
|
228
|
-
type SnapshotForOperationResults<CreatePrograms extends
|
|
292
|
+
type SnapshotForOperationResults<CreatePrograms extends readonly unknown[] | undefined, OpenFiles extends readonly unknown[] | undefined> = Snapshot & {
|
|
229
293
|
readonly operation: SnapshotOperation & (CreatePrograms extends readonly unknown[] ? {
|
|
230
294
|
readonly createdPrograms: MapTupleTo<CreatePrograms, Program<SyntheticProjectId>>;
|
|
231
295
|
} : unknown) & (OpenFiles extends readonly unknown[] ? {
|
|
@@ -282,6 +346,28 @@ export declare class Snapshot {
|
|
|
282
346
|
private ensureNotDisposed;
|
|
283
347
|
private requireProject;
|
|
284
348
|
}
|
|
349
|
+
export declare class ModuleResolver {
|
|
350
|
+
readonly id: number;
|
|
351
|
+
private readonly client;
|
|
352
|
+
private readonly disposeCallback;
|
|
353
|
+
private disposed;
|
|
354
|
+
constructor(id: number, client: Client, disposeCallback: (() => void) | undefined);
|
|
355
|
+
get resolveModuleName(): {
|
|
356
|
+
(moduleName: string, containingDirectory: DocumentIdentifier, resolutionMode?: ResolutionMode, options?: {
|
|
357
|
+
snapshot?: Snapshot | InProgressSnapshot | undefined;
|
|
358
|
+
}): ResolveModuleNameResult;
|
|
359
|
+
gen(moduleName: string, containingDirectory: DocumentIdentifier, resolutionMode?: ResolutionMode, options?: {
|
|
360
|
+
snapshot?: Snapshot | InProgressSnapshot | undefined;
|
|
361
|
+
}): Generator<ProtocolRequest, ResolveModuleNameResult, ProtocolResponse["result"]>;
|
|
362
|
+
};
|
|
363
|
+
[globalThis.Symbol.dispose](): void;
|
|
364
|
+
get dispose(): {
|
|
365
|
+
(): void;
|
|
366
|
+
gen(): Generator<ProtocolRequest, void, ProtocolResponse["result"]>;
|
|
367
|
+
};
|
|
368
|
+
/** @internal */
|
|
369
|
+
ensureNotDisposed(): void;
|
|
370
|
+
}
|
|
285
371
|
declare class SnapshotObjectRegistry {
|
|
286
372
|
private readonly symbols;
|
|
287
373
|
private readonly client;
|
|
@@ -1270,6 +1356,7 @@ declare class TypeObject implements Type {
|
|
|
1270
1356
|
private constructSignatures;
|
|
1271
1357
|
private indexInfos;
|
|
1272
1358
|
private baseTypes;
|
|
1359
|
+
private types;
|
|
1273
1360
|
private stringIndexType;
|
|
1274
1361
|
private numberIndexType;
|
|
1275
1362
|
constructor(data: TypeResponse, objectRegistry: ProjectObjectRegistry);
|