@rsbuild/core 1.6.5 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/0~open.js CHANGED
@@ -1,359 +1,349 @@
1
+ let isDockerCached, cachedResult, mountPoint, defaultMountPoint;
2
+ import { __webpack_require__ } from "./rslib-runtime.js";
1
3
  import { Buffer } from "node:buffer";
2
4
  import node_child_process, { execFile } from "node:child_process";
3
5
  import promises, { constants } from "node:fs/promises";
4
- export const __webpack_id__ = "664";
5
- export const __webpack_ids__ = [
6
- "664"
7
- ];
8
- export const __webpack_modules__ = {
9
- "../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10
- let isDockerCached, cachedResult, mountPoint, defaultMountPoint;
11
- __webpack_require__.d(__webpack_exports__, {
12
- default: ()=>node_modules_open,
13
- apps: ()=>apps
6
+ import { node_fs, node_process, node_os, external_node_util_promisify } from "./58.js";
7
+ function hasDockerEnv() {
8
+ try {
9
+ return node_fs.statSync('/.dockerenv'), !0;
10
+ } catch {
11
+ return !1;
12
+ }
13
+ }
14
+ function hasDockerCGroup() {
15
+ try {
16
+ return node_fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
17
+ } catch {
18
+ return !1;
19
+ }
20
+ }
21
+ function isDocker() {
22
+ return void 0 === isDockerCached && (isDockerCached = hasDockerEnv() || hasDockerCGroup()), isDockerCached;
23
+ }
24
+ function isInsideContainer() {
25
+ return void 0 === cachedResult && (cachedResult = (()=>{
26
+ try {
27
+ return node_fs.statSync('/run/.containerenv'), !0;
28
+ } catch {
29
+ return !1;
30
+ }
31
+ })() || isDocker()), cachedResult;
32
+ }
33
+ let isWsl = ()=>{
34
+ if ('linux' !== node_process.platform) return !1;
35
+ if (node_os.release().toLowerCase().includes('microsoft')) return !isInsideContainer();
36
+ try {
37
+ return !!node_fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') && !isInsideContainer();
38
+ } catch {
39
+ return !1;
40
+ }
41
+ }, is_wsl = node_process.env.__IS_WSL_TEST__ ? isWsl : isWsl(), wslDrivesMountPoint = (defaultMountPoint = '/mnt/', async function() {
42
+ if (mountPoint) return mountPoint;
43
+ let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
44
+ try {
45
+ await promises.access(configFilePath, constants.F_OK), isConfigFileExists = !0;
46
+ } catch {}
47
+ if (!isConfigFileExists) return defaultMountPoint;
48
+ let configContent = await promises.readFile(configFilePath, {
49
+ encoding: 'utf8'
50
+ }), configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
51
+ return configMountPoint ? mountPoint = (mountPoint = configMountPoint.groups.mountPoint.trim()).endsWith('/') ? mountPoint : `${mountPoint}/` : defaultMountPoint;
52
+ }), powerShellPathFromWsl = async ()=>{
53
+ let mountPoint = await wslDrivesMountPoint();
54
+ return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
55
+ }, powerShellPath = async ()=>is_wsl ? powerShellPathFromWsl() : `${node_process.env.SYSTEMROOT || node_process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
56
+ function defineLazyProperty(object, propertyName, valueGetter) {
57
+ let define = (value)=>Object.defineProperty(object, propertyName, {
58
+ value,
59
+ enumerable: !0,
60
+ writable: !0
14
61
  });
15
- var external_node_process_ = __webpack_require__("node:process"), external_node_path_ = __webpack_require__("node:path"), external_node_url_ = __webpack_require__("node:url"), external_node_util_ = __webpack_require__("node:util"), external_node_os_ = __webpack_require__("node:os"), external_node_fs_ = __webpack_require__("node:fs");
16
- function hasDockerEnv() {
17
- try {
18
- return external_node_fs_.default.statSync('/.dockerenv'), !0;
19
- } catch {
20
- return !1;
21
- }
62
+ return Object.defineProperty(object, propertyName, {
63
+ configurable: !0,
64
+ enumerable: !0,
65
+ get () {
66
+ let result = valueGetter();
67
+ return define(result), result;
68
+ },
69
+ set (value) {
70
+ define(value);
22
71
  }
23
- function hasDockerCGroup() {
24
- try {
25
- return external_node_fs_.default.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
26
- } catch {
27
- return !1;
72
+ }), object;
73
+ }
74
+ let execFileAsync = external_node_util_promisify(execFile);
75
+ async function defaultBrowserId() {
76
+ if ('darwin' !== node_process.platform) throw Error('macOS only');
77
+ let { stdout } = await execFileAsync('defaults', [
78
+ 'read',
79
+ 'com.apple.LaunchServices/com.apple.launchservices.secure',
80
+ 'LSHandlers'
81
+ ]), match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
82
+ return match?.groups.id ?? 'com.apple.Safari';
83
+ }
84
+ let run_applescript_execFileAsync = external_node_util_promisify(execFile);
85
+ async function runAppleScript(script, { humanReadableOutput = !0, signal } = {}) {
86
+ if ('darwin' !== node_process.platform) throw Error('macOS only');
87
+ let execOptions = {};
88
+ signal && (execOptions.signal = signal);
89
+ let { stdout } = await run_applescript_execFileAsync("osascript", [
90
+ '-e',
91
+ script,
92
+ humanReadableOutput ? [] : [
93
+ '-ss'
94
+ ]
95
+ ], execOptions);
96
+ return stdout.trim();
97
+ }
98
+ async function bundleName(bundleId) {
99
+ return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
100
+ }
101
+ let windows_execFileAsync = external_node_util_promisify(execFile), windowsBrowserProgIds = {
102
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
103
+ name: 'Edge',
104
+ id: 'com.microsoft.edge.old'
105
+ },
106
+ MSEdgeDHTML: {
107
+ name: 'Edge',
108
+ id: 'com.microsoft.edge'
109
+ },
110
+ MSEdgeHTM: {
111
+ name: 'Edge',
112
+ id: 'com.microsoft.edge'
113
+ },
114
+ 'IE.HTTP': {
115
+ name: 'Internet Explorer',
116
+ id: 'com.microsoft.ie'
117
+ },
118
+ FirefoxURL: {
119
+ name: 'Firefox',
120
+ id: 'org.mozilla.firefox'
121
+ },
122
+ ChromeHTML: {
123
+ name: 'Chrome',
124
+ id: 'com.google.chrome'
125
+ },
126
+ BraveHTML: {
127
+ name: 'Brave',
128
+ id: 'com.brave.Browser'
129
+ },
130
+ BraveBHTML: {
131
+ name: 'Brave Beta',
132
+ id: 'com.brave.Browser.beta'
133
+ },
134
+ BraveSSHTM: {
135
+ name: 'Brave Nightly',
136
+ id: 'com.brave.Browser.nightly'
137
+ }
138
+ };
139
+ class UnknownBrowserError extends Error {
140
+ }
141
+ async function defaultBrowser(_execFileAsync = windows_execFileAsync) {
142
+ let { stdout } = await _execFileAsync('reg', [
143
+ 'QUERY',
144
+ ' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',
145
+ '/v',
146
+ 'ProgId'
147
+ ]), match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
148
+ if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
149
+ let { id } = match.groups, browser = windowsBrowserProgIds[id];
150
+ if (!browser) throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
151
+ return browser;
152
+ }
153
+ let default_browser_execFileAsync = external_node_util_promisify(execFile);
154
+ async function default_browser_defaultBrowser() {
155
+ if ('darwin' === node_process.platform) {
156
+ let id = await defaultBrowserId();
157
+ return {
158
+ name: await bundleName(id),
159
+ id
160
+ };
161
+ }
162
+ if ('linux' === node_process.platform) {
163
+ let { stdout } = await default_browser_execFileAsync('xdg-mime', [
164
+ 'query',
165
+ 'default',
166
+ 'x-scheme-handler/http'
167
+ ]), id = stdout.trim();
168
+ return {
169
+ name: id.replace(/.desktop$/, '').replace('-', ' ').toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x)=>x.toUpperCase()),
170
+ id
171
+ };
172
+ }
173
+ if ('win32' === node_process.platform) return defaultBrowser();
174
+ throw Error('Only macOS, Linux, and Windows are supported');
175
+ }
176
+ let external_node_path_ = __webpack_require__("node:path"), external_node_url_ = __webpack_require__("node:url"), open_execFile = external_node_util_promisify(node_child_process.execFile), open_dirname = external_node_path_.default.dirname((0, external_node_url_.fileURLToPath)(import.meta.url)), localXdgOpenPath = external_node_path_.default.join(open_dirname, 'xdg-open'), { platform: platform, arch: arch } = node_process;
177
+ async function getWindowsDefaultBrowserFromWsl() {
178
+ let powershellPath = await powerShellPath(), rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, encodedCommand = Buffer.from(rawCommand, 'utf16le').toString('base64'), { stdout } = await open_execFile(powershellPath, [
179
+ '-NoProfile',
180
+ '-NonInteractive',
181
+ '-ExecutionPolicy',
182
+ 'Bypass',
183
+ '-EncodedCommand',
184
+ encodedCommand
185
+ ], {
186
+ encoding: 'utf8'
187
+ }), progId = stdout.trim(), browserMap = {
188
+ ChromeHTML: 'com.google.chrome',
189
+ BraveHTML: 'com.brave.Browser',
190
+ MSEdgeHTM: 'com.microsoft.edge',
191
+ FirefoxURL: 'org.mozilla.firefox'
192
+ };
193
+ return browserMap[progId] ? {
194
+ id: browserMap[progId]
195
+ } : {};
196
+ }
197
+ let pTryEach = async (array, mapper)=>{
198
+ let latestError;
199
+ for (let item of array)try {
200
+ return await mapper(item);
201
+ } catch (error) {
202
+ latestError = error;
203
+ }
204
+ throw latestError;
205
+ }, baseOpen = async (options)=>{
206
+ let command;
207
+ if (Array.isArray((options = {
208
+ wait: !1,
209
+ background: !1,
210
+ newInstance: !1,
211
+ allowNonzeroExitCode: !1,
212
+ ...options
213
+ }).app)) return pTryEach(options.app, (singleApp)=>baseOpen({
214
+ ...options,
215
+ app: singleApp
216
+ }));
217
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
218
+ if (appArguments = [
219
+ ...appArguments
220
+ ], Array.isArray(app)) return pTryEach(app, (appName)=>baseOpen({
221
+ ...options,
222
+ app: {
223
+ name: appName,
224
+ arguments: appArguments
28
225
  }
29
- }
30
- function isDocker() {
31
- return void 0 === isDockerCached && (isDockerCached = hasDockerEnv() || hasDockerCGroup()), isDockerCached;
32
- }
33
- function isInsideContainer() {
34
- return void 0 === cachedResult && (cachedResult = (()=>{
35
- try {
36
- return external_node_fs_.default.statSync('/run/.containerenv'), !0;
37
- } catch {
38
- return !1;
226
+ }));
227
+ if ('browser' === app || 'browserPrivate' === app) {
228
+ let ids = {
229
+ 'com.google.chrome': 'chrome',
230
+ 'google-chrome.desktop': 'chrome',
231
+ 'com.brave.Browser': 'brave',
232
+ 'org.mozilla.firefox': 'firefox',
233
+ 'firefox.desktop': 'firefox',
234
+ 'com.microsoft.msedge': 'edge',
235
+ 'com.microsoft.edge': 'edge',
236
+ 'com.microsoft.edgemac': 'edge',
237
+ 'microsoft-edge.desktop': 'edge'
238
+ }, browser = is_wsl ? await getWindowsDefaultBrowserFromWsl() : await default_browser_defaultBrowser();
239
+ if (browser.id in ids) {
240
+ let browserName = ids[browser.id];
241
+ return 'browserPrivate' === app && appArguments.push({
242
+ chrome: '--incognito',
243
+ brave: '--incognito',
244
+ firefox: '--private-window',
245
+ edge: '--inPrivate'
246
+ }[browserName]), baseOpen({
247
+ ...options,
248
+ app: {
249
+ name: apps[browserName],
250
+ arguments: appArguments
39
251
  }
40
- })() || isDocker()), cachedResult;
252
+ });
41
253
  }
42
- let isWsl = ()=>{
43
- if ('linux' !== external_node_process_.default.platform) return !1;
44
- if (external_node_os_.default.release().toLowerCase().includes('microsoft')) return !isInsideContainer();
45
- try {
46
- return !!external_node_fs_.default.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') && !isInsideContainer();
47
- } catch {
48
- return !1;
49
- }
50
- }, is_wsl = external_node_process_.default.env.__IS_WSL_TEST__ ? isWsl : isWsl(), wslDrivesMountPoint = (defaultMountPoint = '/mnt/', async function() {
51
- if (mountPoint) return mountPoint;
52
- let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
254
+ throw Error(`${browser.name} is not supported as a default browser`);
255
+ }
256
+ let cliArguments = [], childProcessOptions = {};
257
+ if ('darwin' === platform) command = 'open', options.wait && cliArguments.push('--wait-apps'), options.background && cliArguments.push('--background'), options.newInstance && cliArguments.push('--new'), app && cliArguments.push('-a', app);
258
+ else if ('win32' !== platform && (!is_wsl || isInsideContainer() || app)) {
259
+ if (app) command = app;
260
+ else {
261
+ let exeLocalXdgOpen = !1;
53
262
  try {
54
- await promises.access(configFilePath, constants.F_OK), isConfigFileExists = !0;
263
+ await promises.access(localXdgOpenPath, constants.X_OK), exeLocalXdgOpen = !0;
55
264
  } catch {}
56
- if (!isConfigFileExists) return defaultMountPoint;
57
- let configContent = await promises.readFile(configFilePath, {
58
- encoding: 'utf8'
59
- }), configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
60
- return configMountPoint ? mountPoint = (mountPoint = configMountPoint.groups.mountPoint.trim()).endsWith('/') ? mountPoint : `${mountPoint}/` : defaultMountPoint;
61
- }), powerShellPathFromWsl = async ()=>{
62
- let mountPoint = await wslDrivesMountPoint();
63
- return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
64
- }, powerShellPath = async ()=>is_wsl ? powerShellPathFromWsl() : `${external_node_process_.default.env.SYSTEMROOT || external_node_process_.default.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
65
- function defineLazyProperty(object, propertyName, valueGetter) {
66
- let define = (value)=>Object.defineProperty(object, propertyName, {
67
- value,
68
- enumerable: !0,
69
- writable: !0
70
- });
71
- return Object.defineProperty(object, propertyName, {
72
- configurable: !0,
73
- enumerable: !0,
74
- get () {
75
- let result = valueGetter();
76
- return define(result), result;
77
- },
78
- set (value) {
79
- define(value);
80
- }
81
- }), object;
82
- }
83
- let execFileAsync = (0, external_node_util_.promisify)(execFile);
84
- async function defaultBrowserId() {
85
- if ('darwin' !== external_node_process_.default.platform) throw Error('macOS only');
86
- let { stdout } = await execFileAsync('defaults', [
87
- 'read',
88
- 'com.apple.LaunchServices/com.apple.launchservices.secure',
89
- 'LSHandlers'
90
- ]), match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
91
- return match?.groups.id ?? 'com.apple.Safari';
92
- }
93
- let run_applescript_execFileAsync = (0, external_node_util_.promisify)(execFile);
94
- async function runAppleScript(script, { humanReadableOutput = !0, signal } = {}) {
95
- if ('darwin' !== external_node_process_.default.platform) throw Error('macOS only');
96
- let execOptions = {};
97
- signal && (execOptions.signal = signal);
98
- let { stdout } = await run_applescript_execFileAsync("osascript", [
99
- '-e',
100
- script,
101
- humanReadableOutput ? [] : [
102
- '-ss'
103
- ]
104
- ], execOptions);
105
- return stdout.trim();
265
+ command = node_process.versions.electron ?? ('android' === platform || !open_dirname || '/' === open_dirname || !exeLocalXdgOpen) ? 'xdg-open' : localXdgOpenPath;
106
266
  }
107
- async function bundleName(bundleId) {
108
- return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
109
- }
110
- let windows_execFileAsync = (0, external_node_util_.promisify)(execFile), windowsBrowserProgIds = {
111
- AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
112
- name: 'Edge',
113
- id: 'com.microsoft.edge.old'
114
- },
115
- MSEdgeDHTML: {
116
- name: 'Edge',
117
- id: 'com.microsoft.edge'
118
- },
119
- MSEdgeHTM: {
120
- name: 'Edge',
121
- id: 'com.microsoft.edge'
122
- },
123
- 'IE.HTTP': {
124
- name: 'Internet Explorer',
125
- id: 'com.microsoft.ie'
126
- },
127
- FirefoxURL: {
128
- name: 'Firefox',
129
- id: 'org.mozilla.firefox'
130
- },
131
- ChromeHTML: {
132
- name: 'Chrome',
133
- id: 'com.google.chrome'
134
- },
135
- BraveHTML: {
136
- name: 'Brave',
137
- id: 'com.brave.Browser'
138
- },
139
- BraveBHTML: {
140
- name: 'Brave Beta',
141
- id: 'com.brave.Browser.beta'
142
- },
143
- BraveSSHTM: {
144
- name: 'Brave Nightly',
145
- id: 'com.brave.Browser.nightly'
146
- }
147
- };
148
- class UnknownBrowserError extends Error {
149
- }
150
- async function defaultBrowser(_execFileAsync = windows_execFileAsync) {
151
- let { stdout } = await _execFileAsync('reg', [
152
- 'QUERY',
153
- ' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',
154
- '/v',
155
- 'ProgId'
156
- ]), match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
157
- if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
158
- let { id } = match.groups, browser = windowsBrowserProgIds[id];
159
- if (!browser) throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
160
- return browser;
161
- }
162
- let default_browser_execFileAsync = (0, external_node_util_.promisify)(execFile);
163
- async function default_browser_defaultBrowser() {
164
- if ('darwin' === external_node_process_.default.platform) {
165
- let id = await defaultBrowserId();
166
- return {
167
- name: await bundleName(id),
168
- id
169
- };
170
- }
171
- if ('linux' === external_node_process_.default.platform) {
172
- let { stdout } = await default_browser_execFileAsync('xdg-mime', [
173
- 'query',
174
- 'default',
175
- 'x-scheme-handler/http'
176
- ]), id = stdout.trim();
177
- return {
178
- name: id.replace(/.desktop$/, '').replace('-', ' ').toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x)=>x.toUpperCase()),
179
- id
180
- };
181
- }
182
- if ('win32' === external_node_process_.default.platform) return defaultBrowser();
183
- throw Error('Only macOS, Linux, and Windows are supported');
184
- }
185
- let open_execFile = (0, external_node_util_.promisify)(node_child_process.execFile), open_dirname = external_node_path_.default.dirname((0, external_node_url_.fileURLToPath)(import.meta.url)), localXdgOpenPath = external_node_path_.default.join(open_dirname, 'xdg-open'), { platform, arch } = external_node_process_.default;
186
- async function getWindowsDefaultBrowserFromWsl() {
187
- let powershellPath = await powerShellPath(), rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, encodedCommand = Buffer.from(rawCommand, 'utf16le').toString('base64'), { stdout } = await open_execFile(powershellPath, [
188
- '-NoProfile',
189
- '-NonInteractive',
190
- '-ExecutionPolicy',
191
- 'Bypass',
192
- '-EncodedCommand',
193
- encodedCommand
194
- ], {
195
- encoding: 'utf8'
196
- }), progId = stdout.trim(), browserMap = {
197
- ChromeHTML: 'com.google.chrome',
198
- BraveHTML: 'com.brave.Browser',
199
- MSEdgeHTM: 'com.microsoft.edge',
200
- FirefoxURL: 'org.mozilla.firefox'
201
- };
202
- return browserMap[progId] ? {
203
- id: browserMap[progId]
204
- } : {};
205
- }
206
- let pTryEach = async (array, mapper)=>{
207
- let latestError;
208
- for (let item of array)try {
209
- return await mapper(item);
210
- } catch (error) {
211
- latestError = error;
212
- }
213
- throw latestError;
214
- }, baseOpen = async (options)=>{
215
- let command;
216
- if (Array.isArray((options = {
217
- wait: !1,
218
- background: !1,
219
- newInstance: !1,
220
- allowNonzeroExitCode: !1,
221
- ...options
222
- }).app)) return pTryEach(options.app, (singleApp)=>baseOpen({
223
- ...options,
224
- app: singleApp
225
- }));
226
- let { name: app, arguments: appArguments = [] } = options.app ?? {};
227
- if (appArguments = [
228
- ...appArguments
229
- ], Array.isArray(app)) return pTryEach(app, (appName)=>baseOpen({
230
- ...options,
231
- app: {
232
- name: appName,
233
- arguments: appArguments
234
- }
235
- }));
236
- if ('browser' === app || 'browserPrivate' === app) {
237
- let ids = {
238
- 'com.google.chrome': 'chrome',
239
- 'google-chrome.desktop': 'chrome',
240
- 'com.brave.Browser': 'brave',
241
- 'org.mozilla.firefox': 'firefox',
242
- 'firefox.desktop': 'firefox',
243
- 'com.microsoft.msedge': 'edge',
244
- 'com.microsoft.edge': 'edge',
245
- 'com.microsoft.edgemac': 'edge',
246
- 'microsoft-edge.desktop': 'edge'
247
- }, browser = is_wsl ? await getWindowsDefaultBrowserFromWsl() : await default_browser_defaultBrowser();
248
- if (browser.id in ids) {
249
- let browserName = ids[browser.id];
250
- return 'browserPrivate' === app && appArguments.push({
251
- chrome: '--incognito',
252
- brave: '--incognito',
253
- firefox: '--private-window',
254
- edge: '--inPrivate'
255
- }[browserName]), baseOpen({
256
- ...options,
257
- app: {
258
- name: apps[browserName],
259
- arguments: appArguments
260
- }
261
- });
262
- }
263
- throw Error(`${browser.name} is not supported as a default browser`);
264
- }
265
- let cliArguments = [], childProcessOptions = {};
266
- if ('darwin' === platform) command = 'open', options.wait && cliArguments.push('--wait-apps'), options.background && cliArguments.push('--background'), options.newInstance && cliArguments.push('--new'), app && cliArguments.push('-a', app);
267
- else if ('win32' !== platform && (!is_wsl || isInsideContainer() || app)) {
268
- if (app) command = app;
269
- else {
270
- let exeLocalXdgOpen = !1;
271
- try {
272
- await promises.access(localXdgOpenPath, constants.X_OK), exeLocalXdgOpen = !0;
273
- } catch {}
274
- command = external_node_process_.default.versions.electron ?? ('android' === platform || !open_dirname || '/' === open_dirname || !exeLocalXdgOpen) ? 'xdg-open' : localXdgOpenPath;
275
- }
276
- appArguments.length > 0 && cliArguments.push(...appArguments), options.wait || (childProcessOptions.stdio = 'ignore', childProcessOptions.detached = !0);
277
- } else {
278
- command = await powerShellPath(), cliArguments.push('-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand'), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0);
279
- let encodedArguments = [
280
- 'Start'
281
- ];
282
- options.wait && encodedArguments.push('-Wait'), app ? (encodedArguments.push(`"\`"${app}\`""`), options.target && appArguments.push(options.target)) : options.target && encodedArguments.push(`"${options.target}"`), appArguments.length > 0 && encodedArguments.push('-ArgumentList', (appArguments = appArguments.map((argument)=>`"\`"${argument}\`""`)).join(',')), options.target = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
283
- }
284
- 'darwin' === platform && appArguments.length > 0 && cliArguments.push('--args', ...appArguments), options.target && cliArguments.push(options.target);
285
- let subprocess = node_child_process.spawn(command, cliArguments, childProcessOptions);
286
- return options.wait ? new Promise((resolve, reject)=>{
287
- subprocess.once('error', reject), subprocess.once('close', (exitCode)=>{
288
- !options.allowNonzeroExitCode && exitCode > 0 ? reject(Error(`Exited with code ${exitCode}`)) : resolve(subprocess);
289
- });
290
- }) : (subprocess.unref(), subprocess);
291
- };
292
- function detectArchBinary(binary) {
293
- if ('string' == typeof binary || Array.isArray(binary)) return binary;
294
- let { [arch]: archBinary } = binary;
295
- if (!archBinary) throw Error(`${arch} is not supported`);
296
- return archBinary;
267
+ appArguments.length > 0 && cliArguments.push(...appArguments), options.wait || (childProcessOptions.stdio = 'ignore', childProcessOptions.detached = !0);
268
+ } else {
269
+ command = await powerShellPath(), cliArguments.push('-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand'), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0);
270
+ let encodedArguments = [
271
+ 'Start'
272
+ ];
273
+ options.wait && encodedArguments.push('-Wait'), app ? (encodedArguments.push(`"\`"${app}\`""`), options.target && appArguments.push(options.target)) : options.target && encodedArguments.push(`"${options.target}"`), appArguments.length > 0 && encodedArguments.push('-ArgumentList', (appArguments = appArguments.map((argument)=>`"\`"${argument}\`""`)).join(',')), options.target = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
274
+ }
275
+ 'darwin' === platform && appArguments.length > 0 && cliArguments.push('--args', ...appArguments), options.target && cliArguments.push(options.target);
276
+ let subprocess = node_child_process.spawn(command, cliArguments, childProcessOptions);
277
+ return options.wait ? new Promise((resolve, reject)=>{
278
+ subprocess.once('error', reject), subprocess.once('close', (exitCode)=>{
279
+ !options.allowNonzeroExitCode && exitCode > 0 ? reject(Error(`Exited with code ${exitCode}`)) : resolve(subprocess);
280
+ });
281
+ }) : (subprocess.unref(), subprocess);
282
+ };
283
+ function detectArchBinary(binary) {
284
+ if ('string' == typeof binary || Array.isArray(binary)) return binary;
285
+ let { [arch]: archBinary } = binary;
286
+ if (!archBinary) throw Error(`${arch} is not supported`);
287
+ return archBinary;
288
+ }
289
+ function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
290
+ if (wsl && is_wsl) return detectArchBinary(wsl);
291
+ if (!platformBinary) throw Error(`${platform} is not supported`);
292
+ return detectArchBinary(platformBinary);
293
+ }
294
+ let apps = {};
295
+ defineLazyProperty(apps, 'chrome', ()=>detectPlatformBinary({
296
+ darwin: 'google chrome',
297
+ win32: 'chrome',
298
+ linux: [
299
+ 'google-chrome',
300
+ 'google-chrome-stable',
301
+ 'chromium'
302
+ ]
303
+ }, {
304
+ wsl: {
305
+ ia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
306
+ x64: [
307
+ '/mnt/c/Program Files/Google/Chrome/Application/chrome.exe',
308
+ '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
309
+ ]
297
310
  }
298
- function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
299
- if (wsl && is_wsl) return detectArchBinary(wsl);
300
- if (!platformBinary) throw Error(`${platform} is not supported`);
301
- return detectArchBinary(platformBinary);
311
+ })), defineLazyProperty(apps, 'brave', ()=>detectPlatformBinary({
312
+ darwin: 'brave browser',
313
+ win32: 'brave',
314
+ linux: [
315
+ 'brave-browser',
316
+ 'brave'
317
+ ]
318
+ }, {
319
+ wsl: {
320
+ ia32: '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe',
321
+ x64: [
322
+ '/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe',
323
+ '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'
324
+ ]
302
325
  }
303
- let apps = {};
304
- defineLazyProperty(apps, 'chrome', ()=>detectPlatformBinary({
305
- darwin: 'google chrome',
306
- win32: 'chrome',
307
- linux: [
308
- 'google-chrome',
309
- 'google-chrome-stable',
310
- 'chromium'
311
- ]
312
- }, {
313
- wsl: {
314
- ia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
315
- x64: [
316
- '/mnt/c/Program Files/Google/Chrome/Application/chrome.exe',
317
- '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
318
- ]
319
- }
320
- })), defineLazyProperty(apps, 'brave', ()=>detectPlatformBinary({
321
- darwin: 'brave browser',
322
- win32: 'brave',
323
- linux: [
324
- 'brave-browser',
325
- 'brave'
326
- ]
327
- }, {
328
- wsl: {
329
- ia32: '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe',
330
- x64: [
331
- '/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe',
332
- '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'
333
- ]
334
- }
335
- })), defineLazyProperty(apps, 'firefox', ()=>detectPlatformBinary({
336
- darwin: 'firefox',
337
- win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
338
- linux: 'firefox'
339
- }, {
340
- wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
341
- })), defineLazyProperty(apps, 'edge', ()=>detectPlatformBinary({
342
- darwin: 'microsoft edge',
343
- win32: 'msedge',
344
- linux: [
345
- 'microsoft-edge',
346
- 'microsoft-edge-dev'
347
- ]
348
- }, {
349
- wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
350
- })), defineLazyProperty(apps, 'browser', ()=>'browser'), defineLazyProperty(apps, 'browserPrivate', ()=>'browserPrivate');
351
- let node_modules_open = (target, options)=>{
352
- if ('string' != typeof target) throw TypeError('Expected a `target`');
353
- return baseOpen({
354
- ...options,
355
- target
356
- });
357
- };
358
- }
326
+ })), defineLazyProperty(apps, 'firefox', ()=>detectPlatformBinary({
327
+ darwin: 'firefox',
328
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
329
+ linux: 'firefox'
330
+ }, {
331
+ wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
332
+ })), defineLazyProperty(apps, 'edge', ()=>detectPlatformBinary({
333
+ darwin: 'microsoft edge',
334
+ win32: 'msedge',
335
+ linux: [
336
+ 'microsoft-edge',
337
+ 'microsoft-edge-dev'
338
+ ]
339
+ }, {
340
+ wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
341
+ })), defineLazyProperty(apps, 'browser', ()=>'browser'), defineLazyProperty(apps, 'browserPrivate', ()=>'browserPrivate');
342
+ let node_modules_open = (target, options)=>{
343
+ if ('string' != typeof target) throw TypeError('Expected a `target`');
344
+ return baseOpen({
345
+ ...options,
346
+ target
347
+ });
359
348
  };
349
+ export { apps, node_modules_open };