// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. import * as js from './javascript'; import * as dom from './dom'; import * as kurl from 'url'; type Boxed = { [Index in keyof Args]: Args[Index] | js.JSHandle }; type PageFunction = string | ((...args: Args) => R | Promise); type PageFunctionOn = string | ((on: On, ...args: Args) => R | Promise); type Handle = T extends Node ? dom.ElementHandle : js.JSHandle; export type Evaluate = (pageFunction: PageFunction, ...args: Boxed) => Promise; export type EvaluateHandle = (pageFunction: PageFunction, ...args: Boxed) => Promise>; export type $Eval = (selector: string, pageFunction: PageFunctionOn, ...args: Boxed) => Promise; export type $$Eval = (selector: string, pageFunction: PageFunctionOn, ...args: Boxed) => Promise; export type EvaluateOn = (pageFunction: PageFunctionOn, ...args: Boxed) => Promise; export type EvaluateHandleOn = (pageFunction: PageFunctionOn, ...args: Boxed) => Promise>; export type Size = { width: number, height: number }; export type Point = { x: number, y: number }; export type Rect = Size & Point; export type Quad = [ Point, Point, Point, Point ]; export type TimeoutOptions = { timeout?: number }; export type Visibility = 'visible' | 'hidden' | 'any'; export type Polling = 'raf' | 'mutation' | number; export type WaitForFunctionOptions = TimeoutOptions & { polling?: Polling }; export type ElementScreenshotOptions = { type?: 'png' | 'jpeg', path?: string, quality?: number, omitBackground?: boolean, }; export type ScreenshotOptions = ElementScreenshotOptions & { fullPage?: boolean, clip?: Rect, }; export type Viewport = { width: number; height: number; deviceScaleFactor?: number; isMobile?: boolean; isLandscape?: boolean; hasTouch?: boolean; }; export type URLMatch = string | RegExp | ((url: kurl.URL) => boolean); export type Credentials = { username: string; password: string; } export type Geolocation = { longitude?: number; latitude?: number; accuracy?: number | undefined; }