fabric 6.0.0 → 6.0.2

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 (269) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +8 -18
  3. package/dist/fabric.d.ts +4 -0
  4. package/dist/fabric.d.ts.map +1 -1
  5. package/dist/fabric.min.mjs +1 -1
  6. package/dist/fabric.mjs +1 -0
  7. package/dist/fabric.mjs.map +1 -1
  8. package/dist/index.js +146 -107
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.min.js +1 -1
  11. package/dist/index.min.js.map +1 -1
  12. package/dist/index.min.mjs +1 -1
  13. package/dist/index.min.mjs.map +1 -1
  14. package/dist/index.mjs +146 -108
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/index.node.cjs +146 -107
  17. package/dist/index.node.cjs.map +1 -1
  18. package/dist/index.node.mjs +146 -108
  19. package/dist/index.node.mjs.map +1 -1
  20. package/dist/package.json.min.mjs +1 -1
  21. package/dist/package.json.mjs +1 -1
  22. package/dist/src/EventTypeDefs.d.ts +2 -1
  23. package/dist/src/EventTypeDefs.d.ts.map +1 -1
  24. package/dist/src/LayoutManager/LayoutManager.d.ts.map +1 -1
  25. package/dist/src/LayoutManager/LayoutManager.min.mjs +1 -1
  26. package/dist/src/LayoutManager/LayoutManager.min.mjs.map +1 -1
  27. package/dist/src/LayoutManager/LayoutManager.mjs +13 -8
  28. package/dist/src/LayoutManager/LayoutManager.mjs.map +1 -1
  29. package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.min.mjs +1 -1
  30. package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.min.mjs.map +1 -1
  31. package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.mjs +3 -3
  32. package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.mjs.map +1 -1
  33. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.d.ts +1 -1
  34. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.d.ts.map +1 -1
  35. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.min.mjs +1 -1
  36. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.min.mjs.map +1 -1
  37. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.mjs +15 -9
  38. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.mjs.map +1 -1
  39. package/dist/src/Observable.d.ts +8 -0
  40. package/dist/src/Observable.d.ts.map +1 -1
  41. package/dist/src/Observable.min.mjs.map +1 -1
  42. package/dist/src/Observable.mjs +8 -0
  43. package/dist/src/Observable.mjs.map +1 -1
  44. package/dist/src/canvas/SelectableCanvas.d.ts.map +1 -1
  45. package/dist/src/canvas/SelectableCanvas.min.mjs +1 -1
  46. package/dist/src/canvas/SelectableCanvas.min.mjs.map +1 -1
  47. package/dist/src/canvas/SelectableCanvas.mjs +5 -5
  48. package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
  49. package/dist/src/canvas/StaticCanvas.d.ts +1 -1
  50. package/dist/src/constants.d.ts +16 -0
  51. package/dist/src/constants.d.ts.map +1 -1
  52. package/dist/src/constants.min.mjs +1 -1
  53. package/dist/src/constants.min.mjs.map +1 -1
  54. package/dist/src/constants.mjs +17 -1
  55. package/dist/src/constants.mjs.map +1 -1
  56. package/dist/src/controls/Control.d.ts.map +1 -1
  57. package/dist/src/controls/Control.min.mjs +1 -1
  58. package/dist/src/controls/Control.min.mjs.map +1 -1
  59. package/dist/src/controls/Control.mjs +2 -1
  60. package/dist/src/controls/Control.mjs.map +1 -1
  61. package/dist/src/controls/changeWidth.min.mjs +1 -1
  62. package/dist/src/controls/changeWidth.min.mjs.map +1 -1
  63. package/dist/src/controls/changeWidth.mjs +2 -2
  64. package/dist/src/controls/changeWidth.mjs.map +1 -1
  65. package/dist/src/controls/commonControls.d.ts.map +1 -1
  66. package/dist/src/controls/commonControls.min.mjs +1 -1
  67. package/dist/src/controls/commonControls.min.mjs.map +1 -1
  68. package/dist/src/controls/commonControls.mjs +4 -3
  69. package/dist/src/controls/commonControls.mjs.map +1 -1
  70. package/dist/src/controls/controlRendering.min.mjs +1 -1
  71. package/dist/src/controls/controlRendering.min.mjs.map +1 -1
  72. package/dist/src/controls/controlRendering.mjs +3 -3
  73. package/dist/src/controls/controlRendering.mjs.map +1 -1
  74. package/dist/src/controls/drag.min.mjs +1 -1
  75. package/dist/src/controls/drag.min.mjs.map +1 -1
  76. package/dist/src/controls/drag.mjs +2 -2
  77. package/dist/src/controls/drag.mjs.map +1 -1
  78. package/dist/src/controls/polyControl.d.ts.map +1 -1
  79. package/dist/src/controls/polyControl.min.mjs +1 -1
  80. package/dist/src/controls/polyControl.min.mjs.map +1 -1
  81. package/dist/src/controls/polyControl.mjs +2 -1
  82. package/dist/src/controls/polyControl.mjs.map +1 -1
  83. package/dist/src/controls/rotate.d.ts.map +1 -1
  84. package/dist/src/controls/rotate.min.mjs +1 -1
  85. package/dist/src/controls/rotate.min.mjs.map +1 -1
  86. package/dist/src/controls/rotate.mjs +2 -1
  87. package/dist/src/controls/rotate.mjs.map +1 -1
  88. package/dist/src/controls/scale.d.ts.map +1 -1
  89. package/dist/src/controls/scale.min.mjs +1 -1
  90. package/dist/src/controls/scale.min.mjs.map +1 -1
  91. package/dist/src/controls/scale.mjs +8 -7
  92. package/dist/src/controls/scale.mjs.map +1 -1
  93. package/dist/src/controls/scaleSkew.d.ts.map +1 -1
  94. package/dist/src/controls/scaleSkew.min.mjs +1 -1
  95. package/dist/src/controls/scaleSkew.min.mjs.map +1 -1
  96. package/dist/src/controls/scaleSkew.mjs +3 -2
  97. package/dist/src/controls/scaleSkew.mjs.map +1 -1
  98. package/dist/src/controls/skew.d.ts.map +1 -1
  99. package/dist/src/controls/skew.min.mjs +1 -1
  100. package/dist/src/controls/skew.min.mjs.map +1 -1
  101. package/dist/src/controls/skew.mjs +7 -7
  102. package/dist/src/controls/skew.mjs.map +1 -1
  103. package/dist/src/filters/Blur.min.mjs +1 -1
  104. package/dist/src/filters/Blur.min.mjs.map +1 -1
  105. package/dist/src/filters/Blur.mjs +1 -1
  106. package/dist/src/filters/Blur.mjs.map +1 -1
  107. package/dist/src/filters/Pixelate.min.mjs +1 -1
  108. package/dist/src/filters/Pixelate.min.mjs.map +1 -1
  109. package/dist/src/filters/Pixelate.mjs +1 -1
  110. package/dist/src/filters/Pixelate.mjs.map +1 -1
  111. package/dist/src/parser/attributes.d.ts.map +1 -1
  112. package/dist/src/parser/attributes.min.mjs +1 -1
  113. package/dist/src/parser/attributes.min.mjs.map +1 -1
  114. package/dist/src/parser/attributes.mjs +3 -1
  115. package/dist/src/parser/attributes.mjs.map +1 -1
  116. package/dist/src/parser/elements_parser.min.mjs +1 -1
  117. package/dist/src/parser/elements_parser.min.mjs.map +1 -1
  118. package/dist/src/parser/elements_parser.mjs +3 -3
  119. package/dist/src/parser/elements_parser.mjs.map +1 -1
  120. package/dist/src/parser/normalizeValue.min.mjs +1 -1
  121. package/dist/src/parser/normalizeValue.min.mjs.map +1 -1
  122. package/dist/src/parser/normalizeValue.mjs +7 -7
  123. package/dist/src/parser/normalizeValue.mjs.map +1 -1
  124. package/dist/src/parser/parseTransformAttribute.min.mjs +1 -1
  125. package/dist/src/parser/parseTransformAttribute.min.mjs.map +1 -1
  126. package/dist/src/parser/parseTransformAttribute.mjs +5 -5
  127. package/dist/src/parser/parseTransformAttribute.mjs.map +1 -1
  128. package/dist/src/shapes/Circle.d.ts.map +1 -1
  129. package/dist/src/shapes/Circle.min.mjs +1 -1
  130. package/dist/src/shapes/Circle.min.mjs.map +1 -1
  131. package/dist/src/shapes/Circle.mjs +3 -2
  132. package/dist/src/shapes/Circle.mjs.map +1 -1
  133. package/dist/src/shapes/Ellipse.min.mjs +1 -1
  134. package/dist/src/shapes/Ellipse.min.mjs.map +1 -1
  135. package/dist/src/shapes/Ellipse.mjs +3 -3
  136. package/dist/src/shapes/Ellipse.mjs.map +1 -1
  137. package/dist/src/shapes/IText/DraggableTextDelegate.min.mjs +1 -1
  138. package/dist/src/shapes/IText/DraggableTextDelegate.min.mjs.map +1 -1
  139. package/dist/src/shapes/IText/DraggableTextDelegate.mjs +3 -3
  140. package/dist/src/shapes/IText/DraggableTextDelegate.mjs.map +1 -1
  141. package/dist/src/shapes/IText/IText.min.mjs +1 -1
  142. package/dist/src/shapes/IText/IText.min.mjs.map +1 -1
  143. package/dist/src/shapes/IText/IText.mjs +3 -3
  144. package/dist/src/shapes/IText/IText.mjs.map +1 -1
  145. package/dist/src/shapes/IText/ITextBehavior.min.mjs +1 -1
  146. package/dist/src/shapes/IText/ITextBehavior.min.mjs.map +1 -1
  147. package/dist/src/shapes/IText/ITextBehavior.mjs +2 -2
  148. package/dist/src/shapes/IText/ITextBehavior.mjs.map +1 -1
  149. package/dist/src/shapes/IText/ITextKeyBehavior.min.mjs +1 -1
  150. package/dist/src/shapes/IText/ITextKeyBehavior.min.mjs.map +1 -1
  151. package/dist/src/shapes/IText/ITextKeyBehavior.mjs +2 -2
  152. package/dist/src/shapes/IText/ITextKeyBehavior.mjs.map +1 -1
  153. package/dist/src/shapes/Image.min.mjs +1 -1
  154. package/dist/src/shapes/Image.min.mjs.map +1 -1
  155. package/dist/src/shapes/Image.mjs +2 -2
  156. package/dist/src/shapes/Image.mjs.map +1 -1
  157. package/dist/src/shapes/Object/AnimatableObject.d.ts.map +1 -1
  158. package/dist/src/shapes/Object/AnimatableObject.min.mjs +1 -1
  159. package/dist/src/shapes/Object/AnimatableObject.min.mjs.map +1 -1
  160. package/dist/src/shapes/Object/AnimatableObject.mjs +2 -1
  161. package/dist/src/shapes/Object/AnimatableObject.mjs.map +1 -1
  162. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
  163. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs +1 -1
  164. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs.map +1 -1
  165. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs +4 -4
  166. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs.map +1 -1
  167. package/dist/src/shapes/Object/InteractiveObject.d.ts.map +1 -1
  168. package/dist/src/shapes/Object/InteractiveObject.min.mjs +1 -1
  169. package/dist/src/shapes/Object/InteractiveObject.min.mjs.map +1 -1
  170. package/dist/src/shapes/Object/InteractiveObject.mjs +2 -1
  171. package/dist/src/shapes/Object/InteractiveObject.mjs.map +1 -1
  172. package/dist/src/shapes/Object/Object.d.ts +9 -7
  173. package/dist/src/shapes/Object/Object.d.ts.map +1 -1
  174. package/dist/src/shapes/Object/Object.min.mjs +1 -1
  175. package/dist/src/shapes/Object/Object.min.mjs.map +1 -1
  176. package/dist/src/shapes/Object/Object.mjs +14 -12
  177. package/dist/src/shapes/Object/Object.mjs.map +1 -1
  178. package/dist/src/shapes/Object/ObjectGeometry.min.mjs +1 -1
  179. package/dist/src/shapes/Object/ObjectGeometry.min.mjs.map +1 -1
  180. package/dist/src/shapes/Object/ObjectGeometry.mjs +3 -3
  181. package/dist/src/shapes/Object/ObjectGeometry.mjs.map +1 -1
  182. package/dist/src/shapes/Object/defaultValues.d.ts.map +1 -1
  183. package/dist/src/shapes/Object/defaultValues.min.mjs +1 -1
  184. package/dist/src/shapes/Object/defaultValues.min.mjs.map +1 -1
  185. package/dist/src/shapes/Object/defaultValues.mjs +4 -4
  186. package/dist/src/shapes/Object/defaultValues.mjs.map +1 -1
  187. package/dist/src/shapes/Object/types/ControlProps.d.ts +4 -3
  188. package/dist/src/shapes/Object/types/ControlProps.d.ts.map +1 -1
  189. package/dist/src/shapes/Polyline.d.ts.map +1 -1
  190. package/dist/src/shapes/Polyline.min.mjs +1 -1
  191. package/dist/src/shapes/Polyline.min.mjs.map +1 -1
  192. package/dist/src/shapes/Polyline.mjs +3 -3
  193. package/dist/src/shapes/Polyline.mjs.map +1 -1
  194. package/dist/src/shapes/Text/Text.d.ts +2 -2
  195. package/dist/src/shapes/Text/Text.d.ts.map +1 -1
  196. package/dist/src/shapes/Text/Text.min.mjs +1 -1
  197. package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
  198. package/dist/src/shapes/Text/Text.mjs +5 -5
  199. package/dist/src/shapes/Text/Text.mjs.map +1 -1
  200. package/dist/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
  201. package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs +1 -1
  202. package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs.map +1 -1
  203. package/dist/src/shapes/Text/TextSVGExportMixin.mjs +2 -1
  204. package/dist/src/shapes/Text/TextSVGExportMixin.mjs.map +1 -1
  205. package/dist/src/shapes/Text/constants.min.mjs +1 -1
  206. package/dist/src/shapes/Text/constants.min.mjs.map +1 -1
  207. package/dist/src/shapes/Text/constants.mjs +2 -2
  208. package/dist/src/shapes/Text/constants.mjs.map +1 -1
  209. package/dist/src/util/misc/objectEnlive.d.ts +1 -0
  210. package/dist/src/util/misc/objectEnlive.d.ts.map +1 -1
  211. package/dist/src/util/misc/objectEnlive.min.mjs.map +1 -1
  212. package/dist/src/util/misc/objectEnlive.mjs +1 -0
  213. package/dist/src/util/misc/objectEnlive.mjs.map +1 -1
  214. package/dist/src/util/misc/svgParsing.min.mjs +1 -1
  215. package/dist/src/util/misc/svgParsing.min.mjs.map +1 -1
  216. package/dist/src/util/misc/svgParsing.mjs +2 -2
  217. package/dist/src/util/misc/svgParsing.mjs.map +1 -1
  218. package/dist/src/util/transform_matrix_removal.min.mjs +1 -1
  219. package/dist/src/util/transform_matrix_removal.min.mjs.map +1 -1
  220. package/dist/src/util/transform_matrix_removal.mjs +3 -3
  221. package/dist/src/util/transform_matrix_removal.mjs.map +1 -1
  222. package/fabric.ts +4 -0
  223. package/package.json +1 -1
  224. package/src/EventTypeDefs.ts +14 -6
  225. package/src/LayoutManager/LayoutManager.ts +28 -19
  226. package/src/LayoutManager/LayoutStrategies/ClipPathLayout.ts +2 -2
  227. package/src/LayoutManager/LayoutStrategies/LayoutStrategy.ts +7 -7
  228. package/src/Observable.ts +8 -0
  229. package/src/canvas/SelectableCanvas.ts +25 -11
  230. package/src/canvas/canvas_gestures.mixin.ts +6 -5
  231. package/src/constants.ts +17 -0
  232. package/src/controls/Control.ts +2 -1
  233. package/src/controls/changeWidth.ts +2 -2
  234. package/src/controls/commonControls.ts +4 -3
  235. package/src/controls/controlRendering.ts +3 -3
  236. package/src/controls/drag.ts +2 -2
  237. package/src/controls/polyControl.ts +2 -1
  238. package/src/controls/rotate.ts +2 -1
  239. package/src/controls/scale.ts +8 -7
  240. package/src/controls/scaleSkew.ts +3 -2
  241. package/src/controls/skew.ts +14 -7
  242. package/src/filters/Blur.ts +1 -1
  243. package/src/filters/Pixelate.ts +1 -1
  244. package/src/parser/attributes.ts +4 -2
  245. package/src/parser/elements_parser.ts +3 -3
  246. package/src/parser/normalizeValue.ts +7 -7
  247. package/src/parser/parseTransformAttribute.ts +5 -5
  248. package/src/shapes/Circle.ts +3 -2
  249. package/src/shapes/Ellipse.ts +3 -3
  250. package/src/shapes/IText/DraggableTextDelegate.ts +3 -3
  251. package/src/shapes/IText/IText.ts +3 -3
  252. package/src/shapes/IText/ITextBehavior.ts +2 -2
  253. package/src/shapes/IText/ITextKeyBehavior.ts +2 -2
  254. package/src/shapes/Image.ts +2 -2
  255. package/src/shapes/Object/AnimatableObject.ts +2 -1
  256. package/src/shapes/Object/FabricObjectSVGExportMixin.ts +4 -6
  257. package/src/shapes/Object/InteractiveObject.ts +2 -1
  258. package/src/shapes/Object/Object.ts +16 -11
  259. package/src/shapes/Object/ObjectGeometry.ts +3 -3
  260. package/src/shapes/Object/defaultValues.ts +17 -8
  261. package/src/shapes/Object/types/ControlProps.ts +4 -3
  262. package/src/shapes/Polyline.spec.ts +0 -1
  263. package/src/shapes/Polyline.ts +12 -4
  264. package/src/shapes/Text/Text.ts +7 -7
  265. package/src/shapes/Text/TextSVGExportMixin.ts +3 -2
  266. package/src/shapes/Text/constants.ts +3 -3
  267. package/src/util/misc/objectEnlive.ts +1 -0
  268. package/src/util/misc/svgParsing.ts +2 -2
  269. package/src/util/transform_matrix_removal.ts +3 -3
@@ -459,7 +459,7 @@ class Cache {
459
459
  }
460
460
  const cache = new Cache();
461
461
 
462
- var version = "6.0.0";
462
+ var version = "6.0.2";
463
463
 
464
464
  // use this syntax so babel plugin see this import here
465
465
  const VERSION = version;
@@ -481,6 +481,22 @@ const BOTTOM = 'bottom';
481
481
  const RIGHT = 'right';
482
482
  const NONE = 'none';
483
483
  const reNewline = /\r?\n/;
484
+ const MOVING = 'moving';
485
+ const SCALING = 'scaling';
486
+ const ROTATING = 'rotating';
487
+ const ROTATE = 'rotate';
488
+ const SKEWING = 'skewing';
489
+ const RESIZING = 'resizing';
490
+ const MODIFY_POLY = 'modifyPoly';
491
+ const CHANGED = 'changed';
492
+ const SCALE = 'scale';
493
+ const SCALE_X = 'scaleX';
494
+ const SCALE_Y = 'scaleY';
495
+ const SKEW_X = 'skewX';
496
+ const SKEW_Y = 'skewY';
497
+ const FILL = 'fill';
498
+ const STROKE = 'stroke';
499
+ const MODIFIED = 'modified';
484
500
 
485
501
  /*
486
502
  * This Map connects the objects type value with their
@@ -671,6 +687,14 @@ class Observable {
671
687
  }
672
688
  }
673
689
 
690
+ /**
691
+ * Unsubscribe all event listeners for eventname.
692
+ * Do not use this pattern. You could kill internal fabricJS events.
693
+ * We know we should have protected events for internal flows, but we don't have yet
694
+ * @deprecated
695
+ * @param {string} eventName event name (eg. 'after:render')
696
+ */
697
+
674
698
  /**
675
699
  * unsubscribe an event listener
676
700
  * @param {string} eventName event name (eg. 'after:render')
@@ -1929,6 +1953,7 @@ const loadImage = function (url) {
1929
1953
  });
1930
1954
  };
1931
1955
  /**
1956
+ * @TODO type this correctly.
1932
1957
  * Creates corresponding fabric instances from their object representations
1933
1958
  * @param {Object[]} objects Objects to enliven
1934
1959
  * @param {EnlivenObjectOptions} [options]
@@ -2839,7 +2864,7 @@ const createSVGRect = function (color, _ref) {
2839
2864
  height
2840
2865
  } = _ref;
2841
2866
  let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : config.NUM_FRACTION_DIGITS;
2842
- const svgColor = colorPropToSVG('fill', color, false);
2867
+ const svgColor = colorPropToSVG(FILL, color, false);
2843
2868
  const [x, y, w, h] = [left, top, width, height].map(value => toFixed(value, precision));
2844
2869
  return "<rect ".concat(svgColor, " x=\"").concat(x, "\" y=\"").concat(y, "\" width=\"").concat(w, "\" height=\"").concat(h, "\"></rect>");
2845
2870
  };
@@ -4741,7 +4766,7 @@ const dragHandler = (eventData, transform, x, y) => {
4741
4766
  moveX && target.set(LEFT, newLeft);
4742
4767
  moveY && target.set(TOP, newTop);
4743
4768
  if (moveX || moveY) {
4744
- fireEvent('moving', commonEventInfo(eventData, transform, x, y));
4769
+ fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));
4745
4770
  }
4746
4771
  return moveX || moveY;
4747
4772
  };
@@ -4769,8 +4794,8 @@ class FabricObjectSVGExportMixin {
4769
4794
  opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',
4770
4795
  visibility = this.visible ? '' : ' visibility: hidden;',
4771
4796
  filter = skipShadow ? '' : this.getSvgFilter(),
4772
- fill = colorPropToSVG('fill', this.fill),
4773
- stroke = colorPropToSVG('stroke', this.stroke);
4797
+ fill = colorPropToSVG(FILL, this.fill),
4798
+ stroke = colorPropToSVG(STROKE, this.stroke);
4774
4799
  return [stroke, 'stroke-width: ', strokeWidth, '; ', 'stroke-dasharray: ', strokeDashArray, '; ', 'stroke-linecap: ', strokeLineCap, '; ', 'stroke-dashoffset: ', strokeDashOffset, '; ', 'stroke-linejoin: ', strokeLineJoin, '; ', 'stroke-miterlimit: ', strokeMiterLimit, '; ', fill, 'fill-rule: ', fillRule, '; ', 'opacity: ', opacity, ';', filter, visibility].join('');
4775
4800
  }
4776
4801
 
@@ -4900,7 +4925,7 @@ class FabricObjectSVGExportMixin {
4900
4925
  return reviver ? reviver(markup.join('')) : markup.join('');
4901
4926
  }
4902
4927
  addPaintOrder() {
4903
- return this.paintFirst !== 'fill' ? " paint-order=\"".concat(this.paintFirst, "\" ") : '';
4928
+ return this.paintFirst !== FILL ? " paint-order=\"".concat(this.paintFirst, "\" ") : '';
4904
4929
  }
4905
4930
  }
4906
4931
 
@@ -6288,8 +6313,8 @@ class ObjectGeometry extends ObjectOrigin {
6288
6313
  * @return {void}
6289
6314
  */
6290
6315
  scale(value) {
6291
- this._set('scaleX', value);
6292
- this._set('scaleY', value);
6316
+ this._set(SCALE_X, value);
6317
+ this._set(SCALE_Y, value);
6293
6318
  this.setCoords();
6294
6319
  }
6295
6320
 
@@ -6676,7 +6701,7 @@ class AnimatableObject extends StackedObject {
6676
6701
  * List of properties to consider for animating colors.
6677
6702
  * @type String[]
6678
6703
  */
6679
- _defineProperty(AnimatableObject, "colorProperties", ['fill', 'stroke', 'backgroundColor']);
6704
+ _defineProperty(AnimatableObject, "colorProperties", [FILL, STROKE, 'backgroundColor']);
6680
6705
 
6681
6706
  function getSvgRegex(arr) {
6682
6707
  return new RegExp('^(' + arr.join('|') + ')\\b', 'i');
@@ -6892,8 +6917,8 @@ classRegistry.setClass(Shadow, 'shadow');
6892
6917
 
6893
6918
  const cloneDeep = object => JSON.parse(JSON.stringify(object));
6894
6919
 
6895
- const stateProperties = [TOP, LEFT, 'scaleX', 'scaleY', 'flipX', 'flipY', 'originX', 'originY', 'angle', 'opacity', 'globalCompositeOperation', 'shadow', 'visible', 'skewX', 'skewY'];
6896
- const cacheProperties = ['fill', 'stroke', 'strokeWidth', 'strokeDashArray', 'width', 'height', 'paintFirst', 'strokeUniform', 'strokeLineCap', 'strokeDashOffset', 'strokeLineJoin', 'strokeMiterLimit', 'backgroundColor', 'clipPath'];
6920
+ const stateProperties = [TOP, LEFT, SCALE_X, SCALE_Y, 'flipX', 'flipY', 'originX', 'originY', 'angle', 'opacity', 'globalCompositeOperation', 'shadow', 'visible', SKEW_X, SKEW_Y];
6921
+ const cacheProperties = [FILL, STROKE, 'strokeWidth', 'strokeDashArray', 'width', 'height', 'paintFirst', 'strokeUniform', 'strokeLineCap', 'strokeDashOffset', 'strokeLineJoin', 'strokeMiterLimit', 'backgroundColor', 'clipPath'];
6897
6922
  const fabricObjectDefaultValues = {
6898
6923
  // see composeMatrix() to see order of transforms. First defaults listed based on this
6899
6924
  top: 0,
@@ -6914,7 +6939,7 @@ const fabricObjectDefaultValues = {
6914
6939
  strokeUniform: false,
6915
6940
  padding: 0,
6916
6941
  opacity: 1,
6917
- paintFirst: 'fill',
6942
+ paintFirst: FILL,
6918
6943
  fill: 'rgb(0,0,0)',
6919
6944
  fillRule: 'nonzero',
6920
6945
  stroke: null,
@@ -7005,18 +7030,20 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7005
7030
  }
7006
7031
 
7007
7032
  /**
7008
- * The class type. Used to identify which class this is.
7009
- * This is used for serialization purposes and internally it can be used
7010
- * to identify classes. As a developer you could use `instance of Class`
7011
- * but to avoid importing all the code and blocking tree shaking we try
7012
- * to avoid doing that.
7033
+ * The class type.
7034
+ * This is used for serialization and deserialization purposes and internally it can be used
7035
+ * to identify classes.
7036
+ * When we transform a class in a plain JS object we need a way to recognize which class it was,
7037
+ * and the type is the way we do that. It has no other purposes and you should not give one.
7038
+ * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).
7039
+ * To idenfity a class use instanceof class ( instanceof Rect ).
7040
+ * We do not do that in fabricJS code because we want to try to have code splitting possible.
7013
7041
  */
7014
7042
 
7015
7043
  /**
7016
7044
  * Legacy identifier of the class. Prefer using utils like isType or instanceOf
7017
7045
  * Will be removed in fabric 7 or 8.
7018
- * The setter exists because is very hard to catch all the ways in which a type value
7019
- * could be set in the instance
7046
+ * The setter exists to avoid type errors in old code and possibly current deserialization code.
7020
7047
  * @TODO add sustainable warning message
7021
7048
  * @type string
7022
7049
  * @deprecated
@@ -7387,10 +7414,10 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7387
7414
  * @param {*} value
7388
7415
  */
7389
7416
  _set(key, value) {
7390
- if (key === 'scaleX' || key === 'scaleY') {
7417
+ if (key === SCALE_X || key === SCALE_Y) {
7391
7418
  value = this._constrainScale(value);
7392
7419
  }
7393
- if (key === 'scaleX' && value < 0) {
7420
+ if (key === SCALE_X && value < 0) {
7394
7421
  this.flipX = !this.flipX;
7395
7422
  value *= -1;
7396
7423
  } else if (key === 'scaleY' && value < 0) {
@@ -7511,7 +7538,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7511
7538
  * @returns Boolean
7512
7539
  */
7513
7540
  needsItsOwnCache() {
7514
- if (this.paintFirst === 'stroke' && this.hasFill() && this.hasStroke() && !!this.shadow) {
7541
+ if (this.paintFirst === STROKE && this.hasFill() && this.hasStroke() && !!this.shadow) {
7515
7542
  return true;
7516
7543
  }
7517
7544
  if (this.clipPath) {
@@ -7806,7 +7833,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7806
7833
  * @param {CanvasRenderingContext2D} ctx Context to render on
7807
7834
  */
7808
7835
  _renderPaintInOrder(ctx) {
7809
- if (this.paintFirst === 'stroke') {
7836
+ if (this.paintFirst === STROKE) {
7810
7837
  this._renderStroke(ctx);
7811
7838
  this._renderFill(ctx);
7812
7839
  } else {
@@ -8283,7 +8310,7 @@ const changeObjectWidth = (eventData, transform, x, y) => {
8283
8310
  }
8284
8311
  return false;
8285
8312
  };
8286
- const changeWidth = wrapWithFireEvent('resizing', wrapWithFixedAnchor(changeObjectWidth));
8313
+ const changeWidth = wrapWithFireEvent(RESIZING, wrapWithFixedAnchor(changeObjectWidth));
8287
8314
 
8288
8315
  /**
8289
8316
  * Render a round control, as per fabric features.
@@ -8301,7 +8328,7 @@ function renderCircleControl(ctx, left, top, styleOverride, fabricObject) {
8301
8328
  const xSize = this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,
8302
8329
  ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,
8303
8330
  transparentCorners = typeof styleOverride.transparentCorners !== 'undefined' ? styleOverride.transparentCorners : fabricObject.transparentCorners,
8304
- methodName = transparentCorners ? 'stroke' : 'fill',
8331
+ methodName = transparentCorners ? STROKE : FILL,
8305
8332
  stroke = !transparentCorners && (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);
8306
8333
  let myLeft = left,
8307
8334
  myTop = top,
@@ -8348,7 +8375,7 @@ function renderSquareControl(ctx, left, top, styleOverride, fabricObject) {
8348
8375
  const xSize = this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,
8349
8376
  ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,
8350
8377
  transparentCorners = typeof styleOverride.transparentCorners !== 'undefined' ? styleOverride.transparentCorners : fabricObject.transparentCorners,
8351
- methodName = transparentCorners ? 'stroke' : 'fill',
8378
+ methodName = transparentCorners ? STROKE : FILL,
8352
8379
  stroke = !transparentCorners && (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),
8353
8380
  xSizeBy2 = xSize / 2,
8354
8381
  ySizeBy2 = ySize / 2;
@@ -8393,7 +8420,7 @@ class Control {
8393
8420
  * @type {String}
8394
8421
  * @default 'scale'
8395
8422
  */
8396
- _defineProperty(this, "actionName", 'scale');
8423
+ _defineProperty(this, "actionName", SCALE);
8397
8424
  /**
8398
8425
  * Drawing angle of the control.
8399
8426
  * NOT used for now, but name marked as needed for internal logic
@@ -8711,7 +8738,7 @@ const rotateObjectWithSnapping = (eventData, _ref, x, y) => {
8711
8738
  target.angle = angle;
8712
8739
  return hasRotated;
8713
8740
  };
8714
- const rotationWithSnapping = wrapWithFireEvent('rotating', wrapWithFixedAnchor(rotateObjectWithSnapping));
8741
+ const rotationWithSnapping = wrapWithFireEvent(ROTATING, wrapWithFixedAnchor(rotateObjectWithSnapping));
8715
8742
 
8716
8743
  /**
8717
8744
  * Inspect event and fabricObject properties to understand if the scaling action
@@ -8860,12 +8887,12 @@ function scaleObject(eventData, transform, x, y) {
8860
8887
  const oldScaleX = target.scaleX,
8861
8888
  oldScaleY = target.scaleY;
8862
8889
  if (!by) {
8863
- !isLocked(target, 'lockScalingX') && target.set('scaleX', scaleX);
8864
- !isLocked(target, 'lockScalingY') && target.set('scaleY', scaleY);
8890
+ !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);
8891
+ !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);
8865
8892
  } else {
8866
8893
  // forbidden cases already handled on top here.
8867
- by === 'x' && target.set('scaleX', scaleX);
8868
- by === 'y' && target.set('scaleY', scaleY);
8894
+ by === 'x' && target.set(SCALE_X, scaleX);
8895
+ by === 'y' && target.set(SCALE_Y, scaleY);
8869
8896
  }
8870
8897
  return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;
8871
8898
  }
@@ -8912,24 +8939,24 @@ const scaleObjectY = (eventData, transform, x, y) => {
8912
8939
  by: 'y'
8913
8940
  });
8914
8941
  };
8915
- const scalingEqually = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectFromCorner));
8916
- const scalingX = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectX));
8917
- const scalingY = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectY));
8942
+ const scalingEqually = wrapWithFireEvent(SCALING, wrapWithFixedAnchor(scaleObjectFromCorner));
8943
+ const scalingX = wrapWithFireEvent(SCALING, wrapWithFixedAnchor(scaleObjectX));
8944
+ const scalingY = wrapWithFireEvent(SCALING, wrapWithFixedAnchor(scaleObjectY));
8918
8945
 
8919
8946
  const _excluded$d = ["target", "ex", "ey", "skewingSide"];
8920
8947
  const AXIS_KEYS = {
8921
8948
  x: {
8922
8949
  counterAxis: 'y',
8923
- scale: 'scaleX',
8924
- skew: 'skewX',
8950
+ scale: SCALE_X,
8951
+ skew: SKEW_X,
8925
8952
  lockSkewing: 'lockSkewingX',
8926
8953
  origin: 'originX',
8927
8954
  flip: 'flipX'
8928
8955
  },
8929
8956
  y: {
8930
8957
  counterAxis: 'x',
8931
- scale: 'scaleY',
8932
- skew: 'skewY',
8958
+ scale: SCALE_Y,
8959
+ skew: SKEW_Y,
8933
8960
  lockSkewing: 'lockSkewingY',
8934
8961
  origin: 'originY',
8935
8962
  flip: 'flipY'
@@ -9008,7 +9035,7 @@ function skewObject(axis, _ref, pointer) {
9008
9035
  }),
9009
9036
  dimAfter = target._getTransformedDimensions(),
9010
9037
  compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;
9011
- compensationFactor !== 1 && target.set('scaleX', compensationFactor * scaleX);
9038
+ compensationFactor !== 1 && target.set(SCALE_X, compensationFactor * scaleX);
9012
9039
  }
9013
9040
  return changed;
9014
9041
  }
@@ -9054,7 +9081,7 @@ function skewHandler(axis, eventData, transform, x, y) {
9054
9081
  // anchor to the opposite side of the skewing direction
9055
9082
  // normalize value from [-1, 1] to origin value [0, 1]
9056
9083
  origin = -skewingDirection * 0.5 + 0.5;
9057
- const finalHandler = wrapWithFireEvent('skewing', wrapWithFixedAnchor((eventData, transform, x, y) => skewObject(axis, transform, new Point(x, y))));
9084
+ const finalHandler = wrapWithFireEvent(SKEWING, wrapWithFixedAnchor((eventData, transform, x, y) => skewObject(axis, transform, new Point(x, y))));
9058
9085
  return finalHandler(eventData, _objectSpread2(_objectSpread2({}, transform), {}, {
9059
9086
  [originKey]: origin,
9060
9087
  skewingSide
@@ -9102,11 +9129,11 @@ const scaleOrSkewActionName = (eventData, control, fabricObject) => {
9102
9129
  const isAlternative = isAltAction(eventData, fabricObject);
9103
9130
  if (control.x === 0) {
9104
9131
  // then is scaleY or skewX
9105
- return isAlternative ? 'skewX' : 'scaleY';
9132
+ return isAlternative ? SKEW_X : SCALE_Y;
9106
9133
  }
9107
9134
  if (control.y === 0) {
9108
9135
  // then is scaleY or skewX
9109
- return isAlternative ? 'skewY' : 'scaleX';
9136
+ return isAlternative ? SKEW_Y : SCALE_X;
9110
9137
  }
9111
9138
  return '';
9112
9139
  };
@@ -9208,7 +9235,7 @@ const createObjectDefaultControls = () => ({
9208
9235
  cursorStyleHandler: rotationStyleHandler,
9209
9236
  offsetY: -40,
9210
9237
  withConnection: true,
9211
- actionName: 'rotate'
9238
+ actionName: ROTATE
9212
9239
  })
9213
9240
  });
9214
9241
  const createResizeControls = () => ({
@@ -9217,14 +9244,14 @@ const createResizeControls = () => ({
9217
9244
  y: 0,
9218
9245
  actionHandler: changeWidth,
9219
9246
  cursorStyleHandler: scaleSkewCursorStyleHandler,
9220
- actionName: 'resizing'
9247
+ actionName: RESIZING
9221
9248
  }),
9222
9249
  ml: new Control({
9223
9250
  x: -0.5,
9224
9251
  y: 0,
9225
9252
  actionHandler: changeWidth,
9226
9253
  cursorStyleHandler: scaleSkewCursorStyleHandler,
9227
- actionName: 'resizing'
9254
+ actionName: RESIZING
9228
9255
  })
9229
9256
  });
9230
9257
  const createTextboxDefaultControls = () => _objectSpread2(_objectSpread2({}, createObjectDefaultControls()), createResizeControls());
@@ -9268,7 +9295,7 @@ class InteractiveFabricObject extends FabricObject$1 {
9268
9295
  const transform = targetCanvas._currentTransform,
9269
9296
  target = transform.target,
9270
9297
  action = transform.action;
9271
- if (this === target && action && action.startsWith('scale')) {
9298
+ if (this === target && action && action.startsWith(SCALE)) {
9272
9299
  return false;
9273
9300
  }
9274
9301
  }
@@ -10424,7 +10451,7 @@ const stylesFromArray = (styles, text) => {
10424
10451
  * Attributes parsed from all SVG elements
10425
10452
  * @type array
10426
10453
  */
10427
- const SHARED_ATTRIBUTES = ['display', 'transform', 'fill', 'fill-opacity', 'fill-rule', 'opacity', 'stroke', 'stroke-dasharray', 'stroke-linecap', 'stroke-dashoffset', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'id', 'paint-order', 'vector-effect', 'instantiated_by_use', 'clip-path'];
10454
+ const SHARED_ATTRIBUTES = ['display', 'transform', FILL, 'fill-opacity', 'fill-rule', 'opacity', STROKE, 'stroke-dasharray', 'stroke-linecap', 'stroke-dashoffset', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'id', 'paint-order', 'vector-effect', 'instantiated_by_use', 'clip-path'];
10428
10455
 
10429
10456
  function selectorMatches(element, selector) {
10430
10457
  const nodeName = element.nodeName;
@@ -10556,7 +10583,7 @@ function parseTransformAttribute(attributeValue) {
10556
10583
  case 'translate':
10557
10584
  matrix = createTranslateMatrix(arg0, arg1);
10558
10585
  break;
10559
- case 'rotate':
10586
+ case ROTATE:
10560
10587
  matrix = createRotateMatrix({
10561
10588
  angle: arg0
10562
10589
  }, {
@@ -10564,13 +10591,13 @@ function parseTransformAttribute(attributeValue) {
10564
10591
  y: arg2
10565
10592
  });
10566
10593
  break;
10567
- case 'scale':
10594
+ case SCALE:
10568
10595
  matrix = createScaleMatrix(arg0, arg1);
10569
10596
  break;
10570
- case 'skewX':
10597
+ case SKEW_X:
10571
10598
  matrix = createSkewXMatrix(arg0);
10572
10599
  break;
10573
- case 'skewY':
10600
+ case SKEW_Y:
10574
10601
  matrix = createSkewYMatrix(arg0);
10575
10602
  break;
10576
10603
  case 'matrix':
@@ -10588,7 +10615,7 @@ function normalizeValue(attr, value, parentAttributes, fontSize) {
10588
10615
  const isArray = Array.isArray(value);
10589
10616
  let parsed;
10590
10617
  let ouputValue = value;
10591
- if ((attr === 'fill' || attr === 'stroke') && value === NONE) {
10618
+ if ((attr === FILL || attr === STROKE) && value === NONE) {
10592
10619
  ouputValue = '';
10593
10620
  } else if (attr === 'strokeUniform') {
10594
10621
  return value === 'non-scaling-stroke';
@@ -10621,13 +10648,13 @@ function normalizeValue(attr, value, parentAttributes, fontSize) {
10621
10648
  // parseUnit returns px and we convert it to em
10622
10649
  parsed = parseUnit(value, fontSize) / fontSize * 1000;
10623
10650
  } else if (attr === 'paintFirst') {
10624
- const fillIndex = value.indexOf('fill');
10625
- const strokeIndex = value.indexOf('stroke');
10626
- ouputValue = 'fill';
10651
+ const fillIndex = value.indexOf(FILL);
10652
+ const strokeIndex = value.indexOf(STROKE);
10653
+ ouputValue = FILL;
10627
10654
  if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {
10628
- ouputValue = 'stroke';
10655
+ ouputValue = STROKE;
10629
10656
  } else if (fillIndex === -1 && strokeIndex > -1) {
10630
- ouputValue = 'stroke';
10657
+ ouputValue = STROKE;
10631
10658
  }
10632
10659
  } else if (attr === 'href' || attr === 'xlink:href' || attr === 'font') {
10633
10660
  return value;
@@ -11001,16 +11028,21 @@ class LayoutStrategy {
11001
11028
  return this.calcBoundingBox(objects, context);
11002
11029
  }
11003
11030
  }
11004
- shouldPerformLayout(context) {
11005
- return context.type === LAYOUT_TYPE_INITIALIZATION || context.type === LAYOUT_TYPE_IMPERATIVE || !!context.prevStrategy && context.strategy !== context.prevStrategy;
11031
+ shouldPerformLayout(_ref) {
11032
+ let {
11033
+ type,
11034
+ prevStrategy,
11035
+ strategy
11036
+ } = _ref;
11037
+ return type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_IMPERATIVE || !!prevStrategy && strategy !== prevStrategy;
11006
11038
  }
11007
- shouldLayoutClipPath(_ref) {
11039
+ shouldLayoutClipPath(_ref2) {
11008
11040
  let {
11009
11041
  type,
11010
11042
  target: {
11011
11043
  clipPath
11012
11044
  }
11013
- } = _ref;
11045
+ } = _ref2;
11014
11046
  return type !== LAYOUT_TYPE_INITIALIZATION && clipPath && !clipPath.absolutePositioned;
11015
11047
  }
11016
11048
  getInitialSize(context, result) {
@@ -11021,15 +11053,16 @@ class LayoutStrategy {
11021
11053
  * Override this method to customize layout.
11022
11054
  */
11023
11055
  calcBoundingBox(objects, context) {
11024
- if (context.type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {
11056
+ const {
11057
+ type,
11058
+ target
11059
+ } = context;
11060
+ if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {
11025
11061
  return context.overrides;
11026
11062
  }
11027
11063
  if (objects.length === 0) {
11028
11064
  return;
11029
11065
  }
11030
- const {
11031
- target
11032
- } = context;
11033
11066
  const {
11034
11067
  left,
11035
11068
  top,
@@ -11039,7 +11072,7 @@ class LayoutStrategy {
11039
11072
  const bboxSize = new Point(width, height);
11040
11073
  const bboxLeftTop = new Point(left, top);
11041
11074
  const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));
11042
- if (context.type === LAYOUT_TYPE_INITIALIZATION) {
11075
+ if (type === LAYOUT_TYPE_INITIALIZATION) {
11043
11076
  const actualSize = this.getInitialSize(context, {
11044
11077
  size: bboxSize,
11045
11078
  center: bboxCenter
@@ -11123,7 +11156,7 @@ class LayoutManager {
11123
11156
  const {
11124
11157
  target
11125
11158
  } = context;
11126
- return ['modified', 'moving', 'resizing', 'rotating', 'scaling', 'skewing', 'changed', 'modifyPoly'].map(key => object.on(key, e => this.performLayout(key === 'modified' ? {
11159
+ return [MODIFIED, MOVING, RESIZING, ROTATING, SCALING, SKEWING, CHANGED, MODIFY_POLY].map(key => object.on(key, e => this.performLayout(key === MODIFIED ? {
11127
11160
  type: LAYOUT_TYPE_OBJECT_MODIFIED,
11128
11161
  trigger: key,
11129
11162
  e,
@@ -11195,13 +11228,15 @@ class LayoutManager {
11195
11228
  }
11196
11229
  getLayoutResult(context) {
11197
11230
  const {
11198
- target
11231
+ target,
11232
+ strategy,
11233
+ type
11199
11234
  } = context;
11200
- const result = context.strategy.calcLayoutResult(context, target.getObjects());
11235
+ const result = strategy.calcLayoutResult(context, target.getObjects());
11201
11236
  if (!result) {
11202
11237
  return;
11203
11238
  }
11204
- const prevCenter = context.type === LAYOUT_TYPE_INITIALIZATION ? new Point() : target.getRelativeCenterPoint();
11239
+ const prevCenter = type === LAYOUT_TYPE_INITIALIZATION ? new Point() : target.getRelativeCenterPoint();
11205
11240
  const {
11206
11241
  center: nextCenter,
11207
11242
  correction = new Point(),
@@ -11209,7 +11244,7 @@ class LayoutManager {
11209
11244
  } = result;
11210
11245
  const offset = prevCenter.subtract(nextCenter).add(correction).transform(
11211
11246
  // in `initialization` we do not account for target's transformation matrix
11212
- context.type === LAYOUT_TYPE_INITIALIZATION ? iMatrix : invertTransform(target.calcOwnMatrix()), true).add(relativeCorrection);
11247
+ type === LAYOUT_TYPE_INITIALIZATION ? iMatrix : invertTransform(target.calcOwnMatrix()), true).add(relativeCorrection);
11213
11248
  return {
11214
11249
  result,
11215
11250
  prevCenter,
@@ -11314,8 +11349,11 @@ class LayoutManager {
11314
11349
  target.set('dirty', true);
11315
11350
  }
11316
11351
  dispose() {
11317
- this._subscriptions.forEach(disposers => disposers.forEach(d => d()));
11318
- this._subscriptions.clear();
11352
+ const {
11353
+ _subscriptions
11354
+ } = this;
11355
+ _subscriptions.forEach(disposers => disposers.forEach(d => d()));
11356
+ _subscriptions.clear();
11319
11357
  }
11320
11358
  toObject() {
11321
11359
  return {
@@ -12873,8 +12911,8 @@ const _assignTransformMatrixProps = object => {
12873
12911
  } = qrDecompose(object.transformMatrix);
12874
12912
  object.flipX = false;
12875
12913
  object.flipY = false;
12876
- object.set('scaleX', scaleX);
12877
- object.set('scaleY', scaleY);
12914
+ object.set(SCALE_X, scaleX);
12915
+ object.set(SCALE_Y, scaleY);
12878
12916
  object.angle = angle;
12879
12917
  object.skewX = skewX;
12880
12918
  object.skewY = 0;
@@ -13498,9 +13536,9 @@ class SelectableCanvas extends StaticCanvas$1 {
13498
13536
  return;
13499
13537
  }
13500
13538
  let centerTransform;
13501
- if (action === 'scale' || action === 'scaleX' || action === 'scaleY' || action === 'resizing') {
13539
+ if (action === SCALE || action === SCALE_X || action === SCALE_Y || action === RESIZING) {
13502
13540
  centerTransform = this.centeredScaling || target.centeredScaling;
13503
- } else if (action === 'rotate') {
13541
+ } else if (action === ROTATE) {
13504
13542
  centerTransform = this.centeredRotation || target.centeredRotation;
13505
13543
  }
13506
13544
  return centerTransform ? !modifierKeyPressed : modifierKeyPressed;
@@ -14129,7 +14167,7 @@ class SelectableCanvas extends StaticCanvas$1 {
14129
14167
  target.setCoords();
14130
14168
  if (transform.actionPerformed) {
14131
14169
  this.fire('object:modified', options);
14132
- target.fire('modified', options);
14170
+ target.fire(MODIFIED, options);
14133
14171
  }
14134
14172
  }
14135
14173
 
@@ -14216,7 +14254,7 @@ class SelectableCanvas extends StaticCanvas$1 {
14216
14254
  group
14217
14255
  } = instance;
14218
14256
  if (group && isActiveSelection(group) && this._activeObject === group) {
14219
- const layoutProps = ['angle', 'flipX', 'flipY', LEFT, 'scaleX', 'scaleY', 'skewX', 'skewY', TOP];
14257
+ const layoutProps = ['angle', 'flipX', 'flipY', LEFT, SCALE_X, SCALE_Y, SKEW_X, SKEW_Y, TOP];
14220
14258
  const originalValues = pick(instance, layoutProps);
14221
14259
  addTransformToObject(instance, group.calcOwnMatrix());
14222
14260
  return originalValues;
@@ -16946,7 +16984,7 @@ class Circle extends FabricObject {
16946
16984
  * @return {Number}
16947
16985
  */
16948
16986
  getRadiusX() {
16949
- return this.get('radius') * this.get('scaleX');
16987
+ return this.get('radius') * this.get(SCALE_X);
16950
16988
  }
16951
16989
 
16952
16990
  /**
@@ -16954,7 +16992,7 @@ class Circle extends FabricObject {
16954
16992
  * @return {Number}
16955
16993
  */
16956
16994
  getRadiusY() {
16957
- return this.get('radius') * this.get('scaleY');
16995
+ return this.get('radius') * this.get(SCALE_Y);
16958
16996
  }
16959
16997
 
16960
16998
  /**
@@ -17775,7 +17813,7 @@ class Ellipse extends FabricObject {
17775
17813
  * @return {Number}
17776
17814
  */
17777
17815
  getRx() {
17778
- return this.get('rx') * this.get('scaleX');
17816
+ return this.get('rx') * this.get(SCALE_X);
17779
17817
  }
17780
17818
 
17781
17819
  /**
@@ -17783,7 +17821,7 @@ class Ellipse extends FabricObject {
17783
17821
  * @return {Number}
17784
17822
  */
17785
17823
  getRy() {
17786
- return this.get('ry') * this.get('scaleY');
17824
+ return this.get('ry') * this.get(SCALE_Y);
17787
17825
  }
17788
17826
 
17789
17827
  /**
@@ -18089,7 +18127,7 @@ class Polyline extends FabricObject {
18089
18127
  _set(key, value) {
18090
18128
  const changed = this.initialized && this[key] !== value;
18091
18129
  const output = super._set(key, value);
18092
- if (this.exactBoundingBox && changed && ((key === 'scaleX' || key === 'scaleY') && this.strokeUniform && this.constructor.layoutProperties.includes('strokeUniform') || this.constructor.layoutProperties.includes(key))) {
18130
+ if (this.exactBoundingBox && changed && ((key === SCALE_X || key === SCALE_Y) && this.strokeUniform && this.constructor.layoutProperties.includes('strokeUniform') || this.constructor.layoutProperties.includes(key))) {
18093
18131
  this.setDimensions();
18094
18132
  }
18095
18133
  return output;
@@ -18208,7 +18246,7 @@ class Polyline extends FabricObject {
18208
18246
  */
18209
18247
  _defineProperty(Polyline, "ownDefaults", polylineDefaultValues);
18210
18248
  _defineProperty(Polyline, "type", 'Polyline');
18211
- _defineProperty(Polyline, "layoutProperties", ['skewX', 'skewY', 'strokeLineCap', 'strokeLineJoin', 'strokeMiterLimit', 'strokeWidth', 'strokeUniform', 'points']);
18249
+ _defineProperty(Polyline, "layoutProperties", [SKEW_X, SKEW_Y, 'strokeLineCap', 'strokeLineJoin', 'strokeMiterLimit', 'strokeWidth', 'strokeUniform', 'points']);
18212
18250
  _defineProperty(Polyline, "cacheProperties", [...cacheProperties, 'points']);
18213
18251
  _defineProperty(Polyline, "ATTRIBUTE_NAMES", [...SHARED_ATTRIBUTES]);
18214
18252
  classRegistry.setClass(Polyline);
@@ -18228,7 +18266,7 @@ const fontProperties = ['fontSize', 'fontWeight', 'fontFamily', 'fontStyle'];
18228
18266
  const textDecorationProperties = ['underline', 'overline', 'linethrough'];
18229
18267
  const textLayoutProperties = [...fontProperties, 'lineHeight', 'text', 'charSpacing', 'textAlign', 'styles', 'path', 'pathStartOffset', 'pathSide', 'pathAlign'];
18230
18268
  const additionalProps = [...textLayoutProperties, ...textDecorationProperties, 'textBackgroundColor', 'direction'];
18231
- const styleProperties = [...fontProperties, ...textDecorationProperties, 'stroke', 'strokeWidth', 'fill', 'deltaY', 'textBackgroundColor'];
18269
+ const styleProperties = [...fontProperties, ...textDecorationProperties, STROKE, 'strokeWidth', FILL, 'deltaY', 'textBackgroundColor'];
18232
18270
 
18233
18271
  // @TODO: Many things here are configuration related and shouldn't be on the class nor prototype
18234
18272
  // regexes, list of properties that are not suppose to change by instances, magic consts.
@@ -18750,7 +18788,7 @@ class TextSVGExportMixin extends FabricObjectSVGExportMixin {
18750
18788
  deltaY
18751
18789
  } = style;
18752
18790
  const textDecoration = this.getSvgTextDecoration(style);
18753
- return [stroke ? colorPropToSVG('stroke', stroke) : '', strokeWidth ? "stroke-width: ".concat(strokeWidth, "; ") : '', fontFamily ? "font-family: ".concat(!fontFamily.includes("'") && !fontFamily.includes('"') ? "'".concat(fontFamily, "'") : fontFamily, "; ") : '', fontSize ? "font-size: ".concat(fontSize, "px; ") : '', fontStyle ? "font-style: ".concat(fontStyle, "; ") : '', fontWeight ? "font-weight: ".concat(fontWeight, "; ") : '', textDecoration ? "text-decoration: ".concat(textDecoration, "; ") : textDecoration, fill ? colorPropToSVG('fill', fill) : '', deltaY ? "baseline-shift: ".concat(-deltaY, "; ") : '', useWhiteSpace ? 'white-space: pre; ' : ''].join('');
18791
+ return [stroke ? colorPropToSVG(STROKE, stroke) : '', strokeWidth ? "stroke-width: ".concat(strokeWidth, "; ") : '', fontFamily ? "font-family: ".concat(!fontFamily.includes("'") && !fontFamily.includes('"') ? "'".concat(fontFamily, "'") : fontFamily, "; ") : '', fontSize ? "font-size: ".concat(fontSize, "px; ") : '', fontStyle ? "font-style: ".concat(fontStyle, "; ") : '', fontWeight ? "font-weight: ".concat(fontWeight, "; ") : '', textDecoration ? "text-decoration: ".concat(textDecoration, "; ") : textDecoration, fill ? colorPropToSVG(FILL, fill) : '', deltaY ? "baseline-shift: ".concat(-deltaY, "; ") : '', useWhiteSpace ? 'white-space: pre; ' : ''].join('');
18754
18792
  }
18755
18793
 
18756
18794
  /**
@@ -18984,7 +19022,7 @@ class FabricText extends StyledText {
18984
19022
  * @param {CanvasRenderingContext2D} ctx Context to render on
18985
19023
  */
18986
19024
  _renderText(ctx) {
18987
- if (this.paintFirst === 'stroke') {
19025
+ if (this.paintFirst === STROKE) {
18988
19026
  this._renderTextStroke(ctx);
18989
19027
  this._renderTextFill(ctx);
18990
19028
  } else {
@@ -19388,7 +19426,7 @@ class FabricText extends StyledText {
19388
19426
  * @param {CanvasRenderingContext2D} ctx Context to render on
19389
19427
  */
19390
19428
  _renderTextFill(ctx) {
19391
- if (!this.fill && !this.styleHas('fill')) {
19429
+ if (!this.fill && !this.styleHas(FILL)) {
19392
19430
  return;
19393
19431
  }
19394
19432
  this._renderTextCommon(ctx, 'fillText');
@@ -19775,7 +19813,7 @@ class FabricText extends StyledText {
19775
19813
  let boxStart = 0;
19776
19814
  let boxWidth = 0;
19777
19815
  let lastDecoration = this.getValueOfPropertyAt(i, 0, type);
19778
- let lastFill = this.getValueOfPropertyAt(i, 0, 'fill');
19816
+ let lastFill = this.getValueOfPropertyAt(i, 0, FILL);
19779
19817
  let currentDecoration;
19780
19818
  let currentFill;
19781
19819
  const top = topOffset + maxHeight * (1 - this._fontSizeFraction);
@@ -19784,7 +19822,7 @@ class FabricText extends StyledText {
19784
19822
  for (let j = 0, jlen = line.length; j < jlen; j++) {
19785
19823
  const charBox = this.__charBounds[i][j];
19786
19824
  currentDecoration = this.getValueOfPropertyAt(i, j, type);
19787
- currentFill = this.getValueOfPropertyAt(i, j, 'fill');
19825
+ currentFill = this.getValueOfPropertyAt(i, j, FILL);
19788
19826
  const currentSize = this.getHeightOfChar(i, j);
19789
19827
  const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');
19790
19828
  if (path && currentDecoration && currentFill) {
@@ -20311,7 +20349,7 @@ class DraggableTextDelegate {
20311
20349
  target.hiddenTextarea.value = target.text;
20312
20350
  target._updateTextarea();
20313
20351
  target.hiddenTextarea.focus();
20314
- target.fire('changed', {
20352
+ target.fire(CHANGED, {
20315
20353
  index: insertAt + selectionStartOffset,
20316
20354
  action: 'drop'
20317
20355
  });
@@ -20357,7 +20395,7 @@ class DraggableTextDelegate {
20357
20395
  target.selectionStart = target.selectionEnd = selectionStart;
20358
20396
  target.hiddenTextarea && (target.hiddenTextarea.value = target.text);
20359
20397
  target._updateTextarea();
20360
- target.fire('changed', {
20398
+ target.fire(CHANGED, {
20361
20399
  index: selectionStart,
20362
20400
  action: 'dragend'
20363
20401
  });
@@ -20935,7 +20973,7 @@ class ITextBehavior extends FabricText {
20935
20973
  this.setCoords();
20936
20974
  }
20937
20975
  this.fire('editing:exited');
20938
- isTextChanged && this.fire('modified');
20976
+ isTextChanged && this.fire(MODIFIED);
20939
20977
  if (this.canvas) {
20940
20978
  this.canvas.fire('text:editing:exited', {
20941
20979
  target: this
@@ -21414,7 +21452,7 @@ class ITextKeyBehavior extends ITextBehavior {
21414
21452
  }
21415
21453
  const updateAndFire = () => {
21416
21454
  this.updateFromTextArea();
21417
- this.fire('changed');
21455
+ this.fire(CHANGED);
21418
21456
  if (this.canvas) {
21419
21457
  this.canvas.fire('text:changed', {
21420
21458
  target: this
@@ -22515,7 +22553,7 @@ class IText extends ITextClickBehavior {
22515
22553
  // and why can't happen at the top of the function
22516
22554
  this.renderSelection(ctx, boundaries);
22517
22555
  }
22518
- ctx.fillStyle = this.cursorColor || this.getValueOfPropertyAt(lineIndex, charIndex, 'fill');
22556
+ ctx.fillStyle = this.cursorColor || this.getValueOfPropertyAt(lineIndex, charIndex, FILL);
22519
22557
  ctx.globalAlpha = this._currentCursorOpacity;
22520
22558
  ctx.fillRect(boundaries.left + boundaries.leftOffset - cursorWidth / 2, topOffset + boundaries.top + dy, cursorWidth, charHeight);
22521
22559
  }
@@ -22632,7 +22670,7 @@ class IText extends ITextClickBehavior {
22632
22670
  */
22633
22671
  getCurrentCharColor() {
22634
22672
  const cp = this._getCurrentCharIndex();
22635
- return this.getValueOfPropertyAt(cp.l, cp.c, 'fill');
22673
+ return this.getValueOfPropertyAt(cp.l, cp.c, FILL);
22636
22674
  }
22637
22675
 
22638
22676
  /**
@@ -23222,7 +23260,8 @@ class ClipPathLayout extends LayoutStrategy {
23222
23260
  target
23223
23261
  } = context;
23224
23262
  const {
23225
- clipPath
23263
+ clipPath,
23264
+ group
23226
23265
  } = target;
23227
23266
  if (!clipPath || !this.shouldPerformLayout(context)) {
23228
23267
  return;
@@ -23234,9 +23273,8 @@ class ClipPathLayout extends LayoutStrategy {
23234
23273
  } = makeBoundingBoxFromPoints(getObjectBounds(target, clipPath));
23235
23274
  const size = new Point(width, height);
23236
23275
  if (clipPath.absolutePositioned) {
23237
- var _target$group;
23238
23276
  // we want the center point to exist in group's containing plane
23239
- const clipPathCenter = sendPointToPlane(clipPath.getRelativeCenterPoint(), undefined, (_target$group = target.group) === null || _target$group === void 0 ? void 0 : _target$group.calcTransformMatrix());
23277
+ const clipPathCenter = sendPointToPlane(clipPath.getRelativeCenterPoint(), undefined, group ? group.calcTransformMatrix() : undefined);
23240
23278
  return {
23241
23279
  center: clipPathCenter,
23242
23280
  size
@@ -24202,7 +24240,7 @@ class FabricImage extends FabricObject {
24202
24240
  strokeSvg = ["\t<rect x=\"".concat(x, "\" y=\"").concat(y, "\" width=\"").concat(this.width, "\" height=\"").concat(this.height, "\" style=\"").concat(this.getSvgStyles(), "\" />\n")];
24203
24241
  this.fill = origFill;
24204
24242
  }
24205
- if (this.paintFirst !== 'fill') {
24243
+ if (this.paintFirst !== FILL) {
24206
24244
  svgString = svgString.concat(strokeSvg, imageMarkup);
24207
24245
  } else {
24208
24246
  svgString = svgString.concat(imageMarkup, strokeSvg);
@@ -24949,8 +24987,8 @@ class ElementsParser {
24949
24987
  const klass = findTag(el);
24950
24988
  if (klass) {
24951
24989
  const obj = await klass.fromElement(el, this.options, this.cssRules);
24952
- this.resolveGradient(obj, el, 'fill');
24953
- this.resolveGradient(obj, el, 'stroke');
24990
+ this.resolveGradient(obj, el, FILL);
24991
+ this.resolveGradient(obj, el, STROKE);
24954
24992
  if (obj instanceof FabricImage && obj._originalElement) {
24955
24993
  removeTransformMatrixForSvgParsing(obj, obj.parsePreserveAspectRatioAttribute());
24956
24994
  } else {
@@ -25176,7 +25214,7 @@ function loadSVGFromURL(url, reviver) {
25176
25214
  });
25177
25215
  }
25178
25216
 
25179
- const ACTION_NAME = 'modifyPoly';
25217
+ const ACTION_NAME = MODIFY_POLY;
25180
25218
  /**
25181
25219
  * This function locates the controls.
25182
25220
  * It'll be used both for drawing and for interaction.
@@ -26075,7 +26113,7 @@ class Blur extends BaseFilter {
26075
26113
  */
26076
26114
  sendUniformData(gl, uniformLocations) {
26077
26115
  const delta = this.chooseRightDelta();
26078
- gl.uniform2fv(uniformLocations.delta, delta);
26116
+ gl.uniform2fv(uniformLocations.uDelta, delta);
26079
26117
  }
26080
26118
  isNeutralState() {
26081
26119
  return this.blur === 0;
@@ -27030,7 +27068,7 @@ class Pixelate extends BaseFilter {
27030
27068
  }
27031
27069
  _defineProperty(Pixelate, "type", 'Pixelate');
27032
27070
  _defineProperty(Pixelate, "defaults", pixelateDefaultValues);
27033
- _defineProperty(Pixelate, "uniformLocations", ['uBlockSize']);
27071
+ _defineProperty(Pixelate, "uniformLocations", ['uBlocksize']);
27034
27072
  classRegistry.setClass(Pixelate);
27035
27073
 
27036
27074
  const fragmentShader = "\nprecision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\n gl_FragColor.a = 0.0;\n }\n}\n";
@@ -27759,6 +27797,7 @@ exports.Gradient = Gradient;
27759
27797
  exports.Group = Group;
27760
27798
  exports.IText = IText;
27761
27799
  exports.Image = FabricImage;
27800
+ exports.InteractiveFabricObject = InteractiveFabricObject;
27762
27801
  exports.Intersection = Intersection;
27763
27802
  exports.LayoutManager = LayoutManager;
27764
27803
  exports.LayoutStrategy = LayoutStrategy;