fabric 6.0.0-beta13 → 6.0.0-beta15

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 (108) hide show
  1. package/.eslintrc.js +9 -0
  2. package/CHANGELOG.md +35 -1
  3. package/CONTRIBUTING.md +9 -9
  4. package/dist/fabric.d.ts +36 -3
  5. package/dist/index.js +218 -324
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.min.js +1 -1
  8. package/dist/index.mjs +214 -323
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/index.node.cjs +218 -324
  11. package/dist/index.node.cjs.map +1 -1
  12. package/dist/index.node.mjs +214 -323
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/src/Intersection.d.ts +8 -0
  15. package/dist/src/canvas/Canvas.d.ts +1 -1
  16. package/dist/src/canvas/CanvasOptions.d.ts +1 -1
  17. package/dist/src/canvas/DOMManagers/CanvasDOMManager.d.ts +1 -1
  18. package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.d.ts +2 -2
  19. package/dist/src/canvas/SelectableCanvas.d.ts +10 -15
  20. package/dist/src/canvas/StaticCanvas.d.ts +2 -2
  21. package/dist/src/controls/Control.d.ts +8 -8
  22. package/dist/src/controls/index.d.ts +1 -1
  23. package/dist/src/controls/polyControl.d.ts +25 -0
  24. package/dist/src/filters/BlendImage.d.ts +4 -4
  25. package/dist/src/shapes/Group.d.ts +5 -1
  26. package/dist/src/shapes/IText/ITextBehavior.d.ts +2 -2
  27. package/dist/src/shapes/Image.d.ts +11 -11
  28. package/dist/src/shapes/Object/InteractiveObject.d.ts +2 -3
  29. package/dist/src/shapes/Object/Object.d.ts +4 -4
  30. package/dist/src/shapes/Object/ObjectGeometry.d.ts +3 -29
  31. package/dist/src/shapes/Object/types/FabricObjectProps.d.ts +1 -1
  32. package/dist/src/shapes/Path.d.ts +1 -1
  33. package/dist/src/shapes/Text/StyledText.d.ts +2 -2
  34. package/dist/src/shapes/Text/Text.d.ts +7 -7
  35. package/dist/src/shapes/Text/TextSVGExportMixin.d.ts +7 -7
  36. package/dist/src/shapes/Text/constants.d.ts +2 -2
  37. package/dist/src/util/animation/AnimationRegistry.d.ts +4 -4
  38. package/dist/src/util/internals/console.d.ts +8 -0
  39. package/dist/src/util/misc/dom.d.ts +1 -1
  40. package/dist/src/util/misc/svgParsing.d.ts +2 -1
  41. package/dist/src/util/typeAssertions.d.ts +2 -2
  42. package/fabric.ts +45 -3
  43. package/jest.extend.ts +3 -1
  44. package/package.json +5 -6
  45. package/playwright.setup.ts +82 -14
  46. package/src/ClassRegistry.ts +3 -1
  47. package/src/Collection.ts +2 -3
  48. package/src/Intersection.spec.ts +74 -0
  49. package/src/Intersection.ts +30 -0
  50. package/src/Pattern/Pattern.ts +2 -1
  51. package/src/benchmarks/README.md +7 -0
  52. package/src/benchmarks/calcCornerCoords.mjs +117 -0
  53. package/src/benchmarks/raycasting.mjs +154 -0
  54. package/src/canvas/Canvas.ts +23 -11
  55. package/src/canvas/CanvasOptions.ts +1 -1
  56. package/src/canvas/DOMManagers/CanvasDOMManager.ts +1 -1
  57. package/src/canvas/DOMManagers/StaticCanvasDOMManager.ts +7 -7
  58. package/src/canvas/SelectableCanvas.ts +30 -43
  59. package/src/canvas/StaticCanvas.ts +9 -7
  60. package/src/canvas/__tests__/SelectableCanvas.spec.ts +60 -0
  61. package/src/canvas/__tests__/__snapshots__/eventData.test.ts.snap +193 -2
  62. package/src/canvas/__tests__/eventData.test.ts +40 -1
  63. package/src/controls/Control.spec.ts +41 -0
  64. package/src/controls/Control.ts +36 -44
  65. package/src/controls/index.ts +1 -1
  66. package/src/controls/polyControl.ts +8 -5
  67. package/src/filters/BaseFilter.ts +8 -6
  68. package/src/filters/BlendImage.ts +4 -4
  69. package/src/filters/GLProbes/WebGLProbe.ts +2 -1
  70. package/src/parser/elements_parser.ts +2 -2
  71. package/src/parser/loadSVGFromString.test.ts +36 -0
  72. package/src/parser/parseSVGDocument.ts +2 -1
  73. package/src/parser/parseUseDirectives.ts +6 -2
  74. package/src/parser/recursivelyParseGradientsXlink.ts +1 -3
  75. package/src/shapes/ActiveSelection.spec.ts +35 -1
  76. package/src/shapes/ActiveSelection.ts +3 -1
  77. package/src/shapes/Group.ts +7 -8
  78. package/src/shapes/IText/IText.test.ts +43 -0
  79. package/src/shapes/IText/IText.ts +1 -1
  80. package/src/shapes/IText/ITextBehavior.ts +2 -2
  81. package/src/shapes/IText/__snapshots__/IText.test.ts.snap +50 -0
  82. package/src/shapes/Image.ts +15 -14
  83. package/src/shapes/Object/FabricObject.spec.ts +16 -0
  84. package/src/shapes/Object/InteractiveObject.spec.ts +43 -0
  85. package/src/shapes/Object/InteractiveObject.ts +20 -30
  86. package/src/shapes/Object/Object.ts +6 -5
  87. package/src/shapes/Object/ObjectGeometry.ts +11 -126
  88. package/src/shapes/Object/types/FabricObjectProps.ts +1 -1
  89. package/src/shapes/Text/StyledText.ts +5 -2
  90. package/src/shapes/Text/Text.spec.ts +9 -9
  91. package/src/shapes/Text/Text.ts +16 -15
  92. package/src/shapes/Text/TextSVGExportMixin.spec.ts +29 -0
  93. package/src/shapes/Text/TextSVGExportMixin.ts +16 -13
  94. package/src/shapes/Text/__snapshots__/Text.spec.ts.snap +6 -6
  95. package/src/shapes/Text/constants.ts +2 -2
  96. package/src/util/animation/AnimationRegistry.ts +7 -6
  97. package/src/util/internals/console.ts +18 -0
  98. package/src/util/internals/dom_request.ts +2 -1
  99. package/src/util/misc/dom.ts +3 -2
  100. package/src/util/misc/objectEnlive.ts +3 -2
  101. package/src/util/misc/planeChange.ts +3 -2
  102. package/src/util/misc/svgParsing.ts +22 -9
  103. package/src/util/transform_matrix_removal.ts +3 -3
  104. package/src/util/typeAssertions.ts +2 -2
  105. package/typedoc.config.json +6 -0
  106. package/typedoc.json +3 -2
  107. package/dist/src/parser/elementById.d.ts +0 -7
  108. package/src/parser/elementById.ts +0 -18
package/.eslintrc.js CHANGED
@@ -36,6 +36,7 @@ module.exports = {
36
36
  ],
37
37
  'no-restricted-syntax': [
38
38
  'error',
39
+ // explore how to define the selector: https://astexplorer.net/
39
40
  {
40
41
  selector: '[callee.object.name="Math"][callee.property.name="hypot"]',
41
42
  message:
@@ -46,6 +47,14 @@ module.exports = {
46
47
  message:
47
48
  'Aliasing or destructing `Math` is not allowed due to restrictions on `Math.hypot` usage.',
48
49
  },
50
+ {
51
+ selector: '[callee.object.name="console"]',
52
+ message: 'Use the `log` util',
53
+ },
54
+ {
55
+ selector: 'NewExpression[callee.name="Error"]',
56
+ message: 'Use `FabricError`',
57
+ },
49
58
  ],
50
59
  },
51
60
  };
package/CHANGELOG.md CHANGED
@@ -2,7 +2,41 @@
2
2
 
3
3
  ## [next]
4
4
 
5
- ## [6.0.0-b3]
5
+ ## [6.0.0-beta14]
6
+
7
+ - Fix(SVGParser) ignore missing xlink target issue on svg parsing (#9427) [#9109](https://github.com/fabricjs/fabric.js/issues/9109)
8
+ - fix(#9172): dep export `Object`, `Text`, `Image` [#9433](https://github.com/fabricjs/fabric.js/pull/9433)
9
+
10
+ ## [6.0.0-beta14]
11
+
12
+ - fix(Object): fixes centeredScaling prop type [#9401](https://github.com/fabricjs/fabric.js/pull/9401)
13
+ - CI(): fix build caching + tests when merging to master [#9404](https://github.com/fabricjs/fabric.js/pull/9404)
14
+ - chore(): export poly control utils [#9400](https://github.com/fabricjs/fabric.js/pull/9400)
15
+ - fix(Canvas): in/out event names were swapped [#9396](https://github.com/fabricjs/fabric.js/pull/9396)
16
+ - fix(Canvas): `setActiveObject` should update `canvas#_activeSelection` [#9336](https://github.com/fabricjs/fabric.js/pull/9336)
17
+ - patch(Coords): calc oCoords only with canvas ref [#9380](https://github.com/fabricjs/fabric.js/pull/9380)
18
+ - patch(Control): pass object to `calcCornerCoords` [#9376](https://github.com/fabricjs/fabric.js/pull/9376)
19
+ - fix(Canvas): invalidate `_objectsToRender` on stack change [#9387](https://github.com/fabricjs/fabric.js/pull/9387)
20
+ - ci(e2e): fix babel compiling error [#9388](https://github.com/fabricjs/fabric.js/pull/9388)
21
+ - Breaking: Remove node 14 [#9383](https://github.com/fabricjs/fabric.js/pull/9383)
22
+ - chore(): Rename exports that conflicts with JS/WEB api ( Object, Text, Image ). Kept backward compatibility with deprecation notice [#9172](https://github.com/fabricjs/fabric.js/pull/9172)
23
+ - fix(Geometry): `containsPoint` [#9372](https://github.com/fabricjs/fabric.js/pull/9372)
24
+ **BREAKING**:
25
+ - `Canvas#_checkTarget(point, object, pointFromViewport)` => `Canvas#_checkTarget(object, pointFromViewport)`
26
+ - fix(Canvas): avoid firing event twice when working with nested objects [#9329](https://github.com/fabricjs/fabric.js/pull/9329)
27
+ - fix(Control): `calcCornerCoords` angle + calculation [#9377](https://github.com/fabricjs/fabric.js/pull/9377)
28
+ - patch(): dep findCrossPoints in favor of `isPointInPolygon` [#9374](https://github.com/fabricjs/fabric.js/pull/9374)
29
+ - docs() enable typedocs to run again [#9356](https://github.com/fabricjs/fabric.js/pull/9356)
30
+ - chore(): cleanup logs and error messages [#9369](https://github.com/fabricjs/fabric.js/pull/9369)
31
+ - feature(Object) BREAKING: Remove lines parameter from object.containsPoint [#9375](https://github.com/fabricjs/fabric.js/pull/9375)
32
+ - patch(Control): move hit detection to shouldActivate [#9374](https://github.com/fabricjs/fabric.js/pull/9374)
33
+ - fix(Control): method binding for mouseUpHandler, mouseDownHandler, and actionHandler [#9370](https://github.com/fabricjs/fabric.js/pull/9370)
34
+ - fix(StaticCanvas): disposing animations [#9361](https://github.com/fabricjs/fabric.js/pull/9361)
35
+ - fix(IText): cursor width under group [#9341](https://github.com/fabricjs/fabric.js/pull/9341)
36
+ - TS(Canvas): constructor optional el [#9348](https://github.com/fabricjs/fabric.js/pull/9348)
37
+ - fix(Utils): fix exported svg color [#9408](https://github.com/fabricjs/fabric.js/pull/9408)
38
+
39
+ ## [6.0.0-beta13]
6
40
 
7
41
  - fix(Textbox): implemente a fix for the style shifting issues on new lines [#9197](https://github.com/fabricjs/fabric.js/pull/9197)
8
42
  - Fix(Control) fix a regression in `wrap with fixed anchor`, regression from #8400 [#9326](https://github.com/fabricjs/fabric.js/pull/9326)
package/CONTRIBUTING.md CHANGED
@@ -129,15 +129,15 @@ It is more than likely you will be requested to change stuff and refine your wor
129
129
  [![🧪](../../actions/workflows/tests.yml/badge.svg)](../../actions/workflows/tests.yml)
130
130
  [![CodeQL](../../actions/workflows/codeql-analysis.yml/badge.svg)](../../actions/workflows/codeql-analysis.yml)
131
131
 
132
- | Suite | unit (node) | e2e (browser) |
133
- | ---------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
134
- | Framework | [`jest`][jest] | [`playwright`][playwright] |
135
- | Setup | | <pre>npm run build -- -f -w</pre> |
136
- | 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). |
137
- | Writing Tests | Add/update `src/*.(spec\|test).ts` files | - Update tests in `e2e/tests`<br>- Create a new test based on `e2e/template` |
138
- | Test Gen | | <pre>npm start vanilla<br>npx playwright codegen http://localhost:1234</pre> |
139
- | Test Spec | | - `index.ts`: built and loaded into the web app<br> - `index.spec.ts`: test spec<br> |
140
- | Outputs | Snapshots next to the test file | - Snapshots next to the test file <br>- `e2e/test-report`<br>- `e2e/test-results` |
132
+ | Suite | unit (node) | e2e (browser) |
133
+ | ------------------------------------------------------------------------------------------------------------- | :--------------------------------------------- | :----------------------------------------------------------------------------------- |
134
+ | Framework | [`jest`][jest] | [`playwright`][playwright] |
135
+ | Setup | | <pre>npm run build -- -f -w</pre> |
136
+ | Running Tests<br><br><pre>\<test cmd\> -- [filter] [watch]</pre><br>It is advised to use filters to save time | <pre>npm run test:jest -- [filters] [-w]</pre> | <pre>npm run test:e2e -- [filters] [--ui]</pre> |
137
+ | Writing Tests | Add/update `src/*.(spec\|test).ts` files | - Update tests in `e2e/tests`<br>- Create a new test based on `e2e/template` |
138
+ | Test Gen | | <pre>npm start vanilla<br>npx playwright codegen http://localhost:1234</pre> |
139
+ | Test Spec | | - `index.ts`: built and loaded into the web app<br> - `index.spec.ts`: test spec<br> |
140
+ | Outputs | Snapshots next to the test file | - Snapshots next to the test file <br>- `e2e/test-report`<br>- `e2e/test-results` |
141
141
 
142
142
  ### Legacy Test Suite
143
143
 
package/dist/fabric.d.ts CHANGED
@@ -30,7 +30,18 @@ export { PencilBrush } from './src/brushes/PencilBrush';
30
30
  export { CircleBrush } from './src/brushes/CircleBrush';
31
31
  export { SprayBrush } from './src/brushes/SprayBrush';
32
32
  export { PatternBrush } from './src/brushes/PatternBrush';
33
- export { FabricObject as Object } from './src/shapes/Object/FabricObject';
33
+ export { FabricObject,
34
+ /**
35
+ * @deprecated Due to a naming conflict with the
36
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object JS API},
37
+ * `fabric.Object` has been renamed to `FabricObject`
38
+ *
39
+ * @example
40
+ * import { Object } from 'fabric'; // deprecated
41
+ * import { FabricObject } from 'fabric'; // migration path
42
+ *
43
+ */
44
+ FabricObject as Object, } from './src/shapes/Object/FabricObject';
34
45
  export type { TFabricObjectProps, FabricObjectProps, SerializedObjectProps, } from './src/shapes/Object/types';
35
46
  export type { SerializedLineProps } from './src/shapes/Line';
36
47
  export { Line } from './src/shapes/Line';
@@ -47,7 +58,18 @@ export type { SerializedPolylineProps } from './src/shapes/Polyline';
47
58
  export { Polyline } from './src/shapes/Polyline';
48
59
  export { Polygon } from './src/shapes/Polygon';
49
60
  export type { GraphemeBBox, SerializedTextProps, TPathAlign, TPathSide, TextProps, } from './src/shapes/Text/Text';
50
- export { Text } from './src/shapes/Text/Text';
61
+ export { FabricText,
62
+ /**
63
+ * @deprecated Due to a naming conflict with the
64
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Text/Text Web API},
65
+ * `fabric.Text` has been renamed to `FabricText`
66
+ *
67
+ * @example
68
+ * import { Text } from 'fabric'; // deprecated
69
+ * import { FabricText } from 'fabric'; // migration path
70
+ *
71
+ */
72
+ FabricText as Text, } from './src/shapes/Text/Text';
51
73
  export type { ITextProps, SerializedITextProps, } from './src/shapes/IText/IText';
52
74
  export { IText } from './src/shapes/IText/IText';
53
75
  export type { GraphemeData, SerializedTextboxProps, TextboxProps, } from './src/shapes/Textbox';
@@ -57,7 +79,18 @@ export type { GroupEvents, GroupProps, LayoutContext, GroupOwnProps, LayoutConte
57
79
  export { Group } from './src/shapes/Group';
58
80
  export type { ActiveSelectionOptions, MultiSelectionStacking, } from './src/shapes/ActiveSelection';
59
81
  export { ActiveSelection } from './src/shapes/ActiveSelection';
60
- export { Image } from './src/shapes/Image';
82
+ export { FabricImage,
83
+ /**
84
+ * @deprecated Due to a naming conflict with the
85
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image Web API},
86
+ * `fabric.Image` has been renamed to `FabricImage`
87
+ *
88
+ * @example
89
+ * import { Image } from 'fabric'; // deprecated
90
+ * import { FabricImage } from 'fabric'; // migration path
91
+ *
92
+ */
93
+ FabricImage as Image, } from './src/shapes/Image';
61
94
  export type { ImageSource, SerializedImageProps, ImageProps, } from './src/shapes/Image';
62
95
  export { createCollectionMixin } from './src/Collection';
63
96
  export * as util from './src/util';