@napi-rs/canvas 0.1.71 → 0.1.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +34 -0
- package/package.json +17 -13
package/index.js
CHANGED
|
@@ -59,6 +59,37 @@ CanvasRenderingContext2D.prototype.getTransform = function getTransform() {
|
|
|
59
59
|
return new DOMMatrix([a, b, c, d, e, f])
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
// Workaround for webpack bundling issue with drawImage
|
|
63
|
+
// Store the original drawImage method
|
|
64
|
+
const _drawImage = CanvasRenderingContext2D.prototype.drawImage
|
|
65
|
+
|
|
66
|
+
// Override drawImage to ensure proper type recognition in bundled environments
|
|
67
|
+
CanvasRenderingContext2D.prototype.drawImage = function drawImage(image, ...args) {
|
|
68
|
+
// If the image is a Canvas-like object but not recognized due to bundling,
|
|
69
|
+
// we need to ensure it's properly identified
|
|
70
|
+
if (image && typeof image === 'object') {
|
|
71
|
+
// First check if it's a wrapped canvas object
|
|
72
|
+
if (image.canvas instanceof CanvasElement || image.canvas instanceof SVGCanvas) {
|
|
73
|
+
image = image.canvas
|
|
74
|
+
} else if (image._canvas instanceof CanvasElement || image._canvas instanceof SVGCanvas) {
|
|
75
|
+
image = image._canvas
|
|
76
|
+
}
|
|
77
|
+
// Then check if it's a Canvas-like object by checking for getContext method
|
|
78
|
+
else if (typeof image.getContext === 'function' && image.width && image.height) {
|
|
79
|
+
// If it has canvas properties but isn't recognized as CanvasElement or SVGCanvas,
|
|
80
|
+
// try to correct the prototype chain
|
|
81
|
+
if (!(image instanceof CanvasElement) && !(image instanceof SVGCanvas)) {
|
|
82
|
+
// Try to create a proper CanvasElement from the canvas-like object
|
|
83
|
+
// This helps when webpack has transformed the prototype chain
|
|
84
|
+
Object.setPrototypeOf(image, CanvasElement.prototype)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Call the original drawImage with the potentially corrected image
|
|
90
|
+
return _drawImage.apply(this, [image, ...args])
|
|
91
|
+
}
|
|
92
|
+
|
|
62
93
|
function createCanvas(width, height, flag) {
|
|
63
94
|
const isSvgBackend = typeof flag !== 'undefined'
|
|
64
95
|
return isSvgBackend ? new SVGCanvas(width, height, flag) : new CanvasElement(width, height)
|
|
@@ -111,4 +142,7 @@ module.exports = {
|
|
|
111
142
|
DOMRect,
|
|
112
143
|
loadImage,
|
|
113
144
|
FontKey,
|
|
145
|
+
// Export these for better webpack compatibility
|
|
146
|
+
CanvasElement,
|
|
147
|
+
SVGCanvas,
|
|
114
148
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napi-rs/canvas",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.72",
|
|
4
4
|
"description": "Canvas for Node.js with skia backend",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/Brooooooklyn/canvas.git"
|
|
9
9
|
},
|
|
10
|
+
"workspaces": [
|
|
11
|
+
"e2e/*"
|
|
12
|
+
],
|
|
10
13
|
"license": "MIT",
|
|
11
14
|
"keywords": [
|
|
12
15
|
"napi-rs",
|
|
@@ -64,6 +67,7 @@
|
|
|
64
67
|
"postpublish": "pinst --enable",
|
|
65
68
|
"test:ci": "ava -c 1",
|
|
66
69
|
"test": "ava",
|
|
70
|
+
"e2e": "yarn workspace @napi-rs/canvas-e2e-webpack test",
|
|
67
71
|
"version": "napi version && conventional-changelog -p angular -i CHANGELOG.md -s && git add ."
|
|
68
72
|
},
|
|
69
73
|
"devDependencies": {
|
|
@@ -71,7 +75,7 @@
|
|
|
71
75
|
"@jimp/custom": "^0.22.12",
|
|
72
76
|
"@jimp/jpeg": "^0.22.12",
|
|
73
77
|
"@jimp/png": "^0.22.12",
|
|
74
|
-
"@napi-rs/cli": "^3.0.0-alpha.
|
|
78
|
+
"@napi-rs/cli": "^3.0.0-alpha.91",
|
|
75
79
|
"@octokit/rest": "^22.0.0",
|
|
76
80
|
"@swc-node/register": "^1.10.10",
|
|
77
81
|
"@swc/core": "^1.11.31",
|
|
@@ -90,7 +94,7 @@
|
|
|
90
94
|
"lint-staged": "^16.1.0",
|
|
91
95
|
"lodash": "^4.17.21",
|
|
92
96
|
"npm-run-all2": "^8.0.4",
|
|
93
|
-
"oxlint": "^0.
|
|
97
|
+
"oxlint": "^1.0.0",
|
|
94
98
|
"pinst": "^3.0.0",
|
|
95
99
|
"png.js": "^0.2.1",
|
|
96
100
|
"prettier": "^3.5.3",
|
|
@@ -138,15 +142,15 @@
|
|
|
138
142
|
},
|
|
139
143
|
"packageManager": "yarn@4.9.2",
|
|
140
144
|
"optionalDependencies": {
|
|
141
|
-
"@napi-rs/canvas-linux-x64-gnu": "0.1.
|
|
142
|
-
"@napi-rs/canvas-darwin-x64": "0.1.
|
|
143
|
-
"@napi-rs/canvas-win32-x64-msvc": "0.1.
|
|
144
|
-
"@napi-rs/canvas-linux-arm-gnueabihf": "0.1.
|
|
145
|
-
"@napi-rs/canvas-linux-x64-musl": "0.1.
|
|
146
|
-
"@napi-rs/canvas-linux-arm64-gnu": "0.1.
|
|
147
|
-
"@napi-rs/canvas-linux-arm64-musl": "0.1.
|
|
148
|
-
"@napi-rs/canvas-darwin-arm64": "0.1.
|
|
149
|
-
"@napi-rs/canvas-android-arm64": "0.1.
|
|
150
|
-
"@napi-rs/canvas-linux-riscv64-gnu": "0.1.
|
|
145
|
+
"@napi-rs/canvas-linux-x64-gnu": "0.1.72",
|
|
146
|
+
"@napi-rs/canvas-darwin-x64": "0.1.72",
|
|
147
|
+
"@napi-rs/canvas-win32-x64-msvc": "0.1.72",
|
|
148
|
+
"@napi-rs/canvas-linux-arm-gnueabihf": "0.1.72",
|
|
149
|
+
"@napi-rs/canvas-linux-x64-musl": "0.1.72",
|
|
150
|
+
"@napi-rs/canvas-linux-arm64-gnu": "0.1.72",
|
|
151
|
+
"@napi-rs/canvas-linux-arm64-musl": "0.1.72",
|
|
152
|
+
"@napi-rs/canvas-darwin-arm64": "0.1.72",
|
|
153
|
+
"@napi-rs/canvas-android-arm64": "0.1.72",
|
|
154
|
+
"@napi-rs/canvas-linux-riscv64-gnu": "0.1.72"
|
|
151
155
|
}
|
|
152
156
|
}
|