utils-lib-js 1.7.5 → 1.7.6
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/bundle/index.js +1 -1
- package/dist/cjs/index.js +4 -3
- package/dist/esm/index.js +4 -3
- package/dist/umd/index.js +4 -3
- package/package.json +1 -1
package/dist/bundle/index.js
CHANGED
|
@@ -3,4 +3,4 @@ var UtilsLib=function(e,t,n,r){"use strict";var o=function(e,t){return o=Object.
|
|
|
3
3
|
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
4
4
|
* @copyright 2015 Toru Nagashima. All rights reserved.
|
|
5
5
|
* See LICENSE file in root directory for full license.
|
|
6
|
-
*/const U=new WeakMap,V=new WeakMap;function G(e){const t=U.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function J(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 Q(e,t){U.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,$(t))}}function $(e){return{get(){return G(this).event[e]},set(t){G(this).event[e]=t},configurable:!0,enumerable:!0}}function K(e){return{value(){const t=G(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function z(e){if(null==e||e===Object.prototype)return Q;let t=V.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?K(i):$(i))}}return r}(z(Object.getPrototypeOf(e)),e),V.set(e,t)),t}function X(e){return G(e).immediateStopped}function Y(e,t){G(e).passiveListener=t}Q.prototype={get type(){return G(this).event.type},get target(){return G(this).eventTarget},get currentTarget(){return G(this).currentTarget},composedPath(){const e=G(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 G(this).eventPhase},stopPropagation(){const e=G(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=G(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(G(this).event.bubbles)},get cancelable(){return Boolean(G(this).event.cancelable)},preventDefault(){J(G(this))},get defaultPrevented(){return G(this).canceled},get composed(){return Boolean(G(this).event.composed)},get timeStamp(){return G(this).timeStamp},get srcElement(){return G(this).eventTarget},get cancelBubble(){return G(this).stopped},set cancelBubble(e){if(!e)return;const t=G(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!G(this).canceled},set returnValue(e){e||J(G(this))},initEvent(){}},Object.defineProperty(Q.prototype,"constructor",{value:Q,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf(Q.prototype,window.Event.prototype),V.set(window.Event.prototype,Q));const Z=new WeakMap,ee=3;function te(e){return null!==e&&"object"==typeof e}function ne(e){const t=Z.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function re(e,t){Object.defineProperty(e,`on${t}`,function(e){return{get(){let t=ne(this).get(e);for(;null!=t;){if(t.listenerType===ee)return t.listener;t=t.next}return null},set(t){"function"==typeof t||te(t)||(t=null);const n=ne(this);let r=null,o=n.get(e);for(;null!=o;)o.listenerType===ee?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:ee,passive:!1,once:!1,next:null};null===r?n.set(e,o):r.next=o}},configurable:!0,enumerable:!0}}(t))}function oe(e){function t(){ie.call(this)}t.prototype=Object.create(ie.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let n=0;n<e.length;++n)re(t.prototype,e[n]);return t}function ie(){if(!(this instanceof ie)){if(1===arguments.length&&Array.isArray(arguments[0]))return oe(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 oe(e)}throw new TypeError("Cannot call a class as a function")}Z.set(this,new Map)}ie.prototype={addEventListener(e,t,n){if(null==t)return;if("function"!=typeof t&&!te(t))throw new TypeError("'listener' should be a function or an object.");const r=ne(this),o=te(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=ne(this),o=(te(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=ne(this),n=e.type;let r=t.get(n);if(null==r)return!0;const o=function(e,t){return new(z(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,Y(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!==ee&&"function"==typeof r.listener.handleEvent&&r.listener.handleEvent(o);if(X(o))break;r=r.next}return Y(o,null),function(e,t){G(e).eventPhase=t}(o,0),function(e,t){G(e).currentTarget=t}(o,null),!o.defaultPrevented}},Object.defineProperty(ie.prototype,"constructor",{value:ie,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(ie.prototype,window.EventTarget.prototype);class ue extends ie{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){const e=ae.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}}re(ue.prototype,"abort");const ae=new WeakMap;Object.defineProperties(ue.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ue.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});class ce{constructor(){le.set(this,function(){const e=Object.create(ue.prototype);return ie.call(e),ae.set(e,!1),e}())}get signal(){return se(this)}abort(){var e;e=se(this),!1===ae.get(e)&&(ae.set(e,!0),e.dispatchEvent({type:"abort"}))}}const le=new WeakMap;function se(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(ce.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ce.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});var fe=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}()),pe=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,l=t.query,s=void 0===l?{}:l,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 ce: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:s,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=S(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}(fe),de=function(e){function r(r){var o=e.call(this,r)||this;return o.fetch=function(e,t){var n=M(),r=n.promise,i=n.resolve,u=n.reject,c=o.initFetchParams(e,t),l=c.url,s=a(c,["url"]),f=s.signal;return r.finally((function(){return o.clearTimer(s)})),f.addEventListener("abort",(function(){return o.errorFn(u)})),fetch(l,s).then((function(e){return(null==e?void 0:e.status)>=200&&(null==e?void 0:e.status)<300?o.getDataByType(s.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=M(),u=i.promise,a=i.resolve,c=i.reject,l=o.initHttpParams(e,r),s=l.signal,f=l.url;u.finally((function(){return o.clearTimer(l)}));var p=(o.checkIsHttps(f)?n.request:t.request)(l,(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(l.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 s.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}(pe),he={Request:de},ve=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},ye=function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},ge=function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},be=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},me=function(e,t){var n=new Event(t);e.dispatchEvent(n)},we={addHandler:ve,stopBubble:ye,stopDefault:ge,removeHandler:be,dispatchEvent:me},je=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},Oe=function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},Ee=function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}},Te={setStorage:je,getStorage:Oe,clearStorage:Ee},Pe=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")},Se=function(e){return Pe(e,!0,!1)},xe=function(e){var t,n=e.loopList,r=e.isStop,o=void 0!==r&&r,i=e.timer,u=void 0===i?100:i,a=e.index,c=void 0===a?0:a,l=null!==(t=null==n?void 0:n.length)&&void 0!==t?t:0;if(l){if(o)return Se("\n");c>=l-1&&(c=0);var s=n[c++];return Se(s),setTimeout((function(){e.index=c,xe(e)}),u),e}},qe={logOneLine:Pe,logLoop:xe},ke=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}(),De=ke.Instance(ke),He=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new ke),e},Le=function(){return Le=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},Le.apply(this,arguments)},Ae=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},Be=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ce=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())}))},Ie=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])}}},Me=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]=Le(Le({},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 Ce(t,void 0,void 0,(function(){var e,t,r,o,i;return Ie(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,l=a[e.name];null==l||l.result.push(null!==(o=r[n])&&void 0!==o?o:u),(null===(i=null==l?void 0:l.result)||void 0===i?void 0:i.length)===(null===(c=null==l?void 0:l.children)||void 0===c?void 0:c.length)&&(t.messageCenter.emit(e.name,null==l?void 0:l.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=Ae([He,Be("design:paramtypes",[Object])],e)}(),_e=u(u(u(u(u(u(u(u(u(u(u({},E),k),A),R),N),W),he),we),Te),qe),{eventMessageCenter:ke,taskQueueLib:Me});return e.MessageCenter=ke,e.Request=de,e.TaskQueue=Me,e.addHandler=ve,e.arrayDemote=L,e.arrayRandom=D,e.arrayUniq=H,e.catchAwait=_,e.classDecorator=w,e.clearStorage=Ee,e.cloneDeep=v,e.createElement=F,e.createObject=g,e.createObjectVariable=y,e.debounce=I,e.decoratorMessageCenter=He,e.decoratorTaskQueue=function(e){return function(t){t.prototype.taskQueue||(t.prototype.taskQueue=new Me(e))}},e.default=_e,e.defer=M,e.dispatchEvent=me,e.enumInversion=d,e.getInstance=m,e.getStorage=Oe,e.getType=x,e.getTypeByList=q,e.getValue=s,e.inherit=b,e.isNotObject=h,e.jsonToString=O,e.logLoop=xe,e.logOneLine=Pe,e.messageCenter=De,e.mixIn=p,e.randomNum=T,e.removeHandler=be,e.setStorage=je,e.setValue=f,e.stopBubble=ye,e.stopDefault=ge,e.stringToJson=j,e.throttle=C,e.urlJoin=S,e.urlSplit=P,Object.defineProperty(e,"__esModule",{value:!0}),e}({},http,https,url);
|
|
6
|
+
*/const U=new WeakMap,V=new WeakMap;function G(e){const t=U.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function J(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 Q(e,t){U.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,$(t))}}function $(e){return{get(){return G(this).event[e]},set(t){G(this).event[e]=t},configurable:!0,enumerable:!0}}function K(e){return{value(){const t=G(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function z(e){if(null==e||e===Object.prototype)return Q;let t=V.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?K(i):$(i))}}return r}(z(Object.getPrototypeOf(e)),e),V.set(e,t)),t}function X(e){return G(e).immediateStopped}function Y(e,t){G(e).passiveListener=t}Q.prototype={get type(){return G(this).event.type},get target(){return G(this).eventTarget},get currentTarget(){return G(this).currentTarget},composedPath(){const e=G(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 G(this).eventPhase},stopPropagation(){const e=G(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=G(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(G(this).event.bubbles)},get cancelable(){return Boolean(G(this).event.cancelable)},preventDefault(){J(G(this))},get defaultPrevented(){return G(this).canceled},get composed(){return Boolean(G(this).event.composed)},get timeStamp(){return G(this).timeStamp},get srcElement(){return G(this).eventTarget},get cancelBubble(){return G(this).stopped},set cancelBubble(e){if(!e)return;const t=G(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!G(this).canceled},set returnValue(e){e||J(G(this))},initEvent(){}},Object.defineProperty(Q.prototype,"constructor",{value:Q,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf(Q.prototype,window.Event.prototype),V.set(window.Event.prototype,Q));const Z=new WeakMap,ee=3;function te(e){return null!==e&&"object"==typeof e}function ne(e){const t=Z.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function re(e,t){Object.defineProperty(e,`on${t}`,function(e){return{get(){let t=ne(this).get(e);for(;null!=t;){if(t.listenerType===ee)return t.listener;t=t.next}return null},set(t){"function"==typeof t||te(t)||(t=null);const n=ne(this);let r=null,o=n.get(e);for(;null!=o;)o.listenerType===ee?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:ee,passive:!1,once:!1,next:null};null===r?n.set(e,o):r.next=o}},configurable:!0,enumerable:!0}}(t))}function oe(e){function t(){ie.call(this)}t.prototype=Object.create(ie.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let n=0;n<e.length;++n)re(t.prototype,e[n]);return t}function ie(){if(!(this instanceof ie)){if(1===arguments.length&&Array.isArray(arguments[0]))return oe(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 oe(e)}throw new TypeError("Cannot call a class as a function")}Z.set(this,new Map)}ie.prototype={addEventListener(e,t,n){if(null==t)return;if("function"!=typeof t&&!te(t))throw new TypeError("'listener' should be a function or an object.");const r=ne(this),o=te(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=ne(this),o=(te(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=ne(this),n=e.type;let r=t.get(n);if(null==r)return!0;const o=function(e,t){return new(z(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,Y(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!==ee&&"function"==typeof r.listener.handleEvent&&r.listener.handleEvent(o);if(X(o))break;r=r.next}return Y(o,null),function(e,t){G(e).eventPhase=t}(o,0),function(e,t){G(e).currentTarget=t}(o,null),!o.defaultPrevented}},Object.defineProperty(ie.prototype,"constructor",{value:ie,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(ie.prototype,window.EventTarget.prototype);class ue extends ie{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){const e=ae.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}}re(ue.prototype,"abort");const ae=new WeakMap;Object.defineProperties(ue.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ue.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});class ce{constructor(){le.set(this,function(){const e=Object.create(ue.prototype);return ie.call(e),ae.set(e,!1),e}())}get signal(){return se(this)}abort(){var e;e=se(this),!1===ae.get(e)&&(ae.set(e,!0),e.dispatchEvent({type:"abort"}))}}const le=new WeakMap;function se(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(ce.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ce.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});var fe=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}()),pe=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,l=t.query,s=void 0===l?{}:l,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 ce: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:s,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=S(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}(fe),de=function(e){function r(r){var o=e.call(this,r)||this;return o.fetch=function(e,t){var n=M(),r=n.promise,i=n.resolve,u=n.reject,c=o.initFetchParams(e,t),l=c.url,s=a(c,["url"]),f=s.signal;return r.finally((function(){return o.clearTimer(s)})),f.addEventListener("abort",(function(){return o.errorFn(u)})),fetch(l,s).then((function(e){return(null==e?void 0:e.status)>=200&&(null==e?void 0:e.status)<300?o.getDataByType(s.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=M(),u=i.promise,a=i.resolve,c=i.reject,l=o.initHttpParams(e,r),s=l.signal,f=l.url;u.finally((function(){return o.clearTimer(l)}));var p=(o.checkIsHttps(f)?n.request:t.request)(l,(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(l.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 s.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}(pe),he={Request:de},ve=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},ye=function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},ge=function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},be=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},me=function(e,t){var n=new Event(t);e.dispatchEvent(n)},we={addHandler:ve,stopBubble:ye,stopDefault:ge,removeHandler:be,dispatchEvent:me},je=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},Oe=function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},Ee=function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}},Te={setStorage:je,getStorage:Oe,clearStorage:Ee},Pe=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")},Se=function(e){return Pe(e,!0,!1)},xe=["\\","|","/","—","—"],qe=function(e){var t,n=e.loopList,r=void 0===n?xe:n,o=e.isStop,i=void 0!==o&&o,u=e.timer,a=void 0===u?100:u,c=e.index,l=void 0===c?0:c,s=null!==(t=null==r?void 0:r.length)&&void 0!==t?t:0;if(!s)return e;if(i)return Se("\n");l>=s-1&&(l=0);var f=r[l++];return Se(f),setTimeout((function(){e.index=l,qe(e)}),a),e},ke={logOneLine:Pe,logLoop:qe},De=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}(),He=De.Instance(De),Le=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new De),e},Ae=function(){return Ae=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},Ae.apply(this,arguments)},Be=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},Ce=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ie=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())}))},Me=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])}}},_e=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]=Ae(Ae({},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 Ie(t,void 0,void 0,(function(){var e,t,r,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 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,l=a[e.name];null==l||l.result.push(null!==(o=r[n])&&void 0!==o?o:u),(null===(i=null==l?void 0:l.result)||void 0===i?void 0:i.length)===(null===(c=null==l?void 0:l.children)||void 0===c?void 0:c.length)&&(t.messageCenter.emit(e.name,null==l?void 0:l.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=Be([Le,Ce("design:paramtypes",[Object])],e)}(),Re=u(u(u(u(u(u(u(u(u(u(u({},E),k),A),R),N),W),he),we),Te),ke),{eventMessageCenter:De,taskQueueLib:_e});return e.MessageCenter=De,e.Request=de,e.TaskQueue=_e,e.addHandler=ve,e.arrayDemote=L,e.arrayRandom=D,e.arrayUniq=H,e.catchAwait=_,e.classDecorator=w,e.clearStorage=Ee,e.cloneDeep=v,e.createElement=F,e.createObject=g,e.createObjectVariable=y,e.debounce=I,e.decoratorMessageCenter=Le,e.decoratorTaskQueue=function(e){return function(t){t.prototype.taskQueue||(t.prototype.taskQueue=new _e(e))}},e.default=Re,e.defer=M,e.dispatchEvent=me,e.enumInversion=d,e.getInstance=m,e.getStorage=Oe,e.getType=x,e.getTypeByList=q,e.getValue=s,e.inherit=b,e.isNotObject=h,e.jsonToString=O,e.logLoop=qe,e.logOneLine=Pe,e.messageCenter=He,e.mixIn=p,e.randomNum=T,e.removeHandler=be,e.setStorage=je,e.setValue=f,e.stopBubble=ye,e.stopDefault=ge,e.stringToJson=j,e.throttle=C,e.urlJoin=S,e.urlSplit=P,Object.defineProperty(e,"__esModule",{value:!0}),e}({},http,https,url);
|
package/dist/cjs/index.js
CHANGED
|
@@ -1624,13 +1624,14 @@ var logOneLine = function (str, overwrite, warp) {
|
|
|
1624
1624
|
warp && process.stdout.write("\n");
|
|
1625
1625
|
};
|
|
1626
1626
|
var renderLoop = function (str) { return logOneLine(str, true, false); };
|
|
1627
|
+
var defaultLoopList = ["\\", "|", "/", "\u2014", "\u2014"];
|
|
1627
1628
|
var logLoop = function (opts) {
|
|
1628
1629
|
var _a;
|
|
1629
|
-
var
|
|
1630
|
-
var
|
|
1630
|
+
var _b = opts.loopList, loopList = _b === void 0 ? defaultLoopList : _b, _c = opts.isStop, isStop = _c === void 0 ? false : _c, _d = opts.timer, timer = _d === void 0 ? 100 : _d;
|
|
1631
|
+
var _e = opts.index, index = _e === void 0 ? 0 : _e;
|
|
1631
1632
|
var len = (_a = loopList === null || loopList === void 0 ? void 0 : loopList.length) !== null && _a !== void 0 ? _a : 0;
|
|
1632
1633
|
if (!!!len)
|
|
1633
|
-
return;
|
|
1634
|
+
return opts;
|
|
1634
1635
|
if (isStop)
|
|
1635
1636
|
return renderLoop("\n");
|
|
1636
1637
|
if (index >= len - 1)
|
package/dist/esm/index.js
CHANGED
|
@@ -1620,13 +1620,14 @@ var logOneLine = function (str, overwrite, warp) {
|
|
|
1620
1620
|
warp && process.stdout.write("\n");
|
|
1621
1621
|
};
|
|
1622
1622
|
var renderLoop = function (str) { return logOneLine(str, true, false); };
|
|
1623
|
+
var defaultLoopList = ["\\", "|", "/", "\u2014", "\u2014"];
|
|
1623
1624
|
var logLoop = function (opts) {
|
|
1624
1625
|
var _a;
|
|
1625
|
-
var
|
|
1626
|
-
var
|
|
1626
|
+
var _b = opts.loopList, loopList = _b === void 0 ? defaultLoopList : _b, _c = opts.isStop, isStop = _c === void 0 ? false : _c, _d = opts.timer, timer = _d === void 0 ? 100 : _d;
|
|
1627
|
+
var _e = opts.index, index = _e === void 0 ? 0 : _e;
|
|
1627
1628
|
var len = (_a = loopList === null || loopList === void 0 ? void 0 : loopList.length) !== null && _a !== void 0 ? _a : 0;
|
|
1628
1629
|
if (!!!len)
|
|
1629
|
-
return;
|
|
1630
|
+
return opts;
|
|
1630
1631
|
if (isStop)
|
|
1631
1632
|
return renderLoop("\n");
|
|
1632
1633
|
if (index >= len - 1)
|
package/dist/umd/index.js
CHANGED
|
@@ -1622,13 +1622,14 @@
|
|
|
1622
1622
|
warp && process.stdout.write("\n");
|
|
1623
1623
|
};
|
|
1624
1624
|
var renderLoop = function (str) { return logOneLine(str, true, false); };
|
|
1625
|
+
var defaultLoopList = ["\\", "|", "/", "\u2014", "\u2014"];
|
|
1625
1626
|
var logLoop = function (opts) {
|
|
1626
1627
|
var _a;
|
|
1627
|
-
var
|
|
1628
|
-
var
|
|
1628
|
+
var _b = opts.loopList, loopList = _b === void 0 ? defaultLoopList : _b, _c = opts.isStop, isStop = _c === void 0 ? false : _c, _d = opts.timer, timer = _d === void 0 ? 100 : _d;
|
|
1629
|
+
var _e = opts.index, index = _e === void 0 ? 0 : _e;
|
|
1629
1630
|
var len = (_a = loopList === null || loopList === void 0 ? void 0 : loopList.length) !== null && _a !== void 0 ? _a : 0;
|
|
1630
1631
|
if (!!!len)
|
|
1631
|
-
return;
|
|
1632
|
+
return opts;
|
|
1632
1633
|
if (isStop)
|
|
1633
1634
|
return renderLoop("\n");
|
|
1634
1635
|
if (index >= len - 1)
|