@alchemy.run/sigil 0.0.0-alpha.1 → 0.0.0-alpha.11

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 (223) hide show
  1. package/README.md +499 -313
  2. package/THIRD_PARTY_NOTICES.md +98 -23
  3. package/dist/Text-DV9CuzAT.d.ts +452 -0
  4. package/dist/ansi.d.ts +217 -0
  5. package/dist/ansi.js +87 -0
  6. package/dist/capabilities.d.ts +5 -0
  7. package/dist/capabilities.js +3 -0
  8. package/dist/cell-_ZVhbfl0.js +44 -0
  9. package/dist/color-CkbalRqK.js +2 -0
  10. package/dist/color-policy-BAC9-TZX.js +592 -0
  11. package/dist/color-policy-CCxuHIdD.d.ts +22 -0
  12. package/dist/color-profile-CyeHnG1T.d.ts +97 -0
  13. package/dist/color-profile-DHhQHY55.js +36 -0
  14. package/dist/color.d.ts +21 -0
  15. package/dist/color.js +3 -0
  16. package/dist/cursor-position-D2LAkRG0.d.ts +7 -0
  17. package/dist/detect-B3dL4Q11.js +374 -0
  18. package/dist/detect-Db6GbKOm.d.ts +195 -0
  19. package/dist/{devtools-QpCMm9JH.mjs → devtools-DbthxoD1.js} +23 -24
  20. package/dist/env-YVw64yZS.js +9 -0
  21. package/dist/escapes-CB_6CWOE.d.ts +72 -0
  22. package/dist/geometry-BxXOzJgo.d.ts +11 -0
  23. package/dist/index-D48vQhhe.d.ts +21 -0
  24. package/dist/index-DDVME65c.d.ts +919 -0
  25. package/dist/index.d.ts +1310 -0
  26. package/dist/index.js +3211 -0
  27. package/dist/jsx-dev-runtime.d.ts +2 -0
  28. package/dist/jsx-dev-runtime.js +227 -0
  29. package/dist/jsx-runtime-XtwIVFsg.js +255 -0
  30. package/dist/jsx-runtime.d.ts +2 -0
  31. package/dist/jsx-runtime.js +8 -0
  32. package/dist/osc-BFKKSqpg.js +71 -0
  33. package/dist/osc-Cn0fw77g.d.ts +23 -0
  34. package/dist/paint-Cx-zC_sX.d.ts +81 -0
  35. package/dist/query-BNc2B8GD.d.ts +152 -0
  36. package/dist/react-CTZ_8dwh.js +1197 -0
  37. package/dist/react.d.ts +2 -0
  38. package/dist/react.js +49 -0
  39. package/dist/router.d.ts +392 -0
  40. package/dist/router.js +711 -0
  41. package/dist/sample-Cqw1bjUL.js +445 -0
  42. package/dist/screen-CgC2WlVM.d.ts +49 -0
  43. package/dist/screen-CiPytswf.js +342 -0
  44. package/dist/screen.d.ts +5 -0
  45. package/dist/screen.js +5 -0
  46. package/dist/semantic-text-style-DIMzC7xt.js +91 -0
  47. package/dist/serialize-BTkAZgw1.js +79 -0
  48. package/dist/session-DDQ5V300.js +723 -0
  49. package/dist/sgr-BhwaWAJB.js +246 -0
  50. package/dist/store-C1P5fOUi.d.ts +72 -0
  51. package/dist/string-width-CijQwpIk.js +69 -0
  52. package/dist/strip-BvU4toXG.js +6 -0
  53. package/dist/terminal.d.ts +121 -0
  54. package/dist/terminal.js +2 -0
  55. package/dist/tokenize-AjqbvtiT.js +1242 -0
  56. package/dist/tokenize-Dx1y_l5H.d.ts +57 -0
  57. package/dist/truncate-D31fhU6i.js +562 -0
  58. package/dist/use-focus-B5npZrJU.js +18736 -0
  59. package/dist/yoga-5jKhYCJC.js +3465 -0
  60. package/dist/yoga.d.ts +2 -0
  61. package/dist/yoga.js +2 -0
  62. package/package.json +89 -29
  63. package/src/ansi/chalk.ts +138 -0
  64. package/src/ansi/cursor.ts +46 -0
  65. package/src/ansi/east-asian-width.ts +259 -0
  66. package/src/ansi/escapes.ts +120 -0
  67. package/src/ansi/graphemes.ts +8 -0
  68. package/src/ansi/hyperlink.ts +44 -0
  69. package/src/ansi/index.ts +27 -0
  70. package/src/ansi/osc.ts +77 -0
  71. package/src/ansi/sgr.ts +234 -0
  72. package/src/ansi/slice.ts +43 -0
  73. package/src/ansi/string-width.ts +121 -0
  74. package/src/ansi/strip.ts +13 -0
  75. package/src/ansi/tokenize.ts +380 -0
  76. package/src/ansi/truncate.ts +196 -0
  77. package/src/ansi/wrap.ts +765 -0
  78. package/src/ansi-tokenizer.ts +510 -0
  79. package/src/capabilities/color-policy.ts +34 -0
  80. package/src/capabilities/detect.ts +608 -0
  81. package/src/capabilities/index.ts +37 -0
  82. package/src/capabilities/query.ts +679 -0
  83. package/src/capabilities/store.ts +394 -0
  84. package/src/code-excerpt.ts +39 -0
  85. package/src/color/index.ts +3 -0
  86. package/src/color/paint.ts +169 -0
  87. package/src/color/palette.ts +48 -0
  88. package/src/color/sample.ts +323 -0
  89. package/src/color.ts +1 -0
  90. package/src/components/AccessibilityContext.ts +5 -0
  91. package/src/components/AnimationContext.ts +24 -0
  92. package/src/components/AnsiText.tsx +42 -0
  93. package/src/components/App.tsx +878 -0
  94. package/src/components/AppContext.ts +111 -0
  95. package/src/components/BackgroundContext.ts +7 -0
  96. package/src/components/Box.tsx +100 -0
  97. package/src/components/CursorContext.ts +19 -0
  98. package/src/components/ErrorBoundary.tsx +39 -0
  99. package/src/components/ErrorOverview.tsx +135 -0
  100. package/src/components/FocusContext.ts +30 -0
  101. package/src/components/Hyperlink.tsx +56 -0
  102. package/src/components/Newline.tsx +16 -0
  103. package/src/components/Spacer.tsx +11 -0
  104. package/src/components/Static.tsx +60 -0
  105. package/src/components/StderrContext.ts +24 -0
  106. package/src/components/StdinContext.ts +48 -0
  107. package/src/components/StdoutContext.ts +26 -0
  108. package/src/components/TerminalOscContext.ts +25 -0
  109. package/src/components/Text.tsx +122 -0
  110. package/src/components/Transform.tsx +38 -0
  111. package/src/components/VirtualList.tsx +128 -0
  112. package/src/cursor-position.ts +103 -0
  113. package/src/devtools.ts +103 -0
  114. package/src/dom.ts +301 -0
  115. package/src/env.ts +12 -0
  116. package/src/get-max-width.ts +11 -0
  117. package/src/global.d.ts +38 -0
  118. package/src/glyphs.ts +99 -0
  119. package/src/hooks/use-animation.ts +142 -0
  120. package/src/hooks/use-app.ts +8 -0
  121. package/src/hooks/use-box-metrics.ts +134 -0
  122. package/src/hooks/use-capabilities.ts +73 -0
  123. package/src/hooks/use-cursor.ts +33 -0
  124. package/src/hooks/use-focus-manager.ts +62 -0
  125. package/src/hooks/use-focus.ts +82 -0
  126. package/src/hooks/use-input.ts +267 -0
  127. package/src/hooks/use-is-screen-reader-enabled.ts +12 -0
  128. package/src/hooks/use-paste.ts +78 -0
  129. package/src/hooks/use-stderr.ts +8 -0
  130. package/src/hooks/use-stdin.ts +10 -0
  131. package/src/hooks/use-stdout.ts +8 -0
  132. package/src/hooks/use-terminal-osc.ts +59 -0
  133. package/src/hooks/use-virtual-scroll.ts +84 -0
  134. package/src/hooks/use-window-size.ts +37 -0
  135. package/src/index.ts +96 -0
  136. package/src/ink.tsx +1452 -0
  137. package/src/input-parser.ts +303 -0
  138. package/src/instances.ts +9 -0
  139. package/src/jsx-dev-runtime.ts +3 -0
  140. package/src/jsx-runtime.ts +6 -0
  141. package/src/kitty-keyboard.ts +185 -0
  142. package/src/measure-element.ts +62 -0
  143. package/src/measure-text.ts +31 -0
  144. package/src/paint-tree.ts +220 -0
  145. package/src/parse-keypress.ts +515 -0
  146. package/src/parse-stack-line.ts +138 -0
  147. package/src/patch-console.ts +106 -0
  148. package/src/quick-lru.ts +85 -0
  149. package/src/react.ts +53 -0
  150. package/src/reconciler.ts +476 -0
  151. package/src/render-background.ts +59 -0
  152. package/src/render-border.ts +167 -0
  153. package/src/render-frame.ts +83 -0
  154. package/src/render-to-string.ts +146 -0
  155. package/src/render.ts +284 -0
  156. package/src/router/components.tsx +343 -0
  157. package/src/router/context.ts +41 -0
  158. package/src/router/history.ts +194 -0
  159. package/src/router/hooks.tsx +391 -0
  160. package/src/router/index.ts +34 -0
  161. package/src/router/matcher.ts +571 -0
  162. package/src/sanitize-ansi.ts +33 -0
  163. package/src/screen/ansi.ts +184 -0
  164. package/src/screen/canvas.ts +160 -0
  165. package/src/screen/cell.ts +138 -0
  166. package/src/screen/color-profile.ts +47 -0
  167. package/src/screen/geometry.ts +9 -0
  168. package/src/screen/index.ts +6 -0
  169. package/src/screen/screen.ts +305 -0
  170. package/src/screen/serialize.ts +129 -0
  171. package/src/screen.ts +1 -0
  172. package/src/semantic-text-style.ts +118 -0
  173. package/src/signal-exit.ts +106 -0
  174. package/src/squash-text-nodes.ts +37 -0
  175. package/src/stream.ts +28 -0
  176. package/src/structured-text.ts +325 -0
  177. package/src/styles.ts +753 -0
  178. package/src/terminal/index.ts +2 -0
  179. package/src/terminal/inline-presenter.ts +120 -0
  180. package/src/terminal/input.ts +92 -0
  181. package/src/terminal/render-scheduler.ts +37 -0
  182. package/src/terminal/screen-presenter.ts +242 -0
  183. package/src/terminal/session.ts +408 -0
  184. package/src/terminal-size.ts +58 -0
  185. package/src/terminal.ts +1 -0
  186. package/src/testing/browser.ts +588 -0
  187. package/src/testing/emulators.ts +205 -0
  188. package/src/testing/explorer-app/index.html +12 -0
  189. package/src/testing/explorer-app/main.ts +381 -0
  190. package/src/testing/explorer-app/style.css +194 -0
  191. package/src/testing/explorer-app/tsconfig.json +15 -0
  192. package/src/testing/explorer-app/vite-env.d.ts +1 -0
  193. package/src/testing/index.ts +26 -0
  194. package/src/testing/keys.ts +56 -0
  195. package/src/testing/live.ts +85 -0
  196. package/src/testing/matchers.ts +70 -0
  197. package/src/testing/public.ts +94 -0
  198. package/src/testing/terminal.ts +361 -0
  199. package/src/testing/vitest.ts +157 -0
  200. package/src/throttle.ts +73 -0
  201. package/src/transform-adapter.ts +14 -0
  202. package/src/types.ts +10 -0
  203. package/src/virtual-scroll.ts +133 -0
  204. package/src/wrap-text.ts +54 -0
  205. package/src/yoga/config.ts +57 -0
  206. package/src/yoga/core/absoluteLayout.ts +626 -0
  207. package/src/yoga/core/baseline.ts +66 -0
  208. package/src/yoga/core/cache.ts +136 -0
  209. package/src/yoga/core/calculateLayout.ts +2926 -0
  210. package/src/yoga/core/config.ts +104 -0
  211. package/src/yoga/core/flexLine.ts +177 -0
  212. package/src/yoga/core/helpers.ts +293 -0
  213. package/src/yoga/core/layoutResults.ts +167 -0
  214. package/src/yoga/core/node.ts +611 -0
  215. package/src/yoga/core/numeric.ts +44 -0
  216. package/src/yoga/core/pixelGrid.ts +151 -0
  217. package/src/yoga/core/style.ts +887 -0
  218. package/src/yoga/core/types.ts +224 -0
  219. package/src/yoga/generated/YGEnums.ts +263 -0
  220. package/src/yoga/index.ts +19 -0
  221. package/src/yoga/node.ts +1140 -0
  222. package/dist/index.d.mts +0 -2379
  223. package/dist/index.mjs +0 -10072
@@ -0,0 +1,1310 @@
1
+ import { a as Multiplexer, c as TerminalAppearance, d as detectCapabilities, f as detectColorLevel, h as detectUnicodeSupport, i as ColorSupportLevel, l as TerminalIdentity, m as detectTerminal, n as ColorInfo, o as PixelGeometry, p as detectHyperlinkSupport, r as ColorSupport, s as RgbColor, t as Capabilities, u as createSupportsColor } from "./detect-Db6GbKOm.js";
2
+ import { n as TerminalProgressState, t as ClipboardSelection } from "./osc-Cn0fw77g.js";
3
+ import { a as getTerminalQuery, i as applyTerminalQuery, n as TerminalQueryOptions, o as queryTerminal, r as TerminalQueryResult, s as refreshTerminalQuery, t as PixelSize } from "./query-BNc2B8GD.js";
4
+ import { i as OutputStream, n as capabilities, r as getCapabilities, t as CapabilitiesStore } from "./store-C1P5fOUi.js";
5
+ import { s as CellStyle, t as ColorProfile } from "./color-profile-CyeHnG1T.js";
6
+ import { s as Paint } from "./paint-Cx-zC_sX.js";
7
+ import { n as Text, r as Styles, t as Props$8 } from "./Text-DV9CuzAT.js";
8
+ import { i as Node } from "./index-DDVME65c.js";
9
+ import { t as CursorPosition } from "./cursor-position-D2LAkRG0.js";
10
+ import { Writable } from "node:stream";
11
+ import { EventEmitter } from "node:events";
12
+ import { Key as Key$1, PropsWithChildren, ReactNode, Ref, RefObject } from "react";
13
+ //#region src/kitty-keyboard.d.ts
14
+ declare const kittyFlags: {
15
+ readonly disambiguateEscapeCodes: 1;
16
+ readonly reportEventTypes: 2;
17
+ readonly reportAlternateKeys: 4;
18
+ readonly reportAllKeysAsEscapeCodes: 8;
19
+ readonly reportAssociatedText: 16;
20
+ };
21
+ type KittyFlagName = keyof typeof kittyFlags;
22
+ declare const kittyModifiers: {
23
+ readonly shift: 1;
24
+ readonly alt: 2;
25
+ readonly ctrl: 4;
26
+ readonly super: 8;
27
+ readonly hyper: 16;
28
+ readonly meta: 32;
29
+ readonly capsLock: 64;
30
+ readonly numLock: 128;
31
+ };
32
+ type KittyKeyboardOptions = {
33
+ mode?: "auto" | "enabled" | "disabled";
34
+ flags?: KittyFlagName[];
35
+ };
36
+ //#endregion
37
+ //#region src/ink.d.ts
38
+ /**
39
+ The origin of a chunk captured by `patchConsole`: a patched `console.*`
40
+ method, or a direct `stdout.write` / `stderr.write` call.
41
+ */
42
+ type CapturedOutputSource = "console" | "stdio";
43
+ /**
44
+ Performance metrics for a render operation.
45
+ */
46
+ type RenderMetrics = {
47
+ /**
48
+ Time spent rendering in milliseconds.
49
+ */
50
+ renderTime: number;
51
+ };
52
+ /**
53
+ A live React terminal runtime for one stdout stream, created by `createInk`.
54
+ */
55
+ type Ink = {
56
+ /**
57
+ Replace the previous root node with a new one or update props of the current root node.
58
+ */
59
+ render: (node: ReactNode) => void;
60
+ /**
61
+ Unmount the app and release the terminal.
62
+ */
63
+ unmount: (error?: Error | number | null) => void;
64
+ /**
65
+ Returns a promise that settles when the app is unmounted.
66
+ */
67
+ waitUntilExit: () => Promise<unknown>;
68
+ /**
69
+ Returns a promise that settles after pending render output is flushed to stdout.
70
+ */
71
+ waitUntilRenderFlush: () => Promise<void>;
72
+ /**
73
+ Clear output.
74
+ */
75
+ clear: () => void;
76
+ /** Copy text through the renderer-owned terminal session. */
77
+ copyToClipboard: (text: string, selection?: ClipboardSelection) => boolean;
78
+ /** Update terminal-native progress through the renderer-owned session. */
79
+ setProgress: (state: TerminalProgressState, value?: number) => boolean;
80
+ };
81
+ //#endregion
82
+ //#region src/render.d.ts
83
+ type RenderOptions = {
84
+ /**
85
+ Output stream where the app will be rendered.
86
+
87
+ @default process.stdout
88
+ */
89
+ stdout?: NodeJS.WritableStream;
90
+ /**
91
+ Input stream where app will listen for input.
92
+
93
+ @default process.stdin
94
+ */
95
+ stdin?: NodeJS.ReadableStream;
96
+ /**
97
+ Error stream.
98
+ @default process.stderr
99
+ */
100
+ stderr?: NodeJS.WritableStream;
101
+ /**
102
+ If true, each update will be rendered as separate output, without replacing the previous one.
103
+
104
+ @default false
105
+ */
106
+ debug?: boolean;
107
+ /**
108
+ 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.
109
+
110
+ @default true
111
+ */
112
+ exitOnCtrlC?: boolean;
113
+ /**
114
+ Patch console methods to ensure console output doesn't mix with Ink's output.
115
+
116
+ Pass `"stdio"` to additionally intercept direct `stdout.write` / `stderr.write` calls on the streams Ink renders to (output from dependencies, native warnings, child tooling). Captured chunks are line-buffered and spliced above the live frame like console output; partial lines are flushed at unmount. Use `onCapturedOutput` to observe captured chunks or take over their display.
117
+
118
+ Note: Once unmount starts, Ink restores the native console (and stream writes) before React cleanup runs. Teardown-time output then follows the normal behavior instead of being rerouted through Ink.
119
+
120
+ @default true
121
+ */
122
+ patchConsole?: boolean | "stdio";
123
+ /**
124
+ Observe output captured by `patchConsole` before Ink displays it.
125
+
126
+ Receives each captured chunk with its origin (`"console"` or `"stdio"`). Return `true` to take ownership of the chunk: Ink will not display it, so the app can render it itself — for example inside a `<Static>` transcript.
127
+ */
128
+ onCapturedOutput?: (stream: "stdout" | "stderr", data: string, source: "console" | "stdio") => boolean | undefined | void;
129
+ /**
130
+ Runs the given callback after each render and re-render with render metrics.
131
+
132
+ Note: this callback runs after Ink commits a frame, but it does not wait for `stdout`/`stderr` stream callbacks.
133
+ To run code after output is flushed, use `waitUntilRenderFlush()`.
134
+ */
135
+ onRender?: (metrics: RenderMetrics) => void;
136
+ /**
137
+ Enable screen reader support. See https://github.com/vadimdemedes/ink/blob/master/readme.md#screen-reader-support
138
+
139
+ @default process.env['SIGIL_SCREEN_READER'] === 'true'
140
+ */
141
+ isScreenReaderEnabled?: boolean;
142
+ /**
143
+ Maximum frames per second for render updates.
144
+ This controls how frequently the UI can update to prevent excessive re-rendering.
145
+ Higher values allow more frequent updates but may impact performance.
146
+
147
+ @default 30
148
+ */
149
+ maxFps?: number;
150
+ /**
151
+ Override the output color profile for this render instance. When omitted,
152
+ the profile follows the capabilities of `stdout` and capability upgrades
153
+ redraw the live frame. Static content already written to scrollback is not
154
+ replayed or recolored.
155
+ */
156
+ colorProfile?: ColorProfile;
157
+ /**
158
+ Enable React Concurrent Rendering mode.
159
+
160
+ When enabled:
161
+ - Suspense boundaries work correctly with async data
162
+ - `useTransition` and `useDeferredValue` are fully functional
163
+ - Updates can be interrupted for higher priority work
164
+
165
+ 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.
166
+
167
+ @default false
168
+ */
169
+ concurrent?: boolean;
170
+ /**
171
+ Configure kitty keyboard protocol support for enhanced keyboard input.
172
+ Enables additional modifiers (super, hyper, capsLock, numLock) and
173
+ disambiguated key events in terminals that support the protocol.
174
+
175
+ @see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
176
+ */
177
+ kittyKeyboard?: KittyKeyboardOptions;
178
+ /**
179
+ Override automatic interactive mode detection.
180
+
181
+ By default, Ink detects whether the environment is interactive based on CI detection (the `CI` environment variable) and `stdout.isTTY`. Most users should not need to set this.
182
+
183
+ 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.
184
+
185
+ Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
186
+
187
+ 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.
188
+
189
+ @default true (false if in CI or `stdout.isTTY` is falsy)
190
+ */
191
+ interactive?: boolean;
192
+ /**
193
+ 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.
194
+
195
+ 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.
196
+
197
+ 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.
198
+
199
+ Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
200
+
201
+ 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.
202
+
203
+ @default false
204
+ */
205
+ alternateScreen?: boolean;
206
+ };
207
+ type Instance = {
208
+ /**
209
+ Replace the previous root node with a new one or update props of the current root node.
210
+ */
211
+ rerender: Ink["render"];
212
+ /**
213
+ Manually unmount the whole Ink app.
214
+ */
215
+ unmount: Ink["unmount"];
216
+ /**
217
+ Returns a promise that settles when the app is unmounted.
218
+
219
+ It resolves with the value passed to `exit(value)` and rejects with the error passed to `exit(error)`.
220
+ When `unmount()` is called manually, it settles after unmount-related stdout writes complete.
221
+
222
+ @example
223
+ ```jsx
224
+ const {unmount, waitUntilExit} = render(<MyApp />);
225
+
226
+ setTimeout(unmount, 1000);
227
+
228
+ await waitUntilExit(); // resolves after `unmount()` is called
229
+ ```
230
+ */
231
+ waitUntilExit: Ink["waitUntilExit"];
232
+ /**
233
+ Returns a promise that settles after pending render output is flushed to stdout.
234
+
235
+ This can be used after `rerender()` when you need to run code only after the frame is written.
236
+
237
+ @example
238
+ ```jsx
239
+ const {rerender, waitUntilRenderFlush} = render(<MyApp step="loading" />);
240
+
241
+ rerender(<MyApp step="ready" />);
242
+ await waitUntilRenderFlush(); // output for "ready" is flushed
243
+
244
+ runNextCommand();
245
+ ```
246
+ */
247
+ waitUntilRenderFlush: Ink["waitUntilRenderFlush"];
248
+ /**
249
+ Unmount the current app and remove the internal Ink instance for this stdout.
250
+
251
+ 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.
252
+ */
253
+ cleanup: () => void;
254
+ /**
255
+ Clear output.
256
+ */
257
+ clear: () => void;
258
+ /** Copy text through the renderer-owned terminal session. */
259
+ copyToClipboard: (text: string, selection?: ClipboardSelection) => boolean;
260
+ /** Update terminal-native progress through the renderer-owned session. */
261
+ setProgress: (state: TerminalProgressState, value?: number) => boolean;
262
+ };
263
+ /**
264
+ Mount a component and render the output.
265
+ */
266
+ declare const render: (node: ReactNode, options?: Writable | RenderOptions) => Instance;
267
+ //#endregion
268
+ //#region src/render-to-string.d.ts
269
+ type RenderToStringOptions = {
270
+ /**
271
+ Width of the virtual terminal in columns.
272
+
273
+ @default 80
274
+ */
275
+ columns?: number;
276
+ /**
277
+ Color profile used for deterministic serialization. By default this retains
278
+ the process color level for Ink compatibility.
279
+ */
280
+ colorProfile?: ColorProfile;
281
+ };
282
+ /**
283
+ Render a React element to a string synchronously. Unlike `render()`, this function does not write to stdout, does not set up any terminal event listeners, and returns the rendered output as a string.
284
+
285
+ Useful for generating documentation, writing output to files, testing, or any scenario where you need the rendered output as a string without starting a persistent terminal application.
286
+
287
+ **Notes:**
288
+
289
+ - Terminal-specific hooks (`useInput`, `useStdin`, `useStdout`, `useStderr`, `useApp`, `useFocus`, `useFocusManager`) return default no-op values since there is no terminal session. They will not throw, but they will not function as in a live terminal.
290
+ - `useEffect` callbacks will execute during rendering (due to synchronous rendering mode), but state updates they trigger will not affect the returned output, which reflects the initial render.
291
+ - `useLayoutEffect` callbacks fire synchronously during commit, so state updates they trigger **will** be reflected in the output.
292
+ - The `<Static>` component is supported — its output is prepended to the dynamic output.
293
+ - If a component throws during rendering, the error is propagated to the caller after cleanup.
294
+
295
+ @example
296
+ ```
297
+ import {renderToString, Text, Box} from 'ink';
298
+
299
+ const output = renderToString(
300
+ <Box padding={1}>
301
+ <Text color="green">Hello World</Text>
302
+ </Box>,
303
+ {columns: 40}
304
+ );
305
+
306
+ console.log(output);
307
+ ```
308
+ */
309
+ declare const renderToString: (node: ReactNode, options?: RenderToStringOptions) => string;
310
+ //#endregion
311
+ //#region src/semantic-text-style.d.ts
312
+ type SemanticTextStyle = {
313
+ readonly foreground?: Paint;
314
+ readonly background?: Paint;
315
+ readonly resetForeground?: boolean;
316
+ readonly resetBackground?: boolean;
317
+ readonly underline?: CellStyle["underline"];
318
+ readonly attributes: number;
319
+ };
320
+ //#endregion
321
+ //#region src/transform-adapter.d.ts
322
+ type AnsiTransformer = (text: string, line: number) => string;
323
+ //#endregion
324
+ //#region src/dom.d.ts
325
+ type InkNode = {
326
+ parentNode: DOMElement | undefined;
327
+ yogaNode?: Node;
328
+ internal_static?: boolean;
329
+ style: Styles;
330
+ };
331
+ type LayoutListener = () => void;
332
+ type TextName = "#text";
333
+ type ElementNames = "ink-root" | "ink-box" | "ink-text" | "ink-virtual-text";
334
+ type NodeNames = ElementNames | TextName;
335
+ type DOMElement = {
336
+ nodeName: ElementNames;
337
+ attributes: Record<string, DOMNodeAttribute>;
338
+ childNodes: DOMNode[];
339
+ internal_ansi?: boolean;
340
+ internal_transform?: AnsiTransformer;
341
+ internal_textStyle?: SemanticTextStyle;
342
+ internal_accessibility?: {
343
+ role?: "button" | "checkbox" | "combobox" | "list" | "listbox" | "listitem" | "menu" | "menuitem" | "option" | "progressbar" | "radio" | "radiogroup" | "tab" | "tablist" | "table" | "textbox" | "timer" | "toolbar";
344
+ state?: {
345
+ busy?: boolean;
346
+ checked?: boolean;
347
+ disabled?: boolean;
348
+ expanded?: boolean;
349
+ multiline?: boolean;
350
+ multiselectable?: boolean;
351
+ readonly?: boolean;
352
+ required?: boolean;
353
+ selected?: boolean;
354
+ };
355
+ };
356
+ isStaticDirty?: boolean;
357
+ staticNode?: DOMElement;
358
+ previousStaticNode?: DOMElement;
359
+ onComputeLayout?: () => void;
360
+ onRender?: () => void;
361
+ onImmediateRender?: () => void;
362
+ onStaticChange?: () => void;
363
+ internal_layoutListeners?: Set<LayoutListener>;
364
+ } & InkNode;
365
+ type TextNode = {
366
+ nodeName: TextName;
367
+ nodeValue: string;
368
+ } & InkNode;
369
+ type DOMNode<T = {
370
+ nodeName: NodeNames;
371
+ }> = T extends {
372
+ nodeName: infer U;
373
+ } ? U extends "#text" ? TextNode : DOMElement : never;
374
+ type DOMNodeAttribute = boolean | string | number;
375
+ //#endregion
376
+ //#region src/components/Box.d.ts
377
+ type Props$2 = Omit<Styles, "textWrap"> & {
378
+ /**
379
+ A label for the element for screen readers.
380
+ */
381
+ readonly "aria-label"?: string;
382
+ /**
383
+ Hide the element from screen readers.
384
+ */
385
+ readonly "aria-hidden"?: boolean;
386
+ /**
387
+ The role of the element.
388
+ */
389
+ readonly "aria-role"?: "button" | "checkbox" | "combobox" | "list" | "listbox" | "listitem" | "menu" | "menuitem" | "option" | "progressbar" | "radio" | "radiogroup" | "tab" | "tablist" | "table" | "textbox" | "timer" | "toolbar";
390
+ /**
391
+ The state of the element.
392
+ */
393
+ readonly "aria-state"?: {
394
+ readonly busy?: boolean;
395
+ readonly checked?: boolean;
396
+ readonly disabled?: boolean;
397
+ readonly expanded?: boolean;
398
+ readonly multiline?: boolean;
399
+ readonly multiselectable?: boolean;
400
+ readonly readonly?: boolean;
401
+ readonly required?: boolean;
402
+ readonly selected?: boolean;
403
+ };
404
+ };
405
+ /**
406
+ `<Box>` is an essential Ink component to build your layout. It's like `<div style="display: flex">` in the browser.
407
+ */
408
+ declare function Box({ children, ref, backgroundColor, "aria-label": ariaLabel, "aria-hidden": ariaHidden, "aria-role": role, "aria-state": ariaState, ...style }: PropsWithChildren<Props$2> & {
409
+ readonly ref?: Ref<DOMElement>;
410
+ }): import("react").JSX.Element | null;
411
+ //#endregion
412
+ //#region src/components/AnsiText.d.ts
413
+ type Props = {
414
+ /** External text containing ANSI SGR styling or OSC 8 hyperlinks. */
415
+ readonly children: string;
416
+ readonly wrap?: Styles["textWrap"];
417
+ readonly "aria-label"?: string;
418
+ readonly "aria-hidden"?: boolean;
419
+ };
420
+ /**
421
+ * Renders explicitly trusted ANSI-styled output as structured terminal cells.
422
+ * Ordinary `Text` continues to strip terminal control sequences.
423
+ */
424
+ declare function AnsiText({ children, wrap, "aria-label": ariaLabel, "aria-hidden": ariaHidden }: Props): import("react").JSX.Element | null;
425
+ //#endregion
426
+ //#region src/components/AppContext.d.ts
427
+ /**
428
+ A handle returned by `suspendTerminal()` when called without a callback.
429
+
430
+ Call `resume()` to give terminal ownership back to Ink, or use `await using`
431
+ so the suspension is resumed automatically when it leaves scope.
432
+ */
433
+ type TerminalSuspension = {
434
+ readonly resume: () => Promise<void>;
435
+ readonly [Symbol.asyncDispose]: () => Promise<void>;
436
+ };
437
+ /**
438
+ Temporarily hand the terminal over to a child process (e.g. `$EDITOR`, `less`,
439
+ `fzf`), then restore Ink's terminal state and force a full redraw.
440
+ */
441
+ type SuspendTerminal = {
442
+ (callback: () => void | Promise<void>): Promise<void>;
443
+ (): Promise<TerminalSuspension>;
444
+ };
445
+ type Props$1 = {
446
+ /**
447
+ Exit (unmount) the whole Ink app.
448
+
449
+ - `exit()` — resolves `waitUntilExit()` with `undefined`.
450
+ - `exit(new Error('…'))` — rejects `waitUntilExit()` with the error.
451
+ - `exit(value)` — resolves `waitUntilExit()` with `value`.
452
+ */
453
+ readonly exit: (errorOrResult?: unknown) => void;
454
+ /**
455
+ Returns a promise that settles after pending render output is flushed to stdout.
456
+
457
+ @example
458
+ ```jsx
459
+ import {useEffect} from 'react';
460
+ import {useApp} from 'ink';
461
+
462
+ const Example = () => {
463
+ const {waitUntilRenderFlush} = useApp();
464
+
465
+ useEffect(() => {
466
+ void (async () => {
467
+ await waitUntilRenderFlush();
468
+ runNextCommand();
469
+ })();
470
+ }, [waitUntilRenderFlush]);
471
+
472
+ return …;
473
+ };
474
+ ```
475
+ */
476
+ readonly waitUntilRenderFlush: () => Promise<void>;
477
+ /**
478
+ Temporarily release the terminal so a child process can take it over, then
479
+ restore Ink's terminal state and force a full redraw.
480
+
481
+ Use the callback form for the common case — Ink restores the terminal even
482
+ if the callback throws:
483
+
484
+ @example
485
+ ```jsx
486
+ import {useApp} from 'ink';
487
+
488
+ const {suspendTerminal} = useApp();
489
+
490
+ await suspendTerminal(async () => {
491
+ await runEditor();
492
+ });
493
+ ```
494
+
495
+ Or hold a suspension and resume it yourself:
496
+
497
+ @example
498
+ ```jsx
499
+ await using suspension = await suspendTerminal();
500
+ await runEditor();
501
+ ```
502
+ */
503
+ readonly suspendTerminal: SuspendTerminal;
504
+ };
505
+ //#endregion
506
+ //#region src/components/StdinContext.d.ts
507
+ type PublicProps = {
508
+ /**
509
+ The stdin stream passed to `render()` in `options.stdin`, or `process.stdin` by default. Useful if your app needs to handle user input.
510
+ */
511
+ readonly stdin: NodeJS.ReadableStream;
512
+ /**
513
+ Ink exposes this function via own `<StdinContext>` to be able to handle Ctrl+C, that's why you should use Ink's `setRawMode` instead of `process.stdin.setRawMode`. If the `stdin` stream passed to Ink does not support setRawMode, this function does nothing.
514
+ */
515
+ readonly setRawMode: (value: boolean) => void;
516
+ /**
517
+ A boolean flag determining if the current `stdin` supports `setRawMode`. A component using `setRawMode` might want to use `isRawModeSupported` to nicely fall back in environments where raw mode is not supported.
518
+ */
519
+ readonly isRawModeSupported: boolean;
520
+ };
521
+ //#endregion
522
+ //#region src/components/StdoutContext.d.ts
523
+ type Props$7 = {
524
+ /**
525
+ Stdout stream passed to `render()` in `options.stdout` or `process.stdout` by default.
526
+ */
527
+ readonly stdout: OutputStream;
528
+ /**
529
+ Write any string to stdout while preserving Ink's output. It's useful when you want to display external information outside of Ink's rendering and ensure there's no conflict between the two. It's similar to `<Static>`, except it can't accept components; it only works with strings.
530
+ */
531
+ readonly write: (data: string) => void;
532
+ };
533
+ //#endregion
534
+ //#region src/components/StderrContext.d.ts
535
+ type Props$6 = {
536
+ /**
537
+ Stderr stream passed to `render()` in `options.stderr` or `process.stderr` by default.
538
+ */
539
+ readonly stderr: NodeJS.WritableStream;
540
+ /**
541
+ Write any string to stderr while preserving Ink's output. It's useful when you want to display external information outside of Ink's rendering and ensure there's no conflict between the two. It's similar to `<Static>`, except it can't accept components; it only works with strings.
542
+ */
543
+ readonly write: (data: string) => void;
544
+ };
545
+ //#endregion
546
+ //#region src/components/Static.d.ts
547
+ type Props$5<T> = {
548
+ /**
549
+ Array of items of any type to render using the function you pass as a component child.
550
+ */
551
+ readonly items: T[];
552
+ /**
553
+ Styles to apply to a container of child elements. See <Box> for supported properties.
554
+ */
555
+ readonly style?: Styles;
556
+ /**
557
+ Function that is called to render every item in the `items` array. The first argument is the item itself, and the second argument is the index of that item in the `items` array. Note that a `key` must be assigned to the root component.
558
+ */
559
+ readonly children: (item: T, index: number) => ReactNode;
560
+ };
561
+ /**
562
+ `<Static>` component permanently renders its output above everything else. It's useful for displaying activity like completed tasks or logs—things that don't change after they're rendered (hence the name "Static").
563
+
564
+ It's preferred to use `<Static>` for use cases like these when you can't know or control the number of items that need to be rendered.
565
+
566
+ For example, [Tap](https://github.com/tapjs/node-tap) uses `<Static>` to display a list of completed tests. [Gatsby](https://github.com/gatsbyjs/gatsby) uses it to display a list of generated pages while still displaying a live progress bar.
567
+ */
568
+ declare function Static<T>(props: Props$5<T>): import("react").JSX.Element;
569
+ //#endregion
570
+ //#region src/components/Transform.d.ts
571
+ type Props$9 = {
572
+ /**
573
+ Screen-reader-specific text to output. If this is set, all children will be ignored.
574
+ */
575
+ readonly accessibilityLabel?: string;
576
+ /**
577
+ Compatibility function that transforms the ANSI serialization of this subtree.
578
+ */
579
+ readonly transform: (children: string, index: number) => string;
580
+ readonly children?: ReactNode;
581
+ };
582
+ /**
583
+ Transform a string representation of React components before they're written to output. For example, you might want to apply a gradient to text, add a clickable link, or create some text effects. These use cases can't accept React nodes as input; they expect a string. That's what the <Transform> component does: it gives you an output string of its child components and lets you transform it in any way.
584
+ */
585
+ declare function Transform({ children, transform, accessibilityLabel }: Props$9): import("react").JSX.Element | null;
586
+ //#endregion
587
+ //#region src/components/Hyperlink.d.ts
588
+ type Props$3 = Omit<Props$8, "children"> & {
589
+ /**
590
+ The URL the hyperlink points to.
591
+ */
592
+ readonly url: string;
593
+ /**
594
+ When the terminal does not support OSC 8 hyperlinks, append the URL in
595
+ parentheses after the text so it stays reachable. Set to `false` to render
596
+ the text alone.
597
+
598
+ @default true
599
+ */
600
+ readonly fallback?: boolean;
601
+ readonly children?: ReactNode;
602
+ };
603
+ /**
604
+ A clickable OSC 8 hyperlink — the counterpart to the router's `<Link>`, which
605
+ navigates between screens. On terminals without hyperlink support it falls
606
+ back to `text (url)`.
607
+
608
+ ```tsx
609
+ <Hyperlink url="https://example.com">Documentation</Hyperlink>
610
+ ```
611
+ */
612
+ declare function Hyperlink({ url, fallback, children, ...textProps }: Props$3): import("react").JSX.Element;
613
+ //#endregion
614
+ //#region src/components/Newline.d.ts
615
+ /** @jsxImportSource react */
616
+ type Props$4 = {
617
+ /**
618
+ Number of newlines to insert.
619
+
620
+ @default 1
621
+ */
622
+ readonly count?: number;
623
+ };
624
+ /**
625
+ Adds one or more newline (`\n`) characters. Must be used within `<Text>` components.
626
+ */
627
+ declare function Newline({ count }: Props$4): import("react").JSX.Element;
628
+ //#endregion
629
+ //#region src/components/Spacer.d.ts
630
+ /**
631
+ A flexible space that expands along the major axis of its containing layout.
632
+
633
+ It's useful as a shortcut for filling all the available space between elements.
634
+ */
635
+ declare function Spacer(): import("react").JSX.Element;
636
+ //#endregion
637
+ //#region src/components/VirtualList.d.ts
638
+ type Props$10<Item> = {
639
+ /**
640
+ Items to window over.
641
+ */
642
+ readonly items: ReadonlyArray<Item>;
643
+ /**
644
+ Height of an item in rows. It must match what `renderItem` produces for it:
645
+ the window is computed from these numbers, never from the rendered output.
646
+ */
647
+ readonly itemHeight: (item: Item, index: number) => number;
648
+ /**
649
+ Render one item. Only items intersecting the viewport are rendered.
650
+ */
651
+ readonly renderItem: (item: Item, index: number) => ReactNode;
652
+ /**
653
+ React key for an item. Defaults to its index.
654
+ */
655
+ readonly getKey?: (item: Item, index: number) => Key$1;
656
+ /**
657
+ Item to keep fully visible. When it changes, the list scrolls as little as
658
+ necessary to show it.
659
+ */
660
+ readonly focusedIndex?: number;
661
+ /**
662
+ Viewport height in rows. When omitted the list takes the height of its
663
+ content and shrinks to whatever space its container leaves: bound an
664
+ ancestor (`height` or `maxHeight`) and give the siblings that must keep
665
+ their size `flexShrink={0}`.
666
+ */
667
+ readonly height?: number;
668
+ };
669
+ /**
670
+ A vertically windowed list: only the items intersecting the viewport are
671
+ rendered, inside a clipped box that scrolls by whole rows. Items may have
672
+ different heights, and the item at the top edge may be partially visible.
673
+
674
+ Until the first layout pass has measured the viewport, every item is rendered
675
+ inside the clipped box so the first frame already looks right.
676
+ */
677
+ declare function VirtualList<Item>({ items, itemHeight, renderItem, getKey, focusedIndex, height }: Props$10<Item>): import("react").JSX.Element;
678
+ //#endregion
679
+ //#region src/hooks/use-capabilities.d.ts
680
+ /**
681
+ Returns everything knowable about the terminal: size, identity, platform,
682
+ color depth, theme, and feature support.
683
+
684
+ A thin wrapper over the framework-free capabilities store (`getCapabilities`):
685
+ environment-derived facts are available immediately; facts only the terminal
686
+ itself can answer fill in after a lazy one-time query, and re-mounting
687
+ consumers refreshes the dynamic facts (theme colors, pixel geometry).
688
+ Re-renders on terminal resize and whenever query answers arrive.
689
+ */
690
+ declare const useCapabilities: () => Capabilities;
691
+ /**
692
+ Calls `onChange` whenever the terminal changes: resizes (including in-band
693
+ pixel geometry), color scheme switches, window focus, and query answers
694
+ arriving. The React wrapper over `capabilities.subscribe()` for side effects —
695
+ for rendering, use `useCapabilities` instead.
696
+
697
+ The callback always sees the latest render's closure and changing it does not
698
+ resubscribe. Both the new and previous snapshot are passed, so handlers can
699
+ react to the specific change:
700
+
701
+ ```tsx
702
+ useCapabilitiesChange((next, previous) => {
703
+ if (next.theme.appearance !== previous.theme.appearance) {
704
+ // re-theme
705
+ }
706
+ });
707
+ ```
708
+ */
709
+ declare const useCapabilitiesChange: (onChange: (capabilities: Capabilities, previous: Capabilities) => void) => void;
710
+ //#endregion
711
+ //#region src/hooks/use-input.d.ts
712
+ /**
713
+ Handy information about a key that was pressed.
714
+ */
715
+ type Key = {
716
+ /**
717
+ Up arrow key was pressed.
718
+ */
719
+ upArrow: boolean;
720
+ /**
721
+ Down arrow key was pressed.
722
+ */
723
+ downArrow: boolean;
724
+ /**
725
+ Left arrow key was pressed.
726
+ */
727
+ leftArrow: boolean;
728
+ /**
729
+ Right arrow key was pressed.
730
+ */
731
+ rightArrow: boolean;
732
+ /**
733
+ Page Down key was pressed.
734
+ */
735
+ pageDown: boolean;
736
+ /**
737
+ Page Up key was pressed.
738
+ */
739
+ pageUp: boolean;
740
+ /**
741
+ Home key was pressed.
742
+ */
743
+ home: boolean;
744
+ /**
745
+ End key was pressed.
746
+ */
747
+ end: boolean;
748
+ /**
749
+ Return (Enter) key was pressed.
750
+ */
751
+ return: boolean;
752
+ /**
753
+ Escape key was pressed.
754
+ */
755
+ escape: boolean;
756
+ /**
757
+ Ctrl key was pressed.
758
+ */
759
+ ctrl: boolean;
760
+ /**
761
+ Shift key was pressed.
762
+ */
763
+ shift: boolean;
764
+ /**
765
+ Tab key was pressed.
766
+ */
767
+ tab: boolean;
768
+ /**
769
+ Backspace key was pressed.
770
+ */
771
+ backspace: boolean;
772
+ /**
773
+ Delete key was pressed.
774
+ */
775
+ delete: boolean;
776
+ /**
777
+ [Meta key](https://en.wikipedia.org/wiki/Meta_key) was pressed.
778
+ */
779
+ meta: boolean;
780
+ /**
781
+ Super key (Cmd on Mac, Win on Windows) was pressed.
782
+
783
+ Only available with kitty keyboard protocol.
784
+ */
785
+ super: boolean;
786
+ /**
787
+ Hyper key was pressed.
788
+
789
+ Only available with kitty keyboard protocol.
790
+ */
791
+ hyper: boolean;
792
+ /**
793
+ Caps Lock is active.
794
+
795
+ Only available with kitty keyboard protocol.
796
+ */
797
+ capsLock: boolean;
798
+ /**
799
+ Num Lock is active.
800
+
801
+ Only available with kitty keyboard protocol.
802
+ */
803
+ numLock: boolean;
804
+ /**
805
+ Event type for key events.
806
+
807
+ Only available with kitty keyboard protocol.
808
+ */
809
+ eventType?: "press" | "repeat" | "release";
810
+ };
811
+ type Handler = (input: string, key: Key) => void;
812
+ type Options$2 = {
813
+ /**
814
+ Enable or disable capturing of user input. Useful when there are multiple `useInput` hooks used at once to avoid handling the same input several times.
815
+
816
+ @default true
817
+ */
818
+ isActive?: boolean;
819
+ };
820
+ /**
821
+ A React hook that returns `void` and handles user input.
822
+ It's a more convenient alternative to using `StdinContext` and listening for `data` events. The callback you pass to `useInput` is called for each character when the user enters any input. However, if the user pastes text and it's more than one character, the callback will be called only once, and the whole string will be passed as `input`.
823
+
824
+ ```
825
+ import {useInput} from 'ink';
826
+
827
+ const UserInput = () => {
828
+ useInput((input, key) => {
829
+ if (input === 'q') {
830
+ // Exit program
831
+ }
832
+
833
+ if (key.leftArrow) {
834
+ // Left arrow key pressed
835
+ }
836
+ });
837
+
838
+ return …
839
+ };
840
+ ```
841
+ */
842
+ declare const useInput: (inputHandler: Handler, options?: Options$2) => void;
843
+ //#endregion
844
+ //#region src/hooks/use-paste.d.ts
845
+ type Options$1 = {
846
+ /**
847
+ Enable or disable the paste handler. Useful when multiple components use `usePaste` and only one should be active at a time.
848
+
849
+ @default true
850
+ */
851
+ isActive?: boolean;
852
+ };
853
+ /**
854
+ A React hook that calls `handler` whenever the user pastes text in the terminal. Bracketed paste mode (`\x1b[?2004h`) is automatically enabled while the hook is active, so pasted text arrives as a single string rather than being misinterpreted as individual key presses.
855
+
856
+ `usePaste` and `useInput` can be used together in the same component. They operate on separate event channels, so paste content is never forwarded to `useInput` handlers when `usePaste` is active.
857
+
858
+ ```
859
+ import {useInput, usePaste} from 'ink';
860
+
861
+ const MyInput = () => {
862
+ useInput((input, key) => {
863
+ // Only receives typed characters and key events, not pasted text.
864
+ if (key.return) {
865
+ // Submit
866
+ }
867
+ });
868
+
869
+ usePaste((text) => {
870
+ // Receives the full pasted string, including newlines.
871
+ console.log('Pasted:', text);
872
+ });
873
+
874
+ return …
875
+ };
876
+ ```
877
+ */
878
+ declare const usePaste: (handler: (text: string) => void, options?: Options$1) => void;
879
+ //#endregion
880
+ //#region src/hooks/use-app.d.ts
881
+ /**
882
+ A React hook that returns app lifecycle methods like `exit()` and `waitUntilRenderFlush()`.
883
+ */
884
+ declare const useApp: () => Props$1;
885
+ //#endregion
886
+ //#region src/hooks/use-stdin.d.ts
887
+ /**
888
+ A React hook that returns the stdin stream and stdin-related utilities.
889
+ */
890
+ declare const useStdin: () => PublicProps;
891
+ //#endregion
892
+ //#region src/hooks/use-stdout.d.ts
893
+ /**
894
+ A React hook that returns the stdout stream where Ink renders your app.
895
+ */
896
+ declare const useStdout: () => Props$7;
897
+ //#endregion
898
+ //#region src/hooks/use-stderr.d.ts
899
+ /**
900
+ A React hook that returns the stderr stream.
901
+ */
902
+ declare const useStderr: () => Props$6;
903
+ //#endregion
904
+ //#region src/hooks/use-focus.d.ts
905
+ type Input = {
906
+ /**
907
+ Enable or disable this component's focus, while still maintaining its position in the list of focusable components.
908
+ */
909
+ isActive?: boolean;
910
+ /**
911
+ Auto-focus this component if there's no active (focused) component right now.
912
+ */
913
+ autoFocus?: boolean;
914
+ /**
915
+ Assign an ID to this component, so it can be programmatically focused with `focus(id)`.
916
+ */
917
+ id?: string;
918
+ };
919
+ type Output$2 = {
920
+ /**
921
+ Determines whether this component is focused.
922
+ */
923
+ isFocused: boolean;
924
+ /**
925
+ Allows focusing a specific element with the provided `id`.
926
+ */
927
+ focus: (id: string) => void;
928
+ };
929
+ /**
930
+ A React hook that returns focus state and focus controls for the current component.
931
+ A component that uses the `useFocus` hook becomes "focusable" to Ink, so when the user presses <kbd>Tab</kbd>, Ink will switch focus to this component. If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered.
932
+ */
933
+ declare const useFocus: ({ isActive, autoFocus, id: customId }?: Input) => Output$2;
934
+ //#endregion
935
+ //#region src/components/FocusContext.d.ts
936
+ type Props$11 = {
937
+ readonly activeId?: string;
938
+ readonly add: (id: string, options: {
939
+ autoFocus: boolean;
940
+ }) => void;
941
+ readonly remove: (id: string) => void;
942
+ readonly activate: (id: string) => void;
943
+ readonly deactivate: (id: string) => void;
944
+ readonly enableFocus: () => void;
945
+ readonly disableFocus: () => void;
946
+ readonly focusNext: () => void;
947
+ readonly focusPrevious: () => void;
948
+ readonly focus: (id: string) => void;
949
+ };
950
+ //#endregion
951
+ //#region src/hooks/use-focus-manager.d.ts
952
+ type Output$1 = {
953
+ /**
954
+ Enable focus management for all components.
955
+ */
956
+ enableFocus: Props$11["enableFocus"];
957
+ /**
958
+ Disable focus management for all components. The currently active component (if there's one) will lose its focus.
959
+ */
960
+ disableFocus: Props$11["disableFocus"];
961
+ /**
962
+ Switch focus to the next focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the last in the list of focusable components, focus will be switched to the first focusable component.
963
+ */
964
+ focusNext: Props$11["focusNext"];
965
+ /**
966
+ Switch focus to the previous focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the first in the list of focusable components, focus will be switched to the last focusable component.
967
+ */
968
+ focusPrevious: Props$11["focusPrevious"];
969
+ /**
970
+ Switch focus to the element with provided `id`. If there's no element with that `id`, focus is not changed.
971
+ */
972
+ focus: Props$11["focus"];
973
+ /**
974
+ The ID of the currently focused component, or `undefined` if no component is focused.
975
+
976
+ @example
977
+ ```tsx
978
+ import {Text, useFocusManager} from 'ink';
979
+
980
+ const Example = () => {
981
+ const {activeId} = useFocusManager();
982
+
983
+ return <Text>Focused: {activeId ?? 'none'}</Text>;
984
+ };
985
+ ```
986
+ */
987
+ activeId: Props$11["activeId"];
988
+ };
989
+ /**
990
+ A React hook that returns methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
991
+ */
992
+ declare const useFocusManager: () => Output$1;
993
+ //#endregion
994
+ //#region src/hooks/use-is-screen-reader-enabled.d.ts
995
+ /**
996
+ A React hook that returns whether a screen reader is enabled.
997
+ This is useful when you want to render different output for screen readers.
998
+ */
999
+ declare const useIsScreenReaderEnabled: () => boolean;
1000
+ //#endregion
1001
+ //#region src/hooks/use-cursor.d.ts
1002
+ /**
1003
+ A React hook that returns methods to control the terminal cursor position.
1004
+
1005
+ Setting a cursor position makes the cursor visible at the specified coordinates (relative to the Ink output origin). This is useful for IME (Input Method Editor) support, where the composing character is displayed at the cursor location.
1006
+
1007
+ Pass `undefined` to hide the cursor.
1008
+ */
1009
+ declare const useCursor: () => {
1010
+ setCursorPosition: (position: CursorPosition | undefined) => void;
1011
+ };
1012
+ //#endregion
1013
+ //#region src/hooks/use-animation.d.ts
1014
+ type Options = {
1015
+ /**
1016
+ Time between ticks in milliseconds.
1017
+
1018
+ @default 100
1019
+ */
1020
+ readonly interval?: number;
1021
+ /**
1022
+ Whether the animation is running. When set to `false`, the animation stops. When toggled back to `true`, all values reset to `0`.
1023
+
1024
+ @default true
1025
+ */
1026
+ readonly isActive?: boolean;
1027
+ };
1028
+ type AnimationResult = {
1029
+ /**
1030
+ Discrete counter that increments by 1 each interval. Useful for indexed sequences like spinner frames.
1031
+ */
1032
+ readonly frame: number;
1033
+ /**
1034
+ Total elapsed time in milliseconds since the animation started or was last reset. Useful for continuous math-based animations like sine waves: `Math.sin(time / 1000 * Math.PI * 2)`.
1035
+ */
1036
+ readonly time: number;
1037
+ /**
1038
+ Time in milliseconds since the previous rendered tick. Accounts for throttled renders. Useful for physics-based or velocity-driven motion: `position += speed * delta`.
1039
+ */
1040
+ readonly delta: number;
1041
+ /**
1042
+ Resets `frame`, `time`, and `delta` to `0` and restarts timing from the current moment. Useful for one-shot animations triggered by events.
1043
+ */
1044
+ readonly reset: () => void;
1045
+ };
1046
+ /**
1047
+ A React hook that drives animations. Returns a frame counter, elapsed time, frame delta, and a reset function. All animations share a single timer internally, so multiple animated components consolidate into one render cycle.
1048
+
1049
+ @example
1050
+ ```
1051
+ import {Text, useAnimation} from 'ink';
1052
+
1053
+ const Spinner = () => {
1054
+ const {frame} = useAnimation({interval: 80});
1055
+ const characters = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
1056
+
1057
+ return <Text>{characters[frame % characters.length]}</Text>;
1058
+ };
1059
+ ```
1060
+ */
1061
+ declare function useAnimation(options?: Options): AnimationResult;
1062
+ //#endregion
1063
+ //#region src/hooks/use-terminal-osc.d.ts
1064
+ type ProgressOptions = {
1065
+ readonly state: TerminalProgressState;
1066
+ readonly value?: number;
1067
+ };
1068
+ declare const useProgress: ({ state, value }: ProgressOptions) => void;
1069
+ declare const useClipboard: () => ((text: string, selection?: ClipboardSelection) => void);
1070
+ declare const useTitle: (title?: string) => void;
1071
+ declare const useWorkingDirectory: (directory: URL | string) => void;
1072
+ declare const useNotification: () => ((title: string) => void);
1073
+ declare const usePointerShape: (shape: string) => void;
1074
+ //#endregion
1075
+ //#region src/hooks/use-window-size.d.ts
1076
+ /**
1077
+ Dimensions of the terminal window.
1078
+ */
1079
+ type WindowSize = {
1080
+ /**
1081
+ Number of columns (horizontal character cells).
1082
+ */
1083
+ readonly columns: number;
1084
+ /**
1085
+ Number of rows (vertical character cells).
1086
+ */
1087
+ readonly rows: number;
1088
+ };
1089
+ /**
1090
+ A React hook that returns the current terminal window dimensions and re-renders the component whenever the terminal is resized.
1091
+
1092
+ Reads the capabilities store, so on terminals that send in-band size reports
1093
+ (mode 2048) the dimensions are the emulator's own, arriving after it has
1094
+ rewrapped its screen; elsewhere they are the stream's `columns`/`rows`.
1095
+ Subscribing to dimensions does not initiate capability queries. In-band reports
1096
+ are used when another consumer has explicitly enabled capability discovery.
1097
+ */
1098
+ declare const useWindowSize: () => WindowSize;
1099
+ //#endregion
1100
+ //#region src/hooks/use-box-metrics.d.ts
1101
+ /**
1102
+ Metrics of a box element.
1103
+
1104
+ All positions are relative to the element's parent.
1105
+ */
1106
+ type BoxMetrics = {
1107
+ /**
1108
+ Element width.
1109
+ */
1110
+ readonly width: number;
1111
+ /**
1112
+ Element height.
1113
+ */
1114
+ readonly height: number;
1115
+ /**
1116
+ Distance from the left edge of the parent.
1117
+ */
1118
+ readonly left: number;
1119
+ /**
1120
+ Distance from the top edge of the parent.
1121
+ */
1122
+ readonly top: number;
1123
+ };
1124
+ type UseBoxMetricsResult = BoxMetrics & {
1125
+ /**
1126
+ Whether the currently tracked element has been measured in the latest layout pass.
1127
+ */
1128
+ readonly hasMeasured: boolean;
1129
+ };
1130
+ /**
1131
+ A React hook that returns the current layout metrics for a tracked box element.
1132
+ It updates when layout changes (for example terminal resize, sibling/content changes, or position changes).
1133
+
1134
+ The hook returns `{width: 0, height: 0, left: 0, top: 0}` until the first layout pass completes. It also returns zeros when the tracked ref is detached.
1135
+
1136
+ Use `hasMeasured` to detect when the currently tracked element has been measured.
1137
+
1138
+ @example
1139
+ ```tsx
1140
+ import {useRef} from 'react';
1141
+ import {Box, Text, useBoxMetrics} from 'ink';
1142
+
1143
+ const Example = () => {
1144
+ const ref = useRef(null);
1145
+ const {width, height, left, top, hasMeasured} = useBoxMetrics(ref);
1146
+ return (
1147
+ <Box ref={ref}>
1148
+ <Text>
1149
+ {hasMeasured ? `${width}x${height} at ${left},${top}` : 'Measuring...'}
1150
+ </Text>
1151
+ </Box>
1152
+ );
1153
+ };
1154
+ ```
1155
+ */
1156
+ declare const useBoxMetrics: (ref: RefObject<DOMElement | null>) => UseBoxMetricsResult;
1157
+ //#endregion
1158
+ //#region src/virtual-scroll.d.ts
1159
+ /**
1160
+ Windowing math shared by `useVirtualScroll` and `<VirtualList>`.
1161
+
1162
+ Items are stacked vertically and measured in terminal rows. The viewport shows
1163
+ `viewportHeight` rows of that stack starting `scrollTop` rows from the top.
1164
+ */
1165
+ type VirtualScrollOptions = {
1166
+ /**
1167
+ Number of items in the list.
1168
+ */
1169
+ readonly count: number;
1170
+ /**
1171
+ Height of the item at `index` in rows. It must match what the item renders:
1172
+ the window is computed from these numbers, never from the rendered output.
1173
+ */
1174
+ readonly itemHeight: (index: number) => number;
1175
+ /**
1176
+ Rows available to show items.
1177
+ */
1178
+ readonly viewportHeight: number;
1179
+ /**
1180
+ Requested distance of the viewport from the top of the list in rows. It is
1181
+ clamped to the scrollable range and then moved as little as necessary to keep
1182
+ `focusedIndex` fully visible.
1183
+ */
1184
+ readonly scrollTop: number;
1185
+ /**
1186
+ Item that must stay fully visible. An item taller than the viewport is aligned
1187
+ to the top. Out-of-range values are ignored.
1188
+ */
1189
+ readonly focusedIndex?: number;
1190
+ };
1191
+ type VirtualScrollWindow = {
1192
+ /**
1193
+ Index of the first item that intersects the viewport.
1194
+ */
1195
+ readonly start: number;
1196
+ /**
1197
+ Index after the last item that intersects the viewport.
1198
+ */
1199
+ readonly end: number;
1200
+ /**
1201
+ Effective distance of the viewport from the top of the list in rows.
1202
+ */
1203
+ readonly scrollTop: number;
1204
+ /**
1205
+ Largest `scrollTop` that still fills the viewport.
1206
+ */
1207
+ readonly maxScrollTop: number;
1208
+ /**
1209
+ Height of every item combined in rows.
1210
+ */
1211
+ readonly totalHeight: number;
1212
+ /**
1213
+ Position of the `start` item relative to the top of the viewport. Zero or
1214
+ negative: a negative value means the item is partially scrolled out above.
1215
+ */
1216
+ readonly offset: number;
1217
+ /**
1218
+ Rows scrolled out above the viewport.
1219
+ */
1220
+ readonly hiddenAbove: number;
1221
+ /**
1222
+ Rows left below the viewport.
1223
+ */
1224
+ readonly hiddenBelow: number;
1225
+ };
1226
+ //#endregion
1227
+ //#region src/hooks/use-virtual-scroll.d.ts
1228
+ type UseVirtualScrollOptions = Omit<VirtualScrollOptions, "scrollTop">;
1229
+ type UseVirtualScrollResult = VirtualScrollWindow & {
1230
+ /**
1231
+ Scroll so the viewport starts `top` rows from the top of the list.
1232
+ */
1233
+ readonly scrollTo: (top: number) => void;
1234
+ /**
1235
+ Scroll by `delta` rows; negative values scroll up.
1236
+ */
1237
+ readonly scrollBy: (delta: number) => void;
1238
+ };
1239
+ /**
1240
+ A React hook that owns the scroll position of a windowed list and returns which
1241
+ items to render for it. The position is clamped to the scrollable range and,
1242
+ while `focusedIndex` is set, moved as little as necessary to keep that item
1243
+ fully visible. Render the items in `[start, end)` inside an `overflowY="hidden"`
1244
+ box of `viewportHeight` rows, shifted up by `offset` rows.
1245
+
1246
+ `<VirtualList>` wraps this hook; use it directly to draw your own chrome such
1247
+ as overflow markers or a scrollbar around the window.
1248
+
1249
+ @example
1250
+ ```tsx
1251
+ import { Box, Text, useVirtualScroll } from "@alchemy.run/sigil";
1252
+
1253
+ const Example = ({ lines, cursor }: { lines: string[]; cursor: number }) => {
1254
+ const { start, end, offset, hiddenAbove, hiddenBelow } = useVirtualScroll({
1255
+ count: lines.length,
1256
+ itemHeight: () => 1,
1257
+ viewportHeight: 10,
1258
+ focusedIndex: cursor,
1259
+ });
1260
+
1261
+ return (
1262
+ <Box flexDirection="column">
1263
+ <Text dimColor>{hiddenAbove > 0 ? `↑ ${hiddenAbove} more` : ""}</Text>
1264
+ <Box flexDirection="column" height={10} overflowY="hidden">
1265
+ <Box flexDirection="column" flexShrink={0} marginTop={offset}>
1266
+ {lines.slice(start, end).map((line, index) => (
1267
+ <Text key={start + index} inverse={start + index === cursor}>
1268
+ {line}
1269
+ </Text>
1270
+ ))}
1271
+ </Box>
1272
+ </Box>
1273
+ <Text dimColor>{hiddenBelow > 0 ? `↓ ${hiddenBelow} more` : ""}</Text>
1274
+ </Box>
1275
+ );
1276
+ };
1277
+ ```
1278
+ */
1279
+ declare const useVirtualScroll: (options: UseVirtualScrollOptions) => UseVirtualScrollResult;
1280
+ //#endregion
1281
+ //#region src/measure-element.d.ts
1282
+ type Output = {
1283
+ /**
1284
+ Horizontal position (0-based column) within the live layout region.
1285
+ */
1286
+ x: number;
1287
+ /**
1288
+ Vertical position (0-based row) within the live layout region.
1289
+ */
1290
+ y: number;
1291
+ /**
1292
+ Element width.
1293
+ */
1294
+ width: number;
1295
+ /**
1296
+ Element height.
1297
+ */
1298
+ height: number;
1299
+ };
1300
+ /**
1301
+ Measure the layout metrics of a particular `<Box>` element.
1302
+ Returns an object with `x`, `y`, `width`, and `height` properties.
1303
+
1304
+ `x` and `y` are the element's position within the live layout region, computed by walking up the layout tree and accumulating each ancestor's offset. These are layout-tree coordinates, not terminal viewport coordinates. To compare them with mouse events, convert the event coordinates using the live region's viewport position. This is necessary even in alternate-screen mode when output, such as `<Static>` content, appears above the live region.
1305
+
1306
+ Note: `measureElement()` returns `{x: 0, y: 0, width: 0, height: 0}` when called during render (before layout is calculated). Call it from post-render code, such as `useEffect`, `useLayoutEffect`, input handlers, or timer callbacks. When content changes, pass the relevant dependency to your effect so it re-measures after each update.
1307
+ */
1308
+ declare const measureElement: (node: DOMElement) => Output;
1309
+ //#endregion
1310
+ export { type AnimationResult, AnsiText, type Props as AnsiTextProps, type Props$1 as AppProps, Box, type BoxMetrics, type Props$2 as BoxProps, type Capabilities, type CapabilitiesStore, type CapturedOutputSource, type ColorInfo, type ColorSupport, type ColorSupportLevel, type CursorPosition, type DOMElement, type Output as ElementMetrics, Hyperlink, type Props$3 as HyperlinkProps, type Instance, type Key, type KittyFlagName, type KittyKeyboardOptions, type Multiplexer, Newline, type Props$4 as NewlineProps, type PixelGeometry, type PixelSize, type ProgressOptions, type RenderOptions, type RenderToStringOptions, type RgbColor, Spacer, Static, type Props$5 as StaticProps, type Props$6 as StderrProps, type PublicProps as StdinProps, type Props$7 as StdoutProps, type SuspendTerminal, type TerminalAppearance, type TerminalIdentity, type TerminalQueryOptions, type TerminalQueryResult, type TerminalSuspension, Text, type Props$8 as TextProps, Transform, type Props$9 as TransformProps, type UseBoxMetricsResult, type UseVirtualScrollOptions, type UseVirtualScrollResult, VirtualList, type Props$10 as VirtualListProps, type VirtualScrollWindow, type WindowSize, applyTerminalQuery, capabilities, createSupportsColor, detectCapabilities, detectColorLevel, detectHyperlinkSupport, detectTerminal, detectUnicodeSupport, getCapabilities, getTerminalQuery, kittyFlags, kittyModifiers, measureElement, queryTerminal, refreshTerminalQuery, render, renderToString, useAnimation, useApp, useBoxMetrics, useCapabilities, useCapabilitiesChange, useClipboard, useCursor, useFocus, useFocusManager, useInput, useIsScreenReaderEnabled, useNotification, usePaste, usePointerShape, useProgress, useStderr, useStdin, useStdout, useTitle, useVirtualScroll, useWindowSize, useWorkingDirectory };