Initial commit - Dutchie dispensary scraper

This commit is contained in:
Kelly
2025-11-28 19:45:44 -07:00
commit 5757a8e9bd
23375 changed files with 3788799 additions and 0 deletions

28
backend/node_modules/@puppeteer/browsers/README.md generated vendored Normal file
View File

@@ -0,0 +1,28 @@
# @puppeteer/browsers
Manage and launch browsers/drivers from a CLI or programmatically.
## CLI
Use `npx` to run the CLI:
```bash
npx @puppeteer/browsers --help
```
CLI help will provide all documentation you need to use the CLI.
```bash
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, 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.
## 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.

View File

@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/// <reference types="node" />
import * as readline from 'readline';
import { type Browser } from './browser-data/browser-data.js';
/**
* @public
*/
export declare class CLI {
#private;
constructor(opts?: string | {
cachePath?: string;
scriptName?: string;
prefixCommand?: {
cmd: string;
description: string;
};
allowCachePathOverride?: boolean;
pinnedBrowsers?: Partial<{
[key in Browser]: string;
}>;
}, rl?: readline.Interface);
run(argv: string[]): Promise<void>;
}
/**
* @public
*/
export declare function makeProgressCallback(browser: Browser, buildId: string): (downloadedBytes: number, totalBytes: number) => void;
//# sourceMappingURL=CLI.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../src/CLI.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAGH,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAOrC,OAAO,EAEL,KAAK,OAAO,EAGb,MAAM,gCAAgC,CAAC;AAmCxC;;GAEG;AACH,qBAAa,GAAG;;gBASZ,IAAI,CAAC,EACD,MAAM,GACN;QACE,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAC,CAAC;QACnD,sBAAsB,CAAC,EAAE,OAAO,CAAC;QACjC,cAAc,CAAC,EAAE,OAAO,CAAC;aAAE,GAAG,IAAI,OAAO,GAAG,MAAM;SAAC,CAAC,CAAC;KACtD,EACL,EAAE,CAAC,EAAE,QAAQ,CAAC,SAAS;IAwDnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CA2OzC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAqBvD"}

276
backend/node_modules/@puppeteer/browsers/lib/cjs/CLI.js generated vendored Normal file
View File

@@ -0,0 +1,276 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeProgressCallback = exports.CLI = void 0;
const process_1 = require("process");
const readline = __importStar(require("readline"));
const progress_1 = __importDefault(require("progress"));
const helpers_1 = require("yargs/helpers");
const yargs_1 = __importDefault(require("yargs/yargs"));
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");
const install_js_1 = require("./install.js");
const launch_js_1 = require("./launch.js");
/**
* @public
*/
class CLI {
#cachePath;
#rl;
#scriptName = '';
#allowCachePathOverride = true;
#pinnedBrowsers;
#prefixCommand;
constructor(opts, rl) {
if (!opts) {
opts = {};
}
if (typeof opts === 'string') {
opts = {
cachePath: opts,
};
}
this.#cachePath = opts.cachePath ?? process.cwd();
this.#rl = rl;
this.#scriptName = opts.scriptName ?? '@puppeteer/browsers';
this.#allowCachePathOverride = opts.allowCachePathOverride ?? true;
this.#pinnedBrowsers = opts.pinnedBrowsers;
this.#prefixCommand = opts.prefixCommand;
}
#defineBrowserParameter(yargs) {
yargs.positional('browser', {
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',
coerce: (opt) => {
return {
name: this.#parseBrowser(opt),
buildId: this.#parseBuildId(opt),
};
},
});
}
#definePlatformParameter(yargs) {
yargs.option('platform', {
type: 'string',
desc: 'Platform that the binary needs to be compatible with.',
choices: Object.values(browser_data_js_1.BrowserPlatform),
defaultDescription: 'Auto-detected',
});
}
#definePathParameter(yargs, required = false) {
if (!this.#allowCachePathOverride) {
return;
}
yargs.option('path', {
type: 'string',
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');
}
}
async run(argv) {
const yargsInstance = (0, yargs_1.default)((0, helpers_1.hideBin)(argv));
let target = yargsInstance.scriptName(this.#scriptName);
if (this.#prefixCommand) {
target = target.command(this.#prefixCommand.cmd, this.#prefixCommand.description, yargs => {
return this.#build(yargs);
});
}
else {
target = this.#build(target);
}
await target
.demandCommand(1)
.help()
.wrap(Math.min(120, yargsInstance.terminalWidth()))
.parse();
}
#build(yargs) {
const latestOrPinned = this.#pinnedBrowsers ? 'pinned' : 'latest';
return yargs
.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 => {
this.#defineBrowserParameter(yargs);
this.#definePlatformParameter(yargs);
this.#definePathParameter(yargs);
yargs.option('base-url', {
type: 'string',
desc: 'Base URL to download from',
});
yargs.example('$0 install chrome', `Install the ${latestOrPinned} 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 chrome@canary', 'Install the latest available build for the Chrome Canary browser.');
yargs.example('$0 install chrome@115', 'Install the latest available build for Chrome 115.');
yargs.example('$0 install chromedriver@canary', 'Install the latest available build for ChromeDriver Canary.');
yargs.example('$0 install chromedriver@115', 'Install the latest available build for ChromeDriver 115.');
yargs.example('$0 install chromedriver@115.0.5790', 'Install the latest available patch (115.0.5790.X) build for ChromeDriver.');
yargs.example('$0 install chrome-headless-shell', 'Install the latest available chrome-headless-shell build.');
yargs.example('$0 install chrome-headless-shell@beta', 'Install the latest available chrome-headless-shell build corresponding to the Beta channel.');
yargs.example('$0 install chrome-headless-shell@118', 'Install the latest available chrome-headless-shell 118 build.');
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.');
if (this.#allowCachePathOverride) {
yargs.example('$0 install firefox --path /tmp/my-browser-cache', 'Install to the specified cache directory.');
}
}, async (argv) => {
const args = argv;
args.platform ??= (0, detectPlatform_js_1.detectBrowserPlatform)();
if (!args.platform) {
throw new Error(`Could not resolve the current platform`);
}
if (args.browser.buildId === 'pinned') {
const pinnedVersion = this.#pinnedBrowsers?.[args.browser.name];
if (!pinnedVersion) {
throw new Error(`No pinned version found for ${args.browser.name}`);
}
args.browser.buildId = pinnedVersion;
}
args.browser.buildId = await (0, browser_data_js_1.resolveBuildId)(args.browser.name, args.platform, args.browser.buildId);
await (0, install_js_1.install)({
browser: args.browser.name,
buildId: args.browser.buildId,
platform: args.platform,
cacheDir: args.path ?? this.#cachePath,
downloadProgressCallback: makeProgressCallback(args.browser.name, args.browser.buildId),
baseUrl: args.baseUrl,
});
console.log(`${args.browser.name}@${args.browser.buildId} ${(0, launch_js_1.computeExecutablePath)({
browser: args.browser.name,
buildId: args.browser.buildId,
cacheDir: args.path ?? this.#cachePath,
platform: args.platform,
})}`);
})
.command('launch <browser>', 'Launch the specified browser', yargs => {
this.#defineBrowserParameter(yargs);
this.#definePlatformParameter(yargs);
this.#definePathParameter(yargs);
yargs.option('detached', {
type: 'boolean',
desc: 'Detach the child process.',
default: false,
});
yargs.option('system', {
type: 'boolean',
desc: 'Search for a browser installed on the system instead of the cache folder.',
default: false,
});
yargs.example('$0 launch chrome@115.0.5790.170', 'Launch Chrome 115.0.5790.170');
yargs.example('$0 launch firefox@112.0a1', 'Launch the Firefox browser identified by the milestone 112.0a1.');
yargs.example('$0 launch chrome@115.0.5790.170 --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) => {
const args = argv;
const executablePath = args.system
? (0, launch_js_1.computeSystemExecutablePath)({
browser: args.browser.name,
// TODO: throw an error if not a ChromeReleaseChannel is provided.
channel: args.browser.buildId,
platform: args.platform,
})
: (0, launch_js_1.computeExecutablePath)({
browser: args.browser.name,
buildId: args.browser.buildId,
cacheDir: args.path ?? this.#cachePath,
platform: args.platform,
});
(0, launch_js_1.launch)({
executablePath,
detached: args.detached,
});
})
.command('clear', this.#allowCachePathOverride
? 'Removes all installed browsers from the specified cache directory'
: `Removes all installed browsers from ${this.#cachePath}`, yargs => {
this.#definePathParameter(yargs, true);
}, async (argv) => {
const args = argv;
const cacheDir = args.path ?? this.#cachePath;
const rl = this.#rl ?? 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();
}
#parseBrowser(version) {
return version.split('@').shift();
}
#parseBuildId(version) {
const parts = version.split('@');
return parts.length === 2
? parts[1]
: this.#pinnedBrowsers
? 'pinned'
: 'latest';
}
}
exports.CLI = CLI;
/**
* @public
*/
function makeProgressCallback(browser, buildId) {
let progressBar;
let lastDownloadedBytes = 0;
return (downloadedBytes, totalBytes) => {
if (!progressBar) {
progressBar = new progress_1.default(`Downloading ${browser} r${buildId} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `, {
complete: '=',
incomplete: ' ',
width: 20,
total: totalBytes,
});
}
const delta = downloadedBytes - lastDownloadedBytes;
lastDownloadedBytes = downloadedBytes;
progressBar.tick(delta);
};
}
exports.makeProgressCallback = makeProgressCallback;
function toMegabytes(bytes) {
const mb = bytes / 1000 / 1000;
return `${Math.round(mb * 10) / 10} MB`;
}
//# sourceMappingURL=CLI.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,74 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { Browser, type BrowserPlatform } from './browser-data/browser-data.js';
/**
* @public
*/
export declare class InstalledBrowser {
#private;
browser: Browser;
buildId: string;
platform: BrowserPlatform;
readonly executablePath: string;
/**
* @internal
*/
constructor(cache: Cache, browser: Browser, buildId: string, platform: BrowserPlatform);
/**
* Path to the root of the installation folder. Use
* {@link computeExecutablePath} to get the path to the executable binary.
*/
get path(): string;
}
/**
* @internal
*/
export interface ComputeExecutablePathOptions {
/**
* Determines which platform the browser will be suited for.
*
* @defaultValue **Auto-detected.**
*/
platform?: BrowserPlatform;
/**
* Determines which browser to launch.
*/
browser: Browser;
/**
* Determines which buildId to download. BuildId should uniquely identify
* binaries and they are used for caching.
*/
buildId: string;
}
/**
* The cache used by Puppeteer relies on the following structure:
*
* - rootDir
* -- <browser1> | browserRoot(browser1)
* ---- <platform>-<buildId> | installationDir()
* ------ the browser-platform-buildId
* ------ specific structure.
* -- <browser2> | browserRoot(browser2)
* ---- <platform>-<buildId> | installationDir()
* ------ the browser-platform-buildId
* ------ specific structure.
* @internal
*/
export declare class Cache {
#private;
constructor(rootDir: string);
/**
* @internal
*/
get rootDir(): string;
browserRoot(browser: Browser): string;
installationDir(browser: Browser, platform: BrowserPlatform, buildId: string): string;
clear(): void;
uninstall(browser: Browser, platform: BrowserPlatform, buildId: string): void;
getInstalledBrowsers(): InstalledBrowser[];
computeExecutablePath(options: ComputeExecutablePathOptions): string;
}
//# sourceMappingURL=Cache.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EACL,OAAO,EACP,KAAK,eAAe,EAErB,MAAM,gCAAgC,CAAC;AAGxC;;GAEG;AACH,qBAAa,gBAAgB;;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAIhC;;OAEG;gBAED,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,eAAe;IAa3B;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAMjB;CACF;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,KAAK;;gBAGJ,OAAO,EAAE,MAAM;IAI3B;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAIrC,eAAe,CACb,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM;IAIT,KAAK,IAAI,IAAI;IASb,SAAS,CACP,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,IAAI;IASP,oBAAoB,IAAI,gBAAgB,EAAE;IA+B1C,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,MAAM;CAoBrE"}

View File

@@ -0,0 +1,141 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Cache = exports.InstalledBrowser = void 0;
const fs_1 = __importDefault(require("fs"));
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
const browser_data_js_1 = require("./browser-data/browser-data.js");
const detectPlatform_js_1 = require("./detectPlatform.js");
/**
* @public
*/
class InstalledBrowser {
browser;
buildId;
platform;
executablePath;
#cache;
/**
* @internal
*/
constructor(cache, browser, buildId, platform) {
this.#cache = cache;
this.browser = browser;
this.buildId = buildId;
this.platform = platform;
this.executablePath = cache.computeExecutablePath({
browser,
buildId,
platform,
});
}
/**
* Path to the root of the installation folder. Use
* {@link computeExecutablePath} to get the path to the executable binary.
*/
get path() {
return this.#cache.installationDir(this.browser, this.platform, this.buildId);
}
}
exports.InstalledBrowser = InstalledBrowser;
/**
* The cache used by Puppeteer relies on the following structure:
*
* - rootDir
* -- <browser1> | browserRoot(browser1)
* ---- <platform>-<buildId> | installationDir()
* ------ the browser-platform-buildId
* ------ specific structure.
* -- <browser2> | browserRoot(browser2)
* ---- <platform>-<buildId> | installationDir()
* ------ the browser-platform-buildId
* ------ specific structure.
* @internal
*/
class Cache {
#rootDir;
constructor(rootDir) {
this.#rootDir = rootDir;
}
/**
* @internal
*/
get rootDir() {
return this.#rootDir;
}
browserRoot(browser) {
return path_1.default.join(this.#rootDir, browser);
}
installationDir(browser, platform, buildId) {
return path_1.default.join(this.browserRoot(browser), `${platform}-${buildId}`);
}
clear() {
fs_1.default.rmSync(this.#rootDir, {
force: true,
recursive: true,
maxRetries: 10,
retryDelay: 500,
});
}
uninstall(browser, platform, buildId) {
fs_1.default.rmSync(this.installationDir(browser, platform, buildId), {
force: true,
recursive: true,
maxRetries: 10,
retryDelay: 500,
});
}
getInstalledBrowsers() {
if (!fs_1.default.existsSync(this.#rootDir)) {
return [];
}
const types = fs_1.default.readdirSync(this.#rootDir);
const browsers = types.filter((t) => {
return Object.values(browser_data_js_1.Browser).includes(t);
});
return browsers.flatMap(browser => {
const files = fs_1.default.readdirSync(this.browserRoot(browser));
return files
.map(file => {
const result = parseFolderPath(path_1.default.join(this.browserRoot(browser), file));
if (!result) {
return null;
}
return new InstalledBrowser(this, browser, result.buildId, result.platform);
})
.filter((item) => {
return item !== null;
});
});
}
computeExecutablePath(options) {
options.platform ??= (0, detectPlatform_js_1.detectBrowserPlatform)();
if (!options.platform) {
throw new Error(`Cannot download a binary for the provided platform: ${os_1.default.platform()} (${os_1.default.arch()})`);
}
const installationDir = this.installationDir(options.browser, options.platform, options.buildId);
return path_1.default.join(installationDir, browser_data_js_1.executablePathByBrowser[options.browser](options.platform, options.buildId));
}
}
exports.Cache = Cache;
function parseFolderPath(folderPath) {
const name = path_1.default.basename(folderPath);
const splits = name.split('-');
if (splits.length !== 2) {
return;
}
const [platform, buildId] = splits;
if (!buildId || !platform) {
return;
}
return { platform, buildId };
}
//# sourceMappingURL=Cache.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AAExB,oEAIwC;AACxC,2DAA0D;AAE1D;;GAEG;AACH,MAAa,gBAAgB;IAC3B,OAAO,CAAU;IACjB,OAAO,CAAS;IAChB,QAAQ,CAAkB;IACjB,cAAc,CAAS;IAEhC,MAAM,CAAQ;IAEd;;OAEG;IACH,YACE,KAAY,EACZ,OAAgB,EAChB,OAAe,EACf,QAAyB;QAEzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,qBAAqB,CAAC;YAChD,OAAO;YACP,OAAO;YACP,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAChC,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,OAAO,CACb,CAAC;IACJ,CAAC;CACF;AAvCD,4CAuCC;AAuBD;;;;;;;;;;;;;GAaG;AACH,MAAa,KAAK;IAChB,QAAQ,CAAS;IAEjB,YAA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OAAO,CAAC,OAAO,CAChB,CACF,CAAC;IACJ,CAAC;CACF;AAnGD,sBAmGC;AAED,SAAS,eAAe,CACtB,UAAkB;IAElB,MAAM,IAAI,GAAG,cAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;IACT,CAAC;IACD,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IACnC,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IACD,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC;AAC7B,CAAC"}

View File

@@ -0,0 +1,47 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import * as chromeHeadlessShell from './chrome-headless-shell.js';
import * as chrome from './chrome.js';
import * as chromedriver from './chromedriver.js';
import * as chromium from './chromium.js';
import * as firefox from './firefox.js';
import { Browser, BrowserPlatform, ChromeReleaseChannel, type ProfileOptions } from './types.js';
export type { ProfileOptions };
export declare const downloadUrls: {
chromedriver: typeof chromedriver.resolveDownloadUrl;
"chrome-headless-shell": typeof chromeHeadlessShell.resolveDownloadUrl;
chrome: typeof chrome.resolveDownloadUrl;
chromium: typeof chromium.resolveDownloadUrl;
firefox: typeof firefox.resolveDownloadUrl;
};
export declare const downloadPaths: {
chromedriver: typeof chromedriver.resolveDownloadPath;
"chrome-headless-shell": typeof chromeHeadlessShell.resolveDownloadPath;
chrome: typeof chrome.resolveDownloadPath;
chromium: typeof chromium.resolveDownloadPath;
firefox: typeof firefox.resolveDownloadPath;
};
export declare const executablePathByBrowser: {
chromedriver: typeof chromedriver.relativeExecutablePath;
"chrome-headless-shell": typeof chromeHeadlessShell.relativeExecutablePath;
chrome: typeof chrome.relativeExecutablePath;
chromium: typeof chromium.relativeExecutablePath;
firefox: typeof firefox.relativeExecutablePath;
};
export { Browser, BrowserPlatform, ChromeReleaseChannel };
/**
* @public
*/
export declare function resolveBuildId(browser: Browser, platform: BrowserPlatform, tag: string): Promise<string>;
/**
* @public
*/
export declare function createProfile(browser: Browser, opts: ProfileOptions): Promise<void>;
/**
* @public
*/
export declare function resolveSystemExecutablePath(browser: Browser, platform: BrowserPlatform, channel: ChromeReleaseChannel): string;
//# sourceMappingURL=browser-data.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"browser-data.d.ts","sourceRoot":"","sources":["../../../src/browser-data/browser-data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,mBAAmB,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,OAAO,EACP,eAAe,EAEf,oBAAoB,EACpB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAC,cAAc,EAAC,CAAC;AAE7B,eAAO,MAAM,YAAY;;;;;;CAMxB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;CAMzB,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;CAMnC,CAAC;AAEF,OAAO,EAAC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAC,CAAC;AAExD;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,EACzB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CA+FjB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,oBAAoB,GAC5B,MAAM,CAYR"}

View File

@@ -0,0 +1,178 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveSystemExecutablePath = exports.createProfile = exports.resolveBuildId = exports.ChromeReleaseChannel = exports.BrowserPlatform = exports.Browser = exports.executablePathByBrowser = exports.downloadPaths = exports.downloadUrls = void 0;
const chromeHeadlessShell = __importStar(require("./chrome-headless-shell.js"));
const chrome = __importStar(require("./chrome.js"));
const chromedriver = __importStar(require("./chromedriver.js"));
const chromium = __importStar(require("./chromium.js"));
const firefox = __importStar(require("./firefox.js"));
const types_js_1 = require("./types.js");
Object.defineProperty(exports, "Browser", { enumerable: true, get: function () { return types_js_1.Browser; } });
Object.defineProperty(exports, "BrowserPlatform", { enumerable: true, get: function () { return types_js_1.BrowserPlatform; } });
Object.defineProperty(exports, "ChromeReleaseChannel", { enumerable: true, get: function () { return types_js_1.ChromeReleaseChannel; } });
exports.downloadUrls = {
[types_js_1.Browser.CHROMEDRIVER]: chromedriver.resolveDownloadUrl,
[types_js_1.Browser.CHROMEHEADLESSSHELL]: chromeHeadlessShell.resolveDownloadUrl,
[types_js_1.Browser.CHROME]: chrome.resolveDownloadUrl,
[types_js_1.Browser.CHROMIUM]: chromium.resolveDownloadUrl,
[types_js_1.Browser.FIREFOX]: firefox.resolveDownloadUrl,
};
exports.downloadPaths = {
[types_js_1.Browser.CHROMEDRIVER]: chromedriver.resolveDownloadPath,
[types_js_1.Browser.CHROMEHEADLESSSHELL]: chromeHeadlessShell.resolveDownloadPath,
[types_js_1.Browser.CHROME]: chrome.resolveDownloadPath,
[types_js_1.Browser.CHROMIUM]: chromium.resolveDownloadPath,
[types_js_1.Browser.FIREFOX]: firefox.resolveDownloadPath,
};
exports.executablePathByBrowser = {
[types_js_1.Browser.CHROMEDRIVER]: chromedriver.relativeExecutablePath,
[types_js_1.Browser.CHROMEHEADLESSSHELL]: chromeHeadlessShell.relativeExecutablePath,
[types_js_1.Browser.CHROME]: chrome.relativeExecutablePath,
[types_js_1.Browser.CHROMIUM]: chromium.relativeExecutablePath,
[types_js_1.Browser.FIREFOX]: firefox.relativeExecutablePath,
};
/**
* @public
*/
async function resolveBuildId(browser, platform, tag) {
switch (browser) {
case types_js_1.Browser.FIREFOX:
switch (tag) {
case types_js_1.BrowserTag.LATEST:
return await firefox.resolveBuildId('FIREFOX_NIGHTLY');
case types_js_1.BrowserTag.BETA:
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.`);
}
case types_js_1.Browser.CHROME: {
switch (tag) {
case types_js_1.BrowserTag.LATEST:
return await chrome.resolveBuildId(types_js_1.ChromeReleaseChannel.CANARY);
case types_js_1.BrowserTag.BETA:
return await chrome.resolveBuildId(types_js_1.ChromeReleaseChannel.BETA);
case types_js_1.BrowserTag.CANARY:
return await chrome.resolveBuildId(types_js_1.ChromeReleaseChannel.CANARY);
case types_js_1.BrowserTag.DEV:
return await chrome.resolveBuildId(types_js_1.ChromeReleaseChannel.DEV);
case types_js_1.BrowserTag.STABLE:
return await chrome.resolveBuildId(types_js_1.ChromeReleaseChannel.STABLE);
default:
const result = await chrome.resolveBuildId(tag);
if (result) {
return result;
}
}
return tag;
}
case types_js_1.Browser.CHROMEDRIVER: {
switch (tag) {
case types_js_1.BrowserTag.LATEST:
case types_js_1.BrowserTag.CANARY:
return await chromedriver.resolveBuildId(types_js_1.ChromeReleaseChannel.CANARY);
case types_js_1.BrowserTag.BETA:
return await chromedriver.resolveBuildId(types_js_1.ChromeReleaseChannel.BETA);
case types_js_1.BrowserTag.DEV:
return await chromedriver.resolveBuildId(types_js_1.ChromeReleaseChannel.DEV);
case types_js_1.BrowserTag.STABLE:
return await chromedriver.resolveBuildId(types_js_1.ChromeReleaseChannel.STABLE);
default:
const result = await chromedriver.resolveBuildId(tag);
if (result) {
return result;
}
}
return tag;
}
case types_js_1.Browser.CHROMEHEADLESSSHELL: {
switch (tag) {
case types_js_1.BrowserTag.LATEST:
case types_js_1.BrowserTag.CANARY:
return await chromeHeadlessShell.resolveBuildId(types_js_1.ChromeReleaseChannel.CANARY);
case types_js_1.BrowserTag.BETA:
return await chromeHeadlessShell.resolveBuildId(types_js_1.ChromeReleaseChannel.BETA);
case types_js_1.BrowserTag.DEV:
return await chromeHeadlessShell.resolveBuildId(types_js_1.ChromeReleaseChannel.DEV);
case types_js_1.BrowserTag.STABLE:
return await chromeHeadlessShell.resolveBuildId(types_js_1.ChromeReleaseChannel.STABLE);
default:
const result = await chromeHeadlessShell.resolveBuildId(tag);
if (result) {
return result;
}
}
return tag;
}
case types_js_1.Browser.CHROMIUM:
switch (tag) {
case types_js_1.BrowserTag.LATEST:
return await chromium.resolveBuildId(platform);
case types_js_1.BrowserTag.BETA:
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.`);
}
}
// We assume the tag is the buildId if it didn't match any keywords.
return tag;
}
exports.resolveBuildId = resolveBuildId;
/**
* @public
*/
async function createProfile(browser, opts) {
switch (browser) {
case types_js_1.Browser.FIREFOX:
return await firefox.createProfile(opts);
case types_js_1.Browser.CHROME:
case types_js_1.Browser.CHROMIUM:
throw new Error(`Profile creation is not support for ${browser} yet`);
}
}
exports.createProfile = createProfile;
/**
* @public
*/
function resolveSystemExecutablePath(browser, platform, channel) {
switch (browser) {
case types_js_1.Browser.CHROMEDRIVER:
case types_js_1.Browser.CHROMEHEADLESSSHELL:
case types_js_1.Browser.FIREFOX:
case types_js_1.Browser.CHROMIUM:
throw new Error(`System browser detection is not supported for ${browser} yet.`);
case types_js_1.Browser.CHROME:
return chrome.resolveSystemExecutablePath(platform, channel);
}
}
exports.resolveSystemExecutablePath = resolveSystemExecutablePath;
//# sourceMappingURL=browser-data.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"browser-data.js","sourceRoot":"","sources":["../../../src/browser-data/browser-data.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gFAAkE;AAClE,oDAAsC;AACtC,gEAAkD;AAClD,wDAA0C;AAC1C,sDAAwC;AACxC,yCAMoB;AA4BZ,wFAjCN,kBAAO,OAiCM;AAAE,gGAhCf,0BAAe,OAgCe;AAAE,qGA9BhC,+BAAoB,OA8BgC;AAxBzC,QAAA,YAAY,GAAG;IAC1B,CAAC,kBAAO,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,kBAAkB;IACvD,CAAC,kBAAO,CAAC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,kBAAkB;IACrE,CAAC,kBAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,kBAAkB;IAC3C,CAAC,kBAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,kBA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"}

View File

@@ -0,0 +1,6 @@
import { BrowserPlatform } from './types.js';
export declare function resolveDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): string;
export declare function resolveDownloadPath(platform: BrowserPlatform, buildId: string): string[];
export declare function relativeExecutablePath(platform: BrowserPlatform, _buildId: string): string;
export { resolveBuildId } from './chrome.js';
//# sourceMappingURL=chrome-headless-shell.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chrome-headless-shell.d.ts","sourceRoot":"","sources":["../../../src/browser-data/chrome-headless-shell.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAiB3C,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,SAAgE,GACtE,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAMV;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAoBR;AAED,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC"}

View File

@@ -0,0 +1,55 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveBuildId = exports.relativeExecutablePath = exports.resolveDownloadPath = exports.resolveDownloadUrl = void 0;
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
const path_1 = __importDefault(require("path"));
const types_js_1 = require("./types.js");
function folder(platform) {
switch (platform) {
case types_js_1.BrowserPlatform.LINUX:
return 'linux64';
case types_js_1.BrowserPlatform.MAC_ARM:
return 'mac-arm64';
case types_js_1.BrowserPlatform.MAC:
return 'mac-x64';
case types_js_1.BrowserPlatform.WIN32:
return 'win32';
case types_js_1.BrowserPlatform.WIN64:
return 'win64';
}
}
function resolveDownloadUrl(platform, buildId, baseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
exports.resolveDownloadUrl = resolveDownloadUrl;
function resolveDownloadPath(platform, buildId) {
return [
buildId,
folder(platform),
`chrome-headless-shell-${folder(platform)}.zip`,
];
}
exports.resolveDownloadPath = resolveDownloadPath;
function relativeExecutablePath(platform, _buildId) {
switch (platform) {
case types_js_1.BrowserPlatform.MAC:
case types_js_1.BrowserPlatform.MAC_ARM:
return path_1.default.join('chrome-headless-shell-' + folder(platform), 'chrome-headless-shell');
case types_js_1.BrowserPlatform.LINUX:
return path_1.default.join('chrome-headless-shell-linux64', 'chrome-headless-shell');
case types_js_1.BrowserPlatform.WIN32:
case types_js_1.BrowserPlatform.WIN64:
return path_1.default.join('chrome-headless-shell-' + folder(platform), 'chrome-headless-shell.exe');
}
}
exports.relativeExecutablePath = relativeExecutablePath;
var chrome_js_1 = require("./chrome.js");
Object.defineProperty(exports, "resolveBuildId", { enumerable: true, get: function () { return chrome_js_1.resolveBuildId; } });
//# sourceMappingURL=chrome-headless-shell.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chrome-headless-shell.js","sourceRoot":"","sources":["../../../src/browser-data/chrome-headless-shell.ts"],"names":[],"mappings":";;;;;;AAAA;;;;GAIG;AACH,gDAAwB;AAExB,yCAA2C;AAE3C,SAAS,MAAM,CAAC,QAAyB;IACvC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,SAAS,CAAC;QACnB,KAAK,0BAAe,CAAC,OAAO;YAC1B,OAAO,WAAW,CAAC;QACrB,KAAK,0BAAe,CAAC,GAAG;YACtB,OAAO,SAAS,CAAC;QACnB,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,OAAO,CAAC;QACjB,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAgB,kBAAkB,CAChC,QAAyB,EACzB,OAAe,EACf,OAAO,GAAG,6DAA6D;IAEvE,OAAO,GAAG,OAAO,IAAI,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC1E,CAAC;AAND,gDAMC;AAED,SAAgB,mBAAmB,CACjC,QAAyB,EACzB,OAAe;IAEf,OAAO;QACL,OAAO;QACP,MAAM,CAAC,QAAQ,CAAC;QAChB,yBAAyB,MAAM,CAAC,QAAQ,CAAC,MAAM;KAChD,CAAC;AACJ,CAAC;AATD,kDASC;AAED,SAAgB,sBAAsB,CACpC,QAAyB,EACzB,QAAgB;IAEhB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,0BAAe,CAAC,GAAG,CAAC;QACzB,KAAK,0BAAe,CAAC,OAAO;YAC1B,OAAO,cAAI,CAAC,IAAI,CACd,wBAAwB,GAAG,MAAM,CAAC,QAAQ,CAAC,EAC3C,uBAAuB,CACxB,CAAC;QACJ,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,cAAI,CAAC,IAAI,CACd,+BAA+B,EAC/B,uBAAuB,CACxB,CAAC;QACJ,KAAK,0BAAe,CAAC,KAAK,CAAC;QAC3B,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,cAAI,CAAC,IAAI,CACd,wBAAwB,GAAG,MAAM,CAAC,QAAQ,CAAC,EAC3C,2BAA2B,CAC5B,CAAC;IACN,CAAC;AACH,CAAC;AAvBD,wDAuBC;AAED,yCAA2C;AAAnC,2GAAA,cAAc,OAAA"}

View File

@@ -0,0 +1,29 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { BrowserPlatform, ChromeReleaseChannel } from './types.js';
export declare function resolveDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): string;
export declare function resolveDownloadPath(platform: BrowserPlatform, buildId: string): string[];
export declare function relativeExecutablePath(platform: BrowserPlatform, _buildId: string): string;
export declare function getLastKnownGoodReleaseForChannel(channel: ChromeReleaseChannel): Promise<{
version: string;
revision: string;
}>;
export declare function getLastKnownGoodReleaseForMilestone(milestone: string): Promise<{
version: string;
revision: string;
} | undefined>;
export declare function getLastKnownGoodReleaseForBuild(
/**
* @example `112.0.23`,
*/
buildPrefix: string): Promise<{
version: string;
revision: string;
} | undefined>;
export declare function resolveBuildId(channel: ChromeReleaseChannel): Promise<string>;
export declare function resolveBuildId(channel: string): Promise<string | undefined>;
export declare function resolveSystemExecutablePath(platform: BrowserPlatform, channel: ChromeReleaseChannel): string;
//# sourceMappingURL=chrome.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chrome.d.ts","sourceRoot":"","sources":["../../../src/browser-data/chrome.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAiBjE,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,SAAgE,GACtE,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAEV;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAiBR;AAED,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC,CAqB9C;AAED,wBAAsB,mCAAmC,CACvD,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,GAAG,SAAS,CAAC,CAW1D;AAED,wBAAsB,+BAA+B;AACnD;;GAEG;AACH,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,GAAG,SAAS,CAAC,CAW1D;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAAC;AACnB,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAwB/B,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,oBAAoB,GAC5B,MAAM,CAwCR"}

View File

@@ -0,0 +1,127 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveSystemExecutablePath = exports.resolveBuildId = exports.getLastKnownGoodReleaseForBuild = exports.getLastKnownGoodReleaseForMilestone = exports.getLastKnownGoodReleaseForChannel = exports.relativeExecutablePath = exports.resolveDownloadPath = exports.resolveDownloadUrl = void 0;
const path_1 = __importDefault(require("path"));
const httpUtil_js_1 = require("../httpUtil.js");
const types_js_1 = require("./types.js");
function folder(platform) {
switch (platform) {
case types_js_1.BrowserPlatform.LINUX:
return 'linux64';
case types_js_1.BrowserPlatform.MAC_ARM:
return 'mac-arm64';
case types_js_1.BrowserPlatform.MAC:
return 'mac-x64';
case types_js_1.BrowserPlatform.WIN32:
return 'win32';
case types_js_1.BrowserPlatform.WIN64:
return 'win64';
}
}
function resolveDownloadUrl(platform, buildId, baseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
exports.resolveDownloadUrl = resolveDownloadUrl;
function resolveDownloadPath(platform, buildId) {
return [buildId, folder(platform), `chrome-${folder(platform)}.zip`];
}
exports.resolveDownloadPath = resolveDownloadPath;
function relativeExecutablePath(platform, _buildId) {
switch (platform) {
case types_js_1.BrowserPlatform.MAC:
case types_js_1.BrowserPlatform.MAC_ARM:
return path_1.default.join('chrome-' + folder(platform), 'Google Chrome for Testing.app', 'Contents', 'MacOS', 'Google Chrome for Testing');
case types_js_1.BrowserPlatform.LINUX:
return path_1.default.join('chrome-linux64', 'chrome');
case types_js_1.BrowserPlatform.WIN32:
case types_js_1.BrowserPlatform.WIN64:
return path_1.default.join('chrome-' + folder(platform), 'chrome.exe');
}
}
exports.relativeExecutablePath = relativeExecutablePath;
async function getLastKnownGoodReleaseForChannel(channel) {
const data = (await (0, httpUtil_js_1.getJSON)(new URL('https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json')));
for (const channel of Object.keys(data.channels)) {
data.channels[channel.toLowerCase()] = data.channels[channel];
delete data.channels[channel];
}
return data.channels[channel];
}
exports.getLastKnownGoodReleaseForChannel = getLastKnownGoodReleaseForChannel;
async function getLastKnownGoodReleaseForMilestone(milestone) {
const data = (await (0, httpUtil_js_1.getJSON)(new URL('https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone.json')));
return data.milestones[milestone];
}
exports.getLastKnownGoodReleaseForMilestone = getLastKnownGoodReleaseForMilestone;
async function getLastKnownGoodReleaseForBuild(
/**
* @example `112.0.23`,
*/
buildPrefix) {
const data = (await (0, httpUtil_js_1.getJSON)(new URL('https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build.json')));
return data.builds[buildPrefix];
}
exports.getLastKnownGoodReleaseForBuild = getLastKnownGoodReleaseForBuild;
async function resolveBuildId(channel) {
if (Object.values(types_js_1.ChromeReleaseChannel).includes(channel)) {
return (await getLastKnownGoodReleaseForChannel(channel)).version;
}
if (channel.match(/^\d+$/)) {
// Potentially a milestone.
return (await getLastKnownGoodReleaseForMilestone(channel))?.version;
}
if (channel.match(/^\d+\.\d+\.\d+$/)) {
// Potentially a build prefix without the patch version.
return (await getLastKnownGoodReleaseForBuild(channel))?.version;
}
return;
}
exports.resolveBuildId = resolveBuildId;
function resolveSystemExecutablePath(platform, channel) {
switch (platform) {
case types_js_1.BrowserPlatform.WIN64:
case types_js_1.BrowserPlatform.WIN32:
switch (channel) {
case types_js_1.ChromeReleaseChannel.STABLE:
return `${process.env['PROGRAMFILES']}\\Google\\Chrome\\Application\\chrome.exe`;
case types_js_1.ChromeReleaseChannel.BETA:
return `${process.env['PROGRAMFILES']}\\Google\\Chrome Beta\\Application\\chrome.exe`;
case types_js_1.ChromeReleaseChannel.CANARY:
return `${process.env['PROGRAMFILES']}\\Google\\Chrome SxS\\Application\\chrome.exe`;
case types_js_1.ChromeReleaseChannel.DEV:
return `${process.env['PROGRAMFILES']}\\Google\\Chrome Dev\\Application\\chrome.exe`;
}
case types_js_1.BrowserPlatform.MAC_ARM:
case types_js_1.BrowserPlatform.MAC:
switch (channel) {
case types_js_1.ChromeReleaseChannel.STABLE:
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
case types_js_1.ChromeReleaseChannel.BETA:
return '/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta';
case types_js_1.ChromeReleaseChannel.CANARY:
return '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary';
case types_js_1.ChromeReleaseChannel.DEV:
return '/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev';
}
case types_js_1.BrowserPlatform.LINUX:
switch (channel) {
case types_js_1.ChromeReleaseChannel.STABLE:
return '/opt/google/chrome/chrome';
case types_js_1.ChromeReleaseChannel.BETA:
return '/opt/google/chrome-beta/chrome';
case types_js_1.ChromeReleaseChannel.DEV:
return '/opt/google/chrome-unstable/chrome';
}
}
throw new Error(`Unable to detect browser executable path for '${channel}' on ${platform}.`);
}
exports.resolveSystemExecutablePath = resolveSystemExecutablePath;
//# sourceMappingURL=chrome.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chrome.js","sourceR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OAAO,EAAE,CAAC;gBAChB,KAAK,+BAAoB,CAAC,MAAM;oBAC9B,OAAO,8DAA8D,CAAC;gBACxE,KAAK,+BAAoB,CAAC,IAAI;oBAC5B,OAAO,wEAAwE,CAAC;gBAClF,KAAK,+BAAoB,CAAC,MAAM;oBAC9B,OAAO,4EAA4E,CAAC;gBACtF,KAAK,+BAAoB,CAAC,GAAG;oBAC3B,OAAO,sEAAsE,CAAC;YAClF,CAAC;QACH,KAAK,0BAAe,CAAC,KAAK;YACxB,QAAQ,OAAO,EAAE,CAAC;gBAChB,KAAK,+BAAoB,CAAC,MAAM;oBAC9B,OAAO,2BAA2B,CAAC;gBACrC,KAAK,+BAAoB,CAAC,IAAI;oBAC5B,OAAO,gCAAgC,CAAC;gBAC1C,KAAK,+BAAoB,CAAC,GAAG;oBAC3B,OAAO,oCAAoC,CAAC;YAChD,CAAC;IACL,CAAC;IAED,MAAM,IAAI,KAAK,CACb,iDAAiD,OAAO,QAAQ,QAAQ,GAAG,CAC5E,CAAC;AACJ,CAAC;AA3CD,kEA2CC"}

View File

@@ -0,0 +1,6 @@
import { BrowserPlatform } from './types.js';
export declare function resolveDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): string;
export declare function resolveDownloadPath(platform: BrowserPlatform, buildId: string): string[];
export declare function relativeExecutablePath(platform: BrowserPlatform, _buildId: string): string;
export { resolveBuildId } from './chrome.js';
//# sourceMappingURL=chromedriver.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chromedriver.d.ts","sourceRoot":"","sources":["../../../src/browser-data/chromedriver.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAiB3C,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,SAAgE,GACtE,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAEV;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAWR;AAED,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC"}

View File

@@ -0,0 +1,51 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveBuildId = exports.relativeExecutablePath = exports.resolveDownloadPath = exports.resolveDownloadUrl = void 0;
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
const path_1 = __importDefault(require("path"));
const types_js_1 = require("./types.js");
function folder(platform) {
switch (platform) {
case types_js_1.BrowserPlatform.LINUX:
return 'linux64';
case types_js_1.BrowserPlatform.MAC_ARM:
return 'mac-arm64';
case types_js_1.BrowserPlatform.MAC:
return 'mac-x64';
case types_js_1.BrowserPlatform.WIN32:
return 'win32';
case types_js_1.BrowserPlatform.WIN64:
return 'win64';
}
}
function resolveDownloadUrl(platform, buildId, baseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
exports.resolveDownloadUrl = resolveDownloadUrl;
function resolveDownloadPath(platform, buildId) {
return [buildId, folder(platform), `chromedriver-${folder(platform)}.zip`];
}
exports.resolveDownloadPath = resolveDownloadPath;
function relativeExecutablePath(platform, _buildId) {
switch (platform) {
case types_js_1.BrowserPlatform.MAC:
case types_js_1.BrowserPlatform.MAC_ARM:
return path_1.default.join('chromedriver-' + folder(platform), 'chromedriver');
case types_js_1.BrowserPlatform.LINUX:
return path_1.default.join('chromedriver-linux64', 'chromedriver');
case types_js_1.BrowserPlatform.WIN32:
case types_js_1.BrowserPlatform.WIN64:
return path_1.default.join('chromedriver-' + folder(platform), 'chromedriver.exe');
}
}
exports.relativeExecutablePath = relativeExecutablePath;
var chrome_js_1 = require("./chrome.js");
Object.defineProperty(exports, "resolveBuildId", { enumerable: true, get: function () { return chrome_js_1.resolveBuildId; } });
//# sourceMappingURL=chromedriver.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chromedriver.js","sourceRoot":"","sources":["../../../src/browser-data/chromedriver.ts"],"names":[],"mappings":";;;;;;AAAA;;;;GAIG;AACH,gDAAwB;AAExB,yCAA2C;AAE3C,SAAS,MAAM,CAAC,QAAyB;IACvC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,SAAS,CAAC;QACnB,KAAK,0BAAe,CAAC,OAAO;YAC1B,OAAO,WAAW,CAAC;QACrB,KAAK,0BAAe,CAAC,GAAG;YACtB,OAAO,SAAS,CAAC;QACnB,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,OAAO,CAAC;QACjB,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAgB,kBAAkB,CAChC,QAAyB,EACzB,OAAe,EACf,OAAO,GAAG,6DAA6D;IAEvE,OAAO,GAAG,OAAO,IAAI,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC1E,CAAC;AAND,gDAMC;AAED,SAAgB,mBAAmB,CACjC,QAAyB,EACzB,OAAe;IAEf,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,gBAAgB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC7E,CAAC;AALD,kDAKC;AAED,SAAgB,sBAAsB,CACpC,QAAyB,EACzB,QAAgB;IAEhB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,0BAAe,CAAC,GAAG,CAAC;QACzB,KAAK,0BAAe,CAAC,OAAO;YAC1B,OAAO,cAAI,CAAC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC,CAAC;QACvE,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,cAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;QAC3D,KAAK,0BAAe,CAAC,KAAK,CAAC;QAC3B,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,cAAI,CAAC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAdD,wDAcC;AAED,yCAA2C;AAAnC,2GAAA,cAAc,OAAA"}

View File

@@ -0,0 +1,11 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { BrowserPlatform } from './types.js';
export declare function resolveDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): string;
export declare function resolveDownloadPath(platform: BrowserPlatform, buildId: string): string[];
export declare function relativeExecutablePath(platform: BrowserPlatform, _buildId: string): string;
export declare function resolveBuildId(platform: BrowserPlatform): Promise<string>;
//# sourceMappingURL=chromium.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chromium.d.ts","sourceRoot":"","sources":["../../../src/browser-data/chromium.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AA+B3C,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,SAA8D,GACpE,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAEV;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAiBR;AACD,wBAAsB,cAAc,CAClC,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC,CAQjB"}

View File

@@ -0,0 +1,67 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveBuildId = exports.relativeExecutablePath = exports.resolveDownloadPath = exports.resolveDownloadUrl = void 0;
const path_1 = __importDefault(require("path"));
const httpUtil_js_1 = require("../httpUtil.js");
const types_js_1 = require("./types.js");
function archive(platform, buildId) {
switch (platform) {
case types_js_1.BrowserPlatform.LINUX:
return 'chrome-linux';
case types_js_1.BrowserPlatform.MAC_ARM:
case types_js_1.BrowserPlatform.MAC:
return 'chrome-mac';
case types_js_1.BrowserPlatform.WIN32:
case types_js_1.BrowserPlatform.WIN64:
// Windows archive name changed at r591479.
return parseInt(buildId, 10) > 591479 ? 'chrome-win' : 'chrome-win32';
}
}
function folder(platform) {
switch (platform) {
case types_js_1.BrowserPlatform.LINUX:
return 'Linux_x64';
case types_js_1.BrowserPlatform.MAC_ARM:
return 'Mac_Arm';
case types_js_1.BrowserPlatform.MAC:
return 'Mac';
case types_js_1.BrowserPlatform.WIN32:
return 'Win';
case types_js_1.BrowserPlatform.WIN64:
return 'Win_x64';
}
}
function resolveDownloadUrl(platform, buildId, baseUrl = 'https://storage.googleapis.com/chromium-browser-snapshots') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
exports.resolveDownloadUrl = resolveDownloadUrl;
function resolveDownloadPath(platform, buildId) {
return [folder(platform), buildId, `${archive(platform, buildId)}.zip`];
}
exports.resolveDownloadPath = resolveDownloadPath;
function relativeExecutablePath(platform, _buildId) {
switch (platform) {
case types_js_1.BrowserPlatform.MAC:
case types_js_1.BrowserPlatform.MAC_ARM:
return path_1.default.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium');
case types_js_1.BrowserPlatform.LINUX:
return path_1.default.join('chrome-linux', 'chrome');
case types_js_1.BrowserPlatform.WIN32:
case types_js_1.BrowserPlatform.WIN64:
return path_1.default.join('chrome-win', 'chrome.exe');
}
}
exports.relativeExecutablePath = relativeExecutablePath;
async function resolveBuildId(platform) {
return await (0, httpUtil_js_1.getText)(new URL(`https://storage.googleapis.com/chromium-browser-snapshots/${folder(platform)}/LAST_CHANGE`));
}
exports.resolveBuildId = resolveBuildId;
//# sourceMappingURL=chromium.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chromium.js","sourceRoot":"","sources":["../../../src/browser-data/chromium.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AAExB,gDAAuC;AAEvC,yCAA2C;AAE3C,SAAS,OAAO,CAAC,QAAyB,EAAE,OAAe;IACzD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,cAAc,CAAC;QACxB,KAAK,0BAAe,CAAC,OAAO,CAAC;QAC7B,KAAK,0BAAe,CAAC,GAAG;YACtB,OAAO,YAAY,CAAC;QACtB,KAAK,0BAAe,CAAC,KAAK,CAAC;QAC3B,KAAK,0BAAe,CAAC,KAAK;YACxB,2CAA2C;YAC3C,OAAO,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,QAAyB;IACvC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,WAAW,CAAC;QACrB,KAAK,0BAAe,CAAC,OAAO;YAC1B,OAAO,SAAS,CAAC;QACnB,KAAK,0BAAe,CAAC,GAAG;YACtB,OAAO,KAAK,CAAC;QACf,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,KAAK,CAAC;QACf,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,SAAgB,kBAAkB,CAChC,QAAyB,EACzB,OAAe,EACf,OAAO,GAAG,2DAA2D;IAErE,OAAO,GAAG,OAAO,IAAI,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC1E,CAAC;AAND,gDAMC;AAED,SAAgB,mBAAmB,CACjC,QAAyB,EACzB,OAAe;IAEf,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;AAC1E,CAAC;AALD,kDAKC;AAED,SAAgB,sBAAsB,CACpC,QAAyB,EACzB,QAAgB;IAEhB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,0BAAe,CAAC,GAAG,CAAC;QACzB,KAAK,0BAAe,CAAC,OAAO;YAC1B,OAAO,cAAI,CAAC,IAAI,CACd,YAAY,EACZ,cAAc,EACd,UAAU,EACV,OAAO,EACP,UAAU,CACX,CAAC;QACJ,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,cAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QAC7C,KAAK,0BAAe,CAAC,KAAK,CAAC;QAC3B,KAAK,0BAAe,CAAC,KAAK;YACxB,OAAO,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AApBD,wDAoBC;AACM,KAAK,UAAU,cAAc,CAClC,QAAyB;IAEzB,OAAO,MAAM,IAAA,qBAAO,EAClB,IAAI,GAAG,CACL,6DAA6D,MAAM,CACjE,QAAQ,CACT,cAAc,CAChB,CACF,CAAC;AACJ,CAAC;AAVD,wCAUC"}

View File

@@ -0,0 +1,12 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { BrowserPlatform, type ProfileOptions } from './types.js';
export declare function resolveDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): string;
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 createProfile(options: ProfileOptions): Promise<void>;
//# sourceMappingURL=firefox.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"firefox.d.ts","sourceRoot":"","sources":["../../../src/browser-data/firefox.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,EAAC,eAAe,EAAE,KAAK,cAAc,EAAC,MAAM,YAAY,CAAC;AAehE,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,SAA2E,GACjF,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAEV;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAWR;AAED,wBAAsB,cAAc,CAClC,OAAO,GAAE,iBAAqC,GAC7C,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAa1E"}

View File

@@ -0,0 +1,257 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createProfile = exports.resolveBuildId = exports.relativeExecutablePath = exports.resolveDownloadPath = exports.resolveDownloadUrl = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const httpUtil_js_1 = require("../httpUtil.js");
const types_js_1 = require("./types.js");
function archive(platform, buildId) {
switch (platform) {
case types_js_1.BrowserPlatform.LINUX:
return `firefox-${buildId}.en-US.${platform}-x86_64.tar.bz2`;
case types_js_1.BrowserPlatform.MAC_ARM:
case types_js_1.BrowserPlatform.MAC:
return `firefox-${buildId}.en-US.mac.dmg`;
case types_js_1.BrowserPlatform.WIN32:
case types_js_1.BrowserPlatform.WIN64:
return `firefox-${buildId}.en-US.${platform}.zip`;
}
}
function resolveDownloadUrl(platform, buildId, baseUrl = 'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
exports.resolveDownloadUrl = resolveDownloadUrl;
function resolveDownloadPath(platform, buildId) {
return [archive(platform, buildId)];
}
exports.resolveDownloadPath = resolveDownloadPath;
function relativeExecutablePath(platform, _buildId) {
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');
}
}
exports.relativeExecutablePath = relativeExecutablePath;
async function resolveBuildId(channel = '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];
if (!version) {
throw new Error(`Channel ${channel} is not found.`);
}
return version;
}
exports.resolveBuildId = resolveBuildId;
async function createProfile(options) {
if (!fs_1.default.existsSync(options.path)) {
await fs_1.default.promises.mkdir(options.path, {
recursive: true,
});
}
await writePreferences({
preferences: {
...defaultProfilePreferences(options.preferences),
...options.preferences,
},
path: options.path,
});
}
exports.createProfile = createProfile;
function defaultProfilePreferences(extraPrefs) {
const server = 'dummy.test';
const defaultPrefs = {
// Make sure Shield doesn't hit the network.
'app.normandy.api_url': '',
// Disable Firefox old build background check
'app.update.checkInstallTime': false,
// Disable automatically upgrading Firefox
'app.update.disabledForTesting': true,
// Increase the APZ content response timeout to 1 minute
'apz.content_response_timeout': 60000,
// Prevent various error message on the console
// jest-puppeteer asserts that no error message is emitted by the console
'browser.contentblocking.features.standard': '-tp,tpPrivate,cookieBehavior0,-cm,-fp',
// Enable the dump function: which sends messages to the system
// console
// https://bugzilla.mozilla.org/show_bug.cgi?id=1543115
'browser.dom.window.dump.enabled': true,
// Disable topstories
'browser.newtabpage.activity-stream.feeds.system.topstories': false,
// Always display a blank page
'browser.newtabpage.enabled': false,
// Background thumbnails in particular cause grief: and disabling
// thumbnails in general cannot hurt
'browser.pagethumbnails.capturing_disabled': true,
// Disable safebrowsing components.
'browser.safebrowsing.blockedURIs.enabled': false,
'browser.safebrowsing.downloads.enabled': false,
'browser.safebrowsing.malware.enabled': false,
'browser.safebrowsing.phishing.enabled': false,
// Disable updates to search engines.
'browser.search.update': false,
// Do not restore the last open set of tabs if the browser has crashed
'browser.sessionstore.resume_from_crash': false,
// Skip check for default browser on startup
'browser.shell.checkDefaultBrowser': false,
// Disable newtabpage
'browser.startup.homepage': 'about:blank',
// Do not redirect user when a milstone upgrade of Firefox is detected
'browser.startup.homepage_override.mstone': 'ignore',
// Start with a blank page about:blank
'browser.startup.page': 0,
// Do not allow background tabs to be zombified on Android: otherwise for
// tests that open additional tabs: the test harness tab itself might get
// unloaded
'browser.tabs.disableBackgroundZombification': false,
// Do not warn when closing all other open tabs
'browser.tabs.warnOnCloseOtherTabs': false,
// Do not warn when multiple tabs will be opened
'browser.tabs.warnOnOpen': false,
// Do not automatically offer translations, as tests do not expect this.
'browser.translations.automaticallyPopup': false,
// Disable the UI tour.
'browser.uitour.enabled': false,
// Turn off search suggestions in the location bar so as not to trigger
// network connections.
'browser.urlbar.suggest.searches': false,
// Disable first run splash page on Windows 10
'browser.usedOnWindows10.introURL': '',
// Do not warn on quitting Firefox
'browser.warnOnQuit': false,
// Defensively disable data reporting systems
'datareporting.healthreport.documentServerURI': `http://${server}/dummy/healthreport/`,
'datareporting.healthreport.logging.consoleEnabled': false,
'datareporting.healthreport.service.enabled': false,
'datareporting.healthreport.service.firstRun': false,
'datareporting.healthreport.uploadEnabled': false,
// Do not show datareporting policy notifications which can interfere with tests
'datareporting.policy.dataSubmissionEnabled': false,
'datareporting.policy.dataSubmissionPolicyBypassNotification': true,
// DevTools JSONViewer sometimes fails to load dependencies with its require.js.
// This doesn't affect Puppeteer but spams console (Bug 1424372)
'devtools.jsonview.enabled': false,
// Disable popup-blocker
'dom.disable_open_during_load': false,
// Enable the support for File object creation in the content process
// Required for |Page.setFileInputFiles| protocol method.
'dom.file.createInChild': true,
// Disable the ProcessHangMonitor
'dom.ipc.reportProcessHangs': false,
// Disable slow script dialogues
'dom.max_chrome_script_run_time': 0,
'dom.max_script_run_time': 0,
// Only load extensions from the application and user profile
// AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
'extensions.autoDisableScopes': 0,
'extensions.enabledScopes': 5,
// Disable metadata caching for installed add-ons by default
'extensions.getAddons.cache.enabled': false,
// Disable installing any distribution extensions or add-ons.
'extensions.installDistroAddons': false,
// Disabled screenshots extension
'extensions.screenshots.disabled': true,
// Turn off extension updates so they do not bother tests
'extensions.update.enabled': false,
// Turn off extension updates so they do not bother tests
'extensions.update.notifyUser': false,
// Make sure opening about:addons will not hit the network
'extensions.webservice.discoverURL': `http://${server}/dummy/discoveryURL`,
// Allow the application to have focus even it runs in the background
'focusmanager.testmode': true,
// Disable useragent updates
'general.useragent.updates.enabled': false,
// Always use network provider for geolocation tests so we bypass the
// macOS dialog raised by the corelocation provider
'geo.provider.testing': true,
// Do not scan Wifi
'geo.wifi.scan': false,
// No hang monitor
'hangmonitor.timeout': 0,
// Show chrome errors and warnings in the error console
'javascript.options.showInConsole': true,
// Disable download and usage of OpenH264: and Widevine plugins
'media.gmp-manager.updateEnabled': false,
// Disable the GFX sanity window
'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
'network.cookie.sameSite.laxByDefault': false,
// Do not prompt for temporary redirects
'network.http.prompt-temp-redirect': false,
// Disable speculative connections so they are not reported as leaking
// when they are hanging around
'network.http.speculative-parallel-limit': 0,
// Do not automatically switch between offline and online
'network.manage-offline-status': false,
// Make sure SNTP requests do not hit the network
'network.sntp.pools': server,
// Disable Flash.
'plugin.state.flash': 0,
'privacy.trackingprotection.enabled': false,
// Can be removed once Firefox 89 is no longer supported
// https://bugzilla.mozilla.org/show_bug.cgi?id=1710839
'remote.enabled': true,
// Don't do network connections for mitm priming
'security.certerrors.mitm.priming.enabled': false,
// Local documents have access to all other local documents,
// including directory listings
'security.fileuri.strict_origin_policy': false,
// Do not wait for the notification button security delay
'security.notification_enable_delay': 0,
// Ensure blocklist updates do not hit the network
'services.settings.server': `http://${server}/dummy/blocklist/`,
// Do not automatically fill sign-in forms with known usernames and
// passwords
'signon.autofillForms': false,
// Disable password capture, so that tests that include forms are not
// influenced by the presence of the persistent doorhanger notification
'signon.rememberSignons': false,
// Disable first-run welcome page
'startup.homepage_welcome_url': 'about:blank',
// Disable first-run welcome page
'startup.homepage_welcome_url.additional': '',
// Disable browser animations (tabs, fullscreen, sliding alerts)
'toolkit.cosmeticAnimations.enabled': false,
// Prevent starting into safe mode after application crashes
'toolkit.startup.max_resumed_crashes': -1,
};
return Object.assign(defaultPrefs, extraPrefs);
}
/**
* Populates the user.js file with custom preferences as needed to allow
* Firefox's CDP support to properly function. These preferences will be
* automatically copied over to prefs.js during startup of Firefox. To be
* able to restore the original values of preferences a backup of prefs.js
* will be created.
*
* @param prefs - List of preferences to add.
* @param profilePath - Firefox profile to write the preferences to.
*/
async function writePreferences(options) {
const lines = Object.entries(options.preferences).map(([key, value]) => {
return `user_pref(${JSON.stringify(key)}, ${JSON.stringify(value)});`;
});
await fs_1.default.promises.writeFile(path_1.default.join(options.path, 'user.js'), lines.join('\n'));
// Create a backup of the preferences file if it already exitsts.
const prefsPath = path_1.default.join(options.path, 'prefs.js');
if (fs_1.default.existsSync(prefsPath)) {
const prefsBackupPath = path_1.default.join(options.path, 'prefs.js.puppeteer');
await fs_1.default.promises.copyFile(prefsPath, prefsBackupPath);
}
}
//# sourceMappingURL=firefox.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,57 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* Supported browsers.
*
* @public
*/
export declare enum Browser {
CHROME = "chrome",
CHROMEHEADLESSSHELL = "chrome-headless-shell",
CHROMIUM = "chromium",
FIREFOX = "firefox",
CHROMEDRIVER = "chromedriver"
}
/**
* Platform names used to identify a OS platform x architecture combination in the way
* that is relevant for the browser download.
*
* @public
*/
export declare enum BrowserPlatform {
LINUX = "linux",
MAC = "mac",
MAC_ARM = "mac_arm",
WIN32 = "win32",
WIN64 = "win64"
}
/**
* @public
*/
export declare enum BrowserTag {
CANARY = "canary",
BETA = "beta",
DEV = "dev",
STABLE = "stable",
LATEST = "latest"
}
/**
* @public
*/
export interface ProfileOptions {
preferences: Record<string, unknown>;
path: string;
}
/**
* @public
*/
export declare enum ChromeReleaseChannel {
STABLE = "stable",
DEV = "dev",
CANARY = "canary",
BETA = "beta"
}
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/browser-data/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,oBAAY,OAAO;IACjB,MAAM,WAAW;IACjB,mBAAmB,0BAA0B;IAC7C,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,YAAY,iBAAiB;CAC9B;AAED;;;;;GAKG;AACH,oBAAY,eAAe;IACzB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,oBAAY,UAAU;IACpB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;CACd"}

View File

@@ -0,0 +1,57 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChromeReleaseChannel = exports.BrowserTag = exports.BrowserPlatform = exports.Browser = void 0;
/**
* Supported browsers.
*
* @public
*/
var Browser;
(function (Browser) {
Browser["CHROME"] = "chrome";
Browser["CHROMEHEADLESSSHELL"] = "chrome-headless-shell";
Browser["CHROMIUM"] = "chromium";
Browser["FIREFOX"] = "firefox";
Browser["CHROMEDRIVER"] = "chromedriver";
})(Browser || (exports.Browser = Browser = {}));
/**
* Platform names used to identify a OS platform x architecture combination in the way
* that is relevant for the browser download.
*
* @public
*/
var BrowserPlatform;
(function (BrowserPlatform) {
BrowserPlatform["LINUX"] = "linux";
BrowserPlatform["MAC"] = "mac";
BrowserPlatform["MAC_ARM"] = "mac_arm";
BrowserPlatform["WIN32"] = "win32";
BrowserPlatform["WIN64"] = "win64";
})(BrowserPlatform || (exports.BrowserPlatform = BrowserPlatform = {}));
/**
* @public
*/
var BrowserTag;
(function (BrowserTag) {
BrowserTag["CANARY"] = "canary";
BrowserTag["BETA"] = "beta";
BrowserTag["DEV"] = "dev";
BrowserTag["STABLE"] = "stable";
BrowserTag["LATEST"] = "latest";
})(BrowserTag || (exports.BrowserTag = BrowserTag = {}));
/**
* @public
*/
var ChromeReleaseChannel;
(function (ChromeReleaseChannel) {
ChromeReleaseChannel["STABLE"] = "stable";
ChromeReleaseChannel["DEV"] = "dev";
ChromeReleaseChannel["CANARY"] = "canary";
ChromeReleaseChannel["BETA"] = "beta";
})(ChromeReleaseChannel || (exports.ChromeReleaseChannel = ChromeReleaseChannel = {}));
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/browser-data/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH;;;;GAIG;AACH,IAAY,OAMX;AAND,WAAY,OAAO;IACjB,4BAAiB,CAAA;IACjB,wDAA6C,CAAA;IAC7C,gCAAqB,CAAA;IACrB,8BAAmB,CAAA;IACnB,wCAA6B,CAAA;AAC/B,CAAC,EANW,OAAO,uBAAP,OAAO,QAMlB;AAED;;;;;GAKG;AACH,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,8BAAW,CAAA;IACX,sCAAmB,CAAA;IACnB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAED;;GAEG;AACH,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;AACnB,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB;AAUD;;GAEG;AACH,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,mCAAW,CAAA;IACX,yCAAiB,CAAA;IACjB,qCAAa,CAAA;AACf,CAAC,EALW,oBAAoB,oCAApB,oBAAoB,QAK/B"}

View File

@@ -0,0 +1,8 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import debug from 'debug';
export { debug };
//# sourceMappingURL=debug.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/debug.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,KAAK,EAAC,CAAC"}

View File

@@ -0,0 +1,14 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.debug = void 0;
const debug_1 = __importDefault(require("debug"));
exports.debug = debug_1.default;
//# sourceMappingURL=debug.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/debug.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kDAA0B;AAElB,gBAFD,eAAK,CAEC"}

View File

@@ -0,0 +1,11 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { BrowserPlatform } from './browser-data/browser-data.js';
/**
* @public
*/
export declare function detectBrowserPlatform(): BrowserPlatform | undefined;
//# sourceMappingURL=detectPlatform.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"detectPlatform.d.ts","sourceRoot":"","sources":["../../src/detectPlatform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAE/D;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,GAAG,SAAS,CAkBnE"}

View File

@@ -0,0 +1,53 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectBrowserPlatform = void 0;
const os_1 = __importDefault(require("os"));
const browser_data_js_1 = require("./browser-data/browser-data.js");
/**
* @public
*/
function detectBrowserPlatform() {
const platform = os_1.default.platform();
switch (platform) {
case 'darwin':
return os_1.default.arch() === 'arm64'
? browser_data_js_1.BrowserPlatform.MAC_ARM
: browser_data_js_1.BrowserPlatform.MAC;
case 'linux':
return browser_data_js_1.BrowserPlatform.LINUX;
case 'win32':
return os_1.default.arch() === 'x64' ||
// Windows 11 for ARM supports x64 emulation
(os_1.default.arch() === 'arm64' && isWindows11(os_1.default.release()))
? browser_data_js_1.BrowserPlatform.WIN64
: browser_data_js_1.BrowserPlatform.WIN32;
default:
return undefined;
}
}
exports.detectBrowserPlatform = detectBrowserPlatform;
/**
* Windows 11 is identified by the version 10.0.22000 or greater
* @internal
*/
function isWindows11(version) {
const parts = version.split('.');
if (parts.length > 2) {
const major = parseInt(parts[0], 10);
const minor = parseInt(parts[1], 10);
const patch = parseInt(parts[2], 10);
return (major > 10 ||
(major === 10 && minor > 0) ||
(major === 10 && minor === 0 && patch >= 22000));
}
return false;
}
//# sourceMappingURL=detectPlatform.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"detectPlatform.js","sourceRoot":"","sources":["../../src/detectPlatform.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,4CAAoB;AAEpB,oEAA+D;AAE/D;;GAEG;AACH,SAAgB,qBAAqB;IACnC,MAAM,QAAQ,GAAG,YAAE,CAAC,QAAQ,EAAE,CAAC;IAC/B,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,YAAE,CAAC,IAAI,EAAE,KAAK,OAAO;gBAC1B,CAAC,CAAC,iCAAe,CAAC,OAAO;gBACzB,CAAC,CAAC,iCAAe,CAAC,GAAG,CAAC;QAC1B,KAAK,OAAO;YACV,OAAO,iCAAe,CAAC,KAAK,CAAC;QAC/B,KAAK,OAAO;YACV,OAAO,YAAE,CAAC,IAAI,EAAE,KAAK,KAAK;gBACxB,4CAA4C;gBAC5C,CAAC,YAAE,CAAC,IAAI,EAAE,KAAK,OAAO,IAAI,WAAW,CAAC,YAAE,CAAC,OAAO,EAAE,CAAC,CAAC;gBACpD,CAAC,CAAC,iCAAe,CAAC,KAAK;gBACvB,CAAC,CAAC,iCAAe,CAAC,KAAK,CAAC;QAC5B;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAlBD,sDAkBC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,OAAe;IAClC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC;QAC/C,OAAO,CACL,KAAK,GAAG,EAAE;YACV,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,GAAG,CAAC,CAAC;YAC3B,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,CAChD,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}

View File

@@ -0,0 +1,10 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @internal
*/
export declare function unpackArchive(archivePath: string, folderPath: string): Promise<void>;
//# sourceMappingURL=fileUtil.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fileUtil.d.ts","sourceRoot":"","sources":["../../src/fileUtil.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH;;GAEG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAWf"}

View File

@@ -0,0 +1,100 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.unpackArchive = void 0;
const child_process_1 = require("child_process");
const fs_1 = require("fs");
const promises_1 = require("fs/promises");
const path = __importStar(require("path"));
const util_1 = require("util");
const extract_zip_1 = __importDefault(require("extract-zip"));
const tar_fs_1 = __importDefault(require("tar-fs"));
const unbzip2_stream_1 = __importDefault(require("unbzip2-stream"));
const exec = (0, util_1.promisify)(child_process_1.exec);
/**
* @internal
*/
async function unpackArchive(archivePath, folderPath) {
if (archivePath.endsWith('.zip')) {
await (0, extract_zip_1.default)(archivePath, { dir: folderPath });
}
else if (archivePath.endsWith('.tar.bz2')) {
await extractTar(archivePath, folderPath);
}
else if (archivePath.endsWith('.dmg')) {
await (0, promises_1.mkdir)(folderPath);
await installDMG(archivePath, folderPath);
}
else {
throw new Error(`Unsupported archive format: ${archivePath}`);
}
}
exports.unpackArchive = unpackArchive;
/**
* @internal
*/
function extractTar(tarPath, folderPath) {
return new Promise((fulfill, reject) => {
const tarStream = tar_fs_1.default.extract(folderPath);
tarStream.on('error', reject);
tarStream.on('finish', fulfill);
const readStream = (0, fs_1.createReadStream)(tarPath);
readStream.pipe((0, unbzip2_stream_1.default)()).pipe(tarStream);
});
}
/**
* @internal
*/
async function installDMG(dmgPath, folderPath) {
const { stdout } = await exec(`hdiutil attach -nobrowse -noautoopen "${dmgPath}"`);
const volumes = stdout.match(/\/Volumes\/(.*)/m);
if (!volumes) {
throw new Error(`Could not find volume path in ${stdout}`);
}
const mountPath = volumes[0];
try {
const fileNames = await (0, promises_1.readdir)(mountPath);
const appName = fileNames.find(item => {
return typeof item === 'string' && item.endsWith('.app');
});
if (!appName) {
throw new Error(`Cannot find app in ${mountPath}`);
}
const mountedPath = path.join(mountPath, appName);
await exec(`cp -R "${mountedPath}" "${folderPath}"`);
}
finally {
await exec(`hdiutil detach "${mountPath}" -quiet`);
}
}
//# sourceMappingURL=fileUtil.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fileUtil.js","sourceRoot":"","sources":["../../src/fileUtil.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAuD;AACvD,2BAAoC;AACpC,0CAA2C;AAC3C,2CAA6B;AAC7B,+BAA+B;AAE/B,8DAAqC;AACrC,oDAAyB;AACzB,oEAAkC;AAElC,MAAM,IAAI,GAAG,IAAA,gBAAS,EAAC,oBAAgB,CAAC,CAAC;AAEzC;;GAEG;AACI,KAAK,UAAU,aAAa,CACjC,WAAmB,EACnB,UAAkB;IAElB,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,MAAM,IAAA,qBAAU,EAAC,WAAW,EAAE,EAAC,GAAG,EAAE,UAAU,EAAC,CAAC,CAAC;IACnD,CAAC;SAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5C,MAAM,UAAU,CAAC,WAAW,EAAE,UAAU,CAA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G,MAAM,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACpC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;QACrD,CAAC;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAU,EAAE,OAAO,CAAC,CAAC;QAEnD,MAAM,IAAI,CAAC,UAAU,WAAW,MAAM,UAAU,GAAG,CAAC,CAAC;IACvD,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,mBAAmB,SAAS,UAAU,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/// <reference types="node" />
/// <reference types="node" />
import * as http from 'http';
import { URL } from 'url';
export declare function headHttpRequest(url: URL): Promise<boolean>;
export declare function httpRequest(url: URL, method: string, response: (x: http.IncomingMessage) => void, keepAlive?: boolean): http.ClientRequest;
/**
* @internal
*/
export declare function downloadFile(url: URL, destinationPath: string, progressCallback?: (downloadedBytes: number, totalBytes: number) => void): Promise<void>;
export declare function getJSON(url: URL): Promise<unknown>;
export declare function getText(url: URL): Promise<string>;
//# sourceMappingURL=httpUtil.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"httpUtil.d.ts","sourceRoot":"","sources":["../../src/httpUtil.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;AAGH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAC,GAAG,EAAmB,MAAM,KAAK,CAAC;AAI1C,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAgB1D;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,KAAK,IAAI,EAC3C,SAAS,UAAO,GACf,IAAI,CAAC,aAAa,CA8BpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,eAAe,EAAE,MAAM,EACvB,gBAAgB,CAAC,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,GACvE,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED,wBAAsB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAOxD;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CA2BjD"}

View File

@@ -0,0 +1,152 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getText = exports.getJSON = exports.downloadFile = exports.httpRequest = exports.headHttpRequest = void 0;
const fs_1 = require("fs");
const http = __importStar(require("http"));
const https = __importStar(require("https"));
const url_1 = require("url");
const proxy_agent_1 = require("proxy-agent");
function headHttpRequest(url) {
return new Promise(resolve => {
const request = httpRequest(url, 'HEAD', response => {
// consume response data free node process
response.resume();
resolve(response.statusCode === 200);
}, false);
request.on('error', () => {
resolve(false);
});
});
}
exports.headHttpRequest = headHttpRequest;
function httpRequest(url, method, response, keepAlive = true) {
const options = {
protocol: url.protocol,
hostname: url.hostname,
port: url.port,
path: url.pathname + url.search,
method,
headers: keepAlive ? { Connection: 'keep-alive' } : undefined,
auth: (0, url_1.urlToHttpOptions)(url).auth,
agent: new proxy_agent_1.ProxyAgent(),
};
const requestCallback = (res) => {
if (res.statusCode &&
res.statusCode >= 300 &&
res.statusCode < 400 &&
res.headers.location) {
httpRequest(new url_1.URL(res.headers.location), method, response);
}
else {
response(res);
}
};
const request = options.protocol === 'https:'
? https.request(options, requestCallback)
: http.request(options, requestCallback);
request.end();
return request;
}
exports.httpRequest = httpRequest;
/**
* @internal
*/
function downloadFile(url, destinationPath, progressCallback) {
return new Promise((resolve, reject) => {
let downloadedBytes = 0;
let totalBytes = 0;
function onData(chunk) {
downloadedBytes += chunk.length;
progressCallback(downloadedBytes, totalBytes);
}
const request = httpRequest(url, 'GET', response => {
if (response.statusCode !== 200) {
const error = new Error(`Download failed: server returned code ${response.statusCode}. URL: ${url}`);
// consume response data to free up memory
response.resume();
reject(error);
return;
}
const file = (0, fs_1.createWriteStream)(destinationPath);
file.on('finish', () => {
return resolve();
});
file.on('error', error => {
return reject(error);
});
response.pipe(file);
totalBytes = parseInt(response.headers['content-length'], 10);
if (progressCallback) {
response.on('data', onData);
}
});
request.on('error', error => {
return reject(error);
});
});
}
exports.downloadFile = downloadFile;
async function getJSON(url) {
const text = await getText(url);
try {
return JSON.parse(text);
}
catch {
throw new Error('Could not parse JSON from ' + url.toString());
}
}
exports.getJSON = getJSON;
function getText(url) {
return new Promise((resolve, reject) => {
const request = httpRequest(url, 'GET', response => {
let data = '';
if (response.statusCode && response.statusCode >= 400) {
return reject(new Error(`Got status code ${response.statusCode}`));
}
response.on('data', chunk => {
data += chunk;
});
response.on('end', () => {
try {
return resolve(String(data));
}
catch {
return reject(new Error('Chrome version not found'));
}
});
}, false);
request.on('error', err => {
reject(err);
});
});
}
exports.getText = getText;
//# sourceMappingURL=httpUtil.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"httpUtil.js","sourceRoot":"","sources":["../../src/httpUtil.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2BAAqC;AACrC,2CAA6B;AAC7B,6CAA+B;AAC/B,6BAA0C;AAE1C,6CAAuC;AAEvC,SAAgB,eAAe,CAAC,GAAQ;IACtC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,MAAM,OAAO,GAAG,WAAW,CACzB,GAAG,EACH,MAAM,EACN,QAAQ,CAAC,EAAE;YACT,0CAA0C;YAC1C,QAAQ,CAAC,MAAM,EAAE,CAAC;YAClB,OAAO,CAAC,QAAQ,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC;QACvC,CAAC,EACD,KAAK,CACN,CAAC;QACF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACvB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAhBD,0CAgBC;AAED,SAAgB,WAAW,CACzB,GAAQ,EACR,MAAc,EACd,QAA2C,EAC3C,SAAS,GAAG,IAAI;IAEhB,MAAM,OAAO,GAAwB;QACnC,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,QAAQ,GAAG,GAAG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@license
* Copyright 2017 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { type Browser, type BrowserPlatform } from './browser-data/browser-data.js';
import { InstalledBrowser } from './Cache.js';
/**
* @public
*/
export interface InstallOptions {
/**
* Determines the path to download browsers to.
*/
cacheDir: string;
/**
* Determines which platform the browser will be suited for.
*
* @defaultValue **Auto-detected.**
*/
platform?: BrowserPlatform;
/**
* Determines which browser to install.
*/
browser: Browser;
/**
* Determines which buildId to download. BuildId should uniquely identify
* binaries and they are used for caching.
*/
buildId: string;
/**
* Provides information about the progress of the download.
*/
downloadProgressCallback?: (downloadedBytes: number, totalBytes: number) => void;
/**
* Determines the host that will be used for downloading.
*
* @defaultValue Either
*
* - https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing or
* - https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central
*
*/
baseUrl?: string;
/**
* Whether to unpack and install browser archives.
*
* @defaultValue `true`
*/
unpack?: boolean;
}
/**
* @public
*/
export declare function install(options: InstallOptions & {
unpack?: true;
}): Promise<InstalledBrowser>;
/**
* @public
*/
export declare function install(options: InstallOptions & {
unpack: false;
}): Promise<string>;
/**
* @public
*/
export interface UninstallOptions {
/**
* Determines the platform for the browser binary.
*
* @defaultValue **Auto-detected.**
*/
platform?: BrowserPlatform;
/**
* The path to the root of the cache directory.
*/
cacheDir: string;
/**
* Determines which browser to uninstall.
*/
browser: Browser;
/**
* The browser build to uninstall
*/
buildId: string;
}
/**
*
* @public
*/
export declare function uninstall(options: UninstallOptions): Promise<void>;
/**
* @public
*/
export interface GetInstalledBrowsersOptions {
/**
* The path to the root of the cache directory.
*/
cacheDir: string;
}
/**
* Returns metadata about browsers installed in the cache directory.
*
* @public
*/
export declare function getInstalledBrowsers(options: GetInstalledBrowsersOptions): Promise<InstalledBrowser[]>;
/**
* @public
*/
export declare function canDownload(options: InstallOptions): Promise<boolean>;
//# sourceMappingURL=install.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"install.d.ts","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AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAE7B;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAe3E"}

View File

@@ -0,0 +1,127 @@
"use strict";
/**
* @license
* Copyright 2017 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.canDownload = exports.getInstalledBrowsers = exports.uninstall = exports.install = void 0;
const assert_1 = __importDefault(require("assert"));
const fs_1 = require("fs");
const promises_1 = require("fs/promises");
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
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");
const detectPlatform_js_1 = require("./detectPlatform.js");
const fileUtil_js_1 = require("./fileUtil.js");
const httpUtil_js_1 = require("./httpUtil.js");
const debugInstall = (0, debug_js_1.debug)('puppeteer:browsers:install');
const times = new Map();
function debugTime(label) {
times.set(label, process.hrtime());
}
function debugTimeEnd(label) {
const end = process.hrtime();
const start = times.get(label);
if (!start) {
return;
}
const duration = end[0] * 1000 + end[1] / 1e6 - (start[0] * 1000 + start[1] / 1e6); // calculate duration in milliseconds
debugInstall(`Duration for ${label}: ${duration}ms`);
}
async function install(options) {
options.platform ??= (0, detectPlatform_js_1.detectBrowserPlatform)();
options.unpack ??= true;
if (!options.platform) {
throw new Error(`Cannot download a binary for the provided platform: ${os_1.default.platform()} (${os_1.default.arch()})`);
}
const url = getDownloadUrl(options.browser, options.platform, options.buildId, options.baseUrl);
const fileName = url.toString().split('/').pop();
(0, assert_1.default)(fileName, `A malformed download URL was found: ${url}.`);
const cache = new Cache_js_1.Cache(options.cacheDir);
const browserRoot = cache.browserRoot(options.browser);
const archivePath = path_1.default.join(browserRoot, `${options.buildId}-${fileName}`);
if (!(0, fs_1.existsSync)(browserRoot)) {
await (0, promises_1.mkdir)(browserRoot, { recursive: true });
}
if (!options.unpack) {
if ((0, fs_1.existsSync)(archivePath)) {
return archivePath;
}
debugInstall(`Downloading binary from ${url}`);
debugTime('download');
await (0, httpUtil_js_1.downloadFile)(url, archivePath, options.downloadProgressCallback);
debugTimeEnd('download');
return archivePath;
}
const outputPath = cache.installationDir(options.browser, options.platform, options.buildId);
if ((0, fs_1.existsSync)(outputPath)) {
return new Cache_js_1.InstalledBrowser(cache, options.browser, options.buildId, options.platform);
}
try {
debugInstall(`Downloading binary from ${url}`);
try {
debugTime('download');
await (0, httpUtil_js_1.downloadFile)(url, archivePath, options.downloadProgressCallback);
}
finally {
debugTimeEnd('download');
}
debugInstall(`Installing ${archivePath} to ${outputPath}`);
try {
debugTime('extract');
await (0, fileUtil_js_1.unpackArchive)(archivePath, outputPath);
}
finally {
debugTimeEnd('extract');
}
}
finally {
if ((0, fs_1.existsSync)(archivePath)) {
await (0, promises_1.unlink)(archivePath);
}
}
return new Cache_js_1.InstalledBrowser(cache, options.browser, options.buildId, options.platform);
}
exports.install = install;
/**
*
* @public
*/
async function uninstall(options) {
options.platform ??= (0, detectPlatform_js_1.detectBrowserPlatform)();
if (!options.platform) {
throw new Error(`Cannot detect the browser platform for: ${os_1.default.platform()} (${os_1.default.arch()})`);
}
new Cache_js_1.Cache(options.cacheDir).uninstall(options.browser, options.platform, options.buildId);
}
exports.uninstall = uninstall;
/**
* Returns metadata about browsers installed in the cache directory.
*
* @public
*/
async function getInstalledBrowsers(options) {
return new Cache_js_1.Cache(options.cacheDir).getInstalledBrowsers();
}
exports.getInstalledBrowsers = getInstalledBrowsers;
/**
* @public
*/
async function canDownload(options) {
options.platform ??= (0, detectPlatform_js_1.detectBrowserPlatform)();
if (!options.platform) {
throw new Error(`Cannot download a binary for the provided platform: ${os_1.default.platform()} (${os_1.default.arch()})`);
}
return await (0, httpUtil_js_1.headHttpRequest)(getDownloadUrl(options.browser, options.platform, options.buildId, options.baseUrl));
}
exports.canDownload = canDownload;
function getDownloadUrl(browser, platform, buildId, baseUrl) {
return new URL(browser_data_js_1.downloadUrls[browser](platform, buildId, baseUrl));
}
//# sourceMappingURL=install.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,oDAA4B;AAC5B,2BAA8B;AAC9B,0CAA0C;AAC1C,4CAAoB;AACpB,gDAAwB;AAExB,oEAIwC;AACxC,yCAAmD;AACnD,yCAAiC;AACjC,2DAA0D;AAC1D,+CAA4C;AAC5C,+CAA4D;AAE5D,MAAM,YAAY,GAAG,IAAA,gBAAK,EAAC,4BAA4B,CAAC,CAAC;AAEzD,MAAM,KAAK,GAAG,IAAI,GAAG,EAA4B,CAAC;AAClD,SAAS,SAAS,CAAC,KAAa;IAC9B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IACD,MAAM,QAAQ,GACZ,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,qCAAqC;IAC1G,YAAY,CAAC,gBAA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C;AAfD,kCAeC;AAED,SAAS,cAAc,CACrB,OAAgB,EAChB,QAAyB,EACzB,OAAe,EACf,OAAgB;IAEhB,OAAO,IAAI,GAAG,CAAC,8BAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC"}

View File

@@ -0,0 +1,124 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/// <reference types="node" />
/// <reference types="node" />
import childProcess from 'child_process';
import { type Browser, type BrowserPlatform, type ChromeReleaseChannel } from './browser-data/browser-data.js';
/**
* @public
*/
export interface ComputeExecutablePathOptions {
/**
* Root path to the storage directory.
*/
cacheDir: string;
/**
* Determines which platform the browser will be suited for.
*
* @defaultValue **Auto-detected.**
*/
platform?: BrowserPlatform;
/**
* Determines which browser to launch.
*/
browser: Browser;
/**
* Determines which buildId to download. BuildId should uniquely identify
* binaries and they are used for caching.
*/
buildId: string;
}
/**
* @public
*/
export declare function computeExecutablePath(options: ComputeExecutablePathOptions): string;
/**
* @public
*/
export interface SystemOptions {
/**
* Determines which platform the browser will be suited for.
*
* @defaultValue **Auto-detected.**
*/
platform?: BrowserPlatform;
/**
* Determines which browser to launch.
*/
browser: Browser;
/**
* Release channel to look for on the system.
*/
channel: ChromeReleaseChannel;
}
/**
* @public
*/
export declare function computeSystemExecutablePath(options: SystemOptions): string;
/**
* @public
*/
export interface LaunchOptions {
executablePath: string;
pipe?: boolean;
dumpio?: boolean;
args?: string[];
env?: Record<string, string | undefined>;
handleSIGINT?: boolean;
handleSIGTERM?: boolean;
handleSIGHUP?: boolean;
detached?: boolean;
onExit?: () => Promise<void>;
}
/**
* @public
*/
export declare function launch(opts: LaunchOptions): Process;
/**
* @public
*/
export declare const CDP_WEBSOCKET_ENDPOINT_REGEX: RegExp;
/**
* @public
*/
export declare const WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX: RegExp;
/**
* @public
*/
export declare class Process {
#private;
constructor(opts: LaunchOptions);
get nodeProcess(): childProcess.ChildProcess;
close(): Promise<void>;
hasClosed(): Promise<void>;
kill(): void;
waitForLineOutput(regex: RegExp, timeout?: number): Promise<string>;
}
/**
* @internal
*/
export interface ErrorLike extends Error {
name: string;
message: string;
}
/**
* @internal
*/
export declare function isErrorLike(obj: unknown): obj is ErrorLike;
/**
* @internal
*/
export declare function isErrnoException(obj: unknown): obj is NodeJS.ErrnoException;
/**
* @public
*/
export declare class TimeoutError extends Error {
/**
* @internal
*/
constructor(message?: string);
}
//# sourceMappingURL=launch.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../src/launch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;AAEH,OAAO,YAAY,MAAM,eAAe,CAAC;AAKzC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,eAAe,EAEpB,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;AAOxC;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,4BAA4B,GACpC,MAAM,CAER;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAoB1E;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,CAAC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SAAQ,KAAK;IACrC;;OAEG;gBACS,OAAO,CAAC,EAAE,MAAM;CAK7B"}

View File

@@ -0,0 +1,342 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeoutError = exports.isErrnoException = exports.isErrorLike = exports.Process = exports.WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX = exports.CDP_WEBSOCKET_ENDPOINT_REGEX = exports.launch = exports.computeSystemExecutablePath = exports.computeExecutablePath = void 0;
const child_process_1 = __importDefault(require("child_process"));
const fs_1 = require("fs");
const os_1 = __importDefault(require("os"));
const readline_1 = __importDefault(require("readline"));
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");
const detectPlatform_js_1 = require("./detectPlatform.js");
const debugLaunch = (0, debug_js_1.debug)('puppeteer:browsers:launcher');
/**
* @public
*/
function computeExecutablePath(options) {
return new Cache_js_1.Cache(options.cacheDir).computeExecutablePath(options);
}
exports.computeExecutablePath = computeExecutablePath;
/**
* @public
*/
function computeSystemExecutablePath(options) {
options.platform ??= (0, detectPlatform_js_1.detectBrowserPlatform)();
if (!options.platform) {
throw new Error(`Cannot download a binary for the provided platform: ${os_1.default.platform()} (${os_1.default.arch()})`);
}
const path = (0, browser_data_js_1.resolveSystemExecutablePath)(options.browser, options.platform, options.channel);
try {
(0, fs_1.accessSync)(path);
}
catch (error) {
throw new Error(`Could not find Google Chrome executable for channel '${options.channel}' at '${path}'.`);
}
return path;
}
exports.computeSystemExecutablePath = computeSystemExecutablePath;
/**
* @public
*/
function launch(opts) {
return new Process(opts);
}
exports.launch = launch;
/**
* @public
*/
exports.CDP_WEBSOCKET_ENDPOINT_REGEX = /^DevTools listening on (ws:\/\/.*)$/;
/**
* @public
*/
exports.WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX = /^WebDriver BiDi listening on (ws:\/\/.*)$/;
/**
* @public
*/
class Process {
#executablePath;
#args;
#browserProcess;
#exited = false;
// The browser process can be closed externally or from the driver process. We
// need to invoke the hooks only once though but we don't know how many times
// we will be invoked.
#hooksRan = false;
#onExitHook = async () => { };
#browserProcessExiting;
constructor(opts) {
this.#executablePath = opts.executablePath;
this.#args = opts.args ?? [];
opts.pipe ??= false;
opts.dumpio ??= false;
opts.handleSIGINT ??= true;
opts.handleSIGTERM ??= true;
opts.handleSIGHUP ??= true;
// On non-windows platforms, `detached: true` makes child process a
// leader of a new process group, making it possible to kill child
// process tree with `.kill(-pid)` command. @see
// https://nodejs.org/api/child_process.html#child_process_options_detached
opts.detached ??= process.platform !== 'win32';
const stdio = this.#configureStdio({
pipe: opts.pipe,
dumpio: opts.dumpio,
});
const env = opts.env || {};
debugLaunch(`Launching ${this.#executablePath} ${this.#args.join(' ')}`, {
detached: opts.detached,
env: Object.keys(env).reduce((res, key) => {
if (key.toLowerCase().startsWith('puppeteer_')) {
res[key] = env[key];
}
return res;
}, {}),
stdio,
});
this.#browserProcess = child_process_1.default.spawn(this.#executablePath, this.#args, {
detached: opts.detached,
env,
stdio,
});
debugLaunch(`Launched ${this.#browserProcess.pid}`);
if (opts.dumpio) {
this.#browserProcess.stderr?.pipe(process.stderr);
this.#browserProcess.stdout?.pipe(process.stdout);
}
process.on('exit', this.#onDriverProcessExit);
if (opts.handleSIGINT) {
process.on('SIGINT', this.#onDriverProcessSignal);
}
if (opts.handleSIGTERM) {
process.on('SIGTERM', this.#onDriverProcessSignal);
}
if (opts.handleSIGHUP) {
process.on('SIGHUP', this.#onDriverProcessSignal);
}
if (opts.onExit) {
this.#onExitHook = opts.onExit;
}
this.#browserProcessExiting = new Promise((resolve, reject) => {
this.#browserProcess.once('exit', async () => {
debugLaunch(`Browser process ${this.#browserProcess.pid} onExit`);
this.#clearListeners();
this.#exited = true;
try {
await this.#runHooks();
}
catch (err) {
reject(err);
return;
}
resolve();
});
});
}
async #runHooks() {
if (this.#hooksRan) {
return;
}
this.#hooksRan = true;
await this.#onExitHook();
}
get nodeProcess() {
return this.#browserProcess;
}
#configureStdio(opts) {
if (opts.pipe) {
if (opts.dumpio) {
return ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'];
}
else {
return ['ignore', 'ignore', 'ignore', 'pipe', 'pipe'];
}
}
else {
if (opts.dumpio) {
return ['pipe', 'pipe', 'pipe'];
}
else {
return ['pipe', 'ignore', 'pipe'];
}
}
}
#clearListeners() {
process.off('exit', this.#onDriverProcessExit);
process.off('SIGINT', this.#onDriverProcessSignal);
process.off('SIGTERM', this.#onDriverProcessSignal);
process.off('SIGHUP', this.#onDriverProcessSignal);
}
#onDriverProcessExit = (_code) => {
this.kill();
};
#onDriverProcessSignal = (signal) => {
switch (signal) {
case 'SIGINT':
this.kill();
process.exit(130);
case 'SIGTERM':
case 'SIGHUP':
void this.close();
break;
}
};
async close() {
await this.#runHooks();
if (!this.#exited) {
this.kill();
}
return await this.#browserProcessExiting;
}
hasClosed() {
return this.#browserProcessExiting;
}
kill() {
debugLaunch(`Trying to kill ${this.#browserProcess.pid}`);
// If the process failed to launch (for example if the browser executable path
// is invalid), then the process does not get a pid assigned. A call to
// `proc.kill` would error, as the `pid` to-be-killed can not be found.
if (this.#browserProcess &&
this.#browserProcess.pid &&
pidExists(this.#browserProcess.pid)) {
try {
debugLaunch(`Browser process ${this.#browserProcess.pid} exists`);
if (process.platform === 'win32') {
try {
child_process_1.default.execSync(`taskkill /pid ${this.#browserProcess.pid} /T /F`);
}
catch (error) {
debugLaunch(`Killing ${this.#browserProcess.pid} using taskkill failed`, error);
// taskkill can fail to kill the process e.g. due to missing permissions.
// Let's kill the process via Node API. This delays killing of all child
// processes of `this.proc` until the main Node.js process dies.
this.#browserProcess.kill();
}
}
else {
// on linux the process group can be killed with the group id prefixed with
// a minus sign. The process group id is the group leader's pid.
const processGroupId = -this.#browserProcess.pid;
try {
process.kill(processGroupId, 'SIGKILL');
}
catch (error) {
debugLaunch(`Killing ${this.#browserProcess.pid} using process.kill failed`, error);
// Killing the process group can fail due e.g. to missing permissions.
// Let's kill the process via Node API. This delays killing of all child
// processes of `this.proc` until the main Node.js process dies.
this.#browserProcess.kill('SIGKILL');
}
}
}
catch (error) {
throw new Error(`${PROCESS_ERROR_EXPLANATION}\nError cause: ${isErrorLike(error) ? error.stack : error}`);
}
}
this.#clearListeners();
}
waitForLineOutput(regex, timeout = 0) {
if (!this.#browserProcess.stderr) {
throw new Error('`browserProcess` does not have stderr.');
}
const rl = readline_1.default.createInterface(this.#browserProcess.stderr);
let stderr = '';
return new Promise((resolve, reject) => {
rl.on('line', onLine);
rl.on('close', onClose);
this.#browserProcess.on('exit', onClose);
this.#browserProcess.on('error', onClose);
const timeoutId = timeout > 0 ? setTimeout(onTimeout, timeout) : undefined;
const cleanup = () => {
if (timeoutId) {
clearTimeout(timeoutId);
}
rl.off('line', onLine);
rl.off('close', onClose);
this.#browserProcess.off('exit', onClose);
this.#browserProcess.off('error', onClose);
};
function onClose(error) {
cleanup();
reject(new Error([
`Failed to launch the browser process!${error ? ' ' + error.message : ''}`,
stderr,
'',
'TROUBLESHOOTING: https://pptr.dev/troubleshooting',
'',
].join('\n')));
}
function onTimeout() {
cleanup();
reject(new TimeoutError(`Timed out after ${timeout} ms while waiting for the WS endpoint URL to appear in stdout!`));
}
function onLine(line) {
stderr += line + '\n';
const match = line.match(regex);
if (!match) {
return;
}
cleanup();
// The RegExp matches, so this will obviously exist.
resolve(match[1]);
}
});
}
}
exports.Process = Process;
const PROCESS_ERROR_EXPLANATION = `Puppeteer was unable to kill the process which ran the browser binary.
This means that, on future Puppeteer launches, Puppeteer might not be able to launch the browser.
Please check your open processes and ensure that the browser processes that Puppeteer launched have been killed.
If you think this is a bug, please report it on the Puppeteer issue tracker.`;
/**
* @internal
*/
function pidExists(pid) {
try {
return process.kill(pid, 0);
}
catch (error) {
if (isErrnoException(error)) {
if (error.code && error.code === 'ESRCH') {
return false;
}
}
throw error;
}
}
/**
* @internal
*/
function isErrorLike(obj) {
return (typeof obj === 'object' && obj !== null && 'name' in obj && 'message' in obj);
}
exports.isErrorLike = isErrorLike;
/**
* @internal
*/
function isErrnoException(obj) {
return (isErrorLike(obj) &&
('errno' in obj || 'code' in obj || 'path' in obj || 'syscall' in obj));
}
exports.isErrnoException = isErrnoException;
/**
* @public
*/
class TimeoutError extends Error {
/**
* @internal
*/
constructor(message) {
super(message);
this.name = this.constructor.name;
Error.captureStackTrace(this, this.constructor);
}
}
exports.TimeoutError = TimeoutError;
//# sourceMappingURL=launch.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
#!/usr/bin/env node
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=main-cli.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"main-cli.d.ts","sourceRoot":"","sources":["../../src/main-cli.ts"],"names":[],"mappings":";AAEA;;;;GAIG"}

11
backend/node_modules/@puppeteer/browsers/lib/cjs/main-cli.js generated vendored Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env node
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
const CLI_js_1 = require("./CLI.js");
void new CLI_js_1.CLI().run(process.argv);
//# sourceMappingURL=main-cli.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"main-cli.js","sourceRoot":"","sources":["../../src/main-cli.ts"],"names":[],"mappings":";;AAEA;;;;GAIG;;AAEH,qCAA6B;AAE7B,KAAK,IAAI,YAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}

View File

@@ -0,0 +1,15 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
export type { LaunchOptions, ComputeExecutablePathOptions as Options, SystemOptions, } from './launch.js';
export { launch, computeExecutablePath, computeSystemExecutablePath, TimeoutError, CDP_WEBSOCKET_ENDPOINT_REGEX, WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX, Process, } from './launch.js';
export type { InstallOptions, GetInstalledBrowsersOptions, UninstallOptions, } from './install.js';
export { install, getInstalledBrowsers, canDownload, uninstall, } from './install.js';
export { detectBrowserPlatform } from './detectPlatform.js';
export type { ProfileOptions } from './browser-data/browser-data.js';
export { resolveBuildId, Browser, BrowserPlatform, ChromeReleaseChannel, createProfile, } from './browser-data/browser-data.js';
export { CLI, makeProgressCallback } from './CLI.js';
export { Cache, InstalledBrowser } from './Cache.js';
//# sourceMappingURL=main.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,aAAa,EACb,4BAA4B,IAAI,OAAO,EACvC,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,MAAM,EACN,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,4BAA4B,EAC5B,uCAAuC,EACvC,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,cAAc,EACd,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,WAAW,EACX,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,qBAAqB,EAAC,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAC,cAAc,EAAC,MAAM,gCAAgC,CAAC;AACnE,OAAO,EACL,cAAc,EACd,OAAO,EACP,eAAe,EACf,oBAAoB,EACpB,aAAa,GACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAC,GAAG,EAAE,oBAAoB,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAC,KAAK,EAAE,gBAAgB,EAAC,MAAM,YAAY,CAAC"}

View File

@@ -0,0 +1,36 @@
"use strict";
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.InstalledBrowser = exports.Cache = exports.makeProgressCallback = exports.CLI = exports.createProfile = exports.ChromeReleaseChannel = exports.BrowserPlatform = exports.Browser = exports.resolveBuildId = exports.detectBrowserPlatform = exports.uninstall = exports.canDownload = exports.getInstalledBrowsers = exports.install = exports.Process = exports.WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX = exports.CDP_WEBSOCKET_ENDPOINT_REGEX = exports.TimeoutError = exports.computeSystemExecutablePath = exports.computeExecutablePath = exports.launch = void 0;
var launch_js_1 = require("./launch.js");
Object.defineProperty(exports, "launch", { enumerable: true, get: function () { return launch_js_1.launch; } });
Object.defineProperty(exports, "computeExecutablePath", { enumerable: true, get: function () { return launch_js_1.computeExecutablePath; } });
Object.defineProperty(exports, "computeSystemExecutablePath", { enumerable: true, get: function () { return launch_js_1.computeSystemExecutablePath; } });
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return launch_js_1.TimeoutError; } });
Object.defineProperty(exports, "CDP_WEBSOCKET_ENDPOINT_REGEX", { enumerable: true, get: function () { return launch_js_1.CDP_WEBSOCKET_ENDPOINT_REGEX; } });
Object.defineProperty(exports, "WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX", { enumerable: true, get: function () { return launch_js_1.WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX; } });
Object.defineProperty(exports, "Process", { enumerable: true, get: function () { return launch_js_1.Process; } });
var install_js_1 = require("./install.js");
Object.defineProperty(exports, "install", { enumerable: true, get: function () { return install_js_1.install; } });
Object.defineProperty(exports, "getInstalledBrowsers", { enumerable: true, get: function () { return install_js_1.getInstalledBrowsers; } });
Object.defineProperty(exports, "canDownload", { enumerable: true, get: function () { return install_js_1.canDownload; } });
Object.defineProperty(exports, "uninstall", { enumerable: true, get: function () { return install_js_1.uninstall; } });
var detectPlatform_js_1 = require("./detectPlatform.js");
Object.defineProperty(exports, "detectBrowserPlatform", { enumerable: true, get: function () { return detectPlatform_js_1.detectBrowserPlatform; } });
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; } });
Object.defineProperty(exports, "createProfile", { enumerable: true, get: function () { return browser_data_js_1.createProfile; } });
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; } });
Object.defineProperty(exports, "InstalledBrowser", { enumerable: true, get: function () { return Cache_js_1.InstalledBrowser; } });
//# sourceMappingURL=main.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAOH,yCAQqB;AAPnB,mGAAA,MAAM,OAAA;AACN,kHAAA,qBAAqB,OAAA;AACrB,wHAAA,2BAA2B,OAAA;AAC3B,yGAAA,YAAY,OAAA;AACZ,yHAAA,4BAA4B,OAAA;AAC5B,oIAAA,uCAAuC,OAAA;AACvC,oGAAA,OAAO,OAAA;AAOT,2CAKsB;AAJpB,qGAAA,OAAO,OAAA;AACP,kHAAA,oBAAoB,OAAA;AACpB,yGAAA,WAAW,OAAA;AACX,uGAAA,SAAS,OAAA;AAEX,yDAA0D;AAAlD,0HAAA,qBAAqB,OAAA;AAE7B,kEAMwC;AALtC,iHAAA,cAAc,OAAA;AACd,0GAAA,OAAO,OAAA;AACP,kHAAA,eAAe,OAAA;AACf,uHAAA,oBAAoB,OAAA;AACpB,gHAAA,aAAa,OAAA;AAEf,mCAAmD;AAA3C,6FAAA,GAAG,OAAA;AAAE,8GAAA,oBAAoB,OAAA;AACjC,uCAAmD;AAA3C,iGAAA,KAAK,OAAA;AAAE,4GAAA,gBAAgB,OAAA"}

View File

@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/// <reference types="node" />
import * as readline from 'readline';
import { type Browser } from './browser-data/browser-data.js';
/**
* @public
*/
export declare class CLI {
#private;
constructor(opts?: string | {
cachePath?: string;
scriptName?: string;
prefixCommand?: {
cmd: string;
description: string;
};
allowCachePathOverride?: boolean;
pinnedBrowsers?: Partial<{
[key in Browser]: string;
}>;
}, rl?: readline.Interface);
run(argv: string[]): Promise<void>;
}
/**
* @public
*/
export declare function makeProgressCallback(browser: Browser, buildId: string): (downloadedBytes: number, totalBytes: number) => void;
//# sourceMappingURL=CLI.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../src/CLI.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAGH,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAOrC,OAAO,EAEL,KAAK,OAAO,EAGb,MAAM,gCAAgC,CAAC;AAmCxC;;GAEG;AACH,qBAAa,GAAG;;gBASZ,IAAI,CAAC,EACD,MAAM,GACN;QACE,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAC,CAAC;QACnD,sBAAsB,CAAC,EAAE,OAAO,CAAC;QACjC,cAAc,CAAC,EAAE,OAAO,CAAC;aAAE,GAAG,IAAI,OAAO,GAAG,MAAM;SAAC,CAAC,CAAC;KACtD,EACL,EAAE,CAAC,EAAE,QAAQ,CAAC,SAAS;IAwDnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CA2OzC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAqBvD"}

245
backend/node_modules/@puppeteer/browsers/lib/esm/CLI.js generated vendored Normal file
View File

@@ -0,0 +1,245 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { stdin as input, stdout as output } from 'process';
import * as readline from 'readline';
import ProgressBar from 'progress';
import { hideBin } from 'yargs/helpers';
import yargs from 'yargs/yargs';
import { resolveBuildId, BrowserPlatform, } from './browser-data/browser-data.js';
import { Cache } from './Cache.js';
import { detectBrowserPlatform } from './detectPlatform.js';
import { install } from './install.js';
import { computeExecutablePath, computeSystemExecutablePath, launch, } from './launch.js';
/**
* @public
*/
export class CLI {
#cachePath;
#rl;
#scriptName = '';
#allowCachePathOverride = true;
#pinnedBrowsers;
#prefixCommand;
constructor(opts, rl) {
if (!opts) {
opts = {};
}
if (typeof opts === 'string') {
opts = {
cachePath: opts,
};
}
this.#cachePath = opts.cachePath ?? process.cwd();
this.#rl = rl;
this.#scriptName = opts.scriptName ?? '@puppeteer/browsers';
this.#allowCachePathOverride = opts.allowCachePathOverride ?? true;
this.#pinnedBrowsers = opts.pinnedBrowsers;
this.#prefixCommand = opts.prefixCommand;
}
#defineBrowserParameter(yargs) {
yargs.positional('browser', {
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',
coerce: (opt) => {
return {
name: this.#parseBrowser(opt),
buildId: this.#parseBuildId(opt),
};
},
});
}
#definePlatformParameter(yargs) {
yargs.option('platform', {
type: 'string',
desc: 'Platform that the binary needs to be compatible with.',
choices: Object.values(BrowserPlatform),
defaultDescription: 'Auto-detected',
});
}
#definePathParameter(yargs, required = false) {
if (!this.#allowCachePathOverride) {
return;
}
yargs.option('path', {
type: 'string',
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');
}
}
async run(argv) {
const yargsInstance = yargs(hideBin(argv));
let target = yargsInstance.scriptName(this.#scriptName);
if (this.#prefixCommand) {
target = target.command(this.#prefixCommand.cmd, this.#prefixCommand.description, yargs => {
return this.#build(yargs);
});
}
else {
target = this.#build(target);
}
await target
.demandCommand(1)
.help()
.wrap(Math.min(120, yargsInstance.terminalWidth()))
.parse();
}
#build(yargs) {
const latestOrPinned = this.#pinnedBrowsers ? 'pinned' : 'latest';
return yargs
.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 => {
this.#defineBrowserParameter(yargs);
this.#definePlatformParameter(yargs);
this.#definePathParameter(yargs);
yargs.option('base-url', {
type: 'string',
desc: 'Base URL to download from',
});
yargs.example('$0 install chrome', `Install the ${latestOrPinned} 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 chrome@canary', 'Install the latest available build for the Chrome Canary browser.');
yargs.example('$0 install chrome@115', 'Install the latest available build for Chrome 115.');
yargs.example('$0 install chromedriver@canary', 'Install the latest available build for ChromeDriver Canary.');
yargs.example('$0 install chromedriver@115', 'Install the latest available build for ChromeDriver 115.');
yargs.example('$0 install chromedriver@115.0.5790', 'Install the latest available patch (115.0.5790.X) build for ChromeDriver.');
yargs.example('$0 install chrome-headless-shell', 'Install the latest available chrome-headless-shell build.');
yargs.example('$0 install chrome-headless-shell@beta', 'Install the latest available chrome-headless-shell build corresponding to the Beta channel.');
yargs.example('$0 install chrome-headless-shell@118', 'Install the latest available chrome-headless-shell 118 build.');
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.');
if (this.#allowCachePathOverride) {
yargs.example('$0 install firefox --path /tmp/my-browser-cache', 'Install to the specified cache directory.');
}
}, async (argv) => {
const args = argv;
args.platform ??= detectBrowserPlatform();
if (!args.platform) {
throw new Error(`Could not resolve the current platform`);
}
if (args.browser.buildId === 'pinned') {
const pinnedVersion = this.#pinnedBrowsers?.[args.browser.name];
if (!pinnedVersion) {
throw new Error(`No pinned version found for ${args.browser.name}`);
}
args.browser.buildId = pinnedVersion;
}
args.browser.buildId = await resolveBuildId(args.browser.name, args.platform, args.browser.buildId);
await install({
browser: args.browser.name,
buildId: args.browser.buildId,
platform: args.platform,
cacheDir: args.path ?? this.#cachePath,
downloadProgressCallback: makeProgressCallback(args.browser.name, args.browser.buildId),
baseUrl: args.baseUrl,
});
console.log(`${args.browser.name}@${args.browser.buildId} ${computeExecutablePath({
browser: args.browser.name,
buildId: args.browser.buildId,
cacheDir: args.path ?? this.#cachePath,
platform: args.platform,
})}`);
})
.command('launch <browser>', 'Launch the specified browser', yargs => {
this.#defineBrowserParameter(yargs);
this.#definePlatformParameter(yargs);
this.#definePathParameter(yargs);
yargs.option('detached', {
type: 'boolean',
desc: 'Detach the child process.',
default: false,
});
yargs.option('system', {
type: 'boolean',
desc: 'Search for a browser installed on the system instead of the cache folder.',
default: false,
});
yargs.example('$0 launch chrome@115.0.5790.170', 'Launch Chrome 115.0.5790.170');
yargs.example('$0 launch firefox@112.0a1', 'Launch the Firefox browser identified by the milestone 112.0a1.');
yargs.example('$0 launch chrome@115.0.5790.170 --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) => {
const args = argv;
const executablePath = args.system
? computeSystemExecutablePath({
browser: args.browser.name,
// TODO: throw an error if not a ChromeReleaseChannel is provided.
channel: args.browser.buildId,
platform: args.platform,
})
: computeExecutablePath({
browser: args.browser.name,
buildId: args.browser.buildId,
cacheDir: args.path ?? this.#cachePath,
platform: args.platform,
});
launch({
executablePath,
detached: args.detached,
});
})
.command('clear', this.#allowCachePathOverride
? 'Removes all installed browsers from the specified cache directory'
: `Removes all installed browsers from ${this.#cachePath}`, yargs => {
this.#definePathParameter(yargs, true);
}, async (argv) => {
const args = argv;
const cacheDir = args.path ?? this.#cachePath;
const rl = this.#rl ?? 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();
}
#parseBrowser(version) {
return version.split('@').shift();
}
#parseBuildId(version) {
const parts = version.split('@');
return parts.length === 2
? parts[1]
: this.#pinnedBrowsers
? 'pinned'
: 'latest';
}
}
/**
* @public
*/
export function makeProgressCallback(browser, buildId) {
let progressBar;
let lastDownloadedBytes = 0;
return (downloadedBytes, totalBytes) => {
if (!progressBar) {
progressBar = new ProgressBar(`Downloading ${browser} r${buildId} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `, {
complete: '=',
incomplete: ' ',
width: 20,
total: totalBytes,
});
}
const delta = downloadedBytes - lastDownloadedBytes;
lastDownloadedBytes = downloadedBytes;
progressBar.tick(delta);
};
}
function toMegabytes(bytes) {
const mb = bytes / 1000 / 1000;
return `${Math.round(mb * 10) / 10} MB`;
}
//# sourceMappingURL=CLI.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,74 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { Browser, type BrowserPlatform } from './browser-data/browser-data.js';
/**
* @public
*/
export declare class InstalledBrowser {
#private;
browser: Browser;
buildId: string;
platform: BrowserPlatform;
readonly executablePath: string;
/**
* @internal
*/
constructor(cache: Cache, browser: Browser, buildId: string, platform: BrowserPlatform);
/**
* Path to the root of the installation folder. Use
* {@link computeExecutablePath} to get the path to the executable binary.
*/
get path(): string;
}
/**
* @internal
*/
export interface ComputeExecutablePathOptions {
/**
* Determines which platform the browser will be suited for.
*
* @defaultValue **Auto-detected.**
*/
platform?: BrowserPlatform;
/**
* Determines which browser to launch.
*/
browser: Browser;
/**
* Determines which buildId to download. BuildId should uniquely identify
* binaries and they are used for caching.
*/
buildId: string;
}
/**
* The cache used by Puppeteer relies on the following structure:
*
* - rootDir
* -- <browser1> | browserRoot(browser1)
* ---- <platform>-<buildId> | installationDir()
* ------ the browser-platform-buildId
* ------ specific structure.
* -- <browser2> | browserRoot(browser2)
* ---- <platform>-<buildId> | installationDir()
* ------ the browser-platform-buildId
* ------ specific structure.
* @internal
*/
export declare class Cache {
#private;
constructor(rootDir: string);
/**
* @internal
*/
get rootDir(): string;
browserRoot(browser: Browser): string;
installationDir(browser: Browser, platform: BrowserPlatform, buildId: string): string;
clear(): void;
uninstall(browser: Browser, platform: BrowserPlatform, buildId: string): void;
getInstalledBrowsers(): InstalledBrowser[];
computeExecutablePath(options: ComputeExecutablePathOptions): string;
}
//# sourceMappingURL=Cache.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EACL,OAAO,EACP,KAAK,eAAe,EAErB,MAAM,gCAAgC,CAAC;AAGxC;;GAEG;AACH,qBAAa,gBAAgB;;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAIhC;;OAEG;gBAED,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,eAAe;IAa3B;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAMjB;CACF;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,KAAK;;gBAGJ,OAAO,EAAE,MAAM;IAI3B;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAIrC,eAAe,CACb,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM;IAIT,KAAK,IAAI,IAAI;IASb,SAAS,CACP,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,IAAI;IASP,oBAAoB,IAAI,gBAAgB,EAAE;IA+B1C,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,MAAM;CAoBrE"}

View File

@@ -0,0 +1,133 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import fs from 'fs';
import os from 'os';
import path from 'path';
import { Browser, executablePathByBrowser, } from './browser-data/browser-data.js';
import { detectBrowserPlatform } from './detectPlatform.js';
/**
* @public
*/
export class InstalledBrowser {
browser;
buildId;
platform;
executablePath;
#cache;
/**
* @internal
*/
constructor(cache, browser, buildId, platform) {
this.#cache = cache;
this.browser = browser;
this.buildId = buildId;
this.platform = platform;
this.executablePath = cache.computeExecutablePath({
browser,
buildId,
platform,
});
}
/**
* Path to the root of the installation folder. Use
* {@link computeExecutablePath} to get the path to the executable binary.
*/
get path() {
return this.#cache.installationDir(this.browser, this.platform, this.buildId);
}
}
/**
* The cache used by Puppeteer relies on the following structure:
*
* - rootDir
* -- <browser1> | browserRoot(browser1)
* ---- <platform>-<buildId> | installationDir()
* ------ the browser-platform-buildId
* ------ specific structure.
* -- <browser2> | browserRoot(browser2)
* ---- <platform>-<buildId> | installationDir()
* ------ the browser-platform-buildId
* ------ specific structure.
* @internal
*/
export class Cache {
#rootDir;
constructor(rootDir) {
this.#rootDir = rootDir;
}
/**
* @internal
*/
get rootDir() {
return this.#rootDir;
}
browserRoot(browser) {
return path.join(this.#rootDir, browser);
}
installationDir(browser, platform, buildId) {
return path.join(this.browserRoot(browser), `${platform}-${buildId}`);
}
clear() {
fs.rmSync(this.#rootDir, {
force: true,
recursive: true,
maxRetries: 10,
retryDelay: 500,
});
}
uninstall(browser, platform, buildId) {
fs.rmSync(this.installationDir(browser, platform, buildId), {
force: true,
recursive: true,
maxRetries: 10,
retryDelay: 500,
});
}
getInstalledBrowsers() {
if (!fs.existsSync(this.#rootDir)) {
return [];
}
const types = fs.readdirSync(this.#rootDir);
const browsers = types.filter((t) => {
return Object.values(Browser).includes(t);
});
return browsers.flatMap(browser => {
const files = fs.readdirSync(this.browserRoot(browser));
return files
.map(file => {
const result = parseFolderPath(path.join(this.browserRoot(browser), file));
if (!result) {
return null;
}
return new InstalledBrowser(this, browser, result.buildId, result.platform);
})
.filter((item) => {
return item !== null;
});
});
}
computeExecutablePath(options) {
options.platform ??= detectBrowserPlatform();
if (!options.platform) {
throw new Error(`Cannot download a binary for the provided platform: ${os.platform()} (${os.arch()})`);
}
const installationDir = this.installationDir(options.browser, options.platform, options.buildId);
return path.join(installationDir, executablePathByBrowser[options.browser](options.platform, options.buildId));
}
}
function parseFolderPath(folderPath) {
const name = path.basename(folderPath);
const splits = name.split('-');
if (splits.length !== 2) {
return;
}
const [platform, buildId] = splits;
if (!buildId || !platform) {
return;
}
return { platform, buildId };
}
//# sourceMappingURL=Cache.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,OAAO,EAEP,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAC,qBAAqB,EAAC,MAAM,qBAAqB,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC3B,OAAO,CAAU;IACjB,OAAO,CAAS;IAChB,QAAQ,CAAkB;IACjB,cAAc,CAAS;IAEhC,MAAM,CAAQ;IAEd;;OAEG;IACH,YACE,KAAY,EACZ,OAAgB,EAChB,OAAe,EACf,QAAyB;QAEzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,qBAAqB,CAAC;YAChD,OAAO;YACP,OAAO;YACP,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAChC,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,OAAO,CACb,CAAC;IACJ,CAAC;CACF;AAuBD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,KAAK;IAChB,QAAQ,CAAS;IAEjB,YAAY,OAAe;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAA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AC,UAAU,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;IACT,CAAC;IACD,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IACnC,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IACD,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC;AAC7B,CAAC"}

View File

@@ -0,0 +1,47 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import * as chromeHeadlessShell from './chrome-headless-shell.js';
import * as chrome from './chrome.js';
import * as chromedriver from './chromedriver.js';
import * as chromium from './chromium.js';
import * as firefox from './firefox.js';
import { Browser, BrowserPlatform, ChromeReleaseChannel, type ProfileOptions } from './types.js';
export type { ProfileOptions };
export declare const downloadUrls: {
chromedriver: typeof chromedriver.resolveDownloadUrl;
"chrome-headless-shell": typeof chromeHeadlessShell.resolveDownloadUrl;
chrome: typeof chrome.resolveDownloadUrl;
chromium: typeof chromium.resolveDownloadUrl;
firefox: typeof firefox.resolveDownloadUrl;
};
export declare const downloadPaths: {
chromedriver: typeof chromedriver.resolveDownloadPath;
"chrome-headless-shell": typeof chromeHeadlessShell.resolveDownloadPath;
chrome: typeof chrome.resolveDownloadPath;
chromium: typeof chromium.resolveDownloadPath;
firefox: typeof firefox.resolveDownloadPath;
};
export declare const executablePathByBrowser: {
chromedriver: typeof chromedriver.relativeExecutablePath;
"chrome-headless-shell": typeof chromeHeadlessShell.relativeExecutablePath;
chrome: typeof chrome.relativeExecutablePath;
chromium: typeof chromium.relativeExecutablePath;
firefox: typeof firefox.relativeExecutablePath;
};
export { Browser, BrowserPlatform, ChromeReleaseChannel };
/**
* @public
*/
export declare function resolveBuildId(browser: Browser, platform: BrowserPlatform, tag: string): Promise<string>;
/**
* @public
*/
export declare function createProfile(browser: Browser, opts: ProfileOptions): Promise<void>;
/**
* @public
*/
export declare function resolveSystemExecutablePath(browser: Browser, platform: BrowserPlatform, channel: ChromeReleaseChannel): string;
//# sourceMappingURL=browser-data.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"browser-data.d.ts","sourceRoot":"","sources":["../../../src/browser-data/browser-data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,mBAAmB,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,OAAO,EACP,eAAe,EAEf,oBAAoB,EACpB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAC,cAAc,EAAC,CAAC;AAE7B,eAAO,MAAM,YAAY;;;;;;CAMxB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;CAMzB,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;CAMnC,CAAC;AAEF,OAAO,EAAC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAC,CAAC;AAExD;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,EACzB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CA+FjB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,oBAAoB,GAC5B,MAAM,CAYR"}

View File

@@ -0,0 +1,147 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import * as chromeHeadlessShell from './chrome-headless-shell.js';
import * as chrome from './chrome.js';
import * as chromedriver from './chromedriver.js';
import * as chromium from './chromium.js';
import * as firefox from './firefox.js';
import { Browser, BrowserPlatform, BrowserTag, ChromeReleaseChannel, } from './types.js';
export const downloadUrls = {
[Browser.CHROMEDRIVER]: chromedriver.resolveDownloadUrl,
[Browser.CHROMEHEADLESSSHELL]: chromeHeadlessShell.resolveDownloadUrl,
[Browser.CHROME]: chrome.resolveDownloadUrl,
[Browser.CHROMIUM]: chromium.resolveDownloadUrl,
[Browser.FIREFOX]: firefox.resolveDownloadUrl,
};
export const downloadPaths = {
[Browser.CHROMEDRIVER]: chromedriver.resolveDownloadPath,
[Browser.CHROMEHEADLESSSHELL]: chromeHeadlessShell.resolveDownloadPath,
[Browser.CHROME]: chrome.resolveDownloadPath,
[Browser.CHROMIUM]: chromium.resolveDownloadPath,
[Browser.FIREFOX]: firefox.resolveDownloadPath,
};
export const executablePathByBrowser = {
[Browser.CHROMEDRIVER]: chromedriver.relativeExecutablePath,
[Browser.CHROMEHEADLESSSHELL]: chromeHeadlessShell.relativeExecutablePath,
[Browser.CHROME]: chrome.relativeExecutablePath,
[Browser.CHROMIUM]: chromium.relativeExecutablePath,
[Browser.FIREFOX]: firefox.relativeExecutablePath,
};
export { Browser, BrowserPlatform, ChromeReleaseChannel };
/**
* @public
*/
export async function resolveBuildId(browser, platform, tag) {
switch (browser) {
case Browser.FIREFOX:
switch (tag) {
case BrowserTag.LATEST:
return await firefox.resolveBuildId('FIREFOX_NIGHTLY');
case BrowserTag.BETA:
case BrowserTag.CANARY:
case BrowserTag.DEV:
case BrowserTag.STABLE:
throw new Error(`${tag} is not supported for ${browser}. Use 'latest' instead.`);
}
case Browser.CHROME: {
switch (tag) {
case BrowserTag.LATEST:
return await chrome.resolveBuildId(ChromeReleaseChannel.CANARY);
case BrowserTag.BETA:
return await chrome.resolveBuildId(ChromeReleaseChannel.BETA);
case BrowserTag.CANARY:
return await chrome.resolveBuildId(ChromeReleaseChannel.CANARY);
case BrowserTag.DEV:
return await chrome.resolveBuildId(ChromeReleaseChannel.DEV);
case BrowserTag.STABLE:
return await chrome.resolveBuildId(ChromeReleaseChannel.STABLE);
default:
const result = await chrome.resolveBuildId(tag);
if (result) {
return result;
}
}
return tag;
}
case Browser.CHROMEDRIVER: {
switch (tag) {
case BrowserTag.LATEST:
case BrowserTag.CANARY:
return await chromedriver.resolveBuildId(ChromeReleaseChannel.CANARY);
case BrowserTag.BETA:
return await chromedriver.resolveBuildId(ChromeReleaseChannel.BETA);
case BrowserTag.DEV:
return await chromedriver.resolveBuildId(ChromeReleaseChannel.DEV);
case BrowserTag.STABLE:
return await chromedriver.resolveBuildId(ChromeReleaseChannel.STABLE);
default:
const result = await chromedriver.resolveBuildId(tag);
if (result) {
return result;
}
}
return tag;
}
case Browser.CHROMEHEADLESSSHELL: {
switch (tag) {
case BrowserTag.LATEST:
case BrowserTag.CANARY:
return await chromeHeadlessShell.resolveBuildId(ChromeReleaseChannel.CANARY);
case BrowserTag.BETA:
return await chromeHeadlessShell.resolveBuildId(ChromeReleaseChannel.BETA);
case BrowserTag.DEV:
return await chromeHeadlessShell.resolveBuildId(ChromeReleaseChannel.DEV);
case BrowserTag.STABLE:
return await chromeHeadlessShell.resolveBuildId(ChromeReleaseChannel.STABLE);
default:
const result = await chromeHeadlessShell.resolveBuildId(tag);
if (result) {
return result;
}
}
return tag;
}
case Browser.CHROMIUM:
switch (tag) {
case BrowserTag.LATEST:
return await chromium.resolveBuildId(platform);
case BrowserTag.BETA:
case BrowserTag.CANARY:
case BrowserTag.DEV:
case BrowserTag.STABLE:
throw new Error(`${tag} is not supported for ${browser}. Use 'latest' instead.`);
}
}
// We assume the tag is the buildId if it didn't match any keywords.
return tag;
}
/**
* @public
*/
export async function createProfile(browser, opts) {
switch (browser) {
case Browser.FIREFOX:
return await firefox.createProfile(opts);
case Browser.CHROME:
case Browser.CHROMIUM:
throw new Error(`Profile creation is not support for ${browser} yet`);
}
}
/**
* @public
*/
export function resolveSystemExecutablePath(browser, platform, channel) {
switch (browser) {
case Browser.CHROMEDRIVER:
case Browser.CHROMEHEADLESSSHELL:
case Browser.FIREFOX:
case Browser.CHROMIUM:
throw new Error(`System browser detection is not supported for ${browser} yet.`);
case Browser.CHROME:
return chrome.resolveSystemExecutablePath(platform, channel);
}
}
//# sourceMappingURL=browser-data.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"browser-data.js","sourceRoot":"","sources":["../../../src/browser-data/browser-data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,mBAAmB,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,OAAO,EACP,eAAe,EACf,UAAU,EACV,oBAAoB,GAErB,MAAM,YAAY,CAAC;AAIpB,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,kBAAkB;IACvD,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,kBAAkB;IACrE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,kBAAkB;IAC3C,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,kBAAkB;IAC/C,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB;CAC9C,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,mBAAmB;IACxD,CAAC,OAAO,CAAC,mBAAmB,CAA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UAAU,CAAC,MAAM,CAAC;gBACvB,KAAK,UAAU,CAAC,GAAG,CAAC;gBACpB,KAAK,UAAU,CAAC,MAAM;oBACpB,MAAM,IAAI,KAAK,CACb,GAAG,GAAG,yBAAyB,OAAO,yBAAyB,CAChE,CAAC;YACN,CAAC;IACL,CAAC;IACD,oEAAoE;IACpE,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAgB,EAChB,IAAoB;IAEpB,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,OAAO,CAAC,OAAO;YAClB,OAAO,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3C,KAAK,OAAO,CAAC,MAAM,CAAC;QACpB,KAAK,OAAO,CAAC,QAAQ;YACnB,MAAM,IAAI,KAAK,CAAC,uCAAuC,OAAO,MAAM,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAgB,EAChB,QAAyB,EACzB,OAA6B;IAE7B,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,OAAO,CAAC,YAAY,CAAC;QAC1B,KAAK,OAAO,CAAC,mBAAmB,CAAC;QACjC,KAAK,OAAO,CAAC,OAAO,CAAC;QACrB,KAAK,OAAO,CAAC,QAAQ;YACnB,MAAM,IAAI,KAAK,CACb,iDAAiD,OAAO,OAAO,CAChE,CAAC;QACJ,KAAK,OAAO,CAAC,MAAM;YACjB,OAAO,MAAM,CAAC,2BAA2B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;AACH,CAAC"}

View File

@@ -0,0 +1,6 @@
import { BrowserPlatform } from './types.js';
export declare function resolveDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): string;
export declare function resolveDownloadPath(platform: BrowserPlatform, buildId: string): string[];
export declare function relativeExecutablePath(platform: BrowserPlatform, _buildId: string): string;
export { resolveBuildId } from './chrome.js';
//# sourceMappingURL=chrome-headless-shell.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chrome-headless-shell.d.ts","sourceRoot":"","sources":["../../../src/browser-data/chrome-headless-shell.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAiB3C,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,SAAgE,GACtE,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAMV;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAoBR;AAED,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC"}

View File

@@ -0,0 +1,45 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import path from 'path';
import { BrowserPlatform } from './types.js';
function folder(platform) {
switch (platform) {
case BrowserPlatform.LINUX:
return 'linux64';
case BrowserPlatform.MAC_ARM:
return 'mac-arm64';
case BrowserPlatform.MAC:
return 'mac-x64';
case BrowserPlatform.WIN32:
return 'win32';
case BrowserPlatform.WIN64:
return 'win64';
}
}
export function resolveDownloadUrl(platform, buildId, baseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
export function resolveDownloadPath(platform, buildId) {
return [
buildId,
folder(platform),
`chrome-headless-shell-${folder(platform)}.zip`,
];
}
export function relativeExecutablePath(platform, _buildId) {
switch (platform) {
case BrowserPlatform.MAC:
case BrowserPlatform.MAC_ARM:
return path.join('chrome-headless-shell-' + folder(platform), 'chrome-headless-shell');
case BrowserPlatform.LINUX:
return path.join('chrome-headless-shell-linux64', 'chrome-headless-shell');
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return path.join('chrome-headless-shell-' + folder(platform), 'chrome-headless-shell.exe');
}
}
export { resolveBuildId } from './chrome.js';
//# sourceMappingURL=chrome-headless-shell.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chrome-headless-shell.js","sourceRoot":"","sources":["../../../src/browser-data/chrome-headless-shell.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAE3C,SAAS,MAAM,CAAC,QAAyB;IACvC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,SAAS,CAAC;QACnB,KAAK,eAAe,CAAC,OAAO;YAC1B,OAAO,WAAW,CAAC;QACrB,KAAK,eAAe,CAAC,GAAG;YACtB,OAAO,SAAS,CAAC;QACnB,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,OAAO,CAAC;QACjB,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,QAAyB,EACzB,OAAe,EACf,OAAO,GAAG,6DAA6D;IAEvE,OAAO,GAAG,OAAO,IAAI,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,QAAyB,EACzB,OAAe;IAEf,OAAO;QACL,OAAO;QACP,MAAM,CAAC,QAAQ,CAAC;QAChB,yBAAyB,MAAM,CAAC,QAAQ,CAAC,MAAM;KAChD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,QAAyB,EACzB,QAAgB;IAEhB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,eAAe,CAAC,GAAG,CAAC;QACzB,KAAK,eAAe,CAAC,OAAO;YAC1B,OAAO,IAAI,CAAC,IAAI,CACd,wBAAwB,GAAG,MAAM,CAAC,QAAQ,CAAC,EAC3C,uBAAuB,CACxB,CAAC;QACJ,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,IAAI,CAAC,IAAI,CACd,+BAA+B,EAC/B,uBAAuB,CACxB,CAAC;QACJ,KAAK,eAAe,CAAC,KAAK,CAAC;QAC3B,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,IAAI,CAAC,IAAI,CACd,wBAAwB,GAAG,MAAM,CAAC,QAAQ,CAAC,EAC3C,2BAA2B,CAC5B,CAAC;IACN,CAAC;AACH,CAAC;AAED,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC"}

View File

@@ -0,0 +1,29 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { BrowserPlatform, ChromeReleaseChannel } from './types.js';
export declare function resolveDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): string;
export declare function resolveDownloadPath(platform: BrowserPlatform, buildId: string): string[];
export declare function relativeExecutablePath(platform: BrowserPlatform, _buildId: string): string;
export declare function getLastKnownGoodReleaseForChannel(channel: ChromeReleaseChannel): Promise<{
version: string;
revision: string;
}>;
export declare function getLastKnownGoodReleaseForMilestone(milestone: string): Promise<{
version: string;
revision: string;
} | undefined>;
export declare function getLastKnownGoodReleaseForBuild(
/**
* @example `112.0.23`,
*/
buildPrefix: string): Promise<{
version: string;
revision: string;
} | undefined>;
export declare function resolveBuildId(channel: ChromeReleaseChannel): Promise<string>;
export declare function resolveBuildId(channel: string): Promise<string | undefined>;
export declare function resolveSystemExecutablePath(platform: BrowserPlatform, channel: ChromeReleaseChannel): string;
//# sourceMappingURL=chrome.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chrome.d.ts","sourceRoot":"","sources":["../../../src/browser-data/chrome.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAiBjE,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,SAAgE,GACtE,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAEV;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAiBR;AAED,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC,CAqB9C;AAED,wBAAsB,mCAAmC,CACvD,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,GAAG,SAAS,CAAC,CAW1D;AAED,wBAAsB,+BAA+B;AACnD;;GAEG;AACH,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,GAAG,SAAS,CAAC,CAW1D;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAAC;AACnB,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAwB/B,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,oBAAoB,GAC5B,MAAM,CAwCR"}

View File

@@ -0,0 +1,113 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import path from 'path';
import { getJSON } from '../httpUtil.js';
import { BrowserPlatform, ChromeReleaseChannel } from './types.js';
function folder(platform) {
switch (platform) {
case BrowserPlatform.LINUX:
return 'linux64';
case BrowserPlatform.MAC_ARM:
return 'mac-arm64';
case BrowserPlatform.MAC:
return 'mac-x64';
case BrowserPlatform.WIN32:
return 'win32';
case BrowserPlatform.WIN64:
return 'win64';
}
}
export function resolveDownloadUrl(platform, buildId, baseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
export function resolveDownloadPath(platform, buildId) {
return [buildId, folder(platform), `chrome-${folder(platform)}.zip`];
}
export function relativeExecutablePath(platform, _buildId) {
switch (platform) {
case BrowserPlatform.MAC:
case BrowserPlatform.MAC_ARM:
return path.join('chrome-' + folder(platform), 'Google Chrome for Testing.app', 'Contents', 'MacOS', 'Google Chrome for Testing');
case BrowserPlatform.LINUX:
return path.join('chrome-linux64', 'chrome');
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return path.join('chrome-' + folder(platform), 'chrome.exe');
}
}
export async function getLastKnownGoodReleaseForChannel(channel) {
const data = (await getJSON(new URL('https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json')));
for (const channel of Object.keys(data.channels)) {
data.channels[channel.toLowerCase()] = data.channels[channel];
delete data.channels[channel];
}
return data.channels[channel];
}
export async function getLastKnownGoodReleaseForMilestone(milestone) {
const data = (await getJSON(new URL('https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone.json')));
return data.milestones[milestone];
}
export async function getLastKnownGoodReleaseForBuild(
/**
* @example `112.0.23`,
*/
buildPrefix) {
const data = (await getJSON(new URL('https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build.json')));
return data.builds[buildPrefix];
}
export async function resolveBuildId(channel) {
if (Object.values(ChromeReleaseChannel).includes(channel)) {
return (await getLastKnownGoodReleaseForChannel(channel)).version;
}
if (channel.match(/^\d+$/)) {
// Potentially a milestone.
return (await getLastKnownGoodReleaseForMilestone(channel))?.version;
}
if (channel.match(/^\d+\.\d+\.\d+$/)) {
// Potentially a build prefix without the patch version.
return (await getLastKnownGoodReleaseForBuild(channel))?.version;
}
return;
}
export function resolveSystemExecutablePath(platform, channel) {
switch (platform) {
case BrowserPlatform.WIN64:
case BrowserPlatform.WIN32:
switch (channel) {
case ChromeReleaseChannel.STABLE:
return `${process.env['PROGRAMFILES']}\\Google\\Chrome\\Application\\chrome.exe`;
case ChromeReleaseChannel.BETA:
return `${process.env['PROGRAMFILES']}\\Google\\Chrome Beta\\Application\\chrome.exe`;
case ChromeReleaseChannel.CANARY:
return `${process.env['PROGRAMFILES']}\\Google\\Chrome SxS\\Application\\chrome.exe`;
case ChromeReleaseChannel.DEV:
return `${process.env['PROGRAMFILES']}\\Google\\Chrome Dev\\Application\\chrome.exe`;
}
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
switch (channel) {
case ChromeReleaseChannel.STABLE:
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
case ChromeReleaseChannel.BETA:
return '/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta';
case ChromeReleaseChannel.CANARY:
return '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary';
case ChromeReleaseChannel.DEV:
return '/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev';
}
case BrowserPlatform.LINUX:
switch (channel) {
case ChromeReleaseChannel.STABLE:
return '/opt/google/chrome/chrome';
case ChromeReleaseChannel.BETA:
return '/opt/google/chrome-beta/chrome';
case ChromeReleaseChannel.DEV:
return '/opt/google/chrome-unstable/chrome';
}
}
throw new Error(`Unable to detect browser executable path for '${channel}' on ${platform}.`);
}
//# sourceMappingURL=chrome.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chrome.js","sourceRoot":"","sources":["../../../src/browser-data/chrome.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAC,eAAe,EAAE,oB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K,oBAAoB,CAAC,MAAM;oBAC9B,OAAO,4EAA4E,CAAC;gBACtF,KAAK,oBAAoB,CAAC,GAAG;oBAC3B,OAAO,sEAAsE,CAAC;YAClF,CAAC;QACH,KAAK,eAAe,CAAC,KAAK;YACxB,QAAQ,OAAO,EAAE,CAAC;gBAChB,KAAK,oBAAoB,CAAC,MAAM;oBAC9B,OAAO,2BAA2B,CAAC;gBACrC,KAAK,oBAAoB,CAAC,IAAI;oBAC5B,OAAO,gCAAgC,CAAC;gBAC1C,KAAK,oBAAoB,CAAC,GAAG;oBAC3B,OAAO,oCAAoC,CAAC;YAChD,CAAC;IACL,CAAC;IAED,MAAM,IAAI,KAAK,CACb,iDAAiD,OAAO,QAAQ,QAAQ,GAAG,CAC5E,CAAC;AACJ,CAAC"}

View File

@@ -0,0 +1,6 @@
import { BrowserPlatform } from './types.js';
export declare function resolveDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): string;
export declare function resolveDownloadPath(platform: BrowserPlatform, buildId: string): string[];
export declare function relativeExecutablePath(platform: BrowserPlatform, _buildId: string): string;
export { resolveBuildId } from './chrome.js';
//# sourceMappingURL=chromedriver.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chromedriver.d.ts","sourceRoot":"","sources":["../../../src/browser-data/chromedriver.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAiB3C,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,SAAgE,GACtE,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAEV;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAWR;AAED,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC"}

View File

@@ -0,0 +1,41 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import path from 'path';
import { BrowserPlatform } from './types.js';
function folder(platform) {
switch (platform) {
case BrowserPlatform.LINUX:
return 'linux64';
case BrowserPlatform.MAC_ARM:
return 'mac-arm64';
case BrowserPlatform.MAC:
return 'mac-x64';
case BrowserPlatform.WIN32:
return 'win32';
case BrowserPlatform.WIN64:
return 'win64';
}
}
export function resolveDownloadUrl(platform, buildId, baseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
export function resolveDownloadPath(platform, buildId) {
return [buildId, folder(platform), `chromedriver-${folder(platform)}.zip`];
}
export function relativeExecutablePath(platform, _buildId) {
switch (platform) {
case BrowserPlatform.MAC:
case BrowserPlatform.MAC_ARM:
return path.join('chromedriver-' + folder(platform), 'chromedriver');
case BrowserPlatform.LINUX:
return path.join('chromedriver-linux64', 'chromedriver');
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return path.join('chromedriver-' + folder(platform), 'chromedriver.exe');
}
}
export { resolveBuildId } from './chrome.js';
//# sourceMappingURL=chromedriver.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chromedriver.js","sourceRoot":"","sources":["../../../src/browser-data/chromedriver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAE3C,SAAS,MAAM,CAAC,QAAyB;IACvC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,SAAS,CAAC;QACnB,KAAK,eAAe,CAAC,OAAO;YAC1B,OAAO,WAAW,CAAC;QACrB,KAAK,eAAe,CAAC,GAAG;YACtB,OAAO,SAAS,CAAC;QACnB,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,OAAO,CAAC;QACjB,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,QAAyB,EACzB,OAAe,EACf,OAAO,GAAG,6DAA6D;IAEvE,OAAO,GAAG,OAAO,IAAI,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,QAAyB,EACzB,OAAe;IAEf,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,gBAAgB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,QAAyB,EACzB,QAAgB;IAEhB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,eAAe,CAAC,GAAG,CAAC;QACzB,KAAK,eAAe,CAAC,OAAO;YAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC,CAAC;QACvE,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;QAC3D,KAAK,eAAe,CAAC,KAAK,CAAC;QAC3B,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC"}

View File

@@ -0,0 +1,11 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { BrowserPlatform } from './types.js';
export declare function resolveDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): string;
export declare function resolveDownloadPath(platform: BrowserPlatform, buildId: string): string[];
export declare function relativeExecutablePath(platform: BrowserPlatform, _buildId: string): string;
export declare function resolveBuildId(platform: BrowserPlatform): Promise<string>;
//# sourceMappingURL=chromium.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chromium.d.ts","sourceRoot":"","sources":["../../../src/browser-data/chromium.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AA+B3C,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,SAA8D,GACpE,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAEV;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAiBR;AACD,wBAAsB,cAAc,CAClC,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC,CAQjB"}

View File

@@ -0,0 +1,57 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import path from 'path';
import { getText } from '../httpUtil.js';
import { BrowserPlatform } from './types.js';
function archive(platform, buildId) {
switch (platform) {
case BrowserPlatform.LINUX:
return 'chrome-linux';
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return 'chrome-mac';
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
// Windows archive name changed at r591479.
return parseInt(buildId, 10) > 591479 ? 'chrome-win' : 'chrome-win32';
}
}
function folder(platform) {
switch (platform) {
case BrowserPlatform.LINUX:
return 'Linux_x64';
case BrowserPlatform.MAC_ARM:
return 'Mac_Arm';
case BrowserPlatform.MAC:
return 'Mac';
case BrowserPlatform.WIN32:
return 'Win';
case BrowserPlatform.WIN64:
return 'Win_x64';
}
}
export function resolveDownloadUrl(platform, buildId, baseUrl = 'https://storage.googleapis.com/chromium-browser-snapshots') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
export function resolveDownloadPath(platform, buildId) {
return [folder(platform), buildId, `${archive(platform, buildId)}.zip`];
}
export function relativeExecutablePath(platform, _buildId) {
switch (platform) {
case BrowserPlatform.MAC:
case BrowserPlatform.MAC_ARM:
return path.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium');
case BrowserPlatform.LINUX:
return path.join('chrome-linux', 'chrome');
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return path.join('chrome-win', 'chrome.exe');
}
}
export async function resolveBuildId(platform) {
return await getText(new URL(`https://storage.googleapis.com/chromium-browser-snapshots/${folder(platform)}/LAST_CHANGE`));
}
//# sourceMappingURL=chromium.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"chromium.js","sourceRoot":"","sources":["../../../src/browser-data/chromium.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAE3C,SAAS,OAAO,CAAC,QAAyB,EAAE,OAAe;IACzD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,eAAe,CAAC,KAAK;YACxB,OAAO,cAAc,CAAC;QACxB,KAAK,eAAe,CAAC,OAAO,CAAC;QAC7B,KAAK,eAAe,CAAC,GAAG;YACtB,OAAO,YAAY,CAAC;QACtB,KAAK,eAAe,CAAC,KAAK,CAAC;QAC3B,KAAK,eAAe,CAAC,KAAK;YACxB,2CAA2C;YAC3C,OAAO,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,QAAyB;IACvC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAA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AO,MAAM,OAAO,CAClB,IAAI,GAAG,CACL,6DAA6D,MAAM,CACjE,QAAQ,CACT,cAAc,CAChB,CACF,CAAC;AACJ,CAAC"}

View File

@@ -0,0 +1,12 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { BrowserPlatform, type ProfileOptions } from './types.js';
export declare function resolveDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): string;
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 createProfile(options: ProfileOptions): Promise<void>;
//# sourceMappingURL=firefox.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"firefox.d.ts","sourceRoot":"","sources":["../../../src/browser-data/firefox.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,EAAC,eAAe,EAAE,KAAK,cAAc,EAAC,MAAM,YAAY,CAAC;AAehE,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,SAA2E,GACjF,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAEV;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAWR;AAED,wBAAsB,cAAc,CAClC,OAAO,GAAE,iBAAqC,GAC7C,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAa1E"}

View File

@@ -0,0 +1,246 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import fs from 'fs';
import path from 'path';
import { getJSON } from '../httpUtil.js';
import { BrowserPlatform } from './types.js';
function archive(platform, buildId) {
switch (platform) {
case BrowserPlatform.LINUX:
return `firefox-${buildId}.en-US.${platform}-x86_64.tar.bz2`;
case BrowserPlatform.MAC_ARM:
case BrowserPlatform.MAC:
return `firefox-${buildId}.en-US.mac.dmg`;
case BrowserPlatform.WIN32:
case BrowserPlatform.WIN64:
return `firefox-${buildId}.en-US.${platform}.zip`;
}
}
export function resolveDownloadUrl(platform, buildId, baseUrl = 'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central') {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
export function resolveDownloadPath(platform, buildId) {
return [archive(platform, buildId)];
}
export function relativeExecutablePath(platform, _buildId) {
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');
}
}
export async function resolveBuildId(channel = 'FIREFOX_NIGHTLY') {
const versions = (await getJSON(new URL('https://product-details.mozilla.org/1.0/firefox_versions.json')));
const version = versions[channel];
if (!version) {
throw new Error(`Channel ${channel} is not found.`);
}
return version;
}
export async function createProfile(options) {
if (!fs.existsSync(options.path)) {
await fs.promises.mkdir(options.path, {
recursive: true,
});
}
await writePreferences({
preferences: {
...defaultProfilePreferences(options.preferences),
...options.preferences,
},
path: options.path,
});
}
function defaultProfilePreferences(extraPrefs) {
const server = 'dummy.test';
const defaultPrefs = {
// Make sure Shield doesn't hit the network.
'app.normandy.api_url': '',
// Disable Firefox old build background check
'app.update.checkInstallTime': false,
// Disable automatically upgrading Firefox
'app.update.disabledForTesting': true,
// Increase the APZ content response timeout to 1 minute
'apz.content_response_timeout': 60000,
// Prevent various error message on the console
// jest-puppeteer asserts that no error message is emitted by the console
'browser.contentblocking.features.standard': '-tp,tpPrivate,cookieBehavior0,-cm,-fp',
// Enable the dump function: which sends messages to the system
// console
// https://bugzilla.mozilla.org/show_bug.cgi?id=1543115
'browser.dom.window.dump.enabled': true,
// Disable topstories
'browser.newtabpage.activity-stream.feeds.system.topstories': false,
// Always display a blank page
'browser.newtabpage.enabled': false,
// Background thumbnails in particular cause grief: and disabling
// thumbnails in general cannot hurt
'browser.pagethumbnails.capturing_disabled': true,
// Disable safebrowsing components.
'browser.safebrowsing.blockedURIs.enabled': false,
'browser.safebrowsing.downloads.enabled': false,
'browser.safebrowsing.malware.enabled': false,
'browser.safebrowsing.phishing.enabled': false,
// Disable updates to search engines.
'browser.search.update': false,
// Do not restore the last open set of tabs if the browser has crashed
'browser.sessionstore.resume_from_crash': false,
// Skip check for default browser on startup
'browser.shell.checkDefaultBrowser': false,
// Disable newtabpage
'browser.startup.homepage': 'about:blank',
// Do not redirect user when a milstone upgrade of Firefox is detected
'browser.startup.homepage_override.mstone': 'ignore',
// Start with a blank page about:blank
'browser.startup.page': 0,
// Do not allow background tabs to be zombified on Android: otherwise for
// tests that open additional tabs: the test harness tab itself might get
// unloaded
'browser.tabs.disableBackgroundZombification': false,
// Do not warn when closing all other open tabs
'browser.tabs.warnOnCloseOtherTabs': false,
// Do not warn when multiple tabs will be opened
'browser.tabs.warnOnOpen': false,
// Do not automatically offer translations, as tests do not expect this.
'browser.translations.automaticallyPopup': false,
// Disable the UI tour.
'browser.uitour.enabled': false,
// Turn off search suggestions in the location bar so as not to trigger
// network connections.
'browser.urlbar.suggest.searches': false,
// Disable first run splash page on Windows 10
'browser.usedOnWindows10.introURL': '',
// Do not warn on quitting Firefox
'browser.warnOnQuit': false,
// Defensively disable data reporting systems
'datareporting.healthreport.documentServerURI': `http://${server}/dummy/healthreport/`,
'datareporting.healthreport.logging.consoleEnabled': false,
'datareporting.healthreport.service.enabled': false,
'datareporting.healthreport.service.firstRun': false,
'datareporting.healthreport.uploadEnabled': false,
// Do not show datareporting policy notifications which can interfere with tests
'datareporting.policy.dataSubmissionEnabled': false,
'datareporting.policy.dataSubmissionPolicyBypassNotification': true,
// DevTools JSONViewer sometimes fails to load dependencies with its require.js.
// This doesn't affect Puppeteer but spams console (Bug 1424372)
'devtools.jsonview.enabled': false,
// Disable popup-blocker
'dom.disable_open_during_load': false,
// Enable the support for File object creation in the content process
// Required for |Page.setFileInputFiles| protocol method.
'dom.file.createInChild': true,
// Disable the ProcessHangMonitor
'dom.ipc.reportProcessHangs': false,
// Disable slow script dialogues
'dom.max_chrome_script_run_time': 0,
'dom.max_script_run_time': 0,
// Only load extensions from the application and user profile
// AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
'extensions.autoDisableScopes': 0,
'extensions.enabledScopes': 5,
// Disable metadata caching for installed add-ons by default
'extensions.getAddons.cache.enabled': false,
// Disable installing any distribution extensions or add-ons.
'extensions.installDistroAddons': false,
// Disabled screenshots extension
'extensions.screenshots.disabled': true,
// Turn off extension updates so they do not bother tests
'extensions.update.enabled': false,
// Turn off extension updates so they do not bother tests
'extensions.update.notifyUser': false,
// Make sure opening about:addons will not hit the network
'extensions.webservice.discoverURL': `http://${server}/dummy/discoveryURL`,
// Allow the application to have focus even it runs in the background
'focusmanager.testmode': true,
// Disable useragent updates
'general.useragent.updates.enabled': false,
// Always use network provider for geolocation tests so we bypass the
// macOS dialog raised by the corelocation provider
'geo.provider.testing': true,
// Do not scan Wifi
'geo.wifi.scan': false,
// No hang monitor
'hangmonitor.timeout': 0,
// Show chrome errors and warnings in the error console
'javascript.options.showInConsole': true,
// Disable download and usage of OpenH264: and Widevine plugins
'media.gmp-manager.updateEnabled': false,
// Disable the GFX sanity window
'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
'network.cookie.sameSite.laxByDefault': false,
// Do not prompt for temporary redirects
'network.http.prompt-temp-redirect': false,
// Disable speculative connections so they are not reported as leaking
// when they are hanging around
'network.http.speculative-parallel-limit': 0,
// Do not automatically switch between offline and online
'network.manage-offline-status': false,
// Make sure SNTP requests do not hit the network
'network.sntp.pools': server,
// Disable Flash.
'plugin.state.flash': 0,
'privacy.trackingprotection.enabled': false,
// Can be removed once Firefox 89 is no longer supported
// https://bugzilla.mozilla.org/show_bug.cgi?id=1710839
'remote.enabled': true,
// Don't do network connections for mitm priming
'security.certerrors.mitm.priming.enabled': false,
// Local documents have access to all other local documents,
// including directory listings
'security.fileuri.strict_origin_policy': false,
// Do not wait for the notification button security delay
'security.notification_enable_delay': 0,
// Ensure blocklist updates do not hit the network
'services.settings.server': `http://${server}/dummy/blocklist/`,
// Do not automatically fill sign-in forms with known usernames and
// passwords
'signon.autofillForms': false,
// Disable password capture, so that tests that include forms are not
// influenced by the presence of the persistent doorhanger notification
'signon.rememberSignons': false,
// Disable first-run welcome page
'startup.homepage_welcome_url': 'about:blank',
// Disable first-run welcome page
'startup.homepage_welcome_url.additional': '',
// Disable browser animations (tabs, fullscreen, sliding alerts)
'toolkit.cosmeticAnimations.enabled': false,
// Prevent starting into safe mode after application crashes
'toolkit.startup.max_resumed_crashes': -1,
};
return Object.assign(defaultPrefs, extraPrefs);
}
/**
* Populates the user.js file with custom preferences as needed to allow
* Firefox's CDP support to properly function. These preferences will be
* automatically copied over to prefs.js during startup of Firefox. To be
* able to restore the original values of preferences a backup of prefs.js
* will be created.
*
* @param prefs - List of preferences to add.
* @param profilePath - Firefox profile to write the preferences to.
*/
async function writePreferences(options) {
const lines = Object.entries(options.preferences).map(([key, value]) => {
return `user_pref(${JSON.stringify(key)}, ${JSON.stringify(value)});`;
});
await fs.promises.writeFile(path.join(options.path, 'user.js'), lines.join('\n'));
// Create a backup of the preferences file if it already exitsts.
const prefsPath = path.join(options.path, 'prefs.js');
if (fs.existsSync(prefsPath)) {
const prefsBackupPath = path.join(options.path, 'prefs.js.puppeteer');
await fs.promises.copyFile(prefsPath, prefsBackupPath);
}
}
//# sourceMappingURL=firefox.js.map

Some files were not shown because too many files have changed in this diff Show More