@visulima/tui 1.0.0-alpha.3 → 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 (250) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE.md +140 -0
  3. package/README.md +3 -3
  4. package/dist/core/index.d.ts +58 -5
  5. package/dist/ink/index.d.ts +6592 -294
  6. package/dist/ink/index.js +1 -1
  7. package/dist/packem_shared/{Histogram-cgAjY5AJ.js → Histogram-CB6XcmZW.js} +1 -1
  8. package/dist/packem_shared/input.d-Bfq7oc06.d.ts +90 -0
  9. package/dist/packem_shared/render.d-CNIzVQTh.d.ts +1257 -0
  10. package/dist/react/index.d.ts +519 -8
  11. package/dist/testing/index.d.ts +274 -135
  12. package/package.json +15 -16
  13. package/dist/core/app.d.ts +0 -50
  14. package/dist/core/cell.d.ts +0 -33
  15. package/dist/core/inline.d.ts +0 -22
  16. package/dist/core/input.d.ts +0 -18
  17. package/dist/core/native-binding.d.ts +0 -22
  18. package/dist/ink/ansi-to-cell.d.ts +0 -5
  19. package/dist/ink/ansi-tokenizer.d.ts +0 -38
  20. package/dist/ink/canvas/braille.d.ts +0 -22
  21. package/dist/ink/canvas/buffer.d.ts +0 -67
  22. package/dist/ink/clipboard.d.ts +0 -29
  23. package/dist/ink/color-matrix.d.ts +0 -49
  24. package/dist/ink/color-utils.d.ts +0 -30
  25. package/dist/ink/colorize.d.ts +0 -4
  26. package/dist/ink/components/accessibility-context.d.ts +0 -4
  27. package/dist/ink/components/accordion.d.ts +0 -52
  28. package/dist/ink/components/alert.d.ts +0 -30
  29. package/dist/ink/components/animate-presence.d.ts +0 -15
  30. package/dist/ink/components/animation-context.d.ts +0 -10
  31. package/dist/ink/components/app-context.d.ts +0 -38
  32. package/dist/ink/components/app.d.ts +0 -19
  33. package/dist/ink/components/approval-prompt.d.ts +0 -55
  34. package/dist/ink/components/area-chart.d.ts +0 -54
  35. package/dist/ink/components/background-context.d.ts +0 -5
  36. package/dist/ink/components/badge.d.ts +0 -27
  37. package/dist/ink/components/bar-chart.d.ts +0 -57
  38. package/dist/ink/components/big-text.d.ts +0 -71
  39. package/dist/ink/components/blink-dot.d.ts +0 -30
  40. package/dist/ink/components/box.d.ts +0 -58
  41. package/dist/ink/components/breadcrumb.d.ts +0 -28
  42. package/dist/ink/components/button.d.ts +0 -38
  43. package/dist/ink/components/calendar.d.ts +0 -60
  44. package/dist/ink/components/canvas.d.ts +0 -38
  45. package/dist/ink/components/card.d.ts +0 -46
  46. package/dist/ink/components/chart-utils.d.ts +0 -54
  47. package/dist/ink/components/checkbox.d.ts +0 -39
  48. package/dist/ink/components/code.d.ts +0 -46
  49. package/dist/ink/components/collapsible.d.ts +0 -43
  50. package/dist/ink/components/command-block.d.ts +0 -38
  51. package/dist/ink/components/command-palette.d.ts +0 -72
  52. package/dist/ink/components/confirm-dialog.d.ts +0 -63
  53. package/dist/ink/components/confirm-input.d.ts +0 -40
  54. package/dist/ink/components/console-overlay.d.ts +0 -52
  55. package/dist/ink/components/content-switcher.d.ts +0 -49
  56. package/dist/ink/components/cursor-context.d.ts +0 -12
  57. package/dist/ink/components/cursor.d.ts +0 -43
  58. package/dist/ink/components/date-picker.d.ts +0 -53
  59. package/dist/ink/components/definition-list.d.ts +0 -37
  60. package/dist/ink/components/dialog.d.ts +0 -93
  61. package/dist/ink/components/diff-view.d.ts +0 -71
  62. package/dist/ink/components/divider.d.ts +0 -40
  63. package/dist/ink/components/error-boundary.d.ts +0 -17
  64. package/dist/ink/components/error-overview.d.ts +0 -6
  65. package/dist/ink/components/file-picker/file-picker.d.ts +0 -58
  66. package/dist/ink/components/file-picker/types.d.ts +0 -35
  67. package/dist/ink/components/file-picker/use-file-system.d.ts +0 -16
  68. package/dist/ink/components/focus-context.d.ts +0 -17
  69. package/dist/ink/components/form.d.ts +0 -74
  70. package/dist/ink/components/gauge.d.ts +0 -75
  71. package/dist/ink/components/gradient.d.ts +0 -38
  72. package/dist/ink/components/heading.d.ts +0 -27
  73. package/dist/ink/components/heatmap.d.ts +0 -51
  74. package/dist/ink/components/help.d.ts +0 -44
  75. package/dist/ink/components/histogram.d.ts +0 -52
  76. package/dist/ink/components/kbd.d.ts +0 -27
  77. package/dist/ink/components/line-chart.d.ts +0 -94
  78. package/dist/ink/components/link.d.ts +0 -34
  79. package/dist/ink/components/loading-indicator.d.ts +0 -24
  80. package/dist/ink/components/markdown.d.ts +0 -34
  81. package/dist/ink/components/masked-input.d.ts +0 -41
  82. package/dist/ink/components/menu.d.ts +0 -70
  83. package/dist/ink/components/message-bubble.d.ts +0 -35
  84. package/dist/ink/components/model-badge.d.ts +0 -32
  85. package/dist/ink/components/multi-select.d.ts +0 -63
  86. package/dist/ink/components/newline.d.ts +0 -12
  87. package/dist/ink/components/operation-tree.d.ts +0 -46
  88. package/dist/ink/components/option-list.d.ts +0 -41
  89. package/dist/ink/components/ordered-list.d.ts +0 -30
  90. package/dist/ink/components/paginator.d.ts +0 -59
  91. package/dist/ink/components/paragraph.d.ts +0 -31
  92. package/dist/ink/components/placeholder.d.ts +0 -47
  93. package/dist/ink/components/progress-bar.d.ts +0 -51
  94. package/dist/ink/components/radio-group.d.ts +0 -62
  95. package/dist/ink/components/scatter-plot.d.ts +0 -23
  96. package/dist/ink/components/scroll/controlled-scroll-view.d.ts +0 -43
  97. package/dist/ink/components/scroll/index.d.ts +0 -10
  98. package/dist/ink/components/scroll/scroll-bar-box.d.ts +0 -15
  99. package/dist/ink/components/scroll/scroll-bar.d.ts +0 -20
  100. package/dist/ink/components/scroll/scroll-list.d.ts +0 -12
  101. package/dist/ink/components/scroll/scroll-view.d.ts +0 -98
  102. package/dist/ink/components/scroll/use-state-ref.d.ts +0 -8
  103. package/dist/ink/components/search-input.d.ts +0 -46
  104. package/dist/ink/components/select-input-indicator.d.ts +0 -36
  105. package/dist/ink/components/select-input-item.d.ts +0 -43
  106. package/dist/ink/components/select-input.d.ts +0 -96
  107. package/dist/ink/components/shimmer-text.d.ts +0 -39
  108. package/dist/ink/components/slider.d.ts +0 -92
  109. package/dist/ink/components/spacer.d.ts +0 -7
  110. package/dist/ink/components/sparkline.d.ts +0 -30
  111. package/dist/ink/components/spinner.d.ts +0 -40
  112. package/dist/ink/components/static-render.d.ts +0 -40
  113. package/dist/ink/components/static.d.ts +0 -24
  114. package/dist/ink/components/status-line.d.ts +0 -30
  115. package/dist/ink/components/status-message.d.ts +0 -26
  116. package/dist/ink/components/stderr-context.d.ts +0 -16
  117. package/dist/ink/components/stdin-context.d.ts +0 -29
  118. package/dist/ink/components/stdout-context.d.ts +0 -16
  119. package/dist/ink/components/stepper.d.ts +0 -42
  120. package/dist/ink/components/stopwatch.d.ts +0 -42
  121. package/dist/ink/components/streaming-text.d.ts +0 -38
  122. package/dist/ink/components/switch.d.ts +0 -46
  123. package/dist/ink/components/tab.d.ts +0 -25
  124. package/dist/ink/components/table.d.ts +0 -80
  125. package/dist/ink/components/tabs.d.ts +0 -104
  126. package/dist/ink/components/tag.d.ts +0 -30
  127. package/dist/ink/components/text-input.d.ts +0 -48
  128. package/dist/ink/components/text.d.ts +0 -63
  129. package/dist/ink/components/textarea.d.ts +0 -62
  130. package/dist/ink/components/timer.d.ts +0 -50
  131. package/dist/ink/components/toast.d.ts +0 -41
  132. package/dist/ink/components/tooltip.d.ts +0 -36
  133. package/dist/ink/components/transform.d.ts +0 -16
  134. package/dist/ink/components/transition.d.ts +0 -53
  135. package/dist/ink/components/tree-view/theme.d.ts +0 -24
  136. package/dist/ink/components/tree-view/tree-node-map.d.ts +0 -72
  137. package/dist/ink/components/tree-view/tree-view-node.d.ts +0 -29
  138. package/dist/ink/components/tree-view/tree-view.d.ts +0 -89
  139. package/dist/ink/components/tree-view/types.d.ts +0 -55
  140. package/dist/ink/components/tree-view/use-tree-view-state.d.ts +0 -135
  141. package/dist/ink/components/tree-view/use-tree-view.d.ts +0 -26
  142. package/dist/ink/components/unordered-list.d.ts +0 -35
  143. package/dist/ink/components/variant-config.d.ts +0 -10
  144. package/dist/ink/cursor-helpers.d.ts +0 -35
  145. package/dist/ink/data-limited-lru-map.d.ts +0 -21
  146. package/dist/ink/devtools-window-polyfill.d.ts +0 -1
  147. package/dist/ink/devtools.d.ts +0 -1
  148. package/dist/ink/dom.d.ts +0 -214
  149. package/dist/ink/get-max-width.d.ts +0 -3
  150. package/dist/ink/highlighter.d.ts +0 -28
  151. package/dist/ink/hooks/use-animation.d.ts +0 -41
  152. package/dist/ink/hooks/use-app.d.ts +0 -6
  153. package/dist/ink/hooks/use-box-metrics.d.ts +0 -58
  154. package/dist/ink/hooks/use-clipboard.d.ts +0 -29
  155. package/dist/ink/hooks/use-color-blindness.d.ts +0 -33
  156. package/dist/ink/hooks/use-console-capture.d.ts +0 -43
  157. package/dist/ink/hooks/use-cursor.d.ts +0 -12
  158. package/dist/ink/hooks/use-focus-manager.d.ts +0 -42
  159. package/dist/ink/hooks/use-focus.d.ts +0 -30
  160. package/dist/ink/hooks/use-form.d.ts +0 -70
  161. package/dist/ink/hooks/use-hotkey.d.ts +0 -37
  162. package/dist/ink/hooks/use-input.d.ts +0 -149
  163. package/dist/ink/hooks/use-interval.d.ts +0 -25
  164. package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +0 -6
  165. package/dist/ink/hooks/use-key-bindings.d.ts +0 -59
  166. package/dist/ink/hooks/use-key-chord.d.ts +0 -26
  167. package/dist/ink/hooks/use-linked-scroll.d.ts +0 -41
  168. package/dist/ink/hooks/use-paste.d.ts +0 -44
  169. package/dist/ink/hooks/use-persistent-state.d.ts +0 -56
  170. package/dist/ink/hooks/use-scroll-acceleration.d.ts +0 -47
  171. package/dist/ink/hooks/use-scroll-input.d.ts +0 -34
  172. package/dist/ink/hooks/use-stderr.d.ts +0 -6
  173. package/dist/ink/hooks/use-stdin.d.ts +0 -7
  174. package/dist/ink/hooks/use-stdout.d.ts +0 -6
  175. package/dist/ink/hooks/use-stopwatch.d.ts +0 -38
  176. package/dist/ink/hooks/use-terminal-palette.d.ts +0 -19
  177. package/dist/ink/hooks/use-text-buffer.d.ts +0 -42
  178. package/dist/ink/hooks/use-text-selection.d.ts +0 -45
  179. package/dist/ink/hooks/use-timeout.d.ts +0 -24
  180. package/dist/ink/hooks/use-timer.d.ts +0 -47
  181. package/dist/ink/hooks/use-window-size.d.ts +0 -18
  182. package/dist/ink/ime-utils.d.ts +0 -25
  183. package/dist/ink/ink.d.ts +0 -190
  184. package/dist/ink/input-parser.d.ts +0 -10
  185. package/dist/ink/input-utils.d.ts +0 -16
  186. package/dist/ink/instances.d.ts +0 -3
  187. package/dist/ink/kitty-keyboard.d.ts +0 -23
  188. package/dist/ink/layout.d.ts +0 -26
  189. package/dist/ink/log-update-native.d.ts +0 -14
  190. package/dist/ink/log-update.d.ts +0 -21
  191. package/dist/ink/measure-element.d.ts +0 -147
  192. package/dist/ink/measure-text.d.ts +0 -56
  193. package/dist/ink/mouse/ansi-parser.d.ts +0 -37
  194. package/dist/ink/mouse/constants.d.ts +0 -14
  195. package/dist/ink/mouse/fullscreen.d.ts +0 -8
  196. package/dist/ink/mouse/index.d.ts +0 -20
  197. package/dist/ink/mouse/is-intersecting.d.ts +0 -18
  198. package/dist/ink/mouse/mouse-context.d.ts +0 -36
  199. package/dist/ink/mouse/mouse-provider.d.ts +0 -11
  200. package/dist/ink/mouse/use-element-position.d.ts +0 -29
  201. package/dist/ink/mouse/use-mouse-action.d.ts +0 -7
  202. package/dist/ink/mouse/use-mouse-position.d.ts +0 -7
  203. package/dist/ink/mouse/use-mouse.d.ts +0 -7
  204. package/dist/ink/mouse/use-on-mouse-click.d.ts +0 -14
  205. package/dist/ink/mouse/use-on-mouse-hover.d.ts +0 -8
  206. package/dist/ink/mouse/use-on-mouse-state.d.ts +0 -11
  207. package/dist/ink/output.d.ts +0 -75
  208. package/dist/ink/parse-keypress.d.ts +0 -22
  209. package/dist/ink/reconciler.d.ts +0 -3
  210. package/dist/ink/region.d.ts +0 -99
  211. package/dist/ink/render-background.d.ts +0 -4
  212. package/dist/ink/render-border.d.ts +0 -4
  213. package/dist/ink/render-node-to-output.d.ts +0 -38
  214. package/dist/ink/render-scrollbar.d.ts +0 -9
  215. package/dist/ink/render-sticky.d.ts +0 -44
  216. package/dist/ink/render-to-string.d.ts +0 -37
  217. package/dist/ink/render.d.ts +0 -191
  218. package/dist/ink/renderer.d.ts +0 -17
  219. package/dist/ink/resize-observer.d.ts +0 -44
  220. package/dist/ink/sanitize-ansi.d.ts +0 -2
  221. package/dist/ink/scroll.d.ts +0 -23
  222. package/dist/ink/selection.d.ts +0 -70
  223. package/dist/ink/squash-text-nodes.d.ts +0 -18
  224. package/dist/ink/style-flags.d.ts +0 -17
  225. package/dist/ink/styled-line-factory.d.ts +0 -25
  226. package/dist/ink/styled-line-serializer.d.ts +0 -18
  227. package/dist/ink/styled-line.d.ts +0 -119
  228. package/dist/ink/styles.d.ts +0 -369
  229. package/dist/ink/terminal-palette.d.ts +0 -25
  230. package/dist/ink/text-wrap.d.ts +0 -10
  231. package/dist/ink/token-to-elements.d.ts +0 -22
  232. package/dist/ink/utils/format-time.d.ts +0 -4
  233. package/dist/ink/utils.d.ts +0 -9
  234. package/dist/ink/wrap-text.d.ts +0 -3
  235. package/dist/ink/write-synchronized.d.ts +0 -4
  236. package/dist/react/devtools.d.ts +0 -27
  237. package/dist/react/focus.d.ts +0 -39
  238. package/dist/react/hooks.d.ts +0 -238
  239. package/dist/react/layout.d.ts +0 -33
  240. package/dist/react/react.d.ts +0 -57
  241. package/dist/react/reconciler.d.ts +0 -4
  242. package/dist/react/render-to-string.d.ts +0 -21
  243. package/dist/react/renderer.d.ts +0 -2
  244. package/dist/react/scene.d.ts +0 -3
  245. package/dist/react/static.d.ts +0 -39
  246. package/dist/react/styles.d.ts +0 -83
  247. package/dist/react/text-width.d.ts +0 -20
  248. package/dist/testing/keys.d.ts +0 -89
  249. package/dist/testing/screen.d.ts +0 -35
  250. package/dist/testing/wait-for.d.ts +0 -20
@@ -1,144 +1,283 @@
1
- import type { ReactElement } from "react";
2
- import type { RenderOptions } from "../ink/render.d.ts";
3
- import type { KeySender } from "./keys.d.ts";
4
- import type { Screen } from "./screen.d.ts";
5
- import type { WaitForOptions } from "./wait-for.d.ts";
6
- export type TestInstanceStdout = {
7
- /**
8
- * All rendered frames captured from stdout.
9
- */
10
- readonly frames: ReadonlyArray<string>;
11
- /**
12
- * Returns the most recently rendered frame, or `undefined` if no frames have been written.
13
- */
14
- lastFrame: () => string | undefined;
15
- /**
16
- * Write data to the mock stdout stream (used internally by the renderer).
17
- */
18
- write: (frame: string) => boolean;
1
+ import { ReactElement } from 'react';
2
+ import { R as RenderOptions } from "../packem_shared/render.d-CNIzVQTh.js";
3
+ import 'yoga-layout';
4
+ import '@visulima/colorize';
5
+ import 'type-fest';
6
+ import 'node:stream';
7
+ declare const KEY: {
8
+ readonly backspace: "";
9
+ readonly ctrlC: "";
10
+ readonly delete: "\x1B[3~";
11
+ readonly down: "\x1B[B";
12
+ readonly end: "\x1B[F";
13
+ readonly escape: "\x1B";
14
+ readonly home: "\x1B[H";
15
+ readonly left: "\x1B[D";
16
+ readonly pageDown: "\x1B[6~";
17
+ readonly pageUp: "\x1B[5~";
18
+ readonly return: "\r";
19
+ readonly right: "\x1B[C";
20
+ readonly space: " ";
21
+ readonly tab: " ";
22
+ readonly up: "\x1B[A";
19
23
  };
20
- export type TestInstanceStderr = {
21
- /**
22
- * All rendered frames captured from stderr.
23
- */
24
- readonly frames: ReadonlyArray<string>;
25
- /**
26
- * Returns the most recently rendered frame, or `undefined` if no frames have been written.
27
- */
28
- lastFrame: () => string | undefined;
29
- /**
30
- * Write data to the mock stderr stream (used internally by the renderer).
31
- */
32
- write: (frame: string) => boolean;
24
+ type KeyName = keyof typeof KEY;
25
+ interface KeySender {
26
+ /**
27
+ * Simulate pressing the backspace key.
28
+ */
29
+ backspace: () => void;
30
+ /**
31
+ * Simulate pressing the delete key.
32
+ */
33
+ delete: () => void;
34
+ /**
35
+ * Simulate pressing the down arrow key.
36
+ */
37
+ down: () => void;
38
+ /**
39
+ * Simulate pressing the end key.
40
+ */
41
+ end: () => void;
42
+ /**
43
+ * Simulate pressing the enter/return key.
44
+ */
45
+ enter: () => void;
46
+ /**
47
+ * Simulate pressing the escape key.
48
+ */
49
+ escape: () => void;
50
+ /**
51
+ * Simulate pressing the home key.
52
+ */
53
+ home: () => void;
54
+ /**
55
+ * Simulate pressing the left arrow key.
56
+ */
57
+ left: () => void;
58
+ /**
59
+ * Simulate pressing the page down key.
60
+ */
61
+ pageDown: () => void;
62
+ /**
63
+ * Simulate pressing the page up key.
64
+ */
65
+ pageUp: () => void;
66
+ /**
67
+ * Send a single character as a key press.
68
+ */
69
+ press: (char: string) => void;
70
+ /**
71
+ * Send arbitrary raw data to stdin.
72
+ */
73
+ raw: (data: string) => void;
74
+ /**
75
+ * Simulate pressing the right arrow key.
76
+ */
77
+ right: () => void;
78
+ /**
79
+ * Simulate pressing the space key.
80
+ */
81
+ space: () => void;
82
+ /**
83
+ * Simulate pressing the tab key.
84
+ */
85
+ tab: () => void;
86
+ /**
87
+ * Type a string character by character.
88
+ */
89
+ type: (text: string) => void;
90
+ /**
91
+ * Simulate pressing the up arrow key.
92
+ */
93
+ up: () => void;
94
+ }
95
+ declare const createKeySender: (write: (data: string) => void) => KeySender;
96
+ interface Screen {
97
+ /**
98
+ * Check if the current screen output contains the given text (ANSI-stripped).
99
+ */
100
+ contains: (text: string) => boolean;
101
+ /**
102
+ * Get all captured frames with ANSI codes stripped.
103
+ */
104
+ frames: () => string[];
105
+ /**
106
+ * Get a specific line by zero-based index from the current screen output.
107
+ */
108
+ line: (n: number) => string;
109
+ /**
110
+ * Get all non-empty lines from the current screen output.
111
+ */
112
+ lines: () => string[];
113
+ /**
114
+ * Check if the current screen output matches the given pattern (ANSI-stripped).
115
+ */
116
+ matches: (pattern: RegExp) => boolean;
117
+ /**
118
+ * Get all captured frames with ANSI codes preserved.
119
+ */
120
+ rawFrames: () => string[];
121
+ /**
122
+ * Get the last rendered frame with ANSI codes preserved.
123
+ */
124
+ rawText: () => string;
125
+ /**
126
+ * Get the last rendered frame with ANSI codes stripped.
127
+ */
128
+ text: () => string;
129
+ }
130
+ declare const createScreen: (lastFrame: () => string | undefined, allFrames: ReadonlyArray<string>) => Screen;
131
+ interface WaitForOptions {
132
+ /**
133
+ * Polling interval in milliseconds.
134
+ * @default 50
135
+ */
136
+ interval?: number;
137
+ /**
138
+ * Maximum time to wait in milliseconds before throwing.
139
+ * @default 3000
140
+ */
141
+ timeout?: number;
142
+ }
143
+ /**
144
+ * Wait for a condition to be met by polling at a regular interval.
145
+ *
146
+ * If `condition` is a string, waits until `screenText()` contains it.
147
+ * If `condition` is a function, waits until it stops throwing.
148
+ * @throws The last error encountered if the timeout is reached.
149
+ */
150
+ declare const waitFor: (condition: (() => void) | string, screenText: () => string, options?: WaitForOptions) => Promise<void>;
151
+ type TestInstanceStdout = {
152
+ /**
153
+ * All rendered frames captured from stdout.
154
+ */
155
+ readonly frames: ReadonlyArray<string>;
156
+ /**
157
+ * Returns the most recently rendered frame, or `undefined` if no frames have been written.
158
+ */
159
+ lastFrame: () => string | undefined;
160
+ /**
161
+ * Write data to the mock stdout stream (used internally by the renderer).
162
+ */
163
+ write: (frame: string) => boolean;
164
+ };
165
+ type TestInstanceStderr = {
166
+ /**
167
+ * All rendered frames captured from stderr.
168
+ */
169
+ readonly frames: ReadonlyArray<string>;
170
+ /**
171
+ * Returns the most recently rendered frame, or `undefined` if no frames have been written.
172
+ */
173
+ lastFrame: () => string | undefined;
174
+ /**
175
+ * Write data to the mock stderr stream (used internally by the renderer).
176
+ */
177
+ write: (frame: string) => boolean;
33
178
  };
34
- export type TestInstanceStdin = {
35
- /**
36
- * Whether the stdin is a TTY.
37
- */
38
- readonly isTTY: boolean;
39
- /**
40
- * Simulate user input by writing data to stdin.
41
- */
42
- write: (data: string) => boolean;
179
+ type TestInstanceStdin = {
180
+ /**
181
+ * Whether the stdin is a TTY.
182
+ */
183
+ readonly isTTY: boolean;
184
+ /**
185
+ * Simulate user input by writing data to stdin.
186
+ */
187
+ write: (data: string) => boolean;
43
188
  };
44
- export type TestInstance = {
45
- /**
46
- * Unmount the app and clean up resources.
47
- */
48
- cleanup: () => void;
49
- /**
50
- * Wait for pending React renders to flush (two microtick delay).
51
- */
52
- flush: () => Promise<void>;
53
- /**
54
- * All rendered frames captured from stdout (shorthand for `stdout.frames`).
55
- */
56
- readonly frames: ReadonlyArray<string>;
57
- /**
58
- * Keyboard input helpers for simulating key presses.
59
- */
60
- keys: KeySender;
61
- /**
62
- * Returns the most recently rendered frame from stdout (shorthand for `stdout.lastFrame()`).
63
- */
64
- lastFrame: () => string | undefined;
65
- /**
66
- * Replace the previous root node with a new one or update props.
67
- */
68
- rerender: (node: ReactElement) => void;
69
- /**
70
- * Screen query helpers for inspecting rendered output with ANSI stripping.
71
- */
72
- screen: Screen;
73
- /**
74
- * Mock stderr stream with frame capture.
75
- */
76
- stderr: TestInstanceStderr;
77
- /**
78
- * Mock stdin stream for simulating user input.
79
- */
80
- stdin: TestInstanceStdin;
81
- /**
82
- * Mock stdout stream with frame capture.
83
- */
84
- stdout: TestInstanceStdout;
85
- /**
86
- * Manually unmount the whole app.
87
- */
88
- unmount: () => void;
89
- /**
90
- * Wait for a condition to be met by polling.
91
- *
92
- * If `condition` is a string, waits until the screen contains it.
93
- * If `condition` is a function, waits until it stops throwing.
94
- */
95
- waitFor: (condition: (() => void) | string, options?: WaitForOptions) => Promise<void>;
189
+ type TestInstance = {
190
+ /**
191
+ * Unmount the app and clean up resources.
192
+ */
193
+ cleanup: () => void;
194
+ /**
195
+ * Wait for pending React renders to flush (two microtick delay).
196
+ */
197
+ flush: () => Promise<void>;
198
+ /**
199
+ * All rendered frames captured from stdout (shorthand for `stdout.frames`).
200
+ */
201
+ readonly frames: ReadonlyArray<string>;
202
+ /**
203
+ * Keyboard input helpers for simulating key presses.
204
+ */
205
+ keys: KeySender;
206
+ /**
207
+ * Returns the most recently rendered frame from stdout (shorthand for `stdout.lastFrame()`).
208
+ */
209
+ lastFrame: () => string | undefined;
210
+ /**
211
+ * Replace the previous root node with a new one or update props.
212
+ */
213
+ rerender: (node: ReactElement) => void;
214
+ /**
215
+ * Screen query helpers for inspecting rendered output with ANSI stripping.
216
+ */
217
+ screen: Screen;
218
+ /**
219
+ * Mock stderr stream with frame capture.
220
+ */
221
+ stderr: TestInstanceStderr;
222
+ /**
223
+ * Mock stdin stream for simulating user input.
224
+ */
225
+ stdin: TestInstanceStdin;
226
+ /**
227
+ * Mock stdout stream with frame capture.
228
+ */
229
+ stdout: TestInstanceStdout;
230
+ /**
231
+ * Manually unmount the whole app.
232
+ */
233
+ unmount: () => void;
234
+ /**
235
+ * Wait for a condition to be met by polling.
236
+ *
237
+ * If `condition` is a string, waits until the screen contains it.
238
+ * If `condition` is a function, waits until it stops throwing.
239
+ */
240
+ waitFor: (condition: (() => void) | string, options?: WaitForOptions) => Promise<void>;
96
241
  };
97
- export type TestRenderOptions = {
98
- /**
99
- * Terminal column width for the mock stdout/stderr streams.
100
- * @default 100
101
- */
102
- columns?: number;
103
- /**
104
- * Additional render options passed through to the underlying render function.
105
- */
106
- options?: Omit<RenderOptions, "debug" | "exitOnCtrlC" | "patchConsole" | "stderr" | "stdin" | "stdout">;
242
+ type TestRenderOptions = {
243
+ /**
244
+ * Terminal column width for the mock stdout/stderr streams.
245
+ * @default 100
246
+ */
247
+ columns?: number;
248
+ /**
249
+ * Additional render options passed through to the underlying render function.
250
+ */
251
+ options?: Omit<RenderOptions, "debug" | "exitOnCtrlC" | "patchConsole" | "stderr" | "stdin" | "stdout">;
107
252
  };
108
253
  /**
109
- * Render a React element for testing, capturing output in mock streams.
110
- *
111
- * Returns an object with methods to inspect rendered output, simulate input,
112
- * and control the component lifecycle.
113
- * @example
114
- * ```tsx
115
- * import { render } from "@visulima/tui/test";
116
- * import { Text } from "@visulima/tui";
117
- *
118
- * const { lastFrame } = render(<Text>Hello</Text>);
119
- * console.log(lastFrame()); // "Hello"
120
- * ```
121
- */
254
+ * Render a React element for testing, capturing output in mock streams.
255
+ *
256
+ * Returns an object with methods to inspect rendered output, simulate input,
257
+ * and control the component lifecycle.
258
+ * @example
259
+ * ```tsx
260
+ * import { render } from "@visulima/tui/test";
261
+ * import { Text } from "@visulima/tui";
262
+ *
263
+ * const { lastFrame } = render(<Text>Hello</Text>);
264
+ * console.log(lastFrame()); // "Hello"
265
+ * ```
266
+ */
122
267
  declare const testRender: (node: ReactElement, testOptions?: TestRenderOptions) => TestInstance;
123
268
  /**
124
- * Unmount and clean up all rendered test instances.
125
- *
126
- * Call this in your test teardown (e.g., `afterEach`) to ensure
127
- * no test instances leak between tests.
128
- * @example
129
- * ```ts
130
- * import { cleanup } from "@visulima/tui/test";
131
- *
132
- * afterEach(() => {
133
- * cleanup();
134
- * });
135
- * ```
136
- */
269
+ * Unmount and clean up all rendered test instances.
270
+ *
271
+ * Call this in your test teardown (e.g., `afterEach`) to ensure
272
+ * no test instances leak between tests.
273
+ * @example
274
+ * ```ts
275
+ * import { cleanup } from "@visulima/tui/test";
276
+ *
277
+ * afterEach(() => {
278
+ * cleanup();
279
+ * });
280
+ * ```
281
+ */
137
282
  declare const cleanup: () => void;
138
- export { cleanup, testRender as render };
139
- export type { KeyName, KeySender } from "./keys.d.ts";
140
- export { createKeySender, KEY } from "./keys.d.ts";
141
- export type { Screen } from "./screen.d.ts";
142
- export { createScreen } from "./screen.d.ts";
143
- export type { WaitForOptions } from "./wait-for.d.ts";
144
- export { waitFor } from "./wait-for.d.ts";
283
+ export { KEY, type KeyName, type KeySender, type Screen, TestInstance, TestInstanceStderr, TestInstanceStdin, TestInstanceStdout, TestRenderOptions, type WaitForOptions, cleanup, createKeySender, createScreen, testRender as render, waitFor };
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@visulima/tui",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.5",
4
4
  "description": "React-based TUI library powered by a native Rust diff engine, drop-in Ink-compatible API",
5
5
  "keywords": [
6
- "visulima",
7
- "tui",
8
- "terminal",
9
- "react",
10
- "ink",
11
6
  "cli",
7
+ "ink",
8
+ "napi",
9
+ "react",
12
10
  "rust",
13
- "napi"
11
+ "terminal",
12
+ "tui",
13
+ "visulima"
14
14
  ],
15
15
  "homepage": "https://visulima.com/packages/tui",
16
16
  "bugs": {
@@ -82,7 +82,6 @@
82
82
  "patch-console": "^2.0.0",
83
83
  "scheduler": "^0.27.0",
84
84
  "shiki": "4.0.2",
85
- "type-fest": "5.6.0",
86
85
  "ws": "^8.20.0",
87
86
  "yoga-layout": "~3.2.1",
88
87
  "yoga-layout-prebuilt": "^1.10.0"
@@ -101,14 +100,14 @@
101
100
  }
102
101
  },
103
102
  "optionalDependencies": {
104
- "@visulima/tui-binding-darwin-arm64": "1.0.0-alpha.3",
105
- "@visulima/tui-binding-darwin-x64": "1.0.0-alpha.3",
106
- "@visulima/tui-binding-linux-arm64-musl": "1.0.0-alpha.3",
107
- "@visulima/tui-binding-linux-x64-gnu": "1.0.0-alpha.3",
108
- "@visulima/tui-binding-linux-arm64-gnu": "1.0.0-alpha.3",
109
- "@visulima/tui-binding-win32-arm64-msvc": "1.0.0-alpha.3",
110
- "@visulima/tui-binding-win32-x64-msvc": "1.0.0-alpha.3",
111
- "@visulima/tui-binding-linux-x64-musl": "1.0.0-alpha.3"
103
+ "@visulima/tui-binding-darwin-arm64": "1.0.0-alpha.5",
104
+ "@visulima/tui-binding-linux-arm64-gnu": "1.0.0-alpha.5",
105
+ "@visulima/tui-binding-darwin-x64": "1.0.0-alpha.5",
106
+ "@visulima/tui-binding-linux-x64-gnu": "1.0.0-alpha.5",
107
+ "@visulima/tui-binding-linux-arm64-musl": "1.0.0-alpha.5",
108
+ "@visulima/tui-binding-linux-x64-musl": "1.0.0-alpha.5",
109
+ "@visulima/tui-binding-win32-arm64-msvc": "1.0.0-alpha.5",
110
+ "@visulima/tui-binding-win32-x64-msvc": "1.0.0-alpha.5"
112
111
  },
113
112
  "engines": {
114
113
  "node": "^22.14.0 || >=24.10.0"
@@ -1,50 +0,0 @@
1
- import EventEmitter from "eventemitter3";
2
- export declare class TuiApp extends EventEmitter {
3
- private renderer;
4
- private terminal;
5
- private backBuffer;
6
- private width;
7
- private height;
8
- private isRunning;
9
- private stdoutBuffer;
10
- private stderrBuffer;
11
- constructor();
12
- /** Enters raw mode + alternate screen. Does NOT start any render loop. */
13
- start(): void;
14
- /** Request a clean exit — restores terminal, stops input, exits the process. */
15
- quit(): void;
16
- /** Exits raw mode + alternate screen, then flushes any buffered stdout/stderr. */
17
- stop(): void;
18
- /**
19
- * Buffer a write to stdout. While the alternate screen is active, writing
20
- * directly would corrupt the TUI. Buffered output is flushed on stop().
21
- */
22
- writeStdout(text: string): void;
23
- /**
24
- * Buffer a write to stderr. While the alternate screen is active, writing
25
- * directly would corrupt the TUI. Buffered output is flushed on stop().
26
- */
27
- writeStderr(text: string): void;
28
- /** Returns the shared Uint32Array back-buffer (width * height * 2 u32 cells). */
29
- getBuffer(): Uint32Array;
30
- /** Returns current terminal dimensions. */
31
- getSize(): {
32
- height: number;
33
- width: number;
34
- };
35
- /** Update terminal dimensions (called on SIGWINCH). */
36
- resize(width: number, height: number): void;
37
- /**
38
- * Callbacks fired on every frame after React paints the buffer but before
39
- * the Rust diff engine flushes to stdout. Use for direct buffer painting
40
- * that needs to overlay React output (animated graphs, overlays, FPS counters).
41
- * Multiple listeners are supported — they fire in registration order.
42
- */
43
- private beforeFlushListeners;
44
- onBeforeFlush(function_: (buffer: Uint32Array, width: number, height: number) => void): () => void;
45
- /**
46
- * Layout + paint synchronously. Called from the render loop on every dirty frame,
47
- * and directly on resize for immediate response.
48
- */
49
- paintNow(calculateLayout: (w: number, h: number) => void, renderToBuffer: (buf: Uint32Array, w: number, h: number) => void): void;
50
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * 2×u32 per-cell back-buffer layout:
3
- * buffer[idx * 2] = charCode (Unicode codepoint, u32)
4
- * buffer[idx * 2 + 1] = attrCode = (styles &lt;< 16) | (bg &lt;< 8) | fg
5
- */
6
- export declare const Cell: {
7
- /** Read bg color from an attr slot value (buffer[idx*2+1]) — bits 15:8 */
8
- getBg(attributeSlot: number): number;
9
- /** Read the char character from a raw char slot value (buffer[idx*2]) */
10
- getChar(charSlot: number): string;
11
- /** Read fg color from an attr slot value (buffer[idx*2+1]) — bits 7:0 */
12
- getFg(attributeSlot: number): number;
13
- /** Read styles bitmask from an attr slot value (buffer[idx*2+1]) — bits 23:16 */
14
- getStyles(attributeSlot: number): number;
15
- /**
16
- * Pack a cell into a [charCode, attrCode] tuple.
17
- * charCode = char.codePointAt(0)
18
- * attrCode = (styles & 0xFF) &lt;< 16 | (bg & 0xFF) &lt;< 8 | (fg & 0xFF)
19
- *
20
- * Write to buffer as: buffer[idx*2] = charCode; buffer[idx*2+1] = attrCode
21
- */
22
- pack(char: string, fg?: number, bg?: number, styles?: number): [number, number];
23
- };
24
- export declare const StyleMasks: {
25
- BLINK: number;
26
- BOLD: number;
27
- DIM: number;
28
- HIDDEN: number;
29
- INVERT: number;
30
- ITALIC: number;
31
- STRIKETHROUGH: number;
32
- UNDERLINE: number;
33
- };
@@ -1,22 +0,0 @@
1
- export interface InlineOptions {
2
- /** Frames per second. Default: 60 */
3
- fps?: number;
4
- /**
5
- * What to do with the rendered content when the loop stops.
6
- * - 'preserve' (default) — content stays in terminal scrollback
7
- * - 'destroy' — content is cleared, terminal looks untouched
8
- */
9
- onExit?: "preserve" | "destroy";
10
- /** Number of terminal rows to reserve. Default: 10 */
11
- rows?: number;
12
- }
13
- export type InlinePaintFn = (buf: Uint32Array, cols: number, rows: number, frame: number) => void;
14
- export interface InlineLoop {
15
- start: () => void;
16
- stop: () => void;
17
- }
18
- /**
19
- * Create an inline render loop. Renders `rows` lines immediately below the
20
- * current cursor position (no alternate screen).
21
- */
22
- export declare function createInlineLoop(paint: InlinePaintFn, options?: InlineOptions): InlineLoop;
@@ -1,18 +0,0 @@
1
- import EventEmitter from "eventemitter3";
2
- export interface MouseEvent {
3
- button: "left" | "right" | "middle" | "scrollUp" | "scrollDown";
4
- ctrl: boolean;
5
- meta: boolean;
6
- shift: boolean;
7
- x: number;
8
- y: number;
9
- }
10
- export declare class InputParser extends EventEmitter {
11
- private stdin;
12
- private _boundHandleData;
13
- private _pasteBuffer;
14
- constructor(stdin: NodeJS.ReadStream);
15
- start(): void;
16
- stop(): void;
17
- private handleData;
18
- }
@@ -1,22 +0,0 @@
1
- export interface TerminalSize {
2
- cols: number;
3
- rows: number;
4
- }
5
- export interface RendererInstance {
6
- readonly height: number;
7
- render: (backBuffer: Uint32Array) => void;
8
- renderDiff: (backBuffer: Uint32Array) => string;
9
- resize: (width: number, height: number) => void;
10
- setRowOffset: (offset: number) => void;
11
- readonly width: number;
12
- writeRaw: (data: string) => void;
13
- }
14
- export type RendererConstructor = new (width: number, height: number) => RendererInstance;
15
- export interface TerminalGuardInstance {
16
- getSize: () => TerminalSize;
17
- leave: () => void;
18
- }
19
- export type TerminalGuardConstructor = new (mouse?: boolean | undefined | null) => TerminalGuardInstance;
20
- export declare const Renderer: RendererConstructor;
21
- export declare const TerminalGuard: TerminalGuardConstructor;
22
- export declare const terminalSize: () => TerminalSize;
@@ -1,5 +0,0 @@
1
- /**
2
- * Sentinel value for the trailing cell of a wide (fullWidth) character.
3
- * Must be outside Unicode scalar range so it never collides with real text.
4
- */
5
- export declare const CONTINUATION_CELL_CODE = 1114112;
@@ -1,38 +0,0 @@
1
- type ControlStringType = "osc" | "dcs" | "pm" | "apc" | "sos";
2
- type CsiToken = {
3
- readonly finalCharacter: string;
4
- readonly intermediateString: string;
5
- readonly parameterString: string;
6
- readonly type: "csi";
7
- readonly value: string;
8
- };
9
- type EscToken = {
10
- readonly finalCharacter: string;
11
- readonly intermediateString: string;
12
- readonly type: "esc";
13
- readonly value: string;
14
- };
15
- type ControlStringToken = {
16
- readonly type: ControlStringType;
17
- readonly value: string;
18
- };
19
- type TextToken = {
20
- readonly type: "text";
21
- readonly value: string;
22
- };
23
- type StToken = {
24
- readonly type: "st";
25
- readonly value: string;
26
- };
27
- type C1Token = {
28
- readonly type: "c1";
29
- readonly value: string;
30
- };
31
- type InvalidToken = {
32
- readonly type: "invalid";
33
- readonly value: string;
34
- };
35
- export type AnsiToken = TextToken | CsiToken | EscToken | ControlStringToken | StToken | C1Token | InvalidToken;
36
- export declare const hasAnsiControlCharacters: (text: string) => boolean;
37
- export declare const tokenizeAnsi: (text: string) => AnsiToken[];
38
- export {};