vitest 0.0.111 → 0.0.115

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,19 +1,22 @@
1
- import { c, s as slash$1, i as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, a as getTests, f as getSuites, h as resolve, n as noop$1, t as toArray, j as hasFailed } from './utils-cb6b1266.js';
1
+ import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-7c024e16.js';
2
2
  import { createServer, mergeConfig } from 'vite';
3
3
  import path$a from 'path';
4
4
  import process$1 from 'process';
5
- import fs$8, { promises } from 'fs';
5
+ import fs$8, { promises, existsSync } from 'fs';
6
6
  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-2b0310b7.js';
10
+ import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-5968a78c.js';
11
+ import MagicString from './magic-string.es-94000aea.js';
11
12
  import { performance } from 'perf_hooks';
12
- import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-66d6bb83.js';
13
- import { o as onetime, s as signalExit } from './index-61c8686f.js';
14
- import { MessageChannel } from 'worker_threads';
13
+ import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-67678e1f.js';
14
+ import { o as onetime, s as signalExit } from './index-648e7ab2.js';
15
+ import { createRequire } from 'module';
15
16
  import { pathToFileURL } from 'url';
17
+ import { MessageChannel } from 'worker_threads';
16
18
  import { Tinypool } from 'tinypool';
19
+ import { c as createBirpc } from './index-e909c175.js';
17
20
 
18
21
  /*
19
22
  How it works:
@@ -411,7 +414,7 @@ var isExtglob$1 = function isExtglob(str) {
411
414
  */
412
415
 
413
416
  var isExtglob = isExtglob$1;
414
- var chars$1 = { '{': '}', '(': ')', '[': ']'};
417
+ var chars = { '{': '}', '(': ')', '[': ']'};
415
418
  var strictCheck = function(str) {
416
419
  if (str[0] === '!') {
417
420
  return true;
@@ -484,7 +487,7 @@ var strictCheck = function(str) {
484
487
  if (str[index] === '\\') {
485
488
  var open = str[index + 1];
486
489
  index += 2;
487
- var close = chars$1[open];
490
+ var close = chars[open];
488
491
 
489
492
  if (close) {
490
493
  var n = str.indexOf(close, index);
@@ -516,7 +519,7 @@ var relaxedCheck = function(str) {
516
519
  if (str[index] === '\\') {
517
520
  var open = str[index + 1];
518
521
  index += 2;
519
- var close = chars$1[open];
522
+ var close = chars[open];
520
523
 
521
524
  if (close) {
522
525
  var n = str.indexOf(close, index);
@@ -1055,7 +1058,7 @@ var toRegexRange_1 = toRegexRange$1;
1055
1058
  const util$1 = require$$0$1;
1056
1059
  const toRegexRange = toRegexRange_1;
1057
1060
 
1058
- const isObject$2 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
1061
+ const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
1059
1062
 
1060
1063
  const transform = toNumber => {
1061
1064
  return value => toNumber === true ? Number(value) : String(value);
@@ -1271,7 +1274,7 @@ const fill$2 = (start, end, step, options = {}) => {
1271
1274
  return fill$2(start, end, 1, { transform: step });
1272
1275
  }
1273
1276
 
1274
- if (isObject$2(step)) {
1277
+ if (isObject$1(step)) {
1275
1278
  return fill$2(start, end, 0, step);
1276
1279
  }
1277
1280
 
@@ -1280,7 +1283,7 @@ const fill$2 = (start, end, step, options = {}) => {
1280
1283
  step = step || opts.step || 1;
1281
1284
 
1282
1285
  if (!isNumber(step)) {
1283
- if (step != null && !isObject$2(step)) return invalidStep(step, opts);
1286
+ if (step != null && !isObject$1(step)) return invalidStep(step, opts);
1284
1287
  return fill$2(start, end, 1, step);
1285
1288
  }
1286
1289
 
@@ -3739,7 +3742,7 @@ const scan = scan_1;
3739
3742
  const parse = parse_1;
3740
3743
  const utils$c = utils$f;
3741
3744
  const constants$1 = constants$3;
3742
- const isObject$1 = val => val && typeof val === 'object' && !Array.isArray(val);
3745
+ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
3743
3746
 
3744
3747
  /**
3745
3748
  * Creates a matcher function from one or more glob patterns. The
@@ -3776,7 +3779,7 @@ const picomatch$2 = (glob, options, returnState = false) => {
3776
3779
  return arrayMatcher;
3777
3780
  }
3778
3781
 
3779
- const isState = isObject$1(glob) && glob.tokens && glob.input;
3782
+ const isState = isObject(glob) && glob.tokens && glob.input;
3780
3783
 
3781
3784
  if (glob === '' || (typeof glob !== 'string' && !isState)) {
3782
3785
  throw new TypeError('Expected pattern to be a non-empty string');
@@ -6750,1079 +6753,6 @@ function addSnapshotResult(summary, result) {
6750
6753
  summary.total += result.added + result.matched + result.unmatched + result.updated;
6751
6754
  }
6752
6755
 
6753
- var charToInteger = {};
6754
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
6755
- for (var i = 0; i < chars.length; i++) {
6756
- charToInteger[chars.charCodeAt(i)] = i;
6757
- }
6758
- function encode(decoded) {
6759
- var sourceFileIndex = 0; // second field
6760
- var sourceCodeLine = 0; // third field
6761
- var sourceCodeColumn = 0; // fourth field
6762
- var nameIndex = 0; // fifth field
6763
- var mappings = '';
6764
- for (var i = 0; i < decoded.length; i++) {
6765
- var line = decoded[i];
6766
- if (i > 0)
6767
- mappings += ';';
6768
- if (line.length === 0)
6769
- continue;
6770
- var generatedCodeColumn = 0; // first field
6771
- var lineMappings = [];
6772
- for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {
6773
- var segment = line_1[_i];
6774
- var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);
6775
- generatedCodeColumn = segment[0];
6776
- if (segment.length > 1) {
6777
- segmentMappings +=
6778
- encodeInteger(segment[1] - sourceFileIndex) +
6779
- encodeInteger(segment[2] - sourceCodeLine) +
6780
- encodeInteger(segment[3] - sourceCodeColumn);
6781
- sourceFileIndex = segment[1];
6782
- sourceCodeLine = segment[2];
6783
- sourceCodeColumn = segment[3];
6784
- }
6785
- if (segment.length === 5) {
6786
- segmentMappings += encodeInteger(segment[4] - nameIndex);
6787
- nameIndex = segment[4];
6788
- }
6789
- lineMappings.push(segmentMappings);
6790
- }
6791
- mappings += lineMappings.join(',');
6792
- }
6793
- return mappings;
6794
- }
6795
- function encodeInteger(num) {
6796
- var result = '';
6797
- num = num < 0 ? (-num << 1) | 1 : num << 1;
6798
- do {
6799
- var clamped = num & 31;
6800
- num >>>= 5;
6801
- if (num > 0) {
6802
- clamped |= 32;
6803
- }
6804
- result += chars[clamped];
6805
- } while (num > 0);
6806
- return result;
6807
- }
6808
-
6809
- var BitSet = function BitSet(arg) {
6810
- this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
6811
- };
6812
-
6813
- BitSet.prototype.add = function add (n) {
6814
- this.bits[n >> 5] |= 1 << (n & 31);
6815
- };
6816
-
6817
- BitSet.prototype.has = function has (n) {
6818
- return !!(this.bits[n >> 5] & (1 << (n & 31)));
6819
- };
6820
-
6821
- var Chunk = function Chunk(start, end, content) {
6822
- this.start = start;
6823
- this.end = end;
6824
- this.original = content;
6825
-
6826
- this.intro = '';
6827
- this.outro = '';
6828
-
6829
- this.content = content;
6830
- this.storeName = false;
6831
- this.edited = false;
6832
-
6833
- // we make these non-enumerable, for sanity while debugging
6834
- Object.defineProperties(this, {
6835
- previous: { writable: true, value: null },
6836
- next: { writable: true, value: null }
6837
- });
6838
- };
6839
-
6840
- Chunk.prototype.appendLeft = function appendLeft (content) {
6841
- this.outro += content;
6842
- };
6843
-
6844
- Chunk.prototype.appendRight = function appendRight (content) {
6845
- this.intro = this.intro + content;
6846
- };
6847
-
6848
- Chunk.prototype.clone = function clone () {
6849
- var chunk = new Chunk(this.start, this.end, this.original);
6850
-
6851
- chunk.intro = this.intro;
6852
- chunk.outro = this.outro;
6853
- chunk.content = this.content;
6854
- chunk.storeName = this.storeName;
6855
- chunk.edited = this.edited;
6856
-
6857
- return chunk;
6858
- };
6859
-
6860
- Chunk.prototype.contains = function contains (index) {
6861
- return this.start < index && index < this.end;
6862
- };
6863
-
6864
- Chunk.prototype.eachNext = function eachNext (fn) {
6865
- var chunk = this;
6866
- while (chunk) {
6867
- fn(chunk);
6868
- chunk = chunk.next;
6869
- }
6870
- };
6871
-
6872
- Chunk.prototype.eachPrevious = function eachPrevious (fn) {
6873
- var chunk = this;
6874
- while (chunk) {
6875
- fn(chunk);
6876
- chunk = chunk.previous;
6877
- }
6878
- };
6879
-
6880
- Chunk.prototype.edit = function edit (content, storeName, contentOnly) {
6881
- this.content = content;
6882
- if (!contentOnly) {
6883
- this.intro = '';
6884
- this.outro = '';
6885
- }
6886
- this.storeName = storeName;
6887
-
6888
- this.edited = true;
6889
-
6890
- return this;
6891
- };
6892
-
6893
- Chunk.prototype.prependLeft = function prependLeft (content) {
6894
- this.outro = content + this.outro;
6895
- };
6896
-
6897
- Chunk.prototype.prependRight = function prependRight (content) {
6898
- this.intro = content + this.intro;
6899
- };
6900
-
6901
- Chunk.prototype.split = function split (index) {
6902
- var sliceIndex = index - this.start;
6903
-
6904
- var originalBefore = this.original.slice(0, sliceIndex);
6905
- var originalAfter = this.original.slice(sliceIndex);
6906
-
6907
- this.original = originalBefore;
6908
-
6909
- var newChunk = new Chunk(index, this.end, originalAfter);
6910
- newChunk.outro = this.outro;
6911
- this.outro = '';
6912
-
6913
- this.end = index;
6914
-
6915
- if (this.edited) {
6916
- // TODO is this block necessary?...
6917
- newChunk.edit('', false);
6918
- this.content = '';
6919
- } else {
6920
- this.content = originalBefore;
6921
- }
6922
-
6923
- newChunk.next = this.next;
6924
- if (newChunk.next) { newChunk.next.previous = newChunk; }
6925
- newChunk.previous = this;
6926
- this.next = newChunk;
6927
-
6928
- return newChunk;
6929
- };
6930
-
6931
- Chunk.prototype.toString = function toString () {
6932
- return this.intro + this.content + this.outro;
6933
- };
6934
-
6935
- Chunk.prototype.trimEnd = function trimEnd (rx) {
6936
- this.outro = this.outro.replace(rx, '');
6937
- if (this.outro.length) { return true; }
6938
-
6939
- var trimmed = this.content.replace(rx, '');
6940
-
6941
- if (trimmed.length) {
6942
- if (trimmed !== this.content) {
6943
- this.split(this.start + trimmed.length).edit('', undefined, true);
6944
- }
6945
- return true;
6946
-
6947
- } else {
6948
- this.edit('', undefined, true);
6949
-
6950
- this.intro = this.intro.replace(rx, '');
6951
- if (this.intro.length) { return true; }
6952
- }
6953
- };
6954
-
6955
- Chunk.prototype.trimStart = function trimStart (rx) {
6956
- this.intro = this.intro.replace(rx, '');
6957
- if (this.intro.length) { return true; }
6958
-
6959
- var trimmed = this.content.replace(rx, '');
6960
-
6961
- if (trimmed.length) {
6962
- if (trimmed !== this.content) {
6963
- this.split(this.end - trimmed.length);
6964
- this.edit('', undefined, true);
6965
- }
6966
- return true;
6967
-
6968
- } else {
6969
- this.edit('', undefined, true);
6970
-
6971
- this.outro = this.outro.replace(rx, '');
6972
- if (this.outro.length) { return true; }
6973
- }
6974
- };
6975
-
6976
- var btoa = function () {
6977
- throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
6978
- };
6979
- if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
6980
- btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
6981
- } else if (typeof Buffer === 'function') {
6982
- btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
6983
- }
6984
-
6985
- var SourceMap = function SourceMap(properties) {
6986
- this.version = 3;
6987
- this.file = properties.file;
6988
- this.sources = properties.sources;
6989
- this.sourcesContent = properties.sourcesContent;
6990
- this.names = properties.names;
6991
- this.mappings = encode(properties.mappings);
6992
- };
6993
-
6994
- SourceMap.prototype.toString = function toString () {
6995
- return JSON.stringify(this);
6996
- };
6997
-
6998
- SourceMap.prototype.toUrl = function toUrl () {
6999
- return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
7000
- };
7001
-
7002
- function guessIndent(code) {
7003
- var lines = code.split('\n');
7004
-
7005
- var tabbed = lines.filter(function (line) { return /^\t+/.test(line); });
7006
- var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); });
7007
-
7008
- if (tabbed.length === 0 && spaced.length === 0) {
7009
- return null;
7010
- }
7011
-
7012
- // More lines tabbed than spaced? Assume tabs, and
7013
- // default to tabs in the case of a tie (or nothing
7014
- // to go on)
7015
- if (tabbed.length >= spaced.length) {
7016
- return '\t';
7017
- }
7018
-
7019
- // Otherwise, we need to guess the multiple
7020
- var min = spaced.reduce(function (previous, current) {
7021
- var numSpaces = /^ +/.exec(current)[0].length;
7022
- return Math.min(numSpaces, previous);
7023
- }, Infinity);
7024
-
7025
- return new Array(min + 1).join(' ');
7026
- }
7027
-
7028
- function getRelativePath(from, to) {
7029
- var fromParts = from.split(/[/\\]/);
7030
- var toParts = to.split(/[/\\]/);
7031
-
7032
- fromParts.pop(); // get dirname
7033
-
7034
- while (fromParts[0] === toParts[0]) {
7035
- fromParts.shift();
7036
- toParts.shift();
7037
- }
7038
-
7039
- if (fromParts.length) {
7040
- var i = fromParts.length;
7041
- while (i--) { fromParts[i] = '..'; }
7042
- }
7043
-
7044
- return fromParts.concat(toParts).join('/');
7045
- }
7046
-
7047
- var toString = Object.prototype.toString;
7048
-
7049
- function isObject(thing) {
7050
- return toString.call(thing) === '[object Object]';
7051
- }
7052
-
7053
- function getLocator(source) {
7054
- var originalLines = source.split('\n');
7055
- var lineOffsets = [];
7056
-
7057
- for (var i = 0, pos = 0; i < originalLines.length; i++) {
7058
- lineOffsets.push(pos);
7059
- pos += originalLines[i].length + 1;
7060
- }
7061
-
7062
- return function locate(index) {
7063
- var i = 0;
7064
- var j = lineOffsets.length;
7065
- while (i < j) {
7066
- var m = (i + j) >> 1;
7067
- if (index < lineOffsets[m]) {
7068
- j = m;
7069
- } else {
7070
- i = m + 1;
7071
- }
7072
- }
7073
- var line = i - 1;
7074
- var column = index - lineOffsets[line];
7075
- return { line: line, column: column };
7076
- };
7077
- }
7078
-
7079
- var Mappings = function Mappings(hires) {
7080
- this.hires = hires;
7081
- this.generatedCodeLine = 0;
7082
- this.generatedCodeColumn = 0;
7083
- this.raw = [];
7084
- this.rawSegments = this.raw[this.generatedCodeLine] = [];
7085
- this.pending = null;
7086
- };
7087
-
7088
- Mappings.prototype.addEdit = function addEdit (sourceIndex, content, loc, nameIndex) {
7089
- if (content.length) {
7090
- var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
7091
- if (nameIndex >= 0) {
7092
- segment.push(nameIndex);
7093
- }
7094
- this.rawSegments.push(segment);
7095
- } else if (this.pending) {
7096
- this.rawSegments.push(this.pending);
7097
- }
7098
-
7099
- this.advance(content);
7100
- this.pending = null;
7101
- };
7102
-
7103
- Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) {
7104
- var originalCharIndex = chunk.start;
7105
- var first = true;
7106
-
7107
- while (originalCharIndex < chunk.end) {
7108
- if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
7109
- this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
7110
- }
7111
-
7112
- if (original[originalCharIndex] === '\n') {
7113
- loc.line += 1;
7114
- loc.column = 0;
7115
- this.generatedCodeLine += 1;
7116
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
7117
- this.generatedCodeColumn = 0;
7118
- first = true;
7119
- } else {
7120
- loc.column += 1;
7121
- this.generatedCodeColumn += 1;
7122
- first = false;
7123
- }
7124
-
7125
- originalCharIndex += 1;
7126
- }
7127
-
7128
- this.pending = null;
7129
- };
7130
-
7131
- Mappings.prototype.advance = function advance (str) {
7132
- if (!str) { return; }
7133
-
7134
- var lines = str.split('\n');
7135
-
7136
- if (lines.length > 1) {
7137
- for (var i = 0; i < lines.length - 1; i++) {
7138
- this.generatedCodeLine++;
7139
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
7140
- }
7141
- this.generatedCodeColumn = 0;
7142
- }
7143
-
7144
- this.generatedCodeColumn += lines[lines.length - 1].length;
7145
- };
7146
-
7147
- var n = '\n';
7148
-
7149
- var warned = {
7150
- insertLeft: false,
7151
- insertRight: false,
7152
- storeName: false
7153
- };
7154
-
7155
- var MagicString = function MagicString(string, options) {
7156
- if ( options === void 0 ) options = {};
7157
-
7158
- var chunk = new Chunk(0, string.length, string);
7159
-
7160
- Object.defineProperties(this, {
7161
- original: { writable: true, value: string },
7162
- outro: { writable: true, value: '' },
7163
- intro: { writable: true, value: '' },
7164
- firstChunk: { writable: true, value: chunk },
7165
- lastChunk: { writable: true, value: chunk },
7166
- lastSearchedChunk: { writable: true, value: chunk },
7167
- byStart: { writable: true, value: {} },
7168
- byEnd: { writable: true, value: {} },
7169
- filename: { writable: true, value: options.filename },
7170
- indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
7171
- sourcemapLocations: { writable: true, value: new BitSet() },
7172
- storedNames: { writable: true, value: {} },
7173
- indentStr: { writable: true, value: guessIndent(string) }
7174
- });
7175
-
7176
- this.byStart[0] = chunk;
7177
- this.byEnd[string.length] = chunk;
7178
- };
7179
-
7180
- MagicString.prototype.addSourcemapLocation = function addSourcemapLocation (char) {
7181
- this.sourcemapLocations.add(char);
7182
- };
7183
-
7184
- MagicString.prototype.append = function append (content) {
7185
- if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
7186
-
7187
- this.outro += content;
7188
- return this;
7189
- };
7190
-
7191
- MagicString.prototype.appendLeft = function appendLeft (index, content) {
7192
- if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
7193
-
7194
- this._split(index);
7195
-
7196
- var chunk = this.byEnd[index];
7197
-
7198
- if (chunk) {
7199
- chunk.appendLeft(content);
7200
- } else {
7201
- this.intro += content;
7202
- }
7203
- return this;
7204
- };
7205
-
7206
- MagicString.prototype.appendRight = function appendRight (index, content) {
7207
- if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
7208
-
7209
- this._split(index);
7210
-
7211
- var chunk = this.byStart[index];
7212
-
7213
- if (chunk) {
7214
- chunk.appendRight(content);
7215
- } else {
7216
- this.outro += content;
7217
- }
7218
- return this;
7219
- };
7220
-
7221
- MagicString.prototype.clone = function clone () {
7222
- var cloned = new MagicString(this.original, { filename: this.filename });
7223
-
7224
- var originalChunk = this.firstChunk;
7225
- var clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
7226
-
7227
- while (originalChunk) {
7228
- cloned.byStart[clonedChunk.start] = clonedChunk;
7229
- cloned.byEnd[clonedChunk.end] = clonedChunk;
7230
-
7231
- var nextOriginalChunk = originalChunk.next;
7232
- var nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
7233
-
7234
- if (nextClonedChunk) {
7235
- clonedChunk.next = nextClonedChunk;
7236
- nextClonedChunk.previous = clonedChunk;
7237
-
7238
- clonedChunk = nextClonedChunk;
7239
- }
7240
-
7241
- originalChunk = nextOriginalChunk;
7242
- }
7243
-
7244
- cloned.lastChunk = clonedChunk;
7245
-
7246
- if (this.indentExclusionRanges) {
7247
- cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
7248
- }
7249
-
7250
- cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
7251
-
7252
- cloned.intro = this.intro;
7253
- cloned.outro = this.outro;
7254
-
7255
- return cloned;
7256
- };
7257
-
7258
- MagicString.prototype.generateDecodedMap = function generateDecodedMap (options) {
7259
- var this$1$1 = this;
7260
-
7261
- options = options || {};
7262
-
7263
- var sourceIndex = 0;
7264
- var names = Object.keys(this.storedNames);
7265
- var mappings = new Mappings(options.hires);
7266
-
7267
- var locate = getLocator(this.original);
7268
-
7269
- if (this.intro) {
7270
- mappings.advance(this.intro);
7271
- }
7272
-
7273
- this.firstChunk.eachNext(function (chunk) {
7274
- var loc = locate(chunk.start);
7275
-
7276
- if (chunk.intro.length) { mappings.advance(chunk.intro); }
7277
-
7278
- if (chunk.edited) {
7279
- mappings.addEdit(
7280
- sourceIndex,
7281
- chunk.content,
7282
- loc,
7283
- chunk.storeName ? names.indexOf(chunk.original) : -1
7284
- );
7285
- } else {
7286
- mappings.addUneditedChunk(sourceIndex, chunk, this$1$1.original, loc, this$1$1.sourcemapLocations);
7287
- }
7288
-
7289
- if (chunk.outro.length) { mappings.advance(chunk.outro); }
7290
- });
7291
-
7292
- return {
7293
- file: options.file ? options.file.split(/[/\\]/).pop() : null,
7294
- sources: [options.source ? getRelativePath(options.file || '', options.source) : null],
7295
- sourcesContent: options.includeContent ? [this.original] : [null],
7296
- names: names,
7297
- mappings: mappings.raw
7298
- };
7299
- };
7300
-
7301
- MagicString.prototype.generateMap = function generateMap (options) {
7302
- return new SourceMap(this.generateDecodedMap(options));
7303
- };
7304
-
7305
- MagicString.prototype.getIndentString = function getIndentString () {
7306
- return this.indentStr === null ? '\t' : this.indentStr;
7307
- };
7308
-
7309
- MagicString.prototype.indent = function indent (indentStr, options) {
7310
- var pattern = /^[^\r\n]/gm;
7311
-
7312
- if (isObject(indentStr)) {
7313
- options = indentStr;
7314
- indentStr = undefined;
7315
- }
7316
-
7317
- indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t';
7318
-
7319
- if (indentStr === '') { return this; } // noop
7320
-
7321
- options = options || {};
7322
-
7323
- // Process exclusion ranges
7324
- var isExcluded = {};
7325
-
7326
- if (options.exclude) {
7327
- var exclusions =
7328
- typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
7329
- exclusions.forEach(function (exclusion) {
7330
- for (var i = exclusion[0]; i < exclusion[1]; i += 1) {
7331
- isExcluded[i] = true;
7332
- }
7333
- });
7334
- }
7335
-
7336
- var shouldIndentNextCharacter = options.indentStart !== false;
7337
- var replacer = function (match) {
7338
- if (shouldIndentNextCharacter) { return ("" + indentStr + match); }
7339
- shouldIndentNextCharacter = true;
7340
- return match;
7341
- };
7342
-
7343
- this.intro = this.intro.replace(pattern, replacer);
7344
-
7345
- var charIndex = 0;
7346
- var chunk = this.firstChunk;
7347
-
7348
- while (chunk) {
7349
- var end = chunk.end;
7350
-
7351
- if (chunk.edited) {
7352
- if (!isExcluded[charIndex]) {
7353
- chunk.content = chunk.content.replace(pattern, replacer);
7354
-
7355
- if (chunk.content.length) {
7356
- shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
7357
- }
7358
- }
7359
- } else {
7360
- charIndex = chunk.start;
7361
-
7362
- while (charIndex < end) {
7363
- if (!isExcluded[charIndex]) {
7364
- var char = this.original[charIndex];
7365
-
7366
- if (char === '\n') {
7367
- shouldIndentNextCharacter = true;
7368
- } else if (char !== '\r' && shouldIndentNextCharacter) {
7369
- shouldIndentNextCharacter = false;
7370
-
7371
- if (charIndex === chunk.start) {
7372
- chunk.prependRight(indentStr);
7373
- } else {
7374
- this._splitChunk(chunk, charIndex);
7375
- chunk = chunk.next;
7376
- chunk.prependRight(indentStr);
7377
- }
7378
- }
7379
- }
7380
-
7381
- charIndex += 1;
7382
- }
7383
- }
7384
-
7385
- charIndex = chunk.end;
7386
- chunk = chunk.next;
7387
- }
7388
-
7389
- this.outro = this.outro.replace(pattern, replacer);
7390
-
7391
- return this;
7392
- };
7393
-
7394
- MagicString.prototype.insert = function insert () {
7395
- throw new Error('magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)');
7396
- };
7397
-
7398
- MagicString.prototype.insertLeft = function insertLeft (index, content) {
7399
- if (!warned.insertLeft) {
7400
- console.warn('magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'); // eslint-disable-line no-console
7401
- warned.insertLeft = true;
7402
- }
7403
-
7404
- return this.appendLeft(index, content);
7405
- };
7406
-
7407
- MagicString.prototype.insertRight = function insertRight (index, content) {
7408
- if (!warned.insertRight) {
7409
- console.warn('magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'); // eslint-disable-line no-console
7410
- warned.insertRight = true;
7411
- }
7412
-
7413
- return this.prependRight(index, content);
7414
- };
7415
-
7416
- MagicString.prototype.move = function move (start, end, index) {
7417
- if (index >= start && index <= end) { throw new Error('Cannot move a selection inside itself'); }
7418
-
7419
- this._split(start);
7420
- this._split(end);
7421
- this._split(index);
7422
-
7423
- var first = this.byStart[start];
7424
- var last = this.byEnd[end];
7425
-
7426
- var oldLeft = first.previous;
7427
- var oldRight = last.next;
7428
-
7429
- var newRight = this.byStart[index];
7430
- if (!newRight && last === this.lastChunk) { return this; }
7431
- var newLeft = newRight ? newRight.previous : this.lastChunk;
7432
-
7433
- if (oldLeft) { oldLeft.next = oldRight; }
7434
- if (oldRight) { oldRight.previous = oldLeft; }
7435
-
7436
- if (newLeft) { newLeft.next = first; }
7437
- if (newRight) { newRight.previous = last; }
7438
-
7439
- if (!first.previous) { this.firstChunk = last.next; }
7440
- if (!last.next) {
7441
- this.lastChunk = first.previous;
7442
- this.lastChunk.next = null;
7443
- }
7444
-
7445
- first.previous = newLeft;
7446
- last.next = newRight || null;
7447
-
7448
- if (!newLeft) { this.firstChunk = first; }
7449
- if (!newRight) { this.lastChunk = last; }
7450
- return this;
7451
- };
7452
-
7453
- MagicString.prototype.overwrite = function overwrite (start, end, content, options) {
7454
- if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); }
7455
-
7456
- while (start < 0) { start += this.original.length; }
7457
- while (end < 0) { end += this.original.length; }
7458
-
7459
- if (end > this.original.length) { throw new Error('end is out of bounds'); }
7460
- if (start === end)
7461
- { throw new Error('Cannot overwrite a zero-length range – use appendLeft or prependRight instead'); }
7462
-
7463
- this._split(start);
7464
- this._split(end);
7465
-
7466
- if (options === true) {
7467
- if (!warned.storeName) {
7468
- 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
7469
- warned.storeName = true;
7470
- }
7471
-
7472
- options = { storeName: true };
7473
- }
7474
- var storeName = options !== undefined ? options.storeName : false;
7475
- var contentOnly = options !== undefined ? options.contentOnly : false;
7476
-
7477
- if (storeName) {
7478
- var original = this.original.slice(start, end);
7479
- this.storedNames[original] = true;
7480
- }
7481
-
7482
- var first = this.byStart[start];
7483
- var last = this.byEnd[end];
7484
-
7485
- if (first) {
7486
- if (end > first.end && first.next !== this.byStart[first.end]) {
7487
- throw new Error('Cannot overwrite across a split point');
7488
- }
7489
-
7490
- first.edit(content, storeName, contentOnly);
7491
-
7492
- if (first !== last) {
7493
- var chunk = first.next;
7494
- while (chunk !== last) {
7495
- chunk.edit('', false);
7496
- chunk = chunk.next;
7497
- }
7498
-
7499
- chunk.edit('', false);
7500
- }
7501
- } else {
7502
- // must be inserting at the end
7503
- var newChunk = new Chunk(start, end, '').edit(content, storeName);
7504
-
7505
- // TODO last chunk in the array may not be the last chunk, if it's moved...
7506
- last.next = newChunk;
7507
- newChunk.previous = last;
7508
- }
7509
- return this;
7510
- };
7511
-
7512
- MagicString.prototype.prepend = function prepend (content) {
7513
- if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
7514
-
7515
- this.intro = content + this.intro;
7516
- return this;
7517
- };
7518
-
7519
- MagicString.prototype.prependLeft = function prependLeft (index, content) {
7520
- if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
7521
-
7522
- this._split(index);
7523
-
7524
- var chunk = this.byEnd[index];
7525
-
7526
- if (chunk) {
7527
- chunk.prependLeft(content);
7528
- } else {
7529
- this.intro = content + this.intro;
7530
- }
7531
- return this;
7532
- };
7533
-
7534
- MagicString.prototype.prependRight = function prependRight (index, content) {
7535
- if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
7536
-
7537
- this._split(index);
7538
-
7539
- var chunk = this.byStart[index];
7540
-
7541
- if (chunk) {
7542
- chunk.prependRight(content);
7543
- } else {
7544
- this.outro = content + this.outro;
7545
- }
7546
- return this;
7547
- };
7548
-
7549
- MagicString.prototype.remove = function remove (start, end) {
7550
- while (start < 0) { start += this.original.length; }
7551
- while (end < 0) { end += this.original.length; }
7552
-
7553
- if (start === end) { return this; }
7554
-
7555
- if (start < 0 || end > this.original.length) { throw new Error('Character is out of bounds'); }
7556
- if (start > end) { throw new Error('end must be greater than start'); }
7557
-
7558
- this._split(start);
7559
- this._split(end);
7560
-
7561
- var chunk = this.byStart[start];
7562
-
7563
- while (chunk) {
7564
- chunk.intro = '';
7565
- chunk.outro = '';
7566
- chunk.edit('');
7567
-
7568
- chunk = end > chunk.end ? this.byStart[chunk.end] : null;
7569
- }
7570
- return this;
7571
- };
7572
-
7573
- MagicString.prototype.lastChar = function lastChar () {
7574
- if (this.outro.length)
7575
- { return this.outro[this.outro.length - 1]; }
7576
- var chunk = this.lastChunk;
7577
- do {
7578
- if (chunk.outro.length)
7579
- { return chunk.outro[chunk.outro.length - 1]; }
7580
- if (chunk.content.length)
7581
- { return chunk.content[chunk.content.length - 1]; }
7582
- if (chunk.intro.length)
7583
- { return chunk.intro[chunk.intro.length - 1]; }
7584
- } while (chunk = chunk.previous);
7585
- if (this.intro.length)
7586
- { return this.intro[this.intro.length - 1]; }
7587
- return '';
7588
- };
7589
-
7590
- MagicString.prototype.lastLine = function lastLine () {
7591
- var lineIndex = this.outro.lastIndexOf(n);
7592
- if (lineIndex !== -1)
7593
- { return this.outro.substr(lineIndex + 1); }
7594
- var lineStr = this.outro;
7595
- var chunk = this.lastChunk;
7596
- do {
7597
- if (chunk.outro.length > 0) {
7598
- lineIndex = chunk.outro.lastIndexOf(n);
7599
- if (lineIndex !== -1)
7600
- { return chunk.outro.substr(lineIndex + 1) + lineStr; }
7601
- lineStr = chunk.outro + lineStr;
7602
- }
7603
-
7604
- if (chunk.content.length > 0) {
7605
- lineIndex = chunk.content.lastIndexOf(n);
7606
- if (lineIndex !== -1)
7607
- { return chunk.content.substr(lineIndex + 1) + lineStr; }
7608
- lineStr = chunk.content + lineStr;
7609
- }
7610
-
7611
- if (chunk.intro.length > 0) {
7612
- lineIndex = chunk.intro.lastIndexOf(n);
7613
- if (lineIndex !== -1)
7614
- { return chunk.intro.substr(lineIndex + 1) + lineStr; }
7615
- lineStr = chunk.intro + lineStr;
7616
- }
7617
- } while (chunk = chunk.previous);
7618
- lineIndex = this.intro.lastIndexOf(n);
7619
- if (lineIndex !== -1)
7620
- { return this.intro.substr(lineIndex + 1) + lineStr; }
7621
- return this.intro + lineStr;
7622
- };
7623
-
7624
- MagicString.prototype.slice = function slice (start, end) {
7625
- if ( start === void 0 ) start = 0;
7626
- if ( end === void 0 ) end = this.original.length;
7627
-
7628
- while (start < 0) { start += this.original.length; }
7629
- while (end < 0) { end += this.original.length; }
7630
-
7631
- var result = '';
7632
-
7633
- // find start chunk
7634
- var chunk = this.firstChunk;
7635
- while (chunk && (chunk.start > start || chunk.end <= start)) {
7636
- // found end chunk before start
7637
- if (chunk.start < end && chunk.end >= end) {
7638
- return result;
7639
- }
7640
-
7641
- chunk = chunk.next;
7642
- }
7643
-
7644
- if (chunk && chunk.edited && chunk.start !== start)
7645
- { throw new Error(("Cannot use replaced character " + start + " as slice start anchor.")); }
7646
-
7647
- var startChunk = chunk;
7648
- while (chunk) {
7649
- if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
7650
- result += chunk.intro;
7651
- }
7652
-
7653
- var containsEnd = chunk.start < end && chunk.end >= end;
7654
- if (containsEnd && chunk.edited && chunk.end !== end)
7655
- { throw new Error(("Cannot use replaced character " + end + " as slice end anchor.")); }
7656
-
7657
- var sliceStart = startChunk === chunk ? start - chunk.start : 0;
7658
- var sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
7659
-
7660
- result += chunk.content.slice(sliceStart, sliceEnd);
7661
-
7662
- if (chunk.outro && (!containsEnd || chunk.end === end)) {
7663
- result += chunk.outro;
7664
- }
7665
-
7666
- if (containsEnd) {
7667
- break;
7668
- }
7669
-
7670
- chunk = chunk.next;
7671
- }
7672
-
7673
- return result;
7674
- };
7675
-
7676
- // TODO deprecate this? not really very useful
7677
- MagicString.prototype.snip = function snip (start, end) {
7678
- var clone = this.clone();
7679
- clone.remove(0, start);
7680
- clone.remove(end, clone.original.length);
7681
-
7682
- return clone;
7683
- };
7684
-
7685
- MagicString.prototype._split = function _split (index) {
7686
- if (this.byStart[index] || this.byEnd[index]) { return; }
7687
-
7688
- var chunk = this.lastSearchedChunk;
7689
- var searchForward = index > chunk.end;
7690
-
7691
- while (chunk) {
7692
- if (chunk.contains(index)) { return this._splitChunk(chunk, index); }
7693
-
7694
- chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
7695
- }
7696
- };
7697
-
7698
- MagicString.prototype._splitChunk = function _splitChunk (chunk, index) {
7699
- if (chunk.edited && chunk.content.length) {
7700
- // zero-length edited chunks are a special case (overlapping replacements)
7701
- var loc = getLocator(this.original)(index);
7702
- throw new Error(
7703
- ("Cannot split a chunk that has already been edited (" + (loc.line) + ":" + (loc.column) + " – \"" + (chunk.original) + "\")")
7704
- );
7705
- }
7706
-
7707
- var newChunk = chunk.split(index);
7708
-
7709
- this.byEnd[index] = chunk;
7710
- this.byStart[index] = newChunk;
7711
- this.byEnd[newChunk.end] = newChunk;
7712
-
7713
- if (chunk === this.lastChunk) { this.lastChunk = newChunk; }
7714
-
7715
- this.lastSearchedChunk = chunk;
7716
- return true;
7717
- };
7718
-
7719
- MagicString.prototype.toString = function toString () {
7720
- var str = this.intro;
7721
-
7722
- var chunk = this.firstChunk;
7723
- while (chunk) {
7724
- str += chunk.toString();
7725
- chunk = chunk.next;
7726
- }
7727
-
7728
- return str + this.outro;
7729
- };
7730
-
7731
- MagicString.prototype.isEmpty = function isEmpty () {
7732
- var chunk = this.firstChunk;
7733
- do {
7734
- if (chunk.intro.length && chunk.intro.trim() ||
7735
- chunk.content.length && chunk.content.trim() ||
7736
- chunk.outro.length && chunk.outro.trim())
7737
- { return false; }
7738
- } while (chunk = chunk.next);
7739
- return true;
7740
- };
7741
-
7742
- MagicString.prototype.length = function length () {
7743
- var chunk = this.firstChunk;
7744
- var length = 0;
7745
- do {
7746
- length += chunk.intro.length + chunk.content.length + chunk.outro.length;
7747
- } while (chunk = chunk.next);
7748
- return length;
7749
- };
7750
-
7751
- MagicString.prototype.trimLines = function trimLines () {
7752
- return this.trim('[\\r\\n]');
7753
- };
7754
-
7755
- MagicString.prototype.trim = function trim (charType) {
7756
- return this.trimStart(charType).trimEnd(charType);
7757
- };
7758
-
7759
- MagicString.prototype.trimEndAborted = function trimEndAborted (charType) {
7760
- var rx = new RegExp((charType || '\\s') + '+$');
7761
-
7762
- this.outro = this.outro.replace(rx, '');
7763
- if (this.outro.length) { return true; }
7764
-
7765
- var chunk = this.lastChunk;
7766
-
7767
- do {
7768
- var end = chunk.end;
7769
- var aborted = chunk.trimEnd(rx);
7770
-
7771
- // if chunk was trimmed, we have a new lastChunk
7772
- if (chunk.end !== end) {
7773
- if (this.lastChunk === chunk) {
7774
- this.lastChunk = chunk.next;
7775
- }
7776
-
7777
- this.byEnd[chunk.end] = chunk;
7778
- this.byStart[chunk.next.start] = chunk.next;
7779
- this.byEnd[chunk.next.end] = chunk.next;
7780
- }
7781
-
7782
- if (aborted) { return true; }
7783
- chunk = chunk.previous;
7784
- } while (chunk);
7785
-
7786
- return false;
7787
- };
7788
-
7789
- MagicString.prototype.trimEnd = function trimEnd (charType) {
7790
- this.trimEndAborted(charType);
7791
- return this;
7792
- };
7793
- MagicString.prototype.trimStartAborted = function trimStartAborted (charType) {
7794
- var rx = new RegExp('^' + (charType || '\\s') + '+');
7795
-
7796
- this.intro = this.intro.replace(rx, '');
7797
- if (this.intro.length) { return true; }
7798
-
7799
- var chunk = this.firstChunk;
7800
-
7801
- do {
7802
- var end = chunk.end;
7803
- var aborted = chunk.trimStart(rx);
7804
-
7805
- if (chunk.end !== end) {
7806
- // special case...
7807
- if (chunk === this.lastChunk) { this.lastChunk = chunk.next; }
7808
-
7809
- this.byEnd[chunk.end] = chunk;
7810
- this.byStart[chunk.next.start] = chunk.next;
7811
- this.byEnd[chunk.next.end] = chunk.next;
7812
- }
7813
-
7814
- if (aborted) { return true; }
7815
- chunk = chunk.next;
7816
- } while (chunk);
7817
-
7818
- return false;
7819
- };
7820
-
7821
- MagicString.prototype.trimStart = function trimStart (charType) {
7822
- this.trimStartAborted(charType);
7823
- return this;
7824
- };
7825
-
7826
6756
  const mockRegexp = /\b((?:vitest|vi)\s*.\s*mock\(["`'\s](.*[@\w_-]+)["`'\s])[),]{1}/;
7827
6757
  const pathRegexp = /\b(?:vitest|vi)\s*.\s*(unmock|importActual|importMock)\(["`'\s](.*[@\w_-]+)["`'\s]\);?/mg;
7828
6758
  const isComment = (line) => {
@@ -8036,13 +6966,16 @@ function elegantSpinner() {
8036
6966
  }
8037
6967
 
8038
6968
  class BaseReporter {
8039
- constructor(ctx) {
8040
- this.ctx = ctx;
6969
+ constructor() {
8041
6970
  this.start = 0;
8042
6971
  this.end = 0;
8043
6972
  this.isTTY = process.stdout.isTTY && !process.env.CI;
6973
+ this.ctx = void 0;
8044
6974
  this.isFirstWatchRun = true;
8045
- const mode = ctx.config.watch ? c.yellow(" DEV ") : c.cyan(" RUN ");
6975
+ }
6976
+ onInit(ctx) {
6977
+ this.ctx = ctx;
6978
+ const mode = this.ctx.config.watch ? c.blue(" WATCH ") : c.cyan(" RUN ");
8046
6979
  this.ctx.log(`
8047
6980
  ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
8048
6981
  `);
@@ -8067,13 +7000,10 @@ ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
8067
7000
  }
8068
7001
  }
8069
7002
  async onWatcherStart() {
8070
- const failed = getTests(this.ctx.state.getFiles()).filter((i) => {
8071
- var _a;
8072
- return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
8073
- });
8074
- if (failed.length)
7003
+ const failed = hasFailed(this.ctx.state.getFiles());
7004
+ if (failed)
8075
7005
  this.ctx.log(`
8076
- ${c.bold(c.inverse(c.red(" FAIL ")))}${c.red(` ${failed.length} tests failed. Watching for file changes...`)}`);
7006
+ ${c.bold(c.inverse(c.red(" FAIL ")))}${c.red(" Tests failed. Watching for file changes...")}`);
8077
7007
  else
8078
7008
  this.ctx.log(`
8079
7009
  ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")}`);
@@ -8084,13 +7014,13 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
8084
7014
  }
8085
7015
  async onWatcherRerun(files, trigger) {
8086
7016
  this.watchFilters = files;
8087
- if (!this.ctx.config.silent) {
8088
- this.ctx.console.clear();
8089
- this.ctx.log(c.blue("Re-running tests...") + c.dim(` [ ${this.relative(trigger)} ]
7017
+ this.ctx.console.clear();
7018
+ this.ctx.log(c.blue("Re-running tests...") + c.dim(` [ ${this.relative(trigger)} ]
8090
7019
  `));
8091
- }
8092
7020
  }
8093
7021
  onUserConsoleLog(log) {
7022
+ if (this.ctx.config.silent)
7023
+ return;
8094
7024
  const task = log.taskId ? this.ctx.state.idMap[log.taskId] : void 0;
8095
7025
  this.ctx.log(c.gray(log.type + c.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
8096
7026
  process[log.type].write(`${log.content}
@@ -8100,16 +7030,15 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
8100
7030
  this.ctx.log(c.cyan("Restarted due to config changes..."));
8101
7031
  }
8102
7032
  async reportSummary(files) {
8103
- var _a, _b;
8104
7033
  const suites = getSuites(files);
8105
7034
  const tests = getTests(files);
8106
7035
  const failedSuites = suites.filter((i) => {
8107
- var _a2;
8108
- return (_a2 = i.result) == null ? void 0 : _a2.error;
7036
+ var _a;
7037
+ return (_a = i.result) == null ? void 0 : _a.error;
8109
7038
  });
8110
7039
  const failedTests = tests.filter((i) => {
8111
- var _a2;
8112
- return ((_a2 = i.result) == null ? void 0 : _a2.state) === "fail";
7040
+ var _a;
7041
+ return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
8113
7042
  });
8114
7043
  const failedTotal = failedSuites.length + failedTests.length;
8115
7044
  let current = 1;
@@ -8118,27 +7047,17 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
8118
7047
  if (failedSuites.length) {
8119
7048
  this.ctx.error(c.red(divider(c.bold(c.inverse(` Failed Suites ${failedSuites.length} `)))));
8120
7049
  this.ctx.error();
8121
- for (const suite of failedSuites) {
8122
- const filepath = (suite == null ? void 0 : suite.filepath) || "";
8123
- this.ctx.error(c.red(`
8124
- - ${getFullName(suite)} ${c.dim(`[ ${this.relative(filepath)} ]`)}`));
8125
- await printError((_a = suite.result) == null ? void 0 : _a.error, this.ctx);
8126
- errorDivider();
8127
- }
7050
+ await this.printTaskErrors(failedSuites, errorDivider);
8128
7051
  }
8129
7052
  if (failedTests.length) {
8130
7053
  this.ctx.error(c.red(divider(c.bold(c.inverse(` Failed Tests ${failedTests.length} `)))));
8131
7054
  this.ctx.error();
8132
- for (const test of failedTests) {
8133
- this.ctx.error(`${c.red(c.bold(c.inverse(" FAIL ")))} ${getFullName(test)}`);
8134
- await printError((_b = test.result) == null ? void 0 : _b.error, this.ctx);
8135
- errorDivider();
8136
- }
7055
+ await this.printTaskErrors(failedTests, errorDivider);
8137
7056
  }
8138
7057
  const executionTime = this.end - this.start;
8139
7058
  const threadTime = tests.reduce((acc, test) => {
8140
- var _a2;
8141
- return acc + (((_a2 = test.result) == null ? void 0 : _a2.end) ? test.result.end - test.result.start : 0);
7059
+ var _a;
7060
+ return acc + (((_a = test.result) == null ? void 0 : _a.end) ? test.result.end - test.result.start : 0);
8142
7061
  }, 0);
8143
7062
  const padTitle = (str) => c.dim(`${str.padStart(10)} `);
8144
7063
  const time = (time2) => {
@@ -8160,6 +7079,32 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
8160
7079
  this.ctx.log(padTitle("Time"), time(executionTime) + c.gray(` (in thread ${time(threadTime)}, ${(executionTime / threadTime * 100).toFixed(2)}%)`));
8161
7080
  this.ctx.log();
8162
7081
  }
7082
+ async printTaskErrors(tasks, errorDivider) {
7083
+ var _a;
7084
+ const errorsQueue = [];
7085
+ for (const task of tasks) {
7086
+ const error = (_a = task.result) == null ? void 0 : _a.error;
7087
+ const errorItem = (error == null ? void 0 : error.stackStr) && errorsQueue.find((i) => {
7088
+ var _a2;
7089
+ return ((_a2 = i[0]) == null ? void 0 : _a2.stackStr) === error.stackStr;
7090
+ });
7091
+ if (errorItem)
7092
+ errorItem[1].push(task);
7093
+ else
7094
+ errorsQueue.push([error, [task]]);
7095
+ }
7096
+ for (const [error, tasks2] of errorsQueue) {
7097
+ for (const task of tasks2) {
7098
+ const filepath = (task == null ? void 0 : task.filepath) || "";
7099
+ let name = getFullName(task);
7100
+ if (filepath)
7101
+ name = `${name} ${c.dim(`[ ${this.relative(filepath)} ]`)}`;
7102
+ this.ctx.error(`${c.red(c.bold(c.inverse(" FAIL ")))} ${name}`);
7103
+ }
7104
+ await printError(error, this.ctx);
7105
+ errorDivider();
7106
+ }
7107
+ }
8163
7108
  }
8164
7109
 
8165
7110
  const ESC = '\u001B[';
@@ -8698,11 +7643,10 @@ function renderTree(tasks, options, level = 0) {
8698
7643
  }
8699
7644
  return output.slice(0, MAX_HEIGHT).join("\n");
8700
7645
  }
8701
- const createListRenderer = (_tasks, options = {}) => {
7646
+ const createListRenderer = (_tasks, options) => {
8702
7647
  let tasks = _tasks;
8703
7648
  let timer;
8704
- const stdout = process.stdout;
8705
- const log = createLogUpdate(stdout);
7649
+ const log = createLogUpdate(options.outputStream);
8706
7650
  function update() {
8707
7651
  log(renderTree(tasks, options));
8708
7652
  }
@@ -8724,7 +7668,7 @@ const createListRenderer = (_tasks, options = {}) => {
8724
7668
  timer = void 0;
8725
7669
  }
8726
7670
  log.clear();
8727
- stdout.write(`${renderTree(tasks, options)}
7671
+ options.outputStream.write(`${renderTree(tasks, options)}
8728
7672
  `);
8729
7673
  return this;
8730
7674
  },
@@ -8741,6 +7685,7 @@ class DefaultReporter extends BaseReporter {
8741
7685
  }
8742
7686
  onStart() {
8743
7687
  if (this.isTTY) {
7688
+ this.rendererOptions.outputStream = this.ctx.outputStream;
8744
7689
  const files = this.ctx.state.getFiles(this.watchFilters);
8745
7690
  if (!this.renderer)
8746
7691
  this.renderer = createListRenderer(files, this.rendererOptions).start();
@@ -8794,11 +7739,10 @@ function render(tasks) {
8794
7739
  }
8795
7740
  }).join("");
8796
7741
  }
8797
- const createDotRenderer = (_tasks) => {
7742
+ const createDotRenderer = (_tasks, options) => {
8798
7743
  let tasks = _tasks;
8799
7744
  let timer;
8800
- const stdout = process.stdout;
8801
- const log = createLogUpdate(stdout);
7745
+ const log = createLogUpdate(options.outputStream);
8802
7746
  function update() {
8803
7747
  log(render(tasks));
8804
7748
  }
@@ -8820,7 +7764,7 @@ const createDotRenderer = (_tasks) => {
8820
7764
  timer = void 0;
8821
7765
  }
8822
7766
  log.clear();
8823
- stdout.write(`${render(tasks)}
7767
+ options.outputStream.write(`${render(tasks)}
8824
7768
  `);
8825
7769
  return this;
8826
7770
  },
@@ -8835,7 +7779,7 @@ class DotReporter extends BaseReporter {
8835
7779
  if (this.isTTY) {
8836
7780
  const files = this.ctx.state.getFiles(this.watchFilters);
8837
7781
  if (!this.renderer)
8838
- this.renderer = createDotRenderer(files).start();
7782
+ this.renderer = createDotRenderer(files, { outputStream: this.ctx.outputStream }).start();
8839
7783
  else
8840
7784
  this.renderer.update(files);
8841
7785
  }
@@ -8867,8 +7811,8 @@ class DotReporter extends BaseReporter {
8867
7811
  }
8868
7812
 
8869
7813
  class VerboseReporter extends DefaultReporter {
8870
- constructor(ctx) {
8871
- super(ctx);
7814
+ constructor() {
7815
+ super();
8872
7816
  this.rendererOptions.renderSucceed = true;
8873
7817
  }
8874
7818
  }
@@ -8879,6 +7823,80 @@ const ReportersMap = {
8879
7823
  dot: DotReporter
8880
7824
  };
8881
7825
 
7826
+ var __defProp$1 = Object.defineProperty;
7827
+ var __defProps$1 = Object.defineProperties;
7828
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
7829
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
7830
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
7831
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
7832
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7833
+ var __spreadValues$1 = (a, b) => {
7834
+ for (var prop in b || (b = {}))
7835
+ if (__hasOwnProp$1.call(b, prop))
7836
+ __defNormalProp$1(a, prop, b[prop]);
7837
+ if (__getOwnPropSymbols$1)
7838
+ for (var prop of __getOwnPropSymbols$1(b)) {
7839
+ if (__propIsEnum$1.call(b, prop))
7840
+ __defNormalProp$1(a, prop, b[prop]);
7841
+ }
7842
+ return a;
7843
+ };
7844
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
7845
+ const defaultExcludes = [
7846
+ "coverage/**",
7847
+ "packages/*/test{,s}/**",
7848
+ "**/*.d.ts",
7849
+ "test{,s}/**",
7850
+ "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
7851
+ "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
7852
+ "**/__tests__/**",
7853
+ "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc}.config.{js,cjs,mjs,ts}",
7854
+ "**/.{eslint,mocha}rc.{js,cjs}"
7855
+ ];
7856
+ function resolveC8Options(options, root) {
7857
+ const resolved = __spreadValues$1({
7858
+ enabled: false,
7859
+ clean: true,
7860
+ cleanOnRerun: false,
7861
+ reportsDirectory: "./coverage",
7862
+ excludeNodeModules: true,
7863
+ exclude: defaultExcludes,
7864
+ reporter: "text",
7865
+ allowExternal: false
7866
+ }, options);
7867
+ resolved.reporter = toArray(resolved.reporter);
7868
+ resolved.reportsDirectory = resolve(root, resolved.reportsDirectory);
7869
+ resolved.tempDirectory = process.env.NODE_V8_COVERAGE || resolve(resolved.reportsDirectory, "tmp");
7870
+ return resolved;
7871
+ }
7872
+ async function cleanCoverage(options, clean = true) {
7873
+ if (clean && existsSync(options.reportsDirectory))
7874
+ await promises.rmdir(options.reportsDirectory, { recursive: true });
7875
+ if (!existsSync(options.tempDirectory))
7876
+ await promises.mkdir(options.tempDirectory, { recursive: true });
7877
+ }
7878
+ async function prepareCoverage(options) {
7879
+ if (options.enabled)
7880
+ return false;
7881
+ await cleanCoverage(options, options.clean);
7882
+ }
7883
+ const require2 = createRequire(import.meta.url);
7884
+ async function reportCoverage(ctx) {
7885
+ const createReport = require2("c8/lib/report");
7886
+ const report = createReport(ctx.config.coverage);
7887
+ Array.from(ctx.visitedFilesMap.entries()).filter((i) => !i[0].includes("/node_modules/")).forEach(([file, map]) => {
7888
+ if (!existsSync(file))
7889
+ return;
7890
+ const url = pathToFileURL(file).href;
7891
+ report.sourceMapCache[url] = {
7892
+ data: __spreadProps$1(__spreadValues$1({}, map), {
7893
+ sources: map.sources.map((i) => pathToFileURL(i).href) || [url]
7894
+ })
7895
+ };
7896
+ });
7897
+ await report.run();
7898
+ }
7899
+
8882
7900
  class StateManager {
8883
7901
  constructor() {
8884
7902
  this.filesMap = {};
@@ -8937,9 +7955,10 @@ function resolveConfig(options, viteConfig) {
8937
7955
  var _a, _b;
8938
7956
  if (options.dom)
8939
7957
  options.environment = "happy-dom";
8940
- const resolved = __spreadProps(__spreadValues(__spreadValues({}, options), viteConfig.test), {
7958
+ const resolved = __spreadProps(__spreadValues({}, deepMerge(options, viteConfig.test)), {
8941
7959
  root: viteConfig.root
8942
7960
  });
7961
+ resolved.coverage = resolveC8Options(resolved.coverage, resolved.root);
8943
7962
  resolved.depsInline = [...((_a = resolved.deps) == null ? void 0 : _a.inline) || []];
8944
7963
  resolved.depsExternal = [...((_b = resolved.deps) == null ? void 0 : _b.external) || []];
8945
7964
  resolved.environment = resolved.environment || "node";
@@ -8952,6 +7971,7 @@ function resolveConfig(options, viteConfig) {
8952
7971
  resolved.exclude = resolved.exclude ?? defaultExclude;
8953
7972
  resolved.testTimeout = resolved.testTimeout ?? 5e3;
8954
7973
  resolved.hookTimeout = resolved.hookTimeout ?? 1e4;
7974
+ resolved.isolate = resolved.isolate ?? true;
8955
7975
  resolved.watchIgnore = resolved.watchIgnore ?? [/\/node_modules\//, /\/dist\//];
8956
7976
  const CI = !!process.env.CI;
8957
7977
  const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
@@ -8987,9 +8007,12 @@ async function _transformRequest(ctx, id) {
8987
8007
  if (result)
8988
8008
  result = await ctx.server.ssrTransform(result.code, result.map, id);
8989
8009
  }
8990
- if (result && process.env.NODE_V8_COVERAGE)
8010
+ if (result && process.env.NODE_V8_COVERAGE) {
8991
8011
  withInlineSourcemap(result);
8992
- return result == null ? void 0 : result.code;
8012
+ if (result.map)
8013
+ ctx.visitedFilesMap.set(toFilePath(id, ctx.config.root), result.map);
8014
+ }
8015
+ return result;
8993
8016
  }
8994
8017
  let SOURCEMAPPING_URL = "sourceMa";
8995
8018
  SOURCEMAPPING_URL += "ppingURL";
@@ -9037,14 +8060,16 @@ function createFakePool(ctx) {
9037
8060
  function createWorkerPool(ctx) {
9038
8061
  const options = {
9039
8062
  filename: workerPath,
9040
- isolateWorkers: true,
9041
- concurrentTasksPerWorker: 1,
9042
8063
  useAtomics: false
9043
8064
  };
9044
8065
  if (ctx.config.maxThreads != null)
9045
8066
  options.maxThreads = ctx.config.maxThreads;
9046
8067
  if (ctx.config.minThreads != null)
9047
8068
  options.minThreads = ctx.config.minThreads;
8069
+ if (ctx.config.isolate) {
8070
+ options.isolateWorkers = true;
8071
+ options.concurrentTasksPerWorker = 1;
8072
+ }
9048
8073
  const pool = new Tinypool(options);
9049
8074
  const runWithFiles = (name) => {
9050
8075
  return async (files, invalidates) => {
@@ -9072,44 +8097,45 @@ function createChannel(ctx) {
9072
8097
  const channel = new MessageChannel();
9073
8098
  const port = channel.port2;
9074
8099
  const workerPort = channel.port1;
9075
- port.on("message", async ({ id, method, args = [] }) => {
9076
- async function send(fn) {
9077
- try {
9078
- port.postMessage({ id, result: await fn() });
9079
- } catch (e) {
9080
- port.postMessage({ id, error: e });
8100
+ createBirpc({
8101
+ functions: {
8102
+ onWorkerExit(code) {
8103
+ process.exit(code || 1);
8104
+ },
8105
+ snapshotSaved(snapshot) {
8106
+ ctx.snapshot.add(snapshot);
8107
+ },
8108
+ async getSourceMap(id, force) {
8109
+ if (force) {
8110
+ const mod = ctx.server.moduleGraph.getModuleById(id);
8111
+ if (mod)
8112
+ ctx.server.moduleGraph.invalidateModule(mod);
8113
+ }
8114
+ const r = await transformRequest(ctx, id);
8115
+ return r == null ? void 0 : r.map;
8116
+ },
8117
+ async fetch(id) {
8118
+ const r = await transformRequest(ctx, id);
8119
+ return r == null ? void 0 : r.code;
8120
+ },
8121
+ onCollected(files) {
8122
+ ctx.state.collectFiles(files);
8123
+ ctx.report("onStart", files.map((i) => i.filepath));
8124
+ },
8125
+ onTaskUpdate(pack) {
8126
+ ctx.state.updateTasks([pack]);
8127
+ ctx.report("onTaskUpdate", pack);
8128
+ },
8129
+ onUserLog(msg) {
8130
+ ctx.report("onUserConsoleLog", msg);
9081
8131
  }
8132
+ },
8133
+ post(v) {
8134
+ port.postMessage(v);
8135
+ },
8136
+ on(fn) {
8137
+ port.on("message", fn);
9082
8138
  }
9083
- switch (method) {
9084
- case "processExit":
9085
- process.exit(args[0] || 1);
9086
- return;
9087
- case "snapshotSaved":
9088
- return send(() => ctx.snapshot.add(args[0]));
9089
- case "fetch":
9090
- return send(() => transformRequest(ctx, ...args));
9091
- case "onCollected":
9092
- ctx.state.collectFiles(args[0]);
9093
- ctx.reporters.forEach((r) => {
9094
- var _a;
9095
- return (_a = r.onStart) == null ? void 0 : _a.call(r, args[0].map((i) => i.filepath));
9096
- });
9097
- return;
9098
- case "onTaskUpdate":
9099
- ctx.state.updateTasks([args[0]]);
9100
- ctx.reporters.forEach((r) => {
9101
- var _a;
9102
- return (_a = r.onTaskUpdate) == null ? void 0 : _a.call(r, args[0]);
9103
- });
9104
- return;
9105
- case "log":
9106
- ctx.reporters.forEach((r) => {
9107
- var _a;
9108
- return (_a = r.onUserConsoleLog) == null ? void 0 : _a.call(r, args[0]);
9109
- });
9110
- return;
9111
- }
9112
- console.error("Unhandled message", method, args);
9113
8139
  });
9114
8140
  return { workerPort, port };
9115
8141
  }
@@ -9122,15 +8148,18 @@ class Vitest {
9122
8148
  this.state = void 0;
9123
8149
  this.snapshot = void 0;
9124
8150
  this.reporters = void 0;
8151
+ this.outputStream = process.stdout;
8152
+ this.errorStream = process.stderr;
9125
8153
  this.invalidates = /* @__PURE__ */ new Set();
9126
8154
  this.changedTests = /* @__PURE__ */ new Set();
8155
+ this.visitedFilesMap = /* @__PURE__ */ new Map();
9127
8156
  this.isFirstRun = true;
9128
8157
  this.restartsCount = 0;
9129
8158
  this._onRestartListeners = [];
9130
8159
  this.unregisterWatcher = noop$1;
9131
8160
  this.console = globalThis.console;
9132
8161
  }
9133
- setServer(options, server) {
8162
+ async setServer(options, server) {
9134
8163
  var _a, _b;
9135
8164
  (_a = this.unregisterWatcher) == null ? void 0 : _a.call(this);
9136
8165
  clearTimeout(this._rerunTimer);
@@ -9147,18 +8176,21 @@ class Vitest {
9147
8176
  const Reporter = ReportersMap[i];
9148
8177
  if (!Reporter)
9149
8178
  throw new Error(`Unknown reporter: ${i}`);
9150
- return new Reporter(this);
8179
+ return new Reporter();
9151
8180
  }
9152
8181
  return i;
9153
8182
  });
9154
- if (!this.reporters.length && !this.config.silent)
9155
- this.reporters.push(new DefaultReporter(this));
8183
+ if (!this.reporters.length)
8184
+ this.reporters.push(new DefaultReporter());
9156
8185
  if (this.config.watch)
9157
8186
  this.registerWatcher();
9158
8187
  this.runningPromise = void 0;
9159
8188
  this._onRestartListeners.forEach((fn) => fn());
8189
+ if (resolved.coverage.enabled)
8190
+ await prepareCoverage(resolved.coverage);
9160
8191
  }
9161
8192
  async start(filters) {
8193
+ this.report("onInit", this);
9162
8194
  const files = await this.globTestFiles(filters);
9163
8195
  if (!files.length) {
9164
8196
  if (this.config.passWithNoTests)
@@ -9170,6 +8202,8 @@ class Vitest {
9170
8202
  await this.runFiles(files);
9171
8203
  if (this.config.watch)
9172
8204
  await this.report("onWatcherStart");
8205
+ if (this.config.coverage.enabled)
8206
+ await reportCoverage(this);
9173
8207
  }
9174
8208
  async runFiles(files) {
9175
8209
  await this.runningPromise;
@@ -9188,13 +8222,9 @@ class Vitest {
9188
8222
  return await this.runningPromise;
9189
8223
  }
9190
8224
  log(...args) {
9191
- if (this.config.silent)
9192
- return;
9193
8225
  this.console.log(...args);
9194
8226
  }
9195
8227
  error(...args) {
9196
- if (this.config.silent)
9197
- return;
9198
8228
  this.console.error(...args);
9199
8229
  }
9200
8230
  async scheduleRerun(triggerId) {
@@ -9215,9 +8245,14 @@ class Vitest {
9215
8245
  this.snapshot.clear();
9216
8246
  const files = Array.from(this.changedTests);
9217
8247
  this.changedTests.clear();
8248
+ this.console.log("return");
8249
+ if (this.config.coverage.enabled && this.config.coverage.cleanOnRerun)
8250
+ await cleanCoverage(this.config.coverage);
9218
8251
  await this.report("onWatcherRerun", files, triggerId);
9219
8252
  await this.runFiles(files);
9220
8253
  await this.report("onWatcherStart");
8254
+ if (this.config.coverage.enabled)
8255
+ await reportCoverage(this);
9221
8256
  }, WATCHER_DEBOUNCE);
9222
8257
  }
9223
8258
  registerWatcher() {
@@ -9315,10 +8350,10 @@ async function createVitest(options, viteOverrides = {}) {
9315
8350
  async configureServer(server2) {
9316
8351
  if (haveStarted)
9317
8352
  await ctx.report("onServerRestart");
9318
- ctx.setServer(options, server2);
8353
+ await ctx.setServer(options, server2);
9319
8354
  haveStarted = true;
9320
8355
  if (options.api)
9321
- server2.middlewares.use((await import('./middleware-2028dfa0.js')).default(ctx));
8356
+ server2.middlewares.use((await import('./middleware-647438b9.js')).default(ctx));
9322
8357
  }
9323
8358
  },
9324
8359
  MocksPlugin()