@pixldocs/canvas-renderer 0.5.445 → 0.5.446

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.
@@ -11682,7 +11682,7 @@ const applyTransformPreservingFlip = (obj, matrix) => {
11682
11682
  const restorePersistedFlipState = (obj, flipX, flipY, angle) => {
11683
11683
  const sx = Math.abs(Number(obj.scaleX ?? 1)) || 1;
11684
11684
  const sy = Math.abs(Number(obj.scaleY ?? 1)) || 1;
11685
- obj.set({ scaleX: sx, scaleY: sy, flipX, flipY, ...Number.isFinite(angle) ? { angle } : {} });
11685
+ obj.set({ scaleX: sx, scaleY: sy, skewX: 0, skewY: 0, flipX, flipY, ...Number.isFinite(angle) ? { angle } : {} });
11686
11686
  obj.setCoords();
11687
11687
  obj.dirty = true;
11688
11688
  };
@@ -11793,11 +11793,16 @@ function applyWarpAwareSelectionBorders(selection) {
11793
11793
  selection.calcTransformMatrix()
11794
11794
  );
11795
11795
  kids.forEach((k, index) => {
11796
+ var _a3;
11796
11797
  const beforeRestore = summarizeRotDriftObject(k);
11797
11798
  const localMatrix = fabric__namespace.util.multiplyTransformMatrices(
11798
11799
  invSelection,
11799
11800
  worldMatrices[index]
11800
11801
  );
11802
+ const isImageLikeKid = k instanceof fabric__namespace.FabricImage || k instanceof fabric__namespace.Group && (k.__cropGroup || ((_a3 = k._ct) == null ? void 0 : _a3.isCropGroup));
11803
+ const persistedKidFlipX = !!k.flipX;
11804
+ const persistedKidFlipY = !!k.flipY;
11805
+ const expectedCleanKidAngle = isImageLikeKid && (persistedKidFlipX || persistedKidFlipY) ? fabric__namespace.util.qrDecompose(toggleLogicalFlipInMatrix(localMatrix, persistedKidFlipX, persistedKidFlipY)).angle ?? 0 : void 0;
11801
11806
  const savedLayout = k.layoutManager;
11802
11807
  try {
11803
11808
  if (savedLayout) k.layoutManager = void 0;
@@ -11807,6 +11812,9 @@ function applyWarpAwareSelectionBorders(selection) {
11807
11812
  );
11808
11813
  const expectedCenter = new fabric__namespace.Point(decomposed.translateX, decomposed.translateY);
11809
11814
  k.setPositionByOrigin(expectedCenter, "center", "center");
11815
+ if (isImageLikeKid && (persistedKidFlipX || persistedKidFlipY)) {
11816
+ restorePersistedFlipState(k, persistedKidFlipX, persistedKidFlipY, expectedCleanKidAngle);
11817
+ }
11810
11818
  } finally {
11811
11819
  if (savedLayout) k.layoutManager = savedLayout;
11812
11820
  }
@@ -14885,22 +14893,6 @@ const PageCanvas = react.forwardRef(
14885
14893
  const startSy = Math.abs(Number(((_h = _cur == null ? void 0 : _cur.original) == null ? void 0 : _h.scaleY) ?? 1)) || 1;
14886
14894
  const sAxis = isXSide ? Math.abs((obj.scaleX ?? 1) / startSx) : Math.abs((obj.scaleY ?? 1) / startSy);
14887
14895
  if (sAxis > 1e-3) {
14888
- const captureAsLiveWorldSnapshot = (childObj, liveW, liveH) => {
14889
- try {
14890
- const selectionMatrix = obj.calcTransformMatrix();
14891
- const childMatrix = childObj.calcOwnMatrix();
14892
- const worldMatrix = fabric__namespace.util.multiplyTransformMatrices(selectionMatrix, childMatrix);
14893
- const live = fabric__namespace.util.qrDecompose(worldMatrix);
14894
- const childOrigLocalAngle = Number.isFinite(childObj.__asLiveOrigAngle) ? childObj.__asLiveOrigAngle : childObj.angle ?? 0;
14895
- childObj.__asLiveWorldAngle = (obj.angle ?? 0) + childOrigLocalAngle;
14896
- childObj.__asLiveWorldCenterX = live.translateX;
14897
- childObj.__asLiveWorldCenterY = live.translateY;
14898
- childObj.__asLiveParentWorldAngle = obj.angle ?? 0;
14899
- if (Number.isFinite(liveW)) childObj.__asLiveFinalW = liveW;
14900
- if (Number.isFinite(liveH)) childObj.__asLiveFinalH = liveH;
14901
- } catch {
14902
- }
14903
- };
14904
14896
  if (isXSide && ((_i = groupShiftReflowSnapshotRef.current) == null ? void 0 : _i.selection) !== obj) {
14905
14897
  groupShiftReflowSnapshotRef.current = null;
14906
14898
  const logicalGroupId = obj.__pixldocsGroupSelection;
@@ -14943,118 +14935,12 @@ const PageCanvas = react.forwardRef(
14943
14935
  child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14944
14936
  }
14945
14937
  if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) {
14946
- const ct = child.__cropData;
14947
- if (!ct) continue;
14948
- if (child.__asLiveOrigAngle == null) {
14949
- child.__asLiveOrigAngle = child.angle ?? 0;
14950
- }
14951
- const childAngleDegC = child.__asLiveOrigAngle;
14952
- const asSxC = isXSide ? sAxis : 1;
14953
- const asSyC = isXSide ? 1 : sAxis;
14954
- const thetaC = fabric__namespace.util.degreesToRadians(childAngleDegC);
14955
- const cosTC = Math.cos(thetaC);
14956
- const sinTC = Math.sin(thetaC);
14957
- const sLocalC = isXSide ? asSxC * cosTC * cosTC + sinTC * sinTC : asSyC * cosTC * cosTC + sinTC * sinTC;
14958
- if (isXSide) {
14959
- if (child.__asLiveOrigW == null) {
14960
- const baseW = child.width ?? ct.frameW ?? 0;
14961
- child.__asLiveOrigW = baseW * (child.scaleX ?? 1);
14962
- }
14963
- const origW = child.__asLiveOrigW;
14964
- const newW = Math.max(20, origW * sLocalC);
14965
- if (Math.abs((child.width ?? 0) - newW) > 0.5) {
14966
- ct.frameW = newW;
14967
- child._set("width", newW);
14968
- }
14969
- } else {
14970
- if (child.__asLiveOrigH == null) {
14971
- const baseH = child.height ?? ct.frameH ?? 0;
14972
- child.__asLiveOrigH = baseH * (child.scaleY ?? 1);
14973
- }
14974
- const origH = child.__asLiveOrigH;
14975
- const newH = Math.max(20, origH * sLocalC);
14976
- if (Math.abs((child.height ?? 0) - newH) > 0.5) {
14977
- ct.frameH = newH;
14978
- child._set("height", newH);
14979
- }
14980
- }
14981
- try {
14982
- const invC = [1 / asSxC, 0, 0, 1 / asSyC, 0, 0];
14983
- const RthetaC = fabric__namespace.util.composeMatrix({
14984
- angle: childAngleDegC,
14985
- scaleX: 1,
14986
- scaleY: 1,
14987
- translateX: 0,
14988
- translateY: 0
14989
- });
14990
- const MC = fabric__namespace.util.multiplyTransformMatrices(invC, RthetaC);
14991
- const decC = fabric__namespace.util.qrDecompose(MC);
14992
- child._set("angle", decC.angle);
14993
- child._set("scaleX", decC.scaleX);
14994
- child._set("scaleY", decC.scaleY);
14995
- child._set("skewX", decC.skewX);
14996
- child._set("skewY", decC.skewY);
14997
- } catch {
14998
- }
14999
- try {
15000
- updateCoverLayout(child);
15001
- } catch {
15002
- }
15003
14938
  child.setCoords();
15004
- captureAsLiveWorldSnapshot(child, ct.frameW ?? child.width ?? 0, ct.frameH ?? child.height ?? 0);
15005
14939
  child.dirty = true;
15006
14940
  continue;
15007
14941
  }
15008
14942
  if (child instanceof fabric__namespace.FabricImage && !child.__cropGroup && !child.smartElementType) {
15009
- if (child.__asLiveOrigAngle == null) {
15010
- child.__asLiveOrigAngle = child.angle ?? 0;
15011
- }
15012
- const childAngleDegI = child.__asLiveOrigAngle;
15013
- const asSxI = isXSide ? sAxis : 1;
15014
- const asSyI = isXSide ? 1 : sAxis;
15015
- const thetaI = fabric__namespace.util.degreesToRadians(childAngleDegI);
15016
- const cosTI = Math.cos(thetaI);
15017
- const sinTI = Math.sin(thetaI);
15018
- const sLocalI = isXSide ? asSxI * cosTI * cosTI + sinTI * sinTI : asSyI * cosTI * cosTI + sinTI * sinTI;
15019
- if (isXSide) {
15020
- if (child.__asLiveOrigW == null) {
15021
- child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
15022
- }
15023
- const origW = child.__asLiveOrigW;
15024
- const newW = Math.max(1, origW * sLocalI);
15025
- if (Math.abs((child.width ?? 0) - newW) > 0.5) {
15026
- child._set("width", newW);
15027
- }
15028
- } else {
15029
- if (child.__asLiveOrigH == null) {
15030
- child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
15031
- }
15032
- const origH = child.__asLiveOrigH;
15033
- const newH = Math.max(1, origH * sLocalI);
15034
- if (Math.abs((child.height ?? 0) - newH) > 0.5) {
15035
- child._set("height", newH);
15036
- }
15037
- }
15038
- try {
15039
- const invI = [1 / asSxI, 0, 0, 1 / asSyI, 0, 0];
15040
- const RthetaI = fabric__namespace.util.composeMatrix({
15041
- angle: childAngleDegI,
15042
- scaleX: 1,
15043
- scaleY: 1,
15044
- translateX: 0,
15045
- translateY: 0
15046
- });
15047
- const MI = fabric__namespace.util.multiplyTransformMatrices(invI, RthetaI);
15048
- const decI = fabric__namespace.util.qrDecompose(MI);
15049
- child._set("angle", decI.angle);
15050
- child._set("scaleX", decI.scaleX);
15051
- child._set("scaleY", decI.scaleY);
15052
- child._set("skewX", decI.skewX);
15053
- child._set("skewY", decI.skewY);
15054
- } catch {
15055
- }
15056
14943
  child.setCoords();
15057
- captureAsLiveWorldSnapshot(child, child.width ?? 0, child.height ?? 0);
15058
14944
  child.dirty = true;
15059
14945
  continue;
15060
14946
  }
@@ -25941,9 +25827,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25941
25827
  }
25942
25828
  return svgString;
25943
25829
  }
25944
- const resolvedPackageVersion = "0.5.445";
25830
+ const resolvedPackageVersion = "0.5.446";
25945
25831
  const PACKAGE_VERSION = resolvedPackageVersion;
25946
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.445";
25832
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.446";
25947
25833
  const roundParityValue = (value) => {
25948
25834
  if (typeof value !== "number") return value;
25949
25835
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26757,7 +26643,7 @@ class PixldocsRenderer {
26757
26643
  await this.waitForCanvasScene(container, cloned, i);
26758
26644
  }
26759
26645
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26760
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CuC9pjN_.cjs"));
26646
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-D7WHhcGD.cjs"));
26761
26647
  const prepared = preparePagesForExport(
26762
26648
  cloned.pages,
26763
26649
  canvasWidth,
@@ -29077,7 +28963,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29077
28963
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29078
28964
  sanitizeSvgTreeForPdf(svgToDraw);
29079
28965
  try {
29080
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CuC9pjN_.cjs"));
28966
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-D7WHhcGD.cjs"));
29081
28967
  try {
29082
28968
  await logTextMeasurementDiagnostic(svgToDraw);
29083
28969
  } catch {
@@ -29474,4 +29360,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29474
29360
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29475
29361
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29476
29362
  exports.warmTemplateFromForm = warmTemplateFromForm;
29477
- //# sourceMappingURL=index-BtExVWAT.cjs.map
29363
+ //# sourceMappingURL=index-BAQIJf_b.cjs.map