konva 8.4.3 → 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 (190) hide show
  1. package/README.md +1 -9
  2. package/konva.js +17669 -16989
  3. package/konva.min.js +3 -3
  4. package/lib/Animation.js +11 -7
  5. package/lib/BezierFunctions.d.ts +6 -0
  6. package/lib/BezierFunctions.js +791 -0
  7. package/lib/Canvas.d.ts +1 -0
  8. package/lib/Canvas.js +26 -18
  9. package/lib/Container.js +16 -12
  10. package/lib/Context.d.ts +3 -1
  11. package/lib/Context.js +18 -10
  12. package/lib/Core.js +7 -3
  13. package/lib/DragAndDrop.js +25 -22
  14. package/lib/Factory.js +27 -24
  15. package/lib/FastLayer.js +10 -6
  16. package/lib/Global.js +16 -12
  17. package/lib/Group.js +10 -6
  18. package/lib/Layer.js +37 -33
  19. package/lib/Node.js +95 -90
  20. package/lib/PointerEvents.js +15 -7
  21. package/lib/Shape.js +90 -86
  22. package/lib/Stage.js +51 -47
  23. package/lib/Tween.js +26 -22
  24. package/lib/Util.js +29 -25
  25. package/lib/Validators.js +58 -44
  26. package/lib/_CoreInternals.js +36 -33
  27. package/lib/_FullInternals.js +78 -75
  28. package/lib/filters/Blur.js +9 -5
  29. package/lib/filters/Brighten.js +9 -5
  30. package/lib/filters/Contrast.js +9 -5
  31. package/lib/filters/Emboss.js +14 -10
  32. package/lib/filters/Enhance.js +9 -5
  33. package/lib/filters/Grayscale.js +5 -1
  34. package/lib/filters/HSL.js +11 -7
  35. package/lib/filters/HSV.js +11 -7
  36. package/lib/filters/Invert.js +5 -1
  37. package/lib/filters/Kaleidoscope.js +13 -9
  38. package/lib/filters/Mask.js +9 -5
  39. package/lib/filters/Noise.js +9 -5
  40. package/lib/filters/Pixelate.js +11 -7
  41. package/lib/filters/Posterize.js +9 -5
  42. package/lib/filters/RGB.js +11 -7
  43. package/lib/filters/RGBA.js +12 -8
  44. package/lib/filters/Sepia.js +5 -1
  45. package/lib/filters/Solarize.js +5 -1
  46. package/lib/filters/Threshold.js +9 -5
  47. package/lib/index-node.js +7 -5
  48. package/lib/index.js +4 -2
  49. package/lib/shapes/Arc.js +17 -13
  50. package/lib/shapes/Arrow.js +17 -13
  51. package/lib/shapes/Circle.js +11 -7
  52. package/lib/shapes/Ellipse.js +13 -9
  53. package/lib/shapes/Image.js +21 -17
  54. package/lib/shapes/Label.js +18 -13
  55. package/lib/shapes/Line.js +14 -10
  56. package/lib/shapes/Path.d.ts +5 -2
  57. package/lib/shapes/Path.js +44 -43
  58. package/lib/shapes/Rect.js +13 -9
  59. package/lib/shapes/RegularPolygon.js +12 -8
  60. package/lib/shapes/Ring.js +12 -8
  61. package/lib/shapes/Sprite.js +19 -15
  62. package/lib/shapes/Star.js +13 -9
  63. package/lib/shapes/Text.js +31 -26
  64. package/lib/shapes/TextPath.d.ts +5 -1
  65. package/lib/shapes/TextPath.js +82 -188
  66. package/lib/shapes/Transformer.js +85 -81
  67. package/lib/shapes/Wedge.js +16 -12
  68. package/lib/types.d.ts +6 -0
  69. package/lib/types.js +5 -2
  70. package/package.json +13 -42
  71. package/cmj/Animation.d.ts +0 -24
  72. package/cmj/Animation.js +0 -145
  73. package/cmj/Canvas.d.ts +0 -32
  74. package/cmj/Canvas.js +0 -114
  75. package/cmj/Container.d.ts +0 -47
  76. package/cmj/Container.js +0 -325
  77. package/cmj/Context.d.ts +0 -85
  78. package/cmj/Context.js +0 -538
  79. package/cmj/Core.d.ts +0 -3
  80. package/cmj/Core.js +0 -7
  81. package/cmj/DragAndDrop.d.ts +0 -17
  82. package/cmj/DragAndDrop.js +0 -111
  83. package/cmj/Factory.d.ts +0 -11
  84. package/cmj/Factory.js +0 -125
  85. package/cmj/FastLayer.d.ts +0 -4
  86. package/cmj/FastLayer.js +0 -16
  87. package/cmj/Global.d.ts +0 -34
  88. package/cmj/Global.js +0 -61
  89. package/cmj/Group.d.ts +0 -8
  90. package/cmj/Group.js +0 -17
  91. package/cmj/Layer.d.ts +0 -61
  92. package/cmj/Layer.js +0 -309
  93. package/cmj/Node.d.ts +0 -328
  94. package/cmj/Node.js +0 -1420
  95. package/cmj/PointerEvents.d.ts +0 -11
  96. package/cmj/PointerEvents.js +0 -45
  97. package/cmj/Shape.d.ts +0 -186
  98. package/cmj/Shape.js +0 -521
  99. package/cmj/Stage.d.ts +0 -85
  100. package/cmj/Stage.js +0 -692
  101. package/cmj/Tween.d.ts +0 -86
  102. package/cmj/Tween.js +0 -520
  103. package/cmj/Util.d.ts +0 -91
  104. package/cmj/Util.js +0 -801
  105. package/cmj/Validators.d.ts +0 -11
  106. package/cmj/Validators.js +0 -192
  107. package/cmj/_CoreInternals.d.ts +0 -152
  108. package/cmj/_CoreInternals.js +0 -37
  109. package/cmj/_FullInternals.d.ts +0 -196
  110. package/cmj/_FullInternals.js +0 -81
  111. package/cmj/filters/Blur.d.ts +0 -2
  112. package/cmj/filters/Blur.js +0 -701
  113. package/cmj/filters/Brighten.d.ts +0 -2
  114. package/cmj/filters/Brighten.js +0 -16
  115. package/cmj/filters/Contrast.d.ts +0 -2
  116. package/cmj/filters/Contrast.js +0 -38
  117. package/cmj/filters/Emboss.d.ts +0 -2
  118. package/cmj/filters/Emboss.js +0 -106
  119. package/cmj/filters/Enhance.d.ts +0 -2
  120. package/cmj/filters/Enhance.js +0 -87
  121. package/cmj/filters/Grayscale.d.ts +0 -2
  122. package/cmj/filters/Grayscale.js +0 -13
  123. package/cmj/filters/HSL.d.ts +0 -2
  124. package/cmj/filters/HSL.js +0 -28
  125. package/cmj/filters/HSV.d.ts +0 -2
  126. package/cmj/filters/HSV.js +0 -28
  127. package/cmj/filters/Invert.d.ts +0 -2
  128. package/cmj/filters/Invert.js +0 -12
  129. package/cmj/filters/Kaleidoscope.d.ts +0 -2
  130. package/cmj/filters/Kaleidoscope.js +0 -137
  131. package/cmj/filters/Mask.d.ts +0 -2
  132. package/cmj/filters/Mask.js +0 -144
  133. package/cmj/filters/Noise.d.ts +0 -2
  134. package/cmj/filters/Noise.js +0 -16
  135. package/cmj/filters/Pixelate.d.ts +0 -2
  136. package/cmj/filters/Pixelate.js +0 -64
  137. package/cmj/filters/Posterize.d.ts +0 -2
  138. package/cmj/filters/Posterize.js +0 -14
  139. package/cmj/filters/RGB.d.ts +0 -2
  140. package/cmj/filters/RGB.js +0 -43
  141. package/cmj/filters/RGBA.d.ts +0 -2
  142. package/cmj/filters/RGBA.js +0 -53
  143. package/cmj/filters/Sepia.d.ts +0 -2
  144. package/cmj/filters/Sepia.js +0 -15
  145. package/cmj/filters/Solarize.d.ts +0 -2
  146. package/cmj/filters/Solarize.js +0 -29
  147. package/cmj/filters/Threshold.d.ts +0 -2
  148. package/cmj/filters/Threshold.js +0 -14
  149. package/cmj/index-node.d.ts +0 -2
  150. package/cmj/index-node.js +0 -21
  151. package/cmj/index-types.d.ts +0 -181
  152. package/cmj/index.d.ts +0 -2
  153. package/cmj/index.js +0 -4
  154. package/cmj/package.json +0 -6
  155. package/cmj/shapes/Arc.d.ts +0 -26
  156. package/cmj/shapes/Arc.js +0 -59
  157. package/cmj/shapes/Arrow.d.ts +0 -26
  158. package/cmj/shapes/Arrow.js +0 -103
  159. package/cmj/shapes/Circle.d.ts +0 -14
  160. package/cmj/shapes/Circle.js +0 -37
  161. package/cmj/shapes/Ellipse.d.ts +0 -17
  162. package/cmj/shapes/Ellipse.js +0 -41
  163. package/cmj/shapes/Image.d.ts +0 -25
  164. package/cmj/shapes/Image.js +0 -117
  165. package/cmj/shapes/Label.d.ts +0 -36
  166. package/cmj/shapes/Label.js +0 -178
  167. package/cmj/shapes/Line.d.ts +0 -28
  168. package/cmj/shapes/Line.js +0 -159
  169. package/cmj/shapes/Path.d.ts +0 -37
  170. package/cmj/shapes/Path.js +0 -631
  171. package/cmj/shapes/Rect.d.ts +0 -10
  172. package/cmj/shapes/Rect.js +0 -26
  173. package/cmj/shapes/RegularPolygon.d.ts +0 -23
  174. package/cmj/shapes/RegularPolygon.js +0 -69
  175. package/cmj/shapes/Ring.d.ts +0 -16
  176. package/cmj/shapes/Ring.js +0 -37
  177. package/cmj/shapes/Sprite.d.ts +0 -31
  178. package/cmj/shapes/Sprite.js +0 -112
  179. package/cmj/shapes/Star.d.ts +0 -18
  180. package/cmj/shapes/Star.js +0 -42
  181. package/cmj/shapes/Text.d.ts +0 -63
  182. package/cmj/shapes/Text.js +0 -373
  183. package/cmj/shapes/TextPath.d.ts +0 -56
  184. package/cmj/shapes/TextPath.js +0 -351
  185. package/cmj/shapes/Transformer.d.ts +0 -116
  186. package/cmj/shapes/Transformer.js +0 -971
  187. package/cmj/shapes/Wedge.d.ts +0 -18
  188. package/cmj/shapes/Wedge.js +0 -42
  189. package/cmj/types.d.ts +0 -50
  190. package/cmj/types.js +0 -25
package/lib/Canvas.d.ts CHANGED
@@ -3,6 +3,7 @@ interface ICanvasConfig {
3
3
  width?: number;
4
4
  height?: number;
5
5
  pixelRatio?: number;
6
+ willReadFrequently?: boolean;
6
7
  }
7
8
  export declare class Canvas {
8
9
  pixelRatio: number;
package/lib/Canvas.js CHANGED
@@ -1,17 +1,20 @@
1
- import { Util } from './Util.js';
2
- import { SceneContext, HitContext } from './Context.js';
3
- import { Konva } from './Global.js';
4
- import { Factory } from './Factory.js';
5
- import { getNumberValidator } from './Validators.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HitCanvas = exports.SceneCanvas = exports.Canvas = void 0;
4
+ const Util_1 = require("./Util");
5
+ const Context_1 = require("./Context");
6
+ const Global_1 = require("./Global");
7
+ const Factory_1 = require("./Factory");
8
+ const Validators_1 = require("./Validators");
6
9
  var _pixelRatio;
7
10
  function getDevicePixelRatio() {
8
11
  if (_pixelRatio) {
9
12
  return _pixelRatio;
10
13
  }
11
- var canvas = Util.createCanvasElement();
14
+ var canvas = Util_1.Util.createCanvasElement();
12
15
  var context = canvas.getContext('2d');
13
16
  _pixelRatio = (function () {
14
- var devicePixelRatio = Konva._global.devicePixelRatio || 1, backingStoreRatio = context.webkitBackingStorePixelRatio ||
17
+ var devicePixelRatio = Global_1.Konva._global.devicePixelRatio || 1, backingStoreRatio = context.webkitBackingStorePixelRatio ||
15
18
  context.mozBackingStorePixelRatio ||
16
19
  context.msBackingStorePixelRatio ||
17
20
  context.oBackingStorePixelRatio ||
@@ -19,19 +22,19 @@ function getDevicePixelRatio() {
19
22
  1;
20
23
  return devicePixelRatio / backingStoreRatio;
21
24
  })();
22
- Util.releaseCanvas(canvas);
25
+ Util_1.Util.releaseCanvas(canvas);
23
26
  return _pixelRatio;
24
27
  }
25
- export class Canvas {
28
+ class Canvas {
26
29
  constructor(config) {
27
30
  this.pixelRatio = 1;
28
31
  this.width = 0;
29
32
  this.height = 0;
30
33
  this.isCache = false;
31
34
  var conf = config || {};
32
- var pixelRatio = conf.pixelRatio || Konva.pixelRatio || getDevicePixelRatio();
35
+ var pixelRatio = conf.pixelRatio || Global_1.Konva.pixelRatio || getDevicePixelRatio();
33
36
  this.pixelRatio = pixelRatio;
34
- this._canvas = Util.createCanvasElement();
37
+ this._canvas = Util_1.Util.createCanvasElement();
35
38
  this._canvas.style.padding = '0';
36
39
  this._canvas.style.margin = '0';
37
40
  this._canvas.style.border = '0';
@@ -82,7 +85,7 @@ export class Canvas {
82
85
  return this._canvas.toDataURL();
83
86
  }
84
87
  catch (err) {
85
- Util.error('Unable to get data URL. ' +
88
+ Util_1.Util.error('Unable to get data URL. ' +
86
89
  err.message +
87
90
  ' For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.');
88
91
  return '';
@@ -90,19 +93,24 @@ export class Canvas {
90
93
  }
91
94
  }
92
95
  }
93
- Factory.addGetterSetter(Canvas, 'pixelRatio', undefined, getNumberValidator());
94
- export class SceneCanvas extends Canvas {
95
- constructor(config = { width: 0, height: 0 }) {
96
+ exports.Canvas = Canvas;
97
+ Factory_1.Factory.addGetterSetter(Canvas, 'pixelRatio', undefined, (0, Validators_1.getNumberValidator)());
98
+ class SceneCanvas extends Canvas {
99
+ constructor(config = { width: 0, height: 0, willReadFrequently: false }) {
96
100
  super(config);
97
- this.context = new SceneContext(this);
101
+ this.context = new Context_1.SceneContext(this, {
102
+ willReadFrequently: config.willReadFrequently,
103
+ });
98
104
  this.setSize(config.width, config.height);
99
105
  }
100
106
  }
101
- export class HitCanvas extends Canvas {
107
+ exports.SceneCanvas = SceneCanvas;
108
+ class HitCanvas extends Canvas {
102
109
  constructor(config = { width: 0, height: 0 }) {
103
110
  super(config);
104
111
  this.hitCanvas = true;
105
- this.context = new HitContext(this);
112
+ this.context = new Context_1.HitContext(this);
106
113
  this.setSize(config.width, config.height);
107
114
  }
108
115
  }
116
+ exports.HitCanvas = HitCanvas;
package/lib/Container.js CHANGED
@@ -1,7 +1,10 @@
1
- import { Factory } from './Factory.js';
2
- import { Node } from './Node.js';
3
- import { getNumberValidator } from './Validators.js';
4
- export class Container extends Node {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Container = void 0;
4
+ const Factory_1 = require("./Factory");
5
+ const Node_1 = require("./Node");
6
+ const Validators_1 = require("./Validators");
7
+ class Container extends Node_1.Node {
5
8
  constructor() {
6
9
  super(...arguments);
7
10
  this.children = [];
@@ -115,7 +118,7 @@ export class Container extends Node {
115
118
  return false;
116
119
  }
117
120
  toObject() {
118
- var obj = Node.prototype.toObject.call(this);
121
+ var obj = Node_1.Node.prototype.toObject.call(this);
119
122
  obj.children = [];
120
123
  this.getChildren().forEach((child) => {
121
124
  obj.children.push(child.toObject());
@@ -133,7 +136,7 @@ export class Container extends Node {
133
136
  return false;
134
137
  }
135
138
  clone(obj) {
136
- var node = Node.prototype.clone.call(this, obj);
139
+ var node = Node_1.Node.prototype.clone.call(this, obj);
137
140
  this.getChildren().forEach(function (no) {
138
141
  node.add(no.clone());
139
142
  });
@@ -308,14 +311,15 @@ export class Container extends Node {
308
311
  return selfRect;
309
312
  }
310
313
  }
311
- Factory.addComponentsGetterSetter(Container, 'clip', [
314
+ exports.Container = Container;
315
+ Factory_1.Factory.addComponentsGetterSetter(Container, 'clip', [
312
316
  'x',
313
317
  'y',
314
318
  'width',
315
319
  'height',
316
320
  ]);
317
- Factory.addGetterSetter(Container, 'clipX', undefined, getNumberValidator());
318
- Factory.addGetterSetter(Container, 'clipY', undefined, getNumberValidator());
319
- Factory.addGetterSetter(Container, 'clipWidth', undefined, getNumberValidator());
320
- Factory.addGetterSetter(Container, 'clipHeight', undefined, getNumberValidator());
321
- Factory.addGetterSetter(Container, 'clipFunc');
321
+ Factory_1.Factory.addGetterSetter(Container, 'clipX', undefined, (0, Validators_1.getNumberValidator)());
322
+ Factory_1.Factory.addGetterSetter(Container, 'clipY', undefined, (0, Validators_1.getNumberValidator)());
323
+ Factory_1.Factory.addGetterSetter(Container, 'clipWidth', undefined, (0, Validators_1.getNumberValidator)());
324
+ Factory_1.Factory.addGetterSetter(Container, 'clipHeight', undefined, (0, Validators_1.getNumberValidator)());
325
+ Factory_1.Factory.addGetterSetter(Container, 'clipFunc');
package/lib/Context.d.ts CHANGED
@@ -66,7 +66,9 @@ type CanvasContextProps = Pick<CanvasRenderingContext2D, typeof CONTEXT_PROPERTI
66
66
  export interface Context extends CanvasContextProps {
67
67
  }
68
68
  export declare class SceneContext extends Context {
69
- constructor(canvas: Canvas);
69
+ constructor(canvas: Canvas, { willReadFrequently }?: {
70
+ willReadFrequently?: boolean;
71
+ });
70
72
  _fillColor(shape: Shape): void;
71
73
  _fillPattern(shape: Shape): void;
72
74
  _fillLinearGradient(shape: Shape): void;
package/lib/Context.js CHANGED
@@ -1,7 +1,10 @@
1
- import { Util } from './Util.js';
2
- import { Konva } from './Global.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HitContext = exports.SceneContext = exports.Context = void 0;
4
+ const Util_1 = require("./Util");
5
+ const Global_1 = require("./Global");
3
6
  function simplifyArray(arr) {
4
- var retArr = [], len = arr.length, util = Util, n, val;
7
+ var retArr = [], len = arr.length, util = Util_1.Util, n, val;
5
8
  for (n = 0; n < len; n++) {
6
9
  val = arr[n];
7
10
  if (util._isNumber(val)) {
@@ -67,10 +70,10 @@ var CONTEXT_PROPERTIES = [
67
70
  'imageSmoothingEnabled',
68
71
  ];
69
72
  const traceArrMax = 100;
70
- export class Context {
73
+ class Context {
71
74
  constructor(canvas) {
72
75
  this.canvas = canvas;
73
- if (Konva.enableTrace) {
76
+ if (Global_1.Konva.enableTrace) {
74
77
  this.traceArr = [];
75
78
  this._enableTrace();
76
79
  }
@@ -111,7 +114,7 @@ export class Context {
111
114
  str += DOUBLE_PAREN;
112
115
  }
113
116
  else {
114
- if (Util._isArray(args[0])) {
117
+ if (Util_1.Util._isArray(args[0])) {
115
118
  str += OPEN_PAREN_BRACKET + args.join(COMMA) + CLOSE_BRACKET_PAREN;
116
119
  }
117
120
  else {
@@ -369,6 +372,7 @@ export class Context {
369
372
  }
370
373
  }
371
374
  }
375
+ exports.Context = Context;
372
376
  CONTEXT_PROPERTIES.forEach(function (prop) {
373
377
  Object.defineProperty(Context.prototype, prop, {
374
378
  get() {
@@ -379,10 +383,12 @@ CONTEXT_PROPERTIES.forEach(function (prop) {
379
383
  },
380
384
  });
381
385
  });
382
- export class SceneContext extends Context {
383
- constructor(canvas) {
386
+ class SceneContext extends Context {
387
+ constructor(canvas, { willReadFrequently = false } = {}) {
384
388
  super(canvas);
385
- this._context = canvas._canvas.getContext('2d');
389
+ this._context = canvas._canvas.getContext('2d', {
390
+ willReadFrequently,
391
+ });
386
392
  }
387
393
  _fillColor(shape) {
388
394
  var fill = shape.fill();
@@ -492,7 +498,8 @@ export class SceneContext extends Context {
492
498
  this.setAttr('shadowOffsetY', offset.y * scaleY);
493
499
  }
494
500
  }
495
- export class HitContext extends Context {
501
+ exports.SceneContext = SceneContext;
502
+ class HitContext extends Context {
496
503
  constructor(canvas) {
497
504
  super(canvas);
498
505
  this._context = canvas._canvas.getContext('2d', {
@@ -530,3 +537,4 @@ export class HitContext extends Context {
530
537
  }
531
538
  }
532
539
  }
540
+ exports.HitContext = HitContext;
package/lib/Core.js CHANGED
@@ -1,3 +1,7 @@
1
- export { Konva } from './_CoreInternals.js';
2
- import { Konva } from './_CoreInternals.js';
3
- export default Konva;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Konva = void 0;
4
+ var _CoreInternals_1 = require("./_CoreInternals");
5
+ Object.defineProperty(exports, "Konva", { enumerable: true, get: function () { return _CoreInternals_1.Konva; } });
6
+ const _CoreInternals_2 = require("./_CoreInternals");
7
+ module.exports = _CoreInternals_2.Konva;
@@ -1,9 +1,12 @@
1
- import { Konva } from './Global.js';
2
- import { Util } from './Util.js';
3
- export const DD = {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DD = void 0;
4
+ const Global_1 = require("./Global");
5
+ const Util_1 = require("./Util");
6
+ exports.DD = {
4
7
  get isDragging() {
5
8
  var flag = false;
6
- DD._dragElements.forEach((elem) => {
9
+ exports.DD._dragElements.forEach((elem) => {
7
10
  if (elem.dragStatus === 'dragging') {
8
11
  flag = true;
9
12
  }
@@ -13,7 +16,7 @@ export const DD = {
13
16
  justDragged: false,
14
17
  get node() {
15
18
  var node;
16
- DD._dragElements.forEach((elem) => {
19
+ exports.DD._dragElements.forEach((elem) => {
17
20
  node = elem.node;
18
21
  });
19
22
  return node;
@@ -21,12 +24,12 @@ export const DD = {
21
24
  _dragElements: new Map(),
22
25
  _drag(evt) {
23
26
  const nodesToFireEvents = [];
24
- DD._dragElements.forEach((elem, key) => {
27
+ exports.DD._dragElements.forEach((elem, key) => {
25
28
  const { node } = elem;
26
29
  const stage = node.getStage();
27
30
  stage.setPointersPositions(evt);
28
31
  if (elem.pointerId === undefined) {
29
- elem.pointerId = Util._getFirstPointerId(evt);
32
+ elem.pointerId = Util_1.Util._getFirstPointerId(evt);
30
33
  }
31
34
  const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
32
35
  if (!pos) {
@@ -56,7 +59,7 @@ export const DD = {
56
59
  },
57
60
  _endDragBefore(evt) {
58
61
  const drawNodes = [];
59
- DD._dragElements.forEach((elem) => {
62
+ exports.DD._dragElements.forEach((elem) => {
60
63
  const { node } = elem;
61
64
  const stage = node.getStage();
62
65
  if (evt) {
@@ -67,14 +70,14 @@ export const DD = {
67
70
  return;
68
71
  }
69
72
  if (elem.dragStatus === 'dragging' || elem.dragStatus === 'stopped') {
70
- DD.justDragged = true;
71
- Konva._mouseListenClick = false;
72
- Konva._touchListenClick = false;
73
- Konva._pointerListenClick = false;
73
+ exports.DD.justDragged = true;
74
+ Global_1.Konva._mouseListenClick = false;
75
+ Global_1.Konva._touchListenClick = false;
76
+ Global_1.Konva._pointerListenClick = false;
74
77
  elem.dragStatus = 'stopped';
75
78
  }
76
79
  const drawNode = elem.node.getLayer() ||
77
- (elem.node instanceof Konva['Stage'] && elem.node);
80
+ (elem.node instanceof Global_1.Konva['Stage'] && elem.node);
78
81
  if (drawNode && drawNodes.indexOf(drawNode) === -1) {
79
82
  drawNodes.push(drawNode);
80
83
  }
@@ -84,7 +87,7 @@ export const DD = {
84
87
  });
85
88
  },
86
89
  _endDragAfter(evt) {
87
- DD._dragElements.forEach((elem, key) => {
90
+ exports.DD._dragElements.forEach((elem, key) => {
88
91
  if (elem.dragStatus === 'stopped') {
89
92
  elem.node.fire('dragend', {
90
93
  type: 'dragend',
@@ -93,16 +96,16 @@ export const DD = {
93
96
  }, true);
94
97
  }
95
98
  if (elem.dragStatus !== 'dragging') {
96
- DD._dragElements.delete(key);
99
+ exports.DD._dragElements.delete(key);
97
100
  }
98
101
  });
99
102
  },
100
103
  };
101
- if (Konva.isBrowser) {
102
- window.addEventListener('mouseup', DD._endDragBefore, true);
103
- window.addEventListener('touchend', DD._endDragBefore, true);
104
- window.addEventListener('mousemove', DD._drag);
105
- window.addEventListener('touchmove', DD._drag);
106
- window.addEventListener('mouseup', DD._endDragAfter, false);
107
- window.addEventListener('touchend', DD._endDragAfter, false);
104
+ if (Global_1.Konva.isBrowser) {
105
+ window.addEventListener('mouseup', exports.DD._endDragBefore, true);
106
+ window.addEventListener('touchend', exports.DD._endDragBefore, true);
107
+ window.addEventListener('mousemove', exports.DD._drag);
108
+ window.addEventListener('touchmove', exports.DD._drag);
109
+ window.addEventListener('mouseup', exports.DD._endDragAfter, false);
110
+ window.addEventListener('touchend', exports.DD._endDragAfter, false);
108
111
  }
package/lib/Factory.js CHANGED
@@ -1,14 +1,17 @@
1
- import { Util } from './Util.js';
2
- import { getComponentValidator } from './Validators.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Factory = void 0;
4
+ const Util_1 = require("./Util");
5
+ const Validators_1 = require("./Validators");
3
6
  var GET = 'get', SET = 'set';
4
- export const Factory = {
7
+ exports.Factory = {
5
8
  addGetterSetter(constructor, attr, def, validator, after) {
6
- Factory.addGetter(constructor, attr, def);
7
- Factory.addSetter(constructor, attr, validator, after);
8
- Factory.addOverloadedGetterSetter(constructor, attr);
9
+ exports.Factory.addGetter(constructor, attr, def);
10
+ exports.Factory.addSetter(constructor, attr, validator, after);
11
+ exports.Factory.addOverloadedGetterSetter(constructor, attr);
9
12
  },
10
13
  addGetter(constructor, attr, def) {
11
- var method = GET + Util._capitalize(attr);
14
+ var method = GET + Util_1.Util._capitalize(attr);
12
15
  constructor.prototype[method] =
13
16
  constructor.prototype[method] ||
14
17
  function () {
@@ -17,13 +20,13 @@ export const Factory = {
17
20
  };
18
21
  },
19
22
  addSetter(constructor, attr, validator, after) {
20
- var method = SET + Util._capitalize(attr);
23
+ var method = SET + Util_1.Util._capitalize(attr);
21
24
  if (!constructor.prototype[method]) {
22
- Factory.overWriteSetter(constructor, attr, validator, after);
25
+ exports.Factory.overWriteSetter(constructor, attr, validator, after);
23
26
  }
24
27
  },
25
28
  overWriteSetter(constructor, attr, validator, after) {
26
- var method = SET + Util._capitalize(attr);
29
+ var method = SET + Util_1.Util._capitalize(attr);
27
30
  constructor.prototype[method] = function (val) {
28
31
  if (validator && val !== undefined && val !== null) {
29
32
  val = validator.call(this, val, attr);
@@ -36,7 +39,7 @@ export const Factory = {
36
39
  };
37
40
  },
38
41
  addComponentsGetterSetter(constructor, attr, components, validator, after) {
39
- var len = components.length, capitalize = Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr), n, component;
42
+ var len = components.length, capitalize = Util_1.Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr), n, component;
40
43
  constructor.prototype[getter] = function () {
41
44
  var ret = {};
42
45
  for (n = 0; n < len; n++) {
@@ -45,7 +48,7 @@ export const Factory = {
45
48
  }
46
49
  return ret;
47
50
  };
48
- var basicValidator = getComponentValidator(components);
51
+ var basicValidator = (0, Validators_1.getComponentValidator)(components);
49
52
  constructor.prototype[setter] = function (val) {
50
53
  var oldVal = this.attrs[attr], key;
51
54
  if (validator) {
@@ -71,10 +74,10 @@ export const Factory = {
71
74
  }
72
75
  return this;
73
76
  };
74
- Factory.addOverloadedGetterSetter(constructor, attr);
77
+ exports.Factory.addOverloadedGetterSetter(constructor, attr);
75
78
  },
76
79
  addOverloadedGetterSetter(constructor, attr) {
77
- var capitalizedAttr = Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr;
80
+ var capitalizedAttr = Util_1.Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr;
78
81
  constructor.prototype[attr] = function () {
79
82
  if (arguments.length) {
80
83
  this[setter](arguments[0]);
@@ -84,28 +87,28 @@ export const Factory = {
84
87
  };
85
88
  },
86
89
  addDeprecatedGetterSetter(constructor, attr, def, validator) {
87
- Util.error('Adding deprecated ' + attr);
88
- var method = GET + Util._capitalize(attr);
90
+ Util_1.Util.error('Adding deprecated ' + attr);
91
+ var method = GET + Util_1.Util._capitalize(attr);
89
92
  var message = attr +
90
93
  ' property is deprecated and will be removed soon. Look at Konva change log for more information.';
91
94
  constructor.prototype[method] = function () {
92
- Util.error(message);
95
+ Util_1.Util.error(message);
93
96
  var val = this.attrs[attr];
94
97
  return val === undefined ? def : val;
95
98
  };
96
- Factory.addSetter(constructor, attr, validator, function () {
97
- Util.error(message);
99
+ exports.Factory.addSetter(constructor, attr, validator, function () {
100
+ Util_1.Util.error(message);
98
101
  });
99
- Factory.addOverloadedGetterSetter(constructor, attr);
102
+ exports.Factory.addOverloadedGetterSetter(constructor, attr);
100
103
  },
101
104
  backCompat(constructor, methods) {
102
- Util.each(methods, function (oldMethodName, newMethodName) {
105
+ Util_1.Util.each(methods, function (oldMethodName, newMethodName) {
103
106
  var method = constructor.prototype[newMethodName];
104
- var oldGetter = GET + Util._capitalize(oldMethodName);
105
- var oldSetter = SET + Util._capitalize(oldMethodName);
107
+ var oldGetter = GET + Util_1.Util._capitalize(oldMethodName);
108
+ var oldSetter = SET + Util_1.Util._capitalize(oldMethodName);
106
109
  function deprecated() {
107
110
  method.apply(this, arguments);
108
- Util.error('"' +
111
+ Util_1.Util.error('"' +
109
112
  oldMethodName +
110
113
  '" method is deprecated and will be removed soon. Use ""' +
111
114
  newMethodName +
package/lib/FastLayer.js CHANGED
@@ -1,12 +1,16 @@
1
- import { Util } from './Util.js';
2
- import { Layer } from './Layer.js';
3
- import { _registerNode } from './Global.js';
4
- export class FastLayer extends Layer {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FastLayer = void 0;
4
+ const Util_1 = require("./Util");
5
+ const Layer_1 = require("./Layer");
6
+ const Global_1 = require("./Global");
7
+ class FastLayer extends Layer_1.Layer {
5
8
  constructor(attrs) {
6
9
  super(attrs);
7
10
  this.listening(false);
8
- Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.');
11
+ Util_1.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.');
9
12
  }
10
13
  }
14
+ exports.FastLayer = FastLayer;
11
15
  FastLayer.prototype.nodeType = 'FastLayer';
12
- _registerNode(FastLayer);
16
+ (0, Global_1._registerNode)(FastLayer);
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.3',
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.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);