yechancho 1.0.7 → 1.0.9
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/index.js +11 -34
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -145,11 +145,6 @@ function stepPetals(petals, width, height) {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
// Render without log-update: write to (0,0) and erase down. No scrolling.
|
|
149
|
-
function drawFrame(frame) {
|
|
150
|
-
process.stdout.write(ansiEscapes.cursorTo(0, 0) + ansiEscapes.eraseDown + frame)
|
|
151
|
-
}
|
|
152
|
-
|
|
153
148
|
function setupCleanup() {
|
|
154
149
|
const cleanup = () => {
|
|
155
150
|
try {
|
|
@@ -169,44 +164,29 @@ function setupCleanup() {
|
|
|
169
164
|
return cleanup
|
|
170
165
|
}
|
|
171
166
|
|
|
172
|
-
async function runIntroAnimation(
|
|
167
|
+
async function runIntroAnimation(durationMs, fps) {
|
|
173
168
|
const frameMs = Math.round(1000 / fps)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
let overlayH = 10
|
|
177
|
-
|
|
178
|
-
const computeSizes = () => {
|
|
179
|
-
const termW = process.stdout.columns ?? 80
|
|
180
|
-
const termH = process.stdout.rows ?? 24
|
|
169
|
+
const termW = process.stdout.columns ?? 80
|
|
170
|
+
const termH = process.stdout.rows ?? 24
|
|
181
171
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const petalCount = clamp(Math.floor(overlayW / 5), 10, 32)
|
|
187
|
-
petals = initPetals(petalCount, overlayW, overlayH)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
computeSizes()
|
|
191
|
-
|
|
192
|
-
// If user resizes terminal, recompute overlay
|
|
193
|
-
const onResize = () => computeSizes()
|
|
194
|
-
process.stdout.on('resize', onResize)
|
|
172
|
+
const overlayW = clamp(termW - 2, 40, 100)
|
|
173
|
+
const overlayH = clamp(Math.floor(termH / 3), 8, 14)
|
|
174
|
+
const petalCount = clamp(Math.floor(overlayW / 4), 12, 28)
|
|
175
|
+
const petals = initPetals(petalCount, overlayW, overlayH)
|
|
195
176
|
|
|
196
177
|
const start = Date.now()
|
|
197
178
|
let t = 0
|
|
198
179
|
|
|
199
180
|
while (Date.now() - start < durationMs) {
|
|
200
181
|
const overlay = renderOverlay(petals, t, overlayW, overlayH)
|
|
201
|
-
const
|
|
202
|
-
|
|
182
|
+
const sparkle = sakura.rose(' ✿ ') + sakura.dim(' · ') + sakura.rose(' ✿ ')
|
|
183
|
+
const frame = overlay + '\n' + sparkle
|
|
184
|
+
process.stdout.write(ansiEscapes.cursorTo(0, 0) + ansiEscapes.eraseDown + frame)
|
|
203
185
|
|
|
204
186
|
stepPetals(petals, overlayW, overlayH)
|
|
205
187
|
t += frameMs
|
|
206
188
|
await sleep(frameMs)
|
|
207
189
|
}
|
|
208
|
-
|
|
209
|
-
process.stdout.off('resize', onResize)
|
|
210
190
|
}
|
|
211
191
|
|
|
212
192
|
async function main() {
|
|
@@ -223,13 +203,10 @@ async function main() {
|
|
|
223
203
|
|
|
224
204
|
setupCleanup()
|
|
225
205
|
cliCursor.hide()
|
|
226
|
-
|
|
227
|
-
// Clear once, then render frames from top-left
|
|
228
206
|
process.stdout.write(ansiEscapes.clearScreen)
|
|
229
207
|
|
|
230
|
-
await runIntroAnimation(
|
|
208
|
+
await runIntroAnimation(durationMs, fps)
|
|
231
209
|
|
|
232
|
-
// Final static render (clean)
|
|
233
210
|
process.stdout.write(ansiEscapes.cursorTo(0, 0) + ansiEscapes.eraseDown)
|
|
234
211
|
cliCursor.show()
|
|
235
212
|
console.log(card)
|