vite 5.4.0-beta.0 → 5.4.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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -10781,17 +10781,34 @@ const glob$1 = Object.assign(glob_, {
10781
10781
  });
10782
10782
  glob$1.glob = glob$1;
10783
10783
 
10784
- const comma$1 = ','.charCodeAt(0);
10785
- const semicolon$1 = ';'.charCodeAt(0);
10786
- const chars$2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
10787
- const intToChar$1 = new Uint8Array(64); // 64 possible chars.
10788
- const charToInt$1 = new Uint8Array(128); // z is 122 in ASCII
10789
- for (let i = 0; i < chars$2.length; i++) {
10790
- const c = chars$2.charCodeAt(i);
10791
- intToChar$1[i] = c;
10792
- charToInt$1[c] = i;
10793
- }
10794
- function encodeInteger$1(builder, num, relative) {
10784
+ const comma = ','.charCodeAt(0);
10785
+ const semicolon = ';'.charCodeAt(0);
10786
+ const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
10787
+ const intToChar = new Uint8Array(64); // 64 possible chars.
10788
+ const charToInt = new Uint8Array(128); // z is 122 in ASCII
10789
+ for (let i = 0; i < chars$1.length; i++) {
10790
+ const c = chars$1.charCodeAt(i);
10791
+ intToChar[i] = c;
10792
+ charToInt[c] = i;
10793
+ }
10794
+ function decodeInteger(reader, relative) {
10795
+ let value = 0;
10796
+ let shift = 0;
10797
+ let integer = 0;
10798
+ do {
10799
+ const c = reader.next();
10800
+ integer = charToInt[c];
10801
+ value |= (integer & 31) << shift;
10802
+ shift += 5;
10803
+ } while (integer & 32);
10804
+ const shouldNegate = value & 1;
10805
+ value >>>= 1;
10806
+ if (shouldNegate) {
10807
+ value = -0x80000000 | -value;
10808
+ }
10809
+ return relative + value;
10810
+ }
10811
+ function encodeInteger(builder, num, relative) {
10795
10812
  let delta = num - relative;
10796
10813
  delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
10797
10814
  do {
@@ -10799,14 +10816,19 @@ function encodeInteger$1(builder, num, relative) {
10799
10816
  delta >>>= 5;
10800
10817
  if (delta > 0)
10801
10818
  clamped |= 0b100000;
10802
- builder.write(intToChar$1[clamped]);
10819
+ builder.write(intToChar[clamped]);
10803
10820
  } while (delta > 0);
10804
10821
  return num;
10805
10822
  }
10823
+ function hasMoreVlq(reader, max) {
10824
+ if (reader.pos >= max)
10825
+ return false;
10826
+ return reader.peek() !== comma;
10827
+ }
10806
10828
 
10807
10829
  const bufLength = 1024 * 16;
10808
10830
  // Provide a fallback for older environments.
10809
- const td$1 = typeof TextDecoder !== 'undefined'
10831
+ const td = typeof TextDecoder !== 'undefined'
10810
10832
  ? /* #__PURE__ */ new TextDecoder()
10811
10833
  : typeof Buffer !== 'undefined'
10812
10834
  ? {
@@ -10834,16 +10856,86 @@ class StringWriter {
10834
10856
  const { buffer } = this;
10835
10857
  buffer[this.pos++] = v;
10836
10858
  if (this.pos === bufLength) {
10837
- this.out += td$1.decode(buffer);
10859
+ this.out += td.decode(buffer);
10838
10860
  this.pos = 0;
10839
10861
  }
10840
10862
  }
10841
10863
  flush() {
10842
10864
  const { buffer, out, pos } = this;
10843
- return pos > 0 ? out + td$1.decode(buffer.subarray(0, pos)) : out;
10865
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
10844
10866
  }
10845
10867
  }
10846
- function encode$2(decoded) {
10868
+ class StringReader {
10869
+ constructor(buffer) {
10870
+ this.pos = 0;
10871
+ this.buffer = buffer;
10872
+ }
10873
+ next() {
10874
+ return this.buffer.charCodeAt(this.pos++);
10875
+ }
10876
+ peek() {
10877
+ return this.buffer.charCodeAt(this.pos);
10878
+ }
10879
+ indexOf(char) {
10880
+ const { buffer, pos } = this;
10881
+ const idx = buffer.indexOf(char, pos);
10882
+ return idx === -1 ? buffer.length : idx;
10883
+ }
10884
+ }
10885
+
10886
+ function decode(mappings) {
10887
+ const { length } = mappings;
10888
+ const reader = new StringReader(mappings);
10889
+ const decoded = [];
10890
+ let genColumn = 0;
10891
+ let sourcesIndex = 0;
10892
+ let sourceLine = 0;
10893
+ let sourceColumn = 0;
10894
+ let namesIndex = 0;
10895
+ do {
10896
+ const semi = reader.indexOf(';');
10897
+ const line = [];
10898
+ let sorted = true;
10899
+ let lastCol = 0;
10900
+ genColumn = 0;
10901
+ while (reader.pos < semi) {
10902
+ let seg;
10903
+ genColumn = decodeInteger(reader, genColumn);
10904
+ if (genColumn < lastCol)
10905
+ sorted = false;
10906
+ lastCol = genColumn;
10907
+ if (hasMoreVlq(reader, semi)) {
10908
+ sourcesIndex = decodeInteger(reader, sourcesIndex);
10909
+ sourceLine = decodeInteger(reader, sourceLine);
10910
+ sourceColumn = decodeInteger(reader, sourceColumn);
10911
+ if (hasMoreVlq(reader, semi)) {
10912
+ namesIndex = decodeInteger(reader, namesIndex);
10913
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
10914
+ }
10915
+ else {
10916
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
10917
+ }
10918
+ }
10919
+ else {
10920
+ seg = [genColumn];
10921
+ }
10922
+ line.push(seg);
10923
+ reader.pos++;
10924
+ }
10925
+ if (!sorted)
10926
+ sort(line);
10927
+ decoded.push(line);
10928
+ reader.pos = semi + 1;
10929
+ } while (reader.pos <= length);
10930
+ return decoded;
10931
+ }
10932
+ function sort(line) {
10933
+ line.sort(sortComparator$1);
10934
+ }
10935
+ function sortComparator$1(a, b) {
10936
+ return a[0] - b[0];
10937
+ }
10938
+ function encode$1(decoded) {
10847
10939
  const writer = new StringWriter();
10848
10940
  let sourcesIndex = 0;
10849
10941
  let sourceLine = 0;
@@ -10852,23 +10944,23 @@ function encode$2(decoded) {
10852
10944
  for (let i = 0; i < decoded.length; i++) {
10853
10945
  const line = decoded[i];
10854
10946
  if (i > 0)
10855
- writer.write(semicolon$1);
10947
+ writer.write(semicolon);
10856
10948
  if (line.length === 0)
10857
10949
  continue;
10858
10950
  let genColumn = 0;
10859
10951
  for (let j = 0; j < line.length; j++) {
10860
10952
  const segment = line[j];
10861
10953
  if (j > 0)
10862
- writer.write(comma$1);
10863
- genColumn = encodeInteger$1(writer, segment[0], genColumn);
10954
+ writer.write(comma);
10955
+ genColumn = encodeInteger(writer, segment[0], genColumn);
10864
10956
  if (segment.length === 1)
10865
10957
  continue;
10866
- sourcesIndex = encodeInteger$1(writer, segment[1], sourcesIndex);
10867
- sourceLine = encodeInteger$1(writer, segment[2], sourceLine);
10868
- sourceColumn = encodeInteger$1(writer, segment[3], sourceColumn);
10958
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
10959
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
10960
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
10869
10961
  if (segment.length === 4)
10870
10962
  continue;
10871
- namesIndex = encodeInteger$1(writer, segment[4], namesIndex);
10963
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
10872
10964
  }
10873
10965
  }
10874
10966
  return writer.flush();
@@ -11088,7 +11180,7 @@ let SourceMap$1 = class SourceMap {
11088
11180
  this.sources = properties.sources;
11089
11181
  this.sourcesContent = properties.sourcesContent;
11090
11182
  this.names = properties.names;
11091
- this.mappings = encode$2(properties.mappings);
11183
+ this.mappings = encode$1(properties.mappings);
11092
11184
  if (typeof properties.x_google_ignoreList !== 'undefined') {
11093
11185
  this.x_google_ignoreList = properties.x_google_ignoreList;
11094
11186
  }
@@ -14448,168 +14540,6 @@ function commonjs(options = {}) {
14448
14540
  };
14449
14541
  }
14450
14542
 
14451
- const comma = ','.charCodeAt(0);
14452
- const semicolon = ';'.charCodeAt(0);
14453
- const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
14454
- const intToChar = new Uint8Array(64); // 64 possible chars.
14455
- const charToInt = new Uint8Array(128); // z is 122 in ASCII
14456
- for (let i = 0; i < chars$1.length; i++) {
14457
- const c = chars$1.charCodeAt(i);
14458
- intToChar[i] = c;
14459
- charToInt[c] = i;
14460
- }
14461
- // Provide a fallback for older environments.
14462
- const td = typeof TextDecoder !== 'undefined'
14463
- ? /* #__PURE__ */ new TextDecoder()
14464
- : typeof Buffer !== 'undefined'
14465
- ? {
14466
- decode(buf) {
14467
- const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
14468
- return out.toString();
14469
- },
14470
- }
14471
- : {
14472
- decode(buf) {
14473
- let out = '';
14474
- for (let i = 0; i < buf.length; i++) {
14475
- out += String.fromCharCode(buf[i]);
14476
- }
14477
- return out;
14478
- },
14479
- };
14480
- function decode(mappings) {
14481
- const state = new Int32Array(5);
14482
- const decoded = [];
14483
- let index = 0;
14484
- do {
14485
- const semi = indexOf(mappings, index);
14486
- const line = [];
14487
- let sorted = true;
14488
- let lastCol = 0;
14489
- state[0] = 0;
14490
- for (let i = index; i < semi; i++) {
14491
- let seg;
14492
- i = decodeInteger(mappings, i, state, 0); // genColumn
14493
- const col = state[0];
14494
- if (col < lastCol)
14495
- sorted = false;
14496
- lastCol = col;
14497
- if (hasMoreVlq(mappings, i, semi)) {
14498
- i = decodeInteger(mappings, i, state, 1); // sourcesIndex
14499
- i = decodeInteger(mappings, i, state, 2); // sourceLine
14500
- i = decodeInteger(mappings, i, state, 3); // sourceColumn
14501
- if (hasMoreVlq(mappings, i, semi)) {
14502
- i = decodeInteger(mappings, i, state, 4); // namesIndex
14503
- seg = [col, state[1], state[2], state[3], state[4]];
14504
- }
14505
- else {
14506
- seg = [col, state[1], state[2], state[3]];
14507
- }
14508
- }
14509
- else {
14510
- seg = [col];
14511
- }
14512
- line.push(seg);
14513
- }
14514
- if (!sorted)
14515
- sort(line);
14516
- decoded.push(line);
14517
- index = semi + 1;
14518
- } while (index <= mappings.length);
14519
- return decoded;
14520
- }
14521
- function indexOf(mappings, index) {
14522
- const idx = mappings.indexOf(';', index);
14523
- return idx === -1 ? mappings.length : idx;
14524
- }
14525
- function decodeInteger(mappings, pos, state, j) {
14526
- let value = 0;
14527
- let shift = 0;
14528
- let integer = 0;
14529
- do {
14530
- const c = mappings.charCodeAt(pos++);
14531
- integer = charToInt[c];
14532
- value |= (integer & 31) << shift;
14533
- shift += 5;
14534
- } while (integer & 32);
14535
- const shouldNegate = value & 1;
14536
- value >>>= 1;
14537
- if (shouldNegate) {
14538
- value = -0x80000000 | -value;
14539
- }
14540
- state[j] += value;
14541
- return pos;
14542
- }
14543
- function hasMoreVlq(mappings, i, length) {
14544
- if (i >= length)
14545
- return false;
14546
- return mappings.charCodeAt(i) !== comma;
14547
- }
14548
- function sort(line) {
14549
- line.sort(sortComparator$1);
14550
- }
14551
- function sortComparator$1(a, b) {
14552
- return a[0] - b[0];
14553
- }
14554
- function encode$1(decoded) {
14555
- const state = new Int32Array(5);
14556
- const bufLength = 1024 * 16;
14557
- const subLength = bufLength - 36;
14558
- const buf = new Uint8Array(bufLength);
14559
- const sub = buf.subarray(0, subLength);
14560
- let pos = 0;
14561
- let out = '';
14562
- for (let i = 0; i < decoded.length; i++) {
14563
- const line = decoded[i];
14564
- if (i > 0) {
14565
- if (pos === bufLength) {
14566
- out += td.decode(buf);
14567
- pos = 0;
14568
- }
14569
- buf[pos++] = semicolon;
14570
- }
14571
- if (line.length === 0)
14572
- continue;
14573
- state[0] = 0;
14574
- for (let j = 0; j < line.length; j++) {
14575
- const segment = line[j];
14576
- // We can push up to 5 ints, each int can take at most 7 chars, and we
14577
- // may push a comma.
14578
- if (pos > subLength) {
14579
- out += td.decode(sub);
14580
- buf.copyWithin(0, subLength, pos);
14581
- pos -= subLength;
14582
- }
14583
- if (j > 0)
14584
- buf[pos++] = comma;
14585
- pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
14586
- if (segment.length === 1)
14587
- continue;
14588
- pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
14589
- pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
14590
- pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
14591
- if (segment.length === 4)
14592
- continue;
14593
- pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
14594
- }
14595
- }
14596
- return out + td.decode(buf.subarray(0, pos));
14597
- }
14598
- function encodeInteger(buf, pos, state, segment, j) {
14599
- const next = segment[j];
14600
- let num = next - state[j];
14601
- state[j] = next;
14602
- num = num < 0 ? (-num << 1) | 1 : num << 1;
14603
- do {
14604
- let clamped = num & 0b011111;
14605
- num >>>= 5;
14606
- if (num > 0)
14607
- clamped |= 0b100000;
14608
- buf[pos++] = intToChar[clamped];
14609
- } while (num > 0);
14610
- return pos;
14611
- }
14612
-
14613
14543
  // Matches the scheme of a URL, eg "http://"
14614
14544
  const schemeRegex = /^[\w+.-]+:\/\//;
14615
14545
  /**
@@ -20428,7 +20358,7 @@ function fileToDevUrl(id, config) {
20428
20358
  } else {
20429
20359
  rtn = path$n.posix.join(FS_PREFIX, id);
20430
20360
  }
20431
- const base = joinUrlSegments(config.server?.origin ?? "", config.base);
20361
+ const base = joinUrlSegments(config.server?.origin ?? "", config.decodedBase);
20432
20362
  return joinUrlSegments(base, removeLeadingSlash(rtn));
20433
20363
  }
20434
20364
  function getPublicAssetFilename(hash, config) {
@@ -20438,7 +20368,7 @@ const publicAssetUrlCache = /* @__PURE__ */ new WeakMap();
20438
20368
  const publicAssetUrlRE = /__VITE_PUBLIC_ASSET__([a-z\d]{8})__/g;
20439
20369
  function publicFileToBuiltUrl(url, config) {
20440
20370
  if (config.command !== "build") {
20441
- return joinUrlSegments(config.base, url);
20371
+ return joinUrlSegments(config.decodedBase, url);
20442
20372
  }
20443
20373
  const hash = getHash(url);
20444
20374
  let cache = publicAssetUrlCache.get(config);
@@ -27143,7 +27073,6 @@ class Collection extends NodeBase {
27143
27073
  }
27144
27074
  }
27145
27075
  }
27146
- Collection.maxFlowStringSingleLineLength = 60;
27147
27076
 
27148
27077
  /**
27149
27078
  * Stringifies a comment.
@@ -27175,6 +27104,8 @@ const FOLD_QUOTED = 'quoted';
27175
27104
  function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
27176
27105
  if (!lineWidth || lineWidth < 0)
27177
27106
  return text;
27107
+ if (lineWidth < minContentWidth)
27108
+ minContentWidth = 0;
27178
27109
  const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
27179
27110
  if (text.length <= endStep)
27180
27111
  return text;
@@ -29747,11 +29678,11 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
29747
29678
  let comment = '';
29748
29679
  let commentSep = '';
29749
29680
  let hasNewline = false;
29750
- let hasNewlineAfterProp = false;
29751
29681
  let reqSpace = false;
29752
29682
  let tab = null;
29753
29683
  let anchor = null;
29754
29684
  let tag = null;
29685
+ let newlineAfterProp = null;
29755
29686
  let comma = null;
29756
29687
  let found = null;
29757
29688
  let start = null;
@@ -29805,7 +29736,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
29805
29736
  atNewline = true;
29806
29737
  hasNewline = true;
29807
29738
  if (anchor || tag)
29808
- hasNewlineAfterProp = true;
29739
+ newlineAfterProp = token;
29809
29740
  hasSpace = true;
29810
29741
  break;
29811
29742
  case 'anchor':
@@ -29879,9 +29810,9 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
29879
29810
  spaceBefore,
29880
29811
  comment,
29881
29812
  hasNewline,
29882
- hasNewlineAfterProp,
29883
29813
  anchor,
29884
29814
  tag,
29815
+ newlineAfterProp,
29885
29816
  end,
29886
29817
  start: start ?? end
29887
29818
  };
@@ -29983,7 +29914,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
29983
29914
  }
29984
29915
  continue;
29985
29916
  }
29986
- if (keyProps.hasNewlineAfterProp || containsNewline(key)) {
29917
+ if (keyProps.newlineAfterProp || containsNewline(key)) {
29987
29918
  onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
29988
29919
  }
29989
29920
  }
@@ -30337,10 +30268,23 @@ function resolveCollection(CN, ctx, token, onError, tagName, tag) {
30337
30268
  coll.tag = tagName;
30338
30269
  return coll;
30339
30270
  }
30340
- function composeCollection(CN, ctx, token, tagToken, onError) {
30271
+ function composeCollection(CN, ctx, token, props, onError) {
30272
+ const tagToken = props.tag;
30341
30273
  const tagName = !tagToken
30342
30274
  ? null
30343
30275
  : ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg));
30276
+ if (token.type === 'block-seq') {
30277
+ const { anchor, newlineAfterProp: nl } = props;
30278
+ const lastProp = anchor && tagToken
30279
+ ? anchor.offset > tagToken.offset
30280
+ ? anchor
30281
+ : tagToken
30282
+ : (anchor ?? tagToken);
30283
+ if (lastProp && (!nl || nl.offset < lastProp.offset)) {
30284
+ const message = 'Missing newline after block sequence props';
30285
+ onError(lastProp, 'MISSING_CHAR', message);
30286
+ }
30287
+ }
30344
30288
  const expType = token.type === 'block-map'
30345
30289
  ? 'map'
30346
30290
  : token.type === 'block-seq'
@@ -30354,8 +30298,7 @@ function composeCollection(CN, ctx, token, tagToken, onError) {
30354
30298
  !tagName ||
30355
30299
  tagName === '!' ||
30356
30300
  (tagName === YAMLMap.tagName && expType === 'map') ||
30357
- (tagName === YAMLSeq.tagName && expType === 'seq') ||
30358
- !expType) {
30301
+ (tagName === YAMLSeq.tagName && expType === 'seq')) {
30359
30302
  return resolveCollection(CN, ctx, token, onError, tagName);
30360
30303
  }
30361
30304
  let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
@@ -30923,7 +30866,7 @@ function composeNode(ctx, token, props, onError) {
30923
30866
  case 'block-map':
30924
30867
  case 'block-seq':
30925
30868
  case 'flow-collection':
30926
- node = composeCollection(CN, ctx, token, tag, onError);
30869
+ node = composeCollection(CN, ctx, token, props, onError);
30927
30870
  if (anchor)
30928
30871
  node.anchor = anchor.source.substring(1);
30929
30872
  break;
@@ -31995,15 +31938,11 @@ class Lexer {
31995
31938
  if (!this.atEnd && !this.hasChars(4))
31996
31939
  return this.setNext('line-start');
31997
31940
  const s = this.peek(3);
31998
- if (s === '---' && isEmpty(this.charAt(3))) {
31941
+ if ((s === '---' || s === '...') && isEmpty(this.charAt(3))) {
31999
31942
  yield* this.pushCount(3);
32000
31943
  this.indentValue = 0;
32001
31944
  this.indentNext = 0;
32002
- return 'doc';
32003
- }
32004
- else if (s === '...' && isEmpty(this.charAt(3))) {
32005
- yield* this.pushCount(3);
32006
- return 'stream';
31945
+ return s === '---' ? 'doc' : 'stream';
32007
31946
  }
32008
31947
  }
32009
31948
  this.indentValue = yield* this.pushSpaces(false);
@@ -35215,7 +35154,7 @@ function buildHtmlPlugin(config) {
35215
35154
  async transform(html, id) {
35216
35155
  if (id.endsWith(".html")) {
35217
35156
  id = normalizePath$3(id);
35218
- const relativeUrlPath = path$n.posix.relative(config.root, id);
35157
+ const relativeUrlPath = normalizePath$3(path$n.relative(config.root, id));
35219
35158
  const publicPath = `/${relativeUrlPath}`;
35220
35159
  const publicBase = getBaseInHTML(relativeUrlPath, config);
35221
35160
  const publicToRelative = (filename, importer) => publicBase + filename;
@@ -35549,7 +35488,9 @@ ${js}`;
35549
35488
  return tags;
35550
35489
  };
35551
35490
  for (const [normalizedId, html] of processedHtml) {
35552
- const relativeUrlPath = path$n.posix.relative(config.root, normalizedId);
35491
+ const relativeUrlPath = normalizePath$3(
35492
+ path$n.relative(config.root, normalizedId)
35493
+ );
35553
35494
  const assetsBase = getBaseInHTML(relativeUrlPath, config);
35554
35495
  const toOutputFilePath = (filename, type) => {
35555
35496
  if (isExternalUrl(filename)) {
@@ -36346,7 +36287,9 @@ function cssPostPlugin(config) {
36346
36287
  const relative = config.base === "./" || config.base === "";
36347
36288
  const cssAssetDirname = encodedPublicUrls || relative ? slash$1(getCssAssetDirname(cssAssetName)) : void 0;
36348
36289
  const toRelative = (filename) => {
36349
- const relativePath = path$n.posix.relative(cssAssetDirname, filename);
36290
+ const relativePath = normalizePath$3(
36291
+ path$n.relative(cssAssetDirname, filename)
36292
+ );
36350
36293
  return relativePath[0] === "." ? relativePath : "./" + relativePath;
36351
36294
  };
36352
36295
  chunkCSS2 = chunkCSS2.replace(assetUrlRE, (_, fileHash, postfix = "") => {
@@ -36364,9 +36307,8 @@ function cssPostPlugin(config) {
36364
36307
  );
36365
36308
  });
36366
36309
  if (encodedPublicUrls) {
36367
- const relativePathToPublicFromCSS = path$n.posix.relative(
36368
- cssAssetDirname,
36369
- ""
36310
+ const relativePathToPublicFromCSS = normalizePath$3(
36311
+ path$n.relative(cssAssetDirname, "")
36370
36312
  );
36371
36313
  chunkCSS2 = chunkCSS2.replace(publicAssetUrlRE, (_, hash) => {
36372
36314
  const publicUrl = publicAssetUrlMap.get(hash).slice(1);
@@ -36988,8 +36930,8 @@ function createCachedImport(imp) {
36988
36930
  return cached;
36989
36931
  };
36990
36932
  }
36991
- const importPostcssImport = createCachedImport(() => import('./dep-C5hW-0CE.js').then(function (n) { return n.i; }));
36992
- const importPostcssModules = createCachedImport(() => import('./dep-AVIP6AlI.js').then(function (n) { return n.i; }));
36933
+ const importPostcssImport = createCachedImport(() => import('./dep-C3NStZH1.js').then(function (n) { return n.i; }));
36934
+ const importPostcssModules = createCachedImport(() => import('./dep-DvdjAuZF.js').then(function (n) { return n.i; }));
36993
36935
  const importPostcss = createCachedImport(() => import('postcss'));
36994
36936
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
36995
36937
  let alwaysFakeWorkerWorkerControllerCache;
@@ -37296,6 +37238,19 @@ ${e.message}`
37296
37238
  }
37297
37239
  }
37298
37240
  }
37241
+ function loadSassPackage(root) {
37242
+ try {
37243
+ const path2 = loadPreprocessorPath("sass-embedded", root);
37244
+ return { name: "sass-embedded", path: path2 };
37245
+ } catch (e1) {
37246
+ try {
37247
+ const path2 = loadPreprocessorPath("sass" /* sass */, root);
37248
+ return { name: "sass", path: path2 };
37249
+ } catch (e2) {
37250
+ throw e1;
37251
+ }
37252
+ }
37253
+ }
37299
37254
  let cachedSss;
37300
37255
  function loadSss(root) {
37301
37256
  if (cachedSss) return cachedSss;
@@ -37410,18 +37365,18 @@ const makeModernScssWorker = (resolvers, alias, maxWorkers) => {
37410
37365
  () => async (sassPath, data, options) => {
37411
37366
  const sass = require(sassPath);
37412
37367
  const path2 = require("node:path");
37413
- const { fileURLToPath, pathToFileURL } = (
37368
+ const { fileURLToPath: fileURLToPath2, pathToFileURL: pathToFileURL2 } = (
37414
37369
  // eslint-disable-next-line no-restricted-globals
37415
37370
  require("node:url")
37416
37371
  );
37417
37372
  const sassOptions = { ...options };
37418
- sassOptions.url = pathToFileURL(options.filename);
37373
+ sassOptions.url = pathToFileURL2(options.filename);
37419
37374
  sassOptions.sourceMap = options.enableSourcemap;
37420
37375
  const internalImporter = {
37421
37376
  async canonicalize(url, context) {
37422
- const importer = context.containingUrl ? fileURLToPath(context.containingUrl) : options.filename;
37377
+ const importer = context.containingUrl ? fileURLToPath2(context.containingUrl) : options.filename;
37423
37378
  const resolved = await internalCanonicalize(url, importer);
37424
- return resolved ? pathToFileURL(resolved) : null;
37379
+ return resolved ? pathToFileURL2(resolved) : null;
37425
37380
  },
37426
37381
  async load(canonicalUrl) {
37427
37382
  const ext = path2.extname(canonicalUrl.pathname);
@@ -37432,7 +37387,7 @@ const makeModernScssWorker = (resolvers, alias, maxWorkers) => {
37432
37387
  syntax = "css";
37433
37388
  }
37434
37389
  const contents = await internalLoad(
37435
- fileURLToPath(canonicalUrl),
37390
+ fileURLToPath2(canonicalUrl),
37436
37391
  options.filename
37437
37392
  );
37438
37393
  return { contents, syntax };
@@ -37447,7 +37402,7 @@ const makeModernScssWorker = (resolvers, alias, maxWorkers) => {
37447
37402
  css: result.css,
37448
37403
  map: result.sourceMap ? JSON.stringify(result.sourceMap) : void 0,
37449
37404
  stats: {
37450
- includedFiles: result.loadedUrls.filter((url) => url.protocol === "file:").map((url) => fileURLToPath(url))
37405
+ includedFiles: result.loadedUrls.filter((url) => url.protocol === "file:").map((url) => fileURLToPath2(url))
37451
37406
  }
37452
37407
  };
37453
37408
  },
@@ -37464,6 +37419,60 @@ const makeModernScssWorker = (resolvers, alias, maxWorkers) => {
37464
37419
  );
37465
37420
  return worker;
37466
37421
  };
37422
+ const makeModernCompilerScssWorker = (resolvers, alias, _maxWorkers) => {
37423
+ let compiler;
37424
+ const worker = {
37425
+ async run(sassPath, data, options) {
37426
+ const sass = (await import(pathToFileURL(sassPath).href)).default;
37427
+ compiler ??= await sass.initAsyncCompiler();
37428
+ const sassOptions = { ...options };
37429
+ sassOptions.url = pathToFileURL(options.filename);
37430
+ sassOptions.sourceMap = options.enableSourcemap;
37431
+ const internalImporter = {
37432
+ async canonicalize(url, context) {
37433
+ const importer = context.containingUrl ? fileURLToPath(context.containingUrl) : options.filename;
37434
+ const resolved = await resolvers.sass(url, cleanScssBugUrl(importer));
37435
+ return resolved ? pathToFileURL(resolved) : null;
37436
+ },
37437
+ async load(canonicalUrl) {
37438
+ const ext = path$n.extname(canonicalUrl.pathname);
37439
+ let syntax = "scss";
37440
+ if (ext === ".sass") {
37441
+ syntax = "indented";
37442
+ } else if (ext === ".css") {
37443
+ syntax = "css";
37444
+ }
37445
+ const result2 = await rebaseUrls(
37446
+ fileURLToPath(canonicalUrl),
37447
+ options.filename,
37448
+ alias,
37449
+ "$",
37450
+ resolvers.sass
37451
+ );
37452
+ const contents = result2.contents ?? await fsp.readFile(result2.file, "utf-8");
37453
+ return { contents, syntax };
37454
+ }
37455
+ };
37456
+ sassOptions.importers = [
37457
+ ...sassOptions.importers ?? [],
37458
+ internalImporter
37459
+ ];
37460
+ const result = await compiler.compileStringAsync(data, sassOptions);
37461
+ return {
37462
+ css: result.css,
37463
+ map: result.sourceMap ? JSON.stringify(result.sourceMap) : void 0,
37464
+ stats: {
37465
+ includedFiles: result.loadedUrls.filter((url) => url.protocol === "file:").map((url) => fileURLToPath(url))
37466
+ }
37467
+ };
37468
+ },
37469
+ async stop() {
37470
+ compiler?.dispose();
37471
+ compiler = void 0;
37472
+ }
37473
+ };
37474
+ return worker;
37475
+ };
37467
37476
  const scssProcessor = (maxWorkers) => {
37468
37477
  const workerMap = /* @__PURE__ */ new Map();
37469
37478
  return {
@@ -37473,11 +37482,12 @@ const scssProcessor = (maxWorkers) => {
37473
37482
  }
37474
37483
  },
37475
37484
  async process(source, root, options, resolvers) {
37476
- const sassPath = loadPreprocessorPath("sass" /* sass */, root);
37485
+ const sassPackage = loadSassPackage(root);
37486
+ const api = options.api ?? "legacy";
37477
37487
  if (!workerMap.has(options.alias)) {
37478
37488
  workerMap.set(
37479
37489
  options.alias,
37480
- options.api === "modern" ? makeModernScssWorker(resolvers, options.alias, maxWorkers) : makeScssWorker(resolvers, options.alias, maxWorkers)
37490
+ api === "modern-compiler" ? makeModernCompilerScssWorker(resolvers, options.alias) : api === "modern" ? makeModernScssWorker(resolvers, options.alias, maxWorkers) : makeScssWorker(resolvers, options.alias, maxWorkers)
37481
37491
  );
37482
37492
  }
37483
37493
  const worker = workerMap.get(options.alias);
@@ -37493,7 +37503,7 @@ const scssProcessor = (maxWorkers) => {
37493
37503
  };
37494
37504
  try {
37495
37505
  const result = await worker.run(
37496
- sassPath,
37506
+ sassPackage.path,
37497
37507
  data,
37498
37508
  optionsWithoutAdditionalData
37499
37509
  );
@@ -45341,8 +45351,8 @@ function launchEditor (file, specifiedEditor, onErrorCallback) {
45341
45351
  // and
45342
45352
  // https://github.com/facebook/create-react-app/pull/5431)
45343
45353
 
45344
- // Allows alphanumeric characters, periods, dashes, slashes, and underscores.
45345
- const WINDOWS_CMD_SAFE_FILE_NAME_PATTERN = /^([A-Za-z]:[/\\])?[\p{L}0-9/.\-_\\]+$/u;
45354
+ // Allows alphanumeric characters, periods, dashes, slashes, underscores, plus and space.
45355
+ const WINDOWS_CMD_SAFE_FILE_NAME_PATTERN = /^([A-Za-z]:[/\\])?[\p{L}0-9/.\-\\_+ ]+$/u;
45346
45356
  if (
45347
45357
  process.platform === 'win32' &&
45348
45358
  !WINDOWS_CMD_SAFE_FILE_NAME_PATTERN.test(fileName.trim())
@@ -45531,7 +45541,7 @@ const cachedFsUtilsMap = /* @__PURE__ */ new WeakMap();
45531
45541
  function getFsUtils(config) {
45532
45542
  let fsUtils = cachedFsUtilsMap.get(config);
45533
45543
  if (!fsUtils) {
45534
- if (config.command !== "serve" || config.server.fs.cachedChecks === false || config.server.watch?.ignored || process.versions.pnp) {
45544
+ if (config.command !== "serve" || config.server.fs.cachedChecks !== true || config.server.watch?.ignored || process.versions.pnp) {
45535
45545
  fsUtils = commonFsUtils;
45536
45546
  } else if (!config.resolve.preserveSymlinks && config.root !== getRealPath(config.root)) {
45537
45547
  fsUtils = commonFsUtils;
@@ -47642,7 +47652,7 @@ function webWorkerPlugin(config) {
47642
47652
  }
47643
47653
  if (injectEnv) {
47644
47654
  const s = new MagicString(raw);
47645
- s.prepend(injectEnv);
47655
+ s.prepend(injectEnv + ";\n");
47646
47656
  return {
47647
47657
  code: s.toString(),
47648
47658
  map: s.generateMap({ hires: "boundary" })
@@ -52274,42 +52284,49 @@ Contents of line ${line}: ${code.split("\n")[line - 1]}`
52274
52284
  Object.defineProperty(${ssrModuleExportsKey}, "${name}", { enumerable: true, configurable: true, get(){ return ${local} }});`
52275
52285
  );
52276
52286
  }
52287
+ const imports = [];
52288
+ const exports = [];
52277
52289
  for (const node of ast.body) {
52278
52290
  if (node.type === "ImportDeclaration") {
52279
- const importId = defineImport(hoistIndex, node.source.value, {
52280
- importedNames: node.specifiers.map((s2) => {
52281
- if (s2.type === "ImportSpecifier")
52282
- return s2.imported.type === "Identifier" ? s2.imported.name : (
52283
- // @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet
52284
- s2.imported.value
52285
- );
52286
- else if (s2.type === "ImportDefaultSpecifier") return "default";
52287
- }).filter(isDefined)
52288
- });
52289
- s.remove(node.start, node.end);
52290
- for (const spec of node.specifiers) {
52291
- if (spec.type === "ImportSpecifier") {
52292
- if (spec.imported.type === "Identifier") {
52293
- idToImportMap.set(
52294
- spec.local.name,
52295
- `${importId}.${spec.imported.name}`
52296
- );
52297
- } else {
52298
- idToImportMap.set(
52299
- spec.local.name,
52300
- `${importId}[${// @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet
52301
- JSON.stringify(spec.imported.value)}]`
52302
- );
52303
- }
52304
- } else if (spec.type === "ImportDefaultSpecifier") {
52305
- idToImportMap.set(spec.local.name, `${importId}.default`);
52291
+ imports.push(node);
52292
+ } else if (node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportAllDeclaration") {
52293
+ exports.push(node);
52294
+ }
52295
+ }
52296
+ for (const node of imports) {
52297
+ const importId = defineImport(hoistIndex, node.source.value, {
52298
+ importedNames: node.specifiers.map((s2) => {
52299
+ if (s2.type === "ImportSpecifier")
52300
+ return s2.imported.type === "Identifier" ? s2.imported.name : (
52301
+ // @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet
52302
+ s2.imported.value
52303
+ );
52304
+ else if (s2.type === "ImportDefaultSpecifier") return "default";
52305
+ }).filter(isDefined)
52306
+ });
52307
+ s.remove(node.start, node.end);
52308
+ for (const spec of node.specifiers) {
52309
+ if (spec.type === "ImportSpecifier") {
52310
+ if (spec.imported.type === "Identifier") {
52311
+ idToImportMap.set(
52312
+ spec.local.name,
52313
+ `${importId}.${spec.imported.name}`
52314
+ );
52306
52315
  } else {
52307
- idToImportMap.set(spec.local.name, importId);
52316
+ idToImportMap.set(
52317
+ spec.local.name,
52318
+ `${importId}[${// @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet
52319
+ JSON.stringify(spec.imported.value)}]`
52320
+ );
52308
52321
  }
52322
+ } else if (spec.type === "ImportDefaultSpecifier") {
52323
+ idToImportMap.set(spec.local.name, `${importId}.default`);
52324
+ } else {
52325
+ idToImportMap.set(spec.local.name, importId);
52309
52326
  }
52310
52327
  }
52311
52328
  }
52312
- for (const node of ast.body) {
52329
+ for (const node of exports) {
52313
52330
  if (node.type === "ExportNamedDeclaration") {
52314
52331
  if (node.declaration) {
52315
52332
  if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
@@ -52703,13 +52720,13 @@ function ssrFixStacktrace(e, moduleGraph) {
52703
52720
  const pendingModules = /* @__PURE__ */ new Map();
52704
52721
  const pendingModuleDependencyGraph = /* @__PURE__ */ new Map();
52705
52722
  const importErrors = /* @__PURE__ */ new WeakMap();
52706
- async function ssrLoadModule(url, server, context = { global }, fixStacktrace) {
52723
+ async function ssrLoadModule(url, server, fixStacktrace) {
52707
52724
  url = unwrapId$1(url);
52708
52725
  const pending = pendingModules.get(url);
52709
52726
  if (pending) {
52710
52727
  return pending;
52711
52728
  }
52712
- const modulePromise = instantiateModule(url, server, context, fixStacktrace);
52729
+ const modulePromise = instantiateModule(url, server, fixStacktrace);
52713
52730
  pendingModules.set(url, modulePromise);
52714
52731
  modulePromise.catch(() => {
52715
52732
  }).finally(() => {
@@ -52717,7 +52734,7 @@ async function ssrLoadModule(url, server, context = { global }, fixStacktrace) {
52717
52734
  });
52718
52735
  return modulePromise;
52719
52736
  }
52720
- async function instantiateModule(url, server, context = { global }, fixStacktrace) {
52737
+ async function instantiateModule(url, server, fixStacktrace) {
52721
52738
  const { moduleGraph } = server;
52722
52739
  const mod = await moduleGraph.ensureEntryFromUrl(url, true);
52723
52740
  if (mod.ssrError) {
@@ -52781,7 +52798,7 @@ async function instantiateModule(url, server, context = { global }, fixStacktrac
52781
52798
  return depSsrModule;
52782
52799
  }
52783
52800
  }
52784
- return ssrLoadModule(dep, server, context, fixStacktrace);
52801
+ return ssrLoadModule(dep, server, fixStacktrace);
52785
52802
  } catch (err) {
52786
52803
  importErrors.set(err, { importee: dep });
52787
52804
  throw err;
@@ -52816,7 +52833,6 @@ async function instantiateModule(url, server, context = { global }, fixStacktrac
52816
52833
  }
52817
52834
  try {
52818
52835
  const initModule = new AsyncFunction(
52819
- `global`,
52820
52836
  ssrModuleExportsKey,
52821
52837
  ssrImportMetaKey,
52822
52838
  ssrImportKey,
@@ -52826,7 +52842,6 @@ async function instantiateModule(url, server, context = { global }, fixStacktrac
52826
52842
  //# sourceURL=${mod.id}${sourceMapSuffix}`
52827
52843
  );
52828
52844
  await initModule(
52829
- context.global,
52830
52845
  ssrModule,
52831
52846
  ssrImportMeta,
52832
52847
  ssrImport,
@@ -61890,7 +61905,12 @@ const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, s
61890
61905
  );
61891
61906
  }
61892
61907
  if (preTransformUrl) {
61893
- preTransformRequest(server, preTransformUrl, config.base);
61908
+ try {
61909
+ preTransformUrl = decodeURI(preTransformUrl);
61910
+ } catch (err) {
61911
+ return url2;
61912
+ }
61913
+ preTransformRequest(server, preTransformUrl, config.decodedBase);
61894
61914
  }
61895
61915
  }
61896
61916
  return url2;
@@ -61901,6 +61921,7 @@ const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, s
61901
61921
  const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl }) => {
61902
61922
  const { config, moduleGraph, watcher } = server;
61903
61923
  const base = config.base || "/";
61924
+ const decodedBase = config.decodedBase || "/";
61904
61925
  let proxyModulePath;
61905
61926
  let proxyModuleUrl;
61906
61927
  const trailingSlash = htmlPath.endsWith("/");
@@ -61912,7 +61933,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
61912
61933
  proxyModulePath = `\0${validPath}`;
61913
61934
  proxyModuleUrl = wrapId$1(proxyModulePath);
61914
61935
  }
61915
- proxyModuleUrl = joinUrlSegments(base, proxyModuleUrl);
61936
+ proxyModuleUrl = joinUrlSegments(decodedBase, proxyModuleUrl);
61916
61937
  const s = new MagicString(html);
61917
61938
  let inlineModuleIndex = -1;
61918
61939
  const proxyCacheUrl = decodeURI(
@@ -61944,7 +61965,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
61944
61965
  node.sourceCodeLocation.endOffset,
61945
61966
  `<script type="module" src="${modulePath}"><\/script>`
61946
61967
  );
61947
- preTransformRequest(server, modulePath, base);
61968
+ preTransformRequest(server, modulePath, decodedBase);
61948
61969
  };
61949
61970
  await traverseHtml(html, filename, (node) => {
61950
61971
  if (!nodeIsElement(node)) {
@@ -62106,14 +62127,10 @@ function indexHtmlMiddleware(root, server) {
62106
62127
  next();
62107
62128
  };
62108
62129
  }
62109
- function preTransformRequest(server, url, base) {
62130
+ function preTransformRequest(server, decodedUrl, decodedBase) {
62110
62131
  if (!server.config.server.preTransformRequests) return;
62111
- try {
62112
- url = unwrapId$1(stripBase(decodeURI(url), base));
62113
- } catch {
62114
- return;
62115
- }
62116
- server.warmupRequest(url);
62132
+ decodedUrl = unwrapId$1(stripBase(decodedUrl, decodedBase));
62133
+ server.warmupRequest(decodedUrl);
62117
62134
  }
62118
62135
 
62119
62136
  const logTime = createDebugger("vite:time");
@@ -62709,7 +62726,7 @@ async function _createServer(inlineConfig = {}, options) {
62709
62726
  return devHtmlTransformFn(server, url, html, originalUrl);
62710
62727
  },
62711
62728
  async ssrLoadModule(url, opts) {
62712
- return ssrLoadModule(url, server, void 0, opts?.fixStacktrace);
62729
+ return ssrLoadModule(url, server, opts?.fixStacktrace);
62713
62730
  },
62714
62731
  async ssrFetchModule(url, importer) {
62715
62732
  return ssrFetchModule(server, url, importer);
@@ -65616,7 +65633,7 @@ function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelati
65616
65633
  if (relative && !config.build.ssr) {
65617
65634
  return toRelative(filename, hostId);
65618
65635
  }
65619
- return joinUrlSegments(config.base, filename);
65636
+ return joinUrlSegments(config.decodedBase, filename);
65620
65637
  }
65621
65638
  function createToImportMetaURLBasedRelativeRuntime(format, isWorker) {
65622
65639
  const formatLong = isWorker && format === "iife" ? "worker-iife" : format;
@@ -65653,7 +65670,7 @@ function toOutputFilePathWithoutRuntime(filename, type, hostId, hostType, config
65653
65670
  if (relative && !config.build.ssr) {
65654
65671
  return toRelative(filename, hostId);
65655
65672
  } else {
65656
- return joinUrlSegments(config.base, filename);
65673
+ return joinUrlSegments(config.decodedBase, filename);
65657
65674
  }
65658
65675
  }
65659
65676
  const toOutputFilePathInCss = toOutputFilePathWithoutRuntime;
@@ -66185,6 +66202,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
66185
66202
  plugins: createWorkerPlugins,
66186
66203
  rollupOptions: config.worker?.rollupOptions || {}
66187
66204
  };
66205
+ const base = withTrailingSlash(resolvedBase);
66188
66206
  resolved = {
66189
66207
  configFile: configFile ? normalizePath$3(configFile) : void 0,
66190
66208
  configFileDependencies: configFileDependencies.map(
@@ -66192,7 +66210,8 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
66192
66210
  ),
66193
66211
  inlineConfig,
66194
66212
  root: resolvedRoot,
66195
- base: withTrailingSlash(resolvedBase),
66213
+ base,
66214
+ decodedBase: decodeURI(base),
66196
66215
  rawBase: resolvedBase,
66197
66216
  resolve: resolveOptions,
66198
66217
  publicDir: resolvedPublicDir,