1 | export interface StartOfSourceMap {
|
---|
2 | file?: string;
|
---|
3 | sourceRoot?: string;
|
---|
4 | }
|
---|
5 |
|
---|
6 | export interface RawSourceMap extends StartOfSourceMap {
|
---|
7 | version: string;
|
---|
8 | sources: string[];
|
---|
9 | names: string[];
|
---|
10 | sourcesContent?: string[];
|
---|
11 | mappings: string;
|
---|
12 | }
|
---|
13 |
|
---|
14 | export interface Position {
|
---|
15 | line: number;
|
---|
16 | column: number;
|
---|
17 | }
|
---|
18 |
|
---|
19 | export interface LineRange extends Position {
|
---|
20 | lastColumn: number;
|
---|
21 | }
|
---|
22 |
|
---|
23 | export interface FindPosition extends Position {
|
---|
24 | // SourceMapConsumer.GREATEST_LOWER_BOUND or SourceMapConsumer.LEAST_UPPER_BOUND
|
---|
25 | bias?: number;
|
---|
26 | }
|
---|
27 |
|
---|
28 | export interface SourceFindPosition extends FindPosition {
|
---|
29 | source: string;
|
---|
30 | }
|
---|
31 |
|
---|
32 | export interface MappedPosition extends Position {
|
---|
33 | source: string;
|
---|
34 | name?: string;
|
---|
35 | }
|
---|
36 |
|
---|
37 | export interface MappingItem {
|
---|
38 | source: string | null;
|
---|
39 | generatedLine: number;
|
---|
40 | generatedColumn: number;
|
---|
41 | originalLine: number | null;
|
---|
42 | originalColumn: number | null;
|
---|
43 | name: string | null;
|
---|
44 | }
|
---|
45 |
|
---|
46 | export class SourceMapConsumer {
|
---|
47 | static GENERATED_ORDER: number;
|
---|
48 | static ORIGINAL_ORDER: number;
|
---|
49 |
|
---|
50 | static GREATEST_LOWER_BOUND: number;
|
---|
51 | static LEAST_UPPER_BOUND: number;
|
---|
52 |
|
---|
53 | constructor(rawSourceMap: RawSourceMap);
|
---|
54 | readonly file: string | undefined | null;
|
---|
55 | readonly sourceRoot: string | undefined | null;
|
---|
56 | readonly sourcesContent: readonly string[] | null | undefined;
|
---|
57 | readonly sources: readonly string[]
|
---|
58 |
|
---|
59 | computeColumnSpans(): void;
|
---|
60 | originalPositionFor(generatedPosition: FindPosition): MappedPosition;
|
---|
61 | generatedPositionFor(originalPosition: SourceFindPosition): LineRange;
|
---|
62 | allGeneratedPositionsFor(originalPosition: MappedPosition): Position[];
|
---|
63 | hasContentsOfAllSources(): boolean;
|
---|
64 | sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null;
|
---|
65 | eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
|
---|
66 | }
|
---|
67 |
|
---|
68 | export interface Mapping {
|
---|
69 | generated: Position;
|
---|
70 | original?: Position | null;
|
---|
71 | source?: string | null;
|
---|
72 | name?: string | null;
|
---|
73 | }
|
---|
74 |
|
---|
75 | export class SourceMapGenerator {
|
---|
76 | constructor(startOfSourceMap?: StartOfSourceMap);
|
---|
77 | static fromSourceMap(sourceMapConsumer: SourceMapConsumer, startOfSourceMap?: StartOfSourceMap): SourceMapGenerator;
|
---|
78 | addMapping(mapping: Mapping): void;
|
---|
79 | setSourceContent(sourceFile: string, sourceContent: string | null | undefined): void;
|
---|
80 | applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void;
|
---|
81 | toString(): string;
|
---|
82 | toJSON(): RawSourceMap;
|
---|
83 | }
|
---|
84 |
|
---|
85 | export interface CodeWithSourceMap {
|
---|
86 | code: string;
|
---|
87 | map: SourceMapGenerator;
|
---|
88 | }
|
---|
89 |
|
---|
90 | export class SourceNode {
|
---|
91 | constructor();
|
---|
92 | constructor(line: number, column: number, source: string);
|
---|
93 | constructor(line: number, column: number, source: string, chunk?: string, name?: string);
|
---|
94 | static fromStringWithSourceMap(code: string, sourceMapConsumer: SourceMapConsumer, relativePath?: string): SourceNode;
|
---|
95 | add(chunk: string): void;
|
---|
96 | prepend(chunk: string): void;
|
---|
97 | setSourceContent(sourceFile: string, sourceContent: string): void;
|
---|
98 | walk(fn: (chunk: string, mapping: MappedPosition) => void): void;
|
---|
99 | walkSourceContents(fn: (file: string, content: string) => void): void;
|
---|
100 | join(sep: string): SourceNode;
|
---|
101 | replaceRight(pattern: string, replacement: string): SourceNode;
|
---|
102 | toString(): string;
|
---|
103 | toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap;
|
---|
104 | }
|
---|