truememory-mirror 1.0.8 → 1.0.10
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/mirror.js +29 -7
- package/package.json +1 -1
package/bin/mirror.js
CHANGED
|
@@ -242,22 +242,44 @@ async function main() {
|
|
|
242
242
|
process.exit(1);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
// --- Poll with
|
|
245
|
+
// --- Poll with smooth interpolation ---
|
|
246
|
+
let serverPct = 0;
|
|
247
|
+
let displayPct = 0;
|
|
248
|
+
let done = false;
|
|
249
|
+
|
|
250
|
+
function renderProgress() {
|
|
251
|
+
const pct = Math.min(Math.round(displayPct), 99);
|
|
252
|
+
clearLine();
|
|
253
|
+
write(` ${progressBar(pct / 100)} ${WHITE}${pct}%${R} ${DIM}${phraseForProgress(pct)}...${R}`);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const smoothTimer = setInterval(() => {
|
|
257
|
+
if (done) return;
|
|
258
|
+
if (displayPct < serverPct) {
|
|
259
|
+
displayPct += Math.max(1, (serverPct - displayPct) * 0.3);
|
|
260
|
+
} else if (displayPct < 95) {
|
|
261
|
+
displayPct += 0.7;
|
|
262
|
+
}
|
|
263
|
+
displayPct = Math.min(displayPct, 99);
|
|
264
|
+
renderProgress();
|
|
265
|
+
}, 500);
|
|
266
|
+
|
|
246
267
|
try {
|
|
247
268
|
await pollStatus(result.profile_id, args.apiUrl, (status) => {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
clearLine();
|
|
252
|
-
write(` ${bar} ${WHITE}${pct}%${R} ${DIM}${phraseForProgress(pct)}...${R}`);
|
|
269
|
+
serverPct = Math.round((status.progress || 0) * 100);
|
|
270
|
+
if (serverPct > displayPct) renderProgress();
|
|
253
271
|
});
|
|
254
272
|
} catch (err) {
|
|
273
|
+
done = true;
|
|
274
|
+
clearInterval(smoothTimer);
|
|
255
275
|
write(`\n\n ✗ extraction failed: ${err.message}\n\n`);
|
|
256
276
|
process.exit(1);
|
|
257
277
|
}
|
|
258
278
|
|
|
279
|
+
done = true;
|
|
280
|
+
clearInterval(smoothTimer);
|
|
259
281
|
clearLine();
|
|
260
|
-
write(` ${progressBar(1.0)} ${WHITE}100%${R}\n\n`);
|
|
282
|
+
write(` ${progressBar(1.0)} ${WHITE}100%${R} ${DIM}finalizing your mirror...${R}\n\n`);
|
|
261
283
|
write(` ${G}✓${R} your mirror is ready\n`);
|
|
262
284
|
write(` ${G}→${R} ${result.url}\n\n`);
|
|
263
285
|
|