azot 5.0.0-alpha.12 → 5.0.0-alpha.13

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/context.cjs CHANGED
@@ -1 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./context-DJcvCJWU.cjs`);exports.createContext=e.t;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_context = require('./context-AYnteC1j.cjs');
3
+
4
+ exports.createContext = require_context.createContext;
package/dist/context.mjs CHANGED
@@ -1 +1,3 @@
1
- import{t as e}from"./context-BhNE2Whq.mjs";export{e as createContext};
1
+ import { t as createContext } from "./context-BJuUj_Q4.mjs";
2
+
3
+ export { createContext };
package/dist/main.cjs CHANGED
@@ -1 +1,39 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=Azot??Streamyx??{};e&&(!e.input&&e.prompt&&(e.input=async(t,n)=>{let r=n?.fields??{answer:{label:t}};return await e.prompt({title:n?.title,description:n?.description,fields:r})}),e.defineExtension||=e=>e);const t=e.defineExtension,n=e.version,r=e.sleep,i=e.input,a=e.prompt,o=e.notify,s=e.confirm,c=e.ask,l=e.utils;exports.ask=c,exports.confirm=s,exports.default=e,exports.defineExtension=t,exports.input=i,exports.notify=o,exports.prompt=a,exports.sleep=r,exports.utils=l,exports.version=n;
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+
3
+ //#region src/main.ts
4
+ const runtimeContext = Azot ?? Streamyx ?? {};
5
+ if (runtimeContext) {
6
+ if (!runtimeContext.input && runtimeContext.prompt) {
7
+ const input = async (message, options) => {
8
+ const fields = options?.fields ?? { answer: { label: message } };
9
+ return await runtimeContext.prompt({
10
+ title: options?.title,
11
+ description: options?.description,
12
+ fields
13
+ });
14
+ };
15
+ runtimeContext.input = input;
16
+ }
17
+ if (!runtimeContext.defineExtension) runtimeContext.defineExtension = (extension) => extension;
18
+ }
19
+ const defineExtension = runtimeContext.defineExtension;
20
+ const version = runtimeContext.version;
21
+ const sleep = runtimeContext.sleep;
22
+ const input = runtimeContext.input;
23
+ const prompt = runtimeContext.prompt;
24
+ const notify = runtimeContext.notify;
25
+ const confirm = runtimeContext.confirm;
26
+ const ask = runtimeContext.ask;
27
+ const utils = runtimeContext.utils;
28
+
29
+ //#endregion
30
+ exports.ask = ask;
31
+ exports.confirm = confirm;
32
+ exports.default = runtimeContext;
33
+ exports.defineExtension = defineExtension;
34
+ exports.input = input;
35
+ exports.notify = notify;
36
+ exports.prompt = prompt;
37
+ exports.sleep = sleep;
38
+ exports.utils = utils;
39
+ exports.version = version;
package/dist/main.mjs CHANGED
@@ -1 +1,28 @@
1
- const e=Azot??Streamyx??{};e&&(!e.input&&e.prompt&&(e.input=async(t,n)=>{let r=n?.fields??{answer:{label:t}};return await e.prompt({title:n?.title,description:n?.description,fields:r})}),e.defineExtension||=e=>e);const t=e.defineExtension,n=e.version,r=e.sleep,i=e.input,a=e.prompt,o=e.notify,s=e.confirm,c=e.ask,l=e.utils;export{c as ask,s as confirm,e as default,t as defineExtension,i as input,o as notify,a as prompt,r as sleep,l as utils,n as version};
1
+ //#region src/main.ts
2
+ const runtimeContext = Azot ?? Streamyx ?? {};
3
+ if (runtimeContext) {
4
+ if (!runtimeContext.input && runtimeContext.prompt) {
5
+ const input = async (message, options) => {
6
+ const fields = options?.fields ?? { answer: { label: message } };
7
+ return await runtimeContext.prompt({
8
+ title: options?.title,
9
+ description: options?.description,
10
+ fields
11
+ });
12
+ };
13
+ runtimeContext.input = input;
14
+ }
15
+ if (!runtimeContext.defineExtension) runtimeContext.defineExtension = (extension) => extension;
16
+ }
17
+ const defineExtension = runtimeContext.defineExtension;
18
+ const version = runtimeContext.version;
19
+ const sleep = runtimeContext.sleep;
20
+ const input = runtimeContext.input;
21
+ const prompt = runtimeContext.prompt;
22
+ const notify = runtimeContext.notify;
23
+ const confirm = runtimeContext.confirm;
24
+ const ask = runtimeContext.ask;
25
+ const utils = runtimeContext.utils;
26
+
27
+ //#endregion
28
+ export { ask, confirm, runtimeContext as default, defineExtension, input, notify, prompt, sleep, utils, version };
@@ -0,0 +1,548 @@
1
+ import { promisify } from "node:util";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import os from "node:os";
5
+ import fsp, { constants } from "node:fs/promises";
6
+ import process from "node:process";
7
+ import childProcess, { execFile } from "node:child_process";
8
+ import { fileURLToPath } from "node:url";
9
+ import { Buffer } from "node:buffer";
10
+
11
+ //#region ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
12
+ let isDockerCached;
13
+ function hasDockerEnv() {
14
+ try {
15
+ fs.statSync("/.dockerenv");
16
+ return true;
17
+ } catch {
18
+ return false;
19
+ }
20
+ }
21
+ function hasDockerCGroup() {
22
+ try {
23
+ return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
24
+ } catch {
25
+ return false;
26
+ }
27
+ }
28
+ function isDocker() {
29
+ if (isDockerCached === void 0) isDockerCached = hasDockerEnv() || hasDockerCGroup();
30
+ return isDockerCached;
31
+ }
32
+
33
+ //#endregion
34
+ //#region ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
35
+ let cachedResult;
36
+ const hasContainerEnv = () => {
37
+ try {
38
+ fs.statSync("/run/.containerenv");
39
+ return true;
40
+ } catch {
41
+ return false;
42
+ }
43
+ };
44
+ function isInsideContainer() {
45
+ if (cachedResult === void 0) cachedResult = hasContainerEnv() || isDocker();
46
+ return cachedResult;
47
+ }
48
+
49
+ //#endregion
50
+ //#region ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
51
+ const isWsl = () => {
52
+ if (process.platform !== "linux") return false;
53
+ if (os.release().toLowerCase().includes("microsoft")) {
54
+ if (isInsideContainer()) return false;
55
+ return true;
56
+ }
57
+ try {
58
+ return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
59
+ } catch {
60
+ return false;
61
+ }
62
+ };
63
+ var is_wsl_default = process.env.__IS_WSL_TEST__ ? isWsl : isWsl();
64
+
65
+ //#endregion
66
+ //#region ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
67
+ const execFile$2 = promisify(childProcess.execFile);
68
+ const powerShellPath$1 = () => `${process.env.SYSTEMROOT || process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
69
+ const executePowerShell = async (command, options = {}) => {
70
+ const { powerShellPath: psPath, ...execFileOptions } = options;
71
+ const encodedCommand = executePowerShell.encodeCommand(command);
72
+ return execFile$2(psPath ?? powerShellPath$1(), [...executePowerShell.argumentsPrefix, encodedCommand], {
73
+ encoding: "utf8",
74
+ ...execFileOptions
75
+ });
76
+ };
77
+ executePowerShell.argumentsPrefix = [
78
+ "-NoProfile",
79
+ "-NonInteractive",
80
+ "-ExecutionPolicy",
81
+ "Bypass",
82
+ "-EncodedCommand"
83
+ ];
84
+ executePowerShell.encodeCommand = (command) => Buffer.from(command, "utf16le").toString("base64");
85
+ executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
86
+
87
+ //#endregion
88
+ //#region ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
89
+ function parseMountPointFromConfig(content) {
90
+ for (const line of content.split("\n")) {
91
+ if (/^\s*#/.test(line)) continue;
92
+ const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
93
+ if (!match) continue;
94
+ return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
95
+ }
96
+ }
97
+
98
+ //#endregion
99
+ //#region ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
100
+ const execFile$1 = promisify(childProcess.execFile);
101
+ const wslDrivesMountPoint = (() => {
102
+ const defaultMountPoint = "/mnt/";
103
+ let mountPoint;
104
+ return async function() {
105
+ if (mountPoint) return mountPoint;
106
+ const configFilePath = "/etc/wsl.conf";
107
+ let isConfigFileExists = false;
108
+ try {
109
+ await fsp.access(configFilePath, constants.F_OK);
110
+ isConfigFileExists = true;
111
+ } catch {}
112
+ if (!isConfigFileExists) return defaultMountPoint;
113
+ const parsedMountPoint = parseMountPointFromConfig(await fsp.readFile(configFilePath, { encoding: "utf8" }));
114
+ if (parsedMountPoint === void 0) return defaultMountPoint;
115
+ mountPoint = parsedMountPoint;
116
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
117
+ return mountPoint;
118
+ };
119
+ })();
120
+ const powerShellPathFromWsl = async () => {
121
+ return `${await wslDrivesMountPoint()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
122
+ };
123
+ const powerShellPath = is_wsl_default ? powerShellPathFromWsl : powerShellPath$1;
124
+ let canAccessPowerShellPromise;
125
+ const canAccessPowerShell = async () => {
126
+ canAccessPowerShellPromise ??= (async () => {
127
+ try {
128
+ const psPath = await powerShellPath();
129
+ await fsp.access(psPath, constants.X_OK);
130
+ return true;
131
+ } catch {
132
+ return false;
133
+ }
134
+ })();
135
+ return canAccessPowerShellPromise;
136
+ };
137
+ const wslDefaultBrowser = async () => {
138
+ const psPath = await powerShellPath();
139
+ const { stdout } = await executePowerShell(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { powerShellPath: psPath });
140
+ return stdout.trim();
141
+ };
142
+ const convertWslPathToWindows = async (path) => {
143
+ if (/^[a-z]+:\/\//i.test(path)) return path;
144
+ try {
145
+ const { stdout } = await execFile$1("wslpath", ["-aw", path], { encoding: "utf8" });
146
+ return stdout.trim();
147
+ } catch {
148
+ return path;
149
+ }
150
+ };
151
+
152
+ //#endregion
153
+ //#region ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
154
+ function defineLazyProperty(object, propertyName, valueGetter) {
155
+ const define = (value) => Object.defineProperty(object, propertyName, {
156
+ value,
157
+ enumerable: true,
158
+ writable: true
159
+ });
160
+ Object.defineProperty(object, propertyName, {
161
+ configurable: true,
162
+ enumerable: true,
163
+ get() {
164
+ const result = valueGetter();
165
+ define(result);
166
+ return result;
167
+ },
168
+ set(value) {
169
+ define(value);
170
+ }
171
+ });
172
+ return object;
173
+ }
174
+
175
+ //#endregion
176
+ //#region ../../node_modules/.pnpm/default-browser-id@5.0.0/node_modules/default-browser-id/index.js
177
+ const execFileAsync$3 = promisify(execFile);
178
+ async function defaultBrowserId() {
179
+ if (process.platform !== "darwin") throw new Error("macOS only");
180
+ const { stdout } = await execFileAsync$3("defaults", [
181
+ "read",
182
+ "com.apple.LaunchServices/com.apple.launchservices.secure",
183
+ "LSHandlers"
184
+ ]);
185
+ return /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout)?.groups.id ?? "com.apple.Safari";
186
+ }
187
+
188
+ //#endregion
189
+ //#region ../../node_modules/.pnpm/run-applescript@7.0.0/node_modules/run-applescript/index.js
190
+ const execFileAsync$2 = promisify(execFile);
191
+ async function runAppleScript(script, { humanReadableOutput = true } = {}) {
192
+ if (process.platform !== "darwin") throw new Error("macOS only");
193
+ const { stdout } = await execFileAsync$2("osascript", [
194
+ "-e",
195
+ script,
196
+ humanReadableOutput ? [] : ["-ss"]
197
+ ]);
198
+ return stdout.trim();
199
+ }
200
+
201
+ //#endregion
202
+ //#region ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
203
+ async function bundleName(bundleId) {
204
+ 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")`);
205
+ }
206
+
207
+ //#endregion
208
+ //#region ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js
209
+ const execFileAsync$1 = promisify(execFile);
210
+ const windowsBrowserProgIds = {
211
+ MSEdgeHTM: {
212
+ name: "Edge",
213
+ id: "com.microsoft.edge"
214
+ },
215
+ MSEdgeBHTML: {
216
+ name: "Edge Beta",
217
+ id: "com.microsoft.edge.beta"
218
+ },
219
+ MSEdgeDHTML: {
220
+ name: "Edge Dev",
221
+ id: "com.microsoft.edge.dev"
222
+ },
223
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
224
+ name: "Edge",
225
+ id: "com.microsoft.edge.old"
226
+ },
227
+ ChromeHTML: {
228
+ name: "Chrome",
229
+ id: "com.google.chrome"
230
+ },
231
+ ChromeBHTML: {
232
+ name: "Chrome Beta",
233
+ id: "com.google.chrome.beta"
234
+ },
235
+ ChromeDHTML: {
236
+ name: "Chrome Dev",
237
+ id: "com.google.chrome.dev"
238
+ },
239
+ ChromiumHTM: {
240
+ name: "Chromium",
241
+ id: "org.chromium.Chromium"
242
+ },
243
+ BraveHTML: {
244
+ name: "Brave",
245
+ id: "com.brave.Browser"
246
+ },
247
+ BraveBHTML: {
248
+ name: "Brave Beta",
249
+ id: "com.brave.Browser.beta"
250
+ },
251
+ BraveDHTML: {
252
+ name: "Brave Dev",
253
+ id: "com.brave.Browser.dev"
254
+ },
255
+ BraveSSHTM: {
256
+ name: "Brave Nightly",
257
+ id: "com.brave.Browser.nightly"
258
+ },
259
+ FirefoxURL: {
260
+ name: "Firefox",
261
+ id: "org.mozilla.firefox"
262
+ },
263
+ OperaStable: {
264
+ name: "Opera",
265
+ id: "com.operasoftware.Opera"
266
+ },
267
+ VivaldiHTM: {
268
+ name: "Vivaldi",
269
+ id: "com.vivaldi.Vivaldi"
270
+ },
271
+ "IE.HTTP": {
272
+ name: "Internet Explorer",
273
+ id: "com.microsoft.ie"
274
+ }
275
+ };
276
+ const _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
277
+ var UnknownBrowserError = class extends Error {};
278
+ async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
279
+ const { stdout } = await _execFileAsync("reg", [
280
+ "QUERY",
281
+ " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
282
+ "/v",
283
+ "ProgId"
284
+ ]);
285
+ const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
286
+ if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
287
+ const { id } = match.groups;
288
+ const dotIndex = id.lastIndexOf(".");
289
+ const hyphenIndex = id.lastIndexOf("-");
290
+ const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
291
+ const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
292
+ return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? {
293
+ name: id,
294
+ id
295
+ };
296
+ }
297
+
298
+ //#endregion
299
+ //#region ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
300
+ const execFileAsync = promisify(execFile);
301
+ const titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
302
+ async function defaultBrowser() {
303
+ if (process.platform === "darwin") {
304
+ const id = await defaultBrowserId();
305
+ return {
306
+ name: await bundleName(id),
307
+ id
308
+ };
309
+ }
310
+ if (process.platform === "linux") {
311
+ const { stdout } = await execFileAsync("xdg-mime", [
312
+ "query",
313
+ "default",
314
+ "x-scheme-handler/http"
315
+ ]);
316
+ const id = stdout.trim();
317
+ return {
318
+ name: titleize(id.replace(/.desktop$/, "").replace("-", " ")),
319
+ id
320
+ };
321
+ }
322
+ if (process.platform === "win32") return defaultBrowser$1();
323
+ throw new Error("Only macOS, Linux, and Windows are supported");
324
+ }
325
+
326
+ //#endregion
327
+ //#region ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
328
+ const isInSsh = Boolean(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY);
329
+
330
+ //#endregion
331
+ //#region ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
332
+ const fallbackAttemptSymbol = Symbol("fallbackAttempt");
333
+ const __dirname = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
334
+ const localXdgOpenPath = path.join(__dirname, "xdg-open");
335
+ const { platform: platform$1, arch: arch$1 } = process;
336
+ const tryEachApp = async (apps, opener) => {
337
+ if (apps.length === 0) return;
338
+ const errors = [];
339
+ for (const app of apps) try {
340
+ return await opener(app);
341
+ } catch (error) {
342
+ errors.push(error);
343
+ }
344
+ throw new AggregateError(errors, "Failed to open in all supported apps");
345
+ };
346
+ const baseOpen = async (options) => {
347
+ options = {
348
+ wait: false,
349
+ background: false,
350
+ newInstance: false,
351
+ allowNonzeroExitCode: false,
352
+ ...options
353
+ };
354
+ const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
355
+ delete options[fallbackAttemptSymbol];
356
+ if (Array.isArray(options.app)) return tryEachApp(options.app, (singleApp) => baseOpen({
357
+ ...options,
358
+ app: singleApp,
359
+ [fallbackAttemptSymbol]: true
360
+ }));
361
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
362
+ appArguments = [...appArguments];
363
+ if (Array.isArray(app)) return tryEachApp(app, (appName) => baseOpen({
364
+ ...options,
365
+ app: {
366
+ name: appName,
367
+ arguments: appArguments
368
+ },
369
+ [fallbackAttemptSymbol]: true
370
+ }));
371
+ if (app === "browser" || app === "browserPrivate") {
372
+ const ids = {
373
+ "com.google.chrome": "chrome",
374
+ "google-chrome.desktop": "chrome",
375
+ "com.brave.browser": "brave",
376
+ "org.mozilla.firefox": "firefox",
377
+ "firefox.desktop": "firefox",
378
+ "com.microsoft.msedge": "edge",
379
+ "com.microsoft.edge": "edge",
380
+ "com.microsoft.edgemac": "edge",
381
+ "microsoft-edge.desktop": "edge",
382
+ "com.apple.safari": "safari"
383
+ };
384
+ const flags = {
385
+ chrome: "--incognito",
386
+ brave: "--incognito",
387
+ firefox: "--private-window",
388
+ edge: "--inPrivate"
389
+ };
390
+ let browser;
391
+ if (is_wsl_default) {
392
+ const progId = await wslDefaultBrowser();
393
+ browser = _windowsBrowserProgIdMap.get(progId) ?? {};
394
+ } else browser = await defaultBrowser();
395
+ if (browser.id in ids) {
396
+ const browserName = ids[browser.id.toLowerCase()];
397
+ if (app === "browserPrivate") {
398
+ if (browserName === "safari") throw new Error("Safari doesn't support opening in private mode via command line");
399
+ appArguments.push(flags[browserName]);
400
+ }
401
+ return baseOpen({
402
+ ...options,
403
+ app: {
404
+ name: apps[browserName],
405
+ arguments: appArguments
406
+ }
407
+ });
408
+ }
409
+ throw new Error(`${browser.name} is not supported as a default browser`);
410
+ }
411
+ let command;
412
+ const cliArguments = [];
413
+ const childProcessOptions = {};
414
+ let shouldUseWindowsInWsl = false;
415
+ if (is_wsl_default && !isInsideContainer() && !isInSsh && !app) shouldUseWindowsInWsl = await canAccessPowerShell();
416
+ if (platform$1 === "darwin") {
417
+ command = "open";
418
+ if (options.wait) cliArguments.push("--wait-apps");
419
+ if (options.background) cliArguments.push("--background");
420
+ if (options.newInstance) cliArguments.push("--new");
421
+ if (app) cliArguments.push("-a", app);
422
+ } else if (platform$1 === "win32" || shouldUseWindowsInWsl) {
423
+ command = await powerShellPath();
424
+ cliArguments.push(...executePowerShell.argumentsPrefix);
425
+ if (!is_wsl_default) childProcessOptions.windowsVerbatimArguments = true;
426
+ if (is_wsl_default && options.target) options.target = await convertWslPathToWindows(options.target);
427
+ const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
428
+ if (options.wait) encodedArguments.push("-Wait");
429
+ if (app) {
430
+ encodedArguments.push(executePowerShell.escapeArgument(app));
431
+ if (options.target) appArguments.push(options.target);
432
+ } else if (options.target) encodedArguments.push(executePowerShell.escapeArgument(options.target));
433
+ if (appArguments.length > 0) {
434
+ appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
435
+ encodedArguments.push("-ArgumentList", appArguments.join(","));
436
+ }
437
+ options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
438
+ if (!options.wait) childProcessOptions.stdio = "ignore";
439
+ } else {
440
+ if (app) command = app;
441
+ else {
442
+ const isBundled = !__dirname || __dirname === "/";
443
+ let exeLocalXdgOpen = false;
444
+ try {
445
+ await fsp.access(localXdgOpenPath, constants.X_OK);
446
+ exeLocalXdgOpen = true;
447
+ } catch {}
448
+ command = process.versions.electron ?? (platform$1 === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
449
+ }
450
+ if (appArguments.length > 0) cliArguments.push(...appArguments);
451
+ if (!options.wait) {
452
+ childProcessOptions.stdio = "ignore";
453
+ childProcessOptions.detached = true;
454
+ }
455
+ }
456
+ if (platform$1 === "darwin" && appArguments.length > 0) cliArguments.push("--args", ...appArguments);
457
+ if (options.target) cliArguments.push(options.target);
458
+ const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
459
+ if (options.wait) return new Promise((resolve, reject) => {
460
+ subprocess.once("error", reject);
461
+ subprocess.once("close", (exitCode) => {
462
+ if (!options.allowNonzeroExitCode && exitCode !== 0) {
463
+ reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
464
+ return;
465
+ }
466
+ resolve(subprocess);
467
+ });
468
+ });
469
+ if (isFallbackAttempt) return new Promise((resolve, reject) => {
470
+ subprocess.once("error", reject);
471
+ subprocess.once("spawn", () => {
472
+ subprocess.once("close", (exitCode) => {
473
+ subprocess.off("error", reject);
474
+ if (exitCode !== 0) {
475
+ reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
476
+ return;
477
+ }
478
+ subprocess.unref();
479
+ resolve(subprocess);
480
+ });
481
+ });
482
+ });
483
+ subprocess.unref();
484
+ return new Promise((resolve, reject) => {
485
+ subprocess.once("error", reject);
486
+ subprocess.once("spawn", () => {
487
+ subprocess.off("error", reject);
488
+ resolve(subprocess);
489
+ });
490
+ });
491
+ };
492
+ const open = (target, options) => {
493
+ if (typeof target !== "string") throw new TypeError("Expected a `target`");
494
+ return baseOpen({
495
+ ...options,
496
+ target
497
+ });
498
+ };
499
+ function detectArchBinary(binary) {
500
+ if (typeof binary === "string" || Array.isArray(binary)) return binary;
501
+ const { [arch$1]: archBinary } = binary;
502
+ if (!archBinary) throw new Error(`${arch$1} is not supported`);
503
+ return archBinary;
504
+ }
505
+ function detectPlatformBinary({ [platform$1]: platformBinary }, { wsl } = {}) {
506
+ if (wsl && is_wsl_default) return detectArchBinary(wsl);
507
+ if (!platformBinary) throw new Error(`${platform$1} is not supported`);
508
+ return detectArchBinary(platformBinary);
509
+ }
510
+ const apps = {
511
+ browser: "browser",
512
+ browserPrivate: "browserPrivate"
513
+ };
514
+ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
515
+ darwin: "google chrome",
516
+ win32: "chrome",
517
+ linux: [
518
+ "google-chrome",
519
+ "google-chrome-stable",
520
+ "chromium",
521
+ "chromium-browser"
522
+ ]
523
+ }, { wsl: {
524
+ ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
525
+ x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
526
+ } }));
527
+ defineLazyProperty(apps, "brave", () => detectPlatformBinary({
528
+ darwin: "brave browser",
529
+ win32: "brave",
530
+ linux: ["brave-browser", "brave"]
531
+ }, { wsl: {
532
+ ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
533
+ x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
534
+ } }));
535
+ defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
536
+ darwin: "firefox",
537
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
538
+ linux: "firefox"
539
+ }, { wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe" }));
540
+ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
541
+ darwin: "microsoft edge",
542
+ win32: "msedge",
543
+ linux: ["microsoft-edge", "microsoft-edge-dev"]
544
+ }, { wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" }));
545
+ defineLazyProperty(apps, "safari", () => detectPlatformBinary({ darwin: "Safari" }));
546
+
547
+ //#endregion
548
+ export { open as default };