@visulima/tui 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/components/box.d.ts +25 -25
  3. package/dist/components/canvas.d.ts +26 -31
  4. package/dist/components/cursor.d.ts +39 -44
  5. package/dist/components/error-overview.d.ts +1 -3
  6. package/dist/components/error-overview.js +1 -1
  7. package/dist/components/newline.d.ts +6 -8
  8. package/dist/components/spacer.d.ts +4 -4
  9. package/dist/components/static-render.d.ts +9 -40
  10. package/dist/components/static.d.ts +13 -13
  11. package/dist/components/text.d.ts +34 -47
  12. package/dist/components/transform.d.ts +7 -11
  13. package/dist/core/index.d.ts +11 -11
  14. package/dist/core/index.js +1 -1
  15. package/dist/ink/canvas/index.d.ts +10 -10
  16. package/dist/ink/hooks/use-animation.d.ts +22 -22
  17. package/dist/ink/hooks/use-app.d.ts +3 -3
  18. package/dist/ink/hooks/use-box-metrics.d.ts +16 -16
  19. package/dist/ink/hooks/use-clipboard.d.ts +16 -16
  20. package/dist/ink/hooks/use-color-blindness.d.ts +16 -16
  21. package/dist/ink/hooks/use-console-capture.d.ts +19 -19
  22. package/dist/ink/hooks/use-cursor.d.ts +6 -6
  23. package/dist/ink/hooks/use-focus-manager.d.ts +25 -25
  24. package/dist/ink/hooks/use-focus.d.ts +14 -18
  25. package/dist/ink/hooks/use-form.d.ts +32 -32
  26. package/dist/ink/hooks/use-hotkey.d.ts +17 -17
  27. package/dist/ink/hooks/use-input.d.ts +92 -92
  28. package/dist/ink/hooks/use-input.js +2 -2
  29. package/dist/ink/hooks/use-interval.d.ts +14 -14
  30. package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +3 -3
  31. package/dist/ink/hooks/use-key-bindings.d.ts +32 -32
  32. package/dist/ink/hooks/use-key-chord.d.ts +15 -15
  33. package/dist/ink/hooks/use-paste.d.ts +38 -38
  34. package/dist/ink/hooks/use-paste.js +1 -1
  35. package/dist/ink/hooks/use-persistent-state.d.ts +46 -46
  36. package/dist/ink/hooks/use-persistent-state.js +2 -2
  37. package/dist/ink/hooks/use-scroll-acceleration.d.ts +24 -24
  38. package/dist/ink/hooks/use-scroll-input.d.ts +15 -15
  39. package/dist/ink/hooks/use-stderr.d.ts +6 -6
  40. package/dist/ink/hooks/use-stderr.js +1 -1
  41. package/dist/ink/hooks/use-stdin.d.ts +10 -10
  42. package/dist/ink/hooks/use-stdin.js +1 -1
  43. package/dist/ink/hooks/use-stdout.d.ts +6 -6
  44. package/dist/ink/hooks/use-stdout.js +1 -1
  45. package/dist/ink/hooks/use-stopwatch.d.ts +12 -12
  46. package/dist/ink/hooks/use-terminal-palette.d.ts +11 -11
  47. package/dist/ink/hooks/use-text-buffer.d.ts +2 -2
  48. package/dist/ink/hooks/use-text-selection.d.ts +18 -18
  49. package/dist/ink/hooks/use-timeout.d.ts +11 -11
  50. package/dist/ink/hooks/use-timer.d.ts +19 -19
  51. package/dist/ink/hooks/use-window-size.d.ts +8 -8
  52. package/dist/ink/hooks/use-window-size.js +1 -1
  53. package/dist/ink/index.d.ts +109 -122
  54. package/dist/ink/index.js +1 -1
  55. package/dist/ink/mouse/use-element-position.d.ts +6 -6
  56. package/dist/ink/mouse/use-mouse-action.d.ts +1 -1
  57. package/dist/ink/mouse/use-mouse-position.d.ts +1 -1
  58. package/dist/ink/mouse/use-mouse.d.ts +1 -1
  59. package/dist/ink/mouse/use-on-mouse-click.d.ts +3 -3
  60. package/dist/ink/mouse/use-on-mouse-hover.d.ts +2 -2
  61. package/dist/ink/mouse/use-on-mouse-state.d.ts +2 -2
  62. package/dist/ink/public/cursor.d.ts +21 -21
  63. package/dist/ink/public/dom.d.ts +2 -2
  64. package/dist/ink/public/highlighter.d.ts +16 -26
  65. package/dist/ink/public/input.d.ts +6 -6
  66. package/dist/ink/public/styles.d.ts +1 -1
  67. package/dist/ink/public/utils.d.ts +2 -2
  68. package/dist/packem_shared/{DevTools-D9tfChBc.js → DevTools-BxD3PYAN.js} +1 -1
  69. package/dist/packem_shared/MouseProvider-DOcWCRVq.js +1 -0
  70. package/dist/packem_shared/{Renderer-DsskdkUd.js → Renderer-BeS49FNq.js} +1 -1
  71. package/dist/packem_shared/{TuiApp-DjIgv5Sk.js → TuiApp-CCVaiKbf.js} +1 -1
  72. package/dist/packem_shared/app-context.d-DMLw5Nxy.d.ts +56 -0
  73. package/dist/packem_shared/{buffer.d-j_dP5JyC.d.ts → buffer.d-CttIC480.d.ts} +26 -26
  74. package/dist/packem_shared/clipboard.d-nDPQkZ2H.d.ts +23 -0
  75. package/dist/packem_shared/color-matrix.d-sTqnJ23h.d.ts +50 -0
  76. package/dist/packem_shared/{createInlineLoop-BT40Wpmx.js → createInlineLoop-DnEvE2eM.js} +1 -1
  77. package/dist/packem_shared/{dom.d-g-nsYquD.d.ts → dom.d-CLGlidfI.d.ts} +138 -151
  78. package/dist/packem_shared/{input.d-D-Yxqha8.d.ts → input.d-Bb8pWHvp.d.ts} +24 -24
  79. package/dist/packem_shared/load-native-root-binding-CxJnHcac.js +1 -0
  80. package/dist/packem_shared/{mouse-context.d-BfL9xGk_.d.ts → mouse-context.d-W-nszUps.d.ts} +8 -8
  81. package/dist/packem_shared/reconciler-DkwOtC5B.js +1 -0
  82. package/dist/packem_shared/{render-D7aV_hO1.js → render-CuCo-R-l.js} +17 -17
  83. package/dist/packem_shared/{render-DMcWfI6-.js → render-DtQd8qQq.js} +1 -1
  84. package/dist/packem_shared/render.d-DjQhFsiN.d.ts +435 -0
  85. package/dist/packem_shared/{renderToString-DqLFFPvO.js → renderToString-B1LgWcJe.js} +1 -1
  86. package/dist/packem_shared/{selection.d-KWphH--_.d.ts → selection.d-BSAWa4ey.d.ts} +16 -16
  87. package/dist/packem_shared/stderr-context-CR2LLec6.js +1 -0
  88. package/dist/packem_shared/stdin-context-BjMA9Sbi.js +1 -0
  89. package/dist/packem_shared/stdout-context-DAAlQct2.js +1 -0
  90. package/dist/packem_shared/styles.d-CKGQFfm4.d.ts +485 -0
  91. package/dist/packem_shared/{terminal-palette.d-D2SQjfn-.d.ts → terminal-palette.d-JbWHISW-.d.ts} +7 -7
  92. package/dist/packem_shared/utils-CVgM8kTn.js +1 -0
  93. package/dist/react/index.d.ts +160 -178
  94. package/dist/react/index.js +1 -1
  95. package/dist/testing/index.d.ts +151 -151
  96. package/dist/testing/index.js +1 -1
  97. package/index.js +52 -52
  98. package/package.json +9 -9
  99. package/dist/packem_shared/MouseProvider-DUqQ3Eaa.js +0 -1
  100. package/dist/packem_shared/app-context.d-CG88lgkg.d.ts +0 -56
  101. package/dist/packem_shared/clipboard.d-D6lZTQ21.d.ts +0 -23
  102. package/dist/packem_shared/color-matrix.d-DSXLsB64.d.ts +0 -50
  103. package/dist/packem_shared/load-native-root-binding-DDikxNox.js +0 -1
  104. package/dist/packem_shared/reconciler-DhUGYWCr.js +0 -1
  105. package/dist/packem_shared/render.d-BvfwvSCx.d.ts +0 -435
  106. package/dist/packem_shared/stderr-context-Bvnik0hL.js +0 -1
  107. package/dist/packem_shared/stdin-context-88AhuztD.js +0 -1
  108. package/dist/packem_shared/stdout-context-BnblEPez.js +0 -1
  109. package/dist/packem_shared/styles.d-D7iZuNC-.d.ts +0 -492
  110. package/dist/packem_shared/utils-C8l_3Dzw.js +0 -1
@@ -0,0 +1,435 @@
1
+ import { ReactNode } from 'react';
2
+ import { D as DOMElement } from "./dom.d-CLGlidfI.js";
3
+ import { T as TerminalSuspension } from "./app-context.d-DMLw5Nxy.js";
4
+ import 'node:stream';
5
+ import { CursorPosition } from "../ink/public/cursor.js";
6
+ declare const kittyFlags: {
7
+ readonly disambiguateEscapeCodes: 1;
8
+ readonly reportAllKeysAsEscapeCodes: 8;
9
+ readonly reportAlternateKeys: 4;
10
+ readonly reportAssociatedText: 16;
11
+ readonly reportEventTypes: 2;
12
+ };
13
+ type KittyFlagName = keyof typeof kittyFlags;
14
+ declare const kittyModifiers: {
15
+ readonly alt: 2;
16
+ readonly capsLock: 64;
17
+ readonly ctrl: 4;
18
+ readonly hyper: 16;
19
+ readonly meta: 32;
20
+ readonly numLock: 128;
21
+ readonly shift: 1;
22
+ readonly super: 8;
23
+ };
24
+ type KittyKeyboardOptions = {
25
+ flags?: KittyFlagName[];
26
+ mode?: "auto" | "enabled" | "disabled";
27
+ };
28
+ /**
29
+ * Performance metrics for a render operation.
30
+ */
31
+ type RenderMetrics = {
32
+ /**
33
+ * Time spent rendering in milliseconds.
34
+ */
35
+ renderTime: number;
36
+ };
37
+ type Options = {
38
+ /**
39
+ * 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.
40
+ *
41
+ * 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.
42
+ *
43
+ * 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.
44
+ *
45
+ Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
46
+
47
+ 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.
48
+
49
+ @default false
50
+
51
+ @see {@link RenderOptions.alternateScreen}
52
+ */
53
+ alternateScreen?: boolean;
54
+ /**
55
+ * Enable React Concurrent Rendering mode.
56
+ *
57
+ * When enabled:
58
+ * - Suspense boundaries work correctly with async data
59
+ * - `useTransition` and `useDeferredValue` are fully functional
60
+ - Updates can be interrupted for higher priority work
61
+
62
+ 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.
63
+
64
+ @default false
65
+ @experimental
66
+ */
67
+ concurrent?: boolean;
68
+ debug: boolean;
69
+ exitOnCtrlC: boolean;
70
+ incrementalRendering?: boolean;
71
+ /**
72
+ * Override automatic interactive mode detection.
73
+ *
74
+ * 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.
75
+ *
76
+ * 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.
77
+ *
78
+ Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
79
+
80
+ 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.
81
+
82
+ @default true (false if in CI or `stdout.isTTY` is falsy)
83
+
84
+ @see {@link RenderOptions.interactive}
85
+ */
86
+ interactive?: boolean;
87
+ isScreenReaderEnabled?: boolean;
88
+ kittyKeyboard?: KittyKeyboardOptions;
89
+ maxFps?: number;
90
+ onRender?: (metrics: RenderMetrics) => void;
91
+ patchConsole: boolean;
92
+ standardReactLayoutTiming?: boolean;
93
+ stderr: NodeJS.WriteStream;
94
+ stdin: NodeJS.ReadStream;
95
+ stdout: NodeJS.WriteStream;
96
+ /**
97
+ * Whether to track text selection state during rendering.
98
+ *
99
+ * @default false
100
+ */
101
+ trackSelection?: boolean;
102
+ /**
103
+ * Use the native Rust cell-diff renderer instead of ANSI string-based log-update.
104
+ * Produces a Uint32Array buffer that the Rust renderer diffs cell-by-cell,
105
+ * generating minimal ANSI escape sequences. Significantly reduces GC pressure
106
+ * and improves rendering performance for complex UIs.
107
+ *
108
+ * Falls back to the string-based path if native bindings are not available.
109
+ * @default false
110
+ */
111
+ useNativeRenderer?: boolean;
112
+ waitUntilExit?: () => Promise<unknown>;
113
+ };
114
+ declare class Ink {
115
+ /**
116
+ * Whether this instance is using concurrent rendering mode.
117
+ */
118
+ readonly isConcurrent: boolean;
119
+ private readonly options;
120
+ private readonly log;
121
+ private manualCursorPosition;
122
+ private renderedCursorPosition;
123
+ private renderedCursorRequested;
124
+ private readonly throttledLog;
125
+ private readonly isScreenReaderEnabled;
126
+ private readonly interactive;
127
+ private readonly renderThrottleMs;
128
+ private alternateScreen;
129
+ private isUnmounted;
130
+ private isUnmounting;
131
+ private lastOutput;
132
+ private lastOutputToRender;
133
+ private lastOutputHeight;
134
+ private lastTerminalWidth;
135
+ private readonly nativeLog;
136
+ private readonly useNativeRenderer;
137
+ private readonly container;
138
+ readonly rootNode: DOMElement;
139
+ private fullStaticOutput;
140
+ private backbufferNode;
141
+ private backbufferMultiWarned;
142
+ private readonly exitPromise;
143
+ private exitResult;
144
+ private beforeExitHandler?;
145
+ private restoreConsole?;
146
+ private unsubscribeResize?;
147
+ private readonly throttledOnRender?;
148
+ private hasPendingThrottledRender;
149
+ private kittyProtocolEnabled;
150
+ private kittyFlags?;
151
+ private isSuspended;
152
+ private pauseInput?;
153
+ private resumeInput?;
154
+ private cancelKittyDetection?;
155
+ private nextRenderCommit?;
156
+ private deferredInitDone;
157
+ constructor(options: Options);
158
+ /**
159
+ * Perform deferred initialization on the first render frame.
160
+ * Kitty keyboard auto-detection is deferred here because the CSI ? u
161
+ * query sets up a synchronous stdin listener with a 200ms timeout.
162
+ * "enabled" mode runs immediately in the constructor (it's just a write).
163
+ */
164
+ private runDeferredInit;
165
+ resized: () => void;
166
+ resolveExitPromise: (result?: unknown) => void;
167
+ rejectExitPromise: (reason?: Error) => void;
168
+ unsubscribeExit: () => void;
169
+ handleAppExit: (errorOrResult?: unknown) => void;
170
+ getActiveCursorPosition: () => CursorPosition | undefined;
171
+ setCursorPosition: (position: CursorPosition | undefined) => void;
172
+ restoreLastOutput: () => void;
173
+ calculateLayout: () => void;
174
+ private calculateScrollAndTriggerObservers;
175
+ /**
176
+ * Force a full layout recalculation by marking all text nodes dirty.
177
+ * Useful when the string width function changes or terminal font changes.
178
+ */
179
+ recalculateLayout(): void;
180
+ /**
181
+ * Walks the DOM tree before Yoga layout to handle StaticRender nodes.
182
+ *
183
+ * - Re-attach Yoga children if a cached render was invalidated.
184
+ * - Pre-render ink-static-render nodes that don't have a cached render yet.
185
+ */
186
+ private prepareYogaTree;
187
+ private markAllTextNodesDirty;
188
+ handleStaticChange: () => void;
189
+ /**
190
+ * Compute the slice of lines that newly scrolled off the top of the single
191
+ * `overflowToBackbuffer` region and have not yet been flushed into the
192
+ * terminal's real scrollback. Advances the monotonic
193
+ * `internal_maxPushedScrollTop` bookkeeping so each line is emitted exactly
194
+ * once and scrolling back up is a no-op. Returns a newline-terminated
195
+ * string to write above the live frame, or "" when there is nothing to do.
196
+ *
197
+ * No-op outside inline mode (alternate-screen / non-TTY / non-interactive /
198
+ * screen-reader / debug), since terminal scrollback only exists for an
199
+ * inline, in-place-updated live region. Debug mode is excluded because it
200
+ * re-dumps the full grid every frame and never writes this slice — running
201
+ * it there would advance the monotonic pointer past lines that were never
202
+ * emitted.
203
+ */
204
+ private computeBackbufferOutput;
205
+ onRender: () => void;
206
+ private accessibilityContextValue;
207
+ render(node: ReactNode): void;
208
+ writeToStdout: (data: string) => void;
209
+ writeToStderr: (data: string) => void;
210
+ unmount: (error?: Error | number | null) => void;
211
+ waitUntilExit(): Promise<unknown>;
212
+ waitUntilRenderFlush(): Promise<void>;
213
+ clear(): void;
214
+ patchConsole(): void;
215
+ private setAlternateScreen;
216
+ private resolveInteractiveOption;
217
+ private resolveAlternateScreenOption;
218
+ private shouldSync;
219
+ private writeBestEffort;
220
+ private awaitExit;
221
+ private hasPendingConcurrentWork;
222
+ private awaitNextRender;
223
+ private renderInteractiveFrame;
224
+ /**
225
+ * Handle kitty keyboard "enabled" mode immediately (just a stdout.write).
226
+ * Called from the constructor.
227
+ */
228
+ private initImmediateKittyKeyboard;
229
+ /**
230
+ * Handle kitty keyboard "auto" mode detection. Deferred to first render
231
+ * because the CSI ? u query sets up a stdin listener with a 200ms timeout.
232
+ */
233
+ private initDeferredKittyKeyboard;
234
+ private confirmKittySupport;
235
+ registerInputControl: (pauseInput: () => void, resumeInput: () => void) => void;
236
+ /**
237
+ * Hand terminal control to a child process, then restore Ink's rendering.
238
+ * With a callback, the terminal is released for its duration and resumed in a
239
+ * `finally`. Without one, returns a handle whose `resume()` (or `await using`)
240
+ * restores.
241
+ */
242
+ suspendTerminal: {
243
+ (callback: () => Promise<void> | void): Promise<undefined>;
244
+ (): Promise<TerminalSuspension>;
245
+ };
246
+ private beginSuspend;
247
+ private endSuspend;
248
+ private enableKittyProtocol;
249
+ }
250
+ type RenderOptions = {
251
+ /**
252
+ * 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.
253
+ *
254
+ * 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.
255
+ *
256
+ * 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.
257
+ *
258
+ * Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
259
+ *
260
+ *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.
261
+ * @default false
262
+ */
263
+ alternateScreen?: boolean;
264
+ /**
265
+ * Enable React Concurrent Rendering mode.
266
+ *
267
+ * When enabled:
268
+ * - Suspense boundaries work correctly with async data
269
+ * - `useTransition` and `useDeferredValue` are fully functional
270
+ * - Updates can be interrupted for higher priority work
271
+ *
272
+ *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.
273
+ * @default false
274
+ */
275
+ concurrent?: boolean;
276
+ /**
277
+ * If true, each update will be rendered as separate output, without replacing the previous one.
278
+ * @default false
279
+ */
280
+ debug?: boolean;
281
+ /**
282
+ * 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.
283
+ * @default true
284
+ */
285
+ exitOnCtrlC?: boolean;
286
+ /**
287
+ * Enable incremental rendering mode which only updates changed lines instead of redrawing the entire output.
288
+ *This can reduce flickering and improve performance for frequently updating UIs.
289
+ * @default false
290
+ */
291
+ incrementalRendering?: boolean;
292
+ /**
293
+ * Override automatic interactive mode detection.
294
+ *
295
+ * 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.
296
+ *
297
+ * 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.
298
+ *
299
+ * Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
300
+ *
301
+ *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.
302
+ * @default true (false if in CI or `stdout.isTTY` is falsy)
303
+ */
304
+ interactive?: boolean;
305
+ /**
306
+ * Enable screen reader support. See https://github.com/vadimdemedes/ink/blob/master/readme.md#screen-reader-support
307
+ * @default process.env['INK_SCREEN_READER'] === 'true'
308
+ */
309
+ isScreenReaderEnabled?: boolean;
310
+ /**
311
+ * Configure kitty keyboard protocol support for enhanced keyboard input.
312
+ * Enables additional modifiers (super, hyper, capsLock, numLock) and
313
+ *disambiguated key events in terminals that support the protocol.
314
+ * @see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
315
+ */
316
+ kittyKeyboard?: KittyKeyboardOptions;
317
+ /**
318
+ * Maximum frames per second for render updates.
319
+ * This controls how frequently the UI can update to prevent excessive re-rendering.
320
+ *Higher values allow more frequent updates but may impact performance.
321
+ * @default 30
322
+ */
323
+ maxFps?: number;
324
+ /**
325
+ * Runs the given callback after each render and re-render with render metrics.
326
+ *
327
+ * Note: this callback runs after Ink commits a frame, but it does not wait for `stdout`/`stderr` stream callbacks.
328
+ * To run code after output is flushed, use `waitUntilRenderFlush()`.
329
+ */
330
+ onRender?: (metrics: RenderMetrics) => void;
331
+ /**
332
+ * Patch console methods to ensure console output doesn't mix with Ink's output.
333
+ *
334
+ *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.
335
+ * @default true
336
+ */
337
+ patchConsole?: boolean;
338
+ /**
339
+ * If true, Ink defers frame output until after React's commit phase completes,
340
+ * ensuring `useLayoutEffect` hooks run before the frame is written to the terminal.
341
+ *
342
+ * This eliminates the one-frame flicker when components measure layout
343
+ * (e.g., scroll position, element size) in `useLayoutEffect` and adjust state.
344
+ *
345
+ * **Warning:** Incompatible with the `&lt;Static>` component, which relies on
346
+ * immediate render timing to append output.
347
+ * @default false
348
+ */
349
+ standardReactLayoutTiming?: boolean;
350
+ /**
351
+ * Error stream.
352
+ * @default process.stderr
353
+ */
354
+ stderr?: NodeJS.WriteStream;
355
+ /**
356
+ * Input stream where app will listen for input.
357
+ * @default process.stdin
358
+ */
359
+ stdin?: NodeJS.ReadStream;
360
+ /**
361
+ * Output stream where the app will be rendered.
362
+ * @default process.stdout
363
+ */
364
+ stdout?: NodeJS.WriteStream;
365
+ /**
366
+ * Use the native Rust cell-diff renderer for terminal output.
367
+ * Produces a Uint32Array buffer that the Rust renderer diffs cell-by-cell,
368
+ * generating minimal ANSI escape sequences. Reduces GC pressure and
369
+ * improves rendering performance for complex UIs.
370
+ *
371
+ * Falls back to string-based rendering if native bindings are not available.
372
+ * @default false
373
+ */
374
+ useNativeRenderer?: boolean;
375
+ };
376
+ type Instance = {
377
+ /**
378
+ * Unmount the current app and remove the internal Ink instance for this stdout.
379
+ *
380
+ * 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.
381
+ */
382
+ cleanup: () => void;
383
+ /**
384
+ * Clear output.
385
+ */
386
+ clear: () => void;
387
+ /**
388
+ * Replace the previous root node with a new one or update props of the current root node.
389
+ */
390
+ rerender: Ink["render"];
391
+ /**
392
+ * The root DOM element of the rendered tree.
393
+ * Useful for programmatic DOM inspection and advanced measurement.
394
+ */
395
+ rootNode: DOMElement;
396
+ /**
397
+ * Manually unmount the whole Ink app.
398
+ */
399
+ unmount: Ink["unmount"];
400
+ /**
401
+ * Returns a promise that settles when the app is unmounted.
402
+ *
403
+ * It resolves with the value passed to `exit(value)` and rejects with the error passed to `exit(error)`.
404
+ *When `unmount()` is called manually, it settles after unmount-related stdout writes complete.
405
+ * @example
406
+ * ```jsx
407
+ * const {unmount, waitUntilExit} = render(<MyApp />);
408
+ *
409
+ * setTimeout(unmount, 1000);
410
+ *
411
+ * await waitUntilExit(); // resolves after `unmount()` is called
412
+ * ```
413
+ */
414
+ waitUntilExit: Ink["waitUntilExit"];
415
+ /**
416
+ * Returns a promise that settles after pending render output is flushed to stdout.
417
+ *
418
+ *This can be used after `rerender()` when you need to run code only after the frame is written.
419
+ * @example
420
+ * ```jsx
421
+ * const {rerender, waitUntilRenderFlush} = render(<MyApp step="loading" />);
422
+ *
423
+ * rerender(<MyApp step="ready" />);
424
+ * await waitUntilRenderFlush(); // output for "ready" is flushed
425
+ *
426
+ * runNextCommand();
427
+ * ```
428
+ */
429
+ waitUntilRenderFlush: Ink["waitUntilRenderFlush"];
430
+ };
431
+ /**
432
+ * Mount a component and render the output.
433
+ */
434
+ declare const render: (node: ReactNode, options?: NodeJS.WriteStream | RenderOptions) => Instance;
435
+ export { Instance as I, KittyFlagName as K, RenderOptions as R, KittyKeyboardOptions as a, kittyModifiers as b, kittyFlags as k, render as r };
@@ -1,4 +1,4 @@
1
- import{LegacyRoot as p}from"react-reconciler/constants.js";import N from"yoga-layout";import{c as g}from"./dom-rphpG0kf.js";import{j as l}from"./reconciler-DhUGYWCr.js";import{H as i}from"./renderer-Cs0KEr1o.js";import{calculateScroll as v}from"./calculateScroll-D4Y_JR4H.js";const L=(f,u)=>{const d=u?.columns??80,e=g("ink-root");let a="";e.onComputeLayout=()=>{e.yogaNode.setWidth(d),e.yogaNode.calculateLayout(void 0,void 0,N.DIRECTION_LTR);const o=t=>{if(t.nodeName==="ink-box"){const n=t.style.overflow??"visible",m=t.style.overflowX??n,y=t.style.overflowY??n;(m==="scroll"||y==="scroll")&&v(t)}for(const n of t.childNodes)n.nodeName!=="#text"&&o(n)};o(e)},e.onImmediateRender=()=>{const{staticOutput:o}=i(e,!1);o&&o!==`
1
+ import{LegacyRoot as p}from"react-reconciler/constants.js";import N from"yoga-layout";import{c as g}from"./dom-rphpG0kf.js";import{j as l}from"./reconciler-DkwOtC5B.js";import{H as i}from"./renderer-Cs0KEr1o.js";import{calculateScroll as v}from"./calculateScroll-D4Y_JR4H.js";const L=(f,u)=>{const d=u?.columns??80,e=g("ink-root");let a="";e.onComputeLayout=()=>{e.yogaNode.setWidth(d),e.yogaNode.calculateLayout(void 0,void 0,N.DIRECTION_LTR);const o=t=>{if(t.nodeName==="ink-box"){const n=t.style.overflow??"visible",m=t.style.overflowX??n,y=t.style.overflowY??n;(m==="scroll"||y==="scroll")&&v(t)}for(const n of t.childNodes)n.nodeName!=="#text"&&o(n)};o(e)},e.onImmediateRender=()=>{const{staticOutput:o}=i(e,!1);o&&o!==`
2
2
  `&&(a+=o)};let r;const c=l.createContainer(e,p,null,!1,null,"render-to-string",o=>{r??=o},()=>{},()=>{},()=>{});let s=!1;try{l.updateContainerSync(f,c,null,()=>{}),l.flushSyncWork();const{output:o}=i(e,!1);if(l.updateContainerSync(null,c,null,()=>{}),l.flushSyncWork(),s=!0,e.yogaNode.free(),r!==void 0)throw r instanceof Error?r:new Error(String(r));const t=a.endsWith(`
3
3
  `)?a.slice(0,-1):a;return t&&o?`${t}
4
4
  ${o}`:t||o}finally{if(!s&&e.yogaNode)try{e.yogaNode.freeRecursive()}catch{}}};export{L as default};
@@ -1,13 +1,13 @@
1
- import { b as DOMNode, e as StyledLine } from "./dom.d-g-nsYquD.js";
1
+ import { b as DOMNode, e as StyledLine } from "./dom.d-CLGlidfI.js";
2
2
  /**
3
- * Compare the document position of two points in the DOM tree.
4
- * Returns -1 if A is before B, 0 if equal, 1 if A is after B.
5
- */
3
+ * Compare the document position of two points in the DOM tree.
4
+ * Returns -1 if A is before B, 0 if equal, 1 if A is after B.
5
+ */
6
6
  declare const comparePoints: (nodeA: DOMNode, offsetA: number, nodeB: DOMNode, offsetB: number) => number;
7
7
  /**
8
- * A Range represents a contiguous portion of the DOM tree.
9
- * Modeled after the browser's Range API.
10
- */
8
+ * A Range represents a contiguous portion of the DOM tree.
9
+ * Modeled after the browser's Range API.
10
+ */
11
11
  declare class Range {
12
12
  startContainer: DOMNode | undefined;
13
13
  startOffset: number;
@@ -25,9 +25,9 @@ declare class Range {
25
25
  private updateCommonAncestor;
26
26
  }
27
27
  /**
28
- * Manages multiple Range objects and provides high-level selection operations.
29
- * Modeled after the browser's Selection API.
30
- */
28
+ * Manages multiple Range objects and provides high-level selection operations.
29
+ * Modeled after the browser's Selection API.
30
+ */
31
31
  declare class Selection {
32
32
  anchorNode: DOMNode | undefined;
33
33
  anchorOffset: number;
@@ -49,12 +49,12 @@ declare class Selection {
49
49
  private notifyChange;
50
50
  }
51
51
  /**
52
- * Apply selection highlighting to a range of characters in a StyledLine.
53
- *
54
- * Characters whose index falls within [start, end) of the selection range
55
- * get the INVERSE style flag applied. Returns a new StyledLine with the
56
- * selection highlighting — the original is not mutated.
57
- */
52
+ * Apply selection highlighting to a range of characters in a StyledLine.
53
+ *
54
+ * Characters whose index falls within [start, end) of the selection range
55
+ * get the INVERSE style flag applied. Returns a new StyledLine with the
56
+ * selection highlighting — the original is not mutated.
57
+ */
58
58
  declare const applySelectionToStyledLine: (line: StyledLine, range: {
59
59
  end: number;
60
60
  start: number;
@@ -0,0 +1 @@
1
+ import{createRequire as c}from"node:module";import{createContext as t}from"react";const e=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,r=e,s=t({stderr:r.stderr,write(){}});s.displayName="InternalStderrContext";export{s as t};
@@ -0,0 +1 @@
1
+ import{createRequire as s}from"node:module";import{createContext as l}from"react";let o;const i=t=>(o??=s(import.meta.url))(t),e=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,c=t=>{if(typeof e<"u"&&e.versions&&e.versions.node){const[n,r]=e.versions.node.split(".").map(Number);if(n>22||n===22&&r>=3||n===20&&r>=16)return e.getBuiltinModule(t)}return i(t)},{EventEmitter:a}=c("node:events"),d=e,u=l({internal_eventEmitter:new a,internal_exitOnCtrlC:!0,isRawModeSupported:!1,setBracketedPasteMode(){},setRawMode(){},stdin:d.stdin});u.displayName="InternalStdinContext";export{u as e};
@@ -0,0 +1 @@
1
+ import{createRequire as c}from"node:module";import{createContext as o}from"react";const e=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,t=e,r=o({stdout:t.stdout,write(){}});r.displayName="InternalStdoutContext";export{r as t};