@glimt/record 0.0.77 → 0.0.79

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.
@@ -10337,6 +10337,8 @@ const _ObserveManager = class _ObserveManager2 {
10337
10337
  __publicField(this, "shadowRootsObservers", /* @__PURE__ */ new WeakSet());
10338
10338
  __publicField(this, "mutationOptions");
10339
10339
  __publicField(this, "emitter", null);
10340
+ __publicField(this, "isSnapshottingShadowRoots", false);
10341
+ __publicField(this, "isSnapshottingDocs", false);
10340
10342
  if (_ObserveManager2.instance) {
10341
10343
  return _ObserveManager2.instance;
10342
10344
  }
@@ -10417,25 +10419,35 @@ const _ObserveManager = class _ObserveManager2 {
10417
10419
  this.emitShadowRoot(serialized, shadowRoot2);
10418
10420
  }
10419
10421
  onDocObserver(doc) {
10422
+ if (this.isSnapshottingDocs) return false;
10420
10423
  if (!this.usable) return false;
10421
- if (!this.docsObservers.has(doc)) return true;
10422
- this.docsObservers.add(doc);
10424
+ if (!this.docsObservers.has(doc)) {
10425
+ this.docsObservers.add(doc);
10426
+ return true;
10427
+ }
10423
10428
  debugLog(
10424
10429
  "onDocObserver: doc already observed, emitting full snapshot for doc",
10425
10430
  doc
10426
10431
  );
10432
+ this.isSnapshottingDocs = true;
10427
10433
  this.serializeAndEmitDoc(doc);
10434
+ this.isSnapshottingDocs = false;
10428
10435
  return false;
10429
10436
  }
10430
10437
  onShadowRootObserver(shadowRoot2) {
10438
+ if (this.isSnapshottingShadowRoots) return false;
10431
10439
  if (!this.usable) return false;
10432
- if (!this.shadowRootsObservers.has(shadowRoot2)) return true;
10433
- this.shadowRootsObservers.add(shadowRoot2);
10440
+ if (!this.shadowRootsObservers.has(shadowRoot2)) {
10441
+ this.shadowRootsObservers.add(shadowRoot2);
10442
+ return true;
10443
+ }
10434
10444
  debugLog(
10435
10445
  "onShadowRootObserver: shadowRoot already observed, emitting full snapshot for shadowRoot",
10436
10446
  shadowRoot2
10437
10447
  );
10448
+ this.isSnapshottingShadowRoots = true;
10438
10449
  this.serializeAndEmitShadowRoot(shadowRoot2);
10450
+ this.isSnapshottingShadowRoots = false;
10439
10451
  return false;
10440
10452
  }
10441
10453
  // canObserveDoc(doc: Document) {
@@ -13627,6 +13639,7 @@ function record(options = {}) {
13627
13639
  iframeManager.addLoadListener((iframeEl) => {
13628
13640
  try {
13629
13641
  if (!observeManager.onDocObserver(iframeEl.contentDocument)) return;
13642
+ debugLog("Adding mutation observer for iframe", iframeEl);
13630
13643
  handlers.push(observe(iframeEl.contentDocument));
13631
13644
  } catch (error) {
13632
13645
  if (isDebug()) {