konva 8.4.3 → 9.0.1

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 (192) hide show
  1. package/README.md +1 -9
  2. package/konva.js +17691 -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.d.ts +1 -0
  20. package/lib/Node.js +105 -104
  21. package/lib/PointerEvents.js +15 -7
  22. package/lib/Shape.js +90 -86
  23. package/lib/Stage.js +51 -47
  24. package/lib/Tween.js +26 -22
  25. package/lib/Util.js +29 -25
  26. package/lib/Validators.js +58 -44
  27. package/lib/_CoreInternals.js +36 -33
  28. package/lib/_FullInternals.js +78 -75
  29. package/lib/filters/Blur.js +9 -5
  30. package/lib/filters/Brighten.js +9 -5
  31. package/lib/filters/Contrast.js +9 -5
  32. package/lib/filters/Emboss.js +14 -10
  33. package/lib/filters/Enhance.js +9 -5
  34. package/lib/filters/Grayscale.js +5 -1
  35. package/lib/filters/HSL.js +11 -7
  36. package/lib/filters/HSV.js +11 -7
  37. package/lib/filters/Invert.js +5 -1
  38. package/lib/filters/Kaleidoscope.js +13 -9
  39. package/lib/filters/Mask.js +9 -5
  40. package/lib/filters/Noise.js +9 -5
  41. package/lib/filters/Pixelate.js +11 -7
  42. package/lib/filters/Posterize.js +9 -5
  43. package/lib/filters/RGB.js +11 -7
  44. package/lib/filters/RGBA.js +12 -8
  45. package/lib/filters/Sepia.js +5 -1
  46. package/lib/filters/Solarize.js +5 -1
  47. package/lib/filters/Threshold.js +9 -5
  48. package/lib/index-node.js +7 -5
  49. package/lib/index.js +4 -2
  50. package/lib/shapes/Arc.js +17 -13
  51. package/lib/shapes/Arrow.js +17 -13
  52. package/lib/shapes/Circle.js +11 -7
  53. package/lib/shapes/Ellipse.js +13 -9
  54. package/lib/shapes/Image.js +21 -17
  55. package/lib/shapes/Label.js +18 -13
  56. package/lib/shapes/Line.js +14 -10
  57. package/lib/shapes/Path.d.ts +5 -2
  58. package/lib/shapes/Path.js +44 -43
  59. package/lib/shapes/Rect.js +13 -9
  60. package/lib/shapes/RegularPolygon.js +12 -8
  61. package/lib/shapes/Ring.js +12 -8
  62. package/lib/shapes/Sprite.js +19 -15
  63. package/lib/shapes/Star.js +13 -9
  64. package/lib/shapes/Text.js +31 -26
  65. package/lib/shapes/TextPath.d.ts +5 -1
  66. package/lib/shapes/TextPath.js +82 -188
  67. package/lib/shapes/Transformer.d.ts +2 -0
  68. package/lib/shapes/Transformer.js +97 -82
  69. package/lib/shapes/Wedge.js +16 -12
  70. package/lib/types.d.ts +6 -0
  71. package/lib/types.js +5 -2
  72. package/package.json +13 -42
  73. package/cmj/Animation.d.ts +0 -24
  74. package/cmj/Animation.js +0 -145
  75. package/cmj/Canvas.d.ts +0 -32
  76. package/cmj/Canvas.js +0 -114
  77. package/cmj/Container.d.ts +0 -47
  78. package/cmj/Container.js +0 -325
  79. package/cmj/Context.d.ts +0 -85
  80. package/cmj/Context.js +0 -538
  81. package/cmj/Core.d.ts +0 -3
  82. package/cmj/Core.js +0 -7
  83. package/cmj/DragAndDrop.d.ts +0 -17
  84. package/cmj/DragAndDrop.js +0 -111
  85. package/cmj/Factory.d.ts +0 -11
  86. package/cmj/Factory.js +0 -125
  87. package/cmj/FastLayer.d.ts +0 -4
  88. package/cmj/FastLayer.js +0 -16
  89. package/cmj/Global.d.ts +0 -34
  90. package/cmj/Global.js +0 -61
  91. package/cmj/Group.d.ts +0 -8
  92. package/cmj/Group.js +0 -17
  93. package/cmj/Layer.d.ts +0 -61
  94. package/cmj/Layer.js +0 -309
  95. package/cmj/Node.d.ts +0 -328
  96. package/cmj/Node.js +0 -1420
  97. package/cmj/PointerEvents.d.ts +0 -11
  98. package/cmj/PointerEvents.js +0 -45
  99. package/cmj/Shape.d.ts +0 -186
  100. package/cmj/Shape.js +0 -521
  101. package/cmj/Stage.d.ts +0 -85
  102. package/cmj/Stage.js +0 -692
  103. package/cmj/Tween.d.ts +0 -86
  104. package/cmj/Tween.js +0 -520
  105. package/cmj/Util.d.ts +0 -91
  106. package/cmj/Util.js +0 -801
  107. package/cmj/Validators.d.ts +0 -11
  108. package/cmj/Validators.js +0 -192
  109. package/cmj/_CoreInternals.d.ts +0 -152
  110. package/cmj/_CoreInternals.js +0 -37
  111. package/cmj/_FullInternals.d.ts +0 -196
  112. package/cmj/_FullInternals.js +0 -81
  113. package/cmj/filters/Blur.d.ts +0 -2
  114. package/cmj/filters/Blur.js +0 -701
  115. package/cmj/filters/Brighten.d.ts +0 -2
  116. package/cmj/filters/Brighten.js +0 -16
  117. package/cmj/filters/Contrast.d.ts +0 -2
  118. package/cmj/filters/Contrast.js +0 -38
  119. package/cmj/filters/Emboss.d.ts +0 -2
  120. package/cmj/filters/Emboss.js +0 -106
  121. package/cmj/filters/Enhance.d.ts +0 -2
  122. package/cmj/filters/Enhance.js +0 -87
  123. package/cmj/filters/Grayscale.d.ts +0 -2
  124. package/cmj/filters/Grayscale.js +0 -13
  125. package/cmj/filters/HSL.d.ts +0 -2
  126. package/cmj/filters/HSL.js +0 -28
  127. package/cmj/filters/HSV.d.ts +0 -2
  128. package/cmj/filters/HSV.js +0 -28
  129. package/cmj/filters/Invert.d.ts +0 -2
  130. package/cmj/filters/Invert.js +0 -12
  131. package/cmj/filters/Kaleidoscope.d.ts +0 -2
  132. package/cmj/filters/Kaleidoscope.js +0 -137
  133. package/cmj/filters/Mask.d.ts +0 -2
  134. package/cmj/filters/Mask.js +0 -144
  135. package/cmj/filters/Noise.d.ts +0 -2
  136. package/cmj/filters/Noise.js +0 -16
  137. package/cmj/filters/Pixelate.d.ts +0 -2
  138. package/cmj/filters/Pixelate.js +0 -64
  139. package/cmj/filters/Posterize.d.ts +0 -2
  140. package/cmj/filters/Posterize.js +0 -14
  141. package/cmj/filters/RGB.d.ts +0 -2
  142. package/cmj/filters/RGB.js +0 -43
  143. package/cmj/filters/RGBA.d.ts +0 -2
  144. package/cmj/filters/RGBA.js +0 -53
  145. package/cmj/filters/Sepia.d.ts +0 -2
  146. package/cmj/filters/Sepia.js +0 -15
  147. package/cmj/filters/Solarize.d.ts +0 -2
  148. package/cmj/filters/Solarize.js +0 -29
  149. package/cmj/filters/Threshold.d.ts +0 -2
  150. package/cmj/filters/Threshold.js +0 -14
  151. package/cmj/index-node.d.ts +0 -2
  152. package/cmj/index-node.js +0 -21
  153. package/cmj/index-types.d.ts +0 -181
  154. package/cmj/index.d.ts +0 -2
  155. package/cmj/index.js +0 -4
  156. package/cmj/package.json +0 -6
  157. package/cmj/shapes/Arc.d.ts +0 -26
  158. package/cmj/shapes/Arc.js +0 -59
  159. package/cmj/shapes/Arrow.d.ts +0 -26
  160. package/cmj/shapes/Arrow.js +0 -103
  161. package/cmj/shapes/Circle.d.ts +0 -14
  162. package/cmj/shapes/Circle.js +0 -37
  163. package/cmj/shapes/Ellipse.d.ts +0 -17
  164. package/cmj/shapes/Ellipse.js +0 -41
  165. package/cmj/shapes/Image.d.ts +0 -25
  166. package/cmj/shapes/Image.js +0 -117
  167. package/cmj/shapes/Label.d.ts +0 -36
  168. package/cmj/shapes/Label.js +0 -178
  169. package/cmj/shapes/Line.d.ts +0 -28
  170. package/cmj/shapes/Line.js +0 -159
  171. package/cmj/shapes/Path.d.ts +0 -37
  172. package/cmj/shapes/Path.js +0 -631
  173. package/cmj/shapes/Rect.d.ts +0 -10
  174. package/cmj/shapes/Rect.js +0 -26
  175. package/cmj/shapes/RegularPolygon.d.ts +0 -23
  176. package/cmj/shapes/RegularPolygon.js +0 -69
  177. package/cmj/shapes/Ring.d.ts +0 -16
  178. package/cmj/shapes/Ring.js +0 -37
  179. package/cmj/shapes/Sprite.d.ts +0 -31
  180. package/cmj/shapes/Sprite.js +0 -112
  181. package/cmj/shapes/Star.d.ts +0 -18
  182. package/cmj/shapes/Star.js +0 -42
  183. package/cmj/shapes/Text.d.ts +0 -63
  184. package/cmj/shapes/Text.js +0 -373
  185. package/cmj/shapes/TextPath.d.ts +0 -56
  186. package/cmj/shapes/TextPath.js +0 -351
  187. package/cmj/shapes/Transformer.d.ts +0 -116
  188. package/cmj/shapes/Transformer.js +0 -971
  189. package/cmj/shapes/Wedge.d.ts +0 -18
  190. package/cmj/shapes/Wedge.js +0 -42
  191. package/cmj/types.d.ts +0 -50
  192. package/cmj/types.js +0 -25
package/lib/Tween.js CHANGED
@@ -1,7 +1,10 @@
1
- import { Util } from './Util.js';
2
- import { Animation } from './Animation.js';
3
- import { Node } from './Node.js';
4
- import { Konva } from './Global.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Easings = exports.Tween = void 0;
4
+ const Util_1 = require("./Util");
5
+ const Animation_1 = require("./Animation");
6
+ const Node_1 = require("./Node");
7
+ const Global_1 = require("./Global");
5
8
  var blacklist = {
6
9
  node: 1,
7
10
  duration: 1,
@@ -123,9 +126,9 @@ class TweenEngine {
123
126
  return new Date().getTime();
124
127
  }
125
128
  }
126
- export class Tween {
129
+ class Tween {
127
130
  constructor(config) {
128
- var that = this, node = config.node, nodeId = node._id, duration, easing = config.easing || Easings.Linear, yoyo = !!config.yoyo, key;
131
+ var that = this, node = config.node, nodeId = node._id, duration, easing = config.easing || exports.Easings.Linear, yoyo = !!config.yoyo, key;
129
132
  if (typeof config.duration === 'undefined') {
130
133
  duration = 0.3;
131
134
  }
@@ -138,11 +141,11 @@ export class Tween {
138
141
  this.node = node;
139
142
  this._id = idCounter++;
140
143
  var layers = node.getLayer() ||
141
- (node instanceof Konva['Stage'] ? node.getLayers() : null);
144
+ (node instanceof Global_1.Konva['Stage'] ? node.getLayers() : null);
142
145
  if (!layers) {
143
- Util.error('Tween constructor have `node` that is not in a layer. Please add node into layer first.');
146
+ Util_1.Util.error('Tween constructor have `node` that is not in a layer. Please add node into layer first.');
144
147
  }
145
- this.anim = new Animation(function () {
148
+ this.anim = new Animation_1.Animation(function () {
146
149
  that.tween.onEnterFrame();
147
150
  }, layers);
148
151
  this.tween = new TweenEngine(key, function (i) {
@@ -175,17 +178,17 @@ export class Tween {
175
178
  delete Tween.attrs[nodeId][tweenId][key];
176
179
  }
177
180
  start = node.getAttr(key);
178
- if (Util._isArray(end)) {
181
+ if (Util_1.Util._isArray(end)) {
179
182
  diff = [];
180
183
  len = Math.max(end.length, start.length);
181
184
  if (key === 'points' && end.length !== start.length) {
182
185
  if (end.length > start.length) {
183
186
  trueStart = start;
184
- start = Util._prepareArrayForTween(start, end, node.closed());
187
+ start = Util_1.Util._prepareArrayForTween(start, end, node.closed());
185
188
  }
186
189
  else {
187
190
  trueEnd = end;
188
- end = Util._prepareArrayForTween(end, start, node.closed());
191
+ end = Util_1.Util._prepareArrayForTween(end, start, node.closed());
189
192
  }
190
193
  }
191
194
  if (key.indexOf('fill') === 0) {
@@ -194,8 +197,8 @@ export class Tween {
194
197
  diff.push(end[n] - start[n]);
195
198
  }
196
199
  else {
197
- var startRGBA = Util.colorToRGBA(start[n]);
198
- endRGBA = Util.colorToRGBA(end[n]);
200
+ var startRGBA = Util_1.Util.colorToRGBA(start[n]);
201
+ endRGBA = Util_1.Util.colorToRGBA(end[n]);
199
202
  start[n] = startRGBA;
200
203
  diff.push({
201
204
  r: endRGBA.r - startRGBA.r,
@@ -213,8 +216,8 @@ export class Tween {
213
216
  }
214
217
  }
215
218
  else if (colorAttrs.indexOf(key) !== -1) {
216
- start = Util.colorToRGBA(start);
217
- endRGBA = Util.colorToRGBA(end);
219
+ start = Util_1.Util.colorToRGBA(start);
220
+ endRGBA = Util_1.Util.colorToRGBA(end);
218
221
  diff = {
219
222
  r: endRGBA.r - start.r,
220
223
  g: endRGBA.g - start.g,
@@ -241,7 +244,7 @@ export class Tween {
241
244
  start = attr.start;
242
245
  diff = attr.diff;
243
246
  end = attr.end;
244
- if (Util._isArray(start)) {
247
+ if (Util_1.Util._isArray(start)) {
245
248
  newVal = [];
246
249
  len = Math.max(start.length, end.length);
247
250
  if (key.indexOf('fill') === 0) {
@@ -357,7 +360,8 @@ export class Tween {
357
360
  }
358
361
  Tween.attrs = {};
359
362
  Tween.tweens = {};
360
- Node.prototype.to = function (params) {
363
+ exports.Tween = Tween;
364
+ Node_1.Node.prototype.to = function (params) {
361
365
  var onFinish = params.onFinish;
362
366
  params.node = this;
363
367
  params.onFinish = function () {
@@ -369,7 +373,7 @@ Node.prototype.to = function (params) {
369
373
  var tween = new Tween(params);
370
374
  tween.play();
371
375
  };
372
- export const Easings = {
376
+ exports.Easings = {
373
377
  BackEaseIn(t, b, c, d) {
374
378
  var s = 1.70158;
375
379
  return c * (t /= d) * t * ((s + 1) * t - s) + b;
@@ -476,14 +480,14 @@ export const Easings = {
476
480
  }
477
481
  },
478
482
  BounceEaseIn(t, b, c, d) {
479
- return c - Easings.BounceEaseOut(d - t, 0, c, d) + b;
483
+ return c - exports.Easings.BounceEaseOut(d - t, 0, c, d) + b;
480
484
  },
481
485
  BounceEaseInOut(t, b, c, d) {
482
486
  if (t < d / 2) {
483
- return Easings.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b;
487
+ return exports.Easings.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b;
484
488
  }
485
489
  else {
486
- return Easings.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
490
+ return exports.Easings.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
487
491
  }
488
492
  },
489
493
  EaseIn(t, b, c, d) {
package/lib/Util.js CHANGED
@@ -1,5 +1,8 @@
1
- import { Konva } from './Global.js';
2
- export class Transform {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Util = exports.Transform = void 0;
4
+ const Global_1 = require("./Global");
5
+ class Transform {
3
6
  constructor(m = [1, 0, 0, 1, 0, 0]) {
4
7
  this.dirty = false;
5
8
  this.m = (m && m.slice()) || [1, 0, 0, 1, 0, 0];
@@ -142,10 +145,11 @@ export class Transform {
142
145
  }
143
146
  else {
144
147
  }
145
- result.rotation = Util._getRotation(result.rotation);
148
+ result.rotation = exports.Util._getRotation(result.rotation);
146
149
  return result;
147
150
  }
148
151
  }
152
+ exports.Transform = Transform;
149
153
  var OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
150
154
  aliceblue: [240, 248, 255],
151
155
  antiquewhite: [250, 235, 215],
@@ -301,7 +305,7 @@ const req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFra
301
305
  function (f) {
302
306
  setTimeout(f, 60);
303
307
  };
304
- export const Util = {
308
+ exports.Util = {
305
309
  _isElement(obj) {
306
310
  return !!(obj && obj.nodeType == 1);
307
311
  },
@@ -380,7 +384,7 @@ export const Util = {
380
384
  return false;
381
385
  },
382
386
  _urlToImage(url, callback) {
383
- var imageObj = Util.createImageElement();
387
+ var imageObj = exports.Util.createImageElement();
384
388
  imageObj.onload = function () {
385
389
  callback(imageObj);
386
390
  };
@@ -436,14 +440,14 @@ export const Util = {
436
440
  },
437
441
  colorToRGBA(str) {
438
442
  str = str || 'black';
439
- return (Util._namedColorToRBA(str) ||
440
- Util._hex3ColorToRGBA(str) ||
441
- Util._hex4ColorToRGBA(str) ||
442
- Util._hex6ColorToRGBA(str) ||
443
- Util._hex8ColorToRGBA(str) ||
444
- Util._rgbColorToRGBA(str) ||
445
- Util._rgbaColorToRGBA(str) ||
446
- Util._hslColorToRGBA(str));
443
+ return (exports.Util._namedColorToRBA(str) ||
444
+ exports.Util._hex3ColorToRGBA(str) ||
445
+ exports.Util._hex4ColorToRGBA(str) ||
446
+ exports.Util._hex6ColorToRGBA(str) ||
447
+ exports.Util._hex8ColorToRGBA(str) ||
448
+ exports.Util._rgbColorToRGBA(str) ||
449
+ exports.Util._rgbaColorToRGBA(str) ||
450
+ exports.Util._hslColorToRGBA(str));
447
451
  },
448
452
  _namedColorToRBA(str) {
449
453
  var c = COLORS[str.toLowerCase()];
@@ -613,15 +617,15 @@ export const Util = {
613
617
  return rad * DEG180_OVER_PI;
614
618
  },
615
619
  _degToRad(deg) {
616
- Util.warn('Util._degToRad is removed. Please use public Util.degToRad instead.');
617
- return Util.degToRad(deg);
620
+ exports.Util.warn('Util._degToRad is removed. Please use public Util.degToRad instead.');
621
+ return exports.Util.degToRad(deg);
618
622
  },
619
623
  _radToDeg(rad) {
620
- Util.warn('Util._radToDeg is removed. Please use public Util.radToDeg instead.');
621
- return Util.radToDeg(rad);
624
+ exports.Util.warn('Util._radToDeg is removed. Please use public Util.radToDeg instead.');
625
+ return exports.Util.radToDeg(rad);
622
626
  },
623
627
  _getRotation(radians) {
624
- return Konva.angleDeg ? Util.radToDeg(radians) : radians;
628
+ return Global_1.Konva.angleDeg ? exports.Util.radToDeg(radians) : radians;
625
629
  },
626
630
  _capitalize(str) {
627
631
  return str.charAt(0).toUpperCase() + str.slice(1);
@@ -633,7 +637,7 @@ export const Util = {
633
637
  console.error(KONVA_ERROR + str);
634
638
  },
635
639
  warn(str) {
636
- if (!Konva.showWarnings) {
640
+ if (!Global_1.Konva.showWarnings) {
637
641
  return;
638
642
  }
639
643
  console.warn(KONVA_WARNING + str);
@@ -675,14 +679,14 @@ export const Util = {
675
679
  return [x, y, dist];
676
680
  },
677
681
  _getProjectionToLine(pt, line, isClosed) {
678
- var pc = Util.cloneObject(pt);
682
+ var pc = exports.Util.cloneObject(pt);
679
683
  var dist = Number.MAX_VALUE;
680
684
  line.forEach(function (p1, i) {
681
685
  if (!isClosed && i === line.length - 1) {
682
686
  return;
683
687
  }
684
688
  var p2 = line[(i + 1) % line.length];
685
- var proj = Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);
689
+ var proj = exports.Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);
686
690
  var px = proj[0], py = proj[1], pdist = proj[2];
687
691
  if (pdist < dist) {
688
692
  pc.x = px;
@@ -713,7 +717,7 @@ export const Util = {
713
717
  }
714
718
  var newStart = [];
715
719
  end.forEach(function (point) {
716
- var pr = Util._getProjectionToLine(point, start, isClosed);
720
+ var pr = exports.Util._getProjectionToLine(point, start, isClosed);
717
721
  newStart.push(pr.x);
718
722
  newStart.push(pr.y);
719
723
  });
@@ -728,7 +732,7 @@ export const Util = {
728
732
  }
729
733
  desc = Object.getOwnPropertyDescriptor(obj, key);
730
734
  if (obj[key].visitedByCircularReferenceRemoval ||
731
- Util._isElement(obj[key])) {
735
+ exports.Util._isElement(obj[key])) {
732
736
  if (desc.configurable) {
733
737
  delete obj[key];
734
738
  }
@@ -736,7 +740,7 @@ export const Util = {
736
740
  return null;
737
741
  }
738
742
  }
739
- else if (Util._prepareToStringify(obj[key]) === null) {
743
+ else if (exports.Util._prepareToStringify(obj[key]) === null) {
740
744
  if (desc.configurable) {
741
745
  delete obj[key];
742
746
  }
@@ -763,7 +767,7 @@ export const Util = {
763
767
  }
764
768
  },
765
769
  releaseCanvas(...canvases) {
766
- if (!Konva.releaseCanvasOnDestroy)
770
+ if (!Global_1.Konva.releaseCanvasOnDestroy)
767
771
  return;
768
772
  canvases.forEach(c => {
769
773
  c.width = 0;
package/lib/Validators.js CHANGED
@@ -1,18 +1,21 @@
1
- import { Konva } from './Global.js';
2
- import { Util } from './Util.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getComponentValidator = exports.getBooleanValidator = exports.getNumberArrayValidator = exports.getFunctionValidator = exports.getStringOrGradientValidator = exports.getStringValidator = exports.getNumberOrAutoValidator = exports.getNumberOrArrayOfNumbersValidator = exports.getNumberValidator = exports.alphaComponent = exports.RGBComponent = void 0;
4
+ const Global_1 = require("./Global");
5
+ const Util_1 = require("./Util");
3
6
  function _formatValue(val) {
4
- if (Util._isString(val)) {
7
+ if (Util_1.Util._isString(val)) {
5
8
  return '"' + val + '"';
6
9
  }
7
10
  if (Object.prototype.toString.call(val) === '[object Number]') {
8
11
  return val;
9
12
  }
10
- if (Util._isBoolean(val)) {
13
+ if (Util_1.Util._isBoolean(val)) {
11
14
  return val;
12
15
  }
13
16
  return Object.prototype.toString.call(val);
14
17
  }
15
- export function RGBComponent(val) {
18
+ function RGBComponent(val) {
16
19
  if (val > 255) {
17
20
  return 255;
18
21
  }
@@ -21,7 +24,8 @@ export function RGBComponent(val) {
21
24
  }
22
25
  return Math.round(val);
23
26
  }
24
- export function alphaComponent(val) {
27
+ exports.RGBComponent = RGBComponent;
28
+ function alphaComponent(val) {
25
29
  if (val > 1) {
26
30
  return 1;
27
31
  }
@@ -30,11 +34,12 @@ export function alphaComponent(val) {
30
34
  }
31
35
  return val;
32
36
  }
33
- export function getNumberValidator() {
34
- if (Konva.isUnminified) {
37
+ exports.alphaComponent = alphaComponent;
38
+ function getNumberValidator() {
39
+ if (Global_1.Konva.isUnminified) {
35
40
  return function (val, attr) {
36
- if (!Util._isNumber(val)) {
37
- Util.warn(_formatValue(val) +
41
+ if (!Util_1.Util._isNumber(val)) {
42
+ Util_1.Util.warn(_formatValue(val) +
38
43
  ' is a not valid value for "' +
39
44
  attr +
40
45
  '" attribute. The value should be a number.');
@@ -43,13 +48,14 @@ export function getNumberValidator() {
43
48
  };
44
49
  }
45
50
  }
46
- export function getNumberOrArrayOfNumbersValidator(noOfElements) {
47
- if (Konva.isUnminified) {
51
+ exports.getNumberValidator = getNumberValidator;
52
+ function getNumberOrArrayOfNumbersValidator(noOfElements) {
53
+ if (Global_1.Konva.isUnminified) {
48
54
  return function (val, attr) {
49
- let isNumber = Util._isNumber(val);
50
- let isValidArray = Util._isArray(val) && val.length == noOfElements;
55
+ let isNumber = Util_1.Util._isNumber(val);
56
+ let isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements;
51
57
  if (!isNumber && !isValidArray) {
52
- Util.warn(_formatValue(val) +
58
+ Util_1.Util.warn(_formatValue(val) +
53
59
  ' is a not valid value for "' +
54
60
  attr +
55
61
  '" attribute. The value should be a number or Array<number>(' +
@@ -60,13 +66,14 @@ export function getNumberOrArrayOfNumbersValidator(noOfElements) {
60
66
  };
61
67
  }
62
68
  }
63
- export function getNumberOrAutoValidator() {
64
- if (Konva.isUnminified) {
69
+ exports.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;
70
+ function getNumberOrAutoValidator() {
71
+ if (Global_1.Konva.isUnminified) {
65
72
  return function (val, attr) {
66
- var isNumber = Util._isNumber(val);
73
+ var isNumber = Util_1.Util._isNumber(val);
67
74
  var isAuto = val === 'auto';
68
75
  if (!(isNumber || isAuto)) {
69
- Util.warn(_formatValue(val) +
76
+ Util_1.Util.warn(_formatValue(val) +
70
77
  ' is a not valid value for "' +
71
78
  attr +
72
79
  '" attribute. The value should be a number or "auto".');
@@ -75,11 +82,12 @@ export function getNumberOrAutoValidator() {
75
82
  };
76
83
  }
77
84
  }
78
- export function getStringValidator() {
79
- if (Konva.isUnminified) {
85
+ exports.getNumberOrAutoValidator = getNumberOrAutoValidator;
86
+ function getStringValidator() {
87
+ if (Global_1.Konva.isUnminified) {
80
88
  return function (val, attr) {
81
- if (!Util._isString(val)) {
82
- Util.warn(_formatValue(val) +
89
+ if (!Util_1.Util._isString(val)) {
90
+ Util_1.Util.warn(_formatValue(val) +
83
91
  ' is a not valid value for "' +
84
92
  attr +
85
93
  '" attribute. The value should be a string.');
@@ -88,14 +96,15 @@ export function getStringValidator() {
88
96
  };
89
97
  }
90
98
  }
91
- export function getStringOrGradientValidator() {
92
- if (Konva.isUnminified) {
99
+ exports.getStringValidator = getStringValidator;
100
+ function getStringOrGradientValidator() {
101
+ if (Global_1.Konva.isUnminified) {
93
102
  return function (val, attr) {
94
- const isString = Util._isString(val);
103
+ const isString = Util_1.Util._isString(val);
95
104
  const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
96
105
  (val && val.addColorStop);
97
106
  if (!(isString || isGradient)) {
98
- Util.warn(_formatValue(val) +
107
+ Util_1.Util.warn(_formatValue(val) +
99
108
  ' is a not valid value for "' +
100
109
  attr +
101
110
  '" attribute. The value should be a string or a native gradient.');
@@ -104,11 +113,12 @@ export function getStringOrGradientValidator() {
104
113
  };
105
114
  }
106
115
  }
107
- export function getFunctionValidator() {
108
- if (Konva.isUnminified) {
116
+ exports.getStringOrGradientValidator = getStringOrGradientValidator;
117
+ function getFunctionValidator() {
118
+ if (Global_1.Konva.isUnminified) {
109
119
  return function (val, attr) {
110
- if (!Util._isFunction(val)) {
111
- Util.warn(_formatValue(val) +
120
+ if (!Util_1.Util._isFunction(val)) {
121
+ Util_1.Util.warn(_formatValue(val) +
112
122
  ' is a not valid value for "' +
113
123
  attr +
114
124
  '" attribute. The value should be a function.');
@@ -117,23 +127,24 @@ export function getFunctionValidator() {
117
127
  };
118
128
  }
119
129
  }
120
- export function getNumberArrayValidator() {
121
- if (Konva.isUnminified) {
130
+ exports.getFunctionValidator = getFunctionValidator;
131
+ function getNumberArrayValidator() {
132
+ if (Global_1.Konva.isUnminified) {
122
133
  return function (val, attr) {
123
134
  const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
124
135
  if (TypedArray && val instanceof TypedArray) {
125
136
  return val;
126
137
  }
127
- if (!Util._isArray(val)) {
128
- Util.warn(_formatValue(val) +
138
+ if (!Util_1.Util._isArray(val)) {
139
+ Util_1.Util.warn(_formatValue(val) +
129
140
  ' is a not valid value for "' +
130
141
  attr +
131
142
  '" attribute. The value should be a array of numbers.');
132
143
  }
133
144
  else {
134
145
  val.forEach(function (item) {
135
- if (!Util._isNumber(item)) {
136
- Util.warn('"' +
146
+ if (!Util_1.Util._isNumber(item)) {
147
+ Util_1.Util.warn('"' +
137
148
  attr +
138
149
  '" attribute has non numeric element ' +
139
150
  item +
@@ -145,12 +156,13 @@ export function getNumberArrayValidator() {
145
156
  };
146
157
  }
147
158
  }
148
- export function getBooleanValidator() {
149
- if (Konva.isUnminified) {
159
+ exports.getNumberArrayValidator = getNumberArrayValidator;
160
+ function getBooleanValidator() {
161
+ if (Global_1.Konva.isUnminified) {
150
162
  return function (val, attr) {
151
163
  var isBool = val === true || val === false;
152
164
  if (!isBool) {
153
- Util.warn(_formatValue(val) +
165
+ Util_1.Util.warn(_formatValue(val) +
154
166
  ' is a not valid value for "' +
155
167
  attr +
156
168
  '" attribute. The value should be a boolean.');
@@ -159,14 +171,15 @@ export function getBooleanValidator() {
159
171
  };
160
172
  }
161
173
  }
162
- export function getComponentValidator(components) {
163
- if (Konva.isUnminified) {
174
+ exports.getBooleanValidator = getBooleanValidator;
175
+ function getComponentValidator(components) {
176
+ if (Global_1.Konva.isUnminified) {
164
177
  return function (val, attr) {
165
178
  if (val === undefined || val === null) {
166
179
  return val;
167
180
  }
168
- if (!Util.isObject(val)) {
169
- Util.warn(_formatValue(val) +
181
+ if (!Util_1.Util.isObject(val)) {
182
+ Util_1.Util.warn(_formatValue(val) +
170
183
  ' is a not valid value for "' +
171
184
  attr +
172
185
  '" attribute. The value should be an object with properties ' +
@@ -176,3 +189,4 @@ export function getComponentValidator(components) {
176
189
  };
177
190
  }
178
191
  }
192
+ exports.getComponentValidator = getComponentValidator;
@@ -1,34 +1,37 @@
1
- import { Konva as Global } from './Global.js';
2
- import { Util, Transform } from './Util.js';
3
- import { Node } from './Node.js';
4
- import { Container } from './Container.js';
5
- import { Stage, stages } from './Stage.js';
6
- import { Layer } from './Layer.js';
7
- import { FastLayer } from './FastLayer.js';
8
- import { Group } from './Group.js';
9
- import { DD } from './DragAndDrop.js';
10
- import { Shape, shapes } from './Shape.js';
11
- import { Animation } from './Animation.js';
12
- import { Tween, Easings } from './Tween.js';
13
- import { Context } from './Context.js';
14
- import { Canvas } from './Canvas.js';
15
- export const Konva = Util._assign(Global, {
16
- Util,
17
- Transform,
18
- Node,
19
- Container,
20
- Stage,
21
- stages,
22
- Layer,
23
- FastLayer,
24
- Group,
25
- DD,
26
- Shape,
27
- shapes,
28
- Animation,
29
- Tween,
30
- Easings,
31
- Context,
32
- Canvas,
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Konva = void 0;
4
+ const Global_1 = require("./Global");
5
+ const Util_1 = require("./Util");
6
+ const Node_1 = require("./Node");
7
+ const Container_1 = require("./Container");
8
+ const Stage_1 = require("./Stage");
9
+ const Layer_1 = require("./Layer");
10
+ const FastLayer_1 = require("./FastLayer");
11
+ const Group_1 = require("./Group");
12
+ const DragAndDrop_1 = require("./DragAndDrop");
13
+ const Shape_1 = require("./Shape");
14
+ const Animation_1 = require("./Animation");
15
+ const Tween_1 = require("./Tween");
16
+ const Context_1 = require("./Context");
17
+ const Canvas_1 = require("./Canvas");
18
+ exports.Konva = Util_1.Util._assign(Global_1.Konva, {
19
+ Util: Util_1.Util,
20
+ Transform: Util_1.Transform,
21
+ Node: Node_1.Node,
22
+ Container: Container_1.Container,
23
+ Stage: Stage_1.Stage,
24
+ stages: Stage_1.stages,
25
+ Layer: Layer_1.Layer,
26
+ FastLayer: FastLayer_1.FastLayer,
27
+ Group: Group_1.Group,
28
+ DD: DragAndDrop_1.DD,
29
+ Shape: Shape_1.Shape,
30
+ shapes: Shape_1.shapes,
31
+ Animation: Animation_1.Animation,
32
+ Tween: Tween_1.Tween,
33
+ Easings: Tween_1.Easings,
34
+ Context: Context_1.Context,
35
+ Canvas: Canvas_1.Canvas,
33
36
  });
34
- export default Konva;
37
+ exports.default = exports.Konva;