index.d.ts 3.2 KB

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