Skip to content

Commit 84bbe2f

Browse files
committed
support manual canvas snapshotting (#108)
See highlight/highlight#6139
1 parent b5c45da commit 84bbe2f

File tree

3 files changed

+209
-179
lines changed

3 files changed

+209
-179
lines changed

packages/rrweb/src/record/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ function record<T = eventWithTime>(
331331
blockSelector,
332332
mirror,
333333
sampling: sampling?.canvas?.fps,
334+
samplingManual: sampling?.canvas?.fpsManual,
334335
clearWebGLBuffer: sampling?.canvas?.clearWebGLBuffer,
335336
initialSnapshotDelay: sampling?.canvas?.initialSnapshotDelay,
336337
dataURLOptions,
@@ -669,6 +670,13 @@ record.takeFullSnapshot = (isCheckout?: boolean) => {
669670
takeFullSnapshot(isCheckout);
670671
};
671672

673+
record.snapshotCanvas = async (element: HTMLCanvasElement) => {
674+
if (!canvasManager) {
675+
throw new Error('canvas manager is not initialized');
676+
}
677+
await canvasManager.snapshot(element);
678+
};
679+
672680
record.mirror = mirror;
673681

674682
export default record;

0 commit comments

Comments
 (0)