generated from dellevin/template
1
This commit is contained in:
115
node_modules/webpack/lib/util/hash/BatchedHash.js
generated
vendored
Normal file
115
node_modules/webpack/lib/util/hash/BatchedHash.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Hash = require("../Hash");
|
||||
const { digest, update } = require("./hash-digest");
|
||||
/** @type {number} */
|
||||
const MAX_SHORT_STRING = require("./wasm-hash").MAX_SHORT_STRING;
|
||||
|
||||
/** @typedef {import("../../../declarations/WebpackOptions").HashDigest} Encoding */
|
||||
|
||||
class BatchedHash extends Hash {
|
||||
/**
|
||||
* @param {Hash} hash hash
|
||||
*/
|
||||
constructor(hash) {
|
||||
super();
|
||||
/** @type {undefined | string} */
|
||||
this.string = undefined;
|
||||
/** @type {undefined | Encoding} */
|
||||
this.encoding = undefined;
|
||||
/** @type {Hash} */
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @overload
|
||||
* @param {string | Buffer} data data
|
||||
* @returns {Hash} updated hash
|
||||
*/
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @overload
|
||||
* @param {string} data data
|
||||
* @param {Encoding} inputEncoding data encoding
|
||||
* @returns {Hash} updated hash
|
||||
*/
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @param {string | Buffer} data data
|
||||
* @param {Encoding=} inputEncoding data encoding
|
||||
* @returns {Hash} updated hash
|
||||
*/
|
||||
update(data, inputEncoding) {
|
||||
if (this.string !== undefined) {
|
||||
if (
|
||||
typeof data === "string" &&
|
||||
inputEncoding === this.encoding &&
|
||||
this.string.length + data.length < MAX_SHORT_STRING
|
||||
) {
|
||||
this.string += data;
|
||||
return this;
|
||||
}
|
||||
if (this.encoding) {
|
||||
update(this.hash, this.string, this.encoding);
|
||||
} else {
|
||||
update(this.hash, this.string);
|
||||
}
|
||||
this.string = undefined;
|
||||
}
|
||||
if (typeof data === "string") {
|
||||
if (
|
||||
data.length < MAX_SHORT_STRING &&
|
||||
// base64 encoding is not valid since it may contain padding chars
|
||||
(!inputEncoding || !inputEncoding.startsWith("ba"))
|
||||
) {
|
||||
this.string = data;
|
||||
this.encoding = inputEncoding;
|
||||
} else if (inputEncoding) {
|
||||
update(this.hash, data, inputEncoding);
|
||||
} else {
|
||||
update(this.hash, data);
|
||||
}
|
||||
} else {
|
||||
update(this.hash, data);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @overload
|
||||
* @returns {Buffer} digest
|
||||
*/
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @overload
|
||||
* @param {Encoding} encoding encoding of the return value
|
||||
* @returns {string} digest
|
||||
*/
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @param {Encoding=} encoding encoding of the return value
|
||||
* @returns {string | Buffer} digest
|
||||
*/
|
||||
digest(encoding) {
|
||||
if (this.string !== undefined) {
|
||||
if (this.encoding) {
|
||||
update(this.hash, this.string, this.encoding);
|
||||
} else {
|
||||
update(this.hash, this.string);
|
||||
}
|
||||
}
|
||||
if (!encoding) {
|
||||
return digest(this.hash);
|
||||
}
|
||||
return digest(this.hash, encoding);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BatchedHash;
|
||||
145
node_modules/webpack/lib/util/hash/BulkUpdateHash.js
generated
vendored
Normal file
145
node_modules/webpack/lib/util/hash/BulkUpdateHash.js
generated
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Alexander Akait @alexander-akait
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Hash = require("../Hash");
|
||||
const { digest, update } = require("./hash-digest");
|
||||
|
||||
/** @typedef {import("../../../declarations/WebpackOptions").HashDigest} Encoding */
|
||||
/** @typedef {() => Hash} HashFactory */
|
||||
|
||||
const BULK_SIZE = 3;
|
||||
|
||||
// We are using an object instead of a Map as this will stay static during the runtime
|
||||
// so access to it can be optimized by v8
|
||||
/** @type {{ [key: string]: Map<string, string> }} */
|
||||
const digestCaches = {};
|
||||
|
||||
class BulkUpdateHash extends Hash {
|
||||
/**
|
||||
* @param {Hash | HashFactory} hashOrFactory function to create a hash
|
||||
* @param {string=} hashKey key for caching
|
||||
*/
|
||||
constructor(hashOrFactory, hashKey) {
|
||||
super();
|
||||
/** @type {undefined | string} */
|
||||
this.hashKey = hashKey;
|
||||
if (typeof hashOrFactory === "function") {
|
||||
/** @type {undefined | HashFactory} */
|
||||
this.hashFactory = hashOrFactory;
|
||||
/** @type {undefined | Hash} */
|
||||
this.hash = undefined;
|
||||
} else {
|
||||
/** @type {undefined | HashFactory} */
|
||||
this.hashFactory = undefined;
|
||||
/** @type {undefined | Hash} */
|
||||
this.hash = hashOrFactory;
|
||||
}
|
||||
/** @type {string} */
|
||||
this.buffer = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @overload
|
||||
* @param {string | Buffer} data data
|
||||
* @returns {Hash} updated hash
|
||||
*/
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @overload
|
||||
* @param {string} data data
|
||||
* @param {Encoding} inputEncoding data encoding
|
||||
* @returns {Hash} updated hash
|
||||
*/
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @param {string | Buffer} data data
|
||||
* @param {Encoding=} inputEncoding data encoding
|
||||
* @returns {Hash} updated hash
|
||||
*/
|
||||
update(data, inputEncoding) {
|
||||
if (
|
||||
inputEncoding !== undefined ||
|
||||
typeof data !== "string" ||
|
||||
data.length > BULK_SIZE
|
||||
) {
|
||||
if (this.hash === undefined) {
|
||||
this.hash = /** @type {HashFactory} */ (this.hashFactory)();
|
||||
}
|
||||
if (this.buffer.length > 0) {
|
||||
update(this.hash, this.buffer);
|
||||
this.buffer = "";
|
||||
}
|
||||
if (typeof data === "string" && inputEncoding) {
|
||||
update(this.hash, data, inputEncoding);
|
||||
} else {
|
||||
update(this.hash, data);
|
||||
}
|
||||
} else {
|
||||
this.buffer += data;
|
||||
if (this.buffer.length > BULK_SIZE) {
|
||||
if (this.hash === undefined) {
|
||||
this.hash = /** @type {HashFactory} */ (this.hashFactory)();
|
||||
}
|
||||
update(this.hash, this.buffer);
|
||||
this.buffer = "";
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @overload
|
||||
* @returns {Buffer} digest
|
||||
*/
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @overload
|
||||
* @param {Encoding} encoding encoding of the return value
|
||||
* @returns {string} digest
|
||||
*/
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @param {Encoding=} encoding encoding of the return value
|
||||
* @returns {string | Buffer} digest
|
||||
*/
|
||||
digest(encoding) {
|
||||
/** @type {undefined | Map<string, string | Buffer>} */
|
||||
let digestCache;
|
||||
const buffer = this.buffer;
|
||||
if (this.hash === undefined) {
|
||||
// short data for hash, we can use caching
|
||||
const cacheKey = `${this.hashKey}-${encoding}`;
|
||||
digestCache = digestCaches[cacheKey];
|
||||
if (digestCache === undefined) {
|
||||
digestCache = digestCaches[cacheKey] = new Map();
|
||||
}
|
||||
const cacheEntry = digestCache.get(buffer);
|
||||
if (cacheEntry !== undefined) return cacheEntry;
|
||||
this.hash = /** @type {HashFactory} */ (this.hashFactory)();
|
||||
}
|
||||
|
||||
if (buffer.length > 0) {
|
||||
update(this.hash, buffer);
|
||||
}
|
||||
if (!encoding) {
|
||||
const result = digest(this.hash, undefined, Boolean(this.hashKey));
|
||||
if (digestCache !== undefined) {
|
||||
digestCache.set(buffer, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
const result = digest(this.hash, encoding, Boolean(this.hashKey));
|
||||
if (digestCache !== undefined) {
|
||||
digestCache.set(buffer, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BulkUpdateHash;
|
||||
75
node_modules/webpack/lib/util/hash/DebugHash.js
generated
vendored
Normal file
75
node_modules/webpack/lib/util/hash/DebugHash.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Alexander Akait @alexander-akait
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Hash = require("../Hash");
|
||||
|
||||
/** @typedef {import("../../../declarations/WebpackOptions").HashDigest} Encoding */
|
||||
|
||||
/* istanbul ignore next */
|
||||
class DebugHash extends Hash {
|
||||
constructor() {
|
||||
super();
|
||||
this.string = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @overload
|
||||
* @param {string | Buffer} data data
|
||||
* @returns {Hash} updated hash
|
||||
*/
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @overload
|
||||
* @param {string} data data
|
||||
* @param {Encoding} inputEncoding data encoding
|
||||
* @returns {Hash} updated hash
|
||||
*/
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @param {string | Buffer} data data
|
||||
* @param {Encoding=} inputEncoding data encoding
|
||||
* @returns {Hash} updated hash
|
||||
*/
|
||||
update(data, inputEncoding) {
|
||||
if (typeof data !== "string") data = data.toString("utf8");
|
||||
const prefix = Buffer.from("@webpack-debug-digest@").toString("hex");
|
||||
if (data.startsWith(prefix)) {
|
||||
data = Buffer.from(data.slice(prefix.length), "hex").toString();
|
||||
}
|
||||
this.string += `[${data}](${
|
||||
/** @type {string} */
|
||||
(
|
||||
// eslint-disable-next-line unicorn/error-message
|
||||
new Error().stack
|
||||
).split("\n", 3)[2]
|
||||
})\n`;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @overload
|
||||
* @returns {Buffer} digest
|
||||
*/
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @overload
|
||||
* @param {Encoding} encoding encoding of the return value
|
||||
* @returns {string} digest
|
||||
*/
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @param {Encoding=} encoding encoding of the return value
|
||||
* @returns {string | Buffer} digest
|
||||
*/
|
||||
digest(encoding) {
|
||||
return Buffer.from(`@webpack-debug-digest@${this.string}`).toString("hex");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DebugHash;
|
||||
217
node_modules/webpack/lib/util/hash/hash-digest.js
generated
vendored
Normal file
217
node_modules/webpack/lib/util/hash/hash-digest.js
generated
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Alexander Akait @alexander-akait
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/** @typedef {import("../Hash")} Hash */
|
||||
/** @typedef {import("../../../declarations/WebpackOptions").HashDigest} Encoding */
|
||||
|
||||
/** @typedef {"26" | "32" | "36" | "49" | "52" | "58" | "62"} Base */
|
||||
|
||||
/* cSpell:disable */
|
||||
|
||||
/** @type {Record<Base, string>} */
|
||||
const ENCODE_TABLE = Object.freeze({
|
||||
26: "abcdefghijklmnopqrstuvwxyz",
|
||||
32: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
|
||||
36: "0123456789abcdefghijklmnopqrstuvwxyz",
|
||||
49: "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",
|
||||
52: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
58: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",
|
||||
62: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
});
|
||||
|
||||
/* cSpell:enable */
|
||||
|
||||
const ZERO = BigInt("0");
|
||||
const EIGHT = BigInt("8");
|
||||
const FF = BigInt("0xff");
|
||||
|
||||
/**
|
||||
* It encodes octet arrays by doing long divisions on all significant digits in the array, creating a representation of that number in the new base.
|
||||
* Then for every leading zero in the input (not significant as a number) it will encode as a single leader character.
|
||||
* This is the first in the alphabet and will decode as 8 bits. The other characters depend upon the base.
|
||||
* For example, a base58 alphabet packs roughly 5.858 bits per character.
|
||||
* This means the encoded string 000f (using a base16, 0-f alphabet) will actually decode to 4 bytes unlike a canonical hex encoding which uniformly packs 4 bits into each character.
|
||||
* While unusual, this does mean that no padding is required, and it works for bases like 43.
|
||||
* @param {Buffer} buffer buffer
|
||||
* @param {Base} base base
|
||||
* @returns {string} encoded buffer
|
||||
*/
|
||||
const encode = (buffer, base) => {
|
||||
if (buffer.length === 0) return "";
|
||||
const bigIntBase = BigInt(ENCODE_TABLE[base].length);
|
||||
// Convert buffer to BigInt efficiently using bitwise operations
|
||||
let value = ZERO;
|
||||
for (let i = 0; i < buffer.length; i++) {
|
||||
value = (value << EIGHT) | BigInt(buffer[i]);
|
||||
}
|
||||
// Convert to baseX string efficiently using array
|
||||
/** @type {string[]} */
|
||||
const digits = [];
|
||||
if (value === ZERO) return ENCODE_TABLE[base][0];
|
||||
while (value > ZERO) {
|
||||
const remainder = Number(value % bigIntBase);
|
||||
digits.push(ENCODE_TABLE[base][remainder]);
|
||||
value /= bigIntBase;
|
||||
}
|
||||
return digits.reverse().join("");
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} data string
|
||||
* @param {Base} base base
|
||||
* @returns {Buffer} buffer
|
||||
*/
|
||||
const decode = (data, base) => {
|
||||
if (data.length === 0) return Buffer.from("");
|
||||
const bigIntBase = BigInt(ENCODE_TABLE[base].length);
|
||||
// Convert the baseX string to a BigInt value
|
||||
let value = ZERO;
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const digit = ENCODE_TABLE[base].indexOf(data[i]);
|
||||
if (digit === -1) {
|
||||
throw new Error(`Invalid character at position ${i}: ${data[i]}`);
|
||||
}
|
||||
value = value * bigIntBase + BigInt(digit);
|
||||
}
|
||||
// If value is 0, return a single-byte buffer with value 0
|
||||
if (value === ZERO) {
|
||||
return Buffer.alloc(1);
|
||||
}
|
||||
// Determine buffer size efficiently by counting bytes
|
||||
let temp = value;
|
||||
let byteLength = 0;
|
||||
while (temp > ZERO) {
|
||||
temp >>= EIGHT;
|
||||
byteLength++;
|
||||
}
|
||||
// Create buffer and fill it from right to left
|
||||
const buffer = Buffer.alloc(byteLength);
|
||||
for (let i = byteLength - 1; i >= 0; i--) {
|
||||
buffer[i] = Number(value & FF);
|
||||
value >>= EIGHT;
|
||||
}
|
||||
return buffer;
|
||||
};
|
||||
|
||||
// Compatibility with the old hash libraries, they can return different structures, so let's stringify them firstly
|
||||
|
||||
/**
|
||||
* @param {string | { toString: (radix: number) => string }} value value
|
||||
* @param {string} encoding encoding
|
||||
* @returns {string} string
|
||||
*/
|
||||
const toString = (value, encoding) =>
|
||||
typeof value === "string"
|
||||
? value
|
||||
: Buffer.from(value.toString(16), "hex").toString(
|
||||
/** @type {NodeJS.BufferEncoding} */
|
||||
(encoding)
|
||||
);
|
||||
|
||||
/**
|
||||
* @param {Buffer | { toString: (radix: number) => string }} value value
|
||||
* @returns {Buffer} buffer
|
||||
*/
|
||||
const toBuffer = (value) =>
|
||||
Buffer.isBuffer(value) ? value : Buffer.from(value.toString(16), "hex");
|
||||
|
||||
let isBase64URLSupported = false;
|
||||
|
||||
try {
|
||||
isBase64URLSupported = Boolean(Buffer.from("", "base64url"));
|
||||
} catch (_err) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Hash} hash hash
|
||||
* @param {string | Buffer} data data
|
||||
* @param {Encoding=} encoding encoding of the return value
|
||||
* @returns {void}
|
||||
*/
|
||||
const update = (hash, data, encoding) => {
|
||||
if (encoding === "base64url" && !isBase64URLSupported) {
|
||||
const base64String = /** @type {string} */ (data)
|
||||
.replace(/-/g, "+")
|
||||
.replace(/_/g, "/");
|
||||
const buf = Buffer.from(base64String, "base64");
|
||||
hash.update(buf);
|
||||
return;
|
||||
} else if (
|
||||
typeof data === "string" &&
|
||||
encoding &&
|
||||
typeof ENCODE_TABLE[/** @type {Base} */ (encoding.slice(4))] !== "undefined"
|
||||
) {
|
||||
const buf = decode(data, /** @type {Base} */ (encoding.slice(4)));
|
||||
hash.update(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (encoding) {
|
||||
hash.update(/** @type {string} */ (data), encoding);
|
||||
} else {
|
||||
hash.update(data);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {Hash} hash hash
|
||||
* @returns {Buffer} digest
|
||||
*/
|
||||
/**
|
||||
* @overload
|
||||
* @param {Hash} hash hash
|
||||
* @param {undefined} encoding encoding of the return value
|
||||
* @param {boolean=} isSafe true when we await right types from digest(), otherwise false
|
||||
* @returns {Buffer} digest
|
||||
*/
|
||||
/**
|
||||
* @overload
|
||||
* @param {Hash} hash hash
|
||||
* @param {Encoding} encoding encoding of the return value
|
||||
* @param {boolean=} isSafe true when we await right types from digest(), otherwise false
|
||||
* @returns {string} digest
|
||||
*/
|
||||
/**
|
||||
* @param {Hash} hash hash
|
||||
* @param {Encoding=} encoding encoding of the return value
|
||||
* @param {boolean=} isSafe true when we await right types from digest(), otherwise false
|
||||
* @returns {string | Buffer} digest
|
||||
*/
|
||||
const digest = (hash, encoding, isSafe) => {
|
||||
if (typeof encoding === "undefined") {
|
||||
return isSafe ? hash.digest() : toBuffer(hash.digest());
|
||||
}
|
||||
|
||||
if (encoding === "base64url" && !isBase64URLSupported) {
|
||||
const digest = isSafe
|
||||
? hash.digest("base64")
|
||||
: toString(hash.digest("base64"), "base64");
|
||||
|
||||
return digest.replace(/\+/g, "-").replace(/\//g, "_").replace(/[=]+$/, "");
|
||||
} else if (
|
||||
typeof ENCODE_TABLE[/** @type {Base} */ (encoding.slice(4))] !== "undefined"
|
||||
) {
|
||||
const buf = isSafe ? hash.digest() : toBuffer(hash.digest());
|
||||
|
||||
return encode(
|
||||
buf,
|
||||
/** @type {Base} */
|
||||
(encoding.slice(4))
|
||||
);
|
||||
}
|
||||
|
||||
return isSafe
|
||||
? hash.digest(encoding)
|
||||
: toString(hash.digest(encoding), encoding);
|
||||
};
|
||||
|
||||
module.exports.decode = decode;
|
||||
module.exports.digest = digest;
|
||||
module.exports.encode = encode;
|
||||
module.exports.update = update;
|
||||
20
node_modules/webpack/lib/util/hash/md4.js
generated
vendored
Normal file
20
node_modules/webpack/lib/util/hash/md4.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const create = require("./wasm-hash");
|
||||
|
||||
// #region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
|
||||
const md4 = new WebAssembly.Module(
|
||||
Buffer.from(
|
||||
// 2150 bytes
|
||||
"AGFz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AEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEIIwKtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEQIwOtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEYIwStIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAAs=",
|
||||
"base64"
|
||||
)
|
||||
);
|
||||
// #endregion
|
||||
|
||||
module.exports = create.bind(null, md4, [], 64, 32);
|
||||
232
node_modules/webpack/lib/util/hash/wasm-hash.js
generated
vendored
Normal file
232
node_modules/webpack/lib/util/hash/wasm-hash.js
generated
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Hash = require("../Hash");
|
||||
|
||||
// 65536 is the size of a wasm memory page
|
||||
// 64 is the maximum chunk size for every possible wasm hash implementation
|
||||
// 4 is the maximum number of bytes per char for string encoding (max is utf-8)
|
||||
// ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
|
||||
const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
|
||||
|
||||
/**
|
||||
* @typedef {object} WasmExports
|
||||
* @property {WebAssembly.Memory} memory
|
||||
* @property {() => void} init
|
||||
* @property {(length: number) => void} update
|
||||
* @property {(length: number) => void} final
|
||||
*/
|
||||
|
||||
class WasmHash extends Hash {
|
||||
/**
|
||||
* @param {WebAssembly.Instance} instance wasm instance
|
||||
* @param {WebAssembly.Instance[]} instancesPool pool of instances
|
||||
* @param {number} chunkSize size of data chunks passed to wasm
|
||||
* @param {number} digestSize size of digest returned by wasm
|
||||
*/
|
||||
constructor(instance, instancesPool, chunkSize, digestSize) {
|
||||
super();
|
||||
|
||||
const exports = /** @type {WasmExports} */ (instance.exports);
|
||||
exports.init();
|
||||
/** @type {WasmExports} */
|
||||
this.exports = exports;
|
||||
/** @type {Buffer} */
|
||||
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
||||
/** @type {number} */
|
||||
this.buffered = 0;
|
||||
/** @type {WebAssembly.Instance[]} */
|
||||
this.instancesPool = instancesPool;
|
||||
/** @type {number} */
|
||||
this.chunkSize = chunkSize;
|
||||
/** @type {number} */
|
||||
this.digestSize = digestSize;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.buffered = 0;
|
||||
this.exports.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @overload
|
||||
* @param {string | Buffer} data data
|
||||
* @returns {Hash} updated hash
|
||||
*/
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @overload
|
||||
* @param {string} data data
|
||||
* @param {string=} inputEncoding data encoding
|
||||
* @returns {this} updated hash
|
||||
*/
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @param {string | Buffer} data data
|
||||
* @param {string=} inputEncoding data encoding
|
||||
* @returns {this} updated hash
|
||||
*/
|
||||
update(data, inputEncoding) {
|
||||
if (typeof data === "string") {
|
||||
while (data.length > MAX_SHORT_STRING) {
|
||||
this._updateWithShortString(
|
||||
data.slice(0, MAX_SHORT_STRING),
|
||||
/** @type {NodeJS.BufferEncoding} */
|
||||
(inputEncoding)
|
||||
);
|
||||
data = data.slice(MAX_SHORT_STRING);
|
||||
}
|
||||
this._updateWithShortString(
|
||||
data,
|
||||
/** @type {NodeJS.BufferEncoding} */
|
||||
(inputEncoding)
|
||||
);
|
||||
return this;
|
||||
}
|
||||
this._updateWithBuffer(data);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} data data
|
||||
* @param {BufferEncoding=} encoding encoding
|
||||
* @returns {void}
|
||||
*/
|
||||
_updateWithShortString(data, encoding) {
|
||||
const { exports, buffered, mem, chunkSize } = this;
|
||||
/** @type {number} */
|
||||
let endPos;
|
||||
if (data.length < 70) {
|
||||
// eslint-disable-next-line unicorn/text-encoding-identifier-case
|
||||
if (!encoding || encoding === "utf-8" || encoding === "utf8") {
|
||||
endPos = buffered;
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const cc = data.charCodeAt(i);
|
||||
if (cc < 0x80) {
|
||||
mem[endPos++] = cc;
|
||||
} else if (cc < 0x800) {
|
||||
mem[endPos] = (cc >> 6) | 0xc0;
|
||||
mem[endPos + 1] = (cc & 0x3f) | 0x80;
|
||||
endPos += 2;
|
||||
} else {
|
||||
// bail-out for weird chars
|
||||
endPos += mem.write(data.slice(i), endPos, encoding);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (encoding === "latin1") {
|
||||
endPos = buffered;
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const cc = data.charCodeAt(i);
|
||||
mem[endPos++] = cc;
|
||||
}
|
||||
} else {
|
||||
endPos = buffered + mem.write(data, buffered, encoding);
|
||||
}
|
||||
} else {
|
||||
endPos = buffered + mem.write(data, buffered, encoding);
|
||||
}
|
||||
if (endPos < chunkSize) {
|
||||
this.buffered = endPos;
|
||||
} else {
|
||||
const l = endPos & ~(this.chunkSize - 1);
|
||||
exports.update(l);
|
||||
const newBuffered = endPos - l;
|
||||
this.buffered = newBuffered;
|
||||
if (newBuffered > 0) mem.copyWithin(0, l, endPos);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Buffer} data data
|
||||
* @returns {void}
|
||||
*/
|
||||
_updateWithBuffer(data) {
|
||||
const { exports, buffered, mem } = this;
|
||||
const length = data.length;
|
||||
if (buffered + length < this.chunkSize) {
|
||||
data.copy(mem, buffered, 0, length);
|
||||
this.buffered += length;
|
||||
} else {
|
||||
const l = (buffered + length) & ~(this.chunkSize - 1);
|
||||
if (l > 65536) {
|
||||
let i = 65536 - buffered;
|
||||
data.copy(mem, buffered, 0, i);
|
||||
exports.update(65536);
|
||||
const stop = l - buffered - 65536;
|
||||
while (i < stop) {
|
||||
data.copy(mem, 0, i, i + 65536);
|
||||
exports.update(65536);
|
||||
i += 65536;
|
||||
}
|
||||
data.copy(mem, 0, i, l - buffered);
|
||||
exports.update(l - buffered - i);
|
||||
} else {
|
||||
data.copy(mem, buffered, 0, l - buffered);
|
||||
exports.update(l);
|
||||
}
|
||||
const newBuffered = length + buffered - l;
|
||||
this.buffered = newBuffered;
|
||||
if (newBuffered > 0) data.copy(mem, 0, length - newBuffered, length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @overload
|
||||
* @returns {Buffer} digest
|
||||
*/
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @overload
|
||||
* @param {string=} encoding encoding of the return value
|
||||
* @returns {string} digest
|
||||
*/
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @param {string=} encoding encoding of the return value
|
||||
* @returns {string | Buffer} digest
|
||||
*/
|
||||
digest(encoding) {
|
||||
const { exports, buffered, mem, digestSize } = this;
|
||||
exports.final(buffered);
|
||||
this.instancesPool.push(this);
|
||||
const hex = mem.toString("latin1", 0, digestSize);
|
||||
if (encoding === "hex") return hex;
|
||||
if (encoding === "binary" || !encoding) return Buffer.from(hex, "hex");
|
||||
return Buffer.from(hex, "hex").toString(
|
||||
/** @type {NodeJS.BufferEncoding} */ (encoding)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {WebAssembly.Module} wasmModule wasm module
|
||||
* @param {WasmHash[]} instancesPool pool of instances
|
||||
* @param {number} chunkSize size of data chunks passed to wasm
|
||||
* @param {number} digestSize size of digest returned by wasm
|
||||
* @returns {WasmHash} wasm hash
|
||||
*/
|
||||
const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
|
||||
if (instancesPool.length > 0) {
|
||||
const old = /** @type {WasmHash} */ (instancesPool.pop());
|
||||
old.reset();
|
||||
return old;
|
||||
}
|
||||
|
||||
return new WasmHash(
|
||||
new WebAssembly.Instance(wasmModule),
|
||||
instancesPool,
|
||||
chunkSize,
|
||||
digestSize
|
||||
);
|
||||
};
|
||||
|
||||
create.MAX_SHORT_STRING = MAX_SHORT_STRING;
|
||||
|
||||
module.exports = create;
|
||||
20
node_modules/webpack/lib/util/hash/xxhash64.js
generated
vendored
Normal file
20
node_modules/webpack/lib/util/hash/xxhash64.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const create = require("./wasm-hash");
|
||||
|
||||
// #region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
|
||||
const xxhash64 = new WebAssembly.Module(
|
||||
Buffer.from(
|
||||
// 1160 b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bnn9+IQMgAUEBaiEBDAELC0EAIAMgA0IhiIVCz9bTvtLHq9lCfiIDQh2IIAOFQvnz3fGZ9pmrFn4iA0IgiCADhSIDQiCIIgRC//8Dg0IghiAEQoCA/P8Pg0IQiIQiBEL/gYCA8B+DQhCGIARCgP6DgIDgP4NCCIiEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEIIANC/////w+DIgNC//8Dg0IghiADQoCA/P8Pg0IQiIQiA0L/gYCA8B+DQhCGIANCgP6DgIDgP4NCCIiEIgNCj4C8gPCBwAeDQgiGIANC8IHAh4CegPgAg0IEiIQiA0KGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gA0Kw4MCBg4aMmDCEfDcDAAs=",
|
||||
"base64"
|
||||
)
|
||||
);
|
||||
// #endregion
|
||||
|
||||
module.exports = create.bind(null, xxhash64, [], 32, 16);
|
||||
Reference in New Issue
Block a user