New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@types/puppeteer

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/puppeteer - npm Package Compare versions

Comparing version 1.3.4 to 1.5.0

380

puppeteer/index.d.ts

@@ -1,7 +0,8 @@

// Type definitions for puppeteer 1.3
// Type definitions for puppeteer 1.5
// Project: https://github.com/GoogleChrome/puppeteer#readme
// Definitions by: Marvin Hagemeister <https://github.com/marvinhagemeister>
// Christopher Deutsch <https://github.com/cdeutsch>
// Konstantin Simon Maria Möllers <https://github.com/ksm2>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8

@@ -13,2 +14,189 @@ /// <reference types="node" />

/** Wraps a DOM element into an ElementHandle instance */
export type WrapElementHandle<X> = X extends Element ? ElementHandle<X> : X;
/** Unwraps a DOM element out of an ElementHandle instance */
export type UnwrapElementHandle<X> = X extends ElementHandle<infer E> ? E : X;
/** Defines `$eval` and `$$eval` for Page, Frame and ElementHandle. */
export interface Evalable {
/**
* This method runs `document.querySelector` within the context and passes it as the first argument to `pageFunction`.
* If there's no element matching `selector`, the method throws an error.
*
* If `pageFunction` returns a Promise, then `$eval` would wait for the promise to resolve and return its value.
*
* @param selector A selector to query for
* @param pageFunction Function to be evaluated in browser context
* @returns Promise which resolves to the return value of pageFunction
*/
$eval<R>(
selector: string,
pageFunction: (element: Element) => R | Promise<R>,
): Promise<WrapElementHandle<R>>;
/**
* This method runs `document.querySelector` within the context and passes it as the first argument to `pageFunction`.
* If there's no element matching `selector`, the method throws an error.
*
* If `pageFunction` returns a Promise, then `$eval` would wait for the promise to resolve and return its value.
*
* @param selector A selector to query for
* @param pageFunction Function to be evaluated in browser context
* @param x1 First argument to pass to pageFunction
* @returns Promise which resolves to the return value of pageFunction
*/
$eval<R, X1>(
selector: string,
pageFunction: (element: Element, x1: UnwrapElementHandle<X1>) => R | Promise<R>,
x1: X1,
): Promise<WrapElementHandle<R>>;
/**
* This method runs `document.querySelector` within the context and passes it as the first argument to `pageFunction`.
* If there's no element matching `selector`, the method throws an error.
*
* If `pageFunction` returns a Promise, then `$eval` would wait for the promise to resolve and return its value.
*
* @param selector A selector to query for
* @param pageFunction Function to be evaluated in browser context
* @param x1 First argument to pass to pageFunction
* @param x2 Second argument to pass to pageFunction
* @returns Promise which resolves to the return value of pageFunction
*/
$eval<R, X1, X2>(
selector: string,
pageFunction: (element: Element, x1: UnwrapElementHandle<X1>, x2: UnwrapElementHandle<X2>) => R | Promise<R>,
x1: X1,
x2: X2,
): Promise<WrapElementHandle<R>>;
/**
* This method runs `document.querySelector` within the context and passes it as the first argument to `pageFunction`.
* If there's no element matching `selector`, the method throws an error.
*
* If `pageFunction` returns a Promise, then `$eval` would wait for the promise to resolve and return its value.
*
* @param selector A selector to query for
* @param pageFunction Function to be evaluated in browser context
* @param x1 First argument to pass to pageFunction
* @param x2 Second argument to pass to pageFunction
* @param x3 Third argument to pass to pageFunction
* @returns Promise which resolves to the return value of pageFunction
*/
$eval<R, X1, X2, X3>(
selector: string,
pageFunction: (element: Element, x1: UnwrapElementHandle<X1>, x2: UnwrapElementHandle<X2>, x3: UnwrapElementHandle<X3>) => R | Promise<R>,
x1: X1,
x2: X2,
x3: X3,
): Promise<WrapElementHandle<R>>;
/**
* This method runs `document.querySelector` within the context and passes it as the first argument to `pageFunction`.
* If there's no element matching `selector`, the method throws an error.
*
* If `pageFunction` returns a Promise, then `$eval` would wait for the promise to resolve and return its value.
*
* @param selector A selector to query for
* @param pageFunction Function to be evaluated in browser context
* @param args Arguments to pass to pageFunction
* @returns Promise which resolves to the return value of pageFunction
*/
$eval<R>(
selector: string,
pageFunction: (element: Element, ...args: any[]) => R | Promise<R>,
...args: any[],
): Promise<WrapElementHandle<R>>;
/**
* This method runs `Array.from(document.querySelectorAll(selector))` within the context and passes it as the
* first argument to `pageFunction`.
*
* If `pageFunction` returns a Promise, then `$$eval` would wait for the promise to resolve and return its value.
*
* @param selector A selector to query for
* @param pageFunction Function to be evaluated in browser context
* @returns Promise which resolves to the return value of pageFunction
*/
$$eval<R>(
selector: string,
pageFunction: (elements: Element[]) => R | Promise<R>,
): Promise<WrapElementHandle<R>>;
/**
* This method runs `Array.from(document.querySelectorAll(selector))` within the context and passes it as the
* first argument to `pageFunction`.
*
* If `pageFunction` returns a Promise, then `$$eval` would wait for the promise to resolve and return its value.
*
* @param selector A selector to query for
* @param pageFunction Function to be evaluated in browser context
* @param x1 First argument to pass to pageFunction
* @returns Promise which resolves to the return value of pageFunction
*/
$$eval<R, X1>(
selector: string,
pageFunction: (elements: Element[], x1: UnwrapElementHandle<X1>) => R | Promise<R>,
x1: X1,
): Promise<WrapElementHandle<R>>;
/**
* This method runs `Array.from(document.querySelectorAll(selector))` within the context and passes it as the
* first argument to `pageFunction`.
*
* If `pageFunction` returns a Promise, then `$$eval` would wait for the promise to resolve and return its value.
*
* @param selector A selector to query for
* @param pageFunction Function to be evaluated in browser context
* @param x1 First argument to pass to pageFunction
* @param x2 Second argument to pass to pageFunction
* @returns Promise which resolves to the return value of pageFunction
*/
$$eval<R, X1, X2>(
selector: string,
pageFunction: (elements: Element[], x1: UnwrapElementHandle<X1>, x2: UnwrapElementHandle<X2>) => R | Promise<R>,
x1: X1,
x2: X2,
): Promise<WrapElementHandle<R>>;
/**
* This method runs `Array.from(document.querySelectorAll(selector))` within the context and passes it as the
* first argument to `pageFunction`.
*
* If `pageFunction` returns a Promise, then `$$eval` would wait for the promise to resolve and return its value.
*
* @param selector A selector to query for
* @param pageFunction Function to be evaluated in browser context
* @param x1 First argument to pass to pageFunction
* @param x2 Second argument to pass to pageFunction
* @param x3 Third argument to pass to pageFunction
* @returns Promise which resolves to the return value of pageFunction
*/
$$eval<R, X1, X2, X3>(
selector: string,
pageFunction: (elements: Element[], x1: UnwrapElementHandle<X1>, x2: UnwrapElementHandle<X2>, x3: UnwrapElementHandle<X3>) => R | Promise<R>,
x1: X1,
x2: X2,
x3: X3,
): Promise<WrapElementHandle<R>>;
/**
* This method runs `Array.from(document.querySelectorAll(selector))` within the context and passes it as the
* first argument to `pageFunction`.
*
* If `pageFunction` returns a Promise, then `$$eval` would wait for the promise to resolve and return its value.
*
* @param selector A selector to query for
* @param pageFunction Function to be evaluated in browser context
* @param args Arguments to pass to pageFunction
* @returns Promise which resolves to the return value of pageFunction
*/
$$eval<R>(
selector: string,
pageFunction: (elements: Element[], ...args: any[]) => R | Promise<R>,
...args: any[]
): Promise<WrapElementHandle<R>>;
}
/** Keyboard provides an api for managing a virtual keyboard. */

@@ -151,3 +339,5 @@ export interface Keyboard {

| "requestfinished"
| "response";
| "response"
| "workercreated"
| "workerdestroyed";

@@ -458,7 +648,39 @@ export type BrowserEvents =

/**
* The Worker class represents a WebWorker.
* The events workercreated and workerdestroyed are emitted on the page object to signal the worker lifecycle.
*/
export interface Worker {
/**
* If the function passed to the `worker.evaluate` returns a Promise,
* then `worker.evaluate` would wait for the promise to resolve and return its value.
*
* If the function passed to the `worker.evaluate` returns a non-Serializable value,
* then `worker.evaluate` resolves to `undefined`.
*/
evaluate<T>(
pageFunction: (...args: any[]) => T | Promise<T>,
...args: any[],
): Promise<T>;
/**
* The only difference between `worker.evaluate` and `worker.evaluateHandle` is
* that `worker.evaluateHandle` returns in-page object (JSHandle).
*/
evaluateHandle<T>(
pageFunction: (...args: any[]) => T | Promise<T>,
...args: any[],
): Promise<T>;
executionContext(): Promise<ExecutionContext>;
url(): string;
}
/**
* Represents an in-page DOM element. ElementHandles can be created with the page.$ method.
*/
export interface ElementHandle extends JSHandle {
export interface ElementHandle<E extends Element = Element> extends JSHandle, Evalable {
/**
* The method runs element.querySelector within the page. If no element matches the selector, the return value resolve to null.
* The method runs element.querySelector within the page.
* If no element matches the selector, the return value resolve to null.
* @param selector A selector to query element for

@@ -468,4 +690,6 @@ * @since 0.13.0

$(selector: string): Promise<ElementHandle | null>;
/**
* The method runs element.querySelectorAll within the page. If no elements match the selector, the return value resolve to [].
* The method runs element.querySelectorAll within the page.
* If no elements match the selector, the return value resolve to [].
* @param selector A selector to query element for

@@ -475,2 +699,3 @@ * @since 0.13.0

$$(selector: string): Promise<ElementHandle[]>;
/**

@@ -691,2 +916,6 @@ * @param selector XPath expression to evaluate.

headers(): Headers;
/** Whether this request is driving frame's navigation. */
isNavigationRequest(): boolean;
/** Returns the request's method (GET, POST, etc.) */

@@ -770,13 +999,17 @@

export interface FrameBase {
export interface FrameBase extends Evalable {
/**
* The method runs document.querySelector within the page.
* If no element matches the selector, the return value resolve to null.
* The method queries frame for the selector.
* If there's no such element within the frame, the method will resolve to null.
*/
$(selector: string): Promise<ElementHandle | null>;
/**
* The method runs document.querySelectorAll within the page. If no elements match the selector, the return value resolve to [].
* The method runs document.querySelectorAll within the frame.
* If no elements match the selector, the return value resolve to [].
*/
$$(selector: string): Promise<ElementHandle[]>;
/**
* The method evaluates the XPath expression.
* @param expression XPath expression to evaluate.

@@ -786,27 +1019,2 @@ */

/**
* This method runs document.querySelector within the page and passes it as the first argument to `fn`.
* If there's no element matching selector, the method throws an error.
* If `fn` returns a Promise, then $eval would wait for the promise to resolve and return its value.
*/
$eval(
selector: string,
pageFunction: (element: Element, ...args: any[]) => any,
...args: any[]
): Promise<any>;
/**
* This method runs document.querySelectorAll within the page and passes it as the first argument to `fn`.
* If `fn` returns a Promise, then $$eval would wait for the promise to resolve and return its value.
* @param selector A selector to query frame for
* @param fn Function to be evaluated in browser context
* @param args Arguments to pass to pageFunction
* @returns Promise which resolves to the return value of pageFunction
*/
$$eval(
selector: string,
pageFunction: (elements: NodeListOf<Element>, ...args: any[]) => any,
...args: any[]
): Promise<any>;
/** Adds a `<script>` tag into the page with the desired url or content. */

@@ -974,4 +1182,13 @@ addScriptTag(options: ScriptTagOptions): Promise<void>;

response: Response;
/** Emitted when a dedicated WebWorker is spawned by the page. */
workercreated: Worker;
/** Emitted when a dedicated WebWorker is terminated. */
workerdestroyed: Worker;
}
export interface PageCloseOptions {
/** Defaults to `false`. Whether to run the before unload page handlers. */
runBeforeUnload?: boolean;
}
/** Page provides methods to interact with a single tab in Chromium. One Browser instance might have multiple Page instances. */

@@ -1011,4 +1228,7 @@ export interface Page extends EventEmitter, FrameBase {

/** Get the browser the page belongs to. */
browser(): Promise<Browser>;
/** Closes the current page. */
close(): Promise<void>;
close(options?: PageCloseOptions): Promise<void>;

@@ -1093,2 +1313,5 @@ /**

/** Indicates that the page has been closed. */
isClosed(): boolean;
/** Page is guaranteed to have a main frame which persists during navigation's. */

@@ -1227,2 +1450,5 @@ mainFrame(): Frame;

waitForNavigation(options?: NavigationOptions): Promise<Response>;
/** This method returns all of the dedicated WebWorkers associated with the page. */
workers(): Worker[];
}

@@ -1256,2 +1482,8 @@

/**
* Returns an array of all open browser contexts.
* In a newly created browser, this will return a single instance of BrowserContext.
*/
browserContexts(): BrowserContext[];
/**
* Closes browser with all the pages (if any were opened).

@@ -1263,2 +1495,8 @@ * The browser object itself is considered to be disposed and can not be used anymore.

/**
* Creates a new incognito browser context.
* This won't share cookies/cache with other browser contexts.
*/
createIncognitoBrowserContext(): Promise<BrowserContext>;
/**
* Disconnects Puppeteer from the browser, but leaves the Chromium process running.

@@ -1308,6 +1546,74 @@ * After calling `disconnect`, the browser object is considered disposed and cannot be used anymore.

/**
* BrowserContexts provide a way to operate multiple independent browser sessions.
* When a browser is launched, it has a single BrowserContext used by default.
* The method `browser.newPage()` creates a page in the default browser context.
*/
export interface BrowserContext extends EventEmitter {
/**
* Adds the listener function to the end of the listeners array for the event named `eventName`.
* No checks are made to see if the listener has already been added. Multiple calls passing the same combination of
* `eventName` and listener will result in the listener being added, and called, multiple times.
* @param event The name of the event.
* @param handler The callback function.
*/
on<K extends keyof BrowserContextEventObj>(
eventName: K,
handler: (e: BrowserContextEventObj[K], ...args: any[]) => void
): this;
/**
* Adds a one time listener function for the event named `eventName`.
* The next time `eventName` is triggered, this listener is removed and then invoked.
* @param event The name of the event.
* @param handler The callback function.
*/
once<K extends keyof BrowserContextEventObj>(
eventName: K,
handler: (e: BrowserContextEventObj[K], ...args: any[]) => void
): this;
/** The browser this browser context belongs to. */
browser(): Browser;
/** Closes the browser context. All the targets that belong to the browser context will be closed. */
close(): Promise<void>;
/**
* Returns whether BrowserContext is incognito.
* The default browser context is the only non-incognito browser context.
*/
isIncognito(): boolean;
/** Creates a new page in the browser context. */
newPage(): Promise<Page>;
/** An array of all active targets inside the browser context. */
targets(): Target[];
}
export interface BrowserContextEventObj {
/** Emitted when the url of a target inside the browser context changes. */
targetchanged: Target;
/** Emitted when a target is created, for example when a new page is opened by `window.open` or `browserContext.newPage`. */
targetcreated: Target;
/** Emitted when a target is destroyed, for example when a page is closed. */
targetdestroyed: Target;
}
export interface Target {
/** Get the browser the target belongs to. */
browser(): Browser;
/** The browser context the target belongs to. */
browserContext(): BrowserContext;
/** Creates a Chrome Devtools Protocol session attached to the target. */
createCDPSession(): Promise<CDPSession>;
/** Get the target that opened this target. Top-level targets return `null`. */
opener(): Target | null;
/** Returns the target `Page` or a `null` if the type of the page is not "page". */

@@ -1317,3 +1623,3 @@ page(): Promise<Page>;

/** Identifies what kind of target this is. */
type(): "page" | "service_worker" | "other";
type(): "page" | "background_page" | "service_worker" | "browser" | "other";

@@ -1320,0 +1626,0 @@ /** Returns the target URL. */

11

puppeteer/package.json
{
"name": "@types/puppeteer",
"version": "1.3.4",
"version": "1.5.0",
"description": "TypeScript definitions for puppeteer",

@@ -16,2 +16,7 @@ "license": "MIT",

"githubUsername": "cdeutsch"
},
{
"name": "Konstantin Simon Maria Möllers",
"url": "https://github.com/ksm2",
"githubUsername": "ksm2"
}

@@ -29,4 +34,4 @@ ],

},
"typesPublisherContentHash": "22dd33b8eebac4e299bc9ee516b90aa36962a59beeb60d62c1dbd3dffc442d58",
"typeScriptVersion": "2.3"
"typesPublisherContentHash": "c8f81ba32befcb0ef238b9fe01bf3831c506284a06deced67030c50ab8d52d19",
"typeScriptVersion": "2.8"
}

@@ -11,3 +11,3 @@ # Installation

Additional Details
* Last updated: Wed, 13 Jun 2018 19:16:57 GMT
* Last updated: Tue, 26 Jun 2018 01:10:51 GMT
* Dependencies: events, child_process, node

@@ -17,2 +17,2 @@ * Global values: none

# Credits
These definitions were written by Marvin Hagemeister <https://github.com/marvinhagemeister>, Christopher Deutsch <https://github.com/cdeutsch>.
These definitions were written by Marvin Hagemeister <https://github.com/marvinhagemeister>, Christopher Deutsch <https://github.com/cdeutsch>, Konstantin Simon Maria Möllers <https://github.com/ksm2>.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc