@glimt/record 0.0.79 → 0.0.81
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 +55 -183
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +55 -183
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +56 -182
- 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
|
@@ -1750,12 +1750,7 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
1750
1750
|
}
|
|
1751
1751
|
return false;
|
|
1752
1752
|
}
|
|
1753
|
-
const debugging = {
|
|
1754
|
-
index: 0,
|
|
1755
|
-
store: {}
|
|
1756
|
-
};
|
|
1757
1753
|
function serializeNodeWithId(n2, options) {
|
|
1758
|
-
const start = Date.now();
|
|
1759
1754
|
const {
|
|
1760
1755
|
doc,
|
|
1761
1756
|
mirror: mirror2,
|
|
@@ -1985,16 +1980,6 @@ function serializeNodeWithId(n2, options) {
|
|
|
1985
1980
|
stylesheetLoadTimeout
|
|
1986
1981
|
);
|
|
1987
1982
|
}
|
|
1988
|
-
debugging.index++;
|
|
1989
|
-
const took = Date.now() - start;
|
|
1990
|
-
if (!(n2.nodeName in debugging.store)) {
|
|
1991
|
-
debugging.store[n2.nodeName] = [];
|
|
1992
|
-
}
|
|
1993
|
-
debugging.store[n2.nodeName].push(took);
|
|
1994
|
-
if (debugging.index % 5e3 === 0) {
|
|
1995
|
-
debugging.index = 0;
|
|
1996
|
-
debugging.store = {};
|
|
1997
|
-
}
|
|
1998
1983
|
return serializedNode;
|
|
1999
1984
|
}
|
|
2000
1985
|
function snapshot(n2, options) {
|
|
@@ -10082,6 +10067,11 @@ class IframeManager {
|
|
|
10082
10067
|
window.addEventListener("message", this.handleMessage.bind(this));
|
|
10083
10068
|
}
|
|
10084
10069
|
}
|
|
10070
|
+
destroy() {
|
|
10071
|
+
this.iframes = /* @__PURE__ */ new WeakMap();
|
|
10072
|
+
this.crossOriginIframeMap = /* @__PURE__ */ new WeakMap();
|
|
10073
|
+
this.crossOriginIframeRootIdMap = /* @__PURE__ */ new WeakMap();
|
|
10074
|
+
}
|
|
10085
10075
|
addIframe(iframeEl) {
|
|
10086
10076
|
this.iframes.set(iframeEl, true);
|
|
10087
10077
|
if (iframeEl.contentWindow)
|
|
@@ -10293,155 +10283,45 @@ const _ObserveManager = class _ObserveManager2 {
|
|
|
10293
10283
|
constructor() {
|
|
10294
10284
|
__publicField(this, "docsObservers", /* @__PURE__ */ new WeakSet());
|
|
10295
10285
|
__publicField(this, "shadowRootsObservers", /* @__PURE__ */ new WeakSet());
|
|
10296
|
-
__publicField(this, "
|
|
10297
|
-
__publicField(this, "emitter", null);
|
|
10298
|
-
__publicField(this, "isSnapshottingShadowRoots", false);
|
|
10299
|
-
__publicField(this, "isSnapshottingDocs", false);
|
|
10286
|
+
__publicField(this, "docObservers", /* @__PURE__ */ new WeakMap());
|
|
10300
10287
|
if (_ObserveManager2.instance) {
|
|
10301
10288
|
return _ObserveManager2.instance;
|
|
10302
10289
|
}
|
|
10303
10290
|
_ObserveManager2.instance = this;
|
|
10304
10291
|
}
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
if (!result2) debugLog("observerManager: emitter is null");
|
|
10314
|
-
return result2;
|
|
10315
|
-
}
|
|
10316
|
-
serializeDoc(doc) {
|
|
10317
|
-
var _a2, _b2, _c;
|
|
10318
|
-
if (!((_a2 = this.mutationOptions) == null ? void 0 : _a2.mirror)) return null;
|
|
10319
|
-
const serialized = serializeNodeWithId(doc, {
|
|
10320
|
-
...this.mutationOptions,
|
|
10321
|
-
doc,
|
|
10322
|
-
skipChild: false,
|
|
10323
|
-
maskTextFn: (_b2 = this.mutationOptions) == null ? void 0 : _b2.maskTextFn,
|
|
10324
|
-
maskInputFn: (_c = this.mutationOptions) == null ? void 0 : _c.maskInputFn
|
|
10325
|
-
});
|
|
10326
|
-
if (!serialized) {
|
|
10327
|
-
debugLog("snapshotDoc: no serialized node");
|
|
10328
|
-
return null;
|
|
10292
|
+
observeIframe(doc, init, cleanup) {
|
|
10293
|
+
const current = this.docObservers.get(doc);
|
|
10294
|
+
if (current) {
|
|
10295
|
+
debugLog(
|
|
10296
|
+
doc,
|
|
10297
|
+
"iframe is already observed, cleaning up and registering again"
|
|
10298
|
+
);
|
|
10299
|
+
current();
|
|
10329
10300
|
}
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
this.emitter({
|
|
10335
|
-
type: EventType.FullSnapshot,
|
|
10336
|
-
data: {
|
|
10337
|
-
node: serialized,
|
|
10338
|
-
initialOffset: {
|
|
10339
|
-
left: 0,
|
|
10340
|
-
top: 0
|
|
10341
|
-
}
|
|
10342
|
-
}
|
|
10301
|
+
const id = makeid();
|
|
10302
|
+
init(id);
|
|
10303
|
+
this.docObservers.set(doc, () => {
|
|
10304
|
+
cleanup(id);
|
|
10343
10305
|
});
|
|
10344
10306
|
}
|
|
10345
|
-
|
|
10346
|
-
var _a2;
|
|
10347
|
-
if (!this.emitter || !serialized || !((_a2 = this.mutationOptions) == null ? void 0 : _a2.mirror)) return;
|
|
10348
|
-
const hostId = this.mutationOptions.mirror.getId(shadowRoot2.host);
|
|
10349
|
-
const shadowId = this.mutationOptions.mirror.getId(shadowRoot2);
|
|
10350
|
-
this.emitter({
|
|
10351
|
-
type: EventType.IncrementalSnapshot,
|
|
10352
|
-
data: {
|
|
10353
|
-
source: IncrementalSource.Mutation,
|
|
10354
|
-
adds: [
|
|
10355
|
-
{
|
|
10356
|
-
parentId: hostId,
|
|
10357
|
-
nextId: null,
|
|
10358
|
-
node: serialized
|
|
10359
|
-
}
|
|
10360
|
-
],
|
|
10361
|
-
removes: [
|
|
10362
|
-
{
|
|
10363
|
-
id: shadowId,
|
|
10364
|
-
parentId: hostId
|
|
10365
|
-
}
|
|
10366
|
-
],
|
|
10367
|
-
attributes: [],
|
|
10368
|
-
texts: []
|
|
10369
|
-
}
|
|
10370
|
-
});
|
|
10371
|
-
}
|
|
10372
|
-
serializeAndEmitDoc(doc) {
|
|
10373
|
-
const serialized = this.serializeDoc(doc);
|
|
10374
|
-
this.emitDoc(serialized);
|
|
10375
|
-
}
|
|
10376
|
-
serializeAndEmitShadowRoot(shadowRoot2) {
|
|
10377
|
-
const serialized = this.serializeDoc(shadowRoot2.ownerDocument);
|
|
10378
|
-
this.emitShadowRoot(serialized, shadowRoot2);
|
|
10379
|
-
}
|
|
10380
|
-
onDocObserver(doc) {
|
|
10381
|
-
if (this.isSnapshottingDocs) return false;
|
|
10382
|
-
if (!this.usable) return false;
|
|
10307
|
+
canRegisterDocObserver(doc) {
|
|
10383
10308
|
if (!this.docsObservers.has(doc)) {
|
|
10384
10309
|
this.docsObservers.add(doc);
|
|
10385
10310
|
return true;
|
|
10386
10311
|
}
|
|
10387
|
-
debugLog(
|
|
10388
|
-
"onDocObserver: doc already observed, emitting full snapshot for doc",
|
|
10389
|
-
doc
|
|
10390
|
-
);
|
|
10391
|
-
this.isSnapshottingDocs = true;
|
|
10392
|
-
this.serializeAndEmitDoc(doc);
|
|
10393
|
-
this.isSnapshottingDocs = false;
|
|
10394
10312
|
return false;
|
|
10395
10313
|
}
|
|
10396
|
-
|
|
10397
|
-
if (this.isSnapshottingShadowRoots) return false;
|
|
10398
|
-
if (!this.usable) return false;
|
|
10314
|
+
canRegisterShadowRootObserver(shadowRoot2) {
|
|
10399
10315
|
if (!this.shadowRootsObservers.has(shadowRoot2)) {
|
|
10400
10316
|
this.shadowRootsObservers.add(shadowRoot2);
|
|
10401
10317
|
return true;
|
|
10402
10318
|
}
|
|
10403
|
-
debugLog(
|
|
10404
|
-
"onShadowRootObserver: shadowRoot already observed, emitting full snapshot for shadowRoot",
|
|
10405
|
-
shadowRoot2
|
|
10406
|
-
);
|
|
10407
|
-
this.isSnapshottingShadowRoots = true;
|
|
10408
|
-
this.serializeAndEmitShadowRoot(shadowRoot2);
|
|
10409
|
-
this.isSnapshottingShadowRoots = false;
|
|
10410
10319
|
return false;
|
|
10411
10320
|
}
|
|
10412
|
-
// canObserveDoc(doc: Document) {
|
|
10413
|
-
// if (!this.usable) return false;
|
|
10414
|
-
// const hasObserver = this.docsObservers.has(doc);
|
|
10415
|
-
// if (!hasObserver) return true;
|
|
10416
|
-
// return false;
|
|
10417
|
-
// }
|
|
10418
|
-
// canObserveShadowRoot(shadowRoot: ShadowRoot) {
|
|
10419
|
-
// if (!this.usable) return false;
|
|
10420
|
-
// return !this.shadowRootsObserved.has(shadowRoot);
|
|
10421
|
-
// }
|
|
10422
|
-
// observerAttached(doc: Document, onCleanup: VoidFunction) {
|
|
10423
|
-
// if (!this.usable) return;
|
|
10424
|
-
// debugLog('[doc] attaching observer to doc', doc);
|
|
10425
|
-
// if (this.docsObservers.has(doc)) {
|
|
10426
|
-
// debugLog('[doc] detected existing observer, cleaning up old observer');
|
|
10427
|
-
// const cleanupFn = this.docsObservers.get(doc);
|
|
10428
|
-
// cleanupFn?.();
|
|
10429
|
-
// }
|
|
10430
|
-
// this.docsObservers.set(doc, onCleanup);
|
|
10431
|
-
// }
|
|
10432
|
-
// observerAttachedToShadow(shadowRoot: ShadowRoot, onCleanup: VoidFunction) {
|
|
10433
|
-
// if (!this.usable) return;
|
|
10434
|
-
// debugLog('[shadow] attaching observer to shadowRoot', shadowRoot);
|
|
10435
|
-
// if (this.shadowRootsObserved.has(shadowRoot)) {
|
|
10436
|
-
// debugLog('[shadow] detected existing observer, cleaning up old observer');
|
|
10437
|
-
// const cleanupFn = this.shadowRootsObserved.get(shadowRoot);
|
|
10438
|
-
// cleanupFn?.();
|
|
10439
|
-
// }
|
|
10440
|
-
// this.shadowRootsObserved.set(shadowRoot, onCleanup);
|
|
10441
|
-
// }
|
|
10442
10321
|
destroy() {
|
|
10443
10322
|
this.docsObservers = /* @__PURE__ */ new WeakSet();
|
|
10444
10323
|
this.shadowRootsObservers = /* @__PURE__ */ new WeakSet();
|
|
10324
|
+
this.docObservers = /* @__PURE__ */ new WeakMap();
|
|
10445
10325
|
}
|
|
10446
10326
|
};
|
|
10447
10327
|
__publicField(_ObserveManager, "instance");
|
|
@@ -10453,7 +10333,7 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10453
10333
|
__publicField(this, "exitMutTracker");
|
|
10454
10334
|
__publicField(this, "interval", 50);
|
|
10455
10335
|
__publicField(this, "exitInterval", 100);
|
|
10456
|
-
__publicField(this, "mutThreshold",
|
|
10336
|
+
__publicField(this, "mutThreshold", 250);
|
|
10457
10337
|
__publicField(this, "inGlobalStorm", false);
|
|
10458
10338
|
__publicField(this, "currentStormStartedAt", -1);
|
|
10459
10339
|
__publicField(this, "stormTimeLimit", 5e3);
|
|
@@ -12985,7 +12865,6 @@ class ShadowDomManager {
|
|
|
12985
12865
|
__publicField(this, "bypassOptions");
|
|
12986
12866
|
__publicField(this, "mirror");
|
|
12987
12867
|
__publicField(this, "restoreHandlers", []);
|
|
12988
|
-
__publicField(this, "mappedRestoreHandlers", {});
|
|
12989
12868
|
this.mutationCb = options.mutationCb;
|
|
12990
12869
|
this.scrollCb = options.scrollCb;
|
|
12991
12870
|
this.bypassOptions = options.bypassOptions;
|
|
@@ -12998,10 +12877,15 @@ class ShadowDomManager {
|
|
|
12998
12877
|
}
|
|
12999
12878
|
addShadowRoot(shadowRoot2, doc) {
|
|
13000
12879
|
if (!isNativeShadowDom(shadowRoot2)) return;
|
|
13001
|
-
if (!observeManager.
|
|
12880
|
+
if (!observeManager.canRegisterShadowRootObserver(shadowRoot2)) return;
|
|
13002
12881
|
if (this.shadowDoms.has(shadowRoot2)) return;
|
|
13003
12882
|
this.shadowDoms.add(shadowRoot2);
|
|
13004
|
-
debugLog(
|
|
12883
|
+
debugLog(
|
|
12884
|
+
`Adding mutation observer for shadowRoot`,
|
|
12885
|
+
shadowRoot2.host,
|
|
12886
|
+
"restoreHandlers",
|
|
12887
|
+
this.restoreHandlers.length
|
|
12888
|
+
);
|
|
13005
12889
|
const observer = initMutationObserver(
|
|
13006
12890
|
{
|
|
13007
12891
|
...this.bypassOptions,
|
|
@@ -13078,15 +12962,6 @@ class ShadowDomManager {
|
|
|
13078
12962
|
} catch (e2) {
|
|
13079
12963
|
}
|
|
13080
12964
|
});
|
|
13081
|
-
Object.values(this.mappedRestoreHandlers).forEach((handlers) => {
|
|
13082
|
-
for (const handler of handlers) {
|
|
13083
|
-
try {
|
|
13084
|
-
handler();
|
|
13085
|
-
} catch (e2) {
|
|
13086
|
-
}
|
|
13087
|
-
}
|
|
13088
|
-
});
|
|
13089
|
-
this.mappedRestoreHandlers = {};
|
|
13090
12965
|
this.restoreHandlers = [];
|
|
13091
12966
|
this.shadowDoms = /* @__PURE__ */ new WeakSet();
|
|
13092
12967
|
}
|
|
@@ -13272,10 +13147,10 @@ function record(options = {}) {
|
|
|
13272
13147
|
}
|
|
13273
13148
|
return e2;
|
|
13274
13149
|
};
|
|
13275
|
-
wrappedEmit = (r2, isCheckout) => {
|
|
13150
|
+
wrappedEmit = (r2, isCheckout, customOpts) => {
|
|
13276
13151
|
var _a2;
|
|
13277
13152
|
const e2 = r2;
|
|
13278
|
-
e2.timestamp = nowTimestamp();
|
|
13153
|
+
e2.timestamp = (customOpts == null ? void 0 : customOpts.overrideTimestamp) ?? nowTimestamp();
|
|
13279
13154
|
if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
|
|
13280
13155
|
mutationBuffers.forEach((buf) => buf.unfreeze());
|
|
13281
13156
|
}
|
|
@@ -13390,29 +13265,6 @@ function record(options = {}) {
|
|
|
13390
13265
|
},
|
|
13391
13266
|
mirror
|
|
13392
13267
|
});
|
|
13393
|
-
observeManager.setEmitter(wrappedEmit);
|
|
13394
|
-
observeManager.setMutationOptions({
|
|
13395
|
-
blockClass,
|
|
13396
|
-
blockSelector,
|
|
13397
|
-
maskTextClass,
|
|
13398
|
-
maskTextSelector,
|
|
13399
|
-
inlineStylesheet,
|
|
13400
|
-
maskInputOptions,
|
|
13401
|
-
maskTextFn,
|
|
13402
|
-
maskInputFn,
|
|
13403
|
-
slimDOMOptions,
|
|
13404
|
-
dataURLOptions,
|
|
13405
|
-
canvasManager,
|
|
13406
|
-
stylesheetManager,
|
|
13407
|
-
shadowDomManager,
|
|
13408
|
-
recordCanvas,
|
|
13409
|
-
inlineImages,
|
|
13410
|
-
mirror,
|
|
13411
|
-
iframeManager,
|
|
13412
|
-
keepIframeSrcFn,
|
|
13413
|
-
mutationCb: wrappedMutationEmit,
|
|
13414
|
-
processedNodeManager
|
|
13415
|
-
});
|
|
13416
13268
|
takeFullSnapshot$1 = (isCheckout = false) => {
|
|
13417
13269
|
if (!recordDOM) {
|
|
13418
13270
|
return;
|
|
@@ -13488,7 +13340,6 @@ function record(options = {}) {
|
|
|
13488
13340
|
};
|
|
13489
13341
|
try {
|
|
13490
13342
|
const handlers = [];
|
|
13491
|
-
const registeredHandlers = {};
|
|
13492
13343
|
const observe = (doc) => {
|
|
13493
13344
|
var _a2;
|
|
13494
13345
|
return callbackWrapper(initObservers)(
|
|
@@ -13612,11 +13463,31 @@ function record(options = {}) {
|
|
|
13612
13463
|
hooks
|
|
13613
13464
|
);
|
|
13614
13465
|
};
|
|
13466
|
+
const registeredHandlers = {};
|
|
13615
13467
|
iframeManager.addLoadListener((iframeEl) => {
|
|
13616
13468
|
try {
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13469
|
+
observeManager.observeIframe(
|
|
13470
|
+
iframeEl.contentDocument,
|
|
13471
|
+
(id) => {
|
|
13472
|
+
const cleanup = observe(iframeEl.contentDocument);
|
|
13473
|
+
registeredHandlers[id] = cleanup;
|
|
13474
|
+
debugLog(
|
|
13475
|
+
iframeEl.contentDocument,
|
|
13476
|
+
"did register handler on iframe. current registered handlers",
|
|
13477
|
+
Object.keys(registeredHandlers).length
|
|
13478
|
+
);
|
|
13479
|
+
},
|
|
13480
|
+
(id) => {
|
|
13481
|
+
const handler = registeredHandlers[id];
|
|
13482
|
+
if (handler) handler();
|
|
13483
|
+
delete registeredHandlers[id];
|
|
13484
|
+
debugLog(
|
|
13485
|
+
iframeEl.contentDocument,
|
|
13486
|
+
"did cleanup for regisited handler on iframe. current registered handlers",
|
|
13487
|
+
Object.keys(registeredHandlers).length
|
|
13488
|
+
);
|
|
13489
|
+
}
|
|
13490
|
+
);
|
|
13620
13491
|
} catch (error) {
|
|
13621
13492
|
if (isDebug()) {
|
|
13622
13493
|
console.warn("internal error");
|
|
@@ -13677,6 +13548,7 @@ function record(options = {}) {
|
|
|
13677
13548
|
handlers.forEach((h) => h());
|
|
13678
13549
|
Object.values(registeredHandlers).forEach((h) => h());
|
|
13679
13550
|
processedNodeManager.destroy();
|
|
13551
|
+
iframeManager.destroy();
|
|
13680
13552
|
observeManager.destroy();
|
|
13681
13553
|
recording = false;
|
|
13682
13554
|
unregisterErrorHandler();
|