@unpackjs/core 3.2.4 → 3.2.5

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/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 as external_node_os_platform } from "node:os";
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 node_child_process, { exec, spawn } from "node:child_process";
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 external_node_url_ = __webpack_require__("node:url"), logger_LogColor = ((LogColor = {}).error = "red", LogColor.warn = "yellow", LogColor.info = "cyan", LogColor.ready = "green", LogColor.event = "magenta", LogColor.wait = "blue", LogColor.debug = "dim", LogColor);
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',
@@ -279,7 +276,7 @@ async function loadConfig({ cliOptions, command }) {
279
276
  if (isNodeVersionAtLeast(23, 6) || /\.(?: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 = (0, external_node_url_.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
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;
@@ -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.4",
592
+ version: "3.2.5",
596
593
  options: this.minifyOptions
597
594
  });
598
595
  compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
@@ -1518,7 +1515,7 @@ async function openBrowser(url) {
1518
1515
  try {
1519
1516
  return new Promise((resolve, reject)=>{
1520
1517
  let command, args = [];
1521
- switch(external_node_os_platform()){
1518
+ switch(platform()){
1522
1519
  case 'darwin':
1523
1520
  command = 'open', args = [
1524
1521
  url
@@ -1801,7 +1798,7 @@ async function unpackDev(originalUnpackConfig) {
1801
1798
  (null == (_req_headers_accept = req.headers.accept) ? void 0 : _req_headers_accept.includes('html')) && (req.url = '/index.html'), next();
1802
1799
  }), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
1803
1800
  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.4`)} ${colors.dim(`ready in ${colors.reset(Math.ceil(performance.now() - global.__unpack_start_time))}ms`)}\n`), getAddressUrls({
1801
+ await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.2.5`)} ${colors.dim(`ready in ${colors.reset(Math.ceil(performance.now() - global.__unpack_start_time))}ms`)}\n`), getAddressUrls({
1805
1802
  port: port
1806
1803
  }).forEach((addr)=>{
1807
1804
  let url;
@@ -1852,7 +1849,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
1852
1849
  ]
1853
1850
  }, _context = {
1854
1851
  callerName,
1855
- version: "3.2.4"
1852
+ version: "3.2.5"
1856
1853
  }, { plugins, bundlerConfig, ...rest } = mergeConfig(defaultConfig, config);
1857
1854
  for (let plugin of getNormalizedPluginsByHook('config', plugins))rest = await plugin.config(rest, {
1858
1855
  ..._context,
@@ -1869,611 +1866,13 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
1869
1866
  build: async ({ watch } = {})=>{
1870
1867
  setNodeEnv(watch ? 'development' : 'production');
1871
1868
  let config = await resolveConfig();
1872
- console.log(colors.rainbow(`${callerName} v3.2.4`), colors.green(`building for ${getNodeEnv()}...`)), unpackBuild(config);
1869
+ console.log(colors.rainbow(`${callerName} v3.2.5`), colors.green(`building for ${getNodeEnv()}...`)), unpackBuild(config);
1873
1870
  },
1874
1871
  dev: async ()=>{
1875
1872
  global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0), unpackDev(await resolveConfig());
1876
1873
  }
1877
1874
  };
1878
1875
  }
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
1876
  let GLOB_REGEX = /[*?{}[\]()!@+|]/;
2478
1877
  async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
2479
1878
  let watchFiles = new Set(), globPatterns = pathOrGlobs.filter((pathOrGlob)=>!!GLOB_REGEX.test(pathOrGlob) || (watchFiles.add(pathOrGlob), !1));
@@ -2487,4 +1886,4 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
2487
1886
  ...options
2488
1887
  });
2489
1888
  }
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, launchEditor, loadConfig, logUpdate, logger_logger as logger, mergeConfig, pathExists, prettyTime, removeDir, resolveConfigPath, restartCleaners, rspack, setDevServer, setNodeEnv, setValueByPath, trackPerformance };
1889
+ 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 };