@vitest/coverage-v8 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/provider.js CHANGED
@@ -1,5 +1,5 @@
1
- import { existsSync, promises as promises$1, readdirSync, writeFileSync } from 'node:fs';
2
- import { pathToFileURL, fileURLToPath as fileURLToPath$1 } from 'node:url';
1
+ import { pathToFileURL, fileURLToPath } from 'node:url';
2
+ import { promises } from 'node:fs';
3
3
  import require$$0 from 'assert';
4
4
  import require$$2 from 'util';
5
5
  import require$$3 from 'path';
@@ -7,263 +7,267 @@ import require$$4 from 'url';
7
7
  import require$$9 from 'fs';
8
8
  import require$$11 from 'module';
9
9
  import { mergeProcessCovs } from '@bcoe/v8-coverage';
10
- import libReport from 'istanbul-lib-report';
11
- import reports from 'istanbul-reports';
12
10
  import libCoverage from 'istanbul-lib-coverage';
11
+ import libReport from 'istanbul-lib-report';
13
12
  import libSourceMaps from 'istanbul-lib-source-maps';
14
- import MagicString from 'magic-string';
15
- import { parseModule } from 'magicast';
16
- import remapping from '@ampproject/remapping';
17
- import c from 'tinyrainbow';
13
+ import reports from 'istanbul-reports';
18
14
  import { provider } from 'std-env';
15
+ import c from 'tinyrainbow';
19
16
  import createDebug from 'debug';
20
- import { builtinModules } from 'node:module';
21
- import { coverageConfigDefaults } from 'vitest/config';
17
+ import MagicString from 'magic-string';
18
+ import TestExclude from 'test-exclude';
19
+ import remapping from '@ampproject/remapping';
22
20
  import { BaseCoverageProvider } from 'vitest/coverage';
23
- import _TestExclude from 'test-exclude';
24
-
25
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
21
+ import { builtinModules } from 'node:module';
22
+ import { parseModule } from 'magicast';
26
23
 
27
24
  function getDefaultExportFromCjs (x) {
28
25
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
29
26
  }
30
27
 
31
- var convertSourceMap$1 = {};
32
-
33
- (function (exports) {
34
-
35
- Object.defineProperty(exports, 'commentRegex', {
36
- get: function getCommentRegex () {
37
- // Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
38
- return /^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg;
39
- }
40
- });
41
-
42
-
43
- Object.defineProperty(exports, 'mapFileCommentRegex', {
44
- get: function getMapFileCommentRegex () {
45
- // Matches sourceMappingURL in either // or /* comment styles.
46
- return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg;
47
- }
48
- });
49
-
50
- var decodeBase64;
51
- if (typeof Buffer !== 'undefined') {
52
- if (typeof Buffer.from === 'function') {
53
- decodeBase64 = decodeBase64WithBufferFrom;
54
- } else {
55
- decodeBase64 = decodeBase64WithNewBuffer;
56
- }
57
- } else {
58
- decodeBase64 = decodeBase64WithAtob;
59
- }
60
-
61
- function decodeBase64WithBufferFrom(base64) {
62
- return Buffer.from(base64, 'base64').toString();
63
- }
64
-
65
- function decodeBase64WithNewBuffer(base64) {
66
- if (typeof value === 'number') {
67
- throw new TypeError('The value to decode must not be of type number.');
68
- }
69
- return new Buffer(base64, 'base64').toString();
70
- }
71
-
72
- function decodeBase64WithAtob(base64) {
73
- return decodeURIComponent(escape(atob(base64)));
74
- }
75
-
76
- function stripComment(sm) {
77
- return sm.split(',').pop();
78
- }
79
-
80
- function readFromFileMap(sm, read) {
81
- var r = exports.mapFileCommentRegex.exec(sm);
82
- // for some odd reason //# .. captures in 1 and /* .. */ in 2
83
- var filename = r[1] || r[2];
84
-
85
- try {
86
- var sm = read(filename);
87
- if (sm != null && typeof sm.catch === 'function') {
88
- return sm.catch(throwError);
89
- } else {
90
- return sm;
91
- }
92
- } catch (e) {
93
- throwError(e);
94
- }
95
-
96
- function throwError(e) {
97
- throw new Error('An error occurred while trying to read the map file at ' + filename + '\n' + e.stack);
98
- }
99
- }
100
-
101
- function Converter (sm, opts) {
102
- opts = opts || {};
103
-
104
- if (opts.hasComment) {
105
- sm = stripComment(sm);
106
- }
107
-
108
- if (opts.encoding === 'base64') {
109
- sm = decodeBase64(sm);
110
- } else if (opts.encoding === 'uri') {
111
- sm = decodeURIComponent(sm);
112
- }
113
-
114
- if (opts.isJSON || opts.encoding) {
115
- sm = JSON.parse(sm);
116
- }
117
-
118
- this.sourcemap = sm;
119
- }
120
-
121
- Converter.prototype.toJSON = function (space) {
122
- return JSON.stringify(this.sourcemap, null, space);
123
- };
124
-
125
- if (typeof Buffer !== 'undefined') {
126
- if (typeof Buffer.from === 'function') {
127
- Converter.prototype.toBase64 = encodeBase64WithBufferFrom;
128
- } else {
129
- Converter.prototype.toBase64 = encodeBase64WithNewBuffer;
130
- }
131
- } else {
132
- Converter.prototype.toBase64 = encodeBase64WithBtoa;
133
- }
134
-
135
- function encodeBase64WithBufferFrom() {
136
- var json = this.toJSON();
137
- return Buffer.from(json, 'utf8').toString('base64');
138
- }
139
-
140
- function encodeBase64WithNewBuffer() {
141
- var json = this.toJSON();
142
- if (typeof json === 'number') {
143
- throw new TypeError('The json to encode must not be of type number.');
144
- }
145
- return new Buffer(json, 'utf8').toString('base64');
146
- }
147
-
148
- function encodeBase64WithBtoa() {
149
- var json = this.toJSON();
150
- return btoa(unescape(encodeURIComponent(json)));
151
- }
152
-
153
- Converter.prototype.toURI = function () {
154
- var json = this.toJSON();
155
- return encodeURIComponent(json);
156
- };
157
-
158
- Converter.prototype.toComment = function (options) {
159
- var encoding, content, data;
160
- if (options != null && options.encoding === 'uri') {
161
- encoding = '';
162
- content = this.toURI();
163
- } else {
164
- encoding = ';base64';
165
- content = this.toBase64();
166
- }
167
- data = 'sourceMappingURL=data:application/json;charset=utf-8' + encoding + ',' + content;
168
- return options != null && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
169
- };
170
-
171
- // returns copy instead of original
172
- Converter.prototype.toObject = function () {
173
- return JSON.parse(this.toJSON());
174
- };
175
-
176
- Converter.prototype.addProperty = function (key, value) {
177
- if (this.sourcemap.hasOwnProperty(key)) throw new Error('property "' + key + '" already exists on the sourcemap, use set property instead');
178
- return this.setProperty(key, value);
179
- };
180
-
181
- Converter.prototype.setProperty = function (key, value) {
182
- this.sourcemap[key] = value;
183
- return this;
184
- };
185
-
186
- Converter.prototype.getProperty = function (key) {
187
- return this.sourcemap[key];
188
- };
189
-
190
- exports.fromObject = function (obj) {
191
- return new Converter(obj);
192
- };
193
-
194
- exports.fromJSON = function (json) {
195
- return new Converter(json, { isJSON: true });
196
- };
197
-
198
- exports.fromURI = function (uri) {
199
- return new Converter(uri, { encoding: 'uri' });
200
- };
201
-
202
- exports.fromBase64 = function (base64) {
203
- return new Converter(base64, { encoding: 'base64' });
204
- };
205
-
206
- exports.fromComment = function (comment) {
207
- var m, encoding;
208
- comment = comment
209
- .replace(/^\/\*/g, '//')
210
- .replace(/\*\/$/g, '');
211
- m = exports.commentRegex.exec(comment);
212
- encoding = m && m[4] || 'uri';
213
- return new Converter(comment, { encoding: encoding, hasComment: true });
214
- };
215
-
216
- function makeConverter(sm) {
217
- return new Converter(sm, { isJSON: true });
218
- }
219
-
220
- exports.fromMapFileComment = function (comment, read) {
221
- if (typeof read === 'string') {
222
- throw new Error(
223
- 'String directory paths are no longer supported with `fromMapFileComment`\n' +
224
- 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
225
- )
226
- }
227
-
228
- var sm = readFromFileMap(comment, read);
229
- if (sm != null && typeof sm.then === 'function') {
230
- return sm.then(makeConverter);
231
- } else {
232
- return makeConverter(sm);
233
- }
234
- };
235
-
236
- // Finds last sourcemap comment in file or returns null if none was found
237
- exports.fromSource = function (content) {
238
- var m = content.match(exports.commentRegex);
239
- return m ? exports.fromComment(m.pop()) : null;
240
- };
241
-
242
- // Finds last sourcemap comment in file or returns null if none was found
243
- exports.fromMapFileSource = function (content, read) {
244
- if (typeof read === 'string') {
245
- throw new Error(
246
- 'String directory paths are no longer supported with `fromMapFileSource`\n' +
247
- 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
248
- )
249
- }
250
- var m = content.match(exports.mapFileCommentRegex);
251
- return m ? exports.fromMapFileComment(m.pop(), read) : null;
252
- };
253
-
254
- exports.removeComments = function (src) {
255
- return src.replace(exports.commentRegex, '');
256
- };
257
-
258
- exports.removeMapFileComments = function (src) {
259
- return src.replace(exports.mapFileCommentRegex, '');
260
- };
261
-
262
- exports.generateMapFileComment = function (file, options) {
263
- var data = 'sourceMappingURL=' + file;
264
- return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
265
- };
266
- } (convertSourceMap$1));
28
+ var convertSourceMap = {};
29
+
30
+ var hasRequiredConvertSourceMap;
31
+
32
+ function requireConvertSourceMap () {
33
+ if (hasRequiredConvertSourceMap) return convertSourceMap;
34
+ hasRequiredConvertSourceMap = 1;
35
+ (function (exports) {
36
+
37
+ Object.defineProperty(exports, 'commentRegex', {
38
+ get: function getCommentRegex () {
39
+ // Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
40
+ return /^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg;
41
+ }
42
+ });
43
+
44
+
45
+ Object.defineProperty(exports, 'mapFileCommentRegex', {
46
+ get: function getMapFileCommentRegex () {
47
+ // Matches sourceMappingURL in either // or /* comment styles.
48
+ return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg;
49
+ }
50
+ });
51
+
52
+ var decodeBase64;
53
+ if (typeof Buffer !== 'undefined') {
54
+ if (typeof Buffer.from === 'function') {
55
+ decodeBase64 = decodeBase64WithBufferFrom;
56
+ } else {
57
+ decodeBase64 = decodeBase64WithNewBuffer;
58
+ }
59
+ } else {
60
+ decodeBase64 = decodeBase64WithAtob;
61
+ }
62
+
63
+ function decodeBase64WithBufferFrom(base64) {
64
+ return Buffer.from(base64, 'base64').toString();
65
+ }
66
+
67
+ function decodeBase64WithNewBuffer(base64) {
68
+ if (typeof value === 'number') {
69
+ throw new TypeError('The value to decode must not be of type number.');
70
+ }
71
+ return new Buffer(base64, 'base64').toString();
72
+ }
73
+
74
+ function decodeBase64WithAtob(base64) {
75
+ return decodeURIComponent(escape(atob(base64)));
76
+ }
77
+
78
+ function stripComment(sm) {
79
+ return sm.split(',').pop();
80
+ }
81
+
82
+ function readFromFileMap(sm, read) {
83
+ var r = exports.mapFileCommentRegex.exec(sm);
84
+ // for some odd reason //# .. captures in 1 and /* .. */ in 2
85
+ var filename = r[1] || r[2];
86
+
87
+ try {
88
+ var sm = read(filename);
89
+ if (sm != null && typeof sm.catch === 'function') {
90
+ return sm.catch(throwError);
91
+ } else {
92
+ return sm;
93
+ }
94
+ } catch (e) {
95
+ throwError(e);
96
+ }
97
+
98
+ function throwError(e) {
99
+ throw new Error('An error occurred while trying to read the map file at ' + filename + '\n' + e.stack);
100
+ }
101
+ }
102
+
103
+ function Converter (sm, opts) {
104
+ opts = opts || {};
105
+
106
+ if (opts.hasComment) {
107
+ sm = stripComment(sm);
108
+ }
109
+
110
+ if (opts.encoding === 'base64') {
111
+ sm = decodeBase64(sm);
112
+ } else if (opts.encoding === 'uri') {
113
+ sm = decodeURIComponent(sm);
114
+ }
115
+
116
+ if (opts.isJSON || opts.encoding) {
117
+ sm = JSON.parse(sm);
118
+ }
119
+
120
+ this.sourcemap = sm;
121
+ }
122
+
123
+ Converter.prototype.toJSON = function (space) {
124
+ return JSON.stringify(this.sourcemap, null, space);
125
+ };
126
+
127
+ if (typeof Buffer !== 'undefined') {
128
+ if (typeof Buffer.from === 'function') {
129
+ Converter.prototype.toBase64 = encodeBase64WithBufferFrom;
130
+ } else {
131
+ Converter.prototype.toBase64 = encodeBase64WithNewBuffer;
132
+ }
133
+ } else {
134
+ Converter.prototype.toBase64 = encodeBase64WithBtoa;
135
+ }
136
+
137
+ function encodeBase64WithBufferFrom() {
138
+ var json = this.toJSON();
139
+ return Buffer.from(json, 'utf8').toString('base64');
140
+ }
141
+
142
+ function encodeBase64WithNewBuffer() {
143
+ var json = this.toJSON();
144
+ if (typeof json === 'number') {
145
+ throw new TypeError('The json to encode must not be of type number.');
146
+ }
147
+ return new Buffer(json, 'utf8').toString('base64');
148
+ }
149
+
150
+ function encodeBase64WithBtoa() {
151
+ var json = this.toJSON();
152
+ return btoa(unescape(encodeURIComponent(json)));
153
+ }
154
+
155
+ Converter.prototype.toURI = function () {
156
+ var json = this.toJSON();
157
+ return encodeURIComponent(json);
158
+ };
159
+
160
+ Converter.prototype.toComment = function (options) {
161
+ var encoding, content, data;
162
+ if (options != null && options.encoding === 'uri') {
163
+ encoding = '';
164
+ content = this.toURI();
165
+ } else {
166
+ encoding = ';base64';
167
+ content = this.toBase64();
168
+ }
169
+ data = 'sourceMappingURL=data:application/json;charset=utf-8' + encoding + ',' + content;
170
+ return options != null && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
171
+ };
172
+
173
+ // returns copy instead of original
174
+ Converter.prototype.toObject = function () {
175
+ return JSON.parse(this.toJSON());
176
+ };
177
+
178
+ Converter.prototype.addProperty = function (key, value) {
179
+ if (this.sourcemap.hasOwnProperty(key)) throw new Error('property "' + key + '" already exists on the sourcemap, use set property instead');
180
+ return this.setProperty(key, value);
181
+ };
182
+
183
+ Converter.prototype.setProperty = function (key, value) {
184
+ this.sourcemap[key] = value;
185
+ return this;
186
+ };
187
+
188
+ Converter.prototype.getProperty = function (key) {
189
+ return this.sourcemap[key];
190
+ };
191
+
192
+ exports.fromObject = function (obj) {
193
+ return new Converter(obj);
194
+ };
195
+
196
+ exports.fromJSON = function (json) {
197
+ return new Converter(json, { isJSON: true });
198
+ };
199
+
200
+ exports.fromURI = function (uri) {
201
+ return new Converter(uri, { encoding: 'uri' });
202
+ };
203
+
204
+ exports.fromBase64 = function (base64) {
205
+ return new Converter(base64, { encoding: 'base64' });
206
+ };
207
+
208
+ exports.fromComment = function (comment) {
209
+ var m, encoding;
210
+ comment = comment
211
+ .replace(/^\/\*/g, '//')
212
+ .replace(/\*\/$/g, '');
213
+ m = exports.commentRegex.exec(comment);
214
+ encoding = m && m[4] || 'uri';
215
+ return new Converter(comment, { encoding: encoding, hasComment: true });
216
+ };
217
+
218
+ function makeConverter(sm) {
219
+ return new Converter(sm, { isJSON: true });
220
+ }
221
+
222
+ exports.fromMapFileComment = function (comment, read) {
223
+ if (typeof read === 'string') {
224
+ throw new Error(
225
+ 'String directory paths are no longer supported with `fromMapFileComment`\n' +
226
+ 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
227
+ )
228
+ }
229
+
230
+ var sm = readFromFileMap(comment, read);
231
+ if (sm != null && typeof sm.then === 'function') {
232
+ return sm.then(makeConverter);
233
+ } else {
234
+ return makeConverter(sm);
235
+ }
236
+ };
237
+
238
+ // Finds last sourcemap comment in file or returns null if none was found
239
+ exports.fromSource = function (content) {
240
+ var m = content.match(exports.commentRegex);
241
+ return m ? exports.fromComment(m.pop()) : null;
242
+ };
243
+
244
+ // Finds last sourcemap comment in file or returns null if none was found
245
+ exports.fromMapFileSource = function (content, read) {
246
+ if (typeof read === 'string') {
247
+ throw new Error(
248
+ 'String directory paths are no longer supported with `fromMapFileSource`\n' +
249
+ 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
250
+ )
251
+ }
252
+ var m = content.match(exports.mapFileCommentRegex);
253
+ return m ? exports.fromMapFileComment(m.pop(), read) : null;
254
+ };
255
+
256
+ exports.removeComments = function (src) {
257
+ return src.replace(exports.commentRegex, '');
258
+ };
259
+
260
+ exports.removeMapFileComments = function (src) {
261
+ return src.replace(exports.mapFileCommentRegex, '');
262
+ };
263
+
264
+ exports.generateMapFileComment = function (file, options) {
265
+ var data = 'sourceMappingURL=' + file;
266
+ return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
267
+ };
268
+ } (convertSourceMap));
269
+ return convertSourceMap;
270
+ }
267
271
 
268
272
  var branch;
269
273
  var hasRequiredBranch;
@@ -429,19 +433,21 @@ function requireRange () {
429
433
  return range;
430
434
  }
431
435
 
432
- var traceMapping_umd = {exports: {}};
436
+ var traceMapping_umd$1 = {exports: {}};
437
+
438
+ var sourcemapCodec_umd$1 = {exports: {}};
433
439
 
434
- var sourcemapCodec_umd = {exports: {}};
440
+ var sourcemapCodec_umd = sourcemapCodec_umd$1.exports;
435
441
 
436
442
  var hasRequiredSourcemapCodec_umd;
437
443
 
438
444
  function requireSourcemapCodec_umd () {
439
- if (hasRequiredSourcemapCodec_umd) return sourcemapCodec_umd.exports;
445
+ if (hasRequiredSourcemapCodec_umd) return sourcemapCodec_umd$1.exports;
440
446
  hasRequiredSourcemapCodec_umd = 1;
441
447
  (function (module, exports) {
442
448
  (function (global, factory) {
443
449
  factory(exports) ;
444
- })(commonjsGlobal, (function (exports) {
450
+ })(sourcemapCodec_umd, (function (exports) {
445
451
  const comma = ','.charCodeAt(0);
446
452
  const semicolon = ';'.charCodeAt(0);
447
453
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
@@ -875,21 +881,23 @@ function requireSourcemapCodec_umd () {
875
881
 
876
882
  }));
877
883
 
878
- } (sourcemapCodec_umd, sourcemapCodec_umd.exports));
879
- return sourcemapCodec_umd.exports;
884
+ } (sourcemapCodec_umd$1, sourcemapCodec_umd$1.exports));
885
+ return sourcemapCodec_umd$1.exports;
880
886
  }
881
887
 
882
- var resolveUri_umd = {exports: {}};
888
+ var resolveUri_umd$1 = {exports: {}};
889
+
890
+ var resolveUri_umd = resolveUri_umd$1.exports;
883
891
 
884
892
  var hasRequiredResolveUri_umd;
885
893
 
886
894
  function requireResolveUri_umd () {
887
- if (hasRequiredResolveUri_umd) return resolveUri_umd.exports;
895
+ if (hasRequiredResolveUri_umd) return resolveUri_umd$1.exports;
888
896
  hasRequiredResolveUri_umd = 1;
889
897
  (function (module, exports) {
890
898
  (function (global, factory) {
891
899
  module.exports = factory() ;
892
- })(commonjsGlobal, (function () {
900
+ })(resolveUri_umd, (function () {
893
901
  // Matches the scheme of a URL, eg "http://"
894
902
  const schemeRegex = /^[\w+.-]+:\/\//;
895
903
  /**
@@ -1134,19 +1142,21 @@ function requireResolveUri_umd () {
1134
1142
 
1135
1143
  }));
1136
1144
 
1137
- } (resolveUri_umd));
1138
- return resolveUri_umd.exports;
1145
+ } (resolveUri_umd$1));
1146
+ return resolveUri_umd$1.exports;
1139
1147
  }
1140
1148
 
1149
+ var traceMapping_umd = traceMapping_umd$1.exports;
1150
+
1141
1151
  var hasRequiredTraceMapping_umd;
1142
1152
 
1143
1153
  function requireTraceMapping_umd () {
1144
- if (hasRequiredTraceMapping_umd) return traceMapping_umd.exports;
1154
+ if (hasRequiredTraceMapping_umd) return traceMapping_umd$1.exports;
1145
1155
  hasRequiredTraceMapping_umd = 1;
1146
1156
  (function (module, exports) {
1147
1157
  (function (global, factory) {
1148
1158
  factory(exports, requireSourcemapCodec_umd(), requireResolveUri_umd()) ;
1149
- })(commonjsGlobal, (function (exports, sourcemapCodec, resolveUri) {
1159
+ })(traceMapping_umd, (function (exports, sourcemapCodec, resolveUri) {
1150
1160
  function resolve(input, base) {
1151
1161
  // The base is always treated as a directory, if it's not empty.
1152
1162
  // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
@@ -1741,8 +1751,8 @@ function requireTraceMapping_umd () {
1741
1751
 
1742
1752
  }));
1743
1753
 
1744
- } (traceMapping_umd, traceMapping_umd.exports));
1745
- return traceMapping_umd.exports;
1754
+ } (traceMapping_umd$1, traceMapping_umd$1.exports));
1755
+ return traceMapping_umd$1.exports;
1746
1756
  }
1747
1757
 
1748
1758
  var source;
@@ -2029,337 +2039,354 @@ function requireSource () {
2029
2039
  return source;
2030
2040
  }
2031
2041
 
2032
- // Patch applied: https://github.com/istanbuljs/v8-to-istanbul/pull/244
2033
- const assert = require$$0;
2034
- const convertSourceMap = convertSourceMap$1;
2035
- const util = require$$2;
2036
- const debuglog = util.debuglog('c8');
2037
- const { dirname, isAbsolute: isAbsolute$1, join, resolve: resolve$1 } = require$$3;
2038
- const { fileURLToPath } = require$$4;
2039
- const CovBranch = requireBranch();
2040
- const CovFunction = require_function();
2041
- const CovSource = requireSource();
2042
- const { sliceRange } = requireRange();
2043
- const { readFileSync, promises } = require$$9;
2044
- const readFile = promises.readFile;
2045
-
2046
- const { TraceMap } = requireTraceMapping_umd();
2047
- const isOlderNode10 = /^v10\.(([0-9]\.)|(1[0-5]\.))/u.test(process.version);
2048
- const isNode8 = /^v8\./.test(process.version);
2049
-
2050
- // Injected when Node.js is loading script into isolate pre Node 10.16.x.
2051
- // see: https://github.com/nodejs/node/pull/21573.
2052
- const cjsWrapperLength = isOlderNode10 ? require$$11.wrapper[0].length : 0;
2053
-
2054
- var v8ToIstanbul$2 = class V8ToIstanbul {
2055
- constructor (scriptPath, wrapperLength, sources, excludePath, excludeEmptyLines) {
2056
- assert(typeof scriptPath === 'string', 'scriptPath must be a string');
2057
- assert(!isNode8, 'This module does not support node 8 or lower, please upgrade to node 10');
2058
- this.path = parsePath(scriptPath);
2059
- this.wrapperLength = wrapperLength === undefined ? cjsWrapperLength : wrapperLength;
2060
- this.excludePath = excludePath || (() => false);
2061
- this.excludeEmptyLines = excludeEmptyLines === true;
2062
- this.sources = sources || {};
2063
- this.generatedLines = [];
2064
- this.branches = {};
2065
- this.functions = {};
2066
- this.covSources = [];
2067
- this.rawSourceMap = undefined;
2068
- this.sourceMap = undefined;
2069
- this.sourceTranspiled = undefined;
2070
- // Indicate that this report was generated with placeholder data from
2071
- // running --all:
2072
- this.all = false;
2073
- }
2042
+ var v8ToIstanbul$2;
2043
+ var hasRequiredV8ToIstanbul$1;
2074
2044
 
2075
- async load () {
2076
- const rawSource = this.sources.source || await readFile(this.path, 'utf8');
2077
- this.rawSourceMap = this.sources.sourceMap ||
2078
- // if we find a source-map (either inline, or a .map file) we load
2079
- // both the transpiled and original source, both of which are used during
2080
- // the backflips we perform to remap absolute to relative positions.
2081
- convertSourceMap.fromSource(rawSource) || convertSourceMap.fromMapFileSource(rawSource, this._readFileFromDir.bind(this));
2082
-
2083
- if (this.rawSourceMap) {
2084
- if (this.rawSourceMap.sourcemap.sources.length > 1) {
2085
- this.sourceMap = new TraceMap(this.rawSourceMap.sourcemap);
2086
- if (!this.sourceMap.sourcesContent) {
2087
- this.sourceMap.sourcesContent = await this.sourcesContentFromSources();
2088
- }
2089
- this.covSources = this.sourceMap.sourcesContent.map((rawSource, i) => ({ source: new CovSource(rawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null), path: this.sourceMap.sources[i] }));
2090
- this.sourceTranspiled = new CovSource(rawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null);
2091
- } else {
2092
- const candidatePath = this.rawSourceMap.sourcemap.sources.length >= 1 ? this.rawSourceMap.sourcemap.sources[0] : this.rawSourceMap.sourcemap.file;
2093
- this.path = this._resolveSource(this.rawSourceMap, candidatePath || this.path);
2094
- this.sourceMap = new TraceMap(this.rawSourceMap.sourcemap);
2095
-
2096
- let originalRawSource;
2097
- if (this.sources.sourceMap && this.sources.sourceMap.sourcemap && this.sources.sourceMap.sourcemap.sourcesContent && this.sources.sourceMap.sourcemap.sourcesContent.length === 1) {
2098
- // If the sourcesContent field has been provided, return it rather than attempting
2099
- // to load the original source from disk.
2100
- // TODO: investigate whether there's ever a case where we hit this logic with 1:many sources.
2101
- originalRawSource = this.sources.sourceMap.sourcemap.sourcesContent[0];
2102
- } else if (this.sources.originalSource) {
2103
- // Original source may be populated on the sources object.
2104
- originalRawSource = this.sources.originalSource;
2105
- } else if (this.sourceMap.sourcesContent && this.sourceMap.sourcesContent[0]) {
2106
- // perhaps we loaded sourcesContent was populated by an inline source map, or .map file?
2107
- // TODO: investigate whether there's ever a case where we hit this logic with 1:many sources.
2108
- originalRawSource = this.sourceMap.sourcesContent[0];
2109
- } else {
2110
- // We fallback to reading the original source from disk.
2111
- originalRawSource = await readFile(this.path, 'utf8');
2112
- }
2113
- this.covSources = [{ source: new CovSource(originalRawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null), path: this.path }];
2114
- this.sourceTranspiled = new CovSource(rawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null);
2115
- }
2116
- } else {
2117
- this.covSources = [{ source: new CovSource(rawSource, this.wrapperLength), path: this.path }];
2118
- }
2119
- }
2045
+ function requireV8ToIstanbul$1 () {
2046
+ if (hasRequiredV8ToIstanbul$1) return v8ToIstanbul$2;
2047
+ hasRequiredV8ToIstanbul$1 = 1;
2048
+ // Patch applied: https://github.com/istanbuljs/v8-to-istanbul/pull/244
2049
+ const assert = require$$0;
2050
+ const convertSourceMap = requireConvertSourceMap();
2051
+ const util = require$$2;
2052
+ const debuglog = util.debuglog('c8');
2053
+ const { dirname, isAbsolute, join, resolve } = require$$3;
2054
+ const { fileURLToPath } = require$$4;
2055
+ const CovBranch = requireBranch();
2056
+ const CovFunction = require_function();
2057
+ const CovSource = requireSource();
2058
+ const { sliceRange } = requireRange();
2059
+ const { readFileSync, promises } = require$$9;
2060
+ const readFile = promises.readFile;
2061
+
2062
+ const { TraceMap } = requireTraceMapping_umd();
2063
+ const isOlderNode10 = /^v10\.(([0-9]\.)|(1[0-5]\.))/u.test(process.version);
2064
+ const isNode8 = /^v8\./.test(process.version);
2065
+
2066
+ // Injected when Node.js is loading script into isolate pre Node 10.16.x.
2067
+ // see: https://github.com/nodejs/node/pull/21573.
2068
+ const cjsWrapperLength = isOlderNode10 ? require$$11.wrapper[0].length : 0;
2069
+
2070
+ v8ToIstanbul$2 = class V8ToIstanbul {
2071
+ constructor (scriptPath, wrapperLength, sources, excludePath, excludeEmptyLines) {
2072
+ assert(typeof scriptPath === 'string', 'scriptPath must be a string');
2073
+ assert(!isNode8, 'This module does not support node 8 or lower, please upgrade to node 10');
2074
+ this.path = parsePath(scriptPath);
2075
+ this.wrapperLength = wrapperLength === undefined ? cjsWrapperLength : wrapperLength;
2076
+ this.excludePath = excludePath || (() => false);
2077
+ this.excludeEmptyLines = excludeEmptyLines === true;
2078
+ this.sources = sources || {};
2079
+ this.generatedLines = [];
2080
+ this.branches = {};
2081
+ this.functions = {};
2082
+ this.covSources = [];
2083
+ this.rawSourceMap = undefined;
2084
+ this.sourceMap = undefined;
2085
+ this.sourceTranspiled = undefined;
2086
+ // Indicate that this report was generated with placeholder data from
2087
+ // running --all:
2088
+ this.all = false;
2089
+ }
2120
2090
 
2121
- _readFileFromDir (filename) {
2122
- return readFileSync(resolve$1(dirname(this.path), filename), 'utf-8')
2123
- }
2091
+ async load () {
2092
+ const rawSource = this.sources.source || await readFile(this.path, 'utf8');
2093
+ this.rawSourceMap = this.sources.sourceMap ||
2094
+ // if we find a source-map (either inline, or a .map file) we load
2095
+ // both the transpiled and original source, both of which are used during
2096
+ // the backflips we perform to remap absolute to relative positions.
2097
+ convertSourceMap.fromSource(rawSource) || convertSourceMap.fromMapFileSource(rawSource, this._readFileFromDir.bind(this));
2098
+
2099
+ if (this.rawSourceMap) {
2100
+ if (this.rawSourceMap.sourcemap.sources.length > 1) {
2101
+ this.sourceMap = new TraceMap(this.rawSourceMap.sourcemap);
2102
+ if (!this.sourceMap.sourcesContent) {
2103
+ this.sourceMap.sourcesContent = await this.sourcesContentFromSources();
2104
+ }
2105
+ this.covSources = this.sourceMap.sourcesContent.map((rawSource, i) => ({ source: new CovSource(rawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null), path: this.sourceMap.sources[i] }));
2106
+ this.sourceTranspiled = new CovSource(rawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null);
2107
+ } else {
2108
+ const candidatePath = this.rawSourceMap.sourcemap.sources.length >= 1 ? this.rawSourceMap.sourcemap.sources[0] : this.rawSourceMap.sourcemap.file;
2109
+ this.path = this._resolveSource(this.rawSourceMap, candidatePath || this.path);
2110
+ this.sourceMap = new TraceMap(this.rawSourceMap.sourcemap);
2111
+
2112
+ let originalRawSource;
2113
+ if (this.sources.sourceMap && this.sources.sourceMap.sourcemap && this.sources.sourceMap.sourcemap.sourcesContent && this.sources.sourceMap.sourcemap.sourcesContent.length === 1) {
2114
+ // If the sourcesContent field has been provided, return it rather than attempting
2115
+ // to load the original source from disk.
2116
+ // TODO: investigate whether there's ever a case where we hit this logic with 1:many sources.
2117
+ originalRawSource = this.sources.sourceMap.sourcemap.sourcesContent[0];
2118
+ } else if (this.sources.originalSource) {
2119
+ // Original source may be populated on the sources object.
2120
+ originalRawSource = this.sources.originalSource;
2121
+ } else if (this.sourceMap.sourcesContent && this.sourceMap.sourcesContent[0]) {
2122
+ // perhaps we loaded sourcesContent was populated by an inline source map, or .map file?
2123
+ // TODO: investigate whether there's ever a case where we hit this logic with 1:many sources.
2124
+ originalRawSource = this.sourceMap.sourcesContent[0];
2125
+ } else {
2126
+ // We fallback to reading the original source from disk.
2127
+ originalRawSource = await readFile(this.path, 'utf8');
2128
+ }
2129
+ this.covSources = [{ source: new CovSource(originalRawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null), path: this.path }];
2130
+ this.sourceTranspiled = new CovSource(rawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null);
2131
+ }
2132
+ } else {
2133
+ this.covSources = [{ source: new CovSource(rawSource, this.wrapperLength), path: this.path }];
2134
+ }
2135
+ }
2124
2136
 
2125
- async sourcesContentFromSources () {
2126
- const fileList = this.sourceMap.sources.map(relativePath => {
2127
- const realPath = this._resolveSource(this.rawSourceMap, relativePath);
2128
- return readFile(realPath, 'utf-8')
2129
- .then(result => result)
2130
- .catch(err => {
2131
- debuglog(`failed to load ${realPath}: ${err.message}`);
2132
- })
2133
- });
2134
- return await Promise.all(fileList)
2135
- }
2137
+ _readFileFromDir (filename) {
2138
+ return readFileSync(resolve(dirname(this.path), filename), 'utf-8')
2139
+ }
2136
2140
 
2137
- destroy () {
2138
- // no longer necessary, but preserved for backwards compatibility.
2139
- }
2141
+ async sourcesContentFromSources () {
2142
+ const fileList = this.sourceMap.sources.map(relativePath => {
2143
+ const realPath = this._resolveSource(this.rawSourceMap, relativePath);
2144
+ return readFile(realPath, 'utf-8')
2145
+ .then(result => result)
2146
+ .catch(err => {
2147
+ debuglog(`failed to load ${realPath}: ${err.message}`);
2148
+ })
2149
+ });
2150
+ return await Promise.all(fileList)
2151
+ }
2140
2152
 
2141
- _resolveSource (rawSourceMap, sourcePath) {
2142
- if (sourcePath.startsWith('file://')) {
2143
- return fileURLToPath(sourcePath)
2144
- }
2145
- sourcePath = sourcePath.replace(/^webpack:\/\//, '');
2146
- const sourceRoot = rawSourceMap.sourcemap.sourceRoot ? rawSourceMap.sourcemap.sourceRoot.replace('file://', '') : '';
2147
- const candidatePath = join(sourceRoot, sourcePath);
2153
+ destroy () {
2154
+ // no longer necessary, but preserved for backwards compatibility.
2155
+ }
2148
2156
 
2149
- if (isAbsolute$1(candidatePath)) {
2150
- return candidatePath
2151
- } else {
2152
- return resolve$1(dirname(this.path), candidatePath)
2153
- }
2154
- }
2157
+ _resolveSource (rawSourceMap, sourcePath) {
2158
+ if (sourcePath.startsWith('file://')) {
2159
+ return fileURLToPath(sourcePath)
2160
+ }
2161
+ sourcePath = sourcePath.replace(/^webpack:\/\//, '');
2162
+ const sourceRoot = rawSourceMap.sourcemap.sourceRoot ? rawSourceMap.sourcemap.sourceRoot.replace('file://', '') : '';
2163
+ const candidatePath = join(sourceRoot, sourcePath);
2155
2164
 
2156
- applyCoverage (blocks) {
2157
- blocks.forEach(block => {
2158
- block.ranges.forEach((range, i) => {
2159
- const isEmptyCoverage = block.functionName === '(empty-report)';
2160
- const { startCol, endCol, path, covSource } = this._maybeRemapStartColEndCol(range, isEmptyCoverage);
2161
- if (this.excludePath(path)) {
2162
- return
2163
- }
2164
- let lines;
2165
- if (isEmptyCoverage) {
2166
- // (empty-report), this will result in a report that has all lines zeroed out.
2167
- lines = covSource.lines.filter((line) => {
2168
- line.count = 0;
2169
- return true
2170
- });
2171
- this.all = lines.length > 0;
2172
- } else {
2173
- lines = sliceRange(covSource.lines, startCol, endCol);
2174
- }
2175
- if (!lines.length) {
2176
- return
2177
- }
2165
+ if (isAbsolute(candidatePath)) {
2166
+ return candidatePath
2167
+ } else {
2168
+ return resolve(dirname(this.path), candidatePath)
2169
+ }
2170
+ }
2178
2171
 
2179
- const startLineInstance = lines[0];
2180
- const endLineInstance = lines[lines.length - 1];
2181
-
2182
- if (block.isBlockCoverage) {
2183
- this.branches[path] = this.branches[path] || [];
2184
- // record branches.
2185
- this.branches[path].push(new CovBranch(
2186
- startLineInstance.line,
2187
- startCol - startLineInstance.startCol,
2188
- endLineInstance.line,
2189
- endCol - endLineInstance.startCol,
2190
- range.count
2191
- ));
2192
-
2193
- // if block-level granularity is enabled, we still create a single
2194
- // CovFunction tracking object for each set of ranges.
2195
- if (block.functionName && i === 0) {
2196
- this.functions[path] = this.functions[path] || [];
2197
- this.functions[path].push(new CovFunction(
2198
- block.functionName,
2199
- startLineInstance.line,
2200
- startCol - startLineInstance.startCol,
2201
- endLineInstance.line,
2202
- endCol - endLineInstance.startCol,
2203
- range.count
2204
- ));
2205
- }
2206
- } else if (block.functionName) {
2207
- this.functions[path] = this.functions[path] || [];
2208
- // record functions.
2209
- this.functions[path].push(new CovFunction(
2210
- block.functionName,
2211
- startLineInstance.line,
2212
- startCol - startLineInstance.startCol,
2213
- endLineInstance.line,
2214
- endCol - endLineInstance.startCol,
2215
- range.count
2216
- ));
2217
- }
2172
+ applyCoverage (blocks) {
2173
+ blocks.forEach(block => {
2174
+ block.ranges.forEach((range, i) => {
2175
+ const isEmptyCoverage = block.functionName === '(empty-report)';
2176
+ const { startCol, endCol, path, covSource } = this._maybeRemapStartColEndCol(range, isEmptyCoverage);
2177
+ if (this.excludePath(path)) {
2178
+ return
2179
+ }
2180
+ let lines;
2181
+ if (isEmptyCoverage) {
2182
+ // (empty-report), this will result in a report that has all lines zeroed out.
2183
+ lines = covSource.lines.filter((line) => {
2184
+ line.count = 0;
2185
+ return true
2186
+ });
2187
+ this.all = lines.length > 0;
2188
+ } else {
2189
+ lines = sliceRange(covSource.lines, startCol, endCol);
2190
+ }
2191
+ if (!lines.length) {
2192
+ return
2193
+ }
2194
+
2195
+ const startLineInstance = lines[0];
2196
+ const endLineInstance = lines[lines.length - 1];
2197
+
2198
+ if (block.isBlockCoverage) {
2199
+ this.branches[path] = this.branches[path] || [];
2200
+ // record branches.
2201
+ this.branches[path].push(new CovBranch(
2202
+ startLineInstance.line,
2203
+ startCol - startLineInstance.startCol,
2204
+ endLineInstance.line,
2205
+ endCol - endLineInstance.startCol,
2206
+ range.count
2207
+ ));
2208
+
2209
+ // if block-level granularity is enabled, we still create a single
2210
+ // CovFunction tracking object for each set of ranges.
2211
+ if (block.functionName && i === 0) {
2212
+ this.functions[path] = this.functions[path] || [];
2213
+ this.functions[path].push(new CovFunction(
2214
+ block.functionName,
2215
+ startLineInstance.line,
2216
+ startCol - startLineInstance.startCol,
2217
+ endLineInstance.line,
2218
+ endCol - endLineInstance.startCol,
2219
+ range.count
2220
+ ));
2221
+ }
2222
+ } else if (block.functionName) {
2223
+ this.functions[path] = this.functions[path] || [];
2224
+ // record functions.
2225
+ this.functions[path].push(new CovFunction(
2226
+ block.functionName,
2227
+ startLineInstance.line,
2228
+ startCol - startLineInstance.startCol,
2229
+ endLineInstance.line,
2230
+ endCol - endLineInstance.startCol,
2231
+ range.count
2232
+ ));
2233
+ }
2234
+
2235
+ // record the lines (we record these as statements, such that we're
2236
+ // compatible with Istanbul 2.0).
2237
+ lines.forEach(line => {
2238
+ // make sure branch spans entire line; don't record 'goodbye'
2239
+ // branch in `const foo = true ? 'hello' : 'goodbye'` as a
2240
+ // 0 for line coverage.
2241
+ //
2242
+ // All lines start out with coverage of 1, and are later set to 0
2243
+ // if they are not invoked; line.ignore prevents a line from being
2244
+ // set to 0, and is set if the special comment /* c8 ignore next */
2245
+ // is used.
2246
+
2247
+ if (startCol <= line.startCol && endCol >= line.endCol && !line.ignore) {
2248
+ line.count = range.count;
2249
+ }
2250
+ });
2251
+ });
2252
+ });
2253
+ }
2218
2254
 
2219
- // record the lines (we record these as statements, such that we're
2220
- // compatible with Istanbul 2.0).
2221
- lines.forEach(line => {
2222
- // make sure branch spans entire line; don't record 'goodbye'
2223
- // branch in `const foo = true ? 'hello' : 'goodbye'` as a
2224
- // 0 for line coverage.
2225
- //
2226
- // All lines start out with coverage of 1, and are later set to 0
2227
- // if they are not invoked; line.ignore prevents a line from being
2228
- // set to 0, and is set if the special comment /* c8 ignore next */
2229
- // is used.
2230
-
2231
- if (startCol <= line.startCol && endCol >= line.endCol && !line.ignore) {
2232
- line.count = range.count;
2233
- }
2234
- });
2235
- });
2236
- });
2237
- }
2255
+ _maybeRemapStartColEndCol (range, isEmptyCoverage) {
2256
+ let covSource = this.covSources[0].source;
2257
+ const covSourceWrapperLength = isEmptyCoverage ? 0 : covSource.wrapperLength;
2258
+ let startCol = Math.max(0, range.startOffset - covSourceWrapperLength);
2259
+ let endCol = Math.min(covSource.eof, range.endOffset - covSourceWrapperLength);
2260
+ let path = this.path;
2261
+
2262
+ if (this.sourceMap) {
2263
+ const sourceTranspiledWrapperLength = isEmptyCoverage ? 0 : this.sourceTranspiled.wrapperLength;
2264
+ startCol = Math.max(0, range.startOffset - sourceTranspiledWrapperLength);
2265
+ endCol = Math.min(this.sourceTranspiled.eof, range.endOffset - sourceTranspiledWrapperLength);
2266
+
2267
+ const { startLine, relStartCol, endLine, relEndCol, source } = this.sourceTranspiled.offsetToOriginalRelative(
2268
+ this.sourceMap,
2269
+ startCol,
2270
+ endCol
2271
+ );
2272
+
2273
+ const matchingSource = this.covSources.find(covSource => covSource.path === source);
2274
+ covSource = matchingSource ? matchingSource.source : this.covSources[0].source;
2275
+ path = matchingSource ? matchingSource.path : this.covSources[0].path;
2276
+
2277
+ // next we convert these relative positions back to absolute positions
2278
+ // in the original source (which is the format expected in the next step).
2279
+ startCol = covSource.relativeToOffset(startLine, relStartCol);
2280
+ endCol = covSource.relativeToOffset(endLine, relEndCol);
2281
+ }
2238
2282
 
2239
- _maybeRemapStartColEndCol (range, isEmptyCoverage) {
2240
- let covSource = this.covSources[0].source;
2241
- const covSourceWrapperLength = isEmptyCoverage ? 0 : covSource.wrapperLength;
2242
- let startCol = Math.max(0, range.startOffset - covSourceWrapperLength);
2243
- let endCol = Math.min(covSource.eof, range.endOffset - covSourceWrapperLength);
2244
- let path = this.path;
2245
-
2246
- if (this.sourceMap) {
2247
- const sourceTranspiledWrapperLength = isEmptyCoverage ? 0 : this.sourceTranspiled.wrapperLength;
2248
- startCol = Math.max(0, range.startOffset - sourceTranspiledWrapperLength);
2249
- endCol = Math.min(this.sourceTranspiled.eof, range.endOffset - sourceTranspiledWrapperLength);
2250
-
2251
- const { startLine, relStartCol, endLine, relEndCol, source } = this.sourceTranspiled.offsetToOriginalRelative(
2252
- this.sourceMap,
2253
- startCol,
2254
- endCol
2255
- );
2283
+ return {
2284
+ path,
2285
+ covSource,
2286
+ startCol,
2287
+ endCol
2288
+ }
2289
+ }
2256
2290
 
2257
- const matchingSource = this.covSources.find(covSource => covSource.path === source);
2258
- covSource = matchingSource ? matchingSource.source : this.covSources[0].source;
2259
- path = matchingSource ? matchingSource.path : this.covSources[0].path;
2291
+ getInnerIstanbul (source, path) {
2292
+ // We apply the "Resolving Sources" logic (as defined in
2293
+ // sourcemaps.info/spec.html) as a final step for 1:many source maps.
2294
+ // for 1:1 source maps, the resolve logic is applied while loading.
2295
+ //
2296
+ // TODO: could we move the resolving logic for 1:1 source maps to the final
2297
+ // step as well? currently this breaks some tests in c8.
2298
+ let resolvedPath = path;
2299
+ if (this.rawSourceMap && this.rawSourceMap.sourcemap.sources.length > 1) {
2300
+ resolvedPath = this._resolveSource(this.rawSourceMap, path);
2301
+ }
2260
2302
 
2261
- // next we convert these relative positions back to absolute positions
2262
- // in the original source (which is the format expected in the next step).
2263
- startCol = covSource.relativeToOffset(startLine, relStartCol);
2264
- endCol = covSource.relativeToOffset(endLine, relEndCol);
2265
- }
2303
+ if (this.excludePath(resolvedPath)) {
2304
+ return
2305
+ }
2266
2306
 
2267
- return {
2268
- path,
2269
- covSource,
2270
- startCol,
2271
- endCol
2272
- }
2273
- }
2307
+ return {
2308
+ [resolvedPath]: {
2309
+ path: resolvedPath,
2310
+ all: this.all,
2311
+ ...this._statementsToIstanbul(source, path),
2312
+ ...this._branchesToIstanbul(source, path),
2313
+ ...this._functionsToIstanbul(source, path)
2314
+ }
2315
+ }
2316
+ }
2274
2317
 
2275
- getInnerIstanbul (source, path) {
2276
- // We apply the "Resolving Sources" logic (as defined in
2277
- // sourcemaps.info/spec.html) as a final step for 1:many source maps.
2278
- // for 1:1 source maps, the resolve logic is applied while loading.
2279
- //
2280
- // TODO: could we move the resolving logic for 1:1 source maps to the final
2281
- // step as well? currently this breaks some tests in c8.
2282
- let resolvedPath = path;
2283
- if (this.rawSourceMap && this.rawSourceMap.sourcemap.sources.length > 1) {
2284
- resolvedPath = this._resolveSource(this.rawSourceMap, path);
2285
- }
2318
+ toIstanbul () {
2319
+ return this.covSources.reduce((istanbulOuter, { source, path }) => Object.assign(istanbulOuter, this.getInnerIstanbul(source, path)), {})
2320
+ }
2286
2321
 
2287
- if (this.excludePath(resolvedPath)) {
2288
- return
2289
- }
2322
+ _statementsToIstanbul (source, path) {
2323
+ const statements = {
2324
+ statementMap: {},
2325
+ s: {}
2326
+ };
2327
+ source.lines.forEach((line, index) => {
2328
+ if (!line.ignore) {
2329
+ statements.statementMap[`${index}`] = line.toIstanbul();
2330
+ statements.s[`${index}`] = line.count;
2331
+ }
2332
+ });
2333
+ return statements
2334
+ }
2290
2335
 
2291
- return {
2292
- [resolvedPath]: {
2293
- path: resolvedPath,
2294
- all: this.all,
2295
- ...this._statementsToIstanbul(source, path),
2296
- ...this._branchesToIstanbul(source, path),
2297
- ...this._functionsToIstanbul(source, path)
2298
- }
2299
- }
2300
- }
2336
+ _branchesToIstanbul (source, path) {
2337
+ const branches = {
2338
+ branchMap: {},
2339
+ b: {}
2340
+ };
2341
+ this.branches[path] = this.branches[path] || [];
2342
+ this.branches[path].forEach((branch, index) => {
2343
+ const srcLine = source.lines[branch.startLine - 1];
2344
+ const ignore = srcLine === undefined ? true : srcLine.ignore;
2345
+ branches.branchMap[`${index}`] = branch.toIstanbul();
2346
+ branches.b[`${index}`] = [ignore ? 1 : branch.count];
2347
+ });
2348
+ return branches
2349
+ }
2301
2350
 
2302
- toIstanbul () {
2303
- return this.covSources.reduce((istanbulOuter, { source, path }) => Object.assign(istanbulOuter, this.getInnerIstanbul(source, path)), {})
2304
- }
2351
+ _functionsToIstanbul (source, path) {
2352
+ const functions = {
2353
+ fnMap: {},
2354
+ f: {}
2355
+ };
2356
+ this.functions[path] = this.functions[path] || [];
2357
+ this.functions[path].forEach((fn, index) => {
2358
+ const srcLine = source.lines[fn.startLine - 1];
2359
+ const ignore = srcLine === undefined ? true : srcLine.ignore;
2360
+ functions.fnMap[`${index}`] = fn.toIstanbul();
2361
+ functions.f[`${index}`] = ignore ? 1 : fn.count;
2362
+ });
2363
+ return functions
2364
+ }
2365
+ };
2305
2366
 
2306
- _statementsToIstanbul (source, path) {
2307
- const statements = {
2308
- statementMap: {},
2309
- s: {}
2310
- };
2311
- source.lines.forEach((line, index) => {
2312
- if (!line.ignore) {
2313
- statements.statementMap[`${index}`] = line.toIstanbul();
2314
- statements.s[`${index}`] = line.count;
2315
- }
2316
- });
2317
- return statements
2318
- }
2367
+ function parsePath (scriptPath) {
2368
+ return scriptPath.startsWith('file://') ? fileURLToPath(scriptPath) : scriptPath
2369
+ }
2370
+ return v8ToIstanbul$2;
2371
+ }
2319
2372
 
2320
- _branchesToIstanbul (source, path) {
2321
- const branches = {
2322
- branchMap: {},
2323
- b: {}
2324
- };
2325
- this.branches[path] = this.branches[path] || [];
2326
- this.branches[path].forEach((branch, index) => {
2327
- const srcLine = source.lines[branch.startLine - 1];
2328
- const ignore = srcLine === undefined ? true : srcLine.ignore;
2329
- branches.branchMap[`${index}`] = branch.toIstanbul();
2330
- branches.b[`${index}`] = [ignore ? 1 : branch.count];
2331
- });
2332
- return branches
2333
- }
2373
+ var v8ToIstanbul$1;
2374
+ var hasRequiredV8ToIstanbul;
2334
2375
 
2335
- _functionsToIstanbul (source, path) {
2336
- const functions = {
2337
- fnMap: {},
2338
- f: {}
2339
- };
2340
- this.functions[path] = this.functions[path] || [];
2341
- this.functions[path].forEach((fn, index) => {
2342
- const srcLine = source.lines[fn.startLine - 1];
2343
- const ignore = srcLine === undefined ? true : srcLine.ignore;
2344
- functions.fnMap[`${index}`] = fn.toIstanbul();
2345
- functions.f[`${index}`] = ignore ? 1 : fn.count;
2346
- });
2347
- return functions
2348
- }
2349
- };
2376
+ function requireV8ToIstanbul () {
2377
+ if (hasRequiredV8ToIstanbul) return v8ToIstanbul$1;
2378
+ hasRequiredV8ToIstanbul = 1;
2379
+ // Patch applied: https://github.com/istanbuljs/v8-to-istanbul/pull/244
2380
+ const V8ToIstanbul = requireV8ToIstanbul$1();
2350
2381
 
2351
- function parsePath (scriptPath) {
2352
- return scriptPath.startsWith('file://') ? fileURLToPath(scriptPath) : scriptPath
2382
+ v8ToIstanbul$1 = function (path, wrapperLength, sources, excludePath, excludeEmptyLines) {
2383
+ return new V8ToIstanbul(path, wrapperLength, sources, excludePath, excludeEmptyLines)
2384
+ };
2385
+ return v8ToIstanbul$1;
2353
2386
  }
2354
2387
 
2355
- // Patch applied: https://github.com/istanbuljs/v8-to-istanbul/pull/244
2356
- const V8ToIstanbul = v8ToIstanbul$2;
2357
-
2358
- var v8ToIstanbul = function (path, wrapperLength, sources, excludePath, excludeEmptyLines) {
2359
- return new V8ToIstanbul(path, wrapperLength, sources, excludePath, excludeEmptyLines)
2360
- };
2361
-
2362
- var v8ToIstanbul$1 = /*@__PURE__*/getDefaultExportFromCjs(v8ToIstanbul);
2388
+ var v8ToIstanbulExports = requireV8ToIstanbul();
2389
+ var v8ToIstanbul = /*@__PURE__*/getDefaultExportFromCjs(v8ToIstanbulExports);
2363
2390
 
2364
2391
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
2365
2392
  function normalizeWindowsPath(input = "") {
@@ -2512,57 +2539,20 @@ function cleanUrl(url) {
2512
2539
  "wasi"
2513
2540
  ]);
2514
2541
 
2515
- var version = "2.1.1";
2542
+ var version = "2.1.3";
2516
2543
 
2517
2544
  const WRAPPER_LENGTH = 185;
2518
2545
  const VITE_EXPORTS_LINE_PATTERN = /Object\.defineProperty\(__vite_ssr_exports__.*\n/g;
2519
2546
  const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes", \[[^\]]*\]\),*/g;
2520
- const DEFAULT_PROJECT = Symbol.for("default-project");
2521
2547
  const FILE_PROTOCOL = "file://";
2522
2548
  const debug = createDebug("vitest:coverage");
2523
- let uniqueId = 0;
2524
2549
  class V8CoverageProvider extends BaseCoverageProvider {
2525
2550
  name = "v8";
2526
- ctx;
2527
- options;
2551
+ version = version;
2528
2552
  testExclude;
2529
- coverageFiles = /* @__PURE__ */ new Map();
2530
- coverageFilesDirectory;
2531
- pendingPromises = [];
2532
2553
  initialize(ctx) {
2533
- const config = ctx.config.coverage;
2534
- if (ctx.version !== version) {
2535
- ctx.logger.warn(
2536
- c.yellow(
2537
- `Loaded ${c.inverse(c.yellow(` vitest@${ctx.version} `))} and ${c.inverse(c.yellow(` @vitest/coverage-v8@${version} `))}.
2538
- Running mixed versions is not supported and may lead into bugs
2539
- Update your dependencies and make sure the versions match.`
2540
- )
2541
- );
2542
- }
2543
- this.ctx = ctx;
2544
- this.options = {
2545
- ...coverageConfigDefaults,
2546
- // User's options
2547
- ...config,
2548
- // Resolved fields
2549
- provider: "v8",
2550
- reporter: this.resolveReporters(
2551
- config.reporter || coverageConfigDefaults.reporter
2552
- ),
2553
- reportsDirectory: resolve(
2554
- ctx.config.root,
2555
- config.reportsDirectory || coverageConfigDefaults.reportsDirectory
2556
- ),
2557
- thresholds: config.thresholds && {
2558
- ...config.thresholds,
2559
- lines: config.thresholds["100"] ? 100 : config.thresholds.lines,
2560
- branches: config.thresholds["100"] ? 100 : config.thresholds.branches,
2561
- functions: config.thresholds["100"] ? 100 : config.thresholds.functions,
2562
- statements: config.thresholds["100"] ? 100 : config.thresholds.statements
2563
- }
2564
- };
2565
- this.testExclude = new _TestExclude({
2554
+ this._initialize(ctx);
2555
+ this.testExclude = new TestExclude({
2566
2556
  cwd: ctx.config.root,
2567
2557
  include: this.options.include,
2568
2558
  exclude: this.options.exclude,
@@ -2570,80 +2560,18 @@ Update your dependencies and make sure the versions match.`
2570
2560
  extension: this.options.extension,
2571
2561
  relativePath: !this.options.allowExternal
2572
2562
  });
2573
- const shard = this.ctx.config.shard;
2574
- const tempDirectory = `.tmp${shard ? `-${shard.index}-${shard.count}` : ""}`;
2575
- this.coverageFilesDirectory = resolve(
2576
- this.options.reportsDirectory,
2577
- tempDirectory
2578
- );
2579
2563
  }
2580
- resolveOptions() {
2581
- return this.options;
2582
- }
2583
- async clean(clean = true) {
2584
- if (clean && existsSync(this.options.reportsDirectory)) {
2585
- await promises$1.rm(this.options.reportsDirectory, {
2586
- recursive: true,
2587
- force: true,
2588
- maxRetries: 10
2589
- });
2590
- }
2591
- if (existsSync(this.coverageFilesDirectory)) {
2592
- await promises$1.rm(this.coverageFilesDirectory, {
2593
- recursive: true,
2594
- force: true,
2595
- maxRetries: 10
2596
- });
2597
- }
2598
- await promises$1.mkdir(this.coverageFilesDirectory, { recursive: true });
2599
- this.coverageFiles = /* @__PURE__ */ new Map();
2600
- this.pendingPromises = [];
2601
- }
2602
- /*
2603
- * Coverage and meta information passed from Vitest runners.
2604
- * Note that adding new entries here and requiring on those without
2605
- * backwards compatibility is a breaking change.
2606
- */
2607
- onAfterSuiteRun({ coverage, transformMode, projectName }) {
2608
- if (transformMode !== "web" && transformMode !== "ssr" && transformMode !== "browser") {
2609
- throw new Error(`Invalid transform mode: ${transformMode}`);
2610
- }
2611
- let entry = this.coverageFiles.get(projectName || DEFAULT_PROJECT);
2612
- if (!entry) {
2613
- entry = { web: [], ssr: [], browser: [] };
2614
- this.coverageFiles.set(projectName || DEFAULT_PROJECT, entry);
2615
- }
2616
- const filename = resolve(
2617
- this.coverageFilesDirectory,
2618
- `coverage-${uniqueId++}.json`
2619
- );
2620
- entry[transformMode].push(filename);
2621
- const promise = promises$1.writeFile(filename, JSON.stringify(coverage), "utf-8");
2622
- this.pendingPromises.push(promise);
2564
+ createCoverageMap() {
2565
+ return libCoverage.createCoverageMap({});
2623
2566
  }
2624
2567
  async generateCoverage({ allTestsRun }) {
2625
- const coverageMap = libCoverage.createCoverageMap({});
2626
- let index = 0;
2627
- const total = this.pendingPromises.length;
2628
- await Promise.all(this.pendingPromises);
2629
- this.pendingPromises = [];
2630
- for (const [projectName, coveragePerProject] of this.coverageFiles.entries()) {
2631
- for (const [transformMode, filenames] of Object.entries(coveragePerProject)) {
2632
- let merged = { result: [] };
2633
- const project = this.ctx.projects.find((p) => p.getName() === projectName) || this.ctx.getCoreWorkspaceProject();
2634
- for (const chunk of this.toSlices(filenames, this.options.processingConcurrency)) {
2635
- if (debug.enabled) {
2636
- index += chunk.length;
2637
- debug("Covered files %d/%d", index, total);
2638
- }
2639
- await Promise.all(
2640
- chunk.map(async (filename) => {
2641
- const contents = await promises$1.readFile(filename, "utf-8");
2642
- const coverage = JSON.parse(contents);
2643
- merged = mergeProcessCovs([merged, coverage]);
2644
- })
2645
- );
2646
- }
2568
+ const coverageMap = this.createCoverageMap();
2569
+ let merged = { result: [] };
2570
+ await this.readCoverageFiles({
2571
+ onFileRead(coverage) {
2572
+ merged = mergeProcessCovs([merged, coverage]);
2573
+ },
2574
+ onFinished: async (project, transformMode) => {
2647
2575
  const converted = await this.convertCoverage(
2648
2576
  merged,
2649
2577
  project,
@@ -2651,9 +2579,11 @@ Update your dependencies and make sure the versions match.`
2651
2579
  );
2652
2580
  const transformedCoverage = await transformCoverage(converted);
2653
2581
  coverageMap.merge(transformedCoverage);
2654
- }
2655
- }
2656
- if (this.options.all && allTestsRun) {
2582
+ merged = { result: [] };
2583
+ },
2584
+ onDebug: debug
2585
+ });
2586
+ if (this.options.all && (allTestsRun || !this.options.cleanOnRerun)) {
2657
2587
  const coveredFiles = coverageMap.files();
2658
2588
  const untestedCoverage = await this.getUntestedFiles(coveredFiles);
2659
2589
  const converted = await this.convertCoverage(untestedCoverage);
@@ -2664,7 +2594,7 @@ Update your dependencies and make sure the versions match.`
2664
2594
  }
2665
2595
  return coverageMap;
2666
2596
  }
2667
- async reportCoverage(coverageMap, { allTestsRun }) {
2597
+ async generateReports(coverageMap, allTestsRun) {
2668
2598
  if (provider === "stackblitz") {
2669
2599
  this.ctx.logger.log(
2670
2600
  c.blue(" % ") + c.yellow(
@@ -2672,20 +2602,6 @@ Update your dependencies and make sure the versions match.`
2672
2602
  )
2673
2603
  );
2674
2604
  }
2675
- await this.generateReports(
2676
- coverageMap || libCoverage.createCoverageMap({}),
2677
- allTestsRun
2678
- );
2679
- const keepResults = !this.options.cleanOnRerun && this.ctx.config.watch;
2680
- if (!keepResults) {
2681
- this.coverageFiles = /* @__PURE__ */ new Map();
2682
- await promises$1.rm(this.coverageFilesDirectory, { recursive: true });
2683
- if (readdirSync(this.options.reportsDirectory).length === 0) {
2684
- await promises$1.rm(this.options.reportsDirectory, { recursive: true });
2685
- }
2686
- }
2687
- }
2688
- async generateReports(coverageMap, allTestsRun) {
2689
2605
  const context = libReport.createContext({
2690
2606
  dir: this.options.reportsDirectory,
2691
2607
  coverageMap,
@@ -2704,46 +2620,13 @@ Update your dependencies and make sure the versions match.`
2704
2620
  }).execute(context);
2705
2621
  }
2706
2622
  if (this.options.thresholds) {
2707
- const resolvedThresholds = this.resolveThresholds({
2708
- coverageMap,
2709
- thresholds: this.options.thresholds,
2710
- createCoverageMap: () => libCoverage.createCoverageMap({}),
2711
- root: this.ctx.config.root
2712
- });
2713
- this.checkThresholds({
2714
- thresholds: resolvedThresholds,
2715
- perFile: this.options.thresholds.perFile,
2716
- onError: (error) => this.ctx.logger.error(error)
2717
- });
2718
- if (this.options.thresholds.autoUpdate && allTestsRun) {
2719
- if (!this.ctx.server.config.configFile) {
2720
- throw new Error(
2721
- 'Missing configurationFile. The "coverage.thresholds.autoUpdate" can only be enabled when configuration file is used.'
2722
- );
2723
- }
2724
- const configFilePath = this.ctx.server.config.configFile;
2725
- const configModule = parseModule(
2726
- await promises$1.readFile(configFilePath, "utf8")
2727
- );
2728
- this.updateThresholds({
2729
- thresholds: resolvedThresholds,
2730
- perFile: this.options.thresholds.perFile,
2731
- configurationFile: configModule,
2732
- onUpdate: () => writeFileSync(
2733
- configFilePath,
2734
- configModule.generate().code,
2735
- "utf-8"
2736
- )
2737
- });
2738
- }
2623
+ await this.reportThresholds(coverageMap, allTestsRun);
2739
2624
  }
2740
2625
  }
2741
- async mergeReports(coverageMaps) {
2742
- const coverageMap = libCoverage.createCoverageMap({});
2743
- for (const coverage of coverageMaps) {
2744
- coverageMap.merge(coverage);
2745
- }
2746
- await this.generateReports(coverageMap, true);
2626
+ async parseConfigModule(configFilePath) {
2627
+ return parseModule(
2628
+ await promises.readFile(configFilePath, "utf8")
2629
+ );
2747
2630
  }
2748
2631
  async getUntestedFiles(testedFiles) {
2749
2632
  const transformResults = normalizeTransformResults(
@@ -2762,10 +2645,7 @@ Update your dependencies and make sure the versions match.`
2762
2645
  const uncoveredFiles = includedFiles.map((file) => pathToFileURL(file)).filter((file) => !testedFiles.includes(file.pathname));
2763
2646
  let merged = { result: [] };
2764
2647
  let index = 0;
2765
- for (const chunk of this.toSlices(
2766
- uncoveredFiles,
2767
- this.options.processingConcurrency
2768
- )) {
2648
+ for (const chunk of this.toSlices(uncoveredFiles, this.options.processingConcurrency)) {
2769
2649
  if (debug.enabled) {
2770
2650
  index += chunk.length;
2771
2651
  debug("Uncovered files %d/%d", index, uncoveredFiles.length);
@@ -2809,7 +2689,7 @@ Update your dependencies and make sure the versions match.`
2809
2689
  return merged;
2810
2690
  }
2811
2691
  async getSources(url, transformResults, onTransform, functions = []) {
2812
- const filePath = normalize(fileURLToPath$1(url));
2692
+ const filePath = normalize(fileURLToPath(url));
2813
2693
  let isExecuted = true;
2814
2694
  let transformResult = transformResults.get(filePath);
2815
2695
  if (!transformResult) {
@@ -2820,7 +2700,7 @@ Update your dependencies and make sure the versions match.`
2820
2700
  const code = transformResult?.code;
2821
2701
  const sourcesContent = map?.sourcesContent || [];
2822
2702
  if (!sourcesContent[0]) {
2823
- sourcesContent[0] = await promises$1.readFile(filePath, "utf-8").catch(() => {
2703
+ sourcesContent[0] = await promises.readFile(filePath, "utf-8").catch(() => {
2824
2704
  const length = findLongestFunctionLength(functions);
2825
2705
  return ".".repeat(length);
2826
2706
  });
@@ -2874,11 +2754,11 @@ Update your dependencies and make sure the versions match.`
2874
2754
  result.url = `${FILE_PROTOCOL}${project.config.root}${result.url}`;
2875
2755
  }
2876
2756
  }
2877
- if (this.testExclude.shouldInstrument(fileURLToPath$1(result.url))) {
2757
+ if (this.testExclude.shouldInstrument(fileURLToPath(result.url))) {
2878
2758
  scriptCoverages.push(result);
2879
2759
  }
2880
2760
  }
2881
- const coverageMap = libCoverage.createCoverageMap({});
2761
+ const coverageMap = this.createCoverageMap();
2882
2762
  let index = 0;
2883
2763
  for (const chunk of this.toSlices(scriptCoverages, this.options.processingConcurrency)) {
2884
2764
  if (debug.enabled) {
@@ -2894,7 +2774,7 @@ Update your dependencies and make sure the versions match.`
2894
2774
  functions
2895
2775
  );
2896
2776
  const wrapperLength = sources.isExecuted ? WRAPPER_LENGTH : 0;
2897
- const converter = v8ToIstanbul$1(
2777
+ const converter = v8ToIstanbul(
2898
2778
  url,
2899
2779
  wrapperLength,
2900
2780
  sources,