@pixldocs/canvas-renderer 0.5.315 → 0.5.317

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
  }
@@ -13582,12 +13593,15 @@ const PageCanvas = react.forwardRef(
13582
13593
  const t = e.target;
13583
13594
  if (t) lastResizeScaleTargetRef.current = t;
13584
13595
  try {
13585
- if (t instanceof fabric__namespace.ActiveSelection && t.__pixldocsMixedRotation) {
13586
- const corner2 = (_a2 = e.transform) == null ? void 0 : _a2.corner;
13587
- if (corner2 === "ml" || corner2 === "mr") {
13588
- t.scaleY = t.scaleX;
13589
- } else if (corner2 === "mt" || corner2 === "mb") {
13590
- t.scaleX = t.scaleY;
13596
+ if (t instanceof fabric__namespace.ActiveSelection) {
13597
+ const isRotated = !!t.__pixldocsMixedRotation || Math.abs(((t.angle ?? 0) % 360 + 360) % 360) > 0.5;
13598
+ if (isRotated) {
13599
+ const corner2 = (_a2 = e.transform) == null ? void 0 : _a2.corner;
13600
+ if (corner2 === "ml" || corner2 === "mr") {
13601
+ t.scaleY = t.scaleX;
13602
+ } else if (corner2 === "mt" || corner2 === "mb") {
13603
+ t.scaleX = t.scaleY;
13604
+ }
13591
13605
  }
13592
13606
  }
13593
13607
  } catch {
@@ -13761,7 +13775,8 @@ const PageCanvas = react.forwardRef(
13761
13775
  };
13762
13776
  }
13763
13777
  }
13764
- if (obj instanceof fabric__namespace.ActiveSelection && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
13778
+ const _asRotatedForReflow = obj instanceof fabric__namespace.ActiveSelection && (!!obj.__pixldocsMixedRotation || Math.abs(((obj.angle ?? 0) % 360 + 360) % 360) > 0.5);
13779
+ if (obj instanceof fabric__namespace.ActiveSelection && !_asRotatedForReflow && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
13765
13780
  const isXSide = corner === "ml" || corner === "mr";
13766
13781
  const sAxis = isXSide ? Math.abs(obj.scaleX ?? 1) : Math.abs(obj.scaleY ?? 1);
13767
13782
  if (sAxis > 1e-3) {
@@ -24292,9 +24307,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24292
24307
  }
24293
24308
  return svgString;
24294
24309
  }
24295
- const resolvedPackageVersion = "0.5.315";
24310
+ const resolvedPackageVersion = "0.5.317";
24296
24311
  const PACKAGE_VERSION = resolvedPackageVersion;
24297
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.315";
24312
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.317";
24298
24313
  const roundParityValue = (value) => {
24299
24314
  if (typeof value !== "number") return value;
24300
24315
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25108,7 +25123,7 @@ class PixldocsRenderer {
25108
25123
  await this.waitForCanvasScene(container, cloned, i);
25109
25124
  }
25110
25125
  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"));
25126
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Cbrzzq6K.cjs"));
25112
25127
  const prepared = preparePagesForExport(
25113
25128
  cloned.pages,
25114
25129
  canvasWidth,
@@ -27428,7 +27443,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27428
27443
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27429
27444
  sanitizeSvgTreeForPdf(svgToDraw);
27430
27445
  try {
27431
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Co08KOeq.cjs"));
27446
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Cbrzzq6K.cjs"));
27432
27447
  try {
27433
27448
  await logTextMeasurementDiagnostic(svgToDraw);
27434
27449
  } catch {
@@ -27825,4 +27840,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27825
27840
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27826
27841
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27827
27842
  exports.warmTemplateFromForm = warmTemplateFromForm;
27828
- //# sourceMappingURL=index-CyM9SvCF.cjs.map
27843
+ //# sourceMappingURL=index-Bx4Y_HmX.cjs.map