@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,164 @@
|
|
|
1
|
+
# Migration Guide
|
|
2
|
+
|
|
3
|
+
This guide documents breaking changes and migration steps for the `@visulima/tui` package.
|
|
4
|
+
|
|
5
|
+
## Version 2.0.0
|
|
6
|
+
|
|
7
|
+
### Breaking Changes Summary
|
|
8
|
+
|
|
9
|
+
- **Component library moved**: every non-primitive component now lives in `@visulima/tui-kit`
|
|
10
|
+
- **`ws` removed**: the DevTools bridge uses the platform-native `WebSocket`
|
|
11
|
+
- **Unchanged**: the renderer, every hook, and the layout/text primitives
|
|
12
|
+
|
|
13
|
+
`@visulima/tui` keeps the runtime — the Ink-compatible renderer, the hooks, and the primitives every component is built on. Its direct dependencies drop from 13 to 3 (`@visulima/colorize`, `scheduler`, `yoga-layout`). If you only use `render`, `Box`, `Text` and the hooks, a dependency bump is the whole migration.
|
|
14
|
+
|
|
15
|
+
### Component library moved to `@visulima/tui-kit`
|
|
16
|
+
|
|
17
|
+
The 110+ higher-level components that lived under `@visulima/tui/components/*` moved to a new package, shipped both as an installable library and as a shadcn-style copy-paste registry.
|
|
18
|
+
|
|
19
|
+
#### Before (v1.x)
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { Accordion } from "@visulima/tui/components/accordion";
|
|
23
|
+
import { Spinner } from "@visulima/tui/components/spinner";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### After (v2.x)
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
pnpm add @visulima/tui-kit
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { Accordion } from "@visulima/tui-kit/accordion";
|
|
34
|
+
import { Spinner } from "@visulima/tui-kit/spinner";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or vendor the source into your own tree instead, with no runtime dependency on the library:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npx shadcn@latest add https://visulima.com/r/spinner.json
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The CLI writes the component to `@/components/ui/*`, puts shared helpers in `@/lib/*`, and pulls in whatever that component depends on. The full index is at [`https://visulima.com/r/registry.json`](https://visulima.com/r/registry.json).
|
|
44
|
+
|
|
45
|
+
#### Primitives that did **not** move
|
|
46
|
+
|
|
47
|
+
These stay in `@visulima/tui` — leave their imports alone:
|
|
48
|
+
|
|
49
|
+
`box` · `canvas` · `cursor` · `error-boundary` · `error-overview` · `newline` · `spacer` · `static` · `static-render` · `text` · `transform`
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// Still correct after upgrading:
|
|
53
|
+
import { Box } from "@visulima/tui/components/box";
|
|
54
|
+
import { Text } from "@visulima/tui/components/text";
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Automating the rewrite
|
|
58
|
+
|
|
59
|
+
The rule is mechanical — `@visulima/tui/components/<x>` becomes `@visulima/tui-kit/<x>` unless `<x>` is one of the 11 primitives above. This rewrites every moved import in place; the negative lookahead is what skips the primitives:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
# From your project root. Requires ripgrep + perl.
|
|
63
|
+
PRIM='box|canvas|cursor|error-boundary|error-overview|newline|spacer|static|static-render|text|transform'
|
|
64
|
+
rg -l "@visulima/tui/components/" --glob '*.{ts,tsx}' \
|
|
65
|
+
| xargs perl -i -pe "s{\@visulima/tui/components/(?!($PRIM)[\"'/])}{\@visulima/tui-kit/}g"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Without `perl`, two passes of your editor's regex find-and-replace do the same:
|
|
69
|
+
|
|
70
|
+
1. Replace `@visulima/tui/components/` with `@visulima/tui-kit/` across the project.
|
|
71
|
+
2. Undo the 11 that stayed: replace `@visulima/tui-kit/(box|canvas|cursor|error-boundary|error-overview|newline|spacer|static|static-render|text|transform)(["'/])` with `@visulima/tui/components/$1$2`. The trailing quote-or-slash matters — it stops `static` from also matching `static-render`, and `text` from matching `textarea`.
|
|
72
|
+
|
|
73
|
+
Run your type-checker afterwards either way. An unresolved import is a compile error, so nothing can rewrite silently wrong.
|
|
74
|
+
|
|
75
|
+
### `ws` is no longer an optional peer
|
|
76
|
+
|
|
77
|
+
`ws` only ever backed the React DevTools bridge, which now uses the native `WebSocket` available on the supported Node versions (`^22.14.0 || >=24.10.0`).
|
|
78
|
+
|
|
79
|
+
- If you installed `ws` explicitly to make DevTools work, remove it.
|
|
80
|
+
- If you never used DevTools, this changes nothing.
|
|
81
|
+
|
|
82
|
+
The rest of the dependency slimming needs no action — those libraries were either inlined or turned into optional peers you only pay for when using the feature that needs them.
|
|
83
|
+
|
|
84
|
+
### Why This Change?
|
|
85
|
+
|
|
86
|
+
The component library and the runtime have different audiences. Most consumers embed a renderer and a handful of primitives; they were paying for 110+ components and 13 dependencies to get them.
|
|
87
|
+
|
|
88
|
+
Splitting the two means:
|
|
89
|
+
|
|
90
|
+
- **A smaller install.** `@visulima/tui` now pulls 3 direct dependencies instead of 13.
|
|
91
|
+
- **Two ways to consume components.** `@visulima/tui-kit` is installable like any package, or copy-pasteable through its shadcn registry so you can own and edit the source.
|
|
92
|
+
- **Independent release cadence.** Component work no longer forces a version of the renderer, and vice versa.
|
|
93
|
+
|
|
94
|
+
### Migration Steps
|
|
95
|
+
|
|
96
|
+
1. Bump `@visulima/tui` to `2.0.0`.
|
|
97
|
+
2. Add `@visulima/tui-kit` (or adopt the shadcn registry) if you use any non-primitive component.
|
|
98
|
+
3. Run the import rewrite from [the section above](#automating-the-rewrite).
|
|
99
|
+
4. Install the optional peers for any heavy component you use — see the table in the README (`BigText`, `Code`, `DiffView`, `Markdown`, `Table`).
|
|
100
|
+
5. Drop any explicit `ws` dependency you added for DevTools.
|
|
101
|
+
6. Run your type-checker.
|
|
102
|
+
|
|
103
|
+
### Migration Issues & Solutions
|
|
104
|
+
|
|
105
|
+
#### 1. A primitive import stopped resolving
|
|
106
|
+
|
|
107
|
+
**Problem**: `Cannot find module '@visulima/tui-kit/text'` after a bulk find-and-replace.
|
|
108
|
+
|
|
109
|
+
**Solution**: The 11 primitives stayed in `@visulima/tui`. A blind replace catches them too — use the scripted rewrite above, whose lookahead skips them, or fix them up in a second pass.
|
|
110
|
+
|
|
111
|
+
#### 2. `static-render` or `textarea` rewritten to the wrong package
|
|
112
|
+
|
|
113
|
+
**Problem**: The second-pass regex turned `@visulima/tui-kit/static-render` into `@visulima/tui/components/static-render`, or did the same to `textarea`.
|
|
114
|
+
|
|
115
|
+
**Solution**: Anchor the pattern with the trailing quote-or-slash — `(box|…|text)(["'/])`. Without it, `static` also matches `static-render` and `text` also matches `textarea`, both of which genuinely moved to `@visulima/tui-kit`.
|
|
116
|
+
|
|
117
|
+
#### 3. A component throws about a missing dependency at runtime
|
|
118
|
+
|
|
119
|
+
**Problem**: `BigText`, `Code`, `DiffView`, `Markdown` or `Table` fails on a missing `cfonts`, `shiki`, `diff`, `marked` or `@visulima/tabular`.
|
|
120
|
+
|
|
121
|
+
**Solution**: Those are optional peers, installed only by the consumers that use them. Add the peers listed for that component in the README.
|
|
122
|
+
|
|
123
|
+
#### 4. DevTools stopped connecting
|
|
124
|
+
|
|
125
|
+
**Problem**: The React DevTools bridge does not attach after upgrading.
|
|
126
|
+
|
|
127
|
+
**Solution**: The bridge uses the native `WebSocket`, which needs Node `^22.14.0 || >=24.10.0`. Check your Node version; reinstalling `ws` will not help.
|
|
128
|
+
|
|
129
|
+
### Verification Steps
|
|
130
|
+
|
|
131
|
+
1. `pnpm type-check` (or `tsc --noEmit`) — an unresolved import is a compile error, so a mis-rewritten path cannot pass silently.
|
|
132
|
+
2. `rg "@visulima/tui/components/" --glob '*.{ts,tsx}'` — every remaining hit should be one of the 11 primitives.
|
|
133
|
+
3. Run your test suite, then the app itself: mount a screen and press a key to confirm input still routes.
|
|
134
|
+
|
|
135
|
+
## Also in this release (not breaking)
|
|
136
|
+
|
|
137
|
+
### `suspendTerminal()`
|
|
138
|
+
|
|
139
|
+
Hand the terminal to a child process — an editor, a pager, a shell — and restore the render afterwards:
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { useApp } from "@visulima/tui/hooks/use-app";
|
|
143
|
+
|
|
144
|
+
const { suspendTerminal } = useApp();
|
|
145
|
+
|
|
146
|
+
// Callback form — runs with the terminal released, then restores:
|
|
147
|
+
await suspendTerminal(async () => {
|
|
148
|
+
await runEditor();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Disposable form — restores on scope exit:
|
|
152
|
+
{
|
|
153
|
+
await using _ = await suspendTerminal();
|
|
154
|
+
await runEditor();
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
It releases the alternate screen and Kitty keyboard mode on suspend, and restores both with a full redraw on resume.
|
|
159
|
+
|
|
160
|
+
### Keystrokes are no longer dropped on focus
|
|
161
|
+
|
|
162
|
+
`useInput` subscribed from a passive effect, which React flushes on its own schedule — after the commit, and potentially after the next I/O callback. A key arriving in that window reached the app, found no handler subscribed, and was discarded with no queue and no retry. In practice a keystroke typed immediately after a component mounted or took focus could be silently lost.
|
|
163
|
+
|
|
164
|
+
The subscription now happens in a layout effect, flushed synchronously with the commit, so a handler is always in place before the terminal can deliver the next key. No API change.
|
package/README.md
CHANGED
|
@@ -40,13 +40,16 @@
|
|
|
40
40
|
|
|
41
41
|
Based on [ratatat](https://github.com/geoffmiller/ratatat) by Geoff Miller.
|
|
42
42
|
|
|
43
|
+
> [!IMPORTANT]
|
|
44
|
+
> **Breaking change.** The component library (~110 components) moved to the companion package [`@visulima/tui-kit`](https://visulima.com/docs/packages/tui-kit) — installable or copy-pasteable via its shadcn registry. `@visulima/tui` now ships only the renderer, hooks, and layout/text primitives, and its runtime dependencies dropped from 13 to 3. See the [migration guide](https://visulima.com/docs/packages/tui/migration).
|
|
45
|
+
|
|
43
46
|
## Features
|
|
44
47
|
|
|
45
48
|
- **Faster than Ink** on mount (1.3-2.3x), competitive on rerender
|
|
46
49
|
- **Drop-in Ink-compatible** React API
|
|
47
50
|
- **Native Rust diff engine** via NAPI for high-throughput rendering
|
|
48
51
|
- **React hooks** for input, focus, clipboard, mouse, scroll, animation, and window size
|
|
49
|
-
- **
|
|
52
|
+
- **Layout & text primitives** - Box, Text, Static, Transform, and more; the full component library (inputs, charts, tables, 100+) ships in [`@visulima/tui-kit`](https://visulima.com/docs/packages/tui-kit)
|
|
50
53
|
- **Cross-platform** native bindings (macOS, Linux glibc/musl, Windows x64/arm64)
|
|
51
54
|
- **Server-side rendering** via `renderToString`
|
|
52
55
|
- **Testing utilities** with mock streams and frame capture
|
|
@@ -67,12 +70,12 @@ pnpm add @visulima/tui react react-reconciler
|
|
|
67
70
|
|
|
68
71
|
### Component imports
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
`@visulima/tui` provides `render`, the hooks, and the layout/text primitives (`Box`, `Text`, …) at `@visulima/tui/components/<kebab-name>`. The higher-level component library lives in [`@visulima/tui-kit`](https://visulima.com/docs/packages/tui-kit), imported from `@visulima/tui-kit/<kebab-name>`.
|
|
71
74
|
|
|
72
75
|
```tsx
|
|
73
76
|
import { Box } from "@visulima/tui/components/box";
|
|
74
77
|
import { Text } from "@visulima/tui/components/text";
|
|
75
|
-
import { Spinner } from "@visulima/tui/
|
|
78
|
+
import { Spinner } from "@visulima/tui-kit/spinner";
|
|
76
79
|
import { useApp } from "@visulima/tui/hooks/use-app";
|
|
77
80
|
import { useInput } from "@visulima/tui/hooks/use-input";
|
|
78
81
|
import { render } from "@visulima/tui";
|
|
@@ -80,17 +83,17 @@ import { render } from "@visulima/tui";
|
|
|
80
83
|
|
|
81
84
|
### Optional peer dependencies
|
|
82
85
|
|
|
83
|
-
A few components have heavy peer dependencies. Install only the peers for the components you use:
|
|
86
|
+
A few `@visulima/tui-kit` components have heavy peer dependencies. Install only the peers for the components you use:
|
|
84
87
|
|
|
85
|
-
| Component | Subpath
|
|
86
|
-
| ---------- |
|
|
87
|
-
| `BigText` | `@visulima/tui/
|
|
88
|
-
| `Code` | `@visulima/tui/
|
|
89
|
-
| `DiffView` | `@visulima/tui/
|
|
90
|
-
| `Markdown` | `@visulima/tui/
|
|
91
|
-
| `Table` | `@visulima/tui/
|
|
88
|
+
| Component | Subpath | Required peers |
|
|
89
|
+
| ---------- | ----------------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
90
|
+
| `BigText` | `@visulima/tui-kit/big-text` | `cfonts` |
|
|
91
|
+
| `Code` | `@visulima/tui-kit/code` | `shiki`, `@shikijs/langs`, `@shikijs/themes` |
|
|
92
|
+
| `DiffView` | `@visulima/tui-kit/diff-view` | `diff` (+ `shiki`, `@shikijs/langs`, `@shikijs/themes` for syntax highlighting) |
|
|
93
|
+
| `Markdown` | `@visulima/tui-kit/markdown` | `marked` (+ `shiki`, `@shikijs/langs`, `@shikijs/themes` for code blocks; `@visulima/tabular` for tables) |
|
|
94
|
+
| `Table` | `@visulima/tui-kit/table` | `@visulima/tabular` |
|
|
92
95
|
|
|
93
|
-
To enable the in-app React DevTools overlay (`DEV=true`), install `react-devtools-core`
|
|
96
|
+
To enable the in-app React DevTools overlay (`DEV=true`), install `react-devtools-core` (the bridge uses the native `WebSocket`, so no `ws` is needed).
|
|
94
97
|
|
|
95
98
|
## Quick Start
|
|
96
99
|
|
package/dist/components/box.d.ts
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { ReactNode, PropsWithChildren, RefAttributes, ForwardRefExoticComponent } from 'react';
|
|
2
2
|
import { Except } from 'type-fest';
|
|
3
|
-
import { D as DOMElement } from "../packem_shared/dom.d-
|
|
4
|
-
import { S as Styles } from "../packem_shared/styles.d-
|
|
3
|
+
import { D as DOMElement } from "../packem_shared/dom.d-CLGlidfI.js";
|
|
4
|
+
import { S as Styles } from "../packem_shared/styles.d-CKGQFfm4.js";
|
|
5
5
|
import 'yoga-layout';
|
|
6
|
-
import "../
|
|
6
|
+
import "../ink/public/cursor.js";
|
|
7
7
|
import '@visulima/colorize';
|
|
8
|
-
import 'cli-boxes';
|
|
9
8
|
type Props = Except<Styles, "textWrap"> & {
|
|
10
9
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
* Hide the element from screen readers.
|
|
11
|
+
*/
|
|
13
12
|
readonly "aria-hidden"?: boolean;
|
|
14
13
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
* A label for the element for screen readers.
|
|
15
|
+
*/
|
|
17
16
|
readonly "aria-label"?: string;
|
|
18
17
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
* The role of the element.
|
|
19
|
+
*/
|
|
21
20
|
readonly "aria-role"?: "button" | "checkbox" | "combobox" | "list" | "listbox" | "listitem" | "menu" | "menuitem" | "option" | "progressbar" | "radio" | "radiogroup" | "tab" | "tablist" | "table" | "textbox" | "timer" | "toolbar";
|
|
22
21
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
* The state of the element.
|
|
23
|
+
*/
|
|
25
24
|
readonly "aria-state"?: {
|
|
26
25
|
readonly busy?: boolean;
|
|
27
26
|
readonly checked?: boolean;
|
|
@@ -34,29 +33,29 @@ type Props = Except<Styles, "textWrap"> & {
|
|
|
34
33
|
readonly selected?: boolean;
|
|
35
34
|
};
|
|
36
35
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
* Whether this element is opaque (prevents rendering of covered content beneath it).
|
|
37
|
+
* Useful for performance optimization with layered content.
|
|
38
|
+
*/
|
|
40
39
|
readonly opaque?: boolean;
|
|
41
40
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
* Whether to render a scrollbar for this scrollable element.
|
|
42
|
+
* Only applies when `overflow` is `'scroll'`. Defaults to `true`.
|
|
43
|
+
*/
|
|
45
44
|
readonly scrollbar?: boolean;
|
|
46
45
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
* Makes this element sticky within its scroll container.
|
|
47
|
+
* - `true` or `'top'`: pinned to the top during scroll
|
|
48
|
+
* - `'bottom'`: pinned to the bottom during scroll
|
|
49
|
+
*/
|
|
51
50
|
readonly sticky?: boolean | "top" | "bottom";
|
|
52
51
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
* Alternate content to render when this element is in its sticky (pinned) state.
|
|
53
|
+
* Only applies when `sticky` is set. When omitted, the normal children are used.
|
|
54
|
+
*/
|
|
56
55
|
readonly stickyChildren?: ReactNode;
|
|
57
56
|
};
|
|
58
57
|
/**
|
|
59
|
-
* `<Box>` is an essential Ink component to build your layout. It's like `<div style="display: flex">` in the browser.
|
|
60
|
-
*/
|
|
58
|
+
* `<Box>` is an essential Ink component to build your layout. It's like `<div style="display: flex">` in the browser.
|
|
59
|
+
*/
|
|
61
60
|
declare const Box: ForwardRefExoticComponent<PropsWithChildren<Props> & RefAttributes<DOMElement>>;
|
|
62
61
|
export { Box, type Props as BoxProps, Props, Box as default };
|
|
@@ -1,44 +1,39 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { C as CanvasContext } from "../packem_shared/buffer.d-
|
|
3
|
-
export type { a as CanvasColor, b as CellStyle } from "../packem_shared/buffer.d-
|
|
2
|
+
import { C as CanvasContext } from "../packem_shared/buffer.d-CttIC480.js";
|
|
3
|
+
export type { a as CanvasColor, b as CellStyle } from "../packem_shared/buffer.d-CttIC480.js";
|
|
4
4
|
type Props = {
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
* Imperative draw callback. Mutates the underlying typed-array buffer via
|
|
7
|
+
* the provided `CanvasContext`. Runs in a `useMemo` keyed by `version` —
|
|
8
|
+
* pass a stable reference (or hash) so the canvas only re-renders when
|
|
9
|
+
* the input data truly changes.
|
|
10
|
+
*/
|
|
11
11
|
readonly draw: (context: CanvasContext) => void;
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
* Number of rows (character cells vertically).
|
|
14
|
+
*/
|
|
15
15
|
readonly height: number;
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
* Invalidation key — required so the memoization contract is explicit.
|
|
18
|
+
* Re-runs `draw` and re-serializes only the rows the draw callback
|
|
19
|
+
* dirtied. Pass the data you render (or a hash of it). Use a stable
|
|
20
|
+
* value (e.g. a counter) when you intentionally want to redraw on
|
|
21
|
+
* every render.
|
|
22
|
+
*/
|
|
23
23
|
readonly version: unknown;
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
* Number of columns (character cells horizontally).
|
|
26
|
+
*/
|
|
27
27
|
readonly width: number;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* A fixed-size cell grid backed by typed arrays. Use the imperative `draw`
|
|
31
|
-
* callback to paint. The canvas emits one `Text` child per row (not per cell)
|
|
32
|
-
* and caches the ANSI output of each row: only rows marked dirty by the last
|
|
33
|
-
* draw pass are re-serialized, and only when `version` changes.
|
|
34
|
-
*
|
|
35
|
-
* This is the foundation for chart/grid components that need more layout
|
|
36
|
-
* control than `Text` alone.
|
|
37
|
-
*/
|
|
38
|
-
declare function Canvas({
|
|
39
|
-
draw,
|
|
40
|
-
height,
|
|
41
|
-
version,
|
|
42
|
-
width
|
|
43
|
-
}: Props): ReactElement;
|
|
30
|
+
* A fixed-size cell grid backed by typed arrays. Use the imperative `draw`
|
|
31
|
+
* callback to paint. The canvas emits one `Text` child per row (not per cell)
|
|
32
|
+
* and caches the ANSI output of each row: only rows marked dirty by the last
|
|
33
|
+
* draw pass are re-serialized, and only when `version` changes.
|
|
34
|
+
*
|
|
35
|
+
* This is the foundation for chart/grid components that need more layout
|
|
36
|
+
* control than `Text` alone.
|
|
37
|
+
*/
|
|
38
|
+
declare function Canvas({ draw, height, version, width }: Props): ReactElement;
|
|
44
39
|
export { Canvas, type CanvasContext, type Props as CanvasProps, Props, Canvas as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as a}from"react/jsx-runtime";import{useRef as d,useMemo as f,Fragment as m}from"react";import{createCanvasBuffer as p,serializeRow as x}from"../packem_shared/createCanvasBuffer-CL6sAM-A.js";import{Box as g}from"./box.js";import{Text as w}from"./text.js";function C({draw:h,height:r,version:c,width:n}){const i=d(void 0),s=d(void 0);(i.current?.width!==n||i.current.height!==r)&&(i.current=p(n,r),s.current={hasRendered:!1,lines:Array.from({length:r}).fill("")});const t=i.current,o=s.current,l=f(()=>{h(t.context);for(let e=0;e<t.height;e+=1)o.hasRendered&&t.dirty[e]===0||(o.lines[e]=x(t,e),t.dirty[e]=0);return o.hasRendered=!0,[...o.lines]},[c,n,r]);return a(g,{flexDirection:"column",flexShrink:0,height:r,width:n,children:l.map((e,u)=>a(m,{children:a(w,{wrap:"truncate-end",children:e})},u))})}export{C as Canvas,C as default};
|
|
@@ -1,62 +1,56 @@
|
|
|
1
1
|
import React, { RefObject } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { D as DOMElement } from "../packem_shared/dom.d-
|
|
2
|
+
import { CursorShape } from "../ink/public/cursor.js";
|
|
3
|
+
import { D as DOMElement } from "../packem_shared/dom.d-CLGlidfI.js";
|
|
4
4
|
import 'yoga-layout';
|
|
5
5
|
import '@visulima/colorize';
|
|
6
|
-
import
|
|
7
|
-
import "../packem_shared/styles.d-cMo36xQz.js";
|
|
6
|
+
import "../packem_shared/styles.d-CKGQFfm4.js";
|
|
8
7
|
import 'type-fest';
|
|
9
8
|
type Props = {
|
|
10
9
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
* Optional reference to anchor cursor coordinates to a different element.
|
|
11
|
+
* If omitted, `<Cursor>` uses the parent container as anchor.
|
|
12
|
+
* If `anchorRef` is set but currently unresolved, Ink hides the cursor for that frame.
|
|
13
|
+
* If multiple `<Cursor>` components are rendered in one frame, the last rendered one controls the terminal cursor position.
|
|
14
|
+
*/
|
|
16
15
|
readonly anchorRef?: RefObject<DOMElement | null>;
|
|
17
16
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
* Optional cursor shape (DECSCUSR). The shape is restored to the terminal
|
|
18
|
+
* default on unmount, SIGINT, and unhandled React tree throws, so the
|
|
19
|
+
* parent shell never inherits a leaked shape.
|
|
20
|
+
*
|
|
21
|
+
* Steady variants are non-blinking; `blinking-*` variants opt into blink.
|
|
22
|
+
*/
|
|
24
23
|
readonly shape?: CursorShape;
|
|
25
24
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
* Horizontal offset from anchor content origin.
|
|
26
|
+
*/
|
|
28
27
|
readonly x?: number;
|
|
29
28
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
* Vertical offset from anchor content origin.
|
|
30
|
+
*/
|
|
32
31
|
readonly y?: number;
|
|
33
32
|
};
|
|
34
33
|
/**
|
|
35
|
-
* Declaratively position the terminal cursor.
|
|
36
|
-
* `<Cursor>` must not be rendered inside `<Text>`.
|
|
37
|
-
*
|
|
38
|
-
* **Inline mode** (no props): place `<Cursor />` after a `<Text>` node and the
|
|
39
|
-
* cursor appears where that text ended — even when text wraps across lines.
|
|
40
|
-
*
|
|
41
|
-
* **Anchor mode**: pass `anchorRef` and/or `x`/`y` to position relative to
|
|
42
|
-
* another element's content origin.
|
|
43
|
-
* @example Inline mode — cursor follows text naturally
|
|
44
|
-
* ```jsx
|
|
45
|
-
* <Box>
|
|
46
|
-
* <Text>{prompt + value}</Text>
|
|
47
|
-
* <Cursor />
|
|
48
|
-
* </Box>
|
|
49
|
-
* ```
|
|
50
|
-
* @example Anchor mode — offset from a referenced element
|
|
51
|
-
* ```jsx
|
|
52
|
-
* <Box ref={ref} />
|
|
53
|
-
* <Cursor anchorRef={ref} x={5} />
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
declare function Cursor({
|
|
57
|
-
anchorRef,
|
|
58
|
-
shape,
|
|
59
|
-
x,
|
|
60
|
-
y
|
|
61
|
-
}: Props): React.JSX.Element;
|
|
34
|
+
* Declaratively position the terminal cursor.
|
|
35
|
+
* `<Cursor>` must not be rendered inside `<Text>`.
|
|
36
|
+
*
|
|
37
|
+
* **Inline mode** (no props): place `<Cursor />` after a `<Text>` node and the
|
|
38
|
+
* cursor appears where that text ended — even when text wraps across lines.
|
|
39
|
+
*
|
|
40
|
+
* **Anchor mode**: pass `anchorRef` and/or `x`/`y` to position relative to
|
|
41
|
+
* another element's content origin.
|
|
42
|
+
* @example Inline mode — cursor follows text naturally
|
|
43
|
+
* ```jsx
|
|
44
|
+
* <Box>
|
|
45
|
+
* <Text>{prompt + value}</Text>
|
|
46
|
+
* <Cursor />
|
|
47
|
+
* </Box>
|
|
48
|
+
* ```
|
|
49
|
+
* @example Anchor mode — offset from a referenced element
|
|
50
|
+
* ```jsx
|
|
51
|
+
* <Box ref={ref} />
|
|
52
|
+
* <Cursor anchorRef={ref} x={5} />
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare function Cursor({ anchorRef, shape, x, y }: Props): React.JSX.Element;
|
|
62
56
|
export { Cursor, type Props as CursorProps, Props, Cursor as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode, PureComponent } from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
readonly children: ReactNode;
|
|
4
|
+
readonly onError: (error: Error) => void;
|
|
5
|
+
};
|
|
6
|
+
type State = {
|
|
7
|
+
readonly error?: Error;
|
|
8
|
+
};
|
|
9
|
+
declare class ErrorBoundary extends PureComponent<Props, State> {
|
|
10
|
+
static displayName: string;
|
|
11
|
+
static getDerivedStateFromError(error: Error): State;
|
|
12
|
+
override state: State;
|
|
13
|
+
override componentDidCatch(error: Error): void;
|
|
14
|
+
override render(): ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export { type Props as ErrorBoundaryProps, ErrorBoundary as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{PureComponent as e}from"react";import o from"./error-overview.js";class p extends e{static displayName="InternalErrorBoundary";static getDerivedStateFromError(r){return{error:r}}state={error:void 0};componentDidCatch(r){this.props.onError(r)}render(){return this.state.error?t(o,{error:this.state.error}):this.props.children}}export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as $}from"node:module";import{jsxs as c,jsx as s}from"react/jsx-runtime";import{parseStacktrace as C}from"@visulima/error/stacktrace";import{Box as a}from"./box.js";import{Text as d}from"./text.js";let _;const w=n=>(_??=$(import.meta.url))(n),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=n=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[r,t]=m.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return m.getBuiltinModule(n)}return w(n)},{existsSync:v,readFileSync:x}=b("node:fs"),{cwd:y}=m,T=(n,r=2)=>n.replace(/^\t+/gm,t=>" ".repeat(t.length*r)),j=(n,r)=>{const t=[],u=n-r,o=n+r;for(let l=u;l<=o;l++)t.push(l);return t},k=(n,r,t={})=>{var u;if(typeof n!="string")throw new TypeError("Source code is missing.");if(!r||r<1)throw new TypeError("Line number must start from `1`.");const o=T(n).split(/\r?\n/);if(!(r>o.length))return j(r,(u=t.around)!==null&&u!==void 0?u:3).filter(l=>o[l-1]!==void 0).map(l=>({line:l,value:o[l-1]}))},g=n=>{if(!n)return n;const r=y();return n.replace(`file://${r}/`,"").replace(`${r}/`,"")};function B({error:n}){const r=C(n),t=new Map,u=r.map(e=>{const i=!e.methodName&&!e.file?`raw:${e.raw}`:`${g(e.file)??""}:${e.line}:${e.column}:${e.methodName??""}`,f=t.get(i)??0;return t.set(i,f+1),{key:`${i}#${f}`,trace:e}}),o=r[0],l=g(o?.file);let h,p=0;if(l&&o?.line&&v(l)){const e=x(l,"utf8");if(h=k(e,o.line),h)for(const{line:i}of h)p=Math.max(p,String(i).length)}return c(a,{flexDirection:"column",padding:1,children:[c(a,{children:[c(d,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),c(d,{children:[" ",n.message]})]}),o&&l?s(a,{marginTop:1,children:c(d,{dimColor:!0,children:[l,":",o.line,":",o.column]})}):null,o&&h?s(a,{flexDirection:"column",marginTop:1,children:h.map(({line:e,value:i})=>c(a,{children:[s(a,{width:p+1,children:c(d,{"aria-label":e===o.line?`Line ${e}, error`:`Line ${e}`,backgroundColor:e===o.line?"red":void 0,color:e===o.line?"white":void 0,dimColor:e!==o.line,children:[String(e).padStart(p," "),":"]})}),s(d,{backgroundColor:e===o.line?"red":void 0,color:e===o.line?"white":void 0,children:` ${i}`})]},`excerpt-${e}`))}):null,r.length>0?s(a,{flexDirection:"column",marginTop:1,children:u.map(({key:e,trace:i})=>{const f=g(i.file)??"";return!i.methodName&&!i.file?c(a,{children:[s(d,{dimColor:!0,children:"- "}),s(d,{bold:!0,dimColor:!0,children:i.raw})]},e):c(a,{children:[s(d,{dimColor:!0,children:"- "}),s(d,{bold:!0,dimColor:!0,children:i.methodName??"<anonymous>"}),c(d,{"aria-label":`at ${f} line ${i.line} column ${i.column}`,color:"gray",dimColor:!0,children:[" ","(",f,":",i.line,":",i.column,")"]})]},e)})}):null]})}export{B as default};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
* Number of newlines to insert.
|
|
5
|
+
* @default 1
|
|
6
|
+
*/
|
|
7
7
|
readonly count?: number;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* Adds one or more newline (`\n`) characters. Must be used within `<Text>` components.
|
|
11
|
-
*/
|
|
12
|
-
declare function Newline({
|
|
13
|
-
count
|
|
14
|
-
}: Props): ReactElement;
|
|
10
|
+
* Adds one or more newline (`\n`) characters. Must be used within `<Text>` components.
|
|
11
|
+
*/
|
|
12
|
+
declare function Newline({ count }: Props): ReactElement;
|
|
15
13
|
export { Newline, type Props as NewlineProps, Props, Newline as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
/**
|
|
3
|
-
* A flexible space that expands along the major axis of its containing layout.
|
|
4
|
-
*
|
|
5
|
-
* It's useful as a shortcut for filling all the available space between elements.
|
|
6
|
-
*/
|
|
3
|
+
* A flexible space that expands along the major axis of its containing layout.
|
|
4
|
+
*
|
|
5
|
+
* It's useful as a shortcut for filling all the available space between elements.
|
|
6
|
+
*/
|
|
7
7
|
declare function Spacer(): ReactElement;
|
|
8
8
|
export { Spacer, Spacer as default };
|