Node updated. Some todos.

This commit is contained in:
Norm Rasmussen
2024-09-23 20:52:09 -04:00
parent 8bfaca8375
commit f25622067f
2041 changed files with 124145 additions and 110445 deletions

View File

@ -44,13 +44,10 @@ const debugInternal = (0, debug_1.default)('bidi:mapper:internal');
class BrowserInstance {
#mapperCdpConnection;
#browserProcess;
static async run(chromeOptions, mapperOptions, verbose) {
static async run(chromeOptions, verbose) {
const profileDir = await (0, promises_1.mkdtemp)(path_1.default.join(os_1.default.tmpdir(), 'web-driver-bidi-server-'));
// See https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md
const chromeArguments = [
...(chromeOptions.headless
? ['--headless', '--hide-scrollbars', '--mute-audio']
: []),
// keep-sorted start
'--allow-browser-signin=false',
'--disable-component-update',
@ -68,23 +65,23 @@ class BrowserInstance {
'--use-mock-keychain',
`--user-data-dir=${profileDir}`,
// keep-sorted end
...chromeOptions.chromeArgs.filter((arg) => !arg.startsWith('--headless')),
...chromeOptions.chromeArgs,
'about:blank',
];
const executablePath = chromeOptions.chromeBinary ??
process.env['BROWSER_BIN'] ??
(0, browsers_1.computeSystemExecutablePath)({
browser: browsers_1.Browser.CHROME,
channel: chromeOptions.channel,
});
const executablePath = chromeOptions.chromeBinary ?? process.env['BROWSER_BIN'];
if (!executablePath) {
throw new Error('Could not find Chrome binary');
}
const browserProcess = (0, browsers_1.launch)({
const launchArguments = {
executablePath,
args: chromeArguments,
env: process.env,
};
debugInternal(`Launching browser`, {
executablePath,
args: chromeArguments,
});
const browserProcess = (0, browsers_1.launch)(launchArguments);
const cdpEndpoint = await browserProcess.waitForLineOutput(browsers_1.CDP_WEBSOCKET_ENDPOINT_REGEX);
// There is a conflict between prettier and eslint here.
// prettier-ignore
@ -92,7 +89,7 @@ class BrowserInstance {
// 2. Get `BiDi-CDP` mapper JS binaries.
const mapperTabSource = await (0, reader_js_1.getMapperTabSource)();
// 3. Run `BiDi-CDP` mapper in launched browser using `MapperRunner`.
const mapperCdpConnection = await MapperCdpConnection_js_1.MapperServerCdpConnection.create(cdpConnection, mapperTabSource, verbose, mapperOptions);
const mapperCdpConnection = await MapperCdpConnection_js_1.MapperServerCdpConnection.create(cdpConnection, mapperTabSource, verbose);
return new BrowserInstance(mapperCdpConnection, browserProcess);
}
constructor(mapperCdpConnection, browserProcess) {