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

Method generateDecodedMap

src/Bundle.ts:136–223  ·  view source on GitHub ↗
(options: SourceMapOptions = {})

Source from the content-addressed store, hash-verified

134 }
135
136 generateDecodedMap(options: SourceMapOptions = {}): DecodedSourceMapOrMissingContent {
137 const names = []
138 let x_google_ignoreList
139 this.sources.forEach((source) => {
140 Object.keys(source.content.storedNames).forEach((name) => {
141 if (!names.includes(name))
142 names.push(name)
143 })
144 })
145
146 const mappings = new Mappings(options.hires)
147
148 if (this.intro) {
149 mappings.advance(this.intro)
150 }
151
152 this.sources.forEach((source, i) => {
153 if (i > 0) {
154 // mirrors toString(): a source can override the bundle separator
155 mappings.advance(source.separator !== undefined ? source.separator : this.separator)
156 }
157
158 const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1
159 const magicString = source.content
160 const locate = getLocator(magicString.original)
161
162 if (magicString.intro) {
163 mappings.advance(magicString.intro)
164 }
165
166 magicString.firstChunk.eachNext((chunk) => {
167 const loc = locate(chunk.start)
168
169 if (chunk.intro.length)
170 mappings.advance(chunk.intro)
171
172 if (source.filename) {
173 if (chunk.edited) {
174 mappings.addEdit(
175 sourceIndex,
176 chunk.content,
177 loc,
178 chunk.storeName ? names.indexOf(chunk.original) : -1,
179 )
180 }
181 else {
182 mappings.addUneditedChunk(
183 sourceIndex,
184 chunk,
185 magicString.original,
186 loc,
187 magicString.sourcemapLocations,
188 )
189 }
190 }
191 else {
192 mappings.advance(chunk.content)
193 }

Callers 2

generateMapMethod · 0.95

Calls 7

advanceMethod · 0.95
addEditMethod · 0.95
addUneditedChunkMethod · 0.95
getLocatorFunction · 0.50
getRelativePathFunction · 0.50
eachNextMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected