neo-cmp-cli 1.8.6-beta.2 → 1.8.6-beta.3

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