From ce67bff71933364c7ce9881953b2032da60b45ef Mon Sep 17 00:00:00 2001 From: coomdev Date: Thu, 13 Jan 2022 13:55:57 +0100 Subject: [PATCH] Fix PNG embedding --- main.meta.js | 2 +- main.user.js | 507 ++++++++++++++++++++++++++------------------------- src/png.ts | 8 +- 3 files changed, 261 insertions(+), 256 deletions(-) diff --git a/main.meta.js b/main.meta.js index 8c073da..6e539e6 100644 --- a/main.meta.js +++ b/main.meta.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.133 +// @version 0.135 // @description uhh // @author You // @match https://boards.4channel.org/* diff --git a/main.user.js b/main.user.js index 3ee00dd..c3386c3 100644 --- a/main.user.js +++ b/main.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.133 +// @version 0.135 // @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 = Buffer14; + exports.Buffer = Buffer15; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; var K_MAX_LENGTH = 2147483647; exports.kMaxLength = K_MAX_LENGTH; - Buffer14.TYPED_ARRAY_SUPPORT = typedArraySupport(); - if (!Buffer14.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { + Buffer15.TYPED_ARRAY_SUPPORT = typedArraySupport(); + if (!Buffer15.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(Buffer14.prototype, "parent", { + Object.defineProperty(Buffer15.prototype, "parent", { enumerable: true, get: function() { - if (!Buffer14.isBuffer(this)) + if (!Buffer15.isBuffer(this)) return void 0; return this.buffer; } }); - Object.defineProperty(Buffer14.prototype, "offset", { + Object.defineProperty(Buffer15.prototype, "offset", { enumerable: true, get: function() { - if (!Buffer14.isBuffer(this)) + if (!Buffer15.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, Buffer14.prototype); + Object.setPrototypeOf(buf2, Buffer15.prototype); return buf2; } - function Buffer14(arg, encodingOrOffset, length) { + function Buffer15(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); } - Buffer14.poolSize = 8192; + Buffer15.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 Buffer14.from(valueOf, encodingOrOffset, length); + return Buffer15.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 Buffer14.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); + return Buffer15.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); } - Buffer14.from = function(value, encodingOrOffset, length) { + Buffer15.from = function(value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }; - Object.setPrototypeOf(Buffer14.prototype, Uint8Array.prototype); - Object.setPrototypeOf(Buffer14, Uint8Array); + Object.setPrototypeOf(Buffer15.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer15, 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); } - Buffer14.alloc = function(size, fill, encoding) { + Buffer15.alloc = function(size, fill, encoding) { return alloc(size, fill, encoding); }; function allocUnsafe(size) { assertSize(size); return createBuffer(size < 0 ? 0 : checked(size) | 0); } - Buffer14.allocUnsafe = function(size) { + Buffer15.allocUnsafe = function(size) { return allocUnsafe(size); }; - Buffer14.allocUnsafeSlow = function(size) { + Buffer15.allocUnsafeSlow = function(size) { return allocUnsafe(size); }; function fromString(string, encoding) { if (typeof encoding !== "string" || encoding === "") { encoding = "utf8"; } - if (!Buffer14.isEncoding(encoding)) { + if (!Buffer15.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, Buffer14.prototype); + Object.setPrototypeOf(buf2, Buffer15.prototype); return buf2; } function fromObject(obj) { - if (Buffer14.isBuffer(obj)) { + if (Buffer15.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 Buffer14.alloc(+length); + return Buffer15.alloc(+length); } - Buffer14.isBuffer = function isBuffer(b) { - return b != null && b._isBuffer === true && b !== Buffer14.prototype; + Buffer15.isBuffer = function isBuffer(b) { + return b != null && b._isBuffer === true && b !== Buffer15.prototype; }; - Buffer14.compare = function compare(a, b) { + Buffer15.compare = function compare(a, b) { if (isInstance(a, Uint8Array)) - a = Buffer14.from(a, a.offset, a.byteLength); + a = Buffer15.from(a, a.offset, a.byteLength); if (isInstance(b, Uint8Array)) - b = Buffer14.from(b, b.offset, b.byteLength); - if (!Buffer14.isBuffer(a) || !Buffer14.isBuffer(b)) { + b = Buffer15.from(b, b.offset, b.byteLength); + if (!Buffer15.isBuffer(a) || !Buffer15.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; }; - Buffer14.isEncoding = function isEncoding(encoding) { + Buffer15.isEncoding = function isEncoding(encoding) { switch (String(encoding).toLowerCase()) { case "hex": case "utf8": @@ -499,12 +499,12 @@ return false; } }; - Buffer14.concat = function concat(list, length) { + Buffer15.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 Buffer14.alloc(0); + return Buffer15.alloc(0); } let i; if (length === void 0) { @@ -513,19 +513,19 @@ length += list[i].length; } } - const buffer = Buffer14.allocUnsafe(length); + const buffer = Buffer15.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 (!Buffer14.isBuffer(buf2)) - buf2 = Buffer14.from(buf2); + if (!Buffer15.isBuffer(buf2)) + buf2 = Buffer15.from(buf2); buf2.copy(buffer, pos); } else { Uint8Array.prototype.set.call(buffer, buf2, pos); } - } else if (!Buffer14.isBuffer(buf2)) { + } else if (!Buffer15.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 (Buffer14.isBuffer(string)) { + if (Buffer15.isBuffer(string)) { return string.length; } if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { @@ -576,7 +576,7 @@ } } } - Buffer14.byteLength = byteLength; + Buffer15.byteLength = byteLength; function slowToString(encoding, start, end) { let loweredCase = false; if (start === void 0 || start < 0) { @@ -625,13 +625,13 @@ } } } - Buffer14.prototype._isBuffer = true; + Buffer15.prototype._isBuffer = true; function swap(b, n, m) { const i = b[n]; b[n] = b[m]; b[m] = i; } - Buffer14.prototype.swap16 = function swap16() { + Buffer15.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; }; - Buffer14.prototype.swap32 = function swap32() { + Buffer15.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; }; - Buffer14.prototype.swap64 = function swap64() { + Buffer15.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; }; - Buffer14.prototype.toString = function toString() { + Buffer15.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); }; - Buffer14.prototype.toLocaleString = Buffer14.prototype.toString; - Buffer14.prototype.equals = function equals(b) { - if (!Buffer14.isBuffer(b)) + Buffer15.prototype.toLocaleString = Buffer15.prototype.toString; + Buffer15.prototype.equals = function equals(b) { + if (!Buffer15.isBuffer(b)) throw new TypeError("Argument must be a Buffer"); if (this === b) return true; - return Buffer14.compare(this, b) === 0; + return Buffer15.compare(this, b) === 0; }; - Buffer14.prototype.inspect = function inspect() { + Buffer15.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) { - Buffer14.prototype[customInspectSymbol] = Buffer14.prototype.inspect; + Buffer15.prototype[customInspectSymbol] = Buffer15.prototype.inspect; } - Buffer14.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { + Buffer15.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) { - target = Buffer14.from(target, target.offset, target.byteLength); + target = Buffer15.from(target, target.offset, target.byteLength); } - if (!Buffer14.isBuffer(target)) { + if (!Buffer15.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 = Buffer14.from(val, encoding); + val = Buffer15.from(val, encoding); } - if (Buffer14.isBuffer(val)) { + if (Buffer15.isBuffer(val)) { if (val.length === 0) { return -1; } @@ -851,13 +851,13 @@ } return -1; } - Buffer14.prototype.includes = function includes(val, byteOffset, encoding) { + Buffer15.prototype.includes = function includes(val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1; }; - Buffer14.prototype.indexOf = function indexOf(val, byteOffset, encoding) { + Buffer15.prototype.indexOf = function indexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true); }; - Buffer14.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + Buffer15.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); } - Buffer14.prototype.write = function write2(string, offset, length, encoding) { + Buffer15.prototype.write = function write2(string, offset, length, encoding) { if (offset === void 0) { encoding = "utf8"; length = this.length; @@ -953,7 +953,7 @@ } } }; - Buffer14.prototype.toJSON = function toJSON() { + Buffer15.prototype.toJSON = function toJSON() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) @@ -1075,7 +1075,7 @@ } return res; } - Buffer14.prototype.slice = function slice(start, end) { + Buffer15.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, Buffer14.prototype); + Object.setPrototypeOf(newBuf, Buffer15.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"); } - Buffer14.prototype.readUintLE = Buffer14.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { + Buffer15.prototype.readUintLE = Buffer15.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -1118,7 +1118,7 @@ } return val; }; - Buffer14.prototype.readUintBE = Buffer14.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { + Buffer15.prototype.readUintBE = Buffer15.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) { @@ -1131,37 +1131,37 @@ } return val; }; - Buffer14.prototype.readUint8 = Buffer14.prototype.readUInt8 = function readUInt8(offset, noAssert) { + Buffer15.prototype.readUint8 = Buffer15.prototype.readUInt8 = function readUInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }; - Buffer14.prototype.readUint16LE = Buffer14.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { + Buffer15.prototype.readUint16LE = Buffer15.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | this[offset + 1] << 8; }; - Buffer14.prototype.readUint16BE = Buffer14.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { + Buffer15.prototype.readUint16BE = Buffer15.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] << 8 | this[offset + 1]; }; - Buffer14.prototype.readUint32LE = Buffer14.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { + Buffer15.prototype.readUint32LE = Buffer15.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; }; - Buffer14.prototype.readUint32BE = Buffer14.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { + Buffer15.prototype.readUint32BE = Buffer15.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]); }; - Buffer14.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) { + Buffer15.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)); }); - Buffer14.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) { + Buffer15.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); }); - Buffer14.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readInt8 = function readInt8(offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readInt16LE = function readInt16LE(offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readInt16BE = function readInt16BE(offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readInt32LE = function readInt32LE(offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readInt32BE = function readInt32BE(offset, noAssert) { + Buffer15.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]; }; - Buffer14.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) { + Buffer15.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); }); - Buffer14.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) { + Buffer15.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); }); - Buffer14.prototype.readFloatLE = function readFloatLE(offset, noAssert) { + Buffer15.prototype.readFloatLE = function readFloatLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, true, 23, 4); }; - Buffer14.prototype.readFloatBE = function readFloatBE(offset, noAssert) { + Buffer15.prototype.readFloatBE = function readFloatBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, false, 23, 4); }; - Buffer14.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { + Buffer15.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee7542.read(this, offset, true, 52, 8); }; - Buffer14.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { + Buffer15.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 (!Buffer14.isBuffer(buf2)) + if (!Buffer15.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"); } - Buffer14.prototype.writeUintLE = Buffer14.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { + Buffer15.prototype.writeUintLE = Buffer15.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -1321,7 +1321,7 @@ } return offset + byteLength2; }; - Buffer14.prototype.writeUintBE = Buffer14.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { + Buffer15.prototype.writeUintBE = Buffer15.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -1337,7 +1337,7 @@ } return offset + byteLength2; }; - Buffer14.prototype.writeUint8 = Buffer14.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { + Buffer15.prototype.writeUint8 = Buffer15.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; }; - Buffer14.prototype.writeUint16LE = Buffer14.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { + Buffer15.prototype.writeUint16LE = Buffer15.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; }; - Buffer14.prototype.writeUint16BE = Buffer14.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { + Buffer15.prototype.writeUint16BE = Buffer15.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; }; - Buffer14.prototype.writeUint32LE = Buffer14.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { + Buffer15.prototype.writeUint32LE = Buffer15.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; }; - Buffer14.prototype.writeUint32BE = Buffer14.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { + Buffer15.prototype.writeUint32BE = Buffer15.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1425,13 +1425,13 @@ buf2[offset] = hi; return offset + 8; } - Buffer14.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) { + Buffer15.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) { return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); }); - Buffer14.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) { + Buffer15.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) { return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); }); - Buffer14.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { + Buffer15.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -1450,7 +1450,7 @@ } return offset + byteLength2; }; - Buffer14.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { + Buffer15.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -1469,7 +1469,7 @@ } return offset + byteLength2; }; - Buffer14.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { + Buffer15.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); }); - Buffer14.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) { + Buffer15.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; } - Buffer14.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { + Buffer15.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert); }; - Buffer14.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { + Buffer15.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; } - Buffer14.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { + Buffer15.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert); }; - Buffer14.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { + Buffer15.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert); }; - Buffer14.prototype.copy = function copy(target, targetStart, start, end) { - if (!Buffer14.isBuffer(target)) + Buffer15.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer15.isBuffer(target)) throw new TypeError("argument should be a Buffer"); if (!start) start = 0; @@ -1600,7 +1600,7 @@ } return len; }; - Buffer14.prototype.fill = function fill(val, start, end, encoding) { + Buffer15.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" && !Buffer14.isEncoding(encoding)) { + if (typeof encoding === "string" && !Buffer15.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } if (val.length === 1) { @@ -1643,7 +1643,7 @@ this[i] = val; } } else { - const bytes = Buffer14.isBuffer(val) ? val : Buffer14.from(val, encoding); + const bytes = Buffer15.isBuffer(val) ? val : Buffer15.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 = Buffer14; + exports.Buffer = Buffer15; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; var K_MAX_LENGTH = 2147483647; exports.kMaxLength = K_MAX_LENGTH; - Buffer14.TYPED_ARRAY_SUPPORT = typedArraySupport(); - if (!Buffer14.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { + Buffer15.TYPED_ARRAY_SUPPORT = typedArraySupport(); + if (!Buffer15.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(Buffer14.prototype, "parent", { + Object.defineProperty(Buffer15.prototype, "parent", { enumerable: true, get: function() { - if (!Buffer14.isBuffer(this)) + if (!Buffer15.isBuffer(this)) return void 0; return this.buffer; } }); - Object.defineProperty(Buffer14.prototype, "offset", { + Object.defineProperty(Buffer15.prototype, "offset", { enumerable: true, get: function() { - if (!Buffer14.isBuffer(this)) + if (!Buffer15.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, Buffer14.prototype); + Object.setPrototypeOf(buf2, Buffer15.prototype); return buf2; } - function Buffer14(arg, encodingOrOffset, length) { + function Buffer15(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); } - Buffer14.poolSize = 8192; + Buffer15.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 Buffer14.from(valueOf, encodingOrOffset, length); + return Buffer15.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 Buffer14.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); + return Buffer15.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); } - Buffer14.from = function(value, encodingOrOffset, length) { + Buffer15.from = function(value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }; - Object.setPrototypeOf(Buffer14.prototype, Uint8Array.prototype); - Object.setPrototypeOf(Buffer14, Uint8Array); + Object.setPrototypeOf(Buffer15.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer15, 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); } - Buffer14.alloc = function(size, fill, encoding) { + Buffer15.alloc = function(size, fill, encoding) { return alloc(size, fill, encoding); }; function allocUnsafe(size) { assertSize(size); return createBuffer(size < 0 ? 0 : checked(size) | 0); } - Buffer14.allocUnsafe = function(size) { + Buffer15.allocUnsafe = function(size) { return allocUnsafe(size); }; - Buffer14.allocUnsafeSlow = function(size) { + Buffer15.allocUnsafeSlow = function(size) { return allocUnsafe(size); }; function fromString(string, encoding) { if (typeof encoding !== "string" || encoding === "") { encoding = "utf8"; } - if (!Buffer14.isEncoding(encoding)) { + if (!Buffer15.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, Buffer14.prototype); + Object.setPrototypeOf(buf2, Buffer15.prototype); return buf2; } function fromObject(obj) { - if (Buffer14.isBuffer(obj)) { + if (Buffer15.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 Buffer14.alloc(+length); + return Buffer15.alloc(+length); } - Buffer14.isBuffer = function isBuffer(b) { - return b != null && b._isBuffer === true && b !== Buffer14.prototype; + Buffer15.isBuffer = function isBuffer(b) { + return b != null && b._isBuffer === true && b !== Buffer15.prototype; }; - Buffer14.compare = function compare(a, b) { + Buffer15.compare = function compare(a, b) { if (isInstance(a, Uint8Array)) - a = Buffer14.from(a, a.offset, a.byteLength); + a = Buffer15.from(a, a.offset, a.byteLength); if (isInstance(b, Uint8Array)) - b = Buffer14.from(b, b.offset, b.byteLength); - if (!Buffer14.isBuffer(a) || !Buffer14.isBuffer(b)) { + b = Buffer15.from(b, b.offset, b.byteLength); + if (!Buffer15.isBuffer(a) || !Buffer15.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; }; - Buffer14.isEncoding = function isEncoding(encoding) { + Buffer15.isEncoding = function isEncoding(encoding) { switch (String(encoding).toLowerCase()) { case "hex": case "utf8": @@ -4689,12 +4689,12 @@ return false; } }; - Buffer14.concat = function concat(list, length) { + Buffer15.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 Buffer14.alloc(0); + return Buffer15.alloc(0); } var i; if (length === void 0) { @@ -4703,17 +4703,17 @@ length += list[i].length; } } - var buffer = Buffer14.allocUnsafe(length); + var buffer = Buffer15.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) { - Buffer14.from(buf2).copy(buffer, pos); + Buffer15.from(buf2).copy(buffer, pos); } else { Uint8Array.prototype.set.call(buffer, buf2, pos); } - } else if (!Buffer14.isBuffer(buf2)) { + } else if (!Buffer15.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 (Buffer14.isBuffer(string)) { + if (Buffer15.isBuffer(string)) { return string.length; } if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { @@ -4764,7 +4764,7 @@ } } } - Buffer14.byteLength = byteLength; + Buffer15.byteLength = byteLength; function slowToString(encoding, start, end) { var loweredCase = false; if (start === void 0 || start < 0) { @@ -4813,13 +4813,13 @@ } } } - Buffer14.prototype._isBuffer = true; + Buffer15.prototype._isBuffer = true; function swap(b, n, m) { var i = b[n]; b[n] = b[m]; b[m] = i; } - Buffer14.prototype.swap16 = function swap16() { + Buffer15.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; }; - Buffer14.prototype.swap32 = function swap32() { + Buffer15.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; }; - Buffer14.prototype.swap64 = function swap64() { + Buffer15.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; }; - Buffer14.prototype.toString = function toString() { + Buffer15.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); }; - Buffer14.prototype.toLocaleString = Buffer14.prototype.toString; - Buffer14.prototype.equals = function equals(b) { - if (!Buffer14.isBuffer(b)) + Buffer15.prototype.toLocaleString = Buffer15.prototype.toString; + Buffer15.prototype.equals = function equals(b) { + if (!Buffer15.isBuffer(b)) throw new TypeError("Argument must be a Buffer"); if (this === b) return true; - return Buffer14.compare(this, b) === 0; + return Buffer15.compare(this, b) === 0; }; - Buffer14.prototype.inspect = function inspect() { + Buffer15.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) { - Buffer14.prototype[customInspectSymbol] = Buffer14.prototype.inspect; + Buffer15.prototype[customInspectSymbol] = Buffer15.prototype.inspect; } - Buffer14.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { + Buffer15.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) { - target = Buffer14.from(target, target.offset, target.byteLength); + target = Buffer15.from(target, target.offset, target.byteLength); } - if (!Buffer14.isBuffer(target)) { + if (!Buffer15.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 = Buffer14.from(val, encoding); + val = Buffer15.from(val, encoding); } - if (Buffer14.isBuffer(val)) { + if (Buffer15.isBuffer(val)) { if (val.length === 0) { return -1; } @@ -5039,13 +5039,13 @@ } return -1; } - Buffer14.prototype.includes = function includes(val, byteOffset, encoding) { + Buffer15.prototype.includes = function includes(val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1; }; - Buffer14.prototype.indexOf = function indexOf(val, byteOffset, encoding) { + Buffer15.prototype.indexOf = function indexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true); }; - Buffer14.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + Buffer15.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); } - Buffer14.prototype.write = function write2(string, offset, length, encoding) { + Buffer15.prototype.write = function write2(string, offset, length, encoding) { if (offset === void 0) { encoding = "utf8"; length = this.length; @@ -5140,7 +5140,7 @@ } } }; - Buffer14.prototype.toJSON = function toJSON() { + Buffer15.prototype.toJSON = function toJSON() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) @@ -5262,7 +5262,7 @@ } return res; } - Buffer14.prototype.slice = function slice(start, end) { + Buffer15.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, Buffer14.prototype); + Object.setPrototypeOf(newBuf, Buffer15.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"); } - Buffer14.prototype.readUintLE = Buffer14.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { + Buffer15.prototype.readUintLE = Buffer15.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -5305,7 +5305,7 @@ } return val; }; - Buffer14.prototype.readUintBE = Buffer14.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { + Buffer15.prototype.readUintBE = Buffer15.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) { @@ -5318,37 +5318,37 @@ } return val; }; - Buffer14.prototype.readUint8 = Buffer14.prototype.readUInt8 = function readUInt8(offset, noAssert) { + Buffer15.prototype.readUint8 = Buffer15.prototype.readUInt8 = function readUInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }; - Buffer14.prototype.readUint16LE = Buffer14.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { + Buffer15.prototype.readUint16LE = Buffer15.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | this[offset + 1] << 8; }; - Buffer14.prototype.readUint16BE = Buffer14.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { + Buffer15.prototype.readUint16BE = Buffer15.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] << 8 | this[offset + 1]; }; - Buffer14.prototype.readUint32LE = Buffer14.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { + Buffer15.prototype.readUint32LE = Buffer15.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; }; - Buffer14.prototype.readUint32BE = Buffer14.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { + Buffer15.prototype.readUint32BE = Buffer15.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]); }; - Buffer14.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readInt8 = function readInt8(offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readInt16LE = function readInt16LE(offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readInt16BE = function readInt16BE(offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readInt32LE = function readInt32LE(offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.readInt32BE = function readInt32BE(offset, noAssert) { + Buffer15.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]; }; - Buffer14.prototype.readFloatLE = function readFloatLE(offset, noAssert) { + Buffer15.prototype.readFloatLE = function readFloatLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, true, 23, 4); }; - Buffer14.prototype.readFloatBE = function readFloatBE(offset, noAssert) { + Buffer15.prototype.readFloatBE = function readFloatBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, false, 23, 4); }; - Buffer14.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { + Buffer15.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee7542.read(this, offset, true, 52, 8); }; - Buffer14.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { + Buffer15.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 (!Buffer14.isBuffer(buf2)) + if (!Buffer15.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"); } - Buffer14.prototype.writeUintLE = Buffer14.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { + Buffer15.prototype.writeUintLE = Buffer15.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -5462,7 +5462,7 @@ } return offset + byteLength2; }; - Buffer14.prototype.writeUintBE = Buffer14.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { + Buffer15.prototype.writeUintBE = Buffer15.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -5478,7 +5478,7 @@ } return offset + byteLength2; }; - Buffer14.prototype.writeUint8 = Buffer14.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { + Buffer15.prototype.writeUint8 = Buffer15.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; }; - Buffer14.prototype.writeUint16LE = Buffer14.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { + Buffer15.prototype.writeUint16LE = Buffer15.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; }; - Buffer14.prototype.writeUint16BE = Buffer14.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { + Buffer15.prototype.writeUint16BE = Buffer15.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; }; - Buffer14.prototype.writeUint32LE = Buffer14.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { + Buffer15.prototype.writeUint32LE = Buffer15.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; }; - Buffer14.prototype.writeUint32BE = Buffer14.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { + Buffer15.prototype.writeUint32BE = Buffer15.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; }; - Buffer14.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { + Buffer15.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -5545,7 +5545,7 @@ } return offset + byteLength2; }; - Buffer14.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { + Buffer15.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -5564,7 +5564,7 @@ } return offset + byteLength2; }; - Buffer14.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { + Buffer15.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; }; - Buffer14.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { + Buffer15.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; } - Buffer14.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { + Buffer15.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert); }; - Buffer14.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { + Buffer15.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; } - Buffer14.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { + Buffer15.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert); }; - Buffer14.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { + Buffer15.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert); }; - Buffer14.prototype.copy = function copy(target, targetStart, start, end) { - if (!Buffer14.isBuffer(target)) + Buffer15.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer15.isBuffer(target)) throw new TypeError("argument should be a Buffer"); if (!start) start = 0; @@ -5689,7 +5689,7 @@ } return len; }; - Buffer14.prototype.fill = function fill(val, start, end, encoding) { + Buffer15.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" && !Buffer14.isEncoding(encoding)) { + if (typeof encoding === "string" && !Buffer15.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } if (val.length === 1) { @@ -5732,7 +5732,7 @@ this[i] = val; } } else { - var bytes = Buffer14.isBuffer(val) ? val : Buffer14.from(val, encoding); + var bytes = Buffer15.isBuffer(val) ? val : Buffer15.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 Buffer14 = _require.Buffer; + var Buffer15 = _require.Buffer; var _require2 = require_util(); var inspect = _require2.inspect; var custom = inspect && inspect.custom || "inspect"; function copyBuffer(src, target, offset) { - Buffer14.prototype.copy.call(src, target, offset); + Buffer15.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 Buffer14.alloc(0); - var ret = Buffer14.allocUnsafe(n >>> 0); + return Buffer15.alloc(0); + var ret = Buffer15.allocUnsafe(n >>> 0); var p = this.head; var i = 0; while (p) { @@ -7884,7 +7884,7 @@ }, { key: "_getBuffer", value: function _getBuffer(n) { - var ret = Buffer14.allocUnsafe(n); + var ret = Buffer15.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 Buffer14 = require_buffer().Buffer; + var Buffer15 = require_buffer().Buffer; var OurUint8Array = window.Uint8Array || function() { }; function _uint8ArrayToBuffer(chunk) { - return Buffer14.from(chunk); + return Buffer15.from(chunk); } function _isUint8Array(obj) { - return Buffer14.isBuffer(obj) || obj instanceof OurUint8Array; + return Buffer15.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 && !Buffer14.isBuffer(chunk)) { + if (isBuf && !Buffer15.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 = Buffer14.from(chunk, encoding); + chunk = Buffer15.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 Buffer14 = buffer.Buffer; + var Buffer15 = buffer.Buffer; function copyProps(src, dst) { for (var key in src) { dst[key] = src[key]; } } - if (Buffer14.from && Buffer14.alloc && Buffer14.allocUnsafe && Buffer14.allocUnsafeSlow) { + if (Buffer15.from && Buffer15.alloc && Buffer15.allocUnsafe && Buffer15.allocUnsafeSlow) { module.exports = buffer; } else { copyProps(buffer, exports); exports.Buffer = SafeBuffer; } function SafeBuffer(arg, encodingOrOffset, length) { - return Buffer14(arg, encodingOrOffset, length); + return Buffer15(arg, encodingOrOffset, length); } - SafeBuffer.prototype = Object.create(Buffer14.prototype); - copyProps(Buffer14, SafeBuffer); + SafeBuffer.prototype = Object.create(Buffer15.prototype); + copyProps(Buffer15, SafeBuffer); SafeBuffer.from = function(arg, encodingOrOffset, length) { if (typeof arg === "number") { throw new TypeError("Argument must not be a number"); } - return Buffer14(arg, encodingOrOffset, length); + return Buffer15(arg, encodingOrOffset, length); }; SafeBuffer.alloc = function(size, fill, encoding) { if (typeof size !== "number") { throw new TypeError("Argument must be a number"); } - var buf2 = Buffer14(size); + var buf2 = Buffer15(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 Buffer14(size); + return Buffer15(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 Buffer14 = require_safe_buffer().Buffer; - var isEncoding = Buffer14.isEncoding || function(encoding) { + var Buffer15 = require_safe_buffer().Buffer; + var isEncoding = Buffer15.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" && (Buffer14.isEncoding === isEncoding || !isEncoding(enc))) + if (typeof nenc !== "string" && (Buffer15.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 = Buffer14.allocUnsafe(nb); + this.lastChar = Buffer15.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 Buffer14 = require_buffer().Buffer; + var Buffer15 = require_buffer().Buffer; var OurUint8Array = window.Uint8Array || function() { }; function _uint8ArrayToBuffer(chunk) { - return Buffer14.from(chunk); + return Buffer15.from(chunk); } function _isUint8Array(obj) { - return Buffer14.isBuffer(obj) || obj instanceof OurUint8Array; + return Buffer15.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 = Buffer14.from(chunk, encoding); + chunk = Buffer15.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) !== Buffer14.prototype) { + if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer15.prototype) { chunk = _uint8ArrayToBuffer(chunk); } if (addToFront) { @@ -10486,7 +10486,7 @@ // src/main.ts init_esbuild_inject(); - var import_buffer7 = __toESM(require_buffer(), 1); + var import_buffer8 = __toESM(require_buffer(), 1); // src/stores.ts init_esbuild_inject(); @@ -11144,11 +11144,11 @@ } async insertchunk(chunk) { const b = import_buffer.Buffer.alloc(4); - b.writeInt32BE(chunk[1].length - 4, 0); + const buff = await chunk[1](); + b.writeInt32BE(buff.length - 4, 0); await this.writer.write(b); - const buff = chunk[1]; - await this.writer.write(await buff()); - b.writeInt32BE((0, import_crc_32.buf)(await buff()), 0); + await this.writer.write(buff); + b.writeInt32BE((0, import_crc_32.buf)(buff), 0); await this.writer.write(b); } async dtor() { @@ -16429,6 +16429,7 @@ // src/EyeButton.svelte init_esbuild_inject(); + var import_buffer7 = __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}"); } @@ -16760,9 +16761,13 @@ const a = document.createElement("a"); document.body.appendChild(a); a.style.display = "none"; - const thumb = Buffer2.isBuffer(file.data) ? file.data : await file.data(); - const type = await fileTypeFromBuffer(thumb); - const url = URL.createObjectURL(new Blob([thumb], { type: type?.mime })); + let url; + if (typeof file.data != "string") { + const thumb = import_buffer7.Buffer.isBuffer(file.data) ? file.data : await file.data(); + const type = await fileTypeFromBuffer(thumb); + url = URL.createObjectURL(new Blob([thumb], { type: type?.mime })); + } else + url = file.data; a.href = url; a.download = file.filename; a.click(); @@ -16857,7 +16862,7 @@ ptr += len; if (fetchRestOnNonCanceled) fetchSize = size; - const val = import_buffer7.Buffer.from(await res.arrayBuffer()); + const val = import_buffer8.Buffer.from(await res.arrayBuffer()); const e = yield val; if (e) { break; @@ -16867,7 +16872,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_buffer7.Buffer.from(hex, "base64"); + const md5 = import_buffer8.Buffer.from(hex, "base64"); if (await proc.has_embed(md5, fn) === true) return [await proc.extract(md5, fn), true]; return; @@ -16875,7 +16880,7 @@ const iter = streamRemote(src); if (!iter) return; - let cumul = import_buffer7.Buffer.alloc(0); + let cumul = import_buffer8.Buffer.alloc(0); let found; let chunk = { done: true }; do { @@ -16886,7 +16891,7 @@ chunk = { done: false, value }; } if (!done) - cumul = import_buffer7.Buffer.concat([cumul, value]); + cumul = import_buffer8.Buffer.concat([cumul, value]); found = await proc.has_embed(cumul); } while (found !== false && !chunk.done); await iter.next(true); diff --git a/src/png.ts b/src/png.ts index dffad56..1e457ff 100644 --- a/src/png.ts +++ b/src/png.ts @@ -70,11 +70,11 @@ export class PNGEncoder { async insertchunk(chunk: PNGChunk) { const b = Buffer.alloc(4); - b.writeInt32BE(chunk[1].length - 4, 0); + const buff = await chunk[1](); + b.writeInt32BE(buff.length - 4, 0); await this.writer.write(b); // write length - const buff = chunk[1]; - await this.writer.write(await buff()); // chunk includes chunkname - b.writeInt32BE(buf(await buff()), 0); + await this.writer.write(buff); // chunk includes chunkname + b.writeInt32BE(buf(buff), 0); await this.writer.write(b); }