@pixldocs/canvas-renderer 0.5.450 → 0.5.451

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.
@@ -5122,7 +5122,13 @@ function localDeltaToWorld(dx, dy, angleDeg) {
5122
5122
  function getWorldAngleDeg(obj) {
5123
5123
  var _a2;
5124
5124
  try {
5125
- if (typeof obj.getTotalAngle === "function") return obj.getTotalAngle() || 0;
5125
+ let total = 0;
5126
+ let cur = obj;
5127
+ while (cur) {
5128
+ total += Number(cur.angle ?? 0) || 0;
5129
+ cur = cur.group;
5130
+ }
5131
+ if (Number.isFinite(total)) return total;
5126
5132
  const matrix = (_a2 = obj.calcTransformMatrix) == null ? void 0 : _a2.call(obj);
5127
5133
  return matrix ? fabric__namespace.util.qrDecompose(matrix).angle || 0 : obj.angle || 0;
5128
5134
  } catch {
@@ -14656,7 +14662,7 @@ const PageCanvas = react.forwardRef(
14656
14662
  fabricCanvas.on("selection:cleared", () => {
14657
14663
  });
14658
14664
  fabricCanvas.on("object:scaling", (e) => {
14659
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
14665
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
14660
14666
  if (!isActiveRef.current) return;
14661
14667
  const t = e.target;
14662
14668
  if (t) lastResizeScaleTargetRef.current = t;
@@ -14949,9 +14955,12 @@ const PageCanvas = react.forwardRef(
14949
14955
  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}`;
14950
14956
  if (child.__asLiveGestureKey !== liveGestureKey) {
14951
14957
  child.__asLiveGestureKey = liveGestureKey;
14952
- child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14958
+ const childIdForAngle = getObjectId(child);
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);
14961
+ child.__asLiveOrigAngle = isFlippedImageLikeChild ? sourceChildForAngle.angle ?? 0 : Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14953
14962
  }
14954
- if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) {
14963
+ if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_n = child._ct) == null ? void 0 : _n.isCropGroup))) {
14955
14964
  const ct = child.__cropData;
14956
14965
  if (!ct) continue;
14957
14966
  if (child.__asLiveOrigAngle == null) {
@@ -15120,7 +15129,7 @@ const PageCanvas = react.forwardRef(
15120
15129
  child.dirty = true;
15121
15130
  didReflowTextChild = true;
15122
15131
  }
15123
- if (isXSide && ((_n = groupShiftReflowSnapshotRef.current) == null ? void 0 : _n.selection) === obj) {
15132
+ if (isXSide && ((_o = groupShiftReflowSnapshotRef.current) == null ? void 0 : _o.selection) === obj) {
15124
15133
  const snap = groupShiftReflowSnapshotRef.current;
15125
15134
  const anchorEntry = snap.children[0];
15126
15135
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -15282,7 +15291,7 @@ const PageCanvas = react.forwardRef(
15282
15291
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
15283
15292
  if (drilledGroupIdRef.current) {
15284
15293
  try {
15285
- (_o = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _o.call(fabricCanvas);
15294
+ (_p = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _p.call(fabricCanvas);
15286
15295
  } catch {
15287
15296
  }
15288
15297
  }
@@ -15689,12 +15698,18 @@ const PageCanvas = react.forwardRef(
15689
15698
  const absLeft = (active.left ?? 0) - ct.frameW / 2;
15690
15699
  const absTop = (active.top ?? 0) - ct.frameH / 2;
15691
15700
  const storePosCrop = absoluteToStorePosition(absLeft, absTop, objId, pageChildrenCrop);
15701
+ const sourceCropElement = pageChildrenCrop.length ? findNodeById(pageChildrenCrop, objId) : null;
15702
+ const cropAngle = sourceCropElement && isElement(sourceCropElement) && (sourceCropElement.flipX || sourceCropElement.flipY) && Number.isFinite(sourceCropElement.angle) ? sourceCropElement.angle ?? 0 : active.angle ?? 0;
15703
+ if ((sourceCropElement == null ? void 0 : sourceCropElement.flipX) || (sourceCropElement == null ? void 0 : sourceCropElement.flipY)) {
15704
+ active.set({ angle: cropAngle, flipX: sourceCropElement.flipX ?? false, flipY: sourceCropElement.flipY ?? false });
15705
+ active.setCoords();
15706
+ }
15692
15707
  updateElement2(objId, {
15693
15708
  width: ct.frameW,
15694
15709
  height: ct.frameH,
15695
15710
  left: storePosCrop.left,
15696
15711
  top: storePosCrop.top,
15697
- angle: active.angle ?? 0,
15712
+ angle: cropAngle,
15698
15713
  cropPanX: panX,
15699
15714
  cropPanY: panY,
15700
15715
  cropZoom: zoom3
@@ -16193,7 +16208,7 @@ const PageCanvas = react.forwardRef(
16193
16208
  useEditorStore.getState().updateElement(objId, { src: newSrc }, { recordHistory: false, skipLayoutRecalc: true });
16194
16209
  }
16195
16210
  } else if (isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
16196
- const imgChildLocalAngle = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : obj.angle ?? 0;
16211
+ const imgChildLocalAngle = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : ((sourceElement == null ? void 0 : sourceElement.flipX) || (sourceElement == null ? void 0 : sourceElement.flipY)) && Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? 0;
16197
16212
  const imgChildNormAngle = (imgChildLocalAngle % 360 + 360) % 360;
16198
16213
  const imgChildIsRotated = Math.abs(imgChildNormAngle) > 0.5 && Math.abs(imgChildNormAngle - 360) > 0.5;
16199
16214
  const imgHandle = activeSelectionResizeHandle;
@@ -16604,7 +16619,7 @@ const PageCanvas = react.forwardRef(
16604
16619
  const isCropGroupObj = obj instanceof fabric__namespace.Group && obj.__cropGroup;
16605
16620
  const isPlainImageObj = obj instanceof fabric__namespace.FabricImage && !obj.__cropGroup && !obj.smartElementType;
16606
16621
  if (isActiveSelection && isActiveSelectionSideHandle && (isCropGroupObj || isPlainImageObj)) {
16607
- const childLocalAngleSrc = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? 0;
16622
+ const childLocalAngleSrc = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : ((sourceElement == null ? void 0 : sourceElement.flipX) || (sourceElement == null ? void 0 : sourceElement.flipY)) && Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? 0;
16608
16623
  const normAng = (childLocalAngleSrc % 360 + 360) % 360;
16609
16624
  const isRotatedImg = Math.min(normAng, 360 - normAng) > 0.5;
16610
16625
  if (isRotatedImg && activeObj instanceof fabric__namespace.ActiveSelection) {
@@ -25946,9 +25961,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25946
25961
  }
25947
25962
  return svgString;
25948
25963
  }
25949
- const resolvedPackageVersion = "0.5.450";
25964
+ const resolvedPackageVersion = "0.5.451";
25950
25965
  const PACKAGE_VERSION = resolvedPackageVersion;
25951
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.450";
25966
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.451";
25952
25967
  const roundParityValue = (value) => {
25953
25968
  if (typeof value !== "number") return value;
25954
25969
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26762,7 +26777,7 @@ class PixldocsRenderer {
26762
26777
  await this.waitForCanvasScene(container, cloned, i);
26763
26778
  }
26764
26779
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26765
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CF7KqDSy.cjs"));
26780
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-a8L9h6E3.cjs"));
26766
26781
  const prepared = preparePagesForExport(
26767
26782
  cloned.pages,
26768
26783
  canvasWidth,
@@ -29082,7 +29097,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29082
29097
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29083
29098
  sanitizeSvgTreeForPdf(svgToDraw);
29084
29099
  try {
29085
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CF7KqDSy.cjs"));
29100
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-a8L9h6E3.cjs"));
29086
29101
  try {
29087
29102
  await logTextMeasurementDiagnostic(svgToDraw);
29088
29103
  } catch {
@@ -29479,4 +29494,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29479
29494
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29480
29495
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29481
29496
  exports.warmTemplateFromForm = warmTemplateFromForm;
29482
- //# sourceMappingURL=index-DM88x3tM.cjs.map
29497
+ //# sourceMappingURL=index-xHv8_Y1M.cjs.map