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

Method generateDecodedMap

src/Bundle.js:85–166  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

83 }
84
85 generateDecodedMap(options = {}) {
86 const names = [];
87 let x_google_ignoreList = undefined;
88 this.sources.forEach((source) => {
89 Object.keys(source.content.storedNames).forEach((name) => {
90 if (!~names.indexOf(name)) names.push(name);
91 });
92 });
93
94 const mappings = new Mappings(options.hires);
95
96 if (this.intro) {
97 mappings.advance(this.intro);
98 }
99
100 this.sources.forEach((source, i) => {
101 if (i > 0) {
102 mappings.advance(this.separator);
103 }
104
105 const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
106 const magicString = source.content;
107 const locate = getLocator(magicString.original);
108
109 if (magicString.intro) {
110 mappings.advance(magicString.intro);
111 }
112
113 magicString.firstChunk.eachNext((chunk) => {
114 const loc = locate(chunk.start);
115
116 if (chunk.intro.length) mappings.advance(chunk.intro);
117
118 if (source.filename) {
119 if (chunk.edited) {
120 mappings.addEdit(
121 sourceIndex,
122 chunk.content,
123 loc,
124 chunk.storeName ? names.indexOf(chunk.original) : -1,
125 );
126 } else {
127 mappings.addUneditedChunk(
128 sourceIndex,
129 chunk,
130 magicString.original,
131 loc,
132 magicString.sourcemapLocations,
133 );
134 }
135 } else {
136 mappings.advance(chunk.content);
137 }
138
139 if (chunk.outro.length) mappings.advance(chunk.outro);
140 });
141
142 if (magicString.outro) {

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