]> git.r.bdr.sh - rbdr/dotfiles/blob
c94ebd1709735eb2bfc97bd33bb62cc98baab0af
[rbdr/dotfiles] /
1 // Generated by CoffeeScript 1.8.0
2 (function() {
3 var LineMap, SourceMap;
4
5 LineMap = (function() {
6 function LineMap(line) {
7 this.line = line;
8 this.columns = [];
9 }
10
11 LineMap.prototype.add = function(column, _arg, options) {
12 var sourceColumn, sourceLine;
13 sourceLine = _arg[0], sourceColumn = _arg[1];
14 if (options == null) {
15 options = {};
16 }
17 if (this.columns[column] && options.noReplace) {
18 return;
19 }
20 return this.columns[column] = {
21 line: this.line,
22 column: column,
23 sourceLine: sourceLine,
24 sourceColumn: sourceColumn
25 };
26 };
27
28 LineMap.prototype.sourceLocation = function(column) {
29 var mapping;
30 while (!((mapping = this.columns[column]) || (column <= 0))) {
31 column--;
32 }
33 return mapping && [mapping.sourceLine, mapping.sourceColumn];
34 };
35
36 return LineMap;
37
38 })();
39
40 SourceMap = (function() {
41 var BASE64_CHARS, VLQ_CONTINUATION_BIT, VLQ_SHIFT, VLQ_VALUE_MASK;
42
43 function SourceMap() {
44 this.lines = [];
45 }
46
47 SourceMap.prototype.add = function(sourceLocation, generatedLocation, options) {
48 var column, line, lineMap, _base;
49 if (options == null) {
50 options = {};
51 }
52 line = generatedLocation[0], column = generatedLocation[1];
53 lineMap = ((_base = this.lines)[line] || (_base[line] = new LineMap(line)));
54 return lineMap.add(column, sourceLocation, options);
55 };
56
57 SourceMap.prototype.sourceLocation = function(_arg) {
58 var column, line, lineMap;
59 line = _arg[0], column = _arg[1];
60 while (!((lineMap = this.lines[line]) || (line <= 0))) {
61 line--;
62 }
63 return lineMap && lineMap.sourceLocation(column);
64 };
65
66 SourceMap.prototype.generate = function(options, code) {
67 var buffer, lastColumn, lastSourceColumn, lastSourceLine, lineMap, lineNumber, mapping, needComma, v3, writingline, _i, _j, _len, _len1, _ref, _ref1;
68 if (options == null) {
69 options = {};
70 }
71 if (code == null) {
72 code = null;
73 }
74 writingline = 0;
75 lastColumn = 0;
76 lastSourceLine = 0;
77 lastSourceColumn = 0;
78 needComma = false;
79 buffer = "";
80 _ref = this.lines;
81 for (lineNumber = _i = 0, _len = _ref.length; _i < _len; lineNumber = ++_i) {
82 lineMap = _ref[lineNumber];
83 if (lineMap) {
84 _ref1 = lineMap.columns;
85 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
86 mapping = _ref1[_j];
87 if (!(mapping)) {
88 continue;
89 }
90 while (writingline < mapping.line) {
91 lastColumn = 0;
92 needComma = false;
93 buffer += ";";
94 writingline++;
95 }
96 if (needComma) {
97 buffer += ",";
98 needComma = false;
99 }
100 buffer += this.encodeVlq(mapping.column - lastColumn);
101 lastColumn = mapping.column;
102 buffer += this.encodeVlq(0);
103 buffer += this.encodeVlq(mapping.sourceLine - lastSourceLine);
104 lastSourceLine = mapping.sourceLine;
105 buffer += this.encodeVlq(mapping.sourceColumn - lastSourceColumn);
106 lastSourceColumn = mapping.sourceColumn;
107 needComma = true;
108 }
109 }
110 }
111 v3 = {
112 version: 3,
113 file: options.generatedFile || '',
114 sourceRoot: options.sourceRoot || '',
115 sources: options.sourceFiles || [''],
116 names: [],
117 mappings: buffer
118 };
119 if (options.inline) {
120 v3.sourcesContent = [code];
121 }
122 return JSON.stringify(v3, null, 2);
123 };
124
125 VLQ_SHIFT = 5;
126
127 VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
128
129 VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
130
131 SourceMap.prototype.encodeVlq = function(value) {
132 var answer, nextChunk, signBit, valueToEncode;
133 answer = '';
134 signBit = value < 0 ? 1 : 0;
135 valueToEncode = (Math.abs(value) << 1) + signBit;
136 while (valueToEncode || !answer) {
137 nextChunk = valueToEncode & VLQ_VALUE_MASK;
138 valueToEncode = valueToEncode >> VLQ_SHIFT;
139 if (valueToEncode) {
140 nextChunk |= VLQ_CONTINUATION_BIT;
141 }
142 answer += this.encodeBase64(nextChunk);
143 }
144 return answer;
145 };
146
147 BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
148
149 SourceMap.prototype.encodeBase64 = function(value) {
150 return BASE64_CHARS[value] || (function() {
151 throw new Error("Cannot Base64 encode value: " + value);
152 })();
153 };
154
155 return SourceMap;
156
157 })();
158
159 module.exports = SourceMap;
160
161 }).call(this);