diff --git a/main.meta.js b/main.meta.js index 782c77f..ba3e1f3 100644 --- a/main.meta.js +++ b/main.meta.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.136 +// @version 0.137 // @description uhh // @author You // @match https://boards.4channel.org/* diff --git a/main.user.js b/main.user.js index 210ed60..218fde3 100644 --- a/main.user.js +++ b/main.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.136 +// @version 0.137 // @description uhh // @author You // @match https://boards.4channel.org/* @@ -251,13 +251,13 @@ var base64 = require_base64_js(); var ieee7542 = require_ieee754(); var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null; - exports.Buffer = Buffer15; + exports.Buffer = Buffer16; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; var K_MAX_LENGTH = 2147483647; exports.kMaxLength = K_MAX_LENGTH; - Buffer15.TYPED_ARRAY_SUPPORT = typedArraySupport(); - if (!Buffer15.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { + Buffer16.TYPED_ARRAY_SUPPORT = typedArraySupport(); + if (!Buffer16.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."); } function typedArraySupport() { @@ -273,18 +273,18 @@ return false; } } - Object.defineProperty(Buffer15.prototype, "parent", { + Object.defineProperty(Buffer16.prototype, "parent", { enumerable: true, get: function() { - if (!Buffer15.isBuffer(this)) + if (!Buffer16.isBuffer(this)) return void 0; return this.buffer; } }); - Object.defineProperty(Buffer15.prototype, "offset", { + Object.defineProperty(Buffer16.prototype, "offset", { enumerable: true, get: function() { - if (!Buffer15.isBuffer(this)) + if (!Buffer16.isBuffer(this)) return void 0; return this.byteOffset; } @@ -294,10 +294,10 @@ throw new RangeError('The value "' + length + '" is invalid for option "size"'); } const buf2 = new Uint8Array(length); - Object.setPrototypeOf(buf2, Buffer15.prototype); + Object.setPrototypeOf(buf2, Buffer16.prototype); return buf2; } - function Buffer15(arg, encodingOrOffset, length) { + function Buffer16(arg, encodingOrOffset, length) { if (typeof arg === "number") { if (typeof encodingOrOffset === "string") { throw new TypeError('The "string" argument must be of type string. Received type number'); @@ -306,7 +306,7 @@ } return from(arg, encodingOrOffset, length); } - Buffer15.poolSize = 8192; + Buffer16.poolSize = 8192; function from(value, encodingOrOffset, length) { if (typeof value === "string") { return fromString(value, encodingOrOffset); @@ -328,21 +328,21 @@ } const valueOf = value.valueOf && value.valueOf(); if (valueOf != null && valueOf !== value) { - return Buffer15.from(valueOf, encodingOrOffset, length); + return Buffer16.from(valueOf, encodingOrOffset, length); } const b = fromObject(value); if (b) return b; if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") { - return Buffer15.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); + return Buffer16.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); } throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); } - Buffer15.from = function(value, encodingOrOffset, length) { + Buffer16.from = function(value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }; - Object.setPrototypeOf(Buffer15.prototype, Uint8Array.prototype); - Object.setPrototypeOf(Buffer15, Uint8Array); + Object.setPrototypeOf(Buffer16.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer16, Uint8Array); function assertSize(size) { if (typeof size !== "number") { throw new TypeError('"size" argument must be of type number'); @@ -360,24 +360,24 @@ } return createBuffer(size); } - Buffer15.alloc = function(size, fill, encoding) { + Buffer16.alloc = function(size, fill, encoding) { return alloc(size, fill, encoding); }; function allocUnsafe(size) { assertSize(size); return createBuffer(size < 0 ? 0 : checked(size) | 0); } - Buffer15.allocUnsafe = function(size) { + Buffer16.allocUnsafe = function(size) { return allocUnsafe(size); }; - Buffer15.allocUnsafeSlow = function(size) { + Buffer16.allocUnsafeSlow = function(size) { return allocUnsafe(size); }; function fromString(string, encoding) { if (typeof encoding !== "string" || encoding === "") { encoding = "utf8"; } - if (!Buffer15.isEncoding(encoding)) { + if (!Buffer16.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } const length = byteLength(string, encoding) | 0; @@ -418,11 +418,11 @@ } else { buf2 = new Uint8Array(array, byteOffset, length); } - Object.setPrototypeOf(buf2, Buffer15.prototype); + Object.setPrototypeOf(buf2, Buffer16.prototype); return buf2; } function fromObject(obj) { - if (Buffer15.isBuffer(obj)) { + if (Buffer16.isBuffer(obj)) { const len = checked(obj.length) | 0; const buf2 = createBuffer(len); if (buf2.length === 0) { @@ -451,17 +451,17 @@ if (+length != length) { length = 0; } - return Buffer15.alloc(+length); + return Buffer16.alloc(+length); } - Buffer15.isBuffer = function isBuffer(b) { - return b != null && b._isBuffer === true && b !== Buffer15.prototype; + Buffer16.isBuffer = function isBuffer(b) { + return b != null && b._isBuffer === true && b !== Buffer16.prototype; }; - Buffer15.compare = function compare(a, b) { + Buffer16.compare = function compare(a, b) { if (isInstance(a, Uint8Array)) - a = Buffer15.from(a, a.offset, a.byteLength); + a = Buffer16.from(a, a.offset, a.byteLength); if (isInstance(b, Uint8Array)) - b = Buffer15.from(b, b.offset, b.byteLength); - if (!Buffer15.isBuffer(a) || !Buffer15.isBuffer(b)) { + b = Buffer16.from(b, b.offset, b.byteLength); + if (!Buffer16.isBuffer(a) || !Buffer16.isBuffer(b)) { throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); } if (a === b) @@ -481,7 +481,7 @@ return 1; return 0; }; - Buffer15.isEncoding = function isEncoding(encoding) { + Buffer16.isEncoding = function isEncoding(encoding) { switch (String(encoding).toLowerCase()) { case "hex": case "utf8": @@ -499,12 +499,12 @@ return false; } }; - Buffer15.concat = function concat(list, length) { + Buffer16.concat = function concat(list, length) { if (!Array.isArray(list)) { throw new TypeError('"list" argument must be an Array of Buffers'); } if (list.length === 0) { - return Buffer15.alloc(0); + return Buffer16.alloc(0); } let i; if (length === void 0) { @@ -513,19 +513,19 @@ length += list[i].length; } } - const buffer = Buffer15.allocUnsafe(length); + const buffer = Buffer16.allocUnsafe(length); let pos = 0; for (i = 0; i < list.length; ++i) { let buf2 = list[i]; if (isInstance(buf2, Uint8Array)) { if (pos + buf2.length > buffer.length) { - if (!Buffer15.isBuffer(buf2)) - buf2 = Buffer15.from(buf2); + if (!Buffer16.isBuffer(buf2)) + buf2 = Buffer16.from(buf2); buf2.copy(buffer, pos); } else { Uint8Array.prototype.set.call(buffer, buf2, pos); } - } else if (!Buffer15.isBuffer(buf2)) { + } else if (!Buffer16.isBuffer(buf2)) { throw new TypeError('"list" argument must be an Array of Buffers'); } else { buf2.copy(buffer, pos); @@ -535,7 +535,7 @@ return buffer; }; function byteLength(string, encoding) { - if (Buffer15.isBuffer(string)) { + if (Buffer16.isBuffer(string)) { return string.length; } if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { @@ -576,7 +576,7 @@ } } } - Buffer15.byteLength = byteLength; + Buffer16.byteLength = byteLength; function slowToString(encoding, start, end) { let loweredCase = false; if (start === void 0 || start < 0) { @@ -625,13 +625,13 @@ } } } - Buffer15.prototype._isBuffer = true; + Buffer16.prototype._isBuffer = true; function swap(b, n, m) { const i = b[n]; b[n] = b[m]; b[m] = i; } - Buffer15.prototype.swap16 = function swap16() { + Buffer16.prototype.swap16 = function swap16() { const len = this.length; if (len % 2 !== 0) { throw new RangeError("Buffer size must be a multiple of 16-bits"); @@ -641,7 +641,7 @@ } return this; }; - Buffer15.prototype.swap32 = function swap32() { + Buffer16.prototype.swap32 = function swap32() { const len = this.length; if (len % 4 !== 0) { throw new RangeError("Buffer size must be a multiple of 32-bits"); @@ -652,7 +652,7 @@ } return this; }; - Buffer15.prototype.swap64 = function swap64() { + Buffer16.prototype.swap64 = function swap64() { const len = this.length; if (len % 8 !== 0) { throw new RangeError("Buffer size must be a multiple of 64-bits"); @@ -665,7 +665,7 @@ } return this; }; - Buffer15.prototype.toString = function toString() { + Buffer16.prototype.toString = function toString() { const length = this.length; if (length === 0) return ""; @@ -673,15 +673,15 @@ return utf8Slice(this, 0, length); return slowToString.apply(this, arguments); }; - Buffer15.prototype.toLocaleString = Buffer15.prototype.toString; - Buffer15.prototype.equals = function equals(b) { - if (!Buffer15.isBuffer(b)) + Buffer16.prototype.toLocaleString = Buffer16.prototype.toString; + Buffer16.prototype.equals = function equals(b) { + if (!Buffer16.isBuffer(b)) throw new TypeError("Argument must be a Buffer"); if (this === b) return true; - return Buffer15.compare(this, b) === 0; + return Buffer16.compare(this, b) === 0; }; - Buffer15.prototype.inspect = function inspect() { + Buffer16.prototype.inspect = function inspect() { let str = ""; const max = exports.INSPECT_MAX_BYTES; str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(); @@ -690,13 +690,13 @@ return ""; }; if (customInspectSymbol) { - Buffer15.prototype[customInspectSymbol] = Buffer15.prototype.inspect; + Buffer16.prototype[customInspectSymbol] = Buffer16.prototype.inspect; } - Buffer15.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { + Buffer16.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) { - target = Buffer15.from(target, target.offset, target.byteLength); + target = Buffer16.from(target, target.offset, target.byteLength); } - if (!Buffer15.isBuffer(target)) { + if (!Buffer16.isBuffer(target)) { throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target); } if (start === void 0) { @@ -776,9 +776,9 @@ return -1; } if (typeof val === "string") { - val = Buffer15.from(val, encoding); + val = Buffer16.from(val, encoding); } - if (Buffer15.isBuffer(val)) { + if (Buffer16.isBuffer(val)) { if (val.length === 0) { return -1; } @@ -851,13 +851,13 @@ } return -1; } - Buffer15.prototype.includes = function includes(val, byteOffset, encoding) { + Buffer16.prototype.includes = function includes(val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1; }; - Buffer15.prototype.indexOf = function indexOf(val, byteOffset, encoding) { + Buffer16.prototype.indexOf = function indexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true); }; - Buffer15.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + Buffer16.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, false); }; function hexWrite(buf2, string, offset, length) { @@ -896,7 +896,7 @@ function ucs2Write(buf2, string, offset, length) { return blitBuffer(utf16leToBytes(string, buf2.length - offset), buf2, offset, length); } - Buffer15.prototype.write = function write2(string, offset, length, encoding) { + Buffer16.prototype.write = function write2(string, offset, length, encoding) { if (offset === void 0) { encoding = "utf8"; length = this.length; @@ -953,7 +953,7 @@ } } }; - Buffer15.prototype.toJSON = function toJSON() { + Buffer16.prototype.toJSON = function toJSON() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) @@ -1075,7 +1075,7 @@ } return res; } - Buffer15.prototype.slice = function slice(start, end) { + Buffer16.prototype.slice = function slice(start, end) { const len = this.length; start = ~~start; end = end === void 0 ? len : ~~end; @@ -1096,7 +1096,7 @@ if (end < start) end = start; const newBuf = this.subarray(start, end); - Object.setPrototypeOf(newBuf, Buffer15.prototype); + Object.setPrototypeOf(newBuf, Buffer16.prototype); return newBuf; }; function checkOffset(offset, ext, length) { @@ -1105,7 +1105,7 @@ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length"); } - Buffer15.prototype.readUintLE = Buffer15.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { + Buffer16.prototype.readUintLE = Buffer16.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -1118,7 +1118,7 @@ } return val; }; - Buffer15.prototype.readUintBE = Buffer15.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { + Buffer16.prototype.readUintBE = Buffer16.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) { @@ -1131,37 +1131,37 @@ } return val; }; - Buffer15.prototype.readUint8 = Buffer15.prototype.readUInt8 = function readUInt8(offset, noAssert) { + Buffer16.prototype.readUint8 = Buffer16.prototype.readUInt8 = function readUInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }; - Buffer15.prototype.readUint16LE = Buffer15.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { + Buffer16.prototype.readUint16LE = Buffer16.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | this[offset + 1] << 8; }; - Buffer15.prototype.readUint16BE = Buffer15.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { + Buffer16.prototype.readUint16BE = Buffer16.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] << 8 | this[offset + 1]; }; - Buffer15.prototype.readUint32LE = Buffer15.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { + Buffer16.prototype.readUint32LE = Buffer16.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216; }; - Buffer15.prototype.readUint32BE = Buffer15.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { + Buffer16.prototype.readUint32BE = Buffer16.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); }; - Buffer15.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) { + Buffer16.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; @@ -1173,7 +1173,7 @@ const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24; return BigInt(lo) + (BigInt(hi) << BigInt(32)); }); - Buffer15.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) { + Buffer16.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; @@ -1185,7 +1185,7 @@ const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last; return (BigInt(hi) << BigInt(32)) + BigInt(lo); }); - Buffer15.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { + Buffer16.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -1201,7 +1201,7 @@ val -= Math.pow(2, 8 * byteLength2); return val; }; - Buffer15.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { + Buffer16.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -1217,7 +1217,7 @@ val -= Math.pow(2, 8 * byteLength2); return val; }; - Buffer15.prototype.readInt8 = function readInt8(offset, noAssert) { + Buffer16.prototype.readInt8 = function readInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); @@ -1225,33 +1225,33 @@ return this[offset]; return (255 - this[offset] + 1) * -1; }; - Buffer15.prototype.readInt16LE = function readInt16LE(offset, noAssert) { + Buffer16.prototype.readInt16LE = function readInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); const val = this[offset] | this[offset + 1] << 8; return val & 32768 ? val | 4294901760 : val; }; - Buffer15.prototype.readInt16BE = function readInt16BE(offset, noAssert) { + Buffer16.prototype.readInt16BE = function readInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); const val = this[offset + 1] | this[offset] << 8; return val & 32768 ? val | 4294901760 : val; }; - Buffer15.prototype.readInt32LE = function readInt32LE(offset, noAssert) { + Buffer16.prototype.readInt32LE = function readInt32LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; }; - Buffer15.prototype.readInt32BE = function readInt32BE(offset, noAssert) { + Buffer16.prototype.readInt32BE = function readInt32BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; }; - Buffer15.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) { + Buffer16.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; @@ -1262,7 +1262,7 @@ const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24); return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24); }); - Buffer15.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) { + Buffer16.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; @@ -1273,39 +1273,39 @@ const val = (first << 24) + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset]; return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last); }); - Buffer15.prototype.readFloatLE = function readFloatLE(offset, noAssert) { + Buffer16.prototype.readFloatLE = function readFloatLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, true, 23, 4); }; - Buffer15.prototype.readFloatBE = function readFloatBE(offset, noAssert) { + Buffer16.prototype.readFloatBE = function readFloatBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, false, 23, 4); }; - Buffer15.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { + Buffer16.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee7542.read(this, offset, true, 52, 8); }; - Buffer15.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { + Buffer16.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee7542.read(this, offset, false, 52, 8); }; function checkInt(buf2, value, offset, ext, max, min) { - if (!Buffer15.isBuffer(buf2)) + if (!Buffer16.isBuffer(buf2)) throw new TypeError('"buffer" argument must be a Buffer instance'); if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); if (offset + ext > buf2.length) throw new RangeError("Index out of range"); } - Buffer15.prototype.writeUintLE = Buffer15.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { + Buffer16.prototype.writeUintLE = Buffer16.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -1321,7 +1321,7 @@ } return offset + byteLength2; }; - Buffer15.prototype.writeUintBE = Buffer15.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { + Buffer16.prototype.writeUintBE = Buffer16.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -1337,7 +1337,7 @@ } return offset + byteLength2; }; - Buffer15.prototype.writeUint8 = Buffer15.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { + Buffer16.prototype.writeUint8 = Buffer16.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1345,7 +1345,7 @@ this[offset] = value & 255; return offset + 1; }; - Buffer15.prototype.writeUint16LE = Buffer15.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { + Buffer16.prototype.writeUint16LE = Buffer16.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1354,7 +1354,7 @@ this[offset + 1] = value >>> 8; return offset + 2; }; - Buffer15.prototype.writeUint16BE = Buffer15.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { + Buffer16.prototype.writeUint16BE = Buffer16.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1363,7 +1363,7 @@ this[offset + 1] = value & 255; return offset + 2; }; - Buffer15.prototype.writeUint32LE = Buffer15.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { + Buffer16.prototype.writeUint32LE = Buffer16.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1374,7 +1374,7 @@ this[offset] = value & 255; return offset + 4; }; - Buffer15.prototype.writeUint32BE = Buffer15.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { + Buffer16.prototype.writeUint32BE = Buffer16.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1425,13 +1425,13 @@ buf2[offset] = hi; return offset + 8; } - Buffer15.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) { + Buffer16.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) { return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); }); - Buffer15.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) { + Buffer16.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) { return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); }); - Buffer15.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { + Buffer16.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -1450,7 +1450,7 @@ } return offset + byteLength2; }; - Buffer15.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { + Buffer16.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -1469,7 +1469,7 @@ } return offset + byteLength2; }; - Buffer15.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { + Buffer16.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1479,7 +1479,7 @@ this[offset] = value & 255; return offset + 1; }; - Buffer15.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { + Buffer16.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1488,7 +1488,7 @@ this[offset + 1] = value >>> 8; return offset + 2; }; - Buffer15.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { + Buffer16.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1497,7 +1497,7 @@ this[offset + 1] = value & 255; return offset + 2; }; - Buffer15.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { + Buffer16.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1508,7 +1508,7 @@ this[offset + 3] = value >>> 24; return offset + 4; }; - Buffer15.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { + Buffer16.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1521,10 +1521,10 @@ this[offset + 3] = value & 255; return offset + 4; }; - Buffer15.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { + Buffer16.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); }); - Buffer15.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) { + Buffer16.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) { return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); }); function checkIEEE754(buf2, value, offset, ext, max, min) { @@ -1542,10 +1542,10 @@ ieee7542.write(buf2, value, offset, littleEndian, 23, 4); return offset + 4; } - Buffer15.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { + Buffer16.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert); }; - Buffer15.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { + Buffer16.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert); }; function writeDouble(buf2, value, offset, littleEndian, noAssert) { @@ -1557,14 +1557,14 @@ ieee7542.write(buf2, value, offset, littleEndian, 52, 8); return offset + 8; } - Buffer15.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { + Buffer16.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert); }; - Buffer15.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { + Buffer16.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert); }; - Buffer15.prototype.copy = function copy(target, targetStart, start, end) { - if (!Buffer15.isBuffer(target)) + Buffer16.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer16.isBuffer(target)) throw new TypeError("argument should be a Buffer"); if (!start) start = 0; @@ -1600,7 +1600,7 @@ } return len; }; - Buffer15.prototype.fill = function fill(val, start, end, encoding) { + Buffer16.prototype.fill = function fill(val, start, end, encoding) { if (typeof val === "string") { if (typeof start === "string") { encoding = start; @@ -1613,7 +1613,7 @@ if (encoding !== void 0 && typeof encoding !== "string") { throw new TypeError("encoding must be a string"); } - if (typeof encoding === "string" && !Buffer15.isEncoding(encoding)) { + if (typeof encoding === "string" && !Buffer16.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } if (val.length === 1) { @@ -1643,7 +1643,7 @@ this[i] = val; } } else { - const bytes = Buffer15.isBuffer(val) ? val : Buffer15.from(val, encoding); + const bytes = Buffer16.isBuffer(val) ? val : Buffer16.from(val, encoding); const len = bytes.length; if (len === 0) { throw new TypeError('The value "' + val + '" is invalid for argument "value"'); @@ -4441,13 +4441,13 @@ var base64 = require_base64_js(); var ieee7542 = require_ieee754(); var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null; - exports.Buffer = Buffer15; + exports.Buffer = Buffer16; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; var K_MAX_LENGTH = 2147483647; exports.kMaxLength = K_MAX_LENGTH; - Buffer15.TYPED_ARRAY_SUPPORT = typedArraySupport(); - if (!Buffer15.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { + Buffer16.TYPED_ARRAY_SUPPORT = typedArraySupport(); + if (!Buffer16.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."); } function typedArraySupport() { @@ -4463,18 +4463,18 @@ return false; } } - Object.defineProperty(Buffer15.prototype, "parent", { + Object.defineProperty(Buffer16.prototype, "parent", { enumerable: true, get: function() { - if (!Buffer15.isBuffer(this)) + if (!Buffer16.isBuffer(this)) return void 0; return this.buffer; } }); - Object.defineProperty(Buffer15.prototype, "offset", { + Object.defineProperty(Buffer16.prototype, "offset", { enumerable: true, get: function() { - if (!Buffer15.isBuffer(this)) + if (!Buffer16.isBuffer(this)) return void 0; return this.byteOffset; } @@ -4484,10 +4484,10 @@ throw new RangeError('The value "' + length + '" is invalid for option "size"'); } var buf2 = new Uint8Array(length); - Object.setPrototypeOf(buf2, Buffer15.prototype); + Object.setPrototypeOf(buf2, Buffer16.prototype); return buf2; } - function Buffer15(arg, encodingOrOffset, length) { + function Buffer16(arg, encodingOrOffset, length) { if (typeof arg === "number") { if (typeof encodingOrOffset === "string") { throw new TypeError('The "string" argument must be of type string. Received type number'); @@ -4496,7 +4496,7 @@ } return from(arg, encodingOrOffset, length); } - Buffer15.poolSize = 8192; + Buffer16.poolSize = 8192; function from(value, encodingOrOffset, length) { if (typeof value === "string") { return fromString(value, encodingOrOffset); @@ -4518,21 +4518,21 @@ } var valueOf = value.valueOf && value.valueOf(); if (valueOf != null && valueOf !== value) { - return Buffer15.from(valueOf, encodingOrOffset, length); + return Buffer16.from(valueOf, encodingOrOffset, length); } var b = fromObject(value); if (b) return b; if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") { - return Buffer15.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); + return Buffer16.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); } throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); } - Buffer15.from = function(value, encodingOrOffset, length) { + Buffer16.from = function(value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }; - Object.setPrototypeOf(Buffer15.prototype, Uint8Array.prototype); - Object.setPrototypeOf(Buffer15, Uint8Array); + Object.setPrototypeOf(Buffer16.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer16, Uint8Array); function assertSize(size) { if (typeof size !== "number") { throw new TypeError('"size" argument must be of type number'); @@ -4550,24 +4550,24 @@ } return createBuffer(size); } - Buffer15.alloc = function(size, fill, encoding) { + Buffer16.alloc = function(size, fill, encoding) { return alloc(size, fill, encoding); }; function allocUnsafe(size) { assertSize(size); return createBuffer(size < 0 ? 0 : checked(size) | 0); } - Buffer15.allocUnsafe = function(size) { + Buffer16.allocUnsafe = function(size) { return allocUnsafe(size); }; - Buffer15.allocUnsafeSlow = function(size) { + Buffer16.allocUnsafeSlow = function(size) { return allocUnsafe(size); }; function fromString(string, encoding) { if (typeof encoding !== "string" || encoding === "") { encoding = "utf8"; } - if (!Buffer15.isEncoding(encoding)) { + if (!Buffer16.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } var length = byteLength(string, encoding) | 0; @@ -4608,11 +4608,11 @@ } else { buf2 = new Uint8Array(array, byteOffset, length); } - Object.setPrototypeOf(buf2, Buffer15.prototype); + Object.setPrototypeOf(buf2, Buffer16.prototype); return buf2; } function fromObject(obj) { - if (Buffer15.isBuffer(obj)) { + if (Buffer16.isBuffer(obj)) { var len = checked(obj.length) | 0; var buf2 = createBuffer(len); if (buf2.length === 0) { @@ -4641,17 +4641,17 @@ if (+length != length) { length = 0; } - return Buffer15.alloc(+length); + return Buffer16.alloc(+length); } - Buffer15.isBuffer = function isBuffer(b) { - return b != null && b._isBuffer === true && b !== Buffer15.prototype; + Buffer16.isBuffer = function isBuffer(b) { + return b != null && b._isBuffer === true && b !== Buffer16.prototype; }; - Buffer15.compare = function compare(a, b) { + Buffer16.compare = function compare(a, b) { if (isInstance(a, Uint8Array)) - a = Buffer15.from(a, a.offset, a.byteLength); + a = Buffer16.from(a, a.offset, a.byteLength); if (isInstance(b, Uint8Array)) - b = Buffer15.from(b, b.offset, b.byteLength); - if (!Buffer15.isBuffer(a) || !Buffer15.isBuffer(b)) { + b = Buffer16.from(b, b.offset, b.byteLength); + if (!Buffer16.isBuffer(a) || !Buffer16.isBuffer(b)) { throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); } if (a === b) @@ -4671,7 +4671,7 @@ return 1; return 0; }; - Buffer15.isEncoding = function isEncoding(encoding) { + Buffer16.isEncoding = function isEncoding(encoding) { switch (String(encoding).toLowerCase()) { case "hex": case "utf8": @@ -4689,12 +4689,12 @@ return false; } }; - Buffer15.concat = function concat(list, length) { + Buffer16.concat = function concat(list, length) { if (!Array.isArray(list)) { throw new TypeError('"list" argument must be an Array of Buffers'); } if (list.length === 0) { - return Buffer15.alloc(0); + return Buffer16.alloc(0); } var i; if (length === void 0) { @@ -4703,17 +4703,17 @@ length += list[i].length; } } - var buffer = Buffer15.allocUnsafe(length); + var buffer = Buffer16.allocUnsafe(length); var pos = 0; for (i = 0; i < list.length; ++i) { var buf2 = list[i]; if (isInstance(buf2, Uint8Array)) { if (pos + buf2.length > buffer.length) { - Buffer15.from(buf2).copy(buffer, pos); + Buffer16.from(buf2).copy(buffer, pos); } else { Uint8Array.prototype.set.call(buffer, buf2, pos); } - } else if (!Buffer15.isBuffer(buf2)) { + } else if (!Buffer16.isBuffer(buf2)) { throw new TypeError('"list" argument must be an Array of Buffers'); } else { buf2.copy(buffer, pos); @@ -4723,7 +4723,7 @@ return buffer; }; function byteLength(string, encoding) { - if (Buffer15.isBuffer(string)) { + if (Buffer16.isBuffer(string)) { return string.length; } if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { @@ -4764,7 +4764,7 @@ } } } - Buffer15.byteLength = byteLength; + Buffer16.byteLength = byteLength; function slowToString(encoding, start, end) { var loweredCase = false; if (start === void 0 || start < 0) { @@ -4813,13 +4813,13 @@ } } } - Buffer15.prototype._isBuffer = true; + Buffer16.prototype._isBuffer = true; function swap(b, n, m) { var i = b[n]; b[n] = b[m]; b[m] = i; } - Buffer15.prototype.swap16 = function swap16() { + Buffer16.prototype.swap16 = function swap16() { var len = this.length; if (len % 2 !== 0) { throw new RangeError("Buffer size must be a multiple of 16-bits"); @@ -4829,7 +4829,7 @@ } return this; }; - Buffer15.prototype.swap32 = function swap32() { + Buffer16.prototype.swap32 = function swap32() { var len = this.length; if (len % 4 !== 0) { throw new RangeError("Buffer size must be a multiple of 32-bits"); @@ -4840,7 +4840,7 @@ } return this; }; - Buffer15.prototype.swap64 = function swap64() { + Buffer16.prototype.swap64 = function swap64() { var len = this.length; if (len % 8 !== 0) { throw new RangeError("Buffer size must be a multiple of 64-bits"); @@ -4853,7 +4853,7 @@ } return this; }; - Buffer15.prototype.toString = function toString() { + Buffer16.prototype.toString = function toString() { var length = this.length; if (length === 0) return ""; @@ -4861,15 +4861,15 @@ return utf8Slice(this, 0, length); return slowToString.apply(this, arguments); }; - Buffer15.prototype.toLocaleString = Buffer15.prototype.toString; - Buffer15.prototype.equals = function equals(b) { - if (!Buffer15.isBuffer(b)) + Buffer16.prototype.toLocaleString = Buffer16.prototype.toString; + Buffer16.prototype.equals = function equals(b) { + if (!Buffer16.isBuffer(b)) throw new TypeError("Argument must be a Buffer"); if (this === b) return true; - return Buffer15.compare(this, b) === 0; + return Buffer16.compare(this, b) === 0; }; - Buffer15.prototype.inspect = function inspect() { + Buffer16.prototype.inspect = function inspect() { var str = ""; var max = exports.INSPECT_MAX_BYTES; str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(); @@ -4878,13 +4878,13 @@ return ""; }; if (customInspectSymbol) { - Buffer15.prototype[customInspectSymbol] = Buffer15.prototype.inspect; + Buffer16.prototype[customInspectSymbol] = Buffer16.prototype.inspect; } - Buffer15.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { + Buffer16.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) { - target = Buffer15.from(target, target.offset, target.byteLength); + target = Buffer16.from(target, target.offset, target.byteLength); } - if (!Buffer15.isBuffer(target)) { + if (!Buffer16.isBuffer(target)) { throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target); } if (start === void 0) { @@ -4964,9 +4964,9 @@ return -1; } if (typeof val === "string") { - val = Buffer15.from(val, encoding); + val = Buffer16.from(val, encoding); } - if (Buffer15.isBuffer(val)) { + if (Buffer16.isBuffer(val)) { if (val.length === 0) { return -1; } @@ -5039,13 +5039,13 @@ } return -1; } - Buffer15.prototype.includes = function includes(val, byteOffset, encoding) { + Buffer16.prototype.includes = function includes(val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1; }; - Buffer15.prototype.indexOf = function indexOf(val, byteOffset, encoding) { + Buffer16.prototype.indexOf = function indexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true); }; - Buffer15.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + Buffer16.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, false); }; function hexWrite(buf2, string, offset, length) { @@ -5083,7 +5083,7 @@ function ucs2Write(buf2, string, offset, length) { return blitBuffer(utf16leToBytes(string, buf2.length - offset), buf2, offset, length); } - Buffer15.prototype.write = function write2(string, offset, length, encoding) { + Buffer16.prototype.write = function write2(string, offset, length, encoding) { if (offset === void 0) { encoding = "utf8"; length = this.length; @@ -5140,7 +5140,7 @@ } } }; - Buffer15.prototype.toJSON = function toJSON() { + Buffer16.prototype.toJSON = function toJSON() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) @@ -5262,7 +5262,7 @@ } return res; } - Buffer15.prototype.slice = function slice(start, end) { + Buffer16.prototype.slice = function slice(start, end) { var len = this.length; start = ~~start; end = end === void 0 ? len : ~~end; @@ -5283,7 +5283,7 @@ if (end < start) end = start; var newBuf = this.subarray(start, end); - Object.setPrototypeOf(newBuf, Buffer15.prototype); + Object.setPrototypeOf(newBuf, Buffer16.prototype); return newBuf; }; function checkOffset(offset, ext, length) { @@ -5292,7 +5292,7 @@ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length"); } - Buffer15.prototype.readUintLE = Buffer15.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { + Buffer16.prototype.readUintLE = Buffer16.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -5305,7 +5305,7 @@ } return val; }; - Buffer15.prototype.readUintBE = Buffer15.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { + Buffer16.prototype.readUintBE = Buffer16.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) { @@ -5318,37 +5318,37 @@ } return val; }; - Buffer15.prototype.readUint8 = Buffer15.prototype.readUInt8 = function readUInt8(offset, noAssert) { + Buffer16.prototype.readUint8 = Buffer16.prototype.readUInt8 = function readUInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }; - Buffer15.prototype.readUint16LE = Buffer15.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { + Buffer16.prototype.readUint16LE = Buffer16.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | this[offset + 1] << 8; }; - Buffer15.prototype.readUint16BE = Buffer15.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { + Buffer16.prototype.readUint16BE = Buffer16.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] << 8 | this[offset + 1]; }; - Buffer15.prototype.readUint32LE = Buffer15.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { + Buffer16.prototype.readUint32LE = Buffer16.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216; }; - Buffer15.prototype.readUint32BE = Buffer15.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { + Buffer16.prototype.readUint32BE = Buffer16.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); }; - Buffer15.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { + Buffer16.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -5364,7 +5364,7 @@ val -= Math.pow(2, 8 * byteLength2); return val; }; - Buffer15.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { + Buffer16.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -5380,7 +5380,7 @@ val -= Math.pow(2, 8 * byteLength2); return val; }; - Buffer15.prototype.readInt8 = function readInt8(offset, noAssert) { + Buffer16.prototype.readInt8 = function readInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); @@ -5388,65 +5388,65 @@ return this[offset]; return (255 - this[offset] + 1) * -1; }; - Buffer15.prototype.readInt16LE = function readInt16LE(offset, noAssert) { + Buffer16.prototype.readInt16LE = function readInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); var val = this[offset] | this[offset + 1] << 8; return val & 32768 ? val | 4294901760 : val; }; - Buffer15.prototype.readInt16BE = function readInt16BE(offset, noAssert) { + Buffer16.prototype.readInt16BE = function readInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); var val = this[offset + 1] | this[offset] << 8; return val & 32768 ? val | 4294901760 : val; }; - Buffer15.prototype.readInt32LE = function readInt32LE(offset, noAssert) { + Buffer16.prototype.readInt32LE = function readInt32LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; }; - Buffer15.prototype.readInt32BE = function readInt32BE(offset, noAssert) { + Buffer16.prototype.readInt32BE = function readInt32BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; }; - Buffer15.prototype.readFloatLE = function readFloatLE(offset, noAssert) { + Buffer16.prototype.readFloatLE = function readFloatLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, true, 23, 4); }; - Buffer15.prototype.readFloatBE = function readFloatBE(offset, noAssert) { + Buffer16.prototype.readFloatBE = function readFloatBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, false, 23, 4); }; - Buffer15.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { + Buffer16.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee7542.read(this, offset, true, 52, 8); }; - Buffer15.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { + Buffer16.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee7542.read(this, offset, false, 52, 8); }; function checkInt(buf2, value, offset, ext, max, min) { - if (!Buffer15.isBuffer(buf2)) + if (!Buffer16.isBuffer(buf2)) throw new TypeError('"buffer" argument must be a Buffer instance'); if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); if (offset + ext > buf2.length) throw new RangeError("Index out of range"); } - Buffer15.prototype.writeUintLE = Buffer15.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { + Buffer16.prototype.writeUintLE = Buffer16.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -5462,7 +5462,7 @@ } return offset + byteLength2; }; - Buffer15.prototype.writeUintBE = Buffer15.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { + Buffer16.prototype.writeUintBE = Buffer16.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -5478,7 +5478,7 @@ } return offset + byteLength2; }; - Buffer15.prototype.writeUint8 = Buffer15.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { + Buffer16.prototype.writeUint8 = Buffer16.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -5486,7 +5486,7 @@ this[offset] = value & 255; return offset + 1; }; - Buffer15.prototype.writeUint16LE = Buffer15.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { + Buffer16.prototype.writeUint16LE = Buffer16.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -5495,7 +5495,7 @@ this[offset + 1] = value >>> 8; return offset + 2; }; - Buffer15.prototype.writeUint16BE = Buffer15.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { + Buffer16.prototype.writeUint16BE = Buffer16.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -5504,7 +5504,7 @@ this[offset + 1] = value & 255; return offset + 2; }; - Buffer15.prototype.writeUint32LE = Buffer15.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { + Buffer16.prototype.writeUint32LE = Buffer16.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -5515,7 +5515,7 @@ this[offset] = value & 255; return offset + 4; }; - Buffer15.prototype.writeUint32BE = Buffer15.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { + Buffer16.prototype.writeUint32BE = Buffer16.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -5526,7 +5526,7 @@ this[offset + 3] = value & 255; return offset + 4; }; - Buffer15.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { + Buffer16.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -5545,7 +5545,7 @@ } return offset + byteLength2; }; - Buffer15.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { + Buffer16.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -5564,7 +5564,7 @@ } return offset + byteLength2; }; - Buffer15.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { + Buffer16.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -5574,7 +5574,7 @@ this[offset] = value & 255; return offset + 1; }; - Buffer15.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { + Buffer16.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -5583,7 +5583,7 @@ this[offset + 1] = value >>> 8; return offset + 2; }; - Buffer15.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { + Buffer16.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -5592,7 +5592,7 @@ this[offset + 1] = value & 255; return offset + 2; }; - Buffer15.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { + Buffer16.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -5603,7 +5603,7 @@ this[offset + 3] = value >>> 24; return offset + 4; }; - Buffer15.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { + Buffer16.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -5631,10 +5631,10 @@ ieee7542.write(buf2, value, offset, littleEndian, 23, 4); return offset + 4; } - Buffer15.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { + Buffer16.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert); }; - Buffer15.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { + Buffer16.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert); }; function writeDouble(buf2, value, offset, littleEndian, noAssert) { @@ -5646,14 +5646,14 @@ ieee7542.write(buf2, value, offset, littleEndian, 52, 8); return offset + 8; } - Buffer15.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { + Buffer16.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert); }; - Buffer15.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { + Buffer16.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert); }; - Buffer15.prototype.copy = function copy(target, targetStart, start, end) { - if (!Buffer15.isBuffer(target)) + Buffer16.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer16.isBuffer(target)) throw new TypeError("argument should be a Buffer"); if (!start) start = 0; @@ -5689,7 +5689,7 @@ } return len; }; - Buffer15.prototype.fill = function fill(val, start, end, encoding) { + Buffer16.prototype.fill = function fill(val, start, end, encoding) { if (typeof val === "string") { if (typeof start === "string") { encoding = start; @@ -5702,7 +5702,7 @@ if (encoding !== void 0 && typeof encoding !== "string") { throw new TypeError("encoding must be a string"); } - if (typeof encoding === "string" && !Buffer15.isEncoding(encoding)) { + if (typeof encoding === "string" && !Buffer16.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } if (val.length === 1) { @@ -5732,7 +5732,7 @@ this[i] = val; } } else { - var bytes = Buffer15.isBuffer(val) ? val : Buffer15.from(val, encoding); + var bytes = Buffer16.isBuffer(val) ? val : Buffer16.from(val, encoding); var len = bytes.length; if (len === 0) { throw new TypeError('The value "' + val + '" is invalid for argument "value"'); @@ -7743,12 +7743,12 @@ return Constructor; } var _require = require_buffer(); - var Buffer15 = _require.Buffer; + var Buffer16 = _require.Buffer; var _require2 = require_util(); var inspect = _require2.inspect; var custom = inspect && inspect.custom || "inspect"; function copyBuffer(src, target, offset) { - Buffer15.prototype.copy.call(src, target, offset); + Buffer16.prototype.copy.call(src, target, offset); } module.exports = /* @__PURE__ */ function() { function BufferList() { @@ -7818,8 +7818,8 @@ key: "concat", value: function concat(n) { if (this.length === 0) - return Buffer15.alloc(0); - var ret = Buffer15.allocUnsafe(n >>> 0); + return Buffer16.alloc(0); + var ret = Buffer16.allocUnsafe(n >>> 0); var p = this.head; var i = 0; while (p) { @@ -7884,7 +7884,7 @@ }, { key: "_getBuffer", value: function _getBuffer(n) { - var ret = Buffer15.allocUnsafe(n); + var ret = Buffer16.allocUnsafe(n); var p = this.head; var c = 1; p.data.copy(ret); @@ -8249,14 +8249,14 @@ deprecate: require_browser() }; var Stream = require_stream_browser(); - var Buffer15 = require_buffer().Buffer; + var Buffer16 = require_buffer().Buffer; var OurUint8Array = window.Uint8Array || function() { }; function _uint8ArrayToBuffer(chunk) { - return Buffer15.from(chunk); + return Buffer16.from(chunk); } function _isUint8Array(obj) { - return Buffer15.isBuffer(obj) || obj instanceof OurUint8Array; + return Buffer16.isBuffer(obj) || obj instanceof OurUint8Array; } var destroyImpl = require_destroy(); var _require = require_state(); @@ -8393,7 +8393,7 @@ var state = this._writableState; var ret = false; var isBuf = !state.objectMode && _isUint8Array(chunk); - if (isBuf && !Buffer15.isBuffer(chunk)) { + if (isBuf && !Buffer16.isBuffer(chunk)) { chunk = _uint8ArrayToBuffer(chunk); } if (typeof encoding === "function") { @@ -8441,7 +8441,7 @@ }); function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") { - chunk = Buffer15.from(chunk, encoding); + chunk = Buffer16.from(chunk, encoding); } return chunk; } @@ -8812,34 +8812,34 @@ "node_modules/safe-buffer/index.js"(exports, module) { init_esbuild_inject(); var buffer = require_buffer(); - var Buffer15 = buffer.Buffer; + var Buffer16 = buffer.Buffer; function copyProps(src, dst) { for (var key in src) { dst[key] = src[key]; } } - if (Buffer15.from && Buffer15.alloc && Buffer15.allocUnsafe && Buffer15.allocUnsafeSlow) { + if (Buffer16.from && Buffer16.alloc && Buffer16.allocUnsafe && Buffer16.allocUnsafeSlow) { module.exports = buffer; } else { copyProps(buffer, exports); exports.Buffer = SafeBuffer; } function SafeBuffer(arg, encodingOrOffset, length) { - return Buffer15(arg, encodingOrOffset, length); + return Buffer16(arg, encodingOrOffset, length); } - SafeBuffer.prototype = Object.create(Buffer15.prototype); - copyProps(Buffer15, SafeBuffer); + SafeBuffer.prototype = Object.create(Buffer16.prototype); + copyProps(Buffer16, SafeBuffer); SafeBuffer.from = function(arg, encodingOrOffset, length) { if (typeof arg === "number") { throw new TypeError("Argument must not be a number"); } - return Buffer15(arg, encodingOrOffset, length); + return Buffer16(arg, encodingOrOffset, length); }; SafeBuffer.alloc = function(size, fill, encoding) { if (typeof size !== "number") { throw new TypeError("Argument must be a number"); } - var buf2 = Buffer15(size); + var buf2 = Buffer16(size); if (fill !== void 0) { if (typeof encoding === "string") { buf2.fill(fill, encoding); @@ -8855,7 +8855,7 @@ if (typeof size !== "number") { throw new TypeError("Argument must be a number"); } - return Buffer15(size); + return Buffer16(size); }; SafeBuffer.allocUnsafeSlow = function(size) { if (typeof size !== "number") { @@ -8871,8 +8871,8 @@ "node_modules/string_decoder/lib/string_decoder.js"(exports) { "use strict"; init_esbuild_inject(); - var Buffer15 = require_safe_buffer().Buffer; - var isEncoding = Buffer15.isEncoding || function(encoding) { + var Buffer16 = require_safe_buffer().Buffer; + var isEncoding = Buffer16.isEncoding || function(encoding) { encoding = "" + encoding; switch (encoding && encoding.toLowerCase()) { case "hex": @@ -8922,7 +8922,7 @@ } function normalizeEncoding(enc) { var nenc = _normalizeEncoding(enc); - if (typeof nenc !== "string" && (Buffer15.isEncoding === isEncoding || !isEncoding(enc))) + if (typeof nenc !== "string" && (Buffer16.isEncoding === isEncoding || !isEncoding(enc))) throw new Error("Unknown encoding: " + enc); return nenc || enc; } @@ -8952,7 +8952,7 @@ } this.lastNeed = 0; this.lastTotal = 0; - this.lastChar = Buffer15.allocUnsafe(nb); + this.lastChar = Buffer16.allocUnsafe(nb); } StringDecoder.prototype.write = function(buf2) { if (buf2.length === 0) @@ -9421,14 +9421,14 @@ return emitter.listeners(type).length; }; var Stream = require_stream_browser(); - var Buffer15 = require_buffer().Buffer; + var Buffer16 = require_buffer().Buffer; var OurUint8Array = window.Uint8Array || function() { }; function _uint8ArrayToBuffer(chunk) { - return Buffer15.from(chunk); + return Buffer16.from(chunk); } function _isUint8Array(obj) { - return Buffer15.isBuffer(obj) || obj instanceof OurUint8Array; + return Buffer16.isBuffer(obj) || obj instanceof OurUint8Array; } var debugUtil = require_util(); var debug; @@ -9543,7 +9543,7 @@ if (typeof chunk === "string") { encoding = encoding || state.defaultEncoding; if (encoding !== state.encoding) { - chunk = Buffer15.from(chunk, encoding); + chunk = Buffer16.from(chunk, encoding); encoding = ""; } skipChunkCheck = true; @@ -9569,7 +9569,7 @@ if (er) { errorOrDestroy(stream, er); } else if (state.objectMode || chunk && chunk.length > 0) { - if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer15.prototype) { + if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer16.prototype) { chunk = _uint8ArrayToBuffer(chunk); } if (addToFront) { @@ -10486,7 +10486,7 @@ // src/main.ts init_esbuild_inject(); - var import_buffer8 = __toESM(require_buffer(), 1); + var import_buffer9 = __toESM(require_buffer(), 1); // src/stores.ts init_esbuild_inject(); @@ -11284,29 +11284,37 @@ const can = document.createElement("canvas"); can.width = 125; can.height = 125; - const ctx = can.getContext("2d"); - if (!ctx) - return import_buffer2.Buffer.alloc(0); const [sw, sh] = [125, 125]; const url = URL.createObjectURL(f); + let source; + let iw, ih; if (f.type.startsWith("image")) { const imgElem = document.createElement("img"); imgElem.src = url; await new Promise((_) => imgElem.onload = _); - const [iw, ih] = [imgElem.naturalWidth, imgElem.naturalHeight]; - const scale = Math.min(1, sw / iw, sh / ih); - const dims = [~~(iw * scale), ~~(ih * scale)]; - ctx.drawImage(imgElem, 0, 0, dims[0], dims[1]); + [iw, ih] = [imgElem.naturalWidth, imgElem.naturalHeight]; + source = imgElem; } else if (f.type.startsWith("video")) { const vidElem = document.createElement("video"); vidElem.src = url; await new Promise((_) => vidElem.onloadedmetadata = _); - const [iw, ih] = [vidElem.videoWidth, vidElem.videoHeight]; - const scale = Math.min(1, sw / iw, sh / ih); - const dims = [~~(iw * scale), ~~(ih * scale)]; - ctx.drawImage(vidElem, 0, 0, dims[0], dims[1]); + vidElem.currentTime = 0; + await new Promise((_) => vidElem.onloadeddata = _); + await new Promise(requestAnimationFrame); + await new Promise(requestAnimationFrame); + await new Promise(requestAnimationFrame); + [iw, ih] = [vidElem.videoWidth, vidElem.videoHeight]; + source = vidElem; } else return import_buffer2.Buffer.alloc(0); + const scale = Math.min(1, sw / iw, sh / ih); + const dims = [~~(iw * scale), ~~(ih * scale)]; + can.width = dims[0]; + can.height = dims[1]; + const ctx = can.getContext("2d"); + if (!ctx) + return import_buffer2.Buffer.alloc(0); + ctx.drawImage(source, 0, 0, dims[0], dims[1]); const blob = await new Promise((_) => can.toBlob(_, "image/jpg")); if (!blob) return import_buffer2.Buffer.alloc(0); @@ -11348,6 +11356,8 @@ let hptr = 0; if (header.slice(0, 4).toString() == "PEE\0") hptr += 4; + else + return; const flags = header[hptr]; const hasFn = !!(flags & 1); const hasTags = !!(flags & 2); @@ -11380,7 +11390,7 @@ } catch (e) { console.warn(e); } - }))).map((e) => e); + }))).filter((e) => e); }; var fireNotification = (level, text2, lifetime = 3) => { document.dispatchEvent(new CustomEvent("CreateNotification", { @@ -11464,13 +11474,11 @@ }); return [ret, () => b]; }; - var inject = async (container, injs) => { + var inject_data = async (container, injb) => { + let magic2 = false; const [writestream, extract6] = BufferWriteStream2(); const encoder = new PNGEncoder(writestream); const decoder = new PNGDecoder(container.stream().getReader()); - let magic2 = false; - const links = await uploadFiles(injs); - const injb = import_buffer3.Buffer.from(links.join(" ")); for await (const [name, chunk, crc, offset] of decoder.chunks()) { if (magic2 && name != "IDAT") break; @@ -11488,6 +11496,11 @@ ]); return extract6(); }; + var inject = async (container, injs) => { + const links = await uploadFiles(injs); + const injb = import_buffer3.Buffer.from(links.join(" ")); + return inject_data(container, injb); + }; var has_embed = async (png) => { const reader = BufferReadStream(png).getReader(); const sneed = new PNGDecoder(reader); @@ -11757,9 +11770,66 @@ match: (fn) => !!fn.match(/\.gif$/) }; - // src/thirdeye.ts + // src/jpg.ts init_esbuild_inject(); var import_buffer6 = __toESM(require_buffer(), 1); + var convertToPng = async (f) => { + const can = document.createElement("canvas"); + const url = URL.createObjectURL(f); + try { + let dims; + let source; + if (f.type.startsWith("image")) { + const imgElem = document.createElement("img"); + imgElem.src = url; + await new Promise((_) => imgElem.onload = _); + dims = [imgElem.naturalWidth, imgElem.naturalHeight]; + source = imgElem; + } else if (f.type.startsWith("video")) { + const vidElem = document.createElement("video"); + vidElem.src = url; + await new Promise((_) => vidElem.onloadedmetadata = _); + vidElem.currentTime = 0; + await new Promise((_) => vidElem.onloadeddata = _); + await new Promise(requestAnimationFrame); + await new Promise(requestAnimationFrame); + await new Promise(requestAnimationFrame); + dims = [vidElem.videoWidth, vidElem.videoHeight]; + source = vidElem; + } else + return; + can.width = dims[0]; + can.height = dims[1]; + const ctx = can.getContext("2d"); + if (!ctx) + return; + ctx.drawImage(source, 0, 0, dims[0], dims[1]); + const blob = await new Promise((_) => can.toBlob(_, "image/png")); + if (!blob) + return; + return blob; + } finally { + URL.revokeObjectURL(url); + } + }; + var inject4 = async (b, c) => { + const pngfile = await convertToPng(b); + if (!pngfile || pngfile.size > 3e3 * 1024) { + throw "Couldn't convert file to PNG: resulting filesize too big."; + } + return pngv3_default.inject(b, c); + }; + var jpg_default = { + skip: true, + match: (fn) => !!fn.match(/\.jpe?g$/), + has_embed: () => false, + extract: () => [], + inject: inject4 + }; + + // src/thirdeye.ts + init_esbuild_inject(); + var import_buffer7 = __toESM(require_buffer(), 1); var csettings2; settings.subscribe((b) => { csettings2 = b; @@ -11877,7 +11947,7 @@ }]; }; var has_embed4 = async (b, fn) => { - if (import_buffer6.Buffer.from(fn, "hex").equals(b)) + if (import_buffer7.Buffer.from(fn, "hex").equals(b)) return false; let result = void 0; for (const e of Object.values(boorus)) { @@ -11913,12 +11983,15 @@ const isB64 = fn.match(/^((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=))?\.(gif|jpe?g|png|webm)/); const isExt = fn.match(/\[.*=(.*)\]/); let ext; - if (isDum) { - ext = fn.split(".").slice(0, -1).join("."); - } else if (isB64) { - ext = atob(isB64[1]); - } else if (isExt) { - ext = isExt[1]; + try { + if (isDum) { + ext = fn.split(".").slice(0, -1).join("."); + } else if (isB64) { + ext = atob(isB64[1]); + } else if (isExt) { + ext = isExt[1]; + } + } catch { } return ext; }; @@ -16429,7 +16502,7 @@ // src/EyeButton.svelte init_esbuild_inject(); - var import_buffer7 = __toESM(require_buffer(), 1); + var import_buffer8 = __toESM(require_buffer(), 1); function add_css7(target) { append_styles(target, "svelte-64lw6s", ".clickable.svelte-64lw6s{cursor:pointer;margin-left:5px}.clickable.svelte-64lw6s:hover{text-shadow:0 0 4px palevioletred}"); } @@ -16763,7 +16836,7 @@ a.style.display = "none"; let url; if (typeof file.data != "string") { - const thumb = import_buffer7.Buffer.isBuffer(file.data) ? file.data : await file.data(); + const thumb = import_buffer8.Buffer.isBuffer(file.data) ? file.data : await file.data(); const type = await fileTypeFromBuffer(thumb); url = URL.createObjectURL(new Blob([thumb], { type: type?.mime })); } else @@ -16830,7 +16903,7 @@ // src/main.ts var csettings4; - var processors = [thirdeye_default, pomf_default, pngv3_default, webm_default, gif_default]; + var processors = [thirdeye_default, pomf_default, pngv3_default, jpg_default, webm_default, gif_default]; var cappState; settings.subscribe((b) => { csettings4 = b; @@ -16838,6 +16911,7 @@ ...!csettings4.te ? [thirdeye_default] : [], pngv3_default, pomf_default, + jpg_default, webm_default, gif_default ]; @@ -16862,7 +16936,7 @@ ptr += len; if (fetchRestOnNonCanceled) fetchSize = size; - const val = import_buffer8.Buffer.from(await res.arrayBuffer()); + const val = import_buffer9.Buffer.from(await res.arrayBuffer()); const e = yield val; if (e) { break; @@ -16872,7 +16946,7 @@ var processImage = async (src, fn, hex) => { return Promise.all(processors.filter((e) => e.match(fn)).map(async (proc) => { if (proc.skip) { - const md5 = import_buffer8.Buffer.from(hex, "base64"); + const md5 = import_buffer9.Buffer.from(hex, "base64"); if (await proc.has_embed(md5, fn) === true) return [await proc.extract(md5, fn), true]; return; @@ -16880,7 +16954,7 @@ const iter = streamRemote(src); if (!iter) return; - let cumul = import_buffer8.Buffer.alloc(0); + let cumul = import_buffer9.Buffer.alloc(0); let found; let chunk = { done: true }; do { @@ -16891,7 +16965,7 @@ chunk = { done: false, value }; } if (!done) - cumul = import_buffer8.Buffer.concat([cumul, value]); + cumul = import_buffer9.Buffer.concat([cumul, value]); found = await proc.has_embed(cumul); } while (found !== false && !chunk.done); await iter.next(true); @@ -16920,6 +16994,73 @@ fireNotification("info", `Last PEE version is ${lmajor}.${lminor}, you're on ${major}.${minor}`); } }; + var scrapeBoard = async (self) => { + self.disabled = true; + self.textContent = "Searching..."; + const boardname = location.pathname.match(/\/(.*)\//)[1]; + const res = await GM_fetch(`https://a.4cdn.org/${boardname}/threads.json`); + const pages = await res.json(); + fireNotification("info", "Fetching all threads..."); + const threads = await Promise.all(pages.reduce((a, b) => [...a, ...b.threads], []).map((e) => e.no).map((id) => GM_fetch(`https://a.4cdn.org/${boardname}/thread/${id}.json`).then((e) => e.json()))); + const filenames = threads.reduce((a, b) => [...a, ...b.posts.filter((p) => p.ext).map((p) => p)], []).filter((p) => p.ext != ".webm" && p.ext != ".gif").map((p) => [p.resto, `https://i.4cdn.org/${boardname}/${p.tim}${p.ext}`, p.md5, p.filename + p.ext]); + console.log(filenames); + fireNotification("info", "Analyzing images..."); + const n = 7; + const processFile = (src, fn, hex) => { + return Promise.all(processors.filter((e) => e.match(fn)).map(async (proc) => { + if (proc.skip) { + const md5 = import_buffer9.Buffer.from(hex, "base64"); + return await proc.has_embed(md5, fn); + } + const iter = streamRemote(src); + if (!iter) + return false; + let cumul = import_buffer9.Buffer.alloc(0); + let found; + let chunk = { done: true }; + do { + const { value, done } = await iter.next(found === false); + if (done) { + chunk = { done: true }; + } else { + chunk = { done: false, value }; + } + if (!done) + cumul = import_buffer9.Buffer.concat([cumul, value]); + found = await proc.has_embed(cumul); + } while (found !== false && !chunk.done); + await iter.next(true); + return found === true; + })); + }; + const range = ~~(filenames.length / n) + 1; + const hasEmbed = []; + const total = filenames.length; + let processed = 0; + const int = setInterval(() => { + fireNotification("info", `Processed [${processed} / ${total}] files`); + }, 5e3); + await Promise.all([...new Array(n + 1)].map(async (e, i) => { + const postsslice = filenames.slice(i * range, (i + 1) * range); + for (const post of postsslice) { + try { + const res2 = await processFile(post[1], post[3], post[2]); + processed++; + if (res2.some((e2) => e2)) { + hasEmbed.push(post); + } + } catch (e2) { + console.log(e2); + } + } + })); + clearInterval(int); + const counters = {}; + for (const k of hasEmbed) + counters[k[0]] = k[0] in counters ? counters[k[0]] + 1 : 1; + console.log(counters); + fireNotification("success", "Processing finished!"); + }; var startup = async () => { if (typeof window["FCX"] != "undefined") appState.set({ ...cappState, is4chanX: true }); @@ -16958,6 +17099,13 @@ ...cappState, isCatalog: !!document.querySelector(".catalog-small") || !!location.pathname.match(/\/catalog$/) }); + if (cappState.isCatalog) { + const opts = document.getElementById("index-options"); + const button2 = document.createElement("button"); + button2.textContent = "\u304A\u3082\u3089\u3057"; + button2.onclick = () => scrapeBoard(button2); + opts.insertAdjacentElement("beforebegin", button2); + } const n = 7; const range = ~~(posts.length / n) + 1; await Promise.all([...new Array(n + 1)].map(async (e, i) => { @@ -17107,6 +17255,19 @@ } post.setAttribute("data-processed", "true"); } + if (window["pagemode"]) { + onload = () => { + const resbuf = async (s) => typeof s != "string" && (import_buffer9.Buffer.isBuffer(s) ? s : await s()); + const container = document.getElementById("container"); + container.onchange = async () => { + const result = document.getElementById("result"); + const output = await convertToPng(container.files[0]); + if (!output) + return; + result.src = URL.createObjectURL(output); + }; + }; + } })(); /*! * The buffer module from node.js, for the browser. diff --git a/src/jpg.ts b/src/jpg.ts index 3453f75..517b34a 100644 --- a/src/jpg.ts +++ b/src/jpg.ts @@ -3,7 +3,7 @@ import type { ImageProcessor } from "./main"; import pngv3 from "./pngv3"; import { fireNotification } from "./utils"; -const convertToPng = async (f: File): Promise => { +export const convertToPng = async (f: File): Promise => { const can = document.createElement("canvas"); const url = URL.createObjectURL(f); @@ -22,6 +22,9 @@ const convertToPng = async (f: File): Promise => { await new Promise(_ => vidElem.onloadedmetadata = _); vidElem.currentTime = 0; await new Promise(_ => vidElem.onloadeddata = _); + await new Promise(requestAnimationFrame); + await new Promise(requestAnimationFrame); + await new Promise(requestAnimationFrame); dims = [vidElem.videoWidth, vidElem.videoHeight]; source = vidElem; } else @@ -29,6 +32,7 @@ const convertToPng = async (f: File): Promise => { can.width = dims[0]; can.height = dims[1]; const ctx = can.getContext("2d"); + if (!ctx) return; ctx.drawImage(source, 0, 0, dims[0], dims[1]); diff --git a/src/main.ts b/src/main.ts index c563e4e..f18e4c6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,9 +2,10 @@ import { Buffer } from "buffer"; import { appState, settings } from "./stores"; import globalCss from './global.css'; -import pngv3 from "./pngv3"; +import pngv3, { inject_data } from "./pngv3"; import webm from "./webm"; import gif from "./gif"; +import jpg, { convertToPng } from "./jpg"; import thirdeye from "./thirdeye"; import pomf from "./pomf"; @@ -29,12 +30,13 @@ export interface ImageProcessor { export let csettings: Parameters[0]; let processors: ImageProcessor[] = - [thirdeye, pomf, pngv3, webm, gif]; + [thirdeye, pomf, pngv3, jpg, webm, gif]; let cappState: Parameters[0]; settings.subscribe(b => { csettings = b; - processors = [...(!csettings.te ? [thirdeye] : []), pngv3, pomf, webm, gif + processors = [...(!csettings.te ? [thirdeye] : []), + pngv3, pomf, jpg, webm, gif ]; }); @@ -155,6 +157,93 @@ const versionCheck = async () => { } }; +const scrapeBoard = async (self: HTMLButtonElement) => { + self.disabled = true; + self.textContent = "Searching..."; + const boardname = location.pathname.match(/\/(.*)\//)![1]; + const res = await GM_fetch(`https://a.4cdn.org/${boardname}/threads.json`); + const pages = await res.json() as Page[]; + type Page = { threads: Thread[] } + type Thread = { no: number; posts: Post[] }; + type BasePost = { resto: number, tim: number }; + type PostWithFile = BasePost & { tim: number, ext: string, md5: string, filename: string }; + type PostWithoutFile = BasePost & Record; + type Post = (PostWithoutFile | PostWithFile); + fireNotification("info", "Fetching all threads..."); + const threads = await Promise.all(pages + .reduce((a: Thread[], b: Page) => [...a, ...b.threads], []) + .map(e => e.no) + .map(id => GM_fetch(`https://a.4cdn.org/${boardname}/thread/${id}.json`).then(e => e.json() as Promise))); + const filenames = threads + .reduce((a, b) => [...a, ...b.posts.filter(p => p.ext) + .map(p => p as PostWithFile)], [] as PostWithFile[]).filter(p => p.ext != '.webm' && p.ext != '.gif') + .map(p => [p.resto, `https://i.4cdn.org/${boardname}/${p.tim}${p.ext}`, p.md5, p.filename + p.ext] as [number, string, string, string]); + + console.log(filenames); + fireNotification("info", "Analyzing images..."); + const n = 7; + //console.log(posts); + const processFile = (src: string, fn: string, hex: string) => { + return Promise.all(processors.filter(e => e.match(fn)).map(async proc => { + if (proc.skip) { + const md5 = Buffer.from(hex, 'base64'); + return await proc.has_embed(md5, fn); + } + // TODO: Move this outside the loop? + const iter = streamRemote(src); + if (!iter) + return false; + let cumul = Buffer.alloc(0); + let found: boolean | undefined; + let chunk: ReadableStreamDefaultReadResult = { done: true }; + do { + const { value, done } = await iter.next(found === false); + if (done) { + chunk = { done: true } as ReadableStreamDefaultReadDoneResult; + } else { + chunk = { done: false, value } as ReadableStreamDefaultReadValueResult; + } + if (!done) + cumul = Buffer.concat([cumul, value!]); + found = await proc.has_embed(cumul); + } while (found !== false && !chunk.done); + await iter.next(true); + return found === true; + })); + }; + const range = ~~(filenames.length / n) + 1; + const hasEmbed: typeof filenames = []; + const total = filenames.length; + let processed = 0; + + const int = setInterval(() => { + fireNotification("info", `Processed [${processed} / ${total}] files`); + }, 5000); + + await Promise.all([...new Array(n + 1)].map(async (e, i) => { + const postsslice = filenames.slice(i * range, (i + 1) * range); + for (const post of postsslice) { + try { + const res = await processFile(post[1], post[3], post[2]); + processed++; + if (res.some(e => e)) { + hasEmbed.push(post); + } + } catch (e) { + console.log(e); + } + } + })); + + clearInterval(int); + + const counters: Record = {}; + for (const k of hasEmbed) + counters[k[0]] = k[0] in counters ? counters[k[0]] + 1 : 1; + console.log(counters); + fireNotification("success", "Processing finished!"); +}; + const startup = async () => { if (typeof (window as any)['FCX'] != "undefined") appState.set({ ...cappState, is4chanX: true }); @@ -205,6 +294,15 @@ const startup = async () => { }); //await processPost(posts[0] as any); + if (cappState.isCatalog) { + const opts = document.getElementById('index-options') as HTMLDivElement; + const button = document.createElement('button'); + button.textContent = "おもらし"; + button.onclick = () => scrapeBoard(button); + opts.insertAdjacentElement("beforebegin", button); + + } + const n = 7; //console.log(posts); const range = ~~(posts.length / n) + 1; @@ -395,33 +493,31 @@ function parseForm(data: object) { return form; } -// if ((window as any)['pagemode']) { -// onload = () => { -// const resbuf = async (s: EmbeddedFile['data']) => typeof s != "string" && (Buffer.isBuffer(s) ? s : await s()); -// const container = document.getElementById("container") as HTMLInputElement; -// const injection = document.getElementById("injection") as HTMLInputElement; -// container.onchange = async () => { -// const ret = await fetch("https://catbox.moe/user/api.php", { -// method: 'POST', -// body: parseForm({ -// reqtype: 'fileupload', -// fileToUpload: container.files![0] -// }) -// }); -// console.log(ret); -// console.log(await ret.text()); -// }; -// }; -// } +if ((window as any)['pagemode']) { + onload = () => { + const resbuf = async (s: EmbeddedFile['data']) => typeof s != "string" && (Buffer.isBuffer(s) ? s : await s()); + const container = document.getElementById("container") as HTMLInputElement; + container.onchange = async () => { + const result = document.getElementById("result") as HTMLImageElement; + const output = await convertToPng(container.files![0]); + if (!output) + return; + result.src = URL.createObjectURL(output); + }; + }; +} -// if ((window as any)['pagemode']) { -// onload = () => { -// const extraction = document.getElementById("extraction") as HTMLInputElement; -// /* extraction.onchange = async () => { -// const pee = await buildPeeFile(extraction.files![0]); -// const dlr = document.getElementById("dlr") as HTMLAnchorElement; -// dlr.href = URL.createObjectURL(pee); -// };*/ +//if ((window as any)['pagemode']) { +// onload = () => { +// const extraction = document.getElementById("extraction") as HTMLInputElement; +// extraction.onchange = async () => { +// const pee = await convertToPng(extraction.files![0]); +// const result = document.getElementById("result") as HTMLImageElement; +// const data = await inject_data(new File([pee!], 'image.png', { type: "image/png" }), Buffer.from("coom")); +// result.src = URL.createObjectURL(new Blob([data])); +// }; +// }; +//} // document.addEventListener("CreateNotification", (e: any) => console.log(e.detail)); // console.log("loaded"); diff --git a/src/pngv3.ts b/src/pngv3.ts index a260e70..5db7a55 100644 --- a/src/pngv3.ts +++ b/src/pngv3.ts @@ -63,15 +63,12 @@ export const BufferWriteStream = () => { return [ret, () => b] as [WritableStream, () => Buffer]; }; -const inject = async (container: File, injs: File[]) => { +export const inject_data = async (container: File, injb: Buffer) => { + let magic = false; const [writestream, extract] = BufferWriteStream(); const encoder = new PNGEncoder(writestream); const decoder = new PNGDecoder(container.stream().getReader()); - let magic = false; - const links = await uploadFiles(injs); - const injb = Buffer.from(links.join(' ')); - for await (const [name, chunk, crc, offset] of decoder.chunks()) { if (magic && name != "IDAT") break; @@ -86,6 +83,13 @@ const inject = async (container: File, injs: File[]) => { async () => Promise.resolve(0), 0]); return extract(); + +}; + +const inject = async (container: File, injs: File[]) => { + const links = await uploadFiles(injs); + const injb = Buffer.from(links.join(' ')); + return inject_data(container, injb); }; const has_embed = async (png: Buffer) => { diff --git a/src/pomf.ts b/src/pomf.ts index d0b31dd..8b96026 100644 --- a/src/pomf.ts +++ b/src/pomf.ts @@ -20,12 +20,16 @@ const getExt = (fn: string) => { const isB64 = fn!.match(/^((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=))?\.(gif|jpe?g|png|webm)/); const isExt = fn!.match(/\[.*=(.*)\]/); let ext; - if (isDum) { - ext = fn.split('.').slice(0, -1).join('.'); - } else if (isB64) { - ext = atob(isB64[1]); - } else if (isExt) { - ext = isExt[1]; + try { + if (isDum) { + ext = fn.split('.').slice(0, -1).join('.'); + } else if (isB64) { + ext = atob(isB64[1]); + } else if (isExt) { + ext = isExt[1]; + } + } catch { + /**/ } return ext; }; diff --git a/src/requests.ts b/src/requests.ts index 9414fb8..b7e6f8d 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -52,7 +52,7 @@ export let GM_fetch = (...[url, opt, lisn]: [...Parameters, EventT else reject("unknown to"); }); } - return new Promise>((resolve, reject) => { + return new Promise>>((resolve, reject) => { // https://www.tampermonkey.net/documentation.php?ext=dhdg#GM_xmlhttpRequest const gmopt: Tampermonkey.Request = { url: url.toString(), diff --git a/src/utils.ts b/src/utils.ts index ca114c8..5a63160 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,32 +7,45 @@ const generateThumbnail = async (f: File): Promise => { const can = document.createElement("canvas"); can.width = 125; can.height = 125; - const ctx = can.getContext("2d"); - - if (!ctx) - return Buffer.alloc(0); const [sw, sh] = [125, 125]; const url = URL.createObjectURL(f); + let source: CanvasImageSource; + let iw: number, ih: number; if (f.type.startsWith("image")) { const imgElem = document.createElement('img'); imgElem.src = url; await new Promise(_ => imgElem.onload = _); - const [iw, ih] = [imgElem.naturalWidth, imgElem.naturalHeight]; - const scale = Math.min(1, sw / iw, sh / ih); - const dims = [~~(iw * scale), ~~(ih * scale)] as [number, number]; - ctx.drawImage(imgElem, 0, 0, dims[0], dims[1]); + [iw, ih] = [imgElem.naturalWidth, imgElem.naturalHeight]; + source = imgElem; } else if (f.type.startsWith("video")) { const vidElem = document.createElement('video'); vidElem.src = url; await new Promise(_ => vidElem.onloadedmetadata = _); - const [iw, ih] = [vidElem.videoWidth, vidElem.videoHeight]; - const scale = Math.min(1, sw / iw, sh / ih); - const dims = [~~(iw * scale), ~~(ih * scale)] as [number, number]; - ctx.drawImage(vidElem, 0, 0, dims[0], dims[1]); + vidElem.currentTime = 0; + await new Promise(_ => vidElem.onloadeddata = _); + await new Promise(requestAnimationFrame); + await new Promise(requestAnimationFrame); + await new Promise(requestAnimationFrame); + [iw, ih] = [vidElem.videoWidth, vidElem.videoHeight]; + source = vidElem; } else return Buffer.alloc(0); + + const scale = Math.min(1, sw / iw, sh / ih); + const dims = [~~(iw * scale), ~~(ih * scale)] as [number, number]; + + can.width = dims[0]; + can.height = dims[1]; + + const ctx = can.getContext("2d"); + + if (!ctx) + return Buffer.alloc(0); + + ctx.drawImage(source, 0, 0, dims[0], dims[1]); + const blob = await new Promise(_ => can.toBlob(_, "image/jpg")); if (!blob) return Buffer.alloc(0); @@ -88,6 +101,8 @@ export const decodeCoom3Payload = async (buff: Buffer) => { let hptr = 0; if (header.slice(0, 4).toString() == "PEE\0") hptr += 4; + else + return; const flags = header[hptr]; const hasFn = !!(flags & 1); const hasTags = !!(flags & 2); @@ -122,7 +137,7 @@ export const decodeCoom3Payload = async (buff: Buffer) => { // niggers trying to fuck with bad links console.warn(e); } - }))).map(e => e); + }))).filter(e => e); }; export const fireNotification = (level: 'success' | 'error' | 'info' | 'warning', text: string, lifetime = 3) => {