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

Method generateDecodedMap

src/Bundle.ts:133–219  ·  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 mappings.advance(this.separator)
152 }
153
154 const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1
155 const magicString = source.content
156 const locate = getLocator(magicString.original)
157
158 if (magicString.intro) {
159 mappings.advance(magicString.intro)
160 }
161
162 magicString.firstChunk.eachNext((chunk) => {
163 const loc = locate(chunk.start)
164
165 if (chunk.intro.length)
166 mappings.advance(chunk.intro)
167
168 if (source.filename) {
169 if (chunk.edited) {
170 mappings.addEdit(
171 sourceIndex,
172 chunk.content,
173 loc,
174 chunk.storeName ? names.indexOf(chunk.original) : -1,
175 )
176 }
177 else {
178 mappings.addUneditedChunk(
179 sourceIndex,
180 chunk,
181 magicString.original,
182 loc,
183 magicString.sourcemapLocations,
184 )
185 }
186 }
187 else {
188 mappings.advance(chunk.content)
189 }
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