@visulima/tui 1.0.0-alpha.4 → 1.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE.md +140 -0
  3. package/dist/core/index.d.ts +58 -5
  4. package/dist/ink/index.d.ts +6592 -294
  5. package/dist/ink/index.js +1 -1
  6. package/dist/packem_shared/{Histogram-cgAjY5AJ.js → Histogram-CB6XcmZW.js} +1 -1
  7. package/dist/packem_shared/input.d-Bfq7oc06.d.ts +90 -0
  8. package/dist/packem_shared/render.d-CNIzVQTh.d.ts +1257 -0
  9. package/dist/react/index.d.ts +519 -8
  10. package/dist/testing/index.d.ts +274 -135
  11. package/package.json +15 -16
  12. package/dist/core/app.d.ts +0 -50
  13. package/dist/core/cell.d.ts +0 -33
  14. package/dist/core/inline.d.ts +0 -22
  15. package/dist/core/input.d.ts +0 -18
  16. package/dist/core/native-binding.d.ts +0 -22
  17. package/dist/ink/ansi-to-cell.d.ts +0 -5
  18. package/dist/ink/ansi-tokenizer.d.ts +0 -38
  19. package/dist/ink/canvas/braille.d.ts +0 -22
  20. package/dist/ink/canvas/buffer.d.ts +0 -67
  21. package/dist/ink/clipboard.d.ts +0 -29
  22. package/dist/ink/color-matrix.d.ts +0 -49
  23. package/dist/ink/color-utils.d.ts +0 -30
  24. package/dist/ink/colorize.d.ts +0 -4
  25. package/dist/ink/components/accessibility-context.d.ts +0 -4
  26. package/dist/ink/components/accordion.d.ts +0 -52
  27. package/dist/ink/components/alert.d.ts +0 -30
  28. package/dist/ink/components/animate-presence.d.ts +0 -15
  29. package/dist/ink/components/animation-context.d.ts +0 -10
  30. package/dist/ink/components/app-context.d.ts +0 -38
  31. package/dist/ink/components/app.d.ts +0 -19
  32. package/dist/ink/components/approval-prompt.d.ts +0 -55
  33. package/dist/ink/components/area-chart.d.ts +0 -54
  34. package/dist/ink/components/background-context.d.ts +0 -5
  35. package/dist/ink/components/badge.d.ts +0 -27
  36. package/dist/ink/components/bar-chart.d.ts +0 -57
  37. package/dist/ink/components/big-text.d.ts +0 -71
  38. package/dist/ink/components/blink-dot.d.ts +0 -30
  39. package/dist/ink/components/box.d.ts +0 -58
  40. package/dist/ink/components/breadcrumb.d.ts +0 -28
  41. package/dist/ink/components/button.d.ts +0 -38
  42. package/dist/ink/components/calendar.d.ts +0 -60
  43. package/dist/ink/components/canvas.d.ts +0 -38
  44. package/dist/ink/components/card.d.ts +0 -46
  45. package/dist/ink/components/chart-utils.d.ts +0 -54
  46. package/dist/ink/components/checkbox.d.ts +0 -39
  47. package/dist/ink/components/code.d.ts +0 -46
  48. package/dist/ink/components/collapsible.d.ts +0 -43
  49. package/dist/ink/components/command-block.d.ts +0 -38
  50. package/dist/ink/components/command-palette.d.ts +0 -72
  51. package/dist/ink/components/confirm-dialog.d.ts +0 -63
  52. package/dist/ink/components/confirm-input.d.ts +0 -40
  53. package/dist/ink/components/console-overlay.d.ts +0 -52
  54. package/dist/ink/components/content-switcher.d.ts +0 -49
  55. package/dist/ink/components/cursor-context.d.ts +0 -12
  56. package/dist/ink/components/cursor.d.ts +0 -43
  57. package/dist/ink/components/date-picker.d.ts +0 -53
  58. package/dist/ink/components/definition-list.d.ts +0 -37
  59. package/dist/ink/components/dialog.d.ts +0 -93
  60. package/dist/ink/components/diff-view.d.ts +0 -71
  61. package/dist/ink/components/divider.d.ts +0 -40
  62. package/dist/ink/components/error-boundary.d.ts +0 -17
  63. package/dist/ink/components/error-overview.d.ts +0 -6
  64. package/dist/ink/components/file-picker/file-picker.d.ts +0 -58
  65. package/dist/ink/components/file-picker/types.d.ts +0 -35
  66. package/dist/ink/components/file-picker/use-file-system.d.ts +0 -16
  67. package/dist/ink/components/focus-context.d.ts +0 -17
  68. package/dist/ink/components/form.d.ts +0 -74
  69. package/dist/ink/components/gauge.d.ts +0 -75
  70. package/dist/ink/components/gradient.d.ts +0 -38
  71. package/dist/ink/components/heading.d.ts +0 -27
  72. package/dist/ink/components/heatmap.d.ts +0 -51
  73. package/dist/ink/components/help.d.ts +0 -44
  74. package/dist/ink/components/histogram.d.ts +0 -52
  75. package/dist/ink/components/kbd.d.ts +0 -27
  76. package/dist/ink/components/line-chart.d.ts +0 -94
  77. package/dist/ink/components/link.d.ts +0 -34
  78. package/dist/ink/components/loading-indicator.d.ts +0 -24
  79. package/dist/ink/components/markdown.d.ts +0 -34
  80. package/dist/ink/components/masked-input.d.ts +0 -41
  81. package/dist/ink/components/menu.d.ts +0 -70
  82. package/dist/ink/components/message-bubble.d.ts +0 -35
  83. package/dist/ink/components/model-badge.d.ts +0 -32
  84. package/dist/ink/components/multi-select.d.ts +0 -63
  85. package/dist/ink/components/newline.d.ts +0 -12
  86. package/dist/ink/components/operation-tree.d.ts +0 -46
  87. package/dist/ink/components/option-list.d.ts +0 -41
  88. package/dist/ink/components/ordered-list.d.ts +0 -30
  89. package/dist/ink/components/paginator.d.ts +0 -59
  90. package/dist/ink/components/paragraph.d.ts +0 -31
  91. package/dist/ink/components/placeholder.d.ts +0 -47
  92. package/dist/ink/components/progress-bar.d.ts +0 -51
  93. package/dist/ink/components/radio-group.d.ts +0 -62
  94. package/dist/ink/components/scatter-plot.d.ts +0 -23
  95. package/dist/ink/components/scroll/controlled-scroll-view.d.ts +0 -43
  96. package/dist/ink/components/scroll/index.d.ts +0 -10
  97. package/dist/ink/components/scroll/scroll-bar-box.d.ts +0 -15
  98. package/dist/ink/components/scroll/scroll-bar.d.ts +0 -20
  99. package/dist/ink/components/scroll/scroll-list.d.ts +0 -12
  100. package/dist/ink/components/scroll/scroll-view.d.ts +0 -98
  101. package/dist/ink/components/scroll/use-state-ref.d.ts +0 -8
  102. package/dist/ink/components/search-input.d.ts +0 -46
  103. package/dist/ink/components/select-input-indicator.d.ts +0 -36
  104. package/dist/ink/components/select-input-item.d.ts +0 -43
  105. package/dist/ink/components/select-input.d.ts +0 -96
  106. package/dist/ink/components/shimmer-text.d.ts +0 -39
  107. package/dist/ink/components/slider.d.ts +0 -92
  108. package/dist/ink/components/spacer.d.ts +0 -7
  109. package/dist/ink/components/sparkline.d.ts +0 -30
  110. package/dist/ink/components/spinner.d.ts +0 -40
  111. package/dist/ink/components/static-render.d.ts +0 -40
  112. package/dist/ink/components/static.d.ts +0 -24
  113. package/dist/ink/components/status-line.d.ts +0 -30
  114. package/dist/ink/components/status-message.d.ts +0 -26
  115. package/dist/ink/components/stderr-context.d.ts +0 -16
  116. package/dist/ink/components/stdin-context.d.ts +0 -29
  117. package/dist/ink/components/stdout-context.d.ts +0 -16
  118. package/dist/ink/components/stepper.d.ts +0 -42
  119. package/dist/ink/components/stopwatch.d.ts +0 -42
  120. package/dist/ink/components/streaming-text.d.ts +0 -38
  121. package/dist/ink/components/switch.d.ts +0 -46
  122. package/dist/ink/components/tab.d.ts +0 -25
  123. package/dist/ink/components/table.d.ts +0 -80
  124. package/dist/ink/components/tabs.d.ts +0 -104
  125. package/dist/ink/components/tag.d.ts +0 -30
  126. package/dist/ink/components/text-input.d.ts +0 -48
  127. package/dist/ink/components/text.d.ts +0 -63
  128. package/dist/ink/components/textarea.d.ts +0 -62
  129. package/dist/ink/components/timer.d.ts +0 -50
  130. package/dist/ink/components/toast.d.ts +0 -41
  131. package/dist/ink/components/tooltip.d.ts +0 -36
  132. package/dist/ink/components/transform.d.ts +0 -16
  133. package/dist/ink/components/transition.d.ts +0 -53
  134. package/dist/ink/components/tree-view/theme.d.ts +0 -24
  135. package/dist/ink/components/tree-view/tree-node-map.d.ts +0 -72
  136. package/dist/ink/components/tree-view/tree-view-node.d.ts +0 -29
  137. package/dist/ink/components/tree-view/tree-view.d.ts +0 -89
  138. package/dist/ink/components/tree-view/types.d.ts +0 -55
  139. package/dist/ink/components/tree-view/use-tree-view-state.d.ts +0 -135
  140. package/dist/ink/components/tree-view/use-tree-view.d.ts +0 -26
  141. package/dist/ink/components/unordered-list.d.ts +0 -35
  142. package/dist/ink/components/variant-config.d.ts +0 -10
  143. package/dist/ink/cursor-helpers.d.ts +0 -35
  144. package/dist/ink/data-limited-lru-map.d.ts +0 -21
  145. package/dist/ink/devtools-window-polyfill.d.ts +0 -1
  146. package/dist/ink/devtools.d.ts +0 -1
  147. package/dist/ink/dom.d.ts +0 -214
  148. package/dist/ink/get-max-width.d.ts +0 -3
  149. package/dist/ink/highlighter.d.ts +0 -28
  150. package/dist/ink/hooks/use-animation.d.ts +0 -41
  151. package/dist/ink/hooks/use-app.d.ts +0 -6
  152. package/dist/ink/hooks/use-box-metrics.d.ts +0 -58
  153. package/dist/ink/hooks/use-clipboard.d.ts +0 -29
  154. package/dist/ink/hooks/use-color-blindness.d.ts +0 -33
  155. package/dist/ink/hooks/use-console-capture.d.ts +0 -43
  156. package/dist/ink/hooks/use-cursor.d.ts +0 -12
  157. package/dist/ink/hooks/use-focus-manager.d.ts +0 -42
  158. package/dist/ink/hooks/use-focus.d.ts +0 -30
  159. package/dist/ink/hooks/use-form.d.ts +0 -70
  160. package/dist/ink/hooks/use-hotkey.d.ts +0 -37
  161. package/dist/ink/hooks/use-input.d.ts +0 -149
  162. package/dist/ink/hooks/use-interval.d.ts +0 -25
  163. package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +0 -6
  164. package/dist/ink/hooks/use-key-bindings.d.ts +0 -59
  165. package/dist/ink/hooks/use-key-chord.d.ts +0 -26
  166. package/dist/ink/hooks/use-linked-scroll.d.ts +0 -41
  167. package/dist/ink/hooks/use-paste.d.ts +0 -44
  168. package/dist/ink/hooks/use-persistent-state.d.ts +0 -56
  169. package/dist/ink/hooks/use-scroll-acceleration.d.ts +0 -47
  170. package/dist/ink/hooks/use-scroll-input.d.ts +0 -34
  171. package/dist/ink/hooks/use-stderr.d.ts +0 -6
  172. package/dist/ink/hooks/use-stdin.d.ts +0 -7
  173. package/dist/ink/hooks/use-stdout.d.ts +0 -6
  174. package/dist/ink/hooks/use-stopwatch.d.ts +0 -38
  175. package/dist/ink/hooks/use-terminal-palette.d.ts +0 -19
  176. package/dist/ink/hooks/use-text-buffer.d.ts +0 -42
  177. package/dist/ink/hooks/use-text-selection.d.ts +0 -45
  178. package/dist/ink/hooks/use-timeout.d.ts +0 -24
  179. package/dist/ink/hooks/use-timer.d.ts +0 -47
  180. package/dist/ink/hooks/use-window-size.d.ts +0 -18
  181. package/dist/ink/ime-utils.d.ts +0 -25
  182. package/dist/ink/ink.d.ts +0 -190
  183. package/dist/ink/input-parser.d.ts +0 -10
  184. package/dist/ink/input-utils.d.ts +0 -16
  185. package/dist/ink/instances.d.ts +0 -3
  186. package/dist/ink/kitty-keyboard.d.ts +0 -23
  187. package/dist/ink/layout.d.ts +0 -26
  188. package/dist/ink/log-update-native.d.ts +0 -14
  189. package/dist/ink/log-update.d.ts +0 -21
  190. package/dist/ink/measure-element.d.ts +0 -147
  191. package/dist/ink/measure-text.d.ts +0 -56
  192. package/dist/ink/mouse/ansi-parser.d.ts +0 -37
  193. package/dist/ink/mouse/constants.d.ts +0 -14
  194. package/dist/ink/mouse/fullscreen.d.ts +0 -8
  195. package/dist/ink/mouse/index.d.ts +0 -20
  196. package/dist/ink/mouse/is-intersecting.d.ts +0 -18
  197. package/dist/ink/mouse/mouse-context.d.ts +0 -36
  198. package/dist/ink/mouse/mouse-provider.d.ts +0 -11
  199. package/dist/ink/mouse/use-element-position.d.ts +0 -29
  200. package/dist/ink/mouse/use-mouse-action.d.ts +0 -7
  201. package/dist/ink/mouse/use-mouse-position.d.ts +0 -7
  202. package/dist/ink/mouse/use-mouse.d.ts +0 -7
  203. package/dist/ink/mouse/use-on-mouse-click.d.ts +0 -14
  204. package/dist/ink/mouse/use-on-mouse-hover.d.ts +0 -8
  205. package/dist/ink/mouse/use-on-mouse-state.d.ts +0 -11
  206. package/dist/ink/output.d.ts +0 -75
  207. package/dist/ink/parse-keypress.d.ts +0 -22
  208. package/dist/ink/reconciler.d.ts +0 -3
  209. package/dist/ink/region.d.ts +0 -99
  210. package/dist/ink/render-background.d.ts +0 -4
  211. package/dist/ink/render-border.d.ts +0 -4
  212. package/dist/ink/render-node-to-output.d.ts +0 -38
  213. package/dist/ink/render-scrollbar.d.ts +0 -9
  214. package/dist/ink/render-sticky.d.ts +0 -44
  215. package/dist/ink/render-to-string.d.ts +0 -37
  216. package/dist/ink/render.d.ts +0 -191
  217. package/dist/ink/renderer.d.ts +0 -17
  218. package/dist/ink/resize-observer.d.ts +0 -44
  219. package/dist/ink/sanitize-ansi.d.ts +0 -2
  220. package/dist/ink/scroll.d.ts +0 -23
  221. package/dist/ink/selection.d.ts +0 -70
  222. package/dist/ink/squash-text-nodes.d.ts +0 -18
  223. package/dist/ink/style-flags.d.ts +0 -17
  224. package/dist/ink/styled-line-factory.d.ts +0 -25
  225. package/dist/ink/styled-line-serializer.d.ts +0 -18
  226. package/dist/ink/styled-line.d.ts +0 -119
  227. package/dist/ink/styles.d.ts +0 -369
  228. package/dist/ink/terminal-palette.d.ts +0 -25
  229. package/dist/ink/text-wrap.d.ts +0 -10
  230. package/dist/ink/token-to-elements.d.ts +0 -22
  231. package/dist/ink/utils/format-time.d.ts +0 -4
  232. package/dist/ink/utils.d.ts +0 -9
  233. package/dist/ink/wrap-text.d.ts +0 -3
  234. package/dist/ink/write-synchronized.d.ts +0 -4
  235. package/dist/react/devtools.d.ts +0 -27
  236. package/dist/react/focus.d.ts +0 -39
  237. package/dist/react/hooks.d.ts +0 -238
  238. package/dist/react/layout.d.ts +0 -33
  239. package/dist/react/react.d.ts +0 -57
  240. package/dist/react/reconciler.d.ts +0 -4
  241. package/dist/react/render-to-string.d.ts +0 -21
  242. package/dist/react/renderer.d.ts +0 -2
  243. package/dist/react/scene.d.ts +0 -3
  244. package/dist/react/static.d.ts +0 -39
  245. package/dist/react/styles.d.ts +0 -83
  246. package/dist/react/text-width.d.ts +0 -20
  247. package/dist/testing/keys.d.ts +0 -89
  248. package/dist/testing/screen.d.ts +0 -35
  249. package/dist/testing/wait-for.d.ts +0 -20
@@ -1,26 +0,0 @@
1
- import type { AsyncChildrenFunction, SelectionMode } from "./types.d.ts";
2
- import type { TreeViewState } from "./use-tree-view-state.d.ts";
3
- export type UseTreeViewProps<T = Record<string, unknown>> = {
4
- /**
5
- * When disabled, user input is ignored.
6
- * @default false
7
- */
8
- readonly isDisabled?: boolean;
9
- /**
10
- * Async function to load children on demand.
11
- */
12
- readonly loadChildren?: AsyncChildrenFunction<T>;
13
- /**
14
- * Called when `loadChildren` rejects.
15
- */
16
- readonly onLoadError?: (nodeId: string, error: Error) => void;
17
- /**
18
- * Selection mode.
19
- */
20
- readonly selectionMode: SelectionMode;
21
- /**
22
- * The tree view state from `useTreeViewState`.
23
- */
24
- readonly state: TreeViewState<T>;
25
- };
26
- export declare function useTreeView<T>({ isDisabled, loadChildren, onLoadError, selectionMode, state }: UseTreeViewProps<T>): void;
@@ -1,35 +0,0 @@
1
- /**
2
- * Unordered list component for Ink.
3
- *
4
- * Inspired by ink-ui UnorderedList by Vadim Demedes.
5
- * @see https://github.com/vadimdemedes/ink-ui
6
- *
7
- * MIT License
8
- * Copyright (c) Vadym Demedes (github.com/vadimdemedes)
9
- */
10
- import type { ReactElement, ReactNode } from "react";
11
- export type UnorderedListEntry = {
12
- /**
13
- * Content of the list entry. Can be a string or nested list.
14
- */
15
- readonly children?: ReadonlyArray<UnorderedListEntry>;
16
- /**
17
- * Display text for this item.
18
- */
19
- readonly label: ReactNode;
20
- };
21
- export type Props = {
22
- /**
23
- * Entries to render as a bullet list.
24
- */
25
- readonly items: ReadonlyArray<UnorderedListEntry>;
26
- /**
27
- * Custom bullet symbol(s). A string uses the same symbol at all depths.
28
- * An array cycles through symbols by nesting depth.
29
- */
30
- readonly marker?: ReadonlyArray<string> | string;
31
- };
32
- /**
33
- * Renders a bullet list with nesting support.
34
- */
35
- export default function UnorderedList({ items, marker }: Props): ReactElement;
@@ -1,10 +0,0 @@
1
- /**
2
- * Shared variant configuration for Alert and StatusMessage components.
3
- */
4
- type VariantConfig = {
5
- readonly color: string;
6
- readonly icon: string;
7
- };
8
- export type Variant = "error" | "info" | "success" | "warning";
9
- declare const VARIANT_CONFIG: Record<Variant, VariantConfig>;
10
- export default VARIANT_CONFIG;
@@ -1,35 +0,0 @@
1
- export type CursorPosition = {
2
- x: number;
3
- y: number;
4
- };
5
- /**
6
- * Compare two cursor positions. Returns true if they differ.
7
- */
8
- export declare const cursorPositionChanged: (a: CursorPosition | undefined, b: CursorPosition | undefined) => boolean;
9
- /**
10
- * Build escape sequence to move cursor from bottom of output to the target position and show it.
11
- * Assumes cursor is at (col 0, line visibleLineCount) — i.e. just after the last output line.
12
- */
13
- export declare const buildCursorSuffix: (visibleLineCount: number, cursorPosition: CursorPosition | undefined) => string;
14
- /**
15
- * Build escape sequence to move cursor from previousCursorPosition back to the bottom of output.
16
- * This must be done before eraseLines or any operation that assumes cursor is at the bottom.
17
- */
18
- export declare const buildReturnToBottom: (previousLineCount: number, previousCursorPosition: CursorPosition | undefined) => string;
19
- export type CursorOnlyInput = {
20
- cursorPosition: CursorPosition | undefined;
21
- cursorWasShown: boolean;
22
- previousCursorPosition: CursorPosition | undefined;
23
- previousLineCount: number;
24
- visibleLineCount: number;
25
- };
26
- /**
27
- * Build the escape sequence for cursor-only updates (output unchanged, cursor moved).
28
- * Hides cursor if it was previously shown, returns to bottom, then repositions.
29
- */
30
- export declare const buildCursorOnlySequence: (input: CursorOnlyInput) => string;
31
- /**
32
- * Build the prefix that hides cursor and returns to bottom before erasing or rewriting.
33
- * Returns empty string if cursor was not shown.
34
- */
35
- export declare const buildReturnToBottomPrefix: (cursorWasShown: boolean, previousLineCount: number, previousCursorPosition: CursorPosition | undefined) => string;
@@ -1,21 +0,0 @@
1
- /**
2
- * A specialized LRU map that enforces limits on both the number of entries and
3
- * the total character length of the keys.
4
- *
5
- * When adding a new item, if the new key's length would exceed `maxDataSize`,
6
- * it evicts the least recently used items until space is available.
7
- *
8
- * Ported from jacob314/ink fork (Google LLC, Apache-2.0).
9
- */
10
- declare class DataLimitedLruMap<V> {
11
- private readonly map;
12
- private readonly maxDataSize;
13
- private readonly maxKeys;
14
- private currentDataSize;
15
- constructor(maxKeys: number, maxDataSize: number);
16
- get size(): number;
17
- clear(): void;
18
- get(key: string): V | undefined;
19
- set(key: string, value: V): void;
20
- }
21
- export default DataLimitedLruMap;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import "./devtools-window-polyfill";
package/dist/ink/dom.d.ts DELETED
@@ -1,214 +0,0 @@
1
- import type { Node as YogaNode } from "yoga-layout";
2
- import type { Region } from "./region.d.ts";
3
- import type { OutputTransformer } from "./render-node-to-output.d.ts";
4
- import type ResizeObserver from "./resize-observer.d.ts";
5
- import type { ScrollState } from "./scroll.d.ts";
6
- import type { StyledLine } from "./styled-line.d.ts";
7
- import type { Styles } from "./styles.d.ts";
8
- type InkNode = {
9
- internal_static?: boolean;
10
- parentNode: DOMElement | undefined;
11
- style: Styles;
12
- yogaNode?: YogaNode;
13
- };
14
- type LayoutListener = () => void;
15
- export type TextName = "#text";
16
- export type ElementNames = "ink-root" | "ink-box" | "ink-text" | "ink-cursor" | "ink-virtual-text" | "ink-static-render";
17
- /**
18
- * Describes a sticky header that should be composited on top of scrolled content.
19
- * Ported from jacob314/ink fork (Google LLC, Apache-2.0).
20
- */
21
- export type StickyHeader = {
22
- /** Content-relative end row. */
23
- endRow: number;
24
- /** Height in rows. */
25
- height?: number;
26
- /** If true, natural 'lines' are already in background content. */
27
- isStuckOnly: boolean;
28
- /** Lines rendered in the natural (scrolling) position. */
29
- lines: ReadonlyArray<StyledLine>;
30
- /** Natural row offset relative to content start. */
31
- naturalRow: number;
32
- /** Reference to the DOM node for this header. */
33
- node?: DOMElement;
34
- /** Unique ID of the sticky node. */
35
- nodeId: number;
36
- /** ID of the scroll container this header belongs to. */
37
- scrollContainerId: number | string;
38
- /** Content-relative start row. */
39
- startRow: number;
40
- /** Lines rendered in the stuck (pinned) position, if different. */
41
- stuckLines?: ReadonlyArray<StyledLine>;
42
- /** Sticky type: top-pinned or bottom-pinned. */
43
- type?: "top" | "bottom";
44
- /** Stuck X position relative to region. */
45
- x: number;
46
- /** Stuck Y position relative to region. */
47
- y: number;
48
- };
49
- export type NodeNames = ElementNames | TextName;
50
- export type CursorAnchorRef = {
51
- readonly current: DOMElement | undefined | null;
52
- };
53
- export type CursorMarker = {
54
- anchorRef?: CursorAnchorRef;
55
- inline?: boolean;
56
- x: number;
57
- y: number;
58
- };
59
- export type DOMElement = InkNode & {
60
- attributes: Record<string, DOMNodeAttribute>;
61
- /**
62
- * Cached render result (a Region). When set, the entire subtree is
63
- * skipped during rendering and the cached region is composited directly.
64
- * Set by setCachedRender(), cleared on unmount by cleanupNodeTree().
65
- */
66
- cachedRender?: Region;
67
- childNodes: DOMNode[];
68
- internal_accessibility?: {
69
- role?: "button" | "checkbox" | "combobox" | "list" | "listbox" | "listitem" | "menu" | "menuitem" | "option" | "progressbar" | "radio" | "radiogroup" | "tab" | "tablist" | "table" | "textbox" | "timer" | "toolbar";
70
- state?: {
71
- busy?: boolean;
72
- checked?: boolean;
73
- disabled?: boolean;
74
- expanded?: boolean;
75
- multiline?: boolean;
76
- multiselectable?: boolean;
77
- readonly?: boolean;
78
- required?: boolean;
79
- selected?: boolean;
80
- };
81
- };
82
- internal_cursor?: CursorMarker;
83
- internal_hidden?: boolean;
84
- /**
85
- * Auto-incrementing unique identifier for this node.
86
- */
87
- internal_id: number;
88
- /**
89
- * Whether this element's scrollback buffer is dirty (needs recalculation).
90
- */
91
- internal_isScrollbackDirty?: boolean;
92
- /**
93
- * Last measured size for ResizeObserver tracking.
94
- */
95
- internal_lastMeasuredSize?: {
96
- height: number;
97
- width: number;
98
- };
99
- internal_layoutListeners?: Set<LayoutListener>;
100
- /**
101
- * Maximum scrollTop ever reached, used with stableScrollback.
102
- */
103
- internal_maxScrollTop?: number;
104
- /**
105
- * Callback invoked after prepareYogaTree() caches the render output for
106
- * an ink-static-render node. StaticRender uses this to set `isRendered`
107
- * state, which prevents React from re-reconciling children once cached.
108
- */
109
- internal_onRendered?: () => void;
110
- /**
111
- * Whether this element is opaque (prevents rendering of covered content beneath it).
112
- */
113
- internal_opaque?: boolean;
114
- /**
115
- * Whether the scrollbar should be rendered for this scrollable element.
116
- * Defaults to true for elements with overflow: 'scroll'.
117
- */
118
- internal_scrollbar?: boolean;
119
- /**
120
- * Scroll state computed by calculateScroll() for elements with overflow: 'scroll'.
121
- */
122
- internal_scrollState?: ScrollState;
123
- /**
124
- * Whether this element is sticky (pinned during scroll).
125
- * - `true` or `'top'`: pinned to the top of the scroll container
126
- * - `'bottom'`: pinned to the bottom of the scroll container
127
- */
128
- internal_sticky?: boolean | "top" | "bottom";
129
- /**
130
- * Whether this element is the alternate (stuck) version of a sticky header.
131
- * The stuck version is rendered when the header is pinned.
132
- */
133
- internal_stickyAlternate?: boolean;
134
- /**
135
- * Whether this element should receive the terminal cursor focus.
136
- */
137
- internal_terminalCursorFocus?: boolean;
138
- /**
139
- * Terminal cursor position offset within this element.
140
- */
141
- internal_terminalCursorPosition?: number;
142
- /**
143
- * Cached text squash result for this node's subtree.
144
- * Invalidated by markNodeAsDirty() when children change.
145
- */
146
- internal_textCache?: {
147
- map: Map<DOMNode, {
148
- end: number;
149
- start: number;
150
- }>;
151
- text: string;
152
- };
153
- internal_transform?: OutputTransformer;
154
- isStaticDirty?: boolean;
155
- /**
156
- * Whether the Yoga subtree has been detached (children removed from Yoga layout)
157
- * because a cachedRender was set. When cachedRender is invalidated,
158
- * prepareYogaTree() re-attaches the children before the next layout pass.
159
- */
160
- isYogaTreeDetached?: boolean;
161
- nodeName: ElementNames;
162
- onComputeLayout?: () => void;
163
- onImmediateRender?: () => void;
164
- onRender?: () => void;
165
- /**
166
- * Set of ResizeObservers attached to this element.
167
- */
168
- resizeObservers?: Set<ResizeObserver>;
169
- staticNode?: DOMElement;
170
- };
171
- export type TextNode = InkNode & {
172
- nodeName: TextName;
173
- nodeValue: string;
174
- };
175
- export type DOMNode<T = {
176
- nodeName: NodeNames;
177
- }> = T extends {
178
- nodeName: infer U;
179
- } ? U extends "#text" ? TextNode : DOMElement : never;
180
- export type DOMNodeAttribute = boolean | string | number;
181
- export declare const createNode: (nodeName: ElementNames) => DOMElement;
182
- export declare const appendChildNode: (node: DOMElement, childNode: DOMElement) => void;
183
- export declare const insertBeforeNode: (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode) => void;
184
- export declare const removeChildNode: (node: DOMElement, removeNode: DOMNode) => void;
185
- export declare const setAttribute: (node: DOMElement, key: string, value: DOMNodeAttribute) => void;
186
- export declare const setStyle: (node: DOMNode, style?: Styles) => void;
187
- export declare const createTextNode: (text: string) => TextNode;
188
- export declare const markNodeAsDirty: (node?: DOMNode) => void;
189
- export declare const setTextNodeValue: (node: TextNode, text: string) => void;
190
- export declare const addLayoutListener: (rootNode: DOMElement, listener: LayoutListener) => () => void;
191
- export declare const emitLayoutListeners: (rootNode: DOMElement) => void;
192
- /**
193
- * Store a cached render result on a DOM node. Fixes the Yoga node
194
- * dimensions to match the cached region and removes all Yoga children
195
- * (since rendering is cached, child layout is no longer needed).
196
- *
197
- * Ported from jacob314/ink (Google LLC, Apache-2.0).
198
- */
199
- export declare const setCachedRender: (node: DOMElement, cachedRender: Region) => void;
200
- /**
201
- * Get the path from the root to this node (inclusive).
202
- * Returns an array starting with the root and ending with the node.
203
- *
204
- * Ported from jacob314/ink fork (Google LLC, Apache-2.0).
205
- */
206
- export declare const getPathToRoot: (node: DOMNode) => DOMNode[];
207
- /**
208
- * Check if a node is selectable by walking up the tree checking `userSelect` style.
209
- * Returns true by default unless an ancestor has `userSelect: 'none'`.
210
- *
211
- * Ported from jacob314/ink fork (Google LLC, Apache-2.0).
212
- */
213
- export declare const isNodeSelectable: (node: DOMElement) => boolean;
214
- export {};
@@ -1,3 +0,0 @@
1
- import type { Node as YogaNode } from "yoga-layout";
2
- declare const getMaxWidth: (yogaNode: YogaNode) => number;
3
- export default getMaxWidth;
@@ -1,28 +0,0 @@
1
- /**
2
- * Singleton Shiki highlighter for terminal syntax highlighting.
3
- *
4
- * Uses codeToTokens() to produce ThemedToken[][] which are mapped
5
- * to Ink React elements by token-to-elements.tsx.
6
- */
7
- import type { Highlighter, TokensResult } from "shiki";
8
- /**
9
- * Get cached tokens or compute and cache them.
10
- */
11
- export declare const getCachedTokens: (highlighter: Highlighter, code: string, lang: string, theme: string) => TokensResult;
12
- /**
13
- * Resolve a language name to a canonical name, handling aliases.
14
- */
15
- export declare const resolveLanguage: (lang: string) => string;
16
- /**
17
- * Check if a language is supported.
18
- */
19
- export declare const isLanguageSupported: (lang: string) => boolean;
20
- /**
21
- * Get or create the singleton Shiki highlighter, optionally loading languages and themes.
22
- */
23
- declare const getHighlighter: (languages?: string[], theme?: string) => Promise<Highlighter>;
24
- /**
25
- * Dispose the singleton highlighter, freeing resources.
26
- */
27
- export declare const disposeHighlighter: () => void;
28
- export default getHighlighter;
@@ -1,41 +0,0 @@
1
- type Options = {
2
- /**
3
- * Time between ticks in milliseconds.
4
- * @default 100
5
- */
6
- readonly interval?: number;
7
- /**
8
- * Whether the animation is running. When set to `false`, the animation stops.
9
- * When toggled back to `true`, all values reset to `0`.
10
- * @default true
11
- */
12
- readonly isActive?: boolean;
13
- };
14
- export type AnimationResult = {
15
- /**
16
- * Time in milliseconds since the previous rendered tick. Accounts for throttled renders.
17
- * Useful for physics-based or velocity-driven motion: `position += speed * delta`.
18
- */
19
- readonly delta: number;
20
- /**
21
- * Discrete counter that increments by 1 each interval.
22
- * Useful for indexed sequences like spinner frames.
23
- */
24
- readonly frame: number;
25
- /**
26
- * Resets `frame`, `time`, and `delta` to `0` and restarts timing from the current moment.
27
- * Useful for one-shot animations triggered by events.
28
- */
29
- readonly reset: () => void;
30
- /**
31
- * Total elapsed time in milliseconds since the animation started or was last reset.
32
- * Useful for continuous math-based animations like sine waves: `Math.sin(time / 1000 * Math.PI * 2)`.
33
- */
34
- readonly time: number;
35
- };
36
- /**
37
- * A React hook that drives animations. Returns a frame counter, elapsed time, frame delta, and a reset function.
38
- * All animations share a single timer internally, so multiple animated components consolidate into one render cycle.
39
- */
40
- export default function useAnimation(options?: Options): AnimationResult;
41
- export {};
@@ -1,6 +0,0 @@
1
- import type { Props } from "../components/app-context.d.ts";
2
- /**
3
- * A React hook that returns app lifecycle methods like `exit()` and `waitUntilRenderFlush()`.
4
- */
5
- declare const useApp: () => Props;
6
- export default useApp;
@@ -1,58 +0,0 @@
1
- import type { RefObject } from "react";
2
- import type { DOMElement } from '../dom.d.ts';
3
- /**
4
- * Metrics of a box element.
5
- *
6
- * All positions are relative to the element's parent.
7
- */
8
- export type BoxMetrics = {
9
- /**
10
- * Element height.
11
- */
12
- readonly height: number;
13
- /**
14
- * Distance from the left edge of the parent.
15
- */
16
- readonly left: number;
17
- /**
18
- * Distance from the top edge of the parent.
19
- */
20
- readonly top: number;
21
- /**
22
- * Element width.
23
- */
24
- readonly width: number;
25
- };
26
- export type UseBoxMetricsResult = BoxMetrics & {
27
- /**
28
- * Whether the currently tracked element has been measured in the latest layout pass.
29
- */
30
- readonly hasMeasured: boolean;
31
- };
32
- /**
33
- * A React hook that returns the current layout metrics for a tracked box element.
34
- * It updates when layout changes (for example terminal resize, sibling/content changes, or position changes).
35
- *
36
- * 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.
37
- *
38
- * Use `hasMeasured` to detect when the currently tracked element has been measured.
39
- * @example
40
- * ```tsx
41
- import {useRef} from 'react';
42
- import {Box, Text, useBoxMetrics} from 'ink';
43
-
44
- const Example = () => {
45
- const ref = useRef(null);
46
- const {width, height, left, top, hasMeasured} = useBoxMetrics(ref);
47
- return (
48
- <Box ref={ref}>
49
- <Text>
50
- {hasMeasured ? `${width}x${height} at ${left},${top}` : 'Measuring...'}
51
- </Text>
52
- </Box>
53
- );
54
- };
55
- ```
56
- */
57
- declare const useBoxMetrics: (ref: RefObject<DOMElement>) => UseBoxMetricsResult;
58
- export default useBoxMetrics;
@@ -1,29 +0,0 @@
1
- import type { ClipboardTarget } from "../clipboard.d.ts";
2
- export type UseClipboardOptions = {
3
- /**
4
- * The clipboard target to write to.
5
- * @default "c"
6
- */
7
- readonly target?: ClipboardTarget;
8
- };
9
- export type UseClipboardResult = {
10
- /**
11
- * Copy text to the system clipboard.
12
- * No-op if the terminal does not support OSC 52.
13
- */
14
- readonly copy: (text: string) => void;
15
- /**
16
- * Whether the current terminal supports OSC 52 clipboard operations.
17
- */
18
- readonly isSupported: boolean;
19
- };
20
- /**
21
- * Hook that provides clipboard write access via OSC 52.
22
- *
23
- * ```tsx
24
- * const { copy, isSupported } = useClipboard();
25
- * copy("Hello, clipboard!");
26
- * ```
27
- */
28
- declare const useClipboard: (options?: UseClipboardOptions) => UseClipboardResult;
29
- export default useClipboard;
@@ -1,33 +0,0 @@
1
- import type { ColorBlindnessType, ColorMatrix } from "../color-matrix.d.ts";
2
- export type UseColorBlindnessOptions = {
3
- /**
4
- * Use compensation mode (shift colors to distinguishable range)
5
- * instead of simulation mode (show how colors appear to affected users).
6
- * Not available for achromatopsia.
7
- * @default false
8
- */
9
- readonly compensate?: boolean;
10
- /**
11
- * Type of color vision deficiency to simulate or compensate for.
12
- * @default "none"
13
- */
14
- readonly mode?: ColorBlindnessType | "none";
15
- };
16
- export type UseColorBlindnessResult = {
17
- /** Whether a transform is active (mode is not "none"). */
18
- readonly isActive: boolean;
19
- /** The active color matrix. */
20
- readonly matrix: ColorMatrix;
21
- /** Transform a hex color string through the active matrix. */
22
- readonly transformColor: (hex: string) => string;
23
- };
24
- /**
25
- * Hook for color blindness simulation and compensation.
26
- *
27
- * ```tsx
28
- * const { transformColor } = useColorBlindness({ mode: "deuteranopia" });
29
- * &lt;Text color={transformColor("#ff0000")}>This text&lt;/Text>
30
- * ```
31
- */
32
- declare const useColorBlindness: (options?: UseColorBlindnessOptions) => UseColorBlindnessResult;
33
- export default useColorBlindness;
@@ -1,43 +0,0 @@
1
- export type ConsoleLevel = "debug" | "error" | "info" | "log" | "warn";
2
- export type ConsoleEntry = {
3
- readonly id: number;
4
- readonly level: ConsoleLevel;
5
- readonly message: string;
6
- readonly timestamp: number;
7
- };
8
- export type UseConsoleCaptureOptions = {
9
- /**
10
- * Which console levels to capture.
11
- * @default ["log", "info", "warn", "error", "debug"]
12
- */
13
- readonly filter?: ReadonlyArray<ConsoleLevel>;
14
- /**
15
- * Enable or disable capture.
16
- * @default true
17
- */
18
- readonly isActive?: boolean;
19
- /**
20
- * Maximum number of entries to keep in the buffer.
21
- * @default 200
22
- */
23
- readonly maxEntries?: number;
24
- };
25
- export type UseConsoleCaptureResult = {
26
- /** Clear all captured entries. */
27
- readonly clear: () => void;
28
- /** Captured console entries (newest last). */
29
- readonly entries: ReadonlyArray<ConsoleEntry>;
30
- };
31
- /**
32
- * Hook that captures console output into a React state buffer.
33
- *
34
- * **Note:** Only one active `useConsoleCapture` instance should exist at a time.
35
- * The `ConsoleOverlay` component uses this hook internally — do not use both
36
- * simultaneously unless the hook instance has `isActive: false`.
37
- *
38
- * ```tsx
39
- * const { entries, clear } = useConsoleCapture({ maxEntries: 100 });
40
- * ```
41
- */
42
- declare const useConsoleCapture: (options?: UseConsoleCaptureOptions) => UseConsoleCaptureResult;
43
- export default useConsoleCapture;
@@ -1,12 +0,0 @@
1
- import type { CursorPosition } from "../log-update.d.ts";
2
- /**
3
- * A React hook that returns methods to control the terminal cursor position.
4
- *
5
- * 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.
6
- *
7
- * Pass `undefined` to hide the cursor.
8
- */
9
- declare const useCursor: () => {
10
- setCursorPosition: (position: CursorPosition | undefined) => void;
11
- };
12
- export default useCursor;
@@ -1,42 +0,0 @@
1
- import type { Props } from '../components/focus-context.d.ts';
2
- type Output = {
3
- /**
4
- * The ID of the currently focused component, or `undefined` if no component is focused.
5
- * @example
6
- * ```tsx
7
- * import {Text, useFocusManager} from 'ink';
8
- *
9
- * const Example = () => {
10
- * const {activeId} = useFocusManager();
11
- *
12
- * return <Text>Focused: {activeId ?? 'none'}</Text>;
13
- * };
14
- * ```
15
- */
16
- activeId: Props["activeId"];
17
- /**
18
- * Disable focus management for all components. The currently active component (if there's one) will lose its focus.
19
- */
20
- disableFocus: Props["disableFocus"];
21
- /**
22
- * Enable focus management for all components.
23
- */
24
- enableFocus: Props["enableFocus"];
25
- /**
26
- * Switch focus to the element with provided `id`. If there's no element with that `id`, focus is not changed.
27
- */
28
- focus: Props["focus"];
29
- /**
30
- * 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.
31
- */
32
- focusNext: Props["focusNext"];
33
- /**
34
- * 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.
35
- */
36
- focusPrevious: Props["focusPrevious"];
37
- };
38
- /**
39
- * 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.
40
- */
41
- declare const useFocusManager: () => Output;
42
- export default useFocusManager;