utils-lib-js 2.0.11 → 2.0.13
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/README.en.md +12 -0
- package/README.md +12 -0
- package/dist/bundle/index.d.ts +1 -0
- package/dist/bundle/index.js +3 -3
- package/dist/bundle/object.d.ts +3 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/object.d.ts +3 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +8 -1
- package/dist/esm/object.d.ts +3 -1
- package/dist/umd/index.d.ts +1 -0
- package/dist/umd/index.js +8 -0
- package/dist/umd/object.d.ts +3 -1
- package/package.json +50 -50
package/README.en.md
CHANGED
|
@@ -322,6 +322,18 @@ const isBrowserWindow = isWindow(window);
|
|
|
322
322
|
console.log(isBrowserWindow); // Output: true
|
|
323
323
|
```
|
|
324
324
|
|
|
325
|
+
##### 14. `emptyObject(init: IObject): object`
|
|
326
|
+
|
|
327
|
+
Creates an object whose prototype is empty.
|
|
328
|
+
|
|
329
|
+
- 'init' : initializes the object.
|
|
330
|
+
|
|
331
|
+
```javascript
|
|
332
|
+
const o = emptyObject({ name: "hunter" });
|
|
333
|
+
const o2 = { name: "hunter" };
|
|
334
|
+
console.log(o.__proto__, o2.__proto__); // Output: undefined, [Object: null prototype] {}
|
|
335
|
+
```
|
|
336
|
+
|
|
325
337
|
#### array module
|
|
326
338
|
|
|
327
339
|
##### 1. `arrayRandom(arr: any[]): any[]`
|
package/README.md
CHANGED
|
@@ -322,6 +322,18 @@ const isBrowserWindow = isWindow(window);
|
|
|
322
322
|
console.log(isBrowserWindow); // 输出: true
|
|
323
323
|
```
|
|
324
324
|
|
|
325
|
+
##### 14. `emptyObject(init: IObject): object`
|
|
326
|
+
|
|
327
|
+
创建原型为空的对象。
|
|
328
|
+
|
|
329
|
+
- `init`: 初始化对象。
|
|
330
|
+
|
|
331
|
+
```javascript
|
|
332
|
+
const o = emptyObject({ name: "hunter" });
|
|
333
|
+
const o2 = { name: "hunter" };
|
|
334
|
+
console.log(o.__proto__, o2.__proto__); // 输出: undefined, [Object: null prototype] {}
|
|
335
|
+
```
|
|
336
|
+
|
|
325
337
|
#### array 模块
|
|
326
338
|
|
|
327
339
|
##### 1. `arrayRandom(arr: any[]): any[]`
|
package/dist/bundle/index.d.ts
CHANGED
package/dist/bundle/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var UtilsLib=function(e,t,n,r){"use strict";var o=function(){return o=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},o.apply(this,arguments)};function i(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))}e.types=void 0,function(e){e["[object Array]"]="array",e["[object Object]"]="object",e["[object Function]"]="function",e["[object Set]"]="set",e["[object Map]"]="map",e["[object WeakMap]"]="weakMap",e["[object WeakSet]"]="weakSet",e["[object Date]"]="date",e["[object RegExp]"]="regExp",e["[object Math]"]="math"}(e.types||(e.types={}));var u={types:e.types},a=function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},c=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},s=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("&"))},l=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},f=function(e,t){void 0===t&&(t=[]);var n=l(e);return t.indexOf(n)>0},p={randomNum:a,urlSplit:c,urlJoin:s,getType:l,getTypeByList:f},h=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},d=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},v=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},y=function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},g=function(e,t){return"object"!=typeof e||"null"===t},b=function(e){var t=l(e);if(g(e,t))return e;var n=m(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,b(e))})):"set"===t?e.forEach((function(e){n.add(b(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=b(r)})),n},m=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{}}},w=function(e){function t(){}return t.prototype=e,new t},j=function(e,t){return void 0===t&&(t=function(){}),t.prototype=w(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},E=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,i([void 0],n,!1)))),e._instance},O=function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},T=function(e){if("string"!==l(e))return null;try{return JSON.parse(e)}catch(e){return null}},S=function(e){if(!f(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},P=function(e){return e&&e===e.window},x={getValue:h,setValue:d,mixIn:v,enumInversion:y,isNotObject:g,cloneDeep:b,createObjectVariable:m,createObject:w,inherit:j,getInstance:E,classDecorator:O,stringToJson:T,jsonToString:S,isWindow:P},q=function(e){return e.sort((function(){return Math.random()-.5}))},k=function(e){return Array.from(new Set(e))},A=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===l(e)?A(e,t):t.push(e)})),t},H={arrayRandom:q,arrayUniq:k,arrayDemote:A},L=void 0,M=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,i([L],r,!1)),n=null}),t))}},C=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,i([L],r,!1))}),t)}},D=function(e){var t,n;return void 0===e&&(e=0),{promise:new Promise((function(r,o){t=r,n=o,e>0&&setTimeout((function(){return n("timeout")}),e)})),resolve:t,reject:n}},B=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},I={throttle:M,debounce:C,defer:D,catchAwait:B},R=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(i))||void 0===n||n.forEach((function(e){return a[e]=i[e]}))),u&&u.appendChild(a),a},F={createElement:R},_=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},N=function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},W=function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},J=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},V=function(e,t){var n=new Event(t);e.dispatchEvent(n)},U={addHandler:_,stopBubble:N,stopDefault:W,removeHandler:J,dispatchEvent:V},G=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},z=function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},Q=function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}},$={setStorage:G,getStorage:z,clearStorage:Q},K=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")},X=function(e){return K(e,!0,!1)},Y=["\\","|","/","—","—"],Z=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?Y: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 X("\n");s>=l-1&&(s=0);var f=r[s++];return X(f),setTimeout((function(){e.index=s,Z(e)}),a),e},ee={logOneLine:K,logLoop:Z},te=function(){function e(e){this.fn=e,this.id=null,this.duration=1/0,this.isActive=!1}return e.prototype.start=function(e){if(!this.isActive)return this.duration=null!=e?e:1/0,this.isActive=!0,this.animate()},e.prototype.stop=function(e){void 0===e&&(e=this.id),this.isActive=!1,cancelAnimationFrame(e)},e.prototype.animate=function(e){if(void 0===e&&(e=0),this.isActive&&this.duration-- >0)return this.fn(e),this.id=requestAnimationFrame(this.animate.bind(this)),this.id},e}();function ne(e,t,n){var r=1-n,o=n*n;return[2*r*n*e+o,2*r*n*t+o]}function re(e,t,n,r,o){var i=3*e,u=3*t,a=3*(n-e)-i,c=3*(r-t)-u,s=1-u-c;return[(1-i-a)*Math.pow(o,3)+a*Math.pow(o,2)+i*o,s*Math.pow(o,3)+c*Math.pow(o,2)+u*o]}function oe(e){return 0===e||1===e?1:e*oe(e-1)}function ie(e,t){return oe(e)/(oe(t)*oe(e-t))}function ue(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=ie(n,o)*Math.pow(1-t,n-o)*Math.pow(t,o);r[0]+=i*e[o][0],r[1]+=i*e[o][1]}return r}var ae,ce={AnimateFrame:te,quadraticBezier:ne,cubicBezier:re,factorial:oe,combination:ie,NBezier:ue},se=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=se.Instance(se),fe=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new se),e},pe=function(){return pe=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},pe.apply(this,arguments)},he=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},de=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ve=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())}))},ye=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])}}},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,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]=pe(pe({},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 ve(t,void 0,void 0,(function(){var e,t,r,o,i;return ye(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=he([fe,de("design:paramtypes",[Object])],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)};function me(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))}!function(e){e["[object Array]"]="array",e["[object Object]"]="object",e["[object Function]"]="function",e["[object Set]"]="set",e["[object Map]"]="map",e["[object WeakMap]"]="weakMap",e["[object WeakSet]"]="weakSet",e["[object Date]"]="date",e["[object RegExp]"]="regExp",e["[object Math]"]="math"}(ae||(ae={}));var we={types:ae},je=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("&"))},Ee=function(e){var t=typeof e;if(null===e)return"null";if("object"===t){var n=Object.prototype.toString.call(e);return ae[n]}return t},Oe=function(e,t){void 0===t&&(t=[]);var n=Ee(e);return t.indexOf(n)>0},Te={randomNum:function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},urlSplit: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},urlJoin:je,getType:Ee,getTypeByList:Oe},Se=function(e,t){return"object"!=typeof e||"null"===t},Pe=function(e){var t=Ee(e);if(Se(e,t))return e;var n=xe(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,Pe(e))})):"set"===t?e.forEach((function(e){n.add(Pe(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=Pe(r)})),n},xe=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{}}},qe=function(e){function t(){}return t.prototype=e,new t},ke=function(e){if("string"!==Ee(e))return null;try{return JSON.parse(e)}catch(e){return null}},Ae=function(e){if(!Oe(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},He={getValue: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},setValue: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},mixIn: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},enumInversion:function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},isNotObject:Se,cloneDeep:Pe,createObjectVariable:xe,createObject:qe,inherit:function(e,t){return void 0===t&&(t=function(){}),t.prototype=qe(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},getInstance: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,me([void 0],n,!1)))),e._instance},classDecorator:function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},stringToJson:ke,jsonToString:Ae,isWindow:function(e){return e&&e===e.window}},Le=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===Ee(e)?Le(e,t):t.push(e)})),t},Me={arrayRandom:function(e){return e.sort((function(){return Math.random()-.5}))},arrayUniq:function(e){return Array.from(new Set(e))},arrayDemote:Le},Ce=void 0,De=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}},Be={throttle: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,me([Ce],r,!1)),n=null}),t))}},debounce: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,me([Ce],r,!1))}),t)}},defer:De,catchAwait:function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))}},Ie={createElement: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(i))||void 0===n||n.forEach((function(e){return a[e]=i[e]}))),u&&u.appendChild(a),a}},Re={addHandler:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},stopBubble:function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},stopDefault:function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},removeHandler:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},dispatchEvent:function(e,t){var n=new Event(t);e.dispatchEvent(n)}},Fe={setStorage:function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},getStorage:function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},clearStorage:function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}}},_e=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")},Ne=function(e){return _e(e,!0,!1)},We=["\\","|","/","—","—"],Je=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?We: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 Ne("\n");s>=l-1&&(s=0);var f=r[s++];return Ne(f),setTimeout((function(){e.index=s,Je(e)}),a),e},Ve={logOneLine:_e,logLoop:Je},Ue=function(){function e(e){this.fn=e,this.id=null,this.duration=1/0,this.isActive=!1}return e.prototype.start=function(e){this.isActive||(this.duration=null!=e?e:1/0,this.isActive=!0,this.animate())},e.prototype.stop=function(){this.isActive=!1,cancelAnimationFrame(this.id)},e.prototype.animate=function(e){void 0===e&&(e=0),this.isActive&&this.duration-- >0&&(this.fn(e),this.id=requestAnimationFrame(this.animate.bind(this)))},e}();function Ge(e){return 0===e||1===e?1:e*Ge(e-1)}function ze(e,t){return Ge(e)/(Ge(t)*Ge(e-t))}var Qe={AnimateFrame:Ue,quadraticBezier:function(e,t,n){var r=1-n,o=n*n;return[2*r*n*e+o,2*r*n*t+o]},cubicBezier:function(e,t,n,r,o){var i=3*e,u=3*t,a=3*(n-e)-i,c=3*(r-t)-u,s=1-u-c;return[(1-i-a)*Math.pow(o,3)+a*Math.pow(o,2)+i*o,s*Math.pow(o,3)+c*Math.pow(o,2)+u*o]},factorial:Ge,combination:ze,NBezier:function(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=ze(n,o)*Math.pow(1-t,n-o)*Math.pow(t,o);r[0]+=i*e[o][0],r[1]+=i*e[o][1]}return r}},$e=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}();$e.Instance($e);var Ke=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new $e),e},Xe=function(){return Xe=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},Xe.apply(this,arguments)},Ye=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ze=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())}))},et=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])}}},tt=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]=Xe(Xe({},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 Ze(t,void 0,void 0,(function(){var e,t,r,o,i;return et(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=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}([Ke,Ye("design:paramtypes",[Object])],e),e}();be(be(be(be(be(be(be(be(be(be(be({},He),Te),Me),Be),Ie),we),Re),Fe),Ve),Qe),{eventMessageCenter:$e,taskQueueLib:tt});
|
|
1
|
+
var UtilsLib=function(e,t,n,r){"use strict";var o=function(){return o=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},o.apply(this,arguments)};function i(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))}e.types=void 0,function(e){e["[object Array]"]="array",e["[object Object]"]="object",e["[object Function]"]="function",e["[object Set]"]="set",e["[object Map]"]="map",e["[object WeakMap]"]="weakMap",e["[object WeakSet]"]="weakSet",e["[object Date]"]="date",e["[object RegExp]"]="regExp",e["[object Math]"]="math"}(e.types||(e.types={}));var u={types:e.types},a=function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},c=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},s=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("&"))},l=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},f=function(e,t){void 0===t&&(t=[]);var n=l(e);return t.indexOf(n)>0},p={randomNum:a,urlSplit:c,urlJoin:s,getType:l,getTypeByList:f},h=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},d=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},v=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},y=function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},g=function(e,t){return"object"!=typeof e||"null"===t},b=function(e){var t=l(e);if(g(e,t))return e;var n=m(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,b(e))})):"set"===t?e.forEach((function(e){n.add(b(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=b(r)})),n},m=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{}}},w=function(e){function t(){}return t.prototype=e,new t},j=function(e,t){return void 0===t&&(t=function(){}),t.prototype=w(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},E=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,i([void 0],n,!1)))),e._instance},O=function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},T=function(e){if("string"!==l(e))return null;try{return JSON.parse(e)}catch(e){return null}},S=function(e){if(!f(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},P=function(e){return e&&e===e.window},x=function(e){void 0===e&&(e={});var t=Object.create(null);return Reflect.ownKeys(e).forEach((function(n){return t[n]=e[n]})),t},q={getValue:h,setValue:d,mixIn:v,enumInversion:y,isNotObject:g,cloneDeep:b,createObjectVariable:m,createObject:w,inherit:j,getInstance:E,classDecorator:O,stringToJson:T,jsonToString:S,isWindow:P,emptyObject:x},k=function(e){return e.sort((function(){return Math.random()-.5}))},A=function(e){return Array.from(new Set(e))},H=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===l(e)?H(e,t):t.push(e)})),t},L={arrayRandom:k,arrayUniq:A,arrayDemote:H},M=void 0,C=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,i([M],r,!1)),n=null}),t))}},D=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,i([M],r,!1))}),t)}},B=function(e){var t,n;return void 0===e&&(e=0),{promise:new Promise((function(r,o){t=r,n=o,e>0&&setTimeout((function(){return n("timeout")}),e)})),resolve:t,reject:n}},I=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},R={throttle:C,debounce:D,defer:B,catchAwait:I},F=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(i))||void 0===n||n.forEach((function(e){return a[e]=i[e]}))),u&&u.appendChild(a),a},_={createElement:F},N=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},W=function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},J=function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},V=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},U=function(e,t){var n=new Event(t);e.dispatchEvent(n)},G={addHandler:N,stopBubble:W,stopDefault:J,removeHandler:V,dispatchEvent:U},z=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},Q=function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},$=function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}},K={setStorage:z,getStorage:Q,clearStorage:$},X=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")},Y=function(e){return X(e,!0,!1)},Z=["\\","|","/","—","—"],ee=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?Z: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 Y("\n");s>=l-1&&(s=0);var f=r[s++];return Y(f),setTimeout((function(){e.index=s,ee(e)}),a),e},te={logOneLine:X,logLoop:ee},ne=function(){function e(e){this.fn=e,this.id=null,this.duration=1/0,this.isActive=!1}return e.prototype.start=function(e){if(!this.isActive)return this.duration=null!=e?e:1/0,this.isActive=!0,this.animate()},e.prototype.stop=function(e){void 0===e&&(e=this.id),this.isActive=!1,cancelAnimationFrame(e)},e.prototype.animate=function(e){if(void 0===e&&(e=0),this.isActive&&this.duration-- >0)return this.fn(e),this.id=requestAnimationFrame(this.animate.bind(this)),this.id},e}();function re(e,t,n){var r=1-n,o=n*n;return[2*r*n*e+o,2*r*n*t+o]}function oe(e,t,n,r,o){var i=3*e,u=3*t,a=3*(n-e)-i,c=3*(r-t)-u,s=1-u-c;return[(1-i-a)*Math.pow(o,3)+a*Math.pow(o,2)+i*o,s*Math.pow(o,3)+c*Math.pow(o,2)+u*o]}function ie(e){return 0===e||1===e?1:e*ie(e-1)}function ue(e,t){return ie(e)/(ie(t)*ie(e-t))}function ae(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=ue(n,o)*Math.pow(1-t,n-o)*Math.pow(t,o);r[0]+=i*e[o][0],r[1]+=i*e[o][1]}return r}var ce,se={AnimateFrame:ne,quadraticBezier:re,cubicBezier:oe,factorial:ie,combination:ue,NBezier:ae},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 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}(),fe=le.Instance(le),pe=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new le),e},he=function(){return he=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},he.apply(this,arguments)},de=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},ve=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ye=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())}))},ge=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])}}},be=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]=he(he({},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 ye(t,void 0,void 0,(function(){var e,t,r,o,i;return ge(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=de([pe,ve("design:paramtypes",[Object])],e)}(),me=function(){return me=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},me.apply(this,arguments)};function we(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))}!function(e){e["[object Array]"]="array",e["[object Object]"]="object",e["[object Function]"]="function",e["[object Set]"]="set",e["[object Map]"]="map",e["[object WeakMap]"]="weakMap",e["[object WeakSet]"]="weakSet",e["[object Date]"]="date",e["[object RegExp]"]="regExp",e["[object Math]"]="math"}(ce||(ce={}));var je={types:ce},Ee=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("&"))},Oe=function(e){var t=typeof e;if(null===e)return"null";if("object"===t){var n=Object.prototype.toString.call(e);return ce[n]}return t},Te=function(e,t){void 0===t&&(t=[]);var n=Oe(e);return t.indexOf(n)>0},Se={randomNum:function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},urlSplit: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},urlJoin:Ee,getType:Oe,getTypeByList:Te},Pe=function(e,t){return"object"!=typeof e||"null"===t},xe=function(e){var t=Oe(e);if(Pe(e,t))return e;var n=qe(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,xe(e))})):"set"===t?e.forEach((function(e){n.add(xe(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=xe(r)})),n},qe=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{}}},ke=function(e){function t(){}return t.prototype=e,new t},Ae=function(e){if("string"!==Oe(e))return null;try{return JSON.parse(e)}catch(e){return null}},He=function(e){if(!Te(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},Le={getValue: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},setValue: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},mixIn: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},enumInversion:function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},isNotObject:Pe,cloneDeep:xe,createObjectVariable:qe,createObject:ke,inherit:function(e,t){return void 0===t&&(t=function(){}),t.prototype=ke(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},getInstance: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,we([void 0],n,!1)))),e._instance},classDecorator:function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},stringToJson:Ae,jsonToString:He,isWindow:function(e){return e&&e===e.window}},Me=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===Oe(e)?Me(e,t):t.push(e)})),t},Ce={arrayRandom:function(e){return e.sort((function(){return Math.random()-.5}))},arrayUniq:function(e){return Array.from(new Set(e))},arrayDemote:Me},De=void 0,Be=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}},Ie={throttle: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,we([De],r,!1)),n=null}),t))}},debounce: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,we([De],r,!1))}),t)}},defer:Be,catchAwait:function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))}},Re={createElement: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(i))||void 0===n||n.forEach((function(e){return a[e]=i[e]}))),u&&u.appendChild(a),a}},Fe={addHandler:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},stopBubble:function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},stopDefault:function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},removeHandler:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},dispatchEvent:function(e,t){var n=new Event(t);e.dispatchEvent(n)}},_e={setStorage:function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},getStorage:function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},clearStorage:function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}}},Ne=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")},We=function(e){return Ne(e,!0,!1)},Je=["\\","|","/","—","—"],Ve=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?Je: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 We("\n");s>=l-1&&(s=0);var f=r[s++];return We(f),setTimeout((function(){e.index=s,Ve(e)}),a),e},Ue={logOneLine:Ne,logLoop:Ve},Ge=function(){function e(e){this.fn=e,this.id=null,this.duration=1/0,this.isActive=!1}return e.prototype.start=function(e){this.isActive||(this.duration=null!=e?e:1/0,this.isActive=!0,this.animate())},e.prototype.stop=function(){this.isActive=!1,cancelAnimationFrame(this.id)},e.prototype.animate=function(e){void 0===e&&(e=0),this.isActive&&this.duration-- >0&&(this.fn(e),this.id=requestAnimationFrame(this.animate.bind(this)))},e}();function ze(e){return 0===e||1===e?1:e*ze(e-1)}function Qe(e,t){return ze(e)/(ze(t)*ze(e-t))}var $e={AnimateFrame:Ge,quadraticBezier:function(e,t,n){var r=1-n,o=n*n;return[2*r*n*e+o,2*r*n*t+o]},cubicBezier:function(e,t,n,r,o){var i=3*e,u=3*t,a=3*(n-e)-i,c=3*(r-t)-u,s=1-u-c;return[(1-i-a)*Math.pow(o,3)+a*Math.pow(o,2)+i*o,s*Math.pow(o,3)+c*Math.pow(o,2)+u*o]},factorial:ze,combination:Qe,NBezier:function(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=Qe(n,o)*Math.pow(1-t,n-o)*Math.pow(t,o);r[0]+=i*e[o][0],r[1]+=i*e[o][1]}return r}},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}();Ke.Instance(Ke);var Xe=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new Ke),e},Ye=function(){return Ye=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},Ye.apply(this,arguments)},Ze=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},et=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())}))},tt=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])}}},nt=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]=Ye(Ye({},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 et(t,void 0,void 0,(function(){var e,t,r,o,i;return tt(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=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}([Xe,Ze("design:paramtypes",[Object])],e),e}();me(me(me(me(me(me(me(me(me(me(me({},Le),Se),Ce),Ie),Re),je),Fe),_e),Ue),$e),{eventMessageCenter:Ke,taskQueueLib:nt});
|
|
2
2
|
/**
|
|
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
6
|
*/
|
|
7
|
-
const nt=new WeakMap,rt=new WeakMap;function ot(e){const t=nt.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function it(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 ut(e,t){nt.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,at(t))}}function at(e){return{get(){return ot(this).event[e]},set(t){ot(this).event[e]=t},configurable:!0,enumerable:!0}}function ct(e){return{value(){const t=ot(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function st(e){if(null==e||e===Object.prototype)return ut;let t=rt.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?ct(i):at(i))}}return r}(st(Object.getPrototypeOf(e)),e),rt.set(e,t)),t}function lt(e){return ot(e).immediateStopped}function ft(e,t){ot(e).passiveListener=t}ut.prototype={get type(){return ot(this).event.type},get target(){return ot(this).eventTarget},get currentTarget(){return ot(this).currentTarget},composedPath(){const e=ot(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 ot(this).eventPhase},stopPropagation(){const e=ot(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=ot(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(ot(this).event.bubbles)},get cancelable(){return Boolean(ot(this).event.cancelable)},preventDefault(){it(ot(this))},get defaultPrevented(){return ot(this).canceled},get composed(){return Boolean(ot(this).event.composed)},get timeStamp(){return ot(this).timeStamp},get srcElement(){return ot(this).eventTarget},get cancelBubble(){return ot(this).stopped},set cancelBubble(e){if(!e)return;const t=ot(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!ot(this).canceled},set returnValue(e){e||it(ot(this))},initEvent(){}},Object.defineProperty(ut.prototype,"constructor",{value:ut,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf(ut.prototype,window.Event.prototype),rt.set(window.Event.prototype,ut));const pt=new WeakMap,ht=3;function dt(e){return null!==e&&"object"==typeof e}function vt(e){const t=pt.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function yt(e,t){Object.defineProperty(e,`on${t}`,function(e){return{get(){let t=vt(this).get(e);for(;null!=t;){if(t.listenerType===ht)return t.listener;t=t.next}return null},set(t){"function"==typeof t||dt(t)||(t=null);const n=vt(this);let r=null,o=n.get(e);for(;null!=o;)o.listenerType===ht?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:ht,passive:!1,once:!1,next:null};null===r?n.set(e,o):r.next=o}},configurable:!0,enumerable:!0}}(t))}function gt(e){function t(){bt.call(this)}t.prototype=Object.create(bt.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let n=0;n<e.length;++n)yt(t.prototype,e[n]);return t}function bt(){if(!(this instanceof bt)){if(1===arguments.length&&Array.isArray(arguments[0]))return gt(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 gt(e)}throw new TypeError("Cannot call a class as a function")}pt.set(this,new Map)}bt.prototype={addEventListener(e,t,n){if(null==t)return;if("function"!=typeof t&&!dt(t))throw new TypeError("'listener' should be a function or an object.");const r=vt(this),o=dt(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=vt(this),o=(dt(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=vt(this),n=e.type;let r=t.get(n);if(null==r)return!0;const o=function(e,t){return new(st(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,ft(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!==ht&&"function"==typeof r.listener.handleEvent&&r.listener.handleEvent(o);if(lt(o))break;r=r.next}return ft(o,null),function(e,t){ot(e).eventPhase=t}(o,0),function(e,t){ot(e).currentTarget=t}(o,null),!o.defaultPrevented}},Object.defineProperty(bt.prototype,"constructor",{value:bt,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(bt.prototype,window.EventTarget.prototype);let mt=class extends bt{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){const e=wt.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}};yt(mt.prototype,"abort");const wt=new WeakMap;Object.defineProperties(mt.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(mt.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});let jt=class{constructor(){Et.set(this,function(){const e=Object.create(mt.prototype);return bt.call(e),wt.set(e,!1),e}())}get signal(){return Ot(this)}abort(){var e;e=Ot(this),!1===wt.get(e)&&(wt.set(e,!0),e.dispatchEvent({type:"abort"}))}};const Et=new WeakMap;function Ot(e){const t=Et.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(jt.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(jt.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});var Tt=function(e,t){return Tt=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])},Tt(e,t)};function St(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}Tt(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Pt,xt,qt,kt,At=function(){return At=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},At.apply(this,arguments)};function Ht(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"==typeof SuppressedError&&SuppressedError;var Lt="undefined"!=typeof AbortController;"undefined"!=typeof window||Lt?Pt=globalThis.AbortController:"undefined"!=typeof require?(xt=require("http").request,qt=require("https").request,kt=require("url").parse,Pt=require("abort-controller")):"object"==typeof globalThis?(xt=t.request,qt=n.request,kt=r.parse,Pt=jt):Pt=function(){throw new Error("AbortController is not defined")};var Mt,Ct=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}(),Dt=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=ke(e))&&void 0!==t?t:e},blob:function(){return ke(e)},formData:function(){return ke(e)},arrayBuffer:function(){return ke(e)}}},n.origin=null!=t?t:"",n}return St(t,e),t}(Ct),Bt=function(e){function t(t){var n=e.call(this,t)||this;return n.initDefaultParams=function(e,t){var r,o,i=t.method,u=void 0===i?"GET":i,a=t.query,c=void 0===a?{}:a,s=t.headers,l=void 0===s?{}:s,f=t.body,p=void 0===f?null:f,h=t.timeout,d=void 0===h?3e4:h,v=t.controller,y=void 0===v?new Pt:v,g=t.type,b=void 0===g?"json":g,m=Ht(t,["method","query","headers","body","timeout","controller","type"]),w=At({url:e,method:u,query:c,headers:l,body:"GET"===u?null:Ae(p),timeout:d,signal:null==y?void 0:y.signal,controller:y,type:b,timer:null},m),j=null!==(o=null===(r=n.reqFn)||void 0===r?void 0:r.call(n,w))&&void 0!==o?o:w;return j.url=je(n.fixOrigin(e),w.query),j},n.initFetchParams=function(e,t){return n.initAbort(n.initDefaultParams(e,t))},n.initHttpParams=function(e,t){var r=n.initAbort(n.initDefaultParams(e,t)),o=kt(r.url,!0);return At(At({},r),o)},n}return St(t,e),t}(Dt),It=function(e){function t(t){var n=e.call(this,t)||this;return n.fetch=function(e,t){var r=De(),o=r.promise,i=r.resolve,u=r.reject,a=n.initFetchParams(e,t),c=a.url,s=Ht(a,["url"]),l=s.signal;return o.finally((function(){return n.clearTimer(s)})),l.addEventListener("abort",(function(){return n.errorFn(u)})),fetch(c,s).then((function(e){return(null==e?void 0:e.status)>=200&&(null==e?void 0:e.status)<300?n.getDataByType(s.type,e):n.errorFn(u)})).then((function(e){var t,r;return i(null!==(r=null===(t=n.resFn)||void 0===t?void 0:t.call(n,e))&&void 0!==r?r:e)})).catch(n.errorFn(u)),o},n.http=function(e,t){var r=De(),o=r.promise,i=r.resolve,u=r.reject,a=n.initHttpParams(e,t),c=a.signal,s=a.url,l=a.body;o.finally((function(){return n.clearTimer(a)}));var f=(n.checkIsHttps(s)?qt:xt)(a,(function(e){var t=e.statusCode,r=e.statusMessage,o="";return e.setEncoding("utf8"),e.on("data",(function(e){return o+=e})),e.on("end",(function(){var e,c,s=n.getDataByType(a.type,n.formatBodyString(o));return t>=200&&t<300?i(null!==(c=null===(e=n.resFn)||void 0===e?void 0:e.call(n,s))&&void 0!==c?c:s):n.errorFn(u)({statusCode:t,statusMessage:r,result:s,data:o})}))}));return c.addEventListener("abort",(function(){return n.errorFn(u)(f.destroy(new Error("request timeout")))})),l&&f.write(l),f.on("error",n.errorFn(u)),f.end(),o},n.GET=function(e,t,r,o){return n.request(e,At({query:t,method:"GET"},o))},n.POST=function(e,t,r,o){return n.request(e,At({query:t,method:"POST",body:r},o))},n.PUT=function(e,t,r,o){return n.request(e,At({query:t,method:"PUT",body:r},o))},n.DELETE=function(e,t,r,o){return n.request(e,At({query:t,method:"DELETE",body:r},o))},n.OPTIONS=function(e,t,r,o){return n.request(e,At({query:t,method:"OPTIONS",body:r},o))},n.HEAD=function(e,t,r,o){return n.request(e,At({query:t,method:"HEAD",body:r},o))},n.PATCH=function(e,t,r,o){return n.request(e,At({query:t,method:"PATCH",body:r},o))},n.request=n.requestType(),n}return St(t,e),t}(Bt),Rt=function(){return Rt=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},Rt.apply(this,arguments)};function Ft(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))}!function(e){e["[object Array]"]="array",e["[object Object]"]="object",e["[object Function]"]="function",e["[object Set]"]="set",e["[object Map]"]="map",e["[object WeakMap]"]="weakMap",e["[object WeakSet]"]="weakSet",e["[object Date]"]="date",e["[object RegExp]"]="regExp",e["[object Math]"]="math"}(Mt||(Mt={}));var _t={types:Mt},Nt=function(e){var t=typeof e;if(null===e)return"null";if("object"===t){var n=Object.prototype.toString.call(e);return Mt[n]}return t},Wt=function(e,t){void 0===t&&(t=[]);var n=Nt(e);return t.indexOf(n)>0},Jt={randomNum:function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},urlSplit: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},urlJoin: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("&"))},getType:Nt,getTypeByList:Wt},Vt=function(e,t){return"object"!=typeof e||"null"===t},Ut=function(e){var t=Nt(e);if(Vt(e,t))return e;var n=Gt(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,Ut(e))})):"set"===t?e.forEach((function(e){n.add(Ut(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=Ut(r)})),n},Gt=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{}}},zt=function(e){function t(){}return t.prototype=e,new t},Qt={getValue: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},setValue: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},mixIn: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},enumInversion:function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},isNotObject:Vt,cloneDeep:Ut,createObjectVariable:Gt,createObject:zt,inherit:function(e,t){return void 0===t&&(t=function(){}),t.prototype=zt(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},getInstance: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,Ft([void 0],n,!1)))),e._instance},classDecorator:function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},stringToJson:function(e){if("string"!==Nt(e))return null;try{return JSON.parse(e)}catch(e){return null}},jsonToString:function(e){if(!Wt(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},isWindow:function(e){return e&&e===e.window}},$t=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===Nt(e)?$t(e,t):t.push(e)})),t},Kt={arrayRandom:function(e){return e.sort((function(){return Math.random()-.5}))},arrayUniq:function(e){return Array.from(new Set(e))},arrayDemote:$t},Xt=void 0,Yt={throttle: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,Ft([Xt],r,!1)),n=null}),t))}},debounce: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,Ft([Xt],r,!1))}),t)}},defer:function(e){var t,n;return void 0===e&&(e=0),{promise:new Promise((function(r,o){t=r,n=o,e>0&&setTimeout((function(){return n("timeout")}),e)})),resolve:t,reject:n}},catchAwait:function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))}},Zt={createElement: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(i))||void 0===n||n.forEach((function(e){return a[e]=i[e]}))),u&&u.appendChild(a),a}},en={addHandler:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},stopBubble:function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},stopDefault:function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},removeHandler:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},dispatchEvent:function(e,t){var n=new Event(t);e.dispatchEvent(n)}},tn={setStorage:function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},getStorage:function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},clearStorage:function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}}},nn=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")},rn=function(e){return nn(e,!0,!1)},on=["\\","|","/","—","—"],un=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?on: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 rn("\n");s>=l-1&&(s=0);var f=r[s++];return rn(f),setTimeout((function(){e.index=s,un(e)}),a),e},an={logOneLine:nn,logLoop:un},cn=function(){function e(e){this.fn=e,this.id=null,this.duration=1/0,this.isActive=!1}return e.prototype.start=function(e){if(!this.isActive)return this.duration=null!=e?e:1/0,this.isActive=!0,this.animate()},e.prototype.stop=function(e){void 0===e&&(e=this.id),this.isActive=!1,cancelAnimationFrame(e)},e.prototype.animate=function(e){if(void 0===e&&(e=0),this.isActive&&this.duration-- >0)return this.fn(e),this.id=requestAnimationFrame(this.animate.bind(this)),this.id},e}();function sn(e){return 0===e||1===e?1:e*sn(e-1)}function ln(e,t){return sn(e)/(sn(t)*sn(e-t))}var fn={AnimateFrame:cn,quadraticBezier:function(e,t,n){var r=1-n,o=n*n;return[2*r*n*e+o,2*r*n*t+o]},cubicBezier:function(e,t,n,r,o){var i=3*e,u=3*t,a=3*(n-e)-i,c=3*(r-t)-u,s=1-u-c;return[(1-i-a)*Math.pow(o,3)+a*Math.pow(o,2)+i*o,s*Math.pow(o,3)+c*Math.pow(o,2)+u*o]},factorial:sn,combination:ln,NBezier:function(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=ln(n,o)*Math.pow(1-t,n-o)*Math.pow(t,o);r[0]+=i*e[o][0],r[1]+=i*e[o][1]}return r}},pn=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}();pn.Instance(pn);var hn,dn=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new pn),e},vn=function(){return vn=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},vn.apply(this,arguments)},yn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},gn=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())}))},bn=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])}}},mn=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]=vn(vn({},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 gn(t,void 0,void 0,(function(){var e,t,r,o,i;return bn(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=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}([dn,yn("design:paramtypes",[Object])],e),e}(),wn=function(){return wn=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},wn.apply(this,arguments)};function jn(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))}!function(e){e["[object Array]"]="array",e["[object Object]"]="object",e["[object Function]"]="function",e["[object Set]"]="set",e["[object Map]"]="map",e["[object WeakMap]"]="weakMap",e["[object WeakSet]"]="weakSet",e["[object Date]"]="date",e["[object RegExp]"]="regExp",e["[object Math]"]="math"}(hn||(hn={}));var En={types:hn},On=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("&"))},Tn=function(e){var t=typeof e;if(null===e)return"null";if("object"===t){var n=Object.prototype.toString.call(e);return hn[n]}return t},Sn=function(e,t){void 0===t&&(t=[]);var n=Tn(e);return t.indexOf(n)>0},Pn={randomNum:function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},urlSplit: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},urlJoin:On,getType:Tn,getTypeByList:Sn},xn=function(e,t){return"object"!=typeof e||"null"===t},qn=function(e){var t=Tn(e);if(xn(e,t))return e;var n=kn(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,qn(e))})):"set"===t?e.forEach((function(e){n.add(qn(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=qn(r)})),n},kn=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{}}},An=function(e){function t(){}return t.prototype=e,new t},Hn=function(e){if("string"!==Tn(e))return null;try{return JSON.parse(e)}catch(e){return null}},Ln=function(e){if(!Sn(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},Mn={getValue: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},setValue: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},mixIn: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},enumInversion:function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},isNotObject:xn,cloneDeep:qn,createObjectVariable:kn,createObject:An,inherit:function(e,t){return void 0===t&&(t=function(){}),t.prototype=An(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},getInstance: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,jn([void 0],n,!1)))),e._instance},classDecorator:function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},stringToJson:Hn,jsonToString:Ln,isWindow:function(e){return e&&e===e.window}},Cn=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===Tn(e)?Cn(e,t):t.push(e)})),t},Dn={arrayRandom:function(e){return e.sort((function(){return Math.random()-.5}))},arrayUniq:function(e){return Array.from(new Set(e))},arrayDemote:Cn},Bn=void 0,In=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}},Rn={throttle: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,jn([Bn],r,!1)),n=null}),t))}},debounce: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,jn([Bn],r,!1))}),t)}},defer:In,catchAwait:function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))}},Fn={createElement: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(i))||void 0===n||n.forEach((function(e){return a[e]=i[e]}))),u&&u.appendChild(a),a}},_n={addHandler:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},stopBubble:function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},stopDefault:function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},removeHandler:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},dispatchEvent:function(e,t){var n=new Event(t);e.dispatchEvent(n)}},Nn={setStorage:function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},getStorage:function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},clearStorage:function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}}},Wn=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")},Jn=function(e){return Wn(e,!0,!1)},Vn=["\\","|","/","—","—"],Un=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?Vn: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 Jn("\n");s>=l-1&&(s=0);var f=r[s++];return Jn(f),setTimeout((function(){e.index=s,Un(e)}),a),e},Gn={logOneLine:Wn,logLoop:Un};function zn(e){return 0===e||1===e?1:e*zn(e-1)}function Qn(e,t){return zn(e)/(zn(t)*zn(e-t))}var $n={AnimateFrame:function(){function e(e){this.fn=e,this.id=null,this.duration=1/0,this.isActive=!1}return e.prototype.start=function(e){this.isActive||(this.duration=null!=e?e:1/0,this.isActive=!0,this.animate())},e.prototype.stop=function(){this.isActive=!1,cancelAnimationFrame(this.id)},e.prototype.animate=function(e){void 0===e&&(e=0),this.isActive&&this.duration-- >0&&(this.fn(e),this.id=requestAnimationFrame(this.animate.bind(this)))},e}(),quadraticBezier:function(e,t,n){var r=1-n,o=n*n;return[2*r*n*e+o,2*r*n*t+o]},cubicBezier:function(e,t,n,r,o){var i=3*e,u=3*t,a=3*(n-e)-i,c=3*(r-t)-u,s=1-u-c;return[(1-i-a)*Math.pow(o,3)+a*Math.pow(o,2)+i*o,s*Math.pow(o,3)+c*Math.pow(o,2)+u*o]},factorial:zn,combination:Qn,NBezier:function(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=Qn(n,o)*Math.pow(1-t,n-o)*Math.pow(t,o);r[0]+=i*e[o][0],r[1]+=i*e[o][1]}return r}},Kn=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}();Kn.Instance(Kn);var Xn=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new Kn),e},Yn=function(){return Yn=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},Yn.apply(this,arguments)},Zn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},er=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())}))},tr=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])}}},nr=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]=Yn(Yn({},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 er(t,void 0,void 0,(function(){var e,t,r,o,i;return tr(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=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}([Xn,Zn("design:paramtypes",[Object])],e),e}();wn(wn(wn(wn(wn(wn(wn(wn(wn(wn(wn({},Mn),Pn),Dn),Rn),Fn),En),_n),Nn),Gn),$n),{eventMessageCenter:Kn,taskQueueLib:nr});
|
|
7
|
+
const rt=new WeakMap,ot=new WeakMap;function it(e){const t=rt.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function ut(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 at(e,t){rt.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,ct(t))}}function ct(e){return{get(){return it(this).event[e]},set(t){it(this).event[e]=t},configurable:!0,enumerable:!0}}function st(e){return{value(){const t=it(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function lt(e){if(null==e||e===Object.prototype)return at;let t=ot.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?st(i):ct(i))}}return r}(lt(Object.getPrototypeOf(e)),e),ot.set(e,t)),t}function ft(e){return it(e).immediateStopped}function pt(e,t){it(e).passiveListener=t}at.prototype={get type(){return it(this).event.type},get target(){return it(this).eventTarget},get currentTarget(){return it(this).currentTarget},composedPath(){const e=it(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 it(this).eventPhase},stopPropagation(){const e=it(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=it(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(it(this).event.bubbles)},get cancelable(){return Boolean(it(this).event.cancelable)},preventDefault(){ut(it(this))},get defaultPrevented(){return it(this).canceled},get composed(){return Boolean(it(this).event.composed)},get timeStamp(){return it(this).timeStamp},get srcElement(){return it(this).eventTarget},get cancelBubble(){return it(this).stopped},set cancelBubble(e){if(!e)return;const t=it(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!it(this).canceled},set returnValue(e){e||ut(it(this))},initEvent(){}},Object.defineProperty(at.prototype,"constructor",{value:at,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf(at.prototype,window.Event.prototype),ot.set(window.Event.prototype,at));const ht=new WeakMap,dt=3;function vt(e){return null!==e&&"object"==typeof e}function yt(e){const t=ht.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function gt(e,t){Object.defineProperty(e,`on${t}`,function(e){return{get(){let t=yt(this).get(e);for(;null!=t;){if(t.listenerType===dt)return t.listener;t=t.next}return null},set(t){"function"==typeof t||vt(t)||(t=null);const n=yt(this);let r=null,o=n.get(e);for(;null!=o;)o.listenerType===dt?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:dt,passive:!1,once:!1,next:null};null===r?n.set(e,o):r.next=o}},configurable:!0,enumerable:!0}}(t))}function bt(e){function t(){mt.call(this)}t.prototype=Object.create(mt.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let n=0;n<e.length;++n)gt(t.prototype,e[n]);return t}function mt(){if(!(this instanceof mt)){if(1===arguments.length&&Array.isArray(arguments[0]))return bt(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 bt(e)}throw new TypeError("Cannot call a class as a function")}ht.set(this,new Map)}mt.prototype={addEventListener(e,t,n){if(null==t)return;if("function"!=typeof t&&!vt(t))throw new TypeError("'listener' should be a function or an object.");const r=yt(this),o=vt(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=yt(this),o=(vt(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=yt(this),n=e.type;let r=t.get(n);if(null==r)return!0;const o=function(e,t){return new(lt(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,pt(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!==dt&&"function"==typeof r.listener.handleEvent&&r.listener.handleEvent(o);if(ft(o))break;r=r.next}return pt(o,null),function(e,t){it(e).eventPhase=t}(o,0),function(e,t){it(e).currentTarget=t}(o,null),!o.defaultPrevented}},Object.defineProperty(mt.prototype,"constructor",{value:mt,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(mt.prototype,window.EventTarget.prototype);let wt=class extends mt{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){const e=jt.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}};gt(wt.prototype,"abort");const jt=new WeakMap;Object.defineProperties(wt.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(wt.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});let Et=class{constructor(){Ot.set(this,function(){const e=Object.create(wt.prototype);return mt.call(e),jt.set(e,!1),e}())}get signal(){return Tt(this)}abort(){var e;e=Tt(this),!1===jt.get(e)&&(jt.set(e,!0),e.dispatchEvent({type:"abort"}))}};const Ot=new WeakMap;function Tt(e){const t=Ot.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(Et.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Et.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});var St=function(e,t){return St=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])},St(e,t)};function Pt(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}St(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var xt,qt,kt,At,Ht=function(){return Ht=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},Ht.apply(this,arguments)};function Lt(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"==typeof SuppressedError&&SuppressedError;var Mt="undefined"!=typeof AbortController;"undefined"!=typeof window||Mt?xt=globalThis.AbortController:"undefined"!=typeof require?(qt=require("http").request,kt=require("https").request,At=require("url").parse,xt=require("abort-controller")):"object"==typeof globalThis?(qt=t.request,kt=n.request,At=r.parse,xt=Et):xt=function(){throw new Error("AbortController is not defined")};var Ct,Dt=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}(),Bt=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=Ae(e))&&void 0!==t?t:e},blob:function(){return Ae(e)},formData:function(){return Ae(e)},arrayBuffer:function(){return Ae(e)}}},n.origin=null!=t?t:"",n}return Pt(t,e),t}(Dt),It=function(e){function t(t){var n=e.call(this,t)||this;return n.initDefaultParams=function(e,t){var r,o,i=t.method,u=void 0===i?"GET":i,a=t.query,c=void 0===a?{}:a,s=t.headers,l=void 0===s?{}:s,f=t.body,p=void 0===f?null:f,h=t.timeout,d=void 0===h?3e4:h,v=t.controller,y=void 0===v?new xt:v,g=t.type,b=void 0===g?"json":g,m=Lt(t,["method","query","headers","body","timeout","controller","type"]),w=Ht({url:e,method:u,query:c,headers:l,body:"GET"===u?null:He(p),timeout:d,signal:null==y?void 0:y.signal,controller:y,type:b,timer:null},m),j=null!==(o=null===(r=n.reqFn)||void 0===r?void 0:r.call(n,w))&&void 0!==o?o:w;return j.url=Ee(n.fixOrigin(e),w.query),j},n.initFetchParams=function(e,t){return n.initAbort(n.initDefaultParams(e,t))},n.initHttpParams=function(e,t){var r=n.initAbort(n.initDefaultParams(e,t)),o=At(r.url,!0);return Ht(Ht({},r),o)},n}return Pt(t,e),t}(Bt),Rt=function(e){function t(t){var n=e.call(this,t)||this;return n.fetch=function(e,t){var r=Be(),o=r.promise,i=r.resolve,u=r.reject,a=n.initFetchParams(e,t),c=a.url,s=Lt(a,["url"]),l=s.signal;return o.finally((function(){return n.clearTimer(s)})),l.addEventListener("abort",(function(){return n.errorFn(u)})),fetch(c,s).then((function(e){return(null==e?void 0:e.status)>=200&&(null==e?void 0:e.status)<300?n.getDataByType(s.type,e):n.errorFn(u)})).then((function(e){var t,r;return i(null!==(r=null===(t=n.resFn)||void 0===t?void 0:t.call(n,e))&&void 0!==r?r:e)})).catch(n.errorFn(u)),o},n.http=function(e,t){var r=Be(),o=r.promise,i=r.resolve,u=r.reject,a=n.initHttpParams(e,t),c=a.signal,s=a.url,l=a.body;o.finally((function(){return n.clearTimer(a)}));var f=(n.checkIsHttps(s)?kt:qt)(a,(function(e){var t=e.statusCode,r=e.statusMessage,o="";return e.setEncoding("utf8"),e.on("data",(function(e){return o+=e})),e.on("end",(function(){var e,c,s=n.getDataByType(a.type,n.formatBodyString(o));return t>=200&&t<300?i(null!==(c=null===(e=n.resFn)||void 0===e?void 0:e.call(n,s))&&void 0!==c?c:s):n.errorFn(u)({statusCode:t,statusMessage:r,result:s,data:o})}))}));return c.addEventListener("abort",(function(){return n.errorFn(u)(f.destroy(new Error("request timeout")))})),l&&f.write(l),f.on("error",n.errorFn(u)),f.end(),o},n.GET=function(e,t,r,o){return n.request(e,Ht({query:t,method:"GET"},o))},n.POST=function(e,t,r,o){return n.request(e,Ht({query:t,method:"POST",body:r},o))},n.PUT=function(e,t,r,o){return n.request(e,Ht({query:t,method:"PUT",body:r},o))},n.DELETE=function(e,t,r,o){return n.request(e,Ht({query:t,method:"DELETE",body:r},o))},n.OPTIONS=function(e,t,r,o){return n.request(e,Ht({query:t,method:"OPTIONS",body:r},o))},n.HEAD=function(e,t,r,o){return n.request(e,Ht({query:t,method:"HEAD",body:r},o))},n.PATCH=function(e,t,r,o){return n.request(e,Ht({query:t,method:"PATCH",body:r},o))},n.request=n.requestType(),n}return Pt(t,e),t}(It),Ft=function(){return Ft=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},Ft.apply(this,arguments)};function _t(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))}!function(e){e["[object Array]"]="array",e["[object Object]"]="object",e["[object Function]"]="function",e["[object Set]"]="set",e["[object Map]"]="map",e["[object WeakMap]"]="weakMap",e["[object WeakSet]"]="weakSet",e["[object Date]"]="date",e["[object RegExp]"]="regExp",e["[object Math]"]="math"}(Ct||(Ct={}));var Nt={types:Ct},Wt=function(e){var t=typeof e;if(null===e)return"null";if("object"===t){var n=Object.prototype.toString.call(e);return Ct[n]}return t},Jt=function(e,t){void 0===t&&(t=[]);var n=Wt(e);return t.indexOf(n)>0},Vt={randomNum:function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},urlSplit: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},urlJoin: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("&"))},getType:Wt,getTypeByList:Jt},Ut=function(e,t){return"object"!=typeof e||"null"===t},Gt=function(e){var t=Wt(e);if(Ut(e,t))return e;var n=zt(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,Gt(e))})):"set"===t?e.forEach((function(e){n.add(Gt(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=Gt(r)})),n},zt=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{}}},Qt=function(e){function t(){}return t.prototype=e,new t},$t={getValue: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},setValue: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},mixIn: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},enumInversion:function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},isNotObject:Ut,cloneDeep:Gt,createObjectVariable:zt,createObject:Qt,inherit:function(e,t){return void 0===t&&(t=function(){}),t.prototype=Qt(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},getInstance: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,_t([void 0],n,!1)))),e._instance},classDecorator:function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},stringToJson:function(e){if("string"!==Wt(e))return null;try{return JSON.parse(e)}catch(e){return null}},jsonToString:function(e){if(!Jt(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},isWindow:function(e){return e&&e===e.window}},Kt=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===Wt(e)?Kt(e,t):t.push(e)})),t},Xt={arrayRandom:function(e){return e.sort((function(){return Math.random()-.5}))},arrayUniq:function(e){return Array.from(new Set(e))},arrayDemote:Kt},Yt=void 0,Zt={throttle: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,_t([Yt],r,!1)),n=null}),t))}},debounce: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,_t([Yt],r,!1))}),t)}},defer:function(e){var t,n;return void 0===e&&(e=0),{promise:new Promise((function(r,o){t=r,n=o,e>0&&setTimeout((function(){return n("timeout")}),e)})),resolve:t,reject:n}},catchAwait:function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))}},en={createElement: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(i))||void 0===n||n.forEach((function(e){return a[e]=i[e]}))),u&&u.appendChild(a),a}},tn={addHandler:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},stopBubble:function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},stopDefault:function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},removeHandler:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},dispatchEvent:function(e,t){var n=new Event(t);e.dispatchEvent(n)}},nn={setStorage:function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},getStorage:function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},clearStorage:function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}}},rn=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")},on=function(e){return rn(e,!0,!1)},un=["\\","|","/","—","—"],an=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?un: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 on("\n");s>=l-1&&(s=0);var f=r[s++];return on(f),setTimeout((function(){e.index=s,an(e)}),a),e},cn={logOneLine:rn,logLoop:an},sn=function(){function e(e){this.fn=e,this.id=null,this.duration=1/0,this.isActive=!1}return e.prototype.start=function(e){if(!this.isActive)return this.duration=null!=e?e:1/0,this.isActive=!0,this.animate()},e.prototype.stop=function(e){void 0===e&&(e=this.id),this.isActive=!1,cancelAnimationFrame(e)},e.prototype.animate=function(e){if(void 0===e&&(e=0),this.isActive&&this.duration-- >0)return this.fn(e),this.id=requestAnimationFrame(this.animate.bind(this)),this.id},e}();function ln(e){return 0===e||1===e?1:e*ln(e-1)}function fn(e,t){return ln(e)/(ln(t)*ln(e-t))}var pn={AnimateFrame:sn,quadraticBezier:function(e,t,n){var r=1-n,o=n*n;return[2*r*n*e+o,2*r*n*t+o]},cubicBezier:function(e,t,n,r,o){var i=3*e,u=3*t,a=3*(n-e)-i,c=3*(r-t)-u,s=1-u-c;return[(1-i-a)*Math.pow(o,3)+a*Math.pow(o,2)+i*o,s*Math.pow(o,3)+c*Math.pow(o,2)+u*o]},factorial:ln,combination:fn,NBezier:function(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=fn(n,o)*Math.pow(1-t,n-o)*Math.pow(t,o);r[0]+=i*e[o][0],r[1]+=i*e[o][1]}return r}},hn=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}();hn.Instance(hn);var dn,vn=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new hn),e},yn=function(){return yn=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},yn.apply(this,arguments)},gn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},bn=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())}))},mn=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])}}},wn=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]=yn(yn({},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 bn(t,void 0,void 0,(function(){var e,t,r,o,i;return mn(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=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}([vn,gn("design:paramtypes",[Object])],e),e}(),jn=function(){return jn=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},jn.apply(this,arguments)};function En(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))}!function(e){e["[object Array]"]="array",e["[object Object]"]="object",e["[object Function]"]="function",e["[object Set]"]="set",e["[object Map]"]="map",e["[object WeakMap]"]="weakMap",e["[object WeakSet]"]="weakSet",e["[object Date]"]="date",e["[object RegExp]"]="regExp",e["[object Math]"]="math"}(dn||(dn={}));var On={types:dn},Tn=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("&"))},Sn=function(e){var t=typeof e;if(null===e)return"null";if("object"===t){var n=Object.prototype.toString.call(e);return dn[n]}return t},Pn=function(e,t){void 0===t&&(t=[]);var n=Sn(e);return t.indexOf(n)>0},xn={randomNum:function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},urlSplit: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},urlJoin:Tn,getType:Sn,getTypeByList:Pn},qn=function(e,t){return"object"!=typeof e||"null"===t},kn=function(e){var t=Sn(e);if(qn(e,t))return e;var n=An(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,kn(e))})):"set"===t?e.forEach((function(e){n.add(kn(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=kn(r)})),n},An=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{}}},Hn=function(e){function t(){}return t.prototype=e,new t},Ln=function(e){if("string"!==Sn(e))return null;try{return JSON.parse(e)}catch(e){return null}},Mn=function(e){if(!Pn(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},Cn={getValue: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},setValue: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},mixIn: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},enumInversion:function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},isNotObject:qn,cloneDeep:kn,createObjectVariable:An,createObject:Hn,inherit:function(e,t){return void 0===t&&(t=function(){}),t.prototype=Hn(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},getInstance: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,En([void 0],n,!1)))),e._instance},classDecorator:function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},stringToJson:Ln,jsonToString:Mn,isWindow:function(e){return e&&e===e.window}},Dn=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===Sn(e)?Dn(e,t):t.push(e)})),t},Bn={arrayRandom:function(e){return e.sort((function(){return Math.random()-.5}))},arrayUniq:function(e){return Array.from(new Set(e))},arrayDemote:Dn},In=void 0,Rn=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}},Fn={throttle: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,En([In],r,!1)),n=null}),t))}},debounce: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,En([In],r,!1))}),t)}},defer:Rn,catchAwait:function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))}},_n={createElement: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(i))||void 0===n||n.forEach((function(e){return a[e]=i[e]}))),u&&u.appendChild(a),a}},Nn={addHandler:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},stopBubble:function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},stopDefault:function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},removeHandler:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},dispatchEvent:function(e,t){var n=new Event(t);e.dispatchEvent(n)}},Wn={setStorage:function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},getStorage:function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},clearStorage:function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}}},Jn=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")},Vn=function(e){return Jn(e,!0,!1)},Un=["\\","|","/","—","—"],Gn=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?Un: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 Vn("\n");s>=l-1&&(s=0);var f=r[s++];return Vn(f),setTimeout((function(){e.index=s,Gn(e)}),a),e},zn={logOneLine:Jn,logLoop:Gn};function Qn(e){return 0===e||1===e?1:e*Qn(e-1)}function $n(e,t){return Qn(e)/(Qn(t)*Qn(e-t))}var Kn={AnimateFrame:function(){function e(e){this.fn=e,this.id=null,this.duration=1/0,this.isActive=!1}return e.prototype.start=function(e){this.isActive||(this.duration=null!=e?e:1/0,this.isActive=!0,this.animate())},e.prototype.stop=function(){this.isActive=!1,cancelAnimationFrame(this.id)},e.prototype.animate=function(e){void 0===e&&(e=0),this.isActive&&this.duration-- >0&&(this.fn(e),this.id=requestAnimationFrame(this.animate.bind(this)))},e}(),quadraticBezier:function(e,t,n){var r=1-n,o=n*n;return[2*r*n*e+o,2*r*n*t+o]},cubicBezier:function(e,t,n,r,o){var i=3*e,u=3*t,a=3*(n-e)-i,c=3*(r-t)-u,s=1-u-c;return[(1-i-a)*Math.pow(o,3)+a*Math.pow(o,2)+i*o,s*Math.pow(o,3)+c*Math.pow(o,2)+u*o]},factorial:Qn,combination:$n,NBezier:function(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=$n(n,o)*Math.pow(1-t,n-o)*Math.pow(t,o);r[0]+=i*e[o][0],r[1]+=i*e[o][1]}return r}},Xn=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}();Xn.Instance(Xn);var Yn=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new Xn),e},Zn=function(){return Zn=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},Zn.apply(this,arguments)},er=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},tr=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())}))},nr=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])}}},rr=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]=Zn(Zn({},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 tr(t,void 0,void 0,(function(){var e,t,r,o,i;return nr(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=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}([Yn,er("design:paramtypes",[Object])],e),e}();jn(jn(jn(jn(jn(jn(jn(jn(jn(jn(jn({},Cn),xn),Bn),Fn),_n),On),Nn),Wn),zn),Kn),{eventMessageCenter:Xn,taskQueueLib:rr});
|
|
8
8
|
/**
|
|
9
9
|
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
10
10
|
* @copyright 2015 Toru Nagashima. All rights reserved.
|
|
11
11
|
* See LICENSE file in root directory for full license.
|
|
12
12
|
*/
|
|
13
|
-
const rr=new WeakMap,or=new WeakMap;function ir(e){const t=rr.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function ur(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 ar(e,t){rr.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,cr(t))}}function cr(e){return{get(){return ir(this).event[e]},set(t){ir(this).event[e]=t},configurable:!0,enumerable:!0}}function sr(e){return{value(){const t=ir(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function lr(e){if(null==e||e===Object.prototype)return ar;let t=or.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?sr(i):cr(i))}}return r}(lr(Object.getPrototypeOf(e)),e),or.set(e,t)),t}function fr(e){return ir(e).immediateStopped}function pr(e,t){ir(e).passiveListener=t}ar.prototype={get type(){return ir(this).event.type},get target(){return ir(this).eventTarget},get currentTarget(){return ir(this).currentTarget},composedPath(){const e=ir(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 ir(this).eventPhase},stopPropagation(){const e=ir(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=ir(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(ir(this).event.bubbles)},get cancelable(){return Boolean(ir(this).event.cancelable)},preventDefault(){ur(ir(this))},get defaultPrevented(){return ir(this).canceled},get composed(){return Boolean(ir(this).event.composed)},get timeStamp(){return ir(this).timeStamp},get srcElement(){return ir(this).eventTarget},get cancelBubble(){return ir(this).stopped},set cancelBubble(e){if(!e)return;const t=ir(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!ir(this).canceled},set returnValue(e){e||ur(ir(this))},initEvent(){}},Object.defineProperty(ar.prototype,"constructor",{value:ar,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf(ar.prototype,window.Event.prototype),or.set(window.Event.prototype,ar));const hr=new WeakMap,dr=3;function vr(e){return null!==e&&"object"==typeof e}function yr(e){const t=hr.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function gr(e,t){Object.defineProperty(e,`on${t}`,function(e){return{get(){let t=yr(this).get(e);for(;null!=t;){if(t.listenerType===dr)return t.listener;t=t.next}return null},set(t){"function"==typeof t||vr(t)||(t=null);const n=yr(this);let r=null,o=n.get(e);for(;null!=o;)o.listenerType===dr?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:dr,passive:!1,once:!1,next:null};null===r?n.set(e,o):r.next=o}},configurable:!0,enumerable:!0}}(t))}function br(e){function t(){mr.call(this)}t.prototype=Object.create(mr.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let n=0;n<e.length;++n)gr(t.prototype,e[n]);return t}function mr(){if(!(this instanceof mr)){if(1===arguments.length&&Array.isArray(arguments[0]))return br(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 br(e)}throw new TypeError("Cannot call a class as a function")}hr.set(this,new Map)}mr.prototype={addEventListener(e,t,n){if(null==t)return;if("function"!=typeof t&&!vr(t))throw new TypeError("'listener' should be a function or an object.");const r=yr(this),o=vr(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=yr(this),o=(vr(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=yr(this),n=e.type;let r=t.get(n);if(null==r)return!0;const o=function(e,t){return new(lr(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,pr(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!==dr&&"function"==typeof r.listener.handleEvent&&r.listener.handleEvent(o);if(fr(o))break;r=r.next}return pr(o,null),function(e,t){ir(e).eventPhase=t}(o,0),function(e,t){ir(e).currentTarget=t}(o,null),!o.defaultPrevented}},Object.defineProperty(mr.prototype,"constructor",{value:mr,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(mr.prototype,window.EventTarget.prototype);class wr extends mr{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){const e=jr.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}}gr(wr.prototype,"abort");const jr=new WeakMap;Object.defineProperties(wr.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(wr.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});let Er=class{constructor(){Or.set(this,function(){const e=Object.create(wr.prototype);return mr.call(e),jr.set(e,!1),e}())}get signal(){return Tr(this)}abort(){var e;e=Tr(this),!1===jr.get(e)&&(jr.set(e,!0),e.dispatchEvent({type:"abort"}))}};const Or=new WeakMap;function Tr(e){const t=Or.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(Er.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Er.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});var Sr=function(e,t){return Sr=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])},Sr(e,t)};function Pr(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}Sr(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var xr,qr,kr,Ar,Hr=function(){return Hr=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},Hr.apply(this,arguments)};function Lr(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"==typeof SuppressedError&&SuppressedError;var Mr="undefined"!=typeof AbortController;"undefined"!=typeof window||Mr?xr=globalThis.AbortController:"undefined"!=typeof require?(qr=require("http").request,kr=require("https").request,Ar=require("url").parse,xr=require("abort-controller")):"object"==typeof globalThis?(qr=t.request,kr=n.request,Ar=r.parse,xr=Er):xr=function(){throw new Error("AbortController is not defined")};var Cr=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=Hn(e))&&void 0!==t?t:e},blob:function(){return Hn(e)},formData:function(){return Hn(e)},arrayBuffer:function(){return Hn(e)}}},n.origin=null!=t?t:"",n}return Pr(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}()),Dr=function(e){function t(t){var n=e.call(this,t)||this;return n.initDefaultParams=function(e,t){var r,o,i=t.method,u=void 0===i?"GET":i,a=t.query,c=void 0===a?{}:a,s=t.headers,l=void 0===s?{}:s,f=t.body,p=void 0===f?null:f,h=t.timeout,d=void 0===h?3e4:h,v=t.controller,y=void 0===v?new xr:v,g=t.type,b=void 0===g?"json":g,m=Lr(t,["method","query","headers","body","timeout","controller","type"]),w=Hr({url:e,method:u,query:c,headers:l,body:"GET"===u?null:Ln(p),timeout:d,signal:null==y?void 0:y.signal,controller:y,type:b,timer:null},m),j=null!==(o=null===(r=n.reqFn)||void 0===r?void 0:r.call(n,w))&&void 0!==o?o:w;return j.url=On(n.fixOrigin(e),w.query),j},n.initFetchParams=function(e,t){return n.initAbort(n.initDefaultParams(e,t))},n.initHttpParams=function(e,t){var r=n.initAbort(n.initDefaultParams(e,t)),o=Ar(r.url,!0);return Hr(Hr({},r),o)},n}return Pr(t,e),t}(Cr),Br=function(e){function t(t){var n=e.call(this,t)||this;return n.fetch=function(e,t){var r=In(),o=r.promise,i=r.resolve,u=r.reject,a=n.initFetchParams(e,t),c=a.url,s=Lr(a,["url"]),l=s.signal;return o.finally((function(){return n.clearTimer(s)})),l.addEventListener("abort",(function(){return n.errorFn(u)})),fetch(c,s).then((function(e){return(null==e?void 0:e.status)>=200&&(null==e?void 0:e.status)<300?n.getDataByType(s.type,e):n.errorFn(u)})).then((function(e){var t,r;return i(null!==(r=null===(t=n.resFn)||void 0===t?void 0:t.call(n,e))&&void 0!==r?r:e)})).catch(n.errorFn(u)),o},n.http=function(e,t){var r=In(),o=r.promise,i=r.resolve,u=r.reject,a=n.initHttpParams(e,t),c=a.signal,s=a.url,l=a.body;o.finally((function(){return n.clearTimer(a)}));var f=(n.checkIsHttps(s)?kr:qr)(a,(function(e){var t=e.statusCode,r=e.statusMessage,o="";return e.setEncoding("utf8"),e.on("data",(function(e){return o+=e})),e.on("end",(function(){var e,c,s=n.getDataByType(a.type,n.formatBodyString(o));return t>=200&&t<300?i(null!==(c=null===(e=n.resFn)||void 0===e?void 0:e.call(n,s))&&void 0!==c?c:s):n.errorFn(u)({statusCode:t,statusMessage:r,result:s,data:o})}))}));return c.addEventListener("abort",(function(){return n.errorFn(u)(f.destroy(new Error("request timeout")))})),l&&f.write(l),f.on("error",n.errorFn(u)),f.end(),o},n.GET=function(e,t,r,o){return n.request(e,Hr({query:t,method:"GET"},o))},n.POST=function(e,t,r,o){return n.request(e,Hr({query:t,method:"POST",body:r},o))},n.PUT=function(e,t,r,o){return n.request(e,Hr({query:t,method:"PUT",body:r},o))},n.DELETE=function(e,t,r,o){return n.request(e,Hr({query:t,method:"DELETE",body:r},o))},n.OPTIONS=function(e,t,r,o){return n.request(e,Hr({query:t,method:"OPTIONS",body:r},o))},n.HEAD=function(e,t,r,o){return n.request(e,Hr({query:t,method:"HEAD",body:r},o))},n.PATCH=function(e,t,r,o){return n.request(e,Hr({query:t,method:"PATCH",body:r},o))},n.request=n.requestType(),n}return Pr(t,e),t}(Dr);Rt(Rt(Rt(Rt(Rt(Rt(Rt(Rt(Rt(Rt(Rt({},Qt),Jt),Kt),Yt),Zt),_t),en),tn),an),fn),{eventMessageCenter:pn,taskQueueLib:mn,JSRequest:Br});var Ir=function(){return Ir=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},Ir.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var Rr={type:"interval",autoStop:!0},Fr=function(){function e(e){var t=this;this.__id=0,this.timers={},this.fixString="#@$&*",this.isFrame=function(){return"frame"===t.opts.type},this.opts=Ir(Ir({},Rr),e)}return e.prototype.add=function(e,t){return this.initDelay(t),this.pushTimer(e,t)},e.prototype.delete=function(e){var t,n=e.id,r=e.delay,o=this.timers;r&&(null===(t=o[r])||void 0===t?void 0:t.handles)&&(o[r].handles=o[r].handles.filter((function(e){return e.id!==n})))},e.prototype.clear=function(){var e=this,t=this.timers;Object.keys(t).forEach((function(n){return e.stopTimer(t[n])})),this.timers={}},e.prototype.pushTimer=function(e,t){var n=this.timers,r={id:this.getId(),handle:e,delay:t};return n[t].handles.push(r),r},e.prototype.initDelay=function(e){var t=this.timers;t[e]||(t[e]={intervalId:null,handles:[],delay:e},this.startTimer(t[e]))},e.prototype.startTimer=function(e){var t=this;e.intervalId=this.delayHandle((function(){t.autoStopTimer(e),e.handles.forEach((function(e){return e.handle()}))}),e.delay)},e.prototype.stopTimer=function(e){var t=e.intervalId;this.isFrame()?t():clearInterval(t)},e.prototype.autoStopTimer=function(e){var t=this.opts.autoStop,n=this.timers,r=e.delay;t&&e.handles.length<=0&&(this.stopTimer(e),n[r]=null)},e.prototype.delayHandle=function(e,t){return this.isFrame()?function(e,t){if(void 0===t&&(t=0),!e)throw Error("callback is empty");var n="undefined"!=typeof process?setImmediate:requestAnimationFrame,r=performance,o=r.now(),i=!1,u=function(){i||(r.now()-o>=t&&(o=r.now(),e(o)),n(u))};return u(),function(){return i=!0}}(e,t):setInterval(e,t)},e.prototype.getId=function(){return"".concat(this.fixString,"-").concat(++this.__id)},e}(),_r=o(o(o(o(o(o(o(o(o(o(o({},x),p),H),I),F),u),U),$),ee),ce),{eventMessageCenter:se,taskQueueLib:ge,JSRequest:It,TimerManager:Fr});return e.AnimateFrame=te,e.MessageCenter=se,e.NBezier=ue,e.Request=It,e.TaskQueue=ge,e.TimerManager=Fr,e.addHandler=_,e.arrayDemote=A,e.arrayRandom=q,e.arrayUniq=k,e.catchAwait=B,e.classDecorator=O,e.clearStorage=Q,e.cloneDeep=b,e.combination=ie,e.createElement=R,e.createObject=w,e.createObjectVariable=m,e.cubicBezier=re,e.debounce=C,e.decoratorMessageCenter=fe,e.decoratorTaskQueue=function(e){return function(t){t.prototype.taskQueue||(t.prototype.taskQueue=new ge(e))}},e.default=_r,e.defaultOptions=Rr,e.defer=D,e.dispatchEvent=V,e.enumInversion=y,e.factorial=oe,e.getInstance=E,e.getStorage=z,e.getType=l,e.getTypeByList=f,e.getValue=h,e.inherit=j,e.isNotObject=g,e.isWindow=P,e.jsonToString=S,e.logLoop=Z,e.logOneLine=K,e.messageCenter=le,e.mixIn=v,e.quadraticBezier=ne,e.randomNum=a,e.removeHandler=J,e.requestFrame=function(e,t){if(void 0===t&&(t=0),!e)throw Error("callback is empty");var n="undefined"!=typeof process?setImmediate:requestAnimationFrame,r=performance,o=r.now(),i=!1,u=function(){i||(r.now()-o>=t&&(o=r.now(),e(o)),n(u))};return u(),function(){return i=!0}},e.setStorage=G,e.setValue=d,e.stopBubble=N,e.stopDefault=W,e.stringToJson=T,e.throttle=M,e.urlJoin=s,e.urlSplit=c,Object.defineProperty(e,"__esModule",{value:!0}),e}({},http,https,url);
|
|
13
|
+
const or=new WeakMap,ir=new WeakMap;function ur(e){const t=or.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function ar(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 cr(e,t){or.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,sr(t))}}function sr(e){return{get(){return ur(this).event[e]},set(t){ur(this).event[e]=t},configurable:!0,enumerable:!0}}function lr(e){return{value(){const t=ur(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function fr(e){if(null==e||e===Object.prototype)return cr;let t=ir.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?lr(i):sr(i))}}return r}(fr(Object.getPrototypeOf(e)),e),ir.set(e,t)),t}function pr(e){return ur(e).immediateStopped}function hr(e,t){ur(e).passiveListener=t}cr.prototype={get type(){return ur(this).event.type},get target(){return ur(this).eventTarget},get currentTarget(){return ur(this).currentTarget},composedPath(){const e=ur(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 ur(this).eventPhase},stopPropagation(){const e=ur(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=ur(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(ur(this).event.bubbles)},get cancelable(){return Boolean(ur(this).event.cancelable)},preventDefault(){ar(ur(this))},get defaultPrevented(){return ur(this).canceled},get composed(){return Boolean(ur(this).event.composed)},get timeStamp(){return ur(this).timeStamp},get srcElement(){return ur(this).eventTarget},get cancelBubble(){return ur(this).stopped},set cancelBubble(e){if(!e)return;const t=ur(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!ur(this).canceled},set returnValue(e){e||ar(ur(this))},initEvent(){}},Object.defineProperty(cr.prototype,"constructor",{value:cr,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf(cr.prototype,window.Event.prototype),ir.set(window.Event.prototype,cr));const dr=new WeakMap,vr=3;function yr(e){return null!==e&&"object"==typeof e}function gr(e){const t=dr.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function br(e,t){Object.defineProperty(e,`on${t}`,function(e){return{get(){let t=gr(this).get(e);for(;null!=t;){if(t.listenerType===vr)return t.listener;t=t.next}return null},set(t){"function"==typeof t||yr(t)||(t=null);const n=gr(this);let r=null,o=n.get(e);for(;null!=o;)o.listenerType===vr?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:vr,passive:!1,once:!1,next:null};null===r?n.set(e,o):r.next=o}},configurable:!0,enumerable:!0}}(t))}function mr(e){function t(){wr.call(this)}t.prototype=Object.create(wr.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let n=0;n<e.length;++n)br(t.prototype,e[n]);return t}function wr(){if(!(this instanceof wr)){if(1===arguments.length&&Array.isArray(arguments[0]))return mr(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 mr(e)}throw new TypeError("Cannot call a class as a function")}dr.set(this,new Map)}wr.prototype={addEventListener(e,t,n){if(null==t)return;if("function"!=typeof t&&!yr(t))throw new TypeError("'listener' should be a function or an object.");const r=gr(this),o=yr(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=gr(this),o=(yr(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=gr(this),n=e.type;let r=t.get(n);if(null==r)return!0;const o=function(e,t){return new(fr(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,hr(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!==vr&&"function"==typeof r.listener.handleEvent&&r.listener.handleEvent(o);if(pr(o))break;r=r.next}return hr(o,null),function(e,t){ur(e).eventPhase=t}(o,0),function(e,t){ur(e).currentTarget=t}(o,null),!o.defaultPrevented}},Object.defineProperty(wr.prototype,"constructor",{value:wr,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(wr.prototype,window.EventTarget.prototype);class jr extends wr{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){const e=Er.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}}br(jr.prototype,"abort");const Er=new WeakMap;Object.defineProperties(jr.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(jr.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});let Or=class{constructor(){Tr.set(this,function(){const e=Object.create(jr.prototype);return wr.call(e),Er.set(e,!1),e}())}get signal(){return Sr(this)}abort(){var e;e=Sr(this),!1===Er.get(e)&&(Er.set(e,!0),e.dispatchEvent({type:"abort"}))}};const Tr=new WeakMap;function Sr(e){const t=Tr.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(Or.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Or.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});var Pr=function(e,t){return Pr=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])},Pr(e,t)};function xr(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}Pr(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var qr,kr,Ar,Hr,Lr=function(){return Lr=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},Lr.apply(this,arguments)};function Mr(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"==typeof SuppressedError&&SuppressedError;var Cr="undefined"!=typeof AbortController;"undefined"!=typeof window||Cr?qr=globalThis.AbortController:"undefined"!=typeof require?(kr=require("http").request,Ar=require("https").request,Hr=require("url").parse,qr=require("abort-controller")):"object"==typeof globalThis?(kr=t.request,Ar=n.request,Hr=r.parse,qr=Or):qr=function(){throw new Error("AbortController is not defined")};var Dr=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=Ln(e))&&void 0!==t?t:e},blob:function(){return Ln(e)},formData:function(){return Ln(e)},arrayBuffer:function(){return Ln(e)}}},n.origin=null!=t?t:"",n}return xr(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}()),Br=function(e){function t(t){var n=e.call(this,t)||this;return n.initDefaultParams=function(e,t){var r,o,i=t.method,u=void 0===i?"GET":i,a=t.query,c=void 0===a?{}:a,s=t.headers,l=void 0===s?{}:s,f=t.body,p=void 0===f?null:f,h=t.timeout,d=void 0===h?3e4:h,v=t.controller,y=void 0===v?new qr:v,g=t.type,b=void 0===g?"json":g,m=Mr(t,["method","query","headers","body","timeout","controller","type"]),w=Lr({url:e,method:u,query:c,headers:l,body:"GET"===u?null:Mn(p),timeout:d,signal:null==y?void 0:y.signal,controller:y,type:b,timer:null},m),j=null!==(o=null===(r=n.reqFn)||void 0===r?void 0:r.call(n,w))&&void 0!==o?o:w;return j.url=Tn(n.fixOrigin(e),w.query),j},n.initFetchParams=function(e,t){return n.initAbort(n.initDefaultParams(e,t))},n.initHttpParams=function(e,t){var r=n.initAbort(n.initDefaultParams(e,t)),o=Hr(r.url,!0);return Lr(Lr({},r),o)},n}return xr(t,e),t}(Dr),Ir=function(e){function t(t){var n=e.call(this,t)||this;return n.fetch=function(e,t){var r=Rn(),o=r.promise,i=r.resolve,u=r.reject,a=n.initFetchParams(e,t),c=a.url,s=Mr(a,["url"]),l=s.signal;return o.finally((function(){return n.clearTimer(s)})),l.addEventListener("abort",(function(){return n.errorFn(u)})),fetch(c,s).then((function(e){return(null==e?void 0:e.status)>=200&&(null==e?void 0:e.status)<300?n.getDataByType(s.type,e):n.errorFn(u)})).then((function(e){var t,r;return i(null!==(r=null===(t=n.resFn)||void 0===t?void 0:t.call(n,e))&&void 0!==r?r:e)})).catch(n.errorFn(u)),o},n.http=function(e,t){var r=Rn(),o=r.promise,i=r.resolve,u=r.reject,a=n.initHttpParams(e,t),c=a.signal,s=a.url,l=a.body;o.finally((function(){return n.clearTimer(a)}));var f=(n.checkIsHttps(s)?Ar:kr)(a,(function(e){var t=e.statusCode,r=e.statusMessage,o="";return e.setEncoding("utf8"),e.on("data",(function(e){return o+=e})),e.on("end",(function(){var e,c,s=n.getDataByType(a.type,n.formatBodyString(o));return t>=200&&t<300?i(null!==(c=null===(e=n.resFn)||void 0===e?void 0:e.call(n,s))&&void 0!==c?c:s):n.errorFn(u)({statusCode:t,statusMessage:r,result:s,data:o})}))}));return c.addEventListener("abort",(function(){return n.errorFn(u)(f.destroy(new Error("request timeout")))})),l&&f.write(l),f.on("error",n.errorFn(u)),f.end(),o},n.GET=function(e,t,r,o){return n.request(e,Lr({query:t,method:"GET"},o))},n.POST=function(e,t,r,o){return n.request(e,Lr({query:t,method:"POST",body:r},o))},n.PUT=function(e,t,r,o){return n.request(e,Lr({query:t,method:"PUT",body:r},o))},n.DELETE=function(e,t,r,o){return n.request(e,Lr({query:t,method:"DELETE",body:r},o))},n.OPTIONS=function(e,t,r,o){return n.request(e,Lr({query:t,method:"OPTIONS",body:r},o))},n.HEAD=function(e,t,r,o){return n.request(e,Lr({query:t,method:"HEAD",body:r},o))},n.PATCH=function(e,t,r,o){return n.request(e,Lr({query:t,method:"PATCH",body:r},o))},n.request=n.requestType(),n}return xr(t,e),t}(Br);Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft({},$t),Vt),Xt),Zt),en),Nt),tn),nn),cn),pn),{eventMessageCenter:hn,taskQueueLib:wn,JSRequest:Ir});var Rr=function(){return Rr=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},Rr.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var Fr={type:"interval",autoStop:!0},_r=function(){function e(e){var t=this;this.__id=0,this.timers={},this.fixString="#@$&*",this.isFrame=function(){return"frame"===t.opts.type},this.opts=Rr(Rr({},Fr),e)}return e.prototype.add=function(e,t){return this.initDelay(t),this.pushTimer(e,t)},e.prototype.delete=function(e){var t,n=e.id,r=e.delay,o=this.timers;r&&(null===(t=o[r])||void 0===t?void 0:t.handles)&&(o[r].handles=o[r].handles.filter((function(e){return e.id!==n})))},e.prototype.clear=function(){var e=this,t=this.timers;Object.keys(t).forEach((function(n){return e.stopTimer(t[n])})),this.timers={}},e.prototype.pushTimer=function(e,t){var n=this.timers,r={id:this.getId(),handle:e,delay:t};return n[t].handles.push(r),r},e.prototype.initDelay=function(e){var t=this.timers;t[e]||(t[e]={intervalId:null,handles:[],delay:e},this.startTimer(t[e]))},e.prototype.startTimer=function(e){var t=this;e.intervalId=this.delayHandle((function(){t.autoStopTimer(e),e.handles.forEach((function(e){return e.handle()}))}),e.delay)},e.prototype.stopTimer=function(e){var t=e.intervalId;this.isFrame()?t():clearInterval(t)},e.prototype.autoStopTimer=function(e){var t=this.opts.autoStop,n=this.timers,r=e.delay;t&&e.handles.length<=0&&(this.stopTimer(e),n[r]=null)},e.prototype.delayHandle=function(e,t){return this.isFrame()?function(e,t){if(void 0===t&&(t=0),!e)throw Error("callback is empty");var n="undefined"!=typeof process?setImmediate:requestAnimationFrame,r=performance,o=r.now(),i=!1,u=function(){i||(r.now()-o>=t&&(o=r.now(),e(o)),n(u))};return u(),function(){return i=!0}}(e,t):setInterval(e,t)},e.prototype.getId=function(){return"".concat(this.fixString,"-").concat(++this.__id)},e}(),Nr=o(o(o(o(o(o(o(o(o(o(o({},q),p),L),R),_),u),G),K),te),se),{eventMessageCenter:le,taskQueueLib:be,JSRequest:Rt,TimerManager:_r});return e.AnimateFrame=ne,e.MessageCenter=le,e.NBezier=ae,e.Request=Rt,e.TaskQueue=be,e.TimerManager=_r,e.addHandler=N,e.arrayDemote=H,e.arrayRandom=k,e.arrayUniq=A,e.catchAwait=I,e.classDecorator=O,e.clearStorage=$,e.cloneDeep=b,e.combination=ue,e.createElement=F,e.createObject=w,e.createObjectVariable=m,e.cubicBezier=oe,e.debounce=D,e.decoratorMessageCenter=pe,e.decoratorTaskQueue=function(e){return function(t){t.prototype.taskQueue||(t.prototype.taskQueue=new be(e))}},e.default=Nr,e.defaultOptions=Fr,e.defer=B,e.dispatchEvent=U,e.emptyObject=x,e.enumInversion=y,e.factorial=ie,e.getInstance=E,e.getStorage=Q,e.getType=l,e.getTypeByList=f,e.getValue=h,e.inherit=j,e.isNotObject=g,e.isWindow=P,e.jsonToString=S,e.logLoop=ee,e.logOneLine=X,e.messageCenter=fe,e.mixIn=v,e.quadraticBezier=re,e.randomNum=a,e.removeHandler=V,e.requestFrame=function(e,t){if(void 0===t&&(t=0),!e)throw Error("callback is empty");var n="undefined"!=typeof process?setImmediate:requestAnimationFrame,r=performance,o=r.now(),i=!1,u=function(){i||(r.now()-o>=t&&(o=r.now(),e(o)),n(u))};return u(),function(){return i=!0}},e.setStorage=z,e.setValue=d,e.stopBubble=W,e.stopDefault=J,e.stringToJson=T,e.throttle=C,e.urlJoin=s,e.urlSplit=c,Object.defineProperty(e,"__esModule",{value:!0}),e}({},http,https,url);
|
package/dist/bundle/object.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString } from "./types";
|
|
1
|
+
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString, IObject } from "./types";
|
|
2
2
|
export declare const getValue: IGetValue;
|
|
3
3
|
export declare const setValue: ISetValue;
|
|
4
4
|
export declare const mixIn: IMixIn;
|
|
@@ -13,6 +13,7 @@ export declare const classDecorator: IClassDecorator;
|
|
|
13
13
|
export declare const stringToJson: IStringToJson;
|
|
14
14
|
export declare const jsonToString: IJsonToString;
|
|
15
15
|
export declare const isWindow: (win: any) => boolean;
|
|
16
|
+
export declare const emptyObject: (init?: IObject<unknown>) => any;
|
|
16
17
|
declare const _default: {
|
|
17
18
|
getValue: IGetValue;
|
|
18
19
|
setValue: ISetValue;
|
|
@@ -28,5 +29,6 @@ declare const _default: {
|
|
|
28
29
|
stringToJson: IStringToJson;
|
|
29
30
|
jsonToString: IJsonToString;
|
|
30
31
|
isWindow: (win: any) => boolean;
|
|
32
|
+
emptyObject: (init?: IObject<unknown>) => any;
|
|
31
33
|
};
|
|
32
34
|
export default _default;
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -257,6 +257,12 @@ var jsonToString$3 = function (target) {
|
|
|
257
257
|
var isWindow$3 = function (win) {
|
|
258
258
|
return win && win === win.window;
|
|
259
259
|
};
|
|
260
|
+
var emptyObject = function (init) {
|
|
261
|
+
if (init === void 0) { init = {}; }
|
|
262
|
+
var _o = Object.create(null);
|
|
263
|
+
Reflect.ownKeys(init).forEach(function (k) { return _o[k] = init[k]; });
|
|
264
|
+
return _o;
|
|
265
|
+
};
|
|
260
266
|
var object$3 = {
|
|
261
267
|
getValue: getValue$3,
|
|
262
268
|
setValue: setValue$3,
|
|
@@ -272,6 +278,7 @@ var object$3 = {
|
|
|
272
278
|
stringToJson: stringToJson$3,
|
|
273
279
|
jsonToString: jsonToString$3,
|
|
274
280
|
isWindow: isWindow$3,
|
|
281
|
+
emptyObject: emptyObject,
|
|
275
282
|
};
|
|
276
283
|
|
|
277
284
|
var arrayRandom$3 = function (arr) { return arr.sort(function () { return Math.random() - 0.5; }); };
|
|
@@ -6120,6 +6127,7 @@ exports.default = index;
|
|
|
6120
6127
|
exports.defaultOptions = defaultOptions;
|
|
6121
6128
|
exports.defer = defer$3;
|
|
6122
6129
|
exports.dispatchEvent = dispatchEvent$3;
|
|
6130
|
+
exports.emptyObject = emptyObject;
|
|
6123
6131
|
exports.enumInversion = enumInversion$3;
|
|
6124
6132
|
exports.factorial = factorial$3;
|
|
6125
6133
|
exports.getInstance = getInstance$3;
|
package/dist/cjs/object.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString } from "./types";
|
|
1
|
+
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString, IObject } from "./types";
|
|
2
2
|
export declare const getValue: IGetValue;
|
|
3
3
|
export declare const setValue: ISetValue;
|
|
4
4
|
export declare const mixIn: IMixIn;
|
|
@@ -13,6 +13,7 @@ export declare const classDecorator: IClassDecorator;
|
|
|
13
13
|
export declare const stringToJson: IStringToJson;
|
|
14
14
|
export declare const jsonToString: IJsonToString;
|
|
15
15
|
export declare const isWindow: (win: any) => boolean;
|
|
16
|
+
export declare const emptyObject: (init?: IObject<unknown>) => any;
|
|
16
17
|
declare const _default: {
|
|
17
18
|
getValue: IGetValue;
|
|
18
19
|
setValue: ISetValue;
|
|
@@ -28,5 +29,6 @@ declare const _default: {
|
|
|
28
29
|
stringToJson: IStringToJson;
|
|
29
30
|
jsonToString: IJsonToString;
|
|
30
31
|
isWindow: (win: any) => boolean;
|
|
32
|
+
emptyObject: (init?: IObject<unknown>) => any;
|
|
31
33
|
};
|
|
32
34
|
export default _default;
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -253,6 +253,12 @@ var jsonToString$3 = function (target) {
|
|
|
253
253
|
var isWindow$3 = function (win) {
|
|
254
254
|
return win && win === win.window;
|
|
255
255
|
};
|
|
256
|
+
var emptyObject = function (init) {
|
|
257
|
+
if (init === void 0) { init = {}; }
|
|
258
|
+
var _o = Object.create(null);
|
|
259
|
+
Reflect.ownKeys(init).forEach(function (k) { return _o[k] = init[k]; });
|
|
260
|
+
return _o;
|
|
261
|
+
};
|
|
256
262
|
var object$3 = {
|
|
257
263
|
getValue: getValue$3,
|
|
258
264
|
setValue: setValue$3,
|
|
@@ -268,6 +274,7 @@ var object$3 = {
|
|
|
268
274
|
stringToJson: stringToJson$3,
|
|
269
275
|
jsonToString: jsonToString$3,
|
|
270
276
|
isWindow: isWindow$3,
|
|
277
|
+
emptyObject: emptyObject,
|
|
271
278
|
};
|
|
272
279
|
|
|
273
280
|
var arrayRandom$3 = function (arr) { return arr.sort(function () { return Math.random() - 0.5; }); };
|
|
@@ -6090,4 +6097,4 @@ var TimerManager = (function () {
|
|
|
6090
6097
|
|
|
6091
6098
|
var index = __assign$9(__assign$9(__assign$9(__assign$9(__assign$9(__assign$9(__assign$9(__assign$9(__assign$9(__assign$9(__assign$9({}, object$3), base$3), array$3), __function$3), element$3), __static$3), event$3), storage$3), log$3), animate$3), { eventMessageCenter: MessageCenter$3, taskQueueLib: TaskQueue$3, JSRequest: Request$1, TimerManager: TimerManager });
|
|
6092
6099
|
|
|
6093
|
-
export { AnimateFrame$3 as AnimateFrame, MessageCenter$3 as MessageCenter, NBezier$3 as NBezier, Request$1 as Request, TaskQueue$3 as TaskQueue, TimerManager, addHandler$3 as addHandler, arrayDemote$3 as arrayDemote, arrayRandom$3 as arrayRandom, arrayUniq$3 as arrayUniq, catchAwait$3 as catchAwait, classDecorator$3 as classDecorator, clearStorage$3 as clearStorage, cloneDeep$3 as cloneDeep, combination$3 as combination, createElement$3 as createElement, createObject$3 as createObject, createObjectVariable$3 as createObjectVariable, cubicBezier$3 as cubicBezier, debounce$3 as debounce, decoratorMessageCenter$3 as decoratorMessageCenter, decoratorTaskQueue, index as default, defaultOptions, defer$3 as defer, dispatchEvent$3 as dispatchEvent, enumInversion$3 as enumInversion, factorial$3 as factorial, getInstance$3 as getInstance, getStorage$3 as getStorage, getType$3 as getType, getTypeByList$3 as getTypeByList, getValue$3 as getValue, inherit$3 as inherit, isNotObject$3 as isNotObject, isWindow$3 as isWindow, jsonToString$3 as jsonToString, logLoop$3 as logLoop, logOneLine$3 as logOneLine, messageCenter, mixIn$3 as mixIn, quadraticBezier$3 as quadraticBezier, randomNum$3 as randomNum, removeHandler$3 as removeHandler, requestFrame$1 as requestFrame, setStorage$3 as setStorage, setValue$3 as setValue, stopBubble$3 as stopBubble, stopDefault$3 as stopDefault, stringToJson$3 as stringToJson, throttle$3 as throttle, types$3 as types, urlJoin$3 as urlJoin, urlSplit$3 as urlSplit };
|
|
6100
|
+
export { AnimateFrame$3 as AnimateFrame, MessageCenter$3 as MessageCenter, NBezier$3 as NBezier, Request$1 as Request, TaskQueue$3 as TaskQueue, TimerManager, addHandler$3 as addHandler, arrayDemote$3 as arrayDemote, arrayRandom$3 as arrayRandom, arrayUniq$3 as arrayUniq, catchAwait$3 as catchAwait, classDecorator$3 as classDecorator, clearStorage$3 as clearStorage, cloneDeep$3 as cloneDeep, combination$3 as combination, createElement$3 as createElement, createObject$3 as createObject, createObjectVariable$3 as createObjectVariable, cubicBezier$3 as cubicBezier, debounce$3 as debounce, decoratorMessageCenter$3 as decoratorMessageCenter, decoratorTaskQueue, index as default, defaultOptions, defer$3 as defer, dispatchEvent$3 as dispatchEvent, emptyObject, enumInversion$3 as enumInversion, factorial$3 as factorial, getInstance$3 as getInstance, getStorage$3 as getStorage, getType$3 as getType, getTypeByList$3 as getTypeByList, getValue$3 as getValue, inherit$3 as inherit, isNotObject$3 as isNotObject, isWindow$3 as isWindow, jsonToString$3 as jsonToString, logLoop$3 as logLoop, logOneLine$3 as logOneLine, messageCenter, mixIn$3 as mixIn, quadraticBezier$3 as quadraticBezier, randomNum$3 as randomNum, removeHandler$3 as removeHandler, requestFrame$1 as requestFrame, setStorage$3 as setStorage, setValue$3 as setValue, stopBubble$3 as stopBubble, stopDefault$3 as stopDefault, stringToJson$3 as stringToJson, throttle$3 as throttle, types$3 as types, urlJoin$3 as urlJoin, urlSplit$3 as urlSplit };
|
package/dist/esm/object.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString } from "./types";
|
|
1
|
+
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString, IObject } from "./types";
|
|
2
2
|
export declare const getValue: IGetValue;
|
|
3
3
|
export declare const setValue: ISetValue;
|
|
4
4
|
export declare const mixIn: IMixIn;
|
|
@@ -13,6 +13,7 @@ export declare const classDecorator: IClassDecorator;
|
|
|
13
13
|
export declare const stringToJson: IStringToJson;
|
|
14
14
|
export declare const jsonToString: IJsonToString;
|
|
15
15
|
export declare const isWindow: (win: any) => boolean;
|
|
16
|
+
export declare const emptyObject: (init?: IObject<unknown>) => any;
|
|
16
17
|
declare const _default: {
|
|
17
18
|
getValue: IGetValue;
|
|
18
19
|
setValue: ISetValue;
|
|
@@ -28,5 +29,6 @@ declare const _default: {
|
|
|
28
29
|
stringToJson: IStringToJson;
|
|
29
30
|
jsonToString: IJsonToString;
|
|
30
31
|
isWindow: (win: any) => boolean;
|
|
32
|
+
emptyObject: (init?: IObject<unknown>) => any;
|
|
31
33
|
};
|
|
32
34
|
export default _default;
|
package/dist/umd/index.d.ts
CHANGED
package/dist/umd/index.js
CHANGED
|
@@ -255,6 +255,12 @@
|
|
|
255
255
|
var isWindow$3 = function (win) {
|
|
256
256
|
return win && win === win.window;
|
|
257
257
|
};
|
|
258
|
+
var emptyObject = function (init) {
|
|
259
|
+
if (init === void 0) { init = {}; }
|
|
260
|
+
var _o = Object.create(null);
|
|
261
|
+
Reflect.ownKeys(init).forEach(function (k) { return _o[k] = init[k]; });
|
|
262
|
+
return _o;
|
|
263
|
+
};
|
|
258
264
|
var object$3 = {
|
|
259
265
|
getValue: getValue$3,
|
|
260
266
|
setValue: setValue$3,
|
|
@@ -270,6 +276,7 @@
|
|
|
270
276
|
stringToJson: stringToJson$3,
|
|
271
277
|
jsonToString: jsonToString$3,
|
|
272
278
|
isWindow: isWindow$3,
|
|
279
|
+
emptyObject: emptyObject,
|
|
273
280
|
};
|
|
274
281
|
|
|
275
282
|
var arrayRandom$3 = function (arr) { return arr.sort(function () { return Math.random() - 0.5; }); };
|
|
@@ -6118,6 +6125,7 @@
|
|
|
6118
6125
|
exports.defaultOptions = defaultOptions;
|
|
6119
6126
|
exports.defer = defer$3;
|
|
6120
6127
|
exports.dispatchEvent = dispatchEvent$3;
|
|
6128
|
+
exports.emptyObject = emptyObject;
|
|
6121
6129
|
exports.enumInversion = enumInversion$3;
|
|
6122
6130
|
exports.factorial = factorial$3;
|
|
6123
6131
|
exports.getInstance = getInstance$3;
|
package/dist/umd/object.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString } from "./types";
|
|
1
|
+
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString, IObject } from "./types";
|
|
2
2
|
export declare const getValue: IGetValue;
|
|
3
3
|
export declare const setValue: ISetValue;
|
|
4
4
|
export declare const mixIn: IMixIn;
|
|
@@ -13,6 +13,7 @@ export declare const classDecorator: IClassDecorator;
|
|
|
13
13
|
export declare const stringToJson: IStringToJson;
|
|
14
14
|
export declare const jsonToString: IJsonToString;
|
|
15
15
|
export declare const isWindow: (win: any) => boolean;
|
|
16
|
+
export declare const emptyObject: (init?: IObject<unknown>) => any;
|
|
16
17
|
declare const _default: {
|
|
17
18
|
getValue: IGetValue;
|
|
18
19
|
setValue: ISetValue;
|
|
@@ -28,5 +29,6 @@ declare const _default: {
|
|
|
28
29
|
stringToJson: IStringToJson;
|
|
29
30
|
jsonToString: IJsonToString;
|
|
30
31
|
isWindow: (win: any) => boolean;
|
|
32
|
+
emptyObject: (init?: IObject<unknown>) => any;
|
|
31
33
|
};
|
|
32
34
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "utils-lib-js",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "JavaScript工具函数,封装的一些常用的js函数",
|
|
5
|
-
"main": "./dist/cjs/index.js",
|
|
6
|
-
"types": "./dist/cjs/index.d.ts",
|
|
7
|
-
"module": "./dist/esm/index.js",
|
|
8
|
-
"type": "module",
|
|
9
|
-
"exports": {
|
|
10
|
-
"import": "./dist/esm/index.js",
|
|
11
|
-
"require": "./dist/cjs/index.js"
|
|
12
|
-
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "utils-lib-js",
|
|
3
|
+
"version": "2.0.13",
|
|
4
|
+
"description": "JavaScript工具函数,封装的一些常用的js函数",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"types": "./dist/cjs/index.d.ts",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
"import": "./dist/esm/index.js",
|
|
11
|
+
"require": "./dist/cjs/index.js"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"debug": "start cmd /k pnpm run build:hot & pnpm run node:hot",
|
|
15
|
+
"node:hot": "nodemon example.js --watch example.js",
|
|
16
|
+
"build:hot": "pnpm rollup -c --watch",
|
|
17
|
+
"build": "pnpm run rollup:build && pnpm run commonjs",
|
|
18
|
+
"rollup:build": "rm -fr dist && pnpm rollup -c",
|
|
19
|
+
"build:publish": "pnpm run build && pnpm publish",
|
|
20
|
+
"commonjs": "cp ./commonjs.json dist/cjs/package.json"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://gitee.com/DieHunter/utils-lib-js.git"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"utils",
|
|
28
|
+
"tools",
|
|
29
|
+
"lib"
|
|
30
|
+
],
|
|
31
|
+
"author": "",
|
|
32
|
+
"license": "ISC",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@rollup/plugin-alias": "^4.0.3",
|
|
35
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
36
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
37
|
+
"@types/node": "^18.7.15",
|
|
38
|
+
"rollup": "^3.20.2",
|
|
39
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
40
|
+
"tslib": "^2.5.0",
|
|
41
|
+
"typescript": "^4.9.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"event-message-center": "^1.3.2",
|
|
45
|
+
"js-request-lib": "^1.0.7",
|
|
46
|
+
"task-queue-lib": "^1.2.0",
|
|
47
|
+
"timer-manager-lib": "^1.0.0"
|
|
48
|
+
},
|
|
49
|
+
"umdModuleName": "UtilsLib"
|
|
50
|
+
}
|