types.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import type { SourceMapSegment } from './sourcemap-segment';
  2. import type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping';
  3. export interface SourceMapV3 {
  4. file?: string | null;
  5. names: string[];
  6. sourceRoot?: string;
  7. sources: (string | null)[];
  8. sourcesContent?: (string | null)[];
  9. version: 3;
  10. ignoreList?: number[];
  11. }
  12. export interface EncodedSourceMap extends SourceMapV3 {
  13. mappings: string;
  14. }
  15. export interface DecodedSourceMap extends SourceMapV3 {
  16. mappings: SourceMapSegment[][];
  17. }
  18. export interface Section {
  19. offset: {
  20. line: number;
  21. column: number;
  22. };
  23. map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap;
  24. }
  25. export interface SectionedSourceMap {
  26. file?: string | null;
  27. sections: Section[];
  28. version: 3;
  29. }
  30. export type OriginalMapping = {
  31. source: string | null;
  32. line: number;
  33. column: number;
  34. name: string | null;
  35. };
  36. export type InvalidOriginalMapping = {
  37. source: null;
  38. line: null;
  39. column: null;
  40. name: null;
  41. };
  42. export type GeneratedMapping = {
  43. line: number;
  44. column: number;
  45. };
  46. export type InvalidGeneratedMapping = {
  47. line: null;
  48. column: null;
  49. };
  50. export type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND;
  51. export type XInput = {
  52. x_google_ignoreList?: SourceMapV3['ignoreList'];
  53. };
  54. export type EncodedSourceMapXInput = EncodedSourceMap & XInput;
  55. export type DecodedSourceMapXInput = DecodedSourceMap & XInput;
  56. export type SectionedSourceMapXInput = Omit<SectionedSourceMap, 'sections'> & {
  57. sections: SectionXInput[];
  58. };
  59. export type SectionXInput = Omit<Section, 'map'> & {
  60. map: SectionedSourceMapInput;
  61. };
  62. export type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap;
  63. export type SectionedSourceMapInput = SourceMapInput | SectionedSourceMapXInput;
  64. export type Needle = {
  65. line: number;
  66. column: number;
  67. bias?: Bias;
  68. };
  69. export type SourceNeedle = {
  70. source: string;
  71. line: number;
  72. column: number;
  73. bias?: Bias;
  74. };
  75. export type EachMapping = {
  76. generatedLine: number;
  77. generatedColumn: number;
  78. source: null;
  79. originalLine: null;
  80. originalColumn: null;
  81. name: null;
  82. } | {
  83. generatedLine: number;
  84. generatedColumn: number;
  85. source: string | null;
  86. originalLine: number;
  87. originalColumn: number;
  88. name: string | null;
  89. };
  90. export declare abstract class SourceMap {
  91. version: SourceMapV3['version'];
  92. file: SourceMapV3['file'];
  93. names: SourceMapV3['names'];
  94. sourceRoot: SourceMapV3['sourceRoot'];
  95. sources: SourceMapV3['sources'];
  96. sourcesContent: SourceMapV3['sourcesContent'];
  97. resolvedSources: SourceMapV3['sources'];
  98. ignoreList: SourceMapV3['ignoreList'];
  99. }