@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.
@@ -11473,12 +11473,54 @@ function applyWarpAwareSelectionBorders(selection) {
11473
11473
  k.calcOwnMatrix()
11474
11474
  ));
11475
11475
  const worldAngles = worldMatrices.map((m) => norm(fabric__namespace.util.qrDecompose(m).angle ?? 0));
11476
- const first = worldAngles[0] ?? 0;
11476
+ const worldPoints = [];
11477
+ for (const k of kids) {
11478
+ try {
11479
+ k.setCoords();
11480
+ } catch {
11481
+ }
11482
+ const coords = typeof k.getCoords === "function" ? k.getCoords() : null;
11483
+ if (Array.isArray(coords) && coords.length) {
11484
+ worldPoints.push(...coords.map((p) => ({ x: p.x, y: p.y })));
11485
+ continue;
11486
+ }
11487
+ const aC = k.aCoords;
11488
+ if (aC) {
11489
+ for (const key of ["tl", "tr", "br", "bl"]) {
11490
+ const p = aC[key];
11491
+ if (p) worldPoints.push({ x: p.x, y: p.y });
11492
+ }
11493
+ }
11494
+ }
11495
+ const orientedAreaForAngle = (angle) => {
11496
+ if (worldPoints.length === 0) return Number.POSITIVE_INFINITY;
11497
+ const rad = -angle * Math.PI / 180;
11498
+ const cos = Math.cos(rad), sin = Math.sin(rad);
11499
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
11500
+ for (const p of worldPoints) {
11501
+ const xr = p.x * cos - p.y * sin;
11502
+ const yr = p.x * sin + p.y * cos;
11503
+ minX = Math.min(minX, xr);
11504
+ minY = Math.min(minY, yr);
11505
+ maxX = Math.max(maxX, xr);
11506
+ maxY = Math.max(maxY, yr);
11507
+ }
11508
+ return Math.max(1, (maxX - minX) * (maxY - minY));
11509
+ };
11477
11510
  const ALL_SAME_TOL_DEG = 2;
11478
- const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= ALL_SAME_TOL_DEG);
11511
+ const buckets = [];
11512
+ for (const a of worldAngles) {
11513
+ const b = buckets.find((x) => angleDelta(x.angle, a) <= ALL_SAME_TOL_DEG);
11514
+ if (b) b.count++;
11515
+ else buckets.push({ angle: a, count: 1, area: Number.POSITIVE_INFINITY });
11516
+ }
11517
+ for (const b of buckets) b.area = orientedAreaForAngle(b.angle);
11518
+ buckets.sort((a, b) => b.count - a.count || a.area - b.area || Math.abs(b.angle) - Math.abs(a.angle));
11519
+ const dominant = buckets[0];
11479
11520
  let targetAngle = null;
11480
- if (allSame) {
11481
- targetAngle = first;
11521
+ const isLogicalGroupSelection = !!selection.__pixldocsGroupSelection;
11522
+ if (dominant && Math.abs(dominant.angle) > 0.5 && (isLogicalGroupSelection || kids.length === 1 || dominant.count >= 2 || dominant.count === kids.length)) {
11523
+ targetAngle = dominant.angle;
11482
11524
  }
11483
11525
  if (targetAngle != null) {
11484
11526
  const restoreKidsFromWorld = () => {
@@ -25042,9 +25084,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25042
25084
  }
25043
25085
  return svgString;
25044
25086
  }
25045
- const resolvedPackageVersion = "0.5.390";
25087
+ const resolvedPackageVersion = "0.5.392";
25046
25088
  const PACKAGE_VERSION = resolvedPackageVersion;
25047
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.390";
25089
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.392";
25048
25090
  const roundParityValue = (value) => {
25049
25091
  if (typeof value !== "number") return value;
25050
25092
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25858,7 +25900,7 @@ class PixldocsRenderer {
25858
25900
  await this.waitForCanvasScene(container, cloned, i);
25859
25901
  }
25860
25902
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25861
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-3tLyCSst.cjs"));
25903
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DhWvQzRg.cjs"));
25862
25904
  const prepared = preparePagesForExport(
25863
25905
  cloned.pages,
25864
25906
  canvasWidth,
@@ -28178,7 +28220,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28178
28220
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28179
28221
  sanitizeSvgTreeForPdf(svgToDraw);
28180
28222
  try {
28181
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-3tLyCSst.cjs"));
28223
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DhWvQzRg.cjs"));
28182
28224
  try {
28183
28225
  await logTextMeasurementDiagnostic(svgToDraw);
28184
28226
  } catch {
@@ -28575,4 +28617,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28575
28617
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28576
28618
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28577
28619
  exports.warmTemplateFromForm = warmTemplateFromForm;
28578
- //# sourceMappingURL=index-BAbK6GX5.cjs.map
28620
+ //# sourceMappingURL=index-B0qSXTeJ.cjs.map