mirror of
https://github.com/tabler/tabler.git
synced 2026-10-12 05:06:55 +04:00
Add ESLint with typescript-eslint and fix its findings (#3256)
This commit is contained in:
1 parent
0e90f8fd16
commit
6394af0a59
40 files changed
+935
-339
No files matched your search
@@ -134,8 +134,8 @@ async function main() {
|
||||
await startPreviewServer()
|
||||
// Interrupting the script (Ctrl+C) must not leave the preview server behind
|
||||
// squatting on the port for the next run to collide with.
|
||||
process.once('SIGINT', stopPreviewServer)
|
||||
process.once('SIGTERM', stopPreviewServer)
|
||||
process.once('SIGINT', () => void stopPreviewServer())
|
||||
process.once('SIGTERM', () => void stopPreviewServer())
|
||||
|
||||
try {
|
||||
const browser = await chromium.launch()
|
||||
|
||||
@@ -145,9 +145,9 @@ function systemFfmpeg(): string | undefined {
|
||||
function resample(frames: Frame[], end: number): Buffer[] {
|
||||
const out: Buffer[] = []
|
||||
let index = 0
|
||||
for (let t = frames[0]!.time; t <= end; t += 1 / FPS) {
|
||||
while (index + 1 < frames.length && frames[index + 1]!.time <= t) index++
|
||||
out.push(frames[index]!.data)
|
||||
for (let t = frames[0].time; t <= end; t += 1 / FPS) {
|
||||
while (index + 1 < frames.length && frames[index + 1].time <= t) index++
|
||||
out.push(frames[index].data)
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -269,9 +269,9 @@ async function recordOne(page: Page, client: CDPSession, slug: string, theme: 'l
|
||||
await moveCursor(page, { x: width / 2, y: height + 40 }, 0)
|
||||
|
||||
const frames: Frame[] = []
|
||||
const onFrame = async (event: { data: string; sessionId: number }) => {
|
||||
const onFrame = (event: { data: string; sessionId: number }) => {
|
||||
frames.push({ data: Buffer.from(event.data, 'base64'), time: Date.now() / 1000 })
|
||||
await client.send('Page.screencastFrameAck', { sessionId: event.sessionId }).catch(() => {})
|
||||
void client.send('Page.screencastFrameAck', { sessionId: event.sessionId }).catch(() => {})
|
||||
}
|
||||
client.on('Page.screencastFrame', onFrame)
|
||||
await client.send('Page.startScreencast', { format: 'jpeg', quality: 92, maxWidth: width, maxHeight: height, everyNthFrame: 1 })
|
||||
@@ -303,8 +303,8 @@ async function main() {
|
||||
|
||||
console.log(`Starting preview server on port ${PORT}…`)
|
||||
await startPreviewServer()
|
||||
process.once('SIGINT', stopPreviewServer)
|
||||
process.once('SIGTERM', stopPreviewServer)
|
||||
process.once('SIGINT', () => void stopPreviewServer())
|
||||
process.once('SIGTERM', () => void stopPreviewServer())
|
||||
|
||||
try {
|
||||
const browser = await chromium.launch()
|
||||
@@ -321,7 +321,7 @@ async function main() {
|
||||
|
||||
// RECORD_FRAMES="0.5,2,4" also writes those seconds as JPEG stills, for a quick look without a player.
|
||||
for (const second of (process.env.RECORD_FRAMES ?? '').split(',').filter(Boolean).map(Number)) {
|
||||
const frame = sampled[Math.min(sampled.length - 1, Math.round(second * FPS))]!
|
||||
const frame = sampled[Math.min(sampled.length - 1, Math.round(second * FPS))]
|
||||
writeFileSync(path.join(outDir, `${name}-${second}s.jpg`), frame)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user