@visulima/tui 1.0.0-alpha.4 → 1.0.0-alpha.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 (249) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE.md +140 -0
  3. package/dist/core/index.d.ts +58 -5
  4. package/dist/ink/index.d.ts +6592 -294
  5. package/dist/ink/index.js +1 -1
  6. package/dist/packem_shared/{Histogram-cgAjY5AJ.js → Histogram-CB6XcmZW.js} +1 -1
  7. package/dist/packem_shared/input.d-Bfq7oc06.d.ts +90 -0
  8. package/dist/packem_shared/render.d-CNIzVQTh.d.ts +1257 -0
  9. package/dist/react/index.d.ts +519 -8
  10. package/dist/testing/index.d.ts +274 -135
  11. package/package.json +15 -16
  12. package/dist/core/app.d.ts +0 -50
  13. package/dist/core/cell.d.ts +0 -33
  14. package/dist/core/inline.d.ts +0 -22
  15. package/dist/core/input.d.ts +0 -18
  16. package/dist/core/native-binding.d.ts +0 -22
  17. package/dist/ink/ansi-to-cell.d.ts +0 -5
  18. package/dist/ink/ansi-tokenizer.d.ts +0 -38
  19. package/dist/ink/canvas/braille.d.ts +0 -22
  20. package/dist/ink/canvas/buffer.d.ts +0 -67
  21. package/dist/ink/clipboard.d.ts +0 -29
  22. package/dist/ink/color-matrix.d.ts +0 -49
  23. package/dist/ink/color-utils.d.ts +0 -30
  24. package/dist/ink/colorize.d.ts +0 -4
  25. package/dist/ink/components/accessibility-context.d.ts +0 -4
  26. package/dist/ink/components/accordion.d.ts +0 -52
  27. package/dist/ink/components/alert.d.ts +0 -30
  28. package/dist/ink/components/animate-presence.d.ts +0 -15
  29. package/dist/ink/components/animation-context.d.ts +0 -10
  30. package/dist/ink/components/app-context.d.ts +0 -38
  31. package/dist/ink/components/app.d.ts +0 -19
  32. package/dist/ink/components/approval-prompt.d.ts +0 -55
  33. package/dist/ink/components/area-chart.d.ts +0 -54
  34. package/dist/ink/components/background-context.d.ts +0 -5
  35. package/dist/ink/components/badge.d.ts +0 -27
  36. package/dist/ink/components/bar-chart.d.ts +0 -57
  37. package/dist/ink/components/big-text.d.ts +0 -71
  38. package/dist/ink/components/blink-dot.d.ts +0 -30
  39. package/dist/ink/components/box.d.ts +0 -58
  40. package/dist/ink/components/breadcrumb.d.ts +0 -28
  41. package/dist/ink/components/button.d.ts +0 -38
  42. package/dist/ink/components/calendar.d.ts +0 -60
  43. package/dist/ink/components/canvas.d.ts +0 -38
  44. package/dist/ink/components/card.d.ts +0 -46
  45. package/dist/ink/components/chart-utils.d.ts +0 -54
  46. package/dist/ink/components/checkbox.d.ts +0 -39
  47. package/dist/ink/components/code.d.ts +0 -46
  48. package/dist/ink/components/collapsible.d.ts +0 -43
  49. package/dist/ink/components/command-block.d.ts +0 -38
  50. package/dist/ink/components/command-palette.d.ts +0 -72
  51. package/dist/ink/components/confirm-dialog.d.ts +0 -63
  52. package/dist/ink/components/confirm-input.d.ts +0 -40
  53. package/dist/ink/components/console-overlay.d.ts +0 -52
  54. package/dist/ink/components/content-switcher.d.ts +0 -49
  55. package/dist/ink/components/cursor-context.d.ts +0 -12
  56. package/dist/ink/components/cursor.d.ts +0 -43
  57. package/dist/ink/components/date-picker.d.ts +0 -53
  58. package/dist/ink/components/definition-list.d.ts +0 -37
  59. package/dist/ink/components/dialog.d.ts +0 -93
  60. package/dist/ink/components/diff-view.d.ts +0 -71
  61. package/dist/ink/components/divider.d.ts +0 -40
  62. package/dist/ink/components/error-boundary.d.ts +0 -17
  63. package/dist/ink/components/error-overview.d.ts +0 -6
  64. package/dist/ink/components/file-picker/file-picker.d.ts +0 -58
  65. package/dist/ink/components/file-picker/types.d.ts +0 -35
  66. package/dist/ink/components/file-picker/use-file-system.d.ts +0 -16
  67. package/dist/ink/components/focus-context.d.ts +0 -17
  68. package/dist/ink/components/form.d.ts +0 -74
  69. package/dist/ink/components/gauge.d.ts +0 -75
  70. package/dist/ink/components/gradient.d.ts +0 -38
  71. package/dist/ink/components/heading.d.ts +0 -27
  72. package/dist/ink/components/heatmap.d.ts +0 -51
  73. package/dist/ink/components/help.d.ts +0 -44
  74. package/dist/ink/components/histogram.d.ts +0 -52
  75. package/dist/ink/components/kbd.d.ts +0 -27
  76. package/dist/ink/components/line-chart.d.ts +0 -94
  77. package/dist/ink/components/link.d.ts +0 -34
  78. package/dist/ink/components/loading-indicator.d.ts +0 -24
  79. package/dist/ink/components/markdown.d.ts +0 -34
  80. package/dist/ink/components/masked-input.d.ts +0 -41
  81. package/dist/ink/components/menu.d.ts +0 -70
  82. package/dist/ink/components/message-bubble.d.ts +0 -35
  83. package/dist/ink/components/model-badge.d.ts +0 -32
  84. package/dist/ink/components/multi-select.d.ts +0 -63
  85. package/dist/ink/components/newline.d.ts +0 -12
  86. package/dist/ink/components/operation-tree.d.ts +0 -46
  87. package/dist/ink/components/option-list.d.ts +0 -41
  88. package/dist/ink/components/ordered-list.d.ts +0 -30
  89. package/dist/ink/components/paginator.d.ts +0 -59
  90. package/dist/ink/components/paragraph.d.ts +0 -31
  91. package/dist/ink/components/placeholder.d.ts +0 -47
  92. package/dist/ink/components/progress-bar.d.ts +0 -51
  93. package/dist/ink/components/radio-group.d.ts +0 -62
  94. package/dist/ink/components/scatter-plot.d.ts +0 -23
  95. package/dist/ink/components/scroll/controlled-scroll-view.d.ts +0 -43
  96. package/dist/ink/components/scroll/index.d.ts +0 -10
  97. package/dist/ink/components/scroll/scroll-bar-box.d.ts +0 -15
  98. package/dist/ink/components/scroll/scroll-bar.d.ts +0 -20
  99. package/dist/ink/components/scroll/scroll-list.d.ts +0 -12
  100. package/dist/ink/components/scroll/scroll-view.d.ts +0 -98
  101. package/dist/ink/components/scroll/use-state-ref.d.ts +0 -8
  102. package/dist/ink/components/search-input.d.ts +0 -46
  103. package/dist/ink/components/select-input-indicator.d.ts +0 -36
  104. package/dist/ink/components/select-input-item.d.ts +0 -43
  105. package/dist/ink/components/select-input.d.ts +0 -96
  106. package/dist/ink/components/shimmer-text.d.ts +0 -39
  107. package/dist/ink/components/slider.d.ts +0 -92
  108. package/dist/ink/components/spacer.d.ts +0 -7
  109. package/dist/ink/components/sparkline.d.ts +0 -30
  110. package/dist/ink/components/spinner.d.ts +0 -40
  111. package/dist/ink/components/static-render.d.ts +0 -40
  112. package/dist/ink/components/static.d.ts +0 -24
  113. package/dist/ink/components/status-line.d.ts +0 -30
  114. package/dist/ink/components/status-message.d.ts +0 -26
  115. package/dist/ink/components/stderr-context.d.ts +0 -16
  116. package/dist/ink/components/stdin-context.d.ts +0 -29
  117. package/dist/ink/components/stdout-context.d.ts +0 -16
  118. package/dist/ink/components/stepper.d.ts +0 -42
  119. package/dist/ink/components/stopwatch.d.ts +0 -42
  120. package/dist/ink/components/streaming-text.d.ts +0 -38
  121. package/dist/ink/components/switch.d.ts +0 -46
  122. package/dist/ink/components/tab.d.ts +0 -25
  123. package/dist/ink/components/table.d.ts +0 -80
  124. package/dist/ink/components/tabs.d.ts +0 -104
  125. package/dist/ink/components/tag.d.ts +0 -30
  126. package/dist/ink/components/text-input.d.ts +0 -48
  127. package/dist/ink/components/text.d.ts +0 -63
  128. package/dist/ink/components/textarea.d.ts +0 -62
  129. package/dist/ink/components/timer.d.ts +0 -50
  130. package/dist/ink/components/toast.d.ts +0 -41
  131. package/dist/ink/components/tooltip.d.ts +0 -36
  132. package/dist/ink/components/transform.d.ts +0 -16
  133. package/dist/ink/components/transition.d.ts +0 -53
  134. package/dist/ink/components/tree-view/theme.d.ts +0 -24
  135. package/dist/ink/components/tree-view/tree-node-map.d.ts +0 -72
  136. package/dist/ink/components/tree-view/tree-view-node.d.ts +0 -29
  137. package/dist/ink/components/tree-view/tree-view.d.ts +0 -89
  138. package/dist/ink/components/tree-view/types.d.ts +0 -55
  139. package/dist/ink/components/tree-view/use-tree-view-state.d.ts +0 -135
  140. package/dist/ink/components/tree-view/use-tree-view.d.ts +0 -26
  141. package/dist/ink/components/unordered-list.d.ts +0 -35
  142. package/dist/ink/components/variant-config.d.ts +0 -10
  143. package/dist/ink/cursor-helpers.d.ts +0 -35
  144. package/dist/ink/data-limited-lru-map.d.ts +0 -21
  145. package/dist/ink/devtools-window-polyfill.d.ts +0 -1
  146. package/dist/ink/devtools.d.ts +0 -1
  147. package/dist/ink/dom.d.ts +0 -214
  148. package/dist/ink/get-max-width.d.ts +0 -3
  149. package/dist/ink/highlighter.d.ts +0 -28
  150. package/dist/ink/hooks/use-animation.d.ts +0 -41
  151. package/dist/ink/hooks/use-app.d.ts +0 -6
  152. package/dist/ink/hooks/use-box-metrics.d.ts +0 -58
  153. package/dist/ink/hooks/use-clipboard.d.ts +0 -29
  154. package/dist/ink/hooks/use-color-blindness.d.ts +0 -33
  155. package/dist/ink/hooks/use-console-capture.d.ts +0 -43
  156. package/dist/ink/hooks/use-cursor.d.ts +0 -12
  157. package/dist/ink/hooks/use-focus-manager.d.ts +0 -42
  158. package/dist/ink/hooks/use-focus.d.ts +0 -30
  159. package/dist/ink/hooks/use-form.d.ts +0 -70
  160. package/dist/ink/hooks/use-hotkey.d.ts +0 -37
  161. package/dist/ink/hooks/use-input.d.ts +0 -149
  162. package/dist/ink/hooks/use-interval.d.ts +0 -25
  163. package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +0 -6
  164. package/dist/ink/hooks/use-key-bindings.d.ts +0 -59
  165. package/dist/ink/hooks/use-key-chord.d.ts +0 -26
  166. package/dist/ink/hooks/use-linked-scroll.d.ts +0 -41
  167. package/dist/ink/hooks/use-paste.d.ts +0 -44
  168. package/dist/ink/hooks/use-persistent-state.d.ts +0 -56
  169. package/dist/ink/hooks/use-scroll-acceleration.d.ts +0 -47
  170. package/dist/ink/hooks/use-scroll-input.d.ts +0 -34
  171. package/dist/ink/hooks/use-stderr.d.ts +0 -6
  172. package/dist/ink/hooks/use-stdin.d.ts +0 -7
  173. package/dist/ink/hooks/use-stdout.d.ts +0 -6
  174. package/dist/ink/hooks/use-stopwatch.d.ts +0 -38
  175. package/dist/ink/hooks/use-terminal-palette.d.ts +0 -19
  176. package/dist/ink/hooks/use-text-buffer.d.ts +0 -42
  177. package/dist/ink/hooks/use-text-selection.d.ts +0 -45
  178. package/dist/ink/hooks/use-timeout.d.ts +0 -24
  179. package/dist/ink/hooks/use-timer.d.ts +0 -47
  180. package/dist/ink/hooks/use-window-size.d.ts +0 -18
  181. package/dist/ink/ime-utils.d.ts +0 -25
  182. package/dist/ink/ink.d.ts +0 -190
  183. package/dist/ink/input-parser.d.ts +0 -10
  184. package/dist/ink/input-utils.d.ts +0 -16
  185. package/dist/ink/instances.d.ts +0 -3
  186. package/dist/ink/kitty-keyboard.d.ts +0 -23
  187. package/dist/ink/layout.d.ts +0 -26
  188. package/dist/ink/log-update-native.d.ts +0 -14
  189. package/dist/ink/log-update.d.ts +0 -21
  190. package/dist/ink/measure-element.d.ts +0 -147
  191. package/dist/ink/measure-text.d.ts +0 -56
  192. package/dist/ink/mouse/ansi-parser.d.ts +0 -37
  193. package/dist/ink/mouse/constants.d.ts +0 -14
  194. package/dist/ink/mouse/fullscreen.d.ts +0 -8
  195. package/dist/ink/mouse/index.d.ts +0 -20
  196. package/dist/ink/mouse/is-intersecting.d.ts +0 -18
  197. package/dist/ink/mouse/mouse-context.d.ts +0 -36
  198. package/dist/ink/mouse/mouse-provider.d.ts +0 -11
  199. package/dist/ink/mouse/use-element-position.d.ts +0 -29
  200. package/dist/ink/mouse/use-mouse-action.d.ts +0 -7
  201. package/dist/ink/mouse/use-mouse-position.d.ts +0 -7
  202. package/dist/ink/mouse/use-mouse.d.ts +0 -7
  203. package/dist/ink/mouse/use-on-mouse-click.d.ts +0 -14
  204. package/dist/ink/mouse/use-on-mouse-hover.d.ts +0 -8
  205. package/dist/ink/mouse/use-on-mouse-state.d.ts +0 -11
  206. package/dist/ink/output.d.ts +0 -75
  207. package/dist/ink/parse-keypress.d.ts +0 -22
  208. package/dist/ink/reconciler.d.ts +0 -3
  209. package/dist/ink/region.d.ts +0 -99
  210. package/dist/ink/render-background.d.ts +0 -4
  211. package/dist/ink/render-border.d.ts +0 -4
  212. package/dist/ink/render-node-to-output.d.ts +0 -38
  213. package/dist/ink/render-scrollbar.d.ts +0 -9
  214. package/dist/ink/render-sticky.d.ts +0 -44
  215. package/dist/ink/render-to-string.d.ts +0 -37
  216. package/dist/ink/render.d.ts +0 -191
  217. package/dist/ink/renderer.d.ts +0 -17
  218. package/dist/ink/resize-observer.d.ts +0 -44
  219. package/dist/ink/sanitize-ansi.d.ts +0 -2
  220. package/dist/ink/scroll.d.ts +0 -23
  221. package/dist/ink/selection.d.ts +0 -70
  222. package/dist/ink/squash-text-nodes.d.ts +0 -18
  223. package/dist/ink/style-flags.d.ts +0 -17
  224. package/dist/ink/styled-line-factory.d.ts +0 -25
  225. package/dist/ink/styled-line-serializer.d.ts +0 -18
  226. package/dist/ink/styled-line.d.ts +0 -119
  227. package/dist/ink/styles.d.ts +0 -369
  228. package/dist/ink/terminal-palette.d.ts +0 -25
  229. package/dist/ink/text-wrap.d.ts +0 -10
  230. package/dist/ink/token-to-elements.d.ts +0 -22
  231. package/dist/ink/utils/format-time.d.ts +0 -4
  232. package/dist/ink/utils.d.ts +0 -9
  233. package/dist/ink/wrap-text.d.ts +0 -3
  234. package/dist/ink/write-synchronized.d.ts +0 -4
  235. package/dist/react/devtools.d.ts +0 -27
  236. package/dist/react/focus.d.ts +0 -39
  237. package/dist/react/hooks.d.ts +0 -238
  238. package/dist/react/layout.d.ts +0 -33
  239. package/dist/react/react.d.ts +0 -57
  240. package/dist/react/reconciler.d.ts +0 -4
  241. package/dist/react/render-to-string.d.ts +0 -21
  242. package/dist/react/renderer.d.ts +0 -2
  243. package/dist/react/scene.d.ts +0 -3
  244. package/dist/react/static.d.ts +0 -39
  245. package/dist/react/styles.d.ts +0 -83
  246. package/dist/react/text-width.d.ts +0 -20
  247. package/dist/testing/keys.d.ts +0 -89
  248. package/dist/testing/screen.d.ts +0 -35
  249. package/dist/testing/wait-for.d.ts +0 -20
@@ -1,238 +0,0 @@
1
- import type { Context, RefObject } from "react";
2
- import type { InputParser, MouseEvent, TuiApp } from "../core/index.d.ts";
3
- import type { LayoutNode } from "./layout.d.ts";
4
- export interface TuiContextProps {
5
- app: TuiApp;
6
- input: InputParser;
7
- writeStderr: (text: string) => void;
8
- writeStdout: (text: string) => void;
9
- }
10
- export declare const TuiContext: Context<TuiContextProps | null>;
11
- export interface Key {
12
- backspace: boolean;
13
- ctrl: boolean;
14
- delete: boolean;
15
- downArrow: boolean;
16
- end: boolean;
17
- escape: boolean;
18
- home: boolean;
19
- leftArrow: boolean;
20
- meta: boolean;
21
- pageDown: boolean;
22
- pageUp: boolean;
23
- return: boolean;
24
- rightArrow: boolean;
25
- shift: boolean;
26
- tab: boolean;
27
- upArrow: boolean;
28
- }
29
- export type InputHandler = (input: string, key: Key) => void;
30
- /**
31
- * Subscribes to keyboard input. Uses a stable ref so the effect runs
32
- * exactly once (on mount) regardless of how often the component re-renders.
33
- * Always invokes the latest handler passed by the caller.
34
- */
35
- export declare const useInput: (handler: InputHandler) => void;
36
- export interface UsePasteOptions {
37
- /**
38
- * Enable or disable capturing pasted text.
39
- * Useful when multiple components use usePaste and only one should be active.
40
- * @default true
41
- */
42
- isActive?: boolean;
43
- }
44
- export type PasteHandler = (text: string) => void;
45
- /**
46
- * Subscribe to bracketed paste events.
47
- *
48
- * `usePaste` and `useInput` can be used together. Paste content is delivered
49
- * through this hook and not forwarded to useInput while at least one paste
50
- * listener is active.
51
- */
52
- export declare const usePaste: (handler: PasteHandler, options?: UsePasteOptions) => void;
53
- /**
54
- * Raw access to the TuiContext — app instance + input parser.
55
- * Useful for advanced integrations (e.g. DevTools, custom hooks).
56
- */
57
- export declare const useTuiContext: () => TuiContextProps;
58
- /**
59
- * Access app controls. Returns { exit } for Ink compatibility.
60
- * exit() triggers a clean shutdown (restores terminal, stops input, exits process).
61
- */
62
- export declare const useApp: () => {
63
- exit: () => void;
64
- quit: () => void;
65
- };
66
- /**
67
- * Returns current terminal dimensions and re-renders on resize (SIGWINCH).
68
- * Ink-compatible: const { columns, rows } = useWindowSize()
69
- */
70
- export declare const useWindowSize: () => {
71
- columns: number;
72
- rows: number;
73
- };
74
- /**
75
- * Write to stdout without disturbing the TUI.
76
- * Ink-compatible: const { write, stdout } = useStdout()
77
- * Output is buffered while the alternate screen is active and flushed on exit.
78
- */
79
- export declare const useStdout: () => {
80
- stdout: NodeJS.WriteStream & {
81
- fd: 1;
82
- };
83
- write: (text: string) => void;
84
- };
85
- /**
86
- * Write to stderr without disturbing the TUI.
87
- * Ink-compatible: const { write, stderr } = useStderr()
88
- * Output is buffered while the alternate screen is active and flushed on exit.
89
- */
90
- export declare const useStderr: () => {
91
- stderr: NodeJS.WriteStream & {
92
- fd: 2;
93
- };
94
- write: (text: string) => void;
95
- };
96
- /**
97
- * Access raw stdin stream and raw mode controls.
98
- * Ink-compatible: const { stdin, setRawMode, isRawModeSupported } = useStdin()
99
- */
100
- export declare const useStdin: () => {
101
- isRawModeSupported: boolean;
102
- setRawMode: (value: boolean) => void;
103
- stdin: NodeJS.ReadStream & {
104
- fd: 0;
105
- };
106
- };
107
- /**
108
- * Measure the dimensions of a Box element.
109
- * Returns { width, height } after layout has been calculated.
110
- * Returns { width: 0, height: 0 } when called during render (before layout).
111
- * Ink-compatible: measureElement(ref.current)
112
- */
113
- export declare const measureElement: (node: LayoutNode | null) => {
114
- height: number;
115
- width: number;
116
- };
117
- export interface BoxMetrics {
118
- readonly height: number;
119
- readonly left: number;
120
- readonly top: number;
121
- readonly width: number;
122
- }
123
- export interface UseBoxMetricsResult extends BoxMetrics {
124
- readonly hasMeasured: boolean;
125
- }
126
- /**
127
- * Returns the current layout metrics for a Box ref, updating on every render
128
- * and on terminal resize.
129
- * Ink-compatible: const { width, height, left, top, hasMeasured } = useBoxMetrics(ref)
130
- */
131
- export declare const useBoxMetrics: (ref: RefObject<LayoutNode | null>) => UseBoxMetricsResult;
132
- /**
133
- * Returns whether a screen reader is enabled.
134
- * Stub: always returns false — no screen reader support.
135
- * Ink-compatible: const isEnabled = useIsScreenReaderEnabled()
136
- */
137
- export declare const useIsScreenReaderEnabled: () => boolean;
138
- /**
139
- * Returns cursor positioning controls.
140
- * Stub: the native renderer hides the cursor during rendering (alternate screen).
141
- * setCursorPosition is a no-op — provided for Ink API compatibility only.
142
- * Ink-compatible: const { setCursorPosition } = useCursor()
143
- */
144
- export declare const useCursor: () => {
145
- setCursorPosition: (position: {
146
- x: number;
147
- y: number;
148
- } | undefined) => void;
149
- };
150
- /**
151
- * Scroll state for a fixed-height viewport over variable-height content.
152
- *
153
- * Usage:
154
- * const scroll = useScrollable({ viewportHeight: 20, contentHeight: totalRows })
155
- *
156
- * &lt;Box height={20}>
157
- * &lt;Box marginTop={-scroll.offset}>
158
- * {items}
159
- * &lt;/Box>
160
- * &lt;/Box>
161
- *
162
- * contentHeight can be updated as content grows. The offset is automatically
163
- * clamped so it never scrolls past the end.
164
- *
165
- * scrollToBottom() is idempotent — safe to call on every new message append.
166
- */
167
- export interface UseScrollableOptions {
168
- /** Total height of the content in rows — update as content grows */
169
- contentHeight: number;
170
- /** Height of the visible window in rows */
171
- viewportHeight: number;
172
- }
173
- export interface UseScrollableResult {
174
- /** True when already at the bottom */
175
- atBottom: boolean;
176
- /** True when already at the top */
177
- atTop: boolean;
178
- /** Current scroll offset in rows (0 = top) */
179
- offset: number;
180
- /** Scroll down N rows */
181
- scrollBy: (n: number) => void;
182
- /** Scroll down one row */
183
- scrollDown: () => void;
184
- /** Jump to the very bottom */
185
- scrollToBottom: () => void;
186
- /** Jump to the very top */
187
- scrollToTop: () => void;
188
- /** Scroll up one row */
189
- scrollUp: () => void;
190
- }
191
- export declare const useScrollable: ({ contentHeight, viewportHeight }: UseScrollableOptions) => UseScrollableResult;
192
- export type MouseHandler = (event: MouseEvent) => void;
193
- /**
194
- * Subscribe to mouse events. Requires mouse tracking to be enabled (it is by
195
- * default — TerminalGuard enables SGR 1006 mouse tracking on start).
196
- *
197
- * Usage:
198
- * useMouse((event) => {
199
- * if (event.button === 'left') { ... }
200
- * if (event.button === 'scrollUp') { ... }
201
- * // event: { x, y, button, shift, ctrl, meta }
202
- * })
203
- *
204
- * button values: 'left' | 'right' | 'middle' | 'scrollUp' | 'scrollDown'
205
- */
206
- export declare const useMouse: (handler: MouseHandler) => void;
207
- export interface UseTextInputOptions {
208
- /** Initial value (default: '') */
209
- initialValue?: string;
210
- /** When false, the hook ignores all input (default: true) */
211
- isActive?: boolean;
212
- /** Called on every keystroke with the new value */
213
- onChange?: (value: string) => void;
214
- /** Called when the user presses Enter */
215
- onSubmit?: (value: string) => void;
216
- }
217
- export interface UseTextInputResult {
218
- /** Clear the input */
219
- clear: () => void;
220
- /** Cursor position (0 = before first char, value.length = after last char) */
221
- cursor: number;
222
- /** Set value programmatically */
223
- setValue: (value: string) => void;
224
- /** Current text value */
225
- value: string;
226
- }
227
- /**
228
- * Managed text input with cursor, backspace, delete, left/right navigation,
229
- * home/end, bracketed paste, and submit on Enter.
230
- *
231
- * Usage:
232
- * const { value, cursor } = useTextInput({ onSubmit: (v) => console.log(v) })
233
- * &lt;Text>{value.slice(0, cursor)}&lt;Text inverse> &lt;/Text>{value.slice(cursor)}&lt;/Text>
234
- *
235
- * Renders a block cursor by inverting the character at cursor position.
236
- * When cursor is at end, renders a trailing space as the cursor block.
237
- */
238
- export declare const useTextInput: ({ initialValue, isActive, onChange, onSubmit }?: UseTextInputOptions) => UseTextInputResult;
@@ -1,33 +0,0 @@
1
- import Yoga from "yoga-layout";
2
- type YogaNode = ReturnType<typeof Yoga.Node.create>;
3
- export declare class LayoutNode {
4
- yogaNode: YogaNode;
5
- children: LayoutNode[];
6
- parent: LayoutNode | null;
7
- private _destroyed;
8
- _hidden: boolean;
9
- transform?: (s: string, index: number) => string;
10
- private _text?;
11
- fg: number;
12
- bg: number;
13
- styles: number;
14
- _style?: any;
15
- set text(value: string | undefined);
16
- get text(): string | undefined;
17
- constructor();
18
- insertChild(child: LayoutNode, index: number): void;
19
- remove(): void;
20
- removeChild(child: LayoutNode): void;
21
- /**
22
- * Free this node's Yoga allocation. Called via detachDeletedInstance
23
- * in the reconciler after React has permanently removed this node.
24
- *
25
- * Does NOT recurse — React calls detachDeletedInstance on every node
26
- * in a deleted subtree individually, so each node frees only itself.
27
- * The _destroyed guard prevents double-free if free() is also called.
28
- */
29
- destroy(): void;
30
- calculateLayout(width: number, height: number): void;
31
- getLayout(): ReturnType<YogaNode["getComputedLayout"]>;
32
- }
33
- export {};
@@ -1,57 +0,0 @@
1
- import React from "react";
2
- import type { InlineOptions } from "../core/index.d.ts";
3
- import { InputParser, TuiApp } from "../core/index.d.ts";
4
- /** @internal */
5
- export declare const _Box: React.FC<Record<string, any>>;
6
- /** @internal */
7
- export declare const _Text: React.FC<Record<string, any>>;
8
- /** @internal */
9
- export declare const _Spacer: React.FC;
10
- /** Ink-compat render options */
11
- export interface RenderOptions {
12
- /** Ignored — the native renderer is always concurrent */
13
- concurrent?: boolean;
14
- /** Ignored */
15
- debug?: boolean;
16
- /** Ignored — Ctrl+C always exits */
17
- exitOnCtrlC?: boolean;
18
- /** Ignored */
19
- incrementalRendering?: boolean;
20
- /** Target frames per second for the render loop. Default: 60 */
21
- maxFps?: number;
22
- /** Ignored — the native renderer always patches console */
23
- patchConsole?: boolean;
24
- }
25
- /** Return value of render() — Ink-compatible instance handle */
26
- export interface Instance {
27
- /** Internal: direct app access */
28
- app: TuiApp;
29
- /** Internal: input parser */
30
- input: InputParser;
31
- rerender: (element: React.ReactElement) => void;
32
- unmount: () => void;
33
- waitUntilExit: () => Promise<void>;
34
- }
35
- export declare function render(element: React.ReactElement, options?: RenderOptions): Instance;
36
- export interface InlineInstance {
37
- /** Unmount the React tree and stop the render loop */
38
- unmount: () => void;
39
- /** Resolves when the loop exits */
40
- waitUntilExit: () => Promise<void>;
41
- }
42
- /**
43
- * Render a React element inline — no alternate screen. The UI appears
44
- * directly below the current shell prompt and stays in terminal scrollback
45
- * on exit (or is destroyed if `onExit: 'destroy'` is set).
46
- *
47
- * The root Box is sized to `cols × rows`. Use `useInput` and `useApp`
48
- * exactly as in a full-screen render.
49
- * @example
50
- * ```tsx
51
- * const { waitUntilExit } = renderInline(<Picker />, { rows: 12, onExit: 'destroy' })
52
- * await waitUntilExit()
53
- * ```
54
- */
55
- export declare function renderInline(element: React.ReactElement, options?: InlineOptions & {
56
- maxFps?: number;
57
- }): InlineInstance;
@@ -1,4 +0,0 @@
1
- import ReactReconciler from "react-reconciler";
2
- export declare let onAfterCommit: (() => void) | null;
3
- export declare function setOnAfterCommit(function_: (() => void) | null): void;
4
- export declare const TuiReconciler: ReturnType<typeof ReactReconciler>;
@@ -1,21 +0,0 @@
1
- import React from "react";
2
- export interface RenderToStringOptions {
3
- /** Width of the virtual terminal in columns. @default 80 */
4
- columns?: number;
5
- /** Height of the virtual terminal in rows. @default 24 */
6
- rows?: number;
7
- }
8
- /**
9
- * Render a React element to a plain string synchronously.
10
- * No TTY, no stdin, no alternate screen — pure layout + buffer read-back.
11
- *
12
- * Useful for testing, documentation generation, and any scenario where
13
- * you need rendered output as a string without a live terminal.
14
- *
15
- * Notes:
16
- * - Terminal hooks (useInput, useApp, useStdin, useStdout, useStderr,
17
- * useFocus, useFocusManager) return safe no-op defaults — they do not throw.
18
- * - useEffect callbacks run but state updates they trigger do not affect output.
19
- * - useLayoutEffect callbacks fire synchronously and DO affect output.
20
- */
21
- export declare function renderToString(element: React.ReactElement, options?: RenderToStringOptions): string;
@@ -1,2 +0,0 @@
1
- import type { LayoutNode } from "./layout.d.ts";
2
- export declare function renderTreeToBuffer(root: LayoutNode, buffer: Uint32Array, cols: number, rows: number): void;
@@ -1,3 +0,0 @@
1
- export * from "./layout.d.ts";
2
- export * from "./renderer.d.ts";
3
- export * from "./styles.d.ts";
@@ -1,39 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import React from "react";
3
- export type StaticProps<T> = {
4
- /**
5
- * Render function called for each item. Must assign a unique `key` to the
6
- * root element returned.
7
- */
8
- readonly children: (item: T, index: number) => ReactNode;
9
- /**
10
- * Array of items to render. Only newly-added items are rendered into the layout —
11
- * previously rendered items are frozen (never re-rendered or cleared).
12
- * Ideal for streaming output: completed tasks, log lines, test results.
13
- */
14
- readonly items: T[];
15
- /**
16
- * Optional styles for the static container Box.
17
- */
18
- readonly style?: Record<string, unknown>;
19
- };
20
- /**
21
- * `&lt;Static>` permanently renders its output above the dynamic UI.
22
- *
23
- * Items are rendered once and frozen — they are never re-rendered or cleared.
24
- * New items appended to `items` are rendered incrementally and accumulate
25
- * in the layout above the dynamic content.
26
- *
27
- * Matches the Ink `&lt;Static>` API exactly.
28
- * @example
29
- * ```tsx
30
- * <Static items={completedTasks}>
31
- * {task => (
32
- * <Box key={task.id}>
33
- * <Text color="green">✔ {task.title}</Text>
34
- * </Box>
35
- * )}
36
- * </Static>
37
- * ```
38
- */
39
- export declare function Static<T>({ children: renderItem, items, style }: StaticProps<T>): React.ReactElement;
@@ -1,83 +0,0 @@
1
- import Yoga from "yoga-layout";
2
- type YogaNode = ReturnType<typeof Yoga.Node.create>;
3
- export declare const NAMED_COLORS: Record<string, number>;
4
- /**
5
- * Resolve a color value to an ANSI 256-color index.
6
- * Accepts: number (pass-through), string name ("green"), hex ("#FF8800"),
7
- * rgb() ("rgb(255,136,0)"), ansi256() ("ansi256(42)"), or undefined (→ 255 = terminal default).
8
- */
9
- export declare function resolveColor(color: number | string | undefined): number;
10
- export type Styles = {
11
- alignContent?: "flex-start" | "flex-end" | "center" | "stretch" | "space-between" | "space-around";
12
- alignItems?: "flex-start" | "center" | "flex-end" | "stretch" | "baseline";
13
- alignSelf?: "flex-start" | "center" | "flex-end" | "auto" | "stretch" | "baseline";
14
- aspectRatio?: number;
15
- backgroundColor?: number | string;
16
- bg?: number | string;
17
- bold?: boolean;
18
- borderBottom?: boolean;
19
- borderBottomColor?: number | string;
20
- borderColor?: number | string;
21
- borderLeft?: boolean;
22
- borderLeftColor?: number | string;
23
- borderRight?: boolean;
24
- borderRightColor?: number | string;
25
- borderStyle?: "single" | "double" | "round" | "bold" | "singleDouble" | "doubleSingle" | "classic";
26
- borderTop?: boolean;
27
- borderTopColor?: number | string;
28
- bottom?: number | string;
29
- color?: number | string;
30
- columnGap?: number;
31
- dim?: boolean;
32
- display?: "flex" | "none";
33
- fg?: number | string;
34
- flexBasis?: number | string;
35
- flexDirection?: "row" | "column" | "row-reverse" | "column-reverse";
36
- flexGrow?: number;
37
- flexShrink?: number;
38
- flexWrap?: "nowrap" | "wrap" | "wrap-reverse";
39
- gap?: number;
40
- height?: number | string;
41
- /** Internal flag for sticky header alternate nodes */
42
- internalStickyAlternate?: boolean;
43
- inverse?: boolean;
44
- italic?: boolean;
45
- justifyContent?: "flex-start" | "flex-end" | "space-between" | "space-around" | "space-evenly" | "center";
46
- left?: number | string;
47
- margin?: number;
48
- marginBottom?: number;
49
- marginLeft?: number;
50
- marginRight?: number;
51
- marginTop?: number;
52
- marginX?: number;
53
- marginY?: number;
54
- maxHeight?: number | string;
55
- maxWidth?: number | string;
56
- minHeight?: number | string;
57
- minWidth?: number | string;
58
- overflow?: "hidden" | "scroll" | "visible";
59
- overflowX?: "hidden" | "scroll" | "visible";
60
- overflowY?: "hidden" | "scroll" | "visible";
61
- padding?: number;
62
- paddingBottom?: number;
63
- paddingLeft?: number;
64
- paddingRight?: number;
65
- paddingTop?: number;
66
- paddingX?: number;
67
- paddingY?: number;
68
- position?: "absolute" | "relative" | "static";
69
- right?: number | string;
70
- rowGap?: number;
71
- scrollbar?: boolean;
72
- scrollbarThumbColor?: string;
73
- scrollLeft?: number;
74
- scrollTop?: number;
75
- sticky?: boolean;
76
- strikethrough?: boolean;
77
- styles?: number;
78
- top?: number | string;
79
- underline?: boolean;
80
- width?: number | string;
81
- };
82
- export declare const applyStyles: (node: YogaNode, style?: Styles, currentStyle?: Styles) => void;
83
- export {};
@@ -1,20 +0,0 @@
1
- /** Display width of a single Unicode code point (at least 1 cell). */
2
- export declare function getCodePointWidth(char: string): number;
3
- /** Display width of a full string (sums grapheme widths). */
4
- export declare function getStringWidth(text: string): number;
5
- /**
6
- * Count wrapped visual rows for a single hard line (no '\n') at a fixed width.
7
- *
8
- * - Widths are measured in terminal cells, not UTF-16 code units.
9
- * - Wide chars (CJK/emoji) consume 2 cells.
10
- * - Empty lines still occupy one visual row.
11
- */
12
- export declare function countWrappedRowsForLine(line: string, width: number): number;
13
- /**
14
- * Measure the max visual line width and wrapped height of a text block.
15
- * Returns widths/heights in terminal cells/rows.
16
- */
17
- export declare function measureTextBlock(text: string, wrapWidth: number): {
18
- maxLineWidth: number;
19
- wrappedRows: number;
20
- };
@@ -1,89 +0,0 @@
1
- export declare const KEY: {
2
- readonly backspace: "";
3
- readonly ctrlC: "\u0003";
4
- readonly delete: "\u001B[3~";
5
- readonly down: "\u001B[B";
6
- readonly end: "\u001B[F";
7
- readonly escape: "\u001B";
8
- readonly home: "\u001B[H";
9
- readonly left: "\u001B[D";
10
- readonly pageDown: "\u001B[6~";
11
- readonly pageUp: "\u001B[5~";
12
- readonly return: "\r";
13
- readonly right: "\u001B[C";
14
- readonly space: " ";
15
- readonly tab: "\t";
16
- readonly up: "\u001B[A";
17
- };
18
- export type KeyName = keyof typeof KEY;
19
- export interface KeySender {
20
- /**
21
- * Simulate pressing the backspace key.
22
- */
23
- backspace: () => void;
24
- /**
25
- * Simulate pressing the delete key.
26
- */
27
- delete: () => void;
28
- /**
29
- * Simulate pressing the down arrow key.
30
- */
31
- down: () => void;
32
- /**
33
- * Simulate pressing the end key.
34
- */
35
- end: () => void;
36
- /**
37
- * Simulate pressing the enter/return key.
38
- */
39
- enter: () => void;
40
- /**
41
- * Simulate pressing the escape key.
42
- */
43
- escape: () => void;
44
- /**
45
- * Simulate pressing the home key.
46
- */
47
- home: () => void;
48
- /**
49
- * Simulate pressing the left arrow key.
50
- */
51
- left: () => void;
52
- /**
53
- * Simulate pressing the page down key.
54
- */
55
- pageDown: () => void;
56
- /**
57
- * Simulate pressing the page up key.
58
- */
59
- pageUp: () => void;
60
- /**
61
- * Send a single character as a key press.
62
- */
63
- press: (char: string) => void;
64
- /**
65
- * Send arbitrary raw data to stdin.
66
- */
67
- raw: (data: string) => void;
68
- /**
69
- * Simulate pressing the right arrow key.
70
- */
71
- right: () => void;
72
- /**
73
- * Simulate pressing the space key.
74
- */
75
- space: () => void;
76
- /**
77
- * Simulate pressing the tab key.
78
- */
79
- tab: () => void;
80
- /**
81
- * Type a string character by character.
82
- */
83
- type: (text: string) => void;
84
- /**
85
- * Simulate pressing the up arrow key.
86
- */
87
- up: () => void;
88
- }
89
- export declare const createKeySender: (write: (data: string) => void) => KeySender;
@@ -1,35 +0,0 @@
1
- export interface Screen {
2
- /**
3
- * Check if the current screen output contains the given text (ANSI-stripped).
4
- */
5
- contains: (text: string) => boolean;
6
- /**
7
- * Get all captured frames with ANSI codes stripped.
8
- */
9
- frames: () => string[];
10
- /**
11
- * Get a specific line by zero-based index from the current screen output.
12
- */
13
- line: (n: number) => string;
14
- /**
15
- * Get all non-empty lines from the current screen output.
16
- */
17
- lines: () => string[];
18
- /**
19
- * Check if the current screen output matches the given pattern (ANSI-stripped).
20
- */
21
- matches: (pattern: RegExp) => boolean;
22
- /**
23
- * Get all captured frames with ANSI codes preserved.
24
- */
25
- rawFrames: () => string[];
26
- /**
27
- * Get the last rendered frame with ANSI codes preserved.
28
- */
29
- rawText: () => string;
30
- /**
31
- * Get the last rendered frame with ANSI codes stripped.
32
- */
33
- text: () => string;
34
- }
35
- export declare const createScreen: (lastFrame: () => string | undefined, allFrames: ReadonlyArray<string>) => Screen;
@@ -1,20 +0,0 @@
1
- export interface WaitForOptions {
2
- /**
3
- * Polling interval in milliseconds.
4
- * @default 50
5
- */
6
- interval?: number;
7
- /**
8
- * Maximum time to wait in milliseconds before throwing.
9
- * @default 3000
10
- */
11
- timeout?: number;
12
- }
13
- /**
14
- * Wait for a condition to be met by polling at a regular interval.
15
- *
16
- * If `condition` is a string, waits until `screenText()` contains it.
17
- * If `condition` is a function, waits until it stops throwing.
18
- * @throws The last error encountered if the timeout is reached.
19
- */
20
- export declare const waitFor: (condition: (() => void) | string, screenText: () => string, options?: WaitForOptions) => Promise<void>;