From ec11e85e34cf88eb149eab230effd074fe7c4e8b Mon Sep 17 00:00:00 2001 From: Tei Leelo Roberts Date: Tue, 5 Sep 2023 09:38:54 +0200 Subject: [PATCH] chore! remove wasi js shim This creates a mostly stubbed js fallback for functions, which leads to unexpected errors such as `e is not iterable`, and will additionally poke more holes in the sandbox than expected. --- .../src/wasi/preview2/command.rs | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/crates/wasm-bridge-js/src/wasi/preview2/command.rs b/crates/wasm-bridge-js/src/wasi/preview2/command.rs index 6d2a73f1..7d7ff7bc 100644 --- a/crates/wasm-bridge-js/src/wasi/preview2/command.rs +++ b/crates/wasm-bridge-js/src/wasi/preview2/command.rs @@ -5,16 +5,9 @@ use crate::component::Linker; use crate::wasi::preview2::{clocks, WasiView}; use crate::{Result, StoreContextMut}; -use super::stdio::{STDERR_IDENT, STDIN_IDENT, STDOUT_IDENT}; use super::{environment, filesystem, preopens, stdio, streams, terminal}; -static WASI_IMPORTS_STR: &str = - include_str!("../../../../../resources/transformed/preview2-shim/bundled.js"); - pub fn add_to_linker(linker: &mut Linker) -> Result<()> { - // Default imports - // linker.set_wasi_imports(get_imports()); - // Overrides // linker.instance("wasi:io/streams")?.func_wrap( // "read", @@ -84,25 +77,3 @@ pub fn add_to_linker(linker: &mut Linker) -> Result<() Ok(()) } - -/// Fills the wasi imports by the browser shim -fn get_imports() -> Object { - let imports = js_sys::eval(WASI_IMPORTS_STR).expect("eval bundled wasi imports"); - - assert!( - imports.is_object(), - "wasi imports must be an object, {imports:#?}" - ); - - imports.into() -} - -#[cfg(test)] -mod tests { - use super::*; - - #[wasm_bindgen_test::wasm_bindgen_test] - fn should_get_imports() { - let _ = get_imports(); - } -}