@glimt/record 0.0.78 → 0.0.80
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 +45 -4
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +45 -4
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +45 -4
- package/dist/record.umd.cjs.map +2 -2
- package/dist/record.umd.min.cjs +21 -21
- package/dist/record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/record.cjs
CHANGED
|
@@ -10293,8 +10293,13 @@ const _ObserveManager = class _ObserveManager2 {
|
|
|
10293
10293
|
constructor() {
|
|
10294
10294
|
__publicField(this, "docsObservers", /* @__PURE__ */ new WeakSet());
|
|
10295
10295
|
__publicField(this, "shadowRootsObservers", /* @__PURE__ */ new WeakSet());
|
|
10296
|
+
__publicField(this, "docsDebounceTimers", /* @__PURE__ */ new WeakMap());
|
|
10297
|
+
__publicField(this, "shadowRootsDebounceTimers", /* @__PURE__ */ new WeakMap());
|
|
10298
|
+
__publicField(this, "debounceTime", 15);
|
|
10296
10299
|
__publicField(this, "mutationOptions");
|
|
10297
10300
|
__publicField(this, "emitter", null);
|
|
10301
|
+
__publicField(this, "isSnapshottingShadowRoots", false);
|
|
10302
|
+
__publicField(this, "isSnapshottingDocs", false);
|
|
10298
10303
|
if (_ObserveManager2.instance) {
|
|
10299
10304
|
return _ObserveManager2.instance;
|
|
10300
10305
|
}
|
|
@@ -10368,37 +10373,73 @@ const _ObserveManager = class _ObserveManager2 {
|
|
|
10368
10373
|
});
|
|
10369
10374
|
}
|
|
10370
10375
|
serializeAndEmitDoc(doc) {
|
|
10376
|
+
debugLog(
|
|
10377
|
+
"onDocObserver: doc already observed, emitting full snapshot for doc",
|
|
10378
|
+
doc
|
|
10379
|
+
);
|
|
10380
|
+
this.isSnapshottingDocs = true;
|
|
10371
10381
|
const serialized = this.serializeDoc(doc);
|
|
10372
10382
|
this.emitDoc(serialized);
|
|
10383
|
+
this.isSnapshottingDocs = false;
|
|
10373
10384
|
}
|
|
10374
10385
|
serializeAndEmitShadowRoot(shadowRoot2) {
|
|
10386
|
+
debugLog(
|
|
10387
|
+
"onShadowRootObserver: shadowRoot already observed, emitting full snapshot for shadowRoot",
|
|
10388
|
+
shadowRoot2
|
|
10389
|
+
);
|
|
10390
|
+
this.isSnapshottingShadowRoots = true;
|
|
10375
10391
|
const serialized = this.serializeDoc(shadowRoot2.ownerDocument);
|
|
10376
10392
|
this.emitShadowRoot(serialized, shadowRoot2);
|
|
10393
|
+
this.isSnapshottingShadowRoots = false;
|
|
10394
|
+
}
|
|
10395
|
+
debounceEmitDoc(doc) {
|
|
10396
|
+
const existingTimer = this.docsDebounceTimers.get(doc);
|
|
10397
|
+
if (existingTimer) clearTimeout(existingTimer);
|
|
10398
|
+
this.docsDebounceTimers.set(
|
|
10399
|
+
doc,
|
|
10400
|
+
setTimeout(() => {
|
|
10401
|
+
this.docsDebounceTimers.delete(doc);
|
|
10402
|
+
this.serializeAndEmitDoc(doc);
|
|
10403
|
+
}, this.debounceTime)
|
|
10404
|
+
);
|
|
10405
|
+
}
|
|
10406
|
+
debounceEmitShadowRoot(shadowRoot2) {
|
|
10407
|
+
const existingTimer = this.shadowRootsDebounceTimers.get(shadowRoot2);
|
|
10408
|
+
if (existingTimer) clearTimeout(existingTimer);
|
|
10409
|
+
this.shadowRootsDebounceTimers.set(
|
|
10410
|
+
shadowRoot2,
|
|
10411
|
+
setTimeout(() => {
|
|
10412
|
+
this.shadowRootsDebounceTimers.delete(shadowRoot2);
|
|
10413
|
+
this.serializeAndEmitShadowRoot(shadowRoot2);
|
|
10414
|
+
}, this.debounceTime)
|
|
10415
|
+
);
|
|
10377
10416
|
}
|
|
10378
10417
|
onDocObserver(doc) {
|
|
10418
|
+
if (this.isSnapshottingDocs) return false;
|
|
10379
10419
|
if (!this.usable) return false;
|
|
10380
10420
|
if (!this.docsObservers.has(doc)) {
|
|
10381
10421
|
this.docsObservers.add(doc);
|
|
10382
10422
|
return true;
|
|
10383
10423
|
}
|
|
10384
10424
|
debugLog(
|
|
10385
|
-
"onDocObserver: doc already observed,
|
|
10425
|
+
"onDocObserver: doc already observed, debouncing full snapshot for doc",
|
|
10386
10426
|
doc
|
|
10387
10427
|
);
|
|
10388
|
-
this.
|
|
10428
|
+
this.debounceEmitDoc(doc);
|
|
10389
10429
|
return false;
|
|
10390
10430
|
}
|
|
10391
10431
|
onShadowRootObserver(shadowRoot2) {
|
|
10432
|
+
if (this.isSnapshottingShadowRoots) return false;
|
|
10392
10433
|
if (!this.usable) return false;
|
|
10393
10434
|
if (!this.shadowRootsObservers.has(shadowRoot2)) {
|
|
10394
10435
|
this.shadowRootsObservers.add(shadowRoot2);
|
|
10395
10436
|
return true;
|
|
10396
10437
|
}
|
|
10397
10438
|
debugLog(
|
|
10398
|
-
"onShadowRootObserver: shadowRoot already observed,
|
|
10439
|
+
"onShadowRootObserver: shadowRoot already observed, debouncing full snapshot for shadowRoot",
|
|
10399
10440
|
shadowRoot2
|
|
10400
10441
|
);
|
|
10401
|
-
this.
|
|
10442
|
+
this.debounceEmitShadowRoot(shadowRoot2);
|
|
10402
10443
|
return false;
|
|
10403
10444
|
}
|
|
10404
10445
|
// canObserveDoc(doc: Document) {
|