|
| 1 | +// Type definitions for source-map v0.1.38 |
| 2 | +// Project: https://github.com/mozilla/source-map |
| 3 | +// Definitions by: Morten Houston Ludvigsen <https://github.com/MortenHoustonLudvigsen> |
| 4 | +// Definitions: https://github.com/borisyankov/DefinitelyTyped |
| 5 | + |
| 6 | +declare module SourceMap { |
| 7 | + interface StartOfSourceMap { |
| 8 | + file?: string; |
| 9 | + sourceRoot?: string; |
| 10 | + } |
| 11 | + |
| 12 | + interface RawSourceMap extends StartOfSourceMap { |
| 13 | + version: string; |
| 14 | + sources: Array<string>; |
| 15 | + names: Array<string>; |
| 16 | + sourcesContent?: string[]; |
| 17 | + mappings: string; |
| 18 | + } |
| 19 | + |
| 20 | + interface Position { |
| 21 | + line: number; |
| 22 | + column: number; |
| 23 | + } |
| 24 | + |
| 25 | + interface MappedPosition extends Position { |
| 26 | + source: string; |
| 27 | + name?: string; |
| 28 | + } |
| 29 | + |
| 30 | + interface MappingItem { |
| 31 | + source: string; |
| 32 | + generatedLine: number; |
| 33 | + generatedColumn: number; |
| 34 | + originalLine: number; |
| 35 | + originalColumn: number; |
| 36 | + name: string; |
| 37 | + } |
| 38 | + |
| 39 | + interface Mapping { |
| 40 | + generated: Position; |
| 41 | + original: Position; |
| 42 | + source: string; |
| 43 | + name?: string; |
| 44 | + } |
| 45 | + |
| 46 | + interface CodeWithSourceMap { |
| 47 | + code: string; |
| 48 | + map: SourceMapGenerator; |
| 49 | + } |
| 50 | + |
| 51 | + class SourceMapConsumer { |
| 52 | + public static GENERATED_ORDER: number; |
| 53 | + public static ORIGINAL_ORDER: number; |
| 54 | + |
| 55 | + constructor(rawSourceMap: RawSourceMap); |
| 56 | + public originalPositionFor(generatedPosition: Position): MappedPosition; |
| 57 | + public generatedPositionFor(originalPosition: MappedPosition): Position; |
| 58 | + public sourceContentFor(source: string): string; |
| 59 | + public eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void; |
| 60 | + } |
| 61 | + |
| 62 | + class SourceMapGenerator { |
| 63 | + constructor(startOfSourceMap?: StartOfSourceMap); |
| 64 | + public static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator; |
| 65 | + public addMapping(mapping: Mapping): void; |
| 66 | + public setSourceContent(sourceFile: string, sourceContent: string): void; |
| 67 | + public applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void; |
| 68 | + public toString(): string; |
| 69 | + } |
| 70 | + |
| 71 | + class SourceNode { |
| 72 | + constructor(); |
| 73 | + constructor(line: number, column: number, source: string); |
| 74 | + constructor(line: number, column: number, source: string, chunk?: string, name?: string); |
| 75 | + public static fromStringWithSourceMap(code: string, sourceMapConsumer: SourceMapConsumer, relativePath?: string): SourceNode; |
| 76 | + public add(chunk: any): SourceNode; |
| 77 | + public prepend(chunk: any): SourceNode; |
| 78 | + public setSourceContent(sourceFile: string, sourceContent: string): void; |
| 79 | + public walk(fn: (chunk: string, mapping: MappedPosition) => void): void; |
| 80 | + public walkSourceContents(fn: (file: string, content: string) => void): void; |
| 81 | + public join(sep: string): SourceNode; |
| 82 | + public replaceRight(pattern: string, replacement: string): SourceNode; |
| 83 | + public toString(): string; |
| 84 | + public toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap; |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +declare module 'source-map' { |
| 89 | + export = SourceMap; |
| 90 | +} |
0 commit comments