@pixldocs/canvas-renderer 0.5.323 → 0.5.324

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.
@@ -13590,30 +13590,6 @@ const PageCanvas = react.forwardRef(
13590
13590
  }
13591
13591
  const obj = t;
13592
13592
  if (!obj) return;
13593
- try {
13594
- const transformInfo = e.transform;
13595
- const cornerEarly = (transformInfo == null ? void 0 : transformInfo.corner) || "";
13596
- const isSideHandle = cornerEarly === "ml" || cornerEarly === "mr" || cornerEarly === "mt" || cornerEarly === "mb";
13597
- const isGroupLike = obj instanceof fabric__namespace.Group && !obj.__cropGroup && !obj.__docuforgeSectionGroup;
13598
- if (isSideHandle && isGroupLike && typeof obj.getObjects === "function") {
13599
- const kids = obj.getObjects();
13600
- const hasRotatedChild = kids.some(
13601
- (c) => Math.abs((c.angle ?? 0) % 360) > 0.5
13602
- );
13603
- if (hasRotatedChild) {
13604
- const isXSideEarly = cornerEarly === "ml" || cornerEarly === "mr";
13605
- if (isXSideEarly) {
13606
- obj._set("scaleY", obj.scaleX ?? 1);
13607
- } else {
13608
- obj._set("scaleX", obj.scaleY ?? 1);
13609
- }
13610
- obj.setCoords();
13611
- obj.dirty = true;
13612
- return;
13613
- }
13614
- }
13615
- } catch {
13616
- }
13617
13593
  if (obj instanceof fabric__namespace.Rect || obj instanceof fabric__namespace.Path || obj instanceof fabric__namespace.Circle || obj instanceof fabric__namespace.Triangle || obj instanceof fabric__namespace.Line) {
13618
13594
  obj.set({ strokeUniform: true });
13619
13595
  }
@@ -13782,12 +13758,109 @@ const PageCanvas = react.forwardRef(
13782
13758
  (c) => Math.abs((c.angle ?? 0) % 360) > 0.5
13783
13759
  );
13784
13760
  if (hasRotatedChild) {
13785
- if (isXSide) {
13786
- obj._set("scaleY", obj.scaleX ?? 1);
13787
- } else {
13788
- obj._set("scaleX", obj.scaleY ?? 1);
13761
+ if (obj.__asRotAwareSnap == null) {
13762
+ obj.__asRotAwareSnap = {
13763
+ width: obj.width ?? 0,
13764
+ height: obj.height ?? 0,
13765
+ scaleX: obj.scaleX ?? 1,
13766
+ scaleY: obj.scaleY ?? 1,
13767
+ angle: obj.angle ?? 0,
13768
+ aCoords: (() => {
13769
+ obj.setCoords();
13770
+ const c = obj.aCoords;
13771
+ return c ? { tl: { x: c.tl.x, y: c.tl.y }, tr: { x: c.tr.x, y: c.tr.y }, br: { x: c.br.x, y: c.br.y }, bl: { x: c.bl.x, y: c.bl.y } } : null;
13772
+ })(),
13773
+ corner
13774
+ };
13775
+ for (const ch of obj.getObjects()) {
13776
+ ch.__asRotAwareChild = {
13777
+ width: ch.width ?? 0,
13778
+ height: ch.height ?? 0,
13779
+ scaleX: ch.scaleX ?? 1,
13780
+ scaleY: ch.scaleY ?? 1,
13781
+ left: ch.left ?? 0,
13782
+ top: ch.top ?? 0,
13783
+ angle: ch.angle ?? 0
13784
+ };
13785
+ }
13786
+ }
13787
+ const snap = obj.__asRotAwareSnap;
13788
+ const asAngle = snap.angle;
13789
+ const effAxisScale = isXSide ? (obj.scaleX ?? 1) / (snap.scaleX || 1) : (obj.scaleY ?? 1) / (snap.scaleY || 1);
13790
+ obj._set("scaleX", snap.scaleX);
13791
+ obj._set("scaleY", snap.scaleY);
13792
+ for (const child of obj.getObjects()) {
13793
+ const cSnap = child.__asRotAwareChild;
13794
+ if (!cSnap) continue;
13795
+ const relAngleRad = (cSnap.angle - asAngle) * Math.PI / 180;
13796
+ const proj = Math.abs(Math.cos(relAngleRad));
13797
+ const effChildScale = 1 + (effAxisScale - 1) * proj;
13798
+ if (child instanceof fabric__namespace.Textbox) {
13799
+ if (isXSide) {
13800
+ const origVisW = cSnap.width * (cSnap.scaleX || 1);
13801
+ const newW = Math.max(20, origVisW * effChildScale);
13802
+ if (Math.abs((child.width ?? 0) - newW) > 0.5) {
13803
+ child._set("width", newW);
13804
+ child._set("scaleX", cSnap.scaleX);
13805
+ try {
13806
+ child.initDimensions();
13807
+ } catch {
13808
+ }
13809
+ }
13810
+ } else {
13811
+ const origVisH = cSnap.height * (cSnap.scaleY || 1);
13812
+ const newH = Math.max(20, origVisH * effChildScale);
13813
+ child.minBoxHeight = newH;
13814
+ child._set("scaleY", cSnap.scaleY);
13815
+ try {
13816
+ child.initDimensions();
13817
+ } catch {
13818
+ }
13819
+ }
13820
+ } else if (child instanceof fabric__namespace.FabricImage && !child.__cropGroup && !child.smartElementType) {
13821
+ if (isXSide) {
13822
+ const origVisW = cSnap.width * (cSnap.scaleX || 1);
13823
+ const newW = Math.max(1, origVisW * effChildScale);
13824
+ child._set("width", newW);
13825
+ child._set("scaleX", cSnap.scaleX);
13826
+ } else {
13827
+ const origVisH = cSnap.height * (cSnap.scaleY || 1);
13828
+ const newH = Math.max(1, origVisH * effChildScale);
13829
+ child._set("height", newH);
13830
+ child._set("scaleY", cSnap.scaleY);
13831
+ }
13832
+ } else {
13833
+ child._set("scaleX", (cSnap.scaleX || 1) * effChildScale);
13834
+ child._set("scaleY", (cSnap.scaleY || 1) * effChildScale);
13835
+ }
13836
+ if (isXSide) {
13837
+ child._set("left", cSnap.left * effAxisScale);
13838
+ child._set("top", cSnap.top);
13839
+ } else {
13840
+ child._set("left", cSnap.left);
13841
+ child._set("top", cSnap.top * effAxisScale);
13842
+ }
13843
+ child.setCoords();
13844
+ child.dirty = true;
13845
+ }
13846
+ try {
13847
+ obj.triggerLayout();
13848
+ } catch {
13789
13849
  }
13790
13850
  obj.setCoords();
13851
+ const aAfter = obj.aCoords;
13852
+ const aBefore = snap.aCoords;
13853
+ if (aBefore && aAfter) {
13854
+ const midBefore = corner === "ml" ? { x: (aBefore.tr.x + aBefore.br.x) / 2, y: (aBefore.tr.y + aBefore.br.y) / 2 } : corner === "mr" ? { x: (aBefore.tl.x + aBefore.bl.x) / 2, y: (aBefore.tl.y + aBefore.bl.y) / 2 } : corner === "mt" ? { x: (aBefore.bl.x + aBefore.br.x) / 2, y: (aBefore.bl.y + aBefore.br.y) / 2 } : { x: (aBefore.tl.x + aBefore.tr.x) / 2, y: (aBefore.tl.y + aBefore.tr.y) / 2 };
13855
+ const midAfter = corner === "ml" ? { x: (aAfter.tr.x + aAfter.br.x) / 2, y: (aAfter.tr.y + aAfter.br.y) / 2 } : corner === "mr" ? { x: (aAfter.tl.x + aAfter.bl.x) / 2, y: (aAfter.tl.y + aAfter.bl.y) / 2 } : corner === "mt" ? { x: (aAfter.bl.x + aAfter.br.x) / 2, y: (aAfter.bl.y + aAfter.br.y) / 2 } : { x: (aAfter.tl.x + aAfter.tr.x) / 2, y: (aAfter.tl.y + aAfter.tr.y) / 2 };
13856
+ const dx = midBefore.x - midAfter.x;
13857
+ const dy = midBefore.y - midAfter.y;
13858
+ if (Math.abs(dx) > 0.01 || Math.abs(dy) > 0.01) {
13859
+ obj._set("left", (obj.left ?? 0) + dx);
13860
+ obj._set("top", (obj.top ?? 0) + dy);
13861
+ obj.setCoords();
13862
+ }
13863
+ }
13791
13864
  obj.dirty = true;
13792
13865
  return;
13793
13866
  }
@@ -14291,7 +14364,9 @@ const PageCanvas = react.forwardRef(
14291
14364
  for (const child of t.getObjects()) {
14292
14365
  delete child.__asLiveOrigW;
14293
14366
  delete child.__asLiveOrigH;
14367
+ delete child.__asRotAwareChild;
14294
14368
  }
14369
+ delete t.__asRotAwareSnap;
14295
14370
  }
14296
14371
  } catch {
14297
14372
  }
@@ -24318,9 +24393,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24318
24393
  }
24319
24394
  return svgString;
24320
24395
  }
24321
- const resolvedPackageVersion = "0.5.323";
24396
+ const resolvedPackageVersion = "0.5.324";
24322
24397
  const PACKAGE_VERSION = resolvedPackageVersion;
24323
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.323";
24398
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.324";
24324
24399
  const roundParityValue = (value) => {
24325
24400
  if (typeof value !== "number") return value;
24326
24401
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25134,7 +25209,7 @@ class PixldocsRenderer {
25134
25209
  await this.waitForCanvasScene(container, cloned, i);
25135
25210
  }
25136
25211
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25137
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Da51BWna.cjs"));
25212
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DYMHC1Zs.cjs"));
25138
25213
  const prepared = preparePagesForExport(
25139
25214
  cloned.pages,
25140
25215
  canvasWidth,
@@ -27454,7 +27529,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27454
27529
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27455
27530
  sanitizeSvgTreeForPdf(svgToDraw);
27456
27531
  try {
27457
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Da51BWna.cjs"));
27532
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DYMHC1Zs.cjs"));
27458
27533
  try {
27459
27534
  await logTextMeasurementDiagnostic(svgToDraw);
27460
27535
  } catch {
@@ -27851,4 +27926,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27851
27926
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27852
27927
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27853
27928
  exports.warmTemplateFromForm = warmTemplateFromForm;
27854
- //# sourceMappingURL=index-DZw_u3PM.cjs.map
27929
+ //# sourceMappingURL=index-DPUc5rGE.cjs.map