@glimt/record 0.0.75 → 0.0.77
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 +158 -49
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +158 -49
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +157 -49
- package/dist/record.umd.cjs.map +2 -2
- 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
|
@@ -10291,40 +10291,145 @@ class IframeManager {
|
|
|
10291
10291
|
}
|
|
10292
10292
|
const _ObserveManager = class _ObserveManager2 {
|
|
10293
10293
|
constructor() {
|
|
10294
|
-
__publicField(this, "docsObservers", /* @__PURE__ */ new
|
|
10295
|
-
__publicField(this, "
|
|
10294
|
+
__publicField(this, "docsObservers", /* @__PURE__ */ new WeakSet());
|
|
10295
|
+
__publicField(this, "shadowRootsObservers", /* @__PURE__ */ new WeakSet());
|
|
10296
|
+
__publicField(this, "mutationOptions");
|
|
10297
|
+
__publicField(this, "emitter", null);
|
|
10296
10298
|
if (_ObserveManager2.instance) {
|
|
10297
10299
|
return _ObserveManager2.instance;
|
|
10298
10300
|
}
|
|
10299
10301
|
_ObserveManager2.instance = this;
|
|
10300
10302
|
}
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
+
setEmitter(emitter) {
|
|
10304
|
+
this.emitter = emitter;
|
|
10303
10305
|
}
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
+
setMutationOptions(options) {
|
|
10307
|
+
this.mutationOptions = options;
|
|
10306
10308
|
}
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
if (
|
|
10310
|
-
|
|
10311
|
-
const cleanupFn = this.docsObservers.get(doc);
|
|
10312
|
-
cleanupFn == null ? void 0 : cleanupFn();
|
|
10313
|
-
}
|
|
10314
|
-
this.docsObservers.set(doc, onCleanup);
|
|
10309
|
+
get usable() {
|
|
10310
|
+
const result2 = this.emitter != null;
|
|
10311
|
+
if (!result2) debugLog("observerManager: emitter is null");
|
|
10312
|
+
return result2;
|
|
10315
10313
|
}
|
|
10316
|
-
|
|
10317
|
-
|
|
10318
|
-
if (this.
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
|
-
|
|
10314
|
+
serializeDoc(doc) {
|
|
10315
|
+
var _a2, _b2, _c;
|
|
10316
|
+
if (!((_a2 = this.mutationOptions) == null ? void 0 : _a2.mirror)) return null;
|
|
10317
|
+
const serialized = serializeNodeWithId(doc, {
|
|
10318
|
+
...this.mutationOptions,
|
|
10319
|
+
doc,
|
|
10320
|
+
skipChild: false,
|
|
10321
|
+
maskTextFn: (_b2 = this.mutationOptions) == null ? void 0 : _b2.maskTextFn,
|
|
10322
|
+
maskInputFn: (_c = this.mutationOptions) == null ? void 0 : _c.maskInputFn
|
|
10323
|
+
});
|
|
10324
|
+
if (!serialized) {
|
|
10325
|
+
debugLog("snapshotDoc: no serialized node");
|
|
10326
|
+
return null;
|
|
10322
10327
|
}
|
|
10323
|
-
|
|
10328
|
+
return serialized;
|
|
10329
|
+
}
|
|
10330
|
+
emitDoc(serialized) {
|
|
10331
|
+
if (!this.emitter || !serialized) return;
|
|
10332
|
+
this.emitter({
|
|
10333
|
+
type: EventType.FullSnapshot,
|
|
10334
|
+
data: {
|
|
10335
|
+
node: serialized,
|
|
10336
|
+
initialOffset: {
|
|
10337
|
+
left: 0,
|
|
10338
|
+
top: 0
|
|
10339
|
+
}
|
|
10340
|
+
}
|
|
10341
|
+
});
|
|
10342
|
+
}
|
|
10343
|
+
emitShadowRoot(serialized, shadowRoot2) {
|
|
10344
|
+
var _a2;
|
|
10345
|
+
if (!this.emitter || !serialized || !((_a2 = this.mutationOptions) == null ? void 0 : _a2.mirror)) return;
|
|
10346
|
+
const hostId = this.mutationOptions.mirror.getId(shadowRoot2.host);
|
|
10347
|
+
const shadowId = this.mutationOptions.mirror.getId(shadowRoot2);
|
|
10348
|
+
this.emitter({
|
|
10349
|
+
type: EventType.IncrementalSnapshot,
|
|
10350
|
+
data: {
|
|
10351
|
+
source: IncrementalSource.Mutation,
|
|
10352
|
+
adds: [
|
|
10353
|
+
{
|
|
10354
|
+
parentId: hostId,
|
|
10355
|
+
nextId: null,
|
|
10356
|
+
node: serialized
|
|
10357
|
+
}
|
|
10358
|
+
],
|
|
10359
|
+
removes: [
|
|
10360
|
+
{
|
|
10361
|
+
id: shadowId,
|
|
10362
|
+
parentId: hostId
|
|
10363
|
+
}
|
|
10364
|
+
],
|
|
10365
|
+
attributes: [],
|
|
10366
|
+
texts: []
|
|
10367
|
+
}
|
|
10368
|
+
});
|
|
10369
|
+
}
|
|
10370
|
+
serializeAndEmitDoc(doc) {
|
|
10371
|
+
const serialized = this.serializeDoc(doc);
|
|
10372
|
+
this.emitDoc(serialized);
|
|
10373
|
+
}
|
|
10374
|
+
serializeAndEmitShadowRoot(shadowRoot2) {
|
|
10375
|
+
const serialized = this.serializeDoc(shadowRoot2.ownerDocument);
|
|
10376
|
+
this.emitShadowRoot(serialized, shadowRoot2);
|
|
10377
|
+
}
|
|
10378
|
+
onDocObserver(doc) {
|
|
10379
|
+
if (!this.usable) return false;
|
|
10380
|
+
if (!this.docsObservers.has(doc)) return true;
|
|
10381
|
+
this.docsObservers.add(doc);
|
|
10382
|
+
debugLog(
|
|
10383
|
+
"onDocObserver: doc already observed, emitting full snapshot for doc",
|
|
10384
|
+
doc
|
|
10385
|
+
);
|
|
10386
|
+
this.serializeAndEmitDoc(doc);
|
|
10387
|
+
return false;
|
|
10388
|
+
}
|
|
10389
|
+
onShadowRootObserver(shadowRoot2) {
|
|
10390
|
+
if (!this.usable) return false;
|
|
10391
|
+
if (!this.shadowRootsObservers.has(shadowRoot2)) return true;
|
|
10392
|
+
this.shadowRootsObservers.add(shadowRoot2);
|
|
10393
|
+
debugLog(
|
|
10394
|
+
"onShadowRootObserver: shadowRoot already observed, emitting full snapshot for shadowRoot",
|
|
10395
|
+
shadowRoot2
|
|
10396
|
+
);
|
|
10397
|
+
this.serializeAndEmitShadowRoot(shadowRoot2);
|
|
10398
|
+
return false;
|
|
10324
10399
|
}
|
|
10400
|
+
// canObserveDoc(doc: Document) {
|
|
10401
|
+
// if (!this.usable) return false;
|
|
10402
|
+
// const hasObserver = this.docsObservers.has(doc);
|
|
10403
|
+
// if (!hasObserver) return true;
|
|
10404
|
+
// return false;
|
|
10405
|
+
// }
|
|
10406
|
+
// canObserveShadowRoot(shadowRoot: ShadowRoot) {
|
|
10407
|
+
// if (!this.usable) return false;
|
|
10408
|
+
// return !this.shadowRootsObserved.has(shadowRoot);
|
|
10409
|
+
// }
|
|
10410
|
+
// observerAttached(doc: Document, onCleanup: VoidFunction) {
|
|
10411
|
+
// if (!this.usable) return;
|
|
10412
|
+
// debugLog('[doc] attaching observer to doc', doc);
|
|
10413
|
+
// if (this.docsObservers.has(doc)) {
|
|
10414
|
+
// debugLog('[doc] detected existing observer, cleaning up old observer');
|
|
10415
|
+
// const cleanupFn = this.docsObservers.get(doc);
|
|
10416
|
+
// cleanupFn?.();
|
|
10417
|
+
// }
|
|
10418
|
+
// this.docsObservers.set(doc, onCleanup);
|
|
10419
|
+
// }
|
|
10420
|
+
// observerAttachedToShadow(shadowRoot: ShadowRoot, onCleanup: VoidFunction) {
|
|
10421
|
+
// if (!this.usable) return;
|
|
10422
|
+
// debugLog('[shadow] attaching observer to shadowRoot', shadowRoot);
|
|
10423
|
+
// if (this.shadowRootsObserved.has(shadowRoot)) {
|
|
10424
|
+
// debugLog('[shadow] detected existing observer, cleaning up old observer');
|
|
10425
|
+
// const cleanupFn = this.shadowRootsObserved.get(shadowRoot);
|
|
10426
|
+
// cleanupFn?.();
|
|
10427
|
+
// }
|
|
10428
|
+
// this.shadowRootsObserved.set(shadowRoot, onCleanup);
|
|
10429
|
+
// }
|
|
10325
10430
|
destroy() {
|
|
10326
|
-
this.docsObservers = /* @__PURE__ */ new
|
|
10327
|
-
this.
|
|
10431
|
+
this.docsObservers = /* @__PURE__ */ new WeakSet();
|
|
10432
|
+
this.shadowRootsObservers = /* @__PURE__ */ new WeakSet();
|
|
10328
10433
|
}
|
|
10329
10434
|
};
|
|
10330
10435
|
__publicField(_ObserveManager, "instance");
|
|
@@ -12881,11 +12986,10 @@ class ShadowDomManager {
|
|
|
12881
12986
|
}
|
|
12882
12987
|
addShadowRoot(shadowRoot2, doc) {
|
|
12883
12988
|
if (!isNativeShadowDom(shadowRoot2)) return;
|
|
12884
|
-
if (!observeManager.
|
|
12989
|
+
if (!observeManager.onShadowRootObserver(shadowRoot2)) return;
|
|
12885
12990
|
if (this.shadowDoms.has(shadowRoot2)) return;
|
|
12886
12991
|
this.shadowDoms.add(shadowRoot2);
|
|
12887
12992
|
debugLog(`Adding mutation observer for shadowRoot ${shadowRoot2.host}`);
|
|
12888
|
-
const observeId = makeid();
|
|
12889
12993
|
const observer = initMutationObserver(
|
|
12890
12994
|
{
|
|
12891
12995
|
...this.bypassOptions,
|
|
@@ -12896,8 +13000,8 @@ class ShadowDomManager {
|
|
|
12896
13000
|
},
|
|
12897
13001
|
shadowRoot2
|
|
12898
13002
|
);
|
|
12899
|
-
this.
|
|
12900
|
-
|
|
13003
|
+
this.restoreHandlers.push(() => observer.disconnect());
|
|
13004
|
+
this.restoreHandlers.push(
|
|
12901
13005
|
initScrollObserver({
|
|
12902
13006
|
...this.bypassOptions,
|
|
12903
13007
|
scrollCb: this.scrollCb,
|
|
@@ -12906,14 +13010,14 @@ class ShadowDomManager {
|
|
|
12906
13010
|
doc: shadowRoot2,
|
|
12907
13011
|
mirror: this.mirror
|
|
12908
13012
|
})
|
|
12909
|
-
|
|
13013
|
+
);
|
|
12910
13014
|
setTimeout(() => {
|
|
12911
13015
|
if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0)
|
|
12912
13016
|
this.bypassOptions.stylesheetManager.adoptStyleSheets(
|
|
12913
13017
|
shadowRoot2.adoptedStyleSheets,
|
|
12914
13018
|
this.mirror.getId(index$1.host(shadowRoot2))
|
|
12915
13019
|
);
|
|
12916
|
-
this.
|
|
13020
|
+
this.restoreHandlers.push(
|
|
12917
13021
|
initAdoptedStyleSheetObserver(
|
|
12918
13022
|
{
|
|
12919
13023
|
mirror: this.mirror,
|
|
@@ -12923,18 +13027,6 @@ class ShadowDomManager {
|
|
|
12923
13027
|
)
|
|
12924
13028
|
);
|
|
12925
13029
|
}, 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
|
-
});
|
|
12938
13030
|
}
|
|
12939
13031
|
/**
|
|
12940
13032
|
* Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
|
|
@@ -13286,6 +13378,29 @@ function record(options = {}) {
|
|
|
13286
13378
|
},
|
|
13287
13379
|
mirror
|
|
13288
13380
|
});
|
|
13381
|
+
observeManager.setEmitter(wrappedEmit);
|
|
13382
|
+
observeManager.setMutationOptions({
|
|
13383
|
+
blockClass,
|
|
13384
|
+
blockSelector,
|
|
13385
|
+
maskTextClass,
|
|
13386
|
+
maskTextSelector,
|
|
13387
|
+
inlineStylesheet,
|
|
13388
|
+
maskInputOptions,
|
|
13389
|
+
maskTextFn,
|
|
13390
|
+
maskInputFn,
|
|
13391
|
+
slimDOMOptions,
|
|
13392
|
+
dataURLOptions,
|
|
13393
|
+
canvasManager,
|
|
13394
|
+
stylesheetManager,
|
|
13395
|
+
shadowDomManager,
|
|
13396
|
+
recordCanvas,
|
|
13397
|
+
inlineImages,
|
|
13398
|
+
mirror,
|
|
13399
|
+
iframeManager,
|
|
13400
|
+
keepIframeSrcFn,
|
|
13401
|
+
mutationCb: wrappedMutationEmit,
|
|
13402
|
+
processedNodeManager
|
|
13403
|
+
});
|
|
13289
13404
|
takeFullSnapshot$1 = (isCheckout = false) => {
|
|
13290
13405
|
if (!recordDOM) {
|
|
13291
13406
|
return;
|
|
@@ -13487,14 +13602,8 @@ function record(options = {}) {
|
|
|
13487
13602
|
};
|
|
13488
13603
|
iframeManager.addLoadListener((iframeEl) => {
|
|
13489
13604
|
try {
|
|
13490
|
-
if (!observeManager.
|
|
13491
|
-
|
|
13492
|
-
const id = makeid();
|
|
13493
|
-
registeredHandlers[id] = stopObserve;
|
|
13494
|
-
observeManager.observerAttached(iframeEl.contentDocument, () => {
|
|
13495
|
-
stopObserve();
|
|
13496
|
-
delete registeredHandlers[id];
|
|
13497
|
-
});
|
|
13605
|
+
if (!observeManager.onDocObserver(iframeEl.contentDocument)) return;
|
|
13606
|
+
handlers.push(observe(iframeEl.contentDocument));
|
|
13498
13607
|
} catch (error) {
|
|
13499
13608
|
if (isDebug()) {
|
|
13500
13609
|
console.warn("internal error");
|