f2f12aa4a4523d5e8bae920d589d30ce80e36f76b457ec6ef65cf8184c1e04e567b20d46e1dca095c5b751eb68c2a81ce914502bf9ba930c69097c96968841 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import type { SourceMapSegment } from './sourcemap-segment';
  2. import type { SourceMapV3, DecodedSourceMap, EncodedSourceMap, InvalidOriginalMapping, OriginalMapping, InvalidGeneratedMapping, GeneratedMapping, SourceMapInput, Needle, SourceNeedle, SourceMap, EachMapping } from './types';
  3. export type { SourceMapSegment } from './sourcemap-segment';
  4. export type { SourceMap, DecodedSourceMap, EncodedSourceMap, Section, SectionedSourceMap, SourceMapV3, Bias, EachMapping, GeneratedMapping, InvalidGeneratedMapping, InvalidOriginalMapping, Needle, OriginalMapping, OriginalMapping as Mapping, SectionedSourceMapInput, SourceMapInput, SourceNeedle, XInput, EncodedSourceMapXInput, DecodedSourceMapXInput, SectionedSourceMapXInput, SectionXInput, } from './types';
  5. export declare const LEAST_UPPER_BOUND = -1;
  6. export declare const GREATEST_LOWER_BOUND = 1;
  7. export { AnyMap } from './any-map';
  8. export declare class TraceMap implements SourceMap {
  9. version: SourceMapV3['version'];
  10. file: SourceMapV3['file'];
  11. names: SourceMapV3['names'];
  12. sourceRoot: SourceMapV3['sourceRoot'];
  13. sources: SourceMapV3['sources'];
  14. sourcesContent: SourceMapV3['sourcesContent'];
  15. ignoreList: SourceMapV3['ignoreList'];
  16. resolvedSources: string[];
  17. private _encoded;
  18. private _decoded;
  19. private _decodedMemo;
  20. private _bySources;
  21. private _bySourceMemos;
  22. constructor(map: SourceMapInput, mapUrl?: string | null);
  23. }
  24. /**
  25. * Returns the encoded (VLQ string) form of the SourceMap's mappings field.
  26. */
  27. export declare function encodedMappings(map: TraceMap): EncodedSourceMap['mappings'];
  28. /**
  29. * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
  30. */
  31. export declare function decodedMappings(map: TraceMap): Readonly<DecodedSourceMap['mappings']>;
  32. /**
  33. * A low-level API to find the segment associated with a generated line/column (think, from a
  34. * stack trace). Line and column here are 0-based, unlike `originalPositionFor`.
  35. */
  36. export declare function traceSegment(map: TraceMap, line: number, column: number): Readonly<SourceMapSegment> | null;
  37. /**
  38. * A higher-level API to find the source/line/column associated with a generated line/column
  39. * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
  40. * `source-map` library.
  41. */
  42. export declare function originalPositionFor(map: TraceMap, needle: Needle): OriginalMapping | InvalidOriginalMapping;
  43. /**
  44. * Finds the generated line/column position of the provided source/line/column source position.
  45. */
  46. export declare function generatedPositionFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping | InvalidGeneratedMapping;
  47. /**
  48. * Finds all generated line/column positions of the provided source/line/column source position.
  49. */
  50. export declare function allGeneratedPositionsFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping[];
  51. /**
  52. * Iterates each mapping in generated position order.
  53. */
  54. export declare function eachMapping(map: TraceMap, cb: (mapping: EachMapping) => void): void;
  55. /**
  56. * Retrieves the source content for a particular source, if its found. Returns null if not.
  57. */
  58. export declare function sourceContentFor(map: TraceMap, source: string): string | null;
  59. /**
  60. * Determines if the source is marked to ignore by the source map.
  61. */
  62. export declare function isIgnored(map: TraceMap, source: string): boolean;
  63. /**
  64. * A helper that skips sorting of the input map's mappings array, which can be expensive for larger
  65. * maps.
  66. */
  67. export declare function presortedDecodedMap(map: DecodedSourceMap, mapUrl?: string): TraceMap;
  68. /**
  69. * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
  70. * a sourcemap, or to JSON.stringify.
  71. */
  72. export declare function decodedMap(map: TraceMap): Omit<DecodedSourceMap, 'mappings'> & {
  73. mappings: readonly SourceMapSegment[][];
  74. };
  75. /**
  76. * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
  77. * a sourcemap, or to JSON.stringify.
  78. */
  79. export declare function encodedMap(map: TraceMap): EncodedSourceMap;