vue-use-async 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import*as e from"vue";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},r={};t.d(r,{BH:()=>d,oV:()=>A,Fs:()=>i,Zn:()=>a,_B:()=>u,LK:()=>s,r5:()=>g,Db:()=>E,pc:()=>_,yu:()=>D,fz:()=>N});const n={log:function(e){},warn:function(e){},info:function(e){},error:function(e){},debug:function(e){}};var o=new Map;function i(e){var t,r,i=e||{},u=i.id,a=i.xhr,s="string"!=typeof e.duration&&e.duration||200;if("max"===e.duration&&(s=36e5),!o.get(u)&&a?(t=a(),o.set(u,t),t.then((function(e){return n.log("[Log] add cache: ".concat(u)),clearTimeout(r),r=window.setTimeout((function(){o.delete(u),n.log("[Log] delete cache: ".concat(u)),clearTimeout(r)}),s),e}),(function(){return o.delete(u),n.log("[Log] delete cache: ".concat(u))}))):u&&(t=o.get(u)),t)return t;throw Error("Call to undefined cache")}function u(){return o.size}function a(){return Array.from(o.keys())}function s(e){e?o.delete(e):o.forEach((function(e,t,r){r.delete(t)})),n.log("[Log] cache cleared")}function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,h(n.key),n)}}function l(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function v(e,t,r){return(t=h(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(e){var t=function(e,t){if("object"!=c(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=c(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==c(t)?t:String(t)}var d=l((function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),v(this,"resolve",void 0),v(this,"reject",void 0),v(this,"promise",void 0),v(this,"done",!1),this.resolve=function(){throw Error("Can t resolve")},this.reject=function(){throw Error("Can t reject")},this.promise=new Promise((function(e,r){t.resolve=e,t.reject=r})),this.promise.finally((function(){t.done=!0}))}));const p=(y={computed:()=>e.computed,isRef:()=>e.isRef,onBeforeUnmount:()=>e.onBeforeUnmount,ref:()=>e.ref,unref:()=>e.unref,watch:()=>e.watch,watchEffect:()=>e.watchEffect},m={},t.d(m,y),m);var y,m;function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}const g=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,p.ref)(!0),n=(0,p.ref)(),o=(0,p.ref)(),i=(0,p.ref)(null),u=[],a=[],s=[],c=(0,p.ref)(null),f=(0,p.computed)((function(){return"function"==typeof t?t():(0,p.unref)(t)})),l=(0,p.ref)(),v=(0,p.computed)((function(){return"function"==typeof r?r():(0,p.unref)(r)})),h=function(t){a.forEach((function(e){return e(f.value)})),n.value=!0,i.value=null;var r,l=e,v=e;return c.value=Array.isArray(t)?v.apply(void 0,function(e){if(Array.isArray(e))return b(e)}(r=t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):l(t),c.value.catch((function(e){i.value=e||null,u.forEach((function(e){return e(i.value,f.value)})),i.value=e})),c.value.then((function(e){o.value=e,s.forEach((function(t){return t(e,f.value)}))})),c.value.finally((function(){n.value=!1})),c.value},d=(0,p.computed)((function(){return c.value}));return(0,p.watch)((function(){return v.value}),(function(e){!n.value&&e&&h(f.value)}),{immediate:!1}),(0,p.watch)((function(){return i.value}),(function(e){if(e)throw e})),(0,p.watch)((function(){return f.value}),(function(e){var t=JSON.stringify(e);!n.value&&(void 0===e&&void 0===l.value||v.value&&t!==JSON.stringify(l.value))&&h(e),l.value=void 0===t?void 0:JSON.parse(t)}),{immediate:v.value,deep:!0}),{isPending:n,data:o,error:i,reload:function(){return h(f.value)},onError:function(e){u.push(e)},onStart:function(e){a.push(e)},onEnd:function(e){s.push(e)},promise:d}};function E(e){var t=(0,p.ref)(),r=(0,p.ref)(),n=(0,p.ref)(),o=[],i=[],u=(0,p.ref)(null);return{mutate:function(a){for(var s=arguments.length,c=new Array(s>1?s-1:0),f=1;f<s;f++)c[f-1]=arguments[f];t.value=!0,n.value=null;var l=e;return u.value=l.apply(void 0,[a].concat(c)),u.value.catch((function(e){n.value=e||null,o.forEach((function(e){return e(n.value,c.length?[a].concat(c):a)})),n.value=e})),u.value.then((function(e){r.value=e,i.forEach((function(e){return e(r.value,c.length?[a].concat(c):a)}))})),u.value.finally((function(){t.value=!1})),u.value},onError:function(e){return o.push(e)},onEnd:function(e){return i.push(e)},isPending:t,error:n,data:r,promise:(0,p.computed)((function(){return u.value}))}}function _(e,t,r){var n=(0,p.ref)(t);return r||(r=function(e){return e}),t&&(n.value=r(t)),(0,p.watchEffect)((function(){if(e){var t,o=(0,p.unref)(e);o&&(n.value=null===(t=r)||void 0===t?void 0:t(o))}})),n}function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,u,a=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return O(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?O(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function S(e){return S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},S(e)}function P(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,k(n.key),n)}}function R(e,t,r){return(t=k(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function k(e){var t=function(e,t){if("object"!=S(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==S(t)?t:String(t)}var A=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),R(this,"onError",(function(){})),R(this,"onStart",(function(){})),R(this,"onAbort",(function(){})),R(this,"onProgress",(function(){})),R(this,"onEnd",(function(){})),R(this,"token",null),R(this,"url",""),R(this,"params",{}),R(this,"sendAs","json"),R(this,"timeout",1e4),R(this,"port",80),R(this,"responseType","text"),R(this,"isPending",!1),R(this,"_eventsReady",void 0),R(this,"_oXHR",void 0),R(this,"_onEnd",(function(){})),R(this,"_onError",(function(){})),R(this,"_deferred",void 0),R(this,"_isXhrResolved",void 0),R(this,"_isXhrRejected",void 0),R(this,"_eventReady",void 0),this._eventsReady=!1,this._constructor(t||{},r)}var t,r,n;return t=e,r=[{key:"_getUrl",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.onBeforeSendList.reduce((function(e,t){return t(e||{})}),t);return e.stringifyUrl(this.url,r)}},{key:"removeEvents",value:function(){var e=this,t=function(){e._oXHR.removeEventListener("load",e._onEnd,!1),e._oXHR.removeEventListener("error",e._onError,!1),e._oXHR.removeEventListener("timeout",e._onError,!1),e._oXHR.removeEventListener("loadstart",e.onStart,!1),e._oXHR.removeEventListener("abort",e.onAbort,!1),e._oXHR.upload.removeEventListener("progress",e.onProgress,!1),e._oXHR.removeEventListener("progress",e.onProgress,!1)};this._deferred.promise.then(t,t)}},{key:"post",value:function(e){return this._constructor(e),this._oXHR.open("POST",this._getUrl(),!0),this._send(),this._deferred.promise}},{key:"put",value:function(e){return this._constructor(e),this._oXHR.open("PUT",this._getUrl(),!0),this._send(),this._deferred.promise}},{key:"get",value:function(e){this._constructor(e||{}),this._oXHR.open("GET",this._getUrl("multipart"===this.sendAs?{}:this.params),!0),this._send();var t=this._deferred.promise;return t.abortXhr=this.abort.bind(this),t}},{key:"delete",value:function(e){return this._constructor(e),this._oXHR.open("DELETE",this._getUrl(this.params),!0),this._send(),this._deferred.promise}},{key:"abort",value:function(){return this._isXhrResolved&&!this._isXhrRejected||(this._oXHR.abort(null,this),this._isXhrRejected=!0,this._deferred.reject({message:"Xhr aborted: ".concat(this.url),name:"HTTP-ABORTED"})),this._deferred.promise}},{key:"resolve",value:function(e){return this._deferred.resolve(e),this._deferred.promise}},{key:"reject",value:function(e){return this._deferred.reject(e),this._deferred.promise}},{key:"_setEvents",value:function(e){this._eventsReady||(this._eventReady=!0,e.addEventListener("load",this._onEnd,!1),e.addEventListener("error",this._onError,!1),e.addEventListener("timeout",this._onError,!1),e.addEventListener("loadstart",this.onStart,!1),e.addEventListener("abort",this.onAbort,!1),e.upload.addEventListener("progress",this.onProgress,!1),e.addEventListener("progress",this.onProgress,!1))}},{key:"_send",value:function(){var t;this.isPending=!0,"multipart"===this.sendAs?t=e.getFormData(this.params):"json"===this.sendAs&&(this._oXHR.setRequestHeader("content-type","application/json; charset=utf-8"),t=JSON.stringify(this.params)),this.token&&this._oXHR.setRequestHeader("Authorization","Bearer ".concat(this.token)),this._oXHR.send(t,this)}},{key:"_constructor",value:function(t,r){var n=this;t&&"object"===S(t)?(this.sendAs=t.sendAs||this.sendAs,this.url=t.url||this.url,this.port=t.port||this.port,this.params=t.params||this.params,this.timeout=t.timeout||this.timeout,this.responseType=t.responseType||this.responseType,this.onProgress=(t.onProgress||this.onProgress).bind(this),this.onStart=(t.onStart||this.onStart).bind(this),this.onAbort=(t.onAbort||this.onAbort).bind(this),this.onEnd=(t.onEnd||this.onEnd).bind(this),this.onError=(t.onError||this.onError).bind(this),this.token=t.token||this.token):t&&"string"==typeof t&&(this.url=t,this.params=r||this.params),80!==this.port&&(this.url="".concat(window.location.protocol,"//").concat(window.location.hostname,":").concat(this.port).concat(this.url)),this._deferred=new d,this._deferred.promise.finally((function(){n.isPending=!1})),this._oXHR=new XMLHttpRequest,this._oXHR.timeout=this.timeout,this._oXHR.responseType=this.responseType,this._isXhrResolved=!1,this._isXhrRejected=!1;var o=e.injectParamsInUrl(this.url,this.params),i=o.url,u=o.params;this.url=i,this.params=u,this._onError=function(e){n.onError(e),n.removeEvents(),n._deferred.reject(e)},this._onEnd=function(t){var r=e.parseResult(n._oXHR);return n._oXHR.status>=400?(n._isXhrRejected=!0,n._onError(r),n._deferred.reject(r)):(n.onEnd(r,t),n._isXhrResolved=!0,n.removeEvents(),n.resolve(r))},this._setEvents(this._oXHR)}}],n=[{key:"parseResult",value:function(e){var t=e.response;try{var r=e.getResponseHeader("Content-Type");r&&r.toLowerCase().indexOf("json")>-1&&(t=JSON.parse(e.response))}catch(r){t=e.response}return t}},{key:"extractQueryParams",value:function(e){var t={},r=e.search(/#/);r>-1&&(e=e.substring(0,r));var n=e.indexOf("?"),o=(!0).toString(),i=(!1).toString();return n>-1&&e.split("?")[1].split("&").reduce((function(e,t){var r=w(t.split("="),2),n=r[0],u=r[1],a=w((void 0===u?"":u).match(/^(?:"?([^"]+)"?)$/)||[],2)[1];if(a===o||a===i)e[n]=a===o;else{var s=Number(a);e[n]=""===a||Number.isNaN(s)?a:s}return e}),t),t}},{key:"onBeforeSend",value:function(t){e.onBeforeSendList.push(t)}},{key:"new",value:function(t){return new e(t)}},{key:"stringifyUrl",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.injectParamsInUrl(t,r);t=n.url,r=n.params;var o=t.indexOf("?")>-1?"&":"?",i="";return r&&!Array.isArray(r)&&"object"===S(r)?Object.getOwnPropertyNames(r).filter((function(e){return void 0!==r[e]})).forEach((function(e){i+="".concat(o).concat(e,"=").concat(encodeURIComponent(JSON.stringify(r[e]))),o="&"})):r&&(i=o+encodeURIComponent(JSON.stringify(r))),(t=t.replace(/\/:[^/]*/gi,""))+i}},{key:"getFormData",value:function(e){var t,r=new FormData;return Object.keys(e).forEach((function(n){if(e[n]instanceof FileList)for(var o=0;o<e[n].length;o+=1)r.append(n,e[n][o]);else e[n]instanceof File?r.append(n,e[n]):("object"!==S(t=e[n])&&!Array.isArray(t)||null===t||(t=JSON.stringify(t)),r.append(n,t))})),r}},{key:"_stringifyForPathParam",value:function(e,t,r){var n=r[t];switch(S(r[t])){case"boolean":case"string":case"bigint":case"number":n=String(n);break;default:n=null===n?"null":encodeURIComponent(JSON.stringify(n))}return e.replace(":".concat(t),n)}},{key:"injectParamsInUrl",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Array.isArray(r)||0===Object.keys(r).length)return{url:t,params:r};var n=decodeURIComponent(t),o=e.extractQueryParams(n),i=n.search(/\?|#/);i>-1&&(n=n.substring(0,i));var u=Object.getOwnPropertyNames(r).reduce((function(e,t){return e[t]=r[t],e}),function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){R(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},o));(n.match(/:[a-z0-9]+/gi)||[]).forEach((function(t){t=t.substring(1),void 0!==u[t]&&(n=e._stringifyForPathParam(n,t,u),delete u[t])})),Object.keys(u).forEach((function(e){void 0!==o[e]&&(o[e]=u[e],delete u[e])}));var a=Object.keys(o);if(a.length){var s="?";a.forEach((function(e){if(!0===o[e]||!1===o[e])n+="".concat(s).concat(e,"=").concat(o[e]);else if(null===o[e])n+="".concat(s).concat(e,"=").concat(o[e]);else{var t=Number(o[e]),r=Number.isNaN(t)?encodeURIComponent('"'.concat(o[e],'"')):t;n+="".concat(s).concat(e,"=").concat(r)}s="&"}))}return{url:n,params:u}}}],r&&P(t.prototype,r),n&&P(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function X(e){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},X(e)}function H(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){var n,o,i,u;n=e,o=t,i=r[t],u=function(e,t){if("object"!=X(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=X(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o),(o="symbol"==X(u)?u:String(u))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}R(A,"onBeforeSendList",[]);var T=function(){},U=function(e){return(0,p.unref)(e)};function N(e){var t=e||{onError:function(){},onStart:function(){},onEnd:function(){},context:null,legacy:!1,token:null},r=t.onError,n=t.onStart,o=t.onEnd,u=t.context,a=t.legacy,s=t.token,c=void 0===s?null:s,f=(0,p.ref)([]),l=[],v=function(e,t,r){var n,o=(0,p.computed)((function(){var e={},n=(0,p.unref)(t||{});r||(r=n.params||{}),e.params=(0,p.unref)(r),c&&(e.token=U(c));var o=(0,p.unref)(e.params||r||{});return"function"==typeof o&&(o=o()),e.url=(0,p.unref)(n.url),e})),i=new A,u=(0,p.unref)(o.value.params)||{};switch(e){case"post":default:n=i.post.bind(i);break;case"put":n=i.put.bind(i);break;case"delete":n=i.delete.bind(i)}return L(L({},g((function(){return n(L(L({},o.value),{},{params:u}))}))),{},{xhr:i})};return a||(0,p.onBeforeUnmount)((function(){f.value.forEach((function(e){e.isPending&&e.abort()})),l.forEach((function(e){return e()}))})),{get:function(e,t,a){var s=new A,v=(r||T).bind(u),h=(n||T).bind(u),d=(o||T).bind(u),y=[v],m=[h],b=[d],g=(0,p.ref)(null);f.value.push(s);var E=(0,p.ref)(),_=(0,p.ref)(),j="",w=0,O=(0,p.computed)((function(){var r,n={},o=(0,p.unref)(e);"string"==typeof o?r=o:(r=(0,p.unref)(o.url),t||(t=o.params||{}),w=o.cacheDuration,void 0!==o.enabled&&(n.enabled=o.enabled),void 0===n.enabled&&(n.enabled=a),n.params=(0,p.unref)(t),n.cacheDuration=w),c&&(n.token=U(c));var i=(0,p.unref)(n.params||t||{});return"function"==typeof i&&(i=i()),n.params=L(L({},i),(0,p.isRef)(t)?t.value||{}:t),j="function"==typeof r?r(n.params):(0,p.unref)(r),n.url=j,n})),S=function(){var e=void 0!==O.value.enabled?O.value.enabled:a;return void 0===e||((0,p.isRef)(e)?(0,p.unref)(e):"function"==typeof e?e():!0===e)},P=(0,p.ref)(),R=function(){if(S()){E.value&&s.abort();var e="object"===X(O.value.params)?O.value.params:{};m.forEach((function(t){return t(e,s)})),E.value=!0,g.value=null;var t=decodeURIComponent(A.stringifyUrl(String(j),e));P.value=i({id:t,xhr:s.get.bind(s,O.value),duration:w}),P.value.catch((function(e){y.forEach((function(t){return t(e,s)})),g.value=e})),P.value.then((function(e){_.value=e})),P.value.finally((function(){var t;(t=f.value.indexOf(s))>-1&&f.value.splice(t,1),E.value=!1,b.forEach((function(t){return t(_.value,e,s)}))}))}};return l.push((0,p.watch)((function(){return O.value}),R,{immediate:S(),deep:!0})),l.push((0,p.watch)((function(){return g.value}),(function(e){if(e)throw e}))),{isPending:(0,p.computed)((function(){return E.value})),data:_,onError:function(e){return y.push(e)},onStart:function(e){return m.push(e)},onEnd:function(e){return b.push(e)},error:g,abort:function(){var e;return null===(e=P.value)||void 0===e?void 0:e.abortXhr()},promise:(0,p.computed)((function(){return P.value||new Promise((function(){}))})),reload:R,xhr:s}},post:function(e,t){return v("post",e,t)},put:function(e,t){return v("put",e,t)},delete:function(e,t){return v("delete",e,t)}}}function D(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:400,n=(0,p.ref)(!1);return(0,p.watch)((function(){return e.value}),(function(){n.value&&!e.value?(t&&clearTimeout(t),t=setTimeout((function(){n.value=!0===e.value}),r)):n.value=!0===e.value}),{immediate:!0}),(0,p.computed)((function(){return n.value}))}var x=r.BH,C=r.oV,I=r.Fs,B=r.Zn,F=r._B,J=r.LK,z=r.r5,M=r.Db,q=r.pc,$=r.yu,K=r.fz;export{x as Deferred,C as Xhr,I as cache,B as cacheIds,F as cacheSize,J as clearCache,z as useAsync,M as useMutation,q as useResult,$ as useSpinner,K as useXhr};
1
+ import*as e from"vue";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},r={};t.d(r,{o9:()=>d,Sz:()=>A,qu:()=>i,cr:()=>a,_C:()=>u,Kk:()=>s,Ck:()=>g,cQ:()=>E,op:()=>_,s5:()=>N,OC:()=>C});const n={log:function(e){},warn:function(e){},info:function(e){},error:function(e){},debug:function(e){}};var o=new Map;function i(e){var t,r,i=e||{},u=i.id,a=i.xhr,s="string"!=typeof e.duration&&e.duration||200;if("max"===e.duration&&(s=36e5),!o.get(u)&&a?(t=a(),o.set(u,t),t.then((function(e){return n.log("[Log] add cache: ".concat(u)),clearTimeout(r),r=window.setTimeout((function(){o.delete(u),n.log("[Log] delete cache: ".concat(u)),clearTimeout(r)}),s),e}),(function(){return o.delete(u),n.log("[Log] delete cache: ".concat(u))}))):u&&(t=o.get(u)),t)return t;throw Error("Call to undefined cache")}function u(){return o.size}function a(){return Array.from(o.keys())}function s(e){e?o.delete(e):o.forEach((function(e,t,r){r.delete(t)})),n.log("[Log] cache cleared")}function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,h(n.key),n)}}function l(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function v(e,t,r){return(t=h(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(e){var t=function(e,t){if("object"!=c(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=c(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==c(t)?t:String(t)}var d=l((function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),v(this,"resolve",void 0),v(this,"reject",void 0),v(this,"promise",void 0),v(this,"done",!1),this.resolve=function(){throw Error("Can t resolve")},this.reject=function(){throw Error("Can t reject")},this.promise=new Promise((function(e,r){t.resolve=e,t.reject=r})),this.promise.finally((function(){t.done=!0}))}));const p=(y={computed:()=>e.computed,isRef:()=>e.isRef,onBeforeUnmount:()=>e.onBeforeUnmount,ref:()=>e.ref,unref:()=>e.unref,watch:()=>e.watch,watchEffect:()=>e.watchEffect},m={},t.d(m,y),m);var y,m;function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}const g=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,p.ref)(!0),n=(0,p.ref)(),o=(0,p.ref)(),i=(0,p.ref)(null),u=[],a=[],s=[],c=(0,p.ref)(null),f=(0,p.computed)((function(){return"function"==typeof t?t():(0,p.unref)(t)})),l=(0,p.ref)(),v=(0,p.computed)((function(){return"function"==typeof r?r():(0,p.unref)(r)})),h=function(t){a.forEach((function(e){return e(f.value)})),n.value=!0,i.value=null;var r,l=e,v=e;return c.value=Array.isArray(t)?v.apply(void 0,function(e){if(Array.isArray(e))return b(e)}(r=t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):l(t),c.value.catch((function(e){i.value=e||null,u.forEach((function(e){return e(i.value,f.value)})),i.value=e})),c.value.then((function(e){o.value=e,s.forEach((function(t){return t(e,f.value)}))})),c.value.finally((function(){n.value=!1})),c.value},d=(0,p.computed)((function(){return c.value}));return(0,p.watch)((function(){return v.value}),(function(e){!n.value&&e&&h(f.value)}),{immediate:!1}),(0,p.watch)((function(){return i.value}),(function(e){if(e)throw e})),(0,p.watch)((function(){return f.value}),(function(e){var t=JSON.stringify(e);!n.value&&(void 0===e&&void 0===l.value||v.value&&t!==JSON.stringify(l.value))&&h(e),l.value=void 0===t?void 0:JSON.parse(t)}),{immediate:v.value,deep:!0}),{isPending:n,data:o,error:i,reload:function(){return h(f.value)},onError:function(e){u.push(e)},onStart:function(e){a.push(e)},onEnd:function(e){s.push(e)},promise:d}};function E(e){var t=(0,p.ref)(),r=(0,p.ref)(),n=(0,p.ref)(),o=[],i=[],u=(0,p.ref)(null);return{mutate:function(a){for(var s=arguments.length,c=new Array(s>1?s-1:0),f=1;f<s;f++)c[f-1]=arguments[f];t.value=!0,n.value=null;var l=e;return u.value=l.apply(void 0,[a].concat(c)),u.value.catch((function(e){n.value=e||null,o.forEach((function(e){return e(n.value,c.length?[a].concat(c):a)})),n.value=e})),u.value.then((function(e){r.value=e,i.forEach((function(e){return e(r.value,c.length?[a].concat(c):a)}))})),u.value.finally((function(){t.value=!1})),u.value},onError:function(e){return o.push(e)},onEnd:function(e){return i.push(e)},isPending:t,error:n,data:r,promise:(0,p.computed)((function(){return u.value}))}}function _(e,t,r){var n=(0,p.ref)(t);return r||(r=function(e){return e}),t&&(n.value=r(t)),(0,p.watchEffect)((function(){if(e){var t,o=(0,p.unref)(e);o&&(n.value=null===(t=r)||void 0===t?void 0:t(o))}})),n}function w(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,u,a=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return O(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?O(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function S(e){return S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},S(e)}function P(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,k(n.key),n)}}function R(e,t,r){return(t=k(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function k(e){var t=function(e,t){if("object"!=S(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==S(t)?t:String(t)}var A=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),R(this,"onError",(function(){})),R(this,"onStart",(function(){})),R(this,"onAbort",(function(){})),R(this,"onProgress",(function(){})),R(this,"onEnd",(function(){})),R(this,"token",null),R(this,"url",""),R(this,"params",{}),R(this,"sendAs","json"),R(this,"timeout",1e4),R(this,"port",80),R(this,"responseType","text"),R(this,"isPending",!1),R(this,"_eventsReady",void 0),R(this,"_oXHR",void 0),R(this,"_onEnd",(function(){})),R(this,"_onError",(function(){})),R(this,"_deferred",void 0),R(this,"_isXhrResolved",void 0),R(this,"_isXhrRejected",void 0),R(this,"_eventReady",void 0),this._eventsReady=!1,this._constructor(t||{},r)}var t,r,n;return t=e,r=[{key:"_getUrl",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.onBeforeSendList.reduce((function(e,t){return t(e||{})}),t);return e.stringifyUrl(this.url,r)}},{key:"removeEvents",value:function(){var e=this,t=function(){e._oXHR.removeEventListener("load",e._onEnd,!1),e._oXHR.removeEventListener("error",e._onError,!1),e._oXHR.removeEventListener("timeout",e._onError,!1),e._oXHR.removeEventListener("loadstart",e.onStart,!1),e._oXHR.removeEventListener("abort",e.onAbort,!1),e._oXHR.upload.removeEventListener("progress",e.onProgress,!1),e._oXHR.removeEventListener("progress",e.onProgress,!1)};this._deferred.promise.then(t,t)}},{key:"post",value:function(e){return this._constructor(e),this._oXHR.open("POST",this._getUrl(),!0),this._send(),this._deferred.promise}},{key:"put",value:function(e){return this._constructor(e),this._oXHR.open("PUT",this._getUrl(),!0),this._send(),this._deferred.promise}},{key:"get",value:function(e){this._constructor(e||{}),this._oXHR.open("GET",this._getUrl("multipart"===this.sendAs?{}:this.params),!0),this._send();var t=this._deferred.promise;return t.abortXhr=this.abort.bind(this),t}},{key:"delete",value:function(e){return this._constructor(e),this._oXHR.open("DELETE",this._getUrl(this.params),!0),this._send(),this._deferred.promise}},{key:"abort",value:function(){return this._isXhrResolved&&!this._isXhrRejected||(this._oXHR.abort(null,this),this._isXhrRejected=!0,this._deferred.reject({message:"Xhr aborted: ".concat(this.url),name:"HTTP-ABORTED"})),this._deferred.promise}},{key:"resolve",value:function(e){return this._deferred.resolve(e),this._deferred.promise}},{key:"reject",value:function(e){return this._deferred.reject(e),this._deferred.promise}},{key:"_setEvents",value:function(e){this._eventsReady||(this._eventReady=!0,e.addEventListener("load",this._onEnd,!1),e.addEventListener("error",this._onError,!1),e.addEventListener("timeout",this._onError,!1),e.addEventListener("loadstart",this.onStart,!1),e.addEventListener("abort",this.onAbort,!1),e.upload.addEventListener("progress",this.onProgress,!1),e.addEventListener("progress",this.onProgress,!1))}},{key:"_send",value:function(){var t;this.isPending=!0,"multipart"===this.sendAs?t=e.getFormData(this.params):"json"===this.sendAs&&(this._oXHR.setRequestHeader("content-type","application/json; charset=utf-8"),t=JSON.stringify(this.params)),this.token&&this._oXHR.setRequestHeader("Authorization","Bearer ".concat(this.token)),this._oXHR.send(t,this)}},{key:"_constructor",value:function(t,r){var n=this;t&&"object"===S(t)?(this.sendAs=t.sendAs||this.sendAs,this.url=t.url||this.url,this.port=t.port||this.port,this.params=t.params||this.params,this.timeout=t.timeout||this.timeout,this.responseType=t.responseType||this.responseType,this.onProgress=(t.onProgress||this.onProgress).bind(this),this.onStart=(t.onStart||this.onStart).bind(this),this.onAbort=(t.onAbort||this.onAbort).bind(this),this.onEnd=(t.onEnd||this.onEnd).bind(this),this.onError=(t.onError||this.onError).bind(this),this.token=t.token||this.token):t&&"string"==typeof t&&(this.url=t,this.params=r||this.params),80!==this.port&&(this.url="".concat(window.location.protocol,"//").concat(window.location.hostname,":").concat(this.port).concat(this.url)),this._deferred=new d,this._deferred.promise.finally((function(){n.isPending=!1})),this._oXHR=new XMLHttpRequest,this._oXHR.timeout=this.timeout,this._oXHR.responseType=this.responseType,this._isXhrResolved=!1,this._isXhrRejected=!1;var o=e.injectParamsInUrl(this.url,this.params),i=o.url,u=o.params;this.url=i,this.params=u,this._onError=function(e){n.onError(e),n.removeEvents(),n._deferred.reject(e)},this._onEnd=function(t){var r=e.parseResult(n._oXHR);return n._oXHR.status>=400?(n._isXhrRejected=!0,n._onError(r),n._deferred.reject(r)):(n.onEnd(r,t),n._isXhrResolved=!0,n.removeEvents(),n.resolve(r))},this._setEvents(this._oXHR)}}],n=[{key:"parseResult",value:function(e){var t=e.response;try{var r=e.getResponseHeader("Content-Type");r&&r.toLowerCase().indexOf("json")>-1&&(t=JSON.parse(e.response))}catch(r){t=e.response}return t}},{key:"extractQueryParams",value:function(e){var t={},r=e.search(/#/);r>-1&&(e=e.substring(0,r));var n=e.indexOf("?"),o=(!0).toString(),i=(!1).toString();return n>-1&&e.split("?")[1].split("&").reduce((function(e,t){var r=j(t.split("="),2),n=r[0],u=r[1],a=j((void 0===u?"":u).match(/^(?:"?([^"]+)"?)$/)||[],2)[1];if(a===o||a===i)e[n]=a===o;else{var s=Number(a);e[n]=""===a||Number.isNaN(s)?a:s}return e}),t),t}},{key:"onBeforeSend",value:function(t){e.onBeforeSendList.push(t)}},{key:"new",value:function(t){return new e(t)}},{key:"stringifyUrl",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.injectParamsInUrl(t,r);t=n.url,r=n.params;var o=t.indexOf("?")>-1?"&":"?",i="";return r&&!Array.isArray(r)&&"object"===S(r)?Object.getOwnPropertyNames(r).filter((function(e){return void 0!==r[e]})).forEach((function(e){i+="".concat(o).concat(e,"=").concat(encodeURIComponent(JSON.stringify(r[e]))),o="&"})):r&&(i=o+encodeURIComponent(JSON.stringify(r))),(t=t.replace(/\/:[^/]*/gi,""))+i}},{key:"getFormData",value:function(e){var t,r=new FormData;return Object.keys(e).forEach((function(n){if(e[n]instanceof FileList)for(var o=0;o<e[n].length;o+=1)r.append(n,e[n][o]);else e[n]instanceof File?r.append(n,e[n]):("object"!==S(t=e[n])&&!Array.isArray(t)||null===t||(t=JSON.stringify(t)),r.append(n,t))})),r}},{key:"_stringifyForPathParam",value:function(e,t,r){var n=r[t];switch(S(r[t])){case"boolean":case"string":case"bigint":case"number":n=String(n);break;default:n=null===n?"null":encodeURIComponent(JSON.stringify(n))}return e.replace(":".concat(t),n)}},{key:"injectParamsInUrl",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Array.isArray(r)||0===Object.keys(r).length)return{url:t,params:r};var n=decodeURIComponent(t),o=e.extractQueryParams(n),i=n.search(/\?|#/);i>-1&&(n=n.substring(0,i));var u=Object.getOwnPropertyNames(r).reduce((function(e,t){return e[t]=r[t],e}),function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?w(Object(r),!0).forEach((function(t){R(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},o));(n.match(/:[a-z0-9]+/gi)||[]).forEach((function(t){t=t.substring(1),void 0!==u[t]&&(n=e._stringifyForPathParam(n,t,u),delete u[t])})),Object.keys(u).forEach((function(e){void 0!==o[e]&&(o[e]=u[e],delete u[e])}));var a=Object.keys(o);if(a.length){var s="?";a.forEach((function(e){if(!0===o[e]||!1===o[e])n+="".concat(s).concat(e,"=").concat(o[e]);else if(null===o[e])n+="".concat(s).concat(e,"=").concat(o[e]);else{var t=Number(o[e]),r=Number.isNaN(t)?encodeURIComponent('"'.concat(o[e],'"')):t;n+="".concat(s).concat(e,"=").concat(r)}s="&"}))}return{url:n,params:u}}}],r&&P(t.prototype,r),n&&P(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function X(e){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},X(e)}function H(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function T(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){var n,o,i,u;n=e,o=t,i=r[t],u=function(e,t){if("object"!=X(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=X(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o),(o="symbol"==X(u)?u:String(u))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}R(A,"onBeforeSendList",[]);var L=function(){},U=function(e){return(0,p.unref)(e)};function C(e){var t=e||{onError:function(){},onStart:function(){},onEnd:function(){},context:null,legacy:!1,token:null},r=t.onError,n=t.onStart,o=t.onEnd,u=t.context,a=t.legacy,s=t.token,c=void 0===s?null:s,f=(0,p.ref)([]),l=[],v=function(e,t,r){var n,o=(0,p.computed)((function(){var e={},n=(0,p.unref)(t||{});r||(r=n.params||{}),e.params=(0,p.unref)(r),c&&(e.token=U(c));var o=(0,p.unref)(e.params||r||{});return"function"==typeof o&&(o=o()),e.url=(0,p.unref)(n.url),e})),i=new A,u=(0,p.unref)(o.value.params)||{};switch(e){case"post":default:n=i.post.bind(i);break;case"put":n=i.put.bind(i);break;case"delete":n=i.delete.bind(i)}return T(T({},g((function(){return n(T(T({},o.value),{},{params:u}))}))),{},{xhr:i})};return a||(0,p.onBeforeUnmount)((function(){f.value.forEach((function(e){e.isPending&&e.abort()})),l.forEach((function(e){return e()}))})),{get:function(e,t,a){var s=new A,v=(r||L).bind(u),h=(n||L).bind(u),d=(o||L).bind(u),y=[v],m=[h],b=[d],g=(0,p.ref)(null);f.value.push(s);var E=(0,p.ref)(),_=(0,p.ref)(),w="",j=0,O=(0,p.computed)((function(){var r,n={},o=(0,p.unref)(e);"string"==typeof o?r=o:(r=(0,p.unref)(o.url),t||(t=o.params||{}),j=o.cacheDuration,void 0!==o.enabled&&(n.enabled=o.enabled),void 0===n.enabled&&(n.enabled=a),n.params=(0,p.unref)(t),n.cacheDuration=j),c&&(n.token=U(c));var i=(0,p.unref)(n.params||t||{});return"function"==typeof i&&(i=i()),n.params=T(T({},i),(0,p.isRef)(t)?t.value||{}:t),w="function"==typeof r?r(n.params):(0,p.unref)(r),n.url=w,n})),S=function(){var e=void 0!==O.value.enabled?O.value.enabled:a;return void 0===e||((0,p.isRef)(e)?(0,p.unref)(e):"function"==typeof e?e():!0===e)},P=(0,p.ref)(),R=function(){if(S()){E.value&&s.abort();var e="object"===X(O.value.params)?O.value.params:{};m.forEach((function(t){return t(e,s)})),E.value=!0,g.value=null;var t=decodeURIComponent(A.stringifyUrl(String(w),e));P.value=i({id:t,xhr:s.get.bind(s,O.value),duration:j}),P.value.catch((function(e){y.forEach((function(t){return t(e,s)})),g.value=e})),P.value.then((function(e){_.value=e})),P.value.finally((function(){var t;(t=f.value.indexOf(s))>-1&&f.value.splice(t,1),E.value=!1,b.forEach((function(t){return t(_.value,e,s)}))}))}};return l.push((0,p.watch)((function(){return O.value}),R,{immediate:S(),deep:!0})),l.push((0,p.watch)((function(){return g.value}),(function(e){if(e)throw e}))),{isPending:(0,p.computed)((function(){return E.value})),data:_,onError:function(e){return y.push(e)},onStart:function(e){return m.push(e)},onEnd:function(e){return b.push(e)},error:g,abort:function(){var e;return null===(e=P.value)||void 0===e?void 0:e.abortXhr()},promise:(0,p.computed)((function(){return P.value||new Promise((function(){}))})),reload:R,xhr:s}},post:function(e,t){return v("post",e,t)},put:function(e,t){return v("put",e,t)},delete:function(e,t){return v("delete",e,t)}}}function N(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:400,n=(0,p.ref)(!1),o=0;return(0,p.watch)((function(){return e.value}),(function(e){if(e&&(o=Date.now(),n.value=e),!1===e&&o>0){var i=Date.now()-o;clearTimeout(t),i>r?n.value=e:t=setTimeout((function(){n.value=e}),r-i)}}),{immediate:!0}),(0,p.onBeforeUnmount)((function(){clearTimeout(t)})),(0,p.computed)((function(){return n.value}))}var D=r.o9,x=r.Sz,I=r.qu,B=r.cr,J=r._C,F=r.Kk,z=r.Ck,q=r.cQ,M=r.op,Q=r.s5,$=r.OC;export{D as Deferred,x as Xhr,I as cache,B as cacheIds,J as cacheSize,F as clearCache,z as useAsync,q as useMutation,M as useResult,Q as useSpinner,$ as useXhr};
@@ -1,2 +1,2 @@
1
1
  import { Ref } from 'vue';
2
- export default function (isPending: Ref<undefined | boolean>, duration?: number): import("vue").ComputedRef<boolean>;
2
+ export default function (isPending: Ref<undefined | boolean>, minDuration?: number): import("vue").ComputedRef<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-use-async",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Xhr and async helpers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,15 +27,15 @@
27
27
  "tsc:export-types": "tsc --outDir types"
28
28
  },
29
29
  "dependencies": {
30
- "vue": "^3.4.5"
30
+ "vue": "^3.4.15"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/plugin-proposal-class-properties": "^7.18.6",
34
- "@babel/preset-env": "^7.23.7",
34
+ "@babel/preset-env": "^7.23.9",
35
35
  "@babel/preset-typescript": "^7.23.3",
36
- "@types/jest": "^29.5.11",
37
- "@typescript-eslint/eslint-plugin": "^6.18.0",
38
- "@typescript-eslint/parser": "^6.18.0",
36
+ "@types/jest": "^29.5.12",
37
+ "@typescript-eslint/eslint-plugin": "^6.20.0",
38
+ "@typescript-eslint/parser": "^6.20.0",
39
39
  "babel-eslint": "^10.1.0",
40
40
  "babel-jest": "^29.7.0",
41
41
  "babel-loader": "^9.1.3",
@@ -44,13 +44,13 @@
44
44
  "eslint-config-airbnb-base": "^15.0.0",
45
45
  "eslint-import-resolver-typescript": "^3.6.1",
46
46
  "eslint-plugin-import": "^2.29.1",
47
- "husky": "^8.0.3",
47
+ "husky": "^9.0.10",
48
48
  "jest": "^29.7.0",
49
49
  "jest-environment-jsdom": "^29.7.0",
50
- "lint-staged": "^15.2.0",
50
+ "lint-staged": "^15.2.1",
51
51
  "typescript": "^5.3.3",
52
- "vue": "^3.4.5",
53
- "webpack": "^5.89.0",
52
+ "vue": "^3.4.15",
53
+ "webpack": "^5.90.1",
54
54
  "webpack-cli": "^5.1.4"
55
55
  },
56
56
  "peerDependencies": {