Socket
Socket
Sign inDemoInstall

@puppeteer/browsers

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@puppeteer/browsers - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

5

lib/cjs/install.d.ts

@@ -58,2 +58,7 @@ /**

unpack?: boolean;
/**
* @internal
* @defaultValue `false`
*/
forceFallbackForTesting?: boolean;
}

@@ -60,0 +65,0 @@ /**

4

lib/cjs/install.js

@@ -48,2 +48,6 @@ "use strict";

catch (err) {
// If custom baseUrl is provided, do not fall back to CfT dashboard.
if (options.baseUrl && !options.forceFallbackForTesting) {
throw err;
}
debugInstall(`Error downloading from ${url}.`);

@@ -50,0 +54,0 @@ switch (options.browser) {

@@ -61,2 +61,45 @@ "use strict";

exports.WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX = /^WebDriver BiDi listening on (ws:\/\/.*)$/;
const processListeners = new Map();
const dispatchers = {
exit: (...args) => {
processListeners.get('exit')?.forEach(handler => {
return handler(...args);
});
},
SIGINT: (...args) => {
processListeners.get('SIGINT')?.forEach(handler => {
return handler(...args);
});
},
SIGHUP: (...args) => {
processListeners.get('SIGHUP')?.forEach(handler => {
return handler(...args);
});
},
SIGTERM: (...args) => {
processListeners.get('SIGTERM')?.forEach(handler => {
return handler(...args);
});
},
};
function subscribeToProcessEvent(event, handler) {
const listeners = processListeners.get(event) || [];
if (listeners.length === 0) {
process.on(event, dispatchers[event]);
}
listeners.push(handler);
processListeners.set(event, listeners);
}
function unsubscribeFromProcessEvent(event, handler) {
const listeners = processListeners.get(event) || [];
const existingListenerIdx = listeners.indexOf(handler);
if (existingListenerIdx === -1) {
return;
}
listeners.splice(existingListenerIdx, 1);
processListeners.set(event, listeners);
if (listeners.length === 0) {
process.off(event, dispatchers[event]);
}
}
/**

@@ -114,11 +157,11 @@ * @public

}
process.on('exit', this.#onDriverProcessExit);
subscribeToProcessEvent('exit', this.#onDriverProcessExit);
if (opts.handleSIGINT) {
process.on('SIGINT', this.#onDriverProcessSignal);
subscribeToProcessEvent('SIGINT', this.#onDriverProcessSignal);
}
if (opts.handleSIGTERM) {
process.on('SIGTERM', this.#onDriverProcessSignal);
subscribeToProcessEvent('SIGTERM', this.#onDriverProcessSignal);
}
if (opts.handleSIGHUP) {
process.on('SIGHUP', this.#onDriverProcessSignal);
subscribeToProcessEvent('SIGHUP', this.#onDriverProcessSignal);
}

@@ -173,6 +216,6 @@ if (opts.onExit) {

#clearListeners() {
process.off('exit', this.#onDriverProcessExit);
process.off('SIGINT', this.#onDriverProcessSignal);
process.off('SIGTERM', this.#onDriverProcessSignal);
process.off('SIGHUP', this.#onDriverProcessSignal);
unsubscribeFromProcessEvent('exit', this.#onDriverProcessExit);
unsubscribeFromProcessEvent('SIGINT', this.#onDriverProcessSignal);
unsubscribeFromProcessEvent('SIGTERM', this.#onDriverProcessSignal);
unsubscribeFromProcessEvent('SIGHUP', this.#onDriverProcessSignal);
}

@@ -179,0 +222,0 @@ #onDriverProcessExit = (_code) => {

@@ -58,2 +58,7 @@ /**

unpack?: boolean;
/**
* @internal
* @defaultValue `false`
*/
forceFallbackForTesting?: boolean;
}

@@ -60,0 +65,0 @@ /**

@@ -42,2 +42,6 @@ /**

catch (err) {
// If custom baseUrl is provided, do not fall back to CfT dashboard.
if (options.baseUrl && !options.forceFallbackForTesting) {
throw err;
}
debugInstall(`Error downloading from ${url}.`);

@@ -44,0 +48,0 @@ switch (options.browser) {

@@ -52,2 +52,45 @@ /**

export const WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX = /^WebDriver BiDi listening on (ws:\/\/.*)$/;
const processListeners = new Map();
const dispatchers = {
exit: (...args) => {
processListeners.get('exit')?.forEach(handler => {
return handler(...args);
});
},
SIGINT: (...args) => {
processListeners.get('SIGINT')?.forEach(handler => {
return handler(...args);
});
},
SIGHUP: (...args) => {
processListeners.get('SIGHUP')?.forEach(handler => {
return handler(...args);
});
},
SIGTERM: (...args) => {
processListeners.get('SIGTERM')?.forEach(handler => {
return handler(...args);
});
},
};
function subscribeToProcessEvent(event, handler) {
const listeners = processListeners.get(event) || [];
if (listeners.length === 0) {
process.on(event, dispatchers[event]);
}
listeners.push(handler);
processListeners.set(event, listeners);
}
function unsubscribeFromProcessEvent(event, handler) {
const listeners = processListeners.get(event) || [];
const existingListenerIdx = listeners.indexOf(handler);
if (existingListenerIdx === -1) {
return;
}
listeners.splice(existingListenerIdx, 1);
processListeners.set(event, listeners);
if (listeners.length === 0) {
process.off(event, dispatchers[event]);
}
}
/**

@@ -105,11 +148,11 @@ * @public

}
process.on('exit', this.#onDriverProcessExit);
subscribeToProcessEvent('exit', this.#onDriverProcessExit);
if (opts.handleSIGINT) {
process.on('SIGINT', this.#onDriverProcessSignal);
subscribeToProcessEvent('SIGINT', this.#onDriverProcessSignal);
}
if (opts.handleSIGTERM) {
process.on('SIGTERM', this.#onDriverProcessSignal);
subscribeToProcessEvent('SIGTERM', this.#onDriverProcessSignal);
}
if (opts.handleSIGHUP) {
process.on('SIGHUP', this.#onDriverProcessSignal);
subscribeToProcessEvent('SIGHUP', this.#onDriverProcessSignal);
}

@@ -164,6 +207,6 @@ if (opts.onExit) {

#clearListeners() {
process.off('exit', this.#onDriverProcessExit);
process.off('SIGINT', this.#onDriverProcessSignal);
process.off('SIGTERM', this.#onDriverProcessSignal);
process.off('SIGHUP', this.#onDriverProcessSignal);
unsubscribeFromProcessEvent('exit', this.#onDriverProcessExit);
unsubscribeFromProcessEvent('SIGINT', this.#onDriverProcessSignal);
unsubscribeFromProcessEvent('SIGTERM', this.#onDriverProcessSignal);
unsubscribeFromProcessEvent('SIGHUP', this.#onDriverProcessSignal);
}

@@ -170,0 +213,0 @@ #onDriverProcessExit = (_code) => {

2

package.json
{
"name": "@puppeteer/browsers",
"version": "2.2.0",
"version": "2.2.1",
"description": "Download and launch browsers",

@@ -5,0 +5,0 @@ "scripts": {

@@ -13,3 +13,3 @@ # @puppeteer/browsers

CLI help will provide all documentation you need to use the CLI.
Built-in per-command `help` will provide all documentation you need to use the CLI.

@@ -22,6 +22,24 @@ ```bash

Some example to give an idea of what the CLI looks like (use the `--help` command for more examples):
```sh
# Download the latest available Chrome for Testing binary corresponding to the Stable channel.
npx @puppeteer/browsers install chrome@stable
# Download a specific Chrome for Testing version.
npx @puppeteer/browsers install chrome@116.0.5793.0
# Download the latest Chrome for Testing version for the given milestone.
npx @puppeteer/browsers install chrome@117
# Download the latest available ChromeDriver version corresponding to the Canary channel.
npx @puppeteer/browsers install chromedriver@canary
# Download a specific ChromeDriver version.
npx @puppeteer/browsers install chromedriver@116.0.5793.0
```
## Known limitations
1. We support installing and running Firefox, Chrome and Chromium. The `latest`, `beta`, `dev`, `canary`, `stable` keywords are only supported for the install command. For the `launch` command you need to specify an exact build ID. The build ID is provided by the `install` command (see `npx @puppeteer/browsers install --help` for the format).
2. Launching the system browsers is only possible for Chrome/Chromium.
1. Launching the system browsers is only possible for Chrome/Chromium.

@@ -28,0 +46,0 @@ ## API

@@ -95,2 +95,7 @@ /**

unpack?: boolean;
/**
* @internal
* @defaultValue `false`
*/
forceFallbackForTesting?: boolean;
}

@@ -129,2 +134,6 @@

} catch (err) {
// If custom baseUrl is provided, do not fall back to CfT dashboard.
if (options.baseUrl && !options.forceFallbackForTesting) {
throw err;
}
debugInstall(`Error downloading from ${url}.`);

@@ -131,0 +140,0 @@ switch (options.browser) {

@@ -138,2 +138,55 @@ /**

type EventHandler = (...args: any[]) => void;
const processListeners = new Map<string, EventHandler[]>();
const dispatchers = {
exit: (...args: any[]) => {
processListeners.get('exit')?.forEach(handler => {
return handler(...args);
});
},
SIGINT: (...args: any[]) => {
processListeners.get('SIGINT')?.forEach(handler => {
return handler(...args);
});
},
SIGHUP: (...args: any[]) => {
processListeners.get('SIGHUP')?.forEach(handler => {
return handler(...args);
});
},
SIGTERM: (...args: any[]) => {
processListeners.get('SIGTERM')?.forEach(handler => {
return handler(...args);
});
},
};
function subscribeToProcessEvent(
event: 'exit' | 'SIGINT' | 'SIGHUP' | 'SIGTERM',
handler: EventHandler
): void {
const listeners = processListeners.get(event) || [];
if (listeners.length === 0) {
process.on(event, dispatchers[event]);
}
listeners.push(handler);
processListeners.set(event, listeners);
}
function unsubscribeFromProcessEvent(
event: 'exit' | 'SIGINT' | 'SIGHUP' | 'SIGTERM',
handler: EventHandler
): void {
const listeners = processListeners.get(event) || [];
const existingListenerIdx = listeners.indexOf(handler);
if (existingListenerIdx === -1) {
return;
}
listeners.splice(existingListenerIdx, 1);
processListeners.set(event, listeners);
if (listeners.length === 0) {
process.off(event, dispatchers[event]);
}
}
/**

@@ -205,11 +258,11 @@ * @public

}
process.on('exit', this.#onDriverProcessExit);
subscribeToProcessEvent('exit', this.#onDriverProcessExit);
if (opts.handleSIGINT) {
process.on('SIGINT', this.#onDriverProcessSignal);
subscribeToProcessEvent('SIGINT', this.#onDriverProcessSignal);
}
if (opts.handleSIGTERM) {
process.on('SIGTERM', this.#onDriverProcessSignal);
subscribeToProcessEvent('SIGTERM', this.#onDriverProcessSignal);
}
if (opts.handleSIGHUP) {
process.on('SIGHUP', this.#onDriverProcessSignal);
subscribeToProcessEvent('SIGHUP', this.#onDriverProcessSignal);
}

@@ -267,6 +320,6 @@ if (opts.onExit) {

#clearListeners(): void {
process.off('exit', this.#onDriverProcessExit);
process.off('SIGINT', this.#onDriverProcessSignal);
process.off('SIGTERM', this.#onDriverProcessSignal);
process.off('SIGHUP', this.#onDriverProcessSignal);
unsubscribeFromProcessEvent('exit', this.#onDriverProcessExit);
unsubscribeFromProcessEvent('SIGINT', this.#onDriverProcessSignal);
unsubscribeFromProcessEvent('SIGTERM', this.#onDriverProcessSignal);
unsubscribeFromProcessEvent('SIGHUP', this.#onDriverProcessSignal);
}

@@ -273,0 +326,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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