web-snaps
Version:
Browser automation with automatic snapshotting.
29 lines (28 loc) • 1.13 kB
TypeScript
import { type MaybePromise } from '@augment-vir/common';
import { type BrowserOptions } from './init-browser.js';
import { type LoadedBrowser } from './loaded-browser.js';
/**
* Params for {@link setupBrowser} and {@link withBrowserContext}.
*
* @category Internal
*/
export type BrowserSetupParams<Context> = Readonly<{
context: MaybePromise<Context>;
userDataDirPath: string;
options?: Readonly<BrowserOptions> | undefined;
}>;
/**
* Setup a browser instance for use with the web-snaps package.
*
* @category Internal
*/
export declare function setupBrowser<Context>({ context: rawContext, userDataDirPath, options, }: BrowserSetupParams<Context>): Promise<LoadedBrowser<Context>>;
/**
* Run a callback with a browser instance. The browser will be cleanly closed when the callback is
* finished (or fails).
*
* @category Internal
*/
export declare function withBrowserContext<Context, T = void>(params: BrowserSetupParams<Context>,
/** Calls this callback and then automatically closes the browser afterwards. */
callback: (params: Readonly<LoadedBrowser<Context>>) => MaybePromise<T>): Promise<T>;