kfc-code-cli 0.0.1-alpha.2 → 0.0.1-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/main.mjs +3549 -3862
- package/dist/{multipart-parser-CetGDzPt.mjs → multipart-parser-OI2tZKyS.mjs} +1 -1
- package/dist/session-event-bus-Baiz630d.mjs +106 -0
- package/dist/{src-CzEfkVXq.mjs → src-CL9dVeBV.mjs} +2 -2
- package/package.json +4 -2
- package/dist/client-CdbQcqne.mjs +0 -2007
- package/dist/open-KsP3qi4-.mjs +0 -466
- package/dist/stdio-S3GL8wYq.mjs +0 -584
- package/dist/streamableHttp-D_Fc3kFI.mjs +0 -1530
- package/dist/types-CdOcSyeC.mjs +0 -1244
- /package/dist/{dist-CKY8wJId.mjs → dist-CsQLzhCC.mjs} +0 -0
- /package/dist/{from-BNWSEQzV.mjs → from-BG79vaL9.mjs} +0 -0
package/dist/open-KsP3qi4-.mjs
DELETED
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import Vt from "node:fs";
|
|
3
|
-
import jn, { constants as constants$1 } from "node:fs/promises";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
import childProcess, { execFile } from "node:child_process";
|
|
7
|
-
import os from "node:os";
|
|
8
|
-
import process from "node:process";
|
|
9
|
-
import { Buffer } from "node:buffer";
|
|
10
|
-
import { promisify } from "node:util";
|
|
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
|
-
Vt.statSync("/.dockerenv");
|
|
16
|
-
return true;
|
|
17
|
-
} catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function hasDockerCGroup() {
|
|
22
|
-
try {
|
|
23
|
-
return Vt.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
|
-
//#endregion
|
|
33
|
-
//#region ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
34
|
-
let cachedResult;
|
|
35
|
-
const hasContainerEnv = () => {
|
|
36
|
-
try {
|
|
37
|
-
Vt.statSync("/run/.containerenv");
|
|
38
|
-
return true;
|
|
39
|
-
} catch {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
function isInsideContainer() {
|
|
44
|
-
if (cachedResult === void 0) cachedResult = hasContainerEnv() || isDocker();
|
|
45
|
-
return cachedResult;
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
49
|
-
const isWsl = () => {
|
|
50
|
-
if (process.platform !== "linux") return false;
|
|
51
|
-
if (os.release().toLowerCase().includes("microsoft")) {
|
|
52
|
-
if (isInsideContainer()) return false;
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
if (Vt.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) return !isInsideContainer();
|
|
57
|
-
} catch {}
|
|
58
|
-
if (Vt.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || Vt.existsSync("/run/WSL")) return !isInsideContainer();
|
|
59
|
-
return false;
|
|
60
|
-
};
|
|
61
|
-
var is_wsl_default = process.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region ../../node_modules/.pnpm/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
|
|
64
|
-
const wslDrivesMountPoint = (() => {
|
|
65
|
-
const defaultMountPoint = "/mnt/";
|
|
66
|
-
let mountPoint;
|
|
67
|
-
return async function() {
|
|
68
|
-
if (mountPoint) return mountPoint;
|
|
69
|
-
const configFilePath = "/etc/wsl.conf";
|
|
70
|
-
let isConfigFileExists = false;
|
|
71
|
-
try {
|
|
72
|
-
await jn.access(configFilePath, constants$1.F_OK);
|
|
73
|
-
isConfigFileExists = true;
|
|
74
|
-
} catch {}
|
|
75
|
-
if (!isConfigFileExists) return defaultMountPoint;
|
|
76
|
-
const configContent = await jn.readFile(configFilePath, { encoding: "utf8" });
|
|
77
|
-
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
78
|
-
if (!configMountPoint) return defaultMountPoint;
|
|
79
|
-
mountPoint = configMountPoint.groups.mountPoint.trim();
|
|
80
|
-
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
81
|
-
return mountPoint;
|
|
82
|
-
};
|
|
83
|
-
})();
|
|
84
|
-
const powerShellPathFromWsl = async () => {
|
|
85
|
-
return `${await wslDrivesMountPoint()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
86
|
-
};
|
|
87
|
-
const powerShellPath = async () => {
|
|
88
|
-
if (is_wsl_default) return powerShellPathFromWsl();
|
|
89
|
-
return `${process.env.SYSTEMROOT || process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
90
|
-
};
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
|
|
93
|
-
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
94
|
-
const define = (value) => Object.defineProperty(object, propertyName, {
|
|
95
|
-
value,
|
|
96
|
-
enumerable: true,
|
|
97
|
-
writable: true
|
|
98
|
-
});
|
|
99
|
-
Object.defineProperty(object, propertyName, {
|
|
100
|
-
configurable: true,
|
|
101
|
-
enumerable: true,
|
|
102
|
-
get() {
|
|
103
|
-
const result = valueGetter();
|
|
104
|
-
define(result);
|
|
105
|
-
return result;
|
|
106
|
-
},
|
|
107
|
-
set(value) {
|
|
108
|
-
define(value);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
return object;
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
|
|
115
|
-
const execFileAsync$3 = promisify(execFile);
|
|
116
|
-
async function defaultBrowserId() {
|
|
117
|
-
if (process.platform !== "darwin") throw new Error("macOS only");
|
|
118
|
-
const { stdout } = await execFileAsync$3("defaults", [
|
|
119
|
-
"read",
|
|
120
|
-
"com.apple.LaunchServices/com.apple.launchservices.secure",
|
|
121
|
-
"LSHandlers"
|
|
122
|
-
]);
|
|
123
|
-
const browserId = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout)?.groups.id ?? "com.apple.Safari";
|
|
124
|
-
if (browserId === "com.apple.safari") return "com.apple.Safari";
|
|
125
|
-
return browserId;
|
|
126
|
-
}
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
129
|
-
const execFileAsync$2 = promisify(execFile);
|
|
130
|
-
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
131
|
-
if (process.platform !== "darwin") throw new Error("macOS only");
|
|
132
|
-
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
133
|
-
const execOptions = {};
|
|
134
|
-
if (signal) execOptions.signal = signal;
|
|
135
|
-
const { stdout } = await execFileAsync$2("osascript", [
|
|
136
|
-
"-e",
|
|
137
|
-
script,
|
|
138
|
-
outputArguments
|
|
139
|
-
], execOptions);
|
|
140
|
-
return stdout.trim();
|
|
141
|
-
}
|
|
142
|
-
//#endregion
|
|
143
|
-
//#region ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
|
|
144
|
-
async function bundleName(bundleId) {
|
|
145
|
-
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")`);
|
|
146
|
-
}
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js
|
|
149
|
-
const execFileAsync$1 = promisify(execFile);
|
|
150
|
-
const windowsBrowserProgIds = {
|
|
151
|
-
MSEdgeHTM: {
|
|
152
|
-
name: "Edge",
|
|
153
|
-
id: "com.microsoft.edge"
|
|
154
|
-
},
|
|
155
|
-
MSEdgeBHTML: {
|
|
156
|
-
name: "Edge Beta",
|
|
157
|
-
id: "com.microsoft.edge.beta"
|
|
158
|
-
},
|
|
159
|
-
MSEdgeDHTML: {
|
|
160
|
-
name: "Edge Dev",
|
|
161
|
-
id: "com.microsoft.edge.dev"
|
|
162
|
-
},
|
|
163
|
-
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
|
|
164
|
-
name: "Edge",
|
|
165
|
-
id: "com.microsoft.edge.old"
|
|
166
|
-
},
|
|
167
|
-
ChromeHTML: {
|
|
168
|
-
name: "Chrome",
|
|
169
|
-
id: "com.google.chrome"
|
|
170
|
-
},
|
|
171
|
-
ChromeBHTML: {
|
|
172
|
-
name: "Chrome Beta",
|
|
173
|
-
id: "com.google.chrome.beta"
|
|
174
|
-
},
|
|
175
|
-
ChromeDHTML: {
|
|
176
|
-
name: "Chrome Dev",
|
|
177
|
-
id: "com.google.chrome.dev"
|
|
178
|
-
},
|
|
179
|
-
ChromiumHTM: {
|
|
180
|
-
name: "Chromium",
|
|
181
|
-
id: "org.chromium.Chromium"
|
|
182
|
-
},
|
|
183
|
-
BraveHTML: {
|
|
184
|
-
name: "Brave",
|
|
185
|
-
id: "com.brave.Browser"
|
|
186
|
-
},
|
|
187
|
-
BraveBHTML: {
|
|
188
|
-
name: "Brave Beta",
|
|
189
|
-
id: "com.brave.Browser.beta"
|
|
190
|
-
},
|
|
191
|
-
BraveDHTML: {
|
|
192
|
-
name: "Brave Dev",
|
|
193
|
-
id: "com.brave.Browser.dev"
|
|
194
|
-
},
|
|
195
|
-
BraveSSHTM: {
|
|
196
|
-
name: "Brave Nightly",
|
|
197
|
-
id: "com.brave.Browser.nightly"
|
|
198
|
-
},
|
|
199
|
-
FirefoxURL: {
|
|
200
|
-
name: "Firefox",
|
|
201
|
-
id: "org.mozilla.firefox"
|
|
202
|
-
},
|
|
203
|
-
OperaStable: {
|
|
204
|
-
name: "Opera",
|
|
205
|
-
id: "com.operasoftware.Opera"
|
|
206
|
-
},
|
|
207
|
-
VivaldiHTM: {
|
|
208
|
-
name: "Vivaldi",
|
|
209
|
-
id: "com.vivaldi.Vivaldi"
|
|
210
|
-
},
|
|
211
|
-
"IE.HTTP": {
|
|
212
|
-
name: "Internet Explorer",
|
|
213
|
-
id: "com.microsoft.ie"
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
new Map(Object.entries(windowsBrowserProgIds));
|
|
217
|
-
var UnknownBrowserError = class extends Error {};
|
|
218
|
-
async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
|
|
219
|
-
const { stdout } = await _execFileAsync("reg", [
|
|
220
|
-
"QUERY",
|
|
221
|
-
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
222
|
-
"/v",
|
|
223
|
-
"ProgId"
|
|
224
|
-
]);
|
|
225
|
-
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
226
|
-
if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
227
|
-
const { id } = match.groups;
|
|
228
|
-
const dotIndex = id.lastIndexOf(".");
|
|
229
|
-
const hyphenIndex = id.lastIndexOf("-");
|
|
230
|
-
const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
|
|
231
|
-
const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
|
|
232
|
-
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? {
|
|
233
|
-
name: id,
|
|
234
|
-
id
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
//#endregion
|
|
238
|
-
//#region ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
239
|
-
const execFileAsync = promisify(execFile);
|
|
240
|
-
const titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
241
|
-
async function defaultBrowser() {
|
|
242
|
-
if (process.platform === "darwin") {
|
|
243
|
-
const id = await defaultBrowserId();
|
|
244
|
-
return {
|
|
245
|
-
name: await bundleName(id),
|
|
246
|
-
id
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
if (process.platform === "linux") {
|
|
250
|
-
const { stdout } = await execFileAsync("xdg-mime", [
|
|
251
|
-
"query",
|
|
252
|
-
"default",
|
|
253
|
-
"x-scheme-handler/http"
|
|
254
|
-
]);
|
|
255
|
-
const id = stdout.trim();
|
|
256
|
-
return {
|
|
257
|
-
name: titleize(id.replace(/.desktop$/, "").replace("-", " ")),
|
|
258
|
-
id
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
if (process.platform === "win32") return defaultBrowser$1();
|
|
262
|
-
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
263
|
-
}
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
266
|
-
const execFile$1 = promisify(childProcess.execFile);
|
|
267
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
268
|
-
const localXdgOpenPath = path.join(__dirname, "xdg-open");
|
|
269
|
-
const { platform, arch: arch$1 } = process;
|
|
270
|
-
/**
|
|
271
|
-
Get the default browser name in Windows from WSL.
|
|
272
|
-
|
|
273
|
-
@returns {Promise<string>} Browser name.
|
|
274
|
-
*/
|
|
275
|
-
async function getWindowsDefaultBrowserFromWsl() {
|
|
276
|
-
const powershellPath = await powerShellPath();
|
|
277
|
-
const rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
278
|
-
const { stdout } = await execFile$1(powershellPath, [
|
|
279
|
-
"-NoProfile",
|
|
280
|
-
"-NonInteractive",
|
|
281
|
-
"-ExecutionPolicy",
|
|
282
|
-
"Bypass",
|
|
283
|
-
"-EncodedCommand",
|
|
284
|
-
Buffer.from(rawCommand, "utf16le").toString("base64")
|
|
285
|
-
], { encoding: "utf8" });
|
|
286
|
-
const progId = stdout.trim();
|
|
287
|
-
const browserMap = {
|
|
288
|
-
ChromeHTML: "com.google.chrome",
|
|
289
|
-
BraveHTML: "com.brave.Browser",
|
|
290
|
-
MSEdgeHTM: "com.microsoft.edge",
|
|
291
|
-
FirefoxURL: "org.mozilla.firefox"
|
|
292
|
-
};
|
|
293
|
-
return browserMap[progId] ? { id: browserMap[progId] } : {};
|
|
294
|
-
}
|
|
295
|
-
const pTryEach = async (array, mapper) => {
|
|
296
|
-
let latestError;
|
|
297
|
-
for (const item of array) try {
|
|
298
|
-
return await mapper(item);
|
|
299
|
-
} catch (error) {
|
|
300
|
-
latestError = error;
|
|
301
|
-
}
|
|
302
|
-
throw latestError;
|
|
303
|
-
};
|
|
304
|
-
const baseOpen = async (options) => {
|
|
305
|
-
options = {
|
|
306
|
-
wait: false,
|
|
307
|
-
background: false,
|
|
308
|
-
newInstance: false,
|
|
309
|
-
allowNonzeroExitCode: false,
|
|
310
|
-
...options
|
|
311
|
-
};
|
|
312
|
-
if (Array.isArray(options.app)) return pTryEach(options.app, (singleApp) => baseOpen({
|
|
313
|
-
...options,
|
|
314
|
-
app: singleApp
|
|
315
|
-
}));
|
|
316
|
-
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
317
|
-
appArguments = [...appArguments];
|
|
318
|
-
if (Array.isArray(app)) return pTryEach(app, (appName) => baseOpen({
|
|
319
|
-
...options,
|
|
320
|
-
app: {
|
|
321
|
-
name: appName,
|
|
322
|
-
arguments: appArguments
|
|
323
|
-
}
|
|
324
|
-
}));
|
|
325
|
-
if (app === "browser" || app === "browserPrivate") {
|
|
326
|
-
const ids = {
|
|
327
|
-
"com.google.chrome": "chrome",
|
|
328
|
-
"google-chrome.desktop": "chrome",
|
|
329
|
-
"com.brave.Browser": "brave",
|
|
330
|
-
"org.mozilla.firefox": "firefox",
|
|
331
|
-
"firefox.desktop": "firefox",
|
|
332
|
-
"com.microsoft.msedge": "edge",
|
|
333
|
-
"com.microsoft.edge": "edge",
|
|
334
|
-
"com.microsoft.edgemac": "edge",
|
|
335
|
-
"microsoft-edge.desktop": "edge"
|
|
336
|
-
};
|
|
337
|
-
const flags = {
|
|
338
|
-
chrome: "--incognito",
|
|
339
|
-
brave: "--incognito",
|
|
340
|
-
firefox: "--private-window",
|
|
341
|
-
edge: "--inPrivate"
|
|
342
|
-
};
|
|
343
|
-
const browser = is_wsl_default ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser();
|
|
344
|
-
if (browser.id in ids) {
|
|
345
|
-
const browserName = ids[browser.id];
|
|
346
|
-
if (app === "browserPrivate") appArguments.push(flags[browserName]);
|
|
347
|
-
return baseOpen({
|
|
348
|
-
...options,
|
|
349
|
-
app: {
|
|
350
|
-
name: apps[browserName],
|
|
351
|
-
arguments: appArguments
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
356
|
-
}
|
|
357
|
-
let command;
|
|
358
|
-
const cliArguments = [];
|
|
359
|
-
const childProcessOptions = {};
|
|
360
|
-
if (platform === "darwin") {
|
|
361
|
-
command = "open";
|
|
362
|
-
if (options.wait) cliArguments.push("--wait-apps");
|
|
363
|
-
if (options.background) cliArguments.push("--background");
|
|
364
|
-
if (options.newInstance) cliArguments.push("--new");
|
|
365
|
-
if (app) cliArguments.push("-a", app);
|
|
366
|
-
} else if (platform === "win32" || is_wsl_default && !isInsideContainer() && !app) {
|
|
367
|
-
command = await powerShellPath();
|
|
368
|
-
cliArguments.push("-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-EncodedCommand");
|
|
369
|
-
if (!is_wsl_default) childProcessOptions.windowsVerbatimArguments = true;
|
|
370
|
-
const encodedArguments = ["Start"];
|
|
371
|
-
if (options.wait) encodedArguments.push("-Wait");
|
|
372
|
-
if (app) {
|
|
373
|
-
encodedArguments.push(`"\`"${app}\`""`);
|
|
374
|
-
if (options.target) appArguments.push(options.target);
|
|
375
|
-
} else if (options.target) encodedArguments.push(`"${options.target}"`);
|
|
376
|
-
if (appArguments.length > 0) {
|
|
377
|
-
appArguments = appArguments.map((argument) => `"\`"${argument}\`""`);
|
|
378
|
-
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
379
|
-
}
|
|
380
|
-
options.target = Buffer.from(encodedArguments.join(" "), "utf16le").toString("base64");
|
|
381
|
-
} else {
|
|
382
|
-
if (app) command = app;
|
|
383
|
-
else {
|
|
384
|
-
const isBundled = !__dirname || __dirname === "/";
|
|
385
|
-
let exeLocalXdgOpen = false;
|
|
386
|
-
try {
|
|
387
|
-
await jn.access(localXdgOpenPath, constants$1.X_OK);
|
|
388
|
-
exeLocalXdgOpen = true;
|
|
389
|
-
} catch {}
|
|
390
|
-
command = process.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
|
|
391
|
-
}
|
|
392
|
-
if (appArguments.length > 0) cliArguments.push(...appArguments);
|
|
393
|
-
if (!options.wait) {
|
|
394
|
-
childProcessOptions.stdio = "ignore";
|
|
395
|
-
childProcessOptions.detached = true;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
if (platform === "darwin" && appArguments.length > 0) cliArguments.push("--args", ...appArguments);
|
|
399
|
-
if (options.target) cliArguments.push(options.target);
|
|
400
|
-
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
401
|
-
if (options.wait) return new Promise((resolve, reject) => {
|
|
402
|
-
subprocess.once("error", reject);
|
|
403
|
-
subprocess.once("close", (exitCode) => {
|
|
404
|
-
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
405
|
-
reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
resolve(subprocess);
|
|
409
|
-
});
|
|
410
|
-
});
|
|
411
|
-
subprocess.unref();
|
|
412
|
-
return subprocess;
|
|
413
|
-
};
|
|
414
|
-
const open = (target, options) => {
|
|
415
|
-
if (typeof target !== "string") throw new TypeError("Expected a `target`");
|
|
416
|
-
return baseOpen({
|
|
417
|
-
...options,
|
|
418
|
-
target
|
|
419
|
-
});
|
|
420
|
-
};
|
|
421
|
-
function detectArchBinary(binary) {
|
|
422
|
-
if (typeof binary === "string" || Array.isArray(binary)) return binary;
|
|
423
|
-
const { [arch$1]: archBinary } = binary;
|
|
424
|
-
if (!archBinary) throw new Error(`${arch$1} is not supported`);
|
|
425
|
-
return archBinary;
|
|
426
|
-
}
|
|
427
|
-
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
|
|
428
|
-
if (wsl && is_wsl_default) return detectArchBinary(wsl);
|
|
429
|
-
if (!platformBinary) throw new Error(`${platform} is not supported`);
|
|
430
|
-
return detectArchBinary(platformBinary);
|
|
431
|
-
}
|
|
432
|
-
const apps = {};
|
|
433
|
-
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
434
|
-
darwin: "google chrome",
|
|
435
|
-
win32: "chrome",
|
|
436
|
-
linux: [
|
|
437
|
-
"google-chrome",
|
|
438
|
-
"google-chrome-stable",
|
|
439
|
-
"chromium"
|
|
440
|
-
]
|
|
441
|
-
}, { wsl: {
|
|
442
|
-
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
443
|
-
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
444
|
-
} }));
|
|
445
|
-
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
446
|
-
darwin: "brave browser",
|
|
447
|
-
win32: "brave",
|
|
448
|
-
linux: ["brave-browser", "brave"]
|
|
449
|
-
}, { wsl: {
|
|
450
|
-
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
451
|
-
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
452
|
-
} }));
|
|
453
|
-
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
454
|
-
darwin: "firefox",
|
|
455
|
-
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
456
|
-
linux: "firefox"
|
|
457
|
-
}, { wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe" }));
|
|
458
|
-
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
459
|
-
darwin: "microsoft edge",
|
|
460
|
-
win32: "msedge",
|
|
461
|
-
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
462
|
-
}, { wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" }));
|
|
463
|
-
defineLazyProperty(apps, "browser", () => "browser");
|
|
464
|
-
defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
|
|
465
|
-
//#endregion
|
|
466
|
-
export { open as default };
|