@pixldocs/canvas-renderer 0.5.312 → 0.5.313

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,30 +11176,39 @@ 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;
11204
11213
  }
11205
11214
  }
@@ -24249,9 +24258,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24249
24258
  }
24250
24259
  return svgString;
24251
24260
  }
24252
- const resolvedPackageVersion = "0.5.312";
24261
+ const resolvedPackageVersion = "0.5.313";
24253
24262
  const PACKAGE_VERSION = resolvedPackageVersion;
24254
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.312";
24263
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.313";
24255
24264
  const roundParityValue = (value) => {
24256
24265
  if (typeof value !== "number") return value;
24257
24266
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25065,7 +25074,7 @@ class PixldocsRenderer {
25065
25074
  await this.waitForCanvasScene(container, cloned, i);
25066
25075
  }
25067
25076
  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");
25077
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BPFpKueR.js");
25069
25078
  const prepared = preparePagesForExport(
25070
25079
  cloned.pages,
25071
25080
  canvasWidth,
@@ -27385,7 +27394,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27385
27394
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27386
27395
  sanitizeSvgTreeForPdf(svgToDraw);
27387
27396
  try {
27388
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-D5wEVDWm.js");
27397
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BPFpKueR.js");
27389
27398
  try {
27390
27399
  await logTextMeasurementDiagnostic(svgToDraw);
27391
27400
  } catch {
@@ -27785,4 +27794,4 @@ export {
27785
27794
  buildTeaserBlurFlatKeys as y,
27786
27795
  collectFontDescriptorsFromConfig as z
27787
27796
  };
27788
- //# sourceMappingURL=index-P103UWW3.js.map
27797
+ //# sourceMappingURL=index-D8s0AmMC.js.map