@types/node 24.7.2 → 24.8.0
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.
- node/README.md +1 -1
- node/crypto.d.ts +356 -25
- node/diagnostics_channel.d.ts +0 -2
- node/http2.d.ts +144 -26
- node/package.json +2 -2
- node/sea.d.ts +9 -0
- node/stream.d.ts +9 -1
- node/v8.d.ts +16 -0
- node/vm.d.ts +128 -38
- node/worker_threads.d.ts +39 -1
node/http2.d.ts
CHANGED
|
@@ -284,61 +284,111 @@ declare module "http2" {
|
|
|
284
284
|
addListener(event: "continue", listener: () => {}): this;
|
|
285
285
|
addListener(
|
|
286
286
|
event: "headers",
|
|
287
|
-
listener: (
|
|
287
|
+
listener: (
|
|
288
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
289
|
+
flags: number,
|
|
290
|
+
rawHeaders: string[],
|
|
291
|
+
) => void,
|
|
288
292
|
): this;
|
|
289
293
|
addListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
|
|
290
294
|
addListener(
|
|
291
295
|
event: "response",
|
|
292
|
-
listener: (
|
|
296
|
+
listener: (
|
|
297
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
298
|
+
flags: number,
|
|
299
|
+
rawHeaders: string[],
|
|
300
|
+
) => void,
|
|
293
301
|
): this;
|
|
294
302
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
295
303
|
emit(event: "continue"): boolean;
|
|
296
|
-
emit(
|
|
304
|
+
emit(
|
|
305
|
+
event: "headers",
|
|
306
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
307
|
+
flags: number,
|
|
308
|
+
rawHeaders: string[],
|
|
309
|
+
): boolean;
|
|
297
310
|
emit(event: "push", headers: IncomingHttpHeaders, flags: number): boolean;
|
|
298
|
-
emit(
|
|
311
|
+
emit(
|
|
312
|
+
event: "response",
|
|
313
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
314
|
+
flags: number,
|
|
315
|
+
rawHeaders: string[],
|
|
316
|
+
): boolean;
|
|
299
317
|
emit(event: string | symbol, ...args: any[]): boolean;
|
|
300
318
|
on(event: "continue", listener: () => {}): this;
|
|
301
319
|
on(
|
|
302
320
|
event: "headers",
|
|
303
|
-
listener: (
|
|
321
|
+
listener: (
|
|
322
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
323
|
+
flags: number,
|
|
324
|
+
rawHeaders: string[],
|
|
325
|
+
) => void,
|
|
304
326
|
): this;
|
|
305
327
|
on(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
|
|
306
328
|
on(
|
|
307
329
|
event: "response",
|
|
308
|
-
listener: (
|
|
330
|
+
listener: (
|
|
331
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
332
|
+
flags: number,
|
|
333
|
+
rawHeaders: string[],
|
|
334
|
+
) => void,
|
|
309
335
|
): this;
|
|
310
336
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
311
337
|
once(event: "continue", listener: () => {}): this;
|
|
312
338
|
once(
|
|
313
339
|
event: "headers",
|
|
314
|
-
listener: (
|
|
340
|
+
listener: (
|
|
341
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
342
|
+
flags: number,
|
|
343
|
+
rawHeaders: string[],
|
|
344
|
+
) => void,
|
|
315
345
|
): this;
|
|
316
346
|
once(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
|
|
317
347
|
once(
|
|
318
348
|
event: "response",
|
|
319
|
-
listener: (
|
|
349
|
+
listener: (
|
|
350
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
351
|
+
flags: number,
|
|
352
|
+
rawHeaders: string[],
|
|
353
|
+
) => void,
|
|
320
354
|
): this;
|
|
321
355
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
322
356
|
prependListener(event: "continue", listener: () => {}): this;
|
|
323
357
|
prependListener(
|
|
324
358
|
event: "headers",
|
|
325
|
-
listener: (
|
|
359
|
+
listener: (
|
|
360
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
361
|
+
flags: number,
|
|
362
|
+
rawHeaders: string[],
|
|
363
|
+
) => void,
|
|
326
364
|
): this;
|
|
327
365
|
prependListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
|
|
328
366
|
prependListener(
|
|
329
367
|
event: "response",
|
|
330
|
-
listener: (
|
|
368
|
+
listener: (
|
|
369
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
370
|
+
flags: number,
|
|
371
|
+
rawHeaders: string[],
|
|
372
|
+
) => void,
|
|
331
373
|
): this;
|
|
332
374
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
333
375
|
prependOnceListener(event: "continue", listener: () => {}): this;
|
|
334
376
|
prependOnceListener(
|
|
335
377
|
event: "headers",
|
|
336
|
-
listener: (
|
|
378
|
+
listener: (
|
|
379
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
380
|
+
flags: number,
|
|
381
|
+
rawHeaders: string[],
|
|
382
|
+
) => void,
|
|
337
383
|
): this;
|
|
338
384
|
prependOnceListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
|
|
339
385
|
prependOnceListener(
|
|
340
386
|
event: "response",
|
|
341
|
-
listener: (
|
|
387
|
+
listener: (
|
|
388
|
+
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
389
|
+
flags: number,
|
|
390
|
+
rawHeaders: string[],
|
|
391
|
+
) => void,
|
|
342
392
|
): this;
|
|
343
393
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
344
394
|
}
|
|
@@ -976,6 +1026,7 @@ declare module "http2" {
|
|
|
976
1026
|
stream: ClientHttp2Stream,
|
|
977
1027
|
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
978
1028
|
flags: number,
|
|
1029
|
+
rawHeaders: string[],
|
|
979
1030
|
) => void,
|
|
980
1031
|
): this;
|
|
981
1032
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
@@ -987,6 +1038,7 @@ declare module "http2" {
|
|
|
987
1038
|
stream: ClientHttp2Stream,
|
|
988
1039
|
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
989
1040
|
flags: number,
|
|
1041
|
+
rawHeaders: string[],
|
|
990
1042
|
): boolean;
|
|
991
1043
|
emit(event: string | symbol, ...args: any[]): boolean;
|
|
992
1044
|
on(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
|
|
@@ -998,6 +1050,7 @@ declare module "http2" {
|
|
|
998
1050
|
stream: ClientHttp2Stream,
|
|
999
1051
|
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
1000
1052
|
flags: number,
|
|
1053
|
+
rawHeaders: string[],
|
|
1001
1054
|
) => void,
|
|
1002
1055
|
): this;
|
|
1003
1056
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
@@ -1013,6 +1066,7 @@ declare module "http2" {
|
|
|
1013
1066
|
stream: ClientHttp2Stream,
|
|
1014
1067
|
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
1015
1068
|
flags: number,
|
|
1069
|
+
rawHeaders: string[],
|
|
1016
1070
|
) => void,
|
|
1017
1071
|
): this;
|
|
1018
1072
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
@@ -1028,6 +1082,7 @@ declare module "http2" {
|
|
|
1028
1082
|
stream: ClientHttp2Stream,
|
|
1029
1083
|
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
1030
1084
|
flags: number,
|
|
1085
|
+
rawHeaders: string[],
|
|
1031
1086
|
) => void,
|
|
1032
1087
|
): this;
|
|
1033
1088
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
@@ -1043,6 +1098,7 @@ declare module "http2" {
|
|
|
1043
1098
|
stream: ClientHttp2Stream,
|
|
1044
1099
|
headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
|
|
1045
1100
|
flags: number,
|
|
1101
|
+
rawHeaders: string[],
|
|
1046
1102
|
) => void,
|
|
1047
1103
|
): this;
|
|
1048
1104
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
@@ -1160,7 +1216,12 @@ declare module "http2" {
|
|
|
1160
1216
|
): this;
|
|
1161
1217
|
addListener(
|
|
1162
1218
|
event: "stream",
|
|
1163
|
-
listener: (
|
|
1219
|
+
listener: (
|
|
1220
|
+
stream: ServerHttp2Stream,
|
|
1221
|
+
headers: IncomingHttpHeaders,
|
|
1222
|
+
flags: number,
|
|
1223
|
+
rawHeaders: string[],
|
|
1224
|
+
) => void,
|
|
1164
1225
|
): this;
|
|
1165
1226
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1166
1227
|
emit(
|
|
@@ -1168,7 +1229,13 @@ declare module "http2" {
|
|
|
1168
1229
|
session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
|
|
1169
1230
|
socket: net.Socket | tls.TLSSocket,
|
|
1170
1231
|
): boolean;
|
|
1171
|
-
emit(
|
|
1232
|
+
emit(
|
|
1233
|
+
event: "stream",
|
|
1234
|
+
stream: ServerHttp2Stream,
|
|
1235
|
+
headers: IncomingHttpHeaders,
|
|
1236
|
+
flags: number,
|
|
1237
|
+
rawHeaders: string[],
|
|
1238
|
+
): boolean;
|
|
1172
1239
|
emit(event: string | symbol, ...args: any[]): boolean;
|
|
1173
1240
|
on(
|
|
1174
1241
|
event: "connect",
|
|
@@ -1179,7 +1246,12 @@ declare module "http2" {
|
|
|
1179
1246
|
): this;
|
|
1180
1247
|
on(
|
|
1181
1248
|
event: "stream",
|
|
1182
|
-
listener: (
|
|
1249
|
+
listener: (
|
|
1250
|
+
stream: ServerHttp2Stream,
|
|
1251
|
+
headers: IncomingHttpHeaders,
|
|
1252
|
+
flags: number,
|
|
1253
|
+
rawHeaders: string[],
|
|
1254
|
+
) => void,
|
|
1183
1255
|
): this;
|
|
1184
1256
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1185
1257
|
once(
|
|
@@ -1191,7 +1263,12 @@ declare module "http2" {
|
|
|
1191
1263
|
): this;
|
|
1192
1264
|
once(
|
|
1193
1265
|
event: "stream",
|
|
1194
|
-
listener: (
|
|
1266
|
+
listener: (
|
|
1267
|
+
stream: ServerHttp2Stream,
|
|
1268
|
+
headers: IncomingHttpHeaders,
|
|
1269
|
+
flags: number,
|
|
1270
|
+
rawHeaders: string[],
|
|
1271
|
+
) => void,
|
|
1195
1272
|
): this;
|
|
1196
1273
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1197
1274
|
prependListener(
|
|
@@ -1203,7 +1280,12 @@ declare module "http2" {
|
|
|
1203
1280
|
): this;
|
|
1204
1281
|
prependListener(
|
|
1205
1282
|
event: "stream",
|
|
1206
|
-
listener: (
|
|
1283
|
+
listener: (
|
|
1284
|
+
stream: ServerHttp2Stream,
|
|
1285
|
+
headers: IncomingHttpHeaders,
|
|
1286
|
+
flags: number,
|
|
1287
|
+
rawHeaders: string[],
|
|
1288
|
+
) => void,
|
|
1207
1289
|
): this;
|
|
1208
1290
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1209
1291
|
prependOnceListener(
|
|
@@ -1215,7 +1297,12 @@ declare module "http2" {
|
|
|
1215
1297
|
): this;
|
|
1216
1298
|
prependOnceListener(
|
|
1217
1299
|
event: "stream",
|
|
1218
|
-
listener: (
|
|
1300
|
+
listener: (
|
|
1301
|
+
stream: ServerHttp2Stream,
|
|
1302
|
+
headers: IncomingHttpHeaders,
|
|
1303
|
+
flags: number,
|
|
1304
|
+
rawHeaders: string[],
|
|
1305
|
+
) => void,
|
|
1219
1306
|
): this;
|
|
1220
1307
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1221
1308
|
}
|
|
@@ -1384,7 +1471,12 @@ declare module "http2" {
|
|
|
1384
1471
|
addListener(event: "sessionError", listener: (err: Error) => void): this;
|
|
1385
1472
|
addListener(
|
|
1386
1473
|
event: "stream",
|
|
1387
|
-
listener: (
|
|
1474
|
+
listener: (
|
|
1475
|
+
stream: ServerHttp2Stream,
|
|
1476
|
+
headers: IncomingHttpHeaders,
|
|
1477
|
+
flags: number,
|
|
1478
|
+
rawHeaders: string[],
|
|
1479
|
+
) => void,
|
|
1388
1480
|
): this;
|
|
1389
1481
|
addListener(event: "timeout", listener: () => void): this;
|
|
1390
1482
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
@@ -1399,7 +1491,13 @@ declare module "http2" {
|
|
|
1399
1491
|
session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
|
|
1400
1492
|
): boolean;
|
|
1401
1493
|
emit(event: "sessionError", err: Error): boolean;
|
|
1402
|
-
emit(
|
|
1494
|
+
emit(
|
|
1495
|
+
event: "stream",
|
|
1496
|
+
stream: ServerHttp2Stream,
|
|
1497
|
+
headers: IncomingHttpHeaders,
|
|
1498
|
+
flags: number,
|
|
1499
|
+
rawHeaders: string[],
|
|
1500
|
+
): boolean;
|
|
1403
1501
|
emit(event: "timeout"): boolean;
|
|
1404
1502
|
emit(event: string | symbol, ...args: any[]): boolean;
|
|
1405
1503
|
on(
|
|
@@ -1417,7 +1515,12 @@ declare module "http2" {
|
|
|
1417
1515
|
on(event: "sessionError", listener: (err: Error) => void): this;
|
|
1418
1516
|
on(
|
|
1419
1517
|
event: "stream",
|
|
1420
|
-
listener: (
|
|
1518
|
+
listener: (
|
|
1519
|
+
stream: ServerHttp2Stream,
|
|
1520
|
+
headers: IncomingHttpHeaders,
|
|
1521
|
+
flags: number,
|
|
1522
|
+
rawHeaders: string[],
|
|
1523
|
+
) => void,
|
|
1421
1524
|
): this;
|
|
1422
1525
|
on(event: "timeout", listener: () => void): this;
|
|
1423
1526
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
@@ -1436,7 +1539,12 @@ declare module "http2" {
|
|
|
1436
1539
|
once(event: "sessionError", listener: (err: Error) => void): this;
|
|
1437
1540
|
once(
|
|
1438
1541
|
event: "stream",
|
|
1439
|
-
listener: (
|
|
1542
|
+
listener: (
|
|
1543
|
+
stream: ServerHttp2Stream,
|
|
1544
|
+
headers: IncomingHttpHeaders,
|
|
1545
|
+
flags: number,
|
|
1546
|
+
rawHeaders: string[],
|
|
1547
|
+
) => void,
|
|
1440
1548
|
): this;
|
|
1441
1549
|
once(event: "timeout", listener: () => void): this;
|
|
1442
1550
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
@@ -1455,7 +1563,12 @@ declare module "http2" {
|
|
|
1455
1563
|
prependListener(event: "sessionError", listener: (err: Error) => void): this;
|
|
1456
1564
|
prependListener(
|
|
1457
1565
|
event: "stream",
|
|
1458
|
-
listener: (
|
|
1566
|
+
listener: (
|
|
1567
|
+
stream: ServerHttp2Stream,
|
|
1568
|
+
headers: IncomingHttpHeaders,
|
|
1569
|
+
flags: number,
|
|
1570
|
+
rawHeaders: string[],
|
|
1571
|
+
) => void,
|
|
1459
1572
|
): this;
|
|
1460
1573
|
prependListener(event: "timeout", listener: () => void): this;
|
|
1461
1574
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
@@ -1474,7 +1587,12 @@ declare module "http2" {
|
|
|
1474
1587
|
prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
|
|
1475
1588
|
prependOnceListener(
|
|
1476
1589
|
event: "stream",
|
|
1477
|
-
listener: (
|
|
1590
|
+
listener: (
|
|
1591
|
+
stream: ServerHttp2Stream,
|
|
1592
|
+
headers: IncomingHttpHeaders,
|
|
1593
|
+
flags: number,
|
|
1594
|
+
rawHeaders: string[],
|
|
1595
|
+
) => void,
|
|
1478
1596
|
): this;
|
|
1479
1597
|
prependOnceListener(event: "timeout", listener: () => void): this;
|
|
1480
1598
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
@@ -2195,8 +2313,8 @@ declare module "http2" {
|
|
|
2195
2313
|
* will result in a `TypeError` being thrown.
|
|
2196
2314
|
* @since v8.4.0
|
|
2197
2315
|
*/
|
|
2198
|
-
writeHead(statusCode: number, headers?: OutgoingHttpHeaders): this;
|
|
2199
|
-
writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders): this;
|
|
2316
|
+
writeHead(statusCode: number, headers?: OutgoingHttpHeaders | readonly string[]): this;
|
|
2317
|
+
writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders | readonly string[]): this;
|
|
2200
2318
|
/**
|
|
2201
2319
|
* Call `http2stream.pushStream()` with the given headers, and wrap the
|
|
2202
2320
|
* given `Http2Stream` on a newly created `Http2ServerResponse` as the callback
|
node/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.8.0",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -150,6 +150,6 @@
|
|
|
150
150
|
"undici-types": "~7.14.0"
|
|
151
151
|
},
|
|
152
152
|
"peerDependencies": {},
|
|
153
|
-
"typesPublisherContentHash": "
|
|
153
|
+
"typesPublisherContentHash": "bc6851a3467c10c05e3cd13590927c15bc180ff735647b20c43b43aa22890b3c",
|
|
154
154
|
"typeScriptVersion": "5.2"
|
|
155
155
|
}
|
node/sea.d.ts
CHANGED
|
@@ -150,4 +150,13 @@ declare module "node:sea" {
|
|
|
150
150
|
* @since v20.12.0
|
|
151
151
|
*/
|
|
152
152
|
function getRawAsset(key: AssetKey): ArrayBuffer;
|
|
153
|
+
/**
|
|
154
|
+
* This method can be used to retrieve an array of all the keys of assets
|
|
155
|
+
* embedded into the single-executable application.
|
|
156
|
+
* An error is thrown when not running inside a single-executable application.
|
|
157
|
+
* @since v24.8.0
|
|
158
|
+
* @returns An array containing all the keys of the assets
|
|
159
|
+
* embedded in the executable. If no assets are embedded, returns an empty array.
|
|
160
|
+
*/
|
|
161
|
+
function getAssetKeys(): string[];
|
|
153
162
|
}
|
node/stream.d.ts
CHANGED
|
@@ -1656,6 +1656,7 @@ declare module "stream" {
|
|
|
1656
1656
|
ref(): void;
|
|
1657
1657
|
unref(): void;
|
|
1658
1658
|
}
|
|
1659
|
+
// TODO: these should all take webstream arguments
|
|
1659
1660
|
/**
|
|
1660
1661
|
* Returns whether the stream has encountered an error.
|
|
1661
1662
|
* @since v17.3.0, v16.14.0
|
|
@@ -1664,8 +1665,15 @@ declare module "stream" {
|
|
|
1664
1665
|
/**
|
|
1665
1666
|
* Returns whether the stream is readable.
|
|
1666
1667
|
* @since v17.4.0, v16.14.0
|
|
1668
|
+
* @returns Only returns `null` if `stream` is not a valid `Readable`, `Duplex` or `ReadableStream`.
|
|
1667
1669
|
*/
|
|
1668
|
-
function isReadable(stream: Readable | NodeJS.ReadableStream): boolean;
|
|
1670
|
+
function isReadable(stream: Readable | NodeJS.ReadableStream): boolean | null;
|
|
1671
|
+
/**
|
|
1672
|
+
* Returns whether the stream is writable.
|
|
1673
|
+
* @since v20.0.0
|
|
1674
|
+
* @returns Only returns `null` if `stream` is not a valid `Writable`, `Duplex` or `WritableStream`.
|
|
1675
|
+
*/
|
|
1676
|
+
function isWritable(stream: Writable | NodeJS.WritableStream): boolean | null;
|
|
1669
1677
|
}
|
|
1670
1678
|
export = Stream;
|
|
1671
1679
|
}
|
node/v8.d.ts
CHANGED
|
@@ -400,6 +400,22 @@ declare module "v8" {
|
|
|
400
400
|
* @since v12.8.0
|
|
401
401
|
*/
|
|
402
402
|
function getHeapCodeStatistics(): HeapCodeStatistics;
|
|
403
|
+
/**
|
|
404
|
+
* @since v24.8.0
|
|
405
|
+
*/
|
|
406
|
+
interface CPUProfileHandle {
|
|
407
|
+
/**
|
|
408
|
+
* Stopping collecting the profile, then return a Promise that fulfills with an error or the
|
|
409
|
+
* profile data.
|
|
410
|
+
* @since v24.8.0
|
|
411
|
+
*/
|
|
412
|
+
stop(): Promise<string>;
|
|
413
|
+
/**
|
|
414
|
+
* Stopping collecting the profile and the profile will be discarded.
|
|
415
|
+
* @since v24.8.0
|
|
416
|
+
*/
|
|
417
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
418
|
+
}
|
|
403
419
|
/**
|
|
404
420
|
* V8 only supports `Latin-1/ISO-8859-1` and `UTF16` as the underlying representation of a string.
|
|
405
421
|
* If the `content` uses `Latin-1/ISO-8859-1` as the underlying representation, this function will return true;
|
node/vm.d.ts
CHANGED
|
@@ -676,14 +676,12 @@ declare module "vm" {
|
|
|
676
676
|
* flag enabled.
|
|
677
677
|
*
|
|
678
678
|
* The `vm.Module` class provides a low-level interface for using
|
|
679
|
-
* ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`
|
|
680
|
-
* defined in the ECMAScript
|
|
679
|
+
* ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`
|
|
680
|
+
* class that closely mirrors [Module Record](https://tc39.es/ecma262/#sec-abstract-module-records)s as defined in the ECMAScript
|
|
681
681
|
* specification.
|
|
682
682
|
*
|
|
683
683
|
* Unlike `vm.Script` however, every `vm.Module` object is bound to a context from
|
|
684
|
-
* its creation.
|
|
685
|
-
* in contrast with the synchronous nature of `vm.Script` objects. The use of
|
|
686
|
-
* 'async' functions can help with manipulating `vm.Module` objects.
|
|
684
|
+
* its creation.
|
|
687
685
|
*
|
|
688
686
|
* Using a `vm.Module` object requires three distinct steps: creation/parsing,
|
|
689
687
|
* linking, and evaluation. These three steps are illustrated in the following
|
|
@@ -711,7 +709,7 @@ declare module "vm" {
|
|
|
711
709
|
* // Here, we attempt to obtain the default export from the module "foo", and
|
|
712
710
|
* // put it into local binding "secret".
|
|
713
711
|
*
|
|
714
|
-
* const
|
|
712
|
+
* const rootModule = new vm.SourceTextModule(`
|
|
715
713
|
* import s from 'foo';
|
|
716
714
|
* s;
|
|
717
715
|
* print(s);
|
|
@@ -721,39 +719,48 @@ declare module "vm" {
|
|
|
721
719
|
* //
|
|
722
720
|
* // "Link" the imported dependencies of this Module to it.
|
|
723
721
|
* //
|
|
724
|
-
* //
|
|
725
|
-
* //
|
|
726
|
-
* // the imported module. The callback is expected to return a Module that
|
|
727
|
-
* // corresponds to the provided specifier, with certain requirements documented
|
|
728
|
-
* // in `module.link()`.
|
|
729
|
-
* //
|
|
730
|
-
* // If linking has not started for the returned Module, the same linker
|
|
731
|
-
* // callback will be called on the returned Module.
|
|
722
|
+
* // Obtain the requested dependencies of a SourceTextModule by
|
|
723
|
+
* // `sourceTextModule.moduleRequests` and resolve them.
|
|
732
724
|
* //
|
|
733
725
|
* // Even top-level Modules without dependencies must be explicitly linked. The
|
|
734
|
-
* //
|
|
735
|
-
* //
|
|
736
|
-
* // The link() method returns a Promise that will be resolved when all the
|
|
737
|
-
* // Promises returned by the linker resolve.
|
|
726
|
+
* // array passed to `sourceTextModule.linkRequests(modules)` can be
|
|
727
|
+
* // empty, however.
|
|
738
728
|
* //
|
|
739
|
-
* // Note: This is a contrived example in that the
|
|
740
|
-
* // "foo" module every time it is called. In a full-fledged
|
|
741
|
-
* // cache would probably be used to avoid duplicated modules.
|
|
729
|
+
* // Note: This is a contrived example in that the resolveAndLinkDependencies
|
|
730
|
+
* // creates a new "foo" module every time it is called. In a full-fledged
|
|
731
|
+
* // module system, a cache would probably be used to avoid duplicated modules.
|
|
732
|
+
*
|
|
733
|
+
* const moduleMap = new Map([
|
|
734
|
+
* ['root', rootModule],
|
|
735
|
+
* ]);
|
|
742
736
|
*
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
* `, { context: referencingModule.context });
|
|
737
|
+
* function resolveAndLinkDependencies(module) {
|
|
738
|
+
* const requestedModules = module.moduleRequests.map((request) => {
|
|
739
|
+
* // In a full-fledged module system, the resolveAndLinkDependencies would
|
|
740
|
+
* // resolve the module with the module cache key `[specifier, attributes]`.
|
|
741
|
+
* // In this example, we just use the specifier as the key.
|
|
742
|
+
* const specifier = request.specifier;
|
|
750
743
|
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
744
|
+
* let requestedModule = moduleMap.get(specifier);
|
|
745
|
+
* if (requestedModule === undefined) {
|
|
746
|
+
* requestedModule = new vm.SourceTextModule(`
|
|
747
|
+
* // The "secret" variable refers to the global variable we added to
|
|
748
|
+
* // "contextifiedObject" when creating the context.
|
|
749
|
+
* export default secret;
|
|
750
|
+
* `, { context: referencingModule.context });
|
|
751
|
+
* moduleMap.set(specifier, linkedModule);
|
|
752
|
+
* // Resolve the dependencies of the new module as well.
|
|
753
|
+
* resolveAndLinkDependencies(requestedModule);
|
|
754
|
+
* }
|
|
755
|
+
*
|
|
756
|
+
* return requestedModule;
|
|
757
|
+
* });
|
|
758
|
+
*
|
|
759
|
+
* module.linkRequests(requestedModules);
|
|
755
760
|
* }
|
|
756
|
-
*
|
|
761
|
+
*
|
|
762
|
+
* resolveAndLinkDependencies(rootModule);
|
|
763
|
+
* rootModule.instantiate();
|
|
757
764
|
*
|
|
758
765
|
* // Step 3
|
|
759
766
|
* //
|
|
@@ -761,7 +768,7 @@ declare module "vm" {
|
|
|
761
768
|
* // resolve after the module has finished evaluating.
|
|
762
769
|
*
|
|
763
770
|
* // Prints 42.
|
|
764
|
-
* await
|
|
771
|
+
* await rootModule.evaluate();
|
|
765
772
|
* ```
|
|
766
773
|
* @since v13.0.0, v12.16.0
|
|
767
774
|
* @experimental
|
|
@@ -831,6 +838,10 @@ declare module "vm" {
|
|
|
831
838
|
* Link module dependencies. This method must be called before evaluation, and
|
|
832
839
|
* can only be called once per module.
|
|
833
840
|
*
|
|
841
|
+
* Use `sourceTextModule.linkRequests(modules)` and
|
|
842
|
+
* `sourceTextModule.instantiate()` to link modules either synchronously or
|
|
843
|
+
* asynchronously.
|
|
844
|
+
*
|
|
834
845
|
* The function is expected to return a `Module` object or a `Promise` that
|
|
835
846
|
* eventually resolves to a `Module` object. The returned `Module` must satisfy the
|
|
836
847
|
* following two invariants:
|
|
@@ -911,6 +922,39 @@ declare module "vm" {
|
|
|
911
922
|
class SourceTextModule extends Module {
|
|
912
923
|
/**
|
|
913
924
|
* Creates a new `SourceTextModule` instance.
|
|
925
|
+
*
|
|
926
|
+
* Properties assigned to the `import.meta` object that are objects may
|
|
927
|
+
* allow the module to access information outside the specified `context`. Use
|
|
928
|
+
* `vm.runInContext()` to create objects in a specific context.
|
|
929
|
+
*
|
|
930
|
+
* ```js
|
|
931
|
+
* import vm from 'node:vm';
|
|
932
|
+
*
|
|
933
|
+
* const contextifiedObject = vm.createContext({ secret: 42 });
|
|
934
|
+
*
|
|
935
|
+
* const module = new vm.SourceTextModule(
|
|
936
|
+
* 'Object.getPrototypeOf(import.meta.prop).secret = secret;',
|
|
937
|
+
* {
|
|
938
|
+
* initializeImportMeta(meta) {
|
|
939
|
+
* // Note: this object is created in the top context. As such,
|
|
940
|
+
* // Object.getPrototypeOf(import.meta.prop) points to the
|
|
941
|
+
* // Object.prototype in the top context rather than that in
|
|
942
|
+
* // the contextified object.
|
|
943
|
+
* meta.prop = {};
|
|
944
|
+
* },
|
|
945
|
+
* });
|
|
946
|
+
* // The module has an empty `moduleRequests` array.
|
|
947
|
+
* module.linkRequests([]);
|
|
948
|
+
* module.instantiate();
|
|
949
|
+
* await module.evaluate();
|
|
950
|
+
*
|
|
951
|
+
* // Now, Object.prototype.secret will be equal to 42.
|
|
952
|
+
* //
|
|
953
|
+
* // To fix this problem, replace
|
|
954
|
+
* // meta.prop = {};
|
|
955
|
+
* // above with
|
|
956
|
+
* // meta.prop = vm.runInContext('{}', contextifiedObject);
|
|
957
|
+
* ```
|
|
914
958
|
* @param code JavaScript Module code to parse
|
|
915
959
|
*/
|
|
916
960
|
constructor(code: string, options?: SourceTextModuleOptions);
|
|
@@ -918,6 +962,55 @@ declare module "vm" {
|
|
|
918
962
|
* @deprecated Use `sourceTextModule.moduleRequests` instead.
|
|
919
963
|
*/
|
|
920
964
|
readonly dependencySpecifiers: readonly string[];
|
|
965
|
+
/**
|
|
966
|
+
* Instantiate the module with the linked requested modules.
|
|
967
|
+
*
|
|
968
|
+
* This resolves the imported bindings of the module, including re-exported
|
|
969
|
+
* binding names. When there are any bindings that cannot be resolved,
|
|
970
|
+
* an error would be thrown synchronously.
|
|
971
|
+
*
|
|
972
|
+
* If the requested modules include cyclic dependencies, the
|
|
973
|
+
* `sourceTextModule.linkRequests(modules)` method must be called on all
|
|
974
|
+
* modules in the cycle before calling this method.
|
|
975
|
+
* @since v24.8.0
|
|
976
|
+
*/
|
|
977
|
+
instantiate(): void;
|
|
978
|
+
/**
|
|
979
|
+
* Link module dependencies. This method must be called before evaluation, and
|
|
980
|
+
* can only be called once per module.
|
|
981
|
+
*
|
|
982
|
+
* The order of the module instances in the `modules` array should correspond to the order of
|
|
983
|
+
* `sourceTextModule.moduleRequests` being resolved. If two module requests have the same
|
|
984
|
+
* specifier and import attributes, they must be resolved with the same module instance or an
|
|
985
|
+
* `ERR_MODULE_LINK_MISMATCH` would be thrown. For example, when linking requests for this
|
|
986
|
+
* module:
|
|
987
|
+
*
|
|
988
|
+
* ```js
|
|
989
|
+
* import foo from 'foo';
|
|
990
|
+
* import source Foo from 'foo';
|
|
991
|
+
* ```
|
|
992
|
+
*
|
|
993
|
+
* The `modules` array must contain two references to the same instance, because the two
|
|
994
|
+
* module requests are identical but in two phases.
|
|
995
|
+
*
|
|
996
|
+
* If the module has no dependencies, the `modules` array can be empty.
|
|
997
|
+
*
|
|
998
|
+
* Users can use `sourceTextModule.moduleRequests` to implement the host-defined
|
|
999
|
+
* [HostLoadImportedModule](https://tc39.es/ecma262/#sec-HostLoadImportedModule) abstract operation in the ECMAScript specification,
|
|
1000
|
+
* and using `sourceTextModule.linkRequests()` to invoke specification defined
|
|
1001
|
+
* [FinishLoadingImportedModule](https://tc39.es/ecma262/#sec-FinishLoadingImportedModule), on the module with all dependencies in a batch.
|
|
1002
|
+
*
|
|
1003
|
+
* It's up to the creator of the `SourceTextModule` to determine if the resolution
|
|
1004
|
+
* of the dependencies is synchronous or asynchronous.
|
|
1005
|
+
*
|
|
1006
|
+
* After each module in the `modules` array is linked, call
|
|
1007
|
+
* `sourceTextModule.instantiate()`.
|
|
1008
|
+
* @since v24.8.0
|
|
1009
|
+
* @param modules Array of `vm.Module` objects that this module depends on.
|
|
1010
|
+
* The order of the modules in the array is the order of
|
|
1011
|
+
* `sourceTextModule.moduleRequests`.
|
|
1012
|
+
*/
|
|
1013
|
+
linkRequests(modules: readonly Module[]): void;
|
|
921
1014
|
/**
|
|
922
1015
|
* The requested import dependencies of this module. The returned array is frozen
|
|
923
1016
|
* to disallow any changes to it.
|
|
@@ -1013,9 +1106,7 @@ declare module "vm" {
|
|
|
1013
1106
|
options?: SyntheticModuleOptions,
|
|
1014
1107
|
);
|
|
1015
1108
|
/**
|
|
1016
|
-
* This method
|
|
1017
|
-
* it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error
|
|
1018
|
-
* will be thrown.
|
|
1109
|
+
* This method sets the module export binding slots with the given value.
|
|
1019
1110
|
*
|
|
1020
1111
|
* ```js
|
|
1021
1112
|
* import vm from 'node:vm';
|
|
@@ -1024,7 +1115,6 @@ declare module "vm" {
|
|
|
1024
1115
|
* m.setExport('x', 1);
|
|
1025
1116
|
* });
|
|
1026
1117
|
*
|
|
1027
|
-
* await m.link(() => {});
|
|
1028
1118
|
* await m.evaluate();
|
|
1029
1119
|
*
|
|
1030
1120
|
* assert.strictEqual(m.namespace.x, 1);
|