@chirper/node 0.0.104 → 0.0.106

Sign up to get free protection for your applications and to get access to all the features.
package/dist/bundle.js CHANGED
@@ -1 +1 @@
1
- var vt=Object.create;var O=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var D=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),St=(r,t)=>{for(var e in t)O(r,e,{get:t[e],enumerable:!0})},F=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of wt(t))!xt.call(r,o)&&o!==e&&O(r,o,{get:()=>t[o],enumerable:!(i=yt(t,o))||i.enumerable});return r};var C=(r,t,e)=>(e=r!=null?vt(bt(r)):{},F(t||!r||!r.__esModule?O(e,"default",{value:r,enumerable:!0}):e,r)),Ot=r=>F(O({},"__esModule",{value:!0}),r);var T=D((Pt,U)=>{var I=(()=>{var r=Object.defineProperty,t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,o=(f,c,p)=>c in f?r(f,c,{enumerable:!0,configurable:!0,writable:!0,value:p}):f[c]=p,u=(f,c)=>{for(var p in c||(c={}))e.call(c,p)&&o(f,p,c[p]);if(t)for(var p of t(c))i.call(c,p)&&o(f,p,c[p]);return f},l=f=>r(f,"__esModule",{value:!0}),m=(f,c)=>{l(f);for(var p in c)r(f,p,{get:c[p],enumerable:!0})},s={};m(s,{DEFAULT_UUID_LENGTH:()=>v,default:()=>w});var y="4.4.4",v=6,h={dictionary:"alphanum",shuffle:!0,debug:!1,length:v},b=class extends Function{constructor(f={}){super(),this.dictIndex=0,this.dictRange=[],this.lowerBound=0,this.upperBound=0,this.dictLength=0,this._digit_first_ascii=48,this._digit_last_ascii=58,this._alpha_lower_first_ascii=97,this._alpha_lower_last_ascii=123,this._hex_last_ascii=103,this._alpha_upper_first_ascii=65,this._alpha_upper_last_ascii=91,this._number_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii]},this._alpha_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alpha_lower_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alpha_upper_dict_ranges={upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_lower_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alphanum_upper_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._hex_dict_ranges={decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]},this.log=(...n)=>{let a=[...n];if(a[0]=`[short-unique-id] ${n[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...a)},this.setDictionary=(n,a)=>{let d;if(n&&Array.isArray(n)&&n.length>1)d=n;else{d=[];let _;this.dictIndex=_=0;let x=`_${n}_dict_ranges`,N=this[x];Object.keys(N).forEach($t=>{let mt=$t;for(this.dictRange=N[mt],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=_=this.lowerBound;this.lowerBound<=this.upperBound?_<this.upperBound:_>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?_+=1:_-=1)d.push(String.fromCharCode(this.dictIndex))})}a&&(d=d.sort(()=>Math.random()-.5)),this.dict=d,this.dictLength=this.dict.length,this.counter=0},this.seq=()=>this.sequentialUUID(),this.sequentialUUID=()=>{let n,a,d="";n=this.counter;do a=n%this.dictLength,n=Math.trunc(n/this.dictLength),d+=this.dict[a];while(n!==0);return this.counter+=1,d},this.randomUUID=(n=this.uuidLength||v)=>{let a,d,_;if(n===null||typeof n>"u"||n<1)throw new Error("Invalid UUID Length Provided");let x=n>=0;for(a="",_=0;_<n;_+=1)d=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,a+=this.dict[d];return a},this.availableUUIDs=(n=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,n).toFixed(0)),this.approxMaxBeforeCollision=(n=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*n).toFixed(20)),this.collisionProbability=(n=this.availableUUIDs(this.uuidLength),a=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(n)/this.availableUUIDs(a)).toFixed(20)),this.uniqueness=(n=this.availableUUIDs(this.uuidLength))=>{let a=parseFloat((1-this.approxMaxBeforeCollision(n)/n).toFixed(20));return a>1?1:a<0?0:a},this.getVersion=()=>this.version,this.stamp=n=>{if(typeof n!="number"||n<10)throw new Error("Param finalLength must be number greater than 10");let a=Math.floor(+new Date/1e3).toString(16),d=n-9,_=Math.round(Math.random()*(d>15?15:d)),x=this.randomUUID(d);return`${x.substr(0,_)}${a}${x.substr(_)}${_.toString(16)}`},this.parseStamp=n=>{if(n.length<10)throw new Error("Stamp length invalid");let a=parseInt(n.substr(n.length-1,1),16);return new Date(parseInt(n.substr(a,8),16)*1e3)};let c=u(u({},h),f);this.counter=0,this.debug=!1,this.dict=[],this.version=y;let{dictionary:p,shuffle:pt,length:_t}=c;return this.uuidLength=_t,this.setDictionary(p,pt),this.debug=c.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength}`),new Proxy(this,{apply:(n,a,d)=>this.randomUUID(...d)})}},w=b;return w.default=b,s})();typeof U<"u"&&(U.exports=I.default),typeof window<"u"&&(I=I.default)});var A=D((Nt,P)=>{"use strict";var Ct=Object.prototype.hasOwnProperty,$="~";function S(){}Object.create&&(S.prototype=Object.create(null),new S().__proto__||($=!1));function kt(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function M(r,t,e,i,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var u=new kt(e,i||r,o),l=$?$+t:t;return r._events[l]?r._events[l].fn?r._events[l]=[r._events[l],u]:r._events[l].push(u):(r._events[l]=u,r._eventsCount++),r}function k(r,t){--r._eventsCount===0?r._events=new S:delete r._events[t]}function g(){this._events=new S,this._eventsCount=0}g.prototype.eventNames=function(){var t=[],e,i;if(this._eventsCount===0)return t;for(i in e=this._events)Ct.call(e,i)&&t.push($?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};g.prototype.listeners=function(t){var e=$?$+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var o=0,u=i.length,l=new Array(u);o<u;o++)l[o]=i[o].fn;return l};g.prototype.listenerCount=function(t){var e=$?$+t:t,i=this._events[e];return i?i.fn?1:i.length:0};g.prototype.emit=function(t,e,i,o,u,l){var m=$?$+t:t;if(!this._events[m])return!1;var s=this._events[m],y=arguments.length,v,h;if(s.fn){switch(s.once&&this.removeListener(t,s.fn,void 0,!0),y){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,e),!0;case 3:return s.fn.call(s.context,e,i),!0;case 4:return s.fn.call(s.context,e,i,o),!0;case 5:return s.fn.call(s.context,e,i,o,u),!0;case 6:return s.fn.call(s.context,e,i,o,u,l),!0}for(h=1,v=new Array(y-1);h<y;h++)v[h-1]=arguments[h];s.fn.apply(s.context,v)}else{var b=s.length,w;for(h=0;h<b;h++)switch(s[h].once&&this.removeListener(t,s[h].fn,void 0,!0),y){case 1:s[h].fn.call(s[h].context);break;case 2:s[h].fn.call(s[h].context,e);break;case 3:s[h].fn.call(s[h].context,e,i);break;case 4:s[h].fn.call(s[h].context,e,i,o);break;default:if(!v)for(w=1,v=new Array(y-1);w<y;w++)v[w-1]=arguments[w];s[h].fn.apply(s[h].context,v)}}return!0};g.prototype.on=function(t,e,i){return M(this,t,e,i,!1)};g.prototype.once=function(t,e,i){return M(this,t,e,i,!0)};g.prototype.removeListener=function(t,e,i,o){var u=$?$+t:t;if(!this._events[u])return this;if(!e)return k(this,u),this;var l=this._events[u];if(l.fn)l.fn===e&&(!o||l.once)&&(!i||l.context===i)&&k(this,u);else{for(var m=0,s=[],y=l.length;m<y;m++)(l[m].fn!==e||o&&!l[m].once||i&&l[m].context!==i)&&s.push(l[m]);s.length?this._events[u]=s.length===1?s[0]:s:k(this,u)}return this};g.prototype.removeAllListeners=function(t){var e;return t?(e=$?$+t:t,this._events[e]&&k(this,e)):(this._events=new S,this._eventsCount=0),this};g.prototype.off=g.prototype.removeListener;g.prototype.addListener=g.prototype.on;g.prefixed=$;g.EventEmitter=g;typeof P<"u"&&(P.exports=g)});var It={};St(It,{default:()=>L});module.exports=Ot(It);var ct=C(require("pako")),dt=C(T()),ft=C(require("socket.io-client")),gt=require("compress-json");var E=C(A(),1);var B=r=>({get:(t,e)=>r.get(`/post/${t?.id||t}`,{lang:e},!1,!1),list:(t={})=>r.get("/post",t,!1,!1),add:(t,e)=>r.post(`/post/${t?.id||t}/add`,{character:e?.id||e}),influence:(t,{value:e,message:i})=>r.post(`/post/${t?.id||t}/influence`,{value:e,message:i}),count:t=>r.get(`/post/${t?.id||t}/count`),delete:t=>r.delete(`/post/${t?.id||t}`),create:(t={})=>r.post("/post",t),subscribe:t=>r.post(`/post/${t?.id||t}/subscribe`),unsubscribe:t=>r.delete(`/post/${t?.id||t}/subscribe`)});var J=r=>({get:(t,e={})=>r.get(`/user/${t}`,e),list:(t={})=>r.get("/user",t),image:(t,e={})=>r.post(`/user/${t?.id||t}/image`,e),update:(t={})=>r.patch(`/user/${t.id}`,t),validate:(t,e,i)=>r.get("/user/value",{key:e,value:i,user:t?.id}),password:(t,e,i)=>r.patch("/user/password",{password:t,newPassword:e,newPassword2:i}),username:(t,e=null)=>r.post("/user/username",{username:t,id:e?.id||e}),suggestion:(t={})=>r.get("/user/suggestion",t),Pin:{list:(t={})=>r.get("/user/pin",t),create:(t={})=>r.post("/user/pin",t),update:(t={})=>r.patch("/user/pin",t),delete:(t={})=>r.delete("/user/pin",t)}});var q=r=>({get:(t,e)=>r.get(`/chat/${t?.id||t}`,e),list:t=>r.get("/chat",t),read:t=>r.get(`/chat/${t?.id||t}/read`),create:(t,e)=>r.post(`/chat/${t?.id||t}`,e),typing:(t,e=!0)=>r.post(`/chat/${t?.id||t}/typing`,{typing:e}),leaveChat:t=>r.delete(`/chat/${t?.id||t}`),readChat:t=>r.post(`/chat/${t?.id||t}/read`),loadMembers:(t,e)=>r.get(`/chat/${t?.id||t}/member`,e),loadMessages:(t,e)=>r.get(`/chat/${t?.id||t}/message`,e),sendMessage:(t,e)=>r.post(`/chat/${t?.id||t}/message`,e),inviteMember:(t,e)=>r.post(`/chat/${t?.id||t}/member`,{member:e?.id||e}),removeMember:(t,e)=>r.delete(`/chat/${t?.id||t}/member/${e?.id||e}`)});var R=r=>({get:(t,e={})=>r.get(`/file/${t?.id||t}`,e),list:(t={})=>r.get("/file",t),modelList:(t={})=>r.get("/file/model",t),like:(t,e={})=>r.post(`/file/${t?.id||t}/like`,e),liked:(t,e={})=>r.get(`/file/${t?.id||t}/like`,e)});var K=r=>({get:(t,e=null,i=null)=>r.get(`/:account/stat/${t}`,{from:e,to:i})});var G=r=>({get:(t,e={})=>r.get(`/item/${t?.id||t}`,e),list:(t={})=>r.get("/item",t),delete:(t,e={})=>r.delete(`/item/${t?.id||t}`,e)});var V=r=>({get:(t,e={})=>r.get(`/like/${t?.id||t}`,e),toggle:(t,e={})=>r.post(`/like/${t?.id||t}`,e)});var H=r=>({get:(t,e={})=>r.get(`/play/${t?.id||t}`,e),play:(t,e={})=>r.post(`/play/${t?.id||t}`,e)});var z=r=>({get:(t,e={})=>r.get(`/view/${t?.id||t}`,e),view:(t,e={})=>r.post(`/view/${t?.id||t}`,e)});var W=r=>({get:(t,e={})=>r.get(`/share/${t?.id||t}`,e),share:(t,e={})=>r.post(`/share/${t?.id||t}`,e)});var Y=r=>({get:(t,e={})=>r.get(`/place/${t?.id||t}`,e),list:(t={})=>r.get("/place",t)});var Q=r=>({code:(t,e)=>r.post("/oauth2/code",{application:t,redirect:e})});var X=r=>({get:(t,e={})=>r.get(`/story/${t?.id||t}`,e),list:(t={})=>r.get("/story",t),Frame:{list:(t={})=>r.get(`/story/${t?.story?.id||t?.story}/frame`,t)}});var Z=r=>({get:t=>r.get(`/world/${t}`),list:(t={})=>r.get("/world",t),alerts:(t={})=>r.get("/world/alerts",t),create:t=>r.post("/world",t),update:t=>r.patch(`/world/${t?.id}`,t),delete:t=>r.delete(`/world/${t?.id||t}`),validate:(t,e,i)=>r.get("/world/value",{key:e,value:i,world:t?.id}),Member:{get:(t,e)=>r.get(`/world/${t?.id||t}/member/${e?.id||e}`),list:(t={})=>r.get(`/world/${t?.world?.id||t?.world}/member`,t),create:(t,e)=>r.post(`/world/${t?.id||t}/member`,{chirper:e?.id||e}),delete:(t,e)=>r.delete(`/world/${t?.id||t}/member/${e?.id||e}`)}});var j=r=>({get:(t,e={})=>r.get(`/brain/${t}`,e),list:(t={})=>r.get("/brain",t),run:(t,e={})=>r.post(`/brain/${t?.id||t}/run`,e),create:(t={})=>r.post("/brain",t),update:(t={})=>r.patch(`/brain/${t.id}`,t),delete:t=>r.delete(`/brain/${t?.id||t}`),validate:(t,e,i)=>r.get("/brain/value",{key:e,value:i,brain:t?.id}),Frame:{list:(t,e={})=>r.get(`/brain/${t?.id||t}/frame`,e),delete:(t,e)=>r.delete(`/brain/${t?.id||t}/frame/${e?.id||e}`)}});var tt=r=>({like:(t,e={})=>r.post(`/studio/${t?.id||t||"default"}/like`,e),dislike:(t,e={})=>r.post(`/studio/${t?.id||t||"default"}/dislike`,e),liked:(t,e={})=>r.get(`/studio/${t?.id||t||"default"}/like`,e),upload:(t={})=>r.post("/studio/upload",t),complete:(t,e={})=>r.post(`/studio/upload/${t?.id||t||"default"}`,e),generate:(t,e={})=>r.post(`/studio/${t?.id||t||"default"}/generate`,e),Message:{list:(t,e={})=>r.get(`/studio/${t?.id||t||"default"}/message`,e),delete:(t,e,i={})=>r.delete(`/studio/${t?.id||t||"default"}/message/${e?.id||e}`,i)}});var et=r=>({get:(t,e={})=>r.get(`/follow/${t?.id||t}`,e),toggle:(t,e={})=>r.post(`/follow/${t?.id||t}`,e)});var rt=r=>({get:(t,e)=>r.get(`/search/${t}`,e),update:(t,e)=>r.put(`/search/${t}`,e),delete:(t,e)=>r.delete(`/search/${t}`,e)});var it=r=>({get:(t,e={})=>r.get(`/dislike/${t?.id||t}`,e),toggle:(t,e={})=>r.post(`/dislike/${t?.id||t}`,e)});var st=r=>({get:(t,e={})=>r.get(`/affinity/${t?.id||t}`,e),list:(t={})=>r.get("/affinity",t)});var nt=r=>({list:({lang:t}={})=>r.get("/trending",{lang:t},!1,!1)});var ot=r=>({get:t=>r.get(`/category/${t?.id||t}`,{}),list:t=>r.get("/category",t)});var lt=r=>({get:(t,e={})=>r.get(`/character/${t}`,e),list:(t={})=>r.get("/character",t),spec:(t,e)=>r.post(`/character/${t?.id||t}/spec`,{type:e}),import:(t,e)=>r.post(`/character/${t}/import`,e),image:(t,e={})=>r.post(`/character/${t?.id||t}/image`,e),username:(t,e=null)=>r.post("/character/username",{username:t,id:e?.id||e}),grant:(t={},e={})=>r.post(`/character/${t?.id||t}/grant`,e),create:(t={})=>r.post("/character",t),update:(t={})=>r.patch(`/character/${t.id}`,t),delete:t=>r.delete(`/character/${t?.id||t}`),influence:t=>r.post(`/character/${t?.id||t}/influence`),toggle:t=>r.post(`/character/${t?.id||t}/toggle`),validate:(t,e,i)=>r.get("/character/value",{key:e,value:i,character:t?.id}),Trip:{list:(t,e={})=>r.get(`/character/${t?.id||t}/trip`,e),get:(t,e={})=>r.get(`/character/trip/${t?.id||t}`,e)},Item:{list:(t,e={})=>r.get(`/character/${t?.id||t}/item`,e),get:(t,e={})=>r.get(`/character/item/${t?.id||t}`,e)}});var ut=r=>({list:(t={})=>r.get(`/transaction/${t?.currency||"mana"}`,t)});var ht=r=>({get:t=>r.get(`/application/${t?.id||t}`,{}),list:t=>r.get("/application",t),create:t=>r.post("/application",t),update:(t,e)=>r.patch(`/application/${t?.id||t}`,e),secret:(t,e)=>r.get(`/application/${t?.id||t}/secret`,e)});var at=r=>({list:t=>r.get("/notification",t),count:t=>r.get("/notification/count",t),read:t=>r.post("/notification/count",t)});var Lt=new dt.default({length:10}),L=class{constructor({url:t,version:e,options:i={}}){this.key=null;this.url=null;this.cache={};this.events=new E.default;this.call=null;this.socket=null;this.account=null;this.version="v1";this.loading=!0;this.authing=null;this.authKey=null;this.shareKey=null;this.customer=null;this.presences={};this.connecting=null;this.extraOptions={};this.options={path:"/ws",cors:!0,agent:!0,reconnect:!0,transports:["websocket"],withCredentials:!0};t&&(this.url=t),e&&(this.version=e),i&&(this.extraOptions=i),this.build=this.build.bind(this),this.fetch=this.fetch.bind(this),this.wsFetch=this.wsFetch.bind(this),this.on=this.on.bind(this),this.off=this.off.bind(this),this.emit=this.emit.bind(this),this.once=this.once.bind(this),this.addListener=this.events.addListener.bind(this.events),this.removeListener=this.events.removeListener.bind(this.events),this.get=this.get.bind(this),this.put=this.put.bind(this),this.post=this.post.bind(this),this.patch=this.patch.bind(this),this.delete=this.delete.bind(this),this.View=z(this),this.Play=H(this),this.File=R(this),this.Item=G(this),this.User=J(this),this.Chat=q(this),this.Stat=K(this),this.Like=V(this),this.Post=B(this),this.Share=W(this),this.OAuth=Q(this),this.Brain=j(this),this.World=Z(this),this.Place=Y(this),this.Story=X(this),this.Search=rt(this),this.Studio=tt(this),this.Follow=et(this),this.Dislike=it(this),this.Affinity=st(this),this.Trending=nt(this),this.Category=ot(this),this.Character=lt(this),this.Application=ht(this),this.Transaction=ut(this),this.Notification=at(this),this.Chirp=this.Post,this.Chirper=this.Character,this.build()}build(){if(this.__resolveConnecting=null,this.connecting=new Promise(i=>{this.__resolveConnecting=i}),!this.url)return;let t={...this.options,...this.extraOptions};t.query||(t.query={}),t.query.compression=!0;let e=ft.default.connect(`${this.url}`,t);e.on("connect",async(...i)=>{this.authing||(this.authing=this.auth(this.authKey,this.shareKey),await this.authing,this.authing=null,this.__resolveConnecting())}),e.on("disconnect",()=>{this.connecting=new Promise(i=>{this.__resolveConnecting=i})}),this.socket=e}async auth(t){!t&&this.user&&(t=this.user),t||(this.loading=!0,this.events.emit("loading",!0),t=(await this.get("/auth",{key:this.key},!1,!1))?.user),t&&(this.user=t,this.events.emit("user",t)),this.loading=!1,this.events.emit("loading",!1),typeof window<"u"&&(window.chirper=this)}async fetch(t,e,i={},o=!1){if(["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(i)}`])return this.cache[`${t}${e}${JSON.stringify(i)}`];delete this.cache[`${t}${e}${JSON.stringify(i)}`],console.time(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(i)}`),Object.keys(i).forEach(l=>{i[l]===void 0&&delete i[l]});let u;try{u=await(await fetch(`${this.url}/${this.version}${e}${`${t}`.toLowerCase()==="get"?`?${new URLSearchParams(i)}`:""}`,{body:`${t}`.toLowerCase()!=="get"?JSON.stringify(i):void 0,headers:{"Content-Type":"application/json",Authentication:this.key?`Bearer ${this.key}`:void 0},credentials:"include"})).json()}catch(l){throw console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(i)}`),l}if(console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(i)}`),!u?.success)throw new Error(u.message);return o&&(this.cache[`${t}${e}${JSON.stringify(i)}`]=u,this.cache[`${t}${e}${JSON.stringify(i)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(i)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(i)}`]})),u.result}async wsFetch(t,e,i={},o=!1,u=!0){if(u&&await this.connecting,u&&await this.authing,["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(i)}`])return this.cache[`${t}${e}${JSON.stringify(i)}`];delete this.cache[`${t}${e}${JSON.stringify(i)}`];let l=Lt();console.time(`[chirper] [${l}] ${t}:${e} ${JSON.stringify(i)}`);let m=new Promise((s,y)=>{this.socket.once(l,v=>{let h=ct.default.ungzip(v,{to:"string"}),{success:b,result:w,message:f,time:c}=(0,gt.decompress)(JSON.parse(h));if(console.timeEnd(`[chirper] [${l}] ${t}:${e} ${JSON.stringify(i)}`),console.log(`[chirper] [${l}] backend time ${c}ms`),b)return s(w);y(f)})});return o&&(this.cache[`${t}${e}${JSON.stringify(i)}`]=m,this.cache[`${t}${e}${JSON.stringify(i)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(i)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(i)}`]})),this.socket.emit("call",l,t.toUpperCase(),e,i),m}on(...t){this.socket.on(...t)}off(...t){this.socket.off(...t)}emit(...t){this.socket.emit(...t)}once(...t){this.socket.once(...t)}get(t,e,...i){return this.wsFetch("GET",`/${this.version}${t}`,e,...i)}put(t,e,...i){return this.wsFetch("PUT",`/${this.version}${t}`,e,...i)}post(t,e,...i){return this.wsFetch("POST",`/${this.version}${t}`,e,...i)}patch(t,e,...i){return this.wsFetch("PATCH",`/${this.version}${t}`,e,...i)}delete(t,e,...i){return this.wsFetch("DELETE",`/${this.version}${t}`,e,...i)}};
1
+ var xt=Object.create;var O=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var Ct=Object.getPrototypeOf,kt=Object.prototype.hasOwnProperty;var D=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Lt=(r,t)=>{for(var e in t)O(r,e,{get:t[e],enumerable:!0})},F=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ot(t))!kt.call(r,o)&&o!==e&&O(r,o,{get:()=>t[o],enumerable:!(i=St(t,o))||i.enumerable});return r};var C=(r,t,e)=>(e=r!=null?xt(Ct(r)):{},F(t||!r||!r.__esModule?O(e,"default",{value:r,enumerable:!0}):e,r)),It=r=>F(O({},"__esModule",{value:!0}),r);var T=D((Ft,P)=>{var I=(()=>{var r=Object.defineProperty,t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,o=(f,d,p)=>d in f?r(f,d,{enumerable:!0,configurable:!0,writable:!0,value:p}):f[d]=p,l=(f,d)=>{for(var p in d||(d={}))e.call(d,p)&&o(f,p,d[p]);if(t)for(var p of t(d))i.call(d,p)&&o(f,p,d[p]);return f},u=f=>r(f,"__esModule",{value:!0}),m=(f,d)=>{u(f);for(var p in d)r(f,p,{get:d[p],enumerable:!0})},s={};m(s,{DEFAULT_UUID_LENGTH:()=>v,default:()=>w});var y="4.4.4",v=6,h={dictionary:"alphanum",shuffle:!0,debug:!1,length:v},b=class extends Function{constructor(f={}){super(),this.dictIndex=0,this.dictRange=[],this.lowerBound=0,this.upperBound=0,this.dictLength=0,this._digit_first_ascii=48,this._digit_last_ascii=58,this._alpha_lower_first_ascii=97,this._alpha_lower_last_ascii=123,this._hex_last_ascii=103,this._alpha_upper_first_ascii=65,this._alpha_upper_last_ascii=91,this._number_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii]},this._alpha_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alpha_lower_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alpha_upper_dict_ranges={upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_lower_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alphanum_upper_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._hex_dict_ranges={decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]},this.log=(...n)=>{let a=[...n];if(a[0]=`[short-unique-id] ${n[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...a)},this.setDictionary=(n,a)=>{let c;if(n&&Array.isArray(n)&&n.length>1)c=n;else{c=[];let _;this.dictIndex=_=0;let x=`_${n}_dict_ranges`,N=this[x];Object.keys(N).forEach(wt=>{let bt=wt;for(this.dictRange=N[bt],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=_=this.lowerBound;this.lowerBound<=this.upperBound?_<this.upperBound:_>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?_+=1:_-=1)c.push(String.fromCharCode(this.dictIndex))})}a&&(c=c.sort(()=>Math.random()-.5)),this.dict=c,this.dictLength=this.dict.length,this.counter=0},this.seq=()=>this.sequentialUUID(),this.sequentialUUID=()=>{let n,a,c="";n=this.counter;do a=n%this.dictLength,n=Math.trunc(n/this.dictLength),c+=this.dict[a];while(n!==0);return this.counter+=1,c},this.randomUUID=(n=this.uuidLength||v)=>{let a,c,_;if(n===null||typeof n>"u"||n<1)throw new Error("Invalid UUID Length Provided");let x=n>=0;for(a="",_=0;_<n;_+=1)c=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,a+=this.dict[c];return a},this.availableUUIDs=(n=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,n).toFixed(0)),this.approxMaxBeforeCollision=(n=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*n).toFixed(20)),this.collisionProbability=(n=this.availableUUIDs(this.uuidLength),a=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(n)/this.availableUUIDs(a)).toFixed(20)),this.uniqueness=(n=this.availableUUIDs(this.uuidLength))=>{let a=parseFloat((1-this.approxMaxBeforeCollision(n)/n).toFixed(20));return a>1?1:a<0?0:a},this.getVersion=()=>this.version,this.stamp=n=>{if(typeof n!="number"||n<10)throw new Error("Param finalLength must be number greater than 10");let a=Math.floor(+new Date/1e3).toString(16),c=n-9,_=Math.round(Math.random()*(c>15?15:c)),x=this.randomUUID(c);return`${x.substr(0,_)}${a}${x.substr(_)}${_.toString(16)}`},this.parseStamp=n=>{if(n.length<10)throw new Error("Stamp length invalid");let a=parseInt(n.substr(n.length-1,1),16);return new Date(parseInt(n.substr(a,8),16)*1e3)};let d=l(l({},h),f);this.counter=0,this.debug=!1,this.dict=[],this.version=y;let{dictionary:p,shuffle:vt,length:yt}=d;return this.uuidLength=yt,this.setDictionary(p,vt),this.debug=d.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength}`),new Proxy(this,{apply:(n,a,c)=>this.randomUUID(...c)})}},w=b;return w.default=b,s})();typeof P<"u"&&(P.exports=I.default),typeof window<"u"&&(I=I.default)});var A=D((Mt,U)=>{"use strict";var Pt=Object.prototype.hasOwnProperty,$="~";function S(){}Object.create&&(S.prototype=Object.create(null),new S().__proto__||($=!1));function Ut(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function M(r,t,e,i,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var l=new Ut(e,i||r,o),u=$?$+t:t;return r._events[u]?r._events[u].fn?r._events[u]=[r._events[u],l]:r._events[u].push(l):(r._events[u]=l,r._eventsCount++),r}function k(r,t){--r._eventsCount===0?r._events=new S:delete r._events[t]}function g(){this._events=new S,this._eventsCount=0}g.prototype.eventNames=function(){var t=[],e,i;if(this._eventsCount===0)return t;for(i in e=this._events)Pt.call(e,i)&&t.push($?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};g.prototype.listeners=function(t){var e=$?$+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var o=0,l=i.length,u=new Array(l);o<l;o++)u[o]=i[o].fn;return u};g.prototype.listenerCount=function(t){var e=$?$+t:t,i=this._events[e];return i?i.fn?1:i.length:0};g.prototype.emit=function(t,e,i,o,l,u){var m=$?$+t:t;if(!this._events[m])return!1;var s=this._events[m],y=arguments.length,v,h;if(s.fn){switch(s.once&&this.removeListener(t,s.fn,void 0,!0),y){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,e),!0;case 3:return s.fn.call(s.context,e,i),!0;case 4:return s.fn.call(s.context,e,i,o),!0;case 5:return s.fn.call(s.context,e,i,o,l),!0;case 6:return s.fn.call(s.context,e,i,o,l,u),!0}for(h=1,v=new Array(y-1);h<y;h++)v[h-1]=arguments[h];s.fn.apply(s.context,v)}else{var b=s.length,w;for(h=0;h<b;h++)switch(s[h].once&&this.removeListener(t,s[h].fn,void 0,!0),y){case 1:s[h].fn.call(s[h].context);break;case 2:s[h].fn.call(s[h].context,e);break;case 3:s[h].fn.call(s[h].context,e,i);break;case 4:s[h].fn.call(s[h].context,e,i,o);break;default:if(!v)for(w=1,v=new Array(y-1);w<y;w++)v[w-1]=arguments[w];s[h].fn.apply(s[h].context,v)}}return!0};g.prototype.on=function(t,e,i){return M(this,t,e,i,!1)};g.prototype.once=function(t,e,i){return M(this,t,e,i,!0)};g.prototype.removeListener=function(t,e,i,o){var l=$?$+t:t;if(!this._events[l])return this;if(!e)return k(this,l),this;var u=this._events[l];if(u.fn)u.fn===e&&(!o||u.once)&&(!i||u.context===i)&&k(this,l);else{for(var m=0,s=[],y=u.length;m<y;m++)(u[m].fn!==e||o&&!u[m].once||i&&u[m].context!==i)&&s.push(u[m]);s.length?this._events[l]=s.length===1?s[0]:s:k(this,l)}return this};g.prototype.removeAllListeners=function(t){var e;return t?(e=$?$+t:t,this._events[e]&&k(this,e)):(this._events=new S,this._eventsCount=0),this};g.prototype.off=g.prototype.removeListener;g.prototype.addListener=g.prototype.on;g.prefixed=$;g.EventEmitter=g;typeof U<"u"&&(U.exports=g)});var Nt={};Lt(Nt,{default:()=>L});module.exports=It(Nt);var pt=C(require("pako")),_t=C(T()),$t=C(require("socket.io-client")),mt=require("compress-json");var E=C(A(),1);var B=r=>({get:(t,e)=>r.get(`/post/${t?.id||t}`,{lang:e},!1,!1),list:(t={})=>r.get("/post",t,!1,!1),add:(t,e)=>r.post(`/post/${t?.id||t}/add`,{character:e?.id||e}),influence:(t,{value:e,message:i})=>r.post(`/post/${t?.id||t}/influence`,{value:e,message:i}),count:t=>r.get(`/post/${t?.id||t}/count`),delete:t=>r.delete(`/post/${t?.id||t}`),create:(t={})=>r.post("/post",t),subscribe:t=>r.post(`/post/${t?.id||t}/subscribe`),unsubscribe:t=>r.delete(`/post/${t?.id||t}/subscribe`)});var J=r=>({get:(t,e={})=>r.get(`/user/${t}`,e),list:(t={})=>r.get("/user",t),image:(t,e={})=>r.post(`/user/${t?.id||t}/image`,e),update:(t={})=>r.patch(`/user/${t.id}`,t),validate:(t,e,i)=>r.get("/user/value",{key:e,value:i,user:t?.id}),password:(t,e,i)=>r.patch("/user/password",{password:t,newPassword:e,newPassword2:i}),username:(t,e=null)=>r.post("/user/username",{username:t,id:e?.id||e}),suggestion:(t={})=>r.get("/user/suggestion",t),Pin:{list:(t={})=>r.get("/user/pin",t),create:(t={})=>r.post("/user/pin",t),update:(t={})=>r.patch("/user/pin",t),delete:(t={})=>r.delete("/user/pin",t)}});var q=r=>({get:(t,e)=>r.get(`/chat/${t?.id||t}`,e),list:t=>r.get("/chat",t),read:t=>r.get(`/chat/${t?.id||t}/read`),create:(t,e)=>r.post(`/chat/${t?.id||t}`,e),typing:(t,e=!0)=>r.post(`/chat/${t?.id||t}/typing`,{typing:e}),leaveChat:t=>r.delete(`/chat/${t?.id||t}`),readChat:t=>r.post(`/chat/${t?.id||t}/read`),loadMembers:(t,e)=>r.get(`/chat/${t?.id||t}/member`,e),loadMessages:(t,e)=>r.get(`/chat/${t?.id||t}/message`,e),sendMessage:(t,e)=>r.post(`/chat/${t?.id||t}/message`,e),inviteMember:(t,e)=>r.post(`/chat/${t?.id||t}/member`,{member:e?.id||e}),removeMember:(t,e)=>r.delete(`/chat/${t?.id||t}/member/${e?.id||e}`)});var R=r=>({get:(t,e={})=>r.get(`/file/${t?.id||t}`,e),list:(t={})=>r.get("/file",t),modelList:(t={})=>r.get("/file/model",t),like:(t,e={})=>r.post(`/file/${t?.id||t}/like`,e),liked:(t,e={})=>r.get(`/file/${t?.id||t}/like`,e)});var K=r=>({get:(t,e=null,i=null)=>r.get(`/:account/stat/${t}`,{from:e,to:i})});var G=r=>({get:(t,e={})=>r.get(`/item/${t?.id||t}`,e),list:(t={})=>r.get("/item",t),delete:(t,e={})=>r.delete(`/item/${t?.id||t}`,e)});var V=r=>({get:(t,e={})=>r.get(`/like/${t?.id||t}`,e),toggle:(t,e={})=>r.post(`/like/${t?.id||t}`,e)});var H=r=>({get:(t,e={})=>r.get(`/play/${t?.id||t}`,e),play:(t,e={})=>r.post(`/play/${t?.id||t}`,e)});var z=r=>({get:(t,e={})=>r.get(`/view/${t?.id||t}`,e),view:(t,e={})=>r.post(`/view/${t?.id||t}`,e)});var W=r=>({get:t=>r.get(`/part/${t?.id||t}`),list:(t={})=>r.get("/part",t),alerts:(t={})=>r.get("/part/alerts",t),create:t=>r.post("/part",t),update:t=>r.patch(`/part/${t?.id}`,t),delete:t=>r.delete(`/part/${t?.id||t}`),validate:(t,e,i)=>r.get("/part/value",{key:e,value:i,part:t?.id})});var Y=r=>({get:(t,e={})=>r.get(`/share/${t?.id||t}`,e),share:(t,e={})=>r.post(`/share/${t?.id||t}`,e)});var Q=r=>({get:(t,e={})=>r.get(`/place/${t?.id||t}`,e),list:(t={})=>r.get("/place",t)});var X=r=>({code:(t,e)=>r.post("/oauth2/code",{application:t,redirect:e})});var Z=r=>({get:(t,e={})=>r.get(`/story/${t?.id||t}`,e),list:(t={})=>r.get("/story",t),Frame:{list:(t={})=>r.get(`/story/${t?.story?.id||t?.story}/frame`,t)}});var j=r=>({get:t=>r.get(`/world/${t}`),list:(t={})=>r.get("/world",t),alerts:(t={})=>r.get("/world/alerts",t),create:t=>r.post("/world",t),update:t=>r.patch(`/world/${t?.id}`,t),delete:t=>r.delete(`/world/${t?.id||t}`),validate:(t,e,i)=>r.get("/world/value",{key:e,value:i,world:t?.id}),Member:{get:(t,e)=>r.get(`/world/${t?.id||t}/member/${e?.id||e}`),list:(t={})=>r.get(`/world/${t?.world?.id||t?.world}/member`,t),create:(t,e)=>r.post(`/world/${t?.id||t}/member`,{chirper:e?.id||e}),delete:(t,e)=>r.delete(`/world/${t?.id||t}/member/${e?.id||e}`)}});var tt=r=>({get:(t,e={})=>r.get(`/brain/${t}`,e),list:(t={})=>r.get("/brain",t),run:(t,e={})=>r.post(`/brain/${t?.id||t}/run`,e),create:(t={})=>r.post("/brain",t),update:(t={})=>r.patch(`/brain/${t.id}`,t),delete:t=>r.delete(`/brain/${t?.id||t}`),validate:(t,e,i)=>r.get("/brain/value",{key:e,value:i,brain:t?.id}),Frame:{list:(t,e={})=>r.get(`/brain/${t?.id||t}/frame`,e),delete:(t,e)=>r.delete(`/brain/${t?.id||t}/frame/${e?.id||e}`)}});var et=r=>({get:t=>r.get(`/season/${t?.id||t}`),list:(t={})=>r.get("/season",t),alerts:(t={})=>r.get("/season/alerts",t),create:t=>r.post("/season",t),update:t=>r.patch(`/season/${t?.id}`,t),delete:t=>r.delete(`/season/${t?.id||t}`),validate:(t,e,i)=>r.get("/season/value",{key:e,value:i,season:t?.id})});var rt=r=>({like:(t,e={})=>r.post(`/studio/${t?.id||t||"default"}/like`,e),dislike:(t,e={})=>r.post(`/studio/${t?.id||t||"default"}/dislike`,e),liked:(t,e={})=>r.get(`/studio/${t?.id||t||"default"}/like`,e),upload:(t={})=>r.post("/studio/upload",t),complete:(t,e={})=>r.post(`/studio/upload/${t?.id||t||"default"}`,e),generate:(t,e={})=>r.post(`/studio/${t?.id||t||"default"}/generate`,e),Message:{list:(t,e={})=>r.get(`/studio/${t?.id||t||"default"}/message`,e),delete:(t,e,i={})=>r.delete(`/studio/${t?.id||t||"default"}/message/${e?.id||e}`,i)}});var it=r=>({get:(t,e={})=>r.get(`/follow/${t?.id||t}`,e),toggle:(t,e={})=>r.post(`/follow/${t?.id||t}`,e)});var st=r=>({get:t=>r.get(`/series/${t?.id||t}`),list:(t={})=>r.get("/series",t),alerts:(t={})=>r.get("/series/alerts",t),create:t=>r.post("/series",t),update:t=>r.patch(`/series/${t?.id}`,t),delete:t=>r.delete(`/series/${t?.id||t}`),validate:(t,e,i)=>r.get("/series/value",{key:e,value:i,series:t?.id})});var nt=r=>({get:(t,e)=>r.get(`/search/${t}`,e),update:(t,e)=>r.put(`/search/${t}`,e),delete:(t,e)=>r.delete(`/search/${t}`,e)});var ot=r=>({get:(t,e={})=>r.get(`/dislike/${t?.id||t}`,e),toggle:(t,e={})=>r.post(`/dislike/${t?.id||t}`,e)});var ut=r=>({get:t=>r.get(`/episode/${t?.id||t}`),list:(t={})=>r.get("/episode",t),alerts:(t={})=>r.get("/episode/alerts",t),create:t=>r.post("/episode",t),update:t=>r.patch(`/episode/${t?.id}`,t),delete:t=>r.delete(`/episode/${t?.id||t}`),validate:(t,e,i)=>r.get("/episode/value",{key:e,value:i,episode:t?.id})});var lt=r=>({get:(t,e={})=>r.get(`/affinity/${t?.id||t}`,e),list:(t={})=>r.get("/affinity",t)});var ht=r=>({list:({lang:t}={})=>r.get("/trending",{lang:t},!1,!1)});var at=r=>({get:t=>r.get(`/category/${t?.id||t}`,{}),list:t=>r.get("/category",t)});var dt=r=>({get:(t,e={})=>r.get(`/character/${t}`,e),list:(t={})=>r.get("/character",t),spec:(t,e)=>r.post(`/character/${t?.id||t}/spec`,{type:e}),import:(t,e)=>r.post(`/character/${t}/import`,e),image:(t,e={})=>r.post(`/character/${t?.id||t}/image`,e),username:(t,e=null)=>r.post("/character/username",{username:t,id:e?.id||e}),grant:(t={},e={})=>r.post(`/character/${t?.id||t}/grant`,e),create:(t={})=>r.post("/character",t),update:(t={})=>r.patch(`/character/${t.id}`,t),delete:t=>r.delete(`/character/${t?.id||t}`),influence:t=>r.post(`/character/${t?.id||t}/influence`),toggle:t=>r.post(`/character/${t?.id||t}/toggle`),validate:(t,e,i)=>r.get("/character/value",{key:e,value:i,character:t?.id}),Trip:{list:(t,e={})=>r.get(`/character/${t?.id||t}/trip`,e),get:(t,e={})=>r.get(`/character/trip/${t?.id||t}`,e)},Item:{list:(t,e={})=>r.get(`/character/${t?.id||t}/item`,e),get:(t,e={})=>r.get(`/character/item/${t?.id||t}`,e)}});var ct=r=>({list:(t={})=>r.get(`/transaction/${t?.currency||"mana"}`,t)});var ft=r=>({get:t=>r.get(`/application/${t?.id||t}`,{}),list:t=>r.get("/application",t),create:t=>r.post("/application",t),update:(t,e)=>r.patch(`/application/${t?.id||t}`,e),secret:(t,e)=>r.get(`/application/${t?.id||t}/secret`,e)});var gt=r=>({list:t=>r.get("/notification",t),count:t=>r.get("/notification/count",t),read:t=>r.post("/notification/count",t)});var Et=new _t.default({length:10}),L=class{constructor({url:t,version:e,options:i={}}){this.key=null;this.url=null;this.cache={};this.events=new E.default;this.call=null;this.socket=null;this.account=null;this.version="v1";this.loading=!0;this.authing=null;this.authKey=null;this.shareKey=null;this.customer=null;this.presences={};this.connecting=null;this.extraOptions={};this.options={path:"/ws",cors:!0,agent:!0,reconnect:!0,transports:["websocket"],withCredentials:!0};t&&(this.url=t),e&&(this.version=e),i&&(this.extraOptions=i),this.build=this.build.bind(this),this.fetch=this.fetch.bind(this),this.wsFetch=this.wsFetch.bind(this),this.on=this.on.bind(this),this.off=this.off.bind(this),this.emit=this.emit.bind(this),this.once=this.once.bind(this),this.addListener=this.events.addListener.bind(this.events),this.removeListener=this.events.removeListener.bind(this.events),this.get=this.get.bind(this),this.put=this.put.bind(this),this.post=this.post.bind(this),this.patch=this.patch.bind(this),this.delete=this.delete.bind(this),this.View=z(this),this.Play=H(this),this.File=R(this),this.Item=G(this),this.User=J(this),this.Chat=q(this),this.Stat=K(this),this.Like=V(this),this.Post=B(this),this.Part=W(this),this.Share=Y(this),this.OAuth=X(this),this.Brain=tt(this),this.World=j(this),this.Place=Q(this),this.Story=Z(this),this.Series=st(this),this.Search=nt(this),this.Studio=rt(this),this.Follow=it(this),this.Season=et(this),this.Dislike=ot(this),this.Episode=ut(this),this.Affinity=lt(this),this.Trending=ht(this),this.Category=at(this),this.Character=dt(this),this.Application=ft(this),this.Transaction=ct(this),this.Notification=gt(this),this.Chirp=this.Post,this.Chirper=this.Character,this.build()}build(){if(this.__resolveConnecting=null,this.connecting=new Promise(i=>{this.__resolveConnecting=i}),!this.url)return;let t={...this.options,...this.extraOptions};t.query||(t.query={}),t.query.compression=!0;let e=$t.default.connect(`${this.url}`,t);e.on("connect",async(...i)=>{this.authing||(this.authing=this.auth(this.authKey,this.shareKey),await this.authing,this.authing=null,this.__resolveConnecting())}),e.on("disconnect",()=>{this.connecting=new Promise(i=>{this.__resolveConnecting=i})}),this.socket=e}async auth(t){!t&&this.user&&(t=this.user),t||(this.loading=!0,this.events.emit("loading",!0),t=(await this.get("/auth",{key:this.key},!1,!1))?.user),t&&(this.user=t,this.events.emit("user",t)),this.loading=!1,this.events.emit("loading",!1),typeof window<"u"&&(window.chirper=this)}async fetch(t,e,i={},o=!1){if(["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(i)}`])return this.cache[`${t}${e}${JSON.stringify(i)}`];delete this.cache[`${t}${e}${JSON.stringify(i)}`],console.time(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(i)}`),Object.keys(i).forEach(u=>{i[u]===void 0&&delete i[u]});let l;try{l=await(await fetch(`${this.url}/${this.version}${e}${`${t}`.toLowerCase()==="get"?`?${new URLSearchParams(i)}`:""}`,{body:`${t}`.toLowerCase()!=="get"?JSON.stringify(i):void 0,headers:{"Content-Type":"application/json",Authentication:this.key?`Bearer ${this.key}`:void 0},credentials:"include"})).json()}catch(u){throw console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(i)}`),u}if(console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(i)}`),!l?.success)throw new Error(l.message);return o&&(this.cache[`${t}${e}${JSON.stringify(i)}`]=l,this.cache[`${t}${e}${JSON.stringify(i)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(i)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(i)}`]})),l.result}async wsFetch(t,e,i={},o=!1,l=!0){if(l&&await this.connecting,l&&await this.authing,["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(i)}`])return this.cache[`${t}${e}${JSON.stringify(i)}`];delete this.cache[`${t}${e}${JSON.stringify(i)}`];let u=Et();console.time(`[chirper] [${u}] ${t}:${e} ${JSON.stringify(i)}`);let m=new Promise((s,y)=>{this.socket.once(u,v=>{let h=pt.default.ungzip(v,{to:"string"}),{success:b,result:w,message:f,time:d}=(0,mt.decompress)(JSON.parse(h));if(console.timeEnd(`[chirper] [${u}] ${t}:${e} ${JSON.stringify(i)}`),console.log(`[chirper] [${u}] backend time ${d}ms`),b)return s(w);y(f)})});return o&&(this.cache[`${t}${e}${JSON.stringify(i)}`]=m,this.cache[`${t}${e}${JSON.stringify(i)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(i)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(i)}`]})),this.socket.emit("call",u,t.toUpperCase(),e,i),m}on(...t){this.socket.on(...t)}off(...t){this.socket.off(...t)}emit(...t){this.socket.emit(...t)}once(...t){this.socket.once(...t)}get(t,e,...i){return this.wsFetch("GET",`/${this.version}${t}`,e,...i)}put(t,e,...i){return this.wsFetch("PUT",`/${this.version}${t}`,e,...i)}post(t,e,...i){return this.wsFetch("POST",`/${this.version}${t}`,e,...i)}patch(t,e,...i){return this.wsFetch("PATCH",`/${this.version}${t}`,e,...i)}delete(t,e,...i){return this.wsFetch("DELETE",`/${this.version}${t}`,e,...i)}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chirper/node",
3
- "version": "0.0.104",
3
+ "version": "0.0.106",
4
4
  "description": "",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {
@@ -0,0 +1,37 @@
1
+
2
+ /**
3
+ * episode api
4
+ */
5
+ export default (api) => ({
6
+ get : (episode) => {
7
+ return api.get(`/episode/${episode?.id || episode}`);
8
+ },
9
+ list : (opts = {}) => {
10
+ // return done
11
+ return api.get(`/episode`, opts);
12
+ },
13
+ alerts : (opts = {}) => {
14
+ // return done
15
+ return api.get(`/episode/alerts`, opts);
16
+ },
17
+ create : (episode) => {
18
+ // return patch
19
+ return api.post(`/episode`, episode);
20
+ },
21
+ update : (episode) => {
22
+ // return patch
23
+ return api.patch(`/episode/${episode?.id}`, episode);
24
+ },
25
+ delete : (episode) => {
26
+ // return patch
27
+ return api.delete(`/episode/${episode?.id || episode}`);
28
+ },
29
+ validate : (episode, key, value) => {
30
+ // return check
31
+ return api.get(`/episode/value`, {
32
+ key,
33
+ value,
34
+ episode : episode?.id,
35
+ });
36
+ }
37
+ });
@@ -0,0 +1,37 @@
1
+
2
+ /**
3
+ * part api
4
+ */
5
+ export default (api) => ({
6
+ get : (part) => {
7
+ return api.get(`/part/${part?.id || part}`);
8
+ },
9
+ list : (opts = {}) => {
10
+ // return done
11
+ return api.get(`/part`, opts);
12
+ },
13
+ alerts : (opts = {}) => {
14
+ // return done
15
+ return api.get(`/part/alerts`, opts);
16
+ },
17
+ create : (part) => {
18
+ // return patch
19
+ return api.post(`/part`, part);
20
+ },
21
+ update : (part) => {
22
+ // return patch
23
+ return api.patch(`/part/${part?.id}`, part);
24
+ },
25
+ delete : (part) => {
26
+ // return patch
27
+ return api.delete(`/part/${part?.id || part}`);
28
+ },
29
+ validate : (part, key, value) => {
30
+ // return check
31
+ return api.get(`/part/value`, {
32
+ key,
33
+ value,
34
+ part : part?.id,
35
+ });
36
+ }
37
+ });
@@ -0,0 +1,37 @@
1
+
2
+ /**
3
+ * season api
4
+ */
5
+ export default (api) => ({
6
+ get : (season) => {
7
+ return api.get(`/season/${season?.id || season}`);
8
+ },
9
+ list : (opts = {}) => {
10
+ // return done
11
+ return api.get(`/season`, opts);
12
+ },
13
+ alerts : (opts = {}) => {
14
+ // return done
15
+ return api.get(`/season/alerts`, opts);
16
+ },
17
+ create : (season) => {
18
+ // return patch
19
+ return api.post(`/season`, season);
20
+ },
21
+ update : (season) => {
22
+ // return patch
23
+ return api.patch(`/season/${season?.id}`, season);
24
+ },
25
+ delete : (season) => {
26
+ // return patch
27
+ return api.delete(`/season/${season?.id || season}`);
28
+ },
29
+ validate : (season, key, value) => {
30
+ // return check
31
+ return api.get(`/season/value`, {
32
+ key,
33
+ value,
34
+ season : season?.id,
35
+ });
36
+ }
37
+ });
@@ -0,0 +1,37 @@
1
+
2
+ /**
3
+ * series api
4
+ */
5
+ export default (api) => ({
6
+ get : (series) => {
7
+ return api.get(`/series/${series?.id || series}`);
8
+ },
9
+ list : (opts = {}) => {
10
+ // return done
11
+ return api.get(`/series`, opts);
12
+ },
13
+ alerts : (opts = {}) => {
14
+ // return done
15
+ return api.get(`/series/alerts`, opts);
16
+ },
17
+ create : (series) => {
18
+ // return patch
19
+ return api.post(`/series`, series);
20
+ },
21
+ update : (series) => {
22
+ // return patch
23
+ return api.patch(`/series/${series?.id}`, series);
24
+ },
25
+ delete : (series) => {
26
+ // return patch
27
+ return api.delete(`/series/${series?.id || series}`);
28
+ },
29
+ validate : (series, key, value) => {
30
+ // return check
31
+ return api.get(`/series/value`, {
32
+ key,
33
+ value,
34
+ series : series?.id,
35
+ });
36
+ }
37
+ });
package/src/index.ts CHANGED
@@ -19,16 +19,20 @@ import Item from './api/Item';
19
19
  import Like from './api/Like';
20
20
  import Play from './api/Play';
21
21
  import View from './api/View';
22
+ import Part from './api/Part';
22
23
  import Share from './api/Share';
23
24
  import Place from './api/Place';
24
25
  import OAuth from './api/OAuth';
25
26
  import Story from './api/Story';
26
27
  import World from './api/World';
27
28
  import Brain from './api/Brain';
29
+ import Season from './api/Season';
28
30
  import Studio from './api/Studio';
29
31
  import Follow from './api/Follow';
32
+ import Series from './api/Series';
30
33
  import Search from './api/Search';
31
34
  import Dislike from './api/Dislike';
35
+ import Episode from './api/Episode';
32
36
  import Affinity from './api/Affinity';
33
37
  import Trending from './api/Trending';
34
38
  import Category from './api/Category';
@@ -115,16 +119,20 @@ export default class chirperNode {
115
119
  this.Stat = Stat(this);
116
120
  this.Like = Like(this);
117
121
  this.Post = Post(this);
122
+ this.Part = Part(this);
118
123
  this.Share = Share(this);
119
124
  this.OAuth = OAuth(this);
120
125
  this.Brain = Brain(this);
121
126
  this.World = World(this);
122
127
  this.Place = Place(this);
123
128
  this.Story = Story(this);
129
+ this.Series = Series(this);
124
130
  this.Search = Search(this);
125
131
  this.Studio = Studio(this);
126
132
  this.Follow = Follow(this);
133
+ this.Season = Season(this);
127
134
  this.Dislike = Dislike(this);
135
+ this.Episode = Episode(this);
128
136
  this.Affinity = Affinity(this);
129
137
  this.Trending = Trending(this);
130
138
  this.Category = Category(this);