Skip to content

Commit 4b4bc3e

Browse files
committed
support manual canvas snapshotting (#108)
See highlight/highlight#6139
1 parent f972817 commit 4b4bc3e

File tree

3 files changed

+186
-173
lines changed

3 files changed

+186
-173
lines changed

packages/rrweb/src/record/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ function record<T = eventWithTime>(
323323
blockSelector,
324324
mirror,
325325
sampling: sampling?.canvas?.fps,
326+
samplingManual: sampling?.canvas?.fpsManual,
326327
clearWebGLBuffer: sampling?.canvas?.clearWebGLBuffer,
327328
initialSnapshotDelay: sampling?.canvas?.initialSnapshotDelay,
328329
dataURLOptions,
@@ -687,6 +688,13 @@ record.takeFullSnapshot = (isCheckout?: boolean) => {
687688
takeFullSnapshot(isCheckout);
688689
};
689690

691+
record.snapshotCanvas = async (element: HTMLCanvasElement) => {
692+
if (!canvasManager) {
693+
throw new Error('canvas manager is not initialized');
694+
}
695+
await canvasManager.snapshot(element);
696+
};
697+
690698
record.mirror = mirror;
691699

692700
export default record;

0 commit comments

Comments
 (0)