vitest 0.25.8 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/LICENSE.md +0 -142
  2. package/dist/browser.d.ts +6 -3
  3. package/dist/browser.js +9 -10
  4. package/dist/{chunk-api-setup.dc71e384.js → chunk-api-setup.08f3b356.js} +39 -42
  5. package/dist/{chunk-integrations-globals.4d261bb8.js → chunk-integrations-globals.cab94a09.js} +5 -5
  6. package/dist/{chunk-runtime-chain.f86e5250.js → chunk-runtime-chain.e655f6cc.js} +4 -5
  7. package/dist/{chunk-runtime-error.616e92ca.js → chunk-runtime-error.dfbbf9be.js} +5 -5
  8. package/dist/{chunk-runtime-mocker.99b910d0.js → chunk-runtime-mocker.35fabb8b.js} +65 -64
  9. package/dist/{chunk-runtime-rpc.42aebbb9.js → chunk-runtime-rpc.7959fc79.js} +1 -1
  10. package/dist/{chunk-runtime-setup.5398e2c4.js → chunk-runtime-setup.4c1b529e.js} +16 -29
  11. package/dist/{chunk-vite-node-externalize.b9495318.js → chunk-snapshot-manager.7d978f79.js} +36 -322
  12. package/dist/{chunk-typecheck-constants.ed987901.js → chunk-typecheck-constants.3f865d14.js} +5 -4
  13. package/dist/{chunk-runtime-test-state.3f86f48f.js → chunk-utils-import.ca62c9d7.js} +49 -18
  14. package/dist/{chunk-utils-source-map.29ff1088.js → chunk-utils-source-map.5bbb50cd.js} +6 -4
  15. package/dist/cli.js +12 -13
  16. package/dist/config.d.ts +4 -1
  17. package/dist/entry.js +9 -9
  18. package/dist/environments.d.ts +4 -1
  19. package/dist/{index-5aad25c1.d.ts → index-c3f83a58.d.ts} +1 -1
  20. package/dist/index.d.ts +28 -10
  21. package/dist/index.js +6 -6
  22. package/dist/loader.js +7 -6
  23. package/dist/node.d.ts +18 -18
  24. package/dist/node.js +14 -14
  25. package/dist/suite.js +4 -4
  26. package/dist/{types-71ccd11d.d.ts → types-56bcd6c3.d.ts} +16 -273
  27. package/dist/vendor-index.783e7f3e.js +71 -0
  28. package/dist/vendor-index.96e022fd.js +211 -0
  29. package/dist/worker.js +12 -14
  30. package/package.json +4 -4
  31. package/dist/chunk-vite-node-source-map.b4ea5792.js +0 -446
  32. package/dist/chunk-vite-node-utils.0e4a6a88.js +0 -1385
  33. package/dist/vendor-source-map-support.1ce17397.js +0 -707
@@ -1,707 +0,0 @@
1
- import require$$0 from 'source-map';
2
- import path from 'path';
3
-
4
- var sourceMapSupport = {exports: {}};
5
-
6
- /* eslint-disable node/no-deprecated-api */
7
-
8
- var toString = Object.prototype.toString;
9
-
10
- var isModern = (
11
- typeof Buffer !== 'undefined' &&
12
- typeof Buffer.alloc === 'function' &&
13
- typeof Buffer.allocUnsafe === 'function' &&
14
- typeof Buffer.from === 'function'
15
- );
16
-
17
- function isArrayBuffer (input) {
18
- return toString.call(input).slice(8, -1) === 'ArrayBuffer'
19
- }
20
-
21
- function fromArrayBuffer (obj, byteOffset, length) {
22
- byteOffset >>>= 0;
23
-
24
- var maxLength = obj.byteLength - byteOffset;
25
-
26
- if (maxLength < 0) {
27
- throw new RangeError("'offset' is out of bounds")
28
- }
29
-
30
- if (length === undefined) {
31
- length = maxLength;
32
- } else {
33
- length >>>= 0;
34
-
35
- if (length > maxLength) {
36
- throw new RangeError("'length' is out of bounds")
37
- }
38
- }
39
-
40
- return isModern
41
- ? Buffer.from(obj.slice(byteOffset, byteOffset + length))
42
- : new Buffer(new Uint8Array(obj.slice(byteOffset, byteOffset + length)))
43
- }
44
-
45
- function fromString (string, encoding) {
46
- if (typeof encoding !== 'string' || encoding === '') {
47
- encoding = 'utf8';
48
- }
49
-
50
- if (!Buffer.isEncoding(encoding)) {
51
- throw new TypeError('"encoding" must be a valid string encoding')
52
- }
53
-
54
- return isModern
55
- ? Buffer.from(string, encoding)
56
- : new Buffer(string, encoding)
57
- }
58
-
59
- function bufferFrom (value, encodingOrOffset, length) {
60
- if (typeof value === 'number') {
61
- throw new TypeError('"value" argument must not be a number')
62
- }
63
-
64
- if (isArrayBuffer(value)) {
65
- return fromArrayBuffer(value, encodingOrOffset, length)
66
- }
67
-
68
- if (typeof value === 'string') {
69
- return fromString(value, encodingOrOffset)
70
- }
71
-
72
- return isModern
73
- ? Buffer.from(value)
74
- : new Buffer(value)
75
- }
76
-
77
- var bufferFrom_1 = bufferFrom;
78
-
79
- (function (module, exports) {
80
- var SourceMapConsumer = require$$0.SourceMapConsumer;
81
- var path$1 = path;
82
-
83
- var fs;
84
- try {
85
- fs = require('fs');
86
- if (!fs.existsSync || !fs.readFileSync) {
87
- // fs doesn't have all methods we need
88
- fs = null;
89
- }
90
- } catch (err) {
91
- /* nop */
92
- }
93
-
94
- var bufferFrom = bufferFrom_1;
95
-
96
- /**
97
- * Requires a module which is protected against bundler minification.
98
- *
99
- * @param {NodeModule} mod
100
- * @param {string} request
101
- */
102
- function dynamicRequire(mod, request) {
103
- return mod.require(request);
104
- }
105
-
106
- // Only install once if called multiple times
107
- var errorFormatterInstalled = false;
108
- var uncaughtShimInstalled = false;
109
-
110
- // If true, the caches are reset before a stack trace formatting operation
111
- var emptyCacheBetweenOperations = false;
112
-
113
- // Supports {browser, node, auto}
114
- var environment = "auto";
115
-
116
- // Maps a file path to a string containing the file contents
117
- var fileContentsCache = {};
118
-
119
- // Maps a file path to a source map for that file
120
- var sourceMapCache = {};
121
-
122
- // Regex for detecting source maps
123
- var reSourceMap = /^data:application\/json[^,]+base64,/;
124
-
125
- // Priority list of retrieve handlers
126
- var retrieveFileHandlers = [];
127
- var retrieveMapHandlers = [];
128
-
129
- function isInBrowser() {
130
- if (environment === "browser")
131
- return true;
132
- if (environment === "node")
133
- return false;
134
- return ((typeof window !== 'undefined') && (typeof XMLHttpRequest === 'function') && !(window.require && window.module && window.process && window.process.type === "renderer"));
135
- }
136
-
137
- function hasGlobalProcessEventEmitter() {
138
- return ((typeof process === 'object') && (process !== null) && (typeof process.on === 'function'));
139
- }
140
-
141
- function globalProcessVersion() {
142
- if ((typeof process === 'object') && (process !== null)) {
143
- return process.version;
144
- } else {
145
- return '';
146
- }
147
- }
148
-
149
- function globalProcessStderr() {
150
- if ((typeof process === 'object') && (process !== null)) {
151
- return process.stderr;
152
- }
153
- }
154
-
155
- function globalProcessExit(code) {
156
- if ((typeof process === 'object') && (process !== null) && (typeof process.exit === 'function')) {
157
- return process.exit(code);
158
- }
159
- }
160
-
161
- function handlerExec(list) {
162
- return function(arg) {
163
- for (var i = 0; i < list.length; i++) {
164
- var ret = list[i](arg);
165
- if (ret) {
166
- return ret;
167
- }
168
- }
169
- return null;
170
- };
171
- }
172
-
173
- var retrieveFile = handlerExec(retrieveFileHandlers);
174
-
175
- retrieveFileHandlers.push(function(path) {
176
- // Trim the path to make sure there is no extra whitespace.
177
- path = path.trim();
178
- if (/^file:/.test(path)) {
179
- // existsSync/readFileSync can't handle file protocol, but once stripped, it works
180
- path = path.replace(/file:\/\/\/(\w:)?/, function(protocol, drive) {
181
- return drive ?
182
- '' : // file:///C:/dir/file -> C:/dir/file
183
- '/'; // file:///root-dir/file -> /root-dir/file
184
- });
185
- }
186
- if (path in fileContentsCache) {
187
- return fileContentsCache[path];
188
- }
189
-
190
- var contents = '';
191
- try {
192
- if (!fs) {
193
- // Use SJAX if we are in the browser
194
- var xhr = new XMLHttpRequest();
195
- console.trace('zdes');
196
- xhr.open('GET', path, /** async */ false);
197
- xhr.send(null);
198
- if (xhr.readyState === 4 && xhr.status === 200) {
199
- contents = xhr.responseText;
200
- }
201
- } else if (fs.existsSync(path)) {
202
- // Otherwise, use the filesystem
203
- contents = fs.readFileSync(path, 'utf8');
204
- }
205
- } catch (er) {
206
- /* ignore any errors */
207
- }
208
-
209
- return fileContentsCache[path] = contents;
210
- });
211
-
212
- // Support URLs relative to a directory, but be careful about a protocol prefix
213
- // in case we are in the browser (i.e. directories may start with "http://" or "file:///")
214
- function supportRelativeURL(file, url) {
215
- if (!file) return url;
216
- var dir = path$1.dirname(file);
217
- var match = /^\w+:\/\/[^\/]*/.exec(dir);
218
- var protocol = match ? match[0] : '';
219
- var startPath = dir.slice(protocol.length);
220
- if (protocol && /^\/\w\:/.test(startPath)) {
221
- // handle file:///C:/ paths
222
- protocol += '/';
223
- return protocol + path$1.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/');
224
- }
225
- return protocol + path$1.resolve(dir.slice(protocol.length), url);
226
- }
227
-
228
- function retrieveSourceMapURL(source) {
229
- var fileData;
230
-
231
- if (isInBrowser()) {
232
- try {
233
- var xhr = new XMLHttpRequest();
234
- xhr.open('GET', source, false);
235
- xhr.send(null);
236
- fileData = xhr.readyState === 4 ? xhr.responseText : null;
237
-
238
- // Support providing a sourceMappingURL via the SourceMap header
239
- var sourceMapHeader = xhr.getResponseHeader("SourceMap") ||
240
- xhr.getResponseHeader("X-SourceMap");
241
- if (sourceMapHeader) {
242
- return sourceMapHeader;
243
- }
244
- } catch (e) {
245
- }
246
- }
247
-
248
- // Get the URL of the source map
249
- fileData = retrieveFile(source);
250
- var re = /(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg;
251
- // Keep executing the search to find the *last* sourceMappingURL to avoid
252
- // picking up sourceMappingURLs from comments, strings, etc.
253
- var lastMatch, match;
254
- while (match = re.exec(fileData)) lastMatch = match;
255
- if (!lastMatch) return null;
256
- return lastMatch[1];
257
- }
258
- // Can be overridden by the retrieveSourceMap option to install. Takes a
259
- // generated source filename; returns a {map, optional url} object, or null if
260
- // there is no source map. The map field may be either a string or the parsed
261
- // JSON object (ie, it must be a valid argument to the SourceMapConsumer
262
- // constructor).
263
- var retrieveSourceMap = handlerExec(retrieveMapHandlers);
264
- retrieveMapHandlers.push(function(source) {
265
- var sourceMappingURL = retrieveSourceMapURL(source);
266
- if (!sourceMappingURL) return null;
267
-
268
- // Read the contents of the source map
269
- var sourceMapData;
270
- if (reSourceMap.test(sourceMappingURL)) {
271
- // Support source map URL as a data url
272
- var rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(',') + 1);
273
- sourceMapData = bufferFrom(rawData, "base64").toString();
274
- sourceMappingURL = source;
275
- } else {
276
- // Support source map URLs relative to the source URL
277
- sourceMappingURL = supportRelativeURL(source, sourceMappingURL);
278
- sourceMapData = retrieveFile(sourceMappingURL);
279
- }
280
-
281
- if (!sourceMapData) {
282
- return null;
283
- }
284
-
285
- return {
286
- url: sourceMappingURL,
287
- map: sourceMapData
288
- };
289
- });
290
-
291
- function mapSourcePosition(position) {
292
- var sourceMap = sourceMapCache[position.source];
293
- if (!sourceMap) {
294
- // Call the (overrideable) retrieveSourceMap function to get the source map.
295
- var urlAndMap = retrieveSourceMap(position.source);
296
- if (urlAndMap) {
297
- sourceMap = sourceMapCache[position.source] = {
298
- url: urlAndMap.url,
299
- map: new SourceMapConsumer(urlAndMap.map)
300
- };
301
-
302
- // Load all sources stored inline with the source map into the file cache
303
- // to pretend like they are already loaded. They may not exist on disk.
304
- if (sourceMap.map.sourcesContent) {
305
- sourceMap.map.sources.forEach(function(source, i) {
306
- var contents = sourceMap.map.sourcesContent[i];
307
- if (contents) {
308
- var url = supportRelativeURL(sourceMap.url, source);
309
- fileContentsCache[url] = contents;
310
- }
311
- });
312
- }
313
- } else {
314
- sourceMap = sourceMapCache[position.source] = {
315
- url: null,
316
- map: null
317
- };
318
- }
319
- }
320
-
321
- // Resolve the source URL relative to the URL of the source map
322
- if (sourceMap && sourceMap.map && typeof sourceMap.map.originalPositionFor === 'function') {
323
- var originalPosition = sourceMap.map.originalPositionFor(position);
324
-
325
- // Only return the original position if a matching line was found. If no
326
- // matching line is found then we return position instead, which will cause
327
- // the stack trace to print the path and line for the compiled file. It is
328
- // better to give a precise location in the compiled file than a vague
329
- // location in the original file.
330
- if (originalPosition.source !== null) {
331
- originalPosition.source = supportRelativeURL(
332
- sourceMap.url, originalPosition.source);
333
- return originalPosition;
334
- }
335
- }
336
-
337
- return position;
338
- }
339
-
340
- // Parses code generated by FormatEvalOrigin(), a function inside V8:
341
- // https://code.google.com/p/v8/source/browse/trunk/src/messages.js
342
- function mapEvalOrigin(origin) {
343
- // Most eval() calls are in this format
344
- var match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin);
345
- if (match) {
346
- var position = mapSourcePosition({
347
- source: match[2],
348
- line: +match[3],
349
- column: match[4] - 1
350
- });
351
- return 'eval at ' + match[1] + ' (' + position.source + ':' +
352
- position.line + ':' + (position.column + 1) + ')';
353
- }
354
-
355
- // Parse nested eval() calls using recursion
356
- match = /^eval at ([^(]+) \((.+)\)$/.exec(origin);
357
- if (match) {
358
- return 'eval at ' + match[1] + ' (' + mapEvalOrigin(match[2]) + ')';
359
- }
360
-
361
- // Make sure we still return useful information if we didn't find anything
362
- return origin;
363
- }
364
-
365
- // This is copied almost verbatim from the V8 source code at
366
- // https://code.google.com/p/v8/source/browse/trunk/src/messages.js. The
367
- // implementation of wrapCallSite() used to just forward to the actual source
368
- // code of CallSite.prototype.toString but unfortunately a new release of V8
369
- // did something to the prototype chain and broke the shim. The only fix I
370
- // could find was copy/paste.
371
- function CallSiteToString() {
372
- var fileName;
373
- var fileLocation = "";
374
- if (this.isNative()) {
375
- fileLocation = "native";
376
- } else {
377
- fileName = this.getScriptNameOrSourceURL();
378
- if (!fileName && this.isEval()) {
379
- fileLocation = this.getEvalOrigin();
380
- fileLocation += ", "; // Expecting source position to follow.
381
- }
382
-
383
- if (fileName) {
384
- fileLocation += fileName;
385
- } else {
386
- // Source code does not originate from a file and is not native, but we
387
- // can still get the source position inside the source string, e.g. in
388
- // an eval string.
389
- fileLocation += "<anonymous>";
390
- }
391
- var lineNumber = this.getLineNumber();
392
- if (lineNumber != null) {
393
- fileLocation += ":" + lineNumber;
394
- var columnNumber = this.getColumnNumber();
395
- if (columnNumber) {
396
- fileLocation += ":" + columnNumber;
397
- }
398
- }
399
- }
400
-
401
- var line = "";
402
- var functionName = this.getFunctionName();
403
- var addSuffix = true;
404
- var isConstructor = this.isConstructor();
405
- var isMethodCall = !(this.isToplevel() || isConstructor);
406
- if (isMethodCall) {
407
- var typeName = this.getTypeName();
408
- // Fixes shim to be backward compatable with Node v0 to v4
409
- if (typeName === "[object Object]") {
410
- typeName = "null";
411
- }
412
- var methodName = this.getMethodName();
413
- if (functionName) {
414
- if (typeName && functionName.indexOf(typeName) != 0) {
415
- line += typeName + ".";
416
- }
417
- line += functionName;
418
- if (methodName && functionName.indexOf("." + methodName) != functionName.length - methodName.length - 1) {
419
- line += " [as " + methodName + "]";
420
- }
421
- } else {
422
- line += typeName + "." + (methodName || "<anonymous>");
423
- }
424
- } else if (isConstructor) {
425
- line += "new " + (functionName || "<anonymous>");
426
- } else if (functionName) {
427
- line += functionName;
428
- } else {
429
- line += fileLocation;
430
- addSuffix = false;
431
- }
432
- if (addSuffix) {
433
- line += " (" + fileLocation + ")";
434
- }
435
- return line;
436
- }
437
-
438
- function cloneCallSite(frame) {
439
- var object = {};
440
- Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach(function(name) {
441
- object[name] = /^(?:is|get)/.test(name) ? function() { return frame[name].call(frame); } : frame[name];
442
- });
443
- object.toString = CallSiteToString;
444
- return object;
445
- }
446
-
447
- function wrapCallSite(frame, state) {
448
- // provides interface backward compatibility
449
- if (state === undefined) {
450
- state = { nextPosition: null, curPosition: null };
451
- }
452
- if(frame.isNative()) {
453
- state.curPosition = null;
454
- return frame;
455
- }
456
-
457
- // Most call sites will return the source file from getFileName(), but code
458
- // passed to eval() ending in "//# sourceURL=..." will return the source file
459
- // from getScriptNameOrSourceURL() instead
460
- var source = frame.getFileName() || frame.getScriptNameOrSourceURL();
461
- if (source) {
462
- var line = frame.getLineNumber();
463
- var column = frame.getColumnNumber() - 1;
464
-
465
- // Fix position in Node where some (internal) code is prepended.
466
- // See https://github.com/evanw/node-source-map-support/issues/36
467
- // Header removed in node at ^10.16 || >=11.11.0
468
- // v11 is not an LTS candidate, we can just test the one version with it.
469
- // Test node versions for: 10.16-19, 10.20+, 12-19, 20-99, 100+, or 11.11
470
- var noHeader = /^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
471
- var headerLength = noHeader.test(globalProcessVersion()) ? 0 : 62;
472
- if (line === 1 && column > headerLength && !isInBrowser() && !frame.isEval()) {
473
- column -= headerLength;
474
- }
475
-
476
- var position = mapSourcePosition({
477
- source: source,
478
- line: line,
479
- column: column
480
- });
481
- state.curPosition = position;
482
- frame = cloneCallSite(frame);
483
- var originalFunctionName = frame.getFunctionName;
484
- frame.getFunctionName = function() {
485
- if (state.nextPosition == null) {
486
- return originalFunctionName();
487
- }
488
- return state.nextPosition.name || originalFunctionName();
489
- };
490
- frame.getFileName = function() { return position.source; };
491
- frame.getLineNumber = function() { return position.line; };
492
- frame.getColumnNumber = function() { return position.column + 1; };
493
- frame.getScriptNameOrSourceURL = function() { return position.source; };
494
- return frame;
495
- }
496
-
497
- // Code called using eval() needs special handling
498
- var origin = frame.isEval() && frame.getEvalOrigin();
499
- if (origin) {
500
- origin = mapEvalOrigin(origin);
501
- frame = cloneCallSite(frame);
502
- frame.getEvalOrigin = function() { return origin; };
503
- return frame;
504
- }
505
-
506
- // If we get here then we were unable to change the source position
507
- return frame;
508
- }
509
-
510
- // This function is part of the V8 stack trace API, for more info see:
511
- // https://v8.dev/docs/stack-trace-api
512
- function prepareStackTrace(error, stack) {
513
- if (emptyCacheBetweenOperations) {
514
- fileContentsCache = {};
515
- sourceMapCache = {};
516
- }
517
-
518
- var name = error.name || 'Error';
519
- var message = error.message || '';
520
- var errorString = name + ": " + message;
521
-
522
- var state = { nextPosition: null, curPosition: null };
523
- var processedStack = [];
524
- for (var i = stack.length - 1; i >= 0; i--) {
525
- processedStack.push('\n at ' + wrapCallSite(stack[i], state));
526
- state.nextPosition = state.curPosition;
527
- }
528
- state.curPosition = state.nextPosition = null;
529
- return errorString + processedStack.reverse().join('');
530
- }
531
-
532
- // Generate position and snippet of original source with pointer
533
- function getErrorSource(error) {
534
- var match = /\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack);
535
- if (match) {
536
- var source = match[1];
537
- var line = +match[2];
538
- var column = +match[3];
539
-
540
- // Support the inline sourceContents inside the source map
541
- var contents = fileContentsCache[source];
542
-
543
- // Support files on disk
544
- if (!contents && fs && fs.existsSync(source)) {
545
- try {
546
- contents = fs.readFileSync(source, 'utf8');
547
- } catch (er) {
548
- contents = '';
549
- }
550
- }
551
-
552
- // Format the line from the original source code like node does
553
- if (contents) {
554
- var code = contents.split(/(?:\r\n|\r|\n)/)[line - 1];
555
- if (code) {
556
- return source + ':' + line + '\n' + code + '\n' +
557
- new Array(column).join(' ') + '^';
558
- }
559
- }
560
- }
561
- return null;
562
- }
563
-
564
- function printErrorAndExit (error) {
565
- var source = getErrorSource(error);
566
-
567
- // Ensure error is printed synchronously and not truncated
568
- var stderr = globalProcessStderr();
569
- if (stderr && stderr._handle && stderr._handle.setBlocking) {
570
- stderr._handle.setBlocking(true);
571
- }
572
-
573
- if (source) {
574
- console.error();
575
- console.error(source);
576
- }
577
-
578
- console.error(error.stack);
579
- globalProcessExit(1);
580
- }
581
-
582
- function shimEmitUncaughtException () {
583
- var origEmit = process.emit;
584
-
585
- process.emit = function (type) {
586
- if (type === 'uncaughtException') {
587
- var hasStack = (arguments[1] && arguments[1].stack);
588
- var hasListeners = (this.listeners(type).length > 0);
589
-
590
- if (hasStack && !hasListeners) {
591
- return printErrorAndExit(arguments[1]);
592
- }
593
- }
594
-
595
- return origEmit.apply(this, arguments);
596
- };
597
- }
598
-
599
- var originalRetrieveFileHandlers = retrieveFileHandlers.slice(0);
600
- var originalRetrieveMapHandlers = retrieveMapHandlers.slice(0);
601
-
602
- exports.wrapCallSite = wrapCallSite;
603
- exports.getErrorSource = getErrorSource;
604
- exports.mapSourcePosition = mapSourcePosition;
605
- exports.retrieveSourceMap = retrieveSourceMap;
606
-
607
- exports.install = function(options) {
608
- options = options || {};
609
-
610
- if (options.environment) {
611
- environment = options.environment;
612
- if (["node", "browser", "auto"].indexOf(environment) === -1) {
613
- throw new Error("environment " + environment + " was unknown. Available options are {auto, browser, node}")
614
- }
615
- }
616
-
617
- // Allow sources to be found by methods other than reading the files
618
- // directly from disk.
619
- if (options.retrieveFile) {
620
- if (options.overrideRetrieveFile) {
621
- retrieveFileHandlers.length = 0;
622
- }
623
-
624
- retrieveFileHandlers.unshift(options.retrieveFile);
625
- }
626
-
627
- // Allow source maps to be found by methods other than reading the files
628
- // directly from disk.
629
- if (options.retrieveSourceMap) {
630
- if (options.overrideRetrieveSourceMap) {
631
- retrieveMapHandlers.length = 0;
632
- }
633
-
634
- retrieveMapHandlers.unshift(options.retrieveSourceMap);
635
- }
636
-
637
- // Support runtime transpilers that include inline source maps
638
- if (options.hookRequire && !isInBrowser()) {
639
- // Use dynamicRequire to avoid including in browser bundles
640
- var Module = dynamicRequire(module, 'module');
641
- var $compile = Module.prototype._compile;
642
-
643
- if (!$compile.__sourceMapSupport) {
644
- Module.prototype._compile = function(content, filename) {
645
- fileContentsCache[filename] = content;
646
- sourceMapCache[filename] = undefined;
647
- return $compile.call(this, content, filename);
648
- };
649
-
650
- Module.prototype._compile.__sourceMapSupport = true;
651
- }
652
- }
653
-
654
- // Configure options
655
- if (!emptyCacheBetweenOperations) {
656
- emptyCacheBetweenOperations = 'emptyCacheBetweenOperations' in options ?
657
- options.emptyCacheBetweenOperations : false;
658
- }
659
-
660
- // Install the error reformatter
661
- if (!errorFormatterInstalled) {
662
- errorFormatterInstalled = true;
663
- Error.prepareStackTrace = prepareStackTrace;
664
- }
665
-
666
- if (!uncaughtShimInstalled) {
667
- var installHandler = 'handleUncaughtExceptions' in options ?
668
- options.handleUncaughtExceptions : true;
669
-
670
- // Do not override 'uncaughtException' with our own handler in Node.js
671
- // Worker threads. Workers pass the error to the main thread as an event,
672
- // rather than printing something to stderr and exiting.
673
- try {
674
- // We need to use `dynamicRequire` because `require` on it's own will be optimized by WebPack/Browserify.
675
- var worker_threads = dynamicRequire(module, 'worker_threads');
676
- if (worker_threads.isMainThread === false) {
677
- installHandler = false;
678
- }
679
- } catch(e) {}
680
-
681
- // Provide the option to not install the uncaught exception handler. This is
682
- // to support other uncaught exception handlers (in test frameworks, for
683
- // example). If this handler is not installed and there are no other uncaught
684
- // exception handlers, uncaught exceptions will be caught by node's built-in
685
- // exception handler and the process will still be terminated. However, the
686
- // generated JavaScript code will be shown above the stack trace instead of
687
- // the original source code.
688
- if (installHandler && hasGlobalProcessEventEmitter()) {
689
- uncaughtShimInstalled = true;
690
- shimEmitUncaughtException();
691
- }
692
- }
693
- };
694
-
695
- exports.resetRetrieveHandlers = function() {
696
- retrieveFileHandlers.length = 0;
697
- retrieveMapHandlers.length = 0;
698
-
699
- retrieveFileHandlers = originalRetrieveFileHandlers.slice(0);
700
- retrieveMapHandlers = originalRetrieveMapHandlers.slice(0);
701
-
702
- retrieveSourceMap = handlerExec(retrieveMapHandlers);
703
- retrieveFile = handlerExec(retrieveFileHandlers);
704
- };
705
- } (sourceMapSupport, sourceMapSupport.exports));
706
-
707
- export { sourceMapSupport as s };