trace-mapping.umd.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/sourcemap-codec'), require('@jridgewell/resolve-uri')) :
  3. typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/sourcemap-codec', '@jridgewell/resolve-uri'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.traceMapping = {}, global.sourcemapCodec, global.resolveURI));
  5. })(this, (function (exports, sourcemapCodec, resolveUri) { 'use strict';
  6. function resolve(input, base) {
  7. // The base is always treated as a directory, if it's not empty.
  8. // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
  9. // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
  10. if (base && !base.endsWith('/'))
  11. base += '/';
  12. return resolveUri(input, base);
  13. }
  14. /**
  15. * Removes everything after the last "/", but leaves the slash.
  16. */
  17. function stripFilename(path) {
  18. if (!path)
  19. return '';
  20. const index = path.lastIndexOf('/');
  21. return path.slice(0, index + 1);
  22. }
  23. const COLUMN = 0;
  24. const SOURCES_INDEX = 1;
  25. const SOURCE_LINE = 2;
  26. const SOURCE_COLUMN = 3;
  27. const NAMES_INDEX = 4;
  28. const REV_GENERATED_LINE = 1;
  29. const REV_GENERATED_COLUMN = 2;
  30. function maybeSort(mappings, owned) {
  31. const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
  32. if (unsortedIndex === mappings.length)
  33. return mappings;
  34. // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If
  35. // not, we do not want to modify the consumer's input array.
  36. if (!owned)
  37. mappings = mappings.slice();
  38. for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
  39. mappings[i] = sortSegments(mappings[i], owned);
  40. }
  41. return mappings;
  42. }
  43. function nextUnsortedSegmentLine(mappings, start) {
  44. for (let i = start; i < mappings.length; i++) {
  45. if (!isSorted(mappings[i]))
  46. return i;
  47. }
  48. return mappings.length;
  49. }
  50. function isSorted(line) {
  51. for (let j = 1; j < line.length; j++) {
  52. if (line[j][COLUMN] < line[j - 1][COLUMN]) {
  53. return false;
  54. }
  55. }
  56. return true;
  57. }
  58. function sortSegments(line, owned) {
  59. if (!owned)
  60. line = line.slice();
  61. return line.sort(sortComparator);
  62. }
  63. function sortComparator(a, b) {
  64. return a[COLUMN] - b[COLUMN];
  65. }
  66. let found = false;
  67. /**
  68. * A binary search implementation that returns the index if a match is found.
  69. * If no match is found, then the left-index (the index associated with the item that comes just
  70. * before the desired index) is returned. To maintain proper sort order, a splice would happen at
  71. * the next index:
  72. *
  73. * ```js
  74. * const array = [1, 3];
  75. * const needle = 2;
  76. * const index = binarySearch(array, needle, (item, needle) => item - needle);
  77. *
  78. * assert.equal(index, 0);
  79. * array.splice(index + 1, 0, needle);
  80. * assert.deepEqual(array, [1, 2, 3]);
  81. * ```
  82. */
  83. function binarySearch(haystack, needle, low, high) {
  84. while (low <= high) {
  85. const mid = low + ((high - low) >> 1);
  86. const cmp = haystack[mid][COLUMN] - needle;
  87. if (cmp === 0) {
  88. found = true;
  89. return mid;
  90. }
  91. if (cmp < 0) {
  92. low = mid + 1;
  93. }
  94. else {
  95. high = mid - 1;
  96. }
  97. }
  98. found = false;
  99. return low - 1;
  100. }
  101. function upperBound(haystack, needle, index) {
  102. for (let i = index + 1; i < haystack.length; index = i++) {
  103. if (haystack[i][COLUMN] !== needle)
  104. break;
  105. }
  106. return index;
  107. }
  108. function lowerBound(haystack, needle, index) {
  109. for (let i = index - 1; i >= 0; index = i--) {
  110. if (haystack[i][COLUMN] !== needle)
  111. break;
  112. }
  113. return index;
  114. }
  115. function memoizedState() {
  116. return {
  117. lastKey: -1,
  118. lastNeedle: -1,
  119. lastIndex: -1,
  120. };
  121. }
  122. /**
  123. * This overly complicated beast is just to record the last tested line/column and the resulting
  124. * index, allowing us to skip a few tests if mappings are monotonically increasing.
  125. */
  126. function memoizedBinarySearch(haystack, needle, state, key) {
  127. const { lastKey, lastNeedle, lastIndex } = state;
  128. let low = 0;
  129. let high = haystack.length - 1;
  130. if (key === lastKey) {
  131. if (needle === lastNeedle) {
  132. found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
  133. return lastIndex;
  134. }
  135. if (needle >= lastNeedle) {
  136. // lastIndex may be -1 if the previous needle was not found.
  137. low = lastIndex === -1 ? 0 : lastIndex;
  138. }
  139. else {
  140. high = lastIndex;
  141. }
  142. }
  143. state.lastKey = key;
  144. state.lastNeedle = needle;
  145. return (state.lastIndex = binarySearch(haystack, needle, low, high));
  146. }
  147. // Rebuilds the original source files, with mappings that are ordered by source line/column instead
  148. // of generated line/column.
  149. function buildBySources(decoded, memos) {
  150. const sources = memos.map(buildNullArray);
  151. for (let i = 0; i < decoded.length; i++) {
  152. const line = decoded[i];
  153. for (let j = 0; j < line.length; j++) {
  154. const seg = line[j];
  155. if (seg.length === 1)
  156. continue;
  157. const sourceIndex = seg[SOURCES_INDEX];
  158. const sourceLine = seg[SOURCE_LINE];
  159. const sourceColumn = seg[SOURCE_COLUMN];
  160. const originalSource = sources[sourceIndex];
  161. const originalLine = (originalSource[sourceLine] || (originalSource[sourceLine] = []));
  162. const memo = memos[sourceIndex];
  163. // The binary search either found a match, or it found the left-index just before where the
  164. // segment should go. Either way, we want to insert after that. And there may be multiple
  165. // generated segments associated with an original location, so there may need to move several
  166. // indexes before we find where we need to insert.
  167. let index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine));
  168. memo.lastIndex = ++index;
  169. insert(originalLine, index, [sourceColumn, i, seg[COLUMN]]);
  170. }
  171. }
  172. return sources;
  173. }
  174. function insert(array, index, value) {
  175. for (let i = array.length; i > index; i--) {
  176. array[i] = array[i - 1];
  177. }
  178. array[index] = value;
  179. }
  180. // Null arrays allow us to use ordered index keys without actually allocating contiguous memory like
  181. // a real array. We use a null-prototype object to avoid prototype pollution and deoptimizations.
  182. // Numeric properties on objects are magically sorted in ascending order by the engine regardless of
  183. // the insertion order. So, by setting any numeric keys, even out of order, we'll get ascending
  184. // order when iterating with for-in.
  185. function buildNullArray() {
  186. return { __proto__: null };
  187. }
  188. const AnyMap = function (map, mapUrl) {
  189. const parsed = parse(map);
  190. if (!('sections' in parsed)) {
  191. return new TraceMap(parsed, mapUrl);
  192. }
  193. const mappings = [];
  194. const sources = [];
  195. const sourcesContent = [];
  196. const names = [];
  197. const ignoreList = [];
  198. recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, ignoreList, 0, 0, Infinity, Infinity);
  199. const joined = {
  200. version: 3,
  201. file: parsed.file,
  202. names,
  203. sources,
  204. sourcesContent,
  205. mappings,
  206. ignoreList,
  207. };
  208. return presortedDecodedMap(joined);
  209. };
  210. function parse(map) {
  211. return typeof map === 'string' ? JSON.parse(map) : map;
  212. }
  213. function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
  214. const { sections } = input;
  215. for (let i = 0; i < sections.length; i++) {
  216. const { map, offset } = sections[i];
  217. let sl = stopLine;
  218. let sc = stopColumn;
  219. if (i + 1 < sections.length) {
  220. const nextOffset = sections[i + 1].offset;
  221. sl = Math.min(stopLine, lineOffset + nextOffset.line);
  222. if (sl === stopLine) {
  223. sc = Math.min(stopColumn, columnOffset + nextOffset.column);
  224. }
  225. else if (sl < stopLine) {
  226. sc = columnOffset + nextOffset.column;
  227. }
  228. }
  229. addSection(map, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset + offset.line, columnOffset + offset.column, sl, sc);
  230. }
  231. }
  232. function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
  233. const parsed = parse(input);
  234. if ('sections' in parsed)
  235. return recurse(...arguments);
  236. const map = new TraceMap(parsed, mapUrl);
  237. const sourcesOffset = sources.length;
  238. const namesOffset = names.length;
  239. const decoded = decodedMappings(map);
  240. const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map;
  241. append(sources, resolvedSources);
  242. append(names, map.names);
  243. if (contents)
  244. append(sourcesContent, contents);
  245. else
  246. for (let i = 0; i < resolvedSources.length; i++)
  247. sourcesContent.push(null);
  248. if (ignores)
  249. for (let i = 0; i < ignores.length; i++)
  250. ignoreList.push(ignores[i] + sourcesOffset);
  251. for (let i = 0; i < decoded.length; i++) {
  252. const lineI = lineOffset + i;
  253. // We can only add so many lines before we step into the range that the next section's map
  254. // controls. When we get to the last line, then we'll start checking the segments to see if
  255. // they've crossed into the column range. But it may not have any columns that overstep, so we
  256. // still need to check that we don't overstep lines, too.
  257. if (lineI > stopLine)
  258. return;
  259. // The out line may already exist in mappings (if we're continuing the line started by a
  260. // previous section). Or, we may have jumped ahead several lines to start this section.
  261. const out = getLine(mappings, lineI);
  262. // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the
  263. // map can be multiple lines), it doesn't.
  264. const cOffset = i === 0 ? columnOffset : 0;
  265. const line = decoded[i];
  266. for (let j = 0; j < line.length; j++) {
  267. const seg = line[j];
  268. const column = cOffset + seg[COLUMN];
  269. // If this segment steps into the column range that the next section's map controls, we need
  270. // to stop early.
  271. if (lineI === stopLine && column >= stopColumn)
  272. return;
  273. if (seg.length === 1) {
  274. out.push([column]);
  275. continue;
  276. }
  277. const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];
  278. const sourceLine = seg[SOURCE_LINE];
  279. const sourceColumn = seg[SOURCE_COLUMN];
  280. out.push(seg.length === 4
  281. ? [column, sourcesIndex, sourceLine, sourceColumn]
  282. : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]]);
  283. }
  284. }
  285. }
  286. function append(arr, other) {
  287. for (let i = 0; i < other.length; i++)
  288. arr.push(other[i]);
  289. }
  290. function getLine(arr, index) {
  291. for (let i = arr.length; i <= index; i++)
  292. arr[i] = [];
  293. return arr[index];
  294. }
  295. const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
  296. const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
  297. const LEAST_UPPER_BOUND = -1;
  298. const GREATEST_LOWER_BOUND = 1;
  299. class TraceMap {
  300. constructor(map, mapUrl) {
  301. const isString = typeof map === 'string';
  302. if (!isString && map._decodedMemo)
  303. return map;
  304. const parsed = (isString ? JSON.parse(map) : map);
  305. const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
  306. this.version = version;
  307. this.file = file;
  308. this.names = names || [];
  309. this.sourceRoot = sourceRoot;
  310. this.sources = sources;
  311. this.sourcesContent = sourcesContent;
  312. this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
  313. const from = resolve(sourceRoot || '', stripFilename(mapUrl));
  314. this.resolvedSources = sources.map((s) => resolve(s || '', from));
  315. const { mappings } = parsed;
  316. if (typeof mappings === 'string') {
  317. this._encoded = mappings;
  318. this._decoded = undefined;
  319. }
  320. else {
  321. this._encoded = undefined;
  322. this._decoded = maybeSort(mappings, isString);
  323. }
  324. this._decodedMemo = memoizedState();
  325. this._bySources = undefined;
  326. this._bySourceMemos = undefined;
  327. }
  328. }
  329. /**
  330. * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
  331. * with public access modifiers.
  332. */
  333. function cast(map) {
  334. return map;
  335. }
  336. /**
  337. * Returns the encoded (VLQ string) form of the SourceMap's mappings field.
  338. */
  339. function encodedMappings(map) {
  340. var _a;
  341. var _b;
  342. return ((_a = (_b = cast(map))._encoded) !== null && _a !== void 0 ? _a : (_b._encoded = sourcemapCodec.encode(cast(map)._decoded)));
  343. }
  344. /**
  345. * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
  346. */
  347. function decodedMappings(map) {
  348. var _a;
  349. return ((_a = cast(map))._decoded || (_a._decoded = sourcemapCodec.decode(cast(map)._encoded)));
  350. }
  351. /**
  352. * A low-level API to find the segment associated with a generated line/column (think, from a
  353. * stack trace). Line and column here are 0-based, unlike `originalPositionFor`.
  354. */
  355. function traceSegment(map, line, column) {
  356. const decoded = decodedMappings(map);
  357. // It's common for parent source maps to have pointers to lines that have no
  358. // mapping (like a "//# sourceMappingURL=") at the end of the child file.
  359. if (line >= decoded.length)
  360. return null;
  361. const segments = decoded[line];
  362. const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
  363. return index === -1 ? null : segments[index];
  364. }
  365. /**
  366. * A higher-level API to find the source/line/column associated with a generated line/column
  367. * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
  368. * `source-map` library.
  369. */
  370. function originalPositionFor(map, needle) {
  371. let { line, column, bias } = needle;
  372. line--;
  373. if (line < 0)
  374. throw new Error(LINE_GTR_ZERO);
  375. if (column < 0)
  376. throw new Error(COL_GTR_EQ_ZERO);
  377. const decoded = decodedMappings(map);
  378. // It's common for parent source maps to have pointers to lines that have no
  379. // mapping (like a "//# sourceMappingURL=") at the end of the child file.
  380. if (line >= decoded.length)
  381. return OMapping(null, null, null, null);
  382. const segments = decoded[line];
  383. const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
  384. if (index === -1)
  385. return OMapping(null, null, null, null);
  386. const segment = segments[index];
  387. if (segment.length === 1)
  388. return OMapping(null, null, null, null);
  389. const { names, resolvedSources } = map;
  390. return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
  391. }
  392. /**
  393. * Finds the generated line/column position of the provided source/line/column source position.
  394. */
  395. function generatedPositionFor(map, needle) {
  396. const { source, line, column, bias } = needle;
  397. return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
  398. }
  399. /**
  400. * Finds all generated line/column positions of the provided source/line/column source position.
  401. */
  402. function allGeneratedPositionsFor(map, needle) {
  403. const { source, line, column, bias } = needle;
  404. // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit.
  405. return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);
  406. }
  407. /**
  408. * Iterates each mapping in generated position order.
  409. */
  410. function eachMapping(map, cb) {
  411. const decoded = decodedMappings(map);
  412. const { names, resolvedSources } = map;
  413. for (let i = 0; i < decoded.length; i++) {
  414. const line = decoded[i];
  415. for (let j = 0; j < line.length; j++) {
  416. const seg = line[j];
  417. const generatedLine = i + 1;
  418. const generatedColumn = seg[0];
  419. let source = null;
  420. let originalLine = null;
  421. let originalColumn = null;
  422. let name = null;
  423. if (seg.length !== 1) {
  424. source = resolvedSources[seg[1]];
  425. originalLine = seg[2] + 1;
  426. originalColumn = seg[3];
  427. }
  428. if (seg.length === 5)
  429. name = names[seg[4]];
  430. cb({
  431. generatedLine,
  432. generatedColumn,
  433. source,
  434. originalLine,
  435. originalColumn,
  436. name,
  437. });
  438. }
  439. }
  440. }
  441. function sourceIndex(map, source) {
  442. const { sources, resolvedSources } = map;
  443. let index = sources.indexOf(source);
  444. if (index === -1)
  445. index = resolvedSources.indexOf(source);
  446. return index;
  447. }
  448. /**
  449. * Retrieves the source content for a particular source, if its found. Returns null if not.
  450. */
  451. function sourceContentFor(map, source) {
  452. const { sourcesContent } = map;
  453. if (sourcesContent == null)
  454. return null;
  455. const index = sourceIndex(map, source);
  456. return index === -1 ? null : sourcesContent[index];
  457. }
  458. /**
  459. * Determines if the source is marked to ignore by the source map.
  460. */
  461. function isIgnored(map, source) {
  462. const { ignoreList } = map;
  463. if (ignoreList == null)
  464. return false;
  465. const index = sourceIndex(map, source);
  466. return index === -1 ? false : ignoreList.includes(index);
  467. }
  468. /**
  469. * A helper that skips sorting of the input map's mappings array, which can be expensive for larger
  470. * maps.
  471. */
  472. function presortedDecodedMap(map, mapUrl) {
  473. const tracer = new TraceMap(clone(map, []), mapUrl);
  474. cast(tracer)._decoded = map.mappings;
  475. return tracer;
  476. }
  477. /**
  478. * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
  479. * a sourcemap, or to JSON.stringify.
  480. */
  481. function decodedMap(map) {
  482. return clone(map, decodedMappings(map));
  483. }
  484. /**
  485. * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
  486. * a sourcemap, or to JSON.stringify.
  487. */
  488. function encodedMap(map) {
  489. return clone(map, encodedMappings(map));
  490. }
  491. function clone(map, mappings) {
  492. return {
  493. version: map.version,
  494. file: map.file,
  495. names: map.names,
  496. sourceRoot: map.sourceRoot,
  497. sources: map.sources,
  498. sourcesContent: map.sourcesContent,
  499. mappings,
  500. ignoreList: map.ignoreList || map.x_google_ignoreList,
  501. };
  502. }
  503. function OMapping(source, line, column, name) {
  504. return { source, line, column, name };
  505. }
  506. function GMapping(line, column) {
  507. return { line, column };
  508. }
  509. function traceSegmentInternal(segments, memo, line, column, bias) {
  510. let index = memoizedBinarySearch(segments, column, memo, line);
  511. if (found) {
  512. index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
  513. }
  514. else if (bias === LEAST_UPPER_BOUND)
  515. index++;
  516. if (index === -1 || index === segments.length)
  517. return -1;
  518. return index;
  519. }
  520. function sliceGeneratedPositions(segments, memo, line, column, bias) {
  521. let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);
  522. // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in
  523. // insertion order) segment that matched. Even if we did respect the bias when tracing, we would
  524. // still need to call `lowerBound()` to find the first segment, which is slower than just looking
  525. // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the
  526. // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to
  527. // match LEAST_UPPER_BOUND.
  528. if (!found && bias === LEAST_UPPER_BOUND)
  529. min++;
  530. if (min === -1 || min === segments.length)
  531. return [];
  532. // We may have found the segment that started at an earlier column. If this is the case, then we
  533. // need to slice all generated segments that match _that_ column, because all such segments span
  534. // to our desired column.
  535. const matchedColumn = found ? column : segments[min][COLUMN];
  536. // The binary search is not guaranteed to find the lower bound when a match wasn't found.
  537. if (!found)
  538. min = lowerBound(segments, matchedColumn, min);
  539. const max = upperBound(segments, matchedColumn, min);
  540. const result = [];
  541. for (; min <= max; min++) {
  542. const segment = segments[min];
  543. result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));
  544. }
  545. return result;
  546. }
  547. function generatedPosition(map, source, line, column, bias, all) {
  548. var _a;
  549. line--;
  550. if (line < 0)
  551. throw new Error(LINE_GTR_ZERO);
  552. if (column < 0)
  553. throw new Error(COL_GTR_EQ_ZERO);
  554. const { sources, resolvedSources } = map;
  555. let sourceIndex = sources.indexOf(source);
  556. if (sourceIndex === -1)
  557. sourceIndex = resolvedSources.indexOf(source);
  558. if (sourceIndex === -1)
  559. return all ? [] : GMapping(null, null);
  560. const generated = ((_a = cast(map))._bySources || (_a._bySources = buildBySources(decodedMappings(map), (cast(map)._bySourceMemos = sources.map(memoizedState)))));
  561. const segments = generated[sourceIndex][line];
  562. if (segments == null)
  563. return all ? [] : GMapping(null, null);
  564. const memo = cast(map)._bySourceMemos[sourceIndex];
  565. if (all)
  566. return sliceGeneratedPositions(segments, memo, line, column, bias);
  567. const index = traceSegmentInternal(segments, memo, line, column, bias);
  568. if (index === -1)
  569. return GMapping(null, null);
  570. const segment = segments[index];
  571. return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
  572. }
  573. exports.AnyMap = AnyMap;
  574. exports.GREATEST_LOWER_BOUND = GREATEST_LOWER_BOUND;
  575. exports.LEAST_UPPER_BOUND = LEAST_UPPER_BOUND;
  576. exports.TraceMap = TraceMap;
  577. exports.allGeneratedPositionsFor = allGeneratedPositionsFor;
  578. exports.decodedMap = decodedMap;
  579. exports.decodedMappings = decodedMappings;
  580. exports.eachMapping = eachMapping;
  581. exports.encodedMap = encodedMap;
  582. exports.encodedMappings = encodedMappings;
  583. exports.generatedPositionFor = generatedPositionFor;
  584. exports.isIgnored = isIgnored;
  585. exports.originalPositionFor = originalPositionFor;
  586. exports.presortedDecodedMap = presortedDecodedMap;
  587. exports.sourceContentFor = sourceContentFor;
  588. exports.traceSegment = traceSegment;
  589. }));
  590. //# sourceMappingURL=trace-mapping.umd.js.map