@appsurify-testmap/rrweb-record 3.2.0-alpha.1 → 3.3.0-alpha.1
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-record.cjs +221 -56
- package/dist/rrweb-record.cjs.map +1 -1
- package/dist/rrweb-record.js +221 -56
- package/dist/rrweb-record.js.map +1 -1
- package/dist/rrweb-record.umd.cjs +228 -56
- package/dist/rrweb-record.umd.cjs.map +3 -3
- package/dist/rrweb-record.umd.min.cjs +32 -32
- package/dist/rrweb-record.umd.min.cjs.map +3 -3
- package/package.json +4 -4
package/dist/rrweb-record.cjs
CHANGED
|
@@ -13860,6 +13860,30 @@ function initNavigationObserver({
|
|
|
13860
13860
|
handlers.push(restoreReplaceState);
|
|
13861
13861
|
handlers.push(on("popstate", () => emitNavigation("popstate"), win));
|
|
13862
13862
|
handlers.push(on("hashchange", () => emitNavigation("hashchange"), win));
|
|
13863
|
+
const useNavigationAPI = typeof sampling.navigation === "object" ? sampling.navigation.useNavigationAPI ?? true : true;
|
|
13864
|
+
if (useNavigationAPI && "navigation" in win) {
|
|
13865
|
+
try {
|
|
13866
|
+
const nav = win.navigation;
|
|
13867
|
+
const handler = (event) => {
|
|
13868
|
+
var _a2;
|
|
13869
|
+
const navEvent = event;
|
|
13870
|
+
if (navEvent.navigationType === "push" || navEvent.navigationType === "replace") {
|
|
13871
|
+
const destUrl = (_a2 = navEvent.destination) == null ? void 0 : _a2.url;
|
|
13872
|
+
if (destUrl && destUrl !== lastHref) {
|
|
13873
|
+
navigationCb({
|
|
13874
|
+
href: destUrl,
|
|
13875
|
+
oldHref: lastHref,
|
|
13876
|
+
navigationType: "navigate"
|
|
13877
|
+
});
|
|
13878
|
+
lastHref = destUrl;
|
|
13879
|
+
}
|
|
13880
|
+
}
|
|
13881
|
+
};
|
|
13882
|
+
nav.addEventListener("navigate", handler);
|
|
13883
|
+
handlers.push(() => nav.removeEventListener("navigate", handler));
|
|
13884
|
+
} catch {
|
|
13885
|
+
}
|
|
13886
|
+
}
|
|
13863
13887
|
return callbackWrapper(() => {
|
|
13864
13888
|
handlers.forEach((h) => h());
|
|
13865
13889
|
});
|
|
@@ -15958,6 +15982,164 @@ class VisibilityManager {
|
|
|
15958
15982
|
}
|
|
15959
15983
|
}
|
|
15960
15984
|
}
|
|
15985
|
+
const DEFAULT_SETTLE_TIMEOUT = 150;
|
|
15986
|
+
const DEFAULT_MAX_WAIT = 5e3;
|
|
15987
|
+
const DEFAULT_DEBOUNCE = 100;
|
|
15988
|
+
class NavigationManager {
|
|
15989
|
+
constructor(options) {
|
|
15990
|
+
__publicField(this, "frozen", false);
|
|
15991
|
+
__publicField(this, "locked", false);
|
|
15992
|
+
__publicField(this, "disabled", false);
|
|
15993
|
+
__publicField(this, "settleTimeout");
|
|
15994
|
+
__publicField(this, "maxWait");
|
|
15995
|
+
__publicField(this, "debounceMs");
|
|
15996
|
+
__publicField(this, "settlingObserver", null);
|
|
15997
|
+
__publicField(this, "debounceTimer", null);
|
|
15998
|
+
__publicField(this, "settleCheckTimer", null);
|
|
15999
|
+
__publicField(this, "maxWaitTimer", null);
|
|
16000
|
+
__publicField(this, "lastMutationTime", 0);
|
|
16001
|
+
__publicField(this, "pendingNavigation", null);
|
|
16002
|
+
__publicField(this, "doc");
|
|
16003
|
+
__publicField(this, "onSnapshot");
|
|
16004
|
+
const { doc, config, onSnapshot } = options;
|
|
16005
|
+
this.doc = doc;
|
|
16006
|
+
this.onSnapshot = callbackWrapper(onSnapshot);
|
|
16007
|
+
this.settleTimeout = config.settleTimeout ?? DEFAULT_SETTLE_TIMEOUT;
|
|
16008
|
+
this.maxWait = config.maxWait ?? DEFAULT_MAX_WAIT;
|
|
16009
|
+
this.debounceMs = config.debounce ?? DEFAULT_DEBOUNCE;
|
|
16010
|
+
}
|
|
16011
|
+
handleNavigation(data) {
|
|
16012
|
+
if (this.disabled) return;
|
|
16013
|
+
if (this.locked) return;
|
|
16014
|
+
this.cancelTimers();
|
|
16015
|
+
this.disconnectSettlingObserver();
|
|
16016
|
+
this.pendingNavigation = data;
|
|
16017
|
+
if (this.frozen) {
|
|
16018
|
+
return;
|
|
16019
|
+
}
|
|
16020
|
+
this.startDebounce();
|
|
16021
|
+
}
|
|
16022
|
+
cancelPending() {
|
|
16023
|
+
this.cancelTimers();
|
|
16024
|
+
this.disconnectSettlingObserver();
|
|
16025
|
+
this.pendingNavigation = null;
|
|
16026
|
+
}
|
|
16027
|
+
freeze() {
|
|
16028
|
+
this.frozen = true;
|
|
16029
|
+
this.cancelTimers();
|
|
16030
|
+
this.disconnectSettlingObserver();
|
|
16031
|
+
}
|
|
16032
|
+
unfreeze() {
|
|
16033
|
+
this.frozen = false;
|
|
16034
|
+
if (this.pendingNavigation && !this.locked && !this.disabled) {
|
|
16035
|
+
this.startDebounce();
|
|
16036
|
+
}
|
|
16037
|
+
}
|
|
16038
|
+
lock() {
|
|
16039
|
+
this.locked = true;
|
|
16040
|
+
this.cancelTimers();
|
|
16041
|
+
this.disconnectSettlingObserver();
|
|
16042
|
+
}
|
|
16043
|
+
unlock() {
|
|
16044
|
+
this.locked = false;
|
|
16045
|
+
this.pendingNavigation = null;
|
|
16046
|
+
}
|
|
16047
|
+
unsetFrozen() {
|
|
16048
|
+
this.frozen = false;
|
|
16049
|
+
}
|
|
16050
|
+
reset() {
|
|
16051
|
+
this.cancelTimers();
|
|
16052
|
+
this.disconnectSettlingObserver();
|
|
16053
|
+
this.pendingNavigation = null;
|
|
16054
|
+
this.frozen = false;
|
|
16055
|
+
this.locked = false;
|
|
16056
|
+
}
|
|
16057
|
+
destroy() {
|
|
16058
|
+
this.reset();
|
|
16059
|
+
this.disabled = true;
|
|
16060
|
+
}
|
|
16061
|
+
startDebounce() {
|
|
16062
|
+
this.debounceTimer = setTimeout(() => {
|
|
16063
|
+
this.debounceTimer = null;
|
|
16064
|
+
this.startDOMSettling();
|
|
16065
|
+
}, this.debounceMs);
|
|
16066
|
+
}
|
|
16067
|
+
startDOMSettling() {
|
|
16068
|
+
if (this.frozen || this.locked || this.disabled) return;
|
|
16069
|
+
this.lastMutationTime = performance.now();
|
|
16070
|
+
const ObserverCtor = mutationObserverCtor();
|
|
16071
|
+
this.settlingObserver = new ObserverCtor(() => {
|
|
16072
|
+
this.lastMutationTime = performance.now();
|
|
16073
|
+
if (this.settleCheckTimer !== null) {
|
|
16074
|
+
clearTimeout(this.settleCheckTimer);
|
|
16075
|
+
}
|
|
16076
|
+
this.settleCheckTimer = setTimeout(
|
|
16077
|
+
() => this.checkSettled(),
|
|
16078
|
+
this.settleTimeout
|
|
16079
|
+
);
|
|
16080
|
+
});
|
|
16081
|
+
this.settlingObserver.observe(this.doc, {
|
|
16082
|
+
childList: true,
|
|
16083
|
+
subtree: true,
|
|
16084
|
+
attributes: true,
|
|
16085
|
+
characterData: true
|
|
16086
|
+
});
|
|
16087
|
+
this.settleCheckTimer = setTimeout(
|
|
16088
|
+
() => this.checkSettled(),
|
|
16089
|
+
this.settleTimeout
|
|
16090
|
+
);
|
|
16091
|
+
this.maxWaitTimer = setTimeout(() => {
|
|
16092
|
+
this.maxWaitTimer = null;
|
|
16093
|
+
this.completeSettling();
|
|
16094
|
+
}, this.maxWait);
|
|
16095
|
+
}
|
|
16096
|
+
checkSettled() {
|
|
16097
|
+
this.settleCheckTimer = null;
|
|
16098
|
+
const elapsed = performance.now() - this.lastMutationTime;
|
|
16099
|
+
if (elapsed >= this.settleTimeout) {
|
|
16100
|
+
this.completeSettling();
|
|
16101
|
+
} else {
|
|
16102
|
+
this.settleCheckTimer = setTimeout(
|
|
16103
|
+
() => this.checkSettled(),
|
|
16104
|
+
this.settleTimeout - elapsed
|
|
16105
|
+
);
|
|
16106
|
+
}
|
|
16107
|
+
}
|
|
16108
|
+
completeSettling() {
|
|
16109
|
+
if (this.frozen || this.locked || this.disabled) return;
|
|
16110
|
+
if (!this.pendingNavigation) return;
|
|
16111
|
+
this.cancelTimers();
|
|
16112
|
+
this.disconnectSettlingObserver();
|
|
16113
|
+
this.pendingNavigation = null;
|
|
16114
|
+
requestAnimationFrame(() => {
|
|
16115
|
+
requestAnimationFrame(() => {
|
|
16116
|
+
if (!this.frozen && !this.locked && !this.disabled) {
|
|
16117
|
+
this.onSnapshot(true);
|
|
16118
|
+
}
|
|
16119
|
+
});
|
|
16120
|
+
});
|
|
16121
|
+
}
|
|
16122
|
+
cancelTimers() {
|
|
16123
|
+
if (this.debounceTimer !== null) {
|
|
16124
|
+
clearTimeout(this.debounceTimer);
|
|
16125
|
+
this.debounceTimer = null;
|
|
16126
|
+
}
|
|
16127
|
+
if (this.settleCheckTimer !== null) {
|
|
16128
|
+
clearTimeout(this.settleCheckTimer);
|
|
16129
|
+
this.settleCheckTimer = null;
|
|
16130
|
+
}
|
|
16131
|
+
if (this.maxWaitTimer !== null) {
|
|
16132
|
+
clearTimeout(this.maxWaitTimer);
|
|
16133
|
+
this.maxWaitTimer = null;
|
|
16134
|
+
}
|
|
16135
|
+
}
|
|
16136
|
+
disconnectSettlingObserver() {
|
|
16137
|
+
if (this.settlingObserver) {
|
|
16138
|
+
this.settlingObserver.disconnect();
|
|
16139
|
+
this.settlingObserver = null;
|
|
16140
|
+
}
|
|
16141
|
+
}
|
|
16142
|
+
}
|
|
15961
16143
|
class StylesheetManager {
|
|
15962
16144
|
constructor(options) {
|
|
15963
16145
|
__publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
|
|
@@ -16041,43 +16223,13 @@ class ProcessedNodeManager {
|
|
|
16041
16223
|
destroy() {
|
|
16042
16224
|
}
|
|
16043
16225
|
}
|
|
16044
|
-
const version$1 = "3.
|
|
16226
|
+
const version$1 = "3.3.0-alpha.1";
|
|
16045
16227
|
let wrappedEmit;
|
|
16046
16228
|
let takeFullSnapshot$1;
|
|
16047
16229
|
let canvasManager;
|
|
16048
16230
|
let recording = false;
|
|
16049
16231
|
const customEventQueue = [];
|
|
16050
16232
|
let flushCustomEventQueue$1;
|
|
16051
|
-
function waitForDOMStabilization(win) {
|
|
16052
|
-
const maxWaitMs = 5e3;
|
|
16053
|
-
return new Promise((resolve2) => {
|
|
16054
|
-
const captureAfterPaint = () => {
|
|
16055
|
-
requestAnimationFrame(() => {
|
|
16056
|
-
requestAnimationFrame(() => {
|
|
16057
|
-
resolve2();
|
|
16058
|
-
});
|
|
16059
|
-
});
|
|
16060
|
-
};
|
|
16061
|
-
const safeResolve = /* @__PURE__ */ (() => {
|
|
16062
|
-
let called = false;
|
|
16063
|
-
return () => {
|
|
16064
|
-
if (!called) {
|
|
16065
|
-
called = true;
|
|
16066
|
-
captureAfterPaint();
|
|
16067
|
-
}
|
|
16068
|
-
};
|
|
16069
|
-
})();
|
|
16070
|
-
if (["interactive", "complete"].includes(win.document.readyState)) {
|
|
16071
|
-
safeResolve();
|
|
16072
|
-
} else {
|
|
16073
|
-
win.addEventListener("DOMContentLoaded", safeResolve, { once: true });
|
|
16074
|
-
win.addEventListener("load", safeResolve, { once: true });
|
|
16075
|
-
setTimeout(() => {
|
|
16076
|
-
safeResolve();
|
|
16077
|
-
}, maxWaitMs);
|
|
16078
|
-
}
|
|
16079
|
-
});
|
|
16080
|
-
}
|
|
16081
16233
|
try {
|
|
16082
16234
|
if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
|
|
16083
16235
|
const cleanFrame = document.createElement("iframe");
|
|
@@ -16210,6 +16362,7 @@ function record(options = {}) {
|
|
|
16210
16362
|
checkoutDebounceTimer = null;
|
|
16211
16363
|
checkoutPending = false;
|
|
16212
16364
|
checkoutFreezeTimestamp = null;
|
|
16365
|
+
navigationManager == null ? void 0 : navigationManager.cancelPending();
|
|
16213
16366
|
takeFullSnapshot$1(true);
|
|
16214
16367
|
mutationBuffers.forEach((buf) => {
|
|
16215
16368
|
buf.resetBuffers();
|
|
@@ -16218,6 +16371,9 @@ function record(options = {}) {
|
|
|
16218
16371
|
if (visibilityManager) {
|
|
16219
16372
|
visibilityManager.unsetFrozen();
|
|
16220
16373
|
}
|
|
16374
|
+
if (navigationManager) {
|
|
16375
|
+
navigationManager.unsetFrozen();
|
|
16376
|
+
}
|
|
16221
16377
|
};
|
|
16222
16378
|
wrappedEmit = (r2, isCheckout) => {
|
|
16223
16379
|
var _a2;
|
|
@@ -16227,6 +16383,7 @@ function record(options = {}) {
|
|
|
16227
16383
|
if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && !checkoutPending && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
|
|
16228
16384
|
mutationBuffers.forEach((buf) => buf.unfreeze());
|
|
16229
16385
|
visibilityManager == null ? void 0 : visibilityManager.unfreeze();
|
|
16386
|
+
navigationManager == null ? void 0 : navigationManager.unfreeze();
|
|
16230
16387
|
}
|
|
16231
16388
|
if (inEmittingFrame) {
|
|
16232
16389
|
emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
|
|
@@ -16436,6 +16593,7 @@ function record(options = {}) {
|
|
|
16436
16593
|
shadowDomManager.init();
|
|
16437
16594
|
mutationBuffers.forEach((buf) => buf.lock());
|
|
16438
16595
|
visibilityManager == null ? void 0 : visibilityManager.lock();
|
|
16596
|
+
navigationManager == null ? void 0 : navigationManager.lock();
|
|
16439
16597
|
const node2 = snapshot(document, {
|
|
16440
16598
|
mirror,
|
|
16441
16599
|
blockClass,
|
|
@@ -16487,6 +16645,7 @@ function record(options = {}) {
|
|
|
16487
16645
|
);
|
|
16488
16646
|
mutationBuffers.forEach((buf) => buf.unlock());
|
|
16489
16647
|
visibilityManager == null ? void 0 : visibilityManager.unlock();
|
|
16648
|
+
navigationManager == null ? void 0 : navigationManager.unlock();
|
|
16490
16649
|
if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)
|
|
16491
16650
|
stylesheetManager.adoptStyleSheets(
|
|
16492
16651
|
document.adoptedStyleSheets,
|
|
@@ -16499,6 +16658,31 @@ function record(options = {}) {
|
|
|
16499
16658
|
}
|
|
16500
16659
|
customEventQueue.length = 0;
|
|
16501
16660
|
};
|
|
16661
|
+
let navigationManager;
|
|
16662
|
+
const navigationSampling = sampling.navigation;
|
|
16663
|
+
if (navigationSampling !== false) {
|
|
16664
|
+
const navConfig = typeof navigationSampling === "object" ? navigationSampling : {};
|
|
16665
|
+
navigationManager = new NavigationManager({
|
|
16666
|
+
doc: document,
|
|
16667
|
+
config: navConfig,
|
|
16668
|
+
onSnapshot: (isCheckout) => {
|
|
16669
|
+
if (checkoutPending) {
|
|
16670
|
+
if (checkoutDebounceTimer) {
|
|
16671
|
+
clearTimeout(checkoutDebounceTimer);
|
|
16672
|
+
checkoutDebounceTimer = null;
|
|
16673
|
+
}
|
|
16674
|
+
checkoutPending = false;
|
|
16675
|
+
checkoutFreezeTimestamp = null;
|
|
16676
|
+
mutationBuffers.forEach((buf) => {
|
|
16677
|
+
buf.resetBuffers();
|
|
16678
|
+
buf.unsetFrozen();
|
|
16679
|
+
});
|
|
16680
|
+
visibilityManager == null ? void 0 : visibilityManager.unsetFrozen();
|
|
16681
|
+
}
|
|
16682
|
+
takeFullSnapshot$1(isCheckout);
|
|
16683
|
+
}
|
|
16684
|
+
});
|
|
16685
|
+
}
|
|
16502
16686
|
try {
|
|
16503
16687
|
const handlers = [];
|
|
16504
16688
|
const observe = (doc) => {
|
|
@@ -16529,14 +16713,11 @@ function record(options = {}) {
|
|
|
16529
16713
|
}
|
|
16530
16714
|
}),
|
|
16531
16715
|
navigationCb: (navData) => {
|
|
16532
|
-
|
|
16533
|
-
|
|
16534
|
-
|
|
16535
|
-
|
|
16536
|
-
|
|
16537
|
-
navData.href
|
|
16538
|
-
);
|
|
16539
|
-
takeFullSnapshot$1(true);
|
|
16716
|
+
if (navigationManager) {
|
|
16717
|
+
navigationManager.handleNavigation(navData);
|
|
16718
|
+
} else {
|
|
16719
|
+
takeFullSnapshot$1(true);
|
|
16720
|
+
}
|
|
16540
16721
|
},
|
|
16541
16722
|
inputCb: (v2) => wrappedEmit({
|
|
16542
16723
|
type: EventType.IncrementalSnapshot,
|
|
@@ -16655,23 +16836,6 @@ function record(options = {}) {
|
|
|
16655
16836
|
flushCustomEventQueue$1();
|
|
16656
16837
|
}
|
|
16657
16838
|
};
|
|
16658
|
-
const runInit = async () => {
|
|
16659
|
-
if (flushCustomEvent === "before") {
|
|
16660
|
-
flushCustomEventQueue$1();
|
|
16661
|
-
}
|
|
16662
|
-
if (recordAfter === "DOMContentStabilized") {
|
|
16663
|
-
console.debug(`[${nowTimestamp()}] [rrweb:record] 🟢 Waiting for DOM stabilization...`);
|
|
16664
|
-
await waitForDOMStabilization(window);
|
|
16665
|
-
console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ DOM stabilized, starting recording`);
|
|
16666
|
-
}
|
|
16667
|
-
console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ Init dom and takeFullSnapshot `);
|
|
16668
|
-
takeFullSnapshot$1();
|
|
16669
|
-
handlers.push(observe(document));
|
|
16670
|
-
recording = true;
|
|
16671
|
-
if (flushCustomEvent === "after") {
|
|
16672
|
-
flushCustomEventQueue$1();
|
|
16673
|
-
}
|
|
16674
|
-
};
|
|
16675
16839
|
if (document.readyState === "interactive" || document.readyState === "complete") {
|
|
16676
16840
|
init();
|
|
16677
16841
|
} else {
|
|
@@ -16705,6 +16869,7 @@ function record(options = {}) {
|
|
|
16705
16869
|
}
|
|
16706
16870
|
flushCustomEventQueue$1();
|
|
16707
16871
|
handlers.forEach((h) => h());
|
|
16872
|
+
navigationManager == null ? void 0 : navigationManager.destroy();
|
|
16708
16873
|
processedNodeManager.destroy();
|
|
16709
16874
|
recording = false;
|
|
16710
16875
|
unregisterErrorHandler();
|