@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.
package/dist/record.cjs CHANGED
@@ -10295,6 +10295,8 @@ const _ObserveManager = class _ObserveManager2 {
10295
10295
  __publicField(this, "shadowRootsObservers", /* @__PURE__ */ new WeakSet());
10296
10296
  __publicField(this, "mutationOptions");
10297
10297
  __publicField(this, "emitter", null);
10298
+ __publicField(this, "isSnapshottingShadowRoots", false);
10299
+ __publicField(this, "isSnapshottingDocs", false);
10298
10300
  if (_ObserveManager2.instance) {
10299
10301
  return _ObserveManager2.instance;
10300
10302
  }
@@ -10376,25 +10378,35 @@ const _ObserveManager = class _ObserveManager2 {
10376
10378
  this.emitShadowRoot(serialized, shadowRoot2);
10377
10379
  }
10378
10380
  onDocObserver(doc) {
10381
+ if (this.isSnapshottingDocs) return false;
10379
10382
  if (!this.usable) return false;
10380
- if (!this.docsObservers.has(doc)) return true;
10381
- this.docsObservers.add(doc);
10383
+ if (!this.docsObservers.has(doc)) {
10384
+ this.docsObservers.add(doc);
10385
+ return true;
10386
+ }
10382
10387
  debugLog(
10383
10388
  "onDocObserver: doc already observed, emitting full snapshot for doc",
10384
10389
  doc
10385
10390
  );
10391
+ this.isSnapshottingDocs = true;
10386
10392
  this.serializeAndEmitDoc(doc);
10393
+ this.isSnapshottingDocs = false;
10387
10394
  return false;
10388
10395
  }
10389
10396
  onShadowRootObserver(shadowRoot2) {
10397
+ if (this.isSnapshottingShadowRoots) return false;
10390
10398
  if (!this.usable) return false;
10391
- if (!this.shadowRootsObservers.has(shadowRoot2)) return true;
10392
- this.shadowRootsObservers.add(shadowRoot2);
10399
+ if (!this.shadowRootsObservers.has(shadowRoot2)) {
10400
+ this.shadowRootsObservers.add(shadowRoot2);
10401
+ return true;
10402
+ }
10393
10403
  debugLog(
10394
10404
  "onShadowRootObserver: shadowRoot already observed, emitting full snapshot for shadowRoot",
10395
10405
  shadowRoot2
10396
10406
  );
10407
+ this.isSnapshottingShadowRoots = true;
10397
10408
  this.serializeAndEmitShadowRoot(shadowRoot2);
10409
+ this.isSnapshottingShadowRoots = false;
10398
10410
  return false;
10399
10411
  }
10400
10412
  // canObserveDoc(doc: Document) {
@@ -13603,6 +13615,7 @@ function record(options = {}) {
13603
13615
  iframeManager.addLoadListener((iframeEl) => {
13604
13616
  try {
13605
13617
  if (!observeManager.onDocObserver(iframeEl.contentDocument)) return;
13618
+ debugLog("Adding mutation observer for iframe", iframeEl);
13606
13619
  handlers.push(observe(iframeEl.contentDocument));
13607
13620
  } catch (error) {
13608
13621
  if (isDebug()) {