MCPcopy Create free account
hub / github.com/Rich-Harris/magic-string / _generateMappings

Method _generateMappings

src/MagicString.ts:369–405  ·  view source on GitHub ↗

@internal

(mappings: Mappings)

Source from the content-addressed store, hash-verified

367
368 /** @internal */
369 _generateMappings(mappings: Mappings): string[] {
370 const sourceIndex = 0
371 const names = Object.keys(this.storedNames)
372 const locate = getLocator(this.original)
373
374 if (this.intro) {
375 mappings.advance(this.intro)
376 }
377
378 this.firstChunk.eachNext((chunk) => {
379 const loc = locate(chunk.start)
380
381 if (chunk.intro.length)
382 mappings.advance(chunk.intro)
383
384 if (chunk.edited) {
385 mappings.addEdit(
386 sourceIndex,
387 chunk.content,
388 loc,
389 chunk.storeName ? names.indexOf(chunk.original) : -1,
390 )
391 }
392 else {
393 mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations)
394 }
395
396 if (chunk.outro.length)
397 mappings.advance(chunk.outro)
398 })
399
400 if (this.outro) {
401 mappings.advance(this.outro)
402 }
403
404 return names
405 }
406
407 /** @internal */
408 _mapProperties(options: SourceMapOptions, names: string[]): Omit<DecodedSourceMap, 'mappings' | 'rangeMappings'> {

Callers 2

generateDecodedMapMethod · 0.95
generateMapMethod · 0.95

Calls 5

getLocatorFunction · 0.90
advanceMethod · 0.45
eachNextMethod · 0.45
addEditMethod · 0.45
addUneditedChunkMethod · 0.45

Tested by

no test coverage detected