utils-lib-js 1.7.12 → 1.7.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1 @@
1
- var UtilsLib=function(e,t,n,r){"use strict";var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var u=function(){return u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},u.apply(this,arguments)};function a(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function c(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var s,l=function(e,t,n){void 0===n&&(n="");for(var r=0,o=t.split(".");r<o.length;r++){if(void 0===(e=e[o[r]]))return n}return e},f=function(e,t,n){void 0===n&&(n={});for(var r=t.split("."),o=r[r.length-1],i=e,u=0,a=r;u<a.length;u++){var c=a[u];if("object"!=typeof i&&void 0!==i)return e;!i&&(i={}),!i[c]&&(i[c]={}),o===c&&(i[o]=n),i=i[c]}return e},p=function(e,t,n){var r;for(var o in void 0===t&&(t={}),void 0===n&&(n=!1),t)for(var i in t[o]){var u=null!==(r=e.prototype)&&void 0!==r?r:e;(void 0===e[i]||n)&&(u[i]=t[o][i])}return e},d=function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},h=function(e,t){return"object"!=typeof e||"null"===t},v=function(e){var t=q(e);if(h(e,t))return e;var n=y(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,v(e))})):"set"===t?e.forEach((function(e){n.add(v(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=v(r)})),n},y=function(e,t){switch(void 0===t&&(t={}),e){case"array":return[];case"function":return t;case"set":return new Set;case"map":return new Map;case"date":return new Date(t);case"regExp":return new RegExp(t);case"math":return Math;default:return{}}},g=function(e){function t(){}return t.prototype=e,new t},b=function(e,t){return void 0===t&&(t=function(){}),t.prototype=g(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},m=function(e,t){void 0===t&&(t=!1);for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return e._instance&&!t||(e._instance=new(e.bind.apply(e,c([void 0],n,!1)))),e._instance},w=function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},j=function(e){if("string"!==q(e))return null;try{return JSON.parse(e)}catch(e){return null}},O=function(e){if(!k(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},E=function(e){return e&&e===e.window},T={getValue:l,setValue:f,mixIn:p,enumInversion:d,isNotObject:h,cloneDeep:v,createObjectVariable:y,createObject:g,inherit:b,getInstance:m,classDecorator:w,stringToJson:j,jsonToString:O,isWindow:E},P=function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},S=function(e){var t={};return e.includes("?")?(e.split("?")[1].split("&").forEach((function(e){var n=e.split("=")[0];t[n]=e.split("=")[1]})),t):t},x=function(e,t){void 0===t&&(t={});var n=Object.keys(t);if(0===n.length)return e;var r=n.map((function(e){return"".concat(e,"=").concat(t[e])}));return"".concat(e).concat(e.includes("?")?"&":"?").concat(r.join("&"))},q=function(t){var n=typeof t;if(null===t)return"null";if("object"===n){var r=Object.prototype.toString.call(t);return e.types[r]}return n},k=function(e,t){void 0===t&&(t=[]);var n=q(e);return t.indexOf(n)>0},D={randomNum:P,urlSplit:S,urlJoin:x,getType:q,getTypeByList:k},H=function(e){return e.sort((function(){return Math.random()-.5}))},L=function(e){return Array.from(new Set(e))},A=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===q(e)?A(e,t):t.push(e)})),t},B={arrayRandom:H,arrayUniq:L,arrayDemote:A},C=void 0,I=function(e,t){var n=null;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n||(n=setTimeout((function(){e.call.apply(e,c([C],r,!1)),n=null}),t))}},M=function(e,t){var n=null;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n&&(clearTimeout(n),n=null),n=setTimeout((function(){e.call.apply(e,c([C],r,!1))}),t)}},_=function(e){var t,n;return void 0===e&&(e=0),e>0&&setTimeout(n,e),{promise:new Promise((function(e,r){t=e,n=r})),resolve:t,reject:n}},R=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},F={throttle:I,debounce:M,defer:_,catchAwait:R},N=function(e){var t,n,r=e.ele,o=e.style,i=e.attr,u=e.parent,a=r instanceof HTMLElement?r:document.createElement(null!=r?r:"div");return o&&(null===(t=Object.keys(o))||void 0===t||t.forEach((function(e){return a.style[e]=o[e]}))),i&&(null===(n=Object.keys(o))||void 0===n||n.forEach((function(e){return a[e]=i[e]}))),u&&u.appendChild(a),a},W={createElement:N};e.types=void 0,(s=e.types||(e.types={}))["[object Array]"]="array",s["[object Object]"]="object",s["[object Function]"]="function",s["[object Set]"]="set",s["[object Map]"]="map",s["[object WeakMap]"]="weakMap",s["[object WeakSet]"]="weakSet",s["[object Date]"]="date",s["[object RegExp]"]="regExp",s["[object Math]"]="math";var U={types:e.types};
2
- /**
3
- * @author Toru Nagashima <https://github.com/mysticatea>
4
- * @copyright 2015 Toru Nagashima. All rights reserved.
5
- * See LICENSE file in root directory for full license.
6
- */const V=new WeakMap,G=new WeakMap;function J(e){const t=V.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function Q(e){null==e.passiveListener?e.event.cancelable&&(e.canceled=!0,"function"==typeof e.event.preventDefault&&e.event.preventDefault()):"undefined"!=typeof console&&"function"==typeof console.error&&console.error("Unable to preventDefault inside passive event listener invocation.",e.passiveListener)}function $(e,t){V.set(this,{eventTarget:e,event:t,eventPhase:2,currentTarget:e,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:t.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});const n=Object.keys(t);for(let e=0;e<n.length;++e){const t=n[e];t in this||Object.defineProperty(this,t,K(t))}}function K(e){return{get(){return J(this).event[e]},set(t){J(this).event[e]=t},configurable:!0,enumerable:!0}}function z(e){return{value(){const t=J(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function X(e){if(null==e||e===Object.prototype)return $;let t=G.get(e);return null==t&&(t=function(e,t){const n=Object.keys(t);if(0===n.length)return e;function r(t,n){e.call(this,t,n)}r.prototype=Object.create(e.prototype,{constructor:{value:r,configurable:!0,writable:!0}});for(let o=0;o<n.length;++o){const i=n[o];if(!(i in e.prototype)){const e="function"==typeof Object.getOwnPropertyDescriptor(t,i).value;Object.defineProperty(r.prototype,i,e?z(i):K(i))}}return r}(X(Object.getPrototypeOf(e)),e),G.set(e,t)),t}function Y(e){return J(e).immediateStopped}function Z(e,t){J(e).passiveListener=t}$.prototype={get type(){return J(this).event.type},get target(){return J(this).eventTarget},get currentTarget(){return J(this).currentTarget},composedPath(){const e=J(this).currentTarget;return null==e?[]:[e]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return J(this).eventPhase},stopPropagation(){const e=J(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=J(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(J(this).event.bubbles)},get cancelable(){return Boolean(J(this).event.cancelable)},preventDefault(){Q(J(this))},get defaultPrevented(){return J(this).canceled},get composed(){return Boolean(J(this).event.composed)},get timeStamp(){return J(this).timeStamp},get srcElement(){return J(this).eventTarget},get cancelBubble(){return J(this).stopped},set cancelBubble(e){if(!e)return;const t=J(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!J(this).canceled},set returnValue(e){e||Q(J(this))},initEvent(){}},Object.defineProperty($.prototype,"constructor",{value:$,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf($.prototype,window.Event.prototype),G.set(window.Event.prototype,$));const ee=new WeakMap,te=3;function ne(e){return null!==e&&"object"==typeof e}function re(e){const t=ee.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function oe(e,t){Object.defineProperty(e,`on${t}`,function(e){return{get(){let t=re(this).get(e);for(;null!=t;){if(t.listenerType===te)return t.listener;t=t.next}return null},set(t){"function"==typeof t||ne(t)||(t=null);const n=re(this);let r=null,o=n.get(e);for(;null!=o;)o.listenerType===te?null!==r?r.next=o.next:null!==o.next?n.set(e,o.next):n.delete(e):r=o,o=o.next;if(null!==t){const o={listener:t,listenerType:te,passive:!1,once:!1,next:null};null===r?n.set(e,o):r.next=o}},configurable:!0,enumerable:!0}}(t))}function ie(e){function t(){ue.call(this)}t.prototype=Object.create(ue.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let n=0;n<e.length;++n)oe(t.prototype,e[n]);return t}function ue(){if(!(this instanceof ue)){if(1===arguments.length&&Array.isArray(arguments[0]))return ie(arguments[0]);if(arguments.length>0){const e=new Array(arguments.length);for(let t=0;t<arguments.length;++t)e[t]=arguments[t];return ie(e)}throw new TypeError("Cannot call a class as a function")}ee.set(this,new Map)}ue.prototype={addEventListener(e,t,n){if(null==t)return;if("function"!=typeof t&&!ne(t))throw new TypeError("'listener' should be a function or an object.");const r=re(this),o=ne(n),i=(o?Boolean(n.capture):Boolean(n))?1:2,u={listener:t,listenerType:i,passive:o&&Boolean(n.passive),once:o&&Boolean(n.once),next:null};let a=r.get(e);if(void 0===a)return void r.set(e,u);let c=null;for(;null!=a;){if(a.listener===t&&a.listenerType===i)return;c=a,a=a.next}c.next=u},removeEventListener(e,t,n){if(null==t)return;const r=re(this),o=(ne(n)?Boolean(n.capture):Boolean(n))?1:2;let i=null,u=r.get(e);for(;null!=u;){if(u.listener===t&&u.listenerType===o)return void(null!==i?i.next=u.next:null!==u.next?r.set(e,u.next):r.delete(e));i=u,u=u.next}},dispatchEvent(e){if(null==e||"string"!=typeof e.type)throw new TypeError('"event.type" should be a string.');const t=re(this),n=e.type;let r=t.get(n);if(null==r)return!0;const o=function(e,t){return new(X(Object.getPrototypeOf(t)))(e,t)}(this,e);let i=null;for(;null!=r;){if(r.once?null!==i?i.next=r.next:null!==r.next?t.set(n,r.next):t.delete(n):i=r,Z(o,r.passive?r.listener:null),"function"==typeof r.listener)try{r.listener.call(this,o)}catch(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e)}else r.listenerType!==te&&"function"==typeof r.listener.handleEvent&&r.listener.handleEvent(o);if(Y(o))break;r=r.next}return Z(o,null),function(e,t){J(e).eventPhase=t}(o,0),function(e,t){J(e).currentTarget=t}(o,null),!o.defaultPrevented}},Object.defineProperty(ue.prototype,"constructor",{value:ue,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(ue.prototype,window.EventTarget.prototype);class ae extends ue{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){const e=ce.get(this);if("boolean"!=typeof e)throw new TypeError("Expected 'this' to be an 'AbortSignal' object, but got "+(null===this?"null":typeof this));return e}}oe(ae.prototype,"abort");const ce=new WeakMap;Object.defineProperties(ae.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ae.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});class se{constructor(){le.set(this,function(){const e=Object.create(ae.prototype);return ue.call(e),ce.set(e,!1),e}())}get signal(){return fe(this)}abort(){var e;e=fe(this),!1===ce.get(e)&&(ce.set(e,!0),e.dispatchEvent({type:"abort"}))}}const le=new WeakMap;function fe(e){const t=le.get(e);if(null==t)throw new TypeError("Expected 'this' to be an 'AbortController' object, but got "+(null===e?"null":typeof e));return t}Object.defineProperties(se.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(se.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});var pe=function(e){function t(t){var n=e.call(this)||this;return n.chackUrl=function(e){return e.startsWith("/")},n.checkIsHttps=function(e){return e.startsWith("https")},n.fixOrigin=function(e){return n.chackUrl(e)?n.origin+e:e},n.envDesc=function(){return"undefined"!=typeof Window?"Window":"Node"},n.errorFn=function(e){return function(t){var r,o;return e(null!==(o=null===(r=n.errFn)||void 0===r?void 0:r.call(n,t))&&void 0!==o?o:t)}},n.clearTimer=function(e){return!!e.timer&&(clearTimeout(e.timer),e.timer=null)},n.initAbort=function(e){var t=e.controller,n=e.timer,r=e.timeout;return!n&&(e.timer=setTimeout((function(){return t.abort()}),r)),e},n.requestType=function(){switch(n.envDesc()){case"Window":return n.fetch;case"Node":return n.http}},n.getDataByType=function(e,t){switch(e){case"text":case"json":case"blob":case"formData":case"arrayBuffer":return t[e]();default:return t.json()}},n.formatBodyString=function(e){return{text:function(){return e},json:function(){var t;return null!==(t=j(e))&&void 0!==t?t:e},blob:function(){return j(e)},formData:function(){return j(e)},arrayBuffer:function(){return j(e)}}},n.origin=null!=t?t:"",n}return i(t,e),t}(function(){function e(){}return e.prototype.use=function(e,t){switch(e){case"request":this.requestSuccess=t;break;case"response":this.responseSuccess=t;break;case"error":this.error=t}return this},Object.defineProperty(e.prototype,"reqFn",{get:function(){return this.requestSuccess},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"resFn",{get:function(){return this.responseSuccess},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"errFn",{get:function(){return this.error},enumerable:!1,configurable:!0}),e}()),de=function(e){function t(t){var n=e.call(this,t)||this;return n.initDefaultParams=function(e,t){var r,o,i=t.method,c=void 0===i?"GET":i,s=t.query,l=void 0===s?{}:s,f=t.headers,p=void 0===f?{}:f,d=t.body,h=void 0===d?null:d,v=t.timeout,y=void 0===v?3e4:v,g=t.controller,b=void 0===g?new se:g,m=t.type,w=void 0===m?"json":m,j=a(t,["method","query","headers","body","timeout","controller","type"]),E=u({url:e,method:c,query:l,headers:p,body:"GET"===c?null:O(h),timeout:y,signal:null==b?void 0:b.signal,controller:b,type:w,timer:null},j),T=null!==(o=null===(r=n.reqFn)||void 0===r?void 0:r.call(n,E))&&void 0!==o?o:E;return T.url=x(n.fixOrigin(e),E.query),T},n.initFetchParams=function(e,t){return n.initAbort(n.initDefaultParams(e,t))},n.initHttpParams=function(e,t){var o=n.initAbort(n.initDefaultParams(e,t)),i=r.parse(o.url,!0);return u(u({},o),i)},n}return i(t,e),t}(pe),he=function(e){function r(r){var o=e.call(this,r)||this;return o.fetch=function(e,t){var n=_(),r=n.promise,i=n.resolve,u=n.reject,c=o.initFetchParams(e,t),s=c.url,l=a(c,["url"]),f=l.signal;return r.finally((function(){return o.clearTimer(l)})),f.addEventListener("abort",(function(){return o.errorFn(u)})),fetch(s,l).then((function(e){return(null==e?void 0:e.status)>=200&&(null==e?void 0:e.status)<300?o.getDataByType(l.type,e):o.errorFn(u)})).then((function(e){var t,n;return i(null!==(n=null===(t=o.resFn)||void 0===t?void 0:t.call(o,e))&&void 0!==n?n:e)})).catch(o.errorFn(u)),r},o.http=function(e,r){var i=_(),u=i.promise,a=i.resolve,c=i.reject,s=o.initHttpParams(e,r),l=s.signal,f=s.url;u.finally((function(){return o.clearTimer(s)}));var p=(o.checkIsHttps(f)?n.request:t.request)(s,(function(e){if((null==e?void 0:e.statusCode)>=200&&(null==e?void 0:e.statusCode)<300){var t="";return e.setEncoding("utf8"),e.on("data",(function(e){return t+=e})),e.on("end",(function(){var e,n,r=o.getDataByType(s.type,o.formatBodyString(t));a(null!==(n=null===(e=o.resFn)||void 0===e?void 0:e.call(o,r))&&void 0!==n?n:r)}))}return o.errorFn(c)(null==e?void 0:e.statusMessage)}));return l.addEventListener("abort",(function(){return o.errorFn(c)(p.destroy(new Error("request timeout")))})),p.on("error",o.errorFn(c)),p.end(),u},o.GET=function(e,t,n,r){return o.request(e,u({query:t,method:"GET"},r))},o.POST=function(e,t,n,r){return o.request(e,u({query:t,method:"POST",body:n},r))},o.PUT=function(e,t,n,r){return o.request(e,u({query:t,method:"PUT",body:n},r))},o.DELETE=function(e,t,n,r){return o.request(e,u({query:t,method:"DELETE",body:n},r))},o.OPTIONS=function(e,t,n,r){return o.request(e,u({query:t,method:"OPTIONS",body:n},r))},o.HEAD=function(e,t,n,r){return o.request(e,u({query:t,method:"HEAD",body:n},r))},o.PATCH=function(e,t,n,r){return o.request(e,u({query:t,method:"PATCH",body:n},r))},o.request=o.requestType(),o}return i(r,e),r}(de),ve={Request:he},ye=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},ge=function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},be=function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},me=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},we=function(e,t){var n=new Event(t);e.dispatchEvent(n)},je={addHandler:ye,stopBubble:ge,stopDefault:be,removeHandler:me,dispatchEvent:we},Oe=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},Ee=function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},Te=function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}},Pe={setStorage:Oe,getStorage:Ee,clearStorage:Te},Se=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!0),t&&(process.stdout.clearLine(0),process.stdout.cursorTo(0)),process.stdout.write(e),n&&process.stdout.write("\n")},xe=function(e){return Se(e,!0,!1)},qe=["\\","|","/","—","—"],ke=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?qe:n,o=e.isStop,i=void 0!==o&&o,u=e.timer,a=void 0===u?100:u,c=e.index,s=void 0===c?0:c,l=null!==(t=null==r?void 0:r.length)&&void 0!==t?t:0;if(!l)return e;if(i)return xe("\n");s>=l-1&&(s=0);var f=r[s++];return xe(f),setTimeout((function(){e.index=s,ke(e)}),a),e},De={logOneLine:Se,logLoop:ke},He=function(){function e(e){void 0===e&&(e={}),this.options=e,this.events={}}return e.prototype.on=function(e,t){return this.checkHandler(e,t),this.getHandler(e,[]).push(t),this},e.prototype.emit=function(e,t){return this.has(e)&&this.runHandler(e,t),this},e.prototype.un=function(e,t){return this.unHandler(e,t),this},e.prototype.once=function(e,t){var n=this;this.checkHandler(e,t);var r=function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];return n.un(e,r),t.apply(void 0,o)};return this.on(e,r),this},e.prototype.clear=function(){return this.events={},this},e.prototype.has=function(e){return!!this.getHandler(e)},e.prototype.getHandler=function(e,t){var n;return"object"==typeof t&&(this.events[e]=null!==(n=this.events[e])&&void 0!==n?n:t),this.events[e]},e.prototype.handlerLength=function(e){var t,n;return null!==(n=null===(t=this.getHandler(e))||void 0===t?void 0:t.length)&&void 0!==n?n:0},e.prototype.watch=function(e,t){var n=this;this.checkHandler(e,t);return this.on(e,(function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n.emit(n.prefixStr(e),t.apply(void 0,r))})),this},e.prototype.invoke=function(e,t){var n=this;return new Promise((function(r){n.once(n.prefixStr(e),r),n.emit(e,t)}))},e.prototype.runHandler=function(e,t){for(var n=0,r=this.getHandler(e);n<r.length;n++){var o=r[n];o&&o(t)}},e.prototype.unHandler=function(e,t){var n=this.getHandler(e);!t&&(this.events[e]=[]),t&&this.checkHandler(e,t);for(var r=0;r<n.length;r++)n&&n[r]===t&&(n[r]=null)},e.prototype.prefixStr=function(e){return"@".concat(e)},e.prototype.checkHandler=function(e,t){var n=this.options,r=n.blackList,o=void 0===r?[]:r,i=n.maxLen,u=void 0===i?1/0:i,a=this.handlerLength(e);if(0===(null==e?void 0:e.length))throw new Error("type.length can not be 0");if(!t||!e)throw new ReferenceError("type or handler is not defined");if("function"!=typeof t||"string"!=typeof e)throw new TypeError("".concat(t," is not a function or ").concat(e," is not a string"));if(o.includes(e))throw new Error("".concat(e," is not allow"));if(u<=a)throw new Error("the number of ".concat(e," must be less than ").concat(u))},e.Instance=function(e){return e._instance||Object.defineProperty(e,"_instance",{value:new e}),e._instance},e}(),Le=He.Instance(He),Ae=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new He),e},Be=function(){return Be=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Be.apply(this,arguments)},Ce=function(e,t,n,r){var o,i=arguments.length,u=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(u=(i<3?o(u):i>3?o(t,n,u):o(t,n))||u);return i>3&&u&&Object.defineProperty(t,n,u),u},Ie=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Me=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((r=r.apply(e,t||[])).next())}))},_e=function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Re=function(){function e(e){var t=this;this.fix="@~&$",this.init=function(){t.messageCenter.on("push:handler",t.run),t.messageCenter.on("run:success:handler",t.run),t.messageCenter.on("run:success:handler",t.finish),t.messageCenter.on("run:error:handler",t.run),t.messageCenter.on("run:error:handler",t.finish)},this.defineProps=function(e,n){Object.defineProperty(t,n,{value:e})},this.push=function(e){var n;t.checkHandler(e);var r=(n=t.defer()).resolve,o=n.reject,i=n.promise,u=t.fixStr(e.name);return t.queues=t.queues.concat(e.children.map((function(e){return{defer:e,name:u}}))),t.queueTemp[u]=Be(Be({},e),{result:[]}),t.messageCenter.emit("push:handler",o),t.messageCenter.on(u,r),i},this.unshift=function(e){return t.queues.splice(0,e)},this.run=function(e){var n=e.reject;return Me(t,void 0,void 0,(function(){var e,t,r,o,i;return _e(this,(function(u){switch(u.label){case 0:if("pending"===this.stateProxy())return[2,void 0];if(0===this.queues.length)return[2,this.stateProxy("idle")];this.stateProxy("pending"),e=this.unshift(null!==(i=null===(o=this.props)||void 0===o?void 0:o.maxLen)&&void 0!==i?i:10),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,Promise.all(e.map((function(e,t){return e.defer().catch((function(e){return e}))})))];case 2:return t=u.sent(),[2,this.handlerSuccess({res:t,queues:e})];case 3:return r=u.sent(),[2,this.handlerError({reject:n,error:r,queues:e})];case 4:return[2]}}))}))},this.clear=function(){t.queues=[],t.queueTemp={},t.props=null,t.stateProxy("idle"),t.messageCenter.clear()},this.finish=function(e){var n=e.res,r=void 0===n?[]:n,o=e.queues,i=e.error,u=void 0===i?"err":i,a=t.queueTemp;o.forEach((function(e,n){var o,i,c,s=a[e.name];null==s||s.result.push(null!==(o=r[n])&&void 0!==o?o:u),(null===(i=null==s?void 0:s.result)||void 0===i?void 0:i.length)===(null===(c=null==s?void 0:s.children)||void 0===c?void 0:c.length)&&(t.messageCenter.emit(e.name,null==s?void 0:s.result),a[e.name]=null)}))},this.handlerSuccess=function(e){return t.stateProxy("fulfilled"),t.messageCenter.emit("run:success:handler",e)},this.handlerError=function(e){var n=e.reject,r=e.error;return t.stateProxy("rejected"),n&&"function"==typeof n&&n(r),t.messageCenter.emit("run:error:handler",e)},this.stateProxy=function(e){return e&&(t.state=e),t.state},this.defer=function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),resolve:e,reject:t}},this.clear(),e&&this.defineProps(e,"props"),this.init()}return e.prototype.checkHandler=function(e){var t,n;if(!e)throw new ReferenceError("queue is not defined");if(!(e.children instanceof Array)||"object"!=typeof e)throw new TypeError("queue should be an object and queue.children should be an array");if(0===(null===(t=e.children)||void 0===t?void 0:t.length))throw new Error("queue.children.length can not be 0");if(null===(n=e.children)||void 0===n?void 0:n.find((function(e){return function(e){return!e||"function"!=typeof e}(e)})))throw new Error("queueList should have defer")},e.prototype.fixStr=function(e){return"".concat(this.fix).concat(e)},e=Ce([Ae,Ie("design:paramtypes",[Object])],e)}(),Fe=u(u(u(u(u(u(u(u(u(u(u({},T),D),B),F),W),U),ve),je),Pe),De),{eventMessageCenter:He,taskQueueLib:Re});return e.MessageCenter=He,e.Request=he,e.TaskQueue=Re,e.addHandler=ye,e.arrayDemote=A,e.arrayRandom=H,e.arrayUniq=L,e.catchAwait=R,e.classDecorator=w,e.clearStorage=Te,e.cloneDeep=v,e.createElement=N,e.createObject=g,e.createObjectVariable=y,e.debounce=M,e.decoratorMessageCenter=Ae,e.decoratorTaskQueue=function(e){return function(t){t.prototype.taskQueue||(t.prototype.taskQueue=new Re(e))}},e.default=Fe,e.defer=_,e.dispatchEvent=we,e.enumInversion=d,e.getInstance=m,e.getStorage=Ee,e.getType=q,e.getTypeByList=k,e.getValue=l,e.inherit=b,e.isNotObject=h,e.isWindow=E,e.jsonToString=O,e.logLoop=ke,e.logOneLine=Se,e.messageCenter=Le,e.mixIn=p,e.randomNum=P,e.removeHandler=me,e.setStorage=Oe,e.setValue=f,e.stopBubble=ge,e.stopDefault=be,e.stringToJson=j,e.throttle=I,e.urlJoin=x,e.urlSplit=S,Object.defineProperty(e,"__esModule",{value:!0}),e}({},http,https,url);
1
+ var UtilsLib=function(e){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};function r(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function i(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}var u,a=function(e,t,r){void 0===r&&(r="");for(var n=0,o=t.split(".");n<o.length;n++){if(void 0===(e=e[o[n]]))return r}return e},c=function(e,t,r){void 0===r&&(r={});for(var n=t.split("."),o=n[n.length-1],i=e,u=0,a=n;u<a.length;u++){var c=a[u];if("object"!=typeof i&&void 0!==i)return e;!i&&(i={}),!i[c]&&(i[c]={}),o===c&&(i[o]=r),i=i[c]}return e},s=function(e,t,r){var n;for(var o in void 0===t&&(t={}),void 0===r&&(r=!1),t)for(var i in t[o]){var u=null!==(n=e.prototype)&&void 0!==n?n:e;(void 0===e[i]||r)&&(u[i]=t[o][i])}return e},l=function(e){for(var t in e){var r=e[t];"string"!=typeof r||e[r]||(e[r]=t)}return e},f=function(e,t){return"object"!=typeof e||"null"===t},p=function(e){var t=T(e);if(f(e,t))return e;var r=d(t,e);return"map"===t?e.forEach((function(e,t){r.set(t,p(e))})):"set"===t?e.forEach((function(e){r.add(p(e))})):Reflect.ownKeys(e).forEach((function(t){var n=e[t];r[t]=p(n)})),r},d=function(e,t){switch(void 0===t&&(t={}),e){case"array":return[];case"function":return t;case"set":return new Set;case"map":return new Map;case"date":return new Date(t);case"regExp":return new RegExp(t);case"math":return Math;default:return{}}},h=function(e){function t(){}return t.prototype=e,new t},v=function(e,t){return void 0===t&&(t=function(){}),t.prototype=h(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},y=function(e,t){void 0===t&&(t=!1);for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return e._instance&&!t||(e._instance=new(e.bind.apply(e,i([void 0],r,!1)))),e._instance},m=function(e){return function(t){for(var r in e)Reflect.has(t.prototype,r)||(t.prototype[r]=e[r])}},g=function(e){if("string"!==T(e))return null;try{return JSON.parse(e)}catch(e){return null}},b=function(e){if(!S(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},w=function(e){return e&&e===e.window},j={getValue:a,setValue:c,mixIn:s,enumInversion:l,isNotObject:f,cloneDeep:p,createObjectVariable:d,createObject:h,inherit:v,getInstance:y,classDecorator:m,stringToJson:g,jsonToString:b,isWindow:w},O=function(e,t,r){return void 0===r&&(r=!1),Math.floor(Math.random()*(t-e+(r?1:0))+e)},E=function(e){var t={};return e.includes("?")?(e.split("?")[1].split("&").forEach((function(e){var r=e.split("=")[0];t[r]=e.split("=")[1]})),t):t},q=function(e,t){void 0===t&&(t={});var r=Object.keys(t);if(0===r.length)return e;var n=r.map((function(e){return"".concat(e,"=").concat(t[e])}));return"".concat(e).concat(e.includes("?")?"&":"?").concat(n.join("&"))},T=function(t){var r=typeof t;if(null===t)return"null";if("object"===r){var n=Object.prototype.toString.call(t);return e.types[n]}return r},S=function(e,t){void 0===t&&(t=[]);var r=T(e);return t.indexOf(r)>0},P={randomNum:O,urlSplit:E,urlJoin:q,getType:T,getTypeByList:S},x=function(e){return e.sort((function(){return Math.random()-.5}))},k=function(e){return Array.from(new Set(e))},H=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===T(e)?H(e,t):t.push(e)})),t},D={arrayRandom:x,arrayUniq:k,arrayDemote:H},C=void 0,L=function(e,t){var r=null;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];r||(r=setTimeout((function(){e.call.apply(e,i([C],n,!1)),r=null}),t))}},A=function(e,t){var r=null;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];r&&(clearTimeout(r),r=null),r=setTimeout((function(){e.call.apply(e,i([C],n,!1))}),t)}},F=function(e){var t,r;return void 0===e&&(e=0),e>0&&setTimeout(r,e),{promise:new Promise((function(e,n){t=e,r=n})),resolve:t,reject:r}},I=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},M={throttle:L,debounce:A,defer:F,catchAwait:I},R=function(e){var t,r,n=e.ele,o=e.style,i=e.attr,u=e.parent,a=n instanceof HTMLElement?n:document.createElement(null!=n?n:"div");return o&&(null===(t=Object.keys(o))||void 0===t||t.forEach((function(e){return a.style[e]=o[e]}))),i&&(null===(r=Object.keys(o))||void 0===r||r.forEach((function(e){return a[e]=i[e]}))),u&&u.appendChild(a),a},_={createElement:R};e.types=void 0,(u=e.types||(e.types={}))["[object Array]"]="array",u["[object Object]"]="object",u["[object Function]"]="function",u["[object Set]"]="set",u["[object Map]"]="map",u["[object WeakMap]"]="weakMap",u["[object WeakSet]"]="weakSet",u["[object Date]"]="date",u["[object RegExp]"]="regExp",u["[object Math]"]="math";var B,N,W,J,U={types:e.types};"undefined"!=typeof require?(J=require("abort-controller"),B=require("http").request,N=require("https").request,W=require("url").parse):J="undefined"!=typeof AbortController?AbortController:function(){throw new Error("AbortController is not defined")};var V=function(e){function t(t){var r=e.call(this)||this;return r.chackUrl=function(e){return e.startsWith("/")},r.checkIsHttps=function(e){return e.startsWith("https")},r.fixOrigin=function(e){return r.chackUrl(e)?r.origin+e:e},r.envDesc=function(){return"undefined"!=typeof Window?"Window":"Node"},r.errorFn=function(e){return function(t){var n,o;return e(null!==(o=null===(n=r.errFn)||void 0===n?void 0:n.call(r,t))&&void 0!==o?o:t)}},r.clearTimer=function(e){return!!e.timer&&(clearTimeout(e.timer),e.timer=null)},r.initAbort=function(e){var t=e.controller,r=e.timer,n=e.timeout;return!r&&(e.timer=setTimeout((function(){return t.abort()}),n)),e},r.requestType=function(){switch(r.envDesc()){case"Window":return r.fetch;case"Node":return r.http}},r.getDataByType=function(e,t){switch(e){case"text":case"json":case"blob":case"formData":case"arrayBuffer":return t[e]();default:return t.json()}},r.formatBodyString=function(e){return{text:function(){return e},json:function(){var t;return null!==(t=g(e))&&void 0!==t?t:e},blob:function(){return g(e)},formData:function(){return g(e)},arrayBuffer:function(){return g(e)}}},r.origin=null!=t?t:"",r}return r(t,e),t}(function(){function e(){}return e.prototype.use=function(e,t){switch(e){case"request":this.requestSuccess=t;break;case"response":this.responseSuccess=t;break;case"error":this.error=t}return this},Object.defineProperty(e.prototype,"reqFn",{get:function(){return this.requestSuccess},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"resFn",{get:function(){return this.responseSuccess},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"errFn",{get:function(){return this.error},enumerable:!1,configurable:!0}),e}()),G=function(e){function t(t){var r=e.call(this,t)||this;return r.initDefaultParams=function(e,t){var i,u,a=t.method,c=void 0===a?"GET":a,s=t.query,l=void 0===s?{}:s,f=t.headers,p=void 0===f?{}:f,d=t.body,h=void 0===d?null:d,v=t.timeout,y=void 0===v?3e4:v,m=t.controller,g=void 0===m?new J:m,w=t.type,j=void 0===w?"json":w,O=o(t,["method","query","headers","body","timeout","controller","type"]),E=n({url:e,method:c,query:l,headers:p,body:"GET"===c?null:b(h),timeout:y,signal:null==g?void 0:g.signal,controller:g,type:j,timer:null},O),T=null!==(u=null===(i=r.reqFn)||void 0===i?void 0:i.call(r,E))&&void 0!==u?u:E;return T.url=q(r.fixOrigin(e),E.query),T},r.initFetchParams=function(e,t){return r.initAbort(r.initDefaultParams(e,t))},r.initHttpParams=function(e,t){var o=r.initAbort(r.initDefaultParams(e,t)),i=W(o.url,!0);return n(n({},o),i)},r}return r(t,e),t}(V),Q=function(e){function t(t){var r=e.call(this,t)||this;return r.fetch=function(e,t){var n=F(),i=n.promise,u=n.resolve,a=n.reject,c=r.initFetchParams(e,t),s=c.url,l=o(c,["url"]),f=l.signal;return i.finally((function(){return r.clearTimer(l)})),f.addEventListener("abort",(function(){return r.errorFn(a)})),fetch(s,l).then((function(e){return(null==e?void 0:e.status)>=200&&(null==e?void 0:e.status)<300?r.getDataByType(l.type,e):r.errorFn(a)})).then((function(e){var t,n;return u(null!==(n=null===(t=r.resFn)||void 0===t?void 0:t.call(r,e))&&void 0!==n?n:e)})).catch(r.errorFn(a)),i},r.http=function(e,t){var n=F(),o=n.promise,i=n.resolve,u=n.reject,a=r.initHttpParams(e,t),c=a.signal,s=a.url;o.finally((function(){return r.clearTimer(a)}));var l=(r.checkIsHttps(s)?N:B)(a,(function(e){var t=e.statusCode,n=e.statusMessage,o=e.data;if(t>=200&&t<300){var c="";return e.setEncoding("utf8"),e.on("data",(function(e){return c+=e})),e.on("end",(function(){var e,t,n=r.getDataByType(a.type,r.formatBodyString(c));i(null!==(t=null===(e=r.resFn)||void 0===e?void 0:e.call(r,n))&&void 0!==t?t:n)}))}return r.errorFn(u)({statusCode:t,statusMessage:n,data:o})}));return c.addEventListener("abort",(function(){return r.errorFn(u)(l.destroy(new Error("request timeout")))})),l.on("error",r.errorFn(u)),l.end(),o},r.GET=function(e,t,o,i){return r.request(e,n({query:t,method:"GET"},i))},r.POST=function(e,t,o,i){return r.request(e,n({query:t,method:"POST",body:o},i))},r.PUT=function(e,t,o,i){return r.request(e,n({query:t,method:"PUT",body:o},i))},r.DELETE=function(e,t,o,i){return r.request(e,n({query:t,method:"DELETE",body:o},i))},r.OPTIONS=function(e,t,o,i){return r.request(e,n({query:t,method:"OPTIONS",body:o},i))},r.HEAD=function(e,t,o,i){return r.request(e,n({query:t,method:"HEAD",body:o},i))},r.PATCH=function(e,t,o,i){return r.request(e,n({query:t,method:"PATCH",body:o},i))},r.request=r.requestType(),r}return r(t,e),t}(G),K={Request:Q},$=function(e,t,r){e.addEventListener?e.addEventListener(t,r,!1):e["on"+t]=r},z=function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},X=function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},Y=function(e,t,r){e.removeEventListener?e.removeEventListener(t,r,!1):e["on"+t]=null},Z=function(e,t){var r=new Event(t);e.dispatchEvent(r)},ee={addHandler:$,stopBubble:z,stopDefault:X,removeHandler:Y,dispatchEvent:Z},te=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},re=function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},ne=function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}},oe={setStorage:te,getStorage:re,clearStorage:ne},ie=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!0),t&&(process.stdout.clearLine(0),process.stdout.cursorTo(0)),process.stdout.write(e),r&&process.stdout.write("\n")},ue=function(e){return ie(e,!0,!1)},ae=["\\","|","/","—","—"],ce=function(e){var t;void 0===e&&(e={});var r=e.loopList,n=void 0===r?ae:r,o=e.isStop,i=void 0!==o&&o,u=e.timer,a=void 0===u?100:u,c=e.index,s=void 0===c?0:c,l=null!==(t=null==n?void 0:n.length)&&void 0!==t?t:0;if(!l)return e;if(i)return ue("\n");s>=l-1&&(s=0);var f=n[s++];return ue(f),setTimeout((function(){e.index=s,ce(e)}),a),e},se={logOneLine:ie,logLoop:ce},le=function(){function e(e){void 0===e&&(e={}),this.options=e,this.events={}}return e.prototype.on=function(e,t){return this.checkHandler(e,t),this.getHandler(e,[]).push(t),this},e.prototype.emit=function(e,t){return this.has(e)&&this.runHandler(e,t),this},e.prototype.un=function(e,t){return this.unHandler(e,t),this},e.prototype.once=function(e,t){var r=this;this.checkHandler(e,t);var n=function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];return r.un(e,n),t.apply(void 0,o)};return this.on(e,n),this},e.prototype.clear=function(){return this.events={},this},e.prototype.has=function(e){return!!this.getHandler(e)},e.prototype.getHandler=function(e,t){var r;return"object"==typeof t&&(this.events[e]=null!==(r=this.events[e])&&void 0!==r?r:t),this.events[e]},e.prototype.handlerLength=function(e){var t,r;return null!==(r=null===(t=this.getHandler(e))||void 0===t?void 0:t.length)&&void 0!==r?r:0},e.prototype.watch=function(e,t){var r=this;this.checkHandler(e,t);return this.on(e,(function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];r.emit(r.prefixStr(e),t.apply(void 0,n))})),this},e.prototype.invoke=function(e,t){var r=this;return new Promise((function(n){r.once(r.prefixStr(e),n),r.emit(e,t)}))},e.prototype.runHandler=function(e,t){for(var r=0,n=this.getHandler(e);r<n.length;r++){var o=n[r];o&&o(t)}},e.prototype.unHandler=function(e,t){var r=this.getHandler(e);!t&&(this.events[e]=[]),t&&this.checkHandler(e,t);for(var n=0;n<r.length;n++)r&&r[n]===t&&(r[n]=null)},e.prototype.prefixStr=function(e){return"@".concat(e)},e.prototype.checkHandler=function(e,t){var r=this.options,n=r.blackList,o=void 0===n?[]:n,i=r.maxLen,u=void 0===i?1/0:i,a=this.handlerLength(e);if(0===(null==e?void 0:e.length))throw new Error("type.length can not be 0");if(!t||!e)throw new ReferenceError("type or handler is not defined");if("function"!=typeof t||"string"!=typeof e)throw new TypeError("".concat(t," is not a function or ").concat(e," is not a string"));if(o.includes(e))throw new Error("".concat(e," is not allow"));if(u<=a)throw new Error("the number of ".concat(e," must be less than ").concat(u))},e.Instance=function(e){return e._instance||Object.defineProperty(e,"_instance",{value:new e}),e._instance},e}(),fe=le.Instance(le),pe=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new le),e},de=function(){return de=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},de.apply(this,arguments)},he=function(e,t,r,n){var o,i=arguments.length,u=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(u=(i<3?o(u):i>3?o(t,r,u):o(t,r))||u);return i>3&&u&&Object.defineProperty(t,r,u),u},ve=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ye=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function u(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(u,a)}c((n=n.apply(e,t||[])).next())}))},me=function(e,t){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,n=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},ge=function(){function e(e){var t=this;this.fix="@~&$",this.init=function(){t.messageCenter.on("push:handler",t.run),t.messageCenter.on("run:success:handler",t.run),t.messageCenter.on("run:success:handler",t.finish),t.messageCenter.on("run:error:handler",t.run),t.messageCenter.on("run:error:handler",t.finish)},this.defineProps=function(e,r){Object.defineProperty(t,r,{value:e})},this.push=function(e){var r;t.checkHandler(e);var n=(r=t.defer()).resolve,o=r.reject,i=r.promise,u=t.fixStr(e.name);return t.queues=t.queues.concat(e.children.map((function(e){return{defer:e,name:u}}))),t.queueTemp[u]=de(de({},e),{result:[]}),t.messageCenter.emit("push:handler",o),t.messageCenter.on(u,n),i},this.unshift=function(e){return t.queues.splice(0,e)},this.run=function(e){var r=e.reject;return ye(t,void 0,void 0,(function(){var e,t,n,o,i;return me(this,(function(u){switch(u.label){case 0:if("pending"===this.stateProxy())return[2,void 0];if(0===this.queues.length)return[2,this.stateProxy("idle")];this.stateProxy("pending"),e=this.unshift(null!==(i=null===(o=this.props)||void 0===o?void 0:o.maxLen)&&void 0!==i?i:10),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,Promise.all(e.map((function(e,t){return e.defer().catch((function(e){return e}))})))];case 2:return t=u.sent(),[2,this.handlerSuccess({res:t,queues:e})];case 3:return n=u.sent(),[2,this.handlerError({reject:r,error:n,queues:e})];case 4:return[2]}}))}))},this.clear=function(){t.queues=[],t.queueTemp={},t.props=null,t.stateProxy("idle"),t.messageCenter.clear()},this.finish=function(e){var r=e.res,n=void 0===r?[]:r,o=e.queues,i=e.error,u=void 0===i?"err":i,a=t.queueTemp;o.forEach((function(e,r){var o,i,c,s=a[e.name];null==s||s.result.push(null!==(o=n[r])&&void 0!==o?o:u),(null===(i=null==s?void 0:s.result)||void 0===i?void 0:i.length)===(null===(c=null==s?void 0:s.children)||void 0===c?void 0:c.length)&&(t.messageCenter.emit(e.name,null==s?void 0:s.result),a[e.name]=null)}))},this.handlerSuccess=function(e){return t.stateProxy("fulfilled"),t.messageCenter.emit("run:success:handler",e)},this.handlerError=function(e){var r=e.reject,n=e.error;return t.stateProxy("rejected"),r&&"function"==typeof r&&r(n),t.messageCenter.emit("run:error:handler",e)},this.stateProxy=function(e){return e&&(t.state=e),t.state},this.defer=function(){var e,t;return{promise:new Promise((function(r,n){e=r,t=n})),resolve:e,reject:t}},this.clear(),e&&this.defineProps(e,"props"),this.init()}return e.prototype.checkHandler=function(e){var t,r;if(!e)throw new ReferenceError("queue is not defined");if(!(e.children instanceof Array)||"object"!=typeof e)throw new TypeError("queue should be an object and queue.children should be an array");if(0===(null===(t=e.children)||void 0===t?void 0:t.length))throw new Error("queue.children.length can not be 0");if(null===(r=e.children)||void 0===r?void 0:r.find((function(e){return function(e){return!e||"function"!=typeof e}(e)})))throw new Error("queueList should have defer")},e.prototype.fixStr=function(e){return"".concat(this.fix).concat(e)},e=he([pe,ve("design:paramtypes",[Object])],e)}(),be=n(n(n(n(n(n(n(n(n(n(n({},j),P),D),M),_),U),K),ee),oe),se),{eventMessageCenter:le,taskQueueLib:ge});return e.MessageCenter=le,e.Request=Q,e.TaskQueue=ge,e.addHandler=$,e.arrayDemote=H,e.arrayRandom=x,e.arrayUniq=k,e.catchAwait=I,e.classDecorator=m,e.clearStorage=ne,e.cloneDeep=p,e.createElement=R,e.createObject=h,e.createObjectVariable=d,e.debounce=A,e.decoratorMessageCenter=pe,e.decoratorTaskQueue=function(e){return function(t){t.prototype.taskQueue||(t.prototype.taskQueue=new ge(e))}},e.default=be,e.defer=F,e.dispatchEvent=Z,e.enumInversion=l,e.getInstance=y,e.getStorage=re,e.getType=T,e.getTypeByList=S,e.getValue=a,e.inherit=v,e.isNotObject=f,e.isWindow=w,e.jsonToString=b,e.logLoop=ce,e.logOneLine=ie,e.messageCenter=fe,e.mixIn=s,e.randomNum=O,e.removeHandler=Y,e.setStorage=te,e.setValue=c,e.stopBubble=z,e.stopDefault=X,e.stringToJson=g,e.throttle=L,e.urlJoin=q,e.urlSplit=E,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
@@ -1,5 +1,4 @@
1
1
  import { IRequest, IRequestBase, IRequestInit, IInterceptors, IUrl, IObject, IRequestBody, IRequestOptions, IRequestBaseFn, IEnv } from "./index";
2
- import CustomAbortController from "abort-controller";
3
2
  declare class Interceptors implements IInterceptors {
4
3
  private requestSuccess;
5
4
  private responseSuccess;
@@ -36,7 +35,7 @@ declare abstract class RequestInit extends RequestBase implements IRequestInit {
36
35
  headers?: {};
37
36
  body?: any;
38
37
  timeout?: number;
39
- controller?: CustomAbortController;
38
+ controller?: any;
40
39
  type?: string;
41
40
  }) => IRequestOptions;
42
41
  initFetchParams: (url: IUrl, opts: IRequestOptions) => any;