@appsurify-testmap/rrweb-record 3.2.0-alpha.1 → 3.4.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 +219 -56
- package/dist/rrweb-record.cjs.map +1 -1
- package/dist/rrweb-record.js +219 -56
- package/dist/rrweb-record.js.map +1 -1
- package/dist/rrweb-record.umd.cjs +226 -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,162 @@ 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
|
+
const hadPending = this.pendingNavigation !== null;
|
|
16059
|
+
this.reset();
|
|
16060
|
+
this.disabled = true;
|
|
16061
|
+
if (hadPending) {
|
|
16062
|
+
this.onSnapshot(true);
|
|
16063
|
+
}
|
|
16064
|
+
}
|
|
16065
|
+
startDebounce() {
|
|
16066
|
+
this.debounceTimer = setTimeout(() => {
|
|
16067
|
+
this.debounceTimer = null;
|
|
16068
|
+
this.startDOMSettling();
|
|
16069
|
+
}, this.debounceMs);
|
|
16070
|
+
}
|
|
16071
|
+
startDOMSettling() {
|
|
16072
|
+
if (this.frozen || this.locked || this.disabled) return;
|
|
16073
|
+
this.lastMutationTime = performance.now();
|
|
16074
|
+
const ObserverCtor = mutationObserverCtor();
|
|
16075
|
+
this.settlingObserver = new ObserverCtor(() => {
|
|
16076
|
+
this.lastMutationTime = performance.now();
|
|
16077
|
+
if (this.settleCheckTimer !== null) {
|
|
16078
|
+
clearTimeout(this.settleCheckTimer);
|
|
16079
|
+
}
|
|
16080
|
+
this.settleCheckTimer = setTimeout(
|
|
16081
|
+
() => this.checkSettled(),
|
|
16082
|
+
this.settleTimeout
|
|
16083
|
+
);
|
|
16084
|
+
});
|
|
16085
|
+
this.settlingObserver.observe(this.doc, {
|
|
16086
|
+
childList: true,
|
|
16087
|
+
subtree: true,
|
|
16088
|
+
attributes: true,
|
|
16089
|
+
characterData: true
|
|
16090
|
+
});
|
|
16091
|
+
this.settleCheckTimer = setTimeout(
|
|
16092
|
+
() => this.checkSettled(),
|
|
16093
|
+
this.settleTimeout
|
|
16094
|
+
);
|
|
16095
|
+
this.maxWaitTimer = setTimeout(() => {
|
|
16096
|
+
this.maxWaitTimer = null;
|
|
16097
|
+
this.completeSettling();
|
|
16098
|
+
}, this.maxWait);
|
|
16099
|
+
}
|
|
16100
|
+
checkSettled() {
|
|
16101
|
+
this.settleCheckTimer = null;
|
|
16102
|
+
const elapsed = performance.now() - this.lastMutationTime;
|
|
16103
|
+
if (elapsed >= this.settleTimeout) {
|
|
16104
|
+
this.completeSettling();
|
|
16105
|
+
} else {
|
|
16106
|
+
this.settleCheckTimer = setTimeout(
|
|
16107
|
+
() => this.checkSettled(),
|
|
16108
|
+
this.settleTimeout - elapsed
|
|
16109
|
+
);
|
|
16110
|
+
}
|
|
16111
|
+
}
|
|
16112
|
+
completeSettling() {
|
|
16113
|
+
if (this.frozen || this.locked || this.disabled) return;
|
|
16114
|
+
if (!this.pendingNavigation) return;
|
|
16115
|
+
this.cancelTimers();
|
|
16116
|
+
this.disconnectSettlingObserver();
|
|
16117
|
+
this.pendingNavigation = null;
|
|
16118
|
+
this.onSnapshot(true);
|
|
16119
|
+
}
|
|
16120
|
+
cancelTimers() {
|
|
16121
|
+
if (this.debounceTimer !== null) {
|
|
16122
|
+
clearTimeout(this.debounceTimer);
|
|
16123
|
+
this.debounceTimer = null;
|
|
16124
|
+
}
|
|
16125
|
+
if (this.settleCheckTimer !== null) {
|
|
16126
|
+
clearTimeout(this.settleCheckTimer);
|
|
16127
|
+
this.settleCheckTimer = null;
|
|
16128
|
+
}
|
|
16129
|
+
if (this.maxWaitTimer !== null) {
|
|
16130
|
+
clearTimeout(this.maxWaitTimer);
|
|
16131
|
+
this.maxWaitTimer = null;
|
|
16132
|
+
}
|
|
16133
|
+
}
|
|
16134
|
+
disconnectSettlingObserver() {
|
|
16135
|
+
if (this.settlingObserver) {
|
|
16136
|
+
this.settlingObserver.disconnect();
|
|
16137
|
+
this.settlingObserver = null;
|
|
16138
|
+
}
|
|
16139
|
+
}
|
|
16140
|
+
}
|
|
15961
16141
|
class StylesheetManager {
|
|
15962
16142
|
constructor(options) {
|
|
15963
16143
|
__publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
|
|
@@ -16041,43 +16221,13 @@ class ProcessedNodeManager {
|
|
|
16041
16221
|
destroy() {
|
|
16042
16222
|
}
|
|
16043
16223
|
}
|
|
16044
|
-
const version$1 = "3.
|
|
16224
|
+
const version$1 = "3.4.0-alpha.1";
|
|
16045
16225
|
let wrappedEmit;
|
|
16046
16226
|
let takeFullSnapshot$1;
|
|
16047
16227
|
let canvasManager;
|
|
16048
16228
|
let recording = false;
|
|
16049
16229
|
const customEventQueue = [];
|
|
16050
16230
|
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
16231
|
try {
|
|
16082
16232
|
if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
|
|
16083
16233
|
const cleanFrame = document.createElement("iframe");
|
|
@@ -16210,6 +16360,7 @@ function record(options = {}) {
|
|
|
16210
16360
|
checkoutDebounceTimer = null;
|
|
16211
16361
|
checkoutPending = false;
|
|
16212
16362
|
checkoutFreezeTimestamp = null;
|
|
16363
|
+
navigationManager == null ? void 0 : navigationManager.cancelPending();
|
|
16213
16364
|
takeFullSnapshot$1(true);
|
|
16214
16365
|
mutationBuffers.forEach((buf) => {
|
|
16215
16366
|
buf.resetBuffers();
|
|
@@ -16218,6 +16369,9 @@ function record(options = {}) {
|
|
|
16218
16369
|
if (visibilityManager) {
|
|
16219
16370
|
visibilityManager.unsetFrozen();
|
|
16220
16371
|
}
|
|
16372
|
+
if (navigationManager) {
|
|
16373
|
+
navigationManager.unsetFrozen();
|
|
16374
|
+
}
|
|
16221
16375
|
};
|
|
16222
16376
|
wrappedEmit = (r2, isCheckout) => {
|
|
16223
16377
|
var _a2;
|
|
@@ -16227,6 +16381,7 @@ function record(options = {}) {
|
|
|
16227
16381
|
if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && !checkoutPending && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
|
|
16228
16382
|
mutationBuffers.forEach((buf) => buf.unfreeze());
|
|
16229
16383
|
visibilityManager == null ? void 0 : visibilityManager.unfreeze();
|
|
16384
|
+
navigationManager == null ? void 0 : navigationManager.unfreeze();
|
|
16230
16385
|
}
|
|
16231
16386
|
if (inEmittingFrame) {
|
|
16232
16387
|
emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
|
|
@@ -16436,6 +16591,7 @@ function record(options = {}) {
|
|
|
16436
16591
|
shadowDomManager.init();
|
|
16437
16592
|
mutationBuffers.forEach((buf) => buf.lock());
|
|
16438
16593
|
visibilityManager == null ? void 0 : visibilityManager.lock();
|
|
16594
|
+
navigationManager == null ? void 0 : navigationManager.lock();
|
|
16439
16595
|
const node2 = snapshot(document, {
|
|
16440
16596
|
mirror,
|
|
16441
16597
|
blockClass,
|
|
@@ -16487,6 +16643,7 @@ function record(options = {}) {
|
|
|
16487
16643
|
);
|
|
16488
16644
|
mutationBuffers.forEach((buf) => buf.unlock());
|
|
16489
16645
|
visibilityManager == null ? void 0 : visibilityManager.unlock();
|
|
16646
|
+
navigationManager == null ? void 0 : navigationManager.unlock();
|
|
16490
16647
|
if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)
|
|
16491
16648
|
stylesheetManager.adoptStyleSheets(
|
|
16492
16649
|
document.adoptedStyleSheets,
|
|
@@ -16499,6 +16656,31 @@ function record(options = {}) {
|
|
|
16499
16656
|
}
|
|
16500
16657
|
customEventQueue.length = 0;
|
|
16501
16658
|
};
|
|
16659
|
+
let navigationManager;
|
|
16660
|
+
const navigationSampling = sampling.navigation;
|
|
16661
|
+
if (navigationSampling !== false) {
|
|
16662
|
+
const navConfig = typeof navigationSampling === "object" ? navigationSampling : {};
|
|
16663
|
+
navigationManager = new NavigationManager({
|
|
16664
|
+
doc: document,
|
|
16665
|
+
config: navConfig,
|
|
16666
|
+
onSnapshot: (isCheckout) => {
|
|
16667
|
+
if (checkoutPending) {
|
|
16668
|
+
if (checkoutDebounceTimer) {
|
|
16669
|
+
clearTimeout(checkoutDebounceTimer);
|
|
16670
|
+
checkoutDebounceTimer = null;
|
|
16671
|
+
}
|
|
16672
|
+
checkoutPending = false;
|
|
16673
|
+
checkoutFreezeTimestamp = null;
|
|
16674
|
+
mutationBuffers.forEach((buf) => {
|
|
16675
|
+
buf.resetBuffers();
|
|
16676
|
+
buf.unsetFrozen();
|
|
16677
|
+
});
|
|
16678
|
+
visibilityManager == null ? void 0 : visibilityManager.unsetFrozen();
|
|
16679
|
+
}
|
|
16680
|
+
takeFullSnapshot$1(isCheckout);
|
|
16681
|
+
}
|
|
16682
|
+
});
|
|
16683
|
+
}
|
|
16502
16684
|
try {
|
|
16503
16685
|
const handlers = [];
|
|
16504
16686
|
const observe = (doc) => {
|
|
@@ -16529,14 +16711,11 @@ function record(options = {}) {
|
|
|
16529
16711
|
}
|
|
16530
16712
|
}),
|
|
16531
16713
|
navigationCb: (navData) => {
|
|
16532
|
-
|
|
16533
|
-
|
|
16534
|
-
|
|
16535
|
-
|
|
16536
|
-
|
|
16537
|
-
navData.href
|
|
16538
|
-
);
|
|
16539
|
-
takeFullSnapshot$1(true);
|
|
16714
|
+
if (navigationManager) {
|
|
16715
|
+
navigationManager.handleNavigation(navData);
|
|
16716
|
+
} else {
|
|
16717
|
+
takeFullSnapshot$1(true);
|
|
16718
|
+
}
|
|
16540
16719
|
},
|
|
16541
16720
|
inputCb: (v2) => wrappedEmit({
|
|
16542
16721
|
type: EventType.IncrementalSnapshot,
|
|
@@ -16655,23 +16834,6 @@ function record(options = {}) {
|
|
|
16655
16834
|
flushCustomEventQueue$1();
|
|
16656
16835
|
}
|
|
16657
16836
|
};
|
|
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
16837
|
if (document.readyState === "interactive" || document.readyState === "complete") {
|
|
16676
16838
|
init();
|
|
16677
16839
|
} else {
|
|
@@ -16705,6 +16867,7 @@ function record(options = {}) {
|
|
|
16705
16867
|
}
|
|
16706
16868
|
flushCustomEventQueue$1();
|
|
16707
16869
|
handlers.forEach((h) => h());
|
|
16870
|
+
navigationManager == null ? void 0 : navigationManager.destroy();
|
|
16708
16871
|
processedNodeManager.destroy();
|
|
16709
16872
|
recording = false;
|
|
16710
16873
|
unregisterErrorHandler();
|