Skip to content

Commit 677e95d

Browse files
committed
export takeFullSnapshot and mirror from record
1 parent 0b5df15 commit 677e95d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

packages/rrweb/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import record from './record';
22
import { Replayer } from './replay';
3-
import { _mirror } from './utils';
43
import * as utils from './utils';
54

65
export {
@@ -27,6 +26,7 @@ export {
2726
addCustomEvent,
2827
freezePage,
2928
Replayer,
30-
_mirror as mirror,
3129
utils,
3230
};
31+
32+
export { takeFullSnapshot, mirror } from './record';

packages/rrweb/src/record/index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ declare global {
6767

6868
let wrappedEmit!: (e: eventWithTime, isCheckout?: boolean) => void;
6969

70-
let takeFullSnapshot!: (isCheckout?: boolean) => void;
70+
let _takeFullSnapshot!: (isCheckout?: boolean) => void;
7171
let canvasManager: CanvasManagerInterface;
7272
let recording = false;
7373

74-
const mirror = createMirror();
74+
export const mirror = createMirror();
7575
function record<T = eventWithTime>(
7676
options: recordOptions<T> = {},
7777
): listenerHandler | undefined {
@@ -256,7 +256,7 @@ function record<T = eventWithTime>(
256256
checkoutEveryNms &&
257257
e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
258258
if (exceedCount || exceedTime) {
259-
takeFullSnapshot(true);
259+
_takeFullSnapshot(true);
260260
}
261261
}
262262
};
@@ -386,7 +386,7 @@ function record<T = eventWithTime>(
386386
mirror,
387387
});
388388

389-
takeFullSnapshot = (isCheckout = false) => {
389+
_takeFullSnapshot = (isCheckout = false) => {
390390
wrappedEmit(
391391
wrapEvent({
392392
type: EventType.Meta,
@@ -644,7 +644,7 @@ function record<T = eventWithTime>(
644644
});
645645

646646
const init = () => {
647-
takeFullSnapshot();
647+
_takeFullSnapshot();
648648
handlers.push(observe(document));
649649
recording = true;
650650
};
@@ -712,12 +712,14 @@ record.freezePage = () => {
712712
mutationBuffers.forEach((buf) => buf.freeze());
713713
};
714714

715-
record.takeFullSnapshot = (isCheckout?: boolean) => {
715+
export function takeFullSnapshot(isCheckout?: boolean) {
716716
if (!recording) {
717717
throw new Error('please take full snapshot after start recording');
718718
}
719-
takeFullSnapshot(isCheckout);
720-
};
719+
_takeFullSnapshot(isCheckout);
720+
}
721+
722+
record.takeFullSnapshot = takeFullSnapshot;
721723

722724
record.mirror = mirror;
723725

0 commit comments

Comments
 (0)