fabric 6.0.0-beta1 → 6.0.0-beta10
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.
- package/.eslintignore +3 -0
- package/.eslintrc.js +8 -0
- package/.gitpod.yml +17 -1
- package/.prettierignore +3 -0
- package/CHANGELOG.md +124 -0
- package/CONTRIBUTING.md +84 -78
- package/README.md +31 -15
- package/babel-jest.config.js +6 -0
- package/dist/fabric.d.ts +53 -1020
- package/dist/{index.cjs → index.js} +21998 -21573
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +21988 -21567
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +22836 -22390
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +9 -4
- package/dist/index.node.mjs +22827 -22385
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/{util/class_registry.d.ts → ClassRegistry.d.ts} +2 -3
- package/dist/src/Collection.d.ts +11 -1
- package/dist/src/EventTypeDefs.d.ts +17 -16
- package/dist/src/Intersection.d.ts +12 -0
- package/dist/src/Observable.d.ts +11 -5
- package/dist/src/{Pattern.d.ts → Pattern/Pattern.d.ts} +23 -28
- package/dist/src/Pattern/index.d.ts +3 -0
- package/dist/src/Pattern/types.d.ts +9 -0
- package/dist/src/Point.d.ts +42 -42
- package/dist/src/Shadow.d.ts +12 -3
- package/dist/src/brushes/BaseBrush.d.ts +1 -5
- package/dist/src/brushes/CircleBrush.d.ts +2 -7
- package/dist/src/brushes/CircleBrush.test.d.ts +2 -0
- package/dist/src/brushes/PatternBrush.d.ts +2 -2
- package/dist/src/brushes/PencilBrush.d.ts +8 -8
- package/dist/src/brushes/SprayBrush.d.ts +2 -7
- package/dist/src/brushes/typedefs.d.ts +18 -0
- package/dist/src/cache.d.ts +2 -1
- package/dist/src/canvas/Canvas.d.ts +19 -222
- package/dist/src/canvas/DOMManagers/CanvasDOMManager.d.ts +29 -0
- package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.d.ts +29 -0
- package/dist/src/canvas/DOMManagers/util.d.ts +24 -0
- package/dist/src/canvas/DOMManagers/util.spec.d.ts +2 -0
- package/dist/src/canvas/SelectableCanvas.d.ts +80 -80
- package/dist/src/canvas/StaticCanvas.d.ts +42 -46
- package/dist/src/canvas/TextEditingManager.d.ts +5 -1
- package/dist/src/color/Color.d.ts +1 -23
- package/dist/src/color/constants.d.ts +96 -14
- package/dist/src/color/typedefs.d.ts +16 -0
- package/dist/src/color/util.d.ts +18 -3
- package/dist/src/constants.d.ts +8 -1
- package/dist/src/controls/Control.d.ts +14 -13
- package/dist/src/controls/changeWidth.d.ts +1 -1
- package/dist/src/controls/{default_controls.d.ts → commonControls.d.ts} +1 -23
- package/dist/src/controls/{controls.render.d.ts → controlRendering.d.ts} +6 -6
- package/dist/src/controls/drag.d.ts +1 -1
- package/dist/src/controls/fireEvent.d.ts +3 -0
- package/dist/src/controls/index.d.ts +13 -0
- package/dist/src/controls/rotate.d.ts +1 -1
- package/dist/src/controls/scale.d.ts +2 -2
- package/dist/src/controls/scaleSkew.d.ts +2 -2
- package/dist/src/controls/skew.d.ts +1 -1
- package/dist/src/controls/util.d.ts +2 -2
- package/dist/src/controls/wrapWithFireEvent.d.ts +1 -1
- package/dist/src/controls/wrapWithFixedAnchor.d.ts +1 -1
- package/dist/src/env/browser.d.ts +1 -1
- package/dist/src/env/index.d.ts +25 -4
- package/dist/src/env/node.d.ts +4 -1
- package/dist/src/env/types.d.ts +5 -5
- package/dist/src/filters/BaseFilter.d.ts +24 -20
- package/dist/src/filters/BlendColor.d.ts +18 -17
- package/dist/src/filters/BlendImage.d.ts +13 -10
- package/dist/src/filters/Blur.d.ts +4 -2
- package/dist/src/filters/Boilerplate.d.ts +6 -4
- package/dist/src/filters/Brightness.d.ts +4 -2
- package/dist/src/filters/Canvas2dFilterBackend.d.ts +1 -1
- package/dist/src/filters/ColorMatrix.d.ts +4 -2
- package/dist/src/filters/ColorMatrixFilters.d.ts +128 -760
- package/dist/src/filters/Composed.d.ts +7 -8
- package/dist/src/filters/Contrast.d.ts +4 -2
- package/dist/src/filters/Convolute.d.ts +6 -5
- package/dist/src/filters/FilterBackend.d.ts +2 -1
- package/dist/src/filters/GLProbes/GLProbe.d.ts +7 -0
- package/dist/src/filters/GLProbes/NodeGLProbe.d.ts +11 -0
- package/dist/src/filters/GLProbes/WebGLProbe.d.ts +20 -0
- package/dist/src/filters/Gamma.d.ts +6 -4
- package/dist/src/filters/Grayscale.d.ts +7 -5
- package/dist/src/filters/HueRotation.d.ts +3 -2
- package/dist/src/filters/Invert.d.ts +4 -2
- package/dist/src/filters/Noise.d.ts +4 -2
- package/dist/src/filters/Pixelate.d.ts +4 -2
- package/dist/src/filters/RemoveColor.d.ts +4 -2
- package/dist/src/filters/Resize.d.ts +7 -4
- package/dist/src/filters/Saturation.d.ts +4 -2
- package/dist/src/filters/Vibrance.d.ts +4 -2
- package/dist/src/filters/WebGLFilterBackend.d.ts +8 -6
- package/dist/src/filters/filters.d.ts +21 -0
- package/dist/src/filters/index.d.ts +7 -0
- package/dist/src/filters/shaders/baseFilter.d.ts +4 -0
- package/dist/src/filters/shaders/blendColor.d.ts +13 -0
- package/dist/src/filters/shaders/blendImage.d.ts +3 -0
- package/dist/src/filters/shaders/blur.d.ts +2 -0
- package/dist/src/filters/shaders/brightness.d.ts +2 -0
- package/dist/src/filters/shaders/colorMatrix.d.ts +2 -0
- package/dist/src/filters/shaders/constrast.d.ts +2 -0
- package/dist/src/filters/shaders/convolute.d.ts +11 -0
- package/dist/src/filters/shaders/gamma.d.ts +2 -0
- package/dist/src/filters/shaders/grayscale.d.ts +3 -0
- package/dist/src/filters/shaders/invert.d.ts +2 -0
- package/dist/src/filters/shaders/noise.d.ts +2 -0
- package/dist/src/filters/shaders/pixelate.d.ts +2 -0
- package/dist/src/filters/shaders/removeColor.d.ts +2 -0
- package/dist/src/filters/shaders/saturation.d.ts +2 -0
- package/dist/src/filters/shaders/vibrance.d.ts +2 -0
- package/dist/src/filters/typedefs.d.ts +1 -2
- package/dist/src/filters/utils.d.ts +3 -0
- package/dist/src/gradient/Gradient.d.ts +3 -2
- package/dist/src/gradient/index.d.ts +3 -0
- package/dist/src/gradient/parser/misc.d.ts +1 -1
- package/dist/src/gradient/parser/parseColorStops.d.ts +2 -5
- package/dist/src/gradient/parser/parseCoords.d.ts +1 -1
- package/dist/src/gradient/typedefs.d.ts +2 -2
- package/dist/src/parser/applyViewboxTransform.d.ts +1 -1
- package/dist/src/parser/constants.d.ts +2 -3
- package/dist/src/parser/doesSomeParentMatch.d.ts +1 -1
- package/dist/src/parser/elementById.d.ts +1 -1
- package/dist/src/parser/elementMatchesRule.d.ts +1 -1
- package/dist/src/parser/elements_parser.d.ts +1 -1
- package/dist/src/parser/getCSSRules.d.ts +1 -1
- package/dist/src/parser/getSvgRegex.d.ts +1 -1
- package/dist/src/parser/index.d.ts +9 -0
- package/dist/src/parser/loadSVGFromString.d.ts +11 -5
- package/dist/src/parser/loadSVGFromURL.d.ts +11 -5
- package/dist/src/parser/parseSVGDocument.d.ts +16 -8
- package/dist/src/parser/parseTransformAttribute.d.ts +3 -2
- package/dist/src/parser/selectorMatches.d.ts +1 -1
- package/dist/src/parser/typedefs.d.ts +9 -0
- package/dist/src/shapes/ActiveSelection.d.ts +20 -3
- package/dist/src/shapes/Circle.d.ts +25 -6
- package/dist/src/shapes/Ellipse.d.ts +22 -12
- package/dist/src/shapes/Group.d.ts +55 -29
- package/dist/src/shapes/IText/DraggableTextDelegate.d.ts +1 -1
- package/dist/src/shapes/IText/IText.d.ts +42 -28
- package/dist/src/shapes/IText/ITextBehavior.d.ts +8 -6
- package/dist/src/shapes/IText/ITextClickBehavior.d.ts +6 -14
- package/dist/src/shapes/IText/ITextKeyBehavior.d.ts +6 -4
- package/dist/src/shapes/Image.d.ts +43 -17
- package/dist/src/shapes/Line.d.ts +31 -27
- package/dist/src/shapes/Object/AnimatableObject.d.ts +3 -3
- package/dist/src/shapes/Object/FabricObject.d.ts +6 -4
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts +1 -1
- package/dist/src/shapes/Object/InteractiveObject.d.ts +52 -38
- package/dist/src/shapes/Object/Object.d.ts +57 -364
- package/dist/src/shapes/Object/ObjectGeometry.d.ts +3 -19
- package/dist/src/shapes/Object/ObjectOrigin.d.ts +6 -75
- package/dist/src/shapes/Object/StackedObject.d.ts +14 -4
- package/dist/src/shapes/Object/defaultValues.d.ts +71 -72
- package/dist/src/shapes/Object/types/BaseProps.d.ts +84 -0
- package/dist/src/shapes/Object/types/BorderProps.d.ts +37 -0
- package/dist/src/shapes/Object/types/ControlProps.d.ts +62 -0
- package/dist/src/shapes/Object/types/FabricObjectProps.d.ts +96 -0
- package/dist/src/shapes/Object/types/FillStrokeProps.d.ts +80 -0
- package/dist/src/shapes/Object/types/LockInteractionProps.d.ts +51 -0
- package/dist/src/shapes/Object/types/ObjectProps.d.ts +42 -0
- package/dist/src/shapes/Object/types/SerializedObjectProps.d.ts +66 -0
- package/dist/src/shapes/Object/types/index.d.ts +6 -0
- package/dist/src/shapes/Path.d.ts +129 -38
- package/dist/src/shapes/Polygon.d.ts +5 -2
- package/dist/src/shapes/Polyline.d.ts +29 -12
- package/dist/src/shapes/Rect.d.ts +27 -7
- package/dist/src/shapes/Text/StyledText.d.ts +19 -14
- package/dist/src/shapes/Text/Text.d.ts +74 -42
- package/dist/src/shapes/Text/TextSVGExportMixin.d.ts +1 -1
- package/dist/src/shapes/Text/constants.d.ts +13 -0
- package/dist/src/shapes/Textbox.d.ts +44 -10
- package/dist/src/shapes/Triangle.d.ts +12 -3
- package/dist/src/typedefs.d.ts +27 -24
- package/dist/src/util/animation/AnimationBase.d.ts +1 -1
- package/dist/src/util/animation/AnimationFrameProvider.d.ts +0 -5
- package/dist/src/util/animation/ArrayAnimation.d.ts +1 -1
- package/dist/src/util/animation/ColorAnimation.d.ts +1 -1
- package/dist/src/util/animation/ValueAnimation.d.ts +1 -1
- package/dist/src/util/animation/animate.d.ts +2 -2
- package/dist/src/util/animation/easing.d.ts +1 -1
- package/dist/src/util/animation/index.d.ts +3 -0
- package/dist/src/util/animation/types.d.ts +1 -1
- package/dist/src/util/applyMixins.d.ts +1 -1
- package/dist/src/util/dom_misc.d.ts +3 -31
- package/dist/src/util/dom_request.d.ts +1 -1
- package/dist/src/util/index.d.ts +36 -0
- package/dist/src/util/internals/cleanupSvgAttribute.d.ts +2 -0
- package/dist/src/util/internals/cleanupSvgAttribute.test.d.ts +2 -0
- package/dist/src/util/internals/cloneDeep.test.d.ts +2 -0
- package/dist/src/util/internals/getRandomInt.test.d.ts +2 -0
- package/dist/src/util/misc/boundingBoxFromPoints.d.ts +4 -4
- package/dist/src/util/misc/dom.d.ts +1 -1
- package/dist/src/util/misc/findScaleTo.d.ts +7 -16
- package/dist/src/util/misc/groupSVGElements.d.ts +1 -1
- package/dist/src/util/misc/isTransparent.d.ts +3 -3
- package/dist/src/util/misc/matrix.d.ts +87 -11
- package/dist/src/util/misc/objectEnlive.d.ts +5 -20
- package/dist/src/util/misc/objectTransforms.d.ts +1 -1
- package/dist/src/util/misc/pick.d.ts +1 -0
- package/dist/src/util/misc/planeChange.d.ts +2 -5
- package/dist/src/util/misc/projectStroke/StrokeLineCapProjections.d.ts +4 -3
- package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.d.ts +4 -3
- package/dist/src/util/misc/projectStroke/StrokeProjectionsBase.d.ts +4 -3
- package/dist/src/util/misc/projectStroke/index.d.ts +4 -3
- package/dist/src/util/misc/projectStroke/types.d.ts +3 -3
- package/dist/src/util/misc/resolveOrigin.d.ts +1 -1
- package/dist/src/util/misc/svgParsing.d.ts +4 -12
- package/dist/src/util/misc/vectors.d.ts +4 -3
- package/dist/src/util/path/index.d.ts +96 -0
- package/dist/src/util/path/regex.d.ts +2 -0
- package/dist/src/util/path/typechecks.d.ts +24 -0
- package/dist/src/util/path/typedefs.d.ts +220 -0
- package/dist/src/util/transform_matrix_removal.d.ts +1 -1
- package/dist/src/util/{types.d.ts → typeAssertions.d.ts} +3 -3
- package/e2e/site/index.html +25 -0
- package/e2e/utils/objects.ts +36 -0
- package/fabric.ts +61 -416
- package/index.node.ts +12 -12
- package/jest.config.js +194 -0
- package/lib/aligning_guidelines.js +2 -2
- package/package.json +36 -17
- package/playwright.config.ts +64 -0
- package/rollup.config.mjs +27 -7
- package/scripts/git.mjs +36 -0
- package/scripts/index.mjs +9 -124
- package/scripts/sandbox.mjs +149 -0
- package/src/{util/class_registry.ts → ClassRegistry.ts} +11 -9
- package/src/Collection.ts +37 -2
- package/src/EventTypeDefs.ts +65 -61
- package/src/Intersection.ts +54 -25
- package/src/Observable.ts +11 -5
- package/src/{Pattern.ts → Pattern/Pattern.ts} +39 -43
- package/src/Pattern/index.ts +2 -0
- package/src/Pattern/types.ts +17 -0
- package/src/Point.ts +43 -43
- package/src/Shadow.ts +28 -29
- package/src/brushes/BaseBrush.ts +1 -3
- package/src/brushes/CircleBrush.test.ts +11 -0
- package/src/brushes/CircleBrush.ts +6 -11
- package/src/brushes/PatternBrush.ts +2 -2
- package/src/brushes/PencilBrush.ts +10 -10
- package/src/brushes/SprayBrush.ts +6 -11
- package/src/brushes/typedefs.ts +18 -0
- package/src/cache.ts +2 -1
- package/src/canvas/Canvas.ts +170 -244
- package/src/canvas/DOMManagers/CanvasDOMManager.ts +124 -0
- package/src/canvas/DOMManagers/StaticCanvasDOMManager.ts +80 -0
- package/src/canvas/DOMManagers/util.spec.ts +26 -0
- package/src/canvas/DOMManagers/util.ts +98 -0
- package/src/canvas/SelectableCanvas.ts +232 -362
- package/src/canvas/StaticCanvas.ts +92 -167
- package/src/canvas/TextEditingManager.ts +24 -2
- package/src/canvas/canvas_gestures.mixin.ts +10 -10
- package/src/color/Color.ts +51 -135
- package/src/color/color_map.ts +13 -13
- package/src/color/constants.ts +98 -17
- package/src/color/typedefs.ts +18 -0
- package/src/color/util.ts +68 -7
- package/src/constants.ts +11 -1
- package/src/controls/Control.ts +26 -18
- package/src/controls/changeWidth.ts +5 -4
- package/src/controls/{default_controls.ts → commonControls.ts} +2 -29
- package/src/controls/{controls.render.ts → controlRendering.ts} +5 -5
- package/src/controls/drag.ts +5 -4
- package/src/{util → controls}/fireEvent.ts +4 -1
- package/src/controls/index.ts +22 -0
- package/src/controls/polyControl.ts +4 -4
- package/src/controls/rotate.ts +1 -1
- package/src/controls/scale.ts +2 -2
- package/src/controls/scaleSkew.ts +2 -2
- package/src/controls/skew.ts +4 -3
- package/src/controls/util.ts +6 -5
- package/src/controls/wrapWithFireEvent.ts +2 -2
- package/src/controls/wrapWithFixedAnchor.ts +1 -1
- package/src/env/browser.ts +6 -2
- package/src/env/index.ts +27 -8
- package/src/env/node.ts +32 -26
- package/src/env/types.ts +5 -5
- package/src/filters/BaseFilter.ts +69 -69
- package/src/filters/BlendColor.ts +41 -80
- package/src/filters/BlendImage.ts +34 -58
- package/src/filters/Blur.ts +16 -37
- package/src/filters/Boilerplate.ts +25 -22
- package/src/filters/Brightness.ts +15 -23
- package/src/filters/Canvas2dFilterBackend.ts +1 -1
- package/src/filters/ColorMatrix.ts +17 -26
- package/src/filters/ColorMatrixFilters.ts +17 -44
- package/src/filters/Composed.ts +11 -18
- package/src/filters/Contrast.ts +13 -23
- package/src/filters/Convolute.ts +15 -170
- package/src/filters/FilterBackend.ts +10 -4
- package/src/filters/GLProbes/GLProbe.ts +7 -0
- package/src/filters/GLProbes/NodeGLProbe.ts +15 -0
- package/src/filters/{WebGLProbe.ts → GLProbes/WebGLProbe.ts} +9 -24
- package/src/filters/Gamma.ts +25 -40
- package/src/filters/Grayscale.ts +17 -50
- package/src/filters/HueRotation.ts +12 -14
- package/src/filters/Invert.ts +16 -32
- package/src/filters/Noise.ts +15 -28
- package/src/filters/Pixelate.ts +15 -31
- package/src/filters/RemoveColor.ts +16 -27
- package/src/filters/Resize.ts +72 -72
- package/src/filters/Saturation.ts +16 -27
- package/src/filters/Vibrance.ts +15 -28
- package/src/filters/WebGLFilterBackend.ts +55 -29
- package/src/filters/filters.ts +28 -0
- package/src/filters/index.ts +12 -0
- package/src/filters/shaders/baseFilter.ts +17 -0
- package/src/filters/shaders/blendColor.ts +33 -0
- package/src/filters/shaders/blendImage.ts +32 -0
- package/src/filters/shaders/blur.ts +24 -0
- package/src/filters/shaders/brightness.ts +11 -0
- package/src/filters/shaders/colorMatrix.ts +12 -0
- package/src/filters/shaders/constrast.ts +11 -0
- package/src/filters/shaders/convolute.ts +154 -0
- package/src/filters/shaders/gamma.ts +15 -0
- package/src/filters/shaders/grayscale.ts +36 -0
- package/src/filters/shaders/invert.ts +19 -0
- package/src/filters/shaders/noise.ts +16 -0
- package/src/filters/shaders/pixelate.ts +19 -0
- package/src/filters/shaders/removeColor.ts +13 -0
- package/src/filters/shaders/saturation.ts +15 -0
- package/src/filters/shaders/vibrance.ts +16 -0
- package/src/filters/typedefs.ts +1 -7
- package/src/filters/utils.ts +7 -0
- package/src/gradient/Gradient.ts +14 -6
- package/src/gradient/index.ts +2 -0
- package/src/gradient/parser/misc.ts +1 -1
- package/src/gradient/parser/parseColorStops.ts +2 -1
- package/src/gradient/parser/parseCoords.ts +2 -2
- package/src/gradient/typedefs.ts +2 -2
- package/src/parser/applyViewboxTransform.ts +29 -33
- package/src/parser/constants.ts +7 -9
- package/src/parser/doesSomeParentMatch.ts +7 -8
- package/src/parser/elementById.ts +5 -7
- package/src/parser/elementMatchesRule.ts +4 -7
- package/src/parser/elements_parser.ts +64 -97
- package/src/parser/getCSSRules.ts +17 -18
- package/src/parser/getGradientDefs.ts +4 -5
- package/src/parser/getSvgRegex.ts +1 -3
- package/src/parser/index.ts +8 -0
- package/src/parser/loadSVGFromString.ts +19 -16
- package/src/parser/loadSVGFromURL.ts +36 -29
- package/src/parser/normalizeValue.ts +8 -7
- package/src/parser/parsePointsAttribute.ts +2 -4
- package/src/parser/parseSVGDocument.ts +71 -59
- package/src/parser/parseTransformAttribute.ts +54 -115
- package/src/parser/parseUseDirectives.ts +20 -21
- package/src/parser/selectorMatches.ts +11 -11
- package/src/parser/setStrokeFillOpacity.ts +3 -3
- package/src/parser/typedefs.ts +13 -0
- package/src/shapes/ActiveSelection.ts +47 -12
- package/src/shapes/Circle.ts +74 -43
- package/src/shapes/Ellipse.ts +52 -29
- package/src/shapes/Group.ts +134 -84
- package/src/shapes/IText/DraggableTextDelegate.ts +23 -32
- package/src/shapes/IText/IText.ts +83 -53
- package/src/shapes/IText/ITextBehavior.ts +72 -54
- package/src/shapes/IText/ITextClickBehavior.ts +43 -72
- package/src/shapes/IText/ITextKeyBehavior.ts +68 -76
- package/src/shapes/IText/constants.ts +26 -20
- package/src/shapes/Image.ts +112 -53
- package/src/shapes/Line.ts +106 -150
- package/src/shapes/Object/AnimatableObject.ts +4 -7
- package/src/shapes/Object/FabricObject.ts +17 -7
- package/src/shapes/Object/FabricObjectSVGExportMixin.ts +3 -2
- package/src/shapes/Object/InteractiveObject.ts +94 -70
- package/src/shapes/Object/Object.ts +163 -470
- package/src/shapes/Object/ObjectGeometry.ts +12 -28
- package/src/shapes/Object/ObjectOrigin.ts +19 -96
- package/src/shapes/Object/StackedObject.ts +36 -21
- package/src/shapes/Object/defaultValues.ts +7 -9
- package/src/shapes/Object/types/BaseProps.ts +96 -0
- package/src/shapes/Object/types/BorderProps.ts +40 -0
- package/src/shapes/Object/types/ControlProps.ts +69 -0
- package/src/shapes/Object/types/FabricObjectProps.ts +111 -0
- package/src/shapes/Object/types/FillStrokeProps.ts +90 -0
- package/src/shapes/Object/types/LockInteractionProps.ts +57 -0
- package/src/shapes/Object/types/ObjectProps.ts +49 -0
- package/src/shapes/Object/types/SerializedObjectProps.ts +73 -0
- package/src/shapes/Object/types/index.ts +8 -0
- package/src/shapes/Path.ts +164 -125
- package/src/shapes/Polygon.ts +12 -9
- package/src/shapes/Polyline.ts +91 -60
- package/src/shapes/Rect.ts +55 -24
- package/src/shapes/Text/StyledText.ts +51 -47
- package/src/shapes/Text/Text.ts +228 -285
- package/src/shapes/Text/TextSVGExportMixin.ts +4 -3
- package/src/shapes/Text/constants.ts +111 -0
- package/src/shapes/Textbox.ts +108 -53
- package/src/shapes/Triangle.ts +28 -11
- package/src/typedefs.ts +29 -27
- package/src/util/animation/AnimationBase.ts +1 -1
- package/src/util/animation/AnimationFrameProvider.ts +3 -22
- package/src/util/animation/ArrayAnimation.ts +1 -1
- package/src/util/animation/ColorAnimation.ts +1 -1
- package/src/util/animation/ValueAnimation.ts +1 -1
- package/src/util/animation/animate.ts +2 -2
- package/src/util/animation/easing.ts +1 -1
- package/src/util/animation/index.ts +2 -0
- package/src/util/animation/types.ts +1 -1
- package/src/util/applyMixins.ts +1 -1
- package/src/util/dom_misc.ts +12 -106
- package/src/util/dom_request.ts +2 -2
- package/src/util/index.ts +106 -0
- package/src/util/internals/cleanupSvgAttribute.test.ts +16 -0
- package/src/util/internals/cleanupSvgAttribute.ts +8 -0
- package/src/util/internals/cloneDeep.test.ts +16 -0
- package/src/util/internals/getRandomInt.test.ts +33 -0
- package/src/util/misc/boundingBoxFromPoints.ts +5 -4
- package/src/util/misc/dom.ts +10 -5
- package/src/util/misc/findScaleTo.ts +7 -22
- package/src/util/misc/isTransparent.ts +9 -32
- package/src/util/misc/matrix.ts +161 -55
- package/src/util/misc/objectEnlive.ts +5 -20
- package/src/util/misc/objectTransforms.ts +3 -2
- package/src/util/misc/pick.ts +12 -0
- package/src/util/misc/planeChange.ts +4 -13
- package/src/util/misc/projectStroke/StrokeLineCapProjections.ts +4 -3
- package/src/util/misc/projectStroke/StrokeLineJoinProjections.ts +4 -8
- package/src/util/misc/projectStroke/StrokeProjectionsBase.ts +4 -3
- package/src/util/misc/projectStroke/index.ts +6 -4
- package/src/util/misc/projectStroke/types.ts +3 -3
- package/src/util/misc/resolveOrigin.ts +1 -1
- package/src/util/misc/svgParsing.ts +20 -30
- package/src/util/misc/textStyles.ts +5 -6
- package/src/util/misc/vectors.ts +4 -3
- package/src/util/{path.ts → path/index.ts} +417 -319
- package/src/util/path/regex.ts +39 -0
- package/src/util/path/typechecks.ts +145 -0
- package/src/util/path/typedefs.ts +305 -0
- package/src/util/transform_matrix_removal.ts +4 -3
- package/src/util/{types.ts → typeAssertions.ts} +3 -3
- package/dist/index.cjs.map +0 -1
- package/dist/src/filters/WebGLProbe.d.ts +0 -28
- package/dist/src/mixins/stateful.mixin.d.ts +0 -18
- package/dist/src/parser/parseElements.d.ts +0 -11
- package/dist/src/parser/rotateMatrix.d.ts +0 -2
- package/dist/src/parser/scaleMatrix.d.ts +0 -2
- package/dist/src/parser/skewMatrix.d.ts +0 -2
- package/dist/src/parser/translateMatrix.d.ts +0 -2
- package/dist/src/util/fireEvent.d.ts +0 -3
- package/dist/src/util/lang_class.d.ts +0 -12
- package/dist/src/util/path.d.ts +0 -108
- package/scripts/transform_files.mjs +0 -504
- package/src/mixins/stateful.mixin.ts +0 -104
- package/src/parser/parseElements.ts +0 -28
- package/src/parser/rotateMatrix.ts +0 -21
- package/src/parser/scaleMatrix.ts +0 -9
- package/src/parser/skewMatrix.ts +0 -6
- package/src/parser/translateMatrix.ts +0 -8
- package/src/util/lang_class.ts +0 -90
package/.eslintignore
ADDED
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
|
-
-
|
|
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
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,130 @@
|
|
|
2
2
|
|
|
3
3
|
## [next]
|
|
4
4
|
|
|
5
|
+
## [6.0.0-beta10]
|
|
6
|
+
|
|
7
|
+
- chore(TS): Remove @ts-nocheck from Text class. [#9018](https://github.com/fabricjs/fabric.js/pull/9018)
|
|
8
|
+
- Fix(Textbox) minimum word width calculation across all lines [#9004](https://github.com/fabricjs/fabric.js/pull/9004)
|
|
9
|
+
- ci(): add Jest for the unit tests [#8919](https://github.com/fabricjs/fabric.js/pull/8919)
|
|
10
|
+
- ci(): Revert "invoke tests after changelog action (#8974)" [#9013](https://github.com/fabricjs/fabric.js/pull/9013)
|
|
11
|
+
- fix(IText): empty line selection [#9019](https://github.com/fabricjs/fabric.js/pull/9019)
|
|
12
|
+
- ci(): Added playwright testing [#8616](https://github.com/fabricjs/fabric.js/pull/8616)
|
|
13
|
+
- fix(IText): `exitEditing` should clear contextTop [#9020](https://github.com/fabricjs/fabric.js/pull/9020)
|
|
14
|
+
- ci(): prettier after changelog action [#9021](https://github.com/fabricjs/fabric.js/pull/9021)
|
|
15
|
+
|
|
16
|
+
## [6.0.0-beta9]
|
|
17
|
+
|
|
18
|
+
- fix(fabric): Fix the serialization and registry dependency from minification [#9009](https://github.com/fabricjs/fabric.js/pull/9009)
|
|
19
|
+
- chore(TS): remove troublesome `AssertKeys` TS construct [#9012](https://github.com/fabricjs/fabric.js/pull/9012)
|
|
20
|
+
- fix(lib): fix aligning_guideline zoom [#8998](https://github.com/fabricjs/fabric.js/pull/8998)
|
|
21
|
+
- fix(IText): support control interaction in text editing mode [#8995](https://github.com/fabricjs/fabric.js/pull/8995)
|
|
22
|
+
- fix(Textbox): `splitByGrapheme` measurements infix length bug [#8990](https://github.com/fabricjs/fabric.js/pull/8990)
|
|
23
|
+
- patch(Text): styles es6 minor patch [#8988](https://github.com/fabricjs/fabric.js/pull/8988)
|
|
24
|
+
|
|
25
|
+
## [6.0.0-beta8]
|
|
26
|
+
|
|
27
|
+
- BREAKING fix(IText): detect cursor from proper offsets, remove getLocalPointer from IText class [#8972](https://github.com/fabricjs/fabric.js/pull/8972)
|
|
28
|
+
- fix(Text): styles line break [#8973](https://github.com/fabricjs/fabric.js/pull/8973)
|
|
29
|
+
- fix(): regression to itext focusing from #8939 [#8970](https://github.com/fabricjs/fabric.js/pull/8970)
|
|
30
|
+
- ci(): warn build errors in dev mode [#8971](https://github.com/fabricjs/fabric.js/pull/8971)
|
|
31
|
+
- ci(): invoke tests after changelog action [#8974](https://github.com/fabricjs/fabric.js/pull/8974)
|
|
32
|
+
- chore(TS): Export more types [#8965](https://github.com/fabricjs/fabric.js/pull/8965)
|
|
33
|
+
- BREAKING: fabric.util.makeElementSelectable / fabric.util.makeElementUnselectable are removed [#8930](https://github.com/fabricjs/fabric.js/pull/8930)
|
|
34
|
+
- refactor(): Canvas DOM delegation to utility class [#8930](https://github.com/fabricjs/fabric.js/pull/8930)
|
|
35
|
+
|
|
36
|
+
## [6.0.0-beta7]
|
|
37
|
+
|
|
38
|
+
- 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)
|
|
39
|
+
- chore(): swap commonly used string with constants [#8933](https://github.com/fabricjs/fabric.js/pull/8933)
|
|
40
|
+
- chore(TS): Add more text types [#8941](https://github.com/fabricjs/fabric.js/pull/8941)
|
|
41
|
+
- ci(): fix changelog action race condition [#8949](https://github.com/fabricjs/fabric.js/pull/8949)
|
|
42
|
+
- ci(): automate PR changelog [#8938](https://github.com/fabricjs/fabric.js/pull/8938)
|
|
43
|
+
- chore(): move canvas click handler to TextManager [#8939](https://github.com/fabricjs/fabric.js/pull/8939)
|
|
44
|
+
- refactor(): write less bulky code [#8943](https://github.com/fabricjs/fabric.js/pull/8943)
|
|
45
|
+
|
|
46
|
+
## [6.0.0-beta6]
|
|
47
|
+
|
|
48
|
+
- patch(): expose `Control#shouldActivate` [#8934](https://github.com/fabricjs/fabric.js/pull/8934)
|
|
49
|
+
- feat(Color) Improve regex for new standards, more documentation and code cleanup [#8916](https://github.com/fabricjs/fabric.js/pull/8916)
|
|
50
|
+
- fix(TS): extending canvas and object event types (`type` => `interface`) [#8926](https://github.com/fabricjs/fabric.js/pull/8926)
|
|
51
|
+
- chore(build) simple deps update [#8929](https://github.com/fabricjs/fabric.js/pull/8929)
|
|
52
|
+
- fix(Canvas): sync cleanup of dom elements in dispose [#8903](https://github.com/fabricjs/fabric.js/pull/8903)
|
|
53
|
+
- chore(TS): export util types [#8915](https://github.com/fabricjs/fabric.js/pull/8915)
|
|
54
|
+
- chore(TS): change enums with types [#8918](https://github.com/fabricjs/fabric.js/pull/8918)
|
|
55
|
+
- chore(TS): export gradient types
|
|
56
|
+
- chore(lint) export filter colors and brushes types [#8913](https://github.com/fabricjs/fabric.js/pull/8913)
|
|
57
|
+
- chore(lint) Add a rule for import type [#8907](https://github.com/fabricjs/fabric.js/pull/8907)
|
|
58
|
+
- fix(Object): dirty unflagging inconsistency [#8910](https://github.com/fabricjs/fabric.js/pull/8910)
|
|
59
|
+
- chore(TS): minor type/import fixes [#8904](https://github.com/fabricjs/fabric.js/pull/8904)
|
|
60
|
+
- chore(): Matrix util cleanup [#8894](https://github.com/fabricjs/fabric.js/pull/8894)
|
|
61
|
+
- chore(TS): pattern cleanup + export types [#8875](https://github.com/fabricjs/fabric.js/pull/8875)
|
|
62
|
+
- fix(): Disable offscreen check for bg and overlay when not needed [#8898](https://github.com/fabricjs/fabric.js/pull/8898)
|
|
63
|
+
- chore(): cleanup #8888 [#8892](https://github.com/fabricjs/fabric.js/pull/8892)
|
|
64
|
+
- feat(env): relative window/document, support iframe [#8897](https://github.com/fabricjs/fabric.js/pull/8897)
|
|
65
|
+
- docs(): add repo repro link to `bug_report.yml` [#8900](https://github.com/fabricjs/fabric.js/pull/8900)
|
|
66
|
+
- refactor(fabric.Line): Line position is calculated from the center between the 2 points now [#8877](https://github.com/fabricjs/fabric.js/pull/8877)
|
|
67
|
+
- chore(Path, Polyline): Clean up old SVG import code [#8857](https://github.com/fabricjs/fabric.js/pull/8857)
|
|
68
|
+
|
|
69
|
+
## [6.0.0-beta5]
|
|
70
|
+
|
|
71
|
+
- refactor(): SVG loading and parsing functionality are now promises or async. Callback have been removed [#8884](https://github.com/fabricjs/fabric.js/pull/8884)
|
|
72
|
+
- refactor(fabric.Line): Line position is calculated from the center between the 2 points now [#8877](https://github.com/fabricjs/fabric.js/pull/8877)
|
|
73
|
+
- bundle(): export `setEnv` for test interoperability [#8888](https://github.com/fabricjs/fabric.js/pull/8888)
|
|
74
|
+
|
|
75
|
+
## [6.0.0-beta4]
|
|
76
|
+
|
|
77
|
+
- chore(): Code cleanup and reuse of code in svg-parsing code [#8881](https://github.com/fabricjs/fabric.js/pull/8881)
|
|
78
|
+
- chore(TS): Parse transform attribute typing [#8878](https://github.com/fabricjs/fabric.js/pull/8878)
|
|
79
|
+
- chore(TS): Fix typing for DOMParser [#8871](https://github.com/fabricjs/fabric.js/pull/8871)
|
|
80
|
+
- fix(Path, Polyline): fix for SVG import [#8879](https://github.com/fabricjs/fabric.js/pull/8879)
|
|
81
|
+
- chore(TS) add types for loadSVGFromURl, parseSVGDocument, loadSVGFromString [#8869](https://github.com/fabricjs/fabric.js/pull/8869)
|
|
82
|
+
- chore(TS): finalize Path migration [#8438](https://github.com/fabricjs/fabric.js/pull/8438)
|
|
83
|
+
- 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)
|
|
84
|
+
|
|
85
|
+
## [6.0.0-beta3]
|
|
86
|
+
|
|
87
|
+
- chore(TS): Path type fixes [#8842](https://github.com/fabricjs/fabric.js/pull/8842)
|
|
88
|
+
- fix(TS): add types to some untyped empty arrays [#8830](https://github.com/fabricjs/fabric.js/pull/8830)
|
|
89
|
+
- chore(TS): Complete typings for toObject/fromObject [#8756](https://github.com/fabricjs/fabric.js/pull/8756)
|
|
90
|
+
- fix(): text styles edge case [#8820](https://github.com/fabricjs/fabric.js/pull/8820)
|
|
91
|
+
- chore(TS): Group types [#8807](https://github.com/fabricjs/fabric.js/pull/8807)
|
|
92
|
+
- chore(TS): Path util typings and refactoring [#8787](https://github.com/fabricjs/fabric.js/pull/8787)
|
|
93
|
+
- rename(): `IPoint` => `XY` [#8806](https://github.com/fabricjs/fabric.js/pull/8806)
|
|
94
|
+
- 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)
|
|
95
|
+
- perf(): optimize `perPixelTargetFind` [#8770](https://github.com/fabricjs/fabric.js/pull/8770)
|
|
96
|
+
- BREAKING fix(): reflect NUM_FRACTION_DIGITS to SVG path data [#8782] (https://github.com/fabricjs/fabric.js/pull/8782)
|
|
97
|
+
- fix(IText): layout change regression caused by #8663 (`text` was changed but layout was skipped) [#8711](https://github.com/fabricjs/fabric.js/pull/8711)
|
|
98
|
+
- fix(IText, Textbox): fix broken text input [#8775](https://github.com/fabricjs/fabric.js/pull/8775)
|
|
99
|
+
- ci(): `.codesandbox` [#8135](https://github.com/fabricjs/fabric.js/pull/8135)
|
|
100
|
+
- ci(): disallow circular deps [#8759](https://github.com/fabricjs/fabric.js/pull/8759)
|
|
101
|
+
- fix(): env WebGL import cycle [#8758](https://github.com/fabricjs/fabric.js/pull/8758)
|
|
102
|
+
- chore(TS): remove controls from prototype. BREAKING: controls aren't shared anymore [#8753](https://github.com/fabricjs/fabric.js/pull/8753)
|
|
103
|
+
- chore(TS): remove object `type` from prototype [#8714](https://github.com/fabricjs/fabric.js/pull/8714)
|
|
104
|
+
- chore(TS): type Object props [#8677](https://github.com/fabricjs/fabric.js/issues/8677)
|
|
105
|
+
- chore(TS): remove default values from filter prototypes [#8742](https://github.com/fabricjs/fabric.js/issues/8742)
|
|
106
|
+
- chore(TS): remove default values from Objects prototypes, ( filters in a followup ) [#8719](https://github.com/fabricjs/fabric.js/issues/8719)
|
|
107
|
+
- fix(Intersection): bug causing selection edge case [#8735](https://github.com/fabricjs/fabric.js/pull/8735)
|
|
108
|
+
- chore(TS): class interface for options/brevity [#8674](https://github.com/fabricjs/fabric.js/issues/8674)
|
|
109
|
+
- ci(): fix import autocomplete in dev mode #8725
|
|
110
|
+
- chore(): remove deprecated class util [#8731](https://github.com/fabricjs/fabric.js/pull/8731)
|
|
111
|
+
- lint(): fix eslint errors [#8729](https://github.com/fabricjs/fabric.js/pull/8729)
|
|
112
|
+
- fix(TS): `this.constructor` types [#8675](https://github.com/fabricjs/fabric.js/issues/8675)
|
|
113
|
+
- fix(DraggableText): drag image blur [#8712](https://github.com/fabricjs/fabric.js/pull/8712)
|
|
114
|
+
- ci(): Fix tests for firefox 110 update [#8710](https://github.com/fabricjs/fabric.js/pull/8710)
|
|
115
|
+
- chore(): index files for exports and tree shaking [#8661](https://github.com/fabricjs/fabric.js/pull/8661)
|
|
116
|
+
- ci(test): cleanup node config (#8694 followup) [#8707](https://github.com/fabricjs/fabric.js/issues/8707)
|
|
117
|
+
- 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)
|
|
118
|
+
- fix(): selection logic to support nested multiselection [#8665](https://github.com/fabricjs/fabric.js/issues/8665)
|
|
119
|
+
- fix(test): remove bad node config [#8694](https://github.com/fabricjs/fabric.js/issues/8694)
|
|
120
|
+
- fix(): keep browser files as .js [#8690](https://github.com/fabricjs/fabric.js/issues/8690)
|
|
121
|
+
- fix(): object dispose removes canvas/event refs [#8673](https://github.com/fabricjs/fabric.js/issues/8673)
|
|
122
|
+
- fix(test): Textbox `fromObject` test is incorrectly trying to restore an instance [#8686](https://github.com/fabricjs/fabric.js/pull/8686)
|
|
123
|
+
- TS(): Moved cache properties to static properties on classes [#xxxx](https://github.com/fabricjs/fabric.js/pull/xxxx)
|
|
124
|
+
- refactor(): Moved cache properties to static properties on classes [#8662](https://github.com/fabricjs/fabric.js/pull/8662)
|
|
125
|
+
- docs(): v6 announcements [#8664](https://github.com/fabricjs/fabric.js/issues/8664)
|
|
126
|
+
- ci(): remove TS transformer [#8660](https://github.com/fabricjs/fabric.js/pull/8660)
|
|
127
|
+
- refactor(): BREAKING remove stateful mixin and functionality [#8663](https://github.com/fabricjs/fabric.js/pull/8663)
|
|
128
|
+
- 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
129
|
- ci(): Removed the browser publish script [#8656](https://github.com/fabricjs/fabric.js/pull/8656)
|
|
6
130
|
- feat(): Node entry point [#8632](https://github.com/fabricjs/fabric.js/pull/8632)
|
|
7
131
|
- chore(): Change import and export strategy [#8622](https://github.com/fabricjs/fabric.js/pull/8622)
|
package/CONTRIBUTING.md
CHANGED
|
@@ -62,12 +62,12 @@ 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
66
|
|
|
67
67
|
Take a look at an existing [demo file][demo_file].\
|
|
68
68
|
Create a new file in the same directory (`posts/demos/_posts`) and follow [**developing the website**](#fabricjscom-deprecated).
|
|
69
69
|
|
|
70
|
-
### ~~`fabricjs.com`~~ (
|
|
70
|
+
### ~~`fabricjs.com`~~ (currently not possible)
|
|
71
71
|
|
|
72
72
|
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
73
|
|
|
@@ -91,17 +91,19 @@ Fabric is an open source project 🦄 and as such depends on the **genuine effor
|
|
|
91
91
|
|
|
92
92
|
- Read this section through.
|
|
93
93
|
- Take a look at [**GOTCHAS**][gotchas]
|
|
94
|
-
- Follow [Developing](#-developing-) and
|
|
94
|
+
- Follow [Developing](#-developing-) and [Testing](#-testing).
|
|
95
95
|
|
|
96
96
|
### ✅ Guidelines
|
|
97
97
|
|
|
98
|
+
- **Be patient** \
|
|
99
|
+
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
100
|
- **Code Style** \
|
|
99
101
|
Fabric uses [`prettier`][prettier] to format files and [`eslint`][eslint] for linting (`npm run lint -- --fix`).\
|
|
100
102
|
To enjoy a seamless dev experience add the [`Prettier - Code formatter`][prettier_extension] extension via the extensions toolbar in VSCode.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
If that doesn't work, once the PR is ready run `npm run prettier:write` and commit the changes.
|
|
104
|
+
Do not reorder imports. Irrelevant changes in a PR that are not created by prettier aren't needed nor welcome.
|
|
103
105
|
- **Tests** \
|
|
104
|
-
PRs must be backed with relevant tests, follow [TESTING](#-testing).
|
|
106
|
+
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.
|
|
105
107
|
- **Docs** \
|
|
106
108
|
Add relevant comments to your code if necessary using [JSDoc 3][jsdoc] and update relevant guides.\
|
|
107
109
|
The generated documentation can be found at [fabricjs.com][docs], see [DOCS](#-improving-docs).
|
|
@@ -110,6 +112,7 @@ Fabric is an open source project 🦄 and as such depends on the **genuine effor
|
|
|
110
112
|
- **1️⃣ PR per feature/bug** \
|
|
111
113
|
Create a new branch for every pull request.\
|
|
112
114
|
If you want to do more than one thing, create multiple pull requests 💪.
|
|
115
|
+
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
116
|
- **And there you go!** \
|
|
114
117
|
If you still have questions we're always happy to help.
|
|
115
118
|
|
|
@@ -122,108 +125,106 @@ It is more than likely you will be requested to change stuff and refine your wor
|
|
|
122
125
|
[](../../actions/workflows/tests.yml)
|
|
123
126
|
[](../../actions/workflows/codeql-analysis.yml)
|
|
124
127
|
|
|
125
|
-
Test suites use [`QUnit`][qunit] for assertions and [`testem`][testem] for serving
|
|
128
|
+
Test suites use [`QUnit`][qunit] for assertions and [`testem`][testem] for serving the browser tests
|
|
126
129
|
|
|
127
130
|
- `unit` tests: test logic and state
|
|
128
|
-
- `visual` tests: test visual outcome against image refs located at
|
|
131
|
+
- `visual` tests: test visual outcome against image refs located at `test/visual/golden`
|
|
132
|
+
- `UI` tests: testing with playwright
|
|
129
133
|
|
|
130
134
|
### Getting Started
|
|
131
135
|
|
|
132
|
-
-
|
|
136
|
+
- Build and watch for changes
|
|
137
|
+
```bash
|
|
138
|
+
npm run build -- -f -w
|
|
139
|
+
```
|
|
140
|
+
- Run the entire test suite on `chrome` (many tests are skipped on `node`)
|
|
141
|
+
```bash
|
|
142
|
+
npm test -- -a -c chrome
|
|
143
|
+
```
|
|
144
|
+
- Handle failing tests
|
|
145
|
+
- Fix logic
|
|
146
|
+
- If needed, alter tests with **caution**
|
|
147
|
+
- Rerun failing tests
|
|
148
|
+
- Save time by rerunning failing tests only
|
|
149
|
+
- Select failing test files
|
|
150
|
+
```bash
|
|
151
|
+
npm test -- -c chrome
|
|
152
|
+
```
|
|
153
|
+
- **OR** launch the browser test suite in _dev mode_ to watch for test changes
|
|
154
|
+
```bash
|
|
155
|
+
npm test -- -c chrome --dev -l
|
|
156
|
+
```
|
|
157
|
+
- In case of failing visual tests, there are 2 options to view visual diffs (in order to understand what is wrong)
|
|
158
|
+
- 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)
|
|
159
|
+
```bash
|
|
160
|
+
npm test -- -d -c chrome
|
|
161
|
+
```
|
|
162
|
+
- Launching the browser test suite
|
|
163
|
+
```bash
|
|
164
|
+
npm test -- -c chrome --dev -l
|
|
165
|
+
```
|
|
166
|
+
- Take into account that different environments produce different outputs so it is advised to run both in `chrome` and `node`.
|
|
167
|
+
- Committing refs is done **ONLY** with `chrome` output.
|
|
168
|
+
- When you are done, rerun the entire test suit to verify all tests pass.
|
|
169
|
+
- 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).
|
|
170
|
+
- Refer to the command docs
|
|
171
|
+
```bash
|
|
172
|
+
npm test -- -h
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## UI tests
|
|
176
|
+
|
|
177
|
+
Run UI tests with Playwright in parallel in Chrome (headed mode).
|
|
133
178
|
|
|
134
179
|
```bash
|
|
135
|
-
|
|
136
|
-
npm run build -- -f -w
|
|
137
|
-
|
|
180
|
+
$ npm run test:e2e
|
|
138
181
|
```
|
|
139
182
|
|
|
140
|
-
|
|
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)
|
|
183
|
+
### Adding Tests
|
|
149
184
|
|
|
150
|
-
|
|
185
|
+
Backing a PR with tests that cover the changes that were made is a **MUST**. Aim to cover 100% of the cases.
|
|
151
186
|
|
|
152
|
-
|
|
187
|
+
Add tests to relevant files or add new files when necessary under `test/unit` or `test/visual`.
|
|
153
188
|
|
|
154
|
-
|
|
189
|
+
- [`unit` test example][unit_test]
|
|
190
|
+
- [`visual` test example][visual_test]
|
|
155
191
|
|
|
156
|
-
|
|
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
|
-
```
|
|
192
|
+
If you need to change test config ask for guidance.
|
|
174
193
|
|
|
175
194
|
---
|
|
176
195
|
|
|
177
196
|
## 🚧🎢 Developing 💡✨
|
|
178
197
|
|
|
179
|
-
###
|
|
198
|
+
### Getting Started
|
|
180
199
|
|
|
181
|
-
1. 🍴 Fork the repository
|
|
182
|
-
1. 💾 Clone your 🍴 to your 💻
|
|
200
|
+
1. 🍴 Fork and clone 💾 the repository
|
|
183
201
|
1. Install dependencies 🕹️ `npm i --include=dev`
|
|
184
|
-
1. Next Up [Prototyping](#-prototyping) & [Testing](#-testing)
|
|
185
|
-
|
|
186
|
-
#### Online
|
|
187
|
-
|
|
188
|
-
[](https://gitpod.io/from-referrer/)
|
|
189
202
|
|
|
190
|
-
|
|
191
|
-
`A service is available on port ...` popups will show up.
|
|
192
|
-
|
|
193
|
-
### 🧭 Prototyping
|
|
194
|
-
|
|
195
|
-
[`.codesandbox/templates`](.codesandbox/templates) contains templates for **INSTANT** out-of-the-box prototyping **👍 Try it out**
|
|
203
|
+
### Starting an App
|
|
196
204
|
|
|
197
205
|
```bash
|
|
206
|
+
npm start <template>
|
|
207
|
+
npm start -- --help
|
|
208
|
+
```
|
|
198
209
|
|
|
199
|
-
|
|
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
|
|
210
|
+
You can deploy an app to codesandbox via the cli or build an app at a path of your choosing:
|
|
210
211
|
|
|
212
|
+
```bash
|
|
213
|
+
npm run sandbox deploy <path/to/app>
|
|
214
|
+
npm run sandbox build <template> <path/to/app>
|
|
211
215
|
npm run sandbox -- --help
|
|
216
|
+
```
|
|
212
217
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
> sandbox commands
|
|
218
|
+
Refer to [`.codesandbox/README.md`](.codesandbox/README.md) for more information.
|
|
216
219
|
|
|
217
|
-
|
|
218
|
-
-h, --help display help for command
|
|
220
|
+
### Online
|
|
219
221
|
|
|
220
|
-
|
|
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
|
|
222
|
+
You can actively develop fabric online using [Github Codespaces][github_codespaces], [Gitpod][gitpod] or CodeSandbox:
|
|
225
223
|
|
|
226
|
-
|
|
224
|
+
- After the Github Codespace has started run `npm start <template>` to start a prototyping app.
|
|
225
|
+
- Gitpod will start the prototyping apps and expose them as endpoints available on forwarded ports.
|
|
226
|
+
`A service is available on port ...` popups will show up.
|
|
227
|
+
- Codesandbox: _available soon_.
|
|
227
228
|
|
|
228
229
|
### 🔮 Symlinking
|
|
229
230
|
|
|
@@ -231,6 +232,7 @@ Establish symlinking to work with a local version on separate projects.
|
|
|
231
232
|
|
|
232
233
|
1. From `fabric.js` folder run `npm link` **OR** `yarn link`.
|
|
233
234
|
1. From the project's folder run `npm link fabric` **OR** `yarn link fabric`.
|
|
235
|
+
1. Consider flagging `--save` to avoid confusion regarding what version of fabric is being used by the project.
|
|
234
236
|
|
|
235
237
|
See [npm link][npm_link] **OR** [yarn link][yarn_link].\
|
|
236
238
|
Don't forget to unlink the package once you're done.
|
|
@@ -256,5 +258,9 @@ Don't forget to unlink the package once you're done.
|
|
|
256
258
|
[jsdoc]: https://jsdoc.app/
|
|
257
259
|
[qunit]: https://qunitjs.com/
|
|
258
260
|
[testem]: https://github.com/testem/testem
|
|
261
|
+
[unit_test]: https://github.com/fabricjs/fabric.js/blob/93dd2dcca705a4b481fbc9982da4952ef5b4ed1d/test/unit/point.js#L227-L237
|
|
262
|
+
[visual_test]: https://github.com/fabricjs/fabric.js/blob/93dd2dcca705a4b481fbc9982da4952ef5b4ed1d/test/visual/generic_rendering.js#L44-L67
|
|
263
|
+
[github_codespaces]: https://github.com/codespaces/new?hide_repo_select=true&ref=master&repo=712530
|
|
264
|
+
[gitpod]: https://gitpod.io/from-referrer/
|
|
259
265
|
[npm_link]: https://docs.npmjs.com/cli/v8/commands/npm-link
|
|
260
266
|
[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
|
-
##
|
|
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
|
-
|
|
72
|
-
// es6 imports
|
|
73
|
-
import { fabric } from 'fabric';
|
|
74
|
+
## Installation
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
146
|
-
|
|
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
|