fabric 6.0.0-beta13 → 6.0.0-beta15

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 (108) hide show
  1. package/.eslintrc.js +9 -0
  2. package/CHANGELOG.md +35 -1
  3. package/CONTRIBUTING.md +9 -9
  4. package/dist/fabric.d.ts +36 -3
  5. package/dist/index.js +218 -324
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.min.js +1 -1
  8. package/dist/index.mjs +214 -323
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/index.node.cjs +218 -324
  11. package/dist/index.node.cjs.map +1 -1
  12. package/dist/index.node.mjs +214 -323
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/src/Intersection.d.ts +8 -0
  15. package/dist/src/canvas/Canvas.d.ts +1 -1
  16. package/dist/src/canvas/CanvasOptions.d.ts +1 -1
  17. package/dist/src/canvas/DOMManagers/CanvasDOMManager.d.ts +1 -1
  18. package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.d.ts +2 -2
  19. package/dist/src/canvas/SelectableCanvas.d.ts +10 -15
  20. package/dist/src/canvas/StaticCanvas.d.ts +2 -2
  21. package/dist/src/controls/Control.d.ts +8 -8
  22. package/dist/src/controls/index.d.ts +1 -1
  23. package/dist/src/controls/polyControl.d.ts +25 -0
  24. package/dist/src/filters/BlendImage.d.ts +4 -4
  25. package/dist/src/shapes/Group.d.ts +5 -1
  26. package/dist/src/shapes/IText/ITextBehavior.d.ts +2 -2
  27. package/dist/src/shapes/Image.d.ts +11 -11
  28. package/dist/src/shapes/Object/InteractiveObject.d.ts +2 -3
  29. package/dist/src/shapes/Object/Object.d.ts +4 -4
  30. package/dist/src/shapes/Object/ObjectGeometry.d.ts +3 -29
  31. package/dist/src/shapes/Object/types/FabricObjectProps.d.ts +1 -1
  32. package/dist/src/shapes/Path.d.ts +1 -1
  33. package/dist/src/shapes/Text/StyledText.d.ts +2 -2
  34. package/dist/src/shapes/Text/Text.d.ts +7 -7
  35. package/dist/src/shapes/Text/TextSVGExportMixin.d.ts +7 -7
  36. package/dist/src/shapes/Text/constants.d.ts +2 -2
  37. package/dist/src/util/animation/AnimationRegistry.d.ts +4 -4
  38. package/dist/src/util/internals/console.d.ts +8 -0
  39. package/dist/src/util/misc/dom.d.ts +1 -1
  40. package/dist/src/util/misc/svgParsing.d.ts +2 -1
  41. package/dist/src/util/typeAssertions.d.ts +2 -2
  42. package/fabric.ts +45 -3
  43. package/jest.extend.ts +3 -1
  44. package/package.json +5 -6
  45. package/playwright.setup.ts +82 -14
  46. package/src/ClassRegistry.ts +3 -1
  47. package/src/Collection.ts +2 -3
  48. package/src/Intersection.spec.ts +74 -0
  49. package/src/Intersection.ts +30 -0
  50. package/src/Pattern/Pattern.ts +2 -1
  51. package/src/benchmarks/README.md +7 -0
  52. package/src/benchmarks/calcCornerCoords.mjs +117 -0
  53. package/src/benchmarks/raycasting.mjs +154 -0
  54. package/src/canvas/Canvas.ts +23 -11
  55. package/src/canvas/CanvasOptions.ts +1 -1
  56. package/src/canvas/DOMManagers/CanvasDOMManager.ts +1 -1
  57. package/src/canvas/DOMManagers/StaticCanvasDOMManager.ts +7 -7
  58. package/src/canvas/SelectableCanvas.ts +30 -43
  59. package/src/canvas/StaticCanvas.ts +9 -7
  60. package/src/canvas/__tests__/SelectableCanvas.spec.ts +60 -0
  61. package/src/canvas/__tests__/__snapshots__/eventData.test.ts.snap +193 -2
  62. package/src/canvas/__tests__/eventData.test.ts +40 -1
  63. package/src/controls/Control.spec.ts +41 -0
  64. package/src/controls/Control.ts +36 -44
  65. package/src/controls/index.ts +1 -1
  66. package/src/controls/polyControl.ts +8 -5
  67. package/src/filters/BaseFilter.ts +8 -6
  68. package/src/filters/BlendImage.ts +4 -4
  69. package/src/filters/GLProbes/WebGLProbe.ts +2 -1
  70. package/src/parser/elements_parser.ts +2 -2
  71. package/src/parser/loadSVGFromString.test.ts +36 -0
  72. package/src/parser/parseSVGDocument.ts +2 -1
  73. package/src/parser/parseUseDirectives.ts +6 -2
  74. package/src/parser/recursivelyParseGradientsXlink.ts +1 -3
  75. package/src/shapes/ActiveSelection.spec.ts +35 -1
  76. package/src/shapes/ActiveSelection.ts +3 -1
  77. package/src/shapes/Group.ts +7 -8
  78. package/src/shapes/IText/IText.test.ts +43 -0
  79. package/src/shapes/IText/IText.ts +1 -1
  80. package/src/shapes/IText/ITextBehavior.ts +2 -2
  81. package/src/shapes/IText/__snapshots__/IText.test.ts.snap +50 -0
  82. package/src/shapes/Image.ts +15 -14
  83. package/src/shapes/Object/FabricObject.spec.ts +16 -0
  84. package/src/shapes/Object/InteractiveObject.spec.ts +43 -0
  85. package/src/shapes/Object/InteractiveObject.ts +20 -30
  86. package/src/shapes/Object/Object.ts +6 -5
  87. package/src/shapes/Object/ObjectGeometry.ts +11 -126
  88. package/src/shapes/Object/types/FabricObjectProps.ts +1 -1
  89. package/src/shapes/Text/StyledText.ts +5 -2
  90. package/src/shapes/Text/Text.spec.ts +9 -9
  91. package/src/shapes/Text/Text.ts +16 -15
  92. package/src/shapes/Text/TextSVGExportMixin.spec.ts +29 -0
  93. package/src/shapes/Text/TextSVGExportMixin.ts +16 -13
  94. package/src/shapes/Text/__snapshots__/Text.spec.ts.snap +6 -6
  95. package/src/shapes/Text/constants.ts +2 -2
  96. package/src/util/animation/AnimationRegistry.ts +7 -6
  97. package/src/util/internals/console.ts +18 -0
  98. package/src/util/internals/dom_request.ts +2 -1
  99. package/src/util/misc/dom.ts +3 -2
  100. package/src/util/misc/objectEnlive.ts +3 -2
  101. package/src/util/misc/planeChange.ts +3 -2
  102. package/src/util/misc/svgParsing.ts +22 -9
  103. package/src/util/transform_matrix_removal.ts +3 -3
  104. package/src/util/typeAssertions.ts +2 -2
  105. package/typedoc.config.json +6 -0
  106. package/typedoc.json +3 -2
  107. package/dist/src/parser/elementById.d.ts +0 -7
  108. package/src/parser/elementById.ts +0 -18
@@ -245,6 +245,26 @@ class NodeGLProbe extends GLProbe {
245
245
  }
246
246
  }
247
247
 
248
+ const log = function (severity) {
249
+ for (var _len = arguments.length, optionalParams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
250
+ optionalParams[_key - 1] = arguments[_key];
251
+ }
252
+ return (
253
+ // eslint-disable-next-line no-restricted-syntax
254
+ console[severity]('fabric', ...optionalParams)
255
+ );
256
+ };
257
+ class FabricError extends Error {
258
+ constructor(message, options) {
259
+ super("fabric: ".concat(message), options);
260
+ }
261
+ }
262
+ class SignalAbortedError extends FabricError {
263
+ constructor(context) {
264
+ super("".concat(context, " 'options.signal' is in 'aborted' state"));
265
+ }
266
+ }
267
+
248
268
  /**
249
269
  * Lazy initialize WebGL constants
250
270
  */
@@ -274,7 +294,7 @@ class WebGLProbe extends GLProbe {
274
294
  if (gl) {
275
295
  this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
276
296
  this.GLPrecision = ['highp', 'mediump', 'lowp'].find(precision => this.testPrecision(gl, precision));
277
- console.log("fabric: max texture size ".concat(this.maxTextureSize));
297
+ log('log', "WebGL: max texture size ".concat(this.maxTextureSize));
278
298
  }
279
299
  }
280
300
  isSupported(textureSize) {
@@ -455,7 +475,7 @@ class Cache {
455
475
  }
456
476
  const cache = new Cache();
457
477
 
458
- var version = "6.0.0-beta13";
478
+ var version = "6.0.0-beta15";
459
479
 
460
480
  // use this syntax so babel plugin see this import here
461
481
  const VERSION = version;
@@ -503,7 +523,7 @@ class ClassRegistry {
503
523
  getClass(classType) {
504
524
  const constructor = this[JSON$1].get(classType);
505
525
  if (!constructor) {
506
- throw new Error("No class registered for ".concat(classType));
526
+ throw new FabricError("No class registered for ".concat(classType));
507
527
  }
508
528
  return constructor;
509
529
  }
@@ -549,8 +569,8 @@ class AnimationRegistry extends Array {
549
569
  }
550
570
 
551
571
  /**
552
- * Cancel all running animations attached to a Canvas on the next frame
553
- * @param {Canvas} canvas
572
+ * Cancel all running animations attached to a canvas on the next frame
573
+ * @param {StaticCanvas} canvas
554
574
  */
555
575
  cancelByCanvas(canvas) {
556
576
  if (!canvas) {
@@ -558,7 +578,7 @@ class AnimationRegistry extends Array {
558
578
  }
559
579
  const animations = this.filter(animation => {
560
580
  var _animation$target;
561
- return typeof animation.target === 'object' && ((_animation$target = animation.target) === null || _animation$target === void 0 ? void 0 : _animation$target.canvas) === canvas;
581
+ return animation.target === canvas || typeof animation.target === 'object' && ((_animation$target = animation.target) === null || _animation$target === void 0 ? void 0 : _animation$target.canvas) === canvas;
562
582
  });
563
583
  animations.forEach(animation => animation.abort());
564
584
  return animations;
@@ -1495,7 +1515,7 @@ function createCollectionMixin(Base) {
1495
1515
  // we iterate reverse order to collect top first in case of click.
1496
1516
  for (let i = this._objects.length - 1; i >= 0; i--) {
1497
1517
  const object = this._objects[i];
1498
- if (object.selectable && object.visible && (includeIntersecting && object.intersectsWithRect(tl, br, true) || object.isContainedWithinRect(tl, br, true) || includeIntersecting && object.containsPoint(tl, undefined, true) || includeIntersecting && object.containsPoint(br, undefined, true))) {
1518
+ if (object.selectable && object.visible && (includeIntersecting && object.intersectsWithRect(tl, br, true) || object.isContainedWithinRect(tl, br, true) || includeIntersecting && object.containsPoint(tl, true) || includeIntersecting && object.containsPoint(br, true))) {
1499
1519
  objects.push(object);
1500
1520
  }
1501
1521
  }
@@ -1585,7 +1605,7 @@ const uid = () => id++;
1585
1605
  const createCanvasElement = () => {
1586
1606
  const element = getFabricDocument().createElement('canvas');
1587
1607
  if (!element || typeof element.getContext === 'undefined') {
1588
- throw new Error('Failed to create `canvas` element');
1608
+ throw new FabricError('Failed to create `canvas` element');
1589
1609
  }
1590
1610
  return element;
1591
1611
  };
@@ -1873,7 +1893,7 @@ const loadImage = function (url) {
1873
1893
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1874
1894
  return new Promise(function (resolve, reject) {
1875
1895
  if (signal && signal.aborted) {
1876
- return reject(new Error('`options.signal` is in `aborted` state'));
1896
+ return reject(new SignalAbortedError('loadImage'));
1877
1897
  }
1878
1898
  const img = createImage();
1879
1899
  let abort;
@@ -1898,7 +1918,7 @@ const loadImage = function (url) {
1898
1918
  img.onload = done;
1899
1919
  img.onerror = function () {
1900
1920
  abort && (signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort));
1901
- reject(new Error('Error loading ' + img.src));
1921
+ reject(new FabricError("Error loading ".concat(img.src)));
1902
1922
  };
1903
1923
  crossOrigin && (img.crossOrigin = crossOrigin);
1904
1924
  img.src = url;
@@ -2756,22 +2776,29 @@ const matrixToSVG = transform => 'matrix(' + transform.map(value => toFixed(valu
2756
2776
  * we work around it by "moving" alpha channel into opacity attribute and setting fill's alpha to 1
2757
2777
  * @param prop
2758
2778
  * @param value
2779
+ * @param {boolean} inlineStyle The default is inline style, the separator used is ":", The other is "="
2759
2780
  * @returns
2760
2781
  */
2761
- const colorPropToSVG = (prop, value) => {
2782
+ const colorPropToSVG = function (prop, value) {
2783
+ let inlineStyle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
2784
+ let colorValue;
2785
+ let opacityValue;
2762
2786
  if (!value) {
2763
- return "".concat(prop, ": none; ");
2787
+ colorValue = 'none';
2764
2788
  } else if (value.toLive) {
2765
- return "".concat(prop, ": url(#SVGID_").concat(value.id, "); ");
2789
+ colorValue = "url(#SVGID_".concat(value.id, ")");
2766
2790
  } else {
2767
2791
  const color = new Color(value),
2768
2792
  opacity = color.getAlpha();
2769
- let str = "".concat(prop, ": ").concat(color.toRgb(), "; ");
2793
+ colorValue = color.toRgb();
2770
2794
  if (opacity !== 1) {
2771
- //change the color in rgb + opacity
2772
- str += "".concat(prop, "-opacity: ").concat(opacity.toString(), "; ");
2795
+ opacityValue = opacity.toString();
2773
2796
  }
2774
- return str;
2797
+ }
2798
+ if (inlineStyle) {
2799
+ return "".concat(prop, ": ").concat(colorValue, "; ").concat(opacityValue ? "".concat(prop, "-opacity: ").concat(opacityValue, "; ") : '');
2800
+ } else {
2801
+ return "".concat(prop, "=\"").concat(colorValue, "\" ").concat(opacityValue ? "".concat(prop, "-opacity=\"").concat(opacityValue, "\" ") : '');
2775
2802
  }
2776
2803
  };
2777
2804
  const createSVGRect = function (color, _ref) {
@@ -2782,7 +2809,7 @@ const createSVGRect = function (color, _ref) {
2782
2809
  height
2783
2810
  } = _ref;
2784
2811
  let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : config.NUM_FRACTION_DIGITS;
2785
- const svgColor = colorPropToSVG('fill', color);
2812
+ const svgColor = colorPropToSVG('fill', color, false);
2786
2813
  const [x, y, w, h] = [left, top, width, height].map(value => toFixed(value, precision));
2787
2814
  return "<rect ".concat(svgColor, " x=\"").concat(x, "\" y=\"").concat(y, "\" width=\"").concat(w, "\" height=\"").concat(h, "\"></rect>");
2788
2815
  };
@@ -2994,13 +3021,10 @@ class StaticCanvasDOMManager {
2994
3021
  }
2995
3022
  createLowerCanvas(arg0) {
2996
3023
  // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node
2997
- const el = isHTMLCanvas(arg0) ? arg0 : getFabricDocument().getElementById(arg0) || createCanvasElement();
3024
+ const el = isHTMLCanvas(arg0) ? arg0 : arg0 && getFabricDocument().getElementById(arg0) || createCanvasElement();
2998
3025
  if (el.hasAttribute('data-fabric')) {
2999
- /* _DEV_MODE_START_ */
3000
- throw new Error('fabric.js: trying to initialize a canvas that has already been initialized');
3001
- /* _DEV_MODE_END_ */
3026
+ throw new FabricError('Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?');
3002
3027
  }
3003
-
3004
3028
  this._originalCanvasStyle = el.style.cssText;
3005
3029
  el.setAttribute('data-fabric', 'main');
3006
3030
  el.classList.add('lower-canvas');
@@ -3169,9 +3193,7 @@ let StaticCanvas$1 = class StaticCanvas extends createCollectionMixin(CommonMeth
3169
3193
  }
3170
3194
  _onObjectAdded(obj) {
3171
3195
  if (obj.canvas && obj.canvas !== this) {
3172
- /* _DEV_MODE_START_ */
3173
- console.warn('fabric.Canvas: trying to add an object that belongs to a different canvas.\n' + 'Resulting to default behavior: removing object from previous canvas and adding to new canvas');
3174
- /* _DEV_MODE_END_ */
3196
+ log('warn', 'Canvas is trying to add an object that belongs to a different canvas.\n' + 'Resulting to default behavior: removing object from previous canvas and adding to new canvas');
3175
3197
  obj.canvas.remove(obj);
3176
3198
  }
3177
3199
  obj._set('canvas', this);
@@ -4101,7 +4123,7 @@ let StaticCanvas$1 = class StaticCanvas extends createCollectionMixin(CommonMeth
4101
4123
  signal
4102
4124
  } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4103
4125
  if (!json) {
4104
- return Promise.reject(new Error('fabric.js: `json` is undefined'));
4126
+ return Promise.reject(new FabricError('`json` is undefined'));
4105
4127
  }
4106
4128
 
4107
4129
  // parse json if it wasn't already
@@ -4271,6 +4293,7 @@ let StaticCanvas$1 = class StaticCanvas extends createCollectionMixin(CommonMeth
4271
4293
  width: this.width,
4272
4294
  height: this.height
4273
4295
  });
4296
+ runningAnimations.cancelByCanvas(this);
4274
4297
  this.disposed = true;
4275
4298
  return new Promise((resolve, reject) => {
4276
4299
  const task = () => {
@@ -4557,10 +4580,10 @@ const sendPointToPlane = function (point) {
4557
4580
  const transformPointRelativeToCanvas = (point, canvas, relationBefore, relationAfter) => {
4558
4581
  // is this still needed with TS?
4559
4582
  if (relationBefore !== 'child' && relationBefore !== 'sibling') {
4560
- throw new Error("fabric.js: received bad argument ".concat(relationBefore));
4583
+ throw new FabricError("received bad argument ".concat(relationBefore));
4561
4584
  }
4562
4585
  if (relationAfter !== 'child' && relationAfter !== 'sibling') {
4563
- throw new Error("fabric.js: received bad argument ".concat(relationAfter));
4586
+ throw new FabricError("received bad argument ".concat(relationAfter));
4564
4587
  }
4565
4588
  if (relationBefore === relationAfter) {
4566
4589
  return point;
@@ -5667,6 +5690,31 @@ class Intersection {
5667
5690
  }
5668
5691
  }
5669
5692
 
5693
+ /**
5694
+ * Use the ray casting algorithm to determine if {@link point} is in the polygon defined by {@link points}
5695
+ * @see https://en.wikipedia.org/wiki/Point_in_polygon
5696
+ * @param point
5697
+ * @param points polygon points
5698
+ * @returns
5699
+ */
5700
+ static isPointInPolygon(point, points) {
5701
+ const other = new Point(point).setX(Math.min(point.x - 1, ...points.map(p => p.x)));
5702
+ let hits = 0;
5703
+ for (let index = 0; index < points.length; index++) {
5704
+ const inter = this.intersectSegmentSegment(
5705
+ // polygon side
5706
+ points[index], points[(index + 1) % points.length],
5707
+ // ray
5708
+ point, other);
5709
+ if (inter.includes(point)) {
5710
+ // point is on the polygon side
5711
+ return true;
5712
+ }
5713
+ hits += Number(inter.status === 'Intersection');
5714
+ }
5715
+ return hits % 2 === 1;
5716
+ }
5717
+
5670
5718
  /**
5671
5719
  * Checks if a line intersects another
5672
5720
  * @see {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection line intersection}
@@ -6203,21 +6251,15 @@ class ObjectGeometry extends ObjectOrigin {
6203
6251
  * Checks if object is fully contained within area of another object
6204
6252
  * @param {Object} other Object to test
6205
6253
  * @param {Boolean} [absolute] use coordinates without viewportTransform
6206
- * @param {Boolean} [calculate] use coordinates of current position instead of store ones
6254
+ * @param {Boolean} [calculate] use coordinates of current position instead of stored ones
6207
6255
  * @return {Boolean} true if object is fully contained within area of another object
6208
6256
  */
6209
6257
  isContainedWithinObject(other) {
6210
6258
  let absolute = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6211
6259
  let calculate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
6212
- const points = this.getCoords(absolute, calculate),
6213
- otherCoords = absolute ? other.aCoords : other.lineCoords,
6214
- lines = other._getImageLines(otherCoords);
6215
- for (let i = 0; i < 4; i++) {
6216
- if (!other.containsPoint(points[i], lines)) {
6217
- return false;
6218
- }
6219
- }
6220
- return true;
6260
+ const points = this.getCoords(absolute, calculate);
6261
+ calculate && other.getCoords(absolute, true);
6262
+ return points.every(point => other.containsPoint(point));
6221
6263
  }
6222
6264
 
6223
6265
  /**
@@ -6239,19 +6281,14 @@ class ObjectGeometry extends ObjectOrigin {
6239
6281
  /**
6240
6282
  * Checks if point is inside the object
6241
6283
  * @param {Point} point Point to check against
6242
- * @param {Object} [lines] object returned from @method _getImageLines
6243
6284
  * @param {Boolean} [absolute] use coordinates without viewportTransform
6244
6285
  * @param {Boolean} [calculate] use coordinates of current position instead of stored ones
6245
6286
  * @return {Boolean} true if point is inside the object
6246
6287
  */
6247
- containsPoint(point, lines) {
6248
- let absolute = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
6249
- let calculate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
6250
- const coords = this._getCoords(absolute, calculate),
6251
- imageLines = lines || this._getImageLines(coords),
6252
- xPoints = this._findCrossPoints(point, imageLines);
6253
- // if xPoints is odd then point is inside the object
6254
- return xPoints !== 0 && xPoints % 2 === 1;
6288
+ containsPoint(point) {
6289
+ let absolute = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6290
+ let calculate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
6291
+ return Intersection.isPointInPolygon(point, this.getCoords(absolute, calculate));
6255
6292
  }
6256
6293
 
6257
6294
  /**
@@ -6293,7 +6330,7 @@ class ObjectGeometry extends ObjectOrigin {
6293
6330
  _containsCenterOfCanvas(pointTL, pointBR, calculate) {
6294
6331
  // worst case scenario the object is so big that contains the screen
6295
6332
  const centerPoint = pointTL.midPointFrom(pointBR);
6296
- return this.containsPoint(centerPoint, undefined, true, calculate);
6333
+ return this.containsPoint(centerPoint, true, calculate);
6297
6334
  }
6298
6335
 
6299
6336
  /**
@@ -6316,100 +6353,6 @@ class ObjectGeometry extends ObjectOrigin {
6316
6353
  return allPointsAreOutside && this._containsCenterOfCanvas(tl, br, calculate);
6317
6354
  }
6318
6355
 
6319
- /**
6320
- * Method that returns an object with the object edges in it, given the coordinates of the corners
6321
- * @private
6322
- * @param {Object} lineCoords or aCoords Coordinates of the object corners
6323
- */
6324
- _getImageLines(_ref) {
6325
- let {
6326
- tl,
6327
- tr,
6328
- bl,
6329
- br
6330
- } = _ref;
6331
- const lines = {
6332
- topline: {
6333
- o: tl,
6334
- d: tr
6335
- },
6336
- rightline: {
6337
- o: tr,
6338
- d: br
6339
- },
6340
- bottomline: {
6341
- o: br,
6342
- d: bl
6343
- },
6344
- leftline: {
6345
- o: bl,
6346
- d: tl
6347
- }
6348
- };
6349
-
6350
- // // debugging
6351
- // if (this.canvas.contextTop) {
6352
- // this.canvas.contextTop.fillRect(lines.bottomline.d.x, lines.bottomline.d.y, 2, 2);
6353
- // this.canvas.contextTop.fillRect(lines.bottomline.o.x, lines.bottomline.o.y, 2, 2);
6354
- //
6355
- // this.canvas.contextTop.fillRect(lines.leftline.d.x, lines.leftline.d.y, 2, 2);
6356
- // this.canvas.contextTop.fillRect(lines.leftline.o.x, lines.leftline.o.y, 2, 2);
6357
- //
6358
- // this.canvas.contextTop.fillRect(lines.topline.d.x, lines.topline.d.y, 2, 2);
6359
- // this.canvas.contextTop.fillRect(lines.topline.o.x, lines.topline.o.y, 2, 2);
6360
- //
6361
- // this.canvas.contextTop.fillRect(lines.rightline.d.x, lines.rightline.d.y, 2, 2);
6362
- // this.canvas.contextTop.fillRect(lines.rightline.o.x, lines.rightline.o.y, 2, 2);
6363
- // }
6364
-
6365
- return lines;
6366
- }
6367
-
6368
- /**
6369
- * Helper method to determine how many cross points are between the 4 object edges
6370
- * and the horizontal line determined by a point on canvas
6371
- * @private
6372
- * @param {Point} point Point to check
6373
- * @param {Object} lines Coordinates of the object being evaluated
6374
- * @return {number} number of crossPoint
6375
- */
6376
- _findCrossPoints(point, lines) {
6377
- let xcount = 0;
6378
- for (const lineKey in lines) {
6379
- let xi;
6380
- const iLine = lines[lineKey];
6381
- // optimization 1: line below point. no cross
6382
- if (iLine.o.y < point.y && iLine.d.y < point.y) {
6383
- continue;
6384
- }
6385
- // optimization 2: line above point. no cross
6386
- if (iLine.o.y >= point.y && iLine.d.y >= point.y) {
6387
- continue;
6388
- }
6389
- // optimization 3: vertical line case
6390
- if (iLine.o.x === iLine.d.x && iLine.o.x >= point.x) {
6391
- xi = iLine.o.x;
6392
- }
6393
- // calculate the intersection point
6394
- else {
6395
- const b1 = 0;
6396
- const b2 = (iLine.d.y - iLine.o.y) / (iLine.d.x - iLine.o.x);
6397
- const a1 = point.y - b1 * point.x;
6398
- const a2 = iLine.o.y - b2 * iLine.o.x;
6399
- xi = -(a1 - a2) / (b1 - b2);
6400
- }
6401
- // don't count xi < point.x cases
6402
- if (xi >= point.x) {
6403
- xcount += 1;
6404
- }
6405
- // optimization 4: specific for square images
6406
- if (xcount === 2) {
6407
- break;
6408
- }
6409
- }
6410
- return xcount;
6411
- }
6412
-
6413
6356
  /**
6414
6357
  * Returns coordinates of object's bounding rectangle (left, top, width, height)
6415
6358
  * the box is intended as aligned to axis of canvas.
@@ -7175,7 +7118,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7175
7118
  return name.toLowerCase();
7176
7119
  }
7177
7120
  set type(value) {
7178
- console.warn('Setting type has no effect', value);
7121
+ log('warn', 'Setting type has no effect', value);
7179
7122
  }
7180
7123
 
7181
7124
  /**
@@ -8095,7 +8038,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
8095
8038
  * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4
8096
8039
  * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4
8097
8040
  * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2
8098
- * @return {Image} Object cloned as image.
8041
+ * @return {FabricImage} Object cloned as image.
8099
8042
  */
8100
8043
  cloneAsImage(options) {
8101
8044
  const canvasEl = this.toCanvasElement(options);
@@ -8592,28 +8535,28 @@ class Control {
8592
8535
  * @type {?Number}
8593
8536
  * @default null
8594
8537
  */
8595
- _defineProperty(this, "sizeX", null);
8538
+ _defineProperty(this, "sizeX", 0);
8596
8539
  /**
8597
8540
  * Sets the height of the control. If null, defaults to object's cornerSize.
8598
8541
  * Expects both sizeX and sizeY to be set when set.
8599
8542
  * @type {?Number}
8600
8543
  * @default null
8601
8544
  */
8602
- _defineProperty(this, "sizeY", null);
8545
+ _defineProperty(this, "sizeY", 0);
8603
8546
  /**
8604
8547
  * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.
8605
8548
  * Expects both touchSizeX and touchSizeY to be set when set.
8606
8549
  * @type {?Number}
8607
8550
  * @default null
8608
8551
  */
8609
- _defineProperty(this, "touchSizeX", null);
8552
+ _defineProperty(this, "touchSizeX", 0);
8610
8553
  /**
8611
8554
  * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.
8612
8555
  * Expects both touchSizeX and touchSizeY to be set when set.
8613
8556
  * @type {?Number}
8614
8557
  * @default null
8615
8558
  */
8616
- _defineProperty(this, "touchSizeY", null);
8559
+ _defineProperty(this, "touchSizeY", 0);
8617
8560
  /**
8618
8561
  * Css cursor style to display when the control is hovered.
8619
8562
  * if the method `cursorStyleHandler` is provided, this property is ignored.
@@ -8658,10 +8601,16 @@ class Control {
8658
8601
  * @return {Boolean} true if the action/event modified the object
8659
8602
  */
8660
8603
 
8661
- shouldActivate(controlKey, fabricObject) {
8604
+ shouldActivate(controlKey, fabricObject, pointer, _ref) {
8662
8605
  var _fabricObject$canvas;
8606
+ let {
8607
+ tl,
8608
+ tr,
8609
+ br,
8610
+ bl
8611
+ } = _ref;
8663
8612
  // TODO: locking logic can be handled here instead of in the control handler logic
8664
- return ((_fabricObject$canvas = fabricObject.canvas) === null || _fabricObject$canvas === void 0 ? void 0 : _fabricObject$canvas.getActiveObject()) === fabricObject && fabricObject.isControlVisible(controlKey);
8613
+ return ((_fabricObject$canvas = fabricObject.canvas) === null || _fabricObject$canvas === void 0 ? void 0 : _fabricObject$canvas.getActiveObject()) === fabricObject && fabricObject.isControlVisible(controlKey) && Intersection.isPointInPolygon(pointer, [tl, tr, br, bl]);
8665
8614
  }
8666
8615
 
8667
8616
  /**
@@ -8754,36 +8703,15 @@ class Control {
8754
8703
  * @param {Number} centerY y coordinate where the control center should be
8755
8704
  * @param {boolean} isTouch true if touch corner, false if normal corner
8756
8705
  */
8757
- calcCornerCoords(objectAngle, objectCornerSize, centerX, centerY, isTouch) {
8758
- let cosHalfOffset, sinHalfOffset, cosHalfOffsetComp, sinHalfOffsetComp;
8759
- const xSize = isTouch ? this.touchSizeX : this.sizeX,
8760
- ySize = isTouch ? this.touchSizeY : this.sizeY;
8761
- if (xSize && ySize && xSize !== ySize) {
8762
- // handle rectangular corners
8763
- const controlTriangleAngle = Math.atan2(ySize, xSize);
8764
- const cornerHypotenuse = Math.sqrt(xSize * xSize + ySize * ySize) / 2;
8765
- const newTheta = controlTriangleAngle - degreesToRadians(objectAngle);
8766
- const newThetaComp = halfPI - controlTriangleAngle - degreesToRadians(objectAngle);
8767
- cosHalfOffset = cornerHypotenuse * cos(newTheta);
8768
- sinHalfOffset = cornerHypotenuse * sin(newTheta);
8769
- // use complementary angle for two corners
8770
- cosHalfOffsetComp = cornerHypotenuse * cos(newThetaComp);
8771
- sinHalfOffsetComp = cornerHypotenuse * sin(newThetaComp);
8772
- } else {
8773
- // handle square corners
8774
- // use default object corner size unless size is defined
8775
- const cornerSize = xSize && ySize ? xSize : objectCornerSize;
8776
- const cornerHypotenuse = cornerSize * Math.SQRT1_2;
8777
- // complementary angles are equal since they're both 45 degrees
8778
- const newTheta = degreesToRadians(45 - objectAngle);
8779
- cosHalfOffset = cosHalfOffsetComp = cornerHypotenuse * cos(newTheta);
8780
- sinHalfOffset = sinHalfOffsetComp = cornerHypotenuse * sin(newTheta);
8781
- }
8706
+ calcCornerCoords(angle, objectCornerSize, centerX, centerY, isTouch, fabricObject) {
8707
+ const t = multiplyTransformMatrixArray([createTranslateMatrix(centerX, centerY), createRotateMatrix({
8708
+ angle
8709
+ }), createScaleMatrix((isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize, (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize)]);
8782
8710
  return {
8783
- tl: new Point(centerX - sinHalfOffsetComp, centerY - cosHalfOffsetComp),
8784
- tr: new Point(centerX + cosHalfOffset, centerY - sinHalfOffset),
8785
- bl: new Point(centerX - cosHalfOffset, centerY + sinHalfOffset),
8786
- br: new Point(centerX + sinHalfOffsetComp, centerY + cosHalfOffsetComp)
8711
+ tl: new Point(-0.5, -0.5).transform(t),
8712
+ tr: new Point(0.5, -0.5).transform(t),
8713
+ bl: new Point(-0.5, 0.5).transform(t),
8714
+ br: new Point(0.5, 0.5).transform(t)
8787
8715
  };
8788
8716
  }
8789
8717
 
@@ -9425,34 +9353,14 @@ class InteractiveFabricObject extends FabricObject$1 {
9425
9353
  return '';
9426
9354
  }
9427
9355
  this.__corner = undefined;
9428
- // had to keep the reverse loop because was breaking tests
9429
9356
  const cornerEntries = Object.entries(this.oCoords);
9430
9357
  for (let i = cornerEntries.length - 1; i >= 0; i--) {
9431
9358
  const [key, corner] = cornerEntries[i];
9432
- if (this.controls[key].shouldActivate(key, this)) {
9433
- const lines = this._getImageLines(forTouch ? corner.touchCorner : corner.corner);
9434
- const xPoints = this._findCrossPoints(pointer, lines);
9435
- if (xPoints !== 0 && xPoints % 2 === 1) {
9436
- this.__corner = key;
9437
- return key;
9438
- }
9359
+ if (this.controls[key].shouldActivate(key, this, pointer, forTouch ? corner.touchCorner : corner.corner)) {
9360
+ // this.canvas.contextTop.fillRect(pointer.x - 1, pointer.y - 1, 2, 2);
9361
+ return this.__corner = key;
9439
9362
  }
9440
-
9441
- // // debugging
9442
- //
9443
- // this.canvas.contextTop.fillRect(lines.bottomline.d.x, lines.bottomline.d.y, 2, 2);
9444
- // this.canvas.contextTop.fillRect(lines.bottomline.o.x, lines.bottomline.o.y, 2, 2);
9445
- //
9446
- // this.canvas.contextTop.fillRect(lines.leftline.d.x, lines.leftline.d.y, 2, 2);
9447
- // this.canvas.contextTop.fillRect(lines.leftline.o.x, lines.leftline.o.y, 2, 2);
9448
- //
9449
- // this.canvas.contextTop.fillRect(lines.topline.d.x, lines.topline.d.y, 2, 2);
9450
- // this.canvas.contextTop.fillRect(lines.topline.o.x, lines.topline.o.y, 2, 2);
9451
- //
9452
- // this.canvas.contextTop.fillRect(lines.rightline.d.x, lines.rightline.d.y, 2, 2);
9453
- // this.canvas.contextTop.fillRect(lines.rightline.o.x, lines.rightline.o.y, 2, 2);
9454
9363
  }
9455
-
9456
9364
  return '';
9457
9365
  }
9458
9366
 
@@ -9508,8 +9416,9 @@ class InteractiveFabricObject extends FabricObject$1 {
9508
9416
  * @private
9509
9417
  */
9510
9418
  _calcCornerCoords(control, position) {
9511
- const corner = control.calcCornerCoords(this.angle, this.cornerSize, position.x, position.y, false);
9512
- const touchCorner = control.calcCornerCoords(this.angle, this.touchCornerSize, position.x, position.y, true);
9419
+ const angle = this.getTotalAngle();
9420
+ const corner = control.calcCornerCoords(angle, this.cornerSize, position.x, position.y, false, this);
9421
+ const touchCorner = control.calcCornerCoords(angle, this.touchCornerSize, position.x, position.y, true, this);
9513
9422
  return {
9514
9423
  corner,
9515
9424
  touchCorner
@@ -9527,7 +9436,7 @@ class InteractiveFabricObject extends FabricObject$1 {
9527
9436
  setCoords() {
9528
9437
  super.setCoords();
9529
9438
  // set coordinates of the draggable boxes in the corners used to scale/rotate the image
9530
- this.oCoords = this.calcOCoords();
9439
+ this.canvas && (this.oCoords = this.calcOCoords());
9531
9440
  }
9532
9441
 
9533
9442
  /**
@@ -10609,15 +10518,11 @@ class Group extends createCollectionMixin(FabricObject) {
10609
10518
  canEnterGroup(object) {
10610
10519
  if (object === this || this.isDescendantOf(object)) {
10611
10520
  // prevent circular object tree
10612
- /* _DEV_MODE_START_ */
10613
- console.error('fabric.Group: circular object trees are not supported, this call has no effect');
10614
- /* _DEV_MODE_END_ */
10521
+ log('error', 'Group: circular object trees are not supported, this call has no effect');
10615
10522
  return false;
10616
10523
  } else if (this._objects.indexOf(object) !== -1) {
10617
10524
  // is already in the objects array
10618
- /* _DEV_MODE_START_ */
10619
- console.error('fabric.Group: duplicate objects are not supported inside group, this call has no effect');
10620
- /* _DEV_MODE_END_ */
10525
+ log('error', 'Group: duplicate objects are not supported inside group, this call has no effect');
10621
10526
  return false;
10622
10527
  }
10623
10528
  return true;
@@ -11470,7 +11375,9 @@ class ActiveSelection extends Group {
11470
11375
  // save ref to group for later in order to return to it
11471
11376
  const parent = object.group;
11472
11377
  parent._exitGroup(object);
11473
- object.__owningGroup = parent;
11378
+ // make sure we are setting the correct owning group
11379
+ // in case `object` is transferred between active selections
11380
+ !(parent instanceof ActiveSelection) && (object.__owningGroup = parent);
11474
11381
  }
11475
11382
  this._enterGroup(object, removeParentTransform);
11476
11383
  return true;
@@ -13122,7 +13029,7 @@ function request(url) {
13122
13029
  xhr.onerror = xhr.ontimeout = noop;
13123
13030
  };
13124
13031
  if (signal && signal.aborted) {
13125
- throw new Error('`options.signal` is in `aborted` state');
13032
+ throw new SignalAbortedError('request');
13126
13033
  } else if (signal) {
13127
13034
  signal.addEventListener('abort', abort, {
13128
13035
  once: true
@@ -13569,9 +13476,9 @@ class SelectableCanvas extends StaticCanvas$1 {
13569
13476
  * @type FabricObject[]
13570
13477
  * @private
13571
13478
  */
13572
- _defineProperty(this, "_objectsToRender", []);
13479
+ _defineProperty(this, "_objectsToRender", void 0);
13573
13480
  /**
13574
- * hold a referenfce to a data structure that contains information
13481
+ * hold a reference to a data structure that contains information
13575
13482
  * on the current on going transform
13576
13483
  * @type
13577
13484
  * @private
@@ -13639,6 +13546,10 @@ class SelectableCanvas extends StaticCanvas$1 {
13639
13546
  }
13640
13547
  super._onObjectRemoved(obj);
13641
13548
  }
13549
+ _onStackOrderChanged() {
13550
+ this._objectsToRender = undefined;
13551
+ super._onStackOrderChanged();
13552
+ }
13642
13553
 
13643
13554
  /**
13644
13555
  * Divides objects in two groups, one to render immediately
@@ -13702,15 +13613,6 @@ class SelectableCanvas extends StaticCanvas$1 {
13702
13613
  });
13703
13614
  }
13704
13615
 
13705
- /**
13706
- * Given a pointer on the canvas with a viewport applied,
13707
- * find out the pointer in object coordinates
13708
- * @private
13709
- */
13710
- _normalizePointer(object, pointer) {
13711
- return transformPoint(this.restorePointerVpt(pointer), invertTransform(object.calcTransformMatrix()));
13712
- }
13713
-
13714
13616
  /**
13715
13617
  * Set the canvas tolerance value for pixel taret find.
13716
13618
  * Use only integer numbers.
@@ -13731,8 +13633,8 @@ class SelectableCanvas extends StaticCanvas$1 {
13731
13633
  * @TODO this seems dumb that we treat controls with transparency. we can find controls
13732
13634
  * programmatically without painting them, the cache canvas optimization is always valid
13733
13635
  * @param {FabricObject} target Object to check
13734
- * @param {Number} x Left coordinate
13735
- * @param {Number} y Top coordinate
13636
+ * @param {Number} x Left coordinate in viewport space
13637
+ * @param {Number} y Top coordinate in viewport space
13736
13638
  * @return {Boolean}
13737
13639
  */
13738
13640
  isTargetTransparent(target, x, y) {
@@ -13842,6 +13744,7 @@ class SelectableCanvas extends StaticCanvas$1 {
13842
13744
  * @param {FaricObject} target
13843
13745
  */
13844
13746
  _setupCurrentTransform(e, target, alreadySelected) {
13747
+ var _control$getActionHan;
13845
13748
  if (!target) {
13846
13749
  return;
13847
13750
  }
@@ -13850,7 +13753,7 @@ class SelectableCanvas extends StaticCanvas$1 {
13850
13753
  sendPointToPlane(this.getPointer(e), undefined, target.group.calcTransformMatrix()) : this.getPointer(e);
13851
13754
  const corner = target.getActiveControl() || '',
13852
13755
  control = !!corner && target.controls[corner],
13853
- actionHandler = alreadySelected && control ? control.getActionHandler(e, target, control) : dragHandler,
13756
+ actionHandler = alreadySelected && control ? (_control$getActionHan = control.getActionHandler(e, target, control)) === null || _control$getActionHan === void 0 ? void 0 : _control$getActionHan.bind(control) : dragHandler,
13854
13757
  action = getActionFromCorner(alreadySelected, corner, e, target),
13855
13758
  origin = this._getOriginFromCorner(target, corner),
13856
13759
  altKey = e[this.centeredKey],
@@ -13988,19 +13891,15 @@ class SelectableCanvas extends StaticCanvas$1 {
13988
13891
 
13989
13892
  /**
13990
13893
  * Checks point is inside the object.
13991
- * @param {Object} [pointer] x,y object of point coordinates we want to check.
13992
13894
  * @param {FabricObject} obj Object to test against
13993
- * @param {Object} [globalPointer] x,y object of point coordinates relative to canvas used to search per pixel target.
13895
+ * @param {Object} [pointer] point from viewport.
13994
13896
  * @return {Boolean} true if point is contained within an area of given object
13995
13897
  * @private
13996
13898
  */
13997
- _checkTarget(pointer, obj, globalPointer) {
13998
- if (obj && obj.visible && obj.evented &&
13999
- // http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html
14000
- // http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html
14001
- obj.containsPoint(pointer)) {
13899
+ _checkTarget(obj, pointer) {
13900
+ if (obj && obj.visible && obj.evented && obj.containsPoint(this.restorePointerVpt(pointer), true)) {
14002
13901
  if ((this.perPixelTargetFind || obj.perPixelTargetFind) && !obj.isEditing) {
14003
- if (!this.isTargetTransparent(obj, globalPointer.x, globalPointer.y)) {
13902
+ if (!this.isTargetTransparent(obj, pointer.x, pointer.y)) {
14004
13903
  return true;
14005
13904
  }
14006
13905
  } else {
@@ -14019,23 +13918,19 @@ class SelectableCanvas extends StaticCanvas$1 {
14019
13918
  */
14020
13919
  _searchPossibleTargets(objects, pointer) {
14021
13920
  // Cache all targets where their bounding box contains point.
14022
- let target,
14023
- i = objects.length;
13921
+ let i = objects.length;
14024
13922
  // Do not check for currently grouped objects, since we check the parent group itself.
14025
13923
  // until we call this function specifically to search inside the activeGroup
14026
13924
  while (i--) {
14027
- const objToCheck = objects[i];
14028
- const pointerToUse = objToCheck.group ? this._normalizePointer(objToCheck.group, pointer) : pointer;
14029
- if (this._checkTarget(pointerToUse, objToCheck, pointer)) {
14030
- target = objects[i];
13925
+ const target = objects[i];
13926
+ if (this._checkTarget(target, pointer)) {
14031
13927
  if (isCollection(target) && target.subTargetCheck) {
14032
13928
  const subTarget = this._searchPossibleTargets(target._objects, pointer);
14033
13929
  subTarget && this.targets.push(subTarget);
14034
13930
  }
14035
- break;
13931
+ return target;
14036
13932
  }
14037
13933
  }
14038
- return target;
14039
13934
  }
14040
13935
 
14041
13936
  /**
@@ -14055,6 +13950,7 @@ class SelectableCanvas extends StaticCanvas$1 {
14055
13950
 
14056
13951
  /**
14057
13952
  * Returns pointer coordinates without the effect of the viewport
13953
+ * Takes a point in html canvas space and gives you back a point of the scene.
14058
13954
  * @param {Object} pointer with "x" and "y" number values in canvas HTML coordinates
14059
13955
  * @return {Object} object with "x" and "y" number values in fabricCanvas coordinates
14060
13956
  */
@@ -14286,6 +14182,11 @@ class SelectableCanvas extends StaticCanvas$1 {
14286
14182
  return false;
14287
14183
  }
14288
14184
  this._activeObject = object;
14185
+ if (object instanceof ActiveSelection && this._activeSelection !== object) {
14186
+ this._activeSelection = object;
14187
+ object.set('canvas', this);
14188
+ object.setCoords();
14189
+ }
14289
14190
  return true;
14290
14191
  }
14291
14192
 
@@ -15185,7 +15086,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15185
15086
  const mouseUpHandler = control && control.getMouseUpHandler(e, target, control);
15186
15087
  if (mouseUpHandler) {
15187
15088
  pointer = this.getPointer(e);
15188
- mouseUpHandler(e, transform, pointer.x, pointer.y);
15089
+ mouseUpHandler.call(control, e, transform, pointer.x, pointer.y);
15189
15090
  }
15190
15091
  }
15191
15092
  target.isMoving = false;
@@ -15196,7 +15097,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15196
15097
  const originalControl = transform.target && transform.target.controls[transform.corner],
15197
15098
  originalMouseUpHandler = originalControl && originalControl.getMouseUpHandler(e, transform.target, originalControl);
15198
15099
  pointer = pointer || this.getPointer(e);
15199
- originalMouseUpHandler && originalMouseUpHandler(e, transform, pointer.x, pointer.y);
15100
+ originalMouseUpHandler && originalMouseUpHandler.call(originalControl, e, transform, pointer.x, pointer.y);
15200
15101
  }
15201
15102
  this._setCursorFromEvent(e, target);
15202
15103
  this._handleEvent(e, 'up', LEFT_CLICK, isClick);
@@ -15218,7 +15119,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15218
15119
  this.fire(eventType, options);
15219
15120
  target && target.fire(eventType, options);
15220
15121
  for (let i = 0; i < subTargets.length; i++) {
15221
- subTargets[i].fire(eventType, options);
15122
+ subTargets[i] !== target && subTargets[i].fire(eventType, options);
15222
15123
  }
15223
15124
  return options;
15224
15125
  }
@@ -15255,7 +15156,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15255
15156
  // this may be a little be more complicated of what we want to handle
15256
15157
  target && target.fire("mouse".concat(eventType), options);
15257
15158
  for (let i = 0; i < targets.length; i++) {
15258
- targets[i].fire("mouse".concat(eventType), options);
15159
+ targets[i] !== target && targets[i].fire("mouse".concat(eventType), options);
15259
15160
  }
15260
15161
  }
15261
15162
 
@@ -15427,7 +15328,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15427
15328
  pointer = this.getPointer(e),
15428
15329
  mouseDownHandler = control && control.getMouseDownHandler(e, target, control);
15429
15330
  if (mouseDownHandler) {
15430
- mouseDownHandler(e, this._currentTransform, pointer.x, pointer.y);
15331
+ mouseDownHandler.call(control, e, this._currentTransform, pointer.x, pointer.y);
15431
15332
  }
15432
15333
  }
15433
15334
  }
@@ -15602,7 +15503,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15602
15503
  pointer: this.getPointer(e, true),
15603
15504
  absolutePointer: this.getPointer(e)
15604
15505
  });
15605
- fireCanvas && this.fire(canvasIn, outOpt);
15506
+ fireCanvas && this.fire(canvasOut, outOpt);
15606
15507
  oldTarget.fire(targetOut, outOpt);
15607
15508
  }
15608
15509
  if (target && targetChanged) {
@@ -15614,7 +15515,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15614
15515
  pointer: this.getPointer(e, true),
15615
15516
  absolutePointer: this.getPointer(e)
15616
15517
  });
15617
- fireCanvas && this.fire(canvasOut, inOpt);
15518
+ fireCanvas && this.fire(canvasIn, inOpt);
15618
15519
  target.fire(targetIn, inOpt);
15619
15520
  }
15620
15521
  }
@@ -16270,6 +16171,7 @@ _defineProperty(Gradient, "type", 'Gradient');
16270
16171
  classRegistry.setClass(Gradient, 'gradient');
16271
16172
 
16272
16173
  const _excluded$b = ["source"];
16174
+
16273
16175
  /**
16274
16176
  * @see {@link http://fabricjs.com/patterns demo}
16275
16177
  * @see {@link http://fabricjs.com/dynamic-patterns demo}
@@ -16287,7 +16189,7 @@ class Pattern {
16287
16189
  return 'pattern';
16288
16190
  }
16289
16191
  set type(value) {
16290
- console.warn('Setting type has no effect', value);
16192
+ log('warn', 'Setting type has no effect', value);
16291
16193
  }
16292
16194
 
16293
16195
  /**
@@ -19030,9 +18932,9 @@ function getMeasuringContext() {
19030
18932
  * Text class
19031
18933
  * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text}
19032
18934
  */
19033
- class Text extends StyledText {
18935
+ class FabricText extends StyledText {
19034
18936
  static getDefaults() {
19035
- return _objectSpread2(_objectSpread2({}, super.getDefaults()), Text.ownDefaults);
18937
+ return _objectSpread2(_objectSpread2({}, super.getDefaults()), FabricText.ownDefaults);
19036
18938
  }
19037
18939
  constructor(text) {
19038
18940
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -20079,7 +19981,7 @@ class Text extends StyledText {
20079
19981
  fontSize = this.fontSize
20080
19982
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
20081
19983
  let forMeasuring = arguments.length > 1 ? arguments[1] : undefined;
20082
- const parsedFontFamily = fontFamily.includes("'") || fontFamily.includes('"') || fontFamily.includes(',') || Text.genericFonts.includes(fontFamily.toLowerCase()) ? fontFamily : "\"".concat(fontFamily, "\"");
19984
+ const parsedFontFamily = fontFamily.includes("'") || fontFamily.includes('"') || fontFamily.includes(',') || FabricText.genericFonts.includes(fontFamily.toLowerCase()) ? fontFamily : "\"".concat(fontFamily, "\"");
20083
19985
  return [fontStyle, fontWeight, "".concat(forMeasuring ? this.CACHE_FONT_SIZE : fontSize, "px"), parsedFontFamily].join(' ');
20084
19986
  }
20085
19987
 
@@ -20185,14 +20087,14 @@ class Text extends StyledText {
20185
20087
  return 1;
20186
20088
  }
20187
20089
  /**
20188
- * Returns Text instance from an SVG element (<b>not yet implemented</b>)
20090
+ * Returns FabricText instance from an SVG element (<b>not yet implemented</b>)
20189
20091
  * @static
20190
20092
  * @memberOf Text
20191
20093
  * @param {HTMLElement} element Element to parse
20192
20094
  * @param {Object} [options] Options object
20193
20095
  */
20194
20096
  static async fromElement(element, options, cssRules) {
20195
- const parsedAttributes = parseAttributes(element, Text.ATTRIBUTE_NAMES, cssRules);
20097
+ const parsedAttributes = parseAttributes(element, FabricText.ATTRIBUTE_NAMES, cssRules);
20196
20098
  const _options$parsedAttrib = _objectSpread2(_objectSpread2({}, options), parsedAttributes),
20197
20099
  {
20198
20100
  textAnchor = LEFT,
@@ -20247,9 +20149,9 @@ class Text extends StyledText {
20247
20149
  /* _FROM_SVG_END_ */
20248
20150
 
20249
20151
  /**
20250
- * Returns Text instance from an object representation
20152
+ * Returns FabricText instance from an object representation
20251
20153
  * @param {Object} object plain js Object to create an instance from
20252
- * @returns {Promise<Text>}
20154
+ * @returns {Promise<FabricText>}
20253
20155
  */
20254
20156
  static fromObject(object) {
20255
20157
  return this._fromObject(_objectSpread2(_objectSpread2({}, object), {}, {
@@ -20264,22 +20166,22 @@ class Text extends StyledText {
20264
20166
  * @type string[]
20265
20167
  * @protected
20266
20168
  */
20267
- _defineProperty(Text, "textLayoutProperties", textLayoutProperties);
20268
- _defineProperty(Text, "cacheProperties", [...cacheProperties, ...additionalProps]);
20269
- _defineProperty(Text, "ownDefaults", textDefaultValues);
20270
- _defineProperty(Text, "type", 'Text');
20271
- _defineProperty(Text, "genericFonts", ['sans-serif', 'serif', 'cursive', 'fantasy', 'monospace']);
20169
+ _defineProperty(FabricText, "textLayoutProperties", textLayoutProperties);
20170
+ _defineProperty(FabricText, "cacheProperties", [...cacheProperties, ...additionalProps]);
20171
+ _defineProperty(FabricText, "ownDefaults", textDefaultValues);
20172
+ _defineProperty(FabricText, "type", 'Text');
20173
+ _defineProperty(FabricText, "genericFonts", ['sans-serif', 'serif', 'cursive', 'fantasy', 'monospace']);
20272
20174
  /* _FROM_SVG_START_ */
20273
20175
  /**
20274
- * List of attribute names to account for when parsing SVG element (used by {@link Text.fromElement})
20176
+ * List of attribute names to account for when parsing SVG element (used by {@link FabricText.fromElement})
20275
20177
  * @static
20276
20178
  * @memberOf Text
20277
20179
  * @see: http://www.w3.org/TR/SVG/text.html#TextElement
20278
20180
  */
20279
- _defineProperty(Text, "ATTRIBUTE_NAMES", SHARED_ATTRIBUTES.concat('x', 'y', 'dx', 'dy', 'font-family', 'font-style', 'font-weight', 'font-size', 'letter-spacing', 'text-decoration', 'text-anchor'));
20280
- applyMixins(Text, [TextSVGExportMixin]);
20281
- classRegistry.setClass(Text);
20282
- classRegistry.setSVGClass(Text);
20181
+ _defineProperty(FabricText, "ATTRIBUTE_NAMES", SHARED_ATTRIBUTES.concat('x', 'y', 'dx', 'dy', 'font-family', 'font-style', 'font-weight', 'font-size', 'letter-spacing', 'text-decoration', 'text-anchor'));
20182
+ applyMixins(FabricText, [TextSVGExportMixin]);
20183
+ classRegistry.setClass(FabricText);
20184
+ classRegistry.setSVGClass(FabricText);
20283
20185
 
20284
20186
  /**
20285
20187
  * #### Dragging IText/Textbox Lifecycle
@@ -20632,7 +20534,7 @@ class DraggableTextDelegate {
20632
20534
  * - `\-` Matches a "-" character (char code 45).
20633
20535
  */ // eslint-disable-next-line no-useless-escape
20634
20536
  const reNonWord = /[ \n\.,;!\?\-]/;
20635
- class ITextBehavior extends Text {
20537
+ class ITextBehavior extends FabricText {
20636
20538
  constructor() {
20637
20539
  super(...arguments);
20638
20540
  /**
@@ -22716,7 +22618,7 @@ class IText extends ITextClickBehavior {
22716
22618
  lineIndex = cursorLocation.lineIndex,
22717
22619
  charIndex = cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0,
22718
22620
  charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'),
22719
- multiplier = this.scaleX * this.canvas.getZoom(),
22621
+ multiplier = this.getObjectScaling().x * this.canvas.getZoom(),
22720
22622
  cursorWidth = this.cursorWidth / multiplier,
22721
22623
  dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'),
22722
22624
  topOffset = boundaries.topOffset + (1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex) / this.lineHeight - charHeight * (1 - this._fontSizeFraction);
@@ -23858,9 +23760,9 @@ const IMAGE_PROPS = ['cropX', 'cropY'];
23858
23760
  /**
23859
23761
  * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images}
23860
23762
  */
23861
- class Image extends FabricObject {
23763
+ class FabricImage extends FabricObject {
23862
23764
  static getDefaults() {
23863
- return _objectSpread2(_objectSpread2({}, super.getDefaults()), Image.ownDefaults);
23765
+ return _objectSpread2(_objectSpread2({}, super.getDefaults()), FabricImage.ownDefaults);
23864
23766
  }
23865
23767
  /**
23866
23768
  * Constructor
@@ -23878,7 +23780,7 @@ class Image extends FabricObject {
23878
23780
  filters: []
23879
23781
  }, options));
23880
23782
  /**
23881
- * When calling {@link Image.getSrc}, return value from element src with `element.getAttribute('src')`.
23783
+ * When calling {@link FabricImage.getSrc}, return value from element src with `element.getAttribute('src')`.
23882
23784
  * This allows for relative urls as image src.
23883
23785
  * @since 2.7.0
23884
23786
  * @type Boolean
@@ -23935,7 +23837,7 @@ class Image extends FabricObject {
23935
23837
  this._element = element;
23936
23838
  this._originalElement = element;
23937
23839
  this._setWidthHeight(size);
23938
- element.classList.add(Image.CSS_CANVAS);
23840
+ element.classList.add(FabricImage.CSS_CANVAS);
23939
23841
  if (this.filters.length !== 0) {
23940
23842
  this.applyFilters();
23941
23843
  }
@@ -24408,12 +24310,12 @@ class Image extends FabricObject {
24408
24310
  */
24409
24311
 
24410
24312
  /**
24411
- * Creates an instance of Image from its object representation
24313
+ * Creates an instance of FabricImage from its object representation
24412
24314
  * @static
24413
24315
  * @param {Object} object Object to create an instance from
24414
24316
  * @param {object} [options] Options object
24415
24317
  * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
24416
- * @returns {Promise<Image>}
24318
+ * @returns {Promise<FabricImage>}
24417
24319
  */
24418
24320
  static fromObject(_ref) {
24419
24321
  let {
@@ -24444,7 +24346,7 @@ class Image extends FabricObject {
24444
24346
  * @static
24445
24347
  * @param {String} url URL to create an image from
24446
24348
  * @param {LoadImageOptions} [options] Options object
24447
- * @returns {Promise<Image>}
24349
+ * @returns {Promise<FabricImage>}
24448
24350
  */
24449
24351
  static fromURL(url) {
24450
24352
  let {
@@ -24459,7 +24361,7 @@ class Image extends FabricObject {
24459
24361
  }
24460
24362
 
24461
24363
  /**
24462
- * Returns {@link Image} instance from an SVG element
24364
+ * Returns {@link FabricImage} instance from an SVG element
24463
24365
  * @static
24464
24366
  * @param {HTMLElement} element Element to parse
24465
24367
  * @param {Object} [options] Options object
@@ -24471,23 +24373,23 @@ class Image extends FabricObject {
24471
24373
  let cssRules = arguments.length > 2 ? arguments[2] : undefined;
24472
24374
  const parsedAttributes = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);
24473
24375
  return this.fromURL(parsedAttributes['xlink:href'], options, parsedAttributes).catch(err => {
24474
- console.log(err);
24376
+ log('log', 'Unable to parse Image', err);
24475
24377
  return null;
24476
24378
  });
24477
24379
  }
24478
24380
  }
24479
- _defineProperty(Image, "type", 'Image');
24480
- _defineProperty(Image, "cacheProperties", [...cacheProperties, ...IMAGE_PROPS]);
24481
- _defineProperty(Image, "ownDefaults", imageDefaultValues);
24482
- _defineProperty(Image, "CSS_CANVAS", 'canvas-img');
24381
+ _defineProperty(FabricImage, "type", 'Image');
24382
+ _defineProperty(FabricImage, "cacheProperties", [...cacheProperties, ...IMAGE_PROPS]);
24383
+ _defineProperty(FabricImage, "ownDefaults", imageDefaultValues);
24384
+ _defineProperty(FabricImage, "CSS_CANVAS", 'canvas-img');
24483
24385
  /**
24484
- * List of attribute names to account for when parsing SVG element (used by {@link Image.fromElement})
24386
+ * List of attribute names to account for when parsing SVG element (used by {@link FabricImage.fromElement})
24485
24387
  * @static
24486
24388
  * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}
24487
24389
  */
24488
- _defineProperty(Image, "ATTRIBUTE_NAMES", [...SHARED_ATTRIBUTES, 'x', 'y', 'width', 'height', 'preserveAspectRatio', 'xlink:href', 'crossOrigin', 'image-rendering']);
24489
- classRegistry.setClass(Image);
24490
- classRegistry.setSVGClass(Image);
24390
+ _defineProperty(FabricImage, "ATTRIBUTE_NAMES", [...SHARED_ATTRIBUTES, 'x', 'y', 'width', 'height', 'preserveAspectRatio', 'xlink:href', 'crossOrigin', 'image-rendering']);
24391
+ classRegistry.setClass(FabricImage);
24392
+ classRegistry.setSVGClass(FabricImage);
24491
24393
 
24492
24394
  /**
24493
24395
  * Add a <g> element that envelop all child elements and makes the viewbox transformMatrix descend on all elements
@@ -24623,25 +24525,6 @@ function hasInvalidAncestor(element) {
24623
24525
  return false;
24624
24526
  }
24625
24527
 
24626
- /**
24627
- * @private
24628
- * TODO: verify if this is still needed
24629
- * to support IE8 missing getElementById on SVGdocument and on node xmlDOM
24630
- */
24631
- function elementById(doc, id) {
24632
- if (doc.getElementById) {
24633
- return doc.getElementById(id);
24634
- }
24635
- const nodelist = doc.getElementsByTagName('*');
24636
- for (let i = 0, len = nodelist.length; i < len; i++) {
24637
- const node = nodelist[i];
24638
- if (id === node.getAttribute('id')) {
24639
- return node;
24640
- }
24641
- }
24642
- return null;
24643
- }
24644
-
24645
24528
  function getMultipleNodes(doc, nodeNames) {
24646
24529
  let nodeName,
24647
24530
  nodeArray = [],
@@ -24668,7 +24551,12 @@ function parseUseDirectives(doc) {
24668
24551
  const xlink = xlinkAttribute.slice(1);
24669
24552
  const x = el.getAttribute('x') || 0;
24670
24553
  const y = el.getAttribute('y') || 0;
24671
- let el2 = elementById(doc, xlink).cloneNode(true);
24554
+ const el2Orig = doc.getElementById(xlink);
24555
+ if (el2Orig === null) {
24556
+ // if we can't find the target of the xlink, consider this use tag bad, similar to no xlink
24557
+ return;
24558
+ }
24559
+ let el2 = el2Orig.cloneNode(true);
24672
24560
  let currentTrans = (el2.getAttribute('transform') || '') + ' translate(' + x + ', ' + y + ')';
24673
24561
  const oldLength = nodelist.length;
24674
24562
  const namespace = svgNS;
@@ -24720,7 +24608,7 @@ const xlinkAttr = 'xlink:href';
24720
24608
  function recursivelyParseGradientsXlink(doc, gradient) {
24721
24609
  var _gradient$getAttribut;
24722
24610
  const xLink = ((_gradient$getAttribut = gradient.getAttribute(xlinkAttr)) === null || _gradient$getAttribut === void 0 ? void 0 : _gradient$getAttribut.slice(1)) || '',
24723
- referencedGradient = elementById(doc, xLink);
24611
+ referencedGradient = doc.getElementById(xLink);
24724
24612
  if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {
24725
24613
  recursivelyParseGradientsXlink(doc, referencedGradient);
24726
24614
  }
@@ -24840,7 +24728,7 @@ class ElementsParser {
24840
24728
  const obj = await klass.fromElement(el, this.options, this.cssRules);
24841
24729
  this.resolveGradient(obj, el, 'fill');
24842
24730
  this.resolveGradient(obj, el, 'stroke');
24843
- if (obj instanceof Image && obj._originalElement) {
24731
+ if (obj instanceof FabricImage && obj._originalElement) {
24844
24732
  removeTransformMatrixForSvgParsing(obj, obj.parsePreserveAspectRatioAttribute());
24845
24733
  } else {
24846
24734
  removeTransformMatrixForSvgParsing(obj);
@@ -24959,7 +24847,7 @@ async function parseSVGDocument(doc, reviver) {
24959
24847
  signal
24960
24848
  } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
24961
24849
  if (signal && signal.aborted) {
24962
- console.log('`options.signal` is in `aborted` state');
24850
+ log('log', new SignalAbortedError('parseSVGDocument'));
24963
24851
  // this is an unhappy path, we dont care about speed
24964
24852
  return createEmptyResponse();
24965
24853
  }
@@ -25063,7 +24951,7 @@ const getSize = poly => {
25063
24951
  * This function locates the controls.
25064
24952
  * It'll be used both for drawing and for interaction.
25065
24953
  */
25066
- const factoryPolyPositionHandler = pointIndex => {
24954
+ const createPolyPositionHandler = pointIndex => {
25067
24955
  return function (dim, finalMatrix, polyObject) {
25068
24956
  var _polyObject$canvas$vi, _polyObject$canvas;
25069
24957
  const x = polyObject.points[pointIndex].x - polyObject.pathOffset.x,
@@ -25096,7 +24984,7 @@ const polyActionHandler = (eventData, transform, x, y) => {
25096
24984
  /**
25097
24985
  * Keep the polygon in the same position when we change its `width`/`height`/`top`/`left`.
25098
24986
  */
25099
- const anchorWrapper = (pointIndex, fn) => {
24987
+ const factoryPolyActionHandler = (pointIndex, fn) => {
25100
24988
  return function (eventData, transform, x, y) {
25101
24989
  const poly = transform.target,
25102
24990
  anchorPoint = new Point(poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1]),
@@ -25110,14 +24998,15 @@ const anchorWrapper = (pointIndex, fn) => {
25110
24998
  return actionPerformed;
25111
24999
  };
25112
25000
  };
25001
+ const createPolyActionHandler = pointIndex => factoryPolyActionHandler(pointIndex, polyActionHandler);
25113
25002
  function createPolyControls(arg0) {
25114
25003
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25115
25004
  const controls = {};
25116
25005
  for (let idx = 0; idx < (typeof arg0 === 'number' ? arg0 : arg0.points.length); idx++) {
25117
25006
  controls["p".concat(idx)] = new Control(_objectSpread2({
25118
25007
  actionName: 'modifyPoly',
25119
- positionHandler: factoryPolyPositionHandler(idx),
25120
- actionHandler: anchorWrapper(idx, polyActionHandler)
25008
+ positionHandler: createPolyPositionHandler(idx),
25009
+ actionHandler: createPolyActionHandler(idx)
25121
25010
  }, options));
25122
25011
  }
25123
25012
  return controls;
@@ -25127,11 +25016,15 @@ var index = /*#__PURE__*/Object.freeze({
25127
25016
  __proto__: null,
25128
25017
  changeWidth: changeWidth,
25129
25018
  createObjectDefaultControls: createObjectDefaultControls,
25019
+ createPolyActionHandler: createPolyActionHandler,
25130
25020
  createPolyControls: createPolyControls,
25021
+ createPolyPositionHandler: createPolyPositionHandler,
25131
25022
  createResizeControls: createResizeControls,
25132
25023
  createTextboxDefaultControls: createTextboxDefaultControls,
25133
25024
  dragHandler: dragHandler,
25025
+ factoryPolyActionHandler: factoryPolyActionHandler,
25134
25026
  getLocalPoint: getLocalPoint,
25027
+ polyActionHandler: polyActionHandler,
25135
25028
  renderCircleControl: renderCircleControl,
25136
25029
  renderSquareControl: renderSquareControl,
25137
25030
  rotationStyleHandler: rotationStyleHandler,
@@ -25226,25 +25119,23 @@ class BaseFilter {
25226
25119
  const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
25227
25120
  const program = gl.createProgram();
25228
25121
  if (!vertexShader || !fragmentShader || !program) {
25229
- throw new Error('Vertex, fragment shader or program creation error');
25122
+ throw new FabricError('Vertex, fragment shader or program creation error');
25230
25123
  }
25231
25124
  gl.shaderSource(vertexShader, vertexSource);
25232
25125
  gl.compileShader(vertexShader);
25233
25126
  if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
25234
- throw new Error("Vertex shader compile error for ".concat(this.type, ": ").concat(gl.getShaderInfoLog(vertexShader)));
25127
+ throw new FabricError("Vertex shader compile error for ".concat(this.type, ": ").concat(gl.getShaderInfoLog(vertexShader)));
25235
25128
  }
25236
25129
  gl.shaderSource(fragmentShader, fragmentSource);
25237
25130
  gl.compileShader(fragmentShader);
25238
25131
  if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
25239
- throw new Error("Fragment shader compile error for ".concat(this.type, ": ").concat(gl.getShaderInfoLog(fragmentShader)));
25132
+ throw new FabricError("Fragment shader compile error for ".concat(this.type, ": ").concat(gl.getShaderInfoLog(fragmentShader)));
25240
25133
  }
25241
25134
  gl.attachShader(program, vertexShader);
25242
25135
  gl.attachShader(program, fragmentShader);
25243
25136
  gl.linkProgram(program);
25244
25137
  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
25245
- throw new Error(
25246
- // eslint-disable-next-line prefer-template
25247
- 'Shader link error for "${this.type}" ' + gl.getProgramInfoLog(program));
25138
+ throw new FabricError("Shader link error for \"".concat(this.type, "\" ").concat(gl.getProgramInfoLog(program)));
25248
25139
  }
25249
25140
  const uniformLocations = this.getUniformLocations(gl, program) || {};
25250
25141
  uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');
@@ -25843,7 +25734,7 @@ class BlendImage extends BaseFilter {
25843
25734
  image
25844
25735
  } = _ref2,
25845
25736
  filterOptions = _objectWithoutProperties(_ref2, _excluded$3);
25846
- return Image.fromObject(image, options).then(enlivedImage => new this(_objectSpread2(_objectSpread2({}, filterOptions), {}, {
25737
+ return FabricImage.fromObject(image, options).then(enlivedImage => new this(_objectSpread2(_objectSpread2({}, filterOptions), {}, {
25847
25738
  image: enlivedImage
25848
25739
  })));
25849
25740
  }
@@ -27839,10 +27730,13 @@ exports.CircleBrush = CircleBrush;
27839
27730
  exports.Color = Color;
27840
27731
  exports.Control = Control;
27841
27732
  exports.Ellipse = Ellipse;
27733
+ exports.FabricImage = FabricImage;
27734
+ exports.FabricObject = FabricObject;
27735
+ exports.FabricText = FabricText;
27842
27736
  exports.Gradient = Gradient;
27843
27737
  exports.Group = Group;
27844
27738
  exports.IText = IText;
27845
- exports.Image = Image;
27739
+ exports.Image = FabricImage;
27846
27740
  exports.Intersection = Intersection;
27847
27741
  exports.Line = Line;
27848
27742
  exports.Object = FabricObject;
@@ -27859,7 +27753,7 @@ exports.Shadow = Shadow;
27859
27753
  exports.SprayBrush = SprayBrush;
27860
27754
  exports.StaticCanvas = StaticCanvas;
27861
27755
  exports.StaticCanvasDOMManager = StaticCanvasDOMManager;
27862
- exports.Text = Text;
27756
+ exports.Text = FabricText;
27863
27757
  exports.Textbox = Textbox;
27864
27758
  exports.Triangle = Triangle;
27865
27759
  exports.WebGLFilterBackend = WebGLFilterBackend;