@rsdoctor/sdk 1.5.17 → 1.5.18
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 +181 -95
- package/dist/{1~765.cjs → 1~184.cjs} +206 -118
- package/dist/612.js +33 -0
- package/dist/index.cjs +27 -13
- package/dist/index.js +19 -33
- package/dist/sdk/server/security.d.cts +1 -0
- package/dist/sdk/server/security.d.ts +1 -0
- package/package.json +6 -6
package/dist/0~open.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
let isDockerCached, cachedResult, mountPoint, defaultMountPoint;
|
|
1
|
+
let isDockerCached, cachedResult, canAccessPowerShellPromise, mountPoint, defaultMountPoint;
|
|
2
2
|
import "node:module";
|
|
3
3
|
import node_process from "node:process";
|
|
4
|
-
import { Buffer } from "node:buffer";
|
|
5
4
|
import node_path from "node:path";
|
|
6
5
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
import {
|
|
8
|
-
import node_child_process, { execFile } from "node:child_process";
|
|
6
|
+
import node_child_process, { execFile as external_node_child_process_execFile } from "node:child_process";
|
|
9
7
|
import promises, { constants } from "node:fs/promises";
|
|
8
|
+
import { promisify } from "node:util";
|
|
10
9
|
import node_os from "node:os";
|
|
11
10
|
import node_fs from "node:fs";
|
|
11
|
+
import { Buffer } from "node:buffer";
|
|
12
12
|
function isInsideContainer() {
|
|
13
13
|
return void 0 === cachedResult && (cachedResult = (()=>{
|
|
14
14
|
try {
|
|
@@ -38,21 +38,69 @@ let isWsl = ()=>{
|
|
|
38
38
|
} catch {
|
|
39
39
|
return !1;
|
|
40
40
|
}
|
|
41
|
-
}, is_wsl = node_process.env.__IS_WSL_TEST__ ? isWsl : isWsl(),
|
|
41
|
+
}, is_wsl = node_process.env.__IS_WSL_TEST__ ? isWsl : isWsl(), execFile = promisify(node_child_process.execFile), powerShellPath = ()=>`${node_process.env.SYSTEMROOT || node_process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {})=>{
|
|
42
|
+
let { powerShellPath: psPath, ...execFileOptions } = options, encodedCommand = executePowerShell.encodeCommand(command);
|
|
43
|
+
return execFile(psPath ?? powerShellPath(), [
|
|
44
|
+
...executePowerShell.argumentsPrefix,
|
|
45
|
+
encodedCommand
|
|
46
|
+
], {
|
|
47
|
+
encoding: 'utf8',
|
|
48
|
+
...execFileOptions
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
executePowerShell.argumentsPrefix = [
|
|
52
|
+
'-NoProfile',
|
|
53
|
+
'-NonInteractive',
|
|
54
|
+
'-ExecutionPolicy',
|
|
55
|
+
'Bypass',
|
|
56
|
+
'-EncodedCommand'
|
|
57
|
+
], executePowerShell.encodeCommand = (command)=>Buffer.from(command, 'utf16le').toString('base64'), executePowerShell.escapeArgument = (value)=>`'${String(value).replaceAll('\'', '\'\'')}'`;
|
|
58
|
+
let wsl_utils_execFile = promisify(node_child_process.execFile), wslDrivesMountPoint = (defaultMountPoint = '/mnt/', async function() {
|
|
42
59
|
if (mountPoint) return mountPoint;
|
|
43
60
|
let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
|
|
44
61
|
try {
|
|
45
62
|
await promises.access(configFilePath, constants.F_OK), isConfigFileExists = !0;
|
|
46
63
|
} catch {}
|
|
47
64
|
if (!isConfigFileExists) return defaultMountPoint;
|
|
48
|
-
let
|
|
65
|
+
let parsedMountPoint = function(content) {
|
|
66
|
+
for (let line of content.split('\n')){
|
|
67
|
+
if (/^\s*#/.test(line)) continue;
|
|
68
|
+
let match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
69
|
+
if (match) return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, '');
|
|
70
|
+
}
|
|
71
|
+
}(await promises.readFile(configFilePath, {
|
|
49
72
|
encoding: 'utf8'
|
|
50
|
-
})
|
|
51
|
-
return
|
|
73
|
+
}));
|
|
74
|
+
return void 0 === parsedMountPoint ? defaultMountPoint : mountPoint = (mountPoint = parsedMountPoint).endsWith('/') ? mountPoint : `${mountPoint}/`;
|
|
52
75
|
}), powerShellPathFromWsl = async ()=>{
|
|
53
76
|
let mountPoint = await wslDrivesMountPoint();
|
|
54
77
|
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
55
|
-
},
|
|
78
|
+
}, wsl_utils_powerShellPath = is_wsl ? powerShellPathFromWsl : powerShellPath, wsl_utils_canAccessPowerShell = async ()=>canAccessPowerShellPromise ??= (async ()=>{
|
|
79
|
+
try {
|
|
80
|
+
let psPath = await wsl_utils_powerShellPath();
|
|
81
|
+
return await promises.access(psPath, constants.X_OK), !0;
|
|
82
|
+
} catch {
|
|
83
|
+
return !1;
|
|
84
|
+
}
|
|
85
|
+
})(), wslDefaultBrowser = async ()=>{
|
|
86
|
+
let psPath = await wsl_utils_powerShellPath(), command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { stdout } = await executePowerShell(command, {
|
|
87
|
+
powerShellPath: psPath
|
|
88
|
+
});
|
|
89
|
+
return stdout.trim();
|
|
90
|
+
}, convertWslPathToWindows = async (path)=>{
|
|
91
|
+
if (/^[a-z]+:\/\//i.test(path)) return path;
|
|
92
|
+
try {
|
|
93
|
+
let { stdout } = await wsl_utils_execFile('wslpath', [
|
|
94
|
+
'-aw',
|
|
95
|
+
path
|
|
96
|
+
], {
|
|
97
|
+
encoding: 'utf8'
|
|
98
|
+
});
|
|
99
|
+
return stdout.trim();
|
|
100
|
+
} catch {
|
|
101
|
+
return path;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
56
104
|
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
57
105
|
let define = (value)=>Object.defineProperty(object, propertyName, {
|
|
58
106
|
value,
|
|
@@ -71,7 +119,7 @@ function defineLazyProperty(object, propertyName, valueGetter) {
|
|
|
71
119
|
}
|
|
72
120
|
}), object;
|
|
73
121
|
}
|
|
74
|
-
let execFileAsync = promisify(
|
|
122
|
+
let execFileAsync = promisify(external_node_child_process_execFile);
|
|
75
123
|
async function defaultBrowserId() {
|
|
76
124
|
if ('darwin' !== node_process.platform) throw Error('macOS only');
|
|
77
125
|
let { stdout } = await execFileAsync('defaults', [
|
|
@@ -81,7 +129,7 @@ async function defaultBrowserId() {
|
|
|
81
129
|
]), match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
82
130
|
return match?.groups.id ?? 'com.apple.Safari';
|
|
83
131
|
}
|
|
84
|
-
let run_applescript_execFileAsync = promisify(
|
|
132
|
+
let run_applescript_execFileAsync = promisify(external_node_child_process_execFile);
|
|
85
133
|
async function runAppleScript(script, { humanReadableOutput = !0 } = {}) {
|
|
86
134
|
if ('darwin' !== node_process.platform) throw Error('macOS only');
|
|
87
135
|
let { stdout } = await run_applescript_execFileAsync("osascript", [
|
|
@@ -96,31 +144,39 @@ async function runAppleScript(script, { humanReadableOutput = !0 } = {}) {
|
|
|
96
144
|
async function bundleName(bundleId) {
|
|
97
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")`);
|
|
98
146
|
}
|
|
99
|
-
let windows_execFileAsync = promisify(
|
|
100
|
-
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
|
|
101
|
-
name: 'Edge',
|
|
102
|
-
id: 'com.microsoft.edge.old'
|
|
103
|
-
},
|
|
104
|
-
MSEdgeDHTML: {
|
|
105
|
-
name: 'Edge',
|
|
106
|
-
id: 'com.microsoft.edge'
|
|
107
|
-
},
|
|
147
|
+
let windows_execFileAsync = promisify(external_node_child_process_execFile), windowsBrowserProgIds = {
|
|
108
148
|
MSEdgeHTM: {
|
|
109
149
|
name: 'Edge',
|
|
110
150
|
id: 'com.microsoft.edge'
|
|
111
151
|
},
|
|
112
|
-
|
|
113
|
-
name: '
|
|
114
|
-
id: 'com.microsoft.
|
|
152
|
+
MSEdgeBHTML: {
|
|
153
|
+
name: 'Edge Beta',
|
|
154
|
+
id: 'com.microsoft.edge.beta'
|
|
115
155
|
},
|
|
116
|
-
|
|
117
|
-
name: '
|
|
118
|
-
id: '
|
|
156
|
+
MSEdgeDHTML: {
|
|
157
|
+
name: 'Edge Dev',
|
|
158
|
+
id: 'com.microsoft.edge.dev'
|
|
159
|
+
},
|
|
160
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
|
|
161
|
+
name: 'Edge',
|
|
162
|
+
id: 'com.microsoft.edge.old'
|
|
119
163
|
},
|
|
120
164
|
ChromeHTML: {
|
|
121
165
|
name: 'Chrome',
|
|
122
166
|
id: 'com.google.chrome'
|
|
123
167
|
},
|
|
168
|
+
ChromeBHTML: {
|
|
169
|
+
name: 'Chrome Beta',
|
|
170
|
+
id: 'com.google.chrome.beta'
|
|
171
|
+
},
|
|
172
|
+
ChromeDHTML: {
|
|
173
|
+
name: 'Chrome Dev',
|
|
174
|
+
id: 'com.google.chrome.dev'
|
|
175
|
+
},
|
|
176
|
+
ChromiumHTM: {
|
|
177
|
+
name: 'Chromium',
|
|
178
|
+
id: 'org.chromium.Chromium'
|
|
179
|
+
},
|
|
124
180
|
BraveHTML: {
|
|
125
181
|
name: 'Brave',
|
|
126
182
|
id: 'com.brave.Browser'
|
|
@@ -129,11 +185,31 @@ let windows_execFileAsync = promisify(execFile), windowsBrowserProgIds = {
|
|
|
129
185
|
name: 'Brave Beta',
|
|
130
186
|
id: 'com.brave.Browser.beta'
|
|
131
187
|
},
|
|
188
|
+
BraveDHTML: {
|
|
189
|
+
name: 'Brave Dev',
|
|
190
|
+
id: 'com.brave.Browser.dev'
|
|
191
|
+
},
|
|
132
192
|
BraveSSHTM: {
|
|
133
193
|
name: 'Brave Nightly',
|
|
134
194
|
id: 'com.brave.Browser.nightly'
|
|
195
|
+
},
|
|
196
|
+
FirefoxURL: {
|
|
197
|
+
name: 'Firefox',
|
|
198
|
+
id: 'org.mozilla.firefox'
|
|
199
|
+
},
|
|
200
|
+
OperaStable: {
|
|
201
|
+
name: 'Opera',
|
|
202
|
+
id: 'com.operasoftware.Opera'
|
|
203
|
+
},
|
|
204
|
+
VivaldiHTM: {
|
|
205
|
+
name: 'Vivaldi',
|
|
206
|
+
id: 'com.vivaldi.Vivaldi'
|
|
207
|
+
},
|
|
208
|
+
'IE.HTTP': {
|
|
209
|
+
name: 'Internet Explorer',
|
|
210
|
+
id: 'com.microsoft.ie'
|
|
135
211
|
}
|
|
136
|
-
};
|
|
212
|
+
}, _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
137
213
|
class UnknownBrowserError extends Error {
|
|
138
214
|
}
|
|
139
215
|
async function defaultBrowser(_execFileAsync = windows_execFileAsync) {
|
|
@@ -144,11 +220,13 @@ async function defaultBrowser(_execFileAsync = windows_execFileAsync) {
|
|
|
144
220
|
'ProgId'
|
|
145
221
|
]), match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
146
222
|
if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
147
|
-
let { id } = match.groups,
|
|
148
|
-
|
|
149
|
-
|
|
223
|
+
let { id } = match.groups, dotIndex = id.lastIndexOf('.'), hyphenIndex = id.lastIndexOf('-'), baseIdByDot = -1 === dotIndex ? void 0 : id.slice(0, dotIndex), baseIdByHyphen = -1 === hyphenIndex ? void 0 : id.slice(0, hyphenIndex);
|
|
224
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? {
|
|
225
|
+
name: id,
|
|
226
|
+
id
|
|
227
|
+
};
|
|
150
228
|
}
|
|
151
|
-
let default_browser_execFileAsync = promisify(
|
|
229
|
+
let default_browser_execFileAsync = promisify(external_node_child_process_execFile);
|
|
152
230
|
async function default_browser_defaultBrowser() {
|
|
153
231
|
if ('darwin' === node_process.platform) {
|
|
154
232
|
let id = await defaultBrowserId();
|
|
@@ -171,89 +249,87 @@ async function default_browser_defaultBrowser() {
|
|
|
171
249
|
if ('win32' === node_process.platform) return defaultBrowser();
|
|
172
250
|
throw Error('Only macOS, Linux, and Windows are supported');
|
|
173
251
|
}
|
|
174
|
-
let
|
|
175
|
-
|
|
176
|
-
let
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
'-ExecutionPolicy',
|
|
180
|
-
'Bypass',
|
|
181
|
-
'-EncodedCommand',
|
|
182
|
-
encodedCommand
|
|
183
|
-
], {
|
|
184
|
-
encoding: 'utf8'
|
|
185
|
-
}), progId = stdout.trim(), browserMap = {
|
|
186
|
-
ChromeHTML: 'com.google.chrome',
|
|
187
|
-
BraveHTML: 'com.brave.Browser',
|
|
188
|
-
MSEdgeHTM: 'com.microsoft.edge',
|
|
189
|
-
FirefoxURL: 'org.mozilla.firefox'
|
|
190
|
-
};
|
|
191
|
-
return browserMap[progId] ? {
|
|
192
|
-
id: browserMap[progId]
|
|
193
|
-
} : {};
|
|
194
|
-
}
|
|
195
|
-
let pTryEach = async (array, mapper)=>{
|
|
196
|
-
let latestError;
|
|
197
|
-
for (let item of array)try {
|
|
198
|
-
return await mapper(item);
|
|
252
|
+
let isInSsh = !!(node_process.env.SSH_CONNECTION || node_process.env.SSH_CLIENT || node_process.env.SSH_TTY), fallbackAttemptSymbol = Symbol('fallbackAttempt'), open_dirname = import.meta.url ? node_path.dirname(fileURLToPath(import.meta.url)) : '', localXdgOpenPath = node_path.join(open_dirname, 'xdg-open'), { platform: platform, arch: arch } = node_process, tryEachApp = async (apps, opener)=>{
|
|
253
|
+
if (0 === apps.length) return;
|
|
254
|
+
let errors = [];
|
|
255
|
+
for (let app of apps)try {
|
|
256
|
+
return await opener(app);
|
|
199
257
|
} catch (error) {
|
|
200
|
-
|
|
258
|
+
errors.push(error);
|
|
201
259
|
}
|
|
202
|
-
throw
|
|
260
|
+
throw AggregateError(errors, 'Failed to open in all supported apps');
|
|
203
261
|
}, baseOpen = async (options)=>{
|
|
204
|
-
let command
|
|
205
|
-
if (Array.isArray((options = {
|
|
262
|
+
let command, isFallbackAttempt = !0 === (options = {
|
|
206
263
|
wait: !1,
|
|
207
264
|
background: !1,
|
|
208
265
|
newInstance: !1,
|
|
209
266
|
allowNonzeroExitCode: !1,
|
|
210
267
|
...options
|
|
211
|
-
})
|
|
268
|
+
})[fallbackAttemptSymbol];
|
|
269
|
+
if (delete options[fallbackAttemptSymbol], Array.isArray(options.app)) return tryEachApp(options.app, (singleApp)=>baseOpen({
|
|
212
270
|
...options,
|
|
213
|
-
app: singleApp
|
|
271
|
+
app: singleApp,
|
|
272
|
+
[fallbackAttemptSymbol]: !0
|
|
214
273
|
}));
|
|
215
274
|
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
216
275
|
if (appArguments = [
|
|
217
276
|
...appArguments
|
|
218
|
-
], Array.isArray(app)) return
|
|
277
|
+
], Array.isArray(app)) return tryEachApp(app, (appName)=>baseOpen({
|
|
219
278
|
...options,
|
|
220
279
|
app: {
|
|
221
280
|
name: appName,
|
|
222
281
|
arguments: appArguments
|
|
223
|
-
}
|
|
282
|
+
},
|
|
283
|
+
[fallbackAttemptSymbol]: !0
|
|
224
284
|
}));
|
|
225
285
|
if ('browser' === app || 'browserPrivate' === app) {
|
|
226
|
-
let ids = {
|
|
286
|
+
let browser, ids = {
|
|
227
287
|
'com.google.chrome': 'chrome',
|
|
228
288
|
'google-chrome.desktop': 'chrome',
|
|
229
|
-
'com.brave.
|
|
289
|
+
'com.brave.browser': 'brave',
|
|
230
290
|
'org.mozilla.firefox': 'firefox',
|
|
231
291
|
'firefox.desktop': 'firefox',
|
|
232
292
|
'com.microsoft.msedge': 'edge',
|
|
233
293
|
'com.microsoft.edge': 'edge',
|
|
234
294
|
'com.microsoft.edgemac': 'edge',
|
|
235
|
-
'microsoft-edge.desktop': 'edge'
|
|
236
|
-
|
|
295
|
+
'microsoft-edge.desktop': 'edge',
|
|
296
|
+
'com.apple.safari': 'safari'
|
|
297
|
+
};
|
|
298
|
+
if (is_wsl) {
|
|
299
|
+
let progId = await wslDefaultBrowser();
|
|
300
|
+
browser = _windowsBrowserProgIdMap.get(progId) ?? {};
|
|
301
|
+
} else browser = await default_browser_defaultBrowser();
|
|
237
302
|
if (browser.id in ids) {
|
|
238
|
-
let browserName = ids[browser.id];
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
303
|
+
let browserName = ids[browser.id.toLowerCase()];
|
|
304
|
+
if ('browserPrivate' === app) {
|
|
305
|
+
if ('safari' === browserName) throw Error('Safari doesn\'t support opening in private mode via command line');
|
|
306
|
+
appArguments.push({
|
|
307
|
+
chrome: '--incognito',
|
|
308
|
+
brave: '--incognito',
|
|
309
|
+
firefox: '--private-window',
|
|
310
|
+
edge: '--inPrivate'
|
|
311
|
+
}[browserName]);
|
|
312
|
+
}
|
|
313
|
+
return baseOpen({
|
|
245
314
|
...options,
|
|
246
315
|
app: {
|
|
247
|
-
name:
|
|
316
|
+
name: open_apps[browserName],
|
|
248
317
|
arguments: appArguments
|
|
249
318
|
}
|
|
250
319
|
});
|
|
251
320
|
}
|
|
252
321
|
throw Error(`${browser.name} is not supported as a default browser`);
|
|
253
322
|
}
|
|
254
|
-
let cliArguments = [], childProcessOptions = {};
|
|
255
|
-
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);
|
|
256
|
-
else if ('win32'
|
|
323
|
+
let cliArguments = [], childProcessOptions = {}, shouldUseWindowsInWsl = !1;
|
|
324
|
+
if (!is_wsl || isInsideContainer() || isInSsh || app || (shouldUseWindowsInWsl = await wsl_utils_canAccessPowerShell()), '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);
|
|
325
|
+
else if ('win32' === platform || shouldUseWindowsInWsl) {
|
|
326
|
+
command = await wsl_utils_powerShellPath(), cliArguments.push(...executePowerShell.argumentsPrefix), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0), is_wsl && options.target && (options.target = await convertWslPathToWindows(options.target));
|
|
327
|
+
let encodedArguments = [
|
|
328
|
+
'$ProgressPreference = \'SilentlyContinue\';',
|
|
329
|
+
'Start'
|
|
330
|
+
];
|
|
331
|
+
options.wait && encodedArguments.push('-Wait'), app ? (encodedArguments.push(executePowerShell.escapeArgument(app)), options.target && appArguments.push(options.target)) : options.target && encodedArguments.push(executePowerShell.escapeArgument(options.target)), appArguments.length > 0 && encodedArguments.push('-ArgumentList', (appArguments = appArguments.map((argument)=>executePowerShell.escapeArgument(argument))).join(',')), options.target = executePowerShell.encodeCommand(encodedArguments.join(' ')), options.wait || (childProcessOptions.stdio = 'ignore');
|
|
332
|
+
} else {
|
|
257
333
|
if (app) command = app;
|
|
258
334
|
else {
|
|
259
335
|
let exeLocalXdgOpen = !1;
|
|
@@ -263,20 +339,24 @@ let pTryEach = async (array, mapper)=>{
|
|
|
263
339
|
command = node_process.versions.electron ?? ('android' === platform || !open_dirname || '/' === open_dirname || !exeLocalXdgOpen) ? 'xdg-open' : localXdgOpenPath;
|
|
264
340
|
}
|
|
265
341
|
appArguments.length > 0 && cliArguments.push(...appArguments), options.wait || (childProcessOptions.stdio = 'ignore', childProcessOptions.detached = !0);
|
|
266
|
-
} else {
|
|
267
|
-
command = await powerShellPath(), cliArguments.push('-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand'), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0);
|
|
268
|
-
let encodedArguments = [
|
|
269
|
-
'Start'
|
|
270
|
-
];
|
|
271
|
-
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');
|
|
272
342
|
}
|
|
273
343
|
'darwin' === platform && appArguments.length > 0 && cliArguments.push('--args', ...appArguments), options.target && cliArguments.push(options.target);
|
|
274
344
|
let subprocess = node_child_process.spawn(command, cliArguments, childProcessOptions);
|
|
275
345
|
return options.wait ? new Promise((resolve, reject)=>{
|
|
276
346
|
subprocess.once('error', reject), subprocess.once('close', (exitCode)=>{
|
|
277
|
-
|
|
347
|
+
options.allowNonzeroExitCode || 0 === exitCode ? resolve(subprocess) : reject(Error(`Exited with code ${exitCode}`));
|
|
278
348
|
});
|
|
279
|
-
}) : (
|
|
349
|
+
}) : isFallbackAttempt ? new Promise((resolve, reject)=>{
|
|
350
|
+
subprocess.once('error', reject), subprocess.once('spawn', ()=>{
|
|
351
|
+
subprocess.once('close', (exitCode)=>{
|
|
352
|
+
(subprocess.off('error', reject), 0 !== exitCode) ? reject(Error(`Exited with code ${exitCode}`)) : (subprocess.unref(), resolve(subprocess));
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
}) : (subprocess.unref(), new Promise((resolve, reject)=>{
|
|
356
|
+
subprocess.once('error', reject), subprocess.once('spawn', ()=>{
|
|
357
|
+
subprocess.off('error', reject), resolve(subprocess);
|
|
358
|
+
});
|
|
359
|
+
}));
|
|
280
360
|
};
|
|
281
361
|
function detectArchBinary(binary) {
|
|
282
362
|
if ('string' == typeof binary || Array.isArray(binary)) return binary;
|
|
@@ -284,19 +364,23 @@ function detectArchBinary(binary) {
|
|
|
284
364
|
if (!archBinary) throw Error(`${arch} is not supported`);
|
|
285
365
|
return archBinary;
|
|
286
366
|
}
|
|
287
|
-
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
|
|
367
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
288
368
|
if (wsl && is_wsl) return detectArchBinary(wsl);
|
|
289
369
|
if (!platformBinary) throw Error(`${platform} is not supported`);
|
|
290
370
|
return detectArchBinary(platformBinary);
|
|
291
371
|
}
|
|
292
|
-
let
|
|
293
|
-
|
|
372
|
+
let open_apps = {
|
|
373
|
+
browser: 'browser',
|
|
374
|
+
browserPrivate: 'browserPrivate'
|
|
375
|
+
};
|
|
376
|
+
defineLazyProperty(open_apps, 'chrome', ()=>detectPlatformBinary({
|
|
294
377
|
darwin: 'google chrome',
|
|
295
378
|
win32: 'chrome',
|
|
296
379
|
linux: [
|
|
297
380
|
'google-chrome',
|
|
298
381
|
'google-chrome-stable',
|
|
299
|
-
'chromium'
|
|
382
|
+
'chromium',
|
|
383
|
+
'chromium-browser'
|
|
300
384
|
]
|
|
301
385
|
}, {
|
|
302
386
|
wsl: {
|
|
@@ -306,7 +390,7 @@ defineLazyProperty(apps, 'chrome', ()=>detectPlatformBinary({
|
|
|
306
390
|
'/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
|
|
307
391
|
]
|
|
308
392
|
}
|
|
309
|
-
})), defineLazyProperty(
|
|
393
|
+
})), defineLazyProperty(open_apps, 'brave', ()=>detectPlatformBinary({
|
|
310
394
|
darwin: 'brave browser',
|
|
311
395
|
win32: 'brave',
|
|
312
396
|
linux: [
|
|
@@ -321,13 +405,13 @@ defineLazyProperty(apps, 'chrome', ()=>detectPlatformBinary({
|
|
|
321
405
|
'/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'
|
|
322
406
|
]
|
|
323
407
|
}
|
|
324
|
-
})), defineLazyProperty(
|
|
408
|
+
})), defineLazyProperty(open_apps, 'firefox', ()=>detectPlatformBinary({
|
|
325
409
|
darwin: 'firefox',
|
|
326
410
|
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
327
411
|
linux: 'firefox'
|
|
328
412
|
}, {
|
|
329
413
|
wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
|
|
330
|
-
})), defineLazyProperty(
|
|
414
|
+
})), defineLazyProperty(open_apps, 'edge', ()=>detectPlatformBinary({
|
|
331
415
|
darwin: 'microsoft edge',
|
|
332
416
|
win32: 'msedge',
|
|
333
417
|
linux: [
|
|
@@ -336,7 +420,9 @@ defineLazyProperty(apps, 'chrome', ()=>detectPlatformBinary({
|
|
|
336
420
|
]
|
|
337
421
|
}, {
|
|
338
422
|
wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
|
|
339
|
-
})), defineLazyProperty(
|
|
423
|
+
})), defineLazyProperty(open_apps, 'safari', ()=>detectPlatformBinary({
|
|
424
|
+
darwin: 'Safari'
|
|
425
|
+
}));
|
|
340
426
|
export default ((target, options)=>{
|
|
341
427
|
if ('string' != typeof target) throw TypeError('Expected a `target`');
|
|
342
428
|
return baseOpen({
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const __rslib_import_meta_url__ = "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
exports.ids = [
|
|
4
|
-
|
|
4
|
+
184
|
|
5
5
|
], exports.modules = {
|
|
6
|
-
"../../node_modules/.pnpm/open@
|
|
7
|
-
let isDockerCached, cachedResult, mountPoint, defaultMountPoint;
|
|
6
|
+
"../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
let isDockerCached, cachedResult, canAccessPowerShellPromise, mountPoint, defaultMountPoint;
|
|
8
8
|
__webpack_require__.d(__webpack_exports__, {
|
|
9
9
|
default: ()=>node_modules_open
|
|
10
10
|
});
|
|
11
|
-
var external_node_process_ = __webpack_require__("node:process"),
|
|
11
|
+
var external_node_process_ = __webpack_require__("node:process"), external_node_path_ = __webpack_require__("node:path"), external_node_url_ = __webpack_require__("node:url"), external_node_child_process_ = __webpack_require__("node:child_process"), promises_ = __webpack_require__("node:fs/promises"), external_node_os_ = __webpack_require__("node:os"), external_node_fs_ = __webpack_require__("node:fs");
|
|
12
12
|
function isInsideContainer() {
|
|
13
13
|
return void 0 === cachedResult && (cachedResult = (()=>{
|
|
14
14
|
try {
|
|
@@ -38,21 +38,71 @@ exports.ids = [
|
|
|
38
38
|
} catch {
|
|
39
39
|
return !1;
|
|
40
40
|
}
|
|
41
|
-
}, is_wsl = external_node_process_.env.__IS_WSL_TEST__ ? isWsl : isWsl()
|
|
41
|
+
}, is_wsl = external_node_process_.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
42
|
+
var external_node_util_ = __webpack_require__("node:util"), external_node_buffer_ = __webpack_require__("node:buffer");
|
|
43
|
+
let execFile = (0, external_node_util_.promisify)(external_node_child_process_.execFile), powerShellPath = ()=>`${external_node_process_.env.SYSTEMROOT || external_node_process_.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {})=>{
|
|
44
|
+
let { powerShellPath: psPath, ...execFileOptions } = options, encodedCommand = executePowerShell.encodeCommand(command);
|
|
45
|
+
return execFile(psPath ?? powerShellPath(), [
|
|
46
|
+
...executePowerShell.argumentsPrefix,
|
|
47
|
+
encodedCommand
|
|
48
|
+
], {
|
|
49
|
+
encoding: 'utf8',
|
|
50
|
+
...execFileOptions
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
executePowerShell.argumentsPrefix = [
|
|
54
|
+
'-NoProfile',
|
|
55
|
+
'-NonInteractive',
|
|
56
|
+
'-ExecutionPolicy',
|
|
57
|
+
'Bypass',
|
|
58
|
+
'-EncodedCommand'
|
|
59
|
+
], executePowerShell.encodeCommand = (command)=>external_node_buffer_.Buffer.from(command, 'utf16le').toString('base64'), executePowerShell.escapeArgument = (value)=>`'${String(value).replaceAll('\'', '\'\'')}'`;
|
|
60
|
+
let wsl_utils_execFile = (0, external_node_util_.promisify)(external_node_child_process_.execFile), wslDrivesMountPoint = (defaultMountPoint = '/mnt/', async function() {
|
|
42
61
|
if (mountPoint) return mountPoint;
|
|
43
62
|
let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
|
|
44
63
|
try {
|
|
45
64
|
await promises_.access(configFilePath, promises_.constants.F_OK), isConfigFileExists = !0;
|
|
46
65
|
} catch {}
|
|
47
66
|
if (!isConfigFileExists) return defaultMountPoint;
|
|
48
|
-
let
|
|
67
|
+
let parsedMountPoint = function(content) {
|
|
68
|
+
for (let line of content.split('\n')){
|
|
69
|
+
if (/^\s*#/.test(line)) continue;
|
|
70
|
+
let match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
71
|
+
if (match) return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, '');
|
|
72
|
+
}
|
|
73
|
+
}(await promises_.readFile(configFilePath, {
|
|
49
74
|
encoding: 'utf8'
|
|
50
|
-
})
|
|
51
|
-
return
|
|
75
|
+
}));
|
|
76
|
+
return void 0 === parsedMountPoint ? defaultMountPoint : mountPoint = (mountPoint = parsedMountPoint).endsWith('/') ? mountPoint : `${mountPoint}/`;
|
|
52
77
|
}), powerShellPathFromWsl = async ()=>{
|
|
53
78
|
let mountPoint = await wslDrivesMountPoint();
|
|
54
79
|
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
55
|
-
},
|
|
80
|
+
}, wsl_utils_powerShellPath = is_wsl ? powerShellPathFromWsl : powerShellPath, wsl_utils_canAccessPowerShell = async ()=>canAccessPowerShellPromise ??= (async ()=>{
|
|
81
|
+
try {
|
|
82
|
+
let psPath = await wsl_utils_powerShellPath();
|
|
83
|
+
return await promises_.access(psPath, promises_.constants.X_OK), !0;
|
|
84
|
+
} catch {
|
|
85
|
+
return !1;
|
|
86
|
+
}
|
|
87
|
+
})(), wslDefaultBrowser = async ()=>{
|
|
88
|
+
let psPath = await wsl_utils_powerShellPath(), command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { stdout } = await executePowerShell(command, {
|
|
89
|
+
powerShellPath: psPath
|
|
90
|
+
});
|
|
91
|
+
return stdout.trim();
|
|
92
|
+
}, convertWslPathToWindows = async (path)=>{
|
|
93
|
+
if (/^[a-z]+:\/\//i.test(path)) return path;
|
|
94
|
+
try {
|
|
95
|
+
let { stdout } = await wsl_utils_execFile('wslpath', [
|
|
96
|
+
'-aw',
|
|
97
|
+
path
|
|
98
|
+
], {
|
|
99
|
+
encoding: 'utf8'
|
|
100
|
+
});
|
|
101
|
+
return stdout.trim();
|
|
102
|
+
} catch {
|
|
103
|
+
return path;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
56
106
|
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
57
107
|
let define = (value)=>Object.defineProperty(object, propertyName, {
|
|
58
108
|
value,
|
|
@@ -71,56 +121,39 @@ exports.ids = [
|
|
|
71
121
|
}
|
|
72
122
|
}), object;
|
|
73
123
|
}
|
|
74
|
-
let execFileAsync = (0, external_node_util_.promisify)(external_node_child_process_.execFile)
|
|
75
|
-
async function defaultBrowserId() {
|
|
76
|
-
if ('darwin' !== external_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 = (0, external_node_util_.promisify)(external_node_child_process_.execFile);
|
|
85
|
-
async function runAppleScript(script, { humanReadableOutput = !0 } = {}) {
|
|
86
|
-
if ('darwin' !== external_node_process_.platform) throw Error('macOS only');
|
|
87
|
-
let { stdout } = await run_applescript_execFileAsync("osascript", [
|
|
88
|
-
'-e',
|
|
89
|
-
script,
|
|
90
|
-
humanReadableOutput ? [] : [
|
|
91
|
-
'-ss'
|
|
92
|
-
]
|
|
93
|
-
]);
|
|
94
|
-
return stdout.trim();
|
|
95
|
-
}
|
|
96
|
-
async function bundleName(bundleId) {
|
|
97
|
-
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")`);
|
|
98
|
-
}
|
|
99
|
-
let windows_execFileAsync = (0, external_node_util_.promisify)(external_node_child_process_.execFile), windowsBrowserProgIds = {
|
|
100
|
-
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
|
|
101
|
-
name: 'Edge',
|
|
102
|
-
id: 'com.microsoft.edge.old'
|
|
103
|
-
},
|
|
104
|
-
MSEdgeDHTML: {
|
|
105
|
-
name: 'Edge',
|
|
106
|
-
id: 'com.microsoft.edge'
|
|
107
|
-
},
|
|
124
|
+
let execFileAsync = (0, external_node_util_.promisify)(external_node_child_process_.execFile), windowsBrowserProgIds = {
|
|
108
125
|
MSEdgeHTM: {
|
|
109
126
|
name: 'Edge',
|
|
110
127
|
id: 'com.microsoft.edge'
|
|
111
128
|
},
|
|
112
|
-
|
|
113
|
-
name: '
|
|
114
|
-
id: 'com.microsoft.
|
|
129
|
+
MSEdgeBHTML: {
|
|
130
|
+
name: 'Edge Beta',
|
|
131
|
+
id: 'com.microsoft.edge.beta'
|
|
115
132
|
},
|
|
116
|
-
|
|
117
|
-
name: '
|
|
118
|
-
id: '
|
|
133
|
+
MSEdgeDHTML: {
|
|
134
|
+
name: 'Edge Dev',
|
|
135
|
+
id: 'com.microsoft.edge.dev'
|
|
136
|
+
},
|
|
137
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
|
|
138
|
+
name: 'Edge',
|
|
139
|
+
id: 'com.microsoft.edge.old'
|
|
119
140
|
},
|
|
120
141
|
ChromeHTML: {
|
|
121
142
|
name: 'Chrome',
|
|
122
143
|
id: 'com.google.chrome'
|
|
123
144
|
},
|
|
145
|
+
ChromeBHTML: {
|
|
146
|
+
name: 'Chrome Beta',
|
|
147
|
+
id: 'com.google.chrome.beta'
|
|
148
|
+
},
|
|
149
|
+
ChromeDHTML: {
|
|
150
|
+
name: 'Chrome Dev',
|
|
151
|
+
id: 'com.google.chrome.dev'
|
|
152
|
+
},
|
|
153
|
+
ChromiumHTM: {
|
|
154
|
+
name: 'Chromium',
|
|
155
|
+
id: 'org.chromium.Chromium'
|
|
156
|
+
},
|
|
124
157
|
BraveHTML: {
|
|
125
158
|
name: 'Brave',
|
|
126
159
|
id: 'com.brave.Browser'
|
|
@@ -129,14 +162,34 @@ exports.ids = [
|
|
|
129
162
|
name: 'Brave Beta',
|
|
130
163
|
id: 'com.brave.Browser.beta'
|
|
131
164
|
},
|
|
165
|
+
BraveDHTML: {
|
|
166
|
+
name: 'Brave Dev',
|
|
167
|
+
id: 'com.brave.Browser.dev'
|
|
168
|
+
},
|
|
132
169
|
BraveSSHTM: {
|
|
133
170
|
name: 'Brave Nightly',
|
|
134
171
|
id: 'com.brave.Browser.nightly'
|
|
172
|
+
},
|
|
173
|
+
FirefoxURL: {
|
|
174
|
+
name: 'Firefox',
|
|
175
|
+
id: 'org.mozilla.firefox'
|
|
176
|
+
},
|
|
177
|
+
OperaStable: {
|
|
178
|
+
name: 'Opera',
|
|
179
|
+
id: 'com.operasoftware.Opera'
|
|
180
|
+
},
|
|
181
|
+
VivaldiHTM: {
|
|
182
|
+
name: 'Vivaldi',
|
|
183
|
+
id: 'com.vivaldi.Vivaldi'
|
|
184
|
+
},
|
|
185
|
+
'IE.HTTP': {
|
|
186
|
+
name: 'Internet Explorer',
|
|
187
|
+
id: 'com.microsoft.ie'
|
|
135
188
|
}
|
|
136
|
-
};
|
|
189
|
+
}, _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
137
190
|
class UnknownBrowserError extends Error {
|
|
138
191
|
}
|
|
139
|
-
async function defaultBrowser(_execFileAsync =
|
|
192
|
+
async function defaultBrowser(_execFileAsync = execFileAsync) {
|
|
140
193
|
let { stdout } = await _execFileAsync('reg', [
|
|
141
194
|
'QUERY',
|
|
142
195
|
' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',
|
|
@@ -144,9 +197,36 @@ exports.ids = [
|
|
|
144
197
|
'ProgId'
|
|
145
198
|
]), match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
146
199
|
if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
147
|
-
let { id } = match.groups,
|
|
148
|
-
|
|
149
|
-
|
|
200
|
+
let { id } = match.groups, dotIndex = id.lastIndexOf('.'), hyphenIndex = id.lastIndexOf('-'), baseIdByDot = -1 === dotIndex ? void 0 : id.slice(0, dotIndex), baseIdByHyphen = -1 === hyphenIndex ? void 0 : id.slice(0, hyphenIndex);
|
|
201
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? {
|
|
202
|
+
name: id,
|
|
203
|
+
id
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
let default_browser_id_execFileAsync = (0, external_node_util_.promisify)(external_node_child_process_.execFile);
|
|
207
|
+
async function defaultBrowserId() {
|
|
208
|
+
if ('darwin' !== external_node_process_.platform) throw Error('macOS only');
|
|
209
|
+
let { stdout } = await default_browser_id_execFileAsync('defaults', [
|
|
210
|
+
'read',
|
|
211
|
+
'com.apple.LaunchServices/com.apple.launchservices.secure',
|
|
212
|
+
'LSHandlers'
|
|
213
|
+
]), match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
214
|
+
return match?.groups.id ?? 'com.apple.Safari';
|
|
215
|
+
}
|
|
216
|
+
let run_applescript_execFileAsync = (0, external_node_util_.promisify)(external_node_child_process_.execFile);
|
|
217
|
+
async function runAppleScript(script, { humanReadableOutput = !0 } = {}) {
|
|
218
|
+
if ('darwin' !== external_node_process_.platform) throw Error('macOS only');
|
|
219
|
+
let { stdout } = await run_applescript_execFileAsync("osascript", [
|
|
220
|
+
'-e',
|
|
221
|
+
script,
|
|
222
|
+
humanReadableOutput ? [] : [
|
|
223
|
+
'-ss'
|
|
224
|
+
]
|
|
225
|
+
]);
|
|
226
|
+
return stdout.trim();
|
|
227
|
+
}
|
|
228
|
+
async function bundleName(bundleId) {
|
|
229
|
+
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")`);
|
|
150
230
|
}
|
|
151
231
|
let default_browser_execFileAsync = (0, external_node_util_.promisify)(external_node_child_process_.execFile);
|
|
152
232
|
async function default_browser_defaultBrowser() {
|
|
@@ -171,89 +251,87 @@ exports.ids = [
|
|
|
171
251
|
if ('win32' === external_node_process_.platform) return defaultBrowser();
|
|
172
252
|
throw Error('Only macOS, Linux, and Windows are supported');
|
|
173
253
|
}
|
|
174
|
-
let
|
|
175
|
-
|
|
176
|
-
let
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
'-ExecutionPolicy',
|
|
180
|
-
'Bypass',
|
|
181
|
-
'-EncodedCommand',
|
|
182
|
-
encodedCommand
|
|
183
|
-
], {
|
|
184
|
-
encoding: 'utf8'
|
|
185
|
-
}), progId = stdout.trim(), browserMap = {
|
|
186
|
-
ChromeHTML: 'com.google.chrome',
|
|
187
|
-
BraveHTML: 'com.brave.Browser',
|
|
188
|
-
MSEdgeHTM: 'com.microsoft.edge',
|
|
189
|
-
FirefoxURL: 'org.mozilla.firefox'
|
|
190
|
-
};
|
|
191
|
-
return browserMap[progId] ? {
|
|
192
|
-
id: browserMap[progId]
|
|
193
|
-
} : {};
|
|
194
|
-
}
|
|
195
|
-
let pTryEach = async (array, mapper)=>{
|
|
196
|
-
let latestError;
|
|
197
|
-
for (let item of array)try {
|
|
198
|
-
return await mapper(item);
|
|
254
|
+
let isInSsh = !!(external_node_process_.env.SSH_CONNECTION || external_node_process_.env.SSH_CLIENT || external_node_process_.env.SSH_TTY), fallbackAttemptSymbol = Symbol('fallbackAttempt'), open_dirname = __rslib_import_meta_url__ ? external_node_path_.dirname((0, external_node_url_.fileURLToPath)(__rslib_import_meta_url__)) : '', localXdgOpenPath = external_node_path_.join(open_dirname, 'xdg-open'), { platform, arch } = external_node_process_, tryEachApp = async (apps, opener)=>{
|
|
255
|
+
if (0 === apps.length) return;
|
|
256
|
+
let errors = [];
|
|
257
|
+
for (let app of apps)try {
|
|
258
|
+
return await opener(app);
|
|
199
259
|
} catch (error) {
|
|
200
|
-
|
|
260
|
+
errors.push(error);
|
|
201
261
|
}
|
|
202
|
-
throw
|
|
262
|
+
throw AggregateError(errors, 'Failed to open in all supported apps');
|
|
203
263
|
}, baseOpen = async (options)=>{
|
|
204
|
-
let command
|
|
205
|
-
if (Array.isArray((options = {
|
|
264
|
+
let command, isFallbackAttempt = !0 === (options = {
|
|
206
265
|
wait: !1,
|
|
207
266
|
background: !1,
|
|
208
267
|
newInstance: !1,
|
|
209
268
|
allowNonzeroExitCode: !1,
|
|
210
269
|
...options
|
|
211
|
-
})
|
|
270
|
+
})[fallbackAttemptSymbol];
|
|
271
|
+
if (delete options[fallbackAttemptSymbol], Array.isArray(options.app)) return tryEachApp(options.app, (singleApp)=>baseOpen({
|
|
212
272
|
...options,
|
|
213
|
-
app: singleApp
|
|
273
|
+
app: singleApp,
|
|
274
|
+
[fallbackAttemptSymbol]: !0
|
|
214
275
|
}));
|
|
215
276
|
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
216
277
|
if (appArguments = [
|
|
217
278
|
...appArguments
|
|
218
|
-
], Array.isArray(app)) return
|
|
279
|
+
], Array.isArray(app)) return tryEachApp(app, (appName)=>baseOpen({
|
|
219
280
|
...options,
|
|
220
281
|
app: {
|
|
221
282
|
name: appName,
|
|
222
283
|
arguments: appArguments
|
|
223
|
-
}
|
|
284
|
+
},
|
|
285
|
+
[fallbackAttemptSymbol]: !0
|
|
224
286
|
}));
|
|
225
287
|
if ('browser' === app || 'browserPrivate' === app) {
|
|
226
|
-
let ids = {
|
|
288
|
+
let browser, ids = {
|
|
227
289
|
'com.google.chrome': 'chrome',
|
|
228
290
|
'google-chrome.desktop': 'chrome',
|
|
229
|
-
'com.brave.
|
|
291
|
+
'com.brave.browser': 'brave',
|
|
230
292
|
'org.mozilla.firefox': 'firefox',
|
|
231
293
|
'firefox.desktop': 'firefox',
|
|
232
294
|
'com.microsoft.msedge': 'edge',
|
|
233
295
|
'com.microsoft.edge': 'edge',
|
|
234
296
|
'com.microsoft.edgemac': 'edge',
|
|
235
|
-
'microsoft-edge.desktop': 'edge'
|
|
236
|
-
|
|
297
|
+
'microsoft-edge.desktop': 'edge',
|
|
298
|
+
'com.apple.safari': 'safari'
|
|
299
|
+
};
|
|
300
|
+
if (is_wsl) {
|
|
301
|
+
let progId = await wslDefaultBrowser();
|
|
302
|
+
browser = _windowsBrowserProgIdMap.get(progId) ?? {};
|
|
303
|
+
} else browser = await default_browser_defaultBrowser();
|
|
237
304
|
if (browser.id in ids) {
|
|
238
|
-
let browserName = ids[browser.id];
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
305
|
+
let browserName = ids[browser.id.toLowerCase()];
|
|
306
|
+
if ('browserPrivate' === app) {
|
|
307
|
+
if ('safari' === browserName) throw Error('Safari doesn\'t support opening in private mode via command line');
|
|
308
|
+
appArguments.push({
|
|
309
|
+
chrome: '--incognito',
|
|
310
|
+
brave: '--incognito',
|
|
311
|
+
firefox: '--private-window',
|
|
312
|
+
edge: '--inPrivate'
|
|
313
|
+
}[browserName]);
|
|
314
|
+
}
|
|
315
|
+
return baseOpen({
|
|
245
316
|
...options,
|
|
246
317
|
app: {
|
|
247
|
-
name:
|
|
318
|
+
name: open_apps[browserName],
|
|
248
319
|
arguments: appArguments
|
|
249
320
|
}
|
|
250
321
|
});
|
|
251
322
|
}
|
|
252
323
|
throw Error(`${browser.name} is not supported as a default browser`);
|
|
253
324
|
}
|
|
254
|
-
let cliArguments = [], childProcessOptions = {};
|
|
255
|
-
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);
|
|
256
|
-
else if ('win32'
|
|
325
|
+
let cliArguments = [], childProcessOptions = {}, shouldUseWindowsInWsl = !1;
|
|
326
|
+
if (!is_wsl || isInsideContainer() || isInSsh || app || (shouldUseWindowsInWsl = await wsl_utils_canAccessPowerShell()), '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);
|
|
327
|
+
else if ('win32' === platform || shouldUseWindowsInWsl) {
|
|
328
|
+
command = await wsl_utils_powerShellPath(), cliArguments.push(...executePowerShell.argumentsPrefix), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0), is_wsl && options.target && (options.target = await convertWslPathToWindows(options.target));
|
|
329
|
+
let encodedArguments = [
|
|
330
|
+
'$ProgressPreference = \'SilentlyContinue\';',
|
|
331
|
+
'Start'
|
|
332
|
+
];
|
|
333
|
+
options.wait && encodedArguments.push('-Wait'), app ? (encodedArguments.push(executePowerShell.escapeArgument(app)), options.target && appArguments.push(options.target)) : options.target && encodedArguments.push(executePowerShell.escapeArgument(options.target)), appArguments.length > 0 && encodedArguments.push('-ArgumentList', (appArguments = appArguments.map((argument)=>executePowerShell.escapeArgument(argument))).join(',')), options.target = executePowerShell.encodeCommand(encodedArguments.join(' ')), options.wait || (childProcessOptions.stdio = 'ignore');
|
|
334
|
+
} else {
|
|
257
335
|
if (app) command = app;
|
|
258
336
|
else {
|
|
259
337
|
let exeLocalXdgOpen = !1;
|
|
@@ -263,20 +341,24 @@ exports.ids = [
|
|
|
263
341
|
command = external_node_process_.versions.electron ?? ('android' === platform || !open_dirname || '/' === open_dirname || !exeLocalXdgOpen) ? 'xdg-open' : localXdgOpenPath;
|
|
264
342
|
}
|
|
265
343
|
appArguments.length > 0 && cliArguments.push(...appArguments), options.wait || (childProcessOptions.stdio = 'ignore', childProcessOptions.detached = !0);
|
|
266
|
-
} else {
|
|
267
|
-
command = await powerShellPath(), cliArguments.push('-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand'), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0);
|
|
268
|
-
let encodedArguments = [
|
|
269
|
-
'Start'
|
|
270
|
-
];
|
|
271
|
-
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 = external_node_buffer_.Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
|
|
272
344
|
}
|
|
273
345
|
'darwin' === platform && appArguments.length > 0 && cliArguments.push('--args', ...appArguments), options.target && cliArguments.push(options.target);
|
|
274
346
|
let subprocess = external_node_child_process_.spawn(command, cliArguments, childProcessOptions);
|
|
275
347
|
return options.wait ? new Promise((resolve, reject)=>{
|
|
276
348
|
subprocess.once('error', reject), subprocess.once('close', (exitCode)=>{
|
|
277
|
-
|
|
349
|
+
options.allowNonzeroExitCode || 0 === exitCode ? resolve(subprocess) : reject(Error(`Exited with code ${exitCode}`));
|
|
278
350
|
});
|
|
279
|
-
}) : (
|
|
351
|
+
}) : isFallbackAttempt ? new Promise((resolve, reject)=>{
|
|
352
|
+
subprocess.once('error', reject), subprocess.once('spawn', ()=>{
|
|
353
|
+
subprocess.once('close', (exitCode)=>{
|
|
354
|
+
(subprocess.off('error', reject), 0 !== exitCode) ? reject(Error(`Exited with code ${exitCode}`)) : (subprocess.unref(), resolve(subprocess));
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
}) : (subprocess.unref(), new Promise((resolve, reject)=>{
|
|
358
|
+
subprocess.once('error', reject), subprocess.once('spawn', ()=>{
|
|
359
|
+
subprocess.off('error', reject), resolve(subprocess);
|
|
360
|
+
});
|
|
361
|
+
}));
|
|
280
362
|
};
|
|
281
363
|
function detectArchBinary(binary) {
|
|
282
364
|
if ('string' == typeof binary || Array.isArray(binary)) return binary;
|
|
@@ -284,19 +366,23 @@ exports.ids = [
|
|
|
284
366
|
if (!archBinary) throw Error(`${arch} is not supported`);
|
|
285
367
|
return archBinary;
|
|
286
368
|
}
|
|
287
|
-
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
|
|
369
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
288
370
|
if (wsl && is_wsl) return detectArchBinary(wsl);
|
|
289
371
|
if (!platformBinary) throw Error(`${platform} is not supported`);
|
|
290
372
|
return detectArchBinary(platformBinary);
|
|
291
373
|
}
|
|
292
|
-
let
|
|
293
|
-
|
|
374
|
+
let open_apps = {
|
|
375
|
+
browser: 'browser',
|
|
376
|
+
browserPrivate: 'browserPrivate'
|
|
377
|
+
};
|
|
378
|
+
defineLazyProperty(open_apps, 'chrome', ()=>detectPlatformBinary({
|
|
294
379
|
darwin: 'google chrome',
|
|
295
380
|
win32: 'chrome',
|
|
296
381
|
linux: [
|
|
297
382
|
'google-chrome',
|
|
298
383
|
'google-chrome-stable',
|
|
299
|
-
'chromium'
|
|
384
|
+
'chromium',
|
|
385
|
+
'chromium-browser'
|
|
300
386
|
]
|
|
301
387
|
}, {
|
|
302
388
|
wsl: {
|
|
@@ -306,7 +392,7 @@ exports.ids = [
|
|
|
306
392
|
'/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
|
|
307
393
|
]
|
|
308
394
|
}
|
|
309
|
-
})), defineLazyProperty(
|
|
395
|
+
})), defineLazyProperty(open_apps, 'brave', ()=>detectPlatformBinary({
|
|
310
396
|
darwin: 'brave browser',
|
|
311
397
|
win32: 'brave',
|
|
312
398
|
linux: [
|
|
@@ -321,13 +407,13 @@ exports.ids = [
|
|
|
321
407
|
'/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'
|
|
322
408
|
]
|
|
323
409
|
}
|
|
324
|
-
})), defineLazyProperty(
|
|
410
|
+
})), defineLazyProperty(open_apps, 'firefox', ()=>detectPlatformBinary({
|
|
325
411
|
darwin: 'firefox',
|
|
326
412
|
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
327
413
|
linux: 'firefox'
|
|
328
414
|
}, {
|
|
329
415
|
wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
|
|
330
|
-
})), defineLazyProperty(
|
|
416
|
+
})), defineLazyProperty(open_apps, 'edge', ()=>detectPlatformBinary({
|
|
331
417
|
darwin: 'microsoft edge',
|
|
332
418
|
win32: 'msedge',
|
|
333
419
|
linux: [
|
|
@@ -336,7 +422,9 @@ exports.ids = [
|
|
|
336
422
|
]
|
|
337
423
|
}, {
|
|
338
424
|
wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
|
|
339
|
-
})), defineLazyProperty(
|
|
425
|
+
})), defineLazyProperty(open_apps, 'safari', ()=>detectPlatformBinary({
|
|
426
|
+
darwin: 'Safari'
|
|
427
|
+
}));
|
|
340
428
|
let node_modules_open = (target, options)=>{
|
|
341
429
|
if ('string' != typeof target) throw TypeError('Expected a `target`');
|
|
342
430
|
return baseOpen({
|
package/dist/612.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
var __webpack_modules__ = {}, __webpack_module_cache__ = {};
|
|
3
|
+
function __webpack_require__(moduleId) {
|
|
4
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
5
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
7
|
+
exports: {}
|
|
8
|
+
};
|
|
9
|
+
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
10
|
+
}
|
|
11
|
+
__webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
12
|
+
var getter = module && module.__esModule ? ()=>module.default : ()=>module;
|
|
13
|
+
return __webpack_require__.d(getter, {
|
|
14
|
+
a: getter
|
|
15
|
+
}), getter;
|
|
16
|
+
}, __webpack_require__.d = (exports, getters, values)=>{
|
|
17
|
+
var define = (defs, kind)=>{
|
|
18
|
+
for(var key in defs)__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key) && Object.defineProperty(exports, key, {
|
|
19
|
+
enumerable: !0,
|
|
20
|
+
[kind]: defs[key]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
define(getters, "get"), define(values, "value");
|
|
24
|
+
}, __webpack_require__.add = function(modules) {
|
|
25
|
+
Object.assign(__webpack_require__.m, modules);
|
|
26
|
+
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports)=>{
|
|
27
|
+
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports, Symbol.toStringTag, {
|
|
28
|
+
value: 'Module'
|
|
29
|
+
}), Object.defineProperty(exports, '__esModule', {
|
|
30
|
+
value: !0
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export { __webpack_require__ };
|
package/dist/index.cjs
CHANGED
|
@@ -1295,7 +1295,7 @@ var __webpack_modules__ = {
|
|
|
1295
1295
|
'WeakSet',
|
|
1296
1296
|
'prototype'
|
|
1297
1297
|
]
|
|
1298
|
-
}, bind = __webpack_require__("../../node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.js"), hasOwn = __webpack_require__("../../node_modules/.pnpm/hasown@2.0.
|
|
1298
|
+
}, bind = __webpack_require__("../../node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.js"), hasOwn = __webpack_require__("../../node_modules/.pnpm/hasown@2.0.4/node_modules/hasown/index.js"), $concat = bind.call($call, Array.prototype.concat), $spliceApply = bind.call($apply, Array.prototype.splice), $replace = bind.call($call, String.prototype.replace), $strSlice = bind.call($call, String.prototype.slice), $exec = bind.call($call, RegExp.prototype.exec), rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g, reEscapeChar = /\\(\\)?/g, stringToPath = function(string) {
|
|
1299
1299
|
var first = $strSlice(string, 0, 1), last = $strSlice(string, -1);
|
|
1300
1300
|
if ('%' === first && '%' !== last) throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
|
|
1301
1301
|
if ('%' === last && '%' !== first) throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
|
|
@@ -1410,7 +1410,7 @@ var __webpack_modules__ = {
|
|
|
1410
1410
|
return !0;
|
|
1411
1411
|
};
|
|
1412
1412
|
},
|
|
1413
|
-
"../../node_modules/.pnpm/hasown@2.0.
|
|
1413
|
+
"../../node_modules/.pnpm/hasown@2.0.4/node_modules/hasown/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1414
1414
|
"use strict";
|
|
1415
1415
|
var call = Function.prototype.call, $hasOwn = Object.prototype.hasOwnProperty;
|
|
1416
1416
|
module.exports = __webpack_require__("../../node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.js").call(call, $hasOwn);
|
|
@@ -5695,7 +5695,7 @@ var __webpack_modules__ = {
|
|
|
5695
5695
|
return this.dataLoader.loadAPI;
|
|
5696
5696
|
}
|
|
5697
5697
|
}
|
|
5698
|
-
let external_node_net_namespaceObject = require("node:net"), DEFAULT_ALLOWED_CORS_ORIGINS = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, LOCAL_HOSTNAMES = /^(?:localhost|[^:]+\.localhost)$/;
|
|
5698
|
+
let external_node_net_namespaceObject = require("node:net"), external_node_crypto_namespaceObject = require("node:crypto"), DEFAULT_ALLOWED_CORS_ORIGINS = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, LOCAL_HOSTNAMES = /^(?:localhost|[^:]+\.localhost)$/;
|
|
5699
5699
|
function getHostnameFromHost(host) {
|
|
5700
5700
|
if (host.startsWith('[')) {
|
|
5701
5701
|
let endIndex = host.indexOf(']');
|
|
@@ -6275,19 +6275,19 @@ var __webpack_modules__ = {
|
|
|
6275
6275
|
cwd: (0, external_node_path_.join)(__dirname, '../static')
|
|
6276
6276
|
}), !0;
|
|
6277
6277
|
logger_namespaceObject.logger.debug('Failed to find the target browser.');
|
|
6278
|
-
let { default: open } = await __webpack_require__.e(
|
|
6278
|
+
let { default: open } = await __webpack_require__.e(184).then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js"));
|
|
6279
6279
|
return await open(url), !0;
|
|
6280
6280
|
} catch (err) {
|
|
6281
6281
|
logger_namespaceObject.logger.debug("Failed to open Rsdoctor URL with apple script."), logger_namespaceObject.logger.debug(err);
|
|
6282
6282
|
}
|
|
6283
6283
|
else try {
|
|
6284
|
-
let { default: open } = await __webpack_require__.e(
|
|
6284
|
+
let { default: open } = await __webpack_require__.e(184).then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js"));
|
|
6285
6285
|
return await open(url), !0;
|
|
6286
6286
|
} catch (err) {
|
|
6287
6287
|
return logger_namespaceObject.logger.error('Failed to open Rsdoctor URL.'), logger_namespaceObject.logger.error(err), !1;
|
|
6288
6288
|
}
|
|
6289
6289
|
}
|
|
6290
|
-
let external_crypto_namespaceObject = require("crypto"), server_require = (0, external_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
6290
|
+
let external_crypto_namespaceObject = require("crypto"), server_require = (0, external_module_namespaceObject.createRequire)(__rslib_import_meta_url__), OPEN_IN_EDITOR_EDITORS = new Set(types_namespaceObject.SDK.OPEN_IN_EDITOR_EDITORS);
|
|
6291
6291
|
class RsdoctorServer {
|
|
6292
6292
|
constructor(sdk, port = build_namespaceObject.Server.defaultPort, config){
|
|
6293
6293
|
this.sdk = sdk, this.disposed = !0, this._socketToken = (0, external_crypto_namespaceObject.randomBytes)(16).toString('hex'), this.get = (route, cb)=>{
|
|
@@ -6465,11 +6465,23 @@ var __webpack_modules__ = {
|
|
|
6465
6465
|
dev: !0
|
|
6466
6466
|
})), this.app.use('/__open-in-editor', (req, res, next)=>{
|
|
6467
6467
|
if ('GET' !== req.method && 'HEAD' !== req.method) return next();
|
|
6468
|
-
let url = new URL(req.url || '', "http://localhost"), file = url.searchParams.get('file'), editor = url.searchParams.get('editor')
|
|
6468
|
+
let url = new URL(req.url || '', "http://localhost"), file = url.searchParams.get('file'), editor = url.searchParams.get('editor');
|
|
6469
|
+
if (!function(token, expectedToken) {
|
|
6470
|
+
if ('string' != typeof token || !expectedToken) return !1;
|
|
6471
|
+
let tokenBuffer = Buffer.from(token), expectedTokenBuffer = Buffer.from(expectedToken);
|
|
6472
|
+
return tokenBuffer.length === expectedTokenBuffer.length && (0, external_node_crypto_namespaceObject.timingSafeEqual)(tokenBuffer, expectedTokenBuffer);
|
|
6473
|
+
}(url.searchParams.get('token'), this._socketToken)) {
|
|
6474
|
+
res.statusCode = 403, res.end();
|
|
6475
|
+
return;
|
|
6476
|
+
}
|
|
6469
6477
|
if (!file) {
|
|
6470
6478
|
res.statusCode = 400, res.end('Missing file parameter');
|
|
6471
6479
|
return;
|
|
6472
6480
|
}
|
|
6481
|
+
if (!('string' == typeof editor && OPEN_IN_EDITOR_EDITORS.has(editor))) {
|
|
6482
|
+
res.statusCode = 400, res.end('Unsupported editor parameter');
|
|
6483
|
+
return;
|
|
6484
|
+
}
|
|
6473
6485
|
try {
|
|
6474
6486
|
let launch = server_require('launch-editor'), responded = !1, safeEnd = (code, body)=>{
|
|
6475
6487
|
responded || (responded = !0, res.statusCode = code, res.end(body));
|
|
@@ -6543,7 +6555,6 @@ var __webpack_modules__ = {
|
|
|
6543
6555
|
}
|
|
6544
6556
|
async openClientPage() {}
|
|
6545
6557
|
}
|
|
6546
|
-
let external_node_crypto_namespaceObject = require("node:crypto");
|
|
6547
6558
|
var external_node_process_ = __webpack_require__("node:process"), external_node_process_default = __webpack_require__.n(external_node_process_);
|
|
6548
6559
|
let external_tapable_namespaceObject = require("tapable"), dayjs_index_js_namespaceObject = require("../compiled/dayjs/index.js");
|
|
6549
6560
|
function findRoot(startDir = process.cwd()) {
|
|
@@ -7209,11 +7220,14 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
7209
7220
|
return __webpack_require__.d(getter, {
|
|
7210
7221
|
a: getter
|
|
7211
7222
|
}), getter;
|
|
7212
|
-
}, __webpack_require__.d = (exports1,
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7223
|
+
}, __webpack_require__.d = (exports1, getters, values)=>{
|
|
7224
|
+
var define = (defs, kind)=>{
|
|
7225
|
+
for(var key in defs)__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
|
|
7226
|
+
enumerable: !0,
|
|
7227
|
+
[kind]: defs[key]
|
|
7228
|
+
});
|
|
7229
|
+
};
|
|
7230
|
+
define(getters, "get"), define(values, "value");
|
|
7217
7231
|
}, __webpack_require__.f = {}, __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>(__webpack_require__.f[key](chunkId, promises), promises), [])), __webpack_require__.u = (chunkId)=>"1~" + chunkId + ".cjs", __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
7218
7232
|
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
7219
7233
|
value: 'Module'
|
package/dist/index.js
CHANGED
|
@@ -19,46 +19,20 @@ import { PassThrough } from "stream";
|
|
|
19
19
|
import { Server as external_socket_io_Server } from "socket.io";
|
|
20
20
|
import { isDeepStrictEqual } from "util";
|
|
21
21
|
import { isIP } from "node:net";
|
|
22
|
+
import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
|
|
22
23
|
import os from "os";
|
|
23
24
|
import { exec } from "node:child_process";
|
|
24
25
|
import { promisify } from "node:util";
|
|
25
26
|
import { randomBytes } from "crypto";
|
|
26
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
27
27
|
import node_process from "node:process";
|
|
28
28
|
import { AsyncSeriesHook } from "tapable";
|
|
29
29
|
import dayjs from "../compiled/dayjs/index.js";
|
|
30
|
+
import { __webpack_require__ } from "./612.js";
|
|
30
31
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
31
32
|
let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
32
33
|
import * as __rspack_external_util from "util";
|
|
33
34
|
import * as __rspack_external_node_querystring_aeb3c0b4 from "node:querystring";
|
|
34
|
-
|
|
35
|
-
function __webpack_require__(moduleId) {
|
|
36
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
37
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
38
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
39
|
-
exports: {}
|
|
40
|
-
};
|
|
41
|
-
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
42
|
-
}
|
|
43
|
-
__webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
44
|
-
var getter = module && module.__esModule ? ()=>module.default : ()=>module;
|
|
45
|
-
return __webpack_require__.d(getter, {
|
|
46
|
-
a: getter
|
|
47
|
-
}), getter;
|
|
48
|
-
}, __webpack_require__.d = (exports, definition)=>{
|
|
49
|
-
for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key) && Object.defineProperty(exports, key, {
|
|
50
|
-
enumerable: !0,
|
|
51
|
-
get: definition[key]
|
|
52
|
-
});
|
|
53
|
-
}, __webpack_require__.add = function(modules) {
|
|
54
|
-
Object.assign(__webpack_require__.m, modules);
|
|
55
|
-
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports)=>{
|
|
56
|
-
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports, Symbol.toStringTag, {
|
|
57
|
-
value: 'Module'
|
|
58
|
-
}), Object.defineProperty(exports, '__esModule', {
|
|
59
|
-
value: !0
|
|
60
|
-
});
|
|
61
|
-
}, __webpack_require__.add({
|
|
35
|
+
__webpack_require__.add({
|
|
62
36
|
"../../node_modules/.pnpm/body-parser@2.2.2/node_modules/body-parser/index.js" (module, exports, __webpack_require__) {
|
|
63
37
|
Object.defineProperty(exports = module.exports = function() {
|
|
64
38
|
throw Error('The bodyParser() generic has been split into individual middleware to use instead.');
|
|
@@ -1324,7 +1298,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
1324
1298
|
'WeakSet',
|
|
1325
1299
|
'prototype'
|
|
1326
1300
|
]
|
|
1327
|
-
}, bind = __webpack_require__("../../node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.js"), hasOwn = __webpack_require__("../../node_modules/.pnpm/hasown@2.0.
|
|
1301
|
+
}, bind = __webpack_require__("../../node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.js"), hasOwn = __webpack_require__("../../node_modules/.pnpm/hasown@2.0.4/node_modules/hasown/index.js"), $concat = bind.call($call, Array.prototype.concat), $spliceApply = bind.call($apply, Array.prototype.splice), $replace = bind.call($call, String.prototype.replace), $strSlice = bind.call($call, String.prototype.slice), $exec = bind.call($call, RegExp.prototype.exec), rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g, reEscapeChar = /\\(\\)?/g, stringToPath = function(string) {
|
|
1328
1302
|
var first = $strSlice(string, 0, 1), last = $strSlice(string, -1);
|
|
1329
1303
|
if ('%' === first && '%' !== last) throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
|
|
1330
1304
|
if ('%' === last && '%' !== first) throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
|
|
@@ -1431,7 +1405,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
1431
1405
|
return !0;
|
|
1432
1406
|
};
|
|
1433
1407
|
},
|
|
1434
|
-
"../../node_modules/.pnpm/hasown@2.0.
|
|
1408
|
+
"../../node_modules/.pnpm/hasown@2.0.4/node_modules/hasown/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1435
1409
|
var call = Function.prototype.call, $hasOwn = Object.prototype.hasOwnProperty;
|
|
1436
1410
|
module.exports = __webpack_require__("../../node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.js").call(call, $hasOwn);
|
|
1437
1411
|
},
|
|
@@ -6309,7 +6283,7 @@ async function openBrowser(url, needEncodeURI = !0) {
|
|
|
6309
6283
|
}
|
|
6310
6284
|
let body_parser = __webpack_require__("../../node_modules/.pnpm/body-parser@2.2.2/node_modules/body-parser/index.js");
|
|
6311
6285
|
var body_parser_default = __webpack_require__.n(body_parser);
|
|
6312
|
-
let server_require = createRequire(import.meta.url);
|
|
6286
|
+
let server_require = createRequire(import.meta.url), OPEN_IN_EDITOR_EDITORS = new Set(SDK.OPEN_IN_EDITOR_EDITORS);
|
|
6313
6287
|
class RsdoctorServer {
|
|
6314
6288
|
constructor(sdk, port = Server.defaultPort, config){
|
|
6315
6289
|
this.sdk = sdk, this.disposed = !0, this._socketToken = randomBytes(16).toString('hex'), this.get = (route, cb)=>{
|
|
@@ -6486,11 +6460,23 @@ class RsdoctorServer {
|
|
|
6486
6460
|
dev: !0
|
|
6487
6461
|
})), this.app.use('/__open-in-editor', (req, res, next)=>{
|
|
6488
6462
|
if ('GET' !== req.method && 'HEAD' !== req.method) return next();
|
|
6489
|
-
let url = new URL(req.url || '', "http://localhost"), file = url.searchParams.get('file'), editor = url.searchParams.get('editor')
|
|
6463
|
+
let url = new URL(req.url || '', "http://localhost"), file = url.searchParams.get('file'), editor = url.searchParams.get('editor');
|
|
6464
|
+
if (!function(token, expectedToken) {
|
|
6465
|
+
if ('string' != typeof token || !expectedToken) return !1;
|
|
6466
|
+
let tokenBuffer = Buffer.from(token), expectedTokenBuffer = Buffer.from(expectedToken);
|
|
6467
|
+
return tokenBuffer.length === expectedTokenBuffer.length && timingSafeEqual(tokenBuffer, expectedTokenBuffer);
|
|
6468
|
+
}(url.searchParams.get('token'), this._socketToken)) {
|
|
6469
|
+
res.statusCode = 403, res.end();
|
|
6470
|
+
return;
|
|
6471
|
+
}
|
|
6490
6472
|
if (!file) {
|
|
6491
6473
|
res.statusCode = 400, res.end('Missing file parameter');
|
|
6492
6474
|
return;
|
|
6493
6475
|
}
|
|
6476
|
+
if (!('string' == typeof editor && OPEN_IN_EDITOR_EDITORS.has(editor))) {
|
|
6477
|
+
res.statusCode = 400, res.end('Unsupported editor parameter');
|
|
6478
|
+
return;
|
|
6479
|
+
}
|
|
6494
6480
|
try {
|
|
6495
6481
|
let launch = server_require('launch-editor'), responded = !1, safeEnd = (code, body)=>{
|
|
6496
6482
|
responded || (responded = !0, res.statusCode = code, res.end(body));
|
|
@@ -2,3 +2,4 @@ export declare const DEFAULT_ALLOWED_CORS_ORIGINS: RegExp;
|
|
|
2
2
|
export declare function isAllowedRequestOrigin(origin: string | string[] | undefined): boolean;
|
|
3
3
|
export declare function isAllowedRequestHost(host: string | string[] | undefined): boolean;
|
|
4
4
|
export declare function isAllowedCorsRequest(origin: string | string[] | undefined, host: string | string[] | undefined): boolean;
|
|
5
|
+
export declare function isAllowedOpenInEditorToken(token: string | null, expectedToken: string): boolean;
|
|
@@ -2,3 +2,4 @@ export declare const DEFAULT_ALLOWED_CORS_ORIGINS: RegExp;
|
|
|
2
2
|
export declare function isAllowedRequestOrigin(origin: string | string[] | undefined): boolean;
|
|
3
3
|
export declare function isAllowedRequestHost(host: string | string[] | undefined): boolean;
|
|
4
4
|
export declare function isAllowedCorsRequest(origin: string | string[] | undefined, host: string | string[] | undefined): boolean;
|
|
5
|
+
export declare function isAllowedOpenInEditorToken(token: string | null, expectedToken: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/sdk",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.18",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"safer-buffer": "2.1.2",
|
|
33
33
|
"socket.io": "4.8.1",
|
|
34
34
|
"tapable": "2.3.3",
|
|
35
|
-
"@rsdoctor/client": "1.5.
|
|
36
|
-
"@rsdoctor/
|
|
37
|
-
"@rsdoctor/
|
|
38
|
-
"@rsdoctor/utils": "1.5.
|
|
35
|
+
"@rsdoctor/client": "1.5.18",
|
|
36
|
+
"@rsdoctor/types": "1.5.18",
|
|
37
|
+
"@rsdoctor/graph": "1.5.18",
|
|
38
|
+
"@rsdoctor/utils": "1.5.18"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/body-parser": "1.19.6",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"cors": "2.8.6",
|
|
48
48
|
"dayjs": "1.11.21",
|
|
49
49
|
"fs-extra": "^11.1.1",
|
|
50
|
-
"open": "^
|
|
50
|
+
"open": "^11.0.0",
|
|
51
51
|
"sirv": "3.0.2",
|
|
52
52
|
"source-map": "^0.7.6",
|
|
53
53
|
"prebundle": "1.6.5",
|