@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.
@@ -11202,8 +11202,23 @@ function applyWarpAwareSelectionBorders(selection) {
11202
11202
  ));
11203
11203
  const worldAngles = worldMatrices.map((m) => norm(fabric__namespace.util.qrDecompose(m).angle ?? 0));
11204
11204
  const first = worldAngles[0] ?? 0;
11205
- const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= 0.5);
11205
+ const ALL_SAME_TOL_DEG = 2;
11206
+ const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= ALL_SAME_TOL_DEG);
11207
+ const anyRotated = worldAngles.some((a) => Math.abs(a) > 0.5);
11208
+ let targetAngle = null;
11206
11209
  if (allSame) {
11210
+ targetAngle = first;
11211
+ } else if (anyRotated) {
11212
+ const rad = (d) => d * Math.PI / 180;
11213
+ const deg = (r) => r * 180 / Math.PI;
11214
+ let sx = 0, sy = 0;
11215
+ for (const a of worldAngles) {
11216
+ sx += Math.cos(rad(a));
11217
+ sy += Math.sin(rad(a));
11218
+ }
11219
+ targetAngle = norm(deg(Math.atan2(sy, sx)));
11220
+ }
11221
+ if (targetAngle != null) {
11207
11222
  const restoreKidsFromWorld = () => {
11208
11223
  const invSelection = fabric__namespace.util.invertTransform(
11209
11224
  selection.calcTransformMatrix()
@@ -11218,7 +11233,7 @@ function applyWarpAwareSelectionBorders(selection) {
11218
11233
  k.dirty = true;
11219
11234
  });
11220
11235
  };
11221
- selection.set({ angle: first, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11236
+ selection.set({ angle: targetAngle, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11222
11237
  restoreKidsFromWorld();
11223
11238
  try {
11224
11239
  (_a2 = selection.triggerLayout) == null ? void 0 : _a2.call(selection);
@@ -11227,12 +11242,8 @@ function applyWarpAwareSelectionBorders(selection) {
11227
11242
  restoreKidsFromWorld();
11228
11243
  selection.setCoords();
11229
11244
  selection.dirty = true;
11230
- selection.__pixldocsAlignedAngle = first;
11231
- } else {
11232
- const anyRotated = worldAngles.some((a) => Math.abs(a) > 0.5);
11233
- if (anyRotated) {
11234
- selection.__pixldocsMixedRotation = true;
11235
- }
11245
+ selection.__pixldocsAlignedAngle = targetAngle;
11246
+ if (!allSame) selection.__pixldocsMixedRotation = true;
11236
11247
  }
11237
11248
  }
11238
11249
  }
@@ -24292,9 +24303,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24292
24303
  }
24293
24304
  return svgString;
24294
24305
  }
24295
- const resolvedPackageVersion = "0.5.315";
24306
+ const resolvedPackageVersion = "0.5.316";
24296
24307
  const PACKAGE_VERSION = resolvedPackageVersion;
24297
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.315";
24308
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.316";
24298
24309
  const roundParityValue = (value) => {
24299
24310
  if (typeof value !== "number") return value;
24300
24311
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25108,7 +25119,7 @@ class PixldocsRenderer {
25108
25119
  await this.waitForCanvasScene(container, cloned, i);
25109
25120
  }
25110
25121
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25111
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Co08KOeq.cjs"));
25122
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CFD-x_MA.cjs"));
25112
25123
  const prepared = preparePagesForExport(
25113
25124
  cloned.pages,
25114
25125
  canvasWidth,
@@ -27428,7 +27439,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27428
27439
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27429
27440
  sanitizeSvgTreeForPdf(svgToDraw);
27430
27441
  try {
27431
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Co08KOeq.cjs"));
27442
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CFD-x_MA.cjs"));
27432
27443
  try {
27433
27444
  await logTextMeasurementDiagnostic(svgToDraw);
27434
27445
  } catch {
@@ -27825,4 +27836,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27825
27836
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27826
27837
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27827
27838
  exports.warmTemplateFromForm = warmTemplateFromForm;
27828
- //# sourceMappingURL=index-CyM9SvCF.cjs.map
27839
+ //# sourceMappingURL=index-CnPI9yBL.cjs.map