import type { Frame, Page } from "puppeteer-core"; /** * Registers an AbortController for a stream. Called when a stream is created. * @param streamIdStr - The stream ID string (e.g., "cnn-5jecl6"). * @param controller - The AbortController for this stream. */ export declare function registerAbortController(streamIdStr: string, controller: AbortController): void; /** * Unregisters an AbortController for a stream. Called when a stream is terminated. * @param streamIdStr - The stream ID string. */ export declare function unregisterAbortController(streamIdStr: string): void; /** * Gets the AbortSignal for a stream, if one exists. * @param streamIdStr - The stream ID string. * @returns The AbortSignal if found, undefined otherwise. */ export declare function getAbortSignal(streamIdStr: string): AbortSignal | undefined; /** * Gets the AbortController for a stream, if one exists. * @param streamIdStr - The stream ID string. * @returns The AbortController if found, undefined otherwise. */ export declare function getAbortController(streamIdStr: string): AbortController | undefined; /** * Custom error class for timeout errors. This allows callers to distinguish timeout errors from other errors. */ export declare class EvaluateTimeoutError extends Error { constructor(timeoutMs: number); } /** * Custom error class for abort errors. This allows callers to distinguish abort errors from other errors. */ export declare class EvaluateAbortError extends Error { constructor(); } /** * Executes a Puppeteer evaluate call with abort and timeout support. This wrapper provides immediate cancellation when a stream is terminated and a safety timeout to * prevent hanging on unresponsive browsers. * * If running within a stream context (via AsyncLocalStorage), the abort signal for that stream is used. If no stream context is available, only the timeout is applied. * @param context - The Page or Frame to evaluate in. * @param pageFunction - The function to evaluate in the browser context. * @param args - Arguments to pass to the function (optional). * @param timeoutMs - Timeout in milliseconds (default: 15000). * @returns The result of the evaluate call. * @throws EvaluateAbortError if the stream was terminated. * @throws EvaluateTimeoutError if the timeout was reached. * @throws Any error from the underlying evaluate call. */ export declare function evaluateWithAbort(context: Frame | Page, pageFunction: (...args: Args) => T, args?: Args, timeoutMs?: number): Promise;