import type { CDPSession, Page } from "puppeteer-core"; /** * Executes a CDP (Chrome DevTools Protocol) operation with proper session lifecycle management. This helper handles the common pattern of: * 1. Creating a CDP session attached to the page's target * 2. Getting the browser window ID for the page * 3. Calling the provided operation with the session and window ID * 4. Gracefully handling errors when the page is closed during the operation * * The session is created fresh for each call rather than being reused because CDP sessions become invalid when the page navigates or closes. Creating a new * session ensures we always have a valid connection. * @param page - The Puppeteer page object to create a CDP session for. * @param operation - An async function that receives the CDP session and window ID. The operation can use any CDP commands via session.send(). * @returns The result of the operation, or undefined if the page was closed or an error occurred. */ export declare function withCDPSession(page: Page, operation: (session: CDPSession, windowId: number) => Promise): Promise; /** * Resizes the browser window to match our target viewport dimensions and optionally minimizes it. This function solves the problem of ensuring the video content * area exactly matches our configured viewport size. * * The complication is that browser windows have "chrome" - the title bar, toolbar, borders, and other UI elements that take up space. If we set the window size * to 1280x720, the actual content area will be smaller (perhaps 1280x670 after accounting for the toolbar). To get a 1280x720 content area, we need to add the * chrome dimensions to our window size. * * This function: * 1. Measures the current chrome dimensions by comparing window.outerWidth/Height to window.innerWidth/Height * 2. Sets the window size to viewport + chrome dimensions, giving us the exact viewport size we want * 3. Verifies the resize took effect by reading back the window bounds, retrying if dimensions don't match * 4. Optionally minimizes the window to reduce GPU usage while still allowing capture * @param page - The Puppeteer page object. * @param shouldMinimize - Whether to minimize the window after resizing. Set to true for stream pages (to reduce GPU usage) and false for debug pages (where * visibility is desired). */ export declare function resizeAndMinimizeWindow(page: Page, shouldMinimize: boolean): Promise; /** * Un-minimizes the browser window, restoring it to normal state. This is used when the user needs to interact with the browser, such as during the authentication * login flow where the user must complete TV provider authentication in the visible browser window. * @param page - The Puppeteer page object. */ export declare function unminimizeWindow(page: Page): Promise;