@idlebox/stripe-node-types 24.0.14 → 24.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assert/strict.d.ts +98 -1
- package/assert.d.ts +147 -248
- package/async_hooks.d.ts +5 -5
- package/buffer.buffer.d.ts +9 -6
- package/buffer.d.ts +49 -169
- package/child_process.d.ts +102 -223
- package/cluster.d.ts +236 -329
- package/console.d.ts +45 -346
- package/constants.d.ts +0 -1
- package/crypto.d.ts +698 -1149
- package/dgram.d.ts +15 -50
- package/diagnostics_channel.d.ts +1 -3
- package/dns.d.ts +135 -131
- package/domain.d.ts +10 -14
- package/events.d.ts +846 -722
- package/fs/promises.d.ts +102 -53
- package/fs.d.ts +714 -484
- package/globals.d.ts +130 -347
- package/globals.typedarray.d.ts +79 -0
- package/http.d.ts +343 -246
- package/http2.d.ts +563 -711
- package/https.d.ts +70 -216
- package/index.d.ts +24 -3
- package/inspector/promises.d.ts +54 -0
- package/inspector.d.ts +167 -3938
- package/inspector.generated.d.ts +4242 -0
- package/module.d.ts +45 -95
- package/net.d.ts +87 -186
- package/os.d.ts +17 -6
- package/package.json +3 -8
- package/path/posix.d.ts +20 -0
- package/path/win32.d.ts +20 -0
- package/path.d.ts +117 -122
- package/perf_hooks.d.ts +295 -644
- package/process.d.ts +177 -138
- package/punycode.d.ts +2 -2
- package/querystring.d.ts +1 -1
- package/quic.d.ts +926 -0
- package/readline/promises.d.ts +1 -1
- package/readline.d.ts +65 -118
- package/repl.d.ts +83 -96
- package/sea.d.ts +10 -1
- package/sqlite.d.ts +262 -13
- package/stream/consumers.d.ts +7 -7
- package/stream/promises.d.ts +133 -12
- package/stream/web.d.ts +173 -495
- package/stream.d.ts +593 -490
- package/string_decoder.d.ts +3 -3
- package/test/reporters.d.ts +112 -0
- package/test.d.ts +223 -199
- package/timers/promises.d.ts +1 -1
- package/timers.d.ts +1 -129
- package/tls.d.ts +148 -163
- package/trace_events.d.ts +6 -6
- package/ts5.6/buffer.buffer.d.ts +10 -8
- package/ts5.6/globals.typedarray.d.ts +16 -0
- package/ts5.6/index.d.ts +24 -3
- package/ts5.7/index.d.ts +24 -3
- package/tty.d.ts +55 -13
- package/url.d.ts +92 -587
- package/util/types.d.ts +571 -0
- package/util.d.ts +143 -792
- package/v8.d.ts +67 -7
- package/vm.d.ts +252 -108
- package/wasi.d.ts +23 -2
- package/web-globals/abortcontroller.d.ts +75 -0
- package/web-globals/blob.d.ts +39 -0
- package/{ts5.1/compatibility/disposable.d.ts → web-globals/console.d.ts} +6 -9
- package/web-globals/crypto.d.ts +55 -0
- package/web-globals/domexception.d.ts +84 -0
- package/web-globals/encoding.d.ts +27 -0
- package/{dom-events.d.ts → web-globals/events.d.ts} +57 -50
- package/web-globals/fetch.d.ts +70 -0
- package/web-globals/importmeta.d.ts +29 -0
- package/web-globals/messaging.d.ts +39 -0
- package/web-globals/navigator.d.ts +41 -0
- package/web-globals/performance.d.ts +61 -0
- package/web-globals/storage.d.ts +40 -0
- package/web-globals/streams.d.ts +131 -0
- package/web-globals/timers.d.ts +60 -0
- package/web-globals/url.d.ts +40 -0
- package/worker_threads.d.ts +291 -349
- package/zlib.d.ts +44 -94
- package/ts5.1/index.d.ts +0 -115
package/vm.d.ts
CHANGED
|
@@ -49,11 +49,12 @@
|
|
|
49
49
|
*
|
|
50
50
|
* console.log(x); // 1; y is not defined.
|
|
51
51
|
* ```
|
|
52
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
52
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/vm.js)
|
|
53
53
|
*/
|
|
54
54
|
|
|
55
55
|
declare module "node:vm" {
|
|
56
|
-
import {
|
|
56
|
+
import { NonSharedBuffer } from 'node:buffer';
|
|
57
|
+
import { ImportAttributes, ImportPhase } from 'node:module';
|
|
57
58
|
interface Context extends NodeJS.Dict<any> {}
|
|
58
59
|
interface BaseOptions {
|
|
59
60
|
/**
|
|
@@ -76,19 +77,19 @@ declare module "node:vm" {
|
|
|
76
77
|
specifier: string,
|
|
77
78
|
referrer: T,
|
|
78
79
|
importAttributes: ImportAttributes,
|
|
79
|
-
phase:
|
|
80
|
+
phase: ImportPhase,
|
|
80
81
|
) => Module | Promise<Module>;
|
|
81
82
|
interface ScriptOptions extends BaseOptions {
|
|
82
83
|
/**
|
|
83
84
|
* Provides an optional data with V8's code cache data for the supplied source.
|
|
84
85
|
*/
|
|
85
|
-
cachedData?:
|
|
86
|
+
cachedData?: NodeJS.ArrayBufferView | undefined;
|
|
86
87
|
/** @deprecated in favor of `script.createCachedData()` */
|
|
87
88
|
produceCachedData?: boolean | undefined;
|
|
88
89
|
/**
|
|
89
90
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
|
90
91
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
|
91
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
|
92
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v25.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
|
92
93
|
* @experimental
|
|
93
94
|
*/
|
|
94
95
|
importModuleDynamically?:
|
|
@@ -115,32 +116,26 @@ declare module "node:vm" {
|
|
|
115
116
|
*/
|
|
116
117
|
breakOnSigint?: boolean | undefined;
|
|
117
118
|
}
|
|
118
|
-
interface RunningScriptInNewContextOptions
|
|
119
|
+
interface RunningScriptInNewContextOptions
|
|
120
|
+
extends RunningScriptOptions, Pick<CreateContextOptions, "microtaskMode">
|
|
121
|
+
{
|
|
119
122
|
/**
|
|
120
123
|
* Human-readable name of the newly created context.
|
|
121
124
|
*/
|
|
122
|
-
contextName?: CreateContextOptions["name"];
|
|
125
|
+
contextName?: CreateContextOptions["name"] | undefined;
|
|
123
126
|
/**
|
|
124
127
|
* Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL,
|
|
125
128
|
* but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object.
|
|
126
129
|
* Most notably, this string should omit the trailing slash, as that denotes a path.
|
|
127
130
|
*/
|
|
128
|
-
contextOrigin?: CreateContextOptions["origin"];
|
|
129
|
-
contextCodeGeneration?: CreateContextOptions["codeGeneration"];
|
|
130
|
-
/**
|
|
131
|
-
* If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
|
|
132
|
-
*/
|
|
133
|
-
microtaskMode?: CreateContextOptions["microtaskMode"];
|
|
131
|
+
contextOrigin?: CreateContextOptions["origin"] | undefined;
|
|
132
|
+
contextCodeGeneration?: CreateContextOptions["codeGeneration"] | undefined;
|
|
134
133
|
}
|
|
135
|
-
interface RunningCodeOptions extends RunningScriptOptions {
|
|
136
|
-
/**
|
|
137
|
-
* Provides an optional data with V8's code cache data for the supplied source.
|
|
138
|
-
*/
|
|
139
|
-
cachedData?: ScriptOptions["cachedData"] | undefined;
|
|
134
|
+
interface RunningCodeOptions extends RunningScriptOptions, Pick<ScriptOptions, "cachedData"> {
|
|
140
135
|
/**
|
|
141
136
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
|
142
137
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
|
143
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
|
138
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v25.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
|
144
139
|
* @experimental
|
|
145
140
|
*/
|
|
146
141
|
importModuleDynamically?:
|
|
@@ -148,15 +143,13 @@ declare module "node:vm" {
|
|
|
148
143
|
| typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
|
|
149
144
|
| undefined;
|
|
150
145
|
}
|
|
151
|
-
interface RunningCodeInNewContextOptions
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
*/
|
|
155
|
-
cachedData?: ScriptOptions["cachedData"] | undefined;
|
|
146
|
+
interface RunningCodeInNewContextOptions
|
|
147
|
+
extends RunningScriptInNewContextOptions, Pick<ScriptOptions, "cachedData">
|
|
148
|
+
{
|
|
156
149
|
/**
|
|
157
150
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
|
158
151
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
|
159
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
|
152
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v25.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
|
160
153
|
* @experimental
|
|
161
154
|
*/
|
|
162
155
|
importModuleDynamically?:
|
|
@@ -164,16 +157,7 @@ declare module "node:vm" {
|
|
|
164
157
|
| typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
|
|
165
158
|
| undefined;
|
|
166
159
|
}
|
|
167
|
-
interface CompileFunctionOptions extends BaseOptions {
|
|
168
|
-
/**
|
|
169
|
-
* Provides an optional data with V8's code cache data for the supplied source.
|
|
170
|
-
*/
|
|
171
|
-
cachedData?: ScriptOptions["cachedData"] | undefined;
|
|
172
|
-
/**
|
|
173
|
-
* Specifies whether to produce new cache data.
|
|
174
|
-
* @default false
|
|
175
|
-
*/
|
|
176
|
-
produceCachedData?: boolean | undefined;
|
|
160
|
+
interface CompileFunctionOptions extends BaseOptions, Pick<ScriptOptions, "cachedData" | "produceCachedData"> {
|
|
177
161
|
/**
|
|
178
162
|
* The sandbox/context in which the said function should be compiled in.
|
|
179
163
|
*/
|
|
@@ -185,7 +169,7 @@ declare module "node:vm" {
|
|
|
185
169
|
/**
|
|
186
170
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
|
187
171
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
|
188
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
|
172
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v25.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
|
189
173
|
* @experimental
|
|
190
174
|
*/
|
|
191
175
|
importModuleDynamically?:
|
|
@@ -229,7 +213,7 @@ declare module "node:vm" {
|
|
|
229
213
|
/**
|
|
230
214
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
|
231
215
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
|
232
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
|
216
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v25.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
|
233
217
|
* @experimental
|
|
234
218
|
*/
|
|
235
219
|
importModuleDynamically?:
|
|
@@ -400,17 +384,17 @@ declare module "node:vm" {
|
|
|
400
384
|
* ```
|
|
401
385
|
* @since v10.6.0
|
|
402
386
|
*/
|
|
403
|
-
createCachedData():
|
|
387
|
+
createCachedData(): NonSharedBuffer;
|
|
404
388
|
/** @deprecated in favor of `script.createCachedData()` */
|
|
405
|
-
cachedDataProduced?: boolean
|
|
389
|
+
cachedDataProduced?: boolean;
|
|
406
390
|
/**
|
|
407
391
|
* When `cachedData` is supplied to create the `vm.Script`, this value will be set
|
|
408
392
|
* to either `true` or `false` depending on acceptance of the data by V8.
|
|
409
393
|
* Otherwise the value is `undefined`.
|
|
410
394
|
* @since v5.7.0
|
|
411
395
|
*/
|
|
412
|
-
cachedDataRejected?: boolean
|
|
413
|
-
cachedData?:
|
|
396
|
+
cachedDataRejected?: boolean;
|
|
397
|
+
cachedData?: NonSharedBuffer;
|
|
414
398
|
/**
|
|
415
399
|
* When the script is compiled from a source that contains a source map magic
|
|
416
400
|
* comment, this property will be set to the URL of the source map.
|
|
@@ -428,13 +412,13 @@ declare module "node:vm" {
|
|
|
428
412
|
* ```
|
|
429
413
|
* @since v19.1.0, v18.13.0
|
|
430
414
|
*/
|
|
431
|
-
sourceMapURL
|
|
415
|
+
sourceMapURL: string | undefined;
|
|
432
416
|
}
|
|
433
417
|
/**
|
|
434
418
|
* If the given `contextObject` is an object, the `vm.createContext()` method will
|
|
435
|
-
* [prepare that object](https://nodejs.org/docs/latest-
|
|
419
|
+
* [prepare that object](https://nodejs.org/docs/latest-v25.x/api/vm.html#what-does-it-mean-to-contextify-an-object)
|
|
436
420
|
* and return a reference to it so that it can be used in calls to {@link runInContext} or
|
|
437
|
-
* [`script.runInContext()`](https://nodejs.org/docs/latest-
|
|
421
|
+
* [`script.runInContext()`](https://nodejs.org/docs/latest-v25.x/api/vm.html#scriptrunincontextcontextifiedobject-options).
|
|
438
422
|
* Inside such scripts, the global object will be wrapped by the `contextObject`, retaining all of its
|
|
439
423
|
* existing properties but also having the built-in objects and functions any standard
|
|
440
424
|
* [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global
|
|
@@ -638,11 +622,7 @@ declare module "node:vm" {
|
|
|
638
622
|
code: string,
|
|
639
623
|
params?: readonly string[],
|
|
640
624
|
options?: CompileFunctionOptions,
|
|
641
|
-
): Function &
|
|
642
|
-
cachedData?: Script["cachedData"] | undefined;
|
|
643
|
-
cachedDataProduced?: Script["cachedDataProduced"] | undefined;
|
|
644
|
-
cachedDataRejected?: Script["cachedDataRejected"] | undefined;
|
|
645
|
-
};
|
|
625
|
+
): Function & Pick<Script, "cachedData" | "cachedDataProduced" | "cachedDataRejected">;
|
|
646
626
|
/**
|
|
647
627
|
* Measure the memory known to V8 and used by all contexts known to the
|
|
648
628
|
* current V8 isolate, or the main context.
|
|
@@ -699,10 +679,7 @@ declare module "node:vm" {
|
|
|
699
679
|
* @experimental
|
|
700
680
|
*/
|
|
701
681
|
function measureMemory(options?: MeasureMemoryOptions): Promise<MemoryMeasurement>;
|
|
702
|
-
interface ModuleEvaluateOptions {
|
|
703
|
-
timeout?: RunningScriptOptions["timeout"] | undefined;
|
|
704
|
-
breakOnSigint?: RunningScriptOptions["breakOnSigint"] | undefined;
|
|
705
|
-
}
|
|
682
|
+
interface ModuleEvaluateOptions extends Pick<RunningScriptOptions, "breakOnSigint" | "timeout"> {}
|
|
706
683
|
type ModuleLinker = (
|
|
707
684
|
specifier: string,
|
|
708
685
|
referencingModule: Module,
|
|
@@ -716,14 +693,12 @@ declare module "node:vm" {
|
|
|
716
693
|
* flag enabled.
|
|
717
694
|
*
|
|
718
695
|
* The `vm.Module` class provides a low-level interface for using
|
|
719
|
-
* ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`
|
|
720
|
-
* defined in the ECMAScript
|
|
696
|
+
* ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`
|
|
697
|
+
* class that closely mirrors [Module Record](https://tc39.es/ecma262/#sec-abstract-module-records)s as defined in the ECMAScript
|
|
721
698
|
* specification.
|
|
722
699
|
*
|
|
723
700
|
* Unlike `vm.Script` however, every `vm.Module` object is bound to a context from
|
|
724
|
-
* its creation.
|
|
725
|
-
* in contrast with the synchronous nature of `vm.Script` objects. The use of
|
|
726
|
-
* 'async' functions can help with manipulating `vm.Module` objects.
|
|
701
|
+
* its creation.
|
|
727
702
|
*
|
|
728
703
|
* Using a `vm.Module` object requires three distinct steps: creation/parsing,
|
|
729
704
|
* linking, and evaluation. These three steps are illustrated in the following
|
|
@@ -751,7 +726,7 @@ declare module "node:vm" {
|
|
|
751
726
|
* // Here, we attempt to obtain the default export from the module "foo", and
|
|
752
727
|
* // put it into local binding "secret".
|
|
753
728
|
*
|
|
754
|
-
* const
|
|
729
|
+
* const rootModule = new vm.SourceTextModule(`
|
|
755
730
|
* import s from 'foo';
|
|
756
731
|
* s;
|
|
757
732
|
* print(s);
|
|
@@ -761,39 +736,48 @@ declare module "node:vm" {
|
|
|
761
736
|
* //
|
|
762
737
|
* // "Link" the imported dependencies of this Module to it.
|
|
763
738
|
* //
|
|
764
|
-
* //
|
|
765
|
-
* //
|
|
766
|
-
* // the imported module. The callback is expected to return a Module that
|
|
767
|
-
* // corresponds to the provided specifier, with certain requirements documented
|
|
768
|
-
* // in `module.link()`.
|
|
769
|
-
* //
|
|
770
|
-
* // If linking has not started for the returned Module, the same linker
|
|
771
|
-
* // callback will be called on the returned Module.
|
|
739
|
+
* // Obtain the requested dependencies of a SourceTextModule by
|
|
740
|
+
* // `sourceTextModule.moduleRequests` and resolve them.
|
|
772
741
|
* //
|
|
773
742
|
* // Even top-level Modules without dependencies must be explicitly linked. The
|
|
774
|
-
* //
|
|
775
|
-
* //
|
|
776
|
-
* // The link() method returns a Promise that will be resolved when all the
|
|
777
|
-
* // Promises returned by the linker resolve.
|
|
743
|
+
* // array passed to `sourceTextModule.linkRequests(modules)` can be
|
|
744
|
+
* // empty, however.
|
|
778
745
|
* //
|
|
779
|
-
* // Note: This is a contrived example in that the
|
|
780
|
-
* // "foo" module every time it is called. In a full-fledged
|
|
781
|
-
* // cache would probably be used to avoid duplicated modules.
|
|
746
|
+
* // Note: This is a contrived example in that the resolveAndLinkDependencies
|
|
747
|
+
* // creates a new "foo" module every time it is called. In a full-fledged
|
|
748
|
+
* // module system, a cache would probably be used to avoid duplicated modules.
|
|
749
|
+
*
|
|
750
|
+
* const moduleMap = new Map([
|
|
751
|
+
* ['root', rootModule],
|
|
752
|
+
* ]);
|
|
753
|
+
*
|
|
754
|
+
* function resolveAndLinkDependencies(module) {
|
|
755
|
+
* const requestedModules = module.moduleRequests.map((request) => {
|
|
756
|
+
* // In a full-fledged module system, the resolveAndLinkDependencies would
|
|
757
|
+
* // resolve the module with the module cache key `[specifier, attributes]`.
|
|
758
|
+
* // In this example, we just use the specifier as the key.
|
|
759
|
+
* const specifier = request.specifier;
|
|
760
|
+
*
|
|
761
|
+
* let requestedModule = moduleMap.get(specifier);
|
|
762
|
+
* if (requestedModule === undefined) {
|
|
763
|
+
* requestedModule = 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 });
|
|
768
|
+
* moduleMap.set(specifier, linkedModule);
|
|
769
|
+
* // Resolve the dependencies of the new module as well.
|
|
770
|
+
* resolveAndLinkDependencies(requestedModule);
|
|
771
|
+
* }
|
|
782
772
|
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
* return new vm.SourceTextModule(`
|
|
786
|
-
* // The "secret" variable refers to the global variable we added to
|
|
787
|
-
* // "contextifiedObject" when creating the context.
|
|
788
|
-
* export default secret;
|
|
789
|
-
* `, { context: referencingModule.context });
|
|
773
|
+
* return requestedModule;
|
|
774
|
+
* });
|
|
790
775
|
*
|
|
791
|
-
*
|
|
792
|
-
* // here would work as well.
|
|
793
|
-
* }
|
|
794
|
-
* throw new Error(`Unable to resolve dependency: ${specifier}`);
|
|
776
|
+
* module.linkRequests(requestedModules);
|
|
795
777
|
* }
|
|
796
|
-
*
|
|
778
|
+
*
|
|
779
|
+
* resolveAndLinkDependencies(rootModule);
|
|
780
|
+
* rootModule.instantiate();
|
|
797
781
|
*
|
|
798
782
|
* // Step 3
|
|
799
783
|
* //
|
|
@@ -801,20 +785,12 @@ declare module "node:vm" {
|
|
|
801
785
|
* // resolve after the module has finished evaluating.
|
|
802
786
|
*
|
|
803
787
|
* // Prints 42.
|
|
804
|
-
* await
|
|
788
|
+
* await rootModule.evaluate();
|
|
805
789
|
* ```
|
|
806
790
|
* @since v13.0.0, v12.16.0
|
|
807
791
|
* @experimental
|
|
808
792
|
*/
|
|
809
793
|
class Module {
|
|
810
|
-
/**
|
|
811
|
-
* The specifiers of all dependencies of this module. The returned array is frozen
|
|
812
|
-
* to disallow any changes to it.
|
|
813
|
-
*
|
|
814
|
-
* Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in
|
|
815
|
-
* the ECMAScript specification.
|
|
816
|
-
*/
|
|
817
|
-
dependencySpecifiers: readonly string[];
|
|
818
794
|
/**
|
|
819
795
|
* If the `module.status` is `'errored'`, this property contains the exception
|
|
820
796
|
* thrown by the module during evaluation. If the status is anything else,
|
|
@@ -879,6 +855,10 @@ declare module "node:vm" {
|
|
|
879
855
|
* Link module dependencies. This method must be called before evaluation, and
|
|
880
856
|
* can only be called once per module.
|
|
881
857
|
*
|
|
858
|
+
* Use `sourceTextModule.linkRequests(modules)` and
|
|
859
|
+
* `sourceTextModule.instantiate()` to link modules either synchronously or
|
|
860
|
+
* asynchronously.
|
|
861
|
+
*
|
|
882
862
|
* The function is expected to return a `Module` object or a `Promise` that
|
|
883
863
|
* eventually resolves to a `Module` object. The returned `Module` must satisfy the
|
|
884
864
|
* following two invariants:
|
|
@@ -909,19 +889,13 @@ declare module "node:vm" {
|
|
|
909
889
|
*/
|
|
910
890
|
link(linker: ModuleLinker): Promise<void>;
|
|
911
891
|
}
|
|
912
|
-
interface SourceTextModuleOptions {
|
|
892
|
+
interface SourceTextModuleOptions extends Pick<ScriptOptions, "cachedData" | "columnOffset" | "lineOffset"> {
|
|
913
893
|
/**
|
|
914
894
|
* String used in stack traces.
|
|
915
895
|
* @default 'vm:module(i)' where i is a context-specific ascending index.
|
|
916
896
|
*/
|
|
917
897
|
identifier?: string | undefined;
|
|
918
|
-
/**
|
|
919
|
-
* Provides an optional data with V8's code cache data for the supplied source.
|
|
920
|
-
*/
|
|
921
|
-
cachedData?: ScriptOptions["cachedData"] | undefined;
|
|
922
898
|
context?: Context | undefined;
|
|
923
|
-
lineOffset?: BaseOptions["lineOffset"] | undefined;
|
|
924
|
-
columnOffset?: BaseOptions["columnOffset"] | undefined;
|
|
925
899
|
/**
|
|
926
900
|
* Called during evaluation of this module to initialize the `import.meta`.
|
|
927
901
|
*/
|
|
@@ -929,11 +903,30 @@ declare module "node:vm" {
|
|
|
929
903
|
/**
|
|
930
904
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
|
931
905
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
|
932
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
|
906
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v25.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
|
933
907
|
* @experimental
|
|
934
908
|
*/
|
|
935
909
|
importModuleDynamically?: DynamicModuleLoader<SourceTextModule> | undefined;
|
|
936
910
|
}
|
|
911
|
+
/**
|
|
912
|
+
* A `ModuleRequest` represents the request to import a module with given import attributes and phase.
|
|
913
|
+
* @since 24.4.0
|
|
914
|
+
*/
|
|
915
|
+
interface ModuleRequest {
|
|
916
|
+
/**
|
|
917
|
+
* The specifier of the requested module.
|
|
918
|
+
*/
|
|
919
|
+
specifier: string;
|
|
920
|
+
/**
|
|
921
|
+
* The `"with"` value passed to the `WithClause` in a `ImportDeclaration`, or an empty object if no value was
|
|
922
|
+
* provided.
|
|
923
|
+
*/
|
|
924
|
+
attributes: ImportAttributes;
|
|
925
|
+
/**
|
|
926
|
+
* The phase of the requested module (`"source"` or `"evaluation"`).
|
|
927
|
+
*/
|
|
928
|
+
phase: ImportPhase;
|
|
929
|
+
}
|
|
937
930
|
/**
|
|
938
931
|
* This feature is only available with the `--experimental-vm-modules` command
|
|
939
932
|
* flag enabled.
|
|
@@ -946,9 +939,163 @@ declare module "node:vm" {
|
|
|
946
939
|
class SourceTextModule extends Module {
|
|
947
940
|
/**
|
|
948
941
|
* Creates a new `SourceTextModule` instance.
|
|
942
|
+
*
|
|
943
|
+
* Properties assigned to the `import.meta` object that are objects may
|
|
944
|
+
* allow the module to access information outside the specified `context`. Use
|
|
945
|
+
* `vm.runInContext()` to create objects in a specific context.
|
|
946
|
+
*
|
|
947
|
+
* ```js
|
|
948
|
+
* import vm from 'node:vm';
|
|
949
|
+
*
|
|
950
|
+
* const contextifiedObject = vm.createContext({ secret: 42 });
|
|
951
|
+
*
|
|
952
|
+
* const module = new vm.SourceTextModule(
|
|
953
|
+
* 'Object.getPrototypeOf(import.meta.prop).secret = secret;',
|
|
954
|
+
* {
|
|
955
|
+
* initializeImportMeta(meta) {
|
|
956
|
+
* // Note: this object is created in the top context. As such,
|
|
957
|
+
* // Object.getPrototypeOf(import.meta.prop) points to the
|
|
958
|
+
* // Object.prototype in the top context rather than that in
|
|
959
|
+
* // the contextified object.
|
|
960
|
+
* meta.prop = {};
|
|
961
|
+
* },
|
|
962
|
+
* });
|
|
963
|
+
* // The module has an empty `moduleRequests` array.
|
|
964
|
+
* module.linkRequests([]);
|
|
965
|
+
* module.instantiate();
|
|
966
|
+
* await module.evaluate();
|
|
967
|
+
*
|
|
968
|
+
* // Now, Object.prototype.secret will be equal to 42.
|
|
969
|
+
* //
|
|
970
|
+
* // To fix this problem, replace
|
|
971
|
+
* // meta.prop = {};
|
|
972
|
+
* // above with
|
|
973
|
+
* // meta.prop = vm.runInContext('{}', contextifiedObject);
|
|
974
|
+
* ```
|
|
949
975
|
* @param code JavaScript Module code to parse
|
|
950
976
|
*/
|
|
951
977
|
constructor(code: string, options?: SourceTextModuleOptions);
|
|
978
|
+
/**
|
|
979
|
+
* @deprecated Use `sourceTextModule.moduleRequests` instead.
|
|
980
|
+
*/
|
|
981
|
+
readonly dependencySpecifiers: readonly string[];
|
|
982
|
+
/**
|
|
983
|
+
* Iterates over the dependency graph and returns `true` if any module in its
|
|
984
|
+
* dependencies or this module itself contains top-level `await` expressions,
|
|
985
|
+
* otherwise returns `false`.
|
|
986
|
+
*
|
|
987
|
+
* The search may be slow if the graph is big enough.
|
|
988
|
+
*
|
|
989
|
+
* This requires the module to be instantiated first. If the module is not
|
|
990
|
+
* instantiated yet, an error will be thrown.
|
|
991
|
+
* @since v24.9.0
|
|
992
|
+
*/
|
|
993
|
+
hasAsyncGraph(): boolean;
|
|
994
|
+
/**
|
|
995
|
+
* Returns whether the module itself contains any top-level `await` expressions.
|
|
996
|
+
*
|
|
997
|
+
* This corresponds to the field `[[HasTLA]]` in [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) in the
|
|
998
|
+
* ECMAScript specification.
|
|
999
|
+
* @since v24.9.0
|
|
1000
|
+
*/
|
|
1001
|
+
hasTopLevelAwait(): boolean;
|
|
1002
|
+
/**
|
|
1003
|
+
* Instantiate the module with the linked requested modules.
|
|
1004
|
+
*
|
|
1005
|
+
* This resolves the imported bindings of the module, including re-exported
|
|
1006
|
+
* binding names. When there are any bindings that cannot be resolved,
|
|
1007
|
+
* an error would be thrown synchronously.
|
|
1008
|
+
*
|
|
1009
|
+
* If the requested modules include cyclic dependencies, the
|
|
1010
|
+
* `sourceTextModule.linkRequests(modules)` method must be called on all
|
|
1011
|
+
* modules in the cycle before calling this method.
|
|
1012
|
+
* @since v24.8.0
|
|
1013
|
+
*/
|
|
1014
|
+
instantiate(): void;
|
|
1015
|
+
/**
|
|
1016
|
+
* Link module dependencies. This method must be called before evaluation, and
|
|
1017
|
+
* can only be called once per module.
|
|
1018
|
+
*
|
|
1019
|
+
* The order of the module instances in the `modules` array should correspond to the order of
|
|
1020
|
+
* `sourceTextModule.moduleRequests` being resolved. If two module requests have the same
|
|
1021
|
+
* specifier and import attributes, they must be resolved with the same module instance or an
|
|
1022
|
+
* `ERR_MODULE_LINK_MISMATCH` would be thrown. For example, when linking requests for this
|
|
1023
|
+
* module:
|
|
1024
|
+
*
|
|
1025
|
+
* ```js
|
|
1026
|
+
* import foo from 'foo';
|
|
1027
|
+
* import source Foo from 'foo';
|
|
1028
|
+
* ```
|
|
1029
|
+
*
|
|
1030
|
+
* The `modules` array must contain two references to the same instance, because the two
|
|
1031
|
+
* module requests are identical but in two phases.
|
|
1032
|
+
*
|
|
1033
|
+
* If the module has no dependencies, the `modules` array can be empty.
|
|
1034
|
+
*
|
|
1035
|
+
* Users can use `sourceTextModule.moduleRequests` to implement the host-defined
|
|
1036
|
+
* [HostLoadImportedModule](https://tc39.es/ecma262/#sec-HostLoadImportedModule) abstract operation in the ECMAScript specification,
|
|
1037
|
+
* and using `sourceTextModule.linkRequests()` to invoke specification defined
|
|
1038
|
+
* [FinishLoadingImportedModule](https://tc39.es/ecma262/#sec-FinishLoadingImportedModule), on the module with all dependencies in a batch.
|
|
1039
|
+
*
|
|
1040
|
+
* It's up to the creator of the `SourceTextModule` to determine if the resolution
|
|
1041
|
+
* of the dependencies is synchronous or asynchronous.
|
|
1042
|
+
*
|
|
1043
|
+
* After each module in the `modules` array is linked, call
|
|
1044
|
+
* `sourceTextModule.instantiate()`.
|
|
1045
|
+
* @since v24.8.0
|
|
1046
|
+
* @param modules Array of `vm.Module` objects that this module depends on.
|
|
1047
|
+
* The order of the modules in the array is the order of
|
|
1048
|
+
* `sourceTextModule.moduleRequests`.
|
|
1049
|
+
*/
|
|
1050
|
+
linkRequests(modules: readonly Module[]): void;
|
|
1051
|
+
/**
|
|
1052
|
+
* The requested import dependencies of this module. The returned array is frozen
|
|
1053
|
+
* to disallow any changes to it.
|
|
1054
|
+
*
|
|
1055
|
+
* For example, given a source text:
|
|
1056
|
+
*
|
|
1057
|
+
* ```js
|
|
1058
|
+
* import foo from 'foo';
|
|
1059
|
+
* import fooAlias from 'foo';
|
|
1060
|
+
* import bar from './bar.js';
|
|
1061
|
+
* import withAttrs from '../with-attrs.ts' with { arbitraryAttr: 'attr-val' };
|
|
1062
|
+
* import source Module from 'wasm-mod.wasm';
|
|
1063
|
+
* ```
|
|
1064
|
+
*
|
|
1065
|
+
* The value of the `sourceTextModule.moduleRequests` will be:
|
|
1066
|
+
*
|
|
1067
|
+
* ```js
|
|
1068
|
+
* [
|
|
1069
|
+
* {
|
|
1070
|
+
* specifier: 'foo',
|
|
1071
|
+
* attributes: {},
|
|
1072
|
+
* phase: 'evaluation',
|
|
1073
|
+
* },
|
|
1074
|
+
* {
|
|
1075
|
+
* specifier: 'foo',
|
|
1076
|
+
* attributes: {},
|
|
1077
|
+
* phase: 'evaluation',
|
|
1078
|
+
* },
|
|
1079
|
+
* {
|
|
1080
|
+
* specifier: './bar.js',
|
|
1081
|
+
* attributes: {},
|
|
1082
|
+
* phase: 'evaluation',
|
|
1083
|
+
* },
|
|
1084
|
+
* {
|
|
1085
|
+
* specifier: '../with-attrs.ts',
|
|
1086
|
+
* attributes: { arbitraryAttr: 'attr-val' },
|
|
1087
|
+
* phase: 'evaluation',
|
|
1088
|
+
* },
|
|
1089
|
+
* {
|
|
1090
|
+
* specifier: 'wasm-mod.wasm',
|
|
1091
|
+
* attributes: {},
|
|
1092
|
+
* phase: 'source',
|
|
1093
|
+
* },
|
|
1094
|
+
* ];
|
|
1095
|
+
* ```
|
|
1096
|
+
* @since v24.4.0
|
|
1097
|
+
*/
|
|
1098
|
+
readonly moduleRequests: readonly ModuleRequest[];
|
|
952
1099
|
}
|
|
953
1100
|
interface SyntheticModuleOptions {
|
|
954
1101
|
/**
|
|
@@ -996,9 +1143,7 @@ declare module "node:vm" {
|
|
|
996
1143
|
options?: SyntheticModuleOptions,
|
|
997
1144
|
);
|
|
998
1145
|
/**
|
|
999
|
-
* This method
|
|
1000
|
-
* it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error
|
|
1001
|
-
* will be thrown.
|
|
1146
|
+
* This method sets the module export binding slots with the given value.
|
|
1002
1147
|
*
|
|
1003
1148
|
* ```js
|
|
1004
1149
|
* import vm from 'node:vm';
|
|
@@ -1007,7 +1152,6 @@ declare module "node:vm" {
|
|
|
1007
1152
|
* m.setExport('x', 1);
|
|
1008
1153
|
* });
|
|
1009
1154
|
*
|
|
1010
|
-
* await m.link(() => {});
|
|
1011
1155
|
* await m.evaluate();
|
|
1012
1156
|
*
|
|
1013
1157
|
* assert.strictEqual(m.namespace.x, 1);
|
|
@@ -1028,7 +1172,7 @@ declare module "node:vm" {
|
|
|
1028
1172
|
* and `vm.compileFunction()` so that Node.js uses the default ESM loader from the main
|
|
1029
1173
|
* context to load the requested module.
|
|
1030
1174
|
*
|
|
1031
|
-
* For detailed information, see [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
|
1175
|
+
* For detailed information, see [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v25.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
|
1032
1176
|
* @since v21.7.0, v20.12.0
|
|
1033
1177
|
*/
|
|
1034
1178
|
const USE_MAIN_CONTEXT_DEFAULT_LOADER: number;
|
package/wasi.d.ts
CHANGED
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
* wat2wasm demo.wat
|
|
83
83
|
* ```
|
|
84
84
|
* @experimental
|
|
85
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
85
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/wasi.js)
|
|
86
86
|
*/
|
|
87
87
|
|
|
88
88
|
declare module "node:wasi" {
|
|
@@ -93,7 +93,7 @@ declare module "node:wasi" {
|
|
|
93
93
|
* WASI command itself.
|
|
94
94
|
* @default []
|
|
95
95
|
*/
|
|
96
|
-
args?: string[] | undefined;
|
|
96
|
+
args?: readonly string[] | undefined;
|
|
97
97
|
/**
|
|
98
98
|
* An object similar to `process.env` that the WebAssembly
|
|
99
99
|
* application will see as its environment.
|
|
@@ -137,6 +137,12 @@ declare module "node:wasi" {
|
|
|
137
137
|
*/
|
|
138
138
|
version: "unstable" | "preview1";
|
|
139
139
|
}
|
|
140
|
+
interface FinalizeBindingsOptions {
|
|
141
|
+
/**
|
|
142
|
+
* @default instance.exports.memory
|
|
143
|
+
*/
|
|
144
|
+
memory?: object | undefined;
|
|
145
|
+
}
|
|
140
146
|
/**
|
|
141
147
|
* The `WASI` class provides the WASI system call API and additional convenience
|
|
142
148
|
* methods for working with WASI-based applications. Each `WASI` instance
|
|
@@ -183,6 +189,21 @@ declare module "node:wasi" {
|
|
|
183
189
|
* @since v14.6.0, v12.19.0
|
|
184
190
|
*/
|
|
185
191
|
initialize(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
|
|
192
|
+
/**
|
|
193
|
+
* Set up WASI host bindings to `instance` without calling `initialize()`
|
|
194
|
+
* or `start()`. This method is useful when the WASI module is instantiated in
|
|
195
|
+
* child threads for sharing the memory across threads.
|
|
196
|
+
*
|
|
197
|
+
* `finalizeBindings()` requires that either `instance` exports a
|
|
198
|
+
* [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named `memory` or user specify a
|
|
199
|
+
* [`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
|
|
200
|
+
* an exception is thrown.
|
|
201
|
+
*
|
|
202
|
+
* `start()` and `initialize()` will call `finalizeBindings()` internally.
|
|
203
|
+
* If `finalizeBindings()` is called more than once, an exception is thrown.
|
|
204
|
+
* @since v24.4.0
|
|
205
|
+
*/
|
|
206
|
+
finalizeBindings(instance: object, options?: FinalizeBindingsOptions): void;
|
|
186
207
|
/**
|
|
187
208
|
* `wasiImport` is an object that implements the WASI system call API. This object
|
|
188
209
|
* should be passed as the `wasi_snapshot_preview1` import during the instantiation
|