This source map decoder reads one source map and one generated position and prints the original position named by the mappings string. The generated line is an integer from 1 with no leading zero. Line 1 is the first group in mappings. The generated column is 0-based. The value 0 is allowed. Any other leading zero is an error. A column of 0 is the first character on that generated line.
The map must be JSON. If a sections field is present, the map is an index map and is not decoded, even if mappings is also present. If version is present, it must be the number 3. If version is absent, decoding continues and the result says the version was not declared. mappings must be a string. sources must be an array. A bad VLQ character, an unfinished VLQ group, or a segment with 2 or 3 fields fails the whole decode and clears the previous result.
Each segment has 1, 4, or 5 fields. The generated column resets at each line. The source index, original line, original column, and name index carry from one segment to the next, including across lines. The walk starts at the beginning of mappings and stops at the end of the requested line. The winning segment is the one on that line with the greatest generated column that is still less than or equal to the column you typed. A line past the end of mappings produces the message No mapping for that line. A trailing semicolon counts as an empty line. If no segment sits at or before the column, or the winning segment has only the generated column, the message is No source mapping at that column. A one-field segment does not invent a source.
A winning segment with 4 or 5 fields shows the source index, the source string unchanged, and sourceRoot or the word none. sourceRoot is not joined to the source and is not fetched. The original line is shown 0-based and again as that number plus 1, labeled as the editor line. The original column is 0-based. A fifth field shows the name when names at that index is a string. A source index or a name index that is out of range, or that became negative, fails the decode. When sourcesContent at the source index is a string, that text is shown as text. Otherwise the page says there is no embedded source. Copy writes the labeled rows and does not write the embedded source text.
Nothing is sent off the page. A source URL is text. The page does not beautify JavaScript and does not read ignore-list extension keys.
The map {“version”:3,”sources”:[“a.js”],”names”:[“x”],”mappings”:”AAAAA”} at line 1 and column 0 produces source a.js, original line 0, editor line 1, original column 0, and name x. The same shape with mappings QAAA at column 0 produces No source mapping at that column, because the first segment starts at column 8. At column 8 that map produces source a.js.
A map with sections is refused as an index map. A version of 2 is refused. A map that omits version still decodes and says the version was not declared. Mappings of a single A at column 0 is a one-field segment and does not invent a source. A sourcesContent string that contains a script tag is shown as text and is not inserted as a script. A query on a line past the mappings groups says there is no mapping for that line. A mappings value that ends with a semicolon has an extra empty line.
The lookup stays in the browser. A result is the original position stored in the map for the generated position you typed. It is not the file from a server, and it is not a formatted script.
One lookup in a source map version 3 mappings string. Generated line starts at 1 and cannot have a leading zero. Generated column is 0-based, so 0 is the first character, and any other leading zero is an error. A map with sections is an index map and is not decoded. If version is present it must be the number 3. If version is absent, the result says it was not declared. A segment has 1, 4, or 5 fields. A 1-field segment does not invent a source. The original line is shown 0-based and as that number plus 1 for an editor. sourceRoot is shown unchanged and is not joined to the source. Source URLs are not fetched. Embedded source, when the map includes it, is text. This page does not beautify JavaScript. Nothing is sent or stored.
The mappings string stores a 0-based column. The field rejects a leading zero on any other column, and it rejects a leading zero on the line. Line 1 is the first group in mappings.
It is an index map. This page does not decode sections, even when a mappings string is also present. The previous result is cleared.
No. The source string and sourceRoot are shown as stored. They are not joined and not requested. Embedded source, when the map contains it, is shown as text.
No. A segment with only a generated column has no source. If that segment is the one at the column you asked for, the page says there is no source mapping there.