konva 8.3.12 → 8.3.14
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/Canvas.js +1 -0
- package/cmj/Context.d.ts +7 -0
- package/cmj/Context.js +11 -1
- package/cmj/Global.d.ts +1 -0
- package/cmj/Global.js +2 -1
- package/cmj/Layer.d.ts +1 -0
- package/cmj/Layer.js +4 -0
- package/cmj/Node.d.ts +1 -1
- package/cmj/Node.js +6 -1
- package/cmj/Shape.js +5 -2
- package/cmj/Stage.js +2 -1
- package/cmj/Util.d.ts +1 -0
- package/cmj/Util.js +8 -0
- package/cmj/_CoreInternals.d.ts +2 -0
- package/cmj/_FullInternals.d.ts +2 -0
- package/cmj/filters/Kaleidoscope.js +1 -0
- package/cmj/shapes/Ring.d.ts +0 -1
- package/cmj/shapes/TextPath.d.ts +1 -0
- package/cmj/shapes/TextPath.js +4 -0
- package/konva.js +55 -9
- package/konva.min.js +3 -3
- package/lib/Canvas.js +1 -0
- package/lib/Context.d.ts +7 -0
- package/lib/Context.js +11 -1
- package/lib/Global.d.ts +1 -0
- package/lib/Global.js +2 -1
- package/lib/Layer.d.ts +1 -0
- package/lib/Layer.js +4 -0
- package/lib/Node.d.ts +1 -1
- package/lib/Node.js +6 -1
- package/lib/Shape.js +5 -2
- package/lib/Stage.js +2 -1
- package/lib/Util.d.ts +1 -0
- package/lib/Util.js +8 -0
- package/lib/_CoreInternals.d.ts +2 -0
- package/lib/_FullInternals.d.ts +2 -0
- package/lib/filters/Kaleidoscope.js +1 -0
- package/lib/shapes/Ring.d.ts +0 -1
- package/lib/shapes/TextPath.d.ts +1 -0
- package/lib/shapes/TextPath.js +4 -0
- package/package.json +1 -1
package/lib/Canvas.js
CHANGED
package/lib/Context.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Canvas } from './Canvas';
|
|
2
2
|
import { Shape } from './Shape';
|
|
3
|
+
declare var CONTEXT_PROPERTIES: readonly ["fillStyle", "strokeStyle", "shadowColor", "shadowBlur", "shadowOffsetX", "shadowOffsetY", "lineCap", "lineDashOffset", "lineJoin", "lineWidth", "miterLimit", "font", "textAlign", "textBaseline", "globalAlpha", "globalCompositeOperation", "imageSmoothingEnabled"];
|
|
3
4
|
export declare class Context {
|
|
4
5
|
canvas: Canvas;
|
|
5
6
|
_context: CanvasRenderingContext2D;
|
|
@@ -59,7 +60,11 @@ export declare class Context {
|
|
|
59
60
|
_enableTrace(): void;
|
|
60
61
|
_applyGlobalCompositeOperation(node: any): void;
|
|
61
62
|
}
|
|
63
|
+
declare type CanvasContextProps = Pick<CanvasRenderingContext2D, typeof CONTEXT_PROPERTIES[number]>;
|
|
64
|
+
export interface Context extends CanvasContextProps {
|
|
65
|
+
}
|
|
62
66
|
export declare class SceneContext extends Context {
|
|
67
|
+
constructor(canvas: Canvas);
|
|
63
68
|
_fillColor(shape: Shape): void;
|
|
64
69
|
_fillPattern(shape: any): void;
|
|
65
70
|
_fillLinearGradient(shape: any): void;
|
|
@@ -70,7 +75,9 @@ export declare class SceneContext extends Context {
|
|
|
70
75
|
_applyShadow(shape: any): void;
|
|
71
76
|
}
|
|
72
77
|
export declare class HitContext extends Context {
|
|
78
|
+
constructor(canvas: Canvas);
|
|
73
79
|
_fill(shape: any): void;
|
|
74
80
|
strokeShape(shape: Shape): void;
|
|
75
81
|
_stroke(shape: any): void;
|
|
76
82
|
}
|
|
83
|
+
export {};
|
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();
|
|
@@ -367,6 +366,7 @@ export class Context {
|
|
|
367
366
|
}
|
|
368
367
|
}
|
|
369
368
|
}
|
|
369
|
+
;
|
|
370
370
|
CONTEXT_PROPERTIES.forEach(function (prop) {
|
|
371
371
|
Object.defineProperty(Context.prototype, prop, {
|
|
372
372
|
get() {
|
|
@@ -378,6 +378,10 @@ CONTEXT_PROPERTIES.forEach(function (prop) {
|
|
|
378
378
|
});
|
|
379
379
|
});
|
|
380
380
|
export class SceneContext extends Context {
|
|
381
|
+
constructor(canvas) {
|
|
382
|
+
super(canvas);
|
|
383
|
+
this._context = canvas._canvas.getContext('2d');
|
|
384
|
+
}
|
|
381
385
|
_fillColor(shape) {
|
|
382
386
|
var fill = shape.fill();
|
|
383
387
|
this.setAttr('fillStyle', fill);
|
|
@@ -487,6 +491,12 @@ export class SceneContext extends Context {
|
|
|
487
491
|
}
|
|
488
492
|
}
|
|
489
493
|
export class HitContext extends Context {
|
|
494
|
+
constructor(canvas) {
|
|
495
|
+
super(canvas);
|
|
496
|
+
this._context = canvas._canvas.getContext('2d', {
|
|
497
|
+
willReadFrequently: true,
|
|
498
|
+
});
|
|
499
|
+
}
|
|
490
500
|
_fill(shape) {
|
|
491
501
|
this.save();
|
|
492
502
|
this.setAttr('fillStyle', shape.colorKey);
|
package/lib/Global.d.ts
CHANGED
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.14',
|
|
17
17
|
isBrowser: detectBrowser(),
|
|
18
18
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
19
19
|
dblClickWindow: 400,
|
|
@@ -45,6 +45,7 @@ export const Konva = {
|
|
|
45
45
|
isDragReady() {
|
|
46
46
|
return !!Konva['DD'].node;
|
|
47
47
|
},
|
|
48
|
+
releaseCanvasOnDestroy: true,
|
|
48
49
|
document: glob.document,
|
|
49
50
|
_injectGlobal(Konva) {
|
|
50
51
|
glob.Konva = Konva;
|
package/lib/Layer.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export declare class Layer extends Container<Group | Shape> {
|
|
|
54
54
|
setHitGraphEnabled(val: any): void;
|
|
55
55
|
getHitGraphEnabled(val: any): boolean;
|
|
56
56
|
toggleHitCanvas(): void;
|
|
57
|
+
destroy(): this;
|
|
57
58
|
hitGraphEnabled: GetSet<boolean, this>;
|
|
58
59
|
clearBeforeDraw: GetSet<boolean, this>;
|
|
59
60
|
imageSmoothingEnabled: GetSet<boolean, this>;
|
package/lib/Layer.js
CHANGED
|
@@ -293,6 +293,10 @@ export class Layer extends Container {
|
|
|
293
293
|
parent.content.appendChild(this.hitCanvas._canvas);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
+
destroy() {
|
|
297
|
+
Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas);
|
|
298
|
+
return super.destroy();
|
|
299
|
+
}
|
|
296
300
|
}
|
|
297
301
|
Layer.prototype.nodeType = 'Layer';
|
|
298
302
|
_registerNode(Layer);
|
package/lib/Node.d.ts
CHANGED
package/lib/Node.js
CHANGED
|
@@ -82,7 +82,11 @@ export class Node {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
clearCache() {
|
|
85
|
-
this._cache.
|
|
85
|
+
if (this._cache.has(CANVAS)) {
|
|
86
|
+
const { scene, filter, hit } = this._cache.get(CANVAS);
|
|
87
|
+
Util.releaseCanvas(scene, filter, hit);
|
|
88
|
+
this._cache.delete(CANVAS);
|
|
89
|
+
}
|
|
86
90
|
this._clearSelfAndDescendantCache();
|
|
87
91
|
this._requestDraw();
|
|
88
92
|
return this;
|
|
@@ -350,6 +354,7 @@ export class Node {
|
|
|
350
354
|
}
|
|
351
355
|
destroy() {
|
|
352
356
|
this.remove();
|
|
357
|
+
this.clearCache();
|
|
353
358
|
return this;
|
|
354
359
|
}
|
|
355
360
|
getAttr(attr) {
|
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
|
@@ -179,6 +179,7 @@ export class Stage extends Container {
|
|
|
179
179
|
if (index > -1) {
|
|
180
180
|
stages.splice(index, 1);
|
|
181
181
|
}
|
|
182
|
+
Util.releaseCanvas(this.bufferCanvas._canvas, this.bufferHitCanvas._canvas);
|
|
182
183
|
return this;
|
|
183
184
|
}
|
|
184
185
|
getPointerPosition() {
|
|
@@ -302,7 +303,7 @@ export class Stage extends Container {
|
|
|
302
303
|
EVENTS.forEach(([event, methodName]) => {
|
|
303
304
|
this.content.addEventListener(event, (evt) => {
|
|
304
305
|
this[methodName](evt);
|
|
305
|
-
});
|
|
306
|
+
}, { passive: false });
|
|
306
307
|
});
|
|
307
308
|
}
|
|
308
309
|
_pointerenter(evt) {
|
package/lib/Util.d.ts
CHANGED
package/lib/Util.js
CHANGED
|
@@ -740,4 +740,12 @@ export const Util = {
|
|
|
740
740
|
return evt.changedTouches[0].identifier;
|
|
741
741
|
}
|
|
742
742
|
},
|
|
743
|
+
releaseCanvas(...canvases) {
|
|
744
|
+
if (!Konva.releaseCanvasOnDestroy)
|
|
745
|
+
return;
|
|
746
|
+
canvases.forEach(c => {
|
|
747
|
+
c.width = 0;
|
|
748
|
+
c.height = 0;
|
|
749
|
+
});
|
|
750
|
+
}
|
|
743
751
|
};
|
package/lib/_CoreInternals.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare const Konva: {
|
|
|
38
38
|
dragButtons: number[];
|
|
39
39
|
isDragging(): any;
|
|
40
40
|
isDragReady(): boolean;
|
|
41
|
+
releaseCanvasOnDestroy: boolean;
|
|
41
42
|
document: any;
|
|
42
43
|
_injectGlobal(Konva: any): void;
|
|
43
44
|
} & {
|
|
@@ -93,6 +94,7 @@ export declare const Konva: {
|
|
|
93
94
|
_prepareToStringify(obj: any): any;
|
|
94
95
|
_assign<T, U>(target: T, source: U): T & U;
|
|
95
96
|
_getFirstPointerId(evt: any): any;
|
|
97
|
+
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
|
|
96
98
|
};
|
|
97
99
|
Transform: typeof Transform;
|
|
98
100
|
Node: typeof Node;
|
package/lib/_FullInternals.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare const Konva: {
|
|
|
43
43
|
dragButtons: number[];
|
|
44
44
|
isDragging(): any;
|
|
45
45
|
isDragReady(): boolean;
|
|
46
|
+
releaseCanvasOnDestroy: boolean;
|
|
46
47
|
document: any;
|
|
47
48
|
_injectGlobal(Konva: any): void;
|
|
48
49
|
} & {
|
|
@@ -98,6 +99,7 @@ export declare const Konva: {
|
|
|
98
99
|
_prepareToStringify(obj: any): any;
|
|
99
100
|
_assign<T, U>(target: T, source: U): T & U;
|
|
100
101
|
_getFirstPointerId(evt: any): any;
|
|
102
|
+
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
|
|
101
103
|
};
|
|
102
104
|
Transform: typeof import("./Util").Transform;
|
|
103
105
|
Node: typeof import("./Node").Node;
|
|
@@ -76,6 +76,7 @@ export const Kaleidoscope = function (imageData) {
|
|
|
76
76
|
var scratchData = tempCanvas
|
|
77
77
|
.getContext('2d')
|
|
78
78
|
.getImageData(0, 0, xSize, ySize);
|
|
79
|
+
Util.releaseCanvas(tempCanvas);
|
|
79
80
|
ToPolar(imageData, scratchData, {
|
|
80
81
|
polarCenterX: xSize / 2,
|
|
81
82
|
polarCenterY: ySize / 2,
|
package/lib/shapes/Ring.d.ts
CHANGED
package/lib/shapes/TextPath.d.ts
CHANGED
package/lib/shapes/TextPath.js
CHANGED
|
@@ -322,6 +322,10 @@ export class TextPath extends Shape {
|
|
|
322
322
|
height: maxY - minY + fontSize,
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
|
+
destroy() {
|
|
326
|
+
Util.releaseCanvas(this.dummyCanvas);
|
|
327
|
+
return super.destroy();
|
|
328
|
+
}
|
|
325
329
|
}
|
|
326
330
|
TextPath.prototype._fillFunc = _fillFunc;
|
|
327
331
|
TextPath.prototype._strokeFunc = _strokeFunc;
|