@pixldocs/canvas-renderer 0.5.388 → 0.5.390

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.
@@ -13522,13 +13522,19 @@ const PageCanvas = forwardRef(
13522
13522
  if (oid && memberIds.has(oid)) members.push(o);
13523
13523
  }
13524
13524
  if (members.length === 0) return null;
13525
- const a0 = ((members[0].angle ?? 0) % 360 + 360) % 360;
13526
13525
  const TOL = 0.5;
13526
+ const buckets = [];
13527
13527
  for (const m of members) {
13528
13528
  const a = ((m.angle ?? 0) % 360 + 360) % 360;
13529
- const diff = Math.min(Math.abs(a - a0), 360 - Math.abs(a - a0));
13530
- if (diff > TOL) return null;
13529
+ const b = buckets.find((x) => {
13530
+ const d = Math.min(Math.abs(x.angle - a), 360 - Math.abs(x.angle - a));
13531
+ return d <= TOL;
13532
+ });
13533
+ if (b) b.count++;
13534
+ else buckets.push({ angle: a, count: 1 });
13531
13535
  }
13536
+ buckets.sort((a, b) => b.count - a.count);
13537
+ const a0 = buckets[0].angle;
13532
13538
  const rad = -a0 * Math.PI / 180;
13533
13539
  const cos = Math.cos(rad), sin = Math.sin(rad);
13534
13540
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
@@ -14312,23 +14318,26 @@ const PageCanvas = forwardRef(
14312
14318
  if (child instanceof fabric.Group && (child.__cropGroup || ((_f = child._ct) == null ? void 0 : _f.isCropGroup))) {
14313
14319
  const ct = child.__cropData;
14314
14320
  if (!ct) continue;
14321
+ if (child.__asLiveOrigAngle == null) {
14322
+ child.__asLiveOrigAngle = child.angle ?? 0;
14323
+ }
14324
+ const childAngleDegC = child.__asLiveOrigAngle;
14325
+ const asSxC = isXSide ? sAxis : 1;
14326
+ const asSyC = isXSide ? 1 : sAxis;
14327
+ const thetaC = fabric.util.degreesToRadians(childAngleDegC);
14328
+ const cosTC = Math.cos(thetaC);
14329
+ const sinTC = Math.sin(thetaC);
14330
+ const sLocalC = isXSide ? asSxC * cosTC * cosTC + sinTC * sinTC : asSyC * cosTC * cosTC + sinTC * sinTC;
14315
14331
  if (isXSide) {
14316
14332
  if (child.__asLiveOrigW == null) {
14317
14333
  const baseW = child.width ?? ct.frameW ?? 0;
14318
14334
  child.__asLiveOrigW = baseW * (child.scaleX ?? 1);
14319
14335
  }
14320
14336
  const origW = child.__asLiveOrigW;
14321
- const newW = Math.max(20, origW * sAxis);
14337
+ const newW = Math.max(20, origW * sLocalC);
14322
14338
  if (Math.abs((child.width ?? 0) - newW) > 0.5) {
14323
14339
  ct.frameW = newW;
14324
14340
  child._set("width", newW);
14325
- child._set("scaleX", 1 / sAxis);
14326
- try {
14327
- updateCoverLayout(child);
14328
- } catch {
14329
- }
14330
- child.setCoords();
14331
- child.dirty = true;
14332
14341
  }
14333
14342
  } else {
14334
14343
  if (child.__asLiveOrigH == null) {
@@ -14336,47 +14345,88 @@ const PageCanvas = forwardRef(
14336
14345
  child.__asLiveOrigH = baseH * (child.scaleY ?? 1);
14337
14346
  }
14338
14347
  const origH = child.__asLiveOrigH;
14339
- const newH = Math.max(20, origH * sAxis);
14348
+ const newH = Math.max(20, origH * sLocalC);
14340
14349
  if (Math.abs((child.height ?? 0) - newH) > 0.5) {
14341
14350
  ct.frameH = newH;
14342
14351
  child._set("height", newH);
14343
- child._set("scaleY", 1 / sAxis);
14344
- try {
14345
- updateCoverLayout(child);
14346
- } catch {
14347
- }
14348
- child.setCoords();
14349
- child.dirty = true;
14350
14352
  }
14351
14353
  }
14354
+ try {
14355
+ const invC = [1 / asSxC, 0, 0, 1 / asSyC, 0, 0];
14356
+ const RthetaC = fabric.util.composeMatrix({
14357
+ angle: childAngleDegC,
14358
+ scaleX: 1,
14359
+ scaleY: 1,
14360
+ translateX: 0,
14361
+ translateY: 0
14362
+ });
14363
+ const MC = fabric.util.multiplyTransformMatrices(invC, RthetaC);
14364
+ const decC = fabric.util.qrDecompose(MC);
14365
+ child._set("angle", decC.angle);
14366
+ child._set("scaleX", decC.scaleX);
14367
+ child._set("scaleY", decC.scaleY);
14368
+ child._set("skewX", decC.skewX);
14369
+ child._set("skewY", decC.skewY);
14370
+ } catch {
14371
+ }
14372
+ try {
14373
+ updateCoverLayout(child);
14374
+ } catch {
14375
+ }
14376
+ child.setCoords();
14377
+ child.dirty = true;
14352
14378
  continue;
14353
14379
  }
14354
14380
  if (child instanceof fabric.FabricImage && !child.__cropGroup && !child.smartElementType) {
14381
+ if (child.__asLiveOrigAngle == null) {
14382
+ child.__asLiveOrigAngle = child.angle ?? 0;
14383
+ }
14384
+ const childAngleDegI = child.__asLiveOrigAngle;
14385
+ const asSxI = isXSide ? sAxis : 1;
14386
+ const asSyI = isXSide ? 1 : sAxis;
14387
+ const thetaI = fabric.util.degreesToRadians(childAngleDegI);
14388
+ const cosTI = Math.cos(thetaI);
14389
+ const sinTI = Math.sin(thetaI);
14390
+ const sLocalI = isXSide ? asSxI * cosTI * cosTI + sinTI * sinTI : asSyI * cosTI * cosTI + sinTI * sinTI;
14355
14391
  if (isXSide) {
14356
14392
  if (child.__asLiveOrigW == null) {
14357
14393
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
14358
14394
  }
14359
14395
  const origW = child.__asLiveOrigW;
14360
- const newW = Math.max(1, origW * sAxis);
14396
+ const newW = Math.max(1, origW * sLocalI);
14361
14397
  if (Math.abs((child.width ?? 0) - newW) > 0.5) {
14362
14398
  child._set("width", newW);
14363
- child._set("scaleX", 1 / sAxis);
14364
- child.setCoords();
14365
- child.dirty = true;
14366
14399
  }
14367
14400
  } else {
14368
14401
  if (child.__asLiveOrigH == null) {
14369
14402
  child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
14370
14403
  }
14371
14404
  const origH = child.__asLiveOrigH;
14372
- const newH = Math.max(1, origH * sAxis);
14405
+ const newH = Math.max(1, origH * sLocalI);
14373
14406
  if (Math.abs((child.height ?? 0) - newH) > 0.5) {
14374
14407
  child._set("height", newH);
14375
- child._set("scaleY", 1 / sAxis);
14376
- child.setCoords();
14377
- child.dirty = true;
14378
14408
  }
14379
14409
  }
14410
+ try {
14411
+ const invI = [1 / asSxI, 0, 0, 1 / asSyI, 0, 0];
14412
+ const RthetaI = fabric.util.composeMatrix({
14413
+ angle: childAngleDegI,
14414
+ scaleX: 1,
14415
+ scaleY: 1,
14416
+ translateX: 0,
14417
+ translateY: 0
14418
+ });
14419
+ const MI = fabric.util.multiplyTransformMatrices(invI, RthetaI);
14420
+ const decI = fabric.util.qrDecompose(MI);
14421
+ child._set("angle", decI.angle);
14422
+ child._set("scaleX", decI.scaleX);
14423
+ child._set("scaleY", decI.scaleY);
14424
+ child._set("skewX", decI.skewX);
14425
+ child._set("skewY", decI.skewY);
14426
+ } catch {
14427
+ }
14428
+ child.setCoords();
14429
+ child.dirty = true;
14380
14430
  continue;
14381
14431
  }
14382
14432
  if (!(child instanceof fabric.Textbox)) continue;
@@ -24974,9 +25024,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24974
25024
  }
24975
25025
  return svgString;
24976
25026
  }
24977
- const resolvedPackageVersion = "0.5.388";
25027
+ const resolvedPackageVersion = "0.5.390";
24978
25028
  const PACKAGE_VERSION = resolvedPackageVersion;
24979
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.388";
25029
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.390";
24980
25030
  const roundParityValue = (value) => {
24981
25031
  if (typeof value !== "number") return value;
24982
25032
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25790,7 +25840,7 @@ class PixldocsRenderer {
25790
25840
  await this.waitForCanvasScene(container, cloned, i);
25791
25841
  }
25792
25842
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25793
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-txxMjll_.js");
25843
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-p4K2EISX.js");
25794
25844
  const prepared = preparePagesForExport(
25795
25845
  cloned.pages,
25796
25846
  canvasWidth,
@@ -28110,7 +28160,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28110
28160
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28111
28161
  sanitizeSvgTreeForPdf(svgToDraw);
28112
28162
  try {
28113
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-txxMjll_.js");
28163
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-p4K2EISX.js");
28114
28164
  try {
28115
28165
  await logTextMeasurementDiagnostic(svgToDraw);
28116
28166
  } catch {
@@ -28510,4 +28560,4 @@ export {
28510
28560
  buildTeaserBlurFlatKeys as y,
28511
28561
  collectFontDescriptorsFromConfig as z
28512
28562
  };
28513
- //# sourceMappingURL=index-CiGVJ3wk.js.map
28563
+ //# sourceMappingURL=index-ByJXwd5Y.js.map