@pixldocs/canvas-renderer 0.5.448 → 0.5.449

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,34 +11646,25 @@ 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 });
11663
11666
  };
11664
- const restorePersistedFlipState = (obj, flipX, flipY, angle) => {
11665
- const sx = Math.abs(Number(obj.scaleX ?? 1)) || 1;
11666
- 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;
11667
+ const restorePersistedFlipState = (obj, flipX, flipY) => {
11677
11668
  const sx = Math.abs(Number(obj.scaleX ?? 1)) || 1;
11678
11669
  const sy = Math.abs(Number(obj.scaleY ?? 1)) || 1;
11679
11670
  obj.set({ scaleX: sx, scaleY: sy, flipX, flipY });
@@ -11787,16 +11778,11 @@ function applyWarpAwareSelectionBorders(selection) {
11787
11778
  selection.calcTransformMatrix()
11788
11779
  );
11789
11780
  kids.forEach((k, index) => {
11790
- var _a3;
11791
11781
  const beforeRestore = summarizeRotDriftObject(k);
11792
11782
  const localMatrix = fabric.util.multiplyTransformMatrices(
11793
11783
  invSelection,
11794
11784
  worldMatrices[index]
11795
11785
  );
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
11786
  const savedLayout = k.layoutManager;
11801
11787
  try {
11802
11788
  if (savedLayout) k.layoutManager = void 0;
@@ -11806,9 +11792,6 @@ function applyWarpAwareSelectionBorders(selection) {
11806
11792
  );
11807
11793
  const expectedCenter = new fabric.Point(decomposed.translateX, decomposed.translateY);
11808
11794
  k.setPositionByOrigin(expectedCenter, "center", "center");
11809
- if (isImageLikeKid && (persistedKidFlipX || persistedKidFlipY)) {
11810
- restorePersistedFlipState(k, persistedKidFlipX, persistedKidFlipY, expectedCleanKidAngle);
11811
- }
11812
11795
  } finally {
11813
11796
  if (savedLayout) k.layoutManager = savedLayout;
11814
11797
  }
@@ -14649,7 +14632,7 @@ const PageCanvas = forwardRef(
14649
14632
  fabricCanvas.on("selection:cleared", () => {
14650
14633
  });
14651
14634
  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;
14635
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
14653
14636
  if (!isActiveRef.current) return;
14654
14637
  const t = e.target;
14655
14638
  if (t) lastResizeScaleTargetRef.current = t;
@@ -14880,66 +14863,11 @@ const PageCanvas = forwardRef(
14880
14863
  };
14881
14864
  }
14882
14865
  }
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
14866
  if (obj instanceof fabric.ActiveSelection && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
14939
14867
  const isXSide = corner === "ml" || corner === "mr";
14940
14868
  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;
14869
+ const startSx = Math.abs(Number(((_g = _cur == null ? void 0 : _cur.original) == null ? void 0 : _g.scaleX) ?? 1)) || 1;
14870
+ const startSy = Math.abs(Number(((_h = _cur == null ? void 0 : _cur.original) == null ? void 0 : _h.scaleY) ?? 1)) || 1;
14943
14871
  const sAxis = isXSide ? Math.abs((obj.scaleX ?? 1) / startSx) : Math.abs((obj.scaleY ?? 1) / startSy);
14944
14872
  if (sAxis > 1e-3) {
14945
14873
  const captureAsLiveWorldSnapshot = (childObj, liveW, liveH) => {
@@ -14958,13 +14886,13 @@ const PageCanvas = forwardRef(
14958
14886
  } catch {
14959
14887
  }
14960
14888
  };
14961
- if (isXSide && ((_o = groupShiftReflowSnapshotRef.current) == null ? void 0 : _o.selection) !== obj) {
14889
+ if (isXSide && ((_i = groupShiftReflowSnapshotRef.current) == null ? void 0 : _i.selection) !== obj) {
14962
14890
  groupShiftReflowSnapshotRef.current = null;
14963
14891
  const logicalGroupId = obj.__pixldocsGroupSelection;
14964
14892
  if (logicalGroupId) {
14965
14893
  try {
14966
14894
  const state = useEditorStore.getState();
14967
- const pageChildren2 = ((_p = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _p.children) ?? [];
14895
+ const pageChildren2 = ((_j = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _j.children) ?? [];
14968
14896
  const groupNode = findNodeById(pageChildren2, logicalGroupId);
14969
14897
  if (groupNode && isGroup(groupNode) && !isStackLayoutMode(groupNode.layoutMode)) {
14970
14898
  const entries = obj.getObjects().map((c) => ({
@@ -14994,50 +14922,124 @@ const PageCanvas = forwardRef(
14994
14922
  const asRect0 = obj.getBoundingRect();
14995
14923
  let didReflowTextChild = false;
14996
14924
  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}`;
14925
+ 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
14926
  if (child.__asLiveGestureKey !== liveGestureKey) {
14999
14927
  child.__asLiveGestureKey = liveGestureKey;
15000
14928
  child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
15001
- child.__asLiveOrigFlipX = !!child.flipX;
15002
- child.__asLiveOrigFlipY = !!child.flipY;
15003
14929
  }
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;
14930
+ if (child instanceof fabric.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) {
14931
+ const ct = child.__cropData;
14932
+ if (!ct) continue;
14933
+ if (child.__asLiveOrigAngle == null) {
14934
+ child.__asLiveOrigAngle = child.angle ?? 0;
14935
+ }
14936
+ const childAngleDegC = child.__asLiveOrigAngle;
14937
+ const asSxC = isXSide ? sAxis : 1;
14938
+ const asSyC = isXSide ? 1 : sAxis;
14939
+ const thetaC = fabric.util.degreesToRadians(childAngleDegC);
14940
+ const cosTC = Math.cos(thetaC);
14941
+ const sinTC = Math.sin(thetaC);
14942
+ const sLocalC = isXSide ? asSxC * cosTC * cosTC + sinTC * sinTC : asSyC * cosTC * cosTC + sinTC * sinTC;
14943
+ if (isXSide) {
14944
+ if (child.__asLiveOrigW == null) {
14945
+ const baseW = child.width ?? ct.frameW ?? 0;
14946
+ child.__asLiveOrigW = baseW * (child.scaleX ?? 1);
14947
+ }
14948
+ const origW = child.__asLiveOrigW;
14949
+ const newW = Math.max(20, origW * sLocalC);
14950
+ if (Math.abs((child.width ?? 0) - newW) > 0.5) {
14951
+ ct.frameW = newW;
14952
+ child._set("width", newW);
14953
+ }
14954
+ } else {
14955
+ if (child.__asLiveOrigH == null) {
14956
+ const baseH = child.height ?? ct.frameH ?? 0;
14957
+ child.__asLiveOrigH = baseH * (child.scaleY ?? 1);
14958
+ }
14959
+ const origH = child.__asLiveOrigH;
14960
+ const newH = Math.max(20, origH * sLocalC);
14961
+ if (Math.abs((child.height ?? 0) - newH) > 0.5) {
14962
+ ct.frameH = newH;
14963
+ child._set("height", newH);
14964
+ }
14965
+ }
15021
14966
  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));
14967
+ const invC = [1 / asSxC, 0, 0, 1 / asSyC, 0, 0];
14968
+ const RthetaC = fabric.util.composeMatrix({
14969
+ angle: childAngleDegC,
14970
+ scaleX: 1,
14971
+ scaleY: 1,
14972
+ translateX: 0,
14973
+ translateY: 0
14974
+ });
14975
+ const MC = fabric.util.multiplyTransformMatrices(invC, RthetaC);
14976
+ const decC = fabric.util.qrDecompose(MC);
14977
+ child._set("angle", decC.angle);
14978
+ child._set("scaleX", decC.scaleX);
14979
+ child._set("scaleY", decC.scaleY);
14980
+ child._set("skewX", decC.skewX);
14981
+ child._set("skewY", decC.skewY);
14982
+ } catch {
14983
+ }
14984
+ try {
14985
+ updateCoverLayout(child);
15037
14986
  } catch {
15038
14987
  }
15039
- captureAsLiveWorldSnapshot(child, liveW, liveH);
15040
14988
  child.setCoords();
14989
+ captureAsLiveWorldSnapshot(child, ct.frameW ?? child.width ?? 0, ct.frameH ?? child.height ?? 0);
14990
+ child.dirty = true;
14991
+ continue;
14992
+ }
14993
+ if (child instanceof fabric.FabricImage && !child.__cropGroup && !child.smartElementType) {
14994
+ if (child.__asLiveOrigAngle == null) {
14995
+ child.__asLiveOrigAngle = child.angle ?? 0;
14996
+ }
14997
+ const childAngleDegI = child.__asLiveOrigAngle;
14998
+ const asSxI = isXSide ? sAxis : 1;
14999
+ const asSyI = isXSide ? 1 : sAxis;
15000
+ const thetaI = fabric.util.degreesToRadians(childAngleDegI);
15001
+ const cosTI = Math.cos(thetaI);
15002
+ const sinTI = Math.sin(thetaI);
15003
+ const sLocalI = isXSide ? asSxI * cosTI * cosTI + sinTI * sinTI : asSyI * cosTI * cosTI + sinTI * sinTI;
15004
+ if (isXSide) {
15005
+ if (child.__asLiveOrigW == null) {
15006
+ child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
15007
+ }
15008
+ const origW = child.__asLiveOrigW;
15009
+ const newW = Math.max(1, origW * sLocalI);
15010
+ if (Math.abs((child.width ?? 0) - newW) > 0.5) {
15011
+ child._set("width", newW);
15012
+ }
15013
+ } else {
15014
+ if (child.__asLiveOrigH == null) {
15015
+ child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
15016
+ }
15017
+ const origH = child.__asLiveOrigH;
15018
+ const newH = Math.max(1, origH * sLocalI);
15019
+ if (Math.abs((child.height ?? 0) - newH) > 0.5) {
15020
+ child._set("height", newH);
15021
+ }
15022
+ }
15023
+ try {
15024
+ const invI = [1 / asSxI, 0, 0, 1 / asSyI, 0, 0];
15025
+ const RthetaI = fabric.util.composeMatrix({
15026
+ angle: childAngleDegI,
15027
+ scaleX: 1,
15028
+ scaleY: 1,
15029
+ translateX: 0,
15030
+ translateY: 0
15031
+ });
15032
+ const MI = fabric.util.multiplyTransformMatrices(invI, RthetaI);
15033
+ const decI = fabric.util.qrDecompose(MI);
15034
+ child._set("angle", decI.angle);
15035
+ child._set("scaleX", decI.scaleX);
15036
+ child._set("scaleY", decI.scaleY);
15037
+ child._set("skewX", decI.skewX);
15038
+ child._set("skewY", decI.skewY);
15039
+ } catch {
15040
+ }
15041
+ child.setCoords();
15042
+ captureAsLiveWorldSnapshot(child, child.width ?? 0, child.height ?? 0);
15041
15043
  child.dirty = true;
15042
15044
  continue;
15043
15045
  }
@@ -15094,7 +15096,7 @@ const PageCanvas = forwardRef(
15094
15096
  child.dirty = true;
15095
15097
  didReflowTextChild = true;
15096
15098
  }
15097
- if (isXSide && ((_v = groupShiftReflowSnapshotRef.current) == null ? void 0 : _v.selection) === obj) {
15099
+ if (isXSide && ((_n = groupShiftReflowSnapshotRef.current) == null ? void 0 : _n.selection) === obj) {
15098
15100
  const snap = groupShiftReflowSnapshotRef.current;
15099
15101
  const anchorEntry = snap.children[0];
15100
15102
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -15256,7 +15258,7 @@ const PageCanvas = forwardRef(
15256
15258
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
15257
15259
  if (drilledGroupIdRef.current) {
15258
15260
  try {
15259
- (_w = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _w.call(fabricCanvas);
15261
+ (_o = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _o.call(fabricCanvas);
15260
15262
  } catch {
15261
15263
  }
15262
15264
  }
@@ -15483,8 +15485,6 @@ const PageCanvas = forwardRef(
15483
15485
  for (const child of t.getObjects()) {
15484
15486
  delete child.__asLiveOrigW;
15485
15487
  delete child.__asLiveOrigH;
15486
- delete child.__asLiveOrigScaleX;
15487
- delete child.__asLiveOrigScaleY;
15488
15488
  delete child.__asLiveRotSnap;
15489
15489
  delete child.__asLiveGestureKey;
15490
15490
  }
@@ -16187,12 +16187,10 @@ const PageCanvas = forwardRef(
16187
16187
  const ownSy = Math.abs(obj.scaleY ?? 1);
16188
16188
  const bakedW = Math.max(1, intrinsicWidth * ownSx * (imgIsXSide ? sLocalI : 1));
16189
16189
  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
16190
  try {
16193
16191
  obj.set({
16194
- width: cleanW,
16195
- height: cleanH,
16192
+ width: bakedW,
16193
+ height: bakedH,
16196
16194
  scaleX: 1,
16197
16195
  scaleY: 1,
16198
16196
  skewX: 0,
@@ -16211,8 +16209,8 @@ const PageCanvas = forwardRef(
16211
16209
  obj.setCoords();
16212
16210
  } catch {
16213
16211
  }
16214
- finalWidth = cleanW;
16215
- finalHeight = cleanH;
16212
+ finalWidth = Math.max(1, Number(obj.__asLiveFinalW ?? bakedW));
16213
+ finalHeight = Math.max(1, Number(obj.__asLiveFinalH ?? bakedH));
16216
16214
  finalScaleX = 1;
16217
16215
  finalScaleY = 1;
16218
16216
  const worldCx = Number.isFinite(obj.__asLiveWorldCenterX) ? obj.__asLiveWorldCenterX : decomposed.translateX ?? 0;
@@ -16488,9 +16486,8 @@ const PageCanvas = forwardRef(
16488
16486
  const objectFlipY = obj.flipY ?? false;
16489
16487
  const persistedFlipX = (sourceElement == null ? void 0 : sourceElement.flipX) ?? objectFlipX;
16490
16488
  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
16489
  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;
16490
+ 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
16491
  const normalizedFinalAbsoluteMatrix = normalizeMatrixForPersistedFlip(
16495
16492
  toggleLogicalFlipInMatrix(
16496
16493
  finalAbsoluteMatrix,
@@ -16504,13 +16501,7 @@ const PageCanvas = forwardRef(
16504
16501
  const cleanTransformMatrix = toggleLogicalFlipInMatrix(normalizedFinalAbsoluteMatrix, persistedFlipX, persistedFlipY);
16505
16502
  const persistedDecomposed = fabric.util.qrDecompose(cleanTransformMatrix);
16506
16503
  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
- });
16504
+ activeSelectionFlipRestores.push({ obj, flipX: persistedFlipX, flipY: persistedFlipY });
16514
16505
  }
16515
16506
  const elementUpdate = {
16516
16507
  left: storePos.left,
@@ -16591,7 +16582,7 @@ const PageCanvas = forwardRef(
16591
16582
  }
16592
16583
  const isCropGroupObj = obj instanceof fabric.Group && obj.__cropGroup;
16593
16584
  const isPlainImageObj = obj instanceof fabric.FabricImage && !obj.__cropGroup && !obj.smartElementType;
16594
- if (isActiveSelection && isActiveSelectionResizeGesture && (isCropGroupObj || isPlainImageObj)) {
16585
+ if (isActiveSelection && isActiveSelectionSideHandle && (isCropGroupObj || isPlainImageObj)) {
16595
16586
  const childLocalAngleSrc = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? 0;
16596
16587
  const normAng = (childLocalAngleSrc % 360 + 360) % 360;
16597
16588
  const isRotatedImg = Math.min(normAng, 360 - normAng) > 0.5;
@@ -16640,12 +16631,6 @@ const PageCanvas = forwardRef(
16640
16631
  objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
16641
16632
  });
16642
16633
  }
16643
- 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
- }
16648
- }
16649
16634
  if (isActiveSelection) {
16650
16635
  logRotGroupImageDrift("store-update-child", {
16651
16636
  time: Math.round(performance.now()),
@@ -16742,7 +16727,7 @@ const PageCanvas = forwardRef(
16742
16727
  skipActiveSelectionBakeOnClearRef.current = true;
16743
16728
  try {
16744
16729
  for (const restore of activeSelectionFlipRestores) {
16745
- restorePersistedFlipFlagsOnly(restore.obj, restore.flipX, restore.flipY);
16730
+ restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY);
16746
16731
  }
16747
16732
  fabricCanvas.discardActiveObject();
16748
16733
  } finally {
@@ -16770,9 +16755,6 @@ const PageCanvas = forwardRef(
16770
16755
  updateCoverLayout(bake.obj);
16771
16756
  bake.obj.setCoords();
16772
16757
  }
16773
- for (const restore of activeSelectionFlipRestores) {
16774
- restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY);
16775
- }
16776
16758
  if (membersToReselect.length > 1) {
16777
16759
  const newSel = new fabric.ActiveSelection(membersToReselect, { canvas: fabricCanvas });
16778
16760
  if (wasGroupSel) restoreGroupSelectionVisualState(newSel, wasGroupSel);
@@ -16830,10 +16812,6 @@ const PageCanvas = forwardRef(
16830
16812
  if (t instanceof fabric.ActiveSelection) {
16831
16813
  for (const child of t.getObjects()) {
16832
16814
  delete child.__asLiveOrigAngle;
16833
- delete child.__asLiveOrigFlipX;
16834
- delete child.__asLiveOrigFlipY;
16835
- delete child.__asLiveOrigScaleX;
16836
- delete child.__asLiveOrigScaleY;
16837
16815
  delete child.__asLiveGestureKey;
16838
16816
  delete child.__asLiveWorldAngle;
16839
16817
  delete child.__asLiveWorldCenterX;
@@ -25944,9 +25922,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25944
25922
  }
25945
25923
  return svgString;
25946
25924
  }
25947
- const resolvedPackageVersion = "0.5.448";
25925
+ const resolvedPackageVersion = "0.5.449";
25948
25926
  const PACKAGE_VERSION = resolvedPackageVersion;
25949
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.448";
25927
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.449";
25950
25928
  const roundParityValue = (value) => {
25951
25929
  if (typeof value !== "number") return value;
25952
25930
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26760,7 +26738,7 @@ class PixldocsRenderer {
26760
26738
  await this.waitForCanvasScene(container, cloned, i);
26761
26739
  }
26762
26740
  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");
26741
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BeSrh7Sq.js");
26764
26742
  const prepared = preparePagesForExport(
26765
26743
  cloned.pages,
26766
26744
  canvasWidth,
@@ -29080,7 +29058,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29080
29058
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29081
29059
  sanitizeSvgTreeForPdf(svgToDraw);
29082
29060
  try {
29083
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-T3FZHnkS.js");
29061
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BeSrh7Sq.js");
29084
29062
  try {
29085
29063
  await logTextMeasurementDiagnostic(svgToDraw);
29086
29064
  } catch {
@@ -29480,4 +29458,4 @@ export {
29480
29458
  buildTeaserBlurFlatKeys as y,
29481
29459
  collectFontDescriptorsFromConfig as z
29482
29460
  };
29483
- //# sourceMappingURL=index-BruY5wZV.js.map
29461
+ //# sourceMappingURL=index-CyBVRtoh.js.map