import type { Page, TestType } from '@playwright/test'; import type { ScreenConfig } from './screen-config.js'; import { FieldExtractor } from './field-extractor.js'; import { ScreenResult } from './screen-result.js'; import { type Charset, type FieldRead } from './utils/ocr.js'; import { Strategies, type ClickStrategy, type FillStrategy, type CaptureStrategy, type OcrStrategy } from './strategies.js'; export interface BindOcrScreenOptions { shotDir?: string; /** * Show live match outlines while waiting/asserting. * Default inherits `init({ overlay })`. */ overlay?: boolean; /** * Override `init({ unhoverBeforeCapture })` for this screen. * Default inherits global config (true when unset). */ unhover?: boolean; /** * Override `init({ read })` for this screen. * Default inherits the init-level read mode. */ read?: FieldRead; /** * When false, returns the ScreenResult synchronously without waiting. * Default is to wait — `await screen(name)` resolves after `waitFor()`. */ wait?: boolean; } /** Warm OCR + OpenCV (safe to call more than once). */ export declare function ensureOcrRuntime(): Promise; /** New extractor for a Playwright fixture scope. */ export declare function createOcrExtractor(): Promise; export declare function bindOcrScreen(page: Page, config: ScreenConfig, extractor: FieldExtractor, shotDir: string, options?: BindOcrScreenOptions): ScreenResult; export interface Strategies { charsets?: Record; ocr?: OcrStrategy; click?: ClickStrategy; fill?: FillStrategy; capture?: CaptureStrategy; } export { Strategies, type OcrStrategy, type ClickStrategy, type FillStrategy, type CaptureStrategy }; interface InitOptions { page: Page; storage?: { root: string; }; devtools?: boolean; unhoverBeforeCapture?: boolean; /** Global overlay default. Per-screen `{ overlay }` still wins. */ overlay?: boolean; /** Environment-level read override. Wins over index.json; call site wins over this. */ read?: FieldRead; /** * Override the default unhover destination (top-left corner). * Useful when the top-left corner overlaps interactive content. */ unhoverPoint?: { x: number; y: number; }; strategies?: Strategies; } /** * Warm OCR/CV, configure the page and storage root, and make `screen()` sync. * Idempotent — calling again with a new page updates the active page. * * await init({ page, storage: { root: process.env.SCREENS_DIR } }); * const customerInfo = screen('customer-info'); */ export declare function init(options: InitOptions): Promise; /** * Bind a screen to the page set by `init()` and wait for it to appear. * Pass `{ wait: false }` to skip waiting and get the result synchronously. * * const customerInfo = await screen('customer-info'); * const s = screen('service', { wait: false }); // already visible */ export declare function screen(nameOrConfig: string | ScreenConfig, options: BindOcrScreenOptions & { wait: false; }): ScreenResult; export declare function screen(nameOrConfig: string | ScreenConfig, options?: BindOcrScreenOptions): Promise; /** Release shared OCR/CV resources. Optional — registered automatically by init(). */ export declare function release(): Promise; /** @deprecated Use release() */ export declare const releaseOcrScreen: typeof release; export type ScreenFixture = (config: ScreenConfig | string) => ScreenResult; interface ScreenFixtures { screen: ScreenFixture; ocrOverlay: boolean; } interface ScreenWorkerFixtures { _ocrReady: void; } /** * Create a Playwright test object with a `screen` fixture and an `ocrOverlay` option. * * const test = createFixture(); * export { test }; * * test('my test', async ({ page, screen }) => { * const login = screen(htmlLoginScreen); * await login.element('username').fill('qawolf'); * }); * * // Enable overlay rendering for a test file: * test.use({ ocrOverlay: true }); */ export declare function createFixture(): TestType; //# sourceMappingURL=screen.d.ts.map