DjDeveloperr / deno-canvas

Canvas API for Deno, ported from canvaskit-wasm (Skia).
https://deno.land/x/canvas
MIT License
189 stars 16 forks source link

Doesn't work unless canvaskit.wasm is a local file #1

Closed mjrlowe closed 3 years ago

mjrlowe commented 3 years ago

Nice work on this module! I had a go at using it but I quickly realised that you need to have the canvaskit.wasm file available locally (in the same directory as Canvas.MakeCanvas is called from), which is a little inconvenient.

I think this is unintentional--when you call Deno.readFileSync('./canvaskit.wasm') in lib.js, it reads the file relative to the user call, rather than the module.

DjDeveloperr commented 3 years ago

Yup, I'll make it download the wasm file when its imported if that's not locally present. I'll be doing this in a bit. I was testing with it being in my project directory, so didn't notice 😅

Edit: Now it would attempt to download (& save) if not locally present.

mjrlowe commented 3 years ago

Seems to work now, thanks.

Once Deno gets wasm imports (which probably won't be for a while) we should be able to do this without needing --allow-read or --allow-net to read the wasm file.