| 137 | } |
| 138 | |
| 139 | export default class MagicString { |
| 140 | declare original: string |
| 141 | /** @internal */ |
| 142 | declare outro: string |
| 143 | /** @internal */ |
| 144 | declare intro: string |
| 145 | /** @internal */ |
| 146 | declare filename: string | undefined |
| 147 | declare indentExclusionRanges: MagicStringOptions['indentExclusionRanges'] |
| 148 | /** @internal */ |
| 149 | declare ignoreList: boolean | undefined |
| 150 | declare offset: number |
| 151 | /** @internal */ |
| 152 | declare firstChunk: Chunk |
| 153 | /** @internal */ |
| 154 | declare lastChunk: Chunk |
| 155 | /** @internal */ |
| 156 | declare lastSearchedChunk: Chunk |
| 157 | /** @internal */ |
| 158 | declare byStart: Map<number, Chunk> |
| 159 | /** @internal */ |
| 160 | declare byEnd: Map<number, Chunk> |
| 161 | /** @internal */ |
| 162 | declare sourcemapLocations: BitSet |
| 163 | /** @internal */ |
| 164 | declare storedNames: Record<string, true> |
| 165 | /** @internal */ |
| 166 | declare indentStr: string | null | undefined |
| 167 | /** @internal */ |
| 168 | declare stats: Stats |
| 169 | /** @internal */ |
| 170 | declare hasMovedChunks: boolean |
| 171 | |
| 172 | constructor(string: string, options: MagicStringOptions = {}) { |
| 173 | const chunk = new Chunk(0, string.length, string) |
| 174 | |
| 175 | Object.defineProperties(this, { |
| 176 | original: { writable: true, value: string }, |
| 177 | outro: { writable: true, value: '' }, |
| 178 | intro: { writable: true, value: '' }, |
| 179 | firstChunk: { writable: true, value: chunk }, |
| 180 | lastChunk: { writable: true, value: chunk }, |
| 181 | lastSearchedChunk: { writable: true, value: chunk }, |
| 182 | byStart: { writable: true, value: new Map<number, Chunk>([[0, chunk]]) }, |
| 183 | byEnd: { writable: true, value: new Map<number, Chunk>([[string.length, chunk]]) }, |
| 184 | filename: { writable: true, value: options.filename }, |
| 185 | indentExclusionRanges: { writable: true, value: options.indentExclusionRanges }, |
| 186 | sourcemapLocations: { writable: true, value: new BitSet() }, |
| 187 | storedNames: { writable: true, value: {} }, |
| 188 | indentStr: { writable: true, value: undefined }, |
| 189 | ignoreList: { writable: true, value: options.ignoreList }, |
| 190 | offset: { writable: true, value: options.offset || 0 }, |
| 191 | hasMovedChunks: { writable: true, value: false }, |
| 192 | }) |
| 193 | |
| 194 | /* v8 ignore next 3 -- DEBUG is always true in tests */ |
| 195 | if (DEBUG) { |
| 196 | Object.defineProperty(this, 'stats', { value: new Stats() }) |
nothing calls this directly
no outgoing calls
no test coverage detected