@visulima/tui 0.0.1 → 1.0.0-alpha.2
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 +200 -0
- package/LICENSE.md +303 -0
- package/README.md +173 -29
- package/dist/core/app.d.ts +50 -0
- package/dist/core/cell.d.ts +33 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +5 -0
- package/dist/core/inline.d.ts +22 -0
- package/dist/core/input.d.ts +18 -0
- package/dist/core/native-binding.d.ts +22 -0
- package/dist/ink/ansi-to-cell.d.ts +5 -0
- package/dist/ink/ansi-tokenizer.d.ts +38 -0
- package/dist/ink/clipboard.d.ts +29 -0
- package/dist/ink/color-matrix.d.ts +49 -0
- package/dist/ink/color-utils.d.ts +30 -0
- package/dist/ink/colorize.d.ts +4 -0
- package/dist/ink/components/AccessibilityContext.d.ts +4 -0
- package/dist/ink/components/Alert.d.ts +30 -0
- package/dist/ink/components/AnimationContext.d.ts +10 -0
- package/dist/ink/components/App.d.ts +19 -0
- package/dist/ink/components/AppContext.d.ts +38 -0
- package/dist/ink/components/BackgroundContext.d.ts +5 -0
- package/dist/ink/components/Badge.d.ts +27 -0
- package/dist/ink/components/BigText.d.ts +71 -0
- package/dist/ink/components/Box.d.ts +58 -0
- package/dist/ink/components/Code.d.ts +46 -0
- package/dist/ink/components/ConfirmInput.d.ts +40 -0
- package/dist/ink/components/ConsoleOverlay.d.ts +52 -0
- package/dist/ink/components/Cursor.d.ts +43 -0
- package/dist/ink/components/CursorContext.d.ts +12 -0
- package/dist/ink/components/Dialog.d.ts +93 -0
- package/dist/ink/components/DiffView.d.ts +71 -0
- package/dist/ink/components/ErrorBoundary.d.ts +17 -0
- package/dist/ink/components/ErrorOverview.d.ts +6 -0
- package/dist/ink/components/FocusContext.d.ts +17 -0
- package/dist/ink/components/Gradient.d.ts +38 -0
- package/dist/ink/components/Help.d.ts +49 -0
- package/dist/ink/components/Link.d.ts +34 -0
- package/dist/ink/components/Markdown.d.ts +34 -0
- package/dist/ink/components/MultiSelect.d.ts +63 -0
- package/dist/ink/components/Newline.d.ts +12 -0
- package/dist/ink/components/OrderedList.d.ts +30 -0
- package/dist/ink/components/Paginator.d.ts +75 -0
- package/dist/ink/components/ProgressBar.d.ts +51 -0
- package/dist/ink/components/SelectInput.d.ts +96 -0
- package/dist/ink/components/SelectInputIndicator.d.ts +36 -0
- package/dist/ink/components/SelectInputItem.d.ts +43 -0
- package/dist/ink/components/Slider.d.ts +92 -0
- package/dist/ink/components/Spacer.d.ts +7 -0
- package/dist/ink/components/Spinner.d.ts +42 -0
- package/dist/ink/components/Static.d.ts +24 -0
- package/dist/ink/components/StaticRender.d.ts +28 -0
- package/dist/ink/components/StatusMessage.d.ts +26 -0
- package/dist/ink/components/StderrContext.d.ts +16 -0
- package/dist/ink/components/StdinContext.d.ts +29 -0
- package/dist/ink/components/StdoutContext.d.ts +16 -0
- package/dist/ink/components/Stopwatch.d.ts +44 -0
- package/dist/ink/components/Tab.d.ts +25 -0
- package/dist/ink/components/Table.d.ts +80 -0
- package/dist/ink/components/Tabs.d.ts +104 -0
- package/dist/ink/components/Text.d.ts +63 -0
- package/dist/ink/components/TextInput.d.ts +48 -0
- package/dist/ink/components/Textarea.d.ts +62 -0
- package/dist/ink/components/Timer.d.ts +52 -0
- package/dist/ink/components/Transform.d.ts +16 -0
- package/dist/ink/components/UnorderedList.d.ts +35 -0
- package/dist/ink/components/file-picker/FilePicker.d.ts +75 -0
- package/dist/ink/components/file-picker/index.d.ts +3 -0
- package/dist/ink/components/file-picker/types.d.ts +38 -0
- package/dist/ink/components/file-picker/use-file-system.d.ts +16 -0
- package/dist/ink/components/scroll/ControlledScrollView.d.ts +43 -0
- package/dist/ink/components/scroll/ScrollBar.d.ts +20 -0
- package/dist/ink/components/scroll/ScrollBarBox.d.ts +15 -0
- package/dist/ink/components/scroll/ScrollList.d.ts +12 -0
- package/dist/ink/components/scroll/ScrollView.d.ts +98 -0
- package/dist/ink/components/scroll/index.d.ts +10 -0
- package/dist/ink/components/scroll/use-state-ref.d.ts +8 -0
- package/dist/ink/components/tree-view/TreeView.d.ts +89 -0
- package/dist/ink/components/tree-view/TreeViewNode.d.ts +29 -0
- package/dist/ink/components/tree-view/index.d.ts +11 -0
- package/dist/ink/components/tree-view/theme.d.ts +24 -0
- package/dist/ink/components/tree-view/tree-node-map.d.ts +72 -0
- package/dist/ink/components/tree-view/types.d.ts +55 -0
- package/dist/ink/components/tree-view/use-tree-view-state.d.ts +135 -0
- package/dist/ink/components/tree-view/use-tree-view.d.ts +26 -0
- package/dist/ink/components/variant-config.d.ts +10 -0
- package/dist/ink/cursor-helpers.d.ts +38 -0
- package/dist/ink/data-limited-lru-map.d.ts +21 -0
- package/dist/ink/devtools-window-polyfill.d.ts +1 -0
- package/dist/ink/devtools.d.ts +1 -0
- package/dist/ink/dom.d.ts +213 -0
- package/dist/ink/get-max-width.d.ts +3 -0
- package/dist/ink/highlighter.d.ts +28 -0
- package/dist/ink/hooks/use-animation.d.ts +43 -0
- package/dist/ink/hooks/use-app.d.ts +6 -0
- package/dist/ink/hooks/use-box-metrics.d.ts +58 -0
- package/dist/ink/hooks/use-clipboard.d.ts +29 -0
- package/dist/ink/hooks/use-color-blindness.d.ts +33 -0
- package/dist/ink/hooks/use-console-capture.d.ts +43 -0
- package/dist/ink/hooks/use-cursor.d.ts +12 -0
- package/dist/ink/hooks/use-focus-manager.d.ts +42 -0
- package/dist/ink/hooks/use-focus.d.ts +30 -0
- package/dist/ink/hooks/use-input.d.ts +149 -0
- package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +6 -0
- package/dist/ink/hooks/use-key-bindings.d.ts +61 -0
- package/dist/ink/hooks/use-linked-scroll.d.ts +41 -0
- package/dist/ink/hooks/use-paste.d.ts +44 -0
- package/dist/ink/hooks/use-scroll-acceleration.d.ts +47 -0
- package/dist/ink/hooks/use-scroll-input.d.ts +34 -0
- package/dist/ink/hooks/use-stderr.d.ts +6 -0
- package/dist/ink/hooks/use-stdin.d.ts +7 -0
- package/dist/ink/hooks/use-stdout.d.ts +6 -0
- package/dist/ink/hooks/use-stopwatch.d.ts +40 -0
- package/dist/ink/hooks/use-terminal-palette.d.ts +19 -0
- package/dist/ink/hooks/use-text-buffer.d.ts +42 -0
- package/dist/ink/hooks/use-text-selection.d.ts +45 -0
- package/dist/ink/hooks/use-timer.d.ts +49 -0
- package/dist/ink/hooks/use-window-size.d.ts +18 -0
- package/dist/ink/ime-utils.d.ts +25 -0
- package/dist/ink/index.d.ts +159 -0
- package/dist/ink/index.js +100 -0
- package/dist/ink/ink.d.ts +189 -0
- package/dist/ink/input-parser.d.ts +10 -0
- package/dist/ink/input-utils.d.ts +16 -0
- package/dist/ink/instances.d.ts +3 -0
- package/dist/ink/kitty-keyboard.d.ts +23 -0
- package/dist/ink/layout.d.ts +26 -0
- package/dist/ink/log-update-native.d.ts +14 -0
- package/dist/ink/log-update.d.ts +21 -0
- package/dist/ink/measure-element.d.ts +147 -0
- package/dist/ink/measure-text.d.ts +56 -0
- package/dist/ink/mouse/Fullscreen.d.ts +8 -0
- package/dist/ink/mouse/MouseProvider.d.ts +11 -0
- package/dist/ink/mouse/ansi-parser.d.ts +37 -0
- package/dist/ink/mouse/constants.d.ts +59 -0
- package/dist/ink/mouse/index.d.ts +20 -0
- package/dist/ink/mouse/is-intersecting.d.ts +18 -0
- package/dist/ink/mouse/mouse-context.d.ts +36 -0
- package/dist/ink/mouse/use-element-position.d.ts +29 -0
- package/dist/ink/mouse/use-mouse-action.d.ts +7 -0
- package/dist/ink/mouse/use-mouse-position.d.ts +7 -0
- package/dist/ink/mouse/use-mouse.d.ts +7 -0
- package/dist/ink/mouse/use-on-mouse-click.d.ts +14 -0
- package/dist/ink/mouse/use-on-mouse-hover.d.ts +8 -0
- package/dist/ink/mouse/use-on-mouse-state.d.ts +11 -0
- package/dist/ink/output.d.ts +74 -0
- package/dist/ink/parse-keypress.d.ts +22 -0
- package/dist/ink/reconciler.d.ts +3 -0
- package/dist/ink/region.d.ts +99 -0
- package/dist/ink/render-background.d.ts +4 -0
- package/dist/ink/render-border.d.ts +4 -0
- package/dist/ink/render-node-to-output.d.ts +38 -0
- package/dist/ink/render-scrollbar.d.ts +9 -0
- package/dist/ink/render-sticky.d.ts +44 -0
- package/dist/ink/render-to-string.d.ts +37 -0
- package/dist/ink/render.d.ts +191 -0
- package/dist/ink/renderer.d.ts +17 -0
- package/dist/ink/resize-observer.d.ts +44 -0
- package/dist/ink/sanitize-ansi.d.ts +2 -0
- package/dist/ink/scroll.d.ts +23 -0
- package/dist/ink/selection.d.ts +70 -0
- package/dist/ink/squash-text-nodes.d.ts +18 -0
- package/dist/ink/style-flags.d.ts +17 -0
- package/dist/ink/styled-line-factory.d.ts +25 -0
- package/dist/ink/styled-line-serializer.d.ts +18 -0
- package/dist/ink/styled-line.d.ts +109 -0
- package/dist/ink/styles.d.ts +369 -0
- package/dist/ink/terminal-palette.d.ts +25 -0
- package/dist/ink/text-wrap.d.ts +10 -0
- package/dist/ink/token-to-elements.d.ts +22 -0
- package/dist/ink/utils/format-time.d.ts +4 -0
- package/dist/ink/utils.d.ts +9 -0
- package/dist/ink/wrap-text.d.ts +3 -0
- package/dist/ink/write-synchronized.d.ts +4 -0
- package/dist/packem_chunks/devtools.js +27 -0
- package/dist/packem_shared/AccessibilityContext-BLelHhNU.js +7 -0
- package/dist/packem_shared/Alert-Dr3s_LD9.js +17 -0
- package/dist/packem_shared/AnimationContext-BcJg8Jr6.js +15 -0
- package/dist/packem_shared/AppContext-CP0U6H7O.js +11 -0
- package/dist/packem_shared/BackgroundContext-BAUaxfOb.js +5 -0
- package/dist/packem_shared/Badge-Dk7EGGM6.js +13 -0
- package/dist/packem_shared/BigText-CjMdY63X.js +24 -0
- package/dist/packem_shared/Box-D_pSJ9Jp.js +73 -0
- package/dist/packem_shared/COLOR_BLINDNESS_SIMULATION-BsMy5Ewl.js +81 -0
- package/dist/packem_shared/Cell-DCg1kJY-.js +48 -0
- package/dist/packem_shared/Code-DjQvPBD9.js +53 -0
- package/dist/packem_shared/ConfirmInput-85Y4kRQW.js +44 -0
- package/dist/packem_shared/ConsoleOverlay-DBNa4vtj.js +57 -0
- package/dist/packem_shared/ControlledScrollView-BlOaxcsN.js +286 -0
- package/dist/packem_shared/ControlledScrollView-DfAhcufF.js +5 -0
- package/dist/packem_shared/Cursor-DiW7YoSK.js +18 -0
- package/dist/packem_shared/CursorContext-JxRzlqAx.js +9 -0
- package/dist/packem_shared/DevTools-aMPIsaHx.js +61 -0
- package/dist/packem_shared/Dialog-DsSNAVgC.js +71 -0
- package/dist/packem_shared/DiffView-hqaw-2S6.js +329 -0
- package/dist/packem_shared/FilePicker-DNwFxRhq.js +254 -0
- package/dist/packem_shared/FocusContext-CWkYtgcm.js +26 -0
- package/dist/packem_shared/FocusContext-D5wFxSRz.js +153 -0
- package/dist/packem_shared/Fullscreen-DrElAE1o.js +11 -0
- package/dist/packem_shared/Gradient-Ql5P0GUd.js +136 -0
- package/dist/packem_shared/Help-6wanGG38.js +112 -0
- package/dist/packem_shared/IMECompositionBuffer-Dl3S0KnF.js +55 -0
- package/dist/packem_shared/InputParser-BKHpWfvN.js +156 -0
- package/dist/packem_shared/LayoutNode-Cjnsodiy.js +131 -0
- package/dist/packem_shared/Link-COcKYfGT.js +66 -0
- package/dist/packem_shared/Markdown-y1ISztof.js +212 -0
- package/dist/packem_shared/MouseProvider-Y9TSSEGl.js +136 -0
- package/dist/packem_shared/MultiSelect-ChoLUcDI.js +129 -0
- package/dist/packem_shared/NAMED_COLORS-a4QBvb5r.js +262 -0
- package/dist/packem_shared/Newline-DBtYEg8x.js +7 -0
- package/dist/packem_shared/OrderedList-Cp7pXr6m.js +26 -0
- package/dist/packem_shared/Paginator-D1AuD-kj.js +104 -0
- package/dist/packem_shared/ProgressBar-DOfpVagn.js +22 -0
- package/dist/packem_shared/Renderer-zZ5O3vxc.js +31 -0
- package/dist/packem_shared/ResizeObserverEntry-Br4seLeQ.js +102 -0
- package/dist/packem_shared/ScrollBar-EWAs2Uc7.js +106 -0
- package/dist/packem_shared/ScrollBarBox-DTNNlh7R.js +72 -0
- package/dist/packem_shared/ScrollList-DCeIFL8M.js +227 -0
- package/dist/packem_shared/ScrollView-v3MCNIyX.js +196 -0
- package/dist/packem_shared/SelectInput-BN2TMyxp.js +260 -0
- package/dist/packem_shared/SelectInputIndicator-DkRMoH_b.js +9 -0
- package/dist/packem_shared/SelectInputItem-BF9LQgKu.js +8 -0
- package/dist/packem_shared/Slider-BWD7xZX6.js +116 -0
- package/dist/packem_shared/Spacer-Bs4ER-HK.js +8 -0
- package/dist/packem_shared/Spinner-BuI-kN4p.js +1799 -0
- package/dist/packem_shared/Static-DpTd6Eed.js +22 -0
- package/dist/packem_shared/Static-xmD9giJj.js +18 -0
- package/dist/packem_shared/StaticRender-tYwH6QXl.js +33 -0
- package/dist/packem_shared/StatusMessage-BtSYxzwb.js +14 -0
- package/dist/packem_shared/StderrContext-Bj4Mf7v7.js +17 -0
- package/dist/packem_shared/StdinContext-Bq_GNJ3z.js +38 -0
- package/dist/packem_shared/StdoutContext-CgjWeCdO.js +17 -0
- package/dist/packem_shared/Stopwatch-DjtTCyHn.js +23 -0
- package/dist/packem_shared/Tab-C6r5q4hR.js +7 -0
- package/dist/packem_shared/Table-D-rSVlzb.js +82 -0
- package/dist/packem_shared/Tabs-hki-KRnx.js +153 -0
- package/dist/packem_shared/Text-DvAUdZcK.js +65 -0
- package/dist/packem_shared/TextInput-C79WEQ5U.js +137 -0
- package/dist/packem_shared/Textarea-Dj06R6Zd.js +272 -0
- package/dist/packem_shared/Timer-wi9zuh4n.js +22 -0
- package/dist/packem_shared/Transform-BHxY_dAM.js +14 -0
- package/dist/packem_shared/TreeNodeMap-CtJUvBnd.js +155 -0
- package/dist/packem_shared/TreeView-C2062dtj.js +148 -0
- package/dist/packem_shared/TuiApp-DfxOnXqi.js +120 -0
- package/dist/packem_shared/TuiContext-CqEjMyXd.js +415 -0
- package/dist/packem_shared/UnorderedList-DhnadWjX.js +33 -0
- package/dist/packem_shared/ansi-parser-0BdVTKho.js +41 -0
- package/dist/packem_shared/ansi-tokenizer-LHq2LUWA.js +307 -0
- package/dist/packem_shared/boxes-oi3WUbyR.js +92 -0
- package/dist/packem_shared/colorize-88_Vk8cn.js +48 -0
- package/dist/packem_shared/comparePoints-CGMDnd3_.js +287 -0
- package/dist/packem_shared/createInlineLoop-BxMmcq9D.js +93 -0
- package/dist/packem_shared/createLinkedScrollGroup-Djw4Ceo0.js +44 -0
- package/dist/packem_shared/dom-DvzhsAez.js +225 -0
- package/dist/packem_shared/format-time-BGmnDukX.js +12 -0
- package/dist/packem_shared/getPathToRoot-a1wbwxfL.js +4 -0
- package/dist/packem_shared/getScrollHeight-BubfU_df.js +63 -0
- package/dist/packem_shared/input-utils-ViAEXa0Z.js +19 -0
- package/dist/packem_shared/isIntersecting-fEXHJN5R.js +10 -0
- package/dist/packem_shared/isOsc52Supported-G0k4sXJx.js +36 -0
- package/dist/packem_shared/isTerminalPaletteQuerySupported-EeiwMKbr.js +93 -0
- package/dist/packem_shared/kittyFlags-bNNf_9kX.js +26 -0
- package/dist/packem_shared/measure-element-Reza_yfC.js +396 -0
- package/dist/packem_shared/measure-text-DItZYotK.js +1189 -0
- package/dist/packem_shared/measureElement-CTgFCmKd.js +4 -0
- package/dist/packem_shared/mouse-context-BUHWKEIe.js +6 -0
- package/dist/packem_shared/parseSgrMouse-BHVBPP9G.js +1 -0
- package/dist/packem_shared/processLayout-BQ9kXfd3.js +2 -0
- package/dist/packem_shared/reconciler-BXf6miSS.js +211 -0
- package/dist/packem_shared/reconciler-gfmqURLy.js +680 -0
- package/dist/packem_shared/render-BAwdjfki.js +2806 -0
- package/dist/packem_shared/render-Bpjhf0lD.js +195 -0
- package/dist/packem_shared/renderToString-Cfg55DRD.js +62 -0
- package/dist/packem_shared/renderToString-ClIaXgrC.js +86 -0
- package/dist/packem_shared/renderTreeToBuffer-D3mo7M7m.js +308 -0
- package/dist/packem_shared/renderer-B3wROkeg.js +1431 -0
- package/dist/packem_shared/setEnableStyledLineCache-BpskngSJ.js +2 -0
- package/dist/packem_shared/squashTextNodesWithMap-iqm6OMMT.js +100 -0
- package/dist/packem_shared/text-width-DhuarWcB.js +42 -0
- package/dist/packem_shared/token-to-elements-BRFl_rzw.js +249 -0
- package/dist/packem_shared/treeViewTheme-BpSw9TMf.js +52 -0
- package/dist/packem_shared/useAnimation-kj31sA-T.js +62 -0
- package/dist/packem_shared/useApp-DPQlRzi5.js +6 -0
- package/dist/packem_shared/useBoxMetrics-rBjKc-g4.js +54 -0
- package/dist/packem_shared/useClipboard-B_9-adw1.js +23 -0
- package/dist/packem_shared/useColorBlindness-D_sTIhcb.js +30 -0
- package/dist/packem_shared/useConsoleCapture-Dvt7G1W1.js +61 -0
- package/dist/packem_shared/useCursor-BIJzc8k9.js +19 -0
- package/dist/packem_shared/useElementDimensions-CAoKitVD.js +67 -0
- package/dist/packem_shared/useFocus-CNl5QHHf.js +37 -0
- package/dist/packem_shared/useFocusManager-BPYaUuKQ.js +16 -0
- package/dist/packem_shared/useInput-Cfp5zB2s.js +594 -0
- package/dist/packem_shared/useIsScreenReaderEnabled-CnGKCe0f.js +9 -0
- package/dist/packem_shared/useKeyBindings-B78l1E1n.js +66 -0
- package/dist/packem_shared/useMouseAction-C5gZ2nj7.js +29 -0
- package/dist/packem_shared/useMouseContext-D-rFy60Q.js +12 -0
- package/dist/packem_shared/useMousePosition-BHBJ-kBk.js +25 -0
- package/dist/packem_shared/useOnMouseClick--ZIyBOBO.js +35 -0
- package/dist/packem_shared/useOnMouseHover-26diuXUC.js +32 -0
- package/dist/packem_shared/useOnMouseState-NO_Kda_C.js +13 -0
- package/dist/packem_shared/usePaste-Ct8J4AGR.js +35 -0
- package/dist/packem_shared/useScrollAcceleration-R9LfrPVG.js +73 -0
- package/dist/packem_shared/useScrollInput-D3CpBq_a.js +72 -0
- package/dist/packem_shared/useStderr-CAOVUh4E.js +6 -0
- package/dist/packem_shared/useStdin-X-O0kd-n.js +7 -0
- package/dist/packem_shared/useStdout-DyF6DSH0.js +6 -0
- package/dist/packem_shared/useStopwatch-qC4Beai4.js +33 -0
- package/dist/packem_shared/useTerminalPalette-BaWO2c4Q.js +38 -0
- package/dist/packem_shared/useTextBuffer-C8fEe9Ly.js +398 -0
- package/dist/packem_shared/useTextSelection-mXtxgsPK.js +50 -0
- package/dist/packem_shared/useTimer-CPQ7j827.js +46 -0
- package/dist/packem_shared/useTreeView-BT57P3Kx.js +101 -0
- package/dist/packem_shared/useTreeViewState-BpS_KZ-K.js +502 -0
- package/dist/packem_shared/useWindowSize-ugEmGZJm.js +20 -0
- package/dist/packem_shared/utils-BgdlrbOH.js +140 -0
- package/dist/packem_shared/variant-config-DSZoX5TM.js +8 -0
- package/dist/packem_shared/wrapOrTruncateStyledLine-DN3Nogoc.js +147 -0
- package/dist/react/devtools.d.ts +27 -0
- package/dist/react/focus.d.ts +39 -0
- package/dist/react/hooks.d.ts +238 -0
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.js +9 -0
- package/dist/react/layout.d.ts +35 -0
- package/dist/react/react.d.ts +57 -0
- package/dist/react/reconciler.d.ts +4 -0
- package/dist/react/render-to-string.d.ts +21 -0
- package/dist/react/renderer.d.ts +2 -0
- package/dist/react/scene.d.ts +3 -0
- package/dist/react/static.d.ts +39 -0
- package/dist/react/styles.d.ts +83 -0
- package/dist/react/text-width.d.ts +20 -0
- package/dist/testing/index.d.ts +144 -0
- package/dist/testing/index.js +260 -0
- package/dist/testing/keys.d.ts +89 -0
- package/dist/testing/screen.d.ts +35 -0
- package/dist/testing/wait-for.d.ts +21 -0
- package/index.js +585 -0
- package/package.json +117 -7
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { TreeNodeMap } from "./tree-node-map.d.ts";
|
|
2
|
+
import type { SelectionMode, TreeNode, TreeNodeState } from "./types.d.ts";
|
|
3
|
+
export type State<T> = {
|
|
4
|
+
expandedIds: Set<string>;
|
|
5
|
+
focusedId: string | undefined;
|
|
6
|
+
loadingIds: Set<string>;
|
|
7
|
+
nodeMap: TreeNodeMap<T>;
|
|
8
|
+
previousExpandedIds: Set<string>;
|
|
9
|
+
previousSelectedIds: Set<string>;
|
|
10
|
+
selectedIds: Set<string>;
|
|
11
|
+
selectionMode: SelectionMode;
|
|
12
|
+
viewportFromIndex: number;
|
|
13
|
+
viewportToIndex: number;
|
|
14
|
+
/** O(1) lookup from node ID to index in visibleIds. */
|
|
15
|
+
visibleIdIndex: Map<string, number>;
|
|
16
|
+
visibleIds: string[];
|
|
17
|
+
visibleNodeCount: number;
|
|
18
|
+
};
|
|
19
|
+
export type Action<T> = {
|
|
20
|
+
nodeId: string;
|
|
21
|
+
type: "collapse-node";
|
|
22
|
+
} | {
|
|
23
|
+
nodeId: string;
|
|
24
|
+
type: "expand-node";
|
|
25
|
+
} | {
|
|
26
|
+
nodeId: string;
|
|
27
|
+
type: "set-children-error";
|
|
28
|
+
} | {
|
|
29
|
+
children: TreeNode<T>[];
|
|
30
|
+
parentId: string;
|
|
31
|
+
type: "insert-children";
|
|
32
|
+
} | {
|
|
33
|
+
isLoading: boolean;
|
|
34
|
+
nodeId: string;
|
|
35
|
+
type: "set-loading";
|
|
36
|
+
} | {
|
|
37
|
+
state: State<T>;
|
|
38
|
+
type: "reset";
|
|
39
|
+
} | {
|
|
40
|
+
type: "collapse";
|
|
41
|
+
} | {
|
|
42
|
+
type: "collapse-all";
|
|
43
|
+
} | {
|
|
44
|
+
type: "expand";
|
|
45
|
+
} | {
|
|
46
|
+
type: "expand-all";
|
|
47
|
+
} | {
|
|
48
|
+
type: "focus-first";
|
|
49
|
+
} | {
|
|
50
|
+
type: "focus-first-child";
|
|
51
|
+
} | {
|
|
52
|
+
type: "focus-last";
|
|
53
|
+
} | {
|
|
54
|
+
type: "focus-next";
|
|
55
|
+
} | {
|
|
56
|
+
type: "focus-parent";
|
|
57
|
+
} | {
|
|
58
|
+
type: "focus-previous";
|
|
59
|
+
} | {
|
|
60
|
+
type: "select";
|
|
61
|
+
} | {
|
|
62
|
+
type: "toggle-expanded";
|
|
63
|
+
};
|
|
64
|
+
export declare function reducer<T>(state: State<T>, action: Action<T>): State<T>;
|
|
65
|
+
export type CreateDefaultStateProps<T> = {
|
|
66
|
+
data: TreeNode<T>[];
|
|
67
|
+
defaultExpanded?: ReadonlySet<string> | "all";
|
|
68
|
+
defaultSelected?: ReadonlySet<string>;
|
|
69
|
+
selectionMode: SelectionMode;
|
|
70
|
+
visibleNodeCount: number;
|
|
71
|
+
};
|
|
72
|
+
export declare function createDefaultState<T>({ data, defaultExpanded, defaultSelected, selectionMode, visibleNodeCount }: CreateDefaultStateProps<T>): State<T>;
|
|
73
|
+
export type UseTreeViewStateProps<T = Record<string, unknown>> = {
|
|
74
|
+
/** The tree data. Array of root-level nodes. */
|
|
75
|
+
readonly data: TreeNode<T>[];
|
|
76
|
+
/**
|
|
77
|
+
* Set of node IDs that are expanded by default.
|
|
78
|
+
* If not provided, all nodes start collapsed.
|
|
79
|
+
*/
|
|
80
|
+
readonly defaultExpanded?: ReadonlySet<string> | "all";
|
|
81
|
+
/**
|
|
82
|
+
* Set of node IDs that are selected by default.
|
|
83
|
+
*/
|
|
84
|
+
readonly defaultSelected?: ReadonlySet<string>;
|
|
85
|
+
/** Called when expanded set changes. */
|
|
86
|
+
readonly onExpandChange?: (expandedIds: ReadonlySet<string>) => void;
|
|
87
|
+
/** Called when the focused node changes. */
|
|
88
|
+
readonly onFocusChange?: (nodeId: string) => void;
|
|
89
|
+
/** Called when selection changes. */
|
|
90
|
+
readonly onSelectChange?: (selectedIds: ReadonlySet<string>) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Selection mode.
|
|
93
|
+
* @default "none"
|
|
94
|
+
*/
|
|
95
|
+
readonly selectionMode?: SelectionMode;
|
|
96
|
+
/**
|
|
97
|
+
* Number of visible nodes in the viewport (for virtualization).
|
|
98
|
+
* @default Infinity
|
|
99
|
+
*/
|
|
100
|
+
readonly visibleNodeCount?: number;
|
|
101
|
+
};
|
|
102
|
+
export type TreeViewState<T = Record<string, unknown>> = {
|
|
103
|
+
readonly collapse: () => void;
|
|
104
|
+
readonly collapseAll: () => void;
|
|
105
|
+
readonly collapseNode: (nodeId: string) => void;
|
|
106
|
+
readonly expand: () => void;
|
|
107
|
+
readonly expandAll: () => void;
|
|
108
|
+
readonly expandedIds: ReadonlySet<string>;
|
|
109
|
+
readonly expandNode: (nodeId: string) => void;
|
|
110
|
+
readonly focusedId: string | undefined;
|
|
111
|
+
readonly focusFirst: () => void;
|
|
112
|
+
readonly focusFirstChild: () => void;
|
|
113
|
+
readonly focusLast: () => void;
|
|
114
|
+
readonly focusNext: () => void;
|
|
115
|
+
readonly focusParent: () => void;
|
|
116
|
+
readonly focusPrevious: () => void;
|
|
117
|
+
readonly hasScrollDown: boolean;
|
|
118
|
+
readonly hasScrollUp: boolean;
|
|
119
|
+
readonly insertChildren: (parentId: string, children: TreeNode<T>[]) => void;
|
|
120
|
+
readonly loadingIds: ReadonlySet<string>;
|
|
121
|
+
readonly nodeMap: TreeNodeMap<T>;
|
|
122
|
+
readonly select: () => void;
|
|
123
|
+
readonly selectedIds: ReadonlySet<string>;
|
|
124
|
+
readonly setChildrenError: (nodeId: string) => void;
|
|
125
|
+
readonly setLoading: (nodeId: string, isLoading: boolean) => void;
|
|
126
|
+
readonly toggleExpanded: () => void;
|
|
127
|
+
readonly viewportFromIndex: number;
|
|
128
|
+
readonly viewportNodes: {
|
|
129
|
+
node: TreeNode<T>;
|
|
130
|
+
state: TreeNodeState;
|
|
131
|
+
}[];
|
|
132
|
+
readonly viewportToIndex: number;
|
|
133
|
+
readonly visibleCount: number;
|
|
134
|
+
};
|
|
135
|
+
export declare function useTreeViewState<T = Record<string, unknown>>({ data, defaultExpanded, defaultSelected, onExpandChange, onFocusChange, onSelectChange, selectionMode, visibleNodeCount, }: UseTreeViewStateProps<T>): TreeViewState<T>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AsyncChildrenFunction, SelectionMode } from "./types.d.ts";
|
|
2
|
+
import type { TreeViewState } from "./use-tree-view-state.d.ts";
|
|
3
|
+
export type UseTreeViewProps<T = Record<string, unknown>> = {
|
|
4
|
+
/**
|
|
5
|
+
* When disabled, user input is ignored.
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
readonly isDisabled?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Async function to load children on demand.
|
|
11
|
+
*/
|
|
12
|
+
readonly loadChildren?: AsyncChildrenFunction<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Called when `loadChildren` rejects.
|
|
15
|
+
*/
|
|
16
|
+
readonly onLoadError?: (nodeId: string, error: Error) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Selection mode.
|
|
19
|
+
*/
|
|
20
|
+
readonly selectionMode: SelectionMode;
|
|
21
|
+
/**
|
|
22
|
+
* The tree view state from `useTreeViewState`.
|
|
23
|
+
*/
|
|
24
|
+
readonly state: TreeViewState<T>;
|
|
25
|
+
};
|
|
26
|
+
export declare function useTreeView<T>({ isDisabled, loadChildren, onLoadError, selectionMode, state }: UseTreeViewProps<T>): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared variant configuration for Alert and StatusMessage components.
|
|
3
|
+
*/
|
|
4
|
+
type VariantConfig = {
|
|
5
|
+
readonly color: string;
|
|
6
|
+
readonly icon: string;
|
|
7
|
+
};
|
|
8
|
+
export type Variant = "error" | "info" | "success" | "warning";
|
|
9
|
+
declare const VARIANT_CONFIG: Record<Variant, VariantConfig>;
|
|
10
|
+
export default VARIANT_CONFIG;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type CursorPosition = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
};
|
|
5
|
+
declare const showCursorEscape = "\u001B[?25h";
|
|
6
|
+
declare const hideCursorEscape = "\u001B[?25l";
|
|
7
|
+
export { hideCursorEscape, showCursorEscape };
|
|
8
|
+
/**
|
|
9
|
+
* Compare two cursor positions. Returns true if they differ.
|
|
10
|
+
*/
|
|
11
|
+
export declare const cursorPositionChanged: (a: CursorPosition | undefined, b: CursorPosition | undefined) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Build escape sequence to move cursor from bottom of output to the target position and show it.
|
|
14
|
+
* Assumes cursor is at (col 0, line visibleLineCount) — i.e. just after the last output line.
|
|
15
|
+
*/
|
|
16
|
+
export declare const buildCursorSuffix: (visibleLineCount: number, cursorPosition: CursorPosition | undefined) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Build escape sequence to move cursor from previousCursorPosition back to the bottom of output.
|
|
19
|
+
* This must be done before eraseLines or any operation that assumes cursor is at the bottom.
|
|
20
|
+
*/
|
|
21
|
+
export declare const buildReturnToBottom: (previousLineCount: number, previousCursorPosition: CursorPosition | undefined) => string;
|
|
22
|
+
export type CursorOnlyInput = {
|
|
23
|
+
cursorPosition: CursorPosition | undefined;
|
|
24
|
+
cursorWasShown: boolean;
|
|
25
|
+
previousCursorPosition: CursorPosition | undefined;
|
|
26
|
+
previousLineCount: number;
|
|
27
|
+
visibleLineCount: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Build the escape sequence for cursor-only updates (output unchanged, cursor moved).
|
|
31
|
+
* Hides cursor if it was previously shown, returns to bottom, then repositions.
|
|
32
|
+
*/
|
|
33
|
+
export declare const buildCursorOnlySequence: (input: CursorOnlyInput) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Build the prefix that hides cursor and returns to bottom before erasing or rewriting.
|
|
36
|
+
* Returns empty string if cursor was not shown.
|
|
37
|
+
*/
|
|
38
|
+
export declare const buildReturnToBottomPrefix: (cursorWasShown: boolean, previousLineCount: number, previousCursorPosition: CursorPosition | undefined) => string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A specialized LRU map that enforces limits on both the number of entries and
|
|
3
|
+
* the total character length of the keys.
|
|
4
|
+
*
|
|
5
|
+
* When adding a new item, if the new key's length would exceed `maxDataSize`,
|
|
6
|
+
* it evicts the least recently used items until space is available.
|
|
7
|
+
*
|
|
8
|
+
* Ported from jacob314/ink fork (Google LLC, Apache-2.0).
|
|
9
|
+
*/
|
|
10
|
+
declare class DataLimitedLruMap<V> {
|
|
11
|
+
private readonly map;
|
|
12
|
+
private readonly maxDataSize;
|
|
13
|
+
private readonly maxKeys;
|
|
14
|
+
private currentDataSize;
|
|
15
|
+
constructor(maxKeys: number, maxDataSize: number);
|
|
16
|
+
get size(): number;
|
|
17
|
+
clear(): void;
|
|
18
|
+
get(key: string): V | undefined;
|
|
19
|
+
set(key: string, value: V): void;
|
|
20
|
+
}
|
|
21
|
+
export default DataLimitedLruMap;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./devtools-window-polyfill";
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { Node as YogaNode } from "yoga-layout";
|
|
2
|
+
import type { OutputTransformer } from "./render-node-to-output.d.ts";
|
|
3
|
+
import type ResizeObserver from "./resize-observer.d.ts";
|
|
4
|
+
import type { ScrollState } from "./scroll.d.ts";
|
|
5
|
+
import type { StyledLine } from "./styled-line.d.ts";
|
|
6
|
+
import type { Styles } from "./styles.d.ts";
|
|
7
|
+
type InkNode = {
|
|
8
|
+
internal_static?: boolean;
|
|
9
|
+
parentNode: DOMElement | undefined;
|
|
10
|
+
style: Styles;
|
|
11
|
+
yogaNode?: YogaNode;
|
|
12
|
+
};
|
|
13
|
+
type LayoutListener = () => void;
|
|
14
|
+
export type TextName = "#text";
|
|
15
|
+
export type ElementNames = "ink-root" | "ink-box" | "ink-text" | "ink-cursor" | "ink-virtual-text" | "ink-static-render";
|
|
16
|
+
/**
|
|
17
|
+
* Describes a sticky header that should be composited on top of scrolled content.
|
|
18
|
+
* Ported from jacob314/ink fork (Google LLC, Apache-2.0).
|
|
19
|
+
*/
|
|
20
|
+
export type StickyHeader = {
|
|
21
|
+
/** Content-relative end row. */
|
|
22
|
+
endRow: number;
|
|
23
|
+
/** Height in rows. */
|
|
24
|
+
height?: number;
|
|
25
|
+
/** If true, natural 'lines' are already in background content. */
|
|
26
|
+
isStuckOnly: boolean;
|
|
27
|
+
/** Lines rendered in the natural (scrolling) position. */
|
|
28
|
+
lines: ReadonlyArray<StyledLine>;
|
|
29
|
+
/** Natural row offset relative to content start. */
|
|
30
|
+
naturalRow: number;
|
|
31
|
+
/** Reference to the DOM node for this header. */
|
|
32
|
+
node?: DOMElement;
|
|
33
|
+
/** Unique ID of the sticky node. */
|
|
34
|
+
nodeId: number;
|
|
35
|
+
/** ID of the scroll container this header belongs to. */
|
|
36
|
+
scrollContainerId: number | string;
|
|
37
|
+
/** Content-relative start row. */
|
|
38
|
+
startRow: number;
|
|
39
|
+
/** Lines rendered in the stuck (pinned) position, if different. */
|
|
40
|
+
stuckLines?: ReadonlyArray<StyledLine>;
|
|
41
|
+
/** Sticky type: top-pinned or bottom-pinned. */
|
|
42
|
+
type?: "top" | "bottom";
|
|
43
|
+
/** Stuck X position relative to region. */
|
|
44
|
+
x: number;
|
|
45
|
+
/** Stuck Y position relative to region. */
|
|
46
|
+
y: number;
|
|
47
|
+
};
|
|
48
|
+
export type NodeNames = ElementNames | TextName;
|
|
49
|
+
export type CursorAnchorRef = {
|
|
50
|
+
readonly current: DOMElement | undefined | null;
|
|
51
|
+
};
|
|
52
|
+
export type CursorMarker = {
|
|
53
|
+
anchorRef?: CursorAnchorRef;
|
|
54
|
+
inline?: boolean;
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
};
|
|
58
|
+
export type DOMElement = InkNode & {
|
|
59
|
+
attributes: Record<string, DOMNodeAttribute>;
|
|
60
|
+
/**
|
|
61
|
+
* Cached render result (a Region). When set, the entire subtree is
|
|
62
|
+
* skipped during rendering and the cached region is composited directly.
|
|
63
|
+
* Set by setCachedRender(), cleared on unmount by cleanupNodeTree().
|
|
64
|
+
*/
|
|
65
|
+
cachedRender?: import("./region").Region;
|
|
66
|
+
childNodes: DOMNode[];
|
|
67
|
+
internal_accessibility?: {
|
|
68
|
+
role?: "button" | "checkbox" | "combobox" | "list" | "listbox" | "listitem" | "menu" | "menuitem" | "option" | "progressbar" | "radio" | "radiogroup" | "tab" | "tablist" | "table" | "textbox" | "timer" | "toolbar";
|
|
69
|
+
state?: {
|
|
70
|
+
busy?: boolean;
|
|
71
|
+
checked?: boolean;
|
|
72
|
+
disabled?: boolean;
|
|
73
|
+
expanded?: boolean;
|
|
74
|
+
multiline?: boolean;
|
|
75
|
+
multiselectable?: boolean;
|
|
76
|
+
readonly?: boolean;
|
|
77
|
+
required?: boolean;
|
|
78
|
+
selected?: boolean;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
internal_cursor?: CursorMarker;
|
|
82
|
+
internal_hidden?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Auto-incrementing unique identifier for this node.
|
|
85
|
+
*/
|
|
86
|
+
internal_id: number;
|
|
87
|
+
/**
|
|
88
|
+
* Whether this element's scrollback buffer is dirty (needs recalculation).
|
|
89
|
+
*/
|
|
90
|
+
internal_isScrollbackDirty?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Last measured size for ResizeObserver tracking.
|
|
93
|
+
*/
|
|
94
|
+
internal_lastMeasuredSize?: {
|
|
95
|
+
height: number;
|
|
96
|
+
width: number;
|
|
97
|
+
};
|
|
98
|
+
internal_layoutListeners?: Set<LayoutListener>;
|
|
99
|
+
/**
|
|
100
|
+
* Maximum scrollTop ever reached, used with stableScrollback.
|
|
101
|
+
*/
|
|
102
|
+
internal_maxScrollTop?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Whether this element is opaque (prevents rendering of covered content beneath it).
|
|
105
|
+
*/
|
|
106
|
+
internal_opaque?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Whether the scrollbar should be rendered for this scrollable element.
|
|
109
|
+
* Defaults to true for elements with overflow: 'scroll'.
|
|
110
|
+
*/
|
|
111
|
+
internal_scrollbar?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Scroll state computed by calculateScroll() for elements with overflow: 'scroll'.
|
|
114
|
+
*/
|
|
115
|
+
internal_scrollState?: ScrollState;
|
|
116
|
+
/**
|
|
117
|
+
* Whether this element is sticky (pinned during scroll).
|
|
118
|
+
* - `true` or `'top'`: pinned to the top of the scroll container
|
|
119
|
+
* - `'bottom'`: pinned to the bottom of the scroll container
|
|
120
|
+
*/
|
|
121
|
+
internal_sticky?: boolean | "top" | "bottom";
|
|
122
|
+
/**
|
|
123
|
+
* Whether this element is the alternate (stuck) version of a sticky header.
|
|
124
|
+
* The stuck version is rendered when the header is pinned.
|
|
125
|
+
*/
|
|
126
|
+
internal_stickyAlternate?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Whether this element should receive the terminal cursor focus.
|
|
129
|
+
*/
|
|
130
|
+
internal_terminalCursorFocus?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Terminal cursor position offset within this element.
|
|
133
|
+
*/
|
|
134
|
+
internal_terminalCursorPosition?: number;
|
|
135
|
+
/**
|
|
136
|
+
* Cached text squash result for this node's subtree.
|
|
137
|
+
* Invalidated by markNodeAsDirty() when children change.
|
|
138
|
+
*/
|
|
139
|
+
internal_textCache?: {
|
|
140
|
+
map: Map<DOMNode, {
|
|
141
|
+
end: number;
|
|
142
|
+
start: number;
|
|
143
|
+
}>;
|
|
144
|
+
text: string;
|
|
145
|
+
};
|
|
146
|
+
internal_transform?: OutputTransformer;
|
|
147
|
+
isStaticDirty?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Callback invoked after prepareYogaTree() caches the render output for
|
|
150
|
+
* an ink-static-render node. StaticRender uses this to set `isRendered`
|
|
151
|
+
* state, which prevents React from re-reconciling children once cached.
|
|
152
|
+
*/
|
|
153
|
+
internal_onRendered?: () => void;
|
|
154
|
+
/**
|
|
155
|
+
* Whether the Yoga subtree has been detached (children removed from Yoga layout)
|
|
156
|
+
* because a cachedRender was set. When cachedRender is invalidated,
|
|
157
|
+
* prepareYogaTree() re-attaches the children before the next layout pass.
|
|
158
|
+
*/
|
|
159
|
+
isYogaTreeDetached?: boolean;
|
|
160
|
+
nodeName: ElementNames;
|
|
161
|
+
onComputeLayout?: () => void;
|
|
162
|
+
onImmediateRender?: () => void;
|
|
163
|
+
onRender?: () => void;
|
|
164
|
+
/**
|
|
165
|
+
* Set of ResizeObservers attached to this element.
|
|
166
|
+
*/
|
|
167
|
+
resizeObservers?: Set<ResizeObserver>;
|
|
168
|
+
staticNode?: DOMElement;
|
|
169
|
+
};
|
|
170
|
+
export type TextNode = InkNode & {
|
|
171
|
+
nodeName: TextName;
|
|
172
|
+
nodeValue: string;
|
|
173
|
+
};
|
|
174
|
+
export type DOMNode<T = {
|
|
175
|
+
nodeName: NodeNames;
|
|
176
|
+
}> = T extends {
|
|
177
|
+
nodeName: infer U;
|
|
178
|
+
} ? U extends "#text" ? TextNode : DOMElement : never;
|
|
179
|
+
export type DOMNodeAttribute = boolean | string | number;
|
|
180
|
+
export declare const createNode: (nodeName: ElementNames) => DOMElement;
|
|
181
|
+
export declare const appendChildNode: (node: DOMElement, childNode: DOMElement) => void;
|
|
182
|
+
export declare const insertBeforeNode: (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode) => void;
|
|
183
|
+
export declare const removeChildNode: (node: DOMElement, removeNode: DOMNode) => void;
|
|
184
|
+
export declare const setAttribute: (node: DOMElement, key: string, value: DOMNodeAttribute) => void;
|
|
185
|
+
export declare const setStyle: (node: DOMNode, style?: Styles) => void;
|
|
186
|
+
export declare const createTextNode: (text: string) => TextNode;
|
|
187
|
+
export declare const markNodeAsDirty: (node?: DOMNode) => void;
|
|
188
|
+
export declare const setTextNodeValue: (node: TextNode, text: string) => void;
|
|
189
|
+
export declare const addLayoutListener: (rootNode: DOMElement, listener: LayoutListener) => () => void;
|
|
190
|
+
export declare const emitLayoutListeners: (rootNode: DOMElement) => void;
|
|
191
|
+
/**
|
|
192
|
+
* Store a cached render result on a DOM node. Fixes the Yoga node
|
|
193
|
+
* dimensions to match the cached region and removes all Yoga children
|
|
194
|
+
* (since rendering is cached, child layout is no longer needed).
|
|
195
|
+
*
|
|
196
|
+
* Ported from jacob314/ink (Google LLC, Apache-2.0).
|
|
197
|
+
*/
|
|
198
|
+
export declare const setCachedRender: (node: DOMElement, cachedRender: import("./region").Region) => void;
|
|
199
|
+
/**
|
|
200
|
+
* Get the path from the root to this node (inclusive).
|
|
201
|
+
* Returns an array starting with the root and ending with the node.
|
|
202
|
+
*
|
|
203
|
+
* Ported from jacob314/ink fork (Google LLC, Apache-2.0).
|
|
204
|
+
*/
|
|
205
|
+
export declare const getPathToRoot: (node: DOMNode) => DOMNode[];
|
|
206
|
+
/**
|
|
207
|
+
* Check if a node is selectable by walking up the tree checking `userSelect` style.
|
|
208
|
+
* Returns true by default unless an ancestor has `userSelect: 'none'`.
|
|
209
|
+
*
|
|
210
|
+
* Ported from jacob314/ink fork (Google LLC, Apache-2.0).
|
|
211
|
+
*/
|
|
212
|
+
export declare const isNodeSelectable: (node: DOMElement) => boolean;
|
|
213
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Singleton Shiki highlighter for terminal syntax highlighting.
|
|
3
|
+
*
|
|
4
|
+
* Uses codeToTokens() to produce ThemedToken[][] which are mapped
|
|
5
|
+
* to Ink React elements by token-to-elements.tsx.
|
|
6
|
+
*/
|
|
7
|
+
import type { Highlighter, TokensResult } from "shiki";
|
|
8
|
+
/**
|
|
9
|
+
* Get cached tokens or compute and cache them.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getCachedTokens: (highlighter: Highlighter, code: string, lang: string, theme: string) => TokensResult;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a language name to a canonical name, handling aliases.
|
|
14
|
+
*/
|
|
15
|
+
export declare const resolveLanguage: (lang: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a language is supported.
|
|
18
|
+
*/
|
|
19
|
+
export declare const isLanguageSupported: (lang: string) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get or create the singleton Shiki highlighter, optionally loading languages and themes.
|
|
22
|
+
*/
|
|
23
|
+
declare const getHighlighter: (languages?: string[], theme?: string) => Promise<Highlighter>;
|
|
24
|
+
/**
|
|
25
|
+
* Dispose the singleton highlighter, freeing resources.
|
|
26
|
+
*/
|
|
27
|
+
export declare const disposeHighlighter: () => void;
|
|
28
|
+
export default getHighlighter;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type Options = {
|
|
2
|
+
/**
|
|
3
|
+
* Time between ticks in milliseconds.
|
|
4
|
+
*
|
|
5
|
+
* @default 100
|
|
6
|
+
*/
|
|
7
|
+
readonly interval?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the animation is running. When set to `false`, the animation stops.
|
|
10
|
+
* When toggled back to `true`, all values reset to `0`.
|
|
11
|
+
*
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
readonly isActive?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type AnimationResult = {
|
|
17
|
+
/**
|
|
18
|
+
* Time in milliseconds since the previous rendered tick. Accounts for throttled renders.
|
|
19
|
+
* Useful for physics-based or velocity-driven motion: `position += speed * delta`.
|
|
20
|
+
*/
|
|
21
|
+
readonly delta: number;
|
|
22
|
+
/**
|
|
23
|
+
* Discrete counter that increments by 1 each interval.
|
|
24
|
+
* Useful for indexed sequences like spinner frames.
|
|
25
|
+
*/
|
|
26
|
+
readonly frame: number;
|
|
27
|
+
/**
|
|
28
|
+
* Resets `frame`, `time`, and `delta` to `0` and restarts timing from the current moment.
|
|
29
|
+
* Useful for one-shot animations triggered by events.
|
|
30
|
+
*/
|
|
31
|
+
readonly reset: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Total elapsed time in milliseconds since the animation started or was last reset.
|
|
34
|
+
* Useful for continuous math-based animations like sine waves: `Math.sin(time / 1000 * Math.PI * 2)`.
|
|
35
|
+
*/
|
|
36
|
+
readonly time: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A React hook that drives animations. Returns a frame counter, elapsed time, frame delta, and a reset function.
|
|
40
|
+
* All animations share a single timer internally, so multiple animated components consolidate into one render cycle.
|
|
41
|
+
*/
|
|
42
|
+
export default function useAnimation(options?: Options): AnimationResult;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import type { DOMElement } from '../dom.d.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Metrics of a box element.
|
|
5
|
+
*
|
|
6
|
+
* All positions are relative to the element's parent.
|
|
7
|
+
*/
|
|
8
|
+
export type BoxMetrics = {
|
|
9
|
+
/**
|
|
10
|
+
* Element height.
|
|
11
|
+
*/
|
|
12
|
+
readonly height: number;
|
|
13
|
+
/**
|
|
14
|
+
* Distance from the left edge of the parent.
|
|
15
|
+
*/
|
|
16
|
+
readonly left: number;
|
|
17
|
+
/**
|
|
18
|
+
* Distance from the top edge of the parent.
|
|
19
|
+
*/
|
|
20
|
+
readonly top: number;
|
|
21
|
+
/**
|
|
22
|
+
* Element width.
|
|
23
|
+
*/
|
|
24
|
+
readonly width: number;
|
|
25
|
+
};
|
|
26
|
+
export type UseBoxMetricsResult = BoxMetrics & {
|
|
27
|
+
/**
|
|
28
|
+
* Whether the currently tracked element has been measured in the latest layout pass.
|
|
29
|
+
*/
|
|
30
|
+
readonly hasMeasured: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* A React hook that returns the current layout metrics for a tracked box element.
|
|
34
|
+
* It updates when layout changes (for example terminal resize, sibling/content changes, or position changes).
|
|
35
|
+
*
|
|
36
|
+
* The hook returns `{width: 0, height: 0, left: 0, top: 0}` until the first layout pass completes. It also returns zeros when the tracked ref is detached.
|
|
37
|
+
*
|
|
38
|
+
* Use `hasMeasured` to detect when the currently tracked element has been measured.
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
import {useRef} from 'react';
|
|
42
|
+
import {Box, Text, useBoxMetrics} from 'ink';
|
|
43
|
+
|
|
44
|
+
const Example = () => {
|
|
45
|
+
const ref = useRef(null);
|
|
46
|
+
const {width, height, left, top, hasMeasured} = useBoxMetrics(ref);
|
|
47
|
+
return (
|
|
48
|
+
<Box ref={ref}>
|
|
49
|
+
<Text>
|
|
50
|
+
{hasMeasured ? `${width}x${height} at ${left},${top}` : 'Measuring...'}
|
|
51
|
+
</Text>
|
|
52
|
+
</Box>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
```
|
|
56
|
+
*/
|
|
57
|
+
declare const useBoxMetrics: (ref: RefObject<DOMElement>) => UseBoxMetricsResult;
|
|
58
|
+
export default useBoxMetrics;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ClipboardTarget } from "../clipboard.d.ts";
|
|
2
|
+
export type UseClipboardOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* The clipboard target to write to.
|
|
5
|
+
* @default "c"
|
|
6
|
+
*/
|
|
7
|
+
readonly target?: ClipboardTarget;
|
|
8
|
+
};
|
|
9
|
+
export type UseClipboardResult = {
|
|
10
|
+
/**
|
|
11
|
+
* Copy text to the system clipboard.
|
|
12
|
+
* No-op if the terminal does not support OSC 52.
|
|
13
|
+
*/
|
|
14
|
+
readonly copy: (text: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the current terminal supports OSC 52 clipboard operations.
|
|
17
|
+
*/
|
|
18
|
+
readonly isSupported: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Hook that provides clipboard write access via OSC 52.
|
|
22
|
+
*
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const { copy, isSupported } = useClipboard();
|
|
25
|
+
* copy("Hello, clipboard!");
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
declare const useClipboard: (options?: UseClipboardOptions) => UseClipboardResult;
|
|
29
|
+
export default useClipboard;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ColorBlindnessType, ColorMatrix } from "../color-matrix.d.ts";
|
|
2
|
+
export type UseColorBlindnessOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Use compensation mode (shift colors to distinguishable range)
|
|
5
|
+
* instead of simulation mode (show how colors appear to affected users).
|
|
6
|
+
* Not available for achromatopsia.
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
readonly compensate?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Type of color vision deficiency to simulate or compensate for.
|
|
12
|
+
* @default "none"
|
|
13
|
+
*/
|
|
14
|
+
readonly mode?: ColorBlindnessType | "none";
|
|
15
|
+
};
|
|
16
|
+
export type UseColorBlindnessResult = {
|
|
17
|
+
/** Whether a transform is active (mode is not "none"). */
|
|
18
|
+
readonly isActive: boolean;
|
|
19
|
+
/** The active color matrix. */
|
|
20
|
+
readonly matrix: ColorMatrix;
|
|
21
|
+
/** Transform a hex color string through the active matrix. */
|
|
22
|
+
readonly transformColor: (hex: string) => string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Hook for color blindness simulation and compensation.
|
|
26
|
+
*
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const { transformColor } = useColorBlindness({ mode: "deuteranopia" });
|
|
29
|
+
* <Text color={transformColor("#ff0000")}>This text</Text>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare const useColorBlindness: (options?: UseColorBlindnessOptions) => UseColorBlindnessResult;
|
|
33
|
+
export default useColorBlindness;
|