-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: common types for evaluate functions (#72)
- Loading branch information
Showing
7 changed files
with
69 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
type Boxed<Args extends any[], Handle> = { [Index in keyof Args]: Args[Index] | Handle }; | ||
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>); | ||
|
||
export type Evaluate<Handle> = <Args extends any[], R>(fn: PageFunction<Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>; | ||
export type EvaluateHandle<Handle> = <Args extends any[]>(fn: PageFunction<Args>, ...args: Boxed<Args, Handle>) => Promise<Handle>; | ||
export type $Eval<Handle> = <Args extends any[], R>(selector: string, fn: PageFunctionOn<Element, Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>; | ||
export type $$Eval<Handle> = <Args extends any[], R>(selector: string, fn: PageFunctionOn<Element[], Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>; | ||
export type EvaluateOn<Handle> = <Args extends any[], R>(fn: PageFunctionOn<any, Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>; | ||
export type EvaluateHandleOn<Handle> = <Args extends any[]>(fn: PageFunctionOn<any, Args>, ...args: Boxed<Args, Handle>) => Promise<Handle>; | ||
|
||
export interface EvaluationContext<Handle> { | ||
evaluate: Evaluate<Handle>; | ||
evaluateHandle: EvaluateHandle<Handle>; | ||
} | ||
|
||
export interface Handle { | ||
dispose(): Promise<void>; | ||
} |