@merittdev/horus-lens 0.5.0 → 0.5.2

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.
package/dist/browser.js CHANGED
@@ -7,8 +7,8 @@ import {
7
7
  isGateActive,
8
8
  loaderSnippet,
9
9
  processQueue
10
- } from "./chunk-M3QMIY4Y.js";
11
- import "./chunk-2G5FEWPU.js";
10
+ } from "./chunk-4E427AKG.js";
11
+ import "./chunk-25CZMYQK.js";
12
12
  export {
13
13
  DEFAULT_CDN_URL,
14
14
  LOADER_SNIPPET,
@@ -29063,7 +29063,7 @@ async function domToBlob(node2, options) {
29063
29063
 
29064
29064
  // ../core/dist/index.js
29065
29065
  var SDK_NAME = "@merittdev/horus-lens";
29066
- var SDK_VERSION = true ? "0.5.0" : "0.0.0-dev";
29066
+ var SDK_VERSION = true ? "0.5.2" : "0.0.0-dev";
29067
29067
  var DEFAULT_ENDPOINT = "https://api.horus.sh";
29068
29068
  var DEFAULT_REPLAY_WINDOW_MS = 15e3;
29069
29069
  var DEFAULT_MAX_CONSOLE_ENTRIES = 200;
@@ -29075,6 +29075,7 @@ var MAX_SERIALIZED_ARG_CHARS = 2e3;
29075
29075
  var MAX_DOM_BYTES = 2 * 1024 * 1024;
29076
29076
  var MAX_TARGET_TEXT_CHARS = 200;
29077
29077
  var SCREENSHOT_TIMEOUT_MS = 2e4;
29078
+ var SCREENSHOT_RESOURCE_TIMEOUT_MS = 3500;
29078
29079
  var SCREENSHOT_MAX_SCALE = 2;
29079
29080
  var SCREENSHOT_MAX_PIXELS = 25e5;
29080
29081
  var AUTO_CAPTURE_COOLDOWN_MS = 10 * 60 * 1e3;
@@ -29629,6 +29630,14 @@ var ReplayRecorder = class {
29629
29630
  }
29630
29631
  };
29631
29632
  var SVG_RASTERIZE_TIMEOUT_MS = 3e3;
29633
+ function isOffscreenMedia(node2) {
29634
+ if (!(node2 instanceof HTMLImageElement) && !(node2 instanceof HTMLIFrameElement) && !(typeof HTMLVideoElement !== "undefined" && node2 instanceof HTMLVideoElement)) {
29635
+ return false;
29636
+ }
29637
+ const r = node2.getBoundingClientRect();
29638
+ if (r.width === 0 && r.height === 0) return false;
29639
+ return r.bottom < 0 || r.top > window.innerHeight || r.right < 0 || r.left > window.innerWidth;
29640
+ }
29632
29641
  function computeCropRect(crop, scale, rasterWidth, rasterHeight) {
29633
29642
  let sx = Math.round(crop.x * scale);
29634
29643
  let sy = Math.round(crop.y * scale);
@@ -29644,8 +29653,11 @@ function computeCropRect(crop, scale, rasterWidth, rasterHeight) {
29644
29653
  async function captureScreenshot(excludeHost, crop, composite) {
29645
29654
  if (typeof document === "undefined" || typeof window === "undefined") return null;
29646
29655
  try {
29647
- const viewportPixels = window.innerWidth * window.innerHeight || 1;
29648
- const pixelCap = Math.sqrt(SCREENSHOT_MAX_PIXELS / viewportPixels);
29656
+ const viewportOnly = !composite && !crop;
29657
+ const captureW = composite ? composite.docWidth : window.innerWidth;
29658
+ const captureH = composite ? composite.docHeight : window.innerHeight;
29659
+ const capturePixels = captureW * captureH || 1;
29660
+ const pixelCap = Math.sqrt(SCREENSHOT_MAX_PIXELS / capturePixels);
29649
29661
  const scale = Math.max(1, Math.min(window.devicePixelRatio || 1, SCREENSHOT_MAX_SCALE, pixelCap));
29650
29662
  const capture = domToBlob(document.documentElement, {
29651
29663
  scale,
@@ -29654,18 +29666,35 @@ async function captureScreenshot(excludeHost, crop, composite) {
29654
29666
  // JPEG has no alpha — transparent page regions (and any capture box
29655
29667
  // extending past short content) would otherwise encode as BLACK.
29656
29668
  backgroundColor: "#ffffff",
29657
- // When compositing annotations, force the capture box to the editor's
29658
- // document measurement (scrollHeight-based). modern-screenshot otherwise
29659
- // sizes from documentElement's bounding box, which on pages SHORTER than
29660
- // the viewport is the content height only — marks drawn in the lower
29661
- // viewport band would fall off the raster and the crop would clamp short.
29669
+ // Composite (annotations): force the capture box to the editor's document
29670
+ // measurement so marks in the lower viewport band aren't clipped.
29662
29671
  ...composite ? { width: composite.docWidth, height: composite.docHeight } : {},
29663
- // Exclude the overlay from the capture CLONE — never hide the live node.
29664
- filter: (node2) => node2 !== excludeHost,
29665
- // Per-resource fetch budget: a single slow cross-origin image must not
29666
- // consume the whole capture window.
29672
+ // Plain report: clip the render to the viewport and shift the scrolled
29673
+ // content into it, so only the visible region is rasterized/fetched.
29674
+ ...viewportOnly ? {
29675
+ width: window.innerWidth,
29676
+ height: window.innerHeight,
29677
+ style: {
29678
+ transform: `translate(${-window.scrollX}px, ${-window.scrollY}px)`,
29679
+ transformOrigin: "top left"
29680
+ }
29681
+ } : {},
29682
+ // Exclude the overlay from the capture CLONE (never hide the live node),
29683
+ // and — for a plain viewport report — drop images/iframes entirely outside
29684
+ // the viewport so we don't fetch dozens of off-screen cross-origin assets.
29685
+ filter: (node2) => {
29686
+ if (node2 === excludeHost) return false;
29687
+ if (viewportOnly && isOffscreenMedia(node2)) return false;
29688
+ return true;
29689
+ },
29690
+ // Skip web-font download/embed. On font-heavy pages (multiple custom
29691
+ // families) this is a dominant, flaky cost; fallback fonts are fine for a
29692
+ // bug-report screenshot and capture becomes far more reliable.
29693
+ font: false,
29667
29694
  fetch: { requestInit: { cache: "force-cache" }, bypassingCache: false },
29668
- timeout: SCREENSHOT_TIMEOUT_MS - 1e3
29695
+ // PER-RESOURCE cap (NOT the overall budget): a hanging asset fails fast to
29696
+ // a placeholder instead of stalling the whole capture.
29697
+ timeout: SCREENSHOT_RESOURCE_TIMEOUT_MS
29669
29698
  });
29670
29699
  const started = Date.now();
29671
29700
  const timeout = new Promise((resolve) => {
@@ -29694,14 +29723,8 @@ async function captureScreenshot(excludeHost, crop, composite) {
29694
29723
  return null;
29695
29724
  }
29696
29725
  }
29697
- const effectiveCrop = crop ?? (composite ? void 0 : {
29698
- x: window.scrollX,
29699
- y: window.scrollY,
29700
- width: window.innerWidth,
29701
- height: window.innerHeight
29702
- });
29703
- if (effectiveCrop) {
29704
- const cropped = await cropBlob(blob2, effectiveCrop, scale);
29726
+ if (crop) {
29727
+ const cropped = await cropBlob(blob2, crop, scale);
29705
29728
  return cropped ?? blob2;
29706
29729
  }
29707
29730
  return blob2;
@@ -30301,4 +30324,4 @@ rrweb/dist/rrweb.js:
30301
30324
  PERFORMANCE OF THIS SOFTWARE.
30302
30325
  ***************************************************************************** *)
30303
30326
  */
30304
- //# sourceMappingURL=chunk-2G5FEWPU.js.map
30327
+ //# sourceMappingURL=chunk-25CZMYQK.js.map