Skip to content

Commit

Permalink
rrweb-io#1289 support config chrome launch options
Browse files Browse the repository at this point in the history
  • Loading branch information
xujiujiu authored Aug 15, 2023
1 parent 4659c77 commit 78c9a91
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/rrvideo/rrvideo.config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"mouseTail": {
"strokeStyle": "green",
"lineWidth": 2
}
},
"launchOptions": {}
}
4 changes: 4 additions & 0 deletions packages/rrvideo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as path from 'path';
import { chromium } from 'playwright';
import { EventType, eventWithTime } from '@rrweb/types';
import type { RRwebPlayerOptions } from 'rrweb-player';
import type { LaunchOptions } from "playwright";

const rrwebScriptPath = path.resolve(
require.resolve('rrweb-player'),
Expand All @@ -18,6 +19,7 @@ type RRvideoConfig = {
input: string;
output?: string;
headless?: boolean;
launchOptions?: LaunchOptions;
// A number between 0 and 1. The higher the value, the better the quality of the video.
resolutionRatio?: number;
// A callback function that will be called when the progress of the replay is updated.
Expand All @@ -29,6 +31,7 @@ const defaultConfig: Required<RRvideoConfig> = {
input: '',
output: 'rrvideo-output.webm',
headless: true,
launchOptions: {},
// A good trade-off value between quality and file size.
resolutionRatio: 0.8,
onProgressUpdate: () => {
Expand Down Expand Up @@ -126,6 +129,7 @@ export async function transformToVideo(options: RRvideoConfig) {
Object.assign(config.rrwebPlayer, scaledViewport);
const browser = await chromium.launch({
headless: config.headless,
...config.launchOptions
});
const context = await browser.newContext({
viewport: scaledViewport,
Expand Down

0 comments on commit 78c9a91

Please sign in to comment.