@pixldocs/canvas-renderer 0.5.296 → 0.5.298

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.
@@ -13955,7 +13955,7 @@ const PageCanvas = react.forwardRef(
13955
13955
  });
13956
13956
  let cropGroupSaveTimer = null;
13957
13957
  fabricCanvas.on("object:modified", (e) => {
13958
- var _a2, _b2, _c, _d, _e, _f, _g;
13958
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
13959
13959
  try {
13960
13960
  dragStarted = false;
13961
13961
  setGuides([]);
@@ -14562,6 +14562,94 @@ const PageCanvas = react.forwardRef(
14562
14562
  };
14563
14563
  useEditorStore.getState().updateElement(objId, { src: newSrc }, { recordHistory: false, skipLayoutRecalc: true });
14564
14564
  }
14565
+ } else if (isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
14566
+ const sx = Math.abs(decomposed.scaleX || 1);
14567
+ const sy = Math.abs(decomposed.scaleY || 1);
14568
+ const handle = activeSelectionResizeHandle;
14569
+ const isCornerHandle = handle === "tl" || handle === "tr" || handle === "bl" || handle === "br" || // Fallback: if handle ref is missing and sx≈sy with non-1 magnitude,
14570
+ // treat as a uniform corner drag.
14571
+ !handle && Math.abs(sx - sy) < 0.01 && Math.abs(sx - 1) > 1e-3;
14572
+ let fx;
14573
+ let fy;
14574
+ if (isCornerHandle) {
14575
+ const u = Math.max(1e-3, Math.sqrt(sx * sy));
14576
+ fx = u;
14577
+ fy = u;
14578
+ } else {
14579
+ fx = sx;
14580
+ fy = sy;
14581
+ }
14582
+ const bakedW = Math.max(1, intrinsicWidth * fx);
14583
+ const bakedH = Math.max(1, intrinsicHeight * fy);
14584
+ try {
14585
+ const preBakeCenter = obj.getCenterPoint();
14586
+ const prevObjCaching = obj.objectCaching;
14587
+ obj.set({
14588
+ width: bakedW,
14589
+ height: bakedH,
14590
+ scaleX: 1,
14591
+ scaleY: 1,
14592
+ objectCaching: false
14593
+ });
14594
+ obj.objectCaching = prevObjCaching;
14595
+ if (sx > 0 && sy > 0) {
14596
+ const localScaleX = 1 / sx;
14597
+ const localScaleY = 1 / sy;
14598
+ obj.set({ scaleX: localScaleX, scaleY: localScaleY });
14599
+ const selectionMatrix = (_g = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _g.call(activeObj);
14600
+ const localCenter = selectionMatrix ? fabric__namespace.util.transformPoint(preBakeCenter, fabric__namespace.util.invertTransform(selectionMatrix)) : preBakeCenter;
14601
+ const localWidth = bakedW * localScaleX;
14602
+ const localHeight = bakedH * localScaleY;
14603
+ const isCenterOrigin = obj.originX === "center" || obj.originY === "center";
14604
+ if (isCenterOrigin) {
14605
+ obj.set({
14606
+ left: localCenter.x,
14607
+ top: localCenter.y
14608
+ });
14609
+ } else {
14610
+ obj.set({
14611
+ left: localCenter.x - localWidth / 2,
14612
+ top: localCenter.y - localHeight / 2
14613
+ });
14614
+ }
14615
+ }
14616
+ obj.dirty = true;
14617
+ if (activeObj) activeObj.dirty = true;
14618
+ obj.setCoords();
14619
+ } catch {
14620
+ }
14621
+ finalWidth = bakedW;
14622
+ finalHeight = bakedH;
14623
+ finalScaleX = 1;
14624
+ finalScaleY = 1;
14625
+ try {
14626
+ const angleRad = (decomposed.angle ?? 0) * Math.PI / 180;
14627
+ const cos = Math.cos(angleRad);
14628
+ const sin = Math.sin(angleRad);
14629
+ const hw = finalWidth / 2;
14630
+ const hh = finalHeight / 2;
14631
+ const corners = [
14632
+ { x: -hw, y: -hh },
14633
+ { x: hw, y: -hh },
14634
+ { x: hw, y: hh },
14635
+ { x: -hw, y: hh }
14636
+ ].map((p) => ({
14637
+ x: decomposed.translateX + p.x * cos - p.y * sin,
14638
+ y: decomposed.translateY + p.x * sin + p.y * cos
14639
+ }));
14640
+ absoluteLeft = Math.min(...corners.map((p) => p.x));
14641
+ absoluteTop = Math.min(...corners.map((p) => p.y));
14642
+ } catch {
14643
+ }
14644
+ finalAbsoluteMatrix = fabric__namespace.util.composeMatrix({
14645
+ translateX: decomposed.translateX,
14646
+ translateY: decomposed.translateY,
14647
+ angle: decomposed.angle ?? 0,
14648
+ scaleX: 1,
14649
+ scaleY: 1,
14650
+ skewX: 0,
14651
+ skewY: 0
14652
+ });
14565
14653
  } else {
14566
14654
  finalWidth = intrinsicWidth;
14567
14655
  finalHeight = intrinsicHeight;
@@ -14602,16 +14690,16 @@ const PageCanvas = react.forwardRef(
14602
14690
  obj.initDimensions();
14603
14691
  obj.objectCaching = prevObjCaching;
14604
14692
  if (sx > 0 && sy > 0) {
14605
- obj.set({ scaleX: 1 / sx, scaleY: 1 / sy });
14606
- const asTx = Number(decomposed.translateX ?? 0);
14607
- const asTy = Number(decomposed.translateY ?? 0);
14608
- const localCx = (preBakeCenter.x - asTx) / sx;
14609
- const localCy = (preBakeCenter.y - asTy) / sy;
14610
- const localWidth = bakedWidth * (1 / sx);
14611
- const localHeight = (obj.height ?? intrinsicHeight) * (1 / sy);
14693
+ const localScaleX = 1 / sx;
14694
+ const localScaleY = 1 / sy;
14695
+ obj.set({ scaleX: localScaleX, scaleY: localScaleY });
14696
+ const selectionMatrix = (_h = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _h.call(activeObj);
14697
+ const localCenter = selectionMatrix ? fabric__namespace.util.transformPoint(preBakeCenter, fabric__namespace.util.invertTransform(selectionMatrix)) : preBakeCenter;
14698
+ const localWidth = bakedWidth * localScaleX;
14699
+ const localHeight = (obj.height ?? intrinsicHeight) * localScaleY;
14612
14700
  obj.set({
14613
- left: localCx - localWidth / 2,
14614
- top: localCy - localHeight / 2
14701
+ left: localCenter.x - localWidth / 2,
14702
+ top: localCenter.y - localHeight / 2
14615
14703
  });
14616
14704
  } else {
14617
14705
  obj.setPositionByOrigin(preBakeCenter, "center", "center");
@@ -14757,7 +14845,7 @@ const PageCanvas = react.forwardRef(
14757
14845
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
14758
14846
  obj.setCoords();
14759
14847
  }
14760
- const pageChildrenForReflow = ((_g = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _g.children) ?? [];
14848
+ const pageChildrenForReflow = ((_i = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _i.children) ?? [];
14761
14849
  const stackGroupsToReflow = /* @__PURE__ */ new Set();
14762
14850
  for (const id of modifiedIdsThisRound) {
14763
14851
  const parent = findParentGroup(pageChildrenForReflow, id);
@@ -23857,9 +23945,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23857
23945
  }
23858
23946
  return svgString;
23859
23947
  }
23860
- const resolvedPackageVersion = "0.5.296";
23948
+ const resolvedPackageVersion = "0.5.298";
23861
23949
  const PACKAGE_VERSION = resolvedPackageVersion;
23862
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.296";
23950
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.298";
23863
23951
  const roundParityValue = (value) => {
23864
23952
  if (typeof value !== "number") return value;
23865
23953
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24673,7 +24761,7 @@ class PixldocsRenderer {
24673
24761
  await this.waitForCanvasScene(container, cloned, i);
24674
24762
  }
24675
24763
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24676
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BhdvkuRF.cjs"));
24764
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BrPykWdO.cjs"));
24677
24765
  const prepared = preparePagesForExport(
24678
24766
  cloned.pages,
24679
24767
  canvasWidth,
@@ -26993,7 +27081,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26993
27081
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26994
27082
  sanitizeSvgTreeForPdf(svgToDraw);
26995
27083
  try {
26996
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BhdvkuRF.cjs"));
27084
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BrPykWdO.cjs"));
26997
27085
  try {
26998
27086
  await logTextMeasurementDiagnostic(svgToDraw);
26999
27087
  } catch {
@@ -27390,4 +27478,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27390
27478
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27391
27479
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27392
27480
  exports.warmTemplateFromForm = warmTemplateFromForm;
27393
- //# sourceMappingURL=index-QphA136A.cjs.map
27481
+ //# sourceMappingURL=index-BzOCkAOn.cjs.map