1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | export type SourceMapUrl = string;
|
8 |
|
9 | export interface StartOfSourceMap {
|
10 | file?: string;
|
11 | sourceRoot?: string;
|
12 | skipValidation?: boolean;
|
13 | }
|
14 |
|
15 | export interface RawSourceMap {
|
16 | version: number;
|
17 | sources: string[];
|
18 | names: string[];
|
19 | sourceRoot?: string;
|
20 | sourcesContent?: string[];
|
21 | mappings: string;
|
22 | file: string;
|
23 | }
|
24 |
|
25 | export interface RawIndexMap extends StartOfSourceMap {
|
26 | version: number;
|
27 | sections: RawSection[];
|
28 | }
|
29 |
|
30 | export interface RawSection {
|
31 | offset: Position;
|
32 | map: RawSourceMap;
|
33 | }
|
34 |
|
35 | export interface Position {
|
36 | line: number;
|
37 | column: number;
|
38 | }
|
39 |
|
40 | export interface NullablePosition {
|
41 | line: number | null;
|
42 | column: number | null;
|
43 | lastColumn: number | null;
|
44 | }
|
45 |
|
46 | export interface MappedPosition {
|
47 | source: string;
|
48 | line: number;
|
49 | column: number;
|
50 | name?: string;
|
51 | }
|
52 |
|
53 | export interface NullableMappedPosition {
|
54 | source: string | null;
|
55 | line: number | null;
|
56 | column: number | null;
|
57 | name: string | null;
|
58 | }
|
59 |
|
60 | export interface MappingItem {
|
61 | source: string;
|
62 | generatedLine: number;
|
63 | generatedColumn: number;
|
64 | originalLine: number;
|
65 | originalColumn: number;
|
66 | name: string;
|
67 | }
|
68 |
|
69 | export interface Mapping {
|
70 | generated: Position;
|
71 | original: Position;
|
72 | source: string;
|
73 | name?: string;
|
74 | }
|
75 |
|
76 | export interface CodeWithSourceMap {
|
77 | code: string;
|
78 | map: SourceMapGenerator;
|
79 | }
|
80 |
|
81 | export interface SourceMapConsumer {
|
82 | |
83 |
|
84 |
|
85 |
|
86 | computeColumnSpans(): void;
|
87 |
|
88 | |
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | originalPositionFor(generatedPosition: Position & { bias?: number }): NullableMappedPosition;
|
109 |
|
110 | |
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | generatedPositionFor(originalPosition: MappedPosition & { bias?: number }): NullablePosition;
|
130 |
|
131 | |
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | allGeneratedPositionsFor(originalPosition: MappedPosition): NullablePosition[];
|
151 |
|
152 | |
153 |
|
154 |
|
155 |
|
156 | hasContentsOfAllSources(): boolean;
|
157 |
|
158 | |
159 |
|
160 |
|
161 |
|
162 |
|
163 | sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null;
|
164 |
|
165 | |
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 | eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
|
182 | |
183 |
|
184 |
|
185 |
|
186 | destroy(): void;
|
187 | }
|
188 |
|
189 | export interface SourceMapConsumerConstructor {
|
190 | prototype: SourceMapConsumer;
|
191 |
|
192 | GENERATED_ORDER: number;
|
193 | ORIGINAL_ORDER: number;
|
194 | GREATEST_LOWER_BOUND: number;
|
195 | LEAST_UPPER_BOUND: number;
|
196 |
|
197 | new (rawSourceMap: RawSourceMap, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>;
|
198 | new (rawSourceMap: RawIndexMap, sourceMapUrl?: SourceMapUrl): Promise<IndexedSourceMapConsumer>;
|
199 | new (rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer | IndexedSourceMapConsumer>;
|
200 |
|
201 | |
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 | fromSourceMap(sourceMap: SourceMapGenerator, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>;
|
208 |
|
209 | |
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 | with<T>(rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl: SourceMapUrl | null | undefined, callback: (consumer: BasicSourceMapConsumer | IndexedSourceMapConsumer) => Promise<T> | T): Promise<T>;
|
240 | }
|
241 |
|
242 | export const SourceMapConsumer: SourceMapConsumerConstructor;
|
243 |
|
244 | export interface BasicSourceMapConsumer extends SourceMapConsumer {
|
245 | file: string;
|
246 | sourceRoot: string;
|
247 | sources: string[];
|
248 | sourcesContent: string[];
|
249 | }
|
250 |
|
251 | export interface BasicSourceMapConsumerConstructor {
|
252 | prototype: BasicSourceMapConsumer;
|
253 |
|
254 | new (rawSourceMap: RawSourceMap | string): Promise<BasicSourceMapConsumer>;
|
255 |
|
256 | /**
|
257 | * Create a BasicSourceMapConsumer from a SourceMapGenerator.
|
258 | *
|
259 | * @param sourceMap
|
260 | * The source map that will be consumed.
|
261 | */
|
262 | fromSourceMap(sourceMap: SourceMapGenerator): Promise<BasicSourceMapConsumer>;
|
263 | }
|
264 |
|
265 | export const BasicSourceMapConsumer: BasicSourceMapConsumerConstructor;
|
266 |
|
267 | export interface IndexedSourceMapConsumer extends SourceMapConsumer {
|
268 | sources: string[];
|
269 | }
|
270 |
|
271 | export interface IndexedSourceMapConsumerConstructor {
|
272 | prototype: IndexedSourceMapConsumer;
|
273 |
|
274 | new (rawSourceMap: RawIndexMap | string): Promise<IndexedSourceMapConsumer>;
|
275 | }
|
276 |
|
277 | export const IndexedSourceMapConsumer: IndexedSourceMapConsumerConstructor;
|
278 |
|
279 | export class SourceMapGenerator {
|
280 | constructor(startOfSourceMap?: StartOfSourceMap);
|
281 |
|
282 | /**
|
283 | * Creates a new SourceMapGenerator based on a SourceMapConsumer
|
284 | *
|
285 | * @param sourceMapConsumer The SourceMap.
|
286 | */
|
287 | static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator;
|
288 |
|
289 | /**
|
290 | * Add a single mapping from original source line and column to the generated
|
291 | * source's line and column for this source map being created. The mapping
|
292 | * object should have the following properties:
|
293 | *
|
294 | * - generated: An object with the generated line and column positions.
|
295 | * - original: An object with the original line and column positions.
|
296 | * - source: The original source file (relative to the sourceRoot).
|
297 | * - name: An optional original token name for this mapping.
|
298 | */
|
299 | addMapping(mapping: Mapping): void;
|
300 |
|
301 | /**
|
302 | * Set the source content for a source file.
|
303 | */
|
304 | setSourceContent(sourceFile: string, sourceContent: string): void;
|
305 |
|
306 | /**
|
307 | * Applies the mappings of a sub-source-map for a specific source file to the
|
308 | * source map being generated. Each mapping to the supplied source file is
|
309 | * rewritten using the supplied source map. Note: The resolution for the
|
310 | * resulting mappings is the minimium of this map and the supplied map.
|
311 | *
|
312 | * @param sourceMapConsumer The source map to be applied.
|
313 | * @param sourceFile Optional. The filename of the source file.
|
314 | * If omitted, SourceMapConsumer's file property will be used.
|
315 | * @param sourceMapPath Optional. The dirname of the path to the source map
|
316 | * to be applied. If relative, it is relative to the SourceMapConsumer.
|
317 | * This parameter is needed when the two source maps aren't in the same
|
318 | * directory, and the source map to be applied contains relative source
|
319 | * paths. If so, those relative source paths need to be rewritten
|
320 | * relative to the SourceMapGenerator.
|
321 | */
|
322 | applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void;
|
323 |
|
324 | toString(): string;
|
325 |
|
326 | toJSON(): RawSourceMap;
|
327 | }
|
328 |
|
329 | export class SourceNode {
|
330 | children: SourceNode[];
|
331 | sourceContents: any;
|
332 | line: number;
|
333 | column: number;
|
334 | source: string;
|
335 | name: string;
|
336 |
|
337 | constructor();
|
338 | constructor(
|
339 | line: number | null,
|
340 | column: number | null,
|
341 | source: string | null,
|
342 | chunks?: Array<(string | SourceNode)> | SourceNode | string,
|
343 | name?: string
|
344 | );
|
345 |
|
346 | static fromStringWithSourceMap(
|
347 | code: string,
|
348 | sourceMapConsumer: SourceMapConsumer,
|
349 | relativePath?: string
|
350 | ): SourceNode;
|
351 |
|
352 | add(chunk: Array<(string | SourceNode)> | SourceNode | string): SourceNode;
|
353 |
|
354 | prepend(chunk: Array<(string | SourceNode)> | SourceNode | string): SourceNode;
|
355 |
|
356 | setSourceContent(sourceFile: string, sourceContent: string): void;
|
357 |
|
358 | walk(fn: (chunk: string, mapping: MappedPosition) => void): void;
|
359 |
|
360 | walkSourceContents(fn: (file: string, content: string) => void): void;
|
361 |
|
362 | join(sep: string): SourceNode;
|
363 |
|
364 | replaceRight(pattern: string, replacement: string): SourceNode;
|
365 |
|
366 | toString(): string;
|
367 |
|
368 | toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap;
|
369 | }
|
370 |
|
\ | No newline at end of file |