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