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