@dcloudio/uni-stacktracey 2.0.2-4010420240430001 → 2.0.2-4020320240708001

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.
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+ var os = require('os');
4
6
 
5
- var require$$0$2 = require('fs');
6
- var require$$1$2 = require('path');
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
8
 
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
11
- var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
9
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
10
+ var path__default = /*#__PURE__*/_interopDefault(path);
11
+ var os__default = /*#__PURE__*/_interopDefault(os);
12
12
 
13
13
  /* ------------------------------------------------------------------------ */
14
14
  const O = Object, isBrowser =
@@ -17,7 +17,9 @@ typeof window !== 'undefined' &&
17
17
  /* eslint-disable */
18
18
  window.window === window &&
19
19
  /* eslint-disable */
20
- window.navigator, nodeRequire = isBrowser ? null : module.require, // to prevent bundlers from expanding the require call
20
+ window.navigator,
21
+ // @ts-ignore
22
+ nodeRequire = isBrowser ? null : module.require, // to prevent bundlers from expanding the require call
21
23
  lastOf = (x) => x[x.length - 1], nixSlashes$1 = (x) => x.replace(/\\/g, '/'), pathRoot = isBrowser ? window.location.href : nixSlashes$1(process.cwd()) + '/';
22
24
  /* ------------------------------------------------------------------------ */
23
25
  class StackTracey {
@@ -94,7 +96,7 @@ class StackTracey {
94
96
  result = externalDomainMatch ? externalDomainMatch[3] : result;
95
97
  // if (!isBrowser) result = nodeRequire!('path').relative(pathRoot, result)
96
98
  return [
97
- nixSlashes$1(result).replace(/^.*\:\/\/?\/?/, ''),
99
+ nixSlashes$1(result).replace(/^.*\:\/\/?\/?/, ''), // cut webpack:/// and webpack:/ things
98
100
  externalDomain,
99
101
  ];
100
102
  }
@@ -190,8 +192,8 @@ function parseItem(e, maxColumnWidths, isMP) {
190
192
  return e.beforeParse;
191
193
  }
192
194
  const filePath = (isMP ? e.file && e.file : e.fileShort && e.fileShort) +
193
- `${e.line ? ':' + e.line : ''}` +
194
- `${e.column ? ':' + e.column : ''}`;
195
+ `${typeof e.line !== 'undefined' ? ':' + e.line : ''}` +
196
+ `${typeof e.column !== 'undefined' ? ':' + e.column : ''}`;
195
197
  return [
196
198
  'at ' + trimEnd(isMP ? e.callee : e.calleeShort, maxColumnWidths.callee),
197
199
  trimStart(filePath || '', maxColumnWidths.file),
@@ -204,692 +206,572 @@ function parseItem(e, maxColumnWidths, isMP) {
204
206
  return new StackTracey(this.items[method].apply(this.items, arguments));
205
207
  };
206
208
  });
207
- /* ------------------------------------------------------------------------ */
208
- var StackTracey$1 = StackTracey;
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
209
 
229
- var base64$1 = {
230
- encode: encode$1
231
- };
232
-
233
- var base64 = base64$1;
210
+ var util$1 = {};
234
211
 
235
212
  /* -*- Mode: js; js-indent-level: 2; -*- */
236
213
 
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
- }
214
+ (function (exports) {
215
+ /*
216
+ * Copyright 2011 Mozilla Foundation and contributors
217
+ * Licensed under the New BSD license. See LICENSE or:
218
+ * http://opensource.org/licenses/BSD-3-Clause
219
+ */
220
+
221
+ /**
222
+ * This is a helper function for getting values from parameter/options
223
+ * objects.
224
+ *
225
+ * @param args The object we are extracting values from
226
+ * @param name The name of the property we are getting.
227
+ * @param defaultValue An optional value to return if the property is missing
228
+ * from the object. If this is not specified and the property is missing, an
229
+ * error will be thrown.
230
+ */
231
+ function getArg(aArgs, aName, aDefaultValue) {
232
+ if (aName in aArgs) {
233
+ return aArgs[aName]
234
+ } else if (arguments.length === 3) {
235
+ return aDefaultValue
236
+ }
237
+ throw new Error('"' + aName + '" is a required argument.')
238
+ }
239
+ exports.getArg = getArg;
240
+
241
+ const urlRegexp =
242
+ /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
243
+ const dataUrlRegexp = /^data:.+\,.+$/;
244
+
245
+ function urlParse(aUrl) {
246
+ const match = aUrl.match(urlRegexp);
247
+ if (!match) {
248
+ return null
249
+ }
250
+ return {
251
+ scheme: match[1],
252
+ auth: match[2],
253
+ host: match[3],
254
+ port: match[4],
255
+ path: match[5],
256
+ }
257
+ }
258
+ exports.urlParse = urlParse;
259
+
260
+ function urlGenerate(aParsedUrl) {
261
+ let url = '';
262
+ if (aParsedUrl.scheme) {
263
+ url += aParsedUrl.scheme + ':';
264
+ }
265
+ url += '//';
266
+ if (aParsedUrl.auth) {
267
+ url += aParsedUrl.auth + '@';
268
+ }
269
+ if (aParsedUrl.host) {
270
+ url += aParsedUrl.host;
271
+ }
272
+ if (aParsedUrl.port) {
273
+ url += ':' + aParsedUrl.port;
274
+ }
275
+ if (aParsedUrl.path) {
276
+ url += aParsedUrl.path;
277
+ }
278
+ return url
279
+ }
280
+ exports.urlGenerate = urlGenerate;
281
+
282
+ const MAX_CACHED_INPUTS = 32;
283
+
284
+ /**
285
+ * Takes some function `f(input) -> result` and returns a memoized version of
286
+ * `f`.
287
+ *
288
+ * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
289
+ * memoization is a dumb-simple, linear least-recently-used cache.
290
+ */
291
+ function lruMemoize(f) {
292
+ const cache = [];
293
+
294
+ return function (input) {
295
+ for (let i = 0; i < cache.length; i++) {
296
+ if (cache[i].input === input) {
297
+ const temp = cache[0];
298
+ cache[0] = cache[i];
299
+ cache[i] = temp;
300
+ return cache[0].result
301
+ }
302
+ }
303
+
304
+ const result = f(input);
305
+
306
+ cache.unshift({
307
+ input,
308
+ result,
309
+ });
310
+
311
+ if (cache.length > MAX_CACHED_INPUTS) {
312
+ cache.pop();
313
+ }
314
+
315
+ return result
316
+ }
317
+ }
318
+
319
+ /**
320
+ * Normalizes a path, or the path portion of a URL:
321
+ *
322
+ * - Replaces consecutive slashes with one slash.
323
+ * - Removes unnecessary '.' parts.
324
+ * - Removes unnecessary '<dir>/..' parts.
325
+ *
326
+ * Based on code in the Node.js 'path' core module.
327
+ *
328
+ * @param aPath The path or url to normalize.
329
+ */
330
+ const normalize = lruMemoize(function normalize(aPath) {
331
+ let path = aPath;
332
+ const url = urlParse(aPath);
333
+ if (url) {
334
+ if (!url.path) {
335
+ return aPath
336
+ }
337
+ path = url.path;
338
+ }
339
+ const isAbsolute = exports.isAbsolute(path);
340
+
341
+ // Split the path into parts between `/` characters. This is much faster than
342
+ // using `.split(/\/+/g)`.
343
+ const parts = [];
344
+ let start = 0;
345
+ let i = 0;
346
+ while (true) {
347
+ start = i;
348
+ i = path.indexOf('/', start);
349
+ if (i === -1) {
350
+ parts.push(path.slice(start));
351
+ break
352
+ } else {
353
+ parts.push(path.slice(start, i));
354
+ while (i < path.length && path[i] === '/') {
355
+ i++;
356
+ }
357
+ }
358
+ }
359
+
360
+ let up = 0;
361
+ for (i = parts.length - 1; i >= 0; i--) {
362
+ const part = parts[i];
363
+ if (part === '.') {
364
+ parts.splice(i, 1);
365
+ } else if (part === '..') {
366
+ up++;
367
+ } else if (up > 0) {
368
+ if (part === '') {
369
+ // The first part is blank if the path is absolute. Trying to go
370
+ // above the root is a no-op. Therefore we can remove all '..' parts
371
+ // directly after the root.
372
+ parts.splice(i + 1, up);
373
+ up = 0;
374
+ } else {
375
+ parts.splice(i, 2);
376
+ up--;
377
+ }
378
+ }
379
+ }
380
+ path = parts.join('/');
381
+
382
+ if (path === '') {
383
+ path = isAbsolute ? '/' : '.';
384
+ }
385
+
386
+ if (url) {
387
+ url.path = path;
388
+ return urlGenerate(url)
389
+ }
390
+ return path
391
+ });
392
+ exports.normalize = normalize;
393
+
394
+ /**
395
+ * Joins two paths/URLs.
396
+ *
397
+ * @param aRoot The root path or URL.
398
+ * @param aPath The path or URL to be joined with the root.
399
+ *
400
+ * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
401
+ * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
402
+ * first.
403
+ * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
404
+ * is updated with the result and aRoot is returned. Otherwise the result
405
+ * is returned.
406
+ * - If aPath is absolute, the result is aPath.
407
+ * - Otherwise the two paths are joined with a slash.
408
+ * - Joining for example 'http://' and 'www.example.com' is also supported.
409
+ */
410
+ function join(aRoot, aPath) {
411
+ if (aRoot === '') {
412
+ aRoot = '.';
413
+ }
414
+ if (aPath === '') {
415
+ aPath = '.';
416
+ }
417
+ const aPathUrl = urlParse(aPath);
418
+ const aRootUrl = urlParse(aRoot);
419
+ if (aRootUrl) {
420
+ aRoot = aRootUrl.path || '/';
421
+ }
422
+
423
+ // `join(foo, '//www.example.org')`
424
+ if (aPathUrl && !aPathUrl.scheme) {
425
+ if (aRootUrl) {
426
+ aPathUrl.scheme = aRootUrl.scheme;
427
+ }
428
+ return urlGenerate(aPathUrl)
429
+ }
430
+
431
+ if (aPathUrl || aPath.match(dataUrlRegexp)) {
432
+ return aPath
433
+ }
434
+
435
+ // `join('http://', 'www.example.com')`
436
+ if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
437
+ aRootUrl.host = aPath;
438
+ return urlGenerate(aRootUrl)
439
+ }
440
+
441
+ const joined =
442
+ aPath.charAt(0) === '/'
443
+ ? aPath
444
+ : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
445
+
446
+ if (aRootUrl) {
447
+ aRootUrl.path = joined;
448
+ return urlGenerate(aRootUrl)
449
+ }
450
+ return joined
451
+ }
452
+ exports.join = join;
453
+
454
+ exports.isAbsolute = function (aPath) {
455
+ return aPath.charAt(0) === '/' || urlRegexp.test(aPath)
456
+ };
457
+
458
+ /**
459
+ * Make a path relative to a URL or another path.
460
+ *
461
+ * @param aRoot The root path or URL.
462
+ * @param aPath The path or URL to be made relative to aRoot.
463
+ */
464
+ function relative(aRoot, aPath) {
465
+ if (aRoot === '') {
466
+ aRoot = '.';
467
+ }
468
+
469
+ aRoot = aRoot.replace(/\/$/, '');
470
+
471
+ // It is possible for the path to be above the root. In this case, simply
472
+ // checking whether the root is a prefix of the path won't work. Instead, we
473
+ // need to remove components from the root one by one, until either we find
474
+ // a prefix that fits, or we run out of components to remove.
475
+ let level = 0;
476
+ while (aPath.indexOf(aRoot + '/') !== 0) {
477
+ const index = aRoot.lastIndexOf('/');
478
+ if (index < 0) {
479
+ return aPath
480
+ }
481
+
482
+ // If the only part of the root that is left is the scheme (i.e. http://,
483
+ // file:///, etc.), one or more slashes (/), or simply nothing at all, we
484
+ // have exhausted all components, so the path is not relative to the root.
485
+ aRoot = aRoot.slice(0, index);
486
+ if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
487
+ return aPath
488
+ }
489
+
490
+ ++level;
491
+ }
492
+
493
+ // Make sure we add a "../" for each component we removed from the root.
494
+ return Array(level + 1).join('../') + aPath.substr(aRoot.length + 1)
495
+ }
496
+ exports.relative = relative;
497
+
498
+ const supportsNullProto = (function () {
499
+ const obj = Object.create(null);
500
+ return !('__proto__' in obj)
501
+ })();
502
+
503
+ function identity(s) {
504
+ return s
505
+ }
506
+
507
+ /**
508
+ * Because behavior goes wacky when you set `__proto__` on objects, we
509
+ * have to prefix all the strings in our set with an arbitrary character.
510
+ *
511
+ * See https://github.com/mozilla/source-map/pull/31 and
512
+ * https://github.com/mozilla/source-map/issues/30
513
+ *
514
+ * @param String aStr
515
+ */
516
+ function toSetString(aStr) {
517
+ if (isProtoString(aStr)) {
518
+ return '$' + aStr
519
+ }
520
+
521
+ return aStr
522
+ }
523
+ exports.toSetString = supportsNullProto ? identity : toSetString;
524
+
525
+ function fromSetString(aStr) {
526
+ if (isProtoString(aStr)) {
527
+ return aStr.slice(1)
528
+ }
529
+
530
+ return aStr
531
+ }
532
+ exports.fromSetString = supportsNullProto ? identity : fromSetString;
533
+
534
+ function isProtoString(s) {
535
+ if (!s) {
536
+ return false
537
+ }
538
+
539
+ const length = s.length;
540
+
541
+ if (length < 9 /* "__proto__".length */) {
542
+ return false
543
+ }
544
+
545
+ /* eslint-disable no-multi-spaces */
546
+ if (
547
+ s.charCodeAt(length - 1) !== 95 /* '_' */ ||
548
+ s.charCodeAt(length - 2) !== 95 /* '_' */ ||
549
+ s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
550
+ s.charCodeAt(length - 4) !== 116 /* 't' */ ||
551
+ s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
552
+ s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
553
+ s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
554
+ s.charCodeAt(length - 8) !== 95 /* '_' */ ||
555
+ s.charCodeAt(length - 9) !== 95 /* '_' */
556
+ ) {
557
+ return false
558
+ }
559
+ /* eslint-enable no-multi-spaces */
560
+
561
+ for (let i = length - 10; i >= 0; i--) {
562
+ if (s.charCodeAt(i) !== 36 /* '$' */) {
563
+ return false
564
+ }
565
+ }
566
+
567
+ return true
568
+ }
569
+
570
+ /**
571
+ * Comparator between two mappings where the original positions are compared.
572
+ *
573
+ * Optionally pass in `true` as `onlyCompareGenerated` to consider two
574
+ * mappings with the same original source/line/column, but different generated
575
+ * line and column the same. Useful when searching for a mapping with a
576
+ * stubbed out mapping.
577
+ */
578
+ function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
579
+ let cmp = strcmp(mappingA.source, mappingB.source);
580
+ if (cmp !== 0) {
581
+ return cmp
582
+ }
583
+
584
+ cmp = mappingA.originalLine - mappingB.originalLine;
585
+ if (cmp !== 0) {
586
+ return cmp
587
+ }
588
+
589
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
590
+ if (cmp !== 0 || onlyCompareOriginal) {
591
+ return cmp
592
+ }
593
+
594
+ cmp = mappingA.generatedColumn - mappingB.generatedColumn;
595
+ if (cmp !== 0) {
596
+ return cmp
597
+ }
598
+
599
+ cmp = mappingA.generatedLine - mappingB.generatedLine;
600
+ if (cmp !== 0) {
601
+ return cmp
602
+ }
603
+
604
+ return strcmp(mappingA.name, mappingB.name)
605
+ }
606
+ exports.compareByOriginalPositions = compareByOriginalPositions;
607
+
608
+ /**
609
+ * Comparator between two mappings with deflated source and name indices where
610
+ * the generated positions are compared.
611
+ *
612
+ * Optionally pass in `true` as `onlyCompareGenerated` to consider two
613
+ * mappings with the same generated line and column, but different
614
+ * source/name/original line and column the same. Useful when searching for a
615
+ * mapping with a stubbed out mapping.
616
+ */
617
+ function compareByGeneratedPositionsDeflated(
618
+ mappingA,
619
+ mappingB,
620
+ onlyCompareGenerated
621
+ ) {
622
+ let cmp = mappingA.generatedLine - mappingB.generatedLine;
623
+ if (cmp !== 0) {
624
+ return cmp
625
+ }
626
+
627
+ cmp = mappingA.generatedColumn - mappingB.generatedColumn;
628
+ if (cmp !== 0 || onlyCompareGenerated) {
629
+ return cmp
630
+ }
631
+
632
+ cmp = strcmp(mappingA.source, mappingB.source);
633
+ if (cmp !== 0) {
634
+ return cmp
635
+ }
636
+
637
+ cmp = mappingA.originalLine - mappingB.originalLine;
638
+ if (cmp !== 0) {
639
+ return cmp
640
+ }
641
+
642
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
643
+ if (cmp !== 0) {
644
+ return cmp
645
+ }
646
+
647
+ return strcmp(mappingA.name, mappingB.name)
648
+ }
649
+ exports.compareByGeneratedPositionsDeflated =
650
+ compareByGeneratedPositionsDeflated;
651
+
652
+ function strcmp(aStr1, aStr2) {
653
+ if (aStr1 === aStr2) {
654
+ return 0
655
+ }
656
+
657
+ if (aStr1 === null) {
658
+ return 1 // aStr2 !== null
659
+ }
660
+
661
+ if (aStr2 === null) {
662
+ return -1 // aStr1 !== null
663
+ }
664
+
665
+ if (aStr1 > aStr2) {
666
+ return 1
667
+ }
668
+
669
+ return -1
670
+ }
671
+
672
+ /**
673
+ * Comparator between two mappings with inflated source and name strings where
674
+ * the generated positions are compared.
675
+ */
676
+ function compareByGeneratedPositionsInflated(mappingA, mappingB) {
677
+ let cmp = mappingA.generatedLine - mappingB.generatedLine;
678
+ if (cmp !== 0) {
679
+ return cmp
680
+ }
681
+
682
+ cmp = mappingA.generatedColumn - mappingB.generatedColumn;
683
+ if (cmp !== 0) {
684
+ return cmp
685
+ }
686
+
687
+ cmp = strcmp(mappingA.source, mappingB.source);
688
+ if (cmp !== 0) {
689
+ return cmp
690
+ }
691
+
692
+ cmp = mappingA.originalLine - mappingB.originalLine;
693
+ if (cmp !== 0) {
694
+ return cmp
695
+ }
696
+
697
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
698
+ if (cmp !== 0) {
699
+ return cmp
700
+ }
701
+
702
+ return strcmp(mappingA.name, mappingB.name)
703
+ }
704
+ exports.compareByGeneratedPositionsInflated =
705
+ compareByGeneratedPositionsInflated;
706
+
707
+ /**
708
+ * Strip any JSON XSSI avoidance prefix from the string (as documented
709
+ * in the source maps specification), and then parse the string as
710
+ * JSON.
711
+ */
712
+ function parseSourceMapInput(str) {
713
+ return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''))
714
+ }
715
+ exports.parseSourceMapInput = parseSourceMapInput;
716
+
717
+ /**
718
+ * Compute the URL of a source given the the source root, the source's
719
+ * URL, and the source map's URL.
720
+ */
721
+ function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
722
+ sourceURL = sourceURL || '';
723
+
724
+ if (sourceRoot) {
725
+ // This follows what Chrome does.
726
+ if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
727
+ sourceRoot += '/';
728
+ }
729
+ // The spec says:
730
+ // Line 4: An optional source root, useful for relocating source
731
+ // files on a server or removing repeated values in the
732
+ // “sources” entry. This value is prepended to the individual
733
+ // entries in the “source” field.
734
+ sourceURL = sourceRoot + sourceURL;
735
+ }
736
+
737
+ // Historically, SourceMapConsumer did not take the sourceMapURL as
738
+ // a parameter. This mode is still somewhat supported, which is why
739
+ // this code block is conditional. However, it's preferable to pass
740
+ // the source map URL to SourceMapConsumer, so that this function
741
+ // can implement the source URL resolution algorithm as outlined in
742
+ // the spec. This block is basically the equivalent of:
743
+ // new URL(sourceURL, sourceMapURL).toString()
744
+ // ... except it avoids using URL, which wasn't available in the
745
+ // older releases of node still supported by this library.
746
+ //
747
+ // The spec says:
748
+ // If the sources are not absolute URLs after prepending of the
749
+ // “sourceRoot”, the sources are resolved relative to the
750
+ // SourceMap (like resolving script src in a html document).
751
+ if (sourceMapURL) {
752
+ const parsed = urlParse(sourceMapURL);
753
+ if (!parsed) {
754
+ throw new Error('sourceMapURL could not be parsed')
755
+ }
756
+ if (parsed.path) {
757
+ // Strip the last path component, but keep the "/".
758
+ const index = parsed.path.lastIndexOf('/');
759
+ if (index >= 0) {
760
+ parsed.path = parsed.path.substring(0, index + 1);
761
+ }
762
+ }
763
+ sourceURL = join(urlGenerate(parsed), sourceURL);
764
+ }
765
+
766
+ return normalize(sourceURL)
767
+ }
768
+ exports.computeSourceURL = computeSourceURL;
769
+ } (util$1));
770
+
771
+ var arraySet = {};
341
772
 
342
773
  /* -*- Mode: js; js-indent-level: 2; -*- */
343
774
 
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
775
  /*
894
776
  * Copyright 2011 Mozilla Foundation and contributors
895
777
  * Licensed under the New BSD license. See LICENSE or:
@@ -902,7 +784,7 @@ exports.computeSourceURL = computeSourceURL;
902
784
  * element is O(1). Removing elements from the set is not supported. Only
903
785
  * strings are supported for membership.
904
786
  */
905
- class ArraySet$2 {
787
+ let ArraySet$1 = class ArraySet {
906
788
  constructor() {
907
789
  this._array = [];
908
790
  this._set = new Map();
@@ -912,11 +794,11 @@ class ArraySet$2 {
912
794
  * Static method for creating ArraySet instances from an existing array.
913
795
  */
914
796
  static fromArray(aArray, aAllowDuplicates) {
915
- const set = new ArraySet$2();
797
+ const set = new ArraySet();
916
798
  for (let i = 0, len = aArray.length; i < len; i++) {
917
799
  set.add(aArray[i], aAllowDuplicates);
918
800
  }
919
- return set;
801
+ return set
920
802
  }
921
803
 
922
804
  /**
@@ -926,7 +808,7 @@ class ArraySet$2 {
926
808
  * @returns Number
927
809
  */
928
810
  size() {
929
- return this._set.size;
811
+ return this._set.size
930
812
  }
931
813
 
932
814
  /**
@@ -951,7 +833,7 @@ class ArraySet$2 {
951
833
  * @param String aStr
952
834
  */
953
835
  has(aStr) {
954
- return this._set.has(aStr);
836
+ return this._set.has(aStr)
955
837
  }
956
838
 
957
839
  /**
@@ -962,9 +844,9 @@ class ArraySet$2 {
962
844
  indexOf(aStr) {
963
845
  const idx = this._set.get(aStr);
964
846
  if (idx >= 0) {
965
- return idx;
847
+ return idx
966
848
  }
967
- throw new Error('"' + aStr + '" is not in the set.');
849
+ throw new Error('"' + aStr + '" is not in the set.')
968
850
  }
969
851
 
970
852
  /**
@@ -974,9 +856,9 @@ class ArraySet$2 {
974
856
  */
975
857
  at(aIdx) {
976
858
  if (aIdx >= 0 && aIdx < this._array.length) {
977
- return this._array[aIdx];
859
+ return this._array[aIdx]
978
860
  }
979
- throw new Error("No element indexed by " + aIdx);
861
+ throw new Error('No element indexed by ' + aIdx)
980
862
  }
981
863
 
982
864
  /**
@@ -985,662 +867,168 @@ class ArraySet$2 {
985
867
  * for storing the members so that no one can mess with internal state.
986
868
  */
987
869
  toArray() {
988
- return this._array.slice();
870
+ return this._array.slice()
989
871
  }
990
- }
991
- var ArraySet_1 = ArraySet$2;
992
-
993
- var arraySet = {
994
- ArraySet: ArraySet_1
995
872
  };
873
+ arraySet.ArraySet = ArraySet$1;
996
874
 
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
-
875
+ var sourceMapConsumer = {};
1007
876
 
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;
877
+ var binarySearch$1 = {};
1090
878
 
1091
879
  /* -*- Mode: js; js-indent-level: 2; -*- */
1092
880
 
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
- });
881
+ (function (exports) {
882
+ /*
883
+ * Copyright 2011 Mozilla Foundation and contributors
884
+ * Licensed under the New BSD license. See LICENSE or:
885
+ * http://opensource.org/licenses/BSD-3-Clause
886
+ */
887
+
888
+ exports.GREATEST_LOWER_BOUND = 1;
889
+ exports.LEAST_UPPER_BOUND = 2;
890
+
891
+ /**
892
+ * Recursive implementation of binary search.
893
+ *
894
+ * @param aLow Indices here and lower do not contain the needle.
895
+ * @param aHigh Indices here and higher do not contain the needle.
896
+ * @param aNeedle The element being searched for.
897
+ * @param aHaystack The non-empty array being searched.
898
+ * @param aCompare Function which takes two elements and returns -1, 0, or 1.
899
+ * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
900
+ * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
901
+ * closest element that is smaller than or greater than the one we are
902
+ * searching for, respectively, if the exact element cannot be found.
903
+ */
904
+ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
905
+ // This function terminates when one of the following is true:
906
+ //
907
+ // 1. We find the exact element we are looking for.
908
+ //
909
+ // 2. We did not find the exact element, but we can return the index of
910
+ // the next-closest element.
911
+ //
912
+ // 3. We did not find the exact element, and there is no next-closest
913
+ // element than the one we are searching for, so we return -1.
914
+ const mid = Math.floor((aHigh - aLow) / 2) + aLow;
915
+ const cmp = aCompare(aNeedle, aHaystack[mid], true);
916
+ if (cmp === 0) {
917
+ // Found the element we are looking for.
918
+ return mid
919
+ } else if (cmp > 0) {
920
+ // Our needle is greater than aHaystack[mid].
921
+ if (aHigh - mid > 1) {
922
+ // The element is in the upper half.
923
+ return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias)
924
+ }
925
+
926
+ // The exact needle element was not found in this haystack. Determine if
927
+ // we are in termination case (3) or (2) and return the appropriate thing.
928
+ if (aBias == exports.LEAST_UPPER_BOUND) {
929
+ return aHigh < aHaystack.length ? aHigh : -1
930
+ }
931
+ return mid
932
+ }
933
+
934
+ // Our needle is less than aHaystack[mid].
935
+ if (mid - aLow > 1) {
936
+ // The element is in the lower half.
937
+ return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias)
938
+ }
939
+
940
+ // we are in termination case (3) or (2) and return the appropriate thing.
941
+ if (aBias == exports.LEAST_UPPER_BOUND) {
942
+ return mid
943
+ }
944
+ return aLow < 0 ? -1 : aLow
945
+ }
946
+
947
+ /**
948
+ * This is an implementation of binary search which will always try and return
949
+ * the index of the closest element if there is no exact hit. This is because
950
+ * mappings between original and generated line/col pairs are single points,
951
+ * and there is an implicit region between each of them, so a miss just means
952
+ * that you aren't on the very start of a region.
953
+ *
954
+ * @param aNeedle The element you are looking for.
955
+ * @param aHaystack The array that is being searched.
956
+ * @param aCompare A function which takes the needle and an element in the
957
+ * array and returns -1, 0, or 1 depending on whether the needle is less
958
+ * than, equal to, or greater than the element, respectively.
959
+ * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
960
+ * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
961
+ * closest element that is smaller than or greater than the one we are
962
+ * searching for, respectively, if the exact element cannot be found.
963
+ * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
964
+ */
965
+ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
966
+ if (aHaystack.length === 0) {
967
+ return -1
968
+ }
969
+
970
+ let index = recursiveSearch(
971
+ -1,
972
+ aHaystack.length,
973
+ aNeedle,
974
+ aHaystack,
975
+ aCompare,
976
+ aBias || exports.GREATEST_LOWER_BOUND
977
+ );
978
+ if (index < 0) {
979
+ return -1
980
+ }
981
+
982
+ // We have found either the exact element, or the next-closest element than
983
+ // the one we are searching for. However, there may be more than one such
984
+ // element. Make sure we always return the smallest of these.
985
+ while (index - 1 >= 0) {
986
+ if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
987
+ break
988
+ }
989
+ --index;
990
+ }
991
+
992
+ return index
993
+ };
994
+ } (binarySearch$1));
995
+
996
+ var readWasm$2 = {exports: {}};
1614
997
 
1615
998
  /* 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
999
  {
1619
1000
  // 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"];
1001
+ const fs = fs__default.default;
1002
+ const path = path__default.default;
1622
1003
 
1623
- module.exports = function readWasm() {
1004
+ readWasm$2.exports = function readWasm() {
1624
1005
  return new Promise((resolve, reject) => {
1625
- const wasmPath = path.join(__dirname, "../lib/source-map/lib", "mappings.wasm");
1006
+ const wasmPath = path.join(
1007
+ __dirname,
1008
+ '../lib/source-map/lib',
1009
+ 'mappings.wasm'
1010
+ );
1626
1011
  fs.readFile(wasmPath, null, (error, data) => {
1627
1012
  if (error) {
1628
1013
  reject(error);
1629
- return;
1014
+ return
1630
1015
  }
1631
1016
 
1632
1017
  resolve(data.buffer);
1633
1018
  });
1634
- });
1019
+ })
1635
1020
  };
1636
1021
 
1637
- module.exports.initialize = _ => {
1638
- console.debug("SourceMapConsumer.initialize is a no-op when running in node.js");
1022
+ readWasm$2.exports.initialize = (_) => {
1023
+ console.debug(
1024
+ 'SourceMapConsumer.initialize is a no-op when running in node.js'
1025
+ );
1639
1026
  };
1640
1027
  }
1641
- });
1642
1028
 
1643
- var readWasm = readWasm$1;
1029
+ var readWasmExports = readWasm$2.exports;
1030
+
1031
+ const readWasm$1 = readWasmExports;
1644
1032
 
1645
1033
  /**
1646
1034
  * Provide the JIT with a nice shape / hidden class.
@@ -1659,12 +1047,13 @@ let cachedWasm = null;
1659
1047
 
1660
1048
  var wasm$1 = function wasm() {
1661
1049
  if (cachedWasm) {
1662
- return cachedWasm;
1050
+ return cachedWasm
1663
1051
  }
1664
1052
 
1665
1053
  const callbackStack = [];
1666
1054
 
1667
- cachedWasm = readWasm().then(buffer => {
1055
+ cachedWasm = readWasm$1()
1056
+ .then((buffer) => {
1668
1057
  return WebAssembly.instantiate(buffer, {
1669
1058
  env: {
1670
1059
  mapping_callback(
@@ -1706,52 +1095,78 @@ var wasm$1 = function wasm() {
1706
1095
  callbackStack[callbackStack.length - 1](mapping);
1707
1096
  },
1708
1097
 
1709
- start_all_generated_locations_for() { console.time("all_generated_locations_for"); },
1710
- end_all_generated_locations_for() { console.timeEnd("all_generated_locations_for"); },
1098
+ start_all_generated_locations_for() {
1099
+ console.time('all_generated_locations_for');
1100
+ },
1101
+ end_all_generated_locations_for() {
1102
+ console.timeEnd('all_generated_locations_for');
1103
+ },
1711
1104
 
1712
- start_compute_column_spans() { console.time("compute_column_spans"); },
1713
- end_compute_column_spans() { console.timeEnd("compute_column_spans"); },
1105
+ start_compute_column_spans() {
1106
+ console.time('compute_column_spans');
1107
+ },
1108
+ end_compute_column_spans() {
1109
+ console.timeEnd('compute_column_spans');
1110
+ },
1714
1111
 
1715
- start_generated_location_for() { console.time("generated_location_for"); },
1716
- end_generated_location_for() { console.timeEnd("generated_location_for"); },
1112
+ start_generated_location_for() {
1113
+ console.time('generated_location_for');
1114
+ },
1115
+ end_generated_location_for() {
1116
+ console.timeEnd('generated_location_for');
1117
+ },
1717
1118
 
1718
- start_original_location_for() { console.time("original_location_for"); },
1719
- end_original_location_for() { console.timeEnd("original_location_for"); },
1119
+ start_original_location_for() {
1120
+ console.time('original_location_for');
1121
+ },
1122
+ end_original_location_for() {
1123
+ console.timeEnd('original_location_for');
1124
+ },
1720
1125
 
1721
- start_parse_mappings() { console.time("parse_mappings"); },
1722
- end_parse_mappings() { console.timeEnd("parse_mappings"); },
1126
+ start_parse_mappings() {
1127
+ console.time('parse_mappings');
1128
+ },
1129
+ end_parse_mappings() {
1130
+ console.timeEnd('parse_mappings');
1131
+ },
1723
1132
 
1724
- start_sort_by_generated_location() { console.time("sort_by_generated_location"); },
1725
- end_sort_by_generated_location() { console.timeEnd("sort_by_generated_location"); },
1133
+ start_sort_by_generated_location() {
1134
+ console.time('sort_by_generated_location');
1135
+ },
1136
+ end_sort_by_generated_location() {
1137
+ console.timeEnd('sort_by_generated_location');
1138
+ },
1726
1139
 
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
- }
1140
+ start_sort_by_original_location() {
1141
+ console.time('sort_by_original_location');
1142
+ },
1143
+ end_sort_by_original_location() {
1144
+ console.timeEnd('sort_by_original_location');
1145
+ },
1146
+ },
1147
+ })
1148
+ })
1149
+ .then((Wasm) => {
1150
+ return {
1151
+ exports: Wasm.instance.exports,
1152
+ withMappingCallback: (mappingCallback, f) => {
1153
+ callbackStack.push(mappingCallback);
1154
+ try {
1155
+ f();
1156
+ } finally {
1157
+ callbackStack.pop();
1158
+ }
1159
+ },
1741
1160
  }
1742
- };
1743
- }).then(null, e => {
1744
- cachedWasm = null;
1745
- throw e;
1746
- });
1161
+ })
1162
+ .then(null, (e) => {
1163
+ cachedWasm = null;
1164
+ throw e
1165
+ });
1747
1166
 
1748
- return cachedWasm;
1167
+ return cachedWasm
1749
1168
  };
1750
1169
 
1751
- var binarySearch = binarySearch$1;
1752
-
1753
- var wasm = wasm$1;
1754
-
1755
1170
  /* -*- Mode: js; js-indent-level: 2; -*- */
1756
1171
 
1757
1172
  /*
@@ -1760,33 +1175,32 @@ var wasm = wasm$1;
1760
1175
  * http://opensource.org/licenses/BSD-3-Clause
1761
1176
  */
1762
1177
 
1178
+ const util = util$1;
1179
+ const binarySearch = binarySearch$1;
1180
+ const ArraySet = arraySet.ArraySet;
1181
+ const readWasm = readWasmExports;
1182
+ const wasm = wasm$1;
1763
1183
 
1184
+ const INTERNAL = Symbol('smcInternal');
1764
1185
 
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 {
1186
+ let SourceMapConsumer$1 = class SourceMapConsumer {
1773
1187
  constructor(aSourceMap, aSourceMapURL) {
1774
1188
  // If the constructor was called by super(), just return Promise<this>.
1775
1189
  // Yes, this is a hack to retain the pre-existing API of the base-class
1776
1190
  // constructor also being an async factory function.
1777
1191
  if (aSourceMap == INTERNAL) {
1778
- return Promise.resolve(this);
1192
+ return Promise.resolve(this)
1779
1193
  }
1780
1194
 
1781
- return _factory(aSourceMap, aSourceMapURL);
1195
+ return _factory(aSourceMap, aSourceMapURL)
1782
1196
  }
1783
1197
 
1784
1198
  static initialize(opts) {
1785
- readWasm.initialize(opts["lib/mappings.wasm"]);
1199
+ readWasm.initialize(opts['lib/mappings.wasm']);
1786
1200
  }
1787
1201
 
1788
1202
  static fromSourceMap(aSourceMap, aSourceMapURL) {
1789
- return _factoryBSM(aSourceMap, aSourceMapURL);
1203
+ return _factoryBSM(aSourceMap, aSourceMapURL)
1790
1204
  }
1791
1205
 
1792
1206
  /**
@@ -1820,9 +1234,9 @@ class SourceMapConsumer$1 {
1820
1234
  * ```
1821
1235
  */
1822
1236
  static async with(rawSourceMap, sourceMapUrl, f) {
1823
- const consumer = await new SourceMapConsumer$1(rawSourceMap, sourceMapUrl);
1237
+ const consumer = await new SourceMapConsumer(rawSourceMap, sourceMapUrl);
1824
1238
  try {
1825
- return await f(consumer);
1239
+ return await f(consumer)
1826
1240
  } finally {
1827
1241
  consumer.destroy();
1828
1242
  }
@@ -1834,7 +1248,7 @@ class SourceMapConsumer$1 {
1834
1248
  * `this.__originalMappings` properties).
1835
1249
  */
1836
1250
  _parseMappings(aStr, aSourceRoot) {
1837
- throw new Error("Subclasses must implement _parseMappings");
1251
+ throw new Error('Subclasses must implement _parseMappings')
1838
1252
  }
1839
1253
 
1840
1254
  /**
@@ -1854,7 +1268,7 @@ class SourceMapConsumer$1 {
1854
1268
  * `SourceMapConsumer.GENERATED_ORDER`.
1855
1269
  */
1856
1270
  eachMapping(aCallback, aContext, aOrder) {
1857
- throw new Error("Subclasses must implement eachMapping");
1271
+ throw new Error('Subclasses must implement eachMapping')
1858
1272
  }
1859
1273
 
1860
1274
  /**
@@ -1880,13 +1294,13 @@ class SourceMapConsumer$1 {
1880
1294
  * The column number is 0-based.
1881
1295
  */
1882
1296
  allGeneratedPositionsFor(aArgs) {
1883
- throw new Error("Subclasses must implement allGeneratedPositionsFor");
1297
+ throw new Error('Subclasses must implement allGeneratedPositionsFor')
1884
1298
  }
1885
1299
 
1886
1300
  destroy() {
1887
- throw new Error("Subclasses must implement destroy");
1301
+ throw new Error('Subclasses must implement destroy')
1888
1302
  }
1889
- }
1303
+ };
1890
1304
 
1891
1305
  /**
1892
1306
  * The version of the source mapping spec that we are consuming.
@@ -1898,7 +1312,7 @@ SourceMapConsumer$1.ORIGINAL_ORDER = 2;
1898
1312
  SourceMapConsumer$1.GREATEST_LOWER_BOUND = 1;
1899
1313
  SourceMapConsumer$1.LEAST_UPPER_BOUND = 2;
1900
1314
 
1901
- var SourceMapConsumer_1 = SourceMapConsumer$1;
1315
+ sourceMapConsumer.SourceMapConsumer = SourceMapConsumer$1;
1902
1316
 
1903
1317
  /**
1904
1318
  * A BasicSourceMapConsumer instance represents a parsed source map which we can
@@ -1936,26 +1350,26 @@ var SourceMapConsumer_1 = SourceMapConsumer$1;
1936
1350
  */
1937
1351
  class BasicSourceMapConsumer extends SourceMapConsumer$1 {
1938
1352
  constructor(aSourceMap, aSourceMapURL) {
1939
- return super(INTERNAL).then(that => {
1353
+ return super(INTERNAL).then((that) => {
1940
1354
  let sourceMap = aSourceMap;
1941
- if (typeof aSourceMap === "string") {
1355
+ if (typeof aSourceMap === 'string') {
1942
1356
  sourceMap = util.parseSourceMapInput(aSourceMap);
1943
1357
  }
1944
1358
 
1945
- const version = util.getArg(sourceMap, "version");
1946
- let sources = util.getArg(sourceMap, "sources");
1359
+ const version = util.getArg(sourceMap, 'version');
1360
+ let sources = util.getArg(sourceMap, 'sources');
1947
1361
  // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
1948
1362
  // 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);
1363
+ const names = util.getArg(sourceMap, 'names', []);
1364
+ let sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
1365
+ const sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
1366
+ const mappings = util.getArg(sourceMap, 'mappings');
1367
+ const file = util.getArg(sourceMap, 'file', null);
1954
1368
 
1955
1369
  // Once again, Sass deviates from the spec and supplies the version as a
1956
1370
  // string rather than a number, so we use loose equality checking here.
1957
1371
  if (version != that._version) {
1958
- throw new Error("Unsupported version: " + version);
1372
+ throw new Error('Unsupported version: ' + version)
1959
1373
  }
1960
1374
 
1961
1375
  if (sourceRoot) {
@@ -1972,10 +1386,12 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
1972
1386
  // the source root, if the source root is absolute. Not doing this would
1973
1387
  // be particularly problematic when the source root is a prefix of the
1974
1388
  // 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)
1389
+ .map(function (source) {
1390
+ return sourceRoot &&
1391
+ util.isAbsolute(sourceRoot) &&
1392
+ util.isAbsolute(source)
1977
1393
  ? util.relative(sourceRoot, source)
1978
- : source;
1394
+ : source
1979
1395
  });
1980
1396
 
1981
1397
  // Pass `true` below to allow duplicate names and sources. While source maps
@@ -1985,8 +1401,8 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
1985
1401
  that._names = ArraySet.fromArray(names.map(String), true);
1986
1402
  that._sources = ArraySet.fromArray(sources, true);
1987
1403
 
1988
- that._absoluteSources = that._sources.toArray().map(function(s) {
1989
- return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
1404
+ that._absoluteSources = that._sources.toArray().map(function (s) {
1405
+ return util.computeSourceURL(sourceRoot, s, aSourceMapURL)
1990
1406
  });
1991
1407
 
1992
1408
  that.sourceRoot = sourceRoot;
@@ -1999,11 +1415,11 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
1999
1415
  that._mappingsPtr = 0;
2000
1416
  that._wasm = null;
2001
1417
 
2002
- return wasm().then(w => {
1418
+ return wasm().then((w) => {
2003
1419
  that._wasm = w;
2004
- return that;
2005
- });
2006
- });
1420
+ return that
1421
+ })
1422
+ })
2007
1423
  }
2008
1424
 
2009
1425
  /**
@@ -2017,18 +1433,18 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2017
1433
  }
2018
1434
 
2019
1435
  if (this._sources.has(relativeSource)) {
2020
- return this._sources.indexOf(relativeSource);
1436
+ return this._sources.indexOf(relativeSource)
2021
1437
  }
2022
1438
 
2023
1439
  // Maybe aSource is an absolute URL as returned by |sources|. In
2024
1440
  // this case we can't simply undo the transform.
2025
1441
  for (let i = 0; i < this._absoluteSources.length; ++i) {
2026
1442
  if (this._absoluteSources[i] == aSource) {
2027
- return i;
1443
+ return i
2028
1444
  }
2029
1445
  }
2030
1446
 
2031
- return -1;
1447
+ return -1
2032
1448
  }
2033
1449
 
2034
1450
  /**
@@ -2041,11 +1457,11 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2041
1457
  * @returns BasicSourceMapConsumer
2042
1458
  */
2043
1459
  static fromSourceMap(aSourceMap, aSourceMapURL) {
2044
- return new BasicSourceMapConsumer(aSourceMap.toString());
1460
+ return new BasicSourceMapConsumer(aSourceMap.toString())
2045
1461
  }
2046
1462
 
2047
1463
  get sources() {
2048
- return this._absoluteSources.slice();
1464
+ return this._absoluteSources.slice()
2049
1465
  }
2050
1466
 
2051
1467
  _getMappingsPtr() {
@@ -2053,7 +1469,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2053
1469
  this._parseMappings(this._mappings, this.sourceRoot);
2054
1470
  }
2055
1471
 
2056
- return this._mappingsPtr;
1472
+ return this._mappingsPtr
2057
1473
  }
2058
1474
 
2059
1475
  /**
@@ -2065,7 +1481,11 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2065
1481
  const size = aStr.length;
2066
1482
 
2067
1483
  const mappingsBufPtr = this._wasm.exports.allocate_mappings(size);
2068
- const mappingsBuf = new Uint8Array(this._wasm.exports.memory.buffer, mappingsBufPtr, size);
1484
+ const mappingsBuf = new Uint8Array(
1485
+ this._wasm.exports.memory.buffer,
1486
+ mappingsBufPtr,
1487
+ size
1488
+ );
2069
1489
  for (let i = 0; i < size; i++) {
2070
1490
  mappingsBuf[i] = aStr.charCodeAt(i);
2071
1491
  }
@@ -2079,23 +1499,24 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2079
1499
  // XXX: keep these error codes in sync with `fitzgen/source-map-mappings`.
2080
1500
  switch (error) {
2081
1501
  case 1:
2082
- msg += "the mappings contained a negative line, column, source index, or name index";
2083
- break;
1502
+ msg +=
1503
+ 'the mappings contained a negative line, column, source index, or name index';
1504
+ break
2084
1505
  case 2:
2085
- msg += "the mappings contained a number larger than 2**32";
2086
- break;
1506
+ msg += 'the mappings contained a number larger than 2**32';
1507
+ break
2087
1508
  case 3:
2088
- msg += "reached EOF while in the middle of parsing a VLQ";
2089
- break;
1509
+ msg += 'reached EOF while in the middle of parsing a VLQ';
1510
+ break
2090
1511
  case 4:
2091
- msg += "invalid base 64 character while parsing a VLQ";
2092
- break;
1512
+ msg += 'invalid base 64 character while parsing a VLQ';
1513
+ break
2093
1514
  default:
2094
- msg += "unknown error code";
2095
- break;
1515
+ msg += 'unknown error code';
1516
+ break
2096
1517
  }
2097
1518
 
2098
- throw new Error(msg);
1519
+ throw new Error(msg)
2099
1520
  }
2100
1521
 
2101
1522
  this._mappingsPtr = mappingsPtr;
@@ -2107,10 +1528,14 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2107
1528
  const sourceRoot = this.sourceRoot;
2108
1529
 
2109
1530
  this._wasm.withMappingCallback(
2110
- mapping => {
1531
+ (mapping) => {
2111
1532
  if (mapping.source !== null) {
2112
1533
  mapping.source = this._sources.at(mapping.source);
2113
- mapping.source = util.computeSourceURL(sourceRoot, mapping.source, this._sourceMapURL);
1534
+ mapping.source = util.computeSourceURL(
1535
+ sourceRoot,
1536
+ mapping.source,
1537
+ this._sourceMapURL
1538
+ );
2114
1539
 
2115
1540
  if (mapping.name !== null) {
2116
1541
  mapping.name = this._names.at(mapping.name);
@@ -2121,41 +1546,41 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2121
1546
  },
2122
1547
  () => {
2123
1548
  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.");
1549
+ case SourceMapConsumer$1.GENERATED_ORDER:
1550
+ this._wasm.exports.by_generated_location(this._getMappingsPtr());
1551
+ break
1552
+ case SourceMapConsumer$1.ORIGINAL_ORDER:
1553
+ this._wasm.exports.by_original_location(this._getMappingsPtr());
1554
+ break
1555
+ default:
1556
+ throw new Error('Unknown order of iteration.')
2132
1557
  }
2133
1558
  }
2134
1559
  );
2135
1560
  }
2136
1561
 
2137
1562
  allGeneratedPositionsFor(aArgs) {
2138
- let source = util.getArg(aArgs, "source");
2139
- const originalLine = util.getArg(aArgs, "line");
1563
+ let source = util.getArg(aArgs, 'source');
1564
+ const originalLine = util.getArg(aArgs, 'line');
2140
1565
  const originalColumn = aArgs.column || 0;
2141
1566
 
2142
1567
  source = this._findSourceIndex(source);
2143
1568
  if (source < 0) {
2144
- return [];
1569
+ return []
2145
1570
  }
2146
1571
 
2147
1572
  if (originalLine < 1) {
2148
- throw new Error("Line numbers must be >= 1");
1573
+ throw new Error('Line numbers must be >= 1')
2149
1574
  }
2150
1575
 
2151
1576
  if (originalColumn < 0) {
2152
- throw new Error("Column numbers must be >= 0");
1577
+ throw new Error('Column numbers must be >= 0')
2153
1578
  }
2154
1579
 
2155
1580
  const mappings = [];
2156
1581
 
2157
1582
  this._wasm.withMappingCallback(
2158
- m => {
1583
+ (m) => {
2159
1584
  let lastColumn = m.lastGeneratedColumn;
2160
1585
  if (this._computedColumnSpans && lastColumn === null) {
2161
1586
  lastColumn = Infinity;
@@ -2165,18 +1590,19 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2165
1590
  column: m.generatedColumn,
2166
1591
  lastColumn,
2167
1592
  });
2168
- }, () => {
1593
+ },
1594
+ () => {
2169
1595
  this._wasm.exports.all_generated_locations_for(
2170
1596
  this._getMappingsPtr(),
2171
1597
  source,
2172
1598
  originalLine - 1,
2173
- "column" in aArgs,
1599
+ 'column' in aArgs,
2174
1600
  originalColumn
2175
1601
  );
2176
1602
  }
2177
1603
  );
2178
1604
 
2179
- return mappings;
1605
+ return mappings
2180
1606
  }
2181
1607
 
2182
1608
  destroy() {
@@ -2192,7 +1618,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2192
1618
  */
2193
1619
  computeColumnSpans() {
2194
1620
  if (this._computedColumnSpans) {
2195
- return;
1621
+ return
2196
1622
  }
2197
1623
 
2198
1624
  this._wasm.exports.compute_column_spans(this._getMappingsPtr());
@@ -2225,52 +1651,63 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2225
1651
  */
2226
1652
  originalPositionFor(aArgs) {
2227
1653
  const needle = {
2228
- generatedLine: util.getArg(aArgs, "line"),
2229
- generatedColumn: util.getArg(aArgs, "column")
1654
+ generatedLine: util.getArg(aArgs, 'line'),
1655
+ generatedColumn: util.getArg(aArgs, 'column'),
2230
1656
  };
2231
1657
 
2232
1658
  if (needle.generatedLine < 1) {
2233
- throw new Error("Line numbers must be >= 1");
1659
+ throw new Error('Line numbers must be >= 1')
2234
1660
  }
2235
1661
 
2236
1662
  if (needle.generatedColumn < 0) {
2237
- throw new Error("Column numbers must be >= 0");
1663
+ throw new Error('Column numbers must be >= 0')
2238
1664
  }
2239
1665
 
2240
- let bias = util.getArg(aArgs, "bias", SourceMapConsumer$1.GREATEST_LOWER_BOUND);
1666
+ let bias = util.getArg(
1667
+ aArgs,
1668
+ 'bias',
1669
+ SourceMapConsumer$1.GREATEST_LOWER_BOUND
1670
+ );
2241
1671
  if (bias == null) {
2242
1672
  bias = SourceMapConsumer$1.GREATEST_LOWER_BOUND;
2243
1673
  }
2244
1674
 
2245
1675
  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
- });
1676
+ this._wasm.withMappingCallback(
1677
+ (m) => (mapping = m),
1678
+ () => {
1679
+ this._wasm.exports.original_location_for(
1680
+ this._getMappingsPtr(),
1681
+ needle.generatedLine - 1,
1682
+ needle.generatedColumn,
1683
+ bias
1684
+ );
1685
+ }
1686
+ );
2254
1687
 
2255
1688
  if (mapping) {
2256
1689
  if (mapping.generatedLine === needle.generatedLine) {
2257
- let source = util.getArg(mapping, "source", null);
1690
+ let source = util.getArg(mapping, 'source', null);
2258
1691
  if (source !== null) {
2259
1692
  source = this._sources.at(source);
2260
- source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
1693
+ source = util.computeSourceURL(
1694
+ this.sourceRoot,
1695
+ source,
1696
+ this._sourceMapURL
1697
+ );
2261
1698
  }
2262
1699
 
2263
- let name = util.getArg(mapping, "name", null);
1700
+ let name = util.getArg(mapping, 'name', null);
2264
1701
  if (name !== null) {
2265
1702
  name = this._names.at(name);
2266
1703
  }
2267
1704
 
2268
1705
  return {
2269
1706
  source,
2270
- line: util.getArg(mapping, "originalLine", null),
2271
- column: util.getArg(mapping, "originalColumn", null),
2272
- name
2273
- };
1707
+ line: util.getArg(mapping, 'originalLine', null),
1708
+ column: util.getArg(mapping, 'originalColumn', null),
1709
+ name,
1710
+ }
2274
1711
  }
2275
1712
  }
2276
1713
 
@@ -2278,8 +1715,8 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2278
1715
  source: null,
2279
1716
  line: null,
2280
1717
  column: null,
2281
- name: null
2282
- };
1718
+ name: null,
1719
+ }
2283
1720
  }
2284
1721
 
2285
1722
  /**
@@ -2288,10 +1725,14 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2288
1725
  */
2289
1726
  hasContentsOfAllSources() {
2290
1727
  if (!this.sourcesContent) {
2291
- return false;
1728
+ return false
2292
1729
  }
2293
- return this.sourcesContent.length >= this._sources.size() &&
2294
- !this.sourcesContent.some(function(sc) { return sc == null; });
1730
+ return (
1731
+ this.sourcesContent.length >= this._sources.size() &&
1732
+ !this.sourcesContent.some(function (sc) {
1733
+ return sc == null
1734
+ })
1735
+ )
2295
1736
  }
2296
1737
 
2297
1738
  /**
@@ -2301,12 +1742,12 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2301
1742
  */
2302
1743
  sourceContentFor(aSource, nullOnMissing) {
2303
1744
  if (!this.sourcesContent) {
2304
- return null;
1745
+ return null
2305
1746
  }
2306
1747
 
2307
1748
  const index = this._findSourceIndex(aSource);
2308
1749
  if (index >= 0) {
2309
- return this.sourcesContent[index];
1750
+ return this.sourcesContent[index]
2310
1751
  }
2311
1752
 
2312
1753
  let relativeSource = aSource;
@@ -2315,21 +1756,21 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2315
1756
  }
2316
1757
 
2317
1758
  let url;
2318
- if (this.sourceRoot != null
2319
- && (url = util.urlParse(this.sourceRoot))) {
1759
+ if (this.sourceRoot != null && (url = util.urlParse(this.sourceRoot))) {
2320
1760
  // XXX: file:// URIs and absolute paths lead to unexpected behavior for
2321
1761
  // many users. We can help them out when they expect file:// URIs to
2322
1762
  // behave like it would if they were running a local HTTP server. See
2323
1763
  // 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)];
1764
+ const fileUriAbsPath = relativeSource.replace(/^file:\/\//, '');
1765
+ if (url.scheme == 'file' && this._sources.has(fileUriAbsPath)) {
1766
+ return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
2328
1767
  }
2329
1768
 
2330
- if ((!url.path || url.path == "/")
2331
- && this._sources.has("/" + relativeSource)) {
2332
- return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
1769
+ if (
1770
+ (!url.path || url.path == '/') &&
1771
+ this._sources.has('/' + relativeSource)
1772
+ ) {
1773
+ return this.sourcesContent[this._sources.indexOf('/' + relativeSource)]
2333
1774
  }
2334
1775
  }
2335
1776
 
@@ -2338,10 +1779,10 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2338
1779
  // don't want to throw if we can't find the source - we just want to
2339
1780
  // return null, so we provide a flag to exit gracefully.
2340
1781
  if (nullOnMissing) {
2341
- return null;
1782
+ return null
2342
1783
  }
2343
1784
 
2344
- throw new Error('"' + relativeSource + '" is not in the SourceMap.');
1785
+ throw new Error('"' + relativeSource + '" is not in the SourceMap.')
2345
1786
  }
2346
1787
 
2347
1788
  /**
@@ -2368,45 +1809,52 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2368
1809
  * The column number is 0-based.
2369
1810
  */
2370
1811
  generatedPositionFor(aArgs) {
2371
- let source = util.getArg(aArgs, "source");
1812
+ let source = util.getArg(aArgs, 'source');
2372
1813
  source = this._findSourceIndex(source);
2373
1814
  if (source < 0) {
2374
1815
  return {
2375
1816
  line: null,
2376
1817
  column: null,
2377
- lastColumn: null
2378
- };
1818
+ lastColumn: null,
1819
+ }
2379
1820
  }
2380
1821
 
2381
1822
  const needle = {
2382
1823
  source,
2383
- originalLine: util.getArg(aArgs, "line"),
2384
- originalColumn: util.getArg(aArgs, "column")
1824
+ originalLine: util.getArg(aArgs, 'line'),
1825
+ originalColumn: util.getArg(aArgs, 'column'),
2385
1826
  };
2386
1827
 
2387
1828
  if (needle.originalLine < 1) {
2388
- throw new Error("Line numbers must be >= 1");
1829
+ throw new Error('Line numbers must be >= 1')
2389
1830
  }
2390
1831
 
2391
1832
  if (needle.originalColumn < 0) {
2392
- throw new Error("Column numbers must be >= 0");
1833
+ throw new Error('Column numbers must be >= 0')
2393
1834
  }
2394
1835
 
2395
- let bias = util.getArg(aArgs, "bias", SourceMapConsumer$1.GREATEST_LOWER_BOUND);
1836
+ let bias = util.getArg(
1837
+ aArgs,
1838
+ 'bias',
1839
+ SourceMapConsumer$1.GREATEST_LOWER_BOUND
1840
+ );
2396
1841
  if (bias == null) {
2397
1842
  bias = SourceMapConsumer$1.GREATEST_LOWER_BOUND;
2398
1843
  }
2399
1844
 
2400
1845
  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
- });
1846
+ this._wasm.withMappingCallback(
1847
+ (m) => (mapping = m),
1848
+ () => {
1849
+ this._wasm.exports.generated_location_for(
1850
+ this._getMappingsPtr(),
1851
+ needle.source,
1852
+ needle.originalLine - 1,
1853
+ needle.originalColumn,
1854
+ bias
1855
+ );
1856
+ }
1857
+ );
2410
1858
 
2411
1859
  if (mapping) {
2412
1860
  if (mapping.source === needle.source) {
@@ -2415,23 +1863,23 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2415
1863
  lastColumn = Infinity;
2416
1864
  }
2417
1865
  return {
2418
- line: util.getArg(mapping, "generatedLine", null),
2419
- column: util.getArg(mapping, "generatedColumn", null),
1866
+ line: util.getArg(mapping, 'generatedLine', null),
1867
+ column: util.getArg(mapping, 'generatedColumn', null),
2420
1868
  lastColumn,
2421
- };
1869
+ }
2422
1870
  }
2423
1871
  }
2424
1872
 
2425
1873
  return {
2426
1874
  line: null,
2427
1875
  column: null,
2428
- lastColumn: null
2429
- };
1876
+ lastColumn: null,
1877
+ }
2430
1878
  }
2431
1879
  }
2432
1880
 
2433
1881
  BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer$1;
2434
- var BasicSourceMapConsumer_1 = BasicSourceMapConsumer;
1882
+ sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
2435
1883
 
2436
1884
  /**
2437
1885
  * An IndexedSourceMapConsumer instance represents a parsed source map which
@@ -2484,17 +1932,17 @@ var BasicSourceMapConsumer_1 = BasicSourceMapConsumer;
2484
1932
  */
2485
1933
  class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2486
1934
  constructor(aSourceMap, aSourceMapURL) {
2487
- return super(INTERNAL).then(that => {
1935
+ return super(INTERNAL).then((that) => {
2488
1936
  let sourceMap = aSourceMap;
2489
- if (typeof aSourceMap === "string") {
1937
+ if (typeof aSourceMap === 'string') {
2490
1938
  sourceMap = util.parseSourceMapInput(aSourceMap);
2491
1939
  }
2492
1940
 
2493
- const version = util.getArg(sourceMap, "version");
2494
- const sections = util.getArg(sourceMap, "sections");
1941
+ const version = util.getArg(sourceMap, 'version');
1942
+ const sections = util.getArg(sourceMap, 'sections');
2495
1943
 
2496
1944
  if (version != that._version) {
2497
- throw new Error("Unsupported version: " + version);
1945
+ throw new Error('Unsupported version: ' + version)
2498
1946
  }
2499
1947
 
2500
1948
  that._sources = new ArraySet();
@@ -2506,41 +1954,52 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2506
1954
 
2507
1955
  let lastOffset = {
2508
1956
  line: -1,
2509
- column: 0
1957
+ column: 0,
2510
1958
  };
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");
1959
+ return Promise.all(
1960
+ sections.map((s) => {
1961
+ if (s.url) {
1962
+ // The url field will require support for asynchronicity.
1963
+ // See https://github.com/mozilla/source-map/issues/16
1964
+ throw new Error(
1965
+ 'Support for url field in sections not implemented.'
1966
+ )
1967
+ }
1968
+ const offset = util.getArg(s, 'offset');
1969
+ const offsetLine = util.getArg(offset, 'line');
1970
+ const offsetColumn = util.getArg(offset, 'column');
2520
1971
 
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 => {
1972
+ if (
1973
+ offsetLine < lastOffset.line ||
1974
+ (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)
1975
+ ) {
1976
+ throw new Error(
1977
+ 'Section offsets must be ordered and non-overlapping.'
1978
+ )
1979
+ }
1980
+ lastOffset = offset;
1981
+
1982
+ const cons = new SourceMapConsumer$1(
1983
+ util.getArg(s, 'map'),
1984
+ aSourceMapURL
1985
+ );
1986
+ return cons.then((consumer) => {
1987
+ return {
1988
+ generatedOffset: {
1989
+ // The offset fields are 0-based, but we use 1-based indices when
1990
+ // encoding/decoding from VLQ.
1991
+ generatedLine: offsetLine + 1,
1992
+ generatedColumn: offsetColumn + 1,
1993
+ },
1994
+ consumer,
1995
+ }
1996
+ })
1997
+ })
1998
+ ).then((s) => {
2540
1999
  that._sections = s;
2541
- return that;
2542
- });
2543
- });
2000
+ return that
2001
+ })
2002
+ })
2544
2003
  }
2545
2004
 
2546
2005
  // `__generatedMappings` and `__originalMappings` are arrays that hold the
@@ -2577,7 +2036,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2577
2036
  this._sortGeneratedMappings();
2578
2037
  }
2579
2038
 
2580
- return this.__generatedMappings;
2039
+ return this.__generatedMappings
2581
2040
  }
2582
2041
 
2583
2042
  get _originalMappings() {
@@ -2585,7 +2044,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2585
2044
  this._sortOriginalMappings();
2586
2045
  }
2587
2046
 
2588
- return this.__originalMappings;
2047
+ return this.__originalMappings
2589
2048
  }
2590
2049
 
2591
2050
  get _generatedMappingsUnsorted() {
@@ -2593,7 +2052,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2593
2052
  this._parseMappings(this._mappings, this.sourceRoot);
2594
2053
  }
2595
2054
 
2596
- return this.__generatedMappingsUnsorted;
2055
+ return this.__generatedMappingsUnsorted
2597
2056
  }
2598
2057
 
2599
2058
  get _originalMappingsUnsorted() {
@@ -2601,7 +2060,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2601
2060
  this._parseMappings(this._mappings, this.sourceRoot);
2602
2061
  }
2603
2062
 
2604
- return this.__originalMappingsUnsorted;
2063
+ return this.__originalMappingsUnsorted
2605
2064
  }
2606
2065
 
2607
2066
  _sortGeneratedMappings() {
@@ -2626,7 +2085,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2626
2085
  sources.push(this._sections[i].consumer.sources[j]);
2627
2086
  }
2628
2087
  }
2629
- return sources;
2088
+ return sources
2630
2089
  }
2631
2090
 
2632
2091
  /**
@@ -2650,22 +2109,25 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2650
2109
  */
2651
2110
  originalPositionFor(aArgs) {
2652
2111
  const needle = {
2653
- generatedLine: util.getArg(aArgs, "line"),
2654
- generatedColumn: util.getArg(aArgs, "column")
2112
+ generatedLine: util.getArg(aArgs, 'line'),
2113
+ generatedColumn: util.getArg(aArgs, 'column'),
2655
2114
  };
2656
2115
 
2657
2116
  // Find the section containing the generated position we're trying to map
2658
2117
  // to an original position.
2659
- const sectionIndex = binarySearch.search(needle, this._sections,
2660
- function(aNeedle, section) {
2661
- const cmp = aNeedle.generatedLine - section.generatedOffset.generatedLine;
2118
+ const sectionIndex = binarySearch.search(
2119
+ needle,
2120
+ this._sections,
2121
+ function (aNeedle, section) {
2122
+ const cmp =
2123
+ aNeedle.generatedLine - section.generatedOffset.generatedLine;
2662
2124
  if (cmp) {
2663
- return cmp;
2125
+ return cmp
2664
2126
  }
2665
2127
 
2666
- return (aNeedle.generatedColumn -
2667
- section.generatedOffset.generatedColumn);
2668
- });
2128
+ return aNeedle.generatedColumn - section.generatedOffset.generatedColumn
2129
+ }
2130
+ );
2669
2131
  const section = this._sections[sectionIndex];
2670
2132
 
2671
2133
  if (!section) {
@@ -2673,19 +2135,19 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2673
2135
  source: null,
2674
2136
  line: null,
2675
2137
  column: null,
2676
- name: null
2677
- };
2138
+ name: null,
2139
+ }
2678
2140
  }
2679
2141
 
2680
2142
  return section.consumer.originalPositionFor({
2681
- line: needle.generatedLine -
2682
- (section.generatedOffset.generatedLine - 1),
2683
- column: needle.generatedColumn -
2143
+ line: needle.generatedLine - (section.generatedOffset.generatedLine - 1),
2144
+ column:
2145
+ needle.generatedColumn -
2684
2146
  (section.generatedOffset.generatedLine === needle.generatedLine
2685
- ? section.generatedOffset.generatedColumn - 1
2686
- : 0),
2687
- bias: aArgs.bias
2688
- });
2147
+ ? section.generatedOffset.generatedColumn - 1
2148
+ : 0),
2149
+ bias: aArgs.bias,
2150
+ })
2689
2151
  }
2690
2152
 
2691
2153
  /**
@@ -2693,9 +2155,9 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2693
2155
  * map, false otherwise.
2694
2156
  */
2695
2157
  hasContentsOfAllSources() {
2696
- return this._sections.every(function(s) {
2697
- return s.consumer.hasContentsOfAllSources();
2698
- });
2158
+ return this._sections.every(function (s) {
2159
+ return s.consumer.hasContentsOfAllSources()
2160
+ })
2699
2161
  }
2700
2162
 
2701
2163
  /**
@@ -2709,13 +2171,13 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2709
2171
 
2710
2172
  const content = section.consumer.sourceContentFor(aSource, true);
2711
2173
  if (content) {
2712
- return content;
2174
+ return content
2713
2175
  }
2714
2176
  }
2715
2177
  if (nullOnMissing) {
2716
- return null;
2178
+ return null
2717
2179
  }
2718
- throw new Error('"' + aSource + '" is not in the SourceMap.');
2180
+ throw new Error('"' + aSource + '" is not in the SourceMap.')
2719
2181
  }
2720
2182
 
2721
2183
  /**
@@ -2742,27 +2204,31 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2742
2204
 
2743
2205
  // Only consider this section if the requested source is in the list of
2744
2206
  // sources of the consumer.
2745
- if (section.consumer._findSourceIndex(util.getArg(aArgs, "source")) === -1) {
2746
- continue;
2207
+ if (
2208
+ section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1
2209
+ ) {
2210
+ continue
2747
2211
  }
2748
2212
  const generatedPosition = section.consumer.generatedPositionFor(aArgs);
2749
2213
  if (generatedPosition) {
2750
2214
  const ret = {
2751
- line: generatedPosition.line +
2215
+ line:
2216
+ generatedPosition.line +
2752
2217
  (section.generatedOffset.generatedLine - 1),
2753
- column: generatedPosition.column +
2218
+ column:
2219
+ generatedPosition.column +
2754
2220
  (section.generatedOffset.generatedLine === generatedPosition.line
2755
- ? section.generatedOffset.generatedColumn - 1
2756
- : 0)
2221
+ ? section.generatedOffset.generatedColumn - 1
2222
+ : 0),
2757
2223
  };
2758
- return ret;
2224
+ return ret
2759
2225
  }
2760
2226
  }
2761
2227
 
2762
2228
  return {
2763
2229
  line: null,
2764
- column: null
2765
- };
2230
+ column: null,
2231
+ }
2766
2232
  }
2767
2233
 
2768
2234
  /**
@@ -2771,13 +2237,13 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2771
2237
  * `this.__originalMappings` properties).
2772
2238
  */
2773
2239
  _parseMappings(aStr, aSourceRoot) {
2774
- const generatedMappings = this.__generatedMappingsUnsorted = [];
2775
- const originalMappings = this.__originalMappingsUnsorted = [];
2240
+ const generatedMappings = (this.__generatedMappingsUnsorted = []);
2241
+ const originalMappings = (this.__originalMappingsUnsorted = []);
2776
2242
  for (let i = 0; i < this._sections.length; i++) {
2777
2243
  const section = this._sections[i];
2778
2244
 
2779
2245
  const sectionMappings = [];
2780
- section.consumer.eachMapping(m => sectionMappings.push(m));
2246
+ section.consumer.eachMapping((m) => sectionMappings.push(m));
2781
2247
 
2782
2248
  for (let j = 0; j < sectionMappings.length; j++) {
2783
2249
  const mapping = sectionMappings[j];
@@ -2786,7 +2252,11 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2786
2252
  // `source`, which would actually have gotten used as null because
2787
2253
  // var's get hoisted.
2788
2254
  // See: https://github.com/mozilla/source-map/issues/333
2789
- let source = util.computeSourceURL(section.consumer.sourceRoot, null, this._sourceMapURL);
2255
+ let source = util.computeSourceURL(
2256
+ section.consumer.sourceRoot,
2257
+ null,
2258
+ this._sourceMapURL
2259
+ );
2790
2260
  this._sources.add(source);
2791
2261
  source = this._sources.indexOf(source);
2792
2262
 
@@ -2802,19 +2272,20 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2802
2272
  // generated file.
2803
2273
  const adjustedMapping = {
2804
2274
  source,
2805
- generatedLine: mapping.generatedLine +
2806
- (section.generatedOffset.generatedLine - 1),
2807
- generatedColumn: mapping.generatedColumn +
2275
+ generatedLine:
2276
+ mapping.generatedLine + (section.generatedOffset.generatedLine - 1),
2277
+ generatedColumn:
2278
+ mapping.generatedColumn +
2808
2279
  (section.generatedOffset.generatedLine === mapping.generatedLine
2809
- ? section.generatedOffset.generatedColumn - 1
2810
- : 0),
2280
+ ? section.generatedOffset.generatedColumn - 1
2281
+ : 0),
2811
2282
  originalLine: mapping.originalLine,
2812
2283
  originalColumn: mapping.originalColumn,
2813
- name
2284
+ name,
2814
2285
  };
2815
2286
 
2816
2287
  generatedMappings.push(adjustedMapping);
2817
- if (typeof adjustedMapping.originalLine === "number") {
2288
+ if (typeof adjustedMapping.originalLine === 'number') {
2818
2289
  originalMappings.push(adjustedMapping);
2819
2290
  }
2820
2291
  }
@@ -2827,91 +2298,96 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2827
2298
 
2828
2299
  let mappings;
2829
2300
  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.");
2301
+ case SourceMapConsumer$1.GENERATED_ORDER:
2302
+ mappings = this._generatedMappings;
2303
+ break
2304
+ case SourceMapConsumer$1.ORIGINAL_ORDER:
2305
+ mappings = this._originalMappings;
2306
+ break
2307
+ default:
2308
+ throw new Error('Unknown order of iteration.')
2838
2309
  }
2839
2310
 
2840
2311
  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);
2312
+ mappings
2313
+ .map(function (mapping) {
2314
+ let source = null;
2315
+ if (mapping.source !== null) {
2316
+ source = this._sources.at(mapping.source);
2317
+ source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
2318
+ }
2319
+ return {
2320
+ source,
2321
+ generatedLine: mapping.generatedLine,
2322
+ generatedColumn: mapping.generatedColumn,
2323
+ originalLine: mapping.originalLine,
2324
+ originalColumn: mapping.originalColumn,
2325
+ name: mapping.name === null ? null : this._names.at(mapping.name),
2326
+ }
2327
+ }, this)
2328
+ .forEach(aCallback, context);
2856
2329
  }
2857
2330
 
2858
2331
  /**
2859
2332
  * Find the mapping that best matches the hypothetical "needle" mapping that
2860
2333
  * we are searching for in the given "haystack" of mappings.
2861
2334
  */
2862
- _findMapping(aNeedle, aMappings, aLineName,
2863
- aColumnName, aComparator, aBias) {
2335
+ _findMapping(aNeedle, aMappings, aLineName, aColumnName, aComparator, aBias) {
2864
2336
  // To return the position we are searching for, we must first find the
2865
2337
  // mapping for the given position and then return the opposite position it
2866
2338
  // points to. Because the mappings are sorted, we can use binary search to
2867
2339
  // find the best mapping.
2868
2340
 
2869
2341
  if (aNeedle[aLineName] <= 0) {
2870
- throw new TypeError("Line must be greater than or equal to 1, got "
2871
- + aNeedle[aLineName]);
2342
+ throw new TypeError(
2343
+ 'Line must be greater than or equal to 1, got ' + aNeedle[aLineName]
2344
+ )
2872
2345
  }
2873
2346
  if (aNeedle[aColumnName] < 0) {
2874
- throw new TypeError("Column must be greater than or equal to 0, got "
2875
- + aNeedle[aColumnName]);
2347
+ throw new TypeError(
2348
+ 'Column must be greater than or equal to 0, got ' + aNeedle[aColumnName]
2349
+ )
2876
2350
  }
2877
2351
 
2878
- return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
2352
+ return binarySearch.search(aNeedle, aMappings, aComparator, aBias)
2879
2353
  }
2880
2354
 
2881
2355
  allGeneratedPositionsFor(aArgs) {
2882
- const line = util.getArg(aArgs, "line");
2356
+ const line = util.getArg(aArgs, 'line');
2883
2357
 
2884
2358
  // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
2885
2359
  // returns the index of the closest mapping less than the needle. By
2886
2360
  // setting needle.originalColumn to 0, we thus find the last mapping for
2887
2361
  // the given line, provided such a mapping exists.
2888
2362
  const needle = {
2889
- source: util.getArg(aArgs, "source"),
2363
+ source: util.getArg(aArgs, 'source'),
2890
2364
  originalLine: line,
2891
- originalColumn: util.getArg(aArgs, "column", 0)
2365
+ originalColumn: util.getArg(aArgs, 'column', 0),
2892
2366
  };
2893
2367
 
2894
2368
  needle.source = this._findSourceIndex(needle.source);
2895
2369
  if (needle.source < 0) {
2896
- return [];
2370
+ return []
2897
2371
  }
2898
2372
 
2899
2373
  if (needle.originalLine < 1) {
2900
- throw new Error("Line numbers must be >= 1");
2374
+ throw new Error('Line numbers must be >= 1')
2901
2375
  }
2902
2376
 
2903
2377
  if (needle.originalColumn < 0) {
2904
- throw new Error("Column numbers must be >= 0");
2378
+ throw new Error('Column numbers must be >= 0')
2905
2379
  }
2906
2380
 
2907
2381
  const mappings = [];
2908
2382
 
2909
- let index = this._findMapping(needle,
2910
- this._originalMappings,
2911
- "originalLine",
2912
- "originalColumn",
2913
- util.compareByOriginalPositions,
2914
- binarySearch.LEAST_UPPER_BOUND);
2383
+ let index = this._findMapping(
2384
+ needle,
2385
+ this._originalMappings,
2386
+ 'originalLine',
2387
+ 'originalColumn',
2388
+ util.compareByOriginalPositions,
2389
+ binarySearch.LEAST_UPPER_BOUND
2390
+ );
2915
2391
  if (index >= 0) {
2916
2392
  let mapping = this._originalMappings[index];
2917
2393
 
@@ -2928,8 +2404,8 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2928
2404
  lastColumn = Infinity;
2929
2405
  }
2930
2406
  mappings.push({
2931
- line: util.getArg(mapping, "generatedLine", null),
2932
- column: util.getArg(mapping, "generatedColumn", null),
2407
+ line: util.getArg(mapping, 'generatedLine', null),
2408
+ column: util.getArg(mapping, 'generatedColumn', null),
2933
2409
  lastColumn,
2934
2410
  });
2935
2411
 
@@ -2942,16 +2418,18 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2942
2418
  // a mapping for a different line than the one we were searching for.
2943
2419
  // Since mappings are sorted, this is guaranteed to find all mappings for
2944
2420
  // the line we are searching for.
2945
- while (mapping &&
2946
- mapping.originalLine === line &&
2947
- mapping.originalColumn == originalColumn) {
2421
+ while (
2422
+ mapping &&
2423
+ mapping.originalLine === line &&
2424
+ mapping.originalColumn == originalColumn
2425
+ ) {
2948
2426
  let lastColumn = mapping.lastGeneratedColumn;
2949
2427
  if (this._computedColumnSpans && lastColumn === null) {
2950
2428
  lastColumn = Infinity;
2951
2429
  }
2952
2430
  mappings.push({
2953
- line: util.getArg(mapping, "generatedLine", null),
2954
- column: util.getArg(mapping, "generatedColumn", null),
2431
+ line: util.getArg(mapping, 'generatedLine', null),
2432
+ column: util.getArg(mapping, 'generatedColumn', null),
2955
2433
  lastColumn,
2956
2434
  });
2957
2435
 
@@ -2960,7 +2438,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2960
2438
  }
2961
2439
  }
2962
2440
 
2963
- return mappings;
2441
+ return mappings
2964
2442
  }
2965
2443
 
2966
2444
  destroy() {
@@ -2969,7 +2447,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2969
2447
  }
2970
2448
  }
2971
2449
  }
2972
- var IndexedSourceMapConsumer_1 = IndexedSourceMapConsumer;
2450
+ sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
2973
2451
 
2974
2452
  /*
2975
2453
  * Cheat to get around inter-twingled classes. `factory()` can be at the end
@@ -2977,451 +2455,188 @@ var IndexedSourceMapConsumer_1 = IndexedSourceMapConsumer;
2977
2455
  */
2978
2456
  function _factory(aSourceMap, aSourceMapURL) {
2979
2457
  let sourceMap = aSourceMap;
2980
- if (typeof aSourceMap === "string") {
2458
+ if (typeof aSourceMap === 'string') {
2981
2459
  sourceMap = util.parseSourceMapInput(aSourceMap);
2982
2460
  }
2983
2461
 
2984
- const consumer = sourceMap.sections != null
2462
+ const consumer =
2463
+ sourceMap.sections != null
2985
2464
  ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
2986
2465
  : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
2987
- return Promise.resolve(consumer);
2466
+ return Promise.resolve(consumer)
2988
2467
  }
2989
2468
 
2990
2469
  function _factoryBSM(aSourceMap, aSourceMapURL) {
2991
- return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
2470
+ return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL)
2992
2471
  }
2993
2472
 
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
2473
  /*
3005
- * Copyright 2011 Mozilla Foundation and contributors
3006
- * Licensed under the New BSD license. See LICENSE or:
2474
+ * Copyright 2009-2011 Mozilla Foundation and contributors
2475
+ * Licensed under the New BSD license. See LICENSE.txt or:
3007
2476
  * http://opensource.org/licenses/BSD-3-Clause
3008
2477
  */
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;
2478
+ var SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
2479
+
2480
+ const splitRE = /\r?\n/;
2481
+ const range = 2;
2482
+ function posToNumber(source, pos) {
2483
+ if (typeof pos === 'number')
2484
+ return pos;
2485
+ const lines = source.split(splitRE);
2486
+ const { line, column } = pos;
2487
+ let start = 0;
2488
+ for (let i = 0; i < line - 1; i++) {
2489
+ start += lines[i].length + 1;
2490
+ }
2491
+ return start + column;
2492
+ }
2493
+ function generateCodeFrame(source, start = 0, end) {
2494
+ start = posToNumber(source, start);
2495
+ end = end || start;
2496
+ const lines = source.split(splitRE);
2497
+ let count = 0;
2498
+ const res = [];
2499
+ for (let i = 0; i < lines.length; i++) {
2500
+ count += lines[i].length + 1;
2501
+ if (count >= start) {
2502
+ for (let j = i - range; j <= i + range || end > count; j++) {
2503
+ if (j < 0 || j >= lines.length)
2504
+ continue;
2505
+ const line = j + 1;
2506
+ res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
2507
+ const lineLength = lines[j].length;
2508
+ if (j === i) {
2509
+ // push underline
2510
+ const pad = start - (count - lineLength) + 1;
2511
+ const length = Math.max(1, end > count ? lineLength - pad : end - start);
2512
+ res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
2513
+ }
2514
+ else if (j > i) {
2515
+ if (end > count) {
2516
+ const length = Math.max(Math.min(end - count, lineLength), 1);
2517
+ res.push(` | ` + '^'.repeat(length));
2518
+ }
2519
+ count += lineLength + 1;
2520
+ }
2521
+ }
2522
+ break;
3113
2523
  }
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
2524
  }
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);
2525
+ return res.join('\n');
2526
+ }
2527
+ let isWindows = false;
2528
+ try {
2529
+ isWindows = os__default.default.platform() === 'win32';
2530
+ }
2531
+ catch (error) { }
2532
+ function normalizePath(id) {
2533
+ return isWindows ? id.replace(/\\/g, '/') : id;
2534
+ }
2535
+ function generateCodeFrameSourceMapConsumer(consumer, m, options = {}) {
2536
+ if (m.file) {
2537
+ const res = consumer.originalPositionFor({
2538
+ line: m.line,
2539
+ column: m.column,
2540
+ });
2541
+ if (res.source != null && res.line != null && res.column != null) {
2542
+ let code = consumer.sourceContentFor(res.source, true);
2543
+ if (code) {
2544
+ code = generateCodeFrame(code, { line: res.line, column: res.column });
2545
+ if (options.replaceTabsWithSpace) {
2546
+ code = code.replace(/\t/g, ' ');
2547
+ }
2548
+ return {
2549
+ type: m.type,
2550
+ file: options.sourceRoot
2551
+ ? normalizePath(path__default.default.relative(options.sourceRoot, res.source.replace('\\\\?\\', '')))
2552
+ : res.source,
2553
+ line: res.line,
2554
+ column: res.column,
2555
+ message: m.message,
2556
+ code,
2557
+ };
2558
+ }
3146
2559
  }
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
2560
  }
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]]);
2561
+ }
2562
+ function initConsumer(filename) {
2563
+ if (fs__default.default.existsSync(filename)) {
2564
+ return new SourceMapConsumer(fs__default.default.readFileSync(filename, 'utf8'));
3303
2565
  }
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
- });
2566
+ return Promise.resolve(undefined);
2567
+ }
2568
+ function generateCodeFrameWithSourceMapPath(filename, messages, options = {}) {
2569
+ if (typeof messages === 'string') {
2570
+ try {
2571
+ messages = JSON.parse(messages);
3355
2572
  }
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
2573
+ catch (e) { }
2574
+ }
2575
+ if (Array.isArray(messages) && messages.length) {
2576
+ return new Promise((resolve) => {
2577
+ initConsumer(filename).then((consumer) => {
2578
+ resolve(messages
2579
+ .map((m) => {
2580
+ if (m.file && consumer) {
2581
+ const message = generateCodeFrameSourceMapConsumer(consumer, m, options);
2582
+ if (message) {
2583
+ return message;
2584
+ }
2585
+ }
2586
+ if (!m.file) {
2587
+ m.file = '';
2588
+ }
2589
+ return m;
2590
+ })
2591
+ .filter(Boolean));
3391
2592
  });
3392
- }
3393
- } else {
3394
- generated.column++;
3395
- }
3396
- }
2593
+ });
2594
+ }
2595
+ return Promise.resolve([]);
2596
+ }
2597
+ function resolveSourceMapPath(sourceMapFilename, name, outputDir) {
2598
+ const is_uni_modules = path__default.default.basename(path__default.default.dirname(name)) === 'uni_modules';
2599
+ return path__default.default.resolve(outputDir, '../.sourcemap/app', name, is_uni_modules ? 'utssdk' : '', sourceMapFilename);
2600
+ }
2601
+ function generateCodeFrameWithKotlinStacktrace(stacktrace, { name, inputDir, outputDir }) {
2602
+ const sourceMapFilename = resolveSourceMapPath('app-android/index.kt.map', name, outputDir);
2603
+ return generateCodeFrameWithStacktrace(stacktrace, /e:\s+(.*):\s+\(([0-9]+),\s+([0-9]+)\):\s+(.*)/g, {
2604
+ sourceRoot: inputDir,
2605
+ sourceMapFilename,
3397
2606
  });
3398
- this.walkSourceContents(function(sourceFile, sourceContent) {
3399
- map.setSourceContent(sourceFile, sourceContent);
2607
+ }
2608
+ function generateCodeFrameWithSwiftStacktrace(stacktrace, { name, inputDir, outputDir }) {
2609
+ const sourceMapFilename = resolveSourceMapPath('app-ios/index.swift.map', name, outputDir);
2610
+ return generateCodeFrameWithStacktrace(stacktrace, /(.*):([0-9]+):([0-9]+):\s+error:\s+(.*)/g, {
2611
+ sourceRoot: inputDir,
2612
+ sourceMapFilename,
2613
+ });
2614
+ }
2615
+ function generateCodeFrameWithStacktrace(stacktrace, regexp, { sourceRoot, sourceMapFilename, replaceTabsWithSpace, }) {
2616
+ return new Promise((resolve) => {
2617
+ initConsumer(sourceMapFilename).then((consumer) => {
2618
+ if (!consumer) {
2619
+ return resolve(stacktrace);
2620
+ }
2621
+ resolve(stacktrace.replace(regexp, (substring, file, line, column, message) => {
2622
+ const m = generateCodeFrameSourceMapConsumer(consumer, {
2623
+ type: 'error',
2624
+ file,
2625
+ message,
2626
+ line: parseInt(line),
2627
+ column: parseInt(column),
2628
+ }, { sourceRoot, replaceTabsWithSpace });
2629
+ if (!m) {
2630
+ return substring;
2631
+ }
2632
+ return `error: ${message}
2633
+ at ${m.file}:${m.line}:${m.column}
2634
+ ${m.code}
2635
+ `;
2636
+ }));
2637
+ });
3400
2638
  });
3401
-
3402
- return { code: generated.code, map };
3403
- }
3404
2639
  }
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
2640
 
3426
2641
  const nixSlashes = (x) => x.replace(/\\/g, '/');
3427
2642
  const sourcemapCatch = {};
@@ -3441,9 +2656,9 @@ function stacktracey(stacktrace, opts) {
3441
2656
  if (content) {
3442
2657
  return getConsumer(content).then((consumer) => {
3443
2658
  return parseSourceMapContent(consumer, {
3444
- line,
2659
+ line: line + (opts.preset.lineOffset || 0),
3445
2660
  column,
3446
- });
2661
+ }, !!opts.withSourceContent);
3447
2662
  });
3448
2663
  }
3449
2664
  });
@@ -3451,7 +2666,7 @@ function stacktracey(stacktrace, opts) {
3451
2666
  try {
3452
2667
  return _getSourceMapContent(file, fileName, fileRelative).then((sourceMapContent) => {
3453
2668
  if (sourceMapContent) {
3454
- const { source, sourcePath, sourceLine, sourceColumn, fileName = '', } = sourceMapContent;
2669
+ const { source, sourcePath, sourceLine, sourceColumn, sourceContent, fileName = '', } = sourceMapContent;
3455
2670
  stack.items[index] = Object.assign({}, item, {
3456
2671
  file: source,
3457
2672
  line: sourceLine,
@@ -3461,6 +2676,7 @@ function stacktracey(stacktrace, opts) {
3461
2676
  fileName,
3462
2677
  thirdParty: isThirdParty(sourcePath),
3463
2678
  parsed: true,
2679
+ sourceContent,
3464
2680
  });
3465
2681
  /**
3466
2682
  * 以 .js 结尾
@@ -3519,7 +2735,7 @@ function getConsumer(content) {
3519
2735
  });
3520
2736
  }
3521
2737
  else {
3522
- // @ts-ignore
2738
+ // @ts-expect-error
3523
2739
  const consumer = SourceMapConsumer(content);
3524
2740
  resolve(consumer);
3525
2741
  }
@@ -3552,7 +2768,7 @@ function getSourceMapContent(sourcemapUrl) {
3552
2768
  });
3553
2769
  }
3554
2770
  else {
3555
- sourcemapCatch[sourcemapUrl] = require$$0__default["default"].readFileSync(sourcemapUrl, 'utf-8');
2771
+ sourcemapCatch[sourcemapUrl] = fs__default.default.readFileSync(sourcemapUrl, 'utf-8');
3556
2772
  resolve(sourcemapCatch[sourcemapUrl]);
3557
2773
  }
3558
2774
  }
@@ -3565,7 +2781,7 @@ function getSourceMapContent(sourcemapUrl) {
3565
2781
  return '';
3566
2782
  }
3567
2783
  }
3568
- function parseSourceMapContent(consumer, obj) {
2784
+ function parseSourceMapContent(consumer, obj, withSourceContent) {
3569
2785
  // source -> 'uni-app:///node_modules/@sentry/browser/esm/helpers.js'
3570
2786
  const { source, line: sourceLine, column: sourceColumn, } = consumer.originalPositionFor(obj);
3571
2787
  if (source) {
@@ -3578,6 +2794,9 @@ function parseSourceMapContent(consumer, obj) {
3578
2794
  sourceLine: sourceLine === null ? 0 : sourceLine,
3579
2795
  sourceColumn: sourceColumn === null ? 0 : sourceColumn,
3580
2796
  fileName,
2797
+ sourceContent: withSourceContent
2798
+ ? consumer.sourceContentFor(source) || ''
2799
+ : '',
3581
2800
  };
3582
2801
  }
3583
2802
  }
@@ -3591,7 +2810,7 @@ function joinItem(item) {
3591
2810
  return `${a}${b}${c}`;
3592
2811
  }
3593
2812
  function uniStracktraceyPreset(opts) {
3594
- const { base, sourceRoot, splitThirdParty, uniPlatform } = opts;
2813
+ const { base, sourceRoot, splitThirdParty, uniPlatform, lineOffset } = opts;
3595
2814
  let stack;
3596
2815
  return {
3597
2816
  /**
@@ -3633,7 +2852,7 @@ function uniStracktraceyPreset(opts) {
3633
2852
  return Promise.resolve(getSourceMapContent(sourcemapUrl));
3634
2853
  },
3635
2854
  parseStacktrace(stacktrace) {
3636
- stack = new StackTracey$1(stacktrace, uniPlatform);
2855
+ stack = new StackTracey(stacktrace, uniPlatform);
3637
2856
  return stack;
3638
2857
  },
3639
2858
  asTableStacktrace({ maxColumnWidths, stacktrace, stack }) {
@@ -3674,18 +2893,15 @@ function uniStracktraceyPreset(opts) {
3674
2893
  return errorName;
3675
2894
  }
3676
2895
  },
2896
+ lineOffset,
3677
2897
  };
3678
2898
  }
3679
2899
  function utsStracktraceyPreset(opts) {
3680
- const { base, sourceRoot } = opts;
2900
+ const { inputRoot, outputRoot, sourceMapRoot } = opts;
3681
2901
  let errStack = [];
3682
2902
  return {
3683
2903
  parseSourceMapUrl(file, fileName, fileRelative) {
3684
- // 组合 sourceMapUrl
3685
- if (sourceRoot) {
3686
- return `${file.replace(sourceRoot, base + '/')}.map`;
3687
- }
3688
- return `${base}/${file}.map`;
2904
+ return path__default.default.resolve(sourceMapRoot, path__default.default.relative(outputRoot, file) + '.map');
3689
2905
  },
3690
2906
  getSourceMapContent(file, fileName, fileRelative) {
3691
2907
  // 根据 base,filename 组合 sourceMapUrl
@@ -3696,30 +2912,26 @@ function utsStracktraceyPreset(opts) {
3696
2912
  const entries = lines
3697
2913
  .map((line, index) => {
3698
2914
  line = line.trim();
3699
- let callee, fileLineColumn = [], planA, planB;
3700
- if ((planA = line.match(/e: (.+\.kt)(.+\))*:\s*(.+)*/))) {
2915
+ const matches = line.match(/\s*(.+\.kt):([0-9]+):([0-9]+):\s+(.*)/);
2916
+ if (matches) {
3701
2917
  errStack.push('%StacktraceyItem%');
3702
- callee = 'e: ';
3703
- fileLineColumn = (planA[2].match(/.*:.*\((\d+).+?(\d+)\)/) || []).slice(1);
3704
2918
  }
3705
2919
  else {
3706
2920
  errStack.push(line);
3707
- return undefined;
2921
+ return;
3708
2922
  }
3709
- const fileName = planA[1]
3710
- ? (planB = planA[1].match(/(.*)*\/(.+)/) || [])[2] || ''
3711
- : '';
2923
+ const fileName = matches[1].replace(/^.*(\\|\/|\:)/, '');
3712
2924
  return {
3713
2925
  beforeParse: line,
3714
- callee: callee || '',
2926
+ callee: '',
3715
2927
  index: false,
3716
2928
  native: false,
3717
- file: nixSlashes(planA[1] || ''),
3718
- line: parseInt(fileLineColumn[0] || '', 10) || undefined,
3719
- column: parseInt(fileLineColumn[1] || '', 10) || undefined,
2929
+ file: nixSlashes(matches[1]),
2930
+ line: parseInt(matches[2]),
2931
+ column: parseInt(matches[3]),
3720
2932
  fileName,
3721
- fileShort: planB ? planB[1] : '',
3722
- errMsg: planA[3] || '',
2933
+ fileShort: line,
2934
+ errMsg: matches[4] || '',
3723
2935
  calleeShort: '',
3724
2936
  fileRelative: '',
3725
2937
  thirdParty: false,
@@ -3736,8 +2948,11 @@ function utsStracktraceyPreset(opts) {
3736
2948
  .map((item) => {
3737
2949
  if (item === '%StacktraceyItem%') {
3738
2950
  const _stack = stack.items.shift();
3739
- if (_stack)
3740
- return `${_stack.callee}${_stack.file}: (${_stack.line}, ${_stack.column}): ${_stack.errMsg}`;
2951
+ if (_stack) {
2952
+ return `at ${nixSlashes(path__default.default.relative(inputRoot, _stack.file.replace('\\\\?\\', '')))}:${_stack.line}:${_stack.column}
2953
+ ${_stack.errMsg}`;
2954
+ }
2955
+ return '';
3741
2956
  }
3742
2957
  return item;
3743
2958
  })
@@ -3746,6 +2961,12 @@ function utsStracktraceyPreset(opts) {
3746
2961
  };
3747
2962
  }
3748
2963
 
2964
+ exports.SourceMapConsumer = SourceMapConsumer;
2965
+ exports.generateCodeFrame = generateCodeFrame;
2966
+ exports.generateCodeFrameSourceMapConsumer = generateCodeFrameSourceMapConsumer;
2967
+ exports.generateCodeFrameWithKotlinStacktrace = generateCodeFrameWithKotlinStacktrace;
2968
+ exports.generateCodeFrameWithSourceMapPath = generateCodeFrameWithSourceMapPath;
2969
+ exports.generateCodeFrameWithSwiftStacktrace = generateCodeFrameWithSwiftStacktrace;
3749
2970
  exports.stacktracey = stacktracey;
3750
2971
  exports.uniStracktraceyPreset = uniStracktraceyPreset;
3751
2972
  exports.utsStracktraceyPreset = utsStracktraceyPreset;