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