@abaplint/transpiler-cli 2.10.74 → 2.10.76

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.
Files changed (2) hide show
  1. package/build/bundle.js +878 -1046
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -95789,7 +95789,7 @@ class ArraySet {
95789
95789
  * @param String aStr
95790
95790
  */
95791
95791
  has(aStr) {
95792
- return this._set.has(aStr);
95792
+ return this._set.has(aStr);
95793
95793
  }
95794
95794
 
95795
95795
  /**
@@ -95800,7 +95800,7 @@ class ArraySet {
95800
95800
  indexOf(aStr) {
95801
95801
  const idx = this._set.get(aStr);
95802
95802
  if (idx >= 0) {
95803
- return idx;
95803
+ return idx;
95804
95804
  }
95805
95805
  throw new Error('"' + aStr + '" is not in the set.');
95806
95806
  }
@@ -95906,24 +95906,7 @@ const VLQ_CONTINUATION_BIT = VLQ_BASE;
95906
95906
  * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
95907
95907
  */
95908
95908
  function toVLQSigned(aValue) {
95909
- return aValue < 0
95910
- ? ((-aValue) << 1) + 1
95911
- : (aValue << 1) + 0;
95912
- }
95913
-
95914
- /**
95915
- * Converts to a two-complement value from a value where the sign bit is
95916
- * placed in the least significant bit. For example, as decimals:
95917
- * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
95918
- * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
95919
- */
95920
- // eslint-disable-next-line no-unused-vars
95921
- function fromVLQSigned(aValue) {
95922
- const isNegative = (aValue & 1) === 1;
95923
- const shifted = aValue >> 1;
95924
- return isNegative
95925
- ? -shifted
95926
- : shifted;
95909
+ return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0;
95927
95910
  }
95928
95911
 
95929
95912
  /**
@@ -95965,12 +95948,13 @@ exports.encode = function base64VLQ_encode(aValue) {
95965
95948
  * http://opensource.org/licenses/BSD-3-Clause
95966
95949
  */
95967
95950
 
95968
- const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
95951
+ const intToCharMap =
95952
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
95969
95953
 
95970
95954
  /**
95971
95955
  * Encode an integer in the range of 0 to 63 to a single base 64 digit.
95972
95956
  */
95973
- exports.encode = function(number) {
95957
+ exports.encode = function (number) {
95974
95958
  if (0 <= number && number < intToCharMap.length) {
95975
95959
  return intToCharMap[number];
95976
95960
  }
@@ -96033,7 +96017,7 @@ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
96033
96017
 
96034
96018
  // The exact needle element was not found in this haystack. Determine if
96035
96019
  // we are in termination case (3) or (2) and return the appropriate thing.
96036
- if (aBias == exports.LEAST_UPPER_BOUND) {
96020
+ if (aBias === exports.LEAST_UPPER_BOUND) {
96037
96021
  return aHigh < aHaystack.length ? aHigh : -1;
96038
96022
  }
96039
96023
  return mid;
@@ -96075,13 +96059,19 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
96075
96059
  return -1;
96076
96060
  }
96077
96061
 
96078
- let index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
96079
- aCompare, aBias || exports.GREATEST_LOWER_BOUND);
96062
+ let index = recursiveSearch(
96063
+ -1,
96064
+ aHaystack.length,
96065
+ aNeedle,
96066
+ aHaystack,
96067
+ aCompare,
96068
+ aBias || exports.GREATEST_LOWER_BOUND
96069
+ );
96080
96070
  if (index < 0) {
96081
96071
  return -1;
96082
96072
  }
96083
96073
 
96084
- // We have found either the exact element, or the next-closest element than
96074
+ // We have found either the exact element, or the next-closest element to
96085
96075
  // the one we are searching for. However, there may be more than one such
96086
96076
  // element. Make sure we always return the smallest of these.
96087
96077
  while (index - 1 >= 0) {
@@ -96122,8 +96112,11 @@ function generatedPositionAfter(mappingA, mappingB) {
96122
96112
  const lineB = mappingB.generatedLine;
96123
96113
  const columnA = mappingA.generatedColumn;
96124
96114
  const columnB = mappingB.generatedColumn;
96125
- return lineB > lineA || lineB == lineA && columnB >= columnA ||
96126
- util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
96115
+ return (
96116
+ lineB > lineA ||
96117
+ (lineB == lineA && columnB >= columnA) ||
96118
+ util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0
96119
+ );
96127
96120
  }
96128
96121
 
96129
96122
  /**
@@ -96136,7 +96129,7 @@ class MappingList {
96136
96129
  this._array = [];
96137
96130
  this._sorted = true;
96138
96131
  // Serves as infimum
96139
- this._last = {generatedLine: -1, generatedColumn: 0};
96132
+ this._last = { generatedLine: -1, generatedColumn: 0 };
96140
96133
  }
96141
96134
 
96142
96135
  /**
@@ -96193,55 +96186,34 @@ exports.MappingList = MappingList;
96193
96186
  \**************************************************/
96194
96187
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
96195
96188
 
96196
- /* 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 */
96197
- const isBrowserEnvironment = (function() {
96198
- // eslint-disable-next-line no-undef
96199
- return (typeof window !== "undefined") && (this === window);
96200
- }).call();
96189
+ "use strict";
96201
96190
 
96202
- if (isBrowserEnvironment) {
96203
- // Web version of reading a wasm file into an array buffer.
96204
96191
 
96205
- let mappingsWasm = null;
96192
+ // Note: This file is replaced with "read-wasm-browser.js" when this module is
96193
+ // bundled with a packager that takes package.json#browser fields into account.
96206
96194
 
96207
- module.exports = function readWasm() {
96208
- if (typeof mappingsWasm === "string") {
96209
- return fetch(mappingsWasm)
96210
- .then(response => response.arrayBuffer());
96211
- }
96212
- if (mappingsWasm instanceof ArrayBuffer) {
96213
- return Promise.resolve(mappingsWasm);
96214
- }
96215
- throw new Error("You must provide the string URL or ArrayBuffer contents " +
96216
- "of lib/mappings.wasm by calling " +
96217
- "SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) " +
96218
- "before using SourceMapConsumer");
96219
- };
96195
+ const fs = __webpack_require__(/*! fs */ "fs");
96196
+ const path = __webpack_require__(/*! path */ "path");
96220
96197
 
96221
- module.exports.initialize = input => mappingsWasm = input;
96222
- } else {
96223
- // Node version of reading a wasm file into an array buffer.
96224
- const fs = __webpack_require__(/*! fs */ "fs");
96225
- const path = __webpack_require__(/*! path */ "path");
96226
-
96227
- module.exports = function readWasm() {
96228
- return new Promise((resolve, reject) => {
96229
- const wasmPath = path.join(__dirname, "mappings.wasm");
96230
- fs.readFile(wasmPath, null, (error, data) => {
96231
- if (error) {
96232
- reject(error);
96233
- return;
96234
- }
96198
+ module.exports = function readWasm() {
96199
+ return new Promise((resolve, reject) => {
96200
+ const wasmPath = path.join(__dirname, "mappings.wasm");
96201
+ fs.readFile(wasmPath, null, (error, data) => {
96202
+ if (error) {
96203
+ reject(error);
96204
+ return;
96205
+ }
96235
96206
 
96236
- resolve(data.buffer);
96237
- });
96207
+ resolve(data.buffer);
96238
96208
  });
96239
- };
96209
+ });
96210
+ };
96240
96211
 
96241
- module.exports.initialize = _ => {
96242
- console.debug("SourceMapConsumer.initialize is a no-op when running in node.js");
96243
- };
96244
- }
96212
+ module.exports.initialize = _ => {
96213
+ console.debug(
96214
+ "SourceMapConsumer.initialize is a no-op when running in node.js"
96215
+ );
96216
+ };
96245
96217
 
96246
96218
 
96247
96219
  /***/ }),
@@ -96327,15 +96299,6 @@ class SourceMapConsumer {
96327
96299
  }
96328
96300
  }
96329
96301
 
96330
- /**
96331
- * Parse the mappings in a string in to a data structure which we can easily
96332
- * query (the ordered arrays in the `this.__generatedMappings` and
96333
- * `this.__originalMappings` properties).
96334
- */
96335
- _parseMappings(aStr, aSourceRoot) {
96336
- throw new Error("Subclasses must implement _parseMappings");
96337
- }
96338
-
96339
96302
  /**
96340
96303
  * Iterate over each mapping between an original source/line/column and a
96341
96304
  * generated line/column in this source map.
@@ -96442,14 +96405,19 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96442
96405
  }
96443
96406
 
96444
96407
  const version = util.getArg(sourceMap, "version");
96445
- let sources = util.getArg(sourceMap, "sources");
96408
+ const sources = util.getArg(sourceMap, "sources").map(String);
96446
96409
  // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
96447
96410
  // requires the array) to play nice here.
96448
96411
  const names = util.getArg(sourceMap, "names", []);
96449
- let sourceRoot = util.getArg(sourceMap, "sourceRoot", null);
96412
+ const sourceRoot = util.getArg(sourceMap, "sourceRoot", null);
96450
96413
  const sourcesContent = util.getArg(sourceMap, "sourcesContent", null);
96451
96414
  const mappings = util.getArg(sourceMap, "mappings");
96452
96415
  const file = util.getArg(sourceMap, "file", null);
96416
+ const x_google_ignoreList = util.getArg(
96417
+ sourceMap,
96418
+ "x_google_ignoreList",
96419
+ null
96420
+ );
96453
96421
 
96454
96422
  // Once again, Sass deviates from the spec and supplies the version as a
96455
96423
  // string rather than a number, so we use loose equality checking here.
@@ -96457,25 +96425,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96457
96425
  throw new Error("Unsupported version: " + version);
96458
96426
  }
96459
96427
 
96460
- if (sourceRoot) {
96461
- sourceRoot = util.normalize(sourceRoot);
96462
- }
96463
-
96464
- sources = sources
96465
- .map(String)
96466
- // Some source maps produce relative source paths like "./foo.js" instead of
96467
- // "foo.js". Normalize these first so that future comparisons will succeed.
96468
- // See bugzil.la/1090768.
96469
- .map(util.normalize)
96470
- // Always ensure that absolute sources are internally stored relative to
96471
- // the source root, if the source root is absolute. Not doing this would
96472
- // be particularly problematic when the source root is a prefix of the
96473
- // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
96474
- .map(function(source) {
96475
- return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
96476
- ? util.relative(sourceRoot, source)
96477
- : source;
96478
- });
96428
+ that._sourceLookupCache = new Map();
96479
96429
 
96480
96430
  // Pass `true` below to allow duplicate names and sources. While source maps
96481
96431
  // are intended to be compressed and deduplicated, the TypeScript compiler
@@ -96484,15 +96434,19 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96484
96434
  that._names = ArraySet.fromArray(names.map(String), true);
96485
96435
  that._sources = ArraySet.fromArray(sources, true);
96486
96436
 
96487
- that._absoluteSources = that._sources.toArray().map(function(s) {
96488
- return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
96489
- });
96437
+ that._absoluteSources = ArraySet.fromArray(
96438
+ that._sources.toArray().map(function (s) {
96439
+ return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
96440
+ }),
96441
+ true
96442
+ );
96490
96443
 
96491
96444
  that.sourceRoot = sourceRoot;
96492
96445
  that.sourcesContent = sourcesContent;
96493
96446
  that._mappings = mappings;
96494
96447
  that._sourceMapURL = aSourceMapURL;
96495
96448
  that.file = file;
96449
+ that.x_google_ignoreList = x_google_ignoreList;
96496
96450
 
96497
96451
  that._computedColumnSpans = false;
96498
96452
  that._mappingsPtr = 0;
@@ -96510,23 +96464,38 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96510
96464
  * found.
96511
96465
  */
96512
96466
  _findSourceIndex(aSource) {
96513
- let relativeSource = aSource;
96514
- if (this.sourceRoot != null) {
96515
- relativeSource = util.relative(this.sourceRoot, relativeSource);
96516
- }
96517
-
96518
- if (this._sources.has(relativeSource)) {
96519
- return this._sources.indexOf(relativeSource);
96467
+ // In the most common usecases, we'll be constantly looking up the index for the same source
96468
+ // files, so we cache the index lookup to avoid constantly recomputing the full URLs.
96469
+ const cachedIndex = this._sourceLookupCache.get(aSource);
96470
+ if (typeof cachedIndex === "number") {
96471
+ return cachedIndex;
96472
+ }
96473
+
96474
+ // Treat the source as map-relative overall by default.
96475
+ const sourceAsMapRelative = util.computeSourceURL(
96476
+ null,
96477
+ aSource,
96478
+ this._sourceMapURL
96479
+ );
96480
+ if (this._absoluteSources.has(sourceAsMapRelative)) {
96481
+ const index = this._absoluteSources.indexOf(sourceAsMapRelative);
96482
+ this._sourceLookupCache.set(aSource, index);
96483
+ return index;
96520
96484
  }
96521
96485
 
96522
- // Maybe aSource is an absolute URL as returned by |sources|. In
96523
- // this case we can't simply undo the transform.
96524
- for (let i = 0; i < this._absoluteSources.length; ++i) {
96525
- if (this._absoluteSources[i] == aSource) {
96526
- return i;
96527
- }
96486
+ // Fall back to treating the source as sourceRoot-relative.
96487
+ const sourceAsSourceRootRelative = util.computeSourceURL(
96488
+ this.sourceRoot,
96489
+ aSource,
96490
+ this._sourceMapURL
96491
+ );
96492
+ if (this._absoluteSources.has(sourceAsSourceRootRelative)) {
96493
+ const index = this._absoluteSources.indexOf(sourceAsSourceRootRelative);
96494
+ this._sourceLookupCache.set(aSource, index);
96495
+ return index;
96528
96496
  }
96529
96497
 
96498
+ // To avoid this cache growing forever, we do not cache lookup misses.
96530
96499
  return -1;
96531
96500
  }
96532
96501
 
@@ -96544,12 +96513,12 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96544
96513
  }
96545
96514
 
96546
96515
  get sources() {
96547
- return this._absoluteSources.slice();
96516
+ return this._absoluteSources.toArray();
96548
96517
  }
96549
96518
 
96550
96519
  _getMappingsPtr() {
96551
96520
  if (this._mappingsPtr === 0) {
96552
- this._parseMappings(this._mappings, this.sourceRoot);
96521
+ this._parseMappings();
96553
96522
  }
96554
96523
 
96555
96524
  return this._mappingsPtr;
@@ -96560,11 +96529,18 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96560
96529
  * query (the ordered arrays in the `this.__generatedMappings` and
96561
96530
  * `this.__originalMappings` properties).
96562
96531
  */
96563
- _parseMappings(aStr, aSourceRoot) {
96532
+ _parseMappings() {
96533
+ const aStr = this._mappings;
96564
96534
  const size = aStr.length;
96565
96535
 
96566
- const mappingsBufPtr = this._wasm.exports.allocate_mappings(size);
96567
- const mappingsBuf = new Uint8Array(this._wasm.exports.memory.buffer, mappingsBufPtr, size);
96536
+ // Interpret signed result of allocate_mappings as unsigned, otherwise
96537
+ // addresses higher than 2GB will be negative.
96538
+ const mappingsBufPtr = this._wasm.exports.allocate_mappings(size) >>> 0;
96539
+ const mappingsBuf = new Uint8Array(
96540
+ this._wasm.exports.memory.buffer,
96541
+ mappingsBufPtr,
96542
+ size
96543
+ );
96568
96544
  for (let i = 0; i < size; i++) {
96569
96545
  mappingsBuf[i] = aStr.charCodeAt(i);
96570
96546
  }
@@ -96575,10 +96551,11 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96575
96551
  const error = this._wasm.exports.get_last_error();
96576
96552
  let msg = `Error parsing mappings (code ${error}): `;
96577
96553
 
96578
- // XXX: keep these error codes in sync with `fitzgen/source-map-mappings`.
96554
+ // XXX: keep these error codes in sync with `wasm-mappings`.
96579
96555
  switch (error) {
96580
96556
  case 1:
96581
- msg += "the mappings contained a negative line, column, source index, or name index";
96557
+ msg +=
96558
+ "the mappings contained a negative line, column, source index, or name index";
96582
96559
  break;
96583
96560
  case 2:
96584
96561
  msg += "the mappings contained a number larger than 2**32";
@@ -96603,31 +96580,32 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96603
96580
  eachMapping(aCallback, aContext, aOrder) {
96604
96581
  const context = aContext || null;
96605
96582
  const order = aOrder || SourceMapConsumer.GENERATED_ORDER;
96606
- const sourceRoot = this.sourceRoot;
96607
96583
 
96608
96584
  this._wasm.withMappingCallback(
96609
96585
  mapping => {
96610
96586
  if (mapping.source !== null) {
96611
- mapping.source = this._sources.at(mapping.source);
96612
- mapping.source = util.computeSourceURL(sourceRoot, mapping.source, this._sourceMapURL);
96587
+ mapping.source = this._absoluteSources.at(mapping.source);
96613
96588
 
96614
96589
  if (mapping.name !== null) {
96615
96590
  mapping.name = this._names.at(mapping.name);
96616
96591
  }
96617
96592
  }
96593
+ if (this._computedColumnSpans && mapping.lastGeneratedColumn === null) {
96594
+ mapping.lastGeneratedColumn = Infinity;
96595
+ }
96618
96596
 
96619
96597
  aCallback.call(context, mapping);
96620
96598
  },
96621
96599
  () => {
96622
96600
  switch (order) {
96623
- case SourceMapConsumer.GENERATED_ORDER:
96624
- this._wasm.exports.by_generated_location(this._getMappingsPtr());
96625
- break;
96626
- case SourceMapConsumer.ORIGINAL_ORDER:
96627
- this._wasm.exports.by_original_location(this._getMappingsPtr());
96628
- break;
96629
- default:
96630
- throw new Error("Unknown order of iteration.");
96601
+ case SourceMapConsumer.GENERATED_ORDER:
96602
+ this._wasm.exports.by_generated_location(this._getMappingsPtr());
96603
+ break;
96604
+ case SourceMapConsumer.ORIGINAL_ORDER:
96605
+ this._wasm.exports.by_original_location(this._getMappingsPtr());
96606
+ break;
96607
+ default:
96608
+ throw new Error("Unknown order of iteration.");
96631
96609
  }
96632
96610
  }
96633
96611
  );
@@ -96664,7 +96642,8 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96664
96642
  column: m.generatedColumn,
96665
96643
  lastColumn,
96666
96644
  });
96667
- }, () => {
96645
+ },
96646
+ () => {
96668
96647
  this._wasm.exports.all_generated_locations_for(
96669
96648
  this._getMappingsPtr(),
96670
96649
  source,
@@ -96725,7 +96704,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96725
96704
  originalPositionFor(aArgs) {
96726
96705
  const needle = {
96727
96706
  generatedLine: util.getArg(aArgs, "line"),
96728
- generatedColumn: util.getArg(aArgs, "column")
96707
+ generatedColumn: util.getArg(aArgs, "column"),
96729
96708
  };
96730
96709
 
96731
96710
  if (needle.generatedLine < 1) {
@@ -96736,27 +96715,33 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96736
96715
  throw new Error("Column numbers must be >= 0");
96737
96716
  }
96738
96717
 
96739
- let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
96718
+ let bias = util.getArg(
96719
+ aArgs,
96720
+ "bias",
96721
+ SourceMapConsumer.GREATEST_LOWER_BOUND
96722
+ );
96740
96723
  if (bias == null) {
96741
96724
  bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
96742
96725
  }
96743
96726
 
96744
96727
  let mapping;
96745
- this._wasm.withMappingCallback(m => mapping = m, () => {
96746
- this._wasm.exports.original_location_for(
96747
- this._getMappingsPtr(),
96748
- needle.generatedLine - 1,
96749
- needle.generatedColumn,
96750
- bias
96751
- );
96752
- });
96728
+ this._wasm.withMappingCallback(
96729
+ m => (mapping = m),
96730
+ () => {
96731
+ this._wasm.exports.original_location_for(
96732
+ this._getMappingsPtr(),
96733
+ needle.generatedLine - 1,
96734
+ needle.generatedColumn,
96735
+ bias
96736
+ );
96737
+ }
96738
+ );
96753
96739
 
96754
96740
  if (mapping) {
96755
96741
  if (mapping.generatedLine === needle.generatedLine) {
96756
96742
  let source = util.getArg(mapping, "source", null);
96757
96743
  if (source !== null) {
96758
- source = this._sources.at(source);
96759
- source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
96744
+ source = this._absoluteSources.at(source);
96760
96745
  }
96761
96746
 
96762
96747
  let name = util.getArg(mapping, "name", null);
@@ -96768,7 +96753,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96768
96753
  source,
96769
96754
  line: util.getArg(mapping, "originalLine", null),
96770
96755
  column: util.getArg(mapping, "originalColumn", null),
96771
- name
96756
+ name,
96772
96757
  };
96773
96758
  }
96774
96759
  }
@@ -96777,7 +96762,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96777
96762
  source: null,
96778
96763
  line: null,
96779
96764
  column: null,
96780
- name: null
96765
+ name: null,
96781
96766
  };
96782
96767
  }
96783
96768
 
@@ -96789,8 +96774,12 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96789
96774
  if (!this.sourcesContent) {
96790
96775
  return false;
96791
96776
  }
96792
- return this.sourcesContent.length >= this._sources.size() &&
96793
- !this.sourcesContent.some(function(sc) { return sc == null; });
96777
+ return (
96778
+ this.sourcesContent.length >= this._sources.size() &&
96779
+ !this.sourcesContent.some(function (sc) {
96780
+ return sc == null;
96781
+ })
96782
+ );
96794
96783
  }
96795
96784
 
96796
96785
  /**
@@ -96808,30 +96797,6 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96808
96797
  return this.sourcesContent[index];
96809
96798
  }
96810
96799
 
96811
- let relativeSource = aSource;
96812
- if (this.sourceRoot != null) {
96813
- relativeSource = util.relative(this.sourceRoot, relativeSource);
96814
- }
96815
-
96816
- let url;
96817
- if (this.sourceRoot != null
96818
- && (url = util.urlParse(this.sourceRoot))) {
96819
- // XXX: file:// URIs and absolute paths lead to unexpected behavior for
96820
- // many users. We can help them out when they expect file:// URIs to
96821
- // behave like it would if they were running a local HTTP server. See
96822
- // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
96823
- const fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
96824
- if (url.scheme == "file"
96825
- && this._sources.has(fileUriAbsPath)) {
96826
- return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)];
96827
- }
96828
-
96829
- if ((!url.path || url.path == "/")
96830
- && this._sources.has("/" + relativeSource)) {
96831
- return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
96832
- }
96833
- }
96834
-
96835
96800
  // This function is used recursively from
96836
96801
  // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
96837
96802
  // don't want to throw if we can't find the source - we just want to
@@ -96840,7 +96805,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96840
96805
  return null;
96841
96806
  }
96842
96807
 
96843
- throw new Error('"' + relativeSource + '" is not in the SourceMap.');
96808
+ throw new Error('"' + aSource + '" is not in the SourceMap.');
96844
96809
  }
96845
96810
 
96846
96811
  /**
@@ -96873,14 +96838,14 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96873
96838
  return {
96874
96839
  line: null,
96875
96840
  column: null,
96876
- lastColumn: null
96841
+ lastColumn: null,
96877
96842
  };
96878
96843
  }
96879
96844
 
96880
96845
  const needle = {
96881
96846
  source,
96882
96847
  originalLine: util.getArg(aArgs, "line"),
96883
- originalColumn: util.getArg(aArgs, "column")
96848
+ originalColumn: util.getArg(aArgs, "column"),
96884
96849
  };
96885
96850
 
96886
96851
  if (needle.originalLine < 1) {
@@ -96891,21 +96856,28 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96891
96856
  throw new Error("Column numbers must be >= 0");
96892
96857
  }
96893
96858
 
96894
- let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
96859
+ let bias = util.getArg(
96860
+ aArgs,
96861
+ "bias",
96862
+ SourceMapConsumer.GREATEST_LOWER_BOUND
96863
+ );
96895
96864
  if (bias == null) {
96896
96865
  bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
96897
96866
  }
96898
96867
 
96899
96868
  let mapping;
96900
- this._wasm.withMappingCallback(m => mapping = m, () => {
96901
- this._wasm.exports.generated_location_for(
96902
- this._getMappingsPtr(),
96903
- needle.source,
96904
- needle.originalLine - 1,
96905
- needle.originalColumn,
96906
- bias
96907
- );
96908
- });
96869
+ this._wasm.withMappingCallback(
96870
+ m => (mapping = m),
96871
+ () => {
96872
+ this._wasm.exports.generated_location_for(
96873
+ this._getMappingsPtr(),
96874
+ needle.source,
96875
+ needle.originalLine - 1,
96876
+ needle.originalColumn,
96877
+ bias
96878
+ );
96879
+ }
96880
+ );
96909
96881
 
96910
96882
  if (mapping) {
96911
96883
  if (mapping.source === needle.source) {
@@ -96924,7 +96896,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96924
96896
  return {
96925
96897
  line: null,
96926
96898
  column: null,
96927
- lastColumn: null
96899
+ lastColumn: null,
96928
96900
  };
96929
96901
  }
96930
96902
  }
@@ -96996,125 +96968,56 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
96996
96968
  throw new Error("Unsupported version: " + version);
96997
96969
  }
96998
96970
 
96999
- that._sources = new ArraySet();
97000
- that._names = new ArraySet();
97001
- that.__generatedMappings = null;
97002
- that.__originalMappings = null;
97003
- that.__generatedMappingsUnsorted = null;
97004
- that.__originalMappingsUnsorted = null;
97005
-
97006
96971
  let lastOffset = {
97007
96972
  line: -1,
97008
- column: 0
96973
+ column: 0,
97009
96974
  };
97010
- return Promise.all(sections.map(s => {
97011
- if (s.url) {
97012
- // The url field will require support for asynchronicity.
97013
- // See https://github.com/mozilla/source-map/issues/16
97014
- throw new Error("Support for url field in sections not implemented.");
97015
- }
97016
- const offset = util.getArg(s, "offset");
97017
- const offsetLine = util.getArg(offset, "line");
97018
- const offsetColumn = util.getArg(offset, "column");
97019
-
97020
- if (offsetLine < lastOffset.line ||
97021
- (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
97022
- throw new Error("Section offsets must be ordered and non-overlapping.");
97023
- }
97024
- lastOffset = offset;
97025
-
97026
- const cons = new SourceMapConsumer(util.getArg(s, "map"), aSourceMapURL);
97027
- return cons.then(consumer => {
97028
- return {
97029
- generatedOffset: {
97030
- // The offset fields are 0-based, but we use 1-based indices when
97031
- // encoding/decoding from VLQ.
97032
- generatedLine: offsetLine + 1,
97033
- generatedColumn: offsetColumn + 1
97034
- },
97035
- consumer
97036
- };
97037
- });
97038
- })).then(s => {
96975
+ return Promise.all(
96976
+ sections.map(s => {
96977
+ if (s.url) {
96978
+ // The url field will require support for asynchronicity.
96979
+ // See https://github.com/mozilla/source-map/issues/16
96980
+ throw new Error(
96981
+ "Support for url field in sections not implemented."
96982
+ );
96983
+ }
96984
+ const offset = util.getArg(s, "offset");
96985
+ const offsetLine = util.getArg(offset, "line");
96986
+ const offsetColumn = util.getArg(offset, "column");
96987
+
96988
+ if (
96989
+ offsetLine < lastOffset.line ||
96990
+ (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)
96991
+ ) {
96992
+ throw new Error(
96993
+ "Section offsets must be ordered and non-overlapping."
96994
+ );
96995
+ }
96996
+ lastOffset = offset;
96997
+
96998
+ const cons = new SourceMapConsumer(
96999
+ util.getArg(s, "map"),
97000
+ aSourceMapURL
97001
+ );
97002
+ return cons.then(consumer => {
97003
+ return {
97004
+ generatedOffset: {
97005
+ // The offset fields are 0-based, but we use 1-based indices when
97006
+ // encoding/decoding from VLQ.
97007
+ generatedLine: offsetLine + 1,
97008
+ generatedColumn: offsetColumn + 1,
97009
+ },
97010
+ consumer,
97011
+ };
97012
+ });
97013
+ })
97014
+ ).then(s => {
97039
97015
  that._sections = s;
97040
97016
  return that;
97041
97017
  });
97042
97018
  });
97043
97019
  }
97044
97020
 
97045
- // `__generatedMappings` and `__originalMappings` are arrays that hold the
97046
- // parsed mapping coordinates from the source map's "mappings" attribute. They
97047
- // are lazily instantiated, accessed via the `_generatedMappings` and
97048
- // `_originalMappings` getters respectively, and we only parse the mappings
97049
- // and create these arrays once queried for a source location. We jump through
97050
- // these hoops because there can be many thousands of mappings, and parsing
97051
- // them is expensive, so we only want to do it if we must.
97052
- //
97053
- // Each object in the arrays is of the form:
97054
- //
97055
- // {
97056
- // generatedLine: The line number in the generated code,
97057
- // generatedColumn: The column number in the generated code,
97058
- // source: The path to the original source file that generated this
97059
- // chunk of code,
97060
- // originalLine: The line number in the original source that
97061
- // corresponds to this chunk of generated code,
97062
- // originalColumn: The column number in the original source that
97063
- // corresponds to this chunk of generated code,
97064
- // name: The name of the original symbol which generated this chunk of
97065
- // code.
97066
- // }
97067
- //
97068
- // All properties except for `generatedLine` and `generatedColumn` can be
97069
- // `null`.
97070
- //
97071
- // `_generatedMappings` is ordered by the generated positions.
97072
- //
97073
- // `_originalMappings` is ordered by the original positions.
97074
- get _generatedMappings() {
97075
- if (!this.__generatedMappings) {
97076
- this._sortGeneratedMappings();
97077
- }
97078
-
97079
- return this.__generatedMappings;
97080
- }
97081
-
97082
- get _originalMappings() {
97083
- if (!this.__originalMappings) {
97084
- this._sortOriginalMappings();
97085
- }
97086
-
97087
- return this.__originalMappings;
97088
- }
97089
-
97090
- get _generatedMappingsUnsorted() {
97091
- if (!this.__generatedMappingsUnsorted) {
97092
- this._parseMappings(this._mappings, this.sourceRoot);
97093
- }
97094
-
97095
- return this.__generatedMappingsUnsorted;
97096
- }
97097
-
97098
- get _originalMappingsUnsorted() {
97099
- if (!this.__originalMappingsUnsorted) {
97100
- this._parseMappings(this._mappings, this.sourceRoot);
97101
- }
97102
-
97103
- return this.__originalMappingsUnsorted;
97104
- }
97105
-
97106
- _sortGeneratedMappings() {
97107
- const mappings = this._generatedMappingsUnsorted;
97108
- mappings.sort(util.compareByGeneratedPositionsDeflated);
97109
- this.__generatedMappings = mappings;
97110
- }
97111
-
97112
- _sortOriginalMappings() {
97113
- const mappings = this._originalMappingsUnsorted;
97114
- mappings.sort(util.compareByOriginalPositions);
97115
- this.__originalMappings = mappings;
97116
- }
97117
-
97118
97021
  /**
97119
97022
  * The list of original sources.
97120
97023
  */
@@ -97150,21 +97053,29 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
97150
97053
  originalPositionFor(aArgs) {
97151
97054
  const needle = {
97152
97055
  generatedLine: util.getArg(aArgs, "line"),
97153
- generatedColumn: util.getArg(aArgs, "column")
97056
+ generatedColumn: util.getArg(aArgs, "column"),
97154
97057
  };
97155
97058
 
97156
97059
  // Find the section containing the generated position we're trying to map
97157
97060
  // to an original position.
97158
- const sectionIndex = binarySearch.search(needle, this._sections,
97159
- function(aNeedle, section) {
97160
- const cmp = aNeedle.generatedLine - section.generatedOffset.generatedLine;
97061
+ const sectionIndex = binarySearch.search(
97062
+ needle,
97063
+ this._sections,
97064
+ function (aNeedle, section) {
97065
+ const cmp =
97066
+ aNeedle.generatedLine - section.generatedOffset.generatedLine;
97161
97067
  if (cmp) {
97162
97068
  return cmp;
97163
97069
  }
97164
97070
 
97165
- return (aNeedle.generatedColumn -
97166
- section.generatedOffset.generatedColumn);
97167
- });
97071
+ // The generated column is 0-based, but the section offset column is
97072
+ // stored 1-based.
97073
+ return (
97074
+ aNeedle.generatedColumn -
97075
+ (section.generatedOffset.generatedColumn - 1)
97076
+ );
97077
+ }
97078
+ );
97168
97079
  const section = this._sections[sectionIndex];
97169
97080
 
97170
97081
  if (!section) {
@@ -97172,18 +97083,18 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
97172
97083
  source: null,
97173
97084
  line: null,
97174
97085
  column: null,
97175
- name: null
97086
+ name: null,
97176
97087
  };
97177
97088
  }
97178
97089
 
97179
97090
  return section.consumer.originalPositionFor({
97180
- line: needle.generatedLine -
97181
- (section.generatedOffset.generatedLine - 1),
97182
- column: needle.generatedColumn -
97091
+ line: needle.generatedLine - (section.generatedOffset.generatedLine - 1),
97092
+ column:
97093
+ needle.generatedColumn -
97183
97094
  (section.generatedOffset.generatedLine === needle.generatedLine
97184
- ? section.generatedOffset.generatedColumn - 1
97185
- : 0),
97186
- bias: aArgs.bias
97095
+ ? section.generatedOffset.generatedColumn - 1
97096
+ : 0),
97097
+ bias: aArgs.bias,
97187
97098
  });
97188
97099
  }
97189
97100
 
@@ -97192,7 +97103,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
97192
97103
  * map, false otherwise.
97193
97104
  */
97194
97105
  hasContentsOfAllSources() {
97195
- return this._sections.every(function(s) {
97106
+ return this._sections.every(function (s) {
97196
97107
  return s.consumer.hasContentsOfAllSources();
97197
97108
  });
97198
97109
  }
@@ -97217,6 +97128,16 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
97217
97128
  throw new Error('"' + aSource + '" is not in the SourceMap.');
97218
97129
  }
97219
97130
 
97131
+ _findSectionIndex(source) {
97132
+ for (let i = 0; i < this._sections.length; i++) {
97133
+ const { consumer } = this._sections[i];
97134
+ if (consumer._findSourceIndex(source) !== -1) {
97135
+ return i;
97136
+ }
97137
+ }
97138
+ return -1;
97139
+ }
97140
+
97220
97141
  /**
97221
97142
  * Returns the generated line and column information for the original source,
97222
97143
  * line, and column positions provided. The only argument is an object with
@@ -97236,230 +97157,124 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
97236
97157
  * The column number is 0-based.
97237
97158
  */
97238
97159
  generatedPositionFor(aArgs) {
97239
- for (let i = 0; i < this._sections.length; i++) {
97240
- const section = this._sections[i];
97160
+ const index = this._findSectionIndex(util.getArg(aArgs, "source"));
97161
+ const section = index >= 0 ? this._sections[index] : null;
97162
+ const nextSection =
97163
+ index >= 0 && index + 1 < this._sections.length
97164
+ ? this._sections[index + 1]
97165
+ : null;
97241
97166
 
97242
- // Only consider this section if the requested source is in the list of
97243
- // sources of the consumer.
97244
- if (section.consumer._findSourceIndex(util.getArg(aArgs, "source")) === -1) {
97245
- continue;
97167
+ const generatedPosition =
97168
+ section && section.consumer.generatedPositionFor(aArgs);
97169
+ if (generatedPosition && generatedPosition.line !== null) {
97170
+ const lineShift = section.generatedOffset.generatedLine - 1;
97171
+ const columnShift = section.generatedOffset.generatedColumn - 1;
97172
+
97173
+ if (generatedPosition.line === 1) {
97174
+ generatedPosition.column += columnShift;
97175
+ if (typeof generatedPosition.lastColumn === "number") {
97176
+ generatedPosition.lastColumn += columnShift;
97177
+ }
97246
97178
  }
97247
- const generatedPosition = section.consumer.generatedPositionFor(aArgs);
97248
- if (generatedPosition) {
97249
- const ret = {
97250
- line: generatedPosition.line +
97251
- (section.generatedOffset.generatedLine - 1),
97252
- column: generatedPosition.column +
97253
- (section.generatedOffset.generatedLine === generatedPosition.line
97254
- ? section.generatedOffset.generatedColumn - 1
97255
- : 0)
97256
- };
97257
- return ret;
97179
+
97180
+ if (
97181
+ generatedPosition.lastColumn === Infinity &&
97182
+ nextSection &&
97183
+ generatedPosition.line === nextSection.generatedOffset.generatedLine
97184
+ ) {
97185
+ generatedPosition.lastColumn =
97186
+ nextSection.generatedOffset.generatedColumn - 2;
97258
97187
  }
97188
+ generatedPosition.line += lineShift;
97189
+
97190
+ return generatedPosition;
97259
97191
  }
97260
97192
 
97261
97193
  return {
97262
97194
  line: null,
97263
- column: null
97195
+ column: null,
97196
+ lastColumn: null,
97264
97197
  };
97265
97198
  }
97266
97199
 
97267
- /**
97268
- * Parse the mappings in a string in to a data structure which we can easily
97269
- * query (the ordered arrays in the `this.__generatedMappings` and
97270
- * `this.__originalMappings` properties).
97271
- */
97272
- _parseMappings(aStr, aSourceRoot) {
97273
- const generatedMappings = this.__generatedMappingsUnsorted = [];
97274
- const originalMappings = this.__originalMappingsUnsorted = [];
97275
- for (let i = 0; i < this._sections.length; i++) {
97276
- const section = this._sections[i];
97277
-
97278
- const sectionMappings = [];
97279
- section.consumer.eachMapping(m => sectionMappings.push(m));
97200
+ allGeneratedPositionsFor(aArgs) {
97201
+ const index = this._findSectionIndex(util.getArg(aArgs, "source"));
97202
+ const section = index >= 0 ? this._sections[index] : null;
97203
+ const nextSection =
97204
+ index >= 0 && index + 1 < this._sections.length
97205
+ ? this._sections[index + 1]
97206
+ : null;
97280
97207
 
97281
- for (let j = 0; j < sectionMappings.length; j++) {
97282
- const mapping = sectionMappings[j];
97208
+ if (!section) return [];
97283
97209
 
97284
- // TODO: test if null is correct here. The original code used
97285
- // `source`, which would actually have gotten used as null because
97286
- // var's get hoisted.
97287
- // See: https://github.com/mozilla/source-map/issues/333
97288
- let source = util.computeSourceURL(section.consumer.sourceRoot, null, this._sourceMapURL);
97289
- this._sources.add(source);
97290
- source = this._sources.indexOf(source);
97210
+ return section.consumer
97211
+ .allGeneratedPositionsFor(aArgs)
97212
+ .map(generatedPosition => {
97213
+ const lineShift = section.generatedOffset.generatedLine - 1;
97214
+ const columnShift = section.generatedOffset.generatedColumn - 1;
97291
97215
 
97292
- let name = null;
97293
- if (mapping.name) {
97294
- this._names.add(mapping.name);
97295
- name = this._names.indexOf(mapping.name);
97216
+ if (generatedPosition.line === 1) {
97217
+ generatedPosition.column += columnShift;
97218
+ if (typeof generatedPosition.lastColumn === "number") {
97219
+ generatedPosition.lastColumn += columnShift;
97220
+ }
97296
97221
  }
97297
97222
 
97298
- // The mappings coming from the consumer for the section have
97299
- // generated positions relative to the start of the section, so we
97300
- // need to offset them to be relative to the start of the concatenated
97301
- // generated file.
97302
- const adjustedMapping = {
97303
- source,
97304
- generatedLine: mapping.generatedLine +
97305
- (section.generatedOffset.generatedLine - 1),
97306
- generatedColumn: mapping.generatedColumn +
97307
- (section.generatedOffset.generatedLine === mapping.generatedLine
97308
- ? section.generatedOffset.generatedColumn - 1
97309
- : 0),
97310
- originalLine: mapping.originalLine,
97311
- originalColumn: mapping.originalColumn,
97312
- name
97313
- };
97314
-
97315
- generatedMappings.push(adjustedMapping);
97316
- if (typeof adjustedMapping.originalLine === "number") {
97317
- originalMappings.push(adjustedMapping);
97223
+ if (
97224
+ generatedPosition.lastColumn === Infinity &&
97225
+ nextSection &&
97226
+ generatedPosition.line === nextSection.generatedOffset.generatedLine
97227
+ ) {
97228
+ generatedPosition.lastColumn =
97229
+ nextSection.generatedOffset.generatedColumn - 2;
97318
97230
  }
97319
- }
97320
- }
97321
- }
97231
+ generatedPosition.line += lineShift;
97322
97232
 
97323
- eachMapping(aCallback, aContext, aOrder) {
97324
- const context = aContext || null;
97325
- const order = aOrder || SourceMapConsumer.GENERATED_ORDER;
97326
-
97327
- let mappings;
97328
- switch (order) {
97329
- case SourceMapConsumer.GENERATED_ORDER:
97330
- mappings = this._generatedMappings;
97331
- break;
97332
- case SourceMapConsumer.ORIGINAL_ORDER:
97333
- mappings = this._originalMappings;
97334
- break;
97335
- default:
97336
- throw new Error("Unknown order of iteration.");
97337
- }
97338
-
97339
- const sourceRoot = this.sourceRoot;
97340
- mappings.map(function(mapping) {
97341
- let source = null;
97342
- if (mapping.source !== null) {
97343
- source = this._sources.at(mapping.source);
97344
- source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
97345
- }
97346
- return {
97347
- source,
97348
- generatedLine: mapping.generatedLine,
97349
- generatedColumn: mapping.generatedColumn,
97350
- originalLine: mapping.originalLine,
97351
- originalColumn: mapping.originalColumn,
97352
- name: mapping.name === null ? null : this._names.at(mapping.name)
97353
- };
97354
- }, this).forEach(aCallback, context);
97355
- }
97356
-
97357
- /**
97358
- * Find the mapping that best matches the hypothetical "needle" mapping that
97359
- * we are searching for in the given "haystack" of mappings.
97360
- */
97361
- _findMapping(aNeedle, aMappings, aLineName,
97362
- aColumnName, aComparator, aBias) {
97363
- // To return the position we are searching for, we must first find the
97364
- // mapping for the given position and then return the opposite position it
97365
- // points to. Because the mappings are sorted, we can use binary search to
97366
- // find the best mapping.
97367
-
97368
- if (aNeedle[aLineName] <= 0) {
97369
- throw new TypeError("Line must be greater than or equal to 1, got "
97370
- + aNeedle[aLineName]);
97371
- }
97372
- if (aNeedle[aColumnName] < 0) {
97373
- throw new TypeError("Column must be greater than or equal to 0, got "
97374
- + aNeedle[aColumnName]);
97375
- }
97376
-
97377
- return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
97233
+ return generatedPosition;
97234
+ });
97378
97235
  }
97379
97236
 
97380
- allGeneratedPositionsFor(aArgs) {
97381
- const line = util.getArg(aArgs, "line");
97382
-
97383
- // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
97384
- // returns the index of the closest mapping less than the needle. By
97385
- // setting needle.originalColumn to 0, we thus find the last mapping for
97386
- // the given line, provided such a mapping exists.
97387
- const needle = {
97388
- source: util.getArg(aArgs, "source"),
97389
- originalLine: line,
97390
- originalColumn: util.getArg(aArgs, "column", 0)
97391
- };
97392
-
97393
- needle.source = this._findSourceIndex(needle.source);
97394
- if (needle.source < 0) {
97395
- return [];
97396
- }
97397
-
97398
- if (needle.originalLine < 1) {
97399
- throw new Error("Line numbers must be >= 1");
97400
- }
97237
+ eachMapping(aCallback, aContext, aOrder) {
97238
+ this._sections.forEach((section, index) => {
97239
+ const nextSection =
97240
+ index + 1 < this._sections.length ? this._sections[index + 1] : null;
97241
+ const { generatedOffset } = section;
97401
97242
 
97402
- if (needle.originalColumn < 0) {
97403
- throw new Error("Column numbers must be >= 0");
97404
- }
97243
+ const lineShift = generatedOffset.generatedLine - 1;
97244
+ const columnShift = generatedOffset.generatedColumn - 1;
97405
97245
 
97406
- const mappings = [];
97246
+ section.consumer.eachMapping(
97247
+ function (mapping) {
97248
+ if (mapping.generatedLine === 1) {
97249
+ mapping.generatedColumn += columnShift;
97407
97250
 
97408
- let index = this._findMapping(needle,
97409
- this._originalMappings,
97410
- "originalLine",
97411
- "originalColumn",
97412
- util.compareByOriginalPositions,
97413
- binarySearch.LEAST_UPPER_BOUND);
97414
- if (index >= 0) {
97415
- let mapping = this._originalMappings[index];
97416
-
97417
- if (aArgs.column === undefined) {
97418
- const originalLine = mapping.originalLine;
97419
-
97420
- // Iterate until either we run out of mappings, or we run into
97421
- // a mapping for a different line than the one we found. Since
97422
- // mappings are sorted, this is guaranteed to find all mappings for
97423
- // the line we found.
97424
- while (mapping && mapping.originalLine === originalLine) {
97425
- let lastColumn = mapping.lastGeneratedColumn;
97426
- if (this._computedColumnSpans && lastColumn === null) {
97427
- lastColumn = Infinity;
97251
+ if (typeof mapping.lastGeneratedColumn === "number") {
97252
+ mapping.lastGeneratedColumn += columnShift;
97253
+ }
97428
97254
  }
97429
- mappings.push({
97430
- line: util.getArg(mapping, "generatedLine", null),
97431
- column: util.getArg(mapping, "generatedColumn", null),
97432
- lastColumn,
97433
- });
97434
97255
 
97435
- mapping = this._originalMappings[++index];
97436
- }
97437
- } else {
97438
- const originalColumn = mapping.originalColumn;
97439
-
97440
- // Iterate until either we run out of mappings, or we run into
97441
- // a mapping for a different line than the one we were searching for.
97442
- // Since mappings are sorted, this is guaranteed to find all mappings for
97443
- // the line we are searching for.
97444
- while (mapping &&
97445
- mapping.originalLine === line &&
97446
- mapping.originalColumn == originalColumn) {
97447
- let lastColumn = mapping.lastGeneratedColumn;
97448
- if (this._computedColumnSpans && lastColumn === null) {
97449
- lastColumn = Infinity;
97256
+ if (
97257
+ mapping.lastGeneratedColumn === Infinity &&
97258
+ nextSection &&
97259
+ mapping.generatedLine === nextSection.generatedOffset.generatedLine
97260
+ ) {
97261
+ mapping.lastGeneratedColumn =
97262
+ nextSection.generatedOffset.generatedColumn - 2;
97450
97263
  }
97451
- mappings.push({
97452
- line: util.getArg(mapping, "generatedLine", null),
97453
- column: util.getArg(mapping, "generatedColumn", null),
97454
- lastColumn,
97455
- });
97264
+ mapping.generatedLine += lineShift;
97456
97265
 
97457
- mapping = this._originalMappings[++index];
97458
- }
97459
- }
97460
- }
97266
+ aCallback.call(this, mapping);
97267
+ },
97268
+ aContext,
97269
+ aOrder
97270
+ );
97271
+ });
97272
+ }
97461
97273
 
97462
- return mappings;
97274
+ computeColumnSpans() {
97275
+ for (let i = 0; i < this._sections.length; i++) {
97276
+ this._sections[i].consumer.computeColumnSpans();
97277
+ }
97463
97278
  }
97464
97279
 
97465
97280
  destroy() {
@@ -97480,7 +97295,8 @@ function _factory(aSourceMap, aSourceMapURL) {
97480
97295
  sourceMap = util.parseSourceMapInput(aSourceMap);
97481
97296
  }
97482
97297
 
97483
- const consumer = sourceMap.sections != null
97298
+ const consumer =
97299
+ sourceMap.sections != null
97484
97300
  ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
97485
97301
  : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
97486
97302
  return Promise.resolve(consumer);
@@ -97542,14 +97358,14 @@ class SourceMapGenerator {
97542
97358
  const sourceRoot = aSourceMapConsumer.sourceRoot;
97543
97359
  const generator = new SourceMapGenerator({
97544
97360
  file: aSourceMapConsumer.file,
97545
- sourceRoot
97361
+ sourceRoot,
97546
97362
  });
97547
- aSourceMapConsumer.eachMapping(function(mapping) {
97363
+ aSourceMapConsumer.eachMapping(function (mapping) {
97548
97364
  const newMapping = {
97549
97365
  generated: {
97550
97366
  line: mapping.generatedLine,
97551
- column: mapping.generatedColumn
97552
- }
97367
+ column: mapping.generatedColumn,
97368
+ },
97553
97369
  };
97554
97370
 
97555
97371
  if (mapping.source != null) {
@@ -97560,7 +97376,7 @@ class SourceMapGenerator {
97560
97376
 
97561
97377
  newMapping.original = {
97562
97378
  line: mapping.originalLine,
97563
- column: mapping.originalColumn
97379
+ column: mapping.originalColumn,
97564
97380
  };
97565
97381
 
97566
97382
  if (mapping.name != null) {
@@ -97570,9 +97386,9 @@ class SourceMapGenerator {
97570
97386
 
97571
97387
  generator.addMapping(newMapping);
97572
97388
  });
97573
- aSourceMapConsumer.sources.forEach(function(sourceFile) {
97389
+ aSourceMapConsumer.sources.forEach(function (sourceFile) {
97574
97390
  let sourceRelative = sourceFile;
97575
- if (sourceRoot !== null) {
97391
+ if (sourceRoot != null) {
97576
97392
  sourceRelative = util.relative(sourceRoot, sourceFile);
97577
97393
  }
97578
97394
 
@@ -97625,10 +97441,10 @@ class SourceMapGenerator {
97625
97441
  this._mappings.add({
97626
97442
  generatedLine: generated.line,
97627
97443
  generatedColumn: generated.column,
97628
- originalLine: original != null && original.line,
97629
- originalColumn: original != null && original.column,
97444
+ originalLine: original && original.line,
97445
+ originalColumn: original && original.column,
97630
97446
  source,
97631
- name
97447
+ name,
97632
97448
  });
97633
97449
  }
97634
97450
 
@@ -97681,7 +97497,7 @@ class SourceMapGenerator {
97681
97497
  if (aSourceMapConsumer.file == null) {
97682
97498
  throw new Error(
97683
97499
  "SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, " +
97684
- 'or the source map\'s "file" property. Both were omitted.'
97500
+ 'or the source map\'s "file" property. Both were omitted.'
97685
97501
  );
97686
97502
  }
97687
97503
  sourceFile = aSourceMapConsumer.file;
@@ -97693,18 +97509,17 @@ class SourceMapGenerator {
97693
97509
  }
97694
97510
  // Applying the SourceMap can add and remove items from the sources and
97695
97511
  // the names array.
97696
- const newSources = this._mappings.toArray().length > 0
97697
- ? new ArraySet()
97698
- : this._sources;
97512
+ const newSources =
97513
+ this._mappings.toArray().length > 0 ? new ArraySet() : this._sources;
97699
97514
  const newNames = new ArraySet();
97700
97515
 
97701
97516
  // Find mappings for the "sourceFile"
97702
- this._mappings.unsortedForEach(function(mapping) {
97517
+ this._mappings.unsortedForEach(function (mapping) {
97703
97518
  if (mapping.source === sourceFile && mapping.originalLine != null) {
97704
97519
  // Check if it can be mapped by the source map, then update the mapping.
97705
97520
  const original = aSourceMapConsumer.originalPositionFor({
97706
97521
  line: mapping.originalLine,
97707
- column: mapping.originalColumn
97522
+ column: mapping.originalColumn,
97708
97523
  });
97709
97524
  if (original.source != null) {
97710
97525
  // Copy mapping
@@ -97732,13 +97547,12 @@ class SourceMapGenerator {
97732
97547
  if (name != null && !newNames.has(name)) {
97733
97548
  newNames.add(name);
97734
97549
  }
97735
-
97736
97550
  }, this);
97737
97551
  this._sources = newSources;
97738
97552
  this._names = newNames;
97739
97553
 
97740
97554
  // Copy sourcesContents of applied map.
97741
- aSourceMapConsumer.sources.forEach(function(srcFile) {
97555
+ aSourceMapConsumer.sources.forEach(function (srcFile) {
97742
97556
  const content = aSourceMapConsumer.sourceContentFor(srcFile);
97743
97557
  if (content != null) {
97744
97558
  if (aSourceMapPath != null) {
@@ -97768,33 +97582,53 @@ class SourceMapGenerator {
97768
97582
  // it is most likely a programmer error. In this case we throw a very
97769
97583
  // specific error message to try to guide them the right way.
97770
97584
  // For example: https://github.com/Polymer/polymer-bundler/pull/519
97771
- if (aOriginal && typeof aOriginal.line !== "number" && typeof aOriginal.column !== "number") {
97772
- throw new Error(
97773
- "original.line and original.column are not numbers -- you probably meant to omit " +
97774
- "the original mapping entirely and only map the generated position. If so, pass " +
97775
- "null for the original mapping instead of an object with empty or null values."
97776
- );
97585
+ if (
97586
+ aOriginal &&
97587
+ typeof aOriginal.line !== "number" &&
97588
+ typeof aOriginal.column !== "number"
97589
+ ) {
97590
+ throw new Error(
97591
+ "original.line and original.column are not numbers -- you probably meant to omit " +
97592
+ "the original mapping entirely and only map the generated position. If so, pass " +
97593
+ "null for the original mapping instead of an object with empty or null values."
97594
+ );
97777
97595
  }
97778
97596
 
97779
- if (aGenerated && "line" in aGenerated && "column" in aGenerated
97780
- && aGenerated.line > 0 && aGenerated.column >= 0
97781
- && !aOriginal && !aSource && !aName) {
97597
+ if (
97598
+ aGenerated &&
97599
+ "line" in aGenerated &&
97600
+ "column" in aGenerated &&
97601
+ aGenerated.line > 0 &&
97602
+ aGenerated.column >= 0 &&
97603
+ !aOriginal &&
97604
+ !aSource &&
97605
+ !aName
97606
+ ) {
97782
97607
  // Case 1.
97783
-
97784
- } else if (aGenerated && "line" in aGenerated && "column" in aGenerated
97785
- && aOriginal && "line" in aOriginal && "column" in aOriginal
97786
- && aGenerated.line > 0 && aGenerated.column >= 0
97787
- && aOriginal.line > 0 && aOriginal.column >= 0
97788
- && aSource) {
97608
+ } else if (
97609
+ aGenerated &&
97610
+ "line" in aGenerated &&
97611
+ "column" in aGenerated &&
97612
+ aOriginal &&
97613
+ "line" in aOriginal &&
97614
+ "column" in aOriginal &&
97615
+ aGenerated.line > 0 &&
97616
+ aGenerated.column >= 0 &&
97617
+ aOriginal.line > 0 &&
97618
+ aOriginal.column >= 0 &&
97619
+ aSource
97620
+ ) {
97789
97621
  // Cases 2 and 3.
97790
-
97791
97622
  } else {
97792
- throw new Error("Invalid mapping: " + JSON.stringify({
97793
- generated: aGenerated,
97794
- source: aSource,
97795
- original: aOriginal,
97796
- name: aName
97797
- }));
97623
+ throw new Error(
97624
+ "Invalid mapping: " +
97625
+ JSON.stringify({
97626
+ generated: aGenerated,
97627
+ source: aSource,
97628
+ original: aOriginal,
97629
+ name: aName,
97630
+ })
97631
+ );
97798
97632
  }
97799
97633
  }
97800
97634
 
@@ -97827,14 +97661,17 @@ class SourceMapGenerator {
97827
97661
  previousGeneratedLine++;
97828
97662
  }
97829
97663
  } else if (i > 0) {
97830
- if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
97664
+ if (
97665
+ !util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])
97666
+ ) {
97831
97667
  continue;
97832
97668
  }
97833
97669
  next += ",";
97834
97670
  }
97835
97671
 
97836
- next += base64VLQ.encode(mapping.generatedColumn
97837
- - previousGeneratedColumn);
97672
+ next += base64VLQ.encode(
97673
+ mapping.generatedColumn - previousGeneratedColumn
97674
+ );
97838
97675
  previousGeneratedColumn = mapping.generatedColumn;
97839
97676
 
97840
97677
  if (mapping.source != null) {
@@ -97843,12 +97680,14 @@ class SourceMapGenerator {
97843
97680
  previousSource = sourceIdx;
97844
97681
 
97845
97682
  // lines are stored 0-based in SourceMap spec version 3
97846
- next += base64VLQ.encode(mapping.originalLine - 1
97847
- - previousOriginalLine);
97683
+ next += base64VLQ.encode(
97684
+ mapping.originalLine - 1 - previousOriginalLine
97685
+ );
97848
97686
  previousOriginalLine = mapping.originalLine - 1;
97849
97687
 
97850
- next += base64VLQ.encode(mapping.originalColumn
97851
- - previousOriginalColumn);
97688
+ next += base64VLQ.encode(
97689
+ mapping.originalColumn - previousOriginalColumn
97690
+ );
97852
97691
  previousOriginalColumn = mapping.originalColumn;
97853
97692
 
97854
97693
  if (mapping.name != null) {
@@ -97865,7 +97704,7 @@ class SourceMapGenerator {
97865
97704
  }
97866
97705
 
97867
97706
  _generateSourcesContent(aSources, aSourceRoot) {
97868
- return aSources.map(function(source) {
97707
+ return aSources.map(function (source) {
97869
97708
  if (!this._sourcesContents) {
97870
97709
  return null;
97871
97710
  }
@@ -97887,7 +97726,7 @@ class SourceMapGenerator {
97887
97726
  version: this._version,
97888
97727
  sources: this._sources.toArray(),
97889
97728
  names: this._names.toArray(),
97890
- mappings: this._serializeMappings()
97729
+ mappings: this._serializeMappings(),
97891
97730
  };
97892
97731
  if (this._file != null) {
97893
97732
  map.file = this._file;
@@ -97896,7 +97735,10 @@ class SourceMapGenerator {
97896
97735
  map.sourceRoot = this._sourceRoot;
97897
97736
  }
97898
97737
  if (this._sourcesContents) {
97899
- map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
97738
+ map.sourcesContent = this._generateSourcesContent(
97739
+ map.sources,
97740
+ map.sourceRoot
97741
+ );
97900
97742
  }
97901
97743
 
97902
97744
  return map;
@@ -97976,7 +97818,11 @@ class SourceNode {
97976
97818
  * @param aRelativePath Optional. The path that relative sources in the
97977
97819
  * SourceMapConsumer should be relative to.
97978
97820
  */
97979
- static fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
97821
+ static fromStringWithSourceMap(
97822
+ aGeneratedCode,
97823
+ aSourceMapConsumer,
97824
+ aRelativePath
97825
+ ) {
97980
97826
  // The SourceNode we want to fill with the generated code
97981
97827
  // and the SourceMap
97982
97828
  const node = new SourceNode();
@@ -97987,20 +97833,22 @@ class SourceNode {
97987
97833
  // Processed fragments are accessed by calling `shiftNextLine`.
97988
97834
  const remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
97989
97835
  let remainingLinesIndex = 0;
97990
- const shiftNextLine = function() {
97836
+ const shiftNextLine = function () {
97991
97837
  const lineContents = getNextLine();
97992
97838
  // The last line of a file might not have a newline.
97993
97839
  const newLine = getNextLine() || "";
97994
97840
  return lineContents + newLine;
97995
97841
 
97996
97842
  function getNextLine() {
97997
- return remainingLinesIndex < remainingLines.length ?
97998
- remainingLines[remainingLinesIndex++] : undefined;
97843
+ return remainingLinesIndex < remainingLines.length
97844
+ ? remainingLines[remainingLinesIndex++]
97845
+ : undefined;
97999
97846
  }
98000
97847
  };
98001
97848
 
98002
97849
  // We need to remember the position of "remainingLines"
98003
- let lastGeneratedLine = 1, lastGeneratedColumn = 0;
97850
+ let lastGeneratedLine = 1,
97851
+ lastGeneratedColumn = 0;
98004
97852
 
98005
97853
  // The generate SourceNodes we need a code range.
98006
97854
  // To extract it current and last mapping is used.
@@ -98008,7 +97856,7 @@ class SourceNode {
98008
97856
  let lastMapping = null;
98009
97857
  let nextLine;
98010
97858
 
98011
- aSourceMapConsumer.eachMapping(function(mapping) {
97859
+ aSourceMapConsumer.eachMapping(function (mapping) {
98012
97860
  if (lastMapping !== null) {
98013
97861
  // We add the code from "lastMapping" to "mapping":
98014
97862
  // First check if there is a new line in between.
@@ -98023,10 +97871,13 @@ class SourceNode {
98023
97871
  // Associate the code between "lastGeneratedColumn" and
98024
97872
  // "mapping.generatedColumn" with "lastMapping"
98025
97873
  nextLine = remainingLines[remainingLinesIndex] || "";
98026
- const code = nextLine.substr(0, mapping.generatedColumn -
98027
- lastGeneratedColumn);
98028
- remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
98029
- lastGeneratedColumn);
97874
+ const code = nextLine.substr(
97875
+ 0,
97876
+ mapping.generatedColumn - lastGeneratedColumn
97877
+ );
97878
+ remainingLines[remainingLinesIndex] = nextLine.substr(
97879
+ mapping.generatedColumn - lastGeneratedColumn
97880
+ );
98030
97881
  lastGeneratedColumn = mapping.generatedColumn;
98031
97882
  addMappingWithCode(lastMapping, code);
98032
97883
  // No more remaining code, continue
@@ -98044,7 +97895,9 @@ class SourceNode {
98044
97895
  if (lastGeneratedColumn < mapping.generatedColumn) {
98045
97896
  nextLine = remainingLines[remainingLinesIndex] || "";
98046
97897
  node.add(nextLine.substr(0, mapping.generatedColumn));
98047
- remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
97898
+ remainingLines[remainingLinesIndex] = nextLine.substr(
97899
+ mapping.generatedColumn
97900
+ );
98048
97901
  lastGeneratedColumn = mapping.generatedColumn;
98049
97902
  }
98050
97903
  lastMapping = mapping;
@@ -98060,7 +97913,7 @@ class SourceNode {
98060
97913
  }
98061
97914
 
98062
97915
  // Copy sourcesContent into SourceNode
98063
- aSourceMapConsumer.sources.forEach(function(sourceFile) {
97916
+ aSourceMapConsumer.sources.forEach(function (sourceFile) {
98064
97917
  const content = aSourceMapConsumer.sourceContentFor(sourceFile);
98065
97918
  if (content != null) {
98066
97919
  if (aRelativePath != null) {
@@ -98079,11 +97932,15 @@ class SourceNode {
98079
97932
  const source = aRelativePath
98080
97933
  ? util.join(aRelativePath, mapping.source)
98081
97934
  : mapping.source;
98082
- node.add(new SourceNode(mapping.originalLine,
98083
- mapping.originalColumn,
98084
- source,
98085
- code,
98086
- mapping.name));
97935
+ node.add(
97936
+ new SourceNode(
97937
+ mapping.originalLine,
97938
+ mapping.originalColumn,
97939
+ source,
97940
+ code,
97941
+ mapping.name
97942
+ )
97943
+ );
98087
97944
  }
98088
97945
  }
98089
97946
  }
@@ -98096,7 +97953,7 @@ class SourceNode {
98096
97953
  */
98097
97954
  add(aChunk) {
98098
97955
  if (Array.isArray(aChunk)) {
98099
- aChunk.forEach(function(chunk) {
97956
+ aChunk.forEach(function (chunk) {
98100
97957
  this.add(chunk);
98101
97958
  }, this);
98102
97959
  } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
@@ -98105,7 +97962,8 @@ class SourceNode {
98105
97962
  }
98106
97963
  } else {
98107
97964
  throw new TypeError(
98108
- "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
97965
+ "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " +
97966
+ aChunk
98109
97967
  );
98110
97968
  }
98111
97969
  return this;
@@ -98126,7 +97984,8 @@ class SourceNode {
98126
97984
  this.children.unshift(aChunk);
98127
97985
  } else {
98128
97986
  throw new TypeError(
98129
- "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
97987
+ "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " +
97988
+ aChunk
98130
97989
  );
98131
97990
  }
98132
97991
  return this;
@@ -98146,10 +98005,12 @@ class SourceNode {
98146
98005
  if (chunk[isSourceNode]) {
98147
98006
  chunk.walk(aFn);
98148
98007
  } else if (chunk !== "") {
98149
- aFn(chunk, { source: this.source,
98150
- line: this.line,
98151
- column: this.column,
98152
- name: this.name });
98008
+ aFn(chunk, {
98009
+ source: this.source,
98010
+ line: this.line,
98011
+ column: this.column,
98012
+ name: this.name,
98013
+ });
98153
98014
  }
98154
98015
  }
98155
98016
  }
@@ -98188,7 +98049,10 @@ class SourceNode {
98188
98049
  if (lastChild[isSourceNode]) {
98189
98050
  lastChild.replaceRight(aPattern, aReplacement);
98190
98051
  } else if (typeof lastChild === "string") {
98191
- this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
98052
+ this.children[this.children.length - 1] = lastChild.replace(
98053
+ aPattern,
98054
+ aReplacement
98055
+ );
98192
98056
  } else {
98193
98057
  this.children.push("".replace(aPattern, aReplacement));
98194
98058
  }
@@ -98231,7 +98095,7 @@ class SourceNode {
98231
98095
  */
98232
98096
  toString() {
98233
98097
  let str = "";
98234
- this.walk(function(chunk) {
98098
+ this.walk(function (chunk) {
98235
98099
  str += chunk;
98236
98100
  });
98237
98101
  return str;
@@ -98245,7 +98109,7 @@ class SourceNode {
98245
98109
  const generated = {
98246
98110
  code: "",
98247
98111
  line: 1,
98248
- column: 0
98112
+ column: 0,
98249
98113
  };
98250
98114
  const map = new SourceMapGenerator(aArgs);
98251
98115
  let sourceMappingActive = false;
@@ -98253,26 +98117,30 @@ class SourceNode {
98253
98117
  let lastOriginalLine = null;
98254
98118
  let lastOriginalColumn = null;
98255
98119
  let lastOriginalName = null;
98256
- this.walk(function(chunk, original) {
98120
+ this.walk(function (chunk, original) {
98257
98121
  generated.code += chunk;
98258
- if (original.source !== null
98259
- && original.line !== null
98260
- && original.column !== null) {
98261
- if (lastOriginalSource !== original.source
98262
- || lastOriginalLine !== original.line
98263
- || lastOriginalColumn !== original.column
98264
- || lastOriginalName !== original.name) {
98122
+ if (
98123
+ original.source !== null &&
98124
+ original.line !== null &&
98125
+ original.column !== null
98126
+ ) {
98127
+ if (
98128
+ lastOriginalSource !== original.source ||
98129
+ lastOriginalLine !== original.line ||
98130
+ lastOriginalColumn !== original.column ||
98131
+ lastOriginalName !== original.name
98132
+ ) {
98265
98133
  map.addMapping({
98266
98134
  source: original.source,
98267
98135
  original: {
98268
98136
  line: original.line,
98269
- column: original.column
98137
+ column: original.column,
98270
98138
  },
98271
98139
  generated: {
98272
98140
  line: generated.line,
98273
- column: generated.column
98141
+ column: generated.column,
98274
98142
  },
98275
- name: original.name
98143
+ name: original.name,
98276
98144
  });
98277
98145
  }
98278
98146
  lastOriginalSource = original.source;
@@ -98284,8 +98152,8 @@ class SourceNode {
98284
98152
  map.addMapping({
98285
98153
  generated: {
98286
98154
  line: generated.line,
98287
- column: generated.column
98288
- }
98155
+ column: generated.column,
98156
+ },
98289
98157
  });
98290
98158
  lastOriginalSource = null;
98291
98159
  sourceMappingActive = false;
@@ -98303,13 +98171,13 @@ class SourceNode {
98303
98171
  source: original.source,
98304
98172
  original: {
98305
98173
  line: original.line,
98306
- column: original.column
98174
+ column: original.column,
98307
98175
  },
98308
98176
  generated: {
98309
98177
  line: generated.line,
98310
- column: generated.column
98178
+ column: generated.column,
98311
98179
  },
98312
- name: original.name
98180
+ name: original.name,
98313
98181
  });
98314
98182
  }
98315
98183
  } else {
@@ -98317,7 +98185,7 @@ class SourceNode {
98317
98185
  }
98318
98186
  }
98319
98187
  });
98320
- this.walkSourceContents(function(sourceFile, sourceContent) {
98188
+ this.walkSourceContents(function (sourceFile, sourceContent) {
98321
98189
  map.setSourceContent(sourceFile, sourceContent);
98322
98190
  });
98323
98191
 
@@ -98328,301 +98196,71 @@ class SourceNode {
98328
98196
  exports.SourceNode = SourceNode;
98329
98197
 
98330
98198
 
98331
- /***/ }),
98332
-
98333
- /***/ "./node_modules/source-map/lib/util.js":
98334
- /*!*********************************************!*\
98335
- !*** ./node_modules/source-map/lib/util.js ***!
98336
- \*********************************************/
98337
- /***/ ((__unused_webpack_module, exports) => {
98338
-
98339
- /* -*- Mode: js; js-indent-level: 2; -*- */
98340
- /*
98341
- * Copyright 2011 Mozilla Foundation and contributors
98342
- * Licensed under the New BSD license. See LICENSE or:
98343
- * http://opensource.org/licenses/BSD-3-Clause
98344
- */
98345
-
98346
- /**
98347
- * This is a helper function for getting values from parameter/options
98348
- * objects.
98349
- *
98350
- * @param args The object we are extracting values from
98351
- * @param name The name of the property we are getting.
98352
- * @param defaultValue An optional value to return if the property is missing
98353
- * from the object. If this is not specified and the property is missing, an
98354
- * error will be thrown.
98355
- */
98356
- function getArg(aArgs, aName, aDefaultValue) {
98357
- if (aName in aArgs) {
98358
- return aArgs[aName];
98359
- } else if (arguments.length === 3) {
98360
- return aDefaultValue;
98361
- }
98362
- throw new Error('"' + aName + '" is a required argument.');
98363
-
98364
- }
98365
- exports.getArg = getArg;
98366
-
98367
- const urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
98368
- const dataUrlRegexp = /^data:.+\,.+$/;
98369
-
98370
- function urlParse(aUrl) {
98371
- const match = aUrl.match(urlRegexp);
98372
- if (!match) {
98373
- return null;
98374
- }
98375
- return {
98376
- scheme: match[1],
98377
- auth: match[2],
98378
- host: match[3],
98379
- port: match[4],
98380
- path: match[5]
98381
- };
98382
- }
98383
- exports.urlParse = urlParse;
98384
-
98385
- function urlGenerate(aParsedUrl) {
98386
- let url = "";
98387
- if (aParsedUrl.scheme) {
98388
- url += aParsedUrl.scheme + ":";
98389
- }
98390
- url += "//";
98391
- if (aParsedUrl.auth) {
98392
- url += aParsedUrl.auth + "@";
98393
- }
98394
- if (aParsedUrl.host) {
98395
- url += aParsedUrl.host;
98396
- }
98397
- if (aParsedUrl.port) {
98398
- url += ":" + aParsedUrl.port;
98399
- }
98400
- if (aParsedUrl.path) {
98401
- url += aParsedUrl.path;
98402
- }
98403
- return url;
98404
- }
98405
- exports.urlGenerate = urlGenerate;
98406
-
98407
- const MAX_CACHED_INPUTS = 32;
98408
-
98409
- /**
98410
- * Takes some function `f(input) -> result` and returns a memoized version of
98411
- * `f`.
98412
- *
98413
- * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
98414
- * memoization is a dumb-simple, linear least-recently-used cache.
98415
- */
98416
- function lruMemoize(f) {
98417
- const cache = [];
98418
-
98419
- return function(input) {
98420
- for (let i = 0; i < cache.length; i++) {
98421
- if (cache[i].input === input) {
98422
- const temp = cache[0];
98423
- cache[0] = cache[i];
98424
- cache[i] = temp;
98425
- return cache[0].result;
98426
- }
98427
- }
98428
-
98429
- const result = f(input);
98430
-
98431
- cache.unshift({
98432
- input,
98433
- result,
98434
- });
98435
-
98436
- if (cache.length > MAX_CACHED_INPUTS) {
98437
- cache.pop();
98438
- }
98439
-
98440
- return result;
98441
- };
98442
- }
98443
-
98444
- /**
98445
- * Normalizes a path, or the path portion of a URL:
98446
- *
98447
- * - Replaces consecutive slashes with one slash.
98448
- * - Removes unnecessary '.' parts.
98449
- * - Removes unnecessary '<dir>/..' parts.
98450
- *
98451
- * Based on code in the Node.js 'path' core module.
98452
- *
98453
- * @param aPath The path or url to normalize.
98454
- */
98455
- const normalize = lruMemoize(function normalize(aPath) {
98456
- let path = aPath;
98457
- const url = urlParse(aPath);
98458
- if (url) {
98459
- if (!url.path) {
98460
- return aPath;
98461
- }
98462
- path = url.path;
98463
- }
98464
- const isAbsolute = exports.isAbsolute(path);
98465
-
98466
- // Split the path into parts between `/` characters. This is much faster than
98467
- // using `.split(/\/+/g)`.
98468
- const parts = [];
98469
- let start = 0;
98470
- let i = 0;
98471
- while (true) {
98472
- start = i;
98473
- i = path.indexOf("/", start);
98474
- if (i === -1) {
98475
- parts.push(path.slice(start));
98476
- break;
98477
- } else {
98478
- parts.push(path.slice(start, i));
98479
- while (i < path.length && path[i] === "/") {
98480
- i++;
98481
- }
98482
- }
98483
- }
98484
-
98485
- let up = 0;
98486
- for (i = parts.length - 1; i >= 0; i--) {
98487
- const part = parts[i];
98488
- if (part === ".") {
98489
- parts.splice(i, 1);
98490
- } else if (part === "..") {
98491
- up++;
98492
- } else if (up > 0) {
98493
- if (part === "") {
98494
- // The first part is blank if the path is absolute. Trying to go
98495
- // above the root is a no-op. Therefore we can remove all '..' parts
98496
- // directly after the root.
98497
- parts.splice(i + 1, up);
98498
- up = 0;
98499
- } else {
98500
- parts.splice(i, 2);
98501
- up--;
98502
- }
98503
- }
98504
- }
98505
- path = parts.join("/");
98506
-
98507
- if (path === "") {
98508
- path = isAbsolute ? "/" : ".";
98509
- }
98510
-
98511
- if (url) {
98512
- url.path = path;
98513
- return urlGenerate(url);
98514
- }
98515
- return path;
98516
- });
98517
- exports.normalize = normalize;
98518
-
98519
- /**
98520
- * Joins two paths/URLs.
98521
- *
98522
- * @param aRoot The root path or URL.
98523
- * @param aPath The path or URL to be joined with the root.
98524
- *
98525
- * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
98526
- * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
98527
- * first.
98528
- * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
98529
- * is updated with the result and aRoot is returned. Otherwise the result
98530
- * is returned.
98531
- * - If aPath is absolute, the result is aPath.
98532
- * - Otherwise the two paths are joined with a slash.
98533
- * - Joining for example 'http://' and 'www.example.com' is also supported.
98534
- */
98535
- function join(aRoot, aPath) {
98536
- if (aRoot === "") {
98537
- aRoot = ".";
98538
- }
98539
- if (aPath === "") {
98540
- aPath = ".";
98541
- }
98542
- const aPathUrl = urlParse(aPath);
98543
- const aRootUrl = urlParse(aRoot);
98544
- if (aRootUrl) {
98545
- aRoot = aRootUrl.path || "/";
98546
- }
98547
-
98548
- // `join(foo, '//www.example.org')`
98549
- if (aPathUrl && !aPathUrl.scheme) {
98550
- if (aRootUrl) {
98551
- aPathUrl.scheme = aRootUrl.scheme;
98552
- }
98553
- return urlGenerate(aPathUrl);
98554
- }
98199
+ /***/ }),
98555
98200
 
98556
- if (aPathUrl || aPath.match(dataUrlRegexp)) {
98557
- return aPath;
98558
- }
98201
+ /***/ "./node_modules/source-map/lib/url.js":
98202
+ /*!********************************************!*\
98203
+ !*** ./node_modules/source-map/lib/url.js ***!
98204
+ \********************************************/
98205
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
98559
98206
 
98560
- // `join('http://', 'www.example.com')`
98561
- if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
98562
- aRootUrl.host = aPath;
98563
- return urlGenerate(aRootUrl);
98564
- }
98207
+ "use strict";
98208
+ /* -*- Mode: js; js-indent-level: 2; -*- */
98209
+ /*
98210
+ * Copyright 2011 Mozilla Foundation and contributors
98211
+ * Licensed under the New BSD license. See LICENSE or:
98212
+ * http://opensource.org/licenses/BSD-3-Clause
98213
+ */
98565
98214
 
98566
- const joined = aPath.charAt(0) === "/"
98567
- ? aPath
98568
- : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath);
98569
98215
 
98570
- if (aRootUrl) {
98571
- aRootUrl.path = joined;
98572
- return urlGenerate(aRootUrl);
98573
- }
98574
- return joined;
98575
- }
98576
- exports.join = join;
98216
+ // Note: This file is overridden in the 'package.json#browser' field to
98217
+ // substitute lib/url-browser.js instead.
98577
98218
 
98578
- exports.isAbsolute = function(aPath) {
98579
- return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
98580
- };
98219
+ // Use the URL global for Node 10, and the 'url' module for Node 8.
98220
+ module.exports = typeof URL === "function" ? URL : (__webpack_require__(/*! url */ "url").URL);
98581
98221
 
98582
- /**
98583
- * Make a path relative to a URL or another path.
98584
- *
98585
- * @param aRoot The root path or URL.
98586
- * @param aPath The path or URL to be made relative to aRoot.
98587
- */
98588
- function relative(aRoot, aPath) {
98589
- if (aRoot === "") {
98590
- aRoot = ".";
98591
- }
98592
98222
 
98593
- aRoot = aRoot.replace(/\/$/, "");
98223
+ /***/ }),
98594
98224
 
98595
- // It is possible for the path to be above the root. In this case, simply
98596
- // checking whether the root is a prefix of the path won't work. Instead, we
98597
- // need to remove components from the root one by one, until either we find
98598
- // a prefix that fits, or we run out of components to remove.
98599
- let level = 0;
98600
- while (aPath.indexOf(aRoot + "/") !== 0) {
98601
- const index = aRoot.lastIndexOf("/");
98602
- if (index < 0) {
98603
- return aPath;
98604
- }
98225
+ /***/ "./node_modules/source-map/lib/util.js":
98226
+ /*!*********************************************!*\
98227
+ !*** ./node_modules/source-map/lib/util.js ***!
98228
+ \*********************************************/
98229
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
98605
98230
 
98606
- // If the only part of the root that is left is the scheme (i.e. http://,
98607
- // file:///, etc.), one or more slashes (/), or simply nothing at all, we
98608
- // have exhausted all components, so the path is not relative to the root.
98609
- aRoot = aRoot.slice(0, index);
98610
- if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
98611
- return aPath;
98612
- }
98231
+ /* -*- Mode: js; js-indent-level: 2; -*- */
98232
+ /*
98233
+ * Copyright 2011 Mozilla Foundation and contributors
98234
+ * Licensed under the New BSD license. See LICENSE or:
98235
+ * http://opensource.org/licenses/BSD-3-Clause
98236
+ */
98613
98237
 
98614
- ++level;
98615
- }
98238
+ const URL = __webpack_require__(/*! ./url */ "./node_modules/source-map/lib/url.js");
98616
98239
 
98617
- // Make sure we add a "../" for each component we removed from the root.
98618
- return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
98240
+ /**
98241
+ * This is a helper function for getting values from parameter/options
98242
+ * objects.
98243
+ *
98244
+ * @param args The object we are extracting values from
98245
+ * @param name The name of the property we are getting.
98246
+ * @param defaultValue An optional value to return if the property is missing
98247
+ * from the object. If this is not specified and the property is missing, an
98248
+ * error will be thrown.
98249
+ */
98250
+ function getArg(aArgs, aName, aDefaultValue) {
98251
+ if (aName in aArgs) {
98252
+ return aArgs[aName];
98253
+ } else if (arguments.length === 3) {
98254
+ return aDefaultValue;
98255
+ }
98256
+ throw new Error('"' + aName + '" is a required argument.');
98619
98257
  }
98620
- exports.relative = relative;
98258
+ exports.getArg = getArg;
98621
98259
 
98622
- const supportsNullProto = (function() {
98260
+ const supportsNullProto = (function () {
98623
98261
  const obj = Object.create(null);
98624
98262
  return !("__proto__" in obj);
98625
- }());
98263
+ })();
98626
98264
 
98627
98265
  function identity(s) {
98628
98266
  return s;
@@ -98667,15 +98305,17 @@ function isProtoString(s) {
98667
98305
  }
98668
98306
 
98669
98307
  /* eslint-disable no-multi-spaces */
98670
- if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
98671
- s.charCodeAt(length - 2) !== 95 /* '_' */ ||
98672
- s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
98673
- s.charCodeAt(length - 4) !== 116 /* 't' */ ||
98674
- s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
98675
- s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
98676
- s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
98677
- s.charCodeAt(length - 8) !== 95 /* '_' */ ||
98678
- s.charCodeAt(length - 9) !== 95 /* '_' */) {
98308
+ if (
98309
+ s.charCodeAt(length - 1) !== 95 /* '_' */ ||
98310
+ s.charCodeAt(length - 2) !== 95 /* '_' */ ||
98311
+ s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
98312
+ s.charCodeAt(length - 4) !== 116 /* 't' */ ||
98313
+ s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
98314
+ s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
98315
+ s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
98316
+ s.charCodeAt(length - 8) !== 95 /* '_' */ ||
98317
+ s.charCodeAt(length - 9) !== 95 /* '_' */
98318
+ ) {
98679
98319
  return false;
98680
98320
  }
98681
98321
  /* eslint-enable no-multi-spaces */
@@ -98689,61 +98329,38 @@ function isProtoString(s) {
98689
98329
  return true;
98690
98330
  }
98691
98331
 
98692
- /**
98693
- * Comparator between two mappings where the original positions are compared.
98694
- *
98695
- * Optionally pass in `true` as `onlyCompareGenerated` to consider two
98696
- * mappings with the same original source/line/column, but different generated
98697
- * line and column the same. Useful when searching for a mapping with a
98698
- * stubbed out mapping.
98699
- */
98700
- function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
98701
- let cmp = strcmp(mappingA.source, mappingB.source);
98702
- if (cmp !== 0) {
98703
- return cmp;
98704
- }
98705
-
98706
- cmp = mappingA.originalLine - mappingB.originalLine;
98707
- if (cmp !== 0) {
98708
- return cmp;
98332
+ function strcmp(aStr1, aStr2) {
98333
+ if (aStr1 === aStr2) {
98334
+ return 0;
98709
98335
  }
98710
98336
 
98711
- cmp = mappingA.originalColumn - mappingB.originalColumn;
98712
- if (cmp !== 0 || onlyCompareOriginal) {
98713
- return cmp;
98337
+ if (aStr1 === null) {
98338
+ return 1; // aStr2 !== null
98714
98339
  }
98715
98340
 
98716
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
98717
- if (cmp !== 0) {
98718
- return cmp;
98341
+ if (aStr2 === null) {
98342
+ return -1; // aStr1 !== null
98719
98343
  }
98720
98344
 
98721
- cmp = mappingA.generatedLine - mappingB.generatedLine;
98722
- if (cmp !== 0) {
98723
- return cmp;
98345
+ if (aStr1 > aStr2) {
98346
+ return 1;
98724
98347
  }
98725
98348
 
98726
- return strcmp(mappingA.name, mappingB.name);
98349
+ return -1;
98727
98350
  }
98728
- exports.compareByOriginalPositions = compareByOriginalPositions;
98729
98351
 
98730
98352
  /**
98731
- * Comparator between two mappings with deflated source and name indices where
98353
+ * Comparator between two mappings with inflated source and name strings where
98732
98354
  * the generated positions are compared.
98733
- *
98734
- * Optionally pass in `true` as `onlyCompareGenerated` to consider two
98735
- * mappings with the same generated line and column, but different
98736
- * source/name/original line and column the same. Useful when searching for a
98737
- * mapping with a stubbed out mapping.
98738
98355
  */
98739
- function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
98356
+ function compareByGeneratedPositionsInflated(mappingA, mappingB) {
98740
98357
  let cmp = mappingA.generatedLine - mappingB.generatedLine;
98741
98358
  if (cmp !== 0) {
98742
98359
  return cmp;
98743
98360
  }
98744
98361
 
98745
98362
  cmp = mappingA.generatedColumn - mappingB.generatedColumn;
98746
- if (cmp !== 0 || onlyCompareGenerated) {
98363
+ if (cmp !== 0) {
98747
98364
  return cmp;
98748
98365
  }
98749
98366
 
@@ -98764,122 +98381,295 @@ function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGene
98764
98381
 
98765
98382
  return strcmp(mappingA.name, mappingB.name);
98766
98383
  }
98767
- exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
98384
+ exports.compareByGeneratedPositionsInflated =
98385
+ compareByGeneratedPositionsInflated;
98768
98386
 
98769
- function strcmp(aStr1, aStr2) {
98770
- if (aStr1 === aStr2) {
98771
- return 0;
98772
- }
98387
+ /**
98388
+ * Strip any JSON XSSI avoidance prefix from the string (as documented
98389
+ * in the source maps specification), and then parse the string as
98390
+ * JSON.
98391
+ */
98392
+ function parseSourceMapInput(str) {
98393
+ return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
98394
+ }
98395
+ exports.parseSourceMapInput = parseSourceMapInput;
98773
98396
 
98774
- if (aStr1 === null) {
98775
- return 1; // aStr2 !== null
98776
- }
98397
+ // We use 'http' as the base here because we want URLs processed relative
98398
+ // to the safe base to be treated as "special" URLs during parsing using
98399
+ // the WHATWG URL parsing. This ensures that backslash normalization
98400
+ // applies to the path and such.
98401
+ const PROTOCOL = "http:";
98402
+ const PROTOCOL_AND_HOST = `${PROTOCOL}//host`;
98777
98403
 
98778
- if (aStr2 === null) {
98779
- return -1; // aStr1 !== null
98404
+ /**
98405
+ * Make it easy to create small utilities that tweak a URL's path.
98406
+ */
98407
+ function createSafeHandler(cb) {
98408
+ return input => {
98409
+ const type = getURLType(input);
98410
+ const base = buildSafeBase(input);
98411
+ const url = new URL(input, base);
98412
+
98413
+ cb(url);
98414
+
98415
+ const result = url.toString();
98416
+
98417
+ if (type === "absolute") {
98418
+ return result;
98419
+ } else if (type === "scheme-relative") {
98420
+ return result.slice(PROTOCOL.length);
98421
+ } else if (type === "path-absolute") {
98422
+ return result.slice(PROTOCOL_AND_HOST.length);
98423
+ }
98424
+
98425
+ // This assumes that the callback will only change
98426
+ // the path, search and hash values.
98427
+ return computeRelativeURL(base, result);
98428
+ };
98429
+ }
98430
+
98431
+ function withBase(url, base) {
98432
+ return new URL(url, base).toString();
98433
+ }
98434
+
98435
+ function buildUniqueSegment(prefix, str) {
98436
+ let id = 0;
98437
+ do {
98438
+ const ident = prefix + id++;
98439
+ if (str.indexOf(ident) === -1) return ident;
98440
+ } while (true);
98441
+ }
98442
+
98443
+ function buildSafeBase(str) {
98444
+ const maxDotParts = str.split("..").length - 1;
98445
+
98446
+ // If we used a segment that also existed in `str`, then we would be unable
98447
+ // to compute relative paths. For example, if `segment` were just "a":
98448
+ //
98449
+ // const url = "../../a/"
98450
+ // const base = buildSafeBase(url); // http://host/a/a/
98451
+ // const joined = "http://host/a/";
98452
+ // const result = relative(base, joined);
98453
+ //
98454
+ // Expected: "../../a/";
98455
+ // Actual: "a/"
98456
+ //
98457
+ const segment = buildUniqueSegment("p", str);
98458
+
98459
+ let base = `${PROTOCOL_AND_HOST}/`;
98460
+ for (let i = 0; i < maxDotParts; i++) {
98461
+ base += `${segment}/`;
98780
98462
  }
98463
+ return base;
98464
+ }
98781
98465
 
98782
- if (aStr1 > aStr2) {
98783
- return 1;
98466
+ const ABSOLUTE_SCHEME = /^[A-Za-z0-9\+\-\.]+:/;
98467
+ function getURLType(url) {
98468
+ if (url[0] === "/") {
98469
+ if (url[1] === "/") return "scheme-relative";
98470
+ return "path-absolute";
98784
98471
  }
98785
98472
 
98786
- return -1;
98473
+ return ABSOLUTE_SCHEME.test(url) ? "absolute" : "path-relative";
98787
98474
  }
98788
98475
 
98789
98476
  /**
98790
- * Comparator between two mappings with inflated source and name strings where
98791
- * the generated positions are compared.
98477
+ * Given two URLs that are assumed to be on the same
98478
+ * protocol/host/user/password build a relative URL from the
98479
+ * path, params, and hash values.
98480
+ *
98481
+ * @param rootURL The root URL that the target will be relative to.
98482
+ * @param targetURL The target that the relative URL points to.
98483
+ * @return A rootURL-relative, normalized URL value.
98792
98484
  */
98793
- function compareByGeneratedPositionsInflated(mappingA, mappingB) {
98794
- let cmp = mappingA.generatedLine - mappingB.generatedLine;
98795
- if (cmp !== 0) {
98796
- return cmp;
98485
+ function computeRelativeURL(rootURL, targetURL) {
98486
+ if (typeof rootURL === "string") rootURL = new URL(rootURL);
98487
+ if (typeof targetURL === "string") targetURL = new URL(targetURL);
98488
+
98489
+ const targetParts = targetURL.pathname.split("/");
98490
+ const rootParts = rootURL.pathname.split("/");
98491
+
98492
+ // If we've got a URL path ending with a "/", we remove it since we'd
98493
+ // otherwise be relative to the wrong location.
98494
+ if (rootParts.length > 0 && !rootParts[rootParts.length - 1]) {
98495
+ rootParts.pop();
98797
98496
  }
98798
98497
 
98799
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
98800
- if (cmp !== 0) {
98801
- return cmp;
98498
+ while (
98499
+ targetParts.length > 0 &&
98500
+ rootParts.length > 0 &&
98501
+ targetParts[0] === rootParts[0]
98502
+ ) {
98503
+ targetParts.shift();
98504
+ rootParts.shift();
98802
98505
  }
98803
98506
 
98804
- cmp = strcmp(mappingA.source, mappingB.source);
98805
- if (cmp !== 0) {
98806
- return cmp;
98507
+ const relativePath = rootParts
98508
+ .map(() => "..")
98509
+ .concat(targetParts)
98510
+ .join("/");
98511
+
98512
+ return relativePath + targetURL.search + targetURL.hash;
98513
+ }
98514
+
98515
+ /**
98516
+ * Given a URL, ensure that it is treated as a directory URL.
98517
+ *
98518
+ * @param url
98519
+ * @return A normalized URL value.
98520
+ */
98521
+ const ensureDirectory = createSafeHandler(url => {
98522
+ url.pathname = url.pathname.replace(/\/?$/, "/");
98523
+ });
98524
+
98525
+ /**
98526
+ * Given a URL, strip off any filename if one is present.
98527
+ *
98528
+ * @param url
98529
+ * @return A normalized URL value.
98530
+ */
98531
+ const trimFilename = createSafeHandler(url => {
98532
+ url.href = new URL(".", url.toString()).toString();
98533
+ });
98534
+
98535
+ /**
98536
+ * Normalize a given URL.
98537
+ * * Convert backslashes.
98538
+ * * Remove any ".." and "." segments.
98539
+ *
98540
+ * @param url
98541
+ * @return A normalized URL value.
98542
+ */
98543
+ const normalize = createSafeHandler(url => {});
98544
+ exports.normalize = normalize;
98545
+
98546
+ /**
98547
+ * Joins two paths/URLs.
98548
+ *
98549
+ * All returned URLs will be normalized.
98550
+ *
98551
+ * @param aRoot The root path or URL. Assumed to reference a directory.
98552
+ * @param aPath The path or URL to be joined with the root.
98553
+ * @return A joined and normalized URL value.
98554
+ */
98555
+ function join(aRoot, aPath) {
98556
+ const pathType = getURLType(aPath);
98557
+ const rootType = getURLType(aRoot);
98558
+
98559
+ aRoot = ensureDirectory(aRoot);
98560
+
98561
+ if (pathType === "absolute") {
98562
+ return withBase(aPath, undefined);
98563
+ }
98564
+ if (rootType === "absolute") {
98565
+ return withBase(aPath, aRoot);
98807
98566
  }
98808
98567
 
98809
- cmp = mappingA.originalLine - mappingB.originalLine;
98810
- if (cmp !== 0) {
98811
- return cmp;
98568
+ if (pathType === "scheme-relative") {
98569
+ return normalize(aPath);
98570
+ }
98571
+ if (rootType === "scheme-relative") {
98572
+ return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(
98573
+ PROTOCOL.length
98574
+ );
98812
98575
  }
98813
98576
 
98814
- cmp = mappingA.originalColumn - mappingB.originalColumn;
98815
- if (cmp !== 0) {
98816
- return cmp;
98577
+ if (pathType === "path-absolute") {
98578
+ return normalize(aPath);
98579
+ }
98580
+ if (rootType === "path-absolute") {
98581
+ return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(
98582
+ PROTOCOL_AND_HOST.length
98583
+ );
98817
98584
  }
98818
98585
 
98819
- return strcmp(mappingA.name, mappingB.name);
98586
+ const base = buildSafeBase(aPath + aRoot);
98587
+ const newPath = withBase(aPath, withBase(aRoot, base));
98588
+ return computeRelativeURL(base, newPath);
98820
98589
  }
98821
- exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
98590
+ exports.join = join;
98822
98591
 
98823
98592
  /**
98824
- * Strip any JSON XSSI avoidance prefix from the string (as documented
98825
- * in the source maps specification), and then parse the string as
98826
- * JSON.
98593
+ * Make a path relative to a URL or another path. If returning a
98594
+ * relative URL is not possible, the original target will be returned.
98595
+ * All returned URLs will be normalized.
98596
+ *
98597
+ * @param aRoot The root path or URL.
98598
+ * @param aPath The path or URL to be made relative to aRoot.
98599
+ * @return A rootURL-relative (if possible), normalized URL value.
98827
98600
  */
98828
- function parseSourceMapInput(str) {
98829
- return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
98601
+ function relative(rootURL, targetURL) {
98602
+ const result = relativeIfPossible(rootURL, targetURL);
98603
+
98604
+ return typeof result === "string" ? result : normalize(targetURL);
98605
+ }
98606
+ exports.relative = relative;
98607
+
98608
+ function relativeIfPossible(rootURL, targetURL) {
98609
+ const urlType = getURLType(rootURL);
98610
+ if (urlType !== getURLType(targetURL)) {
98611
+ return null;
98612
+ }
98613
+
98614
+ const base = buildSafeBase(rootURL + targetURL);
98615
+ const root = new URL(rootURL, base);
98616
+ const target = new URL(targetURL, base);
98617
+
98618
+ try {
98619
+ new URL("", target.toString());
98620
+ } catch (err) {
98621
+ // Bail if the URL doesn't support things being relative to it,
98622
+ // For example, data: and blob: URLs.
98623
+ return null;
98624
+ }
98625
+
98626
+ if (
98627
+ target.protocol !== root.protocol ||
98628
+ target.user !== root.user ||
98629
+ target.password !== root.password ||
98630
+ target.hostname !== root.hostname ||
98631
+ target.port !== root.port
98632
+ ) {
98633
+ return null;
98634
+ }
98635
+
98636
+ return computeRelativeURL(root, target);
98830
98637
  }
98831
- exports.parseSourceMapInput = parseSourceMapInput;
98832
98638
 
98833
98639
  /**
98834
98640
  * Compute the URL of a source given the the source root, the source's
98835
98641
  * URL, and the source map's URL.
98836
98642
  */
98837
98643
  function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
98838
- sourceURL = sourceURL || "";
98839
-
98840
- if (sourceRoot) {
98841
- // This follows what Chrome does.
98842
- if (sourceRoot[sourceRoot.length - 1] !== "/" && sourceURL[0] !== "/") {
98843
- sourceRoot += "/";
98844
- }
98845
- // The spec says:
98846
- // Line 4: An optional source root, useful for relocating source
98847
- // files on a server or removing repeated values in the
98848
- // “sources” entry. This value is prepended to the individual
98849
- // entries in the “source” field.
98850
- sourceURL = sourceRoot + sourceURL;
98851
- }
98852
-
98853
- // Historically, SourceMapConsumer did not take the sourceMapURL as
98854
- // a parameter. This mode is still somewhat supported, which is why
98855
- // this code block is conditional. However, it's preferable to pass
98856
- // the source map URL to SourceMapConsumer, so that this function
98857
- // can implement the source URL resolution algorithm as outlined in
98858
- // the spec. This block is basically the equivalent of:
98859
- // new URL(sourceURL, sourceMapURL).toString()
98860
- // ... except it avoids using URL, which wasn't available in the
98861
- // older releases of node still supported by this library.
98644
+ // The source map spec states that "sourceRoot" and "sources" entries are to be appended. While
98645
+ // that is a little vague, implementations have generally interpreted that as joining the
98646
+ // URLs with a `/` between then, assuming the "sourceRoot" doesn't already end with one.
98647
+ // For example,
98862
98648
  //
98863
- // The spec says:
98864
- // If the sources are not absolute URLs after prepending of the
98865
- // “sourceRoot”, the sources are resolved relative to the
98866
- // SourceMap (like resolving script src in a html document).
98867
- if (sourceMapURL) {
98868
- const parsed = urlParse(sourceMapURL);
98869
- if (!parsed) {
98870
- throw new Error("sourceMapURL could not be parsed");
98871
- }
98872
- if (parsed.path) {
98873
- // Strip the last path component, but keep the "/".
98874
- const index = parsed.path.lastIndexOf("/");
98875
- if (index >= 0) {
98876
- parsed.path = parsed.path.substring(0, index + 1);
98877
- }
98878
- }
98879
- sourceURL = join(urlGenerate(parsed), sourceURL);
98649
+ // sourceRoot: "some-dir",
98650
+ // sources: ["/some-path.js"]
98651
+ //
98652
+ // and
98653
+ //
98654
+ // sourceRoot: "some-dir/",
98655
+ // sources: ["/some-path.js"]
98656
+ //
98657
+ // must behave as "some-dir/some-path.js".
98658
+ //
98659
+ // With this library's the transition to a more URL-focused implementation, that behavior is
98660
+ // preserved here. To acheive that, we trim the "/" from absolute-path when a sourceRoot value
98661
+ // is present in order to make the sources entries behave as if they are relative to the
98662
+ // "sourceRoot", as they would have if the two strings were simply concated.
98663
+ if (sourceRoot && getURLType(sourceURL) === "path-absolute") {
98664
+ sourceURL = sourceURL.replace(/^\//, "");
98880
98665
  }
98881
98666
 
98882
- return normalize(sourceURL);
98667
+ let url = normalize(sourceURL || "");
98668
+
98669
+ // Parsing URLs can be expensive, so we only perform these joins when needed.
98670
+ if (sourceRoot) url = join(sourceRoot, url);
98671
+ if (sourceMapURL) url = join(trimFilename(sourceMapURL), url);
98672
+ return url;
98883
98673
  }
98884
98674
  exports.computeSourceURL = computeSourceURL;
98885
98675
 
@@ -98916,7 +98706,8 @@ module.exports = function wasm() {
98916
98706
 
98917
98707
  const callbackStack = [];
98918
98708
 
98919
- cachedWasm = readWasm().then(buffer => {
98709
+ cachedWasm = readWasm()
98710
+ .then(buffer => {
98920
98711
  return WebAssembly.instantiate(buffer, {
98921
98712
  env: {
98922
98713
  mapping_callback(
@@ -98958,44 +98749,74 @@ module.exports = function wasm() {
98958
98749
  callbackStack[callbackStack.length - 1](mapping);
98959
98750
  },
98960
98751
 
98961
- start_all_generated_locations_for() { console.time("all_generated_locations_for"); },
98962
- end_all_generated_locations_for() { console.timeEnd("all_generated_locations_for"); },
98752
+ start_all_generated_locations_for() {
98753
+ console.time("all_generated_locations_for");
98754
+ },
98755
+ end_all_generated_locations_for() {
98756
+ console.timeEnd("all_generated_locations_for");
98757
+ },
98963
98758
 
98964
- start_compute_column_spans() { console.time("compute_column_spans"); },
98965
- end_compute_column_spans() { console.timeEnd("compute_column_spans"); },
98759
+ start_compute_column_spans() {
98760
+ console.time("compute_column_spans");
98761
+ },
98762
+ end_compute_column_spans() {
98763
+ console.timeEnd("compute_column_spans");
98764
+ },
98966
98765
 
98967
- start_generated_location_for() { console.time("generated_location_for"); },
98968
- end_generated_location_for() { console.timeEnd("generated_location_for"); },
98766
+ start_generated_location_for() {
98767
+ console.time("generated_location_for");
98768
+ },
98769
+ end_generated_location_for() {
98770
+ console.timeEnd("generated_location_for");
98771
+ },
98969
98772
 
98970
- start_original_location_for() { console.time("original_location_for"); },
98971
- end_original_location_for() { console.timeEnd("original_location_for"); },
98773
+ start_original_location_for() {
98774
+ console.time("original_location_for");
98775
+ },
98776
+ end_original_location_for() {
98777
+ console.timeEnd("original_location_for");
98778
+ },
98972
98779
 
98973
- start_parse_mappings() { console.time("parse_mappings"); },
98974
- end_parse_mappings() { console.timeEnd("parse_mappings"); },
98780
+ start_parse_mappings() {
98781
+ console.time("parse_mappings");
98782
+ },
98783
+ end_parse_mappings() {
98784
+ console.timeEnd("parse_mappings");
98785
+ },
98975
98786
 
98976
- start_sort_by_generated_location() { console.time("sort_by_generated_location"); },
98977
- end_sort_by_generated_location() { console.timeEnd("sort_by_generated_location"); },
98787
+ start_sort_by_generated_location() {
98788
+ console.time("sort_by_generated_location");
98789
+ },
98790
+ end_sort_by_generated_location() {
98791
+ console.timeEnd("sort_by_generated_location");
98792
+ },
98978
98793
 
98979
- start_sort_by_original_location() { console.time("sort_by_original_location"); },
98980
- end_sort_by_original_location() { console.timeEnd("sort_by_original_location"); },
98981
- }
98794
+ start_sort_by_original_location() {
98795
+ console.time("sort_by_original_location");
98796
+ },
98797
+ end_sort_by_original_location() {
98798
+ console.timeEnd("sort_by_original_location");
98799
+ },
98800
+ },
98982
98801
  });
98983
- }).then(Wasm => {
98984
- return {
98985
- exports: Wasm.instance.exports,
98986
- withMappingCallback: (mappingCallback, f) => {
98987
- callbackStack.push(mappingCallback);
98988
- try {
98989
- f();
98990
- } finally {
98991
- callbackStack.pop();
98992
- }
98993
- }
98994
- };
98995
- }).then(null, e => {
98996
- cachedWasm = null;
98997
- throw e;
98998
- });
98802
+ })
98803
+ .then(Wasm => {
98804
+ return {
98805
+ exports: Wasm.instance.exports,
98806
+ withMappingCallback: (mappingCallback, f) => {
98807
+ callbackStack.push(mappingCallback);
98808
+ try {
98809
+ f();
98810
+ } finally {
98811
+ callbackStack.pop();
98812
+ }
98813
+ },
98814
+ };
98815
+ })
98816
+ .then(null, e => {
98817
+ cachedWasm = null;
98818
+ throw e;
98819
+ });
98999
98820
 
99000
98821
  return cachedWasm;
99001
98822
  };
@@ -99011,7 +98832,7 @@ module.exports = function wasm() {
99011
98832
 
99012
98833
  /*
99013
98834
  * Copyright 2009-2011 Mozilla Foundation and contributors
99014
- * Licensed under the New BSD license. See LICENSE.txt or:
98835
+ * Licensed under the New BSD license. See LICENSE or:
99015
98836
  * http://opensource.org/licenses/BSD-3-Clause
99016
98837
  */
99017
98838
  exports.SourceMapGenerator = __webpack_require__(/*! ./lib/source-map-generator */ "./node_modules/source-map/lib/source-map-generator.js").SourceMapGenerator;
@@ -101544,6 +101365,17 @@ module.exports = require("path");
101544
101365
 
101545
101366
  /***/ }),
101546
101367
 
101368
+ /***/ "url":
101369
+ /*!**********************!*\
101370
+ !*** external "url" ***!
101371
+ \**********************/
101372
+ /***/ ((module) => {
101373
+
101374
+ "use strict";
101375
+ module.exports = require("url");
101376
+
101377
+ /***/ }),
101378
+
101547
101379
  /***/ "util":
101548
101380
  /*!***********************!*\
101549
101381
  !*** external "util" ***!