import type { ElementConfig, ElementResult, ScreenComparison } from './types.js'; import type { ScreenConfig } from './screen-config.js'; import { ScreenElement, type MatchOptions, type WaitForOptions } from './element.js'; import { TextElement, type TextQuery, type TextElementOptions } from './text-element.js'; import type { Page } from '@playwright/test'; import { type FieldRead } from './utils/ocr.js'; export type ScreenExtractor = { loadForms(blankFormPath: string, filledFormPath: string): Promise; locateOnScreenshot(screenshotPath: string, config: ElementConfig): Promise; extractElements?(configs: readonly ElementConfig[] | ElementConfig[]): Promise; extractFields?(configs: readonly ElementConfig[] | ElementConfig[]): Promise<{ fields: ElementResult[]; totalFields: number; filledFields: number; emptyFields: number; }>; }; export type ScreenHost = { extractor: ScreenExtractor; screen: ScreenConfig; shotDir: string; overlay?: boolean; /** Override global unhoverBeforeCapture for this bind. */ unhover?: boolean; /** init()-level read override — wins over index.json, loses to call site. */ initRead?: FieldRead; }; /** * Playwright-style screen result wrapper * Provides chainable access to elements with assertions */ export declare class ScreenResult { private comparison; private page?; private host?; private dirty; constructor(comparison: ScreenComparison, page?: Page | undefined, host?: ScreenHost | undefined); /** * Construct a ScreenResult pre-populated from an already-taken screenshot. * Used by screen handler dispatch — avoids an extra screenshot round-trip. */ static fromShot(shot: string, page: Page, host: ScreenHost): Promise; /** * Bind a screen to a live page so element().waitFor / fill / click can screenshot and match. */ static bind(page: Page, extractor: ScreenExtractor, screen: ScreenConfig, shotDir: string, options?: { overlay?: boolean; unhover?: boolean; initRead?: FieldRead; }): ScreenResult; /** * Get an element by name * Returns a ScreenElement with chainable assertions */ element(name: string): ScreenElement; elementResult(name: string, partName?: string): ElementResult | undefined; matchOptions(name: string, partName?: string): MatchOptions; markDirty(): void; ensureFresh(): Promise; /** * Wait until this screen is showing, then OCR-extract every field. * * Behaviour is controlled by screen.ready: * string — one element must reach the visible threshold * string[] — all elements must reach the threshold (sequential) * { any: [...] }— any one element must reach the threshold (single poll loop) */ waitFor(options?: WaitForOptions): Promise; private waitForAny; /** * Poll the live screenshot until this element's template is visible (or hidden). * On success, OCR-extracts every field on the screen. */ waitForElement(name: string, options?: WaitForOptions): Promise; /** * Screenshot the live page and OCR-extract every field on this screen. */ refresh(): Promise; private captureLive; private loadExtracted; paintOverlay(result: ElementResult, label?: string): Promise; hideOverlay(): Promise; private captureWords; /** * Find the first occurrence of text on screen via OCR. * Waits until the text is visible (by default). * Use for dynamic / ad-hoc content that is not registered in index.json — * dropdown options, toast messages, menu rows, table cells. * * @param query - Exact string (case-insensitive) or RegExp. * @param options.timeout - How long to wait for the text to appear (ms). Default 15 000. */ getByText(query: TextQuery, options?: TextElementOptions): Promise; /** * Find all occurrences of text on screen via OCR. * Returns immediately with whatever matches are currently visible — no implicit wait. * Use for list rows, repeated badges, or any case where multiple matches are expected. */ getAllByText(query: TextQuery): Promise; /** * Assert that the given text is visible anywhere on screen. * Useful for smoke-checking dynamic feedback without registering an element. * * @param query - Exact string (case-insensitive) or RegExp. * @param options.timeout - How long to poll (ms). Default: expectTimeout(). */ toContainText(query: TextQuery, options?: TextElementOptions): Promise; /** * Get all elements */ allElements(): ScreenElement[]; /** * Get all filled elements */ filledElements(): ScreenElement[]; /** * Get all empty elements */ emptyElements(): ScreenElement[]; /** * Count total elements */ count(): number; /** * Count filled elements */ filledCount(): number; /** * Count empty elements */ emptyCount(): number; /** * Check if element exists */ hasElement(name: string): boolean; /** * Get raw comparison data */ raw(): ScreenComparison; } //# sourceMappingURL=screen-result.d.ts.map