konva 10.9.1 → 10.10.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/README.md +22 -10
- package/konva.js +18996 -18924
- package/konva.min.js +50 -50
- package/lib/Animation.js +3 -3
- package/lib/Canvas.js +11 -3
- package/lib/Container.js +3 -3
- package/lib/Context.d.ts +1 -2
- package/lib/Context.js +2 -19
- package/lib/Core.js +2 -2
- package/lib/DragAndDrop.js +1 -1
- package/lib/Factory.js +2 -2
- package/lib/FastLayer.js +3 -3
- package/lib/Global.d.ts +0 -1
- package/lib/Global.js +13 -7
- package/lib/Group.js +5 -5
- package/lib/Layer.d.ts +1 -1
- package/lib/Layer.js +8 -8
- package/lib/Node.js +32 -26
- package/lib/PointerEvents.js +1 -1
- package/lib/Shape.js +8 -27
- package/lib/Stage.js +8 -8
- package/lib/Tween.js +4 -4
- package/lib/Util.d.ts +67 -3
- package/lib/Util.js +122 -41
- package/lib/Validators.js +2 -2
- package/lib/_CoreInternals.d.ts +15 -11
- package/lib/_CoreInternals.js +16 -14
- package/lib/_FullInternals.d.ts +14 -10
- package/lib/_FullInternals.js +38 -38
- package/lib/canvas-backend.js +6 -15
- package/lib/filters/Blur.js +3 -3
- package/lib/filters/Brighten.js +3 -3
- package/lib/filters/Brightness.js +2 -2
- package/lib/filters/Contrast.js +3 -3
- package/lib/filters/Emboss.js +10 -9
- package/lib/filters/Enhance.js +3 -3
- package/lib/filters/HSL.js +3 -3
- package/lib/filters/HSV.js +3 -3
- package/lib/filters/Kaleidoscope.js +3 -3
- package/lib/filters/Mask.js +3 -3
- package/lib/filters/Noise.js +3 -3
- package/lib/filters/Pixelate.js +4 -4
- package/lib/filters/Posterize.js +3 -3
- package/lib/filters/RGB.js +3 -3
- package/lib/filters/RGBA.js +3 -3
- package/lib/filters/Threshold.js +3 -3
- package/lib/index.js +1 -1
- package/lib/napi-backend.d.ts +2 -0
- package/lib/napi-backend.js +15 -0
- package/lib/shapes/Arc.js +5 -5
- package/lib/shapes/Arrow.js +5 -5
- package/lib/shapes/Circle.js +4 -4
- package/lib/shapes/Ellipse.js +4 -4
- package/lib/shapes/Image.js +5 -5
- package/lib/shapes/Label.js +7 -7
- package/lib/shapes/Line.js +6 -6
- package/lib/shapes/Path.js +5 -5
- package/lib/shapes/Rect.js +5 -5
- package/lib/shapes/RegularPolygon.js +5 -5
- package/lib/shapes/Ring.js +4 -4
- package/lib/shapes/Sprite.js +5 -5
- package/lib/shapes/Star.js +4 -4
- package/lib/shapes/Text.d.ts +0 -1
- package/lib/shapes/Text.js +32 -30
- package/lib/shapes/TextPath.js +7 -7
- package/lib/shapes/Transformer.js +12 -11
- package/lib/shapes/Wedge.js +5 -5
- package/lib/skia-backend.js +17 -25
- package/package.json +31 -34
package/lib/skia-backend.js
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
import { Konva } from
|
|
2
|
-
// @ts-ignore
|
|
1
|
+
import { Konva } from './_CoreInternals.js';
|
|
3
2
|
import { Canvas, DOMMatrix, Image, Path2D } from 'skia-canvas';
|
|
4
3
|
// @ts-ignore
|
|
5
4
|
global.DOMMatrix = DOMMatrix;
|
|
6
5
|
// @ts-ignore
|
|
7
6
|
global.Path2D = Path2D;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
node
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
// create image in Node env
|
|
25
|
-
Konva.Util.createImageElement = () => {
|
|
26
|
-
const node = new Image();
|
|
27
|
-
node.toString = () => '[object HTMLImageElement]';
|
|
28
|
-
return node;
|
|
29
|
-
};
|
|
30
|
-
Konva._renderBackend = 'skia-canvas';
|
|
7
|
+
Konva.setCanvasBackend({
|
|
8
|
+
name: 'skia-canvas',
|
|
9
|
+
createCanvas: () => {
|
|
10
|
+
const node = new Canvas(300, 300);
|
|
11
|
+
const ctx = node.getContext('2d');
|
|
12
|
+
// Override the getter to return the canvas node directly
|
|
13
|
+
// because in skia-canvas canvas is using weak ref to the canvas node
|
|
14
|
+
// and somehow on many tests it fails to get the canvas node
|
|
15
|
+
Object.defineProperty(ctx, 'canvas', {
|
|
16
|
+
get: () => node,
|
|
17
|
+
});
|
|
18
|
+
return node;
|
|
19
|
+
},
|
|
20
|
+
createImage: () => new Image(),
|
|
21
|
+
createPath2D: (path) => new Path2D(path),
|
|
22
|
+
});
|
|
31
23
|
// the core Konva object, without shapes and filters. `import 'konva'` extends
|
|
32
24
|
// this same object with them
|
|
33
25
|
export default Konva;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "konva",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.10.0",
|
|
4
4
|
"description": "HTML5 2d canvas library for interactive graphics, design editors, whiteboards, and diagrams.",
|
|
5
5
|
"author": "Anton Lavrenov",
|
|
6
6
|
"type": "module",
|
|
@@ -31,30 +31,32 @@
|
|
|
31
31
|
"types": "./lib/skia-backend.d.ts",
|
|
32
32
|
"default": "./lib/skia-backend.js"
|
|
33
33
|
},
|
|
34
|
+
"./napi-backend": {
|
|
35
|
+
"types": "./lib/napi-backend.d.ts",
|
|
36
|
+
"default": "./lib/napi-backend.js"
|
|
37
|
+
},
|
|
34
38
|
"./package.json": "./package.json"
|
|
35
39
|
},
|
|
36
40
|
"main": "./lib/index.js",
|
|
37
41
|
"types": "./lib/index.d.ts",
|
|
38
42
|
"scripts": {
|
|
39
43
|
"start": "npm run test:watch",
|
|
40
|
-
"compile": "npm run clean &&
|
|
44
|
+
"compile": "npm run clean && tsc && rollup lib/index.js --file konva.js --format umd --name Konva --no-freeze",
|
|
41
45
|
"prepublishOnly": "npm run build",
|
|
42
|
-
"build": "npm run compile &&
|
|
46
|
+
"build": "npm run compile && node build.mjs",
|
|
43
47
|
"fmt": "prettier --write .",
|
|
44
48
|
"fmt:check": "prettier --check .",
|
|
45
49
|
"test:import": "npm run build && node ./test/import-test.cjs && node ./test/import-test.mjs",
|
|
46
50
|
"test": "npm run test:types && npm run test:browser && npm run test:node && npm run test:import",
|
|
47
51
|
"test:types": "tsc -p test/types/tsconfig.json",
|
|
48
52
|
"test:build": "rimraf ./.parcel-cache && PARCEL_WORKER_BACKEND=process parcel build ./test/unit-tests.html --dist-dir ./test-build --target none --public-url ./ --no-source-maps",
|
|
49
|
-
"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security -a no-sandbox -a disable-setuid-sandbox",
|
|
53
|
+
"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security -a allow-file-access-from-files -a no-sandbox -a disable-setuid-sandbox",
|
|
50
54
|
"test:watch": "rimraf ./.parcel-cache && PARCEL_WORKERS=0 parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html ./test/bunnies.html",
|
|
51
|
-
"test:node:canvas": "mocha -r tsx
|
|
52
|
-
"test:node:skia": "mocha -r tsx
|
|
53
|
-
"test:node": "
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"clean": "rimraf ./lib ./test-build",
|
|
57
|
-
"watch": "rollup -c -w"
|
|
55
|
+
"test:node:canvas": "mocha -r tsx --file ./test/node-canvas-setup.ts --file ./test/setup.ts --extension ts --recursive './test/unit/'",
|
|
56
|
+
"test:node:skia": "mocha -r tsx --file ./test/node-skia-setup.ts --file ./test/setup.ts --extension ts --recursive './test/unit/'",
|
|
57
|
+
"test:node:napi": "mocha -r tsx --file ./test/node-napi-setup.ts --file ./test/setup.ts --extension ts --recursive './test/unit/'",
|
|
58
|
+
"test:node": "npm run test:node:canvas && npm run test:node:skia && npm run test:node:napi",
|
|
59
|
+
"clean": "rimraf ./lib ./test-build"
|
|
58
60
|
},
|
|
59
61
|
"targets": {
|
|
60
62
|
"none": {}
|
|
@@ -74,35 +76,30 @@
|
|
|
74
76
|
}
|
|
75
77
|
],
|
|
76
78
|
"devDependencies": {
|
|
77
|
-
"@
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"gulp-util": "^3.0.8",
|
|
88
|
-
"mocha": "^10",
|
|
89
|
-
"mocha-headless-chrome": "^4.0.0",
|
|
90
|
-
"parcel": "2.15.4",
|
|
91
|
-
"prettier": "^3.7.4",
|
|
92
|
-
"process": "^0.11.10",
|
|
93
|
-
"rimraf": "^6.1.2",
|
|
94
|
-
"rollup": "^4.55.1",
|
|
95
|
-
"rollup-plugin-typescript2": "^0.37.0",
|
|
96
|
-
"skia-canvas": "^3.0.4",
|
|
79
|
+
"@napi-rs/canvas": "^1.1.1",
|
|
80
|
+
"canvas": "^3.2.3",
|
|
81
|
+
"chai": "6.3.0",
|
|
82
|
+
"mocha": "^12.0.3",
|
|
83
|
+
"mocha-headless-chrome": "^5.1.0",
|
|
84
|
+
"parcel": "2.16.4",
|
|
85
|
+
"prettier": "^3.10.1",
|
|
86
|
+
"rimraf": "^6.1.4",
|
|
87
|
+
"rollup": "^4.68.7",
|
|
88
|
+
"skia-canvas": "^4.0.1",
|
|
97
89
|
"stats.js": "0.17.0",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
90
|
+
"terser": "^5.51.2",
|
|
91
|
+
"tsx": "^4.23.15",
|
|
92
|
+
"typescript": "^7.0.2"
|
|
100
93
|
},
|
|
101
94
|
"peerDependencies": {
|
|
95
|
+
"@napi-rs/canvas": "^1.1.0",
|
|
102
96
|
"canvas": "^3.0.0",
|
|
103
|
-
"skia-canvas": "^3.0.0"
|
|
97
|
+
"skia-canvas": "^3.0.0 || ^4.0.0"
|
|
104
98
|
},
|
|
105
99
|
"peerDependenciesMeta": {
|
|
100
|
+
"@napi-rs/canvas": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
106
103
|
"canvas": {
|
|
107
104
|
"optional": true
|
|
108
105
|
},
|