@pixldocs/canvas-renderer 0.5.415 → 0.5.417

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.
@@ -14610,6 +14610,21 @@ const PageCanvas = react.forwardRef(
14610
14610
  const startSy = Math.abs(Number(((_h = _cur == null ? void 0 : _cur.original) == null ? void 0 : _h.scaleY) ?? 1)) || 1;
14611
14611
  const sAxis = isXSide ? Math.abs((obj.scaleX ?? 1) / startSx) : Math.abs((obj.scaleY ?? 1) / startSy);
14612
14612
  if (sAxis > 1e-3) {
14613
+ const captureAsLiveWorldSnapshot = (childObj, liveW, liveH) => {
14614
+ try {
14615
+ const selectionMatrix = obj.calcTransformMatrix();
14616
+ const childMatrix = childObj.calcOwnMatrix();
14617
+ const worldMatrix = fabric__namespace.util.multiplyTransformMatrices(selectionMatrix, childMatrix);
14618
+ const live = fabric__namespace.util.qrDecompose(worldMatrix);
14619
+ childObj.__asLiveWorldAngle = live.angle;
14620
+ childObj.__asLiveWorldCenterX = live.translateX;
14621
+ childObj.__asLiveWorldCenterY = live.translateY;
14622
+ childObj.__asLiveParentWorldAngle = obj.angle ?? 0;
14623
+ if (Number.isFinite(liveW)) childObj.__asLiveFinalW = liveW;
14624
+ if (Number.isFinite(liveH)) childObj.__asLiveFinalH = liveH;
14625
+ } catch {
14626
+ }
14627
+ };
14613
14628
  if (isXSide && ((_i = groupShiftReflowSnapshotRef.current) == null ? void 0 : _i.selection) !== obj) {
14614
14629
  groupShiftReflowSnapshotRef.current = null;
14615
14630
  const logicalGroupId = obj.__pixldocsGroupSelection;
@@ -14708,6 +14723,7 @@ const PageCanvas = react.forwardRef(
14708
14723
  } catch {
14709
14724
  }
14710
14725
  child.setCoords();
14726
+ captureAsLiveWorldSnapshot(child, ct.frameW ?? child.width ?? 0, ct.frameH ?? child.height ?? 0);
14711
14727
  child.dirty = true;
14712
14728
  continue;
14713
14729
  }
@@ -14760,6 +14776,7 @@ const PageCanvas = react.forwardRef(
14760
14776
  } catch {
14761
14777
  }
14762
14778
  child.setCoords();
14779
+ captureAsLiveWorldSnapshot(child, child.width ?? 0, child.height ?? 0);
14763
14780
  child.dirty = true;
14764
14781
  continue;
14765
14782
  }
@@ -15783,13 +15800,14 @@ const PageCanvas = react.forwardRef(
15783
15800
  const ownSy = Math.abs(obj.scaleY ?? 1);
15784
15801
  const newFrameW = cropIsXSide ? sourceFrameW * ownSx * sLocal : sourceFrameW * ownSx;
15785
15802
  const newFrameH = cropIsXSide ? sourceFrameH * ownSy : sourceFrameH * ownSy * sLocal;
15786
- finalWidth = Math.max(1, newFrameW);
15787
- finalHeight = Math.max(1, newFrameH);
15803
+ finalWidth = Math.max(1, Number(obj.__asLiveFinalW ?? newFrameW));
15804
+ finalHeight = Math.max(1, Number(obj.__asLiveFinalH ?? newFrameH));
15788
15805
  finalScaleX = 1;
15789
15806
  finalScaleY = 1;
15790
- const worldCx = decomposed.translateX ?? 0;
15791
- const worldCy = decomposed.translateY ?? 0;
15792
- const worldAngle = (activeObj.angle ?? 0) + cropChildLocalAngle;
15807
+ const worldCx = Number.isFinite(obj.__asLiveWorldCenterX) ? obj.__asLiveWorldCenterX : decomposed.translateX ?? 0;
15808
+ const worldCy = Number.isFinite(obj.__asLiveWorldCenterY) ? obj.__asLiveWorldCenterY : decomposed.translateY ?? 0;
15809
+ const liveWorldAngle = Number.isFinite(obj.__asLiveWorldAngle) ? obj.__asLiveWorldAngle : (activeObj.angle ?? 0) + cropChildLocalAngle;
15810
+ const worldAngle = liveWorldAngle;
15793
15811
  absoluteLeft = worldCx - finalWidth / 2;
15794
15812
  absoluteTop = worldCy - finalHeight / 2;
15795
15813
  finalAbsoluteMatrix = fabric__namespace.util.composeMatrix({
@@ -15912,13 +15930,13 @@ const PageCanvas = react.forwardRef(
15912
15930
  obj.setCoords();
15913
15931
  } catch {
15914
15932
  }
15915
- finalWidth = bakedW;
15916
- finalHeight = bakedH;
15933
+ finalWidth = Math.max(1, Number(obj.__asLiveFinalW ?? bakedW));
15934
+ finalHeight = Math.max(1, Number(obj.__asLiveFinalH ?? bakedH));
15917
15935
  finalScaleX = 1;
15918
15936
  finalScaleY = 1;
15919
- const worldCx = decomposed.translateX ?? 0;
15920
- const worldCy = decomposed.translateY ?? 0;
15921
- const worldAngleI = (activeObj.angle ?? 0) + imgChildLocalAngle;
15937
+ const worldCx = Number.isFinite(obj.__asLiveWorldCenterX) ? obj.__asLiveWorldCenterX : decomposed.translateX ?? 0;
15938
+ const worldCy = Number.isFinite(obj.__asLiveWorldCenterY) ? obj.__asLiveWorldCenterY : decomposed.translateY ?? 0;
15939
+ const worldAngleI = Number.isFinite(obj.__asLiveWorldAngle) ? obj.__asLiveWorldAngle : (activeObj.angle ?? 0) + imgChildLocalAngle;
15922
15940
  absoluteLeft = worldCx - finalWidth / 2;
15923
15941
  absoluteTop = worldCy - finalHeight / 2;
15924
15942
  finalAbsoluteMatrix = fabric__namespace.util.composeMatrix({
@@ -16268,11 +16286,13 @@ const PageCanvas = react.forwardRef(
16268
16286
  const isRotatedImg = Math.min(normAng, 360 - normAng) > 0.5;
16269
16287
  if (isRotatedImg && activeObj instanceof fabric__namespace.ActiveSelection) {
16270
16288
  try {
16271
- const cleanAngleI = childLocalAngleSrc;
16272
- const cleanW = Math.max(1, Number(elementUpdate.width ?? finalWidth));
16273
- const cleanH = Math.max(1, Number(elementUpdate.height ?? finalHeight));
16274
- const cx = decomposed.translateX ?? absoluteLeft + cleanW / 2;
16275
- const cy = decomposed.translateY ?? absoluteTop + cleanH / 2;
16289
+ const parentWorldAngle = activeObj.angle ?? 0;
16290
+ const liveWorldAngleI = Number.isFinite(obj.__asLiveWorldAngle) ? obj.__asLiveWorldAngle : (activeObj.angle ?? 0) + childLocalAngleSrc;
16291
+ const cleanAngleI = Number.isFinite(liveWorldAngleI) ? liveWorldAngleI - parentWorldAngle : childLocalAngleSrc;
16292
+ const cleanW = Math.max(1, Number(obj.__asLiveFinalW ?? elementUpdate.width ?? finalWidth));
16293
+ const cleanH = Math.max(1, Number(obj.__asLiveFinalH ?? elementUpdate.height ?? finalHeight));
16294
+ const cx = Number.isFinite(obj.__asLiveWorldCenterX) ? obj.__asLiveWorldCenterX : decomposed.translateX ?? absoluteLeft + cleanW / 2;
16295
+ const cy = Number.isFinite(obj.__asLiveWorldCenterY) ? obj.__asLiveWorldCenterY : decomposed.translateY ?? absoluteTop + cleanH / 2;
16276
16296
  const thetaI = fabric__namespace.util.degreesToRadians(cleanAngleI);
16277
16297
  const cosI = Math.cos(thetaI);
16278
16298
  const sinI = Math.sin(thetaI);
@@ -16466,6 +16486,12 @@ const PageCanvas = react.forwardRef(
16466
16486
  if (t instanceof fabric__namespace.ActiveSelection) {
16467
16487
  for (const child of t.getObjects()) {
16468
16488
  delete child.__asLiveOrigAngle;
16489
+ delete child.__asLiveWorldAngle;
16490
+ delete child.__asLiveWorldCenterX;
16491
+ delete child.__asLiveWorldCenterY;
16492
+ delete child.__asLiveParentWorldAngle;
16493
+ delete child.__asLiveFinalW;
16494
+ delete child.__asLiveFinalH;
16469
16495
  }
16470
16496
  }
16471
16497
  } catch {
@@ -25537,9 +25563,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25537
25563
  }
25538
25564
  return svgString;
25539
25565
  }
25540
- const resolvedPackageVersion = "0.5.415";
25566
+ const resolvedPackageVersion = "0.5.417";
25541
25567
  const PACKAGE_VERSION = resolvedPackageVersion;
25542
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.415";
25568
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.417";
25543
25569
  const roundParityValue = (value) => {
25544
25570
  if (typeof value !== "number") return value;
25545
25571
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26353,7 +26379,7 @@ class PixldocsRenderer {
26353
26379
  await this.waitForCanvasScene(container, cloned, i);
26354
26380
  }
26355
26381
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26356
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DaaYbqll.cjs"));
26382
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-zoXsqwIv.cjs"));
26357
26383
  const prepared = preparePagesForExport(
26358
26384
  cloned.pages,
26359
26385
  canvasWidth,
@@ -28673,7 +28699,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28673
28699
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28674
28700
  sanitizeSvgTreeForPdf(svgToDraw);
28675
28701
  try {
28676
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DaaYbqll.cjs"));
28702
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-zoXsqwIv.cjs"));
28677
28703
  try {
28678
28704
  await logTextMeasurementDiagnostic(svgToDraw);
28679
28705
  } catch {
@@ -29070,4 +29096,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29070
29096
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29071
29097
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29072
29098
  exports.warmTemplateFromForm = warmTemplateFromForm;
29073
- //# sourceMappingURL=index-CjQENuN6.cjs.map
29099
+ //# sourceMappingURL=index-DejgwlrF.cjs.map