@pixldocs/canvas-renderer 0.5.297 → 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.
@@ -13937,7 +13937,7 @@ const PageCanvas = forwardRef(
13937
13937
  });
13938
13938
  let cropGroupSaveTimer = null;
13939
13939
  fabricCanvas.on("object:modified", (e) => {
13940
- var _a2, _b2, _c, _d, _e, _f, _g, _h;
13940
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
13941
13941
  try {
13942
13942
  dragStarted = false;
13943
13943
  setGuides([]);
@@ -14544,6 +14544,94 @@ const PageCanvas = forwardRef(
14544
14544
  };
14545
14545
  useEditorStore.getState().updateElement(objId, { src: newSrc }, { recordHistory: false, skipLayoutRecalc: true });
14546
14546
  }
14547
+ } else if (isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
14548
+ const sx = Math.abs(decomposed.scaleX || 1);
14549
+ const sy = Math.abs(decomposed.scaleY || 1);
14550
+ const handle = activeSelectionResizeHandle;
14551
+ const isCornerHandle = handle === "tl" || handle === "tr" || handle === "bl" || handle === "br" || // Fallback: if handle ref is missing and sx≈sy with non-1 magnitude,
14552
+ // treat as a uniform corner drag.
14553
+ !handle && Math.abs(sx - sy) < 0.01 && Math.abs(sx - 1) > 1e-3;
14554
+ let fx;
14555
+ let fy;
14556
+ if (isCornerHandle) {
14557
+ const u = Math.max(1e-3, Math.sqrt(sx * sy));
14558
+ fx = u;
14559
+ fy = u;
14560
+ } else {
14561
+ fx = sx;
14562
+ fy = sy;
14563
+ }
14564
+ const bakedW = Math.max(1, intrinsicWidth * fx);
14565
+ const bakedH = Math.max(1, intrinsicHeight * fy);
14566
+ try {
14567
+ const preBakeCenter = obj.getCenterPoint();
14568
+ const prevObjCaching = obj.objectCaching;
14569
+ obj.set({
14570
+ width: bakedW,
14571
+ height: bakedH,
14572
+ scaleX: 1,
14573
+ scaleY: 1,
14574
+ objectCaching: false
14575
+ });
14576
+ obj.objectCaching = prevObjCaching;
14577
+ if (sx > 0 && sy > 0) {
14578
+ const localScaleX = 1 / sx;
14579
+ const localScaleY = 1 / sy;
14580
+ obj.set({ scaleX: localScaleX, scaleY: localScaleY });
14581
+ const selectionMatrix = (_g = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _g.call(activeObj);
14582
+ const localCenter = selectionMatrix ? fabric.util.transformPoint(preBakeCenter, fabric.util.invertTransform(selectionMatrix)) : preBakeCenter;
14583
+ const localWidth = bakedW * localScaleX;
14584
+ const localHeight = bakedH * localScaleY;
14585
+ const isCenterOrigin = obj.originX === "center" || obj.originY === "center";
14586
+ if (isCenterOrigin) {
14587
+ obj.set({
14588
+ left: localCenter.x,
14589
+ top: localCenter.y
14590
+ });
14591
+ } else {
14592
+ obj.set({
14593
+ left: localCenter.x - localWidth / 2,
14594
+ top: localCenter.y - localHeight / 2
14595
+ });
14596
+ }
14597
+ }
14598
+ obj.dirty = true;
14599
+ if (activeObj) activeObj.dirty = true;
14600
+ obj.setCoords();
14601
+ } catch {
14602
+ }
14603
+ finalWidth = bakedW;
14604
+ finalHeight = bakedH;
14605
+ finalScaleX = 1;
14606
+ finalScaleY = 1;
14607
+ try {
14608
+ const angleRad = (decomposed.angle ?? 0) * Math.PI / 180;
14609
+ const cos = Math.cos(angleRad);
14610
+ const sin = Math.sin(angleRad);
14611
+ const hw = finalWidth / 2;
14612
+ const hh = finalHeight / 2;
14613
+ const corners = [
14614
+ { x: -hw, y: -hh },
14615
+ { x: hw, y: -hh },
14616
+ { x: hw, y: hh },
14617
+ { x: -hw, y: hh }
14618
+ ].map((p) => ({
14619
+ x: decomposed.translateX + p.x * cos - p.y * sin,
14620
+ y: decomposed.translateY + p.x * sin + p.y * cos
14621
+ }));
14622
+ absoluteLeft = Math.min(...corners.map((p) => p.x));
14623
+ absoluteTop = Math.min(...corners.map((p) => p.y));
14624
+ } catch {
14625
+ }
14626
+ finalAbsoluteMatrix = fabric.util.composeMatrix({
14627
+ translateX: decomposed.translateX,
14628
+ translateY: decomposed.translateY,
14629
+ angle: decomposed.angle ?? 0,
14630
+ scaleX: 1,
14631
+ scaleY: 1,
14632
+ skewX: 0,
14633
+ skewY: 0
14634
+ });
14547
14635
  } else {
14548
14636
  finalWidth = intrinsicWidth;
14549
14637
  finalHeight = intrinsicHeight;
@@ -14587,7 +14675,7 @@ const PageCanvas = forwardRef(
14587
14675
  const localScaleX = 1 / sx;
14588
14676
  const localScaleY = 1 / sy;
14589
14677
  obj.set({ scaleX: localScaleX, scaleY: localScaleY });
14590
- const selectionMatrix = (_g = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _g.call(activeObj);
14678
+ const selectionMatrix = (_h = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _h.call(activeObj);
14591
14679
  const localCenter = selectionMatrix ? fabric.util.transformPoint(preBakeCenter, fabric.util.invertTransform(selectionMatrix)) : preBakeCenter;
14592
14680
  const localWidth = bakedWidth * localScaleX;
14593
14681
  const localHeight = (obj.height ?? intrinsicHeight) * localScaleY;
@@ -14739,7 +14827,7 @@ const PageCanvas = forwardRef(
14739
14827
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
14740
14828
  obj.setCoords();
14741
14829
  }
14742
- const pageChildrenForReflow = ((_h = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _h.children) ?? [];
14830
+ const pageChildrenForReflow = ((_i = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _i.children) ?? [];
14743
14831
  const stackGroupsToReflow = /* @__PURE__ */ new Set();
14744
14832
  for (const id of modifiedIdsThisRound) {
14745
14833
  const parent = findParentGroup(pageChildrenForReflow, id);
@@ -23839,9 +23927,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23839
23927
  }
23840
23928
  return svgString;
23841
23929
  }
23842
- const resolvedPackageVersion = "0.5.297";
23930
+ const resolvedPackageVersion = "0.5.298";
23843
23931
  const PACKAGE_VERSION = resolvedPackageVersion;
23844
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.297";
23932
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.298";
23845
23933
  const roundParityValue = (value) => {
23846
23934
  if (typeof value !== "number") return value;
23847
23935
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24655,7 +24743,7 @@ class PixldocsRenderer {
24655
24743
  await this.waitForCanvasScene(container, cloned, i);
24656
24744
  }
24657
24745
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24658
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DOAlZclW.js");
24746
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CL-maCe-.js");
24659
24747
  const prepared = preparePagesForExport(
24660
24748
  cloned.pages,
24661
24749
  canvasWidth,
@@ -26975,7 +27063,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26975
27063
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26976
27064
  sanitizeSvgTreeForPdf(svgToDraw);
26977
27065
  try {
26978
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DOAlZclW.js");
27066
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CL-maCe-.js");
26979
27067
  try {
26980
27068
  await logTextMeasurementDiagnostic(svgToDraw);
26981
27069
  } catch {
@@ -27375,4 +27463,4 @@ export {
27375
27463
  buildTeaserBlurFlatKeys as y,
27376
27464
  collectFontDescriptorsFromConfig as z
27377
27465
  };
27378
- //# sourceMappingURL=index-BDVGR-oo.js.map
27466
+ //# sourceMappingURL=index-72P860wB.js.map