@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
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
type Listener = (...args: any[]) => Promise<any> | void;
|
|
2
|
+
type DefaultEventMap = { [event in (string | symbol)]: Listener; } & {
|
|
3
|
+
/**
|
|
4
|
+
* __proto__ key not allowed due to implementation
|
|
5
|
+
* add prefix, if you want to use this keyword
|
|
6
|
+
*/
|
|
7
|
+
__proto__?: never;
|
|
8
|
+
};
|
|
9
|
+
interface IEventEmitter<EventMap extends DefaultEventMap = DefaultEventMap> {
|
|
10
|
+
emit<EventKey extends keyof EventMap>(event: EventKey, ...args: Parameters<EventMap[EventKey]>): boolean;
|
|
11
|
+
on<EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]): this;
|
|
12
|
+
once<EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]): this;
|
|
13
|
+
addListener<EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]): this;
|
|
14
|
+
removeListener<EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]): this;
|
|
15
|
+
prependListener<EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]): this;
|
|
16
|
+
prependOnceListener<EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]): this;
|
|
17
|
+
off<EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]): this;
|
|
18
|
+
removeAllListeners<EventKey extends keyof EventMap = string>(event?: EventKey): this;
|
|
19
|
+
setMaxListeners(n: number): this;
|
|
20
|
+
getMaxListeners(): number;
|
|
21
|
+
listeners<EventKey extends keyof EventMap = string>(event: EventKey): EventMap[EventKey][];
|
|
22
|
+
rawListeners<EventKey extends keyof EventMap = string>(event: EventKey): EventMap[EventKey][];
|
|
23
|
+
eventNames(): Array<string | symbol>;
|
|
24
|
+
listenerCount<EventKey extends keyof EventMap = string>(type: EventKey): number;
|
|
25
|
+
}
|
|
26
|
+
type ArgsNum<T extends (...args: any[]) => any> = T extends ((...args: infer K) => any) ? K["length"] : never;
|
|
27
|
+
declare class TaskCollection<Func extends (...args: any) => void, AwaitTasks extends true | false = false> {
|
|
28
|
+
readonly awaitTasks: AwaitTasks;
|
|
29
|
+
constructor(argsNum: ArgsNum<Func>, autoRebuild?: boolean, initialTasks?: (Func[]) | Func | null, awaitTasks?: AwaitTasks);
|
|
30
|
+
/** DO NOT CHANGE DIRECTLY */
|
|
31
|
+
_tasks: (Func[]) | Func | null;
|
|
32
|
+
/** cached */
|
|
33
|
+
length: number;
|
|
34
|
+
/** auto rebuild on first emit call; otherwise autorebuild on every change */
|
|
35
|
+
firstEmitBuildStrategy: boolean;
|
|
36
|
+
readonly argsNum: ArgsNum<Func>;
|
|
37
|
+
autoRebuild: boolean;
|
|
38
|
+
readonly growArgsNum: typeof growArgsNum;
|
|
39
|
+
setAutoRebuild: typeof setAutoRebuild;
|
|
40
|
+
call: (...args: Parameters<Func>) => (AwaitTasks extends true ? Promise<void> : void);
|
|
41
|
+
rebuild: () => void;
|
|
42
|
+
push: (...func: Func[]) => void;
|
|
43
|
+
/** remove last matched task from tasks */
|
|
44
|
+
removeLast: (func: Func) => void;
|
|
45
|
+
insert: (index: number, ...func: Func[]) => void;
|
|
46
|
+
setTasks: (tasks: Func[]) => void;
|
|
47
|
+
tasksAsArray: () => Func[];
|
|
48
|
+
/** this autorebuilds */
|
|
49
|
+
readonly clear: typeof clear;
|
|
50
|
+
/** this autorebuilds */
|
|
51
|
+
readonly fastClear: typeof fastClear;
|
|
52
|
+
}
|
|
53
|
+
declare function fastClear<Func extends (...args: any) => void, AwaitTasks extends true | false = false>(this: TaskCollection<Func, AwaitTasks>): void;
|
|
54
|
+
declare function clear<Func extends (...args: any) => void, AwaitTasks extends true | false = false>(this: TaskCollection<Func, AwaitTasks>): void;
|
|
55
|
+
declare function growArgsNum<Func extends (...args: any) => void, AwaitTasks extends true | false = false>(this: TaskCollection<Func, AwaitTasks>, argsNum: number): void;
|
|
56
|
+
declare function setAutoRebuild<Func extends (...args: any) => void, AwaitTasks extends true | false = false>(this: TaskCollection<Func, AwaitTasks>, newVal: boolean): void;
|
|
57
|
+
/** Implemented event emitter */
|
|
58
|
+
declare class EventEmitter<EventMap extends DefaultEventMap = DefaultEventMap> implements IEventEmitter<EventMap> {
|
|
59
|
+
events: { [eventName in keyof EventMap]?: TaskCollection<EventMap[eventName]>; };
|
|
60
|
+
onceEvents: { [eventName in keyof EventMap]?: (EventMap[eventName][]) | EventMap[eventName]; };
|
|
61
|
+
boundFuncs: undefined | Map<Function, Function>;
|
|
62
|
+
_symbolKeys: Set<symbol>;
|
|
63
|
+
maxListeners: number;
|
|
64
|
+
get _eventsCount(): number;
|
|
65
|
+
emit: <EventKey extends keyof EventMap>(event: EventKey, ...args: Parameters<EventMap[EventKey]>) => boolean;
|
|
66
|
+
on: <EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]) => this;
|
|
67
|
+
once: <EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]) => this;
|
|
68
|
+
addListener: <EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey], argsNum?: ArgsNum<EventMap[EventKey]>) => this;
|
|
69
|
+
removeListener: <EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]) => this;
|
|
70
|
+
hasListeners: <EventKey extends keyof EventMap = string>(event: EventKey) => boolean;
|
|
71
|
+
prependListener: <EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]) => this;
|
|
72
|
+
prependOnceListener: <EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]) => this;
|
|
73
|
+
off: <EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]) => this;
|
|
74
|
+
removeAllListeners: <EventKey extends keyof EventMap = string>(event?: EventKey) => this;
|
|
75
|
+
setMaxListeners: (n: number) => this;
|
|
76
|
+
getMaxListeners: () => number;
|
|
77
|
+
listeners: <EventKey extends keyof EventMap = string>(event: EventKey) => EventMap[EventKey][];
|
|
78
|
+
rawListeners: <EventKey extends keyof EventMap = string>(event: EventKey) => EventMap[EventKey][];
|
|
79
|
+
eventNames: () => Array<string | symbol>;
|
|
80
|
+
listenerCount: <EventKey extends keyof EventMap = string>(type: EventKey) => number;
|
|
81
|
+
addListenerBound: <EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey], bindTo?: any, argsNum?: ArgsNum<EventMap[EventKey]>) => this;
|
|
82
|
+
removeListenerBound: <EventKey extends keyof EventMap = string>(event: EventKey, listener: EventMap[EventKey]) => this;
|
|
83
|
+
}
|
|
84
|
+
declare class TuiApp extends EventEmitter {
|
|
85
|
+
private renderer;
|
|
86
|
+
private terminal;
|
|
87
|
+
private backBuffer;
|
|
88
|
+
private width;
|
|
89
|
+
private height;
|
|
90
|
+
private isRunning;
|
|
91
|
+
private stdoutBuffer;
|
|
92
|
+
private stderrBuffer;
|
|
93
|
+
constructor();
|
|
94
|
+
/** Enters raw mode + alternate screen. Does NOT start any render loop. */
|
|
95
|
+
start(): void;
|
|
96
|
+
/** Request a clean exit — restores terminal, stops input, exits the process. */
|
|
97
|
+
quit(): void;
|
|
98
|
+
/** Exits raw mode + alternate screen, then flushes any buffered stdout/stderr. */
|
|
99
|
+
stop(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Buffer a write to stdout. While the alternate screen is active, writing
|
|
102
|
+
* directly would corrupt the TUI. Buffered output is flushed on stop().
|
|
103
|
+
*/
|
|
104
|
+
writeStdout(text: string): void;
|
|
105
|
+
/**
|
|
106
|
+
* Buffer a write to stderr. While the alternate screen is active, writing
|
|
107
|
+
* directly would corrupt the TUI. Buffered output is flushed on stop().
|
|
108
|
+
*/
|
|
109
|
+
writeStderr(text: string): void;
|
|
110
|
+
/** Returns the shared Uint32Array back-buffer (width * height * 2 u32 cells). */
|
|
111
|
+
getBuffer(): Uint32Array;
|
|
112
|
+
/** Returns current terminal dimensions. */
|
|
113
|
+
getSize(): {
|
|
114
|
+
height: number;
|
|
115
|
+
width: number;
|
|
116
|
+
};
|
|
117
|
+
/** Update terminal dimensions (called on SIGWINCH). */
|
|
118
|
+
resize(width: number, height: number): void;
|
|
119
|
+
/**
|
|
120
|
+
* Callbacks fired on every frame after React paints the buffer but before
|
|
121
|
+
* the Rust diff engine flushes to stdout. Use for direct buffer painting
|
|
122
|
+
* that needs to overlay React output (animated graphs, overlays, FPS counters).
|
|
123
|
+
* Multiple listeners are supported — they fire in registration order.
|
|
124
|
+
*/
|
|
125
|
+
private beforeFlushListeners;
|
|
126
|
+
onBeforeFlush(function_: (buffer: Uint32Array, width: number, height: number) => void): () => void;
|
|
127
|
+
/**
|
|
128
|
+
* Layout + paint synchronously. Called from the render loop on every dirty frame,
|
|
129
|
+
* and directly on resize for immediate response.
|
|
130
|
+
*/
|
|
131
|
+
paintNow(calculateLayout: (w: number, h: number) => void, renderToBuffer: (buf: Uint32Array, w: number, h: number) => void): void;
|
|
132
|
+
}
|
|
133
|
+
interface InlineOptions {
|
|
134
|
+
/** Frames per second. Default: 60 */
|
|
135
|
+
fps?: number;
|
|
136
|
+
/**
|
|
137
|
+
* What to do with the rendered content when the loop stops.
|
|
138
|
+
* - 'preserve' (default) — content stays in terminal scrollback
|
|
139
|
+
* - 'destroy' — content is cleared, terminal looks untouched
|
|
140
|
+
*/
|
|
141
|
+
onExit?: "preserve" | "destroy";
|
|
142
|
+
/** Number of terminal rows to reserve. Default: 10 */
|
|
143
|
+
rows?: number;
|
|
144
|
+
}
|
|
145
|
+
type InlinePaintFn = (buf: Uint32Array, cols: number, rows: number, frame: number) => void;
|
|
146
|
+
interface InlineLoop {
|
|
147
|
+
start: () => void;
|
|
148
|
+
stop: () => void;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Create an inline render loop. Renders `rows` lines immediately below the
|
|
152
|
+
* current cursor position (no alternate screen).
|
|
153
|
+
*/
|
|
154
|
+
declare function createInlineLoop(paint: InlinePaintFn, options?: InlineOptions): InlineLoop;
|
|
155
|
+
interface MouseEvent {
|
|
156
|
+
button: "left" | "right" | "middle" | "scrollUp" | "scrollDown";
|
|
157
|
+
ctrl: boolean;
|
|
158
|
+
meta: boolean;
|
|
159
|
+
shift: boolean;
|
|
160
|
+
x: number;
|
|
161
|
+
y: number;
|
|
162
|
+
}
|
|
163
|
+
declare class InputParser extends EventEmitter {
|
|
164
|
+
private stdin;
|
|
165
|
+
private _boundHandleData;
|
|
166
|
+
private _pasteBuffer;
|
|
167
|
+
constructor(stdin: NodeJS.ReadStream);
|
|
168
|
+
start(): void;
|
|
169
|
+
stop(): void;
|
|
170
|
+
private handleData;
|
|
171
|
+
}
|
|
172
|
+
export { InlineLoop as I, MouseEvent as M, TuiApp as T, InlineOptions as a, InlinePaintFn as b, InputParser as c, createInlineLoop as d };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=/^[a-z]$/i,n=r=>{const t=r.codePointAt(0);return t!==void 0&&(t<32||t===127)},o=(r,t)=>r.length===0||n(r)?!1:t.ctrl&&t.meta?!e.test(r):!(t.ctrl||t.meta);export{o as
|
|
1
|
+
const e=/^[a-z]$/i,n=r=>{const t=r.codePointAt(0);return t!==void 0&&(t<32||t===127)},o=(r,t)=>r.length===0||n(r)?!1:t.ctrl&&t.meta?!e.test(r):!(t.ctrl||t.meta);export{n as isControlCharacter,o as isInsertableInput};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as l}from"node:module";let _;const f=e=>(_??=l(import.meta.url))(e),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,i=e=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[o,n]=t.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return t.getBuiltinModule(e)}return f(e)},{existsSync:d}=i("node:fs"),{createRequire:p}=i("node:module"),{dirname:a,join:r}=i("node:path"),{fileURLToPath:j}=i("node:url"),m=12,h=e=>{const o=p(e),n=a(j(e));let s=n;for(let c=0;c<m;c+=1){if(d(r(s,"package.json"))&&d(r(s,"index.js")))return o(r(s,"index.js"));const u=a(s);if(u===s)break;s=u}return o(r(n,"..","index.js"))};export{h as p};
|
|
@@ -10,14 +10,14 @@ type MouseScrollAction = "scrolldown" | "scrollup" | null;
|
|
|
10
10
|
type MouseDragAction = "dragging" | null;
|
|
11
11
|
type MouseAction = MouseClickAction | MouseDragAction | MouseScrollAction;
|
|
12
12
|
/**
|
|
13
|
-
* Internal event emitter for mouse state changes.
|
|
14
|
-
*
|
|
15
|
-
* Events:
|
|
16
|
-
* - "position" (position: MousePosition)
|
|
17
|
-
* - "click" (position: MousePosition, action: MouseClickAction, button: MouseButton)
|
|
18
|
-
* - "scroll" (position: MousePosition, direction: MouseScrollAction)
|
|
19
|
-
* - "drag" (position: MousePosition, action: MouseDragAction, button: MouseButton)
|
|
20
|
-
*/
|
|
13
|
+
* Internal event emitter for mouse state changes.
|
|
14
|
+
*
|
|
15
|
+
* Events:
|
|
16
|
+
* - "position" (position: MousePosition)
|
|
17
|
+
* - "click" (position: MousePosition, action: MouseClickAction, button: MouseButton)
|
|
18
|
+
* - "scroll" (position: MousePosition, direction: MouseScrollAction)
|
|
19
|
+
* - "drag" (position: MousePosition, action: MouseDragAction, button: MouseButton)
|
|
20
|
+
*/
|
|
21
21
|
type MouseEvents = EventEmitter;
|
|
22
22
|
type MouseContextShape = {
|
|
23
23
|
readonly button: MouseButton | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as $}from"node:module";import{version as S,createContext as L}from"react";import R from"react-reconciler";import{NoEventPriority as A,DefaultEventPriority as b}from"react-reconciler/constants.js";import{unstable_shouldYield as P,unstable_scheduleCallback as D,unstable_now as O,unstable_cancelCallback as G}from"scheduler";import n from"yoga-layout";import{b as _,d as f,s as m,m as p,e as F,r as h,f as v,c as w,h as T,j as I}from"./dom-rphpG0kf.js";const x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=x,W=[["top",n.EDGE_TOP],["right",n.EDGE_RIGHT],["bottom",n.EDGE_BOTTOM],["left",n.EDGE_LEFT]],k=(t,e)=>{if("position"in e){let r=n.POSITION_TYPE_RELATIVE;e.position==="absolute"?r=n.POSITION_TYPE_ABSOLUTE:e.position==="static"&&(r=n.POSITION_TYPE_STATIC),t.setPositionType(r)}for(const[r,s]of W){if(!(r in e))continue;const l=e[r];if(typeof l=="string"){t.setPositionPercent(s,Number.parseFloat(l));continue}t.setPosition(s,l)}},B=(t,e)=>{"margin"in e&&t.setMargin(n.EDGE_ALL,e.margin??0),"marginX"in e&&t.setMargin(n.EDGE_HORIZONTAL,e.marginX??0),"marginY"in e&&t.setMargin(n.EDGE_VERTICAL,e.marginY??0),"marginLeft"in e&&t.setMargin(n.EDGE_START,e.marginLeft||0),"marginRight"in e&&t.setMargin(n.EDGE_END,e.marginRight||0),"marginTop"in e&&t.setMargin(n.EDGE_TOP,e.marginTop||0),"marginBottom"in e&&t.setMargin(n.EDGE_BOTTOM,e.marginBottom||0)},H=(t,e)=>{"padding"in e&&t.setPadding(n.EDGE_ALL,e.padding??0),"paddingX"in e&&t.setPadding(n.EDGE_HORIZONTAL,e.paddingX??0),"paddingY"in e&&t.setPadding(n.EDGE_VERTICAL,e.paddingY??0),"paddingLeft"in e&&t.setPadding(n.EDGE_LEFT,e.paddingLeft||0),"paddingRight"in e&&t.setPadding(n.EDGE_RIGHT,e.paddingRight||0),"paddingTop"in e&&t.setPadding(n.EDGE_TOP,e.paddingTop||0),"paddingBottom"in e&&t.setPadding(n.EDGE_BOTTOM,e.paddingBottom||0)},M=(t,e)=>{"flexGrow"in e&&t.setFlexGrow(e.flexGrow??0),"flexShrink"in e&&t.setFlexShrink(typeof e.flexShrink=="number"?e.flexShrink:1),"flexWrap"in e&&(e.flexWrap==="nowrap"&&t.setFlexWrap(n.WRAP_NO_WRAP),e.flexWrap==="wrap"&&t.setFlexWrap(n.WRAP_WRAP),e.flexWrap==="wrap-reverse"&&t.setFlexWrap(n.WRAP_WRAP_REVERSE)),"flexDirection"in e&&(e.flexDirection==="row"&&t.setFlexDirection(n.FLEX_DIRECTION_ROW),e.flexDirection==="row-reverse"&&t.setFlexDirection(n.FLEX_DIRECTION_ROW_REVERSE),e.flexDirection==="column"&&t.setFlexDirection(n.FLEX_DIRECTION_COLUMN),e.flexDirection==="column-reverse"&&t.setFlexDirection(n.FLEX_DIRECTION_COLUMN_REVERSE)),"flexBasis"in e&&(typeof e.flexBasis=="number"?t.setFlexBasis(e.flexBasis):typeof e.flexBasis=="string"?t.setFlexBasisPercent(Number.parseInt(e.flexBasis,10)):t.setFlexBasis(Number.NaN)),"alignItems"in e&&((e.alignItems==="stretch"||!e.alignItems)&&t.setAlignItems(n.ALIGN_STRETCH),e.alignItems==="flex-start"&&t.setAlignItems(n.ALIGN_FLEX_START),e.alignItems==="center"&&t.setAlignItems(n.ALIGN_CENTER),e.alignItems==="flex-end"&&t.setAlignItems(n.ALIGN_FLEX_END),e.alignItems==="baseline"&&t.setAlignItems(n.ALIGN_BASELINE)),"alignSelf"in e&&((e.alignSelf==="auto"||!e.alignSelf)&&t.setAlignSelf(n.ALIGN_AUTO),e.alignSelf==="flex-start"&&t.setAlignSelf(n.ALIGN_FLEX_START),e.alignSelf==="center"&&t.setAlignSelf(n.ALIGN_CENTER),e.alignSelf==="flex-end"&&t.setAlignSelf(n.ALIGN_FLEX_END),e.alignSelf==="stretch"&&t.setAlignSelf(n.ALIGN_STRETCH),e.alignSelf==="baseline"&&t.setAlignSelf(n.ALIGN_BASELINE)),"alignContent"in e&&((e.alignContent==="flex-start"||!e.alignContent)&&t.setAlignContent(n.ALIGN_FLEX_START),e.alignContent==="center"&&t.setAlignContent(n.ALIGN_CENTER),e.alignContent==="flex-end"&&t.setAlignContent(n.ALIGN_FLEX_END),e.alignContent==="space-between"&&t.setAlignContent(n.ALIGN_SPACE_BETWEEN),e.alignContent==="space-around"&&t.setAlignContent(n.ALIGN_SPACE_AROUND),e.alignContent==="space-evenly"&&t.setAlignContent(n.ALIGN_SPACE_EVENLY),e.alignContent==="stretch"&&t.setAlignContent(n.ALIGN_STRETCH)),"justifyContent"in e&&((e.justifyContent==="flex-start"||!e.justifyContent)&&t.setJustifyContent(n.JUSTIFY_FLEX_START),e.justifyContent==="center"&&t.setJustifyContent(n.JUSTIFY_CENTER),e.justifyContent==="flex-end"&&t.setJustifyContent(n.JUSTIFY_FLEX_END),e.justifyContent==="space-between"&&t.setJustifyContent(n.JUSTIFY_SPACE_BETWEEN),e.justifyContent==="space-around"&&t.setJustifyContent(n.JUSTIFY_SPACE_AROUND),e.justifyContent==="space-evenly"&&t.setJustifyContent(n.JUSTIFY_SPACE_EVENLY))},U=(t,e)=>{"width"in e&&(typeof e.width=="number"?t.setWidth(e.width):typeof e.width=="string"?t.setWidthPercent(Number.parseInt(e.width,10)):t.setWidthAuto()),"height"in e&&(typeof e.height=="number"?t.setHeight(e.height):typeof e.height=="string"?t.setHeightPercent(Number.parseInt(e.height,10)):t.setHeightAuto()),"minWidth"in e&&(typeof e.minWidth=="string"?t.setMinWidthPercent(Number.parseInt(e.minWidth,10)):t.setMinWidth(e.minWidth??0)),"minHeight"in e&&(typeof e.minHeight=="string"?t.setMinHeightPercent(Number.parseInt(e.minHeight,10)):t.setMinHeight(e.minHeight??0)),"maxWidth"in e&&(typeof e.maxWidth=="string"?t.setMaxWidthPercent(Number.parseInt(e.maxWidth,10)):t.setMaxWidth(e.maxWidth)),"maxHeight"in e&&(typeof e.maxHeight=="string"?t.setMaxHeightPercent(Number.parseInt(e.maxHeight,10)):t.setMaxHeight(e.maxHeight)),"aspectRatio"in e&&t.setAspectRatio(e.aspectRatio)},Y=(t,e)=>{"display"in e&&t.setDisplay(e.display==="flex"?n.DISPLAY_FLEX:n.DISPLAY_NONE)},j=(t,e,r)=>{if(!("borderStyle"in e||"borderTop"in e||"borderBottom"in e||"borderLeft"in e||"borderRight"in e))return;const s=r.borderStyle?1:0;t.setBorder(n.EDGE_TOP,r.borderTop===!1?0:s),t.setBorder(n.EDGE_BOTTOM,r.borderBottom===!1?0:s),t.setBorder(n.EDGE_LEFT,r.borderLeft===!1?0:s),t.setBorder(n.EDGE_RIGHT,r.borderRight===!1?0:s)},X=(t,e)=>{"gap"in e&&t.setGap(n.GUTTER_ALL,e.gap??0),"columnGap"in e&&t.setGap(n.GUTTER_COLUMN,e.columnGap??0),"rowGap"in e&&t.setGap(n.GUTTER_ROW,e.rowGap??0)},V=(t,e)=>{const r=e.overflow??"visible",s=e.overflowX??r,l=e.overflowY??r;s==="scroll"||l==="scroll"?t.setOverflow(n.OVERFLOW_SCROLL):s==="hidden"||l==="hidden"?t.setOverflow(n.OVERFLOW_HIDDEN):t.setOverflow(n.OVERFLOW_VISIBLE)},C=(t,e={},r=e)=>{k(t,e),B(t,e),H(t,e),M(t,e),U(t,e),Y(t,e),j(t,e,r),X(t,e),V(t,r)};if(y.env.DEV==="true"){let t=!1;try{import.meta.resolve("react-devtools-core"),t=!0}catch{}t&&await import("../packem_chunks/devtools.js")}const N=(t,e)=>{if(t===e)return;if(!t)return e;const r={};let s=!1;for(const l of Object.keys(t))(!e||!Object.hasOwn(e,l))&&(r[l]=void 0,s=!0);if(e)for(const l of Object.keys(e))e[l]!==t[l]&&(r[l]=e[l],s=!0);return s?r:void 0},E=t=>{if(t){if(t.yogaNode?.unsetMeasureFunc(),"resizeObservers"in t&&t.resizeObservers?.clear(),"childNodes"in t&&t.childNodes)for(const e of t.childNodes)E(e);t.yogaNode?.free(),"cachedRender"in t&&(t.cachedRender=void 0),"childNodes"in t&&(t.childNodes=[]),t.parentNode=void 0}};let u=A,g;async function J(){const t=(await import("node:fs")).readFileSync(new URL("../package.json",import.meta.url),"utf8"),e=JSON.parse(t);return{name:e?.name,version:e?.version}}let d={name:"ink",version:S};if(y.env.DEV==="true")try{const t=await J();d={name:t.name||d.name,version:t.version||d.version}}catch(t){console.warn("Failed to load package.json in development mode. Falling back to default renderer metadata.",t)}const nt=R({afterActiveInstanceBlur(){},appendChild:f,appendChildToContainer:f,appendInitialChild:f,beforeActiveInstanceBlur(){},cancelCallback:G,cancelTimeout:clearTimeout,clearContainer:()=>!1,commitTextUpdate(t,e,r){m(t,r)},commitUpdate(t,e,r,s){g&&t.internal_static&&(g.isStaticDirty=!0);const l=N(r,s),a=N(r.style,s.style);if(!l&&!a)return;let i=!!a;if(l){for(const[o,c]of Object.entries(l))if(o!=="children"){if(o==="style"){T(t,c);continue}if(o==="internal_transform"){t.internal_transform=c,i=!0;continue}if(o==="internal_cursor"){t.internal_cursor=c,i=!0;continue}if(o==="internal_static"){t.internal_static=!0,i=!0;continue}if(o==="sticky"){t.internal_sticky=c,i=!0;continue}if(o==="internalStickyAlternate"){t.internal_stickyAlternate=c,i=!0;continue}if(o==="opaque"){t.internal_opaque=c,i=!0;continue}if(o==="scrollbar"){t.internal_scrollbar=c,i=!0;continue}if(o==="internal_terminalCursorFocus"){t.internal_terminalCursorFocus=c,i=!0;continue}if(o==="internal_terminalCursorPosition"){t.internal_terminalCursorPosition=c,i=!0;continue}if(o==="cachedRender"){t.cachedRender=c,i=!0;continue}I(t,o,c),i=!0}}a&&t.yogaNode&&C(t.yogaNode,a,s.style??{}),i&&p(t)},createInstance(t,e,r,s){if(s.isInsideText&&t==="ink-box")throw new Error("<Box> can’t be nested inside <Text> component");if(s.isInsideText&&t==="ink-cursor")throw new Error("<Cursor> can’t be nested inside <Text> component");const l=t==="ink-text"&&s.isInsideText?"ink-virtual-text":t,a=w(l);for(const[i,o]of Object.entries(e))if(i!=="children"){if(i==="style"){T(a,o),a.yogaNode&&C(a.yogaNode,o);continue}if(i==="internal_transform"){a.internal_transform=o;continue}if(i==="internal_cursor"){a.internal_cursor=o;continue}if(i==="internal_static"){g=r,a.internal_static=!0,r.isStaticDirty=!0,r.staticNode=a;continue}if(i==="sticky"){a.internal_sticky=o;continue}if(i==="internalStickyAlternate"){a.internal_stickyAlternate=o;continue}if(i==="opaque"){a.internal_opaque=o;continue}if(i==="scrollbar"){a.internal_scrollbar=o;continue}if(i==="internal_terminalCursorFocus"){a.internal_terminalCursorFocus=o;continue}if(i==="internal_terminalCursorPosition"){a.internal_terminalCursorPosition=o;continue}if(i==="internal_static"){a.internal_static=!0;continue}if(i==="cachedRender"){a.cachedRender=o;continue}I(a,i,o)}return a},createTextInstance(t,e,r){if(!r.isInsideText)throw new Error(`Text string "${t}" must be rendered inside <Text> component`);return v(t)},detachDeletedInstance(){},finalizeInitialChildren(){return!1},getChildHostContext(t,e){const r=t.isInsideText,s=e==="ink-text"||e==="ink-virtual-text";return r===s?t:{isInsideText:s}},getCurrentUpdatePriority:()=>u,getInstanceFromNode:()=>null,getInstanceFromScope:()=>null,getPublicInstance:t=>t,getRootHostContext:()=>({isInsideText:!1}),hideInstance(t){t.internal_hidden=!0,t.yogaNode?.setDisplay(n.DISPLAY_NONE),p(t)},hideTextInstance(t){m(t,"")},HostTransitionContext:L(null),insertBefore:_,insertInContainerBefore:_,isPrimaryRenderer:!0,maySuspendCommit(){return!0},noTimeout:-1,NotPendingTransition:void 0,now:O,preloadInstance(){return!0},prepareForCommit:()=>null,preparePortalMount:()=>null,prepareScopeUpdate(){},removeChild(t,e){h(t,e),E(e)},removeChildFromContainer(t,e){h(t,e),E(e)},rendererPackageName:d.name,rendererVersion:d.version,requestPostPaintCallback(){},resetAfterCommit(t){if(typeof t.onComputeLayout=="function"&&t.onComputeLayout(),F(t),t.staticNode!==t.previousStaticNode&&(t.previousStaticNode=t.staticNode,typeof t.onStaticChange=="function"&&t.onStaticChange()),t.isStaticDirty){t.isStaticDirty=!1,typeof t.onImmediateRender=="function"&&t.onImmediateRender();return}typeof t.onRender=="function"&&t.onRender()},resetFormInstance(){},resetTextContent(){},resolveEventTimeStamp(){return-1.1},resolveEventType(){return null},resolveUpdatePriority(){return u!==A?u:b},scheduleCallback:D,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(t){u=t},shouldAttemptEagerTransition(){return!1},shouldSetTextContent:()=>!1,shouldYield:P,startSuspendingCommit(){},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance(){},trackSchedulerEvent(){},unhideInstance(t){t.internal_hidden=!1,t.yogaNode?.setDisplay(n.DISPLAY_FLEX),p(t)},unhideTextInstance(t,e){m(t,e)},waitForCommitToBeReady(){return null}});export{C as c,nt as j};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import{createRequire as Le}from"node:module";import{jsx as _}from"react/jsx-runtime";import{cursorShow as ot,setMode as le,BracketedPasteMode as de,resetMode as ce,eraseLines as G,cursorHide as nt,cursorUp as Vt,cursorNextLine as We,cursorTo as $e,eraseLineEnd as Ae,createDecMode as Be,ALT_SCREEN_ON as Xt,clearScreenAndHomeCursor as He,ALT_SCREEN_OFF as Jt}from"@visulima/ansi";import{wordWrap as Ge}from"@visulima/string";import{ConcurrentRoot as Ke,LegacyRoot as Ye}from"react-reconciler/constants.js";import U from"yoga-layout";import{a as Fe}from"./accessibility-context-DDyHTwmA.js";import{useState as ct,useRef as I,useCallback as v,useEffect as ht,useMemo as B}from"react";import{e as qe}from"./animation-context-DW3p-vpk.js";import{e as ze}from"./app-context-DTm1_XBA.js";import{o as Ve}from"./cursor-context-CFviBqPX.js";import Xe from"../components/error-boundary.js";import{o as Je}from"./focus-context-CsT69klR.js";import{t as Qe}from"./stderr-context-CR2LLec6.js";import{e as Ze}from"./stdin-context-BjMA9Sbi.js";import{t as ti}from"./stdout-context-DAAlQct2.js";import{I as ei,_ as ii,r as si,H as ri}from"./renderer-Cs0KEr1o.js";import{c as oi,e as ni}from"./dom-rphpG0kf.js";import{resolveFlags as Qt}from"./kittyFlags-g8ALyoCU.js";import{buildReturnToBottomPrefix as mt,buildCursorSuffix as st,buildCursorOnlySequence as he,cursorPositionChanged as gt,buildCursorShapeSequence as Zt}from"./buildCursorOnlySequence-CerkmjWt.js";import{p as ui}from"./load-native-root-binding-CxJnHcac.js";import{a as ai}from"./measure-text-B7juNq4Y.js";import{j as k,c as li}from"./reconciler-DkwOtC5B.js";import{measureAndExtractObservers as di}from"./ResizeObserver-BI9bDy-j.js";import{calculateScroll as ci}from"./calculateScroll-D4Y_JR4H.js";import{g as q}from"./utils-CVgM8kTn.js";let _e;const De=i=>(_e??=Le(import.meta.url))(i),X=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,vt=i=>{if(typeof X<"u"&&X.versions&&X.versions.node){const[t,e]=X.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return X.getBuiltinModule(i)}return De(i)},P=X,{env:yt}=P,{PassThrough:qt,Stream:Me}=vt("node:stream"),{Buffer:zt}=vt("node:buffer"),{Console:Ue}=vt("node:console"),{EventEmitter:je}=vt("node:events"),te=i=>i in yt&&yt[i]!=="0"&&yt[i]!=="false",fe=te("CI")||te("CONTINUOUS_INTEGRATION"),ee=["assert","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"];let xt={};const hi=i=>{const t=new qt,e=new qt;t.write=r=>{i("stdout",r)},e.write=r=>{i("stderr",r)};const s=new console.Console(t,e);for(const r of ee)xt[r]=console[r],console[r]=s[r];return()=>{for(const r of ee)console[r]=xt[r];xt={}}},J=[];J.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&J.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&J.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const pt=i=>!!i&&!0&&typeof i.removeListener=="function"&&typeof i.emit=="function"&&typeof i.reallyExit=="function"&&typeof i.listeners=="function"&&typeof i.kill=="function"&&typeof i.pid=="number"&&typeof i.on=="function",Tt=Symbol.for("signal-exit emitter"),St=globalThis,fi=Object.defineProperty.bind(Object);let pi=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(St[Tt])return St[Tt];fi(St,Tt,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,e){this.listeners[t].push(e)}removeListener(t,e){const s=this.listeners[t],r=s.indexOf(e);r!==-1&&(r===0&&s.length===1?s.length=0:s.splice(r,1))}emit(t,e,s){if(this.emitted[t])return!1;this.emitted[t]=!0;let r=!1;for(const n of this.listeners[t])r=n(e,s)===!0||r;return t==="exit"&&(r=this.emit("afterExit",e,s)||r),r}},pe=class{};const mi=i=>({onExit(t,e){return i.onExit(t,e)},load(){return i.load()},unload(){return i.unload()}});class gi extends pe{onExit(){return()=>{}}load(){}unload(){}}let wi=class extends pe{#n=Et.platform==="win32"?"SIGINT":"SIGHUP";#e=new pi;#t;#r;#o;#s={};#i=!1;constructor(t){super(),this.#t=t,this.#s={};for(const e of J)this.#s[e]=()=>{const s=this.#t.listeners(e);let{count:r}=this.#e;const n=t;if(typeof n.__signal_exit_emitter__=="object"&&typeof n.__signal_exit_emitter__.count=="number"&&(r+=n.__signal_exit_emitter__.count),s.length===r){this.unload();const l=this.#e.emit("exit",null,e),o=e==="SIGHUP"?this.#n:e;l||t.kill(t.pid,o)}};this.#o=t.reallyExit,this.#r=t.emit}onExit(t,e){if(!pt(this.#t))return()=>{};this.#i===!1&&this.load();const s=e?.alwaysLast?"afterExit":"exit";return this.#e.on(s,t),()=>{this.#e.removeListener(s,t),this.#e.listeners.exit.length===0&&this.#e.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#i){this.#i=!0,this.#e.count+=1;for(const t of J)try{const e=this.#s[t];e&&this.#t.on(t,e)}catch{}this.#t.emit=(t,...e)=>this.#a(t,...e),this.#t.reallyExit=t=>this.#u(t)}}unload(){this.#i&&(this.#i=!1,J.forEach(t=>{const e=this.#s[t];if(!e)throw new Error("Listener not defined for signal: "+t);try{this.#t.removeListener(t,e)}catch{}}),this.#t.emit=this.#r,this.#t.reallyExit=this.#o,this.#e.count-=1)}#u(t){return pt(this.#t)?(this.#t.exitCode=t||0,this.#e.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#a(t,...e){const s=this.#r;if(t==="exit"&&pt(this.#t)){typeof e[0]=="number"&&(this.#t.exitCode=e[0]);const r=s.call(this.#t,t,...e);return this.#e.emit("exit",this.#t.exitCode,null),r}else return s.call(this.#t,t,...e)}};const Et=globalThis.process,{onExit:vi}=mi(pt(Et)?new wi(Et):new gi),me="\x1B[200~",ie="\x1B[201~",bi=i=>i>=48&&i<=63,yi=i=>i>=32&&i<=47,ge=i=>i>=64&&i<=126,xi=(i,t,e)=>{const s=t+e+1;let r=s;for(;r<i.length;r++){const n=i.codePointAt(r);if(n===void 0)return"pending";if(!(bi(n)||yi(n))&&!(n===91&&r===s))return ge(n)?{nextIndex:r+1,sequence:i.slice(t,r+1)}:void 0}return"pending"},Ti=(i,t,e)=>{const s=t+e+2;if(s>i.length)return"pending";const r=i.codePointAt(s-1);if(!(r===void 0||!ge(r)))return{nextIndex:s,sequence:i.slice(t,s)}},se=(i,t,e)=>{const s=i[t+e];if(s===void 0)return"pending";if(s==="[")return xi(i,t,e);if(s==="O")return Ti(i,t,e)},Si=(i,t)=>{const e=i.codePointAt(t+1),s=e!==void 0&&e>65535?2:1,r=t+1+s;return{nextIndex:r,sequence:i.slice(t,r)}},Ri=(i,t)=>{if(t===i.length-1)return"pending";if(i[t+1]==="\x1B"){if(t+2>=i.length)return"pending";const s=se(i,t,2);return s==="pending"?"pending":s||{nextIndex:t+2,sequence:i.slice(t,t+2)}}const e=se(i,t,1);return e==="pending"?"pending":e||Si(i,t)},re=(i,t)=>{let e=0;for(let s=0;s<i.length;s++){const r=i[s];(r===""||r==="\b")&&(s>e&&t.push(i.slice(e,s)),t.push(r),e=s+1)}e<i.length&&t.push(i.slice(e))},Ci=i=>{const t=[];let e=0;const s=r=>({events:t,pending:i.slice(r)});for(;e<i.length;){const r=i.indexOf("\x1B",e);if(r===-1)return re(i.slice(e),t),{events:t,pending:""};r>e&&re(i.slice(e,r),t);const n=Ri(i,r);if(n==="pending")return s(r);if(n.sequence===me){const l=n.nextIndex,o=i.indexOf(ie,l);if(o===-1)return s(r);t.push({paste:i.slice(l,o)}),e=o+ie.length;continue}t.push(n.sequence),e=n.nextIndex}return{events:t,pending:""}},Ei=()=>{let i="";return{flushPendingEscape(){if(!i.startsWith("\x1B"))return;const t=i;return i="",t},hasPendingEscape(){return i.startsWith("\x1B")&&!i.startsWith(me)&&i!=="\x1B[200"},push(t){const e=Ci(i+t);return i=e.pending,e.events},reset(){i=""}}},Oi=" ",Pi="\x1B[Z",Ni="\x1B",oe=le(de),Rt=ce(de),we=({children:i,exitOnCtrlC:t,interactive:e,onExit:s,onRegisterInputControl:r,onSuspendTerminal:n,onWaitUntilRenderFlush:l,renderThrottleMs:o,setCursorPosition:a,stderr:f,stdin:h,stdout:m,writeToStderr:w,writeToStdout:d})=>{const[c,b]=ct(!0),[y,R]=ct(void 0),[,T]=ct([]),D=I(0),N=I(new Map),W=I(void 0),C=I(0),E=I(!1),M=I(0),[x]=ct(()=>{const u=new je;return u.setMaxListeners(1/0),u}),$=I(void 0),Q=I(void 0);Q.current??=Ei();const Z=I(void 0),Pt=I(!1),Te=20,K=v(()=>{Z.current&&(clearTimeout(Z.current),Z.current=void 0)},[]),Y=v(()=>{W.current&&(clearTimeout(W.current),W.current=void 0)},[]),ut=v(()=>{if(Y(),N.current.size===0)return;let u=Number.POSITIVE_INFINITY;for(const g of N.current.values())u=Math.min(u,g.nextDueTime);const p=Math.max(0,u-performance.now());W.current=setTimeout(()=>{W.current=void 0;const g=performance.now(),S=[...N.current.values()];for(const O of S){if(g<O.nextDueTime)continue;O.callback(g);const Ie=g-O.startTime,ke=Math.floor(Ie/O.interval)+1;O.nextDueTime=O.startTime+ke*O.interval}ut()},p)},[Y]),Nt=v((u,p)=>{const g=performance.now();return N.current.set(u,{callback:u,interval:p,nextDueTime:g+p,startTime:g}),ut(),{startTime:g,unsubscribe(){if(N.current.delete(u),N.current.size===0){Y();return}ut()}}},[Y,ut]);ht(()=>()=>{Y()},[Y]);const L=h.isTTY,It=v(()=>{$.current&&(h.removeListener("readable",$.current),$.current=void 0)},[h]),F=v(()=>{Q.current?.reset(),K(),It()},[K,It]),j=v(()=>{E.current=!1,h.setRawMode(!1),h.unref(),C.current=0,F()},[h,F]),tt=v(u=>{L&&(C.current>0||E.current)&&j(),s(u)},[L,j,s]),kt=v(u=>{if(u.includes("")&&t){tt();return}u===Ni&&c&&R(p=>{if(!p)return p})},[t,tt,c]),et=v(u=>{kt(u),x.emit("input",u)},[kt,x]),Lt=v(()=>{K(),Z.current=setTimeout(()=>{Z.current=void 0;const u=Q.current.flushPendingEscape();u&&et(u)},Te)},[K,et]),bt=v(()=>{K();let u;for(;(u=h.read())!==null;){const p=Q.current.push(u);for(const g of p)if(typeof g=="string")et(g);else{if(x.listenerCount("paste")===0){Pt.current||(Pt.current=!0,w(`Warning: useInput() received bracketed paste because no usePaste() handler is active. This fallback is deprecated and will be removed in the next major version. Migrate paste handling to usePaste().
|
|
2
|
+
`)),et(g.paste);continue}x.emit("paste",g.paste)}}Q.current.hasPendingEscape()&&Lt()},[h,et,K,Lt,w,x]),at=v(()=>{$.current||($.current=bt,h.addListener("readable",bt))},[h,bt]),_t=v(u=>{if(!L)throw h===P.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
|
|
3
|
+
Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`):new Error(`Raw mode is not supported on the stdin provided to Ink.
|
|
4
|
+
Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(h.setEncoding("utf8"),u){if(C.current===0){const p=E.current;E.current=!1,p||(h.ref(),h.setRawMode(!0)),at()}C.current++;return}C.current!==0&&--C.current===0&&(F(),E.current=!0,queueMicrotask(()=>{E.current&&j()}))},[L,h,at,F,j]),Dt=v(u=>{if(m.isTTY){if(u){M.current===0&&m.write(oe),M.current++;return}M.current!==0&&--M.current===0&&m.write(Rt)}},[m]),Mt=I({bracketedPaste:!1,rawMode:!1}),Ut=v(()=>{const u=L&&(C.current>0||E.current),p=M.current>0;Mt.current={bracketedPaste:p,rawMode:u},p&&m.isTTY&&m.write(Rt),u&&(E.current=!1,F(),h.setRawMode(!1),h.unref())},[L,m,h,F]),Wt=v(()=>{const{bracketedPaste:u,rawMode:p}=Mt.current;p&&(h.ref(),h.setRawMode(!0),h.setEncoding("utf8"),at()),u&&m.isTTY&&m.write(oe)},[h,m,at]);ht(()=>{r(Ut,Wt)},[r,Ut,Wt]);const $t=v((u,p)=>{const g=u.findIndex(S=>S.id===p);for(let S=g+1;S<u.length;S++){const O=u[S];if(O?.isActive)return O.id}},[]),At=v((u,p)=>{const g=u.findIndex(S=>S.id===p);for(let S=g-1;S>=0;S--){const O=u[S];if(O?.isActive)return O.id}},[]),lt=v(()=>{T(u=>(R(p=>{const g=u.find(S=>S.isActive)?.id;return $t(u,p)??g}),u))},[$t]),dt=v(()=>{T(u=>(R(p=>{const g=u.findLast(S=>S.isActive)?.id;return At(u,p)??g}),u))},[At]);ht(()=>{const u=g=>{!c||D.current===0||(g===Oi&<(),g===Pi&&dt())};x.on("input",u);const p=x;return()=>{p.off("input",u)}},[c,lt,dt,x]);const Bt=v(()=>{b(!0)},[]),Ht=v(()=>{b(!1)},[]),Gt=v(u=>{T(p=>(p.some(g=>g?.id===u)&&R(u),p))},[]),Kt=v((u,{autoFocus:p})=>{T(g=>(D.current=g.length+1,[...g,{id:u,isActive:!0}])),p&&R(g=>g||u)},[]),Yt=v(u=>{R(p=>{if(p!==u)return p}),T(p=>{const g=p.filter(S=>S.id!==u);return D.current=g.length,g})},[]),Ft=v(u=>{T(p=>p.map(g=>g.id!==u?g:{id:u,isActive:!0}))},[]),jt=v(u=>{R(p=>{if(p!==u)return p}),T(p=>p.map(g=>g.id!==u?g:{id:u,isActive:!1}))},[]);ht(()=>()=>{const u=!m.destroyed&&!m.writableEnded;e&&u&&m.write(ot),L&&(C.current>0||E.current)&&j(),M.current>0&&(m.isTTY&&u&&m.write(Rt),M.current=0)},[m,L,j,e]);const Se=B(()=>({exit:tt,suspendTerminal:n,waitUntilRenderFlush:l}),[tt,n,l]),Re=B(()=>({internal_eventEmitter:x,internal_exitOnCtrlC:t,isRawModeSupported:L,setBracketedPasteMode:Dt,setRawMode:_t,stdin:h}),[h,_t,Dt,L,t,x]),Ce=B(()=>({stdout:m,write:d}),[m,d]),Ee=B(()=>({stderr:f,write:w}),[f,w]),Oe=B(()=>({setCursorPosition:a}),[a]),Pe=B(()=>({activate:Ft,activeId:y,add:Kt,deactivate:jt,disableFocus:Ht,enableFocus:Bt,focus:Gt,focusNext:lt,focusPrevious:dt,remove:Yt}),[y,Kt,Yt,Ft,jt,Bt,Ht,lt,dt,Gt]),Ne=B(()=>({renderThrottleMs:o,subscribe:Nt}),[Nt,o]);return _(ze.Provider,{value:Se,children:_(Ze.Provider,{value:Re,children:_(ti.Provider,{value:Ce,children:_(Qe.Provider,{value:Ee,children:_(Je.Provider,{value:Pe,children:_(qe.Provider,{value:Ne,children:_(Ve.Provider,{value:Oe,children:_(Xe,{onError:tt,children:i})})})})})})})})};we.displayName="InternalApp";const Ii=(i,t,e)=>{if(e<=0||!i.yogaNode)return"";const{yogaNode:s}=i,r=s.getComputedBorder(U.EDGE_LEFT),n=s.getComputedBorder(U.EDGE_RIGHT),l=s.getComputedBorder(U.EDGE_TOP),o=s.getComputedPadding(U.EDGE_LEFT),a=s.getComputedPadding(U.EDGE_RIGHT),f=s.getComputedPadding(U.EDGE_TOP),h=Math.round(s.getComputedWidth()-r-n-o-a);if(h<=0)return"";const m=new ei({height:e,width:h}),w=-(i.internal_scrollState?.scrollLeft??0)-r-o,d=-t-l-f;for(const c of i.childNodes)ii(c,m,{absoluteOffsetX:w,absoluteOffsetY:d,offsetX:w,offsetY:d,skipStaticElements:!1});return m.get().output},Ot=new WeakMap,z=i=>i??"default",ve=()=>{let i,t;return{consumeDelta:()=>{if(z(t)===z(i))return"";const e=z(t);return i=t,Zt(e)},consumeRestoreOnDone:()=>{const e=z(i)!=="default";return i=void 0,t=void 0,e?Zt("default"):""},isDirty:()=>z(t)!==z(i),setPending:e=>{t=e}}},rt=(i,t)=>t.endsWith(`
|
|
5
|
+
`)?i.length-1:i.length,be=i=>i.rows||1/0,wt=(i,t)=>Math.min(i,be(t)),ki=(i,{showCursor:t=!1}={})=>{let e=0,s="",r=!1,n,l=!1,o,a=!1;const f=ve(),h=()=>l?n:void 0,m=(d,c)=>{const b=gt(c,o);return d!==s||b||f.isDirty()},w=d=>{!t&&!r&&(i.write(nt),r=!0);const c=h();l=!1;const b=gt(c,o);if(!m(d,c))return!1;const y=f.consumeDelta(),R=d.split(`
|
|
6
|
+
`),T=rt(R,d),D=st(T,c);if(d===s&&b)i.write(y+he({cursorPosition:c,cursorWasShown:a,previousCursorPosition:o,previousLineCount:e,visibleLineCount:T}));else if(d===s&&y!=="")i.write(y);else{s=d;const N=mt(a,e,o);i.write(y+N+G(wt(e,i))+d+D),e=R.length}return o=c?{...c}:void 0,a=c!==void 0,!0};return w.clear=()=>{const d=mt(a,e,o);i.write(d+G(wt(e,i))),s="",e=0,o=void 0,a=!1},w.done=()=>{s="",e=0,o=void 0,a=!1;const d=f.consumeRestoreOnDone();d!==""&&i.write(d),t||(i.write(ot),r=!1)},w.reset=()=>{s="",e=0,o=void 0,a=!1},w.sync=d=>{const c=l?n:void 0;l=!1;const b=d.split(`
|
|
7
|
+
`);s=d,e=b.length;const y=f.consumeDelta();y!==""&&i.write(y),!c&&a&&i.write(nt),c&&i.write(st(rt(b,d),c)),o=c?{...c}:void 0,a=c!==void 0},w.setCursorPosition=d=>{n=d,l=!0},w.setCursorShape=f.setPending,w.isCursorDirty=()=>l||f.isDirty(),w.willRender=d=>m(d,h()),w},Li=(i,{showCursor:t=!1}={})=>{let e=[],s="",r=!1,n,l=!1,o,a=!1;const f=ve(),h=()=>l?n:void 0,m=(d,c)=>{const b=gt(c,o);return d!==s||b||f.isDirty()},w=d=>{!t&&!r&&(i.write(nt),r=!0);const c=h();l=!1;const b=gt(c,o);if(!m(d,c))return!1;const y=f.consumeDelta(),R=d.split(`
|
|
8
|
+
`),T=rt(R,d),D=rt(e,s);if(d===s&&b)return i.write(y+he({cursorPosition:c,cursorWasShown:a,previousCursorPosition:o,previousLineCount:e.length,visibleLineCount:T})),o=c?{...c}:void 0,a=c!==void 0,!0;if(d===s&&y!=="")return i.write(y),!0;const N=mt(a,e.length,o);if(d===`
|
|
9
|
+
`||s.length===0){const x=st(T,c);return i.write(y+N+G(wt(e.length,i))+d+x),a=c!==void 0,o=c?{...c}:void 0,s=d,e=R,!0}const W=d.endsWith(`
|
|
10
|
+
`),C=[y,N],E=be(i);if(T<D){const x=s.endsWith(`
|
|
11
|
+
`)?1:0;C.push(G(Math.min(D-T+x,E)),Vt(Math.min(T,E-1)))}else C.push(Vt(Math.min(D-1,E-1)));for(let x=0;x<T;x++){const $=x===T-1;if(R[x]===e[x]){(!$||W)&&C.push(We());continue}C.push($e(0)+R[x]+Ae+($&&!W?"":`
|
|
12
|
+
`))}const M=st(T,c);return C.push(M),i.write(C.join("")),a=c!==void 0,o=c?{...c}:void 0,s=d,e=R,!0};return w.clear=()=>{const d=mt(a,e.length,o);i.write(d+G(wt(e.length,i))),s="",e=[],o=void 0,a=!1},w.done=()=>{s="",e=[],o=void 0,a=!1;const d=f.consumeRestoreOnDone();d!==""&&i.write(d),t||(i.write(ot),r=!1)},w.reset=()=>{s="",e=[],o=void 0,a=!1},w.sync=d=>{const c=l?n:void 0;l=!1;const b=d.split(`
|
|
13
|
+
`);s=d,e=b;const y=f.consumeDelta();y!==""&&i.write(y),!c&&a&&i.write(nt),c&&i.write(st(rt(b,d),c)),o=c?{...c}:void 0,a=c!==void 0},w.setCursorPosition=d=>{n=d,l=!0},w.setCursorShape=f.setPending,w.isCursorDirty=()=>l||f.isDirty(),w.willRender=d=>m(d,h()),w},_i=(i,{incremental:t=!1,showCursor:e=!1}={})=>t?Li(i,{showCursor:e}):ki(i,{showCursor:e}),Di={create:_i},ye=Be(2026),H=le(ye),A=ce(ye);function Mi(i,t){return"isTTY"in i&&i.isTTY&&(t??!fe)}let V;const Ui=()=>{if(V!==!1){if(V!==void 0)return V;try{return V=ui(import.meta.url).Renderer,V}catch{V=!1;return}}},Wi=i=>{const t=Ui();if(!t)return;let e,s=0,r=0;const n=(l,o)=>{(!e||s!==l||r!==o)&&(e?e.resize(l,o):e=new t(l,o),s=l,r=o)};return{clear(){if(e){const l=new Uint32Array(s*r*2),o=65535;for(let a=0;a<l.length;a+=2)l[a]=32,l[a+1]=o;e.render(l)}},destroy(){e=void 0},render(l,o,a){if(n(o,a),!!e){i.isTTY&&e.writeRaw(H);try{e.render(l)}finally{i.isTTY&&e.writeRaw(A)}}},resize(l,o){n(l,o)}}};function ne(i,t=0,e={}){const s=e.leading??!0,r=e.trailing??!0;let n,l,o,a;const f=()=>{if(l===void 0)return;const c=l;l=void 0,a=i(...c)},h=()=>{n!==void 0&&(clearTimeout(n),n=void 0)},m=()=>{n=void 0,r&&f(),l=void 0,o=void 0},w=()=>{h(),n=setTimeout(m,t)},d=function(...c){const b=Date.now();if(o??=b,b-o>=t)return l=c,f(),o=b,w(),a;l=c;const y=n===void 0;return w(),s&&y&&f(),a};return d.cancel=()=>{h(),l=void 0,o=void 0},d.flush=()=>(h(),f(),o=void 0,a),d}console.Console||(console.Console=Ue);const it=()=>{},ue=async()=>new Promise(i=>{setImmediate(i)}),$i=27,Ai=91,Bi=63,Hi=117,Gi=48,Ki=57,Yi=i=>i>=Gi&&i<=Ki,xe=(i,t)=>{if(i[t]!==$i||i[t+1]!==Ai||i[t+2]!==Bi)return;let e=t+3;const s=e;for(;e<i.length&&Yi(i[e]);)e++;if(e!==s){if(e===i.length)return{state:"partial"};if(i[e]===Hi)return{endIndex:e,state:"complete"}}},Fi=i=>{for(let t=0;t<i.length;t++)if(xe(i,t)?.state==="complete")return!0;return!1},ji=i=>{const t=[];let e=0;for(;e<i.length;){const s=xe(i,e);if(s?.state==="complete"){e=s.endIndex+1;continue}if(s?.state==="partial")break;t.push(i[e]),e++}return t},qi=({isTty:i,isUnmounting:t,isWindows:e,nextOutputHeight:s,previousOutputHeight:r,viewportRows:n})=>{if(!i)return!1;const l=r>0,o=r>=n,a=s>=n,f=r>n,h=s>n,m=o&&s<n;return f||h&&l||m||t&&o||e&&(a||o)},Ct=i=>i instanceof Error||Object.prototype.toString.call(i)==="[object Error]",ae=i=>{const t=!i.destroyed&&!i.writableEnded&&(i.writable??!0),e=i._writableState!==void 0||i.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:e}},ft=(i,t)=>{if(!i||typeof i.flush!="function")return;const e=i;t?e.flush():typeof e.cancel=="function"&&e.cancel()};class zi{isConcurrent;options;log;manualCursorPosition;renderedCursorPosition;renderedCursorRequested;throttledLog;isScreenReaderEnabled;interactive;renderThrottleMs;alternateScreen;isUnmounted;isUnmounting;lastOutput;lastOutputToRender;lastOutputHeight;lastTerminalWidth;nativeLog;useNativeRenderer;container;rootNode;fullStaticOutput;backbufferNode;backbufferMultiWarned=!1;exitPromise;exitResult;beforeExitHandler;restoreConsole;unsubscribeResize;throttledOnRender;hasPendingThrottledRender=!1;kittyProtocolEnabled=!1;kittyFlags;isSuspended=!1;pauseInput;resumeInput;cancelKittyDetection;nextRenderCommit;deferredInitDone=!1;constructor(t){this.options=t,this.rootNode=oi("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??P.env.INK_SCREEN_READER==="true",this.interactive=this.resolveInteractiveOption(t.interactive),this.alternateScreen=!1;const e=t.debug||this.isScreenReaderEnabled,s=t.maxFps??30,r=s>0?Math.max(1,Math.ceil(1e3/s)):0;this.renderThrottleMs=e?0:r;const n=e?this.onRender:(()=>{const o=ne(this.onRender,r,{leading:!0,trailing:!0});return this.throttledOnRender=o,()=>{this.hasPendingThrottledRender=!0,o()}})();if(e&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let o=!1;const a=()=>{o||(o=!0,queueMicrotask(()=>{o=!1,this.onRender()}))};this.rootNode.onRender=a,this.rootNode.onImmediateRender=a}else this.rootNode.onRender=n,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=Di.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=Wi(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=e?this.log:ne(o=>{const a=this.log.willRender(o),f=this.shouldSync();f&&a&&this.options.stdout.write(H),this.log(o),f&&a&&this.options.stdout.write(A)},void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.isUnmounting=!1,this.isConcurrent=t.concurrent??!1,this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.lastTerminalWidth=q(this.options.stdout).columns,this.fullStaticOutput="";const l=t.concurrent?Ke:Ye;this.container=k.createContainer(this.rootNode,l,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=vi(this.unmount,{alwaysLast:!1}),this.setAlternateScreen(!!t.alternateScreen),t.patchConsole&&this.patchConsole(),this.interactive&&(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)}),this.initImmediateKittyKeyboard(),P.env.DEV==="true"&&k.injectIntoDevTools(),this.exitPromise=new Promise((o,a)=>{this.resolveExitPromise=o,this.rejectExitPromise=a}),this.exitPromise.catch(it)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=()=>{const t=q(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),ai(),this.calculateLayout(),ni(this.rootNode),this.onRender(),this.lastTerminalWidth=t};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};handleAppExit=t=>{if(!(this.isUnmounted||this.isUnmounting)){if(Ct(t)){this.unmount(t);return}this.exitResult=t,this.unmount()}};getActiveCursorPosition=()=>this.renderedCursorRequested?this.renderedCursorPosition:this.manualCursorPosition;setCursorPosition=t=>{this.manualCursorPosition=t,this.log.setCursorPosition(this.getActiveCursorPosition())};restoreLastOutput=()=>{this.interactive&&(this.log.setCursorPosition(this.getActiveCursorPosition()),this.log(this.lastOutputToRender||`${this.lastOutput}
|
|
14
|
+
`))};calculateLayout=()=>{const t=s=>{const r=new Map;this.calculateScrollAndTriggerObservers(s,r);for(const[n,l]of r)n.internalTrigger(l)};this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const e=q(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(e),this.rootNode.yogaNode.calculateLayout(void 0,void 0,U.DIRECTION_LTR),t(this.rootNode)};calculateScrollAndTriggerObservers(t,e){if(t.nodeName==="ink-box"){const{style:s}=t,r=s.overflow??"visible",n=s.overflowX??r,l=s.overflowY??r;n==="scroll"||l==="scroll"?(ci(t),s.overflowToBackbuffer&&(this.backbufferNode&&this.backbufferNode!==t&&!this.backbufferMultiWarned&&(this.backbufferMultiWarned=!0,console.warn("[@visulima/tui] Multiple scrollable regions have `overflowToBackbuffer` enabled; only one is supported. The last one in render order wins.")),this.backbufferNode=t)):t.internal_scrollState&&delete t.internal_scrollState}if(di(t,e),!t.internal_static)for(const s of t.childNodes)s.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(s,e)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,e){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),li(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let s=0;for(const r of t.childNodes){const n=r;r.nodeName!=="#text"&&n.yogaNode&&(t.yogaNode.insertChild(n.yogaNode,s),s++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const s of t.childNodes)s.nodeName!=="#text"&&this.prepareYogaTree(s,e);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const s=q(this.options.stdout).columns,{width:r}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof r=="number"?r:s),t.yogaNode.calculateLayout(void 0,void 0,U.DIRECTION_LTR)),e(t),si(t,{skipStaticElements:!1}),t.internal_onRendered?.()}}markAllTextNodesDirty(t){if(!t.cachedRender){t.nodeName==="ink-text"&&t.yogaNode&&t.yogaNode.markDirty();for(const e of t.childNodes)e.nodeName!=="#text"&&this.markAllTextNodesDirty(e)}}handleStaticChange=()=>{this.fullStaticOutput=""};computeBackbufferOutput(){const t=this.backbufferNode;if(!t?.internal_scrollState||!this.interactive||!this.options.stdout.isTTY||this.alternateScreen||this.isScreenReaderEnabled||this.options.debug)return"";const e=Math.round(t.internal_scrollState.scrollTop),s=t.yogaNode?.getComputedPadding(U.EDGE_TOP)??0,r=Math.max(0,e-Math.round(s)),n=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:l}=t.style,o=l===void 0?n:Math.max(n,r-Math.max(0,l)),a=r-o;if(a<=0)return"";const f=Ii(t,o,a);return f===""?"":(t.internal_maxPushedScrollTop=r,`${f}\x1B[0m
|
|
15
|
+
`)}onRender=()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=ri(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:e,cursorRequested:s,cursorShape:r,output:n,outputBuffer:l,outputHeight:o,outputWidth:a,staticOutput:f}=t;this.renderedCursorRequested=s,this.renderedCursorPosition=e,this.log.setCursorShape(s?r:void 0);const h=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&l&&a){f&&f!==`
|
|
16
|
+
`&&this.options.stdout.write(f),h&&this.options.stdout.write(h),this.nativeLog.render(l,a,o),this.lastOutputHeight=o;return}s&&this.log.setCursorPosition(this.getActiveCursorPosition());const m=f&&f!==`
|
|
17
|
+
`;if(this.options.debug){m&&(this.fullStaticOutput+=f),this.lastOutput=n,this.lastOutputToRender=n,this.lastOutputHeight=o,this.options.stdout.write(this.fullStaticOutput+n);return}if(!this.interactive){m&&this.options.stdout.write(f),this.lastOutput=n,this.lastOutputToRender=`${n}
|
|
18
|
+
`,this.lastOutputHeight=o;return}if(this.isScreenReaderEnabled){const w=this.shouldSync();if(w&&this.options.stdout.write(H),m){const b=this.lastOutputHeight>0?G(this.lastOutputHeight):"";this.options.stdout.write(b+f),this.lastOutputHeight=0}if(n===this.lastOutput&&!m){w&&this.options.stdout.write(A);return}const d=q(this.options.stdout).columns,c=Ge(n,{trim:!1,width:d,wrapMode:"BREAK_WORDS"}).replace(/\n$/,"");if(m)this.options.stdout.write(c);else{const b=this.lastOutputHeight>0?G(this.lastOutputHeight):"";this.options.stdout.write(b+c)}this.lastOutput=n,this.lastOutputToRender=c,this.lastOutputHeight=c===""?0:c.split(`
|
|
19
|
+
`).length,w&&this.options.stdout.write(A);return}m&&(this.fullStaticOutput+=f),this.renderInteractiveFrame(n,o,m?f:"",h)};accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const e=_(Fe.Provider,{value:this.accessibilityContextValue,children:_(we,{exitOnCtrlC:this.options.exitOnCtrlC,interactive:this.interactive,onExit:this.handleAppExit,onRegisterInputControl:this.registerInputControl,onSuspendTerminal:this.suspendTerminal,onWaitUntilRenderFlush:this.waitUntilRenderFlush,renderThrottleMs:this.renderThrottleMs,setCursorPosition:this.setCursorPosition,stderr:this.options.stderr,stdin:this.options.stdin,stdout:this.options.stdout,writeToStderr:this.writeToStderr,writeToStdout:this.writeToStdout,children:t})});this.options.concurrent?k.updateContainer(e,this.container,null,it):(k.updateContainerSync(e,this.container,null,it),k.flushSyncWork())}writeToStdout=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stdout.write(t);return}const e=this.shouldSync();e&&this.options.stdout.write(H),this.log.clear(),this.options.stdout.write(t),this.restoreLastOutput(),e&&this.options.stdout.write(A)};writeToStderr=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stderr.write(t);return}const e=this.shouldSync();e&&this.options.stdout.write(H),this.log.clear(),this.options.stderr.write(t),this.restoreLastOutput(),e&&this.options.stdout.write(A)};unmount=t=>{if(this.isUnmounted||this.isUnmounting)return;this.isUnmounting=!0,this.beforeExitHandler&&(P.off("beforeExit",this.beforeExitHandler),this.beforeExitHandler=void 0);const e=this.options.stdout,{canWriteToStdout:s,hasWritableState:r}=ae(e);ft(this.throttledOnRender,s),s&&!this.alternateScreen&&(!this.throttledOnRender||!this.hasPendingThrottledRender&&this.fullStaticOutput==="")&&(this.calculateLayout(),this.onRender()),this.isUnmounted=!0,this.unsubscribeExit(),ft(this.throttledLog,s),typeof this.restoreConsole=="function"&&this.restoreConsole();const n=()=>{typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),this.cancelKittyDetection&&this.cancelKittyDetection(),s&&(this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen?(this.log.clear(),this.log.done(),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.fullStaticOutput="",this.writeBestEffort(this.options.stdout,Jt),this.writeBestEffort(this.options.stdout,ot),this.alternateScreen=!1):this.interactive?this.options.debug||this.log.done():this.options.stdout.write(this.options.debug?`
|
|
20
|
+
`:`${this.lastOutput}
|
|
21
|
+
`)),this.kittyProtocolEnabled=!1,Ot.delete(this.options.stdout);const{exitResult:o}=this,a=()=>{Ct(t)?this.rejectExitPromise(t):this.resolveExitPromise(o)};t!==void 0&&!Ct(t)?a():s&&r?this.options.stdout.write("",a):setImmediate(a)},l=k;this.options.concurrent?(k.updateContainerSync(null,this.container,null,it),k.flushSyncWork(),l.flushPassiveEffects?.(),n()):(k.updateContainerSync(null,this.container,null,it),k.flushSyncWork(),n())};async waitUntilExit(){return this.beforeExitHandler||(this.beforeExitHandler=()=>{this.unmount()},P.on("beforeExit",this.beforeExitHandler)),this.exitPromise}async waitUntilRenderFlush(){if(this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(await ue(),this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(this.isConcurrent&&this.hasPendingConcurrentWork()&&(await Promise.race([this.awaitNextRender(),this.awaitExit()]),this.isUnmounted||this.isUnmounting)){this.nextRenderCommit=void 0,await this.awaitExit();return}k.flushSyncWork();const t=this.options.stdout,{canWriteToStdout:e,hasWritableState:s}=ae(t);if(ft(this.throttledOnRender,e),ft(this.throttledLog,e),e&&s){await new Promise(r=>{this.options.stdout.write("",()=>{r()})});return}await ue()}clear(){this.interactive&&!this.options.debug&&(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
|
|
22
|
+
`))}patchConsole(){this.options.debug||(this.restoreConsole=hi((t,e)=>{t==="stdout"&&this.writeToStdout(e),t==="stderr"&&(e.startsWith("The above error occurred")||this.writeToStderr(e))}))}setAlternateScreen(t){this.alternateScreen=this.resolveAlternateScreenOption(t,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,Xt),this.writeBestEffort(this.options.stdout,nt))}resolveInteractiveOption(t){return t??(!fe&&!!this.options.stdout.isTTY)}resolveAlternateScreenOption(t,e){return!!t&&e&&!!this.options.stdout.isTTY}shouldSync(){return Mi(this.options.stdout,this.interactive)}writeBestEffort(t,e){try{t.write(e)}catch{}}async awaitExit(){try{await this.exitPromise}catch{}}hasPendingConcurrentWork(){const t=this.container;return(t.pendingLanes??0)!==0&&t.callbackNode!==void 0&&t.callbackNode!==null}async awaitNextRender(){if(!this.nextRenderCommit){let t;const e=new Promise(s=>{t=s});this.nextRenderCommit={promise:e,resolve:t}}return this.nextRenderCommit.promise}renderInteractiveFrame(t,e,s,r=""){const n=s+r,l=n!=="",o=this.options.stdout.isTTY,a=o?q(this.options.stdout).rows:24,f=o&&e>=a,h=f?t:`${t}
|
|
23
|
+
`,m=P.platform==="win32",w=o&&m&&(f||this.lastOutputHeight>=a);if(qi({isTty:o,isUnmounting:this.isUnmounting,isWindows:m,nextOutputHeight:e,previousOutputHeight:this.lastOutputHeight,viewportRows:a})){if(this.options.incrementalRendering&&!w){l&&(this.log.clear(),this.options.stdout.write(n)),(t!==this.lastOutput||this.log.isCursorDirty()||l)&&this.throttledLog(h),this.lastOutput=t,this.lastOutputToRender=h,this.lastOutputHeight=e;return}const d=this.shouldSync();d&&this.options.stdout.write(H),this.options.stdout.write(He+this.fullStaticOutput+r+t),this.lastOutput=t,this.lastOutputToRender=h,this.lastOutputHeight=e,this.log.sync(h),d&&this.options.stdout.write(A);return}if(l){const d=this.shouldSync();d&&this.options.stdout.write(H),this.log.clear(),this.options.stdout.write(n),this.log(h),d&&this.options.stdout.write(A)}else(t!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(h);this.lastOutput=t,this.lastOutputToRender=h,this.lastOutputHeight=e}initImmediateKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="enabled")return;const e=t.flags??["disambiguateEscapeCodes"];this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(e)}initDeferredKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="auto")return;const e=t.flags??["disambiguateEscapeCodes"];!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(e)}confirmKittySupport(t){const{stdin:e,stdout:s}=this.options;let r=[];const n=()=>{this.cancelKittyDetection=void 0,clearTimeout(o),e.removeListener("data",l);const a=ji(r);r=[],a.length>0&&e.unshift(zt.from(a))},l=a=>{const f=typeof a=="string"?zt.from(a):a;for(const h of f)r.push(h);Fi(r)&&(n(),this.isUnmounted||this.enableKittyProtocol(t))};e.on("data",l);const o=setTimeout(n,200);this.cancelKittyDetection=n,s.write("\x1B[?u")}registerInputControl=(t,e)=>{this.pauseInput=t,this.resumeInput=e};suspendTerminal=(async t=>{if(this.beginSuspend(),t){try{await t()}finally{await this.endSuspend()}return}const e=async()=>{await this.endSuspend()};return{resume:e,[Symbol.asyncDispose]:e}});beginSuspend(){if(this.isSuspended)throw new Error("The terminal is already suspended. Resume the current suspension before suspending again.");if(this.isSuspended=!0,!(!this.interactive||this.isUnmounted||this.isUnmounting))try{this.log.clear(),this.log.done(),this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,Jt),this.writeBestEffort(this.options.stdout,ot)),this.pauseInput?.()}catch(t){this.isSuspended=!1;try{this.resumeInput?.()}catch{}throw t}}async endSuspend(){if(this.isSuspended&&(this.isSuspended=!1,this.resumeInput?.(),!(!this.interactive||this.isUnmounted||this.isUnmounting))){this.alternateScreen&&this.writeBestEffort(this.options.stdout,Xt),this.kittyProtocolEnabled&&this.kittyFlags&&this.writeBestEffort(this.options.stdout,`\x1B[>${Qt(this.kittyFlags)}u`),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.log.reset();try{this.calculateLayout(),this.onRender(),await this.waitUntilRenderFlush()}catch{}}}enableKittyProtocol(t){this.kittyFlags=t,this.options.stdout.write(`\x1B[>${Qt(t)}u`),this.kittyProtocolEnabled=!0}}const Es=(i,t)=>{const e={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:P.stderr,stdin:P.stdin,stdout:P.stdout,...Vi(t)},s=Xi(e.stdout,()=>new zi(e));return s.render(i),{cleanup(){s.unmount()},clear(){s.clear()},rerender(r){s.render(r)},rootNode:s.rootNode,unmount(){s.unmount()},waitUntilExit(){return s.waitUntilExit()},waitUntilRenderFlush(){return s.waitUntilRenderFlush()}}},Vi=(i={})=>i instanceof Me?{stdin:P.stdin,stdout:i}:i,Xi=(i,t)=>{const e=Ot.get(i);if(e===void 0){const s=t();return Ot.set(i,s),s}return P.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
|
|
24
|
+
`),e};export{Es as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import i from"react";import{FocusProvider as y,useFocusManager as W}from"./FocusContext-C2Sosxa4.js";import{TuiContext as I,useInput as z}from"./TuiContext-BNmP0lMY.js";import{LayoutNode as v}from"./LayoutNode-LPYsuzBg.js";import{T as f,s as P}from"./reconciler-ClpU7Y-V.js";import{renderTreeToBuffer as F}from"./renderTreeToBuffer-
|
|
1
|
+
import i from"react";import{FocusProvider as y,useFocusManager as W}from"./FocusContext-C2Sosxa4.js";import{TuiContext as I,useInput as z}from"./TuiContext-BNmP0lMY.js";import{LayoutNode as v}from"./LayoutNode-LPYsuzBg.js";import{T as f,s as P}from"./reconciler-ClpU7Y-V.js";import{renderTreeToBuffer as F}from"./renderTreeToBuffer-BpSD0sBJ.js";import{TuiApp as L}from"./TuiApp-CCVaiKbf.js";import{InputParser as T}from"./InputParser-CiBitCva.js";import{terminalSize as G}from"./Renderer-BeS49FNq.js";import{createInlineLoop as M}from"./createInlineLoop-DnEvE2eM.js";const R=n=>i.createElement("box",n,n.children),K=n=>i.createElement("text",n,n.children),Q=()=>i.createElement(R,{flexGrow:1}),b=({children:n})=>{const{disableFocus:c,enableFocus:e,focusNext:a,focusPrevious:o}=W();return z((w,s)=>{s.tab&&!s.shift&&a(),s.tab&&s.shift&&o(),s.escape&&(c(),e())}),i.createElement(i.Fragment,null,n)};function V(n,c){const e=new L,a=new T(process.stdin),o=new v,{height:w,width:s}=e.getSize();o.yogaNode.setWidth(s),o.yogaNode.setHeight(w);const u=f.createContainer(o,0,null,!1,null,"",t=>console.error(t),null),p=t=>i.createElement(I.Provider,{value:{app:e,input:a,writeStderr:l=>e.writeStderr(l),writeStdout:l=>e.writeStdout(l)}},i.createElement(y,null,i.createElement(b,null,t)));f.updateContainer(p(n),u,null,()=>{});const h=(t,l)=>o.calculateLayout(t,l),x=(t,l,H)=>F(o,t,l,H),g=()=>e.paintNow(h,x);let S=!1;P(()=>{S=!0});const d=Math.round(1e3/(c?.maxFps??60)),E=setInterval(()=>{S&&(S=!1,g())},d);let N;const r=new Promise(t=>{N=t}),m=()=>{clearInterval(E),f.updateContainer(null,u,null,()=>{}),o.destroy(),e.stop(),a.stop(),process.off("SIGWINCH",C),N()};a.on("exit",()=>{m(),process.exit(0)}),e.on("quit",()=>{m(),process.exit(0)}),a.start(),e.start();const C=()=>{const t=process.stdout.columns||80,l=process.stdout.rows||24;e.resize(t,l),o.yogaNode.setWidth(t),o.yogaNode.setHeight(l),e.emit("resize"),g()};return process.on("SIGWINCH",C),g(),{app:e,input:a,rerender(t){f.updateContainer(p(t),u,null,()=>{})},unmount(){m()},waitUntilExit(){return r}}}function X(n,c){const e=G(),a=c?.rows??10,{cols:o}=e,w=Math.min(a,e.rows),s=new T(process.stdin),u=new v;u.yogaNode.setWidth(o),u.yogaNode.setHeight(w);const p=[],h=[],x={quit:()=>d.stop(),writeStderr:r=>h.push(r),writeStdout:r=>p.push(r)},g=f.createContainer(u,0,null,!1,null,"",r=>console.error(r),null),S=r=>i.createElement(I.Provider,{value:{app:x,input:s,writeStderr:x.writeStderr,writeStdout:x.writeStdout}},i.createElement(y,null,i.createElement(b,null,r)));f.updateContainer(S(n),g,null,()=>{}),P(()=>{});const d=M((r,m,C)=>{u.calculateLayout(m,C),F(u,r,m,C)},{...c,fps:c?.maxFps??c?.fps??60,rows:w});s.on("exit",()=>d.stop());let E;const N=new Promise(r=>{E=r});return process.on("exit",()=>{p.length>0&&process.stdout.write(p.join("")),h.length>0&&process.stderr.write(h.join("")),E()}),d.start(),s.start(),{unmount(){d.stop()},waitUntilExit(){return N}}}export{R as _Box,Q as _Spacer,K as _Text,V as render,X as renderInline};
|