Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
136
node_modules/loader-utils/lib/getHashDigest.js
generated
vendored
Normal file
136
node_modules/loader-utils/lib/getHashDigest.js
generated
vendored
Normal file
|
@ -0,0 +1,136 @@
|
|||
"use strict";
|
||||
|
||||
const baseEncodeTables = {
|
||||
26: "abcdefghijklmnopqrstuvwxyz",
|
||||
32: "123456789abcdefghjkmnpqrstuvwxyz", // no 0lio
|
||||
36: "0123456789abcdefghijklmnopqrstuvwxyz",
|
||||
49: "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ", // no lIO
|
||||
52: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
58: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ", // no 0lIO
|
||||
62: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
64: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_",
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Uint32Array} uint32Array Treated as a long base-0x100000000 number, little endian
|
||||
* @param {number} divisor The divisor
|
||||
* @return {number} Modulo (remainder) of the division
|
||||
*/
|
||||
function divmod32(uint32Array, divisor) {
|
||||
let carry = 0;
|
||||
for (let i = uint32Array.length - 1; i >= 0; i--) {
|
||||
const value = carry * 0x100000000 + uint32Array[i];
|
||||
carry = value % divisor;
|
||||
uint32Array[i] = Math.floor(value / divisor);
|
||||
}
|
||||
return carry;
|
||||
}
|
||||
|
||||
function encodeBufferToBase(buffer, base, length) {
|
||||
const encodeTable = baseEncodeTables[base];
|
||||
|
||||
if (!encodeTable) {
|
||||
throw new Error("Unknown encoding base" + base);
|
||||
}
|
||||
|
||||
// Input bits are only enough to generate this many characters
|
||||
const limit = Math.ceil((buffer.length * 8) / Math.log2(base));
|
||||
length = Math.min(length, limit);
|
||||
|
||||
// Most of the crypto digests (if not all) has length a multiple of 4 bytes.
|
||||
// Fewer numbers in the array means faster math.
|
||||
const uint32Array = new Uint32Array(Math.ceil(buffer.length / 4));
|
||||
|
||||
// Make sure the input buffer data is copied and is not mutated by reference.
|
||||
// divmod32() would corrupt the BulkUpdateDecorator cache otherwise.
|
||||
buffer.copy(Buffer.from(uint32Array.buffer));
|
||||
|
||||
let output = "";
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
output = encodeTable[divmod32(uint32Array, base)] + output;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
let crypto = undefined;
|
||||
let createXXHash64 = undefined;
|
||||
let createMd4 = undefined;
|
||||
let BatchedHash = undefined;
|
||||
let BulkUpdateDecorator = undefined;
|
||||
|
||||
function getHashDigest(buffer, algorithm, digestType, maxLength) {
|
||||
algorithm = algorithm || "xxhash64";
|
||||
maxLength = maxLength || 9999;
|
||||
|
||||
let hash;
|
||||
|
||||
if (algorithm === "xxhash64") {
|
||||
if (createXXHash64 === undefined) {
|
||||
createXXHash64 = require("./hash/xxhash64");
|
||||
|
||||
if (BatchedHash === undefined) {
|
||||
BatchedHash = require("./hash/BatchedHash");
|
||||
}
|
||||
}
|
||||
|
||||
hash = new BatchedHash(createXXHash64());
|
||||
} else if (algorithm === "md4") {
|
||||
if (createMd4 === undefined) {
|
||||
createMd4 = require("./hash/md4");
|
||||
|
||||
if (BatchedHash === undefined) {
|
||||
BatchedHash = require("./hash/BatchedHash");
|
||||
}
|
||||
}
|
||||
|
||||
hash = new BatchedHash(createMd4());
|
||||
} else if (algorithm === "native-md4") {
|
||||
if (typeof crypto === "undefined") {
|
||||
crypto = require("crypto");
|
||||
|
||||
if (BulkUpdateDecorator === undefined) {
|
||||
BulkUpdateDecorator = require("./hash/BulkUpdateDecorator");
|
||||
}
|
||||
}
|
||||
|
||||
hash = new BulkUpdateDecorator(() => crypto.createHash("md4"), "md4");
|
||||
} else {
|
||||
if (typeof crypto === "undefined") {
|
||||
crypto = require("crypto");
|
||||
|
||||
if (BulkUpdateDecorator === undefined) {
|
||||
BulkUpdateDecorator = require("./hash/BulkUpdateDecorator");
|
||||
}
|
||||
}
|
||||
|
||||
hash = new BulkUpdateDecorator(
|
||||
() => crypto.createHash(algorithm),
|
||||
algorithm
|
||||
);
|
||||
}
|
||||
|
||||
hash.update(buffer);
|
||||
|
||||
if (
|
||||
digestType === "base26" ||
|
||||
digestType === "base32" ||
|
||||
digestType === "base36" ||
|
||||
digestType === "base49" ||
|
||||
digestType === "base52" ||
|
||||
digestType === "base58" ||
|
||||
digestType === "base62" ||
|
||||
digestType === "base64safe"
|
||||
) {
|
||||
return encodeBufferToBase(
|
||||
hash.digest(),
|
||||
digestType === "base64safe" ? 64 : digestType.substr(4),
|
||||
maxLength
|
||||
);
|
||||
}
|
||||
|
||||
return hash.digest(digestType || "hex").substr(0, maxLength);
|
||||
}
|
||||
|
||||
module.exports = getHashDigest;
|
11
node_modules/loader-utils/lib/index.js
generated
vendored
Normal file
11
node_modules/loader-utils/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
const isUrlRequest = require("./isUrlRequest");
|
||||
const urlToRequest = require("./urlToRequest");
|
||||
const getHashDigest = require("./getHashDigest");
|
||||
const interpolateName = require("./interpolateName");
|
||||
|
||||
exports.urlToRequest = urlToRequest;
|
||||
exports.getHashDigest = getHashDigest;
|
||||
exports.interpolateName = interpolateName;
|
||||
exports.isUrlRequest = isUrlRequest;
|
117
node_modules/loader-utils/lib/interpolateName.js
generated
vendored
Normal file
117
node_modules/loader-utils/lib/interpolateName.js
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
"use strict";
|
||||
|
||||
const path = require("path");
|
||||
const getHashDigest = require("./getHashDigest");
|
||||
|
||||
function interpolateName(loaderContext, name, options = {}) {
|
||||
let filename;
|
||||
|
||||
const hasQuery =
|
||||
loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1;
|
||||
|
||||
if (typeof name === "function") {
|
||||
filename = name(
|
||||
loaderContext.resourcePath,
|
||||
hasQuery ? loaderContext.resourceQuery : undefined
|
||||
);
|
||||
} else {
|
||||
filename = name || "[hash].[ext]";
|
||||
}
|
||||
|
||||
const context = options.context;
|
||||
const content = options.content;
|
||||
const regExp = options.regExp;
|
||||
|
||||
let ext = "bin";
|
||||
let basename = "file";
|
||||
let directory = "";
|
||||
let folder = "";
|
||||
let query = "";
|
||||
|
||||
if (loaderContext.resourcePath) {
|
||||
const parsed = path.parse(loaderContext.resourcePath);
|
||||
let resourcePath = loaderContext.resourcePath;
|
||||
|
||||
if (parsed.ext) {
|
||||
ext = parsed.ext.substr(1);
|
||||
}
|
||||
|
||||
if (parsed.dir) {
|
||||
basename = parsed.name;
|
||||
resourcePath = parsed.dir + path.sep;
|
||||
}
|
||||
|
||||
if (typeof context !== "undefined") {
|
||||
directory = path
|
||||
.relative(context, resourcePath + "_")
|
||||
.replace(/\\/g, "/")
|
||||
.replace(/\.\.(\/)?/g, "_$1");
|
||||
directory = directory.substr(0, directory.length - 1);
|
||||
} else {
|
||||
directory = resourcePath.replace(/\\/g, "/").replace(/\.\.(\/)?/g, "_$1");
|
||||
}
|
||||
|
||||
if (directory.length <= 1) {
|
||||
directory = "";
|
||||
} else {
|
||||
// directory.length > 1
|
||||
folder = path.basename(directory);
|
||||
}
|
||||
}
|
||||
|
||||
if (loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1) {
|
||||
query = loaderContext.resourceQuery;
|
||||
|
||||
const hashIdx = query.indexOf("#");
|
||||
|
||||
if (hashIdx >= 0) {
|
||||
query = query.substr(0, hashIdx);
|
||||
}
|
||||
}
|
||||
|
||||
let url = filename;
|
||||
|
||||
if (content) {
|
||||
// Match hash template
|
||||
url = url
|
||||
// `hash` and `contenthash` are same in `loader-utils` context
|
||||
// let's keep `hash` for backward compatibility
|
||||
.replace(
|
||||
/\[(?:([^[:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*(?:safe)?))?(?::(\d+))?\]/gi,
|
||||
(all, hashType, digestType, maxLength) =>
|
||||
getHashDigest(content, hashType, digestType, parseInt(maxLength, 10))
|
||||
);
|
||||
}
|
||||
|
||||
url = url
|
||||
.replace(/\[ext\]/gi, () => ext)
|
||||
.replace(/\[name\]/gi, () => basename)
|
||||
.replace(/\[path\]/gi, () => directory)
|
||||
.replace(/\[folder\]/gi, () => folder)
|
||||
.replace(/\[query\]/gi, () => query);
|
||||
|
||||
if (regExp && loaderContext.resourcePath) {
|
||||
const match = loaderContext.resourcePath.match(new RegExp(regExp));
|
||||
|
||||
match &&
|
||||
match.forEach((matched, i) => {
|
||||
url = url.replace(new RegExp("\\[" + i + "\\]", "ig"), matched);
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
typeof loaderContext.options === "object" &&
|
||||
typeof loaderContext.options.customInterpolateName === "function"
|
||||
) {
|
||||
url = loaderContext.options.customInterpolateName.call(
|
||||
loaderContext,
|
||||
url,
|
||||
name,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
module.exports = interpolateName;
|
31
node_modules/loader-utils/lib/isUrlRequest.js
generated
vendored
Normal file
31
node_modules/loader-utils/lib/isUrlRequest.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
"use strict";
|
||||
|
||||
const path = require("path");
|
||||
|
||||
function isUrlRequest(url) {
|
||||
// An URL is not an request if
|
||||
|
||||
// 1. Allow `data URI`
|
||||
if (/^data:/i.test(url)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. It's an absolute url and it is not `windows` path like `C:\dir\file`
|
||||
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !path.win32.isAbsolute(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 3. It's a protocol-relative
|
||||
if (/^\/\//.test(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 4. It's some kind of url for a template
|
||||
if (/^#/.test(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = isUrlRequest;
|
60
node_modules/loader-utils/lib/urlToRequest.js
generated
vendored
Normal file
60
node_modules/loader-utils/lib/urlToRequest.js
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
|
||||
// we can't use path.win32.isAbsolute because it also matches paths starting with a forward slash
|
||||
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i;
|
||||
|
||||
function urlToRequest(url, root) {
|
||||
// Do not rewrite an empty url
|
||||
if (url === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
const moduleRequestRegex = /^[^?]*~/;
|
||||
let request;
|
||||
|
||||
if (matchNativeWin32Path.test(url)) {
|
||||
// absolute windows path, keep it
|
||||
request = url;
|
||||
} else if (root !== undefined && root !== false && /^\//.test(url)) {
|
||||
// if root is set and the url is root-relative
|
||||
switch (typeof root) {
|
||||
// 1. root is a string: root is prefixed to the url
|
||||
case "string":
|
||||
// special case: `~` roots convert to module request
|
||||
if (moduleRequestRegex.test(root)) {
|
||||
request = root.replace(/([^~/])$/, "$1/") + url.slice(1);
|
||||
} else {
|
||||
request = root + url;
|
||||
}
|
||||
break;
|
||||
// 2. root is `true`: absolute paths are allowed
|
||||
// *nix only, windows-style absolute paths are always allowed as they doesn't start with a `/`
|
||||
case "boolean":
|
||||
request = url;
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
"Unexpected parameters to loader-utils 'urlToRequest': url = " +
|
||||
url +
|
||||
", root = " +
|
||||
root +
|
||||
"."
|
||||
);
|
||||
}
|
||||
} else if (/^\.\.?\//.test(url)) {
|
||||
// A relative url stays
|
||||
request = url;
|
||||
} else {
|
||||
// every other url is threaded like a relative url
|
||||
request = "./" + url;
|
||||
}
|
||||
|
||||
// A `~` makes the url an module
|
||||
if (moduleRequestRegex.test(request)) {
|
||||
request = request.replace(moduleRequestRegex, "");
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
module.exports = urlToRequest;
|
Loading…
Add table
Add a link
Reference in a new issue