@zakmandhro/bunti 0.1.4 → 0.1.5

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 (92) hide show
  1. package/README.md +66 -25
  2. package/dist/colors.d.ts +74 -0
  3. package/dist/colors.d.ts.map +1 -0
  4. package/dist/colors.js +227 -0
  5. package/dist/colors.js.map +1 -0
  6. package/dist/components/Box.d.ts +5 -0
  7. package/dist/components/Box.d.ts.map +1 -0
  8. package/dist/components/Box.js +4 -0
  9. package/dist/components/Box.js.map +1 -0
  10. package/dist/components/Button.d.ts +14 -0
  11. package/dist/components/Button.d.ts.map +1 -0
  12. package/dist/components/Button.js +91 -0
  13. package/dist/components/Button.js.map +1 -0
  14. package/dist/components/Card.d.ts +11 -0
  15. package/dist/components/Card.d.ts.map +1 -0
  16. package/dist/components/Card.js +37 -0
  17. package/dist/components/Card.js.map +1 -0
  18. package/dist/components/Header.d.ts +13 -0
  19. package/dist/components/Header.d.ts.map +1 -0
  20. package/dist/components/Header.js +54 -0
  21. package/dist/components/Header.js.map +1 -0
  22. package/dist/components/Input.d.ts +16 -0
  23. package/dist/components/Input.d.ts.map +1 -0
  24. package/dist/components/Input.js +101 -0
  25. package/dist/components/Input.js.map +1 -0
  26. package/dist/components/Modal.d.ts +13 -0
  27. package/dist/components/Modal.d.ts.map +1 -0
  28. package/dist/components/Modal.js +28 -0
  29. package/dist/components/Modal.js.map +1 -0
  30. package/dist/components/index.d.ts +7 -0
  31. package/dist/components/index.d.ts.map +1 -0
  32. package/{src/components/index.ts → dist/components/index.js} +3 -0
  33. package/dist/components/index.js.map +1 -0
  34. package/dist/data/glyphs.d.ts +5 -0
  35. package/dist/data/glyphs.d.ts.map +1 -0
  36. package/dist/data/glyphs.js +29 -0
  37. package/dist/data/glyphs.js.map +1 -0
  38. package/dist/detect.d.ts +15 -0
  39. package/dist/detect.d.ts.map +1 -0
  40. package/dist/detect.js +49 -0
  41. package/dist/detect.js.map +1 -0
  42. package/dist/dsl.d.ts +159 -0
  43. package/dist/dsl.d.ts.map +1 -0
  44. package/dist/dsl.js +663 -0
  45. package/dist/dsl.js.map +1 -0
  46. package/dist/easing.d.ts +5 -0
  47. package/dist/easing.d.ts.map +1 -0
  48. package/dist/easing.js +18 -0
  49. package/dist/easing.js.map +1 -0
  50. package/dist/geometry.d.ts +38 -0
  51. package/dist/geometry.d.ts.map +1 -0
  52. package/dist/geometry.js +110 -0
  53. package/dist/geometry.js.map +1 -0
  54. package/dist/icons.d.ts +21 -0
  55. package/dist/icons.d.ts.map +1 -0
  56. package/dist/icons.js +185 -0
  57. package/dist/icons.js.map +1 -0
  58. package/dist/index.d.ts +157 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +36 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/layout.d.ts +89 -0
  63. package/dist/layout.d.ts.map +1 -0
  64. package/dist/layout.js +533 -0
  65. package/dist/layout.js.map +1 -0
  66. package/dist/render.d.ts +17 -0
  67. package/dist/render.d.ts.map +1 -0
  68. package/dist/render.js +335 -0
  69. package/dist/render.js.map +1 -0
  70. package/dist/state.d.ts +92 -0
  71. package/dist/state.d.ts.map +1 -0
  72. package/dist/state.js +105 -0
  73. package/dist/state.js.map +1 -0
  74. package/dist/utils.d.ts +27 -0
  75. package/dist/utils.d.ts.map +1 -0
  76. package/dist/utils.js +157 -0
  77. package/dist/utils.js.map +1 -0
  78. package/package.json +33 -8
  79. package/src/colors.ts +0 -255
  80. package/src/components/Button.ts +0 -104
  81. package/src/components/Card.ts +0 -53
  82. package/src/components/Header.ts +0 -65
  83. package/src/components/Input.ts +0 -124
  84. package/src/data/glyphs.ts +0 -30
  85. package/src/detect.ts +0 -60
  86. package/src/dsl.ts +0 -661
  87. package/src/icons.ts +0 -186
  88. package/src/index.ts +0 -72
  89. package/src/layout.ts +0 -640
  90. package/src/render.ts +0 -302
  91. package/src/state.ts +0 -148
  92. package/src/utils.ts +0 -165
package/README.md CHANGED
@@ -12,10 +12,11 @@ Bunti (pronounced *Bun-ty*) is a zero-dependency, double-buffered layout engine
12
12
  - 📐 **Tactical Standard**: Opinionated border styles (`default`, `rounded`, `frame`, `thick-frame`).
13
13
  - 🌈 **24-bit TrueColor**: High-fidelity RGB gradients with native hex parsing and relative contrast.
14
14
  - 🖱️ **Interactive**: Built-in SGR mouse tracking and focus detection with automatic FPS throttling.
15
+ - 🎞️ **Animation Helpers**: Timeline progress, color fades, flicker, and typewriter text with block cursors.
15
16
 
16
17
  ## 📦 Installation
17
18
 
18
- Bunti is designed for Bun, but works in standard Node.js environments (v18+) as well.
19
+ Bunti is Bun-first and ships compiled ESM plus TypeScript declarations for package consumers.
19
20
 
20
21
  ```bash
21
22
  bun add @zakmandhro/bunti
@@ -31,29 +32,49 @@ npm install @zakmandhro/bunti
31
32
 
32
33
  ```typescript
33
34
  import { bunti } from '@zakmandhro/bunti';
35
+ import { Box, Button, Input } from '@zakmandhro/bunti/components';
34
36
 
35
- bunti.render(({ wallpaper, box, color, icon, span }) => {
36
- // 1. Set a dynamic gradient background
37
- wallpaper(bunti.gradient({ colors: ['midnight', 'plasma'] }));
38
-
39
- // 2. Define a centered high-contrast card
40
- box({
41
- size: "auto",
42
- bgColor: "white",
43
- color: "blank", // Automatic high-contrast black
44
- border: 'frame' // Tactical block border
45
- }, ({ text }) => {
37
+ bunti.render((ctx) => {
38
+ const { color, icon, wallpaper, gradient } = ctx;
39
+
40
+ wallpaper(gradient({ colors: ['midnight', 'plasma'] }));
41
+
42
+ Box(ctx, {
43
+ width: 48,
44
+ border: 'frame',
45
+ bgColor: 'white',
46
+ color: 'black'
47
+ }, (sub) => {
48
+ const { text } = sub;
46
49
  text(` ${icon('rocket')} `);
47
- text(color.bold("MISSION CONTROL\n\n"));
48
-
49
- span({ color: color.dim }, ({ text }) => {
50
- text("STATUS: ");
50
+ text(color.bold('MISSION CONTROL\n\n'));
51
+
52
+ Input(sub, {
53
+ id: 'mission',
54
+ label: 'MISSION:',
55
+ placeholder: 'Enter mission name...',
56
+ width: 36
57
+ });
58
+
59
+ Button(sub, {
60
+ id: 'deploy',
61
+ label: 'Deploy',
62
+ variant: 'primary'
51
63
  });
52
- text("NOMINAL");
53
64
  });
54
- }, { fps: 60, mouse: true });
65
+ }, { fps: 60, mouse: true, keyboard: true, defaultFg: 'silver' });
55
66
  ```
56
67
 
68
+ ## 📏 Layout Model
69
+
70
+ Bunti's public layout direction is Rect-first:
71
+
72
+ - `Rect` is the geometry primitive.
73
+ - `Box`, `Button`, `Input`, `Card`, and `Header` resolve a rect before rendering.
74
+ - Hitboxes and rendered output share the same resolved rect.
75
+ - `splitRect()` and `ctx.split()` create responsive tracks from fixed sizes, percentages, and `fr` fill units.
76
+ - `ctx.resolveLocalRect()` places components within the current parent area, including left/center/right and top/center/bottom defaults.
77
+
57
78
  ## 📐 Border Archetypes
58
79
 
59
80
  Bunti categorizes containers into three visual archetypes:
@@ -68,17 +89,35 @@ Bunti categorizes containers into three visual archetypes:
68
89
 
69
90
  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.
70
91
 
92
+ ## 🎮 Demos
93
+
94
+ Run a public demo:
95
+
96
+ ```bash
97
+ bun demo 2048
98
+ bun demo showcase
99
+ bun demo animation
100
+ bun demo interaction
101
+ bun demo dashboard
102
+ bun demo engine
103
+ bun demo login
104
+ ```
105
+
106
+ Internal/debug demos are still available by name in the runner, but the public list favors fewer, richer examples.
107
+
71
108
  ## 🛠️ Tooling
72
109
 
73
- ### TSGO (High-Performance TypeScript)
74
- Bunti uses **[tsgo](https://github.com/d-ts/tsgo)** for its type-checking pipeline.
110
+ ### TypeScript
111
+ Bunti uses the standard TypeScript compiler for type checking so local development and GitHub Actions run the same toolchain.
112
+
113
+ Run a full check with: `bun run typecheck`
75
114
 
76
- We chose `tsgo` over the standard `tsc` because:
77
- - **Speed**: It leverages a Go-based core to provide near-instant feedback during development.
78
- - **Agent-Friendly**: Its predictable and high-performance output makes it ideal for automated engineering workflows.
79
- - **Strict Integrity**: It ensures that Bunti's functional architecture remains 100% type-safe without the overhead of standard Node-based compilers.
115
+ Build the published package with:
80
116
 
81
- Run a full check with: `npm run type-check`
117
+ ```bash
118
+ bun run build
119
+ npm pack --dry-run
120
+ ```
82
121
 
83
122
  ## 📚 Documentation
84
123
 
@@ -96,6 +135,8 @@ Contributions are welcome! Please feel free to submit a Pull Request. Since Bunt
96
135
  bun run lint
97
136
  bun run typecheck
98
137
  bun run test
138
+ bun run build
139
+ npm pack --dry-run
99
140
  bun run bench
100
141
  ```
101
142
 
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Bunti Semantic & Palette Color System
3
+ */
4
+ import type { RGB } from './state';
5
+ export interface Gradient {
6
+ colors: RGB[];
7
+ direction: 'vertical' | 'horizontal';
8
+ steps: number;
9
+ }
10
+ export declare const PALETTE: {
11
+ readonly slate: "235";
12
+ readonly ash: "240";
13
+ readonly gray: "244";
14
+ readonly silver: "247";
15
+ readonly white: "255";
16
+ readonly black: "0";
17
+ readonly midnight: "17";
18
+ readonly ocean: "24";
19
+ readonly sky: "33";
20
+ readonly 'bunti-blue': "38";
21
+ readonly 'deep-navy': "17";
22
+ readonly nebula: "61";
23
+ readonly plasma: "165";
24
+ readonly success: "40";
25
+ readonly warning: "214";
26
+ readonly error: "196";
27
+ readonly info: "39";
28
+ readonly gold: "220";
29
+ readonly rose: "211";
30
+ readonly mint: "121";
31
+ };
32
+ export type PaletteColor = keyof typeof PALETTE;
33
+ /**
34
+ * Parses a hex color string (#RRGGBB or #RGB) to an RGB object.
35
+ */
36
+ export declare function hexToRGB(hex: string): RGB;
37
+ /**
38
+ * Resolves a palette name, color code, or RGB object to a string for ANSI.
39
+ */
40
+ export declare function resolveColor(color: PaletteColor | string | number | RGB): string | number;
41
+ /**
42
+ * Creates a multi-stop gradient (array of RGB objects) between multiple colors.
43
+ */
44
+ export declare function createGradient(arg1: (string | number | RGB)[] | string | number | RGB, arg2?: string | number | RGB | number, arg3?: number): RGB[];
45
+ /**
46
+ * Adjusts the brightness of a color.
47
+ */
48
+ export declare function adjustBrightness(color: any, amount: number): RGB;
49
+ /**
50
+ * Interpolates between two colors and returns an RGB value.
51
+ */
52
+ export declare function fade(from: string | number | RGB, to: string | number | RGB, progress: number): RGB;
53
+ /**
54
+ * Returns a function that darkens a color and can be used as a style wrapper.
55
+ */
56
+ export declare function darken(color: any, amount?: number): (text: string) => string;
57
+ /**
58
+ * Returns a function that lightens a color and can be used as a style wrapper.
59
+ */
60
+ export declare function lighten(color: any, amount?: number): (text: string) => string;
61
+ /**
62
+ * Returns an RGB object for TrueColor rendering.
63
+ */
64
+ export declare function rgb(r: number, g: number, b: number): {
65
+ r: number;
66
+ g: number;
67
+ b: number;
68
+ };
69
+ /**
70
+ * Returns an ANSI escape sequence for a color.
71
+ */
72
+ export declare function fg(color: any, text: string): string;
73
+ export declare function bg(color: any, text: string): string;
74
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,SAAS,EAAE,UAAU,GAAG,YAAY,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;CA4BV,CAAC;AAgDX,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,OAAO,CAAC;AAEhD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAczC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,GAC1C,MAAM,GAAG,MAAM,CAYjB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,EACvD,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM,EACrC,IAAI,CAAC,EAAE,MAAM,GACZ,GAAG,EAAE,CAwCP;AA0BD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,CAQhE;AAED;;GAEG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,EAC3B,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,EACzB,QAAQ,EAAE,MAAM,GACf,GAAG,CAUL;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,GAAE,MAAW,IAE5C,MAAM,MAAM,YACrB;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,GAAE,MAAW,IAE7C,MAAM,MAAM,YACrB;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;;;;EAElD;AAED;;GAEG;AACH,wBAAgB,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED,wBAAgB,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMnD"}
package/dist/colors.js ADDED
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Bunti Semantic & Palette Color System
3
+ */
4
+ export const PALETTE = {
5
+ // Greyscale
6
+ slate: '235',
7
+ ash: '240',
8
+ gray: '244',
9
+ silver: '247',
10
+ white: '255',
11
+ black: '0',
12
+ // Deep Blues & Space
13
+ midnight: '17',
14
+ ocean: '24',
15
+ sky: '33',
16
+ 'bunti-blue': '38',
17
+ 'deep-navy': '17',
18
+ nebula: '61',
19
+ plasma: '165',
20
+ // Semantic
21
+ success: '40',
22
+ warning: '214',
23
+ error: '196',
24
+ info: '39',
25
+ // Accents
26
+ gold: '220',
27
+ rose: '211',
28
+ mint: '121',
29
+ };
30
+ const RGB_REGISTRY = {
31
+ black: { r: 0, g: 0, b: 0 },
32
+ red: { r: 200, g: 50, b: 50 },
33
+ green: { r: 50, g: 200, b: 50 },
34
+ yellow: { r: 200, g: 200, b: 50 },
35
+ blue: { r: 50, g: 50, b: 200 },
36
+ magenta: { r: 200, g: 50, b: 200 },
37
+ cyan: { r: 50, g: 200, b: 200 },
38
+ white: { r: 255, g: 255, b: 255 },
39
+ gray: { r: 128, g: 128, b: 128 },
40
+ // Greyscale
41
+ slate: { r: 40, g: 44, b: 52 },
42
+ ash: { r: 75, g: 82, b: 99 },
43
+ silver: { r: 188, g: 192, b: 204 },
44
+ // Deep Blues & Space
45
+ midnight: { r: 15, g: 15, b: 35 },
46
+ ocean: { r: 20, g: 40, b: 80 },
47
+ sky: { r: 0, g: 135, b: 255 },
48
+ 'bunti-blue': { r: 59, g: 188, b: 225 },
49
+ 'deep-navy': { r: 0, g: 51, b: 102 },
50
+ nebula: { r: 95, g: 95, b: 175 },
51
+ plasma: { r: 201, g: 0, b: 255 },
52
+ // Semantic
53
+ success: { r: 0, g: 215, b: 0 },
54
+ warning: { r: 255, g: 175, b: 0 },
55
+ error: { r: 215, g: 0, b: 0 },
56
+ info: { r: 0, g: 175, b: 255 },
57
+ // Accents
58
+ gold: { r: 255, g: 215, b: 0 },
59
+ rose: { r: 255, g: 175, b: 175 },
60
+ mint: { r: 175, g: 255, b: 175 },
61
+ };
62
+ // Map standard names to ANSI-256 for basic compat
63
+ const NAME_TO_ANSI = {
64
+ red: '160',
65
+ green: '40',
66
+ yellow: '220',
67
+ blue: '33',
68
+ magenta: '165',
69
+ cyan: '39',
70
+ white: '255',
71
+ black: '0',
72
+ gray: '244',
73
+ };
74
+ /**
75
+ * Parses a hex color string (#RRGGBB or #RGB) to an RGB object.
76
+ */
77
+ export function hexToRGB(hex) {
78
+ const h = hex.replace('#', '');
79
+ if (h.length === 3) {
80
+ return {
81
+ r: parseInt(h[0] + h[0], 16),
82
+ g: parseInt(h[1] + h[1], 16),
83
+ b: parseInt(h[2] + h[2], 16),
84
+ };
85
+ }
86
+ return {
87
+ r: parseInt(h.substring(0, 2), 16),
88
+ g: parseInt(h.substring(2, 4), 16),
89
+ b: parseInt(h.substring(4, 6), 16),
90
+ };
91
+ }
92
+ /**
93
+ * Resolves a palette name, color code, or RGB object to a string for ANSI.
94
+ */
95
+ export function resolveColor(color) {
96
+ if (typeof color === 'object' && 'r' in color) {
97
+ return `2;${color.r};${color.g};${color.b}`;
98
+ }
99
+ if (typeof color === 'string') {
100
+ if (color.startsWith('#')) {
101
+ const rgb = hexToRGB(color);
102
+ return `2;${rgb.r};${rgb.g};${rgb.b}`;
103
+ }
104
+ return PALETTE[color] || NAME_TO_ANSI[color] || color;
105
+ }
106
+ return color;
107
+ }
108
+ /**
109
+ * Creates a multi-stop gradient (array of RGB objects) between multiple colors.
110
+ */
111
+ export function createGradient(arg1, arg2, arg3) {
112
+ let colors = [];
113
+ let steps = 5;
114
+ if (Array.isArray(arg1)) {
115
+ colors = arg1;
116
+ steps = typeof arg2 === 'number' ? arg2 : 5;
117
+ }
118
+ else if (arg1 && arg2) {
119
+ colors = [arg1, arg2];
120
+ steps = typeof arg3 === 'number' ? arg3 : 5;
121
+ }
122
+ if (colors.length === 0)
123
+ return [];
124
+ if (colors.length === 1)
125
+ return Array(steps).fill(resolveColorToRGB(colors[0]));
126
+ if (steps <= 1)
127
+ return [resolveColorToRGB(colors[0])];
128
+ const result = [];
129
+ const rgbColors = colors.map(resolveColorToRGB);
130
+ for (let i = 0; i < steps; i++) {
131
+ const globalT = i / (steps - 1);
132
+ const segmentCount = rgbColors.length - 1;
133
+ const segmentIdx = Math.min(Math.floor(globalT * segmentCount), segmentCount - 1);
134
+ const start = rgbColors[segmentIdx];
135
+ const end = rgbColors[segmentIdx + 1];
136
+ const t = globalT * segmentCount - segmentIdx;
137
+ result.push({
138
+ r: Math.round(start.r + (end.r - start.r) * t),
139
+ g: Math.round(start.g + (end.g - start.g) * t),
140
+ b: Math.round(start.b + (end.b - start.b) * t),
141
+ });
142
+ }
143
+ return result;
144
+ }
145
+ /**
146
+ * Helper to resolve any color type to an RGB object.
147
+ */
148
+ function resolveColorToRGB(color) {
149
+ if (typeof color === 'object' && 'r' in color)
150
+ return color;
151
+ if (typeof color === 'string' && color.startsWith('#'))
152
+ return hexToRGB(color);
153
+ // 1. Check registry
154
+ if (typeof color === 'string' && RGB_REGISTRY[color])
155
+ return RGB_REGISTRY[color];
156
+ // 2. Check Palette
157
+ const paletteValue = PALETTE[color];
158
+ if (paletteValue) {
159
+ // If palette value is a name, look it up in registry
160
+ const registered = RGB_REGISTRY[color];
161
+ if (registered)
162
+ return registered;
163
+ }
164
+ // Fallback
165
+ return { r: 128, g: 128, b: 128 };
166
+ }
167
+ /**
168
+ * Adjusts the brightness of a color.
169
+ */
170
+ export function adjustBrightness(color, amount) {
171
+ const rgb = resolveColorToRGB(color);
172
+ const factor = 1 + amount / 100;
173
+ return {
174
+ r: Math.max(0, Math.min(255, Math.round(rgb.r * factor))),
175
+ g: Math.max(0, Math.min(255, Math.round(rgb.g * factor))),
176
+ b: Math.max(0, Math.min(255, Math.round(rgb.b * factor))),
177
+ };
178
+ }
179
+ /**
180
+ * Interpolates between two colors and returns an RGB value.
181
+ */
182
+ export function fade(from, to, progress) {
183
+ const start = resolveColorToRGB(from);
184
+ const end = resolveColorToRGB(to);
185
+ const t = Math.max(0, Math.min(1, progress));
186
+ return {
187
+ r: Math.round(start.r + (end.r - start.r) * t),
188
+ g: Math.round(start.g + (end.g - start.g) * t),
189
+ b: Math.round(start.b + (end.b - start.b) * t),
190
+ };
191
+ }
192
+ /**
193
+ * Returns a function that darkens a color and can be used as a style wrapper.
194
+ */
195
+ export function darken(color, amount = 20) {
196
+ const adjusted = adjustBrightness(color, -amount);
197
+ return (text) => fg(adjusted, text);
198
+ }
199
+ /**
200
+ * Returns a function that lightens a color and can be used as a style wrapper.
201
+ */
202
+ export function lighten(color, amount = 20) {
203
+ const adjusted = adjustBrightness(color, amount);
204
+ return (text) => fg(adjusted, text);
205
+ }
206
+ /**
207
+ * Returns an RGB object for TrueColor rendering.
208
+ */
209
+ export function rgb(r, g, b) {
210
+ return { r, g, b };
211
+ }
212
+ /**
213
+ * Returns an ANSI escape sequence for a color.
214
+ */
215
+ export function fg(color, text) {
216
+ const code = resolveColor(color);
217
+ const codeStr = String(code);
218
+ const prefix = typeof color === 'object' || codeStr.startsWith('2;') ? '38' : '38;5';
219
+ return `\x1b[${prefix};${codeStr}m${text}\x1b[0m`;
220
+ }
221
+ export function bg(color, text) {
222
+ const code = resolveColor(color);
223
+ const codeStr = String(code);
224
+ const prefix = typeof color === 'object' || codeStr.startsWith('2;') ? '48' : '48;5';
225
+ return `\x1b[${prefix};${codeStr}m${text}\x1b[0m`;
226
+ }
227
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,YAAY;IACZ,KAAK,EAAE,KAAK;IACZ,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,GAAG;IAEV,qBAAqB;IACrB,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,IAAI;IACT,YAAY,EAAE,IAAI;IAClB,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,KAAK;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YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,MAAM,GACV,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IACxE,OAAO,QAAQ,MAAM,IAAI,OAAO,IAAI,IAAI,SAAS,CAAC;AACpD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { BuntiContext, DSLBoxOptions } from '../dsl';
2
+ export interface BoxProps extends DSLBoxOptions {
3
+ }
4
+ export declare function Box(ctx: BuntiContext, props: BoxProps, callback: (sub: BuntiContext) => void): string;
5
+ //# sourceMappingURL=Box.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../src/components/Box.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE1D,MAAM,WAAW,QAAS,SAAQ,aAAa;CAAG;AAElD,wBAAgB,GAAG,CACjB,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,UAGtC"}
@@ -0,0 +1,4 @@
1
+ export function Box(ctx, props, callback) {
2
+ return ctx.box(props, callback);
3
+ }
4
+ //# sourceMappingURL=Box.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Box.js","sourceRoot":"","sources":["../../src/components/Box.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,GAAG,CACjB,GAAiB,EACjB,KAAe,EACf,QAAqC;IAErC,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { BuntiContext, DSLBoxOptions } from '../dsl';
2
+ export interface ButtonProps extends DSLBoxOptions {
3
+ id: string;
4
+ label: string;
5
+ icon?: string;
6
+ variant?: 'primary' | 'secondary' | 'danger' | 'ghost';
7
+ onClick?: () => void;
8
+ }
9
+ /**
10
+ * Tactical Button Component
11
+ * Fully reactive to keyboard focus and action events.
12
+ */
13
+ export declare function Button(ctx: BuntiContext, props: ButtonProps): string;
14
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG1D,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;IACvD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,UA6F3D"}
@@ -0,0 +1,91 @@
1
+ import { adjustBrightness } from '../colors';
2
+ import { indentBlock } from '../utils';
3
+ /**
4
+ * Tactical Button Component
5
+ * Fully reactive to keyboard focus and action events.
6
+ */
7
+ export function Button(ctx, props) {
8
+ const { box, color, focusable, state, hitbox, resolveLocalRect } = ctx;
9
+ // 1. Register in the global focus loop (for TAB navigation)
10
+ const isSelected = focusable(props.id);
11
+ // 2. Resolve final dimensions to perform Mouse Hit-Testing
12
+ const finalLabel = props.icon ? `${props.icon} ${props.label}` : props.label;
13
+ const isGhost = props.variant === 'ghost';
14
+ const isPill = props.variant === 'primary';
15
+ const filled = isPill || props.variant === 'danger';
16
+ const contentWidth = Math.max(12, finalLabel.length + (isPill ? 6 : 4));
17
+ const contentHeight = filled || isGhost ? 1 : 3;
18
+ const area = resolveLocalRect({
19
+ x: props.x,
20
+ y: props.y ?? ctx.cursorY,
21
+ width: props.width ?? contentWidth,
22
+ height: props.height ?? contentHeight,
23
+ contentWidth,
24
+ contentHeight,
25
+ });
26
+ const interaction = hitbox(props.id, {
27
+ x: area.x,
28
+ y: area.y,
29
+ width: area.width,
30
+ height: area.height,
31
+ });
32
+ const isHovered = interaction.hovered;
33
+ const isActive = isSelected || isHovered;
34
+ // 3. Resolve Theme & State
35
+ let bg = 254; // Near white
36
+ let fg = 'black';
37
+ let borderCol = { r: 217, g: 216, b: 213 };
38
+ if (props.variant === 'primary') {
39
+ bg = isActive ? 'sky' : 'bunti-blue';
40
+ fg = 'white';
41
+ borderCol = bg;
42
+ }
43
+ else if (props.variant === 'danger') {
44
+ bg = 'error';
45
+ borderCol = adjustBrightness('error', 20);
46
+ fg = 'white';
47
+ }
48
+ else if (isGhost) {
49
+ bg = undefined;
50
+ fg = isActive ? 'white' : 'silver';
51
+ borderCol = 'ash';
52
+ }
53
+ if (isActive) {
54
+ if (props.variant !== 'primary' && !isGhost) {
55
+ borderCol = 'black';
56
+ if (interaction.pressed) {
57
+ bg = adjustBrightness(bg, -5); // Pressed state
58
+ }
59
+ }
60
+ }
61
+ // 4. Handle Interaction
62
+ const wasClicked = interaction.pressed;
63
+ const wasActivated = isSelected && (state.lastKey === 'enter' || state.lastKey === ' ');
64
+ if (wasClicked || wasActivated) {
65
+ if (props.onClick)
66
+ props.onClick();
67
+ }
68
+ // 5. Render the Primitive
69
+ const renderLabel = isPill
70
+ ? `${color.fg(bg, '')}${color.bg(bg, color.fg(fg, ` ${isActive ? color.bold(finalLabel) : finalLabel} `))}${color.fg(bg, '')}`
71
+ : color.fg(fg, isActive ? color.bold(finalLabel) : finalLabel);
72
+ const rendered = box({
73
+ x: area.x,
74
+ y: area.y,
75
+ width: area.width,
76
+ height: area.height,
77
+ border: filled || isGhost ? 'none' : props.border || 'rounded',
78
+ borderColor: borderCol,
79
+ bgColor: filled && !isPill ? bg : undefined,
80
+ align: props.align || 'center',
81
+ valign: props.valign || 'middle',
82
+ padding: props.padding || [0, isGhost ? 0 : 1],
83
+ detach: props.detach,
84
+ }, ({ text }) => {
85
+ text(renderLabel);
86
+ });
87
+ return !ctx.isRoot && props.detach && props.x === undefined
88
+ ? indentBlock(rendered, area.x)
89
+ : rendered;
90
+ }
91
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/components/Button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAUvC;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,GAAiB,EAAE,KAAkB;IAC1D,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,GAAG,CAAC;IAEvE,4DAA4D;IAC5D,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAEvC,2DAA2D;IAC3D,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;IAC7E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC;IAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC;IAC3C,MAAM,MAAM,GAAG,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;IACpD,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,MAAM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EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAEjE,MAAM,QAAQ,GAAG,GAAG,CAClB;QACE,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,MAAM,EAAE,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,SAAS;QAC9D,WAAW,EAAE,SAAS;QACtB,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;QAC3C,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,QAAQ;QAC9B,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,QAAQ;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,EACD,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QACX,IAAI,CAAC,WAAW,CAAC,CAAC;IACpB,CAAC,CACF,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,KAAK,SAAS;QACzD,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;QAC/B,CAAC,CAAC,QAAQ,CAAC;AACf,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { BuntiContext, DSLBoxOptions } from '../dsl';
2
+ export interface CardProps extends DSLBoxOptions {
3
+ title?: string;
4
+ theme?: 'default' | 'accent' | 'danger';
5
+ }
6
+ /**
7
+ * Tactical Card Component
8
+ * A structural container with an integrated header.
9
+ */
10
+ export declare function Card(ctx: BuntiContext, props: CardProps, callback: (sub: BuntiContext) => void): string;
11
+ //# sourceMappingURL=Card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG1D,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAClB,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,UAuCtC"}
@@ -0,0 +1,37 @@
1
+ import { Box } from './Box';
2
+ /**
3
+ * Tactical Card Component
4
+ * A structural container with an integrated header.
5
+ */
6
+ export function Card(ctx, props, callback) {
7
+ const { color } = ctx;
8
+ const neutralGray = { r: 217, g: 216, b: 213 };
9
+ let borderColor = neutralGray;
10
+ let titleColor = neutralGray;
11
+ if (props.theme === 'accent') {
12
+ titleColor = 'black';
13
+ // Border remains neutral gray
14
+ }
15
+ else if (props.theme === 'danger') {
16
+ borderColor = 'error';
17
+ titleColor = 'error';
18
+ }
19
+ return Box(ctx, {
20
+ x: props.x,
21
+ y: props.y,
22
+ anchor: props.anchor,
23
+ width: props.width || '100%',
24
+ height: props.height,
25
+ minHeight: props.minHeight,
26
+ border: props.border || 'frame',
27
+ borderColor: props.borderColor || borderColor,
28
+ padding: props.padding || [1, 2],
29
+ bgColor: props.bgColor,
30
+ }, (sub) => {
31
+ if (props.title) {
32
+ sub.text(color.fg(titleColor, color.bold(`${props.title.toUpperCase()}\n\n`)));
33
+ }
34
+ callback(sub);
35
+ });
36
+ }
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