konva 8.4.2 → 9.0.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.
Files changed (242) hide show
  1. package/README.md +1 -9
  2. package/konva.js +17669 -16968
  3. package/konva.min.js +3 -3
  4. package/lib/Animation.d.ts +2 -2
  5. package/lib/Animation.js +11 -7
  6. package/lib/BezierFunctions.d.ts +6 -0
  7. package/lib/BezierFunctions.js +791 -0
  8. package/lib/Canvas.d.ts +2 -1
  9. package/lib/Canvas.js +26 -18
  10. package/lib/Container.d.ts +4 -4
  11. package/lib/Container.js +16 -12
  12. package/lib/Context.d.ts +16 -13
  13. package/lib/Context.js +27 -19
  14. package/lib/Core.d.ts +2 -2
  15. package/lib/Core.js +7 -3
  16. package/lib/DragAndDrop.d.ts +3 -3
  17. package/lib/DragAndDrop.js +25 -22
  18. package/lib/Factory.js +27 -24
  19. package/lib/FastLayer.d.ts +1 -1
  20. package/lib/FastLayer.js +10 -6
  21. package/lib/Global.js +16 -12
  22. package/lib/Group.d.ts +3 -3
  23. package/lib/Group.js +10 -6
  24. package/lib/Layer.d.ts +9 -9
  25. package/lib/Layer.js +37 -33
  26. package/lib/Node.d.ts +8 -8
  27. package/lib/Node.js +95 -90
  28. package/lib/PointerEvents.d.ts +4 -4
  29. package/lib/PointerEvents.js +15 -7
  30. package/lib/Shape.d.ts +6 -4
  31. package/lib/Shape.js +90 -86
  32. package/lib/Stage.d.ts +7 -7
  33. package/lib/Stage.js +51 -47
  34. package/lib/Tween.d.ts +2 -2
  35. package/lib/Tween.js +26 -22
  36. package/lib/Util.d.ts +2 -2
  37. package/lib/Util.js +29 -25
  38. package/lib/Validators.js +58 -44
  39. package/lib/_CoreInternals.d.ts +29 -29
  40. package/lib/_CoreInternals.js +36 -33
  41. package/lib/_FullInternals.d.ts +67 -67
  42. package/lib/_FullInternals.js +78 -75
  43. package/lib/filters/Blur.d.ts +1 -1
  44. package/lib/filters/Blur.js +9 -5
  45. package/lib/filters/Brighten.d.ts +1 -1
  46. package/lib/filters/Brighten.js +9 -5
  47. package/lib/filters/Contrast.d.ts +1 -1
  48. package/lib/filters/Contrast.js +9 -5
  49. package/lib/filters/Emboss.d.ts +1 -1
  50. package/lib/filters/Emboss.js +14 -10
  51. package/lib/filters/Enhance.d.ts +1 -1
  52. package/lib/filters/Enhance.js +9 -5
  53. package/lib/filters/Grayscale.d.ts +1 -1
  54. package/lib/filters/Grayscale.js +5 -1
  55. package/lib/filters/HSL.d.ts +1 -1
  56. package/lib/filters/HSL.js +11 -7
  57. package/lib/filters/HSV.d.ts +1 -1
  58. package/lib/filters/HSV.js +11 -7
  59. package/lib/filters/Invert.d.ts +1 -1
  60. package/lib/filters/Invert.js +5 -1
  61. package/lib/filters/Kaleidoscope.d.ts +1 -1
  62. package/lib/filters/Kaleidoscope.js +13 -9
  63. package/lib/filters/Mask.d.ts +1 -1
  64. package/lib/filters/Mask.js +9 -5
  65. package/lib/filters/Noise.d.ts +1 -1
  66. package/lib/filters/Noise.js +9 -5
  67. package/lib/filters/Pixelate.d.ts +1 -1
  68. package/lib/filters/Pixelate.js +11 -7
  69. package/lib/filters/Posterize.d.ts +1 -1
  70. package/lib/filters/Posterize.js +9 -5
  71. package/lib/filters/RGB.d.ts +1 -1
  72. package/lib/filters/RGB.js +11 -7
  73. package/lib/filters/RGBA.d.ts +1 -1
  74. package/lib/filters/RGBA.js +12 -8
  75. package/lib/filters/Sepia.d.ts +1 -1
  76. package/lib/filters/Sepia.js +5 -1
  77. package/lib/filters/Solarize.d.ts +1 -1
  78. package/lib/filters/Solarize.js +5 -1
  79. package/lib/filters/Threshold.d.ts +1 -1
  80. package/lib/filters/Threshold.js +9 -5
  81. package/lib/index-node.d.ts +1 -1
  82. package/lib/index-node.js +7 -5
  83. package/lib/index-types.d.ts +124 -124
  84. package/lib/index.d.ts +1 -1
  85. package/lib/index.js +4 -2
  86. package/lib/shapes/Arc.d.ts +6 -5
  87. package/lib/shapes/Arc.js +17 -13
  88. package/lib/shapes/Arrow.d.ts +5 -4
  89. package/lib/shapes/Arrow.js +17 -13
  90. package/lib/shapes/Circle.d.ts +6 -5
  91. package/lib/shapes/Circle.js +11 -7
  92. package/lib/shapes/Ellipse.d.ts +6 -5
  93. package/lib/shapes/Ellipse.js +13 -9
  94. package/lib/shapes/Image.d.ts +5 -5
  95. package/lib/shapes/Image.js +21 -17
  96. package/lib/shapes/Label.d.ts +8 -7
  97. package/lib/shapes/Label.js +18 -13
  98. package/lib/shapes/Line.d.ts +3 -3
  99. package/lib/shapes/Line.js +14 -10
  100. package/lib/shapes/Path.d.ts +6 -3
  101. package/lib/shapes/Path.js +44 -43
  102. package/lib/shapes/Rect.d.ts +3 -3
  103. package/lib/shapes/Rect.js +13 -9
  104. package/lib/shapes/RegularPolygon.d.ts +6 -5
  105. package/lib/shapes/RegularPolygon.js +12 -8
  106. package/lib/shapes/Ring.d.ts +6 -5
  107. package/lib/shapes/Ring.js +12 -8
  108. package/lib/shapes/Sprite.d.ts +7 -6
  109. package/lib/shapes/Sprite.js +19 -15
  110. package/lib/shapes/Star.d.ts +6 -5
  111. package/lib/shapes/Star.js +13 -9
  112. package/lib/shapes/Text.d.ts +8 -7
  113. package/lib/shapes/Text.js +31 -26
  114. package/lib/shapes/TextPath.d.ts +12 -7
  115. package/lib/shapes/TextPath.js +82 -188
  116. package/lib/shapes/Transformer.d.ts +10 -10
  117. package/lib/shapes/Transformer.js +92 -81
  118. package/lib/shapes/Wedge.d.ts +6 -5
  119. package/lib/shapes/Wedge.js +16 -12
  120. package/lib/types.d.ts +6 -0
  121. package/lib/types.js +5 -2
  122. package/package.json +13 -42
  123. package/cmj/Animation.d.ts +0 -24
  124. package/cmj/Animation.js +0 -145
  125. package/cmj/Canvas.d.ts +0 -32
  126. package/cmj/Canvas.js +0 -114
  127. package/cmj/Container.d.ts +0 -47
  128. package/cmj/Container.js +0 -325
  129. package/cmj/Context.d.ts +0 -84
  130. package/cmj/Context.js +0 -538
  131. package/cmj/Core.d.ts +0 -3
  132. package/cmj/Core.js +0 -7
  133. package/cmj/DragAndDrop.d.ts +0 -17
  134. package/cmj/DragAndDrop.js +0 -111
  135. package/cmj/Factory.d.ts +0 -11
  136. package/cmj/Factory.js +0 -125
  137. package/cmj/FastLayer.d.ts +0 -4
  138. package/cmj/FastLayer.js +0 -16
  139. package/cmj/Global.d.ts +0 -34
  140. package/cmj/Global.js +0 -61
  141. package/cmj/Group.d.ts +0 -8
  142. package/cmj/Group.js +0 -17
  143. package/cmj/Layer.d.ts +0 -61
  144. package/cmj/Layer.js +0 -309
  145. package/cmj/Node.d.ts +0 -328
  146. package/cmj/Node.js +0 -1420
  147. package/cmj/PointerEvents.d.ts +0 -11
  148. package/cmj/PointerEvents.js +0 -45
  149. package/cmj/Shape.d.ts +0 -184
  150. package/cmj/Shape.js +0 -521
  151. package/cmj/Stage.d.ts +0 -85
  152. package/cmj/Stage.js +0 -692
  153. package/cmj/Tween.d.ts +0 -86
  154. package/cmj/Tween.js +0 -520
  155. package/cmj/Util.d.ts +0 -91
  156. package/cmj/Util.js +0 -801
  157. package/cmj/Validators.d.ts +0 -11
  158. package/cmj/Validators.js +0 -192
  159. package/cmj/_CoreInternals.d.ts +0 -152
  160. package/cmj/_CoreInternals.js +0 -37
  161. package/cmj/_FullInternals.d.ts +0 -196
  162. package/cmj/_FullInternals.js +0 -81
  163. package/cmj/filters/Blur.d.ts +0 -2
  164. package/cmj/filters/Blur.js +0 -701
  165. package/cmj/filters/Brighten.d.ts +0 -2
  166. package/cmj/filters/Brighten.js +0 -16
  167. package/cmj/filters/Contrast.d.ts +0 -2
  168. package/cmj/filters/Contrast.js +0 -38
  169. package/cmj/filters/Emboss.d.ts +0 -2
  170. package/cmj/filters/Emboss.js +0 -106
  171. package/cmj/filters/Enhance.d.ts +0 -2
  172. package/cmj/filters/Enhance.js +0 -87
  173. package/cmj/filters/Grayscale.d.ts +0 -2
  174. package/cmj/filters/Grayscale.js +0 -13
  175. package/cmj/filters/HSL.d.ts +0 -2
  176. package/cmj/filters/HSL.js +0 -28
  177. package/cmj/filters/HSV.d.ts +0 -2
  178. package/cmj/filters/HSV.js +0 -28
  179. package/cmj/filters/Invert.d.ts +0 -2
  180. package/cmj/filters/Invert.js +0 -12
  181. package/cmj/filters/Kaleidoscope.d.ts +0 -2
  182. package/cmj/filters/Kaleidoscope.js +0 -137
  183. package/cmj/filters/Mask.d.ts +0 -2
  184. package/cmj/filters/Mask.js +0 -144
  185. package/cmj/filters/Noise.d.ts +0 -2
  186. package/cmj/filters/Noise.js +0 -16
  187. package/cmj/filters/Pixelate.d.ts +0 -2
  188. package/cmj/filters/Pixelate.js +0 -64
  189. package/cmj/filters/Posterize.d.ts +0 -2
  190. package/cmj/filters/Posterize.js +0 -14
  191. package/cmj/filters/RGB.d.ts +0 -2
  192. package/cmj/filters/RGB.js +0 -43
  193. package/cmj/filters/RGBA.d.ts +0 -2
  194. package/cmj/filters/RGBA.js +0 -53
  195. package/cmj/filters/Sepia.d.ts +0 -2
  196. package/cmj/filters/Sepia.js +0 -15
  197. package/cmj/filters/Solarize.d.ts +0 -2
  198. package/cmj/filters/Solarize.js +0 -29
  199. package/cmj/filters/Threshold.d.ts +0 -2
  200. package/cmj/filters/Threshold.js +0 -14
  201. package/cmj/index-node.d.ts +0 -2
  202. package/cmj/index-node.js +0 -21
  203. package/cmj/index-types.d.ts +0 -181
  204. package/cmj/index.d.ts +0 -2
  205. package/cmj/index.js +0 -4
  206. package/cmj/package.json +0 -6
  207. package/cmj/shapes/Arc.d.ts +0 -25
  208. package/cmj/shapes/Arc.js +0 -59
  209. package/cmj/shapes/Arrow.d.ts +0 -25
  210. package/cmj/shapes/Arrow.js +0 -103
  211. package/cmj/shapes/Circle.d.ts +0 -13
  212. package/cmj/shapes/Circle.js +0 -37
  213. package/cmj/shapes/Ellipse.d.ts +0 -16
  214. package/cmj/shapes/Ellipse.js +0 -41
  215. package/cmj/shapes/Image.d.ts +0 -25
  216. package/cmj/shapes/Image.js +0 -117
  217. package/cmj/shapes/Label.d.ts +0 -35
  218. package/cmj/shapes/Label.js +0 -178
  219. package/cmj/shapes/Line.d.ts +0 -28
  220. package/cmj/shapes/Line.js +0 -159
  221. package/cmj/shapes/Path.d.ts +0 -37
  222. package/cmj/shapes/Path.js +0 -631
  223. package/cmj/shapes/Rect.d.ts +0 -10
  224. package/cmj/shapes/Rect.js +0 -26
  225. package/cmj/shapes/RegularPolygon.d.ts +0 -22
  226. package/cmj/shapes/RegularPolygon.js +0 -69
  227. package/cmj/shapes/Ring.d.ts +0 -15
  228. package/cmj/shapes/Ring.js +0 -37
  229. package/cmj/shapes/Sprite.d.ts +0 -30
  230. package/cmj/shapes/Sprite.js +0 -112
  231. package/cmj/shapes/Star.d.ts +0 -17
  232. package/cmj/shapes/Star.js +0 -42
  233. package/cmj/shapes/Text.d.ts +0 -62
  234. package/cmj/shapes/Text.js +0 -373
  235. package/cmj/shapes/TextPath.d.ts +0 -55
  236. package/cmj/shapes/TextPath.js +0 -351
  237. package/cmj/shapes/Transformer.d.ts +0 -116
  238. package/cmj/shapes/Transformer.js +0 -964
  239. package/cmj/shapes/Wedge.d.ts +0 -17
  240. package/cmj/shapes/Wedge.js +0 -42
  241. package/cmj/types.d.ts +0 -50
  242. package/cmj/types.js +0 -25
package/lib/Global.js CHANGED
@@ -1,24 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._registerNode = exports.Konva = exports.glob = void 0;
1
4
  var PI_OVER_180 = Math.PI / 180;
2
5
  function detectBrowser() {
3
6
  return (typeof window !== 'undefined' &&
4
7
  ({}.toString.call(window) === '[object Window]' ||
5
8
  {}.toString.call(window) === '[object global]'));
6
9
  }
7
- export const glob = typeof global !== 'undefined'
10
+ exports.glob = typeof global !== 'undefined'
8
11
  ? global
9
12
  : typeof window !== 'undefined'
10
13
  ? window
11
14
  : typeof WorkerGlobalScope !== 'undefined'
12
15
  ? self
13
16
  : {};
14
- export const Konva = {
15
- _global: glob,
16
- version: '8.4.2',
17
+ exports.Konva = {
18
+ _global: exports.glob,
19
+ version: '9.0.0',
17
20
  isBrowser: detectBrowser(),
18
21
  isUnminified: /param/.test(function (param) { }.toString()),
19
22
  dblClickWindow: 400,
20
23
  getAngle(angle) {
21
- return Konva.angleDeg ? angle * PI_OVER_180 : angle;
24
+ return exports.Konva.angleDeg ? angle * PI_OVER_180 : angle;
22
25
  },
23
26
  enableTrace: false,
24
27
  pointerEventsEnabled: true,
@@ -40,18 +43,19 @@ export const Konva = {
40
43
  showWarnings: true,
41
44
  dragButtons: [0, 1],
42
45
  isDragging() {
43
- return Konva['DD'].isDragging;
46
+ return exports.Konva['DD'].isDragging;
44
47
  },
45
48
  isDragReady() {
46
- return !!Konva['DD'].node;
49
+ return !!exports.Konva['DD'].node;
47
50
  },
48
51
  releaseCanvasOnDestroy: true,
49
- document: glob.document,
52
+ document: exports.glob.document,
50
53
  _injectGlobal(Konva) {
51
- glob.Konva = Konva;
54
+ exports.glob.Konva = Konva;
52
55
  },
53
56
  };
54
- export const _registerNode = (NodeClass) => {
55
- Konva[NodeClass.prototype.getClassName()] = NodeClass;
57
+ const _registerNode = (NodeClass) => {
58
+ exports.Konva[NodeClass.prototype.getClassName()] = NodeClass;
56
59
  };
57
- Konva._injectGlobal(Konva);
60
+ exports._registerNode = _registerNode;
61
+ exports.Konva._injectGlobal(exports.Konva);
package/lib/Group.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Container, ContainerConfig } from './Container';
2
- import { Node } from './Node';
3
- import { Shape } from './Shape';
1
+ import { Container, ContainerConfig } from './Container.js';
2
+ import { Node } from './Node.js';
3
+ import { Shape } from './Shape.js';
4
4
  export interface GroupConfig extends ContainerConfig {
5
5
  }
6
6
  export declare class Group extends Container<Group | Shape> {
package/lib/Group.js CHANGED
@@ -1,13 +1,17 @@
1
- import { Util } from './Util.js';
2
- import { Container } from './Container.js';
3
- import { _registerNode } from './Global.js';
4
- export class Group extends Container {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Group = void 0;
4
+ const Util_1 = require("./Util");
5
+ const Container_1 = require("./Container");
6
+ const Global_1 = require("./Global");
7
+ class Group extends Container_1.Container {
5
8
  _validateAdd(child) {
6
9
  var type = child.getType();
7
10
  if (type !== 'Group' && type !== 'Shape') {
8
- Util.throw('You may only add groups and shapes to groups.');
11
+ Util_1.Util.throw('You may only add groups and shapes to groups.');
9
12
  }
10
13
  }
11
14
  }
15
+ exports.Group = Group;
12
16
  Group.prototype.nodeType = 'Group';
13
- _registerNode(Group);
17
+ (0, Global_1._registerNode)(Group);
package/lib/Layer.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { Container, ContainerConfig } from './Container';
2
- import { Node } from './Node';
3
- import { SceneCanvas, HitCanvas } from './Canvas';
4
- import { Stage } from './Stage';
5
- import { GetSet, Vector2d } from './types';
6
- import { Group } from './Group';
7
- import { Shape } from './Shape';
1
+ import { Container, ContainerConfig } from './Container.js';
2
+ import { Node } from './Node.js';
3
+ import { SceneCanvas, HitCanvas } from './Canvas.js';
4
+ import { Stage } from './Stage.js';
5
+ import { GetSet, Vector2d } from './types.js';
6
+ import { Group } from './Group.js';
7
+ import { Shape } from './Shape.js';
8
8
  export interface LayerConfig extends ContainerConfig {
9
9
  clearBeforeDraw?: boolean;
10
10
  hitGraphEnabled?: boolean;
@@ -19,7 +19,7 @@ export declare class Layer extends Container<Group | Shape> {
19
19
  getCanvas(): SceneCanvas;
20
20
  getNativeCanvasElement(): HTMLCanvasElement;
21
21
  getHitCanvas(): HitCanvas;
22
- getContext(): import("./Context").Context;
22
+ getContext(): import("./Context.js").Context;
23
23
  clear(bounds?: any): this;
24
24
  setZIndex(index: any): this;
25
25
  moveToTop(): boolean;
@@ -42,7 +42,7 @@ export declare class Layer extends Container<Group | Shape> {
42
42
  getHeight(): number;
43
43
  setHeight(): void;
44
44
  batchDraw(): this;
45
- getIntersection(pos: Vector2d): Shape<import("./Shape").ShapeConfig>;
45
+ getIntersection(pos: Vector2d): Shape<import("./Shape.js").ShapeConfig>;
46
46
  _getIntersection(pos: Vector2d): {
47
47
  shape?: Shape;
48
48
  antialiased?: boolean;
package/lib/Layer.js CHANGED
@@ -1,11 +1,14 @@
1
- import { Util } from './Util.js';
2
- import { Container } from './Container.js';
3
- import { Node } from './Node.js';
4
- import { Factory } from './Factory.js';
5
- import { SceneCanvas, HitCanvas } from './Canvas.js';
6
- import { getBooleanValidator } from './Validators.js';
7
- import { shapes } from './Shape.js';
8
- import { _registerNode } from './Global.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Layer = void 0;
4
+ const Util_1 = require("./Util");
5
+ const Container_1 = require("./Container");
6
+ const Node_1 = require("./Node");
7
+ const Factory_1 = require("./Factory");
8
+ const Canvas_1 = require("./Canvas");
9
+ const Validators_1 = require("./Validators");
10
+ const Shape_1 = require("./Shape");
11
+ const Global_1 = require("./Global");
9
12
  var HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [
10
13
  { x: 0, y: 0 },
11
14
  { x: -1, y: -1 },
@@ -13,11 +16,11 @@ var HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS
13
16
  { x: 1, y: 1 },
14
17
  { x: -1, y: 1 },
15
18
  ], INTERSECTION_OFFSETS_LEN = INTERSECTION_OFFSETS.length;
16
- export class Layer extends Container {
19
+ class Layer extends Container_1.Container {
17
20
  constructor(config) {
18
21
  super(config);
19
- this.canvas = new SceneCanvas();
20
- this.hitCanvas = new HitCanvas({
22
+ this.canvas = new Canvas_1.SceneCanvas();
23
+ this.hitCanvas = new Canvas_1.HitCanvas({
21
24
  pixelRatio: 1,
22
25
  });
23
26
  this._waitingForDraw = false;
@@ -62,7 +65,7 @@ export class Layer extends Container {
62
65
  return this;
63
66
  }
64
67
  moveToTop() {
65
- Node.prototype.moveToTop.call(this);
68
+ Node_1.Node.prototype.moveToTop.call(this);
66
69
  var stage = this.getStage();
67
70
  if (stage && stage.content) {
68
71
  stage.content.removeChild(this.getNativeCanvasElement());
@@ -71,7 +74,7 @@ export class Layer extends Container {
71
74
  return true;
72
75
  }
73
76
  moveUp() {
74
- var moved = Node.prototype.moveUp.call(this);
77
+ var moved = Node_1.Node.prototype.moveUp.call(this);
75
78
  if (!moved) {
76
79
  return false;
77
80
  }
@@ -89,7 +92,7 @@ export class Layer extends Container {
89
92
  return true;
90
93
  }
91
94
  moveDown() {
92
- if (Node.prototype.moveDown.call(this)) {
95
+ if (Node_1.Node.prototype.moveDown.call(this)) {
93
96
  var stage = this.getStage();
94
97
  if (stage) {
95
98
  var children = stage.children;
@@ -103,7 +106,7 @@ export class Layer extends Container {
103
106
  return false;
104
107
  }
105
108
  moveToBottom() {
106
- if (Node.prototype.moveToBottom.call(this)) {
109
+ if (Node_1.Node.prototype.moveToBottom.call(this)) {
107
110
  var stage = this.getStage();
108
111
  if (stage) {
109
112
  var children = stage.children;
@@ -121,8 +124,8 @@ export class Layer extends Container {
121
124
  }
122
125
  remove() {
123
126
  var _canvas = this.getNativeCanvasElement();
124
- Node.prototype.remove.call(this);
125
- if (_canvas && _canvas.parentNode && Util._isInDocument(_canvas)) {
127
+ Node_1.Node.prototype.remove.call(this);
128
+ if (_canvas && _canvas.parentNode && Util_1.Util._isInDocument(_canvas)) {
126
129
  _canvas.parentNode.removeChild(_canvas);
127
130
  }
128
131
  return this;
@@ -139,7 +142,7 @@ export class Layer extends Container {
139
142
  _validateAdd(child) {
140
143
  var type = child.getType();
141
144
  if (type !== 'Group' && type !== 'Shape') {
142
- Util.throw('You may only add groups and shapes to a layer.');
145
+ Util_1.Util.throw('You may only add groups and shapes to a layer.');
143
146
  }
144
147
  }
145
148
  _toKonvaCanvas(config) {
@@ -148,7 +151,7 @@ export class Layer extends Container {
148
151
  config.height = config.height || this.getHeight();
149
152
  config.x = config.x !== undefined ? config.x : this.x();
150
153
  config.y = config.y !== undefined ? config.y : this.y();
151
- return Node.prototype._toKonvaCanvas.call(this, config);
154
+ return Node_1.Node.prototype._toKonvaCanvas.call(this, config);
152
155
  }
153
156
  _checkVisibility() {
154
157
  const visible = this.visible();
@@ -169,7 +172,7 @@ export class Layer extends Container {
169
172
  }
170
173
  }
171
174
  setWidth() {
172
- Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.');
175
+ Util_1.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.');
173
176
  }
174
177
  getHeight() {
175
178
  if (this.parent) {
@@ -177,12 +180,12 @@ export class Layer extends Container {
177
180
  }
178
181
  }
179
182
  setHeight() {
180
- Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.');
183
+ Util_1.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.');
181
184
  }
182
185
  batchDraw() {
183
186
  if (!this._waitingForDraw) {
184
187
  this._waitingForDraw = true;
185
- Util.requestAnimFrame(() => {
188
+ Util_1.Util.requestAnimFrame(() => {
186
189
  this.draw();
187
190
  this._waitingForDraw = false;
188
191
  });
@@ -224,8 +227,8 @@ export class Layer extends Container {
224
227
  const p = this.hitCanvas.context.getImageData(Math.round(pos.x * ratio), Math.round(pos.y * ratio), 1, 1).data;
225
228
  const p3 = p[3];
226
229
  if (p3 === 255) {
227
- const colorKey = Util._rgbToHex(p[0], p[1], p[2]);
228
- const shape = shapes[HASH + colorKey];
230
+ const colorKey = Util_1.Util._rgbToHex(p[0], p[1], p[2]);
231
+ const shape = Shape_1.shapes[HASH + colorKey];
229
232
  if (shape) {
230
233
  return {
231
234
  shape: shape,
@@ -250,7 +253,7 @@ export class Layer extends Container {
250
253
  if (this.clearBeforeDraw()) {
251
254
  canvas.getContext().clear();
252
255
  }
253
- Container.prototype.drawScene.call(this, canvas, top);
256
+ Container_1.Container.prototype.drawScene.call(this, canvas, top);
254
257
  this._fire(DRAW, {
255
258
  node: this,
256
259
  });
@@ -261,7 +264,7 @@ export class Layer extends Container {
261
264
  if (layer && layer.clearBeforeDraw()) {
262
265
  layer.getHitCanvas().getContext().clear();
263
266
  }
264
- Container.prototype.drawHit.call(this, canvas, top);
267
+ Container_1.Container.prototype.drawHit.call(this, canvas, top);
265
268
  return this;
266
269
  }
267
270
  enableHitGraph() {
@@ -273,11 +276,11 @@ export class Layer extends Container {
273
276
  return this;
274
277
  }
275
278
  setHitGraphEnabled(val) {
276
- Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
279
+ Util_1.Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
277
280
  this.listening(val);
278
281
  }
279
282
  getHitGraphEnabled(val) {
280
- Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
283
+ Util_1.Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
281
284
  return this.listening();
282
285
  }
283
286
  toggleHitCanvas() {
@@ -294,12 +297,13 @@ export class Layer extends Container {
294
297
  }
295
298
  }
296
299
  destroy() {
297
- Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas);
300
+ Util_1.Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas);
298
301
  return super.destroy();
299
302
  }
300
303
  }
304
+ exports.Layer = Layer;
301
305
  Layer.prototype.nodeType = 'Layer';
302
- _registerNode(Layer);
303
- Factory.addGetterSetter(Layer, 'imageSmoothingEnabled', true);
304
- Factory.addGetterSetter(Layer, 'clearBeforeDraw', true);
305
- Factory.addGetterSetter(Layer, 'hitGraphEnabled', true, getBooleanValidator());
306
+ (0, Global_1._registerNode)(Layer);
307
+ Factory_1.Factory.addGetterSetter(Layer, 'imageSmoothingEnabled', true);
308
+ Factory_1.Factory.addGetterSetter(Layer, 'clearBeforeDraw', true);
309
+ Factory_1.Factory.addGetterSetter(Layer, 'hitGraphEnabled', true, (0, Validators_1.getBooleanValidator)());
package/lib/Node.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { Transform } from './Util';
2
- import { SceneCanvas, Canvas } from './Canvas';
3
- import { Container } from './Container';
4
- import { GetSet, Vector2d, IRect } from './types';
5
- import { Stage } from './Stage';
6
- import { Context } from './Context';
7
- import { Shape } from './Shape';
8
- import { Layer } from './Layer';
1
+ import { Transform } from './Util.js';
2
+ import { SceneCanvas, Canvas } from './Canvas.js';
3
+ import { Container } from './Container.js';
4
+ import { GetSet, Vector2d, IRect } from './types.js';
5
+ import { Stage } from './Stage.js';
6
+ import { Context } from './Context.js';
7
+ import { Shape } from './Shape.js';
8
+ import { Layer } from './Layer.js';
9
9
  export type Filter = (this: Node, imageData: ImageData) => void;
10
10
  type globalCompositeOperationType = '' | 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'lighter' | 'copy' | 'xor' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity';
11
11
  export interface NodeConfig {