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