UNPKG

127 kBJavaScriptView Raw
1module.exports =
2/******/ (function(modules, runtime) { // webpackBootstrap
3/******/ "use strict";
4/******/ // The module cache
5/******/ var installedModules = {};
6/******/
7/******/ // The require function
8/******/ function __webpack_require__(moduleId) {
9/******/
10/******/ // Check if module is in cache
11/******/ if(installedModules[moduleId]) {
12/******/ return installedModules[moduleId].exports;
13/******/ }
14/******/ // Create a new module (and put it into the cache)
15/******/ var module = installedModules[moduleId] = {
16/******/ i: moduleId,
17/******/ l: false,
18/******/ exports: {}
19/******/ };
20/******/
21/******/ // Execute the module function
22/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
23/******/
24/******/ // Flag the module as loaded
25/******/ module.l = true;
26/******/
27/******/ // Return the exports of the module
28/******/ return module.exports;
29/******/ }
30/******/
31/******/
32/******/ __webpack_require__.ab = __dirname + "/";
33/******/
34/******/ // the startup function
35/******/ function startup() {
36/******/ // Load entry module and return exports
37/******/ return __webpack_require__(219);
38/******/ };
39/******/ // initialize runtime
40/******/ runtime(__webpack_require__);
41/******/
42/******/ // run startup
43/******/ return startup();
44/******/ })
45/************************************************************************/
46/******/ ({
47
48/***/ 46:
49/***/ (function(__unusedmodule, exports, __webpack_require__) {
50
51/* -*- Mode: js; js-indent-level: 2; -*- */
52/*
53 * Copyright 2011 Mozilla Foundation and contributors
54 * Licensed under the New BSD license. See LICENSE or:
55 * http://opensource.org/licenses/BSD-3-Clause
56 */
57
58var util = __webpack_require__(567);
59var has = Object.prototype.hasOwnProperty;
60var hasNativeMap = typeof Map !== "undefined";
61
62/**
63 * A data structure which is a combination of an array and a set. Adding a new
64 * member is O(1), testing for membership is O(1), and finding the index of an
65 * element is O(1). Removing elements from the set is not supported. Only
66 * strings are supported for membership.
67 */
68function ArraySet() {
69 this._array = [];
70 this._set = hasNativeMap ? new Map() : Object.create(null);
71}
72
73/**
74 * Static method for creating ArraySet instances from an existing array.
75 */
76ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
77 var set = new ArraySet();
78 for (var i = 0, len = aArray.length; i < len; i++) {
79 set.add(aArray[i], aAllowDuplicates);
80 }
81 return set;
82};
83
84/**
85 * Return how many unique items are in this ArraySet. If duplicates have been
86 * added, than those do not count towards the size.
87 *
88 * @returns Number
89 */
90ArraySet.prototype.size = function ArraySet_size() {
91 return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
92};
93
94/**
95 * Add the given string to this set.
96 *
97 * @param String aStr
98 */
99ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
100 var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
101 var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
102 var idx = this._array.length;
103 if (!isDuplicate || aAllowDuplicates) {
104 this._array.push(aStr);
105 }
106 if (!isDuplicate) {
107 if (hasNativeMap) {
108 this._set.set(aStr, idx);
109 } else {
110 this._set[sStr] = idx;
111 }
112 }
113};
114
115/**
116 * Is the given string a member of this set?
117 *
118 * @param String aStr
119 */
120ArraySet.prototype.has = function ArraySet_has(aStr) {
121 if (hasNativeMap) {
122 return this._set.has(aStr);
123 } else {
124 var sStr = util.toSetString(aStr);
125 return has.call(this._set, sStr);
126 }
127};
128
129/**
130 * What is the index of the given string in the array?
131 *
132 * @param String aStr
133 */
134ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
135 if (hasNativeMap) {
136 var idx = this._set.get(aStr);
137 if (idx >= 0) {
138 return idx;
139 }
140 } else {
141 var sStr = util.toSetString(aStr);
142 if (has.call(this._set, sStr)) {
143 return this._set[sStr];
144 }
145 }
146
147 throw new Error('"' + aStr + '" is not in the set.');
148};
149
150/**
151 * What is the element at the given index?
152 *
153 * @param Number aIdx
154 */
155ArraySet.prototype.at = function ArraySet_at(aIdx) {
156 if (aIdx >= 0 && aIdx < this._array.length) {
157 return this._array[aIdx];
158 }
159 throw new Error('No element indexed by ' + aIdx);
160};
161
162/**
163 * Returns the array representation of this set (which has the proper indices
164 * indicated by indexOf). Note that this is a copy of the internal array used
165 * for storing the members so that no one can mess with internal state.
166 */
167ArraySet.prototype.toArray = function ArraySet_toArray() {
168 return this._array.slice();
169};
170
171exports.ArraySet = ArraySet;
172
173
174/***/ }),
175
176/***/ 116:
177/***/ (function(__unusedmodule, exports, __webpack_require__) {
178
179/* -*- Mode: js; js-indent-level: 2; -*- */
180/*
181 * Copyright 2011 Mozilla Foundation and contributors
182 * Licensed under the New BSD license. See LICENSE or:
183 * http://opensource.org/licenses/BSD-3-Clause
184 */
185
186var base64VLQ = __webpack_require__(668);
187var util = __webpack_require__(567);
188var ArraySet = __webpack_require__(46).ArraySet;
189var MappingList = __webpack_require__(245).MappingList;
190
191/**
192 * An instance of the SourceMapGenerator represents a source map which is
193 * being built incrementally. You may pass an object with the following
194 * properties:
195 *
196 * - file: The filename of the generated source.
197 * - sourceRoot: A root for all relative URLs in this source map.
198 */
199function SourceMapGenerator(aArgs) {
200 if (!aArgs) {
201 aArgs = {};
202 }
203 this._file = util.getArg(aArgs, 'file', null);
204 this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
205 this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
206 this._sources = new ArraySet();
207 this._names = new ArraySet();
208 this._mappings = new MappingList();
209 this._sourcesContents = null;
210}
211
212SourceMapGenerator.prototype._version = 3;
213
214/**
215 * Creates a new SourceMapGenerator based on a SourceMapConsumer
216 *
217 * @param aSourceMapConsumer The SourceMap.
218 */
219SourceMapGenerator.fromSourceMap =
220 function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
221 var sourceRoot = aSourceMapConsumer.sourceRoot;
222 var generator = new SourceMapGenerator({
223 file: aSourceMapConsumer.file,
224 sourceRoot: sourceRoot
225 });
226 aSourceMapConsumer.eachMapping(function (mapping) {
227 var newMapping = {
228 generated: {
229 line: mapping.generatedLine,
230 column: mapping.generatedColumn
231 }
232 };
233
234 if (mapping.source != null) {
235 newMapping.source = mapping.source;
236 if (sourceRoot != null) {
237 newMapping.source = util.relative(sourceRoot, newMapping.source);
238 }
239
240 newMapping.original = {
241 line: mapping.originalLine,
242 column: mapping.originalColumn
243 };
244
245 if (mapping.name != null) {
246 newMapping.name = mapping.name;
247 }
248 }
249
250 generator.addMapping(newMapping);
251 });
252 aSourceMapConsumer.sources.forEach(function (sourceFile) {
253 var sourceRelative = sourceFile;
254 if (sourceRoot !== null) {
255 sourceRelative = util.relative(sourceRoot, sourceFile);
256 }
257
258 if (!generator._sources.has(sourceRelative)) {
259 generator._sources.add(sourceRelative);
260 }
261
262 var content = aSourceMapConsumer.sourceContentFor(sourceFile);
263 if (content != null) {
264 generator.setSourceContent(sourceFile, content);
265 }
266 });
267 return generator;
268 };
269
270/**
271 * Add a single mapping from original source line and column to the generated
272 * source's line and column for this source map being created. The mapping
273 * object should have the following properties:
274 *
275 * - generated: An object with the generated line and column positions.
276 * - original: An object with the original line and column positions.
277 * - source: The original source file (relative to the sourceRoot).
278 * - name: An optional original token name for this mapping.
279 */
280SourceMapGenerator.prototype.addMapping =
281 function SourceMapGenerator_addMapping(aArgs) {
282 var generated = util.getArg(aArgs, 'generated');
283 var original = util.getArg(aArgs, 'original', null);
284 var source = util.getArg(aArgs, 'source', null);
285 var name = util.getArg(aArgs, 'name', null);
286
287 if (!this._skipValidation) {
288 this._validateMapping(generated, original, source, name);
289 }
290
291 if (source != null) {
292 source = String(source);
293 if (!this._sources.has(source)) {
294 this._sources.add(source);
295 }
296 }
297
298 if (name != null) {
299 name = String(name);
300 if (!this._names.has(name)) {
301 this._names.add(name);
302 }
303 }
304
305 this._mappings.add({
306 generatedLine: generated.line,
307 generatedColumn: generated.column,
308 originalLine: original != null && original.line,
309 originalColumn: original != null && original.column,
310 source: source,
311 name: name
312 });
313 };
314
315/**
316 * Set the source content for a source file.
317 */
318SourceMapGenerator.prototype.setSourceContent =
319 function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
320 var source = aSourceFile;
321 if (this._sourceRoot != null) {
322 source = util.relative(this._sourceRoot, source);
323 }
324
325 if (aSourceContent != null) {
326 // Add the source content to the _sourcesContents map.
327 // Create a new _sourcesContents map if the property is null.
328 if (!this._sourcesContents) {
329 this._sourcesContents = Object.create(null);
330 }
331 this._sourcesContents[util.toSetString(source)] = aSourceContent;
332 } else if (this._sourcesContents) {
333 // Remove the source file from the _sourcesContents map.
334 // If the _sourcesContents map is empty, set the property to null.
335 delete this._sourcesContents[util.toSetString(source)];
336 if (Object.keys(this._sourcesContents).length === 0) {
337 this._sourcesContents = null;
338 }
339 }
340 };
341
342/**
343 * Applies the mappings of a sub-source-map for a specific source file to the
344 * source map being generated. Each mapping to the supplied source file is
345 * rewritten using the supplied source map. Note: The resolution for the
346 * resulting mappings is the minimium of this map and the supplied map.
347 *
348 * @param aSourceMapConsumer The source map to be applied.
349 * @param aSourceFile Optional. The filename of the source file.
350 * If omitted, SourceMapConsumer's file property will be used.
351 * @param aSourceMapPath Optional. The dirname of the path to the source map
352 * to be applied. If relative, it is relative to the SourceMapConsumer.
353 * This parameter is needed when the two source maps aren't in the same
354 * directory, and the source map to be applied contains relative source
355 * paths. If so, those relative source paths need to be rewritten
356 * relative to the SourceMapGenerator.
357 */
358SourceMapGenerator.prototype.applySourceMap =
359 function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
360 var sourceFile = aSourceFile;
361 // If aSourceFile is omitted, we will use the file property of the SourceMap
362 if (aSourceFile == null) {
363 if (aSourceMapConsumer.file == null) {
364 throw new Error(
365 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
366 'or the source map\'s "file" property. Both were omitted.'
367 );
368 }
369 sourceFile = aSourceMapConsumer.file;
370 }
371 var sourceRoot = this._sourceRoot;
372 // Make "sourceFile" relative if an absolute Url is passed.
373 if (sourceRoot != null) {
374 sourceFile = util.relative(sourceRoot, sourceFile);
375 }
376 // Applying the SourceMap can add and remove items from the sources and
377 // the names array.
378 var newSources = new ArraySet();
379 var newNames = new ArraySet();
380
381 // Find mappings for the "sourceFile"
382 this._mappings.unsortedForEach(function (mapping) {
383 if (mapping.source === sourceFile && mapping.originalLine != null) {
384 // Check if it can be mapped by the source map, then update the mapping.
385 var original = aSourceMapConsumer.originalPositionFor({
386 line: mapping.originalLine,
387 column: mapping.originalColumn
388 });
389 if (original.source != null) {
390 // Copy mapping
391 mapping.source = original.source;
392 if (aSourceMapPath != null) {
393 mapping.source = util.join(aSourceMapPath, mapping.source)
394 }
395 if (sourceRoot != null) {
396 mapping.source = util.relative(sourceRoot, mapping.source);
397 }
398 mapping.originalLine = original.line;
399 mapping.originalColumn = original.column;
400 if (original.name != null) {
401 mapping.name = original.name;
402 }
403 }
404 }
405
406 var source = mapping.source;
407 if (source != null && !newSources.has(source)) {
408 newSources.add(source);
409 }
410
411 var name = mapping.name;
412 if (name != null && !newNames.has(name)) {
413 newNames.add(name);
414 }
415
416 }, this);
417 this._sources = newSources;
418 this._names = newNames;
419
420 // Copy sourcesContents of applied map.
421 aSourceMapConsumer.sources.forEach(function (sourceFile) {
422 var content = aSourceMapConsumer.sourceContentFor(sourceFile);
423 if (content != null) {
424 if (aSourceMapPath != null) {
425 sourceFile = util.join(aSourceMapPath, sourceFile);
426 }
427 if (sourceRoot != null) {
428 sourceFile = util.relative(sourceRoot, sourceFile);
429 }
430 this.setSourceContent(sourceFile, content);
431 }
432 }, this);
433 };
434
435/**
436 * A mapping can have one of the three levels of data:
437 *
438 * 1. Just the generated position.
439 * 2. The Generated position, original position, and original source.
440 * 3. Generated and original position, original source, as well as a name
441 * token.
442 *
443 * To maintain consistency, we validate that any new mapping being added falls
444 * in to one of these categories.
445 */
446SourceMapGenerator.prototype._validateMapping =
447 function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
448 aName) {
449 // When aOriginal is truthy but has empty values for .line and .column,
450 // it is most likely a programmer error. In this case we throw a very
451 // specific error message to try to guide them the right way.
452 // For example: https://github.com/Polymer/polymer-bundler/pull/519
453 if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
454 throw new Error(
455 'original.line and original.column are not numbers -- you probably meant to omit ' +
456 'the original mapping entirely and only map the generated position. If so, pass ' +
457 'null for the original mapping instead of an object with empty or null values.'
458 );
459 }
460
461 if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
462 && aGenerated.line > 0 && aGenerated.column >= 0
463 && !aOriginal && !aSource && !aName) {
464 // Case 1.
465 return;
466 }
467 else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
468 && aOriginal && 'line' in aOriginal && 'column' in aOriginal
469 && aGenerated.line > 0 && aGenerated.column >= 0
470 && aOriginal.line > 0 && aOriginal.column >= 0
471 && aSource) {
472 // Cases 2 and 3.
473 return;
474 }
475 else {
476 throw new Error('Invalid mapping: ' + JSON.stringify({
477 generated: aGenerated,
478 source: aSource,
479 original: aOriginal,
480 name: aName
481 }));
482 }
483 };
484
485/**
486 * Serialize the accumulated mappings in to the stream of base 64 VLQs
487 * specified by the source map format.
488 */
489SourceMapGenerator.prototype._serializeMappings =
490 function SourceMapGenerator_serializeMappings() {
491 var previousGeneratedColumn = 0;
492 var previousGeneratedLine = 1;
493 var previousOriginalColumn = 0;
494 var previousOriginalLine = 0;
495 var previousName = 0;
496 var previousSource = 0;
497 var result = '';
498 var next;
499 var mapping;
500 var nameIdx;
501 var sourceIdx;
502
503 var mappings = this._mappings.toArray();
504 for (var i = 0, len = mappings.length; i < len; i++) {
505 mapping = mappings[i];
506 next = ''
507
508 if (mapping.generatedLine !== previousGeneratedLine) {
509 previousGeneratedColumn = 0;
510 while (mapping.generatedLine !== previousGeneratedLine) {
511 next += ';';
512 previousGeneratedLine++;
513 }
514 }
515 else {
516 if (i > 0) {
517 if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
518 continue;
519 }
520 next += ',';
521 }
522 }
523
524 next += base64VLQ.encode(mapping.generatedColumn
525 - previousGeneratedColumn);
526 previousGeneratedColumn = mapping.generatedColumn;
527
528 if (mapping.source != null) {
529 sourceIdx = this._sources.indexOf(mapping.source);
530 next += base64VLQ.encode(sourceIdx - previousSource);
531 previousSource = sourceIdx;
532
533 // lines are stored 0-based in SourceMap spec version 3
534 next += base64VLQ.encode(mapping.originalLine - 1
535 - previousOriginalLine);
536 previousOriginalLine = mapping.originalLine - 1;
537
538 next += base64VLQ.encode(mapping.originalColumn
539 - previousOriginalColumn);
540 previousOriginalColumn = mapping.originalColumn;
541
542 if (mapping.name != null) {
543 nameIdx = this._names.indexOf(mapping.name);
544 next += base64VLQ.encode(nameIdx - previousName);
545 previousName = nameIdx;
546 }
547 }
548
549 result += next;
550 }
551
552 return result;
553 };
554
555SourceMapGenerator.prototype._generateSourcesContent =
556 function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
557 return aSources.map(function (source) {
558 if (!this._sourcesContents) {
559 return null;
560 }
561 if (aSourceRoot != null) {
562 source = util.relative(aSourceRoot, source);
563 }
564 var key = util.toSetString(source);
565 return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
566 ? this._sourcesContents[key]
567 : null;
568 }, this);
569 };
570
571/**
572 * Externalize the source map.
573 */
574SourceMapGenerator.prototype.toJSON =
575 function SourceMapGenerator_toJSON() {
576 var map = {
577 version: this._version,
578 sources: this._sources.toArray(),
579 names: this._names.toArray(),
580 mappings: this._serializeMappings()
581 };
582 if (this._file != null) {
583 map.file = this._file;
584 }
585 if (this._sourceRoot != null) {
586 map.sourceRoot = this._sourceRoot;
587 }
588 if (this._sourcesContents) {
589 map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
590 }
591
592 return map;
593 };
594
595/**
596 * Render the source map being generated to a string.
597 */
598SourceMapGenerator.prototype.toString =
599 function SourceMapGenerator_toString() {
600 return JSON.stringify(this.toJSON());
601 };
602
603exports.SourceMapGenerator = SourceMapGenerator;
604
605
606/***/ }),
607
608/***/ 168:
609/***/ (function(__unusedmodule, exports, __webpack_require__) {
610
611/*
612 * Copyright 2009-2011 Mozilla Foundation and contributors
613 * Licensed under the New BSD license. See LICENSE.txt or:
614 * http://opensource.org/licenses/BSD-3-Clause
615 */
616exports.SourceMapGenerator = __webpack_require__(116).SourceMapGenerator;
617exports.SourceMapConsumer = __webpack_require__(302).SourceMapConsumer;
618exports.SourceNode = __webpack_require__(872).SourceNode;
619
620
621/***/ }),
622
623/***/ 219:
624/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
625
626__webpack_require__(545).install();
627
628
629/***/ }),
630
631/***/ 245:
632/***/ (function(__unusedmodule, exports, __webpack_require__) {
633
634/* -*- Mode: js; js-indent-level: 2; -*- */
635/*
636 * Copyright 2014 Mozilla Foundation and contributors
637 * Licensed under the New BSD license. See LICENSE or:
638 * http://opensource.org/licenses/BSD-3-Clause
639 */
640
641var util = __webpack_require__(567);
642
643/**
644 * Determine whether mappingB is after mappingA with respect to generated
645 * position.
646 */
647function generatedPositionAfter(mappingA, mappingB) {
648 // Optimized for most common case
649 var lineA = mappingA.generatedLine;
650 var lineB = mappingB.generatedLine;
651 var columnA = mappingA.generatedColumn;
652 var columnB = mappingB.generatedColumn;
653 return lineB > lineA || lineB == lineA && columnB >= columnA ||
654 util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
655}
656
657/**
658 * A data structure to provide a sorted view of accumulated mappings in a
659 * performance conscious manner. It trades a neglibable overhead in general
660 * case for a large speedup in case of mappings being added in order.
661 */
662function MappingList() {
663 this._array = [];
664 this._sorted = true;
665 // Serves as infimum
666 this._last = {generatedLine: -1, generatedColumn: 0};
667}
668
669/**
670 * Iterate through internal items. This method takes the same arguments that
671 * `Array.prototype.forEach` takes.
672 *
673 * NOTE: The order of the mappings is NOT guaranteed.
674 */
675MappingList.prototype.unsortedForEach =
676 function MappingList_forEach(aCallback, aThisArg) {
677 this._array.forEach(aCallback, aThisArg);
678 };
679
680/**
681 * Add the given source mapping.
682 *
683 * @param Object aMapping
684 */
685MappingList.prototype.add = function MappingList_add(aMapping) {
686 if (generatedPositionAfter(this._last, aMapping)) {
687 this._last = aMapping;
688 this._array.push(aMapping);
689 } else {
690 this._sorted = false;
691 this._array.push(aMapping);
692 }
693};
694
695/**
696 * Returns the flat, sorted array of mappings. The mappings are sorted by
697 * generated position.
698 *
699 * WARNING: This method returns internal data without copying, for
700 * performance. The return value must NOT be mutated, and should be treated as
701 * an immutable borrow. If you want to take ownership, you must make your own
702 * copy.
703 */
704MappingList.prototype.toArray = function MappingList_toArray() {
705 if (!this._sorted) {
706 this._array.sort(util.compareByGeneratedPositionsInflated);
707 this._sorted = true;
708 }
709 return this._array;
710};
711
712exports.MappingList = MappingList;
713
714
715/***/ }),
716
717/***/ 285:
718/***/ (function(__unusedmodule, exports) {
719
720/* -*- Mode: js; js-indent-level: 2; -*- */
721/*
722 * Copyright 2011 Mozilla Foundation and contributors
723 * Licensed under the New BSD license. See LICENSE or:
724 * http://opensource.org/licenses/BSD-3-Clause
725 */
726
727exports.GREATEST_LOWER_BOUND = 1;
728exports.LEAST_UPPER_BOUND = 2;
729
730/**
731 * Recursive implementation of binary search.
732 *
733 * @param aLow Indices here and lower do not contain the needle.
734 * @param aHigh Indices here and higher do not contain the needle.
735 * @param aNeedle The element being searched for.
736 * @param aHaystack The non-empty array being searched.
737 * @param aCompare Function which takes two elements and returns -1, 0, or 1.
738 * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
739 * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
740 * closest element that is smaller than or greater than the one we are
741 * searching for, respectively, if the exact element cannot be found.
742 */
743function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
744 // This function terminates when one of the following is true:
745 //
746 // 1. We find the exact element we are looking for.
747 //
748 // 2. We did not find the exact element, but we can return the index of
749 // the next-closest element.
750 //
751 // 3. We did not find the exact element, and there is no next-closest
752 // element than the one we are searching for, so we return -1.
753 var mid = Math.floor((aHigh - aLow) / 2) + aLow;
754 var cmp = aCompare(aNeedle, aHaystack[mid], true);
755 if (cmp === 0) {
756 // Found the element we are looking for.
757 return mid;
758 }
759 else if (cmp > 0) {
760 // Our needle is greater than aHaystack[mid].
761 if (aHigh - mid > 1) {
762 // The element is in the upper half.
763 return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
764 }
765
766 // The exact needle element was not found in this haystack. Determine if
767 // we are in termination case (3) or (2) and return the appropriate thing.
768 if (aBias == exports.LEAST_UPPER_BOUND) {
769 return aHigh < aHaystack.length ? aHigh : -1;
770 } else {
771 return mid;
772 }
773 }
774 else {
775 // Our needle is less than aHaystack[mid].
776 if (mid - aLow > 1) {
777 // The element is in the lower half.
778 return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
779 }
780
781 // we are in termination case (3) or (2) and return the appropriate thing.
782 if (aBias == exports.LEAST_UPPER_BOUND) {
783 return mid;
784 } else {
785 return aLow < 0 ? -1 : aLow;
786 }
787 }
788}
789
790/**
791 * This is an implementation of binary search which will always try and return
792 * the index of the closest element if there is no exact hit. This is because
793 * mappings between original and generated line/col pairs are single points,
794 * and there is an implicit region between each of them, so a miss just means
795 * that you aren't on the very start of a region.
796 *
797 * @param aNeedle The element you are looking for.
798 * @param aHaystack The array that is being searched.
799 * @param aCompare A function which takes the needle and an element in the
800 * array and returns -1, 0, or 1 depending on whether the needle is less
801 * than, equal to, or greater than the element, respectively.
802 * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
803 * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
804 * closest element that is smaller than or greater than the one we are
805 * searching for, respectively, if the exact element cannot be found.
806 * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
807 */
808exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
809 if (aHaystack.length === 0) {
810 return -1;
811 }
812
813 var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
814 aCompare, aBias || exports.GREATEST_LOWER_BOUND);
815 if (index < 0) {
816 return -1;
817 }
818
819 // We have found either the exact element, or the next-closest element than
820 // the one we are searching for. However, there may be more than one such
821 // element. Make sure we always return the smallest of these.
822 while (index - 1 >= 0) {
823 if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
824 break;
825 }
826 --index;
827 }
828
829 return index;
830};
831
832
833/***/ }),
834
835/***/ 302:
836/***/ (function(__unusedmodule, exports, __webpack_require__) {
837
838/* -*- Mode: js; js-indent-level: 2; -*- */
839/*
840 * Copyright 2011 Mozilla Foundation and contributors
841 * Licensed under the New BSD license. See LICENSE or:
842 * http://opensource.org/licenses/BSD-3-Clause
843 */
844
845var util = __webpack_require__(567);
846var binarySearch = __webpack_require__(285);
847var ArraySet = __webpack_require__(46).ArraySet;
848var base64VLQ = __webpack_require__(668);
849var quickSort = __webpack_require__(882).quickSort;
850
851function SourceMapConsumer(aSourceMap, aSourceMapURL) {
852 var sourceMap = aSourceMap;
853 if (typeof aSourceMap === 'string') {
854 sourceMap = util.parseSourceMapInput(aSourceMap);
855 }
856
857 return sourceMap.sections != null
858 ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
859 : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
860}
861
862SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
863 return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
864}
865
866/**
867 * The version of the source mapping spec that we are consuming.
868 */
869SourceMapConsumer.prototype._version = 3;
870
871// `__generatedMappings` and `__originalMappings` are arrays that hold the
872// parsed mapping coordinates from the source map's "mappings" attribute. They
873// are lazily instantiated, accessed via the `_generatedMappings` and
874// `_originalMappings` getters respectively, and we only parse the mappings
875// and create these arrays once queried for a source location. We jump through
876// these hoops because there can be many thousands of mappings, and parsing
877// them is expensive, so we only want to do it if we must.
878//
879// Each object in the arrays is of the form:
880//
881// {
882// generatedLine: The line number in the generated code,
883// generatedColumn: The column number in the generated code,
884// source: The path to the original source file that generated this
885// chunk of code,
886// originalLine: The line number in the original source that
887// corresponds to this chunk of generated code,
888// originalColumn: The column number in the original source that
889// corresponds to this chunk of generated code,
890// name: The name of the original symbol which generated this chunk of
891// code.
892// }
893//
894// All properties except for `generatedLine` and `generatedColumn` can be
895// `null`.
896//
897// `_generatedMappings` is ordered by the generated positions.
898//
899// `_originalMappings` is ordered by the original positions.
900
901SourceMapConsumer.prototype.__generatedMappings = null;
902Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
903 configurable: true,
904 enumerable: true,
905 get: function () {
906 if (!this.__generatedMappings) {
907 this._parseMappings(this._mappings, this.sourceRoot);
908 }
909
910 return this.__generatedMappings;
911 }
912});
913
914SourceMapConsumer.prototype.__originalMappings = null;
915Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
916 configurable: true,
917 enumerable: true,
918 get: function () {
919 if (!this.__originalMappings) {
920 this._parseMappings(this._mappings, this.sourceRoot);
921 }
922
923 return this.__originalMappings;
924 }
925});
926
927SourceMapConsumer.prototype._charIsMappingSeparator =
928 function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
929 var c = aStr.charAt(index);
930 return c === ";" || c === ",";
931 };
932
933/**
934 * Parse the mappings in a string in to a data structure which we can easily
935 * query (the ordered arrays in the `this.__generatedMappings` and
936 * `this.__originalMappings` properties).
937 */
938SourceMapConsumer.prototype._parseMappings =
939 function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
940 throw new Error("Subclasses must implement _parseMappings");
941 };
942
943SourceMapConsumer.GENERATED_ORDER = 1;
944SourceMapConsumer.ORIGINAL_ORDER = 2;
945
946SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
947SourceMapConsumer.LEAST_UPPER_BOUND = 2;
948
949/**
950 * Iterate over each mapping between an original source/line/column and a
951 * generated line/column in this source map.
952 *
953 * @param Function aCallback
954 * The function that is called with each mapping.
955 * @param Object aContext
956 * Optional. If specified, this object will be the value of `this` every
957 * time that `aCallback` is called.
958 * @param aOrder
959 * Either `SourceMapConsumer.GENERATED_ORDER` or
960 * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
961 * iterate over the mappings sorted by the generated file's line/column
962 * order or the original's source/line/column order, respectively. Defaults to
963 * `SourceMapConsumer.GENERATED_ORDER`.
964 */
965SourceMapConsumer.prototype.eachMapping =
966 function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
967 var context = aContext || null;
968 var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
969
970 var mappings;
971 switch (order) {
972 case SourceMapConsumer.GENERATED_ORDER:
973 mappings = this._generatedMappings;
974 break;
975 case SourceMapConsumer.ORIGINAL_ORDER:
976 mappings = this._originalMappings;
977 break;
978 default:
979 throw new Error("Unknown order of iteration.");
980 }
981
982 var sourceRoot = this.sourceRoot;
983 mappings.map(function (mapping) {
984 var source = mapping.source === null ? null : this._sources.at(mapping.source);
985 source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
986 return {
987 source: source,
988 generatedLine: mapping.generatedLine,
989 generatedColumn: mapping.generatedColumn,
990 originalLine: mapping.originalLine,
991 originalColumn: mapping.originalColumn,
992 name: mapping.name === null ? null : this._names.at(mapping.name)
993 };
994 }, this).forEach(aCallback, context);
995 };
996
997/**
998 * Returns all generated line and column information for the original source,
999 * line, and column provided. If no column is provided, returns all mappings
1000 * corresponding to a either the line we are searching for or the next
1001 * closest line that has any mappings. Otherwise, returns all mappings
1002 * corresponding to the given line and either the column we are searching for
1003 * or the next closest column that has any offsets.
1004 *
1005 * The only argument is an object with the following properties:
1006 *
1007 * - source: The filename of the original source.
1008 * - line: The line number in the original source. The line number is 1-based.
1009 * - column: Optional. the column number in the original source.
1010 * The column number is 0-based.
1011 *
1012 * and an array of objects is returned, each with the following properties:
1013 *
1014 * - line: The line number in the generated source, or null. The
1015 * line number is 1-based.
1016 * - column: The column number in the generated source, or null.
1017 * The column number is 0-based.
1018 */
1019SourceMapConsumer.prototype.allGeneratedPositionsFor =
1020 function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
1021 var line = util.getArg(aArgs, 'line');
1022
1023 // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
1024 // returns the index of the closest mapping less than the needle. By
1025 // setting needle.originalColumn to 0, we thus find the last mapping for
1026 // the given line, provided such a mapping exists.
1027 var needle = {
1028 source: util.getArg(aArgs, 'source'),
1029 originalLine: line,
1030 originalColumn: util.getArg(aArgs, 'column', 0)
1031 };
1032
1033 needle.source = this._findSourceIndex(needle.source);
1034 if (needle.source < 0) {
1035 return [];
1036 }
1037
1038 var mappings = [];
1039
1040 var index = this._findMapping(needle,
1041 this._originalMappings,
1042 "originalLine",
1043 "originalColumn",
1044 util.compareByOriginalPositions,
1045 binarySearch.LEAST_UPPER_BOUND);
1046 if (index >= 0) {
1047 var mapping = this._originalMappings[index];
1048
1049 if (aArgs.column === undefined) {
1050 var originalLine = mapping.originalLine;
1051
1052 // Iterate until either we run out of mappings, or we run into
1053 // a mapping for a different line than the one we found. Since
1054 // mappings are sorted, this is guaranteed to find all mappings for
1055 // the line we found.
1056 while (mapping && mapping.originalLine === originalLine) {
1057 mappings.push({
1058 line: util.getArg(mapping, 'generatedLine', null),
1059 column: util.getArg(mapping, 'generatedColumn', null),
1060 lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
1061 });
1062
1063 mapping = this._originalMappings[++index];
1064 }
1065 } else {
1066 var originalColumn = mapping.originalColumn;
1067
1068 // Iterate until either we run out of mappings, or we run into
1069 // a mapping for a different line than the one we were searching for.
1070 // Since mappings are sorted, this is guaranteed to find all mappings for
1071 // the line we are searching for.
1072 while (mapping &&
1073 mapping.originalLine === line &&
1074 mapping.originalColumn == originalColumn) {
1075 mappings.push({
1076 line: util.getArg(mapping, 'generatedLine', null),
1077 column: util.getArg(mapping, 'generatedColumn', null),
1078 lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
1079 });
1080
1081 mapping = this._originalMappings[++index];
1082 }
1083 }
1084 }
1085
1086 return mappings;
1087 };
1088
1089exports.SourceMapConsumer = SourceMapConsumer;
1090
1091/**
1092 * A BasicSourceMapConsumer instance represents a parsed source map which we can
1093 * query for information about the original file positions by giving it a file
1094 * position in the generated source.
1095 *
1096 * The first parameter is the raw source map (either as a JSON string, or
1097 * already parsed to an object). According to the spec, source maps have the
1098 * following attributes:
1099 *
1100 * - version: Which version of the source map spec this map is following.
1101 * - sources: An array of URLs to the original source files.
1102 * - names: An array of identifiers which can be referrenced by individual mappings.
1103 * - sourceRoot: Optional. The URL root from which all sources are relative.
1104 * - sourcesContent: Optional. An array of contents of the original source files.
1105 * - mappings: A string of base64 VLQs which contain the actual mappings.
1106 * - file: Optional. The generated file this source map is associated with.
1107 *
1108 * Here is an example source map, taken from the source map spec[0]:
1109 *
1110 * {
1111 * version : 3,
1112 * file: "out.js",
1113 * sourceRoot : "",
1114 * sources: ["foo.js", "bar.js"],
1115 * names: ["src", "maps", "are", "fun"],
1116 * mappings: "AA,AB;;ABCDE;"
1117 * }
1118 *
1119 * The second parameter, if given, is a string whose value is the URL
1120 * at which the source map was found. This URL is used to compute the
1121 * sources array.
1122 *
1123 * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
1124 */
1125function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
1126 var sourceMap = aSourceMap;
1127 if (typeof aSourceMap === 'string') {
1128 sourceMap = util.parseSourceMapInput(aSourceMap);
1129 }
1130
1131 var version = util.getArg(sourceMap, 'version');
1132 var sources = util.getArg(sourceMap, 'sources');
1133 // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
1134 // requires the array) to play nice here.
1135 var names = util.getArg(sourceMap, 'names', []);
1136 var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
1137 var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
1138 var mappings = util.getArg(sourceMap, 'mappings');
1139 var file = util.getArg(sourceMap, 'file', null);
1140
1141 // Once again, Sass deviates from the spec and supplies the version as a
1142 // string rather than a number, so we use loose equality checking here.
1143 if (version != this._version) {
1144 throw new Error('Unsupported version: ' + version);
1145 }
1146
1147 if (sourceRoot) {
1148 sourceRoot = util.normalize(sourceRoot);
1149 }
1150
1151 sources = sources
1152 .map(String)
1153 // Some source maps produce relative source paths like "./foo.js" instead of
1154 // "foo.js". Normalize these first so that future comparisons will succeed.
1155 // See bugzil.la/1090768.
1156 .map(util.normalize)
1157 // Always ensure that absolute sources are internally stored relative to
1158 // the source root, if the source root is absolute. Not doing this would
1159 // be particularly problematic when the source root is a prefix of the
1160 // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
1161 .map(function (source) {
1162 return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
1163 ? util.relative(sourceRoot, source)
1164 : source;
1165 });
1166
1167 // Pass `true` below to allow duplicate names and sources. While source maps
1168 // are intended to be compressed and deduplicated, the TypeScript compiler
1169 // sometimes generates source maps with duplicates in them. See Github issue
1170 // #72 and bugzil.la/889492.
1171 this._names = ArraySet.fromArray(names.map(String), true);
1172 this._sources = ArraySet.fromArray(sources, true);
1173
1174 this._absoluteSources = this._sources.toArray().map(function (s) {
1175 return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
1176 });
1177
1178 this.sourceRoot = sourceRoot;
1179 this.sourcesContent = sourcesContent;
1180 this._mappings = mappings;
1181 this._sourceMapURL = aSourceMapURL;
1182 this.file = file;
1183}
1184
1185BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
1186BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
1187
1188/**
1189 * Utility function to find the index of a source. Returns -1 if not
1190 * found.
1191 */
1192BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
1193 var relativeSource = aSource;
1194 if (this.sourceRoot != null) {
1195 relativeSource = util.relative(this.sourceRoot, relativeSource);
1196 }
1197
1198 if (this._sources.has(relativeSource)) {
1199 return this._sources.indexOf(relativeSource);
1200 }
1201
1202 // Maybe aSource is an absolute URL as returned by |sources|. In
1203 // this case we can't simply undo the transform.
1204 var i;
1205 for (i = 0; i < this._absoluteSources.length; ++i) {
1206 if (this._absoluteSources[i] == aSource) {
1207 return i;
1208 }
1209 }
1210
1211 return -1;
1212};
1213
1214/**
1215 * Create a BasicSourceMapConsumer from a SourceMapGenerator.
1216 *
1217 * @param SourceMapGenerator aSourceMap
1218 * The source map that will be consumed.
1219 * @param String aSourceMapURL
1220 * The URL at which the source map can be found (optional)
1221 * @returns BasicSourceMapConsumer
1222 */
1223BasicSourceMapConsumer.fromSourceMap =
1224 function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
1225 var smc = Object.create(BasicSourceMapConsumer.prototype);
1226
1227 var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
1228 var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
1229 smc.sourceRoot = aSourceMap._sourceRoot;
1230 smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
1231 smc.sourceRoot);
1232 smc.file = aSourceMap._file;
1233 smc._sourceMapURL = aSourceMapURL;
1234 smc._absoluteSources = smc._sources.toArray().map(function (s) {
1235 return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
1236 });
1237
1238 // Because we are modifying the entries (by converting string sources and
1239 // names to indices into the sources and names ArraySets), we have to make
1240 // a copy of the entry or else bad things happen. Shared mutable state
1241 // strikes again! See github issue #191.
1242
1243 var generatedMappings = aSourceMap._mappings.toArray().slice();
1244 var destGeneratedMappings = smc.__generatedMappings = [];
1245 var destOriginalMappings = smc.__originalMappings = [];
1246
1247 for (var i = 0, length = generatedMappings.length; i < length; i++) {
1248 var srcMapping = generatedMappings[i];
1249 var destMapping = new Mapping;
1250 destMapping.generatedLine = srcMapping.generatedLine;
1251 destMapping.generatedColumn = srcMapping.generatedColumn;
1252
1253 if (srcMapping.source) {
1254 destMapping.source = sources.indexOf(srcMapping.source);
1255 destMapping.originalLine = srcMapping.originalLine;
1256 destMapping.originalColumn = srcMapping.originalColumn;
1257
1258 if (srcMapping.name) {
1259 destMapping.name = names.indexOf(srcMapping.name);
1260 }
1261
1262 destOriginalMappings.push(destMapping);
1263 }
1264
1265 destGeneratedMappings.push(destMapping);
1266 }
1267
1268 quickSort(smc.__originalMappings, util.compareByOriginalPositions);
1269
1270 return smc;
1271 };
1272
1273/**
1274 * The version of the source mapping spec that we are consuming.
1275 */
1276BasicSourceMapConsumer.prototype._version = 3;
1277
1278/**
1279 * The list of original sources.
1280 */
1281Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
1282 get: function () {
1283 return this._absoluteSources.slice();
1284 }
1285});
1286
1287/**
1288 * Provide the JIT with a nice shape / hidden class.
1289 */
1290function Mapping() {
1291 this.generatedLine = 0;
1292 this.generatedColumn = 0;
1293 this.source = null;
1294 this.originalLine = null;
1295 this.originalColumn = null;
1296 this.name = null;
1297}
1298
1299/**
1300 * Parse the mappings in a string in to a data structure which we can easily
1301 * query (the ordered arrays in the `this.__generatedMappings` and
1302 * `this.__originalMappings` properties).
1303 */
1304BasicSourceMapConsumer.prototype._parseMappings =
1305 function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
1306 var generatedLine = 1;
1307 var previousGeneratedColumn = 0;
1308 var previousOriginalLine = 0;
1309 var previousOriginalColumn = 0;
1310 var previousSource = 0;
1311 var previousName = 0;
1312 var length = aStr.length;
1313 var index = 0;
1314 var cachedSegments = {};
1315 var temp = {};
1316 var originalMappings = [];
1317 var generatedMappings = [];
1318 var mapping, str, segment, end, value;
1319
1320 while (index < length) {
1321 if (aStr.charAt(index) === ';') {
1322 generatedLine++;
1323 index++;
1324 previousGeneratedColumn = 0;
1325 }
1326 else if (aStr.charAt(index) === ',') {
1327 index++;
1328 }
1329 else {
1330 mapping = new Mapping();
1331 mapping.generatedLine = generatedLine;
1332
1333 // Because each offset is encoded relative to the previous one,
1334 // many segments often have the same encoding. We can exploit this
1335 // fact by caching the parsed variable length fields of each segment,
1336 // allowing us to avoid a second parse if we encounter the same
1337 // segment again.
1338 for (end = index; end < length; end++) {
1339 if (this._charIsMappingSeparator(aStr, end)) {
1340 break;
1341 }
1342 }
1343 str = aStr.slice(index, end);
1344
1345 segment = cachedSegments[str];
1346 if (segment) {
1347 index += str.length;
1348 } else {
1349 segment = [];
1350 while (index < end) {
1351 base64VLQ.decode(aStr, index, temp);
1352 value = temp.value;
1353 index = temp.rest;
1354 segment.push(value);
1355 }
1356
1357 if (segment.length === 2) {
1358 throw new Error('Found a source, but no line and column');
1359 }
1360
1361 if (segment.length === 3) {
1362 throw new Error('Found a source and line, but no column');
1363 }
1364
1365 cachedSegments[str] = segment;
1366 }
1367
1368 // Generated column.
1369 mapping.generatedColumn = previousGeneratedColumn + segment[0];
1370 previousGeneratedColumn = mapping.generatedColumn;
1371
1372 if (segment.length > 1) {
1373 // Original source.
1374 mapping.source = previousSource + segment[1];
1375 previousSource += segment[1];
1376
1377 // Original line.
1378 mapping.originalLine = previousOriginalLine + segment[2];
1379 previousOriginalLine = mapping.originalLine;
1380 // Lines are stored 0-based
1381 mapping.originalLine += 1;
1382
1383 // Original column.
1384 mapping.originalColumn = previousOriginalColumn + segment[3];
1385 previousOriginalColumn = mapping.originalColumn;
1386
1387 if (segment.length > 4) {
1388 // Original name.
1389 mapping.name = previousName + segment[4];
1390 previousName += segment[4];
1391 }
1392 }
1393
1394 generatedMappings.push(mapping);
1395 if (typeof mapping.originalLine === 'number') {
1396 originalMappings.push(mapping);
1397 }
1398 }
1399 }
1400
1401 quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);
1402 this.__generatedMappings = generatedMappings;
1403
1404 quickSort(originalMappings, util.compareByOriginalPositions);
1405 this.__originalMappings = originalMappings;
1406 };
1407
1408/**
1409 * Find the mapping that best matches the hypothetical "needle" mapping that
1410 * we are searching for in the given "haystack" of mappings.
1411 */
1412BasicSourceMapConsumer.prototype._findMapping =
1413 function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
1414 aColumnName, aComparator, aBias) {
1415 // To return the position we are searching for, we must first find the
1416 // mapping for the given position and then return the opposite position it
1417 // points to. Because the mappings are sorted, we can use binary search to
1418 // find the best mapping.
1419
1420 if (aNeedle[aLineName] <= 0) {
1421 throw new TypeError('Line must be greater than or equal to 1, got '
1422 + aNeedle[aLineName]);
1423 }
1424 if (aNeedle[aColumnName] < 0) {
1425 throw new TypeError('Column must be greater than or equal to 0, got '
1426 + aNeedle[aColumnName]);
1427 }
1428
1429 return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
1430 };
1431
1432/**
1433 * Compute the last column for each generated mapping. The last column is
1434 * inclusive.
1435 */
1436BasicSourceMapConsumer.prototype.computeColumnSpans =
1437 function SourceMapConsumer_computeColumnSpans() {
1438 for (var index = 0; index < this._generatedMappings.length; ++index) {
1439 var mapping = this._generatedMappings[index];
1440
1441 // Mappings do not contain a field for the last generated columnt. We
1442 // can come up with an optimistic estimate, however, by assuming that
1443 // mappings are contiguous (i.e. given two consecutive mappings, the
1444 // first mapping ends where the second one starts).
1445 if (index + 1 < this._generatedMappings.length) {
1446 var nextMapping = this._generatedMappings[index + 1];
1447
1448 if (mapping.generatedLine === nextMapping.generatedLine) {
1449 mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
1450 continue;
1451 }
1452 }
1453
1454 // The last mapping for each line spans the entire line.
1455 mapping.lastGeneratedColumn = Infinity;
1456 }
1457 };
1458
1459/**
1460 * Returns the original source, line, and column information for the generated
1461 * source's line and column positions provided. The only argument is an object
1462 * with the following properties:
1463 *
1464 * - line: The line number in the generated source. The line number
1465 * is 1-based.
1466 * - column: The column number in the generated source. The column
1467 * number is 0-based.
1468 * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
1469 * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
1470 * closest element that is smaller than or greater than the one we are
1471 * searching for, respectively, if the exact element cannot be found.
1472 * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
1473 *
1474 * and an object is returned with the following properties:
1475 *
1476 * - source: The original source file, or null.
1477 * - line: The line number in the original source, or null. The
1478 * line number is 1-based.
1479 * - column: The column number in the original source, or null. The
1480 * column number is 0-based.
1481 * - name: The original identifier, or null.
1482 */
1483BasicSourceMapConsumer.prototype.originalPositionFor =
1484 function SourceMapConsumer_originalPositionFor(aArgs) {
1485 var needle = {
1486 generatedLine: util.getArg(aArgs, 'line'),
1487 generatedColumn: util.getArg(aArgs, 'column')
1488 };
1489
1490 var index = this._findMapping(
1491 needle,
1492 this._generatedMappings,
1493 "generatedLine",
1494 "generatedColumn",
1495 util.compareByGeneratedPositionsDeflated,
1496 util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
1497 );
1498
1499 if (index >= 0) {
1500 var mapping = this._generatedMappings[index];
1501
1502 if (mapping.generatedLine === needle.generatedLine) {
1503 var source = util.getArg(mapping, 'source', null);
1504 if (source !== null) {
1505 source = this._sources.at(source);
1506 source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
1507 }
1508 var name = util.getArg(mapping, 'name', null);
1509 if (name !== null) {
1510 name = this._names.at(name);
1511 }
1512 return {
1513 source: source,
1514 line: util.getArg(mapping, 'originalLine', null),
1515 column: util.getArg(mapping, 'originalColumn', null),
1516 name: name
1517 };
1518 }
1519 }
1520
1521 return {
1522 source: null,
1523 line: null,
1524 column: null,
1525 name: null
1526 };
1527 };
1528
1529/**
1530 * Return true if we have the source content for every source in the source
1531 * map, false otherwise.
1532 */
1533BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
1534 function BasicSourceMapConsumer_hasContentsOfAllSources() {
1535 if (!this.sourcesContent) {
1536 return false;
1537 }
1538 return this.sourcesContent.length >= this._sources.size() &&
1539 !this.sourcesContent.some(function (sc) { return sc == null; });
1540 };
1541
1542/**
1543 * Returns the original source content. The only argument is the url of the
1544 * original source file. Returns null if no original source content is
1545 * available.
1546 */
1547BasicSourceMapConsumer.prototype.sourceContentFor =
1548 function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
1549 if (!this.sourcesContent) {
1550 return null;
1551 }
1552
1553 var index = this._findSourceIndex(aSource);
1554 if (index >= 0) {
1555 return this.sourcesContent[index];
1556 }
1557
1558 var relativeSource = aSource;
1559 if (this.sourceRoot != null) {
1560 relativeSource = util.relative(this.sourceRoot, relativeSource);
1561 }
1562
1563 var url;
1564 if (this.sourceRoot != null
1565 && (url = util.urlParse(this.sourceRoot))) {
1566 // XXX: file:// URIs and absolute paths lead to unexpected behavior for
1567 // many users. We can help them out when they expect file:// URIs to
1568 // behave like it would if they were running a local HTTP server. See
1569 // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
1570 var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
1571 if (url.scheme == "file"
1572 && this._sources.has(fileUriAbsPath)) {
1573 return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
1574 }
1575
1576 if ((!url.path || url.path == "/")
1577 && this._sources.has("/" + relativeSource)) {
1578 return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
1579 }
1580 }
1581
1582 // This function is used recursively from
1583 // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
1584 // don't want to throw if we can't find the source - we just want to
1585 // return null, so we provide a flag to exit gracefully.
1586 if (nullOnMissing) {
1587 return null;
1588 }
1589 else {
1590 throw new Error('"' + relativeSource + '" is not in the SourceMap.');
1591 }
1592 };
1593
1594/**
1595 * Returns the generated line and column information for the original source,
1596 * line, and column positions provided. The only argument is an object with
1597 * the following properties:
1598 *
1599 * - source: The filename of the original source.
1600 * - line: The line number in the original source. The line number
1601 * is 1-based.
1602 * - column: The column number in the original source. The column
1603 * number is 0-based.
1604 * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
1605 * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
1606 * closest element that is smaller than or greater than the one we are
1607 * searching for, respectively, if the exact element cannot be found.
1608 * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
1609 *
1610 * and an object is returned with the following properties:
1611 *
1612 * - line: The line number in the generated source, or null. The
1613 * line number is 1-based.
1614 * - column: The column number in the generated source, or null.
1615 * The column number is 0-based.
1616 */
1617BasicSourceMapConsumer.prototype.generatedPositionFor =
1618 function SourceMapConsumer_generatedPositionFor(aArgs) {
1619 var source = util.getArg(aArgs, 'source');
1620 source = this._findSourceIndex(source);
1621 if (source < 0) {
1622 return {
1623 line: null,
1624 column: null,
1625 lastColumn: null
1626 };
1627 }
1628
1629 var needle = {
1630 source: source,
1631 originalLine: util.getArg(aArgs, 'line'),
1632 originalColumn: util.getArg(aArgs, 'column')
1633 };
1634
1635 var index = this._findMapping(
1636 needle,
1637 this._originalMappings,
1638 "originalLine",
1639 "originalColumn",
1640 util.compareByOriginalPositions,
1641 util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
1642 );
1643
1644 if (index >= 0) {
1645 var mapping = this._originalMappings[index];
1646
1647 if (mapping.source === needle.source) {
1648 return {
1649 line: util.getArg(mapping, 'generatedLine', null),
1650 column: util.getArg(mapping, 'generatedColumn', null),
1651 lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
1652 };
1653 }
1654 }
1655
1656 return {
1657 line: null,
1658 column: null,
1659 lastColumn: null
1660 };
1661 };
1662
1663exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
1664
1665/**
1666 * An IndexedSourceMapConsumer instance represents a parsed source map which
1667 * we can query for information. It differs from BasicSourceMapConsumer in
1668 * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
1669 * input.
1670 *
1671 * The first parameter is a raw source map (either as a JSON string, or already
1672 * parsed to an object). According to the spec for indexed source maps, they
1673 * have the following attributes:
1674 *
1675 * - version: Which version of the source map spec this map is following.
1676 * - file: Optional. The generated file this source map is associated with.
1677 * - sections: A list of section definitions.
1678 *
1679 * Each value under the "sections" field has two fields:
1680 * - offset: The offset into the original specified at which this section
1681 * begins to apply, defined as an object with a "line" and "column"
1682 * field.
1683 * - map: A source map definition. This source map could also be indexed,
1684 * but doesn't have to be.
1685 *
1686 * Instead of the "map" field, it's also possible to have a "url" field
1687 * specifying a URL to retrieve a source map from, but that's currently
1688 * unsupported.
1689 *
1690 * Here's an example source map, taken from the source map spec[0], but
1691 * modified to omit a section which uses the "url" field.
1692 *
1693 * {
1694 * version : 3,
1695 * file: "app.js",
1696 * sections: [{
1697 * offset: {line:100, column:10},
1698 * map: {
1699 * version : 3,
1700 * file: "section.js",
1701 * sources: ["foo.js", "bar.js"],
1702 * names: ["src", "maps", "are", "fun"],
1703 * mappings: "AAAA,E;;ABCDE;"
1704 * }
1705 * }],
1706 * }
1707 *
1708 * The second parameter, if given, is a string whose value is the URL
1709 * at which the source map was found. This URL is used to compute the
1710 * sources array.
1711 *
1712 * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
1713 */
1714function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
1715 var sourceMap = aSourceMap;
1716 if (typeof aSourceMap === 'string') {
1717 sourceMap = util.parseSourceMapInput(aSourceMap);
1718 }
1719
1720 var version = util.getArg(sourceMap, 'version');
1721 var sections = util.getArg(sourceMap, 'sections');
1722
1723 if (version != this._version) {
1724 throw new Error('Unsupported version: ' + version);
1725 }
1726
1727 this._sources = new ArraySet();
1728 this._names = new ArraySet();
1729
1730 var lastOffset = {
1731 line: -1,
1732 column: 0
1733 };
1734 this._sections = sections.map(function (s) {
1735 if (s.url) {
1736 // The url field will require support for asynchronicity.
1737 // See https://github.com/mozilla/source-map/issues/16
1738 throw new Error('Support for url field in sections not implemented.');
1739 }
1740 var offset = util.getArg(s, 'offset');
1741 var offsetLine = util.getArg(offset, 'line');
1742 var offsetColumn = util.getArg(offset, 'column');
1743
1744 if (offsetLine < lastOffset.line ||
1745 (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
1746 throw new Error('Section offsets must be ordered and non-overlapping.');
1747 }
1748 lastOffset = offset;
1749
1750 return {
1751 generatedOffset: {
1752 // The offset fields are 0-based, but we use 1-based indices when
1753 // encoding/decoding from VLQ.
1754 generatedLine: offsetLine + 1,
1755 generatedColumn: offsetColumn + 1
1756 },
1757 consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
1758 }
1759 });
1760}
1761
1762IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
1763IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
1764
1765/**
1766 * The version of the source mapping spec that we are consuming.
1767 */
1768IndexedSourceMapConsumer.prototype._version = 3;
1769
1770/**
1771 * The list of original sources.
1772 */
1773Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
1774 get: function () {
1775 var sources = [];
1776 for (var i = 0; i < this._sections.length; i++) {
1777 for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
1778 sources.push(this._sections[i].consumer.sources[j]);
1779 }
1780 }
1781 return sources;
1782 }
1783});
1784
1785/**
1786 * Returns the original source, line, and column information for the generated
1787 * source's line and column positions provided. The only argument is an object
1788 * with the following properties:
1789 *
1790 * - line: The line number in the generated source. The line number
1791 * is 1-based.
1792 * - column: The column number in the generated source. The column
1793 * number is 0-based.
1794 *
1795 * and an object is returned with the following properties:
1796 *
1797 * - source: The original source file, or null.
1798 * - line: The line number in the original source, or null. The
1799 * line number is 1-based.
1800 * - column: The column number in the original source, or null. The
1801 * column number is 0-based.
1802 * - name: The original identifier, or null.
1803 */
1804IndexedSourceMapConsumer.prototype.originalPositionFor =
1805 function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
1806 var needle = {
1807 generatedLine: util.getArg(aArgs, 'line'),
1808 generatedColumn: util.getArg(aArgs, 'column')
1809 };
1810
1811 // Find the section containing the generated position we're trying to map
1812 // to an original position.
1813 var sectionIndex = binarySearch.search(needle, this._sections,
1814 function(needle, section) {
1815 var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
1816 if (cmp) {
1817 return cmp;
1818 }
1819
1820 return (needle.generatedColumn -
1821 section.generatedOffset.generatedColumn);
1822 });
1823 var section = this._sections[sectionIndex];
1824
1825 if (!section) {
1826 return {
1827 source: null,
1828 line: null,
1829 column: null,
1830 name: null
1831 };
1832 }
1833
1834 return section.consumer.originalPositionFor({
1835 line: needle.generatedLine -
1836 (section.generatedOffset.generatedLine - 1),
1837 column: needle.generatedColumn -
1838 (section.generatedOffset.generatedLine === needle.generatedLine
1839 ? section.generatedOffset.generatedColumn - 1
1840 : 0),
1841 bias: aArgs.bias
1842 });
1843 };
1844
1845/**
1846 * Return true if we have the source content for every source in the source
1847 * map, false otherwise.
1848 */
1849IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
1850 function IndexedSourceMapConsumer_hasContentsOfAllSources() {
1851 return this._sections.every(function (s) {
1852 return s.consumer.hasContentsOfAllSources();
1853 });
1854 };
1855
1856/**
1857 * Returns the original source content. The only argument is the url of the
1858 * original source file. Returns null if no original source content is
1859 * available.
1860 */
1861IndexedSourceMapConsumer.prototype.sourceContentFor =
1862 function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
1863 for (var i = 0; i < this._sections.length; i++) {
1864 var section = this._sections[i];
1865
1866 var content = section.consumer.sourceContentFor(aSource, true);
1867 if (content) {
1868 return content;
1869 }
1870 }
1871 if (nullOnMissing) {
1872 return null;
1873 }
1874 else {
1875 throw new Error('"' + aSource + '" is not in the SourceMap.');
1876 }
1877 };
1878
1879/**
1880 * Returns the generated line and column information for the original source,
1881 * line, and column positions provided. The only argument is an object with
1882 * the following properties:
1883 *
1884 * - source: The filename of the original source.
1885 * - line: The line number in the original source. The line number
1886 * is 1-based.
1887 * - column: The column number in the original source. The column
1888 * number is 0-based.
1889 *
1890 * and an object is returned with the following properties:
1891 *
1892 * - line: The line number in the generated source, or null. The
1893 * line number is 1-based.
1894 * - column: The column number in the generated source, or null.
1895 * The column number is 0-based.
1896 */
1897IndexedSourceMapConsumer.prototype.generatedPositionFor =
1898 function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
1899 for (var i = 0; i < this._sections.length; i++) {
1900 var section = this._sections[i];
1901
1902 // Only consider this section if the requested source is in the list of
1903 // sources of the consumer.
1904 if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
1905 continue;
1906 }
1907 var generatedPosition = section.consumer.generatedPositionFor(aArgs);
1908 if (generatedPosition) {
1909 var ret = {
1910 line: generatedPosition.line +
1911 (section.generatedOffset.generatedLine - 1),
1912 column: generatedPosition.column +
1913 (section.generatedOffset.generatedLine === generatedPosition.line
1914 ? section.generatedOffset.generatedColumn - 1
1915 : 0)
1916 };
1917 return ret;
1918 }
1919 }
1920
1921 return {
1922 line: null,
1923 column: null
1924 };
1925 };
1926
1927/**
1928 * Parse the mappings in a string in to a data structure which we can easily
1929 * query (the ordered arrays in the `this.__generatedMappings` and
1930 * `this.__originalMappings` properties).
1931 */
1932IndexedSourceMapConsumer.prototype._parseMappings =
1933 function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
1934 this.__generatedMappings = [];
1935 this.__originalMappings = [];
1936 for (var i = 0; i < this._sections.length; i++) {
1937 var section = this._sections[i];
1938 var sectionMappings = section.consumer._generatedMappings;
1939 for (var j = 0; j < sectionMappings.length; j++) {
1940 var mapping = sectionMappings[j];
1941
1942 var source = section.consumer._sources.at(mapping.source);
1943 source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
1944 this._sources.add(source);
1945 source = this._sources.indexOf(source);
1946
1947 var name = null;
1948 if (mapping.name) {
1949 name = section.consumer._names.at(mapping.name);
1950 this._names.add(name);
1951 name = this._names.indexOf(name);
1952 }
1953
1954 // The mappings coming from the consumer for the section have
1955 // generated positions relative to the start of the section, so we
1956 // need to offset them to be relative to the start of the concatenated
1957 // generated file.
1958 var adjustedMapping = {
1959 source: source,
1960 generatedLine: mapping.generatedLine +
1961 (section.generatedOffset.generatedLine - 1),
1962 generatedColumn: mapping.generatedColumn +
1963 (section.generatedOffset.generatedLine === mapping.generatedLine
1964 ? section.generatedOffset.generatedColumn - 1
1965 : 0),
1966 originalLine: mapping.originalLine,
1967 originalColumn: mapping.originalColumn,
1968 name: name
1969 };
1970
1971 this.__generatedMappings.push(adjustedMapping);
1972 if (typeof adjustedMapping.originalLine === 'number') {
1973 this.__originalMappings.push(adjustedMapping);
1974 }
1975 }
1976 }
1977
1978 quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
1979 quickSort(this.__originalMappings, util.compareByOriginalPositions);
1980 };
1981
1982exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
1983
1984
1985/***/ }),
1986
1987/***/ 470:
1988/***/ (function(module) {
1989
1990var toString = Object.prototype.toString
1991
1992var isModern = (
1993 typeof Buffer.alloc === 'function' &&
1994 typeof Buffer.allocUnsafe === 'function' &&
1995 typeof Buffer.from === 'function'
1996)
1997
1998function isArrayBuffer (input) {
1999 return toString.call(input).slice(8, -1) === 'ArrayBuffer'
2000}
2001
2002function fromArrayBuffer (obj, byteOffset, length) {
2003 byteOffset >>>= 0
2004
2005 var maxLength = obj.byteLength - byteOffset
2006
2007 if (maxLength < 0) {
2008 throw new RangeError("'offset' is out of bounds")
2009 }
2010
2011 if (length === undefined) {
2012 length = maxLength
2013 } else {
2014 length >>>= 0
2015
2016 if (length > maxLength) {
2017 throw new RangeError("'length' is out of bounds")
2018 }
2019 }
2020
2021 return isModern
2022 ? Buffer.from(obj.slice(byteOffset, byteOffset + length))
2023 : new Buffer(new Uint8Array(obj.slice(byteOffset, byteOffset + length)))
2024}
2025
2026function fromString (string, encoding) {
2027 if (typeof encoding !== 'string' || encoding === '') {
2028 encoding = 'utf8'
2029 }
2030
2031 if (!Buffer.isEncoding(encoding)) {
2032 throw new TypeError('"encoding" must be a valid string encoding')
2033 }
2034
2035 return isModern
2036 ? Buffer.from(string, encoding)
2037 : new Buffer(string, encoding)
2038}
2039
2040function bufferFrom (value, encodingOrOffset, length) {
2041 if (typeof value === 'number') {
2042 throw new TypeError('"value" argument must not be a number')
2043 }
2044
2045 if (isArrayBuffer(value)) {
2046 return fromArrayBuffer(value, encodingOrOffset, length)
2047 }
2048
2049 if (typeof value === 'string') {
2050 return fromString(value, encodingOrOffset)
2051 }
2052
2053 return isModern
2054 ? Buffer.from(value)
2055 : new Buffer(value)
2056}
2057
2058module.exports = bufferFrom
2059
2060
2061/***/ }),
2062
2063/***/ 545:
2064/***/ (function(module, exports, __webpack_require__) {
2065
2066/* module decorator */ module = __webpack_require__.nmd(module);
2067var SourceMapConsumer = __webpack_require__(168).SourceMapConsumer;
2068var path = __webpack_require__(622);
2069
2070var fs;
2071try {
2072 fs = __webpack_require__(747);
2073 if (!fs.existsSync || !fs.readFileSync) {
2074 // fs doesn't have all methods we need
2075 fs = null;
2076 }
2077} catch (err) {
2078 /* nop */
2079}
2080
2081var bufferFrom = __webpack_require__(470);
2082
2083/**
2084 * Requires a module which is protected against bundler minification.
2085 *
2086 * @param {NodeModule} mod
2087 * @param {string} request
2088 */
2089function dynamicRequire(mod, request) {
2090 return mod.require(request);
2091}
2092
2093// Only install once if called multiple times
2094var errorFormatterInstalled = false;
2095var uncaughtShimInstalled = false;
2096
2097// If true, the caches are reset before a stack trace formatting operation
2098var emptyCacheBetweenOperations = false;
2099
2100// Supports {browser, node, auto}
2101var environment = "auto";
2102
2103// Maps a file path to a string containing the file contents
2104var fileContentsCache = {};
2105
2106// Maps a file path to a source map for that file
2107var sourceMapCache = {};
2108
2109// Regex for detecting source maps
2110var reSourceMap = /^data:application\/json[^,]+base64,/;
2111
2112// Priority list of retrieve handlers
2113var retrieveFileHandlers = [];
2114var retrieveMapHandlers = [];
2115
2116function isInBrowser() {
2117 if (environment === "browser")
2118 return true;
2119 if (environment === "node")
2120 return false;
2121 return ((typeof window !== 'undefined') && (typeof XMLHttpRequest === 'function') && !(window.require && window.module && window.process && window.process.type === "renderer"));
2122}
2123
2124function hasGlobalProcessEventEmitter() {
2125 return ((typeof process === 'object') && (process !== null) && (typeof process.on === 'function'));
2126}
2127
2128function handlerExec(list) {
2129 return function(arg) {
2130 for (var i = 0; i < list.length; i++) {
2131 var ret = list[i](arg);
2132 if (ret) {
2133 return ret;
2134 }
2135 }
2136 return null;
2137 };
2138}
2139
2140var retrieveFile = handlerExec(retrieveFileHandlers);
2141
2142retrieveFileHandlers.push(function(path) {
2143 // Trim the path to make sure there is no extra whitespace.
2144 path = path.trim();
2145 if (/^file:/.test(path)) {
2146 // existsSync/readFileSync can't handle file protocol, but once stripped, it works
2147 path = path.replace(/file:\/\/\/(\w:)?/, function(protocol, drive) {
2148 return drive ?
2149 '' : // file:///C:/dir/file -> C:/dir/file
2150 '/'; // file:///root-dir/file -> /root-dir/file
2151 });
2152 }
2153 if (path in fileContentsCache) {
2154 return fileContentsCache[path];
2155 }
2156
2157 var contents = '';
2158 try {
2159 if (!fs) {
2160 // Use SJAX if we are in the browser
2161 var xhr = new XMLHttpRequest();
2162 xhr.open('GET', path, /** async */ false);
2163 xhr.send(null);
2164 if (xhr.readyState === 4 && xhr.status === 200) {
2165 contents = xhr.responseText;
2166 }
2167 } else if (fs.existsSync(path)) {
2168 // Otherwise, use the filesystem
2169 contents = fs.readFileSync(path, 'utf8');
2170 }
2171 } catch (er) {
2172 /* ignore any errors */
2173 }
2174
2175 return fileContentsCache[path] = contents;
2176});
2177
2178// Support URLs relative to a directory, but be careful about a protocol prefix
2179// in case we are in the browser (i.e. directories may start with "http://" or "file:///")
2180function supportRelativeURL(file, url) {
2181 if (!file) return url;
2182 var dir = path.dirname(file);
2183 var match = /^\w+:\/\/[^\/]*/.exec(dir);
2184 var protocol = match ? match[0] : '';
2185 var startPath = dir.slice(protocol.length);
2186 if (protocol && /^\/\w\:/.test(startPath)) {
2187 // handle file:///C:/ paths
2188 protocol += '/';
2189 return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/');
2190 }
2191 return protocol + path.resolve(dir.slice(protocol.length), url);
2192}
2193
2194function retrieveSourceMapURL(source) {
2195 var fileData;
2196
2197 if (isInBrowser()) {
2198 try {
2199 var xhr = new XMLHttpRequest();
2200 xhr.open('GET', source, false);
2201 xhr.send(null);
2202 fileData = xhr.readyState === 4 ? xhr.responseText : null;
2203
2204 // Support providing a sourceMappingURL via the SourceMap header
2205 var sourceMapHeader = xhr.getResponseHeader("SourceMap") ||
2206 xhr.getResponseHeader("X-SourceMap");
2207 if (sourceMapHeader) {
2208 return sourceMapHeader;
2209 }
2210 } catch (e) {
2211 }
2212 }
2213
2214 // Get the URL of the source map
2215 fileData = retrieveFile(source);
2216 var re = /(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg;
2217 // Keep executing the search to find the *last* sourceMappingURL to avoid
2218 // picking up sourceMappingURLs from comments, strings, etc.
2219 var lastMatch, match;
2220 while (match = re.exec(fileData)) lastMatch = match;
2221 if (!lastMatch) return null;
2222 return lastMatch[1];
2223};
2224
2225// Can be overridden by the retrieveSourceMap option to install. Takes a
2226// generated source filename; returns a {map, optional url} object, or null if
2227// there is no source map. The map field may be either a string or the parsed
2228// JSON object (ie, it must be a valid argument to the SourceMapConsumer
2229// constructor).
2230var retrieveSourceMap = handlerExec(retrieveMapHandlers);
2231retrieveMapHandlers.push(function(source) {
2232 var sourceMappingURL = retrieveSourceMapURL(source);
2233 if (!sourceMappingURL) return null;
2234
2235 // Read the contents of the source map
2236 var sourceMapData;
2237 if (reSourceMap.test(sourceMappingURL)) {
2238 // Support source map URL as a data url
2239 var rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(',') + 1);
2240 sourceMapData = bufferFrom(rawData, "base64").toString();
2241 sourceMappingURL = source;
2242 } else {
2243 // Support source map URLs relative to the source URL
2244 sourceMappingURL = supportRelativeURL(source, sourceMappingURL);
2245 sourceMapData = retrieveFile(sourceMappingURL);
2246 }
2247
2248 if (!sourceMapData) {
2249 return null;
2250 }
2251
2252 return {
2253 url: sourceMappingURL,
2254 map: sourceMapData
2255 };
2256});
2257
2258function mapSourcePosition(position) {
2259 var sourceMap = sourceMapCache[position.source];
2260 if (!sourceMap) {
2261 // Call the (overrideable) retrieveSourceMap function to get the source map.
2262 var urlAndMap = retrieveSourceMap(position.source);
2263 if (urlAndMap) {
2264 sourceMap = sourceMapCache[position.source] = {
2265 url: urlAndMap.url,
2266 map: new SourceMapConsumer(urlAndMap.map)
2267 };
2268
2269 // Load all sources stored inline with the source map into the file cache
2270 // to pretend like they are already loaded. They may not exist on disk.
2271 if (sourceMap.map.sourcesContent) {
2272 sourceMap.map.sources.forEach(function(source, i) {
2273 var contents = sourceMap.map.sourcesContent[i];
2274 if (contents) {
2275 var url = supportRelativeURL(sourceMap.url, source);
2276 fileContentsCache[url] = contents;
2277 }
2278 });
2279 }
2280 } else {
2281 sourceMap = sourceMapCache[position.source] = {
2282 url: null,
2283 map: null
2284 };
2285 }
2286 }
2287
2288 // Resolve the source URL relative to the URL of the source map
2289 if (sourceMap && sourceMap.map && typeof sourceMap.map.originalPositionFor === 'function') {
2290 var originalPosition = sourceMap.map.originalPositionFor(position);
2291
2292 // Only return the original position if a matching line was found. If no
2293 // matching line is found then we return position instead, which will cause
2294 // the stack trace to print the path and line for the compiled file. It is
2295 // better to give a precise location in the compiled file than a vague
2296 // location in the original file.
2297 if (originalPosition.source !== null) {
2298 originalPosition.source = supportRelativeURL(
2299 sourceMap.url, originalPosition.source);
2300 return originalPosition;
2301 }
2302 }
2303
2304 return position;
2305}
2306
2307// Parses code generated by FormatEvalOrigin(), a function inside V8:
2308// https://code.google.com/p/v8/source/browse/trunk/src/messages.js
2309function mapEvalOrigin(origin) {
2310 // Most eval() calls are in this format
2311 var match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin);
2312 if (match) {
2313 var position = mapSourcePosition({
2314 source: match[2],
2315 line: +match[3],
2316 column: match[4] - 1
2317 });
2318 return 'eval at ' + match[1] + ' (' + position.source + ':' +
2319 position.line + ':' + (position.column + 1) + ')';
2320 }
2321
2322 // Parse nested eval() calls using recursion
2323 match = /^eval at ([^(]+) \((.+)\)$/.exec(origin);
2324 if (match) {
2325 return 'eval at ' + match[1] + ' (' + mapEvalOrigin(match[2]) + ')';
2326 }
2327
2328 // Make sure we still return useful information if we didn't find anything
2329 return origin;
2330}
2331
2332// This is copied almost verbatim from the V8 source code at
2333// https://code.google.com/p/v8/source/browse/trunk/src/messages.js. The
2334// implementation of wrapCallSite() used to just forward to the actual source
2335// code of CallSite.prototype.toString but unfortunately a new release of V8
2336// did something to the prototype chain and broke the shim. The only fix I
2337// could find was copy/paste.
2338function CallSiteToString() {
2339 var fileName;
2340 var fileLocation = "";
2341 if (this.isNative()) {
2342 fileLocation = "native";
2343 } else {
2344 fileName = this.getScriptNameOrSourceURL();
2345 if (!fileName && this.isEval()) {
2346 fileLocation = this.getEvalOrigin();
2347 fileLocation += ", "; // Expecting source position to follow.
2348 }
2349
2350 if (fileName) {
2351 fileLocation += fileName;
2352 } else {
2353 // Source code does not originate from a file and is not native, but we
2354 // can still get the source position inside the source string, e.g. in
2355 // an eval string.
2356 fileLocation += "<anonymous>";
2357 }
2358 var lineNumber = this.getLineNumber();
2359 if (lineNumber != null) {
2360 fileLocation += ":" + lineNumber;
2361 var columnNumber = this.getColumnNumber();
2362 if (columnNumber) {
2363 fileLocation += ":" + columnNumber;
2364 }
2365 }
2366 }
2367
2368 var line = "";
2369 var functionName = this.getFunctionName();
2370 var addSuffix = true;
2371 var isConstructor = this.isConstructor();
2372 var isMethodCall = !(this.isToplevel() || isConstructor);
2373 if (isMethodCall) {
2374 var typeName = this.getTypeName();
2375 // Fixes shim to be backward compatable with Node v0 to v4
2376 if (typeName === "[object Object]") {
2377 typeName = "null";
2378 }
2379 var methodName = this.getMethodName();
2380 if (functionName) {
2381 if (typeName && functionName.indexOf(typeName) != 0) {
2382 line += typeName + ".";
2383 }
2384 line += functionName;
2385 if (methodName && functionName.indexOf("." + methodName) != functionName.length - methodName.length - 1) {
2386 line += " [as " + methodName + "]";
2387 }
2388 } else {
2389 line += typeName + "." + (methodName || "<anonymous>");
2390 }
2391 } else if (isConstructor) {
2392 line += "new " + (functionName || "<anonymous>");
2393 } else if (functionName) {
2394 line += functionName;
2395 } else {
2396 line += fileLocation;
2397 addSuffix = false;
2398 }
2399 if (addSuffix) {
2400 line += " (" + fileLocation + ")";
2401 }
2402 return line;
2403}
2404
2405function cloneCallSite(frame) {
2406 var object = {};
2407 Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach(function(name) {
2408 object[name] = /^(?:is|get)/.test(name) ? function() { return frame[name].call(frame); } : frame[name];
2409 });
2410 object.toString = CallSiteToString;
2411 return object;
2412}
2413
2414function wrapCallSite(frame, state) {
2415 // provides interface backward compatibility
2416 if (state === undefined) {
2417 state = { nextPosition: null, curPosition: null }
2418 }
2419 if(frame.isNative()) {
2420 state.curPosition = null;
2421 return frame;
2422 }
2423
2424 // Most call sites will return the source file from getFileName(), but code
2425 // passed to eval() ending in "//# sourceURL=..." will return the source file
2426 // from getScriptNameOrSourceURL() instead
2427 var source = frame.getFileName() || frame.getScriptNameOrSourceURL();
2428 if (source) {
2429 var line = frame.getLineNumber();
2430 var column = frame.getColumnNumber() - 1;
2431
2432 // Fix position in Node where some (internal) code is prepended.
2433 // See https://github.com/evanw/node-source-map-support/issues/36
2434 // Header removed in node at ^10.16 || >=11.11.0
2435 // v11 is not an LTS candidate, we can just test the one version with it.
2436 // Test node versions for: 10.16-19, 10.20+, 12-19, 20-99, 100+, or 11.11
2437 var noHeader = /^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
2438 var headerLength = noHeader.test(process.version) ? 0 : 62;
2439 if (line === 1 && column > headerLength && !isInBrowser() && !frame.isEval()) {
2440 column -= headerLength;
2441 }
2442
2443 var position = mapSourcePosition({
2444 source: source,
2445 line: line,
2446 column: column
2447 });
2448 state.curPosition = position;
2449 frame = cloneCallSite(frame);
2450 var originalFunctionName = frame.getFunctionName;
2451 frame.getFunctionName = function() {
2452 if (state.nextPosition == null) {
2453 return originalFunctionName();
2454 }
2455 return state.nextPosition.name || originalFunctionName();
2456 };
2457 frame.getFileName = function() { return position.source; };
2458 frame.getLineNumber = function() { return position.line; };
2459 frame.getColumnNumber = function() { return position.column + 1; };
2460 frame.getScriptNameOrSourceURL = function() { return position.source; };
2461 return frame;
2462 }
2463
2464 // Code called using eval() needs special handling
2465 var origin = frame.isEval() && frame.getEvalOrigin();
2466 if (origin) {
2467 origin = mapEvalOrigin(origin);
2468 frame = cloneCallSite(frame);
2469 frame.getEvalOrigin = function() { return origin; };
2470 return frame;
2471 }
2472
2473 // If we get here then we were unable to change the source position
2474 return frame;
2475}
2476
2477// This function is part of the V8 stack trace API, for more info see:
2478// https://v8.dev/docs/stack-trace-api
2479function prepareStackTrace(error, stack) {
2480 if (emptyCacheBetweenOperations) {
2481 fileContentsCache = {};
2482 sourceMapCache = {};
2483 }
2484
2485 var name = error.name || 'Error';
2486 var message = error.message || '';
2487 var errorString = name + ": " + message;
2488
2489 var state = { nextPosition: null, curPosition: null };
2490 var processedStack = [];
2491 for (var i = stack.length - 1; i >= 0; i--) {
2492 processedStack.push('\n at ' + wrapCallSite(stack[i], state));
2493 state.nextPosition = state.curPosition;
2494 }
2495 state.curPosition = state.nextPosition = null;
2496 return errorString + processedStack.reverse().join('');
2497}
2498
2499// Generate position and snippet of original source with pointer
2500function getErrorSource(error) {
2501 var match = /\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack);
2502 if (match) {
2503 var source = match[1];
2504 var line = +match[2];
2505 var column = +match[3];
2506
2507 // Support the inline sourceContents inside the source map
2508 var contents = fileContentsCache[source];
2509
2510 // Support files on disk
2511 if (!contents && fs && fs.existsSync(source)) {
2512 try {
2513 contents = fs.readFileSync(source, 'utf8');
2514 } catch (er) {
2515 contents = '';
2516 }
2517 }
2518
2519 // Format the line from the original source code like node does
2520 if (contents) {
2521 var code = contents.split(/(?:\r\n|\r|\n)/)[line - 1];
2522 if (code) {
2523 return source + ':' + line + '\n' + code + '\n' +
2524 new Array(column).join(' ') + '^';
2525 }
2526 }
2527 }
2528 return null;
2529}
2530
2531function printErrorAndExit (error) {
2532 var source = getErrorSource(error);
2533
2534 // Ensure error is printed synchronously and not truncated
2535 if (process.stderr._handle && process.stderr._handle.setBlocking) {
2536 process.stderr._handle.setBlocking(true);
2537 }
2538
2539 if (source) {
2540 console.error();
2541 console.error(source);
2542 }
2543
2544 console.error(error.stack);
2545 process.exit(1);
2546}
2547
2548function shimEmitUncaughtException () {
2549 var origEmit = process.emit;
2550
2551 process.emit = function (type) {
2552 if (type === 'uncaughtException') {
2553 var hasStack = (arguments[1] && arguments[1].stack);
2554 var hasListeners = (this.listeners(type).length > 0);
2555
2556 if (hasStack && !hasListeners) {
2557 return printErrorAndExit(arguments[1]);
2558 }
2559 }
2560
2561 return origEmit.apply(this, arguments);
2562 };
2563}
2564
2565var originalRetrieveFileHandlers = retrieveFileHandlers.slice(0);
2566var originalRetrieveMapHandlers = retrieveMapHandlers.slice(0);
2567
2568exports.wrapCallSite = wrapCallSite;
2569exports.getErrorSource = getErrorSource;
2570exports.mapSourcePosition = mapSourcePosition;
2571exports.retrieveSourceMap = retrieveSourceMap;
2572
2573exports.install = function(options) {
2574 options = options || {};
2575
2576 if (options.environment) {
2577 environment = options.environment;
2578 if (["node", "browser", "auto"].indexOf(environment) === -1) {
2579 throw new Error("environment " + environment + " was unknown. Available options are {auto, browser, node}")
2580 }
2581 }
2582
2583 // Allow sources to be found by methods other than reading the files
2584 // directly from disk.
2585 if (options.retrieveFile) {
2586 if (options.overrideRetrieveFile) {
2587 retrieveFileHandlers.length = 0;
2588 }
2589
2590 retrieveFileHandlers.unshift(options.retrieveFile);
2591 }
2592
2593 // Allow source maps to be found by methods other than reading the files
2594 // directly from disk.
2595 if (options.retrieveSourceMap) {
2596 if (options.overrideRetrieveSourceMap) {
2597 retrieveMapHandlers.length = 0;
2598 }
2599
2600 retrieveMapHandlers.unshift(options.retrieveSourceMap);
2601 }
2602
2603 // Support runtime transpilers that include inline source maps
2604 if (options.hookRequire && !isInBrowser()) {
2605 // Use dynamicRequire to avoid including in browser bundles
2606 var Module = dynamicRequire(module, 'module');
2607 var $compile = Module.prototype._compile;
2608
2609 if (!$compile.__sourceMapSupport) {
2610 Module.prototype._compile = function(content, filename) {
2611 fileContentsCache[filename] = content;
2612 sourceMapCache[filename] = undefined;
2613 return $compile.call(this, content, filename);
2614 };
2615
2616 Module.prototype._compile.__sourceMapSupport = true;
2617 }
2618 }
2619
2620 // Configure options
2621 if (!emptyCacheBetweenOperations) {
2622 emptyCacheBetweenOperations = 'emptyCacheBetweenOperations' in options ?
2623 options.emptyCacheBetweenOperations : false;
2624 }
2625
2626 // Install the error reformatter
2627 if (!errorFormatterInstalled) {
2628 errorFormatterInstalled = true;
2629 Error.prepareStackTrace = prepareStackTrace;
2630 }
2631
2632 if (!uncaughtShimInstalled) {
2633 var installHandler = 'handleUncaughtExceptions' in options ?
2634 options.handleUncaughtExceptions : true;
2635
2636 // Do not override 'uncaughtException' with our own handler in Node.js
2637 // Worker threads. Workers pass the error to the main thread as an event,
2638 // rather than printing something to stderr and exiting.
2639 try {
2640 // We need to use `dynamicRequire` because `require` on it's own will be optimized by WebPack/Browserify.
2641 var worker_threads = dynamicRequire(module, 'worker_threads');
2642 if (worker_threads.isMainThread === false) {
2643 installHandler = false;
2644 }
2645 } catch(e) {}
2646
2647 // Provide the option to not install the uncaught exception handler. This is
2648 // to support other uncaught exception handlers (in test frameworks, for
2649 // example). If this handler is not installed and there are no other uncaught
2650 // exception handlers, uncaught exceptions will be caught by node's built-in
2651 // exception handler and the process will still be terminated. However, the
2652 // generated JavaScript code will be shown above the stack trace instead of
2653 // the original source code.
2654 if (installHandler && hasGlobalProcessEventEmitter()) {
2655 uncaughtShimInstalled = true;
2656 shimEmitUncaughtException();
2657 }
2658 }
2659};
2660
2661exports.resetRetrieveHandlers = function() {
2662 retrieveFileHandlers.length = 0;
2663 retrieveMapHandlers.length = 0;
2664
2665 retrieveFileHandlers = originalRetrieveFileHandlers.slice(0);
2666 retrieveMapHandlers = originalRetrieveMapHandlers.slice(0);
2667
2668 retrieveSourceMap = handlerExec(retrieveMapHandlers);
2669 retrieveFile = handlerExec(retrieveFileHandlers);
2670}
2671
2672
2673/***/ }),
2674
2675/***/ 567:
2676/***/ (function(__unusedmodule, exports) {
2677
2678/* -*- Mode: js; js-indent-level: 2; -*- */
2679/*
2680 * Copyright 2011 Mozilla Foundation and contributors
2681 * Licensed under the New BSD license. See LICENSE or:
2682 * http://opensource.org/licenses/BSD-3-Clause
2683 */
2684
2685/**
2686 * This is a helper function for getting values from parameter/options
2687 * objects.
2688 *
2689 * @param args The object we are extracting values from
2690 * @param name The name of the property we are getting.
2691 * @param defaultValue An optional value to return if the property is missing
2692 * from the object. If this is not specified and the property is missing, an
2693 * error will be thrown.
2694 */
2695function getArg(aArgs, aName, aDefaultValue) {
2696 if (aName in aArgs) {
2697 return aArgs[aName];
2698 } else if (arguments.length === 3) {
2699 return aDefaultValue;
2700 } else {
2701 throw new Error('"' + aName + '" is a required argument.');
2702 }
2703}
2704exports.getArg = getArg;
2705
2706var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
2707var dataUrlRegexp = /^data:.+\,.+$/;
2708
2709function urlParse(aUrl) {
2710 var match = aUrl.match(urlRegexp);
2711 if (!match) {
2712 return null;
2713 }
2714 return {
2715 scheme: match[1],
2716 auth: match[2],
2717 host: match[3],
2718 port: match[4],
2719 path: match[5]
2720 };
2721}
2722exports.urlParse = urlParse;
2723
2724function urlGenerate(aParsedUrl) {
2725 var url = '';
2726 if (aParsedUrl.scheme) {
2727 url += aParsedUrl.scheme + ':';
2728 }
2729 url += '//';
2730 if (aParsedUrl.auth) {
2731 url += aParsedUrl.auth + '@';
2732 }
2733 if (aParsedUrl.host) {
2734 url += aParsedUrl.host;
2735 }
2736 if (aParsedUrl.port) {
2737 url += ":" + aParsedUrl.port
2738 }
2739 if (aParsedUrl.path) {
2740 url += aParsedUrl.path;
2741 }
2742 return url;
2743}
2744exports.urlGenerate = urlGenerate;
2745
2746/**
2747 * Normalizes a path, or the path portion of a URL:
2748 *
2749 * - Replaces consecutive slashes with one slash.
2750 * - Removes unnecessary '.' parts.
2751 * - Removes unnecessary '<dir>/..' parts.
2752 *
2753 * Based on code in the Node.js 'path' core module.
2754 *
2755 * @param aPath The path or url to normalize.
2756 */
2757function normalize(aPath) {
2758 var path = aPath;
2759 var url = urlParse(aPath);
2760 if (url) {
2761 if (!url.path) {
2762 return aPath;
2763 }
2764 path = url.path;
2765 }
2766 var isAbsolute = exports.isAbsolute(path);
2767
2768 var parts = path.split(/\/+/);
2769 for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
2770 part = parts[i];
2771 if (part === '.') {
2772 parts.splice(i, 1);
2773 } else if (part === '..') {
2774 up++;
2775 } else if (up > 0) {
2776 if (part === '') {
2777 // The first part is blank if the path is absolute. Trying to go
2778 // above the root is a no-op. Therefore we can remove all '..' parts
2779 // directly after the root.
2780 parts.splice(i + 1, up);
2781 up = 0;
2782 } else {
2783 parts.splice(i, 2);
2784 up--;
2785 }
2786 }
2787 }
2788 path = parts.join('/');
2789
2790 if (path === '') {
2791 path = isAbsolute ? '/' : '.';
2792 }
2793
2794 if (url) {
2795 url.path = path;
2796 return urlGenerate(url);
2797 }
2798 return path;
2799}
2800exports.normalize = normalize;
2801
2802/**
2803 * Joins two paths/URLs.
2804 *
2805 * @param aRoot The root path or URL.
2806 * @param aPath The path or URL to be joined with the root.
2807 *
2808 * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
2809 * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
2810 * first.
2811 * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
2812 * is updated with the result and aRoot is returned. Otherwise the result
2813 * is returned.
2814 * - If aPath is absolute, the result is aPath.
2815 * - Otherwise the two paths are joined with a slash.
2816 * - Joining for example 'http://' and 'www.example.com' is also supported.
2817 */
2818function join(aRoot, aPath) {
2819 if (aRoot === "") {
2820 aRoot = ".";
2821 }
2822 if (aPath === "") {
2823 aPath = ".";
2824 }
2825 var aPathUrl = urlParse(aPath);
2826 var aRootUrl = urlParse(aRoot);
2827 if (aRootUrl) {
2828 aRoot = aRootUrl.path || '/';
2829 }
2830
2831 // `join(foo, '//www.example.org')`
2832 if (aPathUrl && !aPathUrl.scheme) {
2833 if (aRootUrl) {
2834 aPathUrl.scheme = aRootUrl.scheme;
2835 }
2836 return urlGenerate(aPathUrl);
2837 }
2838
2839 if (aPathUrl || aPath.match(dataUrlRegexp)) {
2840 return aPath;
2841 }
2842
2843 // `join('http://', 'www.example.com')`
2844 if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
2845 aRootUrl.host = aPath;
2846 return urlGenerate(aRootUrl);
2847 }
2848
2849 var joined = aPath.charAt(0) === '/'
2850 ? aPath
2851 : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
2852
2853 if (aRootUrl) {
2854 aRootUrl.path = joined;
2855 return urlGenerate(aRootUrl);
2856 }
2857 return joined;
2858}
2859exports.join = join;
2860
2861exports.isAbsolute = function (aPath) {
2862 return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
2863};
2864
2865/**
2866 * Make a path relative to a URL or another path.
2867 *
2868 * @param aRoot The root path or URL.
2869 * @param aPath The path or URL to be made relative to aRoot.
2870 */
2871function relative(aRoot, aPath) {
2872 if (aRoot === "") {
2873 aRoot = ".";
2874 }
2875
2876 aRoot = aRoot.replace(/\/$/, '');
2877
2878 // It is possible for the path to be above the root. In this case, simply
2879 // checking whether the root is a prefix of the path won't work. Instead, we
2880 // need to remove components from the root one by one, until either we find
2881 // a prefix that fits, or we run out of components to remove.
2882 var level = 0;
2883 while (aPath.indexOf(aRoot + '/') !== 0) {
2884 var index = aRoot.lastIndexOf("/");
2885 if (index < 0) {
2886 return aPath;
2887 }
2888
2889 // If the only part of the root that is left is the scheme (i.e. http://,
2890 // file:///, etc.), one or more slashes (/), or simply nothing at all, we
2891 // have exhausted all components, so the path is not relative to the root.
2892 aRoot = aRoot.slice(0, index);
2893 if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
2894 return aPath;
2895 }
2896
2897 ++level;
2898 }
2899
2900 // Make sure we add a "../" for each component we removed from the root.
2901 return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
2902}
2903exports.relative = relative;
2904
2905var supportsNullProto = (function () {
2906 var obj = Object.create(null);
2907 return !('__proto__' in obj);
2908}());
2909
2910function identity (s) {
2911 return s;
2912}
2913
2914/**
2915 * Because behavior goes wacky when you set `__proto__` on objects, we
2916 * have to prefix all the strings in our set with an arbitrary character.
2917 *
2918 * See https://github.com/mozilla/source-map/pull/31 and
2919 * https://github.com/mozilla/source-map/issues/30
2920 *
2921 * @param String aStr
2922 */
2923function toSetString(aStr) {
2924 if (isProtoString(aStr)) {
2925 return '$' + aStr;
2926 }
2927
2928 return aStr;
2929}
2930exports.toSetString = supportsNullProto ? identity : toSetString;
2931
2932function fromSetString(aStr) {
2933 if (isProtoString(aStr)) {
2934 return aStr.slice(1);
2935 }
2936
2937 return aStr;
2938}
2939exports.fromSetString = supportsNullProto ? identity : fromSetString;
2940
2941function isProtoString(s) {
2942 if (!s) {
2943 return false;
2944 }
2945
2946 var length = s.length;
2947
2948 if (length < 9 /* "__proto__".length */) {
2949 return false;
2950 }
2951
2952 if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
2953 s.charCodeAt(length - 2) !== 95 /* '_' */ ||
2954 s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
2955 s.charCodeAt(length - 4) !== 116 /* 't' */ ||
2956 s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
2957 s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
2958 s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
2959 s.charCodeAt(length - 8) !== 95 /* '_' */ ||
2960 s.charCodeAt(length - 9) !== 95 /* '_' */) {
2961 return false;
2962 }
2963
2964 for (var i = length - 10; i >= 0; i--) {
2965 if (s.charCodeAt(i) !== 36 /* '$' */) {
2966 return false;
2967 }
2968 }
2969
2970 return true;
2971}
2972
2973/**
2974 * Comparator between two mappings where the original positions are compared.
2975 *
2976 * Optionally pass in `true` as `onlyCompareGenerated` to consider two
2977 * mappings with the same original source/line/column, but different generated
2978 * line and column the same. Useful when searching for a mapping with a
2979 * stubbed out mapping.
2980 */
2981function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
2982 var cmp = strcmp(mappingA.source, mappingB.source);
2983 if (cmp !== 0) {
2984 return cmp;
2985 }
2986
2987 cmp = mappingA.originalLine - mappingB.originalLine;
2988 if (cmp !== 0) {
2989 return cmp;
2990 }
2991
2992 cmp = mappingA.originalColumn - mappingB.originalColumn;
2993 if (cmp !== 0 || onlyCompareOriginal) {
2994 return cmp;
2995 }
2996
2997 cmp = mappingA.generatedColumn - mappingB.generatedColumn;
2998 if (cmp !== 0) {
2999 return cmp;
3000 }
3001
3002 cmp = mappingA.generatedLine - mappingB.generatedLine;
3003 if (cmp !== 0) {
3004 return cmp;
3005 }
3006
3007 return strcmp(mappingA.name, mappingB.name);
3008}
3009exports.compareByOriginalPositions = compareByOriginalPositions;
3010
3011/**
3012 * Comparator between two mappings with deflated source and name indices where
3013 * the generated positions are compared.
3014 *
3015 * Optionally pass in `true` as `onlyCompareGenerated` to consider two
3016 * mappings with the same generated line and column, but different
3017 * source/name/original line and column the same. Useful when searching for a
3018 * mapping with a stubbed out mapping.
3019 */
3020function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
3021 var cmp = mappingA.generatedLine - mappingB.generatedLine;
3022 if (cmp !== 0) {
3023 return cmp;
3024 }
3025
3026 cmp = mappingA.generatedColumn - mappingB.generatedColumn;
3027 if (cmp !== 0 || onlyCompareGenerated) {
3028 return cmp;
3029 }
3030
3031 cmp = strcmp(mappingA.source, mappingB.source);
3032 if (cmp !== 0) {
3033 return cmp;
3034 }
3035
3036 cmp = mappingA.originalLine - mappingB.originalLine;
3037 if (cmp !== 0) {
3038 return cmp;
3039 }
3040
3041 cmp = mappingA.originalColumn - mappingB.originalColumn;
3042 if (cmp !== 0) {
3043 return cmp;
3044 }
3045
3046 return strcmp(mappingA.name, mappingB.name);
3047}
3048exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
3049
3050function strcmp(aStr1, aStr2) {
3051 if (aStr1 === aStr2) {
3052 return 0;
3053 }
3054
3055 if (aStr1 === null) {
3056 return 1; // aStr2 !== null
3057 }
3058
3059 if (aStr2 === null) {
3060 return -1; // aStr1 !== null
3061 }
3062
3063 if (aStr1 > aStr2) {
3064 return 1;
3065 }
3066
3067 return -1;
3068}
3069
3070/**
3071 * Comparator between two mappings with inflated source and name strings where
3072 * the generated positions are compared.
3073 */
3074function compareByGeneratedPositionsInflated(mappingA, mappingB) {
3075 var cmp = mappingA.generatedLine - mappingB.generatedLine;
3076 if (cmp !== 0) {
3077 return cmp;
3078 }
3079
3080 cmp = mappingA.generatedColumn - mappingB.generatedColumn;
3081 if (cmp !== 0) {
3082 return cmp;
3083 }
3084
3085 cmp = strcmp(mappingA.source, mappingB.source);
3086 if (cmp !== 0) {
3087 return cmp;
3088 }
3089
3090 cmp = mappingA.originalLine - mappingB.originalLine;
3091 if (cmp !== 0) {
3092 return cmp;
3093 }
3094
3095 cmp = mappingA.originalColumn - mappingB.originalColumn;
3096 if (cmp !== 0) {
3097 return cmp;
3098 }
3099
3100 return strcmp(mappingA.name, mappingB.name);
3101}
3102exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
3103
3104/**
3105 * Strip any JSON XSSI avoidance prefix from the string (as documented
3106 * in the source maps specification), and then parse the string as
3107 * JSON.
3108 */
3109function parseSourceMapInput(str) {
3110 return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
3111}
3112exports.parseSourceMapInput = parseSourceMapInput;
3113
3114/**
3115 * Compute the URL of a source given the the source root, the source's
3116 * URL, and the source map's URL.
3117 */
3118function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
3119 sourceURL = sourceURL || '';
3120
3121 if (sourceRoot) {
3122 // This follows what Chrome does.
3123 if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
3124 sourceRoot += '/';
3125 }
3126 // The spec says:
3127 // Line 4: An optional source root, useful for relocating source
3128 // files on a server or removing repeated values in the
3129 // “sources” entry. This value is prepended to the individual
3130 // entries in the “source” field.
3131 sourceURL = sourceRoot + sourceURL;
3132 }
3133
3134 // Historically, SourceMapConsumer did not take the sourceMapURL as
3135 // a parameter. This mode is still somewhat supported, which is why
3136 // this code block is conditional. However, it's preferable to pass
3137 // the source map URL to SourceMapConsumer, so that this function
3138 // can implement the source URL resolution algorithm as outlined in
3139 // the spec. This block is basically the equivalent of:
3140 // new URL(sourceURL, sourceMapURL).toString()
3141 // ... except it avoids using URL, which wasn't available in the
3142 // older releases of node still supported by this library.
3143 //
3144 // The spec says:
3145 // If the sources are not absolute URLs after prepending of the
3146 // “sourceRoot”, the sources are resolved relative to the
3147 // SourceMap (like resolving script src in a html document).
3148 if (sourceMapURL) {
3149 var parsed = urlParse(sourceMapURL);
3150 if (!parsed) {
3151 throw new Error("sourceMapURL could not be parsed");
3152 }
3153 if (parsed.path) {
3154 // Strip the last path component, but keep the "/".
3155 var index = parsed.path.lastIndexOf('/');
3156 if (index >= 0) {
3157 parsed.path = parsed.path.substring(0, index + 1);
3158 }
3159 }
3160 sourceURL = join(urlGenerate(parsed), sourceURL);
3161 }
3162
3163 return normalize(sourceURL);
3164}
3165exports.computeSourceURL = computeSourceURL;
3166
3167
3168/***/ }),
3169
3170/***/ 622:
3171/***/ (function(module) {
3172
3173module.exports = require("path");
3174
3175/***/ }),
3176
3177/***/ 668:
3178/***/ (function(__unusedmodule, exports, __webpack_require__) {
3179
3180/* -*- Mode: js; js-indent-level: 2; -*- */
3181/*
3182 * Copyright 2011 Mozilla Foundation and contributors
3183 * Licensed under the New BSD license. See LICENSE or:
3184 * http://opensource.org/licenses/BSD-3-Clause
3185 *
3186 * Based on the Base 64 VLQ implementation in Closure Compiler:
3187 * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
3188 *
3189 * Copyright 2011 The Closure Compiler Authors. All rights reserved.
3190 * Redistribution and use in source and binary forms, with or without
3191 * modification, are permitted provided that the following conditions are
3192 * met:
3193 *
3194 * * Redistributions of source code must retain the above copyright
3195 * notice, this list of conditions and the following disclaimer.
3196 * * Redistributions in binary form must reproduce the above
3197 * copyright notice, this list of conditions and the following
3198 * disclaimer in the documentation and/or other materials provided
3199 * with the distribution.
3200 * * Neither the name of Google Inc. nor the names of its
3201 * contributors may be used to endorse or promote products derived
3202 * from this software without specific prior written permission.
3203 *
3204 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3205 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3206 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3207 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3208 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3209 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3210 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3211 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3212 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3213 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3214 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3215 */
3216
3217var base64 = __webpack_require__(781);
3218
3219// A single base 64 digit can contain 6 bits of data. For the base 64 variable
3220// length quantities we use in the source map spec, the first bit is the sign,
3221// the next four bits are the actual value, and the 6th bit is the
3222// continuation bit. The continuation bit tells us whether there are more
3223// digits in this value following this digit.
3224//
3225// Continuation
3226// | Sign
3227// | |
3228// V V
3229// 101011
3230
3231var VLQ_BASE_SHIFT = 5;
3232
3233// binary: 100000
3234var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
3235
3236// binary: 011111
3237var VLQ_BASE_MASK = VLQ_BASE - 1;
3238
3239// binary: 100000
3240var VLQ_CONTINUATION_BIT = VLQ_BASE;
3241
3242/**
3243 * Converts from a two-complement value to a value where the sign bit is
3244 * placed in the least significant bit. For example, as decimals:
3245 * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
3246 * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
3247 */
3248function toVLQSigned(aValue) {
3249 return aValue < 0
3250 ? ((-aValue) << 1) + 1
3251 : (aValue << 1) + 0;
3252}
3253
3254/**
3255 * Converts to a two-complement value from a value where the sign bit is
3256 * placed in the least significant bit. For example, as decimals:
3257 * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
3258 * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
3259 */
3260function fromVLQSigned(aValue) {
3261 var isNegative = (aValue & 1) === 1;
3262 var shifted = aValue >> 1;
3263 return isNegative
3264 ? -shifted
3265 : shifted;
3266}
3267
3268/**
3269 * Returns the base 64 VLQ encoded value.
3270 */
3271exports.encode = function base64VLQ_encode(aValue) {
3272 var encoded = "";
3273 var digit;
3274
3275 var vlq = toVLQSigned(aValue);
3276
3277 do {
3278 digit = vlq & VLQ_BASE_MASK;
3279 vlq >>>= VLQ_BASE_SHIFT;
3280 if (vlq > 0) {
3281 // There are still more digits in this value, so we must make sure the
3282 // continuation bit is marked.
3283 digit |= VLQ_CONTINUATION_BIT;
3284 }
3285 encoded += base64.encode(digit);
3286 } while (vlq > 0);
3287
3288 return encoded;
3289};
3290
3291/**
3292 * Decodes the next base 64 VLQ value from the given string and returns the
3293 * value and the rest of the string via the out parameter.
3294 */
3295exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
3296 var strLen = aStr.length;
3297 var result = 0;
3298 var shift = 0;
3299 var continuation, digit;
3300
3301 do {
3302 if (aIndex >= strLen) {
3303 throw new Error("Expected more digits in base 64 VLQ value.");
3304 }
3305
3306 digit = base64.decode(aStr.charCodeAt(aIndex++));
3307 if (digit === -1) {
3308 throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
3309 }
3310
3311 continuation = !!(digit & VLQ_CONTINUATION_BIT);
3312 digit &= VLQ_BASE_MASK;
3313 result = result + (digit << shift);
3314 shift += VLQ_BASE_SHIFT;
3315 } while (continuation);
3316
3317 aOutParam.value = fromVLQSigned(result);
3318 aOutParam.rest = aIndex;
3319};
3320
3321
3322/***/ }),
3323
3324/***/ 747:
3325/***/ (function(module) {
3326
3327module.exports = require("fs");
3328
3329/***/ }),
3330
3331/***/ 781:
3332/***/ (function(__unusedmodule, exports) {
3333
3334/* -*- Mode: js; js-indent-level: 2; -*- */
3335/*
3336 * Copyright 2011 Mozilla Foundation and contributors
3337 * Licensed under the New BSD license. See LICENSE or:
3338 * http://opensource.org/licenses/BSD-3-Clause
3339 */
3340
3341var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
3342
3343/**
3344 * Encode an integer in the range of 0 to 63 to a single base 64 digit.
3345 */
3346exports.encode = function (number) {
3347 if (0 <= number && number < intToCharMap.length) {
3348 return intToCharMap[number];
3349 }
3350 throw new TypeError("Must be between 0 and 63: " + number);
3351};
3352
3353/**
3354 * Decode a single base 64 character code digit to an integer. Returns -1 on
3355 * failure.
3356 */
3357exports.decode = function (charCode) {
3358 var bigA = 65; // 'A'
3359 var bigZ = 90; // 'Z'
3360
3361 var littleA = 97; // 'a'
3362 var littleZ = 122; // 'z'
3363
3364 var zero = 48; // '0'
3365 var nine = 57; // '9'
3366
3367 var plus = 43; // '+'
3368 var slash = 47; // '/'
3369
3370 var littleOffset = 26;
3371 var numberOffset = 52;
3372
3373 // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
3374 if (bigA <= charCode && charCode <= bigZ) {
3375 return (charCode - bigA);
3376 }
3377
3378 // 26 - 51: abcdefghijklmnopqrstuvwxyz
3379 if (littleA <= charCode && charCode <= littleZ) {
3380 return (charCode - littleA + littleOffset);
3381 }
3382
3383 // 52 - 61: 0123456789
3384 if (zero <= charCode && charCode <= nine) {
3385 return (charCode - zero + numberOffset);
3386 }
3387
3388 // 62: +
3389 if (charCode == plus) {
3390 return 62;
3391 }
3392
3393 // 63: /
3394 if (charCode == slash) {
3395 return 63;
3396 }
3397
3398 // Invalid base64 digit.
3399 return -1;
3400};
3401
3402
3403/***/ }),
3404
3405/***/ 872:
3406/***/ (function(__unusedmodule, exports, __webpack_require__) {
3407
3408/* -*- Mode: js; js-indent-level: 2; -*- */
3409/*
3410 * Copyright 2011 Mozilla Foundation and contributors
3411 * Licensed under the New BSD license. See LICENSE or:
3412 * http://opensource.org/licenses/BSD-3-Clause
3413 */
3414
3415var SourceMapGenerator = __webpack_require__(116).SourceMapGenerator;
3416var util = __webpack_require__(567);
3417
3418// Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
3419// operating systems these days (capturing the result).
3420var REGEX_NEWLINE = /(\r?\n)/;
3421
3422// Newline character code for charCodeAt() comparisons
3423var NEWLINE_CODE = 10;
3424
3425// Private symbol for identifying `SourceNode`s when multiple versions of
3426// the source-map library are loaded. This MUST NOT CHANGE across
3427// versions!
3428var isSourceNode = "$$$isSourceNode$$$";
3429
3430/**
3431 * SourceNodes provide a way to abstract over interpolating/concatenating
3432 * snippets of generated JavaScript source code while maintaining the line and
3433 * column information associated with the original source code.
3434 *
3435 * @param aLine The original line number.
3436 * @param aColumn The original column number.
3437 * @param aSource The original source's filename.
3438 * @param aChunks Optional. An array of strings which are snippets of
3439 * generated JS, or other SourceNodes.
3440 * @param aName The original identifier.
3441 */
3442function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
3443 this.children = [];
3444 this.sourceContents = {};
3445 this.line = aLine == null ? null : aLine;
3446 this.column = aColumn == null ? null : aColumn;
3447 this.source = aSource == null ? null : aSource;
3448 this.name = aName == null ? null : aName;
3449 this[isSourceNode] = true;
3450 if (aChunks != null) this.add(aChunks);
3451}
3452
3453/**
3454 * Creates a SourceNode from generated code and a SourceMapConsumer.
3455 *
3456 * @param aGeneratedCode The generated code
3457 * @param aSourceMapConsumer The SourceMap for the generated code
3458 * @param aRelativePath Optional. The path that relative sources in the
3459 * SourceMapConsumer should be relative to.
3460 */
3461SourceNode.fromStringWithSourceMap =
3462 function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
3463 // The SourceNode we want to fill with the generated code
3464 // and the SourceMap
3465 var node = new SourceNode();
3466
3467 // All even indices of this array are one line of the generated code,
3468 // while all odd indices are the newlines between two adjacent lines
3469 // (since `REGEX_NEWLINE` captures its match).
3470 // Processed fragments are accessed by calling `shiftNextLine`.
3471 var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
3472 var remainingLinesIndex = 0;
3473 var shiftNextLine = function() {
3474 var lineContents = getNextLine();
3475 // The last line of a file might not have a newline.
3476 var newLine = getNextLine() || "";
3477 return lineContents + newLine;
3478
3479 function getNextLine() {
3480 return remainingLinesIndex < remainingLines.length ?
3481 remainingLines[remainingLinesIndex++] : undefined;
3482 }
3483 };
3484
3485 // We need to remember the position of "remainingLines"
3486 var lastGeneratedLine = 1, lastGeneratedColumn = 0;
3487
3488 // The generate SourceNodes we need a code range.
3489 // To extract it current and last mapping is used.
3490 // Here we store the last mapping.
3491 var lastMapping = null;
3492
3493 aSourceMapConsumer.eachMapping(function (mapping) {
3494 if (lastMapping !== null) {
3495 // We add the code from "lastMapping" to "mapping":
3496 // First check if there is a new line in between.
3497 if (lastGeneratedLine < mapping.generatedLine) {
3498 // Associate first line with "lastMapping"
3499 addMappingWithCode(lastMapping, shiftNextLine());
3500 lastGeneratedLine++;
3501 lastGeneratedColumn = 0;
3502 // The remaining code is added without mapping
3503 } else {
3504 // There is no new line in between.
3505 // Associate the code between "lastGeneratedColumn" and
3506 // "mapping.generatedColumn" with "lastMapping"
3507 var nextLine = remainingLines[remainingLinesIndex] || '';
3508 var code = nextLine.substr(0, mapping.generatedColumn -
3509 lastGeneratedColumn);
3510 remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
3511 lastGeneratedColumn);
3512 lastGeneratedColumn = mapping.generatedColumn;
3513 addMappingWithCode(lastMapping, code);
3514 // No more remaining code, continue
3515 lastMapping = mapping;
3516 return;
3517 }
3518 }
3519 // We add the generated code until the first mapping
3520 // to the SourceNode without any mapping.
3521 // Each line is added as separate string.
3522 while (lastGeneratedLine < mapping.generatedLine) {
3523 node.add(shiftNextLine());
3524 lastGeneratedLine++;
3525 }
3526 if (lastGeneratedColumn < mapping.generatedColumn) {
3527 var nextLine = remainingLines[remainingLinesIndex] || '';
3528 node.add(nextLine.substr(0, mapping.generatedColumn));
3529 remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
3530 lastGeneratedColumn = mapping.generatedColumn;
3531 }
3532 lastMapping = mapping;
3533 }, this);
3534 // We have processed all mappings.
3535 if (remainingLinesIndex < remainingLines.length) {
3536 if (lastMapping) {
3537 // Associate the remaining code in the current line with "lastMapping"
3538 addMappingWithCode(lastMapping, shiftNextLine());
3539 }
3540 // and add the remaining lines without any mapping
3541 node.add(remainingLines.splice(remainingLinesIndex).join(""));
3542 }
3543
3544 // Copy sourcesContent into SourceNode
3545 aSourceMapConsumer.sources.forEach(function (sourceFile) {
3546 var content = aSourceMapConsumer.sourceContentFor(sourceFile);
3547 if (content != null) {
3548 if (aRelativePath != null) {
3549 sourceFile = util.join(aRelativePath, sourceFile);
3550 }
3551 node.setSourceContent(sourceFile, content);
3552 }
3553 });
3554
3555 return node;
3556
3557 function addMappingWithCode(mapping, code) {
3558 if (mapping === null || mapping.source === undefined) {
3559 node.add(code);
3560 } else {
3561 var source = aRelativePath
3562 ? util.join(aRelativePath, mapping.source)
3563 : mapping.source;
3564 node.add(new SourceNode(mapping.originalLine,
3565 mapping.originalColumn,
3566 source,
3567 code,
3568 mapping.name));
3569 }
3570 }
3571 };
3572
3573/**
3574 * Add a chunk of generated JS to this source node.
3575 *
3576 * @param aChunk A string snippet of generated JS code, another instance of
3577 * SourceNode, or an array where each member is one of those things.
3578 */
3579SourceNode.prototype.add = function SourceNode_add(aChunk) {
3580 if (Array.isArray(aChunk)) {
3581 aChunk.forEach(function (chunk) {
3582 this.add(chunk);
3583 }, this);
3584 }
3585 else if (aChunk[isSourceNode] || typeof aChunk === "string") {
3586 if (aChunk) {
3587 this.children.push(aChunk);
3588 }
3589 }
3590 else {
3591 throw new TypeError(
3592 "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
3593 );
3594 }
3595 return this;
3596};
3597
3598/**
3599 * Add a chunk of generated JS to the beginning of this source node.
3600 *
3601 * @param aChunk A string snippet of generated JS code, another instance of
3602 * SourceNode, or an array where each member is one of those things.
3603 */
3604SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
3605 if (Array.isArray(aChunk)) {
3606 for (var i = aChunk.length-1; i >= 0; i--) {
3607 this.prepend(aChunk[i]);
3608 }
3609 }
3610 else if (aChunk[isSourceNode] || typeof aChunk === "string") {
3611 this.children.unshift(aChunk);
3612 }
3613 else {
3614 throw new TypeError(
3615 "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
3616 );
3617 }
3618 return this;
3619};
3620
3621/**
3622 * Walk over the tree of JS snippets in this node and its children. The
3623 * walking function is called once for each snippet of JS and is passed that
3624 * snippet and the its original associated source's line/column location.
3625 *
3626 * @param aFn The traversal function.
3627 */
3628SourceNode.prototype.walk = function SourceNode_walk(aFn) {
3629 var chunk;
3630 for (var i = 0, len = this.children.length; i < len; i++) {
3631 chunk = this.children[i];
3632 if (chunk[isSourceNode]) {
3633 chunk.walk(aFn);
3634 }
3635 else {
3636 if (chunk !== '') {
3637 aFn(chunk, { source: this.source,
3638 line: this.line,
3639 column: this.column,
3640 name: this.name });
3641 }
3642 }
3643 }
3644};
3645
3646/**
3647 * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
3648 * each of `this.children`.
3649 *
3650 * @param aSep The separator.
3651 */
3652SourceNode.prototype.join = function SourceNode_join(aSep) {
3653 var newChildren;
3654 var i;
3655 var len = this.children.length;
3656 if (len > 0) {
3657 newChildren = [];
3658 for (i = 0; i < len-1; i++) {
3659 newChildren.push(this.children[i]);
3660 newChildren.push(aSep);
3661 }
3662 newChildren.push(this.children[i]);
3663 this.children = newChildren;
3664 }
3665 return this;
3666};
3667
3668/**
3669 * Call String.prototype.replace on the very right-most source snippet. Useful
3670 * for trimming whitespace from the end of a source node, etc.
3671 *
3672 * @param aPattern The pattern to replace.
3673 * @param aReplacement The thing to replace the pattern with.
3674 */
3675SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
3676 var lastChild = this.children[this.children.length - 1];
3677 if (lastChild[isSourceNode]) {
3678 lastChild.replaceRight(aPattern, aReplacement);
3679 }
3680 else if (typeof lastChild === 'string') {
3681 this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
3682 }
3683 else {
3684 this.children.push(''.replace(aPattern, aReplacement));
3685 }
3686 return this;
3687};
3688
3689/**
3690 * Set the source content for a source file. This will be added to the SourceMapGenerator
3691 * in the sourcesContent field.
3692 *
3693 * @param aSourceFile The filename of the source file
3694 * @param aSourceContent The content of the source file
3695 */
3696SourceNode.prototype.setSourceContent =
3697 function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
3698 this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
3699 };
3700
3701/**
3702 * Walk over the tree of SourceNodes. The walking function is called for each
3703 * source file content and is passed the filename and source content.
3704 *
3705 * @param aFn The traversal function.
3706 */
3707SourceNode.prototype.walkSourceContents =
3708 function SourceNode_walkSourceContents(aFn) {
3709 for (var i = 0, len = this.children.length; i < len; i++) {
3710 if (this.children[i][isSourceNode]) {
3711 this.children[i].walkSourceContents(aFn);
3712 }
3713 }
3714
3715 var sources = Object.keys(this.sourceContents);
3716 for (var i = 0, len = sources.length; i < len; i++) {
3717 aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
3718 }
3719 };
3720
3721/**
3722 * Return the string representation of this source node. Walks over the tree
3723 * and concatenates all the various snippets together to one string.
3724 */
3725SourceNode.prototype.toString = function SourceNode_toString() {
3726 var str = "";
3727 this.walk(function (chunk) {
3728 str += chunk;
3729 });
3730 return str;
3731};
3732
3733/**
3734 * Returns the string representation of this source node along with a source
3735 * map.
3736 */
3737SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
3738 var generated = {
3739 code: "",
3740 line: 1,
3741 column: 0
3742 };
3743 var map = new SourceMapGenerator(aArgs);
3744 var sourceMappingActive = false;
3745 var lastOriginalSource = null;
3746 var lastOriginalLine = null;
3747 var lastOriginalColumn = null;
3748 var lastOriginalName = null;
3749 this.walk(function (chunk, original) {
3750 generated.code += chunk;
3751 if (original.source !== null
3752 && original.line !== null
3753 && original.column !== null) {
3754 if(lastOriginalSource !== original.source
3755 || lastOriginalLine !== original.line
3756 || lastOriginalColumn !== original.column
3757 || lastOriginalName !== original.name) {
3758 map.addMapping({
3759 source: original.source,
3760 original: {
3761 line: original.line,
3762 column: original.column
3763 },
3764 generated: {
3765 line: generated.line,
3766 column: generated.column
3767 },
3768 name: original.name
3769 });
3770 }
3771 lastOriginalSource = original.source;
3772 lastOriginalLine = original.line;
3773 lastOriginalColumn = original.column;
3774 lastOriginalName = original.name;
3775 sourceMappingActive = true;
3776 } else if (sourceMappingActive) {
3777 map.addMapping({
3778 generated: {
3779 line: generated.line,
3780 column: generated.column
3781 }
3782 });
3783 lastOriginalSource = null;
3784 sourceMappingActive = false;
3785 }
3786 for (var idx = 0, length = chunk.length; idx < length; idx++) {
3787 if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
3788 generated.line++;
3789 generated.column = 0;
3790 // Mappings end at eol
3791 if (idx + 1 === length) {
3792 lastOriginalSource = null;
3793 sourceMappingActive = false;
3794 } else if (sourceMappingActive) {
3795 map.addMapping({
3796 source: original.source,
3797 original: {
3798 line: original.line,
3799 column: original.column
3800 },
3801 generated: {
3802 line: generated.line,
3803 column: generated.column
3804 },
3805 name: original.name
3806 });
3807 }
3808 } else {
3809 generated.column++;
3810 }
3811 }
3812 });
3813 this.walkSourceContents(function (sourceFile, sourceContent) {
3814 map.setSourceContent(sourceFile, sourceContent);
3815 });
3816
3817 return { code: generated.code, map: map };
3818};
3819
3820exports.SourceNode = SourceNode;
3821
3822
3823/***/ }),
3824
3825/***/ 882:
3826/***/ (function(__unusedmodule, exports) {
3827
3828/* -*- Mode: js; js-indent-level: 2; -*- */
3829/*
3830 * Copyright 2011 Mozilla Foundation and contributors
3831 * Licensed under the New BSD license. See LICENSE or:
3832 * http://opensource.org/licenses/BSD-3-Clause
3833 */
3834
3835// It turns out that some (most?) JavaScript engines don't self-host
3836// `Array.prototype.sort`. This makes sense because C++ will likely remain
3837// faster than JS when doing raw CPU-intensive sorting. However, when using a
3838// custom comparator function, calling back and forth between the VM's C++ and
3839// JIT'd JS is rather slow *and* loses JIT type information, resulting in
3840// worse generated code for the comparator function than would be optimal. In
3841// fact, when sorting with a comparator, these costs outweigh the benefits of
3842// sorting in C++. By using our own JS-implemented Quick Sort (below), we get
3843// a ~3500ms mean speed-up in `bench/bench.html`.
3844
3845/**
3846 * Swap the elements indexed by `x` and `y` in the array `ary`.
3847 *
3848 * @param {Array} ary
3849 * The array.
3850 * @param {Number} x
3851 * The index of the first item.
3852 * @param {Number} y
3853 * The index of the second item.
3854 */
3855function swap(ary, x, y) {
3856 var temp = ary[x];
3857 ary[x] = ary[y];
3858 ary[y] = temp;
3859}
3860
3861/**
3862 * Returns a random integer within the range `low .. high` inclusive.
3863 *
3864 * @param {Number} low
3865 * The lower bound on the range.
3866 * @param {Number} high
3867 * The upper bound on the range.
3868 */
3869function randomIntInRange(low, high) {
3870 return Math.round(low + (Math.random() * (high - low)));
3871}
3872
3873/**
3874 * The Quick Sort algorithm.
3875 *
3876 * @param {Array} ary
3877 * An array to sort.
3878 * @param {function} comparator
3879 * Function to use to compare two items.
3880 * @param {Number} p
3881 * Start index of the array
3882 * @param {Number} r
3883 * End index of the array
3884 */
3885function doQuickSort(ary, comparator, p, r) {
3886 // If our lower bound is less than our upper bound, we (1) partition the
3887 // array into two pieces and (2) recurse on each half. If it is not, this is
3888 // the empty array and our base case.
3889
3890 if (p < r) {
3891 // (1) Partitioning.
3892 //
3893 // The partitioning chooses a pivot between `p` and `r` and moves all
3894 // elements that are less than or equal to the pivot to the before it, and
3895 // all the elements that are greater than it after it. The effect is that
3896 // once partition is done, the pivot is in the exact place it will be when
3897 // the array is put in sorted order, and it will not need to be moved
3898 // again. This runs in O(n) time.
3899
3900 // Always choose a random pivot so that an input array which is reverse
3901 // sorted does not cause O(n^2) running time.
3902 var pivotIndex = randomIntInRange(p, r);
3903 var i = p - 1;
3904
3905 swap(ary, pivotIndex, r);
3906 var pivot = ary[r];
3907
3908 // Immediately after `j` is incremented in this loop, the following hold
3909 // true:
3910 //
3911 // * Every element in `ary[p .. i]` is less than or equal to the pivot.
3912 //
3913 // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
3914 for (var j = p; j < r; j++) {
3915 if (comparator(ary[j], pivot) <= 0) {
3916 i += 1;
3917 swap(ary, i, j);
3918 }
3919 }
3920
3921 swap(ary, i + 1, j);
3922 var q = i + 1;
3923
3924 // (2) Recurse on each half.
3925
3926 doQuickSort(ary, comparator, p, q - 1);
3927 doQuickSort(ary, comparator, q + 1, r);
3928 }
3929}
3930
3931/**
3932 * Sort the given array in-place with the given comparator function.
3933 *
3934 * @param {Array} ary
3935 * An array to sort.
3936 * @param {function} comparator
3937 * Function to use to compare two items.
3938 */
3939exports.quickSort = function (ary, comparator) {
3940 doQuickSort(ary, comparator, 0, ary.length - 1);
3941};
3942
3943
3944/***/ })
3945
3946/******/ },
3947/******/ function(__webpack_require__) { // webpackRuntimeModules
3948/******/ "use strict";
3949/******/
3950/******/ /* webpack/runtime/node module decorator */
3951/******/ !function() {
3952/******/ __webpack_require__.nmd = function(module) {
3953/******/ module.paths = [];
3954/******/ if (!module.children) module.children = [];
3955/******/ Object.defineProperty(module, 'loaded', {
3956/******/ enumerable: true,
3957/******/ get: function() { return module.l; }
3958/******/ });
3959/******/ Object.defineProperty(module, 'id', {
3960/******/ enumerable: true,
3961/******/ get: function() { return module.i; }
3962/******/ });
3963/******/ return module;
3964/******/ };
3965/******/ }();
3966/******/
3967/******/ }
3968);
\No newline at end of file