ink-hud 0.1.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.
- package/LICENSE +21 -0
- package/README.md +284 -0
- package/dist/index.cjs +3012 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1510 -0
- package/dist/index.d.ts +1510 -0
- package/dist/index.js +2951 -0
- package/dist/index.js.map +1 -0
- package/package.json +89 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 saonian
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# ink-hud
|
|
2
|
+
|
|
3
|
+
> 💎 Retina-grade terminal data visualization dashboard - High-resolution chart library based on Braille characters
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ink-hud)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
**ink-hud** is a high-fidelity data visualization component library designed for the terminal, built on React and Ink. By utilizing Braille dot matrix characters (⣿), it achieves 8x higher vertical resolution than standard block characters, delivering smooth and detailed charts and data visualizations right in your terminal.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## ✨ Core Features
|
|
13
|
+
|
|
14
|
+
- **🎯 High-Resolution Rendering**: Uses Braille dot matrix characters (2×4 dots) for 8x vertical resolution
|
|
15
|
+
- **🎨 Multi-Renderer Architecture**: Auto-detects terminal capabilities, supports Braille, Block, and ASCII rendering modes
|
|
16
|
+
- **📊 Rich Component Library**: 13+ ready-to-use components covering charts, metrics, and layouts
|
|
17
|
+
- **🎭 VS Code Dark+ Theme**: Carefully designed default color scheme, beautiful and readable
|
|
18
|
+
- **📐 Responsive Layout**: Built-in Grid and Panel system for easy adaptive terminal interfaces
|
|
19
|
+
- **⚡ Smooth Animations**: Built-in data smoothing Hooks with multiple easing functions
|
|
20
|
+
- **🔧 TypeScript First**: Complete type definitions for excellent developer experience
|
|
21
|
+
- **🌈 Compatibility Guaranteed**: Auto-degrades to block characters or ASCII for universal terminal support
|
|
22
|
+
|
|
23
|
+
## 📦 Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install ink-hud ink react
|
|
27
|
+
# or with pnpm
|
|
28
|
+
pnpm add ink-hud ink react
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Requirements:**
|
|
32
|
+
- Node.js >= 18.0.0
|
|
33
|
+
- React >= 18.0.0
|
|
34
|
+
- Ink >= 4.0.0
|
|
35
|
+
|
|
36
|
+
## 🚀 Quick Start
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import React from 'react';
|
|
40
|
+
import { render } from 'ink';
|
|
41
|
+
import { LineChart } from 'ink-hud';
|
|
42
|
+
|
|
43
|
+
const App = () => {
|
|
44
|
+
const data = [
|
|
45
|
+
{ name: 'CPU', data: [12, 15, 45, 32, 60, 75, 20, 10], color: 'cyan' },
|
|
46
|
+
{ name: 'Memory', data: [40, 42, 45, 48, 40, 38, 42, 45], color: 'magenta' },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
return <LineChart series={data} width={60} height={15} />;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
render(<App />);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx tsx app.tsx
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 📊 Components
|
|
60
|
+
|
|
61
|
+
### Chart Components
|
|
62
|
+
|
|
63
|
+
#### LineChart
|
|
64
|
+
Multi-series line chart for trend analysis and time series comparison.
|
|
65
|
+
|
|
66
|
+

|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
<LineChart
|
|
70
|
+
series={[{ name: 'CPU', data: [12, 15, 45, 32], color: 'cyan' }]}
|
|
71
|
+
width={60}
|
|
72
|
+
height={15}
|
|
73
|
+
showLegend={true}
|
|
74
|
+
/>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### AreaChart
|
|
78
|
+
Stacked area chart for cumulative data and proportion trends.
|
|
79
|
+
|
|
80
|
+

|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<AreaChart
|
|
84
|
+
series={[{ name: 'Usage', data: [10, 20, 15, 25], color: 'green' }]}
|
|
85
|
+
width={60}
|
|
86
|
+
height={15}
|
|
87
|
+
/>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### BarChart
|
|
91
|
+
Vertical and horizontal bar charts for category comparison.
|
|
92
|
+
|
|
93
|
+

|
|
94
|
+

|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
<BarChart
|
|
98
|
+
series={[{ name: 'Sales', data: [100, 200, 150], color: 'blue' }]}
|
|
99
|
+
width={40}
|
|
100
|
+
height={15}
|
|
101
|
+
orientation="vertical"
|
|
102
|
+
/>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### PieChart
|
|
106
|
+
Pie chart for distribution and resource allocation visualization.
|
|
107
|
+
|
|
108
|
+

|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<PieChart
|
|
112
|
+
data={[
|
|
113
|
+
{ name: 'System', value: 30, color: 'cyan' },
|
|
114
|
+
{ name: 'Apps', value: 50, color: 'green' },
|
|
115
|
+
{ name: 'Free', value: 20, color: 'yellow' },
|
|
116
|
+
]}
|
|
117
|
+
width={30}
|
|
118
|
+
height={15}
|
|
119
|
+
/>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### Sparkline
|
|
123
|
+
Compact inline trend chart for embedded metrics.
|
|
124
|
+
|
|
125
|
+

|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<Sparkline data={[1, 4, 2, 5, 3, 6]} width={20} color="cyan" />
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### Heatmap
|
|
132
|
+
2D grid visualization for matrix data and density distribution.
|
|
133
|
+
|
|
134
|
+

|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
<Heatmap
|
|
138
|
+
data={[[0.2, 0.5, 0.8], [0.1, 0.4, 0.7], [0.3, 0.6, 0.9]]}
|
|
139
|
+
/>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Metric Components
|
|
143
|
+
|
|
144
|
+
#### BigNumber
|
|
145
|
+
Large number card for KPI display with trend indicators.
|
|
146
|
+
|
|
147
|
+

|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
<BigNumber value={125000} label="Revenue" trend={12.5} color="green" />
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Gauge
|
|
154
|
+
Circular or linear progress indicator for percentages and load.
|
|
155
|
+
|
|
156
|
+

|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<Gauge value={75} label="CPU" max={100} color="yellow" />
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Data Components
|
|
163
|
+
|
|
164
|
+
#### Table
|
|
165
|
+
Interactive sortable data table with keyboard navigation.
|
|
166
|
+
|
|
167
|
+

|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
<Table
|
|
171
|
+
data={[{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]}
|
|
172
|
+
columns={[
|
|
173
|
+
{ header: 'ID', accessor: 'id' },
|
|
174
|
+
{ header: 'Name', accessor: 'name' },
|
|
175
|
+
]}
|
|
176
|
+
zebra={true}
|
|
177
|
+
/>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### LogStream
|
|
181
|
+
Real-time scrolling log display with syntax highlighting.
|
|
182
|
+
|
|
183
|
+

|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
<LogStream
|
|
187
|
+
logs={['[INFO] Started', '[WARN] High CPU', '[ERROR] Failed']}
|
|
188
|
+
maxLines={10}
|
|
189
|
+
/>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Layout Components
|
|
193
|
+
|
|
194
|
+
#### Panel
|
|
195
|
+
Bordered container with optional title for content grouping.
|
|
196
|
+
|
|
197
|
+

|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
<Panel title="System Status" borderColor="cyan">
|
|
201
|
+
<Text>Content here</Text>
|
|
202
|
+
</Panel>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### Grid
|
|
206
|
+
Responsive grid layout system for dashboard construction.
|
|
207
|
+
|
|
208
|
+

|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
<Grid columns={3} width={120} rowHeight={10}>
|
|
212
|
+
<GridItem><Panel title="A">Content</Panel></GridItem>
|
|
213
|
+
<GridItem span={2}><Panel title="B">Wide</Panel></GridItem>
|
|
214
|
+
</Grid>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## 🎨 Renderer System
|
|
218
|
+
|
|
219
|
+
ink-hud auto-detects terminal capabilities and selects the best renderer:
|
|
220
|
+
|
|
221
|
+
| Renderer | Resolution | Characters | Best For |
|
|
222
|
+
|----------|------------|------------|----------|
|
|
223
|
+
| **Braille** | 2×4 dots, 8x vertical | `⠀⠁⠂...⣿` | Modern terminals |
|
|
224
|
+
| **Block** | 2×8 dots, 8x vertical | `▁▂▃▄▅▆▇█` | UTF-8 terminals |
|
|
225
|
+
| **ASCII** | 1×3, max compat | `_.-'"` | Legacy terminals |
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
// Force specific renderer
|
|
229
|
+
<LineChart series={data} renderer="braille" />
|
|
230
|
+
<LineChart series={data} renderer="block" />
|
|
231
|
+
<LineChart series={data} renderer="ascii" />
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## 🖥 Terminal Compatibility
|
|
235
|
+
|
|
236
|
+
| Support Level | Terminals |
|
|
237
|
+
|---------------|-----------|
|
|
238
|
+
| ✅ **Full (Braille)** | iTerm2, Warp, Alacritty, Kitty, Windows Terminal, VS Code |
|
|
239
|
+
| ⚠️ **Partial (Block)** | macOS Terminal.app, some SSH sessions |
|
|
240
|
+
| 📝 **Minimum (ASCII)** | Legacy terminals, plain text environments |
|
|
241
|
+
|
|
242
|
+
## 📚 Examples
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
git clone https://github.com/zzf2333/ink-hud.git
|
|
246
|
+
cd ink-hud
|
|
247
|
+
pnpm install
|
|
248
|
+
|
|
249
|
+
# Run complete dashboard
|
|
250
|
+
npx tsx examples/dashboard.tsx
|
|
251
|
+
|
|
252
|
+
# Run individual components
|
|
253
|
+
npx tsx examples/basic/linechart.tsx
|
|
254
|
+
npx tsx examples/basic/piechart.tsx
|
|
255
|
+
npx tsx examples/basic/table.tsx
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## 🛠 Development
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
pnpm install # Install dependencies
|
|
262
|
+
pnpm build # Build library
|
|
263
|
+
pnpm test # Run tests
|
|
264
|
+
pnpm lint # Lint code
|
|
265
|
+
pnpm typecheck # Type check
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## 📖 Documentation
|
|
269
|
+
|
|
270
|
+
- [Component API Reference](./docs/api.md)
|
|
271
|
+
- [Component Usage Guide](./docs/components.md)
|
|
272
|
+
- [Getting Started Tutorial](./docs/getting-started.md)
|
|
273
|
+
|
|
274
|
+
## 🤝 Contributing
|
|
275
|
+
|
|
276
|
+
Contributions welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
|
|
277
|
+
|
|
278
|
+
## 📄 License
|
|
279
|
+
|
|
280
|
+
MIT © [saonian](https://github.com/zzf2333)
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
**If this project helps you, please give it a ⭐️!**
|