vue3-request 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),b=e=>e,V=e=>e==null;function A(e){return V(e)?e:typeof e=="number"&&!isNaN(e)}function w(e,t){return A(e)===void 0?{is:!1,value:0}:A(e)?t&&e===-1?{is:!0,value:-1}:{is:!0,value:e===0||e&&e<0?0:e}:{is:!1,value:0}}const M=(e,t)=>{let n=t;for(let s=e.length;s-- >0;){const r=e[s];n=r(n)}return n?.()},C=()=>new Promise(()=>{}),O=e=>e instanceof Function,R=new Map,L=(e,t,{data:n,params:s,time:r})=>{let u;const a=x(e),{is:o,value:l}=w(t,!0);o&&(a?.timer&&window.clearTimeout(a?.timer),l!==-1&&(u=window.setTimeout(()=>{T(e)},l)),R.set(e,{data:n,params:s,time:r,timer:u}))},x=e=>R.get(e),T=e=>{e&&typeof e=="string"?R.delete(e):R.clear()};class j{constructor(t,n){this.service=t,this.options=n,this.state=i.reactive({data:void 0,error:void 0,params:n?.defaultParams||[],loading:!1,isFinished:!1,isAborted:!1,signal:new AbortController().signal})}currentRequestId=0;pluginImpls=[];state;abort=()=>{};setState=t=>{Object.assign(this.state,t)};executePlugin=(t,...n)=>{if(t==="onRequest")return{servicePromise:M(this.pluginImpls.map(r=>r.onRequest).filter(Boolean),n[0])};{const s=this.pluginImpls.map(r=>r[t]?.(...n)).filter(Boolean);return Object.assign({},...s)}};loading=t=>{this.setState({loading:t,isFinished:!t})};onFinished=()=>{this.executePlugin("onFinally",this.state.params,this.state.data,this.state.error),this.loading(!1),this.options.onFinally?.(this.state.params,this.state.data,this.state.error)};runAsync=async(...t)=>{const n=++this.currentRequestId,{isReturn:s,isReady:r,...u}=this.executePlugin("onBefore",t);if(!r)return C();if(this.setState({params:t}),this.loading(!0),s)return this.loading(u.loading||!1),u.data;this.options.onBefore?.(t);try{const a=()=>this.service(...t);let{servicePromise:o}=this.executePlugin("onRequest",a);o||(o=a());const l=await o;return n!==this.currentRequestId?C():(this.setState({data:l,error:void 0}),this.executePlugin("onSuccess",l,t),this.options.onSuccess?.(l,t),this.onFinished(),l)}catch(a){if(n!==this.currentRequestId)return C();const o=a;throw this.setState({data:void 0,error:o}),this.executePlugin("onError",o,t),this.options.onError?.(o,t),this.onFinished(),o}};run=(...t)=>{this.runAsync(...t).catch(n=>{this.options.onError})};refresh=()=>{this.run(...this.state.params)};refreshAsync=async()=>await this.runAsync(...this.state.params);mutate=t=>{O(t)?t(this.state.data):this.setState({data:t}),this.executePlugin("onMutate",this.state.data)};cancel=()=>{this.executePlugin("onCancel"),this.currentRequestId++,this.loading(!1)}}function N(e,t,n){const s={manual:!1,...t},r=new j(e,s);r.pluginImpls=n.map(g=>g(r,s)),i.onMounted(()=>{if(!s.manual){const g=r.state.params;r.run(...g)}}),i.onUnmounted(r.cancel);const{run:u,cancel:a,refresh:o,runAsync:l,refreshAsync:v,abort:f,mutate:h}=r;return{...i.toRefs(r.state),run:u,cancel:a,refresh:o,runAsync:l,mutate:h,abort:f,refreshAsync:v,clearCache:T}}const U=b((e,{abortPrevious:t=!0})=>{let n=null;const s=()=>{n=new AbortController,e.setState({signal:n.signal,isAborted:n.signal.aborted})};return e.abort=()=>{n&&!n.signal.aborted&&!e.state.isFinished&&(n.abort(),e.setState({isAborted:n.signal.aborted}))},{onBefore:()=>{typeof t=="boolean"&&t&&e.abort(),s()},onRequest:r=>()=>r(),onCancel:()=>{e.abort(),n=null}}}),p=new Map,D=(e,{data:t,params:n,time:s})=>{p.has(e)&&p.get(e)?.forEach(u=>u({data:t,params:n,time:s}))},E=(e,t)=>(p.has(e)?p.get(e)?.add(t):p.set(e,new Set),()=>{const n=p.get(e);n?.delete(t),n?.size===0&&p.delete(e)}),P=new Map,W=(e,t)=>{P.set(e,t),t.then(n=>{}).catch(()=>{}).finally(()=>{_(e)})},H=e=>P.get(e),_=e=>{e&&typeof e=="string"?P.delete(e):P.clear()},$=b((e,{cacheKey:t,cacheTime:n=3e5,staleTime:s=0,setCache:r,getCache:u})=>{const a=i.ref(null);let o=null;const{is:l,value:v}=w(s,!0);if(!l)return{};const f=(c,d)=>{r?r(c,d):L(c,n,d),D(c,d)},h=c=>u?u(c):x(c);function g(){if(!t)return;const c=h(t);c&&Reflect.has(c,"data")&&e.setState({data:c.data,params:c.params}),a.value=E(t,d=>{e.setState({data:d.data})})}return g(),i.onUnmounted(()=>{a.value?.()}),{onBefore:()=>{if(!t)return null;const c=h(t);return!c||!Reflect.has(c,"data")?{}:v===-1||Date.now()-c.time<v?{loading:!1,data:c.data,error:void 0,isReturn:!0}:{data:c.data,error:void 0}},onRequest:c=>{if(!t)return c;let d=H(t);return d&&d!==o?()=>d:(d=c(),o=d,W(t,d),()=>d)},onSuccess:(c,d)=>{if(!t)return;const m={data:c,params:d,time:Date.now()};a.value?.(),f(t,m),a.value=E(t,B=>{e.setState({data:B.data})})}}}),z=b((e,{errorRetryCount:t=0,errorRetryInterval:n})=>{const s=i.ref(),r=i.ref(0),u=i.ref(!1),a=i.computed(()=>1e3*Math.pow(2,r.value)),o=()=>{let f=null;r.value++;const{value:h}=w(i.toValue(t),!0),g=h===-1,c=r.value<=h;if(g||c){let{is:d,value:m}=w(i.toValue(n));d||(m=i.toValue(Math.min(a.value,3e4))),f=window.setTimeout(()=>{u.value=!0,e.refresh()},m)}return()=>{f&&window.clearTimeout(f)}},l=()=>{s.value?.()},{is:v}=w(i.toValue(t),!0);return v?{onBefore:()=>{u.value||(r.value=0),u.value=!1,l()},onSuccess:()=>{r.value=0},onError:()=>{s.value=o()},onCancel:()=>{r.value=0,l()}}:{}}),y=()=>document.visibilityState==="visible",F=new Set,I=e=>(F.add(e),()=>{F.delete(e)}),J=()=>{y()&&F.forEach(e=>{e()})};window.addEventListener("visibilitychange",J,!1);const Q=b((e,{pollingInterval:t,pollingWhenHidden:n=!0,errorRetryCount:s})=>{const r=i.ref(null),u=i.ref(),a=()=>{let o;const{value:l}=w(i.toValue(s),!0);if(e.state.error&&l!==0)return;const{is:v,value:f}=w(i.toValue(t));if(!v)return;const h=f;return o=window.setTimeout(()=>{!i.toValue(n)&&!y()?r.value=I(e.refresh):e.refresh()},h),()=>{o&&window.clearTimeout(o),r.value?.()}};return i.watch([()=>i.toValue(t),()=>i.toValue(n)],()=>{u.value?.(),u.value=a()}),i.onUnmounted(()=>{r.value?.()}),{onBefore:()=>{u.value?.()},onCancel:()=>{u.value?.()},onFinally:()=>{u.value=a()}}}),X=b((e,{manual:t,refreshDeps:n,refreshDepsAction:s})=>{if(V(n)||typeof n!="object"&&typeof n!="function")return{};const r=i.watch(n,()=>{t||(s?s():e.refresh())},{deep:!0});return{onCancel:()=>{r()}}}),Y=()=>window.navigator.onLine,S=new Set,Z=e=>(S.add(e),()=>{S.delete(e)}),q=()=>{!y()||!Y()||S.forEach(e=>{e()})};window.addEventListener("visibilitychange",q,!1);window.addEventListener("focus",q,!1);const G=b((e,{refocusTimespan:t=5e3,refreshOnWindowFocus:n=!1})=>{const s=i.ref(),{is:r}=w(i.toValue(t));if(!r||V(i.toValue(n))||typeof i.toValue(n)!="boolean")return{};const u=(a,o)=>{let l=!1;return()=>{l||(l=!0,a(),window.setTimeout(()=>{l=!1},o))}};return i.watchEffect(()=>{s.value?.(),i.toValue(n)&&(s.value=Z(u(e.refresh,i.toValue(t))))}),i.onUnmounted(()=>{s.value?.()}),{}}),k=b((e,{manual:t,ready:n=!0,defaultParams:s=[]})=>{const r=i.watch(()=>i.toValue(n),u=>{!t&&u&&e.run(...s)},{flush:"sync"});return{onBefore:()=>({isReady:i.toValue(n)}),onCancel:()=>{r()}}});function K(e,t,n){var s=null,r=null,u=typeof n=="boolean"?{leading:n,trailing:!n}:Object.assign({leading:!1,trailing:!0},n),a=!1,o=null,l=u.leading,v=u.trailing,f=function(){s=null,r=null},h=function(){a=!0,e.apply(r,s),f()},g=function(){if(l===!0&&(o=null),a){f();return}if(v===!0){h();return}f()},c=function(){var m=o!==null;return m&&clearTimeout(o),f(),o=null,a=!1,m},d=function(){a=!1,s=arguments,r=this,o===null?l===!0&&h():clearTimeout(o),o=setTimeout(g,t)};return d.cancel=c,d}const ee=b((e,{debounceWait:t,debounceOptions:n,manual:s})=>{const r=i.ref(!1);let u=null;const a=e.runAsync;return s||(r.value=!0),i.watchEffect(()=>{const{is:o,value:l}=w(i.toValue(t));if(!o)return;const v=i.toValue(n);u=K(f=>f(),l,v),e.runAsync=(...f)=>new Promise((h,g)=>{r.value?(r.value=!1,a(...f).then(h).catch(g)):u(()=>{a(...f).then(h).catch(g)})}),i.onWatcherCleanup(()=>{u?.cancel(),e.runAsync=a})}),{onCancel:()=>{u?.cancel()}}});function te(e,t,n){var s=null,r=null,u=!1,a=null,o=Object.assign({leading:!0,trailing:!0},n),l=o.leading,v=o.trailing,f=function(){s=null,r=null},h=function(){u=!0,e.apply(r,s),a=setTimeout(g,t),f()},g=function(){if(a=null,u){f();return}if(v===!0){h();return}f()},c=function(){var m=a!==null;return m&&clearTimeout(a),f(),a=null,u=!1,m},d=function(){if(s=arguments,r=this,u=!1,a===null&&l===!0){h();return}v===!0&&(a=setTimeout(g,t))};return d.cancel=c,d}const ne=b((e,{throttleWait:t,throttleOptions:n})=>{let s=null;const r=e.runAsync;return i.watchEffect(()=>{const{is:u,value:a}=w(i.toValue(t));if(!u)return;const o=i.toValue(n);s=te(l=>l(),a,o),e.runAsync=(...l)=>new Promise((v,f)=>{s(()=>{r(...l).then(v).catch(f)})}),i.onWatcherCleanup(()=>{s?.cancel(),e.runAsync=r})}),{onCancel:()=>{s?.cancel()}}}),re=[z,Q,X,G,U,k,ee,ne,$];function se(e,t,n){return N(e,t||{},[...n||[],...re])}exports.clearCache=T;exports.definePlugin=b;exports.useRequest=se;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),p=e=>e,C=e=>e==null,S=typeof window>"u";function E(e){return C(e)?e:typeof e=="number"&&!isNaN(e)}function b(e,t){return E(e)===void 0?{is:!1,value:0}:E(e)?t&&e===-1?{is:!0,value:-1}:{is:!0,value:e===0||e&&e<0?0:e}:{is:!1,value:0}}const L=(e,t)=>{let n=t;for(let s=e.length;s-- >0;){const r=e[s];n=r(n)}return n?.()},F=()=>new Promise(()=>{}),O=e=>e instanceof Function,R=new Map,j=(e,t,{data:n,params:s,time:r})=>{let u;const a=B(e),{is:o,value:l}=b(t,!0);o&&(a?.timer&&clearTimeout(a.timer),l!==-1&&(u=setTimeout(()=>{T(e)},l)),R.set(e,{data:n,params:s,time:r,timer:u}))},B=e=>R.get(e),T=e=>{e&&typeof e=="string"?R.delete(e):R.clear()};class N{constructor(t,n){this.service=t,this.options=n,this.state=i.reactive({data:void 0,error:void 0,params:n?.defaultParams||[],loading:!1,isFinished:!1,isAborted:!1,signal:new AbortController().signal})}currentRequestId=0;pluginImpls=[];state;abort=()=>{};setState=t=>{Object.assign(this.state,t)};executePlugin=(t,...n)=>{if(t==="onRequest")return{servicePromise:L(this.pluginImpls.map(r=>r.onRequest).filter(Boolean),n[0])};{const s=this.pluginImpls.map(r=>r[t]?.(...n)).filter(Boolean);return Object.assign({},...s)}};loading=t=>{this.setState({loading:t,isFinished:!t})};onFinished=()=>{this.executePlugin("onFinally",this.state.params,this.state.data,this.state.error),this.loading(!1),this.options.onFinally?.(this.state.params,this.state.data,this.state.error)};runAsync=async(...t)=>{const n=++this.currentRequestId,{isReturn:s,isReady:r,...u}=this.executePlugin("onBefore",t);if(!r)return F();if(this.setState({params:t}),this.loading(!0),s)return this.loading(u.loading||!1),u.data;this.options.onBefore?.(t);try{const a=()=>this.service(...t);let{servicePromise:o}=this.executePlugin("onRequest",a);o||(o=a());const l=await o;return n!==this.currentRequestId?F():(this.setState({data:l,error:void 0}),this.executePlugin("onSuccess",l,t),this.options.onSuccess?.(l,t),this.onFinished(),l)}catch(a){if(n!==this.currentRequestId)return F();const o=a;throw this.setState({data:void 0,error:o}),this.executePlugin("onError",o,t),this.options.onError?.(o,t),this.onFinished(),o}};run=(...t)=>{this.runAsync(...t).catch(n=>{this.options.onError})};refresh=()=>{this.run(...this.state.params)};refreshAsync=async()=>await this.runAsync(...this.state.params);mutate=t=>{O(t)?t(this.state.data):this.setState({data:t}),this.executePlugin("onMutate",this.state.data)};cancel=()=>{this.executePlugin("onCancel"),this.currentRequestId++,this.loading(!1)}}function U(e,t,n){const s={manual:!1,...t},r=new N(e,s);r.pluginImpls=n.map(g=>g(r,s)),i.onMounted(()=>{if(!s.manual){const g=r.state.params;r.run(...g)}}),i.onUnmounted(r.cancel);const{run:u,cancel:a,refresh:o,runAsync:l,refreshAsync:v,abort:f,mutate:h}=r;return{...i.toRefs(r.state),run:u,cancel:a,refresh:o,runAsync:l,mutate:h,abort:f,refreshAsync:v,clearCache:T}}const D=p((e,{abortPrevious:t=!0})=>{let n=null;const s=()=>{n=new AbortController,e.setState({signal:n.signal,isAborted:n.signal.aborted})};return e.abort=()=>{n&&!n.signal.aborted&&!e.state.isFinished&&(n.abort(),e.setState({isAborted:n.signal.aborted}))},{onBefore:()=>{typeof t=="boolean"&&t&&e.abort(),s()},onRequest:r=>()=>r(),onCancel:()=>{e.abort(),n=null}}}),w=new Map,W=(e,{data:t,params:n,time:s})=>{w.has(e)&&w.get(e)?.forEach(u=>u({data:t,params:n,time:s}))},x=(e,t)=>(w.has(e)?w.get(e)?.add(t):w.set(e,new Set),()=>{const n=w.get(e);n?.delete(t),n?.size===0&&w.delete(e)}),P=new Map,H=(e,t)=>{P.set(e,t),t.then(n=>{}).catch(()=>{}).finally(()=>{$(e)})},_=e=>P.get(e),$=e=>{e&&typeof e=="string"?P.delete(e):P.clear()},z=p((e,{cacheKey:t,cacheTime:n=3e5,staleTime:s=0,setCache:r,getCache:u})=>{const a=i.ref(null);let o=null;const{is:l,value:v}=b(s,!0);if(!l)return{};const f=(c,d)=>{r?r(c,d):j(c,n,d),W(c,d)},h=c=>u?u(c):B(c);function g(){if(!t)return;const c=h(t);c&&Reflect.has(c,"data")&&e.setState({data:c.data,params:c.params}),a.value=x(t,d=>{e.setState({data:d.data})})}return g(),i.onUnmounted(()=>{a.value?.()}),{onBefore:()=>{if(!t)return null;const c=h(t);return!c||!Reflect.has(c,"data")?{}:v===-1||Date.now()-c.time<v?{loading:!1,data:c.data,error:void 0,isReturn:!0}:{data:c.data,error:void 0}},onRequest:c=>{if(!t)return c;let d=_(t);return d&&d!==o?()=>d:(d=c(),o=d,H(t,d),()=>d)},onSuccess:(c,d)=>{if(!t)return;const m={data:c,params:d,time:Date.now()};a.value?.(),f(t,m),a.value=x(t,M=>{e.setState({data:M.data})})}}}),I=p((e,{errorRetryCount:t=0,errorRetryInterval:n})=>{const s=i.ref(),r=i.ref(0),u=i.ref(!1),a=i.computed(()=>1e3*Math.pow(2,r.value)),o=()=>{let f=null;r.value++;const{value:h}=b(i.toValue(t),!0),g=h===-1,c=r.value<=h;if(g||c){let{is:d,value:m}=b(i.toValue(n));d||(m=i.toValue(Math.min(a.value,3e4))),f=setTimeout(()=>{u.value=!0,e.refresh()},m)}return()=>{f&&clearTimeout(f)}},l=()=>{s.value?.()},{is:v}=b(i.toValue(t),!0);return v?{onBefore:()=>{u.value||(r.value=0),u.value=!1,l()},onSuccess:()=>{r.value=0},onError:()=>{s.value=o()},onCancel:()=>{r.value=0,l()}}:{}}),A=()=>S||C(window.document?.visibilityState)?!0:document.visibilityState==="visible",V=new Set,J=e=>(V.add(e),()=>{V.delete(e)}),Q=()=>{A()&&V.forEach(e=>{e()})};!S&&window?.addEventListener&&window.addEventListener("visibilitychange",Q,!1);const X=p((e,{pollingInterval:t,pollingWhenHidden:n=!0,errorRetryCount:s})=>{const r=i.ref(null),u=i.ref(),a=()=>{let o;const{value:l}=b(i.toValue(s),!0);if(e.state.error&&l!==0)return;const{is:v,value:f}=b(i.toValue(t));return v?(o=setTimeout(()=>{!i.toValue(n)&&!A()?r.value=J(e.refresh):e.refresh()},f),()=>{o&&clearTimeout(o),r.value?.()}):void 0};return i.watch([()=>i.toValue(t),()=>i.toValue(n)],()=>{u.value?.(),u.value=a()}),i.onUnmounted(()=>{r.value?.()}),{onBefore:()=>{u.value?.()},onCancel:()=>{u.value?.()},onFinally:()=>{u.value=a()}}}),Y=p((e,{manual:t,refreshDeps:n,refreshDepsAction:s})=>{if(C(n)||typeof n!="object"&&typeof n!="function")return{};const r=i.watch(n,()=>{t||(s?s():e.refresh())},{deep:!0});return{onCancel:()=>{r()}}}),Z=()=>(!S&&window.navigator?.onLine)??!0,y=new Set,G=e=>(y.add(e),()=>{y.delete(e)}),q=()=>{!A()||!Z()||y.forEach(e=>{e()})};!S&&window?.addEventListener&&(window.addEventListener("visibilitychange",q,!1),window.addEventListener("focus",q,!1));const k=p((e,{refocusTimespan:t=5e3,refreshOnWindowFocus:n=!1})=>{const s=i.ref(),{is:r}=b(i.toValue(t));if(!r||C(i.toValue(n))||typeof i.toValue(n)!="boolean")return{};const u=(a,o)=>{let l=!1;return()=>{l||(l=!0,a(),setTimeout(()=>{l=!1},o))}};return i.watchEffect(()=>{s.value?.(),i.toValue(n)&&(s.value=G(u(e.refresh,i.toValue(t))))}),i.onUnmounted(()=>{s.value?.()}),{}}),K=p((e,{manual:t,ready:n=!0,defaultParams:s=[]})=>{const r=i.watch(()=>i.toValue(n),u=>{!t&&u&&e.run(...s)},{flush:"sync"});return{onBefore:()=>({isReady:i.toValue(n)}),onCancel:()=>{r()}}});function ee(e,t,n){var s=null,r=null,u=typeof n=="boolean"?{leading:n,trailing:!n}:Object.assign({leading:!1,trailing:!0},n),a=!1,o=null,l=u.leading,v=u.trailing,f=function(){s=null,r=null},h=function(){a=!0,e.apply(r,s),f()},g=function(){if(l===!0&&(o=null),a){f();return}if(v===!0){h();return}f()},c=function(){var m=o!==null;return m&&clearTimeout(o),f(),o=null,a=!1,m},d=function(){a=!1,s=arguments,r=this,o===null?l===!0&&h():clearTimeout(o),o=setTimeout(g,t)};return d.cancel=c,d}const te=p((e,{debounceWait:t,debounceOptions:n,manual:s})=>{const r=i.ref(!1);let u=null;const a=e.runAsync;return s||(r.value=!0),i.watchEffect(()=>{const{is:o,value:l}=b(i.toValue(t));if(!o)return;const v=i.toValue(n);u=ee(f=>f(),l,v),e.runAsync=(...f)=>new Promise((h,g)=>{r.value?(r.value=!1,a(...f).then(h).catch(g)):u(()=>{a(...f).then(h).catch(g)})}),i.onWatcherCleanup(()=>{u?.cancel(),e.runAsync=a})}),{onCancel:()=>{u?.cancel()}}});function ne(e,t,n){var s=null,r=null,u=!1,a=null,o=Object.assign({leading:!0,trailing:!0},n),l=o.leading,v=o.trailing,f=function(){s=null,r=null},h=function(){u=!0,e.apply(r,s),a=setTimeout(g,t),f()},g=function(){if(a=null,u){f();return}if(v===!0){h();return}f()},c=function(){var m=a!==null;return m&&clearTimeout(a),f(),a=null,u=!1,m},d=function(){if(s=arguments,r=this,u=!1,a===null&&l===!0){h();return}v===!0&&(a=setTimeout(g,t))};return d.cancel=c,d}const re=p((e,{throttleWait:t,throttleOptions:n})=>{let s=null;const r=e.runAsync;return i.watchEffect(()=>{const{is:u,value:a}=b(i.toValue(t));if(!u)return;const o=i.toValue(n);s=ne(l=>l(),a,o),e.runAsync=(...l)=>new Promise((v,f)=>{s(()=>{r(...l).then(v).catch(f)})}),i.onWatcherCleanup(()=>{s?.cancel(),e.runAsync=r})}),{onCancel:()=>{s?.cancel()}}}),se=[I,X,Y,k,D,K,te,re,z];function ie(e,t,n){return U(e,t||{},[...n||[],...se])}exports.clearCache=T;exports.definePlugin=p;exports.useRequest=ie;
@@ -36,7 +36,7 @@ declare type CacheParamsType<D = any, P = any> = {
36
36
  params: P;
37
37
  time: number;
38
38
  } & {
39
- timer?: number;
39
+ timer?: Timeout;
40
40
  };
41
41
 
42
42
  export declare const clearCache: (cacheKey?: string) => void;
@@ -107,6 +107,8 @@ declare type ThrottleOptionsType = {
107
107
  trailing?: boolean;
108
108
  };
109
109
 
110
+ declare type Timeout = ReturnType<typeof setTimeout>;
111
+
110
112
  export declare function useRequest<D, P extends any[] = any[]>(service: ServiceType<D, P>, options?: BaseOptions<D, P>): UseRequestReturnType<D, P>;
111
113
 
112
114
  export declare function useRequest<D, P extends any[] = any[], O = {}>(service: ServiceType<D, P>, options: BaseOptions<D, P> & O, plugins: Plugin_2<D, P, O>[]): UseRequestReturnType<D, P>;
@@ -1,13 +1,13 @@
1
- import { reactive as D, onMounted as H, onUnmounted as F, toRefs as W, ref as w, computed as _, toValue as d, watch as A, watchEffect as E, onWatcherCleanup as O } from "vue";
2
- const p = (e) => e, x = (e) => e == null;
3
- function q(e) {
4
- return x(e) ? e : typeof e == "number" && !isNaN(e);
1
+ import { reactive as H, onMounted as W, onUnmounted as F, toRefs as _, ref as R, computed as $, toValue as d, watch as x, watchEffect as B, onWatcherCleanup as j } from "vue";
2
+ const p = (e) => e, S = (e) => e == null, T = typeof window > "u";
3
+ function L(e) {
4
+ return S(e) ? e : typeof e == "number" && !isNaN(e);
5
5
  }
6
6
  function b(e, t) {
7
- return q(e) === void 0 ? {
7
+ return L(e) === void 0 ? {
8
8
  is: !1,
9
9
  value: 0
10
- } : q(e) ? t && e === -1 ? {
10
+ } : L(e) ? t && e === -1 ? {
11
11
  is: !0,
12
12
  value: -1
13
13
  } : {
@@ -18,26 +18,26 @@ function b(e, t) {
18
18
  value: 0
19
19
  };
20
20
  }
21
- const $ = (e, t) => {
21
+ const z = (e, t) => {
22
22
  let n = t;
23
23
  for (let s = e.length; s-- > 0; ) {
24
24
  const r = e[s];
25
25
  n = r(n);
26
26
  }
27
27
  return n?.();
28
- }, S = () => new Promise(() => {
29
- }), z = (e) => e instanceof Function, P = /* @__PURE__ */ new Map(), I = (e, t, { data: n, params: s, time: r }) => {
28
+ }, y = () => new Promise(() => {
29
+ }), I = (e) => e instanceof Function, P = /* @__PURE__ */ new Map(), U = (e, t, { data: n, params: s, time: r }) => {
30
30
  let i;
31
- const u = L(e), { is: a, value: o } = b(t, !0);
32
- a && (u?.timer && window.clearTimeout(u?.timer), o !== -1 && (i = window.setTimeout(() => {
33
- j(e);
31
+ const u = N(e), { is: a, value: o } = b(t, !0);
32
+ a && (u?.timer && clearTimeout(u.timer), o !== -1 && (i = setTimeout(() => {
33
+ V(e);
34
34
  }, o)), P.set(e, { data: n, params: s, time: r, timer: i }));
35
- }, L = (e) => P.get(e), j = (e) => {
35
+ }, N = (e) => P.get(e), V = (e) => {
36
36
  e && typeof e == "string" ? P.delete(e) : P.clear();
37
37
  };
38
- class U {
38
+ class J {
39
39
  constructor(t, n) {
40
- this.service = t, this.options = n, this.state = D({
40
+ this.service = t, this.options = n, this.state = H({
41
41
  data: void 0,
42
42
  error: void 0,
43
43
  params: n?.defaultParams || [],
@@ -58,7 +58,7 @@ class U {
58
58
  executePlugin = (t, ...n) => {
59
59
  if (t === "onRequest")
60
60
  return {
61
- servicePromise: $(
61
+ servicePromise: z(
62
62
  this.pluginImpls.map((r) => r.onRequest).filter(Boolean),
63
63
  n[0]
64
64
  )
@@ -91,7 +91,7 @@ class U {
91
91
  t
92
92
  );
93
93
  if (!r)
94
- return S();
94
+ return y();
95
95
  if (this.setState({ params: t }), this.loading(!0), s)
96
96
  return this.loading(i.loading || !1), i.data;
97
97
  this.options.onBefore?.(t);
@@ -100,10 +100,10 @@ class U {
100
100
  let { servicePromise: a } = this.executePlugin("onRequest", u);
101
101
  a || (a = u());
102
102
  const o = await a;
103
- return n !== this.currentRequestId ? S() : (this.setState({ data: o, error: void 0 }), this.executePlugin("onSuccess", o, t), this.options.onSuccess?.(o, t), this.onFinished(), o);
103
+ return n !== this.currentRequestId ? y() : (this.setState({ data: o, error: void 0 }), this.executePlugin("onSuccess", o, t), this.options.onSuccess?.(o, t), this.onFinished(), o);
104
104
  } catch (u) {
105
105
  if (n !== this.currentRequestId)
106
- return S();
106
+ return y();
107
107
  const a = u;
108
108
  throw this.setState({ data: void 0, error: a }), this.executePlugin("onError", a, t), this.options.onError?.(a, t), this.onFinished(), a;
109
109
  }
@@ -118,39 +118,39 @@ class U {
118
118
  };
119
119
  refreshAsync = async () => await this.runAsync(...this.state.params);
120
120
  mutate = (t) => {
121
- z(t) ? t(this.state.data) : this.setState({ data: t }), this.executePlugin("onMutate", this.state.data);
121
+ I(t) ? t(this.state.data) : this.setState({ data: t }), this.executePlugin("onMutate", this.state.data);
122
122
  };
123
123
  cancel = () => {
124
124
  this.executePlugin("onCancel"), this.currentRequestId++, this.loading(!1);
125
125
  };
126
126
  }
127
- function J(e, t, n) {
127
+ function Q(e, t, n) {
128
128
  const s = {
129
129
  manual: !1,
130
130
  ...t
131
- }, r = new U(e, s);
131
+ }, r = new J(e, s);
132
132
  r.pluginImpls = n.map(
133
133
  (g) => g(r, s)
134
- ), H(() => {
134
+ ), W(() => {
135
135
  if (!s.manual) {
136
136
  const g = r.state.params;
137
137
  r.run(...g);
138
138
  }
139
139
  }), F(r.cancel);
140
- const { run: i, cancel: u, refresh: a, runAsync: o, refreshAsync: h, abort: c, mutate: v } = r;
140
+ const { run: i, cancel: u, refresh: a, runAsync: o, refreshAsync: v, abort: c, mutate: h } = r;
141
141
  return {
142
- ...W(r.state),
142
+ ..._(r.state),
143
143
  run: i,
144
144
  cancel: u,
145
145
  refresh: a,
146
146
  runAsync: o,
147
- mutate: v,
147
+ mutate: h,
148
148
  abort: c,
149
- refreshAsync: h,
150
- clearCache: j
149
+ refreshAsync: v,
150
+ clearCache: V
151
151
  };
152
152
  }
153
- const Q = p((e, { abortPrevious: t = !0 }) => {
153
+ const X = p((e, { abortPrevious: t = !0 }) => {
154
154
  let n = null;
155
155
  const s = () => {
156
156
  n = new AbortController(), e.setState({
@@ -171,20 +171,20 @@ const Q = p((e, { abortPrevious: t = !0 }) => {
171
171
  e.abort(), n = null;
172
172
  }
173
173
  };
174
- }), R = /* @__PURE__ */ new Map(), X = (e, { data: t, params: n, time: s }) => {
175
- R.has(e) && R.get(e)?.forEach((i) => i({ data: t, params: n, time: s }));
176
- }, M = (e, t) => (R.has(e) ? R.get(e)?.add(t) : R.set(e, /* @__PURE__ */ new Set()), () => {
177
- const n = R.get(e);
178
- n?.delete(t), n?.size === 0 && R.delete(e);
179
- }), C = /* @__PURE__ */ new Map(), Y = (e, t) => {
174
+ }), w = /* @__PURE__ */ new Map(), Y = (e, { data: t, params: n, time: s }) => {
175
+ w.has(e) && w.get(e)?.forEach((i) => i({ data: t, params: n, time: s }));
176
+ }, M = (e, t) => (w.has(e) ? w.get(e)?.add(t) : w.set(e, /* @__PURE__ */ new Set()), () => {
177
+ const n = w.get(e);
178
+ n?.delete(t), n?.size === 0 && w.delete(e);
179
+ }), C = /* @__PURE__ */ new Map(), Z = (e, t) => {
180
180
  C.set(e, t), t.then((n) => {
181
181
  }).catch(() => {
182
182
  }).finally(() => {
183
- G(e);
183
+ k(e);
184
184
  });
185
- }, Z = (e) => C.get(e), G = (e) => {
185
+ }, G = (e) => C.get(e), k = (e) => {
186
186
  e && typeof e == "string" ? C.delete(e) : C.clear();
187
- }, k = p(
187
+ }, K = p(
188
188
  (e, {
189
189
  cacheKey: t,
190
190
  cacheTime: n = 3e5,
@@ -192,17 +192,17 @@ const Q = p((e, { abortPrevious: t = !0 }) => {
192
192
  setCache: r,
193
193
  getCache: i
194
194
  }) => {
195
- const u = w(null);
195
+ const u = R(null);
196
196
  let a = null;
197
- const { is: o, value: h } = b(s, !0);
197
+ const { is: o, value: v } = b(s, !0);
198
198
  if (!o)
199
199
  return {};
200
200
  const c = (l, f) => {
201
- r ? r(l, f) : I(l, n, f), X(l, f);
202
- }, v = (l) => i ? i(l) : L(l);
201
+ r ? r(l, f) : U(l, n, f), Y(l, f);
202
+ }, h = (l) => i ? i(l) : N(l);
203
203
  function g() {
204
204
  if (!t) return;
205
- const l = v(t);
205
+ const l = h(t);
206
206
  l && Reflect.has(l, "data") && e.setState({
207
207
  data: l.data,
208
208
  params: l.params
@@ -217,8 +217,8 @@ const Q = p((e, { abortPrevious: t = !0 }) => {
217
217
  }), {
218
218
  onBefore: () => {
219
219
  if (!t) return null;
220
- const l = v(t);
221
- return !l || !Reflect.has(l, "data") ? {} : h === -1 || Date.now() - l.time < h ? {
220
+ const l = h(t);
221
+ return !l || !Reflect.has(l, "data") ? {} : v === -1 || Date.now() - l.time < v ? {
222
222
  loading: !1,
223
223
  data: l.data,
224
224
  error: void 0,
@@ -230,8 +230,8 @@ const Q = p((e, { abortPrevious: t = !0 }) => {
230
230
  },
231
231
  onRequest: (l) => {
232
232
  if (!t) return l;
233
- let f = Z(t);
234
- return f && f !== a ? () => f : (f = l(), a = f, Y(t, f), () => f);
233
+ let f = G(t);
234
+ return f && f !== a ? () => f : (f = l(), a = f, Z(t, f), () => f);
235
235
  },
236
236
  onSuccess: (l, f) => {
237
237
  if (!t) return;
@@ -240,34 +240,34 @@ const Q = p((e, { abortPrevious: t = !0 }) => {
240
240
  params: f,
241
241
  time: Date.now()
242
242
  };
243
- u.value?.(), c(t, m), u.value = M(t, (V) => {
243
+ u.value?.(), c(t, m), u.value = M(t, (D) => {
244
244
  e.setState({
245
- data: V.data
245
+ data: D.data
246
246
  });
247
247
  });
248
248
  }
249
249
  };
250
250
  }
251
- ), K = p((e, { errorRetryCount: t = 0, errorRetryInterval: n }) => {
252
- const s = w(), r = w(0), i = w(!1), u = _(
251
+ ), ee = p((e, { errorRetryCount: t = 0, errorRetryInterval: n }) => {
252
+ const s = R(), r = R(0), i = R(!1), u = $(
253
253
  () => 1e3 * Math.pow(2, r.value)
254
254
  ), a = () => {
255
255
  let c = null;
256
256
  r.value++;
257
- const { value: v } = b(d(t), !0), g = v === -1, l = r.value <= v;
257
+ const { value: h } = b(d(t), !0), g = h === -1, l = r.value <= h;
258
258
  if (g || l) {
259
259
  let { is: f, value: m } = b(d(n));
260
- f || (m = d(Math.min(u.value, 3e4))), c = window.setTimeout(() => {
260
+ f || (m = d(Math.min(u.value, 3e4))), c = setTimeout(() => {
261
261
  i.value = !0, e.refresh();
262
262
  }, m);
263
263
  }
264
264
  return () => {
265
- c && window.clearTimeout(c);
265
+ c && clearTimeout(c);
266
266
  };
267
267
  }, o = () => {
268
268
  s.value?.();
269
- }, { is: h } = b(d(t), !0);
270
- return h ? {
269
+ }, { is: v } = b(d(t), !0);
270
+ return v ? {
271
271
  onBefore: () => {
272
272
  i.value || (r.value = 0), i.value = !1, o();
273
273
  },
@@ -281,56 +281,56 @@ const Q = p((e, { abortPrevious: t = !0 }) => {
281
281
  r.value = 0, o();
282
282
  }
283
283
  } : {};
284
- }), B = () => document.visibilityState === "visible", T = /* @__PURE__ */ new Set(), ee = (e) => (T.add(e), () => {
285
- T.delete(e);
286
- }), te = () => {
287
- B() && T.forEach((e) => {
284
+ }), q = () => T || S(window.document?.visibilityState) ? !0 : document.visibilityState === "visible", A = /* @__PURE__ */ new Set(), te = (e) => (A.add(e), () => {
285
+ A.delete(e);
286
+ }), ne = () => {
287
+ q() && A.forEach((e) => {
288
288
  e();
289
289
  });
290
290
  };
291
- window.addEventListener("visibilitychange", te, !1);
292
- const ne = p((e, { pollingInterval: t, pollingWhenHidden: n = !0, errorRetryCount: s }) => {
293
- const r = w(null), i = w(), u = () => {
294
- let a;
295
- const { value: o } = b(
296
- d(s),
297
- !0
298
- );
299
- if (e.state.error && o !== 0) return;
300
- const { is: h, value: c } = b(
301
- d(t)
302
- );
303
- if (!h) return;
304
- const v = c;
305
- return a = window.setTimeout(() => {
306
- !d(n) && !B() ? r.value = ee(e.refresh) : e.refresh();
307
- }, v), () => {
308
- a && window.clearTimeout(a), r.value?.();
291
+ !T && window?.addEventListener && window.addEventListener("visibilitychange", ne, !1);
292
+ const re = p(
293
+ (e, { pollingInterval: t, pollingWhenHidden: n = !0, errorRetryCount: s }) => {
294
+ const r = R(null), i = R(), u = () => {
295
+ let a;
296
+ const { value: o } = b(
297
+ d(s),
298
+ !0
299
+ );
300
+ if (e.state.error && o !== 0) return;
301
+ const { is: v, value: c } = b(
302
+ d(t)
303
+ );
304
+ return v ? (a = setTimeout(() => {
305
+ !d(n) && !q() ? r.value = te(e.refresh) : e.refresh();
306
+ }, c), () => {
307
+ a && clearTimeout(a), r.value?.();
308
+ }) : void 0;
309
309
  };
310
- };
311
- return A(
312
- [() => d(t), () => d(n)],
313
- () => {
314
- i.value?.(), i.value = u();
315
- }
316
- ), F(() => {
317
- r.value?.();
318
- }), {
319
- onBefore: () => {
320
- i.value?.();
321
- },
322
- onCancel: () => {
323
- i.value?.();
324
- },
325
- onFinally: () => {
326
- i.value = u();
327
- }
328
- };
329
- }), re = p(
310
+ return x(
311
+ [() => d(t), () => d(n)],
312
+ () => {
313
+ i.value?.(), i.value = u();
314
+ }
315
+ ), F(() => {
316
+ r.value?.();
317
+ }), {
318
+ onBefore: () => {
319
+ i.value?.();
320
+ },
321
+ onCancel: () => {
322
+ i.value?.();
323
+ },
324
+ onFinally: () => {
325
+ i.value = u();
326
+ }
327
+ };
328
+ }
329
+ ), se = p(
330
330
  (e, { manual: t, refreshDeps: n, refreshDepsAction: s }) => {
331
- if (x(n) || typeof n != "object" && typeof n != "function")
331
+ if (S(n) || typeof n != "object" && typeof n != "function")
332
332
  return {};
333
- const r = A(
333
+ const r = x(
334
334
  n,
335
335
  () => {
336
336
  t || (s ? s() : e.refresh());
@@ -345,39 +345,38 @@ const ne = p((e, { pollingInterval: t, pollingWhenHidden: n = !0, errorRetryCoun
345
345
  }
346
346
  };
347
347
  }
348
- ), se = () => window.navigator.onLine, y = /* @__PURE__ */ new Set(), ie = (e) => (y.add(e), () => {
349
- y.delete(e);
350
- }), N = () => {
351
- !B() || !se() || y.forEach((e) => {
348
+ ), ie = () => (!T && window.navigator?.onLine) ?? !0, E = /* @__PURE__ */ new Set(), ue = (e) => (E.add(e), () => {
349
+ E.delete(e);
350
+ }), O = () => {
351
+ !q() || !ie() || E.forEach((e) => {
352
352
  e();
353
353
  });
354
354
  };
355
- window.addEventListener("visibilitychange", N, !1);
356
- window.addEventListener("focus", N, !1);
357
- const ue = p(
355
+ !T && window?.addEventListener && (window.addEventListener("visibilitychange", O, !1), window.addEventListener("focus", O, !1));
356
+ const ae = p(
358
357
  (e, { refocusTimespan: t = 5e3, refreshOnWindowFocus: n = !1 }) => {
359
- const s = w(), { is: r } = b(d(t));
360
- if (!r || x(d(n)) || typeof d(n) != "boolean")
358
+ const s = R(), { is: r } = b(d(t));
359
+ if (!r || S(d(n)) || typeof d(n) != "boolean")
361
360
  return {};
362
361
  const i = (u, a) => {
363
362
  let o = !1;
364
363
  return () => {
365
- o || (o = !0, u(), window.setTimeout(() => {
364
+ o || (o = !0, u(), setTimeout(() => {
366
365
  o = !1;
367
366
  }, a));
368
367
  };
369
368
  };
370
- return E(() => {
371
- s.value?.(), d(n) && (s.value = ie(
369
+ return B(() => {
370
+ s.value?.(), d(n) && (s.value = ue(
372
371
  i(e.refresh, d(t))
373
372
  ));
374
373
  }), F(() => {
375
374
  s.value?.();
376
375
  }), {};
377
376
  }
378
- ), ae = p(
377
+ ), oe = p(
379
378
  (e, { manual: t, ready: n = !0, defaultParams: s = [] }) => {
380
- const r = A(
379
+ const r = x(
381
380
  () => d(n),
382
381
  (i) => {
383
382
  !t && i && e.run(...s);
@@ -394,18 +393,18 @@ const ue = p(
394
393
  };
395
394
  }
396
395
  );
397
- function oe(e, t, n) {
398
- var s = null, r = null, i = typeof n == "boolean" ? { leading: n, trailing: !n } : Object.assign({ leading: !1, trailing: !0 }, n), u = !1, a = null, o = i.leading, h = i.trailing, c = function() {
396
+ function le(e, t, n) {
397
+ var s = null, r = null, i = typeof n == "boolean" ? { leading: n, trailing: !n } : Object.assign({ leading: !1, trailing: !0 }, n), u = !1, a = null, o = i.leading, v = i.trailing, c = function() {
399
398
  s = null, r = null;
400
- }, v = function() {
399
+ }, h = function() {
401
400
  u = !0, e.apply(r, s), c();
402
401
  }, g = function() {
403
402
  if (o === !0 && (a = null), u) {
404
403
  c();
405
404
  return;
406
405
  }
407
- if (h === !0) {
408
- v();
406
+ if (v === !0) {
407
+ h();
409
408
  return;
410
409
  }
411
410
  c();
@@ -413,28 +412,28 @@ function oe(e, t, n) {
413
412
  var m = a !== null;
414
413
  return m && clearTimeout(a), c(), a = null, u = !1, m;
415
414
  }, f = function() {
416
- u = !1, s = arguments, r = this, a === null ? o === !0 && v() : clearTimeout(a), a = setTimeout(g, t);
415
+ u = !1, s = arguments, r = this, a === null ? o === !0 && h() : clearTimeout(a), a = setTimeout(g, t);
417
416
  };
418
417
  return f.cancel = l, f;
419
418
  }
420
- const le = p(
419
+ const ce = p(
421
420
  (e, { debounceWait: t, debounceOptions: n, manual: s }) => {
422
- const r = w(!1);
421
+ const r = R(!1);
423
422
  let i = null;
424
423
  const u = e.runAsync;
425
- return s || (r.value = !0), E(() => {
424
+ return s || (r.value = !0), B(() => {
426
425
  const { is: a, value: o } = b(d(t));
427
426
  if (!a) return;
428
- const h = d(n);
429
- i = oe(
427
+ const v = d(n);
428
+ i = le(
430
429
  (c) => c(),
431
430
  o,
432
- h
433
- ), e.runAsync = (...c) => new Promise((v, g) => {
434
- r.value ? (r.value = !1, u(...c).then(v).catch(g)) : i(() => {
435
- u(...c).then(v).catch(g);
431
+ v
432
+ ), e.runAsync = (...c) => new Promise((h, g) => {
433
+ r.value ? (r.value = !1, u(...c).then(h).catch(g)) : i(() => {
434
+ u(...c).then(h).catch(g);
436
435
  });
437
- }), O(() => {
436
+ }), j(() => {
438
437
  i?.cancel(), e.runAsync = u;
439
438
  });
440
439
  }), {
@@ -444,18 +443,18 @@ const le = p(
444
443
  };
445
444
  }
446
445
  );
447
- function ce(e, t, n) {
448
- var s = null, r = null, i = !1, u = null, a = Object.assign({ leading: !0, trailing: !0 }, n), o = a.leading, h = a.trailing, c = function() {
446
+ function fe(e, t, n) {
447
+ var s = null, r = null, i = !1, u = null, a = Object.assign({ leading: !0, trailing: !0 }, n), o = a.leading, v = a.trailing, c = function() {
449
448
  s = null, r = null;
450
- }, v = function() {
449
+ }, h = function() {
451
450
  i = !0, e.apply(r, s), u = setTimeout(g, t), c();
452
451
  }, g = function() {
453
452
  if (u = null, i) {
454
453
  c();
455
454
  return;
456
455
  }
457
- if (h === !0) {
458
- v();
456
+ if (v === !0) {
457
+ h();
459
458
  return;
460
459
  }
461
460
  c();
@@ -464,30 +463,30 @@ function ce(e, t, n) {
464
463
  return m && clearTimeout(u), c(), u = null, i = !1, m;
465
464
  }, f = function() {
466
465
  if (s = arguments, r = this, i = !1, u === null && o === !0) {
467
- v();
466
+ h();
468
467
  return;
469
468
  }
470
- h === !0 && (u = setTimeout(g, t));
469
+ v === !0 && (u = setTimeout(g, t));
471
470
  };
472
471
  return f.cancel = l, f;
473
472
  }
474
- const fe = p(
473
+ const de = p(
475
474
  (e, { throttleWait: t, throttleOptions: n }) => {
476
475
  let s = null;
477
476
  const r = e.runAsync;
478
- return E(() => {
477
+ return B(() => {
479
478
  const { is: i, value: u } = b(d(t));
480
479
  if (!i) return;
481
480
  const a = d(n);
482
- s = ce(
481
+ s = fe(
483
482
  (o) => o(),
484
483
  u,
485
484
  a
486
- ), e.runAsync = (...o) => new Promise((h, c) => {
485
+ ), e.runAsync = (...o) => new Promise((v, c) => {
487
486
  s(() => {
488
- r(...o).then(h).catch(c);
487
+ r(...o).then(v).catch(c);
489
488
  });
490
- }), O(() => {
489
+ }), j(() => {
491
490
  s?.cancel(), e.runAsync = r;
492
491
  });
493
492
  }), {
@@ -496,25 +495,25 @@ const fe = p(
496
495
  }
497
496
  };
498
497
  }
499
- ), de = [
500
- K,
501
- ne,
498
+ ), ve = [
499
+ ee,
502
500
  re,
503
- ue,
504
- Q,
501
+ se,
505
502
  ae,
506
- le,
507
- fe,
508
- k
503
+ X,
504
+ oe,
505
+ ce,
506
+ de,
507
+ K
509
508
  ];
510
- function he(e, t, n) {
511
- return J(e, t || {}, [
509
+ function ge(e, t, n) {
510
+ return Q(e, t || {}, [
512
511
  ...n || [],
513
- ...de
512
+ ...ve
514
513
  ]);
515
514
  }
516
515
  export {
517
- j as clearCache,
516
+ V as clearCache,
518
517
  p as definePlugin,
519
- he as useRequest
518
+ ge as useRequest
520
519
  };
@@ -1 +1 @@
1
- (function(b,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(b=typeof globalThis<"u"?globalThis:b||self,s(b.Vue3Request={},b.Vue))})(this,function(b,s){"use strict";const v=t=>t,V=t=>t==null;function E(t){return V(t)?t:typeof t=="number"&&!isNaN(t)}function p(t,e){return E(t)===void 0?{is:!1,value:0}:E(t)?e&&t===-1?{is:!0,value:-1}:{is:!0,value:t===0||t&&t<0?0:t}:{is:!1,value:0}}const M=(t,e)=>{let n=e;for(let i=t.length;i-- >0;){const r=t[i];n=r(n)}return n?.()},T=()=>new Promise(()=>{}),O=t=>t instanceof Function,P=new Map,j=(t,e,{data:n,params:i,time:r})=>{let a;const o=q(t),{is:l,value:u}=p(e,!0);l&&(o?.timer&&window.clearTimeout(o?.timer),u!==-1&&(a=window.setTimeout(()=>{F(t)},u)),P.set(t,{data:n,params:i,time:r,timer:a}))},q=t=>P.get(t),F=t=>{t&&typeof t=="string"?P.delete(t):P.clear()};class L{constructor(e,n){this.service=e,this.options=n,this.state=s.reactive({data:void 0,error:void 0,params:n?.defaultParams||[],loading:!1,isFinished:!1,isAborted:!1,signal:new AbortController().signal})}currentRequestId=0;pluginImpls=[];state;abort=()=>{};setState=e=>{Object.assign(this.state,e)};executePlugin=(e,...n)=>{if(e==="onRequest")return{servicePromise:M(this.pluginImpls.map(r=>r.onRequest).filter(Boolean),n[0])};{const i=this.pluginImpls.map(r=>r[e]?.(...n)).filter(Boolean);return Object.assign({},...i)}};loading=e=>{this.setState({loading:e,isFinished:!e})};onFinished=()=>{this.executePlugin("onFinally",this.state.params,this.state.data,this.state.error),this.loading(!1),this.options.onFinally?.(this.state.params,this.state.data,this.state.error)};runAsync=async(...e)=>{const n=++this.currentRequestId,{isReturn:i,isReady:r,...a}=this.executePlugin("onBefore",e);if(!r)return T();if(this.setState({params:e}),this.loading(!0),i)return this.loading(a.loading||!1),a.data;this.options.onBefore?.(e);try{const o=()=>this.service(...e);let{servicePromise:l}=this.executePlugin("onRequest",o);l||(l=o());const u=await l;return n!==this.currentRequestId?T():(this.setState({data:u,error:void 0}),this.executePlugin("onSuccess",u,e),this.options.onSuccess?.(u,e),this.onFinished(),u)}catch(o){if(n!==this.currentRequestId)return T();const l=o;throw this.setState({data:void 0,error:l}),this.executePlugin("onError",l,e),this.options.onError?.(l,e),this.onFinished(),l}};run=(...e)=>{this.runAsync(...e).catch(n=>{this.options.onError})};refresh=()=>{this.run(...this.state.params)};refreshAsync=async()=>await this.runAsync(...this.state.params);mutate=e=>{O(e)?e(this.state.data):this.setState({data:e}),this.executePlugin("onMutate",this.state.data)};cancel=()=>{this.executePlugin("onCancel"),this.currentRequestId++,this.loading(!1)}}function N(t,e,n){const i={manual:!1,...e},r=new L(t,i);r.pluginImpls=n.map(m=>m(r,i)),s.onMounted(()=>{if(!i.manual){const m=r.state.params;r.run(...m)}}),s.onUnmounted(r.cancel);const{run:a,cancel:o,refresh:l,runAsync:u,refreshAsync:g,abort:f,mutate:h}=r;return{...s.toRefs(r.state),run:a,cancel:o,refresh:l,runAsync:u,mutate:h,abort:f,refreshAsync:g,clearCache:F}}const U=v((t,{abortPrevious:e=!0})=>{let n=null;const i=()=>{n=new AbortController,t.setState({signal:n.signal,isAborted:n.signal.aborted})};return t.abort=()=>{n&&!n.signal.aborted&&!t.state.isFinished&&(n.abort(),t.setState({isAborted:n.signal.aborted}))},{onBefore:()=>{typeof e=="boolean"&&e&&t.abort(),i()},onRequest:r=>()=>r(),onCancel:()=>{t.abort(),n=null}}}),R=new Map,D=(t,{data:e,params:n,time:i})=>{R.has(t)&&R.get(t)?.forEach(a=>a({data:e,params:n,time:i}))},x=(t,e)=>(R.has(t)?R.get(t)?.add(e):R.set(t,new Set),()=>{const n=R.get(t);n?.delete(e),n?.size===0&&R.delete(t)}),C=new Map,W=(t,e)=>{C.set(t,e),e.then(n=>{}).catch(()=>{}).finally(()=>{_(t)})},H=t=>C.get(t),_=t=>{t&&typeof t=="string"?C.delete(t):C.clear()},$=v((t,{cacheKey:e,cacheTime:n=3e5,staleTime:i=0,setCache:r,getCache:a})=>{const o=s.ref(null);let l=null;const{is:u,value:g}=p(i,!0);if(!u)return{};const f=(c,d)=>{r?r(c,d):j(c,n,d),D(c,d)},h=c=>a?a(c):q(c);function m(){if(!e)return;const c=h(e);c&&Reflect.has(c,"data")&&t.setState({data:c.data,params:c.params}),o.value=x(e,d=>{t.setState({data:d.data})})}return m(),s.onUnmounted(()=>{o.value?.()}),{onBefore:()=>{if(!e)return null;const c=h(e);return!c||!Reflect.has(c,"data")?{}:g===-1||Date.now()-c.time<g?{loading:!1,data:c.data,error:void 0,isReturn:!0}:{data:c.data,error:void 0}},onRequest:c=>{if(!e)return c;let d=H(e);return d&&d!==l?()=>d:(d=c(),l=d,W(e,d),()=>d)},onSuccess:(c,d)=>{if(!e)return;const w={data:c,params:d,time:Date.now()};o.value?.(),f(e,w),o.value=x(e,it=>{t.setState({data:it.data})})}}}),z=v((t,{errorRetryCount:e=0,errorRetryInterval:n})=>{const i=s.ref(),r=s.ref(0),a=s.ref(!1),o=s.computed(()=>1e3*Math.pow(2,r.value)),l=()=>{let f=null;r.value++;const{value:h}=p(s.toValue(e),!0),m=h===-1,c=r.value<=h;if(m||c){let{is:d,value:w}=p(s.toValue(n));d||(w=s.toValue(Math.min(o.value,3e4))),f=window.setTimeout(()=>{a.value=!0,t.refresh()},w)}return()=>{f&&window.clearTimeout(f)}},u=()=>{i.value?.()},{is:g}=p(s.toValue(e),!0);return g?{onBefore:()=>{a.value||(r.value=0),a.value=!1,u()},onSuccess:()=>{r.value=0},onError:()=>{i.value=l()},onCancel:()=>{r.value=0,u()}}:{}}),S=()=>document.visibilityState==="visible",y=new Set,I=t=>(y.add(t),()=>{y.delete(t)}),J=()=>{S()&&y.forEach(t=>{t()})};window.addEventListener("visibilitychange",J,!1);const Q=v((t,{pollingInterval:e,pollingWhenHidden:n=!0,errorRetryCount:i})=>{const r=s.ref(null),a=s.ref(),o=()=>{let l;const{value:u}=p(s.toValue(i),!0);if(t.state.error&&u!==0)return;const{is:g,value:f}=p(s.toValue(e));if(!g)return;const h=f;return l=window.setTimeout(()=>{!s.toValue(n)&&!S()?r.value=I(t.refresh):t.refresh()},h),()=>{l&&window.clearTimeout(l),r.value?.()}};return s.watch([()=>s.toValue(e),()=>s.toValue(n)],()=>{a.value?.(),a.value=o()}),s.onUnmounted(()=>{r.value?.()}),{onBefore:()=>{a.value?.()},onCancel:()=>{a.value?.()},onFinally:()=>{a.value=o()}}}),X=v((t,{manual:e,refreshDeps:n,refreshDepsAction:i})=>{if(V(n)||typeof n!="object"&&typeof n!="function")return{};const r=s.watch(n,()=>{e||(i?i():t.refresh())},{deep:!0});return{onCancel:()=>{r()}}}),Y=()=>window.navigator.onLine,A=new Set,Z=t=>(A.add(t),()=>{A.delete(t)}),B=()=>{!S()||!Y()||A.forEach(t=>{t()})};window.addEventListener("visibilitychange",B,!1),window.addEventListener("focus",B,!1);const G=v((t,{refocusTimespan:e=5e3,refreshOnWindowFocus:n=!1})=>{const i=s.ref(),{is:r}=p(s.toValue(e));if(!r||V(s.toValue(n))||typeof s.toValue(n)!="boolean")return{};const a=(o,l)=>{let u=!1;return()=>{u||(u=!0,o(),window.setTimeout(()=>{u=!1},l))}};return s.watchEffect(()=>{i.value?.(),s.toValue(n)&&(i.value=Z(a(t.refresh,s.toValue(e))))}),s.onUnmounted(()=>{i.value?.()}),{}}),k=v((t,{manual:e,ready:n=!0,defaultParams:i=[]})=>{const r=s.watch(()=>s.toValue(n),a=>{!e&&a&&t.run(...i)},{flush:"sync"});return{onBefore:()=>({isReady:s.toValue(n)}),onCancel:()=>{r()}}});function K(t,e,n){var i=null,r=null,a=typeof n=="boolean"?{leading:n,trailing:!n}:Object.assign({leading:!1,trailing:!0},n),o=!1,l=null,u=a.leading,g=a.trailing,f=function(){i=null,r=null},h=function(){o=!0,t.apply(r,i),f()},m=function(){if(u===!0&&(l=null),o){f();return}if(g===!0){h();return}f()},c=function(){var w=l!==null;return w&&clearTimeout(l),f(),l=null,o=!1,w},d=function(){o=!1,i=arguments,r=this,l===null?u===!0&&h():clearTimeout(l),l=setTimeout(m,e)};return d.cancel=c,d}const tt=v((t,{debounceWait:e,debounceOptions:n,manual:i})=>{const r=s.ref(!1);let a=null;const o=t.runAsync;return i||(r.value=!0),s.watchEffect(()=>{const{is:l,value:u}=p(s.toValue(e));if(!l)return;const g=s.toValue(n);a=K(f=>f(),u,g),t.runAsync=(...f)=>new Promise((h,m)=>{r.value?(r.value=!1,o(...f).then(h).catch(m)):a(()=>{o(...f).then(h).catch(m)})}),s.onWatcherCleanup(()=>{a?.cancel(),t.runAsync=o})}),{onCancel:()=>{a?.cancel()}}});function et(t,e,n){var i=null,r=null,a=!1,o=null,l=Object.assign({leading:!0,trailing:!0},n),u=l.leading,g=l.trailing,f=function(){i=null,r=null},h=function(){a=!0,t.apply(r,i),o=setTimeout(m,e),f()},m=function(){if(o=null,a){f();return}if(g===!0){h();return}f()},c=function(){var w=o!==null;return w&&clearTimeout(o),f(),o=null,a=!1,w},d=function(){if(i=arguments,r=this,a=!1,o===null&&u===!0){h();return}g===!0&&(o=setTimeout(m,e))};return d.cancel=c,d}const nt=v((t,{throttleWait:e,throttleOptions:n})=>{let i=null;const r=t.runAsync;return s.watchEffect(()=>{const{is:a,value:o}=p(s.toValue(e));if(!a)return;const l=s.toValue(n);i=et(u=>u(),o,l),t.runAsync=(...u)=>new Promise((g,f)=>{i(()=>{r(...u).then(g).catch(f)})}),s.onWatcherCleanup(()=>{i?.cancel(),t.runAsync=r})}),{onCancel:()=>{i?.cancel()}}}),rt=[z,Q,X,G,U,k,tt,nt,$];function st(t,e,n){return N(t,e||{},[...n||[],...rt])}b.clearCache=F,b.definePlugin=v,b.useRequest=st,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
1
+ (function(w,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],i):(w=typeof globalThis<"u"?globalThis:w||self,i(w.Vue3Request={},w.Vue))})(this,function(w,i){"use strict";const v=t=>t,P=t=>t==null,C=typeof window>"u";function q(t){return P(t)?t:typeof t=="number"&&!isNaN(t)}function p(t,e){return q(t)===void 0?{is:!1,value:0}:q(t)?e&&t===-1?{is:!0,value:-1}:{is:!0,value:t===0||t&&t<0?0:t}:{is:!1,value:0}}const L=(t,e)=>{let n=e;for(let s=t.length;s-- >0;){const r=t[s];n=r(n)}return n?.()},y=()=>new Promise(()=>{}),O=t=>t instanceof Function,S=new Map,j=(t,e,{data:n,params:s,time:r})=>{let a;const o=x(t),{is:l,value:u}=p(e,!0);l&&(o?.timer&&clearTimeout(o.timer),u!==-1&&(a=setTimeout(()=>{T(t)},u)),S.set(t,{data:n,params:s,time:r,timer:a}))},x=t=>S.get(t),T=t=>{t&&typeof t=="string"?S.delete(t):S.clear()};class N{constructor(e,n){this.service=e,this.options=n,this.state=i.reactive({data:void 0,error:void 0,params:n?.defaultParams||[],loading:!1,isFinished:!1,isAborted:!1,signal:new AbortController().signal})}currentRequestId=0;pluginImpls=[];state;abort=()=>{};setState=e=>{Object.assign(this.state,e)};executePlugin=(e,...n)=>{if(e==="onRequest")return{servicePromise:L(this.pluginImpls.map(r=>r.onRequest).filter(Boolean),n[0])};{const s=this.pluginImpls.map(r=>r[e]?.(...n)).filter(Boolean);return Object.assign({},...s)}};loading=e=>{this.setState({loading:e,isFinished:!e})};onFinished=()=>{this.executePlugin("onFinally",this.state.params,this.state.data,this.state.error),this.loading(!1),this.options.onFinally?.(this.state.params,this.state.data,this.state.error)};runAsync=async(...e)=>{const n=++this.currentRequestId,{isReturn:s,isReady:r,...a}=this.executePlugin("onBefore",e);if(!r)return y();if(this.setState({params:e}),this.loading(!0),s)return this.loading(a.loading||!1),a.data;this.options.onBefore?.(e);try{const o=()=>this.service(...e);let{servicePromise:l}=this.executePlugin("onRequest",o);l||(l=o());const u=await l;return n!==this.currentRequestId?y():(this.setState({data:u,error:void 0}),this.executePlugin("onSuccess",u,e),this.options.onSuccess?.(u,e),this.onFinished(),u)}catch(o){if(n!==this.currentRequestId)return y();const l=o;throw this.setState({data:void 0,error:l}),this.executePlugin("onError",l,e),this.options.onError?.(l,e),this.onFinished(),l}};run=(...e)=>{this.runAsync(...e).catch(n=>{this.options.onError})};refresh=()=>{this.run(...this.state.params)};refreshAsync=async()=>await this.runAsync(...this.state.params);mutate=e=>{O(e)?e(this.state.data):this.setState({data:e}),this.executePlugin("onMutate",this.state.data)};cancel=()=>{this.executePlugin("onCancel"),this.currentRequestId++,this.loading(!1)}}function U(t,e,n){const s={manual:!1,...e},r=new N(t,s);r.pluginImpls=n.map(m=>m(r,s)),i.onMounted(()=>{if(!s.manual){const m=r.state.params;r.run(...m)}}),i.onUnmounted(r.cancel);const{run:a,cancel:o,refresh:l,runAsync:u,refreshAsync:h,abort:f,mutate:g}=r;return{...i.toRefs(r.state),run:a,cancel:o,refresh:l,runAsync:u,mutate:g,abort:f,refreshAsync:h,clearCache:T}}const D=v((t,{abortPrevious:e=!0})=>{let n=null;const s=()=>{n=new AbortController,t.setState({signal:n.signal,isAborted:n.signal.aborted})};return t.abort=()=>{n&&!n.signal.aborted&&!t.state.isFinished&&(n.abort(),t.setState({isAborted:n.signal.aborted}))},{onBefore:()=>{typeof e=="boolean"&&e&&t.abort(),s()},onRequest:r=>()=>r(),onCancel:()=>{t.abort(),n=null}}}),R=new Map,W=(t,{data:e,params:n,time:s})=>{R.has(t)&&R.get(t)?.forEach(a=>a({data:e,params:n,time:s}))},B=(t,e)=>(R.has(t)?R.get(t)?.add(e):R.set(t,new Set),()=>{const n=R.get(t);n?.delete(e),n?.size===0&&R.delete(t)}),V=new Map,H=(t,e)=>{V.set(t,e),e.then(n=>{}).catch(()=>{}).finally(()=>{$(t)})},_=t=>V.get(t),$=t=>{t&&typeof t=="string"?V.delete(t):V.clear()},z=v((t,{cacheKey:e,cacheTime:n=3e5,staleTime:s=0,setCache:r,getCache:a})=>{const o=i.ref(null);let l=null;const{is:u,value:h}=p(s,!0);if(!u)return{};const f=(c,d)=>{r?r(c,d):j(c,n,d),W(c,d)},g=c=>a?a(c):x(c);function m(){if(!e)return;const c=g(e);c&&Reflect.has(c,"data")&&t.setState({data:c.data,params:c.params}),o.value=B(e,d=>{t.setState({data:d.data})})}return m(),i.onUnmounted(()=>{o.value?.()}),{onBefore:()=>{if(!e)return null;const c=g(e);return!c||!Reflect.has(c,"data")?{}:h===-1||Date.now()-c.time<h?{loading:!1,data:c.data,error:void 0,isReturn:!0}:{data:c.data,error:void 0}},onRequest:c=>{if(!e)return c;let d=_(e);return d&&d!==l?()=>d:(d=c(),l=d,H(e,d),()=>d)},onSuccess:(c,d)=>{if(!e)return;const b={data:c,params:d,time:Date.now()};o.value?.(),f(e,b),o.value=B(e,at=>{t.setState({data:at.data})})}}}),I=v((t,{errorRetryCount:e=0,errorRetryInterval:n})=>{const s=i.ref(),r=i.ref(0),a=i.ref(!1),o=i.computed(()=>1e3*Math.pow(2,r.value)),l=()=>{let f=null;r.value++;const{value:g}=p(i.toValue(e),!0),m=g===-1,c=r.value<=g;if(m||c){let{is:d,value:b}=p(i.toValue(n));d||(b=i.toValue(Math.min(o.value,3e4))),f=setTimeout(()=>{a.value=!0,t.refresh()},b)}return()=>{f&&clearTimeout(f)}},u=()=>{s.value?.()},{is:h}=p(i.toValue(e),!0);return h?{onBefore:()=>{a.value||(r.value=0),a.value=!1,u()},onSuccess:()=>{r.value=0},onError:()=>{s.value=l()},onCancel:()=>{r.value=0,u()}}:{}}),F=()=>C||P(window.document?.visibilityState)?!0:document.visibilityState==="visible",A=new Set,J=t=>(A.add(t),()=>{A.delete(t)}),Q=()=>{F()&&A.forEach(t=>{t()})};!C&&window?.addEventListener&&window.addEventListener("visibilitychange",Q,!1);const X=v((t,{pollingInterval:e,pollingWhenHidden:n=!0,errorRetryCount:s})=>{const r=i.ref(null),a=i.ref(),o=()=>{let l;const{value:u}=p(i.toValue(s),!0);if(t.state.error&&u!==0)return;const{is:h,value:f}=p(i.toValue(e));return h?(l=setTimeout(()=>{!i.toValue(n)&&!F()?r.value=J(t.refresh):t.refresh()},f),()=>{l&&clearTimeout(l),r.value?.()}):void 0};return i.watch([()=>i.toValue(e),()=>i.toValue(n)],()=>{a.value?.(),a.value=o()}),i.onUnmounted(()=>{r.value?.()}),{onBefore:()=>{a.value?.()},onCancel:()=>{a.value?.()},onFinally:()=>{a.value=o()}}}),Y=v((t,{manual:e,refreshDeps:n,refreshDepsAction:s})=>{if(P(n)||typeof n!="object"&&typeof n!="function")return{};const r=i.watch(n,()=>{e||(s?s():t.refresh())},{deep:!0});return{onCancel:()=>{r()}}}),Z=()=>(!C&&window.navigator?.onLine)??!0,E=new Set,G=t=>(E.add(t),()=>{E.delete(t)}),M=()=>{!F()||!Z()||E.forEach(t=>{t()})};!C&&window?.addEventListener&&(window.addEventListener("visibilitychange",M,!1),window.addEventListener("focus",M,!1));const k=v((t,{refocusTimespan:e=5e3,refreshOnWindowFocus:n=!1})=>{const s=i.ref(),{is:r}=p(i.toValue(e));if(!r||P(i.toValue(n))||typeof i.toValue(n)!="boolean")return{};const a=(o,l)=>{let u=!1;return()=>{u||(u=!0,o(),setTimeout(()=>{u=!1},l))}};return i.watchEffect(()=>{s.value?.(),i.toValue(n)&&(s.value=G(a(t.refresh,i.toValue(e))))}),i.onUnmounted(()=>{s.value?.()}),{}}),K=v((t,{manual:e,ready:n=!0,defaultParams:s=[]})=>{const r=i.watch(()=>i.toValue(n),a=>{!e&&a&&t.run(...s)},{flush:"sync"});return{onBefore:()=>({isReady:i.toValue(n)}),onCancel:()=>{r()}}});function tt(t,e,n){var s=null,r=null,a=typeof n=="boolean"?{leading:n,trailing:!n}:Object.assign({leading:!1,trailing:!0},n),o=!1,l=null,u=a.leading,h=a.trailing,f=function(){s=null,r=null},g=function(){o=!0,t.apply(r,s),f()},m=function(){if(u===!0&&(l=null),o){f();return}if(h===!0){g();return}f()},c=function(){var b=l!==null;return b&&clearTimeout(l),f(),l=null,o=!1,b},d=function(){o=!1,s=arguments,r=this,l===null?u===!0&&g():clearTimeout(l),l=setTimeout(m,e)};return d.cancel=c,d}const et=v((t,{debounceWait:e,debounceOptions:n,manual:s})=>{const r=i.ref(!1);let a=null;const o=t.runAsync;return s||(r.value=!0),i.watchEffect(()=>{const{is:l,value:u}=p(i.toValue(e));if(!l)return;const h=i.toValue(n);a=tt(f=>f(),u,h),t.runAsync=(...f)=>new Promise((g,m)=>{r.value?(r.value=!1,o(...f).then(g).catch(m)):a(()=>{o(...f).then(g).catch(m)})}),i.onWatcherCleanup(()=>{a?.cancel(),t.runAsync=o})}),{onCancel:()=>{a?.cancel()}}});function nt(t,e,n){var s=null,r=null,a=!1,o=null,l=Object.assign({leading:!0,trailing:!0},n),u=l.leading,h=l.trailing,f=function(){s=null,r=null},g=function(){a=!0,t.apply(r,s),o=setTimeout(m,e),f()},m=function(){if(o=null,a){f();return}if(h===!0){g();return}f()},c=function(){var b=o!==null;return b&&clearTimeout(o),f(),o=null,a=!1,b},d=function(){if(s=arguments,r=this,a=!1,o===null&&u===!0){g();return}h===!0&&(o=setTimeout(m,e))};return d.cancel=c,d}const rt=v((t,{throttleWait:e,throttleOptions:n})=>{let s=null;const r=t.runAsync;return i.watchEffect(()=>{const{is:a,value:o}=p(i.toValue(e));if(!a)return;const l=i.toValue(n);s=nt(u=>u(),o,l),t.runAsync=(...u)=>new Promise((h,f)=>{s(()=>{r(...u).then(h).catch(f)})}),i.onWatcherCleanup(()=>{s?.cancel(),t.runAsync=r})}),{onCancel:()=>{s?.cancel()}}}),it=[I,X,Y,k,D,K,et,rt,z];function st(t,e,n){return U(t,e||{},[...n||[],...it])}w.clearCache=T,w.definePlugin=v,w.useRequest=st,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-request",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "type": "module",
5
5
  "description": "A Vue3 asynchronous request processing library, designed to simplify your asynchronous operations and API calls.",
6
6
  "main": "dist/vue3-request.es.js",