image-js 1.4.0 → 1.5.0
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/dist/image-js.esm.js +11 -2
- package/dist/image-js.esm.js.map +1 -1
- package/dist/image-js.esm.min.js +2 -2
- package/dist/image-js.esm.min.js.map +1 -1
- package/dist/image-js.umd.js +11 -2
- package/dist/image-js.umd.js.map +1 -1
- package/dist/image-js.umd.min.js +2 -2
- package/dist/image-js.umd.min.js.map +1 -1
- package/lib/utils/cross_platform.d.ts +1 -0
- package/lib/utils/cross_platform.d.ts.map +1 -1
- package/lib/utils/cross_platform.js +9 -1
- package/lib/utils/cross_platform.js.map +1 -1
- package/package.json +4 -2
- package/src/utils/cross_platform.ts +11 -1
package/dist/image-js.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* image-js v1.
|
|
2
|
+
* image-js v1.5.0
|
|
3
3
|
* Image processing and manipulation in JavaScript
|
|
4
4
|
* https://github.com/image-js/image-js#readme
|
|
5
5
|
*
|
|
@@ -23204,13 +23204,22 @@ let CanvasCtorBrowser;
|
|
|
23204
23204
|
let CanvasCtorNode;
|
|
23205
23205
|
/**
|
|
23206
23206
|
* Returns a 2D canvas context for rendering on the browser or Node.js.
|
|
23207
|
+
* On Node.js this requires the optional `skia-canvas` package to be installed.
|
|
23207
23208
|
* @param width - Width of the canvas.
|
|
23208
23209
|
* @param height - Height of the canvas.
|
|
23209
23210
|
* @returns The initialised canvas context.
|
|
23210
23211
|
*/
|
|
23211
23212
|
function getCanvasContext(width, height) {
|
|
23212
23213
|
if (isNode()) {
|
|
23213
|
-
|
|
23214
|
+
if (!CanvasCtorNode) {
|
|
23215
|
+
try {
|
|
23216
|
+
CanvasCtorNode = getRequireFn()('skia-canvas').Canvas;
|
|
23217
|
+
} catch (error) {
|
|
23218
|
+
throw new Error('drawText on Node.js requires the optional "skia-canvas" package. Install it with: npm install skia-canvas', {
|
|
23219
|
+
cause: error
|
|
23220
|
+
});
|
|
23221
|
+
}
|
|
23222
|
+
}
|
|
23214
23223
|
return new CanvasCtorNode(width, height).getContext('2d');
|
|
23215
23224
|
} else {
|
|
23216
23225
|
CanvasCtorBrowser ??= globalThis.OffscreenCanvas;
|