import { sleepLong, untilAborted, withTimeout } from "@oh-my-pi/pi-utils"; import type { CustomQueryHandler, ElementHandle, Frame, default as PuppeteerInstance, Puppeteer as PuppeteerClass, WaitForSelectorOptions, } from "puppeteer-core"; import { puppeteerTimeoutError } from "./launch"; import { isNavigatedContextError } from "./navigation"; /** Root node Puppeteer passes to a custom query handler (the document for page-level queries). */ type QueryNode = Parameters>[0]; interface QueryRoot { querySelectorAll(selector: string): readonly Element[]; } // Each handler is serialized with `Function.prototype.toString()` — by Puppeteer's custom query // handler registry and by the Tern page kit — so it MUST stay self-contained: no references to // module scope, imports, or other handlers. /** * `label/` handler: controls whose `