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