@vueuse/integrations 10.7.1 → 10.8.0

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.
Files changed (56) hide show
  1. package/index.cjs +14 -7
  2. package/index.d.cts +8 -3
  3. package/index.d.mts +8 -3
  4. package/index.d.ts +8 -3
  5. package/index.iife.js +20 -9
  6. package/index.iife.min.js +1 -1
  7. package/index.mjs +14 -7
  8. package/package.json +8 -8
  9. package/useAsyncValidator/component.d.cts +1 -1
  10. package/useAsyncValidator/component.d.mts +1 -1
  11. package/useAsyncValidator/component.d.ts +1 -1
  12. package/useAsyncValidator.iife.js +6 -2
  13. package/useAsyncValidator.iife.min.js +1 -1
  14. package/useAxios.cjs +9 -6
  15. package/useAxios.d.cts +6 -0
  16. package/useAxios.d.mts +6 -0
  17. package/useAxios.d.ts +6 -0
  18. package/useAxios.iife.js +15 -8
  19. package/useAxios.iife.min.js +1 -1
  20. package/useAxios.mjs +9 -6
  21. package/useChangeCase.iife.js +6 -2
  22. package/useChangeCase.iife.min.js +1 -1
  23. package/useCookies.iife.js +6 -2
  24. package/useCookies.iife.min.js +1 -1
  25. package/useDrauu.iife.js +6 -2
  26. package/useDrauu.iife.min.js +1 -1
  27. package/useFocusTrap/component.d.cts +1 -1
  28. package/useFocusTrap/component.d.mts +1 -1
  29. package/useFocusTrap/component.d.ts +1 -1
  30. package/useFocusTrap.iife.js +6 -2
  31. package/useFocusTrap.iife.min.js +1 -1
  32. package/useFuse.iife.js +6 -2
  33. package/useFuse.iife.min.js +1 -1
  34. package/useIDBKeyval.d.cts +1 -1
  35. package/useIDBKeyval.d.mts +1 -1
  36. package/useIDBKeyval.d.ts +1 -1
  37. package/useIDBKeyval.iife.js +6 -2
  38. package/useIDBKeyval.iife.min.js +1 -1
  39. package/useJwt.iife.js +6 -2
  40. package/useJwt.iife.min.js +1 -1
  41. package/useNProgress.iife.js +6 -2
  42. package/useNProgress.iife.min.js +1 -1
  43. package/useQRCode.iife.js +6 -2
  44. package/useQRCode.iife.min.js +1 -1
  45. package/useSortable/component.cjs +5 -1
  46. package/useSortable/component.d.cts +1 -1
  47. package/useSortable/component.d.mts +1 -1
  48. package/useSortable/component.d.ts +1 -1
  49. package/useSortable/component.mjs +5 -1
  50. package/useSortable.cjs +5 -1
  51. package/useSortable.d.cts +1 -2
  52. package/useSortable.d.mts +1 -2
  53. package/useSortable.d.ts +1 -2
  54. package/useSortable.iife.js +11 -3
  55. package/useSortable.iife.min.js +1 -1
  56. package/useSortable.mjs +5 -1
package/index.cjs CHANGED
@@ -86,12 +86,14 @@ function useAsyncValidator(value, rules, options = {}) {
86
86
  function useAxios(...args) {
87
87
  const url = typeof args[0] === "string" ? args[0] : void 0;
88
88
  const argsPlaceholder = typeof url === "string" ? 1 : 0;
89
- let defaultConfig = {};
90
- let instance = axios;
91
- let options = {
89
+ const defaultOptions = {
92
90
  immediate: !!argsPlaceholder,
93
- shallow: true
91
+ shallow: true,
92
+ abortPrevious: true
94
93
  };
94
+ let defaultConfig = {};
95
+ let instance = axios;
96
+ let options = defaultOptions;
95
97
  const isAxiosInstance = (val) => !!(val == null ? void 0 : val.request);
96
98
  if (args.length > 0 + argsPlaceholder) {
97
99
  if (isAxiosInstance(args[0 + argsPlaceholder]))
@@ -104,7 +106,7 @@ function useAxios(...args) {
104
106
  instance = args[1 + argsPlaceholder];
105
107
  }
106
108
  if (args.length === 2 + argsPlaceholder && !isAxiosInstance(args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
107
- options = args[args.length - 1];
109
+ options = args[args.length - 1] || defaultOptions;
108
110
  const {
109
111
  initialData,
110
112
  shallow,
@@ -155,7 +157,8 @@ function useAxios(...args) {
155
157
  return promise;
156
158
  }
157
159
  resetData();
158
- abort();
160
+ if (options.abortPrevious !== false)
161
+ abort();
159
162
  loading(true);
160
163
  executeCounter += 1;
161
164
  const currentExecuteCounter = executeCounter;
@@ -634,7 +637,11 @@ function useSortable(el, list, options = {}) {
634
637
  };
635
638
  core.tryOnMounted(start);
636
639
  core.tryOnScopeDispose(stop);
637
- return { stop, start, option };
640
+ return {
641
+ stop,
642
+ start,
643
+ option
644
+ };
638
645
  }
639
646
  function moveArrayElement(list, from, to) {
640
647
  const _valueIsRef = vueDemi.isRef(list);
package/index.d.cts CHANGED
@@ -121,6 +121,12 @@ interface UseAxiosOptions<T = any> {
121
121
  * @default true
122
122
  */
123
123
  shallow?: boolean;
124
+ /**
125
+ * Abort previous request when a new request is made.
126
+ *
127
+ * @default true
128
+ */
129
+ abortPrevious?: boolean;
124
130
  /**
125
131
  * Callback when error is caught.
126
132
  */
@@ -341,7 +347,7 @@ interface UseIDBOptions extends ConfigurableFlush {
341
347
  interface UseIDBKeyvalReturn<T> {
342
348
  data: RemovableRef<T>;
343
349
  isFinished: Ref<boolean>;
344
- set(value: T): Promise<void>;
350
+ set: (value: T) => Promise<void>;
345
351
  }
346
352
  /**
347
353
  *
@@ -412,8 +418,7 @@ interface UseSortableReturn {
412
418
  * @param name a Sortable.Options property.
413
419
  * @param value a value.
414
420
  */
415
- option<K extends keyof Sortable.Options>(name: K, value: Sortable.Options[K]): void;
416
- option<K extends keyof Sortable.Options>(name: K): Sortable.Options[K];
421
+ option: (<K extends keyof Sortable.Options>(name: K, value: Sortable.Options[K]) => void) & (<K extends keyof Sortable.Options>(name: K) => Sortable.Options[K]);
417
422
  }
418
423
  type UseSortableOptions = Options$3 & ConfigurableDocument;
419
424
  declare function useSortable<T>(selector: string, list: MaybeRefOrGetter$1<T[]>, options?: UseSortableOptions): UseSortableReturn;
package/index.d.mts CHANGED
@@ -121,6 +121,12 @@ interface UseAxiosOptions<T = any> {
121
121
  * @default true
122
122
  */
123
123
  shallow?: boolean;
124
+ /**
125
+ * Abort previous request when a new request is made.
126
+ *
127
+ * @default true
128
+ */
129
+ abortPrevious?: boolean;
124
130
  /**
125
131
  * Callback when error is caught.
126
132
  */
@@ -341,7 +347,7 @@ interface UseIDBOptions extends ConfigurableFlush {
341
347
  interface UseIDBKeyvalReturn<T> {
342
348
  data: RemovableRef<T>;
343
349
  isFinished: Ref<boolean>;
344
- set(value: T): Promise<void>;
350
+ set: (value: T) => Promise<void>;
345
351
  }
346
352
  /**
347
353
  *
@@ -412,8 +418,7 @@ interface UseSortableReturn {
412
418
  * @param name a Sortable.Options property.
413
419
  * @param value a value.
414
420
  */
415
- option<K extends keyof Sortable.Options>(name: K, value: Sortable.Options[K]): void;
416
- option<K extends keyof Sortable.Options>(name: K): Sortable.Options[K];
421
+ option: (<K extends keyof Sortable.Options>(name: K, value: Sortable.Options[K]) => void) & (<K extends keyof Sortable.Options>(name: K) => Sortable.Options[K]);
417
422
  }
418
423
  type UseSortableOptions = Options$3 & ConfigurableDocument;
419
424
  declare function useSortable<T>(selector: string, list: MaybeRefOrGetter$1<T[]>, options?: UseSortableOptions): UseSortableReturn;
package/index.d.ts CHANGED
@@ -121,6 +121,12 @@ interface UseAxiosOptions<T = any> {
121
121
  * @default true
122
122
  */
123
123
  shallow?: boolean;
124
+ /**
125
+ * Abort previous request when a new request is made.
126
+ *
127
+ * @default true
128
+ */
129
+ abortPrevious?: boolean;
124
130
  /**
125
131
  * Callback when error is caught.
126
132
  */
@@ -341,7 +347,7 @@ interface UseIDBOptions extends ConfigurableFlush {
341
347
  interface UseIDBKeyvalReturn<T> {
342
348
  data: RemovableRef<T>;
343
349
  isFinished: Ref<boolean>;
344
- set(value: T): Promise<void>;
350
+ set: (value: T) => Promise<void>;
345
351
  }
346
352
  /**
347
353
  *
@@ -412,8 +418,7 @@ interface UseSortableReturn {
412
418
  * @param name a Sortable.Options property.
413
419
  * @param value a value.
414
420
  */
415
- option<K extends keyof Sortable.Options>(name: K, value: Sortable.Options[K]): void;
416
- option<K extends keyof Sortable.Options>(name: K): Sortable.Options[K];
421
+ option: (<K extends keyof Sortable.Options>(name: K, value: Sortable.Options[K]) => void) & (<K extends keyof Sortable.Options>(name: K) => Sortable.Options[K]);
417
422
  }
418
423
  type UseSortableOptions = Options$3 & ConfigurableDocument;
419
424
  declare function useSortable<T>(selector: string, list: MaybeRefOrGetter$1<T[]>, options?: UseSortableOptions): UseSortableReturn;
package/index.iife.js CHANGED
@@ -19,7 +19,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
19
19
  VueDemi.Vue2 = Vue
20
20
  VueDemi.version = Vue.version
21
21
  VueDemi.warn = Vue.util.warn
22
- VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
22
+ VueDemi.hasInjectionContext = function() {
23
+ return !!VueDemi.getCurrentInstance()
24
+ }
23
25
  function createApp(rootComponent, rootProps) {
24
26
  var vm
25
27
  var provide = {}
@@ -72,7 +74,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
72
74
  VueDemi.Vue = Vue
73
75
  VueDemi.Vue2 = Vue
74
76
  VueDemi.version = Vue.version
75
- VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
77
+ VueDemi.hasInjectionContext = function() {
78
+ return !!VueDemi.getCurrentInstance()
79
+ }
76
80
  } else {
77
81
  console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
78
82
  }
@@ -187,12 +191,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
187
191
  function useAxios(...args) {
188
192
  const url = typeof args[0] === "string" ? args[0] : void 0;
189
193
  const argsPlaceholder = typeof url === "string" ? 1 : 0;
190
- let defaultConfig = {};
191
- let instance = axios;
192
- let options = {
194
+ const defaultOptions = {
193
195
  immediate: !!argsPlaceholder,
194
- shallow: true
196
+ shallow: true,
197
+ abortPrevious: true
195
198
  };
199
+ let defaultConfig = {};
200
+ let instance = axios;
201
+ let options = defaultOptions;
196
202
  const isAxiosInstance = (val) => !!(val == null ? void 0 : val.request);
197
203
  if (args.length > 0 + argsPlaceholder) {
198
204
  if (isAxiosInstance(args[0 + argsPlaceholder]))
@@ -205,7 +211,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
205
211
  instance = args[1 + argsPlaceholder];
206
212
  }
207
213
  if (args.length === 2 + argsPlaceholder && !isAxiosInstance(args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
208
- options = args[args.length - 1];
214
+ options = args[args.length - 1] || defaultOptions;
209
215
  const {
210
216
  initialData,
211
217
  shallow,
@@ -256,7 +262,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
256
262
  return promise;
257
263
  }
258
264
  resetData();
259
- abort();
265
+ if (options.abortPrevious !== false)
266
+ abort();
260
267
  loading(true);
261
268
  executeCounter += 1;
262
269
  const currentExecuteCounter = executeCounter;
@@ -735,7 +742,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
735
742
  };
736
743
  core.tryOnMounted(start);
737
744
  core.tryOnScopeDispose(stop);
738
- return { stop, start, option };
745
+ return {
746
+ stop,
747
+ start,
748
+ option
749
+ };
739
750
  }
740
751
  function moveArrayElement(list, from, to) {
741
752
  const _valueIsRef = vueDemi.isRef(list);
package/index.iife.min.js CHANGED
@@ -1 +1 @@
1
- var VueDemi=function(l,o,H){if(l.install)return l;if(!o)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),l;if(o.version.slice(0,4)==="2.7."){let h=function(b,P){var C,N={},B={config:o.config,use:o.use.bind(o),mixin:o.mixin.bind(o),component:o.component.bind(o),provide:function(E,k){return N[E]=k,this},directive:function(E,k){return k?(o.directive(E,k),B):o.directive(E)},mount:function(E,k){return C||(C=new o(Object.assign({propsData:P},b,{provide:Object.assign(N,b.provide)})),C.$mount(E,k),C)},unmount:function(){C&&(C.$destroy(),C=void 0)}};return B};var j=h;for(var n in o)l[n]=o[n];l.isVue2=!0,l.isVue3=!1,l.install=function(){},l.Vue=o,l.Vue2=o,l.version=o.version,l.warn=o.util.warn,l.hasInjectionContext=()=>!!l.getCurrentInstance(),l.createApp=h}else if(o.version.slice(0,2)==="2.")if(H){for(var n in H)l[n]=H[n];l.isVue2=!0,l.isVue3=!1,l.install=function(){},l.Vue=o,l.Vue2=o,l.version=o.version,l.hasInjectionContext=()=>!!l.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(o.version.slice(0,2)==="3."){for(var n in o)l[n]=o[n];l.isVue2=!1,l.isVue3=!0,l.install=function(){},l.Vue=o,l.Vue2=void 0,l.version=o.version,l.set=function(h,b,P){return Array.isArray(h)?(h.length=Math.max(h.length,b),h.splice(b,1,P),P):(h[b]=P,P)},l.del=function(h,b){if(Array.isArray(h)){h.splice(b,1);return}delete h[b]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");return l}(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(l,o,H,n,j,h,b,P,C,N,B,E,k,S,V,$){"use strict";const D=H.default||H;function ee(t,r,e={}){const{validateOption:a={},immediate:s=!0,manual:i=!1}=e,c=o.toRef(t),f=n.shallowRef(null),u=n.ref(!0),p=n.ref(!s||i),w=n.computed(()=>{var v;return((v=f.value)==null?void 0:v.errors)||[]}),y=n.computed(()=>{var v;return((v=f.value)==null?void 0:v.fields)||{}}),F=n.computed(()=>new D(o.toValue(r))),_=async()=>{u.value=!1,p.value=!1;try{await F.value.validate(c.value,a),p.value=!0,f.value=null}catch(v){f.value=v}finally{u.value=!0}return{pass:p.value,errorInfo:f.value,errors:w.value,errorFields:y.value}};i||n.watch([c,F],()=>_(),{immediate:s,deep:!0});const I={isFinished:u,pass:p,errors:w,errorInfo:f,errorFields:y,execute:_};function g(){return new Promise((v,R)=>{o.until(u).toBe(!0).then(()=>v(I)).catch(O=>R(O))})}return{...I,then(v,R){return g().then(v,R)}}}function te(...t){const r=typeof t[0]=="string"?t[0]:void 0,e=typeof r=="string"?1:0;let a={},s=j,i={immediate:!!e,shallow:!0};const c=A=>!!A?.request;t.length>0+e&&(c(t[0+e])?s=t[0+e]:a=t[0+e]),t.length>1+e&&c(t[1+e])&&(s=t[1+e]),(t.length===2+e&&!c(t[1+e])||t.length===3+e)&&(i=t[t.length-1]);const{initialData:f,shallow:u,onSuccess:p=o.noop,onError:w=o.noop,immediate:y,resetOnExecute:F=!1}=i,_=n.shallowRef(),I=(u?n.shallowRef:n.ref)(f),g=n.ref(!1),v=n.ref(!1),R=n.ref(!1),O=n.shallowRef(),G=j.CancelToken.source;let T=G();const U=A=>{g.value||!v.value||(T.cancel(A),T=G(),R.value=!0,v.value=!1,g.value=!1)},d=A=>{v.value=A,g.value=!A},L=()=>{F&&(I.value=f)},q=()=>new Promise((A,W)=>{o.until(g).toBe(!0).then(()=>O.value?W(O.value):A(Y))}),J={then:(...A)=>q().then(...A),catch:(...A)=>q().catch(...A)};let Q=0;const X=(A=r,W={})=>{O.value=void 0;const Z=typeof A=="string"?A:r??W.url;if(Z===void 0)return O.value=new j.AxiosError(j.AxiosError.ERR_INVALID_URL),g.value=!0,J;L(),U(),d(!0),Q+=1;const ve=Q;return R.value=!1,s(Z,{...a,...typeof A=="object"?A:W,cancelToken:T.token}).then(m=>{if(R.value)return;_.value=m;const K=m.data;I.value=K,p(K)}).catch(m=>{O.value=m,w(m)}).finally(()=>{var m;(m=i.onFinish)==null||m.call(i),ve===Q&&d(!1)}),J};y&&r&&X();const Y={response:_,data:I,error:O,isFinished:g,isLoading:v,cancel:U,isAborted:R,isCanceled:R,abort:U,execute:X};return{...Y,...J}}var x=Object.freeze({__proto__:null,camelCase:h.camelCase,capitalCase:h.capitalCase,constantCase:h.constantCase,dotCase:h.dotCase,headerCase:h.headerCase,noCase:h.noCase,paramCase:h.paramCase,pascalCase:h.pascalCase,pathCase:h.pathCase,sentenceCase:h.sentenceCase,snakeCase:h.snakeCase});function ne(t,r,e){if(typeof t=="function")return n.computed(()=>x[r](o.toValue(t),e));const a=n.ref(t);return n.computed({get(){return x[r](a.value,e)},set(s){a.value=s}})}function oe(t){const r=new b(t?t.headers.cookie:null);return(e,{doNotParse:a=!1,autoUpdateDependencies:s=!1}={})=>z(e,{doNotParse:a,autoUpdateDependencies:s},r)}function z(t,{doNotParse:r=!1,autoUpdateDependencies:e=!1}={},a=new b){const s=e?[...t||[]]:t;let i=a.getAll({doNotParse:!0});const c=n.ref(0),f=()=>{const u=a.getAll({doNotParse:!0});ae(s||null,u,i)&&c.value++,i=u};return a.addChangeListener(f),o.tryOnScopeDispose(()=>{a.removeChangeListener(f)}),{get:(...u)=>(e&&s&&!s.includes(u[0])&&s.push(u[0]),c.value,a.get(u[0],{doNotParse:r,...u[1]})),getAll:(...u)=>(c.value,a.getAll({doNotParse:r,...u[0]})),set:(...u)=>a.set(...u),remove:(...u)=>a.remove(...u),addChangeListener:(...u)=>a.addChangeListener(...u),removeChangeListener:(...u)=>a.removeChangeListener(...u)}}function ae(t,r,e){if(!t)return!0;for(const a of t)if(r[a]!==e[a])return!0;return!1}function le(t,r){const e=n.ref();let a=[];const s=C.createEventHook(),i=C.createEventHook(),c=C.createEventHook(),f=C.createEventHook(),u=C.createEventHook(),p=n.ref(!1),w=n.ref(!1),y=n.ref(!1),F=n.ref(!1),_=n.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw",...r?.brush});n.watch(_,()=>{const d=e.value;d&&(d.brush=_.value,d.mode=_.value.mode)},{deep:!0});const I=()=>{var d;return(d=e.value)==null?void 0:d.undo()},g=()=>{var d;return(d=e.value)==null?void 0:d.redo()},v=()=>{var d;return(d=e.value)==null?void 0:d.clear()},R=()=>{var d;return(d=e.value)==null?void 0:d.cancel()},O=d=>{var L;return(L=e.value)==null?void 0:L.load(d)},G=()=>{var d;return(d=e.value)==null?void 0:d.dump()},T=()=>{var d;a.forEach(L=>L()),(d=e.value)==null||d.unmount()},U=()=>{e.value&&(p.value=e.value.canUndo(),w.value=e.value.canRedo(),y.value=e.value.altPressed,F.value=e.value.shiftPressed)};return n.watch(()=>C.unrefElement(t),d=>{!d||typeof SVGSVGElement>"u"||!(d instanceof SVGSVGElement)||(e.value&&T(),e.value=P.createDrauu({el:d,...r}),U(),a=[e.value.on("canceled",()=>i.trigger()),e.value.on("committed",L=>c.trigger(L)),e.value.on("start",()=>f.trigger()),e.value.on("end",()=>u.trigger()),e.value.on("changed",()=>{U(),s.trigger()})])},{flush:"post"}),o.tryOnScopeDispose(()=>T()),{drauuInstance:e,load:O,dump:G,clear:v,cancel:R,undo:I,redo:g,canUndo:p,canRedo:w,brush:_,onChanged:s.on,onCommitted:c.on,onStart:f.on,onEnd:u.on,onCanceled:i.on}}function re(t,r={}){let e;const{immediate:a,...s}=r,i=n.ref(!1),c=n.ref(!1),f=y=>e&&e.activate(y),u=y=>e&&e.deactivate(y),p=()=>{e&&(e.pause(),c.value=!0)},w=()=>{e&&(e.unpause(),c.value=!1)};return n.watch(()=>C.unrefElement(t),y=>{y&&(e=N.createFocusTrap(y,{...s,onActivate(){i.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){i.value=!1,r.onDeactivate&&r.onDeactivate()}}),a&&f())},{flush:"post"}),C.tryOnScopeDispose(()=>u()),{hasFocus:i,isPaused:c,activate:f,deactivate:u,pause:p,unpause:w}}function se(t,r,e){const a=()=>{var c,f;return new B((c=o.toValue(r))!=null?c:[],(f=o.toValue(e))==null?void 0:f.fuseOptions)},s=n.ref(a());n.watch(()=>{var c;return(c=o.toValue(e))==null?void 0:c.fuseOptions},()=>{s.value=a()},{deep:!0}),n.watch(()=>o.toValue(r),c=>{s.value.setCollection(c)},{deep:!0});const i=n.computed(()=>{const c=o.toValue(e);if(c?.matchAllWhenSearchEmpty&&!o.toValue(t))return o.toValue(r).map((u,p)=>({item:u,refIndex:p}));const f=c?.resultLimit;return s.value.search(o.toValue(t),f?{limit:f}:void 0)});return{fuse:s,results:i}}function ue(t,r,e={}){const{flush:a="pre",deep:s=!0,shallow:i=!1,onError:c=v=>{console.error(v)},writeDefaults:f=!0}=e,u=n.ref(!1),p=(i?n.shallowRef:n.ref)(r),w=o.toValue(r);async function y(){try{const v=await E.get(t);v===void 0?w!=null&&f&&await E.set(t,w):p.value=v}catch(v){c(v)}u.value=!0}y();async function F(){try{p.value==null?await E.del(t):Array.isArray(p.value)?await E.update(t,()=>JSON.parse(JSON.stringify(p.value))):typeof p.value=="object"?await E.update(t,()=>({...p.value})):await E.update(t,()=>p.value)}catch(v){c(v)}}const{pause:_,resume:I}=C.watchPausable(p,()=>F(),{flush:a,deep:s});async function g(v){_(),p.value=v,await F(),I()}return{set:g,isFinished:u,data:p}}function ce(t,r={}){const{onError:e,fallbackValue:a=null}=r,s=(f,u)=>{try{return k(f,u)}catch(p){return e?.(p),a}},i=n.computed(()=>s(o.toValue(t),{header:!0})),c=n.computed(()=>s(o.toValue(t)));return{header:i,payload:c}}function ie(t=null,r){const e=n.ref(t),a=n.computed({set:i=>i?S.start():S.done(),get:()=>typeof e.value=="number"&&e.value<1});r&&S.configure(r);const s=S.set;return S.set=i=>(e.value=i,s.call(S,i)),n.watchEffect(()=>{typeof e.value=="number"&&o.isClient&&s.call(S,e.value)}),o.tryOnScopeDispose(S.remove),{isLoading:a,progress:e,start:S.start,done:S.done,remove:()=>{e.value=null,S.remove()}}}function fe(t,r){const e=o.toRef(t),a=n.ref("");return n.watch(e,async s=>{e.value&&o.isClient&&(a.value=await V.toDataURL(s,r))},{immediate:!0}),a}function de(t,r,e={}){let a;const{document:s=C.defaultDocument,...i}=e,c={onUpdate:w=>{M(r,w.oldIndex,w.newIndex)}},f=()=>{const w=typeof t=="string"?s?.querySelector(t):C.unrefElement(t);!w||a!==void 0||(a=new $(w,{...c,...i}))},u=()=>{a?.destroy(),a=void 0},p=(w,y)=>{if(y!==void 0)a?.option(w,y);else return a?.option(w)};return C.tryOnMounted(f),C.tryOnScopeDispose(u),{stop:u,start:f,option:p}}function M(t,r,e){const a=n.isRef(t),s=a?[...C.toValue(t)]:C.toValue(t);if(e>=0&&e<s.length){const i=s.splice(r,1)[0];n.nextTick(()=>{s.splice(e,0,i),a&&(t.value=s)})}}l.createCookies=oe,l.moveArrayElement=M,l.useAsyncValidator=ee,l.useAxios=te,l.useChangeCase=ne,l.useCookies=z,l.useDrauu=le,l.useFocusTrap=re,l.useFuse=se,l.useIDBKeyval=ue,l.useJwt=ce,l.useNProgress=ie,l.useQRCode=fe,l.useSortable=de})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,VueDemi,axios,changeCase,UniversalCookie,Drauu,VueUse,focusTrap,Fuse,idbKeyval,jwt_decode,nprogress,QRCode,Sortable);
1
+ var VueDemi=function(r,o,T){if(r.install)return r;if(!o)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),r;if(o.version.slice(0,4)==="2.7."){let h=function(E,k){var C,B={},G={config:o.config,use:o.use.bind(o),mixin:o.mixin.bind(o),component:o.component.bind(o),provide:function(b,L){return B[b]=L,this},directive:function(b,L){return L?(o.directive(b,L),G):o.directive(b)},mount:function(b,L){return C||(C=new o(Object.assign({propsData:k},E,{provide:Object.assign(B,E.provide)})),C.$mount(b,L),C)},unmount:function(){C&&(C.$destroy(),C=void 0)}};return G};var j=h;for(var n in o)r[n]=o[n];r.isVue2=!0,r.isVue3=!1,r.install=function(){},r.Vue=o,r.Vue2=o,r.version=o.version,r.warn=o.util.warn,r.hasInjectionContext=function(){return!!r.getCurrentInstance()},r.createApp=h}else if(o.version.slice(0,2)==="2.")if(T){for(var n in T)r[n]=T[n];r.isVue2=!0,r.isVue3=!1,r.install=function(){},r.Vue=o,r.Vue2=o,r.version=o.version,r.hasInjectionContext=function(){return!!r.getCurrentInstance()}}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(o.version.slice(0,2)==="3."){for(var n in o)r[n]=o[n];r.isVue2=!1,r.isVue3=!0,r.install=function(){},r.Vue=o,r.Vue2=void 0,r.version=o.version,r.set=function(h,E,k){return Array.isArray(h)?(h.length=Math.max(h.length,E),h.splice(E,1,k),k):(h[E]=k,k)},r.del=function(h,E){if(Array.isArray(h)){h.splice(E,1);return}delete h[E]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");return r}(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(r,o,T,n,j,h,E,k,C,B,G,b,L,_,V,$){"use strict";const D=T.default||T;function ee(t,l,e={}){const{validateOption:a={},immediate:s=!0,manual:f=!1}=e,c=o.toRef(t),i=n.shallowRef(null),u=n.ref(!0),p=n.ref(!s||f),w=n.computed(()=>{var d;return((d=i.value)==null?void 0:d.errors)||[]}),y=n.computed(()=>{var d;return((d=i.value)==null?void 0:d.fields)||{}}),R=n.computed(()=>new D(o.toValue(l))),g=async()=>{u.value=!1,p.value=!1;try{await R.value.validate(c.value,a),p.value=!0,i.value=null}catch(d){i.value=d}finally{u.value=!0}return{pass:p.value,errorInfo:i.value,errors:w.value,errorFields:y.value}};f||n.watch([c,R],()=>g(),{immediate:s,deep:!0});const I={isFinished:u,pass:p,errors:w,errorInfo:i,errorFields:y,execute:g};function O(){return new Promise((d,S)=>{o.until(u).toBe(!0).then(()=>d(I)).catch(F=>S(F))})}return{...I,then(d,S){return O().then(d,S)}}}function te(...t){const l=typeof t[0]=="string"?t[0]:void 0,e=typeof l=="string"?1:0,a={immediate:!!e,shallow:!0,abortPrevious:!0};let s={},f=j,c=a;const i=A=>!!A?.request;t.length>0+e&&(i(t[0+e])?f=t[0+e]:s=t[0+e]),t.length>1+e&&i(t[1+e])&&(f=t[1+e]),(t.length===2+e&&!i(t[1+e])||t.length===3+e)&&(c=t[t.length-1]||a);const{initialData:u,shallow:p,onSuccess:w=o.noop,onError:y=o.noop,immediate:R,resetOnExecute:g=!1}=c,I=n.shallowRef(),O=(p?n.shallowRef:n.ref)(u),d=n.ref(!1),S=n.ref(!1),F=n.ref(!1),m=n.shallowRef(),N=j.CancelToken.source;let U=N();const v=A=>{d.value||!S.value||(U.cancel(A),U=N(),F.value=!0,S.value=!1,d.value=!1)},P=A=>{S.value=A,d.value=!A},ve=()=>{g&&(O.value=u)},q=()=>new Promise((A,W)=>{o.until(d).toBe(!0).then(()=>m.value?W(m.value):A(Y))}),J={then:(...A)=>q().then(...A),catch:(...A)=>q().catch(...A)};let Q=0;const X=(A=l,W={})=>{m.value=void 0;const Z=typeof A=="string"?A:l??W.url;if(Z===void 0)return m.value=new j.AxiosError(j.AxiosError.ERR_INVALID_URL),d.value=!0,J;ve(),c.abortPrevious!==!1&&v(),P(!0),Q+=1;const pe=Q;return F.value=!1,f(Z,{...s,...typeof A=="object"?A:W,cancelToken:U.token}).then(H=>{if(F.value)return;I.value=H;const K=H.data;O.value=K,w(K)}).catch(H=>{m.value=H,y(H)}).finally(()=>{var H;(H=c.onFinish)==null||H.call(c),pe===Q&&P(!1)}),J};R&&l&&X();const Y={response:I,data:O,error:m,isFinished:d,isLoading:S,cancel:v,isAborted:F,isCanceled:F,abort:v,execute:X};return{...Y,...J}}var x=Object.freeze({__proto__:null,camelCase:h.camelCase,capitalCase:h.capitalCase,constantCase:h.constantCase,dotCase:h.dotCase,headerCase:h.headerCase,noCase:h.noCase,paramCase:h.paramCase,pascalCase:h.pascalCase,pathCase:h.pathCase,sentenceCase:h.sentenceCase,snakeCase:h.snakeCase});function ne(t,l,e){if(typeof t=="function")return n.computed(()=>x[l](o.toValue(t),e));const a=n.ref(t);return n.computed({get(){return x[l](a.value,e)},set(s){a.value=s}})}function oe(t){const l=new E(t?t.headers.cookie:null);return(e,{doNotParse:a=!1,autoUpdateDependencies:s=!1}={})=>z(e,{doNotParse:a,autoUpdateDependencies:s},l)}function z(t,{doNotParse:l=!1,autoUpdateDependencies:e=!1}={},a=new E){const s=e?[...t||[]]:t;let f=a.getAll({doNotParse:!0});const c=n.ref(0),i=()=>{const u=a.getAll({doNotParse:!0});ae(s||null,u,f)&&c.value++,f=u};return a.addChangeListener(i),o.tryOnScopeDispose(()=>{a.removeChangeListener(i)}),{get:(...u)=>(e&&s&&!s.includes(u[0])&&s.push(u[0]),c.value,a.get(u[0],{doNotParse:l,...u[1]})),getAll:(...u)=>(c.value,a.getAll({doNotParse:l,...u[0]})),set:(...u)=>a.set(...u),remove:(...u)=>a.remove(...u),addChangeListener:(...u)=>a.addChangeListener(...u),removeChangeListener:(...u)=>a.removeChangeListener(...u)}}function ae(t,l,e){if(!t)return!0;for(const a of t)if(l[a]!==e[a])return!0;return!1}function re(t,l){const e=n.ref();let a=[];const s=C.createEventHook(),f=C.createEventHook(),c=C.createEventHook(),i=C.createEventHook(),u=C.createEventHook(),p=n.ref(!1),w=n.ref(!1),y=n.ref(!1),R=n.ref(!1),g=n.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw",...l?.brush});n.watch(g,()=>{const v=e.value;v&&(v.brush=g.value,v.mode=g.value.mode)},{deep:!0});const I=()=>{var v;return(v=e.value)==null?void 0:v.undo()},O=()=>{var v;return(v=e.value)==null?void 0:v.redo()},d=()=>{var v;return(v=e.value)==null?void 0:v.clear()},S=()=>{var v;return(v=e.value)==null?void 0:v.cancel()},F=v=>{var P;return(P=e.value)==null?void 0:P.load(v)},m=()=>{var v;return(v=e.value)==null?void 0:v.dump()},N=()=>{var v;a.forEach(P=>P()),(v=e.value)==null||v.unmount()},U=()=>{e.value&&(p.value=e.value.canUndo(),w.value=e.value.canRedo(),y.value=e.value.altPressed,R.value=e.value.shiftPressed)};return n.watch(()=>C.unrefElement(t),v=>{!v||typeof SVGSVGElement>"u"||!(v instanceof SVGSVGElement)||(e.value&&N(),e.value=k.createDrauu({el:v,...l}),U(),a=[e.value.on("canceled",()=>f.trigger()),e.value.on("committed",P=>c.trigger(P)),e.value.on("start",()=>i.trigger()),e.value.on("end",()=>u.trigger()),e.value.on("changed",()=>{U(),s.trigger()})])},{flush:"post"}),o.tryOnScopeDispose(()=>N()),{drauuInstance:e,load:F,dump:m,clear:d,cancel:S,undo:I,redo:O,canUndo:p,canRedo:w,brush:g,onChanged:s.on,onCommitted:c.on,onStart:i.on,onEnd:u.on,onCanceled:f.on}}function le(t,l={}){let e;const{immediate:a,...s}=l,f=n.ref(!1),c=n.ref(!1),i=y=>e&&e.activate(y),u=y=>e&&e.deactivate(y),p=()=>{e&&(e.pause(),c.value=!0)},w=()=>{e&&(e.unpause(),c.value=!1)};return n.watch(()=>C.unrefElement(t),y=>{y&&(e=B.createFocusTrap(y,{...s,onActivate(){f.value=!0,l.onActivate&&l.onActivate()},onDeactivate(){f.value=!1,l.onDeactivate&&l.onDeactivate()}}),a&&i())},{flush:"post"}),C.tryOnScopeDispose(()=>u()),{hasFocus:f,isPaused:c,activate:i,deactivate:u,pause:p,unpause:w}}function se(t,l,e){const a=()=>{var c,i;return new G((c=o.toValue(l))!=null?c:[],(i=o.toValue(e))==null?void 0:i.fuseOptions)},s=n.ref(a());n.watch(()=>{var c;return(c=o.toValue(e))==null?void 0:c.fuseOptions},()=>{s.value=a()},{deep:!0}),n.watch(()=>o.toValue(l),c=>{s.value.setCollection(c)},{deep:!0});const f=n.computed(()=>{const c=o.toValue(e);if(c?.matchAllWhenSearchEmpty&&!o.toValue(t))return o.toValue(l).map((u,p)=>({item:u,refIndex:p}));const i=c?.resultLimit;return s.value.search(o.toValue(t),i?{limit:i}:void 0)});return{fuse:s,results:f}}function ue(t,l,e={}){const{flush:a="pre",deep:s=!0,shallow:f=!1,onError:c=d=>{console.error(d)},writeDefaults:i=!0}=e,u=n.ref(!1),p=(f?n.shallowRef:n.ref)(l),w=o.toValue(l);async function y(){try{const d=await b.get(t);d===void 0?w!=null&&i&&await b.set(t,w):p.value=d}catch(d){c(d)}u.value=!0}y();async function R(){try{p.value==null?await b.del(t):Array.isArray(p.value)?await b.update(t,()=>JSON.parse(JSON.stringify(p.value))):typeof p.value=="object"?await b.update(t,()=>({...p.value})):await b.update(t,()=>p.value)}catch(d){c(d)}}const{pause:g,resume:I}=C.watchPausable(p,()=>R(),{flush:a,deep:s});async function O(d){g(),p.value=d,await R(),I()}return{set:O,isFinished:u,data:p}}function ce(t,l={}){const{onError:e,fallbackValue:a=null}=l,s=(i,u)=>{try{return L(i,u)}catch(p){return e?.(p),a}},f=n.computed(()=>s(o.toValue(t),{header:!0})),c=n.computed(()=>s(o.toValue(t)));return{header:f,payload:c}}function ie(t=null,l){const e=n.ref(t),a=n.computed({set:f=>f?_.start():_.done(),get:()=>typeof e.value=="number"&&e.value<1});l&&_.configure(l);const s=_.set;return _.set=f=>(e.value=f,s.call(_,f)),n.watchEffect(()=>{typeof e.value=="number"&&o.isClient&&s.call(_,e.value)}),o.tryOnScopeDispose(_.remove),{isLoading:a,progress:e,start:_.start,done:_.done,remove:()=>{e.value=null,_.remove()}}}function fe(t,l){const e=o.toRef(t),a=n.ref("");return n.watch(e,async s=>{e.value&&o.isClient&&(a.value=await V.toDataURL(s,l))},{immediate:!0}),a}function de(t,l,e={}){let a;const{document:s=C.defaultDocument,...f}=e,c={onUpdate:w=>{M(l,w.oldIndex,w.newIndex)}},i=()=>{const w=typeof t=="string"?s?.querySelector(t):C.unrefElement(t);!w||a!==void 0||(a=new $(w,{...c,...f}))},u=()=>{a?.destroy(),a=void 0},p=(w,y)=>{if(y!==void 0)a?.option(w,y);else return a?.option(w)};return C.tryOnMounted(i),C.tryOnScopeDispose(u),{stop:u,start:i,option:p}}function M(t,l,e){const a=n.isRef(t),s=a?[...C.toValue(t)]:C.toValue(t);if(e>=0&&e<s.length){const f=s.splice(l,1)[0];n.nextTick(()=>{s.splice(e,0,f),a&&(t.value=s)})}}r.createCookies=oe,r.moveArrayElement=M,r.useAsyncValidator=ee,r.useAxios=te,r.useChangeCase=ne,r.useCookies=z,r.useDrauu=re,r.useFocusTrap=le,r.useFuse=se,r.useIDBKeyval=ue,r.useJwt=ce,r.useNProgress=ie,r.useQRCode=fe,r.useSortable=de})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,VueDemi,axios,changeCase,UniversalCookie,Drauu,VueUse,focusTrap,Fuse,idbKeyval,jwt_decode,nprogress,QRCode,Sortable);
package/index.mjs CHANGED
@@ -84,12 +84,14 @@ function useAsyncValidator(value, rules, options = {}) {
84
84
  function useAxios(...args) {
85
85
  const url = typeof args[0] === "string" ? args[0] : void 0;
86
86
  const argsPlaceholder = typeof url === "string" ? 1 : 0;
87
- let defaultConfig = {};
88
- let instance = axios;
89
- let options = {
87
+ const defaultOptions = {
90
88
  immediate: !!argsPlaceholder,
91
- shallow: true
89
+ shallow: true,
90
+ abortPrevious: true
92
91
  };
92
+ let defaultConfig = {};
93
+ let instance = axios;
94
+ let options = defaultOptions;
93
95
  const isAxiosInstance = (val) => !!(val == null ? void 0 : val.request);
94
96
  if (args.length > 0 + argsPlaceholder) {
95
97
  if (isAxiosInstance(args[0 + argsPlaceholder]))
@@ -102,7 +104,7 @@ function useAxios(...args) {
102
104
  instance = args[1 + argsPlaceholder];
103
105
  }
104
106
  if (args.length === 2 + argsPlaceholder && !isAxiosInstance(args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
105
- options = args[args.length - 1];
107
+ options = args[args.length - 1] || defaultOptions;
106
108
  const {
107
109
  initialData,
108
110
  shallow,
@@ -153,7 +155,8 @@ function useAxios(...args) {
153
155
  return promise;
154
156
  }
155
157
  resetData();
156
- abort();
158
+ if (options.abortPrevious !== false)
159
+ abort();
157
160
  loading(true);
158
161
  executeCounter += 1;
159
162
  const currentExecuteCounter = executeCounter;
@@ -632,7 +635,11 @@ function useSortable(el, list, options = {}) {
632
635
  };
633
636
  tryOnMounted(start);
634
637
  tryOnScopeDispose$1(stop);
635
- return { stop, start, option };
638
+ return {
639
+ stop,
640
+ start,
641
+ option
642
+ };
636
643
  }
637
644
  function moveArrayElement(list, from, to) {
638
645
  const _valueIsRef = isRef(list);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueuse/integrations",
3
- "version": "10.7.1",
3
+ "version": "10.8.0",
4
4
  "description": "Integration wrappers for utility libraries",
5
5
  "author": "Anthony Fu <https://github.com/antfu>",
6
6
  "license": "MIT",
@@ -145,16 +145,16 @@
145
145
  }
146
146
  },
147
147
  "dependencies": {
148
- "@vueuse/core": "10.7.1",
149
- "@vueuse/shared": "10.7.1",
150
- "vue-demi": ">=0.14.6"
148
+ "@vueuse/core": "10.8.0",
149
+ "@vueuse/shared": "10.8.0",
150
+ "vue-demi": ">=0.14.7"
151
151
  },
152
152
  "devDependencies": {
153
153
  "@types/nprogress": "^0.2.3",
154
154
  "@types/qrcode": "^1.5.5",
155
- "@types/sortablejs": "^1.15.7",
155
+ "@types/sortablejs": "^1.15.8",
156
156
  "async-validator": "^4.2.5",
157
- "axios": "^1.6.3",
157
+ "axios": "^1.6.7",
158
158
  "change-case": "^4.1.2",
159
159
  "drauu": "^0.3.7",
160
160
  "focus-trap": "^7.5.4",
@@ -163,7 +163,7 @@
163
163
  "jwt-decode": "^3.1.2",
164
164
  "nprogress": "^0.2.0",
165
165
  "qrcode": "^1.5.3",
166
- "sortablejs": "^1.15.1",
167
- "universal-cookie": "^6.1.1"
166
+ "sortablejs": "^1.15.2",
167
+ "universal-cookie": "^6.1.3"
168
168
  }
169
169
  }
@@ -13,7 +13,7 @@ declare const UseAsyncValidator: vue_demi.DefineComponent<{
13
13
  };
14
14
  }, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
15
15
  [key: string]: any;
16
- }>[] | undefined, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
16
+ }>[] | undefined, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.PublicProps, Readonly<vue_demi.ExtractPropTypes<{
17
17
  form: {
18
18
  type: PropType<Record<string, any>>;
19
19
  required: true;
@@ -13,7 +13,7 @@ declare const UseAsyncValidator: vue_demi.DefineComponent<{
13
13
  };
14
14
  }, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
15
15
  [key: string]: any;
16
- }>[] | undefined, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
16
+ }>[] | undefined, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.PublicProps, Readonly<vue_demi.ExtractPropTypes<{
17
17
  form: {
18
18
  type: PropType<Record<string, any>>;
19
19
  required: true;
@@ -13,7 +13,7 @@ declare const UseAsyncValidator: vue_demi.DefineComponent<{
13
13
  };
14
14
  }, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
15
15
  [key: string]: any;
16
- }>[] | undefined, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
16
+ }>[] | undefined, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.PublicProps, Readonly<vue_demi.ExtractPropTypes<{
17
17
  form: {
18
18
  type: PropType<Record<string, any>>;
19
19
  required: true;
@@ -19,7 +19,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
19
19
  VueDemi.Vue2 = Vue
20
20
  VueDemi.version = Vue.version
21
21
  VueDemi.warn = Vue.util.warn
22
- VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
22
+ VueDemi.hasInjectionContext = function() {
23
+ return !!VueDemi.getCurrentInstance()
24
+ }
23
25
  function createApp(rootComponent, rootProps) {
24
26
  var vm
25
27
  var provide = {}
@@ -72,7 +74,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
72
74
  VueDemi.Vue = Vue
73
75
  VueDemi.Vue2 = Vue
74
76
  VueDemi.version = Vue.version
75
- VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
77
+ VueDemi.hasInjectionContext = function() {
78
+ return !!VueDemi.getCurrentInstance()
79
+ }
76
80
  } else {
77
81
  console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
78
82
  }
@@ -1 +1 @@
1
- var VueDemi=function(n,r,f){if(n.install)return n;if(!r)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),n;if(r.version.slice(0,4)==="2.7."){let e=function(o,c){var i,v={},d={config:r.config,use:r.use.bind(r),mixin:r.mixin.bind(r),component:r.component.bind(r),provide:function(a,l){return v[a]=l,this},directive:function(a,l){return l?(r.directive(a,l),d):r.directive(a)},mount:function(a,l){return i||(i=new r(Object.assign({propsData:c},o,{provide:Object.assign(v,o.provide)})),i.$mount(a,l),i)},unmount:function(){i&&(i.$destroy(),i=void 0)}};return d};var A=e;for(var t in r)n[t]=r[t];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=r,n.Vue2=r,n.version=r.version,n.warn=r.util.warn,n.hasInjectionContext=()=>!!n.getCurrentInstance(),n.createApp=e}else if(r.version.slice(0,2)==="2.")if(f){for(var t in f)n[t]=f[t];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=r,n.Vue2=r,n.version=r.version,n.hasInjectionContext=()=>!!n.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(r.version.slice(0,2)==="3."){for(var t in r)n[t]=r[t];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=r,n.Vue2=void 0,n.version=r.version,n.set=function(e,o,c){return Array.isArray(e)?(e.length=Math.max(e.length,o),e.splice(o,1,c),c):(e[o]=c,c)},n.del=function(e,o){if(Array.isArray(e)){e.splice(o,1);return}delete e[o]}}else console.error("[vue-demi] Vue version "+r.version+" is unsupported.");return n}(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(n,r,f,t){"use strict";const A=f.default||f;function e(o,c,i={}){const{validateOption:v={},immediate:d=!0,manual:a=!1}=i,l=r.toRef(o),u=t.shallowRef(null),p=t.ref(!0),h=t.ref(!d||a),b=t.computed(()=>{var s;return((s=u.value)==null?void 0:s.errors)||[]}),w=t.computed(()=>{var s;return((s=u.value)==null?void 0:s.fields)||{}}),I=t.computed(()=>new A(r.toValue(c))),x=async()=>{p.value=!1,h.value=!1;try{await I.value.validate(l.value,v),h.value=!0,u.value=null}catch(s){u.value=s}finally{p.value=!0}return{pass:h.value,errorInfo:u.value,errors:b.value,errorFields:w.value}};a||t.watch([l,I],()=>x(),{immediate:d,deep:!0});const C={isFinished:p,pass:h,errors:b,errorInfo:u,errorFields:w,execute:x};function j(){return new Promise((s,y)=>{r.until(p).toBe(!0).then(()=>s(C)).catch(F=>y(F))})}return{...C,then(s,y){return j().then(s,y)}}}n.useAsyncValidator=e})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,VueDemi);
1
+ var VueDemi=function(n,r,u){if(n.install)return n;if(!r)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),n;if(r.version.slice(0,4)==="2.7."){let e=function(o,c){var i,v={},d={config:r.config,use:r.use.bind(r),mixin:r.mixin.bind(r),component:r.component.bind(r),provide:function(a,l){return v[a]=l,this},directive:function(a,l){return l?(r.directive(a,l),d):r.directive(a)},mount:function(a,l){return i||(i=new r(Object.assign({propsData:c},o,{provide:Object.assign(v,o.provide)})),i.$mount(a,l),i)},unmount:function(){i&&(i.$destroy(),i=void 0)}};return d};var A=e;for(var t in r)n[t]=r[t];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=r,n.Vue2=r,n.version=r.version,n.warn=r.util.warn,n.hasInjectionContext=function(){return!!n.getCurrentInstance()},n.createApp=e}else if(r.version.slice(0,2)==="2.")if(u){for(var t in u)n[t]=u[t];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=r,n.Vue2=r,n.version=r.version,n.hasInjectionContext=function(){return!!n.getCurrentInstance()}}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(r.version.slice(0,2)==="3."){for(var t in r)n[t]=r[t];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=r,n.Vue2=void 0,n.version=r.version,n.set=function(e,o,c){return Array.isArray(e)?(e.length=Math.max(e.length,o),e.splice(o,1,c),c):(e[o]=c,c)},n.del=function(e,o){if(Array.isArray(e)){e.splice(o,1);return}delete e[o]}}else console.error("[vue-demi] Vue version "+r.version+" is unsupported.");return n}(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(n,r,u,t){"use strict";const A=u.default||u;function e(o,c,i={}){const{validateOption:v={},immediate:d=!0,manual:a=!1}=i,l=r.toRef(o),f=t.shallowRef(null),p=t.ref(!0),h=t.ref(!d||a),b=t.computed(()=>{var s;return((s=f.value)==null?void 0:s.errors)||[]}),w=t.computed(()=>{var s;return((s=f.value)==null?void 0:s.fields)||{}}),I=t.computed(()=>new A(r.toValue(c))),x=async()=>{p.value=!1,h.value=!1;try{await I.value.validate(l.value,v),h.value=!0,f.value=null}catch(s){f.value=s}finally{p.value=!0}return{pass:h.value,errorInfo:f.value,errors:b.value,errorFields:w.value}};a||t.watch([l,I],()=>x(),{immediate:d,deep:!0});const C={isFinished:p,pass:h,errors:b,errorInfo:f,errorFields:w,execute:x};function j(){return new Promise((s,y)=>{r.until(p).toBe(!0).then(()=>s(C)).catch(F=>y(F))})}return{...C,then(s,y){return j().then(s,y)}}}n.useAsyncValidator=e})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,VueDemi);
package/useAxios.cjs CHANGED
@@ -7,12 +7,14 @@ var axios = require('axios');
7
7
  function useAxios(...args) {
8
8
  const url = typeof args[0] === "string" ? args[0] : void 0;
9
9
  const argsPlaceholder = typeof url === "string" ? 1 : 0;
10
- let defaultConfig = {};
11
- let instance = axios;
12
- let options = {
10
+ const defaultOptions = {
13
11
  immediate: !!argsPlaceholder,
14
- shallow: true
12
+ shallow: true,
13
+ abortPrevious: true
15
14
  };
15
+ let defaultConfig = {};
16
+ let instance = axios;
17
+ let options = defaultOptions;
16
18
  const isAxiosInstance = (val) => !!(val == null ? void 0 : val.request);
17
19
  if (args.length > 0 + argsPlaceholder) {
18
20
  if (isAxiosInstance(args[0 + argsPlaceholder]))
@@ -25,7 +27,7 @@ function useAxios(...args) {
25
27
  instance = args[1 + argsPlaceholder];
26
28
  }
27
29
  if (args.length === 2 + argsPlaceholder && !isAxiosInstance(args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
28
- options = args[args.length - 1];
30
+ options = args[args.length - 1] || defaultOptions;
29
31
  const {
30
32
  initialData,
31
33
  shallow,
@@ -76,7 +78,8 @@ function useAxios(...args) {
76
78
  return promise;
77
79
  }
78
80
  resetData();
79
- abort();
81
+ if (options.abortPrevious !== false)
82
+ abort();
80
83
  loading(true);
81
84
  executeCounter += 1;
82
85
  const currentExecuteCounter = executeCounter;
package/useAxios.d.cts CHANGED
@@ -63,6 +63,12 @@ interface UseAxiosOptions<T = any> {
63
63
  * @default true
64
64
  */
65
65
  shallow?: boolean;
66
+ /**
67
+ * Abort previous request when a new request is made.
68
+ *
69
+ * @default true
70
+ */
71
+ abortPrevious?: boolean;
66
72
  /**
67
73
  * Callback when error is caught.
68
74
  */
package/useAxios.d.mts CHANGED
@@ -63,6 +63,12 @@ interface UseAxiosOptions<T = any> {
63
63
  * @default true
64
64
  */
65
65
  shallow?: boolean;
66
+ /**
67
+ * Abort previous request when a new request is made.
68
+ *
69
+ * @default true
70
+ */
71
+ abortPrevious?: boolean;
66
72
  /**
67
73
  * Callback when error is caught.
68
74
  */
package/useAxios.d.ts CHANGED
@@ -63,6 +63,12 @@ interface UseAxiosOptions<T = any> {
63
63
  * @default true
64
64
  */
65
65
  shallow?: boolean;
66
+ /**
67
+ * Abort previous request when a new request is made.
68
+ *
69
+ * @default true
70
+ */
71
+ abortPrevious?: boolean;
66
72
  /**
67
73
  * Callback when error is caught.
68
74
  */
package/useAxios.iife.js CHANGED
@@ -19,7 +19,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
19
19
  VueDemi.Vue2 = Vue
20
20
  VueDemi.version = Vue.version
21
21
  VueDemi.warn = Vue.util.warn
22
- VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
22
+ VueDemi.hasInjectionContext = function() {
23
+ return !!VueDemi.getCurrentInstance()
24
+ }
23
25
  function createApp(rootComponent, rootProps) {
24
26
  var vm
25
27
  var provide = {}
@@ -72,7 +74,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
72
74
  VueDemi.Vue = Vue
73
75
  VueDemi.Vue2 = Vue
74
76
  VueDemi.version = Vue.version
75
- VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
77
+ VueDemi.hasInjectionContext = function() {
78
+ return !!VueDemi.getCurrentInstance()
79
+ }
76
80
  } else {
77
81
  console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
78
82
  }
@@ -120,12 +124,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
120
124
  function useAxios(...args) {
121
125
  const url = typeof args[0] === "string" ? args[0] : void 0;
122
126
  const argsPlaceholder = typeof url === "string" ? 1 : 0;
123
- let defaultConfig = {};
124
- let instance = axios;
125
- let options = {
127
+ const defaultOptions = {
126
128
  immediate: !!argsPlaceholder,
127
- shallow: true
129
+ shallow: true,
130
+ abortPrevious: true
128
131
  };
132
+ let defaultConfig = {};
133
+ let instance = axios;
134
+ let options = defaultOptions;
129
135
  const isAxiosInstance = (val) => !!(val == null ? void 0 : val.request);
130
136
  if (args.length > 0 + argsPlaceholder) {
131
137
  if (isAxiosInstance(args[0 + argsPlaceholder]))
@@ -138,7 +144,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
138
144
  instance = args[1 + argsPlaceholder];
139
145
  }
140
146
  if (args.length === 2 + argsPlaceholder && !isAxiosInstance(args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
141
- options = args[args.length - 1];
147
+ options = args[args.length - 1] || defaultOptions;
142
148
  const {
143
149
  initialData,
144
150
  shallow,
@@ -189,7 +195,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
189
195
  return promise;
190
196
  }
191
197
  resetData();
192
- abort();
198
+ if (options.abortPrevious !== false)
199
+ abort();
193
200
  loading(true);
194
201
  executeCounter += 1;
195
202
  const currentExecuteCounter = executeCounter;
@@ -1 +1 @@
1
- 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);
1
+ 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 c,h={},d={config:n.config,use:n.use.bind(n),mixin:n.mixin.bind(n),component:n.component.bind(n),provide:function(l,f){return h[l]=f,this},directive:function(l,f){return f?(n.directive(l,f),d):n.directive(l)},mount:function(l,f){return c||(c=new n(Object.assign({propsData:o},i,{provide:Object.assign(h,i.provide)})),c.$mount(l,f),c)},unmount:function(){c&&(c.$destroy(),c=void 0)}};return d};var P=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=function(){return!!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=function(){return!!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 P(...t){const i=typeof t[0]=="string"?t[0]:void 0,o=typeof i=="string"?1:0,c={immediate:!!o,shallow:!0,abortPrevious:!0};let h={},d=r,l=c;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)&&(l=t[t.length-1]||c);const{initialData:R,shallow:U,onSuccess:$=u.noop,onError:q=u.noop,immediate:B,resetOnExecute:M=!1}=l,j=n.shallowRef(),y=(U?n.shallowRef:n.ref)(R),v=n.ref(!1),A=n.ref(!1),b=n.ref(!1),p=n.shallowRef(),O=r.CancelToken.source;let C=O();const x=s=>{v.value||!A.value||(C.cancel(s),C=O(),b.value=!0,A.value=!1,v.value=!1)},T=s=>{A.value=s,v.value=!s},N=()=>{M&&(y.value=R)},_=()=>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(),l.abortPrevious!==!1&&x(),T(!0),E+=1;const z=E;return b.value=!1,d(L,{...h,...typeof s=="object"?s:w,cancelToken:C.token}).then(a=>{if(b.value)return;j.value=a;const S=a.data;y.value=S,$(S)}).catch(a=>{p.value=a,q(a)}).finally(()=>{var a;(a=l.onFinish)==null||a.call(l),z===E&&T(!1)}),I};B&&i&&k();const F={response:j,data:y,error:p,isFinished:v,isLoading:A,cancel:x,isAborted:b,isCanceled:b,abort:x,execute:k};return{...F,...I}}e.useAxios=P})(this.VueUse=this.VueUse||{},VueDemi,VueUse,axios);
package/useAxios.mjs CHANGED
@@ -5,12 +5,14 @@ import axios, { AxiosError } from 'axios';
5
5
  function useAxios(...args) {
6
6
  const url = typeof args[0] === "string" ? args[0] : void 0;
7
7
  const argsPlaceholder = typeof url === "string" ? 1 : 0;
8
- let defaultConfig = {};
9
- let instance = axios;
10
- let options = {
8
+ const defaultOptions = {
11
9
  immediate: !!argsPlaceholder,
12
- shallow: true
10
+ shallow: true,
11
+ abortPrevious: true
13
12
  };
13
+ let defaultConfig = {};
14
+ let instance = axios;
15
+ let options = defaultOptions;
14
16
  const isAxiosInstance = (val) => !!(val == null ? void 0 : val.request);
15
17
  if (args.length > 0 + argsPlaceholder) {
16
18
  if (isAxiosInstance(args[0 + argsPlaceholder]))
@@ -23,7 +25,7 @@ function useAxios(...args) {
23
25
  instance = args[1 + argsPlaceholder];
24
26
  }
25
27
  if (args.length === 2 + argsPlaceholder && !isAxiosInstance(args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
26
- options = args[args.length - 1];
28
+ options = args[args.length - 1] || defaultOptions;
27
29
  const {
28
30
  initialData,
29
31
  shallow,
@@ -74,7 +76,8 @@ function useAxios(...args) {
74
76
  return promise;
75
77
  }
76
78
  resetData();
77
- abort();
79
+ if (options.abortPrevious !== false)
80
+ abort();
78
81
  loading(true);
79
82
  executeCounter += 1;
80
83
  const currentExecuteCounter = executeCounter;