@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.
@@ -11711,13 +11711,13 @@ const angleDistanceDeg = (a, b) => {
11711
11711
  const delta = Math.abs(((a - b) % 360 + 540) % 360 - 180);
11712
11712
  return Number.isFinite(delta) ? delta : Number.POSITIVE_INFINITY;
11713
11713
  };
11714
- const normalizeMatrixForPersistedFlip = (matrix, persistedFlipX, persistedFlipY, expectedCleanAngle) => {
11714
+ const stripPersistedFlipForStableAngle = (matrix, persistedFlipX, persistedFlipY, expectedCleanAngle) => {
11715
11715
  if (!persistedFlipX && !persistedFlipY) return matrix;
11716
- if (!Number.isFinite(expectedCleanAngle)) return matrix;
11717
- const toggledVisual = toggleLogicalFlipInMatrix(matrix, persistedFlipX, persistedFlipY);
11718
- const cleanIfMatrixAlreadyHasFlip = fabric__namespace.util.qrDecompose(toggleLogicalFlipInMatrix(matrix, persistedFlipX, persistedFlipY)).angle ?? 0;
11719
- const cleanIfMatrixLostFlip = fabric__namespace.util.qrDecompose(matrix).angle ?? 0;
11720
- return angleDistanceDeg(cleanIfMatrixLostFlip, expectedCleanAngle) + 0.1 < angleDistanceDeg(cleanIfMatrixAlreadyHasFlip, expectedCleanAngle) ? toggledVisual : matrix;
11716
+ const toggled = toggleLogicalFlipInMatrix(matrix, persistedFlipX, persistedFlipY);
11717
+ if (!Number.isFinite(expectedCleanAngle)) return toggled;
11718
+ const asIsAngle = fabric__namespace.util.qrDecompose(matrix).angle ?? 0;
11719
+ const toggledAngle = fabric__namespace.util.qrDecompose(toggled).angle ?? 0;
11720
+ return angleDistanceDeg(toggledAngle, expectedCleanAngle) <= angleDistanceDeg(asIsAngle, expectedCleanAngle) ? toggled : matrix;
11721
11721
  };
11722
11722
  function applyWarpAwareSelectionBorders(selection) {
11723
11723
  var _a2;
@@ -14662,7 +14662,7 @@ const PageCanvas = react.forwardRef(
14662
14662
  fabricCanvas.on("selection:cleared", () => {
14663
14663
  });
14664
14664
  fabricCanvas.on("object:scaling", (e) => {
14665
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
14665
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
14666
14666
  if (!isActiveRef.current) return;
14667
14667
  const t = e.target;
14668
14668
  if (t) lastResizeScaleTargetRef.current = t;
@@ -14957,10 +14957,17 @@ const PageCanvas = react.forwardRef(
14957
14957
  child.__asLiveGestureKey = liveGestureKey;
14958
14958
  const childIdForAngle = getObjectId(child);
14959
14959
  const sourceChildForAngle = childIdForAngle ? elementsRef.current.find((el) => el.id === childIdForAngle) : null;
14960
- const isFlippedImageLikeChild = (child instanceof fabric__namespace.FabricImage || child instanceof fabric__namespace.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);
14960
+ const persistedChildFlipX = (sourceChildForAngle == null ? void 0 : sourceChildForAngle.flipX) ?? child.flipX ?? false;
14961
+ const persistedChildFlipY = (sourceChildForAngle == null ? void 0 : sourceChildForAngle.flipY) ?? child.flipY ?? false;
14962
+ const isFlippedImageLikeChild = (child instanceof fabric__namespace.FabricImage || child instanceof fabric__namespace.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) && !!(persistedChildFlipX || persistedChildFlipY) && Number.isFinite(sourceChildForAngle == null ? void 0 : sourceChildForAngle.angle);
14963
+ if (child instanceof fabric__namespace.FabricImage || child instanceof fabric__namespace.Group && (child.__cropGroup || ((_n = child._ct) == null ? void 0 : _n.isCropGroup))) {
14964
+ child.set({ flipX: persistedChildFlipX, flipY: persistedChildFlipY });
14965
+ child.__asLivePersistedFlipX = persistedChildFlipX;
14966
+ child.__asLivePersistedFlipY = persistedChildFlipY;
14967
+ }
14961
14968
  child.__asLiveOrigAngle = isFlippedImageLikeChild ? sourceChildForAngle.angle ?? 0 : Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14962
14969
  }
14963
- if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_n = child._ct) == null ? void 0 : _n.isCropGroup))) {
14970
+ if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_o = child._ct) == null ? void 0 : _o.isCropGroup))) {
14964
14971
  const ct = child.__cropData;
14965
14972
  if (!ct) continue;
14966
14973
  if (child.__asLiveOrigAngle == null) {
@@ -15012,6 +15019,8 @@ const PageCanvas = react.forwardRef(
15012
15019
  child._set("scaleY", decC.scaleY);
15013
15020
  child._set("skewX", decC.skewX);
15014
15021
  child._set("skewY", decC.skewY);
15022
+ child._set("flipX", child.__asLivePersistedFlipX ?? child.flipX ?? false);
15023
+ child._set("flipY", child.__asLivePersistedFlipY ?? child.flipY ?? false);
15015
15024
  } catch {
15016
15025
  }
15017
15026
  try {
@@ -15069,6 +15078,8 @@ const PageCanvas = react.forwardRef(
15069
15078
  child._set("scaleY", decI.scaleY);
15070
15079
  child._set("skewX", decI.skewX);
15071
15080
  child._set("skewY", decI.skewY);
15081
+ child._set("flipX", child.__asLivePersistedFlipX ?? child.flipX ?? false);
15082
+ child._set("flipY", child.__asLivePersistedFlipY ?? child.flipY ?? false);
15072
15083
  } catch {
15073
15084
  }
15074
15085
  child.setCoords();
@@ -15129,7 +15140,7 @@ const PageCanvas = react.forwardRef(
15129
15140
  child.dirty = true;
15130
15141
  didReflowTextChild = true;
15131
15142
  }
15132
- if (isXSide && ((_o = groupShiftReflowSnapshotRef.current) == null ? void 0 : _o.selection) === obj) {
15143
+ if (isXSide && ((_p = groupShiftReflowSnapshotRef.current) == null ? void 0 : _p.selection) === obj) {
15133
15144
  const snap = groupShiftReflowSnapshotRef.current;
15134
15145
  const anchorEntry = snap.children[0];
15135
15146
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -15291,7 +15302,7 @@ const PageCanvas = react.forwardRef(
15291
15302
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
15292
15303
  if (drilledGroupIdRef.current) {
15293
15304
  try {
15294
- (_p = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _p.call(fabricCanvas);
15305
+ (_q = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _q.call(fabricCanvas);
15295
15306
  } catch {
15296
15307
  }
15297
15308
  }
@@ -15964,12 +15975,15 @@ const PageCanvas = react.forwardRef(
15964
15975
  360 - Math.abs(currentSelAngle - startSelAngle)
15965
15976
  );
15966
15977
  const hadRotation = isActiveSelection && activeObj && angleDelta > 0.01;
15967
- if (!hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
15978
+ const isMoveOnlyLogicalGroupGesture = !hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1);
15979
+ if (isMoveOnlyLogicalGroupGesture || !hadScale && !hadRotation && activeGroupSelectionId === groupToMove.id) {
15968
15980
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
15969
- const newLeft = (groupToMove.left ?? 0) + deltaX;
15970
- const newTop = (groupToMove.top ?? 0) + deltaY;
15971
- updateNodeStore(groupToMove.id, { left: newLeft, top: newTop }, { recordHistory: false, skipLayoutRecalc: true });
15972
- commitHistoryStore();
15981
+ if (isMoveOnlyLogicalGroupGesture) {
15982
+ const newLeft = (groupToMove.left ?? 0) + deltaX;
15983
+ const newTop = (groupToMove.top ?? 0) + deltaY;
15984
+ updateNodeStore(groupToMove.id, { left: newLeft, top: newTop }, { recordHistory: false, skipLayoutRecalc: true });
15985
+ commitHistoryStore();
15986
+ }
15973
15987
  pendingGroupDrillInRef.current = null;
15974
15988
  fabricCanvas.__activeEditingGroupId = null;
15975
15989
  setDrilledGroupBounds(null);
@@ -16527,17 +16541,17 @@ const PageCanvas = react.forwardRef(
16527
16541
  const persistedFlipY = (sourceElement == null ? void 0 : sourceElement.flipY) ?? objectFlipY;
16528
16542
  const isActiveSelectionResizeGesture = activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb" || activeSelectionResizeHandle === "tl" || activeSelectionResizeHandle === "tr" || activeSelectionResizeHandle === "bl" || activeSelectionResizeHandle === "br";
16529
16543
  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;
16530
- const normalizedFinalAbsoluteMatrix = normalizeMatrixForPersistedFlip(
16531
- toggleLogicalFlipInMatrix(
16532
- finalAbsoluteMatrix,
16533
- objectFlipX !== persistedFlipX,
16534
- objectFlipY !== persistedFlipY
16535
- ),
16544
+ const matrixWithPersistedFlipState = toggleLogicalFlipInMatrix(
16545
+ finalAbsoluteMatrix,
16546
+ objectFlipX !== persistedFlipX,
16547
+ objectFlipY !== persistedFlipY
16548
+ );
16549
+ const cleanTransformMatrix = stripPersistedFlipForStableAngle(
16550
+ matrixWithPersistedFlipState,
16536
16551
  persistedFlipX,
16537
16552
  persistedFlipY,
16538
16553
  expectedCleanAngle
16539
16554
  );
16540
- const cleanTransformMatrix = toggleLogicalFlipInMatrix(normalizedFinalAbsoluteMatrix, persistedFlipX, persistedFlipY);
16541
16555
  const persistedDecomposed = fabric__namespace.util.qrDecompose(cleanTransformMatrix);
16542
16556
  const elementUpdate = {
16543
16557
  left: storePos.left,
@@ -16858,6 +16872,8 @@ const PageCanvas = react.forwardRef(
16858
16872
  delete child.__asLiveParentWorldAngle;
16859
16873
  delete child.__asLiveFinalW;
16860
16874
  delete child.__asLiveFinalH;
16875
+ delete child.__asLivePersistedFlipX;
16876
+ delete child.__asLivePersistedFlipY;
16861
16877
  }
16862
16878
  }
16863
16879
  } catch {
@@ -25961,9 +25977,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25961
25977
  }
25962
25978
  return svgString;
25963
25979
  }
25964
- const resolvedPackageVersion = "0.5.451";
25980
+ const resolvedPackageVersion = "0.5.452";
25965
25981
  const PACKAGE_VERSION = resolvedPackageVersion;
25966
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.451";
25982
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.452";
25967
25983
  const roundParityValue = (value) => {
25968
25984
  if (typeof value !== "number") return value;
25969
25985
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26777,7 +26793,7 @@ class PixldocsRenderer {
26777
26793
  await this.waitForCanvasScene(container, cloned, i);
26778
26794
  }
26779
26795
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26780
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-a8L9h6E3.cjs"));
26796
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DLdSAaBB.cjs"));
26781
26797
  const prepared = preparePagesForExport(
26782
26798
  cloned.pages,
26783
26799
  canvasWidth,
@@ -29097,7 +29113,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29097
29113
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29098
29114
  sanitizeSvgTreeForPdf(svgToDraw);
29099
29115
  try {
29100
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-a8L9h6E3.cjs"));
29116
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DLdSAaBB.cjs"));
29101
29117
  try {
29102
29118
  await logTextMeasurementDiagnostic(svgToDraw);
29103
29119
  } catch {
@@ -29494,4 +29510,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29494
29510
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29495
29511
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29496
29512
  exports.warmTemplateFromForm = warmTemplateFromForm;
29497
- //# sourceMappingURL=index-xHv8_Y1M.cjs.map
29513
+ //# sourceMappingURL=index-L5Rj-oYv.cjs.map