(decode-reverse source-map)
(decode-reverse mappings source-map)
Convert a v3 source map JSON object into a reverse source map
mapping original ClojureScript source locations to the generated
JavaScript.
Source
(defn
decode-reverse
"Convert a v3 source map JSON object into a reverse source map\n mapping original ClojureScript source locations to the generated\n JavaScript."
([source-map]
(decode-reverse (gobj/get source-map "mappings") source-map))
([mappings source-map]
(let
[sources
(gobj/get source-map "sources")
relseg-init
[0 0 0 0 0]
lines
(seq (string/split mappings #";"))]
(loop
[gline
0
lines
lines
relseg
relseg-init
result
(sorted-map-by (source-compare sources))]
(if
lines
(let
[line
(first lines)
[result relseg]
(if
(string/blank? line)
[result relseg]
(let
[segs (seq (string/split line #","))]
(loop
[segs segs relseg relseg result result]
(if
segs
(let
[seg
(first segs)
nrelseg
(seg-combine (base64-vlq/decode seg) relseg)]
(recur
(next segs)
nrelseg
(update-reverse-result
result
(seg->map nrelseg source-map)
gline)))
[result relseg]))))]
(recur (inc gline) (next lines) (assoc relseg 0 0) result))
result)))))