inkeliz / karmem

Karmem is a fast binary serialization format, faster than Google Flatbuffers and optimized for TinyGo and WASM.
BSD 3-Clause "New" or "Revised" License
654 stars 27 forks source link

Can I use Karmem for communicating with WASM app in browser? #99

Closed vlkv closed 1 year ago

vlkv commented 1 year ago

Hello,

Sorry, this could be a noob question. I have this use case: an application written in TinyGo which I compile into target=wasm. This application uses Karmem for its API declared in *.km file. It means that this app has a function like ExecuteCmd(cmdPtr int32, cmdLen int32) where cmd - is a Karmem message, some Go generated struct type.

Now, I want to run my wasm app in browser. To call ExecuteCmd I have to somehow pass a cmd data to it. It means that I need to construct an instance of cmd (in Javascipt/Typescript I guess...), serialize it into an array of bytes, copy those bytes into wasm's memory, get address of the begining + length of that message and finally call the ExecuteCmd.

The missing part here is that Karmem does not support code generation of *.km into JavaScript/TypeScript. And that is why - I cannot use Karmem in browser. Is this correct? Or maybe there is another way of doing it?

Kind regards.

vlkv commented 1 year ago

Any response?... Please)))

inkeliz commented 1 year ago

Currently, it doesn't generates code to Javacript/Typescript, https://github.com/users/inkeliz/projects/3/views/1?pane=issue&itemId=9119809. I'm looking to implement new languages and update this project, in general, in the future. 😞

vlkv commented 1 year ago

Thank you for your response!