@zakmandhro/bunti 0.1.5 → 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.
Files changed (192) hide show
  1. package/AGENTS.md +65 -0
  2. package/README.md +86 -11
  3. package/dist/cli.d.ts +44 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +147 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/colors.d.ts +77 -7
  8. package/dist/colors.d.ts.map +1 -1
  9. package/dist/colors.js +238 -39
  10. package/dist/colors.js.map +1 -1
  11. package/dist/components/Box.d.ts +6 -0
  12. package/dist/components/Box.d.ts.map +1 -1
  13. package/dist/components/Box.js +5 -0
  14. package/dist/components/Box.js.map +1 -1
  15. package/dist/components/Button.d.ts +15 -2
  16. package/dist/components/Button.d.ts.map +1 -1
  17. package/dist/components/Button.js +45 -25
  18. package/dist/components/Button.js.map +1 -1
  19. package/dist/components/Card.d.ts +24 -2
  20. package/dist/components/Card.d.ts.map +1 -1
  21. package/dist/components/Card.js +56 -14
  22. package/dist/components/Card.js.map +1 -1
  23. package/dist/components/Header.d.ts +11 -1
  24. package/dist/components/Header.d.ts.map +1 -1
  25. package/dist/components/Header.js +12 -8
  26. package/dist/components/Header.js.map +1 -1
  27. package/dist/components/Input.d.ts +10 -1
  28. package/dist/components/Input.d.ts.map +1 -1
  29. package/dist/components/Input.js +176 -41
  30. package/dist/components/Input.js.map +1 -1
  31. package/dist/components/Link.d.ts +21 -0
  32. package/dist/components/Link.d.ts.map +1 -0
  33. package/dist/components/Link.js +38 -0
  34. package/dist/components/Link.js.map +1 -0
  35. package/dist/components/Modal.d.ts +25 -0
  36. package/dist/components/Modal.d.ts.map +1 -1
  37. package/dist/components/Modal.js +88 -24
  38. package/dist/components/Modal.js.map +1 -1
  39. package/dist/components/Progress.d.ts +27 -0
  40. package/dist/components/Progress.d.ts.map +1 -0
  41. package/dist/components/Progress.js +39 -0
  42. package/dist/components/Progress.js.map +1 -0
  43. package/dist/components/Spinner.d.ts +19 -0
  44. package/dist/components/Spinner.d.ts.map +1 -0
  45. package/dist/components/Spinner.js +27 -0
  46. package/dist/components/Spinner.js.map +1 -0
  47. package/dist/components/index.d.ts +3 -0
  48. package/dist/components/index.d.ts.map +1 -1
  49. package/dist/components/index.js +3 -0
  50. package/dist/components/index.js.map +1 -1
  51. package/dist/data/nf-glyphs.d.ts +11 -0
  52. package/dist/data/nf-glyphs.d.ts.map +1 -0
  53. package/dist/data/nf-glyphs.js +535 -0
  54. package/dist/data/nf-glyphs.js.map +1 -0
  55. package/dist/data/nf-names.d.ts +8 -0
  56. package/dist/data/nf-names.d.ts.map +1 -0
  57. package/dist/data/nf-names.js +2 -0
  58. package/dist/data/nf-names.js.map +1 -0
  59. package/dist/demo-registry.d.ts +27 -0
  60. package/dist/demo-registry.d.ts.map +1 -0
  61. package/dist/demo-registry.js +57 -0
  62. package/dist/demo-registry.js.map +1 -0
  63. package/dist/demos/2048.ts +743 -0
  64. package/dist/demos/animation.ts +246 -0
  65. package/dist/demos/demo-layout.ts +124 -0
  66. package/dist/demos/engine.ts +374 -0
  67. package/dist/demos/interaction.ts +91 -0
  68. package/dist/demos/login.ts +203 -0
  69. package/dist/demos/mission-control.ts +558 -0
  70. package/dist/demos/showcase.ts +224 -0
  71. package/dist/detect.d.ts +92 -3
  72. package/dist/detect.d.ts.map +1 -1
  73. package/dist/detect.js +218 -40
  74. package/dist/detect.js.map +1 -1
  75. package/dist/diagnostics.d.ts +73 -0
  76. package/dist/diagnostics.d.ts.map +1 -0
  77. package/dist/diagnostics.js +225 -0
  78. package/dist/diagnostics.js.map +1 -0
  79. package/dist/dsl/context.d.ts +11 -0
  80. package/dist/dsl/context.d.ts.map +1 -0
  81. package/dist/dsl/context.js +658 -0
  82. package/dist/dsl/context.js.map +1 -0
  83. package/dist/dsl/hooks.d.ts +12 -0
  84. package/dist/dsl/hooks.d.ts.map +1 -0
  85. package/dist/dsl/hooks.js +148 -0
  86. package/dist/dsl/hooks.js.map +1 -0
  87. package/dist/dsl/interaction.d.ts +31 -0
  88. package/dist/dsl/interaction.d.ts.map +1 -0
  89. package/dist/dsl/interaction.js +150 -0
  90. package/dist/dsl/interaction.js.map +1 -0
  91. package/dist/dsl/layers.d.ts +14 -0
  92. package/dist/dsl/layers.d.ts.map +1 -0
  93. package/dist/dsl/layers.js +87 -0
  94. package/dist/dsl/layers.js.map +1 -0
  95. package/dist/dsl/motion.d.ts +10 -0
  96. package/dist/dsl/motion.d.ts.map +1 -0
  97. package/dist/dsl/motion.js +150 -0
  98. package/dist/dsl/motion.js.map +1 -0
  99. package/dist/dsl/render.d.ts +22 -0
  100. package/dist/dsl/render.d.ts.map +1 -0
  101. package/dist/dsl/render.js +69 -0
  102. package/dist/dsl/render.js.map +1 -0
  103. package/dist/dsl/types.d.ts +555 -0
  104. package/dist/dsl/types.d.ts.map +1 -0
  105. package/dist/dsl/types.js +33 -0
  106. package/dist/dsl/types.js.map +1 -0
  107. package/dist/dsl.d.ts +13 -154
  108. package/dist/dsl.d.ts.map +1 -1
  109. package/dist/dsl.js +12 -658
  110. package/dist/dsl.js.map +1 -1
  111. package/dist/easing.d.ts +41 -1
  112. package/dist/easing.d.ts.map +1 -1
  113. package/dist/easing.js +105 -2
  114. package/dist/easing.js.map +1 -1
  115. package/dist/geometry.d.ts +39 -0
  116. package/dist/geometry.d.ts.map +1 -1
  117. package/dist/geometry.js +20 -0
  118. package/dist/geometry.js.map +1 -1
  119. package/dist/icons-full.d.ts +5 -0
  120. package/dist/icons-full.d.ts.map +1 -0
  121. package/dist/icons-full.js +31 -0
  122. package/dist/icons-full.js.map +1 -0
  123. package/dist/icons.d.ts +426 -5
  124. package/dist/icons.d.ts.map +1 -1
  125. package/dist/icons.js +144 -15
  126. package/dist/icons.js.map +1 -1
  127. package/dist/index.d.ts +95 -23
  128. package/dist/index.d.ts.map +1 -1
  129. package/dist/index.js +17 -7
  130. package/dist/index.js.map +1 -1
  131. package/dist/input.d.ts +177 -0
  132. package/dist/input.d.ts.map +1 -0
  133. package/dist/input.js +533 -0
  134. package/dist/input.js.map +1 -0
  135. package/dist/layout.d.ts +153 -7
  136. package/dist/layout.d.ts.map +1 -1
  137. package/dist/layout.js +221 -34
  138. package/dist/layout.js.map +1 -1
  139. package/dist/render.d.ts +33 -1
  140. package/dist/render.d.ts.map +1 -1
  141. package/dist/render.js +431 -116
  142. package/dist/render.js.map +1 -1
  143. package/dist/state.d.ts +156 -3
  144. package/dist/state.d.ts.map +1 -1
  145. package/dist/state.js +25 -0
  146. package/dist/state.js.map +1 -1
  147. package/dist/theme.d.ts +129 -0
  148. package/dist/theme.d.ts.map +1 -0
  149. package/dist/theme.js +167 -0
  150. package/dist/theme.js.map +1 -0
  151. package/dist/themes/catppuccin-mocha.d.ts +19 -0
  152. package/dist/themes/catppuccin-mocha.d.ts.map +1 -0
  153. package/dist/themes/catppuccin-mocha.js +36 -0
  154. package/dist/themes/catppuccin-mocha.js.map +1 -0
  155. package/dist/themes/dracula.d.ts +21 -0
  156. package/dist/themes/dracula.d.ts.map +1 -0
  157. package/dist/themes/dracula.js +37 -0
  158. package/dist/themes/dracula.js.map +1 -0
  159. package/dist/themes/github-light.d.ts +21 -0
  160. package/dist/themes/github-light.d.ts.map +1 -0
  161. package/dist/themes/github-light.js +36 -0
  162. package/dist/themes/github-light.js.map +1 -0
  163. package/dist/themes/index.d.ts +19 -0
  164. package/dist/themes/index.d.ts.map +1 -0
  165. package/dist/themes/index.js +17 -0
  166. package/dist/themes/index.js.map +1 -0
  167. package/dist/themes/nord.d.ts +23 -0
  168. package/dist/themes/nord.d.ts.map +1 -0
  169. package/dist/themes/nord.js +38 -0
  170. package/dist/themes/nord.js.map +1 -0
  171. package/dist/themes/one-dark-pro.d.ts +21 -0
  172. package/dist/themes/one-dark-pro.d.ts.map +1 -0
  173. package/dist/themes/one-dark-pro.js +36 -0
  174. package/dist/themes/one-dark-pro.js.map +1 -0
  175. package/dist/themes/tokyo-night.d.ts +20 -0
  176. package/dist/themes/tokyo-night.d.ts.map +1 -0
  177. package/dist/themes/tokyo-night.js +37 -0
  178. package/dist/themes/tokyo-night.js.map +1 -0
  179. package/dist/utils.d.ts +1 -0
  180. package/dist/utils.d.ts.map +1 -1
  181. package/dist/utils.js +1 -0
  182. package/dist/utils.js.map +1 -1
  183. package/dist/vendor/colors.d.ts +45 -0
  184. package/dist/vendor/colors.d.ts.map +1 -0
  185. package/dist/vendor/colors.js +72 -0
  186. package/dist/vendor/colors.js.map +1 -0
  187. package/llms.txt +79 -0
  188. package/package.json +23 -7
  189. package/dist/data/glyphs.d.ts +0 -5
  190. package/dist/data/glyphs.d.ts.map +0 -1
  191. package/dist/data/glyphs.js +0 -29
  192. package/dist/data/glyphs.js.map +0 -1
@@ -0,0 +1,555 @@
1
+ /**
2
+ * Bunti DSL shared types and constants.
3
+ */
4
+ import type { bg, darken, fg, Gradient, lighten, rgb } from '../colors';
5
+ import type { TerminalProfile } from '../detect';
6
+ import type { PlacedRectInput, PlacedRectOptions, Rect, RectInput, SplitOptions } from '../geometry';
7
+ import type { KeyEvent } from '../input';
8
+ import type { ListOptions, SideColors, StyleOptions, TableOptions } from '../layout';
9
+ import type { Cell, Hitbox, RGB, ScreenState } from '../state';
10
+ import type { Theme, ThemeColor, ThemeInput } from '../theme';
11
+ import type { BuntiColor } from '../vendor/colors';
12
+ /**
13
+ * Normalized key-name constants for `ctx.lastKey` / `ctx.keyPressed()`.
14
+ * Printable keys are their literal character ('a', 'A', ' '); mouse events
15
+ * arrive as the 'click' / 'wheel_up' / 'wheel_down' pseudo-keys.
16
+ * @example if (ctx.keyPressed(KEYS.ENTER)) submit();
17
+ */
18
+ export declare const KEYS: {
19
+ UP: string;
20
+ DOWN: string;
21
+ RIGHT: string;
22
+ LEFT: string;
23
+ ENTER: string;
24
+ ESCAPE: string;
25
+ TAB: string;
26
+ BACKSPACE: string;
27
+ SPACE: string;
28
+ HOME: string;
29
+ END: string;
30
+ DELETE: string;
31
+ PAGE_UP: string;
32
+ PAGE_DOWN: string;
33
+ INSERT: string;
34
+ /** Left-button click (emitted once, on release; requires `mouse: true`). */
35
+ CLICK: string;
36
+ /** Mouse wheel scrolled up (requires `mouse: true`). */
37
+ WHEEL_UP: string;
38
+ /** Mouse wheel scrolled down (requires `mouse: true`). */
39
+ WHEEL_DOWN: string;
40
+ };
41
+ /**
42
+ * Options for `ctx.box()`. Extends StyleOptions (width/height/padding/
43
+ * border/align/wrap) with placement, layering, and color controls.
44
+ */
45
+ export interface DSLBoxOptions extends StyleOptions {
46
+ /** Background fill: palette name, hex, ANSI-256 code, RGB, Gradient, or theme token. */
47
+ bgColor?: string | number | RGB | Gradient | ThemeColor;
48
+ /**
49
+ * Default text color inside the box. 'blank' auto-picks black or white
50
+ * for WCAG contrast against `bgColor`.
51
+ */
52
+ color?: string | number | RGB | ThemeColor | 'blank';
53
+ /** Column offset (cells) inside the parent area. Unplaced boxes center. */
54
+ x?: number;
55
+ /** Row offset (cells) inside the parent area. Unplaced boxes center. */
56
+ y?: number;
57
+ /**
58
+ * Promotes the box onto its own composited layer at this z-index —
59
+ * shorthand for wrapping it in `ctx.layer(zIndex, ...)`.
60
+ */
61
+ zIndex?: number;
62
+ /** Pins the box to the top or bottom edge at full parent width. */
63
+ anchor?: 'top' | 'bottom';
64
+ /** Reserved size hint ('auto' sizes to content). */
65
+ size?: 'auto' | number;
66
+ /** Title rendered into the top border. */
67
+ title?: string;
68
+ /** Styler applied to the rendered title (e.g. a ThemeColor or color.bold). */
69
+ titleStyle?: (s: string) => string;
70
+ /** Stable identifier (useful with hitboxes/focus). */
71
+ id?: string;
72
+ /**
73
+ * Border color: single color value, a styler function, or per-side
74
+ * colors ({ top, bottom, left, right }).
75
+ */
76
+ borderColor?: string | number | RGB | ThemeColor | ((s: string) => string) | SideColors;
77
+ /** If true, the string is returned but NOT appended to the flow. */
78
+ detach?: boolean;
79
+ /**
80
+ * Visual-only vertical paint offset in rows (direct-rendered boxes).
81
+ * The box PAINTS shifted by this amount while its resolved rect —
82
+ * sub-context offsets, hitboxes, focus geometry — stays at the settled
83
+ * position. Entrance animations (Modal's slide-in) use this so hitboxes
84
+ * sit at their final coordinates from the first frame.
85
+ */
86
+ paintOffsetY?: number;
87
+ }
88
+ /** Options for `ctx.typewriter()`. */
89
+ export interface TypewriterOptions {
90
+ /** Keys the animation clock (restartable via `ctx.restartAnimation(id)`). */
91
+ id?: string;
92
+ /** Typing speed in characters per second (default 24). */
93
+ cps?: number;
94
+ /** Milliseconds to wait before typing starts. */
95
+ delay?: number;
96
+ /** Restart from the beginning after the full text is typed. */
97
+ loop?: boolean;
98
+ /** Cursor glyph (default '█'). */
99
+ cursor?: string;
100
+ /** Set false to disable cursor blinking after typing completes. */
101
+ blink?: boolean;
102
+ /** Cursor blink period in milliseconds (default 450). */
103
+ blinkRate?: number;
104
+ }
105
+ /** Frame snapshot returned by `ctx.typewriter()`. */
106
+ export interface TypewriterState {
107
+ /** The portion of the text typed so far. */
108
+ text: string;
109
+ /** The cursor glyph for this frame (' ' during blink-off phases). */
110
+ cursor: string;
111
+ /** True once the full text has been typed. */
112
+ done: boolean;
113
+ /** Number of graphemes typed so far. */
114
+ index: number;
115
+ /** Typing progress 0..1. */
116
+ progress: number;
117
+ }
118
+ /** Options for `ctx.layer()`. */
119
+ export interface LayerOptions {
120
+ /** Composite order: higher z-index layers paint on top (default 0). */
121
+ zIndex?: number;
122
+ /**
123
+ * Paints a drop shadow under the layer's painted content bounds
124
+ * (offset +2 columns, +1 row) at composite time. The shadow darkens
125
+ * whatever sits below it, including lower layers.
126
+ */
127
+ shadow?: boolean;
128
+ /**
129
+ * Dims everything below this layer by 0..1 (backdrop luminance scale
130
+ * toward black) before the layer composites. Applied in z-order, so
131
+ * lower layers are dimmed too.
132
+ */
133
+ backdrop?: number;
134
+ }
135
+ /**
136
+ * The contextual builder passed to every render closure. One frame = one
137
+ * callback invocation: read input, derive state, draw.
138
+ *
139
+ * Coordinate model: `x`/`y` are cell offsets local to the current context
140
+ * area (the whole screen at the root; the padded interior inside a box).
141
+ * At the root, `box()` paints straight into the screen buffer and centers
142
+ * when not given `x`/`y`; inside a box, drawing calls append to that box's
143
+ * text flow. Use `layer()`/`zIndex` for anything that must overlap.
144
+ */
145
+ export interface BuntiContext {
146
+ /**
147
+ * ANSI color helpers: picocolors-style stylers (`color.bold`,
148
+ * `color.cyan`, ...) plus Bunti's RGB helpers (`color.fg(value, text)`,
149
+ * `color.bg`, `color.rgb`, `color.darken`, `color.lighten`).
150
+ */
151
+ color: BuntiColor & {
152
+ darken: typeof darken;
153
+ lighten: typeof lighten;
154
+ rgb: typeof rgb;
155
+ fg: typeof fg;
156
+ bg: typeof bg;
157
+ };
158
+ /** The underlying screen state (buffers, options, input). Advanced use. */
159
+ state: ScreenState;
160
+ /** Width of the current context area in cells. */
161
+ width: number;
162
+ /** Height of the current context area in cells (rows). */
163
+ height: number;
164
+ /** The current context area as an absolute Rect. */
165
+ area: Rect;
166
+ /** True on the top-level screen context (false inside box/layer closures). */
167
+ isRoot: boolean;
168
+ /** Absolute column of this context's origin (for `blit`/`rect` math). */
169
+ offsetX: number;
170
+ /** Absolute row of this context's origin (for `blit`/`rect` math). */
171
+ offsetY: number;
172
+ /** Column the text flow ends at on its last line (local). */
173
+ readonly cursorX: number;
174
+ /** Row the text flow ends at (local) — where the next text/box lands. */
175
+ readonly cursorY: number;
176
+ /** Mouse column (0-based screen cells; requires `mouse: true`). */
177
+ mouseX: number;
178
+ /** Mouse row (0-based screen cells; requires `mouse: true`). */
179
+ mouseY: number;
180
+ /** Raw SGR button code of the most recent mouse event. */
181
+ mouseButton: number;
182
+ /** True while the left mouse button is held down. */
183
+ isMouseDown: boolean;
184
+ /**
185
+ * First unmodified key name of this frame, or undefined when no key
186
+ * arrived. Printable keys are the literal character ('a', ' '); special
187
+ * keys are normalized lowercase names ('up', 'enter', 'escape', 'f1');
188
+ * mouse events arrive as 'click' / 'wheel_up' / 'wheel_down'. Requires
189
+ * `keyboard: true` in the render options.
190
+ * @example if (ctx.lastKey === 'q') ctx.requestStop();
191
+ */
192
+ lastKey?: string;
193
+ /**
194
+ * All KeyEvents of this frame (multiple keys per frame arrive whole),
195
+ * including ctrl/alt combos and synthetic 'release' events that
196
+ * `lastKey` never carries. Requires `keyboard: true`.
197
+ * @example for (const e of ctx.keys) if (e.key === 'enter') submit();
198
+ */
199
+ keys: KeyEvent[];
200
+ /** Id of the currently focused focusable, if any. */
201
+ focusedId?: string;
202
+ /**
203
+ * Milliseconds elapsed since render() started. Drives time-based
204
+ * animation (fps-independent).
205
+ * @example const pulse = Math.sin(ctx.elapsedTime / 300);
206
+ */
207
+ elapsedTime: number;
208
+ /**
209
+ * The env-detected terminal profile (app, version, multiplexer, truecolor,
210
+ * sync output, Nerd Font policy). Detected once per render().
211
+ */
212
+ readonly terminal: TerminalProfile;
213
+ /**
214
+ * The active semantic theme for this subtree. Tokens are callable fg
215
+ * stylers that also carry `.rgb`/`.hex`, so they work as both text
216
+ * wrappers and color values.
217
+ * @example ctx.box({ bgColor: ctx.theme.surface }, (s) => s.text(ctx.theme.primary('hi')));
218
+ */
219
+ readonly theme: Theme;
220
+ /**
221
+ * Swaps the active theme live and requests a rerender. Sparse inputs are
222
+ * completed via createTheme() derivation.
223
+ * @example ctx.setTheme(dracula); // from '@zakmandhro/bunti/themes'
224
+ */
225
+ setTheme(theme: Theme | ThemeInput): void;
226
+ /**
227
+ * Runs the callback with an overridden theme for that subtree only.
228
+ * Partial inputs overlay the current theme; the previous theme is
229
+ * restored afterwards.
230
+ * @example ctx.themed({ primary: '#ff5f87' }, (sub) => sidebar(sub));
231
+ */
232
+ themed(theme: Theme | ThemeInput, callback: (sub: BuntiContext) => void): BuntiContext;
233
+ /**
234
+ * True if `name` was pressed (or auto-repeated) this frame. Requires
235
+ * `keyboard: true`.
236
+ * @example if (ctx.keyPressed('escape')) closeModal();
237
+ */
238
+ keyPressed(name: string): boolean;
239
+ /**
240
+ * True from a key's first press until its repeat stream expires
241
+ * (~150ms hold window) — smooth held-key movement on legacy terminals.
242
+ * @example if (ctx.isKeyHeld('right')) player.x += speed * ctx.dt;
243
+ */
244
+ isKeyHeld(name: string): boolean;
245
+ /**
246
+ * Appends text to the current flow at the cursor. Supports '\n' and
247
+ * pre-styled ANSI strings; returns the context for chaining.
248
+ * @example ctx.text(ctx.color.bold('Status: ')).text('ready\n');
249
+ */
250
+ text(str: string | number): BuntiContext;
251
+ /**
252
+ * Resolves an icon name to its glyph (Nerd Font, or ASCII fallback on
253
+ * plain terminals). Pure string return for template-literal safety.
254
+ * Curated names work out of the box; `import '@zakmandhro/bunti/icons-full'`
255
+ * unlocks all ~10.7k Nerd Font names.
256
+ * @example ctx.text(`${ctx.icon('rocket')} Launch`);
257
+ */
258
+ icon(name: string): string;
259
+ /**
260
+ * Paints a (possibly multi-line, ANSI-styled) string directly into the
261
+ * screen buffer at absolute cell coordinates — exact-position text,
262
+ * sprites, labels, and ASCII art.
263
+ * @example ctx.blit(2, 1, 'FPS 60', { fg: 'gold' });
264
+ */
265
+ blit(x: number, y: number, content: string, style?: Partial<Cell>): BuntiContext;
266
+ /**
267
+ * Fills a w×h cell rectangle at absolute coordinates with a style —
268
+ * bars, panels, charts, and backgrounds. Pure-background fills keep the
269
+ * characters already painted underneath.
270
+ * @example ctx.rect(0, 0, ctx.width, 3, { bg: ctx.theme.surface });
271
+ */
272
+ rect(x: number, y: number, w: number, h: number, style: Partial<Cell>): BuntiContext;
273
+ /**
274
+ * Crops a multi-line string to a width×height window starting at
275
+ * `scrollY` — the primitive for scrollable content.
276
+ */
277
+ viewport(content: string, width: number, height: number, scrollY?: number): string;
278
+ /**
279
+ * Runs the callback, wraps everything it appended in one color, and
280
+ * pushes the styled result to the flow. Returns the styled string.
281
+ */
282
+ span(options: {
283
+ color?: string | number | RGB | ((s: string) => string);
284
+ }, callback: (sub: BuntiContext) => void): string;
285
+ /**
286
+ * Draws a styled box and renders the callback inside its padded
287
+ * interior (a fresh sub-context). At the root, boxes paint directly to
288
+ * the screen and center unless given x/y; nested boxes join the parent
289
+ * flow. Returns the rendered string.
290
+ * @example ctx.box({ width: 40, border: 'rounded', title: 'Log' }, (s) => s.text('...'));
291
+ */
292
+ box(options: DSLBoxOptions, callback: (sub: BuntiContext) => void): string;
293
+ /**
294
+ * Renders the callback into a transparent buffer composited above the
295
+ * base content by z-index — THE primitive for modals, HUDs, popovers,
296
+ * and anything that must overlap other content.
297
+ * @example ctx.layer(10, (overlay) => overlay.box({ width: 30, height: 5 }, drawModal));
298
+ */
299
+ layer(zIndexOrOptions: number | LayerOptions, callback: (sub: BuntiContext) => void): BuntiContext;
300
+ layer(callback: (sub: BuntiContext) => void): BuntiContext;
301
+ /** Joins rendered blocks side-by-side, padding each to its own width. */
302
+ joinHorizontal(...blocks: string[]): string;
303
+ /** Stacks rendered blocks vertically (skips empty strings). */
304
+ joinVertical(...blocks: string[]): string;
305
+ /**
306
+ * Fills the whole screen background with a color or gradient.
307
+ * @example ctx.wallpaper(ctx.gradient({ colors: ['midnight', 'plasma'] }));
308
+ */
309
+ wallpaper(input: string | number | RGB | ThemeColor | RGB[] | Gradient | {
310
+ color: any;
311
+ }): void;
312
+ /**
313
+ * Builds a multi-stop Gradient value for `wallpaper`/`bgColor`.
314
+ * @example ctx.gradient({ colors: ['#0000ff', '#ff0000'], direction: 'horizontal' });
315
+ */
316
+ gradient(options: {
317
+ colors: (string | number | RGB | ThemeColor)[];
318
+ direction?: 'vertical' | 'horizontal';
319
+ steps?: number;
320
+ }): Gradient;
321
+ /** Builds an RGB color value for truecolor rendering. */
322
+ rgb(r: number, g: number, b: number): RGB;
323
+ /**
324
+ * Frame-persistent state. The keyed form is position-independent; the
325
+ * keyless form is positional (React-style) and must not be called
326
+ * conditionally. Setting a value requests a rerender.
327
+ * @example const [count, setCount] = ctx.useState('count', 0);
328
+ */
329
+ useState<T>(initial: T): [T, (val: T) => void];
330
+ useState<T>(key: string, initial: T): [T, (val: T) => void];
331
+ /**
332
+ * Like useState, but the value also persists across app restarts
333
+ * (stored in .tmp/bunti_store.json).
334
+ */
335
+ usePersistentState<T>(key: string, initial: T): [T, (val: T) => void];
336
+ /**
337
+ * Registers `id` in the Tab-focus cycle and returns true while it is
338
+ * focused. The first registered focusable receives initial focus.
339
+ */
340
+ focusable(id: string): boolean;
341
+ /** True while `id` holds focus. */
342
+ isFocused(id: string): boolean;
343
+ /** Moves focus to `id`. */
344
+ focus(id: string): void;
345
+ /** Advances focus to the next registered focusable (what Tab does). */
346
+ focusNext(): void;
347
+ /**
348
+ * Registers a clickable region and returns its interaction snapshot for
349
+ * this frame. Requires `mouse: true`. When several hitboxes contain the
350
+ * pointer, only the topmost (last-registered — layers render later, so
351
+ * later registration is visually on top) reports hovered/pressed/clicked.
352
+ * @example const { hovered, clicked } = ctx.hitbox('save', { x: 2, y: 5, width: 10, height: 1 });
353
+ */
354
+ hitbox(id: string, bounds: HitboxBounds): {
355
+ box: Hitbox;
356
+ hovered: boolean;
357
+ pressed: boolean;
358
+ clicked: boolean;
359
+ };
360
+ /**
361
+ * Resolves a partial rect (percent/fr sizes allowed) against the current
362
+ * context area into absolute cells. `y` defaults to the flow cursor.
363
+ */
364
+ resolveRect(bounds: RectInput): Rect;
365
+ /**
366
+ * Places a rect within the current area with alignment defaults
367
+ * (centered unless overridden) — the same placement `box()` uses.
368
+ */
369
+ resolveLocalRect(bounds: PlacedRectInput, options?: PlacedRectOptions): Rect;
370
+ /**
371
+ * Splits the current area into tracks from fixed sizes, percentages,
372
+ * and 'fr' fill units — the layout workhorse for dashboards.
373
+ * @example const [sidebar, main] = ctx.split({ direction: 'horizontal', constraints: [24, '1fr'] });
374
+ */
375
+ split(options: SplitOptions): Rect[];
376
+ /**
377
+ * True while the mouse is inside the hitbox registered for `id`.
378
+ * @example const border = ctx.isHovered('card') ? theme.focus : theme.border;
379
+ */
380
+ isHovered(id: string): boolean;
381
+ /** Mouse currently down inside the hitbox. */
382
+ isPressed(id: string): boolean;
383
+ /**
384
+ * True exactly one frame per click (SGR release at the press origin) —
385
+ * fire actions here, not on isPressed.
386
+ * @example if (ctx.isClicked('save')) save();
387
+ */
388
+ isClicked(id: string): boolean;
389
+ /** Hover turned on for this hitbox this frame. */
390
+ isHoverEnter(id: string): boolean;
391
+ /** Hover turned off for this hitbox this frame. */
392
+ isHoverLeave(id: string): boolean;
393
+ /**
394
+ * Renders a selectable list with built-in up/down keyboard navigation,
395
+ * mouse hover/click selection, and theme-token highlighting. Selection
396
+ * state lives in `useState(`${id}_index`)`.
397
+ * @example ctx.list('menu', ['Start', 'Options', 'Quit'], { maxVisible: 5 });
398
+ */
399
+ list(id: string, items: string[], options?: ListOptions): BuntiContext;
400
+ /**
401
+ * Renders rows of cells as an aligned table with shared borders.
402
+ * @example ctx.table([['NAME', 'STATUS'], ['api', 'ready']], { width: '100%' });
403
+ */
404
+ table(rows: string[][], options?: TableOptions): BuntiContext;
405
+ /**
406
+ * 0→1 progress over `duration` ms. loop: true wraps, 'yoyo' bounces
407
+ * 0→1→0. Pass `id` for a restartable clock (restartAnimation).
408
+ * @example const t = ctx.animate(800, { loop: 'yoyo', easing: easeInOutCubic });
409
+ */
410
+ animate(duration: number, options?: {
411
+ loop?: boolean | 'yoyo';
412
+ delay?: number;
413
+ id?: string;
414
+ easing?: (t: number) => number;
415
+ }): number;
416
+ /** Interpolates between two colors at `progress` 0..1, returning RGB. */
417
+ fade(from: string | number | RGB, to: string | number | RGB, progress: number): RGB;
418
+ /** Types `text` out over time with a blinking block cursor. */
419
+ typewriter(text: string, options?: TypewriterOptions): TypewriterState;
420
+ /** Deterministic time-bucketed flicker (fps-independent). */
421
+ flicker(intensity?: number, options?: {
422
+ id?: string;
423
+ interval?: number;
424
+ }): boolean;
425
+ /**
426
+ * Fetches async data without blocking the render loop: kicks off the
427
+ * fetcher (re-running every `interval` ms when set) and returns the
428
+ * latest { data, loading, error } snapshot each frame. Prefer the keyed
429
+ * form; the keyless form is positional.
430
+ * @example const { data, loading } = ctx.useAsync('stats', fetchStats, { interval: 5000 });
431
+ */
432
+ useAsync<T>(fetcher: () => Promise<T>, options?: {
433
+ interval?: number;
434
+ }): {
435
+ data: T | undefined;
436
+ loading: boolean;
437
+ error: Error | undefined;
438
+ };
439
+ useAsync<T>(key: string, fetcher: () => Promise<T>, options?: {
440
+ interval?: number;
441
+ }): {
442
+ data: T | undefined;
443
+ loading: boolean;
444
+ error: Error | undefined;
445
+ };
446
+ /**
447
+ * Stops the render loop and restores the terminal (the promise returned
448
+ * by render() then resolves). Also triggered by Ctrl+C.
449
+ * @example if (ctx.lastKey === 'q') ctx.requestStop();
450
+ */
451
+ requestStop(): void;
452
+ /** Flushes the pending flow to the buffer (called by render(); rare). */
453
+ flushFlow(): void;
454
+ /** Milliseconds since the previous frame, clamped to 100 (0 outside loop()). */
455
+ readonly dt: number;
456
+ /** Frame counter, incremented once per render tick (0 outside loop()). */
457
+ readonly frame: number;
458
+ /**
459
+ * Enter/exit progress keyed on a visibility flag. progress runs 0→1
460
+ * (eased) when `visible` turns on and 1→0 when it turns off; `mounted`
461
+ * stays true through the exit so callers keep rendering while animating
462
+ * out. THE primitive for modal/panel entrances and exits.
463
+ * @example const { progress, mounted } = ctx.transition('panel', open, { duration: 200 });
464
+ */
465
+ transition(id: string, visible: boolean, options?: {
466
+ duration?: number;
467
+ easing?: (t: number) => number;
468
+ exitDuration?: number;
469
+ }): {
470
+ progress: number;
471
+ mounted: boolean;
472
+ };
473
+ /**
474
+ * Cascading entrance progress: item `index` starts index*delay ms into
475
+ * the timeline and animates for `duration` ms. Pass `id` to drive it from
476
+ * an animate()-style clock (restartable via restartAnimation).
477
+ * @example rows.forEach((row, i) => draw(row, ctx.stagger(i, { delay: 60, duration: 240 })));
478
+ */
479
+ stagger(index: number, options: {
480
+ delay: number;
481
+ duration: number;
482
+ easing?: (t: number) => number;
483
+ id?: string;
484
+ }): number;
485
+ /** Resets an animate()/typewriter()/stagger() id clock to "now". */
486
+ restartAnimation(id: string): void;
487
+ }
488
+ /**
489
+ * Bounds for ctx.hitbox(): a RectInput plus flow anchoring.
490
+ */
491
+ export interface HitboxBounds extends RectInput {
492
+ /**
493
+ * Anchors the hitbox to the text flow: x/y are the flow (column, line)
494
+ * where the owning content begins, and the enclosing direct-rendered box
495
+ * re-places the rect at paint time so content alignment (align/valign,
496
+ * auto-height centering) can never separate the hitbox from the painted
497
+ * cells. Components (Button/Input/Link) pass this for their flow
498
+ * placement; app code with explicit coordinates rarely needs it.
499
+ */
500
+ flow?: boolean;
501
+ }
502
+ /** One hitbox registered inside a pending direct-box paint (see HitboxFrame). */
503
+ export interface HitboxEntry {
504
+ /** The live Hitbox object in state.hitboxes (mutated by the fixup). */
505
+ box: Hitbox;
506
+ /** Flow anchor (content-local line/column) for flow-placed hitboxes. */
507
+ flow?: {
508
+ line: number;
509
+ col: number;
510
+ };
511
+ }
512
+ /**
513
+ * Hitboxes registered while a direct box renders its callback. Once the
514
+ * box's painted rect is known (content measured, alignment applied), the
515
+ * renderer re-places every captured entry so registered hitboxes exactly
516
+ * match the painted cells.
517
+ */
518
+ export interface HitboxFrame {
519
+ entries: HitboxEntry[];
520
+ }
521
+ /**
522
+ * The DSL state container allowing stable references with dynamic capture targets.
523
+ */
524
+ export interface DSLState {
525
+ /** Text-flow fragments accumulated for the active capture target. */
526
+ activeContents: string[];
527
+ /** Saved capture targets for nested box/span closures. */
528
+ stack: string[][];
529
+ /** Layers queued this frame, composited by flushFlow. */
530
+ layers: RenderLayer[];
531
+ /** Monotonic tiebreaker so equal z-indexes keep declaration order. */
532
+ layerOrder: number;
533
+ /** Stack of subtree theme overrides pushed by ctx.themed(). */
534
+ themeStack: Theme[];
535
+ /** Direct-rendered box areas this frame (root only; dev diagnostics). */
536
+ boxRects?: Rect[];
537
+ /** Pending direct-box hitbox fixups (innermost frame last). */
538
+ hitboxFrames?: HitboxFrame[];
539
+ }
540
+ /** One queued overlay buffer awaiting composite (see ctx.layer()). */
541
+ export interface RenderLayer {
542
+ /** Composite order: higher paints later (on top). */
543
+ zIndex: number;
544
+ /** Declaration-order tiebreaker for equal z-indexes. */
545
+ order: number;
546
+ /** The layer's transparent cell buffer. */
547
+ buffer: Cell[];
548
+ /** Composite-time drop shadow under the painted bounds. */
549
+ shadow?: boolean;
550
+ /** Composite-time whole-screen dim (0..1) below this layer. */
551
+ backdrop?: number;
552
+ /** Tight bounds of the layer's painted cells (null when empty). */
553
+ bounds: Rect | null;
554
+ }
555
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dsl/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,IAAI,EACJ,SAAS,EACT,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACb,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;IAgBf,4EAA4E;;IAE5E,wDAAwD;;IAExD,0DAA0D;;CAE3D,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,wFAAwF;IACxF,OAAO,CAAC,E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IAClB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;CAC9B;AAED,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,MAAM,EAAE,IAAI,EAAE,CAAC;IACf,2DAA2D;IAC3D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;CACrB"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Bunti DSL shared types and constants.
3
+ */
4
+ /**
5
+ * Normalized key-name constants for `ctx.lastKey` / `ctx.keyPressed()`.
6
+ * Printable keys are their literal character ('a', 'A', ' '); mouse events
7
+ * arrive as the 'click' / 'wheel_up' / 'wheel_down' pseudo-keys.
8
+ * @example if (ctx.keyPressed(KEYS.ENTER)) submit();
9
+ */
10
+ export const KEYS = {
11
+ UP: 'up',
12
+ DOWN: 'down',
13
+ RIGHT: 'right',
14
+ LEFT: 'left',
15
+ ENTER: 'enter',
16
+ ESCAPE: 'escape',
17
+ TAB: 'tab',
18
+ BACKSPACE: 'backspace',
19
+ SPACE: ' ',
20
+ HOME: 'home',
21
+ END: 'end',
22
+ DELETE: 'delete',
23
+ PAGE_UP: 'pageup',
24
+ PAGE_DOWN: 'pagedown',
25
+ INSERT: 'insert',
26
+ /** Left-button click (emitted once, on release; requires `mouse: true`). */
27
+ CLICK: 'click',
28
+ /** Mouse wheel scrolled up (requires `mouse: true`). */
29
+ WHEEL_UP: 'wheel_up',
30
+ /** Mouse wheel scrolled down (requires `mouse: true`). */
31
+ WHEEL_DOWN: 'wheel_down',
32
+ };
33
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/dsl/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAsBH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;IACV,SAAS,EAAE,WAAW;IACtB,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,QAAQ;IACjB,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,QAAQ;IAChB,4EAA4E;IAC5E,KAAK,EAAE,OAAO;IACd,wDAAwD;IACxD,QAAQ,EAAE,UAAU;IACpB,0DAA0D;IAC1D,UAAU,EAAE,YAAY;CACzB,CAAC"}