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

Method generateDecodedMap

src/Bundle.ts:151–243  ·  view source on GitHub ↗
(options: BundleSourceMapOptions = {})

Source from the content-addressed store, hash-verified

149 }
150
151 generateDecodedMap(options: BundleSourceMapOptions = {}): DecodedSourceMapOrMissingContent {
152 const names = []
153 let x_google_ignoreList
154 this.sources.forEach((source) => {
155 Object.keys(source.content.storedNames).forEach((name) => {
156 if (!names.includes(name))
157 names.push(name)
158 })
159 })
160
161 const mappings = new Mappings(options.hires)
162
163 if (this.intro) {
164 mappings.advance(this.intro)
165 }
166
167 this.sources.forEach((source, i) => {
168 if (i > 0) {
169 // mirrors toString(): a source can override the bundle separator
170 mappings.advance(source.separator !== undefined ? source.separator : this.separator)
171 }
172
173 const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1
174 const magicString = source.content
175 const locate = getLocator(magicString.original)
176
177 if (magicString.intro) {
178 mappings.advance(magicString.intro)
179 }
180
181 magicString.firstChunk.eachNext((chunk) => {
182 const loc = locate(chunk.start)
183
184 if (chunk.intro.length)
185 mappings.advance(chunk.intro)
186
187 if (source.filename) {
188 if (chunk.edited) {
189 mappings.addEdit(
190 sourceIndex,
191 chunk.content,
192 loc,
193 chunk.storeName ? names.indexOf(chunk.original) : -1,
194 )
195 }
196 else {
197 mappings.addUneditedChunk(
198 sourceIndex,
199 chunk,
200 magicString.original,
201 loc,
202 magicString.sourcemapLocations,
203 )
204 }
205 }
206 else {
207 mappings.advance(chunk.content)
208 }

Callers 3

generateMapMethod · 0.95
Bundle.test.tsFile · 0.45

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