neo-cmp-cli 1.8.7 → 1.8.8

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 (124) hide show
  1. package/bin/index.js +2 -2
  2. package/dist/_virtual/_commonjsHelpers.js +12 -0
  3. package/dist/_virtual/array-set.js +7 -0
  4. package/dist/_virtual/base64-vlq.js +7 -0
  5. package/dist/_virtual/base64.js +7 -0
  6. package/dist/_virtual/binary-search.js +7 -0
  7. package/dist/_virtual/mapping-list.js +7 -0
  8. package/dist/_virtual/quick-sort.js +7 -0
  9. package/dist/_virtual/source-map-consumer.js +7 -0
  10. package/dist/_virtual/source-map-generator.js +7 -0
  11. package/dist/_virtual/source-map-support.js +7 -0
  12. package/dist/_virtual/source-map.js +7 -0
  13. package/dist/_virtual/source-node.js +7 -0
  14. package/dist/_virtual/typescript.js +7 -0
  15. package/dist/_virtual/util.js +7 -0
  16. package/dist/config/auth.config.js +43 -0
  17. package/dist/config/default.config.js +192 -0
  18. package/dist/config/index.js +26 -0
  19. package/dist/main.js +9 -0
  20. package/dist/main2.js +259 -0
  21. package/dist/module/inspect.js +63 -0
  22. package/dist/module/neoInit.js +75 -0
  23. package/dist/module/neoInitByCopy.js +83 -0
  24. package/dist/neo/neoLogin.js +590 -0
  25. package/dist/neo/neoRequire.js +123 -0
  26. package/dist/neo/neoService.js +898 -0
  27. package/dist/node_modules/buffer-from/index.js +86 -0
  28. package/dist/node_modules/source-map/lib/array-set.js +138 -0
  29. package/dist/node_modules/source-map/lib/base64-vlq.js +157 -0
  30. package/dist/node_modules/source-map/lib/base64.js +83 -0
  31. package/dist/node_modules/source-map/lib/binary-search.js +129 -0
  32. package/dist/node_modules/source-map/lib/mapping-list.js +96 -0
  33. package/dist/node_modules/source-map/lib/quick-sort.js +130 -0
  34. package/dist/node_modules/source-map/lib/source-map-consumer.js +1166 -0
  35. package/dist/node_modules/source-map/lib/source-map-generator.js +445 -0
  36. package/dist/node_modules/source-map/lib/source-node.js +431 -0
  37. package/dist/node_modules/source-map/lib/util.js +506 -0
  38. package/dist/node_modules/source-map/source-map.js +27 -0
  39. package/dist/node_modules/source-map-support/source-map-support.js +646 -0
  40. package/dist/node_modules/typescript/lib/typescript.js +174130 -0
  41. package/dist/oss/publish2oss.js +331 -0
  42. package/dist/plugins/AddNeoRequirePlugin.js +195 -0
  43. package/dist/utils/autoEntryRootDir.js +103 -0
  44. package/dist/utils/cmpUtils/createCmpByTemplate.js +82 -0
  45. package/dist/utils/cmpUtils/createCmpByZip.js +433 -0
  46. package/dist/utils/cmpUtils/createCommonModulesCode.js +139 -0
  47. package/dist/utils/cmpUtils/deleteCmp.js +81 -0
  48. package/dist/utils/cmpUtils/getCmpModelRegisterCode.js +47 -0
  49. package/dist/utils/cmpUtils/getCmpPreviewCode.js +60 -0
  50. package/dist/utils/cmpUtils/getCmpRegisterCode.js +47 -0
  51. package/dist/utils/cmpUtils/getCmpTypeByDir.js +59 -0
  52. package/dist/utils/cmpUtils/hasCmpTypeByDir.js +27 -0
  53. package/dist/utils/cmpUtils/previewCmp.js +75 -0
  54. package/dist/utils/cmpUtils/pullCmp.js +126 -0
  55. package/dist/utils/cmpUtils/pushCmp.js +254 -0
  56. package/dist/utils/common.js +125 -0
  57. package/dist/utils/configureNeoBuild.js +129 -0
  58. package/dist/utils/generateEntries.js +80 -0
  59. package/dist/utils/neoConfigInit.js +30 -0
  60. package/dist/utils/neoParams.js +26 -0
  61. package/dist/utils/pathUtils.js +40 -0
  62. package/dist/utils/projectNameValidator.js +90 -0
  63. package/dist/utils/projectUtils/createCmpProjectByTemplate.js +81 -0
  64. package/dist/utils/projectUtils/createCmpProjectZip.js +141 -0
  65. package/dist/utils/projectUtils/getEntries.js +99 -0
  66. package/dist/utils/projectUtils/getEntriesWithAutoRegister.js +129 -0
  67. package/dist/utils/projectUtils/hasNeoProject.js +34 -0
  68. package/dist/utils/projectUtils/openProject.js +117 -0
  69. package/dist/utils/projectUtils/updatePublishLog.js +47 -0
  70. package/dist/utils/replaceInFilesByMap.js +71 -0
  71. package/dist/utils/replaceInPackage.js +151 -0
  72. package/dist/utils/resetPackageVersion.js +132 -0
  73. package/package.json +6 -8
  74. package/test/demo.js +0 -2
  75. package/src/config/auth.config.js +0 -27
  76. package/src/config/default.config.js +0 -176
  77. package/src/config/index.js +0 -9
  78. package/src/initData/defaultTemplate.html +0 -13
  79. package/src/initData/neo.config.js +0 -138
  80. package/src/main.js +0 -221
  81. package/src/module/inspect.js +0 -41
  82. package/src/module/neoInit.js +0 -55
  83. package/src/module/neoInitByCopy.js +0 -61
  84. package/src/neo/NeoUMDContent.js +0 -30
  85. package/src/neo/neoLogin.js +0 -565
  86. package/src/neo/neoRequire.js +0 -125
  87. package/src/neo/neoService.js +0 -874
  88. package/src/neo/webpack.mf.js +0 -60
  89. package/src/neo/wrapperContent.js +0 -16
  90. package/src/oss/publish2oss.js +0 -348
  91. package/src/plugins/AddNeoRequirePlugin-v1.js +0 -47
  92. package/src/plugins/AddNeoRequirePlugin.js +0 -179
  93. package/src/plugins/README.md +0 -109
  94. package/src/utils/autoEntryRootDir.js +0 -85
  95. package/src/utils/cmpUtils/createCmpByTemplate.js +0 -60
  96. package/src/utils/cmpUtils/createCmpByZip.js +0 -408
  97. package/src/utils/cmpUtils/createCommonModulesCode.js +0 -121
  98. package/src/utils/cmpUtils/deleteCmp.js +0 -63
  99. package/src/utils/cmpUtils/getCmpModelRegisterCode.js +0 -31
  100. package/src/utils/cmpUtils/getCmpPreviewCode.js +0 -43
  101. package/src/utils/cmpUtils/getCmpRegisterCode.js +0 -31
  102. package/src/utils/cmpUtils/getCmpTypeByDir.js +0 -41
  103. package/src/utils/cmpUtils/hasCmpTypeByDir.js +0 -11
  104. package/src/utils/cmpUtils/previewCmp.js +0 -55
  105. package/src/utils/cmpUtils/pullCmp.js +0 -104
  106. package/src/utils/cmpUtils/pushCmp.js +0 -230
  107. package/src/utils/common.js +0 -107
  108. package/src/utils/configureNeoBuild.js +0 -109
  109. package/src/utils/generateEntries.js +0 -63
  110. package/src/utils/neoConfigInit.js +0 -13
  111. package/src/utils/neoParams.js +0 -12
  112. package/src/utils/pathUtils.js +0 -23
  113. package/src/utils/projectNameValidator.js +0 -76
  114. package/src/utils/projectUtils/createCmpProjectByTemplate.js +0 -59
  115. package/src/utils/projectUtils/createCmpProjectZip.js +0 -120
  116. package/src/utils/projectUtils/getEntries.js +0 -80
  117. package/src/utils/projectUtils/getEntriesWithAutoRegister.js +0 -108
  118. package/src/utils/projectUtils/hasNeoProject.js +0 -17
  119. package/src/utils/projectUtils/openProject.js +0 -96
  120. package/src/utils/projectUtils/updatePublishLog.js +0 -30
  121. package/src/utils/replaceInFiles.js +0 -47
  122. package/src/utils/replaceInFilesByMap.js +0 -54
  123. package/src/utils/replaceInPackage.js +0 -134
  124. package/src/utils/resetPackageVersion.js +0 -115
@@ -0,0 +1,1166 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const sourceMapConsumer = require('../../../_virtual/source-map-consumer.js');
6
+ const util = require('./util.js');
7
+ const binarySearch = require('./binary-search.js');
8
+ const arraySet = require('./array-set.js');
9
+ const base64Vlq = require('./base64-vlq.js');
10
+ const quickSort = require('./quick-sort.js');
11
+
12
+ /* -*- Mode: js; js-indent-level: 2; -*- */
13
+
14
+ var hasRequiredSourceMapConsumer;
15
+
16
+ function requireSourceMapConsumer () {
17
+ if (hasRequiredSourceMapConsumer) return sourceMapConsumer.__exports;
18
+ hasRequiredSourceMapConsumer = 1;
19
+ /*
20
+ * Copyright 2011 Mozilla Foundation and contributors
21
+ * Licensed under the New BSD license. See LICENSE or:
22
+ * http://opensource.org/licenses/BSD-3-Clause
23
+ */
24
+
25
+ var util$1 = util.__require();
26
+ var binarySearch$1 = binarySearch.__require();
27
+ var ArraySet = arraySet.__require().ArraySet;
28
+ var base64VLQ = base64Vlq.__require();
29
+ var quickSort$1 = quickSort.__require().quickSort;
30
+
31
+ function SourceMapConsumer(aSourceMap, aSourceMapURL) {
32
+ var sourceMap = aSourceMap;
33
+ if (typeof aSourceMap === 'string') {
34
+ sourceMap = util$1.parseSourceMapInput(aSourceMap);
35
+ }
36
+
37
+ return sourceMap.sections != null
38
+ ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
39
+ : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
40
+ }
41
+
42
+ SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
43
+ return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
44
+ };
45
+
46
+ /**
47
+ * The version of the source mapping spec that we are consuming.
48
+ */
49
+ SourceMapConsumer.prototype._version = 3;
50
+
51
+ // `__generatedMappings` and `__originalMappings` are arrays that hold the
52
+ // parsed mapping coordinates from the source map's "mappings" attribute. They
53
+ // are lazily instantiated, accessed via the `_generatedMappings` and
54
+ // `_originalMappings` getters respectively, and we only parse the mappings
55
+ // and create these arrays once queried for a source location. We jump through
56
+ // these hoops because there can be many thousands of mappings, and parsing
57
+ // them is expensive, so we only want to do it if we must.
58
+ //
59
+ // Each object in the arrays is of the form:
60
+ //
61
+ // {
62
+ // generatedLine: The line number in the generated code,
63
+ // generatedColumn: The column number in the generated code,
64
+ // source: The path to the original source file that generated this
65
+ // chunk of code,
66
+ // originalLine: The line number in the original source that
67
+ // corresponds to this chunk of generated code,
68
+ // originalColumn: The column number in the original source that
69
+ // corresponds to this chunk of generated code,
70
+ // name: The name of the original symbol which generated this chunk of
71
+ // code.
72
+ // }
73
+ //
74
+ // All properties except for `generatedLine` and `generatedColumn` can be
75
+ // `null`.
76
+ //
77
+ // `_generatedMappings` is ordered by the generated positions.
78
+ //
79
+ // `_originalMappings` is ordered by the original positions.
80
+
81
+ SourceMapConsumer.prototype.__generatedMappings = null;
82
+ Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
83
+ configurable: true,
84
+ enumerable: true,
85
+ get: function () {
86
+ if (!this.__generatedMappings) {
87
+ this._parseMappings(this._mappings, this.sourceRoot);
88
+ }
89
+
90
+ return this.__generatedMappings;
91
+ }
92
+ });
93
+
94
+ SourceMapConsumer.prototype.__originalMappings = null;
95
+ Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
96
+ configurable: true,
97
+ enumerable: true,
98
+ get: function () {
99
+ if (!this.__originalMappings) {
100
+ this._parseMappings(this._mappings, this.sourceRoot);
101
+ }
102
+
103
+ return this.__originalMappings;
104
+ }
105
+ });
106
+
107
+ SourceMapConsumer.prototype._charIsMappingSeparator =
108
+ function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
109
+ var c = aStr.charAt(index);
110
+ return c === ";" || c === ",";
111
+ };
112
+
113
+ /**
114
+ * Parse the mappings in a string in to a data structure which we can easily
115
+ * query (the ordered arrays in the `this.__generatedMappings` and
116
+ * `this.__originalMappings` properties).
117
+ */
118
+ SourceMapConsumer.prototype._parseMappings =
119
+ function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
120
+ throw new Error("Subclasses must implement _parseMappings");
121
+ };
122
+
123
+ SourceMapConsumer.GENERATED_ORDER = 1;
124
+ SourceMapConsumer.ORIGINAL_ORDER = 2;
125
+
126
+ SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
127
+ SourceMapConsumer.LEAST_UPPER_BOUND = 2;
128
+
129
+ /**
130
+ * Iterate over each mapping between an original source/line/column and a
131
+ * generated line/column in this source map.
132
+ *
133
+ * @param Function aCallback
134
+ * The function that is called with each mapping.
135
+ * @param Object aContext
136
+ * Optional. If specified, this object will be the value of `this` every
137
+ * time that `aCallback` is called.
138
+ * @param aOrder
139
+ * Either `SourceMapConsumer.GENERATED_ORDER` or
140
+ * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
141
+ * iterate over the mappings sorted by the generated file's line/column
142
+ * order or the original's source/line/column order, respectively. Defaults to
143
+ * `SourceMapConsumer.GENERATED_ORDER`.
144
+ */
145
+ SourceMapConsumer.prototype.eachMapping =
146
+ function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
147
+ var context = aContext || null;
148
+ var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
149
+
150
+ var mappings;
151
+ switch (order) {
152
+ case SourceMapConsumer.GENERATED_ORDER:
153
+ mappings = this._generatedMappings;
154
+ break;
155
+ case SourceMapConsumer.ORIGINAL_ORDER:
156
+ mappings = this._originalMappings;
157
+ break;
158
+ default:
159
+ throw new Error("Unknown order of iteration.");
160
+ }
161
+
162
+ var sourceRoot = this.sourceRoot;
163
+ mappings.map(function (mapping) {
164
+ var source = mapping.source === null ? null : this._sources.at(mapping.source);
165
+ source = util$1.computeSourceURL(sourceRoot, source, this._sourceMapURL);
166
+ return {
167
+ source: source,
168
+ generatedLine: mapping.generatedLine,
169
+ generatedColumn: mapping.generatedColumn,
170
+ originalLine: mapping.originalLine,
171
+ originalColumn: mapping.originalColumn,
172
+ name: mapping.name === null ? null : this._names.at(mapping.name)
173
+ };
174
+ }, this).forEach(aCallback, context);
175
+ };
176
+
177
+ /**
178
+ * Returns all generated line and column information for the original source,
179
+ * line, and column provided. If no column is provided, returns all mappings
180
+ * corresponding to a either the line we are searching for or the next
181
+ * closest line that has any mappings. Otherwise, returns all mappings
182
+ * corresponding to the given line and either the column we are searching for
183
+ * or the next closest column that has any offsets.
184
+ *
185
+ * The only argument is an object with the following properties:
186
+ *
187
+ * - source: The filename of the original source.
188
+ * - line: The line number in the original source. The line number is 1-based.
189
+ * - column: Optional. the column number in the original source.
190
+ * The column number is 0-based.
191
+ *
192
+ * and an array of objects is returned, each with the following properties:
193
+ *
194
+ * - line: The line number in the generated source, or null. The
195
+ * line number is 1-based.
196
+ * - column: The column number in the generated source, or null.
197
+ * The column number is 0-based.
198
+ */
199
+ SourceMapConsumer.prototype.allGeneratedPositionsFor =
200
+ function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
201
+ var line = util$1.getArg(aArgs, 'line');
202
+
203
+ // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
204
+ // returns the index of the closest mapping less than the needle. By
205
+ // setting needle.originalColumn to 0, we thus find the last mapping for
206
+ // the given line, provided such a mapping exists.
207
+ var needle = {
208
+ source: util$1.getArg(aArgs, 'source'),
209
+ originalLine: line,
210
+ originalColumn: util$1.getArg(aArgs, 'column', 0)
211
+ };
212
+
213
+ needle.source = this._findSourceIndex(needle.source);
214
+ if (needle.source < 0) {
215
+ return [];
216
+ }
217
+
218
+ var mappings = [];
219
+
220
+ var index = this._findMapping(needle,
221
+ this._originalMappings,
222
+ "originalLine",
223
+ "originalColumn",
224
+ util$1.compareByOriginalPositions,
225
+ binarySearch$1.LEAST_UPPER_BOUND);
226
+ if (index >= 0) {
227
+ var mapping = this._originalMappings[index];
228
+
229
+ if (aArgs.column === undefined) {
230
+ var originalLine = mapping.originalLine;
231
+
232
+ // Iterate until either we run out of mappings, or we run into
233
+ // a mapping for a different line than the one we found. Since
234
+ // mappings are sorted, this is guaranteed to find all mappings for
235
+ // the line we found.
236
+ while (mapping && mapping.originalLine === originalLine) {
237
+ mappings.push({
238
+ line: util$1.getArg(mapping, 'generatedLine', null),
239
+ column: util$1.getArg(mapping, 'generatedColumn', null),
240
+ lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
241
+ });
242
+
243
+ mapping = this._originalMappings[++index];
244
+ }
245
+ } else {
246
+ var originalColumn = mapping.originalColumn;
247
+
248
+ // Iterate until either we run out of mappings, or we run into
249
+ // a mapping for a different line than the one we were searching for.
250
+ // Since mappings are sorted, this is guaranteed to find all mappings for
251
+ // the line we are searching for.
252
+ while (mapping &&
253
+ mapping.originalLine === line &&
254
+ mapping.originalColumn == originalColumn) {
255
+ mappings.push({
256
+ line: util$1.getArg(mapping, 'generatedLine', null),
257
+ column: util$1.getArg(mapping, 'generatedColumn', null),
258
+ lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
259
+ });
260
+
261
+ mapping = this._originalMappings[++index];
262
+ }
263
+ }
264
+ }
265
+
266
+ return mappings;
267
+ };
268
+
269
+ sourceMapConsumer.__exports.SourceMapConsumer = SourceMapConsumer;
270
+
271
+ /**
272
+ * A BasicSourceMapConsumer instance represents a parsed source map which we can
273
+ * query for information about the original file positions by giving it a file
274
+ * position in the generated source.
275
+ *
276
+ * The first parameter is the raw source map (either as a JSON string, or
277
+ * already parsed to an object). According to the spec, source maps have the
278
+ * following attributes:
279
+ *
280
+ * - version: Which version of the source map spec this map is following.
281
+ * - sources: An array of URLs to the original source files.
282
+ * - names: An array of identifiers which can be referrenced by individual mappings.
283
+ * - sourceRoot: Optional. The URL root from which all sources are relative.
284
+ * - sourcesContent: Optional. An array of contents of the original source files.
285
+ * - mappings: A string of base64 VLQs which contain the actual mappings.
286
+ * - file: Optional. The generated file this source map is associated with.
287
+ *
288
+ * Here is an example source map, taken from the source map spec[0]:
289
+ *
290
+ * {
291
+ * version : 3,
292
+ * file: "out.js",
293
+ * sourceRoot : "",
294
+ * sources: ["foo.js", "bar.js"],
295
+ * names: ["src", "maps", "are", "fun"],
296
+ * mappings: "AA,AB;;ABCDE;"
297
+ * }
298
+ *
299
+ * The second parameter, if given, is a string whose value is the URL
300
+ * at which the source map was found. This URL is used to compute the
301
+ * sources array.
302
+ *
303
+ * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
304
+ */
305
+ function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
306
+ var sourceMap = aSourceMap;
307
+ if (typeof aSourceMap === 'string') {
308
+ sourceMap = util$1.parseSourceMapInput(aSourceMap);
309
+ }
310
+
311
+ var version = util$1.getArg(sourceMap, 'version');
312
+ var sources = util$1.getArg(sourceMap, 'sources');
313
+ // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
314
+ // requires the array) to play nice here.
315
+ var names = util$1.getArg(sourceMap, 'names', []);
316
+ var sourceRoot = util$1.getArg(sourceMap, 'sourceRoot', null);
317
+ var sourcesContent = util$1.getArg(sourceMap, 'sourcesContent', null);
318
+ var mappings = util$1.getArg(sourceMap, 'mappings');
319
+ var file = util$1.getArg(sourceMap, 'file', null);
320
+
321
+ // Once again, Sass deviates from the spec and supplies the version as a
322
+ // string rather than a number, so we use loose equality checking here.
323
+ if (version != this._version) {
324
+ throw new Error('Unsupported version: ' + version);
325
+ }
326
+
327
+ if (sourceRoot) {
328
+ sourceRoot = util$1.normalize(sourceRoot);
329
+ }
330
+
331
+ sources = sources
332
+ .map(String)
333
+ // Some source maps produce relative source paths like "./foo.js" instead of
334
+ // "foo.js". Normalize these first so that future comparisons will succeed.
335
+ // See bugzil.la/1090768.
336
+ .map(util$1.normalize)
337
+ // Always ensure that absolute sources are internally stored relative to
338
+ // the source root, if the source root is absolute. Not doing this would
339
+ // be particularly problematic when the source root is a prefix of the
340
+ // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
341
+ .map(function (source) {
342
+ return sourceRoot && util$1.isAbsolute(sourceRoot) && util$1.isAbsolute(source)
343
+ ? util$1.relative(sourceRoot, source)
344
+ : source;
345
+ });
346
+
347
+ // Pass `true` below to allow duplicate names and sources. While source maps
348
+ // are intended to be compressed and deduplicated, the TypeScript compiler
349
+ // sometimes generates source maps with duplicates in them. See Github issue
350
+ // #72 and bugzil.la/889492.
351
+ this._names = ArraySet.fromArray(names.map(String), true);
352
+ this._sources = ArraySet.fromArray(sources, true);
353
+
354
+ this._absoluteSources = this._sources.toArray().map(function (s) {
355
+ return util$1.computeSourceURL(sourceRoot, s, aSourceMapURL);
356
+ });
357
+
358
+ this.sourceRoot = sourceRoot;
359
+ this.sourcesContent = sourcesContent;
360
+ this._mappings = mappings;
361
+ this._sourceMapURL = aSourceMapURL;
362
+ this.file = file;
363
+ }
364
+
365
+ BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
366
+ BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
367
+
368
+ /**
369
+ * Utility function to find the index of a source. Returns -1 if not
370
+ * found.
371
+ */
372
+ BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
373
+ var relativeSource = aSource;
374
+ if (this.sourceRoot != null) {
375
+ relativeSource = util$1.relative(this.sourceRoot, relativeSource);
376
+ }
377
+
378
+ if (this._sources.has(relativeSource)) {
379
+ return this._sources.indexOf(relativeSource);
380
+ }
381
+
382
+ // Maybe aSource is an absolute URL as returned by |sources|. In
383
+ // this case we can't simply undo the transform.
384
+ var i;
385
+ for (i = 0; i < this._absoluteSources.length; ++i) {
386
+ if (this._absoluteSources[i] == aSource) {
387
+ return i;
388
+ }
389
+ }
390
+
391
+ return -1;
392
+ };
393
+
394
+ /**
395
+ * Create a BasicSourceMapConsumer from a SourceMapGenerator.
396
+ *
397
+ * @param SourceMapGenerator aSourceMap
398
+ * The source map that will be consumed.
399
+ * @param String aSourceMapURL
400
+ * The URL at which the source map can be found (optional)
401
+ * @returns BasicSourceMapConsumer
402
+ */
403
+ BasicSourceMapConsumer.fromSourceMap =
404
+ function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
405
+ var smc = Object.create(BasicSourceMapConsumer.prototype);
406
+
407
+ var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
408
+ var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
409
+ smc.sourceRoot = aSourceMap._sourceRoot;
410
+ smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
411
+ smc.sourceRoot);
412
+ smc.file = aSourceMap._file;
413
+ smc._sourceMapURL = aSourceMapURL;
414
+ smc._absoluteSources = smc._sources.toArray().map(function (s) {
415
+ return util$1.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
416
+ });
417
+
418
+ // Because we are modifying the entries (by converting string sources and
419
+ // names to indices into the sources and names ArraySets), we have to make
420
+ // a copy of the entry or else bad things happen. Shared mutable state
421
+ // strikes again! See github issue #191.
422
+
423
+ var generatedMappings = aSourceMap._mappings.toArray().slice();
424
+ var destGeneratedMappings = smc.__generatedMappings = [];
425
+ var destOriginalMappings = smc.__originalMappings = [];
426
+
427
+ for (var i = 0, length = generatedMappings.length; i < length; i++) {
428
+ var srcMapping = generatedMappings[i];
429
+ var destMapping = new Mapping;
430
+ destMapping.generatedLine = srcMapping.generatedLine;
431
+ destMapping.generatedColumn = srcMapping.generatedColumn;
432
+
433
+ if (srcMapping.source) {
434
+ destMapping.source = sources.indexOf(srcMapping.source);
435
+ destMapping.originalLine = srcMapping.originalLine;
436
+ destMapping.originalColumn = srcMapping.originalColumn;
437
+
438
+ if (srcMapping.name) {
439
+ destMapping.name = names.indexOf(srcMapping.name);
440
+ }
441
+
442
+ destOriginalMappings.push(destMapping);
443
+ }
444
+
445
+ destGeneratedMappings.push(destMapping);
446
+ }
447
+
448
+ quickSort$1(smc.__originalMappings, util$1.compareByOriginalPositions);
449
+
450
+ return smc;
451
+ };
452
+
453
+ /**
454
+ * The version of the source mapping spec that we are consuming.
455
+ */
456
+ BasicSourceMapConsumer.prototype._version = 3;
457
+
458
+ /**
459
+ * The list of original sources.
460
+ */
461
+ Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
462
+ get: function () {
463
+ return this._absoluteSources.slice();
464
+ }
465
+ });
466
+
467
+ /**
468
+ * Provide the JIT with a nice shape / hidden class.
469
+ */
470
+ function Mapping() {
471
+ this.generatedLine = 0;
472
+ this.generatedColumn = 0;
473
+ this.source = null;
474
+ this.originalLine = null;
475
+ this.originalColumn = null;
476
+ this.name = null;
477
+ }
478
+
479
+ /**
480
+ * Parse the mappings in a string in to a data structure which we can easily
481
+ * query (the ordered arrays in the `this.__generatedMappings` and
482
+ * `this.__originalMappings` properties).
483
+ */
484
+ BasicSourceMapConsumer.prototype._parseMappings =
485
+ function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
486
+ var generatedLine = 1;
487
+ var previousGeneratedColumn = 0;
488
+ var previousOriginalLine = 0;
489
+ var previousOriginalColumn = 0;
490
+ var previousSource = 0;
491
+ var previousName = 0;
492
+ var length = aStr.length;
493
+ var index = 0;
494
+ var cachedSegments = {};
495
+ var temp = {};
496
+ var originalMappings = [];
497
+ var generatedMappings = [];
498
+ var mapping, str, segment, end, value;
499
+
500
+ while (index < length) {
501
+ if (aStr.charAt(index) === ';') {
502
+ generatedLine++;
503
+ index++;
504
+ previousGeneratedColumn = 0;
505
+ }
506
+ else if (aStr.charAt(index) === ',') {
507
+ index++;
508
+ }
509
+ else {
510
+ mapping = new Mapping();
511
+ mapping.generatedLine = generatedLine;
512
+
513
+ // Because each offset is encoded relative to the previous one,
514
+ // many segments often have the same encoding. We can exploit this
515
+ // fact by caching the parsed variable length fields of each segment,
516
+ // allowing us to avoid a second parse if we encounter the same
517
+ // segment again.
518
+ for (end = index; end < length; end++) {
519
+ if (this._charIsMappingSeparator(aStr, end)) {
520
+ break;
521
+ }
522
+ }
523
+ str = aStr.slice(index, end);
524
+
525
+ segment = cachedSegments[str];
526
+ if (segment) {
527
+ index += str.length;
528
+ } else {
529
+ segment = [];
530
+ while (index < end) {
531
+ base64VLQ.decode(aStr, index, temp);
532
+ value = temp.value;
533
+ index = temp.rest;
534
+ segment.push(value);
535
+ }
536
+
537
+ if (segment.length === 2) {
538
+ throw new Error('Found a source, but no line and column');
539
+ }
540
+
541
+ if (segment.length === 3) {
542
+ throw new Error('Found a source and line, but no column');
543
+ }
544
+
545
+ cachedSegments[str] = segment;
546
+ }
547
+
548
+ // Generated column.
549
+ mapping.generatedColumn = previousGeneratedColumn + segment[0];
550
+ previousGeneratedColumn = mapping.generatedColumn;
551
+
552
+ if (segment.length > 1) {
553
+ // Original source.
554
+ mapping.source = previousSource + segment[1];
555
+ previousSource += segment[1];
556
+
557
+ // Original line.
558
+ mapping.originalLine = previousOriginalLine + segment[2];
559
+ previousOriginalLine = mapping.originalLine;
560
+ // Lines are stored 0-based
561
+ mapping.originalLine += 1;
562
+
563
+ // Original column.
564
+ mapping.originalColumn = previousOriginalColumn + segment[3];
565
+ previousOriginalColumn = mapping.originalColumn;
566
+
567
+ if (segment.length > 4) {
568
+ // Original name.
569
+ mapping.name = previousName + segment[4];
570
+ previousName += segment[4];
571
+ }
572
+ }
573
+
574
+ generatedMappings.push(mapping);
575
+ if (typeof mapping.originalLine === 'number') {
576
+ originalMappings.push(mapping);
577
+ }
578
+ }
579
+ }
580
+
581
+ quickSort$1(generatedMappings, util$1.compareByGeneratedPositionsDeflated);
582
+ this.__generatedMappings = generatedMappings;
583
+
584
+ quickSort$1(originalMappings, util$1.compareByOriginalPositions);
585
+ this.__originalMappings = originalMappings;
586
+ };
587
+
588
+ /**
589
+ * Find the mapping that best matches the hypothetical "needle" mapping that
590
+ * we are searching for in the given "haystack" of mappings.
591
+ */
592
+ BasicSourceMapConsumer.prototype._findMapping =
593
+ function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
594
+ aColumnName, aComparator, aBias) {
595
+ // To return the position we are searching for, we must first find the
596
+ // mapping for the given position and then return the opposite position it
597
+ // points to. Because the mappings are sorted, we can use binary search to
598
+ // find the best mapping.
599
+
600
+ if (aNeedle[aLineName] <= 0) {
601
+ throw new TypeError('Line must be greater than or equal to 1, got '
602
+ + aNeedle[aLineName]);
603
+ }
604
+ if (aNeedle[aColumnName] < 0) {
605
+ throw new TypeError('Column must be greater than or equal to 0, got '
606
+ + aNeedle[aColumnName]);
607
+ }
608
+
609
+ return binarySearch$1.search(aNeedle, aMappings, aComparator, aBias);
610
+ };
611
+
612
+ /**
613
+ * Compute the last column for each generated mapping. The last column is
614
+ * inclusive.
615
+ */
616
+ BasicSourceMapConsumer.prototype.computeColumnSpans =
617
+ function SourceMapConsumer_computeColumnSpans() {
618
+ for (var index = 0; index < this._generatedMappings.length; ++index) {
619
+ var mapping = this._generatedMappings[index];
620
+
621
+ // Mappings do not contain a field for the last generated columnt. We
622
+ // can come up with an optimistic estimate, however, by assuming that
623
+ // mappings are contiguous (i.e. given two consecutive mappings, the
624
+ // first mapping ends where the second one starts).
625
+ if (index + 1 < this._generatedMappings.length) {
626
+ var nextMapping = this._generatedMappings[index + 1];
627
+
628
+ if (mapping.generatedLine === nextMapping.generatedLine) {
629
+ mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
630
+ continue;
631
+ }
632
+ }
633
+
634
+ // The last mapping for each line spans the entire line.
635
+ mapping.lastGeneratedColumn = Infinity;
636
+ }
637
+ };
638
+
639
+ /**
640
+ * Returns the original source, line, and column information for the generated
641
+ * source's line and column positions provided. The only argument is an object
642
+ * with the following properties:
643
+ *
644
+ * - line: The line number in the generated source. The line number
645
+ * is 1-based.
646
+ * - column: The column number in the generated source. The column
647
+ * number is 0-based.
648
+ * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
649
+ * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
650
+ * closest element that is smaller than or greater than the one we are
651
+ * searching for, respectively, if the exact element cannot be found.
652
+ * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
653
+ *
654
+ * and an object is returned with the following properties:
655
+ *
656
+ * - source: The original source file, or null.
657
+ * - line: The line number in the original source, or null. The
658
+ * line number is 1-based.
659
+ * - column: The column number in the original source, or null. The
660
+ * column number is 0-based.
661
+ * - name: The original identifier, or null.
662
+ */
663
+ BasicSourceMapConsumer.prototype.originalPositionFor =
664
+ function SourceMapConsumer_originalPositionFor(aArgs) {
665
+ var needle = {
666
+ generatedLine: util$1.getArg(aArgs, 'line'),
667
+ generatedColumn: util$1.getArg(aArgs, 'column')
668
+ };
669
+
670
+ var index = this._findMapping(
671
+ needle,
672
+ this._generatedMappings,
673
+ "generatedLine",
674
+ "generatedColumn",
675
+ util$1.compareByGeneratedPositionsDeflated,
676
+ util$1.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
677
+ );
678
+
679
+ if (index >= 0) {
680
+ var mapping = this._generatedMappings[index];
681
+
682
+ if (mapping.generatedLine === needle.generatedLine) {
683
+ var source = util$1.getArg(mapping, 'source', null);
684
+ if (source !== null) {
685
+ source = this._sources.at(source);
686
+ source = util$1.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
687
+ }
688
+ var name = util$1.getArg(mapping, 'name', null);
689
+ if (name !== null) {
690
+ name = this._names.at(name);
691
+ }
692
+ return {
693
+ source: source,
694
+ line: util$1.getArg(mapping, 'originalLine', null),
695
+ column: util$1.getArg(mapping, 'originalColumn', null),
696
+ name: name
697
+ };
698
+ }
699
+ }
700
+
701
+ return {
702
+ source: null,
703
+ line: null,
704
+ column: null,
705
+ name: null
706
+ };
707
+ };
708
+
709
+ /**
710
+ * Return true if we have the source content for every source in the source
711
+ * map, false otherwise.
712
+ */
713
+ BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
714
+ function BasicSourceMapConsumer_hasContentsOfAllSources() {
715
+ if (!this.sourcesContent) {
716
+ return false;
717
+ }
718
+ return this.sourcesContent.length >= this._sources.size() &&
719
+ !this.sourcesContent.some(function (sc) { return sc == null; });
720
+ };
721
+
722
+ /**
723
+ * Returns the original source content. The only argument is the url of the
724
+ * original source file. Returns null if no original source content is
725
+ * available.
726
+ */
727
+ BasicSourceMapConsumer.prototype.sourceContentFor =
728
+ function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
729
+ if (!this.sourcesContent) {
730
+ return null;
731
+ }
732
+
733
+ var index = this._findSourceIndex(aSource);
734
+ if (index >= 0) {
735
+ return this.sourcesContent[index];
736
+ }
737
+
738
+ var relativeSource = aSource;
739
+ if (this.sourceRoot != null) {
740
+ relativeSource = util$1.relative(this.sourceRoot, relativeSource);
741
+ }
742
+
743
+ var url;
744
+ if (this.sourceRoot != null
745
+ && (url = util$1.urlParse(this.sourceRoot))) {
746
+ // XXX: file:// URIs and absolute paths lead to unexpected behavior for
747
+ // many users. We can help them out when they expect file:// URIs to
748
+ // behave like it would if they were running a local HTTP server. See
749
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
750
+ var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
751
+ if (url.scheme == "file"
752
+ && this._sources.has(fileUriAbsPath)) {
753
+ return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
754
+ }
755
+
756
+ if ((!url.path || url.path == "/")
757
+ && this._sources.has("/" + relativeSource)) {
758
+ return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
759
+ }
760
+ }
761
+
762
+ // This function is used recursively from
763
+ // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
764
+ // don't want to throw if we can't find the source - we just want to
765
+ // return null, so we provide a flag to exit gracefully.
766
+ if (nullOnMissing) {
767
+ return null;
768
+ }
769
+ else {
770
+ throw new Error('"' + relativeSource + '" is not in the SourceMap.');
771
+ }
772
+ };
773
+
774
+ /**
775
+ * Returns the generated line and column information for the original source,
776
+ * line, and column positions provided. The only argument is an object with
777
+ * the following properties:
778
+ *
779
+ * - source: The filename of the original source.
780
+ * - line: The line number in the original source. The line number
781
+ * is 1-based.
782
+ * - column: The column number in the original source. The column
783
+ * number is 0-based.
784
+ * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
785
+ * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
786
+ * closest element that is smaller than or greater than the one we are
787
+ * searching for, respectively, if the exact element cannot be found.
788
+ * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
789
+ *
790
+ * and an object is returned with the following properties:
791
+ *
792
+ * - line: The line number in the generated source, or null. The
793
+ * line number is 1-based.
794
+ * - column: The column number in the generated source, or null.
795
+ * The column number is 0-based.
796
+ */
797
+ BasicSourceMapConsumer.prototype.generatedPositionFor =
798
+ function SourceMapConsumer_generatedPositionFor(aArgs) {
799
+ var source = util$1.getArg(aArgs, 'source');
800
+ source = this._findSourceIndex(source);
801
+ if (source < 0) {
802
+ return {
803
+ line: null,
804
+ column: null,
805
+ lastColumn: null
806
+ };
807
+ }
808
+
809
+ var needle = {
810
+ source: source,
811
+ originalLine: util$1.getArg(aArgs, 'line'),
812
+ originalColumn: util$1.getArg(aArgs, 'column')
813
+ };
814
+
815
+ var index = this._findMapping(
816
+ needle,
817
+ this._originalMappings,
818
+ "originalLine",
819
+ "originalColumn",
820
+ util$1.compareByOriginalPositions,
821
+ util$1.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
822
+ );
823
+
824
+ if (index >= 0) {
825
+ var mapping = this._originalMappings[index];
826
+
827
+ if (mapping.source === needle.source) {
828
+ return {
829
+ line: util$1.getArg(mapping, 'generatedLine', null),
830
+ column: util$1.getArg(mapping, 'generatedColumn', null),
831
+ lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
832
+ };
833
+ }
834
+ }
835
+
836
+ return {
837
+ line: null,
838
+ column: null,
839
+ lastColumn: null
840
+ };
841
+ };
842
+
843
+ sourceMapConsumer.__exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
844
+
845
+ /**
846
+ * An IndexedSourceMapConsumer instance represents a parsed source map which
847
+ * we can query for information. It differs from BasicSourceMapConsumer in
848
+ * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
849
+ * input.
850
+ *
851
+ * The first parameter is a raw source map (either as a JSON string, or already
852
+ * parsed to an object). According to the spec for indexed source maps, they
853
+ * have the following attributes:
854
+ *
855
+ * - version: Which version of the source map spec this map is following.
856
+ * - file: Optional. The generated file this source map is associated with.
857
+ * - sections: A list of section definitions.
858
+ *
859
+ * Each value under the "sections" field has two fields:
860
+ * - offset: The offset into the original specified at which this section
861
+ * begins to apply, defined as an object with a "line" and "column"
862
+ * field.
863
+ * - map: A source map definition. This source map could also be indexed,
864
+ * but doesn't have to be.
865
+ *
866
+ * Instead of the "map" field, it's also possible to have a "url" field
867
+ * specifying a URL to retrieve a source map from, but that's currently
868
+ * unsupported.
869
+ *
870
+ * Here's an example source map, taken from the source map spec[0], but
871
+ * modified to omit a section which uses the "url" field.
872
+ *
873
+ * {
874
+ * version : 3,
875
+ * file: "app.js",
876
+ * sections: [{
877
+ * offset: {line:100, column:10},
878
+ * map: {
879
+ * version : 3,
880
+ * file: "section.js",
881
+ * sources: ["foo.js", "bar.js"],
882
+ * names: ["src", "maps", "are", "fun"],
883
+ * mappings: "AAAA,E;;ABCDE;"
884
+ * }
885
+ * }],
886
+ * }
887
+ *
888
+ * The second parameter, if given, is a string whose value is the URL
889
+ * at which the source map was found. This URL is used to compute the
890
+ * sources array.
891
+ *
892
+ * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
893
+ */
894
+ function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
895
+ var sourceMap = aSourceMap;
896
+ if (typeof aSourceMap === 'string') {
897
+ sourceMap = util$1.parseSourceMapInput(aSourceMap);
898
+ }
899
+
900
+ var version = util$1.getArg(sourceMap, 'version');
901
+ var sections = util$1.getArg(sourceMap, 'sections');
902
+
903
+ if (version != this._version) {
904
+ throw new Error('Unsupported version: ' + version);
905
+ }
906
+
907
+ this._sources = new ArraySet();
908
+ this._names = new ArraySet();
909
+
910
+ var lastOffset = {
911
+ line: -1,
912
+ column: 0
913
+ };
914
+ this._sections = sections.map(function (s) {
915
+ if (s.url) {
916
+ // The url field will require support for asynchronicity.
917
+ // See https://github.com/mozilla/source-map/issues/16
918
+ throw new Error('Support for url field in sections not implemented.');
919
+ }
920
+ var offset = util$1.getArg(s, 'offset');
921
+ var offsetLine = util$1.getArg(offset, 'line');
922
+ var offsetColumn = util$1.getArg(offset, 'column');
923
+
924
+ if (offsetLine < lastOffset.line ||
925
+ (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
926
+ throw new Error('Section offsets must be ordered and non-overlapping.');
927
+ }
928
+ lastOffset = offset;
929
+
930
+ return {
931
+ generatedOffset: {
932
+ // The offset fields are 0-based, but we use 1-based indices when
933
+ // encoding/decoding from VLQ.
934
+ generatedLine: offsetLine + 1,
935
+ generatedColumn: offsetColumn + 1
936
+ },
937
+ consumer: new SourceMapConsumer(util$1.getArg(s, 'map'), aSourceMapURL)
938
+ }
939
+ });
940
+ }
941
+
942
+ IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
943
+ IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
944
+
945
+ /**
946
+ * The version of the source mapping spec that we are consuming.
947
+ */
948
+ IndexedSourceMapConsumer.prototype._version = 3;
949
+
950
+ /**
951
+ * The list of original sources.
952
+ */
953
+ Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
954
+ get: function () {
955
+ var sources = [];
956
+ for (var i = 0; i < this._sections.length; i++) {
957
+ for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
958
+ sources.push(this._sections[i].consumer.sources[j]);
959
+ }
960
+ }
961
+ return sources;
962
+ }
963
+ });
964
+
965
+ /**
966
+ * Returns the original source, line, and column information for the generated
967
+ * source's line and column positions provided. The only argument is an object
968
+ * with the following properties:
969
+ *
970
+ * - line: The line number in the generated source. The line number
971
+ * is 1-based.
972
+ * - column: The column number in the generated source. The column
973
+ * number is 0-based.
974
+ *
975
+ * and an object is returned with the following properties:
976
+ *
977
+ * - source: The original source file, or null.
978
+ * - line: The line number in the original source, or null. The
979
+ * line number is 1-based.
980
+ * - column: The column number in the original source, or null. The
981
+ * column number is 0-based.
982
+ * - name: The original identifier, or null.
983
+ */
984
+ IndexedSourceMapConsumer.prototype.originalPositionFor =
985
+ function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
986
+ var needle = {
987
+ generatedLine: util$1.getArg(aArgs, 'line'),
988
+ generatedColumn: util$1.getArg(aArgs, 'column')
989
+ };
990
+
991
+ // Find the section containing the generated position we're trying to map
992
+ // to an original position.
993
+ var sectionIndex = binarySearch$1.search(needle, this._sections,
994
+ function(needle, section) {
995
+ var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
996
+ if (cmp) {
997
+ return cmp;
998
+ }
999
+
1000
+ return (needle.generatedColumn -
1001
+ section.generatedOffset.generatedColumn);
1002
+ });
1003
+ var section = this._sections[sectionIndex];
1004
+
1005
+ if (!section) {
1006
+ return {
1007
+ source: null,
1008
+ line: null,
1009
+ column: null,
1010
+ name: null
1011
+ };
1012
+ }
1013
+
1014
+ return section.consumer.originalPositionFor({
1015
+ line: needle.generatedLine -
1016
+ (section.generatedOffset.generatedLine - 1),
1017
+ column: needle.generatedColumn -
1018
+ (section.generatedOffset.generatedLine === needle.generatedLine
1019
+ ? section.generatedOffset.generatedColumn - 1
1020
+ : 0),
1021
+ bias: aArgs.bias
1022
+ });
1023
+ };
1024
+
1025
+ /**
1026
+ * Return true if we have the source content for every source in the source
1027
+ * map, false otherwise.
1028
+ */
1029
+ IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
1030
+ function IndexedSourceMapConsumer_hasContentsOfAllSources() {
1031
+ return this._sections.every(function (s) {
1032
+ return s.consumer.hasContentsOfAllSources();
1033
+ });
1034
+ };
1035
+
1036
+ /**
1037
+ * Returns the original source content. The only argument is the url of the
1038
+ * original source file. Returns null if no original source content is
1039
+ * available.
1040
+ */
1041
+ IndexedSourceMapConsumer.prototype.sourceContentFor =
1042
+ function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
1043
+ for (var i = 0; i < this._sections.length; i++) {
1044
+ var section = this._sections[i];
1045
+
1046
+ var content = section.consumer.sourceContentFor(aSource, true);
1047
+ if (content) {
1048
+ return content;
1049
+ }
1050
+ }
1051
+ if (nullOnMissing) {
1052
+ return null;
1053
+ }
1054
+ else {
1055
+ throw new Error('"' + aSource + '" is not in the SourceMap.');
1056
+ }
1057
+ };
1058
+
1059
+ /**
1060
+ * Returns the generated line and column information for the original source,
1061
+ * line, and column positions provided. The only argument is an object with
1062
+ * the following properties:
1063
+ *
1064
+ * - source: The filename of the original source.
1065
+ * - line: The line number in the original source. The line number
1066
+ * is 1-based.
1067
+ * - column: The column number in the original source. The column
1068
+ * number is 0-based.
1069
+ *
1070
+ * and an object is returned with the following properties:
1071
+ *
1072
+ * - line: The line number in the generated source, or null. The
1073
+ * line number is 1-based.
1074
+ * - column: The column number in the generated source, or null.
1075
+ * The column number is 0-based.
1076
+ */
1077
+ IndexedSourceMapConsumer.prototype.generatedPositionFor =
1078
+ function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
1079
+ for (var i = 0; i < this._sections.length; i++) {
1080
+ var section = this._sections[i];
1081
+
1082
+ // Only consider this section if the requested source is in the list of
1083
+ // sources of the consumer.
1084
+ if (section.consumer._findSourceIndex(util$1.getArg(aArgs, 'source')) === -1) {
1085
+ continue;
1086
+ }
1087
+ var generatedPosition = section.consumer.generatedPositionFor(aArgs);
1088
+ if (generatedPosition) {
1089
+ var ret = {
1090
+ line: generatedPosition.line +
1091
+ (section.generatedOffset.generatedLine - 1),
1092
+ column: generatedPosition.column +
1093
+ (section.generatedOffset.generatedLine === generatedPosition.line
1094
+ ? section.generatedOffset.generatedColumn - 1
1095
+ : 0)
1096
+ };
1097
+ return ret;
1098
+ }
1099
+ }
1100
+
1101
+ return {
1102
+ line: null,
1103
+ column: null
1104
+ };
1105
+ };
1106
+
1107
+ /**
1108
+ * Parse the mappings in a string in to a data structure which we can easily
1109
+ * query (the ordered arrays in the `this.__generatedMappings` and
1110
+ * `this.__originalMappings` properties).
1111
+ */
1112
+ IndexedSourceMapConsumer.prototype._parseMappings =
1113
+ function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
1114
+ this.__generatedMappings = [];
1115
+ this.__originalMappings = [];
1116
+ for (var i = 0; i < this._sections.length; i++) {
1117
+ var section = this._sections[i];
1118
+ var sectionMappings = section.consumer._generatedMappings;
1119
+ for (var j = 0; j < sectionMappings.length; j++) {
1120
+ var mapping = sectionMappings[j];
1121
+
1122
+ var source = section.consumer._sources.at(mapping.source);
1123
+ source = util$1.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
1124
+ this._sources.add(source);
1125
+ source = this._sources.indexOf(source);
1126
+
1127
+ var name = null;
1128
+ if (mapping.name) {
1129
+ name = section.consumer._names.at(mapping.name);
1130
+ this._names.add(name);
1131
+ name = this._names.indexOf(name);
1132
+ }
1133
+
1134
+ // The mappings coming from the consumer for the section have
1135
+ // generated positions relative to the start of the section, so we
1136
+ // need to offset them to be relative to the start of the concatenated
1137
+ // generated file.
1138
+ var adjustedMapping = {
1139
+ source: source,
1140
+ generatedLine: mapping.generatedLine +
1141
+ (section.generatedOffset.generatedLine - 1),
1142
+ generatedColumn: mapping.generatedColumn +
1143
+ (section.generatedOffset.generatedLine === mapping.generatedLine
1144
+ ? section.generatedOffset.generatedColumn - 1
1145
+ : 0),
1146
+ originalLine: mapping.originalLine,
1147
+ originalColumn: mapping.originalColumn,
1148
+ name: name
1149
+ };
1150
+
1151
+ this.__generatedMappings.push(adjustedMapping);
1152
+ if (typeof adjustedMapping.originalLine === 'number') {
1153
+ this.__originalMappings.push(adjustedMapping);
1154
+ }
1155
+ }
1156
+ }
1157
+
1158
+ quickSort$1(this.__generatedMappings, util$1.compareByGeneratedPositionsDeflated);
1159
+ quickSort$1(this.__originalMappings, util$1.compareByOriginalPositions);
1160
+ };
1161
+
1162
+ sourceMapConsumer.__exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
1163
+ return sourceMapConsumer.__exports;
1164
+ }
1165
+
1166
+ exports.__require = requireSourceMapConsumer;