module Sprockets::SourceMapUtils
def decode_source_map(map)
map - Source map hash (v3 spec)
}
names: [..]
sources: [..],
],
{ source: "..", generated: [0, 0], original: [0, 0], name: ".."}, ..
mappings: [
file: "..",
version: 3,
# => {
decode_source_map(map)
Example:
Public: Decompress source map
def decode_source_map(map) return nil unless map mappings, sources, names = [], [], [] if map["sections"] map["sections"].each do |s| mappings += decode_source_map(s["map"])[:mappings].each do |m| m[:generated][0] += s["offset"]["line"] m[:generated][1] += s["offset"]["column"] end sources |= s["map"]["sources"] names |= s["map"]["names"] end else mappings = decode_vlq_mappings(map["mappings"], sources: map["sources"], names: map["names"]) sources = map["sources"] names = map["names"] end { version: 3, file: map["file"], mappings: mappings, sources: sources, names: names } end