@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.
@@ -13540,13 +13540,19 @@ const PageCanvas = react.forwardRef(
13540
13540
  if (oid && memberIds.has(oid)) members.push(o);
13541
13541
  }
13542
13542
  if (members.length === 0) return null;
13543
- const a0 = ((members[0].angle ?? 0) % 360 + 360) % 360;
13544
13543
  const TOL = 0.5;
13544
+ const buckets = [];
13545
13545
  for (const m of members) {
13546
13546
  const a = ((m.angle ?? 0) % 360 + 360) % 360;
13547
- const diff = Math.min(Math.abs(a - a0), 360 - Math.abs(a - a0));
13548
- if (diff > TOL) return null;
13547
+ const b = buckets.find((x) => {
13548
+ const d = Math.min(Math.abs(x.angle - a), 360 - Math.abs(x.angle - a));
13549
+ return d <= TOL;
13550
+ });
13551
+ if (b) b.count++;
13552
+ else buckets.push({ angle: a, count: 1 });
13549
13553
  }
13554
+ buckets.sort((a, b) => b.count - a.count);
13555
+ const a0 = buckets[0].angle;
13550
13556
  const rad = -a0 * Math.PI / 180;
13551
13557
  const cos = Math.cos(rad), sin = Math.sin(rad);
13552
13558
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
@@ -14330,23 +14336,26 @@ const PageCanvas = react.forwardRef(
14330
14336
  if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_f = child._ct) == null ? void 0 : _f.isCropGroup))) {
14331
14337
  const ct = child.__cropData;
14332
14338
  if (!ct) continue;
14339
+ if (child.__asLiveOrigAngle == null) {
14340
+ child.__asLiveOrigAngle = child.angle ?? 0;
14341
+ }
14342
+ const childAngleDegC = child.__asLiveOrigAngle;
14343
+ const asSxC = isXSide ? sAxis : 1;
14344
+ const asSyC = isXSide ? 1 : sAxis;
14345
+ const thetaC = fabric__namespace.util.degreesToRadians(childAngleDegC);
14346
+ const cosTC = Math.cos(thetaC);
14347
+ const sinTC = Math.sin(thetaC);
14348
+ const sLocalC = isXSide ? asSxC * cosTC * cosTC + sinTC * sinTC : asSyC * cosTC * cosTC + sinTC * sinTC;
14333
14349
  if (isXSide) {
14334
14350
  if (child.__asLiveOrigW == null) {
14335
14351
  const baseW = child.width ?? ct.frameW ?? 0;
14336
14352
  child.__asLiveOrigW = baseW * (child.scaleX ?? 1);
14337
14353
  }
14338
14354
  const origW = child.__asLiveOrigW;
14339
- const newW = Math.max(20, origW * sAxis);
14355
+ const newW = Math.max(20, origW * sLocalC);
14340
14356
  if (Math.abs((child.width ?? 0) - newW) > 0.5) {
14341
14357
  ct.frameW = newW;
14342
14358
  child._set("width", newW);
14343
- child._set("scaleX", 1 / sAxis);
14344
- try {
14345
- updateCoverLayout(child);
14346
- } catch {
14347
- }
14348
- child.setCoords();
14349
- child.dirty = true;
14350
14359
  }
14351
14360
  } else {
14352
14361
  if (child.__asLiveOrigH == null) {
@@ -14354,47 +14363,88 @@ const PageCanvas = react.forwardRef(
14354
14363
  child.__asLiveOrigH = baseH * (child.scaleY ?? 1);
14355
14364
  }
14356
14365
  const origH = child.__asLiveOrigH;
14357
- const newH = Math.max(20, origH * sAxis);
14366
+ const newH = Math.max(20, origH * sLocalC);
14358
14367
  if (Math.abs((child.height ?? 0) - newH) > 0.5) {
14359
14368
  ct.frameH = newH;
14360
14369
  child._set("height", newH);
14361
- child._set("scaleY", 1 / sAxis);
14362
- try {
14363
- updateCoverLayout(child);
14364
- } catch {
14365
- }
14366
- child.setCoords();
14367
- child.dirty = true;
14368
14370
  }
14369
14371
  }
14372
+ try {
14373
+ const invC = [1 / asSxC, 0, 0, 1 / asSyC, 0, 0];
14374
+ const RthetaC = fabric__namespace.util.composeMatrix({
14375
+ angle: childAngleDegC,
14376
+ scaleX: 1,
14377
+ scaleY: 1,
14378
+ translateX: 0,
14379
+ translateY: 0
14380
+ });
14381
+ const MC = fabric__namespace.util.multiplyTransformMatrices(invC, RthetaC);
14382
+ const decC = fabric__namespace.util.qrDecompose(MC);
14383
+ child._set("angle", decC.angle);
14384
+ child._set("scaleX", decC.scaleX);
14385
+ child._set("scaleY", decC.scaleY);
14386
+ child._set("skewX", decC.skewX);
14387
+ child._set("skewY", decC.skewY);
14388
+ } catch {
14389
+ }
14390
+ try {
14391
+ updateCoverLayout(child);
14392
+ } catch {
14393
+ }
14394
+ child.setCoords();
14395
+ child.dirty = true;
14370
14396
  continue;
14371
14397
  }
14372
14398
  if (child instanceof fabric__namespace.FabricImage && !child.__cropGroup && !child.smartElementType) {
14399
+ if (child.__asLiveOrigAngle == null) {
14400
+ child.__asLiveOrigAngle = child.angle ?? 0;
14401
+ }
14402
+ const childAngleDegI = child.__asLiveOrigAngle;
14403
+ const asSxI = isXSide ? sAxis : 1;
14404
+ const asSyI = isXSide ? 1 : sAxis;
14405
+ const thetaI = fabric__namespace.util.degreesToRadians(childAngleDegI);
14406
+ const cosTI = Math.cos(thetaI);
14407
+ const sinTI = Math.sin(thetaI);
14408
+ const sLocalI = isXSide ? asSxI * cosTI * cosTI + sinTI * sinTI : asSyI * cosTI * cosTI + sinTI * sinTI;
14373
14409
  if (isXSide) {
14374
14410
  if (child.__asLiveOrigW == null) {
14375
14411
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
14376
14412
  }
14377
14413
  const origW = child.__asLiveOrigW;
14378
- const newW = Math.max(1, origW * sAxis);
14414
+ const newW = Math.max(1, origW * sLocalI);
14379
14415
  if (Math.abs((child.width ?? 0) - newW) > 0.5) {
14380
14416
  child._set("width", newW);
14381
- child._set("scaleX", 1 / sAxis);
14382
- child.setCoords();
14383
- child.dirty = true;
14384
14417
  }
14385
14418
  } else {
14386
14419
  if (child.__asLiveOrigH == null) {
14387
14420
  child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
14388
14421
  }
14389
14422
  const origH = child.__asLiveOrigH;
14390
- const newH = Math.max(1, origH * sAxis);
14423
+ const newH = Math.max(1, origH * sLocalI);
14391
14424
  if (Math.abs((child.height ?? 0) - newH) > 0.5) {
14392
14425
  child._set("height", newH);
14393
- child._set("scaleY", 1 / sAxis);
14394
- child.setCoords();
14395
- child.dirty = true;
14396
14426
  }
14397
14427
  }
14428
+ try {
14429
+ const invI = [1 / asSxI, 0, 0, 1 / asSyI, 0, 0];
14430
+ const RthetaI = fabric__namespace.util.composeMatrix({
14431
+ angle: childAngleDegI,
14432
+ scaleX: 1,
14433
+ scaleY: 1,
14434
+ translateX: 0,
14435
+ translateY: 0
14436
+ });
14437
+ const MI = fabric__namespace.util.multiplyTransformMatrices(invI, RthetaI);
14438
+ const decI = fabric__namespace.util.qrDecompose(MI);
14439
+ child._set("angle", decI.angle);
14440
+ child._set("scaleX", decI.scaleX);
14441
+ child._set("scaleY", decI.scaleY);
14442
+ child._set("skewX", decI.skewX);
14443
+ child._set("skewY", decI.skewY);
14444
+ } catch {
14445
+ }
14446
+ child.setCoords();
14447
+ child.dirty = true;
14398
14448
  continue;
14399
14449
  }
14400
14450
  if (!(child instanceof fabric__namespace.Textbox)) continue;
@@ -24992,9 +25042,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24992
25042
  }
24993
25043
  return svgString;
24994
25044
  }
24995
- const resolvedPackageVersion = "0.5.388";
25045
+ const resolvedPackageVersion = "0.5.390";
24996
25046
  const PACKAGE_VERSION = resolvedPackageVersion;
24997
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.388";
25047
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.390";
24998
25048
  const roundParityValue = (value) => {
24999
25049
  if (typeof value !== "number") return value;
25000
25050
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25808,7 +25858,7 @@ class PixldocsRenderer {
25808
25858
  await this.waitForCanvasScene(container, cloned, i);
25809
25859
  }
25810
25860
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25811
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BMKSimKF.cjs"));
25861
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-3tLyCSst.cjs"));
25812
25862
  const prepared = preparePagesForExport(
25813
25863
  cloned.pages,
25814
25864
  canvasWidth,
@@ -28128,7 +28178,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28128
28178
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28129
28179
  sanitizeSvgTreeForPdf(svgToDraw);
28130
28180
  try {
28131
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BMKSimKF.cjs"));
28181
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-3tLyCSst.cjs"));
28132
28182
  try {
28133
28183
  await logTextMeasurementDiagnostic(svgToDraw);
28134
28184
  } catch {
@@ -28525,4 +28575,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28525
28575
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28526
28576
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28527
28577
  exports.warmTemplateFromForm = warmTemplateFromForm;
28528
- //# sourceMappingURL=index-CnSzRkFP.cjs.map
28578
+ //# sourceMappingURL=index-BAbK6GX5.cjs.map