@pixldocs/canvas-renderer 0.5.451 → 0.5.452

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.
@@ -11693,13 +11693,13 @@ const angleDistanceDeg = (a, b) => {
11693
11693
  const delta = Math.abs(((a - b) % 360 + 540) % 360 - 180);
11694
11694
  return Number.isFinite(delta) ? delta : Number.POSITIVE_INFINITY;
11695
11695
  };
11696
- const normalizeMatrixForPersistedFlip = (matrix, persistedFlipX, persistedFlipY, expectedCleanAngle) => {
11696
+ const stripPersistedFlipForStableAngle = (matrix, persistedFlipX, persistedFlipY, expectedCleanAngle) => {
11697
11697
  if (!persistedFlipX && !persistedFlipY) return matrix;
11698
- if (!Number.isFinite(expectedCleanAngle)) return matrix;
11699
- const toggledVisual = toggleLogicalFlipInMatrix(matrix, persistedFlipX, persistedFlipY);
11700
- const cleanIfMatrixAlreadyHasFlip = fabric.util.qrDecompose(toggleLogicalFlipInMatrix(matrix, persistedFlipX, persistedFlipY)).angle ?? 0;
11701
- const cleanIfMatrixLostFlip = fabric.util.qrDecompose(matrix).angle ?? 0;
11702
- return angleDistanceDeg(cleanIfMatrixLostFlip, expectedCleanAngle) + 0.1 < angleDistanceDeg(cleanIfMatrixAlreadyHasFlip, expectedCleanAngle) ? toggledVisual : matrix;
11698
+ const toggled = toggleLogicalFlipInMatrix(matrix, persistedFlipX, persistedFlipY);
11699
+ if (!Number.isFinite(expectedCleanAngle)) return toggled;
11700
+ const asIsAngle = fabric.util.qrDecompose(matrix).angle ?? 0;
11701
+ const toggledAngle = fabric.util.qrDecompose(toggled).angle ?? 0;
11702
+ return angleDistanceDeg(toggledAngle, expectedCleanAngle) <= angleDistanceDeg(asIsAngle, expectedCleanAngle) ? toggled : matrix;
11703
11703
  };
11704
11704
  function applyWarpAwareSelectionBorders(selection) {
11705
11705
  var _a2;
@@ -14644,7 +14644,7 @@ const PageCanvas = forwardRef(
14644
14644
  fabricCanvas.on("selection:cleared", () => {
14645
14645
  });
14646
14646
  fabricCanvas.on("object:scaling", (e) => {
14647
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
14647
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
14648
14648
  if (!isActiveRef.current) return;
14649
14649
  const t = e.target;
14650
14650
  if (t) lastResizeScaleTargetRef.current = t;
@@ -14939,10 +14939,17 @@ const PageCanvas = forwardRef(
14939
14939
  child.__asLiveGestureKey = liveGestureKey;
14940
14940
  const childIdForAngle = getObjectId(child);
14941
14941
  const sourceChildForAngle = childIdForAngle ? elementsRef.current.find((el) => el.id === childIdForAngle) : null;
14942
- const isFlippedImageLikeChild = (child instanceof fabric.FabricImage || child instanceof fabric.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) && !!((sourceChildForAngle == null ? void 0 : sourceChildForAngle.flipX) || (sourceChildForAngle == null ? void 0 : sourceChildForAngle.flipY)) && Number.isFinite(sourceChildForAngle == null ? void 0 : sourceChildForAngle.angle);
14942
+ const persistedChildFlipX = (sourceChildForAngle == null ? void 0 : sourceChildForAngle.flipX) ?? child.flipX ?? false;
14943
+ const persistedChildFlipY = (sourceChildForAngle == null ? void 0 : sourceChildForAngle.flipY) ?? child.flipY ?? false;
14944
+ const isFlippedImageLikeChild = (child instanceof fabric.FabricImage || child instanceof fabric.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) && !!(persistedChildFlipX || persistedChildFlipY) && Number.isFinite(sourceChildForAngle == null ? void 0 : sourceChildForAngle.angle);
14945
+ if (child instanceof fabric.FabricImage || child instanceof fabric.Group && (child.__cropGroup || ((_n = child._ct) == null ? void 0 : _n.isCropGroup))) {
14946
+ child.set({ flipX: persistedChildFlipX, flipY: persistedChildFlipY });
14947
+ child.__asLivePersistedFlipX = persistedChildFlipX;
14948
+ child.__asLivePersistedFlipY = persistedChildFlipY;
14949
+ }
14943
14950
  child.__asLiveOrigAngle = isFlippedImageLikeChild ? sourceChildForAngle.angle ?? 0 : Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14944
14951
  }
14945
- if (child instanceof fabric.Group && (child.__cropGroup || ((_n = child._ct) == null ? void 0 : _n.isCropGroup))) {
14952
+ if (child instanceof fabric.Group && (child.__cropGroup || ((_o = child._ct) == null ? void 0 : _o.isCropGroup))) {
14946
14953
  const ct = child.__cropData;
14947
14954
  if (!ct) continue;
14948
14955
  if (child.__asLiveOrigAngle == null) {
@@ -14994,6 +15001,8 @@ const PageCanvas = forwardRef(
14994
15001
  child._set("scaleY", decC.scaleY);
14995
15002
  child._set("skewX", decC.skewX);
14996
15003
  child._set("skewY", decC.skewY);
15004
+ child._set("flipX", child.__asLivePersistedFlipX ?? child.flipX ?? false);
15005
+ child._set("flipY", child.__asLivePersistedFlipY ?? child.flipY ?? false);
14997
15006
  } catch {
14998
15007
  }
14999
15008
  try {
@@ -15051,6 +15060,8 @@ const PageCanvas = forwardRef(
15051
15060
  child._set("scaleY", decI.scaleY);
15052
15061
  child._set("skewX", decI.skewX);
15053
15062
  child._set("skewY", decI.skewY);
15063
+ child._set("flipX", child.__asLivePersistedFlipX ?? child.flipX ?? false);
15064
+ child._set("flipY", child.__asLivePersistedFlipY ?? child.flipY ?? false);
15054
15065
  } catch {
15055
15066
  }
15056
15067
  child.setCoords();
@@ -15111,7 +15122,7 @@ const PageCanvas = forwardRef(
15111
15122
  child.dirty = true;
15112
15123
  didReflowTextChild = true;
15113
15124
  }
15114
- if (isXSide && ((_o = groupShiftReflowSnapshotRef.current) == null ? void 0 : _o.selection) === obj) {
15125
+ if (isXSide && ((_p = groupShiftReflowSnapshotRef.current) == null ? void 0 : _p.selection) === obj) {
15115
15126
  const snap = groupShiftReflowSnapshotRef.current;
15116
15127
  const anchorEntry = snap.children[0];
15117
15128
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -15273,7 +15284,7 @@ const PageCanvas = forwardRef(
15273
15284
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
15274
15285
  if (drilledGroupIdRef.current) {
15275
15286
  try {
15276
- (_p = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _p.call(fabricCanvas);
15287
+ (_q = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _q.call(fabricCanvas);
15277
15288
  } catch {
15278
15289
  }
15279
15290
  }
@@ -15946,12 +15957,15 @@ const PageCanvas = forwardRef(
15946
15957
  360 - Math.abs(currentSelAngle - startSelAngle)
15947
15958
  );
15948
15959
  const hadRotation = isActiveSelection && activeObj && angleDelta > 0.01;
15949
- if (!hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
15960
+ const isMoveOnlyLogicalGroupGesture = !hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1);
15961
+ if (isMoveOnlyLogicalGroupGesture || !hadScale && !hadRotation && activeGroupSelectionId === groupToMove.id) {
15950
15962
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
15951
- const newLeft = (groupToMove.left ?? 0) + deltaX;
15952
- const newTop = (groupToMove.top ?? 0) + deltaY;
15953
- updateNodeStore(groupToMove.id, { left: newLeft, top: newTop }, { recordHistory: false, skipLayoutRecalc: true });
15954
- commitHistoryStore();
15963
+ if (isMoveOnlyLogicalGroupGesture) {
15964
+ const newLeft = (groupToMove.left ?? 0) + deltaX;
15965
+ const newTop = (groupToMove.top ?? 0) + deltaY;
15966
+ updateNodeStore(groupToMove.id, { left: newLeft, top: newTop }, { recordHistory: false, skipLayoutRecalc: true });
15967
+ commitHistoryStore();
15968
+ }
15955
15969
  pendingGroupDrillInRef.current = null;
15956
15970
  fabricCanvas.__activeEditingGroupId = null;
15957
15971
  setDrilledGroupBounds(null);
@@ -16509,17 +16523,17 @@ const PageCanvas = forwardRef(
16509
16523
  const persistedFlipY = (sourceElement == null ? void 0 : sourceElement.flipY) ?? objectFlipY;
16510
16524
  const isActiveSelectionResizeGesture = activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb" || activeSelectionResizeHandle === "tl" || activeSelectionResizeHandle === "tr" || activeSelectionResizeHandle === "bl" || activeSelectionResizeHandle === "br";
16511
16525
  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;
16512
- const normalizedFinalAbsoluteMatrix = normalizeMatrixForPersistedFlip(
16513
- toggleLogicalFlipInMatrix(
16514
- finalAbsoluteMatrix,
16515
- objectFlipX !== persistedFlipX,
16516
- objectFlipY !== persistedFlipY
16517
- ),
16526
+ const matrixWithPersistedFlipState = toggleLogicalFlipInMatrix(
16527
+ finalAbsoluteMatrix,
16528
+ objectFlipX !== persistedFlipX,
16529
+ objectFlipY !== persistedFlipY
16530
+ );
16531
+ const cleanTransformMatrix = stripPersistedFlipForStableAngle(
16532
+ matrixWithPersistedFlipState,
16518
16533
  persistedFlipX,
16519
16534
  persistedFlipY,
16520
16535
  expectedCleanAngle
16521
16536
  );
16522
- const cleanTransformMatrix = toggleLogicalFlipInMatrix(normalizedFinalAbsoluteMatrix, persistedFlipX, persistedFlipY);
16523
16537
  const persistedDecomposed = fabric.util.qrDecompose(cleanTransformMatrix);
16524
16538
  const elementUpdate = {
16525
16539
  left: storePos.left,
@@ -16840,6 +16854,8 @@ const PageCanvas = forwardRef(
16840
16854
  delete child.__asLiveParentWorldAngle;
16841
16855
  delete child.__asLiveFinalW;
16842
16856
  delete child.__asLiveFinalH;
16857
+ delete child.__asLivePersistedFlipX;
16858
+ delete child.__asLivePersistedFlipY;
16843
16859
  }
16844
16860
  }
16845
16861
  } catch {
@@ -25943,9 +25959,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25943
25959
  }
25944
25960
  return svgString;
25945
25961
  }
25946
- const resolvedPackageVersion = "0.5.451";
25962
+ const resolvedPackageVersion = "0.5.452";
25947
25963
  const PACKAGE_VERSION = resolvedPackageVersion;
25948
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.451";
25964
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.452";
25949
25965
  const roundParityValue = (value) => {
25950
25966
  if (typeof value !== "number") return value;
25951
25967
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26759,7 +26775,7 @@ class PixldocsRenderer {
26759
26775
  await this.waitForCanvasScene(container, cloned, i);
26760
26776
  }
26761
26777
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26762
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-hQLfUhri.js");
26778
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-IArzJ4nC.js");
26763
26779
  const prepared = preparePagesForExport(
26764
26780
  cloned.pages,
26765
26781
  canvasWidth,
@@ -29079,7 +29095,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29079
29095
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29080
29096
  sanitizeSvgTreeForPdf(svgToDraw);
29081
29097
  try {
29082
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-hQLfUhri.js");
29098
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-IArzJ4nC.js");
29083
29099
  try {
29084
29100
  await logTextMeasurementDiagnostic(svgToDraw);
29085
29101
  } catch {
@@ -29479,4 +29495,4 @@ export {
29479
29495
  buildTeaserBlurFlatKeys as y,
29480
29496
  collectFontDescriptorsFromConfig as z
29481
29497
  };
29482
- //# sourceMappingURL=index-CmdwL3tr.js.map
29498
+ //# sourceMappingURL=index-B4jCHYd5.js.map