Brooooooklyn / canvas

High performance skia binding to Node.js. Zero system dependencies and pure npm packages without any postinstall scripts nor node-gyp.
https://vercel.skia.rs
MIT License
1.78k stars 76 forks source link

about `??` compatibility issues #881

Closed ByLCY closed 2 months ago

ByLCY commented 2 months ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @napi-rs/canvas@0.1.54 for the project I'm working on.

The package compatibility is declared as "node": ">= 10" in package.json, but ?? is used in geometry.js. However, this operator is only supported in node 14 and above.

Here is the diff that solved my problem:

diff --git a/node_modules/@napi-rs/canvas/geometry.js b/node_modules/@napi-rs/canvas/geometry.js
index fb6b8a5..656da04 100644
--- a/node_modules/@napi-rs/canvas/geometry.js
+++ b/node_modules/@napi-rs/canvas/geometry.js
@@ -771,10 +771,10 @@ class DOMMatrix {
   }

   transformPoint(point) {
-    const x = point.x ?? 0
-    const y = point.y ?? 0
-    const z = point.z ?? 0
-    const w = point.w ?? 1
+    const x = point.x || 0
+    const y = point.y || 0
+    const z = point.z || 0
+    const w = point.w || 1

     const values = this[VALUES]

This issue body was partially generated by patch-package.