ddan-js 2.0.6 → 2.0.7
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/bin/ddan-js.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/lib/class/event.js +19 -19
- package/bin/lib/class/icon.js +5 -5
- package/bin/lib/class/pipeTask.js +4 -4
- package/bin/lib/class/pipeline.js +20 -20
- package/bin/lib/class/pipeparallel.js +4 -4
- package/bin/lib/class/store.js +1 -1
- package/bin/lib/class/task.js +5 -5
- package/bin/lib/class/tracker.js +16 -16
- package/bin/lib/modules/time/{timeFormat.js → dtime.js} +51 -30
- package/bin/lib/modules/time/index.js +9 -9
- package/bin/types/class/event.d.ts +3 -3
- package/bin/types/class/icon.d.ts +2 -2
- package/bin/types/class/pipeTask.d.ts +1 -1
- package/bin/types/class/pipeline.d.ts +3 -3
- package/bin/types/class/pipeparallel.d.ts +1 -1
- package/bin/types/class/task.d.ts +1 -1
- package/bin/types/class/tracker.d.ts +2 -2
- package/bin/types/index.d.ts +3 -3
- package/bin/types/modules/time/{timeFormat.d.ts → dtime.d.ts} +20 -5
- package/bin/types/modules/time/index.d.ts +4 -4
- package/package.json +1 -1
package/bin/lib/class/task.js
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const is_1 = require("../util/is");
|
|
4
4
|
class DTask {
|
|
5
|
-
|
|
5
|
+
__source__;
|
|
6
6
|
constructor(source) {
|
|
7
|
-
this.
|
|
7
|
+
this.__source__ = source;
|
|
8
8
|
}
|
|
9
9
|
run() {
|
|
10
10
|
let promise;
|
|
11
11
|
try {
|
|
12
12
|
let temp;
|
|
13
|
-
if (is_1.default.isFunction(this.
|
|
14
|
-
temp = this.
|
|
13
|
+
if (is_1.default.isFunction(this.__source__)) {
|
|
14
|
+
temp = this.__source__();
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
|
-
temp = this.
|
|
17
|
+
temp = this.__source__;
|
|
18
18
|
}
|
|
19
19
|
promise = is_1.default.isPromise(temp) ? temp : Promise.resolve(temp);
|
|
20
20
|
return promise.then(data => [null, data]).catch(err => [err, undefined]);
|
package/bin/lib/class/tracker.js
CHANGED
|
@@ -48,12 +48,12 @@ class DTrack {
|
|
|
48
48
|
}
|
|
49
49
|
exports.DTrack = DTrack;
|
|
50
50
|
class DTracker {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
__map__ = new Map();
|
|
52
|
+
__trackList__ = [];
|
|
53
53
|
can = true;
|
|
54
54
|
clear() {
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
55
|
+
this.__map__.clear();
|
|
56
|
+
this.__trackList__ = [];
|
|
57
57
|
return this;
|
|
58
58
|
}
|
|
59
59
|
add(name, { desc = "", type = "" } = {}) {
|
|
@@ -63,13 +63,13 @@ class DTracker {
|
|
|
63
63
|
_track.name = name;
|
|
64
64
|
_track.type = type;
|
|
65
65
|
_track.desc = desc;
|
|
66
|
-
this.
|
|
66
|
+
this.__trackList__.push(_track);
|
|
67
67
|
return _track.id;
|
|
68
68
|
}
|
|
69
69
|
done(id) {
|
|
70
70
|
if (!id || !this.can)
|
|
71
71
|
return;
|
|
72
|
-
const _track = this.
|
|
72
|
+
const _track = this.__trackList__.find(e => e.id === id);
|
|
73
73
|
if (!_track || _track.isDone)
|
|
74
74
|
return;
|
|
75
75
|
_track.done();
|
|
@@ -77,38 +77,38 @@ class DTracker {
|
|
|
77
77
|
endTrack.id = this._endId(id);
|
|
78
78
|
endTrack.flag = 1;
|
|
79
79
|
endTrack.desc = `${_track.desc} | end`;
|
|
80
|
-
this.
|
|
80
|
+
this.__trackList__.push(endTrack);
|
|
81
81
|
}
|
|
82
82
|
getTrack(id) {
|
|
83
|
-
return this.
|
|
83
|
+
return this.__trackList__.find(e => e.id === id);
|
|
84
84
|
}
|
|
85
85
|
getLine(id) {
|
|
86
86
|
if (!id || id.endsWith("-end"))
|
|
87
87
|
return [];
|
|
88
|
-
const idx_s = this.
|
|
88
|
+
const idx_s = this.__trackList__.findIndex(e => e.id === id);
|
|
89
89
|
if (idx_s < 0)
|
|
90
90
|
return [];
|
|
91
91
|
const endid = this._endId(id);
|
|
92
|
-
const idx_e = this.
|
|
93
|
-
const count = idx_e < 0 ? this.
|
|
94
|
-
return list_1.default.take(this.
|
|
92
|
+
const idx_e = this.__trackList__.findIndex(e => e.id === endid);
|
|
93
|
+
const count = idx_e < 0 ? this.__trackList__.length - idx_s : idx_e - idx_s + 1;
|
|
94
|
+
return list_1.default.take(this.__trackList__, count, idx_s);
|
|
95
95
|
}
|
|
96
96
|
getListByName(name, id = "") {
|
|
97
97
|
if (!name)
|
|
98
98
|
return [];
|
|
99
|
-
const _nameList = this.
|
|
99
|
+
const _nameList = this.__trackList__.filter(e => e.name === name);
|
|
100
100
|
if (_nameList.length <= 0)
|
|
101
101
|
return [];
|
|
102
102
|
if (!id)
|
|
103
103
|
return _nameList;
|
|
104
104
|
const endid = this._endId(id);
|
|
105
|
-
return this.
|
|
105
|
+
return this.__trackList__.filter(e => e.id === id || e.id === endid);
|
|
106
106
|
}
|
|
107
107
|
getList() {
|
|
108
|
-
return this.
|
|
108
|
+
return this.__trackList__;
|
|
109
109
|
}
|
|
110
110
|
size() {
|
|
111
|
-
return this.
|
|
111
|
+
return this.__trackList__.length;
|
|
112
112
|
}
|
|
113
113
|
_endId = (id) => `${id}-end`;
|
|
114
114
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const const_1 = require("./const");
|
|
4
|
-
class
|
|
4
|
+
class DTime {
|
|
5
5
|
date;
|
|
6
|
-
countdown = 0;
|
|
7
|
-
countdownS = 0;
|
|
8
6
|
timestamp = 0;
|
|
9
7
|
yyyy = 0;
|
|
10
8
|
yy = "";
|
|
@@ -52,47 +50,70 @@ class DTimeFormat {
|
|
|
52
50
|
this.SSS = this.S.toString().padStart(3, "0");
|
|
53
51
|
return this;
|
|
54
52
|
}
|
|
55
|
-
toCountdown() {
|
|
53
|
+
toCountdown(reg = "") {
|
|
54
|
+
const result = {
|
|
55
|
+
countdown: 0,
|
|
56
|
+
timestamp: 0,
|
|
57
|
+
seconds: 0,
|
|
58
|
+
d: 0,
|
|
59
|
+
dd: "",
|
|
60
|
+
h: 0,
|
|
61
|
+
hh: "",
|
|
62
|
+
m: 0,
|
|
63
|
+
mm: "",
|
|
64
|
+
s: 0,
|
|
65
|
+
ss: "",
|
|
66
|
+
S: 0,
|
|
67
|
+
SS: "",
|
|
68
|
+
SSS: "",
|
|
69
|
+
desc: "",
|
|
70
|
+
};
|
|
56
71
|
if (!this.timestamp)
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
return result;
|
|
73
|
+
result.timestamp = this.timestamp;
|
|
74
|
+
result.countdown = Math.max(result.timestamp - Date.now(), 0);
|
|
75
|
+
result.seconds = Math.floor(result.countdown / const_1.default.oneSecond);
|
|
76
|
+
let amount = result.countdown;
|
|
77
|
+
result.d = Math.floor(amount / const_1.default.oneDay);
|
|
78
|
+
result.dd = (result.d < 10 ? "0" : "") + result.d;
|
|
63
79
|
amount = amount % const_1.default.oneDay;
|
|
64
|
-
|
|
65
|
-
|
|
80
|
+
result.h = Math.floor(amount / const_1.default.oneHour);
|
|
81
|
+
result.hh = (result.h < 10 ? "0" : "") + result.h;
|
|
66
82
|
amount = amount % const_1.default.oneHour;
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
result.m = Math.floor(amount / const_1.default.oneMinute);
|
|
84
|
+
result.mm = (result.m < 10 ? "0" : "") + result.m;
|
|
69
85
|
amount = amount % const_1.default.oneMinute;
|
|
70
|
-
|
|
71
|
-
|
|
86
|
+
result.s = Math.floor(amount / const_1.default.oneSecond);
|
|
87
|
+
result.ss = (result.s < 10 ? "0" : "") + result.s;
|
|
72
88
|
amount = amount % const_1.default.oneSecond;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
format(reg = "yyyy-MM-dd hh:mm:ss") {
|
|
79
|
-
return reg.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g, ($1) => this[$1]);
|
|
80
|
-
}
|
|
81
|
-
countdownFormat(reg = "") {
|
|
89
|
+
result.S = amount;
|
|
90
|
+
result.SS = (result.S < 10 ? "0" : "") + result.S;
|
|
91
|
+
result.SSS = result.S.toString().padStart(3, "0");
|
|
82
92
|
let _reg = reg;
|
|
83
93
|
if (!_reg) {
|
|
84
|
-
if (
|
|
94
|
+
if (result.countdown > const_1.default.oneHour) {
|
|
85
95
|
_reg = "hh:mm:ss";
|
|
86
96
|
}
|
|
87
|
-
else if (
|
|
97
|
+
else if (result.countdown > const_1.default.oneMinute) {
|
|
88
98
|
_reg = "mm:ss";
|
|
89
99
|
}
|
|
90
100
|
else {
|
|
91
101
|
_reg = "ss";
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
|
-
|
|
104
|
+
result.desc = _reg.replace(/\bdd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g, ($1) => result[$1]);
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
add(ms = 0) {
|
|
108
|
+
if (!ms)
|
|
109
|
+
return this;
|
|
110
|
+
this.timestamp = this.timestamp + ms;
|
|
111
|
+
this.date = new Date(this.timestamp);
|
|
112
|
+
this.toDate();
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
format(reg = "yyyy-MM-dd hh:mm:ss") {
|
|
116
|
+
return reg.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g, ($1) => this[$1]);
|
|
95
117
|
}
|
|
96
|
-
;
|
|
97
118
|
}
|
|
98
|
-
exports.default =
|
|
119
|
+
exports.default = DTime;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const frame_1 = require("./frame");
|
|
4
|
-
const
|
|
4
|
+
const dtime_1 = require("./dtime");
|
|
5
5
|
const const_1 = require("./const");
|
|
6
6
|
/**
|
|
7
7
|
* 是否是今天
|
|
@@ -23,18 +23,18 @@ const format = (time, reg = "yyyy-MM-dd hh:mm:ss") => {
|
|
|
23
23
|
const date = typeof time === "string" || typeof time === "number" ? new Date(time) : time;
|
|
24
24
|
if (!date)
|
|
25
25
|
return "";
|
|
26
|
-
return
|
|
26
|
+
return dtime(date).format(reg);
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
29
|
*
|
|
30
30
|
* @param time 时间戳|日期时间字符串|Date
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
|
-
const
|
|
33
|
+
const dtime = (time) => {
|
|
34
34
|
const date = typeof time === "string" || typeof time === "number" ? new Date(time) : time;
|
|
35
35
|
if (!date)
|
|
36
|
-
return new
|
|
37
|
-
return new
|
|
36
|
+
return new dtime_1.default(0);
|
|
37
|
+
return new dtime_1.default(date);
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
40
|
* 解析时间
|
|
@@ -50,7 +50,7 @@ function parseTimestamp({ year = 0, month = 0, date = 0, hour = 0, minute = 0, s
|
|
|
50
50
|
* @returns
|
|
51
51
|
*/
|
|
52
52
|
function now() {
|
|
53
|
-
return
|
|
53
|
+
return dtime(new Date());
|
|
54
54
|
}
|
|
55
55
|
;
|
|
56
56
|
/**
|
|
@@ -64,10 +64,10 @@ const countdown = (endTime, reg = "") => {
|
|
|
64
64
|
const date = typeof endTime === "string" || typeof endTime === "number" ? new Date(endTime) : endTime;
|
|
65
65
|
if (!date)
|
|
66
66
|
return "";
|
|
67
|
-
const map =
|
|
68
|
-
return map.toCountdown(
|
|
67
|
+
const map = dtime(date);
|
|
68
|
+
return map.toCountdown(reg);
|
|
69
69
|
};
|
|
70
70
|
const loopFrame = (interval = 500) => {
|
|
71
71
|
return new frame_1.default(interval);
|
|
72
72
|
};
|
|
73
|
-
exports.default = { ...const_1.default, now, isToday, parseTimestamp, todayZero, format, countdown,
|
|
73
|
+
exports.default = { ...const_1.default, now, isToday, parseTimestamp, todayZero, format, countdown, dtime, loopFrame };
|
|
@@ -4,9 +4,9 @@ export interface IDEvent {
|
|
|
4
4
|
tag: string;
|
|
5
5
|
}
|
|
6
6
|
export default class DEvent {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
__map__: Map<string, Set<Function | any>>;
|
|
8
|
+
__tagList__: IDEvent[];
|
|
9
|
+
__eventId__: string;
|
|
10
10
|
constructor();
|
|
11
11
|
clear(): this;
|
|
12
12
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type TSVG = "back" | "right" | "home" | "close" | "close_circle" | "close_circle_fill" | "warning" | "play" | "lock" | "lock_fill" | "plus" | "plus_circle" | "plus_circle_fill" | "star" | "star_fill" | "share" | "love" | "love_fill";
|
|
2
2
|
export declare class DIcon {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
__defStyle__: string;
|
|
4
|
+
__map__: Record<TSVG, string>;
|
|
5
5
|
getBase64: (svgType: TSVG) => string;
|
|
6
6
|
getSVG: (svgType: TSVG) => {
|
|
7
7
|
url: string;
|
|
@@ -25,8 +25,8 @@ export declare class DTrack {
|
|
|
25
25
|
done: (t?: number) => void;
|
|
26
26
|
}
|
|
27
27
|
export declare class DTracker {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
__map__: Map<string, DTrack>;
|
|
29
|
+
__trackList__: DTrack[];
|
|
30
30
|
can: boolean;
|
|
31
31
|
clear(): this;
|
|
32
32
|
add(name: string, { desc, type }?: {
|
package/bin/types/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare const _default: {
|
|
|
8
8
|
gbkCut: (source: string, len: number) => string;
|
|
9
9
|
};
|
|
10
10
|
time: {
|
|
11
|
-
now: () => import("./modules/time/
|
|
11
|
+
now: () => import("./modules/time/dtime").default;
|
|
12
12
|
isToday: (date: any) => any;
|
|
13
13
|
parseTimestamp: ({ year, month, date, hour, minute, second }: {
|
|
14
14
|
year?: number | undefined;
|
|
@@ -20,8 +20,8 @@ declare const _default: {
|
|
|
20
20
|
}) => number;
|
|
21
21
|
todayZero: () => number;
|
|
22
22
|
format: (time: string | number | Date, reg?: string) => string;
|
|
23
|
-
countdown: (endTime: string | number | Date, reg?: string) =>
|
|
24
|
-
|
|
23
|
+
countdown: (endTime: string | number | Date, reg?: string) => "" | import("./modules/time/dtime").IDCountdownFormat;
|
|
24
|
+
dtime: (time: string | number | Date) => import("./modules/time/dtime").default;
|
|
25
25
|
loopFrame: (interval?: number) => import("./modules/time/frame").default;
|
|
26
26
|
oneDay: number;
|
|
27
27
|
oneHour: number;
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
export
|
|
2
|
-
date?: Date;
|
|
1
|
+
export interface IDCountdownFormat {
|
|
3
2
|
countdown: number;
|
|
4
|
-
|
|
3
|
+
timestamp: number;
|
|
4
|
+
seconds: number;
|
|
5
|
+
d: number;
|
|
6
|
+
dd: string;
|
|
7
|
+
h: number;
|
|
8
|
+
hh: string;
|
|
9
|
+
m: number;
|
|
10
|
+
mm: string;
|
|
11
|
+
s: number;
|
|
12
|
+
ss: string;
|
|
13
|
+
S: number;
|
|
14
|
+
SS: string;
|
|
15
|
+
SSS: string;
|
|
16
|
+
desc: string;
|
|
17
|
+
}
|
|
18
|
+
export default class DTime {
|
|
19
|
+
date?: Date;
|
|
5
20
|
timestamp: number;
|
|
6
21
|
yyyy?: number;
|
|
7
22
|
yy?: string;
|
|
@@ -20,7 +35,7 @@ export default class DTimeFormat {
|
|
|
20
35
|
SSS: string;
|
|
21
36
|
constructor(time: string | number | Date);
|
|
22
37
|
toDate(): this;
|
|
23
|
-
toCountdown():
|
|
38
|
+
toCountdown(reg?: string): IDCountdownFormat;
|
|
39
|
+
add(ms?: number): this;
|
|
24
40
|
format(reg?: string): string;
|
|
25
|
-
countdownFormat(reg?: string): string;
|
|
26
41
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import LoopFrame from "./frame";
|
|
2
|
-
import
|
|
2
|
+
import DTime from "./dtime";
|
|
3
3
|
/**
|
|
4
4
|
* 解析时间
|
|
5
5
|
* @param param0
|
|
@@ -17,15 +17,15 @@ declare function parseTimestamp({ year, month, date, hour, minute, second }: {
|
|
|
17
17
|
* 当前时间格式类
|
|
18
18
|
* @returns
|
|
19
19
|
*/
|
|
20
|
-
declare function now():
|
|
20
|
+
declare function now(): DTime;
|
|
21
21
|
declare const _default: {
|
|
22
22
|
now: typeof now;
|
|
23
23
|
isToday: (date: any) => any;
|
|
24
24
|
parseTimestamp: typeof parseTimestamp;
|
|
25
25
|
todayZero: () => number;
|
|
26
26
|
format: (time: string | number | Date, reg?: string) => string;
|
|
27
|
-
countdown: (endTime: string | number | Date, reg?: string) =>
|
|
28
|
-
|
|
27
|
+
countdown: (endTime: string | number | Date, reg?: string) => "" | import("./dtime").IDCountdownFormat;
|
|
28
|
+
dtime: (time: string | number | Date) => DTime;
|
|
29
29
|
loopFrame: (interval?: number) => LoopFrame;
|
|
30
30
|
oneDay: number;
|
|
31
31
|
oneHour: number;
|