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
package/dist/index.mjs CHANGED
@@ -401,7 +401,7 @@ class Cache {
401
401
  }
402
402
  const cache = new Cache();
403
403
 
404
- var version = "6.0.0";
404
+ var version = "6.0.2";
405
405
 
406
406
  // use this syntax so babel plugin see this import here
407
407
  const VERSION = version;
@@ -423,6 +423,22 @@ const BOTTOM = 'bottom';
423
423
  const RIGHT = 'right';
424
424
  const NONE = 'none';
425
425
  const reNewline = /\r?\n/;
426
+ const MOVING = 'moving';
427
+ const SCALING = 'scaling';
428
+ const ROTATING = 'rotating';
429
+ const ROTATE = 'rotate';
430
+ const SKEWING = 'skewing';
431
+ const RESIZING = 'resizing';
432
+ const MODIFY_POLY = 'modifyPoly';
433
+ const CHANGED = 'changed';
434
+ const SCALE = 'scale';
435
+ const SCALE_X = 'scaleX';
436
+ const SCALE_Y = 'scaleY';
437
+ const SKEW_X = 'skewX';
438
+ const SKEW_Y = 'skewY';
439
+ const FILL = 'fill';
440
+ const STROKE = 'stroke';
441
+ const MODIFIED = 'modified';
426
442
 
427
443
  /*
428
444
  * This Map connects the objects type value with their
@@ -613,6 +629,14 @@ class Observable {
613
629
  }
614
630
  }
615
631
 
632
+ /**
633
+ * Unsubscribe all event listeners for eventname.
634
+ * Do not use this pattern. You could kill internal fabricJS events.
635
+ * We know we should have protected events for internal flows, but we don't have yet
636
+ * @deprecated
637
+ * @param {string} eventName event name (eg. 'after:render')
638
+ */
639
+
616
640
  /**
617
641
  * unsubscribe an event listener
618
642
  * @param {string} eventName event name (eg. 'after:render')
@@ -1871,6 +1895,7 @@ const loadImage = function (url) {
1871
1895
  });
1872
1896
  };
1873
1897
  /**
1898
+ * @TODO type this correctly.
1874
1899
  * Creates corresponding fabric instances from their object representations
1875
1900
  * @param {Object[]} objects Objects to enliven
1876
1901
  * @param {EnlivenObjectOptions} [options]
@@ -2781,7 +2806,7 @@ const createSVGRect = function (color, _ref) {
2781
2806
  height
2782
2807
  } = _ref;
2783
2808
  let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : config.NUM_FRACTION_DIGITS;
2784
- const svgColor = colorPropToSVG('fill', color, false);
2809
+ const svgColor = colorPropToSVG(FILL, color, false);
2785
2810
  const [x, y, w, h] = [left, top, width, height].map(value => toFixed(value, precision));
2786
2811
  return "<rect ".concat(svgColor, " x=\"").concat(x, "\" y=\"").concat(y, "\" width=\"").concat(w, "\" height=\"").concat(h, "\"></rect>");
2787
2812
  };
@@ -4683,7 +4708,7 @@ const dragHandler = (eventData, transform, x, y) => {
4683
4708
  moveX && target.set(LEFT, newLeft);
4684
4709
  moveY && target.set(TOP, newTop);
4685
4710
  if (moveX || moveY) {
4686
- fireEvent('moving', commonEventInfo(eventData, transform, x, y));
4711
+ fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));
4687
4712
  }
4688
4713
  return moveX || moveY;
4689
4714
  };
@@ -4711,8 +4736,8 @@ class FabricObjectSVGExportMixin {
4711
4736
  opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',
4712
4737
  visibility = this.visible ? '' : ' visibility: hidden;',
4713
4738
  filter = skipShadow ? '' : this.getSvgFilter(),
4714
- fill = colorPropToSVG('fill', this.fill),
4715
- stroke = colorPropToSVG('stroke', this.stroke);
4739
+ fill = colorPropToSVG(FILL, this.fill),
4740
+ stroke = colorPropToSVG(STROKE, this.stroke);
4716
4741
  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('');
4717
4742
  }
4718
4743
 
@@ -4842,7 +4867,7 @@ class FabricObjectSVGExportMixin {
4842
4867
  return reviver ? reviver(markup.join('')) : markup.join('');
4843
4868
  }
4844
4869
  addPaintOrder() {
4845
- return this.paintFirst !== 'fill' ? " paint-order=\"".concat(this.paintFirst, "\" ") : '';
4870
+ return this.paintFirst !== FILL ? " paint-order=\"".concat(this.paintFirst, "\" ") : '';
4846
4871
  }
4847
4872
  }
4848
4873
 
@@ -6230,8 +6255,8 @@ class ObjectGeometry extends ObjectOrigin {
6230
6255
  * @return {void}
6231
6256
  */
6232
6257
  scale(value) {
6233
- this._set('scaleX', value);
6234
- this._set('scaleY', value);
6258
+ this._set(SCALE_X, value);
6259
+ this._set(SCALE_Y, value);
6235
6260
  this.setCoords();
6236
6261
  }
6237
6262
 
@@ -6618,7 +6643,7 @@ class AnimatableObject extends StackedObject {
6618
6643
  * List of properties to consider for animating colors.
6619
6644
  * @type String[]
6620
6645
  */
6621
- _defineProperty(AnimatableObject, "colorProperties", ['fill', 'stroke', 'backgroundColor']);
6646
+ _defineProperty(AnimatableObject, "colorProperties", [FILL, STROKE, 'backgroundColor']);
6622
6647
 
6623
6648
  function getSvgRegex(arr) {
6624
6649
  return new RegExp('^(' + arr.join('|') + ')\\b', 'i');
@@ -6834,8 +6859,8 @@ classRegistry.setClass(Shadow, 'shadow');
6834
6859
 
6835
6860
  const cloneDeep = object => JSON.parse(JSON.stringify(object));
6836
6861
 
6837
- const stateProperties = [TOP, LEFT, 'scaleX', 'scaleY', 'flipX', 'flipY', 'originX', 'originY', 'angle', 'opacity', 'globalCompositeOperation', 'shadow', 'visible', 'skewX', 'skewY'];
6838
- const cacheProperties = ['fill', 'stroke', 'strokeWidth', 'strokeDashArray', 'width', 'height', 'paintFirst', 'strokeUniform', 'strokeLineCap', 'strokeDashOffset', 'strokeLineJoin', 'strokeMiterLimit', 'backgroundColor', 'clipPath'];
6862
+ const stateProperties = [TOP, LEFT, SCALE_X, SCALE_Y, 'flipX', 'flipY', 'originX', 'originY', 'angle', 'opacity', 'globalCompositeOperation', 'shadow', 'visible', SKEW_X, SKEW_Y];
6863
+ const cacheProperties = [FILL, STROKE, 'strokeWidth', 'strokeDashArray', 'width', 'height', 'paintFirst', 'strokeUniform', 'strokeLineCap', 'strokeDashOffset', 'strokeLineJoin', 'strokeMiterLimit', 'backgroundColor', 'clipPath'];
6839
6864
  const fabricObjectDefaultValues = {
6840
6865
  // see composeMatrix() to see order of transforms. First defaults listed based on this
6841
6866
  top: 0,
@@ -6856,7 +6881,7 @@ const fabricObjectDefaultValues = {
6856
6881
  strokeUniform: false,
6857
6882
  padding: 0,
6858
6883
  opacity: 1,
6859
- paintFirst: 'fill',
6884
+ paintFirst: FILL,
6860
6885
  fill: 'rgb(0,0,0)',
6861
6886
  fillRule: 'nonzero',
6862
6887
  stroke: null,
@@ -6947,18 +6972,20 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
6947
6972
  }
6948
6973
 
6949
6974
  /**
6950
- * The class type. Used to identify which class this is.
6951
- * This is used for serialization purposes and internally it can be used
6952
- * to identify classes. As a developer you could use `instance of Class`
6953
- * but to avoid importing all the code and blocking tree shaking we try
6954
- * to avoid doing that.
6975
+ * The class type.
6976
+ * This is used for serialization and deserialization purposes and internally it can be used
6977
+ * to identify classes.
6978
+ * When we transform a class in a plain JS object we need a way to recognize which class it was,
6979
+ * and the type is the way we do that. It has no other purposes and you should not give one.
6980
+ * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).
6981
+ * To idenfity a class use instanceof class ( instanceof Rect ).
6982
+ * We do not do that in fabricJS code because we want to try to have code splitting possible.
6955
6983
  */
6956
6984
 
6957
6985
  /**
6958
6986
  * Legacy identifier of the class. Prefer using utils like isType or instanceOf
6959
6987
  * Will be removed in fabric 7 or 8.
6960
- * The setter exists because is very hard to catch all the ways in which a type value
6961
- * could be set in the instance
6988
+ * The setter exists to avoid type errors in old code and possibly current deserialization code.
6962
6989
  * @TODO add sustainable warning message
6963
6990
  * @type string
6964
6991
  * @deprecated
@@ -7329,10 +7356,10 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7329
7356
  * @param {*} value
7330
7357
  */
7331
7358
  _set(key, value) {
7332
- if (key === 'scaleX' || key === 'scaleY') {
7359
+ if (key === SCALE_X || key === SCALE_Y) {
7333
7360
  value = this._constrainScale(value);
7334
7361
  }
7335
- if (key === 'scaleX' && value < 0) {
7362
+ if (key === SCALE_X && value < 0) {
7336
7363
  this.flipX = !this.flipX;
7337
7364
  value *= -1;
7338
7365
  } else if (key === 'scaleY' && value < 0) {
@@ -7453,7 +7480,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7453
7480
  * @returns Boolean
7454
7481
  */
7455
7482
  needsItsOwnCache() {
7456
- if (this.paintFirst === 'stroke' && this.hasFill() && this.hasStroke() && !!this.shadow) {
7483
+ if (this.paintFirst === STROKE && this.hasFill() && this.hasStroke() && !!this.shadow) {
7457
7484
  return true;
7458
7485
  }
7459
7486
  if (this.clipPath) {
@@ -7748,7 +7775,7 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
7748
7775
  * @param {CanvasRenderingContext2D} ctx Context to render on
7749
7776
  */
7750
7777
  _renderPaintInOrder(ctx) {
7751
- if (this.paintFirst === 'stroke') {
7778
+ if (this.paintFirst === STROKE) {
7752
7779
  this._renderStroke(ctx);
7753
7780
  this._renderFill(ctx);
7754
7781
  } else {
@@ -8225,7 +8252,7 @@ const changeObjectWidth = (eventData, transform, x, y) => {
8225
8252
  }
8226
8253
  return false;
8227
8254
  };
8228
- const changeWidth = wrapWithFireEvent('resizing', wrapWithFixedAnchor(changeObjectWidth));
8255
+ const changeWidth = wrapWithFireEvent(RESIZING, wrapWithFixedAnchor(changeObjectWidth));
8229
8256
 
8230
8257
  /**
8231
8258
  * Render a round control, as per fabric features.
@@ -8243,7 +8270,7 @@ function renderCircleControl(ctx, left, top, styleOverride, fabricObject) {
8243
8270
  const xSize = this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,
8244
8271
  ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,
8245
8272
  transparentCorners = typeof styleOverride.transparentCorners !== 'undefined' ? styleOverride.transparentCorners : fabricObject.transparentCorners,
8246
- methodName = transparentCorners ? 'stroke' : 'fill',
8273
+ methodName = transparentCorners ? STROKE : FILL,
8247
8274
  stroke = !transparentCorners && (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);
8248
8275
  let myLeft = left,
8249
8276
  myTop = top,
@@ -8290,7 +8317,7 @@ function renderSquareControl(ctx, left, top, styleOverride, fabricObject) {
8290
8317
  const xSize = this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,
8291
8318
  ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,
8292
8319
  transparentCorners = typeof styleOverride.transparentCorners !== 'undefined' ? styleOverride.transparentCorners : fabricObject.transparentCorners,
8293
- methodName = transparentCorners ? 'stroke' : 'fill',
8320
+ methodName = transparentCorners ? STROKE : FILL,
8294
8321
  stroke = !transparentCorners && (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),
8295
8322
  xSizeBy2 = xSize / 2,
8296
8323
  ySizeBy2 = ySize / 2;
@@ -8335,7 +8362,7 @@ class Control {
8335
8362
  * @type {String}
8336
8363
  * @default 'scale'
8337
8364
  */
8338
- _defineProperty(this, "actionName", 'scale');
8365
+ _defineProperty(this, "actionName", SCALE);
8339
8366
  /**
8340
8367
  * Drawing angle of the control.
8341
8368
  * NOT used for now, but name marked as needed for internal logic
@@ -8653,7 +8680,7 @@ const rotateObjectWithSnapping = (eventData, _ref, x, y) => {
8653
8680
  target.angle = angle;
8654
8681
  return hasRotated;
8655
8682
  };
8656
- const rotationWithSnapping = wrapWithFireEvent('rotating', wrapWithFixedAnchor(rotateObjectWithSnapping));
8683
+ const rotationWithSnapping = wrapWithFireEvent(ROTATING, wrapWithFixedAnchor(rotateObjectWithSnapping));
8657
8684
 
8658
8685
  /**
8659
8686
  * Inspect event and fabricObject properties to understand if the scaling action
@@ -8802,12 +8829,12 @@ function scaleObject(eventData, transform, x, y) {
8802
8829
  const oldScaleX = target.scaleX,
8803
8830
  oldScaleY = target.scaleY;
8804
8831
  if (!by) {
8805
- !isLocked(target, 'lockScalingX') && target.set('scaleX', scaleX);
8806
- !isLocked(target, 'lockScalingY') && target.set('scaleY', scaleY);
8832
+ !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);
8833
+ !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);
8807
8834
  } else {
8808
8835
  // forbidden cases already handled on top here.
8809
- by === 'x' && target.set('scaleX', scaleX);
8810
- by === 'y' && target.set('scaleY', scaleY);
8836
+ by === 'x' && target.set(SCALE_X, scaleX);
8837
+ by === 'y' && target.set(SCALE_Y, scaleY);
8811
8838
  }
8812
8839
  return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;
8813
8840
  }
@@ -8854,24 +8881,24 @@ const scaleObjectY = (eventData, transform, x, y) => {
8854
8881
  by: 'y'
8855
8882
  });
8856
8883
  };
8857
- const scalingEqually = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectFromCorner));
8858
- const scalingX = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectX));
8859
- const scalingY = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectY));
8884
+ const scalingEqually = wrapWithFireEvent(SCALING, wrapWithFixedAnchor(scaleObjectFromCorner));
8885
+ const scalingX = wrapWithFireEvent(SCALING, wrapWithFixedAnchor(scaleObjectX));
8886
+ const scalingY = wrapWithFireEvent(SCALING, wrapWithFixedAnchor(scaleObjectY));
8860
8887
 
8861
8888
  const _excluded$d = ["target", "ex", "ey", "skewingSide"];
8862
8889
  const AXIS_KEYS = {
8863
8890
  x: {
8864
8891
  counterAxis: 'y',
8865
- scale: 'scaleX',
8866
- skew: 'skewX',
8892
+ scale: SCALE_X,
8893
+ skew: SKEW_X,
8867
8894
  lockSkewing: 'lockSkewingX',
8868
8895
  origin: 'originX',
8869
8896
  flip: 'flipX'
8870
8897
  },
8871
8898
  y: {
8872
8899
  counterAxis: 'x',
8873
- scale: 'scaleY',
8874
- skew: 'skewY',
8900
+ scale: SCALE_Y,
8901
+ skew: SKEW_Y,
8875
8902
  lockSkewing: 'lockSkewingY',
8876
8903
  origin: 'originY',
8877
8904
  flip: 'flipY'
@@ -8950,7 +8977,7 @@ function skewObject(axis, _ref, pointer) {
8950
8977
  }),
8951
8978
  dimAfter = target._getTransformedDimensions(),
8952
8979
  compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;
8953
- compensationFactor !== 1 && target.set('scaleX', compensationFactor * scaleX);
8980
+ compensationFactor !== 1 && target.set(SCALE_X, compensationFactor * scaleX);
8954
8981
  }
8955
8982
  return changed;
8956
8983
  }
@@ -8996,7 +9023,7 @@ function skewHandler(axis, eventData, transform, x, y) {
8996
9023
  // anchor to the opposite side of the skewing direction
8997
9024
  // normalize value from [-1, 1] to origin value [0, 1]
8998
9025
  origin = -skewingDirection * 0.5 + 0.5;
8999
- const finalHandler = wrapWithFireEvent('skewing', wrapWithFixedAnchor((eventData, transform, x, y) => skewObject(axis, transform, new Point(x, y))));
9026
+ const finalHandler = wrapWithFireEvent(SKEWING, wrapWithFixedAnchor((eventData, transform, x, y) => skewObject(axis, transform, new Point(x, y))));
9000
9027
  return finalHandler(eventData, _objectSpread2(_objectSpread2({}, transform), {}, {
9001
9028
  [originKey]: origin,
9002
9029
  skewingSide
@@ -9044,11 +9071,11 @@ const scaleOrSkewActionName = (eventData, control, fabricObject) => {
9044
9071
  const isAlternative = isAltAction(eventData, fabricObject);
9045
9072
  if (control.x === 0) {
9046
9073
  // then is scaleY or skewX
9047
- return isAlternative ? 'skewX' : 'scaleY';
9074
+ return isAlternative ? SKEW_X : SCALE_Y;
9048
9075
  }
9049
9076
  if (control.y === 0) {
9050
9077
  // then is scaleY or skewX
9051
- return isAlternative ? 'skewY' : 'scaleX';
9078
+ return isAlternative ? SKEW_Y : SCALE_X;
9052
9079
  }
9053
9080
  return '';
9054
9081
  };
@@ -9150,7 +9177,7 @@ const createObjectDefaultControls = () => ({
9150
9177
  cursorStyleHandler: rotationStyleHandler,
9151
9178
  offsetY: -40,
9152
9179
  withConnection: true,
9153
- actionName: 'rotate'
9180
+ actionName: ROTATE
9154
9181
  })
9155
9182
  });
9156
9183
  const createResizeControls = () => ({
@@ -9159,14 +9186,14 @@ const createResizeControls = () => ({
9159
9186
  y: 0,
9160
9187
  actionHandler: changeWidth,
9161
9188
  cursorStyleHandler: scaleSkewCursorStyleHandler,
9162
- actionName: 'resizing'
9189
+ actionName: RESIZING
9163
9190
  }),
9164
9191
  ml: new Control({
9165
9192
  x: -0.5,
9166
9193
  y: 0,
9167
9194
  actionHandler: changeWidth,
9168
9195
  cursorStyleHandler: scaleSkewCursorStyleHandler,
9169
- actionName: 'resizing'
9196
+ actionName: RESIZING
9170
9197
  })
9171
9198
  });
9172
9199
  const createTextboxDefaultControls = () => _objectSpread2(_objectSpread2({}, createObjectDefaultControls()), createResizeControls());
@@ -9210,7 +9237,7 @@ class InteractiveFabricObject extends FabricObject$1 {
9210
9237
  const transform = targetCanvas._currentTransform,
9211
9238
  target = transform.target,
9212
9239
  action = transform.action;
9213
- if (this === target && action && action.startsWith('scale')) {
9240
+ if (this === target && action && action.startsWith(SCALE)) {
9214
9241
  return false;
9215
9242
  }
9216
9243
  }
@@ -10366,7 +10393,7 @@ const stylesFromArray = (styles, text) => {
10366
10393
  * Attributes parsed from all SVG elements
10367
10394
  * @type array
10368
10395
  */
10369
- 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'];
10396
+ 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'];
10370
10397
 
10371
10398
  function selectorMatches(element, selector) {
10372
10399
  const nodeName = element.nodeName;
@@ -10498,7 +10525,7 @@ function parseTransformAttribute(attributeValue) {
10498
10525
  case 'translate':
10499
10526
  matrix = createTranslateMatrix(arg0, arg1);
10500
10527
  break;
10501
- case 'rotate':
10528
+ case ROTATE:
10502
10529
  matrix = createRotateMatrix({
10503
10530
  angle: arg0
10504
10531
  }, {
@@ -10506,13 +10533,13 @@ function parseTransformAttribute(attributeValue) {
10506
10533
  y: arg2
10507
10534
  });
10508
10535
  break;
10509
- case 'scale':
10536
+ case SCALE:
10510
10537
  matrix = createScaleMatrix(arg0, arg1);
10511
10538
  break;
10512
- case 'skewX':
10539
+ case SKEW_X:
10513
10540
  matrix = createSkewXMatrix(arg0);
10514
10541
  break;
10515
- case 'skewY':
10542
+ case SKEW_Y:
10516
10543
  matrix = createSkewYMatrix(arg0);
10517
10544
  break;
10518
10545
  case 'matrix':
@@ -10530,7 +10557,7 @@ function normalizeValue(attr, value, parentAttributes, fontSize) {
10530
10557
  const isArray = Array.isArray(value);
10531
10558
  let parsed;
10532
10559
  let ouputValue = value;
10533
- if ((attr === 'fill' || attr === 'stroke') && value === NONE) {
10560
+ if ((attr === FILL || attr === STROKE) && value === NONE) {
10534
10561
  ouputValue = '';
10535
10562
  } else if (attr === 'strokeUniform') {
10536
10563
  return value === 'non-scaling-stroke';
@@ -10563,13 +10590,13 @@ function normalizeValue(attr, value, parentAttributes, fontSize) {
10563
10590
  // parseUnit returns px and we convert it to em
10564
10591
  parsed = parseUnit(value, fontSize) / fontSize * 1000;
10565
10592
  } else if (attr === 'paintFirst') {
10566
- const fillIndex = value.indexOf('fill');
10567
- const strokeIndex = value.indexOf('stroke');
10568
- ouputValue = 'fill';
10593
+ const fillIndex = value.indexOf(FILL);
10594
+ const strokeIndex = value.indexOf(STROKE);
10595
+ ouputValue = FILL;
10569
10596
  if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {
10570
- ouputValue = 'stroke';
10597
+ ouputValue = STROKE;
10571
10598
  } else if (fillIndex === -1 && strokeIndex > -1) {
10572
- ouputValue = 'stroke';
10599
+ ouputValue = STROKE;
10573
10600
  }
10574
10601
  } else if (attr === 'href' || attr === 'xlink:href' || attr === 'font') {
10575
10602
  return value;
@@ -10943,16 +10970,21 @@ class LayoutStrategy {
10943
10970
  return this.calcBoundingBox(objects, context);
10944
10971
  }
10945
10972
  }
10946
- shouldPerformLayout(context) {
10947
- return context.type === LAYOUT_TYPE_INITIALIZATION || context.type === LAYOUT_TYPE_IMPERATIVE || !!context.prevStrategy && context.strategy !== context.prevStrategy;
10973
+ shouldPerformLayout(_ref) {
10974
+ let {
10975
+ type,
10976
+ prevStrategy,
10977
+ strategy
10978
+ } = _ref;
10979
+ return type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_IMPERATIVE || !!prevStrategy && strategy !== prevStrategy;
10948
10980
  }
10949
- shouldLayoutClipPath(_ref) {
10981
+ shouldLayoutClipPath(_ref2) {
10950
10982
  let {
10951
10983
  type,
10952
10984
  target: {
10953
10985
  clipPath
10954
10986
  }
10955
- } = _ref;
10987
+ } = _ref2;
10956
10988
  return type !== LAYOUT_TYPE_INITIALIZATION && clipPath && !clipPath.absolutePositioned;
10957
10989
  }
10958
10990
  getInitialSize(context, result) {
@@ -10963,15 +10995,16 @@ class LayoutStrategy {
10963
10995
  * Override this method to customize layout.
10964
10996
  */
10965
10997
  calcBoundingBox(objects, context) {
10966
- if (context.type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {
10998
+ const {
10999
+ type,
11000
+ target
11001
+ } = context;
11002
+ if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {
10967
11003
  return context.overrides;
10968
11004
  }
10969
11005
  if (objects.length === 0) {
10970
11006
  return;
10971
11007
  }
10972
- const {
10973
- target
10974
- } = context;
10975
11008
  const {
10976
11009
  left,
10977
11010
  top,
@@ -10981,7 +11014,7 @@ class LayoutStrategy {
10981
11014
  const bboxSize = new Point(width, height);
10982
11015
  const bboxLeftTop = new Point(left, top);
10983
11016
  const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));
10984
- if (context.type === LAYOUT_TYPE_INITIALIZATION) {
11017
+ if (type === LAYOUT_TYPE_INITIALIZATION) {
10985
11018
  const actualSize = this.getInitialSize(context, {
10986
11019
  size: bboxSize,
10987
11020
  center: bboxCenter
@@ -11065,7 +11098,7 @@ class LayoutManager {
11065
11098
  const {
11066
11099
  target
11067
11100
  } = context;
11068
- return ['modified', 'moving', 'resizing', 'rotating', 'scaling', 'skewing', 'changed', 'modifyPoly'].map(key => object.on(key, e => this.performLayout(key === 'modified' ? {
11101
+ return [MODIFIED, MOVING, RESIZING, ROTATING, SCALING, SKEWING, CHANGED, MODIFY_POLY].map(key => object.on(key, e => this.performLayout(key === MODIFIED ? {
11069
11102
  type: LAYOUT_TYPE_OBJECT_MODIFIED,
11070
11103
  trigger: key,
11071
11104
  e,
@@ -11137,13 +11170,15 @@ class LayoutManager {
11137
11170
  }
11138
11171
  getLayoutResult(context) {
11139
11172
  const {
11140
- target
11173
+ target,
11174
+ strategy,
11175
+ type
11141
11176
  } = context;
11142
- const result = context.strategy.calcLayoutResult(context, target.getObjects());
11177
+ const result = strategy.calcLayoutResult(context, target.getObjects());
11143
11178
  if (!result) {
11144
11179
  return;
11145
11180
  }
11146
- const prevCenter = context.type === LAYOUT_TYPE_INITIALIZATION ? new Point() : target.getRelativeCenterPoint();
11181
+ const prevCenter = type === LAYOUT_TYPE_INITIALIZATION ? new Point() : target.getRelativeCenterPoint();
11147
11182
  const {
11148
11183
  center: nextCenter,
11149
11184
  correction = new Point(),
@@ -11151,7 +11186,7 @@ class LayoutManager {
11151
11186
  } = result;
11152
11187
  const offset = prevCenter.subtract(nextCenter).add(correction).transform(
11153
11188
  // in `initialization` we do not account for target's transformation matrix
11154
- context.type === LAYOUT_TYPE_INITIALIZATION ? iMatrix : invertTransform(target.calcOwnMatrix()), true).add(relativeCorrection);
11189
+ type === LAYOUT_TYPE_INITIALIZATION ? iMatrix : invertTransform(target.calcOwnMatrix()), true).add(relativeCorrection);
11155
11190
  return {
11156
11191
  result,
11157
11192
  prevCenter,
@@ -11256,8 +11291,11 @@ class LayoutManager {
11256
11291
  target.set('dirty', true);
11257
11292
  }
11258
11293
  dispose() {
11259
- this._subscriptions.forEach(disposers => disposers.forEach(d => d()));
11260
- this._subscriptions.clear();
11294
+ const {
11295
+ _subscriptions
11296
+ } = this;
11297
+ _subscriptions.forEach(disposers => disposers.forEach(d => d()));
11298
+ _subscriptions.clear();
11261
11299
  }
11262
11300
  toObject() {
11263
11301
  return {
@@ -12815,8 +12853,8 @@ const _assignTransformMatrixProps = object => {
12815
12853
  } = qrDecompose(object.transformMatrix);
12816
12854
  object.flipX = false;
12817
12855
  object.flipY = false;
12818
- object.set('scaleX', scaleX);
12819
- object.set('scaleY', scaleY);
12856
+ object.set(SCALE_X, scaleX);
12857
+ object.set(SCALE_Y, scaleY);
12820
12858
  object.angle = angle;
12821
12859
  object.skewX = skewX;
12822
12860
  object.skewY = 0;
@@ -13440,9 +13478,9 @@ class SelectableCanvas extends StaticCanvas {
13440
13478
  return;
13441
13479
  }
13442
13480
  let centerTransform;
13443
- if (action === 'scale' || action === 'scaleX' || action === 'scaleY' || action === 'resizing') {
13481
+ if (action === SCALE || action === SCALE_X || action === SCALE_Y || action === RESIZING) {
13444
13482
  centerTransform = this.centeredScaling || target.centeredScaling;
13445
- } else if (action === 'rotate') {
13483
+ } else if (action === ROTATE) {
13446
13484
  centerTransform = this.centeredRotation || target.centeredRotation;
13447
13485
  }
13448
13486
  return centerTransform ? !modifierKeyPressed : modifierKeyPressed;
@@ -14071,7 +14109,7 @@ class SelectableCanvas extends StaticCanvas {
14071
14109
  target.setCoords();
14072
14110
  if (transform.actionPerformed) {
14073
14111
  this.fire('object:modified', options);
14074
- target.fire('modified', options);
14112
+ target.fire(MODIFIED, options);
14075
14113
  }
14076
14114
  }
14077
14115
 
@@ -14158,7 +14196,7 @@ class SelectableCanvas extends StaticCanvas {
14158
14196
  group
14159
14197
  } = instance;
14160
14198
  if (group && isActiveSelection(group) && this._activeObject === group) {
14161
- const layoutProps = ['angle', 'flipX', 'flipY', LEFT, 'scaleX', 'scaleY', 'skewX', 'skewY', TOP];
14199
+ const layoutProps = ['angle', 'flipX', 'flipY', LEFT, SCALE_X, SCALE_Y, SKEW_X, SKEW_Y, TOP];
14162
14200
  const originalValues = pick(instance, layoutProps);
14163
14201
  addTransformToObject(instance, group.calcOwnMatrix());
14164
14202
  return originalValues;
@@ -16888,7 +16926,7 @@ class Circle extends FabricObject {
16888
16926
  * @return {Number}
16889
16927
  */
16890
16928
  getRadiusX() {
16891
- return this.get('radius') * this.get('scaleX');
16929
+ return this.get('radius') * this.get(SCALE_X);
16892
16930
  }
16893
16931
 
16894
16932
  /**
@@ -16896,7 +16934,7 @@ class Circle extends FabricObject {
16896
16934
  * @return {Number}
16897
16935
  */
16898
16936
  getRadiusY() {
16899
- return this.get('radius') * this.get('scaleY');
16937
+ return this.get('radius') * this.get(SCALE_Y);
16900
16938
  }
16901
16939
 
16902
16940
  /**
@@ -17717,7 +17755,7 @@ class Ellipse extends FabricObject {
17717
17755
  * @return {Number}
17718
17756
  */
17719
17757
  getRx() {
17720
- return this.get('rx') * this.get('scaleX');
17758
+ return this.get('rx') * this.get(SCALE_X);
17721
17759
  }
17722
17760
 
17723
17761
  /**
@@ -17725,7 +17763,7 @@ class Ellipse extends FabricObject {
17725
17763
  * @return {Number}
17726
17764
  */
17727
17765
  getRy() {
17728
- return this.get('ry') * this.get('scaleY');
17766
+ return this.get('ry') * this.get(SCALE_Y);
17729
17767
  }
17730
17768
 
17731
17769
  /**
@@ -18031,7 +18069,7 @@ class Polyline extends FabricObject {
18031
18069
  _set(key, value) {
18032
18070
  const changed = this.initialized && this[key] !== value;
18033
18071
  const output = super._set(key, value);
18034
- if (this.exactBoundingBox && changed && ((key === 'scaleX' || key === 'scaleY') && this.strokeUniform && this.constructor.layoutProperties.includes('strokeUniform') || this.constructor.layoutProperties.includes(key))) {
18072
+ if (this.exactBoundingBox && changed && ((key === SCALE_X || key === SCALE_Y) && this.strokeUniform && this.constructor.layoutProperties.includes('strokeUniform') || this.constructor.layoutProperties.includes(key))) {
18035
18073
  this.setDimensions();
18036
18074
  }
18037
18075
  return output;
@@ -18150,7 +18188,7 @@ class Polyline extends FabricObject {
18150
18188
  */
18151
18189
  _defineProperty(Polyline, "ownDefaults", polylineDefaultValues);
18152
18190
  _defineProperty(Polyline, "type", 'Polyline');
18153
- _defineProperty(Polyline, "layoutProperties", ['skewX', 'skewY', 'strokeLineCap', 'strokeLineJoin', 'strokeMiterLimit', 'strokeWidth', 'strokeUniform', 'points']);
18191
+ _defineProperty(Polyline, "layoutProperties", [SKEW_X, SKEW_Y, 'strokeLineCap', 'strokeLineJoin', 'strokeMiterLimit', 'strokeWidth', 'strokeUniform', 'points']);
18154
18192
  _defineProperty(Polyline, "cacheProperties", [...cacheProperties, 'points']);
18155
18193
  _defineProperty(Polyline, "ATTRIBUTE_NAMES", [...SHARED_ATTRIBUTES]);
18156
18194
  classRegistry.setClass(Polyline);
@@ -18170,7 +18208,7 @@ const fontProperties = ['fontSize', 'fontWeight', 'fontFamily', 'fontStyle'];
18170
18208
  const textDecorationProperties = ['underline', 'overline', 'linethrough'];
18171
18209
  const textLayoutProperties = [...fontProperties, 'lineHeight', 'text', 'charSpacing', 'textAlign', 'styles', 'path', 'pathStartOffset', 'pathSide', 'pathAlign'];
18172
18210
  const additionalProps = [...textLayoutProperties, ...textDecorationProperties, 'textBackgroundColor', 'direction'];
18173
- const styleProperties = [...fontProperties, ...textDecorationProperties, 'stroke', 'strokeWidth', 'fill', 'deltaY', 'textBackgroundColor'];
18211
+ const styleProperties = [...fontProperties, ...textDecorationProperties, STROKE, 'strokeWidth', FILL, 'deltaY', 'textBackgroundColor'];
18174
18212
 
18175
18213
  // @TODO: Many things here are configuration related and shouldn't be on the class nor prototype
18176
18214
  // regexes, list of properties that are not suppose to change by instances, magic consts.
@@ -18692,7 +18730,7 @@ class TextSVGExportMixin extends FabricObjectSVGExportMixin {
18692
18730
  deltaY
18693
18731
  } = style;
18694
18732
  const textDecoration = this.getSvgTextDecoration(style);
18695
- 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('');
18733
+ 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('');
18696
18734
  }
18697
18735
 
18698
18736
  /**
@@ -18926,7 +18964,7 @@ class FabricText extends StyledText {
18926
18964
  * @param {CanvasRenderingContext2D} ctx Context to render on
18927
18965
  */
18928
18966
  _renderText(ctx) {
18929
- if (this.paintFirst === 'stroke') {
18967
+ if (this.paintFirst === STROKE) {
18930
18968
  this._renderTextStroke(ctx);
18931
18969
  this._renderTextFill(ctx);
18932
18970
  } else {
@@ -19330,7 +19368,7 @@ class FabricText extends StyledText {
19330
19368
  * @param {CanvasRenderingContext2D} ctx Context to render on
19331
19369
  */
19332
19370
  _renderTextFill(ctx) {
19333
- if (!this.fill && !this.styleHas('fill')) {
19371
+ if (!this.fill && !this.styleHas(FILL)) {
19334
19372
  return;
19335
19373
  }
19336
19374
  this._renderTextCommon(ctx, 'fillText');
@@ -19717,7 +19755,7 @@ class FabricText extends StyledText {
19717
19755
  let boxStart = 0;
19718
19756
  let boxWidth = 0;
19719
19757
  let lastDecoration = this.getValueOfPropertyAt(i, 0, type);
19720
- let lastFill = this.getValueOfPropertyAt(i, 0, 'fill');
19758
+ let lastFill = this.getValueOfPropertyAt(i, 0, FILL);
19721
19759
  let currentDecoration;
19722
19760
  let currentFill;
19723
19761
  const top = topOffset + maxHeight * (1 - this._fontSizeFraction);
@@ -19726,7 +19764,7 @@ class FabricText extends StyledText {
19726
19764
  for (let j = 0, jlen = line.length; j < jlen; j++) {
19727
19765
  const charBox = this.__charBounds[i][j];
19728
19766
  currentDecoration = this.getValueOfPropertyAt(i, j, type);
19729
- currentFill = this.getValueOfPropertyAt(i, j, 'fill');
19767
+ currentFill = this.getValueOfPropertyAt(i, j, FILL);
19730
19768
  const currentSize = this.getHeightOfChar(i, j);
19731
19769
  const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');
19732
19770
  if (path && currentDecoration && currentFill) {
@@ -20253,7 +20291,7 @@ class DraggableTextDelegate {
20253
20291
  target.hiddenTextarea.value = target.text;
20254
20292
  target._updateTextarea();
20255
20293
  target.hiddenTextarea.focus();
20256
- target.fire('changed', {
20294
+ target.fire(CHANGED, {
20257
20295
  index: insertAt + selectionStartOffset,
20258
20296
  action: 'drop'
20259
20297
  });
@@ -20299,7 +20337,7 @@ class DraggableTextDelegate {
20299
20337
  target.selectionStart = target.selectionEnd = selectionStart;
20300
20338
  target.hiddenTextarea && (target.hiddenTextarea.value = target.text);
20301
20339
  target._updateTextarea();
20302
- target.fire('changed', {
20340
+ target.fire(CHANGED, {
20303
20341
  index: selectionStart,
20304
20342
  action: 'dragend'
20305
20343
  });
@@ -20877,7 +20915,7 @@ class ITextBehavior extends FabricText {
20877
20915
  this.setCoords();
20878
20916
  }
20879
20917
  this.fire('editing:exited');
20880
- isTextChanged && this.fire('modified');
20918
+ isTextChanged && this.fire(MODIFIED);
20881
20919
  if (this.canvas) {
20882
20920
  this.canvas.fire('text:editing:exited', {
20883
20921
  target: this
@@ -21356,7 +21394,7 @@ class ITextKeyBehavior extends ITextBehavior {
21356
21394
  }
21357
21395
  const updateAndFire = () => {
21358
21396
  this.updateFromTextArea();
21359
- this.fire('changed');
21397
+ this.fire(CHANGED);
21360
21398
  if (this.canvas) {
21361
21399
  this.canvas.fire('text:changed', {
21362
21400
  target: this
@@ -22457,7 +22495,7 @@ class IText extends ITextClickBehavior {
22457
22495
  // and why can't happen at the top of the function
22458
22496
  this.renderSelection(ctx, boundaries);
22459
22497
  }
22460
- ctx.fillStyle = this.cursorColor || this.getValueOfPropertyAt(lineIndex, charIndex, 'fill');
22498
+ ctx.fillStyle = this.cursorColor || this.getValueOfPropertyAt(lineIndex, charIndex, FILL);
22461
22499
  ctx.globalAlpha = this._currentCursorOpacity;
22462
22500
  ctx.fillRect(boundaries.left + boundaries.leftOffset - cursorWidth / 2, topOffset + boundaries.top + dy, cursorWidth, charHeight);
22463
22501
  }
@@ -22574,7 +22612,7 @@ class IText extends ITextClickBehavior {
22574
22612
  */
22575
22613
  getCurrentCharColor() {
22576
22614
  const cp = this._getCurrentCharIndex();
22577
- return this.getValueOfPropertyAt(cp.l, cp.c, 'fill');
22615
+ return this.getValueOfPropertyAt(cp.l, cp.c, FILL);
22578
22616
  }
22579
22617
 
22580
22618
  /**
@@ -23164,7 +23202,8 @@ class ClipPathLayout extends LayoutStrategy {
23164
23202
  target
23165
23203
  } = context;
23166
23204
  const {
23167
- clipPath
23205
+ clipPath,
23206
+ group
23168
23207
  } = target;
23169
23208
  if (!clipPath || !this.shouldPerformLayout(context)) {
23170
23209
  return;
@@ -23176,9 +23215,8 @@ class ClipPathLayout extends LayoutStrategy {
23176
23215
  } = makeBoundingBoxFromPoints(getObjectBounds(target, clipPath));
23177
23216
  const size = new Point(width, height);
23178
23217
  if (clipPath.absolutePositioned) {
23179
- var _target$group;
23180
23218
  // we want the center point to exist in group's containing plane
23181
- const clipPathCenter = sendPointToPlane(clipPath.getRelativeCenterPoint(), undefined, (_target$group = target.group) === null || _target$group === void 0 ? void 0 : _target$group.calcTransformMatrix());
23219
+ const clipPathCenter = sendPointToPlane(clipPath.getRelativeCenterPoint(), undefined, group ? group.calcTransformMatrix() : undefined);
23182
23220
  return {
23183
23221
  center: clipPathCenter,
23184
23222
  size
@@ -24144,7 +24182,7 @@ class FabricImage extends FabricObject {
24144
24182
  strokeSvg = ["\t<rect x=\"".concat(x, "\" y=\"").concat(y, "\" width=\"").concat(this.width, "\" height=\"").concat(this.height, "\" style=\"").concat(this.getSvgStyles(), "\" />\n")];
24145
24183
  this.fill = origFill;
24146
24184
  }
24147
- if (this.paintFirst !== 'fill') {
24185
+ if (this.paintFirst !== FILL) {
24148
24186
  svgString = svgString.concat(strokeSvg, imageMarkup);
24149
24187
  } else {
24150
24188
  svgString = svgString.concat(imageMarkup, strokeSvg);
@@ -24891,8 +24929,8 @@ class ElementsParser {
24891
24929
  const klass = findTag(el);
24892
24930
  if (klass) {
24893
24931
  const obj = await klass.fromElement(el, this.options, this.cssRules);
24894
- this.resolveGradient(obj, el, 'fill');
24895
- this.resolveGradient(obj, el, 'stroke');
24932
+ this.resolveGradient(obj, el, FILL);
24933
+ this.resolveGradient(obj, el, STROKE);
24896
24934
  if (obj instanceof FabricImage && obj._originalElement) {
24897
24935
  removeTransformMatrixForSvgParsing(obj, obj.parsePreserveAspectRatioAttribute());
24898
24936
  } else {
@@ -25118,7 +25156,7 @@ function loadSVGFromURL(url, reviver) {
25118
25156
  });
25119
25157
  }
25120
25158
 
25121
- const ACTION_NAME = 'modifyPoly';
25159
+ const ACTION_NAME = MODIFY_POLY;
25122
25160
  /**
25123
25161
  * This function locates the controls.
25124
25162
  * It'll be used both for drawing and for interaction.
@@ -26017,7 +26055,7 @@ class Blur extends BaseFilter {
26017
26055
  */
26018
26056
  sendUniformData(gl, uniformLocations) {
26019
26057
  const delta = this.chooseRightDelta();
26020
- gl.uniform2fv(uniformLocations.delta, delta);
26058
+ gl.uniform2fv(uniformLocations.uDelta, delta);
26021
26059
  }
26022
26060
  isNeutralState() {
26023
26061
  return this.blur === 0;
@@ -26972,7 +27010,7 @@ class Pixelate extends BaseFilter {
26972
27010
  }
26973
27011
  _defineProperty(Pixelate, "type", 'Pixelate');
26974
27012
  _defineProperty(Pixelate, "defaults", pixelateDefaultValues);
26975
- _defineProperty(Pixelate, "uniformLocations", ['uBlockSize']);
27013
+ _defineProperty(Pixelate, "uniformLocations", ['uBlocksize']);
26976
27014
  classRegistry.setClass(Pixelate);
26977
27015
 
26978
27016
  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";
@@ -27646,5 +27684,5 @@ var filters = /*#__PURE__*/Object.freeze({
27646
27684
  Vintage: Vintage
27647
27685
  });
27648
27686
 
27649
- 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, 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 };
27687
+ 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, 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 };
27650
27688
  //# sourceMappingURL=index.mjs.map