@pixldocs/canvas-renderer 0.5.324 → 0.5.325

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.
@@ -13736,113 +13736,21 @@ const PageCanvas = forwardRef(
13736
13736
  const isXSide = corner === "ml" || corner === "mr";
13737
13737
  const sAxis = isXSide ? Math.abs(obj.scaleX ?? 1) : Math.abs(obj.scaleY ?? 1);
13738
13738
  if (sAxis > 1e-3) {
13739
- const hasRotatedChild = obj.getObjects().some(
13740
- (c) => Math.abs((c.angle ?? 0) % 360) > 0.5
13739
+ const childAnglesNorm = obj.getObjects().map((c) => {
13740
+ const a = (c.angle ?? 0) % 360;
13741
+ return a < 0 ? a + 360 : a;
13742
+ });
13743
+ const baseAngle = childAnglesNorm[0] ?? 0;
13744
+ const hasMixedRotation = childAnglesNorm.some(
13745
+ (a) => Math.abs(a - baseAngle) > 0.5 && Math.abs(Math.abs(a - baseAngle) - 360) > 0.5
13741
13746
  );
13742
- if (hasRotatedChild) {
13743
- if (obj.__asRotAwareSnap == null) {
13744
- obj.__asRotAwareSnap = {
13745
- width: obj.width ?? 0,
13746
- height: obj.height ?? 0,
13747
- scaleX: obj.scaleX ?? 1,
13748
- scaleY: obj.scaleY ?? 1,
13749
- angle: obj.angle ?? 0,
13750
- aCoords: (() => {
13751
- obj.setCoords();
13752
- const c = obj.aCoords;
13753
- 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;
13754
- })(),
13755
- corner
13756
- };
13757
- for (const ch of obj.getObjects()) {
13758
- ch.__asRotAwareChild = {
13759
- width: ch.width ?? 0,
13760
- height: ch.height ?? 0,
13761
- scaleX: ch.scaleX ?? 1,
13762
- scaleY: ch.scaleY ?? 1,
13763
- left: ch.left ?? 0,
13764
- top: ch.top ?? 0,
13765
- angle: ch.angle ?? 0
13766
- };
13767
- }
13768
- }
13769
- const snap = obj.__asRotAwareSnap;
13770
- const asAngle = snap.angle;
13771
- const effAxisScale = isXSide ? (obj.scaleX ?? 1) / (snap.scaleX || 1) : (obj.scaleY ?? 1) / (snap.scaleY || 1);
13772
- obj._set("scaleX", snap.scaleX);
13773
- obj._set("scaleY", snap.scaleY);
13774
- for (const child of obj.getObjects()) {
13775
- const cSnap = child.__asRotAwareChild;
13776
- if (!cSnap) continue;
13777
- const relAngleRad = (cSnap.angle - asAngle) * Math.PI / 180;
13778
- const proj = Math.abs(Math.cos(relAngleRad));
13779
- const effChildScale = 1 + (effAxisScale - 1) * proj;
13780
- if (child instanceof fabric.Textbox) {
13781
- if (isXSide) {
13782
- const origVisW = cSnap.width * (cSnap.scaleX || 1);
13783
- const newW = Math.max(20, origVisW * effChildScale);
13784
- if (Math.abs((child.width ?? 0) - newW) > 0.5) {
13785
- child._set("width", newW);
13786
- child._set("scaleX", cSnap.scaleX);
13787
- try {
13788
- child.initDimensions();
13789
- } catch {
13790
- }
13791
- }
13792
- } else {
13793
- const origVisH = cSnap.height * (cSnap.scaleY || 1);
13794
- const newH = Math.max(20, origVisH * effChildScale);
13795
- child.minBoxHeight = newH;
13796
- child._set("scaleY", cSnap.scaleY);
13797
- try {
13798
- child.initDimensions();
13799
- } catch {
13800
- }
13801
- }
13802
- } else if (child instanceof fabric.FabricImage && !child.__cropGroup && !child.smartElementType) {
13803
- if (isXSide) {
13804
- const origVisW = cSnap.width * (cSnap.scaleX || 1);
13805
- const newW = Math.max(1, origVisW * effChildScale);
13806
- child._set("width", newW);
13807
- child._set("scaleX", cSnap.scaleX);
13808
- } else {
13809
- const origVisH = cSnap.height * (cSnap.scaleY || 1);
13810
- const newH = Math.max(1, origVisH * effChildScale);
13811
- child._set("height", newH);
13812
- child._set("scaleY", cSnap.scaleY);
13813
- }
13814
- } else {
13815
- child._set("scaleX", (cSnap.scaleX || 1) * effChildScale);
13816
- child._set("scaleY", (cSnap.scaleY || 1) * effChildScale);
13817
- }
13818
- if (isXSide) {
13819
- child._set("left", cSnap.left * effAxisScale);
13820
- child._set("top", cSnap.top);
13821
- } else {
13822
- child._set("left", cSnap.left);
13823
- child._set("top", cSnap.top * effAxisScale);
13824
- }
13825
- child.setCoords();
13826
- child.dirty = true;
13827
- }
13828
- try {
13829
- obj.triggerLayout();
13830
- } catch {
13747
+ if (hasMixedRotation) {
13748
+ if (isXSide) {
13749
+ obj._set("scaleY", obj.scaleX ?? 1);
13750
+ } else {
13751
+ obj._set("scaleX", obj.scaleY ?? 1);
13831
13752
  }
13832
13753
  obj.setCoords();
13833
- const aAfter = obj.aCoords;
13834
- const aBefore = snap.aCoords;
13835
- if (aBefore && aAfter) {
13836
- 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 };
13837
- 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 };
13838
- const dx = midBefore.x - midAfter.x;
13839
- const dy = midBefore.y - midAfter.y;
13840
- if (Math.abs(dx) > 0.01 || Math.abs(dy) > 0.01) {
13841
- obj._set("left", (obj.left ?? 0) + dx);
13842
- obj._set("top", (obj.top ?? 0) + dy);
13843
- obj.setCoords();
13844
- }
13845
- }
13846
13754
  obj.dirty = true;
13847
13755
  return;
13848
13756
  }
@@ -14346,9 +14254,7 @@ const PageCanvas = forwardRef(
14346
14254
  for (const child of t.getObjects()) {
14347
14255
  delete child.__asLiveOrigW;
14348
14256
  delete child.__asLiveOrigH;
14349
- delete child.__asRotAwareChild;
14350
14257
  }
14351
- delete t.__asRotAwareSnap;
14352
14258
  }
14353
14259
  } catch {
14354
14260
  }
@@ -24375,9 +24281,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24375
24281
  }
24376
24282
  return svgString;
24377
24283
  }
24378
- const resolvedPackageVersion = "0.5.324";
24284
+ const resolvedPackageVersion = "0.5.325";
24379
24285
  const PACKAGE_VERSION = resolvedPackageVersion;
24380
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.324";
24286
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.325";
24381
24287
  const roundParityValue = (value) => {
24382
24288
  if (typeof value !== "number") return value;
24383
24289
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25191,7 +25097,7 @@ class PixldocsRenderer {
25191
25097
  await this.waitForCanvasScene(container, cloned, i);
25192
25098
  }
25193
25099
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25194
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Chs7LuGz.js");
25100
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Mq6tcwR7.js");
25195
25101
  const prepared = preparePagesForExport(
25196
25102
  cloned.pages,
25197
25103
  canvasWidth,
@@ -27511,7 +27417,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27511
27417
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27512
27418
  sanitizeSvgTreeForPdf(svgToDraw);
27513
27419
  try {
27514
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Chs7LuGz.js");
27420
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Mq6tcwR7.js");
27515
27421
  try {
27516
27422
  await logTextMeasurementDiagnostic(svgToDraw);
27517
27423
  } catch {
@@ -27911,4 +27817,4 @@ export {
27911
27817
  buildTeaserBlurFlatKeys as y,
27912
27818
  collectFontDescriptorsFromConfig as z
27913
27819
  };
27914
- //# sourceMappingURL=index-y6RZ0a0x.js.map
27820
+ //# sourceMappingURL=index-CYpr1MY-.js.map