fabric 6.0.0-beta19 → 6.0.0-beta20

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 (193) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/index.js +86 -38
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/dist/index.min.mjs +1 -1
  7. package/dist/index.min.mjs.map +1 -1
  8. package/dist/index.mjs +86 -38
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/index.node.cjs +86 -38
  11. package/dist/index.node.cjs.map +1 -1
  12. package/dist/index.node.mjs +86 -38
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/package.json.min.mjs +1 -1
  15. package/dist/package.json.mjs +1 -1
  16. package/dist/src/LayoutManager/LayoutManager.d.ts.map +1 -1
  17. package/dist/src/LayoutManager/LayoutManager.min.mjs.map +1 -1
  18. package/dist/src/LayoutManager/LayoutManager.mjs +3 -0
  19. package/dist/src/LayoutManager/LayoutManager.mjs.map +1 -1
  20. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.d.ts.map +1 -1
  21. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.min.mjs +1 -1
  22. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.min.mjs.map +1 -1
  23. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.mjs +3 -7
  24. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.mjs.map +1 -1
  25. package/dist/src/Pattern/Pattern.d.ts.map +1 -1
  26. package/dist/src/Pattern/Pattern.min.mjs.map +1 -1
  27. package/dist/src/Pattern/Pattern.mjs.map +1 -1
  28. package/dist/src/Shadow.d.ts +1 -1
  29. package/dist/src/Shadow.d.ts.map +1 -1
  30. package/dist/src/Shadow.min.mjs +1 -1
  31. package/dist/src/Shadow.min.mjs.map +1 -1
  32. package/dist/src/Shadow.mjs +1 -1
  33. package/dist/src/Shadow.mjs.map +1 -1
  34. package/dist/src/canvas/Canvas.d.ts +1 -1
  35. package/dist/src/canvas/Canvas.d.ts.map +1 -1
  36. package/dist/src/canvas/Canvas.min.mjs +1 -1
  37. package/dist/src/canvas/Canvas.min.mjs.map +1 -1
  38. package/dist/src/canvas/Canvas.mjs +2 -2
  39. package/dist/src/canvas/Canvas.mjs.map +1 -1
  40. package/dist/src/canvas/SelectableCanvas.d.ts +1 -1
  41. package/dist/src/canvas/SelectableCanvas.d.ts.map +1 -1
  42. package/dist/src/canvas/SelectableCanvas.min.mjs.map +1 -1
  43. package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
  44. package/dist/src/canvas/StaticCanvas.min.mjs +1 -1
  45. package/dist/src/canvas/StaticCanvas.min.mjs.map +1 -1
  46. package/dist/src/canvas/StaticCanvas.mjs +1 -1
  47. package/dist/src/canvas/StaticCanvas.mjs.map +1 -1
  48. package/dist/src/filters/WebGLFilterBackend.min.mjs.map +1 -1
  49. package/dist/src/filters/WebGLFilterBackend.mjs.map +1 -1
  50. package/dist/src/parser/elements_parser.d.ts.map +1 -1
  51. package/dist/src/parser/elements_parser.min.mjs +1 -1
  52. package/dist/src/parser/elements_parser.min.mjs.map +1 -1
  53. package/dist/src/parser/elements_parser.mjs +14 -2
  54. package/dist/src/parser/elements_parser.mjs.map +1 -1
  55. package/dist/src/parser/getCSSRules.d.ts.map +1 -1
  56. package/dist/src/parser/getCSSRules.min.mjs +1 -1
  57. package/dist/src/parser/getCSSRules.min.mjs.map +1 -1
  58. package/dist/src/parser/getCSSRules.mjs +6 -0
  59. package/dist/src/parser/getCSSRules.mjs.map +1 -1
  60. package/dist/src/parser/getTagName.d.ts +2 -0
  61. package/dist/src/parser/getTagName.d.ts.map +1 -0
  62. package/dist/src/parser/getTagName.min.mjs +2 -0
  63. package/dist/src/parser/getTagName.min.mjs.map +1 -0
  64. package/dist/src/parser/getTagName.mjs +4 -0
  65. package/dist/src/parser/getTagName.mjs.map +1 -0
  66. package/dist/src/parser/hasInvalidAncestor.d.ts.map +1 -1
  67. package/dist/src/parser/hasInvalidAncestor.min.mjs +1 -1
  68. package/dist/src/parser/hasInvalidAncestor.min.mjs.map +1 -1
  69. package/dist/src/parser/hasInvalidAncestor.mjs +2 -1
  70. package/dist/src/parser/hasInvalidAncestor.mjs.map +1 -1
  71. package/dist/src/parser/parseSVGDocument.d.ts.map +1 -1
  72. package/dist/src/parser/parseSVGDocument.min.mjs +1 -1
  73. package/dist/src/parser/parseSVGDocument.min.mjs.map +1 -1
  74. package/dist/src/parser/parseSVGDocument.mjs +4 -2
  75. package/dist/src/parser/parseSVGDocument.mjs.map +1 -1
  76. package/dist/src/shapes/ActiveSelection.d.ts +7 -4
  77. package/dist/src/shapes/ActiveSelection.d.ts.map +1 -1
  78. package/dist/src/shapes/ActiveSelection.min.mjs +1 -1
  79. package/dist/src/shapes/ActiveSelection.min.mjs.map +1 -1
  80. package/dist/src/shapes/ActiveSelection.mjs +18 -3
  81. package/dist/src/shapes/ActiveSelection.mjs.map +1 -1
  82. package/dist/src/shapes/Circle.d.ts +14 -8
  83. package/dist/src/shapes/Circle.d.ts.map +1 -1
  84. package/dist/src/shapes/Circle.min.mjs +1 -1
  85. package/dist/src/shapes/Circle.min.mjs.map +1 -1
  86. package/dist/src/shapes/Circle.mjs +7 -5
  87. package/dist/src/shapes/Circle.mjs.map +1 -1
  88. package/dist/src/shapes/Ellipse.d.ts +3 -5
  89. package/dist/src/shapes/Ellipse.d.ts.map +1 -1
  90. package/dist/src/shapes/Ellipse.min.mjs.map +1 -1
  91. package/dist/src/shapes/Ellipse.mjs.map +1 -1
  92. package/dist/src/shapes/Group.d.ts +2 -6
  93. package/dist/src/shapes/Group.d.ts.map +1 -1
  94. package/dist/src/shapes/Group.min.mjs.map +1 -1
  95. package/dist/src/shapes/Group.mjs.map +1 -1
  96. package/dist/src/shapes/IText/IText.d.ts +6 -27
  97. package/dist/src/shapes/IText/IText.d.ts.map +1 -1
  98. package/dist/src/shapes/IText/IText.min.mjs +1 -1
  99. package/dist/src/shapes/IText/IText.min.mjs.map +1 -1
  100. package/dist/src/shapes/IText/IText.mjs +9 -6
  101. package/dist/src/shapes/IText/IText.mjs.map +1 -1
  102. package/dist/src/shapes/Image.d.ts +3 -5
  103. package/dist/src/shapes/Image.d.ts.map +1 -1
  104. package/dist/src/shapes/Image.min.mjs +1 -1
  105. package/dist/src/shapes/Image.min.mjs.map +1 -1
  106. package/dist/src/shapes/Image.mjs +3 -2
  107. package/dist/src/shapes/Image.mjs.map +1 -1
  108. package/dist/src/shapes/Object/InteractiveObject.d.ts +1 -1
  109. package/dist/src/shapes/Object/InteractiveObject.d.ts.map +1 -1
  110. package/dist/src/shapes/Object/InteractiveObject.min.mjs +1 -1
  111. package/dist/src/shapes/Object/InteractiveObject.min.mjs.map +1 -1
  112. package/dist/src/shapes/Object/InteractiveObject.mjs +6 -1
  113. package/dist/src/shapes/Object/InteractiveObject.mjs.map +1 -1
  114. package/dist/src/shapes/Object/Object.d.ts +36 -8
  115. package/dist/src/shapes/Object/Object.d.ts.map +1 -1
  116. package/dist/src/shapes/Object/Object.min.mjs.map +1 -1
  117. package/dist/src/shapes/Object/Object.mjs +3 -3
  118. package/dist/src/shapes/Object/Object.mjs.map +1 -1
  119. package/dist/src/shapes/Object/defaultValues.d.ts +5 -73
  120. package/dist/src/shapes/Object/defaultValues.d.ts.map +1 -1
  121. package/dist/src/shapes/Object/defaultValues.min.mjs.map +1 -1
  122. package/dist/src/shapes/Object/defaultValues.mjs.map +1 -1
  123. package/dist/src/shapes/Polygon.d.ts +2 -4
  124. package/dist/src/shapes/Polygon.d.ts.map +1 -1
  125. package/dist/src/shapes/Polygon.min.mjs.map +1 -1
  126. package/dist/src/shapes/Polygon.mjs.map +1 -1
  127. package/dist/src/shapes/Polyline.d.ts +2 -4
  128. package/dist/src/shapes/Polyline.d.ts.map +1 -1
  129. package/dist/src/shapes/Polyline.min.mjs.map +1 -1
  130. package/dist/src/shapes/Polyline.mjs.map +1 -1
  131. package/dist/src/shapes/Rect.d.ts +1 -1
  132. package/dist/src/shapes/Rect.d.ts.map +1 -1
  133. package/dist/src/shapes/Rect.min.mjs.map +1 -1
  134. package/dist/src/shapes/Rect.mjs.map +1 -1
  135. package/dist/src/shapes/Text/Text.d.ts +2 -4
  136. package/dist/src/shapes/Text/Text.d.ts.map +1 -1
  137. package/dist/src/shapes/Text/Text.min.mjs +1 -1
  138. package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
  139. package/dist/src/shapes/Text/Text.mjs +3 -1
  140. package/dist/src/shapes/Text/Text.mjs.map +1 -1
  141. package/dist/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
  142. package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs.map +1 -1
  143. package/dist/src/shapes/Text/TextSVGExportMixin.mjs +2 -1
  144. package/dist/src/shapes/Text/TextSVGExportMixin.mjs.map +1 -1
  145. package/dist/src/shapes/Textbox.d.ts +2 -14
  146. package/dist/src/shapes/Textbox.d.ts.map +1 -1
  147. package/dist/src/shapes/Textbox.min.mjs.map +1 -1
  148. package/dist/src/shapes/Textbox.mjs +2 -1
  149. package/dist/src/shapes/Textbox.mjs.map +1 -1
  150. package/dist/src/shapes/Triangle.d.ts +4 -9
  151. package/dist/src/shapes/Triangle.d.ts.map +1 -1
  152. package/dist/src/shapes/Triangle.min.mjs.map +1 -1
  153. package/dist/src/shapes/Triangle.mjs.map +1 -1
  154. package/package.json +1 -3
  155. package/src/LayoutManager/LayoutManager.spec.ts +2 -2
  156. package/src/LayoutManager/LayoutManager.ts +3 -0
  157. package/src/LayoutManager/LayoutStrategies/LayoutStrategy.ts +3 -12
  158. package/src/LayoutManager/README.md +41 -0
  159. package/src/Pattern/Pattern.ts +12 -4
  160. package/src/Shadow.spec.ts +15 -0
  161. package/src/Shadow.ts +1 -1
  162. package/src/__snapshots__/Shadow.spec.ts.snap +27 -0
  163. package/src/canvas/Canvas.ts +3 -3
  164. package/src/canvas/SelectableCanvas.ts +1 -1
  165. package/src/canvas/StaticCanvas.ts +3 -3
  166. package/src/filters/WebGLFilterBackend.ts +2 -2
  167. package/src/parser/elements_parser.ts +23 -3
  168. package/src/parser/getCSSRules.spec.ts +24 -6
  169. package/src/parser/getCSSRules.ts +10 -0
  170. package/src/parser/getTagName.ts +1 -0
  171. package/src/parser/hasInvalidAncestor.ts +2 -1
  172. package/src/parser/parseSVGDocument.ts +4 -2
  173. package/src/shapes/ActiveSelection.spec.ts +22 -0
  174. package/src/shapes/ActiveSelection.ts +29 -4
  175. package/src/shapes/Circle.ts +26 -17
  176. package/src/shapes/Ellipse.ts +3 -3
  177. package/src/shapes/Group.ts +1 -1
  178. package/src/shapes/IText/IText.ts +14 -8
  179. package/src/shapes/Image.spec.ts +27 -0
  180. package/src/shapes/Image.ts +6 -6
  181. package/src/shapes/Object/InteractiveObject.ts +7 -2
  182. package/src/shapes/Object/Object.ts +36 -7
  183. package/src/shapes/Object/defaultValues.ts +9 -2
  184. package/src/shapes/Polygon.ts +2 -2
  185. package/src/shapes/Polyline.ts +2 -2
  186. package/src/shapes/Rect.ts +1 -1
  187. package/src/shapes/Text/Text.ts +5 -3
  188. package/src/shapes/Text/TextSVGExportMixin.ts +2 -1
  189. package/src/shapes/Textbox.ts +4 -3
  190. package/src/shapes/Triangle.ts +4 -4
  191. package/src/shapes/__snapshots__/Image.spec.ts.snap +22 -0
  192. package/typedoc.config.json +1 -2
  193. package/typedoc.json +0 -12
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  ## [next]
4
4
 
5
+ ## [6.0.0-beta20]
6
+
7
+ - chore(TS): minor changes to typescript notation to be compatible with a 5.3.3 [#9725](https://github.com/fabricjs/fabric.js/pull/9725)
8
+ - fix(InteractiveObject): "borderOpacityWhenMoving" does not take effect on the child shapes within the group [#9374](https://github.com/fabricjs/fabric.js/issues/9734)
9
+ - fix(SVGParser): Consider the transformMatrix of the clipPath owner as part of the clipPath trasnformation [#9750](https://github.com/fabricjs/fabric.js/pull/9750)
10
+ - fix(StaticCanvas): setDimensions not requesting a render if options are not passed [#9710](https://github.com/fabricjs/fabric.js/pull/9710)
11
+ - fix(LayoutManager): wrong bounding box position when activeSelection has originX/originY that are not default left/top [#9649](https://github.com/fabricjs/fabric.js/pull/9649)
12
+ - fix(ActiveSelection): block ancestors/descendants of selected objects from being selected [#9732](https://github.com/fabricjs/fabric.js/pull/9732)
13
+ - fix(Image): typo in style property for svg export [#9717](https://github.com/fabricjs/fabric.js/pull/9717)
14
+ - ci(): Update the changelog and stats action to work from forks
15
+ - fix(Shadow): Cloning a shape with shadow throws an error[#9711](https://github.com/fabricjs/fabric.js/issues/9711)
16
+ - chore(TS): use consistent and improved types for getDefaults and ownDefaults [#9698](https://github.com/fabricjs/fabric.js/pull/9698)
17
+ - fix(SVGParser): Don't crash on nested CSS at-rules [#9707](https://github.com/fabricjs/fabric.js/pull/9707)
18
+ - perf(): measuring canvas size [#9697](https://github.com/fabricjs/fabric.js/pull/9697)
19
+ - chore(TS): Add type for options in toCanvasElement and toDataUrl [#9673](https://github.com/fabricjs/fabric.js/pull/9673)
20
+ - ci(): add source map support to node sandbox [#9686](https://github.com/fabricjs/fabric.js/pull/9686)
21
+ - fix(Canvas): Correct type mainTouchId initialization [#9684](https://github.com/fabricjs/fabric.js/pull/9684)
22
+ - feat(Circle): Add counterclockwise parameter to Circle class [#9670](https://github.com/fabricjs/fabric.js/pull/9670)
23
+
5
24
  ## [6.0.0-beta19]
6
25
 
7
26
  - feat(LayoutManager): Expose objects registration [#9661](https://github.com/fabricjs/fabric.js/pull/9661)
package/dist/index.js CHANGED
@@ -423,7 +423,7 @@
423
423
  }
424
424
  const cache = new Cache();
425
425
 
426
- var version = "6.0.0-beta19";
426
+ var version = "6.0.0-beta20";
427
427
 
428
428
  // use this syntax so babel plugin see this import here
429
429
  const VERSION = version;
@@ -3252,7 +3252,7 @@
3252
3252
 
3253
3253
  setDimensions(dimensions, options) {
3254
3254
  this._setDimensionsImpl(dimensions, options);
3255
- if (options && !options.cssOnly) {
3255
+ if (!options || !options.cssOnly) {
3256
3256
  this.requestRenderAll();
3257
3257
  }
3258
3258
  }
@@ -6777,7 +6777,7 @@
6777
6777
  const defaults = Shadow.ownDefaults;
6778
6778
  return !this.includeDefaultValues ? pickBy(data, (value, key) => value !== defaults[key]) : data;
6779
6779
  }
6780
- static fromObject(options) {
6780
+ static async fromObject(options) {
6781
6781
  return new this(options);
6782
6782
  }
6783
6783
  }
@@ -7874,7 +7874,7 @@
7874
7874
  * If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it.
7875
7875
  * toCanvasElement and then toBlob from the obtained canvas is also a good option.
7876
7876
  * @todo fix the export type, it could not be Image but the type that getClass return for 'image'.
7877
- * @param {Object} [options] for clone as image, passed to toDataURL
7877
+ * @param {ObjectToCanvasElementOptions} [options] for clone as image, passed to toDataURL
7878
7878
  * @param {Number} [options.multiplier=1] Multiplier to scale by
7879
7879
  * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14
7880
7880
  * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14
@@ -7894,7 +7894,7 @@
7894
7894
 
7895
7895
  /**
7896
7896
  * Converts an object into a HTMLCanvas element
7897
- * @param {Object} options Options object
7897
+ * @param {ObjectToCanvasElementOptions} options Options object
7898
7898
  * @param {Number} [options.multiplier=1] Multiplier to scale by
7899
7899
  * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14
7900
7900
  * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14
@@ -7904,7 +7904,7 @@
7904
7904
  * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4
7905
7905
  * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2
7906
7906
  * @param {Boolean} [options.viewportTransform] Account for canvas viewport transform
7907
- * @param {(el: HTMLCanvasElement) => Canvas} [options.canvasProvider] Create the output canvas
7907
+ * @param {(el?: HTMLCanvasElement) => StaticCanvas} [options.canvasProvider] Create the output canvas
7908
7908
  * @return {HTMLCanvasElement} Returns DOM element <canvas> with the FabricObject
7909
7909
  */
7910
7910
  toCanvasElement() {
@@ -9392,7 +9392,12 @@
9392
9392
  ctx.save();
9393
9393
  ctx.translate(options.translateX, options.translateY);
9394
9394
  ctx.lineWidth = 1 * this.borderScaleFactor;
9395
- if (!this.group) {
9395
+ // since interactive groups have been introduced, an object could be inside a group and needing controls
9396
+ // the following equality check `this.group === this.parent` covers:
9397
+ // object without a group ( undefined === undefined )
9398
+ // object inside a group
9399
+ // excludes object inside a group but multi selected since group and parent will differ in value
9400
+ if (this.group === this.parent) {
9396
9401
  ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;
9397
9402
  }
9398
9403
  if (this.flipX) {
@@ -10939,14 +10944,11 @@
10939
10944
  size: bboxSize,
10940
10945
  center: bboxCenter
10941
10946
  });
10942
- const originFactor = new Point(-resolveOrigin(target.originX), -resolveOrigin(target.originY));
10943
- const sizeCorrection = actualSize.subtract(bboxSize).multiply(originFactor);
10944
- // translate the layout origin from left top to target's origin
10945
- const center = bboxLeftTop.add(bboxSize.multiply(originFactor));
10946
10947
  return {
10947
10948
  // in `initialization` we do not account for target's transformation matrix
10948
- center: center.add(sizeCorrection),
10949
- relativeCorrection: center.subtract(bboxCenter),
10949
+ center: bboxCenter,
10950
+ // TODO: investigate if this is still necessary
10951
+ relativeCorrection: new Point(0, 0),
10950
10952
  size: actualSize
10951
10953
  };
10952
10954
  } else {
@@ -11155,6 +11157,9 @@
11155
11157
  let {
11156
11158
  offset
11157
11159
  } = _ref;
11160
+ // TODO: this is here for cache invalidation.
11161
+ // verify if this is necessary since we have explicit
11162
+ // cache invalidation at the end of commitLayout
11158
11163
  object.set({
11159
11164
  left: object.left + offset.x,
11160
11165
  top: object.top + offset.y
@@ -14651,7 +14656,7 @@
14651
14656
  */
14652
14657
  _onTouchStart(e) {
14653
14658
  e.preventDefault();
14654
- if (this.mainTouchId === null) {
14659
+ if (this.mainTouchId === undefined) {
14655
14660
  this.mainTouchId = this.getPointerId(e);
14656
14661
  }
14657
14662
  this.__onMouseDown(e);
@@ -14691,7 +14696,7 @@
14691
14696
  }
14692
14697
  this.__onMouseUp(e);
14693
14698
  this._resetTransformEventData();
14694
- this.mainTouchId = null;
14699
+ delete this.mainTouchId;
14695
14700
  const eventTypePrefix = this._getEventPrefix();
14696
14701
  const doc = getDocumentFromElement(this.upperCanvasEl);
14697
14702
  removeListener(doc, 'touchend', this._onTouchEnd, addEventOptions);
@@ -16738,11 +16743,12 @@
16738
16743
  }
16739
16744
 
16740
16745
  const _excluded$9 = ["left", "top", "radius"];
16741
- const CIRCLE_PROPS = ['radius', 'startAngle', 'endAngle'];
16746
+ const CIRCLE_PROPS = ['radius', 'startAngle', 'endAngle', 'counterClockwise'];
16742
16747
  const circleDefaultValues = {
16743
16748
  radius: 0,
16744
16749
  startAngle: 0,
16745
- endAngle: 360
16750
+ endAngle: 360,
16751
+ counterClockwise: false
16746
16752
  };
16747
16753
  class Circle extends FabricObject {
16748
16754
  static getDefaults() {
@@ -16768,7 +16774,7 @@
16768
16774
  */
16769
16775
  _render(ctx) {
16770
16776
  ctx.beginPath();
16771
- ctx.arc(0, 0, this.radius, degreesToRadians(this.startAngle), degreesToRadians(this.endAngle), false);
16777
+ ctx.arc(0, 0, this.radius, degreesToRadians(this.startAngle), degreesToRadians(this.endAngle), this.counterClockwise);
16772
16778
  this._renderPaintInOrder(ctx);
16773
16779
  }
16774
16780
 
@@ -16830,8 +16836,9 @@
16830
16836
  startY = sin(start) * radius,
16831
16837
  endX = cos(end) * radius,
16832
16838
  endY = sin(end) * radius,
16833
- largeFlag = angle > 180 ? '1' : '0';
16834
- return ["<path d=\"M ".concat(startX, " ").concat(startY), " A ".concat(radius, " ").concat(radius), ' 0 ', "".concat(largeFlag, " 1"), " ".concat(endX, " ").concat(endY), '" ', 'COMMON_PARTS', ' />\n'];
16839
+ largeFlag = angle > 180 ? 1 : 0,
16840
+ sweepFlag = this.counterClockwise ? 0 : 1;
16841
+ return ["<path d=\"M ".concat(startX, " ").concat(startY, " A ").concat(radius, " ").concat(radius, " 0 ").concat(largeFlag, " ").concat(sweepFlag, " ").concat(endX, " ").concat(endY, "\" "), 'COMMON_PARTS', ' />\n'];
16835
16842
  }
16836
16843
  }
16837
16844
  /* _TO_SVG_END_ */
@@ -18539,7 +18546,8 @@
18539
18546
  * @return {String}
18540
18547
  */
18541
18548
  getSvgStyles(skipShadow) {
18542
- // @ts-expect-error TS doesn't respect this type casting
18549
+ // cant use ts-expect-error because of ts 5.3 cross check
18550
+ // @ts-ignore TS doesn't respect this type casting
18543
18551
  return "".concat(super.getSvgStyles(skipShadow), " white-space: pre;");
18544
18552
  }
18545
18553
 
@@ -18583,7 +18591,9 @@
18583
18591
  */
18584
18592
  function getMeasuringContext() {
18585
18593
  if (!measuringContext) {
18586
- measuringContext = createCanvasElement().getContext('2d');
18594
+ const canvas = createCanvasElement();
18595
+ canvas.width = canvas.height = 0;
18596
+ measuringContext = canvas.getContext('2d');
18587
18597
  }
18588
18598
  return measuringContext;
18589
18599
  }
@@ -21942,7 +21952,13 @@
21942
21952
  65: 'selectAll'
21943
21953
  };
21944
21954
 
21945
- const iTextDefaultValues = {
21955
+ // Declare IText protected properties to workaround TS
21956
+ const protectedDefaultValues = {
21957
+ _selectionDirection: null,
21958
+ _reSpace: /\s|\r?\n/,
21959
+ inCompositionMode: false
21960
+ };
21961
+ const iTextDefaultValues = _objectSpread2({
21946
21962
  selectionStart: 0,
21947
21963
  selectionEnd: 0,
21948
21964
  selectionColor: 'rgba(17,119,255,0.3)',
@@ -21955,14 +21971,11 @@
21955
21971
  cursorDuration: 600,
21956
21972
  caching: true,
21957
21973
  hiddenTextareaContainer: null,
21958
- _selectionDirection: null,
21959
- _reSpace: /\s|\r?\n/,
21960
- inCompositionMode: false,
21961
21974
  keysMap,
21962
21975
  keysMapRtl,
21963
21976
  ctrlKeysMapDown,
21964
21977
  ctrlKeysMapUp
21965
- };
21978
+ }, protectedDefaultValues);
21966
21979
 
21967
21980
  // @TODO this is not complete
21968
21981
 
@@ -22937,7 +22950,8 @@
22937
22950
  * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output
22938
22951
  * @return {Object} object representation of an instance
22939
22952
  */
22940
- // @ts-expect-error TS this typing limitations
22953
+ // cant use ts-expect-error because of ts 5.3 cross check
22954
+ // @ts-ignore TS this typing limitations
22941
22955
  toObject() {
22942
22956
  let propertiesToInclude = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
22943
22957
  return super.toObject(['minWidth', 'splitByGrapheme', ...propertiesToInclude]);
@@ -23047,6 +23061,10 @@
23047
23061
  _defineProperty(FixedLayout, "type", 'fixed');
23048
23062
  classRegistry.setClass(FixedLayout);
23049
23063
 
23064
+ const activeSelectionDefaultValues = {
23065
+ multiSelectionStacking: 'canvas-stacking'
23066
+ };
23067
+
23050
23068
  /**
23051
23069
  * Used by Canvas to manage selection.
23052
23070
  *
@@ -23109,6 +23127,18 @@
23109
23127
  }
23110
23128
  }
23111
23129
 
23130
+ /**
23131
+ * @override block ancestors/descendants of selected objects from being selected to prevent a circular object tree
23132
+ */
23133
+ canEnterGroup(object) {
23134
+ if (this.getObjects().some(o => o.isDescendantOf(object) || object.isDescendantOf(o))) {
23135
+ // prevent circular object tree
23136
+ log('error', 'ActiveSelection: circular object trees are not supported, this call has no effect');
23137
+ return false;
23138
+ }
23139
+ return super.canEnterGroup(object);
23140
+ }
23141
+
23112
23142
  /**
23113
23143
  * Change an object so that it can be part of an active selection.
23114
23144
  * this method is called by multiselectAdd from canvas code.
@@ -23232,9 +23262,7 @@
23232
23262
  }
23233
23263
  }
23234
23264
  _defineProperty(ActiveSelection, "type", 'ActiveSelection');
23235
- _defineProperty(ActiveSelection, "ownDefaults", {
23236
- multiSelectionStacking: 'canvas-stacking'
23237
- });
23265
+ _defineProperty(ActiveSelection, "ownDefaults", activeSelectionDefaultValues);
23238
23266
  classRegistry.setClass(ActiveSelection);
23239
23267
  classRegistry.setClass(ActiveSelection, 'activeSelection');
23240
23268
 
@@ -23875,7 +23903,7 @@
23875
23903
  if (this.stroke || this.strokeDashArray) {
23876
23904
  const origFill = this.fill;
23877
23905
  this.fill = null;
23878
- strokeSvg = ["\t<rect x=\"".concat(x, "\" y=\"").concat(y, "\" width=\"").concat(this.width, "\" height=\"").concat(this.height, "\" styles=\"").concat(this.getSvgStyles(), "\" />\n")];
23906
+ strokeSvg = ["\t<rect x=\"".concat(x, "\" y=\"").concat(y, "\" width=\"").concat(this.width, "\" height=\"").concat(this.height, "\" style=\"").concat(this.getSvgStyles(), "\" />\n")];
23879
23907
  this.fill = origFill;
23880
23908
  }
23881
23909
  if (this.paintFirst !== 'fill') {
@@ -24046,7 +24074,8 @@
24046
24074
  */
24047
24075
  drawCacheOnCanvas(ctx) {
24048
24076
  ctx.imageSmoothingEnabled = this.imageSmoothing;
24049
- // @ts-expect-error TS doesn't respect this type casting
24077
+ // cant use ts-expect-error because of ts 5.3 cross check
24078
+ // @ts-ignore TS doesn't respect this type casting
24050
24079
  super.drawCacheOnCanvas(ctx);
24051
24080
  }
24052
24081
 
@@ -24410,11 +24439,13 @@
24410
24439
  return parsedDim;
24411
24440
  }
24412
24441
 
24442
+ const getTagName = node => node.tagName.replace('svg:', '');
24443
+
24413
24444
  const svgInvalidAncestorsRegEx = getSvgRegex(svgInvalidAncestors);
24414
24445
  function hasInvalidAncestor(element) {
24415
24446
  let _element = element;
24416
24447
  while (_element && (_element = _element.parentElement)) {
24417
- if (_element && _element.nodeName && svgInvalidAncestorsRegEx.test(_element.nodeName.replace('svg:', '')) && !_element.getAttribute('instantiated_by_use')) {
24448
+ if (_element && _element.nodeName && svgInvalidAncestorsRegEx.test(getTagName(_element)) && !_element.getAttribute('instantiated_by_use')) {
24418
24449
  return true;
24419
24450
  }
24420
24451
  }
@@ -24575,6 +24606,12 @@
24575
24606
  .filter((rule, index, array) => array.length > 1 && rule.trim())
24576
24607
  // at this point we have hopefully an array of rules `body { style code... `
24577
24608
  .forEach(rule => {
24609
+ // if there is more than one opening bracket and the rule starts with '@', it is likely
24610
+ // a nested at-rule like @media, @supports, @scope, etc. Ignore these as the code below
24611
+ // can not handle it.
24612
+ if ((rule.match(/{/g) || []).length > 1 && rule.trim().startsWith('@')) {
24613
+ return;
24614
+ }
24578
24615
  const match = rule.split('{'),
24579
24616
  ruleObj = {},
24580
24617
  declaration = match[1].trim(),
@@ -24600,7 +24637,7 @@
24600
24637
  return allRules;
24601
24638
  }
24602
24639
 
24603
- const findTag = el => classRegistry.getSVGClass(el.tagName.toLowerCase().replace('svg:', ''));
24640
+ const findTag = el => classRegistry.getSVGClass(getTagName(el).toLowerCase());
24604
24641
  class ElementsParser {
24605
24642
  constructor(elements, options, reviver, doc, clipPaths) {
24606
24643
  this.elements = elements;
@@ -24656,17 +24693,27 @@
24656
24693
  obj.set(property, gradient);
24657
24694
  }
24658
24695
  }
24696
+
24697
+ // TODO: resolveClipPath could be run once per clippath with minor work per object.
24698
+ // is a refactor that i m not sure is worth on this code
24659
24699
  async resolveClipPath(obj, usingElement) {
24660
24700
  const clipPathElements = this.extractPropertyDefinition(obj, 'clipPath', this.clipPaths);
24661
24701
  if (clipPathElements) {
24662
24702
  const objTransformInv = invertTransform(obj.calcTransformMatrix());
24663
- // move the clipPath tag as sibling to the real element that is using it
24664
24703
  const clipPathTag = clipPathElements[0].parentElement;
24665
24704
  let clipPathOwner = usingElement;
24666
24705
  while (clipPathOwner.parentElement && clipPathOwner.getAttribute('clip-path') !== obj.clipPath) {
24667
24706
  clipPathOwner = clipPathOwner.parentElement;
24668
24707
  }
24708
+ // move the clipPath tag as sibling to the real element that is using it
24669
24709
  clipPathOwner.parentElement.appendChild(clipPathTag);
24710
+
24711
+ // this multiplication order could be opposite.
24712
+ // but i don't have an svg to test it
24713
+ // at the first SVG that has a transform on both places and is misplaced
24714
+ // try to invert this multiplication order
24715
+ const finalTransform = parseTransformAttribute("".concat(clipPathOwner.getAttribute('transform') || '', " ").concat(clipPathTag.getAttribute('originalTransform') || ''));
24716
+ clipPathTag.setAttribute('transform', "matrix(".concat(finalTransform.join(','), ")"));
24670
24717
  const container = await Promise.all(clipPathElements.map(clipPathElement => {
24671
24718
  return findTag(clipPathElement).fromElement(clipPathElement, this.options, this.cssRules).then(enlivedClippath => {
24672
24719
  removeTransformMatrixForSvgParsing(enlivedClippath);
@@ -24709,7 +24756,7 @@
24709
24756
  }
24710
24757
  }
24711
24758
 
24712
- const isValidSvgTag = el => svgValidTagNamesRegEx.test(el.nodeName.replace('svg:', ''));
24759
+ const isValidSvgTag = el => svgValidTagNamesRegEx.test(getTagName(el));
24713
24760
  const createEmptyResponse = () => ({
24714
24761
  objects: [],
24715
24762
  elements: [],
@@ -24763,7 +24810,8 @@
24763
24810
  });
24764
24811
  }
24765
24812
  const localClipPaths = {};
24766
- descendants.filter(el => el.nodeName.replace('svg:', '') === 'clipPath').forEach(el => {
24813
+ descendants.filter(el => getTagName(el) === 'clipPath').forEach(el => {
24814
+ el.setAttribute('originalTransform', el.getAttribute('transform') || '');
24767
24815
  const id = el.getAttribute('id');
24768
24816
  localClipPaths[id] = Array.from(el.getElementsByTagName('*')).filter(el => isValidSvgTag(el));
24769
24817
  });