@visulima/tui 0.0.1 → 1.0.0-alpha.10

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 (218) hide show
  1. package/CHANGELOG.md +331 -0
  2. package/LICENSE.md +497 -0
  3. package/README.md +173 -29
  4. package/dist/core/index.d.ts +58 -0
  5. package/dist/core/index.js +1 -0
  6. package/dist/ink/index.d.ts +6574 -0
  7. package/dist/ink/index.js +1 -0
  8. package/dist/packem_chunks/devtools.js +4 -0
  9. package/dist/packem_shared/Accordion-BXsqchV-.js +1 -0
  10. package/dist/packem_shared/Alert-BhYVMHtR.js +1 -0
  11. package/dist/packem_shared/AnimatePresence-Eu7Z8KHc.js +1 -0
  12. package/dist/packem_shared/ApprovalPrompt-BSn0FT1g.js +1 -0
  13. package/dist/packem_shared/AreaChart-Chy-frI7.js +1 -0
  14. package/dist/packem_shared/Badge-B8WPyRsK.js +1 -0
  15. package/dist/packem_shared/BarChart-rpZtlMcF.js +1 -0
  16. package/dist/packem_shared/BigText-CRpwUzrt.js +1 -0
  17. package/dist/packem_shared/BlinkDot-BvnRuWP8.js +1 -0
  18. package/dist/packem_shared/Box-BwqSvWuq.js +1 -0
  19. package/dist/packem_shared/Breadcrumb-D0hClbRV.js +1 -0
  20. package/dist/packem_shared/Button-B89Yvbc6.js +1 -0
  21. package/dist/packem_shared/COLOR_BLINDNESS_SIMULATION-DqErf7XX.js +1 -0
  22. package/dist/packem_shared/Calendar-Dmflvm2S.js +1 -0
  23. package/dist/packem_shared/Canvas-CKg6WV47.js +1 -0
  24. package/dist/packem_shared/Card-B_9fXdtU.js +1 -0
  25. package/dist/packem_shared/Cell-BrXn3jxY.js +1 -0
  26. package/dist/packem_shared/Checkbox-BN71eCWU.js +1 -0
  27. package/dist/packem_shared/Code-HhevcyiH.js +2 -0
  28. package/dist/packem_shared/Collapsible-u6uf_FdV.js +1 -0
  29. package/dist/packem_shared/CommandBlock-B-nslpCv.js +4 -0
  30. package/dist/packem_shared/CommandPalette-CEFdaURo.js +1 -0
  31. package/dist/packem_shared/ConfirmDialog-5Jje_Xpu.js +1 -0
  32. package/dist/packem_shared/ConfirmInput-D44Mb9oo.js +1 -0
  33. package/dist/packem_shared/ConsoleOverlay-CM3APfgP.js +1 -0
  34. package/dist/packem_shared/ContentSwitcher-Dm5BkrCt.js +1 -0
  35. package/dist/packem_shared/ControlledScrollView-DI8KZOQB.js +1 -0
  36. package/dist/packem_shared/Cursor-BoLFIMol.js +1 -0
  37. package/dist/packem_shared/DatePicker-CnSrFFAE.js +1 -0
  38. package/dist/packem_shared/DefinitionList-v8RDuF_R.js +1 -0
  39. package/dist/packem_shared/DevTools-O8EbCfHa.js +1 -0
  40. package/dist/packem_shared/Dialog-CTaL8pn0.js +1 -0
  41. package/dist/packem_shared/DiffView-BUIFqUB0.js +1 -0
  42. package/dist/packem_shared/Divider-C47bKmqu.js +1 -0
  43. package/dist/packem_shared/FilePicker-CUo7R5Qb.js +1 -0
  44. package/dist/packem_shared/FocusContext-Xy0cwJpO.js +1 -0
  45. package/dist/packem_shared/FormField-af3aUpRL.js +1 -0
  46. package/dist/packem_shared/Fullscreen-CuJ8y0s0.js +1 -0
  47. package/dist/packem_shared/Gauge-Dz-usH__.js +1 -0
  48. package/dist/packem_shared/Gradient-DYNc0GZA.js +1 -0
  49. package/dist/packem_shared/Heading-mwEYza3Y.js +1 -0
  50. package/dist/packem_shared/Heatmap-ChL97U1-.js +1 -0
  51. package/dist/packem_shared/Help-Zcelyw_U.js +1 -0
  52. package/dist/packem_shared/Histogram-FIf2F83d.js +1 -0
  53. package/dist/packem_shared/IMECompositionBuffer-C89PhiOu.js +1 -0
  54. package/dist/packem_shared/InputParser-rZKjY_7Y.js +2 -0
  55. package/dist/packem_shared/KEY-Bk8B-3h_.js +1 -0
  56. package/dist/packem_shared/Kbd-DpkPp4jB.js +1 -0
  57. package/dist/packem_shared/LayoutNode-rxblE317.js +1 -0
  58. package/dist/packem_shared/LineChart-BXE_girm.js +1 -0
  59. package/dist/packem_shared/Link-i2o2EG4-.js +1 -0
  60. package/dist/packem_shared/LoadingIndicator-TC1Fjwyt.js +1 -0
  61. package/dist/packem_shared/Markdown-R1XqK63D.js +1 -0
  62. package/dist/packem_shared/MaskedInput-J01phOZs.js +1 -0
  63. package/dist/packem_shared/Menu-CfrH4ymk.js +1 -0
  64. package/dist/packem_shared/MessageBubble-BmBBU2Rm.js +1 -0
  65. package/dist/packem_shared/ModelBadge-D3wrXncu.js +1 -0
  66. package/dist/packem_shared/MouseProvider-pjza-lpc.js +1 -0
  67. package/dist/packem_shared/MultiSelect-Dqmn-bVo.js +1 -0
  68. package/dist/packem_shared/NAMED_COLORS-B9fJsYdg.js +1 -0
  69. package/dist/packem_shared/Newline-BSG4iUqp.js +2 -0
  70. package/dist/packem_shared/OperationTree-DksxjMIV.js +1 -0
  71. package/dist/packem_shared/OptionList-CNx7r9yN.js +1 -0
  72. package/dist/packem_shared/OrderedList-BeDy035w.js +1 -0
  73. package/dist/packem_shared/Paginator-B56s6bhS.js +1 -0
  74. package/dist/packem_shared/Paragraph-BqJlH0R-.js +1 -0
  75. package/dist/packem_shared/Placeholder-GMpHRGC8.js +1 -0
  76. package/dist/packem_shared/ProgressBar-Bj3fmORR.js +1 -0
  77. package/dist/packem_shared/RadioGroup-Br8BeEwS.js +1 -0
  78. package/dist/packem_shared/Renderer-DJXooAsp.js +1 -0
  79. package/dist/packem_shared/ResizeObserverEntry-Dq0dk8Kq.js +1 -0
  80. package/dist/packem_shared/ScatterPlot-OhfYco5l.js +1 -0
  81. package/dist/packem_shared/ScrollBar-Da5Y3z7N.js +1 -0
  82. package/dist/packem_shared/ScrollBarBox-Dz6F-Eat.js +1 -0
  83. package/dist/packem_shared/ScrollList-DiVGyEjv.js +1 -0
  84. package/dist/packem_shared/ScrollView-BojONotI.js +1 -0
  85. package/dist/packem_shared/SearchInput-BoPTRbhV.js +1 -0
  86. package/dist/packem_shared/SelectInput-CAJ7SCBq.js +1 -0
  87. package/dist/packem_shared/SelectInputIndicator-N1n8ULHs.js +1 -0
  88. package/dist/packem_shared/SelectInputItem-BEkbmobs.js +1 -0
  89. package/dist/packem_shared/ShimmerText-CuGQ2NDC.js +1 -0
  90. package/dist/packem_shared/Slider-Cg_tJpKa.js +1 -0
  91. package/dist/packem_shared/Spacer-eT3HOrXk.js +1 -0
  92. package/dist/packem_shared/Sparkline-T6_FPVET.js +1 -0
  93. package/dist/packem_shared/Spinner-B0-A50pu.js +1 -0
  94. package/dist/packem_shared/Static-DLynr5pn.js +1 -0
  95. package/dist/packem_shared/Static-jzLPaHJF.js +1 -0
  96. package/dist/packem_shared/StaticRender-BgD61E7x.js +1 -0
  97. package/dist/packem_shared/StatusLine-Ch4jjef1.js +1 -0
  98. package/dist/packem_shared/StatusMessage-B1qfKeMM.js +1 -0
  99. package/dist/packem_shared/Stepper-CNPAqxiU.js +1 -0
  100. package/dist/packem_shared/Stopwatch-CAx2EWwq.js +1 -0
  101. package/dist/packem_shared/StreamingText-BYOKSB2T.js +1 -0
  102. package/dist/packem_shared/Switch-DzSpKYu7.js +1 -0
  103. package/dist/packem_shared/Tab-BcXzSUdj.js +1 -0
  104. package/dist/packem_shared/Table-DJp1TLrR.js +1 -0
  105. package/dist/packem_shared/Tabs-D68z0SOt.js +1 -0
  106. package/dist/packem_shared/Tag-BvLHnYRn.js +1 -0
  107. package/dist/packem_shared/Text-mTAve9R2.js +1 -0
  108. package/dist/packem_shared/TextInput-C_gYQlnF.js +1 -0
  109. package/dist/packem_shared/Textarea-C2ET_oMb.js +2 -0
  110. package/dist/packem_shared/Timer-CI3aQX65.js +1 -0
  111. package/dist/packem_shared/Toast-Drvc8XfG.js +1 -0
  112. package/dist/packem_shared/Tooltip-C5UnQlLd.js +1 -0
  113. package/dist/packem_shared/Transform-fYmcdqRT.js +1 -0
  114. package/dist/packem_shared/Transition-CJDBKYUB.js +1 -0
  115. package/dist/packem_shared/TreeNodeMap-CspqSCpb.js +1 -0
  116. package/dist/packem_shared/TreeView-DjhacGJ5.js +1 -0
  117. package/dist/packem_shared/TuiApp-DrjI_i-R.js +1 -0
  118. package/dist/packem_shared/TuiContext-BoJvG3NN.js +3 -0
  119. package/dist/packem_shared/UnorderedList-BnfqexZs.js +1 -0
  120. package/dist/packem_shared/accessibility-context-DDyHTwmA.js +1 -0
  121. package/dist/packem_shared/animation-context-DW3p-vpk.js +1 -0
  122. package/dist/packem_shared/ansi-parser-B6uXaq65.js +1 -0
  123. package/dist/packem_shared/ansi-tokenizer-DqX9nJuk.js +1 -0
  124. package/dist/packem_shared/app-context-BVpKlG1z.js +1 -0
  125. package/dist/packem_shared/background-context-rjOaWFki.js +1 -0
  126. package/dist/packem_shared/boxes-DyY_LXCi.js +1 -0
  127. package/dist/packem_shared/braille-BBjIoaN0.js +1 -0
  128. package/dist/packem_shared/colorize-DbTZMrJO.js +1 -0
  129. package/dist/packem_shared/comparePoints-C85EsmNz.js +1 -0
  130. package/dist/packem_shared/controlled-scroll-view-CmrAEvJk.js +1 -0
  131. package/dist/packem_shared/createInlineLoop-DRNZ7jqH.js +2 -0
  132. package/dist/packem_shared/createLinkedScrollGroup-BMTJ7rAj.js +1 -0
  133. package/dist/packem_shared/createMemoryStorage-QVZNXbWz.js +2 -0
  134. package/dist/packem_shared/createScreen-CrLrxA6t.js +3 -0
  135. package/dist/packem_shared/cursor-context-CFviBqPX.js +1 -0
  136. package/dist/packem_shared/dom-4y__5fWB.js +1 -0
  137. package/dist/packem_shared/focus-context-CsT69klR.js +1 -0
  138. package/dist/packem_shared/format-time-C7Q-hQZq.js +1 -0
  139. package/dist/packem_shared/getPathToRoot-B2tKmx3i.js +1 -0
  140. package/dist/packem_shared/getScrollHeight-BTEY8ewu.js +1 -0
  141. package/dist/packem_shared/input-utils-fAxzSlNh.js +1 -0
  142. package/dist/packem_shared/input.d-Bfq7oc06.d.ts +90 -0
  143. package/dist/packem_shared/isIntersecting-B3KbKTmu.js +1 -0
  144. package/dist/packem_shared/isOsc52Supported-DKK7Uee6.js +1 -0
  145. package/dist/packem_shared/isTerminalPaletteQuerySupported-Dn2hFAZ_.js +1 -0
  146. package/dist/packem_shared/kittyFlags-C3rZLbcK.js +1 -0
  147. package/dist/packem_shared/line-chart-DrM8PwnI.js +1 -0
  148. package/dist/packem_shared/measure-element-DSp7YDus.js +2 -0
  149. package/dist/packem_shared/measure-text-DDjHT1jD.js +3 -0
  150. package/dist/packem_shared/measureElement-DA8WqFP_.js +1 -0
  151. package/dist/packem_shared/mouse-context-DaARgUu1.js +1 -0
  152. package/dist/packem_shared/parseSgrMouse-Ccj70ijb.js +1 -0
  153. package/dist/packem_shared/processLayout-DXDfFb_d.js +1 -0
  154. package/dist/packem_shared/reconciler-BuOP-TZ6.js +1 -0
  155. package/dist/packem_shared/reconciler-DSYCrIZs.js +1 -0
  156. package/dist/packem_shared/render-DDqtMAFN.js +1 -0
  157. package/dist/packem_shared/render-_r0K9K11.js +28 -0
  158. package/dist/packem_shared/render.d-BR3gA-N8.d.ts +1257 -0
  159. package/dist/packem_shared/renderToString-DeqOWRP8.js +4 -0
  160. package/dist/packem_shared/renderToString-IYYPyASm.js +2 -0
  161. package/dist/packem_shared/renderTreeToBuffer-DPkoCgP2.js +2 -0
  162. package/dist/packem_shared/renderer-D2p6av2X.js +17 -0
  163. package/dist/packem_shared/setEnableStyledLineCache-D2gZbwFM.js +1 -0
  164. package/dist/packem_shared/squashTextNodesWithMap-Cpqmc45i.js +1 -0
  165. package/dist/packem_shared/stderr-context-BzEaUICS.js +1 -0
  166. package/dist/packem_shared/stdin-context-BTaaFagk.js +1 -0
  167. package/dist/packem_shared/stdout-context-BnblEPez.js +1 -0
  168. package/dist/packem_shared/text-width-CZ9vPvM0.js +2 -0
  169. package/dist/packem_shared/token-to-elements-BYxT6J_Q.js +1 -0
  170. package/dist/packem_shared/treeViewTheme-1RIZyB4M.js +1 -0
  171. package/dist/packem_shared/useAnimation-B9we6ZzL.js +1 -0
  172. package/dist/packem_shared/useApp-B6fvM42d.js +1 -0
  173. package/dist/packem_shared/useBoxMetrics-D5pkIr6P.js +1 -0
  174. package/dist/packem_shared/useClipboard-CBxy0hT8.js +1 -0
  175. package/dist/packem_shared/useColorBlindness-BvWcu2Bb.js +1 -0
  176. package/dist/packem_shared/useConsoleCapture-BxiG8iLJ.js +1 -0
  177. package/dist/packem_shared/useCursor-CPu8T5Db.js +1 -0
  178. package/dist/packem_shared/useElementDimensions-qJ_WXFZ9.js +1 -0
  179. package/dist/packem_shared/useFocus-DSmziO_x.js +1 -0
  180. package/dist/packem_shared/useFocusManager-Uapn3LQo.js +1 -0
  181. package/dist/packem_shared/useForm-CzV-Oext.js +1 -0
  182. package/dist/packem_shared/useHotkey-D0dGey14.js +1 -0
  183. package/dist/packem_shared/useInput-D1_jG26Z.js +2 -0
  184. package/dist/packem_shared/useInterval-AobjZT3u.js +1 -0
  185. package/dist/packem_shared/useIsScreenReaderEnabled-DjWHh-II.js +1 -0
  186. package/dist/packem_shared/useKeyBindings-zabkEJQs.js +1 -0
  187. package/dist/packem_shared/useKeyChord-CICQIxXj.js +1 -0
  188. package/dist/packem_shared/useMouseAction-2dRfU1vE.js +1 -0
  189. package/dist/packem_shared/useMouseContext-C746G7kY.js +1 -0
  190. package/dist/packem_shared/useMousePosition-BTWfV4JK.js +1 -0
  191. package/dist/packem_shared/useOnMouseClick-nY8xLZmt.js +1 -0
  192. package/dist/packem_shared/useOnMouseHover-D3DczIol.js +1 -0
  193. package/dist/packem_shared/useOnMouseState-cRK8QvzD.js +1 -0
  194. package/dist/packem_shared/usePaste-CKKB9H-Z.js +1 -0
  195. package/dist/packem_shared/useScrollAcceleration-NrY1oVMs.js +1 -0
  196. package/dist/packem_shared/useScrollInput-Caghtn-Q.js +1 -0
  197. package/dist/packem_shared/useStderr-BDZb6InG.js +1 -0
  198. package/dist/packem_shared/useStdin-DKa4h35k.js +1 -0
  199. package/dist/packem_shared/useStdout-B-2lX4C5.js +1 -0
  200. package/dist/packem_shared/useStopwatch-DffK7iMh.js +1 -0
  201. package/dist/packem_shared/useTerminalPalette-Cv7tSduR.js +1 -0
  202. package/dist/packem_shared/useTextBuffer-DekkGLxI.js +4 -0
  203. package/dist/packem_shared/useTextSelection-CGT0GLDR.js +1 -0
  204. package/dist/packem_shared/useTimeout-7LEFYTnG.js +1 -0
  205. package/dist/packem_shared/useTimer-DyoqSyGi.js +1 -0
  206. package/dist/packem_shared/useTreeView-8UlTK6sW.js +1 -0
  207. package/dist/packem_shared/useTreeViewState-CRPCUWrb.js +1 -0
  208. package/dist/packem_shared/useWindowSize-yDZsXF8z.js +1 -0
  209. package/dist/packem_shared/utils-THUhYKG2.js +1 -0
  210. package/dist/packem_shared/variant-config-BJqpNo7H.js +1 -0
  211. package/dist/packem_shared/waitFor-Dj5zfL5s.js +4 -0
  212. package/dist/packem_shared/wrapOrTruncateStyledLine-BZ00SM8i.js +3 -0
  213. package/dist/react/index.d.ts +519 -0
  214. package/dist/react/index.js +1 -0
  215. package/dist/testing/index.d.ts +283 -0
  216. package/dist/testing/index.js +1 -0
  217. package/index.js +737 -0
  218. package/package.json +113 -7
@@ -0,0 +1,283 @@
1
+ import { ReactElement } from 'react';
2
+ import { R as RenderOptions } from "../packem_shared/render.d-BR3gA-N8.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";
23
+ };
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;
178
+ };
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;
188
+ };
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>;
241
+ };
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">;
252
+ };
253
+ /**
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
+ */
267
+ declare const testRender: (node: ReactElement, testOptions?: TestRenderOptions) => TestInstance;
268
+ /**
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
+ */
282
+ declare const cleanup: () => void;
283
+ export { KEY, type KeyName, type KeySender, type Screen, TestInstance, TestInstanceStderr, TestInstanceStdin, TestInstanceStdout, TestRenderOptions, type WaitForOptions, cleanup, createKeySender, createScreen, testRender as render, waitFor };
@@ -0,0 +1 @@
1
+ var w=Object.defineProperty;var a=(t,e)=>w(t,"name",{value:e,configurable:!0});import{createRequire as F}from"node:module";import x from"../packem_shared/render-_r0K9K11.js";import{createKeySender as y}from"../packem_shared/KEY-Bk8B-3h_.js";import{KEY as $}from"../packem_shared/KEY-Bk8B-3h_.js";import{createScreen as T}from"../packem_shared/createScreen-CrLrxA6t.js";import{waitFor as j}from"../packem_shared/waitFor-Dj5zfL5s.js";const b=F(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=a(t=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,i]=o.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return o.getBuiltinModule(t)}return b(t)},"__cjs_getBuiltinModule"),l=v("node:events");var R=Object.defineProperty,r=a((t,e)=>R(t,"name",{value:e,configurable:!0}),"t");class S extends l{static{a(this,"v")}static{r(this,"Stdout")}columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=r(e=>(this._frames.push(e),this._lastFrame=e,!0),"write")}class D extends l{static{a(this,"x")}static{r(this,"Stderr")}columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=r(e=>(this._frames.push(e),this._lastFrame=e,!0),"write")}class P extends l{static{a(this,"R")}static{r(this,"Stdin")}isTTY=!0;pendingData;write=r(e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0),"write");read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const c=[],O=r((t,e={})=>{const{columns:i,options:p}=e,n=new S(i),d=new D(i),m=new P,u=x(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:d,stdin:m,stdout:n,...p});c.push(u);const f=T(()=>n.lastFrame(),n.frames),h=y(s=>m.write(s)),_=r(async()=>{await new Promise(s=>{setTimeout(s,0)}),await new Promise(s=>{setTimeout(s,0)})},"flush");return{cleanup:u.cleanup,flush:_,get frames(){return n.frames},keys:h,lastFrame:r(()=>n.lastFrame(),"lastFrame"),rerender:u.rerender,screen:f,stderr:d,stdin:m,stdout:n,unmount:u.unmount,async waitFor(s,g){await j(s,()=>f.text(),g)}}},"testRender"),Y=r(()=>{for(const t of c)t.cleanup();c.length=0},"cleanup");export{$ as KEY,Y as cleanup,y as createKeySender,T as createScreen,O as render,j as waitFor};