zames_pro 2.1.1 → 2.1.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/input.js +11 -3
- package/dist/spinner.js +9 -3
- package/package.json +1 -1
package/dist/input.js
CHANGED
|
@@ -18,7 +18,10 @@ const CR = String.fromCharCode(13);
|
|
|
18
18
|
const ESC = String.fromCharCode(27);
|
|
19
19
|
const PASTE_START = ESC + '[200~';
|
|
20
20
|
const PASTE_END = ESC + '[201~';
|
|
21
|
-
|
|
21
|
+
// Анимация точек: старт с пустой строки (0 точек), затем рост.
|
|
22
|
+
// Ширину выравниваем по максимуму (3), чтобы подсказка не смещалась.
|
|
23
|
+
const DOTS = ['', '.', '..', '...'];
|
|
24
|
+
const DOTS_PAD = ' ';
|
|
22
25
|
const HINT = theme.dim(' · Enter — отправить, Ctrl+J — новая строка, Esc — стоп');
|
|
23
26
|
function safeJson(v) {
|
|
24
27
|
try {
|
|
@@ -216,6 +219,11 @@ export class LineEditor {
|
|
|
216
219
|
this._dotTimer = null;
|
|
217
220
|
}
|
|
218
221
|
}
|
|
222
|
+
_dots(n) {
|
|
223
|
+
// Точки того же цвета, что и база, и фиксированной ширины — иначе
|
|
224
|
+
// подсказка справа «прыгает» при смене фазы анимации.
|
|
225
|
+
return theme.brown(DOTS[n] + DOTS_PAD.slice(DOTS[n].length));
|
|
226
|
+
}
|
|
219
227
|
_startThinking() {
|
|
220
228
|
if (this.pendingText) {
|
|
221
229
|
this.setStatus(theme.prompt('✎ ') + this.pendingText + HINT);
|
|
@@ -223,11 +231,11 @@ export class LineEditor {
|
|
|
223
231
|
}
|
|
224
232
|
this._thinkBase = theme.brown(stripEllipsis(randomThinkingPhrase()));
|
|
225
233
|
this._dotPhase = 0;
|
|
226
|
-
this.setStatus(this._thinkBase +
|
|
234
|
+
this.setStatus(this._thinkBase + this._dots(0) + HINT);
|
|
227
235
|
this._stopDots();
|
|
228
236
|
this._dotTimer = setInterval(() => {
|
|
229
237
|
this._dotPhase = (this._dotPhase + 1) % DOTS.length;
|
|
230
|
-
this.setStatus(this._thinkBase +
|
|
238
|
+
this.setStatus(this._thinkBase + this._dots(this._dotPhase) + HINT);
|
|
231
239
|
}, 400);
|
|
232
240
|
if (this._dotTimer.unref)
|
|
233
241
|
this._dotTimer.unref();
|
package/dist/spinner.js
CHANGED
|
@@ -46,7 +46,10 @@ export function createSpinner() {
|
|
|
46
46
|
let dotTimer = null;
|
|
47
47
|
let dotPhase = 0;
|
|
48
48
|
let pending = null;
|
|
49
|
-
|
|
49
|
+
// Анимация точек: старт с пустой строки (0 точек), затем рост.
|
|
50
|
+
// Ширину выравниваем по максимуму (3), чтобы подсказка не смещалась.
|
|
51
|
+
const DOTS = ['', '.', '..', '...'];
|
|
52
|
+
const DOTS_PAD = ' ';
|
|
50
53
|
const start = (text) => {
|
|
51
54
|
if (!spinner)
|
|
52
55
|
spinner = ora(text).start();
|
|
@@ -67,7 +70,10 @@ export function createSpinner() {
|
|
|
67
70
|
// Запуск анимированного статуса: коричневый текст + «бегущие» точки.
|
|
68
71
|
const startThinking = () => {
|
|
69
72
|
const base = theme.brown(stripEllipsis(randomThinkingPhrase()));
|
|
70
|
-
|
|
73
|
+
// Точки того же цвета, что и база, и фиксированной ширины — иначе
|
|
74
|
+
// подсказка справа «прыгает» при смене фазы анимации.
|
|
75
|
+
const dots = (n) => theme.brown(DOTS[n] + DOTS_PAD.slice(DOTS[n].length));
|
|
76
|
+
start(base + dots(0) + HINT);
|
|
71
77
|
dotPhase = 0;
|
|
72
78
|
if (dotTimer)
|
|
73
79
|
clearInterval(dotTimer);
|
|
@@ -75,7 +81,7 @@ export function createSpinner() {
|
|
|
75
81
|
if (!spinner)
|
|
76
82
|
return;
|
|
77
83
|
dotPhase = (dotPhase + 1) % DOTS.length;
|
|
78
|
-
spinner.text = base +
|
|
84
|
+
spinner.text = base + dots(dotPhase) + HINT;
|
|
79
85
|
}, 400);
|
|
80
86
|
if (dotTimer.unref)
|
|
81
87
|
dotTimer.unref();
|