Skip to content

Commit

Permalink
fix: eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
YunFeng0817 committed Mar 19, 2023
1 parent 49a94c5 commit a3a3739
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 2,532 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@
"eslint-plugin-compat": "^4.0.2",
"eslint-plugin-jest": "^27.1.3",
"eslint-plugin-tsdoc": "^0.2.16",
"lerna": "^4.0.0",
"markdownlint": "^0.25.1",
"markdownlint-cli": "^0.31.1",
"prettier": "2.8.4",
"turbo": "^1.2.4",
"typescript": "^4.7.3"
},
"scripts": {
"lerna": "lerna",
"build:all": "yarn run concurrently --success=all -r -m=1 'yarn workspaces-to-typescript-project-references' 'yarn turbo run prepublish'",
"test": "yarn run concurrently --success=all -r -m=1 'yarn workspaces-to-typescript-project-references --check' 'yarn turbo run test'",
"test:watch": "yarn turbo run test:watch",
Expand Down
17 changes: 11 additions & 6 deletions packages/rrvideo/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as fs from 'fs';
import * as path from 'path';
import minimist from 'minimist';
import type { RRwebPlayerOptions } from 'rrweb-player';
import { transformToVideo } from './index';

const argv = minimist(process.argv.slice(2));
Expand All @@ -13,15 +14,19 @@ if (!argv.input) {
let config = {};

if (argv.config) {
const configPath = path.isAbsolute(argv.config)
? argv.config
: path.resolve(process.cwd(), argv.config);
config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
const configPathStr = argv.config as string;
const configPath = path.isAbsolute(configPathStr)
? configPathStr
: path.resolve(process.cwd(), configPathStr);
config = JSON.parse(fs.readFileSync(configPath, 'utf-8')) as Omit<
RRwebPlayerOptions['props'],
'events'
>;
}

transformToVideo({
input: argv.input,
output: argv.output,
input: argv.input as string,
output: argv.output as string,
rrwebPlayer: config,
})
.then((file) => {
Expand Down
35 changes: 19 additions & 16 deletions packages/rrvideo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ const defaultConfig: Required<RRvideoConfig> = {
output: 'rrvideo-output.mp4',
headless: true,
fps: 15,
cb: () => {},
cb: () => {
//
},
startDelayTime: 1000,
rrwebPlayer: {},
};
Expand All @@ -53,7 +55,7 @@ function getHtml(
'<\\/script>',
)};
/*-->*/
const userConfig = ${config ? JSON.stringify(config) : {}};
const userConfig = ${JSON.stringify(config || {})};
window.replayer = new rrwebPlayer({
target: document.body,
props: {
Expand Down Expand Up @@ -91,22 +93,25 @@ export class RRvideo {
await this.page.goto('about:blank');

await this.page.exposeFunction('onReplayFinish', () => {
this.finishRecording();
void this.finishRecording();
});

const eventsPath = path.isAbsolute(this.config.input)
? this.config.input
: path.resolve(process.cwd(), this.config.input);
const events = JSON.parse(fs.readFileSync(eventsPath, 'utf-8'));
const events = JSON.parse(
fs.readFileSync(eventsPath, 'utf-8'),
) as eventWithTime[];

await this.page.setContent(getHtml(events, this.config.rrwebPlayer));

setTimeout(() => {
this.startRecording();
this.page.evaluate('window.replayer.play();');
void this.startRecording().then(() => {
return this.page.evaluate('window.replayer.play();');
});
}, this.config.startDelayTime);
} catch (error) {
this.config.cb('', error);
this.config.cb('', error as Error);
}
}

Expand Down Expand Up @@ -149,16 +154,14 @@ export class RRvideo {

let processError: Error | null = null;

const timer = setInterval(async () => {
const timer = setInterval(() => {
if (this.state === 'recording' && !processError) {
try {
const buffer = await wrapperEl.screenshot({
void wrapperEl
.screenshot({
encoding: 'binary',
});
ffmpegProcess.stdin.write(buffer);
} catch (error) {
// ignore
}
})
.then((buffer) => ffmpegProcess.stdin.write(buffer))
.catch();
} else {
clearInterval(timer);
if (this.state === 'closed' && !processError) {
Expand Down Expand Up @@ -209,6 +212,6 @@ export function transformToVideo(config: RRvideoConfig): Promise<string> {
resolve(file);
},
});
rrvideo.transform();
void rrvideo.transform();
});
}
11 changes: 10 additions & 1 deletion packages/rrvideo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"composite": true,
"target": "ES6",
"module": "commonjs",
"declaration": true,
Expand All @@ -14,5 +15,13 @@
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
},
"references": [
{
"path": "../rrweb-player"
},
{
"path": "../types"
}
]
}
2 changes: 1 addition & 1 deletion packages/rrweb-player/src/Controller.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
export const playRange = (
timeOffset: number,
endTimeOffset: number,
startLooping: boolean = false,
startLooping = false,
afterHook: undefined | (() => void) = undefined,
) => {
if (startLooping) {
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb-player/src/Player.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
export const playRange = (
timeOffset: number,
endTimeOffset: number,
startLooping: boolean = false,
startLooping = false,
afterHook: undefined | (() => void) = undefined,
) => {
controller.playRange(timeOffset, endTimeOffset, startLooping, afterHook);
Expand Down
15 changes: 4 additions & 11 deletions packages/web-extension/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"module": "ESNext",
"target": "es2016",
"lib": [
"DOM",
"ESNext"
],
"lib": ["DOM", "ESNext"],
"strict": true,
"esModuleInterop": true,
"incremental": false,
Expand All @@ -17,16 +15,11 @@
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"~/*": [
"src/*"
]
"~/*": ["src/*"]
},
"jsx": "react-jsx"
},
"exclude": [
"dist",
"node_modules"
],
"exclude": ["dist", "node_modules"],
"references": [
{
"path": "../rrweb"
Expand Down
6 changes: 6 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
},
{
"path": "packages/types"
},
{
"path": "packages/rrvideo"
},
{
"path": "packages/web-extension"
}
],
"files": [],
Expand Down
Loading

0 comments on commit a3a3739

Please sign in to comment.