@pixldocs/canvas-renderer 0.5.448 → 0.5.450

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.
@@ -11646,17 +11646,20 @@ const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11646
11646
  return updates;
11647
11647
  };
11648
11648
  const applyTransformPreservingFlip = (obj, matrix) => {
11649
- fabric.util.applyTransformToObject(obj, matrix);
11650
- let sx = obj.scaleX ?? 1;
11651
- let sy = obj.scaleY ?? 1;
11652
- let flipX = false;
11653
- let flipY = false;
11649
+ const intendedFlipX = obj.flipX ?? false;
11650
+ const intendedFlipY = obj.flipY ?? false;
11651
+ const cleanMatrix = toggleLogicalFlipInMatrix(matrix, intendedFlipX, intendedFlipY);
11652
+ fabric.util.applyTransformToObject(obj, cleanMatrix);
11653
+ let sx = Number(obj.scaleX ?? 1) || 1;
11654
+ let sy = Number(obj.scaleY ?? 1) || 1;
11655
+ let flipX = intendedFlipX;
11656
+ let flipY = intendedFlipY;
11654
11657
  if (sx < 0) {
11655
- flipX = true;
11658
+ flipX = !flipX;
11656
11659
  sx = -sx;
11657
11660
  }
11658
11661
  if (sy < 0) {
11659
- flipY = true;
11662
+ flipY = !flipY;
11660
11663
  sy = -sy;
11661
11664
  }
11662
11665
  obj.set({ scaleX: sx, scaleY: sy, flipX, flipY });
@@ -11664,19 +11667,13 @@ const applyTransformPreservingFlip = (obj, matrix) => {
11664
11667
  const restorePersistedFlipState = (obj, flipX, flipY, angle) => {
11665
11668
  const sx = Math.abs(Number(obj.scaleX ?? 1)) || 1;
11666
11669
  const sy = Math.abs(Number(obj.scaleY ?? 1)) || 1;
11667
- obj.set({ scaleX: sx, scaleY: sy, skewX: 0, skewY: 0, flipX, flipY, ...Number.isFinite(angle) ? { angle } : {} });
11668
- obj.setCoords();
11669
- obj.dirty = true;
11670
- };
11671
- const isBitmapLikeFabricObject = (obj) => {
11672
- var _a2;
11673
- return obj instanceof fabric.FabricImage || obj instanceof fabric.Group && !!(obj.__cropGroup || ((_a2 = obj._ct) == null ? void 0 : _a2.isCropGroup));
11674
- };
11675
- const restorePersistedFlipFlagsOnly = (obj, flipX, flipY) => {
11676
- if (!isBitmapLikeFabricObject(obj)) return;
11677
- const sx = Math.abs(Number(obj.scaleX ?? 1)) || 1;
11678
- const sy = Math.abs(Number(obj.scaleY ?? 1)) || 1;
11679
- obj.set({ scaleX: sx, scaleY: sy, flipX, flipY });
11670
+ obj.set({
11671
+ scaleX: sx,
11672
+ scaleY: sy,
11673
+ flipX,
11674
+ flipY,
11675
+ ...Number.isFinite(angle) ? { angle } : {}
11676
+ });
11680
11677
  obj.setCoords();
11681
11678
  obj.dirty = true;
11682
11679
  };
@@ -11787,16 +11784,11 @@ function applyWarpAwareSelectionBorders(selection) {
11787
11784
  selection.calcTransformMatrix()
11788
11785
  );
11789
11786
  kids.forEach((k, index) => {
11790
- var _a3;
11791
11787
  const beforeRestore = summarizeRotDriftObject(k);
11792
11788
  const localMatrix = fabric.util.multiplyTransformMatrices(
11793
11789
  invSelection,
11794
11790
  worldMatrices[index]
11795
11791
  );
11796
- const isImageLikeKid = k instanceof fabric.FabricImage || k instanceof fabric.Group && (k.__cropGroup || ((_a3 = k._ct) == null ? void 0 : _a3.isCropGroup));
11797
- const persistedKidFlipX = !!k.flipX;
11798
- const persistedKidFlipY = !!k.flipY;
11799
- const expectedCleanKidAngle = isImageLikeKid && (persistedKidFlipX || persistedKidFlipY) ? fabric.util.qrDecompose(toggleLogicalFlipInMatrix(localMatrix, persistedKidFlipX, persistedKidFlipY)).angle ?? 0 : void 0;
11800
11792
  const savedLayout = k.layoutManager;
11801
11793
  try {
11802
11794
  if (savedLayout) k.layoutManager = void 0;
@@ -11806,9 +11798,6 @@ function applyWarpAwareSelectionBorders(selection) {
11806
11798
  );
11807
11799
  const expectedCenter = new fabric.Point(decomposed.translateX, decomposed.translateY);
11808
11800
  k.setPositionByOrigin(expectedCenter, "center", "center");
11809
- if (isImageLikeKid && (persistedKidFlipX || persistedKidFlipY)) {
11810
- restorePersistedFlipState(k, persistedKidFlipX, persistedKidFlipY, expectedCleanKidAngle);
11811
- }
11812
11801
  } finally {
11813
11802
  if (savedLayout) k.layoutManager = savedLayout;
11814
11803
  }
@@ -14649,7 +14638,7 @@ const PageCanvas = forwardRef(
14649
14638
  fabricCanvas.on("selection:cleared", () => {
14650
14639
  });
14651
14640
  fabricCanvas.on("object:scaling", (e) => {
14652
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
14641
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
14653
14642
  if (!isActiveRef.current) return;
14654
14643
  const t = e.target;
14655
14644
  if (t) lastResizeScaleTargetRef.current = t;
@@ -14880,66 +14869,11 @@ const PageCanvas = forwardRef(
14880
14869
  };
14881
14870
  }
14882
14871
  }
14883
- if (obj instanceof fabric.ActiveSelection && isCornerResizeHandle(corner)) {
14884
- const _cur = fabricCanvas._currentTransform;
14885
- const startSx = Math.abs(Number(((_g = _cur == null ? void 0 : _cur.original) == null ? void 0 : _g.scaleX) ?? 1)) || 1;
14886
- const startSy = Math.abs(Number(((_h = _cur == null ? void 0 : _cur.original) == null ? void 0 : _h.scaleY) ?? 1)) || 1;
14887
- const liveAsSx = Math.abs((obj.scaleX ?? 1) / startSx) || 1;
14888
- const liveAsSy = Math.abs((obj.scaleY ?? 1) / startSy) || 1;
14889
- const uniform = Math.max(1e-3, Math.sqrt(liveAsSx * liveAsSy));
14890
- for (const child of obj.getObjects()) {
14891
- if (!isBitmapLikeFabricObject(child)) continue;
14892
- const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((_i = groupSelectionTransformStartRef.current) == null ? void 0 : _i.selectionLeft) ?? obj.left ?? 0}:${((_j = groupSelectionTransformStartRef.current) == null ? void 0 : _j.selectionTop) ?? obj.top ?? 0}`;
14893
- if (child.__asLiveGestureKey !== liveGestureKey) {
14894
- child.__asLiveGestureKey = liveGestureKey;
14895
- child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14896
- child.__asLiveOrigFlipX = !!child.flipX;
14897
- child.__asLiveOrigFlipY = !!child.flipY;
14898
- child.__asLiveOrigScaleX = Math.abs(Number(child.scaleX ?? 1)) || 1;
14899
- child.__asLiveOrigScaleY = Math.abs(Number(child.scaleY ?? 1)) || 1;
14900
- }
14901
- const childAngleDeg = child.__asLiveOrigAngle ?? (child.angle ?? 0);
14902
- const origScaleX = child.__asLiveOrigScaleX;
14903
- const origScaleY = child.__asLiveOrigScaleY;
14904
- const baseW = Math.max(1, Number(((_k = child.__cropData) == null ? void 0 : _k.frameW) ?? child.width ?? 1));
14905
- const baseH = Math.max(1, Number(((_l = child.__cropData) == null ? void 0 : _l.frameH) ?? child.height ?? 1));
14906
- try {
14907
- const inv = [1 / liveAsSx, 0, 0, 1 / liveAsSy, 0, 0];
14908
- const Rtheta = fabric.util.composeMatrix({ angle: childAngleDeg, scaleX: 1, scaleY: 1, translateX: 0, translateY: 0 });
14909
- const Uscale = fabric.util.composeMatrix({ angle: 0, scaleX: origScaleX * uniform, scaleY: origScaleY * uniform, translateX: 0, translateY: 0 });
14910
- const M = fabric.util.multiplyTransformMatrices(
14911
- fabric.util.multiplyTransformMatrices(inv, Rtheta),
14912
- Uscale
14913
- );
14914
- const dec = fabric.util.qrDecompose(M);
14915
- child._set("angle", dec.angle);
14916
- child._set("scaleX", dec.scaleX);
14917
- child._set("scaleY", dec.scaleY);
14918
- child._set("skewX", dec.skewX);
14919
- child._set("skewY", dec.skewY);
14920
- child._set("flipX", !!(child.__asLiveOrigFlipX ?? child.flipX));
14921
- child._set("flipY", !!(child.__asLiveOrigFlipY ?? child.flipY));
14922
- const worldMatrix = fabric.util.multiplyTransformMatrices(
14923
- obj.calcTransformMatrix(),
14924
- child.calcOwnMatrix()
14925
- );
14926
- const live = fabric.util.qrDecompose(worldMatrix);
14927
- child.__asLiveWorldAngle = (obj.angle ?? 0) + childAngleDeg;
14928
- child.__asLiveWorldCenterX = live.translateX;
14929
- child.__asLiveWorldCenterY = live.translateY;
14930
- child.__asLiveFinalW = baseW * origScaleX * uniform;
14931
- child.__asLiveFinalH = baseH * origScaleY * uniform;
14932
- } catch {
14933
- }
14934
- child.setCoords();
14935
- child.dirty = true;
14936
- }
14937
- }
14938
14872
  if (obj instanceof fabric.ActiveSelection && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
14939
14873
  const isXSide = corner === "ml" || corner === "mr";
14940
14874
  const _cur = fabricCanvas._currentTransform;
14941
- const startSx = Math.abs(Number(((_m = _cur == null ? void 0 : _cur.original) == null ? void 0 : _m.scaleX) ?? 1)) || 1;
14942
- const startSy = Math.abs(Number(((_n = _cur == null ? void 0 : _cur.original) == null ? void 0 : _n.scaleY) ?? 1)) || 1;
14875
+ const startSx = Math.abs(Number(((_g = _cur == null ? void 0 : _cur.original) == null ? void 0 : _g.scaleX) ?? 1)) || 1;
14876
+ const startSy = Math.abs(Number(((_h = _cur == null ? void 0 : _cur.original) == null ? void 0 : _h.scaleY) ?? 1)) || 1;
14943
14877
  const sAxis = isXSide ? Math.abs((obj.scaleX ?? 1) / startSx) : Math.abs((obj.scaleY ?? 1) / startSy);
14944
14878
  if (sAxis > 1e-3) {
14945
14879
  const captureAsLiveWorldSnapshot = (childObj, liveW, liveH) => {
@@ -14958,13 +14892,13 @@ const PageCanvas = forwardRef(
14958
14892
  } catch {
14959
14893
  }
14960
14894
  };
14961
- if (isXSide && ((_o = groupShiftReflowSnapshotRef.current) == null ? void 0 : _o.selection) !== obj) {
14895
+ if (isXSide && ((_i = groupShiftReflowSnapshotRef.current) == null ? void 0 : _i.selection) !== obj) {
14962
14896
  groupShiftReflowSnapshotRef.current = null;
14963
14897
  const logicalGroupId = obj.__pixldocsGroupSelection;
14964
14898
  if (logicalGroupId) {
14965
14899
  try {
14966
14900
  const state = useEditorStore.getState();
14967
- const pageChildren2 = ((_p = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _p.children) ?? [];
14901
+ const pageChildren2 = ((_j = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _j.children) ?? [];
14968
14902
  const groupNode = findNodeById(pageChildren2, logicalGroupId);
14969
14903
  if (groupNode && isGroup(groupNode) && !isStackLayoutMode(groupNode.layoutMode)) {
14970
14904
  const entries = obj.getObjects().map((c) => ({
@@ -14994,50 +14928,124 @@ const PageCanvas = forwardRef(
14994
14928
  const asRect0 = obj.getBoundingRect();
14995
14929
  let didReflowTextChild = false;
14996
14930
  for (const child of obj.getObjects()) {
14997
- const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((_q = groupSelectionTransformStartRef.current) == null ? void 0 : _q.selectionLeft) ?? obj.left ?? 0}:${((_r = groupSelectionTransformStartRef.current) == null ? void 0 : _r.selectionTop) ?? obj.top ?? 0}`;
14931
+ const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((_k = groupSelectionTransformStartRef.current) == null ? void 0 : _k.selectionLeft) ?? obj.left ?? 0}:${((_l = groupSelectionTransformStartRef.current) == null ? void 0 : _l.selectionTop) ?? obj.top ?? 0}`;
14998
14932
  if (child.__asLiveGestureKey !== liveGestureKey) {
14999
14933
  child.__asLiveGestureKey = liveGestureKey;
15000
14934
  child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
15001
- child.__asLiveOrigFlipX = !!child.flipX;
15002
- child.__asLiveOrigFlipY = !!child.flipY;
15003
14935
  }
15004
- const liveAsSx = isXSide ? sAxis : 1;
15005
- const liveAsSy = isXSide ? 1 : sAxis;
15006
- if (child instanceof fabric.Group && (child.__cropGroup || ((_s = child._ct) == null ? void 0 : _s.isCropGroup)) || child instanceof fabric.FabricImage && !child.__cropGroup && !child.smartElementType) {
15007
- const childAngleDeg2 = child.__asLiveOrigAngle ?? (child.angle ?? 0);
15008
- const theta2 = fabric.util.degreesToRadians(childAngleDeg2);
15009
- const cosT2 = Math.cos(theta2);
15010
- const sinT2 = Math.sin(theta2);
15011
- const dX = isXSide ? Math.max(1e-3, liveAsSx * cosT2 * cosT2 + sinT2 * sinT2) : 1;
15012
- const dY = isXSide ? 1 : Math.max(1e-3, liveAsSy * cosT2 * cosT2 + sinT2 * sinT2);
15013
- if (child.__asLiveOrigScaleX == null) child.__asLiveOrigScaleX = Math.abs(Number(child.scaleX ?? 1)) || 1;
15014
- if (child.__asLiveOrigScaleY == null) child.__asLiveOrigScaleY = Math.abs(Number(child.scaleY ?? 1)) || 1;
15015
- const origScaleX = child.__asLiveOrigScaleX;
15016
- const origScaleY = child.__asLiveOrigScaleY;
15017
- const baseW = Math.max(1, Number(((_t = child.__cropData) == null ? void 0 : _t.frameW) ?? child.width ?? 1));
15018
- const baseH = Math.max(1, Number(((_u = child.__cropData) == null ? void 0 : _u.frameH) ?? child.height ?? 1));
15019
- const liveW = baseW * origScaleX * dX;
15020
- const liveH = baseH * origScaleY * dY;
14936
+ if (child instanceof fabric.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) {
14937
+ const ct = child.__cropData;
14938
+ if (!ct) continue;
14939
+ if (child.__asLiveOrigAngle == null) {
14940
+ child.__asLiveOrigAngle = child.angle ?? 0;
14941
+ }
14942
+ const childAngleDegC = child.__asLiveOrigAngle;
14943
+ const asSxC = isXSide ? sAxis : 1;
14944
+ const asSyC = isXSide ? 1 : sAxis;
14945
+ const thetaC = fabric.util.degreesToRadians(childAngleDegC);
14946
+ const cosTC = Math.cos(thetaC);
14947
+ const sinTC = Math.sin(thetaC);
14948
+ const sLocalC = isXSide ? asSxC * cosTC * cosTC + sinTC * sinTC : asSyC * cosTC * cosTC + sinTC * sinTC;
14949
+ if (isXSide) {
14950
+ if (child.__asLiveOrigW == null) {
14951
+ const baseW = child.width ?? ct.frameW ?? 0;
14952
+ child.__asLiveOrigW = baseW * (child.scaleX ?? 1);
14953
+ }
14954
+ const origW = child.__asLiveOrigW;
14955
+ const newW = Math.max(20, origW * sLocalC);
14956
+ if (Math.abs((child.width ?? 0) - newW) > 0.5) {
14957
+ ct.frameW = newW;
14958
+ child._set("width", newW);
14959
+ }
14960
+ } else {
14961
+ if (child.__asLiveOrigH == null) {
14962
+ const baseH = child.height ?? ct.frameH ?? 0;
14963
+ child.__asLiveOrigH = baseH * (child.scaleY ?? 1);
14964
+ }
14965
+ const origH = child.__asLiveOrigH;
14966
+ const newH = Math.max(20, origH * sLocalC);
14967
+ if (Math.abs((child.height ?? 0) - newH) > 0.5) {
14968
+ ct.frameH = newH;
14969
+ child._set("height", newH);
14970
+ }
14971
+ }
15021
14972
  try {
15022
- const inv = [1 / liveAsSx, 0, 0, 1 / liveAsSy, 0, 0];
15023
- const Rtheta = fabric.util.composeMatrix({ angle: childAngleDeg2, scaleX: 1, scaleY: 1, translateX: 0, translateY: 0 });
15024
- const Dscale = fabric.util.composeMatrix({ angle: 0, scaleX: origScaleX * dX, scaleY: origScaleY * dY, translateX: 0, translateY: 0 });
15025
- const M = fabric.util.multiplyTransformMatrices(
15026
- fabric.util.multiplyTransformMatrices(inv, Rtheta),
15027
- Dscale
15028
- );
15029
- const dec = fabric.util.qrDecompose(M);
15030
- child._set("angle", dec.angle);
15031
- child._set("scaleX", dec.scaleX);
15032
- child._set("scaleY", dec.scaleY);
15033
- child._set("skewX", dec.skewX);
15034
- child._set("skewY", dec.skewY);
15035
- child._set("flipX", !!(child.__asLiveOrigFlipX ?? child.flipX));
15036
- child._set("flipY", !!(child.__asLiveOrigFlipY ?? child.flipY));
14973
+ const invC = [1 / asSxC, 0, 0, 1 / asSyC, 0, 0];
14974
+ const RthetaC = fabric.util.composeMatrix({
14975
+ angle: childAngleDegC,
14976
+ scaleX: 1,
14977
+ scaleY: 1,
14978
+ translateX: 0,
14979
+ translateY: 0
14980
+ });
14981
+ const MC = fabric.util.multiplyTransformMatrices(invC, RthetaC);
14982
+ const decC = fabric.util.qrDecompose(MC);
14983
+ child._set("angle", decC.angle);
14984
+ child._set("scaleX", decC.scaleX);
14985
+ child._set("scaleY", decC.scaleY);
14986
+ child._set("skewX", decC.skewX);
14987
+ child._set("skewY", decC.skewY);
14988
+ } catch {
14989
+ }
14990
+ try {
14991
+ updateCoverLayout(child);
14992
+ } catch {
14993
+ }
14994
+ child.setCoords();
14995
+ captureAsLiveWorldSnapshot(child, ct.frameW ?? child.width ?? 0, ct.frameH ?? child.height ?? 0);
14996
+ child.dirty = true;
14997
+ continue;
14998
+ }
14999
+ if (child instanceof fabric.FabricImage && !child.__cropGroup && !child.smartElementType) {
15000
+ if (child.__asLiveOrigAngle == null) {
15001
+ child.__asLiveOrigAngle = child.angle ?? 0;
15002
+ }
15003
+ const childAngleDegI = child.__asLiveOrigAngle;
15004
+ const asSxI = isXSide ? sAxis : 1;
15005
+ const asSyI = isXSide ? 1 : sAxis;
15006
+ const thetaI = fabric.util.degreesToRadians(childAngleDegI);
15007
+ const cosTI = Math.cos(thetaI);
15008
+ const sinTI = Math.sin(thetaI);
15009
+ const sLocalI = isXSide ? asSxI * cosTI * cosTI + sinTI * sinTI : asSyI * cosTI * cosTI + sinTI * sinTI;
15010
+ if (isXSide) {
15011
+ if (child.__asLiveOrigW == null) {
15012
+ child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
15013
+ }
15014
+ const origW = child.__asLiveOrigW;
15015
+ const newW = Math.max(1, origW * sLocalI);
15016
+ if (Math.abs((child.width ?? 0) - newW) > 0.5) {
15017
+ child._set("width", newW);
15018
+ }
15019
+ } else {
15020
+ if (child.__asLiveOrigH == null) {
15021
+ child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
15022
+ }
15023
+ const origH = child.__asLiveOrigH;
15024
+ const newH = Math.max(1, origH * sLocalI);
15025
+ if (Math.abs((child.height ?? 0) - newH) > 0.5) {
15026
+ child._set("height", newH);
15027
+ }
15028
+ }
15029
+ try {
15030
+ const invI = [1 / asSxI, 0, 0, 1 / asSyI, 0, 0];
15031
+ const RthetaI = fabric.util.composeMatrix({
15032
+ angle: childAngleDegI,
15033
+ scaleX: 1,
15034
+ scaleY: 1,
15035
+ translateX: 0,
15036
+ translateY: 0
15037
+ });
15038
+ const MI = fabric.util.multiplyTransformMatrices(invI, RthetaI);
15039
+ const decI = fabric.util.qrDecompose(MI);
15040
+ child._set("angle", decI.angle);
15041
+ child._set("scaleX", decI.scaleX);
15042
+ child._set("scaleY", decI.scaleY);
15043
+ child._set("skewX", decI.skewX);
15044
+ child._set("skewY", decI.skewY);
15037
15045
  } catch {
15038
15046
  }
15039
- captureAsLiveWorldSnapshot(child, liveW, liveH);
15040
15047
  child.setCoords();
15048
+ captureAsLiveWorldSnapshot(child, child.width ?? 0, child.height ?? 0);
15041
15049
  child.dirty = true;
15042
15050
  continue;
15043
15051
  }
@@ -15094,7 +15102,7 @@ const PageCanvas = forwardRef(
15094
15102
  child.dirty = true;
15095
15103
  didReflowTextChild = true;
15096
15104
  }
15097
- if (isXSide && ((_v = groupShiftReflowSnapshotRef.current) == null ? void 0 : _v.selection) === obj) {
15105
+ if (isXSide && ((_n = groupShiftReflowSnapshotRef.current) == null ? void 0 : _n.selection) === obj) {
15098
15106
  const snap = groupShiftReflowSnapshotRef.current;
15099
15107
  const anchorEntry = snap.children[0];
15100
15108
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -15256,7 +15264,7 @@ const PageCanvas = forwardRef(
15256
15264
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
15257
15265
  if (drilledGroupIdRef.current) {
15258
15266
  try {
15259
- (_w = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _w.call(fabricCanvas);
15267
+ (_o = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _o.call(fabricCanvas);
15260
15268
  } catch {
15261
15269
  }
15262
15270
  }
@@ -15483,8 +15491,6 @@ const PageCanvas = forwardRef(
15483
15491
  for (const child of t.getObjects()) {
15484
15492
  delete child.__asLiveOrigW;
15485
15493
  delete child.__asLiveOrigH;
15486
- delete child.__asLiveOrigScaleX;
15487
- delete child.__asLiveOrigScaleY;
15488
15494
  delete child.__asLiveRotSnap;
15489
15495
  delete child.__asLiveGestureKey;
15490
15496
  }
@@ -16187,12 +16193,10 @@ const PageCanvas = forwardRef(
16187
16193
  const ownSy = Math.abs(obj.scaleY ?? 1);
16188
16194
  const bakedW = Math.max(1, intrinsicWidth * ownSx * (imgIsXSide ? sLocalI : 1));
16189
16195
  const bakedH = Math.max(1, intrinsicHeight * ownSy * (imgIsXSide ? 1 : sLocalI));
16190
- const cleanW = Math.max(1, Number(obj.__asLiveFinalW ?? bakedW));
16191
- const cleanH = Math.max(1, Number(obj.__asLiveFinalH ?? bakedH));
16192
16196
  try {
16193
16197
  obj.set({
16194
- width: cleanW,
16195
- height: cleanH,
16198
+ width: bakedW,
16199
+ height: bakedH,
16196
16200
  scaleX: 1,
16197
16201
  scaleY: 1,
16198
16202
  skewX: 0,
@@ -16211,8 +16215,8 @@ const PageCanvas = forwardRef(
16211
16215
  obj.setCoords();
16212
16216
  } catch {
16213
16217
  }
16214
- finalWidth = cleanW;
16215
- finalHeight = cleanH;
16218
+ finalWidth = Math.max(1, Number(obj.__asLiveFinalW ?? bakedW));
16219
+ finalHeight = Math.max(1, Number(obj.__asLiveFinalH ?? bakedH));
16216
16220
  finalScaleX = 1;
16217
16221
  finalScaleY = 1;
16218
16222
  const worldCx = Number.isFinite(obj.__asLiveWorldCenterX) ? obj.__asLiveWorldCenterX : decomposed.translateX ?? 0;
@@ -16488,9 +16492,8 @@ const PageCanvas = forwardRef(
16488
16492
  const objectFlipY = obj.flipY ?? false;
16489
16493
  const persistedFlipX = (sourceElement == null ? void 0 : sourceElement.flipX) ?? objectFlipX;
16490
16494
  const persistedFlipY = (sourceElement == null ? void 0 : sourceElement.flipY) ?? objectFlipY;
16491
- const persistedAngle = sourceElement ? Number.isFinite(sourceElement.angle) ? sourceElement.angle ?? 0 : 0 : Number.isFinite(obj.angle) ? obj.angle ?? 0 : void 0;
16492
16495
  const isActiveSelectionResizeGesture = activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb" || activeSelectionResizeHandle === "tl" || activeSelectionResizeHandle === "tr" || activeSelectionResizeHandle === "bl" || activeSelectionResizeHandle === "br";
16493
- const expectedCleanAngle = isActiveSelection && isActiveSelectionResizeGesture ? sourceElement ? Number.isFinite(sourceElement.angle) ? sourceElement.angle ?? 0 : 0 : Number.isFinite(obj.angle) ? obj.angle ?? 0 : void 0 : void 0;
16496
+ const expectedCleanAngle = isActiveSelection && isActiveSelectionResizeGesture ? Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? (sourceElement == null ? void 0 : sourceElement.angle) ?? 0 : Number.isFinite(obj.angle) ? obj.angle ?? 0 : void 0 : void 0;
16494
16497
  const normalizedFinalAbsoluteMatrix = normalizeMatrixForPersistedFlip(
16495
16498
  toggleLogicalFlipInMatrix(
16496
16499
  finalAbsoluteMatrix,
@@ -16503,15 +16506,6 @@ const PageCanvas = forwardRef(
16503
16506
  );
16504
16507
  const cleanTransformMatrix = toggleLogicalFlipInMatrix(normalizedFinalAbsoluteMatrix, persistedFlipX, persistedFlipY);
16505
16508
  const persistedDecomposed = fabric.util.qrDecompose(cleanTransformMatrix);
16506
- if (isActiveSelection && (obj instanceof fabric.FabricImage || obj instanceof fabric.Group && obj.__cropGroup)) {
16507
- activeSelectionFlipRestores.push({
16508
- obj,
16509
- flipX: persistedFlipX,
16510
- flipY: persistedFlipY,
16511
- localAngle: Number.isFinite(obj.angle) ? obj.angle ?? 0 : persistedAngle,
16512
- worldAngle: persistedAngle
16513
- });
16514
- }
16515
16509
  const elementUpdate = {
16516
16510
  left: storePos.left,
16517
16511
  top: storePos.top,
@@ -16591,7 +16585,7 @@ const PageCanvas = forwardRef(
16591
16585
  }
16592
16586
  const isCropGroupObj = obj instanceof fabric.Group && obj.__cropGroup;
16593
16587
  const isPlainImageObj = obj instanceof fabric.FabricImage && !obj.__cropGroup && !obj.smartElementType;
16594
- if (isActiveSelection && isActiveSelectionResizeGesture && (isCropGroupObj || isPlainImageObj)) {
16588
+ if (isActiveSelection && isActiveSelectionSideHandle && (isCropGroupObj || isPlainImageObj)) {
16595
16589
  const childLocalAngleSrc = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? 0;
16596
16590
  const normAng = (childLocalAngleSrc % 360 + 360) % 360;
16597
16591
  const isRotatedImg = Math.min(normAng, 360 - normAng) > 0.5;
@@ -16641,10 +16635,7 @@ const PageCanvas = forwardRef(
16641
16635
  });
16642
16636
  }
16643
16637
  if (isActiveSelection && (obj instanceof fabric.FabricImage || obj instanceof fabric.Group && obj.__cropGroup)) {
16644
- const restore = activeSelectionFlipRestores.find((entry) => entry.obj === obj);
16645
- if (restore) {
16646
- restore.worldAngle = Number.isFinite(elementUpdate.angle) ? elementUpdate.angle : persistedAngle;
16647
- }
16638
+ activeSelectionFlipRestores.push({ obj, flipX: persistedFlipX, flipY: persistedFlipY, angle: elementUpdate.angle });
16648
16639
  }
16649
16640
  if (isActiveSelection) {
16650
16641
  logRotGroupImageDrift("store-update-child", {
@@ -16742,14 +16733,14 @@ const PageCanvas = forwardRef(
16742
16733
  skipActiveSelectionBakeOnClearRef.current = true;
16743
16734
  try {
16744
16735
  for (const restore of activeSelectionFlipRestores) {
16745
- restorePersistedFlipFlagsOnly(restore.obj, restore.flipX, restore.flipY);
16736
+ restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY, restore.angle);
16746
16737
  }
16747
16738
  fabricCanvas.discardActiveObject();
16748
16739
  } finally {
16749
16740
  skipActiveSelectionBakeOnClearRef.current = false;
16750
16741
  }
16751
16742
  for (const restore of activeSelectionFlipRestores) {
16752
- restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY);
16743
+ restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY, restore.angle);
16753
16744
  }
16754
16745
  for (const bake of pendingCropGroupFrameBakes) {
16755
16746
  const ct = bake.obj.__cropData;
@@ -16770,9 +16761,6 @@ const PageCanvas = forwardRef(
16770
16761
  updateCoverLayout(bake.obj);
16771
16762
  bake.obj.setCoords();
16772
16763
  }
16773
- for (const restore of activeSelectionFlipRestores) {
16774
- restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY);
16775
- }
16776
16764
  if (membersToReselect.length > 1) {
16777
16765
  const newSel = new fabric.ActiveSelection(membersToReselect, { canvas: fabricCanvas });
16778
16766
  if (wasGroupSel) restoreGroupSelectionVisualState(newSel, wasGroupSel);
@@ -16830,10 +16818,6 @@ const PageCanvas = forwardRef(
16830
16818
  if (t instanceof fabric.ActiveSelection) {
16831
16819
  for (const child of t.getObjects()) {
16832
16820
  delete child.__asLiveOrigAngle;
16833
- delete child.__asLiveOrigFlipX;
16834
- delete child.__asLiveOrigFlipY;
16835
- delete child.__asLiveOrigScaleX;
16836
- delete child.__asLiveOrigScaleY;
16837
16821
  delete child.__asLiveGestureKey;
16838
16822
  delete child.__asLiveWorldAngle;
16839
16823
  delete child.__asLiveWorldCenterX;
@@ -25944,9 +25928,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25944
25928
  }
25945
25929
  return svgString;
25946
25930
  }
25947
- const resolvedPackageVersion = "0.5.448";
25931
+ const resolvedPackageVersion = "0.5.450";
25948
25932
  const PACKAGE_VERSION = resolvedPackageVersion;
25949
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.448";
25933
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.450";
25950
25934
  const roundParityValue = (value) => {
25951
25935
  if (typeof value !== "number") return value;
25952
25936
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26760,7 +26744,7 @@ class PixldocsRenderer {
26760
26744
  await this.waitForCanvasScene(container, cloned, i);
26761
26745
  }
26762
26746
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26763
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-T3FZHnkS.js");
26747
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Ds3M_wlL.js");
26764
26748
  const prepared = preparePagesForExport(
26765
26749
  cloned.pages,
26766
26750
  canvasWidth,
@@ -29080,7 +29064,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29080
29064
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29081
29065
  sanitizeSvgTreeForPdf(svgToDraw);
29082
29066
  try {
29083
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-T3FZHnkS.js");
29067
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Ds3M_wlL.js");
29084
29068
  try {
29085
29069
  await logTextMeasurementDiagnostic(svgToDraw);
29086
29070
  } catch {
@@ -29480,4 +29464,4 @@ export {
29480
29464
  buildTeaserBlurFlatKeys as y,
29481
29465
  collectFontDescriptorsFromConfig as z
29482
29466
  };
29483
- //# sourceMappingURL=index-BruY5wZV.js.map
29467
+ //# sourceMappingURL=index-BIyCaEvT.js.map