@pixldocs/canvas-renderer 0.5.380 → 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.
@@ -11751,13 +11751,17 @@ const PageCanvas = react.forwardRef(
11751
11751
  const sameMembers = activeMembers.length === members.length && members.every((member) => activeMembers.includes(member));
11752
11752
  const sameGroup = activeBeforeRestore.__pixldocsGroupSelection === groupId;
11753
11753
  const alreadyAligned = activeBeforeRestore.__pixldocsAlignedAngle != null;
11754
- if (sameMembers && sameGroup && alreadyAligned) return;
11754
+ if (sameMembers && sameGroup && alreadyAligned) {
11755
+ ensureCanvaControlRenders(activeBeforeRestore);
11756
+ return;
11757
+ }
11755
11758
  }
11756
11759
  isSyncingSelectionToFabricRef.current = true;
11757
11760
  try {
11758
11761
  const active = activeBeforeRestore;
11759
11762
  const selection = active instanceof fabric__namespace.ActiveSelection && members.every((member) => active.getObjects().includes(member)) ? active : new fabric__namespace.ActiveSelection(members, { canvas: fc });
11760
11763
  applyLogicalGroupSelectionVisualState(selection, groupId);
11764
+ ensureCanvaControlRenders(selection);
11761
11765
  fc.setActiveObject(selection);
11762
11766
  try {
11763
11767
  members.forEach((m) => m.setCoords());
@@ -13381,7 +13385,10 @@ const PageCanvas = react.forwardRef(
13381
13385
  const sameMembers = activeIds.length === snapshot.memberIds.length && snapshot.memberIds.every((id) => activeIds.includes(id));
13382
13386
  const sameGroup = active.__pixldocsGroupSelection === snapshot.groupSelectionId;
13383
13387
  const alreadyAligned = active.__pixldocsAlignedAngle != null;
13384
- if (sameMembers && sameGroup && alreadyAligned) return;
13388
+ if (sameMembers && sameGroup && alreadyAligned) {
13389
+ ensureCanvaControlRenders(active);
13390
+ return;
13391
+ }
13385
13392
  }
13386
13393
  restoreGroupSelectionSnapshot(snapshot);
13387
13394
  }, 0);
@@ -14310,6 +14317,75 @@ const PageCanvas = react.forwardRef(
14310
14317
  continue;
14311
14318
  }
14312
14319
  if (!(child instanceof fabric__namespace.Textbox)) continue;
14320
+ const childAngle = child.angle ?? 0;
14321
+ const normalizedAng = (childAngle % 180 + 180) % 180;
14322
+ const distFromAxis = Math.min(
14323
+ normalizedAng,
14324
+ Math.abs(normalizedAng - 90),
14325
+ Math.abs(normalizedAng - 180)
14326
+ );
14327
+ const isRotatedChild = distFromAxis > 0.5;
14328
+ if (isRotatedChild) {
14329
+ if (child.__asLiveRotSnap == null) {
14330
+ const selMatrix0 = obj.calcTransformMatrix();
14331
+ const localCenter0 = child.getCenterPoint();
14332
+ const worldCenter0 = fabric__namespace.util.transformPoint(localCenter0, selMatrix0);
14333
+ const origMinBoxH = Number(child.minBoxHeight);
14334
+ child.__asLiveRotSnap = {
14335
+ worldCenter: { x: worldCenter0.x, y: worldCenter0.y },
14336
+ worldAngle: (obj.angle ?? 0) + childAngle,
14337
+ origW: (child.width ?? 0) * Math.abs(child.scaleX ?? 1),
14338
+ origH: (child.height ?? 0) * Math.abs(child.scaleY ?? 1),
14339
+ origMinBoxH: Number.isFinite(origMinBoxH) ? origMinBoxH : 0
14340
+ };
14341
+ }
14342
+ const snap = child.__asLiveRotSnap;
14343
+ const θ = (snap.worldAngle - (obj.angle ?? 0)) * Math.PI / 180;
14344
+ const c = Math.cos(θ);
14345
+ const s = Math.sin(θ);
14346
+ const cos2 = c * c;
14347
+ const sin2 = s * s;
14348
+ if (isXSide) {
14349
+ const sLocal = Math.max(0.01, sin2 + sAxis * cos2);
14350
+ const newW = Math.max(20, snap.origW * sLocal);
14351
+ child._set("width", newW);
14352
+ } else {
14353
+ const sLocal = Math.max(0.01, cos2 + sAxis * sin2);
14354
+ const newH = Math.max(20, (snap.origMinBoxH || snap.origH) * sLocal);
14355
+ child.minBoxHeight = newH;
14356
+ }
14357
+ const asAngleRad = (obj.angle ?? 0) * Math.PI / 180;
14358
+ const ca = Math.cos(asAngleRad), sa = Math.sin(asAngleRad);
14359
+ const asSx = obj.scaleX || 1;
14360
+ const asSy = obj.scaleY || 1;
14361
+ const wa = snap.worldAngle * Math.PI / 180;
14362
+ const cw = Math.cos(wa), sw = Math.sin(wa);
14363
+ const i00 = ca / asSx, i01 = sa / asSx;
14364
+ const i10 = -sa / asSy, i11 = ca / asSy;
14365
+ const m00 = i00 * cw + i01 * sw;
14366
+ const m01 = i00 * -sw + i01 * cw;
14367
+ const m10 = i10 * cw + i11 * sw;
14368
+ const m11 = i10 * -sw + i11 * cw;
14369
+ const decomp = fabric__namespace.util.qrDecompose([m00, m10, m01, m11, 0, 0]);
14370
+ child._set("angle", decomp.angle);
14371
+ child._set("scaleX", decomp.scaleX);
14372
+ child._set("scaleY", decomp.scaleY);
14373
+ child._set("skewX", decomp.skewX || 0);
14374
+ child._set("skewY", decomp.skewY || 0);
14375
+ try {
14376
+ child.initDimensions();
14377
+ } catch {
14378
+ }
14379
+ const selMatrixNow = obj.calcTransformMatrix();
14380
+ const invSelNow = fabric__namespace.util.invertTransform(selMatrixNow);
14381
+ const wcPoint = new fabric__namespace.Point(snap.worldCenter.x, snap.worldCenter.y);
14382
+ const localCenterNow = fabric__namespace.util.transformPoint(wcPoint, invSelNow);
14383
+ child.setPositionByOrigin(localCenterNow, "center", "center");
14384
+ child.setCoords();
14385
+ child.dirty = true;
14386
+ didReflowTextChild = true;
14387
+ continue;
14388
+ }
14313
14389
  if (isXSide) {
14314
14390
  if (child.__asLiveOrigW == null) {
14315
14391
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
@@ -14726,6 +14802,7 @@ const PageCanvas = react.forwardRef(
14726
14802
  for (const child of t.getObjects()) {
14727
14803
  delete child.__asLiveOrigW;
14728
14804
  delete child.__asLiveOrigH;
14805
+ delete child.__asLiveRotSnap;
14729
14806
  }
14730
14807
  }
14731
14808
  } catch {
@@ -16107,6 +16184,10 @@ const PageCanvas = react.forwardRef(
16107
16184
  const sameMembers = !!prevAS && prevMembers.length === freshMembers.length && prevMembers.every((m) => freshMembers.includes(m));
16108
16185
  const alreadyAligned = sameMembers && prevAS.__pixldocsAlignedAngle != null;
16109
16186
  if (sameMembers && alreadyAligned) {
16187
+ try {
16188
+ ensureCanvaControlRenders(prevAS);
16189
+ } catch {
16190
+ }
16110
16191
  fc.setActiveObject(prevAS);
16111
16192
  prevAS.setCoords();
16112
16193
  fc.requestRenderAll();
@@ -17214,6 +17295,7 @@ const PageCanvas = react.forwardRef(
17214
17295
  });
17215
17296
  if (isPureSingleGroupSelection) applyWarpAwareSelectionBorders(selection);
17216
17297
  }
17298
+ ensureCanvaControlRenders(selection);
17217
17299
  fc.setActiveObject(selection);
17218
17300
  if (!isFlatGroupSelection) {
17219
17301
  selection.setCoords();
@@ -24821,9 +24903,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24821
24903
  }
24822
24904
  return svgString;
24823
24905
  }
24824
- const resolvedPackageVersion = "0.5.380";
24906
+ const resolvedPackageVersion = "0.5.382";
24825
24907
  const PACKAGE_VERSION = resolvedPackageVersion;
24826
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.380";
24908
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.382";
24827
24909
  const roundParityValue = (value) => {
24828
24910
  if (typeof value !== "number") return value;
24829
24911
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25637,7 +25719,7 @@ class PixldocsRenderer {
25637
25719
  await this.waitForCanvasScene(container, cloned, i);
25638
25720
  }
25639
25721
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25640
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-C4lbJ3r7.cjs"));
25722
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BI3et0Ux.cjs"));
25641
25723
  const prepared = preparePagesForExport(
25642
25724
  cloned.pages,
25643
25725
  canvasWidth,
@@ -27957,7 +28039,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27957
28039
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27958
28040
  sanitizeSvgTreeForPdf(svgToDraw);
27959
28041
  try {
27960
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-C4lbJ3r7.cjs"));
28042
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BI3et0Ux.cjs"));
27961
28043
  try {
27962
28044
  await logTextMeasurementDiagnostic(svgToDraw);
27963
28045
  } catch {
@@ -28354,4 +28436,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28354
28436
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28355
28437
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28356
28438
  exports.warmTemplateFromForm = warmTemplateFromForm;
28357
- //# sourceMappingURL=index-B-wkU613.cjs.map
28439
+ //# sourceMappingURL=index-BpiWTXuI.cjs.map