import { execFileSync } from "node:child_process"; import path from "node:path"; /** * Launch parameters shared by the Playwright config and the shared-session * fixture, so both modes (isolated and reused context) drive the same browser. */ export const DEPLOYED_ORIGIN = (process.env.WEB_ORIGIN ?? "https://49.232.250.35:58014").replace(/\/+$/, ""); export const DEPLOYED_VIEWPORT = { width: 1600, height: 900 }; export function chromePath(): string | undefined { if (process.env.CHROME_PATH) return process.env.CHROME_PATH; try { return execFileSync("which", ["google-chrome"], { encoding: "utf8" }).trim() || undefined; } catch { return undefined; } } const hardwareArgs = [ "--no-sandbox", "--use-gl=angle", "--use-angle=gl", "--ignore-gpu-blocklist", "--enable-gpu-rasterization", "--enable-zero-copy", "--enable-unsafe-webgpu", ]; const swiftshaderArgs = [ "--no-sandbox", "--use-gl=swiftshader", "--enable-unsafe-swiftshader", "--enable-unsafe-webgpu", "--enable-dawn-features=allow_unsafe_apis", "--use-webgpu-adapter=swiftshader", ]; export function browserArgs(): string[] { const mode = process.env.GPU_MODE ?? (process.env.DISPLAY ? "hardware" : "swiftshader"); return mode === "hardware" ? hardwareArgs : swiftshaderArgs; } /** Chromium profile kept between runs: the 300 MB engine is revalidated, not re-downloaded. */ export function profileDir(repoRoot: string): string { return process.env.DEPLOYED_PROFILE ?? path.join(repoRoot, "web/.cache/deployed-profile"); }