Tim van der Lippe | f171bbb | 2020-07-02 18:02:57 +0100 | [diff] [blame] | 1 | export interface BundleOptions { |
| 2 | intro?: string; |
| 3 | separator?: string; |
| 4 | } |
| 5 | |
| 6 | export interface SourceMapOptions { |
| 7 | hires: boolean; |
| 8 | file: string; |
| 9 | source: string; |
| 10 | includeContent: boolean; |
| 11 | } |
| 12 | |
| 13 | export type SourceMapSegment = |
| 14 | | [number] |
| 15 | | [number, number, number, number] |
| 16 | | [number, number, number, number, number]; |
| 17 | |
| 18 | export interface DecodedSourceMap { |
| 19 | file: string; |
| 20 | sources: string[]; |
| 21 | sourcesContent: string[]; |
| 22 | names: string[]; |
| 23 | mappings: SourceMapSegment[][]; |
| 24 | } |
| 25 | |
| 26 | export class SourceMap { |
| 27 | constructor(properties: DecodedSourceMap); |
| 28 | |
| 29 | version: number; |
| 30 | file: string; |
| 31 | sources: string[]; |
| 32 | sourcesContent: string[]; |
| 33 | names: string[]; |
| 34 | mappings: string; |
| 35 | |
| 36 | toString(): string; |
| 37 | toUrl(): string; |
| 38 | } |
| 39 | |
| 40 | export class Bundle { |
| 41 | constructor(options?: BundleOptions); |
| 42 | addSource(source: MagicString | { filename?: string, content: MagicString }): Bundle; |
| 43 | append(str: string, options?: BundleOptions): Bundle; |
| 44 | clone(): Bundle; |
| 45 | generateMap(options?: Partial<SourceMapOptions>): SourceMap; |
| 46 | generateDecodedMap(options?: Partial<SourceMapOptions>): DecodedSourceMap; |
| 47 | getIndentString(): string; |
| 48 | indent(indentStr?: string): Bundle; |
| 49 | indentExclusionRanges: ExclusionRange | Array<ExclusionRange>; |
| 50 | prepend(str: string): Bundle; |
| 51 | toString(): string; |
| 52 | trimLines(): Bundle; |
| 53 | trim(charType?: string): Bundle; |
| 54 | trimStart(charType?: string): Bundle; |
| 55 | trimEnd(charType?: string): Bundle; |
| 56 | isEmpty(): boolean; |
| 57 | length(): number; |
| 58 | } |
| 59 | |
| 60 | export type ExclusionRange = [ number, number ]; |
| 61 | |
| 62 | export interface MagicStringOptions { |
| 63 | filename: string, |
| 64 | indentExclusionRanges: ExclusionRange | Array<ExclusionRange>; |
| 65 | } |
| 66 | |
| 67 | export interface IndentOptions { |
| 68 | exclude: ExclusionRange | Array<ExclusionRange>; |
| 69 | indentStart: boolean; |
| 70 | } |
| 71 | |
| 72 | export interface OverwriteOptions { |
| 73 | storeName?: boolean; |
| 74 | contentOnly?: boolean; |
| 75 | } |
| 76 | |
| 77 | export default class MagicString { |
| 78 | constructor(str: string, options?: MagicStringOptions); |
| 79 | addSourcemapLocation(char: number): void; |
| 80 | append(content: string): MagicString; |
| 81 | appendLeft(index: number, content: string): MagicString; |
| 82 | appendRight(index: number, content: string): MagicString; |
| 83 | clone(): MagicString; |
| 84 | generateMap(options?: Partial<SourceMapOptions>): SourceMap; |
| 85 | generateDecodedMap(options?: Partial<SourceMapOptions>): DecodedSourceMap; |
| 86 | getIndentString(): string; |
| 87 | |
| 88 | indent(options?: IndentOptions): MagicString; |
| 89 | indent(indentStr?: string, options?: IndentOptions): MagicString; |
| 90 | indentExclusionRanges: ExclusionRange | Array<ExclusionRange>; |
| 91 | |
| 92 | move(start: number, end: number, index: number): MagicString; |
| 93 | overwrite(start: number, end: number, content: string, options?: boolean | OverwriteOptions): MagicString; |
| 94 | prepend(content: string): MagicString; |
| 95 | prependLeft(index: number, content: string): MagicString; |
| 96 | prependRight(index: number, content: string): MagicString; |
| 97 | remove(start: number, end: number): MagicString; |
| 98 | slice(start: number, end: number): string; |
| 99 | snip(start: number, end: number): MagicString; |
| 100 | trim(charType?: string): MagicString; |
| 101 | trimStart(charType?: string): MagicString; |
| 102 | trimEnd(charType?: string): MagicString; |
| 103 | trimLines(): MagicString; |
| 104 | |
| 105 | lastChar(): string; |
| 106 | lastLine(): string; |
| 107 | isEmpty(): boolean; |
| 108 | length(): number; |
| 109 | |
| 110 | original: string; |
| 111 | } |