konva 10.0.8 → 10.0.10

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 (127) hide show
  1. package/konva.js +95 -48
  2. package/konva.min.js +4 -4
  3. package/package.json +1 -1
  4. package/lib/Animation.d.ts +0 -24
  5. package/lib/Animation.js +0 -142
  6. package/lib/BezierFunctions.d.ts +0 -6
  7. package/lib/BezierFunctions.js +0 -784
  8. package/lib/Canvas.d.ts +0 -33
  9. package/lib/Canvas.js +0 -137
  10. package/lib/Container.d.ts +0 -54
  11. package/lib/Container.js +0 -316
  12. package/lib/Context.d.ts +0 -95
  13. package/lib/Context.js +0 -561
  14. package/lib/Core.d.ts +0 -3
  15. package/lib/Core.js +0 -3
  16. package/lib/DragAndDrop.d.ts +0 -17
  17. package/lib/DragAndDrop.js +0 -110
  18. package/lib/Factory.d.ts +0 -22
  19. package/lib/Factory.js +0 -123
  20. package/lib/FastLayer.d.ts +0 -4
  21. package/lib/FastLayer.js +0 -12
  22. package/lib/Global.d.ts +0 -37
  23. package/lib/Global.js +0 -66
  24. package/lib/Group.d.ts +0 -9
  25. package/lib/Group.js +0 -13
  26. package/lib/Layer.d.ts +0 -62
  27. package/lib/Layer.js +0 -305
  28. package/lib/Node.d.ts +0 -323
  29. package/lib/Node.js +0 -1532
  30. package/lib/PointerEvents.d.ts +0 -11
  31. package/lib/PointerEvents.js +0 -37
  32. package/lib/Shape.d.ts +0 -196
  33. package/lib/Shape.js +0 -548
  34. package/lib/Stage.d.ts +0 -86
  35. package/lib/Stage.js +0 -715
  36. package/lib/Tween.d.ts +0 -90
  37. package/lib/Tween.js +0 -531
  38. package/lib/Util.d.ts +0 -133
  39. package/lib/Util.js +0 -866
  40. package/lib/Validators.d.ts +0 -11
  41. package/lib/Validators.js +0 -178
  42. package/lib/_CoreInternals.d.ts +0 -220
  43. package/lib/_CoreInternals.js +0 -34
  44. package/lib/_FullInternals.d.ts +0 -302
  45. package/lib/_FullInternals.js +0 -80
  46. package/lib/canvas-backend.d.ts +0 -2
  47. package/lib/canvas-backend.js +0 -27
  48. package/lib/filters/Blur.d.ts +0 -2
  49. package/lib/filters/Blur.js +0 -235
  50. package/lib/filters/Brighten.d.ts +0 -2
  51. package/lib/filters/Brighten.js +0 -12
  52. package/lib/filters/Brightness.d.ts +0 -2
  53. package/lib/filters/Brightness.js +0 -8
  54. package/lib/filters/Contrast.d.ts +0 -2
  55. package/lib/filters/Contrast.js +0 -35
  56. package/lib/filters/Emboss.d.ts +0 -2
  57. package/lib/filters/Emboss.js +0 -101
  58. package/lib/filters/Enhance.d.ts +0 -2
  59. package/lib/filters/Enhance.js +0 -84
  60. package/lib/filters/Grayscale.d.ts +0 -2
  61. package/lib/filters/Grayscale.js +0 -9
  62. package/lib/filters/HSL.d.ts +0 -2
  63. package/lib/filters/HSL.js +0 -24
  64. package/lib/filters/HSV.d.ts +0 -2
  65. package/lib/filters/HSV.js +0 -23
  66. package/lib/filters/Invert.d.ts +0 -2
  67. package/lib/filters/Invert.js +0 -8
  68. package/lib/filters/Kaleidoscope.d.ts +0 -2
  69. package/lib/filters/Kaleidoscope.js +0 -133
  70. package/lib/filters/Mask.d.ts +0 -2
  71. package/lib/filters/Mask.js +0 -151
  72. package/lib/filters/Noise.d.ts +0 -2
  73. package/lib/filters/Noise.js +0 -12
  74. package/lib/filters/Pixelate.d.ts +0 -2
  75. package/lib/filters/Pixelate.js +0 -60
  76. package/lib/filters/Posterize.d.ts +0 -2
  77. package/lib/filters/Posterize.js +0 -10
  78. package/lib/filters/RGB.d.ts +0 -2
  79. package/lib/filters/RGB.js +0 -38
  80. package/lib/filters/RGBA.d.ts +0 -2
  81. package/lib/filters/RGBA.js +0 -49
  82. package/lib/filters/Sepia.d.ts +0 -2
  83. package/lib/filters/Sepia.js +0 -11
  84. package/lib/filters/Solarize.d.ts +0 -2
  85. package/lib/filters/Solarize.js +0 -14
  86. package/lib/filters/Threshold.d.ts +0 -2
  87. package/lib/filters/Threshold.js +0 -10
  88. package/lib/index.d.ts +0 -2
  89. package/lib/index.js +0 -2
  90. package/lib/shapes/Arc.d.ts +0 -27
  91. package/lib/shapes/Arc.js +0 -60
  92. package/lib/shapes/Arrow.d.ts +0 -27
  93. package/lib/shapes/Arrow.js +0 -99
  94. package/lib/shapes/Circle.d.ts +0 -15
  95. package/lib/shapes/Circle.js +0 -33
  96. package/lib/shapes/Ellipse.d.ts +0 -18
  97. package/lib/shapes/Ellipse.js +0 -37
  98. package/lib/shapes/Image.d.ts +0 -29
  99. package/lib/shapes/Image.js +0 -131
  100. package/lib/shapes/Label.d.ts +0 -39
  101. package/lib/shapes/Label.js +0 -173
  102. package/lib/shapes/Line.d.ts +0 -29
  103. package/lib/shapes/Line.js +0 -156
  104. package/lib/shapes/Path.d.ts +0 -50
  105. package/lib/shapes/Path.js +0 -670
  106. package/lib/shapes/Rect.d.ts +0 -11
  107. package/lib/shapes/Rect.js +0 -22
  108. package/lib/shapes/RegularPolygon.d.ts +0 -26
  109. package/lib/shapes/RegularPolygon.js +0 -72
  110. package/lib/shapes/Ring.d.ts +0 -17
  111. package/lib/shapes/Ring.js +0 -33
  112. package/lib/shapes/Sprite.d.ts +0 -32
  113. package/lib/shapes/Sprite.js +0 -108
  114. package/lib/shapes/Star.d.ts +0 -19
  115. package/lib/shapes/Star.js +0 -38
  116. package/lib/shapes/Text.d.ts +0 -90
  117. package/lib/shapes/Text.js +0 -460
  118. package/lib/shapes/TextPath.d.ts +0 -72
  119. package/lib/shapes/TextPath.js +0 -268
  120. package/lib/shapes/Transformer.d.ts +0 -130
  121. package/lib/shapes/Transformer.js +0 -1009
  122. package/lib/shapes/Wedge.d.ts +0 -19
  123. package/lib/shapes/Wedge.js +0 -38
  124. package/lib/skia-backend.d.ts +0 -2
  125. package/lib/skia-backend.js +0 -24
  126. package/lib/types.d.ts +0 -56
  127. package/lib/types.js +0 -21
package/konva.js CHANGED
@@ -5,10 +5,10 @@
5
5
  })(this, (function () { 'use strict';
6
6
 
7
7
  /*
8
- * Konva JavaScript Framework v10.0.8
8
+ * Konva JavaScript Framework v10.0.10
9
9
  * http://konvajs.org/
10
10
  * Licensed under the MIT
11
- * Date: Fri Oct 24 2025
11
+ * Date: Thu Nov 20 2025
12
12
  *
13
13
  * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
14
14
  * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@@ -35,7 +35,7 @@
35
35
  : {};
36
36
  const Konva$2 = {
37
37
  _global: glob,
38
- version: '10.0.8',
38
+ version: '10.0.10',
39
39
  isBrowser: detectBrowser(),
40
40
  isUnminified: /param/.test(function (param) { }.toString()),
41
41
  dblClickWindow: 400,
@@ -465,7 +465,7 @@ js: import "konva/skia-backend";
465
465
  }
466
466
  }
467
467
  // CONSTANTS
468
- 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$1 = '#', EMPTY_STRING$1 = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
468
+ 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$1 = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
469
469
  aliceblue: [240, 248, 255],
470
470
  antiquewhite: [250, 235, 215],
471
471
  aqua: [0, 255, 255],
@@ -617,6 +617,8 @@ js: import "konva/skia-backend";
617
617
  yellowgreen: [154, 205, 5],
618
618
  }, RGB_REGEX = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;
619
619
  let animQueue = [];
620
+ // Cache for canvas farbling detection
621
+ let _isCanvasFarblingActive = null;
620
622
  const req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame) ||
621
623
  function (f) {
622
624
  setTimeout(f, 60);
@@ -727,7 +729,7 @@ js: import "konva/skia-backend";
727
729
  return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
728
730
  },
729
731
  _hexToRgb(hex) {
730
- hex = hex.replace(HASH$1, EMPTY_STRING$1);
732
+ hex = hex.replace(HASH, EMPTY_STRING$1);
731
733
  const bigint = parseInt(hex, 16);
732
734
  return {
733
735
  r: (bigint >> 16) & 255,
@@ -747,7 +749,77 @@ js: import "konva/skia-backend";
747
749
  while (randColor.length < 6) {
748
750
  randColor = ZERO + randColor;
749
751
  }
750
- return HASH$1 + randColor;
752
+ return HASH + randColor;
753
+ },
754
+ /**
755
+ * Check if canvas farbling is active (e.g., Brave browser fingerprinting protection)
756
+ * @method
757
+ * @memberof Konva.Util
758
+ * @returns {Boolean}
759
+ */
760
+ isCanvasFarblingActive() {
761
+ if (_isCanvasFarblingActive !== null) {
762
+ return _isCanvasFarblingActive;
763
+ }
764
+ if (typeof document === 'undefined') {
765
+ _isCanvasFarblingActive = false;
766
+ return false;
767
+ }
768
+ const c = this.createCanvasElement();
769
+ c.width = 1;
770
+ c.height = 1;
771
+ const ctx = c.getContext('2d', {
772
+ willReadFrequently: true,
773
+ });
774
+ ctx.clearRect(0, 0, 1, 1);
775
+ ctx.fillStyle = 'rgba(255,0,255,1)'; // clear #FF00FF, no alpha
776
+ ctx.fillRect(0, 0, 1, 1);
777
+ const d = ctx.getImageData(0, 0, 1, 1).data;
778
+ const exact = d[0] === 255 && d[1] === 0 && d[2] === 255 && d[3] === 255;
779
+ _isCanvasFarblingActive = !exact;
780
+ this.releaseCanvas(c);
781
+ return _isCanvasFarblingActive;
782
+ },
783
+ /**
784
+ * Get a random color for hit detection (normalized if farbling is active)
785
+ * @method
786
+ * @memberof Konva.Util
787
+ * @returns {String} hex color string
788
+ */
789
+ getHitColor() {
790
+ const color = this.getRandomColor();
791
+ return this.isCanvasFarblingActive()
792
+ ? this.getSnappedHexColor(color)
793
+ : color;
794
+ },
795
+ /**
796
+ * Get hit color key from RGB values (normalized if farbling is active)
797
+ * @method
798
+ * @memberof Konva.Util
799
+ * @param {Number} r - red component (0-255)
800
+ * @param {Number} g - green component (0-255)
801
+ * @param {Number} b - blue component (0-255)
802
+ * @returns {String} hex color key string
803
+ */
804
+ getHitColorKey(r, g, b) {
805
+ if (this.isCanvasFarblingActive()) {
806
+ r = Math.round(r / 5) * 5;
807
+ g = Math.round(g / 5) * 5;
808
+ b = Math.round(b / 5) * 5;
809
+ }
810
+ return HASH + this._rgbToHex(r, g, b);
811
+ },
812
+ /**
813
+ * Snap hex color values to end with 0 (normalize for canvas farbling)
814
+ * @method
815
+ * @memberof Konva.Util
816
+ * @param {String} hex - hex color string (e.g., "#ff00ff")
817
+ * @returns {String} normalized hex color string
818
+ */
819
+ getSnappedHexColor(hex) {
820
+ const rgb = this._hexToRgb(hex);
821
+ return (HASH +
822
+ this._rgbToHex(Math.round(rgb.r / 5) * 5, Math.round(rgb.g / 5) * 5, Math.round(rgb.b / 5) * 5));
751
823
  },
752
824
  /**
753
825
  * get RGB components of a color
@@ -771,7 +843,7 @@ js: import "konva/skia-backend";
771
843
  b: rgb[2],
772
844
  };
773
845
  }
774
- else if (color[0] === HASH$1) {
846
+ else if (color[0] === HASH) {
775
847
  // hex
776
848
  return this._hexToRgb(color.substring(1));
777
849
  }
@@ -2200,45 +2272,12 @@ js: import "konva/skia-backend";
2200
2272
  this.setSize(config.width, config.height);
2201
2273
  }
2202
2274
  }
2203
- // function checks if canvas farbling is active
2204
- // canvas farbling is a Browser security feature, it break konva internals
2205
- function isCanvasFarblingActive() {
2206
- const c = Util.createCanvasElement();
2207
- c.width = 1;
2208
- c.height = 1;
2209
- const ctx = c.getContext('2d', {
2210
- willReadFrequently: true,
2211
- });
2212
- ctx.clearRect(0, 0, 1, 1);
2213
- ctx.fillStyle = 'rgba(255,0,255,1)'; // clear #FF00FF, no alpha
2214
- ctx.fillRect(0, 0, 1, 1);
2215
- const d = ctx.getImageData(0, 0, 1, 1).data;
2216
- const exact = d[0] === 255 && d[1] === 0 && d[2] === 255 && d[3] === 255;
2217
- return !exact;
2218
- }
2219
- function isBraveBrowser() {
2220
- var _a, _b;
2221
- if (typeof navigator === 'undefined') {
2222
- return false;
2223
- }
2224
- // @ts-ignore
2225
- return (_b = (_a = navigator.brave) === null || _a === void 0 ? void 0 : _a.isBrave()) !== null && _b !== void 0 ? _b : false;
2226
- }
2227
- let warned = false;
2228
- function checkHitCanvasSupport() {
2229
- if (isBraveBrowser() && isCanvasFarblingActive() && !warned) {
2230
- warned = true;
2231
- Util.error('Looks like you have "Brave shield" enabled in your browser. It breaks KonvaJS internals. Please disable it. You may need to ask your users to do the same.');
2232
- }
2233
- return isBraveBrowser() && isCanvasFarblingActive();
2234
- }
2235
2275
  class HitCanvas extends Canvas {
2236
2276
  constructor(config = { width: 0, height: 0 }) {
2237
2277
  super(config);
2238
2278
  this.hitCanvas = true;
2239
2279
  this.context = new HitContext(this);
2240
2280
  this.setSize(config.width, config.height);
2241
- checkHitCanvasSupport();
2242
2281
  }
2243
2282
  }
2244
2283
 
@@ -7159,11 +7198,18 @@ js: import "konva/skia-backend";
7159
7198
  super(config);
7160
7199
  // set colorKey
7161
7200
  let key;
7201
+ let attempts = 0;
7162
7202
  while (true) {
7163
- key = Util.getRandomColor();
7203
+ key = Util.getHitColor();
7164
7204
  if (key && !(key in shapes)) {
7165
7205
  break;
7166
7206
  }
7207
+ attempts++;
7208
+ if (attempts >= 10000) {
7209
+ Util.warn('Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it.');
7210
+ key = Util.getRandomColor();
7211
+ break;
7212
+ }
7167
7213
  }
7168
7214
  this.colorKey = key;
7169
7215
  shapes[key] = this;
@@ -8680,7 +8726,7 @@ js: import "konva/skia-backend";
8680
8726
  });
8681
8727
 
8682
8728
  // constants
8683
- const HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw',
8729
+ const BEFORE_DRAW = 'beforeDraw', DRAW = 'draw',
8684
8730
  /*
8685
8731
  * 2 - 3 - 4
8686
8732
  * | |
@@ -9018,8 +9064,8 @@ js: import "konva/skia-backend";
9018
9064
  const p3 = p[3];
9019
9065
  // fully opaque pixel
9020
9066
  if (p3 === 255) {
9021
- const colorKey = Util._rgbToHex(p[0], p[1], p[2]);
9022
- const shape = shapes[HASH + colorKey];
9067
+ const colorKey = Util.getHitColorKey(p[0], p[1], p[2]);
9068
+ const shape = shapes[colorKey];
9023
9069
  if (shape) {
9024
9070
  return {
9025
9071
  shape: shape,
@@ -13824,8 +13870,8 @@ js: import "konva/skia-backend";
13824
13870
  getSelfRect() {
13825
13871
  const points = this._getPoints();
13826
13872
  let minX = points[0].x;
13827
- let maxX = points[0].y;
13828
- let minY = points[0].x;
13873
+ let maxX = points[0].x;
13874
+ let minY = points[0].y;
13829
13875
  let maxY = points[0].y;
13830
13876
  points.forEach((point) => {
13831
13877
  minX = Math.min(minX, point.x);
@@ -14858,7 +14904,8 @@ js: import "konva/skia-backend";
14858
14904
  context.stroke();
14859
14905
  context.restore();
14860
14906
  }
14861
- // draw line-through above the text content
14907
+ // store the starting x position for line-through which is drawn after text
14908
+ const lineThroughStartX = lineTranslateX;
14862
14909
  // As `letterSpacing` isn't supported on Safari, we use this polyfill.
14863
14910
  // The exception is for RTL text, which we rely on native as it cannot
14864
14911
  // be supported otherwise.
@@ -14920,7 +14967,7 @@ js: import "konva/skia-backend";
14920
14967
  const yOffset = !Konva$2.legacyTextRendering
14921
14968
  ? -Math.round(fontSize / 4)
14922
14969
  : 0;
14923
- const x = align === JUSTIFY ? 0 : lineTranslateX;
14970
+ const x = lineThroughStartX;
14924
14971
  context.moveTo(x, translateY + lineTranslateY + yOffset);
14925
14972
  const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
14926
14973
  context.lineTo(x + Math.round(lineWidth), translateY + lineTranslateY + yOffset);