@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.umd.cjs
CHANGED
|
@@ -9998,6 +9998,21 @@ function inDom(n2) {
|
|
|
9998
9998
|
if (!doc) return false;
|
|
9999
9999
|
return index$1.contains(doc, n2) || shadowHostInDom(n2);
|
|
10000
10000
|
}
|
|
10001
|
+
const isDebug = () => {
|
|
10002
|
+
return "_rrweb_is_debug" in window && window._rrweb_is_debug ? window._rrweb_is_debug : false;
|
|
10003
|
+
};
|
|
10004
|
+
const debugLog = (...args) => {
|
|
10005
|
+
if (!isDebug()) return;
|
|
10006
|
+
console.log("[recapt:rrweb]", ...args);
|
|
10007
|
+
};
|
|
10008
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
10009
|
+
function makeid(length = 8) {
|
|
10010
|
+
let result2 = "";
|
|
10011
|
+
for (let i2 = 0; i2 < length; i2++) {
|
|
10012
|
+
result2 += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
10013
|
+
}
|
|
10014
|
+
return result2;
|
|
10015
|
+
}
|
|
10001
10016
|
let errorHandler;
|
|
10002
10017
|
function registerErrorHandler(handler) {
|
|
10003
10018
|
errorHandler = handler;
|
|
@@ -10316,13 +10331,47 @@ class IframeManager {
|
|
|
10316
10331
|
}
|
|
10317
10332
|
}
|
|
10318
10333
|
}
|
|
10319
|
-
const
|
|
10320
|
-
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10334
|
+
const _ObserveManager = class _ObserveManager2 {
|
|
10335
|
+
constructor() {
|
|
10336
|
+
__publicField(this, "docsObservers", /* @__PURE__ */ new WeakMap());
|
|
10337
|
+
__publicField(this, "shadowRootsObserved", /* @__PURE__ */ new WeakMap());
|
|
10338
|
+
if (_ObserveManager2.instance) {
|
|
10339
|
+
return _ObserveManager2.instance;
|
|
10340
|
+
}
|
|
10341
|
+
_ObserveManager2.instance = this;
|
|
10342
|
+
}
|
|
10343
|
+
canObserveDoc(doc) {
|
|
10344
|
+
return !this.docsObservers.has(doc);
|
|
10345
|
+
}
|
|
10346
|
+
canObserveShadowRoot(shadowRoot2) {
|
|
10347
|
+
return !this.shadowRootsObserved.has(shadowRoot2);
|
|
10348
|
+
}
|
|
10349
|
+
observerAttached(doc, onCleanup) {
|
|
10350
|
+
debugLog("[doc] attaching observer to doc", doc);
|
|
10351
|
+
if (this.docsObservers.has(doc)) {
|
|
10352
|
+
debugLog("[doc] detected existing observer, cleaning up old observer");
|
|
10353
|
+
const cleanupFn = this.docsObservers.get(doc);
|
|
10354
|
+
cleanupFn == null ? void 0 : cleanupFn();
|
|
10355
|
+
}
|
|
10356
|
+
this.docsObservers.set(doc, onCleanup);
|
|
10357
|
+
}
|
|
10358
|
+
observerAttachedToShadow(shadowRoot2, onCleanup) {
|
|
10359
|
+
debugLog("[shadow] attaching observer to shadowRoot", shadowRoot2);
|
|
10360
|
+
if (this.shadowRootsObserved.has(shadowRoot2)) {
|
|
10361
|
+
debugLog("[shadow] detected existing observer, cleaning up old observer");
|
|
10362
|
+
const cleanupFn = this.shadowRootsObserved.get(shadowRoot2);
|
|
10363
|
+
cleanupFn == null ? void 0 : cleanupFn();
|
|
10364
|
+
}
|
|
10365
|
+
this.shadowRootsObserved.set(shadowRoot2, onCleanup);
|
|
10366
|
+
}
|
|
10367
|
+
destroy() {
|
|
10368
|
+
this.docsObservers = /* @__PURE__ */ new WeakMap();
|
|
10369
|
+
this.shadowRootsObserved = /* @__PURE__ */ new WeakMap();
|
|
10370
|
+
}
|
|
10325
10371
|
};
|
|
10372
|
+
__publicField(_ObserveManager, "instance");
|
|
10373
|
+
let ObserveManager = _ObserveManager;
|
|
10374
|
+
const observeManager = new ObserveManager();
|
|
10326
10375
|
const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
10327
10376
|
constructor() {
|
|
10328
10377
|
__publicField(this, "mutTracker");
|
|
@@ -10586,14 +10635,6 @@ class DoubleLinkedList {
|
|
|
10586
10635
|
}
|
|
10587
10636
|
}
|
|
10588
10637
|
const moveKey = (id, parentId) => `${id}@${parentId}`;
|
|
10589
|
-
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
10590
|
-
function makeid(length = 8) {
|
|
10591
|
-
let result2 = "";
|
|
10592
|
-
for (let i2 = 0; i2 < length; i2++) {
|
|
10593
|
-
result2 += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
10594
|
-
}
|
|
10595
|
-
return result2;
|
|
10596
|
-
}
|
|
10597
10638
|
class MutationBuffer {
|
|
10598
10639
|
constructor() {
|
|
10599
10640
|
__publicField(this, "frozen", false);
|
|
@@ -12232,7 +12273,6 @@ function initObservers(o2, hooks = {}) {
|
|
|
12232
12273
|
mergeHooks(o2, hooks);
|
|
12233
12274
|
let mutationObserver;
|
|
12234
12275
|
if (o2.recordDOM) {
|
|
12235
|
-
debugLog("adding mutation observer in initObservers");
|
|
12236
12276
|
mutationObserver = initMutationObserver(o2, o2.doc);
|
|
12237
12277
|
}
|
|
12238
12278
|
const mousemoveHandler = initMoveObserver(o2);
|
|
@@ -12868,6 +12908,7 @@ class ShadowDomManager {
|
|
|
12868
12908
|
__publicField(this, "bypassOptions");
|
|
12869
12909
|
__publicField(this, "mirror");
|
|
12870
12910
|
__publicField(this, "restoreHandlers", []);
|
|
12911
|
+
__publicField(this, "mappedRestoreHandlers", {});
|
|
12871
12912
|
this.mutationCb = options.mutationCb;
|
|
12872
12913
|
this.scrollCb = options.scrollCb;
|
|
12873
12914
|
this.bypassOptions = options.bypassOptions;
|
|
@@ -12880,9 +12921,11 @@ class ShadowDomManager {
|
|
|
12880
12921
|
}
|
|
12881
12922
|
addShadowRoot(shadowRoot2, doc) {
|
|
12882
12923
|
if (!isNativeShadowDom(shadowRoot2)) return;
|
|
12924
|
+
if (!observeManager.canObserveShadowRoot(shadowRoot2)) return;
|
|
12883
12925
|
if (this.shadowDoms.has(shadowRoot2)) return;
|
|
12884
12926
|
this.shadowDoms.add(shadowRoot2);
|
|
12885
12927
|
debugLog(`Adding mutation observer for shadowRoot ${shadowRoot2.host}`);
|
|
12928
|
+
const observeId = makeid();
|
|
12886
12929
|
const observer = initMutationObserver(
|
|
12887
12930
|
__spreadProps(__spreadValues({}, this.bypassOptions), {
|
|
12888
12931
|
doc,
|
|
@@ -12892,8 +12935,8 @@ class ShadowDomManager {
|
|
|
12892
12935
|
}),
|
|
12893
12936
|
shadowRoot2
|
|
12894
12937
|
);
|
|
12895
|
-
this.
|
|
12896
|
-
|
|
12938
|
+
this.mappedRestoreHandlers[observeId] = [
|
|
12939
|
+
() => observer.disconnect(),
|
|
12897
12940
|
initScrollObserver(__spreadProps(__spreadValues({}, this.bypassOptions), {
|
|
12898
12941
|
scrollCb: this.scrollCb,
|
|
12899
12942
|
// https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
|
|
@@ -12901,14 +12944,14 @@ class ShadowDomManager {
|
|
|
12901
12944
|
doc: shadowRoot2,
|
|
12902
12945
|
mirror: this.mirror
|
|
12903
12946
|
}))
|
|
12904
|
-
|
|
12947
|
+
];
|
|
12905
12948
|
setTimeout(() => {
|
|
12906
12949
|
if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0)
|
|
12907
12950
|
this.bypassOptions.stylesheetManager.adoptStyleSheets(
|
|
12908
12951
|
shadowRoot2.adoptedStyleSheets,
|
|
12909
12952
|
this.mirror.getId(index$1.host(shadowRoot2))
|
|
12910
12953
|
);
|
|
12911
|
-
this.
|
|
12954
|
+
this.mappedRestoreHandlers[observeId].push(
|
|
12912
12955
|
initAdoptedStyleSheetObserver(
|
|
12913
12956
|
{
|
|
12914
12957
|
mirror: this.mirror,
|
|
@@ -12918,6 +12961,18 @@ class ShadowDomManager {
|
|
|
12918
12961
|
)
|
|
12919
12962
|
);
|
|
12920
12963
|
}, 0);
|
|
12964
|
+
observeManager.observerAttachedToShadow(shadowRoot2, () => {
|
|
12965
|
+
const handlers = this.mappedRestoreHandlers[observeId];
|
|
12966
|
+
if (handlers) {
|
|
12967
|
+
for (const handler of handlers) {
|
|
12968
|
+
try {
|
|
12969
|
+
handler();
|
|
12970
|
+
} catch (e2) {
|
|
12971
|
+
}
|
|
12972
|
+
}
|
|
12973
|
+
}
|
|
12974
|
+
delete this.mappedRestoreHandlers[observeId];
|
|
12975
|
+
});
|
|
12921
12976
|
}
|
|
12922
12977
|
/**
|
|
12923
12978
|
* Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
|
|
@@ -12957,6 +13012,15 @@ class ShadowDomManager {
|
|
|
12957
13012
|
} catch (e2) {
|
|
12958
13013
|
}
|
|
12959
13014
|
});
|
|
13015
|
+
Object.values(this.mappedRestoreHandlers).forEach((handlers) => {
|
|
13016
|
+
for (const handler of handlers) {
|
|
13017
|
+
try {
|
|
13018
|
+
handler();
|
|
13019
|
+
} catch (e2) {
|
|
13020
|
+
}
|
|
13021
|
+
}
|
|
13022
|
+
});
|
|
13023
|
+
this.mappedRestoreHandlers = {};
|
|
12960
13024
|
this.restoreHandlers = [];
|
|
12961
13025
|
this.shadowDoms = /* @__PURE__ */ new WeakSet();
|
|
12962
13026
|
}
|
|
@@ -13331,6 +13395,7 @@ function record(options = {}) {
|
|
|
13331
13395
|
};
|
|
13332
13396
|
try {
|
|
13333
13397
|
const handlers = [];
|
|
13398
|
+
const registeredHandlers = {};
|
|
13334
13399
|
const observe = (doc) => {
|
|
13335
13400
|
var _a2;
|
|
13336
13401
|
return callbackWrapper(initObservers)(
|
|
@@ -13447,8 +13512,14 @@ function record(options = {}) {
|
|
|
13447
13512
|
};
|
|
13448
13513
|
iframeManager.addLoadListener((iframeEl) => {
|
|
13449
13514
|
try {
|
|
13450
|
-
|
|
13451
|
-
|
|
13515
|
+
if (!observeManager.canObserveDoc(iframeEl.contentDocument)) return;
|
|
13516
|
+
const stopObserve = observe(iframeEl.contentDocument);
|
|
13517
|
+
const id = makeid();
|
|
13518
|
+
registeredHandlers[id] = stopObserve;
|
|
13519
|
+
observeManager.observerAttached(iframeEl.contentDocument, () => {
|
|
13520
|
+
stopObserve();
|
|
13521
|
+
delete registeredHandlers[id];
|
|
13522
|
+
});
|
|
13452
13523
|
} catch (error) {
|
|
13453
13524
|
if (isDebug()) {
|
|
13454
13525
|
console.warn("internal error");
|
|
@@ -13507,7 +13578,9 @@ function record(options = {}) {
|
|
|
13507
13578
|
}
|
|
13508
13579
|
return () => {
|
|
13509
13580
|
handlers.forEach((h) => h());
|
|
13581
|
+
Object.values(registeredHandlers).forEach((h) => h());
|
|
13510
13582
|
processedNodeManager.destroy();
|
|
13583
|
+
observeManager.destroy();
|
|
13511
13584
|
recording = false;
|
|
13512
13585
|
unregisterErrorHandler();
|
|
13513
13586
|
};
|