import { type CacheDirContext } from "./cacheDir.js"; import { type Logger } from "./loader.js"; export type BrowserAssetName = "chrome" | "firefox" | "chromedriver" | "geckodriver"; /** Outcome of executing a driver binary to confirm it actually works. */ export interface DriverVerifyResult { ok: boolean; version?: string; error?: string; } /** * Injectable executor for `verifyDriverBinary`. Resolves with the child's * exit code (null when the process couldn't be spawned) plus its captured * output. Tests inject a fake; production uses {@link defaultDriverExec}. */ export type DriverExec = (binaryPath: string, args: string[], timeoutMs: number) => Promise<{ code: number | null; stdout: string; stderr: string; }>; /** * Execute a driver binary and confirm it is functional — i.e. it runs and * reports a parseable version. This is the single guard that stops a * present-but-broken driver (e.g. a partially downloaded geckodriver on * Windows that exists on disk but doesn't run) from being trusted as * installed. Driver-agnostic: works for geckodriver, chromedriver, and * safaridriver. */ export declare function verifyDriverBinary(driverName: string, binaryPath: string, options?: { exec?: DriverExec; timeoutMs?: number; }): Promise; /** * Map a browser name to the installable asset(s) it needs to drive — the * browser binary plus its WebDriver. This is the single source of truth the * runtime install paths share (the runTests pre-flight and the runner's * on-demand context-gate install both consume it). Safari/webkit ship with * macOS, so they have no installable assets; unknown names map to nothing. * * Only schema-valid driver browser names are mapped. "chromium" is * intentionally absent: it isn't in the runner's KNOWN_BROWSERS, so installing * Chrome for it wouldn't make the context runnable end-to-end (isSupportedContext * and getDriverCapabilities key off the exact name) — mapping it would install * assets that then go unused. */ export declare function requiredBrowserAssets(name: string | undefined): BrowserAssetName[]; /** * The one place browser channel selection lives. Exact buildIds are NOT * pinned in source — they are resolved against @puppeteer/browsers at * install time so an `install browsers --force` always picks up the * channel's current build. */ export declare const BROWSER_CHANNELS: { readonly chrome: "stable"; readonly firefox: "latest"; readonly chromedriver: "stable"; readonly geckodriver: "latest"; }; export interface EnsureBrowserResult { /** Absolute path to the executable (or driver binary). */ path: string; /** Resolved buildId / version string for the installed asset. */ version: string; /** True when the installed buildId is older than the channel's current. */ outdated: boolean; } export interface BrowserDeps { logger?: Logger; /** * Injected `@puppeteer/browsers` namespace for tests. When omitted the * helper lazy-loads it via loadHeavyDep. */ browsersModule?: any; /** Injected `geckodriver` namespace for tests. */ geckodriverModule?: any; /** Injected driver executor for `verifyDriverBinary` (tests stub it). */ verifyExec?: DriverExec; /** Wall-clock for freshness gating — tests inject a fixed time. */ now?: () => Date; } export interface EnsureBrowserOptions { ctx?: CacheDirContext; deps?: BrowserDeps; force?: boolean; } /** * Install (or refresh) a browser asset into /browsers. * * Missing → install latest channel buildId. Present and matches channel → * no-op. Present and outdated → warn (with update instructions) and proceed * with the installed version. force=true reinstalls and prunes the old * buildId from the cache. * * Concurrent calls for the same (name, cacheDir) share a single * in-flight promise so parallel installs can't corrupt each other. */ export declare function ensureBrowserInstalled(name: BrowserAssetName, options?: EnsureBrowserOptions): Promise; /** * Probe a browsers cache dir for the geckodriver binary a download wrote. * Returns its path if found at the cache root or one level deep (some layouts * nest under a version dir), else undefined. Exported so the availability probe * (Layer 2 in core/config) can resolve the same binary the install path uses * when the geckodriver module exposes no `.path` — otherwise the functional * driver gate would silently not run for a present-but-broken geckodriver. */ export declare function geckodriverBinaryInCache(cacheDir: string): string | undefined; /** * Read the installed-browsers record without resolving or installing * anything. Mirrors @puppeteer/browsers.getInstalledBrowsers() but reads * from our cache record rather than rescanning the filesystem. */ export declare function getInstalledBrowsers(ctx?: CacheDirContext): Array<{ name: string; installedVersion: string; installedAt: string; latestKnownVersion?: string; }>; //# sourceMappingURL=browsers.d.ts.map