diff --git a/main.user.js b/main.user.js index 9c0021c..b924d2c 100644 --- a/main.user.js +++ b/main.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.39 +// @version 0.40 // @description uhh // @author You // @match https://boards.4channel.org/*/thread/* @@ -233,13 +233,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 = Buffer9; + exports.Buffer = Buffer10; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; var K_MAX_LENGTH = 2147483647; exports.kMaxLength = K_MAX_LENGTH; - Buffer9.TYPED_ARRAY_SUPPORT = typedArraySupport(); - if (!Buffer9.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { + Buffer10.TYPED_ARRAY_SUPPORT = typedArraySupport(); + if (!Buffer10.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() { @@ -255,18 +255,18 @@ return false; } } - Object.defineProperty(Buffer9.prototype, "parent", { + Object.defineProperty(Buffer10.prototype, "parent", { enumerable: true, get: function() { - if (!Buffer9.isBuffer(this)) + if (!Buffer10.isBuffer(this)) return void 0; return this.buffer; } }); - Object.defineProperty(Buffer9.prototype, "offset", { + Object.defineProperty(Buffer10.prototype, "offset", { enumerable: true, get: function() { - if (!Buffer9.isBuffer(this)) + if (!Buffer10.isBuffer(this)) return void 0; return this.byteOffset; } @@ -276,10 +276,10 @@ throw new RangeError('The value "' + length + '" is invalid for option "size"'); } const buf2 = new Uint8Array(length); - Object.setPrototypeOf(buf2, Buffer9.prototype); + Object.setPrototypeOf(buf2, Buffer10.prototype); return buf2; } - function Buffer9(arg, encodingOrOffset, length) { + function Buffer10(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'); @@ -288,7 +288,7 @@ } return from(arg, encodingOrOffset, length); } - Buffer9.poolSize = 8192; + Buffer10.poolSize = 8192; function from(value, encodingOrOffset, length) { if (typeof value === "string") { return fromString(value, encodingOrOffset); @@ -310,21 +310,21 @@ } const valueOf = value.valueOf && value.valueOf(); if (valueOf != null && valueOf !== value) { - return Buffer9.from(valueOf, encodingOrOffset, length); + return Buffer10.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 Buffer9.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); + return Buffer10.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); } - Buffer9.from = function(value, encodingOrOffset, length) { + Buffer10.from = function(value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }; - Object.setPrototypeOf(Buffer9.prototype, Uint8Array.prototype); - Object.setPrototypeOf(Buffer9, Uint8Array); + Object.setPrototypeOf(Buffer10.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer10, Uint8Array); function assertSize(size) { if (typeof size !== "number") { throw new TypeError('"size" argument must be of type number'); @@ -342,24 +342,24 @@ } return createBuffer(size); } - Buffer9.alloc = function(size, fill, encoding) { + Buffer10.alloc = function(size, fill, encoding) { return alloc(size, fill, encoding); }; function allocUnsafe(size) { assertSize(size); return createBuffer(size < 0 ? 0 : checked(size) | 0); } - Buffer9.allocUnsafe = function(size) { + Buffer10.allocUnsafe = function(size) { return allocUnsafe(size); }; - Buffer9.allocUnsafeSlow = function(size) { + Buffer10.allocUnsafeSlow = function(size) { return allocUnsafe(size); }; function fromString(string, encoding) { if (typeof encoding !== "string" || encoding === "") { encoding = "utf8"; } - if (!Buffer9.isEncoding(encoding)) { + if (!Buffer10.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } const length = byteLength(string, encoding) | 0; @@ -400,11 +400,11 @@ } else { buf2 = new Uint8Array(array, byteOffset, length); } - Object.setPrototypeOf(buf2, Buffer9.prototype); + Object.setPrototypeOf(buf2, Buffer10.prototype); return buf2; } function fromObject(obj) { - if (Buffer9.isBuffer(obj)) { + if (Buffer10.isBuffer(obj)) { const len = checked(obj.length) | 0; const buf2 = createBuffer(len); if (buf2.length === 0) { @@ -433,17 +433,17 @@ if (+length != length) { length = 0; } - return Buffer9.alloc(+length); + return Buffer10.alloc(+length); } - Buffer9.isBuffer = function isBuffer(b) { - return b != null && b._isBuffer === true && b !== Buffer9.prototype; + Buffer10.isBuffer = function isBuffer(b) { + return b != null && b._isBuffer === true && b !== Buffer10.prototype; }; - Buffer9.compare = function compare(a, b) { + Buffer10.compare = function compare(a, b) { if (isInstance(a, Uint8Array)) - a = Buffer9.from(a, a.offset, a.byteLength); + a = Buffer10.from(a, a.offset, a.byteLength); if (isInstance(b, Uint8Array)) - b = Buffer9.from(b, b.offset, b.byteLength); - if (!Buffer9.isBuffer(a) || !Buffer9.isBuffer(b)) { + b = Buffer10.from(b, b.offset, b.byteLength); + if (!Buffer10.isBuffer(a) || !Buffer10.isBuffer(b)) { throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); } if (a === b) @@ -463,7 +463,7 @@ return 1; return 0; }; - Buffer9.isEncoding = function isEncoding(encoding) { + Buffer10.isEncoding = function isEncoding(encoding) { switch (String(encoding).toLowerCase()) { case "hex": case "utf8": @@ -481,12 +481,12 @@ return false; } }; - Buffer9.concat = function concat(list, length) { + Buffer10.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 Buffer9.alloc(0); + return Buffer10.alloc(0); } let i; if (length === void 0) { @@ -495,19 +495,19 @@ length += list[i].length; } } - const buffer = Buffer9.allocUnsafe(length); + const buffer = Buffer10.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 (!Buffer9.isBuffer(buf2)) - buf2 = Buffer9.from(buf2); + if (!Buffer10.isBuffer(buf2)) + buf2 = Buffer10.from(buf2); buf2.copy(buffer, pos); } else { Uint8Array.prototype.set.call(buffer, buf2, pos); } - } else if (!Buffer9.isBuffer(buf2)) { + } else if (!Buffer10.isBuffer(buf2)) { throw new TypeError('"list" argument must be an Array of Buffers'); } else { buf2.copy(buffer, pos); @@ -517,7 +517,7 @@ return buffer; }; function byteLength(string, encoding) { - if (Buffer9.isBuffer(string)) { + if (Buffer10.isBuffer(string)) { return string.length; } if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { @@ -558,7 +558,7 @@ } } } - Buffer9.byteLength = byteLength; + Buffer10.byteLength = byteLength; function slowToString(encoding, start, end) { let loweredCase = false; if (start === void 0 || start < 0) { @@ -607,13 +607,13 @@ } } } - Buffer9.prototype._isBuffer = true; + Buffer10.prototype._isBuffer = true; function swap(b, n, m) { const i = b[n]; b[n] = b[m]; b[m] = i; } - Buffer9.prototype.swap16 = function swap16() { + Buffer10.prototype.swap16 = function swap16() { const len = this.length; if (len % 2 !== 0) { throw new RangeError("Buffer size must be a multiple of 16-bits"); @@ -623,7 +623,7 @@ } return this; }; - Buffer9.prototype.swap32 = function swap32() { + Buffer10.prototype.swap32 = function swap32() { const len = this.length; if (len % 4 !== 0) { throw new RangeError("Buffer size must be a multiple of 32-bits"); @@ -634,7 +634,7 @@ } return this; }; - Buffer9.prototype.swap64 = function swap64() { + Buffer10.prototype.swap64 = function swap64() { const len = this.length; if (len % 8 !== 0) { throw new RangeError("Buffer size must be a multiple of 64-bits"); @@ -647,7 +647,7 @@ } return this; }; - Buffer9.prototype.toString = function toString() { + Buffer10.prototype.toString = function toString() { const length = this.length; if (length === 0) return ""; @@ -655,15 +655,15 @@ return utf8Slice(this, 0, length); return slowToString.apply(this, arguments); }; - Buffer9.prototype.toLocaleString = Buffer9.prototype.toString; - Buffer9.prototype.equals = function equals(b) { - if (!Buffer9.isBuffer(b)) + Buffer10.prototype.toLocaleString = Buffer10.prototype.toString; + Buffer10.prototype.equals = function equals(b) { + if (!Buffer10.isBuffer(b)) throw new TypeError("Argument must be a Buffer"); if (this === b) return true; - return Buffer9.compare(this, b) === 0; + return Buffer10.compare(this, b) === 0; }; - Buffer9.prototype.inspect = function inspect() { + Buffer10.prototype.inspect = function inspect() { let str = ""; const max = exports.INSPECT_MAX_BYTES; str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(); @@ -672,13 +672,13 @@ return ""; }; if (customInspectSymbol) { - Buffer9.prototype[customInspectSymbol] = Buffer9.prototype.inspect; + Buffer10.prototype[customInspectSymbol] = Buffer10.prototype.inspect; } - Buffer9.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { + Buffer10.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) { - target = Buffer9.from(target, target.offset, target.byteLength); + target = Buffer10.from(target, target.offset, target.byteLength); } - if (!Buffer9.isBuffer(target)) { + if (!Buffer10.isBuffer(target)) { throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target); } if (start === void 0) { @@ -758,9 +758,9 @@ return -1; } if (typeof val === "string") { - val = Buffer9.from(val, encoding); + val = Buffer10.from(val, encoding); } - if (Buffer9.isBuffer(val)) { + if (Buffer10.isBuffer(val)) { if (val.length === 0) { return -1; } @@ -833,13 +833,13 @@ } return -1; } - Buffer9.prototype.includes = function includes(val, byteOffset, encoding) { + Buffer10.prototype.includes = function includes(val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1; }; - Buffer9.prototype.indexOf = function indexOf(val, byteOffset, encoding) { + Buffer10.prototype.indexOf = function indexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true); }; - Buffer9.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + Buffer10.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, false); }; function hexWrite(buf2, string, offset, length) { @@ -878,7 +878,7 @@ function ucs2Write(buf2, string, offset, length) { return blitBuffer(utf16leToBytes(string, buf2.length - offset), buf2, offset, length); } - Buffer9.prototype.write = function write2(string, offset, length, encoding) { + Buffer10.prototype.write = function write2(string, offset, length, encoding) { if (offset === void 0) { encoding = "utf8"; length = this.length; @@ -935,7 +935,7 @@ } } }; - Buffer9.prototype.toJSON = function toJSON() { + Buffer10.prototype.toJSON = function toJSON() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) @@ -1057,7 +1057,7 @@ } return res; } - Buffer9.prototype.slice = function slice(start, end) { + Buffer10.prototype.slice = function slice(start, end) { const len = this.length; start = ~~start; end = end === void 0 ? len : ~~end; @@ -1078,7 +1078,7 @@ if (end < start) end = start; const newBuf = this.subarray(start, end); - Object.setPrototypeOf(newBuf, Buffer9.prototype); + Object.setPrototypeOf(newBuf, Buffer10.prototype); return newBuf; }; function checkOffset(offset, ext, length) { @@ -1087,7 +1087,7 @@ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length"); } - Buffer9.prototype.readUintLE = Buffer9.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { + Buffer10.prototype.readUintLE = Buffer10.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -1100,7 +1100,7 @@ } return val; }; - Buffer9.prototype.readUintBE = Buffer9.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { + Buffer10.prototype.readUintBE = Buffer10.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) { @@ -1113,37 +1113,37 @@ } return val; }; - Buffer9.prototype.readUint8 = Buffer9.prototype.readUInt8 = function readUInt8(offset, noAssert) { + Buffer10.prototype.readUint8 = Buffer10.prototype.readUInt8 = function readUInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }; - Buffer9.prototype.readUint16LE = Buffer9.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { + Buffer10.prototype.readUint16LE = Buffer10.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | this[offset + 1] << 8; }; - Buffer9.prototype.readUint16BE = Buffer9.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { + Buffer10.prototype.readUint16BE = Buffer10.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] << 8 | this[offset + 1]; }; - Buffer9.prototype.readUint32LE = Buffer9.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { + Buffer10.prototype.readUint32LE = Buffer10.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; }; - Buffer9.prototype.readUint32BE = Buffer9.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { + Buffer10.prototype.readUint32BE = Buffer10.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]); }; - Buffer9.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) { + Buffer10.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; @@ -1155,7 +1155,7 @@ const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24; return BigInt(lo) + (BigInt(hi) << BigInt(32)); }); - Buffer9.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) { + Buffer10.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; @@ -1167,7 +1167,7 @@ const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last; return (BigInt(hi) << BigInt(32)) + BigInt(lo); }); - Buffer9.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { + Buffer10.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -1183,7 +1183,7 @@ val -= Math.pow(2, 8 * byteLength2); return val; }; - Buffer9.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { + Buffer10.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -1199,7 +1199,7 @@ val -= Math.pow(2, 8 * byteLength2); return val; }; - Buffer9.prototype.readInt8 = function readInt8(offset, noAssert) { + Buffer10.prototype.readInt8 = function readInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); @@ -1207,33 +1207,33 @@ return this[offset]; return (255 - this[offset] + 1) * -1; }; - Buffer9.prototype.readInt16LE = function readInt16LE(offset, noAssert) { + Buffer10.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; }; - Buffer9.prototype.readInt16BE = function readInt16BE(offset, noAssert) { + Buffer10.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; }; - Buffer9.prototype.readInt32LE = function readInt32LE(offset, noAssert) { + Buffer10.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; }; - Buffer9.prototype.readInt32BE = function readInt32BE(offset, noAssert) { + Buffer10.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]; }; - Buffer9.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) { + Buffer10.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; @@ -1244,7 +1244,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); }); - Buffer9.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) { + Buffer10.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; @@ -1255,39 +1255,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); }); - Buffer9.prototype.readFloatLE = function readFloatLE(offset, noAssert) { + Buffer10.prototype.readFloatLE = function readFloatLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, true, 23, 4); }; - Buffer9.prototype.readFloatBE = function readFloatBE(offset, noAssert) { + Buffer10.prototype.readFloatBE = function readFloatBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, false, 23, 4); }; - Buffer9.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { + Buffer10.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee7542.read(this, offset, true, 52, 8); }; - Buffer9.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { + Buffer10.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 (!Buffer9.isBuffer(buf2)) + if (!Buffer10.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"); } - Buffer9.prototype.writeUintLE = Buffer9.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { + Buffer10.prototype.writeUintLE = Buffer10.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -1303,7 +1303,7 @@ } return offset + byteLength2; }; - Buffer9.prototype.writeUintBE = Buffer9.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { + Buffer10.prototype.writeUintBE = Buffer10.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -1319,7 +1319,7 @@ } return offset + byteLength2; }; - Buffer9.prototype.writeUint8 = Buffer9.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { + Buffer10.prototype.writeUint8 = Buffer10.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1327,7 +1327,7 @@ this[offset] = value & 255; return offset + 1; }; - Buffer9.prototype.writeUint16LE = Buffer9.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { + Buffer10.prototype.writeUint16LE = Buffer10.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1336,7 +1336,7 @@ this[offset + 1] = value >>> 8; return offset + 2; }; - Buffer9.prototype.writeUint16BE = Buffer9.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { + Buffer10.prototype.writeUint16BE = Buffer10.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1345,7 +1345,7 @@ this[offset + 1] = value & 255; return offset + 2; }; - Buffer9.prototype.writeUint32LE = Buffer9.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { + Buffer10.prototype.writeUint32LE = Buffer10.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1356,7 +1356,7 @@ this[offset] = value & 255; return offset + 4; }; - Buffer9.prototype.writeUint32BE = Buffer9.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { + Buffer10.prototype.writeUint32BE = Buffer10.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1407,13 +1407,13 @@ buf2[offset] = hi; return offset + 8; } - Buffer9.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) { + Buffer10.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) { return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); }); - Buffer9.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) { + Buffer10.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) { return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); }); - Buffer9.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { + Buffer10.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -1432,7 +1432,7 @@ } return offset + byteLength2; }; - Buffer9.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { + Buffer10.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -1451,7 +1451,7 @@ } return offset + byteLength2; }; - Buffer9.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { + Buffer10.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1461,7 +1461,7 @@ this[offset] = value & 255; return offset + 1; }; - Buffer9.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { + Buffer10.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1470,7 +1470,7 @@ this[offset + 1] = value >>> 8; return offset + 2; }; - Buffer9.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { + Buffer10.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1479,7 +1479,7 @@ this[offset + 1] = value & 255; return offset + 2; }; - Buffer9.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { + Buffer10.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1490,7 +1490,7 @@ this[offset + 3] = value >>> 24; return offset + 4; }; - Buffer9.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { + Buffer10.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -1503,10 +1503,10 @@ this[offset + 3] = value & 255; return offset + 4; }; - Buffer9.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { + Buffer10.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); }); - Buffer9.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) { + Buffer10.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) { @@ -1524,10 +1524,10 @@ ieee7542.write(buf2, value, offset, littleEndian, 23, 4); return offset + 4; } - Buffer9.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { + Buffer10.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert); }; - Buffer9.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { + Buffer10.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert); }; function writeDouble(buf2, value, offset, littleEndian, noAssert) { @@ -1539,14 +1539,14 @@ ieee7542.write(buf2, value, offset, littleEndian, 52, 8); return offset + 8; } - Buffer9.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { + Buffer10.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert); }; - Buffer9.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { + Buffer10.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert); }; - Buffer9.prototype.copy = function copy(target, targetStart, start, end) { - if (!Buffer9.isBuffer(target)) + Buffer10.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer10.isBuffer(target)) throw new TypeError("argument should be a Buffer"); if (!start) start = 0; @@ -1582,7 +1582,7 @@ } return len; }; - Buffer9.prototype.fill = function fill(val, start, end, encoding) { + Buffer10.prototype.fill = function fill(val, start, end, encoding) { if (typeof val === "string") { if (typeof start === "string") { encoding = start; @@ -1595,7 +1595,7 @@ if (encoding !== void 0 && typeof encoding !== "string") { throw new TypeError("encoding must be a string"); } - if (typeof encoding === "string" && !Buffer9.isEncoding(encoding)) { + if (typeof encoding === "string" && !Buffer10.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } if (val.length === 1) { @@ -1625,7 +1625,7 @@ this[i] = val; } } else { - const bytes = Buffer9.isBuffer(val) ? val : Buffer9.from(val, encoding); + const bytes = Buffer10.isBuffer(val) ? val : Buffer10.from(val, encoding); const len = bytes.length; if (len === 0) { throw new TypeError('The value "' + val + '" is invalid for argument "value"'); @@ -2320,12 +2320,12 @@ return Constructor; } var _require = require_buffer(); - var Buffer9 = _require.Buffer; + var Buffer10 = _require.Buffer; var _require2 = require_util(); var inspect = _require2.inspect; var custom = inspect && inspect.custom || "inspect"; function copyBuffer(src, target, offset) { - Buffer9.prototype.copy.call(src, target, offset); + Buffer10.prototype.copy.call(src, target, offset); } module.exports = /* @__PURE__ */ function() { function BufferList() { @@ -2395,8 +2395,8 @@ key: "concat", value: function concat(n) { if (this.length === 0) - return Buffer9.alloc(0); - var ret = Buffer9.allocUnsafe(n >>> 0); + return Buffer10.alloc(0); + var ret = Buffer10.allocUnsafe(n >>> 0); var p = this.head; var i = 0; while (p) { @@ -2461,7 +2461,7 @@ }, { key: "_getBuffer", value: function _getBuffer(n) { - var ret = Buffer9.allocUnsafe(n); + var ret = Buffer10.allocUnsafe(n); var p = this.head; var c = 1; p.data.copy(ret); @@ -2826,14 +2826,14 @@ deprecate: require_browser() }; var Stream = require_stream_browser(); - var Buffer9 = require_buffer().Buffer; + var Buffer10 = require_buffer().Buffer; var OurUint8Array = window.Uint8Array || function() { }; function _uint8ArrayToBuffer(chunk) { - return Buffer9.from(chunk); + return Buffer10.from(chunk); } function _isUint8Array(obj) { - return Buffer9.isBuffer(obj) || obj instanceof OurUint8Array; + return Buffer10.isBuffer(obj) || obj instanceof OurUint8Array; } var destroyImpl = require_destroy(); var _require = require_state(); @@ -2970,7 +2970,7 @@ var state = this._writableState; var ret = false; var isBuf = !state.objectMode && _isUint8Array(chunk); - if (isBuf && !Buffer9.isBuffer(chunk)) { + if (isBuf && !Buffer10.isBuffer(chunk)) { chunk = _uint8ArrayToBuffer(chunk); } if (typeof encoding === "function") { @@ -3018,7 +3018,7 @@ }); function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") { - chunk = Buffer9.from(chunk, encoding); + chunk = Buffer10.from(chunk, encoding); } return chunk; } @@ -3389,34 +3389,34 @@ "node_modules/safe-buffer/index.js"(exports, module) { init_esbuild_inject(); var buffer = require_buffer(); - var Buffer9 = buffer.Buffer; + var Buffer10 = buffer.Buffer; function copyProps(src, dst) { for (var key in src) { dst[key] = src[key]; } } - if (Buffer9.from && Buffer9.alloc && Buffer9.allocUnsafe && Buffer9.allocUnsafeSlow) { + if (Buffer10.from && Buffer10.alloc && Buffer10.allocUnsafe && Buffer10.allocUnsafeSlow) { module.exports = buffer; } else { copyProps(buffer, exports); exports.Buffer = SafeBuffer; } function SafeBuffer(arg, encodingOrOffset, length) { - return Buffer9(arg, encodingOrOffset, length); + return Buffer10(arg, encodingOrOffset, length); } - SafeBuffer.prototype = Object.create(Buffer9.prototype); - copyProps(Buffer9, SafeBuffer); + SafeBuffer.prototype = Object.create(Buffer10.prototype); + copyProps(Buffer10, SafeBuffer); SafeBuffer.from = function(arg, encodingOrOffset, length) { if (typeof arg === "number") { throw new TypeError("Argument must not be a number"); } - return Buffer9(arg, encodingOrOffset, length); + return Buffer10(arg, encodingOrOffset, length); }; SafeBuffer.alloc = function(size, fill, encoding) { if (typeof size !== "number") { throw new TypeError("Argument must be a number"); } - var buf2 = Buffer9(size); + var buf2 = Buffer10(size); if (fill !== void 0) { if (typeof encoding === "string") { buf2.fill(fill, encoding); @@ -3432,7 +3432,7 @@ if (typeof size !== "number") { throw new TypeError("Argument must be a number"); } - return Buffer9(size); + return Buffer10(size); }; SafeBuffer.allocUnsafeSlow = function(size) { if (typeof size !== "number") { @@ -3448,8 +3448,8 @@ "node_modules/string_decoder/lib/string_decoder.js"(exports) { "use strict"; init_esbuild_inject(); - var Buffer9 = require_safe_buffer().Buffer; - var isEncoding = Buffer9.isEncoding || function(encoding) { + var Buffer10 = require_safe_buffer().Buffer; + var isEncoding = Buffer10.isEncoding || function(encoding) { encoding = "" + encoding; switch (encoding && encoding.toLowerCase()) { case "hex": @@ -3499,7 +3499,7 @@ } function normalizeEncoding(enc) { var nenc = _normalizeEncoding(enc); - if (typeof nenc !== "string" && (Buffer9.isEncoding === isEncoding || !isEncoding(enc))) + if (typeof nenc !== "string" && (Buffer10.isEncoding === isEncoding || !isEncoding(enc))) throw new Error("Unknown encoding: " + enc); return nenc || enc; } @@ -3529,7 +3529,7 @@ } this.lastNeed = 0; this.lastTotal = 0; - this.lastChar = Buffer9.allocUnsafe(nb); + this.lastChar = Buffer10.allocUnsafe(nb); } StringDecoder.prototype.write = function(buf2) { if (buf2.length === 0) @@ -3998,14 +3998,14 @@ return emitter.listeners(type).length; }; var Stream = require_stream_browser(); - var Buffer9 = require_buffer().Buffer; + var Buffer10 = require_buffer().Buffer; var OurUint8Array = window.Uint8Array || function() { }; function _uint8ArrayToBuffer(chunk) { - return Buffer9.from(chunk); + return Buffer10.from(chunk); } function _isUint8Array(obj) { - return Buffer9.isBuffer(obj) || obj instanceof OurUint8Array; + return Buffer10.isBuffer(obj) || obj instanceof OurUint8Array; } var debugUtil = require_util(); var debug; @@ -4120,7 +4120,7 @@ if (typeof chunk === "string") { encoding = encoding || state.defaultEncoding; if (encoding !== state.encoding) { - chunk = Buffer9.from(chunk, encoding); + chunk = Buffer10.from(chunk, encoding); encoding = ""; } skipChunkCheck = true; @@ -4146,7 +4146,7 @@ if (er) { errorOrDestroy(stream, er); } else if (state.objectMode || chunk && chunk.length > 0) { - if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer9.prototype) { + if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer10.prototype) { chunk = _uint8ArrayToBuffer(chunk); } if (addToFront) { @@ -7613,13 +7613,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 = Buffer9; + exports.Buffer = Buffer10; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; var K_MAX_LENGTH = 2147483647; exports.kMaxLength = K_MAX_LENGTH; - Buffer9.TYPED_ARRAY_SUPPORT = typedArraySupport(); - if (!Buffer9.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { + Buffer10.TYPED_ARRAY_SUPPORT = typedArraySupport(); + if (!Buffer10.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() { @@ -7635,18 +7635,18 @@ return false; } } - Object.defineProperty(Buffer9.prototype, "parent", { + Object.defineProperty(Buffer10.prototype, "parent", { enumerable: true, get: function() { - if (!Buffer9.isBuffer(this)) + if (!Buffer10.isBuffer(this)) return void 0; return this.buffer; } }); - Object.defineProperty(Buffer9.prototype, "offset", { + Object.defineProperty(Buffer10.prototype, "offset", { enumerable: true, get: function() { - if (!Buffer9.isBuffer(this)) + if (!Buffer10.isBuffer(this)) return void 0; return this.byteOffset; } @@ -7656,10 +7656,10 @@ throw new RangeError('The value "' + length + '" is invalid for option "size"'); } var buf2 = new Uint8Array(length); - Object.setPrototypeOf(buf2, Buffer9.prototype); + Object.setPrototypeOf(buf2, Buffer10.prototype); return buf2; } - function Buffer9(arg, encodingOrOffset, length) { + function Buffer10(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'); @@ -7668,7 +7668,7 @@ } return from(arg, encodingOrOffset, length); } - Buffer9.poolSize = 8192; + Buffer10.poolSize = 8192; function from(value, encodingOrOffset, length) { if (typeof value === "string") { return fromString(value, encodingOrOffset); @@ -7690,21 +7690,21 @@ } var valueOf = value.valueOf && value.valueOf(); if (valueOf != null && valueOf !== value) { - return Buffer9.from(valueOf, encodingOrOffset, length); + return Buffer10.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 Buffer9.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); + return Buffer10.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); } - Buffer9.from = function(value, encodingOrOffset, length) { + Buffer10.from = function(value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }; - Object.setPrototypeOf(Buffer9.prototype, Uint8Array.prototype); - Object.setPrototypeOf(Buffer9, Uint8Array); + Object.setPrototypeOf(Buffer10.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer10, Uint8Array); function assertSize(size) { if (typeof size !== "number") { throw new TypeError('"size" argument must be of type number'); @@ -7722,24 +7722,24 @@ } return createBuffer(size); } - Buffer9.alloc = function(size, fill, encoding) { + Buffer10.alloc = function(size, fill, encoding) { return alloc(size, fill, encoding); }; function allocUnsafe(size) { assertSize(size); return createBuffer(size < 0 ? 0 : checked(size) | 0); } - Buffer9.allocUnsafe = function(size) { + Buffer10.allocUnsafe = function(size) { return allocUnsafe(size); }; - Buffer9.allocUnsafeSlow = function(size) { + Buffer10.allocUnsafeSlow = function(size) { return allocUnsafe(size); }; function fromString(string, encoding) { if (typeof encoding !== "string" || encoding === "") { encoding = "utf8"; } - if (!Buffer9.isEncoding(encoding)) { + if (!Buffer10.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } var length = byteLength(string, encoding) | 0; @@ -7780,11 +7780,11 @@ } else { buf2 = new Uint8Array(array, byteOffset, length); } - Object.setPrototypeOf(buf2, Buffer9.prototype); + Object.setPrototypeOf(buf2, Buffer10.prototype); return buf2; } function fromObject(obj) { - if (Buffer9.isBuffer(obj)) { + if (Buffer10.isBuffer(obj)) { var len = checked(obj.length) | 0; var buf2 = createBuffer(len); if (buf2.length === 0) { @@ -7813,17 +7813,17 @@ if (+length != length) { length = 0; } - return Buffer9.alloc(+length); + return Buffer10.alloc(+length); } - Buffer9.isBuffer = function isBuffer(b) { - return b != null && b._isBuffer === true && b !== Buffer9.prototype; + Buffer10.isBuffer = function isBuffer(b) { + return b != null && b._isBuffer === true && b !== Buffer10.prototype; }; - Buffer9.compare = function compare(a, b) { + Buffer10.compare = function compare(a, b) { if (isInstance(a, Uint8Array)) - a = Buffer9.from(a, a.offset, a.byteLength); + a = Buffer10.from(a, a.offset, a.byteLength); if (isInstance(b, Uint8Array)) - b = Buffer9.from(b, b.offset, b.byteLength); - if (!Buffer9.isBuffer(a) || !Buffer9.isBuffer(b)) { + b = Buffer10.from(b, b.offset, b.byteLength); + if (!Buffer10.isBuffer(a) || !Buffer10.isBuffer(b)) { throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); } if (a === b) @@ -7843,7 +7843,7 @@ return 1; return 0; }; - Buffer9.isEncoding = function isEncoding(encoding) { + Buffer10.isEncoding = function isEncoding(encoding) { switch (String(encoding).toLowerCase()) { case "hex": case "utf8": @@ -7861,12 +7861,12 @@ return false; } }; - Buffer9.concat = function concat(list, length) { + Buffer10.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 Buffer9.alloc(0); + return Buffer10.alloc(0); } var i; if (length === void 0) { @@ -7875,17 +7875,17 @@ length += list[i].length; } } - var buffer = Buffer9.allocUnsafe(length); + var buffer = Buffer10.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) { - Buffer9.from(buf2).copy(buffer, pos); + Buffer10.from(buf2).copy(buffer, pos); } else { Uint8Array.prototype.set.call(buffer, buf2, pos); } - } else if (!Buffer9.isBuffer(buf2)) { + } else if (!Buffer10.isBuffer(buf2)) { throw new TypeError('"list" argument must be an Array of Buffers'); } else { buf2.copy(buffer, pos); @@ -7895,7 +7895,7 @@ return buffer; }; function byteLength(string, encoding) { - if (Buffer9.isBuffer(string)) { + if (Buffer10.isBuffer(string)) { return string.length; } if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { @@ -7936,7 +7936,7 @@ } } } - Buffer9.byteLength = byteLength; + Buffer10.byteLength = byteLength; function slowToString(encoding, start, end) { var loweredCase = false; if (start === void 0 || start < 0) { @@ -7985,13 +7985,13 @@ } } } - Buffer9.prototype._isBuffer = true; + Buffer10.prototype._isBuffer = true; function swap(b, n, m) { var i = b[n]; b[n] = b[m]; b[m] = i; } - Buffer9.prototype.swap16 = function swap16() { + Buffer10.prototype.swap16 = function swap16() { var len = this.length; if (len % 2 !== 0) { throw new RangeError("Buffer size must be a multiple of 16-bits"); @@ -8001,7 +8001,7 @@ } return this; }; - Buffer9.prototype.swap32 = function swap32() { + Buffer10.prototype.swap32 = function swap32() { var len = this.length; if (len % 4 !== 0) { throw new RangeError("Buffer size must be a multiple of 32-bits"); @@ -8012,7 +8012,7 @@ } return this; }; - Buffer9.prototype.swap64 = function swap64() { + Buffer10.prototype.swap64 = function swap64() { var len = this.length; if (len % 8 !== 0) { throw new RangeError("Buffer size must be a multiple of 64-bits"); @@ -8025,7 +8025,7 @@ } return this; }; - Buffer9.prototype.toString = function toString() { + Buffer10.prototype.toString = function toString() { var length = this.length; if (length === 0) return ""; @@ -8033,15 +8033,15 @@ return utf8Slice(this, 0, length); return slowToString.apply(this, arguments); }; - Buffer9.prototype.toLocaleString = Buffer9.prototype.toString; - Buffer9.prototype.equals = function equals(b) { - if (!Buffer9.isBuffer(b)) + Buffer10.prototype.toLocaleString = Buffer10.prototype.toString; + Buffer10.prototype.equals = function equals(b) { + if (!Buffer10.isBuffer(b)) throw new TypeError("Argument must be a Buffer"); if (this === b) return true; - return Buffer9.compare(this, b) === 0; + return Buffer10.compare(this, b) === 0; }; - Buffer9.prototype.inspect = function inspect() { + Buffer10.prototype.inspect = function inspect() { var str = ""; var max = exports.INSPECT_MAX_BYTES; str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(); @@ -8050,13 +8050,13 @@ return ""; }; if (customInspectSymbol) { - Buffer9.prototype[customInspectSymbol] = Buffer9.prototype.inspect; + Buffer10.prototype[customInspectSymbol] = Buffer10.prototype.inspect; } - Buffer9.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { + Buffer10.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) { - target = Buffer9.from(target, target.offset, target.byteLength); + target = Buffer10.from(target, target.offset, target.byteLength); } - if (!Buffer9.isBuffer(target)) { + if (!Buffer10.isBuffer(target)) { throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target); } if (start === void 0) { @@ -8136,9 +8136,9 @@ return -1; } if (typeof val === "string") { - val = Buffer9.from(val, encoding); + val = Buffer10.from(val, encoding); } - if (Buffer9.isBuffer(val)) { + if (Buffer10.isBuffer(val)) { if (val.length === 0) { return -1; } @@ -8211,13 +8211,13 @@ } return -1; } - Buffer9.prototype.includes = function includes(val, byteOffset, encoding) { + Buffer10.prototype.includes = function includes(val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1; }; - Buffer9.prototype.indexOf = function indexOf(val, byteOffset, encoding) { + Buffer10.prototype.indexOf = function indexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true); }; - Buffer9.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + Buffer10.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, false); }; function hexWrite(buf2, string, offset, length) { @@ -8255,7 +8255,7 @@ function ucs2Write(buf2, string, offset, length) { return blitBuffer(utf16leToBytes(string, buf2.length - offset), buf2, offset, length); } - Buffer9.prototype.write = function write2(string, offset, length, encoding) { + Buffer10.prototype.write = function write2(string, offset, length, encoding) { if (offset === void 0) { encoding = "utf8"; length = this.length; @@ -8312,7 +8312,7 @@ } } }; - Buffer9.prototype.toJSON = function toJSON() { + Buffer10.prototype.toJSON = function toJSON() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) @@ -8434,7 +8434,7 @@ } return res; } - Buffer9.prototype.slice = function slice(start, end) { + Buffer10.prototype.slice = function slice(start, end) { var len = this.length; start = ~~start; end = end === void 0 ? len : ~~end; @@ -8455,7 +8455,7 @@ if (end < start) end = start; var newBuf = this.subarray(start, end); - Object.setPrototypeOf(newBuf, Buffer9.prototype); + Object.setPrototypeOf(newBuf, Buffer10.prototype); return newBuf; }; function checkOffset(offset, ext, length) { @@ -8464,7 +8464,7 @@ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length"); } - Buffer9.prototype.readUintLE = Buffer9.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { + Buffer10.prototype.readUintLE = Buffer10.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -8477,7 +8477,7 @@ } return val; }; - Buffer9.prototype.readUintBE = Buffer9.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { + Buffer10.prototype.readUintBE = Buffer10.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) { @@ -8490,37 +8490,37 @@ } return val; }; - Buffer9.prototype.readUint8 = Buffer9.prototype.readUInt8 = function readUInt8(offset, noAssert) { + Buffer10.prototype.readUint8 = Buffer10.prototype.readUInt8 = function readUInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }; - Buffer9.prototype.readUint16LE = Buffer9.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { + Buffer10.prototype.readUint16LE = Buffer10.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | this[offset + 1] << 8; }; - Buffer9.prototype.readUint16BE = Buffer9.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { + Buffer10.prototype.readUint16BE = Buffer10.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] << 8 | this[offset + 1]; }; - Buffer9.prototype.readUint32LE = Buffer9.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { + Buffer10.prototype.readUint32LE = Buffer10.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; }; - Buffer9.prototype.readUint32BE = Buffer9.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { + Buffer10.prototype.readUint32BE = Buffer10.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]); }; - Buffer9.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { + Buffer10.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -8536,7 +8536,7 @@ val -= Math.pow(2, 8 * byteLength2); return val; }; - Buffer9.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { + Buffer10.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; if (!noAssert) @@ -8552,7 +8552,7 @@ val -= Math.pow(2, 8 * byteLength2); return val; }; - Buffer9.prototype.readInt8 = function readInt8(offset, noAssert) { + Buffer10.prototype.readInt8 = function readInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); @@ -8560,65 +8560,65 @@ return this[offset]; return (255 - this[offset] + 1) * -1; }; - Buffer9.prototype.readInt16LE = function readInt16LE(offset, noAssert) { + Buffer10.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; }; - Buffer9.prototype.readInt16BE = function readInt16BE(offset, noAssert) { + Buffer10.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; }; - Buffer9.prototype.readInt32LE = function readInt32LE(offset, noAssert) { + Buffer10.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; }; - Buffer9.prototype.readInt32BE = function readInt32BE(offset, noAssert) { + Buffer10.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]; }; - Buffer9.prototype.readFloatLE = function readFloatLE(offset, noAssert) { + Buffer10.prototype.readFloatLE = function readFloatLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, true, 23, 4); }; - Buffer9.prototype.readFloatBE = function readFloatBE(offset, noAssert) { + Buffer10.prototype.readFloatBE = function readFloatBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee7542.read(this, offset, false, 23, 4); }; - Buffer9.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { + Buffer10.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee7542.read(this, offset, true, 52, 8); }; - Buffer9.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { + Buffer10.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 (!Buffer9.isBuffer(buf2)) + if (!Buffer10.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"); } - Buffer9.prototype.writeUintLE = Buffer9.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { + Buffer10.prototype.writeUintLE = Buffer10.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -8634,7 +8634,7 @@ } return offset + byteLength2; }; - Buffer9.prototype.writeUintBE = Buffer9.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { + Buffer10.prototype.writeUintBE = Buffer10.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; byteLength2 = byteLength2 >>> 0; @@ -8650,7 +8650,7 @@ } return offset + byteLength2; }; - Buffer9.prototype.writeUint8 = Buffer9.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { + Buffer10.prototype.writeUint8 = Buffer10.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -8658,7 +8658,7 @@ this[offset] = value & 255; return offset + 1; }; - Buffer9.prototype.writeUint16LE = Buffer9.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { + Buffer10.prototype.writeUint16LE = Buffer10.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -8667,7 +8667,7 @@ this[offset + 1] = value >>> 8; return offset + 2; }; - Buffer9.prototype.writeUint16BE = Buffer9.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { + Buffer10.prototype.writeUint16BE = Buffer10.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -8676,7 +8676,7 @@ this[offset + 1] = value & 255; return offset + 2; }; - Buffer9.prototype.writeUint32LE = Buffer9.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { + Buffer10.prototype.writeUint32LE = Buffer10.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -8687,7 +8687,7 @@ this[offset] = value & 255; return offset + 4; }; - Buffer9.prototype.writeUint32BE = Buffer9.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { + Buffer10.prototype.writeUint32BE = Buffer10.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -8698,7 +8698,7 @@ this[offset + 3] = value & 255; return offset + 4; }; - Buffer9.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { + Buffer10.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -8717,7 +8717,7 @@ } return offset + byteLength2; }; - Buffer9.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { + Buffer10.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { @@ -8736,7 +8736,7 @@ } return offset + byteLength2; }; - Buffer9.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { + Buffer10.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -8746,7 +8746,7 @@ this[offset] = value & 255; return offset + 1; }; - Buffer9.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { + Buffer10.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -8755,7 +8755,7 @@ this[offset + 1] = value >>> 8; return offset + 2; }; - Buffer9.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { + Buffer10.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -8764,7 +8764,7 @@ this[offset + 1] = value & 255; return offset + 2; }; - Buffer9.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { + Buffer10.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -8775,7 +8775,7 @@ this[offset + 3] = value >>> 24; return offset + 4; }; - Buffer9.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { + Buffer10.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) @@ -8803,10 +8803,10 @@ ieee7542.write(buf2, value, offset, littleEndian, 23, 4); return offset + 4; } - Buffer9.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { + Buffer10.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert); }; - Buffer9.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { + Buffer10.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert); }; function writeDouble(buf2, value, offset, littleEndian, noAssert) { @@ -8818,14 +8818,14 @@ ieee7542.write(buf2, value, offset, littleEndian, 52, 8); return offset + 8; } - Buffer9.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { + Buffer10.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert); }; - Buffer9.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { + Buffer10.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert); }; - Buffer9.prototype.copy = function copy(target, targetStart, start, end) { - if (!Buffer9.isBuffer(target)) + Buffer10.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer10.isBuffer(target)) throw new TypeError("argument should be a Buffer"); if (!start) start = 0; @@ -8861,7 +8861,7 @@ } return len; }; - Buffer9.prototype.fill = function fill(val, start, end, encoding) { + Buffer10.prototype.fill = function fill(val, start, end, encoding) { if (typeof val === "string") { if (typeof start === "string") { encoding = start; @@ -8874,7 +8874,7 @@ if (encoding !== void 0 && typeof encoding !== "string") { throw new TypeError("encoding must be a string"); } - if (typeof encoding === "string" && !Buffer9.isEncoding(encoding)) { + if (typeof encoding === "string" && !Buffer10.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } if (val.length === 1) { @@ -8904,7 +8904,7 @@ this[i] = val; } } else { - var bytes = Buffer9.isBuffer(val) ? val : Buffer9.from(val, encoding); + var bytes = Buffer10.isBuffer(val) ? val : Buffer10.from(val, encoding); var len = bytes.length; if (len === 0) { throw new TypeError('The value "' + val + '" is invalid for argument "value"'); @@ -10468,6 +10468,7 @@ // src/main.ts init_esbuild_inject(); + var import_buffer3 = __toESM(require_buffer()); // node_modules/file-type/browser.js init_esbuild_inject(); @@ -12544,6 +12545,26 @@ // src/main.ts var xmlhttprequest = typeof GM_xmlhttpRequest != "undefined" ? GM_xmlhttpRequest : GM ? GM.xmlHttpRequest : GM_xmlhttpRequest; + var headerStringToObject = (s) => Object.fromEntries(s.split("\n").map((e) => { + const [name, ...rest] = e.split(":"); + return [name.toLowerCase(), rest.join(":").trim()]; + })); + function GM_head(...[url, opt]) { + return new Promise((resolve, reject) => { + const gmopt = { + url: url.toString(), + data: opt?.body?.toString(), + method: "HEAD", + onload: (resp) => { + resolve(resp.responseHeaders); + }, + ontimeout: () => reject("fetch timeout"), + onerror: () => reject("fetch error"), + onabort: () => reject("fetch abort") + }; + xmlhttprequest(gmopt); + }); + } function GM_fetch(...[url, opt]) { function blobTo(to, blob) { if (to == "arrayBuffer" && blob.arrayBuffer) @@ -12573,6 +12594,7 @@ url: url.toString(), data: opt?.body?.toString(), responseType: "blob", + headers: opt?.headers, method: "GET", onload: (resp) => { const blob = resp.response; @@ -12590,16 +12612,49 @@ xmlhttprequest(gmopt); }); } + async function* streamRemote(url, chunkSize = 128 * 1024, fetchRestOnNonCanceled = true) { + const headers = await GM_head(url); + const h = headerStringToObject(headers); + const size = +h["content-length"]; + let ptr = 0; + let fetchSize = chunkSize; + while (ptr != size) { + const res = await GM_fetch(url, { headers: { range: `bytes=${ptr}-${ptr + fetchSize - 1}` } }); + const obj = headerStringToObject(res.responseHeaders); + if (!("content-length" in obj)) + return; + const len = +obj["content-length"]; + console.log("completed read of ", len); + ptr += len; + if (fetchRestOnNonCanceled) + fetchSize = size; + yield import_buffer3.Buffer.from(await res.arrayBuffer()); + } + } + function iteratorToStream(iterator) { + return new ReadableStream({ + async pull(controller) { + const { value, done } = await iterator.next(); + if (done) { + controller.close(); + } else { + controller.enqueue(value); + } + } + }); + } var processors = [ [/\.png$/, extract, inject], [/\.webm$/, extract2, inject2] ]; var processImage = async (src) => { + if (src.includes("/images/")) + return; const proc = processors.find((e) => src.match(e[0])); if (!proc) return; - const resp = await GM_fetch(src); - const reader = (await resp.blob()).stream(); + const iter = streamRemote(src); + const reader = iteratorToStream(iter); if (!reader) return; return await proc[1](reader.getReader()); @@ -12636,7 +12691,8 @@ cont.pause(); } else if (type?.mime.startsWith("audio")) { cont = document.createElement("audio"); - cont.autoplay = true; + cont.autoplay = false; + cont.pause(); } else { if (!type) type = { mime: "application/unknown", "ext": "data" }; diff --git a/src/main.ts b/src/main.ts index 700f351..5e3f3cd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,6 +7,30 @@ type Awaited = T extends PromiseLike ? U : T const xmlhttprequest = typeof GM_xmlhttpRequest != 'undefined' ? GM_xmlhttpRequest : (GM ? GM.xmlHttpRequest : GM_xmlhttpRequest); +const headerStringToObject = (s: string) => + Object.fromEntries(s.split('\n').map(e => { + const [name, ...rest] = e.split(':'); + return [name.toLowerCase(), rest.join(':').trim()]; + })); + +function GM_head(...[url, opt]: Parameters) { + return new Promise((resolve, reject) => { + // https://www.tampermonkey.net/documentation.php?ext=dhdg#GM_xmlhttpRequest + const gmopt: Tampermonkey.Request = { + url: url.toString(), + data: opt?.body?.toString(), + method: "HEAD", + onload: (resp) => { + resolve(resp.responseHeaders); + }, + ontimeout: () => reject("fetch timeout"), + onerror: () => reject("fetch error"), + onabort: () => reject("fetch abort") + }; + xmlhttprequest(gmopt); + }); +} + function GM_fetch(...[url, opt]: Parameters) { function blobTo(to: string, blob: Blob) { if (to == "arrayBuffer" && blob.arrayBuffer) @@ -32,6 +56,7 @@ function GM_fetch(...[url, opt]: Parameters) { url: url.toString(), data: opt?.body?.toString(), responseType: "blob", + headers: opt?.headers as any, method: "GET", onload: (resp) => { const blob = resp.response as Blob; @@ -50,6 +75,52 @@ function GM_fetch(...[url, opt]: Parameters) { }); } +async function* streamRemote(url: string, chunkSize = 128 * 1024, fetchRestOnNonCanceled = true) { + const headers = await GM_head(url); + const h = headerStringToObject(headers); + const size = +h['content-length']; + let ptr = 0; + let fetchSize = chunkSize; + while (ptr != size) { + const res = await GM_fetch(url, { headers: { range: `bytes=${ptr}-${ptr + fetchSize - 1}` } }) as any as Tampermonkey.Response; + const obj = headerStringToObject(res.responseHeaders); + if (!('content-length' in obj)) + return; + const len = +obj['content-length']; + console.log('completed read of ', len); + ptr += len; + if (fetchRestOnNonCanceled) + fetchSize = size; + yield Buffer.from(await (res as any).arrayBuffer()); + } +} + +function iteratorToStream(iterator: AsyncGenerator) { + return new ReadableStream({ + async pull(controller) { + const { value, done } = await iterator.next(); + + if (done) { + controller.close(); + } else { + controller.enqueue(value); + } + }, + }); +} + +// (async () => { +// const iter = streamRemote("https://i.4cdn.org/g/1641097404527.png", 16 * 1024, false); +// //const str = iteratorToStream(iter); +// const cum: Buffer[] = []; +// for await (const buf of iter) { +// console.log(buf.byteLength); +// cum.push(buf); +// } +// const total = cum.reduce((a, b) => png.concatAB(a, b)); +// console.log(await fileTypeFromBuffer(total)); +// })(); + const processors: [RegExp, (reader: ReadableStreamDefaultReader) => Promise<{ filename: string; data: Buffer } | undefined>, (container: File, inj: File) => Promise][] = [ @@ -58,11 +129,15 @@ const processors: [RegExp, ]; const processImage = async (src: string) => { + if (src.includes('/images/')) // thirdeye removes the original link and puts a non-existing link + return; // cant do shit about that. const proc = processors.find(e => src.match(e[0])); if (!proc) return; - const resp = await GM_fetch(src); - const reader = (await resp.blob()).stream(); + // const resp = await GM_fetch(src); + // const reader = resp.body; + const iter = streamRemote(src); + const reader = iteratorToStream(iter); if (!reader) return; return await proc[1](reader.getReader()); @@ -101,7 +176,8 @@ const processPost = async (post: HTMLDivElement) => { cont.pause(); } else if (type?.mime.startsWith("audio")) { cont = document.createElement("audio"); - cont.autoplay = true; + cont.autoplay = false; + cont.pause(); } else { // If type detection fails, you'd better have an extension if (!type)