|
1 | 1 | /// <reference lib="esnext.bigint" />
|
2 | 2 |
|
3 |
| -interface ResultObject { |
4 |
| - module: WebAssembly.Module, |
5 |
| - instance: WebAssembly.Instance |
6 |
| -}; |
| 3 | +export interface ResultObject { |
| 4 | + module: WebAssembly.Module; |
| 5 | + instance: WebAssembly.Instance; |
| 6 | +} |
| 7 | + |
| 8 | +type ImportValue = Function | WebAssembly.Global | WebAssembly.Memory | WebAssembly.Table | number; |
7 | 9 |
|
8 | 10 | /** WebAssembly imports with two levels of nesting. */
|
9 |
| -interface ImportsObject extends Record<string, any> { |
| 11 | +export interface Imports extends Record<string, Record<string, ImportValue>> { |
10 | 12 | env?: {
|
11 | 13 | memory?: WebAssembly.Memory,
|
12 | 14 | table?: WebAssembly.Table,
|
| 15 | + seed?: () => number, |
13 | 16 | abort?(msg: number, file: number, line: number, column: number): void,
|
14 | 17 | trace?(msg: number, numArgs?: number, ...args: number[]): void
|
15 | 18 | };
|
16 | 19 | }
|
17 | 20 |
|
18 | 21 | /** Utility mixed in by the loader. */
|
19 |
| -interface ASUtil { |
| 22 | +export interface ASUtil { |
20 | 23 | memory?: WebAssembly.Memory;
|
21 | 24 | table?: WebAssembly.Table;
|
22 | 25 |
|
@@ -99,19 +102,19 @@ interface ASUtil {
|
99 | 102 | /** Asynchronously instantiates an AssemblyScript module from anything that can be instantiated. */
|
100 | 103 | export declare function instantiate<T extends {}>(
|
101 | 104 | source: WebAssembly.Module | BufferSource | Response | PromiseLike<WebAssembly.Module | BufferSource | Response>,
|
102 |
| - imports?: ImportsObject |
| 105 | + imports?: Imports |
103 | 106 | ): Promise<ResultObject & { exports: ASUtil & T }>;
|
104 | 107 |
|
105 | 108 | /** Synchronously instantiates an AssemblyScript module from a WebAssembly.Module or binary buffer. */
|
106 | 109 | export declare function instantiateSync<T extends {}>(
|
107 | 110 | source: WebAssembly.Module | BufferSource,
|
108 |
| - imports?: ImportsObject |
| 111 | + imports?: Imports |
109 | 112 | ): ResultObject & { exports: ASUtil & T };
|
110 | 113 |
|
111 | 114 | /** Asynchronously instantiates an AssemblyScript module from a response, i.e. as obtained by `fetch`. */
|
112 | 115 | export declare function instantiateStreaming<T extends {}>(
|
113 | 116 | source: Response | PromiseLike<Response>,
|
114 |
| - imports?: ImportsObject |
| 117 | + imports?: Imports |
115 | 118 | ): Promise<ResultObject & { exports: ASUtil & T }>;
|
116 | 119 |
|
117 | 120 | /** Demangles an AssemblyScript module's exports to a friendly object structure. */
|
|
0 commit comments