| 
									
										
										
										
											2020-01-06 18:22:35 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Copyright (c) Microsoft Corporation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-11-25 15:06:52 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-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>; | 
					
						
							| 
									
										
										
										
											2020-01-16 17:03:32 -08:00
										 |  |  | export type $Wait = <Args extends any[], R>(selector: string, pageFunction: PageFunctionOn<Element | undefined, Args, R>, options?: WaitForFunctionOptions, ...args: Boxed<Args>) => Promise<Handle<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; | 
					
						
							| 
									
										
										
										
											2019-12-10 11:15:14 -08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-12-17 14:00:39 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-07 11:55:24 -08:00
										 |  |  | export type URLMatch = string | RegExp | ((url: URL) => boolean); | 
					
						
							| 
									
										
										
										
											2019-12-30 14:09:54 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export type Credentials = { | 
					
						
							|  |  |  |   username: string; | 
					
						
							|  |  |  |   password: string; | 
					
						
							| 
									
										
										
										
											2020-01-03 12:59:06 -08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-01-03 10:14:50 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export type Geolocation = { | 
					
						
							| 
									
										
										
										
											2020-01-13 15:39:13 -08:00
										 |  |  |   longitude: number; | 
					
						
							|  |  |  |   latitude: number; | 
					
						
							|  |  |  |   accuracy?: number; | 
					
						
							| 
									
										
										
										
											2020-01-03 12:59:06 -08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type SelectOption = { | 
					
						
							|  |  |  |   value?: string; | 
					
						
							|  |  |  |   label?: string; | 
					
						
							|  |  |  |   index?: number; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type FilePayload = { | 
					
						
							|  |  |  |   name: string, | 
					
						
							|  |  |  |   type: string, | 
					
						
							|  |  |  |   data: string, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type MediaType = 'screen' | 'print'; | 
					
						
							|  |  |  | export const mediaTypes: Set<MediaType> = new Set(['screen', 'print']); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type ColorScheme = 'dark' | 'light' | 'no-preference'; | 
					
						
							|  |  |  | export const colorSchemes: Set<ColorScheme> = new Set(['dark', 'light', 'no-preference']); | 
					
						
							| 
									
										
										
										
											2020-01-07 12:53:06 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export type DeviceDescriptor = { | 
					
						
							|  |  |  |   name: string, | 
					
						
							|  |  |  |   userAgent: string, | 
					
						
							|  |  |  |   viewport: Viewport, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | export type Devices = { [name: string]: DeviceDescriptor } & DeviceDescriptor[]; | 
					
						
							| 
									
										
										
										
											2020-01-07 13:57:37 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export type PDFOptions = { | 
					
						
							|  |  |  |   scale?: number, | 
					
						
							|  |  |  |   displayHeaderFooter?: boolean, | 
					
						
							|  |  |  |   headerTemplate?: string, | 
					
						
							|  |  |  |   footerTemplate?: string, | 
					
						
							|  |  |  |   printBackground?: boolean, | 
					
						
							|  |  |  |   landscape?: boolean, | 
					
						
							|  |  |  |   pageRanges?: string, | 
					
						
							|  |  |  |   format?: string, | 
					
						
							|  |  |  |   width?: string|number, | 
					
						
							|  |  |  |   height?: string|number, | 
					
						
							|  |  |  |   preferCSSPageSize?: boolean, | 
					
						
							|  |  |  |   margin?: {top?: string|number, bottom?: string|number, left?: string|number, right?: string|number}, | 
					
						
							|  |  |  |   path?: string, | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type CoverageEntry = { | 
					
						
							|  |  |  |   url: string, | 
					
						
							|  |  |  |   text: string, | 
					
						
							|  |  |  |   ranges : {start: number, end: number}[] | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-01-16 17:46:50 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export type CSSCoverageOptions = { | 
					
						
							|  |  |  |   resetOnNavigation?: boolean, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type JSCoverageOptions = { | 
					
						
							|  |  |  |   resetOnNavigation?: boolean, | 
					
						
							|  |  |  |   reportAnonymousScripts?: boolean, | 
					
						
							|  |  |  | }; |