konva 8.3.13 → 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/lib/Canvas.js CHANGED
@@ -19,6 +19,7 @@ function getDevicePixelRatio() {
19
19
  1;
20
20
  return devicePixelRatio / backingStoreRatio;
21
21
  })();
22
+ Util.releaseCanvas(canvas);
22
23
  return _pixelRatio;
23
24
  }
24
25
  export class Canvas {
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,6 +60,9 @@ 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 {
63
67
  constructor(canvas: Canvas);
64
68
  _fillColor(shape: Shape): void;
@@ -76,3 +80,4 @@ export declare class HitContext extends Context {
76
80
  strokeShape(shape: Shape): void;
77
81
  _stroke(shape: any): void;
78
82
  }
83
+ export {};
package/lib/Context.js CHANGED
@@ -366,6 +366,7 @@ export class Context {
366
366
  }
367
367
  }
368
368
  }
369
+ ;
369
370
  CONTEXT_PROPERTIES.forEach(function (prop) {
370
371
  Object.defineProperty(Context.prototype, prop, {
371
372
  get() {
package/lib/Global.d.ts CHANGED
@@ -27,6 +27,7 @@ export declare const Konva: {
27
27
  dragButtons: number[];
28
28
  isDragging(): any;
29
29
  isDragReady(): boolean;
30
+ releaseCanvasOnDestroy: boolean;
30
31
  document: any;
31
32
  _injectGlobal(Konva: any): void;
32
33
  };
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.13',
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.js CHANGED
@@ -82,7 +82,11 @@ export class Node {
82
82
  }
83
83
  }
84
84
  clearCache() {
85
- this._cache.delete(CANVAS);
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/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() {
package/lib/Util.d.ts CHANGED
@@ -83,4 +83,5 @@ export declare const Util: {
83
83
  _prepareToStringify(obj: any): any;
84
84
  _assign<T, U>(target: T, source: U): T & U;
85
85
  _getFirstPointerId(evt: any): any;
86
+ releaseCanvas(...canvases: HTMLCanvasElement[]): void;
86
87
  };
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
  };
@@ -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;
@@ -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,
@@ -40,6 +40,7 @@ export declare class TextPath extends Shape<TextPathConfig> {
40
40
  width: number;
41
41
  height: number;
42
42
  };
43
+ destroy(): this;
43
44
  fontFamily: GetSet<string, this>;
44
45
  fontSize: GetSet<number, this>;
45
46
  fontStyle: GetSet<string, this>;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "konva",
3
- "version": "8.3.13",
3
+ "version": "8.3.14",
4
4
  "author": "Anton Lavrenov",
5
5
  "files": [
6
6
  "README.md",