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

Method generateDecodedMap

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

Source from the content-addressed store, hash-verified

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

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