@pixldocs/canvas-renderer 0.5.312 → 0.5.314

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.
@@ -11176,31 +11176,53 @@ function applyWarpAwareSelectionBorders(selection) {
11176
11176
  const n = (a % 360 + 360) % 360;
11177
11177
  return n > 180 ? n - 360 : n;
11178
11178
  };
11179
- const first = norm(((_a2 = kids[0]) == null ? void 0 : _a2.angle) ?? 0);
11180
- let allSame = Math.abs(first) > 0.5;
11179
+ const angleDelta = (a, b) => Math.abs(norm(a - b));
11180
+ const selectionMatrix = selection.calcTransformMatrix();
11181
+ const worldMatrices = kids.map((k) => fabric.util.multiplyTransformMatrices(
11182
+ selectionMatrix,
11183
+ k.calcOwnMatrix()
11184
+ ));
11185
+ const worldAngles = worldMatrices.map((m) => norm(fabric.util.qrDecompose(m).angle ?? 0));
11186
+ const first = worldAngles[0] ?? 0;
11187
+ const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= 0.5);
11181
11188
  if (allSame) {
11182
- for (const k of kids) {
11183
- if (Math.abs(norm(k.angle ?? 0) - first) > 0.5) {
11184
- allSame = false;
11185
- break;
11186
- }
11187
- }
11188
- }
11189
- if (allSame) {
11190
- const rad = -first * Math.PI / 180;
11191
- const cos = Math.cos(rad), sin = Math.sin(rad);
11192
- for (const k of kids) {
11193
- const x = k.left ?? 0, y = k.top ?? 0;
11194
- k.set({
11195
- left: x * cos - y * sin,
11196
- top: x * sin + y * cos,
11197
- angle: 0
11189
+ const restoreKidsFromWorld = () => {
11190
+ const invSelection = fabric.util.invertTransform(
11191
+ selection.calcTransformMatrix()
11192
+ );
11193
+ kids.forEach((k, index) => {
11194
+ const localMatrix = fabric.util.multiplyTransformMatrices(
11195
+ invSelection,
11196
+ worldMatrices[index]
11197
+ );
11198
+ fabric.util.applyTransformToObject(k, localMatrix);
11199
+ k.setCoords();
11200
+ k.dirty = true;
11198
11201
  });
11199
- k.setCoords();
11202
+ };
11203
+ selection.set({ angle: first, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11204
+ restoreKidsFromWorld();
11205
+ try {
11206
+ (_a2 = selection.triggerLayout) == null ? void 0 : _a2.call(selection);
11207
+ } catch {
11200
11208
  }
11201
- selection.set({ angle: first });
11209
+ restoreKidsFromWorld();
11202
11210
  selection.setCoords();
11211
+ selection.dirty = true;
11203
11212
  selection.__pixldocsAlignedAngle = first;
11213
+ } else {
11214
+ const anyRotated = worldAngles.some((a) => Math.abs(a) > 0.5);
11215
+ if (anyRotated) {
11216
+ try {
11217
+ selection.setControlsVisibility({
11218
+ ml: false,
11219
+ mr: false,
11220
+ mt: false,
11221
+ mb: false
11222
+ });
11223
+ } catch {
11224
+ }
11225
+ }
11204
11226
  }
11205
11227
  }
11206
11228
  }
@@ -24249,9 +24271,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24249
24271
  }
24250
24272
  return svgString;
24251
24273
  }
24252
- const resolvedPackageVersion = "0.5.312";
24274
+ const resolvedPackageVersion = "0.5.314";
24253
24275
  const PACKAGE_VERSION = resolvedPackageVersion;
24254
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.312";
24276
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.314";
24255
24277
  const roundParityValue = (value) => {
24256
24278
  if (typeof value !== "number") return value;
24257
24279
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25065,7 +25087,7 @@ class PixldocsRenderer {
25065
25087
  await this.waitForCanvasScene(container, cloned, i);
25066
25088
  }
25067
25089
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25068
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-D5wEVDWm.js");
25090
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DBoLqkEn.js");
25069
25091
  const prepared = preparePagesForExport(
25070
25092
  cloned.pages,
25071
25093
  canvasWidth,
@@ -27385,7 +27407,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27385
27407
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27386
27408
  sanitizeSvgTreeForPdf(svgToDraw);
27387
27409
  try {
27388
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-D5wEVDWm.js");
27410
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DBoLqkEn.js");
27389
27411
  try {
27390
27412
  await logTextMeasurementDiagnostic(svgToDraw);
27391
27413
  } catch {
@@ -27785,4 +27807,4 @@ export {
27785
27807
  buildTeaserBlurFlatKeys as y,
27786
27808
  collectFontDescriptorsFromConfig as z
27787
27809
  };
27788
- //# sourceMappingURL=index-P103UWW3.js.map
27810
+ //# sourceMappingURL=index-Dr4Grd18.js.map