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
@@ -457,7 +457,7 @@ class Cache {
457
457
  }
458
458
  const cache = new Cache();
459
459
 
460
- var version = "6.0.0";
460
+ var version = "6.0.2";
461
461
 
462
462
  // use this syntax so babel plugin see this import here
463
463
  const VERSION = version;
@@ -479,6 +479,22 @@ const BOTTOM = 'bottom';
479
479
  const RIGHT = 'right';
480
480
  const NONE = 'none';
481
481
  const reNewline = /\r?\n/;
482
+ const MOVING = 'moving';
483
+ const SCALING = 'scaling';
484
+ const ROTATING = 'rotating';
485
+ const ROTATE = 'rotate';
486
+ const SKEWING = 'skewing';
487
+ const RESIZING = 'resizing';
488
+ const MODIFY_POLY = 'modifyPoly';
489
+ const CHANGED = 'changed';
490
+ const SCALE = 'scale';
491
+ const SCALE_X = 'scaleX';
492
+ const SCALE_Y = 'scaleY';
493
+ const SKEW_X = 'skewX';
494
+ const SKEW_Y = 'skewY';
495
+ const FILL = 'fill';
496
+ const STROKE = 'stroke';
497
+ const MODIFIED = 'modified';
482
498
 
483
499
  /*
484
500
  * This Map connects the objects type value with their
@@ -669,6 +685,14 @@ class Observable {
669
685
  }
670
686
  }
671
687
 
688
+ /**
689
+ * Unsubscribe all event listeners for eventname.
690
+ * Do not use this pattern. You could kill internal fabricJS events.
691
+ * We know we should have protected events for internal flows, but we don't have yet
692
+ * @deprecated
693
+ * @param {string} eventName event name (eg. 'after:render')
694
+ */
695
+
672
696
  /**
673
697
  * unsubscribe an event listener
674
698
  * @param {string} eventName event name (eg. 'after:render')
@@ -1927,6 +1951,7 @@ const loadImage = function (url) {
1927
1951
  });
1928
1952
  };
1929
1953
  /**
1954
+ * @TODO type this correctly.
1930
1955
  * Creates corresponding fabric instances from their object representations
1931
1956
  * @param {Object[]} objects Objects to enliven
1932
1957
  * @param {EnlivenObjectOptions} [options]
@@ -2837,7 +2862,7 @@ const createSVGRect = function (color, _ref) {
2837
2862
  height
2838
2863
  } = _ref;
2839
2864
  let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : config.NUM_FRACTION_DIGITS;
2840
- const svgColor = colorPropToSVG('fill', color, false);
2865
+ const svgColor = colorPropToSVG(FILL, color, false);
2841
2866
  const [x, y, w, h] = [left, top, width, height].map(value => toFixed(value, precision));
2842
2867
  return "<rect ".concat(svgColor, " x=\"").concat(x, "\" y=\"").concat(y, "\" width=\"").concat(w, "\" height=\"").concat(h, "\"></rect>");
2843
2868
  };
@@ -4739,7 +4764,7 @@ const dragHandler = (eventData, transform, x, y) => {
4739
4764
  moveX && target.set(LEFT, newLeft);
4740
4765
  moveY && target.set(TOP, newTop);
4741
4766
  if (moveX || moveY) {
4742
- fireEvent('moving', commonEventInfo(eventData, transform, x, y));
4767
+ fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));
4743
4768
  }
4744
4769
  return moveX || moveY;
4745
4770
  };
@@ -4767,8 +4792,8 @@ class FabricObjectSVGExportMixin {
4767
4792
  opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',
4768
4793
  visibility = this.visible ? '' : ' visibility: hidden;',
4769
4794
  filter = skipShadow ? '' : this.getSvgFilter(),
4770
- fill = colorPropToSVG('fill', this.fill),
4771
- stroke = colorPropToSVG('stroke', this.stroke);
4795
+ fill = colorPropToSVG(FILL, this.fill),
4796
+ stroke = colorPropToSVG(STROKE, this.stroke);
4772
4797
  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('');
4773
4798
  }
4774
4799
 
@@ -4898,7 +4923,7 @@ class FabricObjectSVGExportMixin {
4898
4923
  return reviver ? reviver(markup.join('')) : markup.join('');
4899
4924
  }
4900
4925
  addPaintOrder() {
4901
- return this.paintFirst !== 'fill' ? " paint-order=\"".concat(this.paintFirst, "\" ") : '';
4926
+ return this.paintFirst !== FILL ? " paint-order=\"".concat(this.paintFirst, "\" ") : '';
4902
4927
  }
4903
4928
  }
4904
4929
 
@@ -6286,8 +6311,8 @@ class ObjectGeometry extends ObjectOrigin {
6286
6311
  * @return {void}
6287
6312
  */
6288
6313
  scale(value) {
6289
- this._set('scaleX', value);
6290
- this._set('scaleY', value);
6314
+ this._set(SCALE_X, value);
6315
+ this._set(SCALE_Y, value);
6291
6316
  this.setCoords();
6292
6317
  }
6293
6318
 
@@ -6674,7 +6699,7 @@ class AnimatableObject extends StackedObject {
6674
6699
  * List of properties to consider for animating colors.
6675
6700
  * @type String[]
6676
6701
  */
6677
- _defineProperty(AnimatableObject, "colorProperties", ['fill', 'stroke', 'backgroundColor']);
6702
+ _defineProperty(AnimatableObject, "colorProperties", [FILL, STROKE, 'backgroundColor']);
6678
6703
 
6679
6704
  function getSvgRegex(arr) {
6680
6705
  return new RegExp('^(' + arr.join('|') + ')\\b', 'i');
@@ -6890,8 +6915,8 @@ classRegistry.setClass(Shadow, 'shadow');
6890
6915
 
6891
6916
  const cloneDeep = object => JSON.parse(JSON.stringify(object));
6892
6917
 
6893
- const stateProperties = [TOP, LEFT, 'scaleX', 'scaleY', 'flipX', 'flipY', 'originX', 'originY', 'angle', 'opacity', 'globalCompositeOperation', 'shadow', 'visible', 'skewX', 'skewY'];
6894
- const cacheProperties = ['fill', 'stroke', 'strokeWidth', 'strokeDashArray', 'width', 'height', 'paintFirst', 'strokeUniform', 'strokeLineCap', 'strokeDashOffset', 'strokeLineJoin', 'strokeMiterLimit', 'backgroundColor', 'clipPath'];
6918
+ const stateProperties = [TOP, LEFT, SCALE_X, SCALE_Y, 'flipX', 'flipY', 'originX', 'originY', 'angle', 'opacity', 'globalCompositeOperation', 'shadow', 'visible', SKEW_X, SKEW_Y];
6919
+ const cacheProperties = [FILL, STROKE, 'strokeWidth', 'strokeDashArray', 'width', 'height', 'paintFirst', 'strokeUniform', 'strokeLineCap', 'strokeDashOffset', 'strokeLineJoin', 'strokeMiterLimit', 'backgroundColor', 'clipPath'];
6895
6920
  const fabricObjectDefaultValues = {
6896
6921
  // see composeMatrix() to see order of transforms. First defaults listed based on this
6897
6922
  top: 0,
@@ -6912,7 +6937,7 @@ const fabricObjectDefaultValues = {
6912
6937
  strokeUniform: false,
6913
6938
  padding: 0,
6914
6939
  opacity: 1,
6915
- paintFirst: 'fill',
6940
+ paintFirst: FILL,
6916
6941
  fill: 'rgb(0,0,0)',
6917
6942
  fillRule: 'nonzero',
6918
6943
  stroke: null,
@@ -7003,18 +7028,20 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7003
7028
  }
7004
7029
 
7005
7030
  /**
7006
- * The class type. Used to identify which class this is.
7007
- * This is used for serialization purposes and internally it can be used
7008
- * to identify classes. As a developer you could use `instance of Class`
7009
- * but to avoid importing all the code and blocking tree shaking we try
7010
- * to avoid doing that.
7031
+ * The class type.
7032
+ * This is used for serialization and deserialization purposes and internally it can be used
7033
+ * to identify classes.
7034
+ * When we transform a class in a plain JS object we need a way to recognize which class it was,
7035
+ * and the type is the way we do that. It has no other purposes and you should not give one.
7036
+ * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).
7037
+ * To idenfity a class use instanceof class ( instanceof Rect ).
7038
+ * We do not do that in fabricJS code because we want to try to have code splitting possible.
7011
7039
  */
7012
7040
 
7013
7041
  /**
7014
7042
  * Legacy identifier of the class. Prefer using utils like isType or instanceOf
7015
7043
  * Will be removed in fabric 7 or 8.
7016
- * The setter exists because is very hard to catch all the ways in which a type value
7017
- * could be set in the instance
7044
+ * The setter exists to avoid type errors in old code and possibly current deserialization code.
7018
7045
  * @TODO add sustainable warning message
7019
7046
  * @type string
7020
7047
  * @deprecated
@@ -7385,10 +7412,10 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7385
7412
  * @param {*} value
7386
7413
  */
7387
7414
  _set(key, value) {
7388
- if (key === 'scaleX' || key === 'scaleY') {
7415
+ if (key === SCALE_X || key === SCALE_Y) {
7389
7416
  value = this._constrainScale(value);
7390
7417
  }
7391
- if (key === 'scaleX' && value < 0) {
7418
+ if (key === SCALE_X && value < 0) {
7392
7419
  this.flipX = !this.flipX;
7393
7420
  value *= -1;
7394
7421
  } else if (key === 'scaleY' && value < 0) {
@@ -7509,7 +7536,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7509
7536
  * @returns Boolean
7510
7537
  */
7511
7538
  needsItsOwnCache() {
7512
- if (this.paintFirst === 'stroke' && this.hasFill() && this.hasStroke() && !!this.shadow) {
7539
+ if (this.paintFirst === STROKE && this.hasFill() && this.hasStroke() && !!this.shadow) {
7513
7540
  return true;
7514
7541
  }
7515
7542
  if (this.clipPath) {
@@ -7804,7 +7831,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7804
7831
  * @param {CanvasRenderingContext2D} ctx Context to render on
7805
7832
  */
7806
7833
  _renderPaintInOrder(ctx) {
7807
- if (this.paintFirst === 'stroke') {
7834
+ if (this.paintFirst === STROKE) {
7808
7835
  this._renderStroke(ctx);
7809
7836
  this._renderFill(ctx);
7810
7837
  } else {
@@ -8281,7 +8308,7 @@ const changeObjectWidth = (eventData, transform, x, y) => {
8281
8308
  }
8282
8309
  return false;
8283
8310
  };
8284
- const changeWidth = wrapWithFireEvent('resizing', wrapWithFixedAnchor(changeObjectWidth));
8311
+ const changeWidth = wrapWithFireEvent(RESIZING, wrapWithFixedAnchor(changeObjectWidth));
8285
8312
 
8286
8313
  /**
8287
8314
  * Render a round control, as per fabric features.
@@ -8299,7 +8326,7 @@ function renderCircleControl(ctx, left, top, styleOverride, fabricObject) {
8299
8326
  const xSize = this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,
8300
8327
  ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,
8301
8328
  transparentCorners = typeof styleOverride.transparentCorners !== 'undefined' ? styleOverride.transparentCorners : fabricObject.transparentCorners,
8302
- methodName = transparentCorners ? 'stroke' : 'fill',
8329
+ methodName = transparentCorners ? STROKE : FILL,
8303
8330
  stroke = !transparentCorners && (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);
8304
8331
  let myLeft = left,
8305
8332
  myTop = top,
@@ -8346,7 +8373,7 @@ function renderSquareControl(ctx, left, top, styleOverride, fabricObject) {
8346
8373
  const xSize = this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,
8347
8374
  ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,
8348
8375
  transparentCorners = typeof styleOverride.transparentCorners !== 'undefined' ? styleOverride.transparentCorners : fabricObject.transparentCorners,
8349
- methodName = transparentCorners ? 'stroke' : 'fill',
8376
+ methodName = transparentCorners ? STROKE : FILL,
8350
8377
  stroke = !transparentCorners && (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),
8351
8378
  xSizeBy2 = xSize / 2,
8352
8379
  ySizeBy2 = ySize / 2;
@@ -8391,7 +8418,7 @@ class Control {
8391
8418
  * @type {String}
8392
8419
  * @default 'scale'
8393
8420
  */
8394
- _defineProperty(this, "actionName", 'scale');
8421
+ _defineProperty(this, "actionName", SCALE);
8395
8422
  /**
8396
8423
  * Drawing angle of the control.
8397
8424
  * NOT used for now, but name marked as needed for internal logic
@@ -8709,7 +8736,7 @@ const rotateObjectWithSnapping = (eventData, _ref, x, y) => {
8709
8736
  target.angle = angle;
8710
8737
  return hasRotated;
8711
8738
  };
8712
- const rotationWithSnapping = wrapWithFireEvent('rotating', wrapWithFixedAnchor(rotateObjectWithSnapping));
8739
+ const rotationWithSnapping = wrapWithFireEvent(ROTATING, wrapWithFixedAnchor(rotateObjectWithSnapping));
8713
8740
 
8714
8741
  /**
8715
8742
  * Inspect event and fabricObject properties to understand if the scaling action
@@ -8858,12 +8885,12 @@ function scaleObject(eventData, transform, x, y) {
8858
8885
  const oldScaleX = target.scaleX,
8859
8886
  oldScaleY = target.scaleY;
8860
8887
  if (!by) {
8861
- !isLocked(target, 'lockScalingX') && target.set('scaleX', scaleX);
8862
- !isLocked(target, 'lockScalingY') && target.set('scaleY', scaleY);
8888
+ !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);
8889
+ !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);
8863
8890
  } else {
8864
8891
  // forbidden cases already handled on top here.
8865
- by === 'x' && target.set('scaleX', scaleX);
8866
- by === 'y' && target.set('scaleY', scaleY);
8892
+ by === 'x' && target.set(SCALE_X, scaleX);
8893
+ by === 'y' && target.set(SCALE_Y, scaleY);
8867
8894
  }
8868
8895
  return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;
8869
8896
  }
@@ -8910,24 +8937,24 @@ const scaleObjectY = (eventData, transform, x, y) => {
8910
8937
  by: 'y'
8911
8938
  });
8912
8939
  };
8913
- const scalingEqually = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectFromCorner));
8914
- const scalingX = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectX));
8915
- const scalingY = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectY));
8940
+ const scalingEqually = wrapWithFireEvent(SCALING, wrapWithFixedAnchor(scaleObjectFromCorner));
8941
+ const scalingX = wrapWithFireEvent(SCALING, wrapWithFixedAnchor(scaleObjectX));
8942
+ const scalingY = wrapWithFireEvent(SCALING, wrapWithFixedAnchor(scaleObjectY));
8916
8943
 
8917
8944
  const _excluded$d = ["target", "ex", "ey", "skewingSide"];
8918
8945
  const AXIS_KEYS = {
8919
8946
  x: {
8920
8947
  counterAxis: 'y',
8921
- scale: 'scaleX',
8922
- skew: 'skewX',
8948
+ scale: SCALE_X,
8949
+ skew: SKEW_X,
8923
8950
  lockSkewing: 'lockSkewingX',
8924
8951
  origin: 'originX',
8925
8952
  flip: 'flipX'
8926
8953
  },
8927
8954
  y: {
8928
8955
  counterAxis: 'x',
8929
- scale: 'scaleY',
8930
- skew: 'skewY',
8956
+ scale: SCALE_Y,
8957
+ skew: SKEW_Y,
8931
8958
  lockSkewing: 'lockSkewingY',
8932
8959
  origin: 'originY',
8933
8960
  flip: 'flipY'
@@ -9006,7 +9033,7 @@ function skewObject(axis, _ref, pointer) {
9006
9033
  }),
9007
9034
  dimAfter = target._getTransformedDimensions(),
9008
9035
  compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;
9009
- compensationFactor !== 1 && target.set('scaleX', compensationFactor * scaleX);
9036
+ compensationFactor !== 1 && target.set(SCALE_X, compensationFactor * scaleX);
9010
9037
  }
9011
9038
  return changed;
9012
9039
  }
@@ -9052,7 +9079,7 @@ function skewHandler(axis, eventData, transform, x, y) {
9052
9079
  // anchor to the opposite side of the skewing direction
9053
9080
  // normalize value from [-1, 1] to origin value [0, 1]
9054
9081
  origin = -skewingDirection * 0.5 + 0.5;
9055
- const finalHandler = wrapWithFireEvent('skewing', wrapWithFixedAnchor((eventData, transform, x, y) => skewObject(axis, transform, new Point(x, y))));
9082
+ const finalHandler = wrapWithFireEvent(SKEWING, wrapWithFixedAnchor((eventData, transform, x, y) => skewObject(axis, transform, new Point(x, y))));
9056
9083
  return finalHandler(eventData, _objectSpread2(_objectSpread2({}, transform), {}, {
9057
9084
  [originKey]: origin,
9058
9085
  skewingSide
@@ -9100,11 +9127,11 @@ const scaleOrSkewActionName = (eventData, control, fabricObject) => {
9100
9127
  const isAlternative = isAltAction(eventData, fabricObject);
9101
9128
  if (control.x === 0) {
9102
9129
  // then is scaleY or skewX
9103
- return isAlternative ? 'skewX' : 'scaleY';
9130
+ return isAlternative ? SKEW_X : SCALE_Y;
9104
9131
  }
9105
9132
  if (control.y === 0) {
9106
9133
  // then is scaleY or skewX
9107
- return isAlternative ? 'skewY' : 'scaleX';
9134
+ return isAlternative ? SKEW_Y : SCALE_X;
9108
9135
  }
9109
9136
  return '';
9110
9137
  };
@@ -9206,7 +9233,7 @@ const createObjectDefaultControls = () => ({
9206
9233
  cursorStyleHandler: rotationStyleHandler,
9207
9234
  offsetY: -40,
9208
9235
  withConnection: true,
9209
- actionName: 'rotate'
9236
+ actionName: ROTATE
9210
9237
  })
9211
9238
  });
9212
9239
  const createResizeControls = () => ({
@@ -9215,14 +9242,14 @@ const createResizeControls = () => ({
9215
9242
  y: 0,
9216
9243
  actionHandler: changeWidth,
9217
9244
  cursorStyleHandler: scaleSkewCursorStyleHandler,
9218
- actionName: 'resizing'
9245
+ actionName: RESIZING
9219
9246
  }),
9220
9247
  ml: new Control({
9221
9248
  x: -0.5,
9222
9249
  y: 0,
9223
9250
  actionHandler: changeWidth,
9224
9251
  cursorStyleHandler: scaleSkewCursorStyleHandler,
9225
- actionName: 'resizing'
9252
+ actionName: RESIZING
9226
9253
  })
9227
9254
  });
9228
9255
  const createTextboxDefaultControls = () => _objectSpread2(_objectSpread2({}, createObjectDefaultControls()), createResizeControls());
@@ -9266,7 +9293,7 @@ class InteractiveFabricObject extends FabricObject$1 {
9266
9293
  const transform = targetCanvas._currentTransform,
9267
9294
  target = transform.target,
9268
9295
  action = transform.action;
9269
- if (this === target && action && action.startsWith('scale')) {
9296
+ if (this === target && action && action.startsWith(SCALE)) {
9270
9297
  return false;
9271
9298
  }
9272
9299
  }
@@ -10422,7 +10449,7 @@ const stylesFromArray = (styles, text) => {
10422
10449
  * Attributes parsed from all SVG elements
10423
10450
  * @type array
10424
10451
  */
10425
- 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'];
10452
+ 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'];
10426
10453
 
10427
10454
  function selectorMatches(element, selector) {
10428
10455
  const nodeName = element.nodeName;
@@ -10554,7 +10581,7 @@ function parseTransformAttribute(attributeValue) {
10554
10581
  case 'translate':
10555
10582
  matrix = createTranslateMatrix(arg0, arg1);
10556
10583
  break;
10557
- case 'rotate':
10584
+ case ROTATE:
10558
10585
  matrix = createRotateMatrix({
10559
10586
  angle: arg0
10560
10587
  }, {
@@ -10562,13 +10589,13 @@ function parseTransformAttribute(attributeValue) {
10562
10589
  y: arg2
10563
10590
  });
10564
10591
  break;
10565
- case 'scale':
10592
+ case SCALE:
10566
10593
  matrix = createScaleMatrix(arg0, arg1);
10567
10594
  break;
10568
- case 'skewX':
10595
+ case SKEW_X:
10569
10596
  matrix = createSkewXMatrix(arg0);
10570
10597
  break;
10571
- case 'skewY':
10598
+ case SKEW_Y:
10572
10599
  matrix = createSkewYMatrix(arg0);
10573
10600
  break;
10574
10601
  case 'matrix':
@@ -10586,7 +10613,7 @@ function normalizeValue(attr, value, parentAttributes, fontSize) {
10586
10613
  const isArray = Array.isArray(value);
10587
10614
  let parsed;
10588
10615
  let ouputValue = value;
10589
- if ((attr === 'fill' || attr === 'stroke') && value === NONE) {
10616
+ if ((attr === FILL || attr === STROKE) && value === NONE) {
10590
10617
  ouputValue = '';
10591
10618
  } else if (attr === 'strokeUniform') {
10592
10619
  return value === 'non-scaling-stroke';
@@ -10619,13 +10646,13 @@ function normalizeValue(attr, value, parentAttributes, fontSize) {
10619
10646
  // parseUnit returns px and we convert it to em
10620
10647
  parsed = parseUnit(value, fontSize) / fontSize * 1000;
10621
10648
  } else if (attr === 'paintFirst') {
10622
- const fillIndex = value.indexOf('fill');
10623
- const strokeIndex = value.indexOf('stroke');
10624
- ouputValue = 'fill';
10649
+ const fillIndex = value.indexOf(FILL);
10650
+ const strokeIndex = value.indexOf(STROKE);
10651
+ ouputValue = FILL;
10625
10652
  if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {
10626
- ouputValue = 'stroke';
10653
+ ouputValue = STROKE;
10627
10654
  } else if (fillIndex === -1 && strokeIndex > -1) {
10628
- ouputValue = 'stroke';
10655
+ ouputValue = STROKE;
10629
10656
  }
10630
10657
  } else if (attr === 'href' || attr === 'xlink:href' || attr === 'font') {
10631
10658
  return value;
@@ -10999,16 +11026,21 @@ class LayoutStrategy {
10999
11026
  return this.calcBoundingBox(objects, context);
11000
11027
  }
11001
11028
  }
11002
- shouldPerformLayout(context) {
11003
- return context.type === LAYOUT_TYPE_INITIALIZATION || context.type === LAYOUT_TYPE_IMPERATIVE || !!context.prevStrategy && context.strategy !== context.prevStrategy;
11029
+ shouldPerformLayout(_ref) {
11030
+ let {
11031
+ type,
11032
+ prevStrategy,
11033
+ strategy
11034
+ } = _ref;
11035
+ return type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_IMPERATIVE || !!prevStrategy && strategy !== prevStrategy;
11004
11036
  }
11005
- shouldLayoutClipPath(_ref) {
11037
+ shouldLayoutClipPath(_ref2) {
11006
11038
  let {
11007
11039
  type,
11008
11040
  target: {
11009
11041
  clipPath
11010
11042
  }
11011
- } = _ref;
11043
+ } = _ref2;
11012
11044
  return type !== LAYOUT_TYPE_INITIALIZATION && clipPath && !clipPath.absolutePositioned;
11013
11045
  }
11014
11046
  getInitialSize(context, result) {
@@ -11019,15 +11051,16 @@ class LayoutStrategy {
11019
11051
  * Override this method to customize layout.
11020
11052
  */
11021
11053
  calcBoundingBox(objects, context) {
11022
- if (context.type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {
11054
+ const {
11055
+ type,
11056
+ target
11057
+ } = context;
11058
+ if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {
11023
11059
  return context.overrides;
11024
11060
  }
11025
11061
  if (objects.length === 0) {
11026
11062
  return;
11027
11063
  }
11028
- const {
11029
- target
11030
- } = context;
11031
11064
  const {
11032
11065
  left,
11033
11066
  top,
@@ -11037,7 +11070,7 @@ class LayoutStrategy {
11037
11070
  const bboxSize = new Point(width, height);
11038
11071
  const bboxLeftTop = new Point(left, top);
11039
11072
  const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));
11040
- if (context.type === LAYOUT_TYPE_INITIALIZATION) {
11073
+ if (type === LAYOUT_TYPE_INITIALIZATION) {
11041
11074
  const actualSize = this.getInitialSize(context, {
11042
11075
  size: bboxSize,
11043
11076
  center: bboxCenter
@@ -11121,7 +11154,7 @@ class LayoutManager {
11121
11154
  const {
11122
11155
  target
11123
11156
  } = context;
11124
- return ['modified', 'moving', 'resizing', 'rotating', 'scaling', 'skewing', 'changed', 'modifyPoly'].map(key => object.on(key, e => this.performLayout(key === 'modified' ? {
11157
+ return [MODIFIED, MOVING, RESIZING, ROTATING, SCALING, SKEWING, CHANGED, MODIFY_POLY].map(key => object.on(key, e => this.performLayout(key === MODIFIED ? {
11125
11158
  type: LAYOUT_TYPE_OBJECT_MODIFIED,
11126
11159
  trigger: key,
11127
11160
  e,
@@ -11193,13 +11226,15 @@ class LayoutManager {
11193
11226
  }
11194
11227
  getLayoutResult(context) {
11195
11228
  const {
11196
- target
11229
+ target,
11230
+ strategy,
11231
+ type
11197
11232
  } = context;
11198
- const result = context.strategy.calcLayoutResult(context, target.getObjects());
11233
+ const result = strategy.calcLayoutResult(context, target.getObjects());
11199
11234
  if (!result) {
11200
11235
  return;
11201
11236
  }
11202
- const prevCenter = context.type === LAYOUT_TYPE_INITIALIZATION ? new Point() : target.getRelativeCenterPoint();
11237
+ const prevCenter = type === LAYOUT_TYPE_INITIALIZATION ? new Point() : target.getRelativeCenterPoint();
11203
11238
  const {
11204
11239
  center: nextCenter,
11205
11240
  correction = new Point(),
@@ -11207,7 +11242,7 @@ class LayoutManager {
11207
11242
  } = result;
11208
11243
  const offset = prevCenter.subtract(nextCenter).add(correction).transform(
11209
11244
  // in `initialization` we do not account for target's transformation matrix
11210
- context.type === LAYOUT_TYPE_INITIALIZATION ? iMatrix : invertTransform(target.calcOwnMatrix()), true).add(relativeCorrection);
11245
+ type === LAYOUT_TYPE_INITIALIZATION ? iMatrix : invertTransform(target.calcOwnMatrix()), true).add(relativeCorrection);
11211
11246
  return {
11212
11247
  result,
11213
11248
  prevCenter,
@@ -11312,8 +11347,11 @@ class LayoutManager {
11312
11347
  target.set('dirty', true);
11313
11348
  }
11314
11349
  dispose() {
11315
- this._subscriptions.forEach(disposers => disposers.forEach(d => d()));
11316
- this._subscriptions.clear();
11350
+ const {
11351
+ _subscriptions
11352
+ } = this;
11353
+ _subscriptions.forEach(disposers => disposers.forEach(d => d()));
11354
+ _subscriptions.clear();
11317
11355
  }
11318
11356
  toObject() {
11319
11357
  return {
@@ -12871,8 +12909,8 @@ const _assignTransformMatrixProps = object => {
12871
12909
  } = qrDecompose(object.transformMatrix);
12872
12910
  object.flipX = false;
12873
12911
  object.flipY = false;
12874
- object.set('scaleX', scaleX);
12875
- object.set('scaleY', scaleY);
12912
+ object.set(SCALE_X, scaleX);
12913
+ object.set(SCALE_Y, scaleY);
12876
12914
  object.angle = angle;
12877
12915
  object.skewX = skewX;
12878
12916
  object.skewY = 0;
@@ -13496,9 +13534,9 @@ class SelectableCanvas extends StaticCanvas$1 {
13496
13534
  return;
13497
13535
  }
13498
13536
  let centerTransform;
13499
- if (action === 'scale' || action === 'scaleX' || action === 'scaleY' || action === 'resizing') {
13537
+ if (action === SCALE || action === SCALE_X || action === SCALE_Y || action === RESIZING) {
13500
13538
  centerTransform = this.centeredScaling || target.centeredScaling;
13501
- } else if (action === 'rotate') {
13539
+ } else if (action === ROTATE) {
13502
13540
  centerTransform = this.centeredRotation || target.centeredRotation;
13503
13541
  }
13504
13542
  return centerTransform ? !modifierKeyPressed : modifierKeyPressed;
@@ -14127,7 +14165,7 @@ class SelectableCanvas extends StaticCanvas$1 {
14127
14165
  target.setCoords();
14128
14166
  if (transform.actionPerformed) {
14129
14167
  this.fire('object:modified', options);
14130
- target.fire('modified', options);
14168
+ target.fire(MODIFIED, options);
14131
14169
  }
14132
14170
  }
14133
14171
 
@@ -14214,7 +14252,7 @@ class SelectableCanvas extends StaticCanvas$1 {
14214
14252
  group
14215
14253
  } = instance;
14216
14254
  if (group && isActiveSelection(group) && this._activeObject === group) {
14217
- const layoutProps = ['angle', 'flipX', 'flipY', LEFT, 'scaleX', 'scaleY', 'skewX', 'skewY', TOP];
14255
+ const layoutProps = ['angle', 'flipX', 'flipY', LEFT, SCALE_X, SCALE_Y, SKEW_X, SKEW_Y, TOP];
14218
14256
  const originalValues = pick(instance, layoutProps);
14219
14257
  addTransformToObject(instance, group.calcOwnMatrix());
14220
14258
  return originalValues;
@@ -16944,7 +16982,7 @@ class Circle extends FabricObject {
16944
16982
  * @return {Number}
16945
16983
  */
16946
16984
  getRadiusX() {
16947
- return this.get('radius') * this.get('scaleX');
16985
+ return this.get('radius') * this.get(SCALE_X);
16948
16986
  }
16949
16987
 
16950
16988
  /**
@@ -16952,7 +16990,7 @@ class Circle extends FabricObject {
16952
16990
  * @return {Number}
16953
16991
  */
16954
16992
  getRadiusY() {
16955
- return this.get('radius') * this.get('scaleY');
16993
+ return this.get('radius') * this.get(SCALE_Y);
16956
16994
  }
16957
16995
 
16958
16996
  /**
@@ -17773,7 +17811,7 @@ class Ellipse extends FabricObject {
17773
17811
  * @return {Number}
17774
17812
  */
17775
17813
  getRx() {
17776
- return this.get('rx') * this.get('scaleX');
17814
+ return this.get('rx') * this.get(SCALE_X);
17777
17815
  }
17778
17816
 
17779
17817
  /**
@@ -17781,7 +17819,7 @@ class Ellipse extends FabricObject {
17781
17819
  * @return {Number}
17782
17820
  */
17783
17821
  getRy() {
17784
- return this.get('ry') * this.get('scaleY');
17822
+ return this.get('ry') * this.get(SCALE_Y);
17785
17823
  }
17786
17824
 
17787
17825
  /**
@@ -18087,7 +18125,7 @@ class Polyline extends FabricObject {
18087
18125
  _set(key, value) {
18088
18126
  const changed = this.initialized && this[key] !== value;
18089
18127
  const output = super._set(key, value);
18090
- if (this.exactBoundingBox && changed && ((key === 'scaleX' || key === 'scaleY') && this.strokeUniform && this.constructor.layoutProperties.includes('strokeUniform') || this.constructor.layoutProperties.includes(key))) {
18128
+ if (this.exactBoundingBox && changed && ((key === SCALE_X || key === SCALE_Y) && this.strokeUniform && this.constructor.layoutProperties.includes('strokeUniform') || this.constructor.layoutProperties.includes(key))) {
18091
18129
  this.setDimensions();
18092
18130
  }
18093
18131
  return output;
@@ -18206,7 +18244,7 @@ class Polyline extends FabricObject {
18206
18244
  */
18207
18245
  _defineProperty(Polyline, "ownDefaults", polylineDefaultValues);
18208
18246
  _defineProperty(Polyline, "type", 'Polyline');
18209
- _defineProperty(Polyline, "layoutProperties", ['skewX', 'skewY', 'strokeLineCap', 'strokeLineJoin', 'strokeMiterLimit', 'strokeWidth', 'strokeUniform', 'points']);
18247
+ _defineProperty(Polyline, "layoutProperties", [SKEW_X, SKEW_Y, 'strokeLineCap', 'strokeLineJoin', 'strokeMiterLimit', 'strokeWidth', 'strokeUniform', 'points']);
18210
18248
  _defineProperty(Polyline, "cacheProperties", [...cacheProperties, 'points']);
18211
18249
  _defineProperty(Polyline, "ATTRIBUTE_NAMES", [...SHARED_ATTRIBUTES]);
18212
18250
  classRegistry.setClass(Polyline);
@@ -18226,7 +18264,7 @@ const fontProperties = ['fontSize', 'fontWeight', 'fontFamily', 'fontStyle'];
18226
18264
  const textDecorationProperties = ['underline', 'overline', 'linethrough'];
18227
18265
  const textLayoutProperties = [...fontProperties, 'lineHeight', 'text', 'charSpacing', 'textAlign', 'styles', 'path', 'pathStartOffset', 'pathSide', 'pathAlign'];
18228
18266
  const additionalProps = [...textLayoutProperties, ...textDecorationProperties, 'textBackgroundColor', 'direction'];
18229
- const styleProperties = [...fontProperties, ...textDecorationProperties, 'stroke', 'strokeWidth', 'fill', 'deltaY', 'textBackgroundColor'];
18267
+ const styleProperties = [...fontProperties, ...textDecorationProperties, STROKE, 'strokeWidth', FILL, 'deltaY', 'textBackgroundColor'];
18230
18268
 
18231
18269
  // @TODO: Many things here are configuration related and shouldn't be on the class nor prototype
18232
18270
  // regexes, list of properties that are not suppose to change by instances, magic consts.
@@ -18748,7 +18786,7 @@ class TextSVGExportMixin extends FabricObjectSVGExportMixin {
18748
18786
  deltaY
18749
18787
  } = style;
18750
18788
  const textDecoration = this.getSvgTextDecoration(style);
18751
- 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('');
18789
+ 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('');
18752
18790
  }
18753
18791
 
18754
18792
  /**
@@ -18982,7 +19020,7 @@ class FabricText extends StyledText {
18982
19020
  * @param {CanvasRenderingContext2D} ctx Context to render on
18983
19021
  */
18984
19022
  _renderText(ctx) {
18985
- if (this.paintFirst === 'stroke') {
19023
+ if (this.paintFirst === STROKE) {
18986
19024
  this._renderTextStroke(ctx);
18987
19025
  this._renderTextFill(ctx);
18988
19026
  } else {
@@ -19386,7 +19424,7 @@ class FabricText extends StyledText {
19386
19424
  * @param {CanvasRenderingContext2D} ctx Context to render on
19387
19425
  */
19388
19426
  _renderTextFill(ctx) {
19389
- if (!this.fill && !this.styleHas('fill')) {
19427
+ if (!this.fill && !this.styleHas(FILL)) {
19390
19428
  return;
19391
19429
  }
19392
19430
  this._renderTextCommon(ctx, 'fillText');
@@ -19773,7 +19811,7 @@ class FabricText extends StyledText {
19773
19811
  let boxStart = 0;
19774
19812
  let boxWidth = 0;
19775
19813
  let lastDecoration = this.getValueOfPropertyAt(i, 0, type);
19776
- let lastFill = this.getValueOfPropertyAt(i, 0, 'fill');
19814
+ let lastFill = this.getValueOfPropertyAt(i, 0, FILL);
19777
19815
  let currentDecoration;
19778
19816
  let currentFill;
19779
19817
  const top = topOffset + maxHeight * (1 - this._fontSizeFraction);
@@ -19782,7 +19820,7 @@ class FabricText extends StyledText {
19782
19820
  for (let j = 0, jlen = line.length; j < jlen; j++) {
19783
19821
  const charBox = this.__charBounds[i][j];
19784
19822
  currentDecoration = this.getValueOfPropertyAt(i, j, type);
19785
- currentFill = this.getValueOfPropertyAt(i, j, 'fill');
19823
+ currentFill = this.getValueOfPropertyAt(i, j, FILL);
19786
19824
  const currentSize = this.getHeightOfChar(i, j);
19787
19825
  const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');
19788
19826
  if (path && currentDecoration && currentFill) {
@@ -20309,7 +20347,7 @@ class DraggableTextDelegate {
20309
20347
  target.hiddenTextarea.value = target.text;
20310
20348
  target._updateTextarea();
20311
20349
  target.hiddenTextarea.focus();
20312
- target.fire('changed', {
20350
+ target.fire(CHANGED, {
20313
20351
  index: insertAt + selectionStartOffset,
20314
20352
  action: 'drop'
20315
20353
  });
@@ -20355,7 +20393,7 @@ class DraggableTextDelegate {
20355
20393
  target.selectionStart = target.selectionEnd = selectionStart;
20356
20394
  target.hiddenTextarea && (target.hiddenTextarea.value = target.text);
20357
20395
  target._updateTextarea();
20358
- target.fire('changed', {
20396
+ target.fire(CHANGED, {
20359
20397
  index: selectionStart,
20360
20398
  action: 'dragend'
20361
20399
  });
@@ -20933,7 +20971,7 @@ class ITextBehavior extends FabricText {
20933
20971
  this.setCoords();
20934
20972
  }
20935
20973
  this.fire('editing:exited');
20936
- isTextChanged && this.fire('modified');
20974
+ isTextChanged && this.fire(MODIFIED);
20937
20975
  if (this.canvas) {
20938
20976
  this.canvas.fire('text:editing:exited', {
20939
20977
  target: this
@@ -21412,7 +21450,7 @@ class ITextKeyBehavior extends ITextBehavior {
21412
21450
  }
21413
21451
  const updateAndFire = () => {
21414
21452
  this.updateFromTextArea();
21415
- this.fire('changed');
21453
+ this.fire(CHANGED);
21416
21454
  if (this.canvas) {
21417
21455
  this.canvas.fire('text:changed', {
21418
21456
  target: this
@@ -22513,7 +22551,7 @@ class IText extends ITextClickBehavior {
22513
22551
  // and why can't happen at the top of the function
22514
22552
  this.renderSelection(ctx, boundaries);
22515
22553
  }
22516
- ctx.fillStyle = this.cursorColor || this.getValueOfPropertyAt(lineIndex, charIndex, 'fill');
22554
+ ctx.fillStyle = this.cursorColor || this.getValueOfPropertyAt(lineIndex, charIndex, FILL);
22517
22555
  ctx.globalAlpha = this._currentCursorOpacity;
22518
22556
  ctx.fillRect(boundaries.left + boundaries.leftOffset - cursorWidth / 2, topOffset + boundaries.top + dy, cursorWidth, charHeight);
22519
22557
  }
@@ -22630,7 +22668,7 @@ class IText extends ITextClickBehavior {
22630
22668
  */
22631
22669
  getCurrentCharColor() {
22632
22670
  const cp = this._getCurrentCharIndex();
22633
- return this.getValueOfPropertyAt(cp.l, cp.c, 'fill');
22671
+ return this.getValueOfPropertyAt(cp.l, cp.c, FILL);
22634
22672
  }
22635
22673
 
22636
22674
  /**
@@ -23220,7 +23258,8 @@ class ClipPathLayout extends LayoutStrategy {
23220
23258
  target
23221
23259
  } = context;
23222
23260
  const {
23223
- clipPath
23261
+ clipPath,
23262
+ group
23224
23263
  } = target;
23225
23264
  if (!clipPath || !this.shouldPerformLayout(context)) {
23226
23265
  return;
@@ -23232,9 +23271,8 @@ class ClipPathLayout extends LayoutStrategy {
23232
23271
  } = makeBoundingBoxFromPoints(getObjectBounds(target, clipPath));
23233
23272
  const size = new Point(width, height);
23234
23273
  if (clipPath.absolutePositioned) {
23235
- var _target$group;
23236
23274
  // we want the center point to exist in group's containing plane
23237
- const clipPathCenter = sendPointToPlane(clipPath.getRelativeCenterPoint(), undefined, (_target$group = target.group) === null || _target$group === void 0 ? void 0 : _target$group.calcTransformMatrix());
23275
+ const clipPathCenter = sendPointToPlane(clipPath.getRelativeCenterPoint(), undefined, group ? group.calcTransformMatrix() : undefined);
23238
23276
  return {
23239
23277
  center: clipPathCenter,
23240
23278
  size
@@ -24200,7 +24238,7 @@ class FabricImage extends FabricObject {
24200
24238
  strokeSvg = ["\t<rect x=\"".concat(x, "\" y=\"").concat(y, "\" width=\"").concat(this.width, "\" height=\"").concat(this.height, "\" style=\"").concat(this.getSvgStyles(), "\" />\n")];
24201
24239
  this.fill = origFill;
24202
24240
  }
24203
- if (this.paintFirst !== 'fill') {
24241
+ if (this.paintFirst !== FILL) {
24204
24242
  svgString = svgString.concat(strokeSvg, imageMarkup);
24205
24243
  } else {
24206
24244
  svgString = svgString.concat(imageMarkup, strokeSvg);
@@ -24947,8 +24985,8 @@ class ElementsParser {
24947
24985
  const klass = findTag(el);
24948
24986
  if (klass) {
24949
24987
  const obj = await klass.fromElement(el, this.options, this.cssRules);
24950
- this.resolveGradient(obj, el, 'fill');
24951
- this.resolveGradient(obj, el, 'stroke');
24988
+ this.resolveGradient(obj, el, FILL);
24989
+ this.resolveGradient(obj, el, STROKE);
24952
24990
  if (obj instanceof FabricImage && obj._originalElement) {
24953
24991
  removeTransformMatrixForSvgParsing(obj, obj.parsePreserveAspectRatioAttribute());
24954
24992
  } else {
@@ -25174,7 +25212,7 @@ function loadSVGFromURL(url, reviver) {
25174
25212
  });
25175
25213
  }
25176
25214
 
25177
- const ACTION_NAME = 'modifyPoly';
25215
+ const ACTION_NAME = MODIFY_POLY;
25178
25216
  /**
25179
25217
  * This function locates the controls.
25180
25218
  * It'll be used both for drawing and for interaction.
@@ -26073,7 +26111,7 @@ class Blur extends BaseFilter {
26073
26111
  */
26074
26112
  sendUniformData(gl, uniformLocations) {
26075
26113
  const delta = this.chooseRightDelta();
26076
- gl.uniform2fv(uniformLocations.delta, delta);
26114
+ gl.uniform2fv(uniformLocations.uDelta, delta);
26077
26115
  }
26078
26116
  isNeutralState() {
26079
26117
  return this.blur === 0;
@@ -27028,7 +27066,7 @@ class Pixelate extends BaseFilter {
27028
27066
  }
27029
27067
  _defineProperty(Pixelate, "type", 'Pixelate');
27030
27068
  _defineProperty(Pixelate, "defaults", pixelateDefaultValues);
27031
- _defineProperty(Pixelate, "uniformLocations", ['uBlockSize']);
27069
+ _defineProperty(Pixelate, "uniformLocations", ['uBlocksize']);
27032
27070
  classRegistry.setClass(Pixelate);
27033
27071
 
27034
27072
  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";
@@ -27736,5 +27774,5 @@ class Canvas extends Canvas$1 {
27736
27774
  }
27737
27775
  }
27738
27776
 
27739
- export { ActiveSelection, BaseBrush, FabricObject$1 as BaseFabricObject, Canvas, Canvas2dFilterBackend, CanvasDOMManager, Circle, CircleBrush, ClipPathLayout, Color, Control, Ellipse, FabricImage, FabricObject, FabricText, FitContentLayout, FixedLayout, Gradient, Group, IText, FabricImage as Image, Intersection, LayoutManager, LayoutStrategy, 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, isPutImageFaster, isWebGLPipelineState, loadSVGFromString, loadSVGFromURL, parseAttributes, parseFontDeclaration, parsePointsAttribute, parseSVGDocument, parseStyleAttribute, parseTransformAttribute, runningAnimations, setEnv, setFilterBackend, index$1 as util, VERSION as version };
27777
+ export { ActiveSelection, BaseBrush, FabricObject$1 as BaseFabricObject, Canvas, Canvas2dFilterBackend, CanvasDOMManager, Circle, CircleBrush, ClipPathLayout, Color, Control, Ellipse, FabricImage, FabricObject, FabricText, FitContentLayout, FixedLayout, Gradient, Group, IText, FabricImage as Image, InteractiveFabricObject, Intersection, LayoutManager, LayoutStrategy, 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, isPutImageFaster, isWebGLPipelineState, loadSVGFromString, loadSVGFromURL, parseAttributes, parseFontDeclaration, parsePointsAttribute, parseSVGDocument, parseStyleAttribute, parseTransformAttribute, runningAnimations, setEnv, setFilterBackend, index$1 as util, VERSION as version };
27740
27778
  //# sourceMappingURL=index.node.mjs.map