fabric 6.0.0-beta1 → 6.0.0-beta11

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 (502) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.js +8 -0
  3. package/.gitpod.yml +17 -1
  4. package/.prettierignore +3 -0
  5. package/CHANGELOG.md +158 -0
  6. package/CONTRIBUTING.md +103 -88
  7. package/README.md +31 -17
  8. package/babel-jest.config.js +6 -0
  9. package/dist/fabric.d.ts +75 -1020
  10. package/dist/{index.cjs → index.js} +22801 -23051
  11. package/dist/index.js.map +1 -0
  12. package/dist/index.min.js +1 -1
  13. package/dist/index.mjs +22790 -23045
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/index.node.cjs +22778 -23007
  16. package/dist/index.node.cjs.map +1 -1
  17. package/dist/index.node.d.ts +9 -4
  18. package/dist/index.node.mjs +22768 -23002
  19. package/dist/index.node.mjs.map +1 -1
  20. package/dist/src/{util/class_registry.d.ts → ClassRegistry.d.ts} +2 -3
  21. package/dist/src/Collection.d.ts +37 -27
  22. package/dist/src/EventTypeDefs.d.ts +39 -42
  23. package/dist/src/Intersection.d.ts +12 -0
  24. package/dist/src/Observable.d.ts +17 -11
  25. package/dist/src/{Pattern.d.ts → Pattern/Pattern.d.ts} +23 -28
  26. package/dist/src/Pattern/index.d.ts +3 -0
  27. package/dist/src/Pattern/types.d.ts +9 -0
  28. package/dist/src/Point.d.ts +42 -42
  29. package/dist/src/Shadow.d.ts +12 -3
  30. package/dist/src/brushes/BaseBrush.d.ts +1 -5
  31. package/dist/src/brushes/CircleBrush.d.ts +2 -7
  32. package/dist/src/brushes/PatternBrush.d.ts +2 -2
  33. package/dist/src/brushes/PencilBrush.d.ts +8 -8
  34. package/dist/src/brushes/SprayBrush.d.ts +2 -7
  35. package/dist/src/brushes/typedefs.d.ts +18 -0
  36. package/dist/src/cache.d.ts +2 -1
  37. package/dist/src/canvas/Canvas.d.ts +22 -229
  38. package/dist/src/canvas/CanvasOptions.d.ts +232 -0
  39. package/dist/src/canvas/DOMManagers/CanvasDOMManager.d.ts +29 -0
  40. package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.d.ts +29 -0
  41. package/dist/src/canvas/DOMManagers/util.d.ts +24 -0
  42. package/dist/src/canvas/SelectableCanvas.d.ts +52 -265
  43. package/dist/src/canvas/StaticCanvas.d.ts +57 -195
  44. package/dist/src/canvas/StaticCanvasOptions.d.ts +153 -0
  45. package/dist/src/canvas/TextEditingManager.d.ts +5 -1
  46. package/dist/src/color/Color.d.ts +1 -23
  47. package/dist/src/color/constants.d.ts +96 -14
  48. package/dist/src/color/typedefs.d.ts +16 -0
  49. package/dist/src/color/util.d.ts +18 -3
  50. package/dist/src/constants.d.ts +8 -1
  51. package/dist/src/controls/Control.d.ts +14 -13
  52. package/dist/src/controls/changeWidth.d.ts +1 -1
  53. package/dist/src/controls/{default_controls.d.ts → commonControls.d.ts} +1 -23
  54. package/dist/src/controls/{controls.render.d.ts → controlRendering.d.ts} +6 -6
  55. package/dist/src/controls/drag.d.ts +1 -1
  56. package/dist/src/controls/fireEvent.d.ts +3 -0
  57. package/dist/src/controls/index.d.ts +13 -0
  58. package/dist/src/controls/rotate.d.ts +1 -1
  59. package/dist/src/controls/scale.d.ts +2 -2
  60. package/dist/src/controls/scaleSkew.d.ts +2 -2
  61. package/dist/src/controls/skew.d.ts +1 -1
  62. package/dist/src/controls/util.d.ts +2 -2
  63. package/dist/src/controls/wrapWithFireEvent.d.ts +1 -1
  64. package/dist/src/controls/wrapWithFixedAnchor.d.ts +1 -1
  65. package/dist/src/env/browser.d.ts +1 -1
  66. package/dist/src/env/index.d.ts +25 -4
  67. package/dist/src/env/node.d.ts +4 -1
  68. package/dist/src/env/types.d.ts +7 -6
  69. package/dist/src/filters/BaseFilter.d.ts +24 -20
  70. package/dist/src/filters/BlendColor.d.ts +17 -17
  71. package/dist/src/filters/BlendImage.d.ts +13 -10
  72. package/dist/src/filters/Blur.d.ts +4 -2
  73. package/dist/src/filters/Boilerplate.d.ts +6 -4
  74. package/dist/src/filters/Brightness.d.ts +4 -2
  75. package/dist/src/filters/Canvas2dFilterBackend.d.ts +1 -1
  76. package/dist/src/filters/ColorMatrix.d.ts +4 -2
  77. package/dist/src/filters/ColorMatrixFilters.d.ts +128 -760
  78. package/dist/src/filters/Composed.d.ts +7 -8
  79. package/dist/src/filters/Contrast.d.ts +4 -2
  80. package/dist/src/filters/Convolute.d.ts +6 -5
  81. package/dist/src/filters/FilterBackend.d.ts +2 -1
  82. package/dist/src/filters/GLProbes/GLProbe.d.ts +7 -0
  83. package/dist/src/filters/GLProbes/NodeGLProbe.d.ts +11 -0
  84. package/dist/src/filters/GLProbes/WebGLProbe.d.ts +20 -0
  85. package/dist/src/filters/Gamma.d.ts +6 -4
  86. package/dist/src/filters/Grayscale.d.ts +7 -5
  87. package/dist/src/filters/HueRotation.d.ts +3 -2
  88. package/dist/src/filters/Invert.d.ts +4 -2
  89. package/dist/src/filters/Noise.d.ts +4 -2
  90. package/dist/src/filters/Pixelate.d.ts +4 -2
  91. package/dist/src/filters/RemoveColor.d.ts +4 -2
  92. package/dist/src/filters/Resize.d.ts +37 -18
  93. package/dist/src/filters/Saturation.d.ts +4 -2
  94. package/dist/src/filters/Vibrance.d.ts +4 -2
  95. package/dist/src/filters/WebGLFilterBackend.d.ts +10 -7
  96. package/dist/src/filters/filters.d.ts +23 -0
  97. package/dist/src/filters/index.d.ts +7 -0
  98. package/dist/src/filters/shaders/baseFilter.d.ts +4 -0
  99. package/dist/src/filters/shaders/blendColor.d.ts +13 -0
  100. package/dist/src/filters/shaders/blendImage.d.ts +3 -0
  101. package/dist/src/filters/shaders/blur.d.ts +2 -0
  102. package/dist/src/filters/shaders/brightness.d.ts +2 -0
  103. package/dist/src/filters/shaders/colorMatrix.d.ts +2 -0
  104. package/dist/src/filters/shaders/constrast.d.ts +2 -0
  105. package/dist/src/filters/shaders/convolute.d.ts +11 -0
  106. package/dist/src/filters/shaders/gamma.d.ts +2 -0
  107. package/dist/src/filters/shaders/grayscale.d.ts +3 -0
  108. package/dist/src/filters/shaders/invert.d.ts +2 -0
  109. package/dist/src/filters/shaders/noise.d.ts +2 -0
  110. package/dist/src/filters/shaders/pixelate.d.ts +2 -0
  111. package/dist/src/filters/shaders/removeColor.d.ts +2 -0
  112. package/dist/src/filters/shaders/saturation.d.ts +2 -0
  113. package/dist/src/filters/shaders/vibrance.d.ts +2 -0
  114. package/dist/src/filters/typedefs.d.ts +2 -2
  115. package/dist/src/filters/utils.d.ts +3 -0
  116. package/dist/src/gradient/Gradient.d.ts +5 -4
  117. package/dist/src/gradient/index.d.ts +3 -0
  118. package/dist/src/gradient/parser/misc.d.ts +1 -1
  119. package/dist/src/gradient/parser/parseColorStops.d.ts +2 -5
  120. package/dist/src/gradient/parser/parseCoords.d.ts +1 -1
  121. package/dist/src/gradient/typedefs.d.ts +2 -2
  122. package/dist/src/parser/applyViewboxTransform.d.ts +9 -1
  123. package/dist/src/parser/constants.d.ts +2 -15
  124. package/dist/src/parser/doesSomeParentMatch.d.ts +1 -1
  125. package/dist/src/parser/elementById.d.ts +2 -1
  126. package/dist/src/parser/elementMatchesRule.d.ts +1 -1
  127. package/dist/src/parser/elements_parser.d.ts +32 -2
  128. package/dist/src/parser/getCSSRules.d.ts +3 -2
  129. package/dist/src/parser/getGlobalStylesForElement.d.ts +2 -1
  130. package/dist/src/parser/getGradientDefs.d.ts +1 -1
  131. package/dist/src/parser/getMultipleNodes.d.ts +1 -1
  132. package/dist/src/parser/getSvgRegex.d.ts +1 -1
  133. package/dist/src/parser/hasInvalidAncestor.d.ts +2 -0
  134. package/dist/src/parser/loadSVGFromString.d.ts +11 -5
  135. package/dist/src/parser/loadSVGFromURL.d.ts +11 -5
  136. package/dist/src/parser/normalizeAttr.d.ts +2 -1
  137. package/dist/src/parser/normalizeValue.d.ts +1 -1
  138. package/dist/src/parser/parseAttributes.d.ts +2 -1
  139. package/dist/src/parser/parseFontDeclaration.d.ts +1 -1
  140. package/dist/src/parser/parsePointsAttribute.d.ts +2 -4
  141. package/dist/src/parser/parseSVGDocument.d.ts +15 -8
  142. package/dist/src/parser/parseStyleAttribute.d.ts +1 -1
  143. package/dist/src/parser/parseStyleObject.d.ts +7 -1
  144. package/dist/src/parser/parseStyleString.d.ts +7 -1
  145. package/dist/src/parser/parseTransformAttribute.d.ts +3 -2
  146. package/dist/src/parser/parseUseDirectives.d.ts +1 -1
  147. package/dist/src/parser/recursivelyParseGradientsXlink.d.ts +1 -1
  148. package/dist/src/parser/selectorMatches.d.ts +1 -1
  149. package/dist/src/parser/setStrokeFillOpacity.d.ts +1 -1
  150. package/dist/src/parser/typedefs.d.ts +10 -0
  151. package/dist/src/shapes/ActiveSelection.d.ts +27 -4
  152. package/dist/src/shapes/Circle.d.ts +28 -8
  153. package/dist/src/shapes/Ellipse.d.ts +25 -14
  154. package/dist/src/shapes/Group.d.ts +78 -51
  155. package/dist/src/shapes/IText/DraggableTextDelegate.d.ts +1 -1
  156. package/dist/src/shapes/IText/IText.d.ts +43 -29
  157. package/dist/src/shapes/IText/ITextBehavior.d.ts +10 -8
  158. package/dist/src/shapes/IText/ITextClickBehavior.d.ts +6 -14
  159. package/dist/src/shapes/IText/ITextKeyBehavior.d.ts +35 -30
  160. package/dist/src/shapes/IText/constants.d.ts +2 -2
  161. package/dist/src/shapes/Image.d.ts +54 -23
  162. package/dist/src/shapes/Line.d.ts +33 -28
  163. package/dist/src/shapes/Object/AnimatableObject.d.ts +3 -3
  164. package/dist/src/shapes/Object/FabricObject.d.ts +6 -4
  165. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts +21 -23
  166. package/dist/src/shapes/Object/InteractiveObject.d.ts +55 -41
  167. package/dist/src/shapes/Object/Object.d.ts +57 -365
  168. package/dist/src/shapes/Object/ObjectGeometry.d.ts +3 -19
  169. package/dist/src/shapes/Object/ObjectOrigin.d.ts +6 -75
  170. package/dist/src/shapes/Object/StackedObject.d.ts +14 -4
  171. package/dist/src/shapes/Object/defaultValues.d.ts +71 -72
  172. package/dist/src/shapes/Object/types/BaseProps.d.ts +84 -0
  173. package/dist/src/shapes/Object/types/BorderProps.d.ts +37 -0
  174. package/dist/src/shapes/Object/types/ControlProps.d.ts +62 -0
  175. package/dist/src/shapes/Object/types/FabricObjectProps.d.ts +96 -0
  176. package/dist/src/shapes/Object/types/FillStrokeProps.d.ts +80 -0
  177. package/dist/src/shapes/Object/types/LockInteractionProps.d.ts +51 -0
  178. package/dist/src/shapes/Object/types/ObjectProps.d.ts +42 -0
  179. package/dist/src/shapes/Object/types/SerializedObjectProps.d.ts +66 -0
  180. package/dist/src/shapes/Object/types/index.d.ts +6 -0
  181. package/dist/src/shapes/Path.d.ts +131 -39
  182. package/dist/src/shapes/Polygon.d.ts +5 -2
  183. package/dist/src/shapes/Polyline.d.ts +39 -15
  184. package/dist/src/shapes/Rect.d.ts +30 -8
  185. package/dist/src/shapes/Text/StyledText.d.ts +19 -13
  186. package/dist/src/shapes/Text/Text.d.ts +102 -59
  187. package/dist/src/shapes/Text/TextSVGExportMixin.d.ts +20 -5
  188. package/dist/src/shapes/Text/constants.d.ts +13 -0
  189. package/dist/src/shapes/Textbox.d.ts +72 -22
  190. package/dist/src/shapes/Triangle.d.ts +13 -3
  191. package/dist/src/typedefs.d.ts +31 -27
  192. package/dist/src/util/animation/AnimationBase.d.ts +1 -1
  193. package/dist/src/util/animation/AnimationFrameProvider.d.ts +0 -5
  194. package/dist/src/util/animation/ArrayAnimation.d.ts +1 -1
  195. package/dist/src/util/animation/ColorAnimation.d.ts +1 -1
  196. package/dist/src/util/animation/ValueAnimation.d.ts +1 -1
  197. package/dist/src/util/animation/animate.d.ts +2 -2
  198. package/dist/src/util/animation/easing.d.ts +1 -1
  199. package/dist/src/util/animation/index.d.ts +3 -0
  200. package/dist/src/util/animation/types.d.ts +1 -1
  201. package/dist/src/util/applyMixins.d.ts +1 -1
  202. package/dist/src/util/dom_event.d.ts +3 -2
  203. package/dist/src/util/dom_misc.d.ts +3 -31
  204. package/dist/src/util/dom_style.d.ts +1 -1
  205. package/dist/src/util/index.d.ts +37 -0
  206. package/dist/src/util/internals/cleanupSvgAttribute.d.ts +2 -0
  207. package/dist/src/util/{dom_request.d.ts → internals/dom_request.d.ts} +6 -4
  208. package/dist/src/util/internals/findRight.d.ts +2 -0
  209. package/dist/src/util/internals/index.d.ts +4 -3
  210. package/dist/src/util/misc/boundingBoxFromPoints.d.ts +4 -4
  211. package/dist/src/util/misc/dom.d.ts +1 -1
  212. package/dist/src/util/misc/findScaleTo.d.ts +7 -16
  213. package/dist/src/util/misc/groupSVGElements.d.ts +1 -1
  214. package/dist/src/util/misc/isTransparent.d.ts +3 -3
  215. package/dist/src/util/misc/matrix.d.ts +90 -14
  216. package/dist/src/util/misc/objectEnlive.d.ts +8 -21
  217. package/dist/src/util/misc/objectTransforms.d.ts +1 -1
  218. package/dist/src/util/misc/pick.d.ts +1 -0
  219. package/dist/src/util/misc/planeChange.d.ts +2 -5
  220. package/dist/src/util/misc/projectStroke/StrokeLineCapProjections.d.ts +4 -3
  221. package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.d.ts +19 -10
  222. package/dist/src/util/misc/projectStroke/StrokeProjectionsBase.d.ts +6 -4
  223. package/dist/src/util/misc/projectStroke/index.d.ts +4 -3
  224. package/dist/src/util/misc/projectStroke/types.d.ts +4 -4
  225. package/dist/src/util/misc/resolveOrigin.d.ts +1 -1
  226. package/dist/src/util/misc/svgParsing.d.ts +4 -12
  227. package/dist/src/util/misc/vectors.d.ts +28 -13
  228. package/dist/src/util/path/index.d.ts +96 -0
  229. package/dist/src/util/path/regex.d.ts +2 -0
  230. package/dist/src/util/path/typechecks.d.ts +24 -0
  231. package/dist/src/util/path/typedefs.d.ts +220 -0
  232. package/dist/src/util/transform_matrix_removal.d.ts +1 -1
  233. package/dist/src/util/{types.d.ts → typeAssertions.d.ts} +6 -4
  234. package/fabric.ts +121 -416
  235. package/index.node.ts +12 -12
  236. package/jest.config.js +195 -0
  237. package/lib/aligning_guidelines.js +2 -2
  238. package/package.json +43 -21
  239. package/playwright.config.ts +77 -0
  240. package/playwright.setup.ts +16 -0
  241. package/rollup.config.mjs +28 -7
  242. package/scripts/git.mjs +36 -0
  243. package/scripts/index.mjs +9 -124
  244. package/scripts/sandbox.mjs +149 -0
  245. package/src/{util/class_registry.ts → ClassRegistry.ts} +11 -9
  246. package/src/Collection.ts +63 -28
  247. package/src/CommonMethods.ts +3 -4
  248. package/src/EventTypeDefs.ts +102 -100
  249. package/src/Intersection.ts +54 -25
  250. package/src/Observable.ts +36 -40
  251. package/src/{Pattern.ts → Pattern/Pattern.ts} +39 -43
  252. package/src/Pattern/index.ts +2 -0
  253. package/src/Pattern/types.ts +17 -0
  254. package/src/Point.ts +43 -43
  255. package/src/Shadow.ts +28 -29
  256. package/src/brushes/BaseBrush.ts +1 -3
  257. package/src/brushes/CircleBrush.test.ts +11 -0
  258. package/src/brushes/CircleBrush.ts +6 -11
  259. package/src/brushes/PatternBrush.ts +2 -2
  260. package/src/brushes/PencilBrush.ts +10 -10
  261. package/src/brushes/SprayBrush.ts +6 -11
  262. package/src/brushes/typedefs.ts +18 -0
  263. package/src/cache.ts +2 -1
  264. package/src/canvas/Canvas.ts +173 -251
  265. package/src/canvas/CanvasOptions.ts +301 -0
  266. package/src/canvas/DOMManagers/CanvasDOMManager.ts +124 -0
  267. package/src/canvas/DOMManagers/StaticCanvasDOMManager.ts +80 -0
  268. package/src/canvas/DOMManagers/util.spec.ts +26 -0
  269. package/src/canvas/DOMManagers/util.ts +98 -0
  270. package/src/canvas/SelectableCanvas.ts +228 -575
  271. package/src/canvas/StaticCanvas.ts +119 -325
  272. package/src/canvas/StaticCanvasOptions.ts +199 -0
  273. package/src/canvas/TextEditingManager.ts +24 -2
  274. package/src/canvas/canvas_gestures.mixin.ts +10 -10
  275. package/src/color/Color.ts +51 -135
  276. package/src/color/color_map.ts +13 -13
  277. package/src/color/constants.ts +98 -17
  278. package/src/color/typedefs.ts +18 -0
  279. package/src/color/util.ts +68 -7
  280. package/src/constants.ts +11 -1
  281. package/src/controls/Control.ts +26 -18
  282. package/src/controls/changeWidth.ts +5 -4
  283. package/src/controls/{default_controls.ts → commonControls.ts} +2 -29
  284. package/src/controls/{controls.render.ts → controlRendering.ts} +5 -5
  285. package/src/controls/drag.ts +5 -4
  286. package/src/{util → controls}/fireEvent.ts +4 -1
  287. package/src/controls/index.ts +22 -0
  288. package/src/controls/polyControl.ts +4 -4
  289. package/src/controls/rotate.ts +1 -1
  290. package/src/controls/scale.ts +2 -2
  291. package/src/controls/scaleSkew.ts +2 -2
  292. package/src/controls/skew.ts +4 -3
  293. package/src/controls/util.ts +6 -5
  294. package/src/controls/wrapWithFireEvent.ts +2 -2
  295. package/src/controls/wrapWithFixedAnchor.ts +1 -1
  296. package/src/env/browser.ts +6 -2
  297. package/src/env/index.ts +27 -8
  298. package/src/env/node.ts +32 -26
  299. package/src/env/types.ts +7 -6
  300. package/src/filters/BaseFilter.ts +69 -69
  301. package/src/filters/BlendColor.ts +41 -80
  302. package/src/filters/BlendImage.ts +34 -58
  303. package/src/filters/Blur.ts +16 -37
  304. package/src/filters/Boilerplate.ts +25 -22
  305. package/src/filters/Brightness.ts +15 -23
  306. package/src/filters/Canvas2dFilterBackend.ts +1 -1
  307. package/src/filters/ColorMatrix.ts +17 -26
  308. package/src/filters/ColorMatrixFilters.ts +15 -46
  309. package/src/filters/Composed.ts +11 -18
  310. package/src/filters/Contrast.ts +13 -23
  311. package/src/filters/Convolute.ts +15 -170
  312. package/src/filters/FilterBackend.ts +10 -4
  313. package/src/filters/GLProbes/GLProbe.ts +7 -0
  314. package/src/filters/GLProbes/NodeGLProbe.ts +15 -0
  315. package/src/filters/{WebGLProbe.ts → GLProbes/WebGLProbe.ts} +9 -24
  316. package/src/filters/Gamma.ts +25 -40
  317. package/src/filters/Grayscale.ts +17 -50
  318. package/src/filters/HueRotation.ts +12 -14
  319. package/src/filters/Invert.ts +16 -32
  320. package/src/filters/Noise.ts +15 -28
  321. package/src/filters/Pixelate.ts +15 -31
  322. package/src/filters/RemoveColor.ts +16 -27
  323. package/src/filters/Resize.ts +142 -111
  324. package/src/filters/Saturation.ts +16 -27
  325. package/src/filters/Vibrance.ts +15 -28
  326. package/src/filters/WebGLFilterBackend.ts +69 -36
  327. package/src/filters/filters.ts +30 -0
  328. package/src/filters/index.ts +12 -0
  329. package/src/filters/shaders/baseFilter.ts +17 -0
  330. package/src/filters/shaders/blendColor.ts +33 -0
  331. package/src/filters/shaders/blendImage.ts +32 -0
  332. package/src/filters/shaders/blur.ts +24 -0
  333. package/src/filters/shaders/brightness.ts +11 -0
  334. package/src/filters/shaders/colorMatrix.ts +12 -0
  335. package/src/filters/shaders/constrast.ts +11 -0
  336. package/src/filters/shaders/convolute.ts +154 -0
  337. package/src/filters/shaders/gamma.ts +15 -0
  338. package/src/filters/shaders/grayscale.ts +36 -0
  339. package/src/filters/shaders/invert.ts +19 -0
  340. package/src/filters/shaders/noise.ts +16 -0
  341. package/src/filters/shaders/pixelate.ts +19 -0
  342. package/src/filters/shaders/removeColor.ts +13 -0
  343. package/src/filters/shaders/saturation.ts +15 -0
  344. package/src/filters/shaders/vibrance.ts +16 -0
  345. package/src/filters/typedefs.ts +2 -7
  346. package/src/filters/utils.ts +7 -0
  347. package/src/gradient/Gradient.ts +19 -18
  348. package/src/gradient/index.ts +2 -0
  349. package/src/gradient/parser/misc.ts +1 -1
  350. package/src/gradient/parser/parseColorStops.ts +2 -1
  351. package/src/gradient/parser/parseCoords.ts +2 -2
  352. package/src/gradient/typedefs.ts +2 -2
  353. package/src/mixins/eraser_brush.mixin.ts +2 -1
  354. package/src/parser/applyViewboxTransform.ts +57 -45
  355. package/src/parser/constants.ts +7 -26
  356. package/src/parser/doesSomeParentMatch.ts +7 -8
  357. package/src/parser/elementById.ts +8 -13
  358. package/src/parser/elementMatchesRule.ts +4 -7
  359. package/src/parser/elements_parser.ts +140 -133
  360. package/src/parser/getCSSRules.ts +43 -42
  361. package/src/parser/getGlobalStylesForElement.ts +11 -8
  362. package/src/parser/getGradientDefs.ts +11 -10
  363. package/src/parser/getMultipleNodes.ts +10 -6
  364. package/src/parser/getSvgRegex.ts +1 -3
  365. package/src/parser/hasInvalidAncestor.ts +19 -0
  366. package/src/parser/loadSVGFromString.ts +19 -16
  367. package/src/parser/loadSVGFromURL.ts +36 -30
  368. package/src/parser/normalizeAttr.ts +3 -8
  369. package/src/parser/normalizeValue.ts +29 -22
  370. package/src/parser/parseAttributes.ts +39 -37
  371. package/src/parser/parseFontDeclaration.ts +4 -2
  372. package/src/parser/parsePointsAttribute.ts +8 -11
  373. package/src/parser/parseSVGDocument.ts +68 -80
  374. package/src/parser/parseStyleAttribute.ts +2 -3
  375. package/src/parser/parseStyleObject.ts +15 -13
  376. package/src/parser/parseStyleString.ts +13 -11
  377. package/src/parser/parseTransformAttribute.ts +54 -115
  378. package/src/parser/parseUseDirectives.ts +38 -36
  379. package/src/parser/recursivelyParseGradientsXlink.ts +18 -18
  380. package/src/parser/selectorMatches.ts +11 -11
  381. package/src/parser/setStrokeFillOpacity.ts +18 -17
  382. package/src/parser/typedefs.ts +15 -0
  383. package/src/shapes/ActiveSelection.ts +55 -13
  384. package/src/shapes/Circle.ts +81 -45
  385. package/src/shapes/Ellipse.ts +60 -37
  386. package/src/shapes/Group.spec.ts +15 -0
  387. package/src/shapes/Group.ts +151 -99
  388. package/src/shapes/IText/DraggableTextDelegate.ts +28 -33
  389. package/src/shapes/IText/IText.ts +86 -54
  390. package/src/shapes/IText/ITextBehavior.test.ts +93 -0
  391. package/src/shapes/IText/ITextBehavior.ts +75 -57
  392. package/src/shapes/IText/ITextClickBehavior.ts +44 -73
  393. package/src/shapes/IText/ITextKeyBehavior.ts +120 -120
  394. package/src/shapes/IText/__snapshots__/ITextBehavior.test.ts.snap +810 -0
  395. package/src/shapes/IText/constants.ts +41 -23
  396. package/src/shapes/Image.ts +185 -114
  397. package/src/shapes/Line.ts +108 -151
  398. package/src/shapes/Object/AnimatableObject.ts +4 -7
  399. package/src/shapes/Object/FabricObject.ts +17 -7
  400. package/src/shapes/Object/FabricObjectSVGExportMixin.ts +50 -73
  401. package/src/shapes/Object/InteractiveObject.ts +105 -76
  402. package/src/shapes/Object/Object.ts +166 -473
  403. package/src/shapes/Object/ObjectGeometry.ts +12 -28
  404. package/src/shapes/Object/ObjectOrigin.ts +19 -96
  405. package/src/shapes/Object/StackedObject.ts +36 -21
  406. package/src/shapes/Object/defaultValues.ts +7 -9
  407. package/src/shapes/Object/types/BaseProps.ts +96 -0
  408. package/src/shapes/Object/types/BorderProps.ts +40 -0
  409. package/src/shapes/Object/types/ControlProps.ts +69 -0
  410. package/src/shapes/Object/types/FabricObjectProps.ts +111 -0
  411. package/src/shapes/Object/types/FillStrokeProps.ts +90 -0
  412. package/src/shapes/Object/types/LockInteractionProps.ts +57 -0
  413. package/src/shapes/Object/types/ObjectProps.ts +49 -0
  414. package/src/shapes/Object/types/SerializedObjectProps.ts +73 -0
  415. package/src/shapes/Object/types/index.ts +7 -0
  416. package/src/shapes/Path.ts +172 -126
  417. package/src/shapes/Polygon.ts +12 -9
  418. package/src/shapes/Polyline.ts +172 -94
  419. package/src/shapes/Rect.ts +57 -29
  420. package/src/shapes/Text/StyledText.ts +49 -48
  421. package/src/shapes/Text/Text.spec.ts +73 -0
  422. package/src/shapes/Text/Text.ts +281 -314
  423. package/src/shapes/Text/TextSVGExportMixin.ts +103 -26
  424. package/src/shapes/Text/__snapshots__/Text.spec.ts.snap +214 -0
  425. package/src/shapes/Text/constants.ts +111 -0
  426. package/src/shapes/Textbox.spec.ts +89 -0
  427. package/src/shapes/Textbox.ts +170 -73
  428. package/src/shapes/Triangle.ts +25 -11
  429. package/src/shapes/__snapshots__/Textbox.spec.ts.snap +164 -0
  430. package/src/typedefs.ts +41 -34
  431. package/src/util/animation/AnimationBase.ts +1 -1
  432. package/src/util/animation/AnimationFrameProvider.ts +3 -22
  433. package/src/util/animation/ArrayAnimation.ts +1 -1
  434. package/src/util/animation/ColorAnimation.ts +1 -1
  435. package/src/util/animation/ValueAnimation.ts +1 -1
  436. package/src/util/animation/animate.ts +2 -2
  437. package/src/util/animation/easing.ts +1 -1
  438. package/src/util/animation/index.ts +2 -0
  439. package/src/util/animation/types.ts +1 -1
  440. package/src/util/applyMixins.ts +1 -1
  441. package/src/util/dom_event.ts +9 -8
  442. package/src/util/dom_misc.ts +18 -109
  443. package/src/util/dom_style.ts +4 -2
  444. package/src/util/index.ts +118 -0
  445. package/src/util/internals/cleanupSvgAttribute.test.ts +16 -0
  446. package/src/util/internals/cleanupSvgAttribute.ts +8 -0
  447. package/src/util/internals/cloneDeep.test.ts +16 -0
  448. package/src/util/{dom_request.ts → internals/dom_request.ts} +13 -25
  449. package/src/util/internals/findRight.ts +11 -0
  450. package/src/util/internals/getRandomInt.test.ts +33 -0
  451. package/src/util/internals/index.ts +4 -3
  452. package/src/util/misc/boundingBoxFromPoints.ts +5 -4
  453. package/src/util/misc/dom.ts +10 -5
  454. package/src/util/misc/findScaleTo.ts +7 -22
  455. package/src/util/misc/isTransparent.ts +9 -32
  456. package/src/util/misc/matrix.ts +164 -57
  457. package/src/util/misc/objectEnlive.ts +25 -33
  458. package/src/util/misc/objectTransforms.ts +3 -2
  459. package/src/util/misc/pick.ts +12 -0
  460. package/src/util/misc/planeChange.ts +4 -13
  461. package/src/util/misc/projectStroke/StrokeLineCapProjections.ts +60 -24
  462. package/src/util/misc/projectStroke/StrokeLineJoinProjections.ts +156 -73
  463. package/src/util/misc/projectStroke/StrokeProjectionsBase.ts +7 -16
  464. package/src/util/misc/projectStroke/index.ts +35 -7
  465. package/src/util/misc/projectStroke/types.ts +4 -4
  466. package/src/util/misc/resolveOrigin.ts +1 -1
  467. package/src/util/misc/svgParsing.ts +20 -30
  468. package/src/util/misc/textStyles.ts +5 -6
  469. package/src/util/misc/vectors.ts +44 -26
  470. package/src/util/path/__snapshots__/index.spec.ts.snap +55 -0
  471. package/src/util/path/index.spec.ts +17 -0
  472. package/src/util/{path.ts → path/index.ts} +419 -321
  473. package/src/util/path/regex.ts +39 -0
  474. package/src/util/path/typechecks.ts +145 -0
  475. package/src/util/path/typedefs.ts +305 -0
  476. package/src/util/transform_matrix_removal.ts +4 -3
  477. package/src/util/{types.ts → typeAssertions.ts} +10 -3
  478. package/toMatchRoundedSnapshot.ts +66 -0
  479. package/tsconfig.json +1 -1
  480. package/dist/index.cjs.map +0 -1
  481. package/dist/src/filters/WebGLProbe.d.ts +0 -28
  482. package/dist/src/gradient/parser/index.d.ts +0 -4
  483. package/dist/src/mixins/stateful.mixin.d.ts +0 -18
  484. package/dist/src/parser/hasAncestorWithNodeName.d.ts +0 -2
  485. package/dist/src/parser/parseElements.d.ts +0 -11
  486. package/dist/src/parser/rotateMatrix.d.ts +0 -2
  487. package/dist/src/parser/scaleMatrix.d.ts +0 -2
  488. package/dist/src/parser/skewMatrix.d.ts +0 -2
  489. package/dist/src/parser/translateMatrix.d.ts +0 -2
  490. package/dist/src/util/fireEvent.d.ts +0 -3
  491. package/dist/src/util/lang_class.d.ts +0 -12
  492. package/dist/src/util/path.d.ts +0 -108
  493. package/scripts/transform_files.mjs +0 -504
  494. package/src/gradient/parser/index.ts +0 -3
  495. package/src/mixins/stateful.mixin.ts +0 -104
  496. package/src/parser/hasAncestorWithNodeName.ts +0 -14
  497. package/src/parser/parseElements.ts +0 -28
  498. package/src/parser/rotateMatrix.ts +0 -21
  499. package/src/parser/scaleMatrix.ts +0 -9
  500. package/src/parser/skewMatrix.ts +0 -6
  501. package/src/parser/translateMatrix.ts +0 -8
  502. package/src/util/lang_class.ts +0 -90
package/.eslintignore ADDED
@@ -0,0 +1,3 @@
1
+ src/mixins/eraser_brush.mixin.ts
2
+ src/util/lang_class.ts
3
+ src/parkinglot
package/.eslintrc.js CHANGED
@@ -1,10 +1,16 @@
1
1
  module.exports = {
2
2
  root: true,
3
3
  parser: '@typescript-eslint/parser',
4
+ parserOptions: {
5
+ project: true,
6
+ tsconfigRootDir: './',
7
+ },
4
8
  plugins: ['@typescript-eslint'],
5
9
  extends: [
6
10
  'eslint:recommended',
7
11
  'plugin:@typescript-eslint/recommended',
12
+ // this is too noisy for now
13
+ // 'plugin:@typescript-eslint/recommended-requiring-type-checking',
8
14
  'prettier',
9
15
  ],
10
16
  overrides: [
@@ -13,6 +19,8 @@ module.exports = {
13
19
  },
14
20
  ],
15
21
  rules: {
22
+ '@typescript-eslint/consistent-type-exports': 'error',
23
+ '@typescript-eslint/consistent-type-imports': 'error',
16
24
  '@typescript-eslint/ban-types': 1,
17
25
  '@typescript-eslint/ban-ts-comment': 1,
18
26
  'no-restricted-globals': [
package/.gitpod.yml CHANGED
@@ -1,2 +1,18 @@
1
+ # https://www.gitpod.io/docs/config-gitpod-file
2
+
1
3
  tasks:
2
- - init: npm install
4
+ - name: Build & Watch
5
+ init: npm install
6
+ command: npm run build -- -w -f
7
+
8
+ - name: Node
9
+ init: npm install
10
+ command: npm start node -- --no-watch
11
+
12
+ - name: Next.js
13
+ init: npm install
14
+ command: npm start next -- --no-watch
15
+
16
+ - name: Vanilla
17
+ init: npm install
18
+ command: npm start vanilla -- --no-watch
package/.prettierignore CHANGED
@@ -14,3 +14,6 @@ before_commit
14
14
  /dist/
15
15
  /lib/
16
16
  /test/
17
+ .next/
18
+ .parcel-cache/
19
+ /docs/
package/CHANGELOG.md CHANGED
@@ -2,6 +2,164 @@
2
2
 
3
3
  ## [next]
4
4
 
5
+ ## [6.0.0-beta11]
6
+
7
+ - patch(): Avoid unwanted mutation to passed objects array to Group constructor [#9151](https://github.com/fabricjs/fabric.js/pull/9151)
8
+ - patch(): ActiveSelection initialization + types [#9143](https://github.com/fabricjs/fabric.js/pull/9143)
9
+ - chore(TS): BREAKING remove canvas.interactive, added typings for canvas options [#9140](https://github.com/fabricjs/fabric.js/pull/9140)
10
+ - chore(TS): BREAKING PREVIOUS BETA mv + rename `TProps` => `TOptions` [#9139](https://github.com/fabricjs/fabric.js/pull/9139)
11
+ - test(playwright): Use embedded eval from playwright [#9133](https://github.com/fabricjs/fabric.js/pull/9133)
12
+ - chore(TS): Fix event types and .once this binding [#9119](https://github.com/fabricjs/fabric.js/pull/9130)
13
+ - docs(): rm `canvas2pdf` [#9135](https://github.com/fabricjs/fabric.js/pull/9135)
14
+ - chore(TS): export types [#9129](https://github.com/fabricjs/fabric.js/pull/9129)
15
+ - ci(e2e): support relative imports [#9108](https://github.com/fabricjs/fabric.js/pull/9108)
16
+ - chore(TS): complete type check [#9119](https://github.com/fabricjs/fabric.js/pull/9119)
17
+ - chore(TS): Add type-checking to files excluded with ts-nocheck [#9097](https://github.com/fabricjs/fabric.js/pull/9097)
18
+ - chore(TS): Add type-checking to files excluded with ts-nocheck ( Parser mostly ) [#9085](https://github.com/fabricjs/fabric.js/pull/9085)
19
+ - docs(): revise test section [#9114](https://github.com/fabricjs/fabric.js/pull/9114)
20
+ - fix(): #8344 stroke projection [#8374](https://github.com/fabricjs/fabric.js/pull/8374)
21
+ - fix(Filters) Removing type from the options passed in the constructor [#9089](https://github.com/fabricjs/fabric.js/pull/9089)
22
+ - feat(InteractiveObject): add `getActiveControl()` to expose `__corner` [#9102](https://github.com/fabricjs/fabric.js/pull/9102)
23
+ - ci(sandbox): bump next.js [#9100](https://github.com/fabricjs/fabric.js/pull/9100)
24
+ - test(playwright): add snapshots, refactor utils, coverage [#9078](https://github.com/fabricjs/fabric.js/pull/9078)
25
+ - test(Text): Add some tests for text in Jest [#9083](https://github.com/fabricjs/fabric.js/pull/9083)
26
+ - ci(): Install system deps only when necessary [#9086](https://github.com/fabricjs/fabric.js/pull/9086)
27
+ - fix(util, Path): path distance measurement fix for M cmd [#9076](https://github.com/fabricjs/fabric.js/pull/9076)
28
+ - chore(TS): Image class type checks, BREAKING change to FromURL static method [#9036](https://github.com/fabricjs/fabric.js/pull/9036)
29
+ - ci(): properly checkout head for stats [#9080](https://github.com/fabricjs/fabric.js/pull/9080)
30
+ - fix(Text): `_getFontDeclaration` wasn't considering fontFamily from the style object [#9082](https://github.com/fabricjs/fabric.js/pull/9082)
31
+ - chore(TS): Fix ITextBehaviour enterEditing type [#9075](https://github.com/fabricjs/fabric.js/pull/9075)
32
+ - chore(TS): export FabricObjectProps and GroupProps [#9025](https://github.com/fabricjs/fabric.js/pull/9025)
33
+ - chore(TS): Replace BaseFabricObject with FabricObject [#9016](https://github.com/fabricjs/fabric.js/pull/9016)
34
+ - refactor(svgImport): remove the css/gradient/clipPath global definitions [#9030](https://github.com/fabricjs/fabric.js/pull/9030)
35
+ - fix(): tweaks to type getter [#9022](https://github.com/fabricjs/fabric.js/pull/9022)
36
+ - ci() Refactor GHA actions for caching and reuse [#9029](https://github.com/fabricjs/fabric.js/pull/9029)
37
+ - ci(): install dev deps types [#9039](https://github.com/fabricjs/fabric.js/pull/9039)
38
+
39
+ ## [6.0.0-beta10]
40
+
41
+ - chore(TS): Remove @ts-nocheck from Text class. [#9018](https://github.com/fabricjs/fabric.js/pull/9018)
42
+ - Fix(Textbox) minimum word width calculation across all lines [#9004](https://github.com/fabricjs/fabric.js/pull/9004)
43
+ - ci(): add Jest for the unit tests [#8919](https://github.com/fabricjs/fabric.js/pull/8919)
44
+ - ci(): Revert "invoke tests after changelog action (#8974)" [#9013](https://github.com/fabricjs/fabric.js/pull/9013)
45
+ - fix(IText): empty line selection [#9019](https://github.com/fabricjs/fabric.js/pull/9019)
46
+ - ci(): Added playwright testing [#8616](https://github.com/fabricjs/fabric.js/pull/8616)
47
+ - fix(IText): `exitEditing` should clear contextTop [#9020](https://github.com/fabricjs/fabric.js/pull/9020)
48
+ - ci(): prettier after changelog action [#9021](https://github.com/fabricjs/fabric.js/pull/9021)
49
+
50
+ ## [6.0.0-beta9]
51
+
52
+ - fix(fabric): Fix the serialization and registry dependency from minification [#9009](https://github.com/fabricjs/fabric.js/pull/9009)
53
+ - chore(TS): remove troublesome `AssertKeys` TS construct [#9012](https://github.com/fabricjs/fabric.js/pull/9012)
54
+ - fix(lib): fix aligning_guideline zoom [#8998](https://github.com/fabricjs/fabric.js/pull/8998)
55
+ - fix(IText): support control interaction in text editing mode [#8995](https://github.com/fabricjs/fabric.js/pull/8995)
56
+ - fix(Textbox): `splitByGrapheme` measurements infix length bug [#8990](https://github.com/fabricjs/fabric.js/pull/8990)
57
+ - patch(Text): styles es6 minor patch [#8988](https://github.com/fabricjs/fabric.js/pull/8988)
58
+
59
+ ## [6.0.0-beta8]
60
+
61
+ - BREAKING fix(IText): detect cursor from proper offsets, remove getLocalPointer from IText class [#8972](https://github.com/fabricjs/fabric.js/pull/8972)
62
+ - fix(Text): styles line break [#8973](https://github.com/fabricjs/fabric.js/pull/8973)
63
+ - fix(): regression to itext focusing from #8939 [#8970](https://github.com/fabricjs/fabric.js/pull/8970)
64
+ - ci(): warn build errors in dev mode [#8971](https://github.com/fabricjs/fabric.js/pull/8971)
65
+ - ci(): invoke tests after changelog action [#8974](https://github.com/fabricjs/fabric.js/pull/8974)
66
+ - chore(TS): Export more types [#8965](https://github.com/fabricjs/fabric.js/pull/8965)
67
+ - BREAKING: fabric.util.makeElementSelectable / fabric.util.makeElementUnselectable are removed [#8930](https://github.com/fabricjs/fabric.js/pull/8930)
68
+ - refactor(): Canvas DOM delegation to utility class [#8930](https://github.com/fabricjs/fabric.js/pull/8930)
69
+
70
+ ## [6.0.0-beta7]
71
+
72
+ - feat(): Export setFilterBackend and port the texture filtering option from fabric 5, exports some extra types [#8954](https://github.com/fabricjs/fabric.js/pull/8954)
73
+ - chore(): swap commonly used string with constants [#8933](https://github.com/fabricjs/fabric.js/pull/8933)
74
+ - chore(TS): Add more text types [#8941](https://github.com/fabricjs/fabric.js/pull/8941)
75
+ - ci(): fix changelog action race condition [#8949](https://github.com/fabricjs/fabric.js/pull/8949)
76
+ - ci(): automate PR changelog [#8938](https://github.com/fabricjs/fabric.js/pull/8938)
77
+ - chore(): move canvas click handler to TextManager [#8939](https://github.com/fabricjs/fabric.js/pull/8939)
78
+ - refactor(): write less bulky code [#8943](https://github.com/fabricjs/fabric.js/pull/8943)
79
+
80
+ ## [6.0.0-beta6]
81
+
82
+ - patch(): expose `Control#shouldActivate` [#8934](https://github.com/fabricjs/fabric.js/pull/8934)
83
+ - feat(Color) Improve regex for new standards, more documentation and code cleanup [#8916](https://github.com/fabricjs/fabric.js/pull/8916)
84
+ - fix(TS): extending canvas and object event types (`type` => `interface`) [#8926](https://github.com/fabricjs/fabric.js/pull/8926)
85
+ - chore(build) simple deps update [#8929](https://github.com/fabricjs/fabric.js/pull/8929)
86
+ - fix(Canvas): sync cleanup of dom elements in dispose [#8903](https://github.com/fabricjs/fabric.js/pull/8903)
87
+ - chore(TS): export util types [#8915](https://github.com/fabricjs/fabric.js/pull/8915)
88
+ - chore(TS): change enums with types [#8918](https://github.com/fabricjs/fabric.js/pull/8918)
89
+ - chore(TS): export gradient types
90
+ - chore(lint) export filter colors and brushes types [#8913](https://github.com/fabricjs/fabric.js/pull/8913)
91
+ - chore(lint) Add a rule for import type [#8907](https://github.com/fabricjs/fabric.js/pull/8907)
92
+ - fix(Object): dirty unflagging inconsistency [#8910](https://github.com/fabricjs/fabric.js/pull/8910)
93
+ - chore(TS): minor type/import fixes [#8904](https://github.com/fabricjs/fabric.js/pull/8904)
94
+ - chore(): Matrix util cleanup [#8894](https://github.com/fabricjs/fabric.js/pull/8894)
95
+ - chore(TS): pattern cleanup + export types [#8875](https://github.com/fabricjs/fabric.js/pull/8875)
96
+ - fix(): Disable offscreen check for bg and overlay when not needed [#8898](https://github.com/fabricjs/fabric.js/pull/8898)
97
+ - chore(): cleanup #8888 [#8892](https://github.com/fabricjs/fabric.js/pull/8892)
98
+ - feat(env): relative window/document, support iframe [#8897](https://github.com/fabricjs/fabric.js/pull/8897)
99
+ - docs(): add repo repro link to `bug_report.yml` [#8900](https://github.com/fabricjs/fabric.js/pull/8900)
100
+ - refactor(fabric.Line): Line position is calculated from the center between the 2 points now [#8877](https://github.com/fabricjs/fabric.js/pull/8877)
101
+ - chore(Path, Polyline): Clean up old SVG import code [#8857](https://github.com/fabricjs/fabric.js/pull/8857)
102
+
103
+ ## [6.0.0-beta5]
104
+
105
+ - refactor(): SVG loading and parsing functionality are now promises or async. Callback have been removed [#8884](https://github.com/fabricjs/fabric.js/pull/8884)
106
+ - refactor(fabric.Line): Line position is calculated from the center between the 2 points now [#8877](https://github.com/fabricjs/fabric.js/pull/8877)
107
+ - bundle(): export `setEnv` for test interoperability [#8888](https://github.com/fabricjs/fabric.js/pull/8888)
108
+
109
+ ## [6.0.0-beta4]
110
+
111
+ - chore(): Code cleanup and reuse of code in svg-parsing code [#8881](https://github.com/fabricjs/fabric.js/pull/8881)
112
+ - chore(TS): Parse transform attribute typing [#8878](https://github.com/fabricjs/fabric.js/pull/8878)
113
+ - chore(TS): Fix typing for DOMParser [#8871](https://github.com/fabricjs/fabric.js/pull/8871)
114
+ - fix(Path, Polyline): fix for SVG import [#8879](https://github.com/fabricjs/fabric.js/pull/8879)
115
+ - chore(TS) add types for loadSVGFromURl, parseSVGDocument, loadSVGFromString [#8869](https://github.com/fabricjs/fabric.js/pull/8869)
116
+ - chore(TS): finalize Path migration [#8438](https://github.com/fabricjs/fabric.js/pull/8438)
117
+ - fix(Path, Obect) Fix path parsing edge case for zeroed arc command and for too small canvas patterns [#8853](https://github.com/fabricjs/fabric.js/pull/8853)
118
+
119
+ ## [6.0.0-beta3]
120
+
121
+ - chore(TS): Path type fixes [#8842](https://github.com/fabricjs/fabric.js/pull/8842)
122
+ - fix(TS): add types to some untyped empty arrays [#8830](https://github.com/fabricjs/fabric.js/pull/8830)
123
+ - chore(TS): Complete typings for toObject/fromObject [#8756](https://github.com/fabricjs/fabric.js/pull/8756)
124
+ - fix(): text styles edge case [#8820](https://github.com/fabricjs/fabric.js/pull/8820)
125
+ - chore(TS): Group types [#8807](https://github.com/fabricjs/fabric.js/pull/8807)
126
+ - chore(TS): Path util typings and refactoring [#8787](https://github.com/fabricjs/fabric.js/pull/8787)
127
+ - rename(): `IPoint` => `XY` [#8806](https://github.com/fabricjs/fabric.js/pull/8806)
128
+ - ci(): use sandbox apps in issue template, use the current branch when deploying an app, minors [#8803](https://github.com/fabricjs/fabric.js/pull/8803)
129
+ - perf(): optimize `perPixelTargetFind` [#8770](https://github.com/fabricjs/fabric.js/pull/8770)
130
+ - BREAKING fix(): reflect NUM_FRACTION_DIGITS to SVG path data [#8782] (https://github.com/fabricjs/fabric.js/pull/8782)
131
+ - fix(IText): layout change regression caused by #8663 (`text` was changed but layout was skipped) [#8711](https://github.com/fabricjs/fabric.js/pull/8711)
132
+ - fix(IText, Textbox): fix broken text input [#8775](https://github.com/fabricjs/fabric.js/pull/8775)
133
+ - ci(): `.codesandbox` [#8135](https://github.com/fabricjs/fabric.js/pull/8135)
134
+ - ci(): disallow circular deps [#8759](https://github.com/fabricjs/fabric.js/pull/8759)
135
+ - fix(): env WebGL import cycle [#8758](https://github.com/fabricjs/fabric.js/pull/8758)
136
+ - chore(TS): remove controls from prototype. BREAKING: controls aren't shared anymore [#8753](https://github.com/fabricjs/fabric.js/pull/8753)
137
+ - chore(TS): remove object `type` from prototype [#8714](https://github.com/fabricjs/fabric.js/pull/8714)
138
+ - chore(TS): type Object props [#8677](https://github.com/fabricjs/fabric.js/issues/8677)
139
+ - chore(TS): remove default values from filter prototypes [#8742](https://github.com/fabricjs/fabric.js/issues/8742)
140
+ - chore(TS): remove default values from Objects prototypes, ( filters in a followup ) [#8719](https://github.com/fabricjs/fabric.js/issues/8719)
141
+ - fix(Intersection): bug causing selection edge case [#8735](https://github.com/fabricjs/fabric.js/pull/8735)
142
+ - chore(TS): class interface for options/brevity [#8674](https://github.com/fabricjs/fabric.js/issues/8674)
143
+ - ci(): fix import autocomplete in dev mode #8725
144
+ - chore(): remove deprecated class util [#8731](https://github.com/fabricjs/fabric.js/pull/8731)
145
+ - lint(): fix eslint errors [#8729](https://github.com/fabricjs/fabric.js/pull/8729)
146
+ - fix(TS): `this.constructor` types [#8675](https://github.com/fabricjs/fabric.js/issues/8675)
147
+ - fix(DraggableText): drag image blur [#8712](https://github.com/fabricjs/fabric.js/pull/8712)
148
+ - ci(): Fix tests for firefox 110 update [#8710](https://github.com/fabricjs/fabric.js/pull/8710)
149
+ - chore(): index files for exports and tree shaking [#8661](https://github.com/fabricjs/fabric.js/pull/8661)
150
+ - ci(test): cleanup node config (#8694 followup) [#8707](https://github.com/fabricjs/fabric.js/issues/8707)
151
+ - fix(): BREAKING set/discard active object return value, discard active object now return false if no discard happened [#8672](https://github.com/fabricjs/fabric.js/issues/8672)
152
+ - fix(): selection logic to support nested multiselection [#8665](https://github.com/fabricjs/fabric.js/issues/8665)
153
+ - fix(test): remove bad node config [#8694](https://github.com/fabricjs/fabric.js/issues/8694)
154
+ - fix(): keep browser files as .js [#8690](https://github.com/fabricjs/fabric.js/issues/8690)
155
+ - fix(): object dispose removes canvas/event refs [#8673](https://github.com/fabricjs/fabric.js/issues/8673)
156
+ - fix(test): Textbox `fromObject` test is incorrectly trying to restore an instance [#8686](https://github.com/fabricjs/fabric.js/pull/8686)
157
+ - TS(): Moved cache properties to static properties on classes [#xxxx](https://github.com/fabricjs/fabric.js/pull/xxxx)
158
+ - refactor(): Moved cache properties to static properties on classes [#8662](https://github.com/fabricjs/fabric.js/pull/8662)
159
+ - docs(): v6 announcements [#8664](https://github.com/fabricjs/fabric.js/issues/8664)
160
+ - ci(): remove TS transformer [#8660](https://github.com/fabricjs/fabric.js/pull/8660)
161
+ - refactor(): BREAKING remove stateful mixin and functionality [#8663](https://github.com/fabricjs/fabric.js/pull/8663)
162
+ - patch(): Added WebGLProbe to env, removed isLikelyNode, added specific env dispose ( instead of cleanup JSDOM ) [#8652](https://github.com/fabricjs/fabric.js/pull/8652)
5
163
  - ci(): Removed the browser publish script [#8656](https://github.com/fabricjs/fabric.js/pull/8656)
6
164
  - feat(): Node entry point [#8632](https://github.com/fabricjs/fabric.js/pull/8632)
7
165
  - chore(): Change import and export strategy [#8622](https://github.com/fabricjs/fabric.js/pull/8622)
package/CONTRIBUTING.md CHANGED
@@ -62,12 +62,14 @@ Answering questions and addressing issues, as well as fixing and adding types (s
62
62
  - [Issues][issues]
63
63
  - [Discussions][discussions]
64
64
 
65
- ### 🎮 Adding a DEMO
65
+ ### 🎮 Adding a DEMO (currently not possible)
66
+
67
+ **New website is under construction. Contributions are welcome.**
66
68
 
67
69
  Take a look at an existing [demo file][demo_file].\
68
70
  Create a new file in the same directory (`posts/demos/_posts`) and follow [**developing the website**](#fabricjscom-deprecated).
69
71
 
70
- ### ~~`fabricjs.com`~~ (_deprecated_)
72
+ ### ~~`fabricjs.com`~~ (currently not possible)
71
73
 
72
74
  To develop fabric's site you need to clone [`fabricjs.com`][website_repo] in the same parent folder of [`fabric.js`][repo], so that `fabric.js` and `fabricjs.com` are siblings.
73
75
 
@@ -91,25 +93,29 @@ Fabric is an open source project 🦄 and as such depends on the **genuine effor
91
93
 
92
94
  - Read this section through.
93
95
  - Take a look at [**GOTCHAS**][gotchas]
94
- - Follow [Developing](#-developing-) and read [Testing](#-testing).
96
+ - Follow [Developing](#-developing-) and [Testing](#-testing).
95
97
 
96
98
  ### ✅ Guidelines
97
99
 
100
+ - **Be patient** \
101
+ Sometimes it takes time to get back to you. Someone eventually will. Having a small, concise and super clear change will make maintainers more prone to handle it quickly.
98
102
  - **Code Style** \
99
103
  Fabric uses [`prettier`][prettier] to format files and [`eslint`][eslint] for linting (`npm run lint -- --fix`).\
100
104
  To enjoy a seamless dev experience add the [`Prettier - Code formatter`][prettier_extension] extension via the extensions toolbar in VSCode.
101
- - **⛔ `dist`** \
102
- Commit changes to [source files](src). Don't commit the generated [distribution files](dist).
105
+ If that doesn't work, once the PR is ready run `npm run prettier:write` and commit the changes.
106
+ Do not reorder imports. Irrelevant changes in a PR that are not created by prettier aren't needed nor welcome.
103
107
  - **Tests** \
104
- PRs must be backed with relevant tests, follow [TESTING](#-testing).
108
+ PRs must be backed with relevant tests, follow [TESTING](#-testing). If you never wrote a test or you find our tests unclear to extend, just ask for help.
109
+ Aim to cover 100% of the changes.
105
110
  - **Docs** \
106
111
  Add relevant comments to your code if necessary using [JSDoc 3][jsdoc] and update relevant guides.\
107
112
  The generated documentation can be found at [fabricjs.com][docs], see [DOCS](#-improving-docs).
108
113
  - **Changelog**\
109
- Add a concise listing to the [**CHANGELOG**](CHANGELOG.md) describing what has changed.
114
+ Add a concise listing to the [**CHANGELOG**](CHANGELOG.md) describing what has changed or let github actions add the PR title for you.
110
115
  - **1️⃣ PR per feature/bug** \
111
116
  Create a new branch for every pull request.\
112
117
  If you want to do more than one thing, create multiple pull requests 💪.
118
+ If your bug fix or feature requires a refactor, don't refactor. Commit the bugfix or the feature with the current code structure, let it sink, give some time to surface issues with the change, then when the bug or the feature seem solid, a refactor or code improvement can be tried
113
119
  - **And there you go!** \
114
120
  If you still have questions we're always happy to help.
115
121
 
@@ -122,108 +128,110 @@ It is more than likely you will be requested to change stuff and refine your wor
122
128
  [![🧪](../../actions/workflows/tests.yml/badge.svg)](../../actions/workflows/tests.yml)
123
129
  [![CodeQL](../../actions/workflows/codeql-analysis.yml/badge.svg)](../../actions/workflows/codeql-analysis.yml)
124
130
 
125
- Test suites use [`QUnit`][qunit] for assertions and [`testem`][testem] for serving
126
-
127
- - `unit` tests: test logic and state
128
- - `visual` tests: test visual outcome against image refs located at `/test/visual/golden`
129
-
130
- ### Getting Started
131
-
132
- - build and watch for changes:
133
-
134
- ```bash
135
-
136
- npm run build -- -f -w
137
-
138
- ```
139
-
140
- - run tests:
141
-
142
- ```bash
143
-
144
- npm test -- -a -d
145
- > Running all tests in debug mode (read more in the help section)
146
-
147
- npm test -- -s visual --dev -l -c chrome
148
- > Running live visual tests on chrome (navigate to see)
131
+ | Suite | unit (node) | e2e (browser) |
132
+ | ---------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
133
+ | Framework | [`jest`][jest] | [`playwright`][playwright] |
134
+ | Setup | | <pre>npm run build -- -f -w</pre> |
135
+ | Running Tests<br><br><br><br><br><pre>\<test cmd\> -- [filter] [watch]</pre> | <pre>npm run test:jest -- [filters] [-w]</pre><br><br><br>It is advised to use filters to save time.<br> | <pre>npm run test:e2e -- [filters] [--ui]</pre><br>In some machines babel is flaky and doesn't build the test files. In that is the case, try running the command using `npx` directly, see [`playwright.setup.ts`](./playwright.setup.ts). |
136
+ | Writing Tests | Add/update `src/*.(spec\|test).ts` files | - Update tests in `e2e/tests`<br>- Create a new test based on `e2e/template` |
137
+ | Test Gen | | <pre>npm start vanilla<br>npx playwright codegen http://localhost:1234</pre> |
138
+ | Test Spec | | - `index.ts`: built and loaded into the web app<br> - `index.spec.ts`: test spec<br> |
139
+ | Outputs | Snapshots next to the test file | - Snapshots next to the test file <br>- `e2e/test-report`<br>- `e2e/test-results` |
149
140
 
150
- npm test -- --help
141
+ ### Legacy Test Suite
151
142
 
152
- > Usage: fabric.js test [options]
143
+ We **discourage** writing new tests in the legacy suite and **encourage** migrating failing tests to the new suite.
144
+ However, it is not carved in stone.
153
145
 
154
- > run test suite
146
+ The test suites use [`QUnit`][qunit] for assertions and [`testem`][testem] for serving the browser tests.
155
147
 
156
- Options:
157
- -s, --suite <suite...> test suite to run (choices: "unit", "visual")
158
- -f, --file <file> run a specific test file
159
- --filter <filter> filter tests by name
160
- -a, --all run all tests (default: false)
161
- -d, --debug debug visual tests by overriding refs (golden images) in case of visual changes (default:
162
- false)
163
- -r, --recreate recreate visual refs (golden images) (default: false)
164
- -v, --verbose log passing tests (default: false)
165
- -l, --launch launch tests in the browser (default: false)
166
- --dev runs testem in `dev` mode, without a `ci` flag (default: false)
167
- -c, --context <context...> context to test in (choices: "chrome", "firefox", "node", default: "node")
168
- -p, --port
169
- -o, --out <out> path to report test results to
170
- --clear-cache clear CLI test cache (default: false)
171
- -h, --help display help for command
172
-
173
- ```
148
+ - `unit` tests: test logic and state
149
+ - `visual` tests: test visual outcome against image refs located at `test/visual/golden`
150
+
151
+ #### Getting Started
152
+
153
+ - Build and watch for changes
154
+ ```bash
155
+ npm run build -- -f -w
156
+ ```
157
+ - Run the _legacy_ test suite on `chrome` (many tests are skipped on `node`)
158
+ ```bash
159
+ npm test -- -a -c chrome
160
+ ```
161
+ - Handle failing tests
162
+ - Fix logic
163
+ - If needed, alter tests with **caution**
164
+ - Rerun failing tests
165
+ - Save time by rerunning failing tests only
166
+ - Select failing test files
167
+ ```bash
168
+ npm test -- -c chrome
169
+ ```
170
+ - **OR** launch the browser test suite in _dev mode_ to watch for test changes
171
+ ```bash
172
+ npm test -- -c chrome --dev -l
173
+ ```
174
+ - In case of failing visual tests, there are 2 options to view visual diffs (in order to understand what is wrong)
175
+ - Testing in _visual debug mode_ is comfortable when using with `Github Desktop` to view the diffs since refs will be overwritten (rerunning tests will use the overwritten refs so be cautious)
176
+ ```bash
177
+ npm test -- -d -c chrome
178
+ ```
179
+ - Launching the browser test suite
180
+ ```bash
181
+ npm test -- -c chrome --dev -l
182
+ ```
183
+ - Take into account that different environments produce different outputs so it is advised to run both in `chrome` and `node`.
184
+ - Committing refs is done **ONLY** with `chrome` output.
185
+ - When you are done, rerun the entire test suit to verify all tests pass.
186
+ - If you are submitting a PR, visit the PR page on github to see all checks have passed (different platforms and config are covered by the checks).
187
+ - Refer to the command docs
188
+ ```bash
189
+ npm test -- -h
190
+ ```
191
+
192
+ #### Adding Tests
193
+
194
+ Add tests to relevant files or add new files when necessary under `test/unit` or `test/visual`.
195
+
196
+ - [`unit` test example][unit_test]
197
+ - [`visual` test example][visual_test]
198
+
199
+ If you need to change test config ask for guidance.
174
200
 
175
201
  ---
176
202
 
177
203
  ## 🚧🎢 Developing 💡✨
178
204
 
179
- ### Setting Up Locally
205
+ ### Getting Started
180
206
 
181
- 1. 🍴 Fork the repository
182
- 1. 💾 Clone your 🍴 to your 💻
207
+ 1. 🍴 Fork and clone 💾 the repository
183
208
  1. Install dependencies 🕹️ `npm i --include=dev`
184
- 1. Next Up [Prototyping](#-prototyping) & [Testing](#-testing)
185
-
186
- #### Online
187
-
188
- [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/from-referrer/)
189
-
190
- Gitpod will start the [prototyping](#-prototyping) apps and expose them as endpoints.
191
- `A service is available on port ...` popups will show up.
192
-
193
- ### 🧭 Prototyping
194
209
 
195
- [`.codesandbox/templates`](.codesandbox/templates) contains templates for **INSTANT** out-of-the-box prototyping **👍 Try it out**
210
+ ### Starting an App
196
211
 
197
212
  ```bash
213
+ npm start <template>
214
+ npm start -- --help
215
+ ```
198
216
 
199
- npm run sandbox build next [/path/to/sandbox]
200
- > building next app at /path/to/sandbox
201
-
202
- npm run sandbox start </path/to/sandbox>
203
- > starting dev server
204
-
205
- npm run sandbox deploy </path/to/sandbox>
206
- > created codesandbox https://codesandbox.io/s/fgh476
207
-
208
- npm run sandbox deploy -- --template node
209
- > created codesandbox https://codesandbox.io/s/fgh476
217
+ You can deploy an app to codesandbox via the cli or build an app at a path of your choosing:
210
218
 
219
+ ```bash
220
+ npm run sandbox deploy <path/to/app>
221
+ npm run sandbox build <template> <path/to/app>
211
222
  npm run sandbox -- --help
223
+ ```
212
224
 
213
- > Usage: fabric.js sandbox [options] [command]
214
-
215
- > sandbox commands
225
+ Refer to [`.codesandbox/README.md`](.codesandbox/README.md) for more information.
216
226
 
217
- Options:
218
- -h, --help display help for command
227
+ ### Online
219
228
 
220
- Commands:
221
- deploy [options] [path] deploy a sandbox to codesandbox
222
- build <template> [destination] build and start a sandbox
223
- start <path> start a sandbox
224
- help [command] display help for command
229
+ You can actively develop fabric online using [Github Codespaces][github_codespaces], [Gitpod][gitpod] or CodeSandbox:
225
230
 
226
- ```
231
+ - After the Github Codespace has started run `npm start <template>` to start a prototyping app.
232
+ - Gitpod will start the prototyping apps and expose them as endpoints available on forwarded ports.
233
+ `A service is available on port ...` popups will show up.
234
+ - Codesandbox: _available soon_.
227
235
 
228
236
  ### 🔮 Symlinking
229
237
 
@@ -231,6 +239,7 @@ Establish symlinking to work with a local version on separate projects.
231
239
 
232
240
  1. From `fabric.js` folder run `npm link` **OR** `yarn link`.
233
241
  1. From the project's folder run `npm link fabric` **OR** `yarn link fabric`.
242
+ 1. Consider flagging `--save` to avoid confusion regarding what version of fabric is being used by the project.
234
243
 
235
244
  See [npm link][npm_link] **OR** [yarn link][yarn_link].\
236
245
  Don't forget to unlink the package once you're done.
@@ -254,7 +263,13 @@ Don't forget to unlink the package once you're done.
254
263
  [prettier_extension]: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
255
264
  [eslint]: https://eslint.org/
256
265
  [jsdoc]: https://jsdoc.app/
266
+ [playwright]: https://playwright.dev/
267
+ [jest]: https://jestjs.io/
257
268
  [qunit]: https://qunitjs.com/
258
269
  [testem]: https://github.com/testem/testem
270
+ [unit_test]: https://github.com/fabricjs/fabric.js/blob/93dd2dcca705a4b481fbc9982da4952ef5b4ed1d/test/unit/point.js#L227-L237
271
+ [visual_test]: https://github.com/fabricjs/fabric.js/blob/93dd2dcca705a4b481fbc9982da4952ef5b4ed1d/test/visual/generic_rendering.js#L44-L67
272
+ [github_codespaces]: https://github.com/codespaces/new?hide_repo_select=true&ref=master&repo=712530
273
+ [gitpod]: https://gitpod.io/from-referrer/
259
274
  [npm_link]: https://docs.npmjs.com/cli/v8/commands/npm-link
260
275
  [yarn_link]: https://yarnpkg.com/cli/link
package/README.md CHANGED
@@ -42,7 +42,7 @@ A **simple and powerful Javascript HTML5 canvas library**.
42
42
  - Out of the box interactions such as scale, move, rotate, skew, group...
43
43
  - Built in shapes, controls, animations, image filters, gradients, patterns, brushes...
44
44
  - `JPG`, `PNG`, `JSON` and `SVG` i/o
45
- - Typed and modular
45
+ - [Typed and modular](#migrating-to-v6)
46
46
  - [Unit tested](CONTRIBUTING.md#%F0%9F%A7%AA%20testing)
47
47
 
48
48
  #### Supported Browsers/Environments
@@ -60,20 +60,23 @@ A **simple and powerful Javascript HTML5 canvas library**.
60
60
 
61
61
  Fabric.js Does not use transpilation by default, the browser version we support is determined by the level of canvas api we want to use and some js syntax. While JS can be easily transpiled, canvas API can't.
62
62
 
63
- ## Installation
63
+ ## Migrating to v6
64
+
65
+ v6 is a **MAJOR** effort including migrating to TS and es6, countless fixes, rewrites and features.\
66
+ Currently in beta, refer to [#8299](../../issues/8299) for guidance.
64
67
 
65
68
  ```bash
66
- $ npm install fabric --save
69
+ $ npm install fabric@beta --save
67
70
  // or
68
- $ yarn add fabric
71
+ $ yarn add fabric@beta
69
72
  ```
70
73
 
71
- ```js
72
- // es6 imports
73
- import { fabric } from 'fabric';
74
+ ## Installation
74
75
 
75
- // or cjs
76
- const fabric = require('fabric').fabric;
76
+ ```bash
77
+ $ npm install fabric --save
78
+ // or
79
+ $ yarn add fabric
77
80
  ```
78
81
 
79
82
  #### Browser
@@ -92,6 +95,15 @@ Follow these [instructions][node_canvas_install] to get `node-canvas` up and run
92
95
 
93
96
  ## Quick Start
94
97
 
98
+ ```js
99
+ // v6
100
+ import { Canvas, Rect } from 'fabric'; // browser
101
+ import { StaticCanvas, Rect } from 'fabric/node'; // node
102
+
103
+ // v5
104
+ import { fabric } from 'fabric';
105
+ ```
106
+
95
107
  <details><summary><b>Plain HTML</b></summary>
96
108
 
97
109
  ```html
@@ -117,10 +129,11 @@ Follow these [instructions][node_canvas_install] to get `node-canvas` up and run
117
129
 
118
130
  ```tsx
119
131
  import React, { useEffect, useRef } from 'react';
120
- import { fabric } from 'fabric';
132
+ import * as fabric from 'fabric'; // v6
133
+ import { fabric } from 'fabric'; // v5
121
134
 
122
135
  export const FabricJSCanvas = () => {
123
- const canvasEl = useRef(null);
136
+ const canvasEl = useRef<HTMLCanvasElement>(null);
124
137
  useEffect(() => {
125
138
  const options = { ... };
126
139
  const canvas = new fabric.Canvas(canvasEl.current, options);
@@ -132,8 +145,8 @@ export const FabricJSCanvas = () => {
132
145
  }
133
146
  }, []);
134
147
 
135
- return (<canvas width="300" height="300" ref={canvasEl}/>)
136
- });
148
+ return <canvas width="300" height="300" ref={canvasEl}/>;
149
+ };
137
150
 
138
151
  ```
139
152
 
@@ -142,8 +155,9 @@ export const FabricJSCanvas = () => {
142
155
  <details><summary><b>Node.js</b></summary>
143
156
 
144
157
  ```js
145
- const http = require('http');
146
- const { fabric } = require('fabric');
158
+ import http from 'http';
159
+ import * as fabric from 'fabric/node'; // v6
160
+ import { fabric } from 'fabric'; // v5
147
161
 
148
162
  const port = 8080;
149
163
 
@@ -177,6 +191,8 @@ http
177
191
 
178
192
  </details>
179
193
 
194
+ See our ready to use [templates](./.codesandbox/templates/).
195
+
180
196
  ---
181
197
 
182
198
  ## Other Solutions
@@ -186,7 +202,6 @@ http
186
202
  | [Three.js][three.js] | 3D graphics |
187
203
  | [PixiJS][pixijs] | WebGL renderer |
188
204
  | [Konva][konva] | Similar features | ❌ |
189
- | [Canvas2PDF][canvas2pdf] | PDF renderer |
190
205
  | [html-to-image][html-to-image] | HTML to image/canvas |
191
206
 
192
207
  ## More Resources
@@ -214,7 +229,6 @@ http
214
229
 
215
230
  [asturur]: https://github.com/asturur
216
231
  [asturur_twitter]: https://twitter.com/AndreaBogazzi
217
- [canvas2pdf]: https://github.com/joshua-gould/canvas2pdf
218
232
  [cdnjs]: https://cdnjs.com/libraries/fabric.js
219
233
  [code_triage]: https://www.codetriage.com/kangax/fabric.js
220
234
  [codepens]: https://codepen.io/tag/fabricjs
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ presets: [
3
+ ['@babel/preset-env', { targets: { node: 'current' } }],
4
+ '@babel/preset-typescript',
5
+ ],
6
+ };