aboutsummaryrefslogtreecommitdiff
path: root/node_modules/source-list-map/lib/fromStringWithSourceMap.js
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:43:05 +0800
committerruki <waruqi@gmail.com>2018-11-07 22:18:30 +0800
commit89e95b3f143682ed9a006991bacf45c9dcba4818 (patch)
tree4f44cf41b828577d583890bdd5a1c31e8491a6ba /node_modules/source-list-map/lib/fromStringWithSourceMap.js
parentaa7f0199255277949790b41c56e8ec97dd4f0da4 (diff)
downloadxmake-docs-89e95b3f143682ed9a006991bacf45c9dcba4818.tar.gz
xmake-docs-89e95b3f143682ed9a006991bacf45c9dcba4818.zip
remove node_modulesvuepress
Diffstat (limited to 'node_modules/source-list-map/lib/fromStringWithSourceMap.js')
-rw-r--r--node_modules/source-list-map/lib/fromStringWithSourceMap.js102
1 files changed, 0 insertions, 102 deletions
diff --git a/node_modules/source-list-map/lib/fromStringWithSourceMap.js b/node_modules/source-list-map/lib/fromStringWithSourceMap.js
deleted file mode 100644
index 0148d7e9..00000000
--- a/node_modules/source-list-map/lib/fromStringWithSourceMap.js
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
-*/
-"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) {
- 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;
- 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);
- }
- }
- mappings.forEach(function(mapping, 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 };
- let lineAdded = false;
- while(mapping.rest)
- lineAdded = processMapping(mapping, line, lineAdded) || lineAdded;
- if(!lineAdded)
- addCode(line);
- });
- if(mappings.length < lines.length) {
- let 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);
- const sourceIdx = mapping.value + currentSourceIdx;
- currentSourceIdx = sourceIdx;
-
- let linePosition;
- if(mapping.rest && mapping.rest[0] !== ",") {
- base64VLQ.decode(mapping.rest, mapping);
- linePosition = mapping.value + currentLine;
- currentLine = linePosition;
- } else {
- linePosition = currentLine;
- }
-
- if(mapping.rest) {
- const 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;
- }
- }
-};