@rstest/core 0.0.1

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/dist/813.js ADDED
@@ -0,0 +1,137 @@
1
+ export const __webpack_ids__ = [
2
+ "813"
3
+ ];
4
+ export const __webpack_modules__ = {
5
+ "./src/runtime/worker/console.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
6
+ __webpack_require__.d(__webpack_exports__, {
7
+ createCustomConsole: ()=>createCustomConsole
8
+ });
9
+ var node_assert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:assert");
10
+ var node_console__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:console");
11
+ var node_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("node:util");
12
+ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
13
+ function createCustomConsole({ rpc, testPath, printConsoleTrace }) {
14
+ const getConsoleTrace = ()=>{
15
+ const limit = Error.stackTraceLimit;
16
+ Error.stackTraceLimit = 4;
17
+ const stack = new Error('STACK_TRACE').stack;
18
+ const trace = stack?.split('\n').slice(4).join('\n');
19
+ Error.stackTraceLimit = limit;
20
+ return trace;
21
+ };
22
+ class CustomConsole extends node_console__WEBPACK_IMPORTED_MODULE_1__.Console {
23
+ _counters = {};
24
+ _timers = {};
25
+ _groupDepth = 0;
26
+ Console = node_console__WEBPACK_IMPORTED_MODULE_1__.Console;
27
+ getPrettyName(type) {
28
+ switch(type){
29
+ case 'error':
30
+ return _utils__WEBPACK_IMPORTED_MODULE_3__.$_.red(type);
31
+ case 'warn':
32
+ return _utils__WEBPACK_IMPORTED_MODULE_3__.$_.yellow(type);
33
+ case 'info':
34
+ return _utils__WEBPACK_IMPORTED_MODULE_3__.$_.cyan(type);
35
+ default:
36
+ return _utils__WEBPACK_IMPORTED_MODULE_3__.$_.gray(type);
37
+ }
38
+ }
39
+ _log(name, message, type = 'stdout') {
40
+ rpc.onConsoleLog({
41
+ content: ' '.repeat(this._groupDepth) + message,
42
+ name: this.getPrettyName(name),
43
+ testPath,
44
+ type,
45
+ trace: printConsoleTrace ? getConsoleTrace() : void 0
46
+ });
47
+ }
48
+ assert(value, message) {
49
+ try {
50
+ (0, node_assert__WEBPACK_IMPORTED_MODULE_0__.strict)(value, message);
51
+ } catch (error) {
52
+ if (!(error instanceof node_assert__WEBPACK_IMPORTED_MODULE_0__.AssertionError)) throw error;
53
+ this._log('assert', error.toString().replaceAll(/:\n\n.*\n/gs, ''), 'stderr');
54
+ }
55
+ }
56
+ count(label = 'default') {
57
+ if (!this._counters[label]) this._counters[label] = 0;
58
+ this._log('count', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(`${label}: ${++this._counters[label]}`));
59
+ }
60
+ countReset(label = 'default') {
61
+ this._counters[label] = 0;
62
+ }
63
+ debug(firstArg, ...args) {
64
+ this._log('debug', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(firstArg, ...args));
65
+ }
66
+ dir(firstArg, options = {}) {
67
+ const representation = (0, node_util__WEBPACK_IMPORTED_MODULE_2__.inspect)(firstArg, options);
68
+ this._log('dir', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.formatWithOptions)(options, representation));
69
+ }
70
+ dirxml(firstArg, ...args) {
71
+ this._log('dirxml', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(firstArg, ...args));
72
+ }
73
+ error(firstArg, ...args) {
74
+ this._log('error', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(firstArg, ...args), 'stderr');
75
+ }
76
+ group(title, ...args) {
77
+ this._groupDepth++;
78
+ if (null != title || args.length > 0) this._log('group', _utils__WEBPACK_IMPORTED_MODULE_3__.$_.bold((0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(title, ...args)));
79
+ }
80
+ groupCollapsed(title, ...args) {
81
+ this._groupDepth++;
82
+ if (null != title || args.length > 0) this._log('groupCollapsed', _utils__WEBPACK_IMPORTED_MODULE_3__.$_.bold((0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(title, ...args)));
83
+ }
84
+ groupEnd() {
85
+ if (this._groupDepth > 0) this._groupDepth--;
86
+ }
87
+ info(firstArg, ...args) {
88
+ this._log('info', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(firstArg, ...args));
89
+ }
90
+ log(firstArg, ...args) {
91
+ this._log('log', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(firstArg, ...args));
92
+ }
93
+ time(label = 'default') {
94
+ if (null != this._timers[label]) return;
95
+ this._timers[label] = new Date();
96
+ }
97
+ timeEnd(label = 'default') {
98
+ const startTime = this._timers[label];
99
+ if (null != startTime) {
100
+ const endTime = Date.now();
101
+ const time = endTime - startTime.getTime();
102
+ this._log('time', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(`${label}: ${(0, _utils__WEBPACK_IMPORTED_MODULE_3__.AS)(time)}`));
103
+ delete this._timers[label];
104
+ }
105
+ }
106
+ timeLog(label = 'default', ...data) {
107
+ const startTime = this._timers[label];
108
+ if (null != startTime) {
109
+ const endTime = new Date();
110
+ const time = endTime.getTime() - startTime.getTime();
111
+ this._log('time', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(`${label}: ${(0, _utils__WEBPACK_IMPORTED_MODULE_3__.AS)(time)}`, ...data));
112
+ }
113
+ }
114
+ warn(firstArg, ...args) {
115
+ this._log('warn', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(firstArg, ...args), 'stderr');
116
+ }
117
+ getBuffer() {}
118
+ }
119
+ return new CustomConsole(process.stdout, process.stderr);
120
+ }
121
+ },
122
+ "./src/utils/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
123
+ __webpack_require__.d(__webpack_exports__, {
124
+ Kn: ()=>helper.Kn,
125
+ AS: ()=>helper.AS,
126
+ n1: ()=>constants.n1,
127
+ XQ: ()=>helper.XQ,
128
+ $_: ()=>helper.$_,
129
+ Yz: ()=>helper.Yz
130
+ });
131
+ var helper = __webpack_require__("./src/utils/helper.ts");
132
+ __webpack_require__("./src/utils/logger.ts");
133
+ __webpack_require__("node:fs/promises");
134
+ __webpack_require__("pathe");
135
+ var constants = __webpack_require__("./src/utils/constants.ts");
136
+ }
137
+ };
package/dist/973.js ADDED
@@ -0,0 +1,482 @@
1
+ export const __webpack_ids__ = [
2
+ "973"
3
+ ];
4
+ export const __webpack_modules__ = {
5
+ "../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.25/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
6
+ __webpack_require__.d(__webpack_exports__, {
7
+ s7: ()=>TraceMap,
8
+ Sk: ()=>originalPositionFor
9
+ });
10
+ const comma = ','.charCodeAt(0);
11
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
12
+ const intToChar = new Uint8Array(64);
13
+ const charToInt = new Uint8Array(128);
14
+ for(let i = 0; i < chars.length; i++){
15
+ const c = chars.charCodeAt(i);
16
+ intToChar[i] = c;
17
+ charToInt[c] = i;
18
+ }
19
+ function decodeInteger(reader, relative) {
20
+ let value = 0;
21
+ let shift = 0;
22
+ let integer = 0;
23
+ do {
24
+ const c = reader.next();
25
+ integer = charToInt[c];
26
+ value |= (31 & integer) << shift;
27
+ shift += 5;
28
+ }while (32 & integer);
29
+ const shouldNegate = 1 & value;
30
+ value >>>= 1;
31
+ if (shouldNegate) value = -2147483648 | -value;
32
+ return relative + value;
33
+ }
34
+ function hasMoreVlq(reader, max) {
35
+ if (reader.pos >= max) return false;
36
+ return reader.peek() !== comma;
37
+ }
38
+ typeof TextDecoder;
39
+ class StringReader {
40
+ constructor(buffer){
41
+ this.pos = 0;
42
+ this.buffer = buffer;
43
+ }
44
+ next() {
45
+ return this.buffer.charCodeAt(this.pos++);
46
+ }
47
+ peek() {
48
+ return this.buffer.charCodeAt(this.pos);
49
+ }
50
+ indexOf(char) {
51
+ const { buffer, pos } = this;
52
+ const idx = buffer.indexOf(char, pos);
53
+ return -1 === idx ? buffer.length : idx;
54
+ }
55
+ }
56
+ function decode(mappings) {
57
+ const { length } = mappings;
58
+ const reader = new StringReader(mappings);
59
+ const decoded = [];
60
+ let genColumn = 0;
61
+ let sourcesIndex = 0;
62
+ let sourceLine = 0;
63
+ let sourceColumn = 0;
64
+ let namesIndex = 0;
65
+ do {
66
+ const semi = reader.indexOf(';');
67
+ const line = [];
68
+ let sorted = true;
69
+ let lastCol = 0;
70
+ genColumn = 0;
71
+ while(reader.pos < semi){
72
+ let seg;
73
+ genColumn = decodeInteger(reader, genColumn);
74
+ if (genColumn < lastCol) sorted = false;
75
+ lastCol = genColumn;
76
+ if (hasMoreVlq(reader, semi)) {
77
+ sourcesIndex = decodeInteger(reader, sourcesIndex);
78
+ sourceLine = decodeInteger(reader, sourceLine);
79
+ sourceColumn = decodeInteger(reader, sourceColumn);
80
+ if (hasMoreVlq(reader, semi)) {
81
+ namesIndex = decodeInteger(reader, namesIndex);
82
+ seg = [
83
+ genColumn,
84
+ sourcesIndex,
85
+ sourceLine,
86
+ sourceColumn,
87
+ namesIndex
88
+ ];
89
+ } else seg = [
90
+ genColumn,
91
+ sourcesIndex,
92
+ sourceLine,
93
+ sourceColumn
94
+ ];
95
+ } else seg = [
96
+ genColumn
97
+ ];
98
+ line.push(seg);
99
+ reader.pos++;
100
+ }
101
+ if (!sorted) sort(line);
102
+ decoded.push(line);
103
+ reader.pos = semi + 1;
104
+ }while (reader.pos <= length);
105
+ return decoded;
106
+ }
107
+ function sort(line) {
108
+ line.sort(sortComparator);
109
+ }
110
+ function sortComparator(a, b) {
111
+ return a[0] - b[0];
112
+ }
113
+ const schemeRegex = /^[\w+.-]+:\/\//;
114
+ const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
115
+ const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
116
+ function isAbsoluteUrl(input) {
117
+ return schemeRegex.test(input);
118
+ }
119
+ function isSchemeRelativeUrl(input) {
120
+ return input.startsWith('//');
121
+ }
122
+ function isAbsolutePath(input) {
123
+ return input.startsWith('/');
124
+ }
125
+ function isFileUrl(input) {
126
+ return input.startsWith('file:');
127
+ }
128
+ function isRelative(input) {
129
+ return /^[.?#]/.test(input);
130
+ }
131
+ function parseAbsoluteUrl(input) {
132
+ const match = urlRegex.exec(input);
133
+ return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || '');
134
+ }
135
+ function parseFileUrl(input) {
136
+ const match = fileRegex.exec(input);
137
+ const path = match[2];
138
+ return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || '');
139
+ }
140
+ function makeUrl(scheme, user, host, port, path, query, hash) {
141
+ return {
142
+ scheme,
143
+ user,
144
+ host,
145
+ port,
146
+ path,
147
+ query,
148
+ hash,
149
+ type: 7
150
+ };
151
+ }
152
+ function parseUrl(input) {
153
+ if (isSchemeRelativeUrl(input)) {
154
+ const url = parseAbsoluteUrl('http:' + input);
155
+ url.scheme = '';
156
+ url.type = 6;
157
+ return url;
158
+ }
159
+ if (isAbsolutePath(input)) {
160
+ const url = parseAbsoluteUrl('http://foo.com' + input);
161
+ url.scheme = '';
162
+ url.host = '';
163
+ url.type = 5;
164
+ return url;
165
+ }
166
+ if (isFileUrl(input)) return parseFileUrl(input);
167
+ if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);
168
+ const url = parseAbsoluteUrl('http://foo.com/' + input);
169
+ url.scheme = '';
170
+ url.host = '';
171
+ url.type = input ? input.startsWith('?') ? 3 : input.startsWith('#') ? 2 : 4 : 1;
172
+ return url;
173
+ }
174
+ function stripPathFilename(path) {
175
+ if (path.endsWith('/..')) return path;
176
+ const index = path.lastIndexOf('/');
177
+ return path.slice(0, index + 1);
178
+ }
179
+ function mergePaths(url, base) {
180
+ normalizePath(base, base.type);
181
+ if ('/' === url.path) url.path = base.path;
182
+ else url.path = stripPathFilename(base.path) + url.path;
183
+ }
184
+ function normalizePath(url, type) {
185
+ const rel = type <= 4;
186
+ const pieces = url.path.split('/');
187
+ let pointer = 1;
188
+ let positive = 0;
189
+ let addTrailingSlash = false;
190
+ for(let i = 1; i < pieces.length; i++){
191
+ const piece = pieces[i];
192
+ if (!piece) {
193
+ addTrailingSlash = true;
194
+ continue;
195
+ }
196
+ addTrailingSlash = false;
197
+ if ('.' !== piece) {
198
+ if ('..' === piece) {
199
+ if (positive) {
200
+ addTrailingSlash = true;
201
+ positive--;
202
+ pointer--;
203
+ } else if (rel) pieces[pointer++] = piece;
204
+ continue;
205
+ }
206
+ pieces[pointer++] = piece;
207
+ positive++;
208
+ }
209
+ }
210
+ let path = '';
211
+ for(let i = 1; i < pointer; i++)path += '/' + pieces[i];
212
+ if (!path || addTrailingSlash && !path.endsWith('/..')) path += '/';
213
+ url.path = path;
214
+ }
215
+ function resolve(input, base) {
216
+ if (!input && !base) return '';
217
+ const url = parseUrl(input);
218
+ let inputType = url.type;
219
+ if (base && 7 !== inputType) {
220
+ const baseUrl = parseUrl(base);
221
+ const baseType = baseUrl.type;
222
+ switch(inputType){
223
+ case 1:
224
+ url.hash = baseUrl.hash;
225
+ case 2:
226
+ url.query = baseUrl.query;
227
+ case 3:
228
+ case 4:
229
+ mergePaths(url, baseUrl);
230
+ case 5:
231
+ url.user = baseUrl.user;
232
+ url.host = baseUrl.host;
233
+ url.port = baseUrl.port;
234
+ case 6:
235
+ url.scheme = baseUrl.scheme;
236
+ }
237
+ if (baseType > inputType) inputType = baseType;
238
+ }
239
+ normalizePath(url, inputType);
240
+ const queryHash = url.query + url.hash;
241
+ switch(inputType){
242
+ case 2:
243
+ case 3:
244
+ return queryHash;
245
+ case 4:
246
+ {
247
+ const path = url.path.slice(1);
248
+ if (!path) return queryHash || '.';
249
+ if (isRelative(base || input) && !isRelative(path)) return './' + path + queryHash;
250
+ return path + queryHash;
251
+ }
252
+ case 5:
253
+ return url.path + queryHash;
254
+ default:
255
+ return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
256
+ }
257
+ }
258
+ function trace_mapping_resolve(input, base) {
259
+ if (base && !base.endsWith('/')) base += '/';
260
+ return resolve(input, base);
261
+ }
262
+ function stripFilename(path) {
263
+ if (!path) return '';
264
+ const index = path.lastIndexOf('/');
265
+ return path.slice(0, index + 1);
266
+ }
267
+ const COLUMN = 0;
268
+ const SOURCES_INDEX = 1;
269
+ const SOURCE_LINE = 2;
270
+ const SOURCE_COLUMN = 3;
271
+ const NAMES_INDEX = 4;
272
+ function maybeSort(mappings, owned) {
273
+ const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
274
+ if (unsortedIndex === mappings.length) return mappings;
275
+ if (!owned) mappings = mappings.slice();
276
+ for(let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1))mappings[i] = sortSegments(mappings[i], owned);
277
+ return mappings;
278
+ }
279
+ function nextUnsortedSegmentLine(mappings, start) {
280
+ for(let i = start; i < mappings.length; i++)if (!isSorted(mappings[i])) return i;
281
+ return mappings.length;
282
+ }
283
+ function isSorted(line) {
284
+ for(let j = 1; j < line.length; j++)if (line[j][COLUMN] < line[j - 1][COLUMN]) return false;
285
+ return true;
286
+ }
287
+ function sortSegments(line, owned) {
288
+ if (!owned) line = line.slice();
289
+ return line.sort(trace_mapping_sortComparator);
290
+ }
291
+ function trace_mapping_sortComparator(a, b) {
292
+ return a[COLUMN] - b[COLUMN];
293
+ }
294
+ let found = false;
295
+ function binarySearch(haystack, needle, low, high) {
296
+ while(low <= high){
297
+ const mid = low + (high - low >> 1);
298
+ const cmp = haystack[mid][COLUMN] - needle;
299
+ if (0 === cmp) {
300
+ found = true;
301
+ return mid;
302
+ }
303
+ if (cmp < 0) low = mid + 1;
304
+ else high = mid - 1;
305
+ }
306
+ found = false;
307
+ return low - 1;
308
+ }
309
+ function upperBound(haystack, needle, index) {
310
+ for(let i = index + 1; i < haystack.length && haystack[i][COLUMN] === needle; index = i++);
311
+ return index;
312
+ }
313
+ function lowerBound(haystack, needle, index) {
314
+ for(let i = index - 1; i >= 0 && haystack[i][COLUMN] === needle; index = i--);
315
+ return index;
316
+ }
317
+ function memoizedState() {
318
+ return {
319
+ lastKey: -1,
320
+ lastNeedle: -1,
321
+ lastIndex: -1
322
+ };
323
+ }
324
+ function memoizedBinarySearch(haystack, needle, state, key) {
325
+ const { lastKey, lastNeedle, lastIndex } = state;
326
+ let low = 0;
327
+ let high = haystack.length - 1;
328
+ if (key === lastKey) {
329
+ if (needle === lastNeedle) {
330
+ found = -1 !== lastIndex && haystack[lastIndex][COLUMN] === needle;
331
+ return lastIndex;
332
+ }
333
+ if (needle >= lastNeedle) low = -1 === lastIndex ? 0 : lastIndex;
334
+ else high = lastIndex;
335
+ }
336
+ state.lastKey = key;
337
+ state.lastNeedle = needle;
338
+ return state.lastIndex = binarySearch(haystack, needle, low, high);
339
+ }
340
+ function parse(map) {
341
+ return 'string' == typeof map ? JSON.parse(map) : map;
342
+ }
343
+ function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
344
+ const { sections } = input;
345
+ for(let i = 0; i < sections.length; i++){
346
+ const { map, offset } = sections[i];
347
+ let sl = stopLine;
348
+ let sc = stopColumn;
349
+ if (i + 1 < sections.length) {
350
+ const nextOffset = sections[i + 1].offset;
351
+ sl = Math.min(stopLine, lineOffset + nextOffset.line);
352
+ if (sl === stopLine) sc = Math.min(stopColumn, columnOffset + nextOffset.column);
353
+ else if (sl < stopLine) sc = columnOffset + nextOffset.column;
354
+ }
355
+ addSection(map, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset + offset.line, columnOffset + offset.column, sl, sc);
356
+ }
357
+ }
358
+ function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
359
+ const parsed = parse(input);
360
+ if ('sections' in parsed) return recurse(...arguments);
361
+ const map = new TraceMap(parsed, mapUrl);
362
+ const sourcesOffset = sources.length;
363
+ const namesOffset = names.length;
364
+ const decoded = decodedMappings(map);
365
+ const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map;
366
+ append(sources, resolvedSources);
367
+ append(names, map.names);
368
+ if (contents) append(sourcesContent, contents);
369
+ else for(let i = 0; i < resolvedSources.length; i++)sourcesContent.push(null);
370
+ if (ignores) for(let i = 0; i < ignores.length; i++)ignoreList.push(ignores[i] + sourcesOffset);
371
+ for(let i = 0; i < decoded.length; i++){
372
+ const lineI = lineOffset + i;
373
+ if (lineI > stopLine) return;
374
+ const out = getLine(mappings, lineI);
375
+ const cOffset = 0 === i ? columnOffset : 0;
376
+ const line = decoded[i];
377
+ for(let j = 0; j < line.length; j++){
378
+ const seg = line[j];
379
+ const column = cOffset + seg[COLUMN];
380
+ if (lineI === stopLine && column >= stopColumn) return;
381
+ if (1 === seg.length) {
382
+ out.push([
383
+ column
384
+ ]);
385
+ continue;
386
+ }
387
+ const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];
388
+ const sourceLine = seg[SOURCE_LINE];
389
+ const sourceColumn = seg[SOURCE_COLUMN];
390
+ out.push(4 === seg.length ? [
391
+ column,
392
+ sourcesIndex,
393
+ sourceLine,
394
+ sourceColumn
395
+ ] : [
396
+ column,
397
+ sourcesIndex,
398
+ sourceLine,
399
+ sourceColumn,
400
+ namesOffset + seg[NAMES_INDEX]
401
+ ]);
402
+ }
403
+ }
404
+ }
405
+ function append(arr, other) {
406
+ for(let i = 0; i < other.length; i++)arr.push(other[i]);
407
+ }
408
+ function getLine(arr, index) {
409
+ for(let i = arr.length; i <= index; i++)arr[i] = [];
410
+ return arr[index];
411
+ }
412
+ const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
413
+ const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
414
+ const LEAST_UPPER_BOUND = -1;
415
+ const GREATEST_LOWER_BOUND = 1;
416
+ class TraceMap {
417
+ constructor(map, mapUrl){
418
+ const isString = 'string' == typeof map;
419
+ if (!isString && map._decodedMemo) return map;
420
+ const parsed = isString ? JSON.parse(map) : map;
421
+ const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
422
+ this.version = version;
423
+ this.file = file;
424
+ this.names = names || [];
425
+ this.sourceRoot = sourceRoot;
426
+ this.sources = sources;
427
+ this.sourcesContent = sourcesContent;
428
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
429
+ const from = trace_mapping_resolve(sourceRoot || '', stripFilename(mapUrl));
430
+ this.resolvedSources = sources.map((s)=>trace_mapping_resolve(s || '', from));
431
+ const { mappings } = parsed;
432
+ if ('string' == typeof mappings) {
433
+ this._encoded = mappings;
434
+ this._decoded = void 0;
435
+ } else {
436
+ this._encoded = void 0;
437
+ this._decoded = maybeSort(mappings, isString);
438
+ }
439
+ this._decodedMemo = memoizedState();
440
+ this._bySources = void 0;
441
+ this._bySourceMemos = void 0;
442
+ }
443
+ }
444
+ function cast(map) {
445
+ return map;
446
+ }
447
+ function decodedMappings(map) {
448
+ var _a;
449
+ return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
450
+ }
451
+ function originalPositionFor(map, needle) {
452
+ let { line, column, bias } = needle;
453
+ line--;
454
+ if (line < 0) throw new Error(LINE_GTR_ZERO);
455
+ if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
456
+ const decoded = decodedMappings(map);
457
+ if (line >= decoded.length) return OMapping(null, null, null, null);
458
+ const segments = decoded[line];
459
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
460
+ if (-1 === index) return OMapping(null, null, null, null);
461
+ const segment = segments[index];
462
+ if (1 === segment.length) return OMapping(null, null, null, null);
463
+ const { names, resolvedSources } = map;
464
+ return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], 5 === segment.length ? names[segment[NAMES_INDEX]] : null);
465
+ }
466
+ function OMapping(source, line, column, name) {
467
+ return {
468
+ source,
469
+ line,
470
+ column,
471
+ name
472
+ };
473
+ }
474
+ function traceSegmentInternal(segments, memo, line, column, bias) {
475
+ let index = memoizedBinarySearch(segments, column, memo, line);
476
+ if (found) index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
477
+ else if (bias === LEAST_UPPER_BOUND) index++;
478
+ if (-1 === index || index === segments.length) return -1;
479
+ return index;
480
+ }
481
+ }
482
+ };