@pixldocs/canvas-renderer 0.5.405 → 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.
@@ -13255,9 +13255,37 @@ 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
+ try {
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 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;
13273
+ if (canBakeResidual) {
13274
+ const asScaleX = Math.abs((ct == null ? void 0 : ct.target) === active ? originalScaleX : rawScaleX);
13275
+ const asScaleY = Math.abs((ct == null ? void 0 : ct.target) === active ? originalScaleY : rawScaleY);
13276
+ const newW = Math.max(1, (active.width ?? 0) * asScaleX);
13277
+ const newH = Math.max(1, (active.height ?? 0) * asScaleY);
13278
+ active.set({ width: newW, height: newH, scaleX: 1, scaleY: 1 });
13279
+ active.setCoords();
13280
+ if (ct && ct.target === active && ct.original) {
13281
+ ct.original.scaleX = 1;
13282
+ ct.original.scaleY = 1;
13283
+ ct.original.width = newW;
13284
+ ct.original.height = newH;
13285
+ }
13286
+ }
13287
+ } catch {
13288
+ }
13261
13289
  if (!activeSelectionMoveStartRef.current || activeSelectionMoveStartRef.current.selection !== active) {
13262
13290
  const rect2 = active.getBoundingRect();
13263
13291
  activeSelectionMoveStartRef.current = {
@@ -13268,14 +13296,14 @@ const PageCanvas = react.forwardRef(
13268
13296
  }
13269
13297
  const groupId = active.__pixldocsGroupSelection;
13270
13298
  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) ?? [];
13299
+ if (((_c2 = groupSelectionTransformStartRef.current) == null ? void 0 : _c2.groupId) === groupId && groupSelectionTransformStartRef.current.selection === active) return;
13300
+ const pageChildren2 = ((_d = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
13273
13301
  const groupNode = findNodeById(pageChildren2, groupId);
13274
13302
  if (!groupNode) return;
13275
13303
  const groupAbs = getAbsoluteBounds(groupNode, pageChildren2);
13276
13304
  const rect = active.getBoundingRect();
13277
13305
  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;
13306
+ 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
13307
  groupSelectionTransformStartRef.current = {
13280
13308
  groupId,
13281
13309
  selection: active,
@@ -14658,14 +14686,15 @@ const PageCanvas = react.forwardRef(
14658
14686
  }
14659
14687
  const normalizedScaleAngle = ((obj.angle ?? 0) % 360 + 360) % 360;
14660
14688
  const isRotatedActiveSelectionCorner = obj instanceof fabric__namespace.ActiveSelection && isCornerResizeHandle(corner) && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14661
- if (!isRotatedActiveSelectionCorner) {
14689
+ const isRotatedActiveSelectionSide = obj instanceof fabric__namespace.ActiveSelection && (corner === "mt" || corner === "mb" || corner === "ml" || corner === "mr") && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14690
+ if (!isRotatedActiveSelectionCorner && !isRotatedActiveSelectionSide) {
14662
14691
  snapDuringScaleCallback(obj, corner);
14663
14692
  }
14664
- const scaleGuides = isRotatedActiveSelectionCorner ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14693
+ const scaleGuides = isRotatedActiveSelectionCorner || isRotatedActiveSelectionSide ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14665
14694
  const gridGuidesForScale = [];
14666
14695
  try {
14667
14696
  const psGrid = projectSettingsRef.current;
14668
- const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !obj.__cropGroup && !obj.__resizeSnapHandler;
14697
+ const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !isRotatedActiveSelectionSide && !obj.__cropGroup && !obj.__resizeSnapHandler;
14669
14698
  if (canApplyGridSnap) {
14670
14699
  const gridX = psGrid.gridSizeX ?? psGrid.gridSize ?? 0;
14671
14700
  const gridY = psGrid.gridSizeY ?? psGrid.gridSize ?? 0;
@@ -25156,9 +25185,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25156
25185
  }
25157
25186
  return svgString;
25158
25187
  }
25159
- const resolvedPackageVersion = "0.5.405";
25188
+ const resolvedPackageVersion = "0.5.407";
25160
25189
  const PACKAGE_VERSION = resolvedPackageVersion;
25161
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.405";
25190
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.407";
25162
25191
  const roundParityValue = (value) => {
25163
25192
  if (typeof value !== "number") return value;
25164
25193
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25972,7 +26001,7 @@ class PixldocsRenderer {
25972
26001
  await this.waitForCanvasScene(container, cloned, i);
25973
26002
  }
25974
26003
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25975
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DSku6Anm.cjs"));
26004
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DRPD9NOQ.cjs"));
25976
26005
  const prepared = preparePagesForExport(
25977
26006
  cloned.pages,
25978
26007
  canvasWidth,
@@ -28292,7 +28321,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28292
28321
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28293
28322
  sanitizeSvgTreeForPdf(svgToDraw);
28294
28323
  try {
28295
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DSku6Anm.cjs"));
28324
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DRPD9NOQ.cjs"));
28296
28325
  try {
28297
28326
  await logTextMeasurementDiagnostic(svgToDraw);
28298
28327
  } catch {
@@ -28689,4 +28718,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28689
28718
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28690
28719
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28691
28720
  exports.warmTemplateFromForm = warmTemplateFromForm;
28692
- //# sourceMappingURL=index-uJf5RraI.cjs.map
28721
+ //# sourceMappingURL=index-DYykToy0.cjs.map