@unpackjs/core 3.2.4 → 3.2.6
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/compiled/css-loader/index.js +20 -20
- package/compiled/less-loader/index.js +8 -8
- package/compiled/postcss-loader/index.js +10 -10
- package/compiled/sass-loader/index.js +9 -9
- package/dist/index.cjs +70 -655
- package/dist/index.js +99 -682
- package/dist-types/bundler-config/index.d.ts +1 -1
- package/dist-types/bundler-config/index.d.ts.map +1 -1
- package/dist-types/createUnpack.d.ts.map +1 -1
- package/dist-types/index.d.ts +0 -1
- package/dist-types/index.d.ts.map +1 -1
- package/dist-types/prebundleDeps.d.ts.map +1 -1
- package/dist-types/run/dev.d.ts.map +1 -1
- package/dist-types/types/config.d.ts +4 -1
- package/dist-types/types/config.d.ts.map +1 -1
- package/package.json +5 -5
- package/compiled/sass-loader/sass.node.js +0 -12
- package/dist-types/launch-editor/editor-info/index.d.ts +0 -4
- package/dist-types/launch-editor/editor-info/index.d.ts.map +0 -1
- package/dist-types/launch-editor/editor-info/linux.d.ts +0 -33
- package/dist-types/launch-editor/editor-info/linux.d.ts.map +0 -1
- package/dist-types/launch-editor/editor-info/macos.d.ts +0 -35
- package/dist-types/launch-editor/editor-info/macos.d.ts.map +0 -1
- package/dist-types/launch-editor/editor-info/windows.d.ts +0 -6
- package/dist-types/launch-editor/editor-info/windows.d.ts.map +0 -1
- package/dist-types/launch-editor/get-args.d.ts +0 -12
- package/dist-types/launch-editor/get-args.d.ts.map +0 -1
- package/dist-types/launch-editor/guess.d.ts +0 -3
- package/dist-types/launch-editor/guess.d.ts.map +0 -1
- package/dist-types/launch-editor/index.d.ts +0 -7
- package/dist-types/launch-editor/index.d.ts.map +0 -1
- package/dist-types/launch-editor/types.d.ts +0 -7
- package/dist-types/launch-editor/types.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -4,15 +4,15 @@ import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
|
|
|
4
4
|
import { dirname as __webpack_dirname__ } from "node:path";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_bundle_analyzer_index_js_1177eada__ from "../compiled/webpack-bundle-analyzer/index.js";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_merge_index_js_efd91626__ from "../compiled/webpack-merge/index.js";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
8
7
|
import { experiments, rspack } from "@rspack/core";
|
|
9
8
|
import picocolors from "picocolors";
|
|
10
9
|
import node_fs from "node:fs";
|
|
11
10
|
import node_path, { join, sep } from "node:path";
|
|
11
|
+
import { pathToFileURL } from "node:url";
|
|
12
12
|
import { createJiti } from "jiti";
|
|
13
13
|
import node_readline from "node:readline";
|
|
14
14
|
import node_net from "node:net";
|
|
15
|
-
import node_os, { platform
|
|
15
|
+
import node_os, { platform } from "node:os";
|
|
16
16
|
import portfinder from "portfinder";
|
|
17
17
|
import { expand } from "dotenv-expand";
|
|
18
18
|
import { TsCheckerRspackPlugin } from "ts-checker-rspack-plugin";
|
|
@@ -20,7 +20,7 @@ import node_assert from "node:assert";
|
|
|
20
20
|
import { glob, globSync } from "tinyglobby";
|
|
21
21
|
import typed_css_modules from "typed-css-modules";
|
|
22
22
|
import { minify } from "oxc-minify";
|
|
23
|
-
import
|
|
23
|
+
import { exec, spawn } from "node:child_process";
|
|
24
24
|
import { promisify } from "node:util";
|
|
25
25
|
import node_zlib from "node:zlib";
|
|
26
26
|
import cors from "cors";
|
|
@@ -33,9 +33,6 @@ var LogColor, __webpack_modules__ = {
|
|
|
33
33
|
},
|
|
34
34
|
"compiled/webpack-merge": function(module) {
|
|
35
35
|
module.exports = __WEBPACK_EXTERNAL_MODULE__compiled_webpack_merge_index_js_efd91626__;
|
|
36
|
-
},
|
|
37
|
-
"node:url": function(module) {
|
|
38
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__;
|
|
39
36
|
}
|
|
40
37
|
}, __webpack_module_cache__ = {};
|
|
41
38
|
function __webpack_require__(moduleId) {
|
|
@@ -56,7 +53,7 @@ let colors = {
|
|
|
56
53
|
return output;
|
|
57
54
|
}
|
|
58
55
|
};
|
|
59
|
-
var
|
|
56
|
+
var logger_LogColor = ((LogColor = {}).error = "red", LogColor.warn = "yellow", LogColor.info = "cyan", LogColor.ready = "green", LogColor.event = "magenta", LogColor.wait = "blue", LogColor.debug = "dim", LogColor);
|
|
60
57
|
let CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]', CSS_MODULES_REGEX = /\.module\.\w+$/i, DEV_DEFAULT_FILENAME = {
|
|
61
58
|
js: 'js/[name].js',
|
|
62
59
|
jsAsync: 'js/async/[name].js',
|
|
@@ -276,10 +273,10 @@ async function loadConfig({ cliOptions, command }) {
|
|
|
276
273
|
'build' === command ? setNodeEnv((null == cliOptions ? void 0 : cliOptions.watch) ? 'development' : 'production') : (setNodeEnv('development'), setDevServer(!0));
|
|
277
274
|
let root = (null == cliOptions ? void 0 : cliOptions.root) ? node_path.resolve(cliOptions.root) : process.cwd(), configFilePath = resolveConfigPath(root, null == cliOptions ? void 0 : cliOptions.config), configExport = {};
|
|
278
275
|
if (configFilePath) {
|
|
279
|
-
if (isNodeVersionAtLeast(
|
|
276
|
+
if (isNodeVersionAtLeast(22, 18) || /\.(?:js|mjs|cjs)$/.test(configFilePath)) {
|
|
280
277
|
logger_logger.debug('loading config file with native loader:', colors.dim(configFilePath));
|
|
281
278
|
try {
|
|
282
|
-
let configFileURL =
|
|
279
|
+
let configFileURL = pathToFileURL(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
|
|
283
280
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
284
281
|
} catch (err) {
|
|
285
282
|
throw logger_logger.error('failed to load config file with native loader:', colors.dim(configFilePath)), err;
|
|
@@ -345,12 +342,6 @@ function resolveConfigPath(root, customConfig) {
|
|
|
345
342
|
}
|
|
346
343
|
return null;
|
|
347
344
|
}
|
|
348
|
-
function getNormalizedPluginsByHook(hook, plugins) {
|
|
349
|
-
let pluginMap = new Map();
|
|
350
|
-
return null == plugins || plugins.forEach((plugin)=>{
|
|
351
|
-
plugin[hook] && pluginMap.set(plugin.name, plugin);
|
|
352
|
-
}), Array.from(pluginMap.values());
|
|
353
|
-
}
|
|
354
345
|
let isFileSync = (filePath)=>{
|
|
355
346
|
try {
|
|
356
347
|
var _fs_statSync;
|
|
@@ -381,6 +372,12 @@ let removeDir = (dir)=>{
|
|
|
381
372
|
force: !0
|
|
382
373
|
});
|
|
383
374
|
}, DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
375
|
+
function getNormalizedPluginsByHook(hook, plugins) {
|
|
376
|
+
let pluginMap = new Map();
|
|
377
|
+
return null == plugins || plugins.forEach((plugin)=>{
|
|
378
|
+
plugin[hook] && pluginMap.set(plugin.name, plugin);
|
|
379
|
+
}), Array.from(pluginMap.values());
|
|
380
|
+
}
|
|
384
381
|
async function getBuildDependencies(root, userBuildDependencies, envFilePaths) {
|
|
385
382
|
let rootPackageJson = node_path.join(root, 'package.json'), browserslistConfig = node_path.join(root, '.browserslistrc'), tsconfigPath = node_path.join(root, 'tsconfig.json'), buildDependencies = {};
|
|
386
383
|
await isFileExists(rootPackageJson) && (buildDependencies.packageJson = [
|
|
@@ -592,7 +589,7 @@ class JsMinifyPlugin {
|
|
|
592
589
|
apply(compiler) {
|
|
593
590
|
let meta = JSON.stringify({
|
|
594
591
|
name: jsMinify_PLUGIN_NAME,
|
|
595
|
-
version: "3.2.
|
|
592
|
+
version: "3.2.6",
|
|
596
593
|
options: this.minifyOptions
|
|
597
594
|
});
|
|
598
595
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -922,9 +919,18 @@ class ProgressRspackPlugin extends rspack.ProgressPlugin {
|
|
|
922
919
|
}
|
|
923
920
|
}
|
|
924
921
|
let BundleAnalyzerPlugin = __webpack_require__("compiled/webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
|
925
|
-
async function getBundlerConfig(
|
|
922
|
+
async function getBundlerConfig(originalUnpackConfig) {
|
|
926
923
|
var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_build2, _unpackConfig_build3, _unpackConfig_build4, _unpackConfig_build5, _unpackConfig_build6, _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_performance, _unpackConfig_performance1, _unpackConfig_build7, _unpackConfig_resolve, _unpackConfig_resolve1, _unpackConfig_dev, _unpackConfig_build8, _unpackConfig_experiments, _unpackConfig_build9, _unpackConfig_dev1;
|
|
927
|
-
let circularCount,
|
|
924
|
+
let circularCount, { plugins, bundlerConfig, ...rest } = originalUnpackConfig;
|
|
925
|
+
for (let plugin of getNormalizedPluginsByHook('config', plugins))rest = await plugin.config(rest, {
|
|
926
|
+
...originalUnpackConfig._context,
|
|
927
|
+
mergeConfig: mergeConfig
|
|
928
|
+
});
|
|
929
|
+
let unpackConfig = {
|
|
930
|
+
...rest,
|
|
931
|
+
plugins,
|
|
932
|
+
bundlerConfig
|
|
933
|
+
}, tsconfigPath = node_path.resolve(unpackConfig.root, 'tsconfig.json'), isTs = node_fs.existsSync(tsconfigPath), minifyOptions = isPlainObject(null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.minify) ? null == (_unpackConfig_build1 = unpackConfig.build) ? void 0 : _unpackConfig_build1.minify : {}, ProgressPlugin = (null == (_unpackConfig_build2 = unpackConfig.build) ? void 0 : _unpackConfig_build2.progressBar) ? ProgressRspackPlugin : ProgressLiteRspackPlugin, { publicVars, filePaths: envFilePaths } = function({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
|
|
928
934
|
'PUBLIC_'
|
|
929
935
|
], processEnv = process.env } = {}) {
|
|
930
936
|
if ('local' === mode) throw Error(`${colors.yellow('local')} cannot be used as a value for env mode, because ${colors.yellow('.env.local')} represents a temporary local file. Please use another value.`);
|
|
@@ -1149,13 +1155,16 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1149
1155
|
...(null == (_unpackConfig_resolve1 = unpackConfig.resolve) ? void 0 : _unpackConfig_resolve1.extensions) || []
|
|
1150
1156
|
]
|
|
1151
1157
|
},
|
|
1158
|
+
lazyCompilation: (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.lazyCompilation) && utils_isDevServer() && {
|
|
1159
|
+
imports: !0,
|
|
1160
|
+
entries: !!unpackConfig.mpa
|
|
1161
|
+
},
|
|
1152
1162
|
experiments: {
|
|
1153
|
-
lazyCompilation: (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.lazyCompilation) && utils_isDevServer() && {
|
|
1154
|
-
imports: !0,
|
|
1155
|
-
entries: !!unpackConfig.mpa
|
|
1156
|
-
},
|
|
1157
1163
|
css: !1,
|
|
1158
|
-
asyncWebAssembly: !0
|
|
1164
|
+
asyncWebAssembly: !0,
|
|
1165
|
+
lazyBarrel: !0,
|
|
1166
|
+
inlineEnum: !0,
|
|
1167
|
+
typeReexportsPresence: !0
|
|
1159
1168
|
},
|
|
1160
1169
|
optimization: {
|
|
1161
1170
|
moduleIds: isDev() ? 'named' : 'deterministic',
|
|
@@ -1518,7 +1527,7 @@ async function openBrowser(url) {
|
|
|
1518
1527
|
try {
|
|
1519
1528
|
return new Promise((resolve, reject)=>{
|
|
1520
1529
|
let command, args = [];
|
|
1521
|
-
switch(
|
|
1530
|
+
switch(platform()){
|
|
1522
1531
|
case 'darwin':
|
|
1523
1532
|
command = 'open', args = [
|
|
1524
1533
|
url
|
|
@@ -1757,15 +1766,20 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1757
1766
|
...unpackConfig.externals
|
|
1758
1767
|
}, unpackConfig.plugins.push({
|
|
1759
1768
|
name: 'unpack:prebundle',
|
|
1769
|
+
config: (config)=>{
|
|
1770
|
+
var _config_html;
|
|
1771
|
+
let originalHeadTag = (null == (_config_html = config.html) ? void 0 : _config_html.headTag) || '', sortedPreTags = preJsAssets.sort((a, b)=>a.order - b.order).map((item)=>item.path).map((item)=>`<script defer src="${item}"></script>`);
|
|
1772
|
+
return setValueByPath(config, [
|
|
1773
|
+
'html',
|
|
1774
|
+
'headTag'
|
|
1775
|
+
], `${sortedPreTags.join('')}${originalHeadTag}`), config;
|
|
1776
|
+
},
|
|
1760
1777
|
bundlerConfig: (config)=>{
|
|
1761
1778
|
let PLUGIN_NAME = 'PluginInjectAssets';
|
|
1762
1779
|
return config.plugins.push({
|
|
1763
1780
|
apply: (compiler)=>{
|
|
1764
1781
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
1765
|
-
rspack.HtmlRspackPlugin.getCompilationHooks(compilation).beforeAssetTagGeneration.tapPromise(PLUGIN_NAME, async (args)=>
|
|
1766
|
-
let sortedPreJsAssets = preJsAssets.sort((a, b)=>a.order - b.order).map((item)=>item.path);
|
|
1767
|
-
return args.assets.js.unshift(...sortedPreJsAssets, ...jsAssets), args.assets.css.unshift(...cssAssets), args;
|
|
1768
|
-
});
|
|
1782
|
+
rspack.HtmlRspackPlugin.getCompilationHooks(compilation).beforeAssetTagGeneration.tapPromise(PLUGIN_NAME, async (args)=>(args.assets.js.unshift(...jsAssets), args.assets.css.unshift(...cssAssets), args));
|
|
1769
1783
|
});
|
|
1770
1784
|
}
|
|
1771
1785
|
}), config;
|
|
@@ -1779,11 +1793,19 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1779
1793
|
unpackConfig
|
|
1780
1794
|
}));
|
|
1781
1795
|
let compiler = rspack(await getBundlerConfig(unpackConfig)), port = await getPort(null == (_unpackConfig_server = unpackConfig.server) ? void 0 : _unpackConfig_server.port), proxyConfig = null == (_unpackConfig_server1 = unpackConfig.server) ? void 0 : _unpackConfig_server1.proxy;
|
|
1782
|
-
isPlainObject(proxyConfig) && (proxyConfig = Object.entries(proxyConfig).map(([contextStr, target])=>
|
|
1796
|
+
isPlainObject(proxyConfig) && (proxyConfig = Object.entries(proxyConfig).map(([contextStr, target])=>{
|
|
1797
|
+
let baseConfig = {
|
|
1783
1798
|
context: contextStr.split(','),
|
|
1784
|
-
target,
|
|
1785
1799
|
changeOrigin: !0
|
|
1786
|
-
}
|
|
1800
|
+
};
|
|
1801
|
+
return isPlainObject(target) ? {
|
|
1802
|
+
...baseConfig,
|
|
1803
|
+
...target
|
|
1804
|
+
} : {
|
|
1805
|
+
...baseConfig,
|
|
1806
|
+
target
|
|
1807
|
+
};
|
|
1808
|
+
}));
|
|
1787
1809
|
let devServerOptions = {
|
|
1788
1810
|
hot: !0,
|
|
1789
1811
|
port,
|
|
@@ -1801,7 +1823,7 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1801
1823
|
(null == (_req_headers_accept = req.headers.accept) ? void 0 : _req_headers_accept.includes('html')) && (req.url = '/index.html'), next();
|
|
1802
1824
|
}), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1803
1825
|
let server = new webpack_dev_server(devServerOptions, compiler);
|
|
1804
|
-
await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.2.
|
|
1826
|
+
await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.2.6`)} ${colors.dim(`ready in ${colors.reset(Math.ceil(performance.now() - global.__unpack_start_time))}ms`)}\n`), getAddressUrls({
|
|
1805
1827
|
port: port
|
|
1806
1828
|
}).forEach((addr)=>{
|
|
1807
1829
|
let url;
|
|
@@ -1816,664 +1838,59 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1816
1838
|
}
|
|
1817
1839
|
}
|
|
1818
1840
|
function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
1819
|
-
let resolveConfig =
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
..._context,
|
|
1859
|
-
mergeConfig: mergeConfig
|
|
1841
|
+
let resolveConfig = ()=>({
|
|
1842
|
+
...mergeConfig({
|
|
1843
|
+
root: cwd,
|
|
1844
|
+
build: {
|
|
1845
|
+
outDir: 'dist',
|
|
1846
|
+
minify: isProd(),
|
|
1847
|
+
sourceMap: !isProd() && 'cheap-module-source-map',
|
|
1848
|
+
parallel: !0,
|
|
1849
|
+
filenameHash: !0,
|
|
1850
|
+
target: 'es2022'
|
|
1851
|
+
},
|
|
1852
|
+
dev: {
|
|
1853
|
+
lazyCompilation: !0
|
|
1854
|
+
},
|
|
1855
|
+
server: {
|
|
1856
|
+
port: 3000
|
|
1857
|
+
},
|
|
1858
|
+
html: {
|
|
1859
|
+
mountId: 'root'
|
|
1860
|
+
},
|
|
1861
|
+
css: {
|
|
1862
|
+
modules: !0,
|
|
1863
|
+
transformer: 'postcss',
|
|
1864
|
+
sourceMap: !1
|
|
1865
|
+
},
|
|
1866
|
+
performance: {
|
|
1867
|
+
chunkSplit: {
|
|
1868
|
+
strategy: 'split-by-experience'
|
|
1869
|
+
}
|
|
1870
|
+
},
|
|
1871
|
+
typeCheck: !0,
|
|
1872
|
+
envPrefix: [
|
|
1873
|
+
'PUBLIC_'
|
|
1874
|
+
]
|
|
1875
|
+
}, config),
|
|
1876
|
+
_context: {
|
|
1877
|
+
callerName,
|
|
1878
|
+
version: "3.2.6"
|
|
1879
|
+
}
|
|
1860
1880
|
});
|
|
1861
|
-
return {
|
|
1862
|
-
...rest,
|
|
1863
|
-
plugins,
|
|
1864
|
-
bundlerConfig,
|
|
1865
|
-
_context
|
|
1866
|
-
};
|
|
1867
|
-
};
|
|
1868
1881
|
return {
|
|
1869
1882
|
build: async ({ watch } = {})=>{
|
|
1870
1883
|
setNodeEnv(watch ? 'development' : 'production');
|
|
1871
|
-
let config =
|
|
1872
|
-
console.log(colors.rainbow(`${callerName} v3.2.
|
|
1884
|
+
let config = resolveConfig();
|
|
1885
|
+
console.log(colors.rainbow(`${callerName} v3.2.6`), colors.green(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
|
|
1873
1886
|
},
|
|
1874
1887
|
dev: async ()=>{
|
|
1875
|
-
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0)
|
|
1888
|
+
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
|
|
1889
|
+
let config = resolveConfig();
|
|
1890
|
+
await unpackDev(config);
|
|
1876
1891
|
}
|
|
1877
1892
|
};
|
|
1878
1893
|
}
|
|
1879
|
-
let COMMON_EDITORS_MAP = {
|
|
1880
|
-
darwin: {
|
|
1881
|
-
'/Cursor.app/Contents/MacOS/Cursor': '/Cursor.app/Contents/MacOS/Cursor',
|
|
1882
|
-
'/Comate.app/Contents/MacOS/Electron': '/Comate.app/Contents/MacOS/Electron',
|
|
1883
|
-
'/Windsurf.app/Contents/MacOS/Electron': '/Windsurf.app/Contents/MacOS/Electron',
|
|
1884
|
-
'/Trae.app/Contents/MacOS/Electron': '/Trae.app/Contents/MacOS/Electron',
|
|
1885
|
-
'/Trae CN.app/Contents/MacOS/Electron': '/Trae CN.app/Contents/MacOS/Electron',
|
|
1886
|
-
'/Visual Studio Code.app/Contents/MacOS/Electron': '/Visual Studio Code.app/Contents/MacOS/Electron',
|
|
1887
|
-
'/Visual Studio Code - Insiders.app/Contents/MacOS/Electron': '/Visual Studio Code - Insiders.app/Contents/MacOS/Electron',
|
|
1888
|
-
'/VSCodium.app/Contents/MacOS/Electron': '/VSCodium.app/Contents/MacOS/Electron',
|
|
1889
|
-
'/WebStorm.app/Contents/MacOS/webstorm': '/WebStorm.app/Contents/MacOS/webstorm',
|
|
1890
|
-
'/HBuilderX.app/Contents/MacOS/HBuilderX': '/HBuilderX.app/Contents/MacOS/HBuilderX',
|
|
1891
|
-
'/Atom.app/Contents/MacOS/Atom': 'atom',
|
|
1892
|
-
'/Atom Beta.app/Contents/MacOS/Atom Beta': '/Atom Beta.app/Contents/MacOS/Atom Beta',
|
|
1893
|
-
'/Brackets.app/Contents/MacOS/Brackets': 'brackets',
|
|
1894
|
-
'/Sublime Text.app/Contents/MacOS/Sublime Text': '/Sublime Text.app/Contents/SharedSupport/bin/subl',
|
|
1895
|
-
'/Sublime Text.app/Contents/MacOS/sublime_text': '/Sublime Text.app/Contents/SharedSupport/bin/subl',
|
|
1896
|
-
'/Sublime Text 2.app/Contents/MacOS/Sublime Text 2': '/Sublime Text 2.app/Contents/SharedSupport/bin/subl',
|
|
1897
|
-
'/Sublime Text Dev.app/Contents/MacOS/Sublime Text': '/Sublime Text Dev.app/Contents/SharedSupport/bin/subl',
|
|
1898
|
-
'/PhpStorm.app/Contents/MacOS/phpstorm': '/PhpStorm.app/Contents/MacOS/phpstorm',
|
|
1899
|
-
'/PyCharm.app/Contents/MacOS/pycharm': '/PyCharm.app/Contents/MacOS/pycharm',
|
|
1900
|
-
'/PyCharm CE.app/Contents/MacOS/pycharm': '/PyCharm CE.app/Contents/MacOS/pycharm',
|
|
1901
|
-
'/IntelliJ IDEA.app/Contents/MacOS/idea': '/IntelliJ IDEA.app/Contents/MacOS/idea',
|
|
1902
|
-
'/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea': '/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea',
|
|
1903
|
-
'/IntelliJ IDEA Community Edition.app/Contents/MacOS/idea': '/IntelliJ IDEA Community Edition.app/Contents/MacOS/idea',
|
|
1904
|
-
'/Zed.app/Contents/MacOS/zed': 'zed',
|
|
1905
|
-
'/GoLand.app/Contents/MacOS/goland': '/GoLand.app/Contents/MacOS/goland',
|
|
1906
|
-
'/AppCode.app/Contents/MacOS/appcode': '/AppCode.app/Contents/MacOS/appcode',
|
|
1907
|
-
'/CLion.app/Contents/MacOS/clion': '/CLion.app/Contents/MacOS/clion',
|
|
1908
|
-
'/RubyMine.app/Contents/MacOS/rubymine': '/RubyMine.app/Contents/MacOS/rubymine',
|
|
1909
|
-
'/MacVim.app/Contents/MacOS/MacVim': 'mvim',
|
|
1910
|
-
'/Rider.app/Contents/MacOS/rider': '/Rider.app/Contents/MacOS/rider'
|
|
1911
|
-
},
|
|
1912
|
-
linux: {
|
|
1913
|
-
cursor: 'cursor',
|
|
1914
|
-
windsurf: 'windsurf',
|
|
1915
|
-
code: 'code',
|
|
1916
|
-
vscodium: 'vscodium',
|
|
1917
|
-
codium: 'codium',
|
|
1918
|
-
webstorm: 'webstorm',
|
|
1919
|
-
'webstorm.sh': 'webstorm',
|
|
1920
|
-
hbuilderx: 'hbuilderx',
|
|
1921
|
-
'hbuilderx.sh': 'hbuilderx',
|
|
1922
|
-
atom: 'atom',
|
|
1923
|
-
Brackets: 'brackets',
|
|
1924
|
-
'code-insiders': 'code-insiders',
|
|
1925
|
-
emacs: 'emacs',
|
|
1926
|
-
gvim: 'gvim',
|
|
1927
|
-
idea: 'idea',
|
|
1928
|
-
'idea.sh': 'idea',
|
|
1929
|
-
phpstorm: 'phpstorm',
|
|
1930
|
-
'phpstorm.sh': 'phpstorm',
|
|
1931
|
-
pycharm: 'pycharm',
|
|
1932
|
-
'pycharm.sh': 'pycharm',
|
|
1933
|
-
rubymine: 'rubymine',
|
|
1934
|
-
'rubymine.sh': 'rubymine',
|
|
1935
|
-
sublime_text: 'subl',
|
|
1936
|
-
vim: 'vim',
|
|
1937
|
-
goland: 'goland',
|
|
1938
|
-
'goland.sh': 'goland',
|
|
1939
|
-
rider: 'rider',
|
|
1940
|
-
'rider.sh': 'rider'
|
|
1941
|
-
},
|
|
1942
|
-
win32: {
|
|
1943
|
-
'Cursor.exe': '',
|
|
1944
|
-
'Windsurf.exe': '',
|
|
1945
|
-
'Trae.exe': '',
|
|
1946
|
-
'Trae CN.exe': '',
|
|
1947
|
-
'comate.exe': '',
|
|
1948
|
-
'Code.exe': '',
|
|
1949
|
-
'Code - Insiders.exe': '',
|
|
1950
|
-
'VSCodium.exe': '',
|
|
1951
|
-
'webstorm.exe': '',
|
|
1952
|
-
'webstorm64.exe': '',
|
|
1953
|
-
'HBuilderX.exe': '',
|
|
1954
|
-
'HBuilderX64.exe': '',
|
|
1955
|
-
'HBuilder.exe': '',
|
|
1956
|
-
'HBuilder64.exe': '',
|
|
1957
|
-
'Brackets.exe': '',
|
|
1958
|
-
'atom.exe': '',
|
|
1959
|
-
'sublime_text.exe': '',
|
|
1960
|
-
'notepad++.exe': '',
|
|
1961
|
-
'clion.exe': '',
|
|
1962
|
-
'clion64.exe': '',
|
|
1963
|
-
'idea.exe': '',
|
|
1964
|
-
'idea64.exe': '',
|
|
1965
|
-
'phpstorm.exe': '',
|
|
1966
|
-
'phpstorm64.exe': '',
|
|
1967
|
-
'pycharm.exe': '',
|
|
1968
|
-
'pycharm64.exe': '',
|
|
1969
|
-
'rubymine.exe': '',
|
|
1970
|
-
'rubymine64.exe': '',
|
|
1971
|
-
'goland.exe': '',
|
|
1972
|
-
'goland64.exe': '',
|
|
1973
|
-
'rider.exe': '',
|
|
1974
|
-
'rider64.exe': ''
|
|
1975
|
-
}
|
|
1976
|
-
}, COMMON_EDITOR_PROCESS_MAP = {
|
|
1977
|
-
darwin: {
|
|
1978
|
-
cursor: [
|
|
1979
|
-
'/Cursor.app/Contents/MacOS/Cursor'
|
|
1980
|
-
],
|
|
1981
|
-
comate: [
|
|
1982
|
-
'/Comate.app/Contents/MacOS/Electron'
|
|
1983
|
-
],
|
|
1984
|
-
windsurf: [
|
|
1985
|
-
'/Windsurf.app/Contents/MacOS/Electron'
|
|
1986
|
-
],
|
|
1987
|
-
trae: [
|
|
1988
|
-
'/Trae.app/Contents/MacOS/Electron',
|
|
1989
|
-
'/Trae CN.app/Contents/MacOS/Electron'
|
|
1990
|
-
],
|
|
1991
|
-
code: [
|
|
1992
|
-
'/Visual Studio Code.app/Contents/MacOS/Electron'
|
|
1993
|
-
],
|
|
1994
|
-
'code-insiders': [
|
|
1995
|
-
'/Visual Studio Code - Insiders.app/Contents/MacOS/Electron'
|
|
1996
|
-
],
|
|
1997
|
-
webstorm: [
|
|
1998
|
-
'/WebStorm.app/Contents/MacOS/webstorm'
|
|
1999
|
-
],
|
|
2000
|
-
atom: [
|
|
2001
|
-
'/Atom.app/Contents/MacOS/Atom'
|
|
2002
|
-
],
|
|
2003
|
-
hbuilder: [
|
|
2004
|
-
'/HBuilderX.app/Contents/MacOS/HBuilderX'
|
|
2005
|
-
],
|
|
2006
|
-
phpstorm: [
|
|
2007
|
-
'/PhpStorm.app/Contents/MacOS/phpstorm'
|
|
2008
|
-
],
|
|
2009
|
-
pycharm: [
|
|
2010
|
-
'/PyCharm.app/Contents/MacOS/pycharm'
|
|
2011
|
-
],
|
|
2012
|
-
idea: [
|
|
2013
|
-
'/IntelliJ IDEA.app/Contents/MacOS/idea'
|
|
2014
|
-
],
|
|
2015
|
-
codium: [
|
|
2016
|
-
'/VSCodium.app/Contents/MacOS/Electron'
|
|
2017
|
-
],
|
|
2018
|
-
goland: [
|
|
2019
|
-
'/GoLand.app/Contents/MacOS/goland'
|
|
2020
|
-
],
|
|
2021
|
-
colin: [
|
|
2022
|
-
'/CLion.app/Contents/MacOS/clion'
|
|
2023
|
-
],
|
|
2024
|
-
appcode: [
|
|
2025
|
-
'/AppCode.app/Contents/MacOS/appcode'
|
|
2026
|
-
],
|
|
2027
|
-
'atom-beta': [
|
|
2028
|
-
'/Atom Beta.app/Contents/MacOS/Atom Beta'
|
|
2029
|
-
],
|
|
2030
|
-
brackets: [
|
|
2031
|
-
'/Brackets.app/Contents/MacOS/Brackets'
|
|
2032
|
-
],
|
|
2033
|
-
rider: [
|
|
2034
|
-
'/Rider.app/Contents/MacOS/rider'
|
|
2035
|
-
],
|
|
2036
|
-
rubymine: [
|
|
2037
|
-
'/RubyMine.app/Contents/MacOS/rubymine'
|
|
2038
|
-
],
|
|
2039
|
-
sublime: [
|
|
2040
|
-
'/Sublime Text.app/Contents/MacOS/sublime_text'
|
|
2041
|
-
],
|
|
2042
|
-
zed: [
|
|
2043
|
-
'/Zed.app/Contents/MacOS/zed'
|
|
2044
|
-
]
|
|
2045
|
-
},
|
|
2046
|
-
linux: {
|
|
2047
|
-
code: [
|
|
2048
|
-
'code'
|
|
2049
|
-
],
|
|
2050
|
-
'code-insiders': [
|
|
2051
|
-
'code-insiders'
|
|
2052
|
-
],
|
|
2053
|
-
webstorm: [
|
|
2054
|
-
'webstorm',
|
|
2055
|
-
'webstorm.sh'
|
|
2056
|
-
],
|
|
2057
|
-
cursor: [
|
|
2058
|
-
'cursor'
|
|
2059
|
-
],
|
|
2060
|
-
windsurf: [
|
|
2061
|
-
'windsurf'
|
|
2062
|
-
],
|
|
2063
|
-
atom: [
|
|
2064
|
-
'atom'
|
|
2065
|
-
],
|
|
2066
|
-
hbuilder: [
|
|
2067
|
-
'hbuilderx',
|
|
2068
|
-
'hbuilderx.sh'
|
|
2069
|
-
],
|
|
2070
|
-
phpstorm: [
|
|
2071
|
-
'phpstorm',
|
|
2072
|
-
'phpstorm.sh'
|
|
2073
|
-
],
|
|
2074
|
-
pycharm: [
|
|
2075
|
-
'pycharm',
|
|
2076
|
-
'pycharm.sh'
|
|
2077
|
-
],
|
|
2078
|
-
idea: [
|
|
2079
|
-
'idea',
|
|
2080
|
-
'idea.sh'
|
|
2081
|
-
],
|
|
2082
|
-
codium: [
|
|
2083
|
-
'vscodium'
|
|
2084
|
-
],
|
|
2085
|
-
goland: [
|
|
2086
|
-
'goland'
|
|
2087
|
-
],
|
|
2088
|
-
brackets: [
|
|
2089
|
-
'Brackets'
|
|
2090
|
-
],
|
|
2091
|
-
rider: [
|
|
2092
|
-
'rider'
|
|
2093
|
-
],
|
|
2094
|
-
rubymine: [
|
|
2095
|
-
'rubymine',
|
|
2096
|
-
'rubymine.sh'
|
|
2097
|
-
],
|
|
2098
|
-
sublime: [
|
|
2099
|
-
'sublime_text'
|
|
2100
|
-
],
|
|
2101
|
-
vim: [
|
|
2102
|
-
'vim'
|
|
2103
|
-
],
|
|
2104
|
-
emacs: [
|
|
2105
|
-
'emacs'
|
|
2106
|
-
]
|
|
2107
|
-
},
|
|
2108
|
-
win32: {
|
|
2109
|
-
code: [
|
|
2110
|
-
'Code.exe'
|
|
2111
|
-
],
|
|
2112
|
-
'code-insiders': [
|
|
2113
|
-
'Code - Insiders.exe'
|
|
2114
|
-
],
|
|
2115
|
-
webstorm: [
|
|
2116
|
-
'webstorm.exe',
|
|
2117
|
-
'webstorm64.exe'
|
|
2118
|
-
],
|
|
2119
|
-
cursor: [
|
|
2120
|
-
'Cursor.exe'
|
|
2121
|
-
],
|
|
2122
|
-
windsurf: [
|
|
2123
|
-
'Windsurf.exe'
|
|
2124
|
-
],
|
|
2125
|
-
trae: [
|
|
2126
|
-
'Trae.exe',
|
|
2127
|
-
'Trae CN.exe'
|
|
2128
|
-
],
|
|
2129
|
-
comate: [
|
|
2130
|
-
'comate.exe'
|
|
2131
|
-
],
|
|
2132
|
-
atom: [
|
|
2133
|
-
'atom.exe'
|
|
2134
|
-
],
|
|
2135
|
-
hbuilder: [
|
|
2136
|
-
'HBuilderX.exe',
|
|
2137
|
-
'HBuilder.exe',
|
|
2138
|
-
'HBuilderX64.exe',
|
|
2139
|
-
'HBuilder64.exe'
|
|
2140
|
-
],
|
|
2141
|
-
phpstorm: [
|
|
2142
|
-
'phpstorm.exe',
|
|
2143
|
-
'phpstorm64.exe'
|
|
2144
|
-
],
|
|
2145
|
-
pycharm: [
|
|
2146
|
-
'pycharm.exe',
|
|
2147
|
-
'pycharm64.exe'
|
|
2148
|
-
],
|
|
2149
|
-
idea: [
|
|
2150
|
-
'idea.exe',
|
|
2151
|
-
'idea64.exe'
|
|
2152
|
-
],
|
|
2153
|
-
codium: [
|
|
2154
|
-
'VSCodium.exe'
|
|
2155
|
-
],
|
|
2156
|
-
goland: [
|
|
2157
|
-
'goland.exe',
|
|
2158
|
-
'goland64.exe'
|
|
2159
|
-
],
|
|
2160
|
-
colin: [
|
|
2161
|
-
'clion.exe',
|
|
2162
|
-
'clion64.exe'
|
|
2163
|
-
],
|
|
2164
|
-
brackets: [
|
|
2165
|
-
'Brackets.exe'
|
|
2166
|
-
],
|
|
2167
|
-
rider: [
|
|
2168
|
-
'rider.exe',
|
|
2169
|
-
'rider64.exe'
|
|
2170
|
-
],
|
|
2171
|
-
rubymine: [
|
|
2172
|
-
'rubymine.exe',
|
|
2173
|
-
'rubymine64.exe'
|
|
2174
|
-
],
|
|
2175
|
-
sublime: [
|
|
2176
|
-
'sublime_text.exe'
|
|
2177
|
-
],
|
|
2178
|
-
notepad: [
|
|
2179
|
-
'notepad++.exe'
|
|
2180
|
-
]
|
|
2181
|
-
}
|
|
2182
|
-
}, FormatFile = '{file}', FormatLine = '{line}', FormatColumn = '{column}', processExecutionMap = {
|
|
2183
|
-
darwin: 'ps ax -o comm=',
|
|
2184
|
-
linux: 'ps -eo comm --sort=comm',
|
|
2185
|
-
win32: 'wmic process where "executablepath is not null" get executablepath'
|
|
2186
|
-
}, compatibleWithChineseCharacter = (isWin32)=>{
|
|
2187
|
-
if (isWin32) try {
|
|
2188
|
-
node_child_process.execSync('chcp 65001');
|
|
2189
|
-
} catch {}
|
|
2190
|
-
}, _childProcess = null, positionRE = /:(\d+)(:(\d+))?$/;
|
|
2191
|
-
function launchEditor(file, options) {
|
|
2192
|
-
let { editor: specifiedEditor, method, onError } = options || {}, parsed = function(file) {
|
|
2193
|
-
let _file = file;
|
|
2194
|
-
_file.startsWith('file://') && (_file = __webpack_require__("node:url").fileURLToPath(_file));
|
|
2195
|
-
let fileName = _file.replace(positionRE, ''), match = _file.match(positionRE);
|
|
2196
|
-
return {
|
|
2197
|
-
fileName,
|
|
2198
|
-
lineNumber: (null == match ? void 0 : match[1]) || 1,
|
|
2199
|
-
columnNumber: (null == match ? void 0 : match[3]) || 1
|
|
2200
|
-
};
|
|
2201
|
-
}(file), { fileName } = parsed, { lineNumber, columnNumber } = parsed;
|
|
2202
|
-
if (!node_fs.existsSync(fileName)) return;
|
|
2203
|
-
let onErrorCallback = (fileName, errorMessage)=>{
|
|
2204
|
-
if (console.log(), console.log(colors.red('Could not open ' + node_path.basename(fileName) + ' in the editor.')), errorMessage) {
|
|
2205
|
-
let displayErrorMessage = errorMessage;
|
|
2206
|
-
'.' !== displayErrorMessage[displayErrorMessage.length - 1] && (displayErrorMessage += '.'), console.log(colors.red('The editor process exited with an error: ' + displayErrorMessage));
|
|
2207
|
-
}
|
|
2208
|
-
console.log(), onError && onError(fileName, errorMessage);
|
|
2209
|
-
}, [editor, ...args] = function(specifiedEditor) {
|
|
2210
|
-
let platform = process.platform;
|
|
2211
|
-
if (specifiedEditor) {
|
|
2212
|
-
var _COMMON_EDITOR_PROCESS_MAP_platform;
|
|
2213
|
-
let editor = null == (_COMMON_EDITOR_PROCESS_MAP_platform = COMMON_EDITOR_PROCESS_MAP[platform]) ? void 0 : _COMMON_EDITOR_PROCESS_MAP_platform[specifiedEditor];
|
|
2214
|
-
if (editor) return editor;
|
|
2215
|
-
}
|
|
2216
|
-
let editorFromPid = function() {
|
|
2217
|
-
let platform = process.platform, editorNames = Object.keys(COMMON_EDITORS_MAP[platform]);
|
|
2218
|
-
try {
|
|
2219
|
-
return function(pid, platform, editorNames) {
|
|
2220
|
-
let depth = 0, currentPid = pid;
|
|
2221
|
-
for(; currentPid && 0 !== currentPid && depth < 50;){
|
|
2222
|
-
let processInfo = function(pid, platform) {
|
|
2223
|
-
switch(platform){
|
|
2224
|
-
case 'darwin':
|
|
2225
|
-
case 'linux':
|
|
2226
|
-
var pid1, pid2 = pid;
|
|
2227
|
-
try {
|
|
2228
|
-
let lines = node_child_process.execSync(`ps -p ${pid2} -o ppid=,comm=`, {
|
|
2229
|
-
encoding: 'utf8'
|
|
2230
|
-
}).trim().split('\n');
|
|
2231
|
-
if (!lines.length) return null;
|
|
2232
|
-
var processLine = lines[0].trim();
|
|
2233
|
-
let match = processLine.match(/^(\d+)\s+(.+)$/);
|
|
2234
|
-
return match ? {
|
|
2235
|
-
command: match[2],
|
|
2236
|
-
parentPid: Number.parseInt(match[1])
|
|
2237
|
-
} : null;
|
|
2238
|
-
} catch {
|
|
2239
|
-
return null;
|
|
2240
|
-
}
|
|
2241
|
-
case 'win32':
|
|
2242
|
-
return pid1 = pid, function(pid) {
|
|
2243
|
-
try {
|
|
2244
|
-
compatibleWithChineseCharacter(!0);
|
|
2245
|
-
let lines = node_child_process.execSync(`wmic process where "ProcessId=${pid}" get ParentProcessId,ExecutablePath /format:csv`, {
|
|
2246
|
-
encoding: 'utf8'
|
|
2247
|
-
}).trim().split('\r\n').filter((line)=>line.trim()).slice(1);
|
|
2248
|
-
if (0 === lines.length) return null;
|
|
2249
|
-
let parts = lines[0].split(',');
|
|
2250
|
-
if (parts.length < 3) return null;
|
|
2251
|
-
return {
|
|
2252
|
-
command: parts[1].trim(),
|
|
2253
|
-
parentPid: Number.parseInt(parts[2].trim())
|
|
2254
|
-
};
|
|
2255
|
-
} catch {
|
|
2256
|
-
return null;
|
|
2257
|
-
}
|
|
2258
|
-
}(pid1) || function(pid) {
|
|
2259
|
-
try {
|
|
2260
|
-
compatibleWithChineseCharacter(!0);
|
|
2261
|
-
let line = node_child_process.execSync(`powershell -NoProfile -Command "Get-CimInstance -Query \"select ParentProcessId,ExecutablePath from win32_process where ProcessId=${pid}\" | ForEach-Object { $_.ExecutablePath + ',' + $_.ParentProcessId }"`, {
|
|
2262
|
-
encoding: 'utf8'
|
|
2263
|
-
}).trim();
|
|
2264
|
-
if (!line) return null;
|
|
2265
|
-
let parts = line.split(',');
|
|
2266
|
-
if (parts.length < 2) return null;
|
|
2267
|
-
return {
|
|
2268
|
-
command: parts[0].trim(),
|
|
2269
|
-
parentPid: Number.parseInt(parts[1].trim())
|
|
2270
|
-
};
|
|
2271
|
-
} catch {
|
|
2272
|
-
return null;
|
|
2273
|
-
}
|
|
2274
|
-
}(pid1);
|
|
2275
|
-
default:
|
|
2276
|
-
return null;
|
|
2277
|
-
}
|
|
2278
|
-
}(currentPid, platform);
|
|
2279
|
-
if (!processInfo) break;
|
|
2280
|
-
let { command, parentPid } = processInfo;
|
|
2281
|
-
if (function(command, editorNames) {
|
|
2282
|
-
return editorNames.some((editorName)=>command.toLowerCase().endsWith(editorName.toLowerCase()));
|
|
2283
|
-
}(command, editorNames)) return command;
|
|
2284
|
-
currentPid = parentPid, depth++;
|
|
2285
|
-
}
|
|
2286
|
-
return null;
|
|
2287
|
-
}(process.pid, platform, editorNames);
|
|
2288
|
-
} catch (error) {
|
|
2289
|
-
return console.error('Error while getting editor by PID:', error), null;
|
|
2290
|
-
}
|
|
2291
|
-
}();
|
|
2292
|
-
if (editorFromPid) return [
|
|
2293
|
-
editorFromPid
|
|
2294
|
-
];
|
|
2295
|
-
try {
|
|
2296
|
-
let first, isWin32 = 'win32' === process.platform, execution = processExecutionMap[platform], commonEditors = COMMON_EDITORS_MAP[platform];
|
|
2297
|
-
compatibleWithChineseCharacter(isWin32);
|
|
2298
|
-
let output = '';
|
|
2299
|
-
try {
|
|
2300
|
-
output = node_child_process.execSync(execution, {
|
|
2301
|
-
encoding: 'utf-8'
|
|
2302
|
-
});
|
|
2303
|
-
} catch {
|
|
2304
|
-
isWin32 && (output = node_child_process.execSync('powershell -NoProfile -Command "Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }"', {
|
|
2305
|
-
encoding: 'utf-8'
|
|
2306
|
-
}));
|
|
2307
|
-
}
|
|
2308
|
-
let editorNames = Object.keys(commonEditors), runningProcesses = output.split(isWin32 ? '\r\n' : '\n').map((item)=>item.trim());
|
|
2309
|
-
for(let i = 0; i < editorNames.length; i++){
|
|
2310
|
-
let editorName = editorNames[i], editor = '', runningEditor = '';
|
|
2311
|
-
if (isWin32) {
|
|
2312
|
-
let processPath = runningProcesses.find((_process)=>node_path.basename(_process).toLowerCase() === editorName.toLowerCase());
|
|
2313
|
-
processPath && (runningEditor = node_path.basename(processPath), editor = processPath);
|
|
2314
|
-
} else if ('darwin' === platform) {
|
|
2315
|
-
let runningProcess = runningProcesses.find((_process)=>_process.toLowerCase().endsWith(editorName.toLowerCase()));
|
|
2316
|
-
if (runningProcess) {
|
|
2317
|
-
let prefixPath = runningProcess.replace(editorName, ''), processName = commonEditors[editorName];
|
|
2318
|
-
runningEditor = editorName, editor = processName.includes('/') ? `${prefixPath}${processName}` : processName;
|
|
2319
|
-
}
|
|
2320
|
-
} else -1 !== output.indexOf(editorName) && (runningEditor = editorName, editor = commonEditors[editorName]);
|
|
2321
|
-
if (runningEditor && editor && !first) {
|
|
2322
|
-
first = [
|
|
2323
|
-
editor
|
|
2324
|
-
];
|
|
2325
|
-
break;
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
|
-
if (first) return first;
|
|
2329
|
-
} catch {}
|
|
2330
|
-
return process.env.VISUAL ? [
|
|
2331
|
-
process.env.VISUAL
|
|
2332
|
-
] : process.env.EDITOR ? [
|
|
2333
|
-
process.env.EDITOR
|
|
2334
|
-
] : [];
|
|
2335
|
-
}(specifiedEditor);
|
|
2336
|
-
if (!editor) return void onErrorCallback(fileName);
|
|
2337
|
-
if ('linux' === process.platform && fileName.startsWith('/mnt/') && /Microsoft/i.test(node_os.release()) && (fileName = node_path.relative('', fileName)), args = args.concat(function({ processName, fileName, lineNumber, columnNumber, workspace, openMethodArgs }) {
|
|
2338
|
-
let format = function({ editorBasename, openMethodArgs, workspace }) {
|
|
2339
|
-
switch(editorBasename){
|
|
2340
|
-
case 'atom':
|
|
2341
|
-
case 'atom beta':
|
|
2342
|
-
case 'subl':
|
|
2343
|
-
case 'sublime':
|
|
2344
|
-
case 'sublime_text':
|
|
2345
|
-
case 'wstorm':
|
|
2346
|
-
case 'charm':
|
|
2347
|
-
case 'zed':
|
|
2348
|
-
return `${FormatFile}:${FormatLine}:${FormatColumn}`;
|
|
2349
|
-
case 'notepad++':
|
|
2350
|
-
return [
|
|
2351
|
-
'-n' + FormatLine,
|
|
2352
|
-
'-c' + FormatColumn,
|
|
2353
|
-
FormatFile
|
|
2354
|
-
];
|
|
2355
|
-
case 'vim':
|
|
2356
|
-
case 'mvim':
|
|
2357
|
-
return [
|
|
2358
|
-
`+call cursor(${FormatLine}, ${FormatColumn})`,
|
|
2359
|
-
FormatFile
|
|
2360
|
-
];
|
|
2361
|
-
case 'joe':
|
|
2362
|
-
case 'gvim':
|
|
2363
|
-
return [
|
|
2364
|
-
'+' + FormatLine,
|
|
2365
|
-
FormatFile
|
|
2366
|
-
];
|
|
2367
|
-
case 'emacs':
|
|
2368
|
-
case 'emacsclient':
|
|
2369
|
-
return [
|
|
2370
|
-
'+' + FormatLine + ':' + FormatColumn,
|
|
2371
|
-
FormatFile
|
|
2372
|
-
];
|
|
2373
|
-
case 'rmate':
|
|
2374
|
-
case 'mate':
|
|
2375
|
-
case 'mine':
|
|
2376
|
-
return [
|
|
2377
|
-
'--line',
|
|
2378
|
-
FormatLine,
|
|
2379
|
-
FormatFile
|
|
2380
|
-
];
|
|
2381
|
-
case 'code':
|
|
2382
|
-
case 'code-insiders':
|
|
2383
|
-
case 'code - insiders':
|
|
2384
|
-
case 'codium':
|
|
2385
|
-
case 'cursor':
|
|
2386
|
-
case 'windsurf':
|
|
2387
|
-
case 'trae':
|
|
2388
|
-
case 'comate':
|
|
2389
|
-
case 'vscodium':
|
|
2390
|
-
case 'hbuilderx':
|
|
2391
|
-
case 'hbuilder':
|
|
2392
|
-
return [
|
|
2393
|
-
...workspace ? [
|
|
2394
|
-
workspace
|
|
2395
|
-
] : [],
|
|
2396
|
-
'-g',
|
|
2397
|
-
...openMethodArgs ? [
|
|
2398
|
-
openMethodArgs
|
|
2399
|
-
] : [],
|
|
2400
|
-
`${FormatFile}:${FormatLine}:${FormatColumn}`
|
|
2401
|
-
];
|
|
2402
|
-
case 'appcode':
|
|
2403
|
-
case 'clion':
|
|
2404
|
-
case 'clion64':
|
|
2405
|
-
case 'idea':
|
|
2406
|
-
case 'idea64':
|
|
2407
|
-
case 'phpstorm':
|
|
2408
|
-
case 'phpstorm64':
|
|
2409
|
-
case 'pycharm':
|
|
2410
|
-
case 'pycharm64':
|
|
2411
|
-
case 'rubymine':
|
|
2412
|
-
case 'rubymine64':
|
|
2413
|
-
case 'webstorm':
|
|
2414
|
-
case 'webstorm64':
|
|
2415
|
-
case 'goland':
|
|
2416
|
-
case 'goland64':
|
|
2417
|
-
case 'rider':
|
|
2418
|
-
case 'rider64':
|
|
2419
|
-
return [
|
|
2420
|
-
...workspace ? [
|
|
2421
|
-
workspace
|
|
2422
|
-
] : [],
|
|
2423
|
-
'--line',
|
|
2424
|
-
FormatLine,
|
|
2425
|
-
FormatFile
|
|
2426
|
-
];
|
|
2427
|
-
}
|
|
2428
|
-
return '';
|
|
2429
|
-
}({
|
|
2430
|
-
editorBasename: function(processName) {
|
|
2431
|
-
let editorBasename = node_path.basename(processName).replace(/\.(exe|cmd|bat|sh)$/i, ''), platform = process.platform, editorBasenameList = Object.keys(COMMON_EDITOR_PROCESS_MAP[platform]);
|
|
2432
|
-
for(let i = 0; i < editorBasenameList.length; i++)if ((COMMON_EDITOR_PROCESS_MAP[platform][editorBasenameList[i]] || []).some((editorPath)=>processName.endsWith(editorPath))) {
|
|
2433
|
-
editorBasename = editorBasenameList[i];
|
|
2434
|
-
break;
|
|
2435
|
-
}
|
|
2436
|
-
return editorBasename.toLowerCase();
|
|
2437
|
-
}(processName),
|
|
2438
|
-
openMethodArgs,
|
|
2439
|
-
workspace
|
|
2440
|
-
}) || '{file}', formattedPath = `${fileName}:${lineNumber}:${columnNumber}`;
|
|
2441
|
-
if ('string' == typeof format) formattedPath = format.replace(FormatFile, fileName).replace(FormatLine, lineNumber.toString()).replace(FormatColumn, columnNumber.toString());
|
|
2442
|
-
else if (Array.isArray(format)) return format.map((item)=>item.replace(FormatFile, fileName).replace(FormatLine, lineNumber.toString()).replace(FormatColumn, columnNumber.toString()));
|
|
2443
|
-
return [
|
|
2444
|
-
formattedPath
|
|
2445
|
-
];
|
|
2446
|
-
}({
|
|
2447
|
-
processName: editor,
|
|
2448
|
-
fileName,
|
|
2449
|
-
lineNumber,
|
|
2450
|
-
columnNumber,
|
|
2451
|
-
workspace: null,
|
|
2452
|
-
openMethodArgs: 'reuse' === method ? '-r' : 'new' === method ? '-n' : ''
|
|
2453
|
-
})), _childProcess && function(editor) {
|
|
2454
|
-
switch(editor){
|
|
2455
|
-
case 'vim':
|
|
2456
|
-
case 'emacs':
|
|
2457
|
-
case 'nano':
|
|
2458
|
-
return !0;
|
|
2459
|
-
}
|
|
2460
|
-
return !1;
|
|
2461
|
-
}(editor) && _childProcess.kill('SIGKILL'), 'win32' === process.platform) {
|
|
2462
|
-
let launchCommand = [
|
|
2463
|
-
editor,
|
|
2464
|
-
...args.map((cmdArgs)=>cmdArgs.replace(/([&|<>,;=^])/g, '^$1'))
|
|
2465
|
-
].map((str)=>str.includes('^') ? `^"${str}^"` : str.includes(' ') ? `"${str}"` : str).join(' ');
|
|
2466
|
-
_childProcess = node_child_process.exec(launchCommand, {
|
|
2467
|
-
shell: !0
|
|
2468
|
-
});
|
|
2469
|
-
} else _childProcess = node_child_process.spawn(editor, args);
|
|
2470
|
-
_childProcess.on('exit', (errorCode)=>{
|
|
2471
|
-
_childProcess = null, errorCode && onErrorCallback(fileName, '(code ' + errorCode + ')');
|
|
2472
|
-
}), _childProcess.on('error', (error)=>{
|
|
2473
|
-
let { message } = error;
|
|
2474
|
-
onErrorCallback(fileName, message);
|
|
2475
|
-
});
|
|
2476
|
-
}
|
|
2477
1894
|
let GLOB_REGEX = /[*?{}[\]()!@+|]/;
|
|
2478
1895
|
async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
|
|
2479
1896
|
let watchFiles = new Set(), globPatterns = pathOrGlobs.filter((pathOrGlob)=>!!GLOB_REGEX.test(pathOrGlob) || (watchFiles.add(pathOrGlob), !1));
|
|
@@ -2487,4 +1904,4 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
|
|
|
2487
1904
|
...options
|
|
2488
1905
|
});
|
|
2489
1906
|
}
|
|
2490
|
-
export { CSS_MODULES_LOCAL_IDENT_NAME, CSS_MODULES_REGEX, CSS_NAMED_EXPORT, DEFAULT_DEV_HOST, DEV_DEFAULT_FILENAME, EXPORT_LOCALS_CONVENTION, logger_LogColor as LogColor, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, TEMPLATE_CONTENT, TEMP_DIR, THREAD_OPTIONS, clearLine, colors, createChokidar, createUnpack, debounce, defineConfig, esVersionToBrowserslist, findExists, getAddressUrls, getCompiledPkgPath, getIpv4Interfaces, getNodeEnv, getPathInJs, getPort, getTime, getUserDepPath, getUserDepVersion, getValueByPath, isBoolean, isCI, isCSSModules, isDebug, isDev, utils_isDevServer as isDevServer, isEmptyDir, isFileExists, isFileSync, isFunction, isNodeVersionAtLeast, isObject, isPlainObject, isProd, isRegExp, isString, isUndefined, isWatch, isWin,
|
|
1907
|
+
export { CSS_MODULES_LOCAL_IDENT_NAME, CSS_MODULES_REGEX, CSS_NAMED_EXPORT, DEFAULT_DEV_HOST, DEV_DEFAULT_FILENAME, EXPORT_LOCALS_CONVENTION, logger_LogColor as LogColor, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, TEMPLATE_CONTENT, TEMP_DIR, THREAD_OPTIONS, clearLine, colors, createChokidar, createUnpack, debounce, defineConfig, esVersionToBrowserslist, findExists, getAddressUrls, getCompiledPkgPath, getIpv4Interfaces, getNodeEnv, getPathInJs, getPort, getTime, getUserDepPath, getUserDepVersion, getValueByPath, isBoolean, isCI, isCSSModules, isDebug, isDev, utils_isDevServer as isDevServer, isEmptyDir, isFileExists, isFileSync, isFunction, isNodeVersionAtLeast, isObject, isPlainObject, isProd, isRegExp, isString, isUndefined, isWatch, isWin, loadConfig, logUpdate, logger_logger as logger, mergeConfig, pathExists, prettyTime, removeDir, resolveConfigPath, restartCleaners, rspack, setDevServer, setNodeEnv, setValueByPath, trackPerformance };
|