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
@@ -243,6 +243,26 @@ class NodeGLProbe extends GLProbe {
243
243
  }
244
244
  }
245
245
 
246
+ const log = function (severity) {
247
+ for (var _len = arguments.length, optionalParams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
248
+ optionalParams[_key - 1] = arguments[_key];
249
+ }
250
+ return (
251
+ // eslint-disable-next-line no-restricted-syntax
252
+ console[severity]('fabric', ...optionalParams)
253
+ );
254
+ };
255
+ class FabricError extends Error {
256
+ constructor(message, options) {
257
+ super("fabric: ".concat(message), options);
258
+ }
259
+ }
260
+ class SignalAbortedError extends FabricError {
261
+ constructor(context) {
262
+ super("".concat(context, " 'options.signal' is in 'aborted' state"));
263
+ }
264
+ }
265
+
246
266
  /**
247
267
  * Lazy initialize WebGL constants
248
268
  */
@@ -272,7 +292,7 @@ class WebGLProbe extends GLProbe {
272
292
  if (gl) {
273
293
  this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
274
294
  this.GLPrecision = ['highp', 'mediump', 'lowp'].find(precision => this.testPrecision(gl, precision));
275
- console.log("fabric: max texture size ".concat(this.maxTextureSize));
295
+ log('log', "WebGL: max texture size ".concat(this.maxTextureSize));
276
296
  }
277
297
  }
278
298
  isSupported(textureSize) {
@@ -453,7 +473,7 @@ class Cache {
453
473
  }
454
474
  const cache = new Cache();
455
475
 
456
- var version = "6.0.0-beta13";
476
+ var version = "6.0.0-beta15";
457
477
 
458
478
  // use this syntax so babel plugin see this import here
459
479
  const VERSION = version;
@@ -501,7 +521,7 @@ class ClassRegistry {
501
521
  getClass(classType) {
502
522
  const constructor = this[JSON$1].get(classType);
503
523
  if (!constructor) {
504
- throw new Error("No class registered for ".concat(classType));
524
+ throw new FabricError("No class registered for ".concat(classType));
505
525
  }
506
526
  return constructor;
507
527
  }
@@ -547,8 +567,8 @@ class AnimationRegistry extends Array {
547
567
  }
548
568
 
549
569
  /**
550
- * Cancel all running animations attached to a Canvas on the next frame
551
- * @param {Canvas} canvas
570
+ * Cancel all running animations attached to a canvas on the next frame
571
+ * @param {StaticCanvas} canvas
552
572
  */
553
573
  cancelByCanvas(canvas) {
554
574
  if (!canvas) {
@@ -556,7 +576,7 @@ class AnimationRegistry extends Array {
556
576
  }
557
577
  const animations = this.filter(animation => {
558
578
  var _animation$target;
559
- return typeof animation.target === 'object' && ((_animation$target = animation.target) === null || _animation$target === void 0 ? void 0 : _animation$target.canvas) === canvas;
579
+ return animation.target === canvas || typeof animation.target === 'object' && ((_animation$target = animation.target) === null || _animation$target === void 0 ? void 0 : _animation$target.canvas) === canvas;
560
580
  });
561
581
  animations.forEach(animation => animation.abort());
562
582
  return animations;
@@ -1493,7 +1513,7 @@ function createCollectionMixin(Base) {
1493
1513
  // we iterate reverse order to collect top first in case of click.
1494
1514
  for (let i = this._objects.length - 1; i >= 0; i--) {
1495
1515
  const object = this._objects[i];
1496
- 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))) {
1516
+ 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))) {
1497
1517
  objects.push(object);
1498
1518
  }
1499
1519
  }
@@ -1583,7 +1603,7 @@ const uid = () => id++;
1583
1603
  const createCanvasElement = () => {
1584
1604
  const element = getFabricDocument().createElement('canvas');
1585
1605
  if (!element || typeof element.getContext === 'undefined') {
1586
- throw new Error('Failed to create `canvas` element');
1606
+ throw new FabricError('Failed to create `canvas` element');
1587
1607
  }
1588
1608
  return element;
1589
1609
  };
@@ -1871,7 +1891,7 @@ const loadImage = function (url) {
1871
1891
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1872
1892
  return new Promise(function (resolve, reject) {
1873
1893
  if (signal && signal.aborted) {
1874
- return reject(new Error('`options.signal` is in `aborted` state'));
1894
+ return reject(new SignalAbortedError('loadImage'));
1875
1895
  }
1876
1896
  const img = createImage();
1877
1897
  let abort;
@@ -1896,7 +1916,7 @@ const loadImage = function (url) {
1896
1916
  img.onload = done;
1897
1917
  img.onerror = function () {
1898
1918
  abort && (signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort));
1899
- reject(new Error('Error loading ' + img.src));
1919
+ reject(new FabricError("Error loading ".concat(img.src)));
1900
1920
  };
1901
1921
  crossOrigin && (img.crossOrigin = crossOrigin);
1902
1922
  img.src = url;
@@ -2754,22 +2774,29 @@ const matrixToSVG = transform => 'matrix(' + transform.map(value => toFixed(valu
2754
2774
  * we work around it by "moving" alpha channel into opacity attribute and setting fill's alpha to 1
2755
2775
  * @param prop
2756
2776
  * @param value
2777
+ * @param {boolean} inlineStyle The default is inline style, the separator used is ":", The other is "="
2757
2778
  * @returns
2758
2779
  */
2759
- const colorPropToSVG = (prop, value) => {
2780
+ const colorPropToSVG = function (prop, value) {
2781
+ let inlineStyle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
2782
+ let colorValue;
2783
+ let opacityValue;
2760
2784
  if (!value) {
2761
- return "".concat(prop, ": none; ");
2785
+ colorValue = 'none';
2762
2786
  } else if (value.toLive) {
2763
- return "".concat(prop, ": url(#SVGID_").concat(value.id, "); ");
2787
+ colorValue = "url(#SVGID_".concat(value.id, ")");
2764
2788
  } else {
2765
2789
  const color = new Color(value),
2766
2790
  opacity = color.getAlpha();
2767
- let str = "".concat(prop, ": ").concat(color.toRgb(), "; ");
2791
+ colorValue = color.toRgb();
2768
2792
  if (opacity !== 1) {
2769
- //change the color in rgb + opacity
2770
- str += "".concat(prop, "-opacity: ").concat(opacity.toString(), "; ");
2793
+ opacityValue = opacity.toString();
2771
2794
  }
2772
- return str;
2795
+ }
2796
+ if (inlineStyle) {
2797
+ return "".concat(prop, ": ").concat(colorValue, "; ").concat(opacityValue ? "".concat(prop, "-opacity: ").concat(opacityValue, "; ") : '');
2798
+ } else {
2799
+ return "".concat(prop, "=\"").concat(colorValue, "\" ").concat(opacityValue ? "".concat(prop, "-opacity=\"").concat(opacityValue, "\" ") : '');
2773
2800
  }
2774
2801
  };
2775
2802
  const createSVGRect = function (color, _ref) {
@@ -2780,7 +2807,7 @@ const createSVGRect = function (color, _ref) {
2780
2807
  height
2781
2808
  } = _ref;
2782
2809
  let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : config.NUM_FRACTION_DIGITS;
2783
- const svgColor = colorPropToSVG('fill', color);
2810
+ const svgColor = colorPropToSVG('fill', color, false);
2784
2811
  const [x, y, w, h] = [left, top, width, height].map(value => toFixed(value, precision));
2785
2812
  return "<rect ".concat(svgColor, " x=\"").concat(x, "\" y=\"").concat(y, "\" width=\"").concat(w, "\" height=\"").concat(h, "\"></rect>");
2786
2813
  };
@@ -2992,13 +3019,10 @@ class StaticCanvasDOMManager {
2992
3019
  }
2993
3020
  createLowerCanvas(arg0) {
2994
3021
  // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node
2995
- const el = isHTMLCanvas(arg0) ? arg0 : getFabricDocument().getElementById(arg0) || createCanvasElement();
3022
+ const el = isHTMLCanvas(arg0) ? arg0 : arg0 && getFabricDocument().getElementById(arg0) || createCanvasElement();
2996
3023
  if (el.hasAttribute('data-fabric')) {
2997
- /* _DEV_MODE_START_ */
2998
- throw new Error('fabric.js: trying to initialize a canvas that has already been initialized');
2999
- /* _DEV_MODE_END_ */
3024
+ throw new FabricError('Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?');
3000
3025
  }
3001
-
3002
3026
  this._originalCanvasStyle = el.style.cssText;
3003
3027
  el.setAttribute('data-fabric', 'main');
3004
3028
  el.classList.add('lower-canvas');
@@ -3167,9 +3191,7 @@ let StaticCanvas$1 = class StaticCanvas extends createCollectionMixin(CommonMeth
3167
3191
  }
3168
3192
  _onObjectAdded(obj) {
3169
3193
  if (obj.canvas && obj.canvas !== this) {
3170
- /* _DEV_MODE_START_ */
3171
- 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');
3172
- /* _DEV_MODE_END_ */
3194
+ 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');
3173
3195
  obj.canvas.remove(obj);
3174
3196
  }
3175
3197
  obj._set('canvas', this);
@@ -4099,7 +4121,7 @@ let StaticCanvas$1 = class StaticCanvas extends createCollectionMixin(CommonMeth
4099
4121
  signal
4100
4122
  } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4101
4123
  if (!json) {
4102
- return Promise.reject(new Error('fabric.js: `json` is undefined'));
4124
+ return Promise.reject(new FabricError('`json` is undefined'));
4103
4125
  }
4104
4126
 
4105
4127
  // parse json if it wasn't already
@@ -4269,6 +4291,7 @@ let StaticCanvas$1 = class StaticCanvas extends createCollectionMixin(CommonMeth
4269
4291
  width: this.width,
4270
4292
  height: this.height
4271
4293
  });
4294
+ runningAnimations.cancelByCanvas(this);
4272
4295
  this.disposed = true;
4273
4296
  return new Promise((resolve, reject) => {
4274
4297
  const task = () => {
@@ -4555,10 +4578,10 @@ const sendPointToPlane = function (point) {
4555
4578
  const transformPointRelativeToCanvas = (point, canvas, relationBefore, relationAfter) => {
4556
4579
  // is this still needed with TS?
4557
4580
  if (relationBefore !== 'child' && relationBefore !== 'sibling') {
4558
- throw new Error("fabric.js: received bad argument ".concat(relationBefore));
4581
+ throw new FabricError("received bad argument ".concat(relationBefore));
4559
4582
  }
4560
4583
  if (relationAfter !== 'child' && relationAfter !== 'sibling') {
4561
- throw new Error("fabric.js: received bad argument ".concat(relationAfter));
4584
+ throw new FabricError("received bad argument ".concat(relationAfter));
4562
4585
  }
4563
4586
  if (relationBefore === relationAfter) {
4564
4587
  return point;
@@ -5665,6 +5688,31 @@ class Intersection {
5665
5688
  }
5666
5689
  }
5667
5690
 
5691
+ /**
5692
+ * Use the ray casting algorithm to determine if {@link point} is in the polygon defined by {@link points}
5693
+ * @see https://en.wikipedia.org/wiki/Point_in_polygon
5694
+ * @param point
5695
+ * @param points polygon points
5696
+ * @returns
5697
+ */
5698
+ static isPointInPolygon(point, points) {
5699
+ const other = new Point(point).setX(Math.min(point.x - 1, ...points.map(p => p.x)));
5700
+ let hits = 0;
5701
+ for (let index = 0; index < points.length; index++) {
5702
+ const inter = this.intersectSegmentSegment(
5703
+ // polygon side
5704
+ points[index], points[(index + 1) % points.length],
5705
+ // ray
5706
+ point, other);
5707
+ if (inter.includes(point)) {
5708
+ // point is on the polygon side
5709
+ return true;
5710
+ }
5711
+ hits += Number(inter.status === 'Intersection');
5712
+ }
5713
+ return hits % 2 === 1;
5714
+ }
5715
+
5668
5716
  /**
5669
5717
  * Checks if a line intersects another
5670
5718
  * @see {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection line intersection}
@@ -6201,21 +6249,15 @@ class ObjectGeometry extends ObjectOrigin {
6201
6249
  * Checks if object is fully contained within area of another object
6202
6250
  * @param {Object} other Object to test
6203
6251
  * @param {Boolean} [absolute] use coordinates without viewportTransform
6204
- * @param {Boolean} [calculate] use coordinates of current position instead of store ones
6252
+ * @param {Boolean} [calculate] use coordinates of current position instead of stored ones
6205
6253
  * @return {Boolean} true if object is fully contained within area of another object
6206
6254
  */
6207
6255
  isContainedWithinObject(other) {
6208
6256
  let absolute = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6209
6257
  let calculate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
6210
- const points = this.getCoords(absolute, calculate),
6211
- otherCoords = absolute ? other.aCoords : other.lineCoords,
6212
- lines = other._getImageLines(otherCoords);
6213
- for (let i = 0; i < 4; i++) {
6214
- if (!other.containsPoint(points[i], lines)) {
6215
- return false;
6216
- }
6217
- }
6218
- return true;
6258
+ const points = this.getCoords(absolute, calculate);
6259
+ calculate && other.getCoords(absolute, true);
6260
+ return points.every(point => other.containsPoint(point));
6219
6261
  }
6220
6262
 
6221
6263
  /**
@@ -6237,19 +6279,14 @@ class ObjectGeometry extends ObjectOrigin {
6237
6279
  /**
6238
6280
  * Checks if point is inside the object
6239
6281
  * @param {Point} point Point to check against
6240
- * @param {Object} [lines] object returned from @method _getImageLines
6241
6282
  * @param {Boolean} [absolute] use coordinates without viewportTransform
6242
6283
  * @param {Boolean} [calculate] use coordinates of current position instead of stored ones
6243
6284
  * @return {Boolean} true if point is inside the object
6244
6285
  */
6245
- containsPoint(point, lines) {
6246
- let absolute = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
6247
- let calculate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
6248
- const coords = this._getCoords(absolute, calculate),
6249
- imageLines = lines || this._getImageLines(coords),
6250
- xPoints = this._findCrossPoints(point, imageLines);
6251
- // if xPoints is odd then point is inside the object
6252
- return xPoints !== 0 && xPoints % 2 === 1;
6286
+ containsPoint(point) {
6287
+ let absolute = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6288
+ let calculate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
6289
+ return Intersection.isPointInPolygon(point, this.getCoords(absolute, calculate));
6253
6290
  }
6254
6291
 
6255
6292
  /**
@@ -6291,7 +6328,7 @@ class ObjectGeometry extends ObjectOrigin {
6291
6328
  _containsCenterOfCanvas(pointTL, pointBR, calculate) {
6292
6329
  // worst case scenario the object is so big that contains the screen
6293
6330
  const centerPoint = pointTL.midPointFrom(pointBR);
6294
- return this.containsPoint(centerPoint, undefined, true, calculate);
6331
+ return this.containsPoint(centerPoint, true, calculate);
6295
6332
  }
6296
6333
 
6297
6334
  /**
@@ -6314,100 +6351,6 @@ class ObjectGeometry extends ObjectOrigin {
6314
6351
  return allPointsAreOutside && this._containsCenterOfCanvas(tl, br, calculate);
6315
6352
  }
6316
6353
 
6317
- /**
6318
- * Method that returns an object with the object edges in it, given the coordinates of the corners
6319
- * @private
6320
- * @param {Object} lineCoords or aCoords Coordinates of the object corners
6321
- */
6322
- _getImageLines(_ref) {
6323
- let {
6324
- tl,
6325
- tr,
6326
- bl,
6327
- br
6328
- } = _ref;
6329
- const lines = {
6330
- topline: {
6331
- o: tl,
6332
- d: tr
6333
- },
6334
- rightline: {
6335
- o: tr,
6336
- d: br
6337
- },
6338
- bottomline: {
6339
- o: br,
6340
- d: bl
6341
- },
6342
- leftline: {
6343
- o: bl,
6344
- d: tl
6345
- }
6346
- };
6347
-
6348
- // // debugging
6349
- // if (this.canvas.contextTop) {
6350
- // this.canvas.contextTop.fillRect(lines.bottomline.d.x, lines.bottomline.d.y, 2, 2);
6351
- // this.canvas.contextTop.fillRect(lines.bottomline.o.x, lines.bottomline.o.y, 2, 2);
6352
- //
6353
- // this.canvas.contextTop.fillRect(lines.leftline.d.x, lines.leftline.d.y, 2, 2);
6354
- // this.canvas.contextTop.fillRect(lines.leftline.o.x, lines.leftline.o.y, 2, 2);
6355
- //
6356
- // this.canvas.contextTop.fillRect(lines.topline.d.x, lines.topline.d.y, 2, 2);
6357
- // this.canvas.contextTop.fillRect(lines.topline.o.x, lines.topline.o.y, 2, 2);
6358
- //
6359
- // this.canvas.contextTop.fillRect(lines.rightline.d.x, lines.rightline.d.y, 2, 2);
6360
- // this.canvas.contextTop.fillRect(lines.rightline.o.x, lines.rightline.o.y, 2, 2);
6361
- // }
6362
-
6363
- return lines;
6364
- }
6365
-
6366
- /**
6367
- * Helper method to determine how many cross points are between the 4 object edges
6368
- * and the horizontal line determined by a point on canvas
6369
- * @private
6370
- * @param {Point} point Point to check
6371
- * @param {Object} lines Coordinates of the object being evaluated
6372
- * @return {number} number of crossPoint
6373
- */
6374
- _findCrossPoints(point, lines) {
6375
- let xcount = 0;
6376
- for (const lineKey in lines) {
6377
- let xi;
6378
- const iLine = lines[lineKey];
6379
- // optimization 1: line below point. no cross
6380
- if (iLine.o.y < point.y && iLine.d.y < point.y) {
6381
- continue;
6382
- }
6383
- // optimization 2: line above point. no cross
6384
- if (iLine.o.y >= point.y && iLine.d.y >= point.y) {
6385
- continue;
6386
- }
6387
- // optimization 3: vertical line case
6388
- if (iLine.o.x === iLine.d.x && iLine.o.x >= point.x) {
6389
- xi = iLine.o.x;
6390
- }
6391
- // calculate the intersection point
6392
- else {
6393
- const b1 = 0;
6394
- const b2 = (iLine.d.y - iLine.o.y) / (iLine.d.x - iLine.o.x);
6395
- const a1 = point.y - b1 * point.x;
6396
- const a2 = iLine.o.y - b2 * iLine.o.x;
6397
- xi = -(a1 - a2) / (b1 - b2);
6398
- }
6399
- // don't count xi < point.x cases
6400
- if (xi >= point.x) {
6401
- xcount += 1;
6402
- }
6403
- // optimization 4: specific for square images
6404
- if (xcount === 2) {
6405
- break;
6406
- }
6407
- }
6408
- return xcount;
6409
- }
6410
-
6411
6354
  /**
6412
6355
  * Returns coordinates of object's bounding rectangle (left, top, width, height)
6413
6356
  * the box is intended as aligned to axis of canvas.
@@ -7173,7 +7116,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7173
7116
  return name.toLowerCase();
7174
7117
  }
7175
7118
  set type(value) {
7176
- console.warn('Setting type has no effect', value);
7119
+ log('warn', 'Setting type has no effect', value);
7177
7120
  }
7178
7121
 
7179
7122
  /**
@@ -8093,7 +8036,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
8093
8036
  * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4
8094
8037
  * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4
8095
8038
  * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2
8096
- * @return {Image} Object cloned as image.
8039
+ * @return {FabricImage} Object cloned as image.
8097
8040
  */
8098
8041
  cloneAsImage(options) {
8099
8042
  const canvasEl = this.toCanvasElement(options);
@@ -8590,28 +8533,28 @@ class Control {
8590
8533
  * @type {?Number}
8591
8534
  * @default null
8592
8535
  */
8593
- _defineProperty(this, "sizeX", null);
8536
+ _defineProperty(this, "sizeX", 0);
8594
8537
  /**
8595
8538
  * Sets the height of the control. If null, defaults to object's cornerSize.
8596
8539
  * Expects both sizeX and sizeY to be set when set.
8597
8540
  * @type {?Number}
8598
8541
  * @default null
8599
8542
  */
8600
- _defineProperty(this, "sizeY", null);
8543
+ _defineProperty(this, "sizeY", 0);
8601
8544
  /**
8602
8545
  * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.
8603
8546
  * Expects both touchSizeX and touchSizeY to be set when set.
8604
8547
  * @type {?Number}
8605
8548
  * @default null
8606
8549
  */
8607
- _defineProperty(this, "touchSizeX", null);
8550
+ _defineProperty(this, "touchSizeX", 0);
8608
8551
  /**
8609
8552
  * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.
8610
8553
  * Expects both touchSizeX and touchSizeY to be set when set.
8611
8554
  * @type {?Number}
8612
8555
  * @default null
8613
8556
  */
8614
- _defineProperty(this, "touchSizeY", null);
8557
+ _defineProperty(this, "touchSizeY", 0);
8615
8558
  /**
8616
8559
  * Css cursor style to display when the control is hovered.
8617
8560
  * if the method `cursorStyleHandler` is provided, this property is ignored.
@@ -8656,10 +8599,16 @@ class Control {
8656
8599
  * @return {Boolean} true if the action/event modified the object
8657
8600
  */
8658
8601
 
8659
- shouldActivate(controlKey, fabricObject) {
8602
+ shouldActivate(controlKey, fabricObject, pointer, _ref) {
8660
8603
  var _fabricObject$canvas;
8604
+ let {
8605
+ tl,
8606
+ tr,
8607
+ br,
8608
+ bl
8609
+ } = _ref;
8661
8610
  // TODO: locking logic can be handled here instead of in the control handler logic
8662
- return ((_fabricObject$canvas = fabricObject.canvas) === null || _fabricObject$canvas === void 0 ? void 0 : _fabricObject$canvas.getActiveObject()) === fabricObject && fabricObject.isControlVisible(controlKey);
8611
+ 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]);
8663
8612
  }
8664
8613
 
8665
8614
  /**
@@ -8752,36 +8701,15 @@ class Control {
8752
8701
  * @param {Number} centerY y coordinate where the control center should be
8753
8702
  * @param {boolean} isTouch true if touch corner, false if normal corner
8754
8703
  */
8755
- calcCornerCoords(objectAngle, objectCornerSize, centerX, centerY, isTouch) {
8756
- let cosHalfOffset, sinHalfOffset, cosHalfOffsetComp, sinHalfOffsetComp;
8757
- const xSize = isTouch ? this.touchSizeX : this.sizeX,
8758
- ySize = isTouch ? this.touchSizeY : this.sizeY;
8759
- if (xSize && ySize && xSize !== ySize) {
8760
- // handle rectangular corners
8761
- const controlTriangleAngle = Math.atan2(ySize, xSize);
8762
- const cornerHypotenuse = Math.sqrt(xSize * xSize + ySize * ySize) / 2;
8763
- const newTheta = controlTriangleAngle - degreesToRadians(objectAngle);
8764
- const newThetaComp = halfPI - controlTriangleAngle - degreesToRadians(objectAngle);
8765
- cosHalfOffset = cornerHypotenuse * cos(newTheta);
8766
- sinHalfOffset = cornerHypotenuse * sin(newTheta);
8767
- // use complementary angle for two corners
8768
- cosHalfOffsetComp = cornerHypotenuse * cos(newThetaComp);
8769
- sinHalfOffsetComp = cornerHypotenuse * sin(newThetaComp);
8770
- } else {
8771
- // handle square corners
8772
- // use default object corner size unless size is defined
8773
- const cornerSize = xSize && ySize ? xSize : objectCornerSize;
8774
- const cornerHypotenuse = cornerSize * Math.SQRT1_2;
8775
- // complementary angles are equal since they're both 45 degrees
8776
- const newTheta = degreesToRadians(45 - objectAngle);
8777
- cosHalfOffset = cosHalfOffsetComp = cornerHypotenuse * cos(newTheta);
8778
- sinHalfOffset = sinHalfOffsetComp = cornerHypotenuse * sin(newTheta);
8779
- }
8704
+ calcCornerCoords(angle, objectCornerSize, centerX, centerY, isTouch, fabricObject) {
8705
+ const t = multiplyTransformMatrixArray([createTranslateMatrix(centerX, centerY), createRotateMatrix({
8706
+ angle
8707
+ }), createScaleMatrix((isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize, (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize)]);
8780
8708
  return {
8781
- tl: new Point(centerX - sinHalfOffsetComp, centerY - cosHalfOffsetComp),
8782
- tr: new Point(centerX + cosHalfOffset, centerY - sinHalfOffset),
8783
- bl: new Point(centerX - cosHalfOffset, centerY + sinHalfOffset),
8784
- br: new Point(centerX + sinHalfOffsetComp, centerY + cosHalfOffsetComp)
8709
+ tl: new Point(-0.5, -0.5).transform(t),
8710
+ tr: new Point(0.5, -0.5).transform(t),
8711
+ bl: new Point(-0.5, 0.5).transform(t),
8712
+ br: new Point(0.5, 0.5).transform(t)
8785
8713
  };
8786
8714
  }
8787
8715
 
@@ -9423,34 +9351,14 @@ class InteractiveFabricObject extends FabricObject$1 {
9423
9351
  return '';
9424
9352
  }
9425
9353
  this.__corner = undefined;
9426
- // had to keep the reverse loop because was breaking tests
9427
9354
  const cornerEntries = Object.entries(this.oCoords);
9428
9355
  for (let i = cornerEntries.length - 1; i >= 0; i--) {
9429
9356
  const [key, corner] = cornerEntries[i];
9430
- if (this.controls[key].shouldActivate(key, this)) {
9431
- const lines = this._getImageLines(forTouch ? corner.touchCorner : corner.corner);
9432
- const xPoints = this._findCrossPoints(pointer, lines);
9433
- if (xPoints !== 0 && xPoints % 2 === 1) {
9434
- this.__corner = key;
9435
- return key;
9436
- }
9357
+ if (this.controls[key].shouldActivate(key, this, pointer, forTouch ? corner.touchCorner : corner.corner)) {
9358
+ // this.canvas.contextTop.fillRect(pointer.x - 1, pointer.y - 1, 2, 2);
9359
+ return this.__corner = key;
9437
9360
  }
9438
-
9439
- // // debugging
9440
- //
9441
- // this.canvas.contextTop.fillRect(lines.bottomline.d.x, lines.bottomline.d.y, 2, 2);
9442
- // this.canvas.contextTop.fillRect(lines.bottomline.o.x, lines.bottomline.o.y, 2, 2);
9443
- //
9444
- // this.canvas.contextTop.fillRect(lines.leftline.d.x, lines.leftline.d.y, 2, 2);
9445
- // this.canvas.contextTop.fillRect(lines.leftline.o.x, lines.leftline.o.y, 2, 2);
9446
- //
9447
- // this.canvas.contextTop.fillRect(lines.topline.d.x, lines.topline.d.y, 2, 2);
9448
- // this.canvas.contextTop.fillRect(lines.topline.o.x, lines.topline.o.y, 2, 2);
9449
- //
9450
- // this.canvas.contextTop.fillRect(lines.rightline.d.x, lines.rightline.d.y, 2, 2);
9451
- // this.canvas.contextTop.fillRect(lines.rightline.o.x, lines.rightline.o.y, 2, 2);
9452
9361
  }
9453
-
9454
9362
  return '';
9455
9363
  }
9456
9364
 
@@ -9506,8 +9414,9 @@ class InteractiveFabricObject extends FabricObject$1 {
9506
9414
  * @private
9507
9415
  */
9508
9416
  _calcCornerCoords(control, position) {
9509
- const corner = control.calcCornerCoords(this.angle, this.cornerSize, position.x, position.y, false);
9510
- const touchCorner = control.calcCornerCoords(this.angle, this.touchCornerSize, position.x, position.y, true);
9417
+ const angle = this.getTotalAngle();
9418
+ const corner = control.calcCornerCoords(angle, this.cornerSize, position.x, position.y, false, this);
9419
+ const touchCorner = control.calcCornerCoords(angle, this.touchCornerSize, position.x, position.y, true, this);
9511
9420
  return {
9512
9421
  corner,
9513
9422
  touchCorner
@@ -9525,7 +9434,7 @@ class InteractiveFabricObject extends FabricObject$1 {
9525
9434
  setCoords() {
9526
9435
  super.setCoords();
9527
9436
  // set coordinates of the draggable boxes in the corners used to scale/rotate the image
9528
- this.oCoords = this.calcOCoords();
9437
+ this.canvas && (this.oCoords = this.calcOCoords());
9529
9438
  }
9530
9439
 
9531
9440
  /**
@@ -10607,15 +10516,11 @@ class Group extends createCollectionMixin(FabricObject) {
10607
10516
  canEnterGroup(object) {
10608
10517
  if (object === this || this.isDescendantOf(object)) {
10609
10518
  // prevent circular object tree
10610
- /* _DEV_MODE_START_ */
10611
- console.error('fabric.Group: circular object trees are not supported, this call has no effect');
10612
- /* _DEV_MODE_END_ */
10519
+ log('error', 'Group: circular object trees are not supported, this call has no effect');
10613
10520
  return false;
10614
10521
  } else if (this._objects.indexOf(object) !== -1) {
10615
10522
  // is already in the objects array
10616
- /* _DEV_MODE_START_ */
10617
- console.error('fabric.Group: duplicate objects are not supported inside group, this call has no effect');
10618
- /* _DEV_MODE_END_ */
10523
+ log('error', 'Group: duplicate objects are not supported inside group, this call has no effect');
10619
10524
  return false;
10620
10525
  }
10621
10526
  return true;
@@ -11468,7 +11373,9 @@ class ActiveSelection extends Group {
11468
11373
  // save ref to group for later in order to return to it
11469
11374
  const parent = object.group;
11470
11375
  parent._exitGroup(object);
11471
- object.__owningGroup = parent;
11376
+ // make sure we are setting the correct owning group
11377
+ // in case `object` is transferred between active selections
11378
+ !(parent instanceof ActiveSelection) && (object.__owningGroup = parent);
11472
11379
  }
11473
11380
  this._enterGroup(object, removeParentTransform);
11474
11381
  return true;
@@ -13120,7 +13027,7 @@ function request(url) {
13120
13027
  xhr.onerror = xhr.ontimeout = noop;
13121
13028
  };
13122
13029
  if (signal && signal.aborted) {
13123
- throw new Error('`options.signal` is in `aborted` state');
13030
+ throw new SignalAbortedError('request');
13124
13031
  } else if (signal) {
13125
13032
  signal.addEventListener('abort', abort, {
13126
13033
  once: true
@@ -13567,9 +13474,9 @@ class SelectableCanvas extends StaticCanvas$1 {
13567
13474
  * @type FabricObject[]
13568
13475
  * @private
13569
13476
  */
13570
- _defineProperty(this, "_objectsToRender", []);
13477
+ _defineProperty(this, "_objectsToRender", void 0);
13571
13478
  /**
13572
- * hold a referenfce to a data structure that contains information
13479
+ * hold a reference to a data structure that contains information
13573
13480
  * on the current on going transform
13574
13481
  * @type
13575
13482
  * @private
@@ -13637,6 +13544,10 @@ class SelectableCanvas extends StaticCanvas$1 {
13637
13544
  }
13638
13545
  super._onObjectRemoved(obj);
13639
13546
  }
13547
+ _onStackOrderChanged() {
13548
+ this._objectsToRender = undefined;
13549
+ super._onStackOrderChanged();
13550
+ }
13640
13551
 
13641
13552
  /**
13642
13553
  * Divides objects in two groups, one to render immediately
@@ -13700,15 +13611,6 @@ class SelectableCanvas extends StaticCanvas$1 {
13700
13611
  });
13701
13612
  }
13702
13613
 
13703
- /**
13704
- * Given a pointer on the canvas with a viewport applied,
13705
- * find out the pointer in object coordinates
13706
- * @private
13707
- */
13708
- _normalizePointer(object, pointer) {
13709
- return transformPoint(this.restorePointerVpt(pointer), invertTransform(object.calcTransformMatrix()));
13710
- }
13711
-
13712
13614
  /**
13713
13615
  * Set the canvas tolerance value for pixel taret find.
13714
13616
  * Use only integer numbers.
@@ -13729,8 +13631,8 @@ class SelectableCanvas extends StaticCanvas$1 {
13729
13631
  * @TODO this seems dumb that we treat controls with transparency. we can find controls
13730
13632
  * programmatically without painting them, the cache canvas optimization is always valid
13731
13633
  * @param {FabricObject} target Object to check
13732
- * @param {Number} x Left coordinate
13733
- * @param {Number} y Top coordinate
13634
+ * @param {Number} x Left coordinate in viewport space
13635
+ * @param {Number} y Top coordinate in viewport space
13734
13636
  * @return {Boolean}
13735
13637
  */
13736
13638
  isTargetTransparent(target, x, y) {
@@ -13840,6 +13742,7 @@ class SelectableCanvas extends StaticCanvas$1 {
13840
13742
  * @param {FaricObject} target
13841
13743
  */
13842
13744
  _setupCurrentTransform(e, target, alreadySelected) {
13745
+ var _control$getActionHan;
13843
13746
  if (!target) {
13844
13747
  return;
13845
13748
  }
@@ -13848,7 +13751,7 @@ class SelectableCanvas extends StaticCanvas$1 {
13848
13751
  sendPointToPlane(this.getPointer(e), undefined, target.group.calcTransformMatrix()) : this.getPointer(e);
13849
13752
  const corner = target.getActiveControl() || '',
13850
13753
  control = !!corner && target.controls[corner],
13851
- actionHandler = alreadySelected && control ? control.getActionHandler(e, target, control) : dragHandler,
13754
+ actionHandler = alreadySelected && control ? (_control$getActionHan = control.getActionHandler(e, target, control)) === null || _control$getActionHan === void 0 ? void 0 : _control$getActionHan.bind(control) : dragHandler,
13852
13755
  action = getActionFromCorner(alreadySelected, corner, e, target),
13853
13756
  origin = this._getOriginFromCorner(target, corner),
13854
13757
  altKey = e[this.centeredKey],
@@ -13986,19 +13889,15 @@ class SelectableCanvas extends StaticCanvas$1 {
13986
13889
 
13987
13890
  /**
13988
13891
  * Checks point is inside the object.
13989
- * @param {Object} [pointer] x,y object of point coordinates we want to check.
13990
13892
  * @param {FabricObject} obj Object to test against
13991
- * @param {Object} [globalPointer] x,y object of point coordinates relative to canvas used to search per pixel target.
13893
+ * @param {Object} [pointer] point from viewport.
13992
13894
  * @return {Boolean} true if point is contained within an area of given object
13993
13895
  * @private
13994
13896
  */
13995
- _checkTarget(pointer, obj, globalPointer) {
13996
- if (obj && obj.visible && obj.evented &&
13997
- // http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html
13998
- // http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html
13999
- obj.containsPoint(pointer)) {
13897
+ _checkTarget(obj, pointer) {
13898
+ if (obj && obj.visible && obj.evented && obj.containsPoint(this.restorePointerVpt(pointer), true)) {
14000
13899
  if ((this.perPixelTargetFind || obj.perPixelTargetFind) && !obj.isEditing) {
14001
- if (!this.isTargetTransparent(obj, globalPointer.x, globalPointer.y)) {
13900
+ if (!this.isTargetTransparent(obj, pointer.x, pointer.y)) {
14002
13901
  return true;
14003
13902
  }
14004
13903
  } else {
@@ -14017,23 +13916,19 @@ class SelectableCanvas extends StaticCanvas$1 {
14017
13916
  */
14018
13917
  _searchPossibleTargets(objects, pointer) {
14019
13918
  // Cache all targets where their bounding box contains point.
14020
- let target,
14021
- i = objects.length;
13919
+ let i = objects.length;
14022
13920
  // Do not check for currently grouped objects, since we check the parent group itself.
14023
13921
  // until we call this function specifically to search inside the activeGroup
14024
13922
  while (i--) {
14025
- const objToCheck = objects[i];
14026
- const pointerToUse = objToCheck.group ? this._normalizePointer(objToCheck.group, pointer) : pointer;
14027
- if (this._checkTarget(pointerToUse, objToCheck, pointer)) {
14028
- target = objects[i];
13923
+ const target = objects[i];
13924
+ if (this._checkTarget(target, pointer)) {
14029
13925
  if (isCollection(target) && target.subTargetCheck) {
14030
13926
  const subTarget = this._searchPossibleTargets(target._objects, pointer);
14031
13927
  subTarget && this.targets.push(subTarget);
14032
13928
  }
14033
- break;
13929
+ return target;
14034
13930
  }
14035
13931
  }
14036
- return target;
14037
13932
  }
14038
13933
 
14039
13934
  /**
@@ -14053,6 +13948,7 @@ class SelectableCanvas extends StaticCanvas$1 {
14053
13948
 
14054
13949
  /**
14055
13950
  * Returns pointer coordinates without the effect of the viewport
13951
+ * Takes a point in html canvas space and gives you back a point of the scene.
14056
13952
  * @param {Object} pointer with "x" and "y" number values in canvas HTML coordinates
14057
13953
  * @return {Object} object with "x" and "y" number values in fabricCanvas coordinates
14058
13954
  */
@@ -14284,6 +14180,11 @@ class SelectableCanvas extends StaticCanvas$1 {
14284
14180
  return false;
14285
14181
  }
14286
14182
  this._activeObject = object;
14183
+ if (object instanceof ActiveSelection && this._activeSelection !== object) {
14184
+ this._activeSelection = object;
14185
+ object.set('canvas', this);
14186
+ object.setCoords();
14187
+ }
14287
14188
  return true;
14288
14189
  }
14289
14190
 
@@ -15183,7 +15084,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15183
15084
  const mouseUpHandler = control && control.getMouseUpHandler(e, target, control);
15184
15085
  if (mouseUpHandler) {
15185
15086
  pointer = this.getPointer(e);
15186
- mouseUpHandler(e, transform, pointer.x, pointer.y);
15087
+ mouseUpHandler.call(control, e, transform, pointer.x, pointer.y);
15187
15088
  }
15188
15089
  }
15189
15090
  target.isMoving = false;
@@ -15194,7 +15095,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15194
15095
  const originalControl = transform.target && transform.target.controls[transform.corner],
15195
15096
  originalMouseUpHandler = originalControl && originalControl.getMouseUpHandler(e, transform.target, originalControl);
15196
15097
  pointer = pointer || this.getPointer(e);
15197
- originalMouseUpHandler && originalMouseUpHandler(e, transform, pointer.x, pointer.y);
15098
+ originalMouseUpHandler && originalMouseUpHandler.call(originalControl, e, transform, pointer.x, pointer.y);
15198
15099
  }
15199
15100
  this._setCursorFromEvent(e, target);
15200
15101
  this._handleEvent(e, 'up', LEFT_CLICK, isClick);
@@ -15216,7 +15117,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15216
15117
  this.fire(eventType, options);
15217
15118
  target && target.fire(eventType, options);
15218
15119
  for (let i = 0; i < subTargets.length; i++) {
15219
- subTargets[i].fire(eventType, options);
15120
+ subTargets[i] !== target && subTargets[i].fire(eventType, options);
15220
15121
  }
15221
15122
  return options;
15222
15123
  }
@@ -15253,7 +15154,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15253
15154
  // this may be a little be more complicated of what we want to handle
15254
15155
  target && target.fire("mouse".concat(eventType), options);
15255
15156
  for (let i = 0; i < targets.length; i++) {
15256
- targets[i].fire("mouse".concat(eventType), options);
15157
+ targets[i] !== target && targets[i].fire("mouse".concat(eventType), options);
15257
15158
  }
15258
15159
  }
15259
15160
 
@@ -15425,7 +15326,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15425
15326
  pointer = this.getPointer(e),
15426
15327
  mouseDownHandler = control && control.getMouseDownHandler(e, target, control);
15427
15328
  if (mouseDownHandler) {
15428
- mouseDownHandler(e, this._currentTransform, pointer.x, pointer.y);
15329
+ mouseDownHandler.call(control, e, this._currentTransform, pointer.x, pointer.y);
15429
15330
  }
15430
15331
  }
15431
15332
  }
@@ -15600,7 +15501,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15600
15501
  pointer: this.getPointer(e, true),
15601
15502
  absolutePointer: this.getPointer(e)
15602
15503
  });
15603
- fireCanvas && this.fire(canvasIn, outOpt);
15504
+ fireCanvas && this.fire(canvasOut, outOpt);
15604
15505
  oldTarget.fire(targetOut, outOpt);
15605
15506
  }
15606
15507
  if (target && targetChanged) {
@@ -15612,7 +15513,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
15612
15513
  pointer: this.getPointer(e, true),
15613
15514
  absolutePointer: this.getPointer(e)
15614
15515
  });
15615
- fireCanvas && this.fire(canvasOut, inOpt);
15516
+ fireCanvas && this.fire(canvasIn, inOpt);
15616
15517
  target.fire(targetIn, inOpt);
15617
15518
  }
15618
15519
  }
@@ -16268,6 +16169,7 @@ _defineProperty(Gradient, "type", 'Gradient');
16268
16169
  classRegistry.setClass(Gradient, 'gradient');
16269
16170
 
16270
16171
  const _excluded$b = ["source"];
16172
+
16271
16173
  /**
16272
16174
  * @see {@link http://fabricjs.com/patterns demo}
16273
16175
  * @see {@link http://fabricjs.com/dynamic-patterns demo}
@@ -16285,7 +16187,7 @@ class Pattern {
16285
16187
  return 'pattern';
16286
16188
  }
16287
16189
  set type(value) {
16288
- console.warn('Setting type has no effect', value);
16190
+ log('warn', 'Setting type has no effect', value);
16289
16191
  }
16290
16192
 
16291
16193
  /**
@@ -19028,9 +18930,9 @@ function getMeasuringContext() {
19028
18930
  * Text class
19029
18931
  * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text}
19030
18932
  */
19031
- class Text extends StyledText {
18933
+ class FabricText extends StyledText {
19032
18934
  static getDefaults() {
19033
- return _objectSpread2(_objectSpread2({}, super.getDefaults()), Text.ownDefaults);
18935
+ return _objectSpread2(_objectSpread2({}, super.getDefaults()), FabricText.ownDefaults);
19034
18936
  }
19035
18937
  constructor(text) {
19036
18938
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -20077,7 +19979,7 @@ class Text extends StyledText {
20077
19979
  fontSize = this.fontSize
20078
19980
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
20079
19981
  let forMeasuring = arguments.length > 1 ? arguments[1] : undefined;
20080
- const parsedFontFamily = fontFamily.includes("'") || fontFamily.includes('"') || fontFamily.includes(',') || Text.genericFonts.includes(fontFamily.toLowerCase()) ? fontFamily : "\"".concat(fontFamily, "\"");
19982
+ const parsedFontFamily = fontFamily.includes("'") || fontFamily.includes('"') || fontFamily.includes(',') || FabricText.genericFonts.includes(fontFamily.toLowerCase()) ? fontFamily : "\"".concat(fontFamily, "\"");
20081
19983
  return [fontStyle, fontWeight, "".concat(forMeasuring ? this.CACHE_FONT_SIZE : fontSize, "px"), parsedFontFamily].join(' ');
20082
19984
  }
20083
19985
 
@@ -20183,14 +20085,14 @@ class Text extends StyledText {
20183
20085
  return 1;
20184
20086
  }
20185
20087
  /**
20186
- * Returns Text instance from an SVG element (<b>not yet implemented</b>)
20088
+ * Returns FabricText instance from an SVG element (<b>not yet implemented</b>)
20187
20089
  * @static
20188
20090
  * @memberOf Text
20189
20091
  * @param {HTMLElement} element Element to parse
20190
20092
  * @param {Object} [options] Options object
20191
20093
  */
20192
20094
  static async fromElement(element, options, cssRules) {
20193
- const parsedAttributes = parseAttributes(element, Text.ATTRIBUTE_NAMES, cssRules);
20095
+ const parsedAttributes = parseAttributes(element, FabricText.ATTRIBUTE_NAMES, cssRules);
20194
20096
  const _options$parsedAttrib = _objectSpread2(_objectSpread2({}, options), parsedAttributes),
20195
20097
  {
20196
20098
  textAnchor = LEFT,
@@ -20245,9 +20147,9 @@ class Text extends StyledText {
20245
20147
  /* _FROM_SVG_END_ */
20246
20148
 
20247
20149
  /**
20248
- * Returns Text instance from an object representation
20150
+ * Returns FabricText instance from an object representation
20249
20151
  * @param {Object} object plain js Object to create an instance from
20250
- * @returns {Promise<Text>}
20152
+ * @returns {Promise<FabricText>}
20251
20153
  */
20252
20154
  static fromObject(object) {
20253
20155
  return this._fromObject(_objectSpread2(_objectSpread2({}, object), {}, {
@@ -20262,22 +20164,22 @@ class Text extends StyledText {
20262
20164
  * @type string[]
20263
20165
  * @protected
20264
20166
  */
20265
- _defineProperty(Text, "textLayoutProperties", textLayoutProperties);
20266
- _defineProperty(Text, "cacheProperties", [...cacheProperties, ...additionalProps]);
20267
- _defineProperty(Text, "ownDefaults", textDefaultValues);
20268
- _defineProperty(Text, "type", 'Text');
20269
- _defineProperty(Text, "genericFonts", ['sans-serif', 'serif', 'cursive', 'fantasy', 'monospace']);
20167
+ _defineProperty(FabricText, "textLayoutProperties", textLayoutProperties);
20168
+ _defineProperty(FabricText, "cacheProperties", [...cacheProperties, ...additionalProps]);
20169
+ _defineProperty(FabricText, "ownDefaults", textDefaultValues);
20170
+ _defineProperty(FabricText, "type", 'Text');
20171
+ _defineProperty(FabricText, "genericFonts", ['sans-serif', 'serif', 'cursive', 'fantasy', 'monospace']);
20270
20172
  /* _FROM_SVG_START_ */
20271
20173
  /**
20272
- * List of attribute names to account for when parsing SVG element (used by {@link Text.fromElement})
20174
+ * List of attribute names to account for when parsing SVG element (used by {@link FabricText.fromElement})
20273
20175
  * @static
20274
20176
  * @memberOf Text
20275
20177
  * @see: http://www.w3.org/TR/SVG/text.html#TextElement
20276
20178
  */
20277
- _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'));
20278
- applyMixins(Text, [TextSVGExportMixin]);
20279
- classRegistry.setClass(Text);
20280
- classRegistry.setSVGClass(Text);
20179
+ _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'));
20180
+ applyMixins(FabricText, [TextSVGExportMixin]);
20181
+ classRegistry.setClass(FabricText);
20182
+ classRegistry.setSVGClass(FabricText);
20281
20183
 
20282
20184
  /**
20283
20185
  * #### Dragging IText/Textbox Lifecycle
@@ -20630,7 +20532,7 @@ class DraggableTextDelegate {
20630
20532
  * - `\-` Matches a "-" character (char code 45).
20631
20533
  */ // eslint-disable-next-line no-useless-escape
20632
20534
  const reNonWord = /[ \n\.,;!\?\-]/;
20633
- class ITextBehavior extends Text {
20535
+ class ITextBehavior extends FabricText {
20634
20536
  constructor() {
20635
20537
  super(...arguments);
20636
20538
  /**
@@ -22714,7 +22616,7 @@ class IText extends ITextClickBehavior {
22714
22616
  lineIndex = cursorLocation.lineIndex,
22715
22617
  charIndex = cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0,
22716
22618
  charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'),
22717
- multiplier = this.scaleX * this.canvas.getZoom(),
22619
+ multiplier = this.getObjectScaling().x * this.canvas.getZoom(),
22718
22620
  cursorWidth = this.cursorWidth / multiplier,
22719
22621
  dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'),
22720
22622
  topOffset = boundaries.topOffset + (1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex) / this.lineHeight - charHeight * (1 - this._fontSizeFraction);
@@ -23856,9 +23758,9 @@ const IMAGE_PROPS = ['cropX', 'cropY'];
23856
23758
  /**
23857
23759
  * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images}
23858
23760
  */
23859
- class Image extends FabricObject {
23761
+ class FabricImage extends FabricObject {
23860
23762
  static getDefaults() {
23861
- return _objectSpread2(_objectSpread2({}, super.getDefaults()), Image.ownDefaults);
23763
+ return _objectSpread2(_objectSpread2({}, super.getDefaults()), FabricImage.ownDefaults);
23862
23764
  }
23863
23765
  /**
23864
23766
  * Constructor
@@ -23876,7 +23778,7 @@ class Image extends FabricObject {
23876
23778
  filters: []
23877
23779
  }, options));
23878
23780
  /**
23879
- * When calling {@link Image.getSrc}, return value from element src with `element.getAttribute('src')`.
23781
+ * When calling {@link FabricImage.getSrc}, return value from element src with `element.getAttribute('src')`.
23880
23782
  * This allows for relative urls as image src.
23881
23783
  * @since 2.7.0
23882
23784
  * @type Boolean
@@ -23933,7 +23835,7 @@ class Image extends FabricObject {
23933
23835
  this._element = element;
23934
23836
  this._originalElement = element;
23935
23837
  this._setWidthHeight(size);
23936
- element.classList.add(Image.CSS_CANVAS);
23838
+ element.classList.add(FabricImage.CSS_CANVAS);
23937
23839
  if (this.filters.length !== 0) {
23938
23840
  this.applyFilters();
23939
23841
  }
@@ -24406,12 +24308,12 @@ class Image extends FabricObject {
24406
24308
  */
24407
24309
 
24408
24310
  /**
24409
- * Creates an instance of Image from its object representation
24311
+ * Creates an instance of FabricImage from its object representation
24410
24312
  * @static
24411
24313
  * @param {Object} object Object to create an instance from
24412
24314
  * @param {object} [options] Options object
24413
24315
  * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
24414
- * @returns {Promise<Image>}
24316
+ * @returns {Promise<FabricImage>}
24415
24317
  */
24416
24318
  static fromObject(_ref) {
24417
24319
  let {
@@ -24442,7 +24344,7 @@ class Image extends FabricObject {
24442
24344
  * @static
24443
24345
  * @param {String} url URL to create an image from
24444
24346
  * @param {LoadImageOptions} [options] Options object
24445
- * @returns {Promise<Image>}
24347
+ * @returns {Promise<FabricImage>}
24446
24348
  */
24447
24349
  static fromURL(url) {
24448
24350
  let {
@@ -24457,7 +24359,7 @@ class Image extends FabricObject {
24457
24359
  }
24458
24360
 
24459
24361
  /**
24460
- * Returns {@link Image} instance from an SVG element
24362
+ * Returns {@link FabricImage} instance from an SVG element
24461
24363
  * @static
24462
24364
  * @param {HTMLElement} element Element to parse
24463
24365
  * @param {Object} [options] Options object
@@ -24469,23 +24371,23 @@ class Image extends FabricObject {
24469
24371
  let cssRules = arguments.length > 2 ? arguments[2] : undefined;
24470
24372
  const parsedAttributes = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);
24471
24373
  return this.fromURL(parsedAttributes['xlink:href'], options, parsedAttributes).catch(err => {
24472
- console.log(err);
24374
+ log('log', 'Unable to parse Image', err);
24473
24375
  return null;
24474
24376
  });
24475
24377
  }
24476
24378
  }
24477
- _defineProperty(Image, "type", 'Image');
24478
- _defineProperty(Image, "cacheProperties", [...cacheProperties, ...IMAGE_PROPS]);
24479
- _defineProperty(Image, "ownDefaults", imageDefaultValues);
24480
- _defineProperty(Image, "CSS_CANVAS", 'canvas-img');
24379
+ _defineProperty(FabricImage, "type", 'Image');
24380
+ _defineProperty(FabricImage, "cacheProperties", [...cacheProperties, ...IMAGE_PROPS]);
24381
+ _defineProperty(FabricImage, "ownDefaults", imageDefaultValues);
24382
+ _defineProperty(FabricImage, "CSS_CANVAS", 'canvas-img');
24481
24383
  /**
24482
- * List of attribute names to account for when parsing SVG element (used by {@link Image.fromElement})
24384
+ * List of attribute names to account for when parsing SVG element (used by {@link FabricImage.fromElement})
24483
24385
  * @static
24484
24386
  * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}
24485
24387
  */
24486
- _defineProperty(Image, "ATTRIBUTE_NAMES", [...SHARED_ATTRIBUTES, 'x', 'y', 'width', 'height', 'preserveAspectRatio', 'xlink:href', 'crossOrigin', 'image-rendering']);
24487
- classRegistry.setClass(Image);
24488
- classRegistry.setSVGClass(Image);
24388
+ _defineProperty(FabricImage, "ATTRIBUTE_NAMES", [...SHARED_ATTRIBUTES, 'x', 'y', 'width', 'height', 'preserveAspectRatio', 'xlink:href', 'crossOrigin', 'image-rendering']);
24389
+ classRegistry.setClass(FabricImage);
24390
+ classRegistry.setSVGClass(FabricImage);
24489
24391
 
24490
24392
  /**
24491
24393
  * Add a <g> element that envelop all child elements and makes the viewbox transformMatrix descend on all elements
@@ -24621,25 +24523,6 @@ function hasInvalidAncestor(element) {
24621
24523
  return false;
24622
24524
  }
24623
24525
 
24624
- /**
24625
- * @private
24626
- * TODO: verify if this is still needed
24627
- * to support IE8 missing getElementById on SVGdocument and on node xmlDOM
24628
- */
24629
- function elementById(doc, id) {
24630
- if (doc.getElementById) {
24631
- return doc.getElementById(id);
24632
- }
24633
- const nodelist = doc.getElementsByTagName('*');
24634
- for (let i = 0, len = nodelist.length; i < len; i++) {
24635
- const node = nodelist[i];
24636
- if (id === node.getAttribute('id')) {
24637
- return node;
24638
- }
24639
- }
24640
- return null;
24641
- }
24642
-
24643
24526
  function getMultipleNodes(doc, nodeNames) {
24644
24527
  let nodeName,
24645
24528
  nodeArray = [],
@@ -24666,7 +24549,12 @@ function parseUseDirectives(doc) {
24666
24549
  const xlink = xlinkAttribute.slice(1);
24667
24550
  const x = el.getAttribute('x') || 0;
24668
24551
  const y = el.getAttribute('y') || 0;
24669
- let el2 = elementById(doc, xlink).cloneNode(true);
24552
+ const el2Orig = doc.getElementById(xlink);
24553
+ if (el2Orig === null) {
24554
+ // if we can't find the target of the xlink, consider this use tag bad, similar to no xlink
24555
+ return;
24556
+ }
24557
+ let el2 = el2Orig.cloneNode(true);
24670
24558
  let currentTrans = (el2.getAttribute('transform') || '') + ' translate(' + x + ', ' + y + ')';
24671
24559
  const oldLength = nodelist.length;
24672
24560
  const namespace = svgNS;
@@ -24718,7 +24606,7 @@ const xlinkAttr = 'xlink:href';
24718
24606
  function recursivelyParseGradientsXlink(doc, gradient) {
24719
24607
  var _gradient$getAttribut;
24720
24608
  const xLink = ((_gradient$getAttribut = gradient.getAttribute(xlinkAttr)) === null || _gradient$getAttribut === void 0 ? void 0 : _gradient$getAttribut.slice(1)) || '',
24721
- referencedGradient = elementById(doc, xLink);
24609
+ referencedGradient = doc.getElementById(xLink);
24722
24610
  if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {
24723
24611
  recursivelyParseGradientsXlink(doc, referencedGradient);
24724
24612
  }
@@ -24838,7 +24726,7 @@ class ElementsParser {
24838
24726
  const obj = await klass.fromElement(el, this.options, this.cssRules);
24839
24727
  this.resolveGradient(obj, el, 'fill');
24840
24728
  this.resolveGradient(obj, el, 'stroke');
24841
- if (obj instanceof Image && obj._originalElement) {
24729
+ if (obj instanceof FabricImage && obj._originalElement) {
24842
24730
  removeTransformMatrixForSvgParsing(obj, obj.parsePreserveAspectRatioAttribute());
24843
24731
  } else {
24844
24732
  removeTransformMatrixForSvgParsing(obj);
@@ -24957,7 +24845,7 @@ async function parseSVGDocument(doc, reviver) {
24957
24845
  signal
24958
24846
  } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
24959
24847
  if (signal && signal.aborted) {
24960
- console.log('`options.signal` is in `aborted` state');
24848
+ log('log', new SignalAbortedError('parseSVGDocument'));
24961
24849
  // this is an unhappy path, we dont care about speed
24962
24850
  return createEmptyResponse();
24963
24851
  }
@@ -25061,7 +24949,7 @@ const getSize = poly => {
25061
24949
  * This function locates the controls.
25062
24950
  * It'll be used both for drawing and for interaction.
25063
24951
  */
25064
- const factoryPolyPositionHandler = pointIndex => {
24952
+ const createPolyPositionHandler = pointIndex => {
25065
24953
  return function (dim, finalMatrix, polyObject) {
25066
24954
  var _polyObject$canvas$vi, _polyObject$canvas;
25067
24955
  const x = polyObject.points[pointIndex].x - polyObject.pathOffset.x,
@@ -25094,7 +24982,7 @@ const polyActionHandler = (eventData, transform, x, y) => {
25094
24982
  /**
25095
24983
  * Keep the polygon in the same position when we change its `width`/`height`/`top`/`left`.
25096
24984
  */
25097
- const anchorWrapper = (pointIndex, fn) => {
24985
+ const factoryPolyActionHandler = (pointIndex, fn) => {
25098
24986
  return function (eventData, transform, x, y) {
25099
24987
  const poly = transform.target,
25100
24988
  anchorPoint = new Point(poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1]),
@@ -25108,14 +24996,15 @@ const anchorWrapper = (pointIndex, fn) => {
25108
24996
  return actionPerformed;
25109
24997
  };
25110
24998
  };
24999
+ const createPolyActionHandler = pointIndex => factoryPolyActionHandler(pointIndex, polyActionHandler);
25111
25000
  function createPolyControls(arg0) {
25112
25001
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25113
25002
  const controls = {};
25114
25003
  for (let idx = 0; idx < (typeof arg0 === 'number' ? arg0 : arg0.points.length); idx++) {
25115
25004
  controls["p".concat(idx)] = new Control(_objectSpread2({
25116
25005
  actionName: 'modifyPoly',
25117
- positionHandler: factoryPolyPositionHandler(idx),
25118
- actionHandler: anchorWrapper(idx, polyActionHandler)
25006
+ positionHandler: createPolyPositionHandler(idx),
25007
+ actionHandler: createPolyActionHandler(idx)
25119
25008
  }, options));
25120
25009
  }
25121
25010
  return controls;
@@ -25125,11 +25014,15 @@ var index = /*#__PURE__*/Object.freeze({
25125
25014
  __proto__: null,
25126
25015
  changeWidth: changeWidth,
25127
25016
  createObjectDefaultControls: createObjectDefaultControls,
25017
+ createPolyActionHandler: createPolyActionHandler,
25128
25018
  createPolyControls: createPolyControls,
25019
+ createPolyPositionHandler: createPolyPositionHandler,
25129
25020
  createResizeControls: createResizeControls,
25130
25021
  createTextboxDefaultControls: createTextboxDefaultControls,
25131
25022
  dragHandler: dragHandler,
25023
+ factoryPolyActionHandler: factoryPolyActionHandler,
25132
25024
  getLocalPoint: getLocalPoint,
25025
+ polyActionHandler: polyActionHandler,
25133
25026
  renderCircleControl: renderCircleControl,
25134
25027
  renderSquareControl: renderSquareControl,
25135
25028
  rotationStyleHandler: rotationStyleHandler,
@@ -25224,25 +25117,23 @@ class BaseFilter {
25224
25117
  const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
25225
25118
  const program = gl.createProgram();
25226
25119
  if (!vertexShader || !fragmentShader || !program) {
25227
- throw new Error('Vertex, fragment shader or program creation error');
25120
+ throw new FabricError('Vertex, fragment shader or program creation error');
25228
25121
  }
25229
25122
  gl.shaderSource(vertexShader, vertexSource);
25230
25123
  gl.compileShader(vertexShader);
25231
25124
  if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
25232
- throw new Error("Vertex shader compile error for ".concat(this.type, ": ").concat(gl.getShaderInfoLog(vertexShader)));
25125
+ throw new FabricError("Vertex shader compile error for ".concat(this.type, ": ").concat(gl.getShaderInfoLog(vertexShader)));
25233
25126
  }
25234
25127
  gl.shaderSource(fragmentShader, fragmentSource);
25235
25128
  gl.compileShader(fragmentShader);
25236
25129
  if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
25237
- throw new Error("Fragment shader compile error for ".concat(this.type, ": ").concat(gl.getShaderInfoLog(fragmentShader)));
25130
+ throw new FabricError("Fragment shader compile error for ".concat(this.type, ": ").concat(gl.getShaderInfoLog(fragmentShader)));
25238
25131
  }
25239
25132
  gl.attachShader(program, vertexShader);
25240
25133
  gl.attachShader(program, fragmentShader);
25241
25134
  gl.linkProgram(program);
25242
25135
  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
25243
- throw new Error(
25244
- // eslint-disable-next-line prefer-template
25245
- 'Shader link error for "${this.type}" ' + gl.getProgramInfoLog(program));
25136
+ throw new FabricError("Shader link error for \"".concat(this.type, "\" ").concat(gl.getProgramInfoLog(program)));
25246
25137
  }
25247
25138
  const uniformLocations = this.getUniformLocations(gl, program) || {};
25248
25139
  uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');
@@ -25841,7 +25732,7 @@ class BlendImage extends BaseFilter {
25841
25732
  image
25842
25733
  } = _ref2,
25843
25734
  filterOptions = _objectWithoutProperties(_ref2, _excluded$3);
25844
- return Image.fromObject(image, options).then(enlivedImage => new this(_objectSpread2(_objectSpread2({}, filterOptions), {}, {
25735
+ return FabricImage.fromObject(image, options).then(enlivedImage => new this(_objectSpread2(_objectSpread2({}, filterOptions), {}, {
25845
25736
  image: enlivedImage
25846
25737
  })));
25847
25738
  }
@@ -27827,5 +27718,5 @@ class Canvas extends Canvas$1 {
27827
27718
  }
27828
27719
  }
27829
27720
 
27830
- export { ActiveSelection, BaseBrush, Canvas, Canvas2dFilterBackend, CanvasDOMManager, Circle, CircleBrush, Color, Control, Ellipse, Gradient, Group, IText, Image, Intersection, Line, FabricObject as Object, Observable, Path, Pattern, PatternBrush, PencilBrush, Point, Polygon, Polyline, Rect, Shadow, SprayBrush, StaticCanvas, StaticCanvasDOMManager, Text, Textbox, Triangle, WebGLFilterBackend, cache, classRegistry, config, index as controlsUtils, createCollectionMixin, filters, getCSSRules, getEnv$1 as getEnv, getFabricDocument, getFabricWindow, getFilterBackend, iMatrix, initFilterBackend, isWebGLPipelineState, loadSVGFromString, loadSVGFromURL, parseAttributes, parseFontDeclaration, parsePointsAttribute, parseSVGDocument, parseStyleAttribute, parseTransformAttribute, runningAnimations, setEnv, setFilterBackend, index$1 as util, VERSION as version };
27721
+ export { ActiveSelection, BaseBrush, Canvas, Canvas2dFilterBackend, CanvasDOMManager, Circle, CircleBrush, Color, Control, Ellipse, FabricImage, FabricObject, FabricText, Gradient, Group, IText, FabricImage as Image, Intersection, Line, FabricObject as Object, Observable, Path, Pattern, PatternBrush, PencilBrush, Point, Polygon, Polyline, Rect, Shadow, SprayBrush, StaticCanvas, StaticCanvasDOMManager, FabricText as Text, Textbox, Triangle, WebGLFilterBackend, cache, classRegistry, config, index as controlsUtils, createCollectionMixin, filters, getCSSRules, getEnv$1 as getEnv, getFabricDocument, getFabricWindow, getFilterBackend, iMatrix, initFilterBackend, isWebGLPipelineState, loadSVGFromString, loadSVGFromURL, parseAttributes, parseFontDeclaration, parsePointsAttribute, parseSVGDocument, parseStyleAttribute, parseTransformAttribute, runningAnimations, setEnv, setFilterBackend, index$1 as util, VERSION as version };
27831
27722
  //# sourceMappingURL=index.node.mjs.map