[6a3a178] | 1 | declare module 'wasi' {
|
---|
| 2 | interface WASIOptions {
|
---|
| 3 | /**
|
---|
| 4 | * An array of strings that the WebAssembly application will
|
---|
| 5 | * see as command line arguments. The first argument is the virtual path to the
|
---|
| 6 | * WASI command itself.
|
---|
| 7 | */
|
---|
| 8 | args?: string[] | undefined;
|
---|
| 9 |
|
---|
| 10 | /**
|
---|
| 11 | * An object similar to `process.env` that the WebAssembly
|
---|
| 12 | * application will see as its environment.
|
---|
| 13 | */
|
---|
| 14 | env?: object | undefined;
|
---|
| 15 |
|
---|
| 16 | /**
|
---|
| 17 | * This object represents the WebAssembly application's
|
---|
| 18 | * sandbox directory structure. The string keys of `preopens` are treated as
|
---|
| 19 | * directories within the sandbox. The corresponding values in `preopens` are
|
---|
| 20 | * the real paths to those directories on the host machine.
|
---|
| 21 | */
|
---|
| 22 | preopens?: NodeJS.Dict<string> | undefined;
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | * By default, WASI applications terminate the Node.js
|
---|
| 26 | * process via the `__wasi_proc_exit()` function. Setting this option to `true`
|
---|
| 27 | * causes `wasi.start()` to return the exit code rather than terminate the
|
---|
| 28 | * process.
|
---|
| 29 | * @default false
|
---|
| 30 | */
|
---|
| 31 | returnOnExit?: boolean | undefined;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | class WASI {
|
---|
| 35 | constructor(options?: WASIOptions);
|
---|
| 36 | /**
|
---|
| 37 | *
|
---|
| 38 | * Attempt to begin execution of `instance` by invoking its `_start()` export.
|
---|
| 39 | * If `instance` does not contain a `_start()` export, then `start()` attempts to
|
---|
| 40 | * invoke the `__wasi_unstable_reactor_start()` export. If neither of those exports
|
---|
| 41 | * is present on `instance`, then `start()` does nothing.
|
---|
| 42 | *
|
---|
| 43 | * `start()` requires that `instance` exports a [`WebAssembly.Memory`][] named
|
---|
| 44 | * `memory`. If `instance` does not have a `memory` export an exception is thrown.
|
---|
| 45 | */
|
---|
| 46 | start(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
|
---|
| 47 |
|
---|
| 48 | /**
|
---|
| 49 | * Is an object that implements the WASI system call API. This object
|
---|
| 50 | * should be passed as the `wasi_snapshot_preview1` import during the instantiation of a
|
---|
| 51 | * [`WebAssembly.Instance`][].
|
---|
| 52 | */
|
---|
| 53 | readonly wasiImport: NodeJS.Dict<any>; // TODO: Narrow to DOM types
|
---|
| 54 | }
|
---|
| 55 | }
|
---|