1 | declare module 'wasi' {
|
2 | interface WASIOptions {
|
3 | |
4 |
|
5 |
|
6 |
|
7 |
|
8 | args?: string[] | undefined;
|
9 |
|
10 | |
11 |
|
12 |
|
13 |
|
14 | env?: object | undefined;
|
15 |
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | preopens?: NodeJS.Dict<string> | undefined;
|
23 |
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | returnOnExit?: boolean | undefined;
|
32 |
|
33 | |
34 |
|
35 |
|
36 |
|
37 | stdin?: number | undefined;
|
38 |
|
39 | |
40 |
|
41 |
|
42 |
|
43 | stdout?: number | undefined;
|
44 |
|
45 | |
46 |
|
47 |
|
48 |
|
49 | stderr?: number | undefined;
|
50 | }
|
51 |
|
52 | class WASI {
|
53 | constructor(options?: WASIOptions);
|
54 | /**
|
55 | *
|
56 | * Attempt to begin execution of `instance` by invoking its `_start()` export.
|
57 | * If `instance` does not contain a `_start()` export, then `start()` attempts to
|
58 | * invoke the `__wasi_unstable_reactor_start()` export. If neither of those exports
|
59 | * is present on `instance`, then `start()` does nothing.
|
60 | *
|
61 | * `start()` requires that `instance` exports a [`WebAssembly.Memory`][] named
|
62 | * `memory`. If `instance` does not have a `memory` export an exception is thrown.
|
63 | *
|
64 | * If `start()` is called more than once, an exception is thrown.
|
65 | */
|
66 | start(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
|
67 |
|
68 | /**
|
69 | * Attempt to initialize `instance` as a WASI reactor by invoking its `_initialize()` export, if it is present.
|
70 | * If `instance` contains a `_start()` export, then an exception is thrown.
|
71 | *
|
72 | * `start()` requires that `instance` exports a [`WebAssembly.Memory`][] named
|
73 | * `memory`. If `instance` does not have a `memory` export an exception is thrown.
|
74 | *
|
75 | * If `initialize()` is called more than once, an exception is thrown.
|
76 | */
|
77 | initialize(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
|
78 |
|
79 | /**
|
80 | * Is an object that implements the WASI system call API. This object
|
81 | * should be passed as the `wasi_snapshot_preview1` import during the instantiation of a
|
82 | * [`WebAssembly.Instance`][].
|
83 | */
|
84 | readonly wasiImport: NodeJS.Dict<any>; // TODO: Narrow to DOM types
|
85 | }
|
86 | }
|
87 | declare module 'node:wasi' {
|
88 | export * from 'wasi';
|
89 | }
|