@appsurify-testmap/rrweb-all 2.1.1-alpha.6 → 2.1.1-alpha.7

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.
@@ -14424,6 +14424,36 @@ let visibilityManager;
14424
14424
  let recording = false;
14425
14425
  const customEventQueue = [];
14426
14426
  let flushCustomEventQueue;
14427
+ function waitForDOMStabilization(win) {
14428
+ const maxWaitMs = 5e3;
14429
+ return new Promise((resolve2) => {
14430
+ const captureAfterPaint = () => {
14431
+ requestAnimationFrame(() => {
14432
+ requestAnimationFrame(() => {
14433
+ resolve2();
14434
+ });
14435
+ });
14436
+ };
14437
+ const safeResolve = /* @__PURE__ */ (() => {
14438
+ let called = false;
14439
+ return () => {
14440
+ if (!called) {
14441
+ called = true;
14442
+ captureAfterPaint();
14443
+ }
14444
+ };
14445
+ })();
14446
+ if (["interactive", "complete"].includes(win.document.readyState)) {
14447
+ safeResolve();
14448
+ } else {
14449
+ win.addEventListener("DOMContentLoaded", safeResolve, { once: true });
14450
+ win.addEventListener("load", safeResolve, { once: true });
14451
+ setTimeout(() => {
14452
+ safeResolve();
14453
+ }, maxWaitMs);
14454
+ }
14455
+ });
14456
+ }
14427
14457
  try {
14428
14458
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
14429
14459
  const cleanFrame = document.createElement("iframe");
@@ -14915,8 +14945,28 @@ function record(options = {}) {
14915
14945
  flushCustomEventQueue();
14916
14946
  }
14917
14947
  };
14948
+ const runInit = async () => {
14949
+ if (flushCustomEvent === "before") {
14950
+ flushCustomEventQueue();
14951
+ }
14952
+ if (recordAfter === "DOMContentStabilized") {
14953
+ console.log(`[rrweb] 🟢 Waiting for DOM stabilization...`);
14954
+ await waitForDOMStabilization(window);
14955
+ console.log(`[rrweb] ✅ DOM stabilized, starting recording`);
14956
+ }
14957
+ takeFullSnapshot$1();
14958
+ handlers.push(observe(document));
14959
+ recording = true;
14960
+ if (flushCustomEvent === "after") {
14961
+ flushCustomEventQueue();
14962
+ }
14963
+ };
14918
14964
  if (document.readyState === "interactive" || document.readyState === "complete") {
14919
- init();
14965
+ if (recordAfter === "DOMContentStabilized") {
14966
+ void runInit();
14967
+ } else {
14968
+ init();
14969
+ }
14920
14970
  } else {
14921
14971
  handlers.push(
14922
14972
  on("DOMContentLoaded", () => {
@@ -14924,7 +14974,9 @@ function record(options = {}) {
14924
14974
  type: EventType.DomContentLoaded,
14925
14975
  data: {}
14926
14976
  });
14927
- if (recordAfter === "DOMContentLoaded") init();
14977
+ if (recordAfter === "DOMContentLoaded" || recordAfter === "DOMContentStabilized") {
14978
+ void runInit();
14979
+ }
14928
14980
  })
14929
14981
  );
14930
14982
  handlers.push(
@@ -14935,7 +14987,7 @@ function record(options = {}) {
14935
14987
  type: EventType.Load,
14936
14988
  data: {}
14937
14989
  });
14938
- if (recordAfter === "load") init();
14990
+ if (recordAfter === "load") void runInit();
14939
14991
  },
14940
14992
  window
14941
14993
  )
@@ -14952,6 +15004,7 @@ function record(options = {}) {
14952
15004
  console.warn(error);
14953
15005
  }
14954
15006
  }
15007
+ record.isRecording = () => recording;
14955
15008
  record.flushCustomEventQueue = () => {
14956
15009
  console.warn(`[rrweb] CustomEvent flushing: ${customEventQueue.length} events`);
14957
15010
  flushCustomEventQueue();