UNPKG

@rstest/core

Version:
977 lines 90 kB
import 'module'; /*#__PURE__*/ import.meta.url; export const __webpack_ids__ = [ "64" ]; export const __webpack_modules__ = { "../../node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/index.js": function(module) { var toString = Object.prototype.toString; var isModern = 'undefined' != typeof Buffer && 'function' == typeof Buffer.alloc && 'function' == typeof Buffer.allocUnsafe && 'function' == typeof Buffer.from; function isArrayBuffer(input) { return 'ArrayBuffer' === toString.call(input).slice(8, -1); } function fromArrayBuffer(obj, byteOffset, length) { byteOffset >>>= 0; var maxLength = obj.byteLength - byteOffset; if (maxLength < 0) throw new RangeError("'offset' is out of bounds"); if (void 0 === length) length = maxLength; else { length >>>= 0; if (length > maxLength) throw new RangeError("'length' is out of bounds"); } return isModern ? Buffer.from(obj.slice(byteOffset, byteOffset + length)) : new Buffer(new Uint8Array(obj.slice(byteOffset, byteOffset + length))); } function fromString(string, encoding) { if ('string' != typeof encoding || '' === encoding) encoding = 'utf8'; if (!Buffer.isEncoding(encoding)) throw new TypeError('"encoding" must be a valid string encoding'); return isModern ? Buffer.from(string, encoding) : new Buffer(string, encoding); } function bufferFrom(value, encodingOrOffset, length) { if ('number' == typeof value) throw new TypeError('"value" argument must not be a number'); if (isArrayBuffer(value)) return fromArrayBuffer(value, encodingOrOffset, length); if ('string' == typeof value) return fromString(value, encodingOrOffset); return isModern ? Buffer.from(value) : new Buffer(value); } module.exports = bufferFrom; }, "../../node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/source-map-support.js": function(module, exports, __webpack_require__) { module = __webpack_require__.nmd(module); var SourceMapConsumer = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/source-map.js").SourceMapConsumer; var path = __webpack_require__("node:path"); var fs; try { fs = __webpack_require__("fs"); if (!fs.existsSync || !fs.readFileSync) fs = null; } catch (err) {} var bufferFrom = __webpack_require__("../../node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/index.js"); function dynamicRequire(mod, request) { return mod.require(request); } var errorFormatterInstalled = false; var uncaughtShimInstalled = false; var emptyCacheBetweenOperations = false; var environment = "auto"; var fileContentsCache = {}; var sourceMapCache = {}; var reSourceMap = /^data:application\/json[^,]+base64,/; var retrieveFileHandlers = []; var retrieveMapHandlers = []; function isInBrowser() { if ("browser" === environment) return true; if ("node" === environment) return false; return 'undefined' != typeof window && 'function' == typeof XMLHttpRequest && !(window.require && window.module && window.process && "renderer" === window.process.type); } function hasGlobalProcessEventEmitter() { return 'object' == typeof process && null !== process && 'function' == typeof process.on; } function globalProcessVersion() { if ('object' == typeof process && null !== process) return process.version; return ''; } function globalProcessStderr() { if ('object' == typeof process && null !== process) return process.stderr; } function globalProcessExit(code) { if ('object' == typeof process && null !== process && 'function' == typeof process.exit) return process.exit(code); } function handlerExec(list) { return function(arg) { for(var i = 0; i < list.length; i++){ var ret = list[i](arg); if (ret) return ret; } return null; }; } var retrieveFile = handlerExec(retrieveFileHandlers); retrieveFileHandlers.push(function(path) { path = path.trim(); if (/^file:/.test(path)) path = path.replace(/file:\/\/\/(\w:)?/, function(protocol, drive) { return drive ? '' : '/'; }); if (path in fileContentsCache) return fileContentsCache[path]; var contents = ''; try { if (fs) { if (fs.existsSync(path)) contents = fs.readFileSync(path, 'utf8'); } else { var xhr = new XMLHttpRequest(); xhr.open('GET', path, false); xhr.send(null); if (4 === xhr.readyState && 200 === xhr.status) contents = xhr.responseText; } } catch (er) {} return fileContentsCache[path] = contents; }); function supportRelativeURL(file, url) { if (!file) return url; var dir = path.dirname(file); var match = /^\w+:\/\/[^\/]*/.exec(dir); var protocol = match ? match[0] : ''; var startPath = dir.slice(protocol.length); if (protocol && /^\/\w\:/.test(startPath)) { protocol += '/'; return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/'); } return protocol + path.resolve(dir.slice(protocol.length), url); } function retrieveSourceMapURL(source) { var fileData; if (isInBrowser()) try { var xhr = new XMLHttpRequest(); xhr.open('GET', source, false); xhr.send(null); fileData = 4 === xhr.readyState ? xhr.responseText : null; var sourceMapHeader = xhr.getResponseHeader("SourceMap") || xhr.getResponseHeader("X-SourceMap"); if (sourceMapHeader) return sourceMapHeader; } catch (e) {} fileData = retrieveFile(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(retrieveMapHandlers); retrieveMapHandlers.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 = bufferFrom(rawData, "base64").toString(); sourceMappingURL = source; } else { sourceMappingURL = supportRelativeURL(source, sourceMappingURL); sourceMapData = retrieveFile(sourceMappingURL); } if (!sourceMapData) return null; return { url: sourceMappingURL, map: sourceMapData }; }); function mapSourcePosition(position) { var sourceMap = sourceMapCache[position.source]; if (!sourceMap) { var urlAndMap = retrieveSourceMap(position.source); if (urlAndMap) { sourceMap = sourceMapCache[position.source] = { url: urlAndMap.url, map: new SourceMapConsumer(urlAndMap.map) }; if (sourceMap.map.sourcesContent) sourceMap.map.sources.forEach(function(source, i) { var contents = sourceMap.map.sourcesContent[i]; if (contents) { var url = supportRelativeURL(sourceMap.url, source); fileContentsCache[url] = contents; } }); } else sourceMap = sourceMapCache[position.source] = { url: null, map: null }; } if (sourceMap && sourceMap.map && 'function' == typeof sourceMap.map.originalPositionFor) { var originalPosition = sourceMap.map.originalPositionFor(position); if (null !== originalPosition.source) { originalPosition.source = supportRelativeURL(sourceMap.url, 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 (null != lineNumber) { fileLocation += ":" + lineNumber; var columnNumber = this.getColumnNumber(); if (columnNumber) fileLocation += ":" + columnNumber; } } var line = ""; var functionName = this.getFunctionName(); var addSuffix = true; var isConstructor = this.isConstructor(); var isMethodCall = !(this.isToplevel() || isConstructor); if (isMethodCall) { var typeName = this.getTypeName(); if ("[object Object]" === typeName) typeName = "null"; var methodName = this.getMethodName(); if (functionName) { if (typeName && 0 != functionName.indexOf(typeName)) 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 (void 0 === state) state = { nextPosition: null, curPosition: null }; if (frame.isNative()) { state.curPosition = null; return frame; } var source = frame.getFileName() || frame.getScriptNameOrSourceURL(); if (source) { 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(globalProcessVersion()) ? 0 : 62; if (1 === line && 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 (null == state.nextPosition) 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; } function prepareStackTrace(error, stack) { if (emptyCacheBetweenOperations) { fileContentsCache = {}; sourceMapCache = {}; } var name = error.name || 'Error'; var message = error.message || ''; var errorString = name + ": " + message; 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 = fileContentsCache[source]; if (!contents && fs && fs.existsSync(source)) try { contents = fs.readFileSync(source, '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 printErrorAndExit(error) { var source = getErrorSource(error); var stderr = globalProcessStderr(); if (stderr && stderr._handle && stderr._handle.setBlocking) stderr._handle.setBlocking(true); if (source) { console.error(); console.error(source); } console.error(error.stack); globalProcessExit(1); } function shimEmitUncaughtException() { var origEmit = process.emit; process.emit = function(type) { if ('uncaughtException' === type) { var hasStack = arguments[1] && arguments[1].stack; var hasListeners = this.listeners(type).length > 0; if (hasStack && !hasListeners) return printErrorAndExit(arguments[1]); } return origEmit.apply(this, arguments); }; } var originalRetrieveFileHandlers = retrieveFileHandlers.slice(0); var originalRetrieveMapHandlers = 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 (-1 === [ "node", "browser", "auto" ].indexOf(environment)) throw new Error("environment " + environment + " was unknown. Available options are {auto, browser, node}"); } if (options.retrieveFile) { if (options.overrideRetrieveFile) retrieveFileHandlers.length = 0; retrieveFileHandlers.unshift(options.retrieveFile); } if (options.retrieveSourceMap) { if (options.overrideRetrieveSourceMap) retrieveMapHandlers.length = 0; retrieveMapHandlers.unshift(options.retrieveSourceMap); } if (options.hookRequire && !isInBrowser()) { var Module = dynamicRequire(module, 'module'); var $compile = Module.prototype._compile; if (!$compile.__sourceMapSupport) { Module.prototype._compile = function(content, filename) { fileContentsCache[filename] = content; sourceMapCache[filename] = void 0; return $compile.call(this, content, filename); }; Module.prototype._compile.__sourceMapSupport = true; } } if (!emptyCacheBetweenOperations) emptyCacheBetweenOperations = 'emptyCacheBetweenOperations' in options ? options.emptyCacheBetweenOperations : false; if (!errorFormatterInstalled) { errorFormatterInstalled = true; Error.prepareStackTrace = prepareStackTrace; } if (!uncaughtShimInstalled) { var installHandler = 'handleUncaughtExceptions' in options ? options.handleUncaughtExceptions : true; try { var worker_threads = dynamicRequire(module, 'worker_threads'); if (false === worker_threads.isMainThread) installHandler = false; } catch (e) {} if (installHandler && hasGlobalProcessEventEmitter()) { uncaughtShimInstalled = true; shimEmitUncaughtException(); } } }; exports.resetRetrieveHandlers = function() { retrieveFileHandlers.length = 0; retrieveMapHandlers.length = 0; retrieveFileHandlers = originalRetrieveFileHandlers.slice(0); retrieveMapHandlers = originalRetrieveMapHandlers.slice(0); retrieveSourceMap = handlerExec(retrieveMapHandlers); retrieveFile = handlerExec(retrieveFileHandlers); }; }, "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/array-set.js": function(__unused_webpack_module, exports, __webpack_require__) { var util = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/util.js"); var has = Object.prototype.hasOwnProperty; var hasNativeMap = "undefined" != typeof Map; function ArraySet() { this._array = []; this._set = hasNativeMap ? new Map() : Object.create(null); } ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { var set = new ArraySet(); for(var i = 0, len = aArray.length; i < len; i++)set.add(aArray[i], aAllowDuplicates); return set; }; ArraySet.prototype.size = function ArraySet_size() { return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length; }; ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { var sStr = hasNativeMap ? aStr : util.toSetString(aStr); var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr); var idx = this._array.length; if (!isDuplicate || aAllowDuplicates) this._array.push(aStr); if (!isDuplicate) if (hasNativeMap) this._set.set(aStr, idx); else this._set[sStr] = idx; }; ArraySet.prototype.has = function ArraySet_has(aStr) { if (hasNativeMap) return this._set.has(aStr); var sStr = util.toSetString(aStr); return has.call(this._set, sStr); }; ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { if (hasNativeMap) { var idx = this._set.get(aStr); if (idx >= 0) return idx; } else { var sStr = util.toSetString(aStr); if (has.call(this._set, sStr)) return this._set[sStr]; } throw new Error('"' + aStr + '" is not in the set.'); }; ArraySet.prototype.at = function ArraySet_at(aIdx) { if (aIdx >= 0 && aIdx < this._array.length) return this._array[aIdx]; throw new Error('No element indexed by ' + aIdx); }; ArraySet.prototype.toArray = function ArraySet_toArray() { return this._array.slice(); }; exports.ArraySet = ArraySet; }, "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/base64-vlq.js": function(__unused_webpack_module, exports, __webpack_require__) { var base64 = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/base64.js"); var VLQ_BASE_SHIFT = 5; var VLQ_BASE = 1 << VLQ_BASE_SHIFT; var VLQ_BASE_MASK = VLQ_BASE - 1; var VLQ_CONTINUATION_BIT = VLQ_BASE; function toVLQSigned(aValue) { return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0; } function fromVLQSigned(aValue) { var isNegative = (1 & aValue) === 1; var shifted = aValue >> 1; return isNegative ? -shifted : shifted; } exports.encode = function base64VLQ_encode(aValue) { var encoded = ""; var digit; var vlq = toVLQSigned(aValue); do { digit = vlq & VLQ_BASE_MASK; vlq >>>= VLQ_BASE_SHIFT; if (vlq > 0) digit |= VLQ_CONTINUATION_BIT; encoded += base64.encode(digit); }while (vlq > 0); return encoded; }; exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { var strLen = aStr.length; var result = 0; var shift = 0; var continuation, digit; do { if (aIndex >= strLen) throw new Error("Expected more digits in base 64 VLQ value."); digit = base64.decode(aStr.charCodeAt(aIndex++)); if (-1 === digit) throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1)); continuation = !!(digit & VLQ_CONTINUATION_BIT); digit &= VLQ_BASE_MASK; result += digit << shift; shift += VLQ_BASE_SHIFT; }while (continuation); aOutParam.value = fromVLQSigned(result); aOutParam.rest = aIndex; }; }, "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/base64.js": function(__unused_webpack_module, exports) { var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''); exports.encode = function(number) { if (0 <= number && number < intToCharMap.length) return intToCharMap[number]; throw new TypeError("Must be between 0 and 63: " + number); }; exports.decode = function(charCode) { var bigA = 65; var bigZ = 90; var littleA = 97; var littleZ = 122; var zero = 48; var nine = 57; var plus = 43; var slash = 47; var littleOffset = 26; var numberOffset = 52; if (bigA <= charCode && charCode <= bigZ) return charCode - bigA; if (littleA <= charCode && charCode <= littleZ) return charCode - littleA + littleOffset; if (zero <= charCode && charCode <= nine) return charCode - zero + numberOffset; if (charCode == plus) return 62; if (charCode == slash) return 63; return -1; }; }, "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/binary-search.js": function(__unused_webpack_module, exports) { exports.GREATEST_LOWER_BOUND = 1; exports.LEAST_UPPER_BOUND = 2; function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) { var mid = Math.floor((aHigh - aLow) / 2) + aLow; var cmp = aCompare(aNeedle, aHaystack[mid], true); if (0 === cmp) return mid; if (cmp > 0) { if (aHigh - mid > 1) return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias); if (aBias == exports.LEAST_UPPER_BOUND) return aHigh < aHaystack.length ? aHigh : -1; return mid; } if (mid - aLow > 1) return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias); if (aBias == exports.LEAST_UPPER_BOUND) return mid; return aLow < 0 ? -1 : aLow; } exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { if (0 === aHaystack.length) return -1; var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare, aBias || exports.GREATEST_LOWER_BOUND); if (index < 0) return -1; while(index - 1 >= 0){ if (0 !== aCompare(aHaystack[index], aHaystack[index - 1], true)) break; --index; } return index; }; }, "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/mapping-list.js": function(__unused_webpack_module, exports, __webpack_require__) { var util = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/util.js"); function generatedPositionAfter(mappingA, mappingB) { var lineA = mappingA.generatedLine; var lineB = mappingB.generatedLine; var columnA = mappingA.generatedColumn; var columnB = mappingB.generatedColumn; return lineB > lineA || lineB == lineA && columnB >= columnA || util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0; } function MappingList() { this._array = []; this._sorted = true; this._last = { generatedLine: -1, generatedColumn: 0 }; } MappingList.prototype.unsortedForEach = function MappingList_forEach(aCallback, aThisArg) { this._array.forEach(aCallback, aThisArg); }; MappingList.prototype.add = function MappingList_add(aMapping) { if (generatedPositionAfter(this._last, aMapping)) { this._last = aMapping; this._array.push(aMapping); } else { this._sorted = false; this._array.push(aMapping); } }; MappingList.prototype.toArray = function MappingList_toArray() { if (!this._sorted) { this._array.sort(util.compareByGeneratedPositionsInflated); this._sorted = true; } return this._array; }; exports.MappingList = MappingList; }, "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/quick-sort.js": function(__unused_webpack_module, exports) { function swap(ary, x, y) { var temp = ary[x]; ary[x] = ary[y]; ary[y] = temp; } function randomIntInRange(low, high) { return Math.round(low + Math.random() * (high - low)); } function doQuickSort(ary, comparator, p, r) { if (p < r) { var pivotIndex = randomIntInRange(p, r); var i = p - 1; swap(ary, pivotIndex, r); var pivot = ary[r]; for(var j = p; j < r; j++)if (comparator(ary[j], pivot) <= 0) { i += 1; swap(ary, i, j); } swap(ary, i + 1, j); var q = i + 1; doQuickSort(ary, comparator, p, q - 1); doQuickSort(ary, comparator, q + 1, r); } } exports.quickSort = function(ary, comparator) { doQuickSort(ary, comparator, 0, ary.length - 1); }; }, "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-consumer.js": function(__unused_webpack_module, exports, __webpack_require__) { var util = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/util.js"); var binarySearch = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/binary-search.js"); var ArraySet = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/array-set.js").ArraySet; var base64VLQ = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/base64-vlq.js"); var quickSort = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/quick-sort.js").quickSort; function SourceMapConsumer(aSourceMap, aSourceMapURL) { var sourceMap = aSourceMap; if ('string' == typeof aSourceMap) sourceMap = util.parseSourceMapInput(aSourceMap); return null != sourceMap.sections ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL) : new BasicSourceMapConsumer(sourceMap, aSourceMapURL); } SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) { return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL); }; SourceMapConsumer.prototype._version = 3; SourceMapConsumer.prototype.__generatedMappings = null; Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { configurable: true, enumerable: true, get: function() { if (!this.__generatedMappings) this._parseMappings(this._mappings, this.sourceRoot); return this.__generatedMappings; } }); SourceMapConsumer.prototype.__originalMappings = null; Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { configurable: true, enumerable: true, get: function() { if (!this.__originalMappings) this._parseMappings(this._mappings, this.sourceRoot); return this.__originalMappings; } }); SourceMapConsumer.prototype._charIsMappingSeparator = function SourceMapConsumer_charIsMappingSeparator(aStr, index) { var c = aStr.charAt(index); return ";" === c || "," === c; }; SourceMapConsumer.prototype._parseMappings = function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { throw new Error("Subclasses must implement _parseMappings"); }; SourceMapConsumer.GENERATED_ORDER = 1; SourceMapConsumer.ORIGINAL_ORDER = 2; SourceMapConsumer.GREATEST_LOWER_BOUND = 1; SourceMapConsumer.LEAST_UPPER_BOUND = 2; SourceMapConsumer.prototype.eachMapping = function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { var context = aContext || null; var order = aOrder || SourceMapConsumer.GENERATED_ORDER; var mappings; switch(order){ case SourceMapConsumer.GENERATED_ORDER: mappings = this._generatedMappings; break; case SourceMapConsumer.ORIGINAL_ORDER: mappings = this._originalMappings; break; default: throw new Error("Unknown order of iteration."); } var sourceRoot = this.sourceRoot; mappings.map(function(mapping) { var source = null === mapping.source ? null : this._sources.at(mapping.source); source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL); return { source: source, generatedLine: mapping.generatedLine, generatedColumn: mapping.generatedColumn, originalLine: mapping.originalLine, originalColumn: mapping.originalColumn, name: null === mapping.name ? null : this._names.at(mapping.name) }; }, this).forEach(aCallback, context); }; SourceMapConsumer.prototype.allGeneratedPositionsFor = function SourceMapConsumer_allGeneratedPositionsFor(aArgs) { var line = util.getArg(aArgs, 'line'); var needle = { source: util.getArg(aArgs, 'source'), originalLine: line, originalColumn: util.getArg(aArgs, 'column', 0) }; needle.source = this._findSourceIndex(needle.source); if (needle.source < 0) return []; var mappings = []; var index = this._findMapping(needle, this._originalMappings, "originalLine", "originalColumn", util.compareByOriginalPositions, binarySearch.LEAST_UPPER_BOUND); if (index >= 0) { var mapping = this._originalMappings[index]; if (void 0 === aArgs.column) { var originalLine = mapping.originalLine; while(mapping && mapping.originalLine === originalLine){ mappings.push({ line: util.getArg(mapping, 'generatedLine', null), column: util.getArg(mapping, 'generatedColumn', null), lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) }); mapping = this._originalMappings[++index]; } } else { var originalColumn = mapping.originalColumn; while(mapping && mapping.originalLine === line && mapping.originalColumn == originalColumn){ mappings.push({ line: util.getArg(mapping, 'generatedLine', null), column: util.getArg(mapping, 'generatedColumn', null), lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) }); mapping = this._originalMappings[++index]; } } } return mappings; }; exports.SourceMapConsumer = SourceMapConsumer; function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) { var sourceMap = aSourceMap; if ('string' == typeof aSourceMap) sourceMap = util.parseSourceMapInput(aSourceMap); var version = util.getArg(sourceMap, 'version'); var sources = util.getArg(sourceMap, 'sources'); var names = util.getArg(sourceMap, 'names', []); var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); var mappings = util.getArg(sourceMap, 'mappings'); var file = util.getArg(sourceMap, 'file', null); if (version != this._version) throw new Error('Unsupported version: ' + version); if (sourceRoot) sourceRoot = util.normalize(sourceRoot); sources = sources.map(String).map(util.normalize).map(function(source) { return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source) ? util.relative(sourceRoot, source) : source; }); this._names = ArraySet.fromArray(names.map(String), true); this._sources = ArraySet.fromArray(sources, true); this._absoluteSources = this._sources.toArray().map(function(s) { return util.computeSourceURL(sourceRoot, s, aSourceMapURL); }); this.sourceRoot = sourceRoot; this.sourcesContent = sourcesContent; this._mappings = mappings; this._sourceMapURL = aSourceMapURL; this.file = file; } BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) { var relativeSource = aSource; if (null != this.sourceRoot) relativeSource = util.relative(this.sourceRoot, relativeSource); if (this._sources.has(relativeSource)) return this._sources.indexOf(relativeSource); var i; for(i = 0; i < this._absoluteSources.length; ++i)if (this._absoluteSources[i] == aSource) return i; return -1; }; BasicSourceMapConsumer.fromSourceMap = function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) { var smc = Object.create(BasicSourceMapConsumer.prototype); var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); smc.sourceRoot = aSourceMap._sourceRoot; smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), smc.sourceRoot); smc.file = aSourceMap._file; smc._sourceMapURL = aSourceMapURL; smc._absoluteSources = smc._sources.toArray().map(function(s) { return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL); }); var generatedMappings = aSourceMap._mappings.toArray().slice(); var destGeneratedMappings = smc.__generatedMappings = []; var destOriginalMappings = smc.__originalMappings = []; for(var i = 0, length = generatedMappings.length; i < length; i++){ var srcMapping = generatedMappings[i]; var destMapping = new Mapping; destMapping.generatedLine = srcMapping.generatedLine; destMapping.generatedColumn = srcMapping.generatedColumn; if (srcMapping.source) { destMapping.source = sources.indexOf(srcMapping.source); destMapping.originalLine = srcMapping.originalLine; destMapping.originalColumn = srcMapping.originalColumn; if (srcMapping.name) destMapping.name = names.indexOf(srcMapping.name); destOriginalMappings.push(destMapping); } destGeneratedMappings.push(destMapping); } quickSort(smc.__originalMappings, util.compareByOriginalPositions); return smc; }; BasicSourceMapConsumer.prototype._version = 3; Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', { get: function() { return this._absoluteSources.slice(); } }); function Mapping() { this.generatedLine = 0; this.generatedColumn = 0; this.source = null; this.originalLine = null; this.originalColumn = null; this.name = null; } BasicSourceMapConsumer.prototype._parseMappings = function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { var generatedLine = 1; var previousGeneratedColumn = 0; var previousOriginalLine = 0; var previousOriginalColumn = 0; var previousSource = 0; var previousName = 0; var length = aStr.length; var index = 0; var cachedSegments = {}; var temp = {}; var originalMappings = []; var generatedMappings = []; var mapping, str, segment, end, value; while(index < length)if (';' === aStr.charAt(index)) { generatedLine++; index++; previousGeneratedColumn = 0; } else if (',' === aStr.charAt(index)) index++; else { mapping = new Mapping(); mapping.generatedLine = generatedLine; for(end = index; end < length && !this._charIsMappingSeparator(aStr, end); end++); str = aStr.slice(index, end); segment = cachedSegments[str]; if (segment) index += str.length; else { segment = []; while(index < end){ base64VLQ.decode(aStr, index, temp); value = temp.value; index = temp.rest; segment.push(value); } if (2 === segment.length) throw new Error('Found a source, but no line and column'); if (3 === segment.length) throw new Error('Found a source and line, but no column'); cachedSegments[str] = segment; } mapping.generatedColumn = previousGeneratedColumn + segment[0]; previousGeneratedColumn = mapping.generatedColumn; if (segment.length > 1) { mapping.source = previousSource + segment[1]; previousSource += segment[1]; mapping.originalLine = previousOriginalLine + segment[2]; previousOriginalLine = mapping.originalLine; mapping.originalLine += 1; mapping.originalColumn = previousOriginalColumn + segment[3]; previousOriginalColumn = mapping.originalColumn; if (segment.length > 4) { mapping.name = previousName + segment[4]; previousName += segment[4]; } } generatedMappings.push(mapping); if ('number' == typeof mapping.originalLine) originalMappings.push(mapping); } quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated); this.__generatedMappings = generatedMappings; quickSort(originalMappings, util.compareByOriginalPositions); this.__originalMappings = originalMappings; }; BasicSourceMapConsumer.prototype._findMapping = function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, aColumnName, aComparator, aBias) { if (aNeedle[aLineName] <= 0) throw new TypeError('Line must be greater than or equal to 1, got ' + aNeedle[aLineName]); if (aNeedle[aColumnName] < 0) throw new TypeError('Column must be greater than or equal to 0, got ' + aNeedle[aColumnName]); return binarySearch.search(aNeedle, aMappings, aComparator, aBias); }; BasicSourceMapConsumer.prototype.computeColumnSpans = function SourceMapConsumer_computeColumnSpans() { for(var index = 0; index < this._generatedMappings.length; ++index){ var mapping = this._generatedMappings[index]; if (index + 1 < this._generatedMappings.length) { var nextMapping = this._generatedMappings[index + 1]; if (mapping.generatedLine === nextMapping.generatedLine) { mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1; continue; } } mapping.lastGeneratedColumn = 1 / 0; } }; BasicSourceMapConsumer.prototype.originalPositionFor = function SourceMapConsumer_originalPositionFor(aArgs) { var needle = { generatedLine: util.getArg(aArgs, 'line'), generatedColumn: util.getArg(aArgs, 'column') }; var index = this._findMapping(needle, this._generatedMappings, "generatedLine", "generatedColumn", util.compareByGeneratedPositionsDeflated, util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)); if (index >= 0) { var mapping = this._generatedMappings[index]; if (mapping.generatedLine === needle.generatedLine) { var source = util.getArg(mapping, 'source', null); if (null !== source) { source = this._sources.at(source); source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL); } var name = util.getArg(mapping, 'name', null); if (null !== name) name = this._names.at(name); return { source: source, line: util.getArg(mapping, 'originalLine', null), column: util.getArg(mapping, 'originalColumn', null), name: name }; } } return { source: null, line: null, column: null, name: null }; }; BasicSourceMapConsumer.prototype.hasContentsOfAllSources = function BasicSourceMapConsumer_hasContentsOfAllSources() { if (!this.sourcesContent) return false; return this.sourcesContent.length >= this._sources.size() && !this.sourcesContent.some(function(sc) { return null == sc; }); }; BasicSourceMapConsumer.prototype.sourceContentFor = function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { if (!this.sourcesContent) return null; var index = this._findSourceIndex(aSource); if (index >= 0) return this.sourcesContent[index]; var relativeSource = aSource; if (null != this.sourceRoot) relativeSource = util.relative(this.sourceRoot, relativeSource); var url; if (null != this.sourceRoot && (url = util.urlParse(this.sourceRoot))) { var fileUriAbsPath = relativeSource.replace(/^file:\/\//, ""); if ("file" == url.scheme && this._sources.has(fileUriAbsPath)) return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]; if ((!url.path || "/" == url.path) && this._sources.has("/" + relativeSource)) return this.sourcesContent[this._sources.indexOf("/" + relativeSource)]; } if (nullOnMissing) return null; throw new Error('"' + relativeSource + '" is not in the SourceMap.'); }; BasicSourceMapConsumer.prototype.generatedPositionFor = function SourceMapConsumer_generatedPositionFor(aArgs) { var source = util.getArg(aArgs, 'source'); source = this._findSourceIndex(source); if (source < 0) return { line: null, column: null, lastColumn: null }; var needle = { source: source, originalLine: util.getArg(aArgs, 'line'), originalColumn: util.getArg(aArgs, 'column') }; var index = this._findMapping(needle, this._originalMappings, "originalLine", "originalColumn", util.compareByOriginalPositions, util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)); if (index >= 0) { var mapping = this._originalMappings[index]; if (mapping.source === needle.source) return { line: util.getArg(mapping, 'generatedLine', null), column: util.getArg(mapping, 'generatedColumn', null), lastColumn: util.getArg(mapping, 'lastGeneratedC