@merittdev/horus-lens 0.5.0 → 0.5.1

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LENS_OVERLAY_HOST_ID,
3
3
  LensClient
4
- } from "./chunk-2G5FEWPU.js";
4
+ } from "./chunk-GVULQ2IF.js";
5
5
 
6
6
  // ../browser/dist/index.js
7
7
  var DEFAULT_PARAM_NAME = "lens";
@@ -2724,4 +2724,4 @@ export {
2724
2724
  boot,
2725
2725
  autoBoot
2726
2726
  };
2727
- //# sourceMappingURL=chunk-M3QMIY4Y.js.map
2727
+ //# sourceMappingURL=chunk-MN44USB4.js.map
package/dist/index.cjs CHANGED
@@ -29111,7 +29111,7 @@ async function domToBlob(node2, options) {
29111
29111
 
29112
29112
  // ../core/dist/index.js
29113
29113
  var SDK_NAME = "@merittdev/horus-lens";
29114
- var SDK_VERSION = true ? "0.5.0" : "0.0.0-dev";
29114
+ var SDK_VERSION = true ? "0.5.1" : "0.0.0-dev";
29115
29115
  var DEFAULT_ENDPOINT = "https://api.horus.sh";
29116
29116
  var DEFAULT_REPLAY_WINDOW_MS = 15e3;
29117
29117
  var DEFAULT_MAX_CONSOLE_ENTRIES = 200;
@@ -29692,8 +29692,11 @@ function computeCropRect(crop, scale, rasterWidth, rasterHeight) {
29692
29692
  async function captureScreenshot(excludeHost, crop, composite) {
29693
29693
  if (typeof document === "undefined" || typeof window === "undefined") return null;
29694
29694
  try {
29695
- const viewportPixels = window.innerWidth * window.innerHeight || 1;
29696
- const pixelCap = Math.sqrt(SCREENSHOT_MAX_PIXELS / viewportPixels);
29695
+ const viewportOnly = !composite && !crop;
29696
+ const captureW = composite ? composite.docWidth : window.innerWidth;
29697
+ const captureH = composite ? composite.docHeight : window.innerHeight;
29698
+ const capturePixels = captureW * captureH || 1;
29699
+ const pixelCap = Math.sqrt(SCREENSHOT_MAX_PIXELS / capturePixels);
29697
29700
  const scale = Math.max(1, Math.min(window.devicePixelRatio || 1, SCREENSHOT_MAX_SCALE, pixelCap));
29698
29701
  const capture = domToBlob(document.documentElement, {
29699
29702
  scale,
@@ -29702,12 +29705,19 @@ async function captureScreenshot(excludeHost, crop, composite) {
29702
29705
  // JPEG has no alpha — transparent page regions (and any capture box
29703
29706
  // extending past short content) would otherwise encode as BLACK.
29704
29707
  backgroundColor: "#ffffff",
29705
- // When compositing annotations, force the capture box to the editor's
29706
- // document measurement (scrollHeight-based). modern-screenshot otherwise
29707
- // sizes from documentElement's bounding box, which on pages SHORTER than
29708
- // the viewport is the content height only — marks drawn in the lower
29709
- // viewport band would fall off the raster and the crop would clamp short.
29708
+ // Composite (annotations): force the capture box to the editor's document
29709
+ // measurement so marks in the lower viewport band aren't clipped.
29710
29710
  ...composite ? { width: composite.docWidth, height: composite.docHeight } : {},
29711
+ // Plain report: clip the render to the viewport and shift the scrolled
29712
+ // content into it, so only the visible region is rasterized/fetched.
29713
+ ...viewportOnly ? {
29714
+ width: window.innerWidth,
29715
+ height: window.innerHeight,
29716
+ style: {
29717
+ transform: `translate(${-window.scrollX}px, ${-window.scrollY}px)`,
29718
+ transformOrigin: "top left"
29719
+ }
29720
+ } : {},
29711
29721
  // Exclude the overlay from the capture CLONE — never hide the live node.
29712
29722
  filter: (node2) => node2 !== excludeHost,
29713
29723
  // Per-resource fetch budget: a single slow cross-origin image must not
@@ -29742,14 +29752,8 @@ async function captureScreenshot(excludeHost, crop, composite) {
29742
29752
  return null;
29743
29753
  }
29744
29754
  }
29745
- const effectiveCrop = crop ?? (composite ? void 0 : {
29746
- x: window.scrollX,
29747
- y: window.scrollY,
29748
- width: window.innerWidth,
29749
- height: window.innerHeight
29750
- });
29751
- if (effectiveCrop) {
29752
- const cropped = await cropBlob(blob2, effectiveCrop, scale);
29755
+ if (crop) {
29756
+ const cropped = await cropBlob(blob2, crop, scale);
29753
29757
  return cropped ?? blob2;
29754
29758
  }
29755
29759
  return blob2;