@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.cjs CHANGED
@@ -29082,7 +29082,7 @@ var ApiErrorSchema = external_exports.object({
29082
29082
 
29083
29083
  // ../core/dist/index.js
29084
29084
  var SDK_NAME = "@merittdev/horus-lens";
29085
- var SDK_VERSION = true ? "0.5.0" : "0.0.0-dev";
29085
+ var SDK_VERSION = true ? "0.5.2" : "0.0.0-dev";
29086
29086
  var DEFAULT_ENDPOINT = "https://api.horus.sh";
29087
29087
  var DEFAULT_REPLAY_WINDOW_MS = 15e3;
29088
29088
  var DEFAULT_MAX_CONSOLE_ENTRIES = 200;
@@ -29094,6 +29094,7 @@ var MAX_SERIALIZED_ARG_CHARS = 2e3;
29094
29094
  var MAX_DOM_BYTES = 2 * 1024 * 1024;
29095
29095
  var MAX_TARGET_TEXT_CHARS = 200;
29096
29096
  var SCREENSHOT_TIMEOUT_MS = 2e4;
29097
+ var SCREENSHOT_RESOURCE_TIMEOUT_MS = 3500;
29097
29098
  var SCREENSHOT_MAX_SCALE = 2;
29098
29099
  var SCREENSHOT_MAX_PIXELS = 25e5;
29099
29100
  var AUTO_CAPTURE_COOLDOWN_MS = 10 * 60 * 1e3;
@@ -29648,6 +29649,14 @@ var ReplayRecorder = class {
29648
29649
  }
29649
29650
  };
29650
29651
  var SVG_RASTERIZE_TIMEOUT_MS = 3e3;
29652
+ function isOffscreenMedia(node2) {
29653
+ if (!(node2 instanceof HTMLImageElement) && !(node2 instanceof HTMLIFrameElement) && !(typeof HTMLVideoElement !== "undefined" && node2 instanceof HTMLVideoElement)) {
29654
+ return false;
29655
+ }
29656
+ const r = node2.getBoundingClientRect();
29657
+ if (r.width === 0 && r.height === 0) return false;
29658
+ return r.bottom < 0 || r.top > window.innerHeight || r.right < 0 || r.left > window.innerWidth;
29659
+ }
29651
29660
  function computeCropRect(crop, scale, rasterWidth, rasterHeight) {
29652
29661
  let sx = Math.round(crop.x * scale);
29653
29662
  let sy = Math.round(crop.y * scale);
@@ -29663,8 +29672,11 @@ function computeCropRect(crop, scale, rasterWidth, rasterHeight) {
29663
29672
  async function captureScreenshot(excludeHost, crop, composite) {
29664
29673
  if (typeof document === "undefined" || typeof window === "undefined") return null;
29665
29674
  try {
29666
- const viewportPixels = window.innerWidth * window.innerHeight || 1;
29667
- const pixelCap = Math.sqrt(SCREENSHOT_MAX_PIXELS / viewportPixels);
29675
+ const viewportOnly = !composite && !crop;
29676
+ const captureW = composite ? composite.docWidth : window.innerWidth;
29677
+ const captureH = composite ? composite.docHeight : window.innerHeight;
29678
+ const capturePixels = captureW * captureH || 1;
29679
+ const pixelCap = Math.sqrt(SCREENSHOT_MAX_PIXELS / capturePixels);
29668
29680
  const scale = Math.max(1, Math.min(window.devicePixelRatio || 1, SCREENSHOT_MAX_SCALE, pixelCap));
29669
29681
  const capture = domToBlob(document.documentElement, {
29670
29682
  scale,
@@ -29673,18 +29685,35 @@ async function captureScreenshot(excludeHost, crop, composite) {
29673
29685
  // JPEG has no alpha — transparent page regions (and any capture box
29674
29686
  // extending past short content) would otherwise encode as BLACK.
29675
29687
  backgroundColor: "#ffffff",
29676
- // When compositing annotations, force the capture box to the editor's
29677
- // document measurement (scrollHeight-based). modern-screenshot otherwise
29678
- // sizes from documentElement's bounding box, which on pages SHORTER than
29679
- // the viewport is the content height only — marks drawn in the lower
29680
- // viewport band would fall off the raster and the crop would clamp short.
29688
+ // Composite (annotations): force the capture box to the editor's document
29689
+ // measurement so marks in the lower viewport band aren't clipped.
29681
29690
  ...composite ? { width: composite.docWidth, height: composite.docHeight } : {},
29682
- // Exclude the overlay from the capture CLONE — never hide the live node.
29683
- filter: (node2) => node2 !== excludeHost,
29684
- // Per-resource fetch budget: a single slow cross-origin image must not
29685
- // consume the whole capture window.
29691
+ // Plain report: clip the render to the viewport and shift the scrolled
29692
+ // content into it, so only the visible region is rasterized/fetched.
29693
+ ...viewportOnly ? {
29694
+ width: window.innerWidth,
29695
+ height: window.innerHeight,
29696
+ style: {
29697
+ transform: `translate(${-window.scrollX}px, ${-window.scrollY}px)`,
29698
+ transformOrigin: "top left"
29699
+ }
29700
+ } : {},
29701
+ // Exclude the overlay from the capture CLONE (never hide the live node),
29702
+ // and — for a plain viewport report — drop images/iframes entirely outside
29703
+ // the viewport so we don't fetch dozens of off-screen cross-origin assets.
29704
+ filter: (node2) => {
29705
+ if (node2 === excludeHost) return false;
29706
+ if (viewportOnly && isOffscreenMedia(node2)) return false;
29707
+ return true;
29708
+ },
29709
+ // Skip web-font download/embed. On font-heavy pages (multiple custom
29710
+ // families) this is a dominant, flaky cost; fallback fonts are fine for a
29711
+ // bug-report screenshot and capture becomes far more reliable.
29712
+ font: false,
29686
29713
  fetch: { requestInit: { cache: "force-cache" }, bypassingCache: false },
29687
- timeout: SCREENSHOT_TIMEOUT_MS - 1e3
29714
+ // PER-RESOURCE cap (NOT the overall budget): a hanging asset fails fast to
29715
+ // a placeholder instead of stalling the whole capture.
29716
+ timeout: SCREENSHOT_RESOURCE_TIMEOUT_MS
29688
29717
  });
29689
29718
  const started = Date.now();
29690
29719
  const timeout = new Promise((resolve) => {
@@ -29713,14 +29742,8 @@ async function captureScreenshot(excludeHost, crop, composite) {
29713
29742
  return null;
29714
29743
  }
29715
29744
  }
29716
- const effectiveCrop = crop ?? (composite ? void 0 : {
29717
- x: window.scrollX,
29718
- y: window.scrollY,
29719
- width: window.innerWidth,
29720
- height: window.innerHeight
29721
- });
29722
- if (effectiveCrop) {
29723
- const cropped = await cropBlob(blob2, effectiveCrop, scale);
29745
+ if (crop) {
29746
+ const cropped = await cropBlob(blob2, crop, scale);
29724
29747
  return cropped ?? blob2;
29725
29748
  }
29726
29749
  return blob2;