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

Method generateDecodedMap

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

Source from the content-addressed store, hash-verified

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

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