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

2 lines
3.2 KiB
JavaScript
Raw Normal View History

2024-01-31 06:33:19 +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,h={},d={config:n.config,use:n.use.bind(n),mixin:n.mixin.bind(n),component:n.component.bind(n),provide:function(c,f){return h[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(h,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,l={immediate:!!o,shallow:!0};let h={},d=r,c=l;const f=s=>!!s?.request;t.length>0+o&&(f(t[0+o])?d=t[0+o]:h=t[0+o]),t.length>1+o&&f(t[1+o])&&(d=t[1+o]),(t.length===2+o&&!f(t[1+o])||t.length===3+o)&&(c=t[t.length-1]||l);const{initialData:j,shallow:U,onSuccess:$=u.noop,onError:q=u.noop,immediate:B,resetOnExecute:M=!1}=c,O=n.shallowRef(),y=(U?n.shallowRef:n.ref)(j),v=n.ref(!1),b=n.ref(!1),A=n.ref(!1),p=n.shallowRef(),P=r.CancelToken.source;let C=P();const x=s=>{v.value||!b.value||(C.cancel(s),C=P(),A.value=!0,b.value=!1,v.value=!1)},T=s=>{b.value=s,v.value=!s},N=()=>{M&&(y.value=j)},_=()=>new Promise((s,w)=>{u.until(v).toBe(!0).then(()=>p.value?w(p.value):s(F))}),I={then:(...s)=>_().then(...s),catch:(...s)=>_().catch(...s)};let E=0;const k=(s=i,w={})=>{p.value=void 0;const L=typeof s=="string"?s:i??w.url;if(L===void 0)return p.value=new r.AxiosError(r.AxiosError.ERR_INVALID_URL),v.value=!0,I;N(),x(),T(!0),E+=1;const z=E;return A.value=!1,d(L,{...h,...typeof s=="object"?s:w,cancelToken:C.token}).then(a=>{if(A.value)return;O.value=a;const S=a.data;y.value=S,$(S)}).catch(a=>{p.value=a,q(a)}).finally(()=>{var a;(a=c.onFinish)==null||a.call(c),z===E&&T(!1)}),I};B&&i&&k();const F={response:O,data:y,error:p,isFinished:v,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);