@flowscripter/dynamic-cli-framework 5.4.11 → 5.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../../../../src/service/printer/terminal/Spinner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../../../../src/service/printer/terminal/Spinner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAQ1D,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,MAAM,CAAC,OAAO,OAAO,OAAO;;IAc1B,YAAmB,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAGpD;IAoDY,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASjD;IAEY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAmBjC;IAEY,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAelC;IAEM,MAAM,IAAI,IAAI,CASpB;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,YAAY,EAEnC;CACF"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
const BOX_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
2
2
|
const STAR_FRAMES = ["★", "✶", "✷", "✹", "✷", "✶", "★", "✦"];
|
|
3
|
+
const SHOW_DELAY_MILLIS = 100;
|
|
3
4
|
export { SpinnerStyle } from "@flowscripter/dynamic-cli-framework-api";
|
|
4
5
|
import { SpinnerStyle } from "@flowscripter/dynamic-cli-framework-api";
|
|
5
6
|
export default class Spinner {
|
|
6
7
|
#isShown = false;
|
|
8
|
+
#isRendering = false;
|
|
7
9
|
#message;
|
|
8
10
|
#frameIndex = 0;
|
|
9
11
|
#timer;
|
|
12
|
+
#showDelayTimer;
|
|
10
13
|
#renderInFlight;
|
|
11
14
|
#spinColor = 0x8a8a8a;
|
|
12
15
|
#msgColor = 0x808080;
|
|
@@ -45,6 +48,17 @@ export default class Spinner {
|
|
|
45
48
|
});
|
|
46
49
|
}, 100);
|
|
47
50
|
}
|
|
51
|
+
async #beginRendering() {
|
|
52
|
+
this.#isRendering = true;
|
|
53
|
+
this.#startTimer();
|
|
54
|
+
await this.#terminal.hideCursor();
|
|
55
|
+
}
|
|
56
|
+
#scheduleShow() {
|
|
57
|
+
this.#showDelayTimer = setTimeout(() => {
|
|
58
|
+
this.#showDelayTimer = undefined;
|
|
59
|
+
void this.#beginRendering();
|
|
60
|
+
}, SHOW_DELAY_MILLIS);
|
|
61
|
+
}
|
|
48
62
|
async show(message) {
|
|
49
63
|
this.#message = message;
|
|
50
64
|
if (this.#isShown) {
|
|
@@ -52,14 +66,21 @@ export default class Spinner {
|
|
|
52
66
|
}
|
|
53
67
|
this.#isShown = true;
|
|
54
68
|
this.#frameIndex = 0;
|
|
55
|
-
this.#
|
|
56
|
-
|
|
69
|
+
this.#scheduleShow();
|
|
70
|
+
return Promise.resolve();
|
|
57
71
|
}
|
|
58
72
|
async hide() {
|
|
59
73
|
if (!this.#isShown) {
|
|
60
74
|
return Promise.resolve();
|
|
61
75
|
}
|
|
62
76
|
this.#isShown = false;
|
|
77
|
+
this.#message = undefined;
|
|
78
|
+
if (this.#showDelayTimer) {
|
|
79
|
+
clearTimeout(this.#showDelayTimer);
|
|
80
|
+
this.#showDelayTimer = undefined;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.#isRendering = false;
|
|
63
84
|
clearInterval(this.#timer);
|
|
64
85
|
this.#timer = undefined;
|
|
65
86
|
if (this.#renderInFlight) {
|
|
@@ -67,12 +88,16 @@ export default class Spinner {
|
|
|
67
88
|
}
|
|
68
89
|
await this.#terminal.clearLine();
|
|
69
90
|
await this.#terminal.showCursor();
|
|
70
|
-
this.#message = undefined;
|
|
71
91
|
}
|
|
72
92
|
async pause() {
|
|
73
93
|
if (!this.#isShown) {
|
|
74
94
|
return Promise.resolve();
|
|
75
95
|
}
|
|
96
|
+
if (this.#showDelayTimer) {
|
|
97
|
+
clearTimeout(this.#showDelayTimer);
|
|
98
|
+
this.#showDelayTimer = undefined;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
76
101
|
clearInterval(this.#timer);
|
|
77
102
|
this.#timer = undefined;
|
|
78
103
|
if (this.#renderInFlight) {
|
|
@@ -81,10 +106,15 @@ export default class Spinner {
|
|
|
81
106
|
await this.#terminal.clearLine();
|
|
82
107
|
}
|
|
83
108
|
resume() {
|
|
84
|
-
if (!this.#isShown || this.#timer !== undefined) {
|
|
109
|
+
if (!this.#isShown || this.#timer !== undefined || this.#showDelayTimer !== undefined) {
|
|
85
110
|
return;
|
|
86
111
|
}
|
|
87
|
-
this.#
|
|
112
|
+
if (this.#isRendering) {
|
|
113
|
+
this.#startTimer();
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.#scheduleShow();
|
|
117
|
+
}
|
|
88
118
|
}
|
|
89
119
|
set spinnerColor(color) {
|
|
90
120
|
this.#spinColor = color;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/dynamic-cli-framework",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.13",
|
|
4
4
|
"description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"build": "tsc -p tsconfig.build.json"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@flowscripter/dynamic-cli-framework-api": "^2.3.
|
|
52
|
-
"@flowscripter/dynamic-plugin-framework": "^2.2.
|
|
51
|
+
"@flowscripter/dynamic-cli-framework-api": "^2.3.6",
|
|
52
|
+
"@flowscripter/dynamic-plugin-framework": "^2.2.8",
|
|
53
53
|
"emphasize": "^7.0.0",
|
|
54
54
|
"fastest-levenshtein": "^1.0.16",
|
|
55
55
|
"figlet": "^1.11.4",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/bun": "^1.4.2",
|
|
64
|
-
"@types/node": "^26.
|
|
64
|
+
"@types/node": "^26.5.1",
|
|
65
65
|
"@types/semver": "^7.8.0",
|
|
66
66
|
"oxfmt": "0.67.0",
|
|
67
67
|
"oxlint": "1.82.0"
|
|
@@ -5,14 +5,18 @@ const BOX_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇
|
|
|
5
5
|
|
|
6
6
|
const STAR_FRAMES = ["★", "✶", "✷", "✹", "✷", "✶", "★", "✦"];
|
|
7
7
|
|
|
8
|
+
const SHOW_DELAY_MILLIS = 100;
|
|
9
|
+
|
|
8
10
|
export { SpinnerStyle } from "@flowscripter/dynamic-cli-framework-api";
|
|
9
11
|
import { SpinnerStyle } from "@flowscripter/dynamic-cli-framework-api";
|
|
10
12
|
|
|
11
13
|
export default class Spinner {
|
|
12
14
|
#isShown = false;
|
|
15
|
+
#isRendering = false;
|
|
13
16
|
#message: string | undefined;
|
|
14
17
|
#frameIndex = 0;
|
|
15
18
|
#timer: Timer | undefined;
|
|
19
|
+
#showDelayTimer: Timer | undefined;
|
|
16
20
|
#renderInFlight: Promise<void> | undefined;
|
|
17
21
|
#spinColor = 0x8a8a8a;
|
|
18
22
|
#msgColor = 0x808080;
|
|
@@ -62,6 +66,19 @@ export default class Spinner {
|
|
|
62
66
|
}, 100);
|
|
63
67
|
}
|
|
64
68
|
|
|
69
|
+
async #beginRendering(): Promise<void> {
|
|
70
|
+
this.#isRendering = true;
|
|
71
|
+
this.#startTimer();
|
|
72
|
+
await this.#terminal.hideCursor();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#scheduleShow(): void {
|
|
76
|
+
this.#showDelayTimer = setTimeout(() => {
|
|
77
|
+
this.#showDelayTimer = undefined;
|
|
78
|
+
void this.#beginRendering();
|
|
79
|
+
}, SHOW_DELAY_MILLIS);
|
|
80
|
+
}
|
|
81
|
+
|
|
65
82
|
public async show(message?: string): Promise<void> {
|
|
66
83
|
this.#message = message;
|
|
67
84
|
if (this.#isShown) {
|
|
@@ -69,8 +86,8 @@ export default class Spinner {
|
|
|
69
86
|
}
|
|
70
87
|
this.#isShown = true;
|
|
71
88
|
this.#frameIndex = 0;
|
|
72
|
-
this.#
|
|
73
|
-
|
|
89
|
+
this.#scheduleShow();
|
|
90
|
+
return Promise.resolve();
|
|
74
91
|
}
|
|
75
92
|
|
|
76
93
|
public async hide(): Promise<void> {
|
|
@@ -78,6 +95,13 @@ export default class Spinner {
|
|
|
78
95
|
return Promise.resolve();
|
|
79
96
|
}
|
|
80
97
|
this.#isShown = false;
|
|
98
|
+
this.#message = undefined;
|
|
99
|
+
if (this.#showDelayTimer) {
|
|
100
|
+
clearTimeout(this.#showDelayTimer);
|
|
101
|
+
this.#showDelayTimer = undefined;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.#isRendering = false;
|
|
81
105
|
clearInterval(this.#timer);
|
|
82
106
|
this.#timer = undefined;
|
|
83
107
|
if (this.#renderInFlight) {
|
|
@@ -85,13 +109,17 @@ export default class Spinner {
|
|
|
85
109
|
}
|
|
86
110
|
await this.#terminal.clearLine();
|
|
87
111
|
await this.#terminal.showCursor();
|
|
88
|
-
this.#message = undefined;
|
|
89
112
|
}
|
|
90
113
|
|
|
91
114
|
public async pause(): Promise<void> {
|
|
92
115
|
if (!this.#isShown) {
|
|
93
116
|
return Promise.resolve();
|
|
94
117
|
}
|
|
118
|
+
if (this.#showDelayTimer) {
|
|
119
|
+
clearTimeout(this.#showDelayTimer);
|
|
120
|
+
this.#showDelayTimer = undefined;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
95
123
|
clearInterval(this.#timer);
|
|
96
124
|
this.#timer = undefined;
|
|
97
125
|
if (this.#renderInFlight) {
|
|
@@ -101,10 +129,14 @@ export default class Spinner {
|
|
|
101
129
|
}
|
|
102
130
|
|
|
103
131
|
public resume(): void {
|
|
104
|
-
if (!this.#isShown || this.#timer !== undefined) {
|
|
132
|
+
if (!this.#isShown || this.#timer !== undefined || this.#showDelayTimer !== undefined) {
|
|
105
133
|
return;
|
|
106
134
|
}
|
|
107
|
-
this.#
|
|
135
|
+
if (this.#isRendering) {
|
|
136
|
+
this.#startTimer();
|
|
137
|
+
} else {
|
|
138
|
+
this.#scheduleShow();
|
|
139
|
+
}
|
|
108
140
|
}
|
|
109
141
|
|
|
110
142
|
set spinnerColor(color: number) {
|