| 49 | } |
| 50 | |
| 51 | export default class MagicString { |
| 52 | declare original: string |
| 53 | /** @internal */ |
| 54 | declare outro: string |
| 55 | /** @internal */ |
| 56 | declare intro: string |
| 57 | /** @internal */ |
| 58 | declare filename: string | undefined |
| 59 | declare indentExclusionRanges: MagicStringOptions['indentExclusionRanges'] |
| 60 | /** @internal */ |
| 61 | declare ignoreList: boolean | undefined |
| 62 | declare offset: number |
| 63 | /** @internal */ |
| 64 | declare firstChunk: Chunk |
| 65 | /** @internal */ |
| 66 | declare lastChunk: Chunk |
| 67 | /** @internal */ |
| 68 | declare lastSearchedChunk: Chunk |
| 69 | /** @internal */ |
| 70 | declare byStart: Map<number, Chunk> |
| 71 | /** @internal */ |
| 72 | declare byEnd: Map<number, Chunk> |
| 73 | /** @internal */ |
| 74 | declare sourcemapLocations: BitSet |
| 75 | /** @internal */ |
| 76 | declare storedNames: Record<string, true> |
| 77 | /** @internal */ |
| 78 | declare indentStr: string | null | undefined |
| 79 | /** @internal */ |
| 80 | declare stats: Stats |
| 81 | |
| 82 | constructor(string: string, options: MagicStringOptions = {}) { |
| 83 | const chunk = new Chunk(0, string.length, string) |
| 84 | |
| 85 | Object.defineProperties(this, { |
| 86 | original: { writable: true, value: string }, |
| 87 | outro: { writable: true, value: '' }, |
| 88 | intro: { writable: true, value: '' }, |
| 89 | firstChunk: { writable: true, value: chunk }, |
| 90 | lastChunk: { writable: true, value: chunk }, |
| 91 | lastSearchedChunk: { writable: true, value: chunk }, |
| 92 | byStart: { writable: true, value: new Map<number, Chunk>([[0, chunk]]) }, |
| 93 | byEnd: { writable: true, value: new Map<number, Chunk>([[string.length, chunk]]) }, |
| 94 | filename: { writable: true, value: options.filename }, |
| 95 | indentExclusionRanges: { writable: true, value: options.indentExclusionRanges }, |
| 96 | sourcemapLocations: { writable: true, value: new BitSet() }, |
| 97 | storedNames: { writable: true, value: {} }, |
| 98 | indentStr: { writable: true, value: undefined }, |
| 99 | ignoreList: { writable: true, value: options.ignoreList }, |
| 100 | offset: { writable: true, value: options.offset || 0 }, |
| 101 | }) |
| 102 | |
| 103 | if (DEBUG) { |
| 104 | Object.defineProperty(this, 'stats', { value: new Stats() }) |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected