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