@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.js
CHANGED
|
@@ -1748,12 +1748,7 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
1748
1748
|
}
|
|
1749
1749
|
return false;
|
|
1750
1750
|
}
|
|
1751
|
-
const debugging = {
|
|
1752
|
-
index: 0,
|
|
1753
|
-
store: {}
|
|
1754
|
-
};
|
|
1755
1751
|
function serializeNodeWithId(n2, options) {
|
|
1756
|
-
const start = Date.now();
|
|
1757
1752
|
const {
|
|
1758
1753
|
doc,
|
|
1759
1754
|
mirror: mirror2,
|
|
@@ -1983,16 +1978,6 @@ function serializeNodeWithId(n2, options) {
|
|
|
1983
1978
|
stylesheetLoadTimeout
|
|
1984
1979
|
);
|
|
1985
1980
|
}
|
|
1986
|
-
debugging.index++;
|
|
1987
|
-
const took = Date.now() - start;
|
|
1988
|
-
if (!(n2.nodeName in debugging.store)) {
|
|
1989
|
-
debugging.store[n2.nodeName] = [];
|
|
1990
|
-
}
|
|
1991
|
-
debugging.store[n2.nodeName].push(took);
|
|
1992
|
-
if (debugging.index % 5e3 === 0) {
|
|
1993
|
-
debugging.index = 0;
|
|
1994
|
-
debugging.store = {};
|
|
1995
|
-
}
|
|
1996
1981
|
return serializedNode;
|
|
1997
1982
|
}
|
|
1998
1983
|
function snapshot(n2, options) {
|
|
@@ -10080,6 +10065,11 @@ class IframeManager {
|
|
|
10080
10065
|
window.addEventListener("message", this.handleMessage.bind(this));
|
|
10081
10066
|
}
|
|
10082
10067
|
}
|
|
10068
|
+
destroy() {
|
|
10069
|
+
this.iframes = /* @__PURE__ */ new WeakMap();
|
|
10070
|
+
this.crossOriginIframeMap = /* @__PURE__ */ new WeakMap();
|
|
10071
|
+
this.crossOriginIframeRootIdMap = /* @__PURE__ */ new WeakMap();
|
|
10072
|
+
}
|
|
10083
10073
|
addIframe(iframeEl) {
|
|
10084
10074
|
this.iframes.set(iframeEl, true);
|
|
10085
10075
|
if (iframeEl.contentWindow)
|
|
@@ -10291,155 +10281,45 @@ const _ObserveManager = class _ObserveManager2 {
|
|
|
10291
10281
|
constructor() {
|
|
10292
10282
|
__publicField(this, "docsObservers", /* @__PURE__ */ new WeakSet());
|
|
10293
10283
|
__publicField(this, "shadowRootsObservers", /* @__PURE__ */ new WeakSet());
|
|
10294
|
-
__publicField(this, "
|
|
10295
|
-
__publicField(this, "emitter", null);
|
|
10296
|
-
__publicField(this, "isSnapshottingShadowRoots", false);
|
|
10297
|
-
__publicField(this, "isSnapshottingDocs", false);
|
|
10284
|
+
__publicField(this, "docObservers", /* @__PURE__ */ new WeakMap());
|
|
10298
10285
|
if (_ObserveManager2.instance) {
|
|
10299
10286
|
return _ObserveManager2.instance;
|
|
10300
10287
|
}
|
|
10301
10288
|
_ObserveManager2.instance = this;
|
|
10302
10289
|
}
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
if (!result2) debugLog("observerManager: emitter is null");
|
|
10312
|
-
return result2;
|
|
10313
|
-
}
|
|
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;
|
|
10290
|
+
observeIframe(doc, init, cleanup) {
|
|
10291
|
+
const current = this.docObservers.get(doc);
|
|
10292
|
+
if (current) {
|
|
10293
|
+
debugLog(
|
|
10294
|
+
doc,
|
|
10295
|
+
"iframe is already observed, cleaning up and registering again"
|
|
10296
|
+
);
|
|
10297
|
+
current();
|
|
10327
10298
|
}
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
this.emitter({
|
|
10333
|
-
type: EventType.FullSnapshot,
|
|
10334
|
-
data: {
|
|
10335
|
-
node: serialized,
|
|
10336
|
-
initialOffset: {
|
|
10337
|
-
left: 0,
|
|
10338
|
-
top: 0
|
|
10339
|
-
}
|
|
10340
|
-
}
|
|
10299
|
+
const id = makeid();
|
|
10300
|
+
init(id);
|
|
10301
|
+
this.docObservers.set(doc, () => {
|
|
10302
|
+
cleanup(id);
|
|
10341
10303
|
});
|
|
10342
10304
|
}
|
|
10343
|
-
|
|
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.isSnapshottingDocs) return false;
|
|
10380
|
-
if (!this.usable) return false;
|
|
10305
|
+
canRegisterDocObserver(doc) {
|
|
10381
10306
|
if (!this.docsObservers.has(doc)) {
|
|
10382
10307
|
this.docsObservers.add(doc);
|
|
10383
10308
|
return true;
|
|
10384
10309
|
}
|
|
10385
|
-
debugLog(
|
|
10386
|
-
"onDocObserver: doc already observed, emitting full snapshot for doc",
|
|
10387
|
-
doc
|
|
10388
|
-
);
|
|
10389
|
-
this.isSnapshottingDocs = true;
|
|
10390
|
-
this.serializeAndEmitDoc(doc);
|
|
10391
|
-
this.isSnapshottingDocs = false;
|
|
10392
10310
|
return false;
|
|
10393
10311
|
}
|
|
10394
|
-
|
|
10395
|
-
if (this.isSnapshottingShadowRoots) return false;
|
|
10396
|
-
if (!this.usable) return false;
|
|
10312
|
+
canRegisterShadowRootObserver(shadowRoot2) {
|
|
10397
10313
|
if (!this.shadowRootsObservers.has(shadowRoot2)) {
|
|
10398
10314
|
this.shadowRootsObservers.add(shadowRoot2);
|
|
10399
10315
|
return true;
|
|
10400
10316
|
}
|
|
10401
|
-
debugLog(
|
|
10402
|
-
"onShadowRootObserver: shadowRoot already observed, emitting full snapshot for shadowRoot",
|
|
10403
|
-
shadowRoot2
|
|
10404
|
-
);
|
|
10405
|
-
this.isSnapshottingShadowRoots = true;
|
|
10406
|
-
this.serializeAndEmitShadowRoot(shadowRoot2);
|
|
10407
|
-
this.isSnapshottingShadowRoots = false;
|
|
10408
10317
|
return false;
|
|
10409
10318
|
}
|
|
10410
|
-
// canObserveDoc(doc: Document) {
|
|
10411
|
-
// if (!this.usable) return false;
|
|
10412
|
-
// const hasObserver = this.docsObservers.has(doc);
|
|
10413
|
-
// if (!hasObserver) return true;
|
|
10414
|
-
// return false;
|
|
10415
|
-
// }
|
|
10416
|
-
// canObserveShadowRoot(shadowRoot: ShadowRoot) {
|
|
10417
|
-
// if (!this.usable) return false;
|
|
10418
|
-
// return !this.shadowRootsObserved.has(shadowRoot);
|
|
10419
|
-
// }
|
|
10420
|
-
// observerAttached(doc: Document, onCleanup: VoidFunction) {
|
|
10421
|
-
// if (!this.usable) return;
|
|
10422
|
-
// debugLog('[doc] attaching observer to doc', doc);
|
|
10423
|
-
// if (this.docsObservers.has(doc)) {
|
|
10424
|
-
// debugLog('[doc] detected existing observer, cleaning up old observer');
|
|
10425
|
-
// const cleanupFn = this.docsObservers.get(doc);
|
|
10426
|
-
// cleanupFn?.();
|
|
10427
|
-
// }
|
|
10428
|
-
// this.docsObservers.set(doc, onCleanup);
|
|
10429
|
-
// }
|
|
10430
|
-
// observerAttachedToShadow(shadowRoot: ShadowRoot, onCleanup: VoidFunction) {
|
|
10431
|
-
// if (!this.usable) return;
|
|
10432
|
-
// debugLog('[shadow] attaching observer to shadowRoot', shadowRoot);
|
|
10433
|
-
// if (this.shadowRootsObserved.has(shadowRoot)) {
|
|
10434
|
-
// debugLog('[shadow] detected existing observer, cleaning up old observer');
|
|
10435
|
-
// const cleanupFn = this.shadowRootsObserved.get(shadowRoot);
|
|
10436
|
-
// cleanupFn?.();
|
|
10437
|
-
// }
|
|
10438
|
-
// this.shadowRootsObserved.set(shadowRoot, onCleanup);
|
|
10439
|
-
// }
|
|
10440
10319
|
destroy() {
|
|
10441
10320
|
this.docsObservers = /* @__PURE__ */ new WeakSet();
|
|
10442
10321
|
this.shadowRootsObservers = /* @__PURE__ */ new WeakSet();
|
|
10322
|
+
this.docObservers = /* @__PURE__ */ new WeakMap();
|
|
10443
10323
|
}
|
|
10444
10324
|
};
|
|
10445
10325
|
__publicField(_ObserveManager, "instance");
|
|
@@ -10451,7 +10331,7 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10451
10331
|
__publicField(this, "exitMutTracker");
|
|
10452
10332
|
__publicField(this, "interval", 50);
|
|
10453
10333
|
__publicField(this, "exitInterval", 100);
|
|
10454
|
-
__publicField(this, "mutThreshold",
|
|
10334
|
+
__publicField(this, "mutThreshold", 250);
|
|
10455
10335
|
__publicField(this, "inGlobalStorm", false);
|
|
10456
10336
|
__publicField(this, "currentStormStartedAt", -1);
|
|
10457
10337
|
__publicField(this, "stormTimeLimit", 5e3);
|
|
@@ -12983,7 +12863,6 @@ class ShadowDomManager {
|
|
|
12983
12863
|
__publicField(this, "bypassOptions");
|
|
12984
12864
|
__publicField(this, "mirror");
|
|
12985
12865
|
__publicField(this, "restoreHandlers", []);
|
|
12986
|
-
__publicField(this, "mappedRestoreHandlers", {});
|
|
12987
12866
|
this.mutationCb = options.mutationCb;
|
|
12988
12867
|
this.scrollCb = options.scrollCb;
|
|
12989
12868
|
this.bypassOptions = options.bypassOptions;
|
|
@@ -12996,10 +12875,15 @@ class ShadowDomManager {
|
|
|
12996
12875
|
}
|
|
12997
12876
|
addShadowRoot(shadowRoot2, doc) {
|
|
12998
12877
|
if (!isNativeShadowDom(shadowRoot2)) return;
|
|
12999
|
-
if (!observeManager.
|
|
12878
|
+
if (!observeManager.canRegisterShadowRootObserver(shadowRoot2)) return;
|
|
13000
12879
|
if (this.shadowDoms.has(shadowRoot2)) return;
|
|
13001
12880
|
this.shadowDoms.add(shadowRoot2);
|
|
13002
|
-
debugLog(
|
|
12881
|
+
debugLog(
|
|
12882
|
+
`Adding mutation observer for shadowRoot`,
|
|
12883
|
+
shadowRoot2.host,
|
|
12884
|
+
"restoreHandlers",
|
|
12885
|
+
this.restoreHandlers.length
|
|
12886
|
+
);
|
|
13003
12887
|
const observer = initMutationObserver(
|
|
13004
12888
|
{
|
|
13005
12889
|
...this.bypassOptions,
|
|
@@ -13076,15 +12960,6 @@ class ShadowDomManager {
|
|
|
13076
12960
|
} catch (e2) {
|
|
13077
12961
|
}
|
|
13078
12962
|
});
|
|
13079
|
-
Object.values(this.mappedRestoreHandlers).forEach((handlers) => {
|
|
13080
|
-
for (const handler of handlers) {
|
|
13081
|
-
try {
|
|
13082
|
-
handler();
|
|
13083
|
-
} catch (e2) {
|
|
13084
|
-
}
|
|
13085
|
-
}
|
|
13086
|
-
});
|
|
13087
|
-
this.mappedRestoreHandlers = {};
|
|
13088
12963
|
this.restoreHandlers = [];
|
|
13089
12964
|
this.shadowDoms = /* @__PURE__ */ new WeakSet();
|
|
13090
12965
|
}
|
|
@@ -13270,10 +13145,10 @@ function record(options = {}) {
|
|
|
13270
13145
|
}
|
|
13271
13146
|
return e2;
|
|
13272
13147
|
};
|
|
13273
|
-
wrappedEmit = (r2, isCheckout) => {
|
|
13148
|
+
wrappedEmit = (r2, isCheckout, customOpts) => {
|
|
13274
13149
|
var _a2;
|
|
13275
13150
|
const e2 = r2;
|
|
13276
|
-
e2.timestamp = nowTimestamp();
|
|
13151
|
+
e2.timestamp = (customOpts == null ? void 0 : customOpts.overrideTimestamp) ?? nowTimestamp();
|
|
13277
13152
|
if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
|
|
13278
13153
|
mutationBuffers.forEach((buf) => buf.unfreeze());
|
|
13279
13154
|
}
|
|
@@ -13388,29 +13263,6 @@ function record(options = {}) {
|
|
|
13388
13263
|
},
|
|
13389
13264
|
mirror
|
|
13390
13265
|
});
|
|
13391
|
-
observeManager.setEmitter(wrappedEmit);
|
|
13392
|
-
observeManager.setMutationOptions({
|
|
13393
|
-
blockClass,
|
|
13394
|
-
blockSelector,
|
|
13395
|
-
maskTextClass,
|
|
13396
|
-
maskTextSelector,
|
|
13397
|
-
inlineStylesheet,
|
|
13398
|
-
maskInputOptions,
|
|
13399
|
-
maskTextFn,
|
|
13400
|
-
maskInputFn,
|
|
13401
|
-
slimDOMOptions,
|
|
13402
|
-
dataURLOptions,
|
|
13403
|
-
canvasManager,
|
|
13404
|
-
stylesheetManager,
|
|
13405
|
-
shadowDomManager,
|
|
13406
|
-
recordCanvas,
|
|
13407
|
-
inlineImages,
|
|
13408
|
-
mirror,
|
|
13409
|
-
iframeManager,
|
|
13410
|
-
keepIframeSrcFn,
|
|
13411
|
-
mutationCb: wrappedMutationEmit,
|
|
13412
|
-
processedNodeManager
|
|
13413
|
-
});
|
|
13414
13266
|
takeFullSnapshot$1 = (isCheckout = false) => {
|
|
13415
13267
|
if (!recordDOM) {
|
|
13416
13268
|
return;
|
|
@@ -13486,7 +13338,6 @@ function record(options = {}) {
|
|
|
13486
13338
|
};
|
|
13487
13339
|
try {
|
|
13488
13340
|
const handlers = [];
|
|
13489
|
-
const registeredHandlers = {};
|
|
13490
13341
|
const observe = (doc) => {
|
|
13491
13342
|
var _a2;
|
|
13492
13343
|
return callbackWrapper(initObservers)(
|
|
@@ -13610,11 +13461,31 @@ function record(options = {}) {
|
|
|
13610
13461
|
hooks
|
|
13611
13462
|
);
|
|
13612
13463
|
};
|
|
13464
|
+
const registeredHandlers = {};
|
|
13613
13465
|
iframeManager.addLoadListener((iframeEl) => {
|
|
13614
13466
|
try {
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13467
|
+
observeManager.observeIframe(
|
|
13468
|
+
iframeEl.contentDocument,
|
|
13469
|
+
(id) => {
|
|
13470
|
+
const cleanup = observe(iframeEl.contentDocument);
|
|
13471
|
+
registeredHandlers[id] = cleanup;
|
|
13472
|
+
debugLog(
|
|
13473
|
+
iframeEl.contentDocument,
|
|
13474
|
+
"did register handler on iframe. current registered handlers",
|
|
13475
|
+
Object.keys(registeredHandlers).length
|
|
13476
|
+
);
|
|
13477
|
+
},
|
|
13478
|
+
(id) => {
|
|
13479
|
+
const handler = registeredHandlers[id];
|
|
13480
|
+
if (handler) handler();
|
|
13481
|
+
delete registeredHandlers[id];
|
|
13482
|
+
debugLog(
|
|
13483
|
+
iframeEl.contentDocument,
|
|
13484
|
+
"did cleanup for regisited handler on iframe. current registered handlers",
|
|
13485
|
+
Object.keys(registeredHandlers).length
|
|
13486
|
+
);
|
|
13487
|
+
}
|
|
13488
|
+
);
|
|
13618
13489
|
} catch (error) {
|
|
13619
13490
|
if (isDebug()) {
|
|
13620
13491
|
console.warn("internal error");
|
|
@@ -13675,6 +13546,7 @@ function record(options = {}) {
|
|
|
13675
13546
|
handlers.forEach((h) => h());
|
|
13676
13547
|
Object.values(registeredHandlers).forEach((h) => h());
|
|
13677
13548
|
processedNodeManager.destroy();
|
|
13549
|
+
iframeManager.destroy();
|
|
13678
13550
|
observeManager.destroy();
|
|
13679
13551
|
recording = false;
|
|
13680
13552
|
unregisterErrorHandler();
|