0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

66
web/node_modules/source-list-map/lib/CodeNode.js generated vendored Normal file
View file

@ -0,0 +1,66 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const getNumberOfLines = require("./helpers").getNumberOfLines;
const getUnfinishedLine = require("./helpers").getUnfinishedLine;
class CodeNode {
constructor(generatedCode) {
this.generatedCode = generatedCode;
}
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 {
const prevUnfinished = mappingsContext.unfinishedGeneratedLine;
mappingsContext.unfinishedGeneratedLine += getUnfinishedLine(this.generatedCode);
if(prevUnfinished === 0 && mappingsContext.unfinishedGeneratedLine > 0) {
return "A";
} else {
return "";
}
}
}
addGeneratedCode(generatedCode) {
this.generatedCode += generatedCode;
}
mapGeneratedCode(fn) {
const generatedCode = fn(this.generatedCode);
return new CodeNode(generatedCode);
}
getNormalizedNodes() {
return [this];
}
merge(otherNode) {
if(otherNode instanceof CodeNode) {
this.generatedCode += otherNode.generatedCode;
return this;
}
return false;
}
}
module.exports = CodeNode;

View file

@ -0,0 +1,45 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
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;
}
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;

93
web/node_modules/source-list-map/lib/SingleLineNode.js generated vendored Normal file
View file

@ -0,0 +1,93 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const base64VLQ = require("./base64-vlq");
const getNumberOfLines = require("./helpers").getNumberOfLines;
const getUnfinishedLine = require("./helpers").getUnfinishedLine;
const LINE_MAPPING = ";AAAA";
class SingleLineNode {
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";
}
clone() {
return new SingleLineNode(this.generatedCode, this.source, this.originalSource, this.line);
}
getGeneratedCode() {
return this.generatedCode;
}
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;
}
getNormalizedNodes() {
return [this];
}
mapGeneratedCode(fn) {
const generatedCode = fn(this.generatedCode);
return new SingleLineNode(generatedCode, this.source, this.originalSource, this.line);
}
merge(otherNode) {
if(otherNode instanceof SingleLineNode) {
return this.mergeSingleLineNode(otherNode);
}
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

117
web/node_modules/source-list-map/lib/SourceListMap.js generated vendored Normal file
View file

@ -0,0 +1,117 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const CodeNode = require("./CodeNode");
const SourceNode = require("./SourceNode");
const MappingsContext = require("./MappingsContext");
const getNumberOfLines = require("./helpers").getNumberOfLines;
class SourceListMap {
constructor(generatedCode, source, originalSource) {
if(Array.isArray(generatedCode)) {
this.children = generatedCode;
} else {
this.children = [];
if(generatedCode || source)
this.add(generatedCode, source, originalSource);
}
}
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 {
throw new Error("Invalid arguments to SourceListMap.protfotype.add: Expected string, Node or SourceListMap");
}
};
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 {
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");
}
};
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);
};
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,
map: {
version: 3,
file: options && options.file,
sources: arrays.sources,
sourcesContent: mappingsContext.hasSourceContent ? arrays.sourcesContent : undefined,
mappings: mappings
}
};
}
}
module.exports = SourceListMap;

129
web/node_modules/source-list-map/lib/SourceNode.js generated vendored Normal file
View file

@ -0,0 +1,129 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
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);
}
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++;
}
return mappings;
}
mapGeneratedCode(fn) {
throw new Error("Cannot map generated code on a SourceMap. Normalize to SingleLineNode first.");
}
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;
}
addSingleLineNode(otherNode) {
this.generatedCode += otherNode.generatedCode;
this._numberOfLines += otherNode._numberOfLines
this._endsWithNewLine = otherNode._endsWithNewLine;
}
}
module.exports = SourceNode;
const SingleLineNode = require("./SingleLineNode"); // circular dependency

169
web/node_modules/source-list-map/lib/base64-vlq.js generated vendored Normal file
View file

@ -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);
};

View file

@ -0,0 +1,102 @@
/*
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;
}
}
};

23
web/node_modules/source-list-map/lib/helpers.js generated vendored Normal file
View file

@ -0,0 +1,23 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
exports.getNumberOfLines = function getNumberOfLines(str) {
let nr = -1;
let idx = -1;
do {
nr++
idx = str.indexOf("\n", idx + 1);
} while(idx >= 0);
return nr;
};
exports.getUnfinishedLine = function getUnfinishedLine(str) {
const idx = str.lastIndexOf("\n");
if(idx === -1)
return str.length;
else
return str.length - idx - 1;
};

6
web/node_modules/source-list-map/lib/index.js generated vendored Normal file
View file

@ -0,0 +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");