Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03k
1(function webpackUniversalModuleDefinition(root, factory) {2 if(typeof exports === 'object' && typeof module === 'object')3 module.exports = factory();4 else if(typeof define === 'function' && define.amd)5 define([], factory);6 else if(typeof exports === 'object')7 exports["sourceMap"] = factory();8 else9 root["sourceMap"] = factory();10})(this, function() {11return /******/ (function(modules) { // webpackBootstrap12/******/ // The module cache13/******/ var installedModules = {};14/******/15/******/ // The require function16/******/ function __webpack_require__(moduleId) {17/******/18/******/ // Check if module is in cache19/******/ if(installedModules[moduleId])20/******/ return installedModules[moduleId].exports;21/******/22/******/ // Create a new module (and put it into the cache)23/******/ var module = installedModules[moduleId] = {24/******/ exports: {},25/******/ id: moduleId,26/******/ loaded: false27/******/ };28/******/29/******/ // Execute the module function30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);31/******/32/******/ // Flag the module as loaded33/******/ module.loaded = true;34/******/35/******/ // Return the exports of the module36/******/ return module.exports;37/******/ }38/******/39/******/40/******/ // expose the modules object (__webpack_modules__)41/******/ __webpack_require__.m = modules;42/******/43/******/ // expose the module cache44/******/ __webpack_require__.c = installedModules;45/******/46/******/ // __webpack_public_path__47/******/ __webpack_require__.p = "";48/******/49/******/ // Load entry module and return exports50/******/ return __webpack_require__(0);51/******/ })52/************************************************************************/53/******/ ([54/* 0 */55/***/ (function(module, exports, __webpack_require__) {56 57 /*58 * Copyright 2009-2011 Mozilla Foundation and contributors59 * Licensed under the New BSD license. See LICENSE.txt or:60 * http://opensource.org/licenses/BSD-3-Clause61 */62 exports.SourceMapGenerator = __webpack_require__(1).SourceMapGenerator;63 exports.SourceMapConsumer = __webpack_require__(7).SourceMapConsumer;64 exports.SourceNode = __webpack_require__(10).SourceNode;65 66 67/***/ }),68/* 1 */69/***/ (function(module, exports, __webpack_require__) {70 71 /* -*- Mode: js; js-indent-level: 2; -*- */72 /*73 * Copyright 2011 Mozilla Foundation and contributors74 * Licensed under the New BSD license. See LICENSE or:75 * http://opensource.org/licenses/BSD-3-Clause76 */77 78 var base64VLQ = __webpack_require__(2);79 var util = __webpack_require__(4);80 var ArraySet = __webpack_require__(5).ArraySet;81 var MappingList = __webpack_require__(6).MappingList;82 83 /**84 * An instance of the SourceMapGenerator represents a source map which is85 * being built incrementally. You may pass an object with the following86 * properties:87 *88 * - file: The filename of the generated source.89 * - sourceRoot: A root for all relative URLs in this source map.90 */91 function SourceMapGenerator(aArgs) {92 if (!aArgs) {93 aArgs = {};94 }95 this._file = util.getArg(aArgs, 'file', null);96 this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);97 this._skipValidation = util.getArg(aArgs, 'skipValidation', false);98 this._sources = new ArraySet();99 this._names = new ArraySet();100 this._mappings = new MappingList();101 this._sourcesContents = null;102 }103 104 SourceMapGenerator.prototype._version = 3;105 106 /**107 * Creates a new SourceMapGenerator based on a SourceMapConsumer108 *109 * @param aSourceMapConsumer The SourceMap.110 */111 SourceMapGenerator.fromSourceMap =112 function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {113 var sourceRoot = aSourceMapConsumer.sourceRoot;114 var generator = new SourceMapGenerator({115 file: aSourceMapConsumer.file,116 sourceRoot: sourceRoot117 });118 aSourceMapConsumer.eachMapping(function (mapping) {119 var newMapping = {120 generated: {121 line: mapping.generatedLine,122 column: mapping.generatedColumn123 }124 };125 126 if (mapping.source != null) {127 newMapping.source = mapping.source;128 if (sourceRoot != null) {129 newMapping.source = util.relative(sourceRoot, newMapping.source);130 }131 132 newMapping.original = {133 line: mapping.originalLine,134 column: mapping.originalColumn135 };136 137 if (mapping.name != null) {138 newMapping.name = mapping.name;139 }140 }141 142 generator.addMapping(newMapping);143 });144 aSourceMapConsumer.sources.forEach(function (sourceFile) {145 var sourceRelative = sourceFile;146 if (sourceRoot !== null) {147 sourceRelative = util.relative(sourceRoot, sourceFile);148 }149 150 if (!generator._sources.has(sourceRelative)) {151 generator._sources.add(sourceRelative);152 }153 154 var content = aSourceMapConsumer.sourceContentFor(sourceFile);155 if (content != null) {156 generator.setSourceContent(sourceFile, content);157 }158 });159 return generator;160 };161 162 /**163 * Add a single mapping from original source line and column to the generated164 * source's line and column for this source map being created. The mapping165 * object should have the following properties:166 *167 * - generated: An object with the generated line and column positions.168 * - original: An object with the original line and column positions.169 * - source: The original source file (relative to the sourceRoot).170 * - name: An optional original token name for this mapping.171 */172 SourceMapGenerator.prototype.addMapping =173 function SourceMapGenerator_addMapping(aArgs) {174 var generated = util.getArg(aArgs, 'generated');175 var original = util.getArg(aArgs, 'original', null);176 var source = util.getArg(aArgs, 'source', null);177 var name = util.getArg(aArgs, 'name', null);178 179 if (!this._skipValidation) {180 this._validateMapping(generated, original, source, name);181 }182 183 if (source != null) {184 source = String(source);185 if (!this._sources.has(source)) {186 this._sources.add(source);187 }188 }189 190 if (name != null) {191 name = String(name);192 if (!this._names.has(name)) {193 this._names.add(name);194 }195 }196 197 this._mappings.add({198 generatedLine: generated.line,199 generatedColumn: generated.column,200 originalLine: original != null && original.line,201 originalColumn: original != null && original.column,202 source: source,203 name: name204 });205 };206 207 /**208 * Set the source content for a source file.209 */210 SourceMapGenerator.prototype.setSourceContent =211 function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {212 var source = aSourceFile;213 if (this._sourceRoot != null) {214 source = util.relative(this._sourceRoot, source);215 }216 217 if (aSourceContent != null) {218 // Add the source content to the _sourcesContents map.219 // Create a new _sourcesContents map if the property is null.220 if (!this._sourcesContents) {221 this._sourcesContents = Object.create(null);222 }223 this._sourcesContents[util.toSetString(source)] = aSourceContent;224 } else if (this._sourcesContents) {225 // Remove the source file from the _sourcesContents map.226 // If the _sourcesContents map is empty, set the property to null.227 delete this._sourcesContents[util.toSetString(source)];228 if (Object.keys(this._sourcesContents).length === 0) {229 this._sourcesContents = null;230 }231 }232 };233 234 /**235 * Applies the mappings of a sub-source-map for a specific source file to the236 * source map being generated. Each mapping to the supplied source file is237 * rewritten using the supplied source map. Note: The resolution for the238 * resulting mappings is the minimium of this map and the supplied map.239 *240 * @param aSourceMapConsumer The source map to be applied.241 * @param aSourceFile Optional. The filename of the source file.242 * If omitted, SourceMapConsumer's file property will be used.243 * @param aSourceMapPath Optional. The dirname of the path to the source map244 * to be applied. If relative, it is relative to the SourceMapConsumer.245 * This parameter is needed when the two source maps aren't in the same246 * directory, and the source map to be applied contains relative source247 * paths. If so, those relative source paths need to be rewritten248 * relative to the SourceMapGenerator.249 */250 SourceMapGenerator.prototype.applySourceMap =251 function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {252 var sourceFile = aSourceFile;253 // If aSourceFile is omitted, we will use the file property of the SourceMap254 if (aSourceFile == null) {255 if (aSourceMapConsumer.file == null) {256 throw new Error(257 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +258 'or the source map\'s "file" property. Both were omitted.'259 );260 }261 sourceFile = aSourceMapConsumer.file;262 }263 var sourceRoot = this._sourceRoot;264 // Make "sourceFile" relative if an absolute Url is passed.265 if (sourceRoot != null) {266 sourceFile = util.relative(sourceRoot, sourceFile);267 }268 // Applying the SourceMap can add and remove items from the sources and269 // the names array.270 var newSources = new ArraySet();271 var newNames = new ArraySet();272 273 // Find mappings for the "sourceFile"274 this._mappings.unsortedForEach(function (mapping) {275 if (mapping.source === sourceFile && mapping.originalLine != null) {276 // Check if it can be mapped by the source map, then update the mapping.277 var original = aSourceMapConsumer.originalPositionFor({278 line: mapping.originalLine,279 column: mapping.originalColumn280 });281 if (original.source != null) {282 // Copy mapping283 mapping.source = original.source;284 if (aSourceMapPath != null) {285 mapping.source = util.join(aSourceMapPath, mapping.source)286 }287 if (sourceRoot != null) {288 mapping.source = util.relative(sourceRoot, mapping.source);289 }290 mapping.originalLine = original.line;291 mapping.originalColumn = original.column;292 if (original.name != null) {293 mapping.name = original.name;294 }295 }296 }297 298 var source = mapping.source;299 if (source != null && !newSources.has(source)) {300 newSources.add(source);301 }302 303 var name = mapping.name;304 if (name != null && !newNames.has(name)) {305 newNames.add(name);306 }307 308 }, this);309 this._sources = newSources;310 this._names = newNames;311 312 // Copy sourcesContents of applied map.313 aSourceMapConsumer.sources.forEach(function (sourceFile) {314 var content = aSourceMapConsumer.sourceContentFor(sourceFile);315 if (content != null) {316 if (aSourceMapPath != null) {317 sourceFile = util.join(aSourceMapPath, sourceFile);318 }319 if (sourceRoot != null) {320 sourceFile = util.relative(sourceRoot, sourceFile);321 }322 this.setSourceContent(sourceFile, content);323 }324 }, this);325 };326 327 /**328 * A mapping can have one of the three levels of data:329 *330 * 1. Just the generated position.331 * 2. The Generated position, original position, and original source.332 * 3. Generated and original position, original source, as well as a name333 * token.334 *335 * To maintain consistency, we validate that any new mapping being added falls336 * in to one of these categories.337 */338 SourceMapGenerator.prototype._validateMapping =339 function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,340 aName) {341 // When aOriginal is truthy but has empty values for .line and .column,342 // it is most likely a programmer error. In this case we throw a very343 // specific error message to try to guide them the right way.344 // For example: https://github.com/Polymer/polymer-bundler/pull/519345 if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {346 throw new Error(347 'original.line and original.column are not numbers -- you probably meant to omit ' +348 'the original mapping entirely and only map the generated position. If so, pass ' +349 'null for the original mapping instead of an object with empty or null values.'350 );351 }352 353 if (aGenerated && 'line' in aGenerated && 'column' in aGenerated354 && aGenerated.line > 0 && aGenerated.column >= 0355 && !aOriginal && !aSource && !aName) {356 // Case 1.357 return;358 }359 else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated360 && aOriginal && 'line' in aOriginal && 'column' in aOriginal361 && aGenerated.line > 0 && aGenerated.column >= 0362 && aOriginal.line > 0 && aOriginal.column >= 0363 && aSource) {364 // Cases 2 and 3.365 return;366 }367 else {368 throw new Error('Invalid mapping: ' + JSON.stringify({369 generated: aGenerated,370 source: aSource,371 original: aOriginal,372 name: aName373 }));374 }375 };376 377 /**378 * Serialize the accumulated mappings in to the stream of base 64 VLQs379 * specified by the source map format.380 */381 SourceMapGenerator.prototype._serializeMappings =382 function SourceMapGenerator_serializeMappings() {383 var previousGeneratedColumn = 0;384 var previousGeneratedLine = 1;385 var previousOriginalColumn = 0;386 var previousOriginalLine = 0;387 var previousName = 0;388 var previousSource = 0;389 var result = '';390 var next;391 var mapping;392 var nameIdx;393 var sourceIdx;394 395 var mappings = this._mappings.toArray();396 for (var i = 0, len = mappings.length; i < len; i++) {397 mapping = mappings[i];398 next = ''399 400 if (mapping.generatedLine !== previousGeneratedLine) {401 previousGeneratedColumn = 0;402 while (mapping.generatedLine !== previousGeneratedLine) {403 next += ';';404 previousGeneratedLine++;405 }406 }407 else {408 if (i > 0) {409 if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {410 continue;411 }412 next += ',';413 }414 }415 416 next += base64VLQ.encode(mapping.generatedColumn417 - previousGeneratedColumn);418 previousGeneratedColumn = mapping.generatedColumn;419 420 if (mapping.source != null) {421 sourceIdx = this._sources.indexOf(mapping.source);422 next += base64VLQ.encode(sourceIdx - previousSource);423 previousSource = sourceIdx;424 425 // lines are stored 0-based in SourceMap spec version 3426 next += base64VLQ.encode(mapping.originalLine - 1427 - previousOriginalLine);428 previousOriginalLine = mapping.originalLine - 1;429 430 next += base64VLQ.encode(mapping.originalColumn431 - previousOriginalColumn);432 previousOriginalColumn = mapping.originalColumn;433 434 if (mapping.name != null) {435 nameIdx = this._names.indexOf(mapping.name);436 next += base64VLQ.encode(nameIdx - previousName);437 previousName = nameIdx;438 }439 }440 441 result += next;442 }443 444 return result;445 };446 447 SourceMapGenerator.prototype._generateSourcesContent =448 function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {449 return aSources.map(function (source) {450 if (!this._sourcesContents) {451 return null;452 }453 if (aSourceRoot != null) {454 source = util.relative(aSourceRoot, source);455 }456 var key = util.toSetString(source);457 return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)458 ? this._sourcesContents[key]459 : null;460 }, this);461 };462 463 /**464 * Externalize the source map.465 */466 SourceMapGenerator.prototype.toJSON =467 function SourceMapGenerator_toJSON() {468 var map = {469 version: this._version,470 sources: this._sources.toArray(),471 names: this._names.toArray(),472 mappings: this._serializeMappings()473 };474 if (this._file != null) {475 map.file = this._file;476 }477 if (this._sourceRoot != null) {478 map.sourceRoot = this._sourceRoot;479 }480 if (this._sourcesContents) {481 map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);482 }483 484 return map;485 };486 487 /**488 * Render the source map being generated to a string.489 */490 SourceMapGenerator.prototype.toString =491 function SourceMapGenerator_toString() {492 return JSON.stringify(this.toJSON());493 };494 495 exports.SourceMapGenerator = SourceMapGenerator;496 497 498/***/ }),499/* 2 */500/***/ (function(module, exports, __webpack_require__) {501 502 /* -*- Mode: js; js-indent-level: 2; -*- */503 /*504 * Copyright 2011 Mozilla Foundation and contributors505 * Licensed under the New BSD license. See LICENSE or:506 * http://opensource.org/licenses/BSD-3-Clause507 *508 * Based on the Base 64 VLQ implementation in Closure Compiler:509 * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java510 *511 * Copyright 2011 The Closure Compiler Authors. All rights reserved.512 * Redistribution and use in source and binary forms, with or without513 * modification, are permitted provided that the following conditions are514 * met:515 *516 * * Redistributions of source code must retain the above copyright517 * notice, this list of conditions and the following disclaimer.518 * * Redistributions in binary form must reproduce the above519 * copyright notice, this list of conditions and the following520 * disclaimer in the documentation and/or other materials provided521 * with the distribution.522 * * Neither the name of Google Inc. nor the names of its523 * contributors may be used to endorse or promote products derived524 * from this software without specific prior written permission.525 *526 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS527 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT528 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR529 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT530 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,531 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT532 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,533 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY534 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT535 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE536 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.537 */538 539 var base64 = __webpack_require__(3);540 541 // A single base 64 digit can contain 6 bits of data. For the base 64 variable542 // length quantities we use in the source map spec, the first bit is the sign,543 // the next four bits are the actual value, and the 6th bit is the544 // continuation bit. The continuation bit tells us whether there are more545 // digits in this value following this digit.546 //547 // Continuation548 // | Sign549 // | |550 // V V551 // 101011552 553 var VLQ_BASE_SHIFT = 5;554 555 // binary: 100000556 var VLQ_BASE = 1 << VLQ_BASE_SHIFT;557 558 // binary: 011111559 var VLQ_BASE_MASK = VLQ_BASE - 1;560 561 // binary: 100000562 var VLQ_CONTINUATION_BIT = VLQ_BASE;563 564 /**565 * Converts from a two-complement value to a value where the sign bit is566 * placed in the least significant bit. For example, as decimals:567 * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)568 * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)569 */570 function toVLQSigned(aValue) {571 return aValue < 0572 ? ((-aValue) << 1) + 1573 : (aValue << 1) + 0;574 }575 576 /**577 * Converts to a two-complement value from a value where the sign bit is578 * placed in the least significant bit. For example, as decimals:579 * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1580 * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2581 */582 function fromVLQSigned(aValue) {583 var isNegative = (aValue & 1) === 1;584 var shifted = aValue >> 1;585 return isNegative586 ? -shifted587 : shifted;588 }589 590 /**591 * Returns the base 64 VLQ encoded value.592 */593 exports.encode = function base64VLQ_encode(aValue) {594 var encoded = "";595 var digit;596 597 var vlq = toVLQSigned(aValue);598 599 do {600 digit = vlq & VLQ_BASE_MASK;601 vlq >>>= VLQ_BASE_SHIFT;602 if (vlq > 0) {603 // There are still more digits in this value, so we must make sure the604 // continuation bit is marked.605 digit |= VLQ_CONTINUATION_BIT;606 }607 encoded += base64.encode(digit);608 } while (vlq > 0);609 610 return encoded;611 };612 613 /**614 * Decodes the next base 64 VLQ value from the given string and returns the615 * value and the rest of the string via the out parameter.616 */617 exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {618 var strLen = aStr.length;619 var result = 0;620 var shift = 0;621 var continuation, digit;622 623 do {624 if (aIndex >= strLen) {625 throw new Error("Expected more digits in base 64 VLQ value.");626 }627 628 digit = base64.decode(aStr.charCodeAt(aIndex++));629 if (digit === -1) {630 throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));631 }632 633 continuation = !!(digit & VLQ_CONTINUATION_BIT);634 digit &= VLQ_BASE_MASK;635 result = result + (digit << shift);636 shift += VLQ_BASE_SHIFT;637 } while (continuation);638 639 aOutParam.value = fromVLQSigned(result);640 aOutParam.rest = aIndex;641 };642 643 644/***/ }),645/* 3 */646/***/ (function(module, exports) {647 648 /* -*- Mode: js; js-indent-level: 2; -*- */649 /*650 * Copyright 2011 Mozilla Foundation and contributors651 * Licensed under the New BSD license. See LICENSE or:652 * http://opensource.org/licenses/BSD-3-Clause653 */654 655 var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');656 657 /**658 * Encode an integer in the range of 0 to 63 to a single base 64 digit.659 */660 exports.encode = function (number) {661 if (0 <= number && number < intToCharMap.length) {662 return intToCharMap[number];663 }664 throw new TypeError("Must be between 0 and 63: " + number);665 };666 667 /**668 * Decode a single base 64 character code digit to an integer. Returns -1 on669 * failure.670 */671 exports.decode = function (charCode) {672 var bigA = 65; // 'A'673 var bigZ = 90; // 'Z'674 675 var littleA = 97; // 'a'676 var littleZ = 122; // 'z'677 678 var zero = 48; // '0'679 var nine = 57; // '9'680 681 var plus = 43; // '+'682 var slash = 47; // '/'683 684 var littleOffset = 26;685 var numberOffset = 52;686 687 // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ688 if (bigA <= charCode && charCode <= bigZ) {689 return (charCode - bigA);690 }691 692 // 26 - 51: abcdefghijklmnopqrstuvwxyz693 if (littleA <= charCode && charCode <= littleZ) {694 return (charCode - littleA + littleOffset);695 }696 697 // 52 - 61: 0123456789698 if (zero <= charCode && charCode <= nine) {699 return (charCode - zero + numberOffset);700 }701 702 // 62: +703 if (charCode == plus) {704 return 62;705 }706 707 // 63: /708 if (charCode == slash) {709 return 63;710 }711 712 // Invalid base64 digit.713 return -1;714 };715 716 717/***/ }),718/* 4 */719/***/ (function(module, exports) {720 721 /* -*- Mode: js; js-indent-level: 2; -*- */722 /*723 * Copyright 2011 Mozilla Foundation and contributors724 * Licensed under the New BSD license. See LICENSE or:725 * http://opensource.org/licenses/BSD-3-Clause726 */727 728 /**729 * This is a helper function for getting values from parameter/options730 * objects.731 *732 * @param args The object we are extracting values from733 * @param name The name of the property we are getting.734 * @param defaultValue An optional value to return if the property is missing735 * from the object. If this is not specified and the property is missing, an736 * error will be thrown.737 */738 function getArg(aArgs, aName, aDefaultValue) {739 if (aName in aArgs) {740 return aArgs[aName];741 } else if (arguments.length === 3) {742 return aDefaultValue;743 } else {744 throw new Error('"' + aName + '" is a required argument.');745 }746 }747 exports.getArg = getArg;748 749 var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;750 var dataUrlRegexp = /^data:.+\,.+$/;751 752 function urlParse(aUrl) {753 var match = aUrl.match(urlRegexp);754 if (!match) {755 return null;756 }757 return {758 scheme: match[1],759 auth: match[2],760 host: match[3],761 port: match[4],762 path: match[5]763 };764 }765 exports.urlParse = urlParse;766 767 function urlGenerate(aParsedUrl) {768 var url = '';769 if (aParsedUrl.scheme) {770 url += aParsedUrl.scheme + ':';771 }772 url += '//';773 if (aParsedUrl.auth) {774 url += aParsedUrl.auth + '@';775 }776 if (aParsedUrl.host) {777 url += aParsedUrl.host;778 }779 if (aParsedUrl.port) {780 url += ":" + aParsedUrl.port781 }782 if (aParsedUrl.path) {783 url += aParsedUrl.path;784 }785 return url;786 }787 exports.urlGenerate = urlGenerate;788 789 /**790 * Normalizes a path, or the path portion of a URL:791 *792 * - Replaces consecutive slashes with one slash.793 * - Removes unnecessary '.' parts.794 * - Removes unnecessary '<dir>/..' parts.795 *796 * Based on code in the Node.js 'path' core module.797 *798 * @param aPath The path or url to normalize.799 */800 function normalize(aPath) {801 var path = aPath;802 var url = urlParse(aPath);803 if (url) {804 if (!url.path) {805 return aPath;806 }807 path = url.path;808 }809 var isAbsolute = exports.isAbsolute(path);810 811 var parts = path.split(/\/+/);812 for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {813 part = parts[i];814 if (part === '.') {815 parts.splice(i, 1);816 } else if (part === '..') {817 up++;818 } else if (up > 0) {819 if (part === '') {820 // The first part is blank if the path is absolute. Trying to go821 // above the root is a no-op. Therefore we can remove all '..' parts822 // directly after the root.823 parts.splice(i + 1, up);824 up = 0;825 } else {826 parts.splice(i, 2);827 up--;828 }829 }830 }831 path = parts.join('/');832 833 if (path === '') {834 path = isAbsolute ? '/' : '.';835 }836 837 if (url) {838 url.path = path;839 return urlGenerate(url);840 }841 return path;842 }843 exports.normalize = normalize;844 845 /**846 * Joins two paths/URLs.847 *848 * @param aRoot The root path or URL.849 * @param aPath The path or URL to be joined with the root.850 *851 * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a852 * scheme-relative URL: Then the scheme of aRoot, if any, is prepended853 * first.854 * - Otherwise aPath is a path. If aRoot is a URL, then its path portion855 * is updated with the result and aRoot is returned. Otherwise the result856 * is returned.857 * - If aPath is absolute, the result is aPath.858 * - Otherwise the two paths are joined with a slash.859 * - Joining for example 'http://' and 'www.example.com' is also supported.860 */861 function join(aRoot, aPath) {862 if (aRoot === "") {863 aRoot = ".";864 }865 if (aPath === "") {866 aPath = ".";867 }868 var aPathUrl = urlParse(aPath);869 var aRootUrl = urlParse(aRoot);870 if (aRootUrl) {871 aRoot = aRootUrl.path || '/';872 }873 874 // `join(foo, '//www.example.org')`875 if (aPathUrl && !aPathUrl.scheme) {876 if (aRootUrl) {877 aPathUrl.scheme = aRootUrl.scheme;878 }879 return urlGenerate(aPathUrl);880 }881 882 if (aPathUrl || aPath.match(dataUrlRegexp)) {883 return aPath;884 }885 886 // `join('http://', 'www.example.com')`887 if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {888 aRootUrl.host = aPath;889 return urlGenerate(aRootUrl);890 }891 892 var joined = aPath.charAt(0) === '/'893 ? aPath894 : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);895 896 if (aRootUrl) {897 aRootUrl.path = joined;898 return urlGenerate(aRootUrl);899 }900 return joined;901 }902 exports.join = join;903 904 exports.isAbsolute = function (aPath) {905 return aPath.charAt(0) === '/' || urlRegexp.test(aPath);906 };907 908 /**909 * Make a path relative to a URL or another path.910 *911 * @param aRoot The root path or URL.912 * @param aPath The path or URL to be made relative to aRoot.913 */914 function relative(aRoot, aPath) {915 if (aRoot === "") {916 aRoot = ".";917 }918 919 aRoot = aRoot.replace(/\/$/, '');920 921 // It is possible for the path to be above the root. In this case, simply922 // checking whether the root is a prefix of the path won't work. Instead, we923 // need to remove components from the root one by one, until either we find924 // a prefix that fits, or we run out of components to remove.925 var level = 0;926 while (aPath.indexOf(aRoot + '/') !== 0) {927 var index = aRoot.lastIndexOf("/");928 if (index < 0) {929 return aPath;930 }931 932 // If the only part of the root that is left is the scheme (i.e. http://,933 // file:///, etc.), one or more slashes (/), or simply nothing at all, we934 // have exhausted all components, so the path is not relative to the root.935 aRoot = aRoot.slice(0, index);936 if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {937 return aPath;938 }939 940 ++level;941 }942 943 // Make sure we add a "../" for each component we removed from the root.944 return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);945 }946 exports.relative = relative;947 948 var supportsNullProto = (function () {949 var obj = Object.create(null);950 return !('__proto__' in obj);951 }());952 953 function identity (s) {954 return s;955 }956 957 /**958 * Because behavior goes wacky when you set `__proto__` on objects, we959 * have to prefix all the strings in our set with an arbitrary character.960 *961 * See https://github.com/mozilla/source-map/pull/31 and962 * https://github.com/mozilla/source-map/issues/30963 *964 * @param String aStr965 */966 function toSetString(aStr) {967 if (isProtoString(aStr)) {968 return '$' + aStr;969 }970 971 return aStr;972 }973 exports.toSetString = supportsNullProto ? identity : toSetString;974 975 function fromSetString(aStr) {976 if (isProtoString(aStr)) {977 return aStr.slice(1);978 }979 980 return aStr;981 }982 exports.fromSetString = supportsNullProto ? identity : fromSetString;983 984 function isProtoString(s) {985 if (!s) {986 return false;987 }988 989 var length = s.length;990 991 if (length < 9 /* "__proto__".length */) {992 return false;993 }994 995 if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||996 s.charCodeAt(length - 2) !== 95 /* '_' */ ||997 s.charCodeAt(length - 3) !== 111 /* 'o' */ ||998 s.charCodeAt(length - 4) !== 116 /* 't' */ ||999 s.charCodeAt(length - 5) !== 111 /* 'o' */ ||1000 s.charCodeAt(length - 6) !== 114 /* 'r' */ ||1001 s.charCodeAt(length - 7) !== 112 /* 'p' */ ||1002 s.charCodeAt(length - 8) !== 95 /* '_' */ ||1003 s.charCodeAt(length - 9) !== 95 /* '_' */) {1004 return false;1005 }1006 1007 for (var i = length - 10; i >= 0; i--) {1008 if (s.charCodeAt(i) !== 36 /* '$' */) {1009 return false;1010 }1011 }1012 1013 return true;1014 }1015 1016 /**1017 * Comparator between two mappings where the original positions are compared.1018 *1019 * Optionally pass in `true` as `onlyCompareGenerated` to consider two1020 * mappings with the same original source/line/column, but different generated1021 * line and column the same. Useful when searching for a mapping with a1022 * stubbed out mapping.1023 */1024 function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {1025 var cmp = strcmp(mappingA.source, mappingB.source);1026 if (cmp !== 0) {1027 return cmp;1028 }1029 1030 cmp = mappingA.originalLine - mappingB.originalLine;1031 if (cmp !== 0) {1032 return cmp;1033 }1034 1035 cmp = mappingA.originalColumn - mappingB.originalColumn;1036 if (cmp !== 0 || onlyCompareOriginal) {1037 return cmp;1038 }1039 1040 cmp = mappingA.generatedColumn - mappingB.generatedColumn;1041 if (cmp !== 0) {1042 return cmp;1043 }1044 1045 cmp = mappingA.generatedLine - mappingB.generatedLine;1046 if (cmp !== 0) {1047 return cmp;1048 }1049 1050 return strcmp(mappingA.name, mappingB.name);1051 }1052 exports.compareByOriginalPositions = compareByOriginalPositions;1053 1054 /**1055 * Comparator between two mappings with deflated source and name indices where1056 * the generated positions are compared.1057 *1058 * Optionally pass in `true` as `onlyCompareGenerated` to consider two1059 * mappings with the same generated line and column, but different1060 * source/name/original line and column the same. Useful when searching for a1061 * mapping with a stubbed out mapping.1062 */1063 function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {1064 var cmp = mappingA.generatedLine - mappingB.generatedLine;1065 if (cmp !== 0) {1066 return cmp;1067 }1068 1069 cmp = mappingA.generatedColumn - mappingB.generatedColumn;1070 if (cmp !== 0 || onlyCompareGenerated) {1071 return cmp;1072 }1073 1074 cmp = strcmp(mappingA.source, mappingB.source);1075 if (cmp !== 0) {1076 return cmp;1077 }1078 1079 cmp = mappingA.originalLine - mappingB.originalLine;1080 if (cmp !== 0) {1081 return cmp;1082 }1083 1084 cmp = mappingA.originalColumn - mappingB.originalColumn;1085 if (cmp !== 0) {1086 return cmp;1087 }1088 1089 return strcmp(mappingA.name, mappingB.name);1090 }1091 exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;1092 1093 function strcmp(aStr1, aStr2) {1094 if (aStr1 === aStr2) {1095 return 0;1096 }1097 1098 if (aStr1 === null) {1099 return 1; // aStr2 !== null1100 }1101 1102 if (aStr2 === null) {1103 return -1; // aStr1 !== null1104 }1105 1106 if (aStr1 > aStr2) {1107 return 1;1108 }1109 1110 return -1;1111 }1112 1113 /**1114 * Comparator between two mappings with inflated source and name strings where1115 * the generated positions are compared.1116 */1117 function compareByGeneratedPositionsInflated(mappingA, mappingB) {1118 var cmp = mappingA.generatedLine - mappingB.generatedLine;1119 if (cmp !== 0) {1120 return cmp;1121 }1122 1123 cmp = mappingA.generatedColumn - mappingB.generatedColumn;1124 if (cmp !== 0) {1125 return cmp;1126 }1127 1128 cmp = strcmp(mappingA.source, mappingB.source);1129 if (cmp !== 0) {1130 return cmp;1131 }1132 1133 cmp = mappingA.originalLine - mappingB.originalLine;1134 if (cmp !== 0) {1135 return cmp;1136 }1137 1138 cmp = mappingA.originalColumn - mappingB.originalColumn;1139 if (cmp !== 0) {1140 return cmp;1141 }1142 1143 return strcmp(mappingA.name, mappingB.name);1144 }1145 exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;1146 1147 /**1148 * Strip any JSON XSSI avoidance prefix from the string (as documented1149 * in the source maps specification), and then parse the string as1150 * JSON.1151 */1152 function parseSourceMapInput(str) {1153 return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));1154 }1155 exports.parseSourceMapInput = parseSourceMapInput;1156 1157 /**1158 * Compute the URL of a source given the the source root, the source's1159 * URL, and the source map's URL.1160 */1161 function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {1162 sourceURL = sourceURL || '';1163 1164 if (sourceRoot) {1165 // This follows what Chrome does.1166 if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {1167 sourceRoot += '/';1168 }1169 // The spec says:1170 // Line 4: An optional source root, useful for relocating source1171 // files on a server or removing repeated values in the1172 // “sources” entry. This value is prepended to the individual1173 // entries in the “source” field.1174 sourceURL = sourceRoot + sourceURL;1175 }1176 1177 // Historically, SourceMapConsumer did not take the sourceMapURL as1178 // a parameter. This mode is still somewhat supported, which is why1179 // this code block is conditional. However, it's preferable to pass1180 // the source map URL to SourceMapConsumer, so that this function1181 // can implement the source URL resolution algorithm as outlined in1182 // the spec. This block is basically the equivalent of:1183 // new URL(sourceURL, sourceMapURL).toString()1184 // ... except it avoids using URL, which wasn't available in the1185 // older releases of node still supported by this library.1186 //1187 // The spec says:1188 // If the sources are not absolute URLs after prepending of the1189 // “sourceRoot”, the sources are resolved relative to the1190 // SourceMap (like resolving script src in a html document).1191 if (sourceMapURL) {1192 var parsed = urlParse(sourceMapURL);1193 if (!parsed) {1194 throw new Error("sourceMapURL could not be parsed");1195 }1196 if (parsed.path) {1197 // Strip the last path component, but keep the "/".1198 var index = parsed.path.lastIndexOf('/');1199 if (index >= 0) {1200 parsed.path = parsed.path.substring(0, index + 1);