@types/node 22.15.33 → 24.10.8

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 (84) hide show
  1. node v24.10/README.md +15 -0
  2. node v24.10/assert/strict.d.ts +111 -0
  3. {node v22.15 → node v24.10}/assert.d.ts +162 -101
  4. {node v22.15 → node v24.10}/async_hooks.d.ts +26 -6
  5. {node v22.15 → node v24.10}/buffer.buffer.d.ts +9 -0
  6. {node v22.15 → node v24.10}/buffer.d.ts +15 -7
  7. {node v22.15 → node v24.10}/child_process.d.ts +91 -164
  8. {node v22.15 → node v24.10}/cluster.d.ts +19 -20
  9. {node v22.15 → node v24.10}/compatibility/iterators.d.ts +1 -0
  10. {node v22.15 → node v24.10}/console.d.ts +19 -18
  11. {node v22.15 → node v24.10}/crypto.d.ts +1264 -356
  12. {node v22.15 → node v24.10}/dgram.d.ts +10 -9
  13. {node v22.15 → node v24.10}/diagnostics_channel.d.ts +1 -3
  14. {node v22.15 → node v24.10}/dns/promises.d.ts +12 -11
  15. {node v22.15 → node v24.10}/dns.d.ts +41 -37
  16. {node v22.15 → node v24.10}/domain.d.ts +1 -1
  17. {node v22.15 → node v24.10}/events.d.ts +81 -36
  18. {node v22.15 → node v24.10}/fs/promises.d.ts +114 -57
  19. {node v22.15 → node v24.10}/fs.d.ts +413 -136
  20. node v24.10/globals.d.ts +170 -0
  21. node v24.10/globals.typedarray.d.ts +41 -0
  22. {node v22.15 → node v24.10}/http.d.ts +187 -37
  23. {node v22.15 → node v24.10}/http2.d.ts +197 -66
  24. {node v22.15 → node v24.10}/https.d.ts +97 -63
  25. {node v22.15 → node v24.10}/index.d.ts +16 -7
  26. node v24.10/inspector.d.ts +277 -0
  27. node v22.15/inspector.d.ts → node v24.10/inspector.generated.d.ts +1059 -828
  28. {node v22.15 → node v24.10}/module.d.ts +90 -30
  29. {node v22.15 → node v24.10}/net.d.ts +35 -16
  30. {node v22.15 → node v24.10}/os.d.ts +22 -10
  31. {node v22.15 → node v24.10}/package.json +14 -84
  32. {node v22.15 → node v24.10}/path.d.ts +2 -2
  33. {node v22.15 → node v24.10}/perf_hooks.d.ts +28 -16
  34. {node v22.15 → node v24.10}/process.d.ts +59 -34
  35. {node v22.15 → node v24.10}/punycode.d.ts +1 -1
  36. {node v22.15 → node v24.10}/querystring.d.ts +1 -1
  37. {node v22.15 → node v24.10}/readline/promises.d.ts +1 -2
  38. {node v22.15 → node v24.10}/readline.d.ts +13 -13
  39. {node v22.15 → node v24.10}/repl.d.ts +25 -17
  40. {node v22.15 → node v24.10}/sea.d.ts +10 -1
  41. {node v22.15 → node v24.10}/sqlite.d.ts +438 -9
  42. {node v22.15 → node v24.10}/stream/consumers.d.ts +2 -2
  43. {node v22.15 → node v24.10}/stream/web.d.ts +13 -54
  44. {node v22.15 → node v24.10}/stream.d.ts +63 -48
  45. {node v22.15 → node v24.10}/string_decoder.d.ts +3 -3
  46. node v24.10/test.d.ts +2339 -0
  47. {node v22.15 → node v24.10}/timers/promises.d.ts +1 -1
  48. {node v22.15 → node v24.10}/timers.d.ts +1 -3
  49. {node v22.15 → node v24.10}/tls.d.ts +128 -114
  50. {node v22.15 → node v24.10}/trace_events.d.ts +6 -6
  51. {node v22.15 → node v24.10}/ts5.6/buffer.buffer.d.ts +10 -2
  52. node v24.10/ts5.6/compatibility/float16array.d.ts +71 -0
  53. node v24.10/ts5.6/globals.typedarray.d.ts +36 -0
  54. {node v22.15 → node v24.10}/ts5.6/index.d.ts +18 -7
  55. node v24.10/ts5.7/compatibility/float16array.d.ts +72 -0
  56. node v24.10/ts5.7/index.d.ts +103 -0
  57. {node v22.15 → node v24.10}/tty.d.ts +1 -1
  58. {node v22.15 → node v24.10}/url.d.ts +119 -34
  59. {node v22.15 → node v24.10}/util.d.ts +45 -304
  60. {node v22.15 → node v24.10}/v8.d.ts +68 -38
  61. {node v22.15 → node v24.10}/vm.d.ts +258 -107
  62. {node v22.15 → node v24.10}/wasi.d.ts +23 -2
  63. node v24.10/web-globals/abortcontroller.d.ts +34 -0
  64. node v24.10/web-globals/crypto.d.ts +32 -0
  65. node v24.10/web-globals/domexception.d.ts +68 -0
  66. node v22.15/dom-events.d.ts → node v24.10/web-globals/events.d.ts +49 -51
  67. node v24.10/web-globals/fetch.d.ts +50 -0
  68. node v24.10/web-globals/navigator.d.ts +25 -0
  69. node v24.10/web-globals/storage.d.ts +24 -0
  70. node v24.10/web-globals/streams.d.ts +22 -0
  71. {node v22.15 → node v24.10}/worker_threads.d.ts +206 -68
  72. {node v22.15 → node v24.10}/zlib.d.ts +44 -33
  73. node v22.15/README.md +0 -15
  74. node v22.15/assert/strict.d.ts +0 -8
  75. node v22.15/compatibility/disposable.d.ts +0 -14
  76. node v22.15/compatibility/index.d.ts +0 -9
  77. node v22.15/compatibility/indexable.d.ts +0 -20
  78. node v22.15/globals.d.ts +0 -364
  79. node v22.15/globals.typedarray.d.ts +0 -21
  80. node v22.15/test.d.ts +0 -2278
  81. node v22.15/ts5.6/globals.typedarray.d.ts +0 -19
  82. {node v22.15 → node v24.10}/LICENSE +0 -0
  83. {node v22.15 → node v24.10}/constants.d.ts +0 -0
  84. {node v22.15 → node v24.10}/stream/promises.d.ts +0 -0
@@ -34,10 +34,11 @@
34
34
  *
35
35
  * console.log(x); // 1; y is not defined.
36
36
  * ```
37
- * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/vm.js)
37
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/vm.js)
38
38
  */
39
39
  declare module "vm" {
40
- import { ImportAttributes } from "node:module";
40
+ import { NonSharedBuffer } from "node:buffer";
41
+ import { ImportAttributes, ImportPhase } from "node:module";
41
42
  interface Context extends NodeJS.Dict<any> {}
42
43
  interface BaseOptions {
43
44
  /**
@@ -60,18 +61,20 @@ declare module "vm" {
60
61
  specifier: string,
61
62
  referrer: T,
62
63
  importAttributes: ImportAttributes,
64
+ phase: ImportPhase,
63
65
  ) => Module | Promise<Module>;
64
66
  interface ScriptOptions extends BaseOptions {
65
67
  /**
66
68
  * Provides an optional data with V8's code cache data for the supplied source.
67
69
  */
68
- cachedData?: Buffer | NodeJS.ArrayBufferView | undefined;
70
+ cachedData?: NodeJS.ArrayBufferView | undefined;
69
71
  /** @deprecated in favor of `script.createCachedData()` */
70
72
  produceCachedData?: boolean | undefined;
71
73
  /**
72
74
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
73
75
  * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
74
- * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
76
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
77
+ * @experimental
75
78
  */
76
79
  importModuleDynamically?:
77
80
  | DynamicModuleLoader<Script>
@@ -97,63 +100,48 @@ declare module "vm" {
97
100
  */
98
101
  breakOnSigint?: boolean | undefined;
99
102
  }
100
- interface RunningScriptInNewContextOptions extends RunningScriptOptions {
103
+ interface RunningScriptInNewContextOptions
104
+ extends RunningScriptOptions, Pick<CreateContextOptions, "microtaskMode">
105
+ {
101
106
  /**
102
107
  * Human-readable name of the newly created context.
103
108
  */
104
- contextName?: CreateContextOptions["name"];
109
+ contextName?: CreateContextOptions["name"] | undefined;
105
110
  /**
106
111
  * Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL,
107
112
  * but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object.
108
113
  * Most notably, this string should omit the trailing slash, as that denotes a path.
109
114
  */
110
- contextOrigin?: CreateContextOptions["origin"];
111
- contextCodeGeneration?: CreateContextOptions["codeGeneration"];
112
- /**
113
- * If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
114
- */
115
- microtaskMode?: CreateContextOptions["microtaskMode"];
115
+ contextOrigin?: CreateContextOptions["origin"] | undefined;
116
+ contextCodeGeneration?: CreateContextOptions["codeGeneration"] | undefined;
116
117
  }
117
- interface RunningCodeOptions extends RunningScriptOptions {
118
- /**
119
- * Provides an optional data with V8's code cache data for the supplied source.
120
- */
121
- cachedData?: ScriptOptions["cachedData"] | undefined;
118
+ interface RunningCodeOptions extends RunningScriptOptions, Pick<ScriptOptions, "cachedData"> {
122
119
  /**
123
120
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
124
121
  * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
125
- * [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
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
123
+ * @experimental
126
124
  */
127
125
  importModuleDynamically?:
128
126
  | DynamicModuleLoader<Script>
129
127
  | typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
130
128
  | undefined;
131
129
  }
132
- interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions {
133
- /**
134
- * Provides an optional data with V8's code cache data for the supplied source.
135
- */
136
- cachedData?: ScriptOptions["cachedData"] | undefined;
130
+ interface RunningCodeInNewContextOptions
131
+ extends RunningScriptInNewContextOptions, Pick<ScriptOptions, "cachedData">
132
+ {
137
133
  /**
138
134
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
139
135
  * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
140
- * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
136
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
137
+ * @experimental
141
138
  */
142
139
  importModuleDynamically?:
143
140
  | DynamicModuleLoader<Script>
144
141
  | typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
145
142
  | undefined;
146
143
  }
147
- interface CompileFunctionOptions extends BaseOptions {
148
- /**
149
- * Provides an optional data with V8's code cache data for the supplied source.
150
- */
151
- cachedData?: ScriptOptions["cachedData"] | undefined;
152
- /**
153
- * Specifies whether to produce new cache data.
154
- * @default false
155
- */
156
- produceCachedData?: boolean | undefined;
144
+ interface CompileFunctionOptions extends BaseOptions, Pick<ScriptOptions, "cachedData" | "produceCachedData"> {
157
145
  /**
158
146
  * The sandbox/context in which the said function should be compiled in.
159
147
  */
@@ -165,7 +153,8 @@ declare module "vm" {
165
153
  /**
166
154
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
167
155
  * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
168
- * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
156
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
157
+ * @experimental
169
158
  */
170
159
  importModuleDynamically?:
171
160
  | DynamicModuleLoader<ReturnType<typeof compileFunction>>
@@ -208,7 +197,8 @@ declare module "vm" {
208
197
  /**
209
198
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
210
199
  * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
211
- * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
200
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
201
+ * @experimental
212
202
  */
213
203
  importModuleDynamically?:
214
204
  | DynamicModuleLoader<Context>
@@ -378,17 +368,17 @@ declare module "vm" {
378
368
  * ```
379
369
  * @since v10.6.0
380
370
  */
381
- createCachedData(): Buffer;
371
+ createCachedData(): NonSharedBuffer;
382
372
  /** @deprecated in favor of `script.createCachedData()` */
383
- cachedDataProduced?: boolean | undefined;
373
+ cachedDataProduced?: boolean;
384
374
  /**
385
375
  * When `cachedData` is supplied to create the `vm.Script`, this value will be set
386
376
  * to either `true` or `false` depending on acceptance of the data by V8.
387
377
  * Otherwise the value is `undefined`.
388
378
  * @since v5.7.0
389
379
  */
390
- cachedDataRejected?: boolean | undefined;
391
- cachedData?: Buffer | undefined;
380
+ cachedDataRejected?: boolean;
381
+ cachedData?: NonSharedBuffer;
392
382
  /**
393
383
  * When the script is compiled from a source that contains a source map magic
394
384
  * comment, this property will be set to the URL of the source map.
@@ -406,13 +396,13 @@ declare module "vm" {
406
396
  * ```
407
397
  * @since v19.1.0, v18.13.0
408
398
  */
409
- sourceMapURL?: string | undefined;
399
+ sourceMapURL: string | undefined;
410
400
  }
411
401
  /**
412
402
  * If the given `contextObject` is an object, the `vm.createContext()` method will
413
- * [prepare that object](https://nodejs.org/docs/latest-v22.x/api/vm.html#what-does-it-mean-to-contextify-an-object)
403
+ * [prepare that object](https://nodejs.org/docs/latest-v24.x/api/vm.html#what-does-it-mean-to-contextify-an-object)
414
404
  * and return a reference to it so that it can be used in calls to {@link runInContext} or
415
- * [`script.runInContext()`](https://nodejs.org/docs/latest-v22.x/api/vm.html#scriptrunincontextcontextifiedobject-options).
405
+ * [`script.runInContext()`](https://nodejs.org/docs/latest-v24.x/api/vm.html#scriptrunincontextcontextifiedobject-options).
416
406
  * Inside such scripts, the global object will be wrapped by the `contextObject`, retaining all of its
417
407
  * existing properties but also having the built-in objects and functions any standard
418
408
  * [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global
@@ -616,11 +606,7 @@ declare module "vm" {
616
606
  code: string,
617
607
  params?: readonly string[],
618
608
  options?: CompileFunctionOptions,
619
- ): Function & {
620
- cachedData?: Script["cachedData"] | undefined;
621
- cachedDataProduced?: Script["cachedDataProduced"] | undefined;
622
- cachedDataRejected?: Script["cachedDataRejected"] | undefined;
623
- };
609
+ ): Function & Pick<Script, "cachedData" | "cachedDataProduced" | "cachedDataRejected">;
624
610
  /**
625
611
  * Measure the memory known to V8 and used by all contexts known to the
626
612
  * current V8 isolate, or the main context.
@@ -677,10 +663,7 @@ declare module "vm" {
677
663
  * @experimental
678
664
  */
679
665
  function measureMemory(options?: MeasureMemoryOptions): Promise<MemoryMeasurement>;
680
- interface ModuleEvaluateOptions {
681
- timeout?: RunningScriptOptions["timeout"] | undefined;
682
- breakOnSigint?: RunningScriptOptions["breakOnSigint"] | undefined;
683
- }
666
+ interface ModuleEvaluateOptions extends Pick<RunningScriptOptions, "breakOnSigint" | "timeout"> {}
684
667
  type ModuleLinker = (
685
668
  specifier: string,
686
669
  referencingModule: Module,
@@ -694,14 +677,12 @@ declare module "vm" {
694
677
  * flag enabled.
695
678
  *
696
679
  * The `vm.Module` class provides a low-level interface for using
697
- * ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script` class that closely mirrors [Module Record](https://262.ecma-international.org/14.0/#sec-abstract-module-records) s as
698
- * defined in the ECMAScript
680
+ * ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`
681
+ * class that closely mirrors [Module Record](https://tc39.es/ecma262/#sec-abstract-module-records)s as defined in the ECMAScript
699
682
  * specification.
700
683
  *
701
684
  * Unlike `vm.Script` however, every `vm.Module` object is bound to a context from
702
- * its creation. Operations on `vm.Module` objects are intrinsically asynchronous,
703
- * in contrast with the synchronous nature of `vm.Script` objects. The use of
704
- * 'async' functions can help with manipulating `vm.Module` objects.
685
+ * its creation.
705
686
  *
706
687
  * Using a `vm.Module` object requires three distinct steps: creation/parsing,
707
688
  * linking, and evaluation. These three steps are illustrated in the following
@@ -729,7 +710,7 @@ declare module "vm" {
729
710
  * // Here, we attempt to obtain the default export from the module "foo", and
730
711
  * // put it into local binding "secret".
731
712
  *
732
- * const bar = new vm.SourceTextModule(`
713
+ * const rootModule = new vm.SourceTextModule(`
733
714
  * import s from 'foo';
734
715
  * s;
735
716
  * print(s);
@@ -739,39 +720,48 @@ declare module "vm" {
739
720
  * //
740
721
  * // "Link" the imported dependencies of this Module to it.
741
722
  * //
742
- * // The provided linking callback (the "linker") accepts two arguments: the
743
- * // parent module (`bar` in this case) and the string that is the specifier of
744
- * // the imported module. The callback is expected to return a Module that
745
- * // corresponds to the provided specifier, with certain requirements documented
746
- * // in `module.link()`.
747
- * //
748
- * // If linking has not started for the returned Module, the same linker
749
- * // callback will be called on the returned Module.
723
+ * // Obtain the requested dependencies of a SourceTextModule by
724
+ * // `sourceTextModule.moduleRequests` and resolve them.
750
725
  * //
751
726
  * // Even top-level Modules without dependencies must be explicitly linked. The
752
- * // callback provided would never be called, however.
753
- * //
754
- * // The link() method returns a Promise that will be resolved when all the
755
- * // Promises returned by the linker resolve.
727
+ * // array passed to `sourceTextModule.linkRequests(modules)` can be
728
+ * // empty, however.
756
729
  * //
757
- * // Note: This is a contrived example in that the linker function creates a new
758
- * // "foo" module every time it is called. In a full-fledged module system, a
759
- * // cache would probably be used to avoid duplicated modules.
730
+ * // Note: This is a contrived example in that the resolveAndLinkDependencies
731
+ * // creates a new "foo" module every time it is called. In a full-fledged
732
+ * // module system, a cache would probably be used to avoid duplicated modules.
733
+ *
734
+ * const moduleMap = new Map([
735
+ * ['root', rootModule],
736
+ * ]);
737
+ *
738
+ * function resolveAndLinkDependencies(module) {
739
+ * const requestedModules = module.moduleRequests.map((request) => {
740
+ * // In a full-fledged module system, the resolveAndLinkDependencies would
741
+ * // resolve the module with the module cache key `[specifier, attributes]`.
742
+ * // In this example, we just use the specifier as the key.
743
+ * const specifier = request.specifier;
744
+ *
745
+ * let requestedModule = moduleMap.get(specifier);
746
+ * if (requestedModule === undefined) {
747
+ * requestedModule = new vm.SourceTextModule(`
748
+ * // The "secret" variable refers to the global variable we added to
749
+ * // "contextifiedObject" when creating the context.
750
+ * export default secret;
751
+ * `, { context: referencingModule.context });
752
+ * moduleMap.set(specifier, linkedModule);
753
+ * // Resolve the dependencies of the new module as well.
754
+ * resolveAndLinkDependencies(requestedModule);
755
+ * }
760
756
  *
761
- * async function linker(specifier, referencingModule) {
762
- * if (specifier === 'foo') {
763
- * return new vm.SourceTextModule(`
764
- * // The "secret" variable refers to the global variable we added to
765
- * // "contextifiedObject" when creating the context.
766
- * export default secret;
767
- * `, { context: referencingModule.context });
757
+ * return requestedModule;
758
+ * });
768
759
  *
769
- * // Using `contextifiedObject` instead of `referencingModule.context`
770
- * // here would work as well.
771
- * }
772
- * throw new Error(`Unable to resolve dependency: ${specifier}`);
760
+ * module.linkRequests(requestedModules);
773
761
  * }
774
- * await bar.link(linker);
762
+ *
763
+ * resolveAndLinkDependencies(rootModule);
764
+ * rootModule.instantiate();
775
765
  *
776
766
  * // Step 3
777
767
  * //
@@ -779,20 +769,12 @@ declare module "vm" {
779
769
  * // resolve after the module has finished evaluating.
780
770
  *
781
771
  * // Prints 42.
782
- * await bar.evaluate();
772
+ * await rootModule.evaluate();
783
773
  * ```
784
774
  * @since v13.0.0, v12.16.0
785
775
  * @experimental
786
776
  */
787
777
  class Module {
788
- /**
789
- * The specifiers of all dependencies of this module. The returned array is frozen
790
- * to disallow any changes to it.
791
- *
792
- * Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in
793
- * the ECMAScript specification.
794
- */
795
- dependencySpecifiers: readonly string[];
796
778
  /**
797
779
  * If the `module.status` is `'errored'`, this property contains the exception
798
780
  * thrown by the module during evaluation. If the status is anything else,
@@ -857,6 +839,10 @@ declare module "vm" {
857
839
  * Link module dependencies. This method must be called before evaluation, and
858
840
  * can only be called once per module.
859
841
  *
842
+ * Use `sourceTextModule.linkRequests(modules)` and
843
+ * `sourceTextModule.instantiate()` to link modules either synchronously or
844
+ * asynchronously.
845
+ *
860
846
  * The function is expected to return a `Module` object or a `Promise` that
861
847
  * eventually resolves to a `Module` object. The returned `Module` must satisfy the
862
848
  * following two invariants:
@@ -887,19 +873,13 @@ declare module "vm" {
887
873
  */
888
874
  link(linker: ModuleLinker): Promise<void>;
889
875
  }
890
- interface SourceTextModuleOptions {
876
+ interface SourceTextModuleOptions extends Pick<ScriptOptions, "cachedData" | "columnOffset" | "lineOffset"> {
891
877
  /**
892
878
  * String used in stack traces.
893
879
  * @default 'vm:module(i)' where i is a context-specific ascending index.
894
880
  */
895
881
  identifier?: string | undefined;
896
- /**
897
- * Provides an optional data with V8's code cache data for the supplied source.
898
- */
899
- cachedData?: ScriptOptions["cachedData"] | undefined;
900
882
  context?: Context | undefined;
901
- lineOffset?: BaseOptions["lineOffset"] | undefined;
902
- columnOffset?: BaseOptions["columnOffset"] | undefined;
903
883
  /**
904
884
  * Called during evaluation of this module to initialize the `import.meta`.
905
885
  */
@@ -907,10 +887,30 @@ declare module "vm" {
907
887
  /**
908
888
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
909
889
  * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
910
- * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
890
+ * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
891
+ * @experimental
911
892
  */
912
893
  importModuleDynamically?: DynamicModuleLoader<SourceTextModule> | undefined;
913
894
  }
895
+ /**
896
+ * A `ModuleRequest` represents the request to import a module with given import attributes and phase.
897
+ * @since 24.4.0
898
+ */
899
+ interface ModuleRequest {
900
+ /**
901
+ * The specifier of the requested module.
902
+ */
903
+ specifier: string;
904
+ /**
905
+ * The `"with"` value passed to the `WithClause` in a `ImportDeclaration`, or an empty object if no value was
906
+ * provided.
907
+ */
908
+ attributes: ImportAttributes;
909
+ /**
910
+ * The phase of the requested module (`"source"` or `"evaluation"`).
911
+ */
912
+ phase: ImportPhase;
913
+ }
914
914
  /**
915
915
  * This feature is only available with the `--experimental-vm-modules` command
916
916
  * flag enabled.
@@ -923,9 +923,163 @@ declare module "vm" {
923
923
  class SourceTextModule extends Module {
924
924
  /**
925
925
  * Creates a new `SourceTextModule` instance.
926
+ *
927
+ * Properties assigned to the `import.meta` object that are objects may
928
+ * allow the module to access information outside the specified `context`. Use
929
+ * `vm.runInContext()` to create objects in a specific context.
930
+ *
931
+ * ```js
932
+ * import vm from 'node:vm';
933
+ *
934
+ * const contextifiedObject = vm.createContext({ secret: 42 });
935
+ *
936
+ * const module = new vm.SourceTextModule(
937
+ * 'Object.getPrototypeOf(import.meta.prop).secret = secret;',
938
+ * {
939
+ * initializeImportMeta(meta) {
940
+ * // Note: this object is created in the top context. As such,
941
+ * // Object.getPrototypeOf(import.meta.prop) points to the
942
+ * // Object.prototype in the top context rather than that in
943
+ * // the contextified object.
944
+ * meta.prop = {};
945
+ * },
946
+ * });
947
+ * // The module has an empty `moduleRequests` array.
948
+ * module.linkRequests([]);
949
+ * module.instantiate();
950
+ * await module.evaluate();
951
+ *
952
+ * // Now, Object.prototype.secret will be equal to 42.
953
+ * //
954
+ * // To fix this problem, replace
955
+ * // meta.prop = {};
956
+ * // above with
957
+ * // meta.prop = vm.runInContext('{}', contextifiedObject);
958
+ * ```
926
959
  * @param code JavaScript Module code to parse
927
960
  */
928
961
  constructor(code: string, options?: SourceTextModuleOptions);
962
+ /**
963
+ * @deprecated Use `sourceTextModule.moduleRequests` instead.
964
+ */
965
+ readonly dependencySpecifiers: readonly string[];
966
+ /**
967
+ * Iterates over the dependency graph and returns `true` if any module in its
968
+ * dependencies or this module itself contains top-level `await` expressions,
969
+ * otherwise returns `false`.
970
+ *
971
+ * The search may be slow if the graph is big enough.
972
+ *
973
+ * This requires the module to be instantiated first. If the module is not
974
+ * instantiated yet, an error will be thrown.
975
+ * @since v24.9.0
976
+ */
977
+ hasAsyncGraph(): boolean;
978
+ /**
979
+ * Returns whether the module itself contains any top-level `await` expressions.
980
+ *
981
+ * This corresponds to the field `[[HasTLA]]` in [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) in the
982
+ * ECMAScript specification.
983
+ * @since v24.9.0
984
+ */
985
+ hasTopLevelAwait(): boolean;
986
+ /**
987
+ * Instantiate the module with the linked requested modules.
988
+ *
989
+ * This resolves the imported bindings of the module, including re-exported
990
+ * binding names. When there are any bindings that cannot be resolved,
991
+ * an error would be thrown synchronously.
992
+ *
993
+ * If the requested modules include cyclic dependencies, the
994
+ * `sourceTextModule.linkRequests(modules)` method must be called on all
995
+ * modules in the cycle before calling this method.
996
+ * @since v24.8.0
997
+ */
998
+ instantiate(): void;
999
+ /**
1000
+ * Link module dependencies. This method must be called before evaluation, and
1001
+ * can only be called once per module.
1002
+ *
1003
+ * The order of the module instances in the `modules` array should correspond to the order of
1004
+ * `sourceTextModule.moduleRequests` being resolved. If two module requests have the same
1005
+ * specifier and import attributes, they must be resolved with the same module instance or an
1006
+ * `ERR_MODULE_LINK_MISMATCH` would be thrown. For example, when linking requests for this
1007
+ * module:
1008
+ *
1009
+ * ```js
1010
+ * import foo from 'foo';
1011
+ * import source Foo from 'foo';
1012
+ * ```
1013
+ *
1014
+ * The `modules` array must contain two references to the same instance, because the two
1015
+ * module requests are identical but in two phases.
1016
+ *
1017
+ * If the module has no dependencies, the `modules` array can be empty.
1018
+ *
1019
+ * Users can use `sourceTextModule.moduleRequests` to implement the host-defined
1020
+ * [HostLoadImportedModule](https://tc39.es/ecma262/#sec-HostLoadImportedModule) abstract operation in the ECMAScript specification,
1021
+ * and using `sourceTextModule.linkRequests()` to invoke specification defined
1022
+ * [FinishLoadingImportedModule](https://tc39.es/ecma262/#sec-FinishLoadingImportedModule), on the module with all dependencies in a batch.
1023
+ *
1024
+ * It's up to the creator of the `SourceTextModule` to determine if the resolution
1025
+ * of the dependencies is synchronous or asynchronous.
1026
+ *
1027
+ * After each module in the `modules` array is linked, call
1028
+ * `sourceTextModule.instantiate()`.
1029
+ * @since v24.8.0
1030
+ * @param modules Array of `vm.Module` objects that this module depends on.
1031
+ * The order of the modules in the array is the order of
1032
+ * `sourceTextModule.moduleRequests`.
1033
+ */
1034
+ linkRequests(modules: readonly Module[]): void;
1035
+ /**
1036
+ * The requested import dependencies of this module. The returned array is frozen
1037
+ * to disallow any changes to it.
1038
+ *
1039
+ * For example, given a source text:
1040
+ *
1041
+ * ```js
1042
+ * import foo from 'foo';
1043
+ * import fooAlias from 'foo';
1044
+ * import bar from './bar.js';
1045
+ * import withAttrs from '../with-attrs.ts' with { arbitraryAttr: 'attr-val' };
1046
+ * import source Module from 'wasm-mod.wasm';
1047
+ * ```
1048
+ *
1049
+ * The value of the `sourceTextModule.moduleRequests` will be:
1050
+ *
1051
+ * ```js
1052
+ * [
1053
+ * {
1054
+ * specifier: 'foo',
1055
+ * attributes: {},
1056
+ * phase: 'evaluation',
1057
+ * },
1058
+ * {
1059
+ * specifier: 'foo',
1060
+ * attributes: {},
1061
+ * phase: 'evaluation',
1062
+ * },
1063
+ * {
1064
+ * specifier: './bar.js',
1065
+ * attributes: {},
1066
+ * phase: 'evaluation',
1067
+ * },
1068
+ * {
1069
+ * specifier: '../with-attrs.ts',
1070
+ * attributes: { arbitraryAttr: 'attr-val' },
1071
+ * phase: 'evaluation',
1072
+ * },
1073
+ * {
1074
+ * specifier: 'wasm-mod.wasm',
1075
+ * attributes: {},
1076
+ * phase: 'source',
1077
+ * },
1078
+ * ];
1079
+ * ```
1080
+ * @since v24.4.0
1081
+ */
1082
+ readonly moduleRequests: readonly ModuleRequest[];
929
1083
  }
930
1084
  interface SyntheticModuleOptions {
931
1085
  /**
@@ -973,9 +1127,7 @@ declare module "vm" {
973
1127
  options?: SyntheticModuleOptions,
974
1128
  );
975
1129
  /**
976
- * This method is used after the module is linked to set the values of exports. If
977
- * it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error
978
- * will be thrown.
1130
+ * This method sets the module export binding slots with the given value.
979
1131
  *
980
1132
  * ```js
981
1133
  * import vm from 'node:vm';
@@ -984,7 +1136,6 @@ declare module "vm" {
984
1136
  * m.setExport('x', 1);
985
1137
  * });
986
1138
  *
987
- * await m.link(() => {});
988
1139
  * await m.evaluate();
989
1140
  *
990
1141
  * assert.strictEqual(m.namespace.x, 1);
@@ -1005,7 +1156,7 @@ declare module "vm" {
1005
1156
  * and `vm.compileFunction()` so that Node.js uses the default ESM loader from the main
1006
1157
  * context to load the requested module.
1007
1158
  *
1008
- * For detailed information, see [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
1159
+ * For detailed information, see [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
1009
1160
  * @since v21.7.0, v20.12.0
1010
1161
  */
1011
1162
  const USE_MAIN_CONTEXT_DEFAULT_LOADER: number;
@@ -67,7 +67,7 @@
67
67
  * wat2wasm demo.wat
68
68
  * ```
69
69
  * @experimental
70
- * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/wasi.js)
70
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/wasi.js)
71
71
  */
72
72
  declare module "wasi" {
73
73
  interface WASIOptions {
@@ -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.
@@ -121,6 +121,12 @@ declare module "wasi" {
121
121
  */
122
122
  version: "unstable" | "preview1";
123
123
  }
124
+ interface FinalizeBindingsOptions {
125
+ /**
126
+ * @default instance.exports.memory
127
+ */
128
+ memory?: object | undefined;
129
+ }
124
130
  /**
125
131
  * The `WASI` class provides the WASI system call API and additional convenience
126
132
  * methods for working with WASI-based applications. Each `WASI` instance
@@ -167,6 +173,21 @@ declare module "wasi" {
167
173
  * @since v14.6.0, v12.19.0
168
174
  */
169
175
  initialize(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
176
+ /**
177
+ * Set up WASI host bindings to `instance` without calling `initialize()`
178
+ * or `start()`. This method is useful when the WASI module is instantiated in
179
+ * child threads for sharing the memory across threads.
180
+ *
181
+ * `finalizeBindings()` requires that either `instance` exports a
182
+ * [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named `memory` or user specify a
183
+ * [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) object in `options.memory`. If the `memory` is invalid
184
+ * an exception is thrown.
185
+ *
186
+ * `start()` and `initialize()` will call `finalizeBindings()` internally.
187
+ * If `finalizeBindings()` is called more than once, an exception is thrown.
188
+ * @since v24.4.0
189
+ */
190
+ finalizeBindings(instance: object, options?: FinalizeBindingsOptions): void;
170
191
  /**
171
192
  * `wasiImport` is an object that implements the WASI system call API. This object
172
193
  * should be passed as the `wasi_snapshot_preview1` import during the instantiation
@@ -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
+ }