@agent-infra/browser 0.0.1 → 0.0.3-beta.0

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.
Files changed (41) hide show
  1. package/dist/browser-finder/chrome-paths.d.ts +10 -0
  2. package/dist/browser-finder/chrome-paths.d.ts.map +1 -0
  3. package/dist/browser-finder/chrome-paths.js +160 -0
  4. package/dist/browser-finder/chrome-paths.js.map +1 -0
  5. package/dist/browser-finder/chrome-paths.mjs +118 -0
  6. package/dist/browser-finder/chrome-paths.mjs.map +1 -0
  7. package/dist/browser-finder/firefox-paths.d.ts +2 -0
  8. package/dist/browser-finder/firefox-paths.d.ts.map +1 -0
  9. package/dist/browser-finder/firefox-paths.js +132 -0
  10. package/dist/browser-finder/firefox-paths.js.map +1 -0
  11. package/dist/browser-finder/firefox-paths.mjs +90 -0
  12. package/dist/browser-finder/firefox-paths.mjs.map +1 -0
  13. package/dist/browser-finder/index.d.ts +15 -0
  14. package/dist/browser-finder/index.d.ts.map +1 -0
  15. package/dist/browser-finder/index.js +151 -0
  16. package/dist/browser-finder/index.js.map +1 -0
  17. package/dist/browser-finder/index.mjs +119 -0
  18. package/dist/browser-finder/index.mjs.map +1 -0
  19. package/dist/browser-finder/index.test.d.ts +2 -0
  20. package/dist/browser-finder/index.test.d.ts.map +1 -0
  21. package/dist/index.js +1 -1
  22. package/dist/index.mjs +1 -1
  23. package/dist/local-browser.d.ts +2 -6
  24. package/dist/local-browser.d.ts.map +1 -1
  25. package/dist/local-browser.js +37 -19
  26. package/dist/local-browser.js.map +1 -1
  27. package/dist/local-browser.mjs +37 -19
  28. package/dist/local-browser.mjs.map +1 -1
  29. package/dist/types.d.ts +11 -2
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/types.js +0 -15
  32. package/dist/types.mjs +0 -3
  33. package/package.json +6 -3
  34. package/dist/browser-finder.d.ts +0 -59
  35. package/dist/browser-finder.d.ts.map +0 -1
  36. package/dist/browser-finder.js +0 -148
  37. package/dist/browser-finder.js.map +0 -1
  38. package/dist/browser-finder.mjs +0 -116
  39. package/dist/browser-finder.mjs.map +0 -1
  40. package/dist/browser-finder.test.d.ts +0 -2
  41. package/dist/browser-finder.test.d.ts.map +0 -1
@@ -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/browser-finder/chrome-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiJH,wBAAgB,kBAAkB,IAAI,MAAM,CAwB3C"}
@@ -0,0 +1,160 @@
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 = function(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
+ var __webpack_export_target__ = exports;
155
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
156
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
157
+ value: true
158
+ });
159
+
160
+ //# sourceMappingURL=chrome-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-finder/chrome-paths.js","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,yBAAAA,IAAU,CAACF;YACxB,OAAOC;QACT;IACF,EAAE,OAAOE,GAAG,CAAC;IAEb,OAAO;AACT;AAEA,SAASC,mBACPJ,IAA4D;IAE5D,MAAMK,SAAS,GAAGC,8BAAAA,GAAGA,CAAC,MAAM,EAAEA,8BAAAA,GAAGA,GAAGN,OAAOM,8BAAAA,GAAGA,CAAC,WAAW,EAAEA,8BAAAA,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,MAAM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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,118 @@
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
@@ -0,0 +1 @@
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;KAAC,CAAC,MAAM,CAAC,CAACiB,OAASA,AAASC,KAAAA,MAATD;IAEzD,KAAK,MAAML,UAAUF,SAAU;QAC7B,MAAMS,aAAaL,AAAAA,IAAAA,iCAAAA,IAAAA,AAAAA,E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AEjC,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/browser-finder/firefox-paths.ts"],"names":[],"mappings":"AA8GA,wBAAgB,mBAAmB,IAAI,MAAM,CAmB5C"}
@@ -0,0 +1,132 @@
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 = function(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
@@ -0,0 +1 @@
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;K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6B;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,90 @@
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
@@ -0,0 +1 @@
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,OAA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AAQ,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,15 @@
1
+ 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
@@ -0,0 +1 @@
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"}