@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.
@@ -13255,18 +13255,28 @@ 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) {
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);
13265
13276
  const newW = Math.max(1, (active.width ?? 0) * asScaleX);
13266
13277
  const newH = Math.max(1, (active.height ?? 0) * asScaleY);
13267
13278
  active.set({ width: newW, height: newH, scaleX: 1, scaleY: 1 });
13268
13279
  active.setCoords();
13269
- const ct = fabricCanvas._currentTransform;
13270
13280
  if (ct && ct.target === active && ct.original) {
13271
13281
  ct.original.scaleX = 1;
13272
13282
  ct.original.scaleY = 1;
@@ -13286,14 +13296,14 @@ const PageCanvas = react.forwardRef(
13286
13296
  }
13287
13297
  const groupId = active.__pixldocsGroupSelection;
13288
13298
  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) ?? [];
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) ?? [];
13291
13301
  const groupNode = findNodeById(pageChildren2, groupId);
13292
13302
  if (!groupNode) return;
13293
13303
  const groupAbs = getAbsoluteBounds(groupNode, pageChildren2);
13294
13304
  const rect = active.getBoundingRect();
13295
13305
  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;
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;
13297
13307
  groupSelectionTransformStartRef.current = {
13298
13308
  groupId,
13299
13309
  selection: active,
@@ -14676,14 +14686,15 @@ const PageCanvas = react.forwardRef(
14676
14686
  }
14677
14687
  const normalizedScaleAngle = ((obj.angle ?? 0) % 360 + 360) % 360;
14678
14688
  const isRotatedActiveSelectionCorner = obj instanceof fabric__namespace.ActiveSelection && isCornerResizeHandle(corner) && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14679
- 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) {
14680
14691
  snapDuringScaleCallback(obj, corner);
14681
14692
  }
14682
- const scaleGuides = isRotatedActiveSelectionCorner ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14693
+ const scaleGuides = isRotatedActiveSelectionCorner || isRotatedActiveSelectionSide ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14683
14694
  const gridGuidesForScale = [];
14684
14695
  try {
14685
14696
  const psGrid = projectSettingsRef.current;
14686
- const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !obj.__cropGroup && !obj.__resizeSnapHandler;
14697
+ const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !isRotatedActiveSelectionSide && !obj.__cropGroup && !obj.__resizeSnapHandler;
14687
14698
  if (canApplyGridSnap) {
14688
14699
  const gridX = psGrid.gridSizeX ?? psGrid.gridSize ?? 0;
14689
14700
  const gridY = psGrid.gridSizeY ?? psGrid.gridSize ?? 0;
@@ -25174,9 +25185,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25174
25185
  }
25175
25186
  return svgString;
25176
25187
  }
25177
- const resolvedPackageVersion = "0.5.406";
25188
+ const resolvedPackageVersion = "0.5.407";
25178
25189
  const PACKAGE_VERSION = resolvedPackageVersion;
25179
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.406";
25190
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.407";
25180
25191
  const roundParityValue = (value) => {
25181
25192
  if (typeof value !== "number") return value;
25182
25193
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25990,7 +26001,7 @@ class PixldocsRenderer {
25990
26001
  await this.waitForCanvasScene(container, cloned, i);
25991
26002
  }
25992
26003
  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"));
26004
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DRPD9NOQ.cjs"));
25994
26005
  const prepared = preparePagesForExport(
25995
26006
  cloned.pages,
25996
26007
  canvasWidth,
@@ -28310,7 +28321,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28310
28321
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28311
28322
  sanitizeSvgTreeForPdf(svgToDraw);
28312
28323
  try {
28313
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-r257koLL.cjs"));
28324
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DRPD9NOQ.cjs"));
28314
28325
  try {
28315
28326
  await logTextMeasurementDiagnostic(svgToDraw);
28316
28327
  } catch {
@@ -28707,4 +28718,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28707
28718
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28708
28719
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28709
28720
  exports.warmTemplateFromForm = warmTemplateFromForm;
28710
- //# sourceMappingURL=index-D5UViOKA.cjs.map
28721
+ //# sourceMappingURL=index-DYykToy0.cjs.map