@abaplint/transpiler-cli 2.10.75 → 2.10.77

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 +885 -1034
  2. package/package.json +4 -4
package/build/bundle.js CHANGED
@@ -52062,7 +52062,7 @@ class Table extends _abstract_object_1.AbstractObject {
52062
52062
  }
52063
52063
  if (found instanceof Types.StructureType) {
52064
52064
  if (field.GROUPNAME !== undefined) {
52065
- components.push({ name: field.GROUPNAME, type: found });
52065
+ components.push({ name: field.GROUPNAME, type: found, asInclude: true });
52066
52066
  }
52067
52067
  if (field.FIELDNAME.startsWith(".INCLU-") === false
52068
52068
  || field.FIELDNAME === ".INCLU--AP") {
@@ -53585,7 +53585,7 @@ class Registry {
53585
53585
  }
53586
53586
  static abaplintVersion() {
53587
53587
  // magic, see build script "version.sh"
53588
- return "2.113.149";
53588
+ return "2.113.150";
53589
53589
  }
53590
53590
  getDDICReferences() {
53591
53591
  return this.ddicReferences;
@@ -67361,6 +67361,7 @@ exports.MethodParameterNames = MethodParameterNames;
67361
67361
 
67362
67362
  Object.defineProperty(exports, "__esModule", ({ value: true }));
67363
67363
  exports.MixReturning = exports.MixReturningConf = void 0;
67364
+ /* eslint-disable max-len */
67364
67365
  const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
67365
67366
  const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
67366
67367
  const Statements = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
@@ -67380,9 +67381,10 @@ class MixReturning extends _abap_rule_1.ABAPRule {
67380
67381
  key: "mix_returning",
67381
67382
  title: "Mix of returning and exporting",
67382
67383
  shortDescription: `Checks that methods don't have a mixture of returning and exporting/changing parameters`,
67383
- // eslint-disable-next-line max-len
67384
- extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-either-returning-or-exporting-or-changing-but-not-a-combination`,
67385
- tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
67384
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-either-returning-or-exporting-or-changing-but-not-a-combination
67385
+
67386
+ This syntax is not allowed on versions earlier than 740sp02, https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abennews-740-abap_objects.htm#!ABAP_MODIFICATION_1@1@`,
67387
+ tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Syntax],
67386
67388
  badExample: `CLASS lcl DEFINITION.
67387
67389
  PUBLIC SECTION.
67388
67390
  METHODS
@@ -89242,13 +89244,30 @@ class TranspileTypes {
89242
89244
  const list = [];
89243
89245
  const suffix = {};
89244
89246
  const asInclude = {};
89247
+ /*
89248
+ const skipFields: Set<string> = new Set();
89249
+
89250
+ for (const c of type.getComponents()) {
89251
+ if (c.type instanceof abaplint.BasicTypes.StructureType) {
89252
+ for (const f of c.type.getComponents()) {
89253
+ skipFields.add(f.name.toLowerCase());
89254
+ }
89255
+ }
89256
+ }
89257
+ */
89245
89258
  for (const c of type.getComponents()) {
89246
- list.push(`"` + c.name.toLowerCase() + `": ` + this.toType(c.type));
89259
+ const lower = c.name.toLowerCase();
89260
+ /*
89261
+ if (skipFields.has(lower)) {
89262
+ continue; // skip fields from nested structures
89263
+ }
89264
+ */
89265
+ list.push(`"` + lower + `": ` + this.toType(c.type));
89247
89266
  if (c.suffix) {
89248
- suffix[c.name.toLowerCase()] = c.suffix;
89267
+ suffix[lower] = c.suffix;
89249
89268
  }
89250
89269
  if (c.asInclude) {
89251
- asInclude[c.name.toLowerCase()] = true;
89270
+ asInclude[lower] = true;
89252
89271
  }
89253
89272
  }
89254
89273
  extra = "{\n" + list.join(",\n") + "}";
@@ -95789,7 +95808,7 @@ class ArraySet {
95789
95808
  * @param String aStr
95790
95809
  */
95791
95810
  has(aStr) {
95792
- return this._set.has(aStr);
95811
+ return this._set.has(aStr);
95793
95812
  }
95794
95813
 
95795
95814
  /**
@@ -95800,7 +95819,7 @@ class ArraySet {
95800
95819
  indexOf(aStr) {
95801
95820
  const idx = this._set.get(aStr);
95802
95821
  if (idx >= 0) {
95803
- return idx;
95822
+ return idx;
95804
95823
  }
95805
95824
  throw new Error('"' + aStr + '" is not in the set.');
95806
95825
  }
@@ -95906,24 +95925,7 @@ const VLQ_CONTINUATION_BIT = VLQ_BASE;
95906
95925
  * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
95907
95926
  */
95908
95927
  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;
95928
+ return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0;
95927
95929
  }
95928
95930
 
95929
95931
  /**
@@ -95965,12 +95967,13 @@ exports.encode = function base64VLQ_encode(aValue) {
95965
95967
  * http://opensource.org/licenses/BSD-3-Clause
95966
95968
  */
95967
95969
 
95968
- const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
95970
+ const intToCharMap =
95971
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
95969
95972
 
95970
95973
  /**
95971
95974
  * Encode an integer in the range of 0 to 63 to a single base 64 digit.
95972
95975
  */
95973
- exports.encode = function(number) {
95976
+ exports.encode = function (number) {
95974
95977
  if (0 <= number && number < intToCharMap.length) {
95975
95978
  return intToCharMap[number];
95976
95979
  }
@@ -96033,7 +96036,7 @@ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
96033
96036
 
96034
96037
  // The exact needle element was not found in this haystack. Determine if
96035
96038
  // we are in termination case (3) or (2) and return the appropriate thing.
96036
- if (aBias == exports.LEAST_UPPER_BOUND) {
96039
+ if (aBias === exports.LEAST_UPPER_BOUND) {
96037
96040
  return aHigh < aHaystack.length ? aHigh : -1;
96038
96041
  }
96039
96042
  return mid;
@@ -96075,13 +96078,19 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
96075
96078
  return -1;
96076
96079
  }
96077
96080
 
96078
- let index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
96079
- aCompare, aBias || exports.GREATEST_LOWER_BOUND);
96081
+ let index = recursiveSearch(
96082
+ -1,
96083
+ aHaystack.length,
96084
+ aNeedle,
96085
+ aHaystack,
96086
+ aCompare,
96087
+ aBias || exports.GREATEST_LOWER_BOUND
96088
+ );
96080
96089
  if (index < 0) {
96081
96090
  return -1;
96082
96091
  }
96083
96092
 
96084
- // We have found either the exact element, or the next-closest element than
96093
+ // We have found either the exact element, or the next-closest element to
96085
96094
  // the one we are searching for. However, there may be more than one such
96086
96095
  // element. Make sure we always return the smallest of these.
96087
96096
  while (index - 1 >= 0) {
@@ -96122,8 +96131,11 @@ function generatedPositionAfter(mappingA, mappingB) {
96122
96131
  const lineB = mappingB.generatedLine;
96123
96132
  const columnA = mappingA.generatedColumn;
96124
96133
  const columnB = mappingB.generatedColumn;
96125
- return lineB > lineA || lineB == lineA && columnB >= columnA ||
96126
- util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
96134
+ return (
96135
+ lineB > lineA ||
96136
+ (lineB == lineA && columnB >= columnA) ||
96137
+ util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0
96138
+ );
96127
96139
  }
96128
96140
 
96129
96141
  /**
@@ -96136,7 +96148,7 @@ class MappingList {
96136
96148
  this._array = [];
96137
96149
  this._sorted = true;
96138
96150
  // Serves as infimum
96139
- this._last = {generatedLine: -1, generatedColumn: 0};
96151
+ this._last = { generatedLine: -1, generatedColumn: 0 };
96140
96152
  }
96141
96153
 
96142
96154
  /**
@@ -96193,55 +96205,34 @@ exports.MappingList = MappingList;
96193
96205
  \**************************************************/
96194
96206
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
96195
96207
 
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();
96208
+ "use strict";
96201
96209
 
96202
- if (isBrowserEnvironment) {
96203
- // Web version of reading a wasm file into an array buffer.
96204
96210
 
96205
- let mappingsWasm = null;
96211
+ // Note: This file is replaced with "read-wasm-browser.js" when this module is
96212
+ // bundled with a packager that takes package.json#browser fields into account.
96206
96213
 
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
- };
96214
+ const fs = __webpack_require__(/*! fs */ "fs");
96215
+ const path = __webpack_require__(/*! path */ "path");
96220
96216
 
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
- }
96217
+ module.exports = function readWasm() {
96218
+ return new Promise((resolve, reject) => {
96219
+ const wasmPath = path.join(__dirname, "mappings.wasm");
96220
+ fs.readFile(wasmPath, null, (error, data) => {
96221
+ if (error) {
96222
+ reject(error);
96223
+ return;
96224
+ }
96235
96225
 
96236
- resolve(data.buffer);
96237
- });
96226
+ resolve(data.buffer);
96238
96227
  });
96239
- };
96228
+ });
96229
+ };
96240
96230
 
96241
- module.exports.initialize = _ => {
96242
- console.debug("SourceMapConsumer.initialize is a no-op when running in node.js");
96243
- };
96244
- }
96231
+ module.exports.initialize = _ => {
96232
+ console.debug(
96233
+ "SourceMapConsumer.initialize is a no-op when running in node.js"
96234
+ );
96235
+ };
96245
96236
 
96246
96237
 
96247
96238
  /***/ }),
@@ -96327,15 +96318,6 @@ class SourceMapConsumer {
96327
96318
  }
96328
96319
  }
96329
96320
 
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
96321
  /**
96340
96322
  * Iterate over each mapping between an original source/line/column and a
96341
96323
  * generated line/column in this source map.
@@ -96442,14 +96424,19 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96442
96424
  }
96443
96425
 
96444
96426
  const version = util.getArg(sourceMap, "version");
96445
- let sources = util.getArg(sourceMap, "sources");
96427
+ const sources = util.getArg(sourceMap, "sources").map(String);
96446
96428
  // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
96447
96429
  // requires the array) to play nice here.
96448
96430
  const names = util.getArg(sourceMap, "names", []);
96449
- let sourceRoot = util.getArg(sourceMap, "sourceRoot", null);
96431
+ const sourceRoot = util.getArg(sourceMap, "sourceRoot", null);
96450
96432
  const sourcesContent = util.getArg(sourceMap, "sourcesContent", null);
96451
96433
  const mappings = util.getArg(sourceMap, "mappings");
96452
96434
  const file = util.getArg(sourceMap, "file", null);
96435
+ const x_google_ignoreList = util.getArg(
96436
+ sourceMap,
96437
+ "x_google_ignoreList",
96438
+ null
96439
+ );
96453
96440
 
96454
96441
  // Once again, Sass deviates from the spec and supplies the version as a
96455
96442
  // string rather than a number, so we use loose equality checking here.
@@ -96457,25 +96444,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96457
96444
  throw new Error("Unsupported version: " + version);
96458
96445
  }
96459
96446
 
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
- });
96447
+ that._sourceLookupCache = new Map();
96479
96448
 
96480
96449
  // Pass `true` below to allow duplicate names and sources. While source maps
96481
96450
  // are intended to be compressed and deduplicated, the TypeScript compiler
@@ -96484,15 +96453,19 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96484
96453
  that._names = ArraySet.fromArray(names.map(String), true);
96485
96454
  that._sources = ArraySet.fromArray(sources, true);
96486
96455
 
96487
- that._absoluteSources = that._sources.toArray().map(function(s) {
96488
- return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
96489
- });
96456
+ that._absoluteSources = ArraySet.fromArray(
96457
+ that._sources.toArray().map(function (s) {
96458
+ return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
96459
+ }),
96460
+ true
96461
+ );
96490
96462
 
96491
96463
  that.sourceRoot = sourceRoot;
96492
96464
  that.sourcesContent = sourcesContent;
96493
96465
  that._mappings = mappings;
96494
96466
  that._sourceMapURL = aSourceMapURL;
96495
96467
  that.file = file;
96468
+ that.x_google_ignoreList = x_google_ignoreList;
96496
96469
 
96497
96470
  that._computedColumnSpans = false;
96498
96471
  that._mappingsPtr = 0;
@@ -96510,23 +96483,38 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96510
96483
  * found.
96511
96484
  */
96512
96485
  _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);
96486
+ // In the most common usecases, we'll be constantly looking up the index for the same source
96487
+ // files, so we cache the index lookup to avoid constantly recomputing the full URLs.
96488
+ const cachedIndex = this._sourceLookupCache.get(aSource);
96489
+ if (typeof cachedIndex === "number") {
96490
+ return cachedIndex;
96491
+ }
96492
+
96493
+ // Treat the source as map-relative overall by default.
96494
+ const sourceAsMapRelative = util.computeSourceURL(
96495
+ null,
96496
+ aSource,
96497
+ this._sourceMapURL
96498
+ );
96499
+ if (this._absoluteSources.has(sourceAsMapRelative)) {
96500
+ const index = this._absoluteSources.indexOf(sourceAsMapRelative);
96501
+ this._sourceLookupCache.set(aSource, index);
96502
+ return index;
96520
96503
  }
96521
96504
 
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
- }
96505
+ // Fall back to treating the source as sourceRoot-relative.
96506
+ const sourceAsSourceRootRelative = util.computeSourceURL(
96507
+ this.sourceRoot,
96508
+ aSource,
96509
+ this._sourceMapURL
96510
+ );
96511
+ if (this._absoluteSources.has(sourceAsSourceRootRelative)) {
96512
+ const index = this._absoluteSources.indexOf(sourceAsSourceRootRelative);
96513
+ this._sourceLookupCache.set(aSource, index);
96514
+ return index;
96528
96515
  }
96529
96516
 
96517
+ // To avoid this cache growing forever, we do not cache lookup misses.
96530
96518
  return -1;
96531
96519
  }
96532
96520
 
@@ -96544,12 +96532,12 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96544
96532
  }
96545
96533
 
96546
96534
  get sources() {
96547
- return this._absoluteSources.slice();
96535
+ return this._absoluteSources.toArray();
96548
96536
  }
96549
96537
 
96550
96538
  _getMappingsPtr() {
96551
96539
  if (this._mappingsPtr === 0) {
96552
- this._parseMappings(this._mappings, this.sourceRoot);
96540
+ this._parseMappings();
96553
96541
  }
96554
96542
 
96555
96543
  return this._mappingsPtr;
@@ -96560,11 +96548,18 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96560
96548
  * query (the ordered arrays in the `this.__generatedMappings` and
96561
96549
  * `this.__originalMappings` properties).
96562
96550
  */
96563
- _parseMappings(aStr, aSourceRoot) {
96551
+ _parseMappings() {
96552
+ const aStr = this._mappings;
96564
96553
  const size = aStr.length;
96565
96554
 
96566
- const mappingsBufPtr = this._wasm.exports.allocate_mappings(size);
96567
- const mappingsBuf = new Uint8Array(this._wasm.exports.memory.buffer, mappingsBufPtr, size);
96555
+ // Interpret signed result of allocate_mappings as unsigned, otherwise
96556
+ // addresses higher than 2GB will be negative.
96557
+ const mappingsBufPtr = this._wasm.exports.allocate_mappings(size) >>> 0;
96558
+ const mappingsBuf = new Uint8Array(
96559
+ this._wasm.exports.memory.buffer,
96560
+ mappingsBufPtr,
96561
+ size
96562
+ );
96568
96563
  for (let i = 0; i < size; i++) {
96569
96564
  mappingsBuf[i] = aStr.charCodeAt(i);
96570
96565
  }
@@ -96575,10 +96570,11 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96575
96570
  const error = this._wasm.exports.get_last_error();
96576
96571
  let msg = `Error parsing mappings (code ${error}): `;
96577
96572
 
96578
- // XXX: keep these error codes in sync with `fitzgen/source-map-mappings`.
96573
+ // XXX: keep these error codes in sync with `wasm-mappings`.
96579
96574
  switch (error) {
96580
96575
  case 1:
96581
- msg += "the mappings contained a negative line, column, source index, or name index";
96576
+ msg +=
96577
+ "the mappings contained a negative line, column, source index, or name index";
96582
96578
  break;
96583
96579
  case 2:
96584
96580
  msg += "the mappings contained a number larger than 2**32";
@@ -96603,31 +96599,32 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96603
96599
  eachMapping(aCallback, aContext, aOrder) {
96604
96600
  const context = aContext || null;
96605
96601
  const order = aOrder || SourceMapConsumer.GENERATED_ORDER;
96606
- const sourceRoot = this.sourceRoot;
96607
96602
 
96608
96603
  this._wasm.withMappingCallback(
96609
96604
  mapping => {
96610
96605
  if (mapping.source !== null) {
96611
- mapping.source = this._sources.at(mapping.source);
96612
- mapping.source = util.computeSourceURL(sourceRoot, mapping.source, this._sourceMapURL);
96606
+ mapping.source = this._absoluteSources.at(mapping.source);
96613
96607
 
96614
96608
  if (mapping.name !== null) {
96615
96609
  mapping.name = this._names.at(mapping.name);
96616
96610
  }
96617
96611
  }
96612
+ if (this._computedColumnSpans && mapping.lastGeneratedColumn === null) {
96613
+ mapping.lastGeneratedColumn = Infinity;
96614
+ }
96618
96615
 
96619
96616
  aCallback.call(context, mapping);
96620
96617
  },
96621
96618
  () => {
96622
96619
  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.");
96620
+ case SourceMapConsumer.GENERATED_ORDER:
96621
+ this._wasm.exports.by_generated_location(this._getMappingsPtr());
96622
+ break;
96623
+ case SourceMapConsumer.ORIGINAL_ORDER:
96624
+ this._wasm.exports.by_original_location(this._getMappingsPtr());
96625
+ break;
96626
+ default:
96627
+ throw new Error("Unknown order of iteration.");
96631
96628
  }
96632
96629
  }
96633
96630
  );
@@ -96664,7 +96661,8 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96664
96661
  column: m.generatedColumn,
96665
96662
  lastColumn,
96666
96663
  });
96667
- }, () => {
96664
+ },
96665
+ () => {
96668
96666
  this._wasm.exports.all_generated_locations_for(
96669
96667
  this._getMappingsPtr(),
96670
96668
  source,
@@ -96725,7 +96723,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96725
96723
  originalPositionFor(aArgs) {
96726
96724
  const needle = {
96727
96725
  generatedLine: util.getArg(aArgs, "line"),
96728
- generatedColumn: util.getArg(aArgs, "column")
96726
+ generatedColumn: util.getArg(aArgs, "column"),
96729
96727
  };
96730
96728
 
96731
96729
  if (needle.generatedLine < 1) {
@@ -96736,27 +96734,33 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96736
96734
  throw new Error("Column numbers must be >= 0");
96737
96735
  }
96738
96736
 
96739
- let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
96737
+ let bias = util.getArg(
96738
+ aArgs,
96739
+ "bias",
96740
+ SourceMapConsumer.GREATEST_LOWER_BOUND
96741
+ );
96740
96742
  if (bias == null) {
96741
96743
  bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
96742
96744
  }
96743
96745
 
96744
96746
  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
- });
96747
+ this._wasm.withMappingCallback(
96748
+ m => (mapping = m),
96749
+ () => {
96750
+ this._wasm.exports.original_location_for(
96751
+ this._getMappingsPtr(),
96752
+ needle.generatedLine - 1,
96753
+ needle.generatedColumn,
96754
+ bias
96755
+ );
96756
+ }
96757
+ );
96753
96758
 
96754
96759
  if (mapping) {
96755
96760
  if (mapping.generatedLine === needle.generatedLine) {
96756
96761
  let source = util.getArg(mapping, "source", null);
96757
96762
  if (source !== null) {
96758
- source = this._sources.at(source);
96759
- source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
96763
+ source = this._absoluteSources.at(source);
96760
96764
  }
96761
96765
 
96762
96766
  let name = util.getArg(mapping, "name", null);
@@ -96768,7 +96772,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96768
96772
  source,
96769
96773
  line: util.getArg(mapping, "originalLine", null),
96770
96774
  column: util.getArg(mapping, "originalColumn", null),
96771
- name
96775
+ name,
96772
96776
  };
96773
96777
  }
96774
96778
  }
@@ -96777,7 +96781,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96777
96781
  source: null,
96778
96782
  line: null,
96779
96783
  column: null,
96780
- name: null
96784
+ name: null,
96781
96785
  };
96782
96786
  }
96783
96787
 
@@ -96789,8 +96793,12 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96789
96793
  if (!this.sourcesContent) {
96790
96794
  return false;
96791
96795
  }
96792
- return this.sourcesContent.length >= this._sources.size() &&
96793
- !this.sourcesContent.some(function(sc) { return sc == null; });
96796
+ return (
96797
+ this.sourcesContent.length >= this._sources.size() &&
96798
+ !this.sourcesContent.some(function (sc) {
96799
+ return sc == null;
96800
+ })
96801
+ );
96794
96802
  }
96795
96803
 
96796
96804
  /**
@@ -96808,30 +96816,6 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96808
96816
  return this.sourcesContent[index];
96809
96817
  }
96810
96818
 
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
96819
  // This function is used recursively from
96836
96820
  // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
96837
96821
  // don't want to throw if we can't find the source - we just want to
@@ -96840,7 +96824,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96840
96824
  return null;
96841
96825
  }
96842
96826
 
96843
- throw new Error('"' + relativeSource + '" is not in the SourceMap.');
96827
+ throw new Error('"' + aSource + '" is not in the SourceMap.');
96844
96828
  }
96845
96829
 
96846
96830
  /**
@@ -96873,14 +96857,14 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96873
96857
  return {
96874
96858
  line: null,
96875
96859
  column: null,
96876
- lastColumn: null
96860
+ lastColumn: null,
96877
96861
  };
96878
96862
  }
96879
96863
 
96880
96864
  const needle = {
96881
96865
  source,
96882
96866
  originalLine: util.getArg(aArgs, "line"),
96883
- originalColumn: util.getArg(aArgs, "column")
96867
+ originalColumn: util.getArg(aArgs, "column"),
96884
96868
  };
96885
96869
 
96886
96870
  if (needle.originalLine < 1) {
@@ -96891,21 +96875,28 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96891
96875
  throw new Error("Column numbers must be >= 0");
96892
96876
  }
96893
96877
 
96894
- let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
96878
+ let bias = util.getArg(
96879
+ aArgs,
96880
+ "bias",
96881
+ SourceMapConsumer.GREATEST_LOWER_BOUND
96882
+ );
96895
96883
  if (bias == null) {
96896
96884
  bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
96897
96885
  }
96898
96886
 
96899
96887
  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
- });
96888
+ this._wasm.withMappingCallback(
96889
+ m => (mapping = m),
96890
+ () => {
96891
+ this._wasm.exports.generated_location_for(
96892
+ this._getMappingsPtr(),
96893
+ needle.source,
96894
+ needle.originalLine - 1,
96895
+ needle.originalColumn,
96896
+ bias
96897
+ );
96898
+ }
96899
+ );
96909
96900
 
96910
96901
  if (mapping) {
96911
96902
  if (mapping.source === needle.source) {
@@ -96924,7 +96915,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
96924
96915
  return {
96925
96916
  line: null,
96926
96917
  column: null,
96927
- lastColumn: null
96918
+ lastColumn: null,
96928
96919
  };
96929
96920
  }
96930
96921
  }
@@ -96996,125 +96987,56 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
96996
96987
  throw new Error("Unsupported version: " + version);
96997
96988
  }
96998
96989
 
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
96990
  let lastOffset = {
97007
96991
  line: -1,
97008
- column: 0
96992
+ column: 0,
97009
96993
  };
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 => {
96994
+ return Promise.all(
96995
+ sections.map(s => {
96996
+ if (s.url) {
96997
+ // The url field will require support for asynchronicity.
96998
+ // See https://github.com/mozilla/source-map/issues/16
96999
+ throw new Error(
97000
+ "Support for url field in sections not implemented."
97001
+ );
97002
+ }
97003
+ const offset = util.getArg(s, "offset");
97004
+ const offsetLine = util.getArg(offset, "line");
97005
+ const offsetColumn = util.getArg(offset, "column");
97006
+
97007
+ if (
97008
+ offsetLine < lastOffset.line ||
97009
+ (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)
97010
+ ) {
97011
+ throw new Error(
97012
+ "Section offsets must be ordered and non-overlapping."
97013
+ );
97014
+ }
97015
+ lastOffset = offset;
97016
+
97017
+ const cons = new SourceMapConsumer(
97018
+ util.getArg(s, "map"),
97019
+ aSourceMapURL
97020
+ );
97021
+ return cons.then(consumer => {
97022
+ return {
97023
+ generatedOffset: {
97024
+ // The offset fields are 0-based, but we use 1-based indices when
97025
+ // encoding/decoding from VLQ.
97026
+ generatedLine: offsetLine + 1,
97027
+ generatedColumn: offsetColumn + 1,
97028
+ },
97029
+ consumer,
97030
+ };
97031
+ });
97032
+ })
97033
+ ).then(s => {
97039
97034
  that._sections = s;
97040
97035
  return that;
97041
97036
  });
97042
97037
  });
97043
97038
  }
97044
97039
 
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
97040
  /**
97119
97041
  * The list of original sources.
97120
97042
  */
@@ -97150,21 +97072,29 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
97150
97072
  originalPositionFor(aArgs) {
97151
97073
  const needle = {
97152
97074
  generatedLine: util.getArg(aArgs, "line"),
97153
- generatedColumn: util.getArg(aArgs, "column")
97075
+ generatedColumn: util.getArg(aArgs, "column"),
97154
97076
  };
97155
97077
 
97156
97078
  // Find the section containing the generated position we're trying to map
97157
97079
  // to an original position.
97158
- const sectionIndex = binarySearch.search(needle, this._sections,
97159
- function(aNeedle, section) {
97160
- const cmp = aNeedle.generatedLine - section.generatedOffset.generatedLine;
97080
+ const sectionIndex = binarySearch.search(
97081
+ needle,
97082
+ this._sections,
97083
+ function (aNeedle, section) {
97084
+ const cmp =
97085
+ aNeedle.generatedLine - section.generatedOffset.generatedLine;
97161
97086
  if (cmp) {
97162
97087
  return cmp;
97163
97088
  }
97164
97089
 
97165
- return (aNeedle.generatedColumn -
97166
- section.generatedOffset.generatedColumn);
97167
- });
97090
+ // The generated column is 0-based, but the section offset column is
97091
+ // stored 1-based.
97092
+ return (
97093
+ aNeedle.generatedColumn -
97094
+ (section.generatedOffset.generatedColumn - 1)
97095
+ );
97096
+ }
97097
+ );
97168
97098
  const section = this._sections[sectionIndex];
97169
97099
 
97170
97100
  if (!section) {
@@ -97172,18 +97102,18 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
97172
97102
  source: null,
97173
97103
  line: null,
97174
97104
  column: null,
97175
- name: null
97105
+ name: null,
97176
97106
  };
97177
97107
  }
97178
97108
 
97179
97109
  return section.consumer.originalPositionFor({
97180
- line: needle.generatedLine -
97181
- (section.generatedOffset.generatedLine - 1),
97182
- column: needle.generatedColumn -
97110
+ line: needle.generatedLine - (section.generatedOffset.generatedLine - 1),
97111
+ column:
97112
+ needle.generatedColumn -
97183
97113
  (section.generatedOffset.generatedLine === needle.generatedLine
97184
- ? section.generatedOffset.generatedColumn - 1
97185
- : 0),
97186
- bias: aArgs.bias
97114
+ ? section.generatedOffset.generatedColumn - 1
97115
+ : 0),
97116
+ bias: aArgs.bias,
97187
97117
  });
97188
97118
  }
97189
97119
 
@@ -97192,7 +97122,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
97192
97122
  * map, false otherwise.
97193
97123
  */
97194
97124
  hasContentsOfAllSources() {
97195
- return this._sections.every(function(s) {
97125
+ return this._sections.every(function (s) {
97196
97126
  return s.consumer.hasContentsOfAllSources();
97197
97127
  });
97198
97128
  }
@@ -97217,6 +97147,16 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
97217
97147
  throw new Error('"' + aSource + '" is not in the SourceMap.');
97218
97148
  }
97219
97149
 
97150
+ _findSectionIndex(source) {
97151
+ for (let i = 0; i < this._sections.length; i++) {
97152
+ const { consumer } = this._sections[i];
97153
+ if (consumer._findSourceIndex(source) !== -1) {
97154
+ return i;
97155
+ }
97156
+ }
97157
+ return -1;
97158
+ }
97159
+
97220
97160
  /**
97221
97161
  * Returns the generated line and column information for the original source,
97222
97162
  * line, and column positions provided. The only argument is an object with
@@ -97236,230 +97176,124 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
97236
97176
  * The column number is 0-based.
97237
97177
  */
97238
97178
  generatedPositionFor(aArgs) {
97239
- for (let i = 0; i < this._sections.length; i++) {
97240
- const section = this._sections[i];
97179
+ const index = this._findSectionIndex(util.getArg(aArgs, "source"));
97180
+ const section = index >= 0 ? this._sections[index] : null;
97181
+ const nextSection =
97182
+ index >= 0 && index + 1 < this._sections.length
97183
+ ? this._sections[index + 1]
97184
+ : null;
97241
97185
 
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;
97186
+ const generatedPosition =
97187
+ section && section.consumer.generatedPositionFor(aArgs);
97188
+ if (generatedPosition && generatedPosition.line !== null) {
97189
+ const lineShift = section.generatedOffset.generatedLine - 1;
97190
+ const columnShift = section.generatedOffset.generatedColumn - 1;
97191
+
97192
+ if (generatedPosition.line === 1) {
97193
+ generatedPosition.column += columnShift;
97194
+ if (typeof generatedPosition.lastColumn === "number") {
97195
+ generatedPosition.lastColumn += columnShift;
97196
+ }
97246
97197
  }
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;
97198
+
97199
+ if (
97200
+ generatedPosition.lastColumn === Infinity &&
97201
+ nextSection &&
97202
+ generatedPosition.line === nextSection.generatedOffset.generatedLine
97203
+ ) {
97204
+ generatedPosition.lastColumn =
97205
+ nextSection.generatedOffset.generatedColumn - 2;
97258
97206
  }
97207
+ generatedPosition.line += lineShift;
97208
+
97209
+ return generatedPosition;
97259
97210
  }
97260
97211
 
97261
97212
  return {
97262
97213
  line: null,
97263
- column: null
97214
+ column: null,
97215
+ lastColumn: null,
97264
97216
  };
97265
97217
  }
97266
97218
 
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));
97219
+ allGeneratedPositionsFor(aArgs) {
97220
+ const index = this._findSectionIndex(util.getArg(aArgs, "source"));
97221
+ const section = index >= 0 ? this._sections[index] : null;
97222
+ const nextSection =
97223
+ index >= 0 && index + 1 < this._sections.length
97224
+ ? this._sections[index + 1]
97225
+ : null;
97280
97226
 
97281
- for (let j = 0; j < sectionMappings.length; j++) {
97282
- const mapping = sectionMappings[j];
97227
+ if (!section) return [];
97283
97228
 
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);
97229
+ return section.consumer
97230
+ .allGeneratedPositionsFor(aArgs)
97231
+ .map(generatedPosition => {
97232
+ const lineShift = section.generatedOffset.generatedLine - 1;
97233
+ const columnShift = section.generatedOffset.generatedColumn - 1;
97291
97234
 
97292
- let name = null;
97293
- if (mapping.name) {
97294
- this._names.add(mapping.name);
97295
- name = this._names.indexOf(mapping.name);
97235
+ if (generatedPosition.line === 1) {
97236
+ generatedPosition.column += columnShift;
97237
+ if (typeof generatedPosition.lastColumn === "number") {
97238
+ generatedPosition.lastColumn += columnShift;
97239
+ }
97296
97240
  }
97297
97241
 
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);
97242
+ if (
97243
+ generatedPosition.lastColumn === Infinity &&
97244
+ nextSection &&
97245
+ generatedPosition.line === nextSection.generatedOffset.generatedLine
97246
+ ) {
97247
+ generatedPosition.lastColumn =
97248
+ nextSection.generatedOffset.generatedColumn - 2;
97318
97249
  }
97319
- }
97320
- }
97321
- }
97322
-
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
- }
97250
+ generatedPosition.line += lineShift;
97338
97251
 
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);
97252
+ return generatedPosition;
97253
+ });
97378
97254
  }
97379
97255
 
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
- }
97256
+ eachMapping(aCallback, aContext, aOrder) {
97257
+ this._sections.forEach((section, index) => {
97258
+ const nextSection =
97259
+ index + 1 < this._sections.length ? this._sections[index + 1] : null;
97260
+ const { generatedOffset } = section;
97397
97261
 
97398
- if (needle.originalLine < 1) {
97399
- throw new Error("Line numbers must be >= 1");
97400
- }
97262
+ const lineShift = generatedOffset.generatedLine - 1;
97263
+ const columnShift = generatedOffset.generatedColumn - 1;
97401
97264
 
97402
- if (needle.originalColumn < 0) {
97403
- throw new Error("Column numbers must be >= 0");
97404
- }
97265
+ section.consumer.eachMapping(
97266
+ function (mapping) {
97267
+ if (mapping.generatedLine === 1) {
97268
+ mapping.generatedColumn += columnShift;
97405
97269
 
97406
- const mappings = [];
97407
-
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;
97270
+ if (typeof mapping.lastGeneratedColumn === "number") {
97271
+ mapping.lastGeneratedColumn += columnShift;
97272
+ }
97428
97273
  }
97429
- mappings.push({
97430
- line: util.getArg(mapping, "generatedLine", null),
97431
- column: util.getArg(mapping, "generatedColumn", null),
97432
- lastColumn,
97433
- });
97434
97274
 
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;
97275
+ if (
97276
+ mapping.lastGeneratedColumn === Infinity &&
97277
+ nextSection &&
97278
+ mapping.generatedLine === nextSection.generatedOffset.generatedLine
97279
+ ) {
97280
+ mapping.lastGeneratedColumn =
97281
+ nextSection.generatedOffset.generatedColumn - 2;
97450
97282
  }
97451
- mappings.push({
97452
- line: util.getArg(mapping, "generatedLine", null),
97453
- column: util.getArg(mapping, "generatedColumn", null),
97454
- lastColumn,
97455
- });
97283
+ mapping.generatedLine += lineShift;
97456
97284
 
97457
- mapping = this._originalMappings[++index];
97458
- }
97459
- }
97460
- }
97285
+ aCallback.call(this, mapping);
97286
+ },
97287
+ aContext,
97288
+ aOrder
97289
+ );
97290
+ });
97291
+ }
97461
97292
 
97462
- return mappings;
97293
+ computeColumnSpans() {
97294
+ for (let i = 0; i < this._sections.length; i++) {
97295
+ this._sections[i].consumer.computeColumnSpans();
97296
+ }
97463
97297
  }
97464
97298
 
97465
97299
  destroy() {
@@ -97480,7 +97314,8 @@ function _factory(aSourceMap, aSourceMapURL) {
97480
97314
  sourceMap = util.parseSourceMapInput(aSourceMap);
97481
97315
  }
97482
97316
 
97483
- const consumer = sourceMap.sections != null
97317
+ const consumer =
97318
+ sourceMap.sections != null
97484
97319
  ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
97485
97320
  : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
97486
97321
  return Promise.resolve(consumer);
@@ -97542,14 +97377,14 @@ class SourceMapGenerator {
97542
97377
  const sourceRoot = aSourceMapConsumer.sourceRoot;
97543
97378
  const generator = new SourceMapGenerator({
97544
97379
  file: aSourceMapConsumer.file,
97545
- sourceRoot
97380
+ sourceRoot,
97546
97381
  });
97547
- aSourceMapConsumer.eachMapping(function(mapping) {
97382
+ aSourceMapConsumer.eachMapping(function (mapping) {
97548
97383
  const newMapping = {
97549
97384
  generated: {
97550
97385
  line: mapping.generatedLine,
97551
- column: mapping.generatedColumn
97552
- }
97386
+ column: mapping.generatedColumn,
97387
+ },
97553
97388
  };
97554
97389
 
97555
97390
  if (mapping.source != null) {
@@ -97560,7 +97395,7 @@ class SourceMapGenerator {
97560
97395
 
97561
97396
  newMapping.original = {
97562
97397
  line: mapping.originalLine,
97563
- column: mapping.originalColumn
97398
+ column: mapping.originalColumn,
97564
97399
  };
97565
97400
 
97566
97401
  if (mapping.name != null) {
@@ -97570,9 +97405,9 @@ class SourceMapGenerator {
97570
97405
 
97571
97406
  generator.addMapping(newMapping);
97572
97407
  });
97573
- aSourceMapConsumer.sources.forEach(function(sourceFile) {
97408
+ aSourceMapConsumer.sources.forEach(function (sourceFile) {
97574
97409
  let sourceRelative = sourceFile;
97575
- if (sourceRoot !== null) {
97410
+ if (sourceRoot != null) {
97576
97411
  sourceRelative = util.relative(sourceRoot, sourceFile);
97577
97412
  }
97578
97413
 
@@ -97625,10 +97460,10 @@ class SourceMapGenerator {
97625
97460
  this._mappings.add({
97626
97461
  generatedLine: generated.line,
97627
97462
  generatedColumn: generated.column,
97628
- originalLine: original != null && original.line,
97629
- originalColumn: original != null && original.column,
97463
+ originalLine: original && original.line,
97464
+ originalColumn: original && original.column,
97630
97465
  source,
97631
- name
97466
+ name,
97632
97467
  });
97633
97468
  }
97634
97469
 
@@ -97681,7 +97516,7 @@ class SourceMapGenerator {
97681
97516
  if (aSourceMapConsumer.file == null) {
97682
97517
  throw new Error(
97683
97518
  "SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, " +
97684
- 'or the source map\'s "file" property. Both were omitted.'
97519
+ 'or the source map\'s "file" property. Both were omitted.'
97685
97520
  );
97686
97521
  }
97687
97522
  sourceFile = aSourceMapConsumer.file;
@@ -97693,18 +97528,17 @@ class SourceMapGenerator {
97693
97528
  }
97694
97529
  // Applying the SourceMap can add and remove items from the sources and
97695
97530
  // the names array.
97696
- const newSources = this._mappings.toArray().length > 0
97697
- ? new ArraySet()
97698
- : this._sources;
97531
+ const newSources =
97532
+ this._mappings.toArray().length > 0 ? new ArraySet() : this._sources;
97699
97533
  const newNames = new ArraySet();
97700
97534
 
97701
97535
  // Find mappings for the "sourceFile"
97702
- this._mappings.unsortedForEach(function(mapping) {
97536
+ this._mappings.unsortedForEach(function (mapping) {
97703
97537
  if (mapping.source === sourceFile && mapping.originalLine != null) {
97704
97538
  // Check if it can be mapped by the source map, then update the mapping.
97705
97539
  const original = aSourceMapConsumer.originalPositionFor({
97706
97540
  line: mapping.originalLine,
97707
- column: mapping.originalColumn
97541
+ column: mapping.originalColumn,
97708
97542
  });
97709
97543
  if (original.source != null) {
97710
97544
  // Copy mapping
@@ -97732,13 +97566,12 @@ class SourceMapGenerator {
97732
97566
  if (name != null && !newNames.has(name)) {
97733
97567
  newNames.add(name);
97734
97568
  }
97735
-
97736
97569
  }, this);
97737
97570
  this._sources = newSources;
97738
97571
  this._names = newNames;
97739
97572
 
97740
97573
  // Copy sourcesContents of applied map.
97741
- aSourceMapConsumer.sources.forEach(function(srcFile) {
97574
+ aSourceMapConsumer.sources.forEach(function (srcFile) {
97742
97575
  const content = aSourceMapConsumer.sourceContentFor(srcFile);
97743
97576
  if (content != null) {
97744
97577
  if (aSourceMapPath != null) {
@@ -97768,33 +97601,53 @@ class SourceMapGenerator {
97768
97601
  // it is most likely a programmer error. In this case we throw a very
97769
97602
  // specific error message to try to guide them the right way.
97770
97603
  // 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
- );
97604
+ if (
97605
+ aOriginal &&
97606
+ typeof aOriginal.line !== "number" &&
97607
+ typeof aOriginal.column !== "number"
97608
+ ) {
97609
+ throw new Error(
97610
+ "original.line and original.column are not numbers -- you probably meant to omit " +
97611
+ "the original mapping entirely and only map the generated position. If so, pass " +
97612
+ "null for the original mapping instead of an object with empty or null values."
97613
+ );
97777
97614
  }
97778
97615
 
97779
- if (aGenerated && "line" in aGenerated && "column" in aGenerated
97780
- && aGenerated.line > 0 && aGenerated.column >= 0
97781
- && !aOriginal && !aSource && !aName) {
97616
+ if (
97617
+ aGenerated &&
97618
+ "line" in aGenerated &&
97619
+ "column" in aGenerated &&
97620
+ aGenerated.line > 0 &&
97621
+ aGenerated.column >= 0 &&
97622
+ !aOriginal &&
97623
+ !aSource &&
97624
+ !aName
97625
+ ) {
97782
97626
  // 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) {
97627
+ } else if (
97628
+ aGenerated &&
97629
+ "line" in aGenerated &&
97630
+ "column" in aGenerated &&
97631
+ aOriginal &&
97632
+ "line" in aOriginal &&
97633
+ "column" in aOriginal &&
97634
+ aGenerated.line > 0 &&
97635
+ aGenerated.column >= 0 &&
97636
+ aOriginal.line > 0 &&
97637
+ aOriginal.column >= 0 &&
97638
+ aSource
97639
+ ) {
97789
97640
  // Cases 2 and 3.
97790
-
97791
97641
  } else {
97792
- throw new Error("Invalid mapping: " + JSON.stringify({
97793
- generated: aGenerated,
97794
- source: aSource,
97795
- original: aOriginal,
97796
- name: aName
97797
- }));
97642
+ throw new Error(
97643
+ "Invalid mapping: " +
97644
+ JSON.stringify({
97645
+ generated: aGenerated,
97646
+ source: aSource,
97647
+ original: aOriginal,
97648
+ name: aName,
97649
+ })
97650
+ );
97798
97651
  }
97799
97652
  }
97800
97653
 
@@ -97827,14 +97680,17 @@ class SourceMapGenerator {
97827
97680
  previousGeneratedLine++;
97828
97681
  }
97829
97682
  } else if (i > 0) {
97830
- if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
97683
+ if (
97684
+ !util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])
97685
+ ) {
97831
97686
  continue;
97832
97687
  }
97833
97688
  next += ",";
97834
97689
  }
97835
97690
 
97836
- next += base64VLQ.encode(mapping.generatedColumn
97837
- - previousGeneratedColumn);
97691
+ next += base64VLQ.encode(
97692
+ mapping.generatedColumn - previousGeneratedColumn
97693
+ );
97838
97694
  previousGeneratedColumn = mapping.generatedColumn;
97839
97695
 
97840
97696
  if (mapping.source != null) {
@@ -97843,12 +97699,14 @@ class SourceMapGenerator {
97843
97699
  previousSource = sourceIdx;
97844
97700
 
97845
97701
  // lines are stored 0-based in SourceMap spec version 3
97846
- next += base64VLQ.encode(mapping.originalLine - 1
97847
- - previousOriginalLine);
97702
+ next += base64VLQ.encode(
97703
+ mapping.originalLine - 1 - previousOriginalLine
97704
+ );
97848
97705
  previousOriginalLine = mapping.originalLine - 1;
97849
97706
 
97850
- next += base64VLQ.encode(mapping.originalColumn
97851
- - previousOriginalColumn);
97707
+ next += base64VLQ.encode(
97708
+ mapping.originalColumn - previousOriginalColumn
97709
+ );
97852
97710
  previousOriginalColumn = mapping.originalColumn;
97853
97711
 
97854
97712
  if (mapping.name != null) {
@@ -97865,7 +97723,7 @@ class SourceMapGenerator {
97865
97723
  }
97866
97724
 
97867
97725
  _generateSourcesContent(aSources, aSourceRoot) {
97868
- return aSources.map(function(source) {
97726
+ return aSources.map(function (source) {
97869
97727
  if (!this._sourcesContents) {
97870
97728
  return null;
97871
97729
  }
@@ -97887,7 +97745,7 @@ class SourceMapGenerator {
97887
97745
  version: this._version,
97888
97746
  sources: this._sources.toArray(),
97889
97747
  names: this._names.toArray(),
97890
- mappings: this._serializeMappings()
97748
+ mappings: this._serializeMappings(),
97891
97749
  };
97892
97750
  if (this._file != null) {
97893
97751
  map.file = this._file;
@@ -97896,7 +97754,10 @@ class SourceMapGenerator {
97896
97754
  map.sourceRoot = this._sourceRoot;
97897
97755
  }
97898
97756
  if (this._sourcesContents) {
97899
- map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
97757
+ map.sourcesContent = this._generateSourcesContent(
97758
+ map.sources,
97759
+ map.sourceRoot
97760
+ );
97900
97761
  }
97901
97762
 
97902
97763
  return map;
@@ -97976,7 +97837,11 @@ class SourceNode {
97976
97837
  * @param aRelativePath Optional. The path that relative sources in the
97977
97838
  * SourceMapConsumer should be relative to.
97978
97839
  */
97979
- static fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
97840
+ static fromStringWithSourceMap(
97841
+ aGeneratedCode,
97842
+ aSourceMapConsumer,
97843
+ aRelativePath
97844
+ ) {
97980
97845
  // The SourceNode we want to fill with the generated code
97981
97846
  // and the SourceMap
97982
97847
  const node = new SourceNode();
@@ -97987,20 +97852,22 @@ class SourceNode {
97987
97852
  // Processed fragments are accessed by calling `shiftNextLine`.
97988
97853
  const remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
97989
97854
  let remainingLinesIndex = 0;
97990
- const shiftNextLine = function() {
97855
+ const shiftNextLine = function () {
97991
97856
  const lineContents = getNextLine();
97992
97857
  // The last line of a file might not have a newline.
97993
97858
  const newLine = getNextLine() || "";
97994
97859
  return lineContents + newLine;
97995
97860
 
97996
97861
  function getNextLine() {
97997
- return remainingLinesIndex < remainingLines.length ?
97998
- remainingLines[remainingLinesIndex++] : undefined;
97862
+ return remainingLinesIndex < remainingLines.length
97863
+ ? remainingLines[remainingLinesIndex++]
97864
+ : undefined;
97999
97865
  }
98000
97866
  };
98001
97867
 
98002
97868
  // We need to remember the position of "remainingLines"
98003
- let lastGeneratedLine = 1, lastGeneratedColumn = 0;
97869
+ let lastGeneratedLine = 1,
97870
+ lastGeneratedColumn = 0;
98004
97871
 
98005
97872
  // The generate SourceNodes we need a code range.
98006
97873
  // To extract it current and last mapping is used.
@@ -98008,7 +97875,7 @@ class SourceNode {
98008
97875
  let lastMapping = null;
98009
97876
  let nextLine;
98010
97877
 
98011
- aSourceMapConsumer.eachMapping(function(mapping) {
97878
+ aSourceMapConsumer.eachMapping(function (mapping) {
98012
97879
  if (lastMapping !== null) {
98013
97880
  // We add the code from "lastMapping" to "mapping":
98014
97881
  // First check if there is a new line in between.
@@ -98023,10 +97890,13 @@ class SourceNode {
98023
97890
  // Associate the code between "lastGeneratedColumn" and
98024
97891
  // "mapping.generatedColumn" with "lastMapping"
98025
97892
  nextLine = remainingLines[remainingLinesIndex] || "";
98026
- const code = nextLine.substr(0, mapping.generatedColumn -
98027
- lastGeneratedColumn);
98028
- remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
98029
- lastGeneratedColumn);
97893
+ const code = nextLine.substr(
97894
+ 0,
97895
+ mapping.generatedColumn - lastGeneratedColumn
97896
+ );
97897
+ remainingLines[remainingLinesIndex] = nextLine.substr(
97898
+ mapping.generatedColumn - lastGeneratedColumn
97899
+ );
98030
97900
  lastGeneratedColumn = mapping.generatedColumn;
98031
97901
  addMappingWithCode(lastMapping, code);
98032
97902
  // No more remaining code, continue
@@ -98044,7 +97914,9 @@ class SourceNode {
98044
97914
  if (lastGeneratedColumn < mapping.generatedColumn) {
98045
97915
  nextLine = remainingLines[remainingLinesIndex] || "";
98046
97916
  node.add(nextLine.substr(0, mapping.generatedColumn));
98047
- remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
97917
+ remainingLines[remainingLinesIndex] = nextLine.substr(
97918
+ mapping.generatedColumn
97919
+ );
98048
97920
  lastGeneratedColumn = mapping.generatedColumn;
98049
97921
  }
98050
97922
  lastMapping = mapping;
@@ -98060,7 +97932,7 @@ class SourceNode {
98060
97932
  }
98061
97933
 
98062
97934
  // Copy sourcesContent into SourceNode
98063
- aSourceMapConsumer.sources.forEach(function(sourceFile) {
97935
+ aSourceMapConsumer.sources.forEach(function (sourceFile) {
98064
97936
  const content = aSourceMapConsumer.sourceContentFor(sourceFile);
98065
97937
  if (content != null) {
98066
97938
  if (aRelativePath != null) {
@@ -98079,11 +97951,15 @@ class SourceNode {
98079
97951
  const source = aRelativePath
98080
97952
  ? util.join(aRelativePath, mapping.source)
98081
97953
  : mapping.source;
98082
- node.add(new SourceNode(mapping.originalLine,
98083
- mapping.originalColumn,
98084
- source,
98085
- code,
98086
- mapping.name));
97954
+ node.add(
97955
+ new SourceNode(
97956
+ mapping.originalLine,
97957
+ mapping.originalColumn,
97958
+ source,
97959
+ code,
97960
+ mapping.name
97961
+ )
97962
+ );
98087
97963
  }
98088
97964
  }
98089
97965
  }
@@ -98096,7 +97972,7 @@ class SourceNode {
98096
97972
  */
98097
97973
  add(aChunk) {
98098
97974
  if (Array.isArray(aChunk)) {
98099
- aChunk.forEach(function(chunk) {
97975
+ aChunk.forEach(function (chunk) {
98100
97976
  this.add(chunk);
98101
97977
  }, this);
98102
97978
  } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
@@ -98105,7 +97981,8 @@ class SourceNode {
98105
97981
  }
98106
97982
  } else {
98107
97983
  throw new TypeError(
98108
- "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
97984
+ "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " +
97985
+ aChunk
98109
97986
  );
98110
97987
  }
98111
97988
  return this;
@@ -98126,7 +98003,8 @@ class SourceNode {
98126
98003
  this.children.unshift(aChunk);
98127
98004
  } else {
98128
98005
  throw new TypeError(
98129
- "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
98006
+ "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " +
98007
+ aChunk
98130
98008
  );
98131
98009
  }
98132
98010
  return this;
@@ -98146,10 +98024,12 @@ class SourceNode {
98146
98024
  if (chunk[isSourceNode]) {
98147
98025
  chunk.walk(aFn);
98148
98026
  } else if (chunk !== "") {
98149
- aFn(chunk, { source: this.source,
98150
- line: this.line,
98151
- column: this.column,
98152
- name: this.name });
98027
+ aFn(chunk, {
98028
+ source: this.source,
98029
+ line: this.line,
98030
+ column: this.column,
98031
+ name: this.name,
98032
+ });
98153
98033
  }
98154
98034
  }
98155
98035
  }
@@ -98188,7 +98068,10 @@ class SourceNode {
98188
98068
  if (lastChild[isSourceNode]) {
98189
98069
  lastChild.replaceRight(aPattern, aReplacement);
98190
98070
  } else if (typeof lastChild === "string") {
98191
- this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
98071
+ this.children[this.children.length - 1] = lastChild.replace(
98072
+ aPattern,
98073
+ aReplacement
98074
+ );
98192
98075
  } else {
98193
98076
  this.children.push("".replace(aPattern, aReplacement));
98194
98077
  }
@@ -98231,7 +98114,7 @@ class SourceNode {
98231
98114
  */
98232
98115
  toString() {
98233
98116
  let str = "";
98234
- this.walk(function(chunk) {
98117
+ this.walk(function (chunk) {
98235
98118
  str += chunk;
98236
98119
  });
98237
98120
  return str;
@@ -98245,7 +98128,7 @@ class SourceNode {
98245
98128
  const generated = {
98246
98129
  code: "",
98247
98130
  line: 1,
98248
- column: 0
98131
+ column: 0,
98249
98132
  };
98250
98133
  const map = new SourceMapGenerator(aArgs);
98251
98134
  let sourceMappingActive = false;
@@ -98253,26 +98136,30 @@ class SourceNode {
98253
98136
  let lastOriginalLine = null;
98254
98137
  let lastOriginalColumn = null;
98255
98138
  let lastOriginalName = null;
98256
- this.walk(function(chunk, original) {
98139
+ this.walk(function (chunk, original) {
98257
98140
  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) {
98141
+ if (
98142
+ original.source !== null &&
98143
+ original.line !== null &&
98144
+ original.column !== null
98145
+ ) {
98146
+ if (
98147
+ lastOriginalSource !== original.source ||
98148
+ lastOriginalLine !== original.line ||
98149
+ lastOriginalColumn !== original.column ||
98150
+ lastOriginalName !== original.name
98151
+ ) {
98265
98152
  map.addMapping({
98266
98153
  source: original.source,
98267
98154
  original: {
98268
98155
  line: original.line,
98269
- column: original.column
98156
+ column: original.column,
98270
98157
  },
98271
98158
  generated: {
98272
98159
  line: generated.line,
98273
- column: generated.column
98160
+ column: generated.column,
98274
98161
  },
98275
- name: original.name
98162
+ name: original.name,
98276
98163
  });
98277
98164
  }
98278
98165
  lastOriginalSource = original.source;
@@ -98284,8 +98171,8 @@ class SourceNode {
98284
98171
  map.addMapping({
98285
98172
  generated: {
98286
98173
  line: generated.line,
98287
- column: generated.column
98288
- }
98174
+ column: generated.column,
98175
+ },
98289
98176
  });
98290
98177
  lastOriginalSource = null;
98291
98178
  sourceMappingActive = false;
@@ -98303,13 +98190,13 @@ class SourceNode {
98303
98190
  source: original.source,
98304
98191
  original: {
98305
98192
  line: original.line,
98306
- column: original.column
98193
+ column: original.column,
98307
98194
  },
98308
98195
  generated: {
98309
98196
  line: generated.line,
98310
- column: generated.column
98197
+ column: generated.column,
98311
98198
  },
98312
- name: original.name
98199
+ name: original.name,
98313
98200
  });
98314
98201
  }
98315
98202
  } else {
@@ -98317,7 +98204,7 @@ class SourceNode {
98317
98204
  }
98318
98205
  }
98319
98206
  });
98320
- this.walkSourceContents(function(sourceFile, sourceContent) {
98207
+ this.walkSourceContents(function (sourceFile, sourceContent) {
98321
98208
  map.setSourceContent(sourceFile, sourceContent);
98322
98209
  });
98323
98210
 
@@ -98328,13 +98215,37 @@ class SourceNode {
98328
98215
  exports.SourceNode = SourceNode;
98329
98216
 
98330
98217
 
98218
+ /***/ }),
98219
+
98220
+ /***/ "./node_modules/source-map/lib/url.js":
98221
+ /*!********************************************!*\
98222
+ !*** ./node_modules/source-map/lib/url.js ***!
98223
+ \********************************************/
98224
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
98225
+
98226
+ "use strict";
98227
+ /* -*- Mode: js; js-indent-level: 2; -*- */
98228
+ /*
98229
+ * Copyright 2011 Mozilla Foundation and contributors
98230
+ * Licensed under the New BSD license. See LICENSE or:
98231
+ * http://opensource.org/licenses/BSD-3-Clause
98232
+ */
98233
+
98234
+
98235
+ // Note: This file is overridden in the 'package.json#browser' field to
98236
+ // substitute lib/url-browser.js instead.
98237
+
98238
+ // Use the URL global for Node 10, and the 'url' module for Node 8.
98239
+ module.exports = typeof URL === "function" ? URL : (__webpack_require__(/*! url */ "url").URL);
98240
+
98241
+
98331
98242
  /***/ }),
98332
98243
 
98333
98244
  /***/ "./node_modules/source-map/lib/util.js":
98334
98245
  /*!*********************************************!*\
98335
98246
  !*** ./node_modules/source-map/lib/util.js ***!
98336
98247
  \*********************************************/
98337
- /***/ ((__unused_webpack_module, exports) => {
98248
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
98338
98249
 
98339
98250
  /* -*- Mode: js; js-indent-level: 2; -*- */
98340
98251
  /*
@@ -98343,6 +98254,8 @@ exports.SourceNode = SourceNode;
98343
98254
  * http://opensource.org/licenses/BSD-3-Clause
98344
98255
  */
98345
98256
 
98257
+ const URL = __webpack_require__(/*! ./url */ "./node_modules/source-map/lib/url.js");
98258
+
98346
98259
  /**
98347
98260
  * This is a helper function for getting values from parameter/options
98348
98261
  * objects.
@@ -98359,270 +98272,14 @@ function getArg(aArgs, aName, aDefaultValue) {
98359
98272
  } else if (arguments.length === 3) {
98360
98273
  return aDefaultValue;
98361
98274
  }
98362
- throw new Error('"' + aName + '" is a required argument.');
98363
-
98275
+ throw new Error('"' + aName + '" is a required argument.');
98364
98276
  }
98365
98277
  exports.getArg = getArg;
98366
98278
 
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
- }
98555
-
98556
- if (aPathUrl || aPath.match(dataUrlRegexp)) {
98557
- return aPath;
98558
- }
98559
-
98560
- // `join('http://', 'www.example.com')`
98561
- if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
98562
- aRootUrl.host = aPath;
98563
- return urlGenerate(aRootUrl);
98564
- }
98565
-
98566
- const joined = aPath.charAt(0) === "/"
98567
- ? aPath
98568
- : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath);
98569
-
98570
- if (aRootUrl) {
98571
- aRootUrl.path = joined;
98572
- return urlGenerate(aRootUrl);
98573
- }
98574
- return joined;
98575
- }
98576
- exports.join = join;
98577
-
98578
- exports.isAbsolute = function(aPath) {
98579
- return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
98580
- };
98581
-
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
-
98593
- aRoot = aRoot.replace(/\/$/, "");
98594
-
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
- }
98605
-
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
- }
98613
-
98614
- ++level;
98615
- }
98616
-
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);
98619
- }
98620
- exports.relative = relative;
98621
-
98622
- const supportsNullProto = (function() {
98279
+ const supportsNullProto = (function () {
98623
98280
  const obj = Object.create(null);
98624
98281
  return !("__proto__" in obj);
98625
- }());
98282
+ })();
98626
98283
 
98627
98284
  function identity(s) {
98628
98285
  return s;
@@ -98667,15 +98324,17 @@ function isProtoString(s) {
98667
98324
  }
98668
98325
 
98669
98326
  /* 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 /* '_' */) {
98327
+ if (
98328
+ s.charCodeAt(length - 1) !== 95 /* '_' */ ||
98329
+ s.charCodeAt(length - 2) !== 95 /* '_' */ ||
98330
+ s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
98331
+ s.charCodeAt(length - 4) !== 116 /* 't' */ ||
98332
+ s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
98333
+ s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
98334
+ s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
98335
+ s.charCodeAt(length - 8) !== 95 /* '_' */ ||
98336
+ s.charCodeAt(length - 9) !== 95 /* '_' */
98337
+ ) {
98679
98338
  return false;
98680
98339
  }
98681
98340
  /* eslint-enable no-multi-spaces */
@@ -98689,61 +98348,38 @@ function isProtoString(s) {
98689
98348
  return true;
98690
98349
  }
98691
98350
 
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;
98351
+ function strcmp(aStr1, aStr2) {
98352
+ if (aStr1 === aStr2) {
98353
+ return 0;
98709
98354
  }
98710
98355
 
98711
- cmp = mappingA.originalColumn - mappingB.originalColumn;
98712
- if (cmp !== 0 || onlyCompareOriginal) {
98713
- return cmp;
98356
+ if (aStr1 === null) {
98357
+ return 1; // aStr2 !== null
98714
98358
  }
98715
98359
 
98716
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
98717
- if (cmp !== 0) {
98718
- return cmp;
98360
+ if (aStr2 === null) {
98361
+ return -1; // aStr1 !== null
98719
98362
  }
98720
98363
 
98721
- cmp = mappingA.generatedLine - mappingB.generatedLine;
98722
- if (cmp !== 0) {
98723
- return cmp;
98364
+ if (aStr1 > aStr2) {
98365
+ return 1;
98724
98366
  }
98725
98367
 
98726
- return strcmp(mappingA.name, mappingB.name);
98368
+ return -1;
98727
98369
  }
98728
- exports.compareByOriginalPositions = compareByOriginalPositions;
98729
98370
 
98730
98371
  /**
98731
- * Comparator between two mappings with deflated source and name indices where
98372
+ * Comparator between two mappings with inflated source and name strings where
98732
98373
  * 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
98374
  */
98739
- function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
98375
+ function compareByGeneratedPositionsInflated(mappingA, mappingB) {
98740
98376
  let cmp = mappingA.generatedLine - mappingB.generatedLine;
98741
98377
  if (cmp !== 0) {
98742
98378
  return cmp;
98743
98379
  }
98744
98380
 
98745
98381
  cmp = mappingA.generatedColumn - mappingB.generatedColumn;
98746
- if (cmp !== 0 || onlyCompareGenerated) {
98382
+ if (cmp !== 0) {
98747
98383
  return cmp;
98748
98384
  }
98749
98385
 
@@ -98764,122 +98400,295 @@ function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGene
98764
98400
 
98765
98401
  return strcmp(mappingA.name, mappingB.name);
98766
98402
  }
98767
- exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
98403
+ exports.compareByGeneratedPositionsInflated =
98404
+ compareByGeneratedPositionsInflated;
98768
98405
 
98769
- function strcmp(aStr1, aStr2) {
98770
- if (aStr1 === aStr2) {
98771
- return 0;
98772
- }
98406
+ /**
98407
+ * Strip any JSON XSSI avoidance prefix from the string (as documented
98408
+ * in the source maps specification), and then parse the string as
98409
+ * JSON.
98410
+ */
98411
+ function parseSourceMapInput(str) {
98412
+ return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
98413
+ }
98414
+ exports.parseSourceMapInput = parseSourceMapInput;
98773
98415
 
98774
- if (aStr1 === null) {
98775
- return 1; // aStr2 !== null
98776
- }
98416
+ // We use 'http' as the base here because we want URLs processed relative
98417
+ // to the safe base to be treated as "special" URLs during parsing using
98418
+ // the WHATWG URL parsing. This ensures that backslash normalization
98419
+ // applies to the path and such.
98420
+ const PROTOCOL = "http:";
98421
+ const PROTOCOL_AND_HOST = `${PROTOCOL}//host`;
98777
98422
 
98778
- if (aStr2 === null) {
98779
- return -1; // aStr1 !== null
98423
+ /**
98424
+ * Make it easy to create small utilities that tweak a URL's path.
98425
+ */
98426
+ function createSafeHandler(cb) {
98427
+ return input => {
98428
+ const type = getURLType(input);
98429
+ const base = buildSafeBase(input);
98430
+ const url = new URL(input, base);
98431
+
98432
+ cb(url);
98433
+
98434
+ const result = url.toString();
98435
+
98436
+ if (type === "absolute") {
98437
+ return result;
98438
+ } else if (type === "scheme-relative") {
98439
+ return result.slice(PROTOCOL.length);
98440
+ } else if (type === "path-absolute") {
98441
+ return result.slice(PROTOCOL_AND_HOST.length);
98442
+ }
98443
+
98444
+ // This assumes that the callback will only change
98445
+ // the path, search and hash values.
98446
+ return computeRelativeURL(base, result);
98447
+ };
98448
+ }
98449
+
98450
+ function withBase(url, base) {
98451
+ return new URL(url, base).toString();
98452
+ }
98453
+
98454
+ function buildUniqueSegment(prefix, str) {
98455
+ let id = 0;
98456
+ do {
98457
+ const ident = prefix + id++;
98458
+ if (str.indexOf(ident) === -1) return ident;
98459
+ } while (true);
98460
+ }
98461
+
98462
+ function buildSafeBase(str) {
98463
+ const maxDotParts = str.split("..").length - 1;
98464
+
98465
+ // If we used a segment that also existed in `str`, then we would be unable
98466
+ // to compute relative paths. For example, if `segment` were just "a":
98467
+ //
98468
+ // const url = "../../a/"
98469
+ // const base = buildSafeBase(url); // http://host/a/a/
98470
+ // const joined = "http://host/a/";
98471
+ // const result = relative(base, joined);
98472
+ //
98473
+ // Expected: "../../a/";
98474
+ // Actual: "a/"
98475
+ //
98476
+ const segment = buildUniqueSegment("p", str);
98477
+
98478
+ let base = `${PROTOCOL_AND_HOST}/`;
98479
+ for (let i = 0; i < maxDotParts; i++) {
98480
+ base += `${segment}/`;
98780
98481
  }
98482
+ return base;
98483
+ }
98781
98484
 
98782
- if (aStr1 > aStr2) {
98783
- return 1;
98485
+ const ABSOLUTE_SCHEME = /^[A-Za-z0-9\+\-\.]+:/;
98486
+ function getURLType(url) {
98487
+ if (url[0] === "/") {
98488
+ if (url[1] === "/") return "scheme-relative";
98489
+ return "path-absolute";
98784
98490
  }
98785
98491
 
98786
- return -1;
98492
+ return ABSOLUTE_SCHEME.test(url) ? "absolute" : "path-relative";
98787
98493
  }
98788
98494
 
98789
98495
  /**
98790
- * Comparator between two mappings with inflated source and name strings where
98791
- * the generated positions are compared.
98496
+ * Given two URLs that are assumed to be on the same
98497
+ * protocol/host/user/password build a relative URL from the
98498
+ * path, params, and hash values.
98499
+ *
98500
+ * @param rootURL The root URL that the target will be relative to.
98501
+ * @param targetURL The target that the relative URL points to.
98502
+ * @return A rootURL-relative, normalized URL value.
98792
98503
  */
98793
- function compareByGeneratedPositionsInflated(mappingA, mappingB) {
98794
- let cmp = mappingA.generatedLine - mappingB.generatedLine;
98795
- if (cmp !== 0) {
98796
- return cmp;
98504
+ function computeRelativeURL(rootURL, targetURL) {
98505
+ if (typeof rootURL === "string") rootURL = new URL(rootURL);
98506
+ if (typeof targetURL === "string") targetURL = new URL(targetURL);
98507
+
98508
+ const targetParts = targetURL.pathname.split("/");
98509
+ const rootParts = rootURL.pathname.split("/");
98510
+
98511
+ // If we've got a URL path ending with a "/", we remove it since we'd
98512
+ // otherwise be relative to the wrong location.
98513
+ if (rootParts.length > 0 && !rootParts[rootParts.length - 1]) {
98514
+ rootParts.pop();
98797
98515
  }
98798
98516
 
98799
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
98800
- if (cmp !== 0) {
98801
- return cmp;
98517
+ while (
98518
+ targetParts.length > 0 &&
98519
+ rootParts.length > 0 &&
98520
+ targetParts[0] === rootParts[0]
98521
+ ) {
98522
+ targetParts.shift();
98523
+ rootParts.shift();
98802
98524
  }
98803
98525
 
98804
- cmp = strcmp(mappingA.source, mappingB.source);
98805
- if (cmp !== 0) {
98806
- return cmp;
98526
+ const relativePath = rootParts
98527
+ .map(() => "..")
98528
+ .concat(targetParts)
98529
+ .join("/");
98530
+
98531
+ return relativePath + targetURL.search + targetURL.hash;
98532
+ }
98533
+
98534
+ /**
98535
+ * Given a URL, ensure that it is treated as a directory URL.
98536
+ *
98537
+ * @param url
98538
+ * @return A normalized URL value.
98539
+ */
98540
+ const ensureDirectory = createSafeHandler(url => {
98541
+ url.pathname = url.pathname.replace(/\/?$/, "/");
98542
+ });
98543
+
98544
+ /**
98545
+ * Given a URL, strip off any filename if one is present.
98546
+ *
98547
+ * @param url
98548
+ * @return A normalized URL value.
98549
+ */
98550
+ const trimFilename = createSafeHandler(url => {
98551
+ url.href = new URL(".", url.toString()).toString();
98552
+ });
98553
+
98554
+ /**
98555
+ * Normalize a given URL.
98556
+ * * Convert backslashes.
98557
+ * * Remove any ".." and "." segments.
98558
+ *
98559
+ * @param url
98560
+ * @return A normalized URL value.
98561
+ */
98562
+ const normalize = createSafeHandler(url => {});
98563
+ exports.normalize = normalize;
98564
+
98565
+ /**
98566
+ * Joins two paths/URLs.
98567
+ *
98568
+ * All returned URLs will be normalized.
98569
+ *
98570
+ * @param aRoot The root path or URL. Assumed to reference a directory.
98571
+ * @param aPath The path or URL to be joined with the root.
98572
+ * @return A joined and normalized URL value.
98573
+ */
98574
+ function join(aRoot, aPath) {
98575
+ const pathType = getURLType(aPath);
98576
+ const rootType = getURLType(aRoot);
98577
+
98578
+ aRoot = ensureDirectory(aRoot);
98579
+
98580
+ if (pathType === "absolute") {
98581
+ return withBase(aPath, undefined);
98582
+ }
98583
+ if (rootType === "absolute") {
98584
+ return withBase(aPath, aRoot);
98807
98585
  }
98808
98586
 
98809
- cmp = mappingA.originalLine - mappingB.originalLine;
98810
- if (cmp !== 0) {
98811
- return cmp;
98587
+ if (pathType === "scheme-relative") {
98588
+ return normalize(aPath);
98589
+ }
98590
+ if (rootType === "scheme-relative") {
98591
+ return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(
98592
+ PROTOCOL.length
98593
+ );
98812
98594
  }
98813
98595
 
98814
- cmp = mappingA.originalColumn - mappingB.originalColumn;
98815
- if (cmp !== 0) {
98816
- return cmp;
98596
+ if (pathType === "path-absolute") {
98597
+ return normalize(aPath);
98598
+ }
98599
+ if (rootType === "path-absolute") {
98600
+ return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(
98601
+ PROTOCOL_AND_HOST.length
98602
+ );
98817
98603
  }
98818
98604
 
98819
- return strcmp(mappingA.name, mappingB.name);
98605
+ const base = buildSafeBase(aPath + aRoot);
98606
+ const newPath = withBase(aPath, withBase(aRoot, base));
98607
+ return computeRelativeURL(base, newPath);
98820
98608
  }
98821
- exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
98609
+ exports.join = join;
98822
98610
 
98823
98611
  /**
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.
98612
+ * Make a path relative to a URL or another path. If returning a
98613
+ * relative URL is not possible, the original target will be returned.
98614
+ * All returned URLs will be normalized.
98615
+ *
98616
+ * @param aRoot The root path or URL.
98617
+ * @param aPath The path or URL to be made relative to aRoot.
98618
+ * @return A rootURL-relative (if possible), normalized URL value.
98827
98619
  */
98828
- function parseSourceMapInput(str) {
98829
- return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
98620
+ function relative(rootURL, targetURL) {
98621
+ const result = relativeIfPossible(rootURL, targetURL);
98622
+
98623
+ return typeof result === "string" ? result : normalize(targetURL);
98624
+ }
98625
+ exports.relative = relative;
98626
+
98627
+ function relativeIfPossible(rootURL, targetURL) {
98628
+ const urlType = getURLType(rootURL);
98629
+ if (urlType !== getURLType(targetURL)) {
98630
+ return null;
98631
+ }
98632
+
98633
+ const base = buildSafeBase(rootURL + targetURL);
98634
+ const root = new URL(rootURL, base);
98635
+ const target = new URL(targetURL, base);
98636
+
98637
+ try {
98638
+ new URL("", target.toString());
98639
+ } catch (err) {
98640
+ // Bail if the URL doesn't support things being relative to it,
98641
+ // For example, data: and blob: URLs.
98642
+ return null;
98643
+ }
98644
+
98645
+ if (
98646
+ target.protocol !== root.protocol ||
98647
+ target.user !== root.user ||
98648
+ target.password !== root.password ||
98649
+ target.hostname !== root.hostname ||
98650
+ target.port !== root.port
98651
+ ) {
98652
+ return null;
98653
+ }
98654
+
98655
+ return computeRelativeURL(root, target);
98830
98656
  }
98831
- exports.parseSourceMapInput = parseSourceMapInput;
98832
98657
 
98833
98658
  /**
98834
98659
  * Compute the URL of a source given the the source root, the source's
98835
98660
  * URL, and the source map's URL.
98836
98661
  */
98837
98662
  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.
98663
+ // The source map spec states that "sourceRoot" and "sources" entries are to be appended. While
98664
+ // that is a little vague, implementations have generally interpreted that as joining the
98665
+ // URLs with a `/` between then, assuming the "sourceRoot" doesn't already end with one.
98666
+ // For example,
98862
98667
  //
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);
98668
+ // sourceRoot: "some-dir",
98669
+ // sources: ["/some-path.js"]
98670
+ //
98671
+ // and
98672
+ //
98673
+ // sourceRoot: "some-dir/",
98674
+ // sources: ["/some-path.js"]
98675
+ //
98676
+ // must behave as "some-dir/some-path.js".
98677
+ //
98678
+ // With this library's the transition to a more URL-focused implementation, that behavior is
98679
+ // preserved here. To acheive that, we trim the "/" from absolute-path when a sourceRoot value
98680
+ // is present in order to make the sources entries behave as if they are relative to the
98681
+ // "sourceRoot", as they would have if the two strings were simply concated.
98682
+ if (sourceRoot && getURLType(sourceURL) === "path-absolute") {
98683
+ sourceURL = sourceURL.replace(/^\//, "");
98880
98684
  }
98881
98685
 
98882
- return normalize(sourceURL);
98686
+ let url = normalize(sourceURL || "");
98687
+
98688
+ // Parsing URLs can be expensive, so we only perform these joins when needed.
98689
+ if (sourceRoot) url = join(sourceRoot, url);
98690
+ if (sourceMapURL) url = join(trimFilename(sourceMapURL), url);
98691
+ return url;
98883
98692
  }
98884
98693
  exports.computeSourceURL = computeSourceURL;
98885
98694
 
@@ -98916,7 +98725,8 @@ module.exports = function wasm() {
98916
98725
 
98917
98726
  const callbackStack = [];
98918
98727
 
98919
- cachedWasm = readWasm().then(buffer => {
98728
+ cachedWasm = readWasm()
98729
+ .then(buffer => {
98920
98730
  return WebAssembly.instantiate(buffer, {
98921
98731
  env: {
98922
98732
  mapping_callback(
@@ -98958,44 +98768,74 @@ module.exports = function wasm() {
98958
98768
  callbackStack[callbackStack.length - 1](mapping);
98959
98769
  },
98960
98770
 
98961
- start_all_generated_locations_for() { console.time("all_generated_locations_for"); },
98962
- end_all_generated_locations_for() { console.timeEnd("all_generated_locations_for"); },
98771
+ start_all_generated_locations_for() {
98772
+ console.time("all_generated_locations_for");
98773
+ },
98774
+ end_all_generated_locations_for() {
98775
+ console.timeEnd("all_generated_locations_for");
98776
+ },
98963
98777
 
98964
- start_compute_column_spans() { console.time("compute_column_spans"); },
98965
- end_compute_column_spans() { console.timeEnd("compute_column_spans"); },
98778
+ start_compute_column_spans() {
98779
+ console.time("compute_column_spans");
98780
+ },
98781
+ end_compute_column_spans() {
98782
+ console.timeEnd("compute_column_spans");
98783
+ },
98966
98784
 
98967
- start_generated_location_for() { console.time("generated_location_for"); },
98968
- end_generated_location_for() { console.timeEnd("generated_location_for"); },
98785
+ start_generated_location_for() {
98786
+ console.time("generated_location_for");
98787
+ },
98788
+ end_generated_location_for() {
98789
+ console.timeEnd("generated_location_for");
98790
+ },
98969
98791
 
98970
- start_original_location_for() { console.time("original_location_for"); },
98971
- end_original_location_for() { console.timeEnd("original_location_for"); },
98792
+ start_original_location_for() {
98793
+ console.time("original_location_for");
98794
+ },
98795
+ end_original_location_for() {
98796
+ console.timeEnd("original_location_for");
98797
+ },
98972
98798
 
98973
- start_parse_mappings() { console.time("parse_mappings"); },
98974
- end_parse_mappings() { console.timeEnd("parse_mappings"); },
98799
+ start_parse_mappings() {
98800
+ console.time("parse_mappings");
98801
+ },
98802
+ end_parse_mappings() {
98803
+ console.timeEnd("parse_mappings");
98804
+ },
98975
98805
 
98976
- start_sort_by_generated_location() { console.time("sort_by_generated_location"); },
98977
- end_sort_by_generated_location() { console.timeEnd("sort_by_generated_location"); },
98806
+ start_sort_by_generated_location() {
98807
+ console.time("sort_by_generated_location");
98808
+ },
98809
+ end_sort_by_generated_location() {
98810
+ console.timeEnd("sort_by_generated_location");
98811
+ },
98978
98812
 
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
- }
98813
+ start_sort_by_original_location() {
98814
+ console.time("sort_by_original_location");
98815
+ },
98816
+ end_sort_by_original_location() {
98817
+ console.timeEnd("sort_by_original_location");
98818
+ },
98819
+ },
98982
98820
  });
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
- });
98821
+ })
98822
+ .then(Wasm => {
98823
+ return {
98824
+ exports: Wasm.instance.exports,
98825
+ withMappingCallback: (mappingCallback, f) => {
98826
+ callbackStack.push(mappingCallback);
98827
+ try {
98828
+ f();
98829
+ } finally {
98830
+ callbackStack.pop();
98831
+ }
98832
+ },
98833
+ };
98834
+ })
98835
+ .then(null, e => {
98836
+ cachedWasm = null;
98837
+ throw e;
98838
+ });
98999
98839
 
99000
98840
  return cachedWasm;
99001
98841
  };
@@ -99011,7 +98851,7 @@ module.exports = function wasm() {
99011
98851
 
99012
98852
  /*
99013
98853
  * Copyright 2009-2011 Mozilla Foundation and contributors
99014
- * Licensed under the New BSD license. See LICENSE.txt or:
98854
+ * Licensed under the New BSD license. See LICENSE or:
99015
98855
  * http://opensource.org/licenses/BSD-3-Clause
99016
98856
  */
99017
98857
  exports.SourceMapGenerator = __webpack_require__(/*! ./lib/source-map-generator */ "./node_modules/source-map/lib/source-map-generator.js").SourceMapGenerator;
@@ -101544,6 +101384,17 @@ module.exports = require("path");
101544
101384
 
101545
101385
  /***/ }),
101546
101386
 
101387
+ /***/ "url":
101388
+ /*!**********************!*\
101389
+ !*** external "url" ***!
101390
+ \**********************/
101391
+ /***/ ((module) => {
101392
+
101393
+ "use strict";
101394
+ module.exports = require("url");
101395
+
101396
+ /***/ }),
101397
+
101547
101398
  /***/ "util":
101548
101399
  /*!***********************!*\
101549
101400
  !*** external "util" ***!