cawfree / react-native-webassembly

⚛️ 🏎 WebAssembly for React Native powered by JSI.
https://twitter.com/cawfree
MIT License
292 stars 6 forks source link

Memory object #9

Closed Faliszek closed 1 year ago

Faliszek commented 1 year ago

First of all - thank you so much for your work on this, amazing job!

I try to use it in order to load some wasm file generated from this repo: https://github.com/matrix-org/matrix-rust-sdk/tree/main/bindings/matrix-sdk-crypto-js

It loads perfectly fine, but later this library uses memory object which from what I read, in browser returns from instatiate function (I think)

When I compile their wasm file to wat there is a code that looks like this

(memory $memory (export "memory") 20)

which according to chatgpt should be accesible on js side like this

//loading binary
const result = await WebAssembly.instatiate(binary);
//getting memory.buffer
result.exports.memory.buffer

Is there a plan for support this behaviour? Or do you have any guidance how can I add it? Thanks in advance :)

cawfree commented 1 year ago

Hey @Faliszek, thanks!

You're correct, this functionality isn't implemented yet, but it would be very nice to have. Thanks for sharing!

I'll need to have a little think about how to implement something like this, but it should be possible.

Faliszek commented 1 year ago

Let me know if it's there anything I can help with. Once again thanks for all your work, this library is a game changer for me.

cawfree commented 1 year ago

This functionality has been implemented as published as version 0.3.3. (Instructions)

Thank you for your patience whilst this was being implemented.

If you have any trouble with this feature or notice any other aspects of the specification that are missing, please feel free to raise another issue!

https://github.com/cawfree/react-native-webassembly/pull/10