@pixldocs/canvas-renderer 0.5.416 → 0.5.418

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