1
0
mirror of https://github.com/StarGazer114/stargazer114.github.io.git synced 2025-01-09 06:48:17 +08:00
stargazer114.github.io/pluginsSrc/artalk/dist/Artalk.js

12 lines
153 KiB
JavaScript
Raw Normal View History

2025-01-05 20:41:38 +08:00
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Artalk={})}(this,(function(e){"use strict";var t=Object.defineProperty,n=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,a=(e,n,s)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,l=(e,t)=>{for(var n in t||(t={}))r.call(t,n)&&a(e,n,t[n]);if(i)for(var n of i(t))o.call(t,n)&&a(e,n,t[n]);return e},c=(e,t)=>n(e,s(t)),d=(e,t,n)=>a(e,"symbol"!=typeof t?t+"":t,n),h=(e,t,n)=>new Promise(((s,i)=>{var r=e=>{try{a(n.next(e))}catch(t){i(t)}},o=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(r,o);a((n=n.apply(e,t)).next())}));class u{constructor(e={}){d(this,"baseUrl","/api/v2"),d(this,"securityData",null),d(this,"securityWorker"),d(this,"abortControllers",new Map),d(this,"customFetch",((...e)=>fetch(...e))),d(this,"baseApiParams",{credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"}),d(this,"setSecurityData",(e=>{this.securityData=e})),d(this,"contentFormatters",{"application/json":e=>null===e||"object"!=typeof e&&"string"!=typeof e?e:JSON.stringify(e),"text/plain":e=>null!==e&&"string"!=typeof e?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce(((t,n)=>{const s=e[n];return t.append(n,s instanceof Blob?s:"object"==typeof s&&null!==s?JSON.stringify(s):`${s}`),t}),new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)}),d(this,"createAbortSignal",(e=>{if(this.abortControllers.has(e)){const t=this.abortControllers.get(e);return t?t.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal})),d(this,"abortRequest",(e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))})),d(this,"request",(e=>h(this,null,(function*(){var t=e,{body:n,secure:s,path:a,type:d,query:u,format:p,baseUrl:g,cancelToken:m}=t,f=((e,t)=>{var n={};for(var s in e)r.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&i)for(var s of i(e))t.indexOf(s)<0&&o.call(e,s)&&(n[s]=e[s]);return n})(t,["body","secure","path","type","query","format","baseUrl","cancelToken"]);const k=("boolean"==typeof s?s:this.baseApiParams.secure)&&this.securityWorker&&(yield this.securityWorker(this.securityData))||{},y=this.mergeRequestParams(f,k),$=u&&this.toQueryString(u),v=this.contentFormatters[d||"application/json"],w=p||y.format;return this.customFetch(`${g||this.baseUrl||""}${a}${$?`?${$}`:""}`,c(l({},y),{headers:l(l({},y.headers||{}),d&&"multipart/form-data"!==d?{"Content-Type":d}:{}),signal:(m?this.createAbortSignal(m):y.signal)||null,body:null==n?null:v(n)})).then((e=>h(this,null,(function*(){const t=e.clone();t.data=null,t.error=null;const n=w?yield e[w]().then((e=>(t.ok?t.data=e:t.error=e,t))).catch((e=>(t.error=e,t))):t;if(m&&this.abortControllers.delete(m),!e.ok)throw n;return n}))))})))),Object.assign(this,e)}encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent("number"==typeof t?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map((e=>this.encodeQueryParam(t,e))).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter((e=>void 0!==t[e])).map((e=>Array.isArray(t[e])?this.addArrayQueryParam(t,e):this.addQueryParam(t,e))).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}mergeRequestParams(e,t){return c(l(l(l({},this.baseApiParams),e),t||{}),{headers:l(l(l({},this.baseApiParams.headers||{}),e.headers||{}),t&&t.headers||{})})}}
/**
* @title Artalk API
* @version 2.0
* @license MIT (https://github.com/ArtalkJS/Artalk/blob/master/LICENSE)
* @baseUrl /api/v2
* @contact API Support <artalkjs@gmail.com> (https://artalk.js.org)
*
* Artalk is a modern comment system based on Golang.
*/let p=class extends u{constructor(){super(...arguments),d(this,"auth",{loginByEmail:(e,t={})=>this.request(l({path:"/auth/email/login",method:"POST",body:e,type:"application/json",format:"json"},t)),registerByEmail:(e,t={})=>this.request(l({path:"/auth/email/register",method:"POST",body:e,type:"application/json",format:"json"},t)),sendVerifyEmail:(e,t={})=>this.request(l({path:"/auth/email/send",method:"POST",body:e,type:"application/json",format:"json"},t)),checkDataMerge:(e={})=>this.request(l({path:"/auth/merge",method:"GET",secure:!0,format:"json"},e)),applyDataMerge:(e,t={})=>this.request(l({path:"/auth/merge",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),d(this,"cache",{flushCache:(e={})=>this.request(l({path:"/cache/flush",method:"POST",secure:!0,format:"json"},e)),warmUpCache:(e={})=>this.request(l({path:"/cache/warm_up",method:"POST",secure:!0,format:"json"},e))}),d(this,"captcha",{getCaptcha:(e={})=>this.request(l({path:"/captcha",method:"GET",format:"json"},e)),getCaptchaStatus:(e={})=>this.request(l({path:"/captcha/status",method:"GET",format:"json"},e)),verifyCaptcha:(e,t={})=>this.request(l({path:"/captcha/verify",method:"POST",body:e,type:"application/json",format:"json"},t))}),d(this,"comments",{getComments:(e,t={})=>this.request(l({path:"/comments",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),createComment:(e,t={})=>this.request(l({path:"/comments",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getComment:(e,t={})=>this.request(l({path:`/comments/${e}`,method:"GET",type:"application/json",format:"json"},t)),updateComment:(e,t,n={})=>this.request(l({path:`/comments/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteComment:(e,t={})=>this.request(l({path:`/comments/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),d(this,"conf",{conf:(e={})=>this.request(l({path:"/conf",method:"GET",format:"json"},e)),getSocialLoginProviders:(e={})=>this.request(l({path:"/conf/auth/providers",method:"GET",format:"json"},e)),getDomain:(e,t={})=>this.request(l({path:"/conf/domain",method:"GET",query:e,format:"json"},t))}),d(this,"notifies",{getNotifies:(e,t={})=>this.request(l({path:"/notifies",method:"GET",query:e,type:"application/json",format:"json"},t)),markAllNotifyRead:(e,t={})=>this.request(l({path:"/notifies/read",method:"POST",body:e,type:"application/json",format:"json"},t)),markNotifyRead:(e,t,n={})=>this.request(l({path:`/notifies/${e}/${t}`,method:"POST",format:"json"},n))}),d(this,"pages",{getPages:(e,t={})=>this.request(l({path:"/pages",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),fetchAllPages:(e,t={})=>this.request(l({path:"/pages/fetch",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getPageFetchStatus:(e={})=>this.request(l({path:"/pages/fetch/status",method:"GET",secure:!0,format:"json"},e)),logPv:(e,t={})=>this.request(l({path:"/pages/pv",method:"POST",body:e,type:"application/json",format:"json"},t)),updatePage:(e,t,n={})=>this.request(l({path:`/pages/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deletePage:(e,t={})=>this.request(l({path:`/pages/${e}`,method:"DELETE",secure:!0,format:"json"},t)),fetchPage:(e,t={})=>this.request(l({path:`/pages/${e}/fetch`,method:"POST",secure:!0,type:"application/json",format:"json"},t))}),d(this,"sendEmail",{sendEmail:(e,t={})=>this.request(l({path:"/send_email",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),d(this,"settings",{getSettings:(e={})=>this.request(l({path:"/settings",method:"GET",secure:!0,format:"json"},e)),applySettings:(e,t={})=>this.request(l({path:"/settings",method:"PUT",body:e,secure:!0,type:"application/json",format:"json"},t)),getSettingsTemplate:(e,t={})=>this.request(l({path:`/settings/template/${e}`,method:"GET",secure:!0,format:"json"},t))}),d(this,"sites",{getSites:(e={})=>this.request(l({path:"/sites",method:"GET",secure:!0,format:"json"},e)),createSite:(e,t={})=>this.request(l({path:"/sites",method:"
//# sourceMappingURL=Artalk.js.map