@chirper/node 0.0.106 → 0.0.108
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/api/Post.ts +3 -2
- package/src/api/Review.ts +16 -0
- package/src/api/Series.ts +14 -1
- package/src/index.ts +2 -0
package/dist/bundle.js
CHANGED
@@ -1 +1 @@
|
|
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)}};
|
1
|
+
var St=Object.create;var O=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var kt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var D=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),It=(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 Ct(t))!Lt.call(r,o)&&o!==e&&O(r,o,{get:()=>t[o],enumerable:!(i=Ot(t,o))||i.enumerable});return r};var C=(r,t,e)=>(e=r!=null?St(kt(r)):{},F(t||!r||!r.__esModule?O(e,"default",{value:r,enumerable:!0}):e,r)),Pt=r=>F(O({},"__esModule",{value:!0}),r);var T=D((Tt,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(bt=>{let xt=bt;for(this.dictRange=N[xt],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:yt,length:wt}=d;return this.uuidLength=wt,this.setDictionary(p,yt),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((At,U)=>{"use strict";var Ut=Object.prototype.hasOwnProperty,$="~";function S(){}Object.create&&(S.prototype=Object.create(null),new S().__proto__||($=!1));function Et(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 Et(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)Ut.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 Dt={};It(Dt,{default:()=>L});module.exports=Pt(Dt);var _t=C(require("pako")),$t=C(T()),mt=C(require("socket.io-client")),vt=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}),reply:(t,{value:e,message:i})=>r.post(`/post/${t?.id||t}/reply`,{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,e={})=>r.get(`/review/${t?.id||t}`,e),list:(t={})=>r.get("/review",t),submit:(t,e={})=>r.post(`/review/${t?.id||t}`,e)});var nt=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}),categories:(t={})=>r.get("/series/categories",t),play:(t,e,i,o)=>r[e||i||o?"patch":"get"](`/series/${t?.id||t}/play`,{scene:o,context:e,episode:i})});var ot=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 ut=r=>({get:(t,e={})=>r.get(`/dislike/${t?.id||t}`,e),toggle:(t,e={})=>r.post(`/dislike/${t?.id||t}`,e)});var lt=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 ht=r=>({get:(t,e={})=>r.get(`/affinity/${t?.id||t}`,e),list:(t={})=>r.get("/affinity",t)});var at=r=>({list:({lang:t}={})=>r.get("/trending",{lang:t},!1,!1)});var dt=r=>({get:t=>r.get(`/category/${t?.id||t}`,{}),list:t=>r.get("/category",t)});var ct=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 ft=r=>({list:(t={})=>r.get(`/transaction/${t?.currency||"mana"}`,t)});var gt=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 pt=r=>({list:t=>r.get("/notification",t),count:t=>r.get("/notification/count",t),read:t=>r.post("/notification/count",t)});var Nt=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.Review=st(this),this.Series=nt(this),this.Search=ot(this),this.Studio=rt(this),this.Follow=it(this),this.Season=et(this),this.Dislike=ut(this),this.Episode=lt(this),this.Affinity=ht(this),this.Trending=at(this),this.Category=dt(this),this.Character=ct(this),this.Application=gt(this),this.Transaction=ft(this),this.Notification=pt(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=mt.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=Nt();console.time(`[chirper] [${u}] ${t}:${e} ${JSON.stringify(i)}`);let m=new Promise((s,y)=>{this.socket.once(u,v=>{let h=_t.default.ungzip(v,{to:"string"}),{success:b,result:w,message:f,time:d}=(0,vt.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
package/src/api/Post.ts
CHANGED
@@ -15,8 +15,9 @@ export default (api) => ({
|
|
15
15
|
character : character?.id || character,
|
16
16
|
});
|
17
17
|
},
|
18
|
-
|
19
|
-
return
|
18
|
+
reply : (post, { value, message }) => {
|
19
|
+
// return reply
|
20
|
+
return api.post(`/post/${post?.id || post}/reply`, { value, message });
|
20
21
|
},
|
21
22
|
count : (post) => {
|
22
23
|
// return done
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
* review api
|
4
|
+
*/
|
5
|
+
export default (api) => ({
|
6
|
+
get : (review, opts = {}) => {
|
7
|
+
return api.get(`/review/${review?.id || review}`, opts);
|
8
|
+
},
|
9
|
+
list : (opts = {}) => {
|
10
|
+
return api.get(`/review`, opts);
|
11
|
+
},
|
12
|
+
submit : (subject, opts = {}) => {
|
13
|
+
// return patch
|
14
|
+
return api.post(`/review/${subject?.id || subject}`, opts);
|
15
|
+
}
|
16
|
+
});
|
package/src/api/Series.ts
CHANGED
@@ -33,5 +33,18 @@ export default (api) => ({
|
|
33
33
|
value,
|
34
34
|
series : series?.id,
|
35
35
|
});
|
36
|
-
}
|
36
|
+
},
|
37
|
+
categories : (opts = {}) => {
|
38
|
+
// return done
|
39
|
+
return api.get(`/series/categories`, opts);
|
40
|
+
},
|
41
|
+
|
42
|
+
play : (series, context, episode, scene) => {
|
43
|
+
// return done
|
44
|
+
return api[(context || episode || scene) ? 'patch' : 'get'](`/series/${series?.id || series}/play`, {
|
45
|
+
scene,
|
46
|
+
context,
|
47
|
+
episode,
|
48
|
+
});
|
49
|
+
},
|
37
50
|
});
|
package/src/index.ts
CHANGED
@@ -29,6 +29,7 @@ import Brain from './api/Brain';
|
|
29
29
|
import Season from './api/Season';
|
30
30
|
import Studio from './api/Studio';
|
31
31
|
import Follow from './api/Follow';
|
32
|
+
import Review from './api/Review';
|
32
33
|
import Series from './api/Series';
|
33
34
|
import Search from './api/Search';
|
34
35
|
import Dislike from './api/Dislike';
|
@@ -126,6 +127,7 @@ export default class chirperNode {
|
|
126
127
|
this.World = World(this);
|
127
128
|
this.Place = Place(this);
|
128
129
|
this.Story = Story(this);
|
130
|
+
this.Review = Review(this);
|
129
131
|
this.Series = Series(this);
|
130
132
|
this.Search = Search(this);
|
131
133
|
this.Studio = Studio(this);
|