UNPKG

histoire

Version:

A fast story book powered by Vite

33 lines • 1.96 kB
import type { Browser } from 'playwright'; /** Pool-owned process lease; callers still create and close a fresh context per operation. */ export interface BrowserProcessLease { /** The exact connected Playwright browser assigned to this operation. */ readonly browser: Browser; /** Returns a healthy browser to the idle pool after operation cleanup succeeds. */ release: () => Promise<void>; /** Closes this browser immediately when operation cleanup is uncertain. */ discard: () => Promise<void>; } /** One generation-scoped browser process pool owned by a setup owner. */ export interface BrowserProcessPool { /** Acquires the retained browser or lazily launches one when none is reusable. */ acquire: (launch: () => Promise<Browser>) => Promise<BrowserProcessLease>; /** Stops future acquisitions; an in-flight operation remains usable until release. */ retire: () => Promise<void>; /** Stops admission and confirms cleanup of current or late-acquired browser. */ close: () => Promise<void>; } /** Dependencies for one private browser process pool. */ export interface BrowserProcessPoolOptions { /** Healthy process lifetime after its last operation releases the lease. */ readonly idleTimeoutMs: number; /** Confirmed Playwright process cleanup; production uses the shared cleanup helper. */ readonly closeBrowser?: (browser: Browser) => Promise<unknown>; /** Invalidates the owner's candidate receipt after an unexpected browser exit. */ readonly onBrowserDisconnected?: (browser: Browser) => void; /** Reports cleanup uncertainty even when idle expiry closes the process in background. */ readonly onCleanupFailure?: (error: unknown) => void; } /** Creates one reusable browser process while preserving exclusive operation leases. */ export declare function createBrowserProcessPool(options: BrowserProcessPoolOptions): BrowserProcessPool; //# sourceMappingURL=pool.d.ts.map