@pixldocs/canvas-renderer 0.5.406 → 0.5.407

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.
@@ -13237,18 +13237,28 @@ const PageCanvas = forwardRef(
13237
13237
  transformingIdsRef.current.clear();
13238
13238
  };
13239
13239
  const prepareGroupSelectionTransformStart = (target) => {
13240
- var _a2, _b2, _c2;
13240
+ var _a2, _b2, _c2, _d, _e;
13241
13241
  const active = target instanceof fabric.ActiveSelection ? target : fabricCanvas.getActiveObject();
13242
13242
  if (!(active instanceof fabric.ActiveSelection)) return;
13243
13243
  try {
13244
- const asScaleX = Math.abs(active.scaleX ?? 1);
13245
- const asScaleY = Math.abs(active.scaleY ?? 1);
13246
- if (Math.abs(asScaleX - 1) > 1e-4 || Math.abs(asScaleY - 1) > 1e-4) {
13244
+ const canvasWithTransform = fabricCanvas;
13245
+ const ct = canvasWithTransform._currentTransform;
13246
+ const rawScaleX = Number(active.scaleX ?? 1) || 1;
13247
+ const rawScaleY = Number(active.scaleY ?? 1) || 1;
13248
+ const originalScaleX = Number((ct == null ? void 0 : ct.target) === active ? (_a2 = ct == null ? void 0 : ct.original) == null ? void 0 : _a2.scaleX : rawScaleX) || 1;
13249
+ const originalScaleY = Number((ct == null ? void 0 : ct.target) === active ? (_b2 = ct == null ? void 0 : ct.original) == null ? void 0 : _b2.scaleY : rawScaleY) || 1;
13250
+ const liveDeltaX = Math.abs(rawScaleX / originalScaleX);
13251
+ const liveDeltaY = Math.abs(rawScaleY / originalScaleY);
13252
+ const hasResidualOriginal = Math.abs(Math.abs(originalScaleX) - 1) > 1e-4 || Math.abs(Math.abs(originalScaleY) - 1) > 1e-4;
13253
+ const hasNoLiveDragDelta = Math.abs(liveDeltaX - 1) < 5e-4 && Math.abs(liveDeltaY - 1) < 5e-4;
13254
+ const canBakeResidual = (ct == null ? void 0 : ct.target) === active ? hasResidualOriginal && hasNoLiveDragDelta : Math.abs(Math.abs(rawScaleX) - 1) > 1e-4 || Math.abs(Math.abs(rawScaleY) - 1) > 1e-4;
13255
+ if (canBakeResidual) {
13256
+ const asScaleX = Math.abs((ct == null ? void 0 : ct.target) === active ? originalScaleX : rawScaleX);
13257
+ const asScaleY = Math.abs((ct == null ? void 0 : ct.target) === active ? originalScaleY : rawScaleY);
13247
13258
  const newW = Math.max(1, (active.width ?? 0) * asScaleX);
13248
13259
  const newH = Math.max(1, (active.height ?? 0) * asScaleY);
13249
13260
  active.set({ width: newW, height: newH, scaleX: 1, scaleY: 1 });
13250
13261
  active.setCoords();
13251
- const ct = fabricCanvas._currentTransform;
13252
13262
  if (ct && ct.target === active && ct.original) {
13253
13263
  ct.original.scaleX = 1;
13254
13264
  ct.original.scaleY = 1;
@@ -13268,14 +13278,14 @@ const PageCanvas = forwardRef(
13268
13278
  }
13269
13279
  const groupId = active.__pixldocsGroupSelection;
13270
13280
  if (!groupId) return;
13271
- if (((_a2 = groupSelectionTransformStartRef.current) == null ? void 0 : _a2.groupId) === groupId && groupSelectionTransformStartRef.current.selection === active) return;
13272
- const pageChildren2 = ((_b2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _b2.children) ?? [];
13281
+ if (((_c2 = groupSelectionTransformStartRef.current) == null ? void 0 : _c2.groupId) === groupId && groupSelectionTransformStartRef.current.selection === active) return;
13282
+ const pageChildren2 = ((_d = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
13273
13283
  const groupNode = findNodeById(pageChildren2, groupId);
13274
13284
  if (!groupNode) return;
13275
13285
  const groupAbs = getAbsoluteBounds(groupNode, pageChildren2);
13276
13286
  const rect = active.getBoundingRect();
13277
13287
  const currentTransform = fabricCanvas._currentTransform;
13278
- const originalSelectionAngle = (currentTransform == null ? void 0 : currentTransform.target) === active && typeof ((_c2 = currentTransform == null ? void 0 : currentTransform.original) == null ? void 0 : _c2.angle) === "number" ? currentTransform.original.angle : active.angle ?? 0;
13288
+ const originalSelectionAngle = (currentTransform == null ? void 0 : currentTransform.target) === active && typeof ((_e = currentTransform == null ? void 0 : currentTransform.original) == null ? void 0 : _e.angle) === "number" ? currentTransform.original.angle : active.angle ?? 0;
13279
13289
  groupSelectionTransformStartRef.current = {
13280
13290
  groupId,
13281
13291
  selection: active,
@@ -14658,14 +14668,15 @@ const PageCanvas = forwardRef(
14658
14668
  }
14659
14669
  const normalizedScaleAngle = ((obj.angle ?? 0) % 360 + 360) % 360;
14660
14670
  const isRotatedActiveSelectionCorner = obj instanceof fabric.ActiveSelection && isCornerResizeHandle(corner) && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14661
- if (!isRotatedActiveSelectionCorner) {
14671
+ const isRotatedActiveSelectionSide = obj instanceof fabric.ActiveSelection && (corner === "mt" || corner === "mb" || corner === "ml" || corner === "mr") && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14672
+ if (!isRotatedActiveSelectionCorner && !isRotatedActiveSelectionSide) {
14662
14673
  snapDuringScaleCallback(obj, corner);
14663
14674
  }
14664
- const scaleGuides = isRotatedActiveSelectionCorner ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14675
+ const scaleGuides = isRotatedActiveSelectionCorner || isRotatedActiveSelectionSide ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14665
14676
  const gridGuidesForScale = [];
14666
14677
  try {
14667
14678
  const psGrid = projectSettingsRef.current;
14668
- const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !obj.__cropGroup && !obj.__resizeSnapHandler;
14679
+ const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !isRotatedActiveSelectionSide && !obj.__cropGroup && !obj.__resizeSnapHandler;
14669
14680
  if (canApplyGridSnap) {
14670
14681
  const gridX = psGrid.gridSizeX ?? psGrid.gridSize ?? 0;
14671
14682
  const gridY = psGrid.gridSizeY ?? psGrid.gridSize ?? 0;
@@ -25156,9 +25167,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25156
25167
  }
25157
25168
  return svgString;
25158
25169
  }
25159
- const resolvedPackageVersion = "0.5.406";
25170
+ const resolvedPackageVersion = "0.5.407";
25160
25171
  const PACKAGE_VERSION = resolvedPackageVersion;
25161
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.406";
25172
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.407";
25162
25173
  const roundParityValue = (value) => {
25163
25174
  if (typeof value !== "number") return value;
25164
25175
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25972,7 +25983,7 @@ class PixldocsRenderer {
25972
25983
  await this.waitForCanvasScene(container, cloned, i);
25973
25984
  }
25974
25985
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25975
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BSFv6jYQ.js");
25986
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DuXVrbKW.js");
25976
25987
  const prepared = preparePagesForExport(
25977
25988
  cloned.pages,
25978
25989
  canvasWidth,
@@ -28292,7 +28303,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28292
28303
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28293
28304
  sanitizeSvgTreeForPdf(svgToDraw);
28294
28305
  try {
28295
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BSFv6jYQ.js");
28306
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DuXVrbKW.js");
28296
28307
  try {
28297
28308
  await logTextMeasurementDiagnostic(svgToDraw);
28298
28309
  } catch {
@@ -28692,4 +28703,4 @@ export {
28692
28703
  buildTeaserBlurFlatKeys as y,
28693
28704
  collectFontDescriptorsFromConfig as z
28694
28705
  };
28695
- //# sourceMappingURL=index-D-UEBi3B.js.map
28706
+ //# sourceMappingURL=index-Dxlbnksl.js.map