tledger 0.1.4 → 0.2.1
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/README.md +142 -78
- package/bin/token-ledger-controls.mjs +24 -0
- package/bin/token-ledger-rates.mjs +62 -0
- package/bin/token-ledger-terminal.mjs +184 -264
- package/bin/token-ledger-trend-image.mjs +945 -0
- package/bin/token-ledger-trend-terminal.mjs +609 -0
- package/bin/token-ledger-trend.mjs +745 -0
- package/bin/token-ledger-tui.mjs +26 -30
- package/bin/token-ledger.mjs +601 -253
- package/lib/{token-ledger-collector.mjs → token-ledger-importer.mjs} +256 -409
- package/package.json +19 -14
- package/lib/token-ledger-models.mjs +0 -113
package/bin/token-ledger-tui.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { renderFullscreen, SCREEN_BASE } from "./token-ledger-terminal.mjs";
|
|
2
|
+
import { actionFor } from "./token-ledger-controls.mjs";
|
|
3
|
+
|
|
4
|
+
export { actionFor };
|
|
2
5
|
|
|
3
6
|
const ENTER_ALT_SCREEN = "\u001b[?1049h";
|
|
4
7
|
const EXIT_ALT_SCREEN = "\u001b[?1049l";
|
|
@@ -7,16 +10,16 @@ const SHOW_CURSOR = "\u001b[?25h";
|
|
|
7
10
|
const CLEAR_SCREEN = "\u001b[2J\u001b[H";
|
|
8
11
|
const RESET = "\u001b[0m";
|
|
9
12
|
|
|
10
|
-
function actionFor(input) {
|
|
11
|
-
const value = String(input);
|
|
12
|
-
if (value.includes("\u001b[A") || value === "k") return "up";
|
|
13
|
-
if (value.includes("\u001b[B") || value === "j") return "down";
|
|
14
|
-
if (value === "q" || value === "Q" || value === "\u0003" || value === "\u001b") return "quit";
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
13
|
export function startInteractive(view) {
|
|
19
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
options,
|
|
16
|
+
snapshot,
|
|
17
|
+
snapshotFreshness,
|
|
18
|
+
bounds,
|
|
19
|
+
events,
|
|
20
|
+
rows,
|
|
21
|
+
allRows,
|
|
22
|
+
} = view;
|
|
20
23
|
const stdin = process.stdin;
|
|
21
24
|
const stdout = process.stdout;
|
|
22
25
|
if (!stdin.isTTY || !stdout.isTTY || typeof stdin.setRawMode !== "function") {
|
|
@@ -28,23 +31,20 @@ export function startInteractive(view) {
|
|
|
28
31
|
let closed = false;
|
|
29
32
|
|
|
30
33
|
const draw = () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} catch (error) {
|
|
46
|
-
finish(error);
|
|
47
|
-
}
|
|
34
|
+
const width = Math.max(40, stdout.columns || 120);
|
|
35
|
+
const height = Math.max(12, stdout.rows || 32);
|
|
36
|
+
const screen = renderFullscreen({
|
|
37
|
+
options: { ...options, forceColor: true, selectedIndex },
|
|
38
|
+
snapshot,
|
|
39
|
+
snapshotFreshness,
|
|
40
|
+
bounds,
|
|
41
|
+
events,
|
|
42
|
+
rows,
|
|
43
|
+
allRows,
|
|
44
|
+
width,
|
|
45
|
+
height,
|
|
46
|
+
});
|
|
47
|
+
stdout.write(`${SCREEN_BASE}${CLEAR_SCREEN}${screen}`);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const finish = (error = null) => {
|
|
@@ -53,8 +53,6 @@ export function startInteractive(view) {
|
|
|
53
53
|
stdin.off("data", onData);
|
|
54
54
|
stdout.off("resize", draw);
|
|
55
55
|
process.off("SIGINT", onSignal);
|
|
56
|
-
process.off("SIGTERM", onSignal);
|
|
57
|
-
process.off("SIGHUP", onSignal);
|
|
58
56
|
if (stdin.isTTY) stdin.setRawMode(false);
|
|
59
57
|
stdin.pause();
|
|
60
58
|
stdout.write(`${RESET}${SHOW_CURSOR}${EXIT_ALT_SCREEN}`);
|
|
@@ -87,8 +85,6 @@ export function startInteractive(view) {
|
|
|
87
85
|
stdin.on("data", onData);
|
|
88
86
|
stdout.on("resize", draw);
|
|
89
87
|
process.once("SIGINT", onSignal);
|
|
90
|
-
process.once("SIGTERM", onSignal);
|
|
91
|
-
process.once("SIGHUP", onSignal);
|
|
92
88
|
stdout.write(`${ENTER_ALT_SCREEN}${SCREEN_BASE}${HIDE_CURSOR}${CLEAR_SCREEN}`);
|
|
93
89
|
draw();
|
|
94
90
|
});
|