WebAssembly module for protobuf encoding / decoding
Are there any plans on wasm implementation of protobufs?
There's no such plan yet. Would simply use the C++ code work for wasm, or it is more about bridging the parsing/serialization with the native JS message types?
Yes, I mean bridging with JS
No plan yet. But will investigate.
Ideally, we could get a WASM module generated directly out of the definitions in a .proto file, with exported functions to unmarshall a Uint8Array containing a PB message into a JS object, or pass in a JS object to be marshalled into a Uint8Array.
@dchenk How to create JS objects in web assembly? Is that efficient or possible? I have looked a bit into web assembly recently but I don't remember seeing any C API that can be used to construct JS objects directly in web assembly. If every manipulation of a JS object requires crossing the wasm-js boundary, creating JS objects this way in web assembly can be very inefficient.
WebAssembly doesn't have any structures besides number types. It has proposal for anyref though.
This basically works with C++ protos and communicate via sending typed arrays back and forth.
We should document how to do this.
I am also interested to know which implementation is faster. protobuf.js, this repo, or the WASM build.