vite 5.3.4 → 5.4.0-beta.0

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.
@@ -1,4 +1,4 @@
1
- import { B as getDefaultExportFromCjs } from './dep-D8YhmIY-.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-BuSuK4CE.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-IQS-Za7F.js';
@@ -371,13 +371,16 @@ var CharCodes;
371
371
  (function (CharCodes) {
372
372
  CharCodes[CharCodes["NUM"] = 35] = "NUM";
373
373
  CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
374
+ CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
374
375
  CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
375
376
  CharCodes[CharCodes["NINE"] = 57] = "NINE";
376
377
  CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
377
378
  CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
378
379
  CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
379
- /** Bit that needs to be set to convert an upper case ASCII character to lower case */
380
- CharCodes[CharCodes["To_LOWER_BIT"] = 32] = "To_LOWER_BIT";
380
+ CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
381
+ CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
382
+ CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
383
+ CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
381
384
  })(CharCodes || (CharCodes = {}));
382
385
  var BinTrieFlags;
383
386
  (function (BinTrieFlags) {
@@ -385,6 +388,33 @@ var BinTrieFlags;
385
388
  BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
386
389
  BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
387
390
  })(BinTrieFlags || (BinTrieFlags = {}));
391
+ var EntityDecoderState;
392
+ (function (EntityDecoderState) {
393
+ EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
394
+ EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
395
+ EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
396
+ EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
397
+ EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
398
+ })(EntityDecoderState || (EntityDecoderState = {}));
399
+ var DecodingMode;
400
+ (function (DecodingMode) {
401
+ /** Entities in text nodes that can end with any character. */
402
+ DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
403
+ /** Only allow entities terminated with a semicolon. */
404
+ DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
405
+ /** Entities in attributes have limitations on ending characters. */
406
+ DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
407
+ })(DecodingMode || (DecodingMode = {}));
408
+ /**
409
+ * Determines the branch of the current node that is taken given the current
410
+ * character. This function is used to traverse the trie.
411
+ *
412
+ * @param decodeTree The trie.
413
+ * @param current The current node.
414
+ * @param nodeIdx The index right after the current node and its value.
415
+ * @param char The current character.
416
+ * @returns The index of the next node, or -1 if no branch is taken.
417
+ */
388
418
  function determineBranch(decodeTree, current, nodeIdx, char) {
389
419
  const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
390
420
  const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
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 { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-D8YhmIY-.js';
5
+ import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-BuSuK4CE.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -730,7 +730,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
730
730
  `[boolean] force the optimizer to ignore the cache and re-bundle`
731
731
  ).action(async (root, options) => {
732
732
  filterDuplicateOptions(options);
733
- const { createServer } = await import('./chunks/dep-D8YhmIY-.js').then(function (n) { return n.E; });
733
+ const { createServer } = await import('./chunks/dep-BuSuK4CE.js').then(function (n) { return n.E; });
734
734
  try {
735
735
  const server = await createServer({
736
736
  root,
@@ -822,7 +822,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
822
822
  `[boolean] force empty outDir when it's outside of root`
823
823
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).action(async (root, options) => {
824
824
  filterDuplicateOptions(options);
825
- const { build } = await import('./chunks/dep-D8YhmIY-.js').then(function (n) { return n.F; });
825
+ const { build } = await import('./chunks/dep-BuSuK4CE.js').then(function (n) { return n.F; });
826
826
  const buildOptions = cleanOptions(options);
827
827
  try {
828
828
  await build({
@@ -851,7 +851,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
851
851
  ).action(
852
852
  async (root, options) => {
853
853
  filterDuplicateOptions(options);
854
- const { optimizeDeps } = await import('./chunks/dep-D8YhmIY-.js').then(function (n) { return n.D; });
854
+ const { optimizeDeps } = await import('./chunks/dep-BuSuK4CE.js').then(function (n) { return n.D; });
855
855
  try {
856
856
  const config = await resolveConfig(
857
857
  {
@@ -877,7 +877,7 @@ ${e.stack}`),
877
877
  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(
878
878
  async (root, options) => {
879
879
  filterDuplicateOptions(options);
880
- const { preview } = await import('./chunks/dep-D8YhmIY-.js').then(function (n) { return n.G; });
880
+ const { preview } = await import('./chunks/dep-BuSuK4CE.js').then(function (n) { return n.G; });
881
881
  try {
882
882
  const server = await preview({
883
883
  root,
@@ -1473,7 +1473,7 @@ interface HmrOptions {
1473
1473
  path?: string;
1474
1474
  timeout?: number;
1475
1475
  overlay?: boolean;
1476
- server?: Server;
1476
+ server?: HttpServer;
1477
1477
  }
1478
1478
  interface HmrContext {
1479
1479
  file: string;
@@ -1623,7 +1623,7 @@ interface ServerOptions extends CommonServerOptions {
1623
1623
  *
1624
1624
  * This is needed to proxy WebSocket connections to the parent server.
1625
1625
  */
1626
- server: http.Server;
1626
+ server: HttpServer;
1627
1627
  };
1628
1628
  /**
1629
1629
  * Options for files served via '/\@fs/'.
@@ -3575,4 +3575,4 @@ declare class ServerHMRConnector implements HMRRuntimeConnection {
3575
3575
  onUpdate(handler: (payload: HMRPayload) => void): void;
3576
3576
  }
3577
3577
 
3578
- export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, type BuildOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, type ESBuildOptions, type ESBuildTransformResult, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HtmlTagDescriptor, HttpProxy, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type MainThreadRuntimeOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type SSROptions, type SSRTarget, type SendOptions, type ServerHMRChannel, ServerHMRConnector, type ServerHook, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createFilter, createLogger, createServer, createViteRuntime, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
3578
+ export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, type BuildOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, type ESBuildOptions, type ESBuildTransformResult, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HtmlTagDescriptor, HttpProxy, type HttpServer, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type MainThreadRuntimeOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type SSROptions, type SSRTarget, type SendOptions, type ServerHMRChannel, ServerHMRConnector, type ServerHook, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createFilter, createLogger, createServer, createViteRuntime, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-D8YhmIY-.js';
3
- export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-D8YhmIY-.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-BuSuK4CE.js';
3
+ export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BuSuK4CE.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import { existsSync, readFileSync } from 'node:fs';
@@ -316,9 +316,7 @@ class ModuleCacheMap extends Map {
316
316
  const mod = this.get(moduleId);
317
317
  if (mod.map) return mod.map;
318
318
  if (!mod.meta || !("code" in mod.meta)) return null;
319
- const mapString = mod.meta.code.match(
320
- VITE_RUNTIME_SOURCEMAPPING_REGEXP
321
- )?.[1];
319
+ const mapString = VITE_RUNTIME_SOURCEMAPPING_REGEXP.exec(mod.meta.code)?.[1];
322
320
  if (!mapString) return null;
323
321
  const baseFile = mod.meta.file || moduleId.split("?")[0];
324
322
  return mod.map = new DecodedMap(JSON.parse(decodeBase64(mapString)), baseFile), mod.map;
@@ -28,92 +28,13 @@ const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
28
28
  path$3.resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
29
29
  path$3.dirname(CLIENT_ENTRY);
30
30
 
31
- const comma = ','.charCodeAt(0);
32
- const semicolon = ';'.charCodeAt(0);
33
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
34
- const intToChar = new Uint8Array(64); // 64 possible chars.
35
- const charToInt = new Uint8Array(128); // z is 122 in ASCII
36
- for (let i = 0; i < chars.length; i++) {
37
- const c = chars.charCodeAt(i);
38
- intToChar[i] = c;
39
- charToInt[c] = i;
40
- }
41
- // Provide a fallback for older environments.
42
- const td = typeof TextDecoder !== 'undefined'
43
- ? /* #__PURE__ */ new TextDecoder()
44
- : typeof Buffer !== 'undefined'
45
- ? {
46
- decode(buf) {
47
- const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
48
- return out.toString();
49
- },
50
- }
51
- : {
52
- decode(buf) {
53
- let out = '';
54
- for (let i = 0; i < buf.length; i++) {
55
- out += String.fromCharCode(buf[i]);
56
- }
57
- return out;
58
- },
59
- };
60
- function encode(decoded) {
61
- const state = new Int32Array(5);
62
- const bufLength = 1024 * 16;
63
- const subLength = bufLength - 36;
64
- const buf = new Uint8Array(bufLength);
65
- const sub = buf.subarray(0, subLength);
66
- let pos = 0;
67
- let out = '';
68
- for (let i = 0; i < decoded.length; i++) {
69
- const line = decoded[i];
70
- if (i > 0) {
71
- if (pos === bufLength) {
72
- out += td.decode(buf);
73
- pos = 0;
74
- }
75
- buf[pos++] = semicolon;
76
- }
77
- if (line.length === 0)
78
- continue;
79
- state[0] = 0;
80
- for (let j = 0; j < line.length; j++) {
81
- const segment = line[j];
82
- // We can push up to 5 ints, each int can take at most 7 chars, and we
83
- // may push a comma.
84
- if (pos > subLength) {
85
- out += td.decode(sub);
86
- buf.copyWithin(0, subLength, pos);
87
- pos -= subLength;
88
- }
89
- if (j > 0)
90
- buf[pos++] = comma;
91
- pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
92
- if (segment.length === 1)
93
- continue;
94
- pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
95
- pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
96
- pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
97
- if (segment.length === 4)
98
- continue;
99
- pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
100
- }
101
- }
102
- return out + td.decode(buf.subarray(0, pos));
103
- }
104
- function encodeInteger(buf, pos, state, segment, j) {
105
- const next = segment[j];
106
- let num = next - state[j];
107
- state[j] = next;
108
- num = num < 0 ? (-num << 1) | 1 : num << 1;
109
- do {
110
- let clamped = num & 0b011111;
111
- num >>>= 5;
112
- if (num > 0)
113
- clamped |= 0b100000;
114
- buf[pos++] = intToChar[clamped];
115
- } while (num > 0);
116
- return pos;
31
+ const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
32
+ const intToChar$1 = new Uint8Array(64); // 64 possible chars.
33
+ const charToInt$1 = new Uint8Array(128); // z is 122 in ASCII
34
+ for (let i = 0; i < chars$1.length; i++) {
35
+ const c = chars$1.charCodeAt(i);
36
+ intToChar$1[i] = c;
37
+ charToInt$1[c] = i;
117
38
  }
118
39
 
119
40
  function getDefaultExportFromCjs (x) {
@@ -785,6 +706,8 @@ function requireBrowser () {
785
706
  return false;
786
707
  }
787
708
 
709
+ let m;
710
+
788
711
  // Is webkit? http://stackoverflow.com/a/16459606/376773
789
712
  // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
790
713
  return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
@@ -792,7 +715,7 @@ function requireBrowser () {
792
715
  (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
793
716
  // Is firefox >= v31?
794
717
  // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
795
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
718
+ (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
796
719
  // Double check webkit in userAgent just in case we are in a worker
797
720
  (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
798
721
  }
@@ -3454,7 +3377,6 @@ function tryStatSync(file) {
3454
3377
  } catch {
3455
3378
  }
3456
3379
  }
3457
- const splitRE = /\r?\n/g;
3458
3380
  function isFileReadable(filename) {
3459
3381
  if (!tryStatSync(filename)) {
3460
3382
  return false;
@@ -3506,6 +3428,9 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
3506
3428
  ...backwardCompatibleWorkerPlugins(value)
3507
3429
  ];
3508
3430
  continue;
3431
+ } else if (key === "server" && rootPath === "server.hmr") {
3432
+ merged[key] = value;
3433
+ continue;
3509
3434
  }
3510
3435
  if (Array.isArray(existing) || Array.isArray(value)) {
3511
3436
  merged[key] = [...arraify(existing), ...arraify(value)];
@@ -4039,6 +3964,99 @@ function stattag (stat) {
4039
3964
 
4040
3965
  var getEtag = /*@__PURE__*/getDefaultExportFromCjs(etag_1);
4041
3966
 
3967
+ const comma = ','.charCodeAt(0);
3968
+ const semicolon = ';'.charCodeAt(0);
3969
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
3970
+ const intToChar = new Uint8Array(64); // 64 possible chars.
3971
+ const charToInt = new Uint8Array(128); // z is 122 in ASCII
3972
+ for (let i = 0; i < chars.length; i++) {
3973
+ const c = chars.charCodeAt(i);
3974
+ intToChar[i] = c;
3975
+ charToInt[c] = i;
3976
+ }
3977
+ function encodeInteger(builder, num, relative) {
3978
+ let delta = num - relative;
3979
+ delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
3980
+ do {
3981
+ let clamped = delta & 0b011111;
3982
+ delta >>>= 5;
3983
+ if (delta > 0)
3984
+ clamped |= 0b100000;
3985
+ builder.write(intToChar[clamped]);
3986
+ } while (delta > 0);
3987
+ return num;
3988
+ }
3989
+
3990
+ const bufLength = 1024 * 16;
3991
+ // Provide a fallback for older environments.
3992
+ const td = typeof TextDecoder !== 'undefined'
3993
+ ? /* #__PURE__ */ new TextDecoder()
3994
+ : typeof Buffer !== 'undefined'
3995
+ ? {
3996
+ decode(buf) {
3997
+ const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
3998
+ return out.toString();
3999
+ },
4000
+ }
4001
+ : {
4002
+ decode(buf) {
4003
+ let out = '';
4004
+ for (let i = 0; i < buf.length; i++) {
4005
+ out += String.fromCharCode(buf[i]);
4006
+ }
4007
+ return out;
4008
+ },
4009
+ };
4010
+ class StringWriter {
4011
+ constructor() {
4012
+ this.pos = 0;
4013
+ this.out = '';
4014
+ this.buffer = new Uint8Array(bufLength);
4015
+ }
4016
+ write(v) {
4017
+ const { buffer } = this;
4018
+ buffer[this.pos++] = v;
4019
+ if (this.pos === bufLength) {
4020
+ this.out += td.decode(buffer);
4021
+ this.pos = 0;
4022
+ }
4023
+ }
4024
+ flush() {
4025
+ const { buffer, out, pos } = this;
4026
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
4027
+ }
4028
+ }
4029
+ function encode(decoded) {
4030
+ const writer = new StringWriter();
4031
+ let sourcesIndex = 0;
4032
+ let sourceLine = 0;
4033
+ let sourceColumn = 0;
4034
+ let namesIndex = 0;
4035
+ for (let i = 0; i < decoded.length; i++) {
4036
+ const line = decoded[i];
4037
+ if (i > 0)
4038
+ writer.write(semicolon);
4039
+ if (line.length === 0)
4040
+ continue;
4041
+ let genColumn = 0;
4042
+ for (let j = 0; j < line.length; j++) {
4043
+ const segment = line[j];
4044
+ if (j > 0)
4045
+ writer.write(comma);
4046
+ genColumn = encodeInteger(writer, segment[0], genColumn);
4047
+ if (segment.length === 1)
4048
+ continue;
4049
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
4050
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
4051
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
4052
+ if (segment.length === 4)
4053
+ continue;
4054
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
4055
+ }
4056
+ }
4057
+ return writer.flush();
4058
+ }
4059
+
4042
4060
  class BitSet {
4043
4061
  constructor(arg) {
4044
4062
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
@@ -4794,8 +4812,10 @@ class MagicString {
4794
4812
  update(start, end, content, options) {
4795
4813
  if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
4796
4814
 
4797
- while (start < 0) start += this.original.length;
4798
- while (end < 0) end += this.original.length;
4815
+ if (this.original.length !== 0) {
4816
+ while (start < 0) start += this.original.length;
4817
+ while (end < 0) end += this.original.length;
4818
+ }
4799
4819
 
4800
4820
  if (end > this.original.length) throw new Error('end is out of bounds');
4801
4821
  if (start === end)
@@ -4891,8 +4911,10 @@ class MagicString {
4891
4911
  }
4892
4912
 
4893
4913
  remove(start, end) {
4894
- while (start < 0) start += this.original.length;
4895
- while (end < 0) end += this.original.length;
4914
+ if (this.original.length !== 0) {
4915
+ while (start < 0) start += this.original.length;
4916
+ while (end < 0) end += this.original.length;
4917
+ }
4896
4918
 
4897
4919
  if (start === end) return this;
4898
4920
 
@@ -4915,8 +4937,10 @@ class MagicString {
4915
4937
  }
4916
4938
 
4917
4939
  reset(start, end) {
4918
- while (start < 0) start += this.original.length;
4919
- while (end < 0) end += this.original.length;
4940
+ if (this.original.length !== 0) {
4941
+ while (start < 0) start += this.original.length;
4942
+ while (end < 0) end += this.original.length;
4943
+ }
4920
4944
 
4921
4945
  if (start === end) return this;
4922
4946
 
@@ -4978,8 +5002,10 @@ class MagicString {
4978
5002
  }
4979
5003
 
4980
5004
  slice(start = 0, end = this.original.length) {
4981
- while (start < 0) start += this.original.length;
4982
- while (end < 0) end += this.original.length;
5005
+ if (this.original.length !== 0) {
5006
+ while (start < 0) start += this.original.length;
5007
+ while (end < 0) end += this.original.length;
5008
+ }
4983
5009
 
4984
5010
  let result = '';
4985
5011
 
@@ -5394,7 +5420,6 @@ function getTimeFormatter() {
5394
5420
  });
5395
5421
  return timeFormatter;
5396
5422
  }
5397
- const MAX_LOG_CHAR = 5e3;
5398
5423
  function createLogger(level = "info", options = {}) {
5399
5424
  if (options.customLogger) {
5400
5425
  return options.customLogger;
@@ -5405,22 +5430,17 @@ function createLogger(level = "info", options = {}) {
5405
5430
  const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
5406
5431
  const clear = canClearScreen ? clearScreen : () => {
5407
5432
  };
5408
- function preventOverflow(msg) {
5409
- if (msg.length > MAX_LOG_CHAR) {
5410
- const shorten = msg.slice(0, MAX_LOG_CHAR);
5411
- const lines = msg.slice(MAX_LOG_CHAR).match(splitRE)?.length || 0;
5412
- return `${shorten}
5413
- ... and ${lines} lines more`;
5414
- }
5415
- return msg;
5416
- }
5417
- function format(type, rawMsg, options2 = {}) {
5418
- const msg = preventOverflow(rawMsg);
5433
+ function format(type, msg, options2 = {}) {
5419
5434
  if (options2.timestamp) {
5420
- const tag = type === "info" ? colors.cyan(colors.bold(prefix)) : type === "warn" ? colors.yellow(colors.bold(prefix)) : colors.red(colors.bold(prefix));
5421
- return `${colors.dim(
5422
- getTimeFormatter().format(/* @__PURE__ */ new Date())
5423
- )} ${tag} ${msg}`;
5435
+ let tag = "";
5436
+ if (type === "info") {
5437
+ tag = colors.cyan(colors.bold(prefix));
5438
+ } else if (type === "warn") {
5439
+ tag = colors.yellow(colors.bold(prefix));
5440
+ } else {
5441
+ tag = colors.red(colors.bold(prefix));
5442
+ }
5443
+ return `${colors.dim(getTimeFormatter().format(/* @__PURE__ */ new Date()))} ${tag} ${msg}`;
5424
5444
  } else {
5425
5445
  return msg;
5426
5446
  }
package/index.cjs CHANGED
@@ -1,12 +1,9 @@
1
- /* eslint-disable no-restricted-globals */
2
-
3
1
  warnCjsUsage()
4
2
 
5
3
  // type utils
6
4
  module.exports.defineConfig = (config) => config
7
5
 
8
6
  // proxy cjs utils (sync functions)
9
- // eslint-disable-next-line n/no-missing-require -- will be generated by build
10
7
  Object.assign(module.exports, require('./dist/node-cjs/publicUtils.cjs'))
11
8
 
12
9
  // async functions, can be redirect from ESM build
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.3.4",
3
+ "version": "5.4.0-beta.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -73,7 +73,7 @@
73
73
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
74
74
  "dependencies": {
75
75
  "esbuild": "^0.21.3",
76
- "postcss": "^8.4.39",
76
+ "postcss": "^8.4.40",
77
77
  "rollup": "^4.13.0"
78
78
  },
79
79
  "optionalDependencies": {
@@ -81,7 +81,7 @@
81
81
  },
82
82
  "devDependencies": {
83
83
  "@ampproject/remapping": "^2.3.0",
84
- "@babel/parser": "^7.24.7",
84
+ "@babel/parser": "^7.25.0",
85
85
  "@jridgewell/trace-mapping": "^0.3.25",
86
86
  "@polka/compression": "^1.0.0-next.25",
87
87
  "@rollup/plugin-alias": "^5.1.0",
@@ -99,7 +99,7 @@
99
99
  "convert-source-map": "^2.0.0",
100
100
  "cors": "^2.8.5",
101
101
  "cross-spawn": "^7.0.3",
102
- "debug": "^4.3.5",
102
+ "debug": "^4.3.6",
103
103
  "dep-types": "link:./src/types",
104
104
  "dotenv": "^16.4.5",
105
105
  "dotenv-expand": "^11.0.6",
@@ -111,7 +111,7 @@
111
111
  "http-proxy": "^1.18.1",
112
112
  "launch-editor-middleware": "^2.8.0",
113
113
  "lightningcss": "^1.25.1",
114
- "magic-string": "^0.30.10",
114
+ "magic-string": "^0.30.11",
115
115
  "micromatch": "^4.0.7",
116
116
  "mlly": "^1.7.1",
117
117
  "mrmime": "^2.0.0",
@@ -127,8 +127,8 @@
127
127
  "resolve.exports": "^2.0.2",
128
128
  "rollup-plugin-dts": "^6.1.1",
129
129
  "rollup-plugin-esbuild": "^6.1.1",
130
- "rollup-plugin-license": "^3.5.1",
131
- "sass": "^1.77.6",
130
+ "rollup-plugin-license": "^3.5.2",
131
+ "sass": "^1.77.8",
132
132
  "sirv": "^2.0.4",
133
133
  "source-map-support": "^0.5.21",
134
134
  "strip-ansi": "^7.1.0",
@@ -136,8 +136,8 @@
136
136
  "tsconfck": "^3.1.1",
137
137
  "tslib": "^2.6.3",
138
138
  "types": "link:./types",
139
- "ufo": "^1.5.3",
140
- "ws": "^8.17.1"
139
+ "ufo": "^1.5.4",
140
+ "ws": "^8.18.0"
141
141
  },
142
142
  "peerDependencies": {
143
143
  "@types/node": "^18.0.0 || >=20.0.0",