vitest 0.0.103 → 0.0.107

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 { c, g as getNames, s as slash$1, a as getTests, i as isAbsolute, r as relative, d as dirname, b as basename, f as getSuites, h as resolve, n as noop$1, t as toArray, j as hasFailed } from './utils-c8e62373.js';
1
+ import { c, g as getNames, d as slash$1, h as getTests, i as isAbsolute, r as relative, j as dirname, k as basename, l as getSuites, m as resolve, n as noop$1, t as toArray, o as hasFailed } from './utils-92ec89d1.js';
2
2
  import { createServer, mergeConfig } from 'vite';
3
3
  import path$a from 'path';
4
4
  import process$1 from 'process';
@@ -7,10 +7,10 @@ import require$$0 from 'os';
7
7
  import require$$0$1 from 'util';
8
8
  import require$$0$2 from 'stream';
9
9
  import require$$2 from 'events';
10
- import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-a1417084.js';
10
+ import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-82dad049.js';
11
11
  import { performance } from 'perf_hooks';
12
- import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, F as F_POINTER, d as F_DOWN, e as F_LONG_DASH, f as F_DOWN_RIGHT, g as F_DOT, h as F_CHECK, i as F_CROSS, j as cliTruncate, k as F_RIGHT, p as printError } from './error-0e2f75a4.js';
13
- import { o as onetime, s as signalExit } from './index-825cb54c.js';
12
+ import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, F as F_POINTER, d as F_DOWN, e as F_LONG_DASH, f as F_DOWN_RIGHT, g as F_DOT, h as F_CHECK, i as F_CROSS, j as cliTruncate, k as F_RIGHT, p as printError } from './error-e81aa23d.js';
13
+ import { o as onetime, s as signalExit } from './index-84978a77.js';
14
14
  import { MessageChannel } from 'worker_threads';
15
15
  import { pathToFileURL } from 'url';
16
16
  import { Tinypool } from 'tinypool';
@@ -411,7 +411,7 @@ var isExtglob$1 = function isExtglob(str) {
411
411
  */
412
412
 
413
413
  var isExtglob = isExtglob$1;
414
- var chars = { '{': '}', '(': ')', '[': ']'};
414
+ var chars$1 = { '{': '}', '(': ')', '[': ']'};
415
415
  var strictCheck = function(str) {
416
416
  if (str[0] === '!') {
417
417
  return true;
@@ -484,7 +484,7 @@ var strictCheck = function(str) {
484
484
  if (str[index] === '\\') {
485
485
  var open = str[index + 1];
486
486
  index += 2;
487
- var close = chars[open];
487
+ var close = chars$1[open];
488
488
 
489
489
  if (close) {
490
490
  var n = str.indexOf(close, index);
@@ -516,7 +516,7 @@ var relaxedCheck = function(str) {
516
516
  if (str[index] === '\\') {
517
517
  var open = str[index + 1];
518
518
  index += 2;
519
- var close = chars[open];
519
+ var close = chars$1[open];
520
520
 
521
521
  if (close) {
522
522
  var n = str.indexOf(close, index);
@@ -1055,7 +1055,7 @@ var toRegexRange_1 = toRegexRange$1;
1055
1055
  const util$1 = require$$0$1;
1056
1056
  const toRegexRange = toRegexRange_1;
1057
1057
 
1058
- const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
1058
+ const isObject$2 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
1059
1059
 
1060
1060
  const transform = toNumber => {
1061
1061
  return value => toNumber === true ? Number(value) : String(value);
@@ -1271,7 +1271,7 @@ const fill$2 = (start, end, step, options = {}) => {
1271
1271
  return fill$2(start, end, 1, { transform: step });
1272
1272
  }
1273
1273
 
1274
- if (isObject$1(step)) {
1274
+ if (isObject$2(step)) {
1275
1275
  return fill$2(start, end, 0, step);
1276
1276
  }
1277
1277
 
@@ -1280,7 +1280,7 @@ const fill$2 = (start, end, step, options = {}) => {
1280
1280
  step = step || opts.step || 1;
1281
1281
 
1282
1282
  if (!isNumber(step)) {
1283
- if (step != null && !isObject$1(step)) return invalidStep(step, opts);
1283
+ if (step != null && !isObject$2(step)) return invalidStep(step, opts);
1284
1284
  return fill$2(start, end, 1, step);
1285
1285
  }
1286
1286
 
@@ -3739,7 +3739,7 @@ const scan = scan_1;
3739
3739
  const parse = parse_1;
3740
3740
  const utils$c = utils$f;
3741
3741
  const constants$1 = constants$3;
3742
- const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
3742
+ const isObject$1 = val => val && typeof val === 'object' && !Array.isArray(val);
3743
3743
 
3744
3744
  /**
3745
3745
  * Creates a matcher function from one or more glob patterns. The
@@ -3776,7 +3776,7 @@ const picomatch$2 = (glob, options, returnState = false) => {
3776
3776
  return arrayMatcher;
3777
3777
  }
3778
3778
 
3779
- const isState = isObject(glob) && glob.tokens && glob.input;
3779
+ const isState = isObject$1(glob) && glob.tokens && glob.input;
3780
3780
 
3781
3781
  if (glob === '' || (typeof glob !== 'string' && !isState)) {
3782
3782
  throw new TypeError('Expected pattern to be a non-empty string');
@@ -7568,6 +7568,1120 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
7568
7568
  }
7569
7569
  }
7570
7570
 
7571
+ var charToInteger = {};
7572
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
7573
+ for (var i = 0; i < chars.length; i++) {
7574
+ charToInteger[chars.charCodeAt(i)] = i;
7575
+ }
7576
+ function encode(decoded) {
7577
+ var sourceFileIndex = 0; // second field
7578
+ var sourceCodeLine = 0; // third field
7579
+ var sourceCodeColumn = 0; // fourth field
7580
+ var nameIndex = 0; // fifth field
7581
+ var mappings = '';
7582
+ for (var i = 0; i < decoded.length; i++) {
7583
+ var line = decoded[i];
7584
+ if (i > 0)
7585
+ mappings += ';';
7586
+ if (line.length === 0)
7587
+ continue;
7588
+ var generatedCodeColumn = 0; // first field
7589
+ var lineMappings = [];
7590
+ for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {
7591
+ var segment = line_1[_i];
7592
+ var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);
7593
+ generatedCodeColumn = segment[0];
7594
+ if (segment.length > 1) {
7595
+ segmentMappings +=
7596
+ encodeInteger(segment[1] - sourceFileIndex) +
7597
+ encodeInteger(segment[2] - sourceCodeLine) +
7598
+ encodeInteger(segment[3] - sourceCodeColumn);
7599
+ sourceFileIndex = segment[1];
7600
+ sourceCodeLine = segment[2];
7601
+ sourceCodeColumn = segment[3];
7602
+ }
7603
+ if (segment.length === 5) {
7604
+ segmentMappings += encodeInteger(segment[4] - nameIndex);
7605
+ nameIndex = segment[4];
7606
+ }
7607
+ lineMappings.push(segmentMappings);
7608
+ }
7609
+ mappings += lineMappings.join(',');
7610
+ }
7611
+ return mappings;
7612
+ }
7613
+ function encodeInteger(num) {
7614
+ var result = '';
7615
+ num = num < 0 ? (-num << 1) | 1 : num << 1;
7616
+ do {
7617
+ var clamped = num & 31;
7618
+ num >>>= 5;
7619
+ if (num > 0) {
7620
+ clamped |= 32;
7621
+ }
7622
+ result += chars[clamped];
7623
+ } while (num > 0);
7624
+ return result;
7625
+ }
7626
+
7627
+ var BitSet = function BitSet(arg) {
7628
+ this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
7629
+ };
7630
+
7631
+ BitSet.prototype.add = function add (n) {
7632
+ this.bits[n >> 5] |= 1 << (n & 31);
7633
+ };
7634
+
7635
+ BitSet.prototype.has = function has (n) {
7636
+ return !!(this.bits[n >> 5] & (1 << (n & 31)));
7637
+ };
7638
+
7639
+ var Chunk = function Chunk(start, end, content) {
7640
+ this.start = start;
7641
+ this.end = end;
7642
+ this.original = content;
7643
+
7644
+ this.intro = '';
7645
+ this.outro = '';
7646
+
7647
+ this.content = content;
7648
+ this.storeName = false;
7649
+ this.edited = false;
7650
+
7651
+ // we make these non-enumerable, for sanity while debugging
7652
+ Object.defineProperties(this, {
7653
+ previous: { writable: true, value: null },
7654
+ next: { writable: true, value: null }
7655
+ });
7656
+ };
7657
+
7658
+ Chunk.prototype.appendLeft = function appendLeft (content) {
7659
+ this.outro += content;
7660
+ };
7661
+
7662
+ Chunk.prototype.appendRight = function appendRight (content) {
7663
+ this.intro = this.intro + content;
7664
+ };
7665
+
7666
+ Chunk.prototype.clone = function clone () {
7667
+ var chunk = new Chunk(this.start, this.end, this.original);
7668
+
7669
+ chunk.intro = this.intro;
7670
+ chunk.outro = this.outro;
7671
+ chunk.content = this.content;
7672
+ chunk.storeName = this.storeName;
7673
+ chunk.edited = this.edited;
7674
+
7675
+ return chunk;
7676
+ };
7677
+
7678
+ Chunk.prototype.contains = function contains (index) {
7679
+ return this.start < index && index < this.end;
7680
+ };
7681
+
7682
+ Chunk.prototype.eachNext = function eachNext (fn) {
7683
+ var chunk = this;
7684
+ while (chunk) {
7685
+ fn(chunk);
7686
+ chunk = chunk.next;
7687
+ }
7688
+ };
7689
+
7690
+ Chunk.prototype.eachPrevious = function eachPrevious (fn) {
7691
+ var chunk = this;
7692
+ while (chunk) {
7693
+ fn(chunk);
7694
+ chunk = chunk.previous;
7695
+ }
7696
+ };
7697
+
7698
+ Chunk.prototype.edit = function edit (content, storeName, contentOnly) {
7699
+ this.content = content;
7700
+ if (!contentOnly) {
7701
+ this.intro = '';
7702
+ this.outro = '';
7703
+ }
7704
+ this.storeName = storeName;
7705
+
7706
+ this.edited = true;
7707
+
7708
+ return this;
7709
+ };
7710
+
7711
+ Chunk.prototype.prependLeft = function prependLeft (content) {
7712
+ this.outro = content + this.outro;
7713
+ };
7714
+
7715
+ Chunk.prototype.prependRight = function prependRight (content) {
7716
+ this.intro = content + this.intro;
7717
+ };
7718
+
7719
+ Chunk.prototype.split = function split (index) {
7720
+ var sliceIndex = index - this.start;
7721
+
7722
+ var originalBefore = this.original.slice(0, sliceIndex);
7723
+ var originalAfter = this.original.slice(sliceIndex);
7724
+
7725
+ this.original = originalBefore;
7726
+
7727
+ var newChunk = new Chunk(index, this.end, originalAfter);
7728
+ newChunk.outro = this.outro;
7729
+ this.outro = '';
7730
+
7731
+ this.end = index;
7732
+
7733
+ if (this.edited) {
7734
+ // TODO is this block necessary?...
7735
+ newChunk.edit('', false);
7736
+ this.content = '';
7737
+ } else {
7738
+ this.content = originalBefore;
7739
+ }
7740
+
7741
+ newChunk.next = this.next;
7742
+ if (newChunk.next) { newChunk.next.previous = newChunk; }
7743
+ newChunk.previous = this;
7744
+ this.next = newChunk;
7745
+
7746
+ return newChunk;
7747
+ };
7748
+
7749
+ Chunk.prototype.toString = function toString () {
7750
+ return this.intro + this.content + this.outro;
7751
+ };
7752
+
7753
+ Chunk.prototype.trimEnd = function trimEnd (rx) {
7754
+ this.outro = this.outro.replace(rx, '');
7755
+ if (this.outro.length) { return true; }
7756
+
7757
+ var trimmed = this.content.replace(rx, '');
7758
+
7759
+ if (trimmed.length) {
7760
+ if (trimmed !== this.content) {
7761
+ this.split(this.start + trimmed.length).edit('', undefined, true);
7762
+ }
7763
+ return true;
7764
+
7765
+ } else {
7766
+ this.edit('', undefined, true);
7767
+
7768
+ this.intro = this.intro.replace(rx, '');
7769
+ if (this.intro.length) { return true; }
7770
+ }
7771
+ };
7772
+
7773
+ Chunk.prototype.trimStart = function trimStart (rx) {
7774
+ this.intro = this.intro.replace(rx, '');
7775
+ if (this.intro.length) { return true; }
7776
+
7777
+ var trimmed = this.content.replace(rx, '');
7778
+
7779
+ if (trimmed.length) {
7780
+ if (trimmed !== this.content) {
7781
+ this.split(this.end - trimmed.length);
7782
+ this.edit('', undefined, true);
7783
+ }
7784
+ return true;
7785
+
7786
+ } else {
7787
+ this.edit('', undefined, true);
7788
+
7789
+ this.outro = this.outro.replace(rx, '');
7790
+ if (this.outro.length) { return true; }
7791
+ }
7792
+ };
7793
+
7794
+ var btoa = function () {
7795
+ throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
7796
+ };
7797
+ if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
7798
+ btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
7799
+ } else if (typeof Buffer === 'function') {
7800
+ btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
7801
+ }
7802
+
7803
+ var SourceMap = function SourceMap(properties) {
7804
+ this.version = 3;
7805
+ this.file = properties.file;
7806
+ this.sources = properties.sources;
7807
+ this.sourcesContent = properties.sourcesContent;
7808
+ this.names = properties.names;
7809
+ this.mappings = encode(properties.mappings);
7810
+ };
7811
+
7812
+ SourceMap.prototype.toString = function toString () {
7813
+ return JSON.stringify(this);
7814
+ };
7815
+
7816
+ SourceMap.prototype.toUrl = function toUrl () {
7817
+ return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
7818
+ };
7819
+
7820
+ function guessIndent(code) {
7821
+ var lines = code.split('\n');
7822
+
7823
+ var tabbed = lines.filter(function (line) { return /^\t+/.test(line); });
7824
+ var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); });
7825
+
7826
+ if (tabbed.length === 0 && spaced.length === 0) {
7827
+ return null;
7828
+ }
7829
+
7830
+ // More lines tabbed than spaced? Assume tabs, and
7831
+ // default to tabs in the case of a tie (or nothing
7832
+ // to go on)
7833
+ if (tabbed.length >= spaced.length) {
7834
+ return '\t';
7835
+ }
7836
+
7837
+ // Otherwise, we need to guess the multiple
7838
+ var min = spaced.reduce(function (previous, current) {
7839
+ var numSpaces = /^ +/.exec(current)[0].length;
7840
+ return Math.min(numSpaces, previous);
7841
+ }, Infinity);
7842
+
7843
+ return new Array(min + 1).join(' ');
7844
+ }
7845
+
7846
+ function getRelativePath(from, to) {
7847
+ var fromParts = from.split(/[/\\]/);
7848
+ var toParts = to.split(/[/\\]/);
7849
+
7850
+ fromParts.pop(); // get dirname
7851
+
7852
+ while (fromParts[0] === toParts[0]) {
7853
+ fromParts.shift();
7854
+ toParts.shift();
7855
+ }
7856
+
7857
+ if (fromParts.length) {
7858
+ var i = fromParts.length;
7859
+ while (i--) { fromParts[i] = '..'; }
7860
+ }
7861
+
7862
+ return fromParts.concat(toParts).join('/');
7863
+ }
7864
+
7865
+ var toString = Object.prototype.toString;
7866
+
7867
+ function isObject(thing) {
7868
+ return toString.call(thing) === '[object Object]';
7869
+ }
7870
+
7871
+ function getLocator(source) {
7872
+ var originalLines = source.split('\n');
7873
+ var lineOffsets = [];
7874
+
7875
+ for (var i = 0, pos = 0; i < originalLines.length; i++) {
7876
+ lineOffsets.push(pos);
7877
+ pos += originalLines[i].length + 1;
7878
+ }
7879
+
7880
+ return function locate(index) {
7881
+ var i = 0;
7882
+ var j = lineOffsets.length;
7883
+ while (i < j) {
7884
+ var m = (i + j) >> 1;
7885
+ if (index < lineOffsets[m]) {
7886
+ j = m;
7887
+ } else {
7888
+ i = m + 1;
7889
+ }
7890
+ }
7891
+ var line = i - 1;
7892
+ var column = index - lineOffsets[line];
7893
+ return { line: line, column: column };
7894
+ };
7895
+ }
7896
+
7897
+ var Mappings = function Mappings(hires) {
7898
+ this.hires = hires;
7899
+ this.generatedCodeLine = 0;
7900
+ this.generatedCodeColumn = 0;
7901
+ this.raw = [];
7902
+ this.rawSegments = this.raw[this.generatedCodeLine] = [];
7903
+ this.pending = null;
7904
+ };
7905
+
7906
+ Mappings.prototype.addEdit = function addEdit (sourceIndex, content, loc, nameIndex) {
7907
+ if (content.length) {
7908
+ var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
7909
+ if (nameIndex >= 0) {
7910
+ segment.push(nameIndex);
7911
+ }
7912
+ this.rawSegments.push(segment);
7913
+ } else if (this.pending) {
7914
+ this.rawSegments.push(this.pending);
7915
+ }
7916
+
7917
+ this.advance(content);
7918
+ this.pending = null;
7919
+ };
7920
+
7921
+ Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) {
7922
+ var originalCharIndex = chunk.start;
7923
+ var first = true;
7924
+
7925
+ while (originalCharIndex < chunk.end) {
7926
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
7927
+ this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
7928
+ }
7929
+
7930
+ if (original[originalCharIndex] === '\n') {
7931
+ loc.line += 1;
7932
+ loc.column = 0;
7933
+ this.generatedCodeLine += 1;
7934
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
7935
+ this.generatedCodeColumn = 0;
7936
+ first = true;
7937
+ } else {
7938
+ loc.column += 1;
7939
+ this.generatedCodeColumn += 1;
7940
+ first = false;
7941
+ }
7942
+
7943
+ originalCharIndex += 1;
7944
+ }
7945
+
7946
+ this.pending = null;
7947
+ };
7948
+
7949
+ Mappings.prototype.advance = function advance (str) {
7950
+ if (!str) { return; }
7951
+
7952
+ var lines = str.split('\n');
7953
+
7954
+ if (lines.length > 1) {
7955
+ for (var i = 0; i < lines.length - 1; i++) {
7956
+ this.generatedCodeLine++;
7957
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
7958
+ }
7959
+ this.generatedCodeColumn = 0;
7960
+ }
7961
+
7962
+ this.generatedCodeColumn += lines[lines.length - 1].length;
7963
+ };
7964
+
7965
+ var n = '\n';
7966
+
7967
+ var warned = {
7968
+ insertLeft: false,
7969
+ insertRight: false,
7970
+ storeName: false
7971
+ };
7972
+
7973
+ var MagicString = function MagicString(string, options) {
7974
+ if ( options === void 0 ) options = {};
7975
+
7976
+ var chunk = new Chunk(0, string.length, string);
7977
+
7978
+ Object.defineProperties(this, {
7979
+ original: { writable: true, value: string },
7980
+ outro: { writable: true, value: '' },
7981
+ intro: { writable: true, value: '' },
7982
+ firstChunk: { writable: true, value: chunk },
7983
+ lastChunk: { writable: true, value: chunk },
7984
+ lastSearchedChunk: { writable: true, value: chunk },
7985
+ byStart: { writable: true, value: {} },
7986
+ byEnd: { writable: true, value: {} },
7987
+ filename: { writable: true, value: options.filename },
7988
+ indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
7989
+ sourcemapLocations: { writable: true, value: new BitSet() },
7990
+ storedNames: { writable: true, value: {} },
7991
+ indentStr: { writable: true, value: guessIndent(string) }
7992
+ });
7993
+
7994
+ this.byStart[0] = chunk;
7995
+ this.byEnd[string.length] = chunk;
7996
+ };
7997
+
7998
+ MagicString.prototype.addSourcemapLocation = function addSourcemapLocation (char) {
7999
+ this.sourcemapLocations.add(char);
8000
+ };
8001
+
8002
+ MagicString.prototype.append = function append (content) {
8003
+ if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
8004
+
8005
+ this.outro += content;
8006
+ return this;
8007
+ };
8008
+
8009
+ MagicString.prototype.appendLeft = function appendLeft (index, content) {
8010
+ if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
8011
+
8012
+ this._split(index);
8013
+
8014
+ var chunk = this.byEnd[index];
8015
+
8016
+ if (chunk) {
8017
+ chunk.appendLeft(content);
8018
+ } else {
8019
+ this.intro += content;
8020
+ }
8021
+ return this;
8022
+ };
8023
+
8024
+ MagicString.prototype.appendRight = function appendRight (index, content) {
8025
+ if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
8026
+
8027
+ this._split(index);
8028
+
8029
+ var chunk = this.byStart[index];
8030
+
8031
+ if (chunk) {
8032
+ chunk.appendRight(content);
8033
+ } else {
8034
+ this.outro += content;
8035
+ }
8036
+ return this;
8037
+ };
8038
+
8039
+ MagicString.prototype.clone = function clone () {
8040
+ var cloned = new MagicString(this.original, { filename: this.filename });
8041
+
8042
+ var originalChunk = this.firstChunk;
8043
+ var clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
8044
+
8045
+ while (originalChunk) {
8046
+ cloned.byStart[clonedChunk.start] = clonedChunk;
8047
+ cloned.byEnd[clonedChunk.end] = clonedChunk;
8048
+
8049
+ var nextOriginalChunk = originalChunk.next;
8050
+ var nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
8051
+
8052
+ if (nextClonedChunk) {
8053
+ clonedChunk.next = nextClonedChunk;
8054
+ nextClonedChunk.previous = clonedChunk;
8055
+
8056
+ clonedChunk = nextClonedChunk;
8057
+ }
8058
+
8059
+ originalChunk = nextOriginalChunk;
8060
+ }
8061
+
8062
+ cloned.lastChunk = clonedChunk;
8063
+
8064
+ if (this.indentExclusionRanges) {
8065
+ cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
8066
+ }
8067
+
8068
+ cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
8069
+
8070
+ cloned.intro = this.intro;
8071
+ cloned.outro = this.outro;
8072
+
8073
+ return cloned;
8074
+ };
8075
+
8076
+ MagicString.prototype.generateDecodedMap = function generateDecodedMap (options) {
8077
+ var this$1$1 = this;
8078
+
8079
+ options = options || {};
8080
+
8081
+ var sourceIndex = 0;
8082
+ var names = Object.keys(this.storedNames);
8083
+ var mappings = new Mappings(options.hires);
8084
+
8085
+ var locate = getLocator(this.original);
8086
+
8087
+ if (this.intro) {
8088
+ mappings.advance(this.intro);
8089
+ }
8090
+
8091
+ this.firstChunk.eachNext(function (chunk) {
8092
+ var loc = locate(chunk.start);
8093
+
8094
+ if (chunk.intro.length) { mappings.advance(chunk.intro); }
8095
+
8096
+ if (chunk.edited) {
8097
+ mappings.addEdit(
8098
+ sourceIndex,
8099
+ chunk.content,
8100
+ loc,
8101
+ chunk.storeName ? names.indexOf(chunk.original) : -1
8102
+ );
8103
+ } else {
8104
+ mappings.addUneditedChunk(sourceIndex, chunk, this$1$1.original, loc, this$1$1.sourcemapLocations);
8105
+ }
8106
+
8107
+ if (chunk.outro.length) { mappings.advance(chunk.outro); }
8108
+ });
8109
+
8110
+ return {
8111
+ file: options.file ? options.file.split(/[/\\]/).pop() : null,
8112
+ sources: [options.source ? getRelativePath(options.file || '', options.source) : null],
8113
+ sourcesContent: options.includeContent ? [this.original] : [null],
8114
+ names: names,
8115
+ mappings: mappings.raw
8116
+ };
8117
+ };
8118
+
8119
+ MagicString.prototype.generateMap = function generateMap (options) {
8120
+ return new SourceMap(this.generateDecodedMap(options));
8121
+ };
8122
+
8123
+ MagicString.prototype.getIndentString = function getIndentString () {
8124
+ return this.indentStr === null ? '\t' : this.indentStr;
8125
+ };
8126
+
8127
+ MagicString.prototype.indent = function indent (indentStr, options) {
8128
+ var pattern = /^[^\r\n]/gm;
8129
+
8130
+ if (isObject(indentStr)) {
8131
+ options = indentStr;
8132
+ indentStr = undefined;
8133
+ }
8134
+
8135
+ indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t';
8136
+
8137
+ if (indentStr === '') { return this; } // noop
8138
+
8139
+ options = options || {};
8140
+
8141
+ // Process exclusion ranges
8142
+ var isExcluded = {};
8143
+
8144
+ if (options.exclude) {
8145
+ var exclusions =
8146
+ typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
8147
+ exclusions.forEach(function (exclusion) {
8148
+ for (var i = exclusion[0]; i < exclusion[1]; i += 1) {
8149
+ isExcluded[i] = true;
8150
+ }
8151
+ });
8152
+ }
8153
+
8154
+ var shouldIndentNextCharacter = options.indentStart !== false;
8155
+ var replacer = function (match) {
8156
+ if (shouldIndentNextCharacter) { return ("" + indentStr + match); }
8157
+ shouldIndentNextCharacter = true;
8158
+ return match;
8159
+ };
8160
+
8161
+ this.intro = this.intro.replace(pattern, replacer);
8162
+
8163
+ var charIndex = 0;
8164
+ var chunk = this.firstChunk;
8165
+
8166
+ while (chunk) {
8167
+ var end = chunk.end;
8168
+
8169
+ if (chunk.edited) {
8170
+ if (!isExcluded[charIndex]) {
8171
+ chunk.content = chunk.content.replace(pattern, replacer);
8172
+
8173
+ if (chunk.content.length) {
8174
+ shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
8175
+ }
8176
+ }
8177
+ } else {
8178
+ charIndex = chunk.start;
8179
+
8180
+ while (charIndex < end) {
8181
+ if (!isExcluded[charIndex]) {
8182
+ var char = this.original[charIndex];
8183
+
8184
+ if (char === '\n') {
8185
+ shouldIndentNextCharacter = true;
8186
+ } else if (char !== '\r' && shouldIndentNextCharacter) {
8187
+ shouldIndentNextCharacter = false;
8188
+
8189
+ if (charIndex === chunk.start) {
8190
+ chunk.prependRight(indentStr);
8191
+ } else {
8192
+ this._splitChunk(chunk, charIndex);
8193
+ chunk = chunk.next;
8194
+ chunk.prependRight(indentStr);
8195
+ }
8196
+ }
8197
+ }
8198
+
8199
+ charIndex += 1;
8200
+ }
8201
+ }
8202
+
8203
+ charIndex = chunk.end;
8204
+ chunk = chunk.next;
8205
+ }
8206
+
8207
+ this.outro = this.outro.replace(pattern, replacer);
8208
+
8209
+ return this;
8210
+ };
8211
+
8212
+ MagicString.prototype.insert = function insert () {
8213
+ throw new Error('magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)');
8214
+ };
8215
+
8216
+ MagicString.prototype.insertLeft = function insertLeft (index, content) {
8217
+ if (!warned.insertLeft) {
8218
+ console.warn('magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'); // eslint-disable-line no-console
8219
+ warned.insertLeft = true;
8220
+ }
8221
+
8222
+ return this.appendLeft(index, content);
8223
+ };
8224
+
8225
+ MagicString.prototype.insertRight = function insertRight (index, content) {
8226
+ if (!warned.insertRight) {
8227
+ console.warn('magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'); // eslint-disable-line no-console
8228
+ warned.insertRight = true;
8229
+ }
8230
+
8231
+ return this.prependRight(index, content);
8232
+ };
8233
+
8234
+ MagicString.prototype.move = function move (start, end, index) {
8235
+ if (index >= start && index <= end) { throw new Error('Cannot move a selection inside itself'); }
8236
+
8237
+ this._split(start);
8238
+ this._split(end);
8239
+ this._split(index);
8240
+
8241
+ var first = this.byStart[start];
8242
+ var last = this.byEnd[end];
8243
+
8244
+ var oldLeft = first.previous;
8245
+ var oldRight = last.next;
8246
+
8247
+ var newRight = this.byStart[index];
8248
+ if (!newRight && last === this.lastChunk) { return this; }
8249
+ var newLeft = newRight ? newRight.previous : this.lastChunk;
8250
+
8251
+ if (oldLeft) { oldLeft.next = oldRight; }
8252
+ if (oldRight) { oldRight.previous = oldLeft; }
8253
+
8254
+ if (newLeft) { newLeft.next = first; }
8255
+ if (newRight) { newRight.previous = last; }
8256
+
8257
+ if (!first.previous) { this.firstChunk = last.next; }
8258
+ if (!last.next) {
8259
+ this.lastChunk = first.previous;
8260
+ this.lastChunk.next = null;
8261
+ }
8262
+
8263
+ first.previous = newLeft;
8264
+ last.next = newRight || null;
8265
+
8266
+ if (!newLeft) { this.firstChunk = first; }
8267
+ if (!newRight) { this.lastChunk = last; }
8268
+ return this;
8269
+ };
8270
+
8271
+ MagicString.prototype.overwrite = function overwrite (start, end, content, options) {
8272
+ if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); }
8273
+
8274
+ while (start < 0) { start += this.original.length; }
8275
+ while (end < 0) { end += this.original.length; }
8276
+
8277
+ if (end > this.original.length) { throw new Error('end is out of bounds'); }
8278
+ if (start === end)
8279
+ { throw new Error('Cannot overwrite a zero-length range – use appendLeft or prependRight instead'); }
8280
+
8281
+ this._split(start);
8282
+ this._split(end);
8283
+
8284
+ if (options === true) {
8285
+ if (!warned.storeName) {
8286
+ console.warn('The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'); // eslint-disable-line no-console
8287
+ warned.storeName = true;
8288
+ }
8289
+
8290
+ options = { storeName: true };
8291
+ }
8292
+ var storeName = options !== undefined ? options.storeName : false;
8293
+ var contentOnly = options !== undefined ? options.contentOnly : false;
8294
+
8295
+ if (storeName) {
8296
+ var original = this.original.slice(start, end);
8297
+ this.storedNames[original] = true;
8298
+ }
8299
+
8300
+ var first = this.byStart[start];
8301
+ var last = this.byEnd[end];
8302
+
8303
+ if (first) {
8304
+ if (end > first.end && first.next !== this.byStart[first.end]) {
8305
+ throw new Error('Cannot overwrite across a split point');
8306
+ }
8307
+
8308
+ first.edit(content, storeName, contentOnly);
8309
+
8310
+ if (first !== last) {
8311
+ var chunk = first.next;
8312
+ while (chunk !== last) {
8313
+ chunk.edit('', false);
8314
+ chunk = chunk.next;
8315
+ }
8316
+
8317
+ chunk.edit('', false);
8318
+ }
8319
+ } else {
8320
+ // must be inserting at the end
8321
+ var newChunk = new Chunk(start, end, '').edit(content, storeName);
8322
+
8323
+ // TODO last chunk in the array may not be the last chunk, if it's moved...
8324
+ last.next = newChunk;
8325
+ newChunk.previous = last;
8326
+ }
8327
+ return this;
8328
+ };
8329
+
8330
+ MagicString.prototype.prepend = function prepend (content) {
8331
+ if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
8332
+
8333
+ this.intro = content + this.intro;
8334
+ return this;
8335
+ };
8336
+
8337
+ MagicString.prototype.prependLeft = function prependLeft (index, content) {
8338
+ if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
8339
+
8340
+ this._split(index);
8341
+
8342
+ var chunk = this.byEnd[index];
8343
+
8344
+ if (chunk) {
8345
+ chunk.prependLeft(content);
8346
+ } else {
8347
+ this.intro = content + this.intro;
8348
+ }
8349
+ return this;
8350
+ };
8351
+
8352
+ MagicString.prototype.prependRight = function prependRight (index, content) {
8353
+ if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
8354
+
8355
+ this._split(index);
8356
+
8357
+ var chunk = this.byStart[index];
8358
+
8359
+ if (chunk) {
8360
+ chunk.prependRight(content);
8361
+ } else {
8362
+ this.outro = content + this.outro;
8363
+ }
8364
+ return this;
8365
+ };
8366
+
8367
+ MagicString.prototype.remove = function remove (start, end) {
8368
+ while (start < 0) { start += this.original.length; }
8369
+ while (end < 0) { end += this.original.length; }
8370
+
8371
+ if (start === end) { return this; }
8372
+
8373
+ if (start < 0 || end > this.original.length) { throw new Error('Character is out of bounds'); }
8374
+ if (start > end) { throw new Error('end must be greater than start'); }
8375
+
8376
+ this._split(start);
8377
+ this._split(end);
8378
+
8379
+ var chunk = this.byStart[start];
8380
+
8381
+ while (chunk) {
8382
+ chunk.intro = '';
8383
+ chunk.outro = '';
8384
+ chunk.edit('');
8385
+
8386
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
8387
+ }
8388
+ return this;
8389
+ };
8390
+
8391
+ MagicString.prototype.lastChar = function lastChar () {
8392
+ if (this.outro.length)
8393
+ { return this.outro[this.outro.length - 1]; }
8394
+ var chunk = this.lastChunk;
8395
+ do {
8396
+ if (chunk.outro.length)
8397
+ { return chunk.outro[chunk.outro.length - 1]; }
8398
+ if (chunk.content.length)
8399
+ { return chunk.content[chunk.content.length - 1]; }
8400
+ if (chunk.intro.length)
8401
+ { return chunk.intro[chunk.intro.length - 1]; }
8402
+ } while (chunk = chunk.previous);
8403
+ if (this.intro.length)
8404
+ { return this.intro[this.intro.length - 1]; }
8405
+ return '';
8406
+ };
8407
+
8408
+ MagicString.prototype.lastLine = function lastLine () {
8409
+ var lineIndex = this.outro.lastIndexOf(n);
8410
+ if (lineIndex !== -1)
8411
+ { return this.outro.substr(lineIndex + 1); }
8412
+ var lineStr = this.outro;
8413
+ var chunk = this.lastChunk;
8414
+ do {
8415
+ if (chunk.outro.length > 0) {
8416
+ lineIndex = chunk.outro.lastIndexOf(n);
8417
+ if (lineIndex !== -1)
8418
+ { return chunk.outro.substr(lineIndex + 1) + lineStr; }
8419
+ lineStr = chunk.outro + lineStr;
8420
+ }
8421
+
8422
+ if (chunk.content.length > 0) {
8423
+ lineIndex = chunk.content.lastIndexOf(n);
8424
+ if (lineIndex !== -1)
8425
+ { return chunk.content.substr(lineIndex + 1) + lineStr; }
8426
+ lineStr = chunk.content + lineStr;
8427
+ }
8428
+
8429
+ if (chunk.intro.length > 0) {
8430
+ lineIndex = chunk.intro.lastIndexOf(n);
8431
+ if (lineIndex !== -1)
8432
+ { return chunk.intro.substr(lineIndex + 1) + lineStr; }
8433
+ lineStr = chunk.intro + lineStr;
8434
+ }
8435
+ } while (chunk = chunk.previous);
8436
+ lineIndex = this.intro.lastIndexOf(n);
8437
+ if (lineIndex !== -1)
8438
+ { return this.intro.substr(lineIndex + 1) + lineStr; }
8439
+ return this.intro + lineStr;
8440
+ };
8441
+
8442
+ MagicString.prototype.slice = function slice (start, end) {
8443
+ if ( start === void 0 ) start = 0;
8444
+ if ( end === void 0 ) end = this.original.length;
8445
+
8446
+ while (start < 0) { start += this.original.length; }
8447
+ while (end < 0) { end += this.original.length; }
8448
+
8449
+ var result = '';
8450
+
8451
+ // find start chunk
8452
+ var chunk = this.firstChunk;
8453
+ while (chunk && (chunk.start > start || chunk.end <= start)) {
8454
+ // found end chunk before start
8455
+ if (chunk.start < end && chunk.end >= end) {
8456
+ return result;
8457
+ }
8458
+
8459
+ chunk = chunk.next;
8460
+ }
8461
+
8462
+ if (chunk && chunk.edited && chunk.start !== start)
8463
+ { throw new Error(("Cannot use replaced character " + start + " as slice start anchor.")); }
8464
+
8465
+ var startChunk = chunk;
8466
+ while (chunk) {
8467
+ if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
8468
+ result += chunk.intro;
8469
+ }
8470
+
8471
+ var containsEnd = chunk.start < end && chunk.end >= end;
8472
+ if (containsEnd && chunk.edited && chunk.end !== end)
8473
+ { throw new Error(("Cannot use replaced character " + end + " as slice end anchor.")); }
8474
+
8475
+ var sliceStart = startChunk === chunk ? start - chunk.start : 0;
8476
+ var sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
8477
+
8478
+ result += chunk.content.slice(sliceStart, sliceEnd);
8479
+
8480
+ if (chunk.outro && (!containsEnd || chunk.end === end)) {
8481
+ result += chunk.outro;
8482
+ }
8483
+
8484
+ if (containsEnd) {
8485
+ break;
8486
+ }
8487
+
8488
+ chunk = chunk.next;
8489
+ }
8490
+
8491
+ return result;
8492
+ };
8493
+
8494
+ // TODO deprecate this? not really very useful
8495
+ MagicString.prototype.snip = function snip (start, end) {
8496
+ var clone = this.clone();
8497
+ clone.remove(0, start);
8498
+ clone.remove(end, clone.original.length);
8499
+
8500
+ return clone;
8501
+ };
8502
+
8503
+ MagicString.prototype._split = function _split (index) {
8504
+ if (this.byStart[index] || this.byEnd[index]) { return; }
8505
+
8506
+ var chunk = this.lastSearchedChunk;
8507
+ var searchForward = index > chunk.end;
8508
+
8509
+ while (chunk) {
8510
+ if (chunk.contains(index)) { return this._splitChunk(chunk, index); }
8511
+
8512
+ chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
8513
+ }
8514
+ };
8515
+
8516
+ MagicString.prototype._splitChunk = function _splitChunk (chunk, index) {
8517
+ if (chunk.edited && chunk.content.length) {
8518
+ // zero-length edited chunks are a special case (overlapping replacements)
8519
+ var loc = getLocator(this.original)(index);
8520
+ throw new Error(
8521
+ ("Cannot split a chunk that has already been edited (" + (loc.line) + ":" + (loc.column) + " – \"" + (chunk.original) + "\")")
8522
+ );
8523
+ }
8524
+
8525
+ var newChunk = chunk.split(index);
8526
+
8527
+ this.byEnd[index] = chunk;
8528
+ this.byStart[index] = newChunk;
8529
+ this.byEnd[newChunk.end] = newChunk;
8530
+
8531
+ if (chunk === this.lastChunk) { this.lastChunk = newChunk; }
8532
+
8533
+ this.lastSearchedChunk = chunk;
8534
+ return true;
8535
+ };
8536
+
8537
+ MagicString.prototype.toString = function toString () {
8538
+ var str = this.intro;
8539
+
8540
+ var chunk = this.firstChunk;
8541
+ while (chunk) {
8542
+ str += chunk.toString();
8543
+ chunk = chunk.next;
8544
+ }
8545
+
8546
+ return str + this.outro;
8547
+ };
8548
+
8549
+ MagicString.prototype.isEmpty = function isEmpty () {
8550
+ var chunk = this.firstChunk;
8551
+ do {
8552
+ if (chunk.intro.length && chunk.intro.trim() ||
8553
+ chunk.content.length && chunk.content.trim() ||
8554
+ chunk.outro.length && chunk.outro.trim())
8555
+ { return false; }
8556
+ } while (chunk = chunk.next);
8557
+ return true;
8558
+ };
8559
+
8560
+ MagicString.prototype.length = function length () {
8561
+ var chunk = this.firstChunk;
8562
+ var length = 0;
8563
+ do {
8564
+ length += chunk.intro.length + chunk.content.length + chunk.outro.length;
8565
+ } while (chunk = chunk.next);
8566
+ return length;
8567
+ };
8568
+
8569
+ MagicString.prototype.trimLines = function trimLines () {
8570
+ return this.trim('[\\r\\n]');
8571
+ };
8572
+
8573
+ MagicString.prototype.trim = function trim (charType) {
8574
+ return this.trimStart(charType).trimEnd(charType);
8575
+ };
8576
+
8577
+ MagicString.prototype.trimEndAborted = function trimEndAborted (charType) {
8578
+ var rx = new RegExp((charType || '\\s') + '+$');
8579
+
8580
+ this.outro = this.outro.replace(rx, '');
8581
+ if (this.outro.length) { return true; }
8582
+
8583
+ var chunk = this.lastChunk;
8584
+
8585
+ do {
8586
+ var end = chunk.end;
8587
+ var aborted = chunk.trimEnd(rx);
8588
+
8589
+ // if chunk was trimmed, we have a new lastChunk
8590
+ if (chunk.end !== end) {
8591
+ if (this.lastChunk === chunk) {
8592
+ this.lastChunk = chunk.next;
8593
+ }
8594
+
8595
+ this.byEnd[chunk.end] = chunk;
8596
+ this.byStart[chunk.next.start] = chunk.next;
8597
+ this.byEnd[chunk.next.end] = chunk.next;
8598
+ }
8599
+
8600
+ if (aborted) { return true; }
8601
+ chunk = chunk.previous;
8602
+ } while (chunk);
8603
+
8604
+ return false;
8605
+ };
8606
+
8607
+ MagicString.prototype.trimEnd = function trimEnd (charType) {
8608
+ this.trimEndAborted(charType);
8609
+ return this;
8610
+ };
8611
+ MagicString.prototype.trimStartAborted = function trimStartAborted (charType) {
8612
+ var rx = new RegExp('^' + (charType || '\\s') + '+');
8613
+
8614
+ this.intro = this.intro.replace(rx, '');
8615
+ if (this.intro.length) { return true; }
8616
+
8617
+ var chunk = this.firstChunk;
8618
+
8619
+ do {
8620
+ var end = chunk.end;
8621
+ var aborted = chunk.trimStart(rx);
8622
+
8623
+ if (chunk.end !== end) {
8624
+ // special case...
8625
+ if (chunk === this.lastChunk) { this.lastChunk = chunk.next; }
8626
+
8627
+ this.byEnd[chunk.end] = chunk;
8628
+ this.byStart[chunk.next.start] = chunk.next;
8629
+ this.byEnd[chunk.next.end] = chunk.next;
8630
+ }
8631
+
8632
+ if (aborted) { return true; }
8633
+ chunk = chunk.next;
8634
+ } while (chunk);
8635
+
8636
+ return false;
8637
+ };
8638
+
8639
+ MagicString.prototype.trimStart = function trimStart (charType) {
8640
+ this.trimStartAborted(charType);
8641
+ return this;
8642
+ };
8643
+
8644
+ const mockRegexp = /\b(?:vitest|vi)\s*.\s*(mock|unmock|importActual|importMock)\(["`'\s](.*[@\w_-]+)["`'\s]\);?/mg;
8645
+ const MocksPlugin = () => {
8646
+ return {
8647
+ name: "vitest:mock-plugin",
8648
+ enforce: "post",
8649
+ async transform(code, id) {
8650
+ let m;
8651
+ const matchAll = Array.from(code.matchAll(mockRegexp));
8652
+ if (!matchAll.length)
8653
+ return;
8654
+ for (const match of matchAll) {
8655
+ const [line, method, modulePath] = match;
8656
+ const filepath = await this.resolve(modulePath, id);
8657
+ if (filepath) {
8658
+ m ?? (m = new MagicString(code));
8659
+ const start = match.index || 0;
8660
+ const end = start + line.length;
8661
+ let nodeModule = "null";
8662
+ if (filepath.id.includes("/node_modules/"))
8663
+ nodeModule = `"${modulePath}"`;
8664
+ const overwrite = `__vitest__${method}__("${filepath.id}", ${nodeModule});`;
8665
+ if (method === "mock") {
8666
+ m.prepend(`${overwrite}
8667
+
8668
+ `);
8669
+ m.remove(start, end);
8670
+ } else {
8671
+ m.overwrite(start, end, overwrite);
8672
+ }
8673
+ }
8674
+ }
8675
+ if (m) {
8676
+ return {
8677
+ code: m.toString(),
8678
+ map: m.generateMap()
8679
+ };
8680
+ }
8681
+ }
8682
+ };
8683
+ };
8684
+
7571
8685
  class StateManager {
7572
8686
  constructor() {
7573
8687
  this.filesMap = {};
@@ -7634,6 +8748,9 @@ function resolveConfig(options, viteConfig) {
7634
8748
  resolved.environment = resolved.environment || "node";
7635
8749
  resolved.threads = resolved.threads ?? true;
7636
8750
  resolved.interpretDefault = resolved.interpretDefault ?? true;
8751
+ resolved.clearMocks = resolved.clearMocks ?? false;
8752
+ resolved.restoreMocks = resolved.restoreMocks ?? false;
8753
+ resolved.mockReset = resolved.mockReset ?? false;
7637
8754
  resolved.include = resolved.include ?? defaultInclude;
7638
8755
  resolved.exclude = resolved.exclude ?? defaultExclude;
7639
8756
  resolved.testTimeout = resolved.testTimeout ?? 5e3;
@@ -7655,27 +8772,27 @@ function resolveConfig(options, viteConfig) {
7655
8772
  }
7656
8773
 
7657
8774
  const promiseMap = /* @__PURE__ */ new Map();
7658
- async function transformRequest(server, id) {
8775
+ async function transformRequest(ctx, id) {
7659
8776
  if (!promiseMap.has(id)) {
7660
- promiseMap.set(id, _transformRequest(server, id).then((r) => {
8777
+ promiseMap.set(id, _transformRequest(ctx, id).then((r) => {
7661
8778
  promiseMap.delete(id);
7662
8779
  return r;
7663
8780
  }));
7664
8781
  }
7665
8782
  return promiseMap.get(id);
7666
8783
  }
7667
- async function _transformRequest(server, id) {
8784
+ async function _transformRequest(ctx, id) {
7668
8785
  let result = null;
7669
8786
  if (id.match(/\.(?:[cm]?[jt]sx?|json)$/)) {
7670
- result = await server.transformRequest(id, { ssr: true });
8787
+ result = await ctx.server.transformRequest(id, { ssr: true });
7671
8788
  } else {
7672
- result = await server.transformRequest(id);
8789
+ result = await ctx.server.transformRequest(id);
7673
8790
  if (result)
7674
- result = await server.ssrTransform(result.code, result.map, id);
8791
+ result = await ctx.server.ssrTransform(result.code, result.map, id);
7675
8792
  }
7676
8793
  if (result && process.env.NODE_V8_COVERAGE)
7677
8794
  withInlineSourcemap(result);
7678
- return result;
8795
+ return result == null ? void 0 : result.code;
7679
8796
  }
7680
8797
  let SOURCEMAPPING_URL = "sourceMa";
7681
8798
  SOURCEMAPPING_URL += "ppingURL";
@@ -7723,6 +8840,8 @@ function createFakePool(ctx) {
7723
8840
  function createWorkerPool(ctx) {
7724
8841
  const options = {
7725
8842
  filename: workerPath,
8843
+ isolateWorkers: true,
8844
+ concurrentTasksPerWorker: 1,
7726
8845
  useAtomics: false
7727
8846
  };
7728
8847
  if (ctx.config.maxThreads != null)
@@ -7771,7 +8890,7 @@ function createChannel(ctx) {
7771
8890
  case "snapshotSaved":
7772
8891
  return send(() => ctx.snapshot.add(args[0]));
7773
8892
  case "fetch":
7774
- return send(() => transformRequest(ctx.server, ...args).then((r) => r == null ? void 0 : r.code));
8893
+ return send(() => transformRequest(ctx, ...args));
7775
8894
  case "onCollected":
7776
8895
  ctx.state.collectFiles(args[0]);
7777
8896
  ctx.reporters.forEach((r) => {
@@ -7994,9 +9113,10 @@ async function createVitest(options, viteOverrides = {}) {
7994
9113
  ctx.setServer(options, server2);
7995
9114
  haveStarted = true;
7996
9115
  if (options.api)
7997
- server2.middlewares.use((await import('./middleware-05e03d95.js')).default(ctx));
9116
+ server2.middlewares.use((await import('./middleware-0c8d46aa.js')).default(ctx));
7998
9117
  }
7999
- }
9118
+ },
9119
+ MocksPlugin()
8000
9120
  ],
8001
9121
  server: {
8002
9122
  open: options.open,