push the uni-demo project
This commit is contained in:
68
uni-demo/node_modules/webpack/lib/util/hash/BatchedHash.js
generated
vendored
Normal file
68
uni-demo/node_modules/webpack/lib/util/hash/BatchedHash.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Hash = require("../Hash");
|
||||
const MAX_SHORT_STRING = require("./wasm-hash").MAX_SHORT_STRING;
|
||||
|
||||
class BatchedHash extends Hash {
|
||||
constructor(hash) {
|
||||
super();
|
||||
this.string = undefined;
|
||||
this.encoding = undefined;
|
||||
this.hash = 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 (this.string !== undefined) {
|
||||
if (
|
||||
typeof data === "string" &&
|
||||
inputEncoding === this.encoding &&
|
||||
this.string.length + data.length < MAX_SHORT_STRING
|
||||
) {
|
||||
this.string += data;
|
||||
return this;
|
||||
}
|
||||
this.hash.update(this.string, this.encoding);
|
||||
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 {
|
||||
this.hash.update(data, inputEncoding);
|
||||
}
|
||||
} else {
|
||||
this.hash.update(data);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
if (this.string !== undefined) {
|
||||
this.hash.update(this.string, this.encoding);
|
||||
}
|
||||
return this.hash.digest(encoding);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BatchedHash;
|
||||
20
uni-demo/node_modules/webpack/lib/util/hash/md4.js
generated
vendored
Normal file
20
uni-demo/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(
|
||||
// 2156 bytes
|
||||
"AGFzbQEAAAABCAJgAX8AYAAAAwUEAQAAAAUDAQABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/AUEACwciBARpbml0AAAGdXBkYXRlAAIFZmluYWwAAwZtZW1vcnkCAAqLEAQmAEGBxpS6BiQBQYnXtv5+JAJB/rnrxXkkA0H2qMmBASQEQQAkAAvSCgEZfyMBIQUjAiECIwMhAyMEIQQDQCAAIAFLBEAgASgCJCISIAEoAiAiEyABKAIcIgkgASgCGCIIIAEoAhQiByABKAIQIg4gASgCDCIGIAEoAggiDyABKAIEIhAgASgCACIRIAMgBHMgAnEgBHMgBWpqQQN3IgogAiADc3EgA3MgBGpqQQd3IgsgAiAKc3EgAnMgA2pqQQt3IgwgCiALc3EgCnMgAmpqQRN3Ig0gCyAMc3EgC3MgCmpqQQN3IgogDCANc3EgDHMgC2pqQQd3IgsgCiANc3EgDXMgDGpqQQt3IgwgCiALc3EgCnMgDWpqQRN3Ig0gCyAMc3EgC3MgCmpqQQN3IhQgDCANc3EgDHMgC2pqQQd3IRUgASgCLCILIAEoAigiCiAMIA0gDSAUcyAVcXNqakELdyIWIBQgFXNxIBRzI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Ah4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAAs=",
|
||||
"base64"
|
||||
)
|
||||
);
|
||||
//#endregion
|
||||
|
||||
module.exports = create.bind(null, md4, [], 64, 32);
|
||||
163
uni-demo/node_modules/webpack/lib/util/hash/wasm-hash.js
generated
vendored
Normal file
163
uni-demo/node_modules/webpack/lib/util/hash/wasm-hash.js
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
// 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;
|
||||
|
||||
class WasmHash {
|
||||
/**
|
||||
* @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) {
|
||||
const exports = /** @type {any} */ (instance.exports);
|
||||
exports.init();
|
||||
this.exports = exports;
|
||||
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
||||
this.buffered = 0;
|
||||
this.instancesPool = instancesPool;
|
||||
this.chunkSize = chunkSize;
|
||||
this.digestSize = digestSize;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.buffered = 0;
|
||||
this.exports.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Buffer | string} data data
|
||||
* @param {BufferEncoding=} encoding encoding
|
||||
* @returns {this} itself
|
||||
*/
|
||||
update(data, encoding) {
|
||||
if (typeof data === "string") {
|
||||
while (data.length > MAX_SHORT_STRING) {
|
||||
this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding);
|
||||
data = data.slice(MAX_SHORT_STRING);
|
||||
}
|
||||
this._updateWithShortString(data, encoding);
|
||||
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;
|
||||
let endPos;
|
||||
if (data.length < 70) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
digest(type) {
|
||||
const { exports, buffered, mem, digestSize } = this;
|
||||
exports.final(buffered);
|
||||
this.instancesPool.push(this);
|
||||
const hex = mem.toString("latin1", 0, digestSize);
|
||||
if (type === "hex") return hex;
|
||||
if (type === "binary" || !type) return Buffer.from(hex, "hex");
|
||||
return Buffer.from(hex, "hex").toString(type);
|
||||
}
|
||||
}
|
||||
|
||||
const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
|
||||
if (instancesPool.length > 0) {
|
||||
const old = instancesPool.pop();
|
||||
old.reset();
|
||||
return old;
|
||||
} else {
|
||||
return new WasmHash(
|
||||
new WebAssembly.Instance(wasmModule),
|
||||
instancesPool,
|
||||
chunkSize,
|
||||
digestSize
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = create;
|
||||
module.exports.MAX_SHORT_STRING = MAX_SHORT_STRING;
|
||||
20
uni-demo/node_modules/webpack/lib/util/hash/xxhash64.js
generated
vendored
Normal file
20
uni-demo/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(
|
||||
// 1170 bytes
|
||||
"AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrIIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEFIAAgAUEgaiIBSw0ACyACJAAgAyQBIAQkAiAFJAMLqAYCAX8EfiMEQgBSBH4jACICQgGJIwEiA0IHiXwjAiIEQgyJfCMDIgVCEol8IAJCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0gA0LP1tO+0ser2UJ+Qh+JQoeVr6+Ytt6bnn9+hUKHla+vmLbem55/fkKdo7Xqg7GNivoAfSAEQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IAVCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0FQsXP2bLx5brqJwsjBCAArXx8IQIDQCABQQhqIABNBEAgAiABKQMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQhuJQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IQIgAUEIaiEBDAELCyABQQRqIABNBEAgAiABNQIAQoeVr6+Ytt6bnn9+hUIXiULP1tO+0ser2UJ+Qvnz3fGZ9pmrFnwhAiABQQRqIQELA0AgACABRwRAIAIgATEAAELFz9my8eW66id+hUILiUKHla+vmLbem55/fiECIAFBAWohAQwBCwtBACACIAJCIYiFQs/W077Sx6vZQn4iAkIdiCAChUL5893xmfaZqxZ+IgJCIIggAoUiAkIgiCIDQv//A4NCIIYgA0KAgPz/D4NCEIiEIgNC/4GAgPAfg0IQhiADQoD+g4CA4D+DQgiIhCIDQo+AvIDwgcAHg0IIhiADQvCBwIeAnoD4AINCBIiEIgNChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IANCsODAgYOGjJgwhHw3AwBBCCACQv////8PgyICQv//A4NCIIYgAkKAgPz/D4NCEIiEIgJC/4GAgPAfg0IQhiACQoD+g4CA4D+DQgiIhCICQo+AvIDwgcAHg0IIhiACQvCBwIeAnoD4AINCBIiEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL",
|
||||
"base64"
|
||||
)
|
||||
);
|
||||
//#endregion
|
||||
|
||||
module.exports = create.bind(null, xxhash64, [], 32, 16);
|
||||
Reference in New Issue
Block a user