konva 8.3.11 → 8.3.13
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/cmj/Context.d.ts +2 -0
- package/cmj/Context.js +10 -1
- package/cmj/Factory.d.ts +1 -1
- package/cmj/Factory.js +5 -0
- package/cmj/Global.js +1 -1
- package/cmj/Node.d.ts +3 -3
- package/cmj/Node.js +1 -1
- package/cmj/Shape.js +5 -2
- package/cmj/Stage.js +1 -1
- package/cmj/Validators.js +7 -0
- package/cmj/shapes/Line.d.ts +1 -1
- package/cmj/shapes/Ring.d.ts +0 -1
- package/cmj/shapes/Text.js +1 -1
- package/cmj/shapes/TextPath.js +1 -1
- package/cmj/shapes/Transformer.d.ts +1 -6
- package/cmj/shapes/Transformer.js +6 -1
- package/konva.js +65 -34
- package/konva.min.js +3 -3
- package/lib/Context.d.ts +2 -0
- package/lib/Context.js +10 -1
- package/lib/Factory.d.ts +1 -1
- package/lib/Factory.js +5 -0
- package/lib/Global.js +1 -1
- package/lib/Node.d.ts +3 -3
- package/lib/Node.js +1 -1
- package/lib/Shape.js +5 -2
- package/lib/Stage.js +1 -1
- package/lib/Validators.js +7 -0
- package/lib/shapes/Line.d.ts +1 -1
- package/lib/shapes/Ring.d.ts +0 -1
- package/lib/shapes/Text.js +1 -1
- package/lib/shapes/TextPath.js +1 -1
- package/lib/shapes/Transformer.d.ts +1 -6
- package/lib/shapes/Transformer.js +6 -1
- package/package.json +13 -13
package/lib/Context.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export declare class Context {
|
|
|
60
60
|
_applyGlobalCompositeOperation(node: any): void;
|
|
61
61
|
}
|
|
62
62
|
export declare class SceneContext extends Context {
|
|
63
|
+
constructor(canvas: Canvas);
|
|
63
64
|
_fillColor(shape: Shape): void;
|
|
64
65
|
_fillPattern(shape: any): void;
|
|
65
66
|
_fillLinearGradient(shape: any): void;
|
|
@@ -70,6 +71,7 @@ export declare class SceneContext extends Context {
|
|
|
70
71
|
_applyShadow(shape: any): void;
|
|
71
72
|
}
|
|
72
73
|
export declare class HitContext extends Context {
|
|
74
|
+
constructor(canvas: Canvas);
|
|
73
75
|
_fill(shape: any): void;
|
|
74
76
|
strokeShape(shape: Shape): void;
|
|
75
77
|
_stroke(shape: any): void;
|
package/lib/Context.js
CHANGED
|
@@ -70,7 +70,6 @@ const traceArrMax = 100;
|
|
|
70
70
|
export class Context {
|
|
71
71
|
constructor(canvas) {
|
|
72
72
|
this.canvas = canvas;
|
|
73
|
-
this._context = canvas._canvas.getContext('2d');
|
|
74
73
|
if (Konva.enableTrace) {
|
|
75
74
|
this.traceArr = [];
|
|
76
75
|
this._enableTrace();
|
|
@@ -378,6 +377,10 @@ CONTEXT_PROPERTIES.forEach(function (prop) {
|
|
|
378
377
|
});
|
|
379
378
|
});
|
|
380
379
|
export class SceneContext extends Context {
|
|
380
|
+
constructor(canvas) {
|
|
381
|
+
super(canvas);
|
|
382
|
+
this._context = canvas._canvas.getContext('2d');
|
|
383
|
+
}
|
|
381
384
|
_fillColor(shape) {
|
|
382
385
|
var fill = shape.fill();
|
|
383
386
|
this.setAttr('fillStyle', fill);
|
|
@@ -487,6 +490,12 @@ export class SceneContext extends Context {
|
|
|
487
490
|
}
|
|
488
491
|
}
|
|
489
492
|
export class HitContext extends Context {
|
|
493
|
+
constructor(canvas) {
|
|
494
|
+
super(canvas);
|
|
495
|
+
this._context = canvas._canvas.getContext('2d', {
|
|
496
|
+
willReadFrequently: true,
|
|
497
|
+
});
|
|
498
|
+
}
|
|
490
499
|
_fill(shape) {
|
|
491
500
|
this.save();
|
|
492
501
|
this.setAttr('fillStyle', shape.colorKey);
|
package/lib/Factory.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare const Factory: {
|
|
|
3
3
|
addGetter(constructor: any, attr: any, def?: any): void;
|
|
4
4
|
addSetter(constructor: any, attr: any, validator?: any, after?: any): void;
|
|
5
5
|
overWriteSetter(constructor: any, attr: any, validator?: any, after?: any): void;
|
|
6
|
-
addComponentsGetterSetter(constructor: any, attr:
|
|
6
|
+
addComponentsGetterSetter(constructor: any, attr: string, components: Array<string>, validator?: Function, after?: Function): void;
|
|
7
7
|
addOverloadedGetterSetter(constructor: any, attr: any): void;
|
|
8
8
|
addDeprecatedGetterSetter(constructor: any, attr: any, def: any, validator: any): void;
|
|
9
9
|
backCompat(constructor: any, methods: any): void;
|
package/lib/Factory.js
CHANGED
|
@@ -60,6 +60,11 @@ export const Factory = {
|
|
|
60
60
|
}
|
|
61
61
|
this._setAttr(attr + capitalize(key), val[key]);
|
|
62
62
|
}
|
|
63
|
+
if (!val) {
|
|
64
|
+
components.forEach((component) => {
|
|
65
|
+
this._setAttr(attr + capitalize(component), undefined);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
63
68
|
this._fireChangeEvent(attr, oldVal, val);
|
|
64
69
|
if (after) {
|
|
65
70
|
after.call(this);
|
package/lib/Global.js
CHANGED
|
@@ -13,7 +13,7 @@ export const glob = typeof global !== 'undefined'
|
|
|
13
13
|
: {};
|
|
14
14
|
export const Konva = {
|
|
15
15
|
_global: glob,
|
|
16
|
-
version: '8.3.
|
|
16
|
+
version: '8.3.13',
|
|
17
17
|
isBrowser: detectBrowser(),
|
|
18
18
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
19
19
|
dblClickWindow: 400,
|
package/lib/Node.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface NodeConfig {
|
|
|
18
18
|
listening?: boolean;
|
|
19
19
|
id?: string;
|
|
20
20
|
name?: string;
|
|
21
|
-
opacity?:
|
|
21
|
+
opacity?: number;
|
|
22
22
|
scale?: Vector2d;
|
|
23
23
|
scaleX?: number;
|
|
24
24
|
scaleY?: number;
|
|
@@ -179,7 +179,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
179
179
|
getParent(): Container<Node<NodeConfig>>;
|
|
180
180
|
findAncestors(selector: string, includeSelf?: boolean, stopNode?: Node): Node<NodeConfig>[];
|
|
181
181
|
isAncestorOf(node: Node): boolean;
|
|
182
|
-
findAncestor(selector?: string, includeSelf?: boolean, stopNode?: Container):
|
|
182
|
+
findAncestor(selector?: string, includeSelf?: boolean, stopNode?: Container): Node<NodeConfig>;
|
|
183
183
|
_isMatch(selector: string | Function): any;
|
|
184
184
|
getLayer(): Layer | null;
|
|
185
185
|
getStage(): Stage | null;
|
|
@@ -303,7 +303,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
303
303
|
opacity: GetSet<number, this>;
|
|
304
304
|
rotation: GetSet<number, this>;
|
|
305
305
|
zIndex: GetSet<number, this>;
|
|
306
|
-
scale: GetSet<Vector2d, this>;
|
|
306
|
+
scale: GetSet<Vector2d | undefined, this>;
|
|
307
307
|
scaleX: GetSet<number, this>;
|
|
308
308
|
scaleY: GetSet<number, this>;
|
|
309
309
|
skew: GetSet<Vector2d, this>;
|
package/lib/Node.js
CHANGED
|
@@ -985,7 +985,7 @@ export class Node {
|
|
|
985
985
|
const callback = config === null || config === void 0 ? void 0 : config.callback;
|
|
986
986
|
if (callback)
|
|
987
987
|
delete config.callback;
|
|
988
|
-
this.toCanvas(config).toBlob(blob => {
|
|
988
|
+
this.toCanvas(config).toBlob((blob) => {
|
|
989
989
|
resolve(blob);
|
|
990
990
|
callback === null || callback === void 0 ? void 0 : callback(blob);
|
|
991
991
|
});
|
package/lib/Shape.js
CHANGED
|
@@ -149,8 +149,11 @@ export class Shape extends Node {
|
|
|
149
149
|
return this._getCache(SHADOW_RGBA, this._getShadowRGBA);
|
|
150
150
|
}
|
|
151
151
|
_getShadowRGBA() {
|
|
152
|
-
if (this.hasShadow()) {
|
|
153
|
-
|
|
152
|
+
if (!this.hasShadow()) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
var rgba = Util.colorToRGBA(this.shadowColor());
|
|
156
|
+
if (rgba) {
|
|
154
157
|
return ('rgba(' +
|
|
155
158
|
rgba.r +
|
|
156
159
|
',' +
|
package/lib/Stage.js
CHANGED
package/lib/Validators.js
CHANGED
|
@@ -120,6 +120,10 @@ export function getFunctionValidator() {
|
|
|
120
120
|
export function getNumberArrayValidator() {
|
|
121
121
|
if (Konva.isUnminified) {
|
|
122
122
|
return function (val, attr) {
|
|
123
|
+
const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
|
|
124
|
+
if (TypedArray && val instanceof TypedArray) {
|
|
125
|
+
return val;
|
|
126
|
+
}
|
|
123
127
|
if (!Util._isArray(val)) {
|
|
124
128
|
Util.warn(_formatValue(val) +
|
|
125
129
|
' is a not valid value for "' +
|
|
@@ -158,6 +162,9 @@ export function getBooleanValidator() {
|
|
|
158
162
|
export function getComponentValidator(components) {
|
|
159
163
|
if (Konva.isUnminified) {
|
|
160
164
|
return function (val, attr) {
|
|
165
|
+
if (val === undefined || val === null) {
|
|
166
|
+
return val;
|
|
167
|
+
}
|
|
161
168
|
if (!Util.isObject(val)) {
|
|
162
169
|
Util.warn(_formatValue(val) +
|
|
163
170
|
' is a not valid value for "' +
|
package/lib/shapes/Line.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Shape, ShapeConfig } from '../Shape';
|
|
|
2
2
|
import { GetSet } from '../types';
|
|
3
3
|
import { Context } from '../Context';
|
|
4
4
|
export interface LineConfig extends ShapeConfig {
|
|
5
|
-
points?: number[];
|
|
5
|
+
points?: number[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
|
6
6
|
tension?: number;
|
|
7
7
|
closed?: boolean;
|
|
8
8
|
bezier?: boolean;
|
package/lib/shapes/Ring.d.ts
CHANGED
package/lib/shapes/Text.js
CHANGED
|
@@ -300,7 +300,7 @@ export class Text extends Shape {
|
|
|
300
300
|
this._addTextLine(line);
|
|
301
301
|
currentHeightPx += lineHeightPx;
|
|
302
302
|
textWidth = Math.max(textWidth, lineWidth);
|
|
303
|
-
if (this._shouldHandleEllipsis(currentHeightPx)) {
|
|
303
|
+
if (this._shouldHandleEllipsis(currentHeightPx) && i < max - 1) {
|
|
304
304
|
this._tryToAddEllipsisToLastLine();
|
|
305
305
|
}
|
|
306
306
|
}
|
package/lib/shapes/TextPath.js
CHANGED
|
@@ -86,12 +86,7 @@ export declare class Transformer extends Group {
|
|
|
86
86
|
stopTransform(): void;
|
|
87
87
|
destroy(): this;
|
|
88
88
|
toObject(): any;
|
|
89
|
-
getClientRect():
|
|
90
|
-
x: number;
|
|
91
|
-
y: number;
|
|
92
|
-
width: number;
|
|
93
|
-
height: number;
|
|
94
|
-
};
|
|
89
|
+
getClientRect(): IRect;
|
|
95
90
|
nodes: GetSet<Node[], this>;
|
|
96
91
|
enabledAnchors: GetSet<string[], this>;
|
|
97
92
|
rotationSnaps: GetSet<number[], this>;
|
|
@@ -897,7 +897,12 @@ export class Transformer extends Group {
|
|
|
897
897
|
return Node.prototype.toObject.call(this);
|
|
898
898
|
}
|
|
899
899
|
getClientRect() {
|
|
900
|
-
|
|
900
|
+
if (this.nodes().length > 0) {
|
|
901
|
+
return super.getClientRect();
|
|
902
|
+
}
|
|
903
|
+
else {
|
|
904
|
+
return { x: 0, y: 0, width: 0, height: 0 };
|
|
905
|
+
}
|
|
901
906
|
}
|
|
902
907
|
}
|
|
903
908
|
function validateAnchors(val) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "konva",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.13",
|
|
4
4
|
"author": "Anton Lavrenov",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"test": "npm run test:browser && npm run test:node",
|
|
50
50
|
"test:build": "parcel build ./test/unit-tests.html --dist-dir ./test-build --target none --public-url ./ --no-source-maps",
|
|
51
51
|
"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security",
|
|
52
|
-
"test:node": "
|
|
52
|
+
"test:node": "ts-mocha -p ./test/tsconfig.json test/unit/**/*.ts --exit && npm run test:import",
|
|
53
53
|
"test:watch": "rm -rf ./parcel-cache && parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html",
|
|
54
54
|
"tsc": "tsc --removeComments && tsc --build ./tsconfig-cmj.json",
|
|
55
55
|
"rollup": "rollup -c",
|
|
@@ -88,10 +88,10 @@
|
|
|
88
88
|
}
|
|
89
89
|
],
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@parcel/transformer-image": "2.
|
|
92
|
-
"@size-limit/preset-big-lib": "^
|
|
91
|
+
"@parcel/transformer-image": "2.7.0",
|
|
92
|
+
"@size-limit/preset-big-lib": "^8.0.0",
|
|
93
93
|
"@types/mocha": "^9.1.1",
|
|
94
|
-
"canvas": "^2.9.
|
|
94
|
+
"canvas": "^2.9.3",
|
|
95
95
|
"chai": "4.3.6",
|
|
96
96
|
"filehound": "^1.17.6",
|
|
97
97
|
"gulp": "^4.0.2",
|
|
@@ -105,19 +105,19 @@
|
|
|
105
105
|
"gulp-uglify": "^3.0.2",
|
|
106
106
|
"gulp-uglify-es": "^3.0.0",
|
|
107
107
|
"gulp-util": "^3.0.8",
|
|
108
|
-
"mocha": "
|
|
108
|
+
"mocha": "10.0.0",
|
|
109
109
|
"mocha-headless-chrome": "^4.0.0",
|
|
110
|
-
"parcel": "2.
|
|
110
|
+
"parcel": "2.7.0",
|
|
111
111
|
"process": "^0.11.10",
|
|
112
|
-
"rollup": "^2.
|
|
112
|
+
"rollup": "^2.77.2",
|
|
113
113
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
114
114
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
115
115
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
116
|
-
"rollup-plugin-typescript2": "^0.
|
|
117
|
-
"size-limit": "^
|
|
118
|
-
"ts-mocha": "^
|
|
119
|
-
"ts-node": "^9.1
|
|
120
|
-
"typescript": "^4.
|
|
116
|
+
"rollup-plugin-typescript2": "^0.32.1",
|
|
117
|
+
"size-limit": "^8.0.0",
|
|
118
|
+
"ts-mocha": "^10.0.0",
|
|
119
|
+
"ts-node": "^10.9.1",
|
|
120
|
+
"typescript": "^4.7.4"
|
|
121
121
|
},
|
|
122
122
|
"keywords": [
|
|
123
123
|
"canvas",
|