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

Method generateDecodedMap

src/Bundle.ts:151–244  ·  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 /* v8 ignore next -- addSource always normalizes source.separator */
171 mappings.advance(source.separator !== undefined ? source.separator : this.separator)
172 }
173
174 const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1
175 const magicString = source.content
176 const locate = getLocator(magicString.original)
177
178 if (magicString.intro) {
179 mappings.advance(magicString.intro)
180 }
181
182 magicString.firstChunk.eachNext((chunk) => {
183 const loc = locate(chunk.start)
184
185 if (chunk.intro.length)
186 mappings.advance(chunk.intro)
187
188 if (source.filename) {
189 if (chunk.edited) {
190 mappings.addEdit(
191 sourceIndex,
192 chunk.content,
193 loc,
194 chunk.storeName ? names.indexOf(chunk.original) : -1,
195 )
196 }
197 else {
198 mappings.addUneditedChunk(
199 sourceIndex,
200 chunk,
201 magicString.original,
202 loc,
203 magicString.sourcemapLocations,
204 )
205 }
206 }
207 else {
208 mappings.advance(chunk.content)

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