erwanvivien / fast_qr

Ultra fast QRCode generation
https://fast-qr.com/
MIT License
208 stars 30 forks source link

Why is `Shape::Command` disabled on wasm? #40

Closed JohnTheCoolingFan closed 1 year ago

JohnTheCoolingFan commented 1 year ago

I'm developing a project that is compiled to wasm (cloudflare worker) and needs to generate qr codes with custom visual processing when converting to an image. I've completed the processing using the command shape variant, but now I need to use it in wasm.

Why is it disabled for wasm? I don't think there are any issues preventing it being enabled, as it's just a function pretty much.

An explanation would be appreciated, or a patch to remove the disabling on wasm arch.

erwanvivien commented 1 year ago

First, hello :)

Why is it disabled for wasm? I don't think there are any issues preventing it being enabled, as it's just a function pretty much.

If you try to enable this in Wasm, it won't compile. You can only send basic types between Js and Wasm: numbers, strings, null (None), etc

If you find a way to make it work, please do a PR !

erwanvivien commented 1 year ago

I think the best bet would be for you to expand the crate to your use case and add a new Shape and implement your your custom SVG paths?

JohnTheCoolingFan commented 1 year ago

Ah, I think I see now. Wasm target arch also assumes wasm-bindgen is enabled, which is probably what's limiting the types available.

My suggestion is to disable the command variant if wasm-bindgen is enabled. I'll do a PR later in the morning.

erwanvivien commented 1 year ago

Ah indeed, I'm using wasm-bindgen as default, maybe it should be a flag 👍