@loupekit/sdk 0.3.3-next.8 → 0.3.4-next.9

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.
@@ -1947,17 +1947,29 @@ var Loupe = (() => {
1947
1947
  }
1948
1948
  return { html, styles };
1949
1949
  }
1950
+ async function fontsReady() {
1951
+ try {
1952
+ const fonts = document.fonts;
1953
+ if (fonts?.ready) await fonts.ready;
1954
+ } catch {
1955
+ }
1956
+ }
1957
+ function captureFilter(node) {
1958
+ if (!(node instanceof Element)) return true;
1959
+ if (node.id === "loupe-root") return false;
1960
+ if (node.hasAttribute("data-loupe-redact")) return false;
1961
+ return true;
1962
+ }
1950
1963
  async function captureScreenshot(el2) {
1951
1964
  try {
1965
+ await fontsReady();
1952
1966
  return await domToPng(el2, {
1953
1967
  scale: Math.min(window.devicePixelRatio || 1, 2),
1954
1968
  backgroundColor: getComputedStyle(document.body).backgroundColor || "#ffffff",
1955
- filter: (node) => {
1956
- if (!(node instanceof Element)) return true;
1957
- if (node.id === "loupe-root") return false;
1958
- if (node.hasAttribute("data-loupe-redact")) return false;
1959
- return true;
1960
- }
1969
+ // Give cross-origin font/asset fetches time to embed (default is short) so
1970
+ // the capture matches the page instead of falling back to system fonts.
1971
+ timeout: 3e4,
1972
+ filter: captureFilter
1961
1973
  });
1962
1974
  } catch (err) {
1963
1975
  console.warn("[loupe] screenshot capture failed", err);
@@ -1966,16 +1978,13 @@ var Loupe = (() => {
1966
1978
  }
1967
1979
  async function captureRegionScreenshot(rect) {
1968
1980
  try {
1981
+ await fontsReady();
1969
1982
  const scale = Math.min(window.devicePixelRatio || 1, 2);
1970
1983
  const full = await domToPng(document.body, {
1971
1984
  scale,
1972
1985
  backgroundColor: getComputedStyle(document.body).backgroundColor || "#ffffff",
1973
- filter: (node) => {
1974
- if (!(node instanceof Element)) return true;
1975
- if (node.id === "loupe-root") return false;
1976
- if (node.hasAttribute("data-loupe-redact")) return false;
1977
- return true;
1978
- }
1986
+ timeout: 3e4,
1987
+ filter: captureFilter
1979
1988
  });
1980
1989
  const bodyRect = document.body.getBoundingClientRect();
1981
1990
  const redact = Array.from(document.querySelectorAll("[data-loupe-redact]")).map(