@types/node 20.19.25 → 24.10.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 (79) hide show
  1. {node v20.19 → node v24.10}/README.md +3 -3
  2. node v24.10/assert/strict.d.ts +111 -0
  3. {node v20.19 → node v24.10}/assert.d.ts +150 -97
  4. {node v20.19 → node v24.10}/async_hooks.d.ts +27 -9
  5. {node v20.19 → node v24.10}/buffer.buffer.d.ts +2 -1
  6. {node v20.19 → node v24.10}/buffer.d.ts +6 -8
  7. {node v20.19 → node v24.10}/child_process.d.ts +11 -10
  8. {node v20.19 → node v24.10}/cluster.d.ts +16 -15
  9. {node v20.19 → node v24.10}/console.d.ts +19 -18
  10. {node v20.19 → node v24.10}/crypto.d.ts +1120 -293
  11. {node v20.19 → node v24.10}/dgram.d.ts +5 -2
  12. {node v20.19 → node v24.10}/diagnostics_channel.d.ts +1 -3
  13. {node v20.19 → node v24.10}/dns/promises.d.ts +30 -6
  14. {node v20.19 → node v24.10}/dns.d.ts +69 -17
  15. {node v20.19 → node v24.10}/domain.d.ts +1 -1
  16. {node v20.19 → node v24.10}/events.d.ts +1 -2
  17. {node v20.19 → node v24.10}/fs/promises.d.ts +85 -38
  18. {node v20.19 → node v24.10}/fs.d.ts +387 -48
  19. {node v20.19 → node v24.10}/globals.d.ts +2 -4
  20. {node v20.19 → node v24.10}/globals.typedarray.d.ts +3 -0
  21. {node v20.19 → node v24.10}/http.d.ts +90 -5
  22. {node v20.19 → node v24.10}/http2.d.ts +166 -41
  23. {node v20.19 → node v24.10}/https.d.ts +4 -3
  24. {node v20.19 → node v24.10}/index.d.ts +13 -5
  25. node v24.10/inspector.d.ts +277 -0
  26. {node v20.19 → node v24.10}/inspector.generated.d.ts +1096 -829
  27. {node v20.19 → node v24.10}/module.d.ts +403 -48
  28. {node v20.19 → node v24.10}/net.d.ts +62 -20
  29. {node v20.19 → node v24.10}/os.d.ts +8 -7
  30. {node v20.19 → node v24.10}/package.json +18 -3
  31. {node v20.19 → node v24.10}/path.d.ts +3 -3
  32. {node v20.19 → node v24.10}/perf_hooks.d.ts +37 -16
  33. {node v20.19 → node v24.10}/process.d.ts +133 -16
  34. {node v20.19 → node v24.10}/punycode.d.ts +1 -1
  35. {node v20.19 → node v24.10}/querystring.d.ts +1 -1
  36. {node v20.19 → node v24.10}/readline/promises.d.ts +0 -1
  37. {node v20.19 → node v24.10}/readline.d.ts +19 -14
  38. {node v20.19 → node v24.10}/repl.d.ts +25 -17
  39. {node v20.19 → node v24.10}/sea.d.ts +11 -2
  40. node v24.10/sqlite.d.ts +937 -0
  41. {node v20.19 → node v24.10}/stream/web.d.ts +85 -45
  42. {node v20.19 → node v24.10}/stream.d.ts +36 -28
  43. {node v20.19 → node v24.10}/string_decoder.d.ts +1 -1
  44. {node v20.19 → node v24.10}/test.d.ts +587 -35
  45. {node v20.19 → node v24.10}/timers/promises.d.ts +1 -1
  46. {node v20.19 → node v24.10}/timers.d.ts +4 -5
  47. {node v20.19 → node v24.10}/tls.d.ts +62 -48
  48. {node v20.19 → node v24.10}/trace_events.d.ts +6 -6
  49. node v24.10/ts5.6/compatibility/float16array.d.ts +71 -0
  50. {node v20.19 → node v24.10}/ts5.6/globals.typedarray.d.ts +2 -0
  51. {node v20.19 → node v24.10}/ts5.6/index.d.ts +15 -5
  52. node v24.10/ts5.7/compatibility/float16array.d.ts +72 -0
  53. node v24.10/ts5.7/index.d.ts +103 -0
  54. {node v20.19 → node v24.10}/tty.d.ts +1 -1
  55. {node v20.19 → node v24.10}/url.d.ts +128 -35
  56. {node v20.19 → node v24.10}/util.d.ts +384 -390
  57. {node v20.19 → node v24.10}/v8.d.ts +175 -32
  58. {node v20.19 → node v24.10}/vm.d.ts +246 -67
  59. {node v20.19 → node v24.10}/wasi.d.ts +23 -2
  60. node v24.10/web-globals/crypto.d.ts +32 -0
  61. {node v20.19 → node v24.10}/web-globals/fetch.d.ts +4 -0
  62. node v24.10/web-globals/navigator.d.ts +25 -0
  63. node v24.10/web-globals/storage.d.ts +24 -0
  64. node v24.10/web-globals/streams.d.ts +22 -0
  65. {node v20.19 → node v24.10}/worker_threads.d.ts +205 -24
  66. {node v20.19 → node v24.10}/zlib.d.ts +185 -44
  67. node v20.19/assert/strict.d.ts +0 -8
  68. node v20.19/compatibility/disposable.d.ts +0 -16
  69. node v20.19/compatibility/index.d.ts +0 -9
  70. node v20.19/compatibility/indexable.d.ts +0 -20
  71. {node v20.19 → node v24.10}/LICENSE +0 -0
  72. {node v20.19 → node v24.10}/compatibility/iterators.d.ts +0 -0
  73. {node v20.19 → node v24.10}/constants.d.ts +0 -0
  74. {node v20.19 → node v24.10}/stream/consumers.d.ts +0 -0
  75. {node v20.19 → node v24.10}/stream/promises.d.ts +0 -0
  76. {node v20.19 → node v24.10}/ts5.6/buffer.buffer.d.ts +0 -0
  77. {node v20.19 → node v24.10}/web-globals/abortcontroller.d.ts +0 -0
  78. {node v20.19 → node v24.10}/web-globals/domexception.d.ts +0 -0
  79. {node v20.19 → node v24.10}/web-globals/events.d.ts +0 -0
@@ -34,11 +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/v20.13.1/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
40
  import { NonSharedBuffer } from "node:buffer";
41
- import { ImportAttributes } from "node:module";
41
+ import { ImportAttributes, ImportPhase } from "node:module";
42
42
  interface Context extends NodeJS.Dict<any> {}
43
43
  interface BaseOptions {
44
44
  /**
@@ -61,6 +61,7 @@ declare module "vm" {
61
61
  specifier: string,
62
62
  referrer: T,
63
63
  importAttributes: ImportAttributes,
64
+ phase: ImportPhase,
64
65
  ) => Module | Promise<Module>;
65
66
  interface ScriptOptions extends BaseOptions {
66
67
  /**
@@ -72,7 +73,8 @@ declare module "vm" {
72
73
  /**
73
74
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
74
75
  * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
75
- * [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v20.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
76
78
  */
77
79
  importModuleDynamically?:
78
80
  | DynamicModuleLoader<Script>
@@ -117,7 +119,8 @@ declare module "vm" {
117
119
  /**
118
120
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
119
121
  * 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).
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
121
124
  */
122
125
  importModuleDynamically?:
123
126
  | DynamicModuleLoader<Script>
@@ -130,7 +133,8 @@ declare module "vm" {
130
133
  /**
131
134
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
132
135
  * 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).
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
134
138
  */
135
139
  importModuleDynamically?:
136
140
  | DynamicModuleLoader<Script>
@@ -149,7 +153,8 @@ declare module "vm" {
149
153
  /**
150
154
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
151
155
  * 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).
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
153
158
  */
154
159
  importModuleDynamically?:
155
160
  | DynamicModuleLoader<ReturnType<typeof compileFunction>>
@@ -192,7 +197,8 @@ declare module "vm" {
192
197
  /**
193
198
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
194
199
  * 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).
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
196
202
  */
197
203
  importModuleDynamically?:
198
204
  | DynamicModuleLoader<Context>
@@ -264,7 +270,7 @@ declare module "vm" {
264
270
  *
265
271
  * 1. Creates a new context.
266
272
  * 2. If `contextObject` is an object, contextifies it with the new context.
267
- * If `contextObject` is undefined, creates a new object and contextifies it.
273
+ * If `contextObject` is undefined, creates a new object and contextifies it.
268
274
  * If `contextObject` is `vm.constants.DONT_CONTEXTIFY`, don't contextify anything.
269
275
  * 3. Runs the compiled code contained by the `vm.Script` object within the created context. The code
270
276
  * does not have access to the scope in which this method is called.
@@ -394,9 +400,9 @@ declare module "vm" {
394
400
  }
395
401
  /**
396
402
  * If the given `contextObject` is an object, the `vm.createContext()` method will
397
- * [prepare that object](https://nodejs.org/docs/latest-v20.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)
398
404
  * and return a reference to it so that it can be used in calls to {@link runInContext} or
399
- * [`script.runInContext()`](https://nodejs.org/docs/latest-v20.x/api/vm.html#scriptrunincontextcontextifiedobject-options).
405
+ * [`script.runInContext()`](https://nodejs.org/docs/latest-v24.x/api/vm.html#scriptrunincontextcontextifiedobject-options).
400
406
  * Inside such scripts, the global object will be wrapped by the `contextObject`, retaining all of its
401
407
  * existing properties but also having the built-in objects and functions any standard
402
408
  * [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global
@@ -558,7 +564,7 @@ declare module "vm" {
558
564
  * context. The code passed to this VM context will have its own isolated scope.
559
565
  *
560
566
  * In order to run a simple web server using the `node:http` module the code passed
561
- * to the context must either call `require('node:http')` on its own, or have a
567
+ * to the context must either import `node:http` on its own, or have a
562
568
  * reference to the `node:http` module passed to it. For instance:
563
569
  *
564
570
  * ```js
@@ -567,7 +573,8 @@ declare module "vm" {
567
573
  *
568
574
  * const code = `
569
575
  * ((require) => {
570
- * const http = require('node:http');
576
+ * const http = require('node:http');
577
+ *
571
578
  * http.createServer((request, response) => {
572
579
  * response.writeHead(200, { 'Content-Type': 'text/plain' });
573
580
  * response.end('Hello World\\n');
@@ -661,8 +668,6 @@ declare module "vm" {
661
668
  specifier: string,
662
669
  referencingModule: Module,
663
670
  extra: {
664
- /** @deprecated Use `attributes` instead */
665
- assert: ImportAttributes;
666
671
  attributes: ImportAttributes;
667
672
  },
668
673
  ) => Module | Promise<Module>;
@@ -672,14 +677,12 @@ declare module "vm" {
672
677
  * flag enabled.
673
678
  *
674
679
  * The `vm.Module` class provides a low-level interface for using
675
- * 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
676
- * 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
677
682
  * specification.
678
683
  *
679
684
  * Unlike `vm.Script` however, every `vm.Module` object is bound to a context from
680
- * its creation. Operations on `vm.Module` objects are intrinsically asynchronous,
681
- * in contrast with the synchronous nature of `vm.Script` objects. The use of
682
- * 'async' functions can help with manipulating `vm.Module` objects.
685
+ * its creation.
683
686
  *
684
687
  * Using a `vm.Module` object requires three distinct steps: creation/parsing,
685
688
  * linking, and evaluation. These three steps are illustrated in the following
@@ -707,7 +710,7 @@ declare module "vm" {
707
710
  * // Here, we attempt to obtain the default export from the module "foo", and
708
711
  * // put it into local binding "secret".
709
712
  *
710
- * const bar = new vm.SourceTextModule(`
713
+ * const rootModule = new vm.SourceTextModule(`
711
714
  * import s from 'foo';
712
715
  * s;
713
716
  * print(s);
@@ -717,39 +720,48 @@ declare module "vm" {
717
720
  * //
718
721
  * // "Link" the imported dependencies of this Module to it.
719
722
  * //
720
- * // The provided linking callback (the "linker") accepts two arguments: the
721
- * // parent module (`bar` in this case) and the string that is the specifier of
722
- * // the imported module. The callback is expected to return a Module that
723
- * // corresponds to the provided specifier, with certain requirements documented
724
- * // in `module.link()`.
725
- * //
726
- * // If linking has not started for the returned Module, the same linker
727
- * // callback will be called on the returned Module.
723
+ * // Obtain the requested dependencies of a SourceTextModule by
724
+ * // `sourceTextModule.moduleRequests` and resolve them.
728
725
  * //
729
726
  * // Even top-level Modules without dependencies must be explicitly linked. The
730
- * // callback provided would never be called, however.
731
- * //
732
- * // The link() method returns a Promise that will be resolved when all the
733
- * // Promises returned by the linker resolve.
727
+ * // array passed to `sourceTextModule.linkRequests(modules)` can be
728
+ * // empty, however.
734
729
  * //
735
- * // Note: This is a contrived example in that the linker function creates a new
736
- * // "foo" module every time it is called. In a full-fledged module system, a
737
- * // cache would probably be used to avoid duplicated modules.
738
- *
739
- * async function linker(specifier, referencingModule) {
740
- * if (specifier === 'foo') {
741
- * return new vm.SourceTextModule(`
742
- * // The "secret" variable refers to the global variable we added to
743
- * // "contextifiedObject" when creating the context.
744
- * export default secret;
745
- * `, { context: referencingModule.context });
746
- *
747
- * // Using `contextifiedObject` instead of `referencingModule.context`
748
- * // here would work as well.
749
- * }
750
- * throw new Error(`Unable to resolve dependency: ${specifier}`);
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
+ * }
756
+ *
757
+ * return requestedModule;
758
+ * });
759
+ *
760
+ * module.linkRequests(requestedModules);
751
761
  * }
752
- * await bar.link(linker);
762
+ *
763
+ * resolveAndLinkDependencies(rootModule);
764
+ * rootModule.instantiate();
753
765
  *
754
766
  * // Step 3
755
767
  * //
@@ -757,20 +769,12 @@ declare module "vm" {
757
769
  * // resolve after the module has finished evaluating.
758
770
  *
759
771
  * // Prints 42.
760
- * await bar.evaluate();
772
+ * await rootModule.evaluate();
761
773
  * ```
762
774
  * @since v13.0.0, v12.16.0
763
775
  * @experimental
764
776
  */
765
777
  class Module {
766
- /**
767
- * The specifiers of all dependencies of this module. The returned array is frozen
768
- * to disallow any changes to it.
769
- *
770
- * Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in
771
- * the ECMAScript specification.
772
- */
773
- dependencySpecifiers: readonly string[];
774
778
  /**
775
779
  * If the `module.status` is `'errored'`, this property contains the exception
776
780
  * thrown by the module during evaluation. If the status is anything else,
@@ -835,6 +839,10 @@ declare module "vm" {
835
839
  * Link module dependencies. This method must be called before evaluation, and
836
840
  * can only be called once per module.
837
841
  *
842
+ * Use `sourceTextModule.linkRequests(modules)` and
843
+ * `sourceTextModule.instantiate()` to link modules either synchronously or
844
+ * asynchronously.
845
+ *
838
846
  * The function is expected to return a `Module` object or a `Promise` that
839
847
  * eventually resolves to a `Module` object. The returned `Module` must satisfy the
840
848
  * following two invariants:
@@ -879,10 +887,30 @@ declare module "vm" {
879
887
  /**
880
888
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
881
889
  * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
882
- * [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
883
892
  */
884
893
  importModuleDynamically?: DynamicModuleLoader<SourceTextModule> | undefined;
885
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
+ }
886
914
  /**
887
915
  * This feature is only available with the `--experimental-vm-modules` command
888
916
  * flag enabled.
@@ -895,9 +923,163 @@ declare module "vm" {
895
923
  class SourceTextModule extends Module {
896
924
  /**
897
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
+ * ```
898
959
  * @param code JavaScript Module code to parse
899
960
  */
900
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[];
901
1083
  }
902
1084
  interface SyntheticModuleOptions {
903
1085
  /**
@@ -945,9 +1127,7 @@ declare module "vm" {
945
1127
  options?: SyntheticModuleOptions,
946
1128
  );
947
1129
  /**
948
- * This method is used after the module is linked to set the values of exports. If
949
- * it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error
950
- * will be thrown.
1130
+ * This method sets the module export binding slots with the given value.
951
1131
  *
952
1132
  * ```js
953
1133
  * import vm from 'node:vm';
@@ -956,7 +1136,6 @@ declare module "vm" {
956
1136
  * m.setExport('x', 1);
957
1137
  * });
958
1138
  *
959
- * await m.link(() => {});
960
1139
  * await m.evaluate();
961
1140
  *
962
1141
  * assert.strictEqual(m.namespace.x, 1);
@@ -969,7 +1148,7 @@ declare module "vm" {
969
1148
  }
970
1149
  /**
971
1150
  * Returns an object containing commonly used constants for VM operations.
972
- * @since v20.12.0
1151
+ * @since v21.7.0, v20.12.0
973
1152
  */
974
1153
  namespace constants {
975
1154
  /**
@@ -977,8 +1156,8 @@ declare module "vm" {
977
1156
  * and `vm.compileFunction()` so that Node.js uses the default ESM loader from the main
978
1157
  * context to load the requested module.
979
1158
  *
980
- * For detailed information, see [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v20.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
981
- * @since v20.12.0
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).
1160
+ * @since v21.7.0, v20.12.0
982
1161
  */
983
1162
  const USE_MAIN_CONTEXT_DEFAULT_LOADER: number;
984
1163
  /**
@@ -991,7 +1170,7 @@ declare module "vm" {
991
1170
  * the returned object is a proxy-like object to the global object in the newly created context with
992
1171
  * fewer Node.js-specific quirks. It is reference equal to the `globalThis` value in the new context,
993
1172
  * can be modified from outside the context, and can be used to access built-ins in the new context directly.
994
- * @since v20.18.0
1173
+ * @since v22.8.0
995
1174
  */
996
1175
  const DONT_CONTEXTIFY: number;
997
1176
  }
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * ```js
11
11
  * import { readFile } from 'node:fs/promises';
12
- * import { WASI } from 'wasi';
12
+ * import { WASI } from 'node:wasi';
13
13
  * import { argv, env } from 'node:process';
14
14
  *
15
15
  * const wasi = new WASI({
@@ -67,7 +67,7 @@
67
67
  * wat2wasm demo.wat
68
68
  * ```
69
69
  * @experimental
70
- * @see [source](https://github.com/nodejs/node/blob/v20.13.1/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 {
@@ -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,32 @@
1
+ export {};
2
+
3
+ import { webcrypto } from "crypto";
4
+
5
+ declare global {
6
+ var Crypto: typeof globalThis extends { onmessage: any; Crypto: infer T } ? T : {
7
+ prototype: webcrypto.Crypto;
8
+ new(): webcrypto.Crypto;
9
+ };
10
+
11
+ var CryptoKey: typeof globalThis extends { onmessage: any; CryptoKey: infer T } ? T : {
12
+ prototype: webcrypto.CryptoKey;
13
+ new(): webcrypto.CryptoKey;
14
+ };
15
+
16
+ var SubtleCrypto: typeof globalThis extends { onmessage: any; SubtleCrypto: infer T } ? T : {
17
+ prototype: webcrypto.SubtleCrypto;
18
+ new(): webcrypto.SubtleCrypto;
19
+ supports(
20
+ operation: string,
21
+ algorithm: webcrypto.AlgorithmIdentifier,
22
+ length?: number,
23
+ ): boolean;
24
+ supports(
25
+ operation: string,
26
+ algorithm: webcrypto.AlgorithmIdentifier,
27
+ additionalAlgorithm: webcrypto.AlgorithmIdentifier,
28
+ ): boolean;
29
+ };
30
+
31
+ var crypto: typeof globalThis extends { onmessage: any; crypto: infer T } ? T : webcrypto.Crypto;
32
+ }
@@ -2,6 +2,7 @@ export {};
2
2
 
3
3
  import * as undici from "undici-types";
4
4
 
5
+ type _CloseEvent = typeof globalThis extends { onmessage: any } ? {} : undici.CloseEvent;
5
6
  type _EventSource = typeof globalThis extends { onmessage: any } ? {} : undici.EventSource;
6
7
  type _FormData = typeof globalThis extends { onmessage: any } ? {} : undici.FormData;
7
8
  type _Headers = typeof globalThis extends { onmessage: any } ? {} : undici.Headers;
@@ -18,6 +19,9 @@ declare global {
18
19
  init?: RequestInit,
19
20
  ): Promise<Response>;
20
21
 
22
+ interface CloseEvent extends _CloseEvent {}
23
+ var CloseEvent: typeof globalThis extends { onmessage: any; CloseEvent: infer T } ? T : typeof undici.CloseEvent;
24
+
21
25
  interface EventSource extends _EventSource {}
22
26
  var EventSource: typeof globalThis extends { onmessage: any; EventSource: infer T } ? T : typeof undici.EventSource;
23
27
 
@@ -0,0 +1,25 @@
1
+ export {};
2
+
3
+ import { LockManager } from "worker_threads";
4
+
5
+ // lib.webworker has `WorkerNavigator` rather than `Navigator`, so conditionals use `onabort` instead of `onmessage`
6
+ type _Navigator = typeof globalThis extends { onabort: any } ? {} : Navigator;
7
+ interface Navigator {
8
+ readonly hardwareConcurrency: number;
9
+ readonly language: string;
10
+ readonly languages: readonly string[];
11
+ readonly locks: LockManager;
12
+ readonly platform: string;
13
+ readonly userAgent: string;
14
+ }
15
+
16
+ declare global {
17
+ interface Navigator extends _Navigator {}
18
+ var Navigator: typeof globalThis extends { onabort: any; Navigator: infer T } ? T : {
19
+ prototype: Navigator;
20
+ new(): Navigator;
21
+ };
22
+
23
+ // Needs conditional inference for lib.dom and lib.webworker compatibility
24
+ var navigator: typeof globalThis extends { onmessage: any; navigator: infer T } ? T : Navigator;
25
+ }
@@ -0,0 +1,24 @@
1
+ export {};
2
+
3
+ // These interfaces are absent from lib.webworker, so the conditionals use `onabort` rather than `onmessage`
4
+ type _Storage = typeof globalThis extends { onabort: any } ? {} : Storage;
5
+ interface Storage {
6
+ readonly length: number;
7
+ clear(): void;
8
+ getItem(key: string): string | null;
9
+ key(index: number): string | null;
10
+ removeItem(key: string): void;
11
+ setItem(key: string, value: string): void;
12
+ [key: string]: any;
13
+ }
14
+
15
+ declare global {
16
+ interface Storage extends _Storage {}
17
+ var Storage: typeof globalThis extends { onabort: any; Storage: infer T } ? T : {
18
+ prototype: Storage;
19
+ new(): Storage;
20
+ };
21
+
22
+ var localStorage: Storage;
23
+ var sessionStorage: Storage;
24
+ }