( projectDir: string, outputPath: string, options: RenderOptions, )
| 1342 | |
| 1343 | // fallow-ignore-next-line complexity |
| 1344 | export async function renderLocal( |
| 1345 | projectDir: string, |
| 1346 | outputPath: string, |
| 1347 | options: RenderOptions, |
| 1348 | ): Promise<SingleRenderResult> { |
| 1349 | const preflight = await runEnvironmentChecks({ |
| 1350 | projectDir, |
| 1351 | browserPath: options.browserPath, |
| 1352 | includeBrowser: true, |
| 1353 | includeDisk: true, |
| 1354 | includeWindowsUnc: true, |
| 1355 | }); |
| 1356 | const failedChecks = preflight.outcomes.filter((outcome) => !outcome.ok); |
| 1357 | if (failedChecks.length > 0) { |
| 1358 | for (const check of failedChecks) { |
| 1359 | errorBox(check.title ?? `${check.name} check failed`, check.detail, check.hint); |
| 1360 | } |
| 1361 | process.exit(1); |
| 1362 | } |
| 1363 | if (!options.quiet) { |
| 1364 | for (const outcome of preflight.outcomes) { |
| 1365 | if (outcome.level === "warn") { |
| 1366 | console.warn(c.warn(` ${outcome.name}: ${outcome.detail}`)); |
| 1367 | if (outcome.hint) console.warn(c.dim(` ${outcome.hint}`)); |
| 1368 | } |
| 1369 | } |
| 1370 | } |
| 1371 | |
| 1372 | if (preflight.ffmpegPath) process.env.HYPERFRAMES_FFMPEG_PATH = preflight.ffmpegPath; |
| 1373 | if (preflight.ffprobePath) process.env.HYPERFRAMES_FFPROBE_PATH = preflight.ffprobePath; |
| 1374 | if (preflight.browser?.executablePath && !process.env.PRODUCER_HEADLESS_SHELL_PATH) { |
| 1375 | process.env.PRODUCER_HEADLESS_SHELL_PATH = preflight.browser.executablePath; |
| 1376 | } |
| 1377 | |
| 1378 | const producer = await loadProducer(); |
| 1379 | |
| 1380 | const startTime = Date.now(); |
| 1381 | const logger = createRenderTelemetryLogger( |
| 1382 | producer.createConsoleLogger?.(options.debug ? "debug" : "info") ?? createNoopProducerLogger(), |
| 1383 | ); |
| 1384 | |
| 1385 | const job = producer.createRenderJob({ |
| 1386 | fps: options.fps, |
| 1387 | quality: options.quality, |
| 1388 | format: options.format, |
| 1389 | gifLoop: options.gifLoop, |
| 1390 | workers: options.workers, |
| 1391 | useGpu: options.gpu, |
| 1392 | logger, |
| 1393 | producerConfig: producer.resolveConfig({ |
| 1394 | browserGpuMode: options.browserGpuMode ?? "software", |
| 1395 | ...(options.pageNavigationTimeoutMs != null |
| 1396 | ? { pageNavigationTimeout: options.pageNavigationTimeoutMs } |
| 1397 | : {}), |
| 1398 | ...(options.protocolTimeout != null && { protocolTimeout: options.protocolTimeout }), |
| 1399 | ...(options.playerReadyTimeout != null && { playerReadyTimeout: options.playerReadyTimeout }), |
| 1400 | ...(options.vp9CpuUsed != null ? { vp9CpuUsed: options.vp9CpuUsed } : {}), |
| 1401 | }), |
no test coverage detected