@rsdoctor/core 2.0.0-beta.3 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/26.js +458 -12
- package/dist/index.js +2094 -18
- package/dist/index.js.LICENSE.txt +45 -0
- package/dist/rslib-runtime.js +6 -1
- package/dist/sdk/multiple/controller.d.ts +3 -0
- package/dist/sdk/multiple/primary.d.ts +1 -0
- package/dist/sdk/sdk/index.d.ts +2 -0
- package/dist/sdk/utils/writeJson.d.ts +1 -0
- package/package.json +5 -5
package/dist/26.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
let flagForceColor;
|
|
1
|
+
let isDockerCached, cachedResult, canAccessPowerShellPromise, flagForceColor, mountPoint, defaultMountPoint;
|
|
2
2
|
import __rslib_shim_module__, { createRequire, createRequire as __rspack_createRequire } from "node:module";
|
|
3
3
|
let require = __rslib_shim_module__.createRequire(import.meta.url);
|
|
4
4
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
@@ -9,7 +9,7 @@ import { connect } from "connect-next";
|
|
|
9
9
|
import http from "http";
|
|
10
10
|
import os from "os";
|
|
11
11
|
import "get-port";
|
|
12
|
-
import { execFileSync } from "child_process";
|
|
12
|
+
import { execFileSync as external_child_process_execFileSync } from "child_process";
|
|
13
13
|
import { Algorithm, Fetch, Graph, Loader, Lodash, Summary, Time } from "@rsdoctor/shared/common-browser";
|
|
14
14
|
import envinfo from "envinfo";
|
|
15
15
|
import "process";
|
|
@@ -20,19 +20,21 @@ import { promisify, stripVTControlCharacters } from "node:util";
|
|
|
20
20
|
import { codeFrameColumns } from "@babel/code-frame";
|
|
21
21
|
import { color } from "rslog";
|
|
22
22
|
import assert from "assert";
|
|
23
|
-
import { exec as external_node_child_process_exec } from "node:child_process";
|
|
23
|
+
import node_child_process, { exec as external_node_child_process_exec, execFile as external_node_child_process_execFile } from "node:child_process";
|
|
24
24
|
import node_path, { join, dirname as __rspack_dirname } from "node:path";
|
|
25
|
+
import node_process from "node:process";
|
|
26
|
+
import { fileURLToPath, fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
27
|
+
import promises, { constants } from "node:fs/promises";
|
|
28
|
+
import node_os from "node:os";
|
|
29
|
+
import { Buffer as external_node_buffer_Buffer } from "node:buffer";
|
|
25
30
|
import { randomUUID } from "node:crypto";
|
|
26
31
|
import { SourceMapConsumer } from "source-map";
|
|
27
32
|
import { diff, gt } from "semver";
|
|
28
33
|
import { builtinModules } from "module";
|
|
29
34
|
import { parse } from "acorn";
|
|
30
|
-
import node_process from "node:process";
|
|
31
|
-
import node_os from "node:os";
|
|
32
35
|
import node_tty from "node:tty";
|
|
33
36
|
import { loadConfig } from "browserslist-load-config";
|
|
34
37
|
import { addProbeLoader2Rules, parseBundle as parseBundle_parseBundle, interceptCompilationHooks, timeEnd as logger_timeEnd, logger_time, getSDK, extractLoaderName, logger as rsdoctorLogger, mapEachRules, getDocument, isESMLoader, parseQuery, filesize as filesize_filesize, color as external_rslog_color, getLoaderNameMatch, interceptCompilerHooks, loadLoaderModule, parser as parser_parser } from "./630.js";
|
|
35
|
-
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
36
38
|
var CheckVersionMap, __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
37
39
|
let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
38
40
|
__webpack_require__.add({
|
|
@@ -23611,7 +23613,7 @@ getAvailablePort(${expectPort}).then(port => process.stdout.write(port.toString(
|
|
|
23611
23613
|
`.trim();
|
|
23612
23614
|
function getPortSync(expectPort, host = defaultHost) {
|
|
23613
23615
|
let statement = '\n' === os.EOL ? createGetPortSyncFunctionString(expectPort, host) : createGetPortSyncFunctionString(expectPort, host).replace(/\n/g, '');
|
|
23614
|
-
return Number(
|
|
23616
|
+
return Number(external_child_process_execFileSync(process.execPath, [
|
|
23615
23617
|
'-e',
|
|
23616
23618
|
statement
|
|
23617
23619
|
], {
|
|
@@ -23766,7 +23768,7 @@ function transformDiagnostic(err, opt) {
|
|
|
23766
23768
|
level: Linter.Severity[err.severity]
|
|
23767
23769
|
});
|
|
23768
23770
|
}
|
|
23769
|
-
let
|
|
23771
|
+
let error_id = 1, stringify = (text)=>String(text), plainColor = Object.fromEntries(Object.keys(color).map((key)=>[
|
|
23770
23772
|
key,
|
|
23771
23773
|
stringify
|
|
23772
23774
|
]));
|
|
@@ -23790,7 +23792,7 @@ class DevToolError extends Error {
|
|
|
23790
23792
|
super(message), this._controller = {
|
|
23791
23793
|
noStack: !0,
|
|
23792
23794
|
noColor: !1
|
|
23793
|
-
}, this.id =
|
|
23795
|
+
}, this.id = error_id++, this.title = title, this.code = opts?.code, this.hint = opts?.hint, this.stack = opts?.stack, this.detail = opts?.detail, this.fixData = opts?.fixData, this.category = opts?.category, this.referenceUrl = opts?.referenceUrl, this._level = opts?.level ? (level = opts.level, Err.ErrorLevel[level]) : Err.ErrorLevel.Error, this._codeFrame = opts?.codeFrame, this.setControllerOption(opts?.controller ?? {});
|
|
23794
23796
|
}
|
|
23795
23797
|
get level() {
|
|
23796
23798
|
return Err.ErrorLevel[this._level];
|
|
@@ -24182,6 +24184,451 @@ let normalizeRspackUserOptions = function(config = {}) {
|
|
|
24182
24184
|
group: 'object' == typeof multiCompiler ? multiCompiler.group : void 0
|
|
24183
24185
|
}
|
|
24184
24186
|
};
|
|
24187
|
+
};
|
|
24188
|
+
function isInsideContainer() {
|
|
24189
|
+
return void 0 === cachedResult && (cachedResult = (()=>{
|
|
24190
|
+
try {
|
|
24191
|
+
return node_fs.statSync('/run/.containerenv'), !0;
|
|
24192
|
+
} catch {
|
|
24193
|
+
return !1;
|
|
24194
|
+
}
|
|
24195
|
+
})() || (void 0 === isDockerCached && (isDockerCached = function() {
|
|
24196
|
+
try {
|
|
24197
|
+
return node_fs.statSync('/.dockerenv'), !0;
|
|
24198
|
+
} catch {
|
|
24199
|
+
return !1;
|
|
24200
|
+
}
|
|
24201
|
+
}() || function() {
|
|
24202
|
+
try {
|
|
24203
|
+
return node_fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
|
|
24204
|
+
} catch {
|
|
24205
|
+
return !1;
|
|
24206
|
+
}
|
|
24207
|
+
}()), isDockerCached)), cachedResult;
|
|
24208
|
+
}
|
|
24209
|
+
let isWsl = ()=>{
|
|
24210
|
+
if ('linux' !== node_process.platform) return !1;
|
|
24211
|
+
if (node_os.release().toLowerCase().includes('microsoft')) return !isInsideContainer();
|
|
24212
|
+
try {
|
|
24213
|
+
return !!node_fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') && !isInsideContainer();
|
|
24214
|
+
} catch {
|
|
24215
|
+
return !1;
|
|
24216
|
+
}
|
|
24217
|
+
}, 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 = {})=>{
|
|
24218
|
+
let { powerShellPath: psPath, ...execFileOptions } = options, encodedCommand = executePowerShell.encodeCommand(command);
|
|
24219
|
+
return execFile(psPath ?? powerShellPath(), [
|
|
24220
|
+
...executePowerShell.argumentsPrefix,
|
|
24221
|
+
encodedCommand
|
|
24222
|
+
], {
|
|
24223
|
+
encoding: 'utf8',
|
|
24224
|
+
...execFileOptions
|
|
24225
|
+
});
|
|
24226
|
+
};
|
|
24227
|
+
executePowerShell.argumentsPrefix = [
|
|
24228
|
+
'-NoProfile',
|
|
24229
|
+
'-NonInteractive',
|
|
24230
|
+
'-ExecutionPolicy',
|
|
24231
|
+
'Bypass',
|
|
24232
|
+
'-EncodedCommand'
|
|
24233
|
+
], executePowerShell.encodeCommand = (command)=>external_node_buffer_Buffer.from(command, 'utf16le').toString('base64'), executePowerShell.escapeArgument = (value)=>`'${String(value).replaceAll('\'', '\'\'')}'`;
|
|
24234
|
+
let wsl_utils_execFile = promisify(node_child_process.execFile), wslDrivesMountPoint = (defaultMountPoint = '/mnt/', async function() {
|
|
24235
|
+
if (mountPoint) return mountPoint;
|
|
24236
|
+
let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
|
|
24237
|
+
try {
|
|
24238
|
+
await promises.access(configFilePath, constants.F_OK), isConfigFileExists = !0;
|
|
24239
|
+
} catch {}
|
|
24240
|
+
if (!isConfigFileExists) return defaultMountPoint;
|
|
24241
|
+
let parsedMountPoint = function(content) {
|
|
24242
|
+
for (let line of content.split('\n')){
|
|
24243
|
+
if (/^\s*#/.test(line)) continue;
|
|
24244
|
+
let match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
24245
|
+
if (match) return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, '');
|
|
24246
|
+
}
|
|
24247
|
+
}(await promises.readFile(configFilePath, {
|
|
24248
|
+
encoding: 'utf8'
|
|
24249
|
+
}));
|
|
24250
|
+
return void 0 === parsedMountPoint ? defaultMountPoint : mountPoint = (mountPoint = parsedMountPoint).endsWith('/') ? mountPoint : `${mountPoint}/`;
|
|
24251
|
+
}), powerShellPathFromWsl = async ()=>{
|
|
24252
|
+
let mountPoint = await wslDrivesMountPoint();
|
|
24253
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
24254
|
+
}, wsl_utils_powerShellPath = is_wsl ? powerShellPathFromWsl : powerShellPath, wsl_utils_canAccessPowerShell = async ()=>canAccessPowerShellPromise ??= (async ()=>{
|
|
24255
|
+
try {
|
|
24256
|
+
let psPath = await wsl_utils_powerShellPath();
|
|
24257
|
+
return await promises.access(psPath, constants.X_OK), !0;
|
|
24258
|
+
} catch {
|
|
24259
|
+
return !1;
|
|
24260
|
+
}
|
|
24261
|
+
})(), wslDefaultBrowser = async ()=>{
|
|
24262
|
+
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, {
|
|
24263
|
+
powerShellPath: psPath,
|
|
24264
|
+
cwd: node_path.dirname(psPath)
|
|
24265
|
+
});
|
|
24266
|
+
return stdout.trim();
|
|
24267
|
+
}, isUrl = (path)=>/^[a-z]+:\/\//i.test(path), convertWslPathToWindows = async (paths)=>{
|
|
24268
|
+
let isBatch = Array.isArray(paths), pathArray = isBatch ? paths : [
|
|
24269
|
+
paths
|
|
24270
|
+
], indicesToConvert = [], pathsToConvert = [];
|
|
24271
|
+
for (let [index, path] of pathArray.entries())isUrl(path) || (indicesToConvert.push(index), pathsToConvert.push(path));
|
|
24272
|
+
let results = [
|
|
24273
|
+
...pathArray
|
|
24274
|
+
];
|
|
24275
|
+
if (pathsToConvert.length > 0) try {
|
|
24276
|
+
let { stdout } = await wsl_utils_execFile('wslpath', [
|
|
24277
|
+
'-aw',
|
|
24278
|
+
...pathsToConvert
|
|
24279
|
+
], {
|
|
24280
|
+
encoding: 'utf8'
|
|
24281
|
+
}), convertedPaths = stdout.split(/\r?\n/).filter(Boolean);
|
|
24282
|
+
for (let [index, originalIndex] of indicesToConvert.entries())results[originalIndex] = convertedPaths[index] ?? pathArray[originalIndex];
|
|
24283
|
+
} catch {}
|
|
24284
|
+
return isBatch ? results : results[0];
|
|
24285
|
+
}, powershell_utils_execFile = promisify(node_child_process.execFile), argumentsPrefix = [
|
|
24286
|
+
'-NoProfile',
|
|
24287
|
+
'-NonInteractive',
|
|
24288
|
+
'-ExecutionPolicy',
|
|
24289
|
+
'Bypass',
|
|
24290
|
+
'-EncodedCommand'
|
|
24291
|
+
], encodeCommand = (command)=>external_node_buffer_Buffer.from(command, 'utf16le').toString('base64'), createArguments = (command)=>[
|
|
24292
|
+
...argumentsPrefix,
|
|
24293
|
+
encodeCommand(command)
|
|
24294
|
+
], powershell_utils_executePowerShell = async (command, options = {})=>{
|
|
24295
|
+
let { powerShellPath: psPath, ...execFileOptions } = options;
|
|
24296
|
+
return powershell_utils_execFile(psPath ?? `${node_process.env.SYSTEMROOT || node_process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, createArguments(command), {
|
|
24297
|
+
encoding: 'utf8',
|
|
24298
|
+
...execFileOptions,
|
|
24299
|
+
shell: !1
|
|
24300
|
+
});
|
|
24301
|
+
};
|
|
24302
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
24303
|
+
let define = (value)=>Object.defineProperty(object, propertyName, {
|
|
24304
|
+
value,
|
|
24305
|
+
enumerable: !0,
|
|
24306
|
+
writable: !0
|
|
24307
|
+
});
|
|
24308
|
+
return Object.defineProperty(object, propertyName, {
|
|
24309
|
+
configurable: !0,
|
|
24310
|
+
enumerable: !0,
|
|
24311
|
+
get () {
|
|
24312
|
+
let result = valueGetter();
|
|
24313
|
+
return define(result), result;
|
|
24314
|
+
},
|
|
24315
|
+
set (value) {
|
|
24316
|
+
define(value);
|
|
24317
|
+
}
|
|
24318
|
+
}), object;
|
|
24319
|
+
}
|
|
24320
|
+
powershell_utils_executePowerShell.argumentsPrefix = argumentsPrefix, powershell_utils_executePowerShell.encodeCommand = encodeCommand, powershell_utils_executePowerShell.escapeArgument = (value)=>`'${String(value).replaceAll(/['‘’‚‛]/g, (match)=>match + match)}'`, powershell_utils_executePowerShell.createArguments = createArguments;
|
|
24321
|
+
let execFileAsync = promisify(external_node_child_process_execFile);
|
|
24322
|
+
async function defaultBrowserId() {
|
|
24323
|
+
if ('darwin' !== node_process.platform) throw Error('macOS only');
|
|
24324
|
+
let { stdout } = await execFileAsync('defaults', [
|
|
24325
|
+
'read',
|
|
24326
|
+
'com.apple.LaunchServices/com.apple.launchservices.secure',
|
|
24327
|
+
'LSHandlers'
|
|
24328
|
+
]), match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
24329
|
+
return match?.groups.id ?? 'com.apple.Safari';
|
|
24330
|
+
}
|
|
24331
|
+
let run_applescript_execFileAsync = promisify(external_node_child_process_execFile);
|
|
24332
|
+
async function runAppleScript(script, { humanReadableOutput = !0 } = {}) {
|
|
24333
|
+
if ('darwin' !== node_process.platform) throw Error('macOS only');
|
|
24334
|
+
let { stdout } = await run_applescript_execFileAsync("osascript", [
|
|
24335
|
+
'-e',
|
|
24336
|
+
script,
|
|
24337
|
+
humanReadableOutput ? [] : [
|
|
24338
|
+
'-ss'
|
|
24339
|
+
]
|
|
24340
|
+
]);
|
|
24341
|
+
return stdout.trim();
|
|
24342
|
+
}
|
|
24343
|
+
async function bundleName(bundleId) {
|
|
24344
|
+
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")`);
|
|
24345
|
+
}
|
|
24346
|
+
let windows_execFileAsync = promisify(external_node_child_process_execFile), windowsBrowserProgIds = {
|
|
24347
|
+
MSEdgeHTM: {
|
|
24348
|
+
name: 'Edge',
|
|
24349
|
+
id: 'com.microsoft.edge'
|
|
24350
|
+
},
|
|
24351
|
+
MSEdgeBHTML: {
|
|
24352
|
+
name: 'Edge Beta',
|
|
24353
|
+
id: 'com.microsoft.edge.beta'
|
|
24354
|
+
},
|
|
24355
|
+
MSEdgeDHTML: {
|
|
24356
|
+
name: 'Edge Dev',
|
|
24357
|
+
id: 'com.microsoft.edge.dev'
|
|
24358
|
+
},
|
|
24359
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
|
|
24360
|
+
name: 'Edge',
|
|
24361
|
+
id: 'com.microsoft.edge.old'
|
|
24362
|
+
},
|
|
24363
|
+
ChromeHTML: {
|
|
24364
|
+
name: 'Chrome',
|
|
24365
|
+
id: 'com.google.chrome'
|
|
24366
|
+
},
|
|
24367
|
+
ChromeBHTML: {
|
|
24368
|
+
name: 'Chrome Beta',
|
|
24369
|
+
id: 'com.google.chrome.beta'
|
|
24370
|
+
},
|
|
24371
|
+
ChromeDHTML: {
|
|
24372
|
+
name: 'Chrome Dev',
|
|
24373
|
+
id: 'com.google.chrome.dev'
|
|
24374
|
+
},
|
|
24375
|
+
ChromiumHTM: {
|
|
24376
|
+
name: 'Chromium',
|
|
24377
|
+
id: 'org.chromium.Chromium'
|
|
24378
|
+
},
|
|
24379
|
+
BraveHTML: {
|
|
24380
|
+
name: 'Brave',
|
|
24381
|
+
id: 'com.brave.Browser'
|
|
24382
|
+
},
|
|
24383
|
+
BraveBHTML: {
|
|
24384
|
+
name: 'Brave Beta',
|
|
24385
|
+
id: 'com.brave.Browser.beta'
|
|
24386
|
+
},
|
|
24387
|
+
BraveDHTML: {
|
|
24388
|
+
name: 'Brave Dev',
|
|
24389
|
+
id: 'com.brave.Browser.dev'
|
|
24390
|
+
},
|
|
24391
|
+
BraveSSHTM: {
|
|
24392
|
+
name: 'Brave Nightly',
|
|
24393
|
+
id: 'com.brave.Browser.nightly'
|
|
24394
|
+
},
|
|
24395
|
+
FirefoxURL: {
|
|
24396
|
+
name: 'Firefox',
|
|
24397
|
+
id: 'org.mozilla.firefox'
|
|
24398
|
+
},
|
|
24399
|
+
OperaStable: {
|
|
24400
|
+
name: 'Opera',
|
|
24401
|
+
id: 'com.operasoftware.Opera'
|
|
24402
|
+
},
|
|
24403
|
+
VivaldiHTM: {
|
|
24404
|
+
name: 'Vivaldi',
|
|
24405
|
+
id: 'com.vivaldi.Vivaldi'
|
|
24406
|
+
},
|
|
24407
|
+
'IE.HTTP': {
|
|
24408
|
+
name: 'Internet Explorer',
|
|
24409
|
+
id: 'com.microsoft.ie'
|
|
24410
|
+
}
|
|
24411
|
+
}, _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
24412
|
+
class UnknownBrowserError extends Error {
|
|
24413
|
+
}
|
|
24414
|
+
async function defaultBrowser(_execFileAsync = windows_execFileAsync) {
|
|
24415
|
+
let regPath = `${node_process.env.SYSTEMROOT ?? node_process.env.windir ?? 'C:\\Windows'}\\System32\\reg.exe`, { stdout } = await _execFileAsync(regPath, [
|
|
24416
|
+
'QUERY',
|
|
24417
|
+
' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',
|
|
24418
|
+
'/v',
|
|
24419
|
+
'ProgId'
|
|
24420
|
+
]), match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
24421
|
+
if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
24422
|
+
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);
|
|
24423
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? {
|
|
24424
|
+
name: id,
|
|
24425
|
+
id
|
|
24426
|
+
};
|
|
24427
|
+
}
|
|
24428
|
+
let default_browser_execFileAsync = promisify(external_node_child_process_execFile);
|
|
24429
|
+
async function default_browser_defaultBrowser() {
|
|
24430
|
+
if ('darwin' === node_process.platform) {
|
|
24431
|
+
let id = await defaultBrowserId();
|
|
24432
|
+
return {
|
|
24433
|
+
name: await bundleName(id),
|
|
24434
|
+
id
|
|
24435
|
+
};
|
|
24436
|
+
}
|
|
24437
|
+
if ('linux' === node_process.platform) {
|
|
24438
|
+
let { stdout } = await default_browser_execFileAsync('xdg-mime', [
|
|
24439
|
+
'query',
|
|
24440
|
+
'default',
|
|
24441
|
+
'x-scheme-handler/http'
|
|
24442
|
+
]), id = stdout.trim();
|
|
24443
|
+
return {
|
|
24444
|
+
name: id.replace(/.desktop$/, '').replace('-', ' ').toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x)=>x.toUpperCase()),
|
|
24445
|
+
id
|
|
24446
|
+
};
|
|
24447
|
+
}
|
|
24448
|
+
if ('win32' === node_process.platform) return defaultBrowser();
|
|
24449
|
+
throw Error('Only macOS, Linux, and Windows are supported');
|
|
24450
|
+
}
|
|
24451
|
+
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)=>{
|
|
24452
|
+
if (0 === apps.length) return;
|
|
24453
|
+
let errors = [];
|
|
24454
|
+
for (let app of apps)try {
|
|
24455
|
+
return await opener(app);
|
|
24456
|
+
} catch (error) {
|
|
24457
|
+
errors.push(error);
|
|
24458
|
+
}
|
|
24459
|
+
throw AggregateError(errors, 'Failed to open in all supported apps');
|
|
24460
|
+
}, baseOpen = async (options)=>{
|
|
24461
|
+
let command, isFallbackAttempt = !0 === (options = {
|
|
24462
|
+
wait: !1,
|
|
24463
|
+
background: !1,
|
|
24464
|
+
newInstance: !1,
|
|
24465
|
+
allowNonzeroExitCode: !1,
|
|
24466
|
+
...options
|
|
24467
|
+
})[fallbackAttemptSymbol];
|
|
24468
|
+
if (delete options[fallbackAttemptSymbol], Array.isArray(options.app)) return tryEachApp(options.app, (singleApp)=>baseOpen({
|
|
24469
|
+
...options,
|
|
24470
|
+
app: singleApp,
|
|
24471
|
+
[fallbackAttemptSymbol]: !0
|
|
24472
|
+
}));
|
|
24473
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
24474
|
+
if (appArguments = [
|
|
24475
|
+
...appArguments
|
|
24476
|
+
], Array.isArray(app)) return tryEachApp(app, (appName)=>baseOpen({
|
|
24477
|
+
...options,
|
|
24478
|
+
app: {
|
|
24479
|
+
name: appName,
|
|
24480
|
+
arguments: appArguments
|
|
24481
|
+
},
|
|
24482
|
+
[fallbackAttemptSymbol]: !0
|
|
24483
|
+
}));
|
|
24484
|
+
if ('browser' === app || 'browserPrivate' === app) {
|
|
24485
|
+
let browser, ids = {
|
|
24486
|
+
'com.google.chrome': 'chrome',
|
|
24487
|
+
'google-chrome.desktop': 'chrome',
|
|
24488
|
+
'com.brave.browser': 'brave',
|
|
24489
|
+
'org.mozilla.firefox': 'firefox',
|
|
24490
|
+
'firefox.desktop': 'firefox',
|
|
24491
|
+
'com.microsoft.msedge': 'edge',
|
|
24492
|
+
'com.microsoft.edge': 'edge',
|
|
24493
|
+
'com.microsoft.edgemac': 'edge',
|
|
24494
|
+
'microsoft-edge.desktop': 'edge',
|
|
24495
|
+
'com.apple.safari': 'safari'
|
|
24496
|
+
};
|
|
24497
|
+
if (is_wsl) {
|
|
24498
|
+
let progId = await wslDefaultBrowser();
|
|
24499
|
+
browser = _windowsBrowserProgIdMap.get(progId) ?? {};
|
|
24500
|
+
} else browser = await default_browser_defaultBrowser();
|
|
24501
|
+
if (Object.hasOwn(ids, browser.id)) {
|
|
24502
|
+
let browserName = ids[browser.id.toLowerCase()];
|
|
24503
|
+
if (void 0 === browserName) throw Error(`${browser.name} is not supported as a default browser`);
|
|
24504
|
+
if ('browserPrivate' === app) {
|
|
24505
|
+
if ('safari' === browserName) throw Error('Safari doesn\'t support opening in private mode via command line');
|
|
24506
|
+
appArguments.push({
|
|
24507
|
+
chrome: '--incognito',
|
|
24508
|
+
brave: '--incognito',
|
|
24509
|
+
firefox: '--private-window',
|
|
24510
|
+
edge: '--inPrivate'
|
|
24511
|
+
}[browserName]);
|
|
24512
|
+
}
|
|
24513
|
+
return baseOpen({
|
|
24514
|
+
...options,
|
|
24515
|
+
app: {
|
|
24516
|
+
name: open_apps[browserName],
|
|
24517
|
+
arguments: appArguments
|
|
24518
|
+
}
|
|
24519
|
+
});
|
|
24520
|
+
}
|
|
24521
|
+
throw Error(`${browser.name} is not supported as a default browser`);
|
|
24522
|
+
}
|
|
24523
|
+
let cliArguments = [], childProcessOptions = {}, shouldUseWindowsInWsl = !1;
|
|
24524
|
+
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);
|
|
24525
|
+
else if ('win32' === platform || shouldUseWindowsInWsl) {
|
|
24526
|
+
command = await wsl_utils_powerShellPath(), cliArguments.push(...powershell_utils_executePowerShell.argumentsPrefix), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0), is_wsl && options.target && (options.target = await convertWslPathToWindows(options.target));
|
|
24527
|
+
let encodedArguments = [
|
|
24528
|
+
'$ProgressPreference = \'SilentlyContinue\';',
|
|
24529
|
+
'Start'
|
|
24530
|
+
];
|
|
24531
|
+
options.wait && encodedArguments.push('-Wait'), app ? (encodedArguments.push(powershell_utils_executePowerShell.escapeArgument(app)), options.target && appArguments.push(options.target)) : options.target && encodedArguments.push(powershell_utils_executePowerShell.escapeArgument(options.target)), appArguments.length > 0 && encodedArguments.push('-ArgumentList', (appArguments = appArguments.map((argument)=>powershell_utils_executePowerShell.escapeArgument(argument))).join(',')), options.target = powershell_utils_executePowerShell.encodeCommand(encodedArguments.join(' ')), options.wait || (childProcessOptions.stdio = 'ignore'), is_wsl && (childProcessOptions.cwd = node_path.dirname(command));
|
|
24532
|
+
} else {
|
|
24533
|
+
if (app) command = app;
|
|
24534
|
+
else {
|
|
24535
|
+
let exeLocalXdgOpen = !1;
|
|
24536
|
+
try {
|
|
24537
|
+
await promises.access(localXdgOpenPath, constants.X_OK), exeLocalXdgOpen = !0;
|
|
24538
|
+
} catch {}
|
|
24539
|
+
command = node_process.versions.electron ?? ('android' === platform || !open_dirname || '/' === open_dirname || !exeLocalXdgOpen) ? 'xdg-open' : localXdgOpenPath;
|
|
24540
|
+
}
|
|
24541
|
+
appArguments.length > 0 && cliArguments.push(...appArguments), options.wait || (childProcessOptions.stdio = 'ignore', childProcessOptions.detached = !0);
|
|
24542
|
+
}
|
|
24543
|
+
'darwin' === platform && appArguments.length > 0 && cliArguments.push('--args', ...appArguments), options.target && cliArguments.push(options.target);
|
|
24544
|
+
let subprocess = node_child_process.spawn(command, cliArguments, childProcessOptions);
|
|
24545
|
+
return options.wait ? new Promise((resolve, reject)=>{
|
|
24546
|
+
subprocess.once('error', reject), subprocess.once('close', (exitCode)=>{
|
|
24547
|
+
options.allowNonzeroExitCode || 0 === exitCode ? resolve(subprocess) : reject(Error(`Exited with code ${exitCode}`));
|
|
24548
|
+
});
|
|
24549
|
+
}) : isFallbackAttempt ? new Promise((resolve, reject)=>{
|
|
24550
|
+
subprocess.once('error', reject), subprocess.once('spawn', ()=>{
|
|
24551
|
+
subprocess.once('close', (exitCode)=>{
|
|
24552
|
+
(subprocess.off('error', reject), 0 !== exitCode) ? reject(Error(`Exited with code ${exitCode}`)) : (subprocess.unref(), resolve(subprocess));
|
|
24553
|
+
});
|
|
24554
|
+
});
|
|
24555
|
+
}) : (subprocess.unref(), new Promise((resolve, reject)=>{
|
|
24556
|
+
subprocess.once('error', reject), subprocess.once('spawn', ()=>{
|
|
24557
|
+
subprocess.off('error', reject), resolve(subprocess);
|
|
24558
|
+
});
|
|
24559
|
+
}));
|
|
24560
|
+
};
|
|
24561
|
+
function detectArchBinary(binary) {
|
|
24562
|
+
if ('string' == typeof binary || Array.isArray(binary)) return binary;
|
|
24563
|
+
let { [arch]: archBinary } = binary;
|
|
24564
|
+
if (!archBinary) throw Error(`${arch} is not supported`);
|
|
24565
|
+
return archBinary;
|
|
24566
|
+
}
|
|
24567
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
24568
|
+
if (wsl && is_wsl) return detectArchBinary(wsl);
|
|
24569
|
+
if (!platformBinary) throw Error(`${platform} is not supported`);
|
|
24570
|
+
return detectArchBinary(platformBinary);
|
|
24571
|
+
}
|
|
24572
|
+
let open_apps = {
|
|
24573
|
+
browser: 'browser',
|
|
24574
|
+
browserPrivate: 'browserPrivate'
|
|
24575
|
+
};
|
|
24576
|
+
defineLazyProperty(open_apps, 'chrome', ()=>detectPlatformBinary({
|
|
24577
|
+
darwin: 'google chrome',
|
|
24578
|
+
win32: 'chrome',
|
|
24579
|
+
linux: [
|
|
24580
|
+
'google-chrome',
|
|
24581
|
+
'google-chrome-stable',
|
|
24582
|
+
'chromium',
|
|
24583
|
+
'chromium-browser'
|
|
24584
|
+
]
|
|
24585
|
+
}, {
|
|
24586
|
+
wsl: {
|
|
24587
|
+
ia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
|
|
24588
|
+
x64: [
|
|
24589
|
+
'/mnt/c/Program Files/Google/Chrome/Application/chrome.exe',
|
|
24590
|
+
'/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
|
|
24591
|
+
]
|
|
24592
|
+
}
|
|
24593
|
+
})), defineLazyProperty(open_apps, 'brave', ()=>detectPlatformBinary({
|
|
24594
|
+
darwin: 'brave browser',
|
|
24595
|
+
win32: 'brave',
|
|
24596
|
+
linux: [
|
|
24597
|
+
'brave-browser',
|
|
24598
|
+
'brave'
|
|
24599
|
+
]
|
|
24600
|
+
}, {
|
|
24601
|
+
wsl: {
|
|
24602
|
+
ia32: '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe',
|
|
24603
|
+
x64: [
|
|
24604
|
+
'/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe',
|
|
24605
|
+
'/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'
|
|
24606
|
+
]
|
|
24607
|
+
}
|
|
24608
|
+
})), defineLazyProperty(open_apps, 'firefox', ()=>detectPlatformBinary({
|
|
24609
|
+
darwin: 'firefox',
|
|
24610
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
24611
|
+
linux: 'firefox'
|
|
24612
|
+
}, {
|
|
24613
|
+
wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
|
|
24614
|
+
})), defineLazyProperty(open_apps, 'edge', ()=>detectPlatformBinary({
|
|
24615
|
+
darwin: 'microsoft edge',
|
|
24616
|
+
win32: 'msedge',
|
|
24617
|
+
linux: [
|
|
24618
|
+
'microsoft-edge',
|
|
24619
|
+
'microsoft-edge-dev'
|
|
24620
|
+
]
|
|
24621
|
+
}, {
|
|
24622
|
+
wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
|
|
24623
|
+
})), defineLazyProperty(open_apps, 'safari', ()=>detectPlatformBinary({
|
|
24624
|
+
darwin: 'Safari'
|
|
24625
|
+
}));
|
|
24626
|
+
let node_modules_open = (target, options)=>{
|
|
24627
|
+
if ('string' != typeof target) throw TypeError('Expected a `target`');
|
|
24628
|
+
return baseOpen({
|
|
24629
|
+
...options,
|
|
24630
|
+
target
|
|
24631
|
+
});
|
|
24185
24632
|
}, execAsync = promisify(external_node_child_process_exec), supportedChromiumBrowsers = [
|
|
24186
24633
|
'Google Chrome Canary',
|
|
24187
24634
|
'Google Chrome Dev',
|
|
@@ -24200,8 +24647,7 @@ let normalizeRspackUserOptions = function(config = {}) {
|
|
|
24200
24647
|
return targetBrowser;
|
|
24201
24648
|
}, openWithDefaultBrowser = async (url)=>{
|
|
24202
24649
|
try {
|
|
24203
|
-
|
|
24204
|
-
return await open(url), !0;
|
|
24650
|
+
return await node_modules_open(url), !0;
|
|
24205
24651
|
} catch (err) {
|
|
24206
24652
|
return rsdoctorLogger.error('Failed to open Rsdoctor URL.'), rsdoctorLogger.error(err), !1;
|
|
24207
24653
|
}
|
|
@@ -26231,4 +26677,4 @@ class InternalResolverPlugin extends InternalBasePlugin {
|
|
|
26231
26677
|
}
|
|
26232
26678
|
}
|
|
26233
26679
|
export { default as fs_extra } from "fs-extra";
|
|
26234
|
-
export { DevToolError, InternalBundlePlugin, InternalErrorReporterPlugin, InternalLoaderPlugin, InternalPluginsPlugin, InternalResolverPlugin, InternalRulesPlugin, InternalSummaryPlugin, Linter as LinterType, ProbeLoaderPlugin, createServer, defaultHost, defaultPort, defineRule, ensureModulesChunksGraphFn, getCPUInfo, getInternalLoaderOptions, getMemoryInfo, getNodeVersion, getNpmVersion, getOriginLoaderModule, getPnpmVersion, getPortSync, getRspackNativePlugin, getYarnVersion, handleBriefModeReport, isCompilerWatching, linter_Linter as Linter, normalizeRspackUserOptions, processCompilerConfig, reportLoader, rule_Rule as LinterRule, rules_rules as rules, shouldSkipLoader };
|
|
26680
|
+
export { DevToolError, InternalBundlePlugin, InternalErrorReporterPlugin, InternalLoaderPlugin, InternalPluginsPlugin, InternalResolverPlugin, InternalRulesPlugin, InternalSummaryPlugin, Linter as LinterType, ProbeLoaderPlugin, createServer, defaultHost, defaultPort, defineRule, ensureModulesChunksGraphFn, getCPUInfo, getInternalLoaderOptions, getMemoryInfo, getNodeVersion, getNpmVersion, getOriginLoaderModule, getPnpmVersion, getPortSync, getRspackNativePlugin, getYarnVersion, handleBriefModeReport, isCompilerWatching, linter_Linter as Linter, node_modules_open, normalizeRspackUserOptions, processCompilerConfig, reportLoader, rule_Rule as LinterRule, rules_rules as rules, shouldSkipLoader };
|