@pixldocs/canvas-renderer 0.5.390 → 0.5.392

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.
@@ -11455,12 +11455,54 @@ function applyWarpAwareSelectionBorders(selection) {
11455
11455
  k.calcOwnMatrix()
11456
11456
  ));
11457
11457
  const worldAngles = worldMatrices.map((m) => norm(fabric.util.qrDecompose(m).angle ?? 0));
11458
- const first = worldAngles[0] ?? 0;
11458
+ const worldPoints = [];
11459
+ for (const k of kids) {
11460
+ try {
11461
+ k.setCoords();
11462
+ } catch {
11463
+ }
11464
+ const coords = typeof k.getCoords === "function" ? k.getCoords() : null;
11465
+ if (Array.isArray(coords) && coords.length) {
11466
+ worldPoints.push(...coords.map((p) => ({ x: p.x, y: p.y })));
11467
+ continue;
11468
+ }
11469
+ const aC = k.aCoords;
11470
+ if (aC) {
11471
+ for (const key of ["tl", "tr", "br", "bl"]) {
11472
+ const p = aC[key];
11473
+ if (p) worldPoints.push({ x: p.x, y: p.y });
11474
+ }
11475
+ }
11476
+ }
11477
+ const orientedAreaForAngle = (angle) => {
11478
+ if (worldPoints.length === 0) return Number.POSITIVE_INFINITY;
11479
+ const rad = -angle * Math.PI / 180;
11480
+ const cos = Math.cos(rad), sin = Math.sin(rad);
11481
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
11482
+ for (const p of worldPoints) {
11483
+ const xr = p.x * cos - p.y * sin;
11484
+ const yr = p.x * sin + p.y * cos;
11485
+ minX = Math.min(minX, xr);
11486
+ minY = Math.min(minY, yr);
11487
+ maxX = Math.max(maxX, xr);
11488
+ maxY = Math.max(maxY, yr);
11489
+ }
11490
+ return Math.max(1, (maxX - minX) * (maxY - minY));
11491
+ };
11459
11492
  const ALL_SAME_TOL_DEG = 2;
11460
- const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= ALL_SAME_TOL_DEG);
11493
+ const buckets = [];
11494
+ for (const a of worldAngles) {
11495
+ const b = buckets.find((x) => angleDelta(x.angle, a) <= ALL_SAME_TOL_DEG);
11496
+ if (b) b.count++;
11497
+ else buckets.push({ angle: a, count: 1, area: Number.POSITIVE_INFINITY });
11498
+ }
11499
+ for (const b of buckets) b.area = orientedAreaForAngle(b.angle);
11500
+ buckets.sort((a, b) => b.count - a.count || a.area - b.area || Math.abs(b.angle) - Math.abs(a.angle));
11501
+ const dominant = buckets[0];
11461
11502
  let targetAngle = null;
11462
- if (allSame) {
11463
- targetAngle = first;
11503
+ const isLogicalGroupSelection = !!selection.__pixldocsGroupSelection;
11504
+ if (dominant && Math.abs(dominant.angle) > 0.5 && (isLogicalGroupSelection || kids.length === 1 || dominant.count >= 2 || dominant.count === kids.length)) {
11505
+ targetAngle = dominant.angle;
11464
11506
  }
11465
11507
  if (targetAngle != null) {
11466
11508
  const restoreKidsFromWorld = () => {
@@ -25024,9 +25066,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25024
25066
  }
25025
25067
  return svgString;
25026
25068
  }
25027
- const resolvedPackageVersion = "0.5.390";
25069
+ const resolvedPackageVersion = "0.5.392";
25028
25070
  const PACKAGE_VERSION = resolvedPackageVersion;
25029
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.390";
25071
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.392";
25030
25072
  const roundParityValue = (value) => {
25031
25073
  if (typeof value !== "number") return value;
25032
25074
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25840,7 +25882,7 @@ class PixldocsRenderer {
25840
25882
  await this.waitForCanvasScene(container, cloned, i);
25841
25883
  }
25842
25884
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25843
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-p4K2EISX.js");
25885
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CRmMt10E.js");
25844
25886
  const prepared = preparePagesForExport(
25845
25887
  cloned.pages,
25846
25888
  canvasWidth,
@@ -28160,7 +28202,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28160
28202
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28161
28203
  sanitizeSvgTreeForPdf(svgToDraw);
28162
28204
  try {
28163
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-p4K2EISX.js");
28205
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CRmMt10E.js");
28164
28206
  try {
28165
28207
  await logTextMeasurementDiagnostic(svgToDraw);
28166
28208
  } catch {
@@ -28560,4 +28602,4 @@ export {
28560
28602
  buildTeaserBlurFlatKeys as y,
28561
28603
  collectFontDescriptorsFromConfig as z
28562
28604
  };
28563
- //# sourceMappingURL=index-ByJXwd5Y.js.map
28605
+ //# sourceMappingURL=index-BMosbEqF.js.map