2019-11-25 15:06:52 -08:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the MIT license.
|
|
|
|
|
2019-11-27 16:03:51 -08:00
|
|
|
import * as js from './javascript';
|
2019-12-05 16:26:09 -08:00
|
|
|
import * as dom from './dom';
|
2019-12-20 14:38:54 -08:00
|
|
|
import * as kurl from 'url';
|
2019-11-27 16:03:51 -08:00
|
|
|
|
2019-12-05 16:26:09 -08:00
|
|
|
type Boxed<Args extends any[]> = { [Index in keyof Args]: Args[Index] | js.JSHandle<Args[Index]> };
|
2019-11-25 15:06:52 -08:00
|
|
|
type PageFunction<Args extends any[], R = any> = string | ((...args: Args) => R | Promise<R>);
|
|
|
|
type PageFunctionOn<On, Args extends any[], R = any> = string | ((on: On, ...args: Args) => R | Promise<R>);
|
|
|
|
|
2019-12-05 16:26:09 -08:00
|
|
|
type Handle<T> = T extends Node ? dom.ElementHandle<T> : js.JSHandle<T>;
|
|
|
|
|
2019-11-27 16:03:51 -08:00
|
|
|
export type Evaluate = <Args extends any[], R>(pageFunction: PageFunction<Args, R>, ...args: Boxed<Args>) => Promise<R>;
|
2019-12-05 16:26:09 -08:00
|
|
|
export type EvaluateHandle = <Args extends any[], R>(pageFunction: PageFunction<Args, R>, ...args: Boxed<Args>) => Promise<Handle<R>>;
|
2019-12-20 16:57:21 -08:00
|
|
|
export type $Eval = <Args extends any[], R>(selector: string, pageFunction: PageFunctionOn<Element, Args, R>, ...args: Boxed<Args>) => Promise<R>;
|
|
|
|
export type $$Eval = <Args extends any[], R>(selector: string, pageFunction: PageFunctionOn<Element[], Args, R>, ...args: Boxed<Args>) => Promise<R>;
|
2019-12-05 16:26:09 -08:00
|
|
|
export type EvaluateOn<T> = <Args extends any[], R>(pageFunction: PageFunctionOn<T, Args, R>, ...args: Boxed<Args>) => Promise<R>;
|
|
|
|
export type EvaluateHandleOn<T> = <Args extends any[], R>(pageFunction: PageFunctionOn<T, Args, R>, ...args: Boxed<Args>) => Promise<Handle<R>>;
|
2019-11-27 16:03:51 -08:00
|
|
|
|
2019-12-11 11:26:34 -08:00
|
|
|
export type Size = { width: number, height: number };
|
2019-11-27 16:03:51 -08:00
|
|
|
export type Point = { x: number, y: number };
|
2019-12-11 11:26:34 -08:00
|
|
|
export type Rect = Size & Point;
|
2019-12-05 09:54:50 -08:00
|
|
|
export type Quad = [ Point, Point, Point, Point ];
|
2019-12-04 13:11:10 -08:00
|
|
|
|
|
|
|
export type TimeoutOptions = { timeout?: number };
|
2019-12-14 19:13:22 -08:00
|
|
|
export type Visibility = 'visible' | 'hidden' | 'any';
|
2019-12-04 13:11:10 -08:00
|
|
|
|
|
|
|
export type Polling = 'raf' | 'mutation' | number;
|
|
|
|
export type WaitForFunctionOptions = TimeoutOptions & { polling?: Polling };
|
|
|
|
|
2019-12-06 11:33:24 -08:00
|
|
|
export type ElementScreenshotOptions = {
|
2019-12-05 14:48:39 -08:00
|
|
|
type?: 'png' | 'jpeg',
|
|
|
|
path?: string,
|
|
|
|
quality?: number,
|
|
|
|
omitBackground?: boolean,
|
|
|
|
};
|
2019-12-06 11:33:24 -08:00
|
|
|
|
|
|
|
export type ScreenshotOptions = ElementScreenshotOptions & {
|
|
|
|
fullPage?: boolean,
|
|
|
|
clip?: Rect,
|
|
|
|
};
|
|
|
|
|
|
|
|
export type Viewport = {
|
|
|
|
width: number;
|
|
|
|
height: number;
|
|
|
|
deviceScaleFactor?: number;
|
|
|
|
isMobile?: boolean;
|
|
|
|
isLandscape?: boolean;
|
|
|
|
hasTouch?: boolean;
|
2019-12-10 11:15:14 -08:00
|
|
|
};
|
2019-12-17 14:00:39 -08:00
|
|
|
|
2019-12-20 14:38:54 -08:00
|
|
|
export type URLMatch = string | RegExp | ((url: kurl.URL) => boolean);
|
2019-12-30 14:09:54 -08:00
|
|
|
|
|
|
|
export type Credentials = {
|
|
|
|
username: string;
|
|
|
|
password: string;
|
|
|
|
}
|