/usr/lib/nodejs/sourcemap-codec/index.js is in node-sourcemap-codec 1.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | "use strict";
"use strict";
exports.__esModule = true;
var vlq_1 = require("vlq");
function decodeSegments(encodedSegments) {
var i = encodedSegments.length;
var segments = new Array(i);
while (i--)
segments[i] = vlq_1.decode(encodedSegments[i]);
return segments;
}
function decode(mappings) {
var sourceFileIndex = 0; // second field
var sourceCodeLine = 0; // third field
var sourceCodeColumn = 0; // fourth field
var nameIndex = 0; // fifth field
var lines = mappings.split(';');
var numLines = lines.length;
var decoded = new Array(numLines);
var i;
var j;
var line;
var generatedCodeColumn;
var decodedLine;
var segments;
var segment;
var result;
for (i = 0; i < numLines; i += 1) {
line = lines[i];
generatedCodeColumn = 0; // first field - reset each time
decodedLine = [];
segments = decodeSegments(line.split(','));
for (j = 0; j < segments.length; j += 1) {
segment = segments[j];
if (!segment.length) {
break;
}
generatedCodeColumn += segment[0];
result = [generatedCodeColumn];
decodedLine.push(result);
if (segment.length === 1) {
// only one field!
continue;
}
sourceFileIndex += segment[1];
sourceCodeLine += segment[2];
sourceCodeColumn += segment[3];
result.push(sourceFileIndex, sourceCodeLine, sourceCodeColumn);
if (segment.length === 5) {
nameIndex += segment[4];
result.push(nameIndex);
}
}
decoded[i] = decodedLine;
}
return decoded;
}
exports.decode = decode;
function encode(decoded) {
var offsets = {
generatedCodeColumn: 0,
sourceFileIndex: 0,
sourceCodeLine: 0,
sourceCodeColumn: 0,
nameIndex: 0 // fifth field
};
return decoded.map(function (line) {
offsets.generatedCodeColumn = 0; // first field - reset each time
return line.map(encodeSegment).join(',');
}).join(';');
function encodeSegment(segment) {
if (!segment.length) {
return '';
}
var result = new Array(segment.length);
result[0] = segment[0] - offsets.generatedCodeColumn;
offsets.generatedCodeColumn = segment[0];
if (segment.length === 1) {
// only one field!
return vlq_1.encode(result);
}
result[1] = segment[1] - offsets.sourceFileIndex;
result[2] = segment[2] - offsets.sourceCodeLine;
result[3] = segment[3] - offsets.sourceCodeColumn;
offsets.sourceFileIndex = segment[1];
offsets.sourceCodeLine = segment[2];
offsets.sourceCodeColumn = segment[3];
if (segment.length === 5) {
result[4] = segment[4] - offsets.nameIndex;
offsets.nameIndex = segment[4];
}
return vlq_1.encode(result);
}
}
exports.encode = encode;
|