@types/node 22.15.21 → 22.19.3

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.
Files changed (80) hide show
  1. node v22.19/README.md +15 -0
  2. node v22.19/assert/strict.d.ts +111 -0
  3. node/assert.d.ts → node v22.19/assert.d.ts +119 -95
  4. node/buffer.buffer.d.ts → node v22.19/buffer.buffer.d.ts +9 -0
  5. node/buffer.d.ts → node v22.19/buffer.d.ts +14 -6
  6. node/child_process.d.ts → node v22.19/child_process.d.ts +89 -162
  7. node/cluster.d.ts → node v22.19/cluster.d.ts +4 -5
  8. node/compatibility/disposable.d.ts → node v22.19/compatibility/disposable.d.ts +0 -2
  9. node/compatibility/indexable.d.ts → node v22.19/compatibility/indexable.d.ts +0 -3
  10. node/compatibility/iterators.d.ts → node v22.19/compatibility/iterators.d.ts +0 -1
  11. node/crypto.d.ts → node v22.19/crypto.d.ts +203 -167
  12. node/dgram.d.ts → node v22.19/dgram.d.ts +9 -8
  13. node/diagnostics_channel.d.ts → node v22.19/diagnostics_channel.d.ts +17 -12
  14. node/dns/promises.d.ts → node v22.19/dns/promises.d.ts +36 -9
  15. node/dns.d.ts → node v22.19/dns.d.ts +79 -21
  16. node/events.d.ts → node v22.19/events.d.ts +80 -35
  17. node/fs/promises.d.ts → node v22.19/fs/promises.d.ts +81 -58
  18. node/fs.d.ts → node v22.19/fs.d.ts +154 -130
  19. node v22.19/globals.d.ts +172 -0
  20. node v22.19/globals.typedarray.d.ts +38 -0
  21. node/http.d.ts → node v22.19/http.d.ts +140 -35
  22. node/http2.d.ts → node v22.19/http2.d.ts +114 -27
  23. node/https.d.ts → node v22.19/https.d.ts +96 -62
  24. node/index.d.ts → node v22.19/index.d.ts +7 -2
  25. node v22.19/inspector.d.ts +253 -0
  26. node/inspector.d.ts → node v22.19/inspector.generated.d.ts +880 -830
  27. node/module.d.ts → node v22.19/module.d.ts +136 -17
  28. node/net.d.ts → node v22.19/net.d.ts +33 -11
  29. node/os.d.ts → node v22.19/os.d.ts +14 -3
  30. node/package.json → node v22.19/package.json +3 -83
  31. node/path.d.ts → node v22.19/path.d.ts +1 -1
  32. node/perf_hooks.d.ts → node v22.19/perf_hooks.d.ts +8 -10
  33. node/process.d.ts → node v22.19/process.d.ts +39 -27
  34. node/readline/promises.d.ts → node v22.19/readline/promises.d.ts +1 -2
  35. node/repl.d.ts → node v22.19/repl.d.ts +3 -5
  36. node/sqlite.d.ts → node v22.19/sqlite.d.ts +219 -6
  37. node/stream/consumers.d.ts → node v22.19/stream/consumers.d.ts +2 -2
  38. node/stream/web.d.ts → node v22.19/stream/web.d.ts +8 -0
  39. node/stream.d.ts → node v22.19/stream.d.ts +34 -32
  40. node/string_decoder.d.ts → node v22.19/string_decoder.d.ts +2 -2
  41. node v22.19/test.d.ts +2162 -0
  42. node/tls.d.ts → node v22.19/tls.d.ts +122 -66
  43. node/ts5.6/buffer.buffer.d.ts → node v22.19/ts5.6/buffer.buffer.d.ts +10 -2
  44. node v22.19/ts5.6/globals.typedarray.d.ts +34 -0
  45. node/ts5.6/index.d.ts → node v22.19/ts5.6/index.d.ts +7 -2
  46. node/url.d.ts → node v22.19/url.d.ts +21 -9
  47. node/util.d.ts → node v22.19/util.d.ts +33 -11
  48. node/v8.d.ts → node v22.19/v8.d.ts +66 -35
  49. node/vm.d.ts → node v22.19/vm.d.ts +65 -56
  50. node/wasi.d.ts → node v22.19/wasi.d.ts +1 -1
  51. node v22.19/web-globals/abortcontroller.d.ts +34 -0
  52. node v22.19/web-globals/domexception.d.ts +68 -0
  53. node v22.19/web-globals/events.d.ts +97 -0
  54. node v22.19/web-globals/fetch.d.ts +46 -0
  55. node v22.19/web-globals/navigator.d.ts +22 -0
  56. node v22.19/web-globals/storage.d.ts +24 -0
  57. node/worker_threads.d.ts → node v22.19/worker_threads.d.ts +112 -74
  58. node/zlib.d.ts → node v22.19/zlib.d.ts +39 -26
  59. node/README.md +0 -15
  60. node/assert/strict.d.ts +0 -8
  61. node/dom-events.d.ts +0 -124
  62. node/globals.d.ts +0 -371
  63. node/globals.typedarray.d.ts +0 -21
  64. node/test.d.ts +0 -2280
  65. node/ts5.6/globals.typedarray.d.ts +0 -19
  66. {node → node v22.19}/LICENSE +0 -0
  67. node/async_hooks.d.ts → node v22.19/async_hooks.d.ts +1 -1
  68. {node → node v22.19}/compatibility/index.d.ts +0 -0
  69. {node → node v22.19}/console.d.ts +0 -0
  70. {node → node v22.19}/constants.d.ts +0 -0
  71. {node → node v22.19}/domain.d.ts +0 -0
  72. {node → node v22.19}/punycode.d.ts +0 -0
  73. {node → node v22.19}/querystring.d.ts +0 -0
  74. {node → node v22.19}/readline.d.ts +0 -0
  75. {node → node v22.19}/sea.d.ts +0 -0
  76. {node → node v22.19}/stream/promises.d.ts +0 -0
  77. {node → node v22.19}/timers/promises.d.ts +0 -0
  78. {node → node v22.19}/timers.d.ts +0 -0
  79. {node → node v22.19}/trace_events.d.ts +0 -0
  80. {node → node v22.19}/tty.d.ts +0 -0
@@ -338,6 +338,11 @@ declare module "util" {
338
338
  * @since v9.7.0
339
339
  */
340
340
  export function getSystemErrorName(err: number): string;
341
+ /**
342
+ * Enable or disable printing a stack trace on `SIGINT`. The API is only available on the main thread.
343
+ * @since 22.19.0
344
+ */
345
+ export function setTraceSigInt(enable: boolean): void;
341
346
  /**
342
347
  * Returns a Map of all system error codes available from the Node.js API.
343
348
  * The mapping between error codes and error names is platform-dependent.
@@ -433,7 +438,6 @@ declare module "util" {
433
438
  * });
434
439
  * ```
435
440
  * @since v19.7.0
436
- * @experimental
437
441
  * @param resource Any non-null object tied to the abortable operation and held weakly.
438
442
  * If `resource` is garbage collected before the `signal` aborts, the promise remains pending,
439
443
  * allowing Node.js to stop tracking it.
@@ -445,8 +449,8 @@ declare module "util" {
445
449
  * intended for debugging. The output of `util.inspect` may change at any time
446
450
  * and should not be depended upon programmatically. Additional `options` may be
447
451
  * passed that alter the result.
448
- * `util.inspect()` will use the constructor's name and/or `@@toStringTag` to make
449
- * an identifiable tag for an inspected value.
452
+ * `util.inspect()` will use the constructor's name and/or `Symbol.toStringTag`
453
+ * property to make an identifiable tag for an inspected value.
450
454
  *
451
455
  * ```js
452
456
  * class Foo {
@@ -1411,7 +1415,7 @@ declare module "util" {
1411
1415
  * @param content The raw contents of a `.env` file.
1412
1416
  * @since v20.12.0
1413
1417
  */
1414
- export function parseEnv(content: string): object;
1418
+ export function parseEnv(content: string): NodeJS.Dict<string>;
1415
1419
  // https://nodejs.org/docs/latest/api/util.html#foreground-colors
1416
1420
  type ForegroundColors =
1417
1421
  | "black"
@@ -1462,6 +1466,7 @@ declare module "util" {
1462
1466
  | "hidden"
1463
1467
  | "inverse"
1464
1468
  | "italic"
1469
+ | "none"
1465
1470
  | "overlined"
1466
1471
  | "reset"
1467
1472
  | "strikethrough"
@@ -1481,7 +1486,7 @@ declare module "util" {
1481
1486
  /**
1482
1487
  * This function returns a formatted text considering the `format` passed
1483
1488
  * for printing in a terminal. It is aware of the terminal's capabilities
1484
- * and acts according to the configuration set via `NO_COLORS`,
1489
+ * and acts according to the configuration set via `NO_COLOR`,
1485
1490
  * `NODE_DISABLE_COLORS` and `FORCE_COLOR` environment variables.
1486
1491
  *
1487
1492
  * ```js
@@ -1518,6 +1523,8 @@ declare module "util" {
1518
1523
  * );
1519
1524
  * ```
1520
1525
  *
1526
+ * The special format value `none` applies no additional styling to the text.
1527
+ *
1521
1528
  * The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v22.x/api/util.html#modifiers).
1522
1529
  * @param format A text format or an Array of text formats defined in `util.inspect.colors`.
1523
1530
  * @param text The text to to be formatted.
@@ -1614,7 +1621,7 @@ declare module "util" {
1614
1621
  * encoded bytes.
1615
1622
  * @param [input='an empty string'] The text to encode.
1616
1623
  */
1617
- encode(input?: string): Uint8Array;
1624
+ encode(input?: string): NodeJS.NonSharedUint8Array;
1618
1625
  /**
1619
1626
  * UTF-8 encodes the `src` string to the `dest` Uint8Array and returns an object
1620
1627
  * containing the read Unicode code units and written UTF-8 bytes.
@@ -1707,10 +1714,12 @@ declare module "util" {
1707
1714
  */
1708
1715
  short?: string | undefined;
1709
1716
  /**
1710
- * The default value to
1711
- * be used if (and only if) the option does not appear in the arguments to be
1712
- * parsed. It must be of the same type as the `type` property. When `multiple`
1713
- * is `true`, it must be an array.
1717
+ * The value to assign to
1718
+ * the option if it does not appear in the arguments to be parsed. The value
1719
+ * must match the type specified by the `type` property. If `multiple` is
1720
+ * `true`, it must be an array. No default value is applied when the option
1721
+ * does appear in the arguments to be parsed, even if the provided value
1722
+ * is falsy.
1714
1723
  * @since v18.11.0
1715
1724
  */
1716
1725
  default?: string | boolean | string[] | boolean[] | undefined;
@@ -1722,7 +1731,7 @@ declare module "util" {
1722
1731
  /**
1723
1732
  * Array of argument strings.
1724
1733
  */
1725
- args?: string[] | undefined;
1734
+ args?: readonly string[] | undefined;
1726
1735
  /**
1727
1736
  * Used to describe arguments known to the parser.
1728
1737
  */
@@ -2226,6 +2235,19 @@ declare module "util/types" {
2226
2235
  * @since v10.0.0
2227
2236
  */
2228
2237
  function isExternal(object: unknown): boolean;
2238
+ /**
2239
+ * Returns `true` if the value is a built-in `Float16Array` instance.
2240
+ *
2241
+ * ```js
2242
+ * util.types.isFloat16Array(new ArrayBuffer()); // Returns false
2243
+ * util.types.isFloat16Array(new Float16Array()); // Returns true
2244
+ * util.types.isFloat16Array(new Float32Array()); // Returns false
2245
+ * ```
2246
+ * @since v22.16.0
2247
+ */
2248
+ // This does NOT return a type predicate in v22.x.
2249
+ // The Float16Array feature does not yet exist in this version of Node.js.
2250
+ function isFloat16Array(object: unknown): boolean;
2229
2251
  /**
2230
2252
  * Returns `true` if the value is a built-in [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) instance.
2231
2253
  *
@@ -7,6 +7,7 @@
7
7
  * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/v8.js)
8
8
  */
9
9
  declare module "v8" {
10
+ import { NonSharedBuffer } from "node:buffer";
10
11
  import { Readable } from "node:stream";
11
12
  interface HeapSpaceInfo {
12
13
  space_name: string;
@@ -43,12 +44,12 @@ declare module "v8" {
43
44
  * If true, expose internals in the heap snapshot.
44
45
  * @default false
45
46
  */
46
- exposeInternals?: boolean;
47
+ exposeInternals?: boolean | undefined;
47
48
  /**
48
49
  * If true, expose numeric values in artificial fields.
49
50
  * @default false
50
51
  */
51
- exposeNumericValues?: boolean;
52
+ exposeNumericValues?: boolean | undefined;
52
53
  }
53
54
  /**
54
55
  * Returns an integer representing a version tag derived from the V8 version,
@@ -400,6 +401,39 @@ declare module "v8" {
400
401
  * @since v12.8.0
401
402
  */
402
403
  function getHeapCodeStatistics(): HeapCodeStatistics;
404
+ /**
405
+ * V8 only supports `Latin-1/ISO-8859-1` and `UTF16` as the underlying representation of a string.
406
+ * If the `content` uses `Latin-1/ISO-8859-1` as the underlying representation, this function will return true;
407
+ * otherwise, it returns false.
408
+ *
409
+ * If this method returns false, that does not mean that the string contains some characters not in `Latin-1/ISO-8859-1`.
410
+ * Sometimes a `Latin-1` string may also be represented as `UTF16`.
411
+ *
412
+ * ```js
413
+ * const { isStringOneByteRepresentation } = require('node:v8');
414
+ *
415
+ * const Encoding = {
416
+ * latin1: 1,
417
+ * utf16le: 2,
418
+ * };
419
+ * const buffer = Buffer.alloc(100);
420
+ * function writeString(input) {
421
+ * if (isStringOneByteRepresentation(input)) {
422
+ * buffer.writeUint8(Encoding.latin1);
423
+ * buffer.writeUint32LE(input.length, 1);
424
+ * buffer.write(input, 5, 'latin1');
425
+ * } else {
426
+ * buffer.writeUint8(Encoding.utf16le);
427
+ * buffer.writeUint32LE(input.length * 2, 1);
428
+ * buffer.write(input, 5, 'utf16le');
429
+ * }
430
+ * }
431
+ * writeString('hello');
432
+ * writeString('你好');
433
+ * ```
434
+ * @since v22.15.0
435
+ */
436
+ function isStringOneByteRepresentation(content: string): boolean;
403
437
  /**
404
438
  * @since v8.0.0
405
439
  */
@@ -420,7 +454,7 @@ declare module "v8" {
420
454
  * the buffer is released. Calling this method results in undefined behavior
421
455
  * if a previous write has failed.
422
456
  */
423
- releaseBuffer(): Buffer;
457
+ releaseBuffer(): NonSharedBuffer;
424
458
  /**
425
459
  * Marks an `ArrayBuffer` as having its contents transferred out of band.
426
460
  * Pass the corresponding `ArrayBuffer` in the deserializing context to `deserializer.transferArrayBuffer()`.
@@ -448,7 +482,7 @@ declare module "v8" {
448
482
  * will require a way to compute the length of the buffer.
449
483
  * For use inside of a custom `serializer._writeHostObject()`.
450
484
  */
451
- writeRawBytes(buffer: NodeJS.TypedArray): void;
485
+ writeRawBytes(buffer: NodeJS.ArrayBufferView): void;
452
486
  }
453
487
  /**
454
488
  * A subclass of `Serializer` that serializes `TypedArray`(in particular `Buffer`) and `DataView` objects as host objects, and only
@@ -519,7 +553,7 @@ declare module "v8" {
519
553
  * larger than `buffer.constants.MAX_LENGTH`.
520
554
  * @since v8.0.0
521
555
  */
522
- function serialize(value: any): Buffer;
556
+ function serialize(value: any): NonSharedBuffer;
523
557
  /**
524
558
  * Uses a `DefaultDeserializer` with default options to read a JS value
525
559
  * from a buffer.
@@ -548,7 +582,6 @@ declare module "v8" {
548
582
  /**
549
583
  * The API is a no-op if `--heapsnapshot-near-heap-limit` is already set from the command line or the API is called more than once.
550
584
  * `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
551
- * @experimental
552
585
  * @since v18.10.0, v16.18.0
553
586
  */
554
587
  function setHeapSnapshotNearHeapLimit(limit: number): void;
@@ -774,33 +807,6 @@ declare module "v8" {
774
807
  */
775
808
  const promiseHooks: PromiseHooks;
776
809
  type StartupSnapshotCallbackFn = (args: any) => any;
777
- interface StartupSnapshot {
778
- /**
779
- * Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
780
- * This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
781
- * @since v18.6.0, v16.17.0
782
- */
783
- addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
784
- /**
785
- * Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
786
- * The `callback` and the `data` (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
787
- * to re-acquire resources that the application needs when the application is restarted from the snapshot.
788
- * @since v18.6.0, v16.17.0
789
- */
790
- addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
791
- /**
792
- * This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script.
793
- * If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized
794
- * data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
795
- * @since v18.6.0, v16.17.0
796
- */
797
- setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
798
- /**
799
- * Returns true if the Node.js instance is run to build a snapshot.
800
- * @since v18.6.0, v16.17.0
801
- */
802
- isBuildingSnapshot(): boolean;
803
- }
804
810
  /**
805
811
  * The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
806
812
  *
@@ -879,10 +885,35 @@ declare module "v8" {
879
885
  *
880
886
  * Currently the application deserialized from a user-land snapshot cannot be snapshotted again, so these APIs are only available to applications that are not deserialized from a user-land snapshot.
881
887
  *
882
- * @experimental
883
888
  * @since v18.6.0, v16.17.0
884
889
  */
885
- const startupSnapshot: StartupSnapshot;
890
+ namespace startupSnapshot {
891
+ /**
892
+ * Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
893
+ * This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
894
+ * @since v18.6.0, v16.17.0
895
+ */
896
+ function addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
897
+ /**
898
+ * Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
899
+ * The `callback` and the `data` (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
900
+ * to re-acquire resources that the application needs when the application is restarted from the snapshot.
901
+ * @since v18.6.0, v16.17.0
902
+ */
903
+ function addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
904
+ /**
905
+ * This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script.
906
+ * If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized
907
+ * data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
908
+ * @since v18.6.0, v16.17.0
909
+ */
910
+ function setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
911
+ /**
912
+ * Returns true if the Node.js instance is run to build a snapshot.
913
+ * @since v18.6.0, v16.17.0
914
+ */
915
+ function isBuildingSnapshot(): boolean;
916
+ }
886
917
  }
887
918
  declare module "node:v8" {
888
919
  export * from "v8";
@@ -37,6 +37,7 @@
37
37
  * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/vm.js)
38
38
  */
39
39
  declare module "vm" {
40
+ import { NonSharedBuffer } from "node:buffer";
40
41
  import { ImportAttributes } from "node:module";
41
42
  interface Context extends NodeJS.Dict<any> {}
42
43
  interface BaseOptions {
@@ -56,11 +57,16 @@ declare module "vm" {
56
57
  */
57
58
  columnOffset?: number | undefined;
58
59
  }
60
+ type DynamicModuleLoader<T> = (
61
+ specifier: string,
62
+ referrer: T,
63
+ importAttributes: ImportAttributes,
64
+ ) => Module | Promise<Module>;
59
65
  interface ScriptOptions extends BaseOptions {
60
66
  /**
61
67
  * Provides an optional data with V8's code cache data for the supplied source.
62
68
  */
63
- cachedData?: Buffer | NodeJS.ArrayBufferView | undefined;
69
+ cachedData?: NodeJS.ArrayBufferView | undefined;
64
70
  /** @deprecated in favor of `script.createCachedData()` */
65
71
  produceCachedData?: boolean | undefined;
66
72
  /**
@@ -69,7 +75,7 @@ declare module "vm" {
69
75
  * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
70
76
  */
71
77
  importModuleDynamically?:
72
- | ((specifier: string, script: Script, importAttributes: ImportAttributes) => Module | Promise<Module>)
78
+ | DynamicModuleLoader<Script>
73
79
  | typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
74
80
  | undefined;
75
81
  }
@@ -92,47 +98,46 @@ declare module "vm" {
92
98
  */
93
99
  breakOnSigint?: boolean | undefined;
94
100
  }
95
- interface RunningScriptInNewContextOptions extends RunningScriptOptions {
101
+ interface RunningScriptInNewContextOptions
102
+ extends RunningScriptOptions, Pick<CreateContextOptions, "microtaskMode">
103
+ {
96
104
  /**
97
105
  * Human-readable name of the newly created context.
98
106
  */
99
- contextName?: CreateContextOptions["name"];
107
+ contextName?: CreateContextOptions["name"] | undefined;
100
108
  /**
101
109
  * Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL,
102
110
  * but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object.
103
111
  * Most notably, this string should omit the trailing slash, as that denotes a path.
104
112
  */
105
- contextOrigin?: CreateContextOptions["origin"];
106
- contextCodeGeneration?: CreateContextOptions["codeGeneration"];
107
- /**
108
- * If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
109
- */
110
- microtaskMode?: CreateContextOptions["microtaskMode"];
113
+ contextOrigin?: CreateContextOptions["origin"] | undefined;
114
+ contextCodeGeneration?: CreateContextOptions["codeGeneration"] | undefined;
111
115
  }
112
- interface RunningCodeOptions extends RunningScriptOptions {
116
+ interface RunningCodeOptions extends RunningScriptOptions, Pick<ScriptOptions, "cachedData"> {
113
117
  /**
114
- * Provides an optional data with V8's code cache data for the supplied source.
118
+ * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
119
+ * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
120
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
115
121
  */
116
- cachedData?: ScriptOptions["cachedData"] | undefined;
117
- importModuleDynamically?: ScriptOptions["importModuleDynamically"];
122
+ importModuleDynamically?:
123
+ | DynamicModuleLoader<Script>
124
+ | typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
125
+ | undefined;
118
126
  }
119
- interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions {
127
+ interface RunningCodeInNewContextOptions
128
+ extends RunningScriptInNewContextOptions, Pick<ScriptOptions, "cachedData">
129
+ {
120
130
  /**
121
- * Provides an optional data with V8's code cache data for the supplied source.
131
+ * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
132
+ * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
133
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
122
134
  */
123
- cachedData?: ScriptOptions["cachedData"] | undefined;
124
- importModuleDynamically?: ScriptOptions["importModuleDynamically"];
135
+ importModuleDynamically?:
136
+ | DynamicModuleLoader<Script>
137
+ | typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
138
+ | undefined;
125
139
  }
126
- interface CompileFunctionOptions extends BaseOptions {
127
- /**
128
- * Provides an optional data with V8's code cache data for the supplied source.
129
- */
130
- cachedData?: ScriptOptions["cachedData"] | undefined;
131
- /**
132
- * Specifies whether to produce new cache data.
133
- * @default false
134
- */
135
- produceCachedData?: boolean | undefined;
140
+ interface CompileFunctionOptions extends BaseOptions, Pick<ScriptOptions, "cachedData" | "produceCachedData"> {
136
141
  /**
137
142
  * The sandbox/context in which the said function should be compiled in.
138
143
  */
@@ -141,6 +146,15 @@ declare module "vm" {
141
146
  * An array containing a collection of context extensions (objects wrapping the current scope) to be applied while compiling
142
147
  */
143
148
  contextExtensions?: Object[] | undefined;
149
+ /**
150
+ * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
151
+ * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
152
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
153
+ */
154
+ importModuleDynamically?:
155
+ | DynamicModuleLoader<ReturnType<typeof compileFunction>>
156
+ | typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
157
+ | undefined;
144
158
  }
145
159
  interface CreateContextOptions {
146
160
  /**
@@ -175,6 +189,15 @@ declare module "vm" {
175
189
  * If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
176
190
  */
177
191
  microtaskMode?: "afterEvaluate" | undefined;
192
+ /**
193
+ * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
194
+ * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
195
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
196
+ */
197
+ importModuleDynamically?:
198
+ | DynamicModuleLoader<Context>
199
+ | typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
200
+ | undefined;
178
201
  }
179
202
  type MeasureMemoryMode = "summary" | "detailed";
180
203
  interface MeasureMemoryOptions {
@@ -339,17 +362,17 @@ declare module "vm" {
339
362
  * ```
340
363
  * @since v10.6.0
341
364
  */
342
- createCachedData(): Buffer;
365
+ createCachedData(): NonSharedBuffer;
343
366
  /** @deprecated in favor of `script.createCachedData()` */
344
- cachedDataProduced?: boolean | undefined;
367
+ cachedDataProduced?: boolean;
345
368
  /**
346
369
  * When `cachedData` is supplied to create the `vm.Script`, this value will be set
347
370
  * to either `true` or `false` depending on acceptance of the data by V8.
348
371
  * Otherwise the value is `undefined`.
349
372
  * @since v5.7.0
350
373
  */
351
- cachedDataRejected?: boolean | undefined;
352
- cachedData?: Buffer | undefined;
374
+ cachedDataRejected?: boolean;
375
+ cachedData?: NonSharedBuffer;
353
376
  /**
354
377
  * When the script is compiled from a source that contains a source map magic
355
378
  * comment, this property will be set to the URL of the source map.
@@ -367,7 +390,7 @@ declare module "vm" {
367
390
  * ```
368
391
  * @since v19.1.0, v18.13.0
369
392
  */
370
- sourceMapURL?: string | undefined;
393
+ sourceMapURL: string | undefined;
371
394
  }
372
395
  /**
373
396
  * If the given `contextObject` is an object, the `vm.createContext()` method will
@@ -577,11 +600,7 @@ declare module "vm" {
577
600
  code: string,
578
601
  params?: readonly string[],
579
602
  options?: CompileFunctionOptions,
580
- ): Function & {
581
- cachedData?: Script["cachedData"] | undefined;
582
- cachedDataProduced?: Script["cachedDataProduced"] | undefined;
583
- cachedDataRejected?: Script["cachedDataRejected"] | undefined;
584
- };
603
+ ): Function & Pick<Script, "cachedData" | "cachedDataProduced" | "cachedDataRejected">;
585
604
  /**
586
605
  * Measure the memory known to V8 and used by all contexts known to the
587
606
  * current V8 isolate, or the main context.
@@ -638,10 +657,7 @@ declare module "vm" {
638
657
  * @experimental
639
658
  */
640
659
  function measureMemory(options?: MeasureMemoryOptions): Promise<MemoryMeasurement>;
641
- interface ModuleEvaluateOptions {
642
- timeout?: RunningScriptOptions["timeout"] | undefined;
643
- breakOnSigint?: RunningScriptOptions["breakOnSigint"] | undefined;
644
- }
660
+ interface ModuleEvaluateOptions extends Pick<RunningScriptOptions, "breakOnSigint" | "timeout"> {}
645
661
  type ModuleLinker = (
646
662
  specifier: string,
647
663
  referencingModule: Module,
@@ -848,30 +864,23 @@ declare module "vm" {
848
864
  */
849
865
  link(linker: ModuleLinker): Promise<void>;
850
866
  }
851
- interface SourceTextModuleOptions {
867
+ interface SourceTextModuleOptions extends Pick<ScriptOptions, "cachedData" | "columnOffset" | "lineOffset"> {
852
868
  /**
853
869
  * String used in stack traces.
854
870
  * @default 'vm:module(i)' where i is a context-specific ascending index.
855
871
  */
856
872
  identifier?: string | undefined;
857
- /**
858
- * Provides an optional data with V8's code cache data for the supplied source.
859
- */
860
- cachedData?: ScriptOptions["cachedData"] | undefined;
861
873
  context?: Context | undefined;
862
- lineOffset?: BaseOptions["lineOffset"] | undefined;
863
- columnOffset?: BaseOptions["columnOffset"] | undefined;
864
874
  /**
865
875
  * Called during evaluation of this module to initialize the `import.meta`.
866
876
  */
867
877
  initializeImportMeta?: ((meta: ImportMeta, module: SourceTextModule) => void) | undefined;
868
- importModuleDynamically?:
869
- | ((
870
- specifier: string,
871
- referrer: SourceTextModule,
872
- importAttributes: ImportAttributes,
873
- ) => Module | Promise<Module>)
874
- | undefined;
878
+ /**
879
+ * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
880
+ * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
881
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
882
+ */
883
+ importModuleDynamically?: DynamicModuleLoader<SourceTextModule> | undefined;
875
884
  }
876
885
  /**
877
886
  * This feature is only available with the `--experimental-vm-modules` command
@@ -77,7 +77,7 @@ declare module "wasi" {
77
77
  * WASI command itself.
78
78
  * @default []
79
79
  */
80
- args?: string[] | undefined;
80
+ args?: readonly string[] | undefined;
81
81
  /**
82
82
  * An object similar to `process.env` that the WebAssembly
83
83
  * application will see as its environment.
@@ -0,0 +1,34 @@
1
+ export {};
2
+
3
+ type _AbortController = typeof globalThis extends { onmessage: any } ? {} : AbortController;
4
+ interface AbortController {
5
+ readonly signal: AbortSignal;
6
+ abort(reason?: any): void;
7
+ }
8
+
9
+ type _AbortSignal = typeof globalThis extends { onmessage: any } ? {} : AbortSignal;
10
+ interface AbortSignal extends EventTarget {
11
+ readonly aborted: boolean;
12
+ onabort: ((this: AbortSignal, ev: Event) => any) | null;
13
+ readonly reason: any;
14
+ throwIfAborted(): void;
15
+ }
16
+
17
+ declare global {
18
+ interface AbortController extends _AbortController {}
19
+ var AbortController: typeof globalThis extends { onmessage: any; AbortController: infer T } ? T
20
+ : {
21
+ prototype: AbortController;
22
+ new(): AbortController;
23
+ };
24
+
25
+ interface AbortSignal extends _AbortSignal {}
26
+ var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal: infer T } ? T
27
+ : {
28
+ prototype: AbortSignal;
29
+ new(): AbortSignal;
30
+ abort(reason?: any): AbortSignal;
31
+ any(signals: AbortSignal[]): AbortSignal;
32
+ timeout(milliseconds: number): AbortSignal;
33
+ };
34
+ }
@@ -0,0 +1,68 @@
1
+ export {};
2
+
3
+ type _DOMException = typeof globalThis extends { onmessage: any } ? {} : DOMException;
4
+ interface DOMException extends Error {
5
+ readonly code: number;
6
+ readonly message: string;
7
+ readonly name: string;
8
+ readonly INDEX_SIZE_ERR: 1;
9
+ readonly DOMSTRING_SIZE_ERR: 2;
10
+ readonly HIERARCHY_REQUEST_ERR: 3;
11
+ readonly WRONG_DOCUMENT_ERR: 4;
12
+ readonly INVALID_CHARACTER_ERR: 5;
13
+ readonly NO_DATA_ALLOWED_ERR: 6;
14
+ readonly NO_MODIFICATION_ALLOWED_ERR: 7;
15
+ readonly NOT_FOUND_ERR: 8;
16
+ readonly NOT_SUPPORTED_ERR: 9;
17
+ readonly INUSE_ATTRIBUTE_ERR: 10;
18
+ readonly INVALID_STATE_ERR: 11;
19
+ readonly SYNTAX_ERR: 12;
20
+ readonly INVALID_MODIFICATION_ERR: 13;
21
+ readonly NAMESPACE_ERR: 14;
22
+ readonly INVALID_ACCESS_ERR: 15;
23
+ readonly VALIDATION_ERR: 16;
24
+ readonly TYPE_MISMATCH_ERR: 17;
25
+ readonly SECURITY_ERR: 18;
26
+ readonly NETWORK_ERR: 19;
27
+ readonly ABORT_ERR: 20;
28
+ readonly URL_MISMATCH_ERR: 21;
29
+ readonly QUOTA_EXCEEDED_ERR: 22;
30
+ readonly TIMEOUT_ERR: 23;
31
+ readonly INVALID_NODE_TYPE_ERR: 24;
32
+ readonly DATA_CLONE_ERR: 25;
33
+ }
34
+
35
+ declare global {
36
+ interface DOMException extends _DOMException {}
37
+ var DOMException: typeof globalThis extends { onmessage: any; DOMException: infer T } ? T
38
+ : {
39
+ prototype: DOMException;
40
+ new(message?: string, name?: string): DOMException;
41
+ new(message?: string, options?: { name?: string; cause?: unknown }): DOMException;
42
+ readonly INDEX_SIZE_ERR: 1;
43
+ readonly DOMSTRING_SIZE_ERR: 2;
44
+ readonly HIERARCHY_REQUEST_ERR: 3;
45
+ readonly WRONG_DOCUMENT_ERR: 4;
46
+ readonly INVALID_CHARACTER_ERR: 5;
47
+ readonly NO_DATA_ALLOWED_ERR: 6;
48
+ readonly NO_MODIFICATION_ALLOWED_ERR: 7;
49
+ readonly NOT_FOUND_ERR: 8;
50
+ readonly NOT_SUPPORTED_ERR: 9;
51
+ readonly INUSE_ATTRIBUTE_ERR: 10;
52
+ readonly INVALID_STATE_ERR: 11;
53
+ readonly SYNTAX_ERR: 12;
54
+ readonly INVALID_MODIFICATION_ERR: 13;
55
+ readonly NAMESPACE_ERR: 14;
56
+ readonly INVALID_ACCESS_ERR: 15;
57
+ readonly VALIDATION_ERR: 16;
58
+ readonly TYPE_MISMATCH_ERR: 17;
59
+ readonly SECURITY_ERR: 18;
60
+ readonly NETWORK_ERR: 19;
61
+ readonly ABORT_ERR: 20;
62
+ readonly URL_MISMATCH_ERR: 21;
63
+ readonly QUOTA_EXCEEDED_ERR: 22;
64
+ readonly TIMEOUT_ERR: 23;
65
+ readonly INVALID_NODE_TYPE_ERR: 24;
66
+ readonly DATA_CLONE_ERR: 25;
67
+ };
68
+ }