| const { TraceMap, originalPositionFor, AnyMap } = require('@jridgewell/trace-mapping'); |
| var path = require('path'); |
| const { fileURLToPath, pathToFileURL } = require('url'); |
| var util = require('util'); |
|
|
| var fs; |
| try { |
| fs = require('fs'); |
| if (!fs.existsSync || !fs.readFileSync) { |
| |
| fs = null; |
| } |
| } catch (err) { |
| |
| } |
|
|
| |
| |
| |
| |
| |
| |
| function dynamicRequire(mod, request) { |
| return mod.require(request); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| var sharedDataVersion = 1; |
|
|
| |
| |
| |
| |
| |
| function initializeSharedData(defaults) { |
| var sharedDataKey = 'source-map-support/sharedData'; |
| if (typeof Symbol !== 'undefined') { |
| sharedDataKey = Symbol.for(sharedDataKey); |
| } |
| var sharedData = this[sharedDataKey]; |
| if (!sharedData) { |
| sharedData = { version: sharedDataVersion }; |
| if (Object.defineProperty) { |
| Object.defineProperty(this, sharedDataKey, { value: sharedData }); |
| } else { |
| this[sharedDataKey] = sharedData; |
| } |
| } |
| if (sharedDataVersion !== sharedData.version) { |
| throw new Error("Multiple incompatible instances of source-map-support were loaded"); |
| } |
| for (var key in defaults) { |
| if (!(key in sharedData)) { |
| sharedData[key] = defaults[key]; |
| } |
| } |
| return sharedData; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| var sharedData = initializeSharedData({ |
|
|
| |
| |
| |
| errorPrepareStackTraceHook: undefined, |
| |
| processEmitHook: undefined, |
| |
| moduleResolveFilenameHook: undefined, |
|
|
| |
| onConflictingLibraryRedirectArr: [], |
|
|
| |
| emptyCacheBetweenOperations: false, |
|
|
| |
| fileContentsCache: Object.create(null), |
|
|
| |
| |
| sourceMapCache: Object.create(null), |
|
|
| |
| retrieveFileHandlers: [], |
| retrieveMapHandlers: [], |
|
|
| |
| |
| internalRetrieveFileHandlers: [], |
| internalRetrieveMapHandlers: [], |
|
|
| }); |
|
|
| |
| var environment = "auto"; |
|
|
| |
| var reSourceMap = /^data:application\/json[^,]+base64,/; |
|
|
| function isInBrowser() { |
| if (environment === "browser") |
| return true; |
| if (environment === "node") |
| return false; |
| return ((typeof window !== 'undefined') && (typeof XMLHttpRequest === 'function') && !(window.require && window.module && window.process && window.process.type === "renderer")); |
| } |
|
|
| function hasGlobalProcessEventEmitter() { |
| return ((typeof process === 'object') && (process !== null) && (typeof process.on === 'function')); |
| } |
|
|
| function tryFileURLToPath(v) { |
| if(isFileUrl(v)) { |
| return fileURLToPath(v); |
| } |
| return v; |
| } |
|
|
| |
| function isFileUrl(input) { |
| return input.startsWith('file:'); |
| } |
| function isAbsoluteUrl(input) { |
| return schemeRegex.test(input); |
| } |
| |
| const schemeRegex = /^[\w+.-]+:\/\//; |
| function isSchemeRelativeUrl(input) { |
| return input.startsWith('//'); |
| } |
|
|
| |
| |
| function getCacheKey(pathOrFileUrl) { |
| if(pathOrFileUrl.startsWith('node:')) return pathOrFileUrl; |
| if(isFileUrl(pathOrFileUrl)) { |
| |
| return new URL(pathOrFileUrl).toString(); |
| } else { |
| try { |
| return pathToFileURL(pathOrFileUrl).toString(); |
| } catch { |
| return pathOrFileUrl; |
| } |
| } |
| } |
| function getFileContentsCache(key) { |
| return sharedData.fileContentsCache[getCacheKey(key)]; |
| } |
| function hasFileContentsCacheFromKey(key) { |
| return Object.prototype.hasOwnProperty.call(sharedData.fileContentsCache, key); |
| } |
| function getFileContentsCacheFromKey(key) { |
| return sharedData.fileContentsCache[key]; |
| } |
| function setFileContentsCache(key, value) { |
| return sharedData.fileContentsCache[getCacheKey(key)] = value; |
| } |
| function getSourceMapCache(key) { |
| return sharedData.sourceMapCache[getCacheKey(key)]; |
| } |
| function setSourceMapCache(key, value) { |
| return sharedData.sourceMapCache[getCacheKey(key)] = value; |
| } |
| function clearCaches() { |
| sharedData.fileContentsCache = Object.create(null); |
| sharedData.sourceMapCache = Object.create(null); |
| } |
| |
|
|
| function handlerExec(list, internalList) { |
| return function(arg) { |
| for (var i = 0; i < list.length; i++) { |
| var ret = list[i](arg); |
| if (ret) { |
| return ret; |
| } |
| } |
| for (var i = 0; i < internalList.length; i++) { |
| var ret = internalList[i](arg); |
| if (ret) { |
| return ret; |
| } |
| } |
| return null; |
| }; |
| } |
|
|
| var retrieveFile = handlerExec(sharedData.retrieveFileHandlers, sharedData.internalRetrieveFileHandlers); |
|
|
| sharedData.internalRetrieveFileHandlers.push(function(path) { |
| |
| path = path.trim(); |
| if (/^file:/.test(path)) { |
| |
| path = path.replace(/file:\/\/\/(\w:)?/, function(protocol, drive) { |
| return drive ? |
| '' : |
| '/'; |
| }); |
| } |
| const key = getCacheKey(path); |
| if(hasFileContentsCacheFromKey(key)) { |
| return getFileContentsCacheFromKey(key); |
| } |
|
|
| var contents = ''; |
| try { |
| if (!fs) { |
| |
| var xhr = new XMLHttpRequest(); |
| xhr.open('GET', path, false); |
| xhr.send(null); |
| if (xhr.readyState === 4 && xhr.status === 200) { |
| contents = xhr.responseText; |
| } |
| } else if (fs.existsSync(path)) { |
| |
| contents = fs.readFileSync(path, 'utf8'); |
| } |
| } catch (er) { |
| |
| } |
|
|
| return setFileContentsCache(path, contents); |
| }); |
|
|
| |
| |
| function supportRelativeURL(file, url) { |
| if(!file) return url; |
| |
| |
| try { |
| |
| if(isAbsoluteUrl(file) || isSchemeRelativeUrl(file)) { |
| if(isAbsoluteUrl(url) || isSchemeRelativeUrl(url)) { |
| return new URL(url, file).toString(); |
| } |
| if(path.isAbsolute(url)) { |
| return new URL(pathToFileURL(url), file).toString(); |
| } |
| |
| return new URL(url.replace(/\\/g, '/'), file).toString(); |
| } |
| |
| if(path.isAbsolute(file)) { |
| if(isFileUrl(url)) { |
| return fileURLToPath(url); |
| } |
| if(isSchemeRelativeUrl(url)) { |
| return fileURLToPath(new URL(url, 'file://')); |
| } |
| if(isAbsoluteUrl(url)) { |
| |
| |
| return url; |
| } |
| if(path.isAbsolute(url)) { |
| |
| return path.normalize(url); |
| } |
| |
| return path.join(file, '..', decodeURI(url)); |
| } |
| |
| |
| |
| if(isAbsoluteUrl(url) || isSchemeRelativeUrl(url)) { |
| return url; |
| } |
| return path.join(file, '..', url); |
| } catch(e) { |
| return url; |
| } |
| } |
|
|
| |
| function matchStyleOfPathOrUrl(matchStyleOf, pathOrUrl) { |
| try { |
| if(isAbsoluteUrl(matchStyleOf) || isSchemeRelativeUrl(matchStyleOf)) { |
| if(isAbsoluteUrl(pathOrUrl) || isSchemeRelativeUrl(pathOrUrl)) return pathOrUrl; |
| if(path.isAbsolute(pathOrUrl)) return pathToFileURL(pathOrUrl).toString(); |
| } else if(path.isAbsolute(matchStyleOf)) { |
| if(isAbsoluteUrl(pathOrUrl) || isSchemeRelativeUrl(pathOrUrl)) { |
| return fileURLToPath(new URL(pathOrUrl, 'file://')); |
| } |
| } |
| return pathOrUrl; |
| } catch(e) { |
| return pathOrUrl; |
| } |
| } |
|
|
| function retrieveSourceMapURL(source) { |
| var fileData; |
|
|
| if (isInBrowser()) { |
| try { |
| var xhr = new XMLHttpRequest(); |
| xhr.open('GET', source, false); |
| xhr.send(null); |
| fileData = xhr.readyState === 4 ? xhr.responseText : null; |
|
|
| |
| var sourceMapHeader = xhr.getResponseHeader("SourceMap") || |
| xhr.getResponseHeader("X-SourceMap"); |
| if (sourceMapHeader) { |
| return sourceMapHeader; |
| } |
| } catch (e) { |
| } |
| } |
|
|
| |
| fileData = retrieveFile(tryFileURLToPath(source)); |
| var re = /(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg; |
| |
| |
| var lastMatch, match; |
| while (match = re.exec(fileData)) lastMatch = match; |
| if (!lastMatch) return null; |
| return lastMatch[1]; |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| var retrieveSourceMap = handlerExec(sharedData.retrieveMapHandlers, sharedData.internalRetrieveMapHandlers); |
| sharedData.internalRetrieveMapHandlers.push(function(source) { |
| var sourceMappingURL = retrieveSourceMapURL(source); |
| if (!sourceMappingURL) return null; |
|
|
| |
| var sourceMapData; |
| if (reSourceMap.test(sourceMappingURL)) { |
| |
| var rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(',') + 1); |
| sourceMapData = Buffer.from(rawData, "base64").toString(); |
| sourceMappingURL = source; |
| } else { |
| |
| sourceMappingURL = supportRelativeURL(source, sourceMappingURL); |
| sourceMapData = retrieveFile(tryFileURLToPath(sourceMappingURL)); |
| } |
|
|
| if (!sourceMapData) { |
| return null; |
| } |
|
|
| return { |
| url: sourceMappingURL, |
| map: sourceMapData |
| }; |
| }); |
|
|
| function mapSourcePosition(position) { |
| var sourceMap = getSourceMapCache(position.source); |
| if (!sourceMap) { |
| |
| var urlAndMap = retrieveSourceMap(position.source); |
| if (urlAndMap) { |
| sourceMap = setSourceMapCache(position.source, { |
| url: urlAndMap.url, |
| map: new AnyMap(urlAndMap.map, urlAndMap.url) |
| }); |
|
|
| |
| |
| |
| sourceMap.map.resolvedSources = sourceMap.map.sources.map(s => supportRelativeURL(sourceMap.url, s)); |
|
|
| |
| |
| if (sourceMap.map.sourcesContent) { |
| sourceMap.map.resolvedSources.forEach(function(resolvedSource, i) { |
| var contents = sourceMap.map.sourcesContent[i]; |
| if (contents) { |
| setFileContentsCache(resolvedSource, contents); |
| } |
| }); |
| } |
| } else { |
| sourceMap = setSourceMapCache(position.source, { |
| url: null, |
| map: null |
| }); |
| } |
| } |
|
|
| |
| if (sourceMap && sourceMap.map) { |
| var originalPosition = originalPositionFor(sourceMap.map, position); |
|
|
| |
| |
| |
| |
| |
| if (originalPosition.source !== null) { |
| |
| |
| |
| originalPosition.source = matchStyleOfPathOrUrl( |
| position.source, originalPosition.source); |
| return originalPosition; |
| } |
| } |
|
|
| return position; |
| } |
|
|
| |
| |
| function mapEvalOrigin(origin) { |
| |
| var match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin); |
| if (match) { |
| var position = mapSourcePosition({ |
| source: match[2], |
| line: +match[3], |
| column: match[4] - 1 |
| }); |
| return 'eval at ' + match[1] + ' (' + position.source + ':' + |
| position.line + ':' + (position.column + 1) + ')'; |
| } |
|
|
| |
| match = /^eval at ([^(]+) \((.+)\)$/.exec(origin); |
| if (match) { |
| return 'eval at ' + match[1] + ' (' + mapEvalOrigin(match[2]) + ')'; |
| } |
|
|
| |
| return origin; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function CallSiteToString() { |
| var fileName; |
| var fileLocation = ""; |
| if (this.isNative()) { |
| fileLocation = "native"; |
| } else { |
| fileName = this.getScriptNameOrSourceURL(); |
| if (!fileName && this.isEval()) { |
| fileLocation = this.getEvalOrigin(); |
| fileLocation += ", "; |
| } |
|
|
| if (fileName) { |
| fileLocation += fileName; |
| } else { |
| |
| |
| |
| fileLocation += "<anonymous>"; |
| } |
| var lineNumber = this.getLineNumber(); |
| if (lineNumber != null) { |
| fileLocation += ":" + lineNumber; |
| var columnNumber = this.getColumnNumber(); |
| if (columnNumber) { |
| fileLocation += ":" + columnNumber; |
| } |
| } |
| } |
|
|
| var line = ""; |
| var isAsync = this.isAsync ? this.isAsync() : false; |
| if(isAsync) { |
| line += 'async '; |
| var isPromiseAll = this.isPromiseAll ? this.isPromiseAll() : false; |
| var isPromiseAny = this.isPromiseAny ? this.isPromiseAny() : false; |
| if(isPromiseAny || isPromiseAll) { |
| line += isPromiseAll ? 'Promise.all (index ' : 'Promise.any (index '; |
| var promiseIndex = this.getPromiseIndex(); |
| line += promiseIndex + ')'; |
| } |
| } |
| var functionName = this.getFunctionName(); |
| var addSuffix = true; |
| var isConstructor = this.isConstructor(); |
| var isMethodCall = !(this.isToplevel() || isConstructor); |
| if (isMethodCall) { |
| var typeName = this.getTypeName(); |
| |
| if (typeName === "[object Object]") { |
| typeName = "null"; |
| } |
| var methodName = this.getMethodName(); |
| if (functionName) { |
| if (typeName && functionName.indexOf(typeName) != 0) { |
| line += typeName + "."; |
| } |
| line += functionName; |
| if (methodName && functionName.indexOf("." + methodName) != functionName.length - methodName.length - 1) { |
| line += " [as " + methodName + "]"; |
| } |
| } else { |
| line += typeName + "." + (methodName || "<anonymous>"); |
| } |
| } else if (isConstructor) { |
| line += "new " + (functionName || "<anonymous>"); |
| } else if (functionName) { |
| line += functionName; |
| } else { |
| line += fileLocation; |
| addSuffix = false; |
| } |
| if (addSuffix) { |
| line += " (" + fileLocation + ")"; |
| } |
| return line; |
| } |
|
|
| function cloneCallSite(frame) { |
| var object = {}; |
| Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach(function(name) { |
| object[name] = /^(?:is|get)/.test(name) ? function() { return frame[name].call(frame); } : frame[name]; |
| }); |
| object.toString = CallSiteToString; |
| return object; |
| } |
|
|
| function wrapCallSite(frame, state) { |
| |
| if (state === undefined) { |
| state = { nextPosition: null, curPosition: null } |
| } |
| if(frame.isNative()) { |
| state.curPosition = null; |
| return frame; |
| } |
|
|
| |
| |
| |
| var source = frame.getFileName() || frame.getScriptNameOrSourceURL(); |
| if (source) { |
| |
| if(source.startsWith('wasm://')) { |
| state.curPosition = null; |
| return frame; |
| } |
|
|
| var line = frame.getLineNumber(); |
| var column = frame.getColumnNumber() - 1; |
|
|
| |
| |
| |
| |
| |
| 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)/; |
| var headerLength = noHeader.test(process.version) ? 0 : 62; |
| if (line === 1 && column > headerLength && !isInBrowser() && !frame.isEval()) { |
| column -= headerLength; |
| } |
|
|
| var position = mapSourcePosition({ |
| source: source, |
| line: line, |
| column: column |
| }); |
| state.curPosition = position; |
| frame = cloneCallSite(frame); |
| var originalFunctionName = frame.getFunctionName; |
| frame.getFunctionName = function() { |
| if (state.nextPosition == null) { |
| return originalFunctionName(); |
| } |
| return state.nextPosition.name || originalFunctionName(); |
| }; |
| frame.getFileName = function() { return position.source; }; |
| frame.getLineNumber = function() { return position.line; }; |
| frame.getColumnNumber = function() { return position.column + 1; }; |
| frame.getScriptNameOrSourceURL = function() { return position.source; }; |
| return frame; |
| } |
|
|
| |
| var origin = frame.isEval() && frame.getEvalOrigin(); |
| if (origin) { |
| origin = mapEvalOrigin(origin); |
| frame = cloneCallSite(frame); |
| frame.getEvalOrigin = function() { return origin; }; |
| return frame; |
| } |
|
|
| |
| return frame; |
| } |
|
|
| var kIsNodeError = undefined; |
| try { |
| |
| |
| path.resolve(123); |
| } catch(e) { |
| const symbols = Object.getOwnPropertySymbols(e); |
| const symbol = symbols.find(function (s) {return s.toString().indexOf('kIsNodeError') >= 0}); |
| if(symbol) kIsNodeError = symbol; |
| } |
|
|
| const ErrorPrototypeToString = (err) =>Error.prototype.toString.call(err); |
|
|
| |
| function createPrepareStackTrace(hookState) { |
| return prepareStackTrace; |
|
|
| |
| |
| function prepareStackTrace(error, stack) { |
| if(!hookState.enabled) return hookState.originalValue.apply(this, arguments); |
|
|
| if (sharedData.emptyCacheBetweenOperations) { |
| clearCaches(); |
| } |
|
|
| |
| |
| |
| var errorString; |
| if (kIsNodeError) { |
| if(kIsNodeError in error) { |
| errorString = `${error.name} [${error.code}]: ${error.message}`; |
| } else { |
| errorString = ErrorPrototypeToString(error); |
| } |
| } else { |
| var name = error.name || 'Error'; |
| var message = error.message || ''; |
| errorString = message ? name + ": " + message : name; |
| } |
|
|
| var state = { nextPosition: null, curPosition: null }; |
| var processedStack = []; |
| for (var i = stack.length - 1; i >= 0; i--) { |
| processedStack.push('\n at ' + wrapCallSite(stack[i], state)); |
| state.nextPosition = state.curPosition; |
| } |
| state.curPosition = state.nextPosition = null; |
| return errorString + processedStack.reverse().join(''); |
| } |
| } |
|
|
| |
| function getErrorSource(error) { |
| var match = /\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack); |
| if (match) { |
| var source = match[1]; |
| var line = +match[2]; |
| var column = +match[3]; |
|
|
| |
| var contents = getFileContentsCache(source); |
|
|
| const sourceAsPath = tryFileURLToPath(source); |
|
|
| |
| if (!contents && fs && fs.existsSync(sourceAsPath)) { |
| try { |
| contents = fs.readFileSync(sourceAsPath, 'utf8'); |
| } catch (er) { |
| contents = ''; |
| } |
| } |
|
|
| |
| if (contents) { |
| var code = contents.split(/(?:\r\n|\r|\n)/)[line - 1]; |
| if (code) { |
| return source + ':' + line + '\n' + code + '\n' + |
| new Array(column).join(' ') + '^'; |
| } |
| } |
| } |
| return null; |
| } |
|
|
| function printFatalErrorUponExit (error) { |
| var source = getErrorSource(error); |
|
|
| |
| if (process.stderr._handle && process.stderr._handle.setBlocking) { |
| process.stderr._handle.setBlocking(true); |
| } |
|
|
| if (source) { |
| console.error(source); |
| } |
|
|
| |
| console.error( |
| util.inspect(error, { |
| customInspect: false, |
| colors: process.stderr.isTTY |
| }) |
| ); |
| } |
|
|
| function shimEmitUncaughtException () { |
| const originalValue = process.emit; |
| var hook = sharedData.processEmitHook = { |
| enabled: true, |
| originalValue, |
| installedValue: undefined |
| }; |
| var isTerminatingDueToFatalException = false; |
| var fatalException; |
|
|
| process.emit = sharedData.processEmitHook.installedValue = function (type) { |
| const hadListeners = originalValue.apply(this, arguments); |
| if(hook.enabled) { |
| if (type === 'uncaughtException' && !hadListeners) { |
| isTerminatingDueToFatalException = true; |
| fatalException = arguments[1]; |
| process.exit(1); |
| } |
| if (type === 'exit' && isTerminatingDueToFatalException) { |
| printFatalErrorUponExit(fatalException); |
| } |
| } |
| return hadListeners; |
| }; |
| } |
|
|
| var originalRetrieveFileHandlers = sharedData.retrieveFileHandlers.slice(0); |
| var originalRetrieveMapHandlers = sharedData.retrieveMapHandlers.slice(0); |
|
|
| exports.wrapCallSite = wrapCallSite; |
| exports.getErrorSource = getErrorSource; |
| exports.mapSourcePosition = mapSourcePosition; |
| exports.retrieveSourceMap = retrieveSourceMap; |
|
|
| exports.install = function(options) { |
| options = options || {}; |
|
|
| if (options.environment) { |
| environment = options.environment; |
| if (["node", "browser", "auto"].indexOf(environment) === -1) { |
| throw new Error("environment " + environment + " was unknown. Available options are {auto, browser, node}") |
| } |
| } |
|
|
| |
| var Module = dynamicRequire(module, 'module'); |
|
|
| |
| |
| const {redirectConflictingLibrary = true, onConflictingLibraryRedirect} = options; |
| if(redirectConflictingLibrary) { |
| if (!sharedData.moduleResolveFilenameHook) { |
| const originalValue = Module._resolveFilename; |
| const moduleResolveFilenameHook = sharedData.moduleResolveFilenameHook = { |
| enabled: true, |
| originalValue, |
| installedValue: undefined, |
| } |
| Module._resolveFilename = sharedData.moduleResolveFilenameHook.installedValue = function (request, parent, isMain, options) { |
| if (moduleResolveFilenameHook.enabled) { |
| |
| let requestRedirect; |
| if (request === 'source-map-support') { |
| requestRedirect = './'; |
| } else if (request === 'source-map-support/register') { |
| requestRedirect = './register'; |
| } |
|
|
| if (requestRedirect !== undefined) { |
| const newRequest = require.resolve(requestRedirect); |
| for (const cb of sharedData.onConflictingLibraryRedirectArr) { |
| cb(request, parent, isMain, options, newRequest); |
| } |
| request = newRequest; |
| } |
| } |
| |
| return originalValue.call(this, request, parent, isMain, options); |
| } |
| } |
| if (onConflictingLibraryRedirect) { |
| sharedData.onConflictingLibraryRedirectArr.push(onConflictingLibraryRedirect); |
| } |
| } |
|
|
| |
| |
| if (options.retrieveFile) { |
| if (options.overrideRetrieveFile) { |
| sharedData.retrieveFileHandlers.length = 0; |
| } |
|
|
| sharedData.retrieveFileHandlers.unshift(options.retrieveFile); |
| } |
|
|
| |
| |
| if (options.retrieveSourceMap) { |
| if (options.overrideRetrieveSourceMap) { |
| sharedData.retrieveMapHandlers.length = 0; |
| } |
|
|
| sharedData.retrieveMapHandlers.unshift(options.retrieveSourceMap); |
| } |
|
|
| |
| if (options.hookRequire && !isInBrowser()) { |
| var $compile = Module.prototype._compile; |
|
|
| if (!$compile.__sourceMapSupport) { |
| Module.prototype._compile = function(content, filename) { |
| setFileContentsCache(filename, content); |
| setSourceMapCache(filename, undefined); |
| return $compile.call(this, content, filename); |
| }; |
|
|
| Module.prototype._compile.__sourceMapSupport = true; |
| } |
| } |
|
|
| |
| if (!sharedData.emptyCacheBetweenOperations) { |
| sharedData.emptyCacheBetweenOperations = 'emptyCacheBetweenOperations' in options ? |
| options.emptyCacheBetweenOperations : false; |
| } |
|
|
|
|
| |
| if (!sharedData.errorPrepareStackTraceHook) { |
| const originalValue = Error.prepareStackTrace; |
| sharedData.errorPrepareStackTraceHook = { |
| enabled: true, |
| originalValue, |
| installedValue: undefined |
| }; |
| Error.prepareStackTrace = sharedData.errorPrepareStackTraceHook.installedValue = createPrepareStackTrace(sharedData.errorPrepareStackTraceHook); |
| } |
|
|
| if (!sharedData.processEmitHook) { |
| var installHandler = 'handleUncaughtExceptions' in options ? |
| options.handleUncaughtExceptions : true; |
|
|
| |
| |
| |
| try { |
| |
| var worker_threads = dynamicRequire(module, 'worker_threads'); |
| if (worker_threads.isMainThread === false) { |
| installHandler = false; |
| } |
| } catch(e) {} |
|
|
| |
| |
| |
| |
| |
| |
| |
| if (installHandler && hasGlobalProcessEventEmitter()) { |
| shimEmitUncaughtException(); |
| } |
| } |
| }; |
|
|
| exports.uninstall = function() { |
| if(sharedData.processEmitHook) { |
| |
| sharedData.processEmitHook.enabled = false; |
| |
| if(process.emit === sharedData.processEmitHook.installedValue) { |
| process.emit = sharedData.processEmitHook.originalValue; |
| } |
| sharedData.processEmitHook = undefined; |
| } |
| if(sharedData.errorPrepareStackTraceHook) { |
| |
| sharedData.errorPrepareStackTraceHook.enabled = false; |
| |
| |
| |
| |
| if(Error.prepareStackTrace === sharedData.errorPrepareStackTraceHook.installedValue || typeof sharedData.errorPrepareStackTraceHook.originalValue !== 'function') { |
| Error.prepareStackTrace = sharedData.errorPrepareStackTraceHook.originalValue; |
| } |
| sharedData.errorPrepareStackTraceHook = undefined; |
| } |
| if (sharedData.moduleResolveFilenameHook) { |
| |
| sharedData.moduleResolveFilenameHook.enabled = false; |
| |
| var Module = dynamicRequire(module, 'module'); |
| if(Module._resolveFilename === sharedData.moduleResolveFilenameHook.installedValue) { |
| Module._resolveFilename = sharedData.moduleResolveFilenameHook.originalValue; |
| } |
| sharedData.moduleResolveFilenameHook = undefined; |
| } |
| sharedData.onConflictingLibraryRedirectArr.length = 0; |
| } |
|
|
| exports.resetRetrieveHandlers = function() { |
| sharedData.retrieveFileHandlers.length = 0; |
| sharedData.retrieveMapHandlers.length = 0; |
| } |
|
|