@zntc/react-native 0.1.2 → 0.1.4
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.
- package/README.md +79 -19
- package/dist/dev-server/platform-state.d.ts +24 -0
- package/dist/index.js +1165 -1130
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -104,60 +104,16 @@ const URI_REGEX = /^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
|
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
//#endregion
|
|
107
|
-
//#region
|
|
108
|
-
var
|
|
109
|
-
"
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var require_source_map_lib_array_set = __commonJS({
|
|
115
|
-
"array-set.js"(exports, module) {
|
|
116
|
-
class ArraySet {
|
|
117
|
-
constructor() {
|
|
118
|
-
this._array = [];
|
|
119
|
-
this._set = new Map();
|
|
120
|
-
}
|
|
121
|
-
static fromArray(aArray,aAllowDuplicates) {
|
|
122
|
-
const set = new ArraySet();
|
|
123
|
-
for (let i = 0,len = aArray.length; i < len; i++) {
|
|
124
|
-
set.add(aArray[i], aAllowDuplicates);
|
|
125
|
-
}
|
|
126
|
-
return set;
|
|
127
|
-
}
|
|
128
|
-
size() {
|
|
129
|
-
return this._set.size;
|
|
130
|
-
}
|
|
131
|
-
add(aStr,aAllowDuplicates) {
|
|
132
|
-
const isDuplicate = this.has(aStr),idx = this._array.length;
|
|
133
|
-
if (!isDuplicate || aAllowDuplicates) {
|
|
134
|
-
this._array.push(aStr);
|
|
135
|
-
}
|
|
136
|
-
if (!isDuplicate) {
|
|
137
|
-
this._set.set(aStr, idx);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
has(aStr) {
|
|
141
|
-
return this._set.has(aStr);
|
|
142
|
-
}
|
|
143
|
-
indexOf(aStr) {
|
|
144
|
-
const idx = this._set.get(aStr);
|
|
145
|
-
if (idx >= 0) {
|
|
146
|
-
return idx;
|
|
147
|
-
}
|
|
148
|
-
throw new Error("\"" + aStr + "\" is not in the set.");
|
|
149
|
-
}
|
|
150
|
-
at(aIdx) {
|
|
151
|
-
if (aIdx >= 0 && aIdx < this._array.length) {
|
|
152
|
-
return this._array[aIdx];
|
|
153
|
-
}
|
|
154
|
-
throw new Error("No element indexed by " + aIdx);
|
|
155
|
-
}
|
|
156
|
-
toArray() {
|
|
157
|
-
return this._array.slice();
|
|
107
|
+
//#region base64.js
|
|
108
|
+
var require_source_map_lib_base64 = __commonJS({
|
|
109
|
+
"base64.js"(exports, module) {
|
|
110
|
+
const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
|
|
111
|
+
exports.encode = function(number) {
|
|
112
|
+
if (0 <= number && number < intToCharMap.length) {
|
|
113
|
+
return intToCharMap[number];
|
|
158
114
|
}
|
|
159
|
-
|
|
160
|
-
|
|
115
|
+
throw new TypeError("Must be between 0 and 63: " + number);
|
|
116
|
+
};
|
|
161
117
|
|
|
162
118
|
}
|
|
163
119
|
});
|
|
@@ -185,661 +141,420 @@ const base64 = require_source_map_lib_base64(),VLQ_BASE_SHIFT = 5,VLQ_BASE = 1 <
|
|
|
185
141
|
}
|
|
186
142
|
});
|
|
187
143
|
//#endregion
|
|
188
|
-
//#region
|
|
189
|
-
var
|
|
190
|
-
"
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
144
|
+
//#region (disabled):url
|
|
145
|
+
var require__disabled__url = __commonJS({
|
|
146
|
+
"(disabled):url"(exports, module) {
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region url.js
|
|
151
|
+
var require_source_map_lib_url = __commonJS({
|
|
152
|
+
"url.js"(exports, module) {
|
|
153
|
+
"use strict";
|
|
154
|
+
module.exports = typeof URL == "function" ? URL : require__disabled__url().URL;
|
|
198
155
|
|
|
199
156
|
}
|
|
200
157
|
});
|
|
201
158
|
//#endregion
|
|
202
|
-
//#region
|
|
203
|
-
var
|
|
204
|
-
"
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
return
|
|
211
|
-
} else if (cmp > 0) {
|
|
212
|
-
if (aHigh - mid > 1) {
|
|
213
|
-
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
|
|
214
|
-
}
|
|
215
|
-
if (aBias === exports.LEAST_UPPER_BOUND) {
|
|
216
|
-
return aHigh < aHaystack.length ? aHigh : -1;
|
|
217
|
-
}
|
|
218
|
-
return mid;
|
|
159
|
+
//#region util.js
|
|
160
|
+
var require_source_map_lib_util = __commonJS({
|
|
161
|
+
"util.js"(exports, module) {
|
|
162
|
+
const URL = require_source_map_lib_url();
|
|
163
|
+
function getArg(aArgs,aName,aDefaultValue) {
|
|
164
|
+
if (aName in aArgs) {
|
|
165
|
+
return aArgs[aName];
|
|
166
|
+
} else if (arguments.length === 3) {
|
|
167
|
+
return aDefaultValue;
|
|
219
168
|
}
|
|
220
|
-
|
|
221
|
-
|
|
169
|
+
throw new Error("\"" + aName + "\" is a required argument.");
|
|
170
|
+
}
|
|
171
|
+
exports.getArg = getArg;
|
|
172
|
+
const supportsNullProto = (function() {
|
|
173
|
+
const obj = Object.create(null);
|
|
174
|
+
return !("__proto__" in obj);
|
|
175
|
+
})();
|
|
176
|
+
function identity(s) {
|
|
177
|
+
return s;
|
|
178
|
+
}
|
|
179
|
+
function toSetString(aStr) {
|
|
180
|
+
if (isProtoString(aStr)) {
|
|
181
|
+
return "$" + aStr;
|
|
222
182
|
}
|
|
223
|
-
|
|
224
|
-
|
|
183
|
+
return aStr;
|
|
184
|
+
}
|
|
185
|
+
exports.toSetString = supportsNullProto ? identity : toSetString;
|
|
186
|
+
function fromSetString(aStr) {
|
|
187
|
+
if (isProtoString(aStr)) {
|
|
188
|
+
return aStr.slice(1);
|
|
225
189
|
}
|
|
226
|
-
return
|
|
190
|
+
return aStr;
|
|
227
191
|
}
|
|
228
|
-
exports.
|
|
229
|
-
|
|
230
|
-
|
|
192
|
+
exports.fromSetString = supportsNullProto ? identity : fromSetString;
|
|
193
|
+
function isProtoString(s) {
|
|
194
|
+
if (!s) {
|
|
195
|
+
return false;
|
|
231
196
|
}
|
|
232
|
-
|
|
233
|
-
if (
|
|
234
|
-
return
|
|
197
|
+
const length = s.length;
|
|
198
|
+
if (length < 9) {
|
|
199
|
+
return false;
|
|
235
200
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
201
|
+
if (s.charCodeAt(length - 1) !== 95 || s.charCodeAt(length - 2) !== 95 || s.charCodeAt(length - 3) !== 111 || s.charCodeAt(length - 4) !== 116 || s.charCodeAt(length - 5) !== 111 || s.charCodeAt(length - 6) !== 114 || s.charCodeAt(length - 7) !== 112 || s.charCodeAt(length - 8) !== 95 || s.charCodeAt(length - 9) !== 95) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
for (let i = length - 10; i >= 0; i--) {
|
|
205
|
+
if (s.charCodeAt(i) !== 36) {
|
|
206
|
+
return false;
|
|
239
207
|
}
|
|
240
|
-
--index;
|
|
241
208
|
}
|
|
242
|
-
return
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
//#endregion
|
|
248
|
-
//#region mapping-list.js
|
|
249
|
-
var require_source_map_lib_mapping_list = __commonJS({
|
|
250
|
-
"mapping-list.js"(exports, module) {
|
|
251
|
-
const util = require_source_map_lib_util();
|
|
252
|
-
function generatedPositionAfter(mappingA,mappingB) {
|
|
253
|
-
const lineA = mappingA.generatedLine,lineB = mappingB.generatedLine,columnA = mappingA.generatedColumn,columnB = mappingB.generatedColumn;
|
|
254
|
-
return lineB > lineA || lineB == lineA && columnB >= columnA || util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
|
|
209
|
+
return true;
|
|
255
210
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
this._sorted = true;
|
|
260
|
-
this._last = { generatedLine: -1, generatedColumn: 0 };
|
|
211
|
+
function strcmp(aStr1,aStr2) {
|
|
212
|
+
if (aStr1 === aStr2) {
|
|
213
|
+
return 0;
|
|
261
214
|
}
|
|
262
|
-
|
|
263
|
-
|
|
215
|
+
if (aStr1 === null) {
|
|
216
|
+
return 1;
|
|
264
217
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
this._last = aMapping;
|
|
268
|
-
this._array.push(aMapping);
|
|
269
|
-
} else {
|
|
270
|
-
this._sorted = false;
|
|
271
|
-
this._array.push(aMapping);
|
|
272
|
-
}
|
|
218
|
+
if (aStr2 === null) {
|
|
219
|
+
return -1;
|
|
273
220
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
this._array.sort(util.compareByGeneratedPositionsInflated);
|
|
277
|
-
this._sorted = true;
|
|
278
|
-
}
|
|
279
|
-
return this._array;
|
|
221
|
+
if (aStr1 > aStr2) {
|
|
222
|
+
return 1;
|
|
280
223
|
}
|
|
224
|
+
return -1;
|
|
281
225
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
//#endregion
|
|
287
|
-
//#region read-wasm-browser.js
|
|
288
|
-
var require_source_map_lib_read_wasm_browser = __commonJS({
|
|
289
|
-
"read-wasm-browser.js"(exports, module) {
|
|
290
|
-
"use strict";
|
|
291
|
-
let mappingsWasm = null;
|
|
292
|
-
module.exports = function readWasm() {
|
|
293
|
-
if (typeof mappingsWasm == "string") {
|
|
294
|
-
return fetch(mappingsWasm).then((response) => response.arrayBuffer());
|
|
226
|
+
function compareByGeneratedPositionsInflated(mappingA,mappingB) {
|
|
227
|
+
let cmp = mappingA.generatedLine - mappingB.generatedLine;
|
|
228
|
+
if (cmp !== 0) {
|
|
229
|
+
return cmp;
|
|
295
230
|
}
|
|
296
|
-
|
|
297
|
-
|
|
231
|
+
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
|
232
|
+
if (cmp !== 0) {
|
|
233
|
+
return cmp;
|
|
298
234
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
mappingsWasm = input;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region source-map-consumer.js
|
|
309
|
-
var require_source_map_lib_source_map_consumer = __commonJS({
|
|
310
|
-
"source-map-consumer.js"(exports, module) {
|
|
311
|
-
const util = require_source_map_lib_util(),binarySearch = require_source_map_lib_binary_search(),ArraySet = require_source_map_lib_array_set().ArraySet,base64VLQ = require_source_map_lib_base64_vlq(),readWasm = require_source_map_lib_read_wasm_browser(),wasm = require_source_map_lib_wasm(),INTERNAL = Symbol("smcInternal");
|
|
312
|
-
class SourceMapConsumer {
|
|
313
|
-
constructor(aSourceMap,aSourceMapURL) {
|
|
314
|
-
if (aSourceMap == INTERNAL) {
|
|
315
|
-
return Promise.resolve(this);
|
|
316
|
-
}
|
|
317
|
-
return _factory(aSourceMap, aSourceMapURL);
|
|
235
|
+
cmp = strcmp(mappingA.source, mappingB.source);
|
|
236
|
+
if (cmp !== 0) {
|
|
237
|
+
return cmp;
|
|
318
238
|
}
|
|
319
|
-
|
|
320
|
-
|
|
239
|
+
cmp = mappingA.originalLine - mappingB.originalLine;
|
|
240
|
+
if (cmp !== 0) {
|
|
241
|
+
return cmp;
|
|
321
242
|
}
|
|
322
|
-
|
|
323
|
-
|
|
243
|
+
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
|
244
|
+
if (cmp !== 0) {
|
|
245
|
+
return cmp;
|
|
324
246
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
247
|
+
return strcmp(mappingA.name, mappingB.name);
|
|
248
|
+
}
|
|
249
|
+
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
|
|
250
|
+
function parseSourceMapInput(str) {
|
|
251
|
+
return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
|
|
252
|
+
}
|
|
253
|
+
exports.parseSourceMapInput = parseSourceMapInput;
|
|
254
|
+
const PROTOCOL = "http:",PROTOCOL_AND_HOST = `${PROTOCOL}//host`;
|
|
255
|
+
function createSafeHandler(cb) {
|
|
256
|
+
return (input) => {
|
|
257
|
+
const type = getURLType(input),base = buildSafeBase(input),url = new URL(input, base);
|
|
258
|
+
cb(url);
|
|
259
|
+
const result = url.toString();
|
|
260
|
+
if (type === "absolute") {
|
|
261
|
+
return result;
|
|
262
|
+
} else if (type === "scheme-relative") {
|
|
263
|
+
return result.slice(PROTOCOL.length);
|
|
264
|
+
} else if (type === "path-absolute") {
|
|
265
|
+
return result.slice(PROTOCOL_AND_HOST.length);
|
|
331
266
|
}
|
|
267
|
+
return computeRelativeURL(base, result);
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function withBase(url,base) {
|
|
271
|
+
return new URL(url, base).toString();
|
|
272
|
+
}
|
|
273
|
+
function buildUniqueSegment(prefix,str) {
|
|
274
|
+
let id = 0;
|
|
275
|
+
do {
|
|
276
|
+
const ident = prefix + id++;
|
|
277
|
+
if (str.indexOf(ident) === -1)return ident;
|
|
278
|
+
} while (true);
|
|
279
|
+
}
|
|
280
|
+
function buildSafeBase(str) {
|
|
281
|
+
const maxDotParts = str.split("..").length - 1,segment = buildUniqueSegment("p", str);
|
|
282
|
+
let base = `${PROTOCOL_AND_HOST}/`;
|
|
283
|
+
for (let i = 0; i < maxDotParts; i++) {
|
|
284
|
+
base += `${segment}/`;
|
|
332
285
|
}
|
|
333
|
-
|
|
334
|
-
|
|
286
|
+
return base;
|
|
287
|
+
}
|
|
288
|
+
const ABSOLUTE_SCHEME = /^[A-Za-z0-9\+\-\.]+:/;
|
|
289
|
+
function getURLType(url) {
|
|
290
|
+
if (url[0] === "/") {
|
|
291
|
+
if (url[1] === "/")return "scheme-relative";
|
|
292
|
+
return "path-absolute";
|
|
335
293
|
}
|
|
336
|
-
|
|
337
|
-
|
|
294
|
+
return ABSOLUTE_SCHEME.test(url) ? "absolute" : "path-relative";
|
|
295
|
+
}
|
|
296
|
+
function computeRelativeURL(rootURL,targetURL) {
|
|
297
|
+
if (typeof rootURL == "string")rootURL = new URL(rootURL);
|
|
298
|
+
if (typeof targetURL == "string")targetURL = new URL(targetURL);
|
|
299
|
+
const targetParts = targetURL.pathname.split("/"),rootParts = rootURL.pathname.split("/");
|
|
300
|
+
if (rootParts.length > 0 && !rootParts[rootParts.length - 1]) {
|
|
301
|
+
rootParts.pop();
|
|
338
302
|
}
|
|
339
|
-
|
|
340
|
-
|
|
303
|
+
while (targetParts.length > 0 && rootParts.length > 0 && targetParts[0] === rootParts[0]) {
|
|
304
|
+
targetParts.shift();
|
|
305
|
+
rootParts.shift();
|
|
341
306
|
}
|
|
307
|
+
const relativePath = rootParts.map(() => "..").concat(targetParts).join("/");
|
|
308
|
+
return relativePath + targetURL.search + targetURL.hash;
|
|
342
309
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
const version = util.getArg(sourceMap, "version"),sources = util.getArg(sourceMap, "sources").map(String),names = util.getArg(sourceMap, "names", []),sourceRoot = util.getArg(sourceMap, "sourceRoot", null),sourcesContent = util.getArg(sourceMap, "sourcesContent", null),mappings = util.getArg(sourceMap, "mappings"),file = util.getArg(sourceMap, "file", null),x_google_ignoreList = util.getArg(sourceMap, "x_google_ignoreList", null);
|
|
357
|
-
if (version != that._version) {
|
|
358
|
-
throw new Error("Unsupported version: " + version);
|
|
359
|
-
}
|
|
360
|
-
that._sourceLookupCache = new Map();
|
|
361
|
-
that._names = ArraySet.fromArray(names.map(String), true);
|
|
362
|
-
that._sources = ArraySet.fromArray(sources, true);
|
|
363
|
-
that._absoluteSources = ArraySet.fromArray(that._sources.toArray().map(function(s) {
|
|
364
|
-
return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
|
|
365
|
-
}), true);
|
|
366
|
-
that.sourceRoot = sourceRoot;
|
|
367
|
-
that.sourcesContent = sourcesContent;
|
|
368
|
-
that._mappings = mappings;
|
|
369
|
-
that._sourceMapURL = aSourceMapURL;
|
|
370
|
-
that.file = file;
|
|
371
|
-
that.x_google_ignoreList = x_google_ignoreList;
|
|
372
|
-
that._computedColumnSpans = false;
|
|
373
|
-
that._mappingsPtr = 0;
|
|
374
|
-
that._wasm = null;
|
|
375
|
-
return wasm().then((w) => {
|
|
376
|
-
that._wasm = w;
|
|
377
|
-
return that;
|
|
378
|
-
});
|
|
379
|
-
});
|
|
310
|
+
const ensureDirectory = createSafeHandler((url) => {
|
|
311
|
+
url.pathname = url.pathname.replace(/\/?$/, "/");
|
|
312
|
+
}),trimFilename = createSafeHandler((url) => {
|
|
313
|
+
url.href = new URL(".", url.toString()).toString();
|
|
314
|
+
}),normalize = createSafeHandler((url) => {
|
|
315
|
+
});
|
|
316
|
+
exports.normalize = normalize;
|
|
317
|
+
function join(aRoot,aPath) {
|
|
318
|
+
const pathType = getURLType(aPath),rootType = getURLType(aRoot);
|
|
319
|
+
aRoot = ensureDirectory(aRoot);
|
|
320
|
+
if (pathType === "absolute") {
|
|
321
|
+
return withBase(aPath, undefined);
|
|
380
322
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
if (typeof cachedIndex == "number") {
|
|
384
|
-
return cachedIndex;
|
|
385
|
-
}
|
|
386
|
-
const sourceAsMapRelative = util.computeSourceURL(null, aSource, this._sourceMapURL);
|
|
387
|
-
if (this._absoluteSources.has(sourceAsMapRelative)) {
|
|
388
|
-
const index = this._absoluteSources.indexOf(sourceAsMapRelative);
|
|
389
|
-
this._sourceLookupCache.set(aSource, index);
|
|
390
|
-
return index;
|
|
391
|
-
}
|
|
392
|
-
const sourceAsSourceRootRelative = util.computeSourceURL(this.sourceRoot, aSource, this._sourceMapURL);
|
|
393
|
-
if (this._absoluteSources.has(sourceAsSourceRootRelative)) {
|
|
394
|
-
const index = this._absoluteSources.indexOf(sourceAsSourceRootRelative);
|
|
395
|
-
this._sourceLookupCache.set(aSource, index);
|
|
396
|
-
return index;
|
|
397
|
-
}
|
|
398
|
-
return -1;
|
|
323
|
+
if (rootType === "absolute") {
|
|
324
|
+
return withBase(aPath, aRoot);
|
|
399
325
|
}
|
|
400
|
-
|
|
401
|
-
return
|
|
326
|
+
if (pathType === "scheme-relative") {
|
|
327
|
+
return normalize(aPath);
|
|
402
328
|
}
|
|
403
|
-
|
|
404
|
-
return
|
|
329
|
+
if (rootType === "scheme-relative") {
|
|
330
|
+
return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(PROTOCOL.length);
|
|
405
331
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
332
|
+
if (pathType === "path-absolute") {
|
|
333
|
+
return normalize(aPath);
|
|
334
|
+
}
|
|
335
|
+
if (rootType === "path-absolute") {
|
|
336
|
+
return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(PROTOCOL_AND_HOST.length);
|
|
337
|
+
}
|
|
338
|
+
const base = buildSafeBase(aPath + aRoot),newPath = withBase(aPath, withBase(aRoot, base));
|
|
339
|
+
return computeRelativeURL(base, newPath);
|
|
340
|
+
}
|
|
341
|
+
exports.join = join;
|
|
342
|
+
function relative(rootURL,targetURL) {
|
|
343
|
+
const result = relativeIfPossible(rootURL, targetURL);
|
|
344
|
+
return typeof result == "string" ? result : normalize(targetURL);
|
|
345
|
+
}
|
|
346
|
+
exports.relative = relative;
|
|
347
|
+
function relativeIfPossible(rootURL,targetURL) {
|
|
348
|
+
const urlType = getURLType(rootURL);
|
|
349
|
+
if (urlType !== getURLType(targetURL)) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
const base = buildSafeBase(rootURL + targetURL),root = new URL(rootURL, base),target = new URL(targetURL, base);
|
|
353
|
+
try {
|
|
354
|
+
new URL("", target.toString());
|
|
355
|
+
} catch (err) {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
if (target.protocol !== root.protocol || target.user !== root.user || target.password !== root.password || target.hostname !== root.hostname || target.port !== root.port) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
return computeRelativeURL(root, target);
|
|
362
|
+
}
|
|
363
|
+
function computeSourceURL(sourceRoot,sourceURL,sourceMapURL) {
|
|
364
|
+
if (sourceRoot && getURLType(sourceURL) === "path-absolute") {
|
|
365
|
+
sourceURL = sourceURL.replace(/^\//, "");
|
|
366
|
+
}
|
|
367
|
+
let url = normalize(sourceURL || "");
|
|
368
|
+
if (sourceRoot)url = join(sourceRoot, url);
|
|
369
|
+
if (sourceMapURL)url = join(trimFilename(sourceMapURL), url);
|
|
370
|
+
return url;
|
|
371
|
+
}
|
|
372
|
+
exports.computeSourceURL = computeSourceURL;
|
|
373
|
+
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region array-set.js
|
|
378
|
+
var require_source_map_lib_array_set = __commonJS({
|
|
379
|
+
"array-set.js"(exports, module) {
|
|
380
|
+
class ArraySet {
|
|
381
|
+
constructor() {
|
|
382
|
+
this._array = [];
|
|
383
|
+
this._set = new Map();
|
|
384
|
+
}
|
|
385
|
+
static fromArray(aArray,aAllowDuplicates) {
|
|
386
|
+
const set = new ArraySet();
|
|
387
|
+
for (let i = 0,len = aArray.length; i < len; i++) {
|
|
388
|
+
set.add(aArray[i], aAllowDuplicates);
|
|
409
389
|
}
|
|
410
|
-
return
|
|
390
|
+
return set;
|
|
411
391
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
392
|
+
size() {
|
|
393
|
+
return this._set.size;
|
|
394
|
+
}
|
|
395
|
+
add(aStr,aAllowDuplicates) {
|
|
396
|
+
const isDuplicate = this.has(aStr),idx = this._array.length;
|
|
397
|
+
if (!isDuplicate || aAllowDuplicates) {
|
|
398
|
+
this._array.push(aStr);
|
|
416
399
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const error = this._wasm.exports.get_last_error();
|
|
420
|
-
let msg = `Error parsing mappings (code ${error}): `;
|
|
421
|
-
switch (error) {
|
|
422
|
-
case 1:
|
|
423
|
-
msg += "the mappings contained a negative line, column, source index, or name index";
|
|
424
|
-
break;
|
|
425
|
-
case 2:
|
|
426
|
-
msg += "the mappings contained a number larger than 2**32";
|
|
427
|
-
break;
|
|
428
|
-
case 3:
|
|
429
|
-
msg += "reached EOF while in the middle of parsing a VLQ";
|
|
430
|
-
break;
|
|
431
|
-
case 4:
|
|
432
|
-
msg += "invalid base 64 character while parsing a VLQ";
|
|
433
|
-
break;
|
|
434
|
-
default:
|
|
435
|
-
msg += "unknown error code";
|
|
436
|
-
break;
|
|
437
|
-
}
|
|
438
|
-
throw new Error(msg);
|
|
400
|
+
if (!isDuplicate) {
|
|
401
|
+
this._set.set(aStr, idx);
|
|
439
402
|
}
|
|
440
|
-
this._mappingsPtr = mappingsPtr;
|
|
441
403
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
this._wasm.withMappingCallback((mapping) => {
|
|
445
|
-
if (mapping.source !== null) {
|
|
446
|
-
mapping.source = this._absoluteSources.at(mapping.source);
|
|
447
|
-
if (mapping.name !== null) {
|
|
448
|
-
mapping.name = this._names.at(mapping.name);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
if (this._computedColumnSpans && mapping.lastGeneratedColumn === null) {
|
|
452
|
-
mapping.lastGeneratedColumn = Infinity;
|
|
453
|
-
}
|
|
454
|
-
aCallback.call(context, mapping);
|
|
455
|
-
}, () => {
|
|
456
|
-
switch (order) {
|
|
457
|
-
case SourceMapConsumer.GENERATED_ORDER:
|
|
458
|
-
this._wasm.exports.by_generated_location(this._getMappingsPtr());
|
|
459
|
-
break;
|
|
460
|
-
case SourceMapConsumer.ORIGINAL_ORDER:
|
|
461
|
-
this._wasm.exports.by_original_location(this._getMappingsPtr());
|
|
462
|
-
break;
|
|
463
|
-
default:
|
|
464
|
-
throw new Error("Unknown order of iteration.");
|
|
465
|
-
}
|
|
466
|
-
});
|
|
404
|
+
has(aStr) {
|
|
405
|
+
return this._set.has(aStr);
|
|
467
406
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
if (source < 0) {
|
|
473
|
-
return [];
|
|
474
|
-
}
|
|
475
|
-
if (originalLine < 1) {
|
|
476
|
-
throw new Error("Line numbers must be >= 1");
|
|
477
|
-
}
|
|
478
|
-
if (originalColumn < 0) {
|
|
479
|
-
throw new Error("Column numbers must be >= 0");
|
|
407
|
+
indexOf(aStr) {
|
|
408
|
+
const idx = this._set.get(aStr);
|
|
409
|
+
if (idx >= 0) {
|
|
410
|
+
return idx;
|
|
480
411
|
}
|
|
481
|
-
|
|
482
|
-
this._wasm.withMappingCallback((m) => {
|
|
483
|
-
let lastColumn = m.lastGeneratedColumn;
|
|
484
|
-
if (this._computedColumnSpans && lastColumn === null) {
|
|
485
|
-
lastColumn = Infinity;
|
|
486
|
-
}
|
|
487
|
-
mappings.push({ line: m.generatedLine, column: m.generatedColumn, lastColumn });
|
|
488
|
-
}, () => {
|
|
489
|
-
this._wasm.exports.all_generated_locations_for(this._getMappingsPtr(), source, originalLine - 1, "column" in aArgs, originalColumn);
|
|
490
|
-
});
|
|
491
|
-
return mappings;
|
|
412
|
+
throw new Error("\"" + aStr + "\" is not in the set.");
|
|
492
413
|
}
|
|
493
|
-
|
|
494
|
-
if (
|
|
495
|
-
this.
|
|
496
|
-
this._mappingsPtr = 0;
|
|
414
|
+
at(aIdx) {
|
|
415
|
+
if (aIdx >= 0 && aIdx < this._array.length) {
|
|
416
|
+
return this._array[aIdx];
|
|
497
417
|
}
|
|
418
|
+
throw new Error("No element indexed by " + aIdx);
|
|
498
419
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
this._wasm.exports.compute_column_spans(this._getMappingsPtr());
|
|
504
|
-
this._computedColumnSpans = true;
|
|
420
|
+
toArray() {
|
|
421
|
+
return this._array.slice();
|
|
505
422
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
423
|
+
}
|
|
424
|
+
exports.ArraySet = ArraySet;
|
|
425
|
+
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region mapping-list.js
|
|
430
|
+
var require_source_map_lib_mapping_list = __commonJS({
|
|
431
|
+
"mapping-list.js"(exports, module) {
|
|
432
|
+
const util = require_source_map_lib_util();
|
|
433
|
+
function generatedPositionAfter(mappingA,mappingB) {
|
|
434
|
+
const lineA = mappingA.generatedLine,lineB = mappingB.generatedLine,columnA = mappingA.generatedColumn,columnB = mappingB.generatedColumn;
|
|
435
|
+
return lineB > lineA || lineB == lineA && columnB >= columnA || util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
|
|
436
|
+
}
|
|
437
|
+
class MappingList {
|
|
438
|
+
constructor() {
|
|
439
|
+
this._array = [];
|
|
440
|
+
this._sorted = true;
|
|
441
|
+
this._last = { generatedLine: -1, generatedColumn: 0 };
|
|
442
|
+
}
|
|
443
|
+
unsortedForEach(aCallback,aThisArg) {
|
|
444
|
+
this._array.forEach(aCallback, aThisArg);
|
|
445
|
+
}
|
|
446
|
+
add(aMapping) {
|
|
447
|
+
if (generatedPositionAfter(this._last, aMapping)) {
|
|
448
|
+
this._last = aMapping;
|
|
449
|
+
this._array.push(aMapping);
|
|
450
|
+
} else {
|
|
451
|
+
this._sorted = false;
|
|
452
|
+
this._array.push(aMapping);
|
|
510
453
|
}
|
|
511
|
-
|
|
512
|
-
|
|
454
|
+
}
|
|
455
|
+
toArray() {
|
|
456
|
+
if (!this._sorted) {
|
|
457
|
+
this._array.sort(util.compareByGeneratedPositionsInflated);
|
|
458
|
+
this._sorted = true;
|
|
513
459
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
460
|
+
return this._array;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
exports.MappingList = MappingList;
|
|
464
|
+
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region source-map-generator.js
|
|
469
|
+
var require_source_map_lib_source_map_generator = __commonJS({
|
|
470
|
+
"source-map-generator.js"(exports, module) {
|
|
471
|
+
const base64VLQ = require_source_map_lib_base64_vlq(),util = require_source_map_lib_util(),ArraySet = require_source_map_lib_array_set().ArraySet,MappingList = require_source_map_lib_mapping_list().MappingList;
|
|
472
|
+
class SourceMapGenerator {
|
|
473
|
+
constructor(aArgs) {
|
|
474
|
+
if (!aArgs) {
|
|
475
|
+
aArgs = {};
|
|
517
476
|
}
|
|
518
|
-
|
|
519
|
-
this.
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
477
|
+
this._file = util.getArg(aArgs, "file", null);
|
|
478
|
+
this._sourceRoot = util.getArg(aArgs, "sourceRoot", null);
|
|
479
|
+
this._skipValidation = util.getArg(aArgs, "skipValidation", false);
|
|
480
|
+
this._sources = new ArraySet();
|
|
481
|
+
this._names = new ArraySet();
|
|
482
|
+
this._mappings = new MappingList();
|
|
483
|
+
this._sourcesContents = null;
|
|
484
|
+
}
|
|
485
|
+
static fromSourceMap(aSourceMapConsumer) {
|
|
486
|
+
const sourceRoot = aSourceMapConsumer.sourceRoot,generator = new SourceMapGenerator({ file: aSourceMapConsumer.file, sourceRoot });
|
|
487
|
+
aSourceMapConsumer.eachMapping(function(mapping) {
|
|
488
|
+
const newMapping = { generated: { line: mapping.generatedLine, column: mapping.generatedColumn } };
|
|
489
|
+
if (mapping.source != null) {
|
|
490
|
+
newMapping.source = mapping.source;
|
|
491
|
+
if (sourceRoot != null) {
|
|
492
|
+
newMapping.source = util.relative(sourceRoot, newMapping.source);
|
|
527
493
|
}
|
|
528
|
-
|
|
529
|
-
if (name
|
|
530
|
-
name =
|
|
494
|
+
newMapping.original = { line: mapping.originalLine, column: mapping.originalColumn };
|
|
495
|
+
if (mapping.name != null) {
|
|
496
|
+
newMapping.name = mapping.name;
|
|
531
497
|
}
|
|
532
|
-
return { source, line: util.getArg(mapping, "originalLine", null), column: util.getArg(mapping, "originalColumn", null), name };
|
|
533
498
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
499
|
+
generator.addMapping(newMapping);
|
|
500
|
+
});
|
|
501
|
+
aSourceMapConsumer.sources.forEach(function(sourceFile) {
|
|
502
|
+
let sourceRelative = sourceFile;
|
|
503
|
+
if (sourceRoot != null) {
|
|
504
|
+
sourceRelative = util.relative(sourceRoot, sourceFile);
|
|
505
|
+
}
|
|
506
|
+
if (!generator._sources.has(sourceRelative)) {
|
|
507
|
+
generator._sources.add(sourceRelative);
|
|
508
|
+
}
|
|
509
|
+
const content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
|
510
|
+
if (content != null) {
|
|
511
|
+
generator.setSourceContent(sourceFile, content);
|
|
512
|
+
}
|
|
543
513
|
});
|
|
514
|
+
return generator;
|
|
544
515
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
516
|
+
addMapping(aArgs) {
|
|
517
|
+
const generated = util.getArg(aArgs, "generated"),original = util.getArg(aArgs, "original", null);
|
|
518
|
+
let source = util.getArg(aArgs, "source", null),name = util.getArg(aArgs, "name", null);
|
|
519
|
+
if (!this._skipValidation) {
|
|
520
|
+
this._validateMapping(generated, original, source, name);
|
|
548
521
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
522
|
+
if (source != null) {
|
|
523
|
+
source = String(source);
|
|
524
|
+
if (!this._sources.has(source)) {
|
|
525
|
+
this._sources.add(source);
|
|
526
|
+
}
|
|
552
527
|
}
|
|
553
|
-
if (
|
|
554
|
-
|
|
528
|
+
if (name != null) {
|
|
529
|
+
name = String(name);
|
|
530
|
+
if (!this._names.has(name)) {
|
|
531
|
+
this._names.add(name);
|
|
532
|
+
}
|
|
555
533
|
}
|
|
556
|
-
|
|
534
|
+
this._mappings.add({ generatedLine: generated.line, generatedColumn: generated.column, originalLine: original && original.line, originalColumn: original && original.column, source, name });
|
|
557
535
|
}
|
|
558
|
-
|
|
559
|
-
let source =
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
return { line: null, column: null, lastColumn: null };
|
|
563
|
-
}
|
|
564
|
-
const needle = { source, originalLine: util.getArg(aArgs, "line"), originalColumn: util.getArg(aArgs, "column") };
|
|
565
|
-
if (needle.originalLine < 1) {
|
|
566
|
-
throw new Error("Line numbers must be >= 1");
|
|
567
|
-
}
|
|
568
|
-
if (needle.originalColumn < 0) {
|
|
569
|
-
throw new Error("Column numbers must be >= 0");
|
|
570
|
-
}
|
|
571
|
-
let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
|
|
572
|
-
if (bias == null) {
|
|
573
|
-
bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
|
|
536
|
+
setSourceContent(aSourceFile,aSourceContent) {
|
|
537
|
+
let source = aSourceFile;
|
|
538
|
+
if (this._sourceRoot != null) {
|
|
539
|
+
source = util.relative(this._sourceRoot, source);
|
|
574
540
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
return { line: util.getArg(mapping, "generatedLine", null), column: util.getArg(mapping, "generatedColumn", null), lastColumn };
|
|
541
|
+
if (aSourceContent != null) {
|
|
542
|
+
if (!this._sourcesContents) {
|
|
543
|
+
this._sourcesContents = Object.create(null);
|
|
544
|
+
}
|
|
545
|
+
this._sourcesContents[util.toSetString(source)] = aSourceContent;
|
|
546
|
+
} else if (this._sourcesContents) {
|
|
547
|
+
delete this._sourcesContents[util.toSetString(source)];
|
|
548
|
+
if (Object.keys(this._sourcesContents).length === 0) {
|
|
549
|
+
this._sourcesContents = null;
|
|
586
550
|
}
|
|
587
551
|
}
|
|
588
|
-
return { line: null, column: null, lastColumn: null };
|
|
589
552
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
return super(INTERNAL).then((that) => {
|
|
596
|
-
let sourceMap = aSourceMap;
|
|
597
|
-
if (typeof aSourceMap == "string") {
|
|
598
|
-
sourceMap = util.parseSourceMapInput(aSourceMap);
|
|
599
|
-
}
|
|
600
|
-
const version = util.getArg(sourceMap, "version"),sections = util.getArg(sourceMap, "sections");
|
|
601
|
-
if (version != that._version) {
|
|
602
|
-
throw new Error("Unsupported version: " + version);
|
|
603
|
-
}
|
|
604
|
-
let lastOffset = { line: -1, column: 0 };
|
|
605
|
-
return Promise.all(sections.map((s) => {
|
|
606
|
-
if (s.url) {
|
|
607
|
-
throw new Error("Support for url field in sections not implemented.");
|
|
608
|
-
}
|
|
609
|
-
const offset = util.getArg(s, "offset"),offsetLine = util.getArg(offset, "line"),offsetColumn = util.getArg(offset, "column");
|
|
610
|
-
if (offsetLine < lastOffset.line || offsetLine === lastOffset.line && offsetColumn < lastOffset.column) {
|
|
611
|
-
throw new Error("Section offsets must be ordered and non-overlapping.");
|
|
612
|
-
}
|
|
613
|
-
lastOffset = offset;
|
|
614
|
-
const cons = new SourceMapConsumer(util.getArg(s, "map"), aSourceMapURL);
|
|
615
|
-
return cons.then((consumer) => {
|
|
616
|
-
return { generatedOffset: { generatedLine: offsetLine + 1, generatedColumn: offsetColumn + 1 }, consumer };
|
|
617
|
-
});
|
|
618
|
-
})).then((s) => {
|
|
619
|
-
that._sections = s;
|
|
620
|
-
return that;
|
|
621
|
-
});
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
get sources() {
|
|
625
|
-
const sources = [];
|
|
626
|
-
for (let i = 0; i < this._sections.length; i++) {
|
|
627
|
-
for (let j = 0; j < this._sections[i].consumer.sources.length; j++) {
|
|
628
|
-
sources.push(this._sections[i].consumer.sources[j]);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
return sources;
|
|
632
|
-
}
|
|
633
|
-
originalPositionFor(aArgs) {
|
|
634
|
-
const needle = { generatedLine: util.getArg(aArgs, "line"), generatedColumn: util.getArg(aArgs, "column") },sectionIndex = binarySearch.search(needle, this._sections, function(aNeedle,section) {
|
|
635
|
-
const cmp = aNeedle.generatedLine - section.generatedOffset.generatedLine;
|
|
636
|
-
if (cmp) {
|
|
637
|
-
return cmp;
|
|
638
|
-
}
|
|
639
|
-
return aNeedle.generatedColumn - (section.generatedOffset.generatedColumn - 1);
|
|
640
|
-
}),section = this._sections[sectionIndex];
|
|
641
|
-
if (!section) {
|
|
642
|
-
return { source: null, line: null, column: null, name: null };
|
|
643
|
-
}
|
|
644
|
-
return section.consumer.originalPositionFor({ line: needle.generatedLine - (section.generatedOffset.generatedLine - 1), column: needle.generatedColumn - (section.generatedOffset.generatedLine === needle.generatedLine ? section.generatedOffset.generatedColumn - 1 : 0), bias: aArgs.bias });
|
|
645
|
-
}
|
|
646
|
-
hasContentsOfAllSources() {
|
|
647
|
-
return this._sections.every(function(s) {
|
|
648
|
-
return s.consumer.hasContentsOfAllSources();
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
sourceContentFor(aSource,nullOnMissing) {
|
|
652
|
-
for (let i = 0; i < this._sections.length; i++) {
|
|
653
|
-
const section = this._sections[i],content = section.consumer.sourceContentFor(aSource, true);
|
|
654
|
-
if (content) {
|
|
655
|
-
return content;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
if (nullOnMissing) {
|
|
659
|
-
return null;
|
|
660
|
-
}
|
|
661
|
-
throw new Error("\"" + aSource + "\" is not in the SourceMap.");
|
|
662
|
-
}
|
|
663
|
-
_findSectionIndex(source) {
|
|
664
|
-
for (let i = 0; i < this._sections.length; i++) {
|
|
665
|
-
const { consumer:consumer } = this._sections[i];
|
|
666
|
-
if (consumer._findSourceIndex(source) !== -1) {
|
|
667
|
-
return i;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
return -1;
|
|
671
|
-
}
|
|
672
|
-
generatedPositionFor(aArgs) {
|
|
673
|
-
const index = this._findSectionIndex(util.getArg(aArgs, "source")),section = index >= 0 ? this._sections[index] : null,nextSection = index >= 0 && index + 1 < this._sections.length ? this._sections[index + 1] : null,generatedPosition = section && section.consumer.generatedPositionFor(aArgs);
|
|
674
|
-
if (generatedPosition && generatedPosition.line !== null) {
|
|
675
|
-
const lineShift = section.generatedOffset.generatedLine - 1,columnShift = section.generatedOffset.generatedColumn - 1;
|
|
676
|
-
if (generatedPosition.line === 1) {
|
|
677
|
-
generatedPosition.column += columnShift;
|
|
678
|
-
if (typeof generatedPosition.lastColumn == "number") {
|
|
679
|
-
generatedPosition.lastColumn += columnShift;
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
if (generatedPosition.lastColumn === Infinity && nextSection && generatedPosition.line === nextSection.generatedOffset.generatedLine) {
|
|
683
|
-
generatedPosition.lastColumn = nextSection.generatedOffset.generatedColumn - 2;
|
|
684
|
-
}
|
|
685
|
-
generatedPosition.line += lineShift;
|
|
686
|
-
return generatedPosition;
|
|
687
|
-
}
|
|
688
|
-
return { line: null, column: null, lastColumn: null };
|
|
689
|
-
}
|
|
690
|
-
allGeneratedPositionsFor(aArgs) {
|
|
691
|
-
const index = this._findSectionIndex(util.getArg(aArgs, "source")),section = index >= 0 ? this._sections[index] : null,nextSection = index >= 0 && index + 1 < this._sections.length ? this._sections[index + 1] : null;
|
|
692
|
-
if (!section)return [];
|
|
693
|
-
return section.consumer.allGeneratedPositionsFor(aArgs).map((generatedPosition) => {
|
|
694
|
-
const lineShift = section.generatedOffset.generatedLine - 1,columnShift = section.generatedOffset.generatedColumn - 1;
|
|
695
|
-
if (generatedPosition.line === 1) {
|
|
696
|
-
generatedPosition.column += columnShift;
|
|
697
|
-
if (typeof generatedPosition.lastColumn == "number") {
|
|
698
|
-
generatedPosition.lastColumn += columnShift;
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
if (generatedPosition.lastColumn === Infinity && nextSection && generatedPosition.line === nextSection.generatedOffset.generatedLine) {
|
|
702
|
-
generatedPosition.lastColumn = nextSection.generatedOffset.generatedColumn - 2;
|
|
703
|
-
}
|
|
704
|
-
generatedPosition.line += lineShift;
|
|
705
|
-
return generatedPosition;
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
eachMapping(aCallback,aContext,aOrder) {
|
|
709
|
-
this._sections.forEach((section, index) => {
|
|
710
|
-
const nextSection = index + 1 < this._sections.length ? this._sections[index + 1] : null,{ generatedOffset:generatedOffset } = section,lineShift = generatedOffset.generatedLine - 1,columnShift = generatedOffset.generatedColumn - 1;
|
|
711
|
-
section.consumer.eachMapping(function(mapping) {
|
|
712
|
-
if (mapping.generatedLine === 1) {
|
|
713
|
-
mapping.generatedColumn += columnShift;
|
|
714
|
-
if (typeof mapping.lastGeneratedColumn == "number") {
|
|
715
|
-
mapping.lastGeneratedColumn += columnShift;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
if (mapping.lastGeneratedColumn === Infinity && nextSection && mapping.generatedLine === nextSection.generatedOffset.generatedLine) {
|
|
719
|
-
mapping.lastGeneratedColumn = nextSection.generatedOffset.generatedColumn - 2;
|
|
720
|
-
}
|
|
721
|
-
mapping.generatedLine += lineShift;
|
|
722
|
-
aCallback.call(this, mapping);
|
|
723
|
-
}, aContext, aOrder);
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
computeColumnSpans() {
|
|
727
|
-
for (let i = 0; i < this._sections.length; i++) {
|
|
728
|
-
this._sections[i].consumer.computeColumnSpans();
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
destroy() {
|
|
732
|
-
for (let i = 0; i < this._sections.length; i++) {
|
|
733
|
-
this._sections[i].consumer.destroy();
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
|
|
738
|
-
function _factory(aSourceMap,aSourceMapURL) {
|
|
739
|
-
let sourceMap = aSourceMap;
|
|
740
|
-
if (typeof aSourceMap == "string") {
|
|
741
|
-
sourceMap = util.parseSourceMapInput(aSourceMap);
|
|
742
|
-
}
|
|
743
|
-
const consumer = sourceMap.sections != null ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL) : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
|
|
744
|
-
return Promise.resolve(consumer);
|
|
745
|
-
}
|
|
746
|
-
function _factoryBSM(aSourceMap,aSourceMapURL) {
|
|
747
|
-
return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
//#endregion
|
|
753
|
-
//#region source-map-generator.js
|
|
754
|
-
var require_source_map_lib_source_map_generator = __commonJS({
|
|
755
|
-
"source-map-generator.js"(exports, module) {
|
|
756
|
-
const base64VLQ = require_source_map_lib_base64_vlq(),util = require_source_map_lib_util(),ArraySet = require_source_map_lib_array_set().ArraySet,MappingList = require_source_map_lib_mapping_list().MappingList;
|
|
757
|
-
class SourceMapGenerator {
|
|
758
|
-
constructor(aArgs) {
|
|
759
|
-
if (!aArgs) {
|
|
760
|
-
aArgs = {};
|
|
761
|
-
}
|
|
762
|
-
this._file = util.getArg(aArgs, "file", null);
|
|
763
|
-
this._sourceRoot = util.getArg(aArgs, "sourceRoot", null);
|
|
764
|
-
this._skipValidation = util.getArg(aArgs, "skipValidation", false);
|
|
765
|
-
this._sources = new ArraySet();
|
|
766
|
-
this._names = new ArraySet();
|
|
767
|
-
this._mappings = new MappingList();
|
|
768
|
-
this._sourcesContents = null;
|
|
769
|
-
}
|
|
770
|
-
static fromSourceMap(aSourceMapConsumer) {
|
|
771
|
-
const sourceRoot = aSourceMapConsumer.sourceRoot,generator = new SourceMapGenerator({ file: aSourceMapConsumer.file, sourceRoot });
|
|
772
|
-
aSourceMapConsumer.eachMapping(function(mapping) {
|
|
773
|
-
const newMapping = { generated: { line: mapping.generatedLine, column: mapping.generatedColumn } };
|
|
774
|
-
if (mapping.source != null) {
|
|
775
|
-
newMapping.source = mapping.source;
|
|
776
|
-
if (sourceRoot != null) {
|
|
777
|
-
newMapping.source = util.relative(sourceRoot, newMapping.source);
|
|
778
|
-
}
|
|
779
|
-
newMapping.original = { line: mapping.originalLine, column: mapping.originalColumn };
|
|
780
|
-
if (mapping.name != null) {
|
|
781
|
-
newMapping.name = mapping.name;
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
generator.addMapping(newMapping);
|
|
785
|
-
});
|
|
786
|
-
aSourceMapConsumer.sources.forEach(function(sourceFile) {
|
|
787
|
-
let sourceRelative = sourceFile;
|
|
788
|
-
if (sourceRoot != null) {
|
|
789
|
-
sourceRelative = util.relative(sourceRoot, sourceFile);
|
|
790
|
-
}
|
|
791
|
-
if (!generator._sources.has(sourceRelative)) {
|
|
792
|
-
generator._sources.add(sourceRelative);
|
|
793
|
-
}
|
|
794
|
-
const content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
|
795
|
-
if (content != null) {
|
|
796
|
-
generator.setSourceContent(sourceFile, content);
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
return generator;
|
|
800
|
-
}
|
|
801
|
-
addMapping(aArgs) {
|
|
802
|
-
const generated = util.getArg(aArgs, "generated"),original = util.getArg(aArgs, "original", null);
|
|
803
|
-
let source = util.getArg(aArgs, "source", null),name = util.getArg(aArgs, "name", null);
|
|
804
|
-
if (!this._skipValidation) {
|
|
805
|
-
this._validateMapping(generated, original, source, name);
|
|
806
|
-
}
|
|
807
|
-
if (source != null) {
|
|
808
|
-
source = String(source);
|
|
809
|
-
if (!this._sources.has(source)) {
|
|
810
|
-
this._sources.add(source);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
if (name != null) {
|
|
814
|
-
name = String(name);
|
|
815
|
-
if (!this._names.has(name)) {
|
|
816
|
-
this._names.add(name);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
this._mappings.add({ generatedLine: generated.line, generatedColumn: generated.column, originalLine: original && original.line, originalColumn: original && original.column, source, name });
|
|
820
|
-
}
|
|
821
|
-
setSourceContent(aSourceFile,aSourceContent) {
|
|
822
|
-
let source = aSourceFile;
|
|
823
|
-
if (this._sourceRoot != null) {
|
|
824
|
-
source = util.relative(this._sourceRoot, source);
|
|
825
|
-
}
|
|
826
|
-
if (aSourceContent != null) {
|
|
827
|
-
if (!this._sourcesContents) {
|
|
828
|
-
this._sourcesContents = Object.create(null);
|
|
829
|
-
}
|
|
830
|
-
this._sourcesContents[util.toSetString(source)] = aSourceContent;
|
|
831
|
-
} else if (this._sourcesContents) {
|
|
832
|
-
delete this._sourcesContents[util.toSetString(source)];
|
|
833
|
-
if (Object.keys(this._sourcesContents).length === 0) {
|
|
834
|
-
this._sourcesContents = null;
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
applySourceMap(aSourceMapConsumer,aSourceFile,aSourceMapPath) {
|
|
839
|
-
let sourceFile = aSourceFile;
|
|
840
|
-
if (aSourceFile == null) {
|
|
841
|
-
if (aSourceMapConsumer.file == null) {
|
|
842
|
-
throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, " + "or the source map's \"file\" property. Both were omitted.");
|
|
553
|
+
applySourceMap(aSourceMapConsumer,aSourceFile,aSourceMapPath) {
|
|
554
|
+
let sourceFile = aSourceFile;
|
|
555
|
+
if (aSourceFile == null) {
|
|
556
|
+
if (aSourceMapConsumer.file == null) {
|
|
557
|
+
throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, " + "or the source map's \"file\" property. Both were omitted.");
|
|
843
558
|
}
|
|
844
559
|
sourceFile = aSourceMapConsumer.file;
|
|
845
560
|
}
|
|
@@ -973,520 +688,805 @@ const base64VLQ = require_source_map_lib_base64_vlq(),util = require_source_map_
|
|
|
973
688
|
}
|
|
974
689
|
});
|
|
975
690
|
//#endregion
|
|
976
|
-
//#region
|
|
977
|
-
var
|
|
978
|
-
"
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
this[isSourceNode] = true;
|
|
989
|
-
if (aChunks != null)this.add(aChunks);
|
|
990
|
-
}
|
|
991
|
-
static fromStringWithSourceMap(aGeneratedCode,aSourceMapConsumer,aRelativePath) {
|
|
992
|
-
const node = new SourceNode(),remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
|
|
993
|
-
let remainingLinesIndex = 0;
|
|
994
|
-
const shiftNextLine = function() {
|
|
995
|
-
const lineContents = getNextLine(),newLine = getNextLine() || "";
|
|
996
|
-
return lineContents + newLine;
|
|
997
|
-
function getNextLine() {
|
|
998
|
-
return remainingLinesIndex < remainingLines.length ? remainingLines[remainingLinesIndex++] : undefined;
|
|
999
|
-
}
|
|
1000
|
-
};
|
|
1001
|
-
let lastGeneratedLine = 1,lastGeneratedColumn = 0,lastMapping = null,nextLine;
|
|
1002
|
-
aSourceMapConsumer.eachMapping(function(mapping) {
|
|
1003
|
-
if (lastMapping !== null) {
|
|
1004
|
-
if (lastGeneratedLine < mapping.generatedLine) {
|
|
1005
|
-
addMappingWithCode(lastMapping, shiftNextLine());
|
|
1006
|
-
lastGeneratedLine++;
|
|
1007
|
-
lastGeneratedColumn = 0;
|
|
1008
|
-
} else {
|
|
1009
|
-
nextLine = remainingLines[remainingLinesIndex] || "";
|
|
1010
|
-
const code = nextLine.substr(0, mapping.generatedColumn - lastGeneratedColumn);
|
|
1011
|
-
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - lastGeneratedColumn);
|
|
1012
|
-
lastGeneratedColumn = mapping.generatedColumn;
|
|
1013
|
-
addMappingWithCode(lastMapping, code);
|
|
1014
|
-
lastMapping = mapping;
|
|
1015
|
-
return;
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
while (lastGeneratedLine < mapping.generatedLine) {
|
|
1019
|
-
node.add(shiftNextLine());
|
|
1020
|
-
lastGeneratedLine++;
|
|
1021
|
-
}
|
|
1022
|
-
if (lastGeneratedColumn < mapping.generatedColumn) {
|
|
1023
|
-
nextLine = remainingLines[remainingLinesIndex] || "";
|
|
1024
|
-
node.add(nextLine.substr(0, mapping.generatedColumn));
|
|
1025
|
-
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
|
|
1026
|
-
lastGeneratedColumn = mapping.generatedColumn;
|
|
1027
|
-
}
|
|
1028
|
-
lastMapping = mapping;
|
|
1029
|
-
}, this);
|
|
1030
|
-
if (remainingLinesIndex < remainingLines.length) {
|
|
1031
|
-
if (lastMapping) {
|
|
1032
|
-
addMappingWithCode(lastMapping, shiftNextLine());
|
|
1033
|
-
}
|
|
1034
|
-
node.add(remainingLines.splice(remainingLinesIndex).join(""));
|
|
1035
|
-
}
|
|
1036
|
-
aSourceMapConsumer.sources.forEach(function(sourceFile) {
|
|
1037
|
-
const content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
|
1038
|
-
if (content != null) {
|
|
1039
|
-
if (aRelativePath != null) {
|
|
1040
|
-
sourceFile = util.join(aRelativePath, sourceFile);
|
|
1041
|
-
}
|
|
1042
|
-
node.setSourceContent(sourceFile, content);
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
return node;
|
|
1046
|
-
function addMappingWithCode(mapping,code) {
|
|
1047
|
-
if (mapping === null || mapping.source === undefined) {
|
|
1048
|
-
node.add(code);
|
|
1049
|
-
} else {
|
|
1050
|
-
const source = aRelativePath ? util.join(aRelativePath, mapping.source) : mapping.source;
|
|
1051
|
-
node.add(new SourceNode(mapping.originalLine, mapping.originalColumn, source, code, mapping.name));
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
add(aChunk) {
|
|
1056
|
-
if (Array.isArray(aChunk)) {
|
|
1057
|
-
aChunk.forEach(function(chunk) {
|
|
1058
|
-
this.add(chunk);
|
|
1059
|
-
}, this);
|
|
1060
|
-
} else if (aChunk[isSourceNode] || typeof aChunk == "string") {
|
|
1061
|
-
if (aChunk) {
|
|
1062
|
-
this.children.push(aChunk);
|
|
1063
|
-
}
|
|
1064
|
-
} else {
|
|
1065
|
-
throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk);
|
|
691
|
+
//#region binary-search.js
|
|
692
|
+
var require_source_map_lib_binary_search = __commonJS({
|
|
693
|
+
"binary-search.js"(exports, module) {
|
|
694
|
+
exports.GREATEST_LOWER_BOUND = 1;
|
|
695
|
+
exports.LEAST_UPPER_BOUND = 2;
|
|
696
|
+
function recursiveSearch(aLow,aHigh,aNeedle,aHaystack,aCompare,aBias) {
|
|
697
|
+
const mid = Math.floor((aHigh - aLow) / 2) + aLow,cmp = aCompare(aNeedle, aHaystack[mid], true);
|
|
698
|
+
if (cmp === 0) {
|
|
699
|
+
return mid;
|
|
700
|
+
} else if (cmp > 0) {
|
|
701
|
+
if (aHigh - mid > 1) {
|
|
702
|
+
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
|
|
1066
703
|
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
prepend(aChunk) {
|
|
1070
|
-
if (Array.isArray(aChunk)) {
|
|
1071
|
-
for (let i = aChunk.length - 1; i >= 0; i--) {
|
|
1072
|
-
this.prepend(aChunk[i]);
|
|
1073
|
-
}
|
|
1074
|
-
} else if (aChunk[isSourceNode] || typeof aChunk == "string") {
|
|
1075
|
-
this.children.unshift(aChunk);
|
|
1076
|
-
} else {
|
|
1077
|
-
throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk);
|
|
704
|
+
if (aBias === exports.LEAST_UPPER_BOUND) {
|
|
705
|
+
return aHigh < aHaystack.length ? aHigh : -1;
|
|
1078
706
|
}
|
|
1079
|
-
return
|
|
707
|
+
return mid;
|
|
1080
708
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
for (let i = 0,len = this.children.length; i < len; i++) {
|
|
1084
|
-
chunk = this.children[i];
|
|
1085
|
-
if (chunk[isSourceNode]) {
|
|
1086
|
-
chunk.walk(aFn);
|
|
1087
|
-
} else if (chunk !== "") {
|
|
1088
|
-
aFn(chunk, { source: this.source, line: this.line, column: this.column, name: this.name });
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
709
|
+
if (mid - aLow > 1) {
|
|
710
|
+
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
|
|
1091
711
|
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
const len = this.children.length;
|
|
1095
|
-
if (len > 0) {
|
|
1096
|
-
newChildren = [];
|
|
1097
|
-
for (i = 0; i < len - 1; i++) {
|
|
1098
|
-
newChildren.push(this.children[i]);
|
|
1099
|
-
newChildren.push(aSep);
|
|
1100
|
-
}
|
|
1101
|
-
newChildren.push(this.children[i]);
|
|
1102
|
-
this.children = newChildren;
|
|
1103
|
-
}
|
|
1104
|
-
return this;
|
|
712
|
+
if (aBias == exports.LEAST_UPPER_BOUND) {
|
|
713
|
+
return mid;
|
|
1105
714
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
|
|
1112
|
-
} else {
|
|
1113
|
-
this.children.push("".replace(aPattern, aReplacement));
|
|
1114
|
-
}
|
|
1115
|
-
return this;
|
|
715
|
+
return aLow < 0 ? -1 : aLow;
|
|
716
|
+
}
|
|
717
|
+
exports.search = function search(aNeedle,aHaystack,aCompare,aBias) {
|
|
718
|
+
if (aHaystack.length === 0) {
|
|
719
|
+
return -1;
|
|
1116
720
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
721
|
+
let index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare, aBias || exports.GREATEST_LOWER_BOUND);
|
|
722
|
+
if (index < 0) {
|
|
723
|
+
return -1;
|
|
1119
724
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
this.children[i].walkSourceContents(aFn);
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
const sources = Object.keys(this.sourceContents);
|
|
1127
|
-
for (let i = 0,len = sources.length; i < len; i++) {
|
|
1128
|
-
aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
|
|
725
|
+
while (index - 1 >= 0) {
|
|
726
|
+
if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
|
|
727
|
+
break;
|
|
1129
728
|
}
|
|
729
|
+
--index;
|
|
1130
730
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
this.walk(function(chunk) {
|
|
1134
|
-
str += chunk;
|
|
1135
|
-
});
|
|
1136
|
-
return str;
|
|
1137
|
-
}
|
|
1138
|
-
toStringWithSourceMap(aArgs) {
|
|
1139
|
-
const generated = { code: "", line: 1, column: 0 },map = new SourceMapGenerator(aArgs);
|
|
1140
|
-
let sourceMappingActive = false,lastOriginalSource = null,lastOriginalLine = null,lastOriginalColumn = null,lastOriginalName = null;
|
|
1141
|
-
this.walk(function(chunk,original) {
|
|
1142
|
-
generated.code += chunk;
|
|
1143
|
-
if (original.source !== null && original.line !== null && original.column !== null) {
|
|
1144
|
-
if (lastOriginalSource !== original.source || lastOriginalLine !== original.line || lastOriginalColumn !== original.column || lastOriginalName !== original.name) {
|
|
1145
|
-
map.addMapping({ source: original.source, original: { line: original.line, column: original.column }, generated: { line: generated.line, column: generated.column }, name: original.name });
|
|
1146
|
-
}
|
|
1147
|
-
lastOriginalSource = original.source;
|
|
1148
|
-
lastOriginalLine = original.line;
|
|
1149
|
-
lastOriginalColumn = original.column;
|
|
1150
|
-
lastOriginalName = original.name;
|
|
1151
|
-
sourceMappingActive = true;
|
|
1152
|
-
} else if (sourceMappingActive) {
|
|
1153
|
-
map.addMapping({ generated: { line: generated.line, column: generated.column } });
|
|
1154
|
-
lastOriginalSource = null;
|
|
1155
|
-
sourceMappingActive = false;
|
|
1156
|
-
}
|
|
1157
|
-
for (let idx = 0,length = chunk.length; idx < length; idx++) {
|
|
1158
|
-
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
|
|
1159
|
-
generated.line++;
|
|
1160
|
-
generated.column = 0;
|
|
1161
|
-
if (idx + 1 === length) {
|
|
1162
|
-
lastOriginalSource = null;
|
|
1163
|
-
sourceMappingActive = false;
|
|
1164
|
-
} else if (sourceMappingActive) {
|
|
1165
|
-
map.addMapping({ source: original.source, original: { line: original.line, column: original.column }, generated: { line: generated.line, column: generated.column }, name: original.name });
|
|
1166
|
-
}
|
|
1167
|
-
} else {
|
|
1168
|
-
generated.column++;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
});
|
|
1172
|
-
this.walkSourceContents(function(sourceFile,sourceContent) {
|
|
1173
|
-
map.setSourceContent(sourceFile, sourceContent);
|
|
1174
|
-
});
|
|
1175
|
-
return { code: generated.code, map };
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
exports.SourceNode = SourceNode;
|
|
731
|
+
return index;
|
|
732
|
+
};
|
|
1179
733
|
|
|
1180
734
|
}
|
|
1181
735
|
});
|
|
1182
736
|
//#endregion
|
|
1183
|
-
//#region
|
|
1184
|
-
var
|
|
1185
|
-
"
|
|
737
|
+
//#region read-wasm-browser.js
|
|
738
|
+
var require_source_map_lib_read_wasm_browser = __commonJS({
|
|
739
|
+
"read-wasm-browser.js"(exports, module) {
|
|
1186
740
|
"use strict";
|
|
1187
|
-
|
|
741
|
+
let mappingsWasm = null;
|
|
742
|
+
module.exports = function readWasm() {
|
|
743
|
+
if (typeof mappingsWasm == "string") {
|
|
744
|
+
return fetch(mappingsWasm).then((response) => response.arrayBuffer());
|
|
745
|
+
}
|
|
746
|
+
if (mappingsWasm instanceof ArrayBuffer) {
|
|
747
|
+
return Promise.resolve(mappingsWasm);
|
|
748
|
+
}
|
|
749
|
+
throw new Error("You must provide the string URL or ArrayBuffer contents of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer");
|
|
750
|
+
};
|
|
751
|
+
module.exports.initialize = (input) => {
|
|
752
|
+
mappingsWasm = input;
|
|
753
|
+
};
|
|
1188
754
|
|
|
1189
755
|
}
|
|
1190
756
|
});
|
|
1191
757
|
//#endregion
|
|
1192
|
-
//#region
|
|
1193
|
-
var
|
|
1194
|
-
"
|
|
1195
|
-
const
|
|
1196
|
-
function
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
exports.getArg = getArg;
|
|
1205
|
-
const supportsNullProto = (function() {
|
|
1206
|
-
const obj = Object.create(null);
|
|
1207
|
-
return !("__proto__" in obj);
|
|
1208
|
-
})();
|
|
1209
|
-
function identity(s) {
|
|
1210
|
-
return s;
|
|
1211
|
-
}
|
|
1212
|
-
function toSetString(aStr) {
|
|
1213
|
-
if (isProtoString(aStr)) {
|
|
1214
|
-
return "$" + aStr;
|
|
1215
|
-
}
|
|
1216
|
-
return aStr;
|
|
758
|
+
//#region wasm.js
|
|
759
|
+
var require_source_map_lib_wasm = __commonJS({
|
|
760
|
+
"wasm.js"(exports, module) {
|
|
761
|
+
const readWasm = require_source_map_lib_read_wasm_browser();
|
|
762
|
+
function Mapping() {
|
|
763
|
+
this.generatedLine = 0;
|
|
764
|
+
this.generatedColumn = 0;
|
|
765
|
+
this.lastGeneratedColumn = null;
|
|
766
|
+
this.source = null;
|
|
767
|
+
this.originalLine = null;
|
|
768
|
+
this.originalColumn = null;
|
|
769
|
+
this.name = null;
|
|
1217
770
|
}
|
|
1218
|
-
|
|
1219
|
-
function
|
|
1220
|
-
if (
|
|
1221
|
-
return
|
|
771
|
+
let cachedWasm = null;
|
|
772
|
+
module.exports = function wasm() {
|
|
773
|
+
if (cachedWasm) {
|
|
774
|
+
return cachedWasm;
|
|
1222
775
|
}
|
|
1223
|
-
|
|
776
|
+
const callbackStack = [];
|
|
777
|
+
cachedWasm = readWasm().then((buffer) => {
|
|
778
|
+
return WebAssembly.instantiate(buffer, { env: { mapping_callback(generatedLine,generatedColumn,hasLastGeneratedColumn,lastGeneratedColumn,hasOriginal,source,originalLine,originalColumn,hasName,name) {
|
|
779
|
+
const mapping = new Mapping();
|
|
780
|
+
mapping.generatedLine = generatedLine + 1;
|
|
781
|
+
mapping.generatedColumn = generatedColumn;
|
|
782
|
+
if (hasLastGeneratedColumn) {
|
|
783
|
+
mapping.lastGeneratedColumn = lastGeneratedColumn - 1;
|
|
784
|
+
}
|
|
785
|
+
if (hasOriginal) {
|
|
786
|
+
mapping.source = source;
|
|
787
|
+
mapping.originalLine = originalLine + 1;
|
|
788
|
+
mapping.originalColumn = originalColumn;
|
|
789
|
+
if (hasName) {
|
|
790
|
+
mapping.name = name;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
callbackStack[callbackStack.length - 1](mapping);
|
|
794
|
+
}, start_all_generated_locations_for() {
|
|
795
|
+
console.time("all_generated_locations_for");
|
|
796
|
+
}, end_all_generated_locations_for() {
|
|
797
|
+
console.timeEnd("all_generated_locations_for");
|
|
798
|
+
}, start_compute_column_spans() {
|
|
799
|
+
console.time("compute_column_spans");
|
|
800
|
+
}, end_compute_column_spans() {
|
|
801
|
+
console.timeEnd("compute_column_spans");
|
|
802
|
+
}, start_generated_location_for() {
|
|
803
|
+
console.time("generated_location_for");
|
|
804
|
+
}, end_generated_location_for() {
|
|
805
|
+
console.timeEnd("generated_location_for");
|
|
806
|
+
}, start_original_location_for() {
|
|
807
|
+
console.time("original_location_for");
|
|
808
|
+
}, end_original_location_for() {
|
|
809
|
+
console.timeEnd("original_location_for");
|
|
810
|
+
}, start_parse_mappings() {
|
|
811
|
+
console.time("parse_mappings");
|
|
812
|
+
}, end_parse_mappings() {
|
|
813
|
+
console.timeEnd("parse_mappings");
|
|
814
|
+
}, start_sort_by_generated_location() {
|
|
815
|
+
console.time("sort_by_generated_location");
|
|
816
|
+
}, end_sort_by_generated_location() {
|
|
817
|
+
console.timeEnd("sort_by_generated_location");
|
|
818
|
+
}, start_sort_by_original_location() {
|
|
819
|
+
console.time("sort_by_original_location");
|
|
820
|
+
}, end_sort_by_original_location() {
|
|
821
|
+
console.timeEnd("sort_by_original_location");
|
|
822
|
+
} } });
|
|
823
|
+
}).then((Wasm) => {
|
|
824
|
+
return { exports: Wasm.instance.exports, withMappingCallback: (mappingCallback, f) => {
|
|
825
|
+
callbackStack.push(mappingCallback);
|
|
826
|
+
try {
|
|
827
|
+
f();
|
|
828
|
+
} finally {
|
|
829
|
+
callbackStack.pop();
|
|
830
|
+
}
|
|
831
|
+
} };
|
|
832
|
+
}).then(null, (e) => {
|
|
833
|
+
cachedWasm = null;
|
|
834
|
+
throw e;
|
|
835
|
+
});
|
|
836
|
+
return cachedWasm;
|
|
837
|
+
};
|
|
838
|
+
|
|
1224
839
|
}
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
840
|
+
});
|
|
841
|
+
//#endregion
|
|
842
|
+
//#region source-map-consumer.js
|
|
843
|
+
var require_source_map_lib_source_map_consumer = __commonJS({
|
|
844
|
+
"source-map-consumer.js"(exports, module) {
|
|
845
|
+
const util = require_source_map_lib_util(),binarySearch = require_source_map_lib_binary_search(),ArraySet = require_source_map_lib_array_set().ArraySet,base64VLQ = require_source_map_lib_base64_vlq(),readWasm = require_source_map_lib_read_wasm_browser(),wasm = require_source_map_lib_wasm(),INTERNAL = Symbol("smcInternal");
|
|
846
|
+
class SourceMapConsumer {
|
|
847
|
+
constructor(aSourceMap,aSourceMapURL) {
|
|
848
|
+
if (aSourceMap == INTERNAL) {
|
|
849
|
+
return Promise.resolve(this);
|
|
850
|
+
}
|
|
851
|
+
return _factory(aSourceMap, aSourceMapURL);
|
|
1229
852
|
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
return false;
|
|
853
|
+
static initialize(opts) {
|
|
854
|
+
readWasm.initialize(opts["lib/mappings.wasm"]);
|
|
1233
855
|
}
|
|
1234
|
-
|
|
1235
|
-
return
|
|
856
|
+
static fromSourceMap(aSourceMap,aSourceMapURL) {
|
|
857
|
+
return _factoryBSM(aSourceMap, aSourceMapURL);
|
|
1236
858
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
859
|
+
static async with(rawSourceMap,sourceMapUrl,f) {
|
|
860
|
+
const consumer = await new SourceMapConsumer(rawSourceMap, sourceMapUrl);
|
|
861
|
+
try {
|
|
862
|
+
return await f(consumer);
|
|
863
|
+
} finally {
|
|
864
|
+
consumer.destroy();
|
|
1240
865
|
}
|
|
1241
866
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
function strcmp(aStr1,aStr2) {
|
|
1245
|
-
if (aStr1 === aStr2) {
|
|
1246
|
-
return 0;
|
|
1247
|
-
}
|
|
1248
|
-
if (aStr1 === null) {
|
|
1249
|
-
return 1;
|
|
867
|
+
eachMapping(aCallback,aContext,aOrder) {
|
|
868
|
+
throw new Error("Subclasses must implement eachMapping");
|
|
1250
869
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
870
|
+
allGeneratedPositionsFor(aArgs) {
|
|
871
|
+
throw new Error("Subclasses must implement allGeneratedPositionsFor");
|
|
1253
872
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
873
|
+
destroy() {
|
|
874
|
+
throw new Error("Subclasses must implement destroy");
|
|
1256
875
|
}
|
|
1257
|
-
return -1;
|
|
1258
876
|
}
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
877
|
+
SourceMapConsumer.prototype._version = 3;
|
|
878
|
+
SourceMapConsumer.GENERATED_ORDER = 1;
|
|
879
|
+
SourceMapConsumer.ORIGINAL_ORDER = 2;
|
|
880
|
+
SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
|
|
881
|
+
SourceMapConsumer.LEAST_UPPER_BOUND = 2;
|
|
882
|
+
exports.SourceMapConsumer = SourceMapConsumer;
|
|
883
|
+
class BasicSourceMapConsumer extends SourceMapConsumer {
|
|
884
|
+
constructor(aSourceMap,aSourceMapURL) {
|
|
885
|
+
return super(INTERNAL).then((that) => {
|
|
886
|
+
let sourceMap = aSourceMap;
|
|
887
|
+
if (typeof aSourceMap == "string") {
|
|
888
|
+
sourceMap = util.parseSourceMapInput(aSourceMap);
|
|
889
|
+
}
|
|
890
|
+
const version = util.getArg(sourceMap, "version"),sources = util.getArg(sourceMap, "sources").map(String),names = util.getArg(sourceMap, "names", []),sourceRoot = util.getArg(sourceMap, "sourceRoot", null),sourcesContent = util.getArg(sourceMap, "sourcesContent", null),mappings = util.getArg(sourceMap, "mappings"),file = util.getArg(sourceMap, "file", null),x_google_ignoreList = util.getArg(sourceMap, "x_google_ignoreList", null);
|
|
891
|
+
if (version != that._version) {
|
|
892
|
+
throw new Error("Unsupported version: " + version);
|
|
893
|
+
}
|
|
894
|
+
that._sourceLookupCache = new Map();
|
|
895
|
+
that._names = ArraySet.fromArray(names.map(String), true);
|
|
896
|
+
that._sources = ArraySet.fromArray(sources, true);
|
|
897
|
+
that._absoluteSources = ArraySet.fromArray(that._sources.toArray().map(function(s) {
|
|
898
|
+
return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
|
|
899
|
+
}), true);
|
|
900
|
+
that.sourceRoot = sourceRoot;
|
|
901
|
+
that.sourcesContent = sourcesContent;
|
|
902
|
+
that._mappings = mappings;
|
|
903
|
+
that._sourceMapURL = aSourceMapURL;
|
|
904
|
+
that.file = file;
|
|
905
|
+
that.x_google_ignoreList = x_google_ignoreList;
|
|
906
|
+
that._computedColumnSpans = false;
|
|
907
|
+
that._mappingsPtr = 0;
|
|
908
|
+
that._wasm = null;
|
|
909
|
+
return wasm().then((w) => {
|
|
910
|
+
that._wasm = w;
|
|
911
|
+
return that;
|
|
912
|
+
});
|
|
913
|
+
});
|
|
1263
914
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
915
|
+
_findSourceIndex(aSource) {
|
|
916
|
+
const cachedIndex = this._sourceLookupCache.get(aSource);
|
|
917
|
+
if (typeof cachedIndex == "number") {
|
|
918
|
+
return cachedIndex;
|
|
919
|
+
}
|
|
920
|
+
const sourceAsMapRelative = util.computeSourceURL(null, aSource, this._sourceMapURL);
|
|
921
|
+
if (this._absoluteSources.has(sourceAsMapRelative)) {
|
|
922
|
+
const index = this._absoluteSources.indexOf(sourceAsMapRelative);
|
|
923
|
+
this._sourceLookupCache.set(aSource, index);
|
|
924
|
+
return index;
|
|
925
|
+
}
|
|
926
|
+
const sourceAsSourceRootRelative = util.computeSourceURL(this.sourceRoot, aSource, this._sourceMapURL);
|
|
927
|
+
if (this._absoluteSources.has(sourceAsSourceRootRelative)) {
|
|
928
|
+
const index = this._absoluteSources.indexOf(sourceAsSourceRootRelative);
|
|
929
|
+
this._sourceLookupCache.set(aSource, index);
|
|
930
|
+
return index;
|
|
931
|
+
}
|
|
932
|
+
return -1;
|
|
1267
933
|
}
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
return cmp;
|
|
934
|
+
static fromSourceMap(aSourceMap,aSourceMapURL) {
|
|
935
|
+
return new BasicSourceMapConsumer(aSourceMap.toString());
|
|
1271
936
|
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
return cmp;
|
|
937
|
+
get sources() {
|
|
938
|
+
return this._absoluteSources.toArray();
|
|
1275
939
|
}
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
940
|
+
_getMappingsPtr() {
|
|
941
|
+
if (this._mappingsPtr === 0) {
|
|
942
|
+
this._parseMappings();
|
|
943
|
+
}
|
|
944
|
+
return this._mappingsPtr;
|
|
1279
945
|
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
|
|
1285
|
-
}
|
|
1286
|
-
exports.parseSourceMapInput = parseSourceMapInput;
|
|
1287
|
-
const PROTOCOL = "http:",PROTOCOL_AND_HOST = `${PROTOCOL}//host`;
|
|
1288
|
-
function createSafeHandler(cb) {
|
|
1289
|
-
return (input) => {
|
|
1290
|
-
const type = getURLType(input),base = buildSafeBase(input),url = new URL(input, base);
|
|
1291
|
-
cb(url);
|
|
1292
|
-
const result = url.toString();
|
|
1293
|
-
if (type === "absolute") {
|
|
1294
|
-
return result;
|
|
1295
|
-
} else if (type === "scheme-relative") {
|
|
1296
|
-
return result.slice(PROTOCOL.length);
|
|
1297
|
-
} else if (type === "path-absolute") {
|
|
1298
|
-
return result.slice(PROTOCOL_AND_HOST.length);
|
|
946
|
+
_parseMappings() {
|
|
947
|
+
const aStr = this._mappings,size = aStr.length,mappingsBufPtr = this._wasm.exports.allocate_mappings(size) >>> 0,mappingsBuf = new Uint8Array(this._wasm.exports.memory.buffer, mappingsBufPtr, size);
|
|
948
|
+
for (let i = 0; i < size; i++) {
|
|
949
|
+
mappingsBuf[i] = aStr.charCodeAt(i);
|
|
1299
950
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
951
|
+
const mappingsPtr = this._wasm.exports.parse_mappings(mappingsBufPtr);
|
|
952
|
+
if (!mappingsPtr) {
|
|
953
|
+
const error = this._wasm.exports.get_last_error();
|
|
954
|
+
let msg = `Error parsing mappings (code ${error}): `;
|
|
955
|
+
switch (error) {
|
|
956
|
+
case 1:
|
|
957
|
+
msg += "the mappings contained a negative line, column, source index, or name index";
|
|
958
|
+
break;
|
|
959
|
+
case 2:
|
|
960
|
+
msg += "the mappings contained a number larger than 2**32";
|
|
961
|
+
break;
|
|
962
|
+
case 3:
|
|
963
|
+
msg += "reached EOF while in the middle of parsing a VLQ";
|
|
964
|
+
break;
|
|
965
|
+
case 4:
|
|
966
|
+
msg += "invalid base 64 character while parsing a VLQ";
|
|
967
|
+
break;
|
|
968
|
+
default:
|
|
969
|
+
msg += "unknown error code";
|
|
970
|
+
break;
|
|
971
|
+
}
|
|
972
|
+
throw new Error(msg);
|
|
973
|
+
}
|
|
974
|
+
this._mappingsPtr = mappingsPtr;
|
|
1318
975
|
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
976
|
+
eachMapping(aCallback,aContext,aOrder) {
|
|
977
|
+
const context = aContext || null,order = aOrder || SourceMapConsumer.GENERATED_ORDER;
|
|
978
|
+
this._wasm.withMappingCallback((mapping) => {
|
|
979
|
+
if (mapping.source !== null) {
|
|
980
|
+
mapping.source = this._absoluteSources.at(mapping.source);
|
|
981
|
+
if (mapping.name !== null) {
|
|
982
|
+
mapping.name = this._names.at(mapping.name);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
if (this._computedColumnSpans && mapping.lastGeneratedColumn === null) {
|
|
986
|
+
mapping.lastGeneratedColumn = Infinity;
|
|
987
|
+
}
|
|
988
|
+
aCallback.call(context, mapping);
|
|
989
|
+
}, () => {
|
|
990
|
+
switch (order) {
|
|
991
|
+
case SourceMapConsumer.GENERATED_ORDER:
|
|
992
|
+
this._wasm.exports.by_generated_location(this._getMappingsPtr());
|
|
993
|
+
break;
|
|
994
|
+
case SourceMapConsumer.ORIGINAL_ORDER:
|
|
995
|
+
this._wasm.exports.by_original_location(this._getMappingsPtr());
|
|
996
|
+
break;
|
|
997
|
+
default:
|
|
998
|
+
throw new Error("Unknown order of iteration.");
|
|
999
|
+
}
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
allGeneratedPositionsFor(aArgs) {
|
|
1003
|
+
let source = util.getArg(aArgs, "source");
|
|
1004
|
+
const originalLine = util.getArg(aArgs, "line"),originalColumn = aArgs.column || 0;
|
|
1005
|
+
source = this._findSourceIndex(source);
|
|
1006
|
+
if (source < 0) {
|
|
1007
|
+
return [];
|
|
1008
|
+
}
|
|
1009
|
+
if (originalLine < 1) {
|
|
1010
|
+
throw new Error("Line numbers must be >= 1");
|
|
1011
|
+
}
|
|
1012
|
+
if (originalColumn < 0) {
|
|
1013
|
+
throw new Error("Column numbers must be >= 0");
|
|
1014
|
+
}
|
|
1015
|
+
const mappings = [];
|
|
1016
|
+
this._wasm.withMappingCallback((m) => {
|
|
1017
|
+
let lastColumn = m.lastGeneratedColumn;
|
|
1018
|
+
if (this._computedColumnSpans && lastColumn === null) {
|
|
1019
|
+
lastColumn = Infinity;
|
|
1020
|
+
}
|
|
1021
|
+
mappings.push({ line: m.generatedLine, column: m.generatedColumn, lastColumn });
|
|
1022
|
+
}, () => {
|
|
1023
|
+
this._wasm.exports.all_generated_locations_for(this._getMappingsPtr(), source, originalLine - 1, "column" in aArgs, originalColumn);
|
|
1024
|
+
});
|
|
1025
|
+
return mappings;
|
|
1026
|
+
}
|
|
1027
|
+
destroy() {
|
|
1028
|
+
if (this._mappingsPtr !== 0) {
|
|
1029
|
+
this._wasm.exports.free_mappings(this._mappingsPtr);
|
|
1030
|
+
this._mappingsPtr = 0;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
computeColumnSpans() {
|
|
1034
|
+
if (this._computedColumnSpans) {
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
this._wasm.exports.compute_column_spans(this._getMappingsPtr());
|
|
1038
|
+
this._computedColumnSpans = true;
|
|
1039
|
+
}
|
|
1040
|
+
originalPositionFor(aArgs) {
|
|
1041
|
+
const needle = { generatedLine: util.getArg(aArgs, "line"), generatedColumn: util.getArg(aArgs, "column") };
|
|
1042
|
+
if (needle.generatedLine < 1) {
|
|
1043
|
+
throw new Error("Line numbers must be >= 1");
|
|
1044
|
+
}
|
|
1045
|
+
if (needle.generatedColumn < 0) {
|
|
1046
|
+
throw new Error("Column numbers must be >= 0");
|
|
1047
|
+
}
|
|
1048
|
+
let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
|
|
1049
|
+
if (bias == null) {
|
|
1050
|
+
bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
|
|
1051
|
+
}
|
|
1052
|
+
let mapping;
|
|
1053
|
+
this._wasm.withMappingCallback((m) => mapping = m, () => {
|
|
1054
|
+
this._wasm.exports.original_location_for(this._getMappingsPtr(), needle.generatedLine - 1, needle.generatedColumn, bias);
|
|
1055
|
+
});
|
|
1056
|
+
if (mapping) {
|
|
1057
|
+
if (mapping.generatedLine === needle.generatedLine) {
|
|
1058
|
+
let source = util.getArg(mapping, "source", null);
|
|
1059
|
+
if (source !== null) {
|
|
1060
|
+
source = this._absoluteSources.at(source);
|
|
1061
|
+
}
|
|
1062
|
+
let name = util.getArg(mapping, "name", null);
|
|
1063
|
+
if (name !== null) {
|
|
1064
|
+
name = this._names.at(name);
|
|
1065
|
+
}
|
|
1066
|
+
return { source, line: util.getArg(mapping, "originalLine", null), column: util.getArg(mapping, "originalColumn", null), name };
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
return { source: null, line: null, column: null, name: null };
|
|
1070
|
+
}
|
|
1071
|
+
hasContentsOfAllSources() {
|
|
1072
|
+
if (!this.sourcesContent) {
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1075
|
+
return this.sourcesContent.length >= this._sources.size() && !this.sourcesContent.some(function(sc) {
|
|
1076
|
+
return sc == null;
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
sourceContentFor(aSource,nullOnMissing) {
|
|
1080
|
+
if (!this.sourcesContent) {
|
|
1081
|
+
return null;
|
|
1082
|
+
}
|
|
1083
|
+
const index = this._findSourceIndex(aSource);
|
|
1084
|
+
if (index >= 0) {
|
|
1085
|
+
return this.sourcesContent[index];
|
|
1086
|
+
}
|
|
1087
|
+
if (nullOnMissing) {
|
|
1088
|
+
return null;
|
|
1089
|
+
}
|
|
1090
|
+
throw new Error("\"" + aSource + "\" is not in the SourceMap.");
|
|
1091
|
+
}
|
|
1092
|
+
generatedPositionFor(aArgs) {
|
|
1093
|
+
let source = util.getArg(aArgs, "source");
|
|
1094
|
+
source = this._findSourceIndex(source);
|
|
1095
|
+
if (source < 0) {
|
|
1096
|
+
return { line: null, column: null, lastColumn: null };
|
|
1097
|
+
}
|
|
1098
|
+
const needle = { source, originalLine: util.getArg(aArgs, "line"), originalColumn: util.getArg(aArgs, "column") };
|
|
1099
|
+
if (needle.originalLine < 1) {
|
|
1100
|
+
throw new Error("Line numbers must be >= 1");
|
|
1101
|
+
}
|
|
1102
|
+
if (needle.originalColumn < 0) {
|
|
1103
|
+
throw new Error("Column numbers must be >= 0");
|
|
1104
|
+
}
|
|
1105
|
+
let bias = util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND);
|
|
1106
|
+
if (bias == null) {
|
|
1107
|
+
bias = SourceMapConsumer.GREATEST_LOWER_BOUND;
|
|
1108
|
+
}
|
|
1109
|
+
let mapping;
|
|
1110
|
+
this._wasm.withMappingCallback((m) => mapping = m, () => {
|
|
1111
|
+
this._wasm.exports.generated_location_for(this._getMappingsPtr(), needle.source, needle.originalLine - 1, needle.originalColumn, bias);
|
|
1112
|
+
});
|
|
1113
|
+
if (mapping) {
|
|
1114
|
+
if (mapping.source === needle.source) {
|
|
1115
|
+
let lastColumn = mapping.lastGeneratedColumn;
|
|
1116
|
+
if (this._computedColumnSpans && lastColumn === null) {
|
|
1117
|
+
lastColumn = Infinity;
|
|
1118
|
+
}
|
|
1119
|
+
return { line: util.getArg(mapping, "generatedLine", null), column: util.getArg(mapping, "generatedColumn", null), lastColumn };
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
return { line: null, column: null, lastColumn: null };
|
|
1326
1123
|
}
|
|
1327
|
-
return ABSOLUTE_SCHEME.test(url) ? "absolute" : "path-relative";
|
|
1328
1124
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1125
|
+
BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
|
|
1126
|
+
exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
|
|
1127
|
+
class IndexedSourceMapConsumer extends SourceMapConsumer {
|
|
1128
|
+
constructor(aSourceMap,aSourceMapURL) {
|
|
1129
|
+
return super(INTERNAL).then((that) => {
|
|
1130
|
+
let sourceMap = aSourceMap;
|
|
1131
|
+
if (typeof aSourceMap == "string") {
|
|
1132
|
+
sourceMap = util.parseSourceMapInput(aSourceMap);
|
|
1133
|
+
}
|
|
1134
|
+
const version = util.getArg(sourceMap, "version"),sections = util.getArg(sourceMap, "sections");
|
|
1135
|
+
if (version != that._version) {
|
|
1136
|
+
throw new Error("Unsupported version: " + version);
|
|
1137
|
+
}
|
|
1138
|
+
let lastOffset = { line: -1, column: 0 };
|
|
1139
|
+
return Promise.all(sections.map((s) => {
|
|
1140
|
+
if (s.url) {
|
|
1141
|
+
throw new Error("Support for url field in sections not implemented.");
|
|
1142
|
+
}
|
|
1143
|
+
const offset = util.getArg(s, "offset"),offsetLine = util.getArg(offset, "line"),offsetColumn = util.getArg(offset, "column");
|
|
1144
|
+
if (offsetLine < lastOffset.line || offsetLine === lastOffset.line && offsetColumn < lastOffset.column) {
|
|
1145
|
+
throw new Error("Section offsets must be ordered and non-overlapping.");
|
|
1146
|
+
}
|
|
1147
|
+
lastOffset = offset;
|
|
1148
|
+
const cons = new SourceMapConsumer(util.getArg(s, "map"), aSourceMapURL);
|
|
1149
|
+
return cons.then((consumer) => {
|
|
1150
|
+
return { generatedOffset: { generatedLine: offsetLine + 1, generatedColumn: offsetColumn + 1 }, consumer };
|
|
1151
|
+
});
|
|
1152
|
+
})).then((s) => {
|
|
1153
|
+
that._sections = s;
|
|
1154
|
+
return that;
|
|
1155
|
+
});
|
|
1156
|
+
});
|
|
1335
1157
|
}
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1158
|
+
get sources() {
|
|
1159
|
+
const sources = [];
|
|
1160
|
+
for (let i = 0; i < this._sections.length; i++) {
|
|
1161
|
+
for (let j = 0; j < this._sections[i].consumer.sources.length; j++) {
|
|
1162
|
+
sources.push(this._sections[i].consumer.sources[j]);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
return sources;
|
|
1166
|
+
}
|
|
1167
|
+
originalPositionFor(aArgs) {
|
|
1168
|
+
const needle = { generatedLine: util.getArg(aArgs, "line"), generatedColumn: util.getArg(aArgs, "column") },sectionIndex = binarySearch.search(needle, this._sections, function(aNeedle,section) {
|
|
1169
|
+
const cmp = aNeedle.generatedLine - section.generatedOffset.generatedLine;
|
|
1170
|
+
if (cmp) {
|
|
1171
|
+
return cmp;
|
|
1172
|
+
}
|
|
1173
|
+
return aNeedle.generatedColumn - (section.generatedOffset.generatedColumn - 1);
|
|
1174
|
+
}),section = this._sections[sectionIndex];
|
|
1175
|
+
if (!section) {
|
|
1176
|
+
return { source: null, line: null, column: null, name: null };
|
|
1177
|
+
}
|
|
1178
|
+
return section.consumer.originalPositionFor({ line: needle.generatedLine - (section.generatedOffset.generatedLine - 1), column: needle.generatedColumn - (section.generatedOffset.generatedLine === needle.generatedLine ? section.generatedOffset.generatedColumn - 1 : 0), bias: aArgs.bias });
|
|
1179
|
+
}
|
|
1180
|
+
hasContentsOfAllSources() {
|
|
1181
|
+
return this._sections.every(function(s) {
|
|
1182
|
+
return s.consumer.hasContentsOfAllSources();
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
sourceContentFor(aSource,nullOnMissing) {
|
|
1186
|
+
for (let i = 0; i < this._sections.length; i++) {
|
|
1187
|
+
const section = this._sections[i],content = section.consumer.sourceContentFor(aSource, true);
|
|
1188
|
+
if (content) {
|
|
1189
|
+
return content;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
if (nullOnMissing) {
|
|
1193
|
+
return null;
|
|
1194
|
+
}
|
|
1195
|
+
throw new Error("\"" + aSource + "\" is not in the SourceMap.");
|
|
1196
|
+
}
|
|
1197
|
+
_findSectionIndex(source) {
|
|
1198
|
+
for (let i = 0; i < this._sections.length; i++) {
|
|
1199
|
+
const { consumer:consumer } = this._sections[i];
|
|
1200
|
+
if (consumer._findSourceIndex(source) !== -1) {
|
|
1201
|
+
return i;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
return -1;
|
|
1205
|
+
}
|
|
1206
|
+
generatedPositionFor(aArgs) {
|
|
1207
|
+
const index = this._findSectionIndex(util.getArg(aArgs, "source")),section = index >= 0 ? this._sections[index] : null,nextSection = index >= 0 && index + 1 < this._sections.length ? this._sections[index + 1] : null,generatedPosition = section && section.consumer.generatedPositionFor(aArgs);
|
|
1208
|
+
if (generatedPosition && generatedPosition.line !== null) {
|
|
1209
|
+
const lineShift = section.generatedOffset.generatedLine - 1,columnShift = section.generatedOffset.generatedColumn - 1;
|
|
1210
|
+
if (generatedPosition.line === 1) {
|
|
1211
|
+
generatedPosition.column += columnShift;
|
|
1212
|
+
if (typeof generatedPosition.lastColumn == "number") {
|
|
1213
|
+
generatedPosition.lastColumn += columnShift;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
if (generatedPosition.lastColumn === Infinity && nextSection && generatedPosition.line === nextSection.generatedOffset.generatedLine) {
|
|
1217
|
+
generatedPosition.lastColumn = nextSection.generatedOffset.generatedColumn - 2;
|
|
1218
|
+
}
|
|
1219
|
+
generatedPosition.line += lineShift;
|
|
1220
|
+
return generatedPosition;
|
|
1221
|
+
}
|
|
1222
|
+
return { line: null, column: null, lastColumn: null };
|
|
1223
|
+
}
|
|
1224
|
+
allGeneratedPositionsFor(aArgs) {
|
|
1225
|
+
const index = this._findSectionIndex(util.getArg(aArgs, "source")),section = index >= 0 ? this._sections[index] : null,nextSection = index >= 0 && index + 1 < this._sections.length ? this._sections[index + 1] : null;
|
|
1226
|
+
if (!section)return [];
|
|
1227
|
+
return section.consumer.allGeneratedPositionsFor(aArgs).map((generatedPosition) => {
|
|
1228
|
+
const lineShift = section.generatedOffset.generatedLine - 1,columnShift = section.generatedOffset.generatedColumn - 1;
|
|
1229
|
+
if (generatedPosition.line === 1) {
|
|
1230
|
+
generatedPosition.column += columnShift;
|
|
1231
|
+
if (typeof generatedPosition.lastColumn == "number") {
|
|
1232
|
+
generatedPosition.lastColumn += columnShift;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
if (generatedPosition.lastColumn === Infinity && nextSection && generatedPosition.line === nextSection.generatedOffset.generatedLine) {
|
|
1236
|
+
generatedPosition.lastColumn = nextSection.generatedOffset.generatedColumn - 2;
|
|
1237
|
+
}
|
|
1238
|
+
generatedPosition.line += lineShift;
|
|
1239
|
+
return generatedPosition;
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
eachMapping(aCallback,aContext,aOrder) {
|
|
1243
|
+
this._sections.forEach((section, index) => {
|
|
1244
|
+
const nextSection = index + 1 < this._sections.length ? this._sections[index + 1] : null,{ generatedOffset:generatedOffset } = section,lineShift = generatedOffset.generatedLine - 1,columnShift = generatedOffset.generatedColumn - 1;
|
|
1245
|
+
section.consumer.eachMapping(function(mapping) {
|
|
1246
|
+
if (mapping.generatedLine === 1) {
|
|
1247
|
+
mapping.generatedColumn += columnShift;
|
|
1248
|
+
if (typeof mapping.lastGeneratedColumn == "number") {
|
|
1249
|
+
mapping.lastGeneratedColumn += columnShift;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
if (mapping.lastGeneratedColumn === Infinity && nextSection && mapping.generatedLine === nextSection.generatedOffset.generatedLine) {
|
|
1253
|
+
mapping.lastGeneratedColumn = nextSection.generatedOffset.generatedColumn - 2;
|
|
1254
|
+
}
|
|
1255
|
+
mapping.generatedLine += lineShift;
|
|
1256
|
+
aCallback.call(this, mapping);
|
|
1257
|
+
}, aContext, aOrder);
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
computeColumnSpans() {
|
|
1261
|
+
for (let i = 0; i < this._sections.length; i++) {
|
|
1262
|
+
this._sections[i].consumer.computeColumnSpans();
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
destroy() {
|
|
1266
|
+
for (let i = 0; i < this._sections.length; i++) {
|
|
1267
|
+
this._sections[i].consumer.destroy();
|
|
1268
|
+
}
|
|
1339
1269
|
}
|
|
1340
|
-
const relativePath = rootParts.map(() => "..").concat(targetParts).join("/");
|
|
1341
|
-
return relativePath + targetURL.search + targetURL.hash;
|
|
1342
1270
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
});
|
|
1349
|
-
exports.normalize = normalize;
|
|
1350
|
-
function join(aRoot,aPath) {
|
|
1351
|
-
const pathType = getURLType(aPath),rootType = getURLType(aRoot);
|
|
1352
|
-
aRoot = ensureDirectory(aRoot);
|
|
1353
|
-
if (pathType === "absolute") {
|
|
1354
|
-
return withBase(aPath, undefined);
|
|
1271
|
+
exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
|
|
1272
|
+
function _factory(aSourceMap,aSourceMapURL) {
|
|
1273
|
+
let sourceMap = aSourceMap;
|
|
1274
|
+
if (typeof aSourceMap == "string") {
|
|
1275
|
+
sourceMap = util.parseSourceMapInput(aSourceMap);
|
|
1355
1276
|
}
|
|
1356
|
-
|
|
1357
|
-
|
|
1277
|
+
const consumer = sourceMap.sections != null ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL) : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
|
|
1278
|
+
return Promise.resolve(consumer);
|
|
1279
|
+
}
|
|
1280
|
+
function _factoryBSM(aSourceMap,aSourceMapURL) {
|
|
1281
|
+
return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
}
|
|
1285
|
+
});
|
|
1286
|
+
//#endregion
|
|
1287
|
+
//#region source-node.js
|
|
1288
|
+
var require_source_map_lib_source_node = __commonJS({
|
|
1289
|
+
"source-node.js"(exports, module) {
|
|
1290
|
+
const SourceMapGenerator = require_source_map_lib_source_map_generator().SourceMapGenerator,util = require_source_map_lib_util(),REGEX_NEWLINE = /(\r?\n)/,NEWLINE_CODE = 10,isSourceNode = "$$$isSourceNode$$$";
|
|
1291
|
+
class SourceNode {
|
|
1292
|
+
constructor(aLine,aColumn,aSource,aChunks,aName) {
|
|
1293
|
+
this.children = [];
|
|
1294
|
+
this.sourceContents = {};
|
|
1295
|
+
this.line = aLine == null ? null : aLine;
|
|
1296
|
+
this.column = aColumn == null ? null : aColumn;
|
|
1297
|
+
this.source = aSource == null ? null : aSource;
|
|
1298
|
+
this.name = aName == null ? null : aName;
|
|
1299
|
+
this[isSourceNode] = true;
|
|
1300
|
+
if (aChunks != null)this.add(aChunks);
|
|
1358
1301
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1302
|
+
static fromStringWithSourceMap(aGeneratedCode,aSourceMapConsumer,aRelativePath) {
|
|
1303
|
+
const node = new SourceNode(),remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
|
|
1304
|
+
let remainingLinesIndex = 0;
|
|
1305
|
+
const shiftNextLine = function() {
|
|
1306
|
+
const lineContents = getNextLine(),newLine = getNextLine() || "";
|
|
1307
|
+
return lineContents + newLine;
|
|
1308
|
+
function getNextLine() {
|
|
1309
|
+
return remainingLinesIndex < remainingLines.length ? remainingLines[remainingLinesIndex++] : undefined;
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
let lastGeneratedLine = 1,lastGeneratedColumn = 0,lastMapping = null,nextLine;
|
|
1313
|
+
aSourceMapConsumer.eachMapping(function(mapping) {
|
|
1314
|
+
if (lastMapping !== null) {
|
|
1315
|
+
if (lastGeneratedLine < mapping.generatedLine) {
|
|
1316
|
+
addMappingWithCode(lastMapping, shiftNextLine());
|
|
1317
|
+
lastGeneratedLine++;
|
|
1318
|
+
lastGeneratedColumn = 0;
|
|
1319
|
+
} else {
|
|
1320
|
+
nextLine = remainingLines[remainingLinesIndex] || "";
|
|
1321
|
+
const code = nextLine.substr(0, mapping.generatedColumn - lastGeneratedColumn);
|
|
1322
|
+
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - lastGeneratedColumn);
|
|
1323
|
+
lastGeneratedColumn = mapping.generatedColumn;
|
|
1324
|
+
addMappingWithCode(lastMapping, code);
|
|
1325
|
+
lastMapping = mapping;
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
while (lastGeneratedLine < mapping.generatedLine) {
|
|
1330
|
+
node.add(shiftNextLine());
|
|
1331
|
+
lastGeneratedLine++;
|
|
1332
|
+
}
|
|
1333
|
+
if (lastGeneratedColumn < mapping.generatedColumn) {
|
|
1334
|
+
nextLine = remainingLines[remainingLinesIndex] || "";
|
|
1335
|
+
node.add(nextLine.substr(0, mapping.generatedColumn));
|
|
1336
|
+
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
|
|
1337
|
+
lastGeneratedColumn = mapping.generatedColumn;
|
|
1338
|
+
}
|
|
1339
|
+
lastMapping = mapping;
|
|
1340
|
+
}, this);
|
|
1341
|
+
if (remainingLinesIndex < remainingLines.length) {
|
|
1342
|
+
if (lastMapping) {
|
|
1343
|
+
addMappingWithCode(lastMapping, shiftNextLine());
|
|
1344
|
+
}
|
|
1345
|
+
node.add(remainingLines.splice(remainingLinesIndex).join(""));
|
|
1346
|
+
}
|
|
1347
|
+
aSourceMapConsumer.sources.forEach(function(sourceFile) {
|
|
1348
|
+
const content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
|
1349
|
+
if (content != null) {
|
|
1350
|
+
if (aRelativePath != null) {
|
|
1351
|
+
sourceFile = util.join(aRelativePath, sourceFile);
|
|
1352
|
+
}
|
|
1353
|
+
node.setSourceContent(sourceFile, content);
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
return node;
|
|
1357
|
+
function addMappingWithCode(mapping,code) {
|
|
1358
|
+
if (mapping === null || mapping.source === undefined) {
|
|
1359
|
+
node.add(code);
|
|
1360
|
+
} else {
|
|
1361
|
+
const source = aRelativePath ? util.join(aRelativePath, mapping.source) : mapping.source;
|
|
1362
|
+
node.add(new SourceNode(mapping.originalLine, mapping.originalColumn, source, code, mapping.name));
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1361
1365
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1366
|
+
add(aChunk) {
|
|
1367
|
+
if (Array.isArray(aChunk)) {
|
|
1368
|
+
aChunk.forEach(function(chunk) {
|
|
1369
|
+
this.add(chunk);
|
|
1370
|
+
}, this);
|
|
1371
|
+
} else if (aChunk[isSourceNode] || typeof aChunk == "string") {
|
|
1372
|
+
if (aChunk) {
|
|
1373
|
+
this.children.push(aChunk);
|
|
1374
|
+
}
|
|
1375
|
+
} else {
|
|
1376
|
+
throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk);
|
|
1377
|
+
}
|
|
1378
|
+
return this;
|
|
1364
1379
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1380
|
+
prepend(aChunk) {
|
|
1381
|
+
if (Array.isArray(aChunk)) {
|
|
1382
|
+
for (let i = aChunk.length - 1; i >= 0; i--) {
|
|
1383
|
+
this.prepend(aChunk[i]);
|
|
1384
|
+
}
|
|
1385
|
+
} else if (aChunk[isSourceNode] || typeof aChunk == "string") {
|
|
1386
|
+
this.children.unshift(aChunk);
|
|
1387
|
+
} else {
|
|
1388
|
+
throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk);
|
|
1389
|
+
}
|
|
1390
|
+
return this;
|
|
1367
1391
|
}
|
|
1368
|
-
|
|
1369
|
-
|
|
1392
|
+
walk(aFn) {
|
|
1393
|
+
let chunk;
|
|
1394
|
+
for (let i = 0,len = this.children.length; i < len; i++) {
|
|
1395
|
+
chunk = this.children[i];
|
|
1396
|
+
if (chunk[isSourceNode]) {
|
|
1397
|
+
chunk.walk(aFn);
|
|
1398
|
+
} else if (chunk !== "") {
|
|
1399
|
+
aFn(chunk, { source: this.source, line: this.line, column: this.column, name: this.name });
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1370
1402
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
return
|
|
1403
|
+
join(aSep) {
|
|
1404
|
+
let newChildren,i;
|
|
1405
|
+
const len = this.children.length;
|
|
1406
|
+
if (len > 0) {
|
|
1407
|
+
newChildren = [];
|
|
1408
|
+
for (i = 0; i < len - 1; i++) {
|
|
1409
|
+
newChildren.push(this.children[i]);
|
|
1410
|
+
newChildren.push(aSep);
|
|
1411
|
+
}
|
|
1412
|
+
newChildren.push(this.children[i]);
|
|
1413
|
+
this.children = newChildren;
|
|
1414
|
+
}
|
|
1415
|
+
return this;
|
|
1384
1416
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1417
|
+
replaceRight(aPattern,aReplacement) {
|
|
1418
|
+
const lastChild = this.children[this.children.length - 1];
|
|
1419
|
+
if (lastChild[isSourceNode]) {
|
|
1420
|
+
lastChild.replaceRight(aPattern, aReplacement);
|
|
1421
|
+
} else if (typeof lastChild == "string") {
|
|
1422
|
+
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
|
|
1423
|
+
} else {
|
|
1424
|
+
this.children.push("".replace(aPattern, aReplacement));
|
|
1425
|
+
}
|
|
1426
|
+
return this;
|
|
1390
1427
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1428
|
+
setSourceContent(aSourceFile,aSourceContent) {
|
|
1429
|
+
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
|
|
1393
1430
|
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1431
|
+
walkSourceContents(aFn) {
|
|
1432
|
+
for (let i = 0,len = this.children.length; i < len; i++) {
|
|
1433
|
+
if (this.children[i][isSourceNode]) {
|
|
1434
|
+
this.children[i].walkSourceContents(aFn);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
const sources = Object.keys(this.sourceContents);
|
|
1438
|
+
for (let i = 0,len = sources.length; i < len; i++) {
|
|
1439
|
+
aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
|
|
1440
|
+
}
|
|
1399
1441
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
}
|
|
1408
|
-
});
|
|
1409
|
-
//#endregion
|
|
1410
|
-
//#region wasm.js
|
|
1411
|
-
var require_source_map_lib_wasm = __commonJS({
|
|
1412
|
-
"wasm.js"(exports, module) {
|
|
1413
|
-
const readWasm = require_source_map_lib_read_wasm_browser();
|
|
1414
|
-
function Mapping() {
|
|
1415
|
-
this.generatedLine = 0;
|
|
1416
|
-
this.generatedColumn = 0;
|
|
1417
|
-
this.lastGeneratedColumn = null;
|
|
1418
|
-
this.source = null;
|
|
1419
|
-
this.originalLine = null;
|
|
1420
|
-
this.originalColumn = null;
|
|
1421
|
-
this.name = null;
|
|
1422
|
-
}
|
|
1423
|
-
let cachedWasm = null;
|
|
1424
|
-
module.exports = function wasm() {
|
|
1425
|
-
if (cachedWasm) {
|
|
1426
|
-
return cachedWasm;
|
|
1442
|
+
toString() {
|
|
1443
|
+
let str = "";
|
|
1444
|
+
this.walk(function(chunk) {
|
|
1445
|
+
str += chunk;
|
|
1446
|
+
});
|
|
1447
|
+
return str;
|
|
1427
1448
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
}
|
|
1437
|
-
if (hasOriginal) {
|
|
1438
|
-
mapping.source = source;
|
|
1439
|
-
mapping.originalLine = originalLine + 1;
|
|
1440
|
-
mapping.originalColumn = originalColumn;
|
|
1441
|
-
if (hasName) {
|
|
1442
|
-
mapping.name = name;
|
|
1449
|
+
toStringWithSourceMap(aArgs) {
|
|
1450
|
+
const generated = { code: "", line: 1, column: 0 },map = new SourceMapGenerator(aArgs);
|
|
1451
|
+
let sourceMappingActive = false,lastOriginalSource = null,lastOriginalLine = null,lastOriginalColumn = null,lastOriginalName = null;
|
|
1452
|
+
this.walk(function(chunk,original) {
|
|
1453
|
+
generated.code += chunk;
|
|
1454
|
+
if (original.source !== null && original.line !== null && original.column !== null) {
|
|
1455
|
+
if (lastOriginalSource !== original.source || lastOriginalLine !== original.line || lastOriginalColumn !== original.column || lastOriginalName !== original.name) {
|
|
1456
|
+
map.addMapping({ source: original.source, original: { line: original.line, column: original.column }, generated: { line: generated.line, column: generated.column }, name: original.name });
|
|
1443
1457
|
}
|
|
1458
|
+
lastOriginalSource = original.source;
|
|
1459
|
+
lastOriginalLine = original.line;
|
|
1460
|
+
lastOriginalColumn = original.column;
|
|
1461
|
+
lastOriginalName = original.name;
|
|
1462
|
+
sourceMappingActive = true;
|
|
1463
|
+
} else if (sourceMappingActive) {
|
|
1464
|
+
map.addMapping({ generated: { line: generated.line, column: generated.column } });
|
|
1465
|
+
lastOriginalSource = null;
|
|
1466
|
+
sourceMappingActive = false;
|
|
1444
1467
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
}, start_original_location_for() {
|
|
1459
|
-
console.time("original_location_for");
|
|
1460
|
-
}, end_original_location_for() {
|
|
1461
|
-
console.timeEnd("original_location_for");
|
|
1462
|
-
}, start_parse_mappings() {
|
|
1463
|
-
console.time("parse_mappings");
|
|
1464
|
-
}, end_parse_mappings() {
|
|
1465
|
-
console.timeEnd("parse_mappings");
|
|
1466
|
-
}, start_sort_by_generated_location() {
|
|
1467
|
-
console.time("sort_by_generated_location");
|
|
1468
|
-
}, end_sort_by_generated_location() {
|
|
1469
|
-
console.timeEnd("sort_by_generated_location");
|
|
1470
|
-
}, start_sort_by_original_location() {
|
|
1471
|
-
console.time("sort_by_original_location");
|
|
1472
|
-
}, end_sort_by_original_location() {
|
|
1473
|
-
console.timeEnd("sort_by_original_location");
|
|
1474
|
-
} } });
|
|
1475
|
-
}).then((Wasm) => {
|
|
1476
|
-
return { exports: Wasm.instance.exports, withMappingCallback: (mappingCallback, f) => {
|
|
1477
|
-
callbackStack.push(mappingCallback);
|
|
1478
|
-
try {
|
|
1479
|
-
f();
|
|
1480
|
-
} finally {
|
|
1481
|
-
callbackStack.pop();
|
|
1468
|
+
for (let idx = 0,length = chunk.length; idx < length; idx++) {
|
|
1469
|
+
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
|
|
1470
|
+
generated.line++;
|
|
1471
|
+
generated.column = 0;
|
|
1472
|
+
if (idx + 1 === length) {
|
|
1473
|
+
lastOriginalSource = null;
|
|
1474
|
+
sourceMappingActive = false;
|
|
1475
|
+
} else if (sourceMappingActive) {
|
|
1476
|
+
map.addMapping({ source: original.source, original: { line: original.line, column: original.column }, generated: { line: generated.line, column: generated.column }, name: original.name });
|
|
1477
|
+
}
|
|
1478
|
+
} else {
|
|
1479
|
+
generated.column++;
|
|
1480
|
+
}
|
|
1482
1481
|
}
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
}
|
|
1482
|
+
});
|
|
1483
|
+
this.walkSourceContents(function(sourceFile,sourceContent) {
|
|
1484
|
+
map.setSourceContent(sourceFile, sourceContent);
|
|
1485
|
+
});
|
|
1486
|
+
return { code: generated.code, map };
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
exports.SourceNode = SourceNode;
|
|
1490
1490
|
|
|
1491
1491
|
}
|
|
1492
1492
|
});
|
|
@@ -2226,7 +2226,10 @@ function createMetroResolveRequestPlugin(opts) {
|
|
|
2226
2226
|
try {
|
|
2227
2227
|
const result = resolveRequest({ originModulePath: args.importer ?? "", platform: metroPlatform, resolveRequest: fallbackResolver }, args.path, metroPlatform);
|
|
2228
2228
|
if (result.type === "sourceFile")return { path: result.filePath };
|
|
2229
|
-
if (result.type === "assetFiles")
|
|
2229
|
+
if (result.type === "assetFiles") {
|
|
2230
|
+
const assetPath = result.filePaths[0];
|
|
2231
|
+
return assetPath ? { path: assetPath } : null;
|
|
2232
|
+
}
|
|
2230
2233
|
if (result.type === "empty")return { disabled: true };
|
|
2231
2234
|
} catch (err) {
|
|
2232
2235
|
if (err.message === DELEGATE_TO_DEFAULT_SENTINEL)return null;
|
|
@@ -2531,28 +2534,42 @@ function getBundleText(result) {
|
|
|
2531
2534
|
function getBundleSourceMapText(result) {
|
|
2532
2535
|
return result.outputFiles.find((file) => file.path.endsWith(".map"))?.text ?? null;
|
|
2533
2536
|
}
|
|
2534
|
-
function
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
state.bundleStale = false;
|
|
2547
|
-
}).catch((err) => {
|
|
2548
|
-
state.bundle = null;
|
|
2549
|
-
state.buildError = err instanceof Error ? err.message : String(err);
|
|
2550
|
-
state.bundleStale = false;
|
|
2537
|
+
function createBundleRefresher(deps) {
|
|
2538
|
+
let inFlight = null,generation = 0;
|
|
2539
|
+
function markStale() {
|
|
2540
|
+
deps.setStale();
|
|
2541
|
+
generation += 1;
|
|
2542
|
+
}
|
|
2543
|
+
function refresh() {
|
|
2544
|
+
if (deps.isFresh())return Promise.resolve();
|
|
2545
|
+
if (inFlight)return inFlight;
|
|
2546
|
+
const startGen = generation;
|
|
2547
|
+
inFlight = deps.build().then(() => {
|
|
2548
|
+
if (generation === startGen)deps.clearStale();
|
|
2551
2549
|
}).finally(() => {
|
|
2552
|
-
|
|
2550
|
+
inFlight = null;
|
|
2553
2551
|
});
|
|
2554
|
-
return
|
|
2552
|
+
return inFlight;
|
|
2555
2553
|
}
|
|
2554
|
+
return { markStale, refresh };
|
|
2555
|
+
}
|
|
2556
|
+
function createPlatformState(options,platform,callbacks) {
|
|
2557
|
+
const outputDir = mkdtempSync(join$2(tmpdir(), `zntc-rn-${platform}-`)),outputPath = join$2(outputDir, "bundle.js"),platformBundle = { ...options.bundle, rnPlatform: platform };
|
|
2558
|
+
let refresher;
|
|
2559
|
+
const state = { platform, outputDir, outputPath, handle: undefined, bundle: null, bundleStale: false, refreshBundle: () => refresher.refresh(), sourceMapCache: null, buildError: null, fileCount: 1, lastRebuildTime: Date.now() };
|
|
2560
|
+
refresher = createBundleRefresher({ isFresh: () => !state.bundleStale && state.bundle !== null, build: () => bundleRn(platformBundle).then((result) => {
|
|
2561
|
+
state.bundle = getBundleText(result);
|
|
2562
|
+
const sourceMap = getBundleSourceMapText(result);
|
|
2563
|
+
state.sourceMapCache = sourceMap ? postProcessSourceMap(sourceMap) : null;
|
|
2564
|
+
state.buildError = null;
|
|
2565
|
+
}).catch((err) => {
|
|
2566
|
+
state.bundle = null;
|
|
2567
|
+
state.buildError = err instanceof Error ? err.message : String(err);
|
|
2568
|
+
}), setStale: () => {
|
|
2569
|
+
state.bundleStale = true;
|
|
2570
|
+
}, clearStale: () => {
|
|
2571
|
+
state.bundleStale = false;
|
|
2572
|
+
} });
|
|
2556
2573
|
if (process.env.ZNTC_DEBUG_TERMINAL === "1") {
|
|
2557
2574
|
process.stderr.write(`[zntc:rn-dev:debug] watchRn[${platform}] sourcemap=${platformBundle.sourcemap} dev=${platformBundle.dev} outfile=${outputPath}\n`);
|
|
2558
2575
|
}
|
|
@@ -2576,7 +2593,7 @@ function createPlatformState(options,platform,callbacks) {
|
|
|
2576
2593
|
state.sourceMapCache = null;
|
|
2577
2594
|
if (platformBundle.dev) {
|
|
2578
2595
|
if (event.graphChanged) {
|
|
2579
|
-
|
|
2596
|
+
refresher.markStale();
|
|
2580
2597
|
return state.refreshBundle().then(() => {
|
|
2581
2598
|
if (state.buildError) {
|
|
2582
2599
|
callbacks?.onRebuild?.(state, { ...event, success: false, error: state.buildError });
|
|
@@ -2586,7 +2603,7 @@ function createPlatformState(options,platform,callbacks) {
|
|
|
2586
2603
|
});
|
|
2587
2604
|
}
|
|
2588
2605
|
if (event.updates && event.updates.length > 0) {
|
|
2589
|
-
|
|
2606
|
+
refresher.markStale();
|
|
2590
2607
|
}
|
|
2591
2608
|
callbacks?.onRebuild?.(state, event);
|
|
2592
2609
|
return;
|
|
@@ -2757,9 +2774,23 @@ function isOpenUrlRoute(pathname,method) {
|
|
|
2757
2774
|
}
|
|
2758
2775
|
function resolveOpener(platform=process.platform) {
|
|
2759
2776
|
if (platform === "darwin")return { command: "open", args: (t) => [t] };
|
|
2760
|
-
if (platform === "win32")return { command: "
|
|
2777
|
+
if (platform === "win32")return { command: "rundll32", args: (t) => ["url.dll,FileProtocolHandler", t] };
|
|
2761
2778
|
return { command: "xdg-open", args: (t) => [t] };
|
|
2762
2779
|
}
|
|
2780
|
+
const ALLOWED_PROTOCOLS = new Set(["http:", "https:"]);
|
|
2781
|
+
function isSafeBrowserUrl(target) {
|
|
2782
|
+
for (let i = 0; i < target.length; i += 1) {
|
|
2783
|
+
const c = target.charCodeAt(i);
|
|
2784
|
+
if (c <= 0x20 || c === 0x22 || c === 0x27 || c === 0x5c)return false;
|
|
2785
|
+
}
|
|
2786
|
+
let parsed;
|
|
2787
|
+
try {
|
|
2788
|
+
parsed = new URL(target);
|
|
2789
|
+
} catch {
|
|
2790
|
+
return false;
|
|
2791
|
+
}
|
|
2792
|
+
return ALLOWED_PROTOCOLS.has(parsed.protocol);
|
|
2793
|
+
}
|
|
2763
2794
|
async function handleOpenUrl(req,res,spawner=spawn,platform=process.platform) {
|
|
2764
2795
|
let body = {};
|
|
2765
2796
|
try {
|
|
@@ -2773,6 +2804,10 @@ async function handleOpenUrl(req,res,spawner=spawn,platform=process.platform) {
|
|
|
2773
2804
|
sendJson(res, 400, { error: "Invalid URL" });
|
|
2774
2805
|
return;
|
|
2775
2806
|
}
|
|
2807
|
+
if (!isSafeBrowserUrl(target)) {
|
|
2808
|
+
sendJson(res, 400, { error: "URL must be an http(s) URL without control characters" });
|
|
2809
|
+
return;
|
|
2810
|
+
}
|
|
2776
2811
|
try {
|
|
2777
2812
|
const { command:command, args:args } = resolveOpener(platform),child = spawner(command, args(target), { detached: true, stdio: "ignore" });
|
|
2778
2813
|
child.unref();
|
|
@@ -2810,7 +2845,7 @@ async function createSourceMapConsumer(sourceMapJson) {
|
|
|
2810
2845
|
return null;
|
|
2811
2846
|
}
|
|
2812
2847
|
try {
|
|
2813
|
-
const mod = await Promise.resolve().then(()=>require_source_map_source_map());
|
|
2848
|
+
const mod = await Promise.resolve().then(()=>__toESM(require_source_map_source_map()));
|
|
2814
2849
|
return await new mod.SourceMapConsumer(parsed);
|
|
2815
2850
|
} catch {
|
|
2816
2851
|
return null;
|