source: trip-planner-front/node_modules/source-map/source-map.d.ts@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 13.0 KB
Line 
1// Type definitions for source-map 0.7
2// Project: https://github.com/mozilla/source-map
3// Definitions by: Morten Houston Ludvigsen <https://github.com/MortenHoustonLudvigsen>,
4// Ron Buckton <https://github.com/rbuckton>,
5// John Vilk <https://github.com/jvilk>
6// Definitions: https://github.com/mozilla/source-map
7export type SourceMapUrl = string;
8
9export interface StartOfSourceMap {
10 file?: string;
11 sourceRoot?: string;
12 skipValidation?: boolean;
13}
14
15export 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
25export interface RawIndexMap extends StartOfSourceMap {
26 version: number;
27 sections: RawSection[];
28}
29
30export interface RawSection {
31 offset: Position;
32 map: RawSourceMap;
33}
34
35export interface Position {
36 line: number;
37 column: number;
38}
39
40export interface NullablePosition {
41 line: number | null;
42 column: number | null;
43 lastColumn: number | null;
44}
45
46export interface MappedPosition {
47 source: string;
48 line: number;
49 column: number;
50 name?: string;
51}
52
53export interface NullableMappedPosition {
54 source: string | null;
55 line: number | null;
56 column: number | null;
57 name: string | null;
58}
59
60export interface MappingItem {
61 source: string;
62 generatedLine: number;
63 generatedColumn: number;
64 originalLine: number;
65 originalColumn: number;
66 name: string;
67}
68
69export interface Mapping {
70 generated: Position;
71 original: Position;
72 source: string;
73 name?: string;
74}
75
76export interface CodeWithSourceMap {
77 code: string;
78 map: SourceMapGenerator;
79}
80
81export interface SourceMapConsumer {
82 /**
83 * Compute the last column for each generated mapping. The last column is
84 * inclusive.
85 */
86 computeColumnSpans(): void;
87
88 /**
89 * Returns the original source, line, and column information for the generated
90 * source's line and column positions provided. The only argument is an object
91 * with the following properties:
92 *
93 * - line: The line number in the generated source.
94 * - column: The column number in the generated source.
95 * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
96 * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
97 * closest element that is smaller than or greater than the one we are
98 * searching for, respectively, if the exact element cannot be found.
99 * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
100 *
101 * and an object is returned with the following properties:
102 *
103 * - source: The original source file, or null.
104 * - line: The line number in the original source, or null.
105 * - column: The column number in the original source, or null.
106 * - name: The original identifier, or null.
107 */
108 originalPositionFor(generatedPosition: Position & { bias?: number }): NullableMappedPosition;
109
110 /**
111 * Returns the generated line and column information for the original source,
112 * line, and column positions provided. The only argument is an object with
113 * the following properties:
114 *
115 * - source: The filename of the original source.
116 * - line: The line number in the original source.
117 * - column: The column number in the original source.
118 * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
119 * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
120 * closest element that is smaller than or greater than the one we are
121 * searching for, respectively, if the exact element cannot be found.
122 * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
123 *
124 * and an object is returned with the following properties:
125 *
126 * - line: The line number in the generated source, or null.
127 * - column: The column number in the generated source, or null.
128 */
129 generatedPositionFor(originalPosition: MappedPosition & { bias?: number }): NullablePosition;
130
131 /**
132 * Returns all generated line and column information for the original source,
133 * line, and column provided. If no column is provided, returns all mappings
134 * corresponding to a either the line we are searching for or the next
135 * closest line that has any mappings. Otherwise, returns all mappings
136 * corresponding to the given line and either the column we are searching for
137 * or the next closest column that has any offsets.
138 *
139 * The only argument is an object with the following properties:
140 *
141 * - source: The filename of the original source.
142 * - line: The line number in the original source.
143 * - column: Optional. the column number in the original source.
144 *
145 * and an array of objects is returned, each with the following properties:
146 *
147 * - line: The line number in the generated source, or null.
148 * - column: The column number in the generated source, or null.
149 */
150 allGeneratedPositionsFor(originalPosition: MappedPosition): NullablePosition[];
151
152 /**
153 * Return true if we have the source content for every source in the source
154 * map, false otherwise.
155 */
156 hasContentsOfAllSources(): boolean;
157
158 /**
159 * Returns the original source content. The only argument is the url of the
160 * original source file. Returns null if no original source content is
161 * available.
162 */
163 sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null;
164
165 /**
166 * Iterate over each mapping between an original source/line/column and a
167 * generated line/column in this source map.
168 *
169 * @param callback
170 * The function that is called with each mapping.
171 * @param context
172 * Optional. If specified, this object will be the value of `this` every
173 * time that `aCallback` is called.
174 * @param order
175 * Either `SourceMapConsumer.GENERATED_ORDER` or
176 * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
177 * iterate over the mappings sorted by the generated file's line/column
178 * order or the original's source/line/column order, respectively. Defaults to
179 * `SourceMapConsumer.GENERATED_ORDER`.
180 */
181 eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
182 /**
183 * Free this source map consumer's associated wasm data that is manually-managed.
184 * Alternatively, you can use SourceMapConsumer.with to avoid needing to remember to call destroy.
185 */
186 destroy(): void;
187}
188
189export 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 * Create a BasicSourceMapConsumer from a SourceMapGenerator.
203 *
204 * @param sourceMap
205 * The source map that will be consumed.
206 */
207 fromSourceMap(sourceMap: SourceMapGenerator, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>;
208
209 /**
210 * Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl`
211 * (see the `SourceMapConsumer` constructor for details. Then, invoke the `async
212 * function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait
213 * for `f` to complete, call `destroy` on the consumer, and return `f`'s return
214 * value.
215 *
216 * You must not use the consumer after `f` completes!
217 *
218 * By using `with`, you do not have to remember to manually call `destroy` on
219 * the consumer, since it will be called automatically once `f` completes.
220 *
221 * ```js
222 * const xSquared = await SourceMapConsumer.with(
223 * myRawSourceMap,
224 * null,
225 * async function (consumer) {
226 * // Use `consumer` inside here and don't worry about remembering
227 * // to call `destroy`.
228 *
229 * const x = await whatever(consumer);
230 * return x * x;
231 * }
232 * );
233 *
234 * // You may not use that `consumer` anymore out here; it has
235 * // been destroyed. But you can use `xSquared`.
236 * console.log(xSquared);
237 * ```
238 */
239 with<T>(rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl: SourceMapUrl | null | undefined, callback: (consumer: BasicSourceMapConsumer | IndexedSourceMapConsumer) => Promise<T> | T): Promise<T>;
240}
241
242export const SourceMapConsumer: SourceMapConsumerConstructor;
243
244export interface BasicSourceMapConsumer extends SourceMapConsumer {
245 file: string;
246 sourceRoot: string;
247 sources: string[];
248 sourcesContent: string[];
249}
250
251export 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
265export const BasicSourceMapConsumer: BasicSourceMapConsumerConstructor;
266
267export interface IndexedSourceMapConsumer extends SourceMapConsumer {
268 sources: string[];
269}
270
271export interface IndexedSourceMapConsumerConstructor {
272 prototype: IndexedSourceMapConsumer;
273
274 new (rawSourceMap: RawIndexMap | string): Promise<IndexedSourceMapConsumer>;
275}
276
277export const IndexedSourceMapConsumer: IndexedSourceMapConsumerConstructor;
278
279export 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
329export 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}
Note: See TracBrowser for help on using the repository browser.