@glimt/record 0.0.75 → 0.0.76
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 +156 -49
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +156 -49
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +155 -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,143 @@ 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 WeakMap());
|
|
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;
|
|
10324
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
|
+
debugLog(
|
|
10382
|
+
"onDocObserver: doc already observed, emitting full snapshot for doc",
|
|
10383
|
+
doc
|
|
10384
|
+
);
|
|
10385
|
+
this.serializeAndEmitDoc(doc);
|
|
10386
|
+
return false;
|
|
10387
|
+
}
|
|
10388
|
+
onShadowRootObserver(shadowRoot2) {
|
|
10389
|
+
if (!this.usable) return false;
|
|
10390
|
+
if (!this.shadowRootsObservers.has(shadowRoot2)) return true;
|
|
10391
|
+
debugLog(
|
|
10392
|
+
"onShadowRootObserver: shadowRoot already observed, emitting full snapshot for shadowRoot",
|
|
10393
|
+
shadowRoot2
|
|
10394
|
+
);
|
|
10395
|
+
this.serializeAndEmitShadowRoot(shadowRoot2);
|
|
10396
|
+
return false;
|
|
10397
|
+
}
|
|
10398
|
+
// canObserveDoc(doc: Document) {
|
|
10399
|
+
// if (!this.usable) return false;
|
|
10400
|
+
// const hasObserver = this.docsObservers.has(doc);
|
|
10401
|
+
// if (!hasObserver) return true;
|
|
10402
|
+
// return false;
|
|
10403
|
+
// }
|
|
10404
|
+
// canObserveShadowRoot(shadowRoot: ShadowRoot) {
|
|
10405
|
+
// if (!this.usable) return false;
|
|
10406
|
+
// return !this.shadowRootsObserved.has(shadowRoot);
|
|
10407
|
+
// }
|
|
10408
|
+
// observerAttached(doc: Document, onCleanup: VoidFunction) {
|
|
10409
|
+
// if (!this.usable) return;
|
|
10410
|
+
// debugLog('[doc] attaching observer to doc', doc);
|
|
10411
|
+
// if (this.docsObservers.has(doc)) {
|
|
10412
|
+
// debugLog('[doc] detected existing observer, cleaning up old observer');
|
|
10413
|
+
// const cleanupFn = this.docsObservers.get(doc);
|
|
10414
|
+
// cleanupFn?.();
|
|
10415
|
+
// }
|
|
10416
|
+
// this.docsObservers.set(doc, onCleanup);
|
|
10417
|
+
// }
|
|
10418
|
+
// observerAttachedToShadow(shadowRoot: ShadowRoot, onCleanup: VoidFunction) {
|
|
10419
|
+
// if (!this.usable) return;
|
|
10420
|
+
// debugLog('[shadow] attaching observer to shadowRoot', shadowRoot);
|
|
10421
|
+
// if (this.shadowRootsObserved.has(shadowRoot)) {
|
|
10422
|
+
// debugLog('[shadow] detected existing observer, cleaning up old observer');
|
|
10423
|
+
// const cleanupFn = this.shadowRootsObserved.get(shadowRoot);
|
|
10424
|
+
// cleanupFn?.();
|
|
10425
|
+
// }
|
|
10426
|
+
// this.shadowRootsObserved.set(shadowRoot, onCleanup);
|
|
10427
|
+
// }
|
|
10325
10428
|
destroy() {
|
|
10326
|
-
this.docsObservers = /* @__PURE__ */ new
|
|
10327
|
-
this.
|
|
10429
|
+
this.docsObservers = /* @__PURE__ */ new WeakSet();
|
|
10430
|
+
this.shadowRootsObservers = /* @__PURE__ */ new WeakMap();
|
|
10328
10431
|
}
|
|
10329
10432
|
};
|
|
10330
10433
|
__publicField(_ObserveManager, "instance");
|
|
@@ -12881,11 +12984,10 @@ class ShadowDomManager {
|
|
|
12881
12984
|
}
|
|
12882
12985
|
addShadowRoot(shadowRoot2, doc) {
|
|
12883
12986
|
if (!isNativeShadowDom(shadowRoot2)) return;
|
|
12884
|
-
if (!observeManager.
|
|
12987
|
+
if (!observeManager.onShadowRootObserver(shadowRoot2)) return;
|
|
12885
12988
|
if (this.shadowDoms.has(shadowRoot2)) return;
|
|
12886
12989
|
this.shadowDoms.add(shadowRoot2);
|
|
12887
12990
|
debugLog(`Adding mutation observer for shadowRoot ${shadowRoot2.host}`);
|
|
12888
|
-
const observeId = makeid();
|
|
12889
12991
|
const observer = initMutationObserver(
|
|
12890
12992
|
{
|
|
12891
12993
|
...this.bypassOptions,
|
|
@@ -12896,8 +12998,8 @@ class ShadowDomManager {
|
|
|
12896
12998
|
},
|
|
12897
12999
|
shadowRoot2
|
|
12898
13000
|
);
|
|
12899
|
-
this.
|
|
12900
|
-
|
|
13001
|
+
this.restoreHandlers.push(() => observer.disconnect());
|
|
13002
|
+
this.restoreHandlers.push(
|
|
12901
13003
|
initScrollObserver({
|
|
12902
13004
|
...this.bypassOptions,
|
|
12903
13005
|
scrollCb: this.scrollCb,
|
|
@@ -12906,14 +13008,14 @@ class ShadowDomManager {
|
|
|
12906
13008
|
doc: shadowRoot2,
|
|
12907
13009
|
mirror: this.mirror
|
|
12908
13010
|
})
|
|
12909
|
-
|
|
13011
|
+
);
|
|
12910
13012
|
setTimeout(() => {
|
|
12911
13013
|
if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0)
|
|
12912
13014
|
this.bypassOptions.stylesheetManager.adoptStyleSheets(
|
|
12913
13015
|
shadowRoot2.adoptedStyleSheets,
|
|
12914
13016
|
this.mirror.getId(index$1.host(shadowRoot2))
|
|
12915
13017
|
);
|
|
12916
|
-
this.
|
|
13018
|
+
this.restoreHandlers.push(
|
|
12917
13019
|
initAdoptedStyleSheetObserver(
|
|
12918
13020
|
{
|
|
12919
13021
|
mirror: this.mirror,
|
|
@@ -12923,18 +13025,6 @@ class ShadowDomManager {
|
|
|
12923
13025
|
)
|
|
12924
13026
|
);
|
|
12925
13027
|
}, 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
13028
|
}
|
|
12939
13029
|
/**
|
|
12940
13030
|
* Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
|
|
@@ -13286,6 +13376,29 @@ function record(options = {}) {
|
|
|
13286
13376
|
},
|
|
13287
13377
|
mirror
|
|
13288
13378
|
});
|
|
13379
|
+
observeManager.setEmitter(wrappedEmit);
|
|
13380
|
+
observeManager.setMutationOptions({
|
|
13381
|
+
blockClass,
|
|
13382
|
+
blockSelector,
|
|
13383
|
+
maskTextClass,
|
|
13384
|
+
maskTextSelector,
|
|
13385
|
+
inlineStylesheet,
|
|
13386
|
+
maskInputOptions,
|
|
13387
|
+
maskTextFn,
|
|
13388
|
+
maskInputFn,
|
|
13389
|
+
slimDOMOptions,
|
|
13390
|
+
dataURLOptions,
|
|
13391
|
+
canvasManager,
|
|
13392
|
+
stylesheetManager,
|
|
13393
|
+
shadowDomManager,
|
|
13394
|
+
recordCanvas,
|
|
13395
|
+
inlineImages,
|
|
13396
|
+
mirror,
|
|
13397
|
+
iframeManager,
|
|
13398
|
+
keepIframeSrcFn,
|
|
13399
|
+
mutationCb: wrappedMutationEmit,
|
|
13400
|
+
processedNodeManager
|
|
13401
|
+
});
|
|
13289
13402
|
takeFullSnapshot$1 = (isCheckout = false) => {
|
|
13290
13403
|
if (!recordDOM) {
|
|
13291
13404
|
return;
|
|
@@ -13487,14 +13600,8 @@ function record(options = {}) {
|
|
|
13487
13600
|
};
|
|
13488
13601
|
iframeManager.addLoadListener((iframeEl) => {
|
|
13489
13602
|
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
|
-
});
|
|
13603
|
+
if (!observeManager.onDocObserver(iframeEl.contentDocument)) return;
|
|
13604
|
+
handlers.push(observe(iframeEl.contentDocument));
|
|
13498
13605
|
} catch (error) {
|
|
13499
13606
|
if (isDebug()) {
|
|
13500
13607
|
console.warn("internal error");
|