* Does what you'd expect.
()
| 286 | * Does what you'd expect. |
| 287 | */ |
| 288 | clone(): this { |
| 289 | const cloned = new MagicString(this.original, { |
| 290 | filename: this.filename, |
| 291 | ignoreList: this.ignoreList, |
| 292 | offset: this.offset, |
| 293 | }) |
| 294 | |
| 295 | let originalChunk = this.firstChunk |
| 296 | let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone()) |
| 297 | |
| 298 | while (originalChunk) { |
| 299 | cloned.byStart.set(clonedChunk.start, clonedChunk) |
| 300 | cloned.byEnd.set(clonedChunk.end, clonedChunk) |
| 301 | |
| 302 | const nextOriginalChunk = originalChunk.next |
| 303 | const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone() |
| 304 | |
| 305 | if (nextClonedChunk) { |
| 306 | clonedChunk.next = nextClonedChunk |
| 307 | nextClonedChunk.previous = clonedChunk |
| 308 | |
| 309 | clonedChunk = nextClonedChunk |
| 310 | } |
| 311 | |
| 312 | originalChunk = nextOriginalChunk |
| 313 | } |
| 314 | |
| 315 | cloned.lastChunk = clonedChunk |
| 316 | |
| 317 | if (this.indentExclusionRanges) { |
| 318 | cloned.indentExclusionRanges = this.indentExclusionRanges.slice() as |
| 319 | | ExclusionRange |
| 320 | | ExclusionRange[] |
| 321 | } |
| 322 | |
| 323 | cloned.sourcemapLocations = new BitSet(this.sourcemapLocations) |
| 324 | cloned.storedNames = { ...this.storedNames } |
| 325 | |
| 326 | cloned.intro = this.intro |
| 327 | cloned.outro = this.outro |
| 328 | cloned.hasMovedChunks = this.hasMovedChunks |
| 329 | |
| 330 | return cloned as this |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * Generates a sourcemap object with raw mappings in array form, rather than encoded as a string. |