@posthog/rrweb 0.0.24 → 0.0.26
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/rrweb.cjs +88 -19
- package/dist/rrweb.cjs.map +1 -1
- package/dist/rrweb.d.cts +7 -0
- package/dist/rrweb.d.ts +7 -0
- package/dist/rrweb.js +88 -19
- package/dist/rrweb.js.map +1 -1
- package/dist/rrweb.umd.cjs +86 -19
- package/dist/rrweb.umd.cjs.map +2 -2
- package/dist/rrweb.umd.min.cjs +38 -38
- package/dist/rrweb.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/rrweb.umd.cjs
CHANGED
|
@@ -284,8 +284,8 @@ function stringifyStylesheet(s2) {
|
|
|
284
284
|
return null;
|
|
285
285
|
}
|
|
286
286
|
let sheetHref = s2.href;
|
|
287
|
-
if (!sheetHref && s2.ownerNode
|
|
288
|
-
sheetHref = s2.ownerNode.
|
|
287
|
+
if (!sheetHref && s2.ownerNode) {
|
|
288
|
+
sheetHref = s2.ownerNode.baseURI;
|
|
289
289
|
}
|
|
290
290
|
const stringifiedRules = Array.from(
|
|
291
291
|
rules2,
|
|
@@ -5686,6 +5686,12 @@ function buildNodeWithSN(n2, options) {
|
|
|
5686
5686
|
} else {
|
|
5687
5687
|
node2.appendChild(childNode);
|
|
5688
5688
|
}
|
|
5689
|
+
} else if (n2.type === NodeType$1$1.Document && childN.type === NodeType$1$1.DocumentType) {
|
|
5690
|
+
if (node2.firstChild && node2.firstChild.nodeType === 1) {
|
|
5691
|
+
node2.insertBefore(childNode, node2.firstChild);
|
|
5692
|
+
} else {
|
|
5693
|
+
node2.appendChild(childNode);
|
|
5694
|
+
}
|
|
5689
5695
|
} else {
|
|
5690
5696
|
node2.appendChild(childNode);
|
|
5691
5697
|
}
|
|
@@ -13245,6 +13251,7 @@ function initObservers(o2, hooks = {}) {
|
|
|
13245
13251
|
selectionObserver();
|
|
13246
13252
|
customElementObserver();
|
|
13247
13253
|
pluginHandlers.forEach((h) => h());
|
|
13254
|
+
mutationBuffers.length = 0;
|
|
13248
13255
|
});
|
|
13249
13256
|
}
|
|
13250
13257
|
function hasNestedCSSRule(prop) {
|
|
@@ -13331,6 +13338,8 @@ class IframeManager {
|
|
|
13331
13338
|
__publicField(this, "loadListener");
|
|
13332
13339
|
__publicField(this, "stylesheetManager");
|
|
13333
13340
|
__publicField(this, "recordCrossOriginIframes");
|
|
13341
|
+
__publicField(this, "messageHandler");
|
|
13342
|
+
__publicField(this, "nestedIframeListeners", /* @__PURE__ */ new Map());
|
|
13334
13343
|
this.mutationCb = options.mutationCb;
|
|
13335
13344
|
this.wrappedEmit = options.wrappedEmit;
|
|
13336
13345
|
this.stylesheetManager = options.stylesheetManager;
|
|
@@ -13341,8 +13350,9 @@ class IframeManager {
|
|
|
13341
13350
|
)
|
|
13342
13351
|
);
|
|
13343
13352
|
this.mirror = options.mirror;
|
|
13353
|
+
this.messageHandler = this.handleMessage.bind(this);
|
|
13344
13354
|
if (this.recordCrossOriginIframes) {
|
|
13345
|
-
window.addEventListener("message", this.
|
|
13355
|
+
window.addEventListener("message", this.messageHandler);
|
|
13346
13356
|
}
|
|
13347
13357
|
}
|
|
13348
13358
|
addIframe(iframeEl) {
|
|
@@ -13354,7 +13364,7 @@ class IframeManager {
|
|
|
13354
13364
|
this.loadListener = cb;
|
|
13355
13365
|
}
|
|
13356
13366
|
attachIframe(iframeEl, childSn) {
|
|
13357
|
-
var _a2
|
|
13367
|
+
var _a2;
|
|
13358
13368
|
this.mutationCb({
|
|
13359
13369
|
adds: [
|
|
13360
13370
|
{
|
|
@@ -13368,12 +13378,13 @@ class IframeManager {
|
|
|
13368
13378
|
attributes: [],
|
|
13369
13379
|
isAttachIframe: true
|
|
13370
13380
|
});
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
);
|
|
13376
|
-
|
|
13381
|
+
const win = iframeEl.contentWindow;
|
|
13382
|
+
if (this.recordCrossOriginIframes && win && !this.nestedIframeListeners.has(win)) {
|
|
13383
|
+
const nestedHandler = this.handleMessage.bind(this);
|
|
13384
|
+
this.nestedIframeListeners.set(win, nestedHandler);
|
|
13385
|
+
win.addEventListener("message", nestedHandler);
|
|
13386
|
+
}
|
|
13387
|
+
(_a2 = this.loadListener) == null ? void 0 : _a2.call(this, iframeEl);
|
|
13377
13388
|
if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0)
|
|
13378
13389
|
this.stylesheetManager.adoptStyleSheets(
|
|
13379
13390
|
iframeEl.contentDocument.adoptedStyleSheets,
|
|
@@ -13551,6 +13562,15 @@ class IframeManager {
|
|
|
13551
13562
|
});
|
|
13552
13563
|
}
|
|
13553
13564
|
}
|
|
13565
|
+
destroy() {
|
|
13566
|
+
if (this.recordCrossOriginIframes) {
|
|
13567
|
+
window.removeEventListener("message", this.messageHandler);
|
|
13568
|
+
}
|
|
13569
|
+
this.nestedIframeListeners.forEach((handler, contentWindow) => {
|
|
13570
|
+
contentWindow.removeEventListener("message", handler);
|
|
13571
|
+
});
|
|
13572
|
+
this.nestedIframeListeners.clear();
|
|
13573
|
+
}
|
|
13554
13574
|
}
|
|
13555
13575
|
class ShadowDomManager {
|
|
13556
13576
|
constructor(options) {
|
|
@@ -14771,6 +14791,7 @@ function record(options = {}) {
|
|
|
14771
14791
|
return () => {
|
|
14772
14792
|
handlers.forEach((h) => h());
|
|
14773
14793
|
processedNodeManager.destroy();
|
|
14794
|
+
iframeManager.destroy();
|
|
14774
14795
|
recording = false;
|
|
14775
14796
|
unregisterErrorHandler();
|
|
14776
14797
|
};
|
|
@@ -15984,6 +16005,11 @@ class Replayer {
|
|
|
15984
16005
|
__publicField(this, "lastSelectionData", null);
|
|
15985
16006
|
__publicField(this, "constructedStyleMutations", []);
|
|
15986
16007
|
__publicField(this, "adoptedStyleSheets", []);
|
|
16008
|
+
__publicField(this, "emitterHandlers", []);
|
|
16009
|
+
__publicField(this, "serviceSubscription");
|
|
16010
|
+
__publicField(this, "speedServiceSubscription");
|
|
16011
|
+
__publicField(this, "timeouts", /* @__PURE__ */ new Set());
|
|
16012
|
+
__publicField(this, "styleSheetLoadListeners", /* @__PURE__ */ new Map());
|
|
15987
16013
|
__publicField(this, "handleResize", (dimension) => {
|
|
15988
16014
|
this.iframe.style.display = "inherit";
|
|
15989
16015
|
for (const el of [this.mouseTail, this.iframe]) {
|
|
@@ -16143,12 +16169,12 @@ class Replayer {
|
|
|
16143
16169
|
this.handleResize = this.handleResize.bind(this);
|
|
16144
16170
|
this.getCastFn = this.getCastFn.bind(this);
|
|
16145
16171
|
this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);
|
|
16146
|
-
this.
|
|
16172
|
+
this.addEmitterHandler(ReplayerEvents.Resize, this.handleResize);
|
|
16147
16173
|
this.setupDom();
|
|
16148
16174
|
for (const plugin of this.config.plugins || []) {
|
|
16149
16175
|
if (plugin.getMirror) plugin.getMirror({ nodeMirror: this.mirror });
|
|
16150
16176
|
}
|
|
16151
|
-
|
|
16177
|
+
const flushHandler = () => {
|
|
16152
16178
|
if (this.usingVirtualDom) {
|
|
16153
16179
|
const replayerHandler = {
|
|
16154
16180
|
mirror: this.mirror,
|
|
@@ -16244,13 +16270,15 @@ class Replayer {
|
|
|
16244
16270
|
this.applySelection(this.lastSelectionData);
|
|
16245
16271
|
this.lastSelectionData = null;
|
|
16246
16272
|
}
|
|
16247
|
-
}
|
|
16248
|
-
this.
|
|
16273
|
+
};
|
|
16274
|
+
this.addEmitterHandler(ReplayerEvents.Flush, flushHandler);
|
|
16275
|
+
const playBackHandler = () => {
|
|
16249
16276
|
this.firstFullSnapshot = null;
|
|
16250
16277
|
this.mirror.reset();
|
|
16251
16278
|
this.styleMirror.reset();
|
|
16252
16279
|
this.mediaManager.reset();
|
|
16253
|
-
}
|
|
16280
|
+
};
|
|
16281
|
+
this.addEmitterHandler(ReplayerEvents.PlayBack, playBackHandler);
|
|
16254
16282
|
const timer = new Timer([], {
|
|
16255
16283
|
speed: this.config.speed
|
|
16256
16284
|
});
|
|
@@ -16274,7 +16302,7 @@ class Replayer {
|
|
|
16274
16302
|
}
|
|
16275
16303
|
);
|
|
16276
16304
|
this.service.start();
|
|
16277
|
-
this.service.subscribe((state) => {
|
|
16305
|
+
this.serviceSubscription = this.service.subscribe((state) => {
|
|
16278
16306
|
this.emitter.emit(ReplayerEvents.StateChange, {
|
|
16279
16307
|
player: state
|
|
16280
16308
|
});
|
|
@@ -16284,7 +16312,7 @@ class Replayer {
|
|
|
16284
16312
|
timer
|
|
16285
16313
|
});
|
|
16286
16314
|
this.speedService.start();
|
|
16287
|
-
this.speedService.subscribe((state) => {
|
|
16315
|
+
this.speedServiceSubscription = this.speedService.subscribe((state) => {
|
|
16288
16316
|
this.emitter.emit(ReplayerEvents.StateChange, {
|
|
16289
16317
|
speed: state
|
|
16290
16318
|
});
|
|
@@ -16304,7 +16332,7 @@ class Replayer {
|
|
|
16304
16332
|
);
|
|
16305
16333
|
if (firstMeta) {
|
|
16306
16334
|
const { width, height } = firstMeta.data;
|
|
16307
|
-
|
|
16335
|
+
this.addTimeout(() => {
|
|
16308
16336
|
this.emitter.emit(ReplayerEvents.Resize, {
|
|
16309
16337
|
width,
|
|
16310
16338
|
height
|
|
@@ -16312,7 +16340,7 @@ class Replayer {
|
|
|
16312
16340
|
}, 0);
|
|
16313
16341
|
}
|
|
16314
16342
|
if (firstFullsnapshot) {
|
|
16315
|
-
|
|
16343
|
+
this.addTimeout(() => {
|
|
16316
16344
|
var _a2;
|
|
16317
16345
|
if (this.firstFullSnapshot) {
|
|
16318
16346
|
return;
|
|
@@ -16341,6 +16369,24 @@ class Replayer {
|
|
|
16341
16369
|
this.emitter.off(event, handler);
|
|
16342
16370
|
return this;
|
|
16343
16371
|
}
|
|
16372
|
+
/**
|
|
16373
|
+
* Track emitter handlers for cleanup
|
|
16374
|
+
*/
|
|
16375
|
+
addEmitterHandler(event, handler) {
|
|
16376
|
+
this.emitter.on(event, handler);
|
|
16377
|
+
this.emitterHandlers.push({ event, handler });
|
|
16378
|
+
}
|
|
16379
|
+
/**
|
|
16380
|
+
* Track timeouts for cleanup
|
|
16381
|
+
*/
|
|
16382
|
+
addTimeout(callback, delay) {
|
|
16383
|
+
const timeout = setTimeout(() => {
|
|
16384
|
+
this.timeouts.delete(timeout);
|
|
16385
|
+
callback();
|
|
16386
|
+
}, delay);
|
|
16387
|
+
this.timeouts.add(timeout);
|
|
16388
|
+
return timeout;
|
|
16389
|
+
}
|
|
16344
16390
|
setConfig(config) {
|
|
16345
16391
|
Object.keys(config).forEach((key) => {
|
|
16346
16392
|
config[key];
|
|
@@ -16443,10 +16489,31 @@ class Replayer {
|
|
|
16443
16489
|
* Memory occupation can be released by removing all references to this replayer.
|
|
16444
16490
|
*/
|
|
16445
16491
|
destroy() {
|
|
16492
|
+
var _a2, _b;
|
|
16493
|
+
if (!this.wrapper || !this.wrapper.parentNode) {
|
|
16494
|
+
return;
|
|
16495
|
+
}
|
|
16446
16496
|
this.pause();
|
|
16497
|
+
this.emitterHandlers.forEach(({ event, handler }) => {
|
|
16498
|
+
this.emitter.off(event, handler);
|
|
16499
|
+
});
|
|
16500
|
+
this.emitterHandlers = [];
|
|
16501
|
+
(_a2 = this.serviceSubscription) == null ? void 0 : _a2.unsubscribe();
|
|
16502
|
+
(_b = this.speedServiceSubscription) == null ? void 0 : _b.unsubscribe();
|
|
16503
|
+
this.serviceSubscription = void 0;
|
|
16504
|
+
this.speedServiceSubscription = void 0;
|
|
16505
|
+
this.timeouts.forEach((timeout) => clearTimeout(timeout));
|
|
16506
|
+
this.timeouts.clear();
|
|
16507
|
+
this.styleSheetLoadListeners.forEach((handler, element) => {
|
|
16508
|
+
element.removeEventListener("load", handler);
|
|
16509
|
+
});
|
|
16510
|
+
this.styleSheetLoadListeners.clear();
|
|
16511
|
+
this.imageMap.clear();
|
|
16512
|
+
this.canvasEventMap.clear();
|
|
16447
16513
|
this.mirror.reset();
|
|
16448
16514
|
this.styleMirror.reset();
|
|
16449
16515
|
this.mediaManager.reset();
|
|
16516
|
+
this.resetCache();
|
|
16450
16517
|
this.config.root.removeChild(this.wrapper);
|
|
16451
16518
|
this.emitter.emit(ReplayerEvents.Destroy);
|
|
16452
16519
|
}
|