@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.js
CHANGED
|
@@ -10289,40 +10289,145 @@ class IframeManager {
|
|
|
10289
10289
|
}
|
|
10290
10290
|
const _ObserveManager = class _ObserveManager2 {
|
|
10291
10291
|
constructor() {
|
|
10292
|
-
__publicField(this, "docsObservers", /* @__PURE__ */ new
|
|
10293
|
-
__publicField(this, "
|
|
10292
|
+
__publicField(this, "docsObservers", /* @__PURE__ */ new WeakSet());
|
|
10293
|
+
__publicField(this, "shadowRootsObservers", /* @__PURE__ */ new WeakSet());
|
|
10294
|
+
__publicField(this, "mutationOptions");
|
|
10295
|
+
__publicField(this, "emitter", null);
|
|
10294
10296
|
if (_ObserveManager2.instance) {
|
|
10295
10297
|
return _ObserveManager2.instance;
|
|
10296
10298
|
}
|
|
10297
10299
|
_ObserveManager2.instance = this;
|
|
10298
10300
|
}
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
+
setEmitter(emitter) {
|
|
10302
|
+
this.emitter = emitter;
|
|
10301
10303
|
}
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
+
setMutationOptions(options) {
|
|
10305
|
+
this.mutationOptions = options;
|
|
10304
10306
|
}
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
if (
|
|
10308
|
-
|
|
10309
|
-
const cleanupFn = this.docsObservers.get(doc);
|
|
10310
|
-
cleanupFn == null ? void 0 : cleanupFn();
|
|
10311
|
-
}
|
|
10312
|
-
this.docsObservers.set(doc, onCleanup);
|
|
10307
|
+
get usable() {
|
|
10308
|
+
const result2 = this.emitter != null;
|
|
10309
|
+
if (!result2) debugLog("observerManager: emitter is null");
|
|
10310
|
+
return result2;
|
|
10313
10311
|
}
|
|
10314
|
-
|
|
10315
|
-
|
|
10316
|
-
if (this.
|
|
10317
|
-
|
|
10318
|
-
|
|
10319
|
-
|
|
10312
|
+
serializeDoc(doc) {
|
|
10313
|
+
var _a2, _b2, _c;
|
|
10314
|
+
if (!((_a2 = this.mutationOptions) == null ? void 0 : _a2.mirror)) return null;
|
|
10315
|
+
const serialized = serializeNodeWithId(doc, {
|
|
10316
|
+
...this.mutationOptions,
|
|
10317
|
+
doc,
|
|
10318
|
+
skipChild: false,
|
|
10319
|
+
maskTextFn: (_b2 = this.mutationOptions) == null ? void 0 : _b2.maskTextFn,
|
|
10320
|
+
maskInputFn: (_c = this.mutationOptions) == null ? void 0 : _c.maskInputFn
|
|
10321
|
+
});
|
|
10322
|
+
if (!serialized) {
|
|
10323
|
+
debugLog("snapshotDoc: no serialized node");
|
|
10324
|
+
return null;
|
|
10320
10325
|
}
|
|
10321
|
-
|
|
10326
|
+
return serialized;
|
|
10327
|
+
}
|
|
10328
|
+
emitDoc(serialized) {
|
|
10329
|
+
if (!this.emitter || !serialized) return;
|
|
10330
|
+
this.emitter({
|
|
10331
|
+
type: EventType.FullSnapshot,
|
|
10332
|
+
data: {
|
|
10333
|
+
node: serialized,
|
|
10334
|
+
initialOffset: {
|
|
10335
|
+
left: 0,
|
|
10336
|
+
top: 0
|
|
10337
|
+
}
|
|
10338
|
+
}
|
|
10339
|
+
});
|
|
10340
|
+
}
|
|
10341
|
+
emitShadowRoot(serialized, shadowRoot2) {
|
|
10342
|
+
var _a2;
|
|
10343
|
+
if (!this.emitter || !serialized || !((_a2 = this.mutationOptions) == null ? void 0 : _a2.mirror)) return;
|
|
10344
|
+
const hostId = this.mutationOptions.mirror.getId(shadowRoot2.host);
|
|
10345
|
+
const shadowId = this.mutationOptions.mirror.getId(shadowRoot2);
|
|
10346
|
+
this.emitter({
|
|
10347
|
+
type: EventType.IncrementalSnapshot,
|
|
10348
|
+
data: {
|
|
10349
|
+
source: IncrementalSource.Mutation,
|
|
10350
|
+
adds: [
|
|
10351
|
+
{
|
|
10352
|
+
parentId: hostId,
|
|
10353
|
+
nextId: null,
|
|
10354
|
+
node: serialized
|
|
10355
|
+
}
|
|
10356
|
+
],
|
|
10357
|
+
removes: [
|
|
10358
|
+
{
|
|
10359
|
+
id: shadowId,
|
|
10360
|
+
parentId: hostId
|
|
10361
|
+
}
|
|
10362
|
+
],
|
|
10363
|
+
attributes: [],
|
|
10364
|
+
texts: []
|
|
10365
|
+
}
|
|
10366
|
+
});
|
|
10367
|
+
}
|
|
10368
|
+
serializeAndEmitDoc(doc) {
|
|
10369
|
+
const serialized = this.serializeDoc(doc);
|
|
10370
|
+
this.emitDoc(serialized);
|
|
10371
|
+
}
|
|
10372
|
+
serializeAndEmitShadowRoot(shadowRoot2) {
|
|
10373
|
+
const serialized = this.serializeDoc(shadowRoot2.ownerDocument);
|
|
10374
|
+
this.emitShadowRoot(serialized, shadowRoot2);
|
|
10375
|
+
}
|
|
10376
|
+
onDocObserver(doc) {
|
|
10377
|
+
if (!this.usable) return false;
|
|
10378
|
+
if (!this.docsObservers.has(doc)) return true;
|
|
10379
|
+
this.docsObservers.add(doc);
|
|
10380
|
+
debugLog(
|
|
10381
|
+
"onDocObserver: doc already observed, emitting full snapshot for doc",
|
|
10382
|
+
doc
|
|
10383
|
+
);
|
|
10384
|
+
this.serializeAndEmitDoc(doc);
|
|
10385
|
+
return false;
|
|
10386
|
+
}
|
|
10387
|
+
onShadowRootObserver(shadowRoot2) {
|
|
10388
|
+
if (!this.usable) return false;
|
|
10389
|
+
if (!this.shadowRootsObservers.has(shadowRoot2)) return true;
|
|
10390
|
+
this.shadowRootsObservers.add(shadowRoot2);
|
|
10391
|
+
debugLog(
|
|
10392
|
+
"onShadowRootObserver: shadowRoot already observed, emitting full snapshot for shadowRoot",
|
|
10393
|
+
shadowRoot2
|
|
10394
|
+
);
|
|
10395
|
+
this.serializeAndEmitShadowRoot(shadowRoot2);
|
|
10396
|
+
return false;
|
|
10322
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
|
+
// }
|
|
10323
10428
|
destroy() {
|
|
10324
|
-
this.docsObservers = /* @__PURE__ */ new
|
|
10325
|
-
this.
|
|
10429
|
+
this.docsObservers = /* @__PURE__ */ new WeakSet();
|
|
10430
|
+
this.shadowRootsObservers = /* @__PURE__ */ new WeakSet();
|
|
10326
10431
|
}
|
|
10327
10432
|
};
|
|
10328
10433
|
__publicField(_ObserveManager, "instance");
|
|
@@ -12879,11 +12984,10 @@ class ShadowDomManager {
|
|
|
12879
12984
|
}
|
|
12880
12985
|
addShadowRoot(shadowRoot2, doc) {
|
|
12881
12986
|
if (!isNativeShadowDom(shadowRoot2)) return;
|
|
12882
|
-
if (!observeManager.
|
|
12987
|
+
if (!observeManager.onShadowRootObserver(shadowRoot2)) return;
|
|
12883
12988
|
if (this.shadowDoms.has(shadowRoot2)) return;
|
|
12884
12989
|
this.shadowDoms.add(shadowRoot2);
|
|
12885
12990
|
debugLog(`Adding mutation observer for shadowRoot ${shadowRoot2.host}`);
|
|
12886
|
-
const observeId = makeid();
|
|
12887
12991
|
const observer = initMutationObserver(
|
|
12888
12992
|
{
|
|
12889
12993
|
...this.bypassOptions,
|
|
@@ -12894,8 +12998,8 @@ class ShadowDomManager {
|
|
|
12894
12998
|
},
|
|
12895
12999
|
shadowRoot2
|
|
12896
13000
|
);
|
|
12897
|
-
this.
|
|
12898
|
-
|
|
13001
|
+
this.restoreHandlers.push(() => observer.disconnect());
|
|
13002
|
+
this.restoreHandlers.push(
|
|
12899
13003
|
initScrollObserver({
|
|
12900
13004
|
...this.bypassOptions,
|
|
12901
13005
|
scrollCb: this.scrollCb,
|
|
@@ -12904,14 +13008,14 @@ class ShadowDomManager {
|
|
|
12904
13008
|
doc: shadowRoot2,
|
|
12905
13009
|
mirror: this.mirror
|
|
12906
13010
|
})
|
|
12907
|
-
|
|
13011
|
+
);
|
|
12908
13012
|
setTimeout(() => {
|
|
12909
13013
|
if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0)
|
|
12910
13014
|
this.bypassOptions.stylesheetManager.adoptStyleSheets(
|
|
12911
13015
|
shadowRoot2.adoptedStyleSheets,
|
|
12912
13016
|
this.mirror.getId(index$1.host(shadowRoot2))
|
|
12913
13017
|
);
|
|
12914
|
-
this.
|
|
13018
|
+
this.restoreHandlers.push(
|
|
12915
13019
|
initAdoptedStyleSheetObserver(
|
|
12916
13020
|
{
|
|
12917
13021
|
mirror: this.mirror,
|
|
@@ -12921,18 +13025,6 @@ class ShadowDomManager {
|
|
|
12921
13025
|
)
|
|
12922
13026
|
);
|
|
12923
13027
|
}, 0);
|
|
12924
|
-
observeManager.observerAttachedToShadow(shadowRoot2, () => {
|
|
12925
|
-
const handlers = this.mappedRestoreHandlers[observeId];
|
|
12926
|
-
if (handlers) {
|
|
12927
|
-
for (const handler of handlers) {
|
|
12928
|
-
try {
|
|
12929
|
-
handler();
|
|
12930
|
-
} catch (e2) {
|
|
12931
|
-
}
|
|
12932
|
-
}
|
|
12933
|
-
}
|
|
12934
|
-
delete this.mappedRestoreHandlers[observeId];
|
|
12935
|
-
});
|
|
12936
13028
|
}
|
|
12937
13029
|
/**
|
|
12938
13030
|
* Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
|
|
@@ -13284,6 +13376,29 @@ function record(options = {}) {
|
|
|
13284
13376
|
},
|
|
13285
13377
|
mirror
|
|
13286
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
|
+
});
|
|
13287
13402
|
takeFullSnapshot$1 = (isCheckout = false) => {
|
|
13288
13403
|
if (!recordDOM) {
|
|
13289
13404
|
return;
|
|
@@ -13485,14 +13600,8 @@ function record(options = {}) {
|
|
|
13485
13600
|
};
|
|
13486
13601
|
iframeManager.addLoadListener((iframeEl) => {
|
|
13487
13602
|
try {
|
|
13488
|
-
if (!observeManager.
|
|
13489
|
-
|
|
13490
|
-
const id = makeid();
|
|
13491
|
-
registeredHandlers[id] = stopObserve;
|
|
13492
|
-
observeManager.observerAttached(iframeEl.contentDocument, () => {
|
|
13493
|
-
stopObserve();
|
|
13494
|
-
delete registeredHandlers[id];
|
|
13495
|
-
});
|
|
13603
|
+
if (!observeManager.onDocObserver(iframeEl.contentDocument)) return;
|
|
13604
|
+
handlers.push(observe(iframeEl.contentDocument));
|
|
13496
13605
|
} catch (error) {
|
|
13497
13606
|
if (isDebug()) {
|
|
13498
13607
|
console.warn("internal error");
|