@zakmandhro/bunti 0.1.5 → 0.2.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/AGENTS.md +65 -0
- package/README.md +81 -11
- package/dist/cli.d.ts +44 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +147 -0
- package/dist/cli.js.map +1 -0
- package/dist/colors.d.ts +77 -7
- package/dist/colors.d.ts.map +1 -1
- package/dist/colors.js +238 -39
- package/dist/colors.js.map +1 -1
- package/dist/components/Box.d.ts +6 -0
- package/dist/components/Box.d.ts.map +1 -1
- package/dist/components/Box.js +5 -0
- package/dist/components/Box.js.map +1 -1
- package/dist/components/Button.d.ts +12 -2
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +35 -24
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.d.ts +24 -2
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/Card.js +56 -14
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Header.d.ts +11 -1
- package/dist/components/Header.d.ts.map +1 -1
- package/dist/components/Header.js +12 -8
- package/dist/components/Header.js.map +1 -1
- package/dist/components/Input.d.ts +10 -1
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +172 -41
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Link.d.ts +21 -0
- package/dist/components/Link.d.ts.map +1 -0
- package/dist/components/Link.js +29 -0
- package/dist/components/Link.js.map +1 -0
- package/dist/components/Modal.d.ts +25 -0
- package/dist/components/Modal.d.ts.map +1 -1
- package/dist/components/Modal.js +83 -24
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/Progress.d.ts +27 -0
- package/dist/components/Progress.d.ts.map +1 -0
- package/dist/components/Progress.js +39 -0
- package/dist/components/Progress.js.map +1 -0
- package/dist/components/Spinner.d.ts +19 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +27 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -0
- package/dist/components/index.js.map +1 -1
- package/dist/data/nf-glyphs.d.ts +11 -0
- package/dist/data/nf-glyphs.d.ts.map +1 -0
- package/dist/data/nf-glyphs.js +535 -0
- package/dist/data/nf-glyphs.js.map +1 -0
- package/dist/data/nf-names.d.ts +8 -0
- package/dist/data/nf-names.d.ts.map +1 -0
- package/dist/data/nf-names.js +2 -0
- package/dist/data/nf-names.js.map +1 -0
- package/dist/demo-registry.d.ts +27 -0
- package/dist/demo-registry.d.ts.map +1 -0
- package/dist/demo-registry.js +57 -0
- package/dist/demo-registry.js.map +1 -0
- package/dist/demos/2048.ts +743 -0
- package/dist/demos/animation.ts +246 -0
- package/dist/demos/demo-layout.ts +124 -0
- package/dist/demos/engine.ts +374 -0
- package/dist/demos/interaction.ts +91 -0
- package/dist/demos/login.ts +203 -0
- package/dist/demos/mission-control.ts +558 -0
- package/dist/demos/showcase.ts +224 -0
- package/dist/detect.d.ts +92 -3
- package/dist/detect.d.ts.map +1 -1
- package/dist/detect.js +218 -40
- package/dist/detect.js.map +1 -1
- package/dist/diagnostics.d.ts +73 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +225 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/dsl/context.d.ts +11 -0
- package/dist/dsl/context.d.ts.map +1 -0
- package/dist/dsl/context.js +563 -0
- package/dist/dsl/context.js.map +1 -0
- package/dist/dsl/hooks.d.ts +12 -0
- package/dist/dsl/hooks.d.ts.map +1 -0
- package/dist/dsl/hooks.js +148 -0
- package/dist/dsl/hooks.js.map +1 -0
- package/dist/dsl/interaction.d.ts +16 -0
- package/dist/dsl/interaction.d.ts.map +1 -0
- package/dist/dsl/interaction.js +101 -0
- package/dist/dsl/interaction.js.map +1 -0
- package/dist/dsl/layers.d.ts +14 -0
- package/dist/dsl/layers.d.ts.map +1 -0
- package/dist/dsl/layers.js +87 -0
- package/dist/dsl/layers.js.map +1 -0
- package/dist/dsl/motion.d.ts +10 -0
- package/dist/dsl/motion.d.ts.map +1 -0
- package/dist/dsl/motion.js +150 -0
- package/dist/dsl/motion.js.map +1 -0
- package/dist/dsl/render.d.ts +22 -0
- package/dist/dsl/render.d.ts.map +1 -0
- package/dist/dsl/render.js +69 -0
- package/dist/dsl/render.js.map +1 -0
- package/dist/dsl/types.d.ts +510 -0
- package/dist/dsl/types.d.ts.map +1 -0
- package/dist/dsl/types.js +33 -0
- package/dist/dsl/types.js.map +1 -0
- package/dist/dsl.d.ts +13 -154
- package/dist/dsl.d.ts.map +1 -1
- package/dist/dsl.js +12 -658
- package/dist/dsl.js.map +1 -1
- package/dist/easing.d.ts +41 -1
- package/dist/easing.d.ts.map +1 -1
- package/dist/easing.js +105 -2
- package/dist/easing.js.map +1 -1
- package/dist/geometry.d.ts +39 -0
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +20 -0
- package/dist/geometry.js.map +1 -1
- package/dist/icons-full.d.ts +5 -0
- package/dist/icons-full.d.ts.map +1 -0
- package/dist/icons-full.js +31 -0
- package/dist/icons-full.js.map +1 -0
- package/dist/icons.d.ts +426 -5
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +144 -15
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +93 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +177 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +533 -0
- package/dist/input.js.map +1 -0
- package/dist/layout.d.ts +111 -6
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +163 -23
- package/dist/layout.js.map +1 -1
- package/dist/render.d.ts +33 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +431 -116
- package/dist/render.js.map +1 -1
- package/dist/state.d.ts +137 -3
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +25 -0
- package/dist/state.js.map +1 -1
- package/dist/theme.d.ts +129 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +167 -0
- package/dist/theme.js.map +1 -0
- package/dist/themes/catppuccin-mocha.d.ts +19 -0
- package/dist/themes/catppuccin-mocha.d.ts.map +1 -0
- package/dist/themes/catppuccin-mocha.js +36 -0
- package/dist/themes/catppuccin-mocha.js.map +1 -0
- package/dist/themes/dracula.d.ts +21 -0
- package/dist/themes/dracula.d.ts.map +1 -0
- package/dist/themes/dracula.js +37 -0
- package/dist/themes/dracula.js.map +1 -0
- package/dist/themes/github-light.d.ts +21 -0
- package/dist/themes/github-light.d.ts.map +1 -0
- package/dist/themes/github-light.js +36 -0
- package/dist/themes/github-light.js.map +1 -0
- package/dist/themes/index.d.ts +19 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/index.js +17 -0
- package/dist/themes/index.js.map +1 -0
- package/dist/themes/nord.d.ts +23 -0
- package/dist/themes/nord.d.ts.map +1 -0
- package/dist/themes/nord.js +38 -0
- package/dist/themes/nord.js.map +1 -0
- package/dist/themes/one-dark-pro.d.ts +21 -0
- package/dist/themes/one-dark-pro.d.ts.map +1 -0
- package/dist/themes/one-dark-pro.js +36 -0
- package/dist/themes/one-dark-pro.js.map +1 -0
- package/dist/themes/tokyo-night.d.ts +20 -0
- package/dist/themes/tokyo-night.d.ts.map +1 -0
- package/dist/themes/tokyo-night.js +37 -0
- package/dist/themes/tokyo-night.js.map +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -0
- package/dist/utils.js.map +1 -1
- package/dist/vendor/colors.d.ts +45 -0
- package/dist/vendor/colors.d.ts.map +1 -0
- package/dist/vendor/colors.js +72 -0
- package/dist/vendor/colors.js.map +1 -0
- package/llms.txt +79 -0
- package/package.json +23 -7
- package/dist/data/glyphs.d.ts +0 -5
- package/dist/data/glyphs.d.ts.map +0 -1
- package/dist/data/glyphs.js +0 -29
- package/dist/data/glyphs.js.map +0 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
How to build good terminal apps with Bunti. The API itself is documented
|
|
4
|
+
where you'll actually read it — JSDoc in the package's `dist/*.d.ts` and
|
|
5
|
+
the quick reference in `llms.txt`; dev-mode hints on stderr catch the
|
|
6
|
+
common wiring mistakes. This file covers what types can't: layout taste
|
|
7
|
+
and app structure.
|
|
8
|
+
|
|
9
|
+
Start from `examples/starter.ts` in the repo — it is the shape most
|
|
10
|
+
dashboards want (header bar, `ctx.split` tracks, keyboard selection,
|
|
11
|
+
themed panels).
|
|
12
|
+
|
|
13
|
+
## Not React
|
|
14
|
+
|
|
15
|
+
Bunti is immediate mode: the render callback redraws the whole frame
|
|
16
|
+
from state and Bunti flushes only the terminal diff. Do not build
|
|
17
|
+
component trees, providers, reducers, or reconciliation-style
|
|
18
|
+
abstractions unless the user explicitly asks. Build the screen directly
|
|
19
|
+
with `ctx` primitives; keep domain logic in plain TypeScript functions
|
|
20
|
+
outside the render callback.
|
|
21
|
+
|
|
22
|
+
## Layout model
|
|
23
|
+
|
|
24
|
+
- Everything is a cell rect. `x`/`y` are local to the current context:
|
|
25
|
+
the whole screen at the root, the padded interior inside a `box()`.
|
|
26
|
+
Use `ctx.offsetX`/`ctx.offsetY` to convert local to absolute when
|
|
27
|
+
drawing with `rect()`/`blit()`.
|
|
28
|
+
- Root-level `box()` paints directly to the screen and **centers**
|
|
29
|
+
itself unless you pass `x`/`y`. Nested boxes join the parent's text
|
|
30
|
+
flow. Both return the rendered string.
|
|
31
|
+
- Carve screens with `ctx.split({ direction, constraints: [24, '1fr'] })`
|
|
32
|
+
and draw one box per track — don't hand-compute column math.
|
|
33
|
+
- Terminal cells are taller than wide: a 1-row vertical gap balances a
|
|
34
|
+
2-column horizontal gap, and `padding: [1, 2]` looks square-ish.
|
|
35
|
+
- Name repeated dimensions (`SIDEBAR_W`, `ROW_H`, `GAP_X`) instead of
|
|
36
|
+
scattering magic numbers.
|
|
37
|
+
- Prefer `border: 'none'` for dense canvases and work surfaces; borders
|
|
38
|
+
are a design choice, not a default.
|
|
39
|
+
|
|
40
|
+
## App patterns
|
|
41
|
+
|
|
42
|
+
- `useState(key, initial)` for view state; `usePersistentState` only
|
|
43
|
+
for values that must survive restarts; `useAsync(key, fetcher,
|
|
44
|
+
{ interval })` for data — never block the render loop.
|
|
45
|
+
- Components (`Card`, `Button`, `Input`, `Modal`, ...) for common
|
|
46
|
+
controls; direct `rect()`/`blit()` for dense dashboards, charts,
|
|
47
|
+
maps, and canvas-like regions.
|
|
48
|
+
- `ctx.layer()` for command palettes, confirmations, notifications, and
|
|
49
|
+
HUDs — anything that overlaps other content. Draw order alone does
|
|
50
|
+
not stack.
|
|
51
|
+
- Style from `ctx.theme` tokens (`theme.surface`, `theme.primary`,
|
|
52
|
+
`theme.muted`, ...) rather than hardcoded colors, so live theme swaps
|
|
53
|
+
and the built-in presets keep working.
|
|
54
|
+
- Animate on time, not frame count: `ctx.animate`/`ctx.transition`/
|
|
55
|
+
`ctx.dt`. UI transitions feel right around 150-250ms. Prefer stable
|
|
56
|
+
geometry with color/brightness interpolation over adding/removing
|
|
57
|
+
cells step-by-step.
|
|
58
|
+
|
|
59
|
+
## Before handing code to the user
|
|
60
|
+
|
|
61
|
+
- Import from `@zakmandhro/bunti`, never repo-relative paths.
|
|
62
|
+
- Run it if possible. It renders to pipes, but keyboard input needs a
|
|
63
|
+
real PTY — see the "Agent & CI testing" section of the README for a
|
|
64
|
+
copy-paste PTY harness.
|
|
65
|
+
- Remove debug/preview state and fix TypeScript errors first.
|
package/README.md
CHANGED
|
@@ -16,17 +16,13 @@ Bunti (pronounced *Bun-ty*) is a zero-dependency, double-buffered layout engine
|
|
|
16
16
|
|
|
17
17
|
## 📦 Installation
|
|
18
18
|
|
|
19
|
-
Bunti is Bun-
|
|
19
|
+
Bunti is Bun-native and ships compiled ESM plus TypeScript declarations — with zero runtime dependencies.
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
bun add @zakmandhro/bunti
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm install @zakmandhro/bunti
|
|
29
|
-
```
|
|
25
|
+
> Bunti requires the [Bun](https://bun.sh) runtime (>= 1.0). It uses Bun-native APIs for rendering, so Node.js is not supported.
|
|
30
26
|
|
|
31
27
|
## 🚀 Quick Start
|
|
32
28
|
|
|
@@ -67,7 +63,24 @@ bunti.render((ctx) => {
|
|
|
67
63
|
|
|
68
64
|
## 📏 Layout Model
|
|
69
65
|
|
|
70
|
-
|
|
66
|
+
Everything is a cell rect, and coordinates are **local to the current
|
|
67
|
+
context**: the whole screen at the root, the padded interior inside a
|
|
68
|
+
`box()`. A root-level `box()` paints directly into the screen buffer and
|
|
69
|
+
**centers itself** unless you pass `x`/`y`; a nested `box()` joins its
|
|
70
|
+
parent's text flow instead. Every drawing call also *returns* the rendered
|
|
71
|
+
string, so you can compose with `joinHorizontal`/`joinVertical` or place
|
|
72
|
+
output manually. Carve responsive layouts with tracks instead of column
|
|
73
|
+
math:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
const [sidebar, main] = ctx.split({
|
|
77
|
+
direction: 'horizontal',
|
|
78
|
+
constraints: [24, '1fr'], // cells, percentages, and fr fill units
|
|
79
|
+
});
|
|
80
|
+
ctx.box({ x: sidebar.x, y: 2, width: sidebar.width, border: 'rounded' }, drawNav);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Under the hood it is Rect-first:
|
|
71
84
|
|
|
72
85
|
- `Rect` is the geometry primitive.
|
|
73
86
|
- `Box`, `Button`, `Input`, `Card`, and `Header` resolve a rect before rendering.
|
|
@@ -75,6 +88,10 @@ Bunti's public layout direction is Rect-first:
|
|
|
75
88
|
- `splitRect()` and `ctx.split()` create responsive tracks from fixed sizes, percentages, and `fr` fill units.
|
|
76
89
|
- `ctx.resolveLocalRect()` places components within the current parent area, including left/center/right and top/center/bottom defaults.
|
|
77
90
|
|
|
91
|
+
A complete, runnable dashboard template lives at
|
|
92
|
+
[`examples/starter.ts`](./examples/starter.ts) — copy it as your app's
|
|
93
|
+
starting point.
|
|
94
|
+
|
|
78
95
|
## 📐 Border Archetypes
|
|
79
96
|
|
|
80
97
|
Bunti categorizes containers into three visual archetypes:
|
|
@@ -89,6 +106,50 @@ Bunti categorizes containers into three visual archetypes:
|
|
|
89
106
|
|
|
90
107
|
Bunti is built for speed. By leveraging `Bun.stdout.writer()` and surgical diffing, it can maintain **60-120 FPS** on complex layouts while keeping TTY bytes significantly lower than standard stream-based libraries.
|
|
91
108
|
|
|
109
|
+
## 🤖 Agent & CI testing
|
|
110
|
+
|
|
111
|
+
Bunti renders fine to plain pipes — `bun app.ts | cat` produces real ANSI
|
|
112
|
+
frames, so screenshot-style assertions work anywhere. **Keyboard input is
|
|
113
|
+
different: it needs a real TTY.** When stdin is a pipe (CI, agent
|
|
114
|
+
harnesses, `echo q | bun app.ts`), raw-mode input is never attached and
|
|
115
|
+
keys are silently ignored — Bunti prints a dev hint to stderr on exit when
|
|
116
|
+
this happens (silence hints with `BUNTI_NO_HINTS=1`).
|
|
117
|
+
|
|
118
|
+
To drive keyboard input headlessly, wrap the run in a PTY. On macOS and
|
|
119
|
+
Linux, `script` is the zero-dependency way — mind the argument-order trap:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# macOS: the transcript file comes BEFORE the command.
|
|
123
|
+
(sleep 2; printf 'q') | script -q /dev/null bun app.ts
|
|
124
|
+
|
|
125
|
+
# Linux (util-linux script): the command is passed via -c.
|
|
126
|
+
(sleep 2; printf 'q') | script -qec "bun app.ts" /dev/null
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Using the Linux syntax on macOS (`script -q bun app.ts`) does not run your
|
|
130
|
+
app — it clobbers a file literally named `bun` with the session transcript
|
|
131
|
+
and drops you into an interactive shell.
|
|
132
|
+
|
|
133
|
+
A copy-paste PTY smoke test (spawn, send a key, assert clean exit):
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
// pty-test.ts — bun pty-test.ts
|
|
137
|
+
const proc = Bun.spawn(
|
|
138
|
+
['script', '-q', '/dev/null', 'bun', 'app.ts'], // macOS arg order
|
|
139
|
+
{ stdin: 'pipe', stdout: 'pipe', stderr: 'inherit' },
|
|
140
|
+
);
|
|
141
|
+
await Bun.sleep(2000); // let it render a few frames
|
|
142
|
+
proc.stdin.write('q'); // your app's quit key
|
|
143
|
+
proc.stdin.end();
|
|
144
|
+
const code = await proc.exited;
|
|
145
|
+
const frames = await new Response(proc.stdout).text();
|
|
146
|
+
if (code !== 0 || !frames.includes('MISSION CONTROL')) process.exit(1);
|
|
147
|
+
console.log('PTY smoke test passed');
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
For pure rendering checks, skip the PTY entirely: `render(cb, { once:
|
|
151
|
+
true })` draws one frame and returns.
|
|
152
|
+
|
|
92
153
|
## 🎮 Demos
|
|
93
154
|
|
|
94
155
|
Run a public demo:
|
|
@@ -121,11 +182,20 @@ npm pack --dry-run
|
|
|
121
182
|
|
|
122
183
|
## 📚 Documentation
|
|
123
184
|
|
|
124
|
-
Dive deeper into Bunti's architecture and layout engine
|
|
185
|
+
Dive deeper into Bunti's architecture and layout engine at
|
|
186
|
+
[zakmandhro.github.io/bunti](https://zakmandhro.github.io/bunti/):
|
|
187
|
+
|
|
188
|
+
- [The Box Model & Layout Math](https://zakmandhro.github.io/bunti/layout.html)
|
|
189
|
+
- [Bunti Components & Primitives](https://zakmandhro.github.io/bunti/components.html)
|
|
190
|
+
- [Theming & Colors](https://zakmandhro.github.io/bunti/theming.html)
|
|
191
|
+
- [Animations & Canvas](https://zakmandhro.github.io/bunti/animations.html)
|
|
192
|
+
- [Engine & Utilities](https://zakmandhro.github.io/bunti/engine.html)
|
|
193
|
+
- [Bunti vs. The TUI Ecosystem](https://zakmandhro.github.io/bunti/comparison.html)
|
|
125
194
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
195
|
+
The package also ships [`AGENTS.md`](./AGENTS.md) (agent playbook) and
|
|
196
|
+
[`llms.txt`](./llms.txt) (compact API reference, generated from the JSDoc
|
|
197
|
+
by `bun scripts/gen-llms.ts`) — the full documented API lives in the
|
|
198
|
+
shipped `dist/*.d.ts`.
|
|
129
199
|
|
|
130
200
|
## 🤝 Contributing
|
|
131
201
|
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* The `bunti` CLI — the zero-install front door:
|
|
4
|
+
*
|
|
5
|
+
* bunx @zakmandhro/bunti demo list the public demos
|
|
6
|
+
* bunx @zakmandhro/bunti demo mission-control run one
|
|
7
|
+
* bunx @zakmandhro/bunti doctor terminal capability report
|
|
8
|
+
* bunx @zakmandhro/bunti --version
|
|
9
|
+
*
|
|
10
|
+
* Demos are plain Bun-runnable TypeScript copied into dist/demos/ at build
|
|
11
|
+
* time (see scripts/build-demos.ts); `demo <name>` simply imports one, which
|
|
12
|
+
* starts its render loop in-process.
|
|
13
|
+
*/
|
|
14
|
+
import { type ColorTier, type TerminalProfile } from './detect';
|
|
15
|
+
export type CliCommand = {
|
|
16
|
+
cmd: 'help';
|
|
17
|
+
} | {
|
|
18
|
+
cmd: 'version';
|
|
19
|
+
} | {
|
|
20
|
+
cmd: 'doctor';
|
|
21
|
+
} | {
|
|
22
|
+
cmd: 'list-demos';
|
|
23
|
+
} | {
|
|
24
|
+
cmd: 'run-demo';
|
|
25
|
+
name: string;
|
|
26
|
+
} | {
|
|
27
|
+
cmd: 'unknown-demo';
|
|
28
|
+
name: string;
|
|
29
|
+
} | {
|
|
30
|
+
cmd: 'unknown';
|
|
31
|
+
arg: string;
|
|
32
|
+
};
|
|
33
|
+
/** Pure argv parser (argv excludes the runtime + script entries). */
|
|
34
|
+
export declare function parseCliArgs(argv: string[]): CliCommand;
|
|
35
|
+
/** `name description` listing lines for the public demos. */
|
|
36
|
+
export declare function demoListLines(): string[];
|
|
37
|
+
export declare function helpText(version: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* The `bunti doctor` report: env-detected terminal profile, color tier, and
|
|
40
|
+
* the Nerd Font policy driving the icon engine. Pure function of its inputs
|
|
41
|
+
* so tests can pin the exact shape.
|
|
42
|
+
*/
|
|
43
|
+
export declare function doctorReport(profile: TerminalProfile, tier: ColorTier, version: string, bunVersion: string): string[];
|
|
44
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;AAGH,OAAO,EACL,KAAK,SAAS,EAGd,KAAK,eAAe,EACrB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,UAAU,GAClB;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GACf;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAClB;IAAE,GAAG,EAAE,QAAQ,CAAA;CAAE,GACjB;IAAE,GAAG,EAAE,YAAY,CAAA;CAAE,GACrB;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,GAAG,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpC,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAoBvD;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,IAAI,MAAM,EAAE,CAGxC;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAehD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAgCV"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* The `bunti` CLI — the zero-install front door:
|
|
4
|
+
*
|
|
5
|
+
* bunx @zakmandhro/bunti demo list the public demos
|
|
6
|
+
* bunx @zakmandhro/bunti demo mission-control run one
|
|
7
|
+
* bunx @zakmandhro/bunti doctor terminal capability report
|
|
8
|
+
* bunx @zakmandhro/bunti --version
|
|
9
|
+
*
|
|
10
|
+
* Demos are plain Bun-runnable TypeScript copied into dist/demos/ at build
|
|
11
|
+
* time (see scripts/build-demos.ts); `demo <name>` simply imports one, which
|
|
12
|
+
* starts its render loop in-process.
|
|
13
|
+
*/
|
|
14
|
+
import { findDemo, PUBLIC_DEMOS } from './demo-registry';
|
|
15
|
+
import { detectColorTier, identifyTerminal, } from './detect';
|
|
16
|
+
/** Pure argv parser (argv excludes the runtime + script entries). */
|
|
17
|
+
export function parseCliArgs(argv) {
|
|
18
|
+
const [first, second] = argv;
|
|
19
|
+
if (first === undefined ||
|
|
20
|
+
first === 'help' ||
|
|
21
|
+
first === '--help' ||
|
|
22
|
+
first === '-h') {
|
|
23
|
+
return { cmd: 'help' };
|
|
24
|
+
}
|
|
25
|
+
if (first === 'version' || first === '--version' || first === '-v') {
|
|
26
|
+
return { cmd: 'version' };
|
|
27
|
+
}
|
|
28
|
+
if (first === 'doctor')
|
|
29
|
+
return { cmd: 'doctor' };
|
|
30
|
+
if (first === 'demo') {
|
|
31
|
+
if (second === undefined)
|
|
32
|
+
return { cmd: 'list-demos' };
|
|
33
|
+
if (findDemo(second))
|
|
34
|
+
return { cmd: 'run-demo', name: second };
|
|
35
|
+
return { cmd: 'unknown-demo', name: second };
|
|
36
|
+
}
|
|
37
|
+
return { cmd: 'unknown', arg: first };
|
|
38
|
+
}
|
|
39
|
+
/** `name description` listing lines for the public demos. */
|
|
40
|
+
export function demoListLines() {
|
|
41
|
+
const pad = Math.max(...PUBLIC_DEMOS.map((d) => d.name.length)) + 2;
|
|
42
|
+
return PUBLIC_DEMOS.map((d) => ` ${d.name.padEnd(pad)}${d.description}`);
|
|
43
|
+
}
|
|
44
|
+
export function helpText(version) {
|
|
45
|
+
return [
|
|
46
|
+
`bunti v${version} — Bun-native terminal UI engine`,
|
|
47
|
+
'',
|
|
48
|
+
'Usage:',
|
|
49
|
+
' bunti demo list the public demos',
|
|
50
|
+
' bunti demo <name> run a demo',
|
|
51
|
+
' bunti doctor terminal capability report',
|
|
52
|
+
' bunti --version print the version',
|
|
53
|
+
'',
|
|
54
|
+
'Demos:',
|
|
55
|
+
...demoListLines(),
|
|
56
|
+
'',
|
|
57
|
+
'Zero-install: bunx @zakmandhro/bunti demo mission-control',
|
|
58
|
+
].join('\n');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The `bunti doctor` report: env-detected terminal profile, color tier, and
|
|
62
|
+
* the Nerd Font policy driving the icon engine. Pure function of its inputs
|
|
63
|
+
* so tests can pin the exact shape.
|
|
64
|
+
*/
|
|
65
|
+
export function doctorReport(profile, tier, version, bunVersion) {
|
|
66
|
+
const terminal = profile.app === 'unknown'
|
|
67
|
+
? 'unknown'
|
|
68
|
+
: `${profile.app}${profile.version ? ` ${profile.version}` : ''}`;
|
|
69
|
+
const tierLabel = tier === 'truecolor'
|
|
70
|
+
? 'truecolor (24-bit)'
|
|
71
|
+
: tier === '256'
|
|
72
|
+
? '256 colors'
|
|
73
|
+
: tier === '16'
|
|
74
|
+
? '16 colors'
|
|
75
|
+
: 'monochrome';
|
|
76
|
+
const nf = {
|
|
77
|
+
yes: 'yes - glyphs enabled',
|
|
78
|
+
'assumed-yes': 'assumed yes - glyphs enabled',
|
|
79
|
+
'assumed-no': 'assumed no - ascii fallback',
|
|
80
|
+
no: 'no - ascii fallback',
|
|
81
|
+
};
|
|
82
|
+
const lines = [
|
|
83
|
+
`bunti v${version} (bun ${bunVersion})`,
|
|
84
|
+
`terminal ${terminal}`,
|
|
85
|
+
];
|
|
86
|
+
if (profile.multiplexer)
|
|
87
|
+
lines.push(`multiplexer ${profile.multiplexer}`);
|
|
88
|
+
lines.push(`colors ${tierLabel}`, `sync output ${profile.syncOutput ? 'yes (mode 2026)' : 'no'}`, `nerd font ${nf[profile.nerdFont]}${profile.source === 'override' ? ' (env override)' : ''}`);
|
|
89
|
+
return lines;
|
|
90
|
+
}
|
|
91
|
+
async function packageVersion() {
|
|
92
|
+
try {
|
|
93
|
+
const pkg = await Bun.file(new URL('../package.json', import.meta.url)).json();
|
|
94
|
+
return typeof pkg.version === 'string' ? pkg.version : 'unknown';
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return 'unknown';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function runDemo(file) {
|
|
101
|
+
// Published layout: dist/cli.js + dist/demos/*.ts. Dev layout (running
|
|
102
|
+
// src/cli.ts directly): ../demo/*.ts. Prefer the packaged copy.
|
|
103
|
+
const packaged = new URL(`./demos/${file}`, import.meta.url);
|
|
104
|
+
const dev = new URL(`../demo/${file}`, import.meta.url);
|
|
105
|
+
const target = (await Bun.file(packaged).exists()) ? packaged : dev;
|
|
106
|
+
await import(target.href);
|
|
107
|
+
}
|
|
108
|
+
async function main() {
|
|
109
|
+
const command = parseCliArgs(process.argv.slice(2));
|
|
110
|
+
switch (command.cmd) {
|
|
111
|
+
case 'help':
|
|
112
|
+
console.log(helpText(await packageVersion()));
|
|
113
|
+
return;
|
|
114
|
+
case 'version':
|
|
115
|
+
console.log(await packageVersion());
|
|
116
|
+
return;
|
|
117
|
+
case 'doctor': {
|
|
118
|
+
const report = doctorReport(identifyTerminal(), detectColorTier(), await packageVersion(), Bun.version);
|
|
119
|
+
console.log(report.join('\n'));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
case 'list-demos':
|
|
123
|
+
console.log('Public demos:\n');
|
|
124
|
+
console.log(demoListLines().join('\n'));
|
|
125
|
+
console.log('\nRun one: bunti demo <name>');
|
|
126
|
+
return;
|
|
127
|
+
case 'run-demo': {
|
|
128
|
+
const entry = findDemo(command.name);
|
|
129
|
+
if (entry)
|
|
130
|
+
await runDemo(entry.file);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
case 'unknown-demo':
|
|
134
|
+
console.error(`Unknown demo "${command.name}". Available demos:\n`);
|
|
135
|
+
console.error(demoListLines().join('\n'));
|
|
136
|
+
process.exitCode = 1;
|
|
137
|
+
return;
|
|
138
|
+
case 'unknown':
|
|
139
|
+
console.error(`Unknown command "${command.arg}". Try: bunti --help`);
|
|
140
|
+
process.exitCode = 1;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (import.meta.main) {
|
|
145
|
+
await main();
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAEL,eAAe,EACf,gBAAgB,GAEjB,MAAM,UAAU,CAAC;AAWlB,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAC7B,IACE,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,MAAM;QAChB,KAAK,KAAK,QAAQ;QAClB,KAAK,KAAK,IAAI,EACd,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IACzB,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,EA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Semantic & Palette Color System
|
|
3
3
|
*/
|
|
4
4
|
import type { RGB } from './state';
|
|
5
|
+
import type { ThemeColor } from './theme';
|
|
6
|
+
/**
|
|
7
|
+
* A resolved multi-stop gradient, accepted anywhere bgColor is (rect fills,
|
|
8
|
+
* box backgrounds, wallpaper). Build one with ctx.gradient().
|
|
9
|
+
*/
|
|
5
10
|
export interface Gradient {
|
|
11
|
+
/** Interpolated RGB stops, one per step. */
|
|
6
12
|
colors: RGB[];
|
|
13
|
+
/** Axis the stops sweep along. */
|
|
7
14
|
direction: 'vertical' | 'horizontal';
|
|
15
|
+
/** Number of interpolated stops. */
|
|
8
16
|
steps: number;
|
|
9
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Any value Bunti accepts where a color is expected.
|
|
20
|
+
*/
|
|
21
|
+
export type ColorValue = string | number | RGB | ThemeColor;
|
|
22
|
+
/**
|
|
23
|
+
* Internal brand carried by ThemeColor instances so callable theme tokens can
|
|
24
|
+
* be distinguished from plain function-style border wrappers.
|
|
25
|
+
*/
|
|
26
|
+
export declare const THEME_COLOR: unique symbol;
|
|
27
|
+
/**
|
|
28
|
+
* Returns true when the value is a ThemeColor (callable fg-styler carrying
|
|
29
|
+
* `.rgb` and `.hex`), detected via the internal brand symbol.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isThemeColor(value: unknown): value is ThemeColor;
|
|
32
|
+
/**
|
|
33
|
+
* Bunti's named color palette (ANSI-256 codes). Any name here works as a
|
|
34
|
+
* color value: `fg('bunti-blue', text)`, `{ bgColor: 'midnight' }`.
|
|
35
|
+
*/
|
|
10
36
|
export declare const PALETTE: {
|
|
11
37
|
readonly slate: "235";
|
|
12
38
|
readonly ash: "240";
|
|
@@ -31,17 +57,54 @@ export declare const PALETTE: {
|
|
|
31
57
|
};
|
|
32
58
|
export type PaletteColor = keyof typeof PALETTE;
|
|
33
59
|
/**
|
|
34
|
-
* Parses a hex color string (#RRGGBB or #
|
|
60
|
+
* Parses a hex color string (#RGB, #RGBA, #RRGGBB, or #RRGGBBAA) to an RGB
|
|
61
|
+
* object. Alpha channels are composited over `base` (defaults to black), so
|
|
62
|
+
* `#ffffff80` over black resolves to mid-gray.
|
|
63
|
+
*/
|
|
64
|
+
export declare function hexToRGB(hex: string, base?: RGB): RGB;
|
|
65
|
+
/**
|
|
66
|
+
* Formats an RGB object as a #rrggbb hex string.
|
|
67
|
+
*/
|
|
68
|
+
export declare function rgbToHex(rgb: RGB): string;
|
|
69
|
+
/**
|
|
70
|
+
* Converts an ANSI-256 code to its exact xterm RGB value
|
|
71
|
+
* (16 base + 6x6x6 color cube + 24-step gray ramp).
|
|
72
|
+
*/
|
|
73
|
+
export declare function ansi256ToRGB(code: number): RGB;
|
|
74
|
+
/**
|
|
75
|
+
* Quantizes an RGB value to the nearest ANSI-256 code
|
|
76
|
+
* (best of the 6x6x6 cube vs the gray ramp).
|
|
35
77
|
*/
|
|
36
|
-
export declare function
|
|
78
|
+
export declare function rgbTo256(rgb: RGB): number;
|
|
37
79
|
/**
|
|
38
|
-
*
|
|
80
|
+
* Quantizes an RGB value to the nearest of the 16 base ANSI colors.
|
|
39
81
|
*/
|
|
40
|
-
export declare function
|
|
82
|
+
export declare function rgbTo16(rgb: RGB): number;
|
|
83
|
+
/**
|
|
84
|
+
* Resolves a palette name, color code, RGB object, or ThemeColor to an ANSI
|
|
85
|
+
* color code, quantized to the active color tier. Returns undefined on the
|
|
86
|
+
* 'mono' tier (NO_COLOR), which suppresses color output entirely.
|
|
87
|
+
*/
|
|
88
|
+
export declare function resolveColor(color: PaletteColor | ColorValue): string | number | undefined;
|
|
41
89
|
/**
|
|
42
90
|
* Creates a multi-stop gradient (array of RGB objects) between multiple colors.
|
|
43
91
|
*/
|
|
44
|
-
export declare function createGradient(arg1:
|
|
92
|
+
export declare function createGradient(arg1: ColorValue[] | ColorValue, arg2?: ColorValue | number, arg3?: number): RGB[];
|
|
93
|
+
/**
|
|
94
|
+
* Resolves any color value (name, hex, ANSI-256 code, RGB, ThemeColor) to an
|
|
95
|
+
* exact RGB object. Numeric codes use the exact xterm 256-color table.
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolveColorToRGB(color: unknown): RGB;
|
|
98
|
+
/**
|
|
99
|
+
* WCAG 2.x relative luminance (0 = black, 1 = white) of any color value.
|
|
100
|
+
*/
|
|
101
|
+
export declare function relativeLuminance(color: ColorValue): number;
|
|
102
|
+
/**
|
|
103
|
+
* Picks pure black or pure white text for maximum WCAG contrast against the
|
|
104
|
+
* given background color. (White wins below luminance ~0.179, the point where
|
|
105
|
+
* both contrast ratios are equal.)
|
|
106
|
+
*/
|
|
107
|
+
export declare function contrastText(bgColor: ColorValue): RGB;
|
|
45
108
|
/**
|
|
46
109
|
* Adjusts the brightness of a color.
|
|
47
110
|
*/
|
|
@@ -49,7 +112,7 @@ export declare function adjustBrightness(color: any, amount: number): RGB;
|
|
|
49
112
|
/**
|
|
50
113
|
* Interpolates between two colors and returns an RGB value.
|
|
51
114
|
*/
|
|
52
|
-
export declare function fade(from:
|
|
115
|
+
export declare function fade(from: ColorValue, to: ColorValue, progress: number): RGB;
|
|
53
116
|
/**
|
|
54
117
|
* Returns a function that darkens a color and can be used as a style wrapper.
|
|
55
118
|
*/
|
|
@@ -67,8 +130,15 @@ export declare function rgb(r: number, g: number, b: number): {
|
|
|
67
130
|
b: number;
|
|
68
131
|
};
|
|
69
132
|
/**
|
|
70
|
-
*
|
|
133
|
+
* Wraps text in a foreground-color ANSI sequence (any color value:
|
|
134
|
+
* palette name, hex, ANSI-256 code, RGB, ThemeColor). On the 'mono' tier
|
|
135
|
+
* the text is returned unstyled.
|
|
136
|
+
* @example fg('#3bbce1', 'hello') // truecolor cyan text
|
|
71
137
|
*/
|
|
72
138
|
export declare function fg(color: any, text: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Wraps text in a background-color ANSI sequence (any color value). On the
|
|
141
|
+
* 'mono' tier the text is returned unstyled.
|
|
142
|
+
*/
|
|
73
143
|
export declare function bg(color: any, text: string): string;
|
|
74
144
|
//# sourceMappingURL=colors.d.ts.map
|
package/dist/colors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,4CAA4C;IAC5C,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,kCAAkC;IAClC,SAAS,EAAE,UAAU,GAAG,YAAY,CAAC;IACrC,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,UAAU,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,MAAwC,CAAC;AAE1E;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAKhE;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;CA4BV,CAAC;AAgDX,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,OAAO,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,GAA0B,GAAG,GAAG,CAmB3E;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAMzC;AAwBD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAa9C;AAMD;;;GAGG;AACH,wBAAgB,QA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