@types/node 16.18.90 → 16.18.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node v16.18/README.md +1 -1
- node v16.18/cluster.d.ts +181 -39
- node v16.18/package.json +2 -2
- node v16.18/wasi.d.ts +11 -9
node v16.18/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v16.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Sat, 30 Mar 2024 04:35:27 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
|
|
14
14
|
# Credits
|
node v16.18/cluster.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Clusters of Node.js processes can be used to run multiple instances of Node.js
|
|
3
|
+
* that can distribute workloads among their application threads. When process isolation
|
|
4
|
+
* is not needed, use the [`worker_threads`](https://nodejs.org/docs/latest-v16.x/api/worker_threads.html)
|
|
5
|
+
* module instead, which allows running multiple application threads within a single Node.js instance.
|
|
5
6
|
*
|
|
6
7
|
* The cluster module allows easy creation of child processes that all share
|
|
7
8
|
* server ports.
|
|
8
9
|
*
|
|
9
10
|
* ```js
|
|
10
|
-
* import cluster from 'cluster';
|
|
11
|
-
* import http from 'http';
|
|
12
|
-
* import { cpus } from 'os';
|
|
13
|
-
* import process from 'process';
|
|
11
|
+
* import cluster from 'node:cluster';
|
|
12
|
+
* import http from 'node:http';
|
|
13
|
+
* import { cpus } from 'node:os';
|
|
14
|
+
* import process from 'node:process';
|
|
14
15
|
*
|
|
15
16
|
* const numCPUs = cpus().length;
|
|
16
17
|
*
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
* ```
|
|
50
51
|
*
|
|
51
52
|
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
|
52
|
-
* @see [source](https://github.com/nodejs/node/blob/v16.
|
|
53
|
+
* @see [source](https://github.com/nodejs/node/blob/v16.20.2/lib/cluster.js)
|
|
53
54
|
*/
|
|
54
55
|
declare module "cluster" {
|
|
55
56
|
import * as child from "node:child_process";
|
|
@@ -57,22 +58,74 @@ declare module "cluster" {
|
|
|
57
58
|
import * as net from "node:net";
|
|
58
59
|
type SerializationType = "json" | "advanced";
|
|
59
60
|
export interface ClusterSettings {
|
|
60
|
-
|
|
61
|
+
/**
|
|
62
|
+
* List of string arguments passed to the Node.js executable.
|
|
63
|
+
* @default process.execArgv
|
|
64
|
+
*/
|
|
65
|
+
execArgv?: string[] | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* File path to worker file.
|
|
68
|
+
* @default process.argv[1]
|
|
69
|
+
*/
|
|
61
70
|
exec?: string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* String arguments passed to worker.
|
|
73
|
+
* @default process.argv.slice(2)
|
|
74
|
+
*/
|
|
62
75
|
args?: string[] | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Whether or not to send output to parent's stdio.
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
63
80
|
silent?: boolean | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Configures the stdio of forked processes. Because the cluster module relies on IPC to function, this configuration must
|
|
83
|
+
* contain an `'ipc'` entry. When this option is provided, it overrides `silent`. See [`child_prcess.spawn()`](https://nodejs.org/docs/latest-v16.x/api/child_process.html#child_processspawncommand-args-options)'s
|
|
84
|
+
* [`stdio`](https://nodejs.org/docs/latest-v16.x/api/child_process.html#optionsstdio).
|
|
85
|
+
*/
|
|
64
86
|
stdio?: any[] | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Sets the user identity of the process. (See [`setuid(2)`](https://man7.org/linux/man-pages/man2/setuid.2.html).)
|
|
89
|
+
*/
|
|
65
90
|
uid?: number | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Sets the group identity of the process. (See [`setgid(2)`](https://man7.org/linux/man-pages/man2/setgid.2.html).)
|
|
93
|
+
*/
|
|
66
94
|
gid?: number | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Sets inspector port of worker. This can be a number, or a function that takes no arguments and returns a number.
|
|
97
|
+
* By default each worker gets its own port, incremented from the primary's `process.debugPort`.
|
|
98
|
+
*/
|
|
67
99
|
inspectPort?: number | (() => number) | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`.
|
|
102
|
+
* See [Advanced serialization for `child_process`](https://nodejs.org/docs/latest-v16.x/api/child_process.html#advanced-serialization) for more details.
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
68
105
|
serialization?: SerializationType | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Current working directory of the worker process.
|
|
108
|
+
* @default undefined (inherits from parent process)
|
|
109
|
+
*/
|
|
69
110
|
cwd?: string | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Hide the forked processes console window that would normally be created on Windows systems.
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
70
115
|
windowsHide?: boolean | undefined;
|
|
71
116
|
}
|
|
72
117
|
export interface Address {
|
|
73
118
|
address: string;
|
|
74
119
|
port: number;
|
|
75
|
-
|
|
120
|
+
/**
|
|
121
|
+
* The `addressType` is one of:
|
|
122
|
+
*
|
|
123
|
+
* * `4` (TCPv4)
|
|
124
|
+
* * `6` (TCPv6)
|
|
125
|
+
* * `-1` (Unix domain socket)
|
|
126
|
+
* * `'udp4'` or `'udp6'` (UDPv4 or UDPv6)
|
|
127
|
+
*/
|
|
128
|
+
addressType: 4 | 6 | -1 | "udp4" | "udp6";
|
|
76
129
|
}
|
|
77
130
|
/**
|
|
78
131
|
* A `Worker` object contains all public information and method about a worker.
|
|
@@ -82,17 +135,17 @@ declare module "cluster" {
|
|
|
82
135
|
*/
|
|
83
136
|
export class Worker extends EventEmitter {
|
|
84
137
|
/**
|
|
85
|
-
* Each new worker is given its own unique id, this id is stored in the`id`.
|
|
138
|
+
* Each new worker is given its own unique id, this id is stored in the `id`.
|
|
86
139
|
*
|
|
87
|
-
* While a worker is alive, this is the key that indexes it in`cluster.workers`.
|
|
140
|
+
* While a worker is alive, this is the key that indexes it in `cluster.workers`.
|
|
88
141
|
* @since v0.8.0
|
|
89
142
|
*/
|
|
90
143
|
id: number;
|
|
91
144
|
/**
|
|
92
|
-
* All workers are created using `child_process.fork()
|
|
93
|
-
* from this function is stored as `.process`. In a worker, the global `process`is stored.
|
|
145
|
+
* All workers are created using [`child_process.fork()`](https://nodejs.org/docs/latest-v16.x/api/child_process.html#child_processforkmodulepath-args-options), the returned object
|
|
146
|
+
* from this function is stored as `.process`. In a worker, the global `process` is stored.
|
|
94
147
|
*
|
|
95
|
-
* See:
|
|
148
|
+
* See: [Child Process module](https://nodejs.org/docs/latest-v16.x/api/child_process.html#child_processforkmodulepath-args-options).
|
|
96
149
|
*
|
|
97
150
|
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
|
98
151
|
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
|
@@ -103,9 +156,9 @@ declare module "cluster" {
|
|
|
103
156
|
/**
|
|
104
157
|
* Send a message to a worker or primary, optionally with a handle.
|
|
105
158
|
*
|
|
106
|
-
* In the primary this sends a message to a specific worker. It is identical to `ChildProcess.send()
|
|
159
|
+
* In the primary, this sends a message to a specific worker. It is identical to [`ChildProcess.send()`](https://nodejs.org/docs/latest-v16.x/api/child_process.html#subprocesssendmessage-sendhandle-options-callback).
|
|
107
160
|
*
|
|
108
|
-
* In a worker this sends a message to the primary. It is identical to`process.send()`.
|
|
161
|
+
* In a worker, this sends a message to the primary. It is identical to `process.send()`.
|
|
109
162
|
*
|
|
110
163
|
* This example will echo back all messages from the primary:
|
|
111
164
|
*
|
|
@@ -121,7 +174,7 @@ declare module "cluster" {
|
|
|
121
174
|
* }
|
|
122
175
|
* ```
|
|
123
176
|
* @since v0.7.0
|
|
124
|
-
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles.
|
|
177
|
+
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles.
|
|
125
178
|
*/
|
|
126
179
|
send(message: child.Serializable, callback?: (error: Error | null) => void): boolean;
|
|
127
180
|
send(
|
|
@@ -136,22 +189,16 @@ declare module "cluster" {
|
|
|
136
189
|
callback?: (error: Error | null) => void,
|
|
137
190
|
): boolean;
|
|
138
191
|
/**
|
|
139
|
-
* This function will kill the worker. In the primary, it does this
|
|
140
|
-
*
|
|
141
|
-
* with `signal`. In the worker, it does it by disconnecting the channel,
|
|
142
|
-
* and then exiting with code `0`.
|
|
192
|
+
* This function will kill the worker. In the primary worker, it does this by
|
|
193
|
+
* disconnecting the `worker.process`, and once disconnected, killing with `signal`. In the worker, it does it by killing the process with `signal`.
|
|
143
194
|
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* if the worker enters an infinite loop, a graceful disconnect will never occur.
|
|
147
|
-
* If the graceful disconnect behavior is not needed, use `worker.process.kill()`.
|
|
148
|
-
*
|
|
149
|
-
* Causes `.exitedAfterDisconnect` to be set.
|
|
195
|
+
* The `kill()` function kills the worker process without waiting for a graceful
|
|
196
|
+
* disconnect, it has the same behavior as `worker.process.kill()`.
|
|
150
197
|
*
|
|
151
|
-
* This method is aliased as `worker.destroy()` for
|
|
198
|
+
* This method is aliased as `worker.destroy()` for backwards compatibility.
|
|
152
199
|
*
|
|
153
200
|
* In a worker, `process.kill()` exists, but it is not this function;
|
|
154
|
-
* it is `kill()
|
|
201
|
+
* it is [`kill()`](https://nodejs.org/docs/latest-v16.x/api/process.html#processkillpid-signal).
|
|
155
202
|
* @since v0.9.12
|
|
156
203
|
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
|
|
157
204
|
*/
|
|
@@ -161,7 +208,7 @@ declare module "cluster" {
|
|
|
161
208
|
* In a worker, this function will close all servers, wait for the `'close'` event
|
|
162
209
|
* on those servers, and then disconnect the IPC channel.
|
|
163
210
|
*
|
|
164
|
-
* In the primary, an internal message is sent to the worker causing it to call`.disconnect()` on itself.
|
|
211
|
+
* In the primary, an internal message is sent to the worker causing it to call `.disconnect()` on itself.
|
|
165
212
|
*
|
|
166
213
|
* Causes `.exitedAfterDisconnect` to be set.
|
|
167
214
|
*
|
|
@@ -201,7 +248,7 @@ declare module "cluster" {
|
|
|
201
248
|
* });
|
|
202
249
|
*
|
|
203
250
|
* } else if (cluster.isWorker) {
|
|
204
|
-
* const net = require('net');
|
|
251
|
+
* const net = require('node:net');
|
|
205
252
|
* const server = net.createServer((socket) => {
|
|
206
253
|
* // Connections never end
|
|
207
254
|
* });
|
|
@@ -231,10 +278,10 @@ declare module "cluster" {
|
|
|
231
278
|
* because of exiting or being signaled). Otherwise, it returns `false`.
|
|
232
279
|
*
|
|
233
280
|
* ```js
|
|
234
|
-
* import cluster from 'cluster';
|
|
235
|
-
* import http from 'http';
|
|
236
|
-
* import { cpus } from 'os';
|
|
237
|
-
* import process from 'process';
|
|
281
|
+
* import cluster from 'node:cluster';
|
|
282
|
+
* import http from 'node:http';
|
|
283
|
+
* import { cpus } from 'node:os';
|
|
284
|
+
* import process from 'node:process';
|
|
238
285
|
*
|
|
239
286
|
* const numCPUs = cpus().length;
|
|
240
287
|
*
|
|
@@ -266,7 +313,8 @@ declare module "cluster" {
|
|
|
266
313
|
*/
|
|
267
314
|
isDead(): boolean;
|
|
268
315
|
/**
|
|
269
|
-
* This property is `true` if the worker exited due to `.
|
|
316
|
+
* This property is `true` if the worker exited due to `.disconnect()`.
|
|
317
|
+
* If the worker exited any other way, it is `false`. If the
|
|
270
318
|
* worker has not exited, it is `undefined`.
|
|
271
319
|
*
|
|
272
320
|
* The boolean `worker.exitedAfterDisconnect` allows distinguishing between
|
|
@@ -340,20 +388,114 @@ declare module "cluster" {
|
|
|
340
388
|
}
|
|
341
389
|
export interface Cluster extends EventEmitter {
|
|
342
390
|
disconnect(callback?: () => void): void;
|
|
391
|
+
/**
|
|
392
|
+
* Spawn a new worker process.
|
|
393
|
+
*
|
|
394
|
+
* This can only be called from the primary process.
|
|
395
|
+
* @param env Key/value pairs to add to worker process environment.
|
|
396
|
+
* @since v0.6.0
|
|
397
|
+
*/
|
|
343
398
|
fork(env?: any): Worker;
|
|
344
399
|
/** @deprecated since v16.0.0 - use isPrimary. */
|
|
345
400
|
readonly isMaster: boolean;
|
|
401
|
+
/**
|
|
402
|
+
* True if the process is a primary. This is determined by the `process.env.NODE_UNIQUE_ID`. If `process.env.NODE_UNIQUE_ID`
|
|
403
|
+
* is undefined, then `isPrimary` is `true`.
|
|
404
|
+
* @since v16.0.0
|
|
405
|
+
*/
|
|
346
406
|
readonly isPrimary: boolean;
|
|
407
|
+
/**
|
|
408
|
+
* True if the process is not a primary (it is the negation of `cluster.isPrimary`).
|
|
409
|
+
* @since v0.6.0
|
|
410
|
+
*/
|
|
347
411
|
readonly isWorker: boolean;
|
|
412
|
+
/**
|
|
413
|
+
* The scheduling policy, either `cluster.SCHED_RR` for round-robin or `cluster.SCHED_NONE` to leave it to the operating system. This is a
|
|
414
|
+
* global setting and effectively frozen once either the first worker is spawned, or [`.setupPrimary()`](https://nodejs.org/docs/latest-v16.x/api/cluster.html#clustersetupprimarysettings)
|
|
415
|
+
* is called, whichever comes first.
|
|
416
|
+
*
|
|
417
|
+
* `SCHED_RR` is the default on all operating systems except Windows. Windows will change to `SCHED_RR` once libuv is able to effectively distribute
|
|
418
|
+
* IOCP handles without incurring a large performance hit.
|
|
419
|
+
*
|
|
420
|
+
* `cluster.schedulingPolicy` can also be set through the `NODE_CLUSTER_SCHED_POLICY` environment variable. Valid values are `'rr'` and `'none'`.
|
|
421
|
+
* @since v0.11.2
|
|
422
|
+
*/
|
|
348
423
|
schedulingPolicy: number;
|
|
424
|
+
/**
|
|
425
|
+
* After calling [`.setupPrimary()`](https://nodejs.org/docs/latest-v16.x/api/cluster.html#clustersetupprimarysettings)
|
|
426
|
+
* (or [`.fork()`](https://nodejs.org/docs/latest-v16.x/api/cluster.html#clusterforkenv)) this settings object will contain
|
|
427
|
+
* the settings, including the default values.
|
|
428
|
+
*
|
|
429
|
+
* This object is not intended to be changed or set manually.
|
|
430
|
+
* @since v0.7.1
|
|
431
|
+
*/
|
|
349
432
|
readonly settings: ClusterSettings;
|
|
350
|
-
/** @deprecated since v16.0.0 - use setupPrimary. */
|
|
433
|
+
/** @deprecated since v16.0.0 - use [`.setupPrimary()`](https://nodejs.org/docs/latest-v16.x/api/cluster.html#clustersetupprimarysettings) instead. */
|
|
351
434
|
setupMaster(settings?: ClusterSettings): void;
|
|
352
435
|
/**
|
|
353
|
-
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings
|
|
436
|
+
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in `cluster.settings`.
|
|
437
|
+
*
|
|
438
|
+
* Any settings changes only affect future calls to [`.fork()`](https://nodejs.org/docs/latest-v16.x/api/cluster.html#clusterforkenv)
|
|
439
|
+
* and have no effect on workers that are already running.
|
|
440
|
+
*
|
|
441
|
+
* The only attribute of a worker that cannot be set via `.setupPrimary()` is the `env` passed to
|
|
442
|
+
* [`.fork()`](https://nodejs.org/docs/latest-v16.x/api/cluster.html#clusterforkenv).
|
|
443
|
+
*
|
|
444
|
+
* The defaults above apply to the first call only; the defaults for later calls are the current values at the time of
|
|
445
|
+
* `cluster.setupPrimary()` is called.
|
|
446
|
+
*
|
|
447
|
+
* ```js
|
|
448
|
+
* import cluster from 'node:cluster';
|
|
449
|
+
*
|
|
450
|
+
* cluster.setupPrimary({
|
|
451
|
+
* exec: 'worker.js',
|
|
452
|
+
* args: ['--use', 'https'],
|
|
453
|
+
* silent: true,
|
|
454
|
+
* });
|
|
455
|
+
* cluster.fork(); // https worker
|
|
456
|
+
* cluster.setupPrimary({
|
|
457
|
+
* exec: 'worker.js',
|
|
458
|
+
* args: ['--use', 'http'],
|
|
459
|
+
* });
|
|
460
|
+
* cluster.fork(); // http worker
|
|
461
|
+
* ```
|
|
462
|
+
*
|
|
463
|
+
* This can only be called from the primary process.
|
|
464
|
+
* @since v16.0.0
|
|
354
465
|
*/
|
|
355
466
|
setupPrimary(settings?: ClusterSettings): void;
|
|
467
|
+
/**
|
|
468
|
+
* A reference to the current worker object. Not available in the primary process.
|
|
469
|
+
*
|
|
470
|
+
* ```js
|
|
471
|
+
* import cluster from 'node:cluster';
|
|
472
|
+
*
|
|
473
|
+
* if (cluster.isPrimary) {
|
|
474
|
+
* console.log('I am primary');
|
|
475
|
+
* cluster.fork();
|
|
476
|
+
* cluster.fork();
|
|
477
|
+
* } else if (cluster.isWorker) {
|
|
478
|
+
* console.log(`I am worker #${cluster.worker.id}`);
|
|
479
|
+
* }
|
|
480
|
+
* ```
|
|
481
|
+
* @since v0.7.0
|
|
482
|
+
*/
|
|
356
483
|
readonly worker?: Worker | undefined;
|
|
484
|
+
/**
|
|
485
|
+
* A hash that stores the active worker objects, keyed by `id` field. This makes it easy to loop through all the workers. It is only available in the primary process.
|
|
486
|
+
*
|
|
487
|
+
* A worker is removed from `cluster.workers` after the worker has disconnected _and_ exited. The order between these two events cannot be determined in advance. However, it
|
|
488
|
+
* is guaranteed that the removal from the `cluster.workers` list happens before the last `'disconnect'` or `'exit'` event is emitted.
|
|
489
|
+
*
|
|
490
|
+
* ```js
|
|
491
|
+
* import cluster from 'node:cluster';
|
|
492
|
+
*
|
|
493
|
+
* for (const worker of Object.values(cluster.workers)) {
|
|
494
|
+
* worker.send('big announcement to all workers');
|
|
495
|
+
* }
|
|
496
|
+
* ```
|
|
497
|
+
* @since v0.7.0
|
|
498
|
+
*/
|
|
357
499
|
readonly workers?: NodeJS.Dict<Worker> | undefined;
|
|
358
500
|
readonly SCHED_NONE: number;
|
|
359
501
|
readonly SCHED_RR: number;
|
node v16.18/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "16.18.
|
|
3
|
+
"version": "16.18.92",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -210,6 +210,6 @@
|
|
|
210
210
|
},
|
|
211
211
|
"scripts": {},
|
|
212
212
|
"dependencies": {},
|
|
213
|
-
"typesPublisherContentHash": "
|
|
213
|
+
"typesPublisherContentHash": "5926ea4342bdadbbc3f973f76497521e341f6a861f8f1cca1dce23edf058bb82",
|
|
214
214
|
"typeScriptVersion": "4.7"
|
|
215
215
|
}
|
node v16.18/wasi.d.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* underlying operating system via a collection of POSIX-like functions.
|
|
4
4
|
*
|
|
5
5
|
* ```js
|
|
6
|
-
* import { readFile } from 'fs/promises';
|
|
6
|
+
* import { readFile } from 'node:fs/promises';
|
|
7
7
|
* import { WASI } from 'wasi';
|
|
8
|
-
* import { argv, env } from 'process';
|
|
8
|
+
* import { argv, env } from 'node:process';
|
|
9
9
|
*
|
|
10
10
|
* const wasi = new WASI({
|
|
11
11
|
* args: argv,
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* wasi.start(instance);
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
-
* To run the above example, create a new WebAssembly text format file named`demo.wat`:
|
|
30
|
+
* To run the above example, create a new WebAssembly text format file named `demo.wat`:
|
|
31
31
|
*
|
|
32
32
|
* ```text
|
|
33
33
|
* (module
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
* The `--experimental-wasi-unstable-preview1` CLI argument is needed for this
|
|
69
69
|
* example to run.
|
|
70
70
|
* @experimental
|
|
71
|
-
* @see [source](https://github.com/nodejs/node/blob/v16.
|
|
71
|
+
* @see [source](https://github.com/nodejs/node/blob/v16.20.2/lib/wasi.js)
|
|
72
72
|
*/
|
|
73
73
|
declare module "wasi" {
|
|
74
74
|
interface WASIOptions {
|
|
@@ -76,11 +76,13 @@ declare module "wasi" {
|
|
|
76
76
|
* An array of strings that the WebAssembly application will
|
|
77
77
|
* see as command line arguments. The first argument is the virtual path to the
|
|
78
78
|
* WASI command itself.
|
|
79
|
+
* @default []
|
|
79
80
|
*/
|
|
80
81
|
args?: string[] | undefined;
|
|
81
82
|
/**
|
|
82
83
|
* An object similar to `process.env` that the WebAssembly
|
|
83
84
|
* application will see as its environment.
|
|
85
|
+
* @default {}
|
|
84
86
|
*/
|
|
85
87
|
env?: object | undefined;
|
|
86
88
|
/**
|
|
@@ -117,17 +119,17 @@ declare module "wasi" {
|
|
|
117
119
|
/**
|
|
118
120
|
* The `WASI` class provides the WASI system call API and additional convenience
|
|
119
121
|
* methods for working with WASI-based applications. Each `WASI` instance
|
|
120
|
-
* represents a distinct sandbox environment. For security purposes, each `WASI`instance must have its command-line arguments, environment variables, and
|
|
122
|
+
* represents a distinct sandbox environment. For security purposes, each `WASI` instance must have its command-line arguments, environment variables, and
|
|
121
123
|
* sandbox directory structure configured explicitly.
|
|
122
124
|
* @since v13.3.0, v12.16.0
|
|
123
125
|
*/
|
|
124
126
|
class WASI {
|
|
125
127
|
constructor(options?: WASIOptions);
|
|
126
128
|
/**
|
|
127
|
-
* Attempt to begin execution of `instance` as a WASI command by invoking its`_start()` export. If `instance` does not contain a `_start()` export, or if`instance` contains an `_initialize()`
|
|
129
|
+
* Attempt to begin execution of `instance` as a WASI command by invoking its `_start()` export. If `instance` does not contain a `_start()` export, or if `instance` contains an `_initialize()`
|
|
128
130
|
* export, then an exception is thrown.
|
|
129
131
|
*
|
|
130
|
-
* `start()` requires that `instance` exports a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named`memory`. If
|
|
132
|
+
* `start()` requires that `instance` exports a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named `memory`. If
|
|
131
133
|
* `instance` does not have a `memory` export an exception is thrown.
|
|
132
134
|
*
|
|
133
135
|
* If `start()` is called more than once, an exception is thrown.
|
|
@@ -135,9 +137,9 @@ declare module "wasi" {
|
|
|
135
137
|
*/
|
|
136
138
|
start(instance: object): number; // TODO: avoid DOM dependency until WASM moved to own lib.
|
|
137
139
|
/**
|
|
138
|
-
* Attempt to initialize `instance` as a WASI reactor by invoking its`_initialize()` export, if it is present. If `instance` contains a `_start()`export, then an exception is thrown.
|
|
140
|
+
* Attempt to initialize `instance` as a WASI reactor by invoking its `_initialize()` export, if it is present. If `instance` contains a `_start()` export, then an exception is thrown.
|
|
139
141
|
*
|
|
140
|
-
* `initialize()` requires that `instance` exports a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named`memory`.
|
|
142
|
+
* `initialize()` requires that `instance` exports a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named `memory`.
|
|
141
143
|
* If `instance` does not have a `memory` export an exception is thrown.
|
|
142
144
|
*
|
|
143
145
|
* If `initialize()` is called more than once, an exception is thrown.
|