cawfree / react-native-webassembly

⚛️ 🏎 WebAssembly for React Native powered by JSI.

Home Page:https://twitter.com/cawfree

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request for Adding the "compile" function support in "react-native-webassembly"

tranhuyducseven opened this issue · comments

Issue Description

I am trying to rebuild ffjavascript to run on React Native, and I need the compile function to be supported in react-native-webassembly.

Currently, the WebAssembly in browser engine supports the compile function, which accepts a bytes parameter and returns a Promise<Module>.

  function compile(bytes: BufferSource): Promise<Module>;
    /** [MDN Reference](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming) */

I would like to request support for this function in react-native-webassembly to replace the following code in my project:

// threadman.js

import * as WebAssembly from "react-native-webassembly";

...

export default async function buildThreadManager(wasm, singleThread) {
  const tm = new ThreadManager();
  tm.memory = new WebAssembly.Memory({ initial: MEM_SIZE });

  // This line uses the compile function
  const wasmModule = await WebAssembly.compile(wasm.code);

  tm.instance = await WebAssembly.instantiate(wasmModule, {
    env: {
      memory: tm.memory,
    },
  });
}

Thank you so much! 🤩

Hey, thanks for reaching out.

Interesting. Um. Hm. Yeah we can probably do this.

Has this feature made any progress