nerdflirt 1.0.1 → 1.0.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/bin/nerdflirt.js +16 -4
- package/package.json +1 -1
package/bin/nerdflirt.js
CHANGED
|
@@ -40,10 +40,18 @@ function animateBanner() {
|
|
|
40
40
|
function startLoader(text) {
|
|
41
41
|
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
|
|
42
42
|
let i = 0
|
|
43
|
+
let stopped = false
|
|
43
44
|
const id = setInterval(() => {
|
|
44
|
-
|
|
45
|
+
const frame = chalk.hex('#C084FC')(frames[i++ % frames.length]) + ' ' + chalk.dim(text)
|
|
46
|
+
// save cursor, move up to loader line, clear it, write frame, restore cursor
|
|
47
|
+
process.stdout.write('\x1b[s\x1b[A\x1b[2K\r ' + frame + '\x1b[u')
|
|
45
48
|
}, 80)
|
|
46
|
-
return () => {
|
|
49
|
+
return () => {
|
|
50
|
+
if (stopped) return
|
|
51
|
+
stopped = true
|
|
52
|
+
clearInterval(id)
|
|
53
|
+
process.stdout.write('\x1b[s\x1b[A\x1b[2K\x1b[u')
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
// --- State ---
|
|
@@ -111,9 +119,12 @@ await animateBanner()
|
|
|
111
119
|
console.log(chalk.hex('#F472B6')(` ♥ You are: ${chalk.bold(myName)}`))
|
|
112
120
|
console.log(chalk.dim(' /swipe to start swiping • /peers to see who\'s online • /quit to exit\n'))
|
|
113
121
|
|
|
114
|
-
const stopLoader = startLoader('Searching for nerds on the network...')
|
|
115
|
-
|
|
116
122
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
|
123
|
+
rl.setPrompt(chalk.hex('#C084FC')(`${myName}> `))
|
|
124
|
+
|
|
125
|
+
console.log() // reserve line for loader
|
|
126
|
+
rl.prompt()
|
|
127
|
+
const stopLoader = startLoader('Searching for nerds on the network...')
|
|
117
128
|
|
|
118
129
|
let firstConnection = true
|
|
119
130
|
|
|
@@ -255,6 +266,7 @@ await discovery.flushed()
|
|
|
255
266
|
|
|
256
267
|
// --- Line input (lobby + chat modes) ---
|
|
257
268
|
rl.on('line', (line) => {
|
|
269
|
+
stopLoader()
|
|
258
270
|
const text = line.trim()
|
|
259
271
|
if (!text) { rl.prompt(); return }
|
|
260
272
|
|