@insitue/sdk 0.1.5 → 0.1.6

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
  mountCaptureOnly
3
- } from "./chunk-Z7GTGO4C.js";
4
- import "./chunk-2QO63Y4R.js";
3
+ } from "./chunk-UWKF2IKW.js";
4
+ import "./chunk-TQEOC7QZ.js";
5
5
  export {
6
6
  mountCaptureOnly
7
7
  };
@@ -1763,11 +1763,59 @@ async function renderViewportCrop(cropRect, pixelRatio) {
1763
1763
  if (looksBlankUniform(ctx, out.width, out.height)) {
1764
1764
  return { dataUrl: null, failedImages };
1765
1765
  }
1766
+ detectUnrenderedImages(ctx, cropRect, out, pixelRatio, failedImages);
1766
1767
  return { dataUrl: out.toDataURL("image/png"), failedImages };
1767
1768
  } finally {
1768
1769
  restoreImages();
1769
1770
  }
1770
1771
  }
1772
+ function detectUnrenderedImages(cropCtx, cropRect, cropCanvas, pixelRatio, failedImages) {
1773
+ const imgs = Array.from(
1774
+ document.querySelectorAll("img")
1775
+ ).filter(
1776
+ (img) => !img.closest?.("#insitu-root, [data-insitu-layer]")
1777
+ );
1778
+ for (const img of imgs) {
1779
+ if (failedImages.has(img)) continue;
1780
+ const r3 = img.getBoundingClientRect();
1781
+ if (r3.width < 32 || r3.height < 32) continue;
1782
+ const overlapX = Math.min(r3.right, cropRect.x + cropRect.width) - Math.max(r3.left, cropRect.x);
1783
+ const overlapY = Math.min(r3.bottom, cropRect.y + cropRect.height) - Math.max(r3.top, cropRect.y);
1784
+ if (overlapX <= 0 || overlapY <= 0) continue;
1785
+ const baseX = Math.max(r3.left, cropRect.x);
1786
+ const baseY = Math.max(r3.top, cropRect.y);
1787
+ const samples = /* @__PURE__ */ new Set();
1788
+ try {
1789
+ for (let i3 = 0; i3 < 3; i3++) {
1790
+ for (let j3 = 0; j3 < 3; j3++) {
1791
+ const px2 = baseX + overlapX * (i3 + 0.5) / 3;
1792
+ const py = baseY + overlapY * (j3 + 0.5) / 3;
1793
+ const cx = Math.max(
1794
+ 0,
1795
+ Math.min(
1796
+ cropCanvas.width - 1,
1797
+ Math.round((px2 - cropRect.x) * pixelRatio)
1798
+ )
1799
+ );
1800
+ const cy = Math.max(
1801
+ 0,
1802
+ Math.min(
1803
+ cropCanvas.height - 1,
1804
+ Math.round((py - cropRect.y) * pixelRatio)
1805
+ )
1806
+ );
1807
+ const d3 = cropCtx.getImageData(cx, cy, 1, 1).data;
1808
+ samples.add(`${d3[0]},${d3[1]},${d3[2]},${d3[3]}`);
1809
+ }
1810
+ }
1811
+ } catch {
1812
+ continue;
1813
+ }
1814
+ if (samples.size === 1) {
1815
+ failedImages.add(img);
1816
+ }
1817
+ }
1818
+ }
1771
1819
  function looksBlankUniform(ctx, w3, h3) {
1772
1820
  if (w3 < 4 || h3 < 4) return false;
1773
1821
  const samples = [];
@@ -10,7 +10,7 @@ import {
10
10
  retryDisplayMedia,
11
11
  stopDisplayMedia,
12
12
  y
13
- } from "./chunk-2QO63Y4R.js";
13
+ } from "./chunk-TQEOC7QZ.js";
14
14
 
15
15
  // src/capture-only.ts
16
16
  var DEFAULT_INGEST = "https://www.insitue.com/api/v1/capture";
@@ -353,8 +353,8 @@ function CaptureOnlyApp(props) {
353
353
  k("span", {}, "\u{1F512} Secrets scrubbed automatically"),
354
354
  k(
355
355
  "span",
356
- { title: `@insitue/sdk@${"0.1.5"}` },
357
- `InSitue \xB7 v${"0.1.5"}`
356
+ { title: `@insitue/sdk@${"0.1.6"}` },
357
+ `InSitue \xB7 v${"0.1.6"}`
358
358
  )
359
359
  ]
360
360
  )
@@ -15,7 +15,7 @@ import {
15
15
  setCaptureSettings,
16
16
  stopDisplayMedia,
17
17
  y
18
- } from "./chunk-2QO63Y4R.js";
18
+ } from "./chunk-TQEOC7QZ.js";
19
19
 
20
20
  // src/client.ts
21
21
  var CompanionClient = class {
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  mountCaptureOnly
3
- } from "./chunk-Z7GTGO4C.js";
3
+ } from "./chunk-UWKF2IKW.js";
4
4
  import {
5
5
  mountInSitue
6
- } from "./chunk-QL6QPM2A.js";
7
- import "./chunk-2QO63Y4R.js";
6
+ } from "./chunk-V2VYHBQC.js";
7
+ import "./chunk-TQEOC7QZ.js";
8
8
 
9
9
  // src/InSitue.tsx
10
10
  import { useEffect } from "react";
@@ -46,7 +46,7 @@ function InSitueCapture({
46
46
  }
47
47
 
48
48
  // src/index.ts
49
- var SDK_VERSION = "0.1.5";
49
+ var SDK_VERSION = "0.1.6";
50
50
  export {
51
51
  InSitue,
52
52
  InSitueCapture,
package/dist/overlay.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  mountInSitue
3
- } from "./chunk-QL6QPM2A.js";
4
- import "./chunk-2QO63Y4R.js";
3
+ } from "./chunk-V2VYHBQC.js";
4
+ import "./chunk-TQEOC7QZ.js";
5
5
  export {
6
6
  mountInSitue
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insitue/sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "InSitue capture SDK — drop one snippet into your deployed app; your users point at a bug, InSitue opens a verified pull request.",
5
5
  "license": "MIT",
6
6
  "type": "module",