@glimt/record 0.0.36 → 0.0.38

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/record.cjs CHANGED
@@ -1213,6 +1213,8 @@ function serializeElementNode(n2, options) {
1213
1213
  delete attributes.rel;
1214
1214
  delete attributes.href;
1215
1215
  attributes._cssText = cssText;
1216
+ } else {
1217
+ console.log("failed to extract stylesheets from link element", n2);
1216
1218
  }
1217
1219
  }
1218
1220
  if (tagName === "style" && n2.sheet) {
@@ -12580,12 +12582,31 @@ function record(options = {}) {
12580
12582
  console.warn(error);
12581
12583
  }
12582
12584
  });
12585
+ let initedAt = null;
12583
12586
  const init = () => {
12587
+ initedAt = Date.now();
12584
12588
  takeFullSnapshot$1();
12585
12589
  handlers.push(observe(document));
12586
12590
  recording = true;
12587
12591
  };
12592
+ const customOnLoad = () => {
12593
+ window.removeEventListener("load", customOnLoad);
12594
+ console.log("customOnLoad fired", recording, initedAt);
12595
+ if (!recording || initedAt == null) return;
12596
+ console.log("customOnLoad wants to take a full snapshot");
12597
+ if (Date.now() - initedAt <= 10) {
12598
+ console.log("customOnLoad skipping full snapshot bc it was too soon");
12599
+ return;
12600
+ }
12601
+ console.log("customOnLoad taking full snapshot bc race condition");
12602
+ takeFullSnapshot$1();
12603
+ };
12604
+ window.addEventListener("load", customOnLoad);
12588
12605
  if (document.readyState === "interactive" || document.readyState === "complete") {
12606
+ console.log(
12607
+ "fired init() bc readyState === 'interactive' || 'complete'",
12608
+ document.readyState
12609
+ );
12589
12610
  init();
12590
12611
  } else {
12591
12612
  handlers.push(
@@ -12594,7 +12615,10 @@ function record(options = {}) {
12594
12615
  type: EventType.DomContentLoaded,
12595
12616
  data: {}
12596
12617
  });
12597
- if (recordAfter === "DOMContentLoaded") init();
12618
+ if (recordAfter === "DOMContentLoaded") {
12619
+ console.log("fired init() bc listener 'DOMContentLoaded'");
12620
+ init();
12621
+ }
12598
12622
  })
12599
12623
  );
12600
12624
  handlers.push(
@@ -12605,7 +12629,10 @@ function record(options = {}) {
12605
12629
  type: EventType.Load,
12606
12630
  data: {}
12607
12631
  });
12608
- if (recordAfter === "load") init();
12632
+ if (recordAfter === "load") {
12633
+ console.log("fired init() bc listener 'load'");
12634
+ init();
12635
+ }
12609
12636
  },
12610
12637
  window
12611
12638
  )