@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.
@@ -11169,25 +11169,50 @@ function applyWarpAwareSelectionBorders(selection) {
11169
11169
  selection.hasBorders = true;
11170
11170
  selection.hasControls = true;
11171
11171
  try {
11172
- const kids = selection.getObjects();
11173
- let allSameNonZero = kids.length > 0;
11174
- const first = ((((_a2 = kids[0]) == null ? void 0 : _a2.angle) ?? 0) % 360 + 360) % 360;
11175
- if (Math.abs(first) < 0.5 || Math.abs(first - 360) < 0.5) allSameNonZero = false;
11176
- if (allSameNonZero) {
11177
- for (const k of kids) {
11178
- const a = ((k.angle ?? 0) % 360 + 360) % 360;
11179
- if (Math.abs(a - first) > 0.5) {
11180
- allSameNonZero = false;
11181
- break;
11172
+ if (selection.__pixldocsAlignedAngle == null) {
11173
+ const kids = selection.getObjects();
11174
+ if (kids.length >= 1) {
11175
+ const norm = (a) => {
11176
+ const n = (a % 360 + 360) % 360;
11177
+ return n > 180 ? n - 360 : n;
11178
+ };
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);
11188
+ if (allSame) {
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;
11201
+ });
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 {
11208
+ }
11209
+ restoreKidsFromWorld();
11210
+ selection.setCoords();
11211
+ selection.dirty = true;
11212
+ selection.__pixldocsAlignedAngle = first;
11182
11213
  }
11183
11214
  }
11184
11215
  }
11185
- selection.setControlsVisibility({
11186
- ml: !allSameNonZero,
11187
- mr: !allSameNonZero,
11188
- mt: !allSameNonZero,
11189
- mb: !allSameNonZero
11190
- });
11191
11216
  } catch {
11192
11217
  }
11193
11218
  }
@@ -24233,9 +24258,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24233
24258
  }
24234
24259
  return svgString;
24235
24260
  }
24236
- const resolvedPackageVersion = "0.5.311";
24261
+ const resolvedPackageVersion = "0.5.313";
24237
24262
  const PACKAGE_VERSION = resolvedPackageVersion;
24238
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.311";
24263
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.313";
24239
24264
  const roundParityValue = (value) => {
24240
24265
  if (typeof value !== "number") return value;
24241
24266
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25049,7 +25074,7 @@ class PixldocsRenderer {
25049
25074
  await this.waitForCanvasScene(container, cloned, i);
25050
25075
  }
25051
25076
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25052
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DouKBaoG.js");
25077
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BPFpKueR.js");
25053
25078
  const prepared = preparePagesForExport(
25054
25079
  cloned.pages,
25055
25080
  canvasWidth,
@@ -27369,7 +27394,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27369
27394
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27370
27395
  sanitizeSvgTreeForPdf(svgToDraw);
27371
27396
  try {
27372
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DouKBaoG.js");
27397
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BPFpKueR.js");
27373
27398
  try {
27374
27399
  await logTextMeasurementDiagnostic(svgToDraw);
27375
27400
  } catch {
@@ -27769,4 +27794,4 @@ export {
27769
27794
  buildTeaserBlurFlatKeys as y,
27770
27795
  collectFontDescriptorsFromConfig as z
27771
27796
  };
27772
- //# sourceMappingURL=index-BGRSqiXc.js.map
27797
+ //# sourceMappingURL=index-D8s0AmMC.js.map