@agent-infra/browser-finder 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/README.md ADDED
@@ -0,0 +1,181 @@
1
+ # Browser Finder
2
+
3
+ A cross-platform browser path finder that helps you locate installed browsers on Windows, macOS, and Linux.
4
+
5
+ ## Features
6
+
7
+ - 🔍 **Cross-platform support** - Works on Windows, macOS, and Linux
8
+ - 🌐 **Multiple browsers** - Supports Chrome, Edge, and Firefox
9
+ - 🔄 **Automatic fallback** - Finds any available browser when specific one isn't found
10
+ - 📝 **Built-in logging** - Comprehensive logging with customizable logger
11
+ - ⚡ **Fast detection** - Optimized for quick browser detection without expensive operations
12
+ - 🛡️ **Type-safe** - Written in TypeScript with full type definitions
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @agent-infra/browser-finder
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ### Basic Usage
23
+
24
+ ```typescript
25
+ import { BrowserFinder } from '@agent-infra/browser-finder';
26
+
27
+ const finder = new BrowserFinder();
28
+
29
+ // Find any available browser (tries Chrome -> Edge -> Firefox)
30
+ const browser = finder.findBrowser();
31
+ console.log(browser.path); // "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
32
+ console.log(browser.type); // "chrome"
33
+ ```
34
+
35
+ ### Find Specific Browser
36
+
37
+ ```typescript
38
+ import { BrowserFinder } from '@agent-infra/browser-finder';
39
+
40
+ const finder = new BrowserFinder();
41
+
42
+ // Find Chrome specifically
43
+ const chrome = finder.findBrowser('chrome');
44
+
45
+ // Find Edge specifically
46
+ const edge = finder.findBrowser('edge');
47
+
48
+ // Find Firefox specifically
49
+ const firefox = finder.findBrowser('firefox');
50
+ ```
51
+
52
+ ### Custom Logger
53
+
54
+ ```typescript
55
+ import { BrowserFinder } from '@agent-infra/browser-finder';
56
+
57
+ const customLogger = {
58
+ info: (msg: string, ...args: any[]) => console.log(`INFO: \${msg}`, ...args),
59
+ warn: (msg: string, ...args: any[]) => console.warn(`WARN: \${msg}`, ...args),
60
+ error: (msg: string, ...args: any[]) => console.error(`ERROR: \${msg}`, ...args),
61
+ // ... other logger methods
62
+ };
63
+
64
+ const finder = new BrowserFinder(customLogger);
65
+ const browser = finder.findBrowser();
66
+ ```
67
+
68
+ ## API Reference
69
+
70
+ ### BrowserFinder
71
+
72
+ #### Constructor
73
+
74
+ `new BrowserFinder(logger?: Logger)`
75
+
76
+ - `logger` (optional): Custom logger instance. If not provided, uses the default logger.
77
+
78
+ #### Methods
79
+
80
+ ##### findBrowser(name?: BrowserType)
81
+
82
+ Finds a browser and returns its path and type.
83
+
84
+ **Parameters:**
85
+ - `name` (optional): Specific browser to find (`'chrome'` | `'edge'` | `'firefox'`)
86
+
87
+ **Returns:**
88
+ ```typescript
89
+ {
90
+ path: string; // Full path to browser executable
91
+ type: BrowserType; // Browser type ('chrome' | 'edge' | 'firefox')
92
+ }
93
+ ```
94
+
95
+ **Examples:**
96
+ ```typescript
97
+ // Find any browser (automatic fallback)
98
+ const anyBrowser = finder.findBrowser();
99
+
100
+ // Find specific browser
101
+ const chrome = finder.findBrowser('chrome');
102
+ const edge = finder.findBrowser('edge');
103
+ const firefox = finder.findBrowser('firefox');
104
+ ```
105
+
106
+ ## Supported Browsers
107
+
108
+ ### Chrome
109
+ - **Windows**: Chrome, Chrome Beta, Chrome Dev, Chrome Canary
110
+ - **macOS**: Google Chrome, Google Chrome Beta, Google Chrome Dev, Google Chrome Canary
111
+ - **Linux**: google-chrome-stable, google-chrome, google-chrome-beta, google-chrome-dev, chromium-browser, chromium
112
+
113
+ ### Edge
114
+ - **Windows**: Edge, Edge Beta, Edge Dev, Edge Canary
115
+ - **macOS**: Edge, Edge Beta, Edge Dev, Edge Canary
116
+ - **Linux**: microsoft-edge-stable, microsoft-edge-beta, microsoft-edge-dev
117
+
118
+ ### Firefox
119
+ - **Windows**: Mozilla Firefox, Firefox Developer Edition, Firefox Nightly
120
+ - **macOS**: Firefox, Firefox Developer Edition, Firefox Nightly
121
+ - **Linux**: firefox (all editions use same binary name)
122
+
123
+ ## Error Handling
124
+
125
+ The library throws descriptive errors when browsers cannot be found:
126
+
127
+ ```typescript
128
+ try {
129
+ const browser = finder.findBrowser('chrome');
130
+ } catch (error) {
131
+ if (error.name === 'ChromePathsError') {
132
+ console.log('Chrome not found on this system');
133
+ }
134
+ }
135
+ ```
136
+
137
+ ### Error Types
138
+
139
+ - `ChromePathsError` - Chrome browser not found
140
+ - `EdgePathsError` - Edge browser not found (from edge-paths package)
141
+ - `FirefoxPathsError` - Firefox browser not found
142
+ - `BrowserPathsError` - No browser found when using automatic detection
143
+
144
+ ## Platform Support
145
+
146
+ - **Windows** (win32) - ✅ Supported
147
+ - **macOS** (darwin) - ✅ Supported
148
+ - **Linux** - ✅ Supported
149
+ - Other platforms - ❌ Will throw "Unsupported platform" error
150
+
151
+ ## Performance Notes
152
+
153
+ This library is optimized for fast browser detection:
154
+
155
+ - **macOS**: Avoids expensive `lsregister -dump` operations used by some other libraries
156
+ - **Linux**: Uses `which` command for quick binary lookup
157
+ - **Windows**: Efficiently checks common installation directories
158
+
159
+ ## Dependencies
160
+
161
+ - `which` - Cross-platform executable finder
162
+ - `edge-paths` - Edge browser path detection
163
+ - `@agent-infra/logger` - Logging functionality
164
+
165
+ ## License
166
+
167
+ Apache-2.0
168
+
169
+ ## Contributing
170
+
171
+ Contributions are welcome! Please feel free to submit a Pull Request.
172
+
173
+ ## Related Projects
174
+
175
+ - [edge-paths](https://github.com/shirshak55/edge-paths) - Edge browser path finder
176
+ - [chrome-finder](https://github.com/gwuhaolin/chrome-finder) - Alternative Chrome finder
177
+ - [find-chrome-bin](https://github.com/mbalabash/find-chrome-bin) - Another Chrome finder
178
+
179
+ ## Changelog
180
+
181
+ See [CHANGELOG.md](./CHANGELOG.md) for release history.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/shirshak55/edge-paths/blob/master/index.ts
4
+ *
5
+ * MIT Licensed
6
+ * Copyright (c) 2020 Shirshak
7
+ * https://github.com/shirshak55/edge-paths/blob/master/LICENSE
8
+ */
9
+ export declare function getAnyChromeStable(): string;
10
+ //# sourceMappingURL=chrome-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome-paths.d.ts","sourceRoot":"","sources":["../src/chrome-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiJH,wBAAgB,kBAAkB,IAAI,MAAM,CAwB3C"}
@@ -0,0 +1,162 @@
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
+ getAnyChromeStable: ()=>getAnyChromeStable
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 getChromeOnLinux(list) {
48
+ try {
49
+ for (const name of list){
50
+ const path = external_which_default().sync(name);
51
+ return path;
52
+ }
53
+ } catch (e) {}
54
+ return null;
55
+ }
56
+ function getChromeOnWindows(name) {
57
+ const suffix = `${external_path_namespaceObject.sep}Google${external_path_namespaceObject.sep}${name}${external_path_namespaceObject.sep}Application${external_path_namespaceObject.sep}chrome.exe`;
58
+ const prefixes = [
59
+ process.env.LOCALAPPDATA,
60
+ process.env.PROGRAMFILES,
61
+ process.env['PROGRAMFILES(X86)']
62
+ ].filter(Boolean);
63
+ for (const prefix of prefixes){
64
+ const chrome = (0, external_path_namespaceObject.join)(prefix, suffix);
65
+ if ((0, external_fs_namespaceObject.existsSync)(chrome)) return chrome;
66
+ }
67
+ return null;
68
+ }
69
+ function getChromeOnDarwin(name) {
70
+ const suffix = `/Applications/${name}.app/Contents/MacOS/${name}`;
71
+ const prefixes = [
72
+ '',
73
+ process.env.HOME
74
+ ].filter((item)=>void 0 !== item);
75
+ for (const prefix of prefixes){
76
+ const chromePath = (0, external_path_namespaceObject.join)(prefix, suffix);
77
+ if ((0, external_fs_namespaceObject.existsSync)(chromePath)) return chromePath;
78
+ }
79
+ return null;
80
+ }
81
+ const chromePaths = {
82
+ chrome: {
83
+ linux: ()=>getChromeOnLinux([
84
+ 'google-chrome-stable',
85
+ 'google-chrome'
86
+ ]),
87
+ darwin: ()=>getChromeOnDarwin('Google Chrome'),
88
+ win32: ()=>getChromeOnWindows('Chrome')
89
+ },
90
+ beta: {
91
+ linux: ()=>getChromeOnLinux([
92
+ 'google-chrome-beta'
93
+ ]),
94
+ darwin: ()=>getChromeOnDarwin('Google Chrome Beta'),
95
+ win32: ()=>getChromeOnWindows('Chrome Beta')
96
+ },
97
+ dev: {
98
+ linux: ()=>getChromeOnLinux([
99
+ 'google-chrome-dev'
100
+ ]),
101
+ darwin: ()=>getChromeOnDarwin('Google Chrome Dev'),
102
+ win32: ()=>getChromeOnWindows('Chrome Dev')
103
+ },
104
+ canary: {
105
+ linux: ()=>getChromeOnLinux([
106
+ 'chromium-browser',
107
+ 'chromium'
108
+ ]),
109
+ darwin: ()=>getChromeOnDarwin('Google Chrome Canary'),
110
+ win32: ()=>getChromeOnWindows('Chrome SxS')
111
+ }
112
+ };
113
+ function getChromePath() {
114
+ const chrome = chromePaths.chrome;
115
+ if (platform && Object.keys(chrome).includes(platform)) {
116
+ const pth = chrome[platform]();
117
+ if (pth) return pth;
118
+ }
119
+ }
120
+ function getChromeBetaPath() {
121
+ const beta = chromePaths.beta;
122
+ if (platform && Object.keys(beta).includes(platform)) {
123
+ const pth = beta[platform]();
124
+ if (pth) return pth;
125
+ }
126
+ }
127
+ function getChromeDevPath() {
128
+ const dev = chromePaths.dev;
129
+ if (platform && Object.keys(dev).includes(platform)) {
130
+ const pth = dev[platform]();
131
+ if (pth) return pth;
132
+ }
133
+ }
134
+ function getChromeCanaryPath() {
135
+ const canary = chromePaths.canary;
136
+ if (platform && Object.keys(canary).includes(platform)) {
137
+ const pth = canary[platform]();
138
+ if (pth) return pth;
139
+ }
140
+ }
141
+ function getAnyChromeStable() {
142
+ const chrome = getChromePath();
143
+ if (chrome) return chrome;
144
+ const beta = getChromeBetaPath();
145
+ if (beta) return beta;
146
+ const dev = getChromeDevPath();
147
+ if (dev) return dev;
148
+ const canary = getChromeCanaryPath();
149
+ if (canary) return canary;
150
+ const error = new Error('Unable to find any chrome browser.');
151
+ error.name = 'ChromePathsError';
152
+ throw error;
153
+ }
154
+ exports.getAnyChromeStable = __webpack_exports__.getAnyChromeStable;
155
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
156
+ "getAnyChromeStable"
157
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
158
+ Object.defineProperty(exports, '__esModule', {
159
+ value: true
160
+ });
161
+
162
+ //# sourceMappingURL=chrome-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome-paths.js","sources":["webpack://@agent-infra/browser-finder/webpack/runtime/compat_get_default_export","webpack://@agent-infra/browser-finder/webpack/runtime/define_property_getters","webpack://@agent-infra/browser-finder/webpack/runtime/has_own_property","webpack://@agent-infra/browser-finder/webpack/runtime/make_namespace_object","webpack://@agent-infra/browser-finder/./src/chrome-paths.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\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":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","platform","process","getChromeOnLinux","list","name","path","which","e","getChromeOnWindows","suffix","sep","prefixes","Boolean","prefix","chrome","join","existsSync","getChromeOnDarwin","item","undefined","chromePath","chromePaths","getChromePath","pth","getChromeBetaPath","beta","getChromeDevPath","dev","getChromeCanaryPath","canary","getAnyChromeStable","error","Error"],"mappings":";;;;;;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C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IAAI;IAE7B,IAAIrB,YAAYJ,OAAO,IAAI,CAAC6B,MAAM,QAAQ,CAACzB,WAAW;QACpD,MAAMuB,MAAME,IAAI,CAACzB,SAA8B;QAC/C,IAAIuB,KACF,OAAOA;IAEX;AACF;AAEA,SAASG;IACP,MAAMC,MAAMN,YAAY,GAAG;IAE3B,IAAIrB,YAAYJ,OAAO,IAAI,CAAC+B,KAAK,QAAQ,CAAC3B,WAAW;QACnD,MAAMuB,MAAMI,GAAG,CAAC3B,SAA6B;QAC7C,IAAIuB,KACF,OAAOA;IAEX;AACF;AAEA,SAASK;IACP,MAAMC,SAASR,YAAY,MAAM;IAEjC,IAAIrB,YAAYJ,OAAO,IAAI,CAACiC,QAAQ,QAAQ,CAAC7B,WAAW;QACtD,MAAMuB,MAAMM,MAAM,CAAC7B,SAAgC;QACnD,IAAIuB,KACF,OAAOA;IAEX;AACF;AAEO,SAASO;IACd,MAAMhB,SAASQ;IACf,IAAIR,QACF,OAAOA;IAGT,MAAMW,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"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { existsSync } from "fs";
6
+ import { join, sep } from "path";
7
+ import which from "which";
8
+ const platform = process.platform;
9
+ function getChromeOnLinux(list) {
10
+ try {
11
+ for (const name of list){
12
+ const path = which.sync(name);
13
+ return path;
14
+ }
15
+ } catch (e) {}
16
+ return null;
17
+ }
18
+ function getChromeOnWindows(name) {
19
+ const suffix = `${sep}Google${sep}${name}${sep}Application${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 = join(prefix, suffix);
27
+ if (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 = join(prefix, suffix);
39
+ if (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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome-paths.mjs","sources":["webpack://@agent-infra/browser-finder/./src/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,MAAM,IAAI,CAACF;YACxB,OAAOC;QACT;IACF,EAAE,OAAOE,GAAG,CAAC;IAEb,OAAO;AACT;AAEA,SAASC,mBACPJ,IAA4D;IAE5D,MAAMK,SAAS,GAA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YuB,OAAO,IAAI,CAACT,QAAQ,QAAQ,CAACd,WAAW;QACtD,MAAMwB,MAAMV,MAAM,CAACd,SAAgC;QACnD,IAAIwB,KACF,OAAOA;IAEX;AACF;AAEA,SAASC;IACP,MAAMC,OAAOL,YAAY,IAAI;IAE7B,IAAIrB,YAAYuB,OAAO,IAAI,CAACG,MAAM,QAAQ,CAAC1B,WAAW;QACpD,MAAMwB,MAAME,IAAI,CAAC1B,SAA8B;QAC/C,IAAIwB,KACF,OAAOA;IAEX;AACF;AAEA,SAASG;IACP,MAAMC,MAAMP,YAAY,GAAG;IAE3B,IAAIrB,YAAYuB,OAAO,IAAI,CAACK,KAAK,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"}
@@ -0,0 +1,2 @@
1
+ export declare function getAnyFirefoxStable(): string;
2
+ //# sourceMappingURL=firefox-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firefox-paths.d.ts","sourceRoot":"","sources":["../src/firefox-paths.ts"],"names":[],"mappings":"AA8GA,wBAAgB,mBAAmB,IAAI,MAAM,CAmB5C"}
@@ -0,0 +1,134 @@
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
+ exports.getAnyFirefoxStable = __webpack_exports__.getAnyFirefoxStable;
127
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
128
+ "getAnyFirefoxStable"
129
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
130
+ Object.defineProperty(exports, '__esModule', {
131
+ value: true
132
+ });
133
+
134
+ //# sourceMappingURL=firefox-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firefox-paths.js","sources":["webpack://@agent-infra/browser-finder/webpack/runtime/compat_get_default_export","webpack://@agent-infra/browser-finder/webpack/runtime/define_property_getters","webpack://@agent-infra/browser-finder/webpack/runtime/has_own_property","webpack://@agent-infra/browser-finder/webpack/runtime/make_namespace_object","webpack://@agent-infra/browser-finder/./src/firefox-paths.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\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":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","platform","process","getFirefoxOnLinux","name","path","which","e","getFirefoxOnWindows","suffix","sep","prefixes","Boolean","prefix","firefoxPath","join","existsSync","getFireFoxOnDarwin","item","undefined","firefoxPaths","getFirefoxPath","firefox","pth","getFirefoxDevPath","dev","getFirefoxNightlyPath","nightly","getAnyFirefoxStable","canary","error","Error"],"mappings":";;;;;;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;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,90 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { existsSync } from "fs";
6
+ import { join, sep } from "path";
7
+ import which from "which";
8
+ const platform = process.platform;
9
+ function getFirefoxOnLinux(name) {
10
+ try {
11
+ const path = which.sync(name);
12
+ return path;
13
+ } catch (e) {}
14
+ return null;
15
+ }
16
+ function getFirefoxOnWindows(name) {
17
+ const suffix = `${sep}${name}${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 = join(prefix, suffix);
25
+ if (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 = join(prefix, suffix);
37
+ if (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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firefox-paths.mjs","sources":["webpack://@agent-infra/browser-finder/./src/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,MAAM,IAAI,CAACF;QACxB,OAAOC;IACT,EAAE,OAAOE,GAAG,CAAC;IAEb,OAAO;AACT;AAEA,SAASC,oBACPJ,IAAyE;IAEzE,MAAMK,SAAS,GAAGC,MAAMN,OAAOM,IAAI,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,KAAKF,QAASJ;QAClC,IAAIO,WAAWF,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,WAATD;IAEzD,KAAK,MAAML,UAAUF,SAAU;QAC7B,MAAMG,cAAcC,KAAKF,QAAQJ;QACjC,IAAIO,WAAWF,cACb,OAAOA;IAEX;IAEA,OAAO;AACT;AAEA,MAAMM,eAAe;IACnB,SAAS;QACP,OAAO,IAAMjB,kBAAkB;QAC/B,QAAQ,IAAMc,mBAAmB;QACjC,OAAO,IAAMT,oBAAoB;IACnC;IAEA,KAAK;QACH,QAAQ,IAAMS,mBAAmB;QACjC,OAAO,IAAMT,oBAAoB;IACnC;IACA,SAAS;QACP,QAAQ,IAAMS,mBAAmB;QACjC,OAAO,IAAMT,oBAAoB;IACnC;AACF;AAEA,SAASa;IACP,MAAMC,UAAUF,aAAa,OAAO;IAEpC,IAAInB,YAAYsB,OAAO,IAAI,CAACD,SAAS,QAAQ,CAACrB,WAAW;QACvD,MAAMuB,MAAMF,OAAO,CAACrB,SAAiC;QACrD,IAAIuB,KACF,OAAOA;IAEX;AACF;AAEA,SAASC;IACP,MAAMC,MAAMN,aAAa,GAAG;IAE5B,IAAInB,YAAYsB,OAAO,IAAI,CAACG,KAAK,QAAQ,CAACzB,WAAW;QACnD,MAAMuB,MAAME,GAAG,CAACzB,SAA6B;QAC7C,IAAIuB,KACF,OAAOA;IAEX;AACF;AAEA,SAASG;IACP,MAAMC,UAAUR,aAAa,OAAO;IAEpC,IAAInB,YAAYsB,OAAO,IAAI,CAACK,SAAS,QAAQ,CAAC3B,WAAW;QACvD,MAAMuB,MAAMI,OAAO,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"}
@@ -0,0 +1,16 @@
1
+ import { Logger } from '@agent-infra/logger';
2
+ import { BrowserType } from './types';
3
+ export type { BrowserType };
4
+ export declare class BrowserFinder {
5
+ private logger;
6
+ constructor(logger?: Logger);
7
+ findBrowser(name?: BrowserType): {
8
+ path: string;
9
+ type: BrowserType;
10
+ };
11
+ private findChrome;
12
+ private findEdge;
13
+ private findFirefox;
14
+ private findAnyBrowser;
15
+ }
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAiB,MAAM,qBAAqB,CAAC;AAM5D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,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"}
package/dist/index.js ADDED
@@ -0,0 +1,153 @@
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
+ exports.BrowserFinder = __webpack_exports__.BrowserFinder;
146
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
147
+ "BrowserFinder"
148
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
149
+ Object.defineProperty(exports, '__esModule', {
150
+ value: true
151
+ });
152
+
153
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["webpack://@agent-infra/browser-finder/webpack/runtime/define_property_getters","webpack://@agent-infra/browser-finder/webpack/runtime/has_own_property","webpack://@agent-infra/browser-finder/webpack/runtime/make_namespace_object","webpack://@agent-infra/browser-finder/./src/index.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\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 type { BrowserType };\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":["__webpack_require__","definition","key","Object","obj","prop","Symbol","BrowserFinder","name","platform","process","browserPath","browserType","error","Error","value","getAnyChromeStable","e","getAnyEdgeStable","getAnyFirefoxStable","logger","defaultLogger"],"mappings":";;;;;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;ACHC;;;;;;;;;;AAWM,MAAMI;IA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CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuBA;YACzC,MAAMA;QACR;IACF;IAEQ,iBAAsD;QAC5D,IAAI;YACF,OAAO;gBACL,MAAMD,AAAAA,IAAAA,yCAAAA,kBAAAA,AAAAA;gBACN,MAAM;YACR;QACF,EAAE,OAAOC,GAAG;YACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsBA;QACzC;QAEA,IAAI;YACF,OAAO;gBACL,MAAMC,AAAAA,IAAAA,oCAAAA,gBAAAA,AAAAA;gBACN,MAAM;YACR;QACF,EAAE,OAAOD,GAAG;YACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoBA;QACvC;QAEA,IAAI;YACF,OAAO;gBACL,MAAME,AAAAA,IAAAA,0CAAAA,mBAAAA,AAAAA;gBACN,MAAM;YACR;QACF,EAAE,OAAOF,GAAG;YACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuBA;QAC1C;QAEA,MAAMJ,QAAQ,IAAIC,MAAM;QACxBD,MAAM,IAAI,GAAG;QACb,MAAMA;IACR;IAzGA,YAAYO,MAAe,CAAE;QAF7B,uBAAQ,UAAR;QAGE,IAAI,CAAC,MAAM,GAAGA,UAAUC,uBAAAA,aAAaA;IACvC;AAwGF"}
package/dist/index.mjs ADDED
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { defaultLogger } from "@agent-infra/logger";
6
+ import { getAnyEdgeStable } from "edge-paths";
7
+ import { getAnyChromeStable } from "./chrome-paths.mjs";
8
+ import { getAnyFirefoxStable } from "./firefox-paths.mjs";
9
+ function _define_property(obj, key, value) {
10
+ if (key in obj) Object.defineProperty(obj, key, {
11
+ value: value,
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true
15
+ });
16
+ else obj[key] = value;
17
+ return obj;
18
+ }
19
+ class BrowserFinder {
20
+ findBrowser(name) {
21
+ const platform = process.platform;
22
+ let browserPath;
23
+ let browserType;
24
+ this.logger.info('Find browser on platform:', platform);
25
+ if (![
26
+ 'darwin',
27
+ 'win32',
28
+ 'linux'
29
+ ].includes(platform)) {
30
+ const error = new Error(`Unsupported platform: ${platform}`);
31
+ this.logger.error(error.message);
32
+ throw error;
33
+ }
34
+ switch(name){
35
+ case 'chrome':
36
+ browserPath = this.findChrome();
37
+ browserType = 'chrome';
38
+ break;
39
+ case 'edge':
40
+ browserPath = this.findEdge();
41
+ browserType = 'edge';
42
+ break;
43
+ case 'firefox':
44
+ browserPath = this.findFirefox();
45
+ browserType = 'firefox';
46
+ break;
47
+ default:
48
+ const value = this.findAnyBrowser();
49
+ browserPath = value.path;
50
+ browserType = value.type;
51
+ break;
52
+ }
53
+ this.logger.info('browserPath:', browserPath);
54
+ return {
55
+ path: browserPath,
56
+ type: browserType
57
+ };
58
+ }
59
+ findChrome() {
60
+ try {
61
+ return getAnyChromeStable();
62
+ } catch (e) {
63
+ this.logger.error('Find Chrome Error:', e);
64
+ throw e;
65
+ }
66
+ }
67
+ findEdge() {
68
+ try {
69
+ return getAnyEdgeStable();
70
+ } catch (e) {
71
+ this.logger.error('Find Edge Error:', e);
72
+ throw e;
73
+ }
74
+ }
75
+ findFirefox() {
76
+ try {
77
+ return getAnyFirefoxStable();
78
+ } catch (e) {
79
+ this.logger.error('Find Firefox Error:', e);
80
+ throw e;
81
+ }
82
+ }
83
+ findAnyBrowser() {
84
+ try {
85
+ return {
86
+ path: getAnyChromeStable(),
87
+ type: 'chrome'
88
+ };
89
+ } catch (e) {
90
+ this.logger.warn('Find Chrome Error:', e);
91
+ }
92
+ try {
93
+ return {
94
+ path: getAnyEdgeStable(),
95
+ type: 'edge'
96
+ };
97
+ } catch (e) {
98
+ this.logger.warn('Find Edge Error:', e);
99
+ }
100
+ try {
101
+ return {
102
+ path: getAnyFirefoxStable(),
103
+ type: 'firefox'
104
+ };
105
+ } catch (e) {
106
+ this.logger.warn('Find Firefox Error:', e);
107
+ }
108
+ const error = new Error('Unable to find any browser.');
109
+ error.name = 'BrowserPathsError';
110
+ throw error;
111
+ }
112
+ constructor(logger){
113
+ _define_property(this, "logger", void 0);
114
+ this.logger = logger ?? defaultLogger;
115
+ }
116
+ }
117
+ export { BrowserFinder };
118
+
119
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["webpack://@agent-infra/browser-finder/./src/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 type { BrowserType };\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;;;;;;;;;;AAWM,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,C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AUC;IAC1B;AAwGF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type BrowserType = 'chrome' | 'edge' | 'firefox';
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,24 @@
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__.r = (exports1)=>{
9
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
10
+ value: 'Module'
11
+ });
12
+ Object.defineProperty(exports1, '__esModule', {
13
+ value: true
14
+ });
15
+ };
16
+ })();
17
+ var __webpack_exports__ = {};
18
+ __webpack_require__.r(__webpack_exports__);
19
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
20
+ Object.defineProperty(exports, '__esModule', {
21
+ value: true
22
+ });
23
+
24
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["webpack://@agent-infra/browser-finder/webpack/runtime/make_namespace_object"],"sourcesContent":["// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"names":["__webpack_require__","Symbol","Object"],"mappings":";;;;;;;IACAA,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOC,UAA0BA,OAAO,WAAW,EACrDC,OAAO,cAAc,CAAC,UAASD,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEC,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D"}
package/dist/types.mjs ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@agent-infra/browser-finder",
3
+ "description": "find browser in your system",
4
+ "version": "0.1.3",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git@github.com:agent-infra/browser.git"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "dependencies": {
26
+ "which": "5.0.0",
27
+ "edge-paths": "3.0.5",
28
+ "@agent-infra/logger": "0.0.2-beta.2"
29
+ },
30
+ "devDependencies": {
31
+ "@types/which": "3.0.4",
32
+ "@types/node": "24.1.0",
33
+ "typescript": "5.8.3",
34
+ "vitest": "3.2.4",
35
+ "@vitest/coverage-v8": "3.2.4",
36
+ "@rslib/core": "0.11.0"
37
+ },
38
+ "scripts": {
39
+ "dev": "rslib build --watch",
40
+ "build": "rslib build",
41
+ "test": "vitest run",
42
+ "test:watch": "vitest",
43
+ "test:e2e": "vitest --config vitest.e2e.config.ts",
44
+ "coverage": "vitest run --coverage",
45
+ "test:e2e:local": "vitest --config vitest.e2e.config.ts local-browser.e2e.test.ts"
46
+ }
47
+ }