Warp/node_modules/@vueuse/integrations/useAxios.iife.min.js

2 lines
3.2 KiB
JavaScript
Raw Normal View History

2024-01-05 12:14:38 +00:00
var VueDemi=function(e,n,u){if(e.install)return e;if(!n)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),e;if(n.version.slice(0,4)==="2.7."){let t=function(i,o){var l,v={},d={config:n.config,use:n.use.bind(n),mixin:n.mixin.bind(n),component:n.component.bind(n),provide:function(c,f){return v[c]=f,this},directive:function(c,f){return f?(n.directive(c,f),d):n.directive(c)},mount:function(c,f){return l||(l=new n(Object.assign({propsData:o},i,{provide:Object.assign(v,i.provide)})),l.$mount(c,f),l)},unmount:function(){l&&(l.$destroy(),l=void 0)}};return d};var R=t;for(var r in n)e[r]=n[r];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=n,e.Vue2=n,e.version=n.version,e.warn=n.util.warn,e.hasInjectionContext=()=>!!e.getCurrentInstance(),e.createApp=t}else if(n.version.slice(0,2)==="2.")if(u){for(var r in u)e[r]=u[r];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=n,e.Vue2=n,e.version=n.version,e.hasInjectionContext=()=>!!e.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(n.version.slice(0,2)==="3."){for(var r in n)e[r]=n[r];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=n,e.Vue2=void 0,e.version=n.version,e.set=function(t,i,o){return Array.isArray(t)?(t.length=Math.max(t.length,i),t.splice(i,1,o),o):(t[i]=o,o)},e.del=function(t,i){if(Array.isArray(t)){t.splice(i,1);return}delete t[i]}}else console.error("[vue-demi] Vue version "+n.version+" is unsupported.");return e}(this.VueDemi=this.VueDemi||(typeof VueDemi<"u"?VueDemi:{}),this.Vue||(typeof Vue<"u"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(e,n,u,r){"use strict";function R(...t){const i=typeof t[0]=="string"?t[0]:void 0,o=typeof i=="string"?1:0;let l={},v=r,d={immediate:!!o,shallow:!0};const c=s=>!!s?.request;t.length>0+o&&(c(t[0+o])?v=t[0+o]:l=t[0+o]),t.length>1+o&&c(t[1+o])&&(v=t[1+o]),(t.length===2+o&&!c(t[1+o])||t.length===3+o)&&(d=t[t.length-1]);const{initialData:f,shallow:S,onSuccess:U=u.noop,onError:$=u.noop,immediate:q,resetOnExecute:B=!1}=d,j=n.shallowRef(),y=(S?n.shallowRef:n.ref)(f),p=n.ref(!1),b=n.ref(!1),A=n.ref(!1),h=n.shallowRef(),P=r.CancelToken.source;let C=P();const x=s=>{p.value||!b.value||(C.cancel(s),C=P(),A.value=!0,b.value=!1,p.value=!1)},T=s=>{b.value=s,p.value=!s},M=()=>{B&&(y.value=f)},_=()=>new Promise((s,w)=>{u.until(p).toBe(!0).then(()=>h.value?w(h.value):s(F))}),I={then:(...s)=>_().then(...s),catch:(...s)=>_().catch(...s)};let E=0;const k=(s=i,w={})=>{h.value=void 0;const L=typeof s=="string"?s:i??w.url;if(L===void 0)return h.value=new r.AxiosError(r.AxiosError.ERR_INVALID_URL),p.value=!0,I;M(),x(),T(!0),E+=1;const N=E;return A.value=!1,v(L,{...l,...typeof s=="object"?s:w,cancelToken:C.token}).then(a=>{if(A.value)return;j.value=a;const O=a.data;y.value=O,U(O)}).catch(a=>{h.value=a,$(a)}).finally(()=>{var a;(a=d.onFinish)==null||a.call(d),N===E&&T(!1)}),I};q&&i&&k();const F={response:j,data:y,error:h,isFinished:p,isLoading:b,cancel:x,isAborted:A,isCanceled:A,abort:x,execute:k};return{...F,...I}}e.useAxios=R})(this.VueUse=this.VueUse||{},VueDemi,VueUse,axios);