@esportsplus/typescript 0.32.0 → 0.33.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 +34 -49
- package/build/cli/tsc.d.ts +3 -2
- package/build/cli/tsc.js +15 -97
- package/build/{probe → guard}/adapter.d.ts +1 -2
- package/build/{probe → guard}/adapter.js +1 -4
- package/build/{probe → guard}/async/channel.d.ts +1 -1
- package/build/{probe → guard}/async/channel.js +11 -191
- package/build/{probe → guard}/async/value.d.ts +1 -2
- package/build/{probe → guard}/async/value.js +1 -4
- package/build/guard/channels.d.ts +4 -0
- package/build/guard/channels.js +13 -0
- package/build/{probe → guard}/exceptions/channel.d.ts +3 -2
- package/build/{probe → guard}/exceptions/channel.js +167 -107
- package/build/guard/exceptions/derive.d.ts +49 -0
- package/build/guard/exceptions/derive.js +478 -0
- package/build/guard/exceptions/resolve-js.d.ts +2 -0
- package/build/guard/exceptions/resolve-js.js +26 -0
- package/build/{probe → guard}/exceptions/value.d.ts +3 -2
- package/build/{probe → guard}/exceptions/value.js +12 -4
- package/build/{probe → guard}/kernel/analyze.d.ts +2 -1
- package/build/guard/kernel/analyze.js +84 -0
- package/build/guard/kernel/ast.d.ts +13 -0
- package/build/{probe → guard}/kernel/ast.js +22 -15
- package/build/guard/kernel/config.js +93 -0
- package/build/guard/kernel/fixpoint.d.ts +6 -0
- package/build/{probe → guard}/kernel/fixpoint.js +8 -48
- package/build/guard/kernel/graph.d.ts +4 -0
- package/build/guard/kernel/graph.js +268 -0
- package/build/{probe → guard}/kernel/ids.d.ts +2 -3
- package/build/{probe → guard}/kernel/ids.js +1 -6
- package/build/{probe → guard}/kernel/types.d.ts +3 -32
- package/build/{probe → guard}/overlay/base/async.jsonc +1 -1
- package/build/{probe → guard}/overlay/base/exceptions.jsonc +16 -3
- package/build/{probe → guard}/overlay/base/resources.jsonc +7 -8
- package/build/{probe → guard}/overlay/load.d.ts +3 -7
- package/build/{probe → guard}/overlay/load.js +37 -120
- package/build/{probe → guard}/resources/channel.d.ts +1 -1
- package/build/{probe → guard}/resources/channel.js +81 -159
- package/build/{probe → guard}/resources/value.d.ts +1 -2
- package/build/{probe → guard}/resources/value.js +1 -14
- package/build/lsp/diagnostics.d.ts +2 -2
- package/build/lsp/diagnostics.js +2 -2
- package/build/lsp/server.js +41 -3
- package/build/lsp/workspace.d.ts +6 -3
- package/build/lsp/workspace.js +19 -5
- package/build/tsconfig.d.ts +2 -1
- package/build/tsconfig.js +44 -102
- package/package.json +2 -2
- package/tsconfig.base.json +12 -19
- package/tsconfig.package.json +6 -1
- package/build/probe/channels.d.ts +0 -4
- package/build/probe/channels.js +0 -16
- package/build/probe/kernel/analyze.js +0 -68
- package/build/probe/kernel/ast.d.ts +0 -11
- package/build/probe/kernel/config.js +0 -209
- package/build/probe/kernel/fixpoint.d.ts +0 -6
- package/build/probe/kernel/graph.d.ts +0 -4
- package/build/probe/kernel/graph.js +0 -507
- package/build/probe/overlay/presets/express.jsonc +0 -25
- package/build/probe/overlay/presets/node.jsonc +0 -17
- /package/build/{probe → guard}/exceptions/jsdoc.d.ts +0 -0
- /package/build/{probe → guard}/exceptions/jsdoc.js +0 -0
- /package/build/{probe → guard}/kernel/config.d.ts +0 -0
- /package/build/{probe → guard}/kernel/format.d.ts +0 -0
- /package/build/{probe → guard}/kernel/format.js +0 -0
- /package/build/{probe → guard}/kernel/program.d.ts +0 -0
- /package/build/{probe → guard}/kernel/program.js +0 -0
- /package/build/{probe → guard}/kernel/types.js +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
// Base exceptions-channel overlay. Top-level keys are
|
|
2
|
-
//
|
|
1
|
+
// Base exceptions-channel overlay. Top-level keys are sections: `lib.*` (matched
|
|
2
|
+
// for symbols declared in that lib), `node:*` (matched for @types/node symbols),
|
|
3
|
+
// and `global` (searched last, for runtime globals present in both hosts). Each
|
|
4
|
+
// section maps an overlay key (see load.ts overlayKey) to an exceptions entry:
|
|
3
5
|
// { "exceptions": ["SyntaxError"] } - the error types the leaf may throw
|
|
4
6
|
// { "exceptionsFromCallbacks": [0] } - inherits whatever the arg at that index throws
|
|
5
7
|
// { "exceptions": [] } - modeled as non-throwing (so it is not logged)
|
|
@@ -46,7 +48,18 @@
|
|
|
46
48
|
"BigInt": { "exceptions": ["RangeError", "SyntaxError", "TypeError"] }
|
|
47
49
|
},
|
|
48
50
|
|
|
49
|
-
"
|
|
51
|
+
"node:fs": {
|
|
52
|
+
"readFileSync": { "exceptions": ["Error"] },
|
|
53
|
+
"writeFileSync": { "exceptions": ["Error"] },
|
|
54
|
+
"mkdirSync": { "exceptions": ["Error"] }
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
"node:path": {
|
|
58
|
+
"relative": { "exceptions": ["TypeError"] },
|
|
59
|
+
"resolve": { "exceptions": ["TypeError"] }
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
"global": {
|
|
50
63
|
"URL": { "exceptions": ["TypeError"] },
|
|
51
64
|
"URLSearchParams": { "exceptions": ["TypeError"] },
|
|
52
65
|
"structuredClone": { "exceptions": ["DataCloneError"] }
|
|
@@ -9,11 +9,16 @@
|
|
|
9
9
|
{
|
|
10
10
|
"overlay": {
|
|
11
11
|
"resources": {
|
|
12
|
-
"
|
|
12
|
+
"global": {
|
|
13
13
|
"setInterval": { "acquires": "Interval", "releasedBy": "clearInterval" },
|
|
14
14
|
"setTimeout": { "acquires": "Timeout", "releasedBy": "clearTimeout" },
|
|
15
15
|
|
|
16
16
|
"EventTarget#addEventListener": { "acquires": "Listener", "releasedBy": "removeEventListener", "pairKey": [0, 1] },
|
|
17
|
+
|
|
18
|
+
"AbortController": { "acquires": "AbortController", "informational": true }
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
"lib.dom": {
|
|
17
22
|
"Element#addEventListener": { "acquires": "Listener", "releasedBy": "removeEventListener", "pairKey": [0, 1] },
|
|
18
23
|
"HTMLElement#addEventListener": { "acquires": "Listener", "releasedBy": "removeEventListener", "pairKey": [0, 1] },
|
|
19
24
|
"Window#addEventListener": { "acquires": "Listener", "releasedBy": "removeEventListener", "pairKey": [0, 1] },
|
|
@@ -22,13 +27,7 @@
|
|
|
22
27
|
|
|
23
28
|
"ResizeObserver": { "acquires": "ResizeObserver", "releasedBy": "#disconnect" },
|
|
24
29
|
"MutationObserver": { "acquires": "MutationObserver", "releasedBy": "#disconnect" },
|
|
25
|
-
"WebSocket": { "acquires": "WebSocket", "releasedBy": "#close" }
|
|
26
|
-
"AbortController": { "acquires": "AbortController", "informational": true }
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
"node:timers": {
|
|
30
|
-
"setInterval": { "acquires": "Interval", "releasedBy": "clearInterval" },
|
|
31
|
-
"setTimeout": { "acquires": "Timeout", "releasedBy": "clearTimeout" }
|
|
30
|
+
"WebSocket": { "acquires": "WebSocket", "releasedBy": "#close" }
|
|
32
31
|
},
|
|
33
32
|
|
|
34
33
|
"node:fs/promises": {
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OverlaySet } from '../kernel/types.js';
|
|
2
2
|
type SectionTable = Map<string, unknown>;
|
|
3
3
|
type ChannelTable = Map<string, SectionTable>;
|
|
4
4
|
type MergedOverlay = {
|
|
5
5
|
readonly channels: ReadonlyMap<string, ChannelTable>;
|
|
6
|
-
readonly boundaries: ReadonlyArray<HandlerBoundary>;
|
|
7
6
|
entry(channel: string, section: string, key: string): unknown;
|
|
8
7
|
};
|
|
9
|
-
type LoadedOverlays = OverlaySet & {
|
|
10
|
-
boundariesFromPresets(): ReadonlyArray<HandlerBoundary>;
|
|
11
|
-
};
|
|
12
8
|
declare function mergeOverlayData(files: ReadonlyArray<{
|
|
13
9
|
name: string;
|
|
14
10
|
text: string;
|
|
15
11
|
}>): MergedOverlay;
|
|
16
12
|
declare function overlayKey(parentName: string | undefined, memberName: string, isNamespace: boolean): string;
|
|
17
|
-
declare function loadOverlays(
|
|
18
|
-
export { loadOverlays, mergeOverlayData, overlayKey, type
|
|
13
|
+
declare function loadOverlays(): OverlaySet;
|
|
14
|
+
export { loadOverlays, mergeOverlayData, overlayKey, type MergedOverlay };
|
|
@@ -12,55 +12,7 @@ const KNOWN_NAMESPACES = new Set([
|
|
|
12
12
|
'Console',
|
|
13
13
|
'console',
|
|
14
14
|
]);
|
|
15
|
-
|
|
16
|
-
let out = '';
|
|
17
|
-
let i = 0;
|
|
18
|
-
const n = text.length;
|
|
19
|
-
let inString = false;
|
|
20
|
-
let quote = '';
|
|
21
|
-
while (i < n) {
|
|
22
|
-
const ch = text[i];
|
|
23
|
-
const next = i + 1 < n ? text[i + 1] : '';
|
|
24
|
-
if (inString) {
|
|
25
|
-
out += ch;
|
|
26
|
-
if (ch === '\\') {
|
|
27
|
-
out += next;
|
|
28
|
-
i += 2;
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
if (ch === quote) {
|
|
32
|
-
inString = false;
|
|
33
|
-
}
|
|
34
|
-
i += 1;
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
if (ch === '"' || ch === "'") {
|
|
38
|
-
inString = true;
|
|
39
|
-
quote = ch;
|
|
40
|
-
out += ch;
|
|
41
|
-
i += 1;
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (ch === '/' && next === '/') {
|
|
45
|
-
while (i < n && text[i] !== '\n') {
|
|
46
|
-
i += 1;
|
|
47
|
-
}
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (ch === '/' && next === '*') {
|
|
51
|
-
i += 2;
|
|
52
|
-
while (i < n && !(text[i] === '*' && text[i + 1] === '/')) {
|
|
53
|
-
i += 1;
|
|
54
|
-
}
|
|
55
|
-
i += 2;
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
out += ch;
|
|
59
|
-
i += 1;
|
|
60
|
-
}
|
|
61
|
-
return out.replace(/,(\s*[}\]])/g, '$1');
|
|
62
|
-
}
|
|
63
|
-
void legacyStripJsonc;
|
|
15
|
+
const GLOBAL_SECTION = 'global';
|
|
64
16
|
function parseJsonc(name, text) {
|
|
65
17
|
let parsed;
|
|
66
18
|
try {
|
|
@@ -96,30 +48,6 @@ function mergeSections(into, sections) {
|
|
|
96
48
|
}
|
|
97
49
|
}
|
|
98
50
|
}
|
|
99
|
-
function readBoundaries(name, raw) {
|
|
100
|
-
if (raw === undefined) {
|
|
101
|
-
return [];
|
|
102
|
-
}
|
|
103
|
-
if (!Array.isArray(raw)) {
|
|
104
|
-
throw new Error(`analyze overlay: ${name} handlerBoundaries must be an array`);
|
|
105
|
-
}
|
|
106
|
-
return raw.map((item, index) => {
|
|
107
|
-
if (typeof item !== 'object' || item === null) {
|
|
108
|
-
throw new Error(`analyze overlay: ${name} handlerBoundaries[${index}] must be an object`);
|
|
109
|
-
}
|
|
110
|
-
const obj = item;
|
|
111
|
-
const callee = obj['callee'];
|
|
112
|
-
const callbackArgs = obj['callbackArgs'];
|
|
113
|
-
if (typeof callee !== 'string') {
|
|
114
|
-
throw new Error(`analyze overlay: ${name} handlerBoundaries[${index}].callee must be a string`);
|
|
115
|
-
}
|
|
116
|
-
if (!Array.isArray(callbackArgs) ||
|
|
117
|
-
callbackArgs.some((v) => typeof v !== 'number' || !Number.isInteger(v))) {
|
|
118
|
-
throw new Error(`analyze overlay: ${name} handlerBoundaries[${index}].callbackArgs must be an array of integers`);
|
|
119
|
-
}
|
|
120
|
-
return { callee, callbackArgs: callbackArgs };
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
51
|
function mergeOverlayData(files) {
|
|
124
52
|
return mergeParsedOverlayData(files.map((file) => ({
|
|
125
53
|
name: file.name,
|
|
@@ -128,7 +56,6 @@ function mergeOverlayData(files) {
|
|
|
128
56
|
}
|
|
129
57
|
function mergeParsedOverlayData(files) {
|
|
130
58
|
const channels = new Map();
|
|
131
|
-
const boundaries = [];
|
|
132
59
|
const channelFor = (channel) => {
|
|
133
60
|
let table = channels.get(channel);
|
|
134
61
|
if (!table) {
|
|
@@ -139,9 +66,7 @@ function mergeParsedOverlayData(files) {
|
|
|
139
66
|
};
|
|
140
67
|
for (const file of files) {
|
|
141
68
|
const root = file.root;
|
|
142
|
-
|
|
143
|
-
if (isBundle) {
|
|
144
|
-
boundaries.push(...readBoundaries(file.name, root['handlerBoundaries']));
|
|
69
|
+
if ('overlay' in root) {
|
|
145
70
|
const overlay = root['overlay'];
|
|
146
71
|
if (overlay !== undefined) {
|
|
147
72
|
if (!isSectionMap(overlay)) {
|
|
@@ -160,7 +85,6 @@ function mergeParsedOverlayData(files) {
|
|
|
160
85
|
}
|
|
161
86
|
return {
|
|
162
87
|
channels,
|
|
163
|
-
boundaries,
|
|
164
88
|
entry(channel, section, key) {
|
|
165
89
|
return channels.get(channel)?.get(section)?.get(key);
|
|
166
90
|
},
|
|
@@ -232,9 +156,16 @@ function findInSections(channel, key, accept, preferred) {
|
|
|
232
156
|
}
|
|
233
157
|
return undefined;
|
|
234
158
|
}
|
|
159
|
+
function findInGlobal(channel, key) {
|
|
160
|
+
const table = channel.get(GLOBAL_SECTION);
|
|
161
|
+
if (table && table.has(key)) {
|
|
162
|
+
return { pkg: GLOBAL_SECTION, symbol: key, entry: table.get(key) };
|
|
163
|
+
}
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
235
166
|
const HERE = NodePath.dirname(NodeURL.fileURLToPath(import.meta.url));
|
|
236
167
|
const shippedOverlayCache = new Map();
|
|
237
|
-
|
|
168
|
+
let mergedOverlayCache;
|
|
238
169
|
function readShippedOverlay(file) {
|
|
239
170
|
let cached = shippedOverlayCache.get(file);
|
|
240
171
|
if (!cached) {
|
|
@@ -246,56 +177,42 @@ function readShippedOverlay(file) {
|
|
|
246
177
|
}
|
|
247
178
|
return cached;
|
|
248
179
|
}
|
|
249
|
-
function
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
};
|
|
257
|
-
userOverlayCache.set(file, { mtimeMs, file: fresh });
|
|
258
|
-
return fresh;
|
|
259
|
-
}
|
|
260
|
-
return cached.file;
|
|
261
|
-
}
|
|
262
|
-
function loadOverlays(config) {
|
|
263
|
-
const files = [];
|
|
264
|
-
files.push(readShippedOverlay(NodePath.join(HERE, 'base', 'async.jsonc')));
|
|
265
|
-
files.push(readShippedOverlay(NodePath.join(HERE, 'base', 'exceptions.jsonc')));
|
|
266
|
-
files.push(readShippedOverlay(NodePath.join(HERE, 'base', 'resources.jsonc')));
|
|
267
|
-
for (const preset of config.presets) {
|
|
268
|
-
const presetPath = NodePath.join(HERE, 'presets', `${preset}.jsonc`);
|
|
269
|
-
if (!NodeFS.existsSync(presetPath)) {
|
|
270
|
-
throw new Error(`analyze overlay: unknown preset "${preset}" (no file at ${presetPath})`);
|
|
271
|
-
}
|
|
272
|
-
files.push(readShippedOverlay(presetPath));
|
|
180
|
+
function loadOverlays() {
|
|
181
|
+
if (!mergedOverlayCache) {
|
|
182
|
+
mergedOverlayCache = mergeParsedOverlayData([
|
|
183
|
+
readShippedOverlay(NodePath.join(HERE, 'base', 'async.jsonc')),
|
|
184
|
+
readShippedOverlay(NodePath.join(HERE, 'base', 'exceptions.jsonc')),
|
|
185
|
+
readShippedOverlay(NodePath.join(HERE, 'base', 'resources.jsonc')),
|
|
186
|
+
]);
|
|
273
187
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
throw new Error(`analyze overlay: overlay file not found: ${overlay}`);
|
|
277
|
-
}
|
|
278
|
-
files.push(readUserOverlay(overlay));
|
|
279
|
-
}
|
|
280
|
-
const merged = mergeParsedOverlayData(files);
|
|
188
|
+
const merged = mergedOverlayCache;
|
|
189
|
+
const lookupCache = new Map();
|
|
281
190
|
return {
|
|
282
|
-
boundariesFromPresets() {
|
|
283
|
-
return merged.boundaries;
|
|
284
|
-
},
|
|
285
191
|
lookup(symbol, channel) {
|
|
192
|
+
let channels = lookupCache.get(symbol);
|
|
193
|
+
if (channels?.has(channel)) {
|
|
194
|
+
return channels.get(channel);
|
|
195
|
+
}
|
|
286
196
|
const table = merged.channels.get(channel);
|
|
197
|
+
if (!channels) {
|
|
198
|
+
channels = new Map();
|
|
199
|
+
lookupCache.set(symbol, channels);
|
|
200
|
+
}
|
|
287
201
|
if (!table) {
|
|
202
|
+
channels.set(channel, undefined);
|
|
288
203
|
return undefined;
|
|
289
204
|
}
|
|
290
205
|
const key = keyFor(symbol);
|
|
291
206
|
const hint = sourceHint(symbol);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
207
|
+
const accept = hint.kind === 'lib'
|
|
208
|
+
? (s) => s.startsWith('lib.')
|
|
209
|
+
: hint.kind === 'node'
|
|
210
|
+
? (s) => s.startsWith('node:')
|
|
211
|
+
: (s) => s !== GLOBAL_SECTION && !s.startsWith('lib.');
|
|
212
|
+
const found = findInSections(table, key, accept, hint.section);
|
|
213
|
+
const result = found ?? findInGlobal(table, key);
|
|
214
|
+
channels.set(channel, result);
|
|
215
|
+
return result;
|
|
299
216
|
},
|
|
300
217
|
};
|
|
301
218
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Channel } from '../kernel/types.js';
|
|
2
2
|
import { type ResourcesValue } from './value.js';
|
|
3
|
-
declare const createResourcesChannel: (
|
|
3
|
+
declare const createResourcesChannel: (onDegrade?: (message: string) => void) => Channel<ResourcesValue>;
|
|
4
4
|
export { createResourcesChannel };
|