Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly downcast RuntimeError through JsValue when extracting WASI exit codes #310

Merged
merged 9 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
371 changes: 254 additions & 117 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ wasm-bindgen = "0.2.73"
wasmer = { version = "3.0.2", default-features = false, features = ["js", "std"] }
wasmer-wasi = { version = "3.0.2", default-features = false, features = ["js"] }
wasmer-vfs = { version = "3.0.2", default-features = false, features = ["mem-fs"] }
wasm-bindgen-downcast = "0.1.1"

[profile.release]
lto = true
opt-level = 'z'

# TODO(Michael-F-Bryan): Remove this when Wasmer 3.1 comes out
# See https://github.com/wasmerio/wasmer-js/issues/312 for more.
[patch.crates-io]
wasmer = { git = "https://github.com/wasmerio/wasmer", default-features = false, features = ["js", "std"], rev = "ecde2aa" }
wasmer-wasi = { git = "https://github.com/wasmerio/wasmer", default-features = false, features = ["js"], rev = "ecde2aa" }
wasmer-vfs = { git = "https://github.com/wasmerio/wasmer", default-features = false, features = ["mem-fs"], rev = "ecde2aa" }
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"main": "dist/Library.cjs.min.js",
"module": "dist/Library.esm.min.js",
"unpkg": "dist/Library.umd.min.js",
"types": "dist/lib.d.ts",
"keywords": [
"webassembly",
"wasm",
Expand All @@ -24,7 +25,7 @@
"access": "public"
},
"scripts": {
"build": "wasm-pack build --release --target web; wasm-opt pkg/wasmer_wasi_js_bg.wasm -O2 -o pkg/wasmer_wasi_js_bg.wasm; wasm-strip pkg/wasmer_wasi_js_bg.wasm; rollup -c --environment BUILD:production",
"build": "wasm-pack build --release --target web && wasm-opt pkg/wasmer_wasi_js_bg.wasm -O2 -o pkg/wasmer_wasi_js_bg.wasm && wasm-strip pkg/wasmer_wasi_js_bg.wasm && rollup -c --environment BUILD:production",
"dev": "rollup -c -w",
"lint": "",
"test": "jest -c jest.config.js",
Expand Down Expand Up @@ -54,7 +55,10 @@
"rollup-plugin-typescript2": "^0.31.0",
"ts-loader": "^9.2.6",
"tslib": "^2.3.1",
"typescript": "^4.5.2"
"typescript": "^4.5.2",
"wabt": "^1.0.30",
"wasm-opt": "^1.3.0",
"wasm-pack": "^0.10.3"
},
"browserslist": "> 0.5%, last 2 versions, Firefox ESR, not dead"
}
23 changes: 21 additions & 2 deletions pkg/wasmer_wasi_js.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
/* tslint:disable */
/* eslint-disable */

interface WasiConfig {
readonly args?: string[],
readonly env?: Record<string, string>,
readonly preopens?: Record<string, string>,
readonly fs?: any,
}


/**
*/
export class JSVirtualFile {
Expand Down Expand Up @@ -56,6 +65,10 @@ export class JSVirtualFile {
export class MemFS {
free(): void;
/**
* @returns {Symbol}
*/
static __wbgd_downcast_token(): Symbol;
/**
*/
constructor();
/**
Expand Down Expand Up @@ -102,9 +115,9 @@ export class MemFS {
export class WASI {
free(): void;
/**
* @param {any} config
* @param {WasiConfig} config
*/
constructor(config: any);
constructor(config: WasiConfig);
/**
* @param {WebAssembly.Module} module
* @returns {object}
Expand Down Expand Up @@ -167,14 +180,20 @@ export class WASI {
*/
export class WasmerRuntimeError {
free(): void;
/**
* @returns {Symbol}
*/
static __wbgd_downcast_token(): Symbol;
}

export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly __wbg_wasmerruntimeerror_free: (a: number) => void;
readonly wasmerruntimeerror___wbgd_downcast_token: () => number;
readonly __wbg_memfs_free: (a: number) => void;
readonly memfs___wbgd_downcast_token: () => number;
readonly memfs_new: (a: number) => void;
readonly memfs_from_js: (a: number, b: number) => void;
readonly memfs_readDir: (a: number, b: number, c: number, d: number) => void;
Expand Down
Loading