@corsa-bind/napi 1.13.2 → 1.14.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/README.md +6 -1
- package/dist/checker_batch.d.mts +22 -0
- package/dist/checker_batch.mjs +43 -0
- package/dist/checker_batch.mjs.map +1 -0
- package/dist/index.d.mts +83 -16
- package/dist/index.mjs +75 -2
- package/dist/index.mjs.map +1 -1
- package/dist/orchestrator.d.mts +18 -0
- package/dist/orchestrator.mjs +332 -0
- package/dist/orchestrator.mjs.map +1 -0
- package/dist/orchestrator_types.d.mts +95 -0
- package/dist/orchestrator_types.mjs +1 -0
- package/dist/types.d.mts +92 -1
- package/index.d.ts +64 -20
- package/index.js +59 -55
- package/package.json +16 -9
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { batchCheckerRequests, batchCheckerRequestsAsync } from "./checker_batch.mjs";
|
|
2
|
+
//#region orchestrator.ts
|
|
3
|
+
/**
|
|
4
|
+
* Resolves common project-scoped checker lookups as one coalesced batch.
|
|
5
|
+
*
|
|
6
|
+
* Position queries are grouped per source file and symbol-type queries use
|
|
7
|
+
* `getTypesOfSymbols`, so callers can express per-node facts without writing
|
|
8
|
+
* their own N+1 loop.
|
|
9
|
+
*/
|
|
10
|
+
function resolveCheckerBatch(client, scope, queries) {
|
|
11
|
+
const plan = planCheckerBatch(scope, queries);
|
|
12
|
+
if (plan.requests.length === 0) return plan.resolve([]);
|
|
13
|
+
return plan.resolve(batchCheckerRequests(client, plan.requests));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Async counterpart of {@link resolveCheckerBatch}.
|
|
17
|
+
*/
|
|
18
|
+
async function resolveCheckerBatchAsync(client, scope, queries) {
|
|
19
|
+
const plan = planCheckerBatch(scope, queries);
|
|
20
|
+
if (plan.requests.length === 0) return plan.resolve([]);
|
|
21
|
+
return plan.resolve(await batchCheckerRequestsAsync(client, plan.requests));
|
|
22
|
+
}
|
|
23
|
+
function planCheckerBatch(scope, queries) {
|
|
24
|
+
const results = [];
|
|
25
|
+
results.length = queries.length;
|
|
26
|
+
const requests = [];
|
|
27
|
+
const requestRoutes = [];
|
|
28
|
+
const directRequestIndexes = /* @__PURE__ */ new Map();
|
|
29
|
+
const typePositionGroups = /* @__PURE__ */ new Map();
|
|
30
|
+
const symbolPositionGroups = /* @__PURE__ */ new Map();
|
|
31
|
+
const symbolTypeGroup = {
|
|
32
|
+
symbols: [],
|
|
33
|
+
symbolSet: /* @__PURE__ */ new Set(),
|
|
34
|
+
routes: []
|
|
35
|
+
};
|
|
36
|
+
const addRequest = (request, route) => {
|
|
37
|
+
requests.push(request);
|
|
38
|
+
requestRoutes.push([route]);
|
|
39
|
+
};
|
|
40
|
+
const addDirectRequest = (query, queryIndex, method, params, transform = directBatchResult) => {
|
|
41
|
+
const compactParams = omitUndefinedProperties(params);
|
|
42
|
+
const requestKey = `${method}\0${JSON.stringify(compactParams)}`;
|
|
43
|
+
const route = (response) => {
|
|
44
|
+
setResponseResult(results, queryIndex, query, response, transform);
|
|
45
|
+
};
|
|
46
|
+
const existingIndex = directRequestIndexes.get(requestKey);
|
|
47
|
+
if (existingIndex !== void 0) {
|
|
48
|
+
requestRoutes[existingIndex]?.push(route);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
directRequestIndexes.set(requestKey, requests.length);
|
|
52
|
+
addRequest({
|
|
53
|
+
method,
|
|
54
|
+
params: compactParams
|
|
55
|
+
}, route);
|
|
56
|
+
};
|
|
57
|
+
queries.forEach((query, queryIndex) => {
|
|
58
|
+
switch (query.kind) {
|
|
59
|
+
case "typeAtPosition":
|
|
60
|
+
addPositionBatchQuery(typePositionGroups, query, queryIndex, query.file, [query.position], true);
|
|
61
|
+
break;
|
|
62
|
+
case "typesAtPositions":
|
|
63
|
+
if (query.positions.length === 0) results[queryIndex] = {
|
|
64
|
+
key: query.key,
|
|
65
|
+
kind: query.kind,
|
|
66
|
+
result: []
|
|
67
|
+
};
|
|
68
|
+
else addPositionBatchQuery(typePositionGroups, query, queryIndex, query.file, query.positions, false);
|
|
69
|
+
break;
|
|
70
|
+
case "symbolAtPosition":
|
|
71
|
+
addPositionBatchQuery(symbolPositionGroups, query, queryIndex, query.file, [query.position], true);
|
|
72
|
+
break;
|
|
73
|
+
case "symbolsAtPositions":
|
|
74
|
+
if (query.positions.length === 0) results[queryIndex] = {
|
|
75
|
+
key: query.key,
|
|
76
|
+
kind: query.kind,
|
|
77
|
+
result: []
|
|
78
|
+
};
|
|
79
|
+
else addPositionBatchQuery(symbolPositionGroups, query, queryIndex, query.file, query.positions, false);
|
|
80
|
+
break;
|
|
81
|
+
case "typeOfSymbol":
|
|
82
|
+
addSymbolTypeBatchQuery(symbolTypeGroup, query, queryIndex, [query.symbol], true);
|
|
83
|
+
break;
|
|
84
|
+
case "typesOfSymbols":
|
|
85
|
+
if (query.symbols.length === 0) results[queryIndex] = {
|
|
86
|
+
key: query.key,
|
|
87
|
+
kind: query.kind,
|
|
88
|
+
result: []
|
|
89
|
+
};
|
|
90
|
+
else addSymbolTypeBatchQuery(symbolTypeGroup, query, queryIndex, query.symbols, false);
|
|
91
|
+
break;
|
|
92
|
+
case "symbolOfType":
|
|
93
|
+
addDirectRequest(query, queryIndex, "getSymbolOfType", {
|
|
94
|
+
snapshot: scope.snapshot,
|
|
95
|
+
project: scope.project,
|
|
96
|
+
type: query.type
|
|
97
|
+
});
|
|
98
|
+
break;
|
|
99
|
+
case "declaredTypeOfSymbol":
|
|
100
|
+
addDirectRequest(query, queryIndex, "getDeclaredTypeOfSymbol", {
|
|
101
|
+
snapshot: scope.snapshot,
|
|
102
|
+
project: scope.project,
|
|
103
|
+
symbol: query.symbol
|
|
104
|
+
});
|
|
105
|
+
break;
|
|
106
|
+
case "aliasedSymbol":
|
|
107
|
+
addDirectRequest(query, queryIndex, "getAliasedSymbol", {
|
|
108
|
+
snapshot: scope.snapshot,
|
|
109
|
+
project: scope.project,
|
|
110
|
+
symbol: query.symbol
|
|
111
|
+
});
|
|
112
|
+
break;
|
|
113
|
+
case "immediateAliasedSymbol":
|
|
114
|
+
addDirectRequest(query, queryIndex, "getImmediateAliasedSymbol", {
|
|
115
|
+
snapshot: scope.snapshot,
|
|
116
|
+
project: scope.project,
|
|
117
|
+
symbol: query.symbol
|
|
118
|
+
});
|
|
119
|
+
break;
|
|
120
|
+
case "exportsOfModule":
|
|
121
|
+
addDirectRequest(query, queryIndex, "getExportsOfModule", {
|
|
122
|
+
snapshot: scope.snapshot,
|
|
123
|
+
project: scope.project,
|
|
124
|
+
symbol: query.symbol
|
|
125
|
+
}, arrayBatchResult);
|
|
126
|
+
break;
|
|
127
|
+
case "propertyOfType":
|
|
128
|
+
addDirectRequest(query, queryIndex, "getPropertyOfType", {
|
|
129
|
+
snapshot: scope.snapshot,
|
|
130
|
+
project: scope.project,
|
|
131
|
+
type: query.type,
|
|
132
|
+
name: query.name
|
|
133
|
+
});
|
|
134
|
+
break;
|
|
135
|
+
case "typeArguments":
|
|
136
|
+
if (query.objectFlags !== void 0 && (query.objectFlags & 36) === 0) results[queryIndex] = {
|
|
137
|
+
key: query.key,
|
|
138
|
+
kind: query.kind,
|
|
139
|
+
result: []
|
|
140
|
+
};
|
|
141
|
+
else addDirectRequest(query, queryIndex, "getTypeArguments", {
|
|
142
|
+
snapshot: scope.snapshot,
|
|
143
|
+
project: scope.project,
|
|
144
|
+
type: query.type
|
|
145
|
+
}, arrayBatchResult);
|
|
146
|
+
break;
|
|
147
|
+
case "constraintOfType":
|
|
148
|
+
addDirectRequest(query, queryIndex, "getConstraintOfType", {
|
|
149
|
+
snapshot: scope.snapshot,
|
|
150
|
+
project: scope.project,
|
|
151
|
+
type: query.type
|
|
152
|
+
});
|
|
153
|
+
break;
|
|
154
|
+
case "isTypeAssignableTo":
|
|
155
|
+
addDirectRequest(query, queryIndex, "isTypeAssignableTo", {
|
|
156
|
+
snapshot: scope.snapshot,
|
|
157
|
+
project: scope.project,
|
|
158
|
+
source: query.source,
|
|
159
|
+
target: query.target
|
|
160
|
+
});
|
|
161
|
+
break;
|
|
162
|
+
case "typeToString": addDirectRequest(query, queryIndex, "typeToString", {
|
|
163
|
+
snapshot: scope.snapshot,
|
|
164
|
+
project: scope.project,
|
|
165
|
+
type: query.type,
|
|
166
|
+
location: query.location,
|
|
167
|
+
flags: query.flags
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
flushPositionBatchGroups(scope, typePositionGroups, "getTypesAtPositions", requests, requestRoutes, results);
|
|
172
|
+
flushPositionBatchGroups(scope, symbolPositionGroups, "getSymbolsAtPositions", requests, requestRoutes, results);
|
|
173
|
+
flushSymbolTypeBatchGroup(scope, symbolTypeGroup, requests, requestRoutes, results);
|
|
174
|
+
return {
|
|
175
|
+
requests,
|
|
176
|
+
resolve(responses) {
|
|
177
|
+
for (const [index, response] of responses.entries()) for (const route of requestRoutes[index] ?? []) route(response);
|
|
178
|
+
return queries.map((query, index) => {
|
|
179
|
+
return results[index] ?? {
|
|
180
|
+
key: query.key,
|
|
181
|
+
kind: query.kind,
|
|
182
|
+
error: "checker batch query did not produce a result"
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function addPositionBatchQuery(groups, query, queryIndex, file, positions, single) {
|
|
189
|
+
let group = groups.get(file);
|
|
190
|
+
if (!group) {
|
|
191
|
+
group = {
|
|
192
|
+
file,
|
|
193
|
+
positions: [],
|
|
194
|
+
positionSet: /* @__PURE__ */ new Set(),
|
|
195
|
+
routes: []
|
|
196
|
+
};
|
|
197
|
+
groups.set(file, group);
|
|
198
|
+
}
|
|
199
|
+
for (const position of positions) if (!group.positionSet.has(position)) {
|
|
200
|
+
group.positionSet.add(position);
|
|
201
|
+
group.positions.push(position);
|
|
202
|
+
}
|
|
203
|
+
group.routes.push({
|
|
204
|
+
query,
|
|
205
|
+
queryIndex,
|
|
206
|
+
positions,
|
|
207
|
+
single
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function addSymbolTypeBatchQuery(group, query, queryIndex, symbols, single) {
|
|
211
|
+
for (const symbol of symbols) if (!group.symbolSet.has(symbol)) {
|
|
212
|
+
group.symbolSet.add(symbol);
|
|
213
|
+
group.symbols.push(symbol);
|
|
214
|
+
}
|
|
215
|
+
group.routes.push({
|
|
216
|
+
query,
|
|
217
|
+
queryIndex,
|
|
218
|
+
symbols,
|
|
219
|
+
single
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function flushPositionBatchGroups(scope, groups, method, requests, requestRoutes, results) {
|
|
223
|
+
for (const group of groups.values()) {
|
|
224
|
+
requests.push({
|
|
225
|
+
method,
|
|
226
|
+
params: {
|
|
227
|
+
snapshot: scope.snapshot,
|
|
228
|
+
project: scope.project,
|
|
229
|
+
file: group.file,
|
|
230
|
+
positions: group.positions
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
requestRoutes.push([(response) => {
|
|
234
|
+
if (response.error) {
|
|
235
|
+
for (const route of group.routes) results[route.queryIndex] = {
|
|
236
|
+
key: route.query.key,
|
|
237
|
+
kind: route.query.kind,
|
|
238
|
+
error: response.error
|
|
239
|
+
};
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (!Array.isArray(response.result)) {
|
|
243
|
+
const error = `${method} returned a non-array result`;
|
|
244
|
+
for (const route of group.routes) results[route.queryIndex] = {
|
|
245
|
+
key: route.query.key,
|
|
246
|
+
kind: route.query.kind,
|
|
247
|
+
error
|
|
248
|
+
};
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const byPosition = /* @__PURE__ */ new Map();
|
|
252
|
+
for (const [index, position] of group.positions.entries()) byPosition.set(position, response.result[index] ?? null);
|
|
253
|
+
for (const route of group.routes) {
|
|
254
|
+
const result = route.single ? byPosition.get(route.positions[0] ?? -1) ?? null : route.positions.map((position) => byPosition.get(position) ?? null);
|
|
255
|
+
results[route.queryIndex] = {
|
|
256
|
+
key: route.query.key,
|
|
257
|
+
kind: route.query.kind,
|
|
258
|
+
result
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}]);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function flushSymbolTypeBatchGroup(scope, group, requests, requestRoutes, results) {
|
|
265
|
+
if (group.symbols.length === 0) return;
|
|
266
|
+
requests.push({
|
|
267
|
+
method: "getTypesOfSymbols",
|
|
268
|
+
params: {
|
|
269
|
+
snapshot: scope.snapshot,
|
|
270
|
+
project: scope.project,
|
|
271
|
+
symbols: group.symbols
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
requestRoutes.push([(response) => {
|
|
275
|
+
if (response.error) {
|
|
276
|
+
for (const route of group.routes) results[route.queryIndex] = {
|
|
277
|
+
key: route.query.key,
|
|
278
|
+
kind: route.query.kind,
|
|
279
|
+
error: response.error
|
|
280
|
+
};
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (!Array.isArray(response.result)) {
|
|
284
|
+
const error = "getTypesOfSymbols returned a non-array result";
|
|
285
|
+
for (const route of group.routes) results[route.queryIndex] = {
|
|
286
|
+
key: route.query.key,
|
|
287
|
+
kind: route.query.kind,
|
|
288
|
+
error
|
|
289
|
+
};
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const bySymbol = /* @__PURE__ */ new Map();
|
|
293
|
+
for (const [index, symbol] of group.symbols.entries()) bySymbol.set(symbol, response.result[index] ?? null);
|
|
294
|
+
for (const route of group.routes) {
|
|
295
|
+
const result = route.single ? bySymbol.get(route.symbols[0] ?? "") ?? null : route.symbols.map((symbol) => bySymbol.get(symbol) ?? null);
|
|
296
|
+
results[route.queryIndex] = {
|
|
297
|
+
key: route.query.key,
|
|
298
|
+
kind: route.query.kind,
|
|
299
|
+
result
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}]);
|
|
303
|
+
}
|
|
304
|
+
function setResponseResult(results, queryIndex, query, response, transform) {
|
|
305
|
+
if (response.error) {
|
|
306
|
+
results[queryIndex] = {
|
|
307
|
+
key: query.key,
|
|
308
|
+
kind: query.kind,
|
|
309
|
+
error: response.error
|
|
310
|
+
};
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
results[queryIndex] = {
|
|
314
|
+
key: query.key,
|
|
315
|
+
kind: query.kind,
|
|
316
|
+
result: transform(response.result)
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function directBatchResult(result) {
|
|
320
|
+
return result ?? null;
|
|
321
|
+
}
|
|
322
|
+
function arrayBatchResult(result) {
|
|
323
|
+
if (result === null || result === void 0) return [];
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
326
|
+
function omitUndefinedProperties(input) {
|
|
327
|
+
return Object.fromEntries(Object.entries(input).filter((entry) => entry[1] !== void 0));
|
|
328
|
+
}
|
|
329
|
+
//#endregion
|
|
330
|
+
export { resolveCheckerBatch, resolveCheckerBatchAsync };
|
|
331
|
+
|
|
332
|
+
//# sourceMappingURL=orchestrator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.mjs","names":[],"sources":["../ts/orchestrator.ts"],"sourcesContent":["import {\n batchCheckerRequests,\n batchCheckerRequestsAsync,\n type AsyncCheckerBatchCapableClient,\n type CheckerBatchCapableClient,\n} from \"./checker_batch\";\n\nimport type { CheckerBatchRequest, CheckerBatchResponse } from \"./types\";\nimport type {\n CheckerBatchQuery,\n CheckerBatchResult,\n CheckerBatchScope,\n ResolvedCheckerBatchItem,\n} from \"./orchestrator_types\";\n\nconst OBJECT_FLAGS_REFERENCE = 1 << 2;\nconst OBJECT_FLAGS_MAPPED = 1 << 5;\n\ntype CheckerBatchRoute = (response: CheckerBatchResponse) => void;\n\ninterface PositionBatchGroup {\n file: string;\n positions: number[];\n positionSet: Set<number>;\n routes: PositionBatchRoute[];\n}\n\ninterface PositionBatchRoute {\n query: CheckerBatchQuery;\n queryIndex: number;\n positions: readonly number[];\n single: boolean;\n}\n\ninterface SymbolTypeBatchGroup {\n symbols: string[];\n symbolSet: Set<string>;\n routes: SymbolTypeBatchRoute[];\n}\n\ninterface SymbolTypeBatchRoute {\n query: CheckerBatchQuery;\n queryIndex: number;\n symbols: readonly string[];\n single: boolean;\n}\n\ninterface CheckerBatchPlan {\n requests: CheckerBatchRequest[];\n resolve(responses: CheckerBatchResponse[]): ResolvedCheckerBatchItem[];\n}\n\n/**\n * Resolves common project-scoped checker lookups as one coalesced batch.\n *\n * Position queries are grouped per source file and symbol-type queries use\n * `getTypesOfSymbols`, so callers can express per-node facts without writing\n * their own N+1 loop.\n */\nexport function resolveCheckerBatch(\n client: CheckerBatchCapableClient,\n scope: CheckerBatchScope,\n queries: readonly CheckerBatchQuery[],\n): ResolvedCheckerBatchItem[] {\n const plan = planCheckerBatch(scope, queries);\n if (plan.requests.length === 0) {\n return plan.resolve([]);\n }\n return plan.resolve(batchCheckerRequests(client, plan.requests));\n}\n\n/**\n * Async counterpart of {@link resolveCheckerBatch}.\n */\nexport async function resolveCheckerBatchAsync(\n client: AsyncCheckerBatchCapableClient,\n scope: CheckerBatchScope,\n queries: readonly CheckerBatchQuery[],\n): Promise<ResolvedCheckerBatchItem[]> {\n const plan = planCheckerBatch(scope, queries);\n if (plan.requests.length === 0) {\n return plan.resolve([]);\n }\n return plan.resolve(await batchCheckerRequestsAsync(client, plan.requests));\n}\n\nexport type * from \"./orchestrator_types\";\n\nfunction planCheckerBatch(\n scope: CheckerBatchScope,\n queries: readonly CheckerBatchQuery[],\n): CheckerBatchPlan {\n const results: Array<ResolvedCheckerBatchItem | undefined> = [];\n results.length = queries.length;\n const requests: CheckerBatchRequest[] = [];\n const requestRoutes: CheckerBatchRoute[][] = [];\n const directRequestIndexes = new Map<string, number>();\n const typePositionGroups = new Map<string, PositionBatchGroup>();\n const symbolPositionGroups = new Map<string, PositionBatchGroup>();\n const symbolTypeGroup: SymbolTypeBatchGroup = {\n symbols: [],\n symbolSet: new Set(),\n routes: [],\n };\n\n const addRequest = (request: CheckerBatchRequest, route: CheckerBatchRoute): void => {\n requests.push(request);\n requestRoutes.push([route]);\n };\n const addDirectRequest = (\n query: CheckerBatchQuery,\n queryIndex: number,\n method: string,\n params: Record<string, unknown>,\n transform: (result: unknown) => CheckerBatchResult = directBatchResult,\n ): void => {\n const compactParams = omitUndefinedProperties(params);\n const requestKey = `${method}\\0${JSON.stringify(compactParams)}`;\n const route = (response: CheckerBatchResponse): void => {\n setResponseResult(results, queryIndex, query, response, transform);\n };\n const existingIndex = directRequestIndexes.get(requestKey);\n if (existingIndex !== undefined) {\n requestRoutes[existingIndex]?.push(route);\n return;\n }\n directRequestIndexes.set(requestKey, requests.length);\n addRequest({ method, params: compactParams }, route);\n };\n\n queries.forEach((query, queryIndex) => {\n switch (query.kind) {\n case \"typeAtPosition\":\n addPositionBatchQuery(\n typePositionGroups,\n query,\n queryIndex,\n query.file,\n [query.position],\n true,\n );\n break;\n case \"typesAtPositions\":\n if (query.positions.length === 0) {\n results[queryIndex] = { key: query.key, kind: query.kind, result: [] };\n } else {\n addPositionBatchQuery(\n typePositionGroups,\n query,\n queryIndex,\n query.file,\n query.positions,\n false,\n );\n }\n break;\n case \"symbolAtPosition\":\n addPositionBatchQuery(\n symbolPositionGroups,\n query,\n queryIndex,\n query.file,\n [query.position],\n true,\n );\n break;\n case \"symbolsAtPositions\":\n if (query.positions.length === 0) {\n results[queryIndex] = { key: query.key, kind: query.kind, result: [] };\n } else {\n addPositionBatchQuery(\n symbolPositionGroups,\n query,\n queryIndex,\n query.file,\n query.positions,\n false,\n );\n }\n break;\n case \"typeOfSymbol\":\n addSymbolTypeBatchQuery(symbolTypeGroup, query, queryIndex, [query.symbol], true);\n break;\n case \"typesOfSymbols\":\n if (query.symbols.length === 0) {\n results[queryIndex] = { key: query.key, kind: query.kind, result: [] };\n } else {\n addSymbolTypeBatchQuery(symbolTypeGroup, query, queryIndex, query.symbols, false);\n }\n break;\n case \"symbolOfType\":\n addDirectRequest(query, queryIndex, \"getSymbolOfType\", {\n snapshot: scope.snapshot,\n project: scope.project,\n type: query.type,\n });\n break;\n case \"declaredTypeOfSymbol\":\n addDirectRequest(query, queryIndex, \"getDeclaredTypeOfSymbol\", {\n snapshot: scope.snapshot,\n project: scope.project,\n symbol: query.symbol,\n });\n break;\n case \"aliasedSymbol\":\n addDirectRequest(query, queryIndex, \"getAliasedSymbol\", {\n snapshot: scope.snapshot,\n project: scope.project,\n symbol: query.symbol,\n });\n break;\n case \"immediateAliasedSymbol\":\n addDirectRequest(query, queryIndex, \"getImmediateAliasedSymbol\", {\n snapshot: scope.snapshot,\n project: scope.project,\n symbol: query.symbol,\n });\n break;\n case \"exportsOfModule\":\n addDirectRequest(\n query,\n queryIndex,\n \"getExportsOfModule\",\n {\n snapshot: scope.snapshot,\n project: scope.project,\n symbol: query.symbol,\n },\n arrayBatchResult,\n );\n break;\n case \"propertyOfType\":\n addDirectRequest(query, queryIndex, \"getPropertyOfType\", {\n snapshot: scope.snapshot,\n project: scope.project,\n type: query.type,\n name: query.name,\n });\n break;\n case \"typeArguments\":\n if (\n query.objectFlags !== undefined &&\n (query.objectFlags & (OBJECT_FLAGS_REFERENCE | OBJECT_FLAGS_MAPPED)) === 0\n ) {\n results[queryIndex] = { key: query.key, kind: query.kind, result: [] };\n } else {\n addDirectRequest(\n query,\n queryIndex,\n \"getTypeArguments\",\n {\n snapshot: scope.snapshot,\n project: scope.project,\n type: query.type,\n },\n arrayBatchResult,\n );\n }\n break;\n case \"constraintOfType\":\n addDirectRequest(query, queryIndex, \"getConstraintOfType\", {\n snapshot: scope.snapshot,\n project: scope.project,\n type: query.type,\n });\n break;\n case \"isTypeAssignableTo\":\n addDirectRequest(query, queryIndex, \"isTypeAssignableTo\", {\n snapshot: scope.snapshot,\n project: scope.project,\n source: query.source,\n target: query.target,\n });\n break;\n case \"typeToString\":\n addDirectRequest(query, queryIndex, \"typeToString\", {\n snapshot: scope.snapshot,\n project: scope.project,\n type: query.type,\n location: query.location,\n flags: query.flags,\n });\n break;\n }\n });\n\n flushPositionBatchGroups(\n scope,\n typePositionGroups,\n \"getTypesAtPositions\",\n requests,\n requestRoutes,\n results,\n );\n flushPositionBatchGroups(\n scope,\n symbolPositionGroups,\n \"getSymbolsAtPositions\",\n requests,\n requestRoutes,\n results,\n );\n flushSymbolTypeBatchGroup(scope, symbolTypeGroup, requests, requestRoutes, results);\n\n return {\n requests,\n resolve(responses) {\n for (const [index, response] of responses.entries()) {\n for (const route of requestRoutes[index] ?? []) {\n route(response);\n }\n }\n return queries.map((query, index) => {\n return (\n results[index] ?? {\n key: query.key,\n kind: query.kind,\n error: \"checker batch query did not produce a result\",\n }\n );\n });\n },\n };\n}\n\nfunction addPositionBatchQuery(\n groups: Map<string, PositionBatchGroup>,\n query: CheckerBatchQuery,\n queryIndex: number,\n file: string,\n positions: readonly number[],\n single: boolean,\n): void {\n let group = groups.get(file);\n if (!group) {\n group = {\n file,\n positions: [],\n positionSet: new Set(),\n routes: [],\n };\n groups.set(file, group);\n }\n for (const position of positions) {\n if (!group.positionSet.has(position)) {\n group.positionSet.add(position);\n group.positions.push(position);\n }\n }\n group.routes.push({ query, queryIndex, positions, single });\n}\n\nfunction addSymbolTypeBatchQuery(\n group: SymbolTypeBatchGroup,\n query: CheckerBatchQuery,\n queryIndex: number,\n symbols: readonly string[],\n single: boolean,\n): void {\n for (const symbol of symbols) {\n if (!group.symbolSet.has(symbol)) {\n group.symbolSet.add(symbol);\n group.symbols.push(symbol);\n }\n }\n group.routes.push({ query, queryIndex, symbols, single });\n}\n\nfunction flushPositionBatchGroups(\n scope: CheckerBatchScope,\n groups: Map<string, PositionBatchGroup>,\n method: \"getTypesAtPositions\" | \"getSymbolsAtPositions\",\n requests: CheckerBatchRequest[],\n requestRoutes: CheckerBatchRoute[][],\n results: Array<ResolvedCheckerBatchItem | undefined>,\n): void {\n for (const group of groups.values()) {\n requests.push({\n method,\n params: {\n snapshot: scope.snapshot,\n project: scope.project,\n file: group.file,\n positions: group.positions,\n },\n });\n requestRoutes.push([\n (response) => {\n if (response.error) {\n for (const route of group.routes) {\n results[route.queryIndex] = {\n key: route.query.key,\n kind: route.query.kind,\n error: response.error,\n };\n }\n return;\n }\n if (!Array.isArray(response.result)) {\n const error = `${method} returned a non-array result`;\n for (const route of group.routes) {\n results[route.queryIndex] = {\n key: route.query.key,\n kind: route.query.kind,\n error,\n };\n }\n return;\n }\n const byPosition = new Map<number, unknown>();\n for (const [index, position] of group.positions.entries()) {\n byPosition.set(position, response.result[index] ?? null);\n }\n for (const route of group.routes) {\n const result = route.single\n ? (byPosition.get(route.positions[0] ?? -1) ?? null)\n : route.positions.map((position) => byPosition.get(position) ?? null);\n results[route.queryIndex] = {\n key: route.query.key,\n kind: route.query.kind,\n result: result as CheckerBatchResult,\n };\n }\n },\n ]);\n }\n}\n\nfunction flushSymbolTypeBatchGroup(\n scope: CheckerBatchScope,\n group: SymbolTypeBatchGroup,\n requests: CheckerBatchRequest[],\n requestRoutes: CheckerBatchRoute[][],\n results: Array<ResolvedCheckerBatchItem | undefined>,\n): void {\n if (group.symbols.length === 0) {\n return;\n }\n requests.push({\n method: \"getTypesOfSymbols\",\n params: {\n snapshot: scope.snapshot,\n project: scope.project,\n symbols: group.symbols,\n },\n });\n requestRoutes.push([\n (response) => {\n if (response.error) {\n for (const route of group.routes) {\n results[route.queryIndex] = {\n key: route.query.key,\n kind: route.query.kind,\n error: response.error,\n };\n }\n return;\n }\n if (!Array.isArray(response.result)) {\n const error = \"getTypesOfSymbols returned a non-array result\";\n for (const route of group.routes) {\n results[route.queryIndex] = {\n key: route.query.key,\n kind: route.query.kind,\n error,\n };\n }\n return;\n }\n const bySymbol = new Map<string, unknown>();\n for (const [index, symbol] of group.symbols.entries()) {\n bySymbol.set(symbol, response.result[index] ?? null);\n }\n for (const route of group.routes) {\n const result = route.single\n ? (bySymbol.get(route.symbols[0] ?? \"\") ?? null)\n : route.symbols.map((symbol) => bySymbol.get(symbol) ?? null);\n results[route.queryIndex] = {\n key: route.query.key,\n kind: route.query.kind,\n result: result as CheckerBatchResult,\n };\n }\n },\n ]);\n}\n\nfunction setResponseResult(\n results: Array<ResolvedCheckerBatchItem | undefined>,\n queryIndex: number,\n query: CheckerBatchQuery,\n response: CheckerBatchResponse,\n transform: (result: unknown) => CheckerBatchResult,\n): void {\n if (response.error) {\n results[queryIndex] = {\n key: query.key,\n kind: query.kind,\n error: response.error,\n };\n return;\n }\n results[queryIndex] = {\n key: query.key,\n kind: query.kind,\n result: transform(response.result),\n };\n}\n\nfunction directBatchResult(result: unknown): CheckerBatchResult {\n return (result ?? null) as CheckerBatchResult;\n}\n\nfunction arrayBatchResult(result: unknown): CheckerBatchResult {\n if (result === null || result === undefined) {\n return [];\n }\n return result as CheckerBatchResult;\n}\n\nfunction omitUndefinedProperties(input: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(input).filter((entry): entry is [string, unknown] => entry[1] !== undefined),\n );\n}\n"],"mappings":";;;;;;;;;AA2DA,SAAgB,oBACd,QACA,OACA,SAC4B;CAC5B,MAAM,OAAO,iBAAiB,OAAO,OAAO;CAC5C,IAAI,KAAK,SAAS,WAAW,GAC3B,OAAO,KAAK,QAAQ,CAAC,CAAC;CAExB,OAAO,KAAK,QAAQ,qBAAqB,QAAQ,KAAK,QAAQ,CAAC;AACjE;;;;AAKA,eAAsB,yBACpB,QACA,OACA,SACqC;CACrC,MAAM,OAAO,iBAAiB,OAAO,OAAO;CAC5C,IAAI,KAAK,SAAS,WAAW,GAC3B,OAAO,KAAK,QAAQ,CAAC,CAAC;CAExB,OAAO,KAAK,QAAQ,MAAM,0BAA0B,QAAQ,KAAK,QAAQ,CAAC;AAC5E;AAIA,SAAS,iBACP,OACA,SACkB;CAClB,MAAM,UAAuD,CAAC;CAC9D,QAAQ,SAAS,QAAQ;CACzB,MAAM,WAAkC,CAAC;CACzC,MAAM,gBAAuC,CAAC;CAC9C,MAAM,uCAAuB,IAAI,IAAoB;CACrD,MAAM,qCAAqB,I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ACF;CACA,QAAQ,cAAc;EACpB,KAAK,MAAM;EACX,MAAM,MAAM;EACZ,QAAQ,UAAU,SAAS,MAAM;CACnC;AACF;AAEA,SAAS,kBAAkB,QAAqC;CAC9D,OAAQ,UAAU;AACpB;AAEA,SAAS,iBAAiB,QAAqC;CAC7D,IAAI,WAAW,QAAQ,WAAW,KAAA,GAChC,OAAO,CAAC;CAEV,OAAO;AACT;AAEA,SAAS,wBAAwB,OAAyD;CACxF,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,CAAC,CAAC,QAAQ,UAAsC,MAAM,OAAO,KAAA,CAAS,CAC5F;AACF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { SymbolResponse, TypeResponse } from "./types.mjs";
|
|
2
|
+
//#region orchestrator_types.d.ts
|
|
3
|
+
interface CheckerBatchScope {
|
|
4
|
+
snapshot: string;
|
|
5
|
+
project: string;
|
|
6
|
+
}
|
|
7
|
+
type CheckerBatchQuery = {
|
|
8
|
+
key: string;
|
|
9
|
+
kind: "typeAtPosition";
|
|
10
|
+
file: string;
|
|
11
|
+
position: number;
|
|
12
|
+
} | {
|
|
13
|
+
key: string;
|
|
14
|
+
kind: "typesAtPositions";
|
|
15
|
+
file: string;
|
|
16
|
+
positions: readonly number[];
|
|
17
|
+
} | {
|
|
18
|
+
key: string;
|
|
19
|
+
kind: "symbolAtPosition";
|
|
20
|
+
file: string;
|
|
21
|
+
position: number;
|
|
22
|
+
} | {
|
|
23
|
+
key: string;
|
|
24
|
+
kind: "symbolsAtPositions";
|
|
25
|
+
file: string;
|
|
26
|
+
positions: readonly number[];
|
|
27
|
+
} | {
|
|
28
|
+
key: string;
|
|
29
|
+
kind: "typeOfSymbol";
|
|
30
|
+
symbol: string;
|
|
31
|
+
} | {
|
|
32
|
+
key: string;
|
|
33
|
+
kind: "typesOfSymbols";
|
|
34
|
+
symbols: readonly string[];
|
|
35
|
+
} | {
|
|
36
|
+
key: string;
|
|
37
|
+
kind: "symbolOfType";
|
|
38
|
+
type: string;
|
|
39
|
+
} | {
|
|
40
|
+
key: string;
|
|
41
|
+
kind: "declaredTypeOfSymbol";
|
|
42
|
+
symbol: string;
|
|
43
|
+
} | {
|
|
44
|
+
key: string;
|
|
45
|
+
kind: "aliasedSymbol";
|
|
46
|
+
symbol: string;
|
|
47
|
+
} | {
|
|
48
|
+
key: string;
|
|
49
|
+
kind: "immediateAliasedSymbol";
|
|
50
|
+
symbol: string;
|
|
51
|
+
} | {
|
|
52
|
+
key: string;
|
|
53
|
+
kind: "exportsOfModule";
|
|
54
|
+
symbol: string;
|
|
55
|
+
} | {
|
|
56
|
+
key: string;
|
|
57
|
+
kind: "propertyOfType";
|
|
58
|
+
type: string;
|
|
59
|
+
name: string;
|
|
60
|
+
} | {
|
|
61
|
+
key: string;
|
|
62
|
+
kind: "typeArguments";
|
|
63
|
+
type: string;
|
|
64
|
+
objectFlags?: number;
|
|
65
|
+
} | {
|
|
66
|
+
key: string;
|
|
67
|
+
kind: "constraintOfType";
|
|
68
|
+
type: string;
|
|
69
|
+
} | {
|
|
70
|
+
key: string;
|
|
71
|
+
kind: "isTypeAssignableTo";
|
|
72
|
+
source: string;
|
|
73
|
+
target: string;
|
|
74
|
+
} | {
|
|
75
|
+
key: string;
|
|
76
|
+
kind: "typeToString";
|
|
77
|
+
type: string;
|
|
78
|
+
location?: string;
|
|
79
|
+
flags?: number;
|
|
80
|
+
};
|
|
81
|
+
type CheckerBatchResult = TypeResponse | Array<TypeResponse | null> | SymbolResponse | Array<SymbolResponse | null> | boolean | string | null;
|
|
82
|
+
type ResolvedCheckerBatchItem = {
|
|
83
|
+
key: string;
|
|
84
|
+
kind: CheckerBatchQuery["kind"];
|
|
85
|
+
result: CheckerBatchResult;
|
|
86
|
+
error?: never;
|
|
87
|
+
} | {
|
|
88
|
+
key: string;
|
|
89
|
+
kind: CheckerBatchQuery["kind"];
|
|
90
|
+
result?: never;
|
|
91
|
+
error: string;
|
|
92
|
+
};
|
|
93
|
+
//#endregion
|
|
94
|
+
export { CheckerBatchQuery, CheckerBatchResult, CheckerBatchScope, ResolvedCheckerBatchItem };
|
|
95
|
+
//# sourceMappingURL=orchestrator_types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.mts
CHANGED
|
@@ -18,6 +18,88 @@ interface InitializeResponse {
|
|
|
18
18
|
interface ConfigResponse {
|
|
19
19
|
options: unknown;
|
|
20
20
|
fileNames: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Raw `tsconfig` object as Corsa read it, when the runtime reports one.
|
|
23
|
+
* Top-level settings that are not compiler options — `contentMappers` among
|
|
24
|
+
* them — only exist here.
|
|
25
|
+
*/
|
|
26
|
+
raw?: unknown;
|
|
27
|
+
}
|
|
28
|
+
/** A content mapper as declared in a `tsconfig.json` `contentMappers` entry. */
|
|
29
|
+
interface ContentMapperDefinition {
|
|
30
|
+
/** npm package that implements the mapper. */
|
|
31
|
+
package: string;
|
|
32
|
+
/** Otherwise unsupported file extensions the mapper registers. */
|
|
33
|
+
extensions: string[];
|
|
34
|
+
/** Mapper-specific options forwarded verbatim to the mapper process. */
|
|
35
|
+
options?: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** `0` verbatim, `1` atom, `2` alias. */
|
|
38
|
+
type SpanMapKind = 0 | 1 | 2;
|
|
39
|
+
/** `0` exact, `1` atom, `2` approximate, `3` none. */
|
|
40
|
+
type SpanMapFidelity = 0 | 1 | 2 | 3;
|
|
41
|
+
/** `0` ignore, `1` expect. */
|
|
42
|
+
type DiagnosticDirectivePolicy = 0 | 1;
|
|
43
|
+
/** Half-open range of UTF-16 code unit offsets. */
|
|
44
|
+
interface TextRange {
|
|
45
|
+
pos: number;
|
|
46
|
+
end: number;
|
|
47
|
+
}
|
|
48
|
+
/** One half-open virtual range mapped onto one half-open original range. */
|
|
49
|
+
interface SpanMapSegment {
|
|
50
|
+
virtualStart: number;
|
|
51
|
+
virtualEnd: number;
|
|
52
|
+
originalStart: number;
|
|
53
|
+
originalEnd: number;
|
|
54
|
+
kind: SpanMapKind;
|
|
55
|
+
/** `SpanMap.Feature` bitmask; every feature when the mapper set no limit. */
|
|
56
|
+
features: number;
|
|
57
|
+
}
|
|
58
|
+
/** One projection of a position, with how faithful it is. */
|
|
59
|
+
interface MappedPosition {
|
|
60
|
+
position: number;
|
|
61
|
+
fidelity: SpanMapFidelity;
|
|
62
|
+
}
|
|
63
|
+
/** One projection of a range, with how faithful it is. */
|
|
64
|
+
interface MappedRange {
|
|
65
|
+
range: TextRange;
|
|
66
|
+
fidelity: SpanMapFidelity;
|
|
67
|
+
}
|
|
68
|
+
/** A directive controlling TypeScript diagnostics inside a mapped range. */
|
|
69
|
+
interface MappedDiagnosticDirective {
|
|
70
|
+
originalRange: TextRange;
|
|
71
|
+
virtualRange: TextRange;
|
|
72
|
+
policy: DiagnosticDirectivePolicy;
|
|
73
|
+
unusedCode: number;
|
|
74
|
+
}
|
|
75
|
+
/** Content mapper state attached to one source file. */
|
|
76
|
+
interface ContentMapping {
|
|
77
|
+
/** `name@version` identity of the mapper that produced the file. */
|
|
78
|
+
contentMapper: string;
|
|
79
|
+
/** Filename whose extension decided how the virtual text was parsed. */
|
|
80
|
+
virtualFileName: string;
|
|
81
|
+
/** Mapping between virtual and original positions, in UTF-16 code units. */
|
|
82
|
+
spanMap: SpanMapSegment[];
|
|
83
|
+
/** Directives that control diagnostics inside mapped ranges. */
|
|
84
|
+
diagnosticDirectives: MappedDiagnosticDirective[];
|
|
85
|
+
/** Compiler-assigned filenames of supplemental outputs for this file. */
|
|
86
|
+
supplementalSourceFileNames: string[];
|
|
87
|
+
/** Canonical file this output supplements, when it is a supplemental one. */
|
|
88
|
+
canonicalSourceFileName?: string;
|
|
89
|
+
}
|
|
90
|
+
/** Source-file fields decoded from a `getSourceFile` payload. */
|
|
91
|
+
interface EncodedSourceFile {
|
|
92
|
+
protocolVersion: number;
|
|
93
|
+
fileName: string;
|
|
94
|
+
path: string;
|
|
95
|
+
/** Text the checker parsed. For a mapped file this is the virtual text. */
|
|
96
|
+
text: string;
|
|
97
|
+
/** Text on disk. Equal to `text` for files no mapper touched. */
|
|
98
|
+
originalText: string;
|
|
99
|
+
languageVariant: number;
|
|
100
|
+
scriptKind: number;
|
|
101
|
+
/** Present only when a content mapper produced this file. */
|
|
102
|
+
contentMapping?: ContentMapping;
|
|
21
103
|
}
|
|
22
104
|
interface ProjectResponse {
|
|
23
105
|
id: string;
|
|
@@ -62,6 +144,15 @@ interface SymbolResponse {
|
|
|
62
144
|
declarations: string[];
|
|
63
145
|
valueDeclaration?: string;
|
|
64
146
|
}
|
|
147
|
+
interface CheckerBatchRequest<Params = unknown> {
|
|
148
|
+
method: string;
|
|
149
|
+
params?: Params;
|
|
150
|
+
}
|
|
151
|
+
interface CheckerBatchResponse<Result = unknown> {
|
|
152
|
+
method: string;
|
|
153
|
+
result?: Result;
|
|
154
|
+
error?: string;
|
|
155
|
+
}
|
|
65
156
|
interface OverlayUpdate {
|
|
66
157
|
document: DocumentIdentifier;
|
|
67
158
|
text: string;
|
|
@@ -197,5 +288,5 @@ interface VirtualDocumentState {
|
|
|
197
288
|
text: string;
|
|
198
289
|
}
|
|
199
290
|
//#endregion
|
|
200
|
-
export { ApiClientOptions, ApiMode, CapabilitiesResponse, ConfigResponse, DiagnosticsCapabilities, DocumentIdentifier, EditorCapabilities, FileChangeSummary, FileChanges, FileDiagnosticsResponse, InitializeResponse, LspCapabilities, NativeLintDiagnostic, NativeLintFix, NativeLintNode, NativeLintRange, NativeLintRuleMeta, NativeLintSuggestion, NativeNodeMetadataDepth, NativeRuleBridgeRequirements, OverlayCapabilities, OverlayChanges, OverlayUpdate, ProjectDiagnosticsResponse, ProjectResponse, RuntimeCapabilities, SnapshotDiagnosticsResponse, SymbolResponse, TypeResponse, TypeTextKind, UnsafeTypeFlowInput, UpdateSnapshotParams, UpdateSnapshotResponse, VirtualChange, VirtualDocumentState };
|
|
291
|
+
export { ApiClientOptions, ApiMode, CapabilitiesResponse, CheckerBatchRequest, CheckerBatchResponse, ConfigResponse, ContentMapperDefinition, ContentMapping, DiagnosticDirectivePolicy, DiagnosticsCapabilities, DocumentIdentifier, EditorCapabilities, EncodedSourceFile, FileChangeSummary, FileChanges, FileDiagnosticsResponse, InitializeResponse, LspCapabilities, MappedDiagnosticDirective, MappedPosition, MappedRange, NativeLintDiagnostic, NativeLintFix, NativeLintNode, NativeLintRange, NativeLintRuleMeta, NativeLintSuggestion, NativeNodeMetadataDepth, NativeRuleBridgeRequirements, OverlayCapabilities, OverlayChanges, OverlayUpdate, ProjectDiagnosticsResponse, ProjectResponse, RuntimeCapabilities, SnapshotDiagnosticsResponse, SpanMapFidelity, SpanMapKind, SpanMapSegment, SymbolResponse, TextRange, TypeResponse, TypeTextKind, UnsafeTypeFlowInput, UpdateSnapshotParams, UpdateSnapshotResponse, VirtualChange, VirtualDocumentState };
|
|
201
292
|
//# sourceMappingURL=types.d.mts.map
|