happy-dom
happy-dom copied to clipboard
Add support for Canvas
e.g. document.createElement('canvas').getContext('2d')
Thanks for reporting @steel! :slightly_smiling_face:
I will look into adding support for Canvas as soon as possible. However, being able to render graphics might be a bit challenging, but at least we can get support for the API.
@capricorn86 Just use https://www.npmjs.com/package/canvas :D
@taye
@capricorn86 Just use npmjs.com/package/canvas :D
Are you saying that you can use that package to add in canvas
support to happy-dom
?
@Sparticuz I need to evaluate the package first. I am a bit worried that it is depended on OS system libraries to work, but on the other hand it seems quite popular :sweat_smile:
FYI, adding canvas might mean impacting running tests in parallel for solutions using happy-dom for that:
https://github.com/Automattic/node-canvas/issues/2019
For example:
https://github.com/vitest-dev/vitest/issues/740
I just wanted to point it out, no real opinion otherwise (maybe some config can control these "if there is a peer I will depend on it" cases to give control over them, or maybe that is too much config... idk)
As @webChannelN said, node-canvas does not support workers environment
And also consider that node-canvas doesn't have prebuilt binaries for ARM64 https://github.com/Automattic/node-canvas/issues/1662
What about use jimp to implement a basic getContext('2d')
support?
https://github.com/google/skia/tree/main/modules/canvaskit runs completely on WASM
Also we could at least add a canvas element as a stub for a future implementation
would like this implemented too. seems like node-canvas
might have issues with things like lambda's. would recommend skia or napi-rs
Please don't use node-canvas
for this 👍
I'm thinking about picking this up soon. I think that going with something like Skia seems like the best bet as performance is an important aspect here. I can imagine this being used in some applications for server side rendering and then we don't want any performance bottlenecks. However, it probably has to be an optional dependency or a plugin.
Hi @capricorn86 Any update on this and/or ETA on a resolution to this issue?
@weastaughscottlogic the update is that this is still high priority, but it is not a small task. It will probably be the next thing after going through the queue of pull requests and major bugs.
Is there an workaround for this, while happy-dom still doesn't support the Canvas AP ?