juancastillo0 / wasm_run

A WebAssembly executor for Dart and Flutter applications. Uses Rust's wasmtime optimizing runtime or wasmi interpreter to parse and execute WASM and WAT files.
https://juancastillo0.github.io/wasm_run/
MIT License
112 stars 10 forks source link

Questions: Wasm modules with Javascript and flutter_rust_bridge async support #37

Open limcheekin opened 1 year ago

limcheekin commented 1 year ago

Hi there,

First of all, thanks for created and published the package.

I have the following questions regarding the package:

  1. How to run Wasm modules with Javascript across platforms such as Android, iOS, Linux, Windows, etc?
  2. From my understanding, the flutter_rust_bridge doesn't support async rust code officially, is there any solution offered by the package?

Appreciate if there are sample projects that answer the questions above.

Please advise. Thank you.

juancastillo0 commented 1 year ago

Hi, thanks for the issue!

  1. This is primarily a Dart package. Could you explain how is the interaction with Javascript? You don't need much Javascript to use this package. However, the same wasm module could be reused on both languages. Could you explain more of what you mean?

  2. You can find more information in their documentation. However I think you could do it by using StreamSink as an argument to a Rust function. Within this package we provide a way to run function from threaded wasm modules asynchronously.

You can see the latest code and multiple packages examples that use wasm_run in this PR https://github.com/juancastillo0/wasm_run/pull/14

limcheekin commented 1 year ago

Hi, thanks for the issue!

  1. This is primarily a Dart package. Could you explain how is the interaction with Javascript? You don't need much Javascript to use this package. However, the same wasm module could be reused on both languages. Could you explain more of what you mean?
  2. You can find more information in their documentation. However I think you could do it by using StreamSink as an argument to a Rust function. Within this package we provide a way to run function from threaded wasm modules asynchronously.

You can see the latest code and multiple packages examples that use wasm_run in this PR #14

Thanks for quick response.

  1. As code speak louder and clearer, let's me show you some codes :). The surrealdb.wasm is built by wasmpack and the wasm-bindgen will produce a JavaScript bindings (index.js) and a wasm module (index_bg.wasm). A single-page application or static html need to use the JavaScript bindings in order to interact with the wasm module, please take a look on the code here. I managed to integrate the JavaScript bindings and wasm module of surrealdb.wasm into a Flutter Web app using package:js. My question: How the wasm_run package able to make the surrealdb.wasm run across platforms such Android, iOS, Linux, Windows, including Web with/without JavaScript?
  2. Could you elaborate more on the statement Within this package we provide a way to run function from threaded wasm modules asynchronously? Better with code snippets.

I will look into PR #14.

Please advise. Thank you.

MulverineX commented 5 months ago

We might be up for partnering on this https://github.com/openwebf/mercury