@rainte/js 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -4
- package/dist/index.umd.cjs +1 -1
- package/index.d.ts +2 -0
- package/package.json +9 -4
package/dist/index.js
CHANGED
|
@@ -5662,7 +5662,7 @@ class Jo {
|
|
|
5662
5662
|
this.storage = o;
|
|
5663
5663
|
}
|
|
5664
5664
|
getRaw(o, u = null) {
|
|
5665
|
-
return this.storage.getItem(o)
|
|
5665
|
+
return this.storage.getItem(o) ?? u;
|
|
5666
5666
|
}
|
|
5667
5667
|
setRaw(o, u) {
|
|
5668
5668
|
this.storage.setItem(o, u);
|
|
@@ -5689,7 +5689,7 @@ const ri = new Jo(localStorage), Go = new Jo(sessionStorage), ju = {
|
|
|
5689
5689
|
default: ju,
|
|
5690
5690
|
local: ri,
|
|
5691
5691
|
session: Go
|
|
5692
|
-
}, Symbol.toStringTag, { value: "Module" })), Xo = "access_token", Qo = (r, o = "请求异常.") => r.message
|
|
5692
|
+
}, Symbol.toStringTag, { value: "Module" })), Xo = "access_token", Qo = (r, o = "请求异常.") => r.message ?? r.msg ?? o, sn = $e.create({
|
|
5693
5693
|
baseURL: "",
|
|
5694
5694
|
timeout: 3e3,
|
|
5695
5695
|
headers: { "Content-Type": "application/json" }
|
|
@@ -5714,7 +5714,7 @@ const qu = (r, o, u) => {
|
|
|
5714
5714
|
})), new Promise((l) => {
|
|
5715
5715
|
Fn.push(() => l(sn(a.config)));
|
|
5716
5716
|
}));
|
|
5717
|
-
}, Zo = (r, o) => an({ url: r, method: "GET", params: o }), es = (r, o) => an({ url: r, method: "POST", data: o }), ts = (r) => (r.responseType
|
|
5717
|
+
}, Zo = (r, o) => an({ url: r, method: "GET", params: o }), es = (r, o) => an({ url: r, method: "POST", data: o }), ts = (r) => (r.responseType ?? (r.responseType = "blob"), an(r)), an = (r) => sn.request(r), Fu = {
|
|
5718
5718
|
get: Zo,
|
|
5719
5719
|
post: es,
|
|
5720
5720
|
download: ts,
|
|
@@ -5741,7 +5741,7 @@ const qu = (r, o, u) => {
|
|
|
5741
5741
|
r[o] = u;
|
|
5742
5742
|
return r;
|
|
5743
5743
|
}, rs = (r, o, u) => {
|
|
5744
|
-
o
|
|
5744
|
+
o ?? (o = "_blank"), window.open(r, o, u);
|
|
5745
5745
|
}, Bu = {
|
|
5746
5746
|
search: ii,
|
|
5747
5747
|
all: ns,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(o){return o instanceof this?o:new this(o)}static concat(o,...u){const a=new this(o);return u.forEach(l=>a.set(l)),a}static accessor(o){const a=(this[Qi]=this[Qi]={accessors:{}}).accessors,l=this.prototype;function d(h){const S=Ut(h);a[S]||(Ma(l,h),a[S]=!0)}return A.isArray(o)?o.forEach(d):d(o),this}};Ye.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),A.reduceDescriptors(Ye.prototype,({value:r},o)=>{let u=o[0].toUpperCase()+o.slice(1);return{get:()=>r,set(a){this[u]=a}}}),A.freezeMethods(Ye);function gr(r,o){const u=this||Lt,a=o||u,l=Ye.from(a.headers);let d=a.data;return A.forEach(r,function(S){d=S.call(u,d,l.normalize(),o?o.status:void 0)}),l.normalize(),d}function Zi(r){return!!(r&&r.__CANCEL__)}function At(r,o,u){pe.call(this,r??"canceled",pe.ERR_CANCELED,o,u),this.name="CanceledError"}A.inherits(At,pe,{__CANCEL__:!0});function eo(r,o,u){const a=u.config.validateStatus;!u.status||!a||a(u.status)?r(u):o(new pe("Request failed with status code "+u.status,[pe.ERR_BAD_REQUEST,pe.ERR_BAD_RESPONSE][Math.floor(u.status/100)-4],u.config,u.request,u))}function Na(r){const o=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return o&&o[1]||""}function qa(r,o){r=r||10;const u=new Array(r),a=new Array(r);let l=0,d=0,h;return o=o!==void 0?o:1e3,function($){const C=Date.now(),D=a[d];h||(h=C),u[l]=$,a[l]=C;let M=d,ae=0;for(;M!==l;)ae+=u[M++],M=M%r;if(l=(l+1)%r,l===d&&(d=(d+1)%r),C-h<o)return;const ue=D&&C-D;return ue?Math.round(ae*1e3/ue):void 0}}function Fa(r,o){let u=0,a=1e3/o,l,d;const h=(C,D=Date.now())=>{u=D,l=null,d&&(clearTimeout(d),d=null),r.apply(null,C)};return[(...C)=>{const D=Date.now(),M=D-u;M>=a?h(C,D):(l=C,d||(d=setTimeout(()=>{d=null,h(l)},a-M)))},()=>l&&h(l)]}const kn=(r,o,u=3)=>{let a=0;const l=qa(50,250);return Fa(d=>{const h=d.loaded,S=d.lengthComputable?d.total:void 0,$=h-a,C=l($),D=h<=S;a=h;const M={loaded:h,total:S,progress:S?h/S:void 0,bytes:$,rate:C||void 0,estimated:C&&S&&D?(S-h)/C:void 0,event:d,lengthComputable:S!=null,[o?"download":"upload"]:!0};r(M)},u)},to=(r,o)=>{const u=r!=null;return[a=>o[0]({lengthComputable:u,total:r,loaded:a}),o[1]]},no=r=>(...o)=>A.asap(()=>r(...o)),Ba=Fe.hasStandardBrowserEnv?((r,o)=>u=>(u=new URL(u,Fe.origin),r.protocol===u.protocol&&r.host===u.host&&(o||r.port===u.port)))(new URL(Fe.origin),Fe.navigator&&/(msie|trident)/i.test(Fe.navigator.userAgent)):()=>!0,Ka=Fe.hasStandardBrowserEnv?{write(r,o,u,a,l,d){const h=[r+"="+encodeURIComponent(o)];A.isNumber(u)&&h.push("expires="+new Date(u).toGMTString()),A.isString(a)&&h.push("path="+a),A.isString(l)&&h.push("domain="+l),d===!0&&h.push("secure"),document.cookie=h.join("; ")},read(r){const o=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return o?decodeURIComponent(o[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Ia(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function La(r,o){return o?r.replace(/\/?\/$/,"")+"/"+o.replace(/^\/+/,""):r}function ro(r,o,u){let a=!Ia(o);return r&&a||u==!1?La(r,o):o}const io=r=>r instanceof Ye?{...r}:r;function yt(r,o){o=o||{};const u={};function a(C,D,M,ae){return A.isPlainObject(C)&&A.isPlainObject(D)?A.merge.call({caseless:ae},C,D):A.isPlainObject(D)?A.merge({},D):A.isArray(D)?D.slice():D}function l(C,D,M,ae){if(A.isUndefined(D)){if(!A.isUndefined(C))return a(void 0,C,M,ae)}else return a(C,D,M,ae)}function d(C,D){if(!A.isUndefined(D))return a(void 0,D)}function h(C,D){if(A.isUndefined(D)){if(!A.isUndefined(C))return a(void 0,C)}else return a(void 0,D)}function S(C,D,M){if(M in o)return a(C,D);if(M in r)return a(void 0,C)}const $={url:d,method:d,data:d,baseURL:h,transformRequest:h,transformResponse:h,paramsSerializer:h,timeout:h,timeoutMessage:h,withCredentials:h,withXSRFToken:h,adapter:h,responseType:h,xsrfCookieName:h,xsrfHeaderName:h,onUploadProgress:h,onDownloadProgress:h,decompress:h,maxContentLength:h,maxBodyLength:h,beforeRedirect:h,transport:h,httpAgent:h,httpsAgent:h,cancelToken:h,socketPath:h,responseEncoding:h,validateStatus:S,headers:(C,D,M)=>l(io(C),io(D),M,!0)};return A.forEach(Object.keys(Object.assign({},r,o)),function(D){const M=$[D]||l,ae=M(r[D],o[D],D);A.isUndefined(ae)&&M!==S||(u[D]=ae)}),u}const oo=r=>{const o=yt({},r);let{data:u,withXSRFToken:a,xsrfHeaderName:l,xsrfCookieName:d,headers:h,auth:S}=o;o.headers=h=Ye.from(h),o.url=Wi(ro(o.baseURL,o.url,o.allowAbsoluteUrls),r.params,r.paramsSerializer),S&&h.set("Authorization","Basic "+btoa((S.username||"")+":"+(S.password?unescape(encodeURIComponent(S.password)):"")));let $;if(A.isFormData(u)){if(Fe.hasStandardBrowserEnv||Fe.hasStandardBrowserWebWorkerEnv)h.setContentType(void 0);else if(($=h.getContentType())!==!1){const[C,...D]=$?$.split(";").map(M=>M.trim()).filter(Boolean):[];h.setContentType([C||"multipart/form-data",...D].join("; "))}}if(Fe.hasStandardBrowserEnv&&(a&&A.isFunction(a)&&(a=a(o)),a||a!==!1&&Ba(o.url))){const C=l&&d&&Ka.read(d);C&&h.set(l,C)}return o},Ua=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(u,a){const l=oo(r);let d=l.data;const h=Ye.from(l.headers).normalize();let{responseType:S,onUploadProgress:$,onDownloadProgress:C}=l,D,M,ae,ue,N;function j(){ue&&ue(),N&&N(),l.cancelToken&&l.cancelToken.unsubscribe(D),l.signal&&l.signal.removeEventListener("abort",D)}let E=new XMLHttpRequest;E.open(l.method.toUpperCase(),l.url,!0),E.timeout=l.timeout;function J(){if(!E)return;const G=Ye.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders()),fe={data:!S||S==="text"||S==="json"?E.responseText:E.response,status:E.status,statusText:E.statusText,headers:G,config:r,request:E};eo(function(U){u(U),j()},function(U){a(U),j()},fe),E=null}"onloadend"in E?E.onloadend=J:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.indexOf("file:")===0)||setTimeout(J)},E.onabort=function(){E&&(a(new pe("Request aborted",pe.ECONNABORTED,r,E)),E=null)},E.onerror=function(){a(new pe("Network Error",pe.ERR_NETWORK,r,E)),E=null},E.ontimeout=function(){let _e=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded";const fe=l.transitional||Gi;l.timeoutErrorMessage&&(_e=l.timeoutErrorMessage),a(new pe(_e,fe.clarifyTimeoutError?pe.ETIMEDOUT:pe.ECONNABORTED,r,E)),E=null},d===void 0&&h.setContentType(null),"setRequestHeader"in E&&A.forEach(h.toJSON(),function(_e,fe){E.setRequestHeader(fe,_e)}),A.isUndefined(l.withCredentials)||(E.withCredentials=!!l.withCredentials),S&&S!=="json"&&(E.responseType=l.responseType),C&&([ae,N]=kn(C,!0),E.addEventListener("progress",ae)),$&&E.upload&&([M,ue]=kn($),E.upload.addEventListener("progress",M),E.upload.addEventListener("loadend",ue)),(l.cancelToken||l.signal)&&(D=G=>{E&&(a(!G||G.type?new At(null,r,E):G),E.abort(),E=null)},l.cancelToken&&l.cancelToken.subscribe(D),l.signal&&(l.signal.aborted?D():l.signal.addEventListener("abort",D)));const re=Na(l.url);if(re&&Fe.protocols.indexOf(re)===-1){a(new pe("Unsupported protocol "+re+":",pe.ERR_BAD_REQUEST,r));return}E.send(d||null)})},Ya=(r,o)=>{const{length:u}=r=r?r.filter(Boolean):[];if(o||u){let a=new AbortController,l;const d=function(C){if(!l){l=!0,S();const D=C instanceof Error?C:this.reason;a.abort(D instanceof pe?D:new At(D instanceof Error?D.message:D))}};let h=o&&setTimeout(()=>{h=null,d(new pe(`timeout ${o} of ms exceeded`,pe.ETIMEDOUT))},o);const S=()=>{r&&(h&&clearTimeout(h),h=null,r.forEach(C=>{C.unsubscribe?C.unsubscribe(d):C.removeEventListener("abort",d)}),r=null)};r.forEach(C=>C.addEventListener("abort",d));const{signal:$}=a;return $.unsubscribe=()=>A.asap(S),$}},Ha=function*(r,o){let u=r.byteLength;if(u<o){yield r;return}let a=0,l;for(;a<u;)l=a+o,yield r.slice(a,l),a=l},za=async function*(r,o){for await(const u of Va(r))yield*Ha(u,o)},Va=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const o=r.getReader();try{for(;;){const{done:u,value:a}=await o.read();if(u)break;yield a}}finally{await o.cancel()}},so=(r,o,u,a)=>{const l=za(r,o);let d=0,h,S=$=>{h||(h=!0,a&&a($))};return new ReadableStream({async pull($){try{const{done:C,value:D}=await l.next();if(C){S(),$.close();return}let M=D.byteLength;if(u){let ae=d+=M;u(ae)}$.enqueue(new Uint8Array(D))}catch(C){throw S(C),C}},cancel($){return S($),l.return()}},{highWaterMark:2})},Tn=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ao=Tn&&typeof ReadableStream=="function",Wa=Tn&&(typeof TextEncoder=="function"?(r=>o=>r.encode(o))(new TextEncoder):async r=>new Uint8Array(await new Response(r).arrayBuffer())),uo=(r,...o)=>{try{return!!r(...o)}catch{return!1}},Ja=ao&&uo(()=>{let r=!1;const o=new Request(Fe.origin,{body:new ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type");return r&&!o}),co=64*1024,br=ao&&uo(()=>A.isReadableStream(new Response("").body)),Rn={stream:br&&(r=>r.body)};Tn&&(r=>{["text","arrayBuffer","blob","formData","stream"].forEach(o=>{!Rn[o]&&(Rn[o]=A.isFunction(r[o])?u=>u[o]():(u,a)=>{throw new pe(`Response type '${o}' is not supported`,pe.ERR_NOT_SUPPORT,a)})})})(new Response);const Ga=async r=>{if(r==null)return 0;if(A.isBlob(r))return r.size;if(A.isSpecCompliantForm(r))return(await new Request(Fe.origin,{method:"POST",body:r}).arrayBuffer()).byteLength;if(A.isArrayBufferView(r)||A.isArrayBuffer(r))return r.byteLength;if(A.isURLSearchParams(r)&&(r=r+""),A.isString(r))return(await Wa(r)).byteLength},Xa=async(r,o)=>{const u=A.toFiniteNumber(r.getContentLength());return u??Ga(o)},wr={http:ga,xhr:Ua,fetch:Tn&&(async r=>{let{url:o,method:u,data:a,signal:l,cancelToken:d,timeout:h,onDownloadProgress:S,onUploadProgress:$,responseType:C,headers:D,withCredentials:M="same-origin",fetchOptions:ae}=oo(r);C=C?(C+"").toLowerCase():"text";let ue=Ya([l,d&&d.toAbortSignal()],h),N;const j=ue&&ue.unsubscribe&&(()=>{ue.unsubscribe()});let E;try{if($&&Ja&&u!=="get"&&u!=="head"&&(E=await Xa(D,a))!==0){let fe=new Request(o,{method:"POST",body:a,duplex:"half"}),te;if(A.isFormData(a)&&(te=fe.headers.get("content-type"))&&D.setContentType(te),fe.body){const[U,K]=to(E,kn(no($)));a=so(fe.body,co,U,K)}}A.isString(M)||(M=M?"include":"omit");const J="credentials"in Request.prototype;N=new Request(o,{...ae,signal:ue,method:u.toUpperCase(),headers:D.normalize().toJSON(),body:a,duplex:"half",credentials:J?M:void 0});let re=await fetch(N);const G=br&&(C==="stream"||C==="response");if(br&&(S||G&&j)){const fe={};["status","statusText","headers"].forEach(ce=>{fe[ce]=re[ce]});const te=A.toFiniteNumber(re.headers.get("content-length")),[U,K]=S&&to(te,kn(no(S),!0))||[];re=new Response(so(re.body,co,U,()=>{K&&K(),j&&j()}),fe)}C=C||"text";let _e=await Rn[A.findKey(Rn,C)||"text"](re,r);return!G&&j&&j(),await new Promise((fe,te)=>{eo(fe,te,{data:_e,headers:Ye.from(re.headers),status:re.status,statusText:re.statusText,config:r,request:N})})}catch(J){throw j&&j(),J&&J.name==="TypeError"&&/fetch/i.test(J.message)?Object.assign(new pe("Network Error",pe.ERR_NETWORK,r,N),{cause:J.cause||J}):pe.from(J,J&&J.code,r,N)}})};A.forEach(wr,(r,o)=>{if(r){try{Object.defineProperty(r,"name",{value:o})}catch{}Object.defineProperty(r,"adapterName",{value:o})}});const lo=r=>`- ${r}`,Qa=r=>A.isFunction(r)||r===null||r===!1,fo={getAdapter:r=>{r=A.isArray(r)?r:[r];const{length:o}=r;let u,a;const l={};for(let d=0;d<o;d++){u=r[d];let h;if(a=u,!Qa(u)&&(a=wr[(h=String(u)).toLowerCase()],a===void 0))throw new pe(`Unknown adapter '${h}'`);if(a)break;l[h||"#"+d]=a}if(!a){const d=Object.entries(l).map(([S,$])=>`adapter ${S} `+($===!1?"is not supported by the environment":"is not available in the build"));let h=o?d.length>1?`since :
|
|
6
6
|
`+d.map(lo).join(`
|
|
7
7
|
`):" "+lo(d[0]):"as no adapter specified";throw new pe("There is no suitable adapter to dispatch the request "+h,"ERR_NOT_SUPPORT")}return a},adapters:wr};function _r(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new At(null,r)}function ho(r){return _r(r),r.headers=Ye.from(r.headers),r.data=gr.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),fo.getAdapter(r.adapter||Lt.adapter)(r).then(function(a){return _r(r),a.data=gr.call(r,r.transformResponse,a),a.headers=Ye.from(a.headers),a},function(a){return Zi(a)||(_r(r),a&&a.response&&(a.response.data=gr.call(r,r.transformResponse,a.response),a.response.headers=Ye.from(a.response.headers))),Promise.reject(a)})}const po="1.8.3",An={};["object","boolean","number","function","string","symbol"].forEach((r,o)=>{An[r]=function(a){return typeof a===r||"a"+(o<1?"n ":" ")+r}});const mo={};An.transitional=function(o,u,a){function l(d,h){return"[Axios v"+po+"] Transitional option '"+d+"'"+h+(a?". "+a:"")}return(d,h,S)=>{if(o===!1)throw new pe(l(h," has been removed"+(u?" in "+u:"")),pe.ERR_DEPRECATED);return u&&!mo[h]&&(mo[h]=!0,console.warn(l(h," has been deprecated since v"+u+" and will be removed in the near future"))),o?o(d,h,S):!0}},An.spelling=function(o){return(u,a)=>(console.warn(`${a} is likely a misspelling of ${o}`),!0)};function Za(r,o,u){if(typeof r!="object")throw new pe("options must be an object",pe.ERR_BAD_OPTION_VALUE);const a=Object.keys(r);let l=a.length;for(;l-- >0;){const d=a[l],h=o[d];if(h){const S=r[d],$=S===void 0||h(S,d,r);if($!==!0)throw new pe("option "+d+" must be "+$,pe.ERR_BAD_OPTION_VALUE);continue}if(u!==!0)throw new pe("Unknown option "+d,pe.ERR_BAD_OPTION)}}const $n={assertOptions:Za,validators:An},tt=$n.validators;let vt=class{constructor(o){this.defaults=o,this.interceptors={request:new Ji,response:new Ji}}async request(o,u){try{return await this._request(o,u)}catch(a){if(a instanceof Error){let l={};Error.captureStackTrace?Error.captureStackTrace(l):l=new Error;const d=l.stack?l.stack.replace(/^.+\n/,""):"";try{a.stack?d&&!String(a.stack).endsWith(d.replace(/^.+\n.+\n/,""))&&(a.stack+=`
|
|
8
|
-
`+d):a.stack=d}catch{}}throw a}}_request(o,u){typeof o=="string"?(u=u||{},u.url=o):u=o||{},u=yt(this.defaults,u);const{transitional:a,paramsSerializer:l,headers:d}=u;a!==void 0&&$n.assertOptions(a,{silentJSONParsing:tt.transitional(tt.boolean),forcedJSONParsing:tt.transitional(tt.boolean),clarifyTimeoutError:tt.transitional(tt.boolean)},!1),l!=null&&(A.isFunction(l)?u.paramsSerializer={serialize:l}:$n.assertOptions(l,{encode:tt.function,serialize:tt.function},!0)),u.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?u.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:u.allowAbsoluteUrls=!0),$n.assertOptions(u,{baseUrl:tt.spelling("baseURL"),withXsrfToken:tt.spelling("withXSRFToken")},!0),u.method=(u.method||this.defaults.method||"get").toLowerCase();let h=d&&A.merge(d.common,d[u.method]);d&&A.forEach(["delete","get","head","post","put","patch","common"],N=>{delete d[N]}),u.headers=Ye.concat(h,d);const S=[];let $=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(u)===!1||($=$&&j.synchronous,S.unshift(j.fulfilled,j.rejected))});const C=[];this.interceptors.response.forEach(function(j){C.push(j.fulfilled,j.rejected)});let D,M=0,ae;if(!$){const N=[ho.bind(this),void 0];for(N.unshift.apply(N,S),N.push.apply(N,C),ae=N.length,D=Promise.resolve(u);M<ae;)D=D.then(N[M++],N[M++]);return D}ae=S.length;let ue=u;for(M=0;M<ae;){const N=S[M++],j=S[M++];try{ue=N(ue)}catch(E){j.call(this,E);break}}try{D=ho.call(this,ue)}catch(N){return Promise.reject(N)}for(M=0,ae=C.length;M<ae;)D=D.then(C[M++],C[M++]);return D}getUri(o){o=yt(this.defaults,o);const u=ro(o.baseURL,o.url,o.allowAbsoluteUrls);return Wi(u,o.params,o.paramsSerializer)}};A.forEach(["delete","get","head","options"],function(o){vt.prototype[o]=function(u,a){return this.request(yt(a||{},{method:o,url:u,data:(a||{}).data}))}}),A.forEach(["post","put","patch"],function(o){function u(a){return function(d,h,S){return this.request(yt(S||{},{method:o,headers:a?{"Content-Type":"multipart/form-data"}:{},url:d,data:h}))}}vt.prototype[o]=u(),vt.prototype[o+"Form"]=u(!0)});let eu=class os{constructor(o){if(typeof o!="function")throw new TypeError("executor must be a function.");let u;this.promise=new Promise(function(d){u=d});const a=this;this.promise.then(l=>{if(!a._listeners)return;let d=a._listeners.length;for(;d-- >0;)a._listeners[d](l);a._listeners=null}),this.promise.then=l=>{let d;const h=new Promise(S=>{a.subscribe(S),d=S}).then(l);return h.cancel=function(){a.unsubscribe(d)},h},o(function(d,h,S){a.reason||(a.reason=new At(d,h,S),u(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(o){if(this.reason){o(this.reason);return}this._listeners?this._listeners.push(o):this._listeners=[o]}unsubscribe(o){if(!this._listeners)return;const u=this._listeners.indexOf(o);u!==-1&&this._listeners.splice(u,1)}toAbortSignal(){const o=new AbortController,u=a=>{o.abort(a)};return this.subscribe(u),o.signal.unsubscribe=()=>this.unsubscribe(u),o.signal}static source(){let o;return{token:new os(function(l){o=l}),cancel:o}}};function tu(r){return function(u){return r.apply(null,u)}}function nu(r){return A.isObject(r)&&r.isAxiosError===!0}const xr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(xr).forEach(([r,o])=>{xr[o]=r});function yo(r){const o=new vt(r),u=ji(vt.prototype.request,o);return A.extend(u,vt.prototype,o,{allOwnKeys:!0}),A.extend(u,o,null,{allOwnKeys:!0}),u.create=function(l){return yo(yt(r,l))},u}const Re=yo(Lt);Re.Axios=vt,Re.CanceledError=At,Re.CancelToken=eu,Re.isCancel=Zi,Re.VERSION=po,Re.toFormData=On,Re.AxiosError=pe,Re.Cancel=Re.CanceledError,Re.all=function(o){return Promise.all(o)},Re.spread=tu,Re.isAxiosError=nu,Re.mergeConfig=yt,Re.AxiosHeaders=Ye,Re.formToJSON=r=>Xi(A.isHTMLForm(r)?new FormData(r):r),Re.getAdapter=fo.getAdapter,Re.HttpStatusCode=xr,Re.default=Re;const{Axios:rc,AxiosError:ic,CanceledError:oc,isCancel:sc,CancelToken:ac,VERSION:uc,all:cc,Cancel:lc,isAxiosError:fc,spread:dc,toFormData:hc,AxiosHeaders:pc,HttpStatusCode:mc,formToJSON:yc,getAdapter:vc,mergeConfig:gc}=Re;class vo{constructor(o){si(this,"storage");this.storage=o}getRaw(o,u=null){return this.storage.getItem(o)
|
|
8
|
+
`+d):a.stack=d}catch{}}throw a}}_request(o,u){typeof o=="string"?(u=u||{},u.url=o):u=o||{},u=yt(this.defaults,u);const{transitional:a,paramsSerializer:l,headers:d}=u;a!==void 0&&$n.assertOptions(a,{silentJSONParsing:tt.transitional(tt.boolean),forcedJSONParsing:tt.transitional(tt.boolean),clarifyTimeoutError:tt.transitional(tt.boolean)},!1),l!=null&&(A.isFunction(l)?u.paramsSerializer={serialize:l}:$n.assertOptions(l,{encode:tt.function,serialize:tt.function},!0)),u.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?u.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:u.allowAbsoluteUrls=!0),$n.assertOptions(u,{baseUrl:tt.spelling("baseURL"),withXsrfToken:tt.spelling("withXSRFToken")},!0),u.method=(u.method||this.defaults.method||"get").toLowerCase();let h=d&&A.merge(d.common,d[u.method]);d&&A.forEach(["delete","get","head","post","put","patch","common"],N=>{delete d[N]}),u.headers=Ye.concat(h,d);const S=[];let $=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(u)===!1||($=$&&j.synchronous,S.unshift(j.fulfilled,j.rejected))});const C=[];this.interceptors.response.forEach(function(j){C.push(j.fulfilled,j.rejected)});let D,M=0,ae;if(!$){const N=[ho.bind(this),void 0];for(N.unshift.apply(N,S),N.push.apply(N,C),ae=N.length,D=Promise.resolve(u);M<ae;)D=D.then(N[M++],N[M++]);return D}ae=S.length;let ue=u;for(M=0;M<ae;){const N=S[M++],j=S[M++];try{ue=N(ue)}catch(E){j.call(this,E);break}}try{D=ho.call(this,ue)}catch(N){return Promise.reject(N)}for(M=0,ae=C.length;M<ae;)D=D.then(C[M++],C[M++]);return D}getUri(o){o=yt(this.defaults,o);const u=ro(o.baseURL,o.url,o.allowAbsoluteUrls);return Wi(u,o.params,o.paramsSerializer)}};A.forEach(["delete","get","head","options"],function(o){vt.prototype[o]=function(u,a){return this.request(yt(a||{},{method:o,url:u,data:(a||{}).data}))}}),A.forEach(["post","put","patch"],function(o){function u(a){return function(d,h,S){return this.request(yt(S||{},{method:o,headers:a?{"Content-Type":"multipart/form-data"}:{},url:d,data:h}))}}vt.prototype[o]=u(),vt.prototype[o+"Form"]=u(!0)});let eu=class os{constructor(o){if(typeof o!="function")throw new TypeError("executor must be a function.");let u;this.promise=new Promise(function(d){u=d});const a=this;this.promise.then(l=>{if(!a._listeners)return;let d=a._listeners.length;for(;d-- >0;)a._listeners[d](l);a._listeners=null}),this.promise.then=l=>{let d;const h=new Promise(S=>{a.subscribe(S),d=S}).then(l);return h.cancel=function(){a.unsubscribe(d)},h},o(function(d,h,S){a.reason||(a.reason=new At(d,h,S),u(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(o){if(this.reason){o(this.reason);return}this._listeners?this._listeners.push(o):this._listeners=[o]}unsubscribe(o){if(!this._listeners)return;const u=this._listeners.indexOf(o);u!==-1&&this._listeners.splice(u,1)}toAbortSignal(){const o=new AbortController,u=a=>{o.abort(a)};return this.subscribe(u),o.signal.unsubscribe=()=>this.unsubscribe(u),o.signal}static source(){let o;return{token:new os(function(l){o=l}),cancel:o}}};function tu(r){return function(u){return r.apply(null,u)}}function nu(r){return A.isObject(r)&&r.isAxiosError===!0}const xr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(xr).forEach(([r,o])=>{xr[o]=r});function yo(r){const o=new vt(r),u=ji(vt.prototype.request,o);return A.extend(u,vt.prototype,o,{allOwnKeys:!0}),A.extend(u,o,null,{allOwnKeys:!0}),u.create=function(l){return yo(yt(r,l))},u}const Re=yo(Lt);Re.Axios=vt,Re.CanceledError=At,Re.CancelToken=eu,Re.isCancel=Zi,Re.VERSION=po,Re.toFormData=On,Re.AxiosError=pe,Re.Cancel=Re.CanceledError,Re.all=function(o){return Promise.all(o)},Re.spread=tu,Re.isAxiosError=nu,Re.mergeConfig=yt,Re.AxiosHeaders=Ye,Re.formToJSON=r=>Xi(A.isHTMLForm(r)?new FormData(r):r),Re.getAdapter=fo.getAdapter,Re.HttpStatusCode=xr,Re.default=Re;const{Axios:rc,AxiosError:ic,CanceledError:oc,isCancel:sc,CancelToken:ac,VERSION:uc,all:cc,Cancel:lc,isAxiosError:fc,spread:dc,toFormData:hc,AxiosHeaders:pc,HttpStatusCode:mc,formToJSON:yc,getAdapter:vc,mergeConfig:gc}=Re;class vo{constructor(o){si(this,"storage");this.storage=o}getRaw(o,u=null){return this.storage.getItem(o)??u}setRaw(o,u){this.storage.setItem(o,u)}get(o,u=null){const a=this.getRaw(o);return a?bn.parse(a):u}set(o,u){this.setRaw(o,bn.stringify(u))}del(o){this.storage.removeItem(o)}clear(){this.storage.clear()}}const Sr=new vo(localStorage),go=new vo(sessionStorage),ru=Object.freeze(Object.defineProperty({__proto__:null,default:{local:Sr,session:go},local:Sr,session:go},Symbol.toStringTag,{value:"Module"})),bo="access_token",wo=(r,o="请求异常.")=>r.message??r.msg??o,Yt=Re.create({baseURL:"",timeout:3e3,headers:{"Content-Type":"application/json"}}),iu=()=>Yt.interceptors.request.use(r=>{const o=Sr.get(bo);return o&&(r.headers.Authorization=`Bearer ${o}`),r}),ou=r=>Yt.interceptors.response.use(o=>{const u=o.data;if(o.status===200)return u.data;const a=new Error(wo(u));return r?r(a):Promise.reject(a)},o=>r?r(o):Promise.reject(o));let Pn=!1,Dn=[];const su=(r,o,u)=>{const{response:a}=r;return a.config.url==o?(Pn=!1,Dn=[],Promise.reject(r)):(Pn||(Pn=!0,u().then(()=>Dn.forEach(l=>l())).finally(()=>{Pn=!1,Dn=[]})),new Promise(l=>{Dn.push(()=>l(Yt(a.config)))}))},_o=(r,o)=>Ht({url:r,method:"GET",params:o}),xo=(r,o)=>Ht({url:r,method:"POST",data:o}),So=r=>(r.responseType??(r.responseType="blob"),Ht(r)),Ht=r=>Yt.request(r),au=Object.freeze(Object.defineProperty({__proto__:null,ACCESS_TOKEN:bo,axios:Yt,default:{get:_o,post:xo,download:So,request:Ht},download:So,get:_o,message:wo,post:xo,request:Ht,responseInterceptor:ou,retry:su,tokenRequestInterceptor:iu},Symbol.toStringTag,{value:"Module"})),Or=()=>{const r=decodeURIComponent(location.search);return new URLSearchParams(r)},Oo=()=>{let r={};for(let[o,u]of Or().entries())r[o]=u;return r},Eo=(r,o,u)=>{o??(o="_blank"),window.open(r,o,u)},uu=Object.freeze(Object.defineProperty({__proto__:null,all:Oo,default:{search:Or,all:Oo,open:Eo},open:Eo,search:Or},Symbol.toStringTag,{value:"Module"}));De.date=_s,De.db=Es,De.fast=ks,De.file=Ts,De.hash=Cs,De.http=au,De.json=Ds,De.storage=ru,De.url=uu,Object.defineProperty(De,Symbol.toStringTag,{value:"Module"})});
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rainte/js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -10,9 +10,14 @@
|
|
|
10
10
|
"module": "./dist/index.js",
|
|
11
11
|
"types": "./dist/types/lib/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/types/lib/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.umd.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./type": {
|
|
19
|
+
"types": "./index.d.ts"
|
|
20
|
+
}
|
|
16
21
|
},
|
|
17
22
|
"scripts": {
|
|
18
23
|
"dev": "vite",
|