vite 6.4.1 → 6.4.3

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/LICENSE.md CHANGED
@@ -1345,7 +1345,7 @@ Repository: lydell/js-tokens
1345
1345
  ## launch-editor, launch-editor-middleware
1346
1346
  License: MIT
1347
1347
  By: Evan You
1348
- Repositories: git+https://github.com/yyx990803/launch-editor.git, git+https://github.com/yyx990803/launch-editor.git
1348
+ Repositories: git+https://github.com/vitejs/launch-editor.git, git+https://github.com/vitejs/launch-editor.git
1349
1349
 
1350
1350
  > The MIT License (MIT)
1351
1351
  >
@@ -1,4 +1,4 @@
1
- import { P as getDefaultExportFromCjs } from './dep-D4NMHUTW.js';
1
+ import { P as getDefaultExportFromCjs } from './dep-Dm0c1Wj2.js';
2
2
  import require$$0 from 'path';
3
3
  import { l as lib } from './dep-3RmXg9uo.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-D4NMHUTW.js';
1
+ import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-Dm0c1Wj2.js';
2
2
  import require$$0$2 from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -6984,11 +6984,11 @@ function processSrcSetSync(srcs, replacer) {
6984
6984
  }))
6985
6985
  );
6986
6986
  }
6987
- const windowsDriveRE = /^[A-Z]:/;
6987
+ const windowsDriveRE$1 = /^[A-Z]:/;
6988
6988
  const replaceWindowsDriveRE = /^([A-Z]):\//;
6989
6989
  const linuxAbsolutePathRE = /^\/[^/]/;
6990
6990
  function escapeToLinuxLikePath(path2) {
6991
- if (windowsDriveRE.test(path2)) {
6991
+ if (windowsDriveRE$1.test(path2)) {
6992
6992
  return path2.replace(replaceWindowsDriveRE, "/windows/$1/");
6993
6993
  }
6994
6994
  if (linuxAbsolutePathRE.test(path2)) {
@@ -11177,7 +11177,7 @@ var src$1 = {};
11177
11177
  const path$9 = require$$0$2;
11178
11178
  const fs$7 = require$$0$4;
11179
11179
  const os$2 = require$$2;
11180
- const url$4 = require$$0$5;
11180
+ const url$3 = require$$0$5;
11181
11181
 
11182
11182
  const fsReadFileAsync = fs$7.promises.readFile;
11183
11183
 
@@ -11230,7 +11230,7 @@ src$1.defaultLoadersSync = defaultLoadersSync;
11230
11230
  /** @type {import('./index').Loader} */
11231
11231
  const dynamicImport = async id => {
11232
11232
  try {
11233
- const fileUrl = url$4.pathToFileURL(id).href;
11233
+ const fileUrl = url$3.pathToFileURL(id).href;
11234
11234
  const mod = await import(/* webpackIgnore: true */ fileUrl);
11235
11235
 
11236
11236
  return mod.default;
@@ -18175,9 +18175,9 @@ var parseurl$1 = {exports: {}};
18175
18175
  * @private
18176
18176
  */
18177
18177
 
18178
- var url$3 = require$$0$5;
18179
- var parse$a = url$3.parse;
18180
- var Url = url$3.Url;
18178
+ var url$2 = require$$0$5;
18179
+ var parse$a = url$2.parse;
18180
+ var Url = url$2.Url;
18181
18181
 
18182
18182
  /**
18183
18183
  * Module exports.
@@ -24221,18 +24221,62 @@ const watch = (paths, options) => {
24221
24221
 
24222
24222
  chokidar.watch = watch;
24223
24223
 
24224
+ var guess = {exports: {}};
24225
+
24224
24226
  var shellQuote$1 = {};
24225
24227
 
24228
+ var OPS = [
24229
+ '||',
24230
+ '&&',
24231
+ ';;',
24232
+ '|&',
24233
+ '<(',
24234
+ '<<<',
24235
+ '>>',
24236
+ '>&',
24237
+ '<&',
24238
+ '&',
24239
+ ';',
24240
+ '(',
24241
+ ')',
24242
+ '|',
24243
+ '<',
24244
+ '>'
24245
+ ];
24246
+ var LINE_TERMINATORS = /[\n\r\u2028\u2029]/;
24247
+ var GLOB_SHELL_SPECIAL = /[\s#!"$&'():;<=>@\\^`|]/g;
24248
+
24226
24249
  var quote = function quote(xs) {
24227
24250
  return xs.map(function (s) {
24228
24251
  if (s === '') {
24229
24252
  return '\'\'';
24230
24253
  }
24231
24254
  if (s && typeof s === 'object') {
24232
- return s.op.replace(/(.)/g, '\\$1');
24255
+ if (s.op === 'glob') {
24256
+ if (typeof s.pattern !== 'string') {
24257
+ throw new TypeError('glob token requires a string `pattern`');
24258
+ }
24259
+ if (LINE_TERMINATORS.test(s.pattern)) {
24260
+ throw new TypeError('glob `pattern` must not contain line terminators');
24261
+ }
24262
+ return s.pattern.replace(GLOB_SHELL_SPECIAL, '\\$&');
24263
+ }
24264
+ if (typeof s.op === 'string') {
24265
+ if (OPS.indexOf(s.op) < 0) {
24266
+ throw new TypeError('invalid `op` value: ' + JSON.stringify(s.op));
24267
+ }
24268
+ return s.op.replace(/[\s\S]/g, '\\$&');
24269
+ }
24270
+ if (typeof s.comment === 'string') {
24271
+ if (LINE_TERMINATORS.test(s.comment)) {
24272
+ throw new TypeError('`comment` must not contain line terminators');
24273
+ }
24274
+ return '#' + s.comment;
24275
+ }
24276
+ throw new TypeError('unrecognized object token shape');
24233
24277
  }
24234
- if ((/["\s]/).test(s) && !(/'/).test(s)) {
24235
- return "'" + s.replace(/(['\\])/g, '\\$1') + "'";
24278
+ if ((/["\s\\]/).test(s) && !(/'/).test(s)) {
24279
+ return "'" + s.replace(/(['])/g, '\\$1') + "'";
24236
24280
  }
24237
24281
  if ((/["'\s]/).test(s)) {
24238
24282
  return '"' + s.replace(/(["\\$`!])/g, '\\$1') + '"';
@@ -24482,15 +24526,17 @@ var macos = {
24482
24526
  '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl',
24483
24527
  '/Applications/Sublime Text Dev.app/Contents/MacOS/Sublime Text':
24484
24528
  '/Applications/Sublime Text Dev.app/Contents/SharedSupport/bin/subl',
24529
+ '/Applications/Visual Studio Code.app/Contents/MacOS/Code': 'code',
24485
24530
  '/Applications/Visual Studio Code.app/Contents/MacOS/Electron': 'code',
24486
- '/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron':
24487
- 'code-insiders',
24531
+ '/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Code - Insiders': 'code-insiders',
24532
+ '/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron': 'code-insiders',
24488
24533
  '/Applications/VSCodium.app/Contents/MacOS/Electron': 'codium',
24489
24534
  '/Applications/Cursor.app/Contents/MacOS/Cursor': 'cursor',
24535
+ '/Applications/Trae.app/Contents/MacOS/Electron': 'trae',
24536
+ '/Applications/Antigravity.app/Contents/MacOS/Electron': 'antigravity',
24490
24537
  '/Applications/AppCode.app/Contents/MacOS/appcode':
24491
24538
  '/Applications/AppCode.app/Contents/MacOS/appcode',
24492
- '/Applications/CLion.app/Contents/MacOS/clion':
24493
- '/Applications/CLion.app/Contents/MacOS/clion',
24539
+ '/Applications/CLion.app/Contents/MacOS/clion': '/Applications/CLion.app/Contents/MacOS/clion',
24494
24540
  '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea':
24495
24541
  '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea',
24496
24542
  '/Applications/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea':
@@ -24510,9 +24556,8 @@ var macos = {
24510
24556
  '/Applications/MacVim.app/Contents/MacOS/MacVim': 'mvim',
24511
24557
  '/Applications/GoLand.app/Contents/MacOS/goland':
24512
24558
  '/Applications/GoLand.app/Contents/MacOS/goland',
24513
- '/Applications/Rider.app/Contents/MacOS/rider':
24514
- '/Applications/Rider.app/Contents/MacOS/rider',
24515
- '/Applications/Zed.app/Contents/MacOS/zed': 'zed'
24559
+ '/Applications/Rider.app/Contents/MacOS/rider': '/Applications/Rider.app/Contents/MacOS/rider',
24560
+ '/Applications/Zed.app/Contents/MacOS/zed': 'zed',
24516
24561
  };
24517
24562
 
24518
24563
  var linux = {
@@ -24522,6 +24567,9 @@ var linux = {
24522
24567
  code: 'code',
24523
24568
  vscodium: 'vscodium',
24524
24569
  codium: 'codium',
24570
+ cursor: 'cursor',
24571
+ trae: 'trae',
24572
+ antigravity: 'antigravity',
24525
24573
  emacs: 'emacs',
24526
24574
  gvim: 'gvim',
24527
24575
  idea: 'idea',
@@ -24539,7 +24587,8 @@ var linux = {
24539
24587
  goland: 'goland',
24540
24588
  'goland.sh': 'goland',
24541
24589
  rider: 'rider',
24542
- 'rider.sh': 'rider'
24590
+ 'rider.sh': 'rider',
24591
+ zed: 'zed',
24543
24592
  };
24544
24593
 
24545
24594
  var windows$1 = [
@@ -24566,7 +24615,10 @@ var windows$1 = [
24566
24615
  'goland.exe',
24567
24616
  'goland64.exe',
24568
24617
  'rider.exe',
24569
- 'rider64.exe'
24618
+ 'rider64.exe',
24619
+ 'Trae.exe',
24620
+ 'zed.exe',
24621
+ 'Antigravity.exe',
24570
24622
  ];
24571
24623
 
24572
24624
  const path$6 = require$$0$2;
@@ -24580,7 +24632,60 @@ const COMMON_EDITORS_MACOS = macos;
24580
24632
  const COMMON_EDITORS_LINUX = linux;
24581
24633
  const COMMON_EDITORS_WIN = windows$1;
24582
24634
 
24583
- var guess = function guessEditor (specifiedEditor) {
24635
+ function getEditorFromMacProcesses(output) {
24636
+ const processNames = Object.keys(COMMON_EDITORS_MACOS);
24637
+ const processList = output.split('\n');
24638
+ for (let i = 0; i < processNames.length; i++) {
24639
+ const processName = processNames[i];
24640
+ // Find editor by exact match.
24641
+ if (processList.includes(processName)) {
24642
+ return COMMON_EDITORS_MACOS[processName]
24643
+ }
24644
+ const processNameWithoutApplications = processName.replace('/Applications', '');
24645
+ // Find editor installation not in /Applications.
24646
+ if (output.indexOf(processNameWithoutApplications) !== -1) {
24647
+ // Use the CLI command if one is specified
24648
+ if (processName !== COMMON_EDITORS_MACOS[processName]) {
24649
+ return COMMON_EDITORS_MACOS[processName]
24650
+ }
24651
+ // Use a partial match to find the running process path. If one is found, use the
24652
+ // existing path since it can be running from anywhere.
24653
+ const runningProcess = processList.find((procName) =>
24654
+ procName.endsWith(processNameWithoutApplications),
24655
+ );
24656
+ if (runningProcess !== undefined) {
24657
+ return runningProcess
24658
+ }
24659
+ }
24660
+ }
24661
+ return undefined
24662
+ }
24663
+
24664
+ function getEditorFromWindowsProcesses(output) {
24665
+ const runningProcesses = output.split('\r\n');
24666
+ for (let i = 0; i < runningProcesses.length; i++) {
24667
+ const fullProcessPath = runningProcesses[i].trim();
24668
+ const shortProcessName = path$6.win32.basename(fullProcessPath);
24669
+
24670
+ if (COMMON_EDITORS_WIN.indexOf(shortProcessName) !== -1) {
24671
+ return fullProcessPath
24672
+ }
24673
+ }
24674
+ return undefined
24675
+ }
24676
+
24677
+ function getEditorFromLinuxProcesses(output) {
24678
+ const processNames = Object.keys(COMMON_EDITORS_LINUX);
24679
+ for (let i = 0; i < processNames.length; i++) {
24680
+ const processName = processNames[i];
24681
+ if (output.indexOf(processName) !== -1) {
24682
+ return COMMON_EDITORS_LINUX[processName]
24683
+ }
24684
+ }
24685
+ return undefined
24686
+ }
24687
+
24688
+ function guessEditor$1(specifiedEditor) {
24584
24689
  if (specifiedEditor) {
24585
24690
  return shellQuote.parse(specifiedEditor)
24586
24691
  }
@@ -24600,31 +24705,12 @@ var guess = function guessEditor (specifiedEditor) {
24600
24705
  if (process.platform === 'darwin') {
24601
24706
  const output = childProcess$1
24602
24707
  .execSync('ps x -o comm=', {
24603
- stdio: ['pipe', 'pipe', 'ignore']
24708
+ stdio: ['pipe', 'pipe', 'ignore'],
24604
24709
  })
24605
24710
  .toString();
24606
- const processNames = Object.keys(COMMON_EDITORS_MACOS);
24607
- const processList = output.split('\n');
24608
- for (let i = 0; i < processNames.length; i++) {
24609
- const processName = processNames[i];
24610
- // Find editor by exact match.
24611
- if (processList.includes(processName)) {
24612
- return [COMMON_EDITORS_MACOS[processName]]
24613
- }
24614
- const processNameWithoutApplications = processName.replace('/Applications', '');
24615
- // Find editor installation not in /Applications.
24616
- if (output.indexOf(processNameWithoutApplications) !== -1) {
24617
- // Use the CLI command if one is specified
24618
- if (processName !== COMMON_EDITORS_MACOS[processName]) {
24619
- return [COMMON_EDITORS_MACOS[processName]]
24620
- }
24621
- // Use a partial match to find the running process path. If one is found, use the
24622
- // existing path since it can be running from anywhere.
24623
- const runningProcess = processList.find((procName) => procName.endsWith(processNameWithoutApplications));
24624
- if (runningProcess !== undefined) {
24625
- return [runningProcess]
24626
- }
24627
- }
24711
+ const editor = getEditorFromMacProcesses(output);
24712
+ if (editor !== undefined) {
24713
+ return [editor]
24628
24714
  }
24629
24715
  } else if (process.platform === 'win32') {
24630
24716
  const output = childProcess$1
@@ -24634,18 +24720,13 @@ var guess = function guessEditor (specifiedEditor) {
24634
24720
  'Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }' +
24635
24721
  '"',
24636
24722
  {
24637
- stdio: ['pipe', 'pipe', 'ignore']
24638
- }
24723
+ stdio: ['pipe', 'pipe', 'ignore'],
24724
+ },
24639
24725
  )
24640
24726
  .toString();
24641
- const runningProcesses = output.split('\r\n');
24642
- for (let i = 0; i < runningProcesses.length; i++) {
24643
- const fullProcessPath = runningProcesses[i].trim();
24644
- const shortProcessName = path$6.basename(fullProcessPath);
24645
-
24646
- if (COMMON_EDITORS_WIN.indexOf(shortProcessName) !== -1) {
24647
- return [fullProcessPath]
24648
- }
24727
+ const editor = getEditorFromWindowsProcesses(output);
24728
+ if (editor !== undefined) {
24729
+ return [editor]
24649
24730
  }
24650
24731
  } else if (process.platform === 'linux') {
24651
24732
  // --no-heading No header line
@@ -24653,15 +24734,12 @@ var guess = function guessEditor (specifiedEditor) {
24653
24734
  // -o comm Need only names column
24654
24735
  const output = childProcess$1
24655
24736
  .execSync('ps x --no-heading -o comm --sort=comm', {
24656
- stdio: ['pipe', 'pipe', 'ignore']
24737
+ stdio: ['pipe', 'pipe', 'ignore'],
24657
24738
  })
24658
24739
  .toString();
24659
- const processNames = Object.keys(COMMON_EDITORS_LINUX);
24660
- for (let i = 0; i < processNames.length; i++) {
24661
- const processName = processNames[i];
24662
- if (output.indexOf(processName) !== -1) {
24663
- return [COMMON_EDITORS_LINUX[processName]]
24664
- }
24740
+ const editor = getEditorFromLinuxProcesses(output);
24741
+ if (editor !== undefined) {
24742
+ return [editor]
24665
24743
  }
24666
24744
  }
24667
24745
  } catch (ignoreError) {
@@ -24676,17 +24754,19 @@ var guess = function guessEditor (specifiedEditor) {
24676
24754
  }
24677
24755
 
24678
24756
  return [null]
24679
- };
24757
+ }
24758
+
24759
+ guess.exports = guessEditor$1;
24760
+ guess.exports.getEditorFromMacProcesses = getEditorFromMacProcesses;
24761
+ guess.exports.getEditorFromWindowsProcesses = getEditorFromWindowsProcesses;
24762
+ guess.exports.getEditorFromLinuxProcesses = getEditorFromLinuxProcesses;
24763
+
24764
+ var guessExports = guess.exports;
24680
24765
 
24681
24766
  const path$5 = require$$0$2;
24682
24767
 
24683
24768
  // normalize file/line numbers into command line args for specific editors
24684
- var getArgs = function getArgumentsForPosition (
24685
- editor,
24686
- fileName,
24687
- lineNumber,
24688
- columnNumber = 1
24689
- ) {
24769
+ var getArgs = function getArgumentsForPosition(editor, fileName, lineNumber, columnNumber = 1) {
24690
24770
  const editorBasename = path$5.basename(editor).replace(/\.(exe|cmd|bat)$/i, '');
24691
24771
  switch (editorBasename) {
24692
24772
  case 'atom':
@@ -24706,7 +24786,7 @@ var getArgs = function getArgumentsForPosition (
24706
24786
  return [`+call cursor(${lineNumber}, ${columnNumber})`, fileName]
24707
24787
  case 'joe':
24708
24788
  case 'gvim':
24709
- return ['+' + `${lineNumber}`, fileName]
24789
+ return [`+${lineNumber}`, fileName]
24710
24790
  case 'emacs':
24711
24791
  case 'emacsclient':
24712
24792
  return [`+${lineNumber}:${columnNumber}`, fileName]
@@ -24719,6 +24799,8 @@ var getArgs = function getArgumentsForPosition (
24719
24799
  case 'code-insiders':
24720
24800
  case 'Code - Insiders':
24721
24801
  case 'codium':
24802
+ case 'trae':
24803
+ case 'antigravity':
24722
24804
  case 'cursor':
24723
24805
  case 'vscodium':
24724
24806
  case 'VSCodium':
@@ -24769,29 +24851,25 @@ const path$4 = require$$0$2;
24769
24851
  const colors = picocolorsExports;
24770
24852
  const childProcess = require$$2$1;
24771
24853
 
24772
- const guessEditor = guess;
24854
+ const guessEditor = guessExports;
24773
24855
  const getArgumentsForPosition = getArgs;
24774
24856
 
24775
- function wrapErrorCallback (cb) {
24857
+ function wrapErrorCallback(cb) {
24776
24858
  return (fileName, errorMessage) => {
24777
24859
  console.log();
24778
- console.log(
24779
- colors.red('Could not open ' + path$4.basename(fileName) + ' in the editor.')
24780
- );
24860
+ console.log(colors.red('Could not open ' + path$4.basename(fileName) + ' in the editor.'));
24781
24861
  if (errorMessage) {
24782
24862
  if (errorMessage[errorMessage.length - 1] !== '.') {
24783
24863
  errorMessage += '.';
24784
24864
  }
24785
- console.log(
24786
- colors.red('The editor process exited with an error: ' + errorMessage)
24787
- );
24865
+ console.log(colors.red('The editor process exited with an error: ' + errorMessage));
24788
24866
  }
24789
24867
  console.log();
24790
24868
  if (cb) cb(fileName, errorMessage);
24791
24869
  }
24792
24870
  }
24793
24871
 
24794
- function isTerminalEditor (editor) {
24872
+ function isTerminalEditor(editor) {
24795
24873
  switch (editor) {
24796
24874
  case 'vim':
24797
24875
  case 'emacs':
@@ -24802,7 +24880,7 @@ function isTerminalEditor (editor) {
24802
24880
  }
24803
24881
 
24804
24882
  const positionRE = /:(\d+)(:(\d+))?$/;
24805
- function parseFile (file) {
24883
+ function parseFile(file) {
24806
24884
  // support `file://` protocol
24807
24885
  if (file.startsWith('file://')) {
24808
24886
  file = require$$0$5.fileURLToPath(file);
@@ -24815,17 +24893,25 @@ function parseFile (file) {
24815
24893
  return {
24816
24894
  fileName,
24817
24895
  lineNumber,
24818
- columnNumber
24896
+ columnNumber,
24819
24897
  }
24820
24898
  }
24821
24899
 
24822
- let _childProcess = null;
24900
+ let currentChildProcess = null;
24823
24901
 
24824
- function launchEditor (file, specifiedEditor, onErrorCallback) {
24902
+ function launchEditor(file, specifiedEditor, onErrorCallback) {
24825
24903
  const parsed = parseFile(file);
24826
24904
  let { fileName } = parsed;
24827
24905
  const { lineNumber, columnNumber } = parsed;
24828
24906
 
24907
+ if (process.platform === 'win32' && path$4.resolve(fileName).startsWith('\\\\')) {
24908
+ return onErrorCallback(
24909
+ fileName,
24910
+ 'UNC paths are not supported on Windows to avoid security issues. ' +
24911
+ 'See https://github.com/vitejs/launch-editor/tree/main/packages/launch-editor#unc-paths-on-windows for details.',
24912
+ )
24913
+ }
24914
+
24829
24915
  if (!fs$1.existsSync(fileName)) {
24830
24916
  return
24831
24917
  }
@@ -24864,11 +24950,11 @@ function launchEditor (file, specifiedEditor, onErrorCallback) {
24864
24950
  args.push(fileName);
24865
24951
  }
24866
24952
 
24867
- if (_childProcess && isTerminalEditor(editor)) {
24953
+ if (currentChildProcess && isTerminalEditor(editor)) {
24868
24954
  // There's an existing editor process already and it's attached
24869
24955
  // to the terminal, so go kill it. Otherwise two separate editor
24870
24956
  // instances attach to the stdin/stdout which gets confusing.
24871
- _childProcess.kill('SIGKILL');
24957
+ currentChildProcess.kill('SIGKILL');
24872
24958
  }
24873
24959
 
24874
24960
  if (process.platform === 'win32') {
@@ -24894,7 +24980,7 @@ function launchEditor (file, specifiedEditor, onErrorCallback) {
24894
24980
  // According to https://ss64.com/nt/syntax-esc.html,
24895
24981
  // we can use `^` to escape `&`, `<`, `>`, `|`, `%`, and `^`
24896
24982
  // I'm not sure if we have to escape all of these, but let's do it anyway
24897
- function escapeCmdArgs (cmdArgs) {
24983
+ function escapeCmdArgs(cmdArgs) {
24898
24984
  return cmdArgs.replace(/([&|<>,;=^])/g, '^$1')
24899
24985
  }
24900
24986
 
@@ -24910,29 +24996,27 @@ function launchEditor (file, specifiedEditor, onErrorCallback) {
24910
24996
  return `^"${str}^"`
24911
24997
  } else if (str.includes(' ')) {
24912
24998
  return `"${str}"`
24913
- }
24999
+ }
24914
25000
  return str
24915
25001
  }
24916
- const launchCommand = [editor, ...args.map(escapeCmdArgs)]
24917
- .map(doubleQuoteIfNeeded)
24918
- .join(' ');
25002
+ const launchCommand = [editor, ...args.map(escapeCmdArgs)].map(doubleQuoteIfNeeded).join(' ');
24919
25003
 
24920
- _childProcess = childProcess.exec(launchCommand, {
25004
+ currentChildProcess = childProcess.exec(launchCommand, {
24921
25005
  stdio: 'inherit',
24922
- shell: true
25006
+ shell: true,
24923
25007
  });
24924
25008
  } else {
24925
- _childProcess = childProcess.spawn(editor, args, { stdio: 'inherit' });
25009
+ currentChildProcess = childProcess.spawn(editor, args, { stdio: 'inherit' });
24926
25010
  }
24927
- _childProcess.on('exit', function (errorCode) {
24928
- _childProcess = null;
25011
+ currentChildProcess.on('exit', function (errorCode) {
25012
+ currentChildProcess = null;
24929
25013
 
24930
25014
  if (errorCode) {
24931
25015
  onErrorCallback(fileName, '(code ' + errorCode + ')');
24932
25016
  }
24933
25017
  });
24934
25018
 
24935
- _childProcess.on('error', function (error) {
25019
+ currentChildProcess.on('error', function (error) {
24936
25020
  let { code, message } = error;
24937
25021
  if ('ENOENT' === code) {
24938
25022
  message = `${message} ('${editor}' command does not exist in 'PATH')`;
@@ -24943,7 +25027,6 @@ function launchEditor (file, specifiedEditor, onErrorCallback) {
24943
25027
 
24944
25028
  var launchEditor_1 = launchEditor;
24945
25029
 
24946
- const url$2 = require$$0$5;
24947
25030
  const path$3 = require$$0$2;
24948
25031
  const launch = launchEditor_1;
24949
25032
 
@@ -24960,13 +25043,26 @@ var launchEditorMiddleware = (specifiedEditor, srcRoot, onErrorCallback) => {
24960
25043
 
24961
25044
  srcRoot = srcRoot || process.cwd();
24962
25045
 
24963
- return function launchEditorMiddleware (req, res) {
24964
- const { file } = url$2.parse(req.url, true).query || {};
25046
+ return function launchEditorMiddleware(req, res) {
25047
+ let url;
25048
+
25049
+ try {
25050
+ const fullUrl = req.url.startsWith('http') ? req.url : `http://localhost${req.url}`;
25051
+ url = new URL(fullUrl);
25052
+ // eslint-disable-next-line no-unused-vars
25053
+ } catch (_err) {
25054
+ res.statusCode = 500;
25055
+ res.end(`launch-editor-middleware: invalid URL.`);
25056
+ return
25057
+ }
25058
+
25059
+ const file = url.searchParams.get('file');
24965
25060
  if (!file) {
24966
25061
  res.statusCode = 500;
24967
25062
  res.end(`launch-editor-middleware: required query param "file" is missing.`);
24968
25063
  } else {
24969
- launch(path$3.resolve(srcRoot, file), specifiedEditor, onErrorCallback);
25064
+ const resolved = file.startsWith('file://') ? file : path$3.resolve(srcRoot, file);
25065
+ launch(resolved, specifiedEditor, onErrorCallback);
24970
25066
  res.end();
24971
25067
  }
24972
25068
  }
@@ -35506,9 +35602,18 @@ function isFileServingAllowed(configOrUrl, urlOrServer) {
35506
35602
  function isUriInFilePath(uri, filePath) {
35507
35603
  return isSameFileUri(uri, filePath) || isParentDirectory(uri, filePath);
35508
35604
  }
35605
+ const windowsDriveRE = /^[A-Z]:/i;
35509
35606
  function isFileLoadingAllowed(config, filePath) {
35510
35607
  const { fs } = config.server;
35511
35608
  if (!fs.strict) return true;
35609
+ if (isWindows$3 && filePath.includes("~")) {
35610
+ return false;
35611
+ }
35612
+ const hasDriveLetter = isWindows$3 && windowsDriveRE.test(filePath);
35613
+ const hasColon = (hasDriveLetter ? filePath.slice(2) : filePath).includes(":");
35614
+ if (hasColon) {
35615
+ return false;
35616
+ }
35512
35617
  const filePathWithoutTrailingSlash = filePath.endsWith("/") ? filePath.slice(0, -1) : filePath;
35513
35618
  if (config.fsDenyGlob(filePathWithoutTrailingSlash)) return false;
35514
35619
  if (config.safeModulePaths.has(filePath)) return true;
@@ -35662,8 +35767,9 @@ async function loadAndTransform(environment, id, url, options, timestamp, mod, r
35662
35767
  const { config, pluginContainer, logger } = environment;
35663
35768
  const prettyUrl = debugLoad || debugTransform ? prettifyUrl(url, config.root) : "";
35664
35769
  const moduleGraph = environment.moduleGraph;
35665
- if (options.allowId && !options.allowId(id)) {
35770
+ if (!options.skipFsCheck && id[0] !== "\0" && isServerAccessDeniedForTransform(config, id)) {
35666
35771
  const err = new Error(`Denied ID ${id}`);
35772
+ err.id = id;
35667
35773
  err.code = ERR_DENIED_ID;
35668
35774
  throw err;
35669
35775
  }
@@ -35676,7 +35782,7 @@ async function loadAndTransform(environment, id, url, options, timestamp, mod, r
35676
35782
  if (options.html && !id.endsWith(".html")) {
35677
35783
  return null;
35678
35784
  }
35679
- if (environment.config.consumer === "server" || isFileLoadingAllowed(environment.getTopLevelConfig(), file)) {
35785
+ if (options.skipFsCheck || isFileLoadingAllowed(environment.getTopLevelConfig(), slash$1(file))) {
35680
35786
  try {
35681
35787
  code = await fsp.readFile(file, "utf-8");
35682
35788
  debugLoad?.(`${timeFrom(loadStart)} [fs] ${prettyUrl}`);
@@ -37134,6 +37240,12 @@ function deniedServingAccessForTransform(url, server, res, next) {
37134
37240
  }
37135
37241
  return false;
37136
37242
  }
37243
+ function isServerAccessDeniedForTransform(config, id) {
37244
+ if (rawRE.test(id) || urlRE.test(id) || inlineRE$2.test(id) || svgRE.test(id)) {
37245
+ return checkLoadingAccess(config, id) !== "allowed";
37246
+ }
37247
+ return false;
37248
+ }
37137
37249
  function cachedTransformMiddleware(server) {
37138
37250
  return function viteCachedTransformMiddleware(req, res, next) {
37139
37251
  const environment = server.environments.client;
@@ -37183,6 +37295,9 @@ function transformMiddleware(server) {
37183
37295
  const depsOptimizer = environment.depsOptimizer;
37184
37296
  if (depsOptimizer?.isOptimizedDepUrl(url)) {
37185
37297
  const sourcemapPath = url.startsWith(FS_PREFIX) ? fsPathFromId(url) : normalizePath$3(path$b.resolve(server.config.root, url.slice(1)));
37298
+ if (!depsOptimizer.isOptimizedDepFile(sourcemapPath)) {
37299
+ return next();
37300
+ }
37186
37301
  try {
37187
37302
  const map = JSON.parse(
37188
37303
  await fsp.readFile(sourcemapPath, "utf-8")
@@ -37253,9 +37368,7 @@ function transformMiddleware(server) {
37253
37368
  }
37254
37369
  const result = await transformRequest(environment, url, {
37255
37370
  html: req.headers.accept?.includes("text/html"),
37256
- allowId(id) {
37257
- return !deniedServingAccessForTransform(id, server, res, next);
37258
- }
37371
+ skipFsCheck: environment._skipFsCheck
37259
37372
  });
37260
37373
  if (result) {
37261
37374
  const depsOptimizer = environment.depsOptimizer;
@@ -37308,7 +37421,23 @@ function transformMiddleware(server) {
37308
37421
  return next();
37309
37422
  }
37310
37423
  if (e?.code === ERR_DENIED_ID) {
37311
- return;
37424
+ const id = e.id;
37425
+ let servingAccessResult = checkLoadingAccess(
37426
+ server.config,
37427
+ cleanUrl(id)
37428
+ );
37429
+ if (servingAccessResult === "allowed") {
37430
+ servingAccessResult = checkLoadingAccess(server.config, id);
37431
+ }
37432
+ if (servingAccessResult === "denied") {
37433
+ respondWithAccessDenied(id, server, res);
37434
+ return true;
37435
+ }
37436
+ if (servingAccessResult === "fallback") {
37437
+ next();
37438
+ return true;
37439
+ }
37440
+ throw new Error(`Unexpected access result for id ${id}`);
37312
37441
  }
37313
37442
  return next(e);
37314
37443
  }
@@ -39656,6 +39785,7 @@ function createServerHotChannel() {
39656
39785
  const innerEmitter = new EventEmitter$4();
39657
39786
  const outsideEmitter = new EventEmitter$4();
39658
39787
  return {
39788
+ skipFsCheck: true,
39659
39789
  send(payload) {
39660
39790
  outsideEmitter.emit("send", payload);
39661
39791
  },
@@ -43941,8 +44071,8 @@ function createCachedImport(imp) {
43941
44071
  return cached;
43942
44072
  };
43943
44073
  }
43944
- const importPostcssImport = createCachedImport(() => import('./dep-C9BXG1mU.js').then(function (n) { return n.i; }));
43945
- const importPostcssModules = createCachedImport(() => import('./dep-DWMUTS1A.js').then(function (n) { return n.i; }));
44074
+ const importPostcssImport = createCachedImport(() => import('./dep-CV-fz3CQ.js').then(function (n) { return n.i; }));
44075
+ const importPostcssModules = createCachedImport(() => import('./dep-DDtvSN7_.js').then(function (n) { return n.i; }));
43946
44076
  const importPostcss = createCachedImport(() => import('postcss'));
43947
44077
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
43948
44078
  let alwaysFakeWorkerWorkerControllerCache;
@@ -47834,6 +47964,10 @@ class DevEnvironment extends BaseEnvironment {
47834
47964
  * @internal
47835
47965
  */
47836
47966
  _remoteRunnerOptions;
47967
+ /**
47968
+ * @internal
47969
+ */
47970
+ _skipFsCheck;
47837
47971
  get pluginContainer() {
47838
47972
  if (!this._pluginContainer)
47839
47973
  throw new Error(
@@ -47881,9 +48015,13 @@ class DevEnvironment extends BaseEnvironment {
47881
48015
  );
47882
48016
  this._crawlEndFinder = setupOnCrawlEnd();
47883
48017
  this._remoteRunnerOptions = context.remoteRunner ?? {};
48018
+ this._skipFsCheck = !!(context.transport && !(isWebSocketServer in context.transport) && context.transport.skipFsCheck);
47884
48019
  this.hot = context.transport ? isWebSocketServer in context.transport ? context.transport : normalizeHotChannel(context.transport, context.hot) : normalizeHotChannel({}, context.hot);
47885
48020
  this.hot.setInvokeHandler({
47886
48021
  fetchModule: (id, importer, options2) => {
48022
+ if (context.disableFetchModule) {
48023
+ throw new Error("fetchModule is disabled in this environment");
48024
+ }
47887
48025
  return this.fetchModule(id, importer, options2);
47888
48026
  }
47889
48027
  });
@@ -47941,11 +48079,11 @@ class DevEnvironment extends BaseEnvironment {
47941
48079
  }
47942
48080
  }
47943
48081
  transformRequest(url) {
47944
- return transformRequest(this, url);
48082
+ return transformRequest(this, url, { skipFsCheck: this._skipFsCheck });
47945
48083
  }
47946
48084
  async warmupRequest(url) {
47947
48085
  try {
47948
- await this.transformRequest(url);
48086
+ await transformRequest(this, url, { skipFsCheck: true });
47949
48087
  } catch (e) {
47950
48088
  if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP || e?.code === ERR_CLOSED_SERVER) {
47951
48089
  return;
@@ -48445,7 +48583,8 @@ function defineConfig(config) {
48445
48583
  function defaultCreateClientDevEnvironment(name, config, context) {
48446
48584
  return new DevEnvironment(name, config, {
48447
48585
  hot: true,
48448
- transport: context.ws
48586
+ transport: context.ws,
48587
+ disableFetchModule: true
48449
48588
  });
48450
48589
  }
48451
48590
  function defaultCreateDevEnvironment(name, config) {
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs__default from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-D4NMHUTW.js';
5
+ import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-Dm0c1Wj2.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -748,7 +748,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
748
748
  `[boolean] force the optimizer to ignore the cache and re-bundle`
749
749
  ).action(async (root, options) => {
750
750
  filterDuplicateOptions(options);
751
- const { createServer } = await import('./chunks/dep-D4NMHUTW.js').then(function (n) { return n.S; });
751
+ const { createServer } = await import('./chunks/dep-Dm0c1Wj2.js').then(function (n) { return n.S; });
752
752
  try {
753
753
  const server = await createServer({
754
754
  root,
@@ -843,7 +843,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
843
843
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
844
844
  async (root, options) => {
845
845
  filterDuplicateOptions(options);
846
- const { createBuilder } = await import('./chunks/dep-D4NMHUTW.js').then(function (n) { return n.T; });
846
+ const { createBuilder } = await import('./chunks/dep-Dm0c1Wj2.js').then(function (n) { return n.T; });
847
847
  const buildOptions = cleanGlobalCLIOptions(
848
848
  cleanBuilderCLIOptions(options)
849
849
  );
@@ -882,7 +882,7 @@ cli.command(
882
882
  ).action(
883
883
  async (root, options) => {
884
884
  filterDuplicateOptions(options);
885
- const { optimizeDeps } = await import('./chunks/dep-D4NMHUTW.js').then(function (n) { return n.R; });
885
+ const { optimizeDeps } = await import('./chunks/dep-Dm0c1Wj2.js').then(function (n) { return n.R; });
886
886
  try {
887
887
  const config = await resolveConfig(
888
888
  {
@@ -909,7 +909,7 @@ ${e.stack}`),
909
909
  cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
910
910
  async (root, options) => {
911
911
  filterDuplicateOptions(options);
912
- const { preview } = await import('./chunks/dep-D4NMHUTW.js').then(function (n) { return n.U; });
912
+ const { preview } = await import('./chunks/dep-Dm0c1Wj2.js').then(function (n) { return n.U; });
913
913
  try {
914
914
  const server = await preview({
915
915
  root,
@@ -1220,6 +1220,11 @@ interface HotChannelClient {
1220
1220
  type HMRBroadcasterClient = HotChannelClient;
1221
1221
  type HotChannelListener<T extends string = string> = (data: InferCustomEventPayload<T>, client: HotChannelClient) => void;
1222
1222
  interface HotChannel<Api = any> {
1223
+ /**
1224
+ * When true, the fs access check is skipped in fetchModule.
1225
+ * Set this for transports that is not exposed over the network.
1226
+ */
1227
+ skipFsCheck?: boolean;
1223
1228
  /**
1224
1229
  * Broadcast events to all clients
1225
1230
  */
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { a as arraify, i as isInNodeModules, D as DevEnvironment } from './chunks/dep-D4NMHUTW.js';
3
- export { B as BuildEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-D4NMHUTW.js';
2
+ import { a as arraify, i as isInNodeModules, D as DevEnvironment } from './chunks/dep-Dm0c1Wj2.js';
3
+ export { B as BuildEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-Dm0c1Wj2.js';
4
4
  export { defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import 'node:fs';
@@ -3414,9 +3414,18 @@ function isFileServingAllowed(configOrUrl, urlOrServer) {
3414
3414
  function isUriInFilePath(uri, filePath) {
3415
3415
  return isSameFileUri(uri, filePath) || isParentDirectory(uri, filePath);
3416
3416
  }
3417
+ const windowsDriveRE = /^[A-Z]:/i;
3417
3418
  function isFileLoadingAllowed(config, filePath) {
3418
3419
  const { fs } = config.server;
3419
3420
  if (!fs.strict) return true;
3421
+ if (isWindows && filePath.includes("~")) {
3422
+ return false;
3423
+ }
3424
+ const hasDriveLetter = isWindows && windowsDriveRE.test(filePath);
3425
+ const hasColon = (hasDriveLetter ? filePath.slice(2) : filePath).includes(":");
3426
+ if (hasColon) {
3427
+ return false;
3428
+ }
3420
3429
  const filePathWithoutTrailingSlash = filePath.endsWith("/") ? filePath.slice(0, -1) : filePath;
3421
3430
  if (config.fsDenyGlob(filePathWithoutTrailingSlash)) return false;
3422
3431
  if (config.safeModulePaths.has(filePath)) return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.4.1",
3
+ "version": "6.4.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -111,7 +111,7 @@
111
111
  "estree-walker": "^3.0.3",
112
112
  "etag": "^1.8.1",
113
113
  "http-proxy": "^1.18.1",
114
- "launch-editor-middleware": "^2.10.0",
114
+ "launch-editor-middleware": "^2.14.1",
115
115
  "lightningcss": "^1.29.3",
116
116
  "magic-string": "^0.30.17",
117
117
  "mlly": "^1.7.4",