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 0.1.1 to 0.2.0

lib/cjs/browser-data/browser-data.d.ts

6

lib/cjs/CLI.d.ts

@@ -16,7 +16,11 @@ /**

*/
/// <reference types="node" />
import * as readline from 'readline';
import { Browser } from './browser-data/browser-data.js';
export declare class CLI {
#private;
constructor(cachePath?: string);
constructor(cachePath?: string, rl?: readline.Interface);
run(argv: string[]): Promise<void>;
}
export declare function makeProgressCallback(browser: Browser, buildId: string): (downloadedBytes: number, totalBytes: number) => void;
//# sourceMappingURL=CLI.d.ts.map

@@ -17,2 +17,25 @@ "use strict";

*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

@@ -32,10 +55,12 @@ if (kind === "m") throw new TypeError("Private method is not writable");

};
var _CLI_instances, _CLI_cachePath, _CLI_defineBrowserParameter, _CLI_definePlatformParameter, _CLI_definePathParameter, _CLI_parseBrowser, _CLI_parseBuildId, _CLI_toMegabytes, _CLI_makeProgressCallback;
var _CLI_instances, _CLI_cachePath, _CLI_rl, _CLI_defineBrowserParameter, _CLI_definePlatformParameter, _CLI_definePathParameter, _CLI_parseBrowser, _CLI_parseBuildId;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLI = void 0;
exports.makeProgressCallback = exports.CLI = void 0;
const process_1 = require("process");
const readline = __importStar(require("readline"));
const progress_1 = __importDefault(require("progress"));
const yargs_1 = __importDefault(require("yargs"));
const helpers_1 = require("yargs/helpers");
const browsers_js_1 = require("./browsers/browsers.js");
const types_js_1 = require("./browsers/types.js");
const browser_data_js_1 = require("./browser-data/browser-data.js");
const Cache_js_1 = require("./Cache.js");
const detectPlatform_js_1 = require("./detectPlatform.js");

@@ -45,13 +70,22 @@ const fetch_js_1 = require("./fetch.js");

class CLI {
constructor(cachePath = process.cwd()) {
constructor(cachePath = process.cwd(), rl) {
_CLI_instances.add(this);
_CLI_cachePath.set(this, void 0);
_CLI_rl.set(this, void 0);
__classPrivateFieldSet(this, _CLI_cachePath, cachePath, "f");
__classPrivateFieldSet(this, _CLI_rl, rl, "f");
}
async run(argv) {
await (0, yargs_1.default)((0, helpers_1.hideBin)(argv))
.command('install <browser>', 'Download and install the specified browser', yargs => {
.scriptName('@puppeteer/browsers')
.command('install <browser>', 'Download and install the specified browser. If successful, the command outputs the actual browser buildId that was installed and the absolute path to the browser executable (format: <browser>@<buildID> <path>).', yargs => {
__classPrivateFieldGet(this, _CLI_instances, "m", _CLI_defineBrowserParameter).call(this, yargs);
__classPrivateFieldGet(this, _CLI_instances, "m", _CLI_definePlatformParameter).call(this, yargs);
__classPrivateFieldGet(this, _CLI_instances, "m", _CLI_definePathParameter).call(this, yargs);
yargs.example('$0 install chrome', 'Install the latest available build of the Chrome browser.');
yargs.example('$0 install chrome@latest', 'Install the latest available build for the Chrome browser.');
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 --platform mac', 'Install the latest Mac (Intel) build of the Firefox browser.');
yargs.example('$0 install firefox --path /tmp/my-browser-cache', 'Install to the specified cache directory.');
}, async (argv) => {

@@ -64,3 +98,3 @@ var _a, _b, _c;

}
args.browser.buildId = await (0, browsers_js_1.resolveBuildId)(args.browser.name, args.platform, args.browser.buildId);
args.browser.buildId = await (0, browser_data_js_1.resolveBuildId)(args.browser.name, args.platform, args.browser.buildId);
await (0, fetch_js_1.fetch)({

@@ -71,3 +105,3 @@ browser: args.browser.name,

cacheDir: (_b = args.path) !== null && _b !== void 0 ? _b : __classPrivateFieldGet(this, _CLI_cachePath, "f"),
downloadProgressCallback: __classPrivateFieldGet(this, _CLI_instances, "m", _CLI_makeProgressCallback).call(this, args.browser.name, args.browser.buildId),
downloadProgressCallback: makeProgressCallback(args.browser.name, args.browser.buildId),
});

@@ -95,2 +129,6 @@ console.log(`${args.browser.name}@${args.browser.buildId} ${(0, launcher_js_1.computeExecutablePath)({

});
yargs.example('$0 launch chrome@1083080', 'Launch the Chrome browser identified by the revision 1083080.');
yargs.example('$0 launch firefox@112.0a1', 'Launch the Firefox browser identified by the milestone 112.0a1.');
yargs.example('$0 launch chrome@1083080 --detached', 'Launch the browser but detach the sub-processes.');
yargs.example('$0 launch chrome@canary --system', 'Try to locate the Canary build of Chrome installed on the system and launch it.');
}, async (argv) => {

@@ -117,4 +155,23 @@ var _a;

})
.command('clear', 'Removes all installed browsers from the specified cache directory', yargs => {
__classPrivateFieldGet(this, _CLI_instances, "m", _CLI_definePathParameter).call(this, yargs, true);
}, async (argv) => {
var _a, _b;
const args = argv;
const cacheDir = (_a = args.path) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _CLI_cachePath, "f");
const rl = (_b = __classPrivateFieldGet(this, _CLI_rl, "f")) !== null && _b !== void 0 ? _b : readline.createInterface({ input: process_1.stdin, output: process_1.stdout });
rl.question(`Do you want to permanently and recursively delete the content of ${cacheDir} (yes/No)? `, answer => {
rl.close();
if (!['y', 'yes'].includes(answer.toLowerCase().trim())) {
console.log('Cancelled.');
return;
}
const cache = new Cache_js_1.Cache(cacheDir);
cache.clear();
console.log(`${cacheDir} cleared.`);
});
})
.demandCommand(1)
.help()
.wrap(Math.min(120, yargs_1.default.terminalWidth()))
.parse();

@@ -124,5 +181,5 @@ }

exports.CLI = CLI;
_CLI_cachePath = new WeakMap(), _CLI_instances = new WeakSet(), _CLI_defineBrowserParameter = function _CLI_defineBrowserParameter(yargs) {
_CLI_cachePath = new WeakMap(), _CLI_rl = new WeakMap(), _CLI_instances = new WeakSet(), _CLI_defineBrowserParameter = function _CLI_defineBrowserParameter(yargs) {
yargs.positional('browser', {
description: 'The browser version',
description: 'Which browser to install <browser>[@<buildId|latest>]. `latest` will try to find the latest available build. `buildId` is a browser-specific identifier such as a version or a revision.',
type: 'string',

@@ -140,11 +197,15 @@ coerce: (opt) => {

desc: 'Platform that the binary needs to be compatible with.',
choices: Object.values(types_js_1.BrowserPlatform),
defaultDescription: 'Auto-detected by default.',
choices: Object.values(browser_data_js_1.BrowserPlatform),
defaultDescription: 'Auto-detected',
});
}, _CLI_definePathParameter = function _CLI_definePathParameter(yargs) {
}, _CLI_definePathParameter = function _CLI_definePathParameter(yargs, required = false) {
yargs.option('path', {
type: 'string',
desc: 'Path to the root folder for the browser downloads and installation',
default: process.cwd(),
desc: 'Path to the root folder for the browser downloads and installation. The installation folder structure is compatible with the cache structure used by Puppeteer.',
defaultDescription: 'Current working directory',
...(required ? {} : { default: process.cwd() }),
});
if (required) {
yargs.demandOption('path');
}
}, _CLI_parseBrowser = function _CLI_parseBrowser(version) {

@@ -155,6 +216,4 @@ return version.split('@').shift();

return (_a = version.split('@').pop()) !== null && _a !== void 0 ? _a : 'latest';
}, _CLI_toMegabytes = function _CLI_toMegabytes(bytes) {
const mb = bytes / 1000 / 1000;
return `${Math.round(mb * 10) / 10} MB`;
}, _CLI_makeProgressCallback = function _CLI_makeProgressCallback(browser, buildId) {
};
function makeProgressCallback(browser, buildId) {
let progressBar;

@@ -164,3 +223,3 @@ let lastDownloadedBytes = 0;

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

@@ -176,3 +235,8 @@ incomplete: ' ',

};
};
}
exports.makeProgressCallback = makeProgressCallback;
function toMegabytes(bytes) {
const mb = bytes / 1000 / 1000;
return `${Math.round(mb * 10) / 10} MB`;
}
//# sourceMappingURL=CLI.js.map

2

lib/cjs/detectPlatform.d.ts

@@ -16,4 +16,4 @@ /**

*/
import { BrowserPlatform } from './browsers/browsers.js';
import { BrowserPlatform } from './browser-data/browser-data.js';
export declare function detectBrowserPlatform(): BrowserPlatform | undefined;
//# sourceMappingURL=detectPlatform.d.ts.map

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

const os_1 = __importDefault(require("os"));
const browsers_js_1 = require("./browsers/browsers.js");
const browser_data_js_1 = require("./browser-data/browser-data.js");
function detectBrowserPlatform() {

@@ -30,6 +30,6 @@ const platform = os_1.default.platform();

return os_1.default.arch() === 'arm64'
? browsers_js_1.BrowserPlatform.MAC_ARM
: browsers_js_1.BrowserPlatform.MAC;
? browser_data_js_1.BrowserPlatform.MAC_ARM
: browser_data_js_1.BrowserPlatform.MAC;
case 'linux':
return browsers_js_1.BrowserPlatform.LINUX;
return browser_data_js_1.BrowserPlatform.LINUX;
case 'win32':

@@ -39,4 +39,4 @@ return os_1.default.arch() === 'x64' ||

(os_1.default.arch() === 'arm64' && isWindows11(os_1.default.release()))
? browsers_js_1.BrowserPlatform.WIN64
: browsers_js_1.BrowserPlatform.WIN32;
? browser_data_js_1.BrowserPlatform.WIN64
: browser_data_js_1.BrowserPlatform.WIN32;
default:

@@ -43,0 +43,0 @@ return undefined;

@@ -16,3 +16,3 @@ /**

*/
import { Browser, BrowserPlatform } from './browsers/browsers.js';
import { Browser, BrowserPlatform } from './browser-data/browser-data.js';
/**

@@ -19,0 +19,0 @@ * @public

@@ -27,4 +27,4 @@ "use strict";

const path_1 = __importDefault(require("path"));
const browsers_js_1 = require("./browsers/browsers.js");
const CacheStructure_js_1 = require("./CacheStructure.js");
const browser_data_js_1 = require("./browser-data/browser-data.js");
const Cache_js_1 = require("./Cache.js");
const debug_js_1 = require("./debug.js");

@@ -44,3 +44,3 @@ const detectPlatform_js_1 = require("./detectPlatform.js");

(0, assert_1.default)(fileName, `A malformed download URL was found: ${url}.`);
const structure = new CacheStructure_js_1.CacheStructure(options.cacheDir);
const structure = new Cache_js_1.Cache(options.cacheDir);
const browserRoot = structure.browserRoot(options.browser);

@@ -89,4 +89,4 @@ const archivePath = path_1.default.join(browserRoot, fileName);

function getDownloadUrl(browser, platform, buildId) {
return new URL(browsers_js_1.downloadUrls[browser](platform, buildId));
return new URL(browser_data_js_1.downloadUrls[browser](platform, buildId));
}
//# sourceMappingURL=fetch.js.map

@@ -17,4 +17,3 @@ /**

/// <reference types="node" />
import { Browser, BrowserPlatform } from './browsers/browsers.js';
import { ChromeReleaseChannel } from './browsers/types.js';
import { Browser, BrowserPlatform, ChromeReleaseChannel } from './browser-data/browser-data.js';
/**

@@ -21,0 +20,0 @@ * @public

@@ -39,4 +39,4 @@ "use strict";

const readline_1 = __importDefault(require("readline"));
const browsers_js_1 = require("./browsers/browsers.js");
const CacheStructure_js_1 = require("./CacheStructure.js");
const browser_data_js_1 = require("./browser-data/browser-data.js");
const Cache_js_1 = require("./Cache.js");
const debug_js_1 = require("./debug.js");

@@ -51,4 +51,4 @@ const detectPlatform_js_1 = require("./detectPlatform.js");

}
const installationDir = new CacheStructure_js_1.CacheStructure(options.cacheDir).installationDir(options.browser, options.platform, options.buildId);
return path_1.default.join(installationDir, browsers_js_1.executablePathByBrowser[options.browser](options.platform, options.buildId));
const installationDir = new Cache_js_1.Cache(options.cacheDir).installationDir(options.browser, options.platform, options.buildId);
return path_1.default.join(installationDir, browser_data_js_1.executablePathByBrowser[options.browser](options.platform, options.buildId));
}

@@ -62,3 +62,3 @@ exports.computeExecutablePath = computeExecutablePath;

}
const path = (0, browsers_js_1.resolveSystemExecutablePath)(options.browser, options.platform, options.channel);
const path = (0, browser_data_js_1.resolveSystemExecutablePath)(options.browser, options.platform, options.channel);
try {

@@ -65,0 +65,0 @@ (0, fs_1.accessSync)(path);

@@ -19,3 +19,5 @@ /**

export { detectBrowserPlatform } from './detectPlatform.js';
export { Browser, BrowserPlatform, ChromeReleaseChannel, } from './browsers/browsers.js';
export { resolveBuildId, Browser, BrowserPlatform, ChromeReleaseChannel, } from './browser-data/browser-data.js';
export { CLI, makeProgressCallback } from './CLI.js';
export { Cache } from './Cache.js';
//# sourceMappingURL=main.d.ts.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.ChromeReleaseChannel = exports.BrowserPlatform = exports.Browser = exports.detectBrowserPlatform = exports.canFetch = exports.fetch = exports.WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX = exports.CDP_WEBSOCKET_ENDPOINT_REGEX = exports.computeSystemExecutablePath = exports.computeExecutablePath = exports.launch = void 0;
exports.Cache = exports.makeProgressCallback = exports.CLI = exports.ChromeReleaseChannel = exports.BrowserPlatform = exports.Browser = exports.resolveBuildId = exports.detectBrowserPlatform = exports.canFetch = exports.fetch = exports.WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX = exports.CDP_WEBSOCKET_ENDPOINT_REGEX = exports.computeSystemExecutablePath = exports.computeExecutablePath = exports.launch = void 0;
var launcher_js_1 = require("./launcher.js");

@@ -31,6 +31,12 @@ Object.defineProperty(exports, "launch", { enumerable: true, get: function () { return launcher_js_1.launch; } });

Object.defineProperty(exports, "detectBrowserPlatform", { enumerable: true, get: function () { return detectPlatform_js_1.detectBrowserPlatform; } });
var browsers_js_1 = require("./browsers/browsers.js");
Object.defineProperty(exports, "Browser", { enumerable: true, get: function () { return browsers_js_1.Browser; } });
Object.defineProperty(exports, "BrowserPlatform", { enumerable: true, get: function () { return browsers_js_1.BrowserPlatform; } });
Object.defineProperty(exports, "ChromeReleaseChannel", { enumerable: true, get: function () { return browsers_js_1.ChromeReleaseChannel; } });
var browser_data_js_1 = require("./browser-data/browser-data.js");
Object.defineProperty(exports, "resolveBuildId", { enumerable: true, get: function () { return browser_data_js_1.resolveBuildId; } });
Object.defineProperty(exports, "Browser", { enumerable: true, get: function () { return browser_data_js_1.Browser; } });
Object.defineProperty(exports, "BrowserPlatform", { enumerable: true, get: function () { return browser_data_js_1.BrowserPlatform; } });
Object.defineProperty(exports, "ChromeReleaseChannel", { enumerable: true, get: function () { return browser_data_js_1.ChromeReleaseChannel; } });
var CLI_js_1 = require("./CLI.js");
Object.defineProperty(exports, "CLI", { enumerable: true, get: function () { return CLI_js_1.CLI; } });
Object.defineProperty(exports, "makeProgressCallback", { enumerable: true, get: function () { return CLI_js_1.makeProgressCallback; } });
var Cache_js_1 = require("./Cache.js");
Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return Cache_js_1.Cache; } });
//# sourceMappingURL=main.js.map

@@ -16,7 +16,11 @@ /**

*/
/// <reference types="node" />
import * as readline from 'readline';
import { Browser } from './browser-data/browser-data.js';
export declare class CLI {
#private;
constructor(cachePath?: string);
constructor(cachePath?: string, rl?: readline.Interface);
run(argv: string[]): Promise<void>;
}
export declare function makeProgressCallback(browser: Browser, buildId: string): (downloadedBytes: number, totalBytes: number) => void;
//# sourceMappingURL=CLI.d.ts.map

@@ -27,8 +27,10 @@ /**

};
var _CLI_instances, _CLI_cachePath, _CLI_defineBrowserParameter, _CLI_definePlatformParameter, _CLI_definePathParameter, _CLI_parseBrowser, _CLI_parseBuildId, _CLI_toMegabytes, _CLI_makeProgressCallback;
var _CLI_instances, _CLI_cachePath, _CLI_rl, _CLI_defineBrowserParameter, _CLI_definePlatformParameter, _CLI_definePathParameter, _CLI_parseBrowser, _CLI_parseBuildId;
import { stdin as input, stdout as output } from 'process';
import * as readline from 'readline';
import ProgressBar from 'progress';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { resolveBuildId } from './browsers/browsers.js';
import { BrowserPlatform, } from './browsers/types.js';
import { resolveBuildId, BrowserPlatform, } from './browser-data/browser-data.js';
import { Cache } from './Cache.js';
import { detectBrowserPlatform } from './detectPlatform.js';

@@ -38,13 +40,22 @@ import { fetch } from './fetch.js';

export class CLI {
constructor(cachePath = process.cwd()) {
constructor(cachePath = process.cwd(), rl) {
_CLI_instances.add(this);
_CLI_cachePath.set(this, void 0);
_CLI_rl.set(this, void 0);
__classPrivateFieldSet(this, _CLI_cachePath, cachePath, "f");
__classPrivateFieldSet(this, _CLI_rl, rl, "f");
}
async run(argv) {
await yargs(hideBin(argv))
.command('install <browser>', 'Download and install the specified browser', yargs => {
.scriptName('@puppeteer/browsers')
.command('install <browser>', 'Download and install the specified browser. If successful, the command outputs the actual browser buildId that was installed and the absolute path to the browser executable (format: <browser>@<buildID> <path>).', yargs => {
__classPrivateFieldGet(this, _CLI_instances, "m", _CLI_defineBrowserParameter).call(this, yargs);
__classPrivateFieldGet(this, _CLI_instances, "m", _CLI_definePlatformParameter).call(this, yargs);
__classPrivateFieldGet(this, _CLI_instances, "m", _CLI_definePathParameter).call(this, yargs);
yargs.example('$0 install chrome', 'Install the latest available build of the Chrome browser.');
yargs.example('$0 install chrome@latest', 'Install the latest available build for the Chrome browser.');
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 --platform mac', 'Install the latest Mac (Intel) build of the Firefox browser.');
yargs.example('$0 install firefox --path /tmp/my-browser-cache', 'Install to the specified cache directory.');
}, async (argv) => {

@@ -63,3 +74,3 @@ var _a, _b, _c;

cacheDir: (_b = args.path) !== null && _b !== void 0 ? _b : __classPrivateFieldGet(this, _CLI_cachePath, "f"),
downloadProgressCallback: __classPrivateFieldGet(this, _CLI_instances, "m", _CLI_makeProgressCallback).call(this, args.browser.name, args.browser.buildId),
downloadProgressCallback: makeProgressCallback(args.browser.name, args.browser.buildId),
});

@@ -87,2 +98,6 @@ console.log(`${args.browser.name}@${args.browser.buildId} ${computeExecutablePath({

});
yargs.example('$0 launch chrome@1083080', 'Launch the Chrome browser identified by the revision 1083080.');
yargs.example('$0 launch firefox@112.0a1', 'Launch the Firefox browser identified by the milestone 112.0a1.');
yargs.example('$0 launch chrome@1083080 --detached', 'Launch the browser but detach the sub-processes.');
yargs.example('$0 launch chrome@canary --system', 'Try to locate the Canary build of Chrome installed on the system and launch it.');
}, async (argv) => {

@@ -109,10 +124,29 @@ var _a;

})
.command('clear', 'Removes all installed browsers from the specified cache directory', yargs => {
__classPrivateFieldGet(this, _CLI_instances, "m", _CLI_definePathParameter).call(this, yargs, true);
}, async (argv) => {
var _a, _b;
const args = argv;
const cacheDir = (_a = args.path) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _CLI_cachePath, "f");
const rl = (_b = __classPrivateFieldGet(this, _CLI_rl, "f")) !== null && _b !== void 0 ? _b : readline.createInterface({ input, output });
rl.question(`Do you want to permanently and recursively delete the content of ${cacheDir} (yes/No)? `, answer => {
rl.close();
if (!['y', 'yes'].includes(answer.toLowerCase().trim())) {
console.log('Cancelled.');
return;
}
const cache = new Cache(cacheDir);
cache.clear();
console.log(`${cacheDir} cleared.`);
});
})
.demandCommand(1)
.help()
.wrap(Math.min(120, yargs.terminalWidth()))
.parse();
}
}
_CLI_cachePath = new WeakMap(), _CLI_instances = new WeakSet(), _CLI_defineBrowserParameter = function _CLI_defineBrowserParameter(yargs) {
_CLI_cachePath = new WeakMap(), _CLI_rl = new WeakMap(), _CLI_instances = new WeakSet(), _CLI_defineBrowserParameter = function _CLI_defineBrowserParameter(yargs) {
yargs.positional('browser', {
description: 'The browser version',
description: 'Which browser to install <browser>[@<buildId|latest>]. `latest` will try to find the latest available build. `buildId` is a browser-specific identifier such as a version or a revision.',
type: 'string',

@@ -131,10 +165,14 @@ coerce: (opt) => {

choices: Object.values(BrowserPlatform),
defaultDescription: 'Auto-detected by default.',
defaultDescription: 'Auto-detected',
});
}, _CLI_definePathParameter = function _CLI_definePathParameter(yargs) {
}, _CLI_definePathParameter = function _CLI_definePathParameter(yargs, required = false) {
yargs.option('path', {
type: 'string',
desc: 'Path to the root folder for the browser downloads and installation',
default: process.cwd(),
desc: 'Path to the root folder for the browser downloads and installation. The installation folder structure is compatible with the cache structure used by Puppeteer.',
defaultDescription: 'Current working directory',
...(required ? {} : { default: process.cwd() }),
});
if (required) {
yargs.demandOption('path');
}
}, _CLI_parseBrowser = function _CLI_parseBrowser(version) {

@@ -145,6 +183,4 @@ return version.split('@').shift();

return (_a = version.split('@').pop()) !== null && _a !== void 0 ? _a : 'latest';
}, _CLI_toMegabytes = function _CLI_toMegabytes(bytes) {
const mb = bytes / 1000 / 1000;
return `${Math.round(mb * 10) / 10} MB`;
}, _CLI_makeProgressCallback = function _CLI_makeProgressCallback(browser, buildId) {
};
export function makeProgressCallback(browser, buildId) {
let progressBar;

@@ -154,3 +190,3 @@ let lastDownloadedBytes = 0;

if (!progressBar) {
progressBar = new ProgressBar(`Downloading ${browser} r${buildId} - ${__classPrivateFieldGet(this, _CLI_instances, "m", _CLI_toMegabytes).call(this, totalBytes)} [:bar] :percent :etas `, {
progressBar = new ProgressBar(`Downloading ${browser} r${buildId} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `, {
complete: '=',

@@ -166,3 +202,7 @@ incomplete: ' ',

};
};
}
function toMegabytes(bytes) {
const mb = bytes / 1000 / 1000;
return `${Math.round(mb * 10) / 10} MB`;
}
//# sourceMappingURL=CLI.js.map

@@ -16,4 +16,4 @@ /**

*/
import { BrowserPlatform } from './browsers/browsers.js';
import { BrowserPlatform } from './browser-data/browser-data.js';
export declare function detectBrowserPlatform(): BrowserPlatform | undefined;
//# sourceMappingURL=detectPlatform.d.ts.map

@@ -17,3 +17,3 @@ /**

import os from 'os';
import { BrowserPlatform } from './browsers/browsers.js';
import { BrowserPlatform } from './browser-data/browser-data.js';
export function detectBrowserPlatform() {

@@ -20,0 +20,0 @@ const platform = os.platform();

@@ -16,3 +16,3 @@ /**

*/
import { Browser, BrowserPlatform } from './browsers/browsers.js';
import { Browser, BrowserPlatform } from './browser-data/browser-data.js';
/**

@@ -19,0 +19,0 @@ * @public

@@ -21,4 +21,4 @@ /**

import path from 'path';
import { downloadUrls } from './browsers/browsers.js';
import { CacheStructure } from './CacheStructure.js';
import { downloadUrls, } from './browser-data/browser-data.js';
import { Cache } from './Cache.js';
import { debug } from './debug.js';

@@ -38,3 +38,3 @@ import { detectBrowserPlatform } from './detectPlatform.js';

assert(fileName, `A malformed download URL was found: ${url}.`);
const structure = new CacheStructure(options.cacheDir);
const structure = new Cache(options.cacheDir);
const browserRoot = structure.browserRoot(options.browser);

@@ -41,0 +41,0 @@ const archivePath = path.join(browserRoot, fileName);

@@ -17,4 +17,3 @@ /**

/// <reference types="node" />
import { Browser, BrowserPlatform } from './browsers/browsers.js';
import { ChromeReleaseChannel } from './browsers/types.js';
import { Browser, BrowserPlatform, ChromeReleaseChannel } from './browser-data/browser-data.js';
/**

@@ -21,0 +20,0 @@ * @public

@@ -33,4 +33,4 @@ /**

import readline from 'readline';
import { executablePathByBrowser, resolveSystemExecutablePath, } from './browsers/browsers.js';
import { CacheStructure } from './CacheStructure.js';
import { executablePathByBrowser, resolveSystemExecutablePath, } from './browser-data/browser-data.js';
import { Cache } from './Cache.js';
import { debug } from './debug.js';

@@ -45,3 +45,3 @@ import { detectBrowserPlatform } from './detectPlatform.js';

}
const installationDir = new CacheStructure(options.cacheDir).installationDir(options.browser, options.platform, options.buildId);
const installationDir = new Cache(options.cacheDir).installationDir(options.browser, options.platform, options.buildId);
return path.join(installationDir, executablePathByBrowser[options.browser](options.platform, options.buildId));

@@ -48,0 +48,0 @@ }

@@ -19,3 +19,5 @@ /**

export { detectBrowserPlatform } from './detectPlatform.js';
export { Browser, BrowserPlatform, ChromeReleaseChannel, } from './browsers/browsers.js';
export { resolveBuildId, Browser, BrowserPlatform, ChromeReleaseChannel, } from './browser-data/browser-data.js';
export { CLI, makeProgressCallback } from './CLI.js';
export { Cache } from './Cache.js';
//# sourceMappingURL=main.d.ts.map

@@ -19,3 +19,5 @@ /**

export { detectBrowserPlatform } from './detectPlatform.js';
export { Browser, BrowserPlatform, ChromeReleaseChannel, } from './browsers/browsers.js';
export { resolveBuildId, Browser, BrowserPlatform, ChromeReleaseChannel, } from './browser-data/browser-data.js';
export { CLI, makeProgressCallback } from './CLI.js';
export { Cache } from './Cache.js';
//# sourceMappingURL=main.js.map
{
"name": "@puppeteer/browsers",
"version": "0.1.1",
"version": "0.2.0",
"description": "Download and launch browsers",

@@ -12,3 +12,3 @@ "scripts": {

"bin": {
"@puppeteer/browsers": "lib/cjs/browsers.js"
"@puppeteer/browsers": "lib/cjs/main-cli.js"
},

@@ -24,3 +24,3 @@ "main": "./lib/cjs/main.js",

"build": {
"command": "tsc -b && chmod a+x lib/cjs/browsers.js lib/esm/browsers.js",
"command": "tsc -b && chmod a+x lib/cjs/main-cli.js lib/esm/main-cli.js",
"files": [

@@ -80,3 +80,2 @@ "src/**/*.ts",

"proxy-from-env": "1.1.0",
"rimraf": "4.4.0",
"tar-fs": "2.1.1",

@@ -83,0 +82,0 @@ "unbzip2-stream": "1.4.3",

# @puppeteer/browsers
Manage and launch browsers for Puppeteer. Documentation TODO.
Manage and launch browsers/drivers from a CLI or programmatically.
## CLI
Use `npx` to run the CLI without installing:
```sh
npx @puppeteer/browsers --help
```
or install the package as a dependency and run it from your `package.json` script:
```sh
npm i @puppeteer/browsers
```
```json
{
"scripts": {
"browsers": "@puppeteer/browsers --help"
}
}
```
CLI help will provide all documentation you need to use the CLI.
```sh
npx @puppeteer/browsers --help # help for all commands
npx @puppeteer/browsers install --help # help for the install command
npx @puppeteer/browsers launch --help # help for the launch command
```
Known limitations:
1. We support installing and running Firefox and Chrome/Chromium. The `latest` keyword only works during the installation. For the `launch` command you need to specify an exact build ID. The build ID is provided by the `install` command.
2. Launching the system browsers is only possible for Chrome/Chromium.
## API
The programmatic API allows installing and launching browsers from your code. See the `test` folder for examples on how to use the `install`, `canInstall`, `launch`, `computeExecutablePath`, `computeSystemExecutablePath` and other methods.

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