utils-lib-js 2.0.8 → 2.0.9
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 +19 -1
- package/README.md +62 -30
- package/dist/bundle/animate.d.ts +3 -3
- package/dist/bundle/function.d.ts +2 -1
- package/dist/bundle/index.js +2 -2
- package/dist/bundle/types.d.ts +2 -1
- package/dist/cjs/animate.d.ts +3 -3
- package/dist/cjs/function.d.ts +2 -1
- package/dist/cjs/index.js +29 -3
- package/dist/cjs/types.d.ts +2 -1
- package/dist/esm/animate.d.ts +3 -3
- package/dist/esm/function.d.ts +2 -1
- package/dist/esm/index.js +29 -4
- package/dist/esm/types.d.ts +2 -1
- package/dist/umd/animate.d.ts +3 -3
- package/dist/umd/function.d.ts +2 -1
- package/dist/umd/index.js +29 -3
- package/dist/umd/types.d.ts +2 -1
- package/package.json +49 -49
package/README.en.md
CHANGED
|
@@ -435,6 +435,24 @@ console.log(error); // Output: Error: Something went wrong!
|
|
|
435
435
|
console.log(result); // Output: null
|
|
436
436
|
```
|
|
437
437
|
|
|
438
|
+
##### 5. `requestFrame(callback: (timestamp: number) => void, delay? : number): () => void`
|
|
439
|
+
|
|
440
|
+
Custom frame callbacks for use in browsers and Node.js environments (like setinterval)
|
|
441
|
+
|
|
442
|
+
- callback: callback function to be executed in each frame, receiving a parameter timestamp indicating the current timestamp.
|
|
443
|
+
- delay (optional) : specifies the interval (milliseconds) between each callback execution. The default value is 0.
|
|
444
|
+
|
|
445
|
+
````javascript
|
|
446
|
+
let count = 0;
|
|
447
|
+
const clear = requestFrame(() => {
|
|
448
|
+
console.log(count);
|
|
449
|
+
count++;
|
|
450
|
+
if (count === 5) {
|
|
451
|
+
clear(); // Cancel the execution
|
|
452
|
+
}
|
|
453
|
+
}, 1000);
|
|
454
|
+
```
|
|
455
|
+
|
|
438
456
|
#### element module
|
|
439
457
|
|
|
440
458
|
##### 1. `createElement(options: { ele? : string | HTMLElement, style? : object, attr? : object, parent? : HTMLElement }): HTMLElement`
|
|
@@ -456,7 +474,7 @@ const options = {
|
|
|
456
474
|
|
|
457
475
|
const createdElement = createElement(options);
|
|
458
476
|
// Create a div element with style and attributes in the body
|
|
459
|
-
|
|
477
|
+
````
|
|
460
478
|
|
|
461
479
|
#### event module
|
|
462
480
|
|
package/README.md
CHANGED
|
@@ -435,6 +435,24 @@ console.log(error); // 输出: Error: Something went wrong!
|
|
|
435
435
|
console.log(result); // 输出: null
|
|
436
436
|
```
|
|
437
437
|
|
|
438
|
+
##### 5. `requestFrame(callback: (timestamp: number) => void, delay?: number): () => void`
|
|
439
|
+
|
|
440
|
+
在浏览器和 Node.js 环境中使用的自定义帧回调函数(类似setinterval)
|
|
441
|
+
|
|
442
|
+
- callback: 每一帧中要执行的回调函数,接收一个参数 timestamp 表示当前时间戳。
|
|
443
|
+
- delay(可选): 每次执行回调函数之间的时间间隔(毫秒),默认为 0。
|
|
444
|
+
|
|
445
|
+
```javascript
|
|
446
|
+
let count = 0;
|
|
447
|
+
const clear = requestFrame(() => {
|
|
448
|
+
console.log(count);
|
|
449
|
+
count++;
|
|
450
|
+
if (count === 5) {
|
|
451
|
+
clear();// 取消执行
|
|
452
|
+
}
|
|
453
|
+
}, 1000);
|
|
454
|
+
```
|
|
455
|
+
|
|
438
456
|
#### element 模块
|
|
439
457
|
|
|
440
458
|
##### 1. `createElement(options: { ele?: string | HTMLElement, style?: object, attr?: object, parent?: HTMLElement }): HTMLElement`
|
|
@@ -448,15 +466,16 @@ console.log(result); // 输出: null
|
|
|
448
466
|
|
|
449
467
|
```javascript
|
|
450
468
|
const options = {
|
|
451
|
-
ele:
|
|
452
|
-
style: { color:
|
|
453
|
-
attr: { id:
|
|
454
|
-
parent: document.body
|
|
469
|
+
ele: "div",
|
|
470
|
+
style: { color: "blue", fontSize: "16px" },
|
|
471
|
+
attr: { id: "myElement", className: "custom-class" },
|
|
472
|
+
parent: document.body,
|
|
455
473
|
};
|
|
456
474
|
|
|
457
475
|
const createdElement = createElement(options);
|
|
458
476
|
// 在 body 中创建一个带有样式和属性的 div 元素
|
|
459
477
|
```
|
|
478
|
+
|
|
460
479
|
#### event 模块
|
|
461
480
|
|
|
462
481
|
##### 1. `addHandler(ele: HTMLElement, type: string, handler: EventListener): void`
|
|
@@ -468,9 +487,9 @@ const createdElement = createElement(options);
|
|
|
468
487
|
- `handler`: 事件处理函数。
|
|
469
488
|
|
|
470
489
|
```javascript
|
|
471
|
-
const button = document.getElementById(
|
|
472
|
-
const handleClick = () => console.log(
|
|
473
|
-
addHandler(button,
|
|
490
|
+
const button = document.getElementById("myButton");
|
|
491
|
+
const handleClick = () => console.log("Button clicked!");
|
|
492
|
+
addHandler(button, "click", handleClick);
|
|
474
493
|
```
|
|
475
494
|
|
|
476
495
|
##### 2. `stopBubble(event: Event): void`
|
|
@@ -481,7 +500,7 @@ addHandler(button, 'click', handleClick);
|
|
|
481
500
|
|
|
482
501
|
```javascript
|
|
483
502
|
const handleClick = (event) => {
|
|
484
|
-
console.log(
|
|
503
|
+
console.log("Button clicked!");
|
|
485
504
|
stopBubble(event);
|
|
486
505
|
};
|
|
487
506
|
```
|
|
@@ -494,7 +513,7 @@ const handleClick = (event) => {
|
|
|
494
513
|
|
|
495
514
|
```javascript
|
|
496
515
|
const handleFormSubmit = (event) => {
|
|
497
|
-
console.log(
|
|
516
|
+
console.log("Form submitted!");
|
|
498
517
|
stopDefault(event);
|
|
499
518
|
};
|
|
500
519
|
```
|
|
@@ -508,11 +527,11 @@ const handleFormSubmit = (event) => {
|
|
|
508
527
|
- `handler`: 要移除的事件处理函数。
|
|
509
528
|
|
|
510
529
|
```javascript
|
|
511
|
-
const button = document.getElementById(
|
|
512
|
-
const handleClick = () => console.log(
|
|
513
|
-
addHandler(button,
|
|
530
|
+
const button = document.getElementById("myButton");
|
|
531
|
+
const handleClick = () => console.log("Button clicked!");
|
|
532
|
+
addHandler(button, "click", handleClick);
|
|
514
533
|
// 其他操作...
|
|
515
|
-
removeHandler(button,
|
|
534
|
+
removeHandler(button, "click", handleClick);
|
|
516
535
|
```
|
|
517
536
|
|
|
518
537
|
##### 5. `dispatchEvent(ele: HTMLElement, data: any): void`
|
|
@@ -523,10 +542,13 @@ removeHandler(button, 'click', handleClick);
|
|
|
523
542
|
- `data`: 自定义事件的数据。
|
|
524
543
|
|
|
525
544
|
```javascript
|
|
526
|
-
const customEvent = new CustomEvent(
|
|
527
|
-
|
|
545
|
+
const customEvent = new CustomEvent("customEvent", {
|
|
546
|
+
detail: { key: "value" },
|
|
547
|
+
});
|
|
548
|
+
const targetElement = document.getElementById("myElement");
|
|
528
549
|
dispatchEvent(targetElement, customEvent);
|
|
529
550
|
```
|
|
551
|
+
|
|
530
552
|
#### storage 模块
|
|
531
553
|
|
|
532
554
|
##### 1. `setStorage(key: string, val: any): void`
|
|
@@ -537,8 +559,8 @@ dispatchEvent(targetElement, customEvent);
|
|
|
537
559
|
- `val`: 要存储的值。
|
|
538
560
|
|
|
539
561
|
```javascript
|
|
540
|
-
const userData = { username:
|
|
541
|
-
setStorage(
|
|
562
|
+
const userData = { username: "john_doe", email: "john@example.com" };
|
|
563
|
+
setStorage("user_data", userData);
|
|
542
564
|
```
|
|
543
565
|
|
|
544
566
|
##### 2. `getStorage(key: string): any`
|
|
@@ -548,7 +570,7 @@ setStorage('user_data', userData);
|
|
|
548
570
|
- `key`: 要获取的键名。
|
|
549
571
|
|
|
550
572
|
```javascript
|
|
551
|
-
const storedUserData = getStorage(
|
|
573
|
+
const storedUserData = getStorage("user_data");
|
|
552
574
|
console.log(storedUserData);
|
|
553
575
|
// 输出: { username: 'john_doe', email: 'john@example.com' }
|
|
554
576
|
```
|
|
@@ -560,7 +582,7 @@ console.log(storedUserData);
|
|
|
560
582
|
- `key`: 可选,要清除的键名。如果未提供键名,则清除所有存储。
|
|
561
583
|
|
|
562
584
|
```javascript
|
|
563
|
-
clearStorage(
|
|
585
|
+
clearStorage("user_data"); // 清除特定键名的存储值
|
|
564
586
|
// 或者
|
|
565
587
|
clearStorage(); // 清除所有本地存储的值
|
|
566
588
|
```
|
|
@@ -576,7 +598,7 @@ clearStorage(); // 清除所有本地存储的值
|
|
|
576
598
|
- `wrap`: 是否在输出后换行,默认为 `true`。
|
|
577
599
|
|
|
578
600
|
```javascript
|
|
579
|
-
logOneLine(
|
|
601
|
+
logOneLine("This is a single line log message.");
|
|
580
602
|
```
|
|
581
603
|
|
|
582
604
|
##### 2. `logLoop(opts?: { loopList?: string[], isStop?: boolean, timer?: number, index?: number }): { loopList?: string[], isStop?: boolean, timer?: number, index?: number }`
|
|
@@ -592,8 +614,9 @@ logOneLine('This is a single line log message.');
|
|
|
592
614
|
```javascript
|
|
593
615
|
logLoop(); // 启动默认循环动画
|
|
594
616
|
// 或者
|
|
595
|
-
logLoop({ loopList: [
|
|
617
|
+
logLoop({ loopList: ["-", "+", "-", "+"], timer: 200 }); // 启动自定义循环动画
|
|
596
618
|
```
|
|
619
|
+
|
|
597
620
|
#### animation 模块
|
|
598
621
|
|
|
599
622
|
##### 1. `class AnimateFrame`
|
|
@@ -606,7 +629,7 @@ logLoop({ loopList: ['-', '+', '-', '+'], timer: 200 }); // 启动自定义循
|
|
|
606
629
|
```javascript
|
|
607
630
|
const animateFrame = new AnimateFrame((timestamp) => {
|
|
608
631
|
// 在此处更新动画状态
|
|
609
|
-
console.log(
|
|
632
|
+
console.log("AnimationFrame callback:", timestamp);
|
|
610
633
|
});
|
|
611
634
|
|
|
612
635
|
animateFrame.start(60); // 启动帧动画,每秒 60 帧
|
|
@@ -618,8 +641,8 @@ animateFrame.stop(); // 停止帧动画
|
|
|
618
641
|
|
|
619
642
|
计算二次贝塞尔曲线上的点坐标。
|
|
620
643
|
|
|
621
|
-
- `_x`: 控制点1 x 坐标。
|
|
622
|
-
- `_y`: 控制点1 y 坐标。
|
|
644
|
+
- `_x`: 控制点 1 x 坐标。
|
|
645
|
+
- `_y`: 控制点 1 y 坐标。
|
|
623
646
|
- `t`: 时间参数,取值范围 [0, 1]。
|
|
624
647
|
|
|
625
648
|
```javascript
|
|
@@ -632,10 +655,10 @@ console.log(result);
|
|
|
632
655
|
|
|
633
656
|
计算三次贝塞尔曲线上的点坐标。
|
|
634
657
|
|
|
635
|
-
- `_x1`: 控制点1 x 坐标。
|
|
636
|
-
- `_y1`: 控制点1 y 坐标。
|
|
637
|
-
- `_x2`: 控制点2 x 坐标。
|
|
638
|
-
- `_y2`: 控制点2 y 坐标。
|
|
658
|
+
- `_x1`: 控制点 1 x 坐标。
|
|
659
|
+
- `_y1`: 控制点 1 y 坐标。
|
|
660
|
+
- `_x2`: 控制点 2 x 坐标。
|
|
661
|
+
- `_y2`: 控制点 2 y 坐标。
|
|
639
662
|
- `t`: 时间参数,取值范围 [0, 1]。
|
|
640
663
|
|
|
641
664
|
```javascript
|
|
@@ -677,15 +700,24 @@ console.log(result);
|
|
|
677
700
|
- `t`: 时间参数,取值范围 [0, 1]。
|
|
678
701
|
|
|
679
702
|
```javascript
|
|
680
|
-
const points = [
|
|
703
|
+
const points = [
|
|
704
|
+
[0, 0],
|
|
705
|
+
[1, 1],
|
|
706
|
+
[2, 0],
|
|
707
|
+
];
|
|
681
708
|
const result = NBezier(points, 0.5);
|
|
682
709
|
console.log(result);
|
|
683
710
|
// 输出: [1.5, 0.75]
|
|
684
711
|
```
|
|
685
712
|
|
|
686
713
|
#### event-message-center
|
|
714
|
+
|
|
687
715
|
https://gitee.com/DieHunter/message-center
|
|
716
|
+
|
|
688
717
|
#### task-queue-lib
|
|
718
|
+
|
|
689
719
|
https://gitee.com/DieHunter/task-queue
|
|
720
|
+
|
|
690
721
|
#### js-request-lib
|
|
691
|
-
|
|
722
|
+
|
|
723
|
+
https://gitee.com/DieHunter/js-request-lib
|
package/dist/bundle/animate.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ export declare class AnimateFrame implements IAnimateFrame {
|
|
|
5
5
|
duration: number;
|
|
6
6
|
isActive: boolean;
|
|
7
7
|
constructor(fn: any);
|
|
8
|
-
start(duration: any):
|
|
9
|
-
stop(): void;
|
|
10
|
-
animate(timer?: number):
|
|
8
|
+
start(duration: any): any;
|
|
9
|
+
stop(id?: any): void;
|
|
10
|
+
animate(timer?: number): any;
|
|
11
11
|
}
|
|
12
12
|
export declare function quadraticBezier(_x: number, _y: number, t: number): number[];
|
|
13
13
|
export declare function cubicBezier(_x1: number, _y1: number, _x2: number, _y2: number, t: number): number[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ICatchAwait, IThrottle, IDebounce, IDefer } from "./types";
|
|
1
|
+
import { ICatchAwait, IThrottle, IDebounce, IDefer, IRequestFrame } from "./types";
|
|
2
2
|
export declare const throttle: IThrottle;
|
|
3
3
|
export declare const debounce: IDebounce;
|
|
4
4
|
export declare const defer: IDefer;
|
|
5
5
|
export declare const catchAwait: ICatchAwait<Promise<any>>;
|
|
6
|
+
export declare const requestFrame: IRequestFrame;
|
|
6
7
|
declare const _default: {
|
|
7
8
|
throttle: IThrottle;
|
|
8
9
|
debounce: IDebounce;
|
package/dist/bundle/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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])}},S=function(e){if("string"!==l(e))return null;try{return JSON.parse(e)}catch(e){return null}},T=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:S,jsonToString:T,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,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([L],r,!1)),n=null}),t))}},M=function(e,t){var n=null;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n&&(clearTimeout(n),n=null),n=setTimeout((function(){e.call.apply(e,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]}))},R={throttle:C,debounce:M,defer:D,catchAwait:B},I=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:I},N=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=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:N,stopBubble:_,stopDefault:W,removeHandler:J,dispatchEvent:V},z=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},G=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:z,getStorage:G,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){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 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},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:je,getType:Ee,getTypeByList:Oe},Te=function(e,t){return"object"!=typeof e||"null"===t},Pe=function(e){var t=Ee(e);if(Te(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:Te,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},Ce={arrayRandom:function(e){return e.sort((function(){return Math.random()-.5}))},arrayUniq:function(e){return Array.from(new Set(e))},arrayDemote:Le},Me=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([Me],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([Me],r,!1))}),t)}},defer:De,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}},Ie={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)}}},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")},_e=function(e){return Ne(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 _e("\n");s>=l-1&&(s=0);var f=r[s++];return _e(f),setTimeout((function(){e.index=s,Je(e)}),a),e},Ve={logOneLine:Ne,logLoop:Je};function Ue(e){return 0===e||1===e?1:e*Ue(e-1)}function ze(e,t){return Ue(e)/(Ue(t)*Ue(e-t))}var Ge={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:Ue,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}},Qe=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}();Qe.Instance(Qe);var $e=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new Qe),e},Ke=function(){return Ke=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},Ke.apply(this,arguments)},Xe=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())}))},Ze=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])}}},et=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]=Ke(Ke({},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 Ze(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}([$e,Xe("design:paramtypes",[Object])],e),e}();be(be(be(be(be(be(be(be(be(be(be({},He),Se),Ce),Be),Re),we),Ie),Fe),Ve),Ge),{eventMessageCenter:Qe,taskQueueLib:et});
|
|
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,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([L],r,!1)),n=null}),t))}},M=function(e,t){var n=null;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n&&(clearTimeout(n),n=null),n=setTimeout((function(){e.call.apply(e,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]}))},R={throttle:C,debounce:M,defer:D,catchAwait:B},I=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:I},N=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e["on"+t]=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:N,stopBubble:_,stopDefault:W,removeHandler:J,dispatchEvent:V},z=function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}},G=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:z,getStorage:G,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},Ce={arrayRandom:function(e){return e.sort((function(){return Math.random()-.5}))},arrayUniq:function(e){return Array.from(new Set(e))},arrayDemote:Le},Me=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([Me],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([Me],r,!1))}),t)}},defer:De,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}},Ie={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)}}},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")},_e=function(e){return Ne(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 _e("\n");s>=l-1&&(s=0);var f=r[s++];return _e(f),setTimeout((function(){e.index=s,Je(e)}),a),e},Ve={logOneLine:Ne,logLoop:Je};function Ue(e){return 0===e||1===e?1:e*Ue(e-1)}function ze(e,t){return Ue(e)/(Ue(t)*Ue(e-t))}var Ge={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:Ue,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}},Qe=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}();Qe.Instance(Qe);var $e=function(e){return e.prototype.messageCenter||(e.prototype.messageCenter=new Qe),e},Ke=function(){return Ke=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},Ke.apply(this,arguments)},Xe=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())}))},Ze=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])}}},et=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]=Ke(Ke({},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 Ze(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}([$e,Xe("design:paramtypes",[Object])],e),e}();be(be(be(be(be(be(be(be(be(be(be({},He),Te),Ce),Be),Re),we),Ie),Fe),Ve),Ge),{eventMessageCenter:Qe,taskQueueLib:et});
|
|
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 tt=new WeakMap,nt=new WeakMap;function rt(e){const t=tt.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function ot(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 it(e,t){tt.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,ut(t))}}function ut(e){return{get(){return rt(this).event[e]},set(t){rt(this).event[e]=t},configurable:!0,enumerable:!0}}function at(e){return{value(){const t=rt(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function ct(e){if(null==e||e===Object.prototype)return it;let t=nt.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?at(i):ut(i))}}return r}(ct(Object.getPrototypeOf(e)),e),nt.set(e,t)),t}function st(e){return rt(e).immediateStopped}function lt(e,t){rt(e).passiveListener=t}it.prototype={get type(){return rt(this).event.type},get target(){return rt(this).eventTarget},get currentTarget(){return rt(this).currentTarget},composedPath(){const e=rt(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 rt(this).eventPhase},stopPropagation(){const e=rt(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=rt(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(rt(this).event.bubbles)},get cancelable(){return Boolean(rt(this).event.cancelable)},preventDefault(){ot(rt(this))},get defaultPrevented(){return rt(this).canceled},get composed(){return Boolean(rt(this).event.composed)},get timeStamp(){return rt(this).timeStamp},get srcElement(){return rt(this).eventTarget},get cancelBubble(){return rt(this).stopped},set cancelBubble(e){if(!e)return;const t=rt(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!rt(this).canceled},set returnValue(e){e||ot(rt(this))},initEvent(){}},Object.defineProperty(it.prototype,"constructor",{value:it,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf(it.prototype,window.Event.prototype),nt.set(window.Event.prototype,it));const ft=new WeakMap,pt=3;function ht(e){return null!==e&&"object"==typeof e}function dt(e){const t=ft.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function vt(e,t){Object.defineProperty(e,`on${t}`,function(e){return{get(){let t=dt(this).get(e);for(;null!=t;){if(t.listenerType===pt)return t.listener;t=t.next}return null},set(t){"function"==typeof t||ht(t)||(t=null);const n=dt(this);let r=null,o=n.get(e);for(;null!=o;)o.listenerType===pt?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:pt,passive:!1,once:!1,next:null};null===r?n.set(e,o):r.next=o}},configurable:!0,enumerable:!0}}(t))}function yt(e){function t(){gt.call(this)}t.prototype=Object.create(gt.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let n=0;n<e.length;++n)vt(t.prototype,e[n]);return t}function gt(){if(!(this instanceof gt)){if(1===arguments.length&&Array.isArray(arguments[0]))return yt(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 yt(e)}throw new TypeError("Cannot call a class as a function")}ft.set(this,new Map)}gt.prototype={addEventListener(e,t,n){if(null==t)return;if("function"!=typeof t&&!ht(t))throw new TypeError("'listener' should be a function or an object.");const r=dt(this),o=ht(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=dt(this),o=(ht(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=dt(this),n=e.type;let r=t.get(n);if(null==r)return!0;const o=function(e,t){return new(ct(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,lt(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!==pt&&"function"==typeof r.listener.handleEvent&&r.listener.handleEvent(o);if(st(o))break;r=r.next}return lt(o,null),function(e,t){rt(e).eventPhase=t}(o,0),function(e,t){rt(e).currentTarget=t}(o,null),!o.defaultPrevented}},Object.defineProperty(gt.prototype,"constructor",{value:gt,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(gt.prototype,window.EventTarget.prototype);class bt extends gt{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){const e=mt.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}}vt(bt.prototype,"abort");const mt=new WeakMap;Object.defineProperties(bt.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(bt.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});let wt=class{constructor(){jt.set(this,function(){const e=Object.create(bt.prototype);return gt.call(e),mt.set(e,!1),e}())}get signal(){return Et(this)}abort(){var e;e=Et(this),!1===mt.get(e)&&(mt.set(e,!0),e.dispatchEvent({type:"abort"}))}};const jt=new WeakMap;function Et(e){const t=jt.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(wt.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(wt.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});var Ot=function(e,t){return Ot=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])},Ot(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}Ot(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Tt,Pt,xt,qt,kt=function(){return kt=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},kt.apply(this,arguments)};function At(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 Ht="undefined"!=typeof AbortController;"undefined"!=typeof window||Ht?Tt=globalThis.AbortController:"undefined"!=typeof require?(Pt=require("http").request,xt=require("https").request,qt=require("url").parse,Tt=require("abort-controller")):"object"==typeof globalThis?(Pt=t.request,xt=n.request,qt=r.parse,Tt=wt):Tt=function(){throw new Error("AbortController is not defined")};var Lt=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}(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}()),Ct=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 Tt:v,g=t.type,b=void 0===g?"json":g,m=At(t,["method","query","headers","body","timeout","controller","type"]),w=kt({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=qt(r.url,!0);return kt(kt({},r),o)},n}return St(t,e),t}(Lt),Mt=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=At(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)?xt:Pt)(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,kt({query:t,method:"GET"},o))},n.POST=function(e,t,r,o){return n.request(e,kt({query:t,method:"POST",body:r},o))},n.PUT=function(e,t,r,o){return n.request(e,kt({query:t,method:"PUT",body:r},o))},n.DELETE=function(e,t,r,o){return n.request(e,kt({query:t,method:"DELETE",body:r},o))},n.OPTIONS=function(e,t,r,o){return n.request(e,kt({query:t,method:"OPTIONS",body:r},o))},n.HEAD=function(e,t,r,o){return n.request(e,kt({query:t,method:"HEAD",body:r},o))},n.PATCH=function(e,t,r,o){return n.request(e,kt({query:t,method:"PATCH",body:r},o))},n.request=n.requestType(),n}return St(t,e),t}(Ct),Dt=o(o(o(o(o(o(o(o(o(o(o({},x),p),H),R),F),u),U),$),ee),ce),{eventMessageCenter:se,taskQueueLib:ge,JSRequest:Mt});return e.AnimateFrame=te,e.MessageCenter=se,e.NBezier=ue,e.Request=Mt,e.TaskQueue=ge,e.addHandler=N,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=I,e.createObject=w,e.createObjectVariable=m,e.cubicBezier=re,e.debounce=M,e.decoratorMessageCenter=fe,e.decoratorTaskQueue=function(e){return function(t){t.prototype.taskQueue||(t.prototype.taskQueue=new ge(e))}},e.default=Dt,e.defer=D,e.dispatchEvent=V,e.enumInversion=y,e.factorial=oe,e.getInstance=E,e.getStorage=G,e.getType=l,e.getTypeByList=f,e.getValue=h,e.inherit=j,e.isNotObject=g,e.isWindow=P,e.jsonToString=T,e.logLoop=Z,e.logOneLine=K,e.messageCenter=le,e.mixIn=v,e.quadraticBezier=ne,e.randomNum=a,e.removeHandler=J,e.setStorage=z,e.setValue=d,e.stopBubble=_,e.stopDefault=W,e.stringToJson=S,e.throttle=C,e.urlJoin=s,e.urlSplit=c,Object.defineProperty(e,"__esModule",{value:!0}),e}({},http,https,url);
|
|
7
|
+
const tt=new WeakMap,nt=new WeakMap;function rt(e){const t=tt.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function ot(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 it(e,t){tt.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,ut(t))}}function ut(e){return{get(){return rt(this).event[e]},set(t){rt(this).event[e]=t},configurable:!0,enumerable:!0}}function at(e){return{value(){const t=rt(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function ct(e){if(null==e||e===Object.prototype)return it;let t=nt.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?at(i):ut(i))}}return r}(ct(Object.getPrototypeOf(e)),e),nt.set(e,t)),t}function st(e){return rt(e).immediateStopped}function lt(e,t){rt(e).passiveListener=t}it.prototype={get type(){return rt(this).event.type},get target(){return rt(this).eventTarget},get currentTarget(){return rt(this).currentTarget},composedPath(){const e=rt(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 rt(this).eventPhase},stopPropagation(){const e=rt(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=rt(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(rt(this).event.bubbles)},get cancelable(){return Boolean(rt(this).event.cancelable)},preventDefault(){ot(rt(this))},get defaultPrevented(){return rt(this).canceled},get composed(){return Boolean(rt(this).event.composed)},get timeStamp(){return rt(this).timeStamp},get srcElement(){return rt(this).eventTarget},get cancelBubble(){return rt(this).stopped},set cancelBubble(e){if(!e)return;const t=rt(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!rt(this).canceled},set returnValue(e){e||ot(rt(this))},initEvent(){}},Object.defineProperty(it.prototype,"constructor",{value:it,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf(it.prototype,window.Event.prototype),nt.set(window.Event.prototype,it));const ft=new WeakMap,pt=3;function ht(e){return null!==e&&"object"==typeof e}function dt(e){const t=ft.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function vt(e,t){Object.defineProperty(e,`on${t}`,function(e){return{get(){let t=dt(this).get(e);for(;null!=t;){if(t.listenerType===pt)return t.listener;t=t.next}return null},set(t){"function"==typeof t||ht(t)||(t=null);const n=dt(this);let r=null,o=n.get(e);for(;null!=o;)o.listenerType===pt?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:pt,passive:!1,once:!1,next:null};null===r?n.set(e,o):r.next=o}},configurable:!0,enumerable:!0}}(t))}function yt(e){function t(){gt.call(this)}t.prototype=Object.create(gt.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let n=0;n<e.length;++n)vt(t.prototype,e[n]);return t}function gt(){if(!(this instanceof gt)){if(1===arguments.length&&Array.isArray(arguments[0]))return yt(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 yt(e)}throw new TypeError("Cannot call a class as a function")}ft.set(this,new Map)}gt.prototype={addEventListener(e,t,n){if(null==t)return;if("function"!=typeof t&&!ht(t))throw new TypeError("'listener' should be a function or an object.");const r=dt(this),o=ht(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=dt(this),o=(ht(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=dt(this),n=e.type;let r=t.get(n);if(null==r)return!0;const o=function(e,t){return new(ct(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,lt(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!==pt&&"function"==typeof r.listener.handleEvent&&r.listener.handleEvent(o);if(st(o))break;r=r.next}return lt(o,null),function(e,t){rt(e).eventPhase=t}(o,0),function(e,t){rt(e).currentTarget=t}(o,null),!o.defaultPrevented}},Object.defineProperty(gt.prototype,"constructor",{value:gt,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(gt.prototype,window.EventTarget.prototype);class bt extends gt{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){const e=mt.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}}vt(bt.prototype,"abort");const mt=new WeakMap;Object.defineProperties(bt.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(bt.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});let wt=class{constructor(){jt.set(this,function(){const e=Object.create(bt.prototype);return gt.call(e),mt.set(e,!1),e}())}get signal(){return Et(this)}abort(){var e;e=Et(this),!1===mt.get(e)&&(mt.set(e,!0),e.dispatchEvent({type:"abort"}))}};const jt=new WeakMap;function Et(e){const t=jt.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(wt.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(wt.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});var Ot=function(e,t){return Ot=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])},Ot(e,t)};function Tt(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}Ot(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var St,Pt,xt,qt,kt=function(){return kt=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},kt.apply(this,arguments)};function At(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 Ht="undefined"!=typeof AbortController;"undefined"!=typeof window||Ht?St=globalThis.AbortController:"undefined"!=typeof require?(Pt=require("http").request,xt=require("https").request,qt=require("url").parse,St=require("abort-controller")):"object"==typeof globalThis?(Pt=t.request,xt=n.request,qt=r.parse,St=wt):St=function(){throw new Error("AbortController is not defined")};var Lt=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 Tt(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}()),Ct=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 St:v,g=t.type,b=void 0===g?"json":g,m=At(t,["method","query","headers","body","timeout","controller","type"]),w=kt({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=qt(r.url,!0);return kt(kt({},r),o)},n}return Tt(t,e),t}(Lt),Mt=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=At(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)?xt:Pt)(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,kt({query:t,method:"GET"},o))},n.POST=function(e,t,r,o){return n.request(e,kt({query:t,method:"POST",body:r},o))},n.PUT=function(e,t,r,o){return n.request(e,kt({query:t,method:"PUT",body:r},o))},n.DELETE=function(e,t,r,o){return n.request(e,kt({query:t,method:"DELETE",body:r},o))},n.OPTIONS=function(e,t,r,o){return n.request(e,kt({query:t,method:"OPTIONS",body:r},o))},n.HEAD=function(e,t,r,o){return n.request(e,kt({query:t,method:"HEAD",body:r},o))},n.PATCH=function(e,t,r,o){return n.request(e,kt({query:t,method:"PATCH",body:r},o))},n.request=n.requestType(),n}return Tt(t,e),t}(Ct),Dt=o(o(o(o(o(o(o(o(o(o(o({},x),p),H),R),F),u),U),$),ee),ce),{eventMessageCenter:se,taskQueueLib:ge,JSRequest:Mt});return e.AnimateFrame=te,e.MessageCenter=se,e.NBezier=ue,e.Request=Mt,e.TaskQueue=ge,e.addHandler=N,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=I,e.createObject=w,e.createObjectVariable=m,e.cubicBezier=re,e.debounce=M,e.decoratorMessageCenter=fe,e.decoratorTaskQueue=function(e){return function(t){t.prototype.taskQueue||(t.prototype.taskQueue=new ge(e))}},e.default=Dt,e.defer=D,e.dispatchEvent=V,e.enumInversion=y,e.factorial=oe,e.getInstance=E,e.getStorage=G,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?process.nextTick: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=_,e.stopDefault=W,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/types.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type IThrottle = (fn: Function, time: number) => (...args: any[]) => void
|
|
|
32
32
|
export type IDebounce = (fn: Function, time: number) => (...args: any[]) => void;
|
|
33
33
|
export type IDefer = (timer?: number) => IPromise;
|
|
34
34
|
export type ICatchAwait<T extends Promise<any>> = (defer: T) => T;
|
|
35
|
+
export type IRequestFrame = (callback: (start: number) => void, delay: number) => () => void;
|
|
35
36
|
export type IArrayRandom<T extends any[]> = (arr: T) => T;
|
|
36
37
|
export type IArrayUniq<T extends any[]> = (arr: T) => T;
|
|
37
38
|
export type IArrayDemote<T extends IDemoteArray<any>> = (arr: T, result?: T) => T;
|
|
@@ -62,7 +63,7 @@ export type IAnimateFrame = {
|
|
|
62
63
|
isActive: boolean;
|
|
63
64
|
fn(timer: number): void;
|
|
64
65
|
start(duration: number): void;
|
|
65
|
-
stop(): void;
|
|
66
|
+
stop(id?: number): void;
|
|
66
67
|
animate(timer: number): void;
|
|
67
68
|
};
|
|
68
69
|
export {};
|
package/dist/cjs/animate.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ export declare class AnimateFrame implements IAnimateFrame {
|
|
|
5
5
|
duration: number;
|
|
6
6
|
isActive: boolean;
|
|
7
7
|
constructor(fn: any);
|
|
8
|
-
start(duration: any):
|
|
9
|
-
stop(): void;
|
|
10
|
-
animate(timer?: number):
|
|
8
|
+
start(duration: any): any;
|
|
9
|
+
stop(id?: any): void;
|
|
10
|
+
animate(timer?: number): any;
|
|
11
11
|
}
|
|
12
12
|
export declare function quadraticBezier(_x: number, _y: number, t: number): number[];
|
|
13
13
|
export declare function cubicBezier(_x1: number, _y1: number, _x2: number, _y2: number, t: number): number[];
|
package/dist/cjs/function.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ICatchAwait, IThrottle, IDebounce, IDefer } from "./types";
|
|
1
|
+
import { ICatchAwait, IThrottle, IDebounce, IDefer, IRequestFrame } from "./types";
|
|
2
2
|
export declare const throttle: IThrottle;
|
|
3
3
|
export declare const debounce: IDebounce;
|
|
4
4
|
export declare const defer: IDefer;
|
|
5
5
|
export declare const catchAwait: ICatchAwait<Promise<any>>;
|
|
6
|
+
export declare const requestFrame: IRequestFrame;
|
|
6
7
|
declare const _default: {
|
|
7
8
|
throttle: IThrottle;
|
|
8
9
|
debounce: IDebounce;
|
package/dist/cjs/index.js
CHANGED
|
@@ -334,6 +334,29 @@ var defer$1 = function (timer) {
|
|
|
334
334
|
};
|
|
335
335
|
};
|
|
336
336
|
var catchAwait$1 = function (defer) { return defer.then(function (res) { return [null, res]; }).catch(function (err) { return [err]; }); };
|
|
337
|
+
var requestFrame = function (callback, delay) {
|
|
338
|
+
if (delay === void 0) { delay = 0; }
|
|
339
|
+
if (!callback)
|
|
340
|
+
throw Error("callback is empty");
|
|
341
|
+
var isNodeEnv = typeof process !== "undefined";
|
|
342
|
+
var frameFn = isNodeEnv ? process.nextTick : requestAnimationFrame;
|
|
343
|
+
var _p = performance;
|
|
344
|
+
var start = _p.now();
|
|
345
|
+
var freeze = false;
|
|
346
|
+
var clear = function () { return freeze = true; };
|
|
347
|
+
var _tempCb = function () {
|
|
348
|
+
if (freeze)
|
|
349
|
+
return;
|
|
350
|
+
var diff = _p.now() - start;
|
|
351
|
+
if (diff >= delay) {
|
|
352
|
+
start = _p.now();
|
|
353
|
+
callback(start);
|
|
354
|
+
}
|
|
355
|
+
frameFn(_tempCb);
|
|
356
|
+
};
|
|
357
|
+
_tempCb();
|
|
358
|
+
return clear;
|
|
359
|
+
};
|
|
337
360
|
var __function$1 = {
|
|
338
361
|
throttle: throttle$1,
|
|
339
362
|
debounce: debounce$1,
|
|
@@ -485,17 +508,19 @@ var AnimateFrame$1 = (function () {
|
|
|
485
508
|
return;
|
|
486
509
|
this.duration = duration !== null && duration !== void 0 ? duration : Infinity;
|
|
487
510
|
this.isActive = true;
|
|
488
|
-
this.animate();
|
|
511
|
+
return this.animate();
|
|
489
512
|
};
|
|
490
|
-
AnimateFrame.prototype.stop = function () {
|
|
513
|
+
AnimateFrame.prototype.stop = function (id) {
|
|
514
|
+
if (id === void 0) { id = this.id; }
|
|
491
515
|
this.isActive = false;
|
|
492
|
-
cancelAnimationFrame(
|
|
516
|
+
cancelAnimationFrame(id);
|
|
493
517
|
};
|
|
494
518
|
AnimateFrame.prototype.animate = function (timer) {
|
|
495
519
|
if (timer === void 0) { timer = 0; }
|
|
496
520
|
if (this.isActive && this.duration-- > 0) {
|
|
497
521
|
this.fn(timer);
|
|
498
522
|
this.id = requestAnimationFrame(this.animate.bind(this));
|
|
523
|
+
return this.id;
|
|
499
524
|
}
|
|
500
525
|
};
|
|
501
526
|
return AnimateFrame;
|
|
@@ -3011,6 +3036,7 @@ exports.mixIn = mixIn$1;
|
|
|
3011
3036
|
exports.quadraticBezier = quadraticBezier$1;
|
|
3012
3037
|
exports.randomNum = randomNum$1;
|
|
3013
3038
|
exports.removeHandler = removeHandler$1;
|
|
3039
|
+
exports.requestFrame = requestFrame;
|
|
3014
3040
|
exports.setStorage = setStorage$1;
|
|
3015
3041
|
exports.setValue = setValue$1;
|
|
3016
3042
|
exports.stopBubble = stopBubble$1;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type IThrottle = (fn: Function, time: number) => (...args: any[]) => void
|
|
|
32
32
|
export type IDebounce = (fn: Function, time: number) => (...args: any[]) => void;
|
|
33
33
|
export type IDefer = (timer?: number) => IPromise;
|
|
34
34
|
export type ICatchAwait<T extends Promise<any>> = (defer: T) => T;
|
|
35
|
+
export type IRequestFrame = (callback: (start: number) => void, delay: number) => () => void;
|
|
35
36
|
export type IArrayRandom<T extends any[]> = (arr: T) => T;
|
|
36
37
|
export type IArrayUniq<T extends any[]> = (arr: T) => T;
|
|
37
38
|
export type IArrayDemote<T extends IDemoteArray<any>> = (arr: T, result?: T) => T;
|
|
@@ -62,7 +63,7 @@ export type IAnimateFrame = {
|
|
|
62
63
|
isActive: boolean;
|
|
63
64
|
fn(timer: number): void;
|
|
64
65
|
start(duration: number): void;
|
|
65
|
-
stop(): void;
|
|
66
|
+
stop(id?: number): void;
|
|
66
67
|
animate(timer: number): void;
|
|
67
68
|
};
|
|
68
69
|
export {};
|
package/dist/esm/animate.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ export declare class AnimateFrame implements IAnimateFrame {
|
|
|
5
5
|
duration: number;
|
|
6
6
|
isActive: boolean;
|
|
7
7
|
constructor(fn: any);
|
|
8
|
-
start(duration: any):
|
|
9
|
-
stop(): void;
|
|
10
|
-
animate(timer?: number):
|
|
8
|
+
start(duration: any): any;
|
|
9
|
+
stop(id?: any): void;
|
|
10
|
+
animate(timer?: number): any;
|
|
11
11
|
}
|
|
12
12
|
export declare function quadraticBezier(_x: number, _y: number, t: number): number[];
|
|
13
13
|
export declare function cubicBezier(_x1: number, _y1: number, _x2: number, _y2: number, t: number): number[];
|
package/dist/esm/function.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ICatchAwait, IThrottle, IDebounce, IDefer } from "./types";
|
|
1
|
+
import { ICatchAwait, IThrottle, IDebounce, IDefer, IRequestFrame } from "./types";
|
|
2
2
|
export declare const throttle: IThrottle;
|
|
3
3
|
export declare const debounce: IDebounce;
|
|
4
4
|
export declare const defer: IDefer;
|
|
5
5
|
export declare const catchAwait: ICatchAwait<Promise<any>>;
|
|
6
|
+
export declare const requestFrame: IRequestFrame;
|
|
6
7
|
declare const _default: {
|
|
7
8
|
throttle: IThrottle;
|
|
8
9
|
debounce: IDebounce;
|
package/dist/esm/index.js
CHANGED
|
@@ -330,6 +330,29 @@ var defer$1 = function (timer) {
|
|
|
330
330
|
};
|
|
331
331
|
};
|
|
332
332
|
var catchAwait$1 = function (defer) { return defer.then(function (res) { return [null, res]; }).catch(function (err) { return [err]; }); };
|
|
333
|
+
var requestFrame = function (callback, delay) {
|
|
334
|
+
if (delay === void 0) { delay = 0; }
|
|
335
|
+
if (!callback)
|
|
336
|
+
throw Error("callback is empty");
|
|
337
|
+
var isNodeEnv = typeof process !== "undefined";
|
|
338
|
+
var frameFn = isNodeEnv ? process.nextTick : requestAnimationFrame;
|
|
339
|
+
var _p = performance;
|
|
340
|
+
var start = _p.now();
|
|
341
|
+
var freeze = false;
|
|
342
|
+
var clear = function () { return freeze = true; };
|
|
343
|
+
var _tempCb = function () {
|
|
344
|
+
if (freeze)
|
|
345
|
+
return;
|
|
346
|
+
var diff = _p.now() - start;
|
|
347
|
+
if (diff >= delay) {
|
|
348
|
+
start = _p.now();
|
|
349
|
+
callback(start);
|
|
350
|
+
}
|
|
351
|
+
frameFn(_tempCb);
|
|
352
|
+
};
|
|
353
|
+
_tempCb();
|
|
354
|
+
return clear;
|
|
355
|
+
};
|
|
333
356
|
var __function$1 = {
|
|
334
357
|
throttle: throttle$1,
|
|
335
358
|
debounce: debounce$1,
|
|
@@ -481,17 +504,19 @@ var AnimateFrame$1 = (function () {
|
|
|
481
504
|
return;
|
|
482
505
|
this.duration = duration !== null && duration !== void 0 ? duration : Infinity;
|
|
483
506
|
this.isActive = true;
|
|
484
|
-
this.animate();
|
|
507
|
+
return this.animate();
|
|
485
508
|
};
|
|
486
|
-
AnimateFrame.prototype.stop = function () {
|
|
509
|
+
AnimateFrame.prototype.stop = function (id) {
|
|
510
|
+
if (id === void 0) { id = this.id; }
|
|
487
511
|
this.isActive = false;
|
|
488
|
-
cancelAnimationFrame(
|
|
512
|
+
cancelAnimationFrame(id);
|
|
489
513
|
};
|
|
490
514
|
AnimateFrame.prototype.animate = function (timer) {
|
|
491
515
|
if (timer === void 0) { timer = 0; }
|
|
492
516
|
if (this.isActive && this.duration-- > 0) {
|
|
493
517
|
this.fn(timer);
|
|
494
518
|
this.id = requestAnimationFrame(this.animate.bind(this));
|
|
519
|
+
return this.id;
|
|
495
520
|
}
|
|
496
521
|
};
|
|
497
522
|
return AnimateFrame;
|
|
@@ -2965,4 +2990,4 @@ var Request = (function (_super) {
|
|
|
2965
2990
|
|
|
2966
2991
|
var index = __assign$4(__assign$4(__assign$4(__assign$4(__assign$4(__assign$4(__assign$4(__assign$4(__assign$4(__assign$4(__assign$4({}, object$1), base$1), array$1), __function$1), element$1), __static$1), event$1), storage$1), log$1), animate$1), { eventMessageCenter: MessageCenter$1, taskQueueLib: TaskQueue$1, JSRequest: Request });
|
|
2967
2992
|
|
|
2968
|
-
export { AnimateFrame$1 as AnimateFrame, MessageCenter$1 as MessageCenter, NBezier$1 as NBezier, Request, TaskQueue$1 as TaskQueue, addHandler$1 as addHandler, arrayDemote$1 as arrayDemote, arrayRandom$1 as arrayRandom, arrayUniq$1 as arrayUniq, catchAwait$1 as catchAwait, classDecorator$1 as classDecorator, clearStorage$1 as clearStorage, cloneDeep$1 as cloneDeep, combination$1 as combination, createElement$1 as createElement, createObject$1 as createObject, createObjectVariable$1 as createObjectVariable, cubicBezier$1 as cubicBezier, debounce$1 as debounce, decoratorMessageCenter$1 as decoratorMessageCenter, decoratorTaskQueue, index as default, defer$1 as defer, dispatchEvent$1 as dispatchEvent, enumInversion$1 as enumInversion, factorial$1 as factorial, getInstance$1 as getInstance, getStorage$1 as getStorage, getType$1 as getType, getTypeByList$1 as getTypeByList, getValue$1 as getValue, inherit$1 as inherit, isNotObject$1 as isNotObject, isWindow$1 as isWindow, jsonToString$1 as jsonToString, logLoop$1 as logLoop, logOneLine$1 as logOneLine, messageCenter, mixIn$1 as mixIn, quadraticBezier$1 as quadraticBezier, randomNum$1 as randomNum, removeHandler$1 as removeHandler, setStorage$1 as setStorage, setValue$1 as setValue, stopBubble$1 as stopBubble, stopDefault$1 as stopDefault, stringToJson$1 as stringToJson, throttle$1 as throttle, types$1 as types, urlJoin$1 as urlJoin, urlSplit$1 as urlSplit };
|
|
2993
|
+
export { AnimateFrame$1 as AnimateFrame, MessageCenter$1 as MessageCenter, NBezier$1 as NBezier, Request, TaskQueue$1 as TaskQueue, addHandler$1 as addHandler, arrayDemote$1 as arrayDemote, arrayRandom$1 as arrayRandom, arrayUniq$1 as arrayUniq, catchAwait$1 as catchAwait, classDecorator$1 as classDecorator, clearStorage$1 as clearStorage, cloneDeep$1 as cloneDeep, combination$1 as combination, createElement$1 as createElement, createObject$1 as createObject, createObjectVariable$1 as createObjectVariable, cubicBezier$1 as cubicBezier, debounce$1 as debounce, decoratorMessageCenter$1 as decoratorMessageCenter, decoratorTaskQueue, index as default, defer$1 as defer, dispatchEvent$1 as dispatchEvent, enumInversion$1 as enumInversion, factorial$1 as factorial, getInstance$1 as getInstance, getStorage$1 as getStorage, getType$1 as getType, getTypeByList$1 as getTypeByList, getValue$1 as getValue, inherit$1 as inherit, isNotObject$1 as isNotObject, isWindow$1 as isWindow, jsonToString$1 as jsonToString, logLoop$1 as logLoop, logOneLine$1 as logOneLine, messageCenter, mixIn$1 as mixIn, quadraticBezier$1 as quadraticBezier, randomNum$1 as randomNum, removeHandler$1 as removeHandler, requestFrame, setStorage$1 as setStorage, setValue$1 as setValue, stopBubble$1 as stopBubble, stopDefault$1 as stopDefault, stringToJson$1 as stringToJson, throttle$1 as throttle, types$1 as types, urlJoin$1 as urlJoin, urlSplit$1 as urlSplit };
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type IThrottle = (fn: Function, time: number) => (...args: any[]) => void
|
|
|
32
32
|
export type IDebounce = (fn: Function, time: number) => (...args: any[]) => void;
|
|
33
33
|
export type IDefer = (timer?: number) => IPromise;
|
|
34
34
|
export type ICatchAwait<T extends Promise<any>> = (defer: T) => T;
|
|
35
|
+
export type IRequestFrame = (callback: (start: number) => void, delay: number) => () => void;
|
|
35
36
|
export type IArrayRandom<T extends any[]> = (arr: T) => T;
|
|
36
37
|
export type IArrayUniq<T extends any[]> = (arr: T) => T;
|
|
37
38
|
export type IArrayDemote<T extends IDemoteArray<any>> = (arr: T, result?: T) => T;
|
|
@@ -62,7 +63,7 @@ export type IAnimateFrame = {
|
|
|
62
63
|
isActive: boolean;
|
|
63
64
|
fn(timer: number): void;
|
|
64
65
|
start(duration: number): void;
|
|
65
|
-
stop(): void;
|
|
66
|
+
stop(id?: number): void;
|
|
66
67
|
animate(timer: number): void;
|
|
67
68
|
};
|
|
68
69
|
export {};
|
package/dist/umd/animate.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ export declare class AnimateFrame implements IAnimateFrame {
|
|
|
5
5
|
duration: number;
|
|
6
6
|
isActive: boolean;
|
|
7
7
|
constructor(fn: any);
|
|
8
|
-
start(duration: any):
|
|
9
|
-
stop(): void;
|
|
10
|
-
animate(timer?: number):
|
|
8
|
+
start(duration: any): any;
|
|
9
|
+
stop(id?: any): void;
|
|
10
|
+
animate(timer?: number): any;
|
|
11
11
|
}
|
|
12
12
|
export declare function quadraticBezier(_x: number, _y: number, t: number): number[];
|
|
13
13
|
export declare function cubicBezier(_x1: number, _y1: number, _x2: number, _y2: number, t: number): number[];
|
package/dist/umd/function.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ICatchAwait, IThrottle, IDebounce, IDefer } from "./types";
|
|
1
|
+
import { ICatchAwait, IThrottle, IDebounce, IDefer, IRequestFrame } from "./types";
|
|
2
2
|
export declare const throttle: IThrottle;
|
|
3
3
|
export declare const debounce: IDebounce;
|
|
4
4
|
export declare const defer: IDefer;
|
|
5
5
|
export declare const catchAwait: ICatchAwait<Promise<any>>;
|
|
6
|
+
export declare const requestFrame: IRequestFrame;
|
|
6
7
|
declare const _default: {
|
|
7
8
|
throttle: IThrottle;
|
|
8
9
|
debounce: IDebounce;
|
package/dist/umd/index.js
CHANGED
|
@@ -332,6 +332,29 @@
|
|
|
332
332
|
};
|
|
333
333
|
};
|
|
334
334
|
var catchAwait$1 = function (defer) { return defer.then(function (res) { return [null, res]; }).catch(function (err) { return [err]; }); };
|
|
335
|
+
var requestFrame = function (callback, delay) {
|
|
336
|
+
if (delay === void 0) { delay = 0; }
|
|
337
|
+
if (!callback)
|
|
338
|
+
throw Error("callback is empty");
|
|
339
|
+
var isNodeEnv = typeof process !== "undefined";
|
|
340
|
+
var frameFn = isNodeEnv ? process.nextTick : requestAnimationFrame;
|
|
341
|
+
var _p = performance;
|
|
342
|
+
var start = _p.now();
|
|
343
|
+
var freeze = false;
|
|
344
|
+
var clear = function () { return freeze = true; };
|
|
345
|
+
var _tempCb = function () {
|
|
346
|
+
if (freeze)
|
|
347
|
+
return;
|
|
348
|
+
var diff = _p.now() - start;
|
|
349
|
+
if (diff >= delay) {
|
|
350
|
+
start = _p.now();
|
|
351
|
+
callback(start);
|
|
352
|
+
}
|
|
353
|
+
frameFn(_tempCb);
|
|
354
|
+
};
|
|
355
|
+
_tempCb();
|
|
356
|
+
return clear;
|
|
357
|
+
};
|
|
335
358
|
var __function$1 = {
|
|
336
359
|
throttle: throttle$1,
|
|
337
360
|
debounce: debounce$1,
|
|
@@ -483,17 +506,19 @@
|
|
|
483
506
|
return;
|
|
484
507
|
this.duration = duration !== null && duration !== void 0 ? duration : Infinity;
|
|
485
508
|
this.isActive = true;
|
|
486
|
-
this.animate();
|
|
509
|
+
return this.animate();
|
|
487
510
|
};
|
|
488
|
-
AnimateFrame.prototype.stop = function () {
|
|
511
|
+
AnimateFrame.prototype.stop = function (id) {
|
|
512
|
+
if (id === void 0) { id = this.id; }
|
|
489
513
|
this.isActive = false;
|
|
490
|
-
cancelAnimationFrame(
|
|
514
|
+
cancelAnimationFrame(id);
|
|
491
515
|
};
|
|
492
516
|
AnimateFrame.prototype.animate = function (timer) {
|
|
493
517
|
if (timer === void 0) { timer = 0; }
|
|
494
518
|
if (this.isActive && this.duration-- > 0) {
|
|
495
519
|
this.fn(timer);
|
|
496
520
|
this.id = requestAnimationFrame(this.animate.bind(this));
|
|
521
|
+
return this.id;
|
|
497
522
|
}
|
|
498
523
|
};
|
|
499
524
|
return AnimateFrame;
|
|
@@ -3009,6 +3034,7 @@
|
|
|
3009
3034
|
exports.quadraticBezier = quadraticBezier$1;
|
|
3010
3035
|
exports.randomNum = randomNum$1;
|
|
3011
3036
|
exports.removeHandler = removeHandler$1;
|
|
3037
|
+
exports.requestFrame = requestFrame;
|
|
3012
3038
|
exports.setStorage = setStorage$1;
|
|
3013
3039
|
exports.setValue = setValue$1;
|
|
3014
3040
|
exports.stopBubble = stopBubble$1;
|
package/dist/umd/types.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type IThrottle = (fn: Function, time: number) => (...args: any[]) => void
|
|
|
32
32
|
export type IDebounce = (fn: Function, time: number) => (...args: any[]) => void;
|
|
33
33
|
export type IDefer = (timer?: number) => IPromise;
|
|
34
34
|
export type ICatchAwait<T extends Promise<any>> = (defer: T) => T;
|
|
35
|
+
export type IRequestFrame = (callback: (start: number) => void, delay: number) => () => void;
|
|
35
36
|
export type IArrayRandom<T extends any[]> = (arr: T) => T;
|
|
36
37
|
export type IArrayUniq<T extends any[]> = (arr: T) => T;
|
|
37
38
|
export type IArrayDemote<T extends IDemoteArray<any>> = (arr: T, result?: T) => T;
|
|
@@ -62,7 +63,7 @@ export type IAnimateFrame = {
|
|
|
62
63
|
isActive: boolean;
|
|
63
64
|
fn(timer: number): void;
|
|
64
65
|
start(duration: number): void;
|
|
65
|
-
stop(): void;
|
|
66
|
+
stop(id?: number): void;
|
|
66
67
|
animate(timer: number): void;
|
|
67
68
|
};
|
|
68
69
|
export {};
|
package/package.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
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":
|
|
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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "utils-lib-js",
|
|
3
|
+
"version": "2.0.9",
|
|
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
|
+
},
|
|
48
|
+
"umdModuleName": "UtilsLib"
|
|
49
|
+
}
|