@d-zero/dealer 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/display.js +22 -6
- package/dist/lanes.js +3 -2
- package/package.json +3 -3
package/dist/display.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import c from 'ansi-colors';
|
|
2
1
|
import { countDownFunctionParser } from './count-down-function-parser.js';
|
|
3
2
|
import { riffle } from './riffle.js';
|
|
4
|
-
const RESET =
|
|
3
|
+
const RESET = '\u001B[0m';
|
|
5
4
|
const CURSOR_UP = (n) => `\u001B[${n}A`;
|
|
6
5
|
const CURSOR_TO_COL0 = '\u001B[G';
|
|
7
6
|
const ERASE_DOWN = '\u001B[0J';
|
|
@@ -14,10 +13,13 @@ const animationPresets = {
|
|
|
14
13
|
};
|
|
15
14
|
export class Display {
|
|
16
15
|
#animations;
|
|
16
|
+
#closed = false;
|
|
17
17
|
#coundDownMap = new Map();
|
|
18
18
|
#debugMessages = [];
|
|
19
19
|
#frameInterval;
|
|
20
20
|
#lastWroteLineNum = 0;
|
|
21
|
+
#resizeHandler = null;
|
|
22
|
+
#sigintHandler = null;
|
|
21
23
|
#stack = null;
|
|
22
24
|
#startTime = Date.now();
|
|
23
25
|
#timer = null;
|
|
@@ -30,19 +32,33 @@ export class Display {
|
|
|
30
32
|
const fps = options?.fps ?? 30;
|
|
31
33
|
this.#frameInterval = 1000 / fps;
|
|
32
34
|
this.#verbose = options?.verbose ?? false;
|
|
33
|
-
|
|
35
|
+
this.#resizeHandler = () => this.#resize();
|
|
36
|
+
process.stdout.on('resize', this.#resizeHandler);
|
|
37
|
+
if (!this.#verbose) {
|
|
38
|
+
this.#sigintHandler = () => {
|
|
39
|
+
this.close();
|
|
40
|
+
process.exit(130);
|
|
41
|
+
};
|
|
42
|
+
process.on('SIGINT', this.#sigintHandler);
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
45
|
close() {
|
|
36
|
-
if (this.#verbose) {
|
|
46
|
+
if (this.#verbose || this.#closed) {
|
|
37
47
|
return;
|
|
38
48
|
}
|
|
49
|
+
this.#closed = true;
|
|
39
50
|
if (this.#timer) {
|
|
40
51
|
clearTimeout(this.#timer);
|
|
41
52
|
this.#timer = null;
|
|
42
53
|
}
|
|
43
54
|
this.#write();
|
|
44
|
-
if (
|
|
45
|
-
process.
|
|
55
|
+
if (this.#resizeHandler) {
|
|
56
|
+
process.stdout.off('resize', this.#resizeHandler);
|
|
57
|
+
this.#resizeHandler = null;
|
|
58
|
+
}
|
|
59
|
+
if (this.#sigintHandler) {
|
|
60
|
+
process.off('SIGINT', this.#sigintHandler);
|
|
61
|
+
this.#sigintHandler = null;
|
|
46
62
|
}
|
|
47
63
|
this.#lastWroteLineNum = 0;
|
|
48
64
|
this.#stack = null;
|
package/dist/lanes.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Display } from './display.js';
|
|
2
|
+
const RESET = '\u001B[0m';
|
|
2
3
|
export class Lanes {
|
|
3
4
|
#display;
|
|
4
5
|
#header;
|
|
@@ -45,7 +46,7 @@ export class Lanes {
|
|
|
45
46
|
}
|
|
46
47
|
update(id, log) {
|
|
47
48
|
if (this.#verbose) {
|
|
48
|
-
this.#display.write(this.#header
|
|
49
|
+
this.#display.write(`${RESET}${this.#header}${RESET} ${log}`);
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
this.#logs.set(id, log);
|
|
@@ -59,7 +60,7 @@ export class Lanes {
|
|
|
59
60
|
logs.sort(this.#sort);
|
|
60
61
|
const messages = logs.map(([, message]) => `${this.#indent}${message}`);
|
|
61
62
|
if (this.#header) {
|
|
62
|
-
messages.unshift(...this.#header.split('\n'));
|
|
63
|
+
messages.unshift(...this.#header.split('\n').map((line) => `${RESET}${line}${RESET}`));
|
|
63
64
|
}
|
|
64
65
|
this.#display.write(...messages);
|
|
65
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/dealer",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "A tool that provides an API and CLI for parallel processing of collections and sequential logging to standard output",
|
|
5
5
|
"author": "D-ZERO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"clean": "tsc --build --clean"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@d-zero/shared": "0.
|
|
26
|
+
"@d-zero/shared": "0.20.0",
|
|
27
27
|
"ansi-colors": "4.1.3"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "1830747a6fee6194c897d54966c25ada5237645e"
|
|
30
30
|
}
|