@dcloudio/uni-stacktracey 3.0.0-3070320230222002 → 3.0.0-3070820230322001

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.
@@ -207,130 +207,7 @@ function parseItem(e, maxColumnWidths, isMP) {
207
207
  /* ------------------------------------------------------------------------ */
208
208
  var StackTracey$1 = StackTracey;
209
209
 
210
- var sourceMapGenerator = {};
211
-
212
- var base64Vlq = {};
213
-
214
- var base64$1 = {};
215
-
216
- /* -*- Mode: js; js-indent-level: 2; -*- */
217
-
218
- /*
219
- * Copyright 2011 Mozilla Foundation and contributors
220
- * Licensed under the New BSD license. See LICENSE or:
221
- * http://opensource.org/licenses/BSD-3-Clause
222
- */
223
-
224
- const intToCharMap =
225
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
226
-
227
- /**
228
- * Encode an integer in the range of 0 to 63 to a single base 64 digit.
229
- */
230
- base64$1.encode = function (number) {
231
- if (0 <= number && number < intToCharMap.length) {
232
- return intToCharMap[number]
233
- }
234
- throw new TypeError('Must be between 0 and 63: ' + number)
235
- };
236
-
237
- /* -*- Mode: js; js-indent-level: 2; -*- */
238
-
239
- /*
240
- * Copyright 2011 Mozilla Foundation and contributors
241
- * Licensed under the New BSD license. See LICENSE or:
242
- * http://opensource.org/licenses/BSD-3-Clause
243
- *
244
- * Based on the Base 64 VLQ implementation in Closure Compiler:
245
- * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
246
- *
247
- * Copyright 2011 The Closure Compiler Authors. All rights reserved.
248
- * Redistribution and use in source and binary forms, with or without
249
- * modification, are permitted provided that the following conditions are
250
- * met:
251
- *
252
- * * Redistributions of source code must retain the above copyright
253
- * notice, this list of conditions and the following disclaimer.
254
- * * Redistributions in binary form must reproduce the above
255
- * copyright notice, this list of conditions and the following
256
- * disclaimer in the documentation and/or other materials provided
257
- * with the distribution.
258
- * * Neither the name of Google Inc. nor the names of its
259
- * contributors may be used to endorse or promote products derived
260
- * from this software without specific prior written permission.
261
- *
262
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
263
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
264
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
265
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
266
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
267
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
268
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
269
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
270
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
271
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273
- */
274
-
275
- const base64 = base64$1;
276
-
277
- // A single base 64 digit can contain 6 bits of data. For the base 64 variable
278
- // length quantities we use in the source map spec, the first bit is the sign,
279
- // the next four bits are the actual value, and the 6th bit is the
280
- // continuation bit. The continuation bit tells us whether there are more
281
- // digits in this value following this digit.
282
- //
283
- // Continuation
284
- // | Sign
285
- // | |
286
- // V V
287
- // 101011
288
-
289
- const VLQ_BASE_SHIFT = 5;
290
-
291
- // binary: 100000
292
- const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
293
-
294
- // binary: 011111
295
- const VLQ_BASE_MASK = VLQ_BASE - 1;
296
-
297
- // binary: 100000
298
- const VLQ_CONTINUATION_BIT = VLQ_BASE;
299
-
300
- /**
301
- * Converts from a two-complement value to a value where the sign bit is
302
- * placed in the least significant bit. For example, as decimals:
303
- * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
304
- * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
305
- */
306
- function toVLQSigned(aValue) {
307
- return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0
308
- }
309
-
310
- /**
311
- * Returns the base 64 VLQ encoded value.
312
- */
313
- base64Vlq.encode = function base64VLQ_encode(aValue) {
314
- let encoded = '';
315
- let digit;
316
-
317
- let vlq = toVLQSigned(aValue);
318
-
319
- do {
320
- digit = vlq & VLQ_BASE_MASK;
321
- vlq >>>= VLQ_BASE_SHIFT;
322
- if (vlq > 0) {
323
- // There are still more digits in this value, so we must make sure the
324
- // continuation bit is marked.
325
- digit |= VLQ_CONTINUATION_BIT;
326
- }
327
- encoded += base64.encode(digit);
328
- } while (vlq > 0)
329
-
330
- return encoded
331
- };
332
-
333
- var util$4 = {};
210
+ var util$1 = {};
334
211
 
335
212
  /* -*- Mode: js; js-indent-level: 2; -*- */
336
213
 
@@ -889,7 +766,7 @@ var util$4 = {};
889
766
  return normalize(sourceURL)
890
767
  }
891
768
  exports.computeSourceURL = computeSourceURL;
892
- } (util$4));
769
+ } (util$1));
893
770
 
894
771
  var arraySet = {};
895
772
 
@@ -907,7 +784,7 @@ var arraySet = {};
907
784
  * element is O(1). Removing elements from the set is not supported. Only
908
785
  * strings are supported for membership.
909
786
  */
910
- let ArraySet$2 = class ArraySet {
787
+ let ArraySet$1 = class ArraySet {
911
788
  constructor() {
912
789
  this._array = [];
913
790
  this._set = new Map();
@@ -917,7 +794,7 @@ let ArraySet$2 = class ArraySet {
917
794
  * Static method for creating ArraySet instances from an existing array.
918
795
  */
919
796
  static fromArray(aArray, aAllowDuplicates) {
920
- const set = new ArraySet$2();
797
+ const set = new ArraySet();
921
798
  for (let i = 0, len = aArray.length; i < len; i++) {
922
799
  set.add(aArray[i], aAllowDuplicates);
923
800
  }
@@ -993,531 +870,7 @@ let ArraySet$2 = class ArraySet {
993
870
  return this._array.slice()
994
871
  }
995
872
  };
996
- arraySet.ArraySet = ArraySet$2;
997
-
998
- var mappingList = {};
999
-
1000
- /* -*- Mode: js; js-indent-level: 2; -*- */
1001
-
1002
- /*
1003
- * Copyright 2014 Mozilla Foundation and contributors
1004
- * Licensed under the New BSD license. See LICENSE or:
1005
- * http://opensource.org/licenses/BSD-3-Clause
1006
- */
1007
-
1008
- const util$3 = util$4;
1009
-
1010
- /**
1011
- * Determine whether mappingB is after mappingA with respect to generated
1012
- * position.
1013
- */
1014
- function generatedPositionAfter(mappingA, mappingB) {
1015
- // Optimized for most common case
1016
- const lineA = mappingA.generatedLine;
1017
- const lineB = mappingB.generatedLine;
1018
- const columnA = mappingA.generatedColumn;
1019
- const columnB = mappingB.generatedColumn;
1020
- return (
1021
- lineB > lineA ||
1022
- (lineB == lineA && columnB >= columnA) ||
1023
- util$3.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0
1024
- )
1025
- }
1026
-
1027
- /**
1028
- * A data structure to provide a sorted view of accumulated mappings in a
1029
- * performance conscious manner. It trades a negligible overhead in general
1030
- * case for a large speedup in case of mappings being added in order.
1031
- */
1032
- let MappingList$1 = class MappingList {
1033
- constructor() {
1034
- this._array = [];
1035
- this._sorted = true;
1036
- // Serves as infimum
1037
- this._last = { generatedLine: -1, generatedColumn: 0 };
1038
- }
1039
-
1040
- /**
1041
- * Iterate through internal items. This method takes the same arguments that
1042
- * `Array.prototype.forEach` takes.
1043
- *
1044
- * NOTE: The order of the mappings is NOT guaranteed.
1045
- */
1046
- unsortedForEach(aCallback, aThisArg) {
1047
- this._array.forEach(aCallback, aThisArg);
1048
- }
1049
-
1050
- /**
1051
- * Add the given source mapping.
1052
- *
1053
- * @param Object aMapping
1054
- */
1055
- add(aMapping) {
1056
- if (generatedPositionAfter(this._last, aMapping)) {
1057
- this._last = aMapping;
1058
- this._array.push(aMapping);
1059
- } else {
1060
- this._sorted = false;
1061
- this._array.push(aMapping);
1062
- }
1063
- }
1064
-
1065
- /**
1066
- * Returns the flat, sorted array of mappings. The mappings are sorted by
1067
- * generated position.
1068
- *
1069
- * WARNING: This method returns internal data without copying, for
1070
- * performance. The return value must NOT be mutated, and should be treated as
1071
- * an immutable borrow. If you want to take ownership, you must make your own
1072
- * copy.
1073
- */
1074
- toArray() {
1075
- if (!this._sorted) {
1076
- this._array.sort(util$3.compareByGeneratedPositionsInflated);
1077
- this._sorted = true;
1078
- }
1079
- return this._array
1080
- }
1081
- };
1082
-
1083
- mappingList.MappingList = MappingList$1;
1084
-
1085
- /* -*- Mode: js; js-indent-level: 2; -*- */
1086
-
1087
- /*
1088
- * Copyright 2011 Mozilla Foundation and contributors
1089
- * Licensed under the New BSD license. See LICENSE or:
1090
- * http://opensource.org/licenses/BSD-3-Clause
1091
- */
1092
-
1093
- const base64VLQ = base64Vlq;
1094
- const util$2 = util$4;
1095
- const ArraySet$1 = arraySet.ArraySet;
1096
- const MappingList = mappingList.MappingList;
1097
-
1098
- /**
1099
- * An instance of the SourceMapGenerator represents a source map which is
1100
- * being built incrementally. You may pass an object with the following
1101
- * properties:
1102
- *
1103
- * - file: The filename of the generated source.
1104
- * - sourceRoot: A root for all relative URLs in this source map.
1105
- */
1106
- let SourceMapGenerator$1 = class SourceMapGenerator {
1107
- constructor(aArgs) {
1108
- if (!aArgs) {
1109
- aArgs = {};
1110
- }
1111
- this._file = util$2.getArg(aArgs, 'file', null);
1112
- this._sourceRoot = util$2.getArg(aArgs, 'sourceRoot', null);
1113
- this._skipValidation = util$2.getArg(aArgs, 'skipValidation', false);
1114
- this._sources = new ArraySet$1();
1115
- this._names = new ArraySet$1();
1116
- this._mappings = new MappingList();
1117
- this._sourcesContents = null;
1118
- }
1119
-
1120
- /**
1121
- * Creates a new SourceMapGenerator based on a SourceMapConsumer
1122
- *
1123
- * @param aSourceMapConsumer The SourceMap.
1124
- */
1125
- static fromSourceMap(aSourceMapConsumer) {
1126
- const sourceRoot = aSourceMapConsumer.sourceRoot;
1127
- const generator = new SourceMapGenerator$1({
1128
- file: aSourceMapConsumer.file,
1129
- sourceRoot,
1130
- });
1131
- aSourceMapConsumer.eachMapping(function (mapping) {
1132
- const newMapping = {
1133
- generated: {
1134
- line: mapping.generatedLine,
1135
- column: mapping.generatedColumn,
1136
- },
1137
- };
1138
-
1139
- if (mapping.source != null) {
1140
- newMapping.source = mapping.source;
1141
- if (sourceRoot != null) {
1142
- newMapping.source = util$2.relative(sourceRoot, newMapping.source);
1143
- }
1144
-
1145
- newMapping.original = {
1146
- line: mapping.originalLine,
1147
- column: mapping.originalColumn,
1148
- };
1149
-
1150
- if (mapping.name != null) {
1151
- newMapping.name = mapping.name;
1152
- }
1153
- }
1154
-
1155
- generator.addMapping(newMapping);
1156
- });
1157
- aSourceMapConsumer.sources.forEach(function (sourceFile) {
1158
- let sourceRelative = sourceFile;
1159
- if (sourceRoot !== null) {
1160
- sourceRelative = util$2.relative(sourceRoot, sourceFile);
1161
- }
1162
-
1163
- if (!generator._sources.has(sourceRelative)) {
1164
- generator._sources.add(sourceRelative);
1165
- }
1166
-
1167
- const content = aSourceMapConsumer.sourceContentFor(sourceFile);
1168
- if (content != null) {
1169
- generator.setSourceContent(sourceFile, content);
1170
- }
1171
- });
1172
- return generator
1173
- }
1174
-
1175
- /**
1176
- * Add a single mapping from original source line and column to the generated
1177
- * source's line and column for this source map being created. The mapping
1178
- * object should have the following properties:
1179
- *
1180
- * - generated: An object with the generated line and column positions.
1181
- * - original: An object with the original line and column positions.
1182
- * - source: The original source file (relative to the sourceRoot).
1183
- * - name: An optional original token name for this mapping.
1184
- */
1185
- addMapping(aArgs) {
1186
- const generated = util$2.getArg(aArgs, 'generated');
1187
- const original = util$2.getArg(aArgs, 'original', null);
1188
- let source = util$2.getArg(aArgs, 'source', null);
1189
- let name = util$2.getArg(aArgs, 'name', null);
1190
-
1191
- if (!this._skipValidation) {
1192
- this._validateMapping(generated, original, source, name);
1193
- }
1194
-
1195
- if (source != null) {
1196
- source = String(source);
1197
- if (!this._sources.has(source)) {
1198
- this._sources.add(source);
1199
- }
1200
- }
1201
-
1202
- if (name != null) {
1203
- name = String(name);
1204
- if (!this._names.has(name)) {
1205
- this._names.add(name);
1206
- }
1207
- }
1208
-
1209
- this._mappings.add({
1210
- generatedLine: generated.line,
1211
- generatedColumn: generated.column,
1212
- originalLine: original != null && original.line,
1213
- originalColumn: original != null && original.column,
1214
- source,
1215
- name,
1216
- });
1217
- }
1218
-
1219
- /**
1220
- * Set the source content for a source file.
1221
- */
1222
- setSourceContent(aSourceFile, aSourceContent) {
1223
- let source = aSourceFile;
1224
- if (this._sourceRoot != null) {
1225
- source = util$2.relative(this._sourceRoot, source);
1226
- }
1227
-
1228
- if (aSourceContent != null) {
1229
- // Add the source content to the _sourcesContents map.
1230
- // Create a new _sourcesContents map if the property is null.
1231
- if (!this._sourcesContents) {
1232
- this._sourcesContents = Object.create(null);
1233
- }
1234
- this._sourcesContents[util$2.toSetString(source)] = aSourceContent;
1235
- } else if (this._sourcesContents) {
1236
- // Remove the source file from the _sourcesContents map.
1237
- // If the _sourcesContents map is empty, set the property to null.
1238
- delete this._sourcesContents[util$2.toSetString(source)];
1239
- if (Object.keys(this._sourcesContents).length === 0) {
1240
- this._sourcesContents = null;
1241
- }
1242
- }
1243
- }
1244
-
1245
- /**
1246
- * Applies the mappings of a sub-source-map for a specific source file to the
1247
- * source map being generated. Each mapping to the supplied source file is
1248
- * rewritten using the supplied source map. Note: The resolution for the
1249
- * resulting mappings is the minimium of this map and the supplied map.
1250
- *
1251
- * @param aSourceMapConsumer The source map to be applied.
1252
- * @param aSourceFile Optional. The filename of the source file.
1253
- * If omitted, SourceMapConsumer's file property will be used.
1254
- * @param aSourceMapPath Optional. The dirname of the path to the source map
1255
- * to be applied. If relative, it is relative to the SourceMapConsumer.
1256
- * This parameter is needed when the two source maps aren't in the same
1257
- * directory, and the source map to be applied contains relative source
1258
- * paths. If so, those relative source paths need to be rewritten
1259
- * relative to the SourceMapGenerator.
1260
- */
1261
- applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
1262
- let sourceFile = aSourceFile;
1263
- // If aSourceFile is omitted, we will use the file property of the SourceMap
1264
- if (aSourceFile == null) {
1265
- if (aSourceMapConsumer.file == null) {
1266
- throw new Error(
1267
- 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
1268
- 'or the source map\'s "file" property. Both were omitted.'
1269
- )
1270
- }
1271
- sourceFile = aSourceMapConsumer.file;
1272
- }
1273
- const sourceRoot = this._sourceRoot;
1274
- // Make "sourceFile" relative if an absolute Url is passed.
1275
- if (sourceRoot != null) {
1276
- sourceFile = util$2.relative(sourceRoot, sourceFile);
1277
- }
1278
- // Applying the SourceMap can add and remove items from the sources and
1279
- // the names array.
1280
- const newSources =
1281
- this._mappings.toArray().length > 0 ? new ArraySet$1() : this._sources;
1282
- const newNames = new ArraySet$1();
1283
-
1284
- // Find mappings for the "sourceFile"
1285
- this._mappings.unsortedForEach(function (mapping) {
1286
- if (mapping.source === sourceFile && mapping.originalLine != null) {
1287
- // Check if it can be mapped by the source map, then update the mapping.
1288
- const original = aSourceMapConsumer.originalPositionFor({
1289
- line: mapping.originalLine,
1290
- column: mapping.originalColumn,
1291
- });
1292
- if (original.source != null) {
1293
- // Copy mapping
1294
- mapping.source = original.source;
1295
- if (aSourceMapPath != null) {
1296
- mapping.source = util$2.join(aSourceMapPath, mapping.source);
1297
- }
1298
- if (sourceRoot != null) {
1299
- mapping.source = util$2.relative(sourceRoot, mapping.source);
1300
- }
1301
- mapping.originalLine = original.line;
1302
- mapping.originalColumn = original.column;
1303
- if (original.name != null) {
1304
- mapping.name = original.name;
1305
- }
1306
- }
1307
- }
1308
-
1309
- const source = mapping.source;
1310
- if (source != null && !newSources.has(source)) {
1311
- newSources.add(source);
1312
- }
1313
-
1314
- const name = mapping.name;
1315
- if (name != null && !newNames.has(name)) {
1316
- newNames.add(name);
1317
- }
1318
- }, this);
1319
- this._sources = newSources;
1320
- this._names = newNames;
1321
-
1322
- // Copy sourcesContents of applied map.
1323
- aSourceMapConsumer.sources.forEach(function (srcFile) {
1324
- const content = aSourceMapConsumer.sourceContentFor(srcFile);
1325
- if (content != null) {
1326
- if (aSourceMapPath != null) {
1327
- srcFile = util$2.join(aSourceMapPath, srcFile);
1328
- }
1329
- if (sourceRoot != null) {
1330
- srcFile = util$2.relative(sourceRoot, srcFile);
1331
- }
1332
- this.setSourceContent(srcFile, content);
1333
- }
1334
- }, this);
1335
- }
1336
-
1337
- /**
1338
- * A mapping can have one of the three levels of data:
1339
- *
1340
- * 1. Just the generated position.
1341
- * 2. The Generated position, original position, and original source.
1342
- * 3. Generated and original position, original source, as well as a name
1343
- * token.
1344
- *
1345
- * To maintain consistency, we validate that any new mapping being added falls
1346
- * in to one of these categories.
1347
- */
1348
- _validateMapping(aGenerated, aOriginal, aSource, aName) {
1349
- // When aOriginal is truthy but has empty values for .line and .column,
1350
- // it is most likely a programmer error. In this case we throw a very
1351
- // specific error message to try to guide them the right way.
1352
- // For example: https://github.com/Polymer/polymer-bundler/pull/519
1353
- if (
1354
- aOriginal &&
1355
- typeof aOriginal.line !== 'number' &&
1356
- typeof aOriginal.column !== 'number'
1357
- ) {
1358
- throw new Error(
1359
- 'original.line and original.column are not numbers -- you probably meant to omit ' +
1360
- 'the original mapping entirely and only map the generated position. If so, pass ' +
1361
- 'null for the original mapping instead of an object with empty or null values.'
1362
- )
1363
- }
1364
-
1365
- if (
1366
- aGenerated &&
1367
- 'line' in aGenerated &&
1368
- 'column' in aGenerated &&
1369
- aGenerated.line > 0 &&
1370
- aGenerated.column >= 0 &&
1371
- !aOriginal &&
1372
- !aSource &&
1373
- !aName
1374
- ) ; else if (
1375
- aGenerated &&
1376
- 'line' in aGenerated &&
1377
- 'column' in aGenerated &&
1378
- aOriginal &&
1379
- 'line' in aOriginal &&
1380
- 'column' in aOriginal &&
1381
- aGenerated.line > 0 &&
1382
- aGenerated.column >= 0 &&
1383
- aOriginal.line > 0 &&
1384
- aOriginal.column >= 0 &&
1385
- aSource
1386
- ) ; else {
1387
- throw new Error(
1388
- 'Invalid mapping: ' +
1389
- JSON.stringify({
1390
- generated: aGenerated,
1391
- source: aSource,
1392
- original: aOriginal,
1393
- name: aName,
1394
- })
1395
- )
1396
- }
1397
- }
1398
-
1399
- /**
1400
- * Serialize the accumulated mappings in to the stream of base 64 VLQs
1401
- * specified by the source map format.
1402
- */
1403
- _serializeMappings() {
1404
- let previousGeneratedColumn = 0;
1405
- let previousGeneratedLine = 1;
1406
- let previousOriginalColumn = 0;
1407
- let previousOriginalLine = 0;
1408
- let previousName = 0;
1409
- let previousSource = 0;
1410
- let result = '';
1411
- let next;
1412
- let mapping;
1413
- let nameIdx;
1414
- let sourceIdx;
1415
-
1416
- const mappings = this._mappings.toArray();
1417
- for (let i = 0, len = mappings.length; i < len; i++) {
1418
- mapping = mappings[i];
1419
- next = '';
1420
-
1421
- if (mapping.generatedLine !== previousGeneratedLine) {
1422
- previousGeneratedColumn = 0;
1423
- while (mapping.generatedLine !== previousGeneratedLine) {
1424
- next += ';';
1425
- previousGeneratedLine++;
1426
- }
1427
- } else if (i > 0) {
1428
- if (
1429
- !util$2.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])
1430
- ) {
1431
- continue
1432
- }
1433
- next += ',';
1434
- }
1435
-
1436
- next += base64VLQ.encode(
1437
- mapping.generatedColumn - previousGeneratedColumn
1438
- );
1439
- previousGeneratedColumn = mapping.generatedColumn;
1440
-
1441
- if (mapping.source != null) {
1442
- sourceIdx = this._sources.indexOf(mapping.source);
1443
- next += base64VLQ.encode(sourceIdx - previousSource);
1444
- previousSource = sourceIdx;
1445
-
1446
- // lines are stored 0-based in SourceMap spec version 3
1447
- next += base64VLQ.encode(
1448
- mapping.originalLine - 1 - previousOriginalLine
1449
- );
1450
- previousOriginalLine = mapping.originalLine - 1;
1451
-
1452
- next += base64VLQ.encode(
1453
- mapping.originalColumn - previousOriginalColumn
1454
- );
1455
- previousOriginalColumn = mapping.originalColumn;
1456
-
1457
- if (mapping.name != null) {
1458
- nameIdx = this._names.indexOf(mapping.name);
1459
- next += base64VLQ.encode(nameIdx - previousName);
1460
- previousName = nameIdx;
1461
- }
1462
- }
1463
-
1464
- result += next;
1465
- }
1466
-
1467
- return result
1468
- }
1469
-
1470
- _generateSourcesContent(aSources, aSourceRoot) {
1471
- return aSources.map(function (source) {
1472
- if (!this._sourcesContents) {
1473
- return null
1474
- }
1475
- if (aSourceRoot != null) {
1476
- source = util$2.relative(aSourceRoot, source);
1477
- }
1478
- const key = util$2.toSetString(source);
1479
- return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
1480
- ? this._sourcesContents[key]
1481
- : null
1482
- }, this)
1483
- }
1484
-
1485
- /**
1486
- * Externalize the source map.
1487
- */
1488
- toJSON() {
1489
- const map = {
1490
- version: this._version,
1491
- sources: this._sources.toArray(),
1492
- names: this._names.toArray(),
1493
- mappings: this._serializeMappings(),
1494
- };
1495
- if (this._file != null) {
1496
- map.file = this._file;
1497
- }
1498
- if (this._sourceRoot != null) {
1499
- map.sourceRoot = this._sourceRoot;
1500
- }
1501
- if (this._sourcesContents) {
1502
- map.sourcesContent = this._generateSourcesContent(
1503
- map.sources,
1504
- map.sourceRoot
1505
- );
1506
- }
1507
-
1508
- return map
1509
- }
1510
-
1511
- /**
1512
- * Render the source map being generated to a string.
1513
- */
1514
- toString() {
1515
- return JSON.stringify(this.toJSON())
1516
- }
1517
- };
1518
-
1519
- SourceMapGenerator$1.prototype._version = 3;
1520
- sourceMapGenerator.SourceMapGenerator = SourceMapGenerator$1;
873
+ arraySet.ArraySet = ArraySet$1;
1521
874
 
1522
875
  var sourceMapConsumer = {};
1523
876
 
@@ -1824,7 +1177,7 @@ var wasm$1 = function wasm() {
1824
1177
  * http://opensource.org/licenses/BSD-3-Clause
1825
1178
  */
1826
1179
 
1827
- const util$1 = util$4;
1180
+ const util = util$1;
1828
1181
  const binarySearch = binarySearch$1;
1829
1182
  const ArraySet = arraySet.ArraySet;
1830
1183
  const readWasm = readWasmExports;
@@ -1883,7 +1236,7 @@ let SourceMapConsumer$1 = class SourceMapConsumer {
1883
1236
  * ```
1884
1237
  */
1885
1238
  static async with(rawSourceMap, sourceMapUrl, f) {
1886
- const consumer = await new SourceMapConsumer$1(rawSourceMap, sourceMapUrl);
1239
+ const consumer = await new SourceMapConsumer(rawSourceMap, sourceMapUrl);
1887
1240
  try {
1888
1241
  return await f(consumer)
1889
1242
  } finally {
@@ -2002,18 +1355,18 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2002
1355
  return super(INTERNAL).then((that) => {
2003
1356
  let sourceMap = aSourceMap;
2004
1357
  if (typeof aSourceMap === 'string') {
2005
- sourceMap = util$1.parseSourceMapInput(aSourceMap);
1358
+ sourceMap = util.parseSourceMapInput(aSourceMap);
2006
1359
  }
2007
1360
 
2008
- const version = util$1.getArg(sourceMap, 'version');
2009
- let sources = util$1.getArg(sourceMap, 'sources');
1361
+ const version = util.getArg(sourceMap, 'version');
1362
+ let sources = util.getArg(sourceMap, 'sources');
2010
1363
  // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
2011
1364
  // requires the array) to play nice here.
2012
- const names = util$1.getArg(sourceMap, 'names', []);
2013
- let sourceRoot = util$1.getArg(sourceMap, 'sourceRoot', null);
2014
- const sourcesContent = util$1.getArg(sourceMap, 'sourcesContent', null);
2015
- const mappings = util$1.getArg(sourceMap, 'mappings');
2016
- const file = util$1.getArg(sourceMap, 'file', null);
1365
+ const names = util.getArg(sourceMap, 'names', []);
1366
+ let sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
1367
+ const sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
1368
+ const mappings = util.getArg(sourceMap, 'mappings');
1369
+ const file = util.getArg(sourceMap, 'file', null);
2017
1370
 
2018
1371
  // Once again, Sass deviates from the spec and supplies the version as a
2019
1372
  // string rather than a number, so we use loose equality checking here.
@@ -2022,7 +1375,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2022
1375
  }
2023
1376
 
2024
1377
  if (sourceRoot) {
2025
- sourceRoot = util$1.normalize(sourceRoot);
1378
+ sourceRoot = util.normalize(sourceRoot);
2026
1379
  }
2027
1380
 
2028
1381
  sources = sources
@@ -2030,16 +1383,16 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2030
1383
  // Some source maps produce relative source paths like "./foo.js" instead of
2031
1384
  // "foo.js". Normalize these first so that future comparisons will succeed.
2032
1385
  // See bugzil.la/1090768.
2033
- .map(util$1.normalize)
1386
+ .map(util.normalize)
2034
1387
  // Always ensure that absolute sources are internally stored relative to
2035
1388
  // the source root, if the source root is absolute. Not doing this would
2036
1389
  // be particularly problematic when the source root is a prefix of the
2037
1390
  // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
2038
1391
  .map(function (source) {
2039
1392
  return sourceRoot &&
2040
- util$1.isAbsolute(sourceRoot) &&
2041
- util$1.isAbsolute(source)
2042
- ? util$1.relative(sourceRoot, source)
1393
+ util.isAbsolute(sourceRoot) &&
1394
+ util.isAbsolute(source)
1395
+ ? util.relative(sourceRoot, source)
2043
1396
  : source
2044
1397
  });
2045
1398
 
@@ -2051,7 +1404,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2051
1404
  that._sources = ArraySet.fromArray(sources, true);
2052
1405
 
2053
1406
  that._absoluteSources = that._sources.toArray().map(function (s) {
2054
- return util$1.computeSourceURL(sourceRoot, s, aSourceMapURL)
1407
+ return util.computeSourceURL(sourceRoot, s, aSourceMapURL)
2055
1408
  });
2056
1409
 
2057
1410
  that.sourceRoot = sourceRoot;
@@ -2078,7 +1431,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2078
1431
  _findSourceIndex(aSource) {
2079
1432
  let relativeSource = aSource;
2080
1433
  if (this.sourceRoot != null) {
2081
- relativeSource = util$1.relative(this.sourceRoot, relativeSource);
1434
+ relativeSource = util.relative(this.sourceRoot, relativeSource);
2082
1435
  }
2083
1436
 
2084
1437
  if (this._sources.has(relativeSource)) {
@@ -2180,7 +1533,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2180
1533
  (mapping) => {
2181
1534
  if (mapping.source !== null) {
2182
1535
  mapping.source = this._sources.at(mapping.source);
2183
- mapping.source = util$1.computeSourceURL(
1536
+ mapping.source = util.computeSourceURL(
2184
1537
  sourceRoot,
2185
1538
  mapping.source,
2186
1539
  this._sourceMapURL
@@ -2209,8 +1562,8 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2209
1562
  }
2210
1563
 
2211
1564
  allGeneratedPositionsFor(aArgs) {
2212
- let source = util$1.getArg(aArgs, 'source');
2213
- const originalLine = util$1.getArg(aArgs, 'line');
1565
+ let source = util.getArg(aArgs, 'source');
1566
+ const originalLine = util.getArg(aArgs, 'line');
2214
1567
  const originalColumn = aArgs.column || 0;
2215
1568
 
2216
1569
  source = this._findSourceIndex(source);
@@ -2300,8 +1653,8 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2300
1653
  */
2301
1654
  originalPositionFor(aArgs) {
2302
1655
  const needle = {
2303
- generatedLine: util$1.getArg(aArgs, 'line'),
2304
- generatedColumn: util$1.getArg(aArgs, 'column'),
1656
+ generatedLine: util.getArg(aArgs, 'line'),
1657
+ generatedColumn: util.getArg(aArgs, 'column'),
2305
1658
  };
2306
1659
 
2307
1660
  if (needle.generatedLine < 1) {
@@ -2312,7 +1665,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2312
1665
  throw new Error('Column numbers must be >= 0')
2313
1666
  }
2314
1667
 
2315
- let bias = util$1.getArg(
1668
+ let bias = util.getArg(
2316
1669
  aArgs,
2317
1670
  'bias',
2318
1671
  SourceMapConsumer$1.GREATEST_LOWER_BOUND
@@ -2336,25 +1689,25 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2336
1689
 
2337
1690
  if (mapping) {
2338
1691
  if (mapping.generatedLine === needle.generatedLine) {
2339
- let source = util$1.getArg(mapping, 'source', null);
1692
+ let source = util.getArg(mapping, 'source', null);
2340
1693
  if (source !== null) {
2341
1694
  source = this._sources.at(source);
2342
- source = util$1.computeSourceURL(
1695
+ source = util.computeSourceURL(
2343
1696
  this.sourceRoot,
2344
1697
  source,
2345
1698
  this._sourceMapURL
2346
1699
  );
2347
1700
  }
2348
1701
 
2349
- let name = util$1.getArg(mapping, 'name', null);
1702
+ let name = util.getArg(mapping, 'name', null);
2350
1703
  if (name !== null) {
2351
1704
  name = this._names.at(name);
2352
1705
  }
2353
1706
 
2354
1707
  return {
2355
1708
  source,
2356
- line: util$1.getArg(mapping, 'originalLine', null),
2357
- column: util$1.getArg(mapping, 'originalColumn', null),
1709
+ line: util.getArg(mapping, 'originalLine', null),
1710
+ column: util.getArg(mapping, 'originalColumn', null),
2358
1711
  name,
2359
1712
  }
2360
1713
  }
@@ -2401,11 +1754,11 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2401
1754
 
2402
1755
  let relativeSource = aSource;
2403
1756
  if (this.sourceRoot != null) {
2404
- relativeSource = util$1.relative(this.sourceRoot, relativeSource);
1757
+ relativeSource = util.relative(this.sourceRoot, relativeSource);
2405
1758
  }
2406
1759
 
2407
1760
  let url;
2408
- if (this.sourceRoot != null && (url = util$1.urlParse(this.sourceRoot))) {
1761
+ if (this.sourceRoot != null && (url = util.urlParse(this.sourceRoot))) {
2409
1762
  // XXX: file:// URIs and absolute paths lead to unexpected behavior for
2410
1763
  // many users. We can help them out when they expect file:// URIs to
2411
1764
  // behave like it would if they were running a local HTTP server. See
@@ -2458,7 +1811,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2458
1811
  * The column number is 0-based.
2459
1812
  */
2460
1813
  generatedPositionFor(aArgs) {
2461
- let source = util$1.getArg(aArgs, 'source');
1814
+ let source = util.getArg(aArgs, 'source');
2462
1815
  source = this._findSourceIndex(source);
2463
1816
  if (source < 0) {
2464
1817
  return {
@@ -2470,8 +1823,8 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2470
1823
 
2471
1824
  const needle = {
2472
1825
  source,
2473
- originalLine: util$1.getArg(aArgs, 'line'),
2474
- originalColumn: util$1.getArg(aArgs, 'column'),
1826
+ originalLine: util.getArg(aArgs, 'line'),
1827
+ originalColumn: util.getArg(aArgs, 'column'),
2475
1828
  };
2476
1829
 
2477
1830
  if (needle.originalLine < 1) {
@@ -2482,7 +1835,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2482
1835
  throw new Error('Column numbers must be >= 0')
2483
1836
  }
2484
1837
 
2485
- let bias = util$1.getArg(
1838
+ let bias = util.getArg(
2486
1839
  aArgs,
2487
1840
  'bias',
2488
1841
  SourceMapConsumer$1.GREATEST_LOWER_BOUND
@@ -2512,8 +1865,8 @@ class BasicSourceMapConsumer extends SourceMapConsumer$1 {
2512
1865
  lastColumn = Infinity;
2513
1866
  }
2514
1867
  return {
2515
- line: util$1.getArg(mapping, 'generatedLine', null),
2516
- column: util$1.getArg(mapping, 'generatedColumn', null),
1868
+ line: util.getArg(mapping, 'generatedLine', null),
1869
+ column: util.getArg(mapping, 'generatedColumn', null),
2517
1870
  lastColumn,
2518
1871
  }
2519
1872
  }
@@ -2584,11 +1937,11 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2584
1937
  return super(INTERNAL).then((that) => {
2585
1938
  let sourceMap = aSourceMap;
2586
1939
  if (typeof aSourceMap === 'string') {
2587
- sourceMap = util$1.parseSourceMapInput(aSourceMap);
1940
+ sourceMap = util.parseSourceMapInput(aSourceMap);
2588
1941
  }
2589
1942
 
2590
- const version = util$1.getArg(sourceMap, 'version');
2591
- const sections = util$1.getArg(sourceMap, 'sections');
1943
+ const version = util.getArg(sourceMap, 'version');
1944
+ const sections = util.getArg(sourceMap, 'sections');
2592
1945
 
2593
1946
  if (version != that._version) {
2594
1947
  throw new Error('Unsupported version: ' + version)
@@ -2614,9 +1967,9 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2614
1967
  'Support for url field in sections not implemented.'
2615
1968
  )
2616
1969
  }
2617
- const offset = util$1.getArg(s, 'offset');
2618
- const offsetLine = util$1.getArg(offset, 'line');
2619
- const offsetColumn = util$1.getArg(offset, 'column');
1970
+ const offset = util.getArg(s, 'offset');
1971
+ const offsetLine = util.getArg(offset, 'line');
1972
+ const offsetColumn = util.getArg(offset, 'column');
2620
1973
 
2621
1974
  if (
2622
1975
  offsetLine < lastOffset.line ||
@@ -2629,7 +1982,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2629
1982
  lastOffset = offset;
2630
1983
 
2631
1984
  const cons = new SourceMapConsumer$1(
2632
- util$1.getArg(s, 'map'),
1985
+ util.getArg(s, 'map'),
2633
1986
  aSourceMapURL
2634
1987
  );
2635
1988
  return cons.then((consumer) => {
@@ -2714,13 +2067,13 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2714
2067
 
2715
2068
  _sortGeneratedMappings() {
2716
2069
  const mappings = this._generatedMappingsUnsorted;
2717
- mappings.sort(util$1.compareByGeneratedPositionsDeflated);
2070
+ mappings.sort(util.compareByGeneratedPositionsDeflated);
2718
2071
  this.__generatedMappings = mappings;
2719
2072
  }
2720
2073
 
2721
2074
  _sortOriginalMappings() {
2722
2075
  const mappings = this._originalMappingsUnsorted;
2723
- mappings.sort(util$1.compareByOriginalPositions);
2076
+ mappings.sort(util.compareByOriginalPositions);
2724
2077
  this.__originalMappings = mappings;
2725
2078
  }
2726
2079
 
@@ -2758,8 +2111,8 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2758
2111
  */
2759
2112
  originalPositionFor(aArgs) {
2760
2113
  const needle = {
2761
- generatedLine: util$1.getArg(aArgs, 'line'),
2762
- generatedColumn: util$1.getArg(aArgs, 'column'),
2114
+ generatedLine: util.getArg(aArgs, 'line'),
2115
+ generatedColumn: util.getArg(aArgs, 'column'),
2763
2116
  };
2764
2117
 
2765
2118
  // Find the section containing the generated position we're trying to map
@@ -2854,7 +2207,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2854
2207
  // Only consider this section if the requested source is in the list of
2855
2208
  // sources of the consumer.
2856
2209
  if (
2857
- section.consumer._findSourceIndex(util$1.getArg(aArgs, 'source')) === -1
2210
+ section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1
2858
2211
  ) {
2859
2212
  continue
2860
2213
  }
@@ -2901,7 +2254,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2901
2254
  // `source`, which would actually have gotten used as null because
2902
2255
  // var's get hoisted.
2903
2256
  // See: https://github.com/mozilla/source-map/issues/333
2904
- let source = util$1.computeSourceURL(
2257
+ let source = util.computeSourceURL(
2905
2258
  section.consumer.sourceRoot,
2906
2259
  null,
2907
2260
  this._sourceMapURL
@@ -2963,7 +2316,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
2963
2316
  let source = null;
2964
2317
  if (mapping.source !== null) {
2965
2318
  source = this._sources.at(mapping.source);
2966
- source = util$1.computeSourceURL(sourceRoot, source, this._sourceMapURL);
2319
+ source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
2967
2320
  }
2968
2321
  return {
2969
2322
  source,
@@ -3002,16 +2355,16 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
3002
2355
  }
3003
2356
 
3004
2357
  allGeneratedPositionsFor(aArgs) {
3005
- const line = util$1.getArg(aArgs, 'line');
2358
+ const line = util.getArg(aArgs, 'line');
3006
2359
 
3007
2360
  // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
3008
2361
  // returns the index of the closest mapping less than the needle. By
3009
2362
  // setting needle.originalColumn to 0, we thus find the last mapping for
3010
2363
  // the given line, provided such a mapping exists.
3011
2364
  const needle = {
3012
- source: util$1.getArg(aArgs, 'source'),
2365
+ source: util.getArg(aArgs, 'source'),
3013
2366
  originalLine: line,
3014
- originalColumn: util$1.getArg(aArgs, 'column', 0),
2367
+ originalColumn: util.getArg(aArgs, 'column', 0),
3015
2368
  };
3016
2369
 
3017
2370
  needle.source = this._findSourceIndex(needle.source);
@@ -3034,7 +2387,7 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
3034
2387
  this._originalMappings,
3035
2388
  'originalLine',
3036
2389
  'originalColumn',
3037
- util$1.compareByOriginalPositions,
2390
+ util.compareByOriginalPositions,
3038
2391
  binarySearch.LEAST_UPPER_BOUND
3039
2392
  );
3040
2393
  if (index >= 0) {
@@ -3053,8 +2406,8 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
3053
2406
  lastColumn = Infinity;
3054
2407
  }
3055
2408
  mappings.push({
3056
- line: util$1.getArg(mapping, 'generatedLine', null),
3057
- column: util$1.getArg(mapping, 'generatedColumn', null),
2409
+ line: util.getArg(mapping, 'generatedLine', null),
2410
+ column: util.getArg(mapping, 'generatedColumn', null),
3058
2411
  lastColumn,
3059
2412
  });
3060
2413
 
@@ -3077,8 +2430,8 @@ class IndexedSourceMapConsumer extends SourceMapConsumer$1 {
3077
2430
  lastColumn = Infinity;
3078
2431
  }
3079
2432
  mappings.push({
3080
- line: util$1.getArg(mapping, 'generatedLine', null),
3081
- column: util$1.getArg(mapping, 'generatedColumn', null),
2433
+ line: util.getArg(mapping, 'generatedLine', null),
2434
+ column: util.getArg(mapping, 'generatedColumn', null),
3082
2435
  lastColumn,
3083
2436
  });
3084
2437
 
@@ -3105,7 +2458,7 @@ sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
3105
2458
  function _factory(aSourceMap, aSourceMapURL) {
3106
2459
  let sourceMap = aSourceMap;
3107
2460
  if (typeof aSourceMap === 'string') {
3108
- sourceMap = util$1.parseSourceMapInput(aSourceMap);
2461
+ sourceMap = util.parseSourceMapInput(aSourceMap);
3109
2462
  }
3110
2463
 
3111
2464
  const consumer =
@@ -3119,449 +2472,12 @@ function _factoryBSM(aSourceMap, aSourceMapURL) {
3119
2472
  return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL)
3120
2473
  }
3121
2474
 
3122
- var sourceNode = {};
3123
-
3124
- /* -*- Mode: js; js-indent-level: 2; -*- */
3125
-
3126
- /*
3127
- * Copyright 2011 Mozilla Foundation and contributors
3128
- * Licensed under the New BSD license. See LICENSE or:
3129
- * http://opensource.org/licenses/BSD-3-Clause
3130
- */
3131
-
3132
- const SourceMapGenerator = sourceMapGenerator.SourceMapGenerator;
3133
- const util = util$4;
3134
-
3135
- // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
3136
- // operating systems these days (capturing the result).
3137
- const REGEX_NEWLINE = /(\r?\n)/;
3138
-
3139
- // Newline character code for charCodeAt() comparisons
3140
- const NEWLINE_CODE = 10;
3141
-
3142
- // Private symbol for identifying `SourceNode`s when multiple versions of
3143
- // the source-map library are loaded. This MUST NOT CHANGE across
3144
- // versions!
3145
- const isSourceNode = '$$$isSourceNode$$$';
3146
-
3147
- /**
3148
- * SourceNodes provide a way to abstract over interpolating/concatenating
3149
- * snippets of generated JavaScript source code while maintaining the line and
3150
- * column information associated with the original source code.
3151
- *
3152
- * @param aLine The original line number.
3153
- * @param aColumn The original column number.
3154
- * @param aSource The original source's filename.
3155
- * @param aChunks Optional. An array of strings which are snippets of
3156
- * generated JS, or other SourceNodes.
3157
- * @param aName The original identifier.
3158
- */
3159
- class SourceNode {
3160
- constructor(aLine, aColumn, aSource, aChunks, aName) {
3161
- this.children = [];
3162
- this.sourceContents = {};
3163
- this.line = aLine == null ? null : aLine;
3164
- this.column = aColumn == null ? null : aColumn;
3165
- this.source = aSource == null ? null : aSource;
3166
- this.name = aName == null ? null : aName;
3167
- this[isSourceNode] = true;
3168
- if (aChunks != null) this.add(aChunks);
3169
- }
3170
-
3171
- /**
3172
- * Creates a SourceNode from generated code and a SourceMapConsumer.
3173
- *
3174
- * @param aGeneratedCode The generated code
3175
- * @param aSourceMapConsumer The SourceMap for the generated code
3176
- * @param aRelativePath Optional. The path that relative sources in the
3177
- * SourceMapConsumer should be relative to.
3178
- */
3179
- static fromStringWithSourceMap(
3180
- aGeneratedCode,
3181
- aSourceMapConsumer,
3182
- aRelativePath
3183
- ) {
3184
- // The SourceNode we want to fill with the generated code
3185
- // and the SourceMap
3186
- const node = new SourceNode();
3187
-
3188
- // All even indices of this array are one line of the generated code,
3189
- // while all odd indices are the newlines between two adjacent lines
3190
- // (since `REGEX_NEWLINE` captures its match).
3191
- // Processed fragments are accessed by calling `shiftNextLine`.
3192
- const remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
3193
- let remainingLinesIndex = 0;
3194
- const shiftNextLine = function () {
3195
- const lineContents = getNextLine();
3196
- // The last line of a file might not have a newline.
3197
- const newLine = getNextLine() || '';
3198
- return lineContents + newLine
3199
-
3200
- function getNextLine() {
3201
- return remainingLinesIndex < remainingLines.length
3202
- ? remainingLines[remainingLinesIndex++]
3203
- : undefined
3204
- }
3205
- };
3206
-
3207
- // We need to remember the position of "remainingLines"
3208
- let lastGeneratedLine = 1,
3209
- lastGeneratedColumn = 0;
3210
-
3211
- // The generate SourceNodes we need a code range.
3212
- // To extract it current and last mapping is used.
3213
- // Here we store the last mapping.
3214
- let lastMapping = null;
3215
- let nextLine;
3216
-
3217
- aSourceMapConsumer.eachMapping(function (mapping) {
3218
- if (lastMapping !== null) {
3219
- // We add the code from "lastMapping" to "mapping":
3220
- // First check if there is a new line in between.
3221
- if (lastGeneratedLine < mapping.generatedLine) {
3222
- // Associate first line with "lastMapping"
3223
- addMappingWithCode(lastMapping, shiftNextLine());
3224
- lastGeneratedLine++;
3225
- lastGeneratedColumn = 0;
3226
- // The remaining code is added without mapping
3227
- } else {
3228
- // There is no new line in between.
3229
- // Associate the code between "lastGeneratedColumn" and
3230
- // "mapping.generatedColumn" with "lastMapping"
3231
- nextLine = remainingLines[remainingLinesIndex] || '';
3232
- const code = nextLine.substr(
3233
- 0,
3234
- mapping.generatedColumn - lastGeneratedColumn
3235
- );
3236
- remainingLines[remainingLinesIndex] = nextLine.substr(
3237
- mapping.generatedColumn - lastGeneratedColumn
3238
- );
3239
- lastGeneratedColumn = mapping.generatedColumn;
3240
- addMappingWithCode(lastMapping, code);
3241
- // No more remaining code, continue
3242
- lastMapping = mapping;
3243
- return
3244
- }
3245
- }
3246
- // We add the generated code until the first mapping
3247
- // to the SourceNode without any mapping.
3248
- // Each line is added as separate string.
3249
- while (lastGeneratedLine < mapping.generatedLine) {
3250
- node.add(shiftNextLine());
3251
- lastGeneratedLine++;
3252
- }
3253
- if (lastGeneratedColumn < mapping.generatedColumn) {
3254
- nextLine = remainingLines[remainingLinesIndex] || '';
3255
- node.add(nextLine.substr(0, mapping.generatedColumn));
3256
- remainingLines[remainingLinesIndex] = nextLine.substr(
3257
- mapping.generatedColumn
3258
- );
3259
- lastGeneratedColumn = mapping.generatedColumn;
3260
- }
3261
- lastMapping = mapping;
3262
- }, this);
3263
- // We have processed all mappings.
3264
- if (remainingLinesIndex < remainingLines.length) {
3265
- if (lastMapping) {
3266
- // Associate the remaining code in the current line with "lastMapping"
3267
- addMappingWithCode(lastMapping, shiftNextLine());
3268
- }
3269
- // and add the remaining lines without any mapping
3270
- node.add(remainingLines.splice(remainingLinesIndex).join(''));
3271
- }
3272
-
3273
- // Copy sourcesContent into SourceNode
3274
- aSourceMapConsumer.sources.forEach(function (sourceFile) {
3275
- const content = aSourceMapConsumer.sourceContentFor(sourceFile);
3276
- if (content != null) {
3277
- if (aRelativePath != null) {
3278
- sourceFile = util.join(aRelativePath, sourceFile);
3279
- }
3280
- node.setSourceContent(sourceFile, content);
3281
- }
3282
- });
3283
-
3284
- return node
3285
-
3286
- function addMappingWithCode(mapping, code) {
3287
- if (mapping === null || mapping.source === undefined) {
3288
- node.add(code);
3289
- } else {
3290
- const source = aRelativePath
3291
- ? util.join(aRelativePath, mapping.source)
3292
- : mapping.source;
3293
- node.add(
3294
- new SourceNode(
3295
- mapping.originalLine,
3296
- mapping.originalColumn,
3297
- source,
3298
- code,
3299
- mapping.name
3300
- )
3301
- );
3302
- }
3303
- }
3304
- }
3305
-
3306
- /**
3307
- * Add a chunk of generated JS to this source node.
3308
- *
3309
- * @param aChunk A string snippet of generated JS code, another instance of
3310
- * SourceNode, or an array where each member is one of those things.
3311
- */
3312
- add(aChunk) {
3313
- if (Array.isArray(aChunk)) {
3314
- aChunk.forEach(function (chunk) {
3315
- this.add(chunk);
3316
- }, this);
3317
- } else if (aChunk[isSourceNode] || typeof aChunk === 'string') {
3318
- if (aChunk) {
3319
- this.children.push(aChunk);
3320
- }
3321
- } else {
3322
- throw new TypeError(
3323
- 'Expected a SourceNode, string, or an array of SourceNodes and strings. Got ' +
3324
- aChunk
3325
- )
3326
- }
3327
- return this
3328
- }
3329
-
3330
- /**
3331
- * Add a chunk of generated JS to the beginning of this source node.
3332
- *
3333
- * @param aChunk A string snippet of generated JS code, another instance of
3334
- * SourceNode, or an array where each member is one of those things.
3335
- */
3336
- prepend(aChunk) {
3337
- if (Array.isArray(aChunk)) {
3338
- for (let i = aChunk.length - 1; i >= 0; i--) {
3339
- this.prepend(aChunk[i]);
3340
- }
3341
- } else if (aChunk[isSourceNode] || typeof aChunk === 'string') {
3342
- this.children.unshift(aChunk);
3343
- } else {
3344
- throw new TypeError(
3345
- 'Expected a SourceNode, string, or an array of SourceNodes and strings. Got ' +
3346
- aChunk
3347
- )
3348
- }
3349
- return this
3350
- }
3351
-
3352
- /**
3353
- * Walk over the tree of JS snippets in this node and its children. The
3354
- * walking function is called once for each snippet of JS and is passed that
3355
- * snippet and the its original associated source's line/column location.
3356
- *
3357
- * @param aFn The traversal function.
3358
- */
3359
- walk(aFn) {
3360
- let chunk;
3361
- for (let i = 0, len = this.children.length; i < len; i++) {
3362
- chunk = this.children[i];
3363
- if (chunk[isSourceNode]) {
3364
- chunk.walk(aFn);
3365
- } else if (chunk !== '') {
3366
- aFn(chunk, {
3367
- source: this.source,
3368
- line: this.line,
3369
- column: this.column,
3370
- name: this.name,
3371
- });
3372
- }
3373
- }
3374
- }
3375
-
3376
- /**
3377
- * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
3378
- * each of `this.children`.
3379
- *
3380
- * @param aSep The separator.
3381
- */
3382
- join(aSep) {
3383
- let newChildren;
3384
- let i;
3385
- const len = this.children.length;
3386
- if (len > 0) {
3387
- newChildren = [];
3388
- for (i = 0; i < len - 1; i++) {
3389
- newChildren.push(this.children[i]);
3390
- newChildren.push(aSep);
3391
- }
3392
- newChildren.push(this.children[i]);
3393
- this.children = newChildren;
3394
- }
3395
- return this
3396
- }
3397
-
3398
- /**
3399
- * Call String.prototype.replace on the very right-most source snippet. Useful
3400
- * for trimming whitespace from the end of a source node, etc.
3401
- *
3402
- * @param aPattern The pattern to replace.
3403
- * @param aReplacement The thing to replace the pattern with.
3404
- */
3405
- replaceRight(aPattern, aReplacement) {
3406
- const lastChild = this.children[this.children.length - 1];
3407
- if (lastChild[isSourceNode]) {
3408
- lastChild.replaceRight(aPattern, aReplacement);
3409
- } else if (typeof lastChild === 'string') {
3410
- this.children[this.children.length - 1] = lastChild.replace(
3411
- aPattern,
3412
- aReplacement
3413
- );
3414
- } else {
3415
- this.children.push(''.replace(aPattern, aReplacement));
3416
- }
3417
- return this
3418
- }
3419
-
3420
- /**
3421
- * Set the source content for a source file. This will be added to the SourceMapGenerator
3422
- * in the sourcesContent field.
3423
- *
3424
- * @param aSourceFile The filename of the source file
3425
- * @param aSourceContent The content of the source file
3426
- */
3427
- setSourceContent(aSourceFile, aSourceContent) {
3428
- this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
3429
- }
3430
-
3431
- /**
3432
- * Walk over the tree of SourceNodes. The walking function is called for each
3433
- * source file content and is passed the filename and source content.
3434
- *
3435
- * @param aFn The traversal function.
3436
- */
3437
- walkSourceContents(aFn) {
3438
- for (let i = 0, len = this.children.length; i < len; i++) {
3439
- if (this.children[i][isSourceNode]) {
3440
- this.children[i].walkSourceContents(aFn);
3441
- }
3442
- }
3443
-
3444
- const sources = Object.keys(this.sourceContents);
3445
- for (let i = 0, len = sources.length; i < len; i++) {
3446
- aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
3447
- }
3448
- }
3449
-
3450
- /**
3451
- * Return the string representation of this source node. Walks over the tree
3452
- * and concatenates all the various snippets together to one string.
3453
- */
3454
- toString() {
3455
- let str = '';
3456
- this.walk(function (chunk) {
3457
- str += chunk;
3458
- });
3459
- return str
3460
- }
3461
-
3462
- /**
3463
- * Returns the string representation of this source node along with a source
3464
- * map.
3465
- */
3466
- toStringWithSourceMap(aArgs) {
3467
- const generated = {
3468
- code: '',
3469
- line: 1,
3470
- column: 0,
3471
- };
3472
- const map = new SourceMapGenerator(aArgs);
3473
- let sourceMappingActive = false;
3474
- let lastOriginalSource = null;
3475
- let lastOriginalLine = null;
3476
- let lastOriginalColumn = null;
3477
- let lastOriginalName = null;
3478
- this.walk(function (chunk, original) {
3479
- generated.code += chunk;
3480
- if (
3481
- original.source !== null &&
3482
- original.line !== null &&
3483
- original.column !== null
3484
- ) {
3485
- if (
3486
- lastOriginalSource !== original.source ||
3487
- lastOriginalLine !== original.line ||
3488
- lastOriginalColumn !== original.column ||
3489
- lastOriginalName !== original.name
3490
- ) {
3491
- map.addMapping({
3492
- source: original.source,
3493
- original: {
3494
- line: original.line,
3495
- column: original.column,
3496
- },
3497
- generated: {
3498
- line: generated.line,
3499
- column: generated.column,
3500
- },
3501
- name: original.name,
3502
- });
3503
- }
3504
- lastOriginalSource = original.source;
3505
- lastOriginalLine = original.line;
3506
- lastOriginalColumn = original.column;
3507
- lastOriginalName = original.name;
3508
- sourceMappingActive = true;
3509
- } else if (sourceMappingActive) {
3510
- map.addMapping({
3511
- generated: {
3512
- line: generated.line,
3513
- column: generated.column,
3514
- },
3515
- });
3516
- lastOriginalSource = null;
3517
- sourceMappingActive = false;
3518
- }
3519
- for (let idx = 0, length = chunk.length; idx < length; idx++) {
3520
- if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
3521
- generated.line++;
3522
- generated.column = 0;
3523
- // Mappings end at eol
3524
- if (idx + 1 === length) {
3525
- lastOriginalSource = null;
3526
- sourceMappingActive = false;
3527
- } else if (sourceMappingActive) {
3528
- map.addMapping({
3529
- source: original.source,
3530
- original: {
3531
- line: original.line,
3532
- column: original.column,
3533
- },
3534
- generated: {
3535
- line: generated.line,
3536
- column: generated.column,
3537
- },
3538
- name: original.name,
3539
- });
3540
- }
3541
- } else {
3542
- generated.column++;
3543
- }
3544
- }
3545
- });
3546
- this.walkSourceContents(function (sourceFile, sourceContent) {
3547
- map.setSourceContent(sourceFile, sourceContent);
3548
- });
3549
-
3550
- return { code: generated.code, map }
3551
- }
3552
- }
3553
-
3554
- sourceNode.SourceNode = SourceNode;
3555
-
3556
2475
  /*
3557
2476
  * Copyright 2009-2011 Mozilla Foundation and contributors
3558
2477
  * Licensed under the New BSD license. See LICENSE.txt or:
3559
2478
  * http://opensource.org/licenses/BSD-3-Clause
3560
2479
  */
3561
-
3562
- sourceMapGenerator.SourceMapGenerator;
3563
2480
  var SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
3564
- sourceNode.SourceNode;
3565
2481
 
3566
2482
  const splitRE = /\r?\n/;
3567
2483
  const range = 2;