diff --git a/lib.ts b/lib.ts index 492c998a837..d8de227ebe4 100644 --- a/lib.ts +++ b/lib.ts @@ -1,6 +1,6 @@ // import load, { WASI } from "./pkg/index"; export * from "./pkg/wasmer_wasi_js"; -import { InitInput } from "./pkg/wasmer_wasi_js"; +// import { InitInput } from "./pkg/wasmer_wasi_js"; import load from "./pkg/wasmer_wasi_js"; import wasm_bytes from "./pkg/wasmer_wasi_js_bg.wasm"; @@ -71,6 +71,8 @@ function dataUriToBuffer(uri: string): MimeBuffer { return buffer; } +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; + let inited: Promise | null = null; export const init = async (input?: InitInput | Promise, force?: boolean) => { if (inited === null || force === true) { diff --git a/pkg/wasmer_wasi_js.d.ts b/pkg/wasmer_wasi_js.d.ts index 859e9835866..9fa46e74042 100644 --- a/pkg/wasmer_wasi_js.d.ts +++ b/pkg/wasmer_wasi_js.d.ts @@ -104,7 +104,7 @@ export class WASI { * @param {WebAssembly.Module} module * @returns {object} */ - get_imports(module: WebAssembly.Module): object; + getImports(module: WebAssembly.Module): object; /** * @param {any} module * @param {object | undefined} imports @@ -173,7 +173,7 @@ export interface InitOutput { readonly __wbg_wasi_free: (a: number) => void; readonly wasi_new: (a: number) => number; readonly wasi_fs: (a: number) => number; - readonly wasi_get_imports: (a: number, b: number) => number; + readonly wasi_getImports: (a: number, b: number) => number; readonly wasi_instantiate: (a: number, b: number, c: number) => number; readonly wasi_start: (a: number, b: number) => number; readonly wasi_getStdoutBuffer: (a: number, b: number) => void; diff --git a/pkg/wasmer_wasi_js.js b/pkg/wasmer_wasi_js.js index 75e113ac76d..1ce0b06d4c9 100644 --- a/pkg/wasmer_wasi_js.js +++ b/pkg/wasmer_wasi_js.js @@ -512,8 +512,8 @@ export class WASI { * @param {WebAssembly.Module} module * @returns {object} */ - get_imports(module) { - var ret = wasm.wasi_get_imports(this.ptr, addHeapObject(module)); + getImports(module) { + var ret = wasm.wasi_getImports(this.ptr, addHeapObject(module)); return takeObject(ret); } /** diff --git a/pkg/wasmer_wasi_js_bg.wasm b/pkg/wasmer_wasi_js_bg.wasm index 9019ce8a161..6c5b9b6fbba 100644 Binary files a/pkg/wasmer_wasi_js_bg.wasm and b/pkg/wasmer_wasi_js_bg.wasm differ diff --git a/pkg/wasmer_wasi_js_bg.wasm.d.ts b/pkg/wasmer_wasi_js_bg.wasm.d.ts index 2ca1479d856..9db5351c89a 100644 --- a/pkg/wasmer_wasi_js_bg.wasm.d.ts +++ b/pkg/wasmer_wasi_js_bg.wasm.d.ts @@ -5,7 +5,7 @@ export function __wbg_wasmerruntimeerror_free(a: number): void; export function __wbg_wasi_free(a: number): void; export function wasi_new(a: number): number; export function wasi_fs(a: number): number; -export function wasi_get_imports(a: number, b: number): number; +export function wasi_getImports(a: number, b: number): number; export function wasi_instantiate(a: number, b: number, c: number): number; export function wasi_start(a: number, b: number): number; export function wasi_getStdoutBuffer(a: number, b: number): void; diff --git a/src/wasi.rs b/src/wasi.rs index cff3a8bfc0b..ad0b0784d9c 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -129,6 +129,7 @@ impl WASI { Ok(mem_fs.clone()) } + #[wasm_bindgen(js_name = getImports)] pub fn get_imports( &mut self, module: js_sys::WebAssembly::Module, diff --git a/tests/index.spec.js b/tests/index.spec.js index 027c49f8917..66bad830333 100644 --- a/tests/index.spec.js +++ b/tests/index.spec.js @@ -82,7 +82,7 @@ test('wasi start empty fails', async() => { let moduleBytes = fs.readFileSync(__dirname + '/test.wasm'); let wasi = new WASI({}); const module = await WebAssembly.compile(moduleBytes); - let imports = wasi.get_imports(module); + let imports = wasi.getImports(module); // console.log(imports); let instance = await WebAssembly.instantiate(module, { ...imports, @@ -97,7 +97,7 @@ test('get imports', async() => { let moduleBytes = fs.readFileSync(__dirname + '/test.wasm'); let wasi = new WASI({}); const module = await WebAssembly.compile(moduleBytes); - let imports = wasi.get_imports(module); + let imports = wasi.getImports(module); // console.log(imports); let instance = await WebAssembly.instantiate(module, { ...imports, diff --git a/tsconfig.json b/tsconfig.json index bb9075d54d8..9bd9e995505 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["*"], + "include": ["pkg"], "exclude": ["dist"], "compilerOptions": { "outDir": "./dist/",