@pixldocs/canvas-renderer 0.5.406 → 0.5.408

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.
@@ -13255,23 +13255,27 @@ const PageCanvas = react.forwardRef(
13255
13255
  transformingIdsRef.current.clear();
13256
13256
  };
13257
13257
  const prepareGroupSelectionTransformStart = (target) => {
13258
- var _a2, _b2, _c2;
13258
+ var _a2, _b2, _c2, _d, _e;
13259
13259
  const active = target instanceof fabric__namespace.ActiveSelection ? target : fabricCanvas.getActiveObject();
13260
13260
  if (!(active instanceof fabric__namespace.ActiveSelection)) return;
13261
13261
  try {
13262
- const asScaleX = Math.abs(active.scaleX ?? 1);
13263
- const asScaleY = Math.abs(active.scaleY ?? 1);
13264
- if (Math.abs(asScaleX - 1) > 1e-4 || Math.abs(asScaleY - 1) > 1e-4) {
13265
- const newW = Math.max(1, (active.width ?? 0) * asScaleX);
13266
- const newH = Math.max(1, (active.height ?? 0) * asScaleY);
13267
- active.set({ width: newW, height: newH, scaleX: 1, scaleY: 1 });
13262
+ const canvasWithTransform = fabricCanvas;
13263
+ const ct = canvasWithTransform._currentTransform;
13264
+ const rawScaleX = Number(active.scaleX ?? 1) || 1;
13265
+ const rawScaleY = Number(active.scaleY ?? 1) || 1;
13266
+ const originalScaleX = Number((ct == null ? void 0 : ct.target) === active ? (_a2 = ct == null ? void 0 : ct.original) == null ? void 0 : _a2.scaleX : rawScaleX) || 1;
13267
+ const originalScaleY = Number((ct == null ? void 0 : ct.target) === active ? (_b2 = ct == null ? void 0 : ct.original) == null ? void 0 : _b2.scaleY : rawScaleY) || 1;
13268
+ const liveDeltaX = Math.abs(rawScaleX / originalScaleX);
13269
+ const liveDeltaY = Math.abs(rawScaleY / originalScaleY);
13270
+ const hasResidualOriginal = Math.abs(Math.abs(originalScaleX) - 1) > 1e-4 || Math.abs(Math.abs(originalScaleY) - 1) > 1e-4;
13271
+ const hasNoLiveDragDelta = Math.abs(liveDeltaX - 1) < 5e-4 && Math.abs(liveDeltaY - 1) < 5e-4;
13272
+ const canNormalize = (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;
13273
+ if (canNormalize) {
13274
+ active.set({ scaleX: 1, scaleY: 1 });
13268
13275
  active.setCoords();
13269
- const ct = fabricCanvas._currentTransform;
13270
13276
  if (ct && ct.target === active && ct.original) {
13271
13277
  ct.original.scaleX = 1;
13272
13278
  ct.original.scaleY = 1;
13273
- ct.original.width = newW;
13274
- ct.original.height = newH;
13275
13279
  }
13276
13280
  }
13277
13281
  } catch {
@@ -13286,14 +13290,14 @@ const PageCanvas = react.forwardRef(
13286
13290
  }
13287
13291
  const groupId = active.__pixldocsGroupSelection;
13288
13292
  if (!groupId) return;
13289
- if (((_a2 = groupSelectionTransformStartRef.current) == null ? void 0 : _a2.groupId) === groupId && groupSelectionTransformStartRef.current.selection === active) return;
13290
- const pageChildren2 = ((_b2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _b2.children) ?? [];
13293
+ if (((_c2 = groupSelectionTransformStartRef.current) == null ? void 0 : _c2.groupId) === groupId && groupSelectionTransformStartRef.current.selection === active) return;
13294
+ const pageChildren2 = ((_d = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
13291
13295
  const groupNode = findNodeById(pageChildren2, groupId);
13292
13296
  if (!groupNode) return;
13293
13297
  const groupAbs = getAbsoluteBounds(groupNode, pageChildren2);
13294
13298
  const rect = active.getBoundingRect();
13295
13299
  const currentTransform = fabricCanvas._currentTransform;
13296
- 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;
13300
+ 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;
13297
13301
  groupSelectionTransformStartRef.current = {
13298
13302
  groupId,
13299
13303
  selection: active,
@@ -14676,14 +14680,15 @@ const PageCanvas = react.forwardRef(
14676
14680
  }
14677
14681
  const normalizedScaleAngle = ((obj.angle ?? 0) % 360 + 360) % 360;
14678
14682
  const isRotatedActiveSelectionCorner = obj instanceof fabric__namespace.ActiveSelection && isCornerResizeHandle(corner) && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14679
- if (!isRotatedActiveSelectionCorner) {
14683
+ const isRotatedActiveSelectionSide = obj instanceof fabric__namespace.ActiveSelection && (corner === "mt" || corner === "mb" || corner === "ml" || corner === "mr") && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14684
+ if (!isRotatedActiveSelectionCorner && !isRotatedActiveSelectionSide) {
14680
14685
  snapDuringScaleCallback(obj, corner);
14681
14686
  }
14682
- const scaleGuides = isRotatedActiveSelectionCorner ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14687
+ const scaleGuides = isRotatedActiveSelectionCorner || isRotatedActiveSelectionSide ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14683
14688
  const gridGuidesForScale = [];
14684
14689
  try {
14685
14690
  const psGrid = projectSettingsRef.current;
14686
- const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !obj.__cropGroup && !obj.__resizeSnapHandler;
14691
+ const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !isRotatedActiveSelectionSide && !obj.__cropGroup && !obj.__resizeSnapHandler;
14687
14692
  if (canApplyGridSnap) {
14688
14693
  const gridX = psGrid.gridSizeX ?? psGrid.gridSize ?? 0;
14689
14694
  const gridY = psGrid.gridSizeY ?? psGrid.gridSize ?? 0;
@@ -25174,9 +25179,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25174
25179
  }
25175
25180
  return svgString;
25176
25181
  }
25177
- const resolvedPackageVersion = "0.5.406";
25182
+ const resolvedPackageVersion = "0.5.408";
25178
25183
  const PACKAGE_VERSION = resolvedPackageVersion;
25179
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.406";
25184
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.408";
25180
25185
  const roundParityValue = (value) => {
25181
25186
  if (typeof value !== "number") return value;
25182
25187
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25990,7 +25995,7 @@ class PixldocsRenderer {
25990
25995
  await this.waitForCanvasScene(container, cloned, i);
25991
25996
  }
25992
25997
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25993
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-r257koLL.cjs"));
25998
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DSZH7267.cjs"));
25994
25999
  const prepared = preparePagesForExport(
25995
26000
  cloned.pages,
25996
26001
  canvasWidth,
@@ -28310,7 +28315,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28310
28315
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28311
28316
  sanitizeSvgTreeForPdf(svgToDraw);
28312
28317
  try {
28313
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-r257koLL.cjs"));
28318
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DSZH7267.cjs"));
28314
28319
  try {
28315
28320
  await logTextMeasurementDiagnostic(svgToDraw);
28316
28321
  } catch {
@@ -28707,4 +28712,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28707
28712
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28708
28713
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28709
28714
  exports.warmTemplateFromForm = warmTemplateFromForm;
28710
- //# sourceMappingURL=index-D5UViOKA.cjs.map
28715
+ //# sourceMappingURL=index-vGjobYro.cjs.map