dankgrinder 8.84.0 → 8.86.0

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.
Files changed (2) hide show
  1. package/lib/ui.js +16 -2
  2. package/package.json +1 -1
package/lib/ui.js CHANGED
@@ -7,6 +7,7 @@ let _version = '0.0.0';
7
7
  let _live = false;
8
8
  let _startTime = Date.now();
9
9
  let _events = [];
10
+ let _coinHistory = new Array(10).fill(0);
10
11
  const MAX_EVENTS = 5;
11
12
  let _refreshTimer = null;
12
13
 
@@ -49,6 +50,18 @@ const STATUS_DOT = {
49
50
  connect: { dot: '◯', color: chalk.hex('#ffb450') }
50
51
  };
51
52
 
53
+
54
+ function getSparkline() {
55
+ const min = Math.min(..._coinHistory);
56
+ const max = Math.max(..._coinHistory);
57
+ if (min === max) return chalk.dim('⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤');
58
+ const sparks = [' ', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
59
+ return _coinHistory.map(v => {
60
+ const idx = Math.floor(((v - min) / (max - min)) * 7);
61
+ return chalk.green(sparks[idx]);
62
+ }).join('');
63
+ }
64
+
52
65
  function init({ workers }) { _workers = workers; _startTime = Date.now(); _events = []; _live = false; }
53
66
 
54
67
  function drawBanner(version) {
@@ -248,14 +261,15 @@ function render() {
248
261
  if (_events.length === 0) out += chalk.dim(' Quiet here...\n');
249
262
  _events.forEach(ev => { out += ` ${chalk.dim(`[${ev.ts}]`)} ${ev.icon} ${ev.msg}\n`; });
250
263
 
251
- process.stdout.write(out);
264
+ require("log-update")(out);
252
265
  }
253
266
 
254
267
  function start() {}
255
268
  function draw() { render(); }
256
269
  function setLive(val) { _live = val; if (val) render(); }
257
270
  function setPhase(phase) {}
258
- function startRefresh() { if (!_refreshTimer) _refreshTimer = setInterval(() => { if (_live) render(); }, 80); }
271
+ function startRefresh() { setInterval(() => { if(_live){ const tot = _workers.reduce((a,w)=>a+(w.stats.coins||0),0); _coinHistory.shift(); _coinHistory.push(tot); } }, 5000);
272
+ if (!_refreshTimer) _refreshTimer = setInterval(() => { if (_live) render(); }, 80); }
259
273
  function stopRefresh() { if (_refreshTimer) { clearInterval(_refreshTimer); _refreshTimer = null; } }
260
274
  function stop() { _live = false; stopRefresh(); logUpdate.clear(); }
261
275
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dankgrinder",
3
- "version": "8.84.0",
3
+ "version": "8.86.0",
4
4
  "description": "Dank Memer automation engine — grind coins while you sleep",
5
5
  "bin": {
6
6
  "dankgrinder": "bin/dankgrinder.js"