* Does what you'd expect.
()
| 193 | * Does what you'd expect. |
| 194 | */ |
| 195 | clone(): this { |
| 196 | const cloned = new MagicString(this.original, { |
| 197 | filename: this.filename, |
| 198 | ignoreList: this.ignoreList, |
| 199 | offset: this.offset, |
| 200 | }) |
| 201 | |
| 202 | let originalChunk = this.firstChunk |
| 203 | let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone()) |
| 204 | |
| 205 | while (originalChunk) { |
| 206 | cloned.byStart.set(clonedChunk.start, clonedChunk) |
| 207 | cloned.byEnd.set(clonedChunk.end, clonedChunk) |
| 208 | |
| 209 | const nextOriginalChunk = originalChunk.next |
| 210 | const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone() |
| 211 | |
| 212 | if (nextClonedChunk) { |
| 213 | clonedChunk.next = nextClonedChunk |
| 214 | nextClonedChunk.previous = clonedChunk |
| 215 | |
| 216 | clonedChunk = nextClonedChunk |
| 217 | } |
| 218 | |
| 219 | originalChunk = nextOriginalChunk |
| 220 | } |
| 221 | |
| 222 | cloned.lastChunk = clonedChunk |
| 223 | |
| 224 | if (this.indentExclusionRanges) { |
| 225 | cloned.indentExclusionRanges = this.indentExclusionRanges.slice() as |
| 226 | | ExclusionRange |
| 227 | | ExclusionRange[] |
| 228 | } |
| 229 | |
| 230 | cloned.sourcemapLocations = new BitSet(this.sourcemapLocations) |
| 231 | cloned.storedNames = { ...this.storedNames } |
| 232 | |
| 233 | cloned.intro = this.intro |
| 234 | cloned.outro = this.outro |
| 235 | cloned.hasMovedChunks = this.hasMovedChunks |
| 236 | |
| 237 | return cloned as this |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * Generates a sourcemap object with raw mappings in array form, rather than encoded as a string. |