index.d.ts 2.4KB

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