@pixldocs/canvas-renderer 0.5.424 → 0.5.425

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.
@@ -10726,6 +10726,8 @@ const SELECTION_PRIMARY = "hsl(217, 91%, 60%)";
10726
10726
  const SELECTION_BORDER_SCALE = 2;
10727
10727
  let ensureCanvaControlRenders = () => {
10728
10728
  };
10729
+ let ensureCanvaEdgeHitArea = () => {
10730
+ };
10729
10731
  try {
10730
10732
  const InteractiveBase = fabric__namespace.InteractiveFabricObject ?? fabric__namespace.Object;
10731
10733
  if ((InteractiveBase == null ? void 0 : InteractiveBase.prototype) && !InteractiveBase.prototype.__pixldocsCenteredSelectionBorder) {
@@ -12750,14 +12752,16 @@ const PageCanvas = react.forwardRef(
12750
12752
  const EDGE_HIT_ALONG_MIN = 44;
12751
12753
  const CORNER_BUFFER = 24;
12752
12754
  const syncEdgeHitSizes = (obj) => {
12753
- var _a2;
12755
+ var _a2, _b2, _c2;
12754
12756
  if (!obj || !obj.controls) return;
12755
12757
  try {
12756
- const zoom3 = fabricCanvas.getZoom() || 1;
12758
+ ensureCanvaControlRenders(obj);
12759
+ const canvasForObj = obj.canvas ?? fabricCanvas;
12760
+ const zoom3 = ((_a2 = canvasForObj.getZoom) == null ? void 0 : _a2.call(canvasForObj)) || 1;
12757
12761
  let scaleX = obj.scaleX ?? 1;
12758
12762
  let scaleY = obj.scaleY ?? 1;
12759
12763
  try {
12760
- const m = (_a2 = obj.calcTransformMatrix) == null ? void 0 : _a2.call(obj);
12764
+ const m = (_b2 = obj.calcTransformMatrix) == null ? void 0 : _b2.call(obj);
12761
12765
  if (m) {
12762
12766
  const dec = fabric__namespace.util.qrDecompose(m);
12763
12767
  scaleX = Math.abs(dec.scaleX ?? scaleX);
@@ -12769,24 +12773,32 @@ const PageCanvas = react.forwardRef(
12769
12773
  const screenH = (obj.height ?? 0) * scaleY * zoom3;
12770
12774
  const alongW = Math.max(EDGE_HIT_ALONG_MIN, screenW - CORNER_BUFFER);
12771
12775
  const alongH = Math.max(EDGE_HIT_ALONG_MIN, screenH - CORNER_BUFFER);
12776
+ let changed = false;
12772
12777
  for (const k of ["ml", "mr"]) {
12773
12778
  const c = obj.controls[k];
12774
12779
  if (!c) continue;
12780
+ if (c.sizeY !== alongH || c.touchSizeY !== alongH) changed = true;
12775
12781
  c.sizeY = alongH;
12776
12782
  c.touchSizeY = alongH;
12777
12783
  }
12778
12784
  for (const k of ["mt", "mb"]) {
12779
12785
  const c = obj.controls[k];
12780
12786
  if (!c) continue;
12787
+ if (c.sizeX !== alongW || c.touchSizeX !== alongW) changed = true;
12781
12788
  c.sizeX = alongW;
12782
12789
  c.touchSizeX = alongW;
12783
12790
  }
12791
+ if (changed) (_c2 = obj.setCoords) == null ? void 0 : _c2.call(obj);
12784
12792
  } catch {
12785
12793
  }
12786
12794
  };
12795
+ ensureCanvaEdgeHitArea = syncEdgeHitSizes;
12787
12796
  const syncActive = () => {
12788
12797
  const obj = fabricCanvas.getActiveObject();
12789
- if (obj) syncEdgeHitSizes(obj);
12798
+ if (obj) {
12799
+ syncEdgeHitSizes(obj);
12800
+ requestAnimationFrame(() => syncEdgeHitSizes(obj));
12801
+ }
12790
12802
  };
12791
12803
  fabricCanvas.on("selection:created", syncActive);
12792
12804
  fabricCanvas.on("selection:updated", syncActive);
@@ -13295,9 +13307,11 @@ const PageCanvas = react.forwardRef(
13295
13307
  if (activeObj instanceof fabric__namespace.ActiveSelection) applyWarpAwareSelectionBorders(activeObj);
13296
13308
  if (activeObj) applyControlSizeForZoom(fabricCanvas, activeObj);
13297
13309
  if (activeObj) ensureCanvaControlRenders(activeObj);
13310
+ if (activeObj) ensureCanvaEdgeHitArea(activeObj);
13298
13311
  if (activeObj && !(activeObj instanceof fabric__namespace.ActiveSelection) && (((_a2 = activeObj._ct) == null ? void 0 : _a2.isCropGroup) || activeObj.__cropGroup)) {
13299
13312
  installImageResizeControlsWithSnap(activeObj);
13300
13313
  ensureCanvaControlRenders(activeObj);
13314
+ ensureCanvaEdgeHitArea(activeObj);
13301
13315
  }
13302
13316
  });
13303
13317
  fabricCanvas.on("selection:updated", () => {
@@ -13311,9 +13325,11 @@ const PageCanvas = react.forwardRef(
13311
13325
  if (activeObj instanceof fabric__namespace.ActiveSelection) applyWarpAwareSelectionBorders(activeObj);
13312
13326
  if (activeObj) applyControlSizeForZoom(fabricCanvas, activeObj);
13313
13327
  if (activeObj) ensureCanvaControlRenders(activeObj);
13328
+ if (activeObj) ensureCanvaEdgeHitArea(activeObj);
13314
13329
  if (activeObj && !(activeObj instanceof fabric__namespace.ActiveSelection) && (((_a2 = activeObj._ct) == null ? void 0 : _a2.isCropGroup) || activeObj.__cropGroup)) {
13315
13330
  installImageResizeControlsWithSnap(activeObj);
13316
13331
  ensureCanvaControlRenders(activeObj);
13332
+ ensureCanvaEdgeHitArea(activeObj);
13317
13333
  }
13318
13334
  });
13319
13335
  fabricCanvas.on("mouse:dblclick", (opt) => {
@@ -16786,7 +16802,10 @@ const PageCanvas = react.forwardRef(
16786
16802
  fc.setViewportTransform([zoom2, 0, 0, zoom2, 0, 0]);
16787
16803
  fc.getObjects().forEach((obj) => applyControlSizeForZoom(fc, obj));
16788
16804
  const active = fc.getActiveObject();
16789
- if (active && active instanceof fabric__namespace.ActiveSelection) applyControlSizeForZoom(fc, active);
16805
+ if (active) {
16806
+ if (active instanceof fabric__namespace.ActiveSelection) applyControlSizeForZoom(fc, active);
16807
+ ensureCanvaEdgeHitArea(active);
16808
+ }
16790
16809
  fc.requestRenderAll();
16791
16810
  }, [workspaceZoom, canvasWidth, canvasHeight]);
16792
16811
  react.useEffect(() => {
@@ -25634,9 +25653,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25634
25653
  }
25635
25654
  return svgString;
25636
25655
  }
25637
- const resolvedPackageVersion = "0.5.424";
25656
+ const resolvedPackageVersion = "0.5.425";
25638
25657
  const PACKAGE_VERSION = resolvedPackageVersion;
25639
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.424";
25658
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.425";
25640
25659
  const roundParityValue = (value) => {
25641
25660
  if (typeof value !== "number") return value;
25642
25661
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26450,7 +26469,7 @@ class PixldocsRenderer {
26450
26469
  await this.waitForCanvasScene(container, cloned, i);
26451
26470
  }
26452
26471
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26453
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-JXuSAPvC.cjs"));
26472
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-ygzscD4n.cjs"));
26454
26473
  const prepared = preparePagesForExport(
26455
26474
  cloned.pages,
26456
26475
  canvasWidth,
@@ -28770,7 +28789,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28770
28789
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28771
28790
  sanitizeSvgTreeForPdf(svgToDraw);
28772
28791
  try {
28773
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-JXuSAPvC.cjs"));
28792
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-ygzscD4n.cjs"));
28774
28793
  try {
28775
28794
  await logTextMeasurementDiagnostic(svgToDraw);
28776
28795
  } catch {
@@ -29167,4 +29186,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29167
29186
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29168
29187
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29169
29188
  exports.warmTemplateFromForm = warmTemplateFromForm;
29170
- //# sourceMappingURL=index-4LN7KRW_.cjs.map
29189
+ //# sourceMappingURL=index-qOAH-a4l.cjs.map