utils-lib-js 2.0.0 → 2.0.3
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 +1 -1
- package/README.md +1 -1
- package/dist/bundle/index.d.ts +3 -0
- package/dist/bundle/index.js +1 -1
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +1182 -66
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +1131 -16
- package/dist/umd/index.d.ts +3 -0
- package/dist/umd/index.js +1182 -66
- package/package.json +13 -12
- package/rollup.config.js +1 -0
package/README.en.md
CHANGED
|
@@ -330,7 +330,7 @@ timer? : number
|
|
|
330
330
|
export type ILogLoop = (opts? : ILogLoopParams) => ILogLoopParams | void
|
|
331
331
|
|
|
332
332
|
##### request module
|
|
333
|
-
###### https://gitee.com/DieHunter/js-request
|
|
333
|
+
###### https://gitee.com/DieHunter/js-request-lib
|
|
334
334
|
export type IRequestParams<T> = T | IObject<any> | null
|
|
335
335
|
|
|
336
336
|
// Request path
|
package/README.md
CHANGED
|
@@ -329,7 +329,7 @@ export type ILogLoopParams = {
|
|
|
329
329
|
export type ILogLoop = (opts?: ILogLoopParams) => ILogLoopParams | void
|
|
330
330
|
|
|
331
331
|
##### request 模块
|
|
332
|
-
###### https://gitee.com/DieHunter/js-request
|
|
332
|
+
###### https://gitee.com/DieHunter/js-request-lib
|
|
333
333
|
export type IRequestParams<T> = T | IObject<any> | null
|
|
334
334
|
|
|
335
335
|
// 请求路径
|
package/dist/bundle/index.d.ts
CHANGED
|
@@ -11,11 +11,14 @@ export * from "./log";
|
|
|
11
11
|
export * from "./animate";
|
|
12
12
|
export * from "event-message-center";
|
|
13
13
|
export * from "task-queue-lib";
|
|
14
|
+
export * from "js-request-lib";
|
|
14
15
|
import eventMessageCenter from "event-message-center";
|
|
15
16
|
import taskQueueLib from "task-queue-lib";
|
|
17
|
+
import JSRequest from "js-request-lib";
|
|
16
18
|
declare const _default: {
|
|
17
19
|
eventMessageCenter: typeof eventMessageCenter;
|
|
18
20
|
taskQueueLib: typeof taskQueueLib;
|
|
21
|
+
JSRequest: typeof JSRequest;
|
|
19
22
|
AnimateFrame: typeof import("./animate").AnimateFrame;
|
|
20
23
|
quadraticBezier: typeof import("./animate").quadraticBezier;
|
|
21
24
|
cubicBezier: typeof import("./animate").cubicBezier;
|
package/dist/bundle/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var UtilsLib=function(e){"use strict";var t,n=function(){return n=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},n.apply(this,arguments)};function r(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,(t=e.types||(e.types={}))["[object Array]"]="array",t["[object Object]"]="object",t["[object Function]"]="function",t["[object Set]"]="set",t["[object Map]"]="map",t["[object WeakMap]"]="weakMap",t["[object WeakSet]"]="weakSet",t["[object Date]"]="date",t["[object RegExp]"]="regExp",t["[object Math]"]="math";var o={types:e.types},i=function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},u=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},a=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("&"))},c=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},s=function(e,t){void 0===t&&(t=[]);var n=c(e);return t.indexOf(n)>0},l={randomNum:i,urlSplit:u,urlJoin:a,getType:c,getTypeByList:s},f=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},p=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},h=function(e,t,n){var r;for(var o in void 0===t&&(t={}),void 0===n&&(n=!1),t)for(var i in t[o]){var u=null!==(r=e.prototype)&&void 0!==r?r:e;(void 0===e[i]||n)&&(u[i]=t[o][i])}return e},d=function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},v=function(e,t){return"object"!=typeof e||"null"===t},y=function(e){var t=c(e);if(v(e,t))return e;var n=g(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,y(e))})):"set"===t?e.forEach((function(e){n.add(y(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=y(r)})),n},g=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{}}},m=function(e){function t(){}return t.prototype=e,new t},b=function(e,t){return void 0===t&&(t=function(){}),t.prototype=m(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},w=function(e,t){void 0===t&&(t=!1);for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return e._instance&&!t||(e._instance=new(e.bind.apply(e,r([void 0],n,!1)))),e._instance},j=function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},E=function(e){if("string"!==c(e))return null;try{return JSON.parse(e)}catch(e){return null}},S=function(e){if(!s(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},O=function(e){return e&&e===e.window},x={getValue:f,setValue:p,mixIn:h,enumInversion:d,isNotObject:v,cloneDeep:y,createObjectVariable:g,createObject:m,inherit:b,getInstance:w,classDecorator:j,stringToJson:E,jsonToString:S,isWindow:O},k=function(e){return e.sort((function(){return Math.random()-.5}))},P=function(e){return Array.from(new Set(e))},T=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===c(e)?T(e,t):t.push(e)})),t},H={arrayRandom:k,arrayUniq:P,arrayDemote:T},q=void 0,L=function(e,t){var n=null;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];n||(n=setTimeout((function(){e.call.apply(e,r([q],o,!1)),n=null}),t))}},M=function(e,t){var n=null;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];n&&(clearTimeout(n),n=null),n=setTimeout((function(){e.call.apply(e,r([q],o,!1))}),t)}},C=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}},A=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},R={throttle:L,debounce:M,defer:C,catchAwait:A},D=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},B={createElement:D},I=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},J=function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},_=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)},z={addHandler:I,stopBubble:N,stopDefault:J,removeHandler:_,dispatchEvent:V},F=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}},W=function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}},U={setStorage:F,getStorage:Q,clearStorage:W},G=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")},K=function(e){return G(e,!0,!1)},$=["\\","|","/","—","—"],X=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?$: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 K("\n");s>=l-1&&(s=0);var f=r[s++];return K(f),setTimeout((function(){e.index=s,X(e)}),a),e},Y={logOneLine:G,logLoop:X},Z=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 ee(e,t,n){var r=1-n,o=n*n;return[2*r*n*e+o,2*r*n*t+o]}function te(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 ne(e){return 0===e||1===e?1:e*ne(e-1)}function re(e,t){return ne(e)/(ne(t)*ne(e-t))}function oe(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=re(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 ie={AnimateFrame:Z,quadraticBezier:ee,cubicBezier:te,factorial:ne,combination:re,NBezier:oe},ue=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}(),ae=ue.Instance(ue),ce=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new ue),e},se=function(){return se=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},se.apply(this,arguments)},le=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},fe=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},pe=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())}))},he=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])}}},de=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]=se(se({},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 pe(t,void 0,void 0,(function(){var e,t,r,o,i;return he(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=le([ce,fe("design:paramtypes",[Object])],e)}(),ve=n(n(n(n(n(n(n(n(n(n(n({},x),l),H),R),B),o),z),U),Y),ie),{eventMessageCenter:ue,taskQueueLib:de});return e.AnimateFrame=Z,e.MessageCenter=ue,e.NBezier=oe,e.TaskQueue=de,e.addHandler=I,e.arrayDemote=T,e.arrayRandom=k,e.arrayUniq=P,e.catchAwait=A,e.classDecorator=j,e.clearStorage=W,e.cloneDeep=y,e.combination=re,e.createElement=D,e.createObject=m,e.createObjectVariable=g,e.cubicBezier=te,e.debounce=M,e.decoratorMessageCenter=ce,e.decoratorTaskQueue=function(e){return function(t){t.prototype.taskQueue||(t.prototype.taskQueue=new de(e))}},e.default=ve,e.defer=C,e.dispatchEvent=V,e.enumInversion=d,e.factorial=ne,e.getInstance=w,e.getStorage=Q,e.getType=c,e.getTypeByList=s,e.getValue=f,e.inherit=b,e.isNotObject=v,e.isWindow=O,e.jsonToString=S,e.logLoop=X,e.logOneLine=G,e.messageCenter=ae,e.mixIn=h,e.quadraticBezier=ee,e.randomNum=i,e.removeHandler=_,e.setStorage=F,e.setValue=p,e.stopBubble=N,e.stopDefault=J,e.stringToJson=E,e.throttle=L,e.urlJoin=a,e.urlSplit=u,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
1
|
+
var UtilsLib=function(e){"use strict";var t=function(){return t=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},t.apply(this,arguments)};function n(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 r={types:e.types},o=function(e,t,n){return void 0===n&&(n=!1),Math.floor(Math.random()*(t-e+(n?1:0))+e)},i=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},u=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("&"))},a=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},c=function(e,t){void 0===t&&(t=[]);var n=a(e);return t.indexOf(n)>0},s={randomNum:o,urlSplit:i,urlJoin:u,getType:a,getTypeByList:c},l=function(e,t,n){void 0===n&&(n="");for(var r=0,o=t.split(".");r<o.length;r++){if(void 0===(e=e[o[r]]))return n}return e},f=function(e,t,n){void 0===n&&(n={});for(var r=t.split("."),o=r[r.length-1],i=e,u=0,a=r;u<a.length;u++){var c=a[u];if("object"!=typeof i&&void 0!==i)return e;!i&&(i={}),!i[c]&&(i[c]={}),o===c&&(i[o]=n),i=i[c]}return e},p=function(e,t,n){var r;for(var o in void 0===t&&(t={}),void 0===n&&(n=!1),t)for(var i in t[o]){var u=null!==(r=e.prototype)&&void 0!==r?r:e;(void 0===e[i]||n)&&(u[i]=t[o][i])}return e},h=function(e){for(var t in e){var n=e[t];"string"!=typeof n||e[n]||(e[n]=t)}return e},d=function(e,t){return"object"!=typeof e||"null"===t},v=function(e){var t=a(e);if(d(e,t))return e;var n=y(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,v(e))})):"set"===t?e.forEach((function(e){n.add(v(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=v(r)})),n},y=function(e,t){switch(void 0===t&&(t={}),e){case"array":return[];case"function":return t;case"set":return new Set;case"map":return new Map;case"date":return new Date(t);case"regExp":return new RegExp(t);case"math":return Math;default:return{}}},m=function(e){function t(){}return t.prototype=e,new t},g=function(e,t){return void 0===t&&(t=function(){}),t.prototype=m(e.prototype),t.prototype.super=e,t.prototype.constructor=t,t},b=function(e,t){void 0===t&&(t=!1);for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return e._instance&&!t||(e._instance=new(e.bind.apply(e,n([void 0],r,!1)))),e._instance},w=function(e){return function(t){for(var n in e)Reflect.has(t.prototype,n)||(t.prototype[n]=e[n])}},j=function(e){if("string"!==a(e))return null;try{return JSON.parse(e)}catch(e){return null}},E=function(e){if(!c(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},O=function(e){return e&&e===e.window},S={getValue:l,setValue:f,mixIn:p,enumInversion:h,isNotObject:d,cloneDeep:v,createObjectVariable:y,createObject:m,inherit:g,getInstance:b,classDecorator:w,stringToJson:j,jsonToString:E,isWindow:O},q=function(e){return e.sort((function(){return Math.random()-.5}))},P=function(e){return Array.from(new Set(e))},x=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===a(e)?x(e,t):t.push(e)})),t},T={arrayRandom:q,arrayUniq:P,arrayDemote:x},k=void 0,H=function(e,t){var r=null;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];r||(r=setTimeout((function(){e.call.apply(e,n([k],o,!1)),r=null}),t))}},L=function(e,t){var r=null;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];r&&(clearTimeout(r),r=null),r=setTimeout((function(){e.call.apply(e,n([k],o,!1))}),t)}},A=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}},C=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},M={throttle:H,debounce:L,defer:A,catchAwait:C},D=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},R={createElement:D},F=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=n},B=function(e){(e=e||window.event).stopPropagation?e.stopPropagation():e.cancelBubble=!1},I=function(e){(e=e||window.event).preventDefault?e.preventDefault():e.returnValue=!1},_=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e["on"+t]=null},N=function(e,t){var n=new Event(t);e.dispatchEvent(n)},J={addHandler:F,stopBubble:B,stopDefault:I,removeHandler:_,dispatchEvent:N},W=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},V=function(e){try{var t=localStorage.getItem(e);return null==t?null:JSON.parse(t)}catch(e){return console.error(e),null}},z=function(e){try{e&&localStorage.removeItem(e),!e&&localStorage.clear()}catch(e){console.error(e)}},U={setStorage:W,getStorage:V,clearStorage:z},G=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")},Q=function(e){return G(e,!0,!1)},K=["\\","|","/","—","—"],$=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?K: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 Q("\n");s>=l-1&&(s=0);var f=r[s++];return Q(f),setTimeout((function(){e.index=s,$(e)}),a),e},X={logOneLine:G,logLoop:$},Y=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 Z(e,t,n){var r=1-n,o=n*n;return[2*r*n*e+o,2*r*n*t+o]}function ee(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 te(e){return 0===e||1===e?1:e*te(e-1)}function ne(e,t){return te(e)/(te(t)*te(e-t))}function re(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=ne(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 oe,ie={AnimateFrame:Y,quadraticBezier:Z,cubicBezier:ee,factorial:te,combination:ne,NBezier:re},ue=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}(),ae=ue.Instance(ue),ce=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new ue),e},se=function(){return se=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},se.apply(this,arguments)},le=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},fe=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},pe=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())}))},he=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])}}},de=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]=se(se({},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 pe(t,void 0,void 0,(function(){var e,t,r,o,i;return he(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=le([ce,fe("design:paramtypes",[Object])],e)}(),ve=function(){return ve=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},ve.apply(this,arguments)};function ye(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"}(oe||(oe={}));var me={types:oe},ge=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("&"))},be=function(e){var t=typeof e;if(null===e)return"null";if("object"===t){var n=Object.prototype.toString.call(e);return oe[n]}return t},we=function(e,t){void 0===t&&(t=[]);var n=be(e);return t.indexOf(n)>0},je={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:ge,getType:be,getTypeByList:we},Ee=function(e,t){return"object"!=typeof e||"null"===t},Oe=function(e){var t=be(e);if(Ee(e,t))return e;var n=Se(t,e);return"map"===t?e.forEach((function(e,t){n.set(t,Oe(e))})):"set"===t?e.forEach((function(e){n.add(Oe(e))})):Reflect.ownKeys(e).forEach((function(t){var r=e[t];n[t]=Oe(r)})),n},Se=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},Pe=function(e){if("string"!==be(e))return null;try{return JSON.parse(e)}catch(e){return null}},xe=function(e){if(!we(e,["array","object","set","map"]))return"";try{return JSON.stringify(e)}catch(e){return""}},Te={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:Ee,cloneDeep:Oe,createObjectVariable:Se,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,ye([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:Pe,jsonToString:xe,isWindow:function(e){return e&&e===e.window}},ke=function(e,t){return void 0===t&&(t=[]),e.forEach((function(e){return"array"===be(e)?ke(e,t):t.push(e)})),t},He={arrayRandom:function(e){return e.sort((function(){return Math.random()-.5}))},arrayUniq:function(e){return Array.from(new Set(e))},arrayDemote:ke},Le=void 0,Ae=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}},Ce={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,ye([Le],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,ye([Le],r,!1))}),t)}},defer:Ae,catchAwait:function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))}},Me={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}},De={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)}},Re={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)}}},Fe=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")},Be=function(e){return Fe(e,!0,!1)},Ie=["\\","|","/","—","—"],_e=function(e){var t;void 0===e&&(e={});var n=e.loopList,r=void 0===n?Ie: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 Be("\n");s>=l-1&&(s=0);var f=r[s++];return Be(f),setTimeout((function(){e.index=s,_e(e)}),a),e},Ne={logOneLine:Fe,logLoop:_e};function Je(e){return 0===e||1===e?1:e*Je(e-1)}function We(e,t){return Je(e)/(Je(t)*Je(e-t))}var Ve={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:Je,combination:We,NBezier:function(e,t){for(var n=e.length-1,r=[0,0],o=0;o<=n;o++){var i=We(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}},ze=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}();ze.Instance(ze);var Ue=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new ze),e},Ge=function(){return Ge=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},Ge.apply(this,arguments)},Qe=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ke=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((r=r.apply(e,t||[])).next())}))},$e=function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Xe=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]=Ge(Ge({},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 Ke(t,void 0,void 0,(function(){var e,t,r,o,i;return $e(this,(function(u){switch(u.label){case 0:if("pending"===this.stateProxy())return[2,void 0];if(0===this.queues.length)return[2,this.stateProxy("idle")];this.stateProxy("pending"),e=this.unshift(null!==(i=null===(o=this.props)||void 0===o?void 0:o.maxLen)&&void 0!==i?i:10),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,Promise.all(e.map((function(e,t){return e.defer().catch((function(e){return e}))})))];case 2:return t=u.sent(),[2,this.handlerSuccess({res:t,queues:e})];case 3:return r=u.sent(),[2,this.handlerError({reject:n,error:r,queues:e})];case 4:return[2]}}))}))},this.clear=function(){t.queues=[],t.queueTemp={},t.props=null,t.stateProxy("idle"),t.messageCenter.clear()},this.finish=function(e){var n=e.res,r=void 0===n?[]:n,o=e.queues,i=e.error,u=void 0===i?"err":i,a=t.queueTemp;o.forEach((function(e,n){var o,i,c,s=a[e.name];null==s||s.result.push(null!==(o=r[n])&&void 0!==o?o:u),(null===(i=null==s?void 0:s.result)||void 0===i?void 0:i.length)===(null===(c=null==s?void 0:s.children)||void 0===c?void 0:c.length)&&(t.messageCenter.emit(e.name,null==s?void 0:s.result),a[e.name]=null)}))},this.handlerSuccess=function(e){return t.stateProxy("fulfilled"),t.messageCenter.emit("run:success:handler",e)},this.handlerError=function(e){var n=e.reject,r=e.error;return t.stateProxy("rejected"),n&&"function"==typeof n&&n(r),t.messageCenter.emit("run:error:handler",e)},this.stateProxy=function(e){return e&&(t.state=e),t.state},this.defer=function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),resolve:e,reject:t}},this.clear(),e&&this.defineProps(e,"props"),this.init()}return e.prototype.checkHandler=function(e){var t,n;if(!e)throw new ReferenceError("queue is not defined");if(!(e.children instanceof Array)||"object"!=typeof e)throw new TypeError("queue should be an object and queue.children should be an array");if(0===(null===(t=e.children)||void 0===t?void 0:t.length))throw new Error("queue.children.length can not be 0");if(null===(n=e.children)||void 0===n?void 0:n.find((function(e){return function(e){return!e||"function"!=typeof e}(e)})))throw new Error("queueList should have defer")},e.prototype.fixStr=function(e){return"".concat(this.fix).concat(e)},e=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}([Ue,Qe("design:paramtypes",[Object])],e),e}();ve(ve(ve(ve(ve(ve(ve(ve(ve(ve(ve({},Te),je),He),Ce),Me),me),De),Re),Ne),Ve),{eventMessageCenter:ze,taskQueueLib:Xe});var Ye=function(e,t){return Ye=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])},Ye(e,t)};function Ze(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}Ye(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var et,tt,nt,rt,ot=function(){return ot=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},ot.apply(this,arguments)};function it(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,"undefined"!=typeof require?(rt=require("abort-controller"),et=require("http").request,tt=require("https").request,nt=require("url").parse):rt="undefined"!=typeof AbortController?AbortController:function(){throw new Error("AbortController is not defined")};var ut=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=Pe(e))&&void 0!==t?t:e},blob:function(){return Pe(e)},formData:function(){return Pe(e)},arrayBuffer:function(){return Pe(e)}}},n.origin=null!=t?t:"",n}return Ze(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}()),at=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 rt:v,m=t.type,g=void 0===m?"json":m,b=it(t,["method","query","headers","body","timeout","controller","type"]),w=ot({url:e,method:u,query:c,headers:l,body:"GET"===u?null:xe(p),timeout:d,signal:null==y?void 0:y.signal,controller:y,type:g,timer:null},b),j=null!==(o=null===(r=n.reqFn)||void 0===r?void 0:r.call(n,w))&&void 0!==o?o:w;return j.url=ge(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=nt(r.url,!0);return ot(ot({},r),o)},n}return Ze(t,e),t}(ut),ct=function(e){function t(t){var n=e.call(this,t)||this;return n.fetch=function(e,t){var r=Ae(),o=r.promise,i=r.resolve,u=r.reject,a=n.initFetchParams(e,t),c=a.url,s=it(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=Ae(),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)?tt:et)(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,ot({query:t,method:"GET"},o))},n.POST=function(e,t,r,o){return n.request(e,ot({query:t,method:"POST",body:r},o))},n.PUT=function(e,t,r,o){return n.request(e,ot({query:t,method:"PUT",body:r},o))},n.DELETE=function(e,t,r,o){return n.request(e,ot({query:t,method:"DELETE",body:r},o))},n.OPTIONS=function(e,t,r,o){return n.request(e,ot({query:t,method:"OPTIONS",body:r},o))},n.HEAD=function(e,t,r,o){return n.request(e,ot({query:t,method:"HEAD",body:r},o))},n.PATCH=function(e,t,r,o){return n.request(e,ot({query:t,method:"PATCH",body:r},o))},n.request=n.requestType(),n}return Ze(t,e),t}(at),st=t(t(t(t(t(t(t(t(t(t(t({},S),s),T),M),R),r),J),U),X),ie),{eventMessageCenter:ue,taskQueueLib:de,JSRequest:ct});return e.AnimateFrame=Y,e.MessageCenter=ue,e.NBezier=re,e.Request=ct,e.TaskQueue=de,e.addHandler=F,e.arrayDemote=x,e.arrayRandom=q,e.arrayUniq=P,e.catchAwait=C,e.classDecorator=w,e.clearStorage=z,e.cloneDeep=v,e.combination=ne,e.createElement=D,e.createObject=m,e.createObjectVariable=y,e.cubicBezier=ee,e.debounce=L,e.decoratorMessageCenter=ce,e.decoratorTaskQueue=function(e){return function(t){t.prototype.taskQueue||(t.prototype.taskQueue=new de(e))}},e.default=st,e.defer=A,e.dispatchEvent=N,e.enumInversion=h,e.factorial=te,e.getInstance=b,e.getStorage=V,e.getType=a,e.getTypeByList=c,e.getValue=l,e.inherit=g,e.isNotObject=d,e.isWindow=O,e.jsonToString=E,e.logLoop=$,e.logOneLine=G,e.messageCenter=ae,e.mixIn=p,e.quadraticBezier=Z,e.randomNum=o,e.removeHandler=_,e.setStorage=W,e.setValue=f,e.stopBubble=B,e.stopDefault=I,e.stringToJson=j,e.throttle=H,e.urlJoin=u,e.urlSplit=i,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -11,11 +11,14 @@ export * from "./log";
|
|
|
11
11
|
export * from "./animate";
|
|
12
12
|
export * from "event-message-center";
|
|
13
13
|
export * from "task-queue-lib";
|
|
14
|
+
export * from "js-request-lib";
|
|
14
15
|
import eventMessageCenter from "event-message-center";
|
|
15
16
|
import taskQueueLib from "task-queue-lib";
|
|
17
|
+
import JSRequest from "js-request-lib";
|
|
16
18
|
declare const _default: {
|
|
17
19
|
eventMessageCenter: typeof eventMessageCenter;
|
|
18
20
|
taskQueueLib: typeof taskQueueLib;
|
|
21
|
+
JSRequest: typeof JSRequest;
|
|
19
22
|
AnimateFrame: typeof import("./animate").AnimateFrame;
|
|
20
23
|
quadraticBezier: typeof import("./animate").quadraticBezier;
|
|
21
24
|
cubicBezier: typeof import("./animate").cubicBezier;
|