mybitduit 0.0.1 → 0.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/cli/mybitduit.mjs +58 -48
- package/package.json +21 -5
package/cli/mybitduit.mjs
CHANGED
|
@@ -126,15 +126,23 @@ async function tui() {
|
|
|
126
126
|
const { useState, useEffect, useRef } = React;
|
|
127
127
|
const html = htm.bind(React.createElement);
|
|
128
128
|
|
|
129
|
-
//
|
|
130
|
-
const
|
|
131
|
-
'
|
|
132
|
-
'
|
|
133
|
-
'
|
|
134
|
-
'
|
|
135
|
-
'
|
|
136
|
-
'
|
|
129
|
+
// big wordmark (figlet "ANSI Shadow"), drawn with a green gradient
|
|
130
|
+
const WORDMARK = [
|
|
131
|
+
'███╗ ███╗██╗ ██╗██████╗ ██╗████████╗██████╗ ██╗ ██╗██╗████████╗',
|
|
132
|
+
'████╗ ████║╚██╗ ██╔╝██╔══██╗██║╚══██╔══╝██╔══██╗██║ ██║██║╚══██╔══╝',
|
|
133
|
+
'██╔████╔██║ ╚████╔╝ ██████╔╝██║ ██║ ██║ ██║██║ ██║██║ ██║ ',
|
|
134
|
+
'██║╚██╔╝██║ ╚██╔╝ ██╔══██╗██║ ██║ ██║ ██║██║ ██║██║ ██║ ',
|
|
135
|
+
'██║ ╚═╝ ██║ ██║ ██████╔╝██║ ██║ ██████╔╝╚██████╔╝██║ ██║ ',
|
|
136
|
+
'╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ',
|
|
137
137
|
];
|
|
138
|
+
const WORDMARK_W = WORDMARK[0].length;
|
|
139
|
+
// line i of n: bright phosphor green fading into the deep logo green
|
|
140
|
+
const grad = (i, n) => {
|
|
141
|
+
const t = i / Math.max(1, n - 1);
|
|
142
|
+
const mix = (a, b) => Math.round(a + (b - a) * t);
|
|
143
|
+
return '#' + [mix(0, 42), mix(255, 125), mix(156, 92)]
|
|
144
|
+
.map((v) => v.toString(16).padStart(2, '0')).join('');
|
|
145
|
+
};
|
|
138
146
|
|
|
139
147
|
const MENU = [
|
|
140
148
|
{ label: 'Live prices · top 10', hint: '↵', action: 'live' },
|
|
@@ -143,10 +151,13 @@ async function tui() {
|
|
|
143
151
|
{ label: 'Quit', hint: 'q', action: 'quit' },
|
|
144
152
|
];
|
|
145
153
|
|
|
146
|
-
// take over the screen
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
// take over the screen like its own window (grok-style):
|
|
155
|
+
// ?1049h = alternate buffer 2J/H = clear ]11; = set the terminal
|
|
156
|
+
// window's own background to void (paints even the padding margins)
|
|
157
|
+
process.stdout.write(`\x1b[?1049h\x1b[2J\x1b[H\x1b]11;${VOID}\x07`);
|
|
158
|
+
const restore = () => process.stdout.write('\x1b]111\x07\x1b[?1049l');
|
|
149
159
|
process.on('exit', restore);
|
|
160
|
+
process.on('SIGTERM', () => { restore(); process.exit(0); });
|
|
150
161
|
|
|
151
162
|
function App() {
|
|
152
163
|
const { exit } = useApp();
|
|
@@ -274,16 +285,26 @@ async function tui() {
|
|
|
274
285
|
}
|
|
275
286
|
});
|
|
276
287
|
|
|
277
|
-
const cursorOn = tick % 2 === 0;
|
|
288
|
+
const cursorOn = Math.floor(tick / 4) % 2 === 0; // ~480ms blink, like a real cursor
|
|
278
289
|
const retryTxt = retryAt ? ` · retrying in ${Math.max(0, Math.ceil((retryAt - Date.now()) / 1000))}s` : '';
|
|
279
290
|
const statusTxt = err
|
|
280
291
|
? `✗ ${err}${retryTxt} · press r`
|
|
281
292
|
: toast || 'non-custodial · nothing leaves your machine · prices via coingecko';
|
|
282
293
|
|
|
283
294
|
const Shell = (children) =>
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
295
|
+
React.createElement(
|
|
296
|
+
Box,
|
|
297
|
+
{ flexDirection: 'column', width: cols, height: rows, backgroundColor: VOID, paddingX: 2, paddingTop: 1 },
|
|
298
|
+
...(Array.isArray(children) ? children : [children]),
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
// gradient wordmark; falls back to plain type on narrow terminals
|
|
302
|
+
const Wordmark = () =>
|
|
303
|
+
cols >= WORDMARK_W + 6
|
|
304
|
+
? html`<${Box} flexDirection="column" alignItems="center">
|
|
305
|
+
${WORDMARK.map((l, i) => html`<${Text} key=${i} color=${grad(i, WORDMARK.length)}>${l}<//>`)}
|
|
306
|
+
<//>`
|
|
307
|
+
: html`<${Box} justifyContent="center"><${Text} bold color=${GREEN}>mybitduit<//><//>`;
|
|
287
308
|
|
|
288
309
|
/* ---------------- HOME ---------------- */
|
|
289
310
|
if (screen === 'home') {
|
|
@@ -298,23 +319,18 @@ async function tui() {
|
|
|
298
319
|
|
|
299
320
|
return Shell(html`
|
|
300
321
|
<${Box} flexGrow=${1}><//>
|
|
322
|
+
<${Wordmark} />
|
|
323
|
+
<${Box} justifyContent="center" marginTop=${1}>
|
|
324
|
+
<${Text} color=${DIM}>your non-custodial solana money terminal<//>
|
|
325
|
+
<${Text} color=${LOGO}> · Beta<//>
|
|
326
|
+
<//>
|
|
301
327
|
<${Box} justifyContent="center">
|
|
302
|
-
<${
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
<${Text} bold color=${INK}>mybitduit<//>
|
|
309
|
-
<${Text} color=${DIM}> Beta 0.0.1<//>
|
|
310
|
-
<//>
|
|
311
|
-
<${Text} color=${DIM}>your non-custodial solana money terminal<//>
|
|
312
|
-
<${Box} marginTop=${1}><${Text} bold color=${AMBER}>live · prices + read-only wallet<//><//>
|
|
313
|
-
<${Text} color=${DIM}>Top 10 + 7d charts, and any wallet by address. Swaps next.<//>
|
|
314
|
-
<${Box} flexDirection="column" marginTop=${1}>
|
|
315
|
-
${menu}
|
|
316
|
-
<//>
|
|
317
|
-
<//>
|
|
328
|
+
<${Text} color=${AMBER}>live · prices + read-only wallet<//>
|
|
329
|
+
<${Text} color=${DIM}> · swaps next<//>
|
|
330
|
+
<//>
|
|
331
|
+
<${Box} justifyContent="center" marginTop=${1}>
|
|
332
|
+
<${Box} flexDirection="column">
|
|
333
|
+
${menu}
|
|
318
334
|
<//>
|
|
319
335
|
<//>
|
|
320
336
|
<${Box} flexGrow=${1}><//>
|
|
@@ -326,7 +342,6 @@ async function tui() {
|
|
|
326
342
|
<${Box} flexGrow=${1}><//>
|
|
327
343
|
<${Text} color=${DIM}>mybitduit · prices<//>
|
|
328
344
|
<//>
|
|
329
|
-
<${Box} justifyContent="flex-end"><${Text} color=${DIM}>Beta<//><//>
|
|
330
345
|
`);
|
|
331
346
|
}
|
|
332
347
|
|
|
@@ -367,13 +382,9 @@ async function tui() {
|
|
|
367
382
|
i === pos || i === (pos + 1) % w ? '█' : '░').join('');
|
|
368
383
|
return Shell(html`
|
|
369
384
|
<${Box} flexGrow=${1}><//>
|
|
370
|
-
<${
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
<${Box} marginTop=${1}><${Text} color=${DIM}>reading wallet · on-chain<//><//>
|
|
374
|
-
<${Box}><${Text} color=${GREEN}>[${barr}]<//><//>
|
|
375
|
-
<//>
|
|
376
|
-
<//>
|
|
385
|
+
<${Wordmark} />
|
|
386
|
+
<${Box} justifyContent="center" marginTop=${1}><${Text} color=${DIM}>reading wallet · on-chain<//><//>
|
|
387
|
+
<${Box} justifyContent="center"><${Text} color=${GREEN}>[${barr}]<//><//>
|
|
377
388
|
<${Box} flexGrow=${1}><//>
|
|
378
389
|
<${Box} justifyContent="flex-end"><${Text} color=${DIM}>read-only · we never see a key<//><//>
|
|
379
390
|
`);
|
|
@@ -440,14 +451,10 @@ async function tui() {
|
|
|
440
451
|
i === pos || i === (pos + 1) % w ? '█' : '░').join('');
|
|
441
452
|
return Shell(html`
|
|
442
453
|
<${Box} flexGrow=${1}><//>
|
|
443
|
-
<${
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
<${Box}><${Text} color=${GREEN}>[${barr}]<//><//>
|
|
448
|
-
${err && html`<${Box} marginTop=${1}><${Text} color=${RED}>✗ ${err}${retryTxt}<//><//>`}
|
|
449
|
-
<//>
|
|
450
|
-
<//>
|
|
454
|
+
<${Wordmark} />
|
|
455
|
+
<${Box} justifyContent="center" marginTop=${1}><${Text} color=${DIM}>loading top 10 markets<//><//>
|
|
456
|
+
<${Box} justifyContent="center"><${Text} color=${GREEN}>[${barr}]<//><//>
|
|
457
|
+
${err && html`<${Box} justifyContent="center" marginTop=${1}><${Text} color=${RED}>✗ ${err}${retryTxt}<//><//>`}
|
|
451
458
|
<${Box} flexGrow=${1}><//>
|
|
452
459
|
<${Box} justifyContent="flex-end"><${Text} color=${DIM}>esc back · q quit<//><//>
|
|
453
460
|
`);
|
|
@@ -512,7 +519,10 @@ async function tui() {
|
|
|
512
519
|
`);
|
|
513
520
|
}
|
|
514
521
|
|
|
515
|
-
render(html`<${App} />`);
|
|
522
|
+
const app = render(html`<${App} />`);
|
|
523
|
+
await app.waitUntilExit();
|
|
524
|
+
restore();
|
|
525
|
+
process.exit(0);
|
|
516
526
|
}
|
|
517
527
|
|
|
518
528
|
/* ---- help ---- */
|
package/package.json
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mybitduit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "mybitduit — your non-custodial Solana money terminal (web + CLI). bit + duit.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
|
|
6
|
+
"bin": {
|
|
7
|
+
"mybitduit": "cli/mybitduit.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"cli/",
|
|
11
|
+
"core/",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
8
14
|
"preferGlobal": true,
|
|
9
|
-
"keywords": [
|
|
15
|
+
"keywords": [
|
|
16
|
+
"solana",
|
|
17
|
+
"crypto",
|
|
18
|
+
"cli",
|
|
19
|
+
"terminal",
|
|
20
|
+
"prices",
|
|
21
|
+
"wallet",
|
|
22
|
+
"non-custodial"
|
|
23
|
+
],
|
|
10
24
|
"license": "MIT",
|
|
11
25
|
"scripts": {
|
|
12
26
|
"start": "node cli/mybitduit.mjs",
|
|
@@ -19,5 +33,7 @@
|
|
|
19
33
|
"ink": "^5.0.1",
|
|
20
34
|
"react": "^18.3.1"
|
|
21
35
|
},
|
|
22
|
-
"engines": {
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
}
|
|
23
39
|
}
|