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

Method generateDecodedMap

src/MagicString.js:139–185  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

137 }
138
139 generateDecodedMap(options) {
140 options = options || {};
141
142 const sourceIndex = 0;
143 const names = Object.keys(this.storedNames);
144 const mappings = new Mappings(options.hires);
145
146 const locate = getLocator(this.original);
147
148 if (this.intro) {
149 mappings.advance(this.intro);
150 }
151
152 this.firstChunk.eachNext((chunk) => {
153 const loc = locate(chunk.start);
154
155 if (chunk.intro.length) mappings.advance(chunk.intro);
156
157 if (chunk.edited) {
158 mappings.addEdit(
159 sourceIndex,
160 chunk.content,
161 loc,
162 chunk.storeName ? names.indexOf(chunk.original) : -1,
163 );
164 } else {
165 mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
166 }
167
168 if (chunk.outro.length) mappings.advance(chunk.outro);
169 });
170
171 if (this.outro) {
172 mappings.advance(this.outro);
173 }
174
175 return {
176 file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
177 sources: [
178 options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
179 ],
180 sourcesContent: options.includeContent ? [this.original] : undefined,
181 names,
182 mappings: mappings.raw,
183 x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
184 };
185 }
186
187 generateMap(options) {
188 return new SourceMap(this.generateDecodedMap(options));

Callers 1

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