UNPKG

2.12 kBTypeScriptView Raw
1export class CodeNode {
2 generatedCode: string;
3
4 constructor(generatedCode: string);
5
6 clone(): CodeNode;
7
8 getGeneratedCode(): string;
9
10 getMappings(mappingsContext?: MappingsContext): string;
11
12 addGeneratedCode(generatedCode: string): void;
13
14 mapGeneratedCode(fn: (code: string) => string): void;
15}
16
17export class MappingsContext {
18 sources: string[];
19 sourcesContent: string[];
20 hasSourceContent: boolean;
21 currentOriginalLine: number;
22 currentSource: number;
23
24 constructor();
25
26 ensureSource(source: string, originalSource: string): number;
27}
28
29export class SourceNode {
30 generatedCode: string;
31 source: string;
32 originalSource: string;
33 startingLine: number;
34
35 constructor(generatedCode: string, source: string, originalSource: string, startingLine?: number);
36
37 clone(): SourceNode;
38
39 getGeneratedCode(): string;
40
41 getMappings(mappingsContext: MappingsContext): string;
42
43 mapGeneratedCode(fn: (code: string) => string): void;
44}
45
46export class SourceListMap {
47 children: Array<SourceNode | CodeNode>;
48
49 constructor(generatedCode: Array<SourceNode | CodeNode>);
50 constructor(
51 generatedCode?: string | SourceNode | CodeNode | SourceListMap,
52 source?: string,
53 originalSource?: string,
54 );
55
56 add(
57 generatedCode: string | CodeNode | SourceNode | SourceListMap,
58 source?: string,
59 originalSource?: string,
60 ): void;
61
62 prepend(generatedCode: SourceListMap | SourceNode | CodeNode, source?: string, originalSource?: string): void;
63
64 mapGeneratedCode(fn: (code: string) => string): void;
65
66 toString(): string;
67
68 toStringWithSourceMap(options: { file: any }): {
69 source: string;
70 map: {
71 version: number;
72 file: any;
73 sources: string[];
74 sourcesContent: string[];
75 mappings: string;
76 };
77 };
78}
79
80export function fromStringWithSourceMap(
81 code: string,
82 map: {
83 sources: Array<string | SourceNode | CodeNode>;
84 sourcesContent: string[];
85 mappings: string;
86 },
87): SourceListMap;