@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.
@@ -11473,12 +11473,18 @@ 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;
11477
11476
  const ALL_SAME_TOL_DEG = 2;
11478
- const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= ALL_SAME_TOL_DEG);
11477
+ const buckets = [];
11478
+ for (const a of worldAngles) {
11479
+ const b = buckets.find((x) => angleDelta(x.angle, a) <= ALL_SAME_TOL_DEG);
11480
+ if (b) b.count++;
11481
+ else buckets.push({ angle: a, count: 1 });
11482
+ }
11483
+ buckets.sort((a, b) => b.count - a.count);
11484
+ const dominant = buckets[0];
11479
11485
  let targetAngle = null;
11480
- if (allSame) {
11481
- targetAngle = first;
11486
+ if (dominant && Math.abs(dominant.angle) > 0.5 && (kids.length === 1 || dominant.count >= 2 || dominant.count === kids.length)) {
11487
+ targetAngle = dominant.angle;
11482
11488
  }
11483
11489
  if (targetAngle != null) {
11484
11490
  const restoreKidsFromWorld = () => {
@@ -13540,13 +13546,19 @@ const PageCanvas = react.forwardRef(
13540
13546
  if (oid && memberIds.has(oid)) members.push(o);
13541
13547
  }
13542
13548
  if (members.length === 0) return null;
13543
- const a0 = ((members[0].angle ?? 0) % 360 + 360) % 360;
13544
13549
  const TOL = 0.5;
13550
+ const buckets = [];
13545
13551
  for (const m of members) {
13546
13552
  const a = ((m.angle ?? 0) % 360 + 360) % 360;
13547
- const diff = Math.min(Math.abs(a - a0), 360 - Math.abs(a - a0));
13548
- if (diff > TOL) return null;
13553
+ const b = buckets.find((x) => {
13554
+ const d = Math.min(Math.abs(x.angle - a), 360 - Math.abs(x.angle - a));
13555
+ return d <= TOL;
13556
+ });
13557
+ if (b) b.count++;
13558
+ else buckets.push({ angle: a, count: 1 });
13549
13559
  }
13560
+ buckets.sort((a, b) => b.count - a.count);
13561
+ const a0 = buckets[0].angle;
13550
13562
  const rad = -a0 * Math.PI / 180;
13551
13563
  const cos = Math.cos(rad), sin = Math.sin(rad);
13552
13564
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
@@ -25036,9 +25048,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25036
25048
  }
25037
25049
  return svgString;
25038
25050
  }
25039
- const resolvedPackageVersion = "0.5.389";
25051
+ const resolvedPackageVersion = "0.5.391";
25040
25052
  const PACKAGE_VERSION = resolvedPackageVersion;
25041
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.389";
25053
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.391";
25042
25054
  const roundParityValue = (value) => {
25043
25055
  if (typeof value !== "number") return value;
25044
25056
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25852,7 +25864,7 @@ class PixldocsRenderer {
25852
25864
  await this.waitForCanvasScene(container, cloned, i);
25853
25865
  }
25854
25866
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25855
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BRGM-p11.cjs"));
25867
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-B8BF2GBZ.cjs"));
25856
25868
  const prepared = preparePagesForExport(
25857
25869
  cloned.pages,
25858
25870
  canvasWidth,
@@ -28172,7 +28184,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28172
28184
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28173
28185
  sanitizeSvgTreeForPdf(svgToDraw);
28174
28186
  try {
28175
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BRGM-p11.cjs"));
28187
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-B8BF2GBZ.cjs"));
28176
28188
  try {
28177
28189
  await logTextMeasurementDiagnostic(svgToDraw);
28178
28190
  } catch {
@@ -28569,4 +28581,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28569
28581
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28570
28582
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28571
28583
  exports.warmTemplateFromForm = warmTemplateFromForm;
28572
- //# sourceMappingURL=index-Z4UNgyZW.cjs.map
28584
+ //# sourceMappingURL=index-C5CC51On.cjs.map