@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
@@ -0,0 +1,1257 @@
1
+ import { ReactNode } from 'react';
2
+ import { Node } from 'yoga-layout';
3
+ import { AnsiColors } from '@visulima/colorize';
4
+ import { LiteralUnion } from 'type-fest';
5
+ import 'node:stream';
6
+ type StyleSpan = {
7
+ bgColor?: string;
8
+ fgColor?: string;
9
+ formatFlags: number;
10
+ length: number;
11
+ link?: string;
12
+ };
13
+ declare class StyledLine {
14
+ length: number;
15
+ private static readonly emptyCache;
16
+ private text;
17
+ private charData;
18
+ private spans;
19
+ private _cachedTrimmedLength?;
20
+ static empty(length: number): StyledLine;
21
+ getValue(index: number): string;
22
+ /**
23
+ * Get the raw text for a range of characters as a single string slice.
24
+ * Much faster than calling getValue() per character.
25
+ */
26
+ getTextRange(start: number, end: number): string;
27
+ getSpan(index: number): StyleSpan | undefined;
28
+ getFullWidth(index: number): boolean;
29
+ hasStyles(index: number): boolean;
30
+ getFormatFlags(index: number): number;
31
+ getFgColor(index: number): string | undefined;
32
+ getBgColor(index: number): string | undefined;
33
+ getLink(index: number): string | undefined;
34
+ setInverted(index: number, inverted: boolean): void;
35
+ setBackgroundColor(index: number, color: string | undefined): void;
36
+ setForegroundColor(index: number, color: string | undefined): void;
37
+ setChar(index: number, value: string, formatFlags: number, fgColor?: string, bgColor?: string, link?: string): void;
38
+ /**
39
+ * Optimized setChar for same-length single-byte replacement.
40
+ * Skips string rebuild and offset adjustment when old and new values
41
+ * have the same byte length (the common case for ASCII overwrites on empty lines).
42
+ */
43
+ setCharFast(index: number, value: string, formatFlags: number, fgColor?: string, bgColor?: string, link?: string): void;
44
+ /**
45
+ * Overwrite a range of this line with content from a source StyledLine.
46
+ * More efficient than calling setChar() per character because it does
47
+ * a single span split + rebuild instead of per-character span manipulation.
48
+ * @param destinationStart — start index in this line
49
+ * @param source — the StyledLine to copy from
50
+ * @param srcStart — start index in source (default 0)
51
+ * @param count — number of characters to copy (default: source.length)
52
+ */
53
+ writeFrom(destinationStart: number, source: StyledLine, srcStart?: number, count?: number): void;
54
+ pushChar(value: string, formatFlags: number, fgColor?: string, bgColor?: string, link?: string): void;
55
+ clone(): StyledLine;
56
+ slice(start: number, end?: number): StyledLine;
57
+ combine(...others: StyledLine[]): StyledLine;
58
+ getTrimmedLength(): number;
59
+ trimEnd(): StyledLine;
60
+ equals(other: StyledLine): boolean;
61
+ getText(): string;
62
+ getSpans(): StyleSpan[];
63
+ getValues(): string[];
64
+ [Symbol.iterator](): Iterator<{
65
+ bgColor?: string;
66
+ fgColor?: string;
67
+ formatFlags: number;
68
+ fullWidth: boolean;
69
+ hasStyles: boolean;
70
+ link?: string;
71
+ value: string;
72
+ }>;
73
+ /**
74
+ * Split the span at `index` into a single-char span, apply the updater,
75
+ * then merge adjacent spans. Shared by setInverted/setBackgroundColor/setForegroundColor.
76
+ */
77
+ private updateSpanAt;
78
+ /**
79
+ * Grow the line to at least `minWidth` columns, filling new cells with
80
+ * empty strings (zero-width placeholders). This matches the behavior of
81
+ * sparse JS arrays in the original ink Output where out-of-bounds writes
82
+ * created gaps that produced no visible output.
83
+ */
84
+ ensureWidth(minWidth: number): void;
85
+ private ensureInitialized;
86
+ private splitSpansAt;
87
+ /**
88
+ * Try to apply a single-char style at `index` by matching or merging
89
+ * with an adjacent span, avoiding splitSpansAt + mergeSpans.
90
+ *
91
+ * Returns true if the style was applied (or was already correct),
92
+ * false if the caller must fall through to the split/update/merge path.
93
+ *
94
+ * Ported from jacob314/ink PR #123 (Google LLC, Apache-2.0).
95
+ */
96
+ private trySetStyleAtIndex;
97
+ private mergeSpans;
98
+ }
99
+ type Region = {
100
+ backgroundColor?: string;
101
+ borderBottom?: number;
102
+ borderTop?: number;
103
+ cachedStickyHeaders?: StickyHeader$1[]; /** Child regions (nested content areas) */
104
+ children: Region[];
105
+ /** Cursor position within this region */
106
+ cursorPosition?: {
107
+ col: number;
108
+ row: number;
109
+ };
110
+ height: number; /** Unique identifier for this region (used for dirty tracking) */
111
+ id: number | string;
112
+ isHorizontallyScrollable?: boolean; /** Whether this region supports scrolling */
113
+ isScrollable: boolean;
114
+ isVerticallyScrollable?: boolean; /** Content buffer — StyledLine per row, relative to (0,0) of this region */
115
+ readonly lines: ReadonlyArray<StyledLine>;
116
+ marginBottom?: number;
117
+ marginRight?: number; /** DOM node reference for debugging/caching */
118
+ nodeId?: number;
119
+ opaque?: boolean; /** Layout properties */
120
+ overflowToBackbuffer?: boolean;
121
+ scrollbarThumbColor?: string;
122
+ scrollbarVisible?: boolean;
123
+ scrollHeight?: number;
124
+ scrollLeft?: number; /** Scroll state */
125
+ scrollTop?: number;
126
+ scrollWidth?: number; /** Selectable text spans for text selection */
127
+ selectableSpans: SelectableSpan[];
128
+ selectableText?: string; /** Whether the scrollback position is stable */
129
+ stableScrollback?: boolean;
130
+ /** Sticky headers for this region */
131
+ stickyHeaders: StickyHeader$1[];
132
+ /** Trimmed output (trailing spaces removed) for final rendering */
133
+ readonly styledOutput: ReadonlyArray<StyledLine>;
134
+ /** Dimensions */
135
+ width: number;
136
+ /** Position relative to parent region */
137
+ x: number;
138
+ y: number;
139
+ };
140
+ type SelectableSpan = {
141
+ endX: number;
142
+ startX: number;
143
+ text: string;
144
+ y: number;
145
+ };
146
+ type StickyHeader$1 = {
147
+ /** Lines in the natural (scrolling) position */
148
+ lines: ReadonlyArray<StyledLine>;
149
+ /** Height of the header in lines */
150
+ maxHeaderHeight: number;
151
+ /** Natural row offset relative to content start */
152
+ naturalRow: number;
153
+ /** Node ID for identification */
154
+ nodeId: number;
155
+ /** Lines in the stuck (fixed) position */
156
+ stuckLines?: ReadonlyArray<StyledLine>;
157
+ /** Stuck X position relative to region */
158
+ x: number;
159
+ /** Stuck Y position relative to region */
160
+ y: number;
161
+ };
162
+ type OutputTransformer = (s: string, index: number) => string;
163
+ type ResizeObserverCallback = (entries: ResizeObserverEntry[], observer: ResizeObserver) => void;
164
+ declare class ResizeObserverEntry {
165
+ readonly target: DOMElement;
166
+ readonly contentRect: Readonly<{
167
+ height: number;
168
+ width: number;
169
+ }>;
170
+ constructor(target: DOMElement, contentRect: Readonly<{
171
+ height: number;
172
+ width: number;
173
+ }>);
174
+ }
175
+ declare class ResizeObserver {
176
+ private readonly callback;
177
+ private readonly observedElements;
178
+ constructor(callback: ResizeObserverCallback);
179
+ observe(element: DOMElement): void;
180
+ unobserve(element: DOMElement): void;
181
+ disconnect(): void;
182
+ /**
183
+ * Internal method called by the layout engine after computing layout.
184
+ */
185
+ internalTrigger(entries: ResizeObserverEntry[]): void;
186
+ }
187
+ /**
188
+ * Measure a node and collect resize observer entries for it.
189
+ * Used by both the main render loop and static render processing.
190
+ */
191
+ type ScrollState = {
192
+ actualScrollHeight: number;
193
+ clientHeight: number;
194
+ clientWidth: number;
195
+ scrollHeight: number;
196
+ scrollLeft: number;
197
+ scrollTop: number;
198
+ scrollWidth: number;
199
+ };
200
+ declare const getScrollHeight: (node: DOMElement) => number;
201
+ declare const getScrollWidth: (node: DOMElement) => number;
202
+ declare const calculateScroll: (node: DOMElement) => void;
203
+ /**
204
+ * Get the effective scroll top position from the pre-computed scroll state.
205
+ * Falls back to computing from style if scroll state hasn't been calculated yet.
206
+ */
207
+ declare const getScrollTop: (node: DOMElement) => number;
208
+ /**
209
+ * Get the effective scroll left position from the pre-computed scroll state.
210
+ * Falls back to computing from style if scroll state hasn't been calculated yet.
211
+ */
212
+ declare const getScrollLeft: (node: DOMElement) => number;
213
+ /**
214
+ Style of the box border.
215
+ */
216
+ type BoxStyle = {
217
+ readonly topLeft: string;
218
+ readonly top: string;
219
+ readonly topRight: string;
220
+ readonly right: string;
221
+ readonly bottomRight: string;
222
+ readonly bottom: string;
223
+ readonly bottomLeft: string;
224
+ readonly left: string;
225
+ };
226
+ /**
227
+ All box styles.
228
+ */
229
+ type Boxes = {
230
+ /**
231
+ @example
232
+ ```
233
+ ┌────┐
234
+ │ │
235
+ └────┘
236
+ ```
237
+ */
238
+ readonly single: BoxStyle;
239
+
240
+ /**
241
+ @example
242
+ ```
243
+ ╔════╗
244
+ ║ ║
245
+ ╚════╝
246
+ ```
247
+ */
248
+ readonly double: BoxStyle;
249
+
250
+ /**
251
+ @example
252
+ ```
253
+ ╭────╮
254
+ │ │
255
+ ╰────╯
256
+ ```
257
+ */
258
+ readonly round: BoxStyle;
259
+
260
+ /**
261
+ @example
262
+ ```
263
+ ┏━━━━┓
264
+ ┃ ┃
265
+ ┗━━━━┛
266
+ ```
267
+ */
268
+ readonly bold: BoxStyle;
269
+
270
+ /**
271
+ @example
272
+ ```
273
+ ╓────╖
274
+ ║ ║
275
+ ╙────╜
276
+ ```
277
+ */
278
+ readonly singleDouble: BoxStyle;
279
+
280
+ /**
281
+ @example
282
+ ```
283
+ ╒════╕
284
+ │ │
285
+ ╘════╛
286
+ ```
287
+ */
288
+ readonly doubleSingle: BoxStyle;
289
+
290
+ /**
291
+ @example
292
+ ```
293
+ +----+
294
+ | |
295
+ +----+
296
+ ```
297
+ */
298
+ readonly classic: BoxStyle;
299
+
300
+ /**
301
+ @example
302
+ ```
303
+ ↘↓↓↓↓↙
304
+ → ←
305
+ ↗↑↑↑↑↖
306
+ ```
307
+ */
308
+ readonly arrow: BoxStyle;
309
+ };
310
+ type Styles = {
311
+ /**
312
+ * It defines the alignment along the cross axis when there are multiple lines of flex items (when using flex-wrap).
313
+ * See [align-content](https://css-tricks.com/almanac/properties/a/align-content/).
314
+ */
315
+ readonly alignContent?: "flex-start" | "flex-end" | "center" | "stretch" | "space-between" | "space-around" | "space-evenly";
316
+ /**
317
+ * The align-items property defines the default behavior for how items are laid out along the cross axis (perpendicular to the main axis).
318
+ * See [align-items](https://css-tricks.com/almanac/properties/a/align-items/).
319
+ */
320
+ readonly alignItems?: "flex-start" | "center" | "flex-end" | "stretch" | "baseline";
321
+ /**
322
+ * It makes possible to override the align-items value for specific flex items.
323
+ * See [align-self](https://css-tricks.com/almanac/properties/a/align-self/).
324
+ */
325
+ readonly alignSelf?: "flex-start" | "center" | "flex-end" | "auto" | "stretch" | "baseline";
326
+ /**
327
+ * Defines the aspect ratio (width/height) for the element.
328
+ *
329
+ * Use it with at least one size constraint (`width`, `height`, `minHeight`, or `maxHeight`) so Ink can derive the missing dimension.
330
+ */
331
+ readonly aspectRatio?: number;
332
+ /**
333
+ * Background color for the element.
334
+ *
335
+ * Accepts the same values as `color` in the `&lt;Text>` component.
336
+ */
337
+ readonly backgroundColor?: LiteralUnion<AnsiColors, string>;
338
+ /**
339
+ * Change border background color. A shorthand for setting `borderTopBackgroundColor`, `borderRightBackgroundColor`, `borderBottomBackgroundColor`, and `borderLeftBackgroundColor`.
340
+ */
341
+ readonly borderBackgroundColor?: LiteralUnion<AnsiColors, string>;
342
+ /**
343
+ * Determines whether the bottom border is visible.
344
+ * @default true
345
+ */
346
+ readonly borderBottom?: boolean;
347
+ /**
348
+ * Change the bottom border background color. Accepts the same values as `backgroundColor` in `Text` component.
349
+ */
350
+ readonly borderBottomBackgroundColor?: LiteralUnion<AnsiColors, string>;
351
+ /**
352
+ * Change the bottom border color. Accepts the same values as `color` in `Text` component.
353
+ */
354
+ readonly borderBottomColor?: LiteralUnion<AnsiColors, string>;
355
+ /**
356
+ * Dim the bottom border color.
357
+ * @default false
358
+ */
359
+ readonly borderBottomDimColor?: boolean;
360
+ /**
361
+ * Text to display embedded in the bottom border line.
362
+ * Rendered as: `└─ title ─────────┘`
363
+ */
364
+ readonly borderBottomTitle?: string;
365
+ /**
366
+ * Alignment of the bottom border title.
367
+ * @default "left"
368
+ */
369
+ readonly borderBottomTitleAlignment?: "center" | "left" | "right";
370
+ /**
371
+ * Change border color. A shorthand for setting `borderTopColor`, `borderRightColor`, `borderBottomColor`, and `borderLeftColor`.
372
+ */
373
+ readonly borderColor?: LiteralUnion<AnsiColors, string>;
374
+ /**
375
+ * Dim the border color. A shorthand for setting `borderTopDimColor`, `borderBottomDimColor`, `borderLeftDimColor`, and `borderRightDimColor`.
376
+ * @default false
377
+ */
378
+ readonly borderDimColor?: boolean;
379
+ /**
380
+ * Determines whether the left border is visible.
381
+ * @default true
382
+ */
383
+ readonly borderLeft?: boolean;
384
+ /**
385
+ * Change the left border background color. Accepts the same values as `backgroundColor` in `Text` component.
386
+ */
387
+ readonly borderLeftBackgroundColor?: LiteralUnion<AnsiColors, string>;
388
+ /**
389
+ * Change the left border color. Accepts the same values as `color` in `Text` component.
390
+ */
391
+ readonly borderLeftColor?: LiteralUnion<AnsiColors, string>;
392
+ /**
393
+ * Dim the left border color.
394
+ * @default false
395
+ */
396
+ readonly borderLeftDimColor?: boolean;
397
+ /**
398
+ * Determines whether the right border is visible.
399
+ * @default true
400
+ */
401
+ readonly borderRight?: boolean;
402
+ /**
403
+ * Change the right border background color. Accepts the same values as `backgroundColor` in `Text` component.
404
+ */
405
+ readonly borderRightBackgroundColor?: LiteralUnion<AnsiColors, string>;
406
+ /**
407
+ * Change the right border color. Accepts the same values as `color` in `Text` component.
408
+ */
409
+ readonly borderRightColor?: LiteralUnion<AnsiColors, string>;
410
+ /**
411
+ * Dim the right border color.
412
+ * @default false
413
+ */
414
+ readonly borderRightDimColor?: boolean;
415
+ /**
416
+ * Add a border with a specified style. If `borderStyle` is `undefined` (the default), no border will be added.
417
+ */
418
+ readonly borderStyle?: keyof Boxes | BoxStyle;
419
+ /**
420
+ * Determines whether the top border is visible.
421
+ * @default true
422
+ */
423
+ readonly borderTop?: boolean;
424
+ /**
425
+ * Change the top border background color. Accepts the same values as `backgroundColor` in `Text` component.
426
+ */
427
+ readonly borderTopBackgroundColor?: LiteralUnion<AnsiColors, string>;
428
+ /**
429
+ * Change the top border color. Accepts the same values as `color` in `Text` component.
430
+ */
431
+ readonly borderTopColor?: LiteralUnion<AnsiColors, string>;
432
+ /**
433
+ * Dim the top border color.
434
+ * @default false
435
+ */
436
+ readonly borderTopDimColor?: boolean;
437
+ /**
438
+ * Text to display on the right side of the top border line.
439
+ * Rendered as: `┌─ title ──── rightTitle ─┐`
440
+ */
441
+ readonly borderTopRightTitle?: string;
442
+ /**
443
+ * Text to display embedded in the top border line.
444
+ * Rendered as: `┌─ title ─────────┐`
445
+ */
446
+ readonly borderTopTitle?: string;
447
+ /**
448
+ * Alignment of the top border title.
449
+ * @default "left"
450
+ */
451
+ readonly borderTopTitleAlignment?: "center" | "left" | "right";
452
+ /**
453
+ * Bottom offset for positioned elements.
454
+ */
455
+ readonly bottom?: number | string;
456
+ /**
457
+ * Size of the gap between an element's columns.
458
+ */
459
+ readonly columnGap?: number;
460
+ /**
461
+ * Set this property to `none` to hide the element.
462
+ */
463
+ readonly display?: "flex" | "none";
464
+ /**
465
+ * It specifies the initial size of the flex item, before any available space is distributed according to the flex factors.
466
+ * See [flex-basis](https://css-tricks.com/almanac/properties/f/flex-basis/).
467
+ */
468
+ readonly flexBasis?: number | string;
469
+ /**
470
+ * It establishes the main-axis, thus defining the direction flex items are placed in the flex container.
471
+ * See [flex-direction](https://css-tricks.com/almanac/properties/f/flex-direction/).
472
+ */
473
+ readonly flexDirection?: "row" | "column" | "row-reverse" | "column-reverse";
474
+ /**
475
+ * This property defines the ability for a flex item to grow if necessary.
476
+ * See [flex-grow](https://css-tricks.com/almanac/properties/f/flex-grow/).
477
+ */
478
+ readonly flexGrow?: number;
479
+ /**
480
+ * It specifies the “flex shrink factor”, which determines how much the flex item will shrink relative to the rest of the flex items in the flex container when there isn’t enough space on the row.
481
+ * See [flex-shrink](https://css-tricks.com/almanac/properties/f/flex-shrink/).
482
+ */
483
+ readonly flexShrink?: number;
484
+ /**
485
+ * It defines whether the flex items are forced in a single line or can be flowed into multiple lines. If set to multiple lines, it also defines the cross-axis which determines the direction new lines are stacked in.
486
+ * See [flex-wrap](https://css-tricks.com/almanac/properties/f/flex-wrap/).
487
+ */
488
+ readonly flexWrap?: "nowrap" | "wrap" | "wrap-reverse";
489
+ /**
490
+ * Size of the gap between an element's columns and rows. A shorthand for `columnGap` and `rowGap`.
491
+ */
492
+ readonly gap?: number;
493
+ /**
494
+ * Height of the element in lines (rows). You can also set it as a percentage, which will calculate the height based on the height of the parent element.
495
+ */
496
+ readonly height?: number | string;
497
+ /**
498
+ * It defines the alignment along the main axis.
499
+ * See [justify-content](https://css-tricks.com/almanac/properties/j/justify-content/).
500
+ */
501
+ readonly justifyContent?: "flex-start" | "flex-end" | "space-between" | "space-around" | "space-evenly" | "center";
502
+ /**
503
+ * Left offset for positioned elements.
504
+ */
505
+ readonly left?: number | string;
506
+ /**
507
+ * Margin on all sides. Equivalent to setting `marginTop`, `marginBottom`, `marginLeft`, and `marginRight`.
508
+ */
509
+ readonly margin?: number;
510
+ /**
511
+ * Bottom margin.
512
+ */
513
+ readonly marginBottom?: number;
514
+ /**
515
+ * Left margin.
516
+ */
517
+ readonly marginLeft?: number;
518
+ /**
519
+ * Right margin.
520
+ */
521
+ readonly marginRight?: number;
522
+ /**
523
+ * Top margin.
524
+ */
525
+ readonly marginTop?: number;
526
+ /**
527
+ * Horizontal margin. Equivalent to setting `marginLeft` and `marginRight`.
528
+ */
529
+ readonly marginX?: number;
530
+ /**
531
+ * Vertical margin. Equivalent to setting `marginTop` and `marginBottom`.
532
+ */
533
+ readonly marginY?: number;
534
+ /**
535
+ * Sets a maximum height of the element in lines (rows). You can also set it as a percentage, which will calculate the maximum height based on the height of the parent element.
536
+ */
537
+ readonly maxHeight?: number | string;
538
+ /**
539
+ * Sets a maximum width of the element.
540
+ * Percentages aren't supported yet; see https://github.com/facebook/yoga/issues/872.
541
+ */
542
+ readonly maxWidth?: number | string;
543
+ /**
544
+ * Sets a minimum height of the element in lines (rows). You can also set it as a percentage, which will calculate the minimum height based on the height of the parent element.
545
+ */
546
+ readonly minHeight?: number | string;
547
+ /**
548
+ * Sets a minimum width of the element.
549
+ * Percentages aren't supported yet; see https://github.com/facebook/yoga/issues/872.
550
+ */
551
+ readonly minWidth?: number | string;
552
+ /**
553
+ * Behavior for an element's overflow in both directions.
554
+ * @default 'visible'
555
+ */
556
+ readonly overflow?: "visible" | "hidden" | "scroll";
557
+ /**
558
+ * If true, content that is scrolled out of the top of the box (when overflowY is 'scroll')
559
+ * will be added to the terminal's scrollback history.
560
+ *
561
+ * Results are undefined if more than one scrollable region in the app has
562
+ * overflowToBackbuffer enabled.
563
+ *
564
+ * Note: Scroll height tracking is implemented but actual backbuffer writes
565
+ * require worker-based rendering (not yet ported).
566
+ * @default false
567
+ */
568
+ readonly overflowToBackbuffer?: boolean;
569
+ /**
570
+ * Behavior for an element's overflow in the horizontal direction.
571
+ * @default 'visible'
572
+ */
573
+ readonly overflowX?: "visible" | "hidden" | "scroll";
574
+ /**
575
+ * Behavior for an element's overflow in the vertical direction.
576
+ * @default 'visible'
577
+ */
578
+ readonly overflowY?: "visible" | "hidden" | "scroll";
579
+ /**
580
+ * Padding on all sides. Equivalent to setting `paddingTop`, `paddingBottom`, `paddingLeft`, and `paddingRight`.
581
+ */
582
+ readonly padding?: number;
583
+ /**
584
+ * Bottom padding.
585
+ */
586
+ readonly paddingBottom?: number;
587
+ /**
588
+ * Left padding.
589
+ */
590
+ readonly paddingLeft?: number;
591
+ /**
592
+ * Right padding.
593
+ */
594
+ readonly paddingRight?: number;
595
+ /**
596
+ * Top padding.
597
+ */
598
+ readonly paddingTop?: number;
599
+ /**
600
+ * Horizontal padding. Equivalent to setting `paddingLeft` and `paddingRight`.
601
+ */
602
+ readonly paddingX?: number;
603
+ /**
604
+ * Vertical padding. Equivalent to setting `paddingTop` and `paddingBottom`.
605
+ */
606
+ readonly paddingY?: number;
607
+ /**
608
+ * Controls how the element is positioned.
609
+ *
610
+ * When `position` is `static`, `top`, `right`, `bottom`, and `left` are ignored.
611
+ */
612
+ readonly position?: "absolute" | "relative" | "static";
613
+ /**
614
+ * Right offset for positioned elements.
615
+ */
616
+ readonly right?: number | string;
617
+ /**
618
+ * Size of the gap between an element's rows.
619
+ */
620
+ readonly rowGap?: number;
621
+ /**
622
+ * Color of the scrollbar thumb when overflow is set to 'scroll'.
623
+ */
624
+ readonly scrollbarThumbColor?: LiteralUnion<AnsiColors, string>;
625
+ /**
626
+ * Horizontal scroll position (in columns). Only applies when overflowX or overflow is 'scroll'.
627
+ */
628
+ readonly scrollLeft?: number;
629
+ /**
630
+ * Vertical scroll position (in rows). Only applies when overflowY or overflow is 'scroll'.
631
+ */
632
+ readonly scrollTop?: number;
633
+ /**
634
+ * If true, and `overflowToBackbuffer` is also enabled, the `scrollHeight` of the box
635
+ * will never decrease as long as the existing history remains valid.
636
+ * This prevents the terminal's scrollback from being corrupted when content shrinks.
637
+ *
638
+ * Note: Scroll height tracking is implemented but actual backbuffer writes
639
+ * require worker-based rendering (not yet ported).
640
+ * @default false
641
+ */
642
+ readonly stableScrollback?: boolean;
643
+ /**
644
+ * Controls how text wraps when it exceeds the container width.
645
+ *
646
+ * - `wrap` (default) — Wrap at word boundaries; break inside words only when a single word exceeds the width.
647
+ * - `wrap-anywhere` — Break at any character boundary, even when a whitespace break exists earlier.
648
+ * - `wrap-preserve-words` — Wrap at word boundaries; never break inside words (long words may overflow).
649
+ * - `wrap-strict` — Enforce exact width; always break at the column limit.
650
+ * - `hard` — Alias for `wrap-strict`. Fills each line to the full column width, breaking words mid-word as needed.
651
+ * - `truncate` / `truncate-end` — Truncate at the end with an ellipsis.
652
+ * - `truncate-start` — Truncate at the start with an ellipsis.
653
+ * - `truncate-middle` — Truncate in the middle with an ellipsis.
654
+ */
655
+ readonly textWrap?: "hard" | "wrap" | "wrap-anywhere" | "wrap-preserve-words" | "wrap-strict" | "end" | "middle" | "truncate-end" | "truncate" | "truncate-middle" | "truncate-start";
656
+ /**
657
+ * Top offset for positioned elements.
658
+ */
659
+ readonly top?: number | string;
660
+ /**
661
+ * Determines whether the user can select text within this element.
662
+ * - `auto`: Default behavior, text is selectable.
663
+ * - `none`: Text cannot be selected.
664
+ * - `text`: Only text can be selected.
665
+ * - `all`: All content is selected on click.
666
+ */
667
+ readonly userSelect?: "auto" | "none" | "text" | "all";
668
+ /**
669
+ * Width of the element in spaces. You can also set it as a percentage, which will calculate the width based on the width of the parent element.
670
+ */
671
+ readonly width?: number | string;
672
+ };
673
+ type InkNode = {
674
+ internal_static?: boolean;
675
+ parentNode: DOMElement | undefined;
676
+ style: Styles;
677
+ yogaNode?: Node;
678
+ };
679
+ type LayoutListener = () => void;
680
+ type TextName = "#text";
681
+ type ElementNames = "ink-root" | "ink-box" | "ink-text" | "ink-cursor" | "ink-virtual-text" | "ink-static-render";
682
+ /**
683
+ * Describes a sticky header that should be composited on top of scrolled content.
684
+ * Ported from jacob314/ink fork (Google LLC, Apache-2.0).
685
+ */
686
+ type StickyHeader = {
687
+ /** Content-relative end row. */
688
+ endRow: number;
689
+ /** Height in rows. */
690
+ height?: number;
691
+ /** If true, natural 'lines' are already in background content. */
692
+ isStuckOnly: boolean;
693
+ /** Lines rendered in the natural (scrolling) position. */
694
+ lines: ReadonlyArray<StyledLine>;
695
+ /** Natural row offset relative to content start. */
696
+ naturalRow: number;
697
+ /** Reference to the DOM node for this header. */
698
+ node?: DOMElement;
699
+ /** Unique ID of the sticky node. */
700
+ nodeId: number;
701
+ /** ID of the scroll container this header belongs to. */
702
+ scrollContainerId: number | string;
703
+ /** Content-relative start row. */
704
+ startRow: number;
705
+ /** Lines rendered in the stuck (pinned) position, if different. */
706
+ stuckLines?: ReadonlyArray<StyledLine>;
707
+ /** Sticky type: top-pinned or bottom-pinned. */
708
+ type?: "top" | "bottom";
709
+ /** Stuck X position relative to region. */
710
+ x: number;
711
+ /** Stuck Y position relative to region. */
712
+ y: number;
713
+ };
714
+ type NodeNames = ElementNames | TextName;
715
+ type CursorAnchorRef = {
716
+ readonly current: DOMElement | undefined | null;
717
+ };
718
+ type CursorMarker = {
719
+ anchorRef?: CursorAnchorRef;
720
+ inline?: boolean;
721
+ x: number;
722
+ y: number;
723
+ };
724
+ type DOMElement = InkNode & {
725
+ attributes: Record<string, DOMNodeAttribute>;
726
+ /**
727
+ * Cached render result (a Region). When set, the entire subtree is
728
+ * skipped during rendering and the cached region is composited directly.
729
+ * Set by setCachedRender(), cleared on unmount by cleanupNodeTree().
730
+ */
731
+ cachedRender?: Region;
732
+ childNodes: DOMNode[];
733
+ internal_accessibility?: {
734
+ role?: "button" | "checkbox" | "combobox" | "list" | "listbox" | "listitem" | "menu" | "menuitem" | "option" | "progressbar" | "radio" | "radiogroup" | "tab" | "tablist" | "table" | "textbox" | "timer" | "toolbar";
735
+ state?: {
736
+ busy?: boolean;
737
+ checked?: boolean;
738
+ disabled?: boolean;
739
+ expanded?: boolean;
740
+ multiline?: boolean;
741
+ multiselectable?: boolean;
742
+ readonly?: boolean;
743
+ required?: boolean;
744
+ selected?: boolean;
745
+ };
746
+ };
747
+ internal_cursor?: CursorMarker;
748
+ internal_hidden?: boolean;
749
+ /**
750
+ * Auto-incrementing unique identifier for this node.
751
+ */
752
+ internal_id: number;
753
+ /**
754
+ * Whether this element's scrollback buffer is dirty (needs recalculation).
755
+ */
756
+ internal_isScrollbackDirty?: boolean;
757
+ /**
758
+ * Last measured size for ResizeObserver tracking.
759
+ */
760
+ internal_lastMeasuredSize?: {
761
+ height: number;
762
+ width: number;
763
+ };
764
+ internal_layoutListeners?: Set<LayoutListener>;
765
+ /**
766
+ * Maximum scrollTop ever reached, used with stableScrollback.
767
+ */
768
+ internal_maxScrollTop?: number;
769
+ /**
770
+ * Callback invoked after prepareYogaTree() caches the render output for
771
+ * an ink-static-render node. StaticRender uses this to set `isRendered`
772
+ * state, which prevents React from re-reconciling children once cached.
773
+ */
774
+ internal_onRendered?: () => void;
775
+ /**
776
+ * Whether this element is opaque (prevents rendering of covered content beneath it).
777
+ */
778
+ internal_opaque?: boolean;
779
+ /**
780
+ * Whether the scrollbar should be rendered for this scrollable element.
781
+ * Defaults to true for elements with overflow: 'scroll'.
782
+ */
783
+ internal_scrollbar?: boolean;
784
+ /**
785
+ * Scroll state computed by calculateScroll() for elements with overflow: 'scroll'.
786
+ */
787
+ internal_scrollState?: ScrollState;
788
+ /**
789
+ * Whether this element is sticky (pinned during scroll).
790
+ * - `true` or `'top'`: pinned to the top of the scroll container
791
+ * - `'bottom'`: pinned to the bottom of the scroll container
792
+ */
793
+ internal_sticky?: boolean | "top" | "bottom";
794
+ /**
795
+ * Whether this element is the alternate (stuck) version of a sticky header.
796
+ * The stuck version is rendered when the header is pinned.
797
+ */
798
+ internal_stickyAlternate?: boolean;
799
+ /**
800
+ * Whether this element should receive the terminal cursor focus.
801
+ */
802
+ internal_terminalCursorFocus?: boolean;
803
+ /**
804
+ * Terminal cursor position offset within this element.
805
+ */
806
+ internal_terminalCursorPosition?: number;
807
+ /**
808
+ * Cached text squash result for this node's subtree.
809
+ * Invalidated by markNodeAsDirty() when children change.
810
+ */
811
+ internal_textCache?: {
812
+ map: Map<DOMNode, {
813
+ end: number;
814
+ start: number;
815
+ }>;
816
+ text: string;
817
+ };
818
+ internal_transform?: OutputTransformer;
819
+ isStaticDirty?: boolean;
820
+ /**
821
+ * Whether the Yoga subtree has been detached (children removed from Yoga layout)
822
+ * because a cachedRender was set. When cachedRender is invalidated,
823
+ * prepareYogaTree() re-attaches the children before the next layout pass.
824
+ */
825
+ isYogaTreeDetached?: boolean;
826
+ nodeName: ElementNames;
827
+ onComputeLayout?: () => void;
828
+ onImmediateRender?: () => void;
829
+ onRender?: () => void;
830
+ /**
831
+ * Set of ResizeObservers attached to this element.
832
+ */
833
+ resizeObservers?: Set<ResizeObserver>;
834
+ staticNode?: DOMElement;
835
+ };
836
+ type TextNode = InkNode & {
837
+ nodeName: TextName;
838
+ nodeValue: string;
839
+ };
840
+ type DOMNode<T = {
841
+ nodeName: NodeNames;
842
+ }> = T extends {
843
+ nodeName: infer U;
844
+ } ? U extends "#text" ? TextNode : DOMElement : never;
845
+ type DOMNodeAttribute = boolean | string | number;
846
+ /**
847
+ * Get the path from the root to this node (inclusive).
848
+ * Returns an array starting with the root and ending with the node.
849
+ *
850
+ * Ported from jacob314/ink fork (Google LLC, Apache-2.0).
851
+ */
852
+ declare const getPathToRoot: (node: DOMNode) => DOMNode[];
853
+ /**
854
+ * Check if a node is selectable by walking up the tree checking `userSelect` style.
855
+ * Returns true by default unless an ancestor has `userSelect: 'none'`.
856
+ *
857
+ * Ported from jacob314/ink fork (Google LLC, Apache-2.0).
858
+ */
859
+ declare const isNodeSelectable: (node: DOMElement) => boolean;
860
+ declare const kittyFlags: {
861
+ readonly disambiguateEscapeCodes: 1;
862
+ readonly reportAllKeysAsEscapeCodes: 8;
863
+ readonly reportAlternateKeys: 4;
864
+ readonly reportAssociatedText: 16;
865
+ readonly reportEventTypes: 2;
866
+ };
867
+ type KittyFlagName = keyof typeof kittyFlags;
868
+ declare const kittyModifiers: {
869
+ readonly alt: 2;
870
+ readonly capsLock: 64;
871
+ readonly ctrl: 4;
872
+ readonly hyper: 16;
873
+ readonly meta: 32;
874
+ readonly numLock: 128;
875
+ readonly shift: 1;
876
+ readonly super: 8;
877
+ };
878
+ type KittyKeyboardOptions = {
879
+ flags?: KittyFlagName[];
880
+ mode?: "auto" | "enabled" | "disabled";
881
+ };
882
+ type CursorPosition = {
883
+ x: number;
884
+ y: number;
885
+ };
886
+ /**
887
+ * Performance metrics for a render operation.
888
+ */
889
+ type RenderMetrics = {
890
+ /**
891
+ * Time spent rendering in milliseconds.
892
+ */
893
+ renderTime: number;
894
+ };
895
+ type Options = {
896
+ /**
897
+ * Render the app in the terminal's alternate screen buffer. When enabled, the app renders on a separate screen, and the original terminal content is restored when the app exits. This is the same mechanism used by programs like vim, htop, and less.
898
+ *
899
+ * Note: The terminal's scrollback buffer is not available while in the alternate screen. This is standard terminal behavior; programs like vim use the alternate screen specifically to avoid polluting the user's scrollback history.
900
+ *
901
+ * Note: Ink intentionally treats alternate-screen teardown output as disposable. It does not preserve or replay teardown-time frames, hook writes, or `console.*` output after restoring the primary screen.
902
+ *
903
+ Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
904
+
905
+ Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
906
+
907
+ @default false
908
+
909
+ @see {@link RenderOptions.alternateScreen}
910
+ */
911
+ alternateScreen?: boolean;
912
+ /**
913
+ * Enable React Concurrent Rendering mode.
914
+ *
915
+ * When enabled:
916
+ * - Suspense boundaries work correctly with async data
917
+ * - `useTransition` and `useDeferredValue` are fully functional
918
+ - Updates can be interrupted for higher priority work
919
+
920
+ Note: Concurrent mode changes the timing of renders. Some tests may need to use `act()` to properly await updates. Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change the rendering mode or create a fresh instance.
921
+
922
+ @default false
923
+ @experimental
924
+ */
925
+ concurrent?: boolean;
926
+ debug: boolean;
927
+ exitOnCtrlC: boolean;
928
+ incrementalRendering?: boolean;
929
+ /**
930
+ * Override automatic interactive mode detection.
931
+ *
932
+ * By default, Ink detects whether the environment is interactive based on CI detection (via [`is-in-ci`](https://github.com/sindresorhus/is-in-ci)) and `stdout.isTTY`. Most users should not need to set this.
933
+ *
934
+ * When non-interactive, Ink disables ANSI erase sequences, cursor manipulation, synchronized output, resize handling, and kitty keyboard auto-detection, writing only the final frame at unmount.
935
+ *
936
+ Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
937
+
938
+ Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
939
+
940
+ @default true (false if in CI or `stdout.isTTY` is falsy)
941
+
942
+ @see {@link RenderOptions.interactive}
943
+ */
944
+ interactive?: boolean;
945
+ isScreenReaderEnabled?: boolean;
946
+ kittyKeyboard?: KittyKeyboardOptions;
947
+ maxFps?: number;
948
+ onRender?: (metrics: RenderMetrics) => void;
949
+ patchConsole: boolean;
950
+ standardReactLayoutTiming?: boolean;
951
+ stderr: NodeJS.WriteStream;
952
+ stdin: NodeJS.ReadStream;
953
+ stdout: NodeJS.WriteStream;
954
+ /**
955
+ * Whether to track text selection state during rendering.
956
+ *
957
+ * @default false
958
+ */
959
+ trackSelection?: boolean;
960
+ /**
961
+ * Use the native Rust cell-diff renderer instead of ANSI string-based log-update.
962
+ * Produces a Uint32Array buffer that the Rust renderer diffs cell-by-cell,
963
+ * generating minimal ANSI escape sequences. Significantly reduces GC pressure
964
+ * and improves rendering performance for complex UIs.
965
+ *
966
+ * Falls back to the string-based path if native bindings are not available.
967
+ * @default false
968
+ */
969
+ useNativeRenderer?: boolean;
970
+ waitUntilExit?: () => Promise<unknown>;
971
+ };
972
+ declare class Ink {
973
+ /**
974
+ * Whether this instance is using concurrent rendering mode.
975
+ */
976
+ readonly isConcurrent: boolean;
977
+ private readonly options;
978
+ private readonly log;
979
+ private manualCursorPosition;
980
+ private renderedCursorPosition;
981
+ private renderedCursorRequested;
982
+ private readonly throttledLog;
983
+ private readonly isScreenReaderEnabled;
984
+ private readonly interactive;
985
+ private readonly renderThrottleMs;
986
+ private alternateScreen;
987
+ private isUnmounted;
988
+ private isUnmounting;
989
+ private lastOutput;
990
+ private lastOutputToRender;
991
+ private lastOutputHeight;
992
+ private lastTerminalWidth;
993
+ private readonly nativeLog;
994
+ private readonly useNativeRenderer;
995
+ private readonly container;
996
+ readonly rootNode: DOMElement;
997
+ private fullStaticOutput;
998
+ private readonly exitPromise!;
999
+ private exitResult;
1000
+ private beforeExitHandler?;
1001
+ private restoreConsole?;
1002
+ private unsubscribeResize?;
1003
+ private readonly throttledOnRender?;
1004
+ private hasPendingThrottledRender;
1005
+ private kittyProtocolEnabled;
1006
+ private cancelKittyDetection?;
1007
+ private nextRenderCommit?;
1008
+ private deferredInitDone;
1009
+ constructor(options: Options);
1010
+ /**
1011
+ * Perform deferred initialization on the first render frame.
1012
+ * Kitty keyboard auto-detection is deferred here because the CSI ? u
1013
+ * query sets up a synchronous stdin listener with a 200ms timeout.
1014
+ * "enabled" mode runs immediately in the constructor (it's just a write).
1015
+ */
1016
+ private runDeferredInit;
1017
+ resized: () => void;
1018
+ resolveExitPromise: (result?: unknown) => void;
1019
+ rejectExitPromise: (reason?: Error) => void;
1020
+ unsubscribeExit: () => void;
1021
+ handleAppExit: (errorOrResult?: unknown) => void;
1022
+ getActiveCursorPosition: () => CursorPosition | undefined;
1023
+ setCursorPosition: (position: CursorPosition | undefined) => void;
1024
+ restoreLastOutput: () => void;
1025
+ calculateLayout: () => void;
1026
+ private calculateScrollAndTriggerObservers;
1027
+ /**
1028
+ * Force a full layout recalculation by marking all text nodes dirty.
1029
+ * Useful when the string width function changes or terminal font changes.
1030
+ */
1031
+ recalculateLayout(): void;
1032
+ /**
1033
+ * Walks the DOM tree before Yoga layout to handle StaticRender nodes.
1034
+ *
1035
+ * - Re-attach Yoga children if a cached render was invalidated.
1036
+ * - Pre-render ink-static-render nodes that don't have a cached render yet.
1037
+ */
1038
+ private prepareYogaTree;
1039
+ private markAllTextNodesDirty;
1040
+ onRender: () => void;
1041
+ private accessibilityContextValue;
1042
+ render(node: ReactNode): void;
1043
+ writeToStdout: (data: string) => void;
1044
+ writeToStderr: (data: string) => void;
1045
+ unmount: (error?: Error | number | null) => void;
1046
+ waitUntilExit(): Promise<unknown>;
1047
+ waitUntilRenderFlush(): Promise<void>;
1048
+ clear(): void;
1049
+ patchConsole(): void;
1050
+ private setAlternateScreen;
1051
+ private resolveInteractiveOption;
1052
+ private resolveAlternateScreenOption;
1053
+ private shouldSync;
1054
+ private writeBestEffort;
1055
+ private awaitExit;
1056
+ private hasPendingConcurrentWork;
1057
+ private awaitNextRender;
1058
+ private renderInteractiveFrame;
1059
+ /**
1060
+ * Handle kitty keyboard "enabled" mode immediately (just a stdout.write).
1061
+ * Called from the constructor.
1062
+ */
1063
+ private initImmediateKittyKeyboard;
1064
+ /**
1065
+ * Handle kitty keyboard "auto" mode detection. Deferred to first render
1066
+ * because the CSI ? u query sets up a stdin listener with a 200ms timeout.
1067
+ */
1068
+ private initDeferredKittyKeyboard;
1069
+ private confirmKittySupport;
1070
+ private enableKittyProtocol;
1071
+ }
1072
+ type RenderOptions = {
1073
+ /**
1074
+ * Render the app in the terminal's alternate screen buffer. When enabled, the app renders on a separate screen, and the original terminal content is restored when the app exits. This is the same mechanism used by programs like vim, htop, and less.
1075
+ *
1076
+ * Note: The terminal's scrollback buffer is not available while in the alternate screen. This is standard terminal behavior; programs like vim use the alternate screen specifically to avoid polluting the user's scrollback history.
1077
+ *
1078
+ * Note: Ink intentionally treats alternate-screen teardown output as disposable. It does not preserve or replay teardown-time frames, hook writes, or `console.*` output after restoring the primary screen.
1079
+ *
1080
+ * Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
1081
+ *
1082
+ *Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
1083
+ * @default false
1084
+ */
1085
+ alternateScreen?: boolean;
1086
+ /**
1087
+ * Enable React Concurrent Rendering mode.
1088
+ *
1089
+ * When enabled:
1090
+ * - Suspense boundaries work correctly with async data
1091
+ * - `useTransition` and `useDeferredValue` are fully functional
1092
+ * - Updates can be interrupted for higher priority work
1093
+ *
1094
+ *Note: Concurrent mode changes the timing of renders. Some tests may need to use `act()` to properly await updates. Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change the rendering mode or create a fresh instance.
1095
+ * @default false
1096
+ */
1097
+ concurrent?: boolean;
1098
+ /**
1099
+ * If true, each update will be rendered as separate output, without replacing the previous one.
1100
+ * @default false
1101
+ */
1102
+ debug?: boolean;
1103
+ /**
1104
+ * Configure whether Ink should listen for Ctrl+C keyboard input and exit the app. This is needed in case `process.stdin` is in raw mode, because then Ctrl+C is ignored by default and the process is expected to handle it manually.
1105
+ * @default true
1106
+ */
1107
+ exitOnCtrlC?: boolean;
1108
+ /**
1109
+ * Enable incremental rendering mode which only updates changed lines instead of redrawing the entire output.
1110
+ *This can reduce flickering and improve performance for frequently updating UIs.
1111
+ * @default false
1112
+ */
1113
+ incrementalRendering?: boolean;
1114
+ /**
1115
+ * Override automatic interactive mode detection.
1116
+ *
1117
+ * By default, Ink detects whether the environment is interactive based on CI detection (via [`is-in-ci`](https://github.com/sindresorhus/is-in-ci)) and `stdout.isTTY`. Most users should not need to set this.
1118
+ *
1119
+ * When non-interactive, Ink disables ANSI erase sequences, cursor manipulation, synchronized output, resize handling, and kitty keyboard auto-detection, writing only the final frame at unmount.
1120
+ *
1121
+ * Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
1122
+ *
1123
+ *Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
1124
+ * @default true (false if in CI or `stdout.isTTY` is falsy)
1125
+ */
1126
+ interactive?: boolean;
1127
+ /**
1128
+ * Enable screen reader support. See https://github.com/vadimdemedes/ink/blob/master/readme.md#screen-reader-support
1129
+ * @default process.env['INK_SCREEN_READER'] === 'true'
1130
+ */
1131
+ isScreenReaderEnabled?: boolean;
1132
+ /**
1133
+ * Configure kitty keyboard protocol support for enhanced keyboard input.
1134
+ * Enables additional modifiers (super, hyper, capsLock, numLock) and
1135
+ *disambiguated key events in terminals that support the protocol.
1136
+ * @see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
1137
+ */
1138
+ kittyKeyboard?: KittyKeyboardOptions;
1139
+ /**
1140
+ * Maximum frames per second for render updates.
1141
+ * This controls how frequently the UI can update to prevent excessive re-rendering.
1142
+ *Higher values allow more frequent updates but may impact performance.
1143
+ * @default 30
1144
+ */
1145
+ maxFps?: number;
1146
+ /**
1147
+ * Runs the given callback after each render and re-render with render metrics.
1148
+ *
1149
+ * Note: this callback runs after Ink commits a frame, but it does not wait for `stdout`/`stderr` stream callbacks.
1150
+ * To run code after output is flushed, use `waitUntilRenderFlush()`.
1151
+ */
1152
+ onRender?: (metrics: RenderMetrics) => void;
1153
+ /**
1154
+ * Patch console methods to ensure console output doesn't mix with Ink's output.
1155
+ *
1156
+ *Note: Once unmount starts, Ink restores the native console before React cleanup runs. Teardown-time `console.*` output then follows the normal console behavior instead of being rerouted through Ink.
1157
+ * @default true
1158
+ */
1159
+ patchConsole?: boolean;
1160
+ /**
1161
+ * If true, Ink defers frame output until after React's commit phase completes,
1162
+ * ensuring `useLayoutEffect` hooks run before the frame is written to the terminal.
1163
+ *
1164
+ * This eliminates the one-frame flicker when components measure layout
1165
+ * (e.g., scroll position, element size) in `useLayoutEffect` and adjust state.
1166
+ *
1167
+ * **Warning:** Incompatible with the `&lt;Static>` component, which relies on
1168
+ * immediate render timing to append output.
1169
+ * @default false
1170
+ */
1171
+ standardReactLayoutTiming?: boolean;
1172
+ /**
1173
+ * Error stream.
1174
+ * @default process.stderr
1175
+ */
1176
+ stderr?: NodeJS.WriteStream;
1177
+ /**
1178
+ * Input stream where app will listen for input.
1179
+ * @default process.stdin
1180
+ */
1181
+ stdin?: NodeJS.ReadStream;
1182
+ /**
1183
+ * Output stream where the app will be rendered.
1184
+ * @default process.stdout
1185
+ */
1186
+ stdout?: NodeJS.WriteStream;
1187
+ /**
1188
+ * Use the native Rust cell-diff renderer for terminal output.
1189
+ * Produces a Uint32Array buffer that the Rust renderer diffs cell-by-cell,
1190
+ * generating minimal ANSI escape sequences. Reduces GC pressure and
1191
+ * improves rendering performance for complex UIs.
1192
+ *
1193
+ * Falls back to string-based rendering if native bindings are not available.
1194
+ * @default false
1195
+ */
1196
+ useNativeRenderer?: boolean;
1197
+ };
1198
+ type Instance = {
1199
+ /**
1200
+ * Unmount the current app and remove the internal Ink instance for this stdout.
1201
+ *
1202
+ * This is mostly useful for advanced cases where you need `render()` to create a fresh instance for the same stream without leaving terminal state such as the alternate screen behind.
1203
+ */
1204
+ cleanup: () => void;
1205
+ /**
1206
+ * Clear output.
1207
+ */
1208
+ clear: () => void;
1209
+ /**
1210
+ * Replace the previous root node with a new one or update props of the current root node.
1211
+ */
1212
+ rerender: Ink["render"];
1213
+ /**
1214
+ * The root DOM element of the rendered tree.
1215
+ * Useful for programmatic DOM inspection and advanced measurement.
1216
+ */
1217
+ rootNode: DOMElement;
1218
+ /**
1219
+ * Manually unmount the whole Ink app.
1220
+ */
1221
+ unmount: Ink["unmount"];
1222
+ /**
1223
+ * Returns a promise that settles when the app is unmounted.
1224
+ *
1225
+ * It resolves with the value passed to `exit(value)` and rejects with the error passed to `exit(error)`.
1226
+ *When `unmount()` is called manually, it settles after unmount-related stdout writes complete.
1227
+ * @example
1228
+ * ```jsx
1229
+ * const {unmount, waitUntilExit} = render(<MyApp />);
1230
+ *
1231
+ * setTimeout(unmount, 1000);
1232
+ *
1233
+ * await waitUntilExit(); // resolves after `unmount()` is called
1234
+ * ```
1235
+ */
1236
+ waitUntilExit: Ink["waitUntilExit"];
1237
+ /**
1238
+ * Returns a promise that settles after pending render output is flushed to stdout.
1239
+ *
1240
+ *This can be used after `rerender()` when you need to run code only after the frame is written.
1241
+ * @example
1242
+ * ```jsx
1243
+ * const {rerender, waitUntilRenderFlush} = render(<MyApp step="loading" />);
1244
+ *
1245
+ * rerender(<MyApp step="ready" />);
1246
+ * await waitUntilRenderFlush(); // output for "ready" is flushed
1247
+ *
1248
+ * runNextCommand();
1249
+ * ```
1250
+ */
1251
+ waitUntilRenderFlush: Ink["waitUntilRenderFlush"];
1252
+ };
1253
+ /**
1254
+ * Mount a component and render the output.
1255
+ */
1256
+ declare const render: (node: ReactNode, options?: NodeJS.WriteStream | RenderOptions) => Instance;
1257
+ export { CursorPosition as C, DOMElement as D, Instance as I, KittyFlagName as K, RenderOptions as R, Styles as S, DOMNode as a, StyledLine as b, KittyKeyboardOptions as c, ResizeObserver as d, ResizeObserverCallback as e, ResizeObserverEntry as f, ScrollState as g, StickyHeader as h, calculateScroll as i, getPathToRoot as j, getScrollHeight as k, getScrollLeft as l, getScrollTop as m, getScrollWidth as n, isNodeSelectable as o, kittyFlags as p, kittyModifiers as q, render as r };