2020-06-25 12:38:01 +00:00
|
|
|
/**
|
|
|
|
* Copyright 2020 Google Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2020-07-02 09:09:34 +00:00
|
|
|
import { JSHandle, ElementHandle } from './JSHandle';
|
2020-06-25 12:38:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2020-07-10 10:52:13 +00:00
|
|
|
export type EvaluateFn<T = unknown> =
|
|
|
|
| string
|
|
|
|
| ((arg1: T, ...args: unknown[]) => unknown);
|
|
|
|
|
|
|
|
export type UnwrapPromiseLike<T> = T extends PromiseLike<infer U> ? U : T;
|
|
|
|
|
2020-06-25 12:38:01 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type EvaluateFnReturnType<T extends EvaluateFn> = T extends (
|
2020-07-10 10:52:13 +00:00
|
|
|
...args: unknown[]
|
2020-06-25 12:38:01 +00:00
|
|
|
) => infer R
|
|
|
|
? R
|
|
|
|
: unknown;
|
|
|
|
|
2020-07-01 11:44:08 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type EvaluateHandleFn = string | ((...args: unknown[]) => unknown);
|
|
|
|
|
2020-06-25 12:38:01 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type Serializable =
|
|
|
|
| number
|
|
|
|
| string
|
|
|
|
| boolean
|
|
|
|
| null
|
2020-07-10 10:52:13 +00:00
|
|
|
| BigInt
|
2020-06-25 12:38:01 +00:00
|
|
|
| JSONArray
|
|
|
|
| JSONObject;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type JSONArray = Serializable[];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface JSONObject {
|
|
|
|
[key: string]: Serializable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type SerializableOrJSHandle = Serializable | JSHandle;
|
2020-07-02 09:09:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Wraps a DOM element into an ElementHandle instance
|
|
|
|
* @public
|
|
|
|
**/
|
|
|
|
export type WrapElementHandle<X> = X extends Element ? ElementHandle<X> : X;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unwraps a DOM element out of an ElementHandle instance
|
|
|
|
* @public
|
|
|
|
**/
|
|
|
|
export type UnwrapElementHandle<X> = X extends ElementHandle<infer E> ? E : X;
|