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.1.0 to 2.2.0

90

lib/cjs/browser-data/browser-data.js

@@ -70,5 +70,5 @@ "use strict";

/**
* @public
* @internal
*/
async function resolveBuildId(browser, platform, tag) {
async function resolveBuildIdForBrowserTag(browser, platform, tag) {
switch (browser) {

@@ -78,8 +78,16 @@ case types_js_1.Browser.FIREFOX:

case types_js_1.BrowserTag.LATEST:
return await firefox.resolveBuildId('FIREFOX_NIGHTLY');
return await firefox.resolveBuildId(firefox.FirefoxChannel.NIGHTLY);
case types_js_1.BrowserTag.BETA:
return await firefox.resolveBuildId(firefox.FirefoxChannel.BETA);
case types_js_1.BrowserTag.NIGHTLY:
return await firefox.resolveBuildId(firefox.FirefoxChannel.NIGHTLY);
case types_js_1.BrowserTag.DEVEDITION:
return await firefox.resolveBuildId(firefox.FirefoxChannel.DEVEDITION);
case types_js_1.BrowserTag.STABLE:
return await firefox.resolveBuildId(firefox.FirefoxChannel.STABLE);
case types_js_1.BrowserTag.ESR:
return await firefox.resolveBuildId(firefox.FirefoxChannel.ESR);
case types_js_1.BrowserTag.CANARY:
case types_js_1.BrowserTag.DEV:
case types_js_1.BrowserTag.STABLE:
throw new Error(`${tag} is not supported for ${browser}. Use 'latest' instead.`);
throw new Error(`${tag.toUpperCase()} is not available for Firefox`);
}

@@ -98,9 +106,7 @@ case types_js_1.Browser.CHROME: {

return await chrome.resolveBuildId(types_js_1.ChromeReleaseChannel.STABLE);
default:
const result = await chrome.resolveBuildId(tag);
if (result) {
return result;
}
case types_js_1.BrowserTag.NIGHTLY:
case types_js_1.BrowserTag.DEVEDITION:
case types_js_1.BrowserTag.ESR:
throw new Error(`${tag.toUpperCase()} is not available for Chrome`);
}
return tag;
}

@@ -118,9 +124,7 @@ case types_js_1.Browser.CHROMEDRIVER: {

return await chromedriver.resolveBuildId(types_js_1.ChromeReleaseChannel.STABLE);
default:
const result = await chromedriver.resolveBuildId(tag);
if (result) {
return result;
}
case types_js_1.BrowserTag.NIGHTLY:
case types_js_1.BrowserTag.DEVEDITION:
case types_js_1.BrowserTag.ESR:
throw new Error(`${tag.toUpperCase()} is not available for ChromeDriver`);
}
return tag;
}

@@ -138,9 +142,7 @@ case types_js_1.Browser.CHROMEHEADLESSSHELL: {

return await chromeHeadlessShell.resolveBuildId(types_js_1.ChromeReleaseChannel.STABLE);
default:
const result = await chromeHeadlessShell.resolveBuildId(tag);
if (result) {
return result;
}
case types_js_1.BrowserTag.NIGHTLY:
case types_js_1.BrowserTag.DEVEDITION:
case types_js_1.BrowserTag.ESR:
throw new Error(`${tag} is not available for chrome-headless-shell`);
}
return tag;
}

@@ -151,12 +153,46 @@ case types_js_1.Browser.CHROMIUM:

return await chromium.resolveBuildId(platform);
case types_js_1.BrowserTag.BETA:
case types_js_1.BrowserTag.NIGHTLY:
case types_js_1.BrowserTag.CANARY:
case types_js_1.BrowserTag.DEV:
case types_js_1.BrowserTag.DEVEDITION:
case types_js_1.BrowserTag.BETA:
case types_js_1.BrowserTag.STABLE:
throw new Error(`${tag} is not supported for ${browser}. Use 'latest' instead.`);
case types_js_1.BrowserTag.ESR:
throw new Error(`${tag} is not supported for Chromium. Use 'latest' instead.`);
}
}
// We assume the tag is the buildId if it didn't match any keywords.
return tag;
}
/**
* @public
*/
async function resolveBuildId(browser, platform, tag) {
const browserTag = tag;
if (Object.values(types_js_1.BrowserTag).includes(browserTag)) {
return await resolveBuildIdForBrowserTag(browser, platform, browserTag);
}
switch (browser) {
case types_js_1.Browser.FIREFOX:
return tag;
case types_js_1.Browser.CHROME:
const chromeResult = await chrome.resolveBuildId(tag);
if (chromeResult) {
return chromeResult;
}
return tag;
case types_js_1.Browser.CHROMEDRIVER:
const chromeDriverResult = await chromedriver.resolveBuildId(tag);
if (chromeDriverResult) {
return chromeDriverResult;
}
return tag;
case types_js_1.Browser.CHROMEHEADLESSSHELL:
const chromeHeadlessShellResult = await chromeHeadlessShell.resolveBuildId(tag);
if (chromeHeadlessShellResult) {
return chromeHeadlessShellResult;
}
return tag;
case types_js_1.Browser.CHROMIUM:
return tag;
}
}
exports.resolveBuildId = resolveBuildId;

@@ -163,0 +199,0 @@ /**

@@ -9,6 +9,13 @@ /**

export declare function resolveDownloadPath(platform: BrowserPlatform, buildId: string): string[];
export declare function relativeExecutablePath(platform: BrowserPlatform, _buildId: string): string;
export declare function resolveBuildId(channel?: 'FIREFOX_NIGHTLY'): Promise<string>;
export declare function relativeExecutablePath(platform: BrowserPlatform, buildId: string): string;
export declare enum FirefoxChannel {
STABLE = "stable",
ESR = "esr",
DEVEDITION = "devedition",
BETA = "beta",
NIGHTLY = "nightly"
}
export declare function resolveBuildId(channel?: FirefoxChannel): Promise<string>;
export declare function createProfile(options: ProfileOptions): Promise<void>;
export declare function compareVersions(a: string, b: string): number;
//# sourceMappingURL=firefox.d.ts.map

@@ -11,3 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.compareVersions = exports.createProfile = exports.resolveBuildId = exports.relativeExecutablePath = exports.resolveDownloadPath = exports.resolveDownloadUrl = void 0;
exports.compareVersions = exports.createProfile = exports.resolveBuildId = exports.FirefoxChannel = exports.relativeExecutablePath = exports.resolveDownloadPath = exports.resolveDownloadUrl = void 0;
const fs_1 = __importDefault(require("fs"));

@@ -17,3 +17,3 @@ const path_1 = __importDefault(require("path"));

const types_js_1 = require("./types.js");
function archive(platform, buildId) {
function archiveNightly(platform, buildId) {
switch (platform) {

@@ -30,30 +30,120 @@ case types_js_1.BrowserPlatform.LINUX:

}
function resolveDownloadUrl(platform, buildId, baseUrl = 'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
function archive(platform, buildId) {
switch (platform) {
case types_js_1.BrowserPlatform.LINUX:
return `firefox-${buildId}.tar.bz2`;
case types_js_1.BrowserPlatform.MAC_ARM:
case types_js_1.BrowserPlatform.MAC:
return `Firefox ${buildId}.dmg`;
case types_js_1.BrowserPlatform.WIN32:
case types_js_1.BrowserPlatform.WIN64:
return `Firefox Setup ${buildId}.exe`;
}
}
exports.resolveDownloadUrl = resolveDownloadUrl;
function resolveDownloadPath(platform, buildId) {
return [archive(platform, buildId)];
}
exports.resolveDownloadPath = resolveDownloadPath;
function relativeExecutablePath(platform, _buildId) {
function platformName(platform) {
switch (platform) {
case types_js_1.BrowserPlatform.LINUX:
return `linux-x86_64`;
case types_js_1.BrowserPlatform.MAC_ARM:
case types_js_1.BrowserPlatform.MAC:
return path_1.default.join('Firefox Nightly.app', 'Contents', 'MacOS', 'firefox');
case types_js_1.BrowserPlatform.LINUX:
return path_1.default.join('firefox', 'firefox');
return `mac`;
case types_js_1.BrowserPlatform.WIN32:
case types_js_1.BrowserPlatform.WIN64:
return path_1.default.join('firefox', 'firefox.exe');
return platform;
}
}
function parseBuildId(buildId) {
for (const value of Object.values(FirefoxChannel)) {
if (buildId.startsWith(value + '_')) {
buildId = buildId.substring(value.length + 1);
return [value, buildId];
}
}
// Older versions do not have channel as the prefix.«
return [FirefoxChannel.NIGHTLY, buildId];
}
function resolveDownloadUrl(platform, buildId, baseUrl) {
const [channel, resolvedBuildId] = parseBuildId(buildId);
switch (channel) {
case FirefoxChannel.NIGHTLY:
baseUrl ??=
'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central';
break;
case FirefoxChannel.DEVEDITION:
baseUrl ??= 'https://archive.mozilla.org/pub/devedition/releases';
break;
case FirefoxChannel.BETA:
case FirefoxChannel.STABLE:
case FirefoxChannel.ESR:
baseUrl ??= 'https://archive.mozilla.org/pub/firefox/releases';
break;
}
switch (channel) {
case FirefoxChannel.NIGHTLY:
return `${baseUrl}/${resolveDownloadPath(platform, resolvedBuildId).join('/')}`;
case FirefoxChannel.DEVEDITION:
case FirefoxChannel.BETA:
case FirefoxChannel.STABLE:
case FirefoxChannel.ESR:
return `${baseUrl}/${resolvedBuildId}/${platformName(platform)}/en-US/${archive(platform, resolvedBuildId)}`;
}
}
exports.resolveDownloadUrl = resolveDownloadUrl;
function resolveDownloadPath(platform, buildId) {
return [archiveNightly(platform, buildId)];
}
exports.resolveDownloadPath = resolveDownloadPath;
function relativeExecutablePath(platform, buildId) {
const [channel] = parseBuildId(buildId);
switch (channel) {
case FirefoxChannel.NIGHTLY:
switch (platform) {
case types_js_1.BrowserPlatform.MAC_ARM:
case types_js_1.BrowserPlatform.MAC:
return path_1.default.join('Firefox Nightly.app', 'Contents', 'MacOS', 'firefox');
case types_js_1.BrowserPlatform.LINUX:
return path_1.default.join('firefox', 'firefox');
case types_js_1.BrowserPlatform.WIN32:
case types_js_1.BrowserPlatform.WIN64:
return path_1.default.join('firefox', 'firefox.exe');
}
case FirefoxChannel.BETA:
case FirefoxChannel.DEVEDITION:
case FirefoxChannel.ESR:
case FirefoxChannel.STABLE:
switch (platform) {
case types_js_1.BrowserPlatform.MAC_ARM:
case types_js_1.BrowserPlatform.MAC:
return path_1.default.join('Firefox.app', 'Contents', 'MacOS', 'firefox');
case types_js_1.BrowserPlatform.LINUX:
return path_1.default.join('firefox', 'firefox');
case types_js_1.BrowserPlatform.WIN32:
case types_js_1.BrowserPlatform.WIN64:
return path_1.default.join('core', 'firefox.exe');
}
}
}
exports.relativeExecutablePath = relativeExecutablePath;
async function resolveBuildId(channel = 'FIREFOX_NIGHTLY') {
var FirefoxChannel;
(function (FirefoxChannel) {
FirefoxChannel["STABLE"] = "stable";
FirefoxChannel["ESR"] = "esr";
FirefoxChannel["DEVEDITION"] = "devedition";
FirefoxChannel["BETA"] = "beta";
FirefoxChannel["NIGHTLY"] = "nightly";
})(FirefoxChannel || (exports.FirefoxChannel = FirefoxChannel = {}));
async function resolveBuildId(channel = FirefoxChannel.NIGHTLY) {
const channelToVersionKey = {
[FirefoxChannel.ESR]: 'FIREFOX_ESR',
[FirefoxChannel.STABLE]: 'LATEST_FIREFOX_VERSION',
[FirefoxChannel.DEVEDITION]: 'FIREFOX_DEVEDITION',
[FirefoxChannel.BETA]: 'FIREFOX_DEVEDITION',
[FirefoxChannel.NIGHTLY]: 'FIREFOX_NIGHTLY',
};
const versions = (await (0, httpUtil_js_1.getJSON)(new URL('https://product-details.mozilla.org/1.0/firefox_versions.json')));
const version = versions[channel];
const version = versions[channelToVersionKey[channel]];
if (!version) {
throw new Error(`Channel ${channel} is not found.`);
}
return version;
return channel + '_' + version;
}

@@ -192,5 +282,2 @@ exports.resolveBuildId = resolveBuildId;

'media.sanity-test.disabled': true,
// Prevent various error message on the console
// jest-puppeteer asserts that no error message is emitted by the console
'network.cookie.cookieBehavior': 0,
// Disable experimental feature that is only available in Nightly

@@ -197,0 +284,0 @@ 'network.cookie.sameSite.laxByDefault': false,

@@ -36,5 +36,8 @@ /**

CANARY = "canary",
NIGHTLY = "nightly",
BETA = "beta",
DEV = "dev",
DEVEDITION = "devedition",
STABLE = "stable",
ESR = "esr",
LATEST = "latest"

@@ -41,0 +44,0 @@ }

@@ -42,5 +42,8 @@ "use strict";

BrowserTag["CANARY"] = "canary";
BrowserTag["NIGHTLY"] = "nightly";
BrowserTag["BETA"] = "beta";
BrowserTag["DEV"] = "dev";
BrowserTag["DEVEDITION"] = "devedition";
BrowserTag["STABLE"] = "stable";
BrowserTag["ESR"] = "esr";
BrowserTag["LATEST"] = "latest";

@@ -47,0 +50,0 @@ })(BrowserTag || (exports.BrowserTag = BrowserTag = {}));

@@ -147,3 +147,9 @@ "use strict";

yargs.example('$0 install chromium@1083080', 'Install the revision 1083080 of the Chromium browser.');
yargs.example('$0 install firefox', 'Install the latest available build of the Firefox browser.');
yargs.example('$0 install firefox', 'Install the latest nightly available build of the Firefox browser.');
yargs.example('$0 install firefox@stable', 'Install the latest stable build of the Firefox browser.');
yargs.example('$0 install firefox@beta', 'Install the latest beta build of the Firefox browser.');
yargs.example('$0 install firefox@devedition', 'Install the latest devedition build of the Firefox browser.');
yargs.example('$0 install firefox@esr', 'Install the latest ESR build of the Firefox browser.');
yargs.example('$0 install firefox@nightly', 'Install the latest nightly build of the Firefox browser.');
yargs.example('$0 install firefox@stable_111.0.1', 'Install a specific version of the Firefox browser.');
yargs.example('$0 install firefox --platform mac', 'Install the latest Mac (Intel) build of the Firefox browser.');

@@ -267,3 +273,3 @@ if (this.#allowCachePathOverride) {

if (!progressBar) {
progressBar = new progress_1.default(`Downloading ${browser} r${buildId} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `, {
progressBar = new progress_1.default(`Downloading ${browser} ${buildId} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `, {
complete: '=',

@@ -270,0 +276,0 @@ incomplete: ' ',

@@ -58,2 +58,13 @@ "use strict";

}
else if (archivePath.endsWith('.exe')) {
// Firefox on Windows.
const result = (0, child_process_1.spawnSync)(archivePath, [`/ExtractDir=${folderPath}`], {
env: {
__compat_layer: 'RunAsInvoker',
},
});
if (result.status !== 0) {
throw new Error(`Failed to extract ${archivePath} to ${folderPath}: ${result.output}`);
}
}
else {

@@ -60,0 +71,0 @@ throw new Error(`Unsupported archive format: ${archivePath}`);

@@ -67,2 +67,5 @@ "use strict";

httpRequest(new url_1.URL(res.headers.location), method, response);
// consume response data to free up memory
// And prevents the connection from being kept alive
res.resume();
}

@@ -69,0 +72,0 @@ else {

@@ -42,5 +42,5 @@ /**

/**
* @public
* @internal
*/
export async function resolveBuildId(browser, platform, tag) {
async function resolveBuildIdForBrowserTag(browser, platform, tag) {
switch (browser) {

@@ -50,8 +50,16 @@ case Browser.FIREFOX:

case BrowserTag.LATEST:
return await firefox.resolveBuildId('FIREFOX_NIGHTLY');
return await firefox.resolveBuildId(firefox.FirefoxChannel.NIGHTLY);
case BrowserTag.BETA:
return await firefox.resolveBuildId(firefox.FirefoxChannel.BETA);
case BrowserTag.NIGHTLY:
return await firefox.resolveBuildId(firefox.FirefoxChannel.NIGHTLY);
case BrowserTag.DEVEDITION:
return await firefox.resolveBuildId(firefox.FirefoxChannel.DEVEDITION);
case BrowserTag.STABLE:
return await firefox.resolveBuildId(firefox.FirefoxChannel.STABLE);
case BrowserTag.ESR:
return await firefox.resolveBuildId(firefox.FirefoxChannel.ESR);
case BrowserTag.CANARY:
case BrowserTag.DEV:
case BrowserTag.STABLE:
throw new Error(`${tag} is not supported for ${browser}. Use 'latest' instead.`);
throw new Error(`${tag.toUpperCase()} is not available for Firefox`);
}

@@ -70,9 +78,7 @@ case Browser.CHROME: {

return await chrome.resolveBuildId(ChromeReleaseChannel.STABLE);
default:
const result = await chrome.resolveBuildId(tag);
if (result) {
return result;
}
case BrowserTag.NIGHTLY:
case BrowserTag.DEVEDITION:
case BrowserTag.ESR:
throw new Error(`${tag.toUpperCase()} is not available for Chrome`);
}
return tag;
}

@@ -90,9 +96,7 @@ case Browser.CHROMEDRIVER: {

return await chromedriver.resolveBuildId(ChromeReleaseChannel.STABLE);
default:
const result = await chromedriver.resolveBuildId(tag);
if (result) {
return result;
}
case BrowserTag.NIGHTLY:
case BrowserTag.DEVEDITION:
case BrowserTag.ESR:
throw new Error(`${tag.toUpperCase()} is not available for ChromeDriver`);
}
return tag;
}

@@ -110,9 +114,7 @@ case Browser.CHROMEHEADLESSSHELL: {

return await chromeHeadlessShell.resolveBuildId(ChromeReleaseChannel.STABLE);
default:
const result = await chromeHeadlessShell.resolveBuildId(tag);
if (result) {
return result;
}
case BrowserTag.NIGHTLY:
case BrowserTag.DEVEDITION:
case BrowserTag.ESR:
throw new Error(`${tag} is not available for chrome-headless-shell`);
}
return tag;
}

@@ -123,11 +125,12 @@ case Browser.CHROMIUM:

return await chromium.resolveBuildId(platform);
case BrowserTag.BETA:
case BrowserTag.NIGHTLY:
case BrowserTag.CANARY:
case BrowserTag.DEV:
case BrowserTag.DEVEDITION:
case BrowserTag.BETA:
case BrowserTag.STABLE:
throw new Error(`${tag} is not supported for ${browser}. Use 'latest' instead.`);
case BrowserTag.ESR:
throw new Error(`${tag} is not supported for Chromium. Use 'latest' instead.`);
}
}
// We assume the tag is the buildId if it didn't match any keywords.
return tag;
}

@@ -137,2 +140,35 @@ /**

*/
export async function resolveBuildId(browser, platform, tag) {
const browserTag = tag;
if (Object.values(BrowserTag).includes(browserTag)) {
return await resolveBuildIdForBrowserTag(browser, platform, browserTag);
}
switch (browser) {
case Browser.FIREFOX:
return tag;
case Browser.CHROME:
const chromeResult = await chrome.resolveBuildId(tag);
if (chromeResult) {
return chromeResult;
}
return tag;
case Browser.CHROMEDRIVER:
const chromeDriverResult = await chromedriver.resolveBuildId(tag);
if (chromeDriverResult) {
return chromeDriverResult;
}
return tag;
case Browser.CHROMEHEADLESSSHELL:
const chromeHeadlessShellResult = await chromeHeadlessShell.resolveBuildId(tag);
if (chromeHeadlessShellResult) {
return chromeHeadlessShellResult;
}
return tag;
case Browser.CHROMIUM:
return tag;
}
}
/**
* @public
*/
export async function createProfile(browser, opts) {

@@ -139,0 +175,0 @@ switch (browser) {

@@ -9,6 +9,13 @@ /**

export declare function resolveDownloadPath(platform: BrowserPlatform, buildId: string): string[];
export declare function relativeExecutablePath(platform: BrowserPlatform, _buildId: string): string;
export declare function resolveBuildId(channel?: 'FIREFOX_NIGHTLY'): Promise<string>;
export declare function relativeExecutablePath(platform: BrowserPlatform, buildId: string): string;
export declare enum FirefoxChannel {
STABLE = "stable",
ESR = "esr",
DEVEDITION = "devedition",
BETA = "beta",
NIGHTLY = "nightly"
}
export declare function resolveBuildId(channel?: FirefoxChannel): Promise<string>;
export declare function createProfile(options: ProfileOptions): Promise<void>;
export declare function compareVersions(a: string, b: string): number;
//# sourceMappingURL=firefox.d.ts.map

@@ -10,3 +10,3 @@ /**

import { BrowserPlatform } from './types.js';
function archive(platform, buildId) {
function archiveNightly(platform, buildId) {
switch (platform) {

@@ -23,27 +23,117 @@ case BrowserPlatform.LINUX:

}
export function resolveDownloadUrl(platform, buildId, baseUrl = 'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
function archive(platform, buildId) {
switch (platform) {
case BrowserPlatform.LINUX:
return `firefox-${buildId}.tar.bz2`;
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return `Firefox ${buildId}.dmg`;
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return `Firefox Setup ${buildId}.exe`;
}
}
export function resolveDownloadPath(platform, buildId) {
return [archive(platform, buildId)];
}
export function relativeExecutablePath(platform, _buildId) {
function platformName(platform) {
switch (platform) {
case BrowserPlatform.LINUX:
return `linux-x86_64`;
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return path.join('Firefox Nightly.app', 'Contents', 'MacOS', 'firefox');
case BrowserPlatform.LINUX:
return path.join('firefox', 'firefox');
return `mac`;
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return path.join('firefox', 'firefox.exe');
return platform;
}
}
export async function resolveBuildId(channel = 'FIREFOX_NIGHTLY') {
function parseBuildId(buildId) {
for (const value of Object.values(FirefoxChannel)) {
if (buildId.startsWith(value + '_')) {
buildId = buildId.substring(value.length + 1);
return [value, buildId];
}
}
// Older versions do not have channel as the prefix.«
return [FirefoxChannel.NIGHTLY, buildId];
}
export function resolveDownloadUrl(platform, buildId, baseUrl) {
const [channel, resolvedBuildId] = parseBuildId(buildId);
switch (channel) {
case FirefoxChannel.NIGHTLY:
baseUrl ??=
'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central';
break;
case FirefoxChannel.DEVEDITION:
baseUrl ??= 'https://archive.mozilla.org/pub/devedition/releases';
break;
case FirefoxChannel.BETA:
case FirefoxChannel.STABLE:
case FirefoxChannel.ESR:
baseUrl ??= 'https://archive.mozilla.org/pub/firefox/releases';
break;
}
switch (channel) {
case FirefoxChannel.NIGHTLY:
return `${baseUrl}/${resolveDownloadPath(platform, resolvedBuildId).join('/')}`;
case FirefoxChannel.DEVEDITION:
case FirefoxChannel.BETA:
case FirefoxChannel.STABLE:
case FirefoxChannel.ESR:
return `${baseUrl}/${resolvedBuildId}/${platformName(platform)}/en-US/${archive(platform, resolvedBuildId)}`;
}
}
export function resolveDownloadPath(platform, buildId) {
return [archiveNightly(platform, buildId)];
}
export function relativeExecutablePath(platform, buildId) {
const [channel] = parseBuildId(buildId);
switch (channel) {
case FirefoxChannel.NIGHTLY:
switch (platform) {
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return path.join('Firefox Nightly.app', 'Contents', 'MacOS', 'firefox');
case BrowserPlatform.LINUX:
return path.join('firefox', 'firefox');
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return path.join('firefox', 'firefox.exe');
}
case FirefoxChannel.BETA:
case FirefoxChannel.DEVEDITION:
case FirefoxChannel.ESR:
case FirefoxChannel.STABLE:
switch (platform) {
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return path.join('Firefox.app', 'Contents', 'MacOS', 'firefox');
case BrowserPlatform.LINUX:
return path.join('firefox', 'firefox');
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return path.join('core', 'firefox.exe');
}
}
}
export var FirefoxChannel;
(function (FirefoxChannel) {
FirefoxChannel["STABLE"] = "stable";
FirefoxChannel["ESR"] = "esr";
FirefoxChannel["DEVEDITION"] = "devedition";
FirefoxChannel["BETA"] = "beta";
FirefoxChannel["NIGHTLY"] = "nightly";
})(FirefoxChannel || (FirefoxChannel = {}));
export async function resolveBuildId(channel = FirefoxChannel.NIGHTLY) {
const channelToVersionKey = {
[FirefoxChannel.ESR]: 'FIREFOX_ESR',
[FirefoxChannel.STABLE]: 'LATEST_FIREFOX_VERSION',
[FirefoxChannel.DEVEDITION]: 'FIREFOX_DEVEDITION',
[FirefoxChannel.BETA]: 'FIREFOX_DEVEDITION',
[FirefoxChannel.NIGHTLY]: 'FIREFOX_NIGHTLY',
};
const versions = (await getJSON(new URL('https://product-details.mozilla.org/1.0/firefox_versions.json')));
const version = versions[channel];
const version = versions[channelToVersionKey[channel]];
if (!version) {
throw new Error(`Channel ${channel} is not found.`);
}
return version;
return channel + '_' + version;
}

@@ -180,5 +270,2 @@ export async function createProfile(options) {

'media.sanity-test.disabled': true,
// Prevent various error message on the console
// jest-puppeteer asserts that no error message is emitted by the console
'network.cookie.cookieBehavior': 0,
// Disable experimental feature that is only available in Nightly

@@ -185,0 +272,0 @@ 'network.cookie.sameSite.laxByDefault': false,

@@ -36,5 +36,8 @@ /**

CANARY = "canary",
NIGHTLY = "nightly",
BETA = "beta",
DEV = "dev",
DEVEDITION = "devedition",
STABLE = "stable",
ESR = "esr",
LATEST = "latest"

@@ -41,0 +44,0 @@ }

@@ -39,5 +39,8 @@ /**

BrowserTag["CANARY"] = "canary";
BrowserTag["NIGHTLY"] = "nightly";
BrowserTag["BETA"] = "beta";
BrowserTag["DEV"] = "dev";
BrowserTag["DEVEDITION"] = "devedition";
BrowserTag["STABLE"] = "stable";
BrowserTag["ESR"] = "esr";
BrowserTag["LATEST"] = "latest";

@@ -44,0 +47,0 @@ })(BrowserTag || (BrowserTag = {}));

@@ -118,3 +118,9 @@ /**

yargs.example('$0 install chromium@1083080', 'Install the revision 1083080 of the Chromium browser.');
yargs.example('$0 install firefox', 'Install the latest available build of the Firefox browser.');
yargs.example('$0 install firefox', 'Install the latest nightly available build of the Firefox browser.');
yargs.example('$0 install firefox@stable', 'Install the latest stable build of the Firefox browser.');
yargs.example('$0 install firefox@beta', 'Install the latest beta build of the Firefox browser.');
yargs.example('$0 install firefox@devedition', 'Install the latest devedition build of the Firefox browser.');
yargs.example('$0 install firefox@esr', 'Install the latest ESR build of the Firefox browser.');
yargs.example('$0 install firefox@nightly', 'Install the latest nightly build of the Firefox browser.');
yargs.example('$0 install firefox@stable_111.0.1', 'Install a specific version of the Firefox browser.');
yargs.example('$0 install firefox --platform mac', 'Install the latest Mac (Intel) build of the Firefox browser.');

@@ -237,3 +243,3 @@ if (this.#allowCachePathOverride) {

if (!progressBar) {
progressBar = new ProgressBar(`Downloading ${browser} r${buildId} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `, {
progressBar = new ProgressBar(`Downloading ${browser} ${buildId} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `, {
complete: '=',

@@ -240,0 +246,0 @@ incomplete: ' ',

@@ -6,3 +6,3 @@ /**

*/
import { exec as execChildProcess } from 'child_process';
import { exec as execChildProcess, spawnSync } from 'child_process';
import { createReadStream } from 'fs';

@@ -30,2 +30,13 @@ import { mkdir, readdir } from 'fs/promises';

}
else if (archivePath.endsWith('.exe')) {
// Firefox on Windows.
const result = spawnSync(archivePath, [`/ExtractDir=${folderPath}`], {
env: {
__compat_layer: 'RunAsInvoker',
},
});
if (result.status !== 0) {
throw new Error(`Failed to extract ${archivePath} to ${folderPath}: ${result.output}`);
}
}
else {

@@ -32,0 +43,0 @@ throw new Error(`Unsupported archive format: ${archivePath}`);

@@ -40,2 +40,5 @@ /**

httpRequest(new URL(res.headers.location), method, response);
// consume response data to free up memory
// And prevents the connection from being kept alive
res.resume();
}

@@ -42,0 +45,0 @@ else {

{
"name": "@puppeteer/browsers",
"version": "2.1.0",
"version": "2.2.0",
"description": "Download and launch browsers",

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

@@ -57,24 +57,32 @@ /**

/**
* @public
* @internal
*/
export async function resolveBuildId(
async function resolveBuildIdForBrowserTag(
browser: Browser,
platform: BrowserPlatform,
tag: string
tag: BrowserTag
): Promise<string> {
switch (browser) {
case Browser.FIREFOX:
switch (tag as BrowserTag) {
switch (tag) {
case BrowserTag.LATEST:
return await firefox.resolveBuildId('FIREFOX_NIGHTLY');
return await firefox.resolveBuildId(firefox.FirefoxChannel.NIGHTLY);
case BrowserTag.BETA:
return await firefox.resolveBuildId(firefox.FirefoxChannel.BETA);
case BrowserTag.NIGHTLY:
return await firefox.resolveBuildId(firefox.FirefoxChannel.NIGHTLY);
case BrowserTag.DEVEDITION:
return await firefox.resolveBuildId(
firefox.FirefoxChannel.DEVEDITION
);
case BrowserTag.STABLE:
return await firefox.resolveBuildId(firefox.FirefoxChannel.STABLE);
case BrowserTag.ESR:
return await firefox.resolveBuildId(firefox.FirefoxChannel.ESR);
case BrowserTag.CANARY:
case BrowserTag.DEV:
case BrowserTag.STABLE:
throw new Error(
`${tag} is not supported for ${browser}. Use 'latest' instead.`
);
throw new Error(`${tag.toUpperCase()} is not available for Firefox`);
}
case Browser.CHROME: {
switch (tag as BrowserTag) {
switch (tag) {
case BrowserTag.LATEST:

@@ -90,9 +98,7 @@ return await chrome.resolveBuildId(ChromeReleaseChannel.CANARY);

return await chrome.resolveBuildId(ChromeReleaseChannel.STABLE);
default:
const result = await chrome.resolveBuildId(tag);
if (result) {
return result;
}
case BrowserTag.NIGHTLY:
case BrowserTag.DEVEDITION:
case BrowserTag.ESR:
throw new Error(`${tag.toUpperCase()} is not available for Chrome`);
}
return tag;
}

@@ -110,9 +116,9 @@ case Browser.CHROMEDRIVER: {

return await chromedriver.resolveBuildId(ChromeReleaseChannel.STABLE);
default:
const result = await chromedriver.resolveBuildId(tag);
if (result) {
return result;
}
case BrowserTag.NIGHTLY:
case BrowserTag.DEVEDITION:
case BrowserTag.ESR:
throw new Error(
`${tag.toUpperCase()} is not available for ChromeDriver`
);
}
return tag;
}

@@ -138,25 +144,24 @@ case Browser.CHROMEHEADLESSSHELL: {

);
default:
const result = await chromeHeadlessShell.resolveBuildId(tag);
if (result) {
return result;
}
case BrowserTag.NIGHTLY:
case BrowserTag.DEVEDITION:
case BrowserTag.ESR:
throw new Error(`${tag} is not available for chrome-headless-shell`);
}
return tag;
}
case Browser.CHROMIUM:
switch (tag as BrowserTag) {
switch (tag) {
case BrowserTag.LATEST:
return await chromium.resolveBuildId(platform);
case BrowserTag.BETA:
case BrowserTag.NIGHTLY:
case BrowserTag.CANARY:
case BrowserTag.DEV:
case BrowserTag.DEVEDITION:
case BrowserTag.BETA:
case BrowserTag.STABLE:
case BrowserTag.ESR:
throw new Error(
`${tag} is not supported for ${browser}. Use 'latest' instead.`
`${tag} is not supported for Chromium. Use 'latest' instead.`
);
}
}
// We assume the tag is the buildId if it didn't match any keywords.
return tag;
}

@@ -167,2 +172,42 @@

*/
export async function resolveBuildId(
browser: Browser,
platform: BrowserPlatform,
tag: string
): Promise<string> {
const browserTag = tag as BrowserTag;
if (Object.values(BrowserTag).includes(browserTag)) {
return await resolveBuildIdForBrowserTag(browser, platform, browserTag);
}
switch (browser) {
case Browser.FIREFOX:
return tag;
case Browser.CHROME:
const chromeResult = await chrome.resolveBuildId(tag);
if (chromeResult) {
return chromeResult;
}
return tag;
case Browser.CHROMEDRIVER:
const chromeDriverResult = await chromedriver.resolveBuildId(tag);
if (chromeDriverResult) {
return chromeDriverResult;
}
return tag;
case Browser.CHROMEHEADLESSSHELL:
const chromeHeadlessShellResult =
await chromeHeadlessShell.resolveBuildId(tag);
if (chromeHeadlessShellResult) {
return chromeHeadlessShellResult;
}
return tag;
case Browser.CHROMIUM:
return tag;
}
}
/**
* @public
*/
export async function createProfile(

@@ -169,0 +214,0 @@ browser: Browser,

@@ -14,3 +14,3 @@ /**

function archive(platform: BrowserPlatform, buildId: string): string {
function archiveNightly(platform: BrowserPlatform, buildId: string): string {
switch (platform) {

@@ -28,8 +28,68 @@ case BrowserPlatform.LINUX:

function archive(platform: BrowserPlatform, buildId: string): string {
switch (platform) {
case BrowserPlatform.LINUX:
return `firefox-${buildId}.tar.bz2`;
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return `Firefox ${buildId}.dmg`;
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return `Firefox Setup ${buildId}.exe`;
}
}
function platformName(platform: BrowserPlatform): string {
switch (platform) {
case BrowserPlatform.LINUX:
return `linux-x86_64`;
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return `mac`;
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return platform;
}
}
function parseBuildId(buildId: string): [FirefoxChannel, string] {
for (const value of Object.values(FirefoxChannel)) {
if (buildId.startsWith(value + '_')) {
buildId = buildId.substring(value.length + 1);
return [value, buildId];
}
}
// Older versions do not have channel as the prefix.«
return [FirefoxChannel.NIGHTLY, buildId];
}
export function resolveDownloadUrl(
platform: BrowserPlatform,
buildId: string,
baseUrl = 'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central'
baseUrl?: string
): string {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
const [channel, resolvedBuildId] = parseBuildId(buildId);
switch (channel) {
case FirefoxChannel.NIGHTLY:
baseUrl ??=
'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central';
break;
case FirefoxChannel.DEVEDITION:
baseUrl ??= 'https://archive.mozilla.org/pub/devedition/releases';
break;
case FirefoxChannel.BETA:
case FirefoxChannel.STABLE:
case FirefoxChannel.ESR:
baseUrl ??= 'https://archive.mozilla.org/pub/firefox/releases';
break;
}
switch (channel) {
case FirefoxChannel.NIGHTLY:
return `${baseUrl}/${resolveDownloadPath(platform, resolvedBuildId).join('/')}`;
case FirefoxChannel.DEVEDITION:
case FirefoxChannel.BETA:
case FirefoxChannel.STABLE:
case FirefoxChannel.ESR:
return `${baseUrl}/${resolvedBuildId}/${platformName(platform)}/en-US/${archive(platform, resolvedBuildId)}`;
}
}

@@ -41,3 +101,3 @@

): string[] {
return [archive(platform, buildId)];
return [archiveNightly(platform, buildId)];
}

@@ -47,27 +107,65 @@

platform: BrowserPlatform,
_buildId: string
buildId: string
): string {
switch (platform) {
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return path.join('Firefox Nightly.app', 'Contents', 'MacOS', 'firefox');
case BrowserPlatform.LINUX:
return path.join('firefox', 'firefox');
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return path.join('firefox', 'firefox.exe');
const [channel] = parseBuildId(buildId);
switch (channel) {
case FirefoxChannel.NIGHTLY:
switch (platform) {
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return path.join(
'Firefox Nightly.app',
'Contents',
'MacOS',
'firefox'
);
case BrowserPlatform.LINUX:
return path.join('firefox', 'firefox');
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return path.join('firefox', 'firefox.exe');
}
case FirefoxChannel.BETA:
case FirefoxChannel.DEVEDITION:
case FirefoxChannel.ESR:
case FirefoxChannel.STABLE:
switch (platform) {
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return path.join('Firefox.app', 'Contents', 'MacOS', 'firefox');
case BrowserPlatform.LINUX:
return path.join('firefox', 'firefox');
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return path.join('core', 'firefox.exe');
}
}
}
export enum FirefoxChannel {
STABLE = 'stable',
ESR = 'esr',
DEVEDITION = 'devedition',
BETA = 'beta',
NIGHTLY = 'nightly',
}
export async function resolveBuildId(
channel: 'FIREFOX_NIGHTLY' = 'FIREFOX_NIGHTLY'
channel: FirefoxChannel = FirefoxChannel.NIGHTLY
): Promise<string> {
const channelToVersionKey = {
[FirefoxChannel.ESR]: 'FIREFOX_ESR',
[FirefoxChannel.STABLE]: 'LATEST_FIREFOX_VERSION',
[FirefoxChannel.DEVEDITION]: 'FIREFOX_DEVEDITION',
[FirefoxChannel.BETA]: 'FIREFOX_DEVEDITION',
[FirefoxChannel.NIGHTLY]: 'FIREFOX_NIGHTLY',
};
const versions = (await getJSON(
new URL('https://product-details.mozilla.org/1.0/firefox_versions.json')
)) as Record<string, string>;
const version = versions[channel];
const version = versions[channelToVersionKey[channel]];
if (!version) {
throw new Error(`Channel ${channel} is not found.`);
}
return version;
return channel + '_' + version;
}

@@ -242,6 +340,2 @@

// Prevent various error message on the console
// jest-puppeteer asserts that no error message is emitted by the console
'network.cookie.cookieBehavior': 0,
// Disable experimental feature that is only available in Nightly

@@ -248,0 +342,0 @@ 'network.cookie.sameSite.laxByDefault': false,

@@ -39,5 +39,8 @@ /**

CANARY = 'canary',
NIGHTLY = 'nightly',
BETA = 'beta',
DEV = 'dev',
DEVEDITION = 'devedition',
STABLE = 'stable',
ESR = 'esr',
LATEST = 'latest',

@@ -44,0 +47,0 @@ }

@@ -225,5 +225,29 @@ /**

'$0 install firefox',
'Install the latest available build of the Firefox browser.'
'Install the latest nightly available build of the Firefox browser.'
);
yargs.example(
'$0 install firefox@stable',
'Install the latest stable build of the Firefox browser.'
);
yargs.example(
'$0 install firefox@beta',
'Install the latest beta build of the Firefox browser.'
);
yargs.example(
'$0 install firefox@devedition',
'Install the latest devedition build of the Firefox browser.'
);
yargs.example(
'$0 install firefox@esr',
'Install the latest ESR build of the Firefox browser.'
);
yargs.example(
'$0 install firefox@nightly',
'Install the latest nightly build of the Firefox browser.'
);
yargs.example(
'$0 install firefox@stable_111.0.1',
'Install a specific version of the Firefox browser.'
);
yargs.example(
'$0 install firefox --platform mac',

@@ -399,3 +423,3 @@ 'Install the latest Mac (Intel) build of the Firefox browser.'

progressBar = new ProgressBar(
`Downloading ${browser} r${buildId} - ${toMegabytes(
`Downloading ${browser} ${buildId} - ${toMegabytes(
totalBytes

@@ -402,0 +426,0 @@ )} [:bar] :percent :etas `,

@@ -7,3 +7,3 @@ /**

import {exec as execChildProcess} from 'child_process';
import {exec as execChildProcess, spawnSync} from 'child_process';
import {createReadStream} from 'fs';

@@ -34,2 +34,14 @@ import {mkdir, readdir} from 'fs/promises';

await installDMG(archivePath, folderPath);
} else if (archivePath.endsWith('.exe')) {
// Firefox on Windows.
const result = spawnSync(archivePath, [`/ExtractDir=${folderPath}`], {
env: {
__compat_layer: 'RunAsInvoker',
},
});
if (result.status !== 0) {
throw new Error(
`Failed to extract ${archivePath} to ${folderPath}: ${result.output}`
);
}
} else {

@@ -36,0 +48,0 @@ throw new Error(`Unsupported archive format: ${archivePath}`);

@@ -57,2 +57,5 @@ /**

httpRequest(new URL(res.headers.location), method, response);
// consume response data to free up memory
// And prevents the connection from being kept alive
res.resume();
} else {

@@ -59,0 +62,0 @@ response(res);

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

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

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