-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfor_browser.min.js
1 lines (1 loc) · 7.7 KB
/
for_browser.min.js
1
(()=>{const{Object:e,JSON:t,WeakMap:n,ReferenceError:r,TypeError:o,RangeError:i}=window,{keys:l,getOwnPropertyDescriptor:u}=e,{stringify:f,parse:a}=t,c=new n,{toStringTag:s,toPrimitive:y}=Symbol,g=new Date,p=Number(g);function h(e){return!!e&&e[y]?.bind(g)("number")===p}function d(e,t){if(!e)return!1;if(e instanceof Array&&"length"===t)return!0;let n=u(e,t);return!!n&&n.enumerable}function w(e,t){if(e===t)return!0;if(h(e)&&h(t)&&(n=t,e[y]("number")===n[y]("number")))return!0;var n;if("symbol"==typeof e&&"symbol"==typeof t)return e.description===t.description;let r=typeof e==typeof t,o=e instanceof Array==t instanceof Array,i=(e?e[s]:null)===(t?t[s]:null),l=r&&o&&i&&"object"==typeof e;return l&&e[s]?.includes("Array")?e.length===t.length:l}function b(e,t,n=0){if(!e||!e.length)return t;var o=t,i=0;for(i=0;i<e.length-n;i++){let t=e[i];if(!d(o,t))throw new r("The given list does not point to any nested value in the given pointer");o=o[t]}return o}const A={__proto__:null,undefined:function(){},Date:function(e){return new Date(e)},Uint8Array:function(e){return new Uint8Array(e)},Uint8ClampedArray:function(e){return new Uint8ClampedArray(e)},Uint16Array:function(e){return new Uint16Array(e)},Uint32Array:function(e){return new Uint32Array(e)},BigUint64Array:function(e){return new BigUint64Array(e.split(","))},Int8Array:function(e){return new Int8Array(e)},Int16Array:function(e){return new Int16Array(e)},Int32Array:function(e){return new Int32Array(e)},Int64Array:function(e){return new Int64Array(e)},BigInt64Array:function(e){return new BigInt64Array(e.split(","))},Float32Array:function(e){return new Float32Array(e)},Float64Array:function(e){return new Float64Array(e)},BigInt:function(e){return BigInt(e)},Symbol:function(e){return Symbol(e)}};function m(e){const t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n];return t}function S(e,t){if(null==e)return t?e:null;if(h(e))return t?new Date(e[y]("number")):e[y]("number");let n=e[s];if(n)return"Symbol"===n?t?Symbol(e.description):e.description:"BigInt"===n?t?e:e.toString():n.includes("Big")?t?A[n](m(e).join(",")):m(e).join(","):t?A[n](m(e)):m(e);if("object"!=typeof e)return e;let r=e instanceof Array?[]:{},o=l(e);for(let t=0;t<o.length;t++){let n=e[o[t]];"bigint"!=typeof n&&void 0!==n&&(n&&(n[s]||"object"==typeof n)||(r[o[t]]=n))}return r}function v(e,t){const n=e.get(t);if(!n)return null;let r=e.get(n);if(!r)return e.delete(t);let o=l(t);for(let n=0;n<o.length;n++)"object"==typeof t[o[n]]&&t[o[n]]&&v(e,t[o[n]]);if(--r[4])return null;e.delete(n),e.delete(t)}function T(e,t,n,r,o,i,u){let f=l(e),a=l(t),c=n.get(e);u&&i.set(e,!0),e instanceof Array&&(f.push("length"),a.push("length"));for(let i=0;i<a.length;i++)d(e,a[i])||(v(n,t[a[i]]),delete t[a[i]],r.push([[...o,a[i]]]));for(let l=0;l<f.length;l++){let u=f[l],a=e[u];if(d(t,u)&&a===t[u])continue;if("function"==typeof a||"number"==typeof a&&isNaN(a)){d(t,u)&&(delete t[u],r.push([[...o,u]]));continue}let y=[...o,u],g=c[2]>0&&c[1]<r.length&&o.length>=2?[c[1],u]:y,p=!w(e[u],t[u]),b=n.get(a);"object"==typeof e[u]&&e[u]||"object"!=typeof t[u]||!t[u]||v(n,t[u]);let A=!d(t,u)||p;if(!A&&b&&(b[2]=0),A)if((p||void 0===a)&&(t[u]=b?b[3]:S(a,!0)),b){b[4]++;let[e,t,n]=b;n?e=t:(b[2]=2,b[1]=r.length),r.push([g,e,n])}else if(null===a||void 0!==a&&(!a[s]&&!h(a)))r.push([g,S(a)]);else{a&&"bigint"!=typeof a&&i.set(a,!0);let e=a||"bigint"==typeof a?a[s]||"Date":"undefined";r.push([g,S(a),0,e])}if("symbol"==typeof a||"object"==typeof a&&null!==a){if(!b){const e=n.get(t[u]);e&&n.delete(e),n.set(a,[y,r.length-1,A?1:0,t[u],1]),n.set(t[u],a)}i.get(a)||(i.set(a,!0),T(e[u],t[u],n,r,y,i))}}}const j={__proto__:null,1:function(){return!1},2:function(e,t){if(1===e.length)return!1;try{return b(e[0],t),!1}catch{return!0}},3:function(){return!0}};let I=[];for(let e=0;e<256;e++)I[e]=String.fromCharCode(e);window.objToString=function(e,t){if(Array.isArray(e)||"object"!=typeof e||null===e)throw new o("root element of data MUST be an OBJECT");if(t)var r=S(e,!0);else var{clone:r,map:i}=c.get(e)||{};const l=[[[],i?{}:S(e)]],u=[],a=e&&e[s]||null;if(A[a]&&l[0].push(0,a),!i){r=S(e,!0);var i=new n;c.set(e,{clone:r,map:i})}return i.set(e,[u,0,1,r,1]),T(e,r,i,l,u,new n,!0),f(l)},window.stringToObj=function(t,n,r=3){if(1===r||"1"===r)return n;let o="function"==typeof r?r:j[r];var i=a("string"==typeof t?t:function(e){let t=new Uint8Array(e),n="";for(let e=0;e<t.length;e++)n+=I[t[e]];return n}(t));"object"!=typeof n||null===n?n=2===i[0].length?S(i[0][1]):A[i[0][3]](i[0][1]):i[0][1]=e.assign(n,i[0][1]);for(let t=1;t<i.length;t++){let l=i[t],[u,f]=l[0];if("number"==typeof u&&(l[0]=[...i[u][0],f]),3!==r&&!o(l,n,i))continue;let[a,c,s]=l,y=a.at(-1);if(1===l.length)delete b(a,n,1)[y];else if(2===l.length){let t=b(a,n,1);w(t[y],l[1])&&"string"!=typeof l[1]?e.assign(t[y],l[1]):t[y]=l[1]}else if(3===l.length)b(a,n,1)[y]=b(s>0?i[c][s-1]:c,n);else{let e=b(a,n,1);w(e[y],l[1])||(e[y]=A[l[3]](l[1]))}}return n},window.objValueFrom=b,window.partFilter=function(e,t=!1){Array.isArray(e)||(e=[e]);for(let t=0;t<e.length;t++)if("string"!=typeof e[t])throw new o("manditoryPath MUST be an ARRAY of STRINGs");return"boolean"!=typeof t&&(t=Boolean(t)),function(n,r,o){if(n[0].length<=e.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[0][t])return!1;try{if(!t)return b(n[0],r),!1;if(3!==n.length)return!0}catch{if(3!==n.length)return!0}const i=o[n[1]][n[2]];if(i.length<=e.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==i[t])return!1;try{return!!t||(b(n[0],r),!1)}catch{return!0}}}})(),(()=>{var e=objToString({});WebSocket.prototype.on=WebSocket.prototype.addEventListener;let t=new Map,n=(e,t)=>crypto.getRandomValues(new Uint32Array(1))[0]%(e-t)+t;var r="abcdefgjiklmnopqrstuvwxyz-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ :;.,\\/\"'?!(){}[]@<>=+*#$&`|~^%".split("");function o(e,o){"string"!=typeof o&&(o="webject_");do{var i="",l=n(2*e,e);for(let e=0;e<l;e++)i+=r[n(r.length-1,0)];i=o+i}while(t.has(i));return t.set(i,1),i}window.connect=async function t(n,r,i,l,u=!0){if("string"!=typeof n||"string"!=typeof r)throw new Error("BOTH location AND authToken MUST be STRINGS >:|");if(!0===u&&(u=e=>t(n,r,i,l,u)),"function"!=typeof u&&u)throw new Error("If you choose the optional parameter onFail, it must be a function >:|");if(l&&"object"==typeof l&&("function"!=typeof l.encoder||"function"!=typeof l.decoder))throw new TypeError("If coding parameter is used, it MUST be an object with both 'encoder' and 'decoder' functions");let f=null,a=null,c=null,s=null,y=!1,g=new WebSocket(n),p=new Promise(((e,t)=>(f=e,a=t)));function h(e,t){if(y)return null;let n=e,r=null;isNaN(n)&&(n=e.code),r=1006==n?"closed ABNORMALLY: either you or the server just LOST connection :|":1002==n?"authToken ENCODING FAULT: incorrect encoding/faulty protocol used, according to the server":1001==n?"authToken LOCKED: this is a correct key, but it takes no new connections 0_0":"closed PURPOSEFULLY: check your location and token parameters, OR you got BOOTED :/";let o=`connection with server is OVER due to event: ${t}\n${r}`;f?a(o):console.error(o),clearInterval(c),clearInterval(s),u&&(f?u().then(f):u())}return g.onerror=e=>{console.error("Attempting to connect to a websocket using the location parameter produced the following error :/\n~",e.message),u&&(f?u().then(f):u())},g.on("open",(async()=>{g.send(JSON.stringify(l?[r,await l.encoder(JSON.stringify([o(32,""),Date.now()]))]:r));let t=!1,n=Date.now();async function u(){let t=objToString(i);t!==e&&g.send(l?await l.encoder(t):t)}s=setInterval((function(){Date.now()-n>32768&&(y=!0,h(1006,"Connection Broken"))}),5e3),g.on("message",(async function(e){if(void 0!==e.data&&(e=e.data),"PING"==e)return n=Date.now();i=stringToObj(l?await l.decoder(e):e,i),t||(objToString(i),c=setInterval(u,20),t=!0,f(i))})),g.on("disconnect",(e=>h(e,"disconnect"))),g.on("close",(e=>h(e,"close"))),g.on("error",(e=>h(e,"error")))})),await p}})();