@pixldocs/canvas-renderer 0.5.389 → 0.5.391

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,18 @@ 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;
11459
11458
  const ALL_SAME_TOL_DEG = 2;
11460
- const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= ALL_SAME_TOL_DEG);
11459
+ const buckets = [];
11460
+ for (const a of worldAngles) {
11461
+ const b = buckets.find((x) => angleDelta(x.angle, a) <= ALL_SAME_TOL_DEG);
11462
+ if (b) b.count++;
11463
+ else buckets.push({ angle: a, count: 1 });
11464
+ }
11465
+ buckets.sort((a, b) => b.count - a.count);
11466
+ const dominant = buckets[0];
11461
11467
  let targetAngle = null;
11462
- if (allSame) {
11463
- targetAngle = first;
11468
+ if (dominant && Math.abs(dominant.angle) > 0.5 && (kids.length === 1 || dominant.count >= 2 || dominant.count === kids.length)) {
11469
+ targetAngle = dominant.angle;
11464
11470
  }
11465
11471
  if (targetAngle != null) {
11466
11472
  const restoreKidsFromWorld = () => {
@@ -13522,13 +13528,19 @@ const PageCanvas = forwardRef(
13522
13528
  if (oid && memberIds.has(oid)) members.push(o);
13523
13529
  }
13524
13530
  if (members.length === 0) return null;
13525
- const a0 = ((members[0].angle ?? 0) % 360 + 360) % 360;
13526
13531
  const TOL = 0.5;
13532
+ const buckets = [];
13527
13533
  for (const m of members) {
13528
13534
  const a = ((m.angle ?? 0) % 360 + 360) % 360;
13529
- const diff = Math.min(Math.abs(a - a0), 360 - Math.abs(a - a0));
13530
- if (diff > TOL) return null;
13535
+ const b = buckets.find((x) => {
13536
+ const d = Math.min(Math.abs(x.angle - a), 360 - Math.abs(x.angle - a));
13537
+ return d <= TOL;
13538
+ });
13539
+ if (b) b.count++;
13540
+ else buckets.push({ angle: a, count: 1 });
13531
13541
  }
13542
+ buckets.sort((a, b) => b.count - a.count);
13543
+ const a0 = buckets[0].angle;
13532
13544
  const rad = -a0 * Math.PI / 180;
13533
13545
  const cos = Math.cos(rad), sin = Math.sin(rad);
13534
13546
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
@@ -25018,9 +25030,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25018
25030
  }
25019
25031
  return svgString;
25020
25032
  }
25021
- const resolvedPackageVersion = "0.5.389";
25033
+ const resolvedPackageVersion = "0.5.391";
25022
25034
  const PACKAGE_VERSION = resolvedPackageVersion;
25023
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.389";
25035
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.391";
25024
25036
  const roundParityValue = (value) => {
25025
25037
  if (typeof value !== "number") return value;
25026
25038
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25834,7 +25846,7 @@ class PixldocsRenderer {
25834
25846
  await this.waitForCanvasScene(container, cloned, i);
25835
25847
  }
25836
25848
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25837
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-aeROfqEB.js");
25849
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-C8_CSDHY.js");
25838
25850
  const prepared = preparePagesForExport(
25839
25851
  cloned.pages,
25840
25852
  canvasWidth,
@@ -28154,7 +28166,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28154
28166
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28155
28167
  sanitizeSvgTreeForPdf(svgToDraw);
28156
28168
  try {
28157
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-aeROfqEB.js");
28169
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-C8_CSDHY.js");
28158
28170
  try {
28159
28171
  await logTextMeasurementDiagnostic(svgToDraw);
28160
28172
  } catch {
@@ -28554,4 +28566,4 @@ export {
28554
28566
  buildTeaserBlurFlatKeys as y,
28555
28567
  collectFontDescriptorsFromConfig as z
28556
28568
  };
28557
- //# sourceMappingURL=index-CxeXN5KG.js.map
28569
+ //# sourceMappingURL=index-Cx-Z8HWW.js.map