react / wstein / node_modules / browserify / node_modules / browser-pack / node_modules / combine-source-map / node_modules / source-map / dist / source-map.js
80556 views/* -*- Mode: js; js-indent-level: 2; -*- */1/*2* Copyright 2011 Mozilla Foundation and contributors3* Licensed under the New BSD license. See LICENSE or:4* http://opensource.org/licenses/BSD-3-Clause5*/67/**8* Define a module along with a payload.9* @param {string} moduleName Name for the payload10* @param {ignored} deps Ignored. For compatibility with CommonJS AMD Spec11* @param {function} payload Function with (require, exports, module) params12*/13function define(moduleName, deps, payload) {14if (typeof moduleName != "string") {15throw new TypeError('Expected string, got: ' + moduleName);16}1718if (arguments.length == 2) {19payload = deps;20}2122if (moduleName in define.modules) {23throw new Error("Module already defined: " + moduleName);24}25define.modules[moduleName] = payload;26};2728/**29* The global store of un-instantiated modules30*/31define.modules = {};323334/**35* We invoke require() in the context of a Domain so we can have multiple36* sets of modules running separate from each other.37* This contrasts with JSMs which are singletons, Domains allows us to38* optionally load a CommonJS module twice with separate data each time.39* Perhaps you want 2 command lines with a different set of commands in each,40* for example.41*/42function Domain() {43this.modules = {};44this._currentModule = null;45}4647(function () {4849/**50* Lookup module names and resolve them by calling the definition function if51* needed.52* There are 2 ways to call this, either with an array of dependencies and a53* callback to call when the dependencies are found (which can happen54* asynchronously in an in-page context) or with a single string an no callback55* where the dependency is resolved synchronously and returned.56* The API is designed to be compatible with the CommonJS AMD spec and57* RequireJS.58* @param {string[]|string} deps A name, or names for the payload59* @param {function|undefined} callback Function to call when the dependencies60* are resolved61* @return {undefined|object} The module required or undefined for62* array/callback method63*/64Domain.prototype.require = function(deps, callback) {65if (Array.isArray(deps)) {66var params = deps.map(function(dep) {67return this.lookup(dep);68}, this);69if (callback) {70callback.apply(null, params);71}72return undefined;73}74else {75return this.lookup(deps);76}77};7879function normalize(path) {80var bits = path.split('/');81var i = 1;82while (i < bits.length) {83if (bits[i] === '..') {84bits.splice(i-1, 1);85} else if (bits[i] === '.') {86bits.splice(i, 1);87} else {88i++;89}90}91return bits.join('/');92}9394function join(a, b) {95a = a.trim();96b = b.trim();97if (/^\//.test(b)) {98return b;99} else {100return a.replace(/\/*$/, '/') + b;101}102}103104function dirname(path) {105var bits = path.split('/');106bits.pop();107return bits.join('/');108}109110/**111* Lookup module names and resolve them by calling the definition function if112* needed.113* @param {string} moduleName A name for the payload to lookup114* @return {object} The module specified by aModuleName or null if not found.115*/116Domain.prototype.lookup = function(moduleName) {117if (/^\./.test(moduleName)) {118moduleName = normalize(join(dirname(this._currentModule), moduleName));119}120121if (moduleName in this.modules) {122var module = this.modules[moduleName];123return module;124}125126if (!(moduleName in define.modules)) {127throw new Error("Module not defined: " + moduleName);128}129130var module = define.modules[moduleName];131132if (typeof module == "function") {133var exports = {};134var previousModule = this._currentModule;135this._currentModule = moduleName;136module(this.require.bind(this), exports, { id: moduleName, uri: "" });137this._currentModule = previousModule;138module = exports;139}140141// cache the resulting module object for next time142this.modules[moduleName] = module;143144return module;145};146147}());148149define.Domain = Domain;150define.globalDomain = new Domain();151var require = define.globalDomain.require.bind(define.globalDomain);152/* -*- Mode: js; js-indent-level: 2; -*- */153/*154* Copyright 2011 Mozilla Foundation and contributors155* Licensed under the New BSD license. See LICENSE or:156* http://opensource.org/licenses/BSD-3-Clause157*/158define('source-map/source-map-generator', ['require', 'exports', 'module' , 'source-map/base64-vlq', 'source-map/util', 'source-map/array-set', 'source-map/mapping-list'], function(require, exports, module) {159160var base64VLQ = require('./base64-vlq');161var util = require('./util');162var ArraySet = require('./array-set').ArraySet;163var MappingList = require('./mapping-list').MappingList;164165/**166* An instance of the SourceMapGenerator represents a source map which is167* being built incrementally. You may pass an object with the following168* properties:169*170* - file: The filename of the generated source.171* - sourceRoot: A root for all relative URLs in this source map.172*/173function SourceMapGenerator(aArgs) {174if (!aArgs) {175aArgs = {};176}177this._file = util.getArg(aArgs, 'file', null);178this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);179this._skipValidation = util.getArg(aArgs, 'skipValidation', false);180this._sources = new ArraySet();181this._names = new ArraySet();182this._mappings = new MappingList();183this._sourcesContents = null;184}185186SourceMapGenerator.prototype._version = 3;187188/**189* Creates a new SourceMapGenerator based on a SourceMapConsumer190*191* @param aSourceMapConsumer The SourceMap.192*/193SourceMapGenerator.fromSourceMap =194function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {195var sourceRoot = aSourceMapConsumer.sourceRoot;196var generator = new SourceMapGenerator({197file: aSourceMapConsumer.file,198sourceRoot: sourceRoot199});200aSourceMapConsumer.eachMapping(function (mapping) {201var newMapping = {202generated: {203line: mapping.generatedLine,204column: mapping.generatedColumn205}206};207208if (mapping.source != null) {209newMapping.source = mapping.source;210if (sourceRoot != null) {211newMapping.source = util.relative(sourceRoot, newMapping.source);212}213214newMapping.original = {215line: mapping.originalLine,216column: mapping.originalColumn217};218219if (mapping.name != null) {220newMapping.name = mapping.name;221}222}223224generator.addMapping(newMapping);225});226aSourceMapConsumer.sources.forEach(function (sourceFile) {227var content = aSourceMapConsumer.sourceContentFor(sourceFile);228if (content != null) {229generator.setSourceContent(sourceFile, content);230}231});232return generator;233};234235/**236* Add a single mapping from original source line and column to the generated237* source's line and column for this source map being created. The mapping238* object should have the following properties:239*240* - generated: An object with the generated line and column positions.241* - original: An object with the original line and column positions.242* - source: The original source file (relative to the sourceRoot).243* - name: An optional original token name for this mapping.244*/245SourceMapGenerator.prototype.addMapping =246function SourceMapGenerator_addMapping(aArgs) {247var generated = util.getArg(aArgs, 'generated');248var original = util.getArg(aArgs, 'original', null);249var source = util.getArg(aArgs, 'source', null);250var name = util.getArg(aArgs, 'name', null);251252if (!this._skipValidation) {253this._validateMapping(generated, original, source, name);254}255256if (source != null && !this._sources.has(source)) {257this._sources.add(source);258}259260if (name != null && !this._names.has(name)) {261this._names.add(name);262}263264this._mappings.add({265generatedLine: generated.line,266generatedColumn: generated.column,267originalLine: original != null && original.line,268originalColumn: original != null && original.column,269source: source,270name: name271});272};273274/**275* Set the source content for a source file.276*/277SourceMapGenerator.prototype.setSourceContent =278function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {279var source = aSourceFile;280if (this._sourceRoot != null) {281source = util.relative(this._sourceRoot, source);282}283284if (aSourceContent != null) {285// Add the source content to the _sourcesContents map.286// Create a new _sourcesContents map if the property is null.287if (!this._sourcesContents) {288this._sourcesContents = {};289}290this._sourcesContents[util.toSetString(source)] = aSourceContent;291} else if (this._sourcesContents) {292// Remove the source file from the _sourcesContents map.293// If the _sourcesContents map is empty, set the property to null.294delete this._sourcesContents[util.toSetString(source)];295if (Object.keys(this._sourcesContents).length === 0) {296this._sourcesContents = null;297}298}299};300301/**302* Applies the mappings of a sub-source-map for a specific source file to the303* source map being generated. Each mapping to the supplied source file is304* rewritten using the supplied source map. Note: The resolution for the305* resulting mappings is the minimium of this map and the supplied map.306*307* @param aSourceMapConsumer The source map to be applied.308* @param aSourceFile Optional. The filename of the source file.309* If omitted, SourceMapConsumer's file property will be used.310* @param aSourceMapPath Optional. The dirname of the path to the source map311* to be applied. If relative, it is relative to the SourceMapConsumer.312* This parameter is needed when the two source maps aren't in the same313* directory, and the source map to be applied contains relative source314* paths. If so, those relative source paths need to be rewritten315* relative to the SourceMapGenerator.316*/317SourceMapGenerator.prototype.applySourceMap =318function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {319var sourceFile = aSourceFile;320// If aSourceFile is omitted, we will use the file property of the SourceMap321if (aSourceFile == null) {322if (aSourceMapConsumer.file == null) {323throw new Error(324'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +325'or the source map\'s "file" property. Both were omitted.'326);327}328sourceFile = aSourceMapConsumer.file;329}330var sourceRoot = this._sourceRoot;331// Make "sourceFile" relative if an absolute Url is passed.332if (sourceRoot != null) {333sourceFile = util.relative(sourceRoot, sourceFile);334}335// Applying the SourceMap can add and remove items from the sources and336// the names array.337var newSources = new ArraySet();338var newNames = new ArraySet();339340// Find mappings for the "sourceFile"341this._mappings.unsortedForEach(function (mapping) {342if (mapping.source === sourceFile && mapping.originalLine != null) {343// Check if it can be mapped by the source map, then update the mapping.344var original = aSourceMapConsumer.originalPositionFor({345line: mapping.originalLine,346column: mapping.originalColumn347});348if (original.source != null) {349// Copy mapping350mapping.source = original.source;351if (aSourceMapPath != null) {352mapping.source = util.join(aSourceMapPath, mapping.source)353}354if (sourceRoot != null) {355mapping.source = util.relative(sourceRoot, mapping.source);356}357mapping.originalLine = original.line;358mapping.originalColumn = original.column;359if (original.name != null) {360mapping.name = original.name;361}362}363}364365var source = mapping.source;366if (source != null && !newSources.has(source)) {367newSources.add(source);368}369370var name = mapping.name;371if (name != null && !newNames.has(name)) {372newNames.add(name);373}374375}, this);376this._sources = newSources;377this._names = newNames;378379// Copy sourcesContents of applied map.380aSourceMapConsumer.sources.forEach(function (sourceFile) {381var content = aSourceMapConsumer.sourceContentFor(sourceFile);382if (content != null) {383if (aSourceMapPath != null) {384sourceFile = util.join(aSourceMapPath, sourceFile);385}386if (sourceRoot != null) {387sourceFile = util.relative(sourceRoot, sourceFile);388}389this.setSourceContent(sourceFile, content);390}391}, this);392};393394/**395* A mapping can have one of the three levels of data:396*397* 1. Just the generated position.398* 2. The Generated position, original position, and original source.399* 3. Generated and original position, original source, as well as a name400* token.401*402* To maintain consistency, we validate that any new mapping being added falls403* in to one of these categories.404*/405SourceMapGenerator.prototype._validateMapping =406function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,407aName) {408if (aGenerated && 'line' in aGenerated && 'column' in aGenerated409&& aGenerated.line > 0 && aGenerated.column >= 0410&& !aOriginal && !aSource && !aName) {411// Case 1.412return;413}414else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated415&& aOriginal && 'line' in aOriginal && 'column' in aOriginal416&& aGenerated.line > 0 && aGenerated.column >= 0417&& aOriginal.line > 0 && aOriginal.column >= 0418&& aSource) {419// Cases 2 and 3.420return;421}422else {423throw new Error('Invalid mapping: ' + JSON.stringify({424generated: aGenerated,425source: aSource,426original: aOriginal,427name: aName428}));429}430};431432/**433* Serialize the accumulated mappings in to the stream of base 64 VLQs434* specified by the source map format.435*/436SourceMapGenerator.prototype._serializeMappings =437function SourceMapGenerator_serializeMappings() {438var previousGeneratedColumn = 0;439var previousGeneratedLine = 1;440var previousOriginalColumn = 0;441var previousOriginalLine = 0;442var previousName = 0;443var previousSource = 0;444var result = '';445var mapping;446447var mappings = this._mappings.toArray();448449for (var i = 0, len = mappings.length; i < len; i++) {450mapping = mappings[i];451452if (mapping.generatedLine !== previousGeneratedLine) {453previousGeneratedColumn = 0;454while (mapping.generatedLine !== previousGeneratedLine) {455result += ';';456previousGeneratedLine++;457}458}459else {460if (i > 0) {461if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) {462continue;463}464result += ',';465}466}467468result += base64VLQ.encode(mapping.generatedColumn469- previousGeneratedColumn);470previousGeneratedColumn = mapping.generatedColumn;471472if (mapping.source != null) {473result += base64VLQ.encode(this._sources.indexOf(mapping.source)474- previousSource);475previousSource = this._sources.indexOf(mapping.source);476477// lines are stored 0-based in SourceMap spec version 3478result += base64VLQ.encode(mapping.originalLine - 1479- previousOriginalLine);480previousOriginalLine = mapping.originalLine - 1;481482result += base64VLQ.encode(mapping.originalColumn483- previousOriginalColumn);484previousOriginalColumn = mapping.originalColumn;485486if (mapping.name != null) {487result += base64VLQ.encode(this._names.indexOf(mapping.name)488- previousName);489previousName = this._names.indexOf(mapping.name);490}491}492}493494return result;495};496497SourceMapGenerator.prototype._generateSourcesContent =498function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {499return aSources.map(function (source) {500if (!this._sourcesContents) {501return null;502}503if (aSourceRoot != null) {504source = util.relative(aSourceRoot, source);505}506var key = util.toSetString(source);507return Object.prototype.hasOwnProperty.call(this._sourcesContents,508key)509? this._sourcesContents[key]510: null;511}, this);512};513514/**515* Externalize the source map.516*/517SourceMapGenerator.prototype.toJSON =518function SourceMapGenerator_toJSON() {519var map = {520version: this._version,521sources: this._sources.toArray(),522names: this._names.toArray(),523mappings: this._serializeMappings()524};525if (this._file != null) {526map.file = this._file;527}528if (this._sourceRoot != null) {529map.sourceRoot = this._sourceRoot;530}531if (this._sourcesContents) {532map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);533}534535return map;536};537538/**539* Render the source map being generated to a string.540*/541SourceMapGenerator.prototype.toString =542function SourceMapGenerator_toString() {543return JSON.stringify(this.toJSON());544};545546exports.SourceMapGenerator = SourceMapGenerator;547548});549/* -*- Mode: js; js-indent-level: 2; -*- */550/*551* Copyright 2011 Mozilla Foundation and contributors552* Licensed under the New BSD license. See LICENSE or:553* http://opensource.org/licenses/BSD-3-Clause554*555* Based on the Base 64 VLQ implementation in Closure Compiler:556* https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java557*558* Copyright 2011 The Closure Compiler Authors. All rights reserved.559* Redistribution and use in source and binary forms, with or without560* modification, are permitted provided that the following conditions are561* met:562*563* * Redistributions of source code must retain the above copyright564* notice, this list of conditions and the following disclaimer.565* * Redistributions in binary form must reproduce the above566* copyright notice, this list of conditions and the following567* disclaimer in the documentation and/or other materials provided568* with the distribution.569* * Neither the name of Google Inc. nor the names of its570* contributors may be used to endorse or promote products derived571* from this software without specific prior written permission.572*573* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS574* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT575* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR576* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT577* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,578* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT579* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,580* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY581* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT582* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE583* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.584*/585define('source-map/base64-vlq', ['require', 'exports', 'module' , 'source-map/base64'], function(require, exports, module) {586587var base64 = require('./base64');588589// A single base 64 digit can contain 6 bits of data. For the base 64 variable590// length quantities we use in the source map spec, the first bit is the sign,591// the next four bits are the actual value, and the 6th bit is the592// continuation bit. The continuation bit tells us whether there are more593// digits in this value following this digit.594//595// Continuation596// | Sign597// | |598// V V599// 101011600601var VLQ_BASE_SHIFT = 5;602603// binary: 100000604var VLQ_BASE = 1 << VLQ_BASE_SHIFT;605606// binary: 011111607var VLQ_BASE_MASK = VLQ_BASE - 1;608609// binary: 100000610var VLQ_CONTINUATION_BIT = VLQ_BASE;611612/**613* Converts from a two-complement value to a value where the sign bit is614* placed in the least significant bit. For example, as decimals:615* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)616* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)617*/618function toVLQSigned(aValue) {619return aValue < 0620? ((-aValue) << 1) + 1621: (aValue << 1) + 0;622}623624/**625* Converts to a two-complement value from a value where the sign bit is626* placed in the least significant bit. For example, as decimals:627* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1628* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2629*/630function fromVLQSigned(aValue) {631var isNegative = (aValue & 1) === 1;632var shifted = aValue >> 1;633return isNegative634? -shifted635: shifted;636}637638/**639* Returns the base 64 VLQ encoded value.640*/641exports.encode = function base64VLQ_encode(aValue) {642var encoded = "";643var digit;644645var vlq = toVLQSigned(aValue);646647do {648digit = vlq & VLQ_BASE_MASK;649vlq >>>= VLQ_BASE_SHIFT;650if (vlq > 0) {651// There are still more digits in this value, so we must make sure the652// continuation bit is marked.653digit |= VLQ_CONTINUATION_BIT;654}655encoded += base64.encode(digit);656} while (vlq > 0);657658return encoded;659};660661/**662* Decodes the next base 64 VLQ value from the given string and returns the663* value and the rest of the string via the out parameter.664*/665exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {666var strLen = aStr.length;667var result = 0;668var shift = 0;669var continuation, digit;670671do {672if (aIndex >= strLen) {673throw new Error("Expected more digits in base 64 VLQ value.");674}675digit = base64.decode(aStr.charAt(aIndex++));676continuation = !!(digit & VLQ_CONTINUATION_BIT);677digit &= VLQ_BASE_MASK;678result = result + (digit << shift);679shift += VLQ_BASE_SHIFT;680} while (continuation);681682aOutParam.value = fromVLQSigned(result);683aOutParam.rest = aIndex;684};685686});687/* -*- Mode: js; js-indent-level: 2; -*- */688/*689* Copyright 2011 Mozilla Foundation and contributors690* Licensed under the New BSD license. See LICENSE or:691* http://opensource.org/licenses/BSD-3-Clause692*/693define('source-map/base64', ['require', 'exports', 'module' , ], function(require, exports, module) {694695var charToIntMap = {};696var intToCharMap = {};697698'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'699.split('')700.forEach(function (ch, index) {701charToIntMap[ch] = index;702intToCharMap[index] = ch;703});704705/**706* Encode an integer in the range of 0 to 63 to a single base 64 digit.707*/708exports.encode = function base64_encode(aNumber) {709if (aNumber in intToCharMap) {710return intToCharMap[aNumber];711}712throw new TypeError("Must be between 0 and 63: " + aNumber);713};714715/**716* Decode a single base 64 digit to an integer.717*/718exports.decode = function base64_decode(aChar) {719if (aChar in charToIntMap) {720return charToIntMap[aChar];721}722throw new TypeError("Not a valid base 64 digit: " + aChar);723};724725});726/* -*- Mode: js; js-indent-level: 2; -*- */727/*728* Copyright 2011 Mozilla Foundation and contributors729* Licensed under the New BSD license. See LICENSE or:730* http://opensource.org/licenses/BSD-3-Clause731*/732define('source-map/util', ['require', 'exports', 'module' , ], function(require, exports, module) {733734/**735* This is a helper function for getting values from parameter/options736* objects.737*738* @param args The object we are extracting values from739* @param name The name of the property we are getting.740* @param defaultValue An optional value to return if the property is missing741* from the object. If this is not specified and the property is missing, an742* error will be thrown.743*/744function getArg(aArgs, aName, aDefaultValue) {745if (aName in aArgs) {746return aArgs[aName];747} else if (arguments.length === 3) {748return aDefaultValue;749} else {750throw new Error('"' + aName + '" is a required argument.');751}752}753exports.getArg = getArg;754755var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;756var dataUrlRegexp = /^data:.+\,.+$/;757758function urlParse(aUrl) {759var match = aUrl.match(urlRegexp);760if (!match) {761return null;762}763return {764scheme: match[1],765auth: match[2],766host: match[3],767port: match[4],768path: match[5]769};770}771exports.urlParse = urlParse;772773function urlGenerate(aParsedUrl) {774var url = '';775if (aParsedUrl.scheme) {776url += aParsedUrl.scheme + ':';777}778url += '//';779if (aParsedUrl.auth) {780url += aParsedUrl.auth + '@';781}782if (aParsedUrl.host) {783url += aParsedUrl.host;784}785if (aParsedUrl.port) {786url += ":" + aParsedUrl.port787}788if (aParsedUrl.path) {789url += aParsedUrl.path;790}791return url;792}793exports.urlGenerate = urlGenerate;794795/**796* Normalizes a path, or the path portion of a URL:797*798* - Replaces consequtive slashes with one slash.799* - Removes unnecessary '.' parts.800* - Removes unnecessary '<dir>/..' parts.801*802* Based on code in the Node.js 'path' core module.803*804* @param aPath The path or url to normalize.805*/806function normalize(aPath) {807var path = aPath;808var url = urlParse(aPath);809if (url) {810if (!url.path) {811return aPath;812}813path = url.path;814}815var isAbsolute = (path.charAt(0) === '/');816817var parts = path.split(/\/+/);818for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {819part = parts[i];820if (part === '.') {821parts.splice(i, 1);822} else if (part === '..') {823up++;824} else if (up > 0) {825if (part === '') {826// The first part is blank if the path is absolute. Trying to go827// above the root is a no-op. Therefore we can remove all '..' parts828// directly after the root.829parts.splice(i + 1, up);830up = 0;831} else {832parts.splice(i, 2);833up--;834}835}836}837path = parts.join('/');838839if (path === '') {840path = isAbsolute ? '/' : '.';841}842843if (url) {844url.path = path;845return urlGenerate(url);846}847return path;848}849exports.normalize = normalize;850851/**852* Joins two paths/URLs.853*854* @param aRoot The root path or URL.855* @param aPath The path or URL to be joined with the root.856*857* - If aPath is a URL or a data URI, aPath is returned, unless aPath is a858* scheme-relative URL: Then the scheme of aRoot, if any, is prepended859* first.860* - Otherwise aPath is a path. If aRoot is a URL, then its path portion861* is updated with the result and aRoot is returned. Otherwise the result862* is returned.863* - If aPath is absolute, the result is aPath.864* - Otherwise the two paths are joined with a slash.865* - Joining for example 'http://' and 'www.example.com' is also supported.866*/867function join(aRoot, aPath) {868if (aRoot === "") {869aRoot = ".";870}871if (aPath === "") {872aPath = ".";873}874var aPathUrl = urlParse(aPath);875var aRootUrl = urlParse(aRoot);876if (aRootUrl) {877aRoot = aRootUrl.path || '/';878}879880// `join(foo, '//www.example.org')`881if (aPathUrl && !aPathUrl.scheme) {882if (aRootUrl) {883aPathUrl.scheme = aRootUrl.scheme;884}885return urlGenerate(aPathUrl);886}887888if (aPathUrl || aPath.match(dataUrlRegexp)) {889return aPath;890}891892// `join('http://', 'www.example.com')`893if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {894aRootUrl.host = aPath;895return urlGenerate(aRootUrl);896}897898var joined = aPath.charAt(0) === '/'899? aPath900: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);901902if (aRootUrl) {903aRootUrl.path = joined;904return urlGenerate(aRootUrl);905}906return joined;907}908exports.join = join;909910/**911* Make a path relative to a URL or another path.912*913* @param aRoot The root path or URL.914* @param aPath The path or URL to be made relative to aRoot.915*/916function relative(aRoot, aPath) {917if (aRoot === "") {918aRoot = ".";919}920921aRoot = aRoot.replace(/\/$/, '');922923// XXX: It is possible to remove this block, and the tests still pass!924var url = urlParse(aRoot);925if (aPath.charAt(0) == "/" && url && url.path == "/") {926return aPath.slice(1);927}928929return aPath.indexOf(aRoot + '/') === 0930? aPath.substr(aRoot.length + 1)931: aPath;932}933exports.relative = relative;934935/**936* Because behavior goes wacky when you set `__proto__` on objects, we937* have to prefix all the strings in our set with an arbitrary character.938*939* See https://github.com/mozilla/source-map/pull/31 and940* https://github.com/mozilla/source-map/issues/30941*942* @param String aStr943*/944function toSetString(aStr) {945return '$' + aStr;946}947exports.toSetString = toSetString;948949function fromSetString(aStr) {950return aStr.substr(1);951}952exports.fromSetString = fromSetString;953954function strcmp(aStr1, aStr2) {955var s1 = aStr1 || "";956var s2 = aStr2 || "";957return (s1 > s2) - (s1 < s2);958}959960/**961* Comparator between two mappings where the original positions are compared.962*963* Optionally pass in `true` as `onlyCompareGenerated` to consider two964* mappings with the same original source/line/column, but different generated965* line and column the same. Useful when searching for a mapping with a966* stubbed out mapping.967*/968function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {969var cmp;970971cmp = strcmp(mappingA.source, mappingB.source);972if (cmp) {973return cmp;974}975976cmp = mappingA.originalLine - mappingB.originalLine;977if (cmp) {978return cmp;979}980981cmp = mappingA.originalColumn - mappingB.originalColumn;982if (cmp || onlyCompareOriginal) {983return cmp;984}985986cmp = strcmp(mappingA.name, mappingB.name);987if (cmp) {988return cmp;989}990991cmp = mappingA.generatedLine - mappingB.generatedLine;992if (cmp) {993return cmp;994}995996return mappingA.generatedColumn - mappingB.generatedColumn;997};998exports.compareByOriginalPositions = compareByOriginalPositions;9991000/**1001* Comparator between two mappings where the generated positions are1002* compared.1003*1004* Optionally pass in `true` as `onlyCompareGenerated` to consider two1005* mappings with the same generated line and column, but different1006* source/name/original line and column the same. Useful when searching for a1007* mapping with a stubbed out mapping.1008*/1009function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {1010var cmp;10111012cmp = mappingA.generatedLine - mappingB.generatedLine;1013if (cmp) {1014return cmp;1015}10161017cmp = mappingA.generatedColumn - mappingB.generatedColumn;1018if (cmp || onlyCompareGenerated) {1019return cmp;1020}10211022cmp = strcmp(mappingA.source, mappingB.source);1023if (cmp) {1024return cmp;1025}10261027cmp = mappingA.originalLine - mappingB.originalLine;1028if (cmp) {1029return cmp;1030}10311032cmp = mappingA.originalColumn - mappingB.originalColumn;1033if (cmp) {1034return cmp;1035}10361037return strcmp(mappingA.name, mappingB.name);1038};1039exports.compareByGeneratedPositions = compareByGeneratedPositions;10401041});1042/* -*- Mode: js; js-indent-level: 2; -*- */1043/*1044* Copyright 2011 Mozilla Foundation and contributors1045* Licensed under the New BSD license. See LICENSE or:1046* http://opensource.org/licenses/BSD-3-Clause1047*/1048define('source-map/array-set', ['require', 'exports', 'module' , 'source-map/util'], function(require, exports, module) {10491050var util = require('./util');10511052/**1053* A data structure which is a combination of an array and a set. Adding a new1054* member is O(1), testing for membership is O(1), and finding the index of an1055* element is O(1). Removing elements from the set is not supported. Only1056* strings are supported for membership.1057*/1058function ArraySet() {1059this._array = [];1060this._set = {};1061}10621063/**1064* Static method for creating ArraySet instances from an existing array.1065*/1066ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {1067var set = new ArraySet();1068for (var i = 0, len = aArray.length; i < len; i++) {1069set.add(aArray[i], aAllowDuplicates);1070}1071return set;1072};10731074/**1075* Add the given string to this set.1076*1077* @param String aStr1078*/1079ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {1080var isDuplicate = this.has(aStr);1081var idx = this._array.length;1082if (!isDuplicate || aAllowDuplicates) {1083this._array.push(aStr);1084}1085if (!isDuplicate) {1086this._set[util.toSetString(aStr)] = idx;1087}1088};10891090/**1091* Is the given string a member of this set?1092*1093* @param String aStr1094*/1095ArraySet.prototype.has = function ArraySet_has(aStr) {1096return Object.prototype.hasOwnProperty.call(this._set,1097util.toSetString(aStr));1098};10991100/**1101* What is the index of the given string in the array?1102*1103* @param String aStr1104*/1105ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {1106if (this.has(aStr)) {1107return this._set[util.toSetString(aStr)];1108}1109throw new Error('"' + aStr + '" is not in the set.');1110};11111112/**1113* What is the element at the given index?1114*1115* @param Number aIdx1116*/1117ArraySet.prototype.at = function ArraySet_at(aIdx) {1118if (aIdx >= 0 && aIdx < this._array.length) {1119return this._array[aIdx];1120}1121throw new Error('No element indexed by ' + aIdx);1122};11231124/**1125* Returns the array representation of this set (which has the proper indices1126* indicated by indexOf). Note that this is a copy of the internal array used1127* for storing the members so that no one can mess with internal state.1128*/1129ArraySet.prototype.toArray = function ArraySet_toArray() {1130return this._array.slice();1131};11321133exports.ArraySet = ArraySet;11341135});1136/* -*- Mode: js; js-indent-level: 2; -*- */1137/*1138* Copyright 2014 Mozilla Foundation and contributors1139* Licensed under the New BSD license. See LICENSE or:1140* http://opensource.org/licenses/BSD-3-Clause1141*/1142define('source-map/mapping-list', ['require', 'exports', 'module' , 'source-map/util'], function(require, exports, module) {11431144var util = require('./util');11451146/**1147* Determine whether mappingB is after mappingA with respect to generated1148* position.1149*/1150function generatedPositionAfter(mappingA, mappingB) {1151// Optimized for most common case1152var lineA = mappingA.generatedLine;1153var lineB = mappingB.generatedLine;1154var columnA = mappingA.generatedColumn;1155var columnB = mappingB.generatedColumn;1156return lineB > lineA || lineB == lineA && columnB >= columnA ||1157util.compareByGeneratedPositions(mappingA, mappingB) <= 0;1158}11591160/**1161* A data structure to provide a sorted view of accumulated mappings in a1162* performance conscious manner. It trades a neglibable overhead in general1163* case for a large speedup in case of mappings being added in order.1164*/1165function MappingList() {1166this._array = [];1167this._sorted = true;1168// Serves as infimum1169this._last = {generatedLine: -1, generatedColumn: 0};1170}11711172/**1173* Iterate through internal items. This method takes the same arguments that1174* `Array.prototype.forEach` takes.1175*1176* NOTE: The order of the mappings is NOT guaranteed.1177*/1178MappingList.prototype.unsortedForEach =1179function MappingList_forEach(aCallback, aThisArg) {1180this._array.forEach(aCallback, aThisArg);1181};11821183/**1184* Add the given source mapping.1185*1186* @param Object aMapping1187*/1188MappingList.prototype.add = function MappingList_add(aMapping) {1189var mapping;1190if (generatedPositionAfter(this._last, aMapping)) {1191this._last = aMapping;1192this._array.push(aMapping);1193} else {1194this._sorted = false;1195this._array.push(aMapping);1196}1197};11981199/**1200* Returns the flat, sorted array of mappings. The mappings are sorted by1201* generated position.1202*1203* WARNING: This method returns internal data without copying, for1204* performance. The return value must NOT be mutated, and should be treated as1205* an immutable borrow. If you want to take ownership, you must make your own1206* copy.1207*/1208MappingList.prototype.toArray = function MappingList_toArray() {1209if (!this._sorted) {1210this._array.sort(util.compareByGeneratedPositions);1211this._sorted = true;1212}1213return this._array;1214};12151216exports.MappingList = MappingList;12171218});1219/* -*- Mode: js; js-indent-level: 2; -*- */1220/*1221* Copyright 2011 Mozilla Foundation and contributors1222* Licensed under the New BSD license. See LICENSE or:1223* http://opensource.org/licenses/BSD-3-Clause1224*/1225define('source-map/source-map-consumer', ['require', 'exports', 'module' , 'source-map/util', 'source-map/asm-parser', 'source-map/binary-search', 'source-map/array-set', 'source-map/base64-vlq'], function(require, exports, module) {12261227var util = require('./util');1228var asmParser = require('./asm-parser');1229var binarySearch = require('./binary-search');1230var ArraySet = require('./array-set').ArraySet;1231var base64VLQ = require('./base64-vlq');12321233function SourceMapConsumer(aSourceMap) {1234var sourceMap = aSourceMap;1235if (typeof aSourceMap === 'string') {1236sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));1237}12381239return sourceMap.sections != null1240? new IndexedSourceMapConsumer(sourceMap)1241: new BasicSourceMapConsumer(sourceMap);1242}12431244SourceMapConsumer.fromSourceMap = function(aSourceMap) {1245return BasicSourceMapConsumer.fromSourceMap(aSourceMap);1246}12471248/**1249* The version of the source mapping spec that we are consuming.1250*/1251SourceMapConsumer.prototype._version = 3;12521253// `__generatedMappings` and `__originalMappings` are arrays that hold the1254// parsed mapping coordinates from the source map's "mappings" attribute. They1255// are lazily instantiated, accessed via the `_generatedMappings` and1256// `_originalMappings` getters respectively, and we only parse the mappings1257// and create these arrays once queried for a source location. We jump through1258// these hoops because there can be many thousands of mappings, and parsing1259// them is expensive, so we only want to do it if we must.1260//1261// Each object in the arrays is of the form:1262//1263// {1264// generatedLine: The line number in the generated code,1265// generatedColumn: The column number in the generated code,1266// source: The path to the original source file that generated this1267// chunk of code,1268// originalLine: The line number in the original source that1269// corresponds to this chunk of generated code,1270// originalColumn: The column number in the original source that1271// corresponds to this chunk of generated code,1272// name: The name of the original symbol which generated this chunk of1273// code.1274// }1275//1276// All properties except for `generatedLine` and `generatedColumn` can be1277// `null`.1278//1279// `_generatedMappings` is ordered by the generated positions.1280//1281// `_originalMappings` is ordered by the original positions.12821283SourceMapConsumer.prototype.__generatedMappings = null;1284Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {1285get: function () {1286if (!this.__generatedMappings) {1287this.__generatedMappings = [];1288this.__originalMappings = [];1289this._parseMappings(this._mappings, this.sourceRoot);1290}12911292return this.__generatedMappings;1293}1294});12951296SourceMapConsumer.prototype.__originalMappings = null;1297Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {1298get: function () {1299if (!this.__originalMappings) {1300this.__generatedMappings = [];1301this.__originalMappings = [];1302this._parseMappings(this._mappings, this.sourceRoot);1303}13041305return this.__originalMappings;1306}1307});13081309SourceMapConsumer.prototype._nextCharIsMappingSeparator =1310function SourceMapConsumer_nextCharIsMappingSeparator(aStr, index) {1311var c = aStr.charAt(index);1312return c === ";" || c === ",";1313};13141315/**1316* Parse the mappings in a string in to a data structure which we can easily1317* query (the ordered arrays in the `this.__generatedMappings` and1318* `this.__originalMappings` properties).1319*/1320SourceMapConsumer.prototype._parseMappings =1321function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {1322throw new Error("Subclasses must implement _parseMappings");1323};13241325SourceMapConsumer.GENERATED_ORDER = 1;1326SourceMapConsumer.ORIGINAL_ORDER = 2;13271328SourceMapConsumer.LEAST_UPPER_BOUND = 1;1329SourceMapConsumer.GREATEST_LOWER_BOUND = 2;13301331/**1332* Iterate over each mapping between an original source/line/column and a1333* generated line/column in this source map.1334*1335* @param Function aCallback1336* The function that is called with each mapping.1337* @param Object aContext1338* Optional. If specified, this object will be the value of `this` every1339* time that `aCallback` is called.1340* @param aOrder1341* Either `SourceMapConsumer.GENERATED_ORDER` or1342* `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to1343* iterate over the mappings sorted by the generated file's line/column1344* order or the original's source/line/column order, respectively. Defaults to1345* `SourceMapConsumer.GENERATED_ORDER`.1346*/1347SourceMapConsumer.prototype.eachMapping =1348function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {1349var context = aContext || null;1350var order = aOrder || SourceMapConsumer.GENERATED_ORDER;13511352var mappings;1353switch (order) {1354case SourceMapConsumer.GENERATED_ORDER:1355mappings = this._generatedMappings;1356break;1357case SourceMapConsumer.ORIGINAL_ORDER:1358mappings = this._originalMappings;1359break;1360default:1361throw new Error("Unknown order of iteration.");1362}13631364var sourceRoot = this.sourceRoot;1365mappings.map(function (mapping) {1366var source = mapping.source;1367if (source != null && sourceRoot != null) {1368source = util.join(sourceRoot, source);1369}1370return {1371source: source,1372generatedLine: mapping.generatedLine,1373generatedColumn: mapping.generatedColumn,1374originalLine: mapping.originalLine,1375originalColumn: mapping.originalColumn,1376name: mapping.name1377};1378}).forEach(aCallback, context);1379};13801381/**1382* Returns all generated line and column information for the original source1383* and line provided. The only argument is an object with the following1384* properties:1385*1386* - source: The filename of the original source.1387* - line: The line number in the original source.1388*1389* and an array of objects is returned, each with the following properties:1390*1391* - line: The line number in the generated source, or null.1392* - column: The column number in the generated source, or null.1393*/1394SourceMapConsumer.prototype.allGeneratedPositionsFor =1395function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {1396var needle = {1397source: util.getArg(aArgs, 'source'),1398originalLine: util.getArg(aArgs, 'line'),1399originalColumn: 01400};14011402if (this.sourceRoot != null) {1403needle.source = util.relative(this.sourceRoot, needle.source);1404}14051406var mappings = [];14071408var index = this._findMapping(needle,1409this._originalMappings,1410"originalLine",1411"originalColumn",1412util.compareByOriginalPositions);1413if (index >= 0) {1414var mapping = this._originalMappings[index];14151416// Iterate until either we run out of mappings, or we run into1417// a mapping for a different line. Since mappings are sorted, this is1418// guaranteed to find all mappings for the line we are interested in.1419while (mapping && mapping.originalLine === needle.originalLine) {1420mappings.push({1421line: util.getArg(mapping, 'generatedLine', null),1422column: util.getArg(mapping, 'generatedColumn', null),1423lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)1424});14251426mapping = this._originalMappings[++index];1427}1428}14291430return mappings;1431};14321433exports.SourceMapConsumer = SourceMapConsumer;14341435/**1436* A BasicSourceMapConsumer instance represents a parsed source map which we can1437* query for information about the original file positions by giving it a file1438* position in the generated source.1439*1440* The only parameter is the raw source map (either as a JSON string, or1441* already parsed to an object). According to the spec, source maps have the1442* following attributes:1443*1444* - version: Which version of the source map spec this map is following.1445* - sources: An array of URLs to the original source files.1446* - names: An array of identifiers which can be referrenced by individual mappings.1447* - sourceRoot: Optional. The URL root from which all sources are relative.1448* - sourcesContent: Optional. An array of contents of the original source files.1449* - mappings: A string of base64 VLQs which contain the actual mappings.1450* - file: Optional. The generated file this source map is associated with.1451*1452* Here is an example source map, taken from the source map spec[0]:1453*1454* {1455* version : 3,1456* file: "out.js",1457* sourceRoot : "",1458* sources: ["foo.js", "bar.js"],1459* names: ["src", "maps", "are", "fun"],1460* mappings: "AA,AB;;ABCDE;"1461* }1462*1463* [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#1464*/1465function BasicSourceMapConsumer(aSourceMap) {1466var sourceMap = aSourceMap;1467if (typeof aSourceMap === 'string') {1468sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));1469}14701471var version = util.getArg(sourceMap, 'version');1472var sources = util.getArg(sourceMap, 'sources');1473// Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which1474// requires the array) to play nice here.1475var names = util.getArg(sourceMap, 'names', []);1476var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);1477var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);1478var mappings = util.getArg(sourceMap, 'mappings');1479var file = util.getArg(sourceMap, 'file', null);14801481// Once again, Sass deviates from the spec and supplies the version as a1482// string rather than a number, so we use loose equality checking here.1483if (version != this._version) {1484throw new Error('Unsupported version: ' + version);1485}14861487// Some source maps produce relative source paths like "./foo.js" instead of1488// "foo.js". Normalize these first so that future comparisons will succeed.1489// See bugzil.la/1090768.1490sources = sources.map(util.normalize);14911492// Pass `true` below to allow duplicate names and sources. While source maps1493// are intended to be compressed and deduplicated, the TypeScript compiler1494// sometimes generates source maps with duplicates in them. See Github issue1495// #72 and bugzil.la/889492.1496this._names = ArraySet.fromArray(names, true);1497this._sources = ArraySet.fromArray(sources, true);14981499this.sourceRoot = sourceRoot;1500this.sourcesContent = sourcesContent;1501this._mappings = mappings;1502this.file = file;1503}15041505BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);1506BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;15071508/**1509* Create a BasicSourceMapConsumer from a SourceMapGenerator.1510*1511* @param SourceMapGenerator aSourceMap1512* The source map that will be consumed.1513* @returns BasicSourceMapConsumer1514*/1515BasicSourceMapConsumer.fromSourceMap =1516function SourceMapConsumer_fromSourceMap(aSourceMap) {1517var smc = Object.create(BasicSourceMapConsumer.prototype);15181519smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);1520smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);1521smc.sourceRoot = aSourceMap._sourceRoot;1522smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),1523smc.sourceRoot);1524smc.file = aSourceMap._file;15251526smc.__generatedMappings = aSourceMap._mappings.toArray().slice();1527smc.__originalMappings = aSourceMap._mappings.toArray().slice()1528.sort(util.compareByOriginalPositions);15291530return smc;1531};15321533/**1534* The version of the source mapping spec that we are consuming.1535*/1536BasicSourceMapConsumer.prototype._version = 3;15371538/**1539* The list of original sources.1540*/1541Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {1542get: function () {1543return this._sources.toArray().map(function (s) {1544return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;1545}, this);1546}1547});15481549/**1550* Parse the mappings in a string in to a data structure which we can easily1551* query (the ordered arrays in the `this.__generatedMappings` and1552* `this.__originalMappings` properties).1553*/1554BasicSourceMapConsumer.prototype._parseMappings =1555asmParser.parseMappings;15561557/**1558* Find the mapping that best matches the hypothetical "needle" mapping that1559* we are searching for in the given "haystack" of mappings.1560*/1561BasicSourceMapConsumer.prototype._findMapping =1562function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,1563aColumnName, aComparator) {1564// To return the position we are searching for, we must first find the1565// mapping for the given position and then return the opposite position it1566// points to. Because the mappings are sorted, we can use binary search to1567// find the best mapping.15681569if (aNeedle[aLineName] <= 0) {1570throw new TypeError('Line must be greater than or equal to 1, got '1571+ aNeedle[aLineName]);1572}1573if (aNeedle[aColumnName] < 0) {1574throw new TypeError('Column must be greater than or equal to 0, got '1575+ aNeedle[aColumnName]);1576}15771578return binarySearch.search(aNeedle, aMappings, aComparator);1579};15801581/**1582* Compute the last column for each generated mapping. The last column is1583* inclusive.1584*/1585BasicSourceMapConsumer.prototype.computeColumnSpans =1586function SourceMapConsumer_computeColumnSpans() {1587for (var index = 0; index < this._generatedMappings.length; ++index) {1588var mapping = this._generatedMappings[index];15891590// Mappings do not contain a field for the last generated columnt. We1591// can come up with an optimistic estimate, however, by assuming that1592// mappings are contiguous (i.e. given two consecutive mappings, the1593// first mapping ends where the second one starts).1594if (index + 1 < this._generatedMappings.length) {1595var nextMapping = this._generatedMappings[index + 1];15961597if (mapping.generatedLine === nextMapping.generatedLine) {1598mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;1599continue;1600}1601}16021603// The last mapping for each line spans the entire line.1604mapping.lastGeneratedColumn = Infinity;1605}1606};16071608/**1609* Returns the original source, line, and column information for the generated1610* source's line and column positions provided. The only argument is an object1611* with the following properties:1612*1613* - line: The line number in the generated source.1614* - column: The column number in the generated source.1615*1616* and an object is returned with the following properties:1617*1618* - source: The original source file, or null.1619* - line: The line number in the original source, or null.1620* - column: The column number in the original source, or null.1621* - name: The original identifier, or null.1622*/1623BasicSourceMapConsumer.prototype.originalPositionFor =1624function SourceMapConsumer_originalPositionFor(aArgs) {1625var needle = {1626generatedLine: util.getArg(aArgs, 'line'),1627generatedColumn: util.getArg(aArgs, 'column')1628};16291630var index = this._findMapping(needle,1631this._generatedMappings,1632"generatedLine",1633"generatedColumn",1634util.compareByGeneratedPositions);16351636if (index >= 0) {1637var mapping = this._generatedMappings[index];16381639if (mapping.generatedLine === needle.generatedLine) {1640var source = util.getArg(mapping, 'source', null);1641if (source != null && this.sourceRoot != null) {1642source = util.join(this.sourceRoot, source);1643}1644return {1645source: source,1646line: util.getArg(mapping, 'originalLine', null),1647column: util.getArg(mapping, 'originalColumn', null),1648name: util.getArg(mapping, 'name', null)1649};1650}1651}16521653return {1654source: null,1655line: null,1656column: null,1657name: null1658};1659};16601661/**1662* Returns the original source content. The only argument is the url of the1663* original source file. Returns null if no original source content is1664* availible.1665*/1666BasicSourceMapConsumer.prototype.sourceContentFor =1667function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {1668if (!this.sourcesContent) {1669return null;1670}16711672if (this.sourceRoot != null) {1673aSource = util.relative(this.sourceRoot, aSource);1674}16751676if (this._sources.has(aSource)) {1677return this.sourcesContent[this._sources.indexOf(aSource)];1678}16791680var url;1681if (this.sourceRoot != null1682&& (url = util.urlParse(this.sourceRoot))) {1683// XXX: file:// URIs and absolute paths lead to unexpected behavior for1684// many users. We can help them out when they expect file:// URIs to1685// behave like it would if they were running a local HTTP server. See1686// https://bugzilla.mozilla.org/show_bug.cgi?id=885597.1687var fileUriAbsPath = aSource.replace(/^file:\/\//, "");1688if (url.scheme == "file"1689&& this._sources.has(fileUriAbsPath)) {1690return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]1691}16921693if ((!url.path || url.path == "/")1694&& this._sources.has("/" + aSource)) {1695return this.sourcesContent[this._sources.indexOf("/" + aSource)];1696}1697}16981699// This function is used recursively from1700// IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we1701// don't want to throw if we can't find the source - we just want to1702// return null, so we provide a flag to exit gracefully.1703if (nullOnMissing) {1704return null;1705}1706else {1707throw new Error('"' + aSource + '" is not in the SourceMap.');1708}1709};17101711/**1712* Returns the generated line and column information for the original source,1713* line, and column positions provided. The only argument is an object with1714* the following properties:1715*1716* - source: The filename of the original source.1717* - line: The line number in the original source.1718* - column: The column number in the original source.1719*1720* and an object is returned with the following properties:1721*1722* - line: The line number in the generated source, or null.1723* - column: The column number in the generated source, or null.1724*/1725BasicSourceMapConsumer.prototype.generatedPositionFor =1726function SourceMapConsumer_generatedPositionFor(aArgs) {1727var needle = {1728source: util.getArg(aArgs, 'source'),1729originalLine: util.getArg(aArgs, 'line'),1730originalColumn: util.getArg(aArgs, 'column')1731};17321733if (this.sourceRoot != null) {1734needle.source = util.relative(this.sourceRoot, needle.source);1735}17361737var index = this._findMapping(needle,1738this._originalMappings,1739"originalLine",1740"originalColumn",1741util.compareByOriginalPositions);17421743if (index >= 0) {1744var mapping = this._originalMappings[index];17451746return {1747line: util.getArg(mapping, 'generatedLine', null),1748column: util.getArg(mapping, 'generatedColumn', null),1749lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)1750};1751}17521753return {1754line: null,1755column: null,1756lastColumn: null1757};1758};17591760exports.BasicSourceMapConsumer = BasicSourceMapConsumer;17611762/**1763* An IndexedSourceMapConsumer instance represents a parsed source map which1764* we can query for information. It differs from BasicSourceMapConsumer in1765* that it takes "indexed" source maps (i.e. ones with a "sections" field) as1766* input.1767*1768* The only parameter is a raw source map (either as a JSON string, or already1769* parsed to an object). According to the spec for indexed source maps, they1770* have the following attributes:1771*1772* - version: Which version of the source map spec this map is following.1773* - file: Optional. The generated file this source map is associated with.1774* - sections: A list of section definitions.1775*1776* Each value under the "sections" field has two fields:1777* - offset: The offset into the original specified at which this section1778* begins to apply, defined as an object with a "line" and "column"1779* field.1780* - map: A source map definition. This source map could also be indexed,1781* but doesn't have to be.1782*1783* Instead of the "map" field, it's also possible to have a "url" field1784* specifying a URL to retrieve a source map from, but that's currently1785* unsupported.1786*1787* Here's an example source map, taken from the source map spec[0], but1788* modified to omit a section which uses the "url" field.1789*1790* {1791* version : 3,1792* file: "app.js",1793* sections: [{1794* offset: {line:100, column:10},1795* map: {1796* version : 3,1797* file: "section.js",1798* sources: ["foo.js", "bar.js"],1799* names: ["src", "maps", "are", "fun"],1800* mappings: "AAAA,E;;ABCDE;"1801* }1802* }],1803* }1804*1805* [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt1806*/1807function IndexedSourceMapConsumer(aSourceMap) {1808var sourceMap = aSourceMap;1809if (typeof aSourceMap === 'string') {1810sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));1811}18121813var version = util.getArg(sourceMap, 'version');1814var sections = util.getArg(sourceMap, 'sections');18151816if (version != this._version) {1817throw new Error('Unsupported version: ' + version);1818}18191820var lastOffset = {1821line: -1,1822column: 01823};1824this._sections = sections.map(function (s) {1825if (s.url) {1826// The url field will require support for asynchronicity.1827// See https://github.com/mozilla/source-map/issues/161828throw new Error('Support for url field in sections not implemented.');1829}1830var offset = util.getArg(s, 'offset');1831var offsetLine = util.getArg(offset, 'line');1832var offsetColumn = util.getArg(offset, 'column');18331834if (offsetLine < lastOffset.line ||1835(offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {1836throw new Error('Section offsets must be ordered and non-overlapping.');1837}1838lastOffset = offset;18391840return {1841generatedOffset: {1842// The offset fields are 0-based, but we use 1-based indices when1843// encoding/decoding from VLQ.1844generatedLine: offsetLine + 1,1845generatedColumn: offsetColumn + 11846},1847consumer: new SourceMapConsumer(util.getArg(s, 'map'))1848}1849});1850}18511852IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);1853IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;18541855/**1856* The version of the source mapping spec that we are consuming.1857*/1858IndexedSourceMapConsumer.prototype._version = 3;18591860/**1861* The list of original sources.1862*/1863Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {1864get: function () {1865var sources = [];1866for (var i = 0; i < this._sections.length; i++) {1867for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {1868sources.push(this._sections[i].consumer.sources[j]);1869}1870};1871return sources;1872}1873});18741875/**1876* Returns the original source, line, and column information for the generated1877* source's line and column positions provided. The only argument is an object1878* with the following properties:1879*1880* - line: The line number in the generated source.1881* - column: The column number in the generated source.1882*1883* and an object is returned with the following properties:1884*1885* - source: The original source file, or null.1886* - line: The line number in the original source, or null.1887* - column: The column number in the original source, or null.1888* - name: The original identifier, or null.1889*/1890IndexedSourceMapConsumer.prototype.originalPositionFor =1891function IndexedSourceMapConsumer_originalPositionFor(aArgs) {1892var needle = {1893generatedLine: util.getArg(aArgs, 'line'),1894generatedColumn: util.getArg(aArgs, 'column')1895};18961897// Find the section containing the generated position we're trying to map1898// to an original position.1899var sectionIndex = binarySearch.search(needle, this._sections,1900function(needle, section) {1901var cmp = needle.generatedLine - section.generatedOffset.generatedLine;1902if (cmp) {1903return cmp;1904}19051906return (needle.generatedColumn -1907section.generatedOffset.generatedColumn);1908}, binarySearch.GREATEST_LOWER_BOUND);1909var section = this._sections[sectionIndex];19101911if (!section) {1912return {1913source: null,1914line: null,1915column: null,1916name: null1917};1918}19191920return section.consumer.originalPositionFor({1921line: needle.generatedLine -1922(section.generatedOffset.generatedLine - 1),1923column: needle.generatedColumn -1924(section.generatedOffset.generatedLine === needle.generatedLine1925? section.generatedOffset.generatedColumn - 11926: 0)1927});1928};19291930/**1931* Returns the original source content. The only argument is the url of the1932* original source file. Returns null if no original source content is1933* available.1934*/1935IndexedSourceMapConsumer.prototype.sourceContentFor =1936function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {1937for (var i = 0; i < this._sections.length; i++) {1938var section = this._sections[i];19391940var content = section.consumer.sourceContentFor(aSource, true);1941if (content) {1942return content;1943}1944}1945if (nullOnMissing) {1946return null;1947}1948else {1949throw new Error('"' + aSource + '" is not in the SourceMap.');1950}1951};19521953/**1954* Returns the generated line and column information for the original source,1955* line, and column positions provided. The only argument is an object with1956* the following properties:1957*1958* - source: The filename of the original source.1959* - line: The line number in the original source.1960* - column: The column number in the original source.1961*1962* and an object is returned with the following properties:1963*1964* - line: The line number in the generated source, or null.1965* - column: The column number in the generated source, or null.1966*/1967IndexedSourceMapConsumer.prototype.generatedPositionFor =1968function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {1969for (var i = 0; i < this._sections.length; i++) {1970var section = this._sections[i];19711972// Only consider this section if the requested source is in the list of1973// sources of the consumer.1974if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {1975continue;1976}1977var generatedPosition = section.consumer.generatedPositionFor(aArgs);1978if (generatedPosition) {1979var ret = {1980line: generatedPosition.line +1981(section.generatedOffset.generatedLine - 1),1982column: generatedPosition.column +1983(section.generatedOffset.generatedLine === generatedPosition.line1984? section.generatedOffset.generatedColumn - 11985: 0)1986};1987return ret;1988}1989}19901991return {1992line: null,1993column: null1994};1995};19961997/**1998* Parse the mappings in a string in to a data structure which we can easily1999* query (the ordered arrays in the `this.__generatedMappings` and2000* `this.__originalMappings` properties).2001*/2002IndexedSourceMapConsumer.prototype._parseMappings =2003function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {2004this.__generatedMappings = [];2005this.__originalMappings = [];2006for (var i = 0; i < this._sections.length; i++) {2007var section = this._sections[i];2008var sectionMappings = section.consumer._generatedMappings;2009for (var j = 0; j < sectionMappings.length; j++) {2010var mapping = sectionMappings[i];20112012var source = mapping.source;2013var sourceRoot = section.consumer.sourceRoot;20142015if (source != null && sourceRoot != null) {2016source = util.join(sourceRoot, source);2017}20182019// The mappings coming from the consumer for the section have2020// generated positions relative to the start of the section, so we2021// need to offset them to be relative to the start of the concatenated2022// generated file.2023var adjustedMapping = {2024source: source,2025generatedLine: mapping.generatedLine +2026(section.generatedOffset.generatedLine - 1),2027generatedColumn: mapping.column +2028(section.generatedOffset.generatedLine === mapping.generatedLine)2029? section.generatedOffset.generatedColumn - 12030: 0,2031originalLine: mapping.originalLine,2032originalColumn: mapping.originalColumn,2033name: mapping.name2034};20352036this.__generatedMappings.push(adjustedMapping);2037if (typeof adjustedMapping.originalLine === 'number') {2038this.__originalMappings.push(adjustedMapping);2039}2040};2041};20422043this.__generatedMappings.sort(util.compareByGeneratedPositions);2044this.__originalMappings.sort(util.compareByOriginalPositions);2045};20462047exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;20482049});2050/* -*- Mode: js; js-indent-level: 2; -*- */2051/*2052* Copyright 2011 Mozilla Foundation and contributors2053* Licensed under the New BSD license. See LICENSE or:2054* http://opensource.org/licenses/BSD-3-Clause2055*/2056define('source-map/asm-parser', ['require', 'exports', 'module' , 'source-map/util'], function(require, exports, module) {20572058var util = require('./util');20592060// Convert the given ASCII string into a Uint8Array with room for `reserved`2061// number of int32 slots at the start.2062function stringToArray(string, reserved) {2063var reservedSize = reserved * 4;2064var length = string.length + reservedSize;2065// Find the smallest power of 2 that is greater than the required length.2066var arraySize = Math.pow(2, Math.ceil(Math.log2(length)));2067var array = new Uint8Array(arraySize);20682069for (var idx = reservedSize; idx < length; idx++) {2070var ch = string.charCodeAt(idx - reservedSize);2071if (ch > 0x80) {2072throw new Error("Unexpected non-ASCII character: '" + string.charAt(idx)2073+ "' at index " + idx + ". A source map's 'mappings' string "2074+ "should only contain ASCII characters.");2075}2076array[idx] = ch;2077}20782079return array;2080}20812082function AsmParse(stdlib, foreign, buffer) {2083"use asm";20842085// Foreign functions.20862087var eachMapping = foreign.eachMapping;2088var getEndOfString = foreign.getEndOfString;2089var log = foreign.log;20902091// Heap views.20922093var HEAPU8 = new stdlib.Uint8Array(buffer);2094var HEAP32 = new stdlib.Int32Array(buffer);2095var HEAPU32 = new stdlib.Uint32Array(buffer);20962097// Constants.20982099var semicolon = 59; // ';'2100var comma = 44; // ','21012102var VLQ_BASE_SHIFT = 5;2103var VLQ_BASE = 32; // 1 << VLQ_BASE_SHIFT2104var VLQ_BASE_MASK = 31; // VLQ_BASE - 12105var VLQ_CONTINUATION_BIT = 32; // VLQ_BASE21062107// Reserved slots in the buffer. Access via `buffer[slotName]`.21082109// The current index into the string. Uint32.2110var slotIdx = 0;2111// The value of the last parsed VLQ. Int32.2112var slotVlq = 1;2113// The end index of the string. Uint32.2114var slotEndIdx = 2;21152116var NUMBER_OF_RESERVED_SLOTS = 3;2117var SIZE_OF_RESERVED_SLOTS = 12; // NUMBER_OF_RESERVED_SLOTS21182119// Reserved slot methods and accessors.21202121function getIdx() {2122return HEAPU32[(slotIdx << 2) >> 2]|0;2123}21242125function setIdx(val) {2126val = val|0;2127HEAPU32[(slotIdx << 2) >> 2] = val;2128return;2129}21302131function incIdx() {2132var idx = 0;2133var newIdx = 0;2134idx = getIdx()|0;2135newIdx = (idx + 1)|0;2136setIdx(newIdx);2137return;2138}21392140function getEndIdx() {2141return HEAPU32[(slotEndIdx << 2) >> 2]|0;2142}21432144function setEndIdx(val) {2145val = val|0;2146HEAPU32[(slotEndIdx << 2) >> 2] = val;2147return;2148}21492150function getVlq() {2151return HEAP32[(slotVlq << 2) >> 2]|0;2152}21532154function setVlq(val) {2155val = val|0;2156HEAP32[(slotVlq << 2) >> 2] = val;2157return;2158}21592160// Decode a base 64 value. char -> int. Returns -1 on failure.2161function decodeBase64(ch) {2162ch = ch|0;21632164var bigA = 65; // 'A'2165var bigZ = 90; // 'Z'21662167var littleA = 97; // 'a'2168var littleZ = 122; // 'z'21692170var zero = 48; // '0'2171var nine = 57; // '9'21722173var plus = 43; // '+'2174var slash = 47; // '/'21752176// 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ2177if ((bigA|0) <= (ch|0)) if ((ch|0) <= (bigZ|0)) {2178return (ch - bigA)|0;2179}21802181// 26 - 51: abcdefghijklmnopqrstuvwxyz2182if ((littleA|0) <= (ch|0)) if ((ch|0) <= (littleZ|0)) {2183return (ch - littleA + 26)|0;2184}21852186// 52 - 61: 01234567892187if ((zero|0) <= (ch|0)) if ((ch|0) <= (nine|0)) {2188return (ch - zero + 52)|0;2189}21902191// 62: +2192if ((ch|0) == (plus|0)) {2193return 62;2194}21952196// 63: /2197if ((ch|0) == (slash|0)) {2198return 63;2199}22002201// Invalid base64 string.2202return -1;2203}22042205function fromVLQSigned(value) {2206value = value|0;2207var isNegative = 0;2208var shifted = 0;22092210isNegative = (value & 1) == 1;2211shifted = value >> 1;2212if ((isNegative|0) == 1) {2213return (-shifted)|0;2214}22152216return shifted|0;2217}22182219// Returns 1 on success, 0 on failure. On success, result is stored in the2220// vlq reserved slot.2221function decodeVLQ() {2222var result = 0;2223var shift = 0;2224var shifted = 0;2225var digit = 0;2226var continuation = 0;22272228var idx = 0;2229var endIdx = 0;22302231endIdx = getEndIdx()|0;22322233do {2234idx = getIdx()|0;2235if ((idx|0) >= (endIdx|0)) {2236return 0;2237}22382239digit = decodeBase64(getCharacterAtIdx()|0)|0;2240if ((digit|0) < 0) {2241return 0;2242}2243incIdx();22442245continuation = digit & VLQ_CONTINUATION_BIT;2246digit = digit & VLQ_BASE_MASK;2247shifted = digit << shift;2248result = (result + shifted)|0;2249} while ((continuation|0) != 0);22502251result = fromVLQSigned(result)|0;2252setVlq(result);2253return 1;2254}22552256// Get the character at the current index.2257function getCharacterAtIdx() {2258var idx = 0;2259idx = getIdx()|0;2260return HEAPU8[idx >> 0]|0;2261}22622263// Return 1 if there is a mapping separator character at the current index,2264// otherwise 0.2265function isSeperatorAtIdx() {2266var ch = 0;2267var idx = 0;2268var endIdx = 0;22692270idx = getIdx()|0;2271endIdx = getEndIdx()|0;22722273if ((idx|0) >= (endIdx|0)) {2274return 1;2275}22762277ch = getCharacterAtIdx()|0;22782279if ((ch|0) == (comma|0)) {2280return 1;2281}22822283if ((ch|0) == (semicolon|0)) {2284return 1;2285}22862287return 0;2288}22892290// Returns 1 on success, 0 on failure.2291function parse() {2292var generatedLine = 1;2293var generatedColumn = 0;2294var originalLine = 0;2295var originalColumn = 0;2296var source = 0;2297var name = 0;22982299var ch = 0;2300var idx = 0;2301var endIdx = 0;2302var result = 0;2303var vlq = 0;23042305log(1,1,1,1,1,1,1,1,1);23062307// Skip past the reserved slots to the data.2308setIdx(SIZE_OF_RESERVED_SLOTS|0);23092310// Initialize the end index.2311endIdx = getEndOfString()|0;2312setEndIdx(endIdx|0);23132314log(getIdx()|0, endIdx|0);23152316while ((getIdx()|0) < (endIdx|0)) {2317ch = getCharacterAtIdx()|0;23182319log(ch|0, getIdx()|0, endIdx|0);23202321if ((ch|0) == (semicolon|0)) {2322generatedLine = (generatedLine + 1)|0;2323incIdx();2324generatedColumn = 0;2325continue;2326}23272328if ((ch|0) == (comma|0)) {2329incIdx();2330continue;2331}23322333// Generated column.2334result = decodeVLQ()|0;2335if ((result|0) == 0) {2336return 0;2337}2338vlq = getVlq()|0;2339generatedColumn = (generatedColumn + vlq)|0;2340result = isSeperatorAtIdx()|0;2341if ((result|0) == 1) {2342eachMapping(2, generatedLine|0, generatedColumn|0, -1, -1, -1, -1);2343continue;2344}23452346// Original source.2347result = decodeVLQ()|0;2348if ((result|0) == 0) {2349return 0;2350}2351vlq = getVlq()|0;2352source = (source + vlq)|0;2353result = isSeperatorAtIdx()|0;2354if ((result|0) == 1) {2355return 0;2356}23572358// Original line.2359result = decodeVLQ()|0;2360if ((result|0) == 0) {2361return 0;2362}2363vlq = getVlq()|0;2364originalLine = (originalLine + vlq)|0;2365result = isSeperatorAtIdx()|0;2366if ((result|0) == 1) {2367return 0;2368}23692370// Original column.2371result = decodeVLQ()|0;2372if ((result|0) == 0) {2373return 0;2374}2375vlq = getVlq()|0;2376originalColumn = (originalColumn + vlq)|0;2377result = isSeperatorAtIdx()|0;2378if ((result|0) == 1) {2379eachMapping(5, generatedLine|0, generatedColumn|0, source|0, originalLine|0,2380originalColumn|0, -1);2381continue;2382}23832384// Name.2385result = decodeVLQ()|0;2386if ((result|0) == 0) {2387return 0;2388}2389vlq = getVlq()|0;2390name = (name + vlq)|0;2391eachMapping(6, generatedLine|0, generatedColumn|0, source|0, originalLine|0,2392originalColumn|0, name|0);23932394// Eat away any garbage at the end of this mapping.2395result = isSeperatorAtIdx()|0;2396while ((result|0) == 0) {2397incIdx();2398result = isSeperatorAtIdx()|0;2399}2400}24012402return 1;2403}24042405return { parse: parse };2406};24072408var NUMBER_OF_RESERVED_SLOTS = 3;24092410exports.parseMappings = function (mappings, sourceRoot) {2411function eachMapping(segmentsParsed, generatedLine, generatedColumn,2412sourceIdx, originalLine, originalColumn, nameIdx) {2413console.log("eachMapping", ([].slice.call(arguments)));24142415var mapping = {};2416this.__generatedMappings.push(mapping);24172418mapping.generatedColumn = generatedColumn;2419mapping.generatedLine24202421if (segmentsParsed >= 5) {2422this.__originalMappings.push(mapping);24232424// try {2425// mapping.source = this._sources.at(sourceIdx);2426// } catch (e) {2427// // TODO2428// }2429mapping.originalLine = originalLine;2430mapping.originalColumn = originalColumn;24312432if (segmentsParsed >= 6 && this._names.has()) {2433// try {2434// mapping.name = this._names.at(nameIdx);2435// } catch (e) {2436// // TODO2437// }2438}2439}2440}24412442var array = stringToArray(mappings, NUMBER_OF_RESERVED_SLOTS);2443var result = AsmParse(typeof window !== "undefined" ? window : global,2444{2445eachMapping: eachMapping.bind(this),2446log: console.log.bind(console),2447getEndOfString: function () {2448return mappings.length + NUMBER_OF_RESERVED_SLOTS * 4;2449}2450},2451array.buffer)2452.parse();2453if (!result) {2454throw new Error("Error parsing source map's mappings");2455}24562457this.__generatedMappings.sort(util.compareByGeneratedPositions);2458this.__originalMappings.sort(util.compareByOriginalPositions);2459};24602461});2462/* -*- Mode: js; js-indent-level: 2; -*- */2463/*2464* Copyright 2011 Mozilla Foundation and contributors2465* Licensed under the New BSD license. See LICENSE or:2466* http://opensource.org/licenses/BSD-3-Clause2467*/2468define('source-map/binary-search', ['require', 'exports', 'module' , ], function(require, exports, module) {2469/**2470* Recursive implementation of binary search.2471*2472* @param aLow Indices here and lower do not contain the needle.2473* @param aHigh Indices here and higher do not contain the needle.2474* @param aNeedle The element being searched for.2475* @param aHaystack The non-empty array being searched.2476* @param aCompare Function which takes two elements and returns -1, 0, or 1.2477* @param aBias Either 'binarySearch.LEAST_UPPER_BOUND' or2478* 'binarySearch.GREATEST_LOWER_BOUND'. Specifies whether to return the2479* closest element that is smaller than or greater than the element we are2480* searching for if the exact element cannot be found.2481*/2482function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {2483// This function terminates when one of the following is true:2484//2485// 1. We find the exact element we are looking for.2486//2487// 2. We did not find the exact element, but we can return the index of2488// the next closest element.2489//2490// 3. We did not find the exact element, and there is no next-closest2491// element than the one we are searching for, so we return -1.2492var mid = Math.floor((aHigh - aLow) / 2) + aLow;2493var cmp = aCompare(aNeedle, aHaystack[mid], true);2494if (cmp === 0) {2495// Found the element we are looking for.2496return mid;2497}2498else if (cmp > 0) {2499// Our needle is greater than aHaystack[mid].2500if (aHigh - mid > 1) {2501// The element is in the upper half.2502return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);2503}2504// The exact needle element was not found in this haystack. Determine if2505// we are in termination case (3) or (2) and return the appropriate thing.2506if (aBias == exports.LEAST_UPPER_BOUND) {2507return aHigh < aHaystack.length ? aHigh : -1;2508} else {2509return mid;2510}2511}2512else {2513// Our needle is less than aHaystack[mid].2514if (mid - aLow > 1) {2515// The element is in the lower half.2516return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);2517}2518// The exact needle element was not found in this haystack. Determine if2519// we are in termination case (3) or (2) and return the appropriate thing.2520if (aBias == exports.LEAST_UPPER_BOUND) {2521return mid;2522} else {2523return aLow < 0 ? -1 : aLow;2524}2525}2526}25272528exports.LEAST_UPPER_BOUND = 1;2529exports.GREATEST_LOWER_BOUND = 2;25302531/**2532* This is an implementation of binary search which will always try and return2533* the index of next highest value checked if there is no exact hit. This is2534* because mappings between original and generated line/col pairs are single2535* points, and there is an implicit region between each of them, so a miss2536* just means that you aren't on the very start of a region.2537*2538* @param aNeedle The element you are looking for.2539* @param aHaystack The array that is being searched.2540* @param aCompare A function which takes the needle and an element in the2541* array and returns -1, 0, or 1 depending on whether the needle is less2542* than, equal to, or greater than the element, respectively.2543* @param aBias Either 'exports.LEAST_UPPER_BOUND' or2544* 'exports.GREATEST_LOWER_BOUND'. Specifies whether to return the2545* closest element that is smaller than or greater than the element we are2546* searching for if the exact element cannot be found. Defaults to2547* 'exports.LEAST_UPPER_BOUND'.2548*/2549exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {2550var aBias = aBias || exports.LEAST_UPPER_BOUND;25512552if (aHaystack.length === 0) {2553return -1;2554}2555return recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare, aBias)2556};25572558});2559/* -*- Mode: js; js-indent-level: 2; -*- */2560/*2561* Copyright 2011 Mozilla Foundation and contributors2562* Licensed under the New BSD license. See LICENSE or:2563* http://opensource.org/licenses/BSD-3-Clause2564*/2565define('source-map/source-node', ['require', 'exports', 'module' , 'source-map/source-map-generator', 'source-map/util'], function(require, exports, module) {25662567var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;2568var util = require('./util');25692570// Matches a Windows-style `\r\n` newline or a `\n` newline used by all other2571// operating systems these days (capturing the result).2572var REGEX_NEWLINE = /(\r?\n)/;25732574// Newline character code for charCodeAt() comparisons2575var NEWLINE_CODE = 10;25762577// Private symbol for identifying `SourceNode`s when multiple versions of2578// the source-map library are loaded. This MUST NOT CHANGE across2579// versions!2580var isSourceNode = "$$$isSourceNode$$$";25812582/**2583* SourceNodes provide a way to abstract over interpolating/concatenating2584* snippets of generated JavaScript source code while maintaining the line and2585* column information associated with the original source code.2586*2587* @param aLine The original line number.2588* @param aColumn The original column number.2589* @param aSource The original source's filename.2590* @param aChunks Optional. An array of strings which are snippets of2591* generated JS, or other SourceNodes.2592* @param aName The original identifier.2593*/2594function SourceNode(aLine, aColumn, aSource, aChunks, aName) {2595this.children = [];2596this.sourceContents = {};2597this.line = aLine == null ? null : aLine;2598this.column = aColumn == null ? null : aColumn;2599this.source = aSource == null ? null : aSource;2600this.name = aName == null ? null : aName;2601this[isSourceNode] = true;2602if (aChunks != null) this.add(aChunks);2603}26042605/**2606* Creates a SourceNode from generated code and a SourceMapConsumer.2607*2608* @param aGeneratedCode The generated code2609* @param aSourceMapConsumer The SourceMap for the generated code2610* @param aRelativePath Optional. The path that relative sources in the2611* SourceMapConsumer should be relative to.2612*/2613SourceNode.fromStringWithSourceMap =2614function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {2615// The SourceNode we want to fill with the generated code2616// and the SourceMap2617var node = new SourceNode();26182619// All even indices of this array are one line of the generated code,2620// while all odd indices are the newlines between two adjacent lines2621// (since `REGEX_NEWLINE` captures its match).2622// Processed fragments are removed from this array, by calling `shiftNextLine`.2623var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);2624var shiftNextLine = function() {2625var lineContents = remainingLines.shift();2626// The last line of a file might not have a newline.2627var newLine = remainingLines.shift() || "";2628return lineContents + newLine;2629};26302631// We need to remember the position of "remainingLines"2632var lastGeneratedLine = 1, lastGeneratedColumn = 0;26332634// The generate SourceNodes we need a code range.2635// To extract it current and last mapping is used.2636// Here we store the last mapping.2637var lastMapping = null;26382639aSourceMapConsumer.eachMapping(function (mapping) {2640if (lastMapping !== null) {2641// We add the code from "lastMapping" to "mapping":2642// First check if there is a new line in between.2643if (lastGeneratedLine < mapping.generatedLine) {2644var code = "";2645// Associate first line with "lastMapping"2646addMappingWithCode(lastMapping, shiftNextLine());2647lastGeneratedLine++;2648lastGeneratedColumn = 0;2649// The remaining code is added without mapping2650} else {2651// There is no new line in between.2652// Associate the code between "lastGeneratedColumn" and2653// "mapping.generatedColumn" with "lastMapping"2654var nextLine = remainingLines[0];2655var code = nextLine.substr(0, mapping.generatedColumn -2656lastGeneratedColumn);2657remainingLines[0] = nextLine.substr(mapping.generatedColumn -2658lastGeneratedColumn);2659lastGeneratedColumn = mapping.generatedColumn;2660addMappingWithCode(lastMapping, code);2661// No more remaining code, continue2662lastMapping = mapping;2663return;2664}2665}2666// We add the generated code until the first mapping2667// to the SourceNode without any mapping.2668// Each line is added as separate string.2669while (lastGeneratedLine < mapping.generatedLine) {2670node.add(shiftNextLine());2671lastGeneratedLine++;2672}2673if (lastGeneratedColumn < mapping.generatedColumn) {2674var nextLine = remainingLines[0];2675node.add(nextLine.substr(0, mapping.generatedColumn));2676remainingLines[0] = nextLine.substr(mapping.generatedColumn);2677lastGeneratedColumn = mapping.generatedColumn;2678}2679lastMapping = mapping;2680}, this);2681// We have processed all mappings.2682if (remainingLines.length > 0) {2683if (lastMapping) {2684// Associate the remaining code in the current line with "lastMapping"2685addMappingWithCode(lastMapping, shiftNextLine());2686}2687// and add the remaining lines without any mapping2688node.add(remainingLines.join(""));2689}26902691// Copy sourcesContent into SourceNode2692aSourceMapConsumer.sources.forEach(function (sourceFile) {2693var content = aSourceMapConsumer.sourceContentFor(sourceFile);2694if (content != null) {2695if (aRelativePath != null) {2696sourceFile = util.join(aRelativePath, sourceFile);2697}2698node.setSourceContent(sourceFile, content);2699}2700});27012702return node;27032704function addMappingWithCode(mapping, code) {2705if (mapping === null || mapping.source === undefined) {2706node.add(code);2707} else {2708var source = aRelativePath2709? util.join(aRelativePath, mapping.source)2710: mapping.source;2711node.add(new SourceNode(mapping.originalLine,2712mapping.originalColumn,2713source,2714code,2715mapping.name));2716}2717}2718};27192720/**2721* Add a chunk of generated JS to this source node.2722*2723* @param aChunk A string snippet of generated JS code, another instance of2724* SourceNode, or an array where each member is one of those things.2725*/2726SourceNode.prototype.add = function SourceNode_add(aChunk) {2727if (Array.isArray(aChunk)) {2728aChunk.forEach(function (chunk) {2729this.add(chunk);2730}, this);2731}2732else if (aChunk[isSourceNode] || typeof aChunk === "string") {2733if (aChunk) {2734this.children.push(aChunk);2735}2736}2737else {2738throw new TypeError(2739"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk2740);2741}2742return this;2743};27442745/**2746* Add a chunk of generated JS to the beginning of this source node.2747*2748* @param aChunk A string snippet of generated JS code, another instance of2749* SourceNode, or an array where each member is one of those things.2750*/2751SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {2752if (Array.isArray(aChunk)) {2753for (var i = aChunk.length-1; i >= 0; i--) {2754this.prepend(aChunk[i]);2755}2756}2757else if (aChunk[isSourceNode] || typeof aChunk === "string") {2758this.children.unshift(aChunk);2759}2760else {2761throw new TypeError(2762"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk2763);2764}2765return this;2766};27672768/**2769* Walk over the tree of JS snippets in this node and its children. The2770* walking function is called once for each snippet of JS and is passed that2771* snippet and the its original associated source's line/column location.2772*2773* @param aFn The traversal function.2774*/2775SourceNode.prototype.walk = function SourceNode_walk(aFn) {2776var chunk;2777for (var i = 0, len = this.children.length; i < len; i++) {2778chunk = this.children[i];2779if (chunk[isSourceNode]) {2780chunk.walk(aFn);2781}2782else {2783if (chunk !== '') {2784aFn(chunk, { source: this.source,2785line: this.line,2786column: this.column,2787name: this.name });2788}2789}2790}2791};27922793/**2794* Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between2795* each of `this.children`.2796*2797* @param aSep The separator.2798*/2799SourceNode.prototype.join = function SourceNode_join(aSep) {2800var newChildren;2801var i;2802var len = this.children.length;2803if (len > 0) {2804newChildren = [];2805for (i = 0; i < len-1; i++) {2806newChildren.push(this.children[i]);2807newChildren.push(aSep);2808}2809newChildren.push(this.children[i]);2810this.children = newChildren;2811}2812return this;2813};28142815/**2816* Call String.prototype.replace on the very right-most source snippet. Useful2817* for trimming whitespace from the end of a source node, etc.2818*2819* @param aPattern The pattern to replace.2820* @param aReplacement The thing to replace the pattern with.2821*/2822SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {2823var lastChild = this.children[this.children.length - 1];2824if (lastChild[isSourceNode]) {2825lastChild.replaceRight(aPattern, aReplacement);2826}2827else if (typeof lastChild === 'string') {2828this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);2829}2830else {2831this.children.push(''.replace(aPattern, aReplacement));2832}2833return this;2834};28352836/**2837* Set the source content for a source file. This will be added to the SourceMapGenerator2838* in the sourcesContent field.2839*2840* @param aSourceFile The filename of the source file2841* @param aSourceContent The content of the source file2842*/2843SourceNode.prototype.setSourceContent =2844function SourceNode_setSourceContent(aSourceFile, aSourceContent) {2845this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;2846};28472848/**2849* Walk over the tree of SourceNodes. The walking function is called for each2850* source file content and is passed the filename and source content.2851*2852* @param aFn The traversal function.2853*/2854SourceNode.prototype.walkSourceContents =2855function SourceNode_walkSourceContents(aFn) {2856for (var i = 0, len = this.children.length; i < len; i++) {2857if (this.children[i][isSourceNode]) {2858this.children[i].walkSourceContents(aFn);2859}2860}28612862var sources = Object.keys(this.sourceContents);2863for (var i = 0, len = sources.length; i < len; i++) {2864aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);2865}2866};28672868/**2869* Return the string representation of this source node. Walks over the tree2870* and concatenates all the various snippets together to one string.2871*/2872SourceNode.prototype.toString = function SourceNode_toString() {2873var str = "";2874this.walk(function (chunk) {2875str += chunk;2876});2877return str;2878};28792880/**2881* Returns the string representation of this source node along with a source2882* map.2883*/2884SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {2885var generated = {2886code: "",2887line: 1,2888column: 02889};2890var map = new SourceMapGenerator(aArgs);2891var sourceMappingActive = false;2892var lastOriginalSource = null;2893var lastOriginalLine = null;2894var lastOriginalColumn = null;2895var lastOriginalName = null;2896this.walk(function (chunk, original) {2897generated.code += chunk;2898if (original.source !== null2899&& original.line !== null2900&& original.column !== null) {2901if(lastOriginalSource !== original.source2902|| lastOriginalLine !== original.line2903|| lastOriginalColumn !== original.column2904|| lastOriginalName !== original.name) {2905map.addMapping({2906source: original.source,2907original: {2908line: original.line,2909column: original.column2910},2911generated: {2912line: generated.line,2913column: generated.column2914},2915name: original.name2916});2917}2918lastOriginalSource = original.source;2919lastOriginalLine = original.line;2920lastOriginalColumn = original.column;2921lastOriginalName = original.name;2922sourceMappingActive = true;2923} else if (sourceMappingActive) {2924map.addMapping({2925generated: {2926line: generated.line,2927column: generated.column2928}2929});2930lastOriginalSource = null;2931sourceMappingActive = false;2932}2933for (var idx = 0, length = chunk.length; idx < length; idx++) {2934if (chunk.charCodeAt(idx) === NEWLINE_CODE) {2935generated.line++;2936generated.column = 0;2937// Mappings end at eol2938if (idx + 1 === length) {2939lastOriginalSource = null;2940sourceMappingActive = false;2941} else if (sourceMappingActive) {2942map.addMapping({2943source: original.source,2944original: {2945line: original.line,2946column: original.column2947},2948generated: {2949line: generated.line,2950column: generated.column2951},2952name: original.name2953});2954}2955} else {2956generated.column++;2957}2958}2959});2960this.walkSourceContents(function (sourceFile, sourceContent) {2961map.setSourceContent(sourceFile, sourceContent);2962});29632964return { code: generated.code, map: map };2965};29662967exports.SourceNode = SourceNode;29682969});2970/* -*- Mode: js; js-indent-level: 2; -*- */2971///////////////////////////////////////////////////////////////////////////////29722973this.sourceMap = {2974SourceMapConsumer: require('source-map/source-map-consumer').SourceMapConsumer,2975SourceMapGenerator: require('source-map/source-map-generator').SourceMapGenerator,2976SourceNode: require('source-map/source-node').SourceNode2977};297829792980