yolkbot 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import r from"./api.js";import{ProxiesEnabled as h}from"./constants/index.js";import{validate as c}from"./wasm/wrapper.js";import f from"./socket.js";class a{connected=!1;onceConnected=[];regionList=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#e=!1;#t=!1;constructor(s={}){this.#e=s.noExitOnError||!1,s.instance||(s.instance="shellshock.io"),s.protocol||(s.protocol="wss"),s.api?this.api=s.api:this.api=new r({instance:s.instance,protocol:s.protocol,proxy:s.proxy}),s.sessionId||s.noLogin?this.sessionId=s.sessionId:this.#n(),s.proxy&&!h?this.#i("proxies do not work and hence are not supported in the browser"):s.proxy&&(this.proxy=s.proxy),this.#o(s.instance,s.protocol,s.noLogin)}async#o(s,i,e){const t=async()=>{try{this.ws=new f(`${i}://${s}/matchmaker/`,this.proxy),this.ws.onerror=async o=>(this.#i(o),await new Promise(n=>setTimeout(n,100)),await t())}catch{await new Promise(o=>setTimeout(o,100)),await t()}};await t(),this.ws.onopen=()=>{this.connected=!0,this.ws.onerror=null,(this.sessionId||e)&&this.onceConnected.forEach(o=>o())},this.ws.onmessage=o=>{const n=JSON.parse(o.data);n.command==="validateUUID"&&this.ws.send(JSON.stringify({command:"validateUUID",hash:c(n.uuid)})),this.#s("msg",n)},this.ws.onclose=()=>{this.connected=!1,this.#t||this.#o(s)}}async#n(){const s=await this.api.loginAnonymously();(!s||typeof s=="string")&&this.#s("authFail",s),this.sessionId=s.sessionId,this.connected&&this.onceConnected.forEach(i=>i())}send(s){this.ws.send(JSON.stringify(s))}async waitForConnect(){return new Promise(s=>{this.connected?s():this.onceConnected.push(s)})}async getRegions(){await this.waitForConnect();const s=this;return new Promise(i=>{const e=t=>{t.command==="regionList"&&(this.regionList=t.regionList,this.off("msg",e),i(t.regionList))};this.on("msg",e),this.ws.onerror=t=>s.#i("failed to get regions",t),this.ws.send(JSON.stringify({command:"regionList"}))})}close(){this.#t=!0,this.connected=!1,this.ws.close()}on(s,i){this.onListeners.has(s)||this.onListeners.set(s,[]),this.onListeners.get(s).push(i)}once(s,i){this.onceListeners.has(s)||this.onceListeners.set(s,[]),this.onceListeners.get(s).push(i)}off(s,i){this.onListeners.has(s)&&this.onListeners.set(s,this.onListeners.get(s).filter(e=>e!==i)),this.onceListeners.has(s)&&this.onceListeners.set(s,this.onceListeners.get(s).filter(e=>e!==i))}#s(s,...i){this.onListeners.has(s)&&this.onListeners.get(s).forEach(e=>e(...i)),this.onceListeners.has(s)&&(this.onceListeners.get(s).forEach(e=>e(...i)),this.onceListeners.delete(s))}#i(s){this.onListeners.has("error")?this.#s("error",s):(console.error(s),this.#e||process.exit(1))}}var y=a;export{a as Matchmaker,y as default};
3
+ import r from"./api.js";import{ProxiesEnabled as h}from"./constants/index.js";import{validate as c}from"./wasm/wrapper.js";import f from"./socket.js";class a{connected=!1;onceConnected=[];regionList=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#e=!1;#t=!1;constructor(s={}){this.#e=s.noExitOnError||!1,s.instance||(s.instance="shellshock.io"),s.protocol||(s.protocol="wss"),s.api?this.api=s.api:this.api=new r({instance:s.instance,protocol:s.protocol,proxy:s.proxy}),s.sessionId||s.noLogin?this.sessionId=s.sessionId:this.#n(),s.proxy&&!h?this.#i("proxies do not work and hence are not supported in the browser"):s.proxy&&(this.proxy=s.proxy),this.#o(s.instance,s.protocol,s.noLogin)}async#o(s,i,e){const t=async()=>{try{this.ws=new f(`${i}://${s}/matchmaker/`,this.proxy),this.ws.onerror=async o=>(this.#i(o),await new Promise(n=>setTimeout(n,100)),await t())}catch{await new Promise(o=>setTimeout(o,100)),await t()}};await t(),this.ws.onopen=()=>{this.connected=!0,this.ws.onerror=null,(this.sessionId||e)&&this.onceConnected.forEach(o=>o())},this.ws.onmessage=o=>{const n=JSON.parse(o.data);n.command==="validateUUID"&&this.ws.send(JSON.stringify({command:"validateUUID",hash:c(n.uuid)})),this.#s("msg",n)},this.ws.onclose=()=>{this.connected=!1,this.#t||this.#o(s,i,e)}}async#n(){const s=await this.api.loginAnonymously();(!s||typeof s=="string")&&this.#s("authFail",s),this.sessionId=s.sessionId,this.connected&&this.onceConnected.forEach(i=>i())}send(s){this.ws.send(JSON.stringify(s))}async waitForConnect(){return new Promise(s=>{this.connected?s():this.onceConnected.push(s)})}async getRegions(){await this.waitForConnect();const s=this;return new Promise(i=>{const e=t=>{t.command==="regionList"&&(this.regionList=t.regionList,this.off("msg",e),i(t.regionList))};this.on("msg",e),this.ws.onerror=t=>s.#i("failed to get regions",t),this.ws.send(JSON.stringify({command:"regionList"}))})}close(){this.#t=!0,this.connected=!1,this.ws.close()}on(s,i){this.onListeners.has(s)||this.onListeners.set(s,[]),this.onListeners.get(s).push(i)}once(s,i){this.onceListeners.has(s)||this.onceListeners.set(s,[]),this.onceListeners.get(s).push(i)}off(s,i){this.onListeners.has(s)&&this.onListeners.set(s,this.onListeners.get(s).filter(e=>e!==i)),this.onceListeners.has(s)&&this.onceListeners.set(s,this.onceListeners.get(s).filter(e=>e!==i))}#s(s,...i){this.onListeners.has(s)&&this.onListeners.get(s).forEach(e=>e(...i)),this.onceListeners.has(s)&&(this.onceListeners.get(s).forEach(e=>e(...i)),this.onceListeners.delete(s))}#i(s){this.onListeners.has("error")?this.#s("error",s):(console.error(s),this.#e||process.exit(1))}}var y=a;export{a as Matchmaker,y as default};
package/dist/socket.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import s from"./globals.js";import{IsBrowser as n,UserAgent as o}from"./constants/index.js";class c extends s.WebSocket{constructor(e,t){n?super(e):super(e,{agent:t?new s.SocksProxyAgent(t):void 0,headers:{"accept-encoding":"gzip, deflate, br, zstd","accept-language":"en-US,en;q=0.9","cache-control":"no-cache",connection:"Upgrade",host:e.split("/")[2],origin:(e.split("/")[0]+"//"+e.split("/")[2]).replace("ws","http"),pragma:"no-cache","sec-websocket-extensions":"permessage-deflate; client_max_window_bits",upgrade:"websocket","user-agent":o}})}}var p=c;export{p as default};
3
+ import s from"./globals.js";import{IsBrowser as n,UserAgent as o}from"./constants/index.js";class c extends s.WebSocket{constructor(e,t){n?super(e):super(e,{agent:t?new s.SocksProxyAgent(t):void 0,headers:{"accept-encoding":"gzip, deflate, br, zstd","accept-language":"en-US,en;q=0.9","cache-control":"no-cache",connection:"Upgrade",host:e.split("/")[2],origin:(e.split("/")[0]+"//"+e.split("/")[2]).replace("ws","http"),pragma:"no-cache","sec-websocket-extensions":"permessage-deflate; client_max_window_bits","user-agent":o}})}}var p=c;export{p as default};
@@ -51,7 +51,7 @@ export declare const CollectType: {
51
51
  Grenade: number;
52
52
  };
53
53
 
54
- export declare const CoopStates: {
54
+ export declare const CoopState: {
55
55
  Start: number;
56
56
  Score: number;
57
57
  Win: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yolkbot",
3
3
  "description": "create a shell shockers bot in under 10 lines.",
4
- "version": "1.1.2",
4
+ "version": "1.1.4",
5
5
  "keywords": [
6
6
  "shell shockers",
7
7
  "shellshock.io",