@visulima/tui 1.0.0-alpha.23 → 1.0.0-alpha.25
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 +51 -0
- package/README.md +17 -0
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert.js +1 -1
- package/dist/components/animate-presence.js +1 -1
- package/dist/components/approval-prompt.js +1 -1
- package/dist/components/area-chart.js +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/bar-chart.js +1 -1
- package/dist/components/big-text.js +1 -1
- package/dist/components/blink-dot.js +1 -1
- package/dist/components/box.d.ts +1 -1
- package/dist/components/breadcrumb.js +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.js +1 -1
- package/dist/components/canvas.d.ts +1 -1
- package/dist/components/canvas.js +1 -1
- package/dist/components/card.js +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/code.js +2 -2
- package/dist/components/collapsible.js +1 -1
- package/dist/components/command-block.js +4 -4
- package/dist/components/command-palette.js +1 -1
- package/dist/components/confirm-dialog.js +1 -1
- package/dist/components/confirm-input.js +1 -1
- package/dist/components/console-overlay.js +1 -1
- package/dist/components/content-switcher.js +1 -1
- package/dist/components/controlled-scroll-view.d.ts +1 -1
- package/dist/components/controlled-scroll-view.js +1 -1
- package/dist/components/cursor.d.ts +1 -1
- package/dist/components/cursor.js +1 -1
- package/dist/components/date-picker.js +1 -1
- package/dist/components/definition-list.js +1 -1
- package/dist/components/dialog.d.ts +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/diff-view.js +1 -1
- package/dist/components/divider.js +1 -1
- package/dist/components/file-picker-entry.js +1 -1
- package/dist/components/form.js +1 -1
- package/dist/components/gauge.js +1 -1
- package/dist/components/gradient.js +1 -1
- package/dist/components/heading.js +1 -1
- package/dist/components/heatmap.js +1 -1
- package/dist/components/help.js +1 -1
- package/dist/components/histogram.js +1 -1
- package/dist/components/kbd.js +1 -1
- package/dist/components/line-chart.js +1 -1
- package/dist/components/link.js +1 -1
- package/dist/components/loading-indicator.js +1 -1
- package/dist/components/markdown.js +1 -1
- package/dist/components/masked-input.js +1 -1
- package/dist/components/menu.js +1 -1
- package/dist/components/message-bubble.js +1 -1
- package/dist/components/model-badge.js +1 -1
- package/dist/components/multi-select.js +1 -1
- package/dist/components/newline.js +2 -2
- package/dist/components/operation-tree.js +1 -1
- package/dist/components/option-list.js +1 -1
- package/dist/components/ordered-list.js +1 -1
- package/dist/components/paginator.js +1 -1
- package/dist/components/paragraph.js +1 -1
- package/dist/components/placeholder.js +1 -1
- package/dist/components/progress-bar.js +1 -1
- package/dist/components/radio-group.js +1 -1
- package/dist/components/scatter-plot.js +1 -1
- package/dist/components/scroll-bar-box.d.ts +1 -1
- package/dist/components/scroll-bar-box.js +1 -1
- package/dist/components/scroll-bar.d.ts +1 -1
- package/dist/components/scroll-bar.js +1 -1
- package/dist/components/scroll-list.d.ts +1 -1
- package/dist/components/scroll-list.js +1 -1
- package/dist/components/scroll-view.d.ts +1 -1
- package/dist/components/scroll-view.js +1 -1
- package/dist/components/search-input.js +1 -1
- package/dist/components/select-input-indicator.js +1 -1
- package/dist/components/select-input-item.js +1 -1
- package/dist/components/select-input.js +1 -1
- package/dist/components/shimmer-text.js +1 -1
- package/dist/components/slider.js +1 -1
- package/dist/components/spacer.js +1 -1
- package/dist/components/sparkline.js +1 -1
- package/dist/components/spinner.js +1 -1
- package/dist/components/static-render.d.ts +1 -1
- package/dist/components/static-render.js +1 -1
- package/dist/components/static.js +1 -1
- package/dist/components/status-line.js +1 -1
- package/dist/components/status-message.js +1 -1
- package/dist/components/stepper.js +1 -1
- package/dist/components/stopwatch.js +1 -1
- package/dist/components/streaming-text.js +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/tab.js +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/tag.js +1 -1
- package/dist/components/text-input.js +1 -1
- package/dist/components/text.js +1 -1
- package/dist/components/textarea.js +2 -2
- package/dist/components/timer.js +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/components/transform.js +1 -1
- package/dist/components/transition.js +1 -1
- package/dist/components/tree-view-entry.d.ts +1 -1
- package/dist/components/tree-view-entry.js +1 -1
- package/dist/components/unordered-list.js +1 -1
- package/dist/core/index.js +1 -1
- package/dist/ink/hooks/use-animation.js +1 -1
- package/dist/ink/hooks/use-app.js +1 -1
- package/dist/ink/hooks/use-box-metrics.d.ts +1 -1
- package/dist/ink/hooks/use-box-metrics.js +1 -1
- package/dist/ink/hooks/use-clipboard.js +1 -1
- package/dist/ink/hooks/use-color-blindness.js +1 -1
- package/dist/ink/hooks/use-console-capture.js +1 -1
- package/dist/ink/hooks/use-cursor.js +1 -1
- package/dist/ink/hooks/use-focus-manager.js +1 -1
- package/dist/ink/hooks/use-focus.js +1 -1
- package/dist/ink/hooks/use-form.js +1 -1
- package/dist/ink/hooks/use-hotkey.js +1 -1
- package/dist/ink/hooks/use-input.js +2 -2
- package/dist/ink/hooks/use-interval.js +1 -1
- package/dist/ink/hooks/use-is-screen-reader-enabled.js +1 -1
- package/dist/ink/hooks/use-key-bindings.js +1 -1
- package/dist/ink/hooks/use-key-chord.js +1 -1
- package/dist/ink/hooks/use-linked-scroll.d.ts +1 -1
- package/dist/ink/hooks/use-linked-scroll.js +1 -1
- package/dist/ink/hooks/use-paste.js +1 -1
- package/dist/ink/hooks/use-persistent-state.d.ts +12 -3
- package/dist/ink/hooks/use-persistent-state.js +2 -2
- package/dist/ink/hooks/use-scroll-acceleration.js +1 -1
- package/dist/ink/hooks/use-scroll-input.js +1 -1
- package/dist/ink/hooks/use-stderr.js +1 -1
- package/dist/ink/hooks/use-stdin.js +1 -1
- package/dist/ink/hooks/use-stdout.js +1 -1
- package/dist/ink/hooks/use-stopwatch.js +1 -1
- package/dist/ink/hooks/use-terminal-palette.js +1 -1
- package/dist/ink/hooks/use-text-buffer.js +4 -4
- package/dist/ink/hooks/use-text-selection.d.ts +2 -2
- package/dist/ink/hooks/use-text-selection.js +1 -1
- package/dist/ink/hooks/use-timeout.js +1 -1
- package/dist/ink/hooks/use-timer.js +1 -1
- package/dist/ink/hooks/use-window-size.js +1 -1
- package/dist/ink/index.d.ts +17 -62
- package/dist/ink/index.js +1 -1
- package/dist/ink/mouse/use-element-position.d.ts +31 -0
- package/dist/ink/mouse/use-element-position.js +1 -0
- package/dist/ink/mouse/use-mouse-action.d.ts +5 -0
- package/dist/ink/mouse/use-mouse-action.js +1 -0
- package/dist/ink/mouse/use-mouse-position.d.ts +5 -0
- package/dist/ink/mouse/use-mouse-position.js +1 -0
- package/dist/ink/mouse/use-mouse.d.ts +5 -0
- package/dist/ink/mouse/use-mouse.js +1 -0
- package/dist/ink/mouse/use-on-mouse-click.d.ts +16 -0
- package/dist/ink/mouse/use-on-mouse-click.js +1 -0
- package/dist/ink/mouse/use-on-mouse-hover.d.ts +10 -0
- package/dist/ink/mouse/use-on-mouse-hover.js +1 -0
- package/dist/ink/mouse/use-on-mouse-state.d.ts +13 -0
- package/dist/ink/mouse/use-on-mouse-state.js +1 -0
- package/dist/packem_chunks/devtools.js +1 -1
- package/dist/packem_shared/COLOR_BLINDNESS_COMPENSATION-Ilnoyeqc.js +1 -0
- package/dist/packem_shared/ControlledScrollView-BoN5Oi-p.js +1 -0
- package/dist/packem_shared/DevTools-k6uiVzqv.js +1 -0
- package/dist/packem_shared/FilePicker-BLS9nOPz.js +1 -0
- package/dist/packem_shared/FocusContext-C2Sosxa4.js +1 -0
- package/dist/packem_shared/Fullscreen-BRhuBLBh.js +1 -0
- package/dist/packem_shared/IMECompositionBuffer-VhC9HRCv.js +1 -0
- package/dist/packem_shared/InputParser-CtwkCbrQ.js +2 -0
- package/dist/packem_shared/KEY-C--kOw41.js +1 -0
- package/dist/packem_shared/LayoutNode-LPYsuzBg.js +1 -0
- package/dist/packem_shared/MouseProvider-DUqQ3Eaa.js +1 -0
- package/dist/packem_shared/NAMED_COLORS-82DpREQV.js +1 -0
- package/dist/packem_shared/Range-BsVYNWtg.js +1 -0
- package/dist/packem_shared/Renderer-DsskdkUd.js +1 -0
- package/dist/packem_shared/ResizeObserver-aX8XOr2u.js +1 -0
- package/dist/packem_shared/ScrollBar-BKCK8jsb.js +1 -0
- package/dist/packem_shared/ScrollBarBox-CBhLo6eZ.js +1 -0
- package/dist/packem_shared/ScrollList-DyFyVs6I.js +1 -0
- package/dist/packem_shared/ScrollView-BEgrtSnt.js +1 -0
- package/dist/packem_shared/Static-DSzsElz4.js +1 -0
- package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +1 -0
- package/dist/packem_shared/TreeView-BsvLCsf0.js +1 -0
- package/dist/packem_shared/TuiApp-BPL8v1i1.js +1 -0
- package/dist/packem_shared/TuiContext-BNmP0lMY.js +3 -0
- package/dist/packem_shared/ansi-parser-DlgLtOYO.js +1 -0
- package/dist/packem_shared/ansi-tokenizer-BU67A126.js +1 -0
- package/dist/packem_shared/braille-ch3O5D7I.js +1 -0
- package/dist/packem_shared/calculateScroll-D4Y_JR4H.js +1 -0
- package/dist/packem_shared/calculateScrollbarLayout--eUVRLw7.js +1 -0
- package/dist/packem_shared/clearOsc52-BUpnQOav.js +1 -0
- package/dist/packem_shared/clearStringWidthCache-DKFjfJuB.js +1 -0
- package/dist/packem_shared/colorize-DU4YZkp3.js +1 -0
- package/dist/packem_shared/controlled-scroll-view-t55HU9L8.js +1 -0
- package/dist/packem_shared/createInlineLoop-BT40Wpmx.js +2 -0
- package/dist/packem_shared/createScreen-DoYpyL0V.js +3 -0
- package/dist/packem_shared/dom-rphpG0kf.js +1 -0
- package/dist/packem_shared/{dom.d-C1IxuLJ9.d.ts → dom.d-B4kXbaVY.d.ts} +35 -0
- package/dist/packem_shared/format-time-fjoQHMxD.js +1 -0
- package/dist/packem_shared/{getPathToRoot-BuAM_kmj.js → getPathToRoot-PDJeqiEH.js} +1 -1
- package/dist/packem_shared/input-utils-BSWCb4F_.js +1 -0
- package/dist/packem_shared/isIntersecting-Bo2npvMR.js +1 -0
- package/dist/packem_shared/isTerminalPaletteQuerySupported-BYzmqq9-.js +1 -0
- package/dist/packem_shared/kittyFlags-g8ALyoCU.js +1 -0
- package/dist/packem_shared/line-chart-C7CUrvVs.js +1 -0
- package/dist/packem_shared/load-native-root-binding-DDikxNox.js +1 -0
- package/dist/packem_shared/measure-element-Cs7_proT.js +2 -0
- package/dist/packem_shared/measure-text-B7juNq4Y.js +3 -0
- package/dist/packem_shared/mouse-context.d-BfL9xGk_.d.ts +30 -0
- package/dist/packem_shared/parseSgrMouse-bUrqPrh-.js +1 -0
- package/dist/packem_shared/processLayout-tAee0ytT.js +1 -0
- package/dist/packem_shared/reconciler-CFyBVf7l.js +1 -0
- package/dist/packem_shared/reconciler-ClpU7Y-V.js +1 -0
- package/dist/packem_shared/render-DFZ8NHlG.js +1 -0
- package/dist/packem_shared/render-DSuj2PjD.js +24 -0
- package/dist/packem_shared/{render.d-DuyG0zip.d.ts → render.d-CBnYBDk2.d.ts} +1 -1
- package/dist/packem_shared/renderToString-Do8K5Fyk.js +4 -0
- package/dist/packem_shared/renderToString-L_bpw4OQ.js +2 -0
- package/dist/packem_shared/renderTreeToBuffer-C8lS0lJ2.js +2 -0
- package/dist/packem_shared/renderer-COXHo5Xk.js +17 -0
- package/dist/packem_shared/{selection.d-Dbha5bMS.d.ts → selection.d-CI3_p8wg.d.ts} +1 -1
- package/dist/packem_shared/squashTextNodesWithMap-BmUSBPfc.js +1 -0
- package/dist/packem_shared/stderr-context-Bvnik0hL.js +1 -0
- package/dist/packem_shared/stdin-context-88AhuztD.js +1 -0
- package/dist/packem_shared/text-width-e49vlbQH.js +2 -0
- package/dist/packem_shared/token-to-elements-D6J6-P2A.js +1 -0
- package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +1 -0
- package/dist/packem_shared/useTreeView-D5ifGwG3.js +1 -0
- package/dist/packem_shared/useTreeViewState-BiTJakkh.js +1 -0
- package/dist/packem_shared/utils-Bup8lyK8.js +1 -0
- package/dist/packem_shared/waitFor-CTAki32d.js +4 -0
- package/dist/packem_shared/wrapOrTruncateStyledLine-46W8bTtv.js +3 -0
- package/dist/react/index.js +1 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -1
- package/index.js +691 -539
- package/package.json +48 -23
- package/dist/packem_shared/COLOR_BLINDNESS_SIMULATION-DqErf7XX.js +0 -1
- package/dist/packem_shared/ControlledScrollView-CIc-x1Cx.js +0 -1
- package/dist/packem_shared/DevTools-ClAYpMVI.js +0 -1
- package/dist/packem_shared/FilePicker-tYj_CIau.js +0 -1
- package/dist/packem_shared/FocusContext-Xy0cwJpO.js +0 -1
- package/dist/packem_shared/Fullscreen-CxLd1-Zu.js +0 -1
- package/dist/packem_shared/IMECompositionBuffer-C89PhiOu.js +0 -1
- package/dist/packem_shared/InputParser-B_qZcN3r.js +0 -2
- package/dist/packem_shared/KEY-Bk8B-3h_.js +0 -1
- package/dist/packem_shared/LayoutNode-B8zej4dm.js +0 -1
- package/dist/packem_shared/MouseProvider-PnIUKURs.js +0 -1
- package/dist/packem_shared/NAMED_COLORS-B9fJsYdg.js +0 -1
- package/dist/packem_shared/Renderer-DJXooAsp.js +0 -1
- package/dist/packem_shared/ResizeObserverEntry-Dq0dk8Kq.js +0 -1
- package/dist/packem_shared/ScrollBar-U_37hlIT.js +0 -1
- package/dist/packem_shared/ScrollBarBox-DwiCxilX.js +0 -1
- package/dist/packem_shared/ScrollList-C7nZ9ufK.js +0 -1
- package/dist/packem_shared/ScrollView-DKZ8OM-m.js +0 -1
- package/dist/packem_shared/Static-DLynr5pn.js +0 -1
- package/dist/packem_shared/TreeNodeMap-CspqSCpb.js +0 -1
- package/dist/packem_shared/TreeView-C0Iv3et8.js +0 -1
- package/dist/packem_shared/TuiApp-BVDXP0Cv.js +0 -1
- package/dist/packem_shared/TuiContext-BoJvG3NN.js +0 -3
- package/dist/packem_shared/ansi-parser-B6uXaq65.js +0 -1
- package/dist/packem_shared/ansi-tokenizer-DqX9nJuk.js +0 -1
- package/dist/packem_shared/braille-BBjIoaN0.js +0 -1
- package/dist/packem_shared/colorize-DbTZMrJO.js +0 -1
- package/dist/packem_shared/comparePoints-C3NJirbh.js +0 -1
- package/dist/packem_shared/controlled-scroll-view-CcUS50jx.js +0 -1
- package/dist/packem_shared/createInlineLoop-DRNZ7jqH.js +0 -2
- package/dist/packem_shared/createScreen-CrLrxA6t.js +0 -3
- package/dist/packem_shared/dom-CXB-19sK.js +0 -1
- package/dist/packem_shared/format-time-C7Q-hQZq.js +0 -1
- package/dist/packem_shared/getScrollHeight-ClEOyLHH.js +0 -1
- package/dist/packem_shared/input-utils-fAxzSlNh.js +0 -1
- package/dist/packem_shared/isIntersecting-B3KbKTmu.js +0 -1
- package/dist/packem_shared/isOsc52Supported-DKK7Uee6.js +0 -1
- package/dist/packem_shared/isTerminalPaletteQuerySupported-Dn2hFAZ_.js +0 -1
- package/dist/packem_shared/kittyFlags-C3rZLbcK.js +0 -1
- package/dist/packem_shared/layout-BMo200nF.js +0 -2
- package/dist/packem_shared/line-chart-kf7uhR0K.js +0 -1
- package/dist/packem_shared/measure-text-Ce2widM1.js +0 -3
- package/dist/packem_shared/measureElement-BTtTFZg4.js +0 -1
- package/dist/packem_shared/parseSgrMouse-Ccj70ijb.js +0 -1
- package/dist/packem_shared/processLayout-FEKj_mWu.js +0 -1
- package/dist/packem_shared/reconciler-DIfG72R9.js +0 -1
- package/dist/packem_shared/reconciler-DYE5h4K4.js +0 -1
- package/dist/packem_shared/render-BRR1ESvR.js +0 -26
- package/dist/packem_shared/render-Dh7HMhK1.js +0 -1
- package/dist/packem_shared/renderToString-BbQiRHrd.js +0 -2
- package/dist/packem_shared/renderToString-vEQyGmv6.js +0 -4
- package/dist/packem_shared/renderTreeToBuffer-CZilzyhN.js +0 -2
- package/dist/packem_shared/renderer-maLLQcut.js +0 -17
- package/dist/packem_shared/setEnableStyledLineCache-DSbMbENc.js +0 -1
- package/dist/packem_shared/squashTextNodesWithMap-DCdi3SZ2.js +0 -1
- package/dist/packem_shared/stderr-context-BzEaUICS.js +0 -1
- package/dist/packem_shared/stdin-context-BTaaFagk.js +0 -1
- package/dist/packem_shared/text-width-BU2eeTWn.js +0 -2
- package/dist/packem_shared/token-to-elements-BAZpNZsu.js +0 -1
- package/dist/packem_shared/treeViewTheme-1RIZyB4M.js +0 -1
- package/dist/packem_shared/useElementDimensions-qJ_WXFZ9.js +0 -1
- package/dist/packem_shared/useMouseAction-2dRfU1vE.js +0 -1
- package/dist/packem_shared/useMouseContext-C746G7kY.js +0 -1
- package/dist/packem_shared/useMousePosition-BTWfV4JK.js +0 -1
- package/dist/packem_shared/useOnMouseClick-nY8xLZmt.js +0 -1
- package/dist/packem_shared/useOnMouseHover-D3DczIol.js +0 -1
- package/dist/packem_shared/useOnMouseState-cRK8QvzD.js +0 -1
- package/dist/packem_shared/useTreeView-BoMMeRPq.js +0 -1
- package/dist/packem_shared/useTreeViewState-CRPCUWrb.js +0 -1
- package/dist/packem_shared/utils-CoviI5Vm.js +0 -1
- package/dist/packem_shared/waitFor-Dj5zfL5s.js +0 -4
- package/dist/packem_shared/wrapOrTruncateStyledLine-C5rcIrNb.js +0 -3
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import s from"react";import{FocusProvider as S}from"./FocusContext-C2Sosxa4.js";import{TuiContext as h}from"./TuiContext-BNmP0lMY.js";import{LayoutNode as T}from"./LayoutNode-LPYsuzBg.js";import{T as l}from"./reconciler-ClpU7Y-V.js";import{renderTreeToBuffer as C}from"./renderTreeToBuffer-C8lS0lJ2.js";import{Cell as w}from"./Cell-BrXn3jxY.js";function P(p,u){const r=u?.columns??80,o=u?.rows??24,e=new T;e.yogaNode.setWidth(r),e.yogaNode.setHeight(o);const d={app:null,input:null,writeStderr:n=>{},writeStdout:n=>{}},y=s.createElement(h.Provider,{value:d},s.createElement(S,null,p)),a=l.createContainer(e,0,null,!1,null,"renderToString",()=>{},null);l.updateContainerSync(y,a,null,()=>{}),l.flushSyncWork(),e.calculateLayout(r,o);const c=new Uint32Array(r*o*2);C(e,c,r,o);const t=[];for(let n=0;n<o;n++){let m="";for(let i=0;i<r;i++){const g=c[(n*r+i)*2],f=w.getChar(g);m+=f===""?" ":f}t.push(m.trimEnd())}for(;t.length>0&&t.at(-1)==="";)t.pop();return l.updateContainerSync(null,a,null,()=>{}),l.flushSyncWork(),e.destroy(),t.join(`
|
|
2
|
+
`)}export{P as renderToString};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import q from"cli-boxes";import{resolveColor as O}from"./NAMED_COLORS-82DpREQV.js";import{a as z}from"./text-width-e49vlbQH.js";const D=1114112,E=9608,F=9600,H=9604;function k(o){const t=o?.borderStyle?1:0;return{bottom:o?.borderBottom===!1?0:t,left:o?.borderLeft===!1?0:t,right:o?.borderRight===!1?0:t,top:o?.borderTop===!1?0:t}}function I(o){let t=0;for(const i of o.children){const b=i.getLayout(),e=b.top+b.height;e>t&&(t=e)}const n=o._style,l=n?.paddingBottom??n?.paddingY??n?.padding??0;return t+l}function N(o,t,n,l,i,b,e,m,_,R,p,u){const r=k(u),a=m-r.top-r.bottom,d=u.scrollTop??0,g=I(o),M=a;if(g<=M||a<=0)return;const s=a*2,y=Math.max(2,Math.round(M/g*s)),f=g-M,x=s-y,A=f>0?Math.round(d/f*x):0,c=typeof u.scrollbarThumbColor=="string"?O(u.scrollbarThumbColor):_,h=i+e-1-r.right,w=R<<16|65280|c;for(let B=0;B<a;B++){const T=B*2,Y=T+1,S=T>=A&&T<A+y,L=Y>=A&&Y<A+y;if(!S&&!L)continue;let v=E;S&&!L?v=F:!S&&L&&(v=H),C(t,n,l,h,b+r.top+B,v,w,p)}}function V(o,t,n,l,i,b,e,m,_,R,p,u,r,a){const d=k(a),g=a.scrollTop??0,M=b+d.top;for(const s of o.children){if(!s._style?.sticky)continue;const y=s.getLayout();if(y.top>=g)continue;const f=s.parent;if(f&&f!==o){const w=f.getLayout();if(w.top+w.height<=g)continue}const x=M,A=s.fg===255?_:s.fg,c=s.bg===255?R:s.bg,h=s.styles===0?p:s.styles;X(s,t,n,l,i-y.left,x-y.top,A,c,h,u,r)}}function Q(o,t,n,l){for(let e=0;e<t.length;e+=2)t[e]=32,t[e+1]=65535;const i=[],b={x0:0,x1:n,y0:0,y1:l};try{X(o,t,n,l,0,0,o.fg,o.bg,o.styles,i,b);for(const e of i)W(e.node,t,n,l,e.absX,e.absY,e.w,e.h,e.fg,e.bg,e.styles,e.clip)}catch(e){console.error("Renderer Error:",e)}}function C(o,t,n,l,i,b,e,m){if(l<m.x0||l>=m.x1||i<m.y0||i>=m.y1||l<0||l>=t||i<0||i>=n)return;const _=(i*t+l)*2;o[_]=b,o[_+1]=e}function W(o,t,n,l,i,b,e,m,_,R,p,u){if(!o._style?.borderStyle||e<=0||m<=0)return;const r=q[o._style.borderStyle],a=o._style.borderColor===void 0?_:O(o._style.borderColor),d=p<<16|R<<8|a,g=o._style.borderTop!==!1,M=o._style.borderBottom!==!1,s=o._style.borderLeft!==!1,y=o._style.borderRight!==!1,f=M&&(m>1||!g);if(g)for(let c=0;c<e;c++){let h;e===1?h=s&&y?r.left:s?r.topLeft:y?r.topRight:r.top:c===0&&s?h=r.topLeft:c===e-1&&y?h=r.topRight:h=r.top,C(t,n,l,i+c,b,h.codePointAt(0),d,u)}if(f)for(let c=0;c<e;c++){let h;e===1?h=s&&y?r.left:s?r.bottomLeft:y?r.bottomRight:r.bottom:c===0&&s?h=r.bottomLeft:c===e-1&&y?h=r.bottomRight:h=r.bottom,C(t,n,l,i+c,b+m-1,h.codePointAt(0),d,u)}const x=g?1:0,A=f?m-1:m;for(let c=x;c<A;c++)s&&C(t,n,l,i,b+c,r.left.codePointAt(0),d,u),y&&C(t,n,l,i+e-1,b+c,r.right.codePointAt(0),d,u)}function U(o){if(o._hidden)return"";if(o.text!==void 0)return o.text;const t=o.children.map(U).join("");return typeof o.transform=="function"?o.transform(t,0):t}function j(o,t,n,l,i,b,e,m,_,R){if(e<=0||m<=0)return;let p=0,u=0;for(const r of o){if(r===`
|
|
2
|
+
`){p=0,u++;continue}const a=r.codePointAt(0)??32,d=z(r);if(p+d>e&&(p=0,u++),u>=m)break;if(d>e){C(t,n,l,i+p,b+u,32,_,R),p+=1;continue}C(t,n,l,i+p,b+u,a,_,R),d===2&&p+1<e&&C(t,n,l,i+p+1,b+u,D,_,R),p+=d}}function X(o,t,n,l,i,b,e,m,_,R,p){if(o._hidden)return;const u=o.getLayout(),r=Math.round(i+u.left),a=Math.round(b+u.top),d=Math.round(u.width),g=Math.round(u.height),M=o.fg===255?e:o.fg,s=o.bg===255?m:o.bg,y=o.styles===0?_:o.styles,f={x0:Math.max(p.x0,r),x1:Math.min(p.x1,r+d),y0:Math.max(p.y0,a),y1:Math.min(p.y1,a+g)};if(f.x0>=f.x1||f.y0>=f.y1)return;if(typeof o.transform=="function"){const L=U(o),v=o.transform(L,0),P=y<<16|s<<8|M;j(v,t,n,l,r,a,d,g,P,f);return}if(o.text===void 0){if(s!==255||y!==0){const L=y<<16|s<<8|M;for(let v=0;v<g;v++)for(let P=0;P<d;P++)C(t,n,l,r+P,a+v,32,L,f)}o._style?.borderStyle&&R.push({absX:r,absY:a,bg:s,clip:f,fg:M,h:g,node:o,styles:y,w:d})}else{const L=y<<16|s<<8|M;if(o.bg!==255)for(let v=0;v<g;v++)for(let P=0;P<d;P++)C(t,n,l,r+P,a+v,32,L,f);j(o.text,t,n,l,r,a,d,g,L,f)}const x=o._style,A=x?.overflow??"visible",c=x?.overflowX??A,h=x?.overflowY??A,w=c==="hidden"||c==="scroll",B=h==="hidden"||h==="scroll";let T=f,Y=0,S=0;if(w||B){const L=k(x);T={x0:w?Math.max(f.x0,r+L.left):f.x0,x1:w?Math.min(f.x1,r+d-L.right):f.x1,y0:B?Math.max(f.y0,a+L.top):f.y0,y1:B?Math.min(f.y1,a+g-L.bottom):f.y1},h==="scroll"&&typeof x?.scrollTop=="number"&&(S=-x.scrollTop),c==="scroll"&&typeof x?.scrollLeft=="number"&&(Y=-x.scrollLeft)}for(const L of o.children)L._style?.internalStickyAlternate||X(L,t,n,l,r+Y,a+S,M,s,y,R,T);(h==="scroll"||c==="scroll")&&x?.scrollbar!==!1&&N(o,t,n,l,r,a,d,g,M,y,f,x),h==="scroll"&&typeof x?.scrollTop=="number"&&V(o,t,n,l,r,a,d,g,M,s,y,R,T,x)}export{Q as renderTreeToBuffer};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{l as xe,i as Me}from"./dom-rphpG0kf.js";import{getStringWidth as j,isFullwidthCodePoint as ke,indent as Te}from"@visulima/string";import{B as P,D as H,I as G,U as I,e as z,H as Y,f as q,g as oe,F as $,h as re,S as we,j as Le,p as _e}from"./measure-text-B7juNq4Y.js";import T from"yoga-layout";import{j as A,i as Re,x as ie,c as se}from"./measure-element-Cs7_proT.js";import{g as Be,a as X}from"./colorize-DU4YZkp3.js";import De from"@visulima/colorize";import We from"cli-boxes";import{getScrollTop as Ce}from"./calculateScroll-D4Y_JR4H.js";import be from"./squashTextNodesWithMap-BmUSBPfc.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
3
|
+
const Oe=1114112,Pe=1,He=2,$e=3,Ae=4,Fe=7,Ge=8,Ie=9,ne=22,le=23,ae=24,de=27,he=28,ue=29,ce=39,ge=49,ze="\x1B[",M=o=>o.length===0?"":`${ze}${o.join(";")}m`,Ye=o=>{if(o.length===0)return"";let t="",e=0,r,i,l,n=!1,c=0;const g=o.getSpans();for(const f of g){const s=f.formatFlags&127,{fgColor:h}=f,{bgColor:a}=f,{link:u}=f,d=s;if(d!==e||h!==r||a!==i||u!==l){if(u!==l&&(l&&(t+=l.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),u)){const m=u.startsWith("ST:");t+=`\x1B]8;;${m?u.slice(3):u}${m?"\x1B\\":"\x07"}`}const p=e&(P|H),y=d&(P|H);if(p!==y){const m=e&P&&!(d&P),C=e&H&&!(d&H);(m||C)&&(t+=M([ne])),d&P&&(!(e&P)||C)&&(t+=M([Pe])),d&H&&(!(e&H)||m)&&(t+=M([He]))}d&G&&!(e&G)?t+=M([$e]):!(d&G)&&e&G&&(t+=M([le])),d&I&&!(e&I)?t+=M([Ae]):!(d&I)&&e&I&&(t+=M([ae])),d&z&&!(e&z)?t+=M([Fe]):!(d&z)&&e&z&&(t+=M([de])),d&Y&&!(e&Y)?t+=M([Ge]):!(d&Y)&&e&Y&&(t+=M([he])),d&q&&!(e&q)?t+=M([Ie]):!(d&q)&&e&q&&(t+=M([ue])),h!==r&&(t+=M(h?oe(h,!0):[ce])),a!==i&&(t+=M(a?oe(a,!1):[ge])),n=d!==0||h!==void 0||a!==void 0,e=d,r=h,i=a,l=u}t+=o.getTextRange(c,c+f.length),c+=f.length}return n&&(e&(P|H)&&(t+=M([ne])),e&G&&(t+=M([le])),e&I&&(t+=M([ae])),e&z&&(t+=M([de])),e&Y&&(t+=M([he])),e&q&&(t+=M([ue])),r!==void 0&&(t+=M([ce])),i!==void 0&&(t+=M([ge]))),l&&(t+=l.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),t};class U{widths=new Map;blockWidths=new Map;styledLines=new Map;lines=new Map;maxEntries;pruneToFactor;constructor(t={}){const{maxEntries:e=3e4,pruneToFactor:r=.8}=t;this.maxEntries=Math.max(1,e),this.pruneToFactor=Math.min(.99,Math.max(.1,r))}getStyledLine(t){let e=this.styledLines.get(t);return e===void 0&&(e=this.hasAnsiControlMarker(t)?Le(t):_e(t),this.setCacheEntry(this.styledLines,t,e)),e}getStringWidth(t){let e=this.widths.get(t);return e===void 0&&(e=j(t),this.setCacheEntry(this.widths,t,e)),e}getWidestLine(t){let e=this.blockWidths.get(t);if(e===void 0){let r=0;for(const i of this.getLines(t))r=Math.max(r,this.getStringWidth(i));e=r,this.setCacheEntry(this.blockWidths,t,e)}return e}getLines(t){let e=this.lines.get(t);return e===void 0&&(e=t.split(`
|
|
4
|
+
`),this.setCacheEntry(this.lines,t,e)),e}hasAnsiControlMarker(t){for(const e of t){const r=e.codePointAt(0);if(qe.has(r))return!0}return!1}setCacheEntry(t,e,r){!t.has(e)&&t.size>=this.maxEntries&&this.pruneCache(t),t.set(e,r)}pruneCache(t){const e=Math.floor(this.maxEntries*this.pruneToFactor);for(const r of t.keys())if(t.delete(r),t.size<=e)break}}const qe=new Set([27,144,152,155,157,158,159]),Ke=.6,Xe=30;class J{width;height;caches;grid;clipStack=[];previousLines=[];previousRenderedLines=[];lineMemoizationEnabled=!0;memoizationProbeCountdown=0;constructor(t){const{caches:e,height:r,width:i}=t;this.width=Math.round(i),this.height=Math.round(r),this.caches=e??new U,this.grid=this.createGrid(this.width,this.height)}reset(t,e){this.width=Math.round(t),this.height=Math.round(e),this.clipStack.length=0,this.grid=this.createGrid(this.width,this.height)}startChildRegion(t,e,r,i){const l=Math.round(t),n=Math.round(e);this.clipStack.push({x1:l,x2:l+Math.round(r),y1:n,y2:n+Math.round(i)})}endChildRegion(){this.clipStack.pop()}write(t,e,r,i){if(!r)return;const{transformers:l}=i,n=this.clipStack.at(-1),c=this.caches.getLines(r),g=l.length>0;for(const[f,s]of c.entries()){const h=e+f;if(h<0||h>=this.grid.length||n&&(h<n.y1||h>=n.y2))continue;let a=s;if(g)for(const v of l)a=v(a,f);if(a.length===0)continue;const u=this.grid[h],d=this.caches.getStyledLine(a);let p=t;const y=n?Math.min(n.x2,u.length):1/0,m=d.getSpans();let C=0,L=m[0]?.length??0;for(let v=0;v<d.length;v++){for(;C<m.length&&v>=L;)C++,L+=m[C]?.length??0;if(p>=y)break;if(n&&(p<n.x1||p>=n.x2)){p++,d.getFullWidth(v)&&p++;continue}if(p>=0){p>=u.length&&u.ensureWidth(p+2);const E=m[C],b=d.getFullWidth(v),N=(E?.formatFlags??0)|(b?$:0);u.setCharFast(p,d.getValue(v),N,E?.fgColor,E?.bgColor,E?.link),b&&(p++,p>=u.length&&u.ensureWidth(p+1),u.setCharFast(p,"",N&~$,E?.fgColor,E?.bgColor,E?.link))}p++}}}writeStyledLine(t,e,r){if(r.length===0||e<0||e>=this.grid.length)return;const i=this.clipStack.at(-1);i&&(e<i.y1||e>=i.y2)||this.writeStyledLineToRow(this.grid[e],t,r,this.width,i)}getRootLines(){return this.grid}getCurrentClip(){return this.clipStack.at(-1)}addRegionTree(t,e,r){for(let i=0;i<t.height;i++){const l=r+i;if(l<0||l>=this.grid.length)continue;const n=t.lines[i];if(!n)continue;const c=this.grid[l],g=n.getSpans();let f=0,s=g[0]?.length??0;for(let h=0;h<n.length;h++){for(;f<g.length&&h>=s;)f++,s+=g[f]?.length??0;const a=e+h;if(a<0||a>=c.length)continue;const u=n.getValue(h),d=g[f],p=d!==void 0&&(d.formatFlags&~$)!==0||d?.fgColor!==void 0||d?.bgColor!==void 0||d?.link!==void 0;if(u!==" "||p){const y=(d?.formatFlags??0)|(n.getFullWidth(h)?$:0);c.setCharFast(a,u,y,d?.fgColor,d?.bgColor,d?.link)}}}for(const i of t.children)this.addRegionTree(i,e+i.x,r+i.y)}writeStyledLineToRow(t,e,r,i,l){let n=e;const c=l?Math.min(l.x2,i):1/0,g=r.getSpans();let f=0,s=g[0]?.length??0;for(let h=0;h<r.length;h++){for(;f<g.length&&h>=s;)f++,s+=g[f]?.length??0;if(n>=c)break;if(l&&(n<l.x1||n>=l.x2)){n++,r.getFullWidth(h)&&n++;continue}if(n>=0){n>=t.length&&t.ensureWidth(n+2);const a=g[f],u=r.getFullWidth(h),d=(a?.formatFlags??0)|(u?$:0);t.setCharFast(n,r.getValue(h),d,a?.fgColor,a?.bgColor,a?.link),u&&(n++,n>=t.length&&t.ensureWidth(n+1),t.setCharFast(n,"",d&~$,a?.fgColor,a?.bgColor,a?.link))}n++}}get(){const t=this.grid;this.lineMemoizationEnabled||(this.memoizationProbeCountdown>0?this.memoizationProbeCountdown--:this.lineMemoizationEnabled=!0);const e=this.lineMemoizationEnabled,r=this.previousLines.length>0,i=e&&r&&this.previousLines.length===t.length&&this.previousRenderedLines.length===t.length;this.previousLines.length>t.length&&(this.previousLines.length=t.length),this.previousRenderedLines.length>t.length&&(this.previousRenderedLines.length=t.length);const l=Array.from({length:t.length});let n=0;for(const[c,g]of t.entries()){const f=g;if(i&&this.previousLines[c]?.equals(f)){l[c]=this.previousRenderedLines[c]??"";continue}n++;const s=f.trimEnd(),h=Ye(s);l[c]=h,e&&(this.previousRenderedLines[c]=h,this.previousLines[c]=f.clone())}return e&&i&&t.length>0&&n/t.length>Ke&&this.disableLineMemoization(),{height:t.length,output:l.join(`
|
|
5
|
+
`)}}getBuffer(){const t=this.grid,e=t.length,r=new Uint32Array(this.width*e*2),i=65535;for(let l=0;l<r.length;l+=2)r[l]=32,r[l+1]=i;for(let l=0;l<e;l++){const n=t[l],c=n.getSpans();let g=0,f=c[0]?.length??0;for(let s=0;s<n.length&&s<this.width;s++){for(;g<c.length&&s>=f;)g++,f+=c[g]?.length??0;const h=n.getValue(s);if(h.length===0)continue;const a=h.codePointAt(0)??32,u=(l*this.width+s)*2,d=c[g],p=d?.formatFlags??0,y=d?.fgColor,m=d?.bgColor,C=y?re(y):255,L=m?re(m):255,v=(p&255)<<16|(L&255)<<8|C&255;if(r[u]=a,r[u+1]=v,n.getFullWidth(s)&&s+1<this.width){const E=u+2;r[E]=Oe,r[E+1]=v,s++}}}return{buffer:r,height:e}}createGrid(t,e){const r=[];for(let i=0;i<e;i++)r.push(we.empty(t));return r}disableLineMemoization(){this.lineMemoizationEnabled=!1,this.memoizationProbeCountdown=Xe,this.previousLines.length=0,this.previousRenderedLines.length=0}}const je=o=>Math.round(o.getComputedWidth()-Math.max(0,o.getComputedLeft()+o.getComputedWidth()-(o.getParent()?.getComputedWidth()??o.getComputedWidth()))-o.getComputedPadding(T.EDGE_LEFT)-o.getComputedPadding(T.EDGE_RIGHT)-o.getComputedBorder(T.EDGE_LEFT)-o.getComputedBorder(T.EDGE_RIGHT)),Ve=(o,t,e,r)=>{if(!e.style.backgroundColor)return;const i=Math.round(e.yogaNode.getComputedWidth()),l=Math.round(e.yogaNode.getComputedHeight()),n=e.style.borderStyle&&e.style.borderLeft!==!1?1:0,c=e.style.borderStyle&&e.style.borderRight!==!1?1:0,g=e.style.borderStyle&&e.style.borderTop!==!1?1:0,f=e.style.borderStyle&&e.style.borderBottom!==!1?1:0,s=i-n-c,h=l-g-f;if(!(s>0&&h>0))return;const a=Be(e.style.backgroundColor);if(!a)return;const u=`${a}${" ".repeat(s)}\x1B[49m`;for(let d=0;d<h;d++)r.write(o+n,t+g+d,u,{transformers:[]})},O=(o,t,e,r)=>{let i=X(o,t,"foreground");return i=X(i,e,"background"),r&&(i=De.dim(i)),i},fe=(o,t,e,r,i,l,n,c)=>{if(!e&&!i)return O(o.repeat(t),l,n,c);const g=e?` ${e} `:"",f=i?` ${i} `:"",s=g.length,h=f.length,a=r??"left";if(s+h>=t){if(s>=t)return`${g.slice(0,t-1)}…`;const y=t-s;return y>3?g+f.slice(0,y):g+O(o.repeat(t-s),l,n,c)}const u=t-s-h;if(a==="left"||i)return g+O(o.repeat(u),l,n,c)+f;if(a==="right"){const y=t-s;return O(o.repeat(y),l,n,c)+g}const d=Math.floor(u/2),p=u-d;return O(o.repeat(d),l,n,c)+g+O(o.repeat(p),l,n,c)},Ue=(o,t,e,r)=>{if(e.style.borderStyle){const i=Math.round(e.yogaNode.getComputedWidth()),l=Math.round(e.yogaNode.getComputedHeight()),n=typeof e.style.borderStyle=="string"?We[e.style.borderStyle]:e.style.borderStyle,c=e.style.borderTopColor??e.style.borderColor,g=e.style.borderBottomColor??e.style.borderColor,f=e.style.borderLeftColor??e.style.borderColor,s=e.style.borderRightColor??e.style.borderColor,h=e.style.borderTopBackgroundColor??e.style.borderBackgroundColor,a=e.style.borderBottomBackgroundColor??e.style.borderBackgroundColor,u=e.style.borderLeftBackgroundColor??e.style.borderBackgroundColor,d=e.style.borderRightBackgroundColor??e.style.borderBackgroundColor,p=e.style.borderTopDimColor??e.style.borderDimColor,y=e.style.borderBottomDimColor??e.style.borderDimColor,m=e.style.borderLeftDimColor??e.style.borderDimColor,C=e.style.borderRightDimColor??e.style.borderDimColor,L=e.style.borderTop!==!1,v=e.style.borderBottom!==!1,E=e.style.borderLeft!==!1,b=e.style.borderRight!==!1,N=Math.max(0,i-(E?1:0)-(b?1:0));let x;if(L){const D=E?O(n.topLeft,c,h,p):"",W=b?O(n.topRight,c,h,p):"",R=fe(n.top,N,e.style.borderTopTitle,e.style.borderTopTitleAlignment,e.style.borderTopRightTitle,c,h,p);x=D+R+W}let k=l;L&&(k-=1),v&&(k-=1),k=Math.max(0,k);let w="";E&&(w=`${O(n.left,f,u,m)}
|
|
6
|
+
`.repeat(k));let S="";b&&(S=`${O(n.right,s,d,C)}
|
|
7
|
+
`.repeat(k));let _;if(v){const D=E?O(n.bottomLeft,g,a,y):"",W=b?O(n.bottomRight,g,a,y):"",R=fe(n.bottom,N,e.style.borderBottomTitle,e.style.borderBottomTitleAlignment,void 0,g,a,y);_=D+R+W}const B=L?1:0;x&&r.write(o,t,x,{transformers:[]}),w&&r.write(o,t+B,w,{transformers:[]}),S&&r.write(o+i-1,t+B,S,{transformers:[]}),_&&r.write(o,t+l-1,_,{transformers:[]})}},pe=[],me=({axis:o,color:t,layout:e,output:r})=>{const{thumb:{end:i,endHalf:l,start:n,startHalf:c},x:g,y:f}=e;if(o==="vertical")for(let s=n;s<i;s++){let h="█";const a=2*s>=c&&2*s<l,u=2*s+1>=c&&2*s+1<l;a&&!u?h="▀":!a&&u&&(h="▄");const d=t?X(h,t,"foreground"):h;r.write(g,f+s,d,{transformers:pe})}else for(let s=n;s<i;s++){let h="█";const a=2*s>=c&&2*s<l,u=2*s+1>=c&&2*s+1<l;a&&!u?h="▌":!a&&u&&(h="▐");const d=t?X(h,t,"foreground"):h;r.write(g+s,f,d,{transformers:pe})}},ve=(o,t=[])=>{for(const e of o.childNodes){if(e.nodeName==="#text")continue;const r=e;if(!r.internal_stickyAlternate)if(r.internal_sticky)t.push({node:r,type:r.internal_sticky==="bottom"?"bottom":"top"});else{const i=r.style.overflow??"visible",l=r.style.overflowX??i,n=r.style.overflowY??i;!(l==="scroll"||n==="scroll")&&r.childNodes&&ve(r,t)}}return t},Je=(o,t,e,r)=>{let i,l=-1,n,c=-1;for(const[f,s]of o.entries()){const{node:h,type:a}=s;if(!h.yogaNode)continue;const u=A(h,t)??0,d=Math.round(h.yogaNode.getComputedHeight()),p=u+d,y=h.parentNode;let m=0,C=Number.MAX_SAFE_INTEGER;y?.yogaNode&&(m=A(y,t)??0,C=Math.round(y.yogaNode.getComputedHeight())),a==="top"&&u<e&&m+C>e&&(i=s,l=f),a==="bottom"&&Math.floor(p)>Math.floor(r)&&m<r&&(n=s,c=f)}const g=[];if(i){let f;for(let s=l+1;s<o.length;s++){const h=o[s];if(h.type!=="bottom"){f=h;break}}g.push({nextStickyNodeInfo:f,stickyNode:i.node,type:"top"})}if(n){let f;for(let s=c-1;s>=0;s--){const h=o[s];if(h.type==="bottom"){f=h;break}}g.push({nextStickyNodeInfo:f,stickyNode:n.node,type:"bottom"})}return g},Qe=(o,t,e,r,i)=>{const{newTransformers:l,skipStaticElements:n,x:c,y:g}=i,{yogaNode:f}=t;if(!f)return;const s=f.getComputedBorder(T.EDGE_TOP),h=f.getComputedBorder(T.EDGE_LEFT),a=Ce(t),u=t.internal_scrollState?.clientHeight??0;for(const{nextStickyNodeInfo:d,stickyNode:p,type:y}of o){if(!p.yogaNode)continue;const m=A(p,t)??0,C=Math.round(p.yogaNode.getComputedHeight()),L=c+(Re(p,t)??0),v=p.parentNode;let E=0,b=Number.MAX_SAFE_INTEGER;v?.yogaNode&&(E=A(v,t)??0,b=Math.round(v.yogaNode.getComputedHeight()));let N;if(y==="top"){const w=v?.yogaNode?.getComputedBorder(T.EDGE_BOTTOM)??0,S=E+b-w;let _=g-a+S-C;const B=g-a+m,D=g+s;if(d?.node?.yogaNode){const W=A(d.node,t)??0,R=g-a+W-C;R<_&&(_=R)}N=Math.min(Math.max(D,B),_)}else{const w=v?.yogaNode?.getComputedBorder(T.EDGE_TOP)??0;let S=g-a+E+w;const _=g-a+m,B=g+s+u-C;if(d?.node?.yogaNode){const D=Math.round(d.node.yogaNode.getComputedHeight()),W=A(d.node,t)??0,R=g-a+W+D;R>S&&(S=R)}N=Math.max(Math.min(B,_),S)}const x=r({height:C,width:Math.round(p.yogaNode.getComputedWidth())});K(p,x,{offsetX:-Math.round(p.yogaNode.getComputedLeft()),offsetY:-Math.round(p.yogaNode.getComputedTop()),skipStaticElements:n,transformers:l});const k=x.get().output.split(`
|
|
8
|
+
`);for(const[w,S]of k.entries())S&&S.length>0&&e.write(L-(c+h),N-(g+s)+w,S,{transformers:[]})}},Ze=(o,t)=>{const e=o.childNodes[0]?.yogaNode;if(e){const r=Math.round(e.getComputedLeft()),i=Math.round(e.getComputedTop());t=`
|
|
9
|
+
`.repeat(i)+Te(t,r)}return t},et=31,tt=127,ot=128,rt=159,it=(o,t)=>{if(!Number.isFinite(t))return!1;if(t<0)return!0;let e=0;for(const r of o){if(r===`
|
|
10
|
+
`){if(e>t)return!0;e=0;continue}const i=r.codePointAt(0);if(i<=et||i===tt||i>=ot&&i<=rt||ke(i)||(e++,e>t))return!0}return!1},st=o=>(o.internal_hidden??!1)||o.yogaNode?.getDisplay()===T.DISPLAY_NONE,nt=o=>{let t=o;for(;t;){if(st(t))return!0;t=t.parentNode}return!1},V=(o,t={})=>{if(t.skipStaticElements&&o.internal_static||o.internal_hidden||o.internal_stickyAlternate||o.yogaNode?.getDisplay()===T.DISPLAY_NONE)return"";let e="";if(o.nodeName==="ink-text")e=be(o);else if(o.nodeName==="ink-box"||o.nodeName==="ink-root"){const r=o.style.flexDirection==="row"||o.style.flexDirection==="row-reverse"?" ":`
|
|
11
|
+
`;e=(o.style.flexDirection==="row-reverse"||o.style.flexDirection==="column-reverse"?o.childNodes.toReversed():[...o.childNodes]).map(i=>V(i,{parentRole:o.internal_accessibility?.role,skipStaticElements:t.skipStaticElements})).filter(Boolean).join(r)}if(o.internal_accessibility){const{role:r,state:i}=o.internal_accessibility;if(i){const l=Object.keys(i).filter(n=>i[n]).join(", ");l&&(e=`(${l}) ${e}`)}r&&r!==t.parentRole&&(e=`${r}: ${e}`)}return e},K=(o,t,e)=>{const{absoluteOffsetX:r,absoluteOffsetY:i,offsetX:l=0,offsetY:n=0,renderState:c,skipStaticElements:g,transformers:f=[]}=e;if(g&&o.internal_static||o.internal_hidden)return;if(o.cachedRender){const h=Math.round(l+(o.yogaNode?.getComputedLeft()??0)),a=Math.round(n+(o.yogaNode?.getComputedTop()??0));t.addRegionTree(o.cachedRender,h,a);return}if(o.nodeName==="ink-cursor"){if(!c)return;c.cursorRequested=!0;const h=o.internal_cursor;if(!h){c.cursorPosition=void 0;return}if(c.cursorShape=h.shape,h.inline){if(c.lastTextWriteEnd)c.cursorPosition={x:c.lastTextWriteEnd.x,y:c.lastTextWriteEnd.y};else{const d=o.parentNode?ie(o.parentNode):void 0;c.cursorPosition=d?{x:d.x,y:d.y}:void 0}return}const a=h.anchorRef?h.anchorRef.current:o.parentNode;if(!a){c.cursorPosition=void 0;return}if(h.anchorRef&&nt(a)){c.cursorPosition=void 0;return}const u=ie(a);if(!u){c.cursorPosition=void 0;return}c.cursorPosition={x:u.x+h.x,y:u.y+h.y};return}const{yogaNode:s}=o;if(s){if(s.getDisplay()===T.DISPLAY_NONE)return;const h=s.getComputedLeft(),a=s.getComputedTop(),u=Math.round(l+h),d=Math.round(n+a),p=Math.round((r??l)+h),y=Math.round((i??n)+a),m=t.getCurrentClip();if(m){const b=Math.round(s.getComputedWidth()),N=Math.round(s.getComputedHeight()),x=p+b,k=y+N,w=m.x1??-1/0,S=m.x2??1/0,_=m.y1??-1/0,B=m.y2??1/0;if(x<=w||p>=S||k<=_||y>=B)return}let C=f;if(typeof o.internal_transform=="function"&&(C=[o.internal_transform,...f]),o.nodeName==="ink-text"){let b=be(o);if(b.length>0){const N=je(s);if(it(b,N)&&Math.max(...b.split(`
|
|
12
|
+
`).map(x=>j(x)))>N){const x=o.style.textWrap??"wrap";b=xe(b,Math.floor(N),x)}if(b=Ze(o,b),t.write(u,d,b,{transformers:C}),c){const x=b.split(`
|
|
13
|
+
`),k=x.at(-1)??"";c.lastTextWriteEnd={x:u+j(k),y:d+x.length-1}}}return}let L=!1,v=0,E=0;if(o.nodeName==="ink-box"){Ve(u,d,o,t),Ue(u,d,o,t);const b=o.style.overflow??"visible",N=o.style.overflowX??b,x=o.style.overflowY??b,k=N==="hidden"||N==="scroll",w=x==="hidden"||x==="scroll";if(k||w){const S=Math.round(s.getComputedWidth()),_=Math.round(s.getComputedHeight()),B=k?u+s.getComputedBorder(T.EDGE_LEFT):u,D=k?S-s.getComputedBorder(T.EDGE_LEFT)-s.getComputedBorder(T.EDGE_RIGHT):S,W=w?d+s.getComputedBorder(T.EDGE_TOP):d,R=w?_-s.getComputedBorder(T.EDGE_TOP)-s.getComputedBorder(T.EDGE_BOTTOM):_;t.startChildRegion(B,W,Math.max(0,D),Math.max(0,R)),L=!0,x==="scroll"&&o.internal_scrollState&&(E=-o.internal_scrollState.scrollTop),N==="scroll"&&o.internal_scrollState&&(v=-o.internal_scrollState.scrollLeft)}}if(o.nodeName==="ink-root"||o.nodeName==="ink-box"||o.nodeName==="ink-static-render"){for(const b of o.childNodes)K(b,t,{absoluteOffsetX:p+v,absoluteOffsetY:y+E,offsetX:u+v,offsetY:d+E,renderState:c,skipStaticElements:g,transformers:C});if(o.nodeName==="ink-box"&&o.internal_scrollState){const b=ve(o);if(b.length>0){const N=Ce(o),x=o.internal_scrollState.clientHeight,k=N+x,w=Je(b,o,N,k);w.length>0&&Qe(w,o,t,S=>new J(S),{newTransformers:C,skipStaticElements:g,x:u,y:d})}}if(o.nodeName==="ink-box"&&o.internal_scrollState){const b=o.style.overflow??"visible",N=o.style.overflowX??b,x=o.style.overflowY??b,k=s.getComputedBorder(T.EDGE_LEFT),w=s.getComputedBorder(T.EDGE_RIGHT),S=s.getComputedBorder(T.EDGE_TOP),_=s.getComputedBorder(T.EDGE_BOTTOM),B=Math.round(s.getComputedWidth()-k-w),D=Math.round(s.getComputedHeight()-S-_),{clientHeight:W,clientWidth:R,scrollHeight:Q,scrollLeft:Ne,scrollTop:Se,scrollWidth:Z}=o.internal_scrollState,ee=x==="scroll"&&Q>W,Ee=N==="scroll"&&Z>R,te=o.internal_scrollbar!==!1;if(ee&&te){const F=se({axis:"vertical",clientDimension:W,hasOppositeScrollbar:!1,height:D,marginBottom:0,marginRight:0,scrollDimension:Q,scrollPosition:Se,width:B,x:u+k,y:d+S});F&&me({axis:"vertical",color:o.style.scrollbarThumbColor,layout:F,output:t})}if(Ee&&te){const F=se({axis:"horizontal",clientDimension:R,hasOppositeScrollbar:ee,height:D,marginBottom:0,marginRight:0,scrollDimension:Z,scrollPosition:Ne,width:B,x:u+k,y:d+S});F&&me({axis:"horizontal",color:o.style.scrollbarThumbColor,layout:F,output:t})}}L&&t.endChildRegion()}}},St=(o,t)=>{if(!o.yogaNode)return;const e=Math.round(o.yogaNode.getComputedWidth()),r=Math.round(o.yogaNode.getComputedHeight());if(e<=0||r<=0)return;const{setCachedRender:i}=require("./dom"),l=new J({height:r,width:e});for(const c of o.childNodes)K(c,l,{skipStaticElements:t?.skipStaticElements});const n={children:[],cursorPosition:void 0,height:r,id:o.internalId??"static",isScrollable:!1,lines:[...l.getRootLines()],selectableSpans:[],stickyHeaders:[],styledOutput:[...l.getRootLines()],width:e,x:0,y:0};i(o,n)},lt=(o,t)=>{const e=new Map;if(t.rangeCount===0)return e;const r=t.getRangeAt(0),{endContainer:i,endOffset:l,startContainer:n,startOffset:c}=r;if(!n||!i)return e;let g=!1,f=!1;const s=(a,u,d,p,y,m)=>{if(a.nodeName==="#text"){const{length:C}=a.nodeValue;n===a&&(y.value=!0,d.value=u.value+c),i===a&&(m.value=!0,p.value=u.value+l),u.value+=C}else if("childNodes"in a){for(const C of a.childNodes)a===n&&(y.value=!0,d.value=u.value),a===i&&(m.value=!0,p.value=u.value),s(C,u,d,p,y,m);a===n&&c===a.childNodes.length&&(y.value=!0,d.value=u.value),a===i&&l===a.childNodes.length&&(m.value=!0,p.value=u.value)}},h=a=>{if(a.nodeName==="ink-text"){if(!Me(a))return;const u={value:0},d={value:-1},p={value:-1},y={value:!1},m={value:!1};for(const C of a.childNodes)a===n&&(y.value=!0,d.value=u.value),a===i&&(m.value=!0,p.value=u.value),s(C,u,d,p,y,m);if(a===n&&c===a.childNodes.length&&(y.value=!0,d.value=u.value),a===i&&l===a.childNodes.length&&(m.value=!0,p.value=u.value),(g||y.value)&&(!f||m.value)){const C=y.value?d.value:0,L=m.value?p.value:u.value;C!==-1&&L!==-1&&C<L&&e.set(a,{end:L,start:C})}y.value&&(g=!0),m.value&&(f=!0)}else{const{childNodes:u}=a;if(u){for(const d of u)a===n&&(g=!0),a===i&&(f=!0),h(d);a===n&&c===u.length&&(g=!0),a===i&&l===u.length&&(f=!0)}}};return h(o),e},at=new U,dt=new U,ht=new WeakMap,ut=new WeakMap,ye=({caches:o,height:t,node:e,outputs:r,width:i})=>{let l=r.get(e);return l||(l=new J({caches:o,height:t,width:i}),r.set(e,l)),l.reset(i,t),l},Et=(o,t,e)=>{if(o.yogaNode){if(t){const g=V(o,{skipStaticElements:!0}),f=g===""?0:g.split(`
|
|
14
|
+
`).length;let s="";return o.staticNode&&(s=V(o.staticNode,{skipStaticElements:!1})),{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:g,outputHeight:f,staticOutput:s?`${s}
|
|
15
|
+
`:""}}e?.selection&&e.selection.rangeCount>0&<(o,e.selection);const r=ye({caches:at,height:o.yogaNode.getComputedHeight(),node:o,outputs:ht,width:o.yogaNode.getComputedWidth()}),i={cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0};K(o,r,{renderState:i,skipStaticElements:!0});let l;if(o.staticNode?.yogaNode&&(l=ye({caches:dt,height:o.staticNode.yogaNode.getComputedHeight(),node:o,outputs:ut,width:o.staticNode.yogaNode.getComputedWidth()}),K(o.staticNode,l,{skipStaticElements:!1})),e?.useNativeRenderer){const{buffer:g,height:f}=r.getBuffer();return{cursorPosition:i.cursorPosition,cursorRequested:i.cursorRequested,cursorShape:i.cursorShape,output:"",outputBuffer:g,outputHeight:f,outputWidth:r.width,staticOutput:l?`${l.get().output}
|
|
16
|
+
`:""}}const{height:n,output:c}=r.get();return{cursorPosition:i.cursorPosition,cursorRequested:i.cursorRequested,cursorShape:i.cursorShape,output:c,outputHeight:n,staticOutput:l?`${l.get().output}
|
|
17
|
+
`:""}}return{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:"",outputHeight:0,staticOutput:""}};export{Et as H,J as I,St as r,K as v};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DOMNode, S as StyledLine } from "./dom.d-
|
|
1
|
+
import { a as DOMNode, S as StyledLine } from "./dom.d-B4kXbaVY.js";
|
|
2
2
|
/**
|
|
3
3
|
* Compare the document position of two points in the DOM tree.
|
|
4
4
|
* Returns -1 if A is before B, 0 if equal, 1 if A is after B.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as u,t as d}from"./ansi-tokenizer-BU67A126.js";const f=/^[\d:;]*$/,h="\x1B]8;",m="8;",x=n=>n.startsWith(h)||n.startsWith(m),p=n=>{if(!u(n))return n;let s="";for(const t of d(n)){if(t.type==="text"){s+=t.value;continue}if(t.type==="osc"&&x(t.value)){s+=t.value;continue}t.type==="csi"&&t.finalCharacter==="m"&&t.intermediateString===""&&f.test(t.parameterString)&&(s+=t.value)}return s},N=n=>{let s="";for(let t=0;t<n.childNodes.length;t++){const r=n.childNodes[t];if(r===void 0)continue;let a="";r.nodeName==="#text"?a=r.nodeValue:((r.nodeName==="ink-text"||r.nodeName==="ink-virtual-text")&&(a=N(r)),a.length>0&&typeof r.internal_transform=="function"&&(a=r.internal_transform(a,t))),s+=a}return p(s)},g=(n,s,t)=>{if(n.internal_textCache){const{map:o,text:e}=n.internal_textCache;for(const[i,c]of o.entries())s.set(i,{end:c.end+t.current,start:c.start+t.current});return t.current+=e.length,e}let r="";const a=new Map,l={current:0};for(let o=0;o<n.childNodes.length;o++){const e=n.childNodes[o];if(e===void 0)continue;let i="";const c=l.current;e.nodeName==="#text"?(i=e.nodeValue,a.set(e,{end:c+i.length,start:c}),l.current+=i.length):((e.nodeName==="ink-text"||e.nodeName==="ink-virtual-text")&&(i=g(e,a,l),a.set(e,{end:l.current,start:c})),i.length>0&&typeof e.internal_transform=="function"&&(i=e.internal_transform(i,o))),r+=i}n.internal_textCache={map:a,text:r};for(const[o,e]of a.entries())s.set(o,{end:e.end+t.current,start:e.start+t.current});return t.current+=r.length,r};export{N as default,g as squashTextNodesWithMap};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{createContext as s}from"react";const i=e(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,t=r,o=s({stderr:t.stderr,write(){}});o.displayName="InternalStderrContext";export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as o}from"node:module";import{createContext as d}from"react";const r=o(import.meta.url),e=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,i=n=>{if(typeof e<"u"&&e.versions&&e.versions.node){const[t,s]=e.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return e.getBuiltinModule(n)}return r(n)},{EventEmitter:a}=i("node:events"),c=e,l=d({internal_eventEmitter:new a,internal_exitOnCtrlC:!0,isRawModeSupported:!1,setBracketedPasteMode(){},setRawMode(){},stdin:c.stdin});l.displayName="InternalStdinContext";export{l as e};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getStringWidth as u}from"@visulima/string";const a={ambiguousIsNarrow:!0,emojiWidth:1};function c(t){return Math.max(1,u(t,a))}function f(t){return u(t,a)}function g(t,o){if(o<=0)return 0;if(t.length===0)return 1;let i=1,n=0;for(const r of t){const e=Math.min(c(r),o);n+e>o&&(i++,n=0),n+=e}return i}function d(t,o){const i=t.split(`
|
|
2
|
+
`);let n=0,r=0;for(const e of i){const s=f(e);s>n&&(n=s),r+=o>0?g(e,o):0}return{maxLineWidth:n,wrappedRows:r}}export{c as a,f as g,d as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as c,jsxs as k,Fragment as j}from"react/jsx-runtime";import{Box as f}from"../components/box.js";import{Text as d}from"../components/text.js";const w={bash:()=>import("@shikijs/langs/bash"),c:()=>import("@shikijs/langs/c"),clojure:()=>import("@shikijs/langs/clojure"),cpp:()=>import("@shikijs/langs/cpp"),csharp:()=>import("@shikijs/langs/csharp"),css:()=>import("@shikijs/langs/css"),dart:()=>import("@shikijs/langs/dart"),diff:()=>import("@shikijs/langs/diff"),dockerfile:()=>import("@shikijs/langs/dockerfile"),elixir:()=>import("@shikijs/langs/elixir"),erlang:()=>import("@shikijs/langs/erlang"),go:()=>import("@shikijs/langs/go"),graphql:()=>import("@shikijs/langs/graphql"),groovy:()=>import("@shikijs/langs/groovy"),haskell:()=>import("@shikijs/langs/haskell"),html:()=>import("@shikijs/langs/html"),java:()=>import("@shikijs/langs/java"),javascript:()=>import("@shikijs/langs/javascript"),json:()=>import("@shikijs/langs/json"),jsonc:()=>import("@shikijs/langs/jsonc"),jsx:()=>import("@shikijs/langs/jsx"),kotlin:()=>import("@shikijs/langs/kotlin"),less:()=>import("@shikijs/langs/less"),lua:()=>import("@shikijs/langs/lua"),makefile:()=>import("@shikijs/langs/makefile"),markdown:()=>import("@shikijs/langs/markdown"),mdx:()=>import("@shikijs/langs/mdx"),nginx:()=>import("@shikijs/langs/nginx"),objc:()=>import("@shikijs/langs/objc"),perl:()=>import("@shikijs/langs/perl"),php:()=>import("@shikijs/langs/php"),powershell:()=>import("@shikijs/langs/powershell"),prisma:()=>import("@shikijs/langs/prisma"),python:()=>import("@shikijs/langs/python"),r:()=>import("@shikijs/langs/r"),ruby:()=>import("@shikijs/langs/ruby"),rust:()=>import("@shikijs/langs/rust"),scala:()=>import("@shikijs/langs/scala"),scss:()=>import("@shikijs/langs/scss"),shell:()=>import("@shikijs/langs/shell"),sql:()=>import("@shikijs/langs/sql"),svelte:()=>import("@shikijs/langs/svelte"),swift:()=>import("@shikijs/langs/swift"),text:()=>Promise.resolve({name:"text",patterns:[],repository:{},scopeName:"source.text"}),toml:()=>import("@shikijs/langs/toml"),tsx:()=>import("@shikijs/langs/tsx"),typescript:()=>import("@shikijs/langs/typescript"),vue:()=>import("@shikijs/langs/vue"),xml:()=>import("@shikijs/langs/xml"),yaml:()=>import("@shikijs/langs/yaml"),zig:()=>import("@shikijs/langs/zig")},L={"c#":"csharp","c++":"cpp",docker:"dockerfile",gql:"graphql",hs:"haskell",js:"javascript",kt:"kotlin",md:"markdown","objective-c":"objc",ps1:"powershell",py:"python",rb:"ruby",rs:"rust",sh:"bash",ts:"typescript",yml:"yaml",zsh:"bash"},$={"catppuccin-frappe":()=>import("@shikijs/themes/catppuccin-frappe"),"catppuccin-latte":()=>import("@shikijs/themes/catppuccin-latte"),"catppuccin-macchiato":()=>import("@shikijs/themes/catppuccin-macchiato"),"catppuccin-mocha":()=>import("@shikijs/themes/catppuccin-mocha"),"dark-plus":()=>import("@shikijs/themes/dark-plus"),dracula:()=>import("@shikijs/themes/dracula"),"github-dark":()=>import("@shikijs/themes/github-dark"),"github-dark-default":()=>import("@shikijs/themes/github-dark-default"),"github-dark-dimmed":()=>import("@shikijs/themes/github-dark-dimmed"),"github-light":()=>import("@shikijs/themes/github-light"),"github-light-default":()=>import("@shikijs/themes/github-light-default"),"light-plus":()=>import("@shikijs/themes/light-plus"),"min-dark":()=>import("@shikijs/themes/min-dark"),"min-light":()=>import("@shikijs/themes/min-light"),monokai:()=>import("@shikijs/themes/monokai"),nord:()=>import("@shikijs/themes/nord"),"one-dark-pro":()=>import("@shikijs/themes/one-dark-pro"),"one-light":()=>import("@shikijs/themes/one-light"),poimandres:()=>import("@shikijs/themes/poimandres"),"rose-pine":()=>import("@shikijs/themes/rose-pine"),"rose-pine-dawn":()=>import("@shikijs/themes/rose-pine-dawn"),"rose-pine-moon":()=>import("@shikijs/themes/rose-pine-moon"),"slack-dark":()=>import("@shikijs/themes/slack-dark"),"slack-ochin":()=>import("@shikijs/themes/slack-ochin"),"solarized-dark":()=>import("@shikijs/themes/solarized-dark"),"solarized-light":()=>import("@shikijs/themes/solarized-light"),"tokyo-night":()=>import("@shikijs/themes/tokyo-night"),"vitesse-dark":()=>import("@shikijs/themes/vitesse-dark"),"vitesse-light":()=>import("@shikijs/themes/vitesse-light")};let h;const m=new Map,n=new Map,T=50,a=new Map,C=(o,r,t)=>`${o.length}:${o}\0${r}\0${t}`,H=(o,r,t,e)=>{const i=C(r,t,e);if(a.has(i)){const p=a.get(i);return a.delete(i),a.set(i,p),p}const s=o.codeToTokens(r,{lang:t,theme:e});if(a.set(i,s),a.size>T){const p=a.keys().next().value;p!==void 0&&a.delete(p)}return s},S=async()=>{const[o,r]=await Promise.all([import("shiki/core"),import("shiki/engine/javascript")]),{createHighlighterCore:t}=o,{createJavaScriptRegexEngine:e}=r;return await t({engine:e(),langs:[],themes:[import("@shikijs/themes/github-dark-default")]})},y=o=>{const r=o.toLowerCase();return L[r]??r},J=o=>y(o)in w,z=async(o,r)=>{const t=y(r);if(!(t==="text"||(o.getLoadedLanguages?.()??[]).includes(t))){if(!m.has(t)){const e=(async()=>{try{const i=w[t];i&&await o.loadLanguage(await i())}catch(i){throw m.delete(t),i}})();m.set(t,e)}await m.get(t)}},q=async(o,r)=>{if((o.getLoadedThemes?.()??[]).includes(r))return;const t=$[r];if(t){if(!n.has(r)){const e=(async()=>{try{await o.loadTheme(await t())}catch(i){throw n.delete(r),i}})();n.set(r,e)}await n.get(r)}},R=async(o=[],r)=>{h||(h=S());const t=await h,e=o.map(i=>z(t,i));return r&&r!=="github-dark-default"&&e.push(q(t,r)),await Promise.all(e),t},M=1,P=2,E=4,N=8,b=(o,r)=>{const t=o.fontStyle??0;return c(d,{backgroundColor:o.bgColor,bold:(t&P)!==0,color:o.color,italic:(t&M)!==0,strikethrough:(t&N)!==0,underline:(t&E)!==0,children:o.content},r)},A=o=>c(j,{children:o.map((r,t)=>b(r,t))}),G=(o,r={})=>{const{highlightLines:t,showLineNumbers:e=!1,startLine:i=1}=r,s=e?String(i+o.length-1).length:0;return c(f,{flexDirection:"column",children:o.map((p,g)=>{const u=i+g,l=t?.has(u)??!1;return k(f,{children:[e?k(d,{color:l?"yellow":void 0,dimColor:!l,children:[String(u).padStart(s)," "]}):void 0,c(d,{backgroundColor:l?"#3a3a00":void 0,children:p.length>0?p.map((x,v)=>b(x,v)):""})]},g)})})};export{A as a,H as g,J as i,y as r,G as t,R as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const c={styles:{container:()=>({flexDirection:"column"}),expandIndicator:e=>({color:"gray"}),focusIndicator:()=>({color:"blue"}),indent:({depth:e})=>({width:(e??0)*2}),label:({isFocused:e,isSelected:n})=>{let o;return n&&(o="green"),e&&(o="blue"),{color:o}},loadingIndicator:()=>({color:"yellow"}),node:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"})}};export{c as theme};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRef as s,useCallback as g}from"react";import I from"../ink/hooks/use-input.js";function C({isDisabled:h=!1,loadChildren:d,onLoadError:i,selectionMode:f,state:e}){const u=s(new Set),n=s(e);n.current=e;const a=s(d);a.current=d;const l=s(i);l.current=i;const p=g(async t=>{if(u.current.has(t))return;const r=a.current;if(!r)return;const o=n.current.nodeMap.get(t);if(!(!o||o.childrenIds.length>0)){u.current.add(t),n.current.setLoading(t,!0);try{const c=await r(o.node);n.current.insertChildren(t,c),n.current.expandNode(t)}catch(c){const x=c instanceof Error?c:new Error(String(c));n.current.setChildrenError(t),l.current?.(t,x)}finally{n.current.setLoading(t,!1),u.current.delete(t)}}},[]);I((t,r)=>{if(r.downArrow){e.focusNext();return}if(r.upArrow){e.focusPrevious();return}if(r.rightArrow){if(e.focusedId&&e.expandedIds.has(e.focusedId))e.focusFirstChild();else if(e.focusedId){if(d){const o=e.nodeMap.get(e.focusedId);if(o&&o.hasChildren&&o.childrenIds.length===0){p(e.focusedId).catch(()=>{});return}}e.expand()}return}if(r.leftArrow){e.focusedId&&e.expandedIds.has(e.focusedId)?e.collapse():e.focusParent();return}if(r.return){f==="none"?e.toggleExpanded():e.select();return}if(t===" "){f==="multiple"?e.select():e.toggleExpanded();return}if(t==="\x1B[H"||t==="\x1B[1~"||t==="\x1BOH"){e.focusFirst();return}(t==="\x1B[F"||t==="\x1B[4~"||t==="\x1BOF")&&e.focusLast()},{isActive:!h})}export{C as useTreeView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useReducer as H,useState as J,useRef as v,useEffect as b,useMemo as K,useCallback as l}from"react";import{TreeNodeMap as Q}from"./TreeNodeMap-cJlYqckB.js";function p(e){const t=new Map;for(const[d,s]of e.entries())t.set(s,d);return t}function f(e,t){if(e.visibleNodeCount>=e.visibleIds.length)return{viewportFromIndex:0,viewportToIndex:e.visibleIds.length};let d=e.viewportFromIndex,s=e.viewportToIndex;return t>=s&&(s=t+1,d=s-e.visibleNodeCount),t<d&&(d=t,s=d+e.visibleNodeCount),{viewportFromIndex:Math.max(0,d),viewportToIndex:Math.min(e.visibleIds.length,s)}}function w(e,t){if(e.visibleNodeCount>=t.length)return{viewportFromIndex:0,viewportToIndex:t.length};const d=e.focusedId?t.indexOf(e.focusedId):-1;if(d<0)return{viewportFromIndex:0,viewportToIndex:Math.min(e.visibleNodeCount,t.length)};let s=Math.min(e.viewportToIndex,t.length),o=Math.max(0,s-e.visibleNodeCount);return d>=s&&(s=d+1,o=s-e.visibleNodeCount),d<o&&(o=d,s=o+e.visibleNodeCount),{viewportFromIndex:Math.max(0,o),viewportToIndex:Math.min(t.length,s)}}function x(e,t){switch(t.type){case"collapse":return e.focusedId?x(e,{nodeId:e.focusedId,type:"collapse-node"}):e;case"collapse-all":{const d=new Set,s=e.nodeMap.getVisibleIds(d);return{...e,expandedIds:d,focusedId:s[0],previousExpandedIds:e.expandedIds,viewportFromIndex:0,viewportToIndex:Math.min(e.visibleNodeCount,s.length),visibleIdIndex:p(s),visibleIds:s}}case"collapse-node":{const{nodeId:d}=t;if(!e.expandedIds.has(d))return e;const s=new Set(e.expandedIds);s.delete(d);const o=e.nodeMap.getVisibleIds(s);let r=e.focusedId;return r!==void 0&&r!==d&&e.nodeMap.isDescendantOf(r,d)&&(r=d),{...e,expandedIds:s,focusedId:r,previousExpandedIds:e.expandedIds,visibleIdIndex:p(o),visibleIds:o,...w({...e,focusedId:r},o)}}case"expand":return e.focusedId?x(e,{nodeId:e.focusedId,type:"expand-node"}):e;case"expand-all":{const d=new Set;for(const[o,r]of e.nodeMap.entries())r.hasChildren&&d.add(o);const s=e.nodeMap.getVisibleIds(d);return{...e,expandedIds:d,previousExpandedIds:e.expandedIds,visibleIdIndex:p(s),visibleIds:s,...w({...e},s)}}case"expand-node":{const{nodeId:d}=t;if(!e.nodeMap.get(d)?.hasChildren||e.expandedIds.has(d))return e;const s=new Set(e.expandedIds);s.add(d);const o=e.nodeMap.getVisibleIds(s);return{...e,expandedIds:s,previousExpandedIds:e.expandedIds,visibleIdIndex:p(o),visibleIds:o,...w({...e},o)}}case"focus-first":return e.visibleIds.length===0?e:{...e,focusedId:e.visibleIds[0],viewportFromIndex:0,viewportToIndex:Math.min(e.visibleNodeCount,e.visibleIds.length)};case"focus-first-child":{if(!e.focusedId)return e;const d=e.nodeMap.get(e.focusedId);if(!d||d.childrenIds.length===0||!e.expandedIds.has(e.focusedId))return e;const s=d.childrenIds[0],o=e.visibleIdIndex.get(s)??-1;return o<0?e:{...e,focusedId:s,...f(e,o)}}case"focus-last":{if(e.visibleIds.length===0)return e;const d=e.visibleIds.length-1;return{...e,focusedId:e.visibleIds[d],...f(e,d)}}case"focus-next":{if(!e.focusedId)return e;const d=e.visibleIdIndex.get(e.focusedId)??-1;if(d<0||d>=e.visibleIds.length-1)return e;const s=e.visibleIds[d+1];return{...e,focusedId:s,...f(e,d+1)}}case"focus-parent":{if(!e.focusedId)return e;const d=e.nodeMap.get(e.focusedId);if(!d?.parentId)return e;const s=e.visibleIdIndex.get(d.parentId)??-1;return s<0?e:{...e,focusedId:d.parentId,...f(e,s)}}case"focus-previous":{if(!e.focusedId)return e;const d=e.visibleIdIndex.get(e.focusedId)??-1;if(d<=0)return e;const s=e.visibleIds[d-1];return{...e,focusedId:s,...f(e,d-1)}}case"insert-children":{if(!e.nodeMap.get(t.parentId))return e;const d=e.nodeMap.withChildren(t.parentId,t.children),s=d.getVisibleIds(e.expandedIds);return{...e,nodeMap:d,visibleIdIndex:p(s),visibleIds:s}}case"reset":return t.state;case"select":{if(!e.focusedId||e.selectionMode==="none")return e;if(e.selectionMode==="single"){const s=new Set([e.focusedId]);return{...e,previousSelectedIds:e.selectedIds,selectedIds:s}}const d=new Set(e.selectedIds);return d.has(e.focusedId)?d.delete(e.focusedId):d.add(e.focusedId),{...e,previousSelectedIds:e.selectedIds,selectedIds:d}}case"set-children-error":{const d=new Set(e.loadingIds);return d.delete(t.nodeId),{...e,loadingIds:d}}case"set-loading":{const d=new Set(e.loadingIds);return t.isLoading?d.add(t.nodeId):d.delete(t.nodeId),{...e,loadingIds:d}}case"toggle-expanded":return e.focusedId?e.expandedIds.has(e.focusedId)?x(e,{type:"collapse"}):x(e,{type:"expand"}):e;default:return e}}function y({data:e,defaultExpanded:t,defaultSelected:d,selectionMode:s,visibleNodeCount:o}){const r=new Q(e);let I;if(t==="all"){I=new Set;for(const[h,g]of r.entries())g.hasChildren&&I.add(h)}else t?I=new Set(t):I=new Set;const c=r.getVisibleIds(I),n=s!=="none"&&d?new Set(d):new Set,i=Math.min(o,c.length);return{expandedIds:I,focusedId:c[0],loadingIds:new Set,nodeMap:r,previousExpandedIds:I,previousSelectedIds:n,selectedIds:n,selectionMode:s,viewportFromIndex:0,viewportToIndex:i,visibleIdIndex:p(c),visibleIds:c,visibleNodeCount:o}}function Y({data:e,defaultExpanded:t,defaultSelected:d,onExpandChange:s,onFocusChange:o,onSelectChange:r,selectionMode:I="none",visibleNodeCount:c=1/0}){const[n,i]=H(x,{data:e,defaultExpanded:t,defaultSelected:d,selectionMode:I,visibleNodeCount:c},y),[h,g]=J(e);e!==h&&(i({state:y({data:e,defaultExpanded:t,defaultSelected:d,selectionMode:I,visibleNodeCount:c}),type:"reset"}),g(e));const M=v(o);M.current=o;const m=v(s);m.current=s;const S=v(r);S.current=r;const C=v(!0);b(()=>{if(C.current){C.current=!1;return}n.focusedId&&M.current?.(n.focusedId)},[n.focusedId]),b(()=>{n.expandedIds!==n.previousExpandedIds&&m.current?.(n.expandedIds)},[n.expandedIds,n.previousExpandedIds]),b(()=>{n.selectedIds!==n.previousSelectedIds&&S.current?.(n.selectedIds)},[n.selectedIds,n.previousSelectedIds]);const N=K(()=>n.visibleIds.slice(n.viewportFromIndex,n.viewportToIndex).map(a=>{const u=n.nodeMap.get(a);return{node:u.node,state:{depth:u.depth,hasChildren:u.hasChildren,isExpanded:n.expandedIds.has(a),isFocused:a===n.focusedId,isLoading:n.loadingIds.has(a),isSelected:n.selectedIds.has(a)}}}),[n.visibleIds,n.viewportFromIndex,n.viewportToIndex,n.focusedId,n.expandedIds,n.selectedIds,n.nodeMap,n.loadingIds]),F=l(()=>{i({type:"focus-next"})},[]),T=l(()=>{i({type:"focus-previous"})},[]),E=l(()=>{i({type:"focus-first"})},[]),V=l(()=>{i({type:"focus-last"})},[]),L=l(()=>{i({type:"expand"})},[]),D=l(a=>{i({nodeId:a,type:"expand-node"})},[]),A=l(()=>{i({type:"collapse"})},[]),O=l(a=>{i({nodeId:a,type:"collapse-node"})},[]),P=l(()=>{i({type:"toggle-expanded"})},[]),R=l(()=>{i({type:"expand-all"})},[]),k=l(()=>{i({type:"collapse-all"})},[]),U=l(()=>{i({type:"select"})},[]),j=l(()=>{i({type:"focus-parent"})},[]),q=l(()=>{i({type:"focus-first-child"})},[]),z=l((a,u)=>{i({isLoading:u,nodeId:a,type:"set-loading"})},[]),B=l(a=>{i({nodeId:a,type:"set-children-error"})},[]),G=l((a,u)=>{i({children:u,parentId:a,type:"insert-children"})},[]);return{collapse:A,collapseAll:k,collapseNode:O,expand:L,expandAll:R,expandedIds:n.expandedIds,expandNode:D,focusedId:n.focusedId,focusFirst:E,focusFirstChild:q,focusLast:V,focusNext:F,focusParent:j,focusPrevious:T,hasScrollDown:n.viewportToIndex<n.visibleIds.length,hasScrollUp:n.viewportFromIndex>0,insertChildren:G,loadingIds:n.loadingIds,nodeMap:n.nodeMap,select:U,selectedIds:n.selectedIds,setChildrenError:B,setLoading:z,toggleExpanded:P,viewportFromIndex:n.viewportFromIndex,viewportNodes:N,viewportToIndex:n.viewportToIndex,visibleCount:n.visibleIds.length}}export{y as createDefaultState,x as reducer,Y as useTreeViewState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"terminal-size";const e=n=>{const{columns:o,rows:s}=n;if(o&&s)return{columns:o,rows:s};const r=t();return{columns:o||r.columns||80,rows:s||r.rows||24}};export{e as g};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const w=async(e,i,o={})=>{const c=o.timeout??3e3,a=o.interval??50,s=Date.now();let r=new Error("waitFor timed out");const n=()=>{if(typeof e=="string"){const t=i();if(!t.includes(e))throw new Error(`Timed out waiting for text: "${e}"
|
|
2
|
+
|
|
3
|
+
Screen content:
|
|
4
|
+
${t}`)}else e()};for(;Date.now()-s<c;){try{n();return}catch(t){r=t}await new Promise(t=>{setTimeout(t,a)})}try{n();return}catch(t){r=t}throw r};export{w as waitFor};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{S as V,d as p,i as o}from"./measure-text-B7juNq4Y.js";const m=(e,i,u="end")=>{if(i<1)return new V;if(p(e)<=i)return e;const t=new V;if(t.pushChar("…",0),i===1)return t;if(u==="start"){let l=0,a=e.length;for(let n=e.length-1;n>=0&&(l+=o(e.getValue(n)),!(l>i-1));n--)a=n;return t.combine(e.slice(a))}if(u==="middle"){const l=Math.ceil(i/2),a=i-l;let n=0,c=0;for(let r=0;r<e.length;r++){const g=o(e.getValue(r));if(c+g>l-1)break;c+=g,n=r+1}let s=e.length;c=0;for(let r=e.length-1;r>=0&&(c+=o(e.getValue(r)),!(c>a));r--)s=r;return e.slice(0,n).combine(t,e.slice(s))}let f=0,h=0;for(let l=0;l<e.length;l++){const a=o(e.getValue(l));if(h+a>i-1)break;h+=a,f=l+1}return e.slice(0,f).combine(t)},y=(e,i)=>{const u=[];let t=0,f=0,h=!0,l=0;for(;l<e.length;){const a=e.getValue(l);if(a===`
|
|
2
|
+
`){u.push(e.slice(t,l)),t=l+1,f=0,h=!0,l++;continue}let n=l,c=0;if(a===" ")c=o(" "),n=l+1;else for(;n<e.length&&e.getValue(n)!==" "&&e.getValue(n)!==`
|
|
3
|
+
`;)c+=o(e.getValue(n)),n++;if(f+c>i&&f>0){if(a===" "&&!h&&!e.hasStyles(l)){l=n;continue}let s=l;for(;s>t&&e.getValue(s-1)===" "&&!e.hasStyles(s-1);)s--;u.push(e.slice(t,s)),t=l,f=0;continue}if(f===0&&c>i){let s=l,r=0;for(;s<n;){const g=o(e.getValue(s));r+g>i&&r>0&&(u.push(e.slice(t,s)),t=s,r=0),r+=g,s++}f=r,l=n,h=!1}else f+=c,l=n,a!==" "&&(h=!1)}return(t<e.length||u.length===0)&&u.push(e.slice(t)),u},d=(e,i,u="wrap")=>{if(u.startsWith("truncate")){let t="end";return u==="truncate-middle"?t="middle":u==="truncate-start"&&(t="start"),[m(e,i,t)]}return y(e,i)};export{d as wrapOrTruncateStyledLine};
|
package/dist/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DevTools as o}from"../packem_shared/DevTools-
|
|
1
|
+
import{DevTools as o}from"../packem_shared/DevTools-k6uiVzqv.js";import{FocusContext as u,FocusProvider as s,useFocus as n,useFocusManager as p}from"../packem_shared/FocusContext-C2Sosxa4.js";import{TuiContext as d,measureElement as f,useApp as l,useBoxMetrics as m,useCursor as a,useInput as i,useIsScreenReaderEnabled as S,useMouse as c,usePaste as T,useScrollable as C,useStderr as F,useStdin as I,useStdout as M,useTextInput as v,useTuiContext as y,useWindowSize as E}from"../packem_shared/TuiContext-BNmP0lMY.js";import{render as g,renderInline as A}from"../packem_shared/render-DFZ8NHlG.js";import{renderToString as D}from"../packem_shared/renderToString-L_bpw4OQ.js";import{Static as N}from"../packem_shared/Static-DSzsElz4.js";import{LayoutNode as P}from"../packem_shared/LayoutNode-LPYsuzBg.js";import{NAMED_COLORS as w,applyStyles as z,resolveColor as W}from"../packem_shared/NAMED_COLORS-82DpREQV.js";import{renderTreeToBuffer as h}from"../packem_shared/renderTreeToBuffer-C8lS0lJ2.js";export{o as DevTools,u as FocusContext,s as FocusProvider,P as LayoutNode,w as NAMED_COLORS,N as Static,d as TuiContext,z as applyStyles,f as measureElement,g as render,A as renderInline,D as renderToString,h as renderTreeToBuffer,W as resolveColor,l as useApp,m as useBoxMetrics,a as useCursor,n as useFocus,p as useFocusManager,i as useInput,S as useIsScreenReaderEnabled,c as useMouse,T as usePaste,C as useScrollable,F as useStderr,I as useStdin,M as useStdout,v as useTextInput,y as useTuiContext,E as useWindowSize};
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { R as RenderOptions } from "../packem_shared/render.d-
|
|
3
|
-
import "../packem_shared/dom.d-
|
|
2
|
+
import { R as RenderOptions } from "../packem_shared/render.d-CBnYBDk2.js";
|
|
3
|
+
import "../packem_shared/dom.d-B4kXbaVY.js";
|
|
4
4
|
import 'yoga-layout';
|
|
5
5
|
import "../packem_shared/cursor-helpers.d-BONB9tky.js";
|
|
6
6
|
import '@visulima/colorize';
|
package/dist/testing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{createRequire as _}from"node:module";import F from"../packem_shared/render-DSuj2PjD.js";import{createKeySender as x}from"../packem_shared/KEY-C--kOw41.js";import{KEY as K}from"../packem_shared/KEY-C--kOw41.js";import{createScreen as y}from"../packem_shared/createScreen-DoYpyL0V.js";import{waitFor as T}from"../packem_shared/waitFor-CTAki32d.js";const g=_(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=t=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,n]=a.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return a.getBuiltinModule(t)}return g(t)},m=w("node:events");class b extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class v extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class j extends m{isTTY=!0;pendingData;write=e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0);read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const u=[],P=(t,e={})=>{const{columns:n,options:d}=e,s=new b(n),c=new v(n),o=new j,i=F(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:c,stdin:o,stdout:s,...d});u.push(i);const l=y(()=>s.lastFrame(),s.frames),p=x(r=>o.write(r)),f=async()=>{await new Promise(r=>{setTimeout(r,0)}),await new Promise(r=>{setTimeout(r,0)})};return{cleanup:i.cleanup,flush:f,get frames(){return s.frames},keys:p,lastFrame:()=>s.lastFrame(),rerender:i.rerender,screen:l,stderr:c,stdin:o,stdout:s,unmount:i.unmount,async waitFor(r,h){await T(r,()=>l.text(),h)}}},S=()=>{for(const t of u)t.cleanup();u.length=0};export{K as KEY,S as cleanup,x as createKeySender,y as createScreen,P as render,T as waitFor};
|