import { type Listener } from './emitter.js'; import { PageGenerated } from './page-generated.js'; import { Transport } from './transport.js'; import type { EvaluateOptions, AddScriptTagOptions, AddStyleTagOptions, GotoOptions, ResponseFilterOptions, SendOptions, WaitForFunctionOptions, WaitForEventOptions, WaitForRequestOptions, WaitForResponseOptions } from './types/options.js'; import type { PageEventMap } from './types/events.js'; import type { CookieInput } from './types/inputs.js'; import type { CookieResponse, AddScriptTagResponse, AddStyleTagResponse, HTTPResponse, HTTPHeadersResponse, ResponseResponse, SelectResponse, WaitForRequestResponse, WaitForResponseResponse, WaitForFunction, WaitForEvent } from './types/responses.js'; /** * Page events surfaced through the puppeteer-style emitter. The schema-derived * {@link PageEventMap} entries (`console`/`request`/`response`) each open a * GraphQL subscription lazily; `error` is emitted if opening or streaming one * fails (it never throws, matching puppeteer's non-fatal emitter errors). * `message` carries every raw frame the transport receives — including * server-pushed frames with no matching operation (e.g. data over a custom * {@link ConnectionTransport}); it is not subscription-backed. */ export type PageEvents = PageEventMap & { error: Error; message: string; }; /** * The Page client. Almost every method is generated into {@link PageGenerated} * by `npm run codegen` straight from the GraphQL schema. This class provides * the concrete `execute` the base depends on, plus the few methods whose * ergonomic (puppeteer-compatible) signatures can't be expressed declaratively: * varargs, `string | Options` unions, function serialization, and Record→input * transforms. These override the generated versions via subclassing. */ /** A raw-frame listener registered via {@link Page.on}/{@link Page.subscribe}. */ export type MessageListener = (message: string) => void; export declare class Page extends PageGenerated { #private; private readonly transport; private _closed; constructor(transport: Transport); get closed(): boolean; /** Sugar for {@link Page.on}('message', …) that returns an unsubscribe fn. */ subscribe(listener: MessageListener): () => void; /** * Register a listener for a page event. Attaching the first listener for a * subscription-backed event (`console`, `request`, `response`) lazily opens * the underlying stream; see {@link PageEvents}. */ on(event: K, listener: Listener): this; /** Register a one-shot listener, auto-removed after it fires once. */ once(event: K, listener: Listener): this; /** * Remove a listener. Removing the last listener for a subscription-backed * event closes the underlying stream. */ off(event: K, listener: Listener): this; /** Emit an event to its listeners (primarily internal). */ emit(event: K, payload: PageEvents[K]): boolean; /** Remove all listeners for an event, or for every event when omitted. */ removeAllListeners(event?: K): this; protected execute(mutationName: string, args: Record | null, responseType: string, timeout?: number): Promise; /** Opt-in remote response metadata keeps new clients compatible with older BQL schemas. */ goto(url: string, options?: GotoOptions): Promise; /** Opt-in body-encoding flag keeps new clients compatible with older BQL schemas. */ response(options?: ResponseFilterOptions): Promise; /** Varargs collapse to a single value or an array (puppeteer `select`). */ select(selector: string, ...values: string[]): Promise; /** Varargs of cookie inputs. */ setCookie(...cookies: CookieInput[]): Promise; /** Accepts a `Record` and reshapes it into the GraphQL `[HeaderInput]`. */ setExtraHTTPHeaders(headers: Record): Promise; /** Serializes a function argument and unwraps the scalar result value. */ evaluate(content: string | ((...args: unknown[]) => unknown), options?: EvaluateOptions): Promise; /** * Preserves the REST compatibility mode that considers an async function * complete once its returned promise settles, without changing the default * BrowserQL predicate semantics for other callers. */ waitForFunction(fn: string, options?: WaitForFunctionOptions): Promise; /** * Leaves enough transport time for BrowserQL to return its own timeout * result instead of racing the client timer at the same millisecond. */ waitForEvent(event: string, options?: WaitForEventOptions): Promise; /** * Reads Puppeteer's client-only `path` option before sending the BrowserQL * mutation. Exactly one content source is required. */ addScriptTag(options?: AddScriptTagOptions): Promise; /** * Reads Puppeteer's client-only `path` option before sending the BrowserQL * mutation. Exactly one content source is required. */ addStyleTag(options?: AddStyleTagOptions): Promise; /** Accepts a bare URL string or an options object. */ waitForRequest(urlOrOptions?: string | WaitForRequestOptions): Promise; /** Accepts a bare URL string or an options object. */ waitForResponse(urlOrOptions?: string | WaitForResponseOptions): Promise; /** Milliseconds → the GraphQL `time` arg, with a transport timeout cushion. */ waitForTimeout(ms: number): Promise; send(query: string, options?: SendOptions): Promise; close(): Promise; } //# sourceMappingURL=page.d.ts.map