Skip to content

Commit adeddb1

Browse files
committed
export takeFullSnapshot and mirror from record
1 parent a087e56 commit adeddb1

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
@@ -49,11 +49,11 @@ function wrapEvent(e: event): eventWithTime {
4949

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

52-
let takeFullSnapshot!: (isCheckout?: boolean) => void;
52+
let _takeFullSnapshot!: (isCheckout?: boolean) => void;
5353
let canvasManager!: CanvasManager;
5454
let recording = false;
5555

56-
const mirror = createMirror();
56+
export const mirror = createMirror();
5757
function record<T = eventWithTime>(
5858
options: recordOptions<T> = {},
5959
): listenerHandler | undefined {
@@ -238,7 +238,7 @@ function record<T = eventWithTime>(
238238
checkoutEveryNms &&
239239
e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
240240
if (exceedCount || exceedTime) {
241-
takeFullSnapshot(true);
241+
_takeFullSnapshot(true);
242242
}
243243
}
244244
};
@@ -358,7 +358,7 @@ function record<T = eventWithTime>(
358358
mirror,
359359
});
360360

361-
takeFullSnapshot = (isCheckout = false) => {
361+
_takeFullSnapshot = (isCheckout = false) => {
362362
wrappedEmit(
363363
wrapEvent({
364364
type: EventType.Meta,
@@ -616,7 +616,7 @@ function record<T = eventWithTime>(
616616
});
617617

618618
const init = () => {
619-
takeFullSnapshot();
619+
_takeFullSnapshot();
620620
handlers.push(observe(document));
621621
recording = true;
622622
};
@@ -684,12 +684,14 @@ record.freezePage = () => {
684684
mutationBuffers.forEach((buf) => buf.freeze());
685685
};
686686

687-
record.takeFullSnapshot = (isCheckout?: boolean) => {
687+
export function takeFullSnapshot(isCheckout?: boolean) {
688688
if (!recording) {
689689
throw new Error('please take full snapshot after start recording');
690690
}
691-
takeFullSnapshot(isCheckout);
692-
};
691+
_takeFullSnapshot(isCheckout);
692+
}
693+
694+
record.takeFullSnapshot = takeFullSnapshot;
693695

694696
record.mirror = mirror;
695697

0 commit comments

Comments
 (0)