From d9d8c5b3fa55030338ce5b8f2c2e12453a25232d Mon Sep 17 00:00:00 2001 From: X Date: Sat, 10 Apr 2021 17:15:04 +0800 Subject: [PATCH] Update node buffer polyfill --- embed/polyfills/node_buffer.js | 509 +-------------------------------- 1 file changed, 9 insertions(+), 500 deletions(-) diff --git a/embed/polyfills/node_buffer.js b/embed/polyfills/node_buffer.js index 126cc9172..905c6a17f 100644 --- a/embed/polyfills/node_buffer.js +++ b/embed/polyfills/node_buffer.js @@ -1,500 +1,9 @@ -const hexTable = new TextEncoder().encode("0123456789abcdef"); -function fromHexChar(byte) { - if (48 <= byte && byte <= 57) return byte - 48; - if (97 <= byte && byte <= 102) return byte - 97 + 10; - if (65 <= byte && byte <= 70) return byte - 65 + 10; - throw errInvalidByte(byte); -} -function encodedLen(n) { - return n * 2; -} -function encode(src) { - const dst = new Uint8Array(encodedLen(src.length)); - for (let i = 0; i < dst.length; i++) { - const v = src[i]; - dst[i * 2] = hexTable[v >> 4]; - dst[i * 2 + 1] = hexTable[v & 15]; - } - return dst; -} -function encodeToString(src) { - return new TextDecoder().decode(encode(src)); -} -function decodedLen(x) { - return x >>> 1; -} -const base64abc = [ - "A", - "B", - "C", - "D", - "E", - "F", - "G", - "H", - "I", - "J", - "K", - "L", - "M", - "N", - "O", - "P", - "Q", - "R", - "S", - "T", - "U", - "V", - "W", - "X", - "Y", - "Z", - "a", - "b", - "c", - "d", - "e", - "f", - "g", - "h", - "i", - "j", - "k", - "l", - "m", - "n", - "o", - "p", - "q", - "r", - "s", - "t", - "u", - "v", - "w", - "x", - "y", - "z", - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "+", - "/" -]; -function encode1(data) { - const uint8 = typeof data === "string" ? new TextEncoder().encode(data) : data instanceof Uint8Array ? data : new Uint8Array(data); - let result = "", i; - const l = uint8.length; - for (i = 2; i < l; i += 3) { - result += base64abc[uint8[i - 2] >> 2]; - result += base64abc[(uint8[i - 2] & 3) << 4 | uint8[i - 1] >> 4]; - result += base64abc[(uint8[i - 1] & 15) << 2 | uint8[i] >> 6]; - result += base64abc[uint8[i] & 63]; - } - if (i === l + 1) { - result += base64abc[uint8[i - 2] >> 2]; - result += base64abc[(uint8[i - 2] & 3) << 4]; - result += "=="; - } - if (i === l) { - result += base64abc[uint8[i - 2] >> 2]; - result += base64abc[(uint8[i - 2] & 3) << 4 | uint8[i - 1] >> 4]; - result += base64abc[(uint8[i - 1] & 15) << 2]; - result += "="; - } - return result; -} -function decode(b64) { - const binString = atob(b64); - const size = binString.length; - const bytes = new Uint8Array(size); - for (let i = 0; i < size; i++) { - bytes[i] = binString.charCodeAt(i); - } - return bytes; -} -var DiffType; -(function (DiffType1) { - DiffType1["removed"] = "removed"; - DiffType1["common"] = "common"; - DiffType1["added"] = "added"; -})(DiffType || (DiffType = { -})); -function notImplemented(msg) { - const message = msg ? `Not implemented: ${msg}` : "Not implemented"; - throw new Error(message); -} -function slowCases(enc) { - switch (enc.length) { - case 4: - if (enc === "UTF8") return "utf8"; - if (enc === "ucs2" || enc === "UCS2") return "utf16le"; - enc = `${enc}`.toLowerCase(); - if (enc === "utf8") return "utf8"; - if (enc === "ucs2") return "utf16le"; - break; - case 3: - if (enc === "hex" || enc === "HEX" || `${enc}`.toLowerCase() === "hex") { - return "hex"; - } - break; - case 5: - if (enc === "ascii") return "ascii"; - if (enc === "ucs-2") return "utf16le"; - if (enc === "UTF-8") return "utf8"; - if (enc === "ASCII") return "ascii"; - if (enc === "UCS-2") return "utf16le"; - enc = `${enc}`.toLowerCase(); - if (enc === "utf-8") return "utf8"; - if (enc === "ascii") return "ascii"; - if (enc === "ucs-2") return "utf16le"; - break; - case 6: - if (enc === "base64") return "base64"; - if (enc === "latin1" || enc === "binary") return "latin1"; - if (enc === "BASE64") return "base64"; - if (enc === "LATIN1" || enc === "BINARY") return "latin1"; - enc = `${enc}`.toLowerCase(); - if (enc === "base64") return "base64"; - if (enc === "latin1" || enc === "binary") return "latin1"; - break; - case 7: - if (enc === "utf16le" || enc === "UTF16LE" || `${enc}`.toLowerCase() === "utf16le") { - return "utf16le"; - } - break; - case 8: - if (enc === "utf-16le" || enc === "UTF-16LE" || `${enc}`.toLowerCase() === "utf-16le") { - return "utf16le"; - } - break; - default: - if (enc === "") return "utf8"; - } -} -const notImplementedEncodings = [ - "ascii", - "binary", - "latin1", - "ucs2", - "utf16le", -]; -function base64ByteLength(str, bytes) { - if (str.charCodeAt(bytes - 1) === 61) bytes--; - if (bytes > 1 && str.charCodeAt(bytes - 1) === 61) bytes--; - return bytes * 3 >>> 2; -} -function decode1(src) { - const dst = new Uint8Array(decodedLen(src.length)); - for (let i = 0; i < dst.length; i++) { - const a = fromHexChar(src[i * 2]); - const b = fromHexChar(src[i * 2 + 1]); - dst[i] = a << 4 | b; - } - if (src.length % 2 == 1) { - fromHexChar(src[dst.length * 2]); - throw errLength(); - } - return dst; -} -function decodeString(s) { - return decode1(new TextEncoder().encode(s)); -} -function normalizeEncoding(enc) { - if (enc == null || enc === "utf8" || enc === "utf-8") return "utf8"; - return slowCases(enc); -} -function checkEncoding(encoding = "utf8", strict = true) { - if (typeof encoding !== "string" || strict && encoding === "") { - if (!strict) return "utf8"; - throw new TypeError(`Unkown encoding: ${encoding}`); - } - const normalized = normalizeEncoding(encoding); - if (normalized === undefined) { - throw new TypeError(`Unkown encoding: ${encoding}`); - } - if (notImplementedEncodings.includes(encoding)) { - notImplemented(`"${encoding}" encoding`); - } - return normalized; -} -const encodingOps = { - utf8: { - byteLength: (string) => new TextEncoder().encode(string).byteLength - }, - ucs2: { - byteLength: (string) => string.length * 2 - }, - utf16le: { - byteLength: (string) => string.length * 2 - }, - latin1: { - byteLength: (string) => string.length - }, - ascii: { - byteLength: (string) => string.length - }, - base64: { - byteLength: (string) => base64ByteLength(string, string.length) - }, - hex: { - byteLength: (string) => string.length >>> 1 - } -}; -export class Buffer extends Uint8Array { - static alloc(size, fill, encoding = "utf8") { - if (typeof size !== "number") { - throw new TypeError(`The "size" argument must be of type number. Received type ${typeof size}`); - } - const buf = new Buffer(size); - if (size === 0) return buf; - let bufFill; - if (typeof fill === "string") { - const clearEncoding = checkEncoding(encoding); - if (typeof fill === "string" && fill.length === 1 && clearEncoding === "utf8") { - buf.fill(fill.charCodeAt(0)); - } else bufFill = Buffer.from(fill, clearEncoding); - } else if (typeof fill === "number") { - buf.fill(fill); - } else if (fill instanceof Uint8Array) { - if (fill.length === 0) { - throw new TypeError(`The argument "value" is invalid. Received ${fill.constructor.name} []`); - } - bufFill = fill; - } - if (bufFill) { - if (bufFill.length > buf.length) { - bufFill = bufFill.subarray(0, buf.length); - } - let offset = 0; - while (offset < size) { - buf.set(bufFill, offset); - offset += bufFill.length; - if (offset + bufFill.length >= size) break; - } - if (offset !== size) { - buf.set(bufFill.subarray(0, size - offset), offset); - } - } - return buf; - } - static allocUnsafe(size) { - return new Buffer(size); - } - static byteLength(string, encoding = "utf8") { - if (typeof string != "string") return string.byteLength; - encoding = normalizeEncoding(encoding) || "utf8"; - return encodingOps[encoding].byteLength(string); - } - static concat(list, totalLength) { - if (totalLength == undefined) { - totalLength = 0; - for (const buf of list) { - totalLength += buf.length; - } - } - const buffer = Buffer.allocUnsafe(totalLength); - let pos = 0; - for (const item of list) { - let buf; - if (!(item instanceof Buffer)) { - buf = Buffer.from(item); - } else { - buf = item; - } - buf.copy(buffer, pos); - pos += buf.length; - } - return buffer; - } - static from(value, offsetOrEncoding, length) { - const offset = typeof offsetOrEncoding === "string" ? undefined : offsetOrEncoding; - let encoding = typeof offsetOrEncoding === "string" ? offsetOrEncoding : undefined; - if (typeof value == "string") { - encoding = checkEncoding(encoding, false); - if (encoding === "hex") return new Buffer(decodeString(value).buffer); - if (encoding === "base64") return new Buffer(decode(value).buffer); - return new Buffer(new TextEncoder().encode(value).buffer); - } - return new Buffer(value, offset, length); - } - static isBuffer(obj) { - return obj instanceof Buffer; - } - static isEncoding(encoding) { - return typeof encoding === "string" && encoding.length !== 0 && normalizeEncoding(encoding) !== undefined; - } - copy(targetBuffer, targetStart = 0, sourceStart = 0, sourceEnd = this.length) { - const sourceBuffer = this.subarray(sourceStart, sourceEnd).subarray(0, Math.max(0, targetBuffer.length - targetStart)); - if (sourceBuffer.length === 0) return 0; - targetBuffer.set(sourceBuffer, targetStart); - return sourceBuffer.length; - } - equals(otherBuffer) { - if (!(otherBuffer instanceof Uint8Array)) { - throw new TypeError(`The "otherBuffer" argument must be an instance of Buffer or Uint8Array. Received type ${typeof otherBuffer}`); - } - if (this === otherBuffer) return true; - if (this.byteLength !== otherBuffer.byteLength) return false; - for (let i = 0; i < this.length; i++) { - if (this[i] !== otherBuffer[i]) return false; - } - return true; - } - readBigInt64BE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigInt64(offset); - } - readBigInt64LE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigInt64(offset, true); - } - readBigUInt64BE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigUint64(offset); - } - readBigUInt64LE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigUint64(offset, true); - } - readDoubleBE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat64(offset); - } - readDoubleLE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat64(offset, true); - } - readFloatBE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat32(offset); - } - readFloatLE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat32(offset, true); - } - readInt8(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getInt8(offset); - } - readInt16BE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getInt16(offset); - } - readInt16LE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getInt16(offset, true); - } - readInt32BE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getInt32(offset); - } - readInt32LE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getInt32(offset, true); - } - readUInt8(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getUint8(offset); - } - readUInt16BE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getUint16(offset); - } - readUInt16LE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getUint16(offset, true); - } - readUInt32BE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getUint32(offset); - } - readUInt32LE(offset = 0) { - return new DataView(this.buffer, this.byteOffset, this.byteLength).getUint32(offset, true); - } - slice(begin = 0, end = this.length) { - return this.subarray(begin, end); - } - toJSON() { - return { - type: "Buffer", - data: Array.from(this) - }; - } - toString(encoding = "utf8", start = 0, end = this.length) { - encoding = checkEncoding(encoding); - const b = this.subarray(start, end); - if (encoding === "hex") return encodeToString(b); - if (encoding === "base64") return encode1(b.buffer); - return new TextDecoder(encoding).decode(b); - } - write(string, offset = 0, length = this.length) { - return new TextEncoder().encodeInto(string, this.subarray(offset, offset + length)).written; - } - writeBigInt64BE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setBigInt64(offset, value); - return offset + 4; - } - writeBigInt64LE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setBigInt64(offset, value, true); - return offset + 4; - } - writeBigUInt64BE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setBigUint64(offset, value); - return offset + 4; - } - writeBigUInt64LE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setBigUint64(offset, value, true); - return offset + 4; - } - writeDoubleBE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat64(offset, value); - return offset + 8; - } - writeDoubleLE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat64(offset, value, true); - return offset + 8; - } - writeFloatBE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat32(offset, value); - return offset + 4; - } - writeFloatLE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat32(offset, value, true); - return offset + 4; - } - writeInt8(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setInt8(offset, value); - return offset + 1; - } - writeInt16BE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setInt16(offset, value); - return offset + 2; - } - writeInt16LE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setInt16(offset, value, true); - return offset + 2; - } - writeInt32BE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setUint32(offset, value); - return offset + 4; - } - writeInt32LE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setInt32(offset, value, true); - return offset + 4; - } - writeUInt8(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setUint8(offset, value); - return offset + 1; - } - writeUInt16BE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setUint16(offset, value); - return offset + 2; - } - writeUInt16LE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setUint16(offset, value, true); - return offset + 2; - } - writeUInt32BE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setUint32(offset, value); - return offset + 4; - } - writeUInt32LE(value, offset = 0) { - new DataView(this.buffer, this.byteOffset, this.byteLength).setUint32(offset, value, true); - return offset + 4; - } -} -export default { - Buffer -}; +/* esm.sh - esbuild bundle(buffer@6.0.3) es2020 production */ +var ar=Object.create,N=Object.defineProperty,yr=Object.getPrototypeOf,wr=Object.prototype.hasOwnProperty,xr=Object.getOwnPropertyNames,Br=Object.getOwnPropertyDescriptor;var Er=i=>N(i,"__esModule",{value:!0});var k=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports);var dr=(i,r,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of xr(r))!wr.call(i,n)&&n!=="default"&&N(i,n,{get:()=>r[n],enumerable:!(t=Br(r,n))||t.enumerable});return i},H=i=>dr(Er(N(i!=null?ar(yr(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var z=k(_=>{"use strict";_.byteLength=gr;_.toByteArray=mr;_.fromByteArray=Ir;var B=[],w=[],Fr=typeof Uint8Array!="undefined"?Uint8Array:Array,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var F=0,Ar=b.length;F0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=r);var n=t===r?0:4-t%4;return[t,n]}function gr(i){var r=V(i),t=r[0],n=r[1];return(t+n)*3/4-n}function Ur(i,r,t){return(r+t)*3/4-t}function mr(i){var r,t=V(i),n=t[0],e=t[1],o=new Fr(Ur(i,n,e)),u=0,f=e>0?n-4:n,c;for(c=0;c>16&255,o[u++]=r>>8&255,o[u++]=r&255;return e===2&&(r=w[i.charCodeAt(c)]<<2|w[i.charCodeAt(c+1)]>>4,o[u++]=r&255),e===1&&(r=w[i.charCodeAt(c)]<<10|w[i.charCodeAt(c+1)]<<4|w[i.charCodeAt(c+2)]>>2,o[u++]=r>>8&255,o[u++]=r&255),o}function Tr(i){return B[i>>18&63]+B[i>>12&63]+B[i>>6&63]+B[i&63]}function Rr(i,r,t){for(var n,e=[],o=r;of?f:u+o));return n===1?(r=i[t-1],e.push(B[r>>2]+B[r<<4&63]+"==")):n===2&&(r=(i[t-2]<<8)+i[t-1],e.push(B[r>>10]+B[r>>4&63]+B[r<<2&63]+"=")),e.join("")}});var J=k(D=>{D.read=function(i,r,t,n,e){var o,u,f=e*8-n-1,c=(1<>1,s=-7,p=t?e-1:0,I=t?-1:1,x=i[r+p];for(p+=I,o=x&(1<<-s)-1,x>>=-s,s+=f;s>0;o=o*256+i[r+p],p+=I,s-=8);for(u=o&(1<<-s)-1,o>>=-s,s+=n;s>0;u=u*256+i[r+p],p+=I,s-=8);if(o===0)o=1-l;else{if(o===c)return u?NaN:(x?-1:1)*Infinity;u=u+Math.pow(2,n),o=o-l}return(x?-1:1)*u*Math.pow(2,o-n)};D.write=function(i,r,t,n,e,o){var u,f,c,l=o*8-e-1,s=(1<>1,I=e===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:o-1,M=n?1:-1,lr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===Infinity?(f=isNaN(r)?1:0,u=s):(u=Math.floor(Math.log(r)/Math.LN2),r*(c=Math.pow(2,-u))<1&&(u--,c*=2),u+p>=1?r+=I/c:r+=I*Math.pow(2,1-p),r*c>=2&&(u++,c/=2),u+p>=s?(f=0,u=s):u+p>=1?(f=(r*c-1)*Math.pow(2,e),u=u+p):(f=r*Math.pow(2,p-1)*Math.pow(2,e),u=0));e>=8;i[t+x]=f&255,x+=M,f/=256,e-=8);for(u=u<0;i[t+x]=u&255,x+=M,u/=256,l-=8);i[t+x-M]|=lr*128}});var X=k(A=>{"use strict";var $=z(),U=J(),K=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;A.Buffer=h;A.SlowBuffer=Cr;A.INSPECT_MAX_BYTES=50;var S=2147483647;A.kMaxLength=S;h.TYPED_ARRAY_SUPPORT=_r();!h.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 _r(){try{let i=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(i,r),i.foo()===42}catch(i){return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(!!h.isBuffer(this))return this.buffer}});Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(!!h.isBuffer(this))return this.byteOffset}});function d(i){if(i>S)throw new RangeError('The value "'+i+'" is invalid for option "size"');let r=new Uint8Array(i);return Object.setPrototypeOf(r,h.prototype),r}function h(i,r,t){if(typeof i=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return P(i)}return Z(i,r,t)}h.poolSize=8192;function Z(i,r,t){if(typeof i=="string")return Sr(i,r);if(ArrayBuffer.isView(i))return Lr(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(E(i,ArrayBuffer)||i&&E(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(E(i,SharedArrayBuffer)||i&&E(i.buffer,SharedArrayBuffer)))return O(i,r,t);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=i.valueOf&&i.valueOf();if(n!=null&&n!==i)return h.from(n,r,t);let e=Mr(i);if(e)return e;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return h.from(i[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}h.from=function(i,r,t){return Z(i,r,t)};Object.setPrototypeOf(h.prototype,Uint8Array.prototype);Object.setPrototypeOf(h,Uint8Array);function Q(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function Nr(i,r,t){return Q(i),i<=0?d(i):r!==void 0?typeof t=="string"?d(i).fill(r,t):d(i).fill(r):d(i)}h.alloc=function(i,r,t){return Nr(i,r,t)};function P(i){return Q(i),d(i<0?0:G(i)|0)}h.allocUnsafe=function(i){return P(i)};h.allocUnsafeSlow=function(i){return P(i)};function Sr(i,r){if((typeof r!="string"||r==="")&&(r="utf8"),!h.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=v(i,r)|0,n=d(t),e=n.write(i,r);return e!==t&&(n=n.slice(0,e)),n}function Y(i){let r=i.length<0?0:G(i.length)|0,t=d(r);for(let n=0;n=S)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+S.toString(16)+" bytes");return i|0}function Cr(i){return+i!=i&&(i=0),h.alloc(+i)}h.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==h.prototype};h.compare=function(r,t){if(E(r,Uint8Array)&&(r=h.from(r,r.offset,r.byteLength)),E(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(r)||!h.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let n=r.length,e=t.length;for(let o=0,u=Math.min(n,e);oe.length?(h.isBuffer(u)||(u=h.from(u)),u.copy(e,o)):Uint8Array.prototype.set.call(e,u,o);else if(h.isBuffer(u))u.copy(e,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=u.length}return e};function v(i,r){if(h.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||E(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);let t=i.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let e=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return W(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return rr(i).length;default:if(e)return n?-1:W(i).length;r=(""+r).toLowerCase(),e=!0}}h.byteLength=v;function Or(i,r,t){let n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(i||(i="utf8");;)switch(i){case"hex":return $r(this,r,t);case"utf8":case"utf-8":return tr(this,r,t);case"ascii":return br(this,r,t);case"latin1":case"binary":return Dr(this,r,t);case"base64":return kr(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pr(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),n=!0}}h.prototype._isBuffer=!0;function m(i,r,t){let n=i[r];i[r]=i[t],i[t]=n}h.prototype.swap16=function(){let r=this.length;if(r%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tt&&(r+=" ... "),""};K&&(h.prototype[K]=h.prototype.inspect);h.prototype.compare=function(r,t,n,e,o){if(E(r,Uint8Array)&&(r=h.from(r,r.offset,r.byteLength)),!h.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),n===void 0&&(n=r?r.length:0),e===void 0&&(e=0),o===void 0&&(o=this.length),t<0||n>r.length||e<0||o>this.length)throw new RangeError("out of range index");if(e>=o&&t>=n)return 0;if(e>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,e>>>=0,o>>>=0,this===r)return 0;let u=o-e,f=n-t,c=Math.min(u,f),l=this.slice(e,o),s=r.slice(t,n);for(let p=0;p2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,q(t)&&(t=e?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(e)return-1;t=i.length-1}else if(t<0)if(e)t=0;else return-1;if(typeof r=="string"&&(r=h.from(r,n)),h.isBuffer(r))return r.length===0?-1:ir(i,r,t,n,e);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?e?Uint8Array.prototype.indexOf.call(i,r,t):Uint8Array.prototype.lastIndexOf.call(i,r,t):ir(i,[r],t,n,e);throw new TypeError("val must be string, number or Buffer")}function ir(i,r,t,n,e){let o=1,u=i.length,f=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(i.length<2||r.length<2)return-1;o=2,u/=2,f/=2,t/=2}function c(s,p){return o===1?s[p]:s.readUInt16BE(p*o)}let l;if(e){let s=-1;for(l=t;lu&&(t=u-f),l=t;l>=0;l--){let s=!0;for(let p=0;pe&&(n=e)):n=e;let o=r.length;n>o/2&&(n=o/2);let u;for(u=0;u>>0,isFinite(n)?(n=n>>>0,e===void 0&&(e="utf8")):(e=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),r.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");e||(e="utf8");let u=!1;for(;;)switch(e){case"hex":return Gr(this,r,t,n);case"utf8":case"utf-8":return Yr(this,r,t,n);case"ascii":case"latin1":case"binary":return Wr(this,r,t,n);case"base64":return jr(this,r,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Hr(this,r,t,n);default:if(u)throw new TypeError("Unknown encoding: "+e);e=(""+e).toLowerCase(),u=!0}};h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function kr(i,r,t){return r===0&&t===i.length?$.fromByteArray(i):$.fromByteArray(i.slice(r,t))}function tr(i,r,t){t=Math.min(i.length,t);let n=[],e=r;for(;e239?4:o>223?3:o>191?2:1;if(e+f<=t){let c,l,s,p;switch(f){case 1:o<128&&(u=o);break;case 2:c=i[e+1],(c&192)==128&&(p=(o&31)<<6|c&63,p>127&&(u=p));break;case 3:c=i[e+1],l=i[e+2],(c&192)==128&&(l&192)==128&&(p=(o&15)<<12|(c&63)<<6|l&63,p>2047&&(p<55296||p>57343)&&(u=p));break;case 4:c=i[e+1],l=i[e+2],s=i[e+3],(c&192)==128&&(l&192)==128&&(s&192)==128&&(p=(o&15)<<18|(c&63)<<12|(l&63)<<6|s&63,p>65535&&p<1114112&&(u=p))}}u===null?(u=65533,f=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|u&1023),n.push(u),e+=f}return Vr(n)}var er=4096;function Vr(i){let r=i.length;if(r<=er)return String.fromCharCode.apply(String,i);let t="",n=0;for(;nn)&&(t=n);let e="";for(let o=r;on&&(r=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),tt)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||a(r,t,this.length);let e=this[r],o=1,u=0;for(;++u>>0,t=t>>>0,n||a(r,t,this.length);let e=this[r+--t],o=1;for(;t>0&&(o*=256);)e+=this[r+--t]*o;return e};h.prototype.readUint8=h.prototype.readUInt8=function(r,t){return r=r>>>0,t||a(r,1,this.length),this[r]};h.prototype.readUint16LE=h.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||a(r,2,this.length),this[r]|this[r+1]<<8};h.prototype.readUint16BE=h.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||a(r,2,this.length),this[r]<<8|this[r+1]};h.prototype.readUint32LE=h.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||a(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};h.prototype.readUint32BE=h.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||a(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};h.prototype.readBigUInt64LE=g(function(r){r=r>>>0,T(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&C(r,this.length-8);let e=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,o=this[++r]+this[++r]*2**8+this[++r]*2**16+n*2**24;return BigInt(e)+(BigInt(o)<>>0,T(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&C(r,this.length-8);let e=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],o=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n;return(BigInt(e)<>>0,t=t>>>0,n||a(r,t,this.length);let e=this[r],o=1,u=0;for(;++u=o&&(e-=Math.pow(2,8*t)),e};h.prototype.readIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||a(r,t,this.length);let e=t,o=1,u=this[r+--e];for(;e>0&&(o*=256);)u+=this[r+--e]*o;return o*=128,u>=o&&(u-=Math.pow(2,8*t)),u};h.prototype.readInt8=function(r,t){return r=r>>>0,t||a(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};h.prototype.readInt16LE=function(r,t){r=r>>>0,t||a(r,2,this.length);let n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};h.prototype.readInt16BE=function(r,t){r=r>>>0,t||a(r,2,this.length);let n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};h.prototype.readInt32LE=function(r,t){return r=r>>>0,t||a(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};h.prototype.readInt32BE=function(r,t){return r=r>>>0,t||a(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};h.prototype.readBigInt64LE=g(function(r){r=r>>>0,T(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&C(r,this.length-8);let e=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(n<<24);return(BigInt(e)<>>0,T(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&C(r,this.length-8);let e=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(e)<>>0,t||a(r,4,this.length),U.read(this,r,!0,23,4)};h.prototype.readFloatBE=function(r,t){return r=r>>>0,t||a(r,4,this.length),U.read(this,r,!1,23,4)};h.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||a(r,8,this.length),U.read(this,r,!0,52,8)};h.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||a(r,8,this.length),U.read(this,r,!1,52,8)};function y(i,r,t,n,e,o){if(!h.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>e||ri.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(r,t,n,e){if(r=+r,t=t>>>0,n=n>>>0,!e){let f=Math.pow(2,8*n)-1;y(this,r,t,n,f,0)}let o=1,u=0;for(this[t]=r&255;++u>>0,n=n>>>0,!e){let f=Math.pow(2,8*n)-1;y(this,r,t,n,f,0)}let o=n-1,u=1;for(this[t+o]=r&255;--o>=0&&(u*=256);)this[t+o]=r/u&255;return t+n};h.prototype.writeUint8=h.prototype.writeUInt8=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,1,255,0),this[t]=r&255,t+1};h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function ur(i,r,t,n,e){or(r,n,e,i,t,7);let o=Number(r&BigInt(4294967295));i[t++]=o,o=o>>8,i[t++]=o,o=o>>8,i[t++]=o,o=o>>8,i[t++]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return i[t++]=u,u=u>>8,i[t++]=u,u=u>>8,i[t++]=u,u=u>>8,i[t++]=u,t}function hr(i,r,t,n,e){or(r,n,e,i,t,7);let o=Number(r&BigInt(4294967295));i[t+7]=o,o=o>>8,i[t+6]=o,o=o>>8,i[t+5]=o,o=o>>8,i[t+4]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return i[t+3]=u,u=u>>8,i[t+2]=u,u=u>>8,i[t+1]=u,u=u>>8,i[t]=u,t+8}h.prototype.writeBigUInt64LE=g(function(r,t=0){return ur(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});h.prototype.writeBigUInt64BE=g(function(r,t=0){return hr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});h.prototype.writeIntLE=function(r,t,n,e){if(r=+r,t=t>>>0,!e){let c=Math.pow(2,8*n-1);y(this,r,t,n,c-1,-c)}let o=0,u=1,f=0;for(this[t]=r&255;++o>0)-f&255;return t+n};h.prototype.writeIntBE=function(r,t,n,e){if(r=+r,t=t>>>0,!e){let c=Math.pow(2,8*n-1);y(this,r,t,n,c-1,-c)}let o=n-1,u=1,f=0;for(this[t+o]=r&255;--o>=0&&(u*=256);)r<0&&f===0&&this[t+o+1]!==0&&(f=1),this[t+o]=(r/u>>0)-f&255;return t+n};h.prototype.writeInt8=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};h.prototype.writeInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};h.prototype.writeInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};h.prototype.writeInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};h.prototype.writeInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};h.prototype.writeBigInt64LE=g(function(r,t=0){return ur(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});h.prototype.writeBigInt64BE=g(function(r,t=0){return hr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function fr(i,r,t,n,e,o){if(t+n>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function cr(i,r,t,n,e){return r=+r,t=t>>>0,e||fr(i,r,t,4,34028234663852886e22,-34028234663852886e22),U.write(i,r,t,n,23,4),t+4}h.prototype.writeFloatLE=function(r,t,n){return cr(this,r,t,!0,n)};h.prototype.writeFloatBE=function(r,t,n){return cr(this,r,t,!1,n)};function pr(i,r,t,n,e){return r=+r,t=t>>>0,e||fr(i,r,t,8,17976931348623157e292,-17976931348623157e292),U.write(i,r,t,n,52,8),t+8}h.prototype.writeDoubleLE=function(r,t,n){return pr(this,r,t,!0,n)};h.prototype.writeDoubleBE=function(r,t,n){return pr(this,r,t,!1,n)};h.prototype.copy=function(r,t,n,e){if(!h.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),!e&&e!==0&&(e=this.length),t>=r.length&&(t=r.length),t||(t=0),e>0&&e=this.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("sourceEnd out of bounds");e>this.length&&(e=this.length),r.length-t>>0,n=n===void 0?this.length:n>>>0,r||(r=0);let o;if(typeof r=="number")for(o=t;o2**32?e=sr(String(t)):typeof t=="bigint"&&(e=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(e=sr(e)),e+="n"),n+=` It must be ${r}. Received ${e}`,n},RangeError);function sr(i){let r="",t=i.length,n=i[0]==="-"?1:0;for(;t>=n+4;t-=3)r=`_${i.slice(t-3,t)}${r}`;return`${i.slice(0,t)}${r}`}function Jr(i,r,t){T(r,"offset"),(i[r]===void 0||i[r+t]===void 0)&&C(r,i.length-(t+1))}function or(i,r,t,n,e,o){if(i>t||i3?r===0||r===BigInt(0)?f=`>= 0${u} and < 2${u} ** ${(o+1)*8}${u}`:f=`>= -(2${u} ** ${(o+1)*8-1}${u}) and < 2 ** ${(o+1)*8-1}${u}`:f=`>= ${r}${u} and <= ${t}${u}`,new R.ERR_OUT_OF_RANGE("value",f,i)}Jr(n,e,o)}function T(i,r){if(typeof i!="number")throw new R.ERR_INVALID_ARG_TYPE(r,"number",i)}function C(i,r,t){throw Math.floor(i)!==i?(T(i,t),new R.ERR_OUT_OF_RANGE(t||"offset","an integer",i)):r<0?new R.ERR_BUFFER_OUT_OF_BOUNDS:new R.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,i)}var Kr=/[^+/0-9A-Za-z-_]/g;function Zr(i){if(i=i.split("=")[0],i=i.trim().replace(Kr,""),i.length<2)return"";for(;i.length%4!=0;)i=i+"=";return i}function W(i,r){r=r||Infinity;let t,n=i.length,e=null,o=[];for(let u=0;u55295&&t<57344){if(!e){if(t>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}e=t;continue}if(t<56320){(r-=3)>-1&&o.push(239,191,189),e=t;continue}t=(e-55296<<10|t-56320)+65536}else e&&(r-=3)>-1&&o.push(239,191,189);if(e=null,t<128){if((r-=1)<0)break;o.push(t)}else if(t<2048){if((r-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function qr(i){let r=[];for(let t=0;t>8,e=t%256,o.push(e),o.push(n);return o}function rr(i){return $.toByteArray(Zr(i))}function L(i,r,t,n){let e;for(e=0;e=r.length||e>=i.length);++e)r[e+t]=i[e];return e}function E(i,r){return i instanceof r||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===r.name}function q(i){return i!==i}var zr=function(){let i="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let e=0;e<16;++e)r[n+e]=i[t]+i[e]}return r}();function g(i){return typeof BigInt=="undefined"?Qr:i}function Qr(){throw new Error("BigInt not supported")}});var vr=H(X()),rt=H(X()),{INSPECT_MAX_BYTES:ht,kMaxLength:ft,Buffer:ct,SlowBuffer:pt}=vr;var export_default=rt.default;export{ct as Buffer,ht as INSPECT_MAX_BYTES,pt as SlowBuffer,export_default as default,ft as kMaxLength}; +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ \ No newline at end of file