@pixldocs/canvas-renderer 0.5.381 → 0.5.382

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.
@@ -14299,6 +14299,75 @@ const PageCanvas = forwardRef(
14299
14299
  continue;
14300
14300
  }
14301
14301
  if (!(child instanceof fabric.Textbox)) continue;
14302
+ const childAngle = child.angle ?? 0;
14303
+ const normalizedAng = (childAngle % 180 + 180) % 180;
14304
+ const distFromAxis = Math.min(
14305
+ normalizedAng,
14306
+ Math.abs(normalizedAng - 90),
14307
+ Math.abs(normalizedAng - 180)
14308
+ );
14309
+ const isRotatedChild = distFromAxis > 0.5;
14310
+ if (isRotatedChild) {
14311
+ if (child.__asLiveRotSnap == null) {
14312
+ const selMatrix0 = obj.calcTransformMatrix();
14313
+ const localCenter0 = child.getCenterPoint();
14314
+ const worldCenter0 = fabric.util.transformPoint(localCenter0, selMatrix0);
14315
+ const origMinBoxH = Number(child.minBoxHeight);
14316
+ child.__asLiveRotSnap = {
14317
+ worldCenter: { x: worldCenter0.x, y: worldCenter0.y },
14318
+ worldAngle: (obj.angle ?? 0) + childAngle,
14319
+ origW: (child.width ?? 0) * Math.abs(child.scaleX ?? 1),
14320
+ origH: (child.height ?? 0) * Math.abs(child.scaleY ?? 1),
14321
+ origMinBoxH: Number.isFinite(origMinBoxH) ? origMinBoxH : 0
14322
+ };
14323
+ }
14324
+ const snap = child.__asLiveRotSnap;
14325
+ const θ = (snap.worldAngle - (obj.angle ?? 0)) * Math.PI / 180;
14326
+ const c = Math.cos(θ);
14327
+ const s = Math.sin(θ);
14328
+ const cos2 = c * c;
14329
+ const sin2 = s * s;
14330
+ if (isXSide) {
14331
+ const sLocal = Math.max(0.01, sin2 + sAxis * cos2);
14332
+ const newW = Math.max(20, snap.origW * sLocal);
14333
+ child._set("width", newW);
14334
+ } else {
14335
+ const sLocal = Math.max(0.01, cos2 + sAxis * sin2);
14336
+ const newH = Math.max(20, (snap.origMinBoxH || snap.origH) * sLocal);
14337
+ child.minBoxHeight = newH;
14338
+ }
14339
+ const asAngleRad = (obj.angle ?? 0) * Math.PI / 180;
14340
+ const ca = Math.cos(asAngleRad), sa = Math.sin(asAngleRad);
14341
+ const asSx = obj.scaleX || 1;
14342
+ const asSy = obj.scaleY || 1;
14343
+ const wa = snap.worldAngle * Math.PI / 180;
14344
+ const cw = Math.cos(wa), sw = Math.sin(wa);
14345
+ const i00 = ca / asSx, i01 = sa / asSx;
14346
+ const i10 = -sa / asSy, i11 = ca / asSy;
14347
+ const m00 = i00 * cw + i01 * sw;
14348
+ const m01 = i00 * -sw + i01 * cw;
14349
+ const m10 = i10 * cw + i11 * sw;
14350
+ const m11 = i10 * -sw + i11 * cw;
14351
+ const decomp = fabric.util.qrDecompose([m00, m10, m01, m11, 0, 0]);
14352
+ child._set("angle", decomp.angle);
14353
+ child._set("scaleX", decomp.scaleX);
14354
+ child._set("scaleY", decomp.scaleY);
14355
+ child._set("skewX", decomp.skewX || 0);
14356
+ child._set("skewY", decomp.skewY || 0);
14357
+ try {
14358
+ child.initDimensions();
14359
+ } catch {
14360
+ }
14361
+ const selMatrixNow = obj.calcTransformMatrix();
14362
+ const invSelNow = fabric.util.invertTransform(selMatrixNow);
14363
+ const wcPoint = new fabric.Point(snap.worldCenter.x, snap.worldCenter.y);
14364
+ const localCenterNow = fabric.util.transformPoint(wcPoint, invSelNow);
14365
+ child.setPositionByOrigin(localCenterNow, "center", "center");
14366
+ child.setCoords();
14367
+ child.dirty = true;
14368
+ didReflowTextChild = true;
14369
+ continue;
14370
+ }
14302
14371
  if (isXSide) {
14303
14372
  if (child.__asLiveOrigW == null) {
14304
14373
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
@@ -14715,6 +14784,7 @@ const PageCanvas = forwardRef(
14715
14784
  for (const child of t.getObjects()) {
14716
14785
  delete child.__asLiveOrigW;
14717
14786
  delete child.__asLiveOrigH;
14787
+ delete child.__asLiveRotSnap;
14718
14788
  }
14719
14789
  }
14720
14790
  } catch {
@@ -24815,9 +24885,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24815
24885
  }
24816
24886
  return svgString;
24817
24887
  }
24818
- const resolvedPackageVersion = "0.5.381";
24888
+ const resolvedPackageVersion = "0.5.382";
24819
24889
  const PACKAGE_VERSION = resolvedPackageVersion;
24820
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.381";
24890
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.382";
24821
24891
  const roundParityValue = (value) => {
24822
24892
  if (typeof value !== "number") return value;
24823
24893
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25631,7 +25701,7 @@ class PixldocsRenderer {
25631
25701
  await this.waitForCanvasScene(container, cloned, i);
25632
25702
  }
25633
25703
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25634
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-OXbQZXtd.js");
25704
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-C6nEEZs9.js");
25635
25705
  const prepared = preparePagesForExport(
25636
25706
  cloned.pages,
25637
25707
  canvasWidth,
@@ -27951,7 +28021,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27951
28021
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27952
28022
  sanitizeSvgTreeForPdf(svgToDraw);
27953
28023
  try {
27954
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-OXbQZXtd.js");
28024
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-C6nEEZs9.js");
27955
28025
  try {
27956
28026
  await logTextMeasurementDiagnostic(svgToDraw);
27957
28027
  } catch {
@@ -28351,4 +28421,4 @@ export {
28351
28421
  buildTeaserBlurFlatKeys as y,
28352
28422
  collectFontDescriptorsFromConfig as z
28353
28423
  };
28354
- //# sourceMappingURL=index-BR48GoFH.js.map
28424
+ //# sourceMappingURL=index-DJ64kXcr.js.map