konva 9.3.21 → 10.0.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 (129) hide show
  1. package/README.md +1 -1
  2. package/konva.js +664 -226
  3. package/konva.min.js +46 -4
  4. package/lib/Animation.d.ts +2 -2
  5. package/lib/Animation.js +7 -11
  6. package/lib/BezierFunctions.js +9 -15
  7. package/lib/Canvas.d.ts +1 -1
  8. package/lib/Canvas.js +14 -20
  9. package/lib/Container.d.ts +7 -6
  10. package/lib/Container.js +12 -16
  11. package/lib/Context.d.ts +7 -5
  12. package/lib/Context.js +34 -14
  13. package/lib/Core.d.ts +2 -2
  14. package/lib/Core.js +3 -7
  15. package/lib/DragAndDrop.d.ts +3 -3
  16. package/lib/DragAndDrop.js +24 -27
  17. package/lib/Factory.d.ts +2 -2
  18. package/lib/Factory.js +24 -27
  19. package/lib/FastLayer.d.ts +1 -1
  20. package/lib/FastLayer.js +6 -10
  21. package/lib/Global.d.ts +4 -3
  22. package/lib/Global.js +19 -19
  23. package/lib/Group.d.ts +4 -3
  24. package/lib/Group.js +6 -10
  25. package/lib/Layer.d.ts +10 -9
  26. package/lib/Layer.js +33 -37
  27. package/lib/Node.d.ts +16 -13
  28. package/lib/Node.js +207 -123
  29. package/lib/PointerEvents.d.ts +4 -4
  30. package/lib/PointerEvents.js +7 -14
  31. package/lib/Shape.d.ts +7 -4
  32. package/lib/Shape.js +91 -91
  33. package/lib/Stage.d.ts +8 -7
  34. package/lib/Stage.js +66 -56
  35. package/lib/Tween.d.ts +3 -2
  36. package/lib/Tween.js +29 -31
  37. package/lib/Util.d.ts +3 -2
  38. package/lib/Util.js +98 -38
  39. package/lib/Validators.js +44 -57
  40. package/lib/_CoreInternals.d.ts +49 -23
  41. package/lib/_CoreInternals.js +33 -36
  42. package/lib/_FullInternals.d.ts +126 -62
  43. package/lib/_FullInternals.js +77 -78
  44. package/lib/canvas-backend.d.ts +2 -0
  45. package/lib/canvas-backend.js +27 -0
  46. package/lib/filters/Blur.d.ts +1 -1
  47. package/lib/filters/Blur.js +5 -9
  48. package/lib/filters/Brighten.d.ts +1 -1
  49. package/lib/filters/Brighten.js +5 -9
  50. package/lib/filters/Brightness.d.ts +2 -0
  51. package/lib/filters/Brightness.js +8 -0
  52. package/lib/filters/Contrast.d.ts +1 -1
  53. package/lib/filters/Contrast.js +5 -9
  54. package/lib/filters/Emboss.d.ts +1 -1
  55. package/lib/filters/Emboss.js +95 -101
  56. package/lib/filters/Enhance.d.ts +1 -1
  57. package/lib/filters/Enhance.js +5 -9
  58. package/lib/filters/Grayscale.d.ts +1 -1
  59. package/lib/filters/Grayscale.js +1 -5
  60. package/lib/filters/HSL.d.ts +1 -1
  61. package/lib/filters/HSL.js +7 -11
  62. package/lib/filters/HSV.d.ts +1 -1
  63. package/lib/filters/HSV.js +7 -11
  64. package/lib/filters/Invert.d.ts +1 -1
  65. package/lib/filters/Invert.js +1 -5
  66. package/lib/filters/Kaleidoscope.d.ts +1 -1
  67. package/lib/filters/Kaleidoscope.js +9 -13
  68. package/lib/filters/Mask.d.ts +1 -1
  69. package/lib/filters/Mask.js +16 -10
  70. package/lib/filters/Noise.d.ts +1 -1
  71. package/lib/filters/Noise.js +5 -9
  72. package/lib/filters/Pixelate.d.ts +1 -1
  73. package/lib/filters/Pixelate.js +7 -11
  74. package/lib/filters/Posterize.d.ts +1 -1
  75. package/lib/filters/Posterize.js +5 -9
  76. package/lib/filters/RGB.d.ts +1 -1
  77. package/lib/filters/RGB.js +7 -11
  78. package/lib/filters/RGBA.d.ts +1 -1
  79. package/lib/filters/RGBA.js +8 -12
  80. package/lib/filters/Sepia.d.ts +1 -1
  81. package/lib/filters/Sepia.js +1 -5
  82. package/lib/filters/Solarize.d.ts +1 -1
  83. package/lib/filters/Solarize.js +13 -29
  84. package/lib/filters/Threshold.d.ts +1 -1
  85. package/lib/filters/Threshold.js +5 -9
  86. package/lib/index.d.ts +1 -1
  87. package/lib/index.js +2 -4
  88. package/lib/shapes/Arc.d.ts +4 -3
  89. package/lib/shapes/Arc.js +13 -17
  90. package/lib/shapes/Arrow.d.ts +4 -3
  91. package/lib/shapes/Arrow.js +13 -17
  92. package/lib/shapes/Circle.d.ts +4 -3
  93. package/lib/shapes/Circle.js +7 -11
  94. package/lib/shapes/Ellipse.d.ts +4 -3
  95. package/lib/shapes/Ellipse.js +9 -13
  96. package/lib/shapes/Image.d.ts +4 -3
  97. package/lib/shapes/Image.js +17 -21
  98. package/lib/shapes/Label.d.ts +7 -6
  99. package/lib/shapes/Label.js +13 -18
  100. package/lib/shapes/Line.d.ts +4 -3
  101. package/lib/shapes/Line.js +10 -14
  102. package/lib/shapes/Path.d.ts +3 -2
  103. package/lib/shapes/Path.js +83 -23
  104. package/lib/shapes/Rect.d.ts +4 -3
  105. package/lib/shapes/Rect.js +9 -13
  106. package/lib/shapes/RegularPolygon.d.ts +6 -3
  107. package/lib/shapes/RegularPolygon.js +19 -16
  108. package/lib/shapes/Ring.d.ts +4 -3
  109. package/lib/shapes/Ring.js +8 -12
  110. package/lib/shapes/Sprite.d.ts +5 -4
  111. package/lib/shapes/Sprite.js +15 -19
  112. package/lib/shapes/Star.d.ts +4 -3
  113. package/lib/shapes/Star.js +9 -13
  114. package/lib/shapes/Text.d.ts +16 -3
  115. package/lib/shapes/Text.js +73 -53
  116. package/lib/shapes/TextPath.d.ts +5 -4
  117. package/lib/shapes/TextPath.js +48 -41
  118. package/lib/shapes/Transformer.d.ts +8 -8
  119. package/lib/shapes/Transformer.js +90 -90
  120. package/lib/shapes/Wedge.d.ts +4 -3
  121. package/lib/shapes/Wedge.js +12 -16
  122. package/lib/skia-backend.d.ts +2 -0
  123. package/lib/skia-backend.js +24 -0
  124. package/lib/types.d.ts +22 -22
  125. package/lib/types.js +21 -25
  126. package/package.json +53 -25
  127. package/lib/index-node.d.ts +0 -2
  128. package/lib/index-node.js +0 -21
  129. package/lib/index-types.d.ts +0 -181
package/lib/Util.js CHANGED
@@ -1,8 +1,24 @@
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 {
1
+ import { Konva } from "./Global.js";
2
+ const NODE_ERROR = `Konva.js unsupported environment.
3
+
4
+ Looks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined.
5
+
6
+ To use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.
7
+
8
+ bash: npm install canvas
9
+ js: import "konva/canvas-backend";
10
+
11
+ or
12
+
13
+ bash: npm install skia-canvas
14
+ js: import "konva/skia-backend";
15
+ `;
16
+ const ensureBrowser = () => {
17
+ if (typeof document === 'undefined') {
18
+ throw new Error(NODE_ERROR);
19
+ }
20
+ };
21
+ export class Transform {
6
22
  constructor(m = [1, 0, 0, 1, 0, 0]) {
7
23
  this.dirty = false;
8
24
  this.m = (m && m.slice()) || [1, 0, 0, 1, 0, 0];
@@ -145,11 +161,10 @@ class Transform {
145
161
  }
146
162
  else {
147
163
  }
148
- result.rotation = exports.Util._getRotation(result.rotation);
164
+ result.rotation = Util._getRotation(result.rotation);
149
165
  return result;
150
166
  }
151
167
  }
152
- exports.Transform = Transform;
153
168
  const 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 = {
154
169
  aliceblue: [240, 248, 255],
155
170
  antiquewhite: [250, 235, 215],
@@ -306,7 +321,7 @@ const req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFra
306
321
  function (f) {
307
322
  setTimeout(f, 60);
308
323
  };
309
- exports.Util = {
324
+ export const Util = {
310
325
  _isElement(obj) {
311
326
  return !!(obj && obj.nodeType == 1);
312
327
  },
@@ -366,6 +381,7 @@ exports.Util = {
366
381
  }
367
382
  },
368
383
  createCanvasElement() {
384
+ ensureBrowser();
369
385
  const canvas = document.createElement('canvas');
370
386
  try {
371
387
  canvas.style = canvas.style || {};
@@ -374,6 +390,7 @@ exports.Util = {
374
390
  return canvas;
375
391
  },
376
392
  createImageElement() {
393
+ ensureBrowser();
377
394
  return document.createElement('img');
378
395
  },
379
396
  _isInDocument(el) {
@@ -385,7 +402,7 @@ exports.Util = {
385
402
  return false;
386
403
  },
387
404
  _urlToImage(url, callback) {
388
- const imageObj = exports.Util.createImageElement();
405
+ const imageObj = Util.createImageElement();
389
406
  imageObj.onload = function () {
390
407
  callback(imageObj);
391
408
  };
@@ -441,14 +458,14 @@ exports.Util = {
441
458
  },
442
459
  colorToRGBA(str) {
443
460
  str = str || 'black';
444
- return (exports.Util._namedColorToRBA(str) ||
445
- exports.Util._hex3ColorToRGBA(str) ||
446
- exports.Util._hex4ColorToRGBA(str) ||
447
- exports.Util._hex6ColorToRGBA(str) ||
448
- exports.Util._hex8ColorToRGBA(str) ||
449
- exports.Util._rgbColorToRGBA(str) ||
450
- exports.Util._rgbaColorToRGBA(str) ||
451
- exports.Util._hslColorToRGBA(str));
461
+ return (Util._namedColorToRBA(str) ||
462
+ Util._hex3ColorToRGBA(str) ||
463
+ Util._hex4ColorToRGBA(str) ||
464
+ Util._hex6ColorToRGBA(str) ||
465
+ Util._hex8ColorToRGBA(str) ||
466
+ Util._rgbColorToRGBA(str) ||
467
+ Util._rgbaColorToRGBA(str) ||
468
+ Util._hslColorToRGBA(str));
452
469
  },
453
470
  _namedColorToRBA(str) {
454
471
  const c = COLORS[str.toLowerCase()];
@@ -618,15 +635,15 @@ exports.Util = {
618
635
  return rad * DEG180_OVER_PI;
619
636
  },
620
637
  _degToRad(deg) {
621
- exports.Util.warn('Util._degToRad is removed. Please use public Util.degToRad instead.');
622
- return exports.Util.degToRad(deg);
638
+ Util.warn('Util._degToRad is removed. Please use public Util.degToRad instead.');
639
+ return Util.degToRad(deg);
623
640
  },
624
641
  _radToDeg(rad) {
625
- exports.Util.warn('Util._radToDeg is removed. Please use public Util.radToDeg instead.');
626
- return exports.Util.radToDeg(rad);
642
+ Util.warn('Util._radToDeg is removed. Please use public Util.radToDeg instead.');
643
+ return Util.radToDeg(rad);
627
644
  },
628
645
  _getRotation(radians) {
629
- return Global_1.Konva.angleDeg ? exports.Util.radToDeg(radians) : radians;
646
+ return Konva.angleDeg ? Util.radToDeg(radians) : radians;
630
647
  },
631
648
  _capitalize(str) {
632
649
  return str.charAt(0).toUpperCase() + str.slice(1);
@@ -638,7 +655,7 @@ exports.Util = {
638
655
  console.error(KONVA_ERROR + str);
639
656
  },
640
657
  warn(str) {
641
- if (!Global_1.Konva.showWarnings) {
658
+ if (!Konva.showWarnings) {
642
659
  return;
643
660
  }
644
661
  console.warn(KONVA_WARNING + str);
@@ -680,14 +697,14 @@ exports.Util = {
680
697
  return [x, y, dist];
681
698
  },
682
699
  _getProjectionToLine(pt, line, isClosed) {
683
- const pc = exports.Util.cloneObject(pt);
700
+ const pc = Util.cloneObject(pt);
684
701
  let dist = Number.MAX_VALUE;
685
702
  line.forEach(function (p1, i) {
686
703
  if (!isClosed && i === line.length - 1) {
687
704
  return;
688
705
  }
689
706
  const p2 = line[(i + 1) % line.length];
690
- const proj = exports.Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);
707
+ const proj = Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);
691
708
  const px = proj[0], py = proj[1], pdist = proj[2];
692
709
  if (pdist < dist) {
693
710
  pc.x = px;
@@ -718,7 +735,7 @@ exports.Util = {
718
735
  }
719
736
  const newStart = [];
720
737
  end.forEach(function (point) {
721
- const pr = exports.Util._getProjectionToLine(point, start, isClosed);
738
+ const pr = Util._getProjectionToLine(point, start, isClosed);
722
739
  newStart.push(pr.x);
723
740
  newStart.push(pr.y);
724
741
  });
@@ -733,7 +750,7 @@ exports.Util = {
733
750
  }
734
751
  desc = Object.getOwnPropertyDescriptor(obj, key);
735
752
  if (obj[key].visitedByCircularReferenceRemoval ||
736
- exports.Util._isElement(obj[key])) {
753
+ Util._isElement(obj[key])) {
737
754
  if (desc.configurable) {
738
755
  delete obj[key];
739
756
  }
@@ -741,7 +758,7 @@ exports.Util = {
741
758
  return null;
742
759
  }
743
760
  }
744
- else if (exports.Util._prepareToStringify(obj[key]) === null) {
761
+ else if (Util._prepareToStringify(obj[key]) === null) {
745
762
  if (desc.configurable) {
746
763
  delete obj[key];
747
764
  }
@@ -768,7 +785,7 @@ exports.Util = {
768
785
  }
769
786
  },
770
787
  releaseCanvas(...canvases) {
771
- if (!Global_1.Konva.releaseCanvasOnDestroy)
788
+ if (!Konva.releaseCanvasOnDestroy)
772
789
  return;
773
790
  canvases.forEach((c) => {
774
791
  c.width = 0;
@@ -776,6 +793,10 @@ exports.Util = {
776
793
  });
777
794
  },
778
795
  drawRoundedRectPath(context, width, height, cornerRadius) {
796
+ let xOrigin = width < 0 ? width : 0;
797
+ let yOrigin = height < 0 ? height : 0;
798
+ width = Math.abs(width);
799
+ height = Math.abs(height);
779
800
  let topLeft = 0;
780
801
  let topRight = 0;
781
802
  let bottomLeft = 0;
@@ -793,14 +814,53 @@ exports.Util = {
793
814
  bottomRight = Math.min(cornerRadius[2] || 0, width / 2, height / 2);
794
815
  bottomLeft = Math.min(cornerRadius[3] || 0, width / 2, height / 2);
795
816
  }
796
- context.moveTo(topLeft, 0);
797
- context.lineTo(width - topRight, 0);
798
- context.arc(width - topRight, topRight, topRight, (Math.PI * 3) / 2, 0, false);
799
- context.lineTo(width, height - bottomRight);
800
- context.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, false);
801
- context.lineTo(bottomLeft, height);
802
- context.arc(bottomLeft, height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);
803
- context.lineTo(0, topLeft);
804
- context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);
817
+ context.moveTo(xOrigin + topLeft, yOrigin);
818
+ context.lineTo(xOrigin + width - topRight, yOrigin);
819
+ context.arc(xOrigin + width - topRight, yOrigin + topRight, topRight, (Math.PI * 3) / 2, 0, false);
820
+ context.lineTo(xOrigin + width, yOrigin + height - bottomRight);
821
+ context.arc(xOrigin + width - bottomRight, yOrigin + height - bottomRight, bottomRight, 0, Math.PI / 2, false);
822
+ context.lineTo(xOrigin + bottomLeft, yOrigin + height);
823
+ context.arc(xOrigin + bottomLeft, yOrigin + height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);
824
+ context.lineTo(xOrigin, yOrigin + topLeft);
825
+ context.arc(xOrigin + topLeft, yOrigin + topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);
826
+ },
827
+ drawRoundedPolygonPath(context, points, sides, radius, cornerRadius) {
828
+ radius = Math.abs(radius);
829
+ for (let i = 0; i < sides; i++) {
830
+ const prev = points[(i - 1 + sides) % sides];
831
+ const curr = points[i];
832
+ const next = points[(i + 1) % sides];
833
+ const vec1 = { x: curr.x - prev.x, y: curr.y - prev.y };
834
+ const vec2 = { x: next.x - curr.x, y: next.y - curr.y };
835
+ const len1 = Math.hypot(vec1.x, vec1.y);
836
+ const len2 = Math.hypot(vec2.x, vec2.y);
837
+ let currCornerRadius;
838
+ if (typeof cornerRadius === 'number') {
839
+ currCornerRadius = cornerRadius;
840
+ }
841
+ else {
842
+ currCornerRadius = i < cornerRadius.length ? cornerRadius[i] : 0;
843
+ }
844
+ const maxCornerRadius = radius * Math.cos(Math.PI / sides);
845
+ currCornerRadius =
846
+ maxCornerRadius * Math.min(1, (currCornerRadius / radius) * 2);
847
+ const normalVec1 = { x: vec1.x / len1, y: vec1.y / len1 };
848
+ const normalVec2 = { x: vec2.x / len2, y: vec2.y / len2 };
849
+ const p1 = {
850
+ x: curr.x - normalVec1.x * currCornerRadius,
851
+ y: curr.y - normalVec1.y * currCornerRadius,
852
+ };
853
+ const p2 = {
854
+ x: curr.x + normalVec2.x * currCornerRadius,
855
+ y: curr.y + normalVec2.y * currCornerRadius,
856
+ };
857
+ if (i === 0) {
858
+ context.moveTo(p1.x, p1.y);
859
+ }
860
+ else {
861
+ context.lineTo(p1.x, p1.y);
862
+ }
863
+ context.arcTo(curr.x, curr.y, p2.x, p2.y, currCornerRadius);
864
+ }
805
865
  },
806
866
  };
package/lib/Validators.js CHANGED
@@ -1,31 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RGBComponent = RGBComponent;
4
- exports.alphaComponent = alphaComponent;
5
- exports.getNumberValidator = getNumberValidator;
6
- exports.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;
7
- exports.getNumberOrAutoValidator = getNumberOrAutoValidator;
8
- exports.getStringValidator = getStringValidator;
9
- exports.getStringOrGradientValidator = getStringOrGradientValidator;
10
- exports.getFunctionValidator = getFunctionValidator;
11
- exports.getNumberArrayValidator = getNumberArrayValidator;
12
- exports.getBooleanValidator = getBooleanValidator;
13
- exports.getComponentValidator = getComponentValidator;
14
- const Global_1 = require("./Global");
15
- const Util_1 = require("./Util");
1
+ import { Konva } from "./Global.js";
2
+ import { Util } from "./Util.js";
16
3
  function _formatValue(val) {
17
- if (Util_1.Util._isString(val)) {
4
+ if (Util._isString(val)) {
18
5
  return '"' + val + '"';
19
6
  }
20
7
  if (Object.prototype.toString.call(val) === '[object Number]') {
21
8
  return val;
22
9
  }
23
- if (Util_1.Util._isBoolean(val)) {
10
+ if (Util._isBoolean(val)) {
24
11
  return val;
25
12
  }
26
13
  return Object.prototype.toString.call(val);
27
14
  }
28
- function RGBComponent(val) {
15
+ export function RGBComponent(val) {
29
16
  if (val > 255) {
30
17
  return 255;
31
18
  }
@@ -34,7 +21,7 @@ function RGBComponent(val) {
34
21
  }
35
22
  return Math.round(val);
36
23
  }
37
- function alphaComponent(val) {
24
+ export function alphaComponent(val) {
38
25
  if (val > 1) {
39
26
  return 1;
40
27
  }
@@ -43,11 +30,11 @@ function alphaComponent(val) {
43
30
  }
44
31
  return val;
45
32
  }
46
- function getNumberValidator() {
47
- if (Global_1.Konva.isUnminified) {
33
+ export function getNumberValidator() {
34
+ if (Konva.isUnminified) {
48
35
  return function (val, attr) {
49
- if (!Util_1.Util._isNumber(val)) {
50
- Util_1.Util.warn(_formatValue(val) +
36
+ if (!Util._isNumber(val)) {
37
+ Util.warn(_formatValue(val) +
51
38
  ' is a not valid value for "' +
52
39
  attr +
53
40
  '" attribute. The value should be a number.');
@@ -56,13 +43,13 @@ function getNumberValidator() {
56
43
  };
57
44
  }
58
45
  }
59
- function getNumberOrArrayOfNumbersValidator(noOfElements) {
60
- if (Global_1.Konva.isUnminified) {
46
+ export function getNumberOrArrayOfNumbersValidator(noOfElements) {
47
+ if (Konva.isUnminified) {
61
48
  return function (val, attr) {
62
- let isNumber = Util_1.Util._isNumber(val);
63
- let isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements;
49
+ let isNumber = Util._isNumber(val);
50
+ let isValidArray = Util._isArray(val) && val.length == noOfElements;
64
51
  if (!isNumber && !isValidArray) {
65
- Util_1.Util.warn(_formatValue(val) +
52
+ Util.warn(_formatValue(val) +
66
53
  ' is a not valid value for "' +
67
54
  attr +
68
55
  '" attribute. The value should be a number or Array<number>(' +
@@ -73,13 +60,13 @@ function getNumberOrArrayOfNumbersValidator(noOfElements) {
73
60
  };
74
61
  }
75
62
  }
76
- function getNumberOrAutoValidator() {
77
- if (Global_1.Konva.isUnminified) {
63
+ export function getNumberOrAutoValidator() {
64
+ if (Konva.isUnminified) {
78
65
  return function (val, attr) {
79
- const isNumber = Util_1.Util._isNumber(val);
66
+ const isNumber = Util._isNumber(val);
80
67
  const isAuto = val === 'auto';
81
68
  if (!(isNumber || isAuto)) {
82
- Util_1.Util.warn(_formatValue(val) +
69
+ Util.warn(_formatValue(val) +
83
70
  ' is a not valid value for "' +
84
71
  attr +
85
72
  '" attribute. The value should be a number or "auto".');
@@ -88,11 +75,11 @@ function getNumberOrAutoValidator() {
88
75
  };
89
76
  }
90
77
  }
91
- function getStringValidator() {
92
- if (Global_1.Konva.isUnminified) {
78
+ export function getStringValidator() {
79
+ if (Konva.isUnminified) {
93
80
  return function (val, attr) {
94
- if (!Util_1.Util._isString(val)) {
95
- Util_1.Util.warn(_formatValue(val) +
81
+ if (!Util._isString(val)) {
82
+ Util.warn(_formatValue(val) +
96
83
  ' is a not valid value for "' +
97
84
  attr +
98
85
  '" attribute. The value should be a string.');
@@ -101,14 +88,14 @@ function getStringValidator() {
101
88
  };
102
89
  }
103
90
  }
104
- function getStringOrGradientValidator() {
105
- if (Global_1.Konva.isUnminified) {
91
+ export function getStringOrGradientValidator() {
92
+ if (Konva.isUnminified) {
106
93
  return function (val, attr) {
107
- const isString = Util_1.Util._isString(val);
94
+ const isString = Util._isString(val);
108
95
  const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
109
96
  (val && val['addColorStop']);
110
97
  if (!(isString || isGradient)) {
111
- Util_1.Util.warn(_formatValue(val) +
98
+ Util.warn(_formatValue(val) +
112
99
  ' is a not valid value for "' +
113
100
  attr +
114
101
  '" attribute. The value should be a string or a native gradient.');
@@ -117,11 +104,11 @@ function getStringOrGradientValidator() {
117
104
  };
118
105
  }
119
106
  }
120
- function getFunctionValidator() {
121
- if (Global_1.Konva.isUnminified) {
107
+ export function getFunctionValidator() {
108
+ if (Konva.isUnminified) {
122
109
  return function (val, attr) {
123
- if (!Util_1.Util._isFunction(val)) {
124
- Util_1.Util.warn(_formatValue(val) +
110
+ if (!Util._isFunction(val)) {
111
+ Util.warn(_formatValue(val) +
125
112
  ' is a not valid value for "' +
126
113
  attr +
127
114
  '" attribute. The value should be a function.');
@@ -130,23 +117,23 @@ function getFunctionValidator() {
130
117
  };
131
118
  }
132
119
  }
133
- function getNumberArrayValidator() {
134
- if (Global_1.Konva.isUnminified) {
120
+ export function getNumberArrayValidator() {
121
+ if (Konva.isUnminified) {
135
122
  return function (val, attr) {
136
123
  const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
137
124
  if (TypedArray && val instanceof TypedArray) {
138
125
  return val;
139
126
  }
140
- if (!Util_1.Util._isArray(val)) {
141
- Util_1.Util.warn(_formatValue(val) +
127
+ if (!Util._isArray(val)) {
128
+ Util.warn(_formatValue(val) +
142
129
  ' is a not valid value for "' +
143
130
  attr +
144
131
  '" attribute. The value should be a array of numbers.');
145
132
  }
146
133
  else {
147
134
  val.forEach(function (item) {
148
- if (!Util_1.Util._isNumber(item)) {
149
- Util_1.Util.warn('"' +
135
+ if (!Util._isNumber(item)) {
136
+ Util.warn('"' +
150
137
  attr +
151
138
  '" attribute has non numeric element ' +
152
139
  item +
@@ -158,12 +145,12 @@ function getNumberArrayValidator() {
158
145
  };
159
146
  }
160
147
  }
161
- function getBooleanValidator() {
162
- if (Global_1.Konva.isUnminified) {
148
+ export function getBooleanValidator() {
149
+ if (Konva.isUnminified) {
163
150
  return function (val, attr) {
164
151
  const isBool = val === true || val === false;
165
152
  if (!isBool) {
166
- Util_1.Util.warn(_formatValue(val) +
153
+ Util.warn(_formatValue(val) +
167
154
  ' is a not valid value for "' +
168
155
  attr +
169
156
  '" attribute. The value should be a boolean.');
@@ -172,14 +159,14 @@ function getBooleanValidator() {
172
159
  };
173
160
  }
174
161
  }
175
- function getComponentValidator(components) {
176
- if (Global_1.Konva.isUnminified) {
162
+ export function getComponentValidator(components) {
163
+ if (Konva.isUnminified) {
177
164
  return function (val, attr) {
178
165
  if (val === undefined || val === null) {
179
166
  return val;
180
167
  }
181
- if (!Util_1.Util.isObject(val)) {
182
- Util_1.Util.warn(_formatValue(val) +
168
+ if (!Util.isObject(val)) {
169
+ Util.warn(_formatValue(val) +
183
170
  ' is a not valid value for "' +
184
171
  attr +
185
172
  '" attribute. The value should be an object with properties ' +
@@ -1,15 +1,15 @@
1
- import { Transform } from './Util.js';
2
- import { Node } from './Node.js';
3
- import { Container } from './Container.js';
4
- import { Stage } from './Stage.js';
5
- import { Layer } from './Layer.js';
6
- import { FastLayer } from './FastLayer.js';
7
- import { Group } from './Group.js';
8
- import { Shape } from './Shape.js';
9
- import { Animation } from './Animation.js';
10
- import { Tween } from './Tween.js';
11
- import { Context } from './Context.js';
12
- import { Canvas } from './Canvas.js';
1
+ import { Transform } from './Util.ts';
2
+ import { Node } from './Node.ts';
3
+ import { Container } from './Container.ts';
4
+ import { Stage } from './Stage.ts';
5
+ import { Layer } from './Layer.ts';
6
+ import { FastLayer } from './FastLayer.ts';
7
+ import { Group } from './Group.ts';
8
+ import { Shape } from './Shape.ts';
9
+ import { Animation } from './Animation.ts';
10
+ import { Tween } from './Tween.ts';
11
+ import { Context } from './Context.ts';
12
+ import { Canvas } from './Canvas.ts';
13
13
  export declare const Konva: {
14
14
  _global: any;
15
15
  version: string;
@@ -31,14 +31,15 @@ export declare const Konva: {
31
31
  _mouseDblClickPointerId: null;
32
32
  _touchDblClickPointerId: null;
33
33
  _pointerDblClickPointerId: null;
34
- _fixTextRendering: boolean;
34
+ _renderBackend: string;
35
+ legacyTextRendering: boolean;
35
36
  pixelRatio: number;
36
37
  dragDistance: number;
37
38
  angleDeg: boolean;
38
39
  showWarnings: boolean;
39
40
  dragButtons: number[];
40
- isDragging(): any;
41
- isTransforming(): any;
41
+ isDragging(): boolean;
42
+ isTransforming(): boolean;
42
43
  isDragReady(): boolean;
43
44
  releaseCanvasOnDestroy: boolean;
44
45
  document: any;
@@ -61,9 +62,9 @@ export declare const Konva: {
61
62
  _isInDocument(el: any): boolean;
62
63
  _urlToImage(url: string, callback: Function): void;
63
64
  _rgbToHex(r: number, g: number, b: number): string;
64
- _hexToRgb(hex: string): import("./types.js").RGB;
65
+ _hexToRgb(hex: string): import("./types.ts").RGB;
65
66
  getRandomColor(): string;
66
- getRGB(color: string): import("./types.js").RGB;
67
+ getRGB(color: string): import("./types.ts").RGB;
67
68
  colorToRGBA(str: string): {
68
69
  r: number;
69
70
  g: number;
@@ -118,7 +119,7 @@ export declare const Konva: {
118
119
  b: number;
119
120
  a: number;
120
121
  } | undefined;
121
- haveIntersection(r1: import("./types").IRect, r2: import("./types.js").IRect): boolean;
122
+ haveIntersection(r1: import("./types.ts").IRect, r2: import("./types.ts").IRect): boolean;
122
123
  cloneObject<Any>(obj: Any): Any;
123
124
  cloneArray(arr: Array<any>): any[];
124
125
  degToRad(deg: number): number;
@@ -133,13 +134,14 @@ export declare const Konva: {
133
134
  each(obj: object, func: Function): void;
134
135
  _inRange(val: number, left: number, right: number): boolean;
135
136
  _getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
136
- _getProjectionToLine(pt: import("./types").Vector2d, line: Array<import("./types").Vector2d>, isClosed: boolean): import("./types.js").Vector2d;
137
+ _getProjectionToLine(pt: import("./types.ts").Vector2d, line: Array<import("./types.ts").Vector2d>, isClosed: boolean): import("./types.ts").Vector2d;
137
138
  _prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
138
139
  _prepareToStringify<T>(obj: any): T | null;
139
140
  _assign<T, U>(target: T, source: U): T & U;
140
141
  _getFirstPointerId(evt: any): any;
141
142
  releaseCanvas(...canvases: HTMLCanvasElement[]): void;
142
143
  drawRoundedRectPath(context: Context, width: number, height: number, cornerRadius: number | number[]): void;
144
+ drawRoundedPolygonPath(context: Context, points: import("./types.ts").Vector2d[], sides: number, radius: number, cornerRadius: number | number[]): void;
143
145
  };
144
146
  Transform: typeof Transform;
145
147
  Node: typeof Node;
@@ -152,11 +154,11 @@ export declare const Konva: {
152
154
  DD: {
153
155
  readonly isDragging: boolean;
154
156
  justDragged: boolean;
155
- readonly node: Node<import("./Node.js").NodeConfig> | undefined;
157
+ readonly node: Node<import("./Node.ts").NodeConfig> | undefined;
156
158
  _dragElements: Map<number, {
157
159
  node: Node;
158
- startPointerPos: import("./types.js").Vector2d;
159
- offset: import("./types.js").Vector2d;
160
+ startPointerPos: import("./types.ts").Vector2d;
161
+ offset: import("./types.ts").Vector2d;
160
162
  pointerId?: number;
161
163
  dragStatus: "ready" | "dragging" | "stopped";
162
164
  }>;
@@ -166,7 +168,7 @@ export declare const Konva: {
166
168
  };
167
169
  Shape: typeof Shape;
168
170
  shapes: {
169
- [key: string]: Shape<import("./Shape.js").ShapeConfig>;
171
+ [key: string]: Shape<import("./Shape.ts").ShapeConfig>;
170
172
  };
171
173
  Animation: typeof Animation;
172
174
  Tween: typeof Tween;
@@ -191,4 +193,28 @@ export declare const Konva: {
191
193
  Context: typeof Context;
192
194
  Canvas: typeof Canvas;
193
195
  };
196
+ export declare namespace Konva {
197
+ type Vector2d = import('./types.ts').Vector2d;
198
+ type Node = import('./Node.ts').Node;
199
+ type NodeConfig = import('./Node.ts').NodeConfig;
200
+ type KonvaEventObject<EventType> = import('./Node.ts').KonvaEventObject<EventType>;
201
+ type KonvaPointerEvent = import('./PointerEvents.ts').KonvaPointerEvent;
202
+ type KonvaEventListener<This, EventType> = import('./Node.ts').KonvaEventListener<This, EventType>;
203
+ type Container = import('./Container.ts').Container<Node>;
204
+ type ContainerConfig = import('./Container.ts').ContainerConfig;
205
+ type Transform = import('./Util.ts').Transform;
206
+ type Context = import('./Context.ts').Context;
207
+ type Stage = import('./Stage.ts').Stage;
208
+ type StageConfig = import('./Stage.ts').StageConfig;
209
+ type Layer = import('./Layer.ts').Layer;
210
+ type LayerConfig = import('./Layer.ts').LayerConfig;
211
+ type FastLayer = import('./FastLayer.ts').FastLayer;
212
+ type Group = import('./Group.ts').Group;
213
+ type GroupConfig = import('./Group.ts').GroupConfig;
214
+ type Shape = import('./Shape.ts').Shape;
215
+ type ShapeConfig = import('./Shape.ts').ShapeConfig;
216
+ type Animation = import('./Animation.ts').Animation;
217
+ type Tween = import('./Tween.ts').Tween;
218
+ type TweenConfig = import('./Tween.ts').TweenConfig;
219
+ }
194
220
  export default Konva;
@@ -1,37 +1,34 @@
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,
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,
36
33
  });
37
- exports.default = exports.Konva;
34
+ export default Konva;