@visulima/tui 1.0.8 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/LICENSE.md +54 -2444
- package/MIGRATION-GUIDE.md +164 -0
- package/README.md +15 -12
- package/dist/components/box.d.ts +26 -27
- package/dist/components/canvas.d.ts +26 -31
- package/dist/components/canvas.js +1 -1
- package/dist/components/cursor.d.ts +40 -46
- package/dist/components/error-boundary.d.ts +16 -0
- package/dist/components/error-boundary.js +1 -0
- package/dist/components/error-overview.d.ts +6 -0
- package/dist/components/error-overview.js +1 -0
- package/dist/components/newline.d.ts +6 -8
- package/dist/components/spacer.d.ts +4 -4
- package/dist/components/static-render.d.ts +10 -42
- package/dist/components/static.d.ts +13 -14
- package/dist/components/text.d.ts +34 -48
- package/dist/components/transform.d.ts +7 -11
- package/dist/core/index.d.ts +11 -12
- package/dist/core/index.js +1 -1
- package/dist/ink/canvas/index.d.ts +24 -0
- package/dist/ink/canvas/index.js +1 -0
- package/dist/ink/hooks/use-animation.d.ts +22 -22
- package/dist/ink/hooks/use-app.d.ts +3 -34
- package/dist/ink/hooks/use-app.js +1 -1
- package/dist/ink/hooks/use-box-metrics.d.ts +17 -18
- package/dist/ink/hooks/use-clipboard.d.ts +16 -16
- package/dist/ink/hooks/use-color-blindness.d.ts +16 -16
- package/dist/ink/hooks/use-console-capture.d.ts +19 -19
- package/dist/ink/hooks/use-cursor.d.ts +7 -7
- package/dist/ink/hooks/use-focus-manager.d.ts +25 -25
- package/dist/ink/hooks/use-focus.d.ts +14 -18
- package/dist/ink/hooks/use-form.d.ts +32 -32
- package/dist/ink/hooks/use-hotkey.d.ts +17 -17
- package/dist/ink/hooks/use-input.d.ts +92 -92
- package/dist/ink/hooks/use-input.js +2 -2
- package/dist/ink/hooks/use-interval.d.ts +14 -14
- package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +3 -3
- package/dist/ink/hooks/use-key-bindings.d.ts +32 -32
- package/dist/ink/hooks/use-key-chord.d.ts +15 -15
- package/dist/ink/hooks/use-paste.d.ts +38 -38
- package/dist/ink/hooks/use-paste.js +1 -1
- package/dist/ink/hooks/use-persistent-state.d.ts +46 -46
- package/dist/ink/hooks/use-persistent-state.js +2 -2
- package/dist/ink/hooks/use-scroll-acceleration.d.ts +24 -24
- package/dist/ink/hooks/use-scroll-input.d.ts +15 -15
- package/dist/ink/hooks/use-stderr.d.ts +6 -6
- package/dist/ink/hooks/use-stderr.js +1 -1
- package/dist/ink/hooks/use-stdin.d.ts +10 -10
- package/dist/ink/hooks/use-stdin.js +1 -1
- package/dist/ink/hooks/use-stdout.d.ts +6 -6
- package/dist/ink/hooks/use-stdout.js +1 -1
- package/dist/ink/hooks/use-stopwatch.d.ts +12 -12
- package/dist/ink/hooks/use-terminal-palette.d.ts +11 -11
- package/dist/ink/hooks/use-text-buffer.d.ts +2 -2
- package/dist/ink/hooks/use-text-selection.d.ts +19 -20
- package/dist/ink/hooks/use-timeout.d.ts +11 -11
- package/dist/ink/hooks/use-timer.d.ts +19 -19
- package/dist/ink/hooks/use-window-size.d.ts +8 -8
- package/dist/ink/hooks/use-window-size.js +1 -1
- package/dist/ink/index.d.ts +110 -123
- package/dist/ink/index.js +1 -1
- package/dist/ink/mouse/use-element-position.d.ts +7 -8
- package/dist/ink/mouse/use-mouse-action.d.ts +1 -1
- package/dist/ink/mouse/use-mouse-position.d.ts +1 -1
- package/dist/ink/mouse/use-mouse.d.ts +1 -1
- package/dist/ink/mouse/use-on-mouse-click.d.ts +4 -5
- package/dist/ink/mouse/use-on-mouse-hover.d.ts +3 -4
- package/dist/ink/mouse/use-on-mouse-state.d.ts +3 -4
- package/dist/ink/public/cursor.d.ts +47 -0
- package/dist/ink/public/cursor.js +1 -0
- package/dist/ink/public/dom.d.ts +6 -0
- package/dist/ink/public/dom.js +0 -0
- package/dist/ink/public/highlighter.d.ts +44 -0
- package/dist/ink/public/highlighter.js +1 -0
- package/dist/ink/public/input.d.ts +14 -0
- package/dist/ink/public/input.js +1 -0
- package/dist/ink/public/styles.d.ts +4 -0
- package/dist/ink/public/styles.js +0 -0
- package/dist/ink/public/utils.d.ts +5 -0
- package/dist/ink/public/utils.js +1 -0
- package/dist/packem_chunks/devtools.js +1 -1
- package/dist/packem_shared/{DevTools-k6uiVzqv.js → DevTools-BxD3PYAN.js} +1 -1
- package/dist/packem_shared/InputParser-CiBitCva.js +2 -0
- package/dist/packem_shared/MouseProvider-DOcWCRVq.js +1 -0
- package/dist/packem_shared/{Renderer-DsskdkUd.js → Renderer-BeS49FNq.js} +1 -1
- package/dist/packem_shared/TuiApp-CCVaiKbf.js +1 -0
- package/dist/packem_shared/app-context-DTm1_XBA.js +1 -0
- package/dist/packem_shared/app-context.d-DMLw5Nxy.d.ts +56 -0
- package/dist/packem_shared/boxes-DyY_LXCi.js +1 -0
- package/dist/packem_shared/buffer.d-CttIC480.d.ts +67 -0
- package/dist/packem_shared/buildCursorOnlySequence-CerkmjWt.js +1 -0
- package/dist/packem_shared/clipboard.d-nDPQkZ2H.d.ts +23 -0
- package/dist/packem_shared/color-matrix.d-sTqnJ23h.d.ts +50 -0
- package/dist/packem_shared/{braille-ch3O5D7I.js → createBrailleGrid-BTOQrujS.js} +1 -1
- package/dist/packem_shared/createCanvasBuffer-CL6sAM-A.js +1 -0
- package/dist/packem_shared/{createInlineLoop-BT40Wpmx.js → createInlineLoop-DnEvE2eM.js} +1 -1
- package/dist/packem_shared/disposeHighlighter-D9OkrhwX.js +1 -0
- package/dist/packem_shared/{dom.d-B4kXbaVY.d.ts → dom.d-CLGlidfI.d.ts} +140 -154
- package/dist/packem_shared/formatDuration-Bdx4ZgRh.js +1 -0
- package/dist/packem_shared/index-Dl9I2_QH.js +75 -0
- package/dist/packem_shared/input.d-Bb8pWHvp.d.ts +172 -0
- package/dist/packem_shared/{input-utils-BSWCb4F_.js → isControlCharacter-uDgBe_32.js} +1 -1
- package/dist/packem_shared/load-native-root-binding-CxJnHcac.js +1 -0
- package/dist/packem_shared/{mouse-context.d-BfL9xGk_.d.ts → mouse-context.d-W-nszUps.d.ts} +8 -8
- package/dist/packem_shared/reconciler-DkwOtC5B.js +1 -0
- package/dist/packem_shared/render-CuCo-R-l.js +24 -0
- package/dist/packem_shared/{render-DFZ8NHlG.js → render-DtQd8qQq.js} +1 -1
- package/dist/packem_shared/render.d-DjQhFsiN.d.ts +435 -0
- package/dist/packem_shared/{renderToString-DwXFY8Qh.js → renderToString-B1LgWcJe.js} +1 -1
- package/dist/packem_shared/{renderToString-L_bpw4OQ.js → renderToString-DkTmJPaS.js} +1 -1
- package/dist/packem_shared/renderToken-DjiQ6dfv.js +1 -0
- package/dist/packem_shared/renderTreeToBuffer-BpSD0sBJ.js +2 -0
- package/dist/packem_shared/{renderer-k-xShm1P.js → renderer-Cs0KEr1o.js} +4 -4
- package/dist/packem_shared/{selection.d-CI3_p8wg.d.ts → selection.d-BSAWa4ey.d.ts} +16 -16
- package/dist/packem_shared/stderr-context-CR2LLec6.js +1 -0
- package/dist/packem_shared/stdin-context-BjMA9Sbi.js +1 -0
- package/dist/packem_shared/stdout-context-DAAlQct2.js +1 -0
- package/dist/packem_shared/styles.d-CKGQFfm4.d.ts +485 -0
- package/dist/packem_shared/{terminal-palette.d-D2SQjfn-.d.ts → terminal-palette.d-JbWHISW-.d.ts} +7 -7
- package/dist/packem_shared/utils-CVgM8kTn.js +1 -0
- package/dist/react/index.d.ts +160 -179
- package/dist/react/index.js +1 -1
- package/dist/testing/index.d.ts +152 -152
- package/dist/testing/index.js +1 -1
- package/index.js +52 -52
- package/package.json +49 -384
- package/dist/components/accordion.d.ts +0 -59
- package/dist/components/accordion.js +0 -1
- package/dist/components/alert.d.ts +0 -26
- package/dist/components/alert.js +0 -1
- package/dist/components/animate-presence.d.ts +0 -18
- package/dist/components/animate-presence.js +0 -1
- package/dist/components/approval-prompt.d.ts +0 -65
- package/dist/components/approval-prompt.js +0 -1
- package/dist/components/area-chart.d.ts +0 -66
- package/dist/components/area-chart.js +0 -1
- package/dist/components/badge.d.ts +0 -22
- package/dist/components/badge.js +0 -1
- package/dist/components/bar-chart.d.ts +0 -67
- package/dist/components/bar-chart.js +0 -1
- package/dist/components/big-text.d.ts +0 -81
- package/dist/components/big-text.js +0 -1
- package/dist/components/blink-dot.d.ts +0 -36
- package/dist/components/blink-dot.js +0 -1
- package/dist/components/breadcrumb.d.ts +0 -33
- package/dist/components/breadcrumb.js +0 -1
- package/dist/components/button.d.ts +0 -45
- package/dist/components/button.js +0 -1
- package/dist/components/calendar.d.ts +0 -72
- package/dist/components/calendar.js +0 -1
- package/dist/components/card.d.ts +0 -57
- package/dist/components/card.js +0 -1
- package/dist/components/checkbox.d.ts +0 -48
- package/dist/components/checkbox.js +0 -1
- package/dist/components/code.d.ts +0 -48
- package/dist/components/code.js +0 -2
- package/dist/components/collapsible.d.ts +0 -53
- package/dist/components/collapsible.js +0 -1
- package/dist/components/command-block.d.ts +0 -47
- package/dist/components/command-block.js +0 -4
- package/dist/components/command-palette.d.ts +0 -82
- package/dist/components/command-palette.js +0 -1
- package/dist/components/confirm-dialog.d.ts +0 -75
- package/dist/components/confirm-dialog.js +0 -1
- package/dist/components/confirm-input.d.ts +0 -38
- package/dist/components/confirm-input.js +0 -1
- package/dist/components/console-overlay.d.ts +0 -54
- package/dist/components/console-overlay.js +0 -1
- package/dist/components/content-switcher.d.ts +0 -57
- package/dist/components/content-switcher.js +0 -1
- package/dist/components/controlled-scroll-view.d.ts +0 -61
- package/dist/components/controlled-scroll-view.js +0 -1
- package/dist/components/date-picker.d.ts +0 -65
- package/dist/components/date-picker.js +0 -1
- package/dist/components/definition-list.d.ts +0 -44
- package/dist/components/definition-list.js +0 -1
- package/dist/components/dialog.d.ts +0 -117
- package/dist/components/dialog.js +0 -1
- package/dist/components/diff-view.d.ts +0 -85
- package/dist/components/diff-view.js +0 -1
- package/dist/components/divider.d.ts +0 -49
- package/dist/components/divider.js +0 -1
- package/dist/components/file-picker-entry.d.ts +0 -104
- package/dist/components/file-picker-entry.js +0 -1
- package/dist/components/form.d.ts +0 -81
- package/dist/components/form.js +0 -1
- package/dist/components/gauge.d.ts +0 -87
- package/dist/components/gauge.js +0 -1
- package/dist/components/gradient.d.ts +0 -42
- package/dist/components/gradient.js +0 -1
- package/dist/components/heading.d.ts +0 -33
- package/dist/components/heading.js +0 -1
- package/dist/components/heatmap.d.ts +0 -62
- package/dist/components/heatmap.js +0 -1
- package/dist/components/help.d.ts +0 -52
- package/dist/components/help.js +0 -1
- package/dist/components/histogram.d.ts +0 -62
- package/dist/components/histogram.js +0 -1
- package/dist/components/kbd.d.ts +0 -31
- package/dist/components/kbd.js +0 -1
- package/dist/components/line-chart.d.ts +0 -109
- package/dist/components/line-chart.js +0 -1
- package/dist/components/link.d.ts +0 -38
- package/dist/components/link.js +0 -1
- package/dist/components/loading-indicator.d.ts +0 -29
- package/dist/components/loading-indicator.js +0 -1
- package/dist/components/markdown.d.ts +0 -40
- package/dist/components/markdown.js +0 -1
- package/dist/components/masked-input.d.ts +0 -50
- package/dist/components/masked-input.js +0 -1
- package/dist/components/menu.d.ts +0 -78
- package/dist/components/menu.js +0 -1
- package/dist/components/message-bubble.d.ts +0 -43
- package/dist/components/message-bubble.js +0 -1
- package/dist/components/model-badge.d.ts +0 -39
- package/dist/components/model-badge.js +0 -1
- package/dist/components/multi-select.d.ts +0 -65
- package/dist/components/multi-select.js +0 -1
- package/dist/components/operation-tree.d.ts +0 -49
- package/dist/components/operation-tree.js +0 -1
- package/dist/components/option-list.d.ts +0 -47
- package/dist/components/option-list.js +0 -1
- package/dist/components/ordered-list.d.ts +0 -24
- package/dist/components/ordered-list.js +0 -1
- package/dist/components/paginator.d.ts +0 -69
- package/dist/components/paginator.js +0 -1
- package/dist/components/paragraph.d.ts +0 -38
- package/dist/components/paragraph.js +0 -1
- package/dist/components/placeholder.d.ts +0 -55
- package/dist/components/placeholder.js +0 -1
- package/dist/components/progress-bar.d.ts +0 -56
- package/dist/components/progress-bar.js +0 -1
- package/dist/components/radio-group.d.ts +0 -74
- package/dist/components/radio-group.js +0 -1
- package/dist/components/scatter-plot.d.ts +0 -35
- package/dist/components/scatter-plot.js +0 -1
- package/dist/components/scroll-bar-box.d.ts +0 -37
- package/dist/components/scroll-bar-box.js +0 -1
- package/dist/components/scroll-bar.d.ts +0 -25
- package/dist/components/scroll-bar.js +0 -1
- package/dist/components/scroll-list.d.ts +0 -20
- package/dist/components/scroll-list.js +0 -1
- package/dist/components/scroll-view.d.ts +0 -10
- package/dist/components/scroll-view.js +0 -1
- package/dist/components/search-input.d.ts +0 -55
- package/dist/components/search-input.js +0 -1
- package/dist/components/select-input-indicator.d.ts +0 -32
- package/dist/components/select-input-indicator.js +0 -1
- package/dist/components/select-input-item.d.ts +0 -41
- package/dist/components/select-input-item.js +0 -1
- package/dist/components/select-input.d.ts +0 -110
- package/dist/components/select-input.js +0 -1
- package/dist/components/shimmer-text.d.ts +0 -47
- package/dist/components/shimmer-text.js +0 -1
- package/dist/components/slider.d.ts +0 -103
- package/dist/components/slider.js +0 -1
- package/dist/components/sparkline.d.ts +0 -35
- package/dist/components/sparkline.js +0 -1
- package/dist/components/spinner.d.ts +0 -17
- package/dist/components/spinner.js +0 -1
- package/dist/components/status-line.d.ts +0 -37
- package/dist/components/status-line.js +0 -1
- package/dist/components/status-message.d.ts +0 -21
- package/dist/components/status-message.js +0 -1
- package/dist/components/stepper.d.ts +0 -48
- package/dist/components/stepper.js +0 -1
- package/dist/components/stopwatch.d.ts +0 -49
- package/dist/components/stopwatch.js +0 -1
- package/dist/components/streaming-text.d.ts +0 -46
- package/dist/components/streaming-text.js +0 -1
- package/dist/components/switch.d.ts +0 -55
- package/dist/components/switch.js +0 -1
- package/dist/components/tab.d.ts +0 -19
- package/dist/components/tab.js +0 -1
- package/dist/components/table.d.ts +0 -119
- package/dist/components/table.js +0 -1
- package/dist/components/tabs.d.ts +0 -107
- package/dist/components/tabs.js +0 -1
- package/dist/components/tag.d.ts +0 -35
- package/dist/components/tag.js +0 -1
- package/dist/components/text-input.d.ts +0 -48
- package/dist/components/text-input.js +0 -1
- package/dist/components/textarea.d.ts +0 -68
- package/dist/components/textarea.js +0 -2
- package/dist/components/timer.d.ts +0 -59
- package/dist/components/timer.js +0 -1
- package/dist/components/toast.d.ts +0 -49
- package/dist/components/toast.js +0 -1
- package/dist/components/tooltip.d.ts +0 -43
- package/dist/components/tooltip.js +0 -1
- package/dist/components/transition.d.ts +0 -74
- package/dist/components/transition.js +0 -1
- package/dist/components/tree-view-entry.d.ts +0 -357
- package/dist/components/tree-view-entry.js +0 -1
- package/dist/components/unordered-list.d.ts +0 -30
- package/dist/components/unordered-list.js +0 -1
- package/dist/ink/hooks/use-linked-scroll.d.ts +0 -49
- package/dist/ink/hooks/use-linked-scroll.js +0 -1
- package/dist/packem_shared/ControlledScrollView-Cn4byU2n.js +0 -1
- package/dist/packem_shared/FilePicker-BLS9nOPz.js +0 -1
- package/dist/packem_shared/InputParser-CtwkCbrQ.js +0 -2
- package/dist/packem_shared/MouseProvider-DUqQ3Eaa.js +0 -1
- package/dist/packem_shared/ScrollBar-qa1IzDDv.js +0 -1
- package/dist/packem_shared/ScrollBarBox-DchESZWv.js +0 -1
- package/dist/packem_shared/ScrollList-BBAnRsrC.js +0 -1
- package/dist/packem_shared/ScrollView-CHAo7Epj.js +0 -1
- package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +0 -1
- package/dist/packem_shared/TreeView-BsvLCsf0.js +0 -1
- package/dist/packem_shared/TuiApp-BPL8v1i1.js +0 -1
- package/dist/packem_shared/app-context-BVpKlG1z.js +0 -1
- package/dist/packem_shared/buffer.d-EJkZr8uH.d.ts +0 -39
- package/dist/packem_shared/clipboard.d-D6lZTQ21.d.ts +0 -23
- package/dist/packem_shared/color-matrix.d-DSXLsB64.d.ts +0 -50
- package/dist/packem_shared/controlled-scroll-view-BVg7ywNW.js +0 -1
- package/dist/packem_shared/cursor-helpers.d-BONB9tky.d.ts +0 -12
- package/dist/packem_shared/format-time-fjoQHMxD.js +0 -1
- package/dist/packem_shared/input.d-CgxV2e8U.d.ts +0 -90
- package/dist/packem_shared/line-chart-C7CUrvVs.js +0 -1
- package/dist/packem_shared/load-native-root-binding-DDikxNox.js +0 -1
- package/dist/packem_shared/reconciler-CFyBVf7l.js +0 -1
- package/dist/packem_shared/render-CuQecTAs.js +0 -24
- package/dist/packem_shared/render.d-CBnYBDk2.d.ts +0 -417
- package/dist/packem_shared/renderTreeToBuffer-C8lS0lJ2.js +0 -2
- package/dist/packem_shared/scroll-view.d-DtpsgHLg.d.ts +0 -119
- package/dist/packem_shared/stderr-context-Bvnik0hL.js +0 -1
- package/dist/packem_shared/stdin-context-88AhuztD.js +0 -1
- package/dist/packem_shared/stdout-context-BnblEPez.js +0 -1
- package/dist/packem_shared/styles.d-cMo36xQz.d.ts +0 -396
- package/dist/packem_shared/token-to-elements-D6J6-P2A.js +0 -1
- package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +0 -1
- package/dist/packem_shared/useTreeView-D5ifGwG3.js +0 -1
- package/dist/packem_shared/useTreeViewState-BiTJakkh.js +0 -1
- package/dist/packem_shared/utils-Bup8lyK8.js +0 -1
- package/dist/packem_shared/variant-config-BJqpNo7H.js +0 -1
- package/dist/packem_shared/variant-config.d-D5NnrrQK.d.ts +0 -2
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,287 +1,287 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { R as RenderOptions } from "../packem_shared/render.d-
|
|
3
|
-
import "../packem_shared/dom.d-
|
|
2
|
+
import { R as RenderOptions } from "../packem_shared/render.d-DjQhFsiN.js";
|
|
3
|
+
import "../packem_shared/dom.d-CLGlidfI.js";
|
|
4
4
|
import 'yoga-layout';
|
|
5
|
-
import "../
|
|
5
|
+
import "../ink/public/cursor.js";
|
|
6
6
|
import '@visulima/colorize';
|
|
7
|
-
import
|
|
8
|
-
import "../packem_shared/styles.d-cMo36xQz.js";
|
|
7
|
+
import "../packem_shared/styles.d-CKGQFfm4.js";
|
|
9
8
|
import 'type-fest';
|
|
9
|
+
import "../packem_shared/app-context.d-DMLw5Nxy.js";
|
|
10
10
|
import 'node:stream';
|
|
11
11
|
declare const KEY: {
|
|
12
12
|
readonly backspace: "";
|
|
13
13
|
readonly ctrlC: "";
|
|
14
|
-
readonly delete: "
|
|
15
|
-
readonly down: "
|
|
16
|
-
readonly end: "
|
|
17
|
-
readonly escape: "
|
|
18
|
-
readonly home: "
|
|
19
|
-
readonly left: "
|
|
20
|
-
readonly pageDown: "
|
|
21
|
-
readonly pageUp: "
|
|
14
|
+
readonly delete: "[3~";
|
|
15
|
+
readonly down: "[B";
|
|
16
|
+
readonly end: "[F";
|
|
17
|
+
readonly escape: "";
|
|
18
|
+
readonly home: "[H";
|
|
19
|
+
readonly left: "[D";
|
|
20
|
+
readonly pageDown: "[6~";
|
|
21
|
+
readonly pageUp: "[5~";
|
|
22
22
|
readonly return: "\r";
|
|
23
|
-
readonly right: "
|
|
23
|
+
readonly right: "[C";
|
|
24
24
|
readonly space: " ";
|
|
25
|
-
readonly tab: "
|
|
26
|
-
readonly up: "
|
|
25
|
+
readonly tab: "\t";
|
|
26
|
+
readonly up: "[A";
|
|
27
27
|
};
|
|
28
28
|
type KeyName = keyof typeof KEY;
|
|
29
29
|
interface KeySender {
|
|
30
30
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
* Simulate pressing the backspace key.
|
|
32
|
+
*/
|
|
33
33
|
backspace: () => void;
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
* Simulate pressing the delete key.
|
|
36
|
+
*/
|
|
37
37
|
delete: () => void;
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
* Simulate pressing the down arrow key.
|
|
40
|
+
*/
|
|
41
41
|
down: () => void;
|
|
42
42
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
* Simulate pressing the end key.
|
|
44
|
+
*/
|
|
45
45
|
end: () => void;
|
|
46
46
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
* Simulate pressing the enter/return key.
|
|
48
|
+
*/
|
|
49
49
|
enter: () => void;
|
|
50
50
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
* Simulate pressing the escape key.
|
|
52
|
+
*/
|
|
53
53
|
escape: () => void;
|
|
54
54
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
* Simulate pressing the home key.
|
|
56
|
+
*/
|
|
57
57
|
home: () => void;
|
|
58
58
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
* Simulate pressing the left arrow key.
|
|
60
|
+
*/
|
|
61
61
|
left: () => void;
|
|
62
62
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
* Simulate pressing the page down key.
|
|
64
|
+
*/
|
|
65
65
|
pageDown: () => void;
|
|
66
66
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
* Simulate pressing the page up key.
|
|
68
|
+
*/
|
|
69
69
|
pageUp: () => void;
|
|
70
70
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
* Send a single character as a key press.
|
|
72
|
+
*/
|
|
73
73
|
press: (char: string) => void;
|
|
74
74
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
* Send arbitrary raw data to stdin.
|
|
76
|
+
*/
|
|
77
77
|
raw: (data: string) => void;
|
|
78
78
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
* Simulate pressing the right arrow key.
|
|
80
|
+
*/
|
|
81
81
|
right: () => void;
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
* Simulate pressing the space key.
|
|
84
|
+
*/
|
|
85
85
|
space: () => void;
|
|
86
86
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
* Simulate pressing the tab key.
|
|
88
|
+
*/
|
|
89
89
|
tab: () => void;
|
|
90
90
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
* Type a string character by character.
|
|
92
|
+
*/
|
|
93
93
|
type: (text: string) => void;
|
|
94
94
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
* Simulate pressing the up arrow key.
|
|
96
|
+
*/
|
|
97
97
|
up: () => void;
|
|
98
98
|
}
|
|
99
99
|
declare const createKeySender: (write: (data: string) => void) => KeySender;
|
|
100
100
|
interface Screen {
|
|
101
101
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
* Check if the current screen output contains the given text (ANSI-stripped).
|
|
103
|
+
*/
|
|
104
104
|
contains: (text: string) => boolean;
|
|
105
105
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
* Get all captured frames with ANSI codes stripped.
|
|
107
|
+
*/
|
|
108
108
|
frames: () => string[];
|
|
109
109
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
* Get a specific line by zero-based index from the current screen output.
|
|
111
|
+
*/
|
|
112
112
|
line: (n: number) => string;
|
|
113
113
|
/**
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
* Get all non-empty lines from the current screen output.
|
|
115
|
+
*/
|
|
116
116
|
lines: () => string[];
|
|
117
117
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
* Check if the current screen output matches the given pattern (ANSI-stripped).
|
|
119
|
+
*/
|
|
120
120
|
matches: (pattern: RegExp) => boolean;
|
|
121
121
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
* Get all captured frames with ANSI codes preserved.
|
|
123
|
+
*/
|
|
124
124
|
rawFrames: () => string[];
|
|
125
125
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
* Get the last rendered frame with ANSI codes preserved.
|
|
127
|
+
*/
|
|
128
128
|
rawText: () => string;
|
|
129
129
|
/**
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
* Get the last rendered frame with ANSI codes stripped.
|
|
131
|
+
*/
|
|
132
132
|
text: () => string;
|
|
133
133
|
}
|
|
134
134
|
declare const createScreen: (lastFrame: () => string | undefined, allFrames: ReadonlyArray<string>) => Screen;
|
|
135
135
|
interface WaitForOptions {
|
|
136
136
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
* Polling interval in milliseconds.
|
|
138
|
+
* @default 50
|
|
139
|
+
*/
|
|
140
140
|
interval?: number;
|
|
141
141
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
* Maximum time to wait in milliseconds before throwing.
|
|
143
|
+
* @default 3000
|
|
144
|
+
*/
|
|
145
145
|
timeout?: number;
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
|
-
* Wait for a condition to be met by polling at a regular interval.
|
|
149
|
-
*
|
|
150
|
-
* If `condition` is a string, waits until `screenText()` contains it.
|
|
151
|
-
* If `condition` is a function, waits until it stops throwing.
|
|
152
|
-
* @throws The last error encountered if the timeout is reached.
|
|
153
|
-
*/
|
|
148
|
+
* Wait for a condition to be met by polling at a regular interval.
|
|
149
|
+
*
|
|
150
|
+
* If `condition` is a string, waits until `screenText()` contains it.
|
|
151
|
+
* If `condition` is a function, waits until it stops throwing.
|
|
152
|
+
* @throws The last error encountered if the timeout is reached.
|
|
153
|
+
*/
|
|
154
154
|
declare const waitFor: (condition: (() => void) | string, screenText: () => string, options?: WaitForOptions) => Promise<void>;
|
|
155
155
|
type TestInstanceStdout = {
|
|
156
156
|
/**
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
* All rendered frames captured from stdout.
|
|
158
|
+
*/
|
|
159
159
|
readonly frames: ReadonlyArray<string>;
|
|
160
160
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
* Returns the most recently rendered frame, or `undefined` if no frames have been written.
|
|
162
|
+
*/
|
|
163
163
|
lastFrame: () => string | undefined;
|
|
164
164
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
* Write data to the mock stdout stream (used internally by the renderer).
|
|
166
|
+
*/
|
|
167
167
|
write: (frame: string) => boolean;
|
|
168
168
|
};
|
|
169
169
|
type TestInstanceStderr = {
|
|
170
170
|
/**
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
* All rendered frames captured from stderr.
|
|
172
|
+
*/
|
|
173
173
|
readonly frames: ReadonlyArray<string>;
|
|
174
174
|
/**
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
* Returns the most recently rendered frame, or `undefined` if no frames have been written.
|
|
176
|
+
*/
|
|
177
177
|
lastFrame: () => string | undefined;
|
|
178
178
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
* Write data to the mock stderr stream (used internally by the renderer).
|
|
180
|
+
*/
|
|
181
181
|
write: (frame: string) => boolean;
|
|
182
182
|
};
|
|
183
183
|
type TestInstanceStdin = {
|
|
184
184
|
/**
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
* Whether the stdin is a TTY.
|
|
186
|
+
*/
|
|
187
187
|
readonly isTTY: boolean;
|
|
188
188
|
/**
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
* Simulate user input by writing data to stdin.
|
|
190
|
+
*/
|
|
191
191
|
write: (data: string) => boolean;
|
|
192
192
|
};
|
|
193
193
|
type TestInstance = {
|
|
194
194
|
/**
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
* Unmount the app and clean up resources.
|
|
196
|
+
*/
|
|
197
197
|
cleanup: () => void;
|
|
198
198
|
/**
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
* Wait for pending React renders to flush (two microtick delay).
|
|
200
|
+
*/
|
|
201
201
|
flush: () => Promise<void>;
|
|
202
202
|
/**
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
* All rendered frames captured from stdout (shorthand for `stdout.frames`).
|
|
204
|
+
*/
|
|
205
205
|
readonly frames: ReadonlyArray<string>;
|
|
206
206
|
/**
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
* Keyboard input helpers for simulating key presses.
|
|
208
|
+
*/
|
|
209
209
|
keys: KeySender;
|
|
210
210
|
/**
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
* Returns the most recently rendered frame from stdout (shorthand for `stdout.lastFrame()`).
|
|
212
|
+
*/
|
|
213
213
|
lastFrame: () => string | undefined;
|
|
214
214
|
/**
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
* Replace the previous root node with a new one or update props.
|
|
216
|
+
*/
|
|
217
217
|
rerender: (node: ReactElement) => void;
|
|
218
218
|
/**
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
* Screen query helpers for inspecting rendered output with ANSI stripping.
|
|
220
|
+
*/
|
|
221
221
|
screen: Screen;
|
|
222
222
|
/**
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
* Mock stderr stream with frame capture.
|
|
224
|
+
*/
|
|
225
225
|
stderr: TestInstanceStderr;
|
|
226
226
|
/**
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
* Mock stdin stream for simulating user input.
|
|
228
|
+
*/
|
|
229
229
|
stdin: TestInstanceStdin;
|
|
230
230
|
/**
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
* Mock stdout stream with frame capture.
|
|
232
|
+
*/
|
|
233
233
|
stdout: TestInstanceStdout;
|
|
234
234
|
/**
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
* Manually unmount the whole app.
|
|
236
|
+
*/
|
|
237
237
|
unmount: () => void;
|
|
238
238
|
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
239
|
+
* Wait for a condition to be met by polling.
|
|
240
|
+
*
|
|
241
|
+
* If `condition` is a string, waits until the screen contains it.
|
|
242
|
+
* If `condition` is a function, waits until it stops throwing.
|
|
243
|
+
*/
|
|
244
244
|
waitFor: (condition: (() => void) | string, options?: WaitForOptions) => Promise<void>;
|
|
245
245
|
};
|
|
246
246
|
type TestRenderOptions = {
|
|
247
247
|
/**
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
* Terminal column width for the mock stdout/stderr streams.
|
|
249
|
+
* @default 100
|
|
250
|
+
*/
|
|
251
251
|
columns?: number;
|
|
252
252
|
/**
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
* Additional render options passed through to the underlying render function.
|
|
254
|
+
*/
|
|
255
255
|
options?: Omit<RenderOptions, "debug" | "exitOnCtrlC" | "patchConsole" | "stderr" | "stdin" | "stdout">;
|
|
256
256
|
};
|
|
257
257
|
/**
|
|
258
|
-
* Render a React element for testing, capturing output in mock streams.
|
|
259
|
-
*
|
|
260
|
-
* Returns an object with methods to inspect rendered output, simulate input,
|
|
261
|
-
* and control the component lifecycle.
|
|
262
|
-
* @example
|
|
263
|
-
* ```tsx
|
|
264
|
-
* import { render } from "@visulima/tui/test";
|
|
265
|
-
* import { Text } from "@visulima/tui";
|
|
266
|
-
*
|
|
267
|
-
* const { lastFrame } = render(<Text>Hello</Text>);
|
|
268
|
-
* console.log(lastFrame()); // "Hello"
|
|
269
|
-
* ```
|
|
270
|
-
*/
|
|
258
|
+
* Render a React element for testing, capturing output in mock streams.
|
|
259
|
+
*
|
|
260
|
+
* Returns an object with methods to inspect rendered output, simulate input,
|
|
261
|
+
* and control the component lifecycle.
|
|
262
|
+
* @example
|
|
263
|
+
* ```tsx
|
|
264
|
+
* import { render } from "@visulima/tui/test";
|
|
265
|
+
* import { Text } from "@visulima/tui";
|
|
266
|
+
*
|
|
267
|
+
* const { lastFrame } = render(<Text>Hello</Text>);
|
|
268
|
+
* console.log(lastFrame()); // "Hello"
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
271
|
declare const testRender: (node: ReactElement, testOptions?: TestRenderOptions) => TestInstance;
|
|
272
272
|
/**
|
|
273
|
-
* Unmount and clean up all rendered test instances.
|
|
274
|
-
*
|
|
275
|
-
* Call this in your test teardown (e.g., `afterEach`) to ensure
|
|
276
|
-
* no test instances leak between tests.
|
|
277
|
-
* @example
|
|
278
|
-
* ```ts
|
|
279
|
-
* import { cleanup } from "@visulima/tui/test";
|
|
280
|
-
*
|
|
281
|
-
* afterEach(() => {
|
|
282
|
-
* cleanup();
|
|
283
|
-
* });
|
|
284
|
-
* ```
|
|
285
|
-
*/
|
|
273
|
+
* Unmount and clean up all rendered test instances.
|
|
274
|
+
*
|
|
275
|
+
* Call this in your test teardown (e.g., `afterEach`) to ensure
|
|
276
|
+
* no test instances leak between tests.
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* import { cleanup } from "@visulima/tui/test";
|
|
280
|
+
*
|
|
281
|
+
* afterEach(() => {
|
|
282
|
+
* cleanup();
|
|
283
|
+
* });
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
286
|
declare const cleanup: () => void;
|
|
287
287
|
export { KEY, type KeyName, type KeySender, type Screen, TestInstance, TestInstanceStderr, TestInstanceStdin, TestInstanceStdout, TestRenderOptions, type WaitForOptions, cleanup, createKeySender, createScreen, testRender as render, waitFor };
|
package/dist/testing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import
|
|
1
|
+
import{createRequire as _}from"node:module";import x from"../packem_shared/render-CuCo-R-l.js";import{createKeySender as y}from"../packem_shared/KEY-C--kOw41.js";import{KEY as Y}from"../packem_shared/KEY-C--kOw41.js";import{createScreen as T}from"../packem_shared/createScreen-DoYpyL0V.js";import{waitFor as b}from"../packem_shared/waitFor-CTAki32d.js";let g;const w=t=>(g??=_(import.meta.url))(t),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,F=t=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,n]=a.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return a.getBuiltinModule(t)}return w(t)},m=F("node:events");class j extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class v extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class R extends m{isTTY=!0;pendingData;write=e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0);read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const u=[],S=(t,e={})=>{const{columns:n,options:d}=e,s=new j(n),c=new v(n),o=new R,i=x(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:c,stdin:o,stdout:s,...d});u.push(i);const l=T(()=>s.lastFrame(),s.frames),p=y(r=>o.write(r)),f=async()=>{await new Promise(r=>{setTimeout(r,0)}),await new Promise(r=>{setTimeout(r,0)})};return{cleanup:i.cleanup,flush:f,get frames(){return s.frames},keys:p,lastFrame:()=>s.lastFrame(),rerender:i.rerender,screen:l,stderr:c,stdin:o,stdout:s,unmount:i.unmount,async waitFor(r,h){await b(r,()=>l.text(),h)}}},B=()=>{for(const t of u)t.cleanup();u.length=0};export{Y as KEY,B as cleanup,y as createKeySender,T as createScreen,S as render,b as waitFor};
|