@pixldocs/canvas-renderer 0.5.311 → 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.
@@ -11187,25 +11187,50 @@ function applyWarpAwareSelectionBorders(selection) {
11187
11187
  selection.hasBorders = true;
11188
11188
  selection.hasControls = true;
11189
11189
  try {
11190
- const kids = selection.getObjects();
11191
- let allSameNonZero = kids.length > 0;
11192
- const first = ((((_a2 = kids[0]) == null ? void 0 : _a2.angle) ?? 0) % 360 + 360) % 360;
11193
- if (Math.abs(first) < 0.5 || Math.abs(first - 360) < 0.5) allSameNonZero = false;
11194
- if (allSameNonZero) {
11195
- for (const k of kids) {
11196
- const a = ((k.angle ?? 0) % 360 + 360) % 360;
11197
- if (Math.abs(a - first) > 0.5) {
11198
- allSameNonZero = false;
11199
- break;
11190
+ if (selection.__pixldocsAlignedAngle == null) {
11191
+ const kids = selection.getObjects();
11192
+ if (kids.length >= 1) {
11193
+ const norm = (a) => {
11194
+ const n = (a % 360 + 360) % 360;
11195
+ return n > 180 ? n - 360 : n;
11196
+ };
11197
+ const angleDelta = (a, b) => Math.abs(norm(a - b));
11198
+ const selectionMatrix = selection.calcTransformMatrix();
11199
+ const worldMatrices = kids.map((k) => fabric__namespace.util.multiplyTransformMatrices(
11200
+ selectionMatrix,
11201
+ k.calcOwnMatrix()
11202
+ ));
11203
+ const worldAngles = worldMatrices.map((m) => norm(fabric__namespace.util.qrDecompose(m).angle ?? 0));
11204
+ const first = worldAngles[0] ?? 0;
11205
+ const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= 0.5);
11206
+ if (allSame) {
11207
+ const restoreKidsFromWorld = () => {
11208
+ const invSelection = fabric__namespace.util.invertTransform(
11209
+ selection.calcTransformMatrix()
11210
+ );
11211
+ kids.forEach((k, index) => {
11212
+ const localMatrix = fabric__namespace.util.multiplyTransformMatrices(
11213
+ invSelection,
11214
+ worldMatrices[index]
11215
+ );
11216
+ fabric__namespace.util.applyTransformToObject(k, localMatrix);
11217
+ k.setCoords();
11218
+ k.dirty = true;
11219
+ });
11220
+ };
11221
+ selection.set({ angle: first, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11222
+ restoreKidsFromWorld();
11223
+ try {
11224
+ (_a2 = selection.triggerLayout) == null ? void 0 : _a2.call(selection);
11225
+ } catch {
11226
+ }
11227
+ restoreKidsFromWorld();
11228
+ selection.setCoords();
11229
+ selection.dirty = true;
11230
+ selection.__pixldocsAlignedAngle = first;
11200
11231
  }
11201
11232
  }
11202
11233
  }
11203
- selection.setControlsVisibility({
11204
- ml: !allSameNonZero,
11205
- mr: !allSameNonZero,
11206
- mt: !allSameNonZero,
11207
- mb: !allSameNonZero
11208
- });
11209
11234
  } catch {
11210
11235
  }
11211
11236
  }
@@ -24251,9 +24276,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24251
24276
  }
24252
24277
  return svgString;
24253
24278
  }
24254
- const resolvedPackageVersion = "0.5.311";
24279
+ const resolvedPackageVersion = "0.5.313";
24255
24280
  const PACKAGE_VERSION = resolvedPackageVersion;
24256
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.311";
24281
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.313";
24257
24282
  const roundParityValue = (value) => {
24258
24283
  if (typeof value !== "number") return value;
24259
24284
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25067,7 +25092,7 @@ class PixldocsRenderer {
25067
25092
  await this.waitForCanvasScene(container, cloned, i);
25068
25093
  }
25069
25094
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25070
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CgqBRltR.cjs"));
25095
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BdNT5NW8.cjs"));
25071
25096
  const prepared = preparePagesForExport(
25072
25097
  cloned.pages,
25073
25098
  canvasWidth,
@@ -27387,7 +27412,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27387
27412
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27388
27413
  sanitizeSvgTreeForPdf(svgToDraw);
27389
27414
  try {
27390
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CgqBRltR.cjs"));
27415
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BdNT5NW8.cjs"));
27391
27416
  try {
27392
27417
  await logTextMeasurementDiagnostic(svgToDraw);
27393
27418
  } catch {
@@ -27784,4 +27809,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27784
27809
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27785
27810
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27786
27811
  exports.warmTemplateFromForm = warmTemplateFromForm;
27787
- //# sourceMappingURL=index-C7ZK-TLB.cjs.map
27812
+ //# sourceMappingURL=index-DaZy0Hz3.cjs.map