aboutsummaryrefslogtreecommitdiff
path: root/node_modules/source-list-map
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/source-list-map
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
downloadwallet-core-363723fc84f7b8477592e0105aeb331ec9a017af.tar.xz
node_modules
Diffstat (limited to 'node_modules/source-list-map')
-rw-r--r--node_modules/source-list-map/lib/CodeNode.js97
-rw-r--r--node_modules/source-list-map/lib/MappingsContext.js58
-rw-r--r--node_modules/source-list-map/lib/SingleLineNode.js144
-rw-r--r--node_modules/source-list-map/lib/SourceListMap.js187
-rw-r--r--node_modules/source-list-map/lib/SourceNode.js225
-rw-r--r--node_modules/source-list-map/lib/fromStringWithSourceMap.js43
-rw-r--r--node_modules/source-list-map/lib/helpers.js8
-rw-r--r--node_modules/source-list-map/lib/index.js1
-rw-r--r--node_modules/source-list-map/package.json2
9 files changed, 407 insertions, 358 deletions
diff --git a/node_modules/source-list-map/lib/CodeNode.js b/node_modules/source-list-map/lib/CodeNode.js
index bfbbdf3ab..dc872dee3 100644
--- a/node_modules/source-list-map/lib/CodeNode.js
+++ b/node_modules/source-list-map/lib/CodeNode.js
@@ -2,60 +2,65 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var getNumberOfLines = require("./helpers").getNumberOfLines;
-var getUnfinishedLine = require("./helpers").getUnfinishedLine;
+"use strict";
-function CodeNode(generatedCode) {
- this.generatedCode = generatedCode;
-}
-module.exports = CodeNode;
+const getNumberOfLines = require("./helpers").getNumberOfLines;
+const getUnfinishedLine = require("./helpers").getUnfinishedLine;
-CodeNode.prototype.clone = function() {
- return new CodeNode(this.generatedCode);
-}
+class CodeNode {
+ constructor(generatedCode) {
+ this.generatedCode = 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";
+ clone() {
+ return new CodeNode(this.generatedCode);
+ }
+
+ getGeneratedCode() {
+ return this.generatedCode;
+ }
+
+ getMappings(mappingsContext) {
+ const lines = getNumberOfLines(this.generatedCode);
+ const mapping = Array(lines+1).join(";");
+ if(lines > 0) {
+ mappingsContext.unfinishedGeneratedLine = getUnfinishedLine(this.generatedCode);
+ if(mappingsContext.unfinishedGeneratedLine > 0) {
+ return mapping + "A";
+ } else {
+ return mapping;
+ }
} else {
- return "";
+ const 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;
-};
+ addGeneratedCode(generatedCode) {
+ this.generatedCode += generatedCode;
+ }
-CodeNode.prototype.mapGeneratedCode = function(fn) {
- var generatedCode = fn(this.generatedCode);
- return new CodeNode(generatedCode);
-};
+ mapGeneratedCode(fn) {
+ const generatedCode = fn(this.generatedCode);
+ return new CodeNode(generatedCode);
+ }
-CodeNode.prototype.getNormalizedNodes = function() {
- return [this];
-};
+ getNormalizedNodes() {
+ return [this];
+ }
-CodeNode.prototype.merge = function merge(otherNode) {
- if(otherNode instanceof CodeNode) {
- this.generatedCode += otherNode.generatedCode;
- return this;
+ merge(otherNode) {
+ if(otherNode instanceof CodeNode) {
+ this.generatedCode += otherNode.generatedCode;
+ return this;
+ }
+ return false;
}
- return false;
-};
+}
+
+module.exports = CodeNode;
diff --git a/node_modules/source-list-map/lib/MappingsContext.js b/node_modules/source-list-map/lib/MappingsContext.js
index 5d2b3b1a6..2d51f6702 100644
--- a/node_modules/source-list-map/lib/MappingsContext.js
+++ b/node_modules/source-list-map/lib/MappingsContext.js
@@ -2,24 +2,44 @@
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;
+"use strict";
-MappingsContext.prototype.ensureSource = function(source, originalSource) {
- var idx = this.sources.indexOf(source);
- if(idx >= 0)
+class MappingsContext {
+ constructor() {
+ this.sourcesIndices = new Map();
+ this.sourcesContent = new Map();
+ this.hasSourceContent = false;
+ this.currentOriginalLine = 1;
+ this.currentSource = 0;
+ this.unfinishedGeneratedLine = false;
+ }
+
+ ensureSource(source, originalSource) {
+ let idx = this.sourcesIndices.get(source);
+ if(typeof idx === "number") {
+ return idx;
+ }
+ idx = this.sourcesIndices.size;
+ this.sourcesIndices.set(source, idx);
+ this.sourcesContent.set(source, originalSource)
+ if(typeof originalSource === "string")
+ this.hasSourceContent = true;
return idx;
- idx = this.sources.length;
- this.sources.push(source);
- this.sourcesContent.push(originalSource);
- if(typeof originalSource === "string")
- this.hasSourceContent = true;
- return idx;
-};
+ }
+
+ getArrays() {
+ const sources = [];
+ const sourcesContent = [];
+
+ for(const pair of this.sourcesContent) {
+ sources.push(pair[0]);
+ sourcesContent.push(pair[1]);
+ }
+
+ return {
+ sources,
+ sourcesContent
+ };
+ }
+}
+module.exports = MappingsContext;
diff --git a/node_modules/source-list-map/lib/SingleLineNode.js b/node_modules/source-list-map/lib/SingleLineNode.js
index a8b7e4ec6..5c1969463 100644
--- a/node_modules/source-list-map/lib/SingleLineNode.js
+++ b/node_modules/source-list-map/lib/SingleLineNode.js
@@ -2,86 +2,92 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-module.exports = SingleLineNode; // circular dependency
+"use strict";
-var base64VLQ = require("./base64-vlq");
-var getNumberOfLines = require("./helpers").getNumberOfLines;
-var getUnfinishedLine = require("./helpers").getUnfinishedLine;
-var SourceNode = require("./SourceNode");
+const base64VLQ = require("./base64-vlq");
+const getNumberOfLines = require("./helpers").getNumberOfLines;
+const getUnfinishedLine = require("./helpers").getUnfinishedLine;
-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";
-}
+const LINE_MAPPING = ";AAAA";
-SingleLineNode.prototype.clone = function() {
- return new SingleLineNode(this.generatedCode, this.source, this.originalSource, this.line);
-}
+class SingleLineNode {
-var LINE_MAPPING = ";AAAA";
+ constructor(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.getGeneratedCode = function() {
- return this.generatedCode;
-};
+ clone() {
+ return new SingleLineNode(this.generatedCode, this.source, this.originalSource, this.line);
+ }
-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;
+ getGeneratedCode() {
+ return this.generatedCode;
}
- return mappings;
-};
-SingleLineNode.prototype.getNormalizedNodes = function() {
- return [this];
-};
+ getMappings(mappingsContext) {
+ if(!this.generatedCode)
+ return "";
+ const lines = this._numberOfLines;
+ const sourceIdx = mappingsContext.ensureSource(this.source, this.originalSource);
+ let 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;
+ const 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.mapGeneratedCode = function(fn) {
- var generatedCode = fn(this.generatedCode);
- return new SingleLineNode(generatedCode, this.source, this.originalSource, this.line);
-};
+ getNormalizedNodes() {
+ return [this];
+ }
-SingleLineNode.prototype.merge = function merge(otherNode) {
- if(otherNode instanceof SingleLineNode) {
- return this.mergeSingleLineNode(otherNode);
+ mapGeneratedCode(fn) {
+ const generatedCode = fn(this.generatedCode);
+ return new SingleLineNode(generatedCode, this.source, this.originalSource, this.line);
}
- 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);
+ merge(otherNode) {
+ if(otherNode instanceof SingleLineNode) {
+ return this.mergeSingleLineNode(otherNode);
}
+ return false;
}
- return false;
-};
+
+ 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;
+ }
+}
+
+module.exports = SingleLineNode;
+
+const SourceNode = require("./SourceNode"); // circular dependency
diff --git a/node_modules/source-list-map/lib/SourceListMap.js b/node_modules/source-list-map/lib/SourceListMap.js
index cb1b8d6f8..6ab8308ce 100644
--- a/node_modules/source-list-map/lib/SourceListMap.js
+++ b/node_modules/source-list-map/lib/SourceListMap.js
@@ -2,109 +2,116 @@
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;
+"use strict";
-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;
+const CodeNode = require("./CodeNode");
+const SourceNode = require("./SourceNode");
+const MappingsContext = require("./MappingsContext");
+const getNumberOfLines = require("./helpers").getNumberOfLines;
+
+class 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);
+ constructor(generatedCode, source, originalSource) {
+ if(Array.isArray(generatedCode)) {
+ this.children = generatedCode;
} else {
- this.children.push(new CodeNode(generatedCode));
+ this.children = [];
+ if(generatedCode || source)
+ this.add(generatedCode, source, originalSource);
}
- } 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);
+ add(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 {
- this.children.unshift(new CodeNode(generatedCode));
+ throw new Error("Invalid arguments to SourceListMap.protfotype.add: Expected string, Node or SourceListMap");
}
- } 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;
+ preprend(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 {
- optimizedNodes.push(sln);
+ 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.protfotype.prerend: Expected string, Node or SourceListMap");
}
- });
- return new SourceListMap(optimizedNodes);
-};
+ };
-SourceListMap.prototype.toString = function() {
- return this.children.map(function(sln) {
- return sln.getGeneratedCode();
- }).join("");
-};
+ mapGeneratedCode(fn) {
+ const normalizedNodes = [];
+ this.children.forEach(function(sln) {
+ sln.getNormalizedNodes().forEach(function(newNode) {
+ normalizedNodes.push(newNode);
+ });
+ });
+ const optimizedNodes = [];
+ normalizedNodes.forEach(function(sln) {
+ sln = sln.mapGeneratedCode(fn);
+ if(optimizedNodes.length === 0) {
+ optimizedNodes.push(sln);
+ } else {
+ const last = optimizedNodes[optimizedNodes.length - 1];
+ const mergedNode = last.merge(sln);
+ if(mergedNode) {
+ optimizedNodes[optimizedNodes.length - 1] = mergedNode;
+ } else {
+ optimizedNodes.push(sln);
+ }
+ }
+ });
+ return new SourceListMap(optimizedNodes);
+ };
-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
- }
+ toString() {
+ return this.children.map(function(sln) {
+ return sln.getGeneratedCode();
+ }).join("");
};
+
+ toStringWithSourceMap(options) {
+ const mappingsContext = new MappingsContext();
+ const source = this.children.map(function(sln) {
+ return sln.getGeneratedCode();
+ }).join("");
+ const mappings = this.children.map(function(sln) {
+ return sln.getMappings(mappingsContext);
+ }).join("");
+ const arrays = mappingsContext.getArrays();
+ return {
+ source: source,
+ map: {
+ version: 3,
+ file: options && options.file,
+ sources: arrays.sources,
+ sourcesContent: mappingsContext.hasSourceContent ? arrays.sourcesContent : undefined,
+ mappings: mappings
+ }
+ };
+ }
}
+
+module.exports = SourceListMap;
diff --git a/node_modules/source-list-map/lib/SourceNode.js b/node_modules/source-list-map/lib/SourceNode.js
index 0939c1e88..b3af0c6e5 100644
--- a/node_modules/source-list-map/lib/SourceNode.js
+++ b/node_modules/source-list-map/lib/SourceNode.js
@@ -2,123 +2,128 @@
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";
-}
+"use strict";
-SourceNode.prototype.clone = function() {
- return new SourceNode(this.generatedCode, this.source, this.originalSource, this.startingLine);
-}
+const base64VLQ = require("./base64-vlq");
+const getNumberOfLines = require("./helpers").getNumberOfLines;
+const getUnfinishedLine = require("./helpers").getUnfinishedLine;
+
+const LINE_MAPPING = ";AACA";
+
+class SourceNode {
+
+ constructor(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";
+ }
+
+ clone() {
+ 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;
+ getGeneratedCode() {
+ return this.generatedCode;
+ }
+
+ addGeneratedCode(code) {
+ this.generatedCode += code;
+ this._numberOfLines += getNumberOfLines(code);
+ this._endsWithNewLine = code[code.length - 1] === "\n";
+ }
+
+ getMappings(mappingsContext) {
+ if(!this.generatedCode)
+ return "";
+ const lines = this._numberOfLines;
+ const sourceIdx = mappingsContext.ensureSource(this.source, this.originalSource);
+ let 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;
+ const 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++;
}
- mappingsContext.currentOriginalLine++;
+ return mappings;
}
- 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++;
+
+ mapGeneratedCode(fn) {
+ throw new Error("Cannot map generated code on a SourceMap. Normalize to SingleLineNode first.");
}
- 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);
+
+ getNormalizedNodes() {
+ 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;
+ }
+
+ merge(otherNode) {
+ if(otherNode instanceof SourceNode) {
+ return this.mergeSourceNode(otherNode);
+ } else if(otherNode instanceof SingleLineNode) {
+ return this.mergeSingleLineNode(otherNode);
+ }
+ return false;
+ }
+
+ 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;
+ }
+
+ 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;
}
- return false;
-};
-SourceNode.prototype.mergeSourceNode = function mergeSourceNode(otherNode) {
- if(this.source === otherNode.source &&
- this._endsWithNewLine &&
- this.startingLine + this._numberOfLines === otherNode.startingLine) {
+ addSingleLineNode(otherNode) {
this.generatedCode += otherNode.generatedCode;
- this._numberOfLines += otherNode._numberOfLines;
+ 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;
-};
+}
+
+module.exports = SourceNode;
+const SingleLineNode = require("./SingleLineNode"); // circular dependency
diff --git a/node_modules/source-list-map/lib/fromStringWithSourceMap.js b/node_modules/source-list-map/lib/fromStringWithSourceMap.js
index d6ccf0bc0..8150fcdd5 100644
--- a/node_modules/source-list-map/lib/fromStringWithSourceMap.js
+++ b/node_modules/source-list-map/lib/fromStringWithSourceMap.js
@@ -2,36 +2,38 @@
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");
+"use strict";
+
+const base64VLQ = require("./base64-vlq");
+const SourceNode = require("./SourceNode");
+const CodeNode = require("./CodeNode");
+const 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;
+ const sources = map.sources;
+ const sourcesContent = map.sourcesContent;
+ const mappings = map.mappings.split(";");
+ const lines = code.split("\n");
+ const nodes = [];
+ let currentNode = null;
+ let currentLine = 1;
+ let currentSourceIdx = 0;
+ let currentSourceNodeLine;
mappings.forEach(function(mapping, idx) {
- var line = lines[idx];
+ let 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;
+ let lineAdded = false;
while(mapping.rest)
lineAdded = processMapping(mapping, line, lineAdded) || lineAdded;
if(!lineAdded)
addCode(line);
});
if(mappings.length < lines.length) {
- var idx = mappings.length;
+ let idx = mappings.length;
while(!lines[idx].trim() && idx < lines.length-1) {
addCode(lines[idx] + "\n");
idx++;
@@ -51,19 +53,20 @@ module.exports = function fromStringWithSourceMap(code, map) {
}
base64VLQ.decode(mapping.rest, mapping);
- var sourceIdx = mapping.value + currentSourceIdx;
+ const sourceIdx = mapping.value + currentSourceIdx;
currentSourceIdx = sourceIdx;
+ let linePosition;
if(mapping.rest && mapping.rest[0] !== ",") {
base64VLQ.decode(mapping.rest, mapping);
- var linePosition = mapping.value + currentLine;
+ linePosition = mapping.value + currentLine;
currentLine = linePosition;
} else {
- var linePosition = currentLine;
+ linePosition = currentLine;
}
if(mapping.rest) {
- var next = mapping.rest.indexOf(",");
+ const next = mapping.rest.indexOf(",");
mapping.rest = next === -1 ? "" : mapping.rest.substr(next);
}
diff --git a/node_modules/source-list-map/lib/helpers.js b/node_modules/source-list-map/lib/helpers.js
index 71fc3c167..e7ca4ec3d 100644
--- a/node_modules/source-list-map/lib/helpers.js
+++ b/node_modules/source-list-map/lib/helpers.js
@@ -2,9 +2,11 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
+"use strict";
+
exports.getNumberOfLines = function getNumberOfLines(str) {
- var nr = -1;
- var idx = -1;
+ let nr = -1;
+ let idx = -1;
do {
nr++
idx = str.indexOf("\n", idx + 1);
@@ -13,7 +15,7 @@ exports.getNumberOfLines = function getNumberOfLines(str) {
};
exports.getUnfinishedLine = function getUnfinishedLine(str) {
- var idx = str.lastIndexOf("\n");
+ const idx = str.lastIndexOf("\n");
if(idx === -1)
return str.length;
else
diff --git a/node_modules/source-list-map/lib/index.js b/node_modules/source-list-map/lib/index.js
index 7828f52d1..c2c52b0ed 100644
--- a/node_modules/source-list-map/lib/index.js
+++ b/node_modules/source-list-map/lib/index.js
@@ -1,5 +1,6 @@
exports.SourceListMap = require("./SourceListMap");
exports.SourceNode = require("./SourceNode");
+exports.SingleLineNode = require("./SingleLineNode");
exports.CodeNode = require("./CodeNode");
exports.MappingsContext = require("./MappingsContext");
exports.fromStringWithSourceMap = require("./fromStringWithSourceMap");
diff --git a/node_modules/source-list-map/package.json b/node_modules/source-list-map/package.json
index fb113c373..8046e8e06 100644
--- a/node_modules/source-list-map/package.json
+++ b/node_modules/source-list-map/package.json
@@ -1,6 +1,6 @@
{
"name": "source-list-map",
- "version": "1.1.2",
+ "version": "2.0.0",
"description": "Fast line to line SourceMap generator.",
"author": "Tobias Koppers @sokra",
"main": "lib/index.js",