Skip to content

Commit

Permalink
chore! remove wasi js shim
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ten3roberts committed Sep 5, 2023
1 parent 7ecc912 commit ec11e85
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions crates/wasm-bridge-js/src/wasi/preview2/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: WasiView + 'static>(linker: &mut Linker<T>) -> Result<()> {
// Default imports
// linker.set_wasi_imports(get_imports());

// Overrides
// linker.instance("wasi:io/streams")?.func_wrap(
// "read",
Expand Down Expand Up @@ -84,25 +77,3 @@ pub fn add_to_linker<T: WasiView + 'static>(linker: &mut Linker<T>) -> 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();
}
}

0 comments on commit ec11e85

Please sign in to comment.