@glimt/record 0.0.73 → 0.0.75
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 +94 -21
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +94 -21
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +94 -21
- package/dist/record.umd.cjs.map +3 -3
- package/dist/record.umd.min.cjs +24 -24
- package/dist/record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/record.cjs
CHANGED
|
@@ -9956,6 +9956,21 @@ function inDom(n2) {
|
|
|
9956
9956
|
if (!doc) return false;
|
|
9957
9957
|
return index$1.contains(doc, n2) || shadowHostInDom(n2);
|
|
9958
9958
|
}
|
|
9959
|
+
const isDebug = () => {
|
|
9960
|
+
return "_rrweb_is_debug" in window && window._rrweb_is_debug ? window._rrweb_is_debug : false;
|
|
9961
|
+
};
|
|
9962
|
+
const debugLog = (...args) => {
|
|
9963
|
+
if (!isDebug()) return;
|
|
9964
|
+
console.log("[recapt:rrweb]", ...args);
|
|
9965
|
+
};
|
|
9966
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
9967
|
+
function makeid(length = 8) {
|
|
9968
|
+
let result2 = "";
|
|
9969
|
+
for (let i2 = 0; i2 < length; i2++) {
|
|
9970
|
+
result2 += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
9971
|
+
}
|
|
9972
|
+
return result2;
|
|
9973
|
+
}
|
|
9959
9974
|
let errorHandler;
|
|
9960
9975
|
function registerErrorHandler(handler) {
|
|
9961
9976
|
errorHandler = handler;
|
|
@@ -10274,13 +10289,47 @@ class IframeManager {
|
|
|
10274
10289
|
}
|
|
10275
10290
|
}
|
|
10276
10291
|
}
|
|
10277
|
-
const
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10292
|
+
const _ObserveManager = class _ObserveManager2 {
|
|
10293
|
+
constructor() {
|
|
10294
|
+
__publicField(this, "docsObservers", /* @__PURE__ */ new WeakMap());
|
|
10295
|
+
__publicField(this, "shadowRootsObserved", /* @__PURE__ */ new WeakMap());
|
|
10296
|
+
if (_ObserveManager2.instance) {
|
|
10297
|
+
return _ObserveManager2.instance;
|
|
10298
|
+
}
|
|
10299
|
+
_ObserveManager2.instance = this;
|
|
10300
|
+
}
|
|
10301
|
+
canObserveDoc(doc) {
|
|
10302
|
+
return !this.docsObservers.has(doc);
|
|
10303
|
+
}
|
|
10304
|
+
canObserveShadowRoot(shadowRoot2) {
|
|
10305
|
+
return !this.shadowRootsObserved.has(shadowRoot2);
|
|
10306
|
+
}
|
|
10307
|
+
observerAttached(doc, onCleanup) {
|
|
10308
|
+
debugLog("[doc] attaching observer to doc", doc);
|
|
10309
|
+
if (this.docsObservers.has(doc)) {
|
|
10310
|
+
debugLog("[doc] detected existing observer, cleaning up old observer");
|
|
10311
|
+
const cleanupFn = this.docsObservers.get(doc);
|
|
10312
|
+
cleanupFn == null ? void 0 : cleanupFn();
|
|
10313
|
+
}
|
|
10314
|
+
this.docsObservers.set(doc, onCleanup);
|
|
10315
|
+
}
|
|
10316
|
+
observerAttachedToShadow(shadowRoot2, onCleanup) {
|
|
10317
|
+
debugLog("[shadow] attaching observer to shadowRoot", shadowRoot2);
|
|
10318
|
+
if (this.shadowRootsObserved.has(shadowRoot2)) {
|
|
10319
|
+
debugLog("[shadow] detected existing observer, cleaning up old observer");
|
|
10320
|
+
const cleanupFn = this.shadowRootsObserved.get(shadowRoot2);
|
|
10321
|
+
cleanupFn == null ? void 0 : cleanupFn();
|
|
10322
|
+
}
|
|
10323
|
+
this.shadowRootsObserved.set(shadowRoot2, onCleanup);
|
|
10324
|
+
}
|
|
10325
|
+
destroy() {
|
|
10326
|
+
this.docsObservers = /* @__PURE__ */ new WeakMap();
|
|
10327
|
+
this.shadowRootsObserved = /* @__PURE__ */ new WeakMap();
|
|
10328
|
+
}
|
|
10283
10329
|
};
|
|
10330
|
+
__publicField(_ObserveManager, "instance");
|
|
10331
|
+
let ObserveManager = _ObserveManager;
|
|
10332
|
+
const observeManager = new ObserveManager();
|
|
10284
10333
|
const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
10285
10334
|
constructor() {
|
|
10286
10335
|
__publicField(this, "mutTracker");
|
|
@@ -10544,14 +10593,6 @@ class DoubleLinkedList {
|
|
|
10544
10593
|
}
|
|
10545
10594
|
}
|
|
10546
10595
|
const moveKey = (id, parentId) => `${id}@${parentId}`;
|
|
10547
|
-
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
10548
|
-
function makeid(length = 8) {
|
|
10549
|
-
let result2 = "";
|
|
10550
|
-
for (let i2 = 0; i2 < length; i2++) {
|
|
10551
|
-
result2 += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
10552
|
-
}
|
|
10553
|
-
return result2;
|
|
10554
|
-
}
|
|
10555
10596
|
class MutationBuffer {
|
|
10556
10597
|
constructor() {
|
|
10557
10598
|
__publicField(this, "frozen", false);
|
|
@@ -12192,7 +12233,6 @@ function initObservers(o2, hooks = {}) {
|
|
|
12192
12233
|
mergeHooks(o2, hooks);
|
|
12193
12234
|
let mutationObserver;
|
|
12194
12235
|
if (o2.recordDOM) {
|
|
12195
|
-
debugLog("adding mutation observer in initObservers");
|
|
12196
12236
|
mutationObserver = initMutationObserver(o2, o2.doc);
|
|
12197
12237
|
}
|
|
12198
12238
|
const mousemoveHandler = initMoveObserver(o2);
|
|
@@ -12828,6 +12868,7 @@ class ShadowDomManager {
|
|
|
12828
12868
|
__publicField(this, "bypassOptions");
|
|
12829
12869
|
__publicField(this, "mirror");
|
|
12830
12870
|
__publicField(this, "restoreHandlers", []);
|
|
12871
|
+
__publicField(this, "mappedRestoreHandlers", {});
|
|
12831
12872
|
this.mutationCb = options.mutationCb;
|
|
12832
12873
|
this.scrollCb = options.scrollCb;
|
|
12833
12874
|
this.bypassOptions = options.bypassOptions;
|
|
@@ -12840,9 +12881,11 @@ class ShadowDomManager {
|
|
|
12840
12881
|
}
|
|
12841
12882
|
addShadowRoot(shadowRoot2, doc) {
|
|
12842
12883
|
if (!isNativeShadowDom(shadowRoot2)) return;
|
|
12884
|
+
if (!observeManager.canObserveShadowRoot(shadowRoot2)) return;
|
|
12843
12885
|
if (this.shadowDoms.has(shadowRoot2)) return;
|
|
12844
12886
|
this.shadowDoms.add(shadowRoot2);
|
|
12845
12887
|
debugLog(`Adding mutation observer for shadowRoot ${shadowRoot2.host}`);
|
|
12888
|
+
const observeId = makeid();
|
|
12846
12889
|
const observer = initMutationObserver(
|
|
12847
12890
|
{
|
|
12848
12891
|
...this.bypassOptions,
|
|
@@ -12853,8 +12896,8 @@ class ShadowDomManager {
|
|
|
12853
12896
|
},
|
|
12854
12897
|
shadowRoot2
|
|
12855
12898
|
);
|
|
12856
|
-
this.
|
|
12857
|
-
|
|
12899
|
+
this.mappedRestoreHandlers[observeId] = [
|
|
12900
|
+
() => observer.disconnect(),
|
|
12858
12901
|
initScrollObserver({
|
|
12859
12902
|
...this.bypassOptions,
|
|
12860
12903
|
scrollCb: this.scrollCb,
|
|
@@ -12863,14 +12906,14 @@ class ShadowDomManager {
|
|
|
12863
12906
|
doc: shadowRoot2,
|
|
12864
12907
|
mirror: this.mirror
|
|
12865
12908
|
})
|
|
12866
|
-
|
|
12909
|
+
];
|
|
12867
12910
|
setTimeout(() => {
|
|
12868
12911
|
if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0)
|
|
12869
12912
|
this.bypassOptions.stylesheetManager.adoptStyleSheets(
|
|
12870
12913
|
shadowRoot2.adoptedStyleSheets,
|
|
12871
12914
|
this.mirror.getId(index$1.host(shadowRoot2))
|
|
12872
12915
|
);
|
|
12873
|
-
this.
|
|
12916
|
+
this.mappedRestoreHandlers[observeId].push(
|
|
12874
12917
|
initAdoptedStyleSheetObserver(
|
|
12875
12918
|
{
|
|
12876
12919
|
mirror: this.mirror,
|
|
@@ -12880,6 +12923,18 @@ class ShadowDomManager {
|
|
|
12880
12923
|
)
|
|
12881
12924
|
);
|
|
12882
12925
|
}, 0);
|
|
12926
|
+
observeManager.observerAttachedToShadow(shadowRoot2, () => {
|
|
12927
|
+
const handlers = this.mappedRestoreHandlers[observeId];
|
|
12928
|
+
if (handlers) {
|
|
12929
|
+
for (const handler of handlers) {
|
|
12930
|
+
try {
|
|
12931
|
+
handler();
|
|
12932
|
+
} catch (e2) {
|
|
12933
|
+
}
|
|
12934
|
+
}
|
|
12935
|
+
}
|
|
12936
|
+
delete this.mappedRestoreHandlers[observeId];
|
|
12937
|
+
});
|
|
12883
12938
|
}
|
|
12884
12939
|
/**
|
|
12885
12940
|
* Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
|
|
@@ -12919,6 +12974,15 @@ class ShadowDomManager {
|
|
|
12919
12974
|
} catch (e2) {
|
|
12920
12975
|
}
|
|
12921
12976
|
});
|
|
12977
|
+
Object.values(this.mappedRestoreHandlers).forEach((handlers) => {
|
|
12978
|
+
for (const handler of handlers) {
|
|
12979
|
+
try {
|
|
12980
|
+
handler();
|
|
12981
|
+
} catch (e2) {
|
|
12982
|
+
}
|
|
12983
|
+
}
|
|
12984
|
+
});
|
|
12985
|
+
this.mappedRestoreHandlers = {};
|
|
12922
12986
|
this.restoreHandlers = [];
|
|
12923
12987
|
this.shadowDoms = /* @__PURE__ */ new WeakSet();
|
|
12924
12988
|
}
|
|
@@ -13297,6 +13361,7 @@ function record(options = {}) {
|
|
|
13297
13361
|
};
|
|
13298
13362
|
try {
|
|
13299
13363
|
const handlers = [];
|
|
13364
|
+
const registeredHandlers = {};
|
|
13300
13365
|
const observe = (doc) => {
|
|
13301
13366
|
var _a2;
|
|
13302
13367
|
return callbackWrapper(initObservers)(
|
|
@@ -13422,8 +13487,14 @@ function record(options = {}) {
|
|
|
13422
13487
|
};
|
|
13423
13488
|
iframeManager.addLoadListener((iframeEl) => {
|
|
13424
13489
|
try {
|
|
13425
|
-
|
|
13426
|
-
|
|
13490
|
+
if (!observeManager.canObserveDoc(iframeEl.contentDocument)) return;
|
|
13491
|
+
const stopObserve = observe(iframeEl.contentDocument);
|
|
13492
|
+
const id = makeid();
|
|
13493
|
+
registeredHandlers[id] = stopObserve;
|
|
13494
|
+
observeManager.observerAttached(iframeEl.contentDocument, () => {
|
|
13495
|
+
stopObserve();
|
|
13496
|
+
delete registeredHandlers[id];
|
|
13497
|
+
});
|
|
13427
13498
|
} catch (error) {
|
|
13428
13499
|
if (isDebug()) {
|
|
13429
13500
|
console.warn("internal error");
|
|
@@ -13482,7 +13553,9 @@ function record(options = {}) {
|
|
|
13482
13553
|
}
|
|
13483
13554
|
return () => {
|
|
13484
13555
|
handlers.forEach((h) => h());
|
|
13556
|
+
Object.values(registeredHandlers).forEach((h) => h());
|
|
13485
13557
|
processedNodeManager.destroy();
|
|
13558
|
+
observeManager.destroy();
|
|
13486
13559
|
recording = false;
|
|
13487
13560
|
unregisterErrorHandler();
|
|
13488
13561
|
};
|