@pixldocs/canvas-renderer 0.5.422 → 0.5.424

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.
@@ -12728,6 +12728,64 @@ const PageCanvas = forwardRef(
12728
12728
  prevKey = null;
12729
12729
  });
12730
12730
  }
12731
+ {
12732
+ const EDGE_HIT_ALONG_MIN = 44;
12733
+ const CORNER_BUFFER = 24;
12734
+ const syncEdgeHitSizes = (obj) => {
12735
+ var _a2;
12736
+ if (!obj || !obj.controls) return;
12737
+ try {
12738
+ const zoom3 = fabricCanvas.getZoom() || 1;
12739
+ let scaleX = obj.scaleX ?? 1;
12740
+ let scaleY = obj.scaleY ?? 1;
12741
+ try {
12742
+ const m = (_a2 = obj.calcTransformMatrix) == null ? void 0 : _a2.call(obj);
12743
+ if (m) {
12744
+ const dec = fabric.util.qrDecompose(m);
12745
+ scaleX = Math.abs(dec.scaleX ?? scaleX);
12746
+ scaleY = Math.abs(dec.scaleY ?? scaleY);
12747
+ }
12748
+ } catch {
12749
+ }
12750
+ const screenW = (obj.width ?? 0) * scaleX * zoom3;
12751
+ const screenH = (obj.height ?? 0) * scaleY * zoom3;
12752
+ const alongW = Math.max(EDGE_HIT_ALONG_MIN, screenW - CORNER_BUFFER);
12753
+ const alongH = Math.max(EDGE_HIT_ALONG_MIN, screenH - CORNER_BUFFER);
12754
+ for (const k of ["ml", "mr"]) {
12755
+ const c = obj.controls[k];
12756
+ if (!c) continue;
12757
+ c.sizeY = alongH;
12758
+ c.touchSizeY = alongH;
12759
+ }
12760
+ for (const k of ["mt", "mb"]) {
12761
+ const c = obj.controls[k];
12762
+ if (!c) continue;
12763
+ c.sizeX = alongW;
12764
+ c.touchSizeX = alongW;
12765
+ }
12766
+ } catch {
12767
+ }
12768
+ };
12769
+ const syncActive = () => {
12770
+ const obj = fabricCanvas.getActiveObject();
12771
+ if (obj) syncEdgeHitSizes(obj);
12772
+ };
12773
+ fabricCanvas.on("selection:created", syncActive);
12774
+ fabricCanvas.on("selection:updated", syncActive);
12775
+ fabricCanvas.on("object:scaling", (e) => syncEdgeHitSizes(e == null ? void 0 : e.target));
12776
+ fabricCanvas.on("object:modified", (e) => syncEdgeHitSizes(e == null ? void 0 : e.target));
12777
+ fabricCanvas.on("object:resizing", (e) => syncEdgeHitSizes(e == null ? void 0 : e.target));
12778
+ fabricCanvas.on("after:render", () => {
12779
+ const obj = fabricCanvas.getActiveObject();
12780
+ if (!obj) return;
12781
+ const lastZoom = obj.__pixldocsLastEdgeHitZoom;
12782
+ const z = fabricCanvas.getZoom() || 1;
12783
+ if (lastZoom !== z) {
12784
+ obj.__pixldocsLastEdgeHitZoom = z;
12785
+ syncEdgeHitSizes(obj);
12786
+ }
12787
+ });
12788
+ }
12731
12789
  const initFonts = async () => {
12732
12790
  try {
12733
12791
  await preloadAllFonts();
@@ -14354,7 +14412,7 @@ const PageCanvas = forwardRef(
14354
14412
  fabricCanvas.on("selection:cleared", () => {
14355
14413
  });
14356
14414
  fabricCanvas.on("object:scaling", (e) => {
14357
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
14415
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
14358
14416
  if (!isActiveRef.current) return;
14359
14417
  const t = e.target;
14360
14418
  if (t) lastResizeScaleTargetRef.current = t;
@@ -14644,20 +14702,12 @@ const PageCanvas = forwardRef(
14644
14702
  const asRect0 = obj.getBoundingRect();
14645
14703
  let didReflowTextChild = false;
14646
14704
  for (const child of obj.getObjects()) {
14647
- if (child.__asLiveOrigAngle == null) {
14648
- const currentLocalAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : void 0;
14649
- let matrixLocalAngle;
14650
- try {
14651
- const selectionMatrix = obj.calcTransformMatrix();
14652
- const childMatrix = child.calcOwnMatrix();
14653
- const worldMatrix = fabric.util.multiplyTransformMatrices(selectionMatrix, childMatrix);
14654
- const liveWorldAngle = fabric.util.qrDecompose(worldMatrix).angle ?? 0;
14655
- matrixLocalAngle = liveWorldAngle - (obj.angle ?? 0);
14656
- } catch {
14657
- }
14658
- child.__asLiveOrigAngle = currentLocalAngle ?? matrixLocalAngle ?? 0;
14705
+ const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((_k = groupSelectionTransformStartRef.current) == null ? void 0 : _k.selectionLeft) ?? obj.left ?? 0}:${((_l = groupSelectionTransformStartRef.current) == null ? void 0 : _l.selectionTop) ?? obj.top ?? 0}`;
14706
+ if (child.__asLiveGestureKey !== liveGestureKey) {
14707
+ child.__asLiveGestureKey = liveGestureKey;
14708
+ child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14659
14709
  }
14660
- if (child instanceof fabric.Group && (child.__cropGroup || ((_k = child._ct) == null ? void 0 : _k.isCropGroup))) {
14710
+ if (child instanceof fabric.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) {
14661
14711
  const ct = child.__cropData;
14662
14712
  if (!ct) continue;
14663
14713
  if (child.__asLiveOrigAngle == null) {
@@ -14826,7 +14876,7 @@ const PageCanvas = forwardRef(
14826
14876
  child.dirty = true;
14827
14877
  didReflowTextChild = true;
14828
14878
  }
14829
- if (isXSide && ((_l = groupShiftReflowSnapshotRef.current) == null ? void 0 : _l.selection) === obj) {
14879
+ if (isXSide && ((_n = groupShiftReflowSnapshotRef.current) == null ? void 0 : _n.selection) === obj) {
14830
14880
  const snap = groupShiftReflowSnapshotRef.current;
14831
14881
  const anchorEntry = snap.children[0];
14832
14882
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -14987,7 +15037,7 @@ const PageCanvas = forwardRef(
14987
15037
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
14988
15038
  if (drilledGroupIdRef.current) {
14989
15039
  try {
14990
- (_m = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _m.call(fabricCanvas);
15040
+ (_o = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _o.call(fabricCanvas);
14991
15041
  } catch {
14992
15042
  }
14993
15043
  }
@@ -15211,6 +15261,7 @@ const PageCanvas = forwardRef(
15211
15261
  delete child.__asLiveOrigW;
15212
15262
  delete child.__asLiveOrigH;
15213
15263
  delete child.__asLiveRotSnap;
15264
+ delete child.__asLiveGestureKey;
15214
15265
  }
15215
15266
  }
15216
15267
  } catch {
@@ -16487,6 +16538,7 @@ const PageCanvas = forwardRef(
16487
16538
  if (t instanceof fabric.ActiveSelection) {
16488
16539
  for (const child of t.getObjects()) {
16489
16540
  delete child.__asLiveOrigAngle;
16541
+ delete child.__asLiveGestureKey;
16490
16542
  delete child.__asLiveWorldAngle;
16491
16543
  delete child.__asLiveWorldCenterX;
16492
16544
  delete child.__asLiveWorldCenterY;
@@ -25564,9 +25616,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25564
25616
  }
25565
25617
  return svgString;
25566
25618
  }
25567
- const resolvedPackageVersion = "0.5.422";
25619
+ const resolvedPackageVersion = "0.5.424";
25568
25620
  const PACKAGE_VERSION = resolvedPackageVersion;
25569
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.422";
25621
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.424";
25570
25622
  const roundParityValue = (value) => {
25571
25623
  if (typeof value !== "number") return value;
25572
25624
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26380,7 +26432,7 @@ class PixldocsRenderer {
26380
26432
  await this.waitForCanvasScene(container, cloned, i);
26381
26433
  }
26382
26434
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26383
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CnV1fqDs.js");
26435
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Bm9r1fXg.js");
26384
26436
  const prepared = preparePagesForExport(
26385
26437
  cloned.pages,
26386
26438
  canvasWidth,
@@ -28700,7 +28752,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28700
28752
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28701
28753
  sanitizeSvgTreeForPdf(svgToDraw);
28702
28754
  try {
28703
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CnV1fqDs.js");
28755
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Bm9r1fXg.js");
28704
28756
  try {
28705
28757
  await logTextMeasurementDiagnostic(svgToDraw);
28706
28758
  } catch {
@@ -29100,4 +29152,4 @@ export {
29100
29152
  buildTeaserBlurFlatKeys as y,
29101
29153
  collectFontDescriptorsFromConfig as z
29102
29154
  };
29103
- //# sourceMappingURL=index-DFjuU6N6.js.map
29155
+ //# sourceMappingURL=index-C7ab3jgT.js.map