@dcloudio/uni-stacktracey 2.0.1-alpha-35320220727001 → 2.0.1-alpha-35320220727002

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,12 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var fs = require('fs');
6
- var sourceMap = require('source-map');
5
+ var require$$0$2 = require('fs');
6
+ var require$$1$2 = require('path');
7
7
 
8
8
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
9
 
10
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
10
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
11
+ var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
11
12
 
12
13
  /* ------------------------------------------------------------------------ */
13
14
  const O = Object, isBrowser =
@@ -206,6 +207,3222 @@ function parseItem(e, maxColumnWidths, isMP) {
206
207
  /* ------------------------------------------------------------------------ */
207
208
  var StackTracey$1 = StackTracey;
208
209
 
210
+ /* -*- Mode: js; js-indent-level: 2; -*- */
211
+ /*
212
+ * Copyright 2011 Mozilla Foundation and contributors
213
+ * Licensed under the New BSD license. See LICENSE or:
214
+ * http://opensource.org/licenses/BSD-3-Clause
215
+ */
216
+
217
+ const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
218
+
219
+ /**
220
+ * Encode an integer in the range of 0 to 63 to a single base 64 digit.
221
+ */
222
+ var encode$1 = function(number) {
223
+ if (0 <= number && number < intToCharMap.length) {
224
+ return intToCharMap[number];
225
+ }
226
+ throw new TypeError("Must be between 0 and 63: " + number);
227
+ };
228
+
229
+ var base64$1 = {
230
+ encode: encode$1
231
+ };
232
+
233
+ var base64 = base64$1;
234
+
235
+ /* -*- Mode: js; js-indent-level: 2; -*- */
236
+
237
+ /*
238
+ * Copyright 2011 Mozilla Foundation and contributors
239
+ * Licensed under the New BSD license. See LICENSE or:
240
+ * http://opensource.org/licenses/BSD-3-Clause
241
+ *
242
+ * Based on the Base 64 VLQ implementation in Closure Compiler:
243
+ * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
244
+ *
245
+ * Copyright 2011 The Closure Compiler Authors. All rights reserved.
246
+ * Redistribution and use in source and binary forms, with or without
247
+ * modification, are permitted provided that the following conditions are
248
+ * met:
249
+ *
250
+ * * Redistributions of source code must retain the above copyright
251
+ * notice, this list of conditions and the following disclaimer.
252
+ * * Redistributions in binary form must reproduce the above
253
+ * copyright notice, this list of conditions and the following
254
+ * disclaimer in the documentation and/or other materials provided
255
+ * with the distribution.
256
+ * * Neither the name of Google Inc. nor the names of its
257
+ * contributors may be used to endorse or promote products derived
258
+ * from this software without specific prior written permission.
259
+ *
260
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
261
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
262
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
263
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
264
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
265
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
266
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
267
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
268
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
269
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
270
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271
+ */
272
+
273
+
274
+
275
+ // A single base 64 digit can contain 6 bits of data. For the base 64 variable
276
+ // length quantities we use in the source map spec, the first bit is the sign,
277
+ // the next four bits are the actual value, and the 6th bit is the
278
+ // continuation bit. The continuation bit tells us whether there are more
279
+ // digits in this value following this digit.
280
+ //
281
+ // Continuation
282
+ // | Sign
283
+ // | |
284
+ // V V
285
+ // 101011
286
+
287
+ const VLQ_BASE_SHIFT = 5;
288
+
289
+ // binary: 100000
290
+ const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
291
+
292
+ // binary: 011111
293
+ const VLQ_BASE_MASK = VLQ_BASE - 1;
294
+
295
+ // binary: 100000
296
+ const VLQ_CONTINUATION_BIT = VLQ_BASE;
297
+
298
+ /**
299
+ * Converts from a two-complement value to a value where the sign bit is
300
+ * placed in the least significant bit. For example, as decimals:
301
+ * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
302
+ * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
303
+ */
304
+ function toVLQSigned(aValue) {
305
+ return aValue < 0
306
+ ? ((-aValue) << 1) + 1
307
+ : (aValue << 1) + 0;
308
+ }
309
+
310
+ /**
311
+ * Returns the base 64 VLQ encoded value.
312
+ */
313
+ var encode = function base64VLQ_encode(aValue) {
314
+ let encoded = "";
315
+ let digit;
316
+
317
+ let vlq = toVLQSigned(aValue);
318
+
319
+ do {
320
+ digit = vlq & VLQ_BASE_MASK;
321
+ vlq >>>= VLQ_BASE_SHIFT;
322
+ if (vlq > 0) {
323
+ // There are still more digits in this value, so we must make sure the
324
+ // continuation bit is marked.
325
+ digit |= VLQ_CONTINUATION_BIT;
326
+ }
327
+ encoded += base64.encode(digit);
328
+ } while (vlq > 0);
329
+
330
+ return encoded;
331
+ };
332
+
333
+ var base64Vlq = {
334
+ encode: encode
335
+ };
336
+
337
+ function createCommonjsModule(fn) {
338
+ var module = { exports: {} };
339
+ return fn(module, module.exports), module.exports;
340
+ }
341
+
342
+ /* -*- Mode: js; js-indent-level: 2; -*- */
343
+
344
+ var util$1 = createCommonjsModule(function (module, exports) {
345
+ /*
346
+ * Copyright 2011 Mozilla Foundation and contributors
347
+ * Licensed under the New BSD license. See LICENSE or:
348
+ * http://opensource.org/licenses/BSD-3-Clause
349
+ */
350
+
351
+ /**
352
+ * This is a helper function for getting values from parameter/options
353
+ * objects.
354
+ *
355
+ * @param args The object we are extracting values from
356
+ * @param name The name of the property we are getting.
357
+ * @param defaultValue An optional value to return if the property is missing
358
+ * from the object. If this is not specified and the property is missing, an
359
+ * error will be thrown.
360
+ */
361
+ function getArg(aArgs, aName, aDefaultValue) {
362
+ if (aName in aArgs) {
363
+ return aArgs[aName];
364
+ } else if (arguments.length === 3) {
365
+ return aDefaultValue;
366
+ }
367
+ throw new Error('"' + aName + '" is a required argument.');
368
+
369
+ }
370
+ exports.getArg = getArg;
371
+
372
+ const urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
373
+ const dataUrlRegexp = /^data:.+\,.+$/;
374
+
375
+ function urlParse(aUrl) {
376
+ const match = aUrl.match(urlRegexp);
377
+ if (!match) {
378
+ return null;
379
+ }
380
+ return {
381
+ scheme: match[1],
382
+ auth: match[2],
383
+ host: match[3],
384
+ port: match[4],
385
+ path: match[5]
386
+ };
387
+ }
388
+ exports.urlParse = urlParse;
389
+
390
+ function urlGenerate(aParsedUrl) {
391
+ let url = "";
392
+ if (aParsedUrl.scheme) {
393
+ url += aParsedUrl.scheme + ":";
394
+ }
395
+ url += "//";
396
+ if (aParsedUrl.auth) {
397
+ url += aParsedUrl.auth + "@";
398
+ }
399
+ if (aParsedUrl.host) {
400
+ url += aParsedUrl.host;
401
+ }
402
+ if (aParsedUrl.port) {
403
+ url += ":" + aParsedUrl.port;
404
+ }
405
+ if (aParsedUrl.path) {
406
+ url += aParsedUrl.path;
407
+ }
408
+ return url;
409
+ }
410
+ exports.urlGenerate = urlGenerate;
411
+
412
+ const MAX_CACHED_INPUTS = 32;
413
+
414
+ /**
415
+ * Takes some function `f(input) -> result` and returns a memoized version of
416
+ * `f`.
417
+ *
418
+ * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
419
+ * memoization is a dumb-simple, linear least-recently-used cache.
420
+ */
421
+ function lruMemoize(f) {
422
+ const cache = [];
423
+
424
+ return function(input) {
425
+ for (let i = 0; i < cache.length; i++) {
426
+ if (cache[i].input === input) {
427
+ const temp = cache[0];
428
+ cache[0] = cache[i];
429
+ cache[i] = temp;
430
+ return cache[0].result;
431
+ }
432
+ }
433
+
434
+ const result = f(input);
435
+
436
+ cache.unshift({
437
+ input,
438
+ result,
439
+ });
440
+
441
+ if (cache.length > MAX_CACHED_INPUTS) {
442
+ cache.pop();
443
+ }
444
+
445
+ return result;
446
+ };
447
+ }
448
+
449
+ /**
450
+ * Normalizes a path, or the path portion of a URL:
451
+ *
452
+ * - Replaces consecutive slashes with one slash.
453
+ * - Removes unnecessary '.' parts.
454
+ * - Removes unnecessary '<dir>/..' parts.
455
+ *
456
+ * Based on code in the Node.js 'path' core module.
457
+ *
458
+ * @param aPath The path or url to normalize.
459
+ */
460
+ const normalize = lruMemoize(function normalize(aPath) {
461
+ let path = aPath;
462
+ const url = urlParse(aPath);
463
+ if (url) {
464
+ if (!url.path) {
465
+ return aPath;
466
+ }
467
+ path = url.path;
468
+ }
469
+ const isAbsolute = exports.isAbsolute(path);
470
+
471
+ // Split the path into parts between `/` characters. This is much faster than
472
+ // using `.split(/\/+/g)`.
473
+ const parts = [];
474
+ let start = 0;
475
+ let i = 0;
476
+ while (true) {
477
+ start = i;
478
+ i = path.indexOf("/", start);
479
+ if (i === -1) {
480
+ parts.push(path.slice(start));
481
+ break;
482
+ } else {
483
+ parts.push(path.slice(start, i));
484
+ while (i < path.length && path[i] === "/") {
485
+ i++;
486
+ }
487
+ }
488
+ }
489
+
490
+ let up = 0;
491
+ for (i = parts.length - 1; i >= 0; i--) {
492
+ const part = parts[i];
493
+ if (part === ".") {
494
+ parts.splice(i, 1);
495
+ } else if (part === "..") {
496
+ up++;
497
+ } else if (up > 0) {
498
+ if (part === "") {
499
+ // The first part is blank if the path is absolute. Trying to go
500
+ // above the root is a no-op. Therefore we can remove all '..' parts
501
+ // directly after the root.
502
+ parts.splice(i + 1, up);
503
+ up = 0;
504
+ } else {
505
+ parts.splice(i, 2);
506
+ up--;
507
+ }
508
+ }
509
+ }
510
+ path = parts.join("/");
511
+
512
+ if (path === "") {
513
+ path = isAbsolute ? "/" : ".";
514
+ }
515
+
516
+ if (url) {
517
+ url.path = path;
518
+ return urlGenerate(url);
519
+ }
520
+ return path;
521
+ });
522
+ exports.normalize = normalize;
523
+
524
+ /**
525
+ * Joins two paths/URLs.
526
+ *
527
+ * @param aRoot The root path or URL.
528
+ * @param aPath The path or URL to be joined with the root.
529
+ *
530
+ * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
531
+ * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
532
+ * first.
533
+ * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
534
+ * is updated with the result and aRoot is returned. Otherwise the result
535
+ * is returned.
536
+ * - If aPath is absolute, the result is aPath.
537
+ * - Otherwise the two paths are joined with a slash.
538
+ * - Joining for example 'http://' and 'www.example.com' is also supported.
539
+ */
540
+ function join(aRoot, aPath) {
541
+ if (aRoot === "") {
542
+ aRoot = ".";
543
+ }
544
+ if (aPath === "") {
545
+ aPath = ".";
546
+ }
547
+ const aPathUrl = urlParse(aPath);
548
+ const aRootUrl = urlParse(aRoot);
549
+ if (aRootUrl) {
550
+ aRoot = aRootUrl.path || "/";
551
+ }
552
+
553
+ // `join(foo, '//www.example.org')`
554
+ if (aPathUrl && !aPathUrl.scheme) {
555
+ if (aRootUrl) {
556
+ aPathUrl.scheme = aRootUrl.scheme;
557
+ }
558
+ return urlGenerate(aPathUrl);
559
+ }
560
+
561
+ if (aPathUrl || aPath.match(dataUrlRegexp)) {
562
+ return aPath;
563
+ }
564
+
565
+ // `join('http://', 'www.example.com')`
566
+ if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
567
+ aRootUrl.host = aPath;
568
+ return urlGenerate(aRootUrl);
569
+ }
570
+
571
+ const joined = aPath.charAt(0) === "/"
572
+ ? aPath
573
+ : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath);
574
+
575
+ if (aRootUrl) {
576
+ aRootUrl.path = joined;
577
+ return urlGenerate(aRootUrl);
578
+ }
579
+ return joined;
580
+ }
581
+ exports.join = join;
582
+
583
+ exports.isAbsolute = function(aPath) {
584
+ return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
585
+ };
586
+
587
+ /**
588
+ * Make a path relative to a URL or another path.
589
+ *
590
+ * @param aRoot The root path or URL.
591
+ * @param aPath The path or URL to be made relative to aRoot.
592
+ */
593
+ function relative(aRoot, aPath) {
594
+ if (aRoot === "") {
595
+ aRoot = ".";
596
+ }
597
+
598
+ aRoot = aRoot.replace(/\/$/, "");
599
+
600
+ // It is possible for the path to be above the root. In this case, simply
601
+ // checking whether the root is a prefix of the path won't work. Instead, we
602
+ // need to remove components from the root one by one, until either we find
603
+ // a prefix that fits, or we run out of components to remove.
604
+ let level = 0;
605
+ while (aPath.indexOf(aRoot + "/") !== 0) {
606
+ const index = aRoot.lastIndexOf("/");
607
+ if (index < 0) {
608
+ return aPath;
609
+ }
610
+
611
+ // If the only part of the root that is left is the scheme (i.e. http://,
612
+ // file:///, etc.), one or more slashes (/), or simply nothing at all, we
613
+ // have exhausted all components, so the path is not relative to the root.
614
+ aRoot = aRoot.slice(0, index);
615
+ if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
616
+ return aPath;
617
+ }
618
+
619
+ ++level;
620
+ }
621
+
622
+ // Make sure we add a "../" for each component we removed from the root.
623
+ return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
624
+ }
625
+ exports.relative = relative;
626
+
627
+ const supportsNullProto = (function() {
628
+ const obj = Object.create(null);
629
+ return !("__proto__" in obj);
630
+ }());
631
+
632
+ function identity(s) {
633
+ return s;
634
+ }
635
+
636
+ /**
637
+ * Because behavior goes wacky when you set `__proto__` on objects, we
638
+ * have to prefix all the strings in our set with an arbitrary character.
639
+ *
640
+ * See https://github.com/mozilla/source-map/pull/31 and
641
+ * https://github.com/mozilla/source-map/issues/30
642
+ *
643
+ * @param String aStr
644
+ */
645
+ function toSetString(aStr) {
646
+ if (isProtoString(aStr)) {
647
+ return "$" + aStr;
648
+ }
649
+
650
+ return aStr;
651
+ }
652
+ exports.toSetString = supportsNullProto ? identity : toSetString;
653
+
654
+ function fromSetString(aStr) {
655
+ if (isProtoString(aStr)) {
656
+ return aStr.slice(1);
657
+ }
658
+
659
+ return aStr;
660
+ }
661
+ exports.fromSetString = supportsNullProto ? identity : fromSetString;
662
+
663
+ function isProtoString(s) {
664
+ if (!s) {
665
+ return false;
666
+ }
667
+
668
+ const length = s.length;
669
+
670
+ if (length < 9 /* "__proto__".length */) {
671
+ return false;
672
+ }
673
+
674
+ /* eslint-disable no-multi-spaces */
675
+ if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
676
+ s.charCodeAt(length - 2) !== 95 /* '_' */ ||
677
+ s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
678
+ s.charCodeAt(length - 4) !== 116 /* 't' */ ||
679
+ s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
680
+ s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
681
+ s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
682
+ s.charCodeAt(length - 8) !== 95 /* '_' */ ||
683
+ s.charCodeAt(length - 9) !== 95 /* '_' */) {
684
+ return false;
685
+ }
686
+ /* eslint-enable no-multi-spaces */
687
+
688
+ for (let i = length - 10; i >= 0; i--) {
689
+ if (s.charCodeAt(i) !== 36 /* '$' */) {
690
+ return false;
691
+ }
692
+ }
693
+
694
+ return true;
695
+ }
696
+
697
+ /**
698
+ * Comparator between two mappings where the original positions are compared.
699
+ *
700
+ * Optionally pass in `true` as `onlyCompareGenerated` to consider two
701
+ * mappings with the same original source/line/column, but different generated
702
+ * line and column the same. Useful when searching for a mapping with a
703
+ * stubbed out mapping.
704
+ */
705
+ function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
706
+ let cmp = strcmp(mappingA.source, mappingB.source);
707
+ if (cmp !== 0) {
708
+ return cmp;
709
+ }
710
+
711
+ cmp = mappingA.originalLine - mappingB.originalLine;
712
+ if (cmp !== 0) {
713
+ return cmp;
714
+ }
715
+
716
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
717
+ if (cmp !== 0 || onlyCompareOriginal) {
718
+ return cmp;
719
+ }
720
+
721
+ cmp = mappingA.generatedColumn - mappingB.generatedColumn;
722
+ if (cmp !== 0) {
723
+ return cmp;
724
+ }
725
+
726
+ cmp = mappingA.generatedLine - mappingB.generatedLine;
727
+ if (cmp !== 0) {
728
+ return cmp;
729
+ }
730
+
731
+ return strcmp(mappingA.name, mappingB.name);
732
+ }
733
+ exports.compareByOriginalPositions = compareByOriginalPositions;
734
+
735
+ /**
736
+ * Comparator between two mappings with deflated source and name indices where
737
+ * the generated positions are compared.
738
+ *
739
+ * Optionally pass in `true` as `onlyCompareGenerated` to consider two
740
+ * mappings with the same generated line and column, but different
741
+ * source/name/original line and column the same. Useful when searching for a
742
+ * mapping with a stubbed out mapping.
743
+ */
744
+ function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
745
+ let cmp = mappingA.generatedLine - mappingB.generatedLine;
746
+ if (cmp !== 0) {
747
+ return cmp;
748
+ }
749
+
750
+ cmp = mappingA.generatedColumn - mappingB.generatedColumn;
751
+ if (cmp !== 0 || onlyCompareGenerated) {
752
+ return cmp;
753
+ }
754
+
755
+ cmp = strcmp(mappingA.source, mappingB.source);
756
+ if (cmp !== 0) {
757
+ return cmp;
758
+ }
759
+
760
+ cmp = mappingA.originalLine - mappingB.originalLine;
761
+ if (cmp !== 0) {
762
+ return cmp;
763
+ }
764
+
765
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
766
+ if (cmp !== 0) {
767
+ return cmp;
768
+ }
769
+
770
+ return strcmp(mappingA.name, mappingB.name);
771
+ }
772
+ exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
773
+
774
+ function strcmp(aStr1, aStr2) {
775
+ if (aStr1 === aStr2) {
776
+ return 0;
777
+ }
778
+
779
+ if (aStr1 === null) {
780
+ return 1; // aStr2 !== null
781
+ }
782
+
783
+ if (aStr2 === null) {
784
+ return -1; // aStr1 !== null
785
+ }
786
+
787
+ if (aStr1 > aStr2) {
788
+ return 1;
789
+ }
790
+
791
+ return -1;
792
+ }
793
+
794
+ /**
795
+ * Comparator between two mappings with inflated source and name strings where
796
+ * the generated positions are compared.
797
+ */
798
+ function compareByGeneratedPositionsInflated(mappingA, mappingB) {
799
+ let cmp = mappingA.generatedLine - mappingB.generatedLine;
800
+ if (cmp !== 0) {
801
+ return cmp;
802
+ }
803
+
804
+ cmp = mappingA.generatedColumn - mappingB.generatedColumn;
805
+ if (cmp !== 0) {
806
+ return cmp;
807
+ }
808
+
809
+ cmp = strcmp(mappingA.source, mappingB.source);
810
+ if (cmp !== 0) {
811
+ return cmp;
812
+ }
813
+
814
+ cmp = mappingA.originalLine - mappingB.originalLine;
815
+ if (cmp !== 0) {
816
+ return cmp;
817
+ }
818
+
819
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
820
+ if (cmp !== 0) {
821
+ return cmp;
822
+ }
823
+
824
+ return strcmp(mappingA.name, mappingB.name);
825
+ }
826
+ exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
827
+
828
+ /**
829
+ * Strip any JSON XSSI avoidance prefix from the string (as documented
830
+ * in the source maps specification), and then parse the string as
831
+ * JSON.
832
+ */
833
+ function parseSourceMapInput(str) {
834
+ return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
835
+ }
836
+ exports.parseSourceMapInput = parseSourceMapInput;
837
+
838
+ /**
839
+ * Compute the URL of a source given the the source root, the source's
840
+ * URL, and the source map's URL.
841
+ */
842
+ function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
843
+ sourceURL = sourceURL || "";
844
+
845
+ if (sourceRoot) {
846
+ // This follows what Chrome does.
847
+ if (sourceRoot[sourceRoot.length - 1] !== "/" && sourceURL[0] !== "/") {
848
+ sourceRoot += "/";
849
+ }
850
+ // The spec says:
851
+ // Line 4: An optional source root, useful for relocating source
852
+ // files on a server or removing repeated values in the
853
+ // “sources” entry. This value is prepended to the individual
854
+ // entries in the “source” field.
855
+ sourceURL = sourceRoot + sourceURL;
856
+ }
857
+
858
+ // Historically, SourceMapConsumer did not take the sourceMapURL as
859
+ // a parameter. This mode is still somewhat supported, which is why
860
+ // this code block is conditional. However, it's preferable to pass
861
+ // the source map URL to SourceMapConsumer, so that this function
862
+ // can implement the source URL resolution algorithm as outlined in
863
+ // the spec. This block is basically the equivalent of:
864
+ // new URL(sourceURL, sourceMapURL).toString()
865
+ // ... except it avoids using URL, which wasn't available in the
866
+ // older releases of node still supported by this library.
867
+ //
868
+ // The spec says:
869
+ // If the sources are not absolute URLs after prepending of the
870
+ // “sourceRoot”, the sources are resolved relative to the
871
+ // SourceMap (like resolving script src in a html document).
872
+ if (sourceMapURL) {
873
+ const parsed = urlParse(sourceMapURL);
874
+ if (!parsed) {
875
+ throw new Error("sourceMapURL could not be parsed");
876
+ }
877
+ if (parsed.path) {
878
+ // Strip the last path component, but keep the "/".
879
+ const index = parsed.path.lastIndexOf("/");
880
+ if (index >= 0) {
881
+ parsed.path = parsed.path.substring(0, index + 1);
882
+ }
883
+ }
884
+ sourceURL = join(urlGenerate(parsed), sourceURL);
885
+ }
886
+
887
+ return normalize(sourceURL);
888
+ }
889
+ exports.computeSourceURL = computeSourceURL;
890
+ });
891
+
892
+ /* -*- Mode: js; js-indent-level: 2; -*- */
893
+ /*
894
+ * Copyright 2011 Mozilla Foundation and contributors
895
+ * Licensed under the New BSD license. See LICENSE or:
896
+ * http://opensource.org/licenses/BSD-3-Clause
897
+ */
898
+
899
+ /**
900
+ * A data structure which is a combination of an array and a set. Adding a new
901
+ * member is O(1), testing for membership is O(1), and finding the index of an
902
+ * element is O(1). Removing elements from the set is not supported. Only
903
+ * strings are supported for membership.
904
+ */
905
+ class ArraySet$2 {
906
+ constructor() {
907
+ this._array = [];
908
+ this._set = new Map();
909
+ }
910
+
911
+ /**
912
+ * Static method for creating ArraySet instances from an existing array.
913
+ */
914
+ static fromArray(aArray, aAllowDuplicates) {
915
+ const set = new ArraySet$2();
916
+ for (let i = 0, len = aArray.length; i < len; i++) {
917
+ set.add(aArray[i], aAllowDuplicates);
918
+ }
919
+ return set;
920
+ }
921
+
922
+ /**
923
+ * Return how many unique items are in this ArraySet. If duplicates have been
924
+ * added, than those do not count towards the size.
925
+ *
926
+ * @returns Number
927
+ */
928
+ size() {
929
+ return this._set.size;
930
+ }
931
+
932
+ /**
933
+ * Add the given string to this set.
934
+ *
935
+ * @param String aStr
936
+ */
937
+ add(aStr, aAllowDuplicates) {
938
+ const isDuplicate = this.has(aStr);
939
+ const idx = this._array.length;
940
+ if (!isDuplicate || aAllowDuplicates) {
941
+ this._array.push(aStr);
942
+ }
943
+ if (!isDuplicate) {
944
+ this._set.set(aStr, idx);
945
+ }
946
+ }
947
+
948
+ /**
949
+ * Is the given string a member of this set?
950
+ *
951
+ * @param String aStr
952
+ */
953
+ has(aStr) {
954
+ return this._set.has(aStr);
955
+ }
956
+
957
+ /**
958
+ * What is the index of the given string in the array?
959
+ *
960
+ * @param String aStr
961
+ */
962
+ indexOf(aStr) {
963
+ const idx = this._set.get(aStr);
964
+ if (idx >= 0) {
965
+ return idx;
966
+ }
967
+ throw new Error('"' + aStr + '" is not in the set.');
968
+ }
969
+
970
+ /**
971
+ * What is the element at the given index?
972
+ *
973
+ * @param Number aIdx
974
+ */
975
+ at(aIdx) {
976
+ if (aIdx >= 0 && aIdx < this._array.length) {
977
+ return this._array[aIdx];
978
+ }
979
+ throw new Error("No element indexed by " + aIdx);
980
+ }
981
+
982
+ /**
983
+ * Returns the array representation of this set (which has the proper indices
984
+ * indicated by indexOf). Note that this is a copy of the internal array used
985
+ * for storing the members so that no one can mess with internal state.
986
+ */
987
+ toArray() {
988
+ return this._array.slice();
989
+ }
990
+ }
991
+ var ArraySet_1 = ArraySet$2;
992
+
993
+ var arraySet = {
994
+ ArraySet: ArraySet_1
995
+ };
996
+
997
+ var util = util$1;
998
+
999
+ /* -*- Mode: js; js-indent-level: 2; -*- */
1000
+
1001
+ /*
1002
+ * Copyright 2014 Mozilla Foundation and contributors
1003
+ * Licensed under the New BSD license. See LICENSE or:
1004
+ * http://opensource.org/licenses/BSD-3-Clause
1005
+ */
1006
+
1007
+
1008
+
1009
+ /**
1010
+ * Determine whether mappingB is after mappingA with respect to generated
1011
+ * position.
1012
+ */
1013
+ function generatedPositionAfter(mappingA, mappingB) {
1014
+ // Optimized for most common case
1015
+ const lineA = mappingA.generatedLine;
1016
+ const lineB = mappingB.generatedLine;
1017
+ const columnA = mappingA.generatedColumn;
1018
+ const columnB = mappingB.generatedColumn;
1019
+ return lineB > lineA || lineB == lineA && columnB >= columnA ||
1020
+ util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
1021
+ }
1022
+
1023
+ /**
1024
+ * A data structure to provide a sorted view of accumulated mappings in a
1025
+ * performance conscious manner. It trades a negligible overhead in general
1026
+ * case for a large speedup in case of mappings being added in order.
1027
+ */
1028
+ class MappingList$1 {
1029
+ constructor() {
1030
+ this._array = [];
1031
+ this._sorted = true;
1032
+ // Serves as infimum
1033
+ this._last = {generatedLine: -1, generatedColumn: 0};
1034
+ }
1035
+
1036
+ /**
1037
+ * Iterate through internal items. This method takes the same arguments that
1038
+ * `Array.prototype.forEach` takes.
1039
+ *
1040
+ * NOTE: The order of the mappings is NOT guaranteed.
1041
+ */
1042
+ unsortedForEach(aCallback, aThisArg) {
1043
+ this._array.forEach(aCallback, aThisArg);
1044
+ }
1045
+
1046
+ /**
1047
+ * Add the given source mapping.
1048
+ *
1049
+ * @param Object aMapping
1050
+ */
1051
+ add(aMapping) {
1052
+ if (generatedPositionAfter(this._last, aMapping)) {
1053
+ this._last = aMapping;
1054
+ this._array.push(aMapping);
1055
+ } else {
1056
+ this._sorted = false;
1057
+ this._array.push(aMapping);
1058
+ }
1059
+ }
1060
+
1061
+ /**
1062
+ * Returns the flat, sorted array of mappings. The mappings are sorted by
1063
+ * generated position.
1064
+ *
1065
+ * WARNING: This method returns internal data without copying, for
1066
+ * performance. The return value must NOT be mutated, and should be treated as
1067
+ * an immutable borrow. If you want to take ownership, you must make your own
1068
+ * copy.
1069
+ */
1070
+ toArray() {
1071
+ if (!this._sorted) {
1072
+ this._array.sort(util.compareByGeneratedPositionsInflated);
1073
+ this._sorted = true;
1074
+ }
1075
+ return this._array;
1076
+ }
1077
+ }
1078
+
1079
+ var MappingList_1 = MappingList$1;
1080
+
1081
+ var mappingList = {
1082
+ MappingList: MappingList_1
1083
+ };
1084
+
1085
+ var base64VLQ = base64Vlq;
1086
+
1087
+ var require$$0$1 = arraySet;
1088
+
1089
+ var require$$1$1 = mappingList;
1090
+
1091
+ /* -*- Mode: js; js-indent-level: 2; -*- */
1092
+
1093
+ /*
1094
+ * Copyright 2011 Mozilla Foundation and contributors
1095
+ * Licensed under the New BSD license. See LICENSE or:
1096
+ * http://opensource.org/licenses/BSD-3-Clause
1097
+ */
1098
+
1099
+
1100
+
1101
+ const ArraySet$1 = require$$0$1.ArraySet;
1102
+ const MappingList = require$$1$1.MappingList;
1103
+
1104
+ /**
1105
+ * An instance of the SourceMapGenerator represents a source map which is
1106
+ * being built incrementally. You may pass an object with the following
1107
+ * properties:
1108
+ *
1109
+ * - file: The filename of the generated source.
1110
+ * - sourceRoot: A root for all relative URLs in this source map.
1111
+ */
1112
+ class SourceMapGenerator$1 {
1113
+ constructor(aArgs) {
1114
+ if (!aArgs) {
1115
+ aArgs = {};
1116
+ }
1117
+ this._file = util.getArg(aArgs, "file", null);
1118
+ this._sourceRoot = util.getArg(aArgs, "sourceRoot", null);
1119
+ this._skipValidation = util.getArg(aArgs, "skipValidation", false);
1120
+ this._sources = new ArraySet$1();
1121
+ this._names = new ArraySet$1();
1122
+ this._mappings = new MappingList();
1123
+ this._sourcesContents = null;
1124
+ }
1125
+
1126
+ /**
1127
+ * Creates a new SourceMapGenerator based on a SourceMapConsumer
1128
+ *
1129
+ * @param aSourceMapConsumer The SourceMap.
1130
+ */
1131
+ static fromSourceMap(aSourceMapConsumer) {
1132
+ const sourceRoot = aSourceMapConsumer.sourceRoot;
1133
+ const generator = new SourceMapGenerator$1({
1134
+ file: aSourceMapConsumer.file,
1135
+ sourceRoot
1136
+ });
1137
+ aSourceMapConsumer.eachMapping(function(mapping) {
1138
+ const newMapping = {
1139
+ generated: {
1140
+ line: mapping.generatedLine,
1141
+ column: mapping.generatedColumn
1142
+ }
1143
+ };
1144
+
1145
+ if (mapping.source != null) {
1146
+ newMapping.source = mapping.source;
1147
+ if (sourceRoot != null) {
1148
+ newMapping.source = util.relative(sourceRoot, newMapping.source);
1149
+ }
1150
+
1151
+ newMapping.original = {
1152
+ line: mapping.originalLine,
1153
+ column: mapping.originalColumn
1154
+ };
1155
+
1156
+ if (mapping.name != null) {
1157
+ newMapping.name = mapping.name;
1158
+ }
1159
+ }
1160
+
1161
+ generator.addMapping(newMapping);
1162
+ });
1163
+ aSourceMapConsumer.sources.forEach(function(sourceFile) {
1164
+ let sourceRelative = sourceFile;
1165
+ if (sourceRoot !== null) {
1166
+ sourceRelative = util.relative(sourceRoot, sourceFile);
1167
+ }
1168
+
1169
+ if (!generator._sources.has(sourceRelative)) {
1170
+ generator._sources.add(sourceRelative);
1171
+ }
1172
+
1173
+ const content = aSourceMapConsumer.sourceContentFor(sourceFile);
1174
+ if (content != null) {
1175
+ generator.setSourceContent(sourceFile, content);
1176
+ }
1177
+ });
1178
+ return generator;
1179
+ }
1180
+
1181
+ /**
1182
+ * Add a single mapping from original source line and column to the generated
1183
+ * source's line and column for this source map being created. The mapping
1184
+ * object should have the following properties:
1185
+ *
1186
+ * - generated: An object with the generated line and column positions.
1187
+ * - original: An object with the original line and column positions.
1188
+ * - source: The original source file (relative to the sourceRoot).
1189
+ * - name: An optional original token name for this mapping.
1190
+ */
1191
+ addMapping(aArgs) {
1192
+ const generated = util.getArg(aArgs, "generated");
1193
+ const original = util.getArg(aArgs, "original", null);
1194
+ let source = util.getArg(aArgs, "source", null);
1195
+ let name = util.getArg(aArgs, "name", null);
1196
+
1197
+ if (!this._skipValidation) {
1198
+ this._validateMapping(generated, original, source, name);
1199
+ }
1200
+
1201
+ if (source != null) {
1202
+ source = String(source);
1203
+ if (!this._sources.has(source)) {
1204
+ this._sources.add(source);
1205
+ }
1206
+ }
1207
+
1208
+ if (name != null) {
1209
+ name = String(name);
1210
+ if (!this._names.has(name)) {
1211
+ this._names.add(name);
1212
+ }
1213
+ }
1214
+
1215
+ this._mappings.add({
1216
+ generatedLine: generated.line,
1217
+ generatedColumn: generated.column,
1218
+ originalLine: original != null && original.line,
1219
+ originalColumn: original != null && original.column,
1220
+ source,
1221
+ name
1222
+ });
1223
+ }
1224
+
1225
+ /**
1226
+ * Set the source content for a source file.
1227
+ */
1228
+ setSourceContent(aSourceFile, aSourceContent) {
1229
+ let source = aSourceFile;
1230
+ if (this._sourceRoot != null) {
1231
+ source = util.relative(this._sourceRoot, source);
1232
+ }
1233
+
1234
+ if (aSourceContent != null) {
1235
+ // Add the source content to the _sourcesContents map.
1236
+ // Create a new _sourcesContents map if the property is null.
1237
+ if (!this._sourcesContents) {
1238
+ this._sourcesContents = Object.create(null);
1239
+ }
1240
+ this._sourcesContents[util.toSetString(source)] = aSourceContent;
1241
+ } else if (this._sourcesContents) {
1242
+ // Remove the source file from the _sourcesContents map.
1243
+ // If the _sourcesContents map is empty, set the property to null.
1244
+ delete this._sourcesContents[util.toSetString(source)];
1245
+ if (Object.keys(this._sourcesContents).length === 0) {
1246
+ this._sourcesContents = null;
1247
+ }
1248
+ }
1249
+ }
1250
+
1251
+ /**
1252
+ * Applies the mappings of a sub-source-map for a specific source file to the
1253
+ * source map being generated. Each mapping to the supplied source file is
1254
+ * rewritten using the supplied source map. Note: The resolution for the
1255
+ * resulting mappings is the minimium of this map and the supplied map.
1256
+ *
1257
+ * @param aSourceMapConsumer The source map to be applied.
1258
+ * @param aSourceFile Optional. The filename of the source file.
1259
+ * If omitted, SourceMapConsumer's file property will be used.
1260
+ * @param aSourceMapPath Optional. The dirname of the path to the source map
1261
+ * to be applied. If relative, it is relative to the SourceMapConsumer.
1262
+ * This parameter is needed when the two source maps aren't in the same
1263
+ * directory, and the source map to be applied contains relative source
1264
+ * paths. If so, those relative source paths need to be rewritten
1265
+ * relative to the SourceMapGenerator.
1266
+ */
1267
+ applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
1268
+ let sourceFile = aSourceFile;
1269
+ // If aSourceFile is omitted, we will use the file property of the SourceMap
1270
+ if (aSourceFile == null) {
1271
+ if (aSourceMapConsumer.file == null) {
1272
+ throw new Error(
1273
+ "SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, " +
1274
+ 'or the source map\'s "file" property. Both were omitted.'
1275
+ );
1276
+ }
1277
+ sourceFile = aSourceMapConsumer.file;
1278
+ }
1279
+ const sourceRoot = this._sourceRoot;
1280
+ // Make "sourceFile" relative if an absolute Url is passed.
1281
+ if (sourceRoot != null) {
1282
+ sourceFile = util.relative(sourceRoot, sourceFile);
1283
+ }
1284
+ // Applying the SourceMap can add and remove items from the sources and
1285
+ // the names array.
1286
+ const newSources = this._mappings.toArray().length > 0
1287
+ ? new ArraySet$1()
1288
+ : this._sources;
1289
+ const newNames = new ArraySet$1();
1290
+
1291
+ // Find mappings for the "sourceFile"
1292
+ this._mappings.unsortedForEach(function(mapping) {
1293
+ if (mapping.source === sourceFile && mapping.originalLine != null) {
1294
+ // Check if it can be mapped by the source map, then update the mapping.
1295
+ const original = aSourceMapConsumer.originalPositionFor({
1296
+ line: mapping.originalLine,
1297
+ column: mapping.originalColumn
1298
+ });
1299
+ if (original.source != null) {
1300
+ // Copy mapping
1301
+ mapping.source = original.source;
1302
+ if (aSourceMapPath != null) {
1303
+ mapping.source = util.join(aSourceMapPath, mapping.source);
1304
+ }
1305
+ if (sourceRoot != null) {
1306
+ mapping.source = util.relative(sourceRoot, mapping.source);
1307
+ }
1308
+ mapping.originalLine = original.line;
1309
+ mapping.originalColumn = original.column;
1310
+ if (original.name != null) {
1311
+ mapping.name = original.name;
1312
+ }
1313
+ }
1314
+ }
1315
+
1316
+ const source = mapping.source;
1317
+ if (source != null && !newSources.has(source)) {
1318
+ newSources.add(source);
1319
+ }
1320
+
1321
+ const name = mapping.name;
1322
+ if (name != null && !newNames.has(name)) {
1323
+ newNames.add(name);
1324
+ }
1325
+
1326
+ }, this);
1327
+ this._sources = newSources;
1328
+ this._names = newNames;
1329
+
1330
+ // Copy sourcesContents of applied map.
1331
+ aSourceMapConsumer.sources.forEach(function(srcFile) {
1332
+ const content = aSourceMapConsumer.sourceContentFor(srcFile);
1333
+ if (content != null) {
1334
+ if (aSourceMapPath != null) {
1335
+ srcFile = util.join(aSourceMapPath, srcFile);
1336
+ }
1337
+ if (sourceRoot != null) {
1338
+ srcFile = util.relative(sourceRoot, srcFile);
1339
+ }
1340
+ this.setSourceContent(srcFile, content);
1341
+ }
1342
+ }, this);
1343
+ }
1344
+
1345
+ /**
1346
+ * A mapping can have one of the three levels of data:
1347
+ *
1348
+ * 1. Just the generated position.
1349
+ * 2. The Generated position, original position, and original source.
1350
+ * 3. Generated and original position, original source, as well as a name
1351
+ * token.
1352
+ *
1353
+ * To maintain consistency, we validate that any new mapping being added falls
1354
+ * in to one of these categories.
1355
+ */
1356
+ _validateMapping(aGenerated, aOriginal, aSource, aName) {
1357
+ // When aOriginal is truthy but has empty values for .line and .column,
1358
+ // it is most likely a programmer error. In this case we throw a very
1359
+ // specific error message to try to guide them the right way.
1360
+ // For example: https://github.com/Polymer/polymer-bundler/pull/519
1361
+ if (aOriginal && typeof aOriginal.line !== "number" && typeof aOriginal.column !== "number") {
1362
+ throw new Error(
1363
+ "original.line and original.column are not numbers -- you probably meant to omit " +
1364
+ "the original mapping entirely and only map the generated position. If so, pass " +
1365
+ "null for the original mapping instead of an object with empty or null values."
1366
+ );
1367
+ }
1368
+
1369
+ if (aGenerated && "line" in aGenerated && "column" in aGenerated
1370
+ && aGenerated.line > 0 && aGenerated.column >= 0
1371
+ && !aOriginal && !aSource && !aName) ; else if (aGenerated && "line" in aGenerated && "column" in aGenerated
1372
+ && aOriginal && "line" in aOriginal && "column" in aOriginal
1373
+ && aGenerated.line > 0 && aGenerated.column >= 0
1374
+ && aOriginal.line > 0 && aOriginal.column >= 0
1375
+ && aSource) ; else {
1376
+ throw new Error("Invalid mapping: " + JSON.stringify({
1377
+ generated: aGenerated,
1378
+ source: aSource,
1379
+ original: aOriginal,
1380
+ name: aName
1381
+ }));
1382
+ }
1383
+ }
1384
+
1385
+ /**
1386
+ * Serialize the accumulated mappings in to the stream of base 64 VLQs
1387
+ * specified by the source map format.
1388
+ */
1389
+ _serializeMappings() {
1390
+ let previousGeneratedColumn = 0;
1391
+ let previousGeneratedLine = 1;
1392
+ let previousOriginalColumn = 0;
1393
+ let previousOriginalLine = 0;
1394
+ let previousName = 0;
1395
+ let previousSource = 0;
1396
+ let result = "";
1397
+ let next;
1398
+ let mapping;
1399
+ let nameIdx;
1400
+ let sourceIdx;
1401
+
1402
+ const mappings = this._mappings.toArray();
1403
+ for (let i = 0, len = mappings.length; i < len; i++) {
1404
+ mapping = mappings[i];
1405
+ next = "";
1406
+
1407
+ if (mapping.generatedLine !== previousGeneratedLine) {
1408
+ previousGeneratedColumn = 0;
1409
+ while (mapping.generatedLine !== previousGeneratedLine) {
1410
+ next += ";";
1411
+ previousGeneratedLine++;
1412
+ }
1413
+ } else if (i > 0) {
1414
+ if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
1415
+ continue;
1416
+ }
1417
+ next += ",";
1418
+ }
1419
+
1420
+ next += base64VLQ.encode(mapping.generatedColumn
1421
+ - previousGeneratedColumn);
1422
+ previousGeneratedColumn = mapping.generatedColumn;
1423
+
1424
+ if (mapping.source != null) {
1425
+ sourceIdx = this._sources.indexOf(mapping.source);
1426
+ next += base64VLQ.encode(sourceIdx - previousSource);
1427
+ previousSource = sourceIdx;
1428
+
1429
+ // lines are stored 0-based in SourceMap spec version 3
1430
+ next += base64VLQ.encode(mapping.originalLine - 1
1431
+ - previousOriginalLine);
1432
+ previousOriginalLine = mapping.originalLine - 1;
1433
+
1434
+ next += base64VLQ.encode(mapping.originalColumn
1435
+ - previousOriginalColumn);
1436
+ previousOriginalColumn = mapping.originalColumn;
1437
+
1438
+ if (mapping.name != null) {
1439
+ nameIdx = this._names.indexOf(mapping.name);
1440
+ next += base64VLQ.encode(nameIdx - previousName);
1441
+ previousName = nameIdx;
1442
+ }
1443
+ }
1444
+
1445
+ result += next;
1446
+ }
1447
+
1448
+ return result;
1449
+ }
1450
+
1451
+ _generateSourcesContent(aSources, aSourceRoot) {
1452
+ return aSources.map(function(source) {
1453
+ if (!this._sourcesContents) {
1454
+ return null;
1455
+ }
1456
+ if (aSourceRoot != null) {
1457
+ source = util.relative(aSourceRoot, source);
1458
+ }
1459
+ const key = util.toSetString(source);
1460
+ return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
1461
+ ? this._sourcesContents[key]
1462
+ : null;
1463
+ }, this);
1464
+ }
1465
+
1466
+ /**
1467
+ * Externalize the source map.
1468
+ */
1469
+ toJSON() {
1470
+ const map = {
1471
+ version: this._version,
1472
+ sources: this._sources.toArray(),
1473
+ names: this._names.toArray(),
1474
+ mappings: this._serializeMappings()
1475
+ };
1476
+ if (this._file != null) {
1477
+ map.file = this._file;
1478
+ }
1479
+ if (this._sourceRoot != null) {
1480
+ map.sourceRoot = this._sourceRoot;
1481
+ }
1482
+ if (this._sourcesContents) {
1483
+ map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
1484
+ }
1485
+
1486
+ return map;
1487
+ }
1488
+
1489
+ /**
1490
+ * Render the source map being generated to a string.
1491
+ */
1492
+ toString() {
1493
+ return JSON.stringify(this.toJSON());
1494
+ }
1495
+ }
1496
+
1497
+ SourceMapGenerator$1.prototype._version = 3;
1498
+ var SourceMapGenerator_1 = SourceMapGenerator$1;
1499
+
1500
+ var sourceMapGenerator = {
1501
+ SourceMapGenerator: SourceMapGenerator_1
1502
+ };
1503
+
1504
+ /* -*- Mode: js; js-indent-level: 2; -*- */
1505
+
1506
+ var binarySearch$1 = createCommonjsModule(function (module, exports) {
1507
+ /*
1508
+ * Copyright 2011 Mozilla Foundation and contributors
1509
+ * Licensed under the New BSD license. See LICENSE or:
1510
+ * http://opensource.org/licenses/BSD-3-Clause
1511
+ */
1512
+
1513
+ exports.GREATEST_LOWER_BOUND = 1;
1514
+ exports.LEAST_UPPER_BOUND = 2;
1515
+
1516
+ /**
1517
+ * Recursive implementation of binary search.
1518
+ *
1519
+ * @param aLow Indices here and lower do not contain the needle.
1520
+ * @param aHigh Indices here and higher do not contain the needle.
1521
+ * @param aNeedle The element being searched for.
1522
+ * @param aHaystack The non-empty array being searched.
1523
+ * @param aCompare Function which takes two elements and returns -1, 0, or 1.
1524
+ * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
1525
+ * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
1526
+ * closest element that is smaller than or greater than the one we are
1527
+ * searching for, respectively, if the exact element cannot be found.
1528
+ */
1529
+ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
1530
+ // This function terminates when one of the following is true:
1531
+ //
1532
+ // 1. We find the exact element we are looking for.
1533
+ //
1534
+ // 2. We did not find the exact element, but we can return the index of
1535
+ // the next-closest element.
1536
+ //
1537
+ // 3. We did not find the exact element, and there is no next-closest
1538
+ // element than the one we are searching for, so we return -1.
1539
+ const mid = Math.floor((aHigh - aLow) / 2) + aLow;
1540
+ const cmp = aCompare(aNeedle, aHaystack[mid], true);
1541
+ if (cmp === 0) {
1542
+ // Found the element we are looking for.
1543
+ return mid;
1544
+ } else if (cmp > 0) {
1545
+ // Our needle is greater than aHaystack[mid].
1546
+ if (aHigh - mid > 1) {
1547
+ // The element is in the upper half.
1548
+ return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
1549
+ }
1550
+
1551
+ // The exact needle element was not found in this haystack. Determine if
1552
+ // we are in termination case (3) or (2) and return the appropriate thing.
1553
+ if (aBias == exports.LEAST_UPPER_BOUND) {
1554
+ return aHigh < aHaystack.length ? aHigh : -1;
1555
+ }
1556
+ return mid;
1557
+ }
1558
+
1559
+ // Our needle is less than aHaystack[mid].
1560
+ if (mid - aLow > 1) {
1561
+ // The element is in the lower half.
1562
+ return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
1563
+ }
1564
+
1565
+ // we are in termination case (3) or (2) and return the appropriate thing.
1566
+ if (aBias == exports.LEAST_UPPER_BOUND) {
1567
+ return mid;
1568
+ }
1569
+ return aLow < 0 ? -1 : aLow;
1570
+ }
1571
+
1572
+ /**
1573
+ * This is an implementation of binary search which will always try and return
1574
+ * the index of the closest element if there is no exact hit. This is because
1575
+ * mappings between original and generated line/col pairs are single points,
1576
+ * and there is an implicit region between each of them, so a miss just means
1577
+ * that you aren't on the very start of a region.
1578
+ *
1579
+ * @param aNeedle The element you are looking for.
1580
+ * @param aHaystack The array that is being searched.
1581
+ * @param aCompare A function which takes the needle and an element in the
1582
+ * array and returns -1, 0, or 1 depending on whether the needle is less
1583
+ * than, equal to, or greater than the element, respectively.
1584
+ * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
1585
+ * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
1586
+ * closest element that is smaller than or greater than the one we are
1587
+ * searching for, respectively, if the exact element cannot be found.
1588
+ * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
1589
+ */
1590
+ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
1591
+ if (aHaystack.length === 0) {
1592
+ return -1;
1593
+ }
1594
+
1595
+ let index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
1596
+ aCompare, aBias || exports.GREATEST_LOWER_BOUND);
1597
+ if (index < 0) {
1598
+ return -1;
1599
+ }
1600
+
1601
+ // We have found either the exact element, or the next-closest element than
1602
+ // the one we are searching for. However, there may be more than one such
1603
+ // element. Make sure we always return the smallest of these.
1604
+ while (index - 1 >= 0) {
1605
+ if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
1606
+ break;
1607
+ }
1608
+ --index;
1609
+ }
1610
+
1611
+ return index;
1612
+ };
1613
+ });
1614
+
1615
+ /* Determine browser vs node environment by testing the default top level context. Solution courtesy of: https://stackoverflow.com/questions/17575790/environment-detection-node-js-or-browser */
1616
+
1617
+ var readWasm$1 = createCommonjsModule(function (module) {
1618
+ {
1619
+ // Node version of reading a wasm file into an array buffer.
1620
+ const fs = require$$0__default["default"];
1621
+ const path = require$$1__default["default"];
1622
+
1623
+ module.exports = function readWasm() {
1624
+ return new Promise((resolve, reject) => {
1625
+ const wasmPath = path.join(__dirname, "../lib/source-map/lib", "mappings.wasm");
1626
+ fs.readFile(wasmPath, null, (error, data) => {
1627
+ if (error) {
1628
+ reject(error);
1629
+ return;
1630
+ }
1631
+
1632
+ resolve(data.buffer);
1633
+ });
1634
+ });
1635
+ };
1636
+
1637
+ module.exports.initialize = _ => {
1638
+ console.debug("SourceMapConsumer.initialize is a no-op when running in node.js");
1639
+ };
1640
+ }
1641
+ });
1642
+
1643
+ var readWasm = readWasm$1;
1644
+
1645
+ /**
1646
+ * Provide the JIT with a nice shape / hidden class.
1647
+ */
1648
+ function Mapping() {
1649
+ this.generatedLine = 0;
1650
+ this.generatedColumn = 0;
1651
+ this.lastGeneratedColumn = null;
1652
+ this.source = null;
1653
+ this.originalLine = null;
1654
+ this.originalColumn = null;
1655
+ this.name = null;
1656
+ }
1657
+
1658
+ let cachedWasm = null;
1659
+
1660
+ var wasm$1 = function wasm() {
1661
+ if (cachedWasm) {
1662
+ return cachedWasm;
1663
+ }
1664
+
1665
+ const callbackStack = [];
1666
+
1667
+ cachedWasm = readWasm().then(buffer => {
1668
+ return WebAssembly.instantiate(buffer, {
1669
+ env: {
1670
+ mapping_callback(
1671
+ generatedLine,
1672
+ generatedColumn,
1673
+
1674
+ hasLastGeneratedColumn,
1675
+ lastGeneratedColumn,
1676
+
1677
+ hasOriginal,
1678
+ source,
1679
+ originalLine,
1680
+ originalColumn,
1681
+
1682
+ hasName,
1683
+ name
1684
+ ) {
1685
+ const mapping = new Mapping();
1686
+ // JS uses 1-based line numbers, wasm uses 0-based.
1687
+ mapping.generatedLine = generatedLine + 1;
1688
+ mapping.generatedColumn = generatedColumn;
1689
+
1690
+ if (hasLastGeneratedColumn) {
1691
+ // JS uses inclusive last generated column, wasm uses exclusive.
1692
+ mapping.lastGeneratedColumn = lastGeneratedColumn - 1;
1693
+ }
1694
+
1695
+ if (hasOriginal) {
1696
+ mapping.source = source;
1697
+ // JS uses 1-based line numbers, wasm uses 0-based.
1698
+ mapping.originalLine = originalLine + 1;
1699
+ mapping.originalColumn = originalColumn;
1700
+
1701
+ if (hasName) {
1702
+ mapping.name = name;
1703
+ }
1704
+ }
1705
+
1706
+ callbackStack[callbackStack.length - 1](mapping);
1707
+ },
1708
+
1709
+ start_all_generated_locations_for() { console.time("all_generated_locations_for"); },
1710
+ end_all_generated_locations_for() { console.timeEnd("all_generated_locations_for"); },
1711
+
1712
+ start_compute_column_spans() { console.time("compute_column_spans"); },
1713
+ end_compute_column_spans() { console.timeEnd("compute_column_spans"); },
1714
+
1715
+ start_generated_location_for() { console.time("generated_location_for"); },
1716
+ end_generated_location_for() { console.timeEnd("generated_location_for"); },
1717
+
1718
+ start_original_location_for() { console.time("original_location_for"); },
1719
+ end_original_location_for() { console.timeEnd("original_location_for"); },
1720
+
1721
+ start_parse_mappings() { console.time("parse_mappings"); },
1722
+ end_parse_mappings() { console.timeEnd("parse_mappings"); },
1723
+
1724
+ start_sort_by_generated_location() { console.time("sort_by_generated_location"); },
1725
+ end_sort_by_generated_location() { console.timeEnd("sort_by_generated_location"); },
1726
+
1727
+ start_sort_by_original_location() { console.time("sort_by_original_location"); },
1728
+ end_sort_by_original_location() { console.timeEnd("sort_by_original_location"); },
1729
+ }
1730
+ });
1731
+ }).then(Wasm => {
1732
+ return {
1733
+ exports: Wasm.instance.exports,
1734
+ withMappingCallback: (mappingCallback, f) => {
1735
+ callbackStack.push(mappingCallback);
1736
+ try {
1737
+ f();
1738
+ } finally {
1739
+ callbackStack.pop();
1740
+ }
1741
+ }
1742
+ };
1743
+ }).then(null, e => {
1744
+ cachedWasm = null;
1745
+ throw e;
1746
+ });
1747
+
1748
+ return cachedWasm;
1749
+ };
1750
+
1751
+ var binarySearch = binarySearch$1;
1752
+
1753
+ var wasm = wasm$1;
1754
+
1755
+ /* -*- Mode: js; js-indent-level: 2; -*- */
1756
+
1757
+ /*
1758
+ * Copyright 2011 Mozilla Foundation and contributors
1759
+ * Licensed under the New BSD license. See LICENSE or:
1760
+ * http://opensource.org/licenses/BSD-3-Clause
1761
+ */
1762
+
1763
+
1764
+
1765
+ const ArraySet = require$$0$1.ArraySet;
1766
+ // eslint-disable-line no-unused-vars
1767
+
1768
+
1769
+
1770
+ const INTERNAL = Symbol("smcInternal");
1771
+
1772
+ class SourceMapConsumer$1 {
1773
+ constructor(aSourceMap, aSourceMapURL) {
1774
+ // If the constructor was called by super(), just return Promise<this>.
1775
+ // Yes, this is a hack to retain the pre-existing API of the base-class
1776
+ // constructor also being an async factory function.
1777
+ if (aSourceMap == INTERNAL) {
1778
+ return Promise.resolve(this);
1779
+ }
1780
+
1781
+ return _factory(aSourceMap, aSourceMapURL);
1782
+ }
1783
+
1784
+ static initialize(opts) {
1785
+ readWasm.initialize(opts["lib/mappings.wasm"]);
1786
+ }
1787
+
1788
+ static fromSourceMap(aSourceMap, aSourceMapURL) {
1789
+ return _factoryBSM(aSourceMap, aSourceMapURL);
1790
+ }
1791
+
1792
+ /**
1793
+ * Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl`
1794
+ * (see the `SourceMapConsumer` constructor for details. Then, invoke the `async
1795
+ * function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait
1796
+ * for `f` to complete, call `destroy` on the consumer, and return `f`'s return
1797
+ * value.
1798
+ *
1799
+ * You must not use the consumer after `f` completes!
1800
+ *
1801
+ * By using `with`, you do not have to remember to manually call `destroy` on
1802
+ * the consumer, since it will be called automatically once `f` completes.
1803
+ *
1804
+ * ```js
1805
+ * const xSquared = await SourceMapConsumer.with(
1806
+ * myRawSourceMap,
1807
+ * null,
1808
+ * async function (consumer) {
1809
+ * // Use `consumer` inside here and don't worry about remembering
1810
+ * // to call `destroy`.
1811
+ *
1812
+ * const x = await whatever(consumer);
1813
+ * return x * x;
1814
+ * }
1815
+ * );
1816
+ *
1817
+ * // You may not use that `consumer` anymore out here; it has
1818
+ * // been destroyed. But you can use `xSquared`.
1819
+ * console.log(xSquared);
1820
+ * ```
1821
+ */
1822
+ static async with(rawSourceMap, sourceMapUrl, f) {
1823
+ const consumer = await new SourceMapConsumer$1(rawSourceMap, sourceMapUrl);
1824
+ try {
1825
+ return await f(consumer);
1826
+ } finally {
1827
+ consumer.destroy();
1828
+ }
1829
+ }
1830
+
1831
+ /**
1832
+ * Parse the mappings in a string in to a data structure which we can easily
1833
+ * query (the ordered arrays in the `this.__generatedMappings` and
1834
+ * `this.__originalMappings` properties).
1835
+ */
1836
+ _parseMappings(aStr, aSourceRoot) {
1837
+ throw new Error("Subclasses must implement _parseMappings");
1838
+ }
1839
+
1840
+ /**
1841
+ * Iterate over each mapping between an original source/line/column and a
1842
+ * generated line/column in this source map.
1843
+ *
1844
+ * @param Function aCallback
1845
+ * The function that is called with each mapping.
1846
+ * @param Object aContext
1847
+ * Optional. If specified, this object will be the value of `this` every
1848
+ * time that `aCallback` is called.
1849
+ * @param aOrder
1850
+ * Either `SourceMapConsumer.GENERATED_ORDER` or
1851
+ * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
1852
+ * iterate over the mappings sorted by the generated file's line/column
1853
+ * order or the original's source/line/column order, respectively. Defaults to
1854
+ * `SourceMapConsumer.GENERATED_ORDER`.
1855
+ */
1856
+ eachMapping(aCallback, aContext, aOrder) {
1857
+ throw new Error("Subclasses must implement eachMapping");
1858
+ }
1859
+
1860
+ /**
1861
+ * Returns all generated line and column information for the original source,
1862
+ * line, and column provided. If no column is provided, returns all mappings
1863
+ * corresponding to a either the line we are searching for or the next
1864
+ * closest line that has any mappings. Otherwise, returns all mappings
1865
+ * corresponding to the given line and either the column we are searching for
1866
+ * or the next closest column that has any offsets.
1867
+ *
1868
+ * The only argument is an object with the following properties:
1869
+ *
1870
+ * - source: The filename of the original source.
1871
+ * - line: The line number in the original source. The line number is 1-based.
1872
+ * - column: Optional. the column number in the original source.
1873
+ * The column number is 0-based.
1874
+ *
1875
+ * and an array of objects is returned, each with the following properties:
1876
+ *
1877
+ * - line: The line number in the generated source, or null. The
1878
+ * line number is 1-based.
1879
+ * - column: The column number in the generated source, or null.
1880
+ * The column number is 0-based.
1881
+ */
1882
+ allGeneratedPositionsFor(aArgs) {
1883
+ throw new Error("Subclasses must implement allGeneratedPositionsFor");
1884
+ }
1885
+
1886
+ destroy() {
1887
+ throw new Error("Subclasses must implement destroy");
1888
+ }
1889
+ }
1890
+
1891
+ /**
1892
+ * The version of the source mapping spec that we are consuming.
1893
+ */
1894
+ SourceMapConsumer$1.prototype._version = 3;
1895
+ SourceMapConsumer$1.GENERATED_ORDER = 1;
1896
+ SourceMapConsumer$1.ORIGINAL_ORDER = 2;
1897
+
1898
+ SourceMapConsumer$1.GREATEST_LOWER_BOUND = 1;
1899
+ SourceMapConsumer$1.LEAST_UPPER_BOUND = 2;
1900
+
1901
+ var SourceMapConsumer_1 = SourceMapConsumer$1;
1902
+
1903
+ /**
1904
+ * A BasicSourceMapConsumer instance represents a parsed source map which we can
1905
+ * query for information about the original file positions by giving it a file
1906
+ * position in the generated source.
1907
+ *
1908
+ * The first parameter is the raw source map (either as a JSON string, or
1909
+ * already parsed to an object). According to the spec, source maps have the
1910
+ * following attributes:
1911
+ *
1912
+ * - version: Which version of the source map spec this map is following.
1913
+ * - sources: An array of URLs to the original source files.
1914
+ * - names: An array of identifiers which can be referenced by individual mappings.
1915
+ * - sourceRoot: Optional. The URL root from which all sources are relative.
1916
+ * - sourcesContent: Optional. An array of contents of the original source files.
1917
+ * - mappings: A string of base64 VLQs which contain the actual mappings.
1918
+ * - file: Optional. The generated file this source map is associated with.
1919
+ *
1920
+ * Here is an example source map, taken from the source map spec[0]:
1921
+ *
1922
+ * {
1923
+ * version : 3,
1924
+ * file: "out.js",
1925
+ * sourceRoot : "",
1926
+ * sources: ["foo.js", "bar.js"],
1927
+ * names: ["src", "maps", "are", "fun"],
1928
+ * mappings: "AA,AB;;ABCDE;"
1929
+ * }
1930
+ *
1931
+ * The second parameter, if given, is a string whose value is the URL
1932
+ * at which the source map was found. This URL is used to compute the
1933
+ * sources array.
1934
+ *
1935
+ * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
1936
+ */
1937
+ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
1938
+ constructor(aSourceMap, aSourceMapURL) {
1939
+ return super(INTERNAL).then(that => {
1940
+ let sourceMap = aSourceMap;
1941
+ if (typeof aSourceMap === "string") {
1942
+ sourceMap = util.parseSourceMapInput(aSourceMap);
1943
+ }
1944
+
1945
+ const version = util.getArg(sourceMap, "version");
1946
+ let sources = util.getArg(sourceMap, "sources");
1947
+ // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
1948
+ // requires the array) to play nice here.
1949
+ const names = util.getArg(sourceMap, "names", []);
1950
+ let sourceRoot = util.getArg(sourceMap, "sourceRoot", null);
1951
+ const sourcesContent = util.getArg(sourceMap, "sourcesContent", null);
1952
+ const mappings = util.getArg(sourceMap, "mappings");
1953
+ const file = util.getArg(sourceMap, "file", null);
1954
+
1955
+ // Once again, Sass deviates from the spec and supplies the version as a
1956
+ // string rather than a number, so we use loose equality checking here.
1957
+ if (version != that._version) {
1958
+ throw new Error("Unsupported version: " + version);
1959
+ }
1960
+
1961
+ if (sourceRoot) {
1962
+ sourceRoot = util.normalize(sourceRoot);
1963
+ }
1964
+
1965
+ sources = sources
1966
+ .map(String)
1967
+ // Some source maps produce relative source paths like "./foo.js" instead of
1968
+ // "foo.js". Normalize these first so that future comparisons will succeed.
1969
+ // See bugzil.la/1090768.
1970
+ .map(util.normalize)
1971
+ // Always ensure that absolute sources are internally stored relative to
1972
+ // the source root, if the source root is absolute. Not doing this would
1973
+ // be particularly problematic when the source root is a prefix of the
1974
+ // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
1975
+ .map(function(source) {
1976
+ return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
1977
+ ? util.relative(sourceRoot, source)
1978
+ : source;
1979
+ });
1980
+
1981
+ // Pass `true` below to allow duplicate names and sources. While source maps
1982
+ // are intended to be compressed and deduplicated, the TypeScript compiler
1983
+ // sometimes generates source maps with duplicates in them. See Github issue
1984
+ // #72 and bugzil.la/889492.
1985
+ that._names = ArraySet.fromArray(names.map(String), true);
1986
+ that._sources = ArraySet.fromArray(sources, true);
1987
+
1988
+ that._absoluteSources = that._sources.toArray().map(function(s) {
1989
+ return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
1990
+ });
1991
+
1992
+ that.sourceRoot = sourceRoot;
1993
+ that.sourcesContent = sourcesContent;
1994
+ that._mappings = mappings;
1995
+ that._sourceMapURL = aSourceMapURL;
1996
+ that.file = file;
1997
+
1998
+ that._computedColumnSpans = false;
1999
+ that._mappingsPtr = 0;
2000
+ that._wasm = null;
2001
+
2002
+ return wasm().then(w => {
2003
+ that._wasm = w;
2004
+ return that;
2005
+ });
2006
+ });
2007
+ }
2008
+
2009
+ /**
2010
+ * Utility function to find the index of a source. Returns -1 if not
2011
+ * found.
2012
+ */
2013
+ _findSourceIndex(aSource) {
2014
+ let relativeSource = aSource;
2015
+ if (this.sourceRoot != null) {
2016
+ relativeSource = util.relative(this.sourceRoot, relativeSource);
2017
+ }
2018
+
2019
+ if (this._sources.has(relativeSource)) {
2020
+ return this._sources.indexOf(relativeSource);
2021
+ }
2022
+
2023
+ // Maybe aSource is an absolute URL as returned by |sources|. In
2024
+ // this case we can't simply undo the transform.
2025
+ for (let i = 0; i < this._absoluteSources.length; ++i) {
2026
+ if (this._absoluteSources[i] == aSource) {
2027
+ return i;
2028
+ }
2029
+ }
2030
+
2031
+ return -1;
2032
+ }
2033
+
2034
+ /**
2035
+ * Create a BasicSourceMapConsumer from a SourceMapGenerator.
2036
+ *
2037
+ * @param SourceMapGenerator aSourceMap
2038
+ * The source map that will be consumed.
2039
+ * @param String aSourceMapURL
2040
+ * The URL at which the source map can be found (optional)
2041
+ * @returns BasicSourceMapConsumer
2042
+ */
2043
+ static fromSourceMap(aSourceMap, aSourceMapURL) {
2044
+ return new BasicSourceMapConsumer(aSourceMap.toString());
2045
+ }
2046
+
2047
+ get sources() {
2048
+ return this._absoluteSources.slice();
2049
+ }
2050
+
2051
+ _getMappingsPtr() {
2052
+ if (this._mappingsPtr === 0) {
2053
+ this._parseMappings(this._mappings, this.sourceRoot);
2054
+ }
2055
+
2056
+ return this._mappingsPtr;
2057
+ }
2058
+
2059
+ /**
2060
+ * Parse the mappings in a string in to a data structure which we can easily
2061
+ * query (the ordered arrays in the `this.__generatedMappings` and
2062
+ * `this.__originalMappings` properties).
2063
+ */
2064
+ _parseMappings(aStr, aSourceRoot) {
2065
+ const size = aStr.length;
2066
+
2067
+ const mappingsBufPtr = this._wasm.exports.allocate_mappings(size);
2068
+ const mappingsBuf = new Uint8Array(this._wasm.exports.memory.buffer, mappingsBufPtr, size);
2069
+ for (let i = 0; i < size; i++) {
2070
+ mappingsBuf[i] = aStr.charCodeAt(i);
2071
+ }
2072
+
2073
+ const mappingsPtr = this._wasm.exports.parse_mappings(mappingsBufPtr);
2074
+
2075
+ if (!mappingsPtr) {
2076
+ const error = this._wasm.exports.get_last_error();
2077
+ let msg = `Error parsing mappings (code ${error}): `;
2078
+
2079
+ // XXX: keep these error codes in sync with `fitzgen/source-map-mappings`.
2080
+ switch (error) {
2081
+ case 1:
2082
+ msg += "the mappings contained a negative line, column, source index, or name index";
2083
+ break;
2084
+ case 2:
2085
+ msg += "the mappings contained a number larger than 2**32";
2086
+ break;
2087
+ case 3:
2088
+ msg += "reached EOF while in the middle of parsing a VLQ";
2089
+ break;
2090
+ case 4:
2091
+ msg += "invalid base 64 character while parsing a VLQ";
2092
+ break;
2093
+ default:
2094
+ msg += "unknown error code";
2095
+ break;
2096
+ }
2097
+
2098
+ throw new Error(msg);
2099
+ }
2100
+
2101
+ this._mappingsPtr = mappingsPtr;
2102
+ }
2103
+
2104
+ eachMapping(aCallback, aContext, aOrder) {
2105
+ const context = aContext || null;
2106
+ const order = aOrder || SourceMapConsumer$1.GENERATED_ORDER;
2107
+ const sourceRoot = this.sourceRoot;
2108
+
2109
+ this._wasm.withMappingCallback(
2110
+ mapping => {
2111
+ if (mapping.source !== null) {
2112
+ mapping.source = this._sources.at(mapping.source);
2113
+ mapping.source = util.computeSourceURL(sourceRoot, mapping.source, this._sourceMapURL);
2114
+
2115
+ if (mapping.name !== null) {
2116
+ mapping.name = this._names.at(mapping.name);
2117
+ }
2118
+ }
2119
+
2120
+ aCallback.call(context, mapping);
2121
+ },
2122
+ () => {
2123
+ switch (order) {
2124
+ case SourceMapConsumer$1.GENERATED_ORDER:
2125
+ this._wasm.exports.by_generated_location(this._getMappingsPtr());
2126
+ break;
2127
+ case SourceMapConsumer$1.ORIGINAL_ORDER:
2128
+ this._wasm.exports.by_original_location(this._getMappingsPtr());
2129
+ break;
2130
+ default:
2131
+ throw new Error("Unknown order of iteration.");
2132
+ }
2133
+ }
2134
+ );
2135
+ }
2136
+
2137
+ allGeneratedPositionsFor(aArgs) {
2138
+ let source = util.getArg(aArgs, "source");
2139
+ const originalLine = util.getArg(aArgs, "line");
2140
+ const originalColumn = aArgs.column || 0;
2141
+
2142
+ source = this._findSourceIndex(source);
2143
+ if (source < 0) {
2144
+ return [];
2145
+ }
2146
+
2147
+ if (originalLine < 1) {
2148
+ throw new Error("Line numbers must be >= 1");
2149
+ }
2150
+
2151
+ if (originalColumn < 0) {
2152
+ throw new Error("Column numbers must be >= 0");
2153
+ }
2154
+
2155
+ const mappings = [];
2156
+
2157
+ this._wasm.withMappingCallback(
2158
+ m => {
2159
+ let lastColumn = m.lastGeneratedColumn;
2160
+ if (this._computedColumnSpans && lastColumn === null) {
2161
+ lastColumn = Infinity;
2162
+ }
2163
+ mappings.push({
2164
+ line: m.generatedLine,
2165
+ column: m.generatedColumn,
2166
+ lastColumn,
2167
+ });
2168
+ }, () => {
2169
+ this._wasm.exports.all_generated_locations_for(
2170
+ this._getMappingsPtr(),
2171
+ source,
2172
+ originalLine - 1,
2173
+ "column" in aArgs,
2174
+ originalColumn
2175
+ );
2176
+ }
2177
+ );
2178
+
2179
+ return mappings;
2180
+ }
2181
+
2182
+ destroy() {
2183
+ if (this._mappingsPtr !== 0) {
2184
+ this._wasm.exports.free_mappings(this._mappingsPtr);
2185
+ this._mappingsPtr = 0;
2186
+ }
2187
+ }
2188
+
2189
+ /**
2190
+ * Compute the last column for each generated mapping. The last column is
2191
+ * inclusive.
2192
+ */
2193
+ computeColumnSpans() {
2194
+ if (this._computedColumnSpans) {
2195
+ return;
2196
+ }
2197
+
2198
+ this._wasm.exports.compute_column_spans(this._getMappingsPtr());
2199
+ this._computedColumnSpans = true;
2200
+ }
2201
+
2202
+ /**
2203
+ * Returns the original source, line, and column information for the generated
2204
+ * source's line and column positions provided. The only argument is an object
2205
+ * with the following properties:
2206
+ *
2207
+ * - line: The line number in the generated source. The line number
2208
+ * is 1-based.
2209
+ * - column: The column number in the generated source. The column
2210
+ * number is 0-based.
2211
+ * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
2212
+ * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
2213
+ * closest element that is smaller than or greater than the one we are
2214
+ * searching for, respectively, if the exact element cannot be found.
2215
+ * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
2216
+ *
2217
+ * and an object is returned with the following properties:
2218
+ *
2219
+ * - source: The original source file, or null.
2220
+ * - line: The line number in the original source, or null. The
2221
+ * line number is 1-based.
2222
+ * - column: The column number in the original source, or null. The
2223
+ * column number is 0-based.
2224
+ * - name: The original identifier, or null.
2225
+ */
2226
+ originalPositionFor(aArgs) {
2227
+ const needle = {
2228
+ generatedLine: util.getArg(aArgs, "line"),
2229
+ generatedColumn: util.getArg(aArgs, "column")
2230
+ };
2231
+
2232
+ if (needle.generatedLine < 1) {
2233
+ throw new Error("Line numbers must be >= 1");
2234
+ }
2235
+
2236
+ if (needle.generatedColumn < 0) {
2237
+ throw new Error("Column numbers must be >= 0");
2238
+ }
2239
+
2240
+ let bias = util.getArg(aArgs, "bias", SourceMapConsumer$1.GREATEST_LOWER_BOUND);
2241
+ if (bias == null) {
2242
+ bias = SourceMapConsumer$1.GREATEST_LOWER_BOUND;
2243
+ }
2244
+
2245
+ let mapping;
2246
+ this._wasm.withMappingCallback(m => mapping = m, () => {
2247
+ this._wasm.exports.original_location_for(
2248
+ this._getMappingsPtr(),
2249
+ needle.generatedLine - 1,
2250
+ needle.generatedColumn,
2251
+ bias
2252
+ );
2253
+ });
2254
+
2255
+ if (mapping) {
2256
+ if (mapping.generatedLine === needle.generatedLine) {
2257
+ let source = util.getArg(mapping, "source", null);
2258
+ if (source !== null) {
2259
+ source = this._sources.at(source);
2260
+ source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
2261
+ }
2262
+
2263
+ let name = util.getArg(mapping, "name", null);
2264
+ if (name !== null) {
2265
+ name = this._names.at(name);
2266
+ }
2267
+
2268
+ return {
2269
+ source,
2270
+ line: util.getArg(mapping, "originalLine", null),
2271
+ column: util.getArg(mapping, "originalColumn", null),
2272
+ name
2273
+ };
2274
+ }
2275
+ }
2276
+
2277
+ return {
2278
+ source: null,
2279
+ line: null,
2280
+ column: null,
2281
+ name: null
2282
+ };
2283
+ }
2284
+
2285
+ /**
2286
+ * Return true if we have the source content for every source in the source
2287
+ * map, false otherwise.
2288
+ */
2289
+ hasContentsOfAllSources() {
2290
+ if (!this.sourcesContent) {
2291
+ return false;
2292
+ }
2293
+ return this.sourcesContent.length >= this._sources.size() &&
2294
+ !this.sourcesContent.some(function(sc) { return sc == null; });
2295
+ }
2296
+
2297
+ /**
2298
+ * Returns the original source content. The only argument is the url of the
2299
+ * original source file. Returns null if no original source content is
2300
+ * available.
2301
+ */
2302
+ sourceContentFor(aSource, nullOnMissing) {
2303
+ if (!this.sourcesContent) {
2304
+ return null;
2305
+ }
2306
+
2307
+ const index = this._findSourceIndex(aSource);
2308
+ if (index >= 0) {
2309
+ return this.sourcesContent[index];
2310
+ }
2311
+
2312
+ let relativeSource = aSource;
2313
+ if (this.sourceRoot != null) {
2314
+ relativeSource = util.relative(this.sourceRoot, relativeSource);
2315
+ }
2316
+
2317
+ let url;
2318
+ if (this.sourceRoot != null
2319
+ && (url = util.urlParse(this.sourceRoot))) {
2320
+ // XXX: file:// URIs and absolute paths lead to unexpected behavior for
2321
+ // many users. We can help them out when they expect file:// URIs to
2322
+ // behave like it would if they were running a local HTTP server. See
2323
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
2324
+ const fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
2325
+ if (url.scheme == "file"
2326
+ && this._sources.has(fileUriAbsPath)) {
2327
+ return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)];
2328
+ }
2329
+
2330
+ if ((!url.path || url.path == "/")
2331
+ && this._sources.has("/" + relativeSource)) {
2332
+ return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
2333
+ }
2334
+ }
2335
+
2336
+ // This function is used recursively from
2337
+ // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
2338
+ // don't want to throw if we can't find the source - we just want to
2339
+ // return null, so we provide a flag to exit gracefully.
2340
+ if (nullOnMissing) {
2341
+ return null;
2342
+ }
2343
+
2344
+ throw new Error('"' + relativeSource + '" is not in the SourceMap.');
2345
+ }
2346
+
2347
+ /**
2348
+ * Returns the generated line and column information for the original source,
2349
+ * line, and column positions provided. The only argument is an object with
2350
+ * the following properties:
2351
+ *
2352
+ * - source: The filename of the original source.
2353
+ * - line: The line number in the original source. The line number
2354
+ * is 1-based.
2355
+ * - column: The column number in the original source. The column
2356
+ * number is 0-based.
2357
+ * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
2358
+ * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
2359
+ * closest element that is smaller than or greater than the one we are
2360
+ * searching for, respectively, if the exact element cannot be found.
2361
+ * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
2362
+ *
2363
+ * and an object is returned with the following properties:
2364
+ *
2365
+ * - line: The line number in the generated source, or null. The
2366
+ * line number is 1-based.
2367
+ * - column: The column number in the generated source, or null.
2368
+ * The column number is 0-based.
2369
+ */
2370
+ generatedPositionFor(aArgs) {
2371
+ let source = util.getArg(aArgs, "source");
2372
+ source = this._findSourceIndex(source);
2373
+ if (source < 0) {
2374
+ return {
2375
+ line: null,
2376
+ column: null,
2377
+ lastColumn: null
2378
+ };
2379
+ }
2380
+
2381
+ const needle = {
2382
+ source,
2383
+ originalLine: util.getArg(aArgs, "line"),
2384
+ originalColumn: util.getArg(aArgs, "column")
2385
+ };
2386
+
2387
+ if (needle.originalLine < 1) {
2388
+ throw new Error("Line numbers must be >= 1");
2389
+ }
2390
+
2391
+ if (needle.originalColumn < 0) {
2392
+ throw new Error("Column numbers must be >= 0");
2393
+ }
2394
+
2395
+ let bias = util.getArg(aArgs, "bias", SourceMapConsumer$1.GREATEST_LOWER_BOUND);
2396
+ if (bias == null) {
2397
+ bias = SourceMapConsumer$1.GREATEST_LOWER_BOUND;
2398
+ }
2399
+
2400
+ let mapping;
2401
+ this._wasm.withMappingCallback(m => mapping = m, () => {
2402
+ this._wasm.exports.generated_location_for(
2403
+ this._getMappingsPtr(),
2404
+ needle.source,
2405
+ needle.originalLine - 1,
2406
+ needle.originalColumn,
2407
+ bias
2408
+ );
2409
+ });
2410
+
2411
+ if (mapping) {
2412
+ if (mapping.source === needle.source) {
2413
+ let lastColumn = mapping.lastGeneratedColumn;
2414
+ if (this._computedColumnSpans && lastColumn === null) {
2415
+ lastColumn = Infinity;
2416
+ }
2417
+ return {
2418
+ line: util.getArg(mapping, "generatedLine", null),
2419
+ column: util.getArg(mapping, "generatedColumn", null),
2420
+ lastColumn,
2421
+ };
2422
+ }
2423
+ }
2424
+
2425
+ return {
2426
+ line: null,
2427
+ column: null,
2428
+ lastColumn: null
2429
+ };
2430
+ }
2431
+ }
2432
+
2433
+ BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer$1;
2434
+ var BasicSourceMapConsumer_1 = BasicSourceMapConsumer;
2435
+
2436
+ /**
2437
+ * An IndexedSourceMapConsumer instance represents a parsed source map which
2438
+ * we can query for information. It differs from BasicSourceMapConsumer in
2439
+ * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
2440
+ * input.
2441
+ *
2442
+ * The first parameter is a raw source map (either as a JSON string, or already
2443
+ * parsed to an object). According to the spec for indexed source maps, they
2444
+ * have the following attributes:
2445
+ *
2446
+ * - version: Which version of the source map spec this map is following.
2447
+ * - file: Optional. The generated file this source map is associated with.
2448
+ * - sections: A list of section definitions.
2449
+ *
2450
+ * Each value under the "sections" field has two fields:
2451
+ * - offset: The offset into the original specified at which this section
2452
+ * begins to apply, defined as an object with a "line" and "column"
2453
+ * field.
2454
+ * - map: A source map definition. This source map could also be indexed,
2455
+ * but doesn't have to be.
2456
+ *
2457
+ * Instead of the "map" field, it's also possible to have a "url" field
2458
+ * specifying a URL to retrieve a source map from, but that's currently
2459
+ * unsupported.
2460
+ *
2461
+ * Here's an example source map, taken from the source map spec[0], but
2462
+ * modified to omit a section which uses the "url" field.
2463
+ *
2464
+ * {
2465
+ * version : 3,
2466
+ * file: "app.js",
2467
+ * sections: [{
2468
+ * offset: {line:100, column:10},
2469
+ * map: {
2470
+ * version : 3,
2471
+ * file: "section.js",
2472
+ * sources: ["foo.js", "bar.js"],
2473
+ * names: ["src", "maps", "are", "fun"],
2474
+ * mappings: "AAAA,E;;ABCDE;"
2475
+ * }
2476
+ * }],
2477
+ * }
2478
+ *
2479
+ * The second parameter, if given, is a string whose value is the URL
2480
+ * at which the source map was found. This URL is used to compute the
2481
+ * sources array.
2482
+ *
2483
+ * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
2484
+ */
2485
+ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2486
+ constructor(aSourceMap, aSourceMapURL) {
2487
+ return super(INTERNAL).then(that => {
2488
+ let sourceMap = aSourceMap;
2489
+ if (typeof aSourceMap === "string") {
2490
+ sourceMap = util.parseSourceMapInput(aSourceMap);
2491
+ }
2492
+
2493
+ const version = util.getArg(sourceMap, "version");
2494
+ const sections = util.getArg(sourceMap, "sections");
2495
+
2496
+ if (version != that._version) {
2497
+ throw new Error("Unsupported version: " + version);
2498
+ }
2499
+
2500
+ that._sources = new ArraySet();
2501
+ that._names = new ArraySet();
2502
+ that.__generatedMappings = null;
2503
+ that.__originalMappings = null;
2504
+ that.__generatedMappingsUnsorted = null;
2505
+ that.__originalMappingsUnsorted = null;
2506
+
2507
+ let lastOffset = {
2508
+ line: -1,
2509
+ column: 0
2510
+ };
2511
+ return Promise.all(sections.map(s => {
2512
+ if (s.url) {
2513
+ // The url field will require support for asynchronicity.
2514
+ // See https://github.com/mozilla/source-map/issues/16
2515
+ throw new Error("Support for url field in sections not implemented.");
2516
+ }
2517
+ const offset = util.getArg(s, "offset");
2518
+ const offsetLine = util.getArg(offset, "line");
2519
+ const offsetColumn = util.getArg(offset, "column");
2520
+
2521
+ if (offsetLine < lastOffset.line ||
2522
+ (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
2523
+ throw new Error("Section offsets must be ordered and non-overlapping.");
2524
+ }
2525
+ lastOffset = offset;
2526
+
2527
+ const cons = new SourceMapConsumer$1(util.getArg(s, "map"), aSourceMapURL);
2528
+ return cons.then(consumer => {
2529
+ return {
2530
+ generatedOffset: {
2531
+ // The offset fields are 0-based, but we use 1-based indices when
2532
+ // encoding/decoding from VLQ.
2533
+ generatedLine: offsetLine + 1,
2534
+ generatedColumn: offsetColumn + 1
2535
+ },
2536
+ consumer
2537
+ };
2538
+ });
2539
+ })).then(s => {
2540
+ that._sections = s;
2541
+ return that;
2542
+ });
2543
+ });
2544
+ }
2545
+
2546
+ // `__generatedMappings` and `__originalMappings` are arrays that hold the
2547
+ // parsed mapping coordinates from the source map's "mappings" attribute. They
2548
+ // are lazily instantiated, accessed via the `_generatedMappings` and
2549
+ // `_originalMappings` getters respectively, and we only parse the mappings
2550
+ // and create these arrays once queried for a source location. We jump through
2551
+ // these hoops because there can be many thousands of mappings, and parsing
2552
+ // them is expensive, so we only want to do it if we must.
2553
+ //
2554
+ // Each object in the arrays is of the form:
2555
+ //
2556
+ // {
2557
+ // generatedLine: The line number in the generated code,
2558
+ // generatedColumn: The column number in the generated code,
2559
+ // source: The path to the original source file that generated this
2560
+ // chunk of code,
2561
+ // originalLine: The line number in the original source that
2562
+ // corresponds to this chunk of generated code,
2563
+ // originalColumn: The column number in the original source that
2564
+ // corresponds to this chunk of generated code,
2565
+ // name: The name of the original symbol which generated this chunk of
2566
+ // code.
2567
+ // }
2568
+ //
2569
+ // All properties except for `generatedLine` and `generatedColumn` can be
2570
+ // `null`.
2571
+ //
2572
+ // `_generatedMappings` is ordered by the generated positions.
2573
+ //
2574
+ // `_originalMappings` is ordered by the original positions.
2575
+ get _generatedMappings() {
2576
+ if (!this.__generatedMappings) {
2577
+ this._sortGeneratedMappings();
2578
+ }
2579
+
2580
+ return this.__generatedMappings;
2581
+ }
2582
+
2583
+ get _originalMappings() {
2584
+ if (!this.__originalMappings) {
2585
+ this._sortOriginalMappings();
2586
+ }
2587
+
2588
+ return this.__originalMappings;
2589
+ }
2590
+
2591
+ get _generatedMappingsUnsorted() {
2592
+ if (!this.__generatedMappingsUnsorted) {
2593
+ this._parseMappings(this._mappings, this.sourceRoot);
2594
+ }
2595
+
2596
+ return this.__generatedMappingsUnsorted;
2597
+ }
2598
+
2599
+ get _originalMappingsUnsorted() {
2600
+ if (!this.__originalMappingsUnsorted) {
2601
+ this._parseMappings(this._mappings, this.sourceRoot);
2602
+ }
2603
+
2604
+ return this.__originalMappingsUnsorted;
2605
+ }
2606
+
2607
+ _sortGeneratedMappings() {
2608
+ const mappings = this._generatedMappingsUnsorted;
2609
+ mappings.sort(util.compareByGeneratedPositionsDeflated);
2610
+ this.__generatedMappings = mappings;
2611
+ }
2612
+
2613
+ _sortOriginalMappings() {
2614
+ const mappings = this._originalMappingsUnsorted;
2615
+ mappings.sort(util.compareByOriginalPositions);
2616
+ this.__originalMappings = mappings;
2617
+ }
2618
+
2619
+ /**
2620
+ * The list of original sources.
2621
+ */
2622
+ get sources() {
2623
+ const sources = [];
2624
+ for (let i = 0; i < this._sections.length; i++) {
2625
+ for (let j = 0; j < this._sections[i].consumer.sources.length; j++) {
2626
+ sources.push(this._sections[i].consumer.sources[j]);
2627
+ }
2628
+ }
2629
+ return sources;
2630
+ }
2631
+
2632
+ /**
2633
+ * Returns the original source, line, and column information for the generated
2634
+ * source's line and column positions provided. The only argument is an object
2635
+ * with the following properties:
2636
+ *
2637
+ * - line: The line number in the generated source. The line number
2638
+ * is 1-based.
2639
+ * - column: The column number in the generated source. The column
2640
+ * number is 0-based.
2641
+ *
2642
+ * and an object is returned with the following properties:
2643
+ *
2644
+ * - source: The original source file, or null.
2645
+ * - line: The line number in the original source, or null. The
2646
+ * line number is 1-based.
2647
+ * - column: The column number in the original source, or null. The
2648
+ * column number is 0-based.
2649
+ * - name: The original identifier, or null.
2650
+ */
2651
+ originalPositionFor(aArgs) {
2652
+ const needle = {
2653
+ generatedLine: util.getArg(aArgs, "line"),
2654
+ generatedColumn: util.getArg(aArgs, "column")
2655
+ };
2656
+
2657
+ // Find the section containing the generated position we're trying to map
2658
+ // to an original position.
2659
+ const sectionIndex = binarySearch.search(needle, this._sections,
2660
+ function(aNeedle, section) {
2661
+ const cmp = aNeedle.generatedLine - section.generatedOffset.generatedLine;
2662
+ if (cmp) {
2663
+ return cmp;
2664
+ }
2665
+
2666
+ return (aNeedle.generatedColumn -
2667
+ section.generatedOffset.generatedColumn);
2668
+ });
2669
+ const section = this._sections[sectionIndex];
2670
+
2671
+ if (!section) {
2672
+ return {
2673
+ source: null,
2674
+ line: null,
2675
+ column: null,
2676
+ name: null
2677
+ };
2678
+ }
2679
+
2680
+ return section.consumer.originalPositionFor({
2681
+ line: needle.generatedLine -
2682
+ (section.generatedOffset.generatedLine - 1),
2683
+ column: needle.generatedColumn -
2684
+ (section.generatedOffset.generatedLine === needle.generatedLine
2685
+ ? section.generatedOffset.generatedColumn - 1
2686
+ : 0),
2687
+ bias: aArgs.bias
2688
+ });
2689
+ }
2690
+
2691
+ /**
2692
+ * Return true if we have the source content for every source in the source
2693
+ * map, false otherwise.
2694
+ */
2695
+ hasContentsOfAllSources() {
2696
+ return this._sections.every(function(s) {
2697
+ return s.consumer.hasContentsOfAllSources();
2698
+ });
2699
+ }
2700
+
2701
+ /**
2702
+ * Returns the original source content. The only argument is the url of the
2703
+ * original source file. Returns null if no original source content is
2704
+ * available.
2705
+ */
2706
+ sourceContentFor(aSource, nullOnMissing) {
2707
+ for (let i = 0; i < this._sections.length; i++) {
2708
+ const section = this._sections[i];
2709
+
2710
+ const content = section.consumer.sourceContentFor(aSource, true);
2711
+ if (content) {
2712
+ return content;
2713
+ }
2714
+ }
2715
+ if (nullOnMissing) {
2716
+ return null;
2717
+ }
2718
+ throw new Error('"' + aSource + '" is not in the SourceMap.');
2719
+ }
2720
+
2721
+ /**
2722
+ * Returns the generated line and column information for the original source,
2723
+ * line, and column positions provided. The only argument is an object with
2724
+ * the following properties:
2725
+ *
2726
+ * - source: The filename of the original source.
2727
+ * - line: The line number in the original source. The line number
2728
+ * is 1-based.
2729
+ * - column: The column number in the original source. The column
2730
+ * number is 0-based.
2731
+ *
2732
+ * and an object is returned with the following properties:
2733
+ *
2734
+ * - line: The line number in the generated source, or null. The
2735
+ * line number is 1-based.
2736
+ * - column: The column number in the generated source, or null.
2737
+ * The column number is 0-based.
2738
+ */
2739
+ generatedPositionFor(aArgs) {
2740
+ for (let i = 0; i < this._sections.length; i++) {
2741
+ const section = this._sections[i];
2742
+
2743
+ // Only consider this section if the requested source is in the list of
2744
+ // sources of the consumer.
2745
+ if (section.consumer._findSourceIndex(util.getArg(aArgs, "source")) === -1) {
2746
+ continue;
2747
+ }
2748
+ const generatedPosition = section.consumer.generatedPositionFor(aArgs);
2749
+ if (generatedPosition) {
2750
+ const ret = {
2751
+ line: generatedPosition.line +
2752
+ (section.generatedOffset.generatedLine - 1),
2753
+ column: generatedPosition.column +
2754
+ (section.generatedOffset.generatedLine === generatedPosition.line
2755
+ ? section.generatedOffset.generatedColumn - 1
2756
+ : 0)
2757
+ };
2758
+ return ret;
2759
+ }
2760
+ }
2761
+
2762
+ return {
2763
+ line: null,
2764
+ column: null
2765
+ };
2766
+ }
2767
+
2768
+ /**
2769
+ * Parse the mappings in a string in to a data structure which we can easily
2770
+ * query (the ordered arrays in the `this.__generatedMappings` and
2771
+ * `this.__originalMappings` properties).
2772
+ */
2773
+ _parseMappings(aStr, aSourceRoot) {
2774
+ const generatedMappings = this.__generatedMappingsUnsorted = [];
2775
+ const originalMappings = this.__originalMappingsUnsorted = [];
2776
+ for (let i = 0; i < this._sections.length; i++) {
2777
+ const section = this._sections[i];
2778
+
2779
+ const sectionMappings = [];
2780
+ section.consumer.eachMapping(m => sectionMappings.push(m));
2781
+
2782
+ for (let j = 0; j < sectionMappings.length; j++) {
2783
+ const mapping = sectionMappings[j];
2784
+
2785
+ // TODO: test if null is correct here. The original code used
2786
+ // `source`, which would actually have gotten used as null because
2787
+ // var's get hoisted.
2788
+ // See: https://github.com/mozilla/source-map/issues/333
2789
+ let source = util.computeSourceURL(section.consumer.sourceRoot, null, this._sourceMapURL);
2790
+ this._sources.add(source);
2791
+ source = this._sources.indexOf(source);
2792
+
2793
+ let name = null;
2794
+ if (mapping.name) {
2795
+ this._names.add(mapping.name);
2796
+ name = this._names.indexOf(mapping.name);
2797
+ }
2798
+
2799
+ // The mappings coming from the consumer for the section have
2800
+ // generated positions relative to the start of the section, so we
2801
+ // need to offset them to be relative to the start of the concatenated
2802
+ // generated file.
2803
+ const adjustedMapping = {
2804
+ source,
2805
+ generatedLine: mapping.generatedLine +
2806
+ (section.generatedOffset.generatedLine - 1),
2807
+ generatedColumn: mapping.generatedColumn +
2808
+ (section.generatedOffset.generatedLine === mapping.generatedLine
2809
+ ? section.generatedOffset.generatedColumn - 1
2810
+ : 0),
2811
+ originalLine: mapping.originalLine,
2812
+ originalColumn: mapping.originalColumn,
2813
+ name
2814
+ };
2815
+
2816
+ generatedMappings.push(adjustedMapping);
2817
+ if (typeof adjustedMapping.originalLine === "number") {
2818
+ originalMappings.push(adjustedMapping);
2819
+ }
2820
+ }
2821
+ }
2822
+ }
2823
+
2824
+ eachMapping(aCallback, aContext, aOrder) {
2825
+ const context = aContext || null;
2826
+ const order = aOrder || SourceMapConsumer$1.GENERATED_ORDER;
2827
+
2828
+ let mappings;
2829
+ switch (order) {
2830
+ case SourceMapConsumer$1.GENERATED_ORDER:
2831
+ mappings = this._generatedMappings;
2832
+ break;
2833
+ case SourceMapConsumer$1.ORIGINAL_ORDER:
2834
+ mappings = this._originalMappings;
2835
+ break;
2836
+ default:
2837
+ throw new Error("Unknown order of iteration.");
2838
+ }
2839
+
2840
+ const sourceRoot = this.sourceRoot;
2841
+ mappings.map(function(mapping) {
2842
+ let source = null;
2843
+ if (mapping.source !== null) {
2844
+ source = this._sources.at(mapping.source);
2845
+ source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
2846
+ }
2847
+ return {
2848
+ source,
2849
+ generatedLine: mapping.generatedLine,
2850
+ generatedColumn: mapping.generatedColumn,
2851
+ originalLine: mapping.originalLine,
2852
+ originalColumn: mapping.originalColumn,
2853
+ name: mapping.name === null ? null : this._names.at(mapping.name)
2854
+ };
2855
+ }, this).forEach(aCallback, context);
2856
+ }
2857
+
2858
+ /**
2859
+ * Find the mapping that best matches the hypothetical "needle" mapping that
2860
+ * we are searching for in the given "haystack" of mappings.
2861
+ */
2862
+ _findMapping(aNeedle, aMappings, aLineName,
2863
+ aColumnName, aComparator, aBias) {
2864
+ // To return the position we are searching for, we must first find the
2865
+ // mapping for the given position and then return the opposite position it
2866
+ // points to. Because the mappings are sorted, we can use binary search to
2867
+ // find the best mapping.
2868
+
2869
+ if (aNeedle[aLineName] <= 0) {
2870
+ throw new TypeError("Line must be greater than or equal to 1, got "
2871
+ + aNeedle[aLineName]);
2872
+ }
2873
+ if (aNeedle[aColumnName] < 0) {
2874
+ throw new TypeError("Column must be greater than or equal to 0, got "
2875
+ + aNeedle[aColumnName]);
2876
+ }
2877
+
2878
+ return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
2879
+ }
2880
+
2881
+ allGeneratedPositionsFor(aArgs) {
2882
+ const line = util.getArg(aArgs, "line");
2883
+
2884
+ // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
2885
+ // returns the index of the closest mapping less than the needle. By
2886
+ // setting needle.originalColumn to 0, we thus find the last mapping for
2887
+ // the given line, provided such a mapping exists.
2888
+ const needle = {
2889
+ source: util.getArg(aArgs, "source"),
2890
+ originalLine: line,
2891
+ originalColumn: util.getArg(aArgs, "column", 0)
2892
+ };
2893
+
2894
+ needle.source = this._findSourceIndex(needle.source);
2895
+ if (needle.source < 0) {
2896
+ return [];
2897
+ }
2898
+
2899
+ if (needle.originalLine < 1) {
2900
+ throw new Error("Line numbers must be >= 1");
2901
+ }
2902
+
2903
+ if (needle.originalColumn < 0) {
2904
+ throw new Error("Column numbers must be >= 0");
2905
+ }
2906
+
2907
+ const mappings = [];
2908
+
2909
+ let index = this._findMapping(needle,
2910
+ this._originalMappings,
2911
+ "originalLine",
2912
+ "originalColumn",
2913
+ util.compareByOriginalPositions,
2914
+ binarySearch.LEAST_UPPER_BOUND);
2915
+ if (index >= 0) {
2916
+ let mapping = this._originalMappings[index];
2917
+
2918
+ if (aArgs.column === undefined) {
2919
+ const originalLine = mapping.originalLine;
2920
+
2921
+ // Iterate until either we run out of mappings, or we run into
2922
+ // a mapping for a different line than the one we found. Since
2923
+ // mappings are sorted, this is guaranteed to find all mappings for
2924
+ // the line we found.
2925
+ while (mapping && mapping.originalLine === originalLine) {
2926
+ let lastColumn = mapping.lastGeneratedColumn;
2927
+ if (this._computedColumnSpans && lastColumn === null) {
2928
+ lastColumn = Infinity;
2929
+ }
2930
+ mappings.push({
2931
+ line: util.getArg(mapping, "generatedLine", null),
2932
+ column: util.getArg(mapping, "generatedColumn", null),
2933
+ lastColumn,
2934
+ });
2935
+
2936
+ mapping = this._originalMappings[++index];
2937
+ }
2938
+ } else {
2939
+ const originalColumn = mapping.originalColumn;
2940
+
2941
+ // Iterate until either we run out of mappings, or we run into
2942
+ // a mapping for a different line than the one we were searching for.
2943
+ // Since mappings are sorted, this is guaranteed to find all mappings for
2944
+ // the line we are searching for.
2945
+ while (mapping &&
2946
+ mapping.originalLine === line &&
2947
+ mapping.originalColumn == originalColumn) {
2948
+ let lastColumn = mapping.lastGeneratedColumn;
2949
+ if (this._computedColumnSpans && lastColumn === null) {
2950
+ lastColumn = Infinity;
2951
+ }
2952
+ mappings.push({
2953
+ line: util.getArg(mapping, "generatedLine", null),
2954
+ column: util.getArg(mapping, "generatedColumn", null),
2955
+ lastColumn,
2956
+ });
2957
+
2958
+ mapping = this._originalMappings[++index];
2959
+ }
2960
+ }
2961
+ }
2962
+
2963
+ return mappings;
2964
+ }
2965
+
2966
+ destroy() {
2967
+ for (let i = 0; i < this._sections.length; i++) {
2968
+ this._sections[i].consumer.destroy();
2969
+ }
2970
+ }
2971
+ }
2972
+ var IndexedSourceMapConsumer_1 = IndexedSourceMapConsumer;
2973
+
2974
+ /*
2975
+ * Cheat to get around inter-twingled classes. `factory()` can be at the end
2976
+ * where it has access to non-hoisted classes, but it gets hoisted itself.
2977
+ */
2978
+ function _factory(aSourceMap, aSourceMapURL) {
2979
+ let sourceMap = aSourceMap;
2980
+ if (typeof aSourceMap === "string") {
2981
+ sourceMap = util.parseSourceMapInput(aSourceMap);
2982
+ }
2983
+
2984
+ const consumer = sourceMap.sections != null
2985
+ ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
2986
+ : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
2987
+ return Promise.resolve(consumer);
2988
+ }
2989
+
2990
+ function _factoryBSM(aSourceMap, aSourceMapURL) {
2991
+ return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
2992
+ }
2993
+
2994
+ var sourceMapConsumer = {
2995
+ SourceMapConsumer: SourceMapConsumer_1,
2996
+ BasicSourceMapConsumer: BasicSourceMapConsumer_1,
2997
+ IndexedSourceMapConsumer: IndexedSourceMapConsumer_1
2998
+ };
2999
+
3000
+ var require$$0 = sourceMapGenerator;
3001
+
3002
+ /* -*- Mode: js; js-indent-level: 2; -*- */
3003
+
3004
+ /*
3005
+ * Copyright 2011 Mozilla Foundation and contributors
3006
+ * Licensed under the New BSD license. See LICENSE or:
3007
+ * http://opensource.org/licenses/BSD-3-Clause
3008
+ */
3009
+
3010
+ const SourceMapGenerator = require$$0.SourceMapGenerator;
3011
+
3012
+
3013
+ // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
3014
+ // operating systems these days (capturing the result).
3015
+ const REGEX_NEWLINE = /(\r?\n)/;
3016
+
3017
+ // Newline character code for charCodeAt() comparisons
3018
+ const NEWLINE_CODE = 10;
3019
+
3020
+ // Private symbol for identifying `SourceNode`s when multiple versions of
3021
+ // the source-map library are loaded. This MUST NOT CHANGE across
3022
+ // versions!
3023
+ const isSourceNode = "$$$isSourceNode$$$";
3024
+
3025
+ /**
3026
+ * SourceNodes provide a way to abstract over interpolating/concatenating
3027
+ * snippets of generated JavaScript source code while maintaining the line and
3028
+ * column information associated with the original source code.
3029
+ *
3030
+ * @param aLine The original line number.
3031
+ * @param aColumn The original column number.
3032
+ * @param aSource The original source's filename.
3033
+ * @param aChunks Optional. An array of strings which are snippets of
3034
+ * generated JS, or other SourceNodes.
3035
+ * @param aName The original identifier.
3036
+ */
3037
+ class SourceNode {
3038
+ constructor(aLine, aColumn, aSource, aChunks, aName) {
3039
+ this.children = [];
3040
+ this.sourceContents = {};
3041
+ this.line = aLine == null ? null : aLine;
3042
+ this.column = aColumn == null ? null : aColumn;
3043
+ this.source = aSource == null ? null : aSource;
3044
+ this.name = aName == null ? null : aName;
3045
+ this[isSourceNode] = true;
3046
+ if (aChunks != null) this.add(aChunks);
3047
+ }
3048
+
3049
+ /**
3050
+ * Creates a SourceNode from generated code and a SourceMapConsumer.
3051
+ *
3052
+ * @param aGeneratedCode The generated code
3053
+ * @param aSourceMapConsumer The SourceMap for the generated code
3054
+ * @param aRelativePath Optional. The path that relative sources in the
3055
+ * SourceMapConsumer should be relative to.
3056
+ */
3057
+ static fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
3058
+ // The SourceNode we want to fill with the generated code
3059
+ // and the SourceMap
3060
+ const node = new SourceNode();
3061
+
3062
+ // All even indices of this array are one line of the generated code,
3063
+ // while all odd indices are the newlines between two adjacent lines
3064
+ // (since `REGEX_NEWLINE` captures its match).
3065
+ // Processed fragments are accessed by calling `shiftNextLine`.
3066
+ const remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
3067
+ let remainingLinesIndex = 0;
3068
+ const shiftNextLine = function() {
3069
+ const lineContents = getNextLine();
3070
+ // The last line of a file might not have a newline.
3071
+ const newLine = getNextLine() || "";
3072
+ return lineContents + newLine;
3073
+
3074
+ function getNextLine() {
3075
+ return remainingLinesIndex < remainingLines.length ?
3076
+ remainingLines[remainingLinesIndex++] : undefined;
3077
+ }
3078
+ };
3079
+
3080
+ // We need to remember the position of "remainingLines"
3081
+ let lastGeneratedLine = 1, lastGeneratedColumn = 0;
3082
+
3083
+ // The generate SourceNodes we need a code range.
3084
+ // To extract it current and last mapping is used.
3085
+ // Here we store the last mapping.
3086
+ let lastMapping = null;
3087
+ let nextLine;
3088
+
3089
+ aSourceMapConsumer.eachMapping(function(mapping) {
3090
+ if (lastMapping !== null) {
3091
+ // We add the code from "lastMapping" to "mapping":
3092
+ // First check if there is a new line in between.
3093
+ if (lastGeneratedLine < mapping.generatedLine) {
3094
+ // Associate first line with "lastMapping"
3095
+ addMappingWithCode(lastMapping, shiftNextLine());
3096
+ lastGeneratedLine++;
3097
+ lastGeneratedColumn = 0;
3098
+ // The remaining code is added without mapping
3099
+ } else {
3100
+ // There is no new line in between.
3101
+ // Associate the code between "lastGeneratedColumn" and
3102
+ // "mapping.generatedColumn" with "lastMapping"
3103
+ nextLine = remainingLines[remainingLinesIndex] || "";
3104
+ const code = nextLine.substr(0, mapping.generatedColumn -
3105
+ lastGeneratedColumn);
3106
+ remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
3107
+ lastGeneratedColumn);
3108
+ lastGeneratedColumn = mapping.generatedColumn;
3109
+ addMappingWithCode(lastMapping, code);
3110
+ // No more remaining code, continue
3111
+ lastMapping = mapping;
3112
+ return;
3113
+ }
3114
+ }
3115
+ // We add the generated code until the first mapping
3116
+ // to the SourceNode without any mapping.
3117
+ // Each line is added as separate string.
3118
+ while (lastGeneratedLine < mapping.generatedLine) {
3119
+ node.add(shiftNextLine());
3120
+ lastGeneratedLine++;
3121
+ }
3122
+ if (lastGeneratedColumn < mapping.generatedColumn) {
3123
+ nextLine = remainingLines[remainingLinesIndex] || "";
3124
+ node.add(nextLine.substr(0, mapping.generatedColumn));
3125
+ remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
3126
+ lastGeneratedColumn = mapping.generatedColumn;
3127
+ }
3128
+ lastMapping = mapping;
3129
+ }, this);
3130
+ // We have processed all mappings.
3131
+ if (remainingLinesIndex < remainingLines.length) {
3132
+ if (lastMapping) {
3133
+ // Associate the remaining code in the current line with "lastMapping"
3134
+ addMappingWithCode(lastMapping, shiftNextLine());
3135
+ }
3136
+ // and add the remaining lines without any mapping
3137
+ node.add(remainingLines.splice(remainingLinesIndex).join(""));
3138
+ }
3139
+
3140
+ // Copy sourcesContent into SourceNode
3141
+ aSourceMapConsumer.sources.forEach(function(sourceFile) {
3142
+ const content = aSourceMapConsumer.sourceContentFor(sourceFile);
3143
+ if (content != null) {
3144
+ if (aRelativePath != null) {
3145
+ sourceFile = util.join(aRelativePath, sourceFile);
3146
+ }
3147
+ node.setSourceContent(sourceFile, content);
3148
+ }
3149
+ });
3150
+
3151
+ return node;
3152
+
3153
+ function addMappingWithCode(mapping, code) {
3154
+ if (mapping === null || mapping.source === undefined) {
3155
+ node.add(code);
3156
+ } else {
3157
+ const source = aRelativePath
3158
+ ? util.join(aRelativePath, mapping.source)
3159
+ : mapping.source;
3160
+ node.add(new SourceNode(mapping.originalLine,
3161
+ mapping.originalColumn,
3162
+ source,
3163
+ code,
3164
+ mapping.name));
3165
+ }
3166
+ }
3167
+ }
3168
+
3169
+ /**
3170
+ * Add a chunk of generated JS to this source node.
3171
+ *
3172
+ * @param aChunk A string snippet of generated JS code, another instance of
3173
+ * SourceNode, or an array where each member is one of those things.
3174
+ */
3175
+ add(aChunk) {
3176
+ if (Array.isArray(aChunk)) {
3177
+ aChunk.forEach(function(chunk) {
3178
+ this.add(chunk);
3179
+ }, this);
3180
+ } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
3181
+ if (aChunk) {
3182
+ this.children.push(aChunk);
3183
+ }
3184
+ } else {
3185
+ throw new TypeError(
3186
+ "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
3187
+ );
3188
+ }
3189
+ return this;
3190
+ }
3191
+
3192
+ /**
3193
+ * Add a chunk of generated JS to the beginning of this source node.
3194
+ *
3195
+ * @param aChunk A string snippet of generated JS code, another instance of
3196
+ * SourceNode, or an array where each member is one of those things.
3197
+ */
3198
+ prepend(aChunk) {
3199
+ if (Array.isArray(aChunk)) {
3200
+ for (let i = aChunk.length - 1; i >= 0; i--) {
3201
+ this.prepend(aChunk[i]);
3202
+ }
3203
+ } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
3204
+ this.children.unshift(aChunk);
3205
+ } else {
3206
+ throw new TypeError(
3207
+ "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
3208
+ );
3209
+ }
3210
+ return this;
3211
+ }
3212
+
3213
+ /**
3214
+ * Walk over the tree of JS snippets in this node and its children. The
3215
+ * walking function is called once for each snippet of JS and is passed that
3216
+ * snippet and the its original associated source's line/column location.
3217
+ *
3218
+ * @param aFn The traversal function.
3219
+ */
3220
+ walk(aFn) {
3221
+ let chunk;
3222
+ for (let i = 0, len = this.children.length; i < len; i++) {
3223
+ chunk = this.children[i];
3224
+ if (chunk[isSourceNode]) {
3225
+ chunk.walk(aFn);
3226
+ } else if (chunk !== "") {
3227
+ aFn(chunk, { source: this.source,
3228
+ line: this.line,
3229
+ column: this.column,
3230
+ name: this.name });
3231
+ }
3232
+ }
3233
+ }
3234
+
3235
+ /**
3236
+ * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
3237
+ * each of `this.children`.
3238
+ *
3239
+ * @param aSep The separator.
3240
+ */
3241
+ join(aSep) {
3242
+ let newChildren;
3243
+ let i;
3244
+ const len = this.children.length;
3245
+ if (len > 0) {
3246
+ newChildren = [];
3247
+ for (i = 0; i < len - 1; i++) {
3248
+ newChildren.push(this.children[i]);
3249
+ newChildren.push(aSep);
3250
+ }
3251
+ newChildren.push(this.children[i]);
3252
+ this.children = newChildren;
3253
+ }
3254
+ return this;
3255
+ }
3256
+
3257
+ /**
3258
+ * Call String.prototype.replace on the very right-most source snippet. Useful
3259
+ * for trimming whitespace from the end of a source node, etc.
3260
+ *
3261
+ * @param aPattern The pattern to replace.
3262
+ * @param aReplacement The thing to replace the pattern with.
3263
+ */
3264
+ replaceRight(aPattern, aReplacement) {
3265
+ const lastChild = this.children[this.children.length - 1];
3266
+ if (lastChild[isSourceNode]) {
3267
+ lastChild.replaceRight(aPattern, aReplacement);
3268
+ } else if (typeof lastChild === "string") {
3269
+ this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
3270
+ } else {
3271
+ this.children.push("".replace(aPattern, aReplacement));
3272
+ }
3273
+ return this;
3274
+ }
3275
+
3276
+ /**
3277
+ * Set the source content for a source file. This will be added to the SourceMapGenerator
3278
+ * in the sourcesContent field.
3279
+ *
3280
+ * @param aSourceFile The filename of the source file
3281
+ * @param aSourceContent The content of the source file
3282
+ */
3283
+ setSourceContent(aSourceFile, aSourceContent) {
3284
+ this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
3285
+ }
3286
+
3287
+ /**
3288
+ * Walk over the tree of SourceNodes. The walking function is called for each
3289
+ * source file content and is passed the filename and source content.
3290
+ *
3291
+ * @param aFn The traversal function.
3292
+ */
3293
+ walkSourceContents(aFn) {
3294
+ for (let i = 0, len = this.children.length; i < len; i++) {
3295
+ if (this.children[i][isSourceNode]) {
3296
+ this.children[i].walkSourceContents(aFn);
3297
+ }
3298
+ }
3299
+
3300
+ const sources = Object.keys(this.sourceContents);
3301
+ for (let i = 0, len = sources.length; i < len; i++) {
3302
+ aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
3303
+ }
3304
+ }
3305
+
3306
+ /**
3307
+ * Return the string representation of this source node. Walks over the tree
3308
+ * and concatenates all the various snippets together to one string.
3309
+ */
3310
+ toString() {
3311
+ let str = "";
3312
+ this.walk(function(chunk) {
3313
+ str += chunk;
3314
+ });
3315
+ return str;
3316
+ }
3317
+
3318
+ /**
3319
+ * Returns the string representation of this source node along with a source
3320
+ * map.
3321
+ */
3322
+ toStringWithSourceMap(aArgs) {
3323
+ const generated = {
3324
+ code: "",
3325
+ line: 1,
3326
+ column: 0
3327
+ };
3328
+ const map = new SourceMapGenerator(aArgs);
3329
+ let sourceMappingActive = false;
3330
+ let lastOriginalSource = null;
3331
+ let lastOriginalLine = null;
3332
+ let lastOriginalColumn = null;
3333
+ let lastOriginalName = null;
3334
+ this.walk(function(chunk, original) {
3335
+ generated.code += chunk;
3336
+ if (original.source !== null
3337
+ && original.line !== null
3338
+ && original.column !== null) {
3339
+ if (lastOriginalSource !== original.source
3340
+ || lastOriginalLine !== original.line
3341
+ || lastOriginalColumn !== original.column
3342
+ || lastOriginalName !== original.name) {
3343
+ map.addMapping({
3344
+ source: original.source,
3345
+ original: {
3346
+ line: original.line,
3347
+ column: original.column
3348
+ },
3349
+ generated: {
3350
+ line: generated.line,
3351
+ column: generated.column
3352
+ },
3353
+ name: original.name
3354
+ });
3355
+ }
3356
+ lastOriginalSource = original.source;
3357
+ lastOriginalLine = original.line;
3358
+ lastOriginalColumn = original.column;
3359
+ lastOriginalName = original.name;
3360
+ sourceMappingActive = true;
3361
+ } else if (sourceMappingActive) {
3362
+ map.addMapping({
3363
+ generated: {
3364
+ line: generated.line,
3365
+ column: generated.column
3366
+ }
3367
+ });
3368
+ lastOriginalSource = null;
3369
+ sourceMappingActive = false;
3370
+ }
3371
+ for (let idx = 0, length = chunk.length; idx < length; idx++) {
3372
+ if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
3373
+ generated.line++;
3374
+ generated.column = 0;
3375
+ // Mappings end at eol
3376
+ if (idx + 1 === length) {
3377
+ lastOriginalSource = null;
3378
+ sourceMappingActive = false;
3379
+ } else if (sourceMappingActive) {
3380
+ map.addMapping({
3381
+ source: original.source,
3382
+ original: {
3383
+ line: original.line,
3384
+ column: original.column
3385
+ },
3386
+ generated: {
3387
+ line: generated.line,
3388
+ column: generated.column
3389
+ },
3390
+ name: original.name
3391
+ });
3392
+ }
3393
+ } else {
3394
+ generated.column++;
3395
+ }
3396
+ }
3397
+ });
3398
+ this.walkSourceContents(function(sourceFile, sourceContent) {
3399
+ map.setSourceContent(sourceFile, sourceContent);
3400
+ });
3401
+
3402
+ return { code: generated.code, map };
3403
+ }
3404
+ }
3405
+
3406
+ var SourceNode_1 = SourceNode;
3407
+
3408
+ var sourceNode = {
3409
+ SourceNode: SourceNode_1
3410
+ };
3411
+
3412
+ var require$$1 = sourceMapConsumer;
3413
+
3414
+ var require$$2 = sourceNode;
3415
+
3416
+ /*
3417
+ * Copyright 2009-2011 Mozilla Foundation and contributors
3418
+ * Licensed under the New BSD license. See LICENSE.txt or:
3419
+ * http://opensource.org/licenses/BSD-3-Clause
3420
+ */
3421
+
3422
+ require$$0.SourceMapGenerator;
3423
+ var SourceMapConsumer = require$$1.SourceMapConsumer;
3424
+ require$$2.SourceNode;
3425
+
209
3426
  const nixSlashes = (x) => x.replace(/\\/g, '/');
210
3427
  const sourcemapCatch = {};
211
3428
  function stacktracey(stacktrace, opts) {
@@ -296,14 +3513,14 @@ function isThirdParty(relativePath) {
296
3513
  function getConsumer(content) {
297
3514
  return new Promise((resolve, reject) => {
298
3515
  try {
299
- if (sourceMap.SourceMapConsumer.with) {
300
- sourceMap.SourceMapConsumer.with(content, null, (consumer) => {
3516
+ if (SourceMapConsumer.with) {
3517
+ SourceMapConsumer.with(content, null, (consumer) => {
301
3518
  resolve(consumer);
302
3519
  });
303
3520
  }
304
3521
  else {
305
3522
  // @ts-ignore
306
- const consumer = sourceMap.SourceMapConsumer(content);
3523
+ const consumer = SourceMapConsumer(content);
307
3524
  resolve(consumer);
308
3525
  }
309
3526
  }
@@ -335,7 +3552,7 @@ function getSourceMapContent(sourcemapUrl) {
335
3552
  });
336
3553
  }
337
3554
  else {
338
- sourcemapCatch[sourcemapUrl] = fs__default["default"].readFileSync(sourcemapUrl, 'utf-8');
3555
+ sourcemapCatch[sourcemapUrl] = require$$0__default["default"].readFileSync(sourcemapUrl, 'utf-8');
339
3556
  resolve(sourcemapCatch[sourcemapUrl]);
340
3557
  }
341
3558
  }