@agent-infra/browser 0.1.1-beta.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-browser.d.ts.map +1 -1
- package/dist/base-browser.js +36 -5
- package/dist/base-browser.js.map +1 -1
- package/dist/base-browser.mjs +32 -3
- package/dist/base-browser.mjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -21
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +0 -1
- package/dist/local-browser.d.ts.map +1 -1
- package/dist/local-browser.js +9 -8
- package/dist/local-browser.js.map +1 -1
- package/dist/local-browser.mjs +8 -9
- package/dist/local-browser.mjs.map +1 -1
- package/dist/remote-browser.d.ts +1 -0
- package/dist/remote-browser.d.ts.map +1 -1
- package/dist/remote-browser.js +10 -5
- package/dist/remote-browser.js.map +1 -1
- package/dist/remote-browser.mjs +9 -6
- package/dist/remote-browser.mjs.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -3
- package/dist/types.js.map +1 -0
- package/package.json +19 -14
- package/LICENSE +0 -201
- package/dist/browser-finder/chrome-paths.d.ts +0 -10
- package/dist/browser-finder/chrome-paths.d.ts.map +0 -1
- package/dist/browser-finder/chrome-paths.js +0 -160
- package/dist/browser-finder/chrome-paths.js.map +0 -1
- package/dist/browser-finder/chrome-paths.mjs +0 -118
- package/dist/browser-finder/chrome-paths.mjs.map +0 -1
- package/dist/browser-finder/firefox-paths.d.ts +0 -2
- package/dist/browser-finder/firefox-paths.d.ts.map +0 -1
- package/dist/browser-finder/firefox-paths.js +0 -132
- package/dist/browser-finder/firefox-paths.js.map +0 -1
- package/dist/browser-finder/firefox-paths.mjs +0 -90
- package/dist/browser-finder/firefox-paths.mjs.map +0 -1
- package/dist/browser-finder/index.d.ts +0 -15
- package/dist/browser-finder/index.d.ts.map +0 -1
- package/dist/browser-finder/index.js +0 -151
- package/dist/browser-finder/index.js.map +0 -1
- package/dist/browser-finder/index.mjs +0 -119
- package/dist/browser-finder/index.mjs.map +0 -1
- package/dist/browser-finder/index.test.d.ts +0 -2
- package/dist/browser-finder/index.test.d.ts.map +0 -1
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE_which__ from "which";
|
|
8
|
-
const platform = process.platform;
|
|
9
|
-
function getChromeOnLinux(list) {
|
|
10
|
-
try {
|
|
11
|
-
for (const name of list){
|
|
12
|
-
const path = __WEBPACK_EXTERNAL_MODULE_which__["default"].sync(name);
|
|
13
|
-
return path;
|
|
14
|
-
}
|
|
15
|
-
} catch (e) {}
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
function getChromeOnWindows(name) {
|
|
19
|
-
const suffix = `${__WEBPACK_EXTERNAL_MODULE_path__.sep}Google${__WEBPACK_EXTERNAL_MODULE_path__.sep}${name}${__WEBPACK_EXTERNAL_MODULE_path__.sep}Application${__WEBPACK_EXTERNAL_MODULE_path__.sep}chrome.exe`;
|
|
20
|
-
const prefixes = [
|
|
21
|
-
process.env.LOCALAPPDATA,
|
|
22
|
-
process.env.PROGRAMFILES,
|
|
23
|
-
process.env['PROGRAMFILES(X86)']
|
|
24
|
-
].filter(Boolean);
|
|
25
|
-
for (const prefix of prefixes){
|
|
26
|
-
const chrome = (0, __WEBPACK_EXTERNAL_MODULE_path__.join)(prefix, suffix);
|
|
27
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE_fs__.existsSync)(chrome)) return chrome;
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
function getChromeOnDarwin(name) {
|
|
32
|
-
const suffix = `/Applications/${name}.app/Contents/MacOS/${name}`;
|
|
33
|
-
const prefixes = [
|
|
34
|
-
'',
|
|
35
|
-
process.env.HOME
|
|
36
|
-
].filter((item)=>void 0 !== item);
|
|
37
|
-
for (const prefix of prefixes){
|
|
38
|
-
const chromePath = (0, __WEBPACK_EXTERNAL_MODULE_path__.join)(prefix, suffix);
|
|
39
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE_fs__.existsSync)(chromePath)) return chromePath;
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const chromePaths = {
|
|
44
|
-
chrome: {
|
|
45
|
-
linux: ()=>getChromeOnLinux([
|
|
46
|
-
'google-chrome-stable',
|
|
47
|
-
'google-chrome'
|
|
48
|
-
]),
|
|
49
|
-
darwin: ()=>getChromeOnDarwin('Google Chrome'),
|
|
50
|
-
win32: ()=>getChromeOnWindows('Chrome')
|
|
51
|
-
},
|
|
52
|
-
beta: {
|
|
53
|
-
linux: ()=>getChromeOnLinux([
|
|
54
|
-
'google-chrome-beta'
|
|
55
|
-
]),
|
|
56
|
-
darwin: ()=>getChromeOnDarwin('Google Chrome Beta'),
|
|
57
|
-
win32: ()=>getChromeOnWindows('Chrome Beta')
|
|
58
|
-
},
|
|
59
|
-
dev: {
|
|
60
|
-
linux: ()=>getChromeOnLinux([
|
|
61
|
-
'google-chrome-dev'
|
|
62
|
-
]),
|
|
63
|
-
darwin: ()=>getChromeOnDarwin('Google Chrome Dev'),
|
|
64
|
-
win32: ()=>getChromeOnWindows('Chrome Dev')
|
|
65
|
-
},
|
|
66
|
-
canary: {
|
|
67
|
-
linux: ()=>getChromeOnLinux([
|
|
68
|
-
'chromium-browser',
|
|
69
|
-
'chromium'
|
|
70
|
-
]),
|
|
71
|
-
darwin: ()=>getChromeOnDarwin('Google Chrome Canary'),
|
|
72
|
-
win32: ()=>getChromeOnWindows('Chrome SxS')
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
function getChromePath() {
|
|
76
|
-
const chrome = chromePaths.chrome;
|
|
77
|
-
if (platform && Object.keys(chrome).includes(platform)) {
|
|
78
|
-
const pth = chrome[platform]();
|
|
79
|
-
if (pth) return pth;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function getChromeBetaPath() {
|
|
83
|
-
const beta = chromePaths.beta;
|
|
84
|
-
if (platform && Object.keys(beta).includes(platform)) {
|
|
85
|
-
const pth = beta[platform]();
|
|
86
|
-
if (pth) return pth;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function getChromeDevPath() {
|
|
90
|
-
const dev = chromePaths.dev;
|
|
91
|
-
if (platform && Object.keys(dev).includes(platform)) {
|
|
92
|
-
const pth = dev[platform]();
|
|
93
|
-
if (pth) return pth;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function getChromeCanaryPath() {
|
|
97
|
-
const canary = chromePaths.canary;
|
|
98
|
-
if (platform && Object.keys(canary).includes(platform)) {
|
|
99
|
-
const pth = canary[platform]();
|
|
100
|
-
if (pth) return pth;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function getAnyChromeStable() {
|
|
104
|
-
const chrome = getChromePath();
|
|
105
|
-
if (chrome) return chrome;
|
|
106
|
-
const beta = getChromeBetaPath();
|
|
107
|
-
if (beta) return beta;
|
|
108
|
-
const dev = getChromeDevPath();
|
|
109
|
-
if (dev) return dev;
|
|
110
|
-
const canary = getChromeCanaryPath();
|
|
111
|
-
if (canary) return canary;
|
|
112
|
-
const error = new Error('Unable to find any chrome browser.');
|
|
113
|
-
error.name = 'ChromePathsError';
|
|
114
|
-
throw error;
|
|
115
|
-
}
|
|
116
|
-
export { getAnyChromeStable };
|
|
117
|
-
|
|
118
|
-
//# sourceMappingURL=chrome-paths.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser-finder/chrome-paths.mjs","sources":["webpack://@agent-infra/browser/./src/browser-finder/chrome-paths.ts"],"sourcesContent":["/**\n * The following code is modified based on\n * https://github.com/shirshak55/edge-paths/blob/master/index.ts\n *\n * MIT Licensed\n * Copyright (c) 2020 Shirshak\n * https://github.com/shirshak55/edge-paths/blob/master/LICENSE\n */\n\n/**\n * Q: Why not use [find-chrome-bin](https://github.com/mbalabash/find-chrome-bin) or [chrome-finder](https://github.com/gwuhaolin/chrome-finder)?\n *\n * A: The `find-chrome-bin` or `chrome-finder` libraries execute `lsregister -dump` under Darwin (macOS),\n * which is a time-consuming operation (taking up to 6 seconds on my computer!).\n * Since this process is performed during the app's startup, such a delay is unacceptable.\n */\nimport { existsSync } from 'fs';\nimport { sep, join } from 'path';\nimport which from 'which';\n\nconst platform = process.platform;\n\nfunction getChromeOnLinux(\n list: (\n | 'google-chrome'\n | 'google-chrome-stable'\n | 'google-chrome-beta'\n | 'google-chrome-dev'\n | 'chromium-browser'\n | 'chromium'\n )[],\n): string | null {\n // TODO: scan desktop installation folders, the `grep` operation can be somewhat time-consuming.\n // https://github.com/mbalabash/find-chrome-bin/blob/main/src/linux/index.js\n try {\n for (const name of list) {\n const path = which.sync(name);\n return path;\n }\n } catch (e) {}\n\n return null;\n}\n\nfunction getChromeOnWindows(\n name: 'Chrome' | 'Chrome Beta' | 'Chrome Dev' | 'Chrome SxS',\n): string | null {\n const suffix = `${sep}Google${sep}${name}${sep}Application${sep}chrome.exe`;\n\n const prefixes = [\n process.env.LOCALAPPDATA,\n process.env.PROGRAMFILES,\n process.env['PROGRAMFILES(X86)'],\n ].filter(Boolean);\n\n for (const prefix of prefixes) {\n const chrome = join(prefix!, suffix);\n if (existsSync(chrome)) {\n return chrome;\n }\n }\n\n return null;\n}\n\nfunction getChromeOnDarwin(\n name:\n | 'Google Chrome'\n | 'Google Chrome Beta'\n | 'Google Chrome Dev'\n | 'Google Chrome Canary',\n): string | null {\n const suffix = `/Applications/${name}.app/Contents/MacOS/${name}`;\n const prefixes = ['', process.env.HOME].filter((item) => item !== undefined);\n\n for (const prefix of prefixes) {\n const chromePath = join(prefix, suffix);\n if (existsSync(chromePath)) {\n return chromePath;\n }\n }\n\n return null;\n}\n\nconst chromePaths = {\n chrome: {\n linux: () => getChromeOnLinux(['google-chrome-stable', 'google-chrome']),\n darwin: () => getChromeOnDarwin('Google Chrome'),\n win32: () => getChromeOnWindows('Chrome'),\n },\n beta: {\n linux: () => getChromeOnLinux(['google-chrome-beta']),\n darwin: () => getChromeOnDarwin('Google Chrome Beta'),\n win32: () => getChromeOnWindows('Chrome Beta'),\n },\n dev: {\n linux: () => getChromeOnLinux(['google-chrome-dev']),\n darwin: () => getChromeOnDarwin('Google Chrome Dev'),\n win32: () => getChromeOnWindows('Chrome Dev'),\n },\n canary: {\n linux: () => getChromeOnLinux(['chromium-browser', 'chromium']),\n darwin: () => getChromeOnDarwin('Google Chrome Canary'),\n win32: () => getChromeOnWindows('Chrome SxS'),\n },\n};\n\nfunction getChromePath() {\n const chrome = chromePaths.chrome;\n\n if (platform && Object.keys(chrome).includes(platform)) {\n const pth = chrome[platform as keyof typeof chrome]();\n if (pth) {\n return pth;\n }\n }\n}\n\nfunction getChromeBetaPath() {\n const beta = chromePaths.beta;\n\n if (platform && Object.keys(beta).includes(platform)) {\n const pth = beta[platform as keyof typeof beta]();\n if (pth) {\n return pth;\n }\n }\n}\n\nfunction getChromeDevPath() {\n const dev = chromePaths.dev;\n\n if (platform && Object.keys(dev).includes(platform)) {\n const pth = dev[platform as keyof typeof dev]();\n if (pth) {\n return pth;\n }\n }\n}\n\nfunction getChromeCanaryPath() {\n const canary = chromePaths.canary;\n\n if (platform && Object.keys(canary).includes(platform)) {\n const pth = canary[platform as keyof typeof canary]();\n if (pth) {\n return pth;\n }\n }\n}\n\nexport function getAnyChromeStable(): string {\n const chrome = getChromePath();\n if (chrome) {\n return chrome;\n }\n\n const beta = getChromeBetaPath();\n if (beta) {\n return beta;\n }\n\n const dev = getChromeDevPath();\n if (dev) {\n return dev;\n }\n\n const canary = getChromeCanaryPath();\n if (canary) {\n return canary;\n }\n\n const error = new Error('Unable to find any chrome browser.');\n error.name = 'ChromePathsError';\n throw error;\n}\n"],"names":["platform","process","getChromeOnLinux","list","name","path","which","e","getChromeOnWindows","suffix","sep","prefixes","Boolean","prefix","chrome","join","existsSync","getChromeOnDarwin","item","undefined","chromePath","chromePaths","getChromePath","Object","pth","getChromeBetaPath","beta","getChromeDevPath","dev","getChromeCanaryPath","canary","getAnyChromeStable","error","Error"],"mappings":";;;;;;;AAoBA,MAAMA,WAAWC,QAAQ,QAAQ;AAEjC,SAASC,iBACPC,IAOG;IAIH,IAAI;QACF,KAAK,MAAMC,QAAQD,KAAM;YACvB,MAAME,OAAOC,iCAAAA,CAAAA,UAAAA,CAAAA,IAAU,CAACF;YACxB,OAAOC;QACT;IACF,EAAE,OAAOE,GAAG,CAAC;IAEb,OAAO;AACT;AAEA,SAASC,mBACPJ,IAA4D;IAE5D,MAAMK,SAAS,GAAGC,iCAAAA,GAAGA,CAAC,MAAM,EAAEA,iCAAAA,GAAGA,GAAGN,OAAOM,iCAAAA,GAAGA,CAAC,WAAW,EAAEA,iCAAAA,GAAGA,CAAC,UAAU,CAAC;IAE3E,MAAMC,WAAW;QACfV,QAAQ,GAAG,CAAC,YAAY;QACxBA,QAAQ,GAAG,CAAC,YAAY;QACxBA,QAAQ,GAAG,CAAC,oBAAoB;KACjC,CAAC,MAAM,CAACW;IAET,KAAK,MAAMC,UAAUF,SAAU;QAC7B,MAAMG,SAASC,AAAAA,IAAAA,iCAAAA,IAAAA,AAAAA,EAAKF,QAASJ;QAC7B,IAAIO,AAAAA,IAAAA,+BAAAA,UAAAA,AAAAA,EAAWF,SACb,OAAOA;IAEX;IAEA,OAAO;AACT;AAEA,SAASG,kBACPb,IAI0B;IAE1B,MAAMK,SAAS,CAAC,cAAc,EAAEL,KAAK,oBAAoB,EAAEA,MAAM;IACjE,MAAMO,WAAW;QAAC;QAAIV,QAAQ,GAAG,CAAC,IAAI;K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,QAAQ,CAAC5B,WAAW;QACnD,MAAMwB,MAAMI,GAAG,CAAC5B,SAA6B;QAC7C,IAAIwB,KACF,OAAOA;IAEX;AACF;AAEA,SAASK;IACP,MAAMC,SAAST,YAAY,MAAM;IAEjC,IAAIrB,YAAYuB,OAAO,IAAI,CAACO,QAAQ,QAAQ,CAAC9B,WAAW;QACtD,MAAMwB,MAAMM,MAAM,CAAC9B,SAAgC;QACnD,IAAIwB,KACF,OAAOA;IAEX;AACF;AAEO,SAASO;IACd,MAAMjB,SAASQ;IACf,IAAIR,QACF,OAAOA;IAGT,MAAMY,OAAOD;IACb,IAAIC,MACF,OAAOA;IAGT,MAAME,MAAMD;IACZ,IAAIC,KACF,OAAOA;IAGT,MAAME,SAASD;IACf,IAAIC,QACF,OAAOA;IAGT,MAAME,QAAQ,IAAIC,MAAM;IACxBD,MAAM,IAAI,GAAG;IACb,MAAMA;AACR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"firefox-paths.d.ts","sourceRoot":"","sources":["../../src/browser-finder/firefox-paths.ts"],"names":[],"mappings":"AA8GA,wBAAgB,mBAAmB,IAAI,MAAM,CAmB5C"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
"use strict";
|
|
6
|
-
var __webpack_require__ = {};
|
|
7
|
-
(()=>{
|
|
8
|
-
__webpack_require__.n = (module)=>{
|
|
9
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
10
|
-
__webpack_require__.d(getter, {
|
|
11
|
-
a: getter
|
|
12
|
-
});
|
|
13
|
-
return getter;
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
(()=>{
|
|
17
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
18
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: definition[key]
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
(()=>{
|
|
25
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
-
})();
|
|
27
|
-
(()=>{
|
|
28
|
-
__webpack_require__.r = (exports1)=>{
|
|
29
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
-
value: 'Module'
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
-
value: true
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
})();
|
|
37
|
-
var __webpack_exports__ = {};
|
|
38
|
-
__webpack_require__.r(__webpack_exports__);
|
|
39
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
-
getAnyFirefoxStable: ()=>getAnyFirefoxStable
|
|
41
|
-
});
|
|
42
|
-
const external_fs_namespaceObject = require("fs");
|
|
43
|
-
const external_path_namespaceObject = require("path");
|
|
44
|
-
const external_which_namespaceObject = require("which");
|
|
45
|
-
var external_which_default = /*#__PURE__*/ __webpack_require__.n(external_which_namespaceObject);
|
|
46
|
-
const platform = process.platform;
|
|
47
|
-
function getFirefoxOnLinux(name) {
|
|
48
|
-
try {
|
|
49
|
-
const path = external_which_default().sync(name);
|
|
50
|
-
return path;
|
|
51
|
-
} catch (e) {}
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
function getFirefoxOnWindows(name) {
|
|
55
|
-
const suffix = `${external_path_namespaceObject.sep}${name}${external_path_namespaceObject.sep}firefox.exe`;
|
|
56
|
-
const prefixes = [
|
|
57
|
-
process.env.LOCALAPPDATA,
|
|
58
|
-
process.env.PROGRAMFILES,
|
|
59
|
-
process.env['PROGRAMFILES(X86)']
|
|
60
|
-
].filter(Boolean);
|
|
61
|
-
for (const prefix of prefixes){
|
|
62
|
-
const firefoxPath = (0, external_path_namespaceObject.join)(prefix, suffix);
|
|
63
|
-
if ((0, external_fs_namespaceObject.existsSync)(firefoxPath)) return firefoxPath;
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
function getFireFoxOnDarwin(name) {
|
|
68
|
-
const suffix = `/Applications/${name}.app/Contents/MacOS/firefox`;
|
|
69
|
-
const prefixes = [
|
|
70
|
-
'',
|
|
71
|
-
process.env.HOME
|
|
72
|
-
].filter((item)=>void 0 !== item);
|
|
73
|
-
for (const prefix of prefixes){
|
|
74
|
-
const firefoxPath = (0, external_path_namespaceObject.join)(prefix, suffix);
|
|
75
|
-
if ((0, external_fs_namespaceObject.existsSync)(firefoxPath)) return firefoxPath;
|
|
76
|
-
}
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
const firefoxPaths = {
|
|
80
|
-
firefox: {
|
|
81
|
-
linux: ()=>getFirefoxOnLinux('firefox'),
|
|
82
|
-
darwin: ()=>getFireFoxOnDarwin('Firefox'),
|
|
83
|
-
win32: ()=>getFirefoxOnWindows('Mozilla Firefox')
|
|
84
|
-
},
|
|
85
|
-
dev: {
|
|
86
|
-
darwin: ()=>getFireFoxOnDarwin('Firefox Developer Edition'),
|
|
87
|
-
win32: ()=>getFirefoxOnWindows('Firefox Developer Edition')
|
|
88
|
-
},
|
|
89
|
-
nightly: {
|
|
90
|
-
darwin: ()=>getFireFoxOnDarwin('Firefox Nightly'),
|
|
91
|
-
win32: ()=>getFirefoxOnWindows('Firefox Nightly')
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
function getFirefoxPath() {
|
|
95
|
-
const firefox = firefoxPaths.firefox;
|
|
96
|
-
if (platform && Object.keys(firefox).includes(platform)) {
|
|
97
|
-
const pth = firefox[platform]();
|
|
98
|
-
if (pth) return pth;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function getFirefoxDevPath() {
|
|
102
|
-
const dev = firefoxPaths.dev;
|
|
103
|
-
if (platform && Object.keys(dev).includes(platform)) {
|
|
104
|
-
const pth = dev[platform]();
|
|
105
|
-
if (pth) return pth;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function getFirefoxNightlyPath() {
|
|
109
|
-
const nightly = firefoxPaths.nightly;
|
|
110
|
-
if (platform && Object.keys(nightly).includes(platform)) {
|
|
111
|
-
const pth = nightly[platform]();
|
|
112
|
-
if (pth) return pth;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
function getAnyFirefoxStable() {
|
|
116
|
-
const firefox = getFirefoxPath();
|
|
117
|
-
if (firefox) return firefox;
|
|
118
|
-
const dev = getFirefoxDevPath();
|
|
119
|
-
if (dev) return dev;
|
|
120
|
-
const canary = getFirefoxNightlyPath();
|
|
121
|
-
if (canary) return canary;
|
|
122
|
-
const error = new Error('Unable to find any firefox browser.');
|
|
123
|
-
error.name = 'FirefoxPathsError';
|
|
124
|
-
throw error;
|
|
125
|
-
}
|
|
126
|
-
var __webpack_export_target__ = exports;
|
|
127
|
-
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
128
|
-
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
129
|
-
value: true
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
//# sourceMappingURL=firefox-paths.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser-finder/firefox-paths.js","sources":["webpack://@agent-infra/browser/./src/browser-finder/firefox-paths.ts"],"sourcesContent":["/**\n * The following code is modified based on\n * https://github.com/shirshak55/edge-paths/blob/master/index.ts\n *\n * MIT Licensed\n * Copyright (c) 2020 Shirshak\n * https://github.com/shirshak55/edge-paths/blob/master/LICENSE\n */\nimport { existsSync } from 'fs';\nimport { sep, join } from 'path';\nimport which from 'which';\n\nconst platform = process.platform;\n\nfunction getFirefoxOnLinux(name: 'firefox'): string | null {\n try {\n const path = which.sync(name);\n return path;\n } catch (e) {}\n\n return null;\n}\n\nfunction getFirefoxOnWindows(\n name: 'Mozilla Firefox' | 'Firefox Developer Edition' | 'Firefox Nightly',\n): string | null {\n const suffix = `${sep}${name}${sep}firefox.exe`;\n\n const prefixes = [\n process.env.LOCALAPPDATA,\n process.env.PROGRAMFILES,\n process.env['PROGRAMFILES(X86)'],\n ].filter(Boolean);\n\n for (const prefix of prefixes) {\n const firefoxPath = join(prefix!, suffix);\n if (existsSync(firefoxPath)) {\n return firefoxPath;\n }\n }\n\n return null;\n}\n\nfunction getFireFoxOnDarwin(\n name: 'Firefox' | 'Firefox Developer Edition' | 'Firefox Nightly',\n): string | null {\n const suffix = `/Applications/${name}.app/Contents/MacOS/firefox`;\n const prefixes = ['', process.env.HOME].filter((item) => item !== undefined);\n\n for (const prefix of prefixes) {\n const firefoxPath = join(prefix, suffix);\n if (existsSync(firefoxPath)) {\n return firefoxPath;\n }\n }\n\n return null;\n}\n\nconst firefoxPaths = {\n firefox: {\n linux: () => getFirefoxOnLinux('firefox'), // stable/beta/dev/nightly use same 'firefox' app name\n darwin: () => getFireFoxOnDarwin('Firefox'),\n win32: () => getFirefoxOnWindows('Mozilla Firefox'),\n },\n // beta and stable use same file path\n dev: {\n darwin: () => getFireFoxOnDarwin('Firefox Developer Edition'),\n win32: () => getFirefoxOnWindows('Firefox Developer Edition'),\n },\n nightly: {\n darwin: () => getFireFoxOnDarwin('Firefox Nightly'),\n win32: () => getFirefoxOnWindows('Firefox Nightly'),\n },\n};\n\nfunction getFirefoxPath() {\n const firefox = firefoxPaths.firefox;\n\n if (platform && Object.keys(firefox).includes(platform)) {\n const pth = firefox[platform as keyof typeof firefox]();\n if (pth) {\n return pth;\n }\n }\n}\n\nfunction getFirefoxDevPath() {\n const dev = firefoxPaths.dev;\n\n if (platform && Object.keys(dev).includes(platform)) {\n const pth = dev[platform as keyof typeof dev]();\n if (pth) {\n return pth;\n }\n }\n}\n\nfunction getFirefoxNightlyPath() {\n const nightly = firefoxPaths.nightly;\n\n if (platform && Object.keys(nightly).includes(platform)) {\n const pth = nightly[platform as keyof typeof nightly]();\n if (pth) {\n return pth;\n }\n }\n}\n\nexport function getAnyFirefoxStable(): string {\n const firefox = getFirefoxPath();\n if (firefox) {\n return firefox;\n }\n\n const dev = getFirefoxDevPath();\n if (dev) {\n return dev;\n }\n\n const canary = getFirefoxNightlyPath();\n if (canary) {\n return canary;\n }\n\n const error = new Error('Unable to find any firefox browser.');\n error.name = 'FirefoxPathsError';\n throw error;\n}\n"],"names":["platform","process","getFirefoxOnLinux","name","path","which","e","getFirefoxOnWindows","suffix","sep","prefixes","Boolean","prefix","firefoxPath","join","existsSync","getFireFoxOnDarwin","item","undefined","firefoxPaths","getFirefoxPath","firefox","Object","pth","getFirefoxDevPath","dev","getFirefoxNightlyPath","nightly","getAnyFirefoxStable","canary","error","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAMA,WAAWC,QAAQ,QAAQ;AAEjC,SAASC,kBAAkBC,IAAe;IACxC,IAAI;QACF,MAAMC,OAAOC,yBAAAA,IAAU,CAACF;QACxB,OAAOC;IACT,EAAE,OAAOE,GAAG,CAAC;IAEb,OAAO;AACT;AAEA,SAASC,oBACPJ,IAAyE;IAEzE,MAAMK,SAAS,GAAGC,8BAAAA,GAAGA,GAAGN,OAAOM,8BAAAA,GAAGA,CAAC,WAAW,CAAC;IAE/C,MAAMC,WAAW;QACfT,QAAQ,GAAG,CAAC,YAAY;QACxBA,QAAQ,GAAG,CAAC,YAAY;QACxBA,QAAQ,GAAG,CAAC,oBAAoB;KACjC,CAAC,MAAM,CAACU;IAET,KAAK,MAAMC,UAAUF,SAAU;QAC7B,MAAMG,cAAcC,AAAAA,IAAAA,8BAAAA,IAAAA,AAAAA,EAAKF,QAASJ;QAClC,IAAIO,AAAAA,IAAAA,4BAAAA,UAAAA,AAAAA,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AO,CAAC3B,SAAiC;QACrD,IAAIuB,KACF,OAAOA;IAEX;AACF;AAEO,SAASK;IACd,MAAMP,UAAUD;IAChB,IAAIC,SACF,OAAOA;IAGT,MAAMI,MAAMD;IACZ,IAAIC,KACF,OAAOA;IAGT,MAAMI,SAASH;IACf,IAAIG,QACF,OAAOA;IAGT,MAAMC,QAAQ,IAAIC,MAAM;IACxBD,MAAM,IAAI,GAAG;IACb,MAAMA;AACR"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE_which__ from "which";
|
|
8
|
-
const platform = process.platform;
|
|
9
|
-
function getFirefoxOnLinux(name) {
|
|
10
|
-
try {
|
|
11
|
-
const path = __WEBPACK_EXTERNAL_MODULE_which__["default"].sync(name);
|
|
12
|
-
return path;
|
|
13
|
-
} catch (e) {}
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
function getFirefoxOnWindows(name) {
|
|
17
|
-
const suffix = `${__WEBPACK_EXTERNAL_MODULE_path__.sep}${name}${__WEBPACK_EXTERNAL_MODULE_path__.sep}firefox.exe`;
|
|
18
|
-
const prefixes = [
|
|
19
|
-
process.env.LOCALAPPDATA,
|
|
20
|
-
process.env.PROGRAMFILES,
|
|
21
|
-
process.env['PROGRAMFILES(X86)']
|
|
22
|
-
].filter(Boolean);
|
|
23
|
-
for (const prefix of prefixes){
|
|
24
|
-
const firefoxPath = (0, __WEBPACK_EXTERNAL_MODULE_path__.join)(prefix, suffix);
|
|
25
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE_fs__.existsSync)(firefoxPath)) return firefoxPath;
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
function getFireFoxOnDarwin(name) {
|
|
30
|
-
const suffix = `/Applications/${name}.app/Contents/MacOS/firefox`;
|
|
31
|
-
const prefixes = [
|
|
32
|
-
'',
|
|
33
|
-
process.env.HOME
|
|
34
|
-
].filter((item)=>void 0 !== item);
|
|
35
|
-
for (const prefix of prefixes){
|
|
36
|
-
const firefoxPath = (0, __WEBPACK_EXTERNAL_MODULE_path__.join)(prefix, suffix);
|
|
37
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE_fs__.existsSync)(firefoxPath)) return firefoxPath;
|
|
38
|
-
}
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
const firefoxPaths = {
|
|
42
|
-
firefox: {
|
|
43
|
-
linux: ()=>getFirefoxOnLinux('firefox'),
|
|
44
|
-
darwin: ()=>getFireFoxOnDarwin('Firefox'),
|
|
45
|
-
win32: ()=>getFirefoxOnWindows('Mozilla Firefox')
|
|
46
|
-
},
|
|
47
|
-
dev: {
|
|
48
|
-
darwin: ()=>getFireFoxOnDarwin('Firefox Developer Edition'),
|
|
49
|
-
win32: ()=>getFirefoxOnWindows('Firefox Developer Edition')
|
|
50
|
-
},
|
|
51
|
-
nightly: {
|
|
52
|
-
darwin: ()=>getFireFoxOnDarwin('Firefox Nightly'),
|
|
53
|
-
win32: ()=>getFirefoxOnWindows('Firefox Nightly')
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
function getFirefoxPath() {
|
|
57
|
-
const firefox = firefoxPaths.firefox;
|
|
58
|
-
if (platform && Object.keys(firefox).includes(platform)) {
|
|
59
|
-
const pth = firefox[platform]();
|
|
60
|
-
if (pth) return pth;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function getFirefoxDevPath() {
|
|
64
|
-
const dev = firefoxPaths.dev;
|
|
65
|
-
if (platform && Object.keys(dev).includes(platform)) {
|
|
66
|
-
const pth = dev[platform]();
|
|
67
|
-
if (pth) return pth;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function getFirefoxNightlyPath() {
|
|
71
|
-
const nightly = firefoxPaths.nightly;
|
|
72
|
-
if (platform && Object.keys(nightly).includes(platform)) {
|
|
73
|
-
const pth = nightly[platform]();
|
|
74
|
-
if (pth) return pth;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function getAnyFirefoxStable() {
|
|
78
|
-
const firefox = getFirefoxPath();
|
|
79
|
-
if (firefox) return firefox;
|
|
80
|
-
const dev = getFirefoxDevPath();
|
|
81
|
-
if (dev) return dev;
|
|
82
|
-
const canary = getFirefoxNightlyPath();
|
|
83
|
-
if (canary) return canary;
|
|
84
|
-
const error = new Error('Unable to find any firefox browser.');
|
|
85
|
-
error.name = 'FirefoxPathsError';
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
export { getAnyFirefoxStable };
|
|
89
|
-
|
|
90
|
-
//# sourceMappingURL=firefox-paths.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser-finder/firefox-paths.mjs","sources":["webpack://@agent-infra/browser/./src/browser-finder/firefox-paths.ts"],"sourcesContent":["/**\n * The following code is modified based on\n * https://github.com/shirshak55/edge-paths/blob/master/index.ts\n *\n * MIT Licensed\n * Copyright (c) 2020 Shirshak\n * https://github.com/shirshak55/edge-paths/blob/master/LICENSE\n */\nimport { existsSync } from 'fs';\nimport { sep, join } from 'path';\nimport which from 'which';\n\nconst platform = process.platform;\n\nfunction getFirefoxOnLinux(name: 'firefox'): string | null {\n try {\n const path = which.sync(name);\n return path;\n } catch (e) {}\n\n return null;\n}\n\nfunction getFirefoxOnWindows(\n name: 'Mozilla Firefox' | 'Firefox Developer Edition' | 'Firefox Nightly',\n): string | null {\n const suffix = `${sep}${name}${sep}firefox.exe`;\n\n const prefixes = [\n process.env.LOCALAPPDATA,\n process.env.PROGRAMFILES,\n process.env['PROGRAMFILES(X86)'],\n ].filter(Boolean);\n\n for (const prefix of prefixes) {\n const firefoxPath = join(prefix!, suffix);\n if (existsSync(firefoxPath)) {\n return firefoxPath;\n }\n }\n\n return null;\n}\n\nfunction getFireFoxOnDarwin(\n name: 'Firefox' | 'Firefox Developer Edition' | 'Firefox Nightly',\n): string | null {\n const suffix = `/Applications/${name}.app/Contents/MacOS/firefox`;\n const prefixes = ['', process.env.HOME].filter((item) => item !== undefined);\n\n for (const prefix of prefixes) {\n const firefoxPath = join(prefix, suffix);\n if (existsSync(firefoxPath)) {\n return firefoxPath;\n }\n }\n\n return null;\n}\n\nconst firefoxPaths = {\n firefox: {\n linux: () => getFirefoxOnLinux('firefox'), // stable/beta/dev/nightly use same 'firefox' app name\n darwin: () => getFireFoxOnDarwin('Firefox'),\n win32: () => getFirefoxOnWindows('Mozilla Firefox'),\n },\n // beta and stable use same file path\n dev: {\n darwin: () => getFireFoxOnDarwin('Firefox Developer Edition'),\n win32: () => getFirefoxOnWindows('Firefox Developer Edition'),\n },\n nightly: {\n darwin: () => getFireFoxOnDarwin('Firefox Nightly'),\n win32: () => getFirefoxOnWindows('Firefox Nightly'),\n },\n};\n\nfunction getFirefoxPath() {\n const firefox = firefoxPaths.firefox;\n\n if (platform && Object.keys(firefox).includes(platform)) {\n const pth = firefox[platform as keyof typeof firefox]();\n if (pth) {\n return pth;\n }\n }\n}\n\nfunction getFirefoxDevPath() {\n const dev = firefoxPaths.dev;\n\n if (platform && Object.keys(dev).includes(platform)) {\n const pth = dev[platform as keyof typeof dev]();\n if (pth) {\n return pth;\n }\n }\n}\n\nfunction getFirefoxNightlyPath() {\n const nightly = firefoxPaths.nightly;\n\n if (platform && Object.keys(nightly).includes(platform)) {\n const pth = nightly[platform as keyof typeof nightly]();\n if (pth) {\n return pth;\n }\n }\n}\n\nexport function getAnyFirefoxStable(): string {\n const firefox = getFirefoxPath();\n if (firefox) {\n return firefox;\n }\n\n const dev = getFirefoxDevPath();\n if (dev) {\n return dev;\n }\n\n const canary = getFirefoxNightlyPath();\n if (canary) {\n return canary;\n }\n\n const error = new Error('Unable to find any firefox browser.');\n error.name = 'FirefoxPathsError';\n throw error;\n}\n"],"names":["platform","process","getFirefoxOnLinux","name","path","which","e","getFirefoxOnWindows","suffix","sep","prefixes","Boolean","prefix","firefoxPath","join","existsSync","getFireFoxOnDarwin","item","undefined","firefoxPaths","getFirefoxPath","firefox","Object","pth","getFirefoxDevPath","dev","getFirefoxNightlyPath","nightly","getAnyFirefoxStable","canary","error","Error"],"mappings":";;;;;;;AAYA,MAAMA,WAAWC,QAAQ,QAAQ;AAEjC,SAASC,kBAAkBC,IAAe;IACxC,IAAI;QACF,MAAMC,OAAOC,iCAAAA,CAAAA,UAAAA,CAAAA,IAAU,CAACF;QACxB,OAAOC;IACT,EAAE,OAAOE,GAAG,CAAC;IAEb,OAAO;AACT;AAEA,SAASC,oBACPJ,IAAyE;IAEzE,MAAMK,SAAS,GAAGC,iCAAAA,GAAGA,GAAGN,OAAOM,iCAAAA,GAAGA,CAAC,WAAW,CAAC;IAE/C,MAAMC,WAAW;QACfT,QAAQ,GAAG,CAAC,YAAY;QACxBA,QAAQ,GAAG,CAAC,YAAY;QACxBA,QAAQ,GAAG,CAAC,oBAAoB;KACjC,CAAC,MAAM,CAACU;IAET,KAAK,MAAMC,UAAUF,SAAU;QAC7B,MAAMG,cAAcC,AAAAA,IAAAA,iCAAAA,IAAAA,AAAAA,EAAKF,QAASJ;QAClC,IAAIO,AAAAA,IAAAA,+BAAAA,UAAAA,AAAAA,EAAWF,cACb,OAAOA;IAEX;IAEA,OAAO;AACT;AAEA,SAASG,mBACPb,IAAiE;IAEjE,MAAMK,SAAS,CAAC,cAAc,EAAEL,KAAK,2BAA2B,CAAC;IACjE,MAAMO,WAAW;QAAC;QAAIT,QAAQ,GAAG,CAAC,IAAI;KAAC,CAAC,MAAM,CAAC,CAACgB,OAASA,AAASC,KAAAA,MAATD;IAEzD,KAAK,MAAML,UAAUF,SAAU;QAC7B,MAAMG,cAAcC,AAAAA,IAAAA,iCA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
-
import { Logger } from '@agent-infra/logger';
|
|
2
|
-
import { BrowserType } from '../types';
|
|
3
|
-
export declare class BrowserFinder {
|
|
4
|
-
private logger;
|
|
5
|
-
constructor(logger?: Logger);
|
|
6
|
-
findBrowser(name?: BrowserType): {
|
|
7
|
-
path: string;
|
|
8
|
-
type: BrowserType;
|
|
9
|
-
};
|
|
10
|
-
private findChrome;
|
|
11
|
-
private findEdge;
|
|
12
|
-
private findFirefox;
|
|
13
|
-
private findAnyBrowser;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser-finder/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAiB,MAAM,qBAAqB,CAAC;AAM5D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,CAAC,EAAE,MAAM;IAIpB,WAAW,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAE;IA2C3E,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,cAAc;CAgCvB"}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
"use strict";
|
|
6
|
-
var __webpack_require__ = {};
|
|
7
|
-
(()=>{
|
|
8
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
9
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: definition[key]
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
(()=>{
|
|
16
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
-
})();
|
|
18
|
-
(()=>{
|
|
19
|
-
__webpack_require__.r = (exports1)=>{
|
|
20
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
-
value: 'Module'
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
-
value: true
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
})();
|
|
28
|
-
var __webpack_exports__ = {};
|
|
29
|
-
__webpack_require__.r(__webpack_exports__);
|
|
30
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
BrowserFinder: ()=>BrowserFinder
|
|
32
|
-
});
|
|
33
|
-
const logger_namespaceObject = require("@agent-infra/logger");
|
|
34
|
-
const external_edge_paths_namespaceObject = require("edge-paths");
|
|
35
|
-
const external_chrome_paths_js_namespaceObject = require("./chrome-paths.js");
|
|
36
|
-
const external_firefox_paths_js_namespaceObject = require("./firefox-paths.js");
|
|
37
|
-
function _define_property(obj, key, value) {
|
|
38
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
39
|
-
value: value,
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true,
|
|
42
|
-
writable: true
|
|
43
|
-
});
|
|
44
|
-
else obj[key] = value;
|
|
45
|
-
return obj;
|
|
46
|
-
}
|
|
47
|
-
class BrowserFinder {
|
|
48
|
-
findBrowser(name) {
|
|
49
|
-
const platform = process.platform;
|
|
50
|
-
let browserPath;
|
|
51
|
-
let browserType;
|
|
52
|
-
this.logger.info('Find browser on platform:', platform);
|
|
53
|
-
if (![
|
|
54
|
-
'darwin',
|
|
55
|
-
'win32',
|
|
56
|
-
'linux'
|
|
57
|
-
].includes(platform)) {
|
|
58
|
-
const error = new Error(`Unsupported platform: ${platform}`);
|
|
59
|
-
this.logger.error(error.message);
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
switch(name){
|
|
63
|
-
case 'chrome':
|
|
64
|
-
browserPath = this.findChrome();
|
|
65
|
-
browserType = 'chrome';
|
|
66
|
-
break;
|
|
67
|
-
case 'edge':
|
|
68
|
-
browserPath = this.findEdge();
|
|
69
|
-
browserType = 'edge';
|
|
70
|
-
break;
|
|
71
|
-
case 'firefox':
|
|
72
|
-
browserPath = this.findFirefox();
|
|
73
|
-
browserType = 'firefox';
|
|
74
|
-
break;
|
|
75
|
-
default:
|
|
76
|
-
const value = this.findAnyBrowser();
|
|
77
|
-
browserPath = value.path;
|
|
78
|
-
browserType = value.type;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
this.logger.info('browserPath:', browserPath);
|
|
82
|
-
return {
|
|
83
|
-
path: browserPath,
|
|
84
|
-
type: browserType
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
findChrome() {
|
|
88
|
-
try {
|
|
89
|
-
return (0, external_chrome_paths_js_namespaceObject.getAnyChromeStable)();
|
|
90
|
-
} catch (e) {
|
|
91
|
-
this.logger.error('Find Chrome Error:', e);
|
|
92
|
-
throw e;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
findEdge() {
|
|
96
|
-
try {
|
|
97
|
-
return (0, external_edge_paths_namespaceObject.getAnyEdgeStable)();
|
|
98
|
-
} catch (e) {
|
|
99
|
-
this.logger.error('Find Edge Error:', e);
|
|
100
|
-
throw e;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
findFirefox() {
|
|
104
|
-
try {
|
|
105
|
-
return (0, external_firefox_paths_js_namespaceObject.getAnyFirefoxStable)();
|
|
106
|
-
} catch (e) {
|
|
107
|
-
this.logger.error('Find Firefox Error:', e);
|
|
108
|
-
throw e;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
findAnyBrowser() {
|
|
112
|
-
try {
|
|
113
|
-
return {
|
|
114
|
-
path: (0, external_chrome_paths_js_namespaceObject.getAnyChromeStable)(),
|
|
115
|
-
type: 'chrome'
|
|
116
|
-
};
|
|
117
|
-
} catch (e) {
|
|
118
|
-
this.logger.warn('Find Chrome Error:', e);
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
return {
|
|
122
|
-
path: (0, external_edge_paths_namespaceObject.getAnyEdgeStable)(),
|
|
123
|
-
type: 'edge'
|
|
124
|
-
};
|
|
125
|
-
} catch (e) {
|
|
126
|
-
this.logger.warn('Find Edge Error:', e);
|
|
127
|
-
}
|
|
128
|
-
try {
|
|
129
|
-
return {
|
|
130
|
-
path: (0, external_firefox_paths_js_namespaceObject.getAnyFirefoxStable)(),
|
|
131
|
-
type: 'firefox'
|
|
132
|
-
};
|
|
133
|
-
} catch (e) {
|
|
134
|
-
this.logger.warn('Find Firefox Error:', e);
|
|
135
|
-
}
|
|
136
|
-
const error = new Error('Unable to find any browser.');
|
|
137
|
-
error.name = 'BrowserPathsError';
|
|
138
|
-
throw error;
|
|
139
|
-
}
|
|
140
|
-
constructor(logger){
|
|
141
|
-
_define_property(this, "logger", void 0);
|
|
142
|
-
this.logger = logger ?? logger_namespaceObject.defaultLogger;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
var __webpack_export_target__ = exports;
|
|
146
|
-
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
147
|
-
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
148
|
-
value: true
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser-finder/index.js","sources":["webpack://@agent-infra/browser/./src/browser-finder/index.ts"],"sourcesContent":["/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { Logger, defaultLogger } from '@agent-infra/logger';\n\nimport { getAnyEdgeStable } from 'edge-paths';\nimport { getAnyChromeStable } from './chrome-paths';\nimport { getAnyFirefoxStable } from './firefox-paths';\n\nimport { BrowserType } from '../types';\n\nexport class BrowserFinder {\n private logger: Logger;\n\n constructor(logger?: Logger) {\n this.logger = logger ?? defaultLogger;\n }\n\n public findBrowser(name?: BrowserType): { path: string; type: BrowserType } {\n const platform = process.platform;\n let browserPath: string;\n let browserType: BrowserType;\n\n this.logger.info('Find browser on platform:', platform);\n\n if (!['darwin', 'win32', 'linux'].includes(platform)) {\n const error = new Error(`Unsupported platform: ${platform}`);\n this.logger.error(error.message);\n throw error;\n }\n\n switch (name) {\n case 'chrome':\n browserPath = this.findChrome();\n browserType = 'chrome';\n break;\n case 'edge':\n // https://learn.microsoft.com/en-us/microsoft-edge/puppeteer/\n browserPath = this.findEdge();\n browserType = 'edge';\n break;\n case 'firefox':\n // https://pptr.dev/webdriver-bidi/#automate-with-chrome-and-firefox\n browserPath = this.findFirefox();\n browserType = 'firefox';\n break;\n default:\n const value = this.findAnyBrowser();\n browserPath = value.path;\n browserType = value.type;\n break;\n }\n\n this.logger.info('browserPath:', browserPath);\n\n return {\n path: browserPath,\n type: browserType,\n };\n }\n\n private findChrome(): string {\n try {\n return getAnyChromeStable();\n } catch (e) {\n this.logger.error('Find Chrome Error:', e);\n throw e;\n }\n }\n\n private findEdge(): string {\n try {\n return getAnyEdgeStable();\n } catch (e) {\n this.logger.error('Find Edge Error:', e);\n throw e;\n }\n }\n\n private findFirefox(): string {\n try {\n return getAnyFirefoxStable();\n } catch (e) {\n this.logger.error('Find Firefox Error:', e);\n throw e;\n }\n }\n\n private findAnyBrowser(): { path: string; type: BrowserType } {\n try {\n return {\n path: getAnyChromeStable(),\n type: 'chrome',\n };\n } catch (e) {\n this.logger.warn('Find Chrome Error:', e);\n }\n\n try {\n return {\n path: getAnyEdgeStable(),\n type: 'edge',\n };\n } catch (e) {\n this.logger.warn('Find Edge Error:', e);\n }\n\n try {\n return {\n path: getAnyFirefoxStable(),\n type: 'firefox',\n };\n } catch (e) {\n this.logger.warn('Find Firefox Error:', e);\n }\n\n const error = new Error('Unable to find any browser.');\n error.name = 'BrowserPathsError';\n throw error;\n }\n}\n"],"names":["BrowserFinder","name","platform","process","browserPath","browserType","error","Error","value","getAnyChromeStable","e","getAnyEdgeStable","getAnyFirefoxStable","logger","defaultLogger"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGC;;;;;;;;;;AASM,MAAMA;IAOJ,YAAYC,IAAkB,EAAuC;QAC1E,MAAMC,WAAWC,QAAQ,QAAQ;QACjC,IAAIC;QACJ,IAAIC;QAEJ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6BH;QAE9C,IAAI,CAAC;YAAC;YAAU;YAAS;SAAQ,CAAC,QAAQ,CAACA,WAAW;YACpD,MAAMI,QAAQ,IAAIC,MAAM,CAAC,sBAAsB,EAAEL,UAAU;YAC3D,IAAI,CAAC,MAAM,CAAC,KAAK,CAACI,MAAM,OAAO;YAC/B,MAAMA;QACR;QAEA,OAAQL;YACN,KAAK;gBACHG,cAAc,IAAI,CAAC,UAAU;gBAC7BC,cAAc;gBACd;YACF,KAAK;gBAEHD,cAAc,IAAI,CAAC,QAAQ;gBAC3BC,cAAc;gBACd;YACF,KAAK;gBAEHD,cAAc,IAAI,CAAC,WAAW;gBAC9BC,cAAc;gBACd;YACF;gBACE,MAAMG,QAAQ,IAAI,CAAC,cAAc;gBACjCJ,cAAcI,MAAM,IAAI;gBACxBH,cAAcG,MAAM,IAAI;gBACxB;QACJ;QAEA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgBJ;QAEjC,OAAO;YACL,MAAMA;YACN,MAAMC;QACR;IACF;IAEQ,aAAqB;QAC3B,IAAI;YACF,OAAOI,AAAAA,IAAAA,yCAAAA,kBAAAA,AAAAA;QACT,EAAE,OAAOC,GAAG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