@pixldocs/canvas-renderer 0.5.315 → 0.5.316

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.
@@ -11184,8 +11184,23 @@ function applyWarpAwareSelectionBorders(selection) {
11184
11184
  ));
11185
11185
  const worldAngles = worldMatrices.map((m) => norm(fabric.util.qrDecompose(m).angle ?? 0));
11186
11186
  const first = worldAngles[0] ?? 0;
11187
- const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= 0.5);
11187
+ const ALL_SAME_TOL_DEG = 2;
11188
+ const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= ALL_SAME_TOL_DEG);
11189
+ const anyRotated = worldAngles.some((a) => Math.abs(a) > 0.5);
11190
+ let targetAngle = null;
11188
11191
  if (allSame) {
11192
+ targetAngle = first;
11193
+ } else if (anyRotated) {
11194
+ const rad = (d) => d * Math.PI / 180;
11195
+ const deg = (r) => r * 180 / Math.PI;
11196
+ let sx = 0, sy = 0;
11197
+ for (const a of worldAngles) {
11198
+ sx += Math.cos(rad(a));
11199
+ sy += Math.sin(rad(a));
11200
+ }
11201
+ targetAngle = norm(deg(Math.atan2(sy, sx)));
11202
+ }
11203
+ if (targetAngle != null) {
11189
11204
  const restoreKidsFromWorld = () => {
11190
11205
  const invSelection = fabric.util.invertTransform(
11191
11206
  selection.calcTransformMatrix()
@@ -11200,7 +11215,7 @@ function applyWarpAwareSelectionBorders(selection) {
11200
11215
  k.dirty = true;
11201
11216
  });
11202
11217
  };
11203
- selection.set({ angle: first, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11218
+ selection.set({ angle: targetAngle, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11204
11219
  restoreKidsFromWorld();
11205
11220
  try {
11206
11221
  (_a2 = selection.triggerLayout) == null ? void 0 : _a2.call(selection);
@@ -11209,12 +11224,8 @@ function applyWarpAwareSelectionBorders(selection) {
11209
11224
  restoreKidsFromWorld();
11210
11225
  selection.setCoords();
11211
11226
  selection.dirty = true;
11212
- selection.__pixldocsAlignedAngle = first;
11213
- } else {
11214
- const anyRotated = worldAngles.some((a) => Math.abs(a) > 0.5);
11215
- if (anyRotated) {
11216
- selection.__pixldocsMixedRotation = true;
11217
- }
11227
+ selection.__pixldocsAlignedAngle = targetAngle;
11228
+ if (!allSame) selection.__pixldocsMixedRotation = true;
11218
11229
  }
11219
11230
  }
11220
11231
  }
@@ -24274,9 +24285,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24274
24285
  }
24275
24286
  return svgString;
24276
24287
  }
24277
- const resolvedPackageVersion = "0.5.315";
24288
+ const resolvedPackageVersion = "0.5.316";
24278
24289
  const PACKAGE_VERSION = resolvedPackageVersion;
24279
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.315";
24290
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.316";
24280
24291
  const roundParityValue = (value) => {
24281
24292
  if (typeof value !== "number") return value;
24282
24293
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25090,7 +25101,7 @@ class PixldocsRenderer {
25090
25101
  await this.waitForCanvasScene(container, cloned, i);
25091
25102
  }
25092
25103
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25093
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BrYF2E8L.js");
25104
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DR523IAy.js");
25094
25105
  const prepared = preparePagesForExport(
25095
25106
  cloned.pages,
25096
25107
  canvasWidth,
@@ -27410,7 +27421,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27410
27421
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27411
27422
  sanitizeSvgTreeForPdf(svgToDraw);
27412
27423
  try {
27413
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BrYF2E8L.js");
27424
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DR523IAy.js");
27414
27425
  try {
27415
27426
  await logTextMeasurementDiagnostic(svgToDraw);
27416
27427
  } catch {
@@ -27810,4 +27821,4 @@ export {
27810
27821
  buildTeaserBlurFlatKeys as y,
27811
27822
  collectFontDescriptorsFromConfig as z
27812
27823
  };
27813
- //# sourceMappingURL=index-BVj3Aj4_.js.map
27824
+ //# sourceMappingURL=index-D23LGkaT.js.map