diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-03 15:35:00 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-03 15:35:00 +0200 |
commit | de98e0b232509d5f40c135d540a70e415272ff85 (patch) | |
tree | a79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/source-list-map/lib | |
parent | e0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff) | |
download | wallet-core-de98e0b232509d5f40c135d540a70e415272ff85.tar.xz |
node_modules
Diffstat (limited to 'node_modules/source-list-map/lib')
-rw-r--r-- | node_modules/source-list-map/lib/CodeNode.js | 61 | ||||
-rw-r--r-- | node_modules/source-list-map/lib/MappingsContext.js | 25 | ||||
-rw-r--r-- | node_modules/source-list-map/lib/SingleLineNode.js | 87 | ||||
-rw-r--r-- | node_modules/source-list-map/lib/SourceListMap.js | 110 | ||||
-rw-r--r-- | node_modules/source-list-map/lib/SourceNode.js | 124 | ||||
-rw-r--r-- | node_modules/source-list-map/lib/base64-vlq.js | 169 | ||||
-rw-r--r-- | node_modules/source-list-map/lib/fromStringWithSourceMap.js | 99 | ||||
-rw-r--r-- | node_modules/source-list-map/lib/helpers.js | 21 | ||||
-rw-r--r-- | node_modules/source-list-map/lib/index.js | 5 |
9 files changed, 701 insertions, 0 deletions
diff --git a/node_modules/source-list-map/lib/CodeNode.js b/node_modules/source-list-map/lib/CodeNode.js new file mode 100644 index 000000000..bfbbdf3ab --- /dev/null +++ b/node_modules/source-list-map/lib/CodeNode.js @@ -0,0 +1,61 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var getNumberOfLines = require("./helpers").getNumberOfLines;
+var getUnfinishedLine = require("./helpers").getUnfinishedLine;
+
+function CodeNode(generatedCode) {
+ this.generatedCode = generatedCode;
+}
+module.exports = CodeNode;
+
+CodeNode.prototype.clone = function() {
+ return new CodeNode(this.generatedCode);
+}
+
+CodeNode.prototype.getGeneratedCode = function() {
+ return this.generatedCode;
+};
+
+CodeNode.prototype.getMappings = function(mappingsContext) {
+ var lines = getNumberOfLines(this.generatedCode);
+ var mapping = Array(lines+1).join(";");
+ if(lines > 0) {
+ mappingsContext.unfinishedGeneratedLine = getUnfinishedLine(this.generatedCode);
+ if(mappingsContext.unfinishedGeneratedLine > 0) {
+ return mapping + "A";
+ } else {
+ return mapping;
+ }
+ } else {
+ var prevUnfinished = mappingsContext.unfinishedGeneratedLine;
+ mappingsContext.unfinishedGeneratedLine += getUnfinishedLine(this.generatedCode);
+ if(prevUnfinished === 0 && mappingsContext.unfinishedGeneratedLine > 0) {
+ return "A";
+ } else {
+ return "";
+ }
+ }
+};
+
+CodeNode.prototype.addGeneratedCode = function(generatedCode) {
+ this.generatedCode += generatedCode;
+};
+
+CodeNode.prototype.mapGeneratedCode = function(fn) {
+ var generatedCode = fn(this.generatedCode);
+ return new CodeNode(generatedCode);
+};
+
+CodeNode.prototype.getNormalizedNodes = function() {
+ return [this];
+};
+
+CodeNode.prototype.merge = function merge(otherNode) {
+ if(otherNode instanceof CodeNode) {
+ this.generatedCode += otherNode.generatedCode;
+ return this;
+ }
+ return false;
+};
diff --git a/node_modules/source-list-map/lib/MappingsContext.js b/node_modules/source-list-map/lib/MappingsContext.js new file mode 100644 index 000000000..5d2b3b1a6 --- /dev/null +++ b/node_modules/source-list-map/lib/MappingsContext.js @@ -0,0 +1,25 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function MappingsContext() {
+ this.sources = [];
+ this.sourcesContent = [];
+ this.hasSourceContent = false;
+ this.currentOriginalLine = 1;
+ this.currentSource = 0;
+ this.unfinishedGeneratedLine = false;
+}
+module.exports = MappingsContext;
+
+MappingsContext.prototype.ensureSource = function(source, originalSource) {
+ var idx = this.sources.indexOf(source);
+ if(idx >= 0)
+ return idx;
+ idx = this.sources.length;
+ this.sources.push(source);
+ this.sourcesContent.push(originalSource);
+ if(typeof originalSource === "string")
+ this.hasSourceContent = true;
+ return idx;
+};
diff --git a/node_modules/source-list-map/lib/SingleLineNode.js b/node_modules/source-list-map/lib/SingleLineNode.js new file mode 100644 index 000000000..a8b7e4ec6 --- /dev/null +++ b/node_modules/source-list-map/lib/SingleLineNode.js @@ -0,0 +1,87 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+module.exports = SingleLineNode; // circular dependency
+
+var base64VLQ = require("./base64-vlq");
+var getNumberOfLines = require("./helpers").getNumberOfLines;
+var getUnfinishedLine = require("./helpers").getUnfinishedLine;
+var SourceNode = require("./SourceNode");
+
+function SingleLineNode(generatedCode, source, originalSource, line) {
+ this.generatedCode = generatedCode;
+ this.originalSource = originalSource;
+ this.source = source;
+ this.line = line || 1;
+ this._numberOfLines = getNumberOfLines(this.generatedCode);
+ this._endsWithNewLine = generatedCode[generatedCode.length - 1] === "\n";
+}
+
+SingleLineNode.prototype.clone = function() {
+ return new SingleLineNode(this.generatedCode, this.source, this.originalSource, this.line);
+}
+
+var LINE_MAPPING = ";AAAA";
+
+SingleLineNode.prototype.getGeneratedCode = function() {
+ return this.generatedCode;
+};
+
+SingleLineNode.prototype.getMappings = function(mappingsContext) {
+ if(!this.generatedCode)
+ return "";
+ var lines = this._numberOfLines;
+ var sourceIdx = mappingsContext.ensureSource(this.source, this.originalSource);
+ var mappings = "A"; // generated column 0
+ if(mappingsContext.unfinishedGeneratedLine)
+ mappings = "," + base64VLQ.encode(mappingsContext.unfinishedGeneratedLine);
+ mappings += base64VLQ.encode(sourceIdx - mappingsContext.currentSource); // source index
+ mappings += base64VLQ.encode(this.line - mappingsContext.currentOriginalLine); // original line index
+ mappings += "A"; // original column 0
+ mappingsContext.currentSource = sourceIdx;
+ mappingsContext.currentOriginalLine = this.line;
+ var unfinishedGeneratedLine = mappingsContext.unfinishedGeneratedLine = getUnfinishedLine(this.generatedCode)
+ mappings += Array(lines).join(LINE_MAPPING);
+ if(unfinishedGeneratedLine === 0) {
+ mappings += ";";
+ } else {
+ if(lines !== 0)
+ mappings += LINE_MAPPING;
+ }
+ return mappings;
+};
+
+SingleLineNode.prototype.getNormalizedNodes = function() {
+ return [this];
+};
+
+SingleLineNode.prototype.mapGeneratedCode = function(fn) {
+ var generatedCode = fn(this.generatedCode);
+ return new SingleLineNode(generatedCode, this.source, this.originalSource, this.line);
+};
+
+SingleLineNode.prototype.merge = function merge(otherNode) {
+ if(otherNode instanceof SingleLineNode) {
+ return this.mergeSingleLineNode(otherNode);
+ }
+ return false;
+};
+
+SingleLineNode.prototype.mergeSingleLineNode = function mergeSingleLineNode(otherNode) {
+ if(this.source === otherNode.source &&
+ this.originalSource === otherNode.originalSource) {
+ if(this.line === otherNode.line) {
+ this.generatedCode += otherNode.generatedCode;
+ this._numberOfLines += otherNode._numberOfLines;
+ this._endsWithNewLine = otherNode._endsWithNewLine;
+ return this;
+ } else if(this.line + 1 === otherNode.line &&
+ this._endsWithNewLine &&
+ this._numberOfLines === 1 &&
+ otherNode._numberOfLines <= 1) {
+ return new SourceNode(this.generatedCode + otherNode.generatedCode, this.source, this.originalSource, this.line);
+ }
+ }
+ return false;
+};
diff --git a/node_modules/source-list-map/lib/SourceListMap.js b/node_modules/source-list-map/lib/SourceListMap.js new file mode 100644 index 000000000..cb1b8d6f8 --- /dev/null +++ b/node_modules/source-list-map/lib/SourceListMap.js @@ -0,0 +1,110 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var CodeNode = require("./CodeNode");
+var SourceNode = require("./SourceNode");
+var MappingsContext = require("./MappingsContext");
+var getNumberOfLines = require("./helpers").getNumberOfLines;
+
+function SourceListMap(generatedCode, source, originalSource) {
+ if(Array.isArray(generatedCode)) {
+ this.children = generatedCode;
+ } else {
+ this.children = [];
+ if(generatedCode || source)
+ this.add(generatedCode, source, originalSource);
+ }
+}
+module.exports = SourceListMap;
+
+SourceListMap.prototype.add = function(generatedCode, source, originalSource) {
+ if(typeof generatedCode === "string") {
+ if(source) {
+ this.children.push(new SourceNode(generatedCode, source, originalSource));
+ } else if(this.children.length > 0 && this.children[this.children.length - 1] instanceof CodeNode) {
+ this.children[this.children.length - 1].addGeneratedCode(generatedCode);
+ } else {
+ this.children.push(new CodeNode(generatedCode));
+ }
+ } else if(generatedCode.getMappings && generatedCode.getGeneratedCode) {
+ this.children.push(generatedCode);
+ } else if(generatedCode.children) {
+ generatedCode.children.forEach(function(sln) {
+ this.children.push(sln);
+ }, this);
+ } else {
+ throw new Error("Invalid arguments to SourceListMap.prototype.add: Expected string, Node or SourceListMap");
+ }
+};
+
+SourceListMap.prototype.preprend = function(generatedCode, source, originalSource) {
+ if(typeof generatedCode === "string") {
+ if(source) {
+ this.children.unshift(new SourceNode(generatedCode, source, originalSource));
+ } else if(this.children.length > 0 && this.children[this.children.length - 1].preprendGeneratedCode) {
+ this.children[this.children.length - 1].preprendGeneratedCode(generatedCode);
+ } else {
+ this.children.unshift(new CodeNode(generatedCode));
+ }
+ } else if(generatedCode.getMappings && generatedCode.getGeneratedCode) {
+ this.children.unshift(generatedCode);
+ } else if(generatedCode.children) {
+ generatedCode.children.slice().reverse().forEach(function(sln) {
+ this.children.unshift(sln);
+ }, this);
+ } else {
+ throw new Error("Invalid arguments to SourceListMap.prototype.prerend: Expected string, Node or SourceListMap");
+ }
+};
+
+SourceListMap.prototype.mapGeneratedCode = function(fn) {
+ var normalizedNodes = [];
+ this.children.forEach(function(sln) {
+ sln.getNormalizedNodes().forEach(function(newNode) {
+ normalizedNodes.push(newNode);
+ });
+ });
+ var optimizedNodes = [];
+ normalizedNodes.forEach(function(sln) {
+ sln = sln.mapGeneratedCode(fn);
+ if(optimizedNodes.length === 0) {
+ optimizedNodes.push(sln);
+ } else {
+ var last = optimizedNodes[optimizedNodes.length - 1];
+ var mergedNode = last.merge(sln);
+ if(mergedNode) {
+ optimizedNodes[optimizedNodes.length - 1] = mergedNode;
+ } else {
+ optimizedNodes.push(sln);
+ }
+ }
+ });
+ return new SourceListMap(optimizedNodes);
+};
+
+SourceListMap.prototype.toString = function() {
+ return this.children.map(function(sln) {
+ return sln.getGeneratedCode();
+ }).join("");
+};
+
+SourceListMap.prototype.toStringWithSourceMap = function(options) {
+ var mappingsContext = new MappingsContext();
+ var source = this.children.map(function(sln) {
+ return sln.getGeneratedCode();
+ }).join("");
+ var mappings = this.children.map(function(sln) {
+ return sln.getMappings(mappingsContext);
+ }).join("");
+ return {
+ source: source,
+ map: {
+ version: 3,
+ file: options && options.file,
+ sources: mappingsContext.sources,
+ sourcesContent: mappingsContext.hasSourceContent ? mappingsContext.sourcesContent : undefined,
+ mappings: mappings
+ }
+ };
+}
diff --git a/node_modules/source-list-map/lib/SourceNode.js b/node_modules/source-list-map/lib/SourceNode.js new file mode 100644 index 000000000..451d3cd10 --- /dev/null +++ b/node_modules/source-list-map/lib/SourceNode.js @@ -0,0 +1,124 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+module.exports = SourceNode; // circular dependency
+
+var base64VLQ = require("./base64-vlq");
+var getNumberOfLines = require("./helpers").getNumberOfLines;
+var getUnfinishedLine = require("./helpers").getUnfinishedLine;
+var SingleLineNode = require("./SingleLineNode");
+
+function SourceNode(generatedCode, source, originalSource, startingLine) {
+ this.generatedCode = generatedCode;
+ this.originalSource = originalSource;
+ this.source = source;
+ this.startingLine = startingLine || 1;
+ this._numberOfLines = getNumberOfLines(this.generatedCode);
+ this._endsWithNewLine = generatedCode[generatedCode.length - 1] === "\n";
+}
+
+SourceNode.prototype.clone = function() {
+ return new SourceNode(this.generatedCode, this.source, this.originalSource, this.startingLine);
+}
+
+var LINE_MAPPING = ";AACA";
+
+SourceNode.prototype.getGeneratedCode = function() {
+ return this.generatedCode;
+};
+
+SourceNode.prototype.addGeneratedCode = function(code) {
+ this.generatedCode += code;
+ this._numberOfLines += getNumberOfLines(code);
+ this._endsWithNewLine = code[code.length - 1] === "\n";
+};
+
+SourceNode.prototype.getMappings = function(mappingsContext) {
+ if(!this.generatedCode)
+ return "";
+ var lines = this._numberOfLines;
+ var sourceIdx = mappingsContext.ensureSource(this.source, this.originalSource);
+ var mappings = "A"; // generated column 0
+ if(mappingsContext.unfinishedGeneratedLine)
+ mappings = "," + base64VLQ.encode(mappingsContext.unfinishedGeneratedLine);
+ mappings += base64VLQ.encode(sourceIdx - mappingsContext.currentSource); // source index
+ mappings += base64VLQ.encode(this.startingLine - mappingsContext.currentOriginalLine); // original line index
+ mappings += "A"; // original column 0
+ mappingsContext.currentSource = sourceIdx;
+ mappingsContext.currentOriginalLine = this.startingLine + lines - 1;
+ var unfinishedGeneratedLine = mappingsContext.unfinishedGeneratedLine = getUnfinishedLine(this.generatedCode)
+ mappings += Array(lines).join(LINE_MAPPING);
+ if(unfinishedGeneratedLine === 0) {
+ mappings += ";";
+ } else {
+ if(lines !== 0) {
+ mappings += LINE_MAPPING;
+ mappingsContext.currentOriginalLine++;
+ }
+ }
+ return mappings;
+};
+
+SourceNode.prototype.mapGeneratedCode = function(fn) {
+ throw new Error("Cannot map generated code on a SourceMap. Normalize to SingleLineNode first.");
+};
+
+SourceNode.prototype.getNormalizedNodes = function() {
+ var results = [];
+ var currentLine = this.startingLine;
+ var generatedCode = this.generatedCode;
+ var index = 0;
+ var indexEnd = generatedCode.length;
+ while(index < indexEnd) {
+ // get one generated line
+ var nextLine = generatedCode.indexOf("\n", index) + 1;
+ if(nextLine === 0) nextLine = indexEnd;
+ var lineGenerated = generatedCode.substr(index, nextLine - index);
+
+ results.push(new SingleLineNode(lineGenerated, this.source, this.originalSource, currentLine));
+
+ // move cursors
+ index = nextLine;
+ currentLine++;
+ }
+ return results;
+};
+
+SourceNode.prototype.merge = function merge(otherNode) {
+ if(otherNode instanceof SourceNode) {
+ return this.mergeSourceNode(otherNode);
+ } else if(otherNode instanceof SingleLineNode) {
+ return this.mergeSingleLineNode(otherNode);
+ }
+ return false;
+};
+
+SourceNode.prototype.mergeSourceNode = function mergeSourceNode(otherNode) {
+ if(this.source === otherNode.source &&
+ this._endsWithNewLine &&
+ this.startingLine + this._numberOfLines === otherNode.startingLine) {
+ this.generatedCode += otherNode.generatedCode;
+ this._numberOfLines += otherNode._numberOfLines;
+ this._endsWithNewLine = otherNode._endsWithNewLine;
+ return this;
+ }
+ return false;
+};
+
+SourceNode.prototype.mergeSingleLineNode = function mergeSingleLineNode(otherNode) {
+ if(this.source === otherNode.source &&
+ this._endsWithNewLine &&
+ this.startingLine + this._numberOfLines === otherNode.line &&
+ otherNode._numberOfLines <= 1) {
+ this.addSingleLineNode(otherNode);
+ return this;
+ }
+ return false;
+};
+
+SourceNode.prototype.addSingleLineNode = function addSingleLineNode(otherNode) {
+ this.generatedCode += otherNode.generatedCode;
+ this._numberOfLines += otherNode._numberOfLines
+ this._endsWithNewLine = otherNode._endsWithNewLine;
+};
diff --git a/node_modules/source-list-map/lib/base64-vlq.js b/node_modules/source-list-map/lib/base64-vlq.js new file mode 100644 index 000000000..b16ec8c5f --- /dev/null +++ b/node_modules/source-list-map/lib/base64-vlq.js @@ -0,0 +1,169 @@ +/* -*- Mode: js; js-indent-level: 2; -*- */
+/*
+ * Copyright 2011 Mozilla Foundation and contributors
+ * Licensed under the New BSD license. See LICENSE or:
+ * http://opensource.org/licenses/BSD-3-Clause
+ *
+ * Based on the Base 64 VLQ implementation in Closure Compiler:
+ * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
+ *
+ * Copyright 2011 The Closure Compiler Authors. All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*eslint no-bitwise:0,quotes:0,global-strict:0*/
+
+var charToIntMap = {};
+var intToCharMap = {};
+
+'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
+ .split('')
+ .forEach(function (ch, index) {
+ charToIntMap[ch] = index;
+ intToCharMap[index] = ch;
+ });
+
+var base64 = {};
+/**
+ * Encode an integer in the range of 0 to 63 to a single base 64 digit.
+ */
+base64.encode = function base64_encode(aNumber) {
+ if (aNumber in intToCharMap) {
+ return intToCharMap[aNumber];
+ }
+ throw new TypeError("Must be between 0 and 63: " + aNumber);
+};
+
+/**
+ * Decode a single base 64 digit to an integer.
+ */
+base64.decode = function base64_decode(aChar) {
+ if (aChar in charToIntMap) {
+ return charToIntMap[aChar];
+ }
+ throw new TypeError("Not a valid base 64 digit: " + aChar);
+};
+
+
+
+// A single base 64 digit can contain 6 bits of data. For the base 64 variable
+// length quantities we use in the source map spec, the first bit is the sign,
+// the next four bits are the actual value, and the 6th bit is the
+// continuation bit. The continuation bit tells us whether there are more
+// digits in this value following this digit.
+//
+// Continuation
+// | Sign
+// | |
+// V V
+// 101011
+
+var VLQ_BASE_SHIFT = 5;
+
+// binary: 100000
+var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
+
+// binary: 011111
+var VLQ_BASE_MASK = VLQ_BASE - 1;
+
+// binary: 100000
+var VLQ_CONTINUATION_BIT = VLQ_BASE;
+
+/**
+ * Converts from a two-complement value to a value where the sign bit is
+ * placed in the least significant bit. For example, as decimals:
+ * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
+ * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
+ */
+function toVLQSigned(aValue) {
+ return aValue < 0
+ ? ((-aValue) << 1) + 1
+ : (aValue << 1) + 0;
+}
+
+/**
+ * Converts to a two-complement value from a value where the sign bit is
+ * placed in the least significant bit. For example, as decimals:
+ * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
+ * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
+ */
+function fromVLQSigned(aValue) {
+ var isNegative = (aValue & 1) === 1;
+ var shifted = aValue >> 1;
+ return isNegative
+ ? -shifted
+ : shifted;
+}
+
+/**
+ * Returns the base 64 VLQ encoded value.
+ */
+exports.encode = function base64VLQ_encode(aValue) {
+ var encoded = "";
+ var digit;
+
+ var vlq = toVLQSigned(aValue);
+
+ do {
+ digit = vlq & VLQ_BASE_MASK;
+ vlq >>>= VLQ_BASE_SHIFT;
+ if (vlq > 0) {
+ // There are still more digits in this value, so we must make sure the
+ // continuation bit is marked.
+ digit |= VLQ_CONTINUATION_BIT;
+ }
+ encoded += base64.encode(digit);
+ } while (vlq > 0);
+
+ return encoded;
+};
+
+/**
+ * Decodes the next base 64 VLQ value from the given string and returns the
+ * value and the rest of the string via the out parameter.
+ */
+exports.decode = function base64VLQ_decode(aStr, aOutParam) {
+ var i = 0;
+ var strLen = aStr.length;
+ var result = 0;
+ var shift = 0;
+ var continuation, digit;
+
+ do {
+ if (i >= strLen) {
+ throw new Error("Expected more digits in base 64 VLQ value.");
+ }
+ digit = base64.decode(aStr.charAt(i++));
+ continuation = !!(digit & VLQ_CONTINUATION_BIT);
+ digit &= VLQ_BASE_MASK;
+ result = result + (digit << shift);
+ shift += VLQ_BASE_SHIFT;
+ } while (continuation);
+
+ aOutParam.value = fromVLQSigned(result);
+ aOutParam.rest = aStr.slice(i);
+};
diff --git a/node_modules/source-list-map/lib/fromStringWithSourceMap.js b/node_modules/source-list-map/lib/fromStringWithSourceMap.js new file mode 100644 index 000000000..d6ccf0bc0 --- /dev/null +++ b/node_modules/source-list-map/lib/fromStringWithSourceMap.js @@ -0,0 +1,99 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var base64VLQ = require("./base64-vlq");
+var SourceNode = require("./SourceNode");
+var CodeNode = require("./CodeNode");
+var SourceListMap = require("./SourceListMap");
+
+module.exports = function fromStringWithSourceMap(code, map) {
+ var sources = map.sources;
+ var sourcesContent = map.sourcesContent;
+ var mappings = map.mappings.split(";");
+ var lines = code.split("\n");
+ var nodes = [];
+ var currentNode = null;
+ var currentLine = 1;
+ var currentSourceIdx = 0;
+ var currentSourceNodeLine;
+ mappings.forEach(function(mapping, idx) {
+ var line = lines[idx];
+ if(typeof line === 'undefined') return;
+ if(idx !== lines.length - 1) line += "\n";
+ if(!mapping)
+ return addCode(line);
+ mapping = { value: 0, rest: mapping };
+ var lineAdded = false;
+ while(mapping.rest)
+ lineAdded = processMapping(mapping, line, lineAdded) || lineAdded;
+ if(!lineAdded)
+ addCode(line);
+ });
+ if(mappings.length < lines.length) {
+ var idx = mappings.length;
+ while(!lines[idx].trim() && idx < lines.length-1) {
+ addCode(lines[idx] + "\n");
+ idx++;
+ }
+ addCode(lines.slice(idx).join("\n"));
+ }
+ return new SourceListMap(nodes);
+ function processMapping(mapping, line, ignore) {
+ if(mapping.rest && mapping.rest[0] !== ",") {
+ base64VLQ.decode(mapping.rest, mapping);
+ }
+ if(!mapping.rest)
+ return false;
+ if(mapping.rest[0] === ",") {
+ mapping.rest = mapping.rest.substr(1);
+ return false;
+ }
+
+ base64VLQ.decode(mapping.rest, mapping);
+ var sourceIdx = mapping.value + currentSourceIdx;
+ currentSourceIdx = sourceIdx;
+
+ if(mapping.rest && mapping.rest[0] !== ",") {
+ base64VLQ.decode(mapping.rest, mapping);
+ var linePosition = mapping.value + currentLine;
+ currentLine = linePosition;
+ } else {
+ var linePosition = currentLine;
+ }
+
+ if(mapping.rest) {
+ var next = mapping.rest.indexOf(",");
+ mapping.rest = next === -1 ? "" : mapping.rest.substr(next);
+ }
+
+ if(!ignore) {
+ addSource(line, sources ? sources[sourceIdx] : null, sourcesContent ? sourcesContent[sourceIdx] : null, linePosition)
+ return true;
+ }
+ }
+ function addCode(generatedCode) {
+ if(currentNode && currentNode instanceof CodeNode) {
+ currentNode.addGeneratedCode(generatedCode);
+ } else if(currentNode && currentNode instanceof SourceNode && !generatedCode.trim()) {
+ currentNode.addGeneratedCode(generatedCode);
+ currentSourceNodeLine++;
+ } else {
+ currentNode = new CodeNode(generatedCode);
+ nodes.push(currentNode);
+ }
+ }
+ function addSource(generatedCode, source, originalSource, linePosition) {
+ if(currentNode && currentNode instanceof SourceNode &&
+ currentNode.source === source &&
+ currentSourceNodeLine === linePosition
+ ) {
+ currentNode.addGeneratedCode(generatedCode);
+ currentSourceNodeLine++;
+ } else {
+ currentNode = new SourceNode(generatedCode, source, originalSource, linePosition);
+ currentSourceNodeLine = linePosition + 1;
+ nodes.push(currentNode);
+ }
+ }
+};
diff --git a/node_modules/source-list-map/lib/helpers.js b/node_modules/source-list-map/lib/helpers.js new file mode 100644 index 000000000..71fc3c167 --- /dev/null +++ b/node_modules/source-list-map/lib/helpers.js @@ -0,0 +1,21 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+exports.getNumberOfLines = function getNumberOfLines(str) {
+ var nr = -1;
+ var idx = -1;
+ do {
+ nr++
+ idx = str.indexOf("\n", idx + 1);
+ } while(idx >= 0);
+ return nr;
+};
+
+exports.getUnfinishedLine = function getUnfinishedLine(str) {
+ var idx = str.lastIndexOf("\n");
+ if(idx === -1)
+ return str.length;
+ else
+ return str.length - idx - 1;
+};
diff --git a/node_modules/source-list-map/lib/index.js b/node_modules/source-list-map/lib/index.js new file mode 100644 index 000000000..7828f52d1 --- /dev/null +++ b/node_modules/source-list-map/lib/index.js @@ -0,0 +1,5 @@ +exports.SourceListMap = require("./SourceListMap");
+exports.SourceNode = require("./SourceNode");
+exports.CodeNode = require("./CodeNode");
+exports.MappingsContext = require("./MappingsContext");
+exports.fromStringWithSourceMap = require("./fromStringWithSourceMap");
|