-
Notifications
You must be signed in to change notification settings - Fork 824
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
Added Wasmer Js API #2460
Added Wasmer Js API #2460
Conversation
#[deprecated( | ||
since = "2.1.0", | ||
note = "ModuleInfo, ExportsIterator, ImportsIterator should be imported from wasmer_types." | ||
)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we should make it deprecated. It's fine to re-export types from another crate here. What do you think?
lib/js-api/src/externals/memory.rs
Outdated
pub fn view<T: ValueType>(&self) -> MemoryView<T> { | ||
unimplemented!("The view function is not yet implemented in Wasmer Javascript"); | ||
} | ||
|
||
/// example view | ||
pub fn uint8view(&self) -> js_sys::Uint8Array { | ||
js_sys::Uint8Array::new(&self.vm_memory.memory.buffer()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint8view
is an example here, not a real method it seems like.
However, we can improve the view
method to produce a Uint8Array
or simply to provide an ArrayBuffer
. We could even mark view
as unimplemented, and provide a buffer
method. Or just re-use data_ptr
to provide an ArrayBuffer
.
I think we should try to make view
working with ArrayBuffer
, that would be the best.
This patch takes the entire `wasmer-js` crate and merges it into the `wasmer` crate. Inside the `lib/api/src/` directory, there are 2 new directories: 1. a new `sys` directory, which contains the usual `wasmer` crate implementation, 2. a new directory `js`, which contains the implementation of `wasmer-js`. The `Cargo.toml` file is still compatible. The `default` feature fallbacks to `sys-default`, which enables the `sys` feature. All features related to compilers or engines or anything else prior this patch, activates the `sys` feature. Parallel to that, there is a `js-default` and `js` features. The `Cargo.toml` file is extensively documented to explain what are dependencies, dev-dependencies, features and other sections related to `sys` or to `js`. There is a bug with `wasm_bindgen_test` where it doesn't compile or look for tests in `tests/*/<test>.rs`. The hack is to name files `tests/js_<test>.rs`. Ugly, but it works.
It is possible to merge |
feat(api) Merge `js-api` into `api`
bors r+ |
Description
This PR adds support for compiling Wasmer into JS/Wasm via wasm-bindgen, so 3rd party dependencies can use Wasmer to target the web also.
Things working:
RuntimeError
)Review