index.d.ts 3.0 KB

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