/** * page-scripts.ts — Browser-context functions passed to Playwright's * page.evaluate() / page.addInitScript(). * * IMPORTANT: every function in this module is serialized by Playwright and * executed INSIDE the browser page, NOT in Node. They must therefore be * self-contained (no references to Node/module-scope variables) and may only * use browser globals (document, window, getComputedStyle, CSS, …). * * They are REAL functions (not strings): Playwright treats a string * pageFunction as a JS expression and never calls it, so a string arrow * function would silently do nothing and ignore its argument. Passing the * function directly lets Playwright serialize and invoke it with the arg. * * DOM typing is provided by the MODULE-SCOPED ambient declarations below. They * intentionally avoid `/// ` and `declare global`, both * of which leak DOM types into the rest of the (Node) codebase; module-scoped * `declare const` bindings are visible only within this file, so the global * tsconfig `lib: ["ES2022"]` (no "DOM") still catches stray DOM usage elsewhere. */ /** * Extract Playwright-friendly element info for the element at a point. * Returns an ElementInfo-compatible object or null. */ export declare const ELEMENT_AT_POINT_SCRIPT: (point: { x: number; y: number; }) => { selector: string; tagName: string; type: string | undefined; text: string | undefined; role: string | undefined; label: string | undefined; href: string | undefined; } | null; /** * Read the CSS `cursor` value of the element at a point. Returns 'default' when * no element is found or the computed cursor is empty. */ export declare const CURSOR_AT_POINT_SCRIPT: (point: { x: number; y: number; }) => string; /** * Extract info about the currently focused element. */ export declare const FOCUSED_ELEMENT_SCRIPT: () => { selector: string; tagName: string; type: string | undefined; role: string | undefined; label: string | undefined; } | null; /** * Read the current selection. Prefers the selection range of a focused * input/textarea, falling back to the document selection. Returns an empty * string when nothing is selected. */ export declare const GET_SELECTED_TEXT_SCRIPT: () => string; /** * Install (idempotently) focus/value/selection reporting for simple * input/textarea elements. Reports through the `window.__onBrowserFocus` * binding exposed by Playwright. * * Listener registration is guarded by `window.__browserFocusReportingInstalled` * so re-evaluating the script does not double-register handlers. The INITIAL * report runs on EVERY evaluation (outside the guard) so an element already * focused at injection time (e.g. an autofocused login field) is surfaced. * * Browser-side failures of the exposed binding are warned at most once here; * the Node side (browser-session.ts exposeBinding wrapper) adds server-log * observability for binding callback failures. */ export declare const FOCUS_REPORTING_SCRIPT: () => void; /** * Reflect a value into the currently-focused reporting-target input/textarea * using the native value setter + InputEvent('input') dispatch, so React-style * controlled components do not roll the value back. Optionally applies a * selection range. No-op when the active element is not a reporting target. */ export declare const SET_FOCUSED_INPUT_VALUE_SCRIPT: (args: { value: string; selectionStart?: number; selectionEnd?: number; }) => void; //# sourceMappingURL=page-scripts.d.ts.map