joshmarinacci / node-pureimage

Pure JS implementation of the HTML Canvas 2D drawing API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Discussion about canvas implementation without system dependencies

Brooooooklyn opened this issue · comments

Hey, I'm the author of skr-canvas. I'm excited about your work, implement Canvas in pure javascript is amazing! And I see some interesting points in your README:

I hate having native dependencies in Node modules.

I hate it too, so my skr-canvas contains zero system dependency. You can simply use it in pure Docker image docker run --rm -it node:lts-alpine sh -c "yarn add @napi-rs/canvas"

hey often don't compile, or break after a system update. They often don't support non-X86 architectures (like the Raspberry Pi). You have to have a compiler already installed to use them, along with any other native dependencies pre-installed (like Cairo).

Yes, it's bothering. So I pre-compile the skr-canvas as much as possible, it supports:

node10 node12 node14 node16
Windows x64
macOS x64
macOS arm64 (m chips)
Linux x64 gnu
Linux x64 musl
Linux arm64 gnu
Linux arm64 musl
Linux arm gnueabihf
Linux arm64 android

And I will add Windows x32 Windows arm64 and FreeBSD x64 WebAssembly support for it soon.

If anyone were interested in skr-canvas, feel free to start discussion with me in Github!

I'm trying to understand this. Your project is NodeJS bindings to Skia, so you still have both the NAN glue code with some C++ in it, plus all of Skia. I don't understand how it has no native dependencies? Is it compiled to WASM so it can use pure Node? Or am I missing something? It certainly looks like a great library for certain use cases.

so you still have both the NAN glue code with some C++ in it, plus all of Skia

I'm using the Node-API, which provide stable API cross Node.js versions.

I don't understand how it has no native dependencies?

I static link every native dependencies which skia need. So developers don't need install anything on their environment.

Is it compiled to WASM so it can use pure Node?

I have a plan to provide WASM version, it should work on Node.js and browser, but the performance will be a little worse

Oh, I see. So when you npm install the lib all native dependencies are pre-compiled and baked in, both the bindings and skia. How big is the final package?

How big is the final package

It depends on platform, for the latest release: https://github.com/Brooooooklyn/canvas/releases/tag/v0.1.13

图片