@visulima/tui 1.0.0-alpha.16 → 1.0.0-alpha.18

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.
Files changed (166) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/LICENSE.md +218 -253
  3. package/dist/components/accordion.d.ts +1 -1
  4. package/dist/components/approval-prompt.d.ts +1 -1
  5. package/dist/components/area-chart.d.ts +1 -1
  6. package/dist/components/badge.d.ts +1 -1
  7. package/dist/components/bar-chart.d.ts +1 -1
  8. package/dist/components/blink-dot.d.ts +1 -1
  9. package/dist/components/box.d.ts +4 -3
  10. package/dist/components/breadcrumb.d.ts +1 -1
  11. package/dist/components/button.d.ts +1 -1
  12. package/dist/components/calendar.d.ts +1 -1
  13. package/dist/components/canvas.js +1 -1
  14. package/dist/components/card.d.ts +1 -1
  15. package/dist/components/checkbox.d.ts +1 -1
  16. package/dist/components/collapsible.d.ts +1 -1
  17. package/dist/components/command-palette.d.ts +1 -1
  18. package/dist/components/content-switcher.d.ts +1 -1
  19. package/dist/components/controlled-scroll-view.d.ts +4 -3
  20. package/dist/components/controlled-scroll-view.js +1 -1
  21. package/dist/components/cursor.d.ts +4 -3
  22. package/dist/components/date-picker.d.ts +1 -1
  23. package/dist/components/definition-list.d.ts +1 -1
  24. package/dist/components/dialog.d.ts +5 -4
  25. package/dist/components/dialog.js +1 -1
  26. package/dist/components/divider.d.ts +1 -1
  27. package/dist/components/form.d.ts +1 -1
  28. package/dist/components/gauge.d.ts +1 -1
  29. package/dist/components/gradient.d.ts +1 -18
  30. package/dist/components/gradient.js +1 -4
  31. package/dist/components/heading.d.ts +1 -1
  32. package/dist/components/heatmap.d.ts +1 -1
  33. package/dist/components/histogram.d.ts +1 -1
  34. package/dist/components/kbd.d.ts +1 -1
  35. package/dist/components/line-chart.d.ts +1 -1
  36. package/dist/components/link.js +1 -1
  37. package/dist/components/loading-indicator.d.ts +2 -2
  38. package/dist/components/menu.d.ts +1 -1
  39. package/dist/components/message-bubble.d.ts +1 -1
  40. package/dist/components/model-badge.d.ts +1 -1
  41. package/dist/components/multi-select.d.ts +1 -1
  42. package/dist/components/option-list.d.ts +1 -1
  43. package/dist/components/paragraph.d.ts +1 -1
  44. package/dist/components/placeholder.d.ts +1 -1
  45. package/dist/components/progress-bar.d.ts +3 -2
  46. package/dist/components/radio-group.d.ts +1 -1
  47. package/dist/components/scatter-plot.d.ts +1 -1
  48. package/dist/components/scroll-bar-box.d.ts +4 -3
  49. package/dist/components/scroll-bar.d.ts +4 -3
  50. package/dist/components/scroll-list.d.ts +4 -3
  51. package/dist/components/scroll-list.js +1 -1
  52. package/dist/components/scroll-view.d.ts +4 -3
  53. package/dist/components/scroll-view.js +1 -1
  54. package/dist/components/search-input.d.ts +1 -1
  55. package/dist/components/select-input-indicator.d.ts +1 -1
  56. package/dist/components/select-input-item.d.ts +1 -1
  57. package/dist/components/select-input.d.ts +1 -1
  58. package/dist/components/shimmer-text.d.ts +1 -1
  59. package/dist/components/slider.d.ts +1 -1
  60. package/dist/components/sparkline.d.ts +1 -1
  61. package/dist/components/spinner.d.ts +1 -1
  62. package/dist/components/spinner.js +1 -1
  63. package/dist/components/static-render.d.ts +8 -3
  64. package/dist/components/static-render.js +1 -1
  65. package/dist/components/static.d.ts +3 -2
  66. package/dist/components/status-line.d.ts +1 -1
  67. package/dist/components/stepper.d.ts +1 -1
  68. package/dist/components/streaming-text.d.ts +1 -1
  69. package/dist/components/switch.d.ts +1 -1
  70. package/dist/components/tabs.d.ts +1 -1
  71. package/dist/components/tag.d.ts +1 -1
  72. package/dist/components/text.d.ts +3 -2
  73. package/dist/components/text.js +1 -1
  74. package/dist/components/tooltip.d.ts +1 -1
  75. package/dist/components/tree-view-entry.d.ts +4 -3
  76. package/dist/core/index.d.ts +2 -1
  77. package/dist/core/index.js +1 -1
  78. package/dist/ink/hooks/use-app.d.ts +1 -1
  79. package/dist/ink/hooks/use-box-metrics.d.ts +7 -4
  80. package/dist/ink/hooks/use-box-metrics.js +1 -1
  81. package/dist/ink/hooks/use-focus-manager.d.ts +2 -1
  82. package/dist/ink/hooks/use-input.d.ts +1 -1
  83. package/dist/ink/hooks/use-input.js +1 -1
  84. package/dist/ink/hooks/use-linked-scroll.d.ts +4 -3
  85. package/dist/ink/hooks/use-paste.d.ts +2 -1
  86. package/dist/ink/hooks/use-paste.js +1 -1
  87. package/dist/ink/hooks/use-text-selection.d.ts +5 -4
  88. package/dist/ink/hooks/use-text-selection.js +1 -1
  89. package/dist/ink/hooks/use-window-size.js +1 -1
  90. package/dist/ink/index.d.ts +10 -7
  91. package/dist/ink/index.js +1 -1
  92. package/dist/packem_shared/ControlledScrollView-CIc-x1Cx.js +1 -0
  93. package/dist/packem_shared/{DevTools-ClnTSU76.js → DevTools-ClAYpMVI.js} +1 -1
  94. package/dist/packem_shared/InputParser-B_qZcN3r.js +2 -0
  95. package/dist/packem_shared/{LayoutNode-Q7nU3hmO.js → LayoutNode-B8zej4dm.js} +1 -1
  96. package/dist/packem_shared/{MouseProvider-CHU5DuwC.js → MouseProvider-PnIUKURs.js} +1 -1
  97. package/dist/packem_shared/{ScrollList-Dxgv-mhZ.js → ScrollList-C7nZ9ufK.js} +1 -1
  98. package/dist/packem_shared/{ScrollView-Dq2v5zJS.js → ScrollView-DKZ8OM-m.js} +1 -1
  99. package/dist/packem_shared/TuiApp-BVDXP0Cv.js +1 -0
  100. package/dist/packem_shared/ansi-parser-B6uXaq65.js +1 -0
  101. package/dist/packem_shared/colorize-DbTZMrJO.js +1 -0
  102. package/dist/packem_shared/{comparePoints-l0iqUoL_.js → comparePoints-YxQfR_zq.js} +1 -1
  103. package/dist/packem_shared/{controlled-scroll-view-CikQ90_V.js → controlled-scroll-view-CcUS50jx.js} +1 -1
  104. package/dist/packem_shared/createInlineLoop-DRNZ7jqH.js +2 -0
  105. package/dist/packem_shared/createScreen-CrLrxA6t.js +3 -0
  106. package/dist/packem_shared/dom-BG-LS10p.js +1 -0
  107. package/dist/packem_shared/{dom.d-BZZeZlyP.d.ts → dom.d-CcFuBd-k.d.ts} +11 -1
  108. package/dist/packem_shared/{getPathToRoot-Nb2eTx2o.js → getPathToRoot-D5Hns9Er.js} +1 -1
  109. package/dist/packem_shared/getScrollHeight-ClEOyLHH.js +1 -0
  110. package/dist/packem_shared/input.d-CgxV2e8U.d.ts +90 -0
  111. package/dist/packem_shared/{layout-P24eyWyL.js → layout-BMo200nF.js} +1 -1
  112. package/dist/packem_shared/measure-text-DDjHT1jD.js +3 -0
  113. package/dist/packem_shared/{measureElement-CRKlFSvD.js → measureElement-BTtTFZg4.js} +1 -1
  114. package/dist/packem_shared/parseSgrMouse-Ccj70ijb.js +1 -0
  115. package/dist/packem_shared/processLayout-FEKj_mWu.js +1 -0
  116. package/dist/packem_shared/{reconciler-tOH9yL_j.js → reconciler-CUbhOvcr.js} +1 -1
  117. package/dist/packem_shared/{reconciler-BQvF1kRj.js → reconciler-DIfG72R9.js} +1 -1
  118. package/dist/packem_shared/{render-yGJFE4of.js → render-Dh7HMhK1.js} +1 -1
  119. package/dist/packem_shared/render-bdbSzkJo.js +26 -0
  120. package/dist/packem_shared/{render.d-BJmVQ_cd.d.ts → render.d-B1kiO3Ca.d.ts} +19 -1
  121. package/dist/packem_shared/{renderToString-D4JqS-Zv.js → renderToString-BbQiRHrd.js} +1 -1
  122. package/dist/packem_shared/{renderToString-GyN-Rw9F.js → renderToString-DVE0cEHt.js} +1 -1
  123. package/dist/packem_shared/renderTreeToBuffer-CZilzyhN.js +2 -0
  124. package/dist/packem_shared/renderer-Cfi6ZyHf.js +17 -0
  125. package/dist/packem_shared/{selection.d-vfuEzv1p.d.ts → selection.d-DAh7REnW.d.ts} +1 -1
  126. package/dist/packem_shared/setEnableStyledLineCache-D2gZbwFM.js +1 -0
  127. package/dist/packem_shared/squashTextNodesWithMap-DCdi3SZ2.js +1 -0
  128. package/dist/packem_shared/{styles.d-i6Mejqz2.d.ts → styles.d-cMo36xQz.d.ts} +37 -105
  129. package/dist/packem_shared/text-width-BU2eeTWn.js +2 -0
  130. package/dist/packem_shared/utils-CoviI5Vm.js +1 -0
  131. package/dist/packem_shared/{wrapOrTruncateStyledLine-D29Fq7pW.js → wrapOrTruncateStyledLine-BZ00SM8i.js} +1 -1
  132. package/dist/react/index.d.ts +2 -1
  133. package/dist/react/index.js +1 -1
  134. package/dist/testing/index.d.ts +5 -4
  135. package/dist/testing/index.js +1 -1
  136. package/index.js +539 -691
  137. package/package.json +28 -16
  138. package/dist/packem_shared/ControlledScrollView-X_OTc-Cw.js +0 -1
  139. package/dist/packem_shared/InputParser-Cfi5GVKV.js +0 -2
  140. package/dist/packem_shared/TuiApp-BSWPFrDu.js +0 -1
  141. package/dist/packem_shared/ansi-parser-C5JuL732.js +0 -1
  142. package/dist/packem_shared/boxes-DyY_LXCi.js +0 -1
  143. package/dist/packem_shared/colorize-gy_cY-wC.js +0 -2
  144. package/dist/packem_shared/constants-D12jy2Zh-RSfxu1eM.js +0 -1
  145. package/dist/packem_shared/createInlineLoop-fhXU93QT.js +0 -2
  146. package/dist/packem_shared/createScreen-87XLHZq6.js +0 -3
  147. package/dist/packem_shared/dom-CMbdnYbk.js +0 -8
  148. package/dist/packem_shared/erase-DeDffywz.js +0 -1
  149. package/dist/packem_shared/get-string-width-4oMZhv2Q.js +0 -1
  150. package/dist/packem_shared/getScrollHeight-BTEY8ewu.js +0 -1
  151. package/dist/packem_shared/index-LwZN2xbk.js +0 -75
  152. package/dist/packem_shared/index.d-Bk52cbgN.d.ts +0 -14
  153. package/dist/packem_shared/index.server.d-eZWyC2Ku.d.ts +0 -5
  154. package/dist/packem_shared/input.d-D-Yxqha8.d.ts +0 -172
  155. package/dist/packem_shared/measure-text-CIs55Wao.js +0 -3
  156. package/dist/packem_shared/mode-BOIU4Roy.js +0 -1
  157. package/dist/packem_shared/parseSgrMouse-DoBY7MKw.js +0 -1
  158. package/dist/packem_shared/processLayout-Dmgf0LO6.js +0 -1
  159. package/dist/packem_shared/render-D9bHMHrx.js +0 -26
  160. package/dist/packem_shared/renderTreeToBuffer-DWl5_yTW.js +0 -2
  161. package/dist/packem_shared/renderer-Cidd3s9K.js +0 -17
  162. package/dist/packem_shared/setEnableStyledLineCache-Aja0FbWo.js +0 -1
  163. package/dist/packem_shared/squashTextNodesWithMap-Cpqmc45i.js +0 -1
  164. package/dist/packem_shared/strip-C6HQYmlg.js +0 -1
  165. package/dist/packem_shared/text-width-DSx26OmB.js +0 -2
  166. package/dist/packem_shared/utils-THUhYKG2.js +0 -1
@@ -1 +1 @@
1
- var Y=Object.defineProperty;var L=(H,C)=>Y(H,"name",{value:C,configurable:!0});import{jsx as $}from"react/jsx-runtime";import{useRef as x,useState as Q,useEffect as j,useCallback as l,useImperativeHandle as U}from"react";import Z from"../ink/hooks/use-scroll-input.js";import{C as _}from"./controlled-scroll-view-CikQ90_V.js";var tt=Object.defineProperty,a=L((H,C)=>tt(H,"name",{value:C,configurable:!0}),"u");const ct=a(H=>{const{children:C,keyboard:A=!1,onContentHeightChange:b,onItemHeightChange:T,onScroll:O,onViewportSizeChange:P,overscan:E,ref:R,scrollAlignment:m="auto",selectedIndex:v,vimBindings:q=!1,virtualize:D,...F}=H,n=x(null),[s,G]=Q(0),I=x(0);j(()=>{I.current=s},[s]);const o=l(t=>{t!==I.current&&(G(t),O?.(t))},[O]),h=x(v);h.current=v;const k=l(()=>{const t=h.current;if(t===void 0||t<0)return null;const e=n.current?.getItemPosition(t);if(!e)return null;const i=n.current?.getViewportHeight()??0,g=n.current?.getContentHeight()??0;let r=e.top+e.height-i,c=e.top;r>c&&([r,c]=[c,r]);const B=Math.max(0,g-i);return{max:Math.min(B,c),min:Math.max(0,r)}},[]),u=l(t=>{const e=n.current?.getContentHeight()??0,i=n.current?.getViewportHeight()??0,g=Math.max(0,e-i);let r=Math.max(0,Math.min(t,g));const c=k();return c&&(r=Math.max(c.min,Math.min(r,c.max))),r},[k]),f=l((t,e,i,g)=>{const r=n.current?.getItemPosition(t);if(!r)return e;const c=g??n.current?.getViewportHeight()??0,B=n.current?.getContentHeight()??0;let p=e;switch(i){case"bottom":{p=r.top+r.height-c;break}case"center":{p=r.top+r.height/2-c/2;break}case"top":{p=r.top;break}default:{const S=r.top+r.height;r.top<=e&&S>=e+c?p=e:r.top<e?p=r.top:S>e+c&&(p=S-c)}}const X=Math.max(0,B-c);return Math.max(0,Math.min(p,X))},[]);let d=s;v!==void 0&&v>=0&&(d=f(v,s,m)),j(()=>{d!==s&&o(d)},[d,s,o]);const y=l((t,e)=>{if(h.current!==void 0&&h.current>=0){const i=f(h.current,s,m,t.height);o(i)}P?.(t,e)},[P,f,s,m,o]),J=l((t,e,i)=>{const g=h.current;if(g!==void 0&&g>=0){if(t<g){const r=u(s+(e-i));o(r)}else if(t===g){const r=f(t,s,m);o(r)}}T?.(t,e,i)},[T,f,m,s,u,o]),K=l((t,e)=>{if(h.current!==void 0&&h.current>=0){const i=f(h.current,s,m);o(i)}b?.(t,e)},[b,f,s,m,o]),z=x(0),M=l(t=>{const e=I.current,i=u(e+t);o(i)},[u,o]),w=l(()=>{const t=n.current?.getContentHeight()??0,e=n.current?.getViewportHeight()??0,i=Math.max(0,t-e),g=u(i);o(g)},[u,o]),V=l(()=>{const t=u(0);o(t)},[u,o]),N=l(()=>z.current,[]);Z({getViewportHeight:N,isActive:A,scrollBy:M,scrollToBottom:w,scrollToTop:V,vimBindings:q}),U(R,()=>({getBottomOffset:a(()=>n.current?.getBottomOffset()??0,"getBottomOffset"),getContentHeight:a(()=>n.current?.getContentHeight()??0,"getContentHeight"),getItemHeight:a(t=>n.current?.getItemHeight(t)??0,"getItemHeight"),getItemPosition:a(t=>n.current?.getItemPosition(t)??null,"getItemPosition"),getScrollOffset:a(()=>I.current,"getScrollOffset"),getViewportHeight:a(()=>n.current?.getViewportHeight()??0,"getViewportHeight"),remeasure:a(()=>n.current?.remeasure(),"remeasure"),remeasureItem:a(t=>n.current?.remeasureItem(t),"remeasureItem"),scrollBy:M,scrollTo:a(t=>{const e=u(t);o(e)},"scrollTo"),scrollToBottom:w,scrollToTop:V}),[u,o,M,w,V]);const W=l((t,e)=>{z.current=t.height,y(t,e)},[y]);return $(_,{onContentHeightChange:K,onItemHeightChange:J,onViewportSizeChange:W,overscan:E,ref:n,scrollOffset:d,virtualize:D,...F,children:C})},"ScrollList");export{ct as ScrollList};
1
+ var Y=Object.defineProperty;var L=(H,C)=>Y(H,"name",{value:C,configurable:!0});import{jsx as $}from"react/jsx-runtime";import{useRef as x,useState as Q,useEffect as j,useCallback as l,useImperativeHandle as U}from"react";import Z from"../ink/hooks/use-scroll-input.js";import{C as _}from"./controlled-scroll-view-CcUS50jx.js";var tt=Object.defineProperty,a=L((H,C)=>tt(H,"name",{value:C,configurable:!0}),"u");const ct=a(H=>{const{children:C,keyboard:A=!1,onContentHeightChange:b,onItemHeightChange:T,onScroll:O,onViewportSizeChange:P,overscan:E,ref:R,scrollAlignment:m="auto",selectedIndex:v,vimBindings:q=!1,virtualize:D,...F}=H,n=x(null),[s,G]=Q(0),I=x(0);j(()=>{I.current=s},[s]);const o=l(t=>{t!==I.current&&(G(t),O?.(t))},[O]),h=x(v);h.current=v;const k=l(()=>{const t=h.current;if(t===void 0||t<0)return null;const e=n.current?.getItemPosition(t);if(!e)return null;const i=n.current?.getViewportHeight()??0,g=n.current?.getContentHeight()??0;let r=e.top+e.height-i,c=e.top;r>c&&([r,c]=[c,r]);const B=Math.max(0,g-i);return{max:Math.min(B,c),min:Math.max(0,r)}},[]),u=l(t=>{const e=n.current?.getContentHeight()??0,i=n.current?.getViewportHeight()??0,g=Math.max(0,e-i);let r=Math.max(0,Math.min(t,g));const c=k();return c&&(r=Math.max(c.min,Math.min(r,c.max))),r},[k]),f=l((t,e,i,g)=>{const r=n.current?.getItemPosition(t);if(!r)return e;const c=g??n.current?.getViewportHeight()??0,B=n.current?.getContentHeight()??0;let p=e;switch(i){case"bottom":{p=r.top+r.height-c;break}case"center":{p=r.top+r.height/2-c/2;break}case"top":{p=r.top;break}default:{const S=r.top+r.height;r.top<=e&&S>=e+c?p=e:r.top<e?p=r.top:S>e+c&&(p=S-c)}}const X=Math.max(0,B-c);return Math.max(0,Math.min(p,X))},[]);let d=s;v!==void 0&&v>=0&&(d=f(v,s,m)),j(()=>{d!==s&&o(d)},[d,s,o]);const y=l((t,e)=>{if(h.current!==void 0&&h.current>=0){const i=f(h.current,s,m,t.height);o(i)}P?.(t,e)},[P,f,s,m,o]),J=l((t,e,i)=>{const g=h.current;if(g!==void 0&&g>=0){if(t<g){const r=u(s+(e-i));o(r)}else if(t===g){const r=f(t,s,m);o(r)}}T?.(t,e,i)},[T,f,m,s,u,o]),K=l((t,e)=>{if(h.current!==void 0&&h.current>=0){const i=f(h.current,s,m);o(i)}b?.(t,e)},[b,f,s,m,o]),z=x(0),M=l(t=>{const e=I.current,i=u(e+t);o(i)},[u,o]),w=l(()=>{const t=n.current?.getContentHeight()??0,e=n.current?.getViewportHeight()??0,i=Math.max(0,t-e),g=u(i);o(g)},[u,o]),V=l(()=>{const t=u(0);o(t)},[u,o]),N=l(()=>z.current,[]);Z({getViewportHeight:N,isActive:A,scrollBy:M,scrollToBottom:w,scrollToTop:V,vimBindings:q}),U(R,()=>({getBottomOffset:a(()=>n.current?.getBottomOffset()??0,"getBottomOffset"),getContentHeight:a(()=>n.current?.getContentHeight()??0,"getContentHeight"),getItemHeight:a(t=>n.current?.getItemHeight(t)??0,"getItemHeight"),getItemPosition:a(t=>n.current?.getItemPosition(t)??null,"getItemPosition"),getScrollOffset:a(()=>I.current,"getScrollOffset"),getViewportHeight:a(()=>n.current?.getViewportHeight()??0,"getViewportHeight"),remeasure:a(()=>n.current?.remeasure(),"remeasure"),remeasureItem:a(t=>n.current?.remeasureItem(t),"remeasureItem"),scrollBy:M,scrollTo:a(t=>{const e=u(t);o(e)},"scrollTo"),scrollToBottom:w,scrollToTop:V}),[u,o,M,w,V]);const W=l((t,e)=>{z.current=t.height,y(t,e)},[y]);return $(_,{onContentHeightChange:K,onItemHeightChange:J,onViewportSizeChange:W,overscan:E,ref:n,scrollOffset:d,virtualize:D,...F,children:C})},"ScrollList");export{ct as ScrollList};
@@ -1 +1 @@
1
- var X=Object.defineProperty;var D=(c,s)=>X(c,"name",{value:s,configurable:!0});import{jsxs as ee,jsx as M}from"react/jsx-runtime";import{useRef as g,useState as F,useCallback as o,useImperativeHandle as te}from"react";import re from"../ink/hooks/use-scroll-input.js";import{Box as oe}from"../components/box.js";import{R as ne,C as Y}from"./controlled-scroll-view-CikQ90_V.js";import{ScrollBar as le}from"./ScrollBar-U_37hlIT.js";var ie=Object.defineProperty,a=D((c,s)=>ie(c,"name",{value:s,configurable:!0}),"c");const ge=a(({children:c,debug:s=!1,followOutput:T=!1,followThreshold:V=3,keyboard:Z=!1,onContentHeightChange:y,onItemHeightChange:O,onReachEnd:x,onReachStart:H,onScroll:z,onViewportSizeChange:N,overscan:P,reachThreshold:h=5,ref:_,scrollbar:q=!1,scrollbarColor:J,scrollbarStyle:K="line",vimBindings:L=!1,virtualize:G,...p})=>{const[d,R,n]=ne(0),u=g(null),m=g(0),l=g(0),[j,Q]=F(0),[v,U]=F(0),w=g(!1),S=g(!1),i=o(()=>Math.max(0,m.current-l.current),[]),k=o(e=>{const r=i();x&&e>=r-h&&!w.current?(w.current=!0,x()):e<r-h&&(w.current=!1),H&&e<=h&&!S.current?(S.current=!0,H()):e>h&&(S.current=!1)},[x,H,h,i]),t=o(e=>{e!==n()&&(R(e),z?.(e),k(e))},[n,R,z,k]),E=o((e,r)=>{const f=n()>=i()-V;if(m.current=e,Q(e),y?.(e,r),T&&f&&e>r){const C=Math.max(0,e-l.current);t(C)}else{const C=Math.max(0,e-l.current);n()>C&&t(C)}},[y,T,V,n,i,t]),$=o((e,r)=>{l.current=e.height,U(e.height),N?.(e,r)},[N]),I=o(e=>{if(typeof e!="number"||Number.isNaN(e))return;const r=Math.max(0,m.current-l.current),f=Math.max(0,Math.min(n()+e,r));t(f)},[n,t]),A=o(e=>{if(typeof e!="number"||Number.isNaN(e))return;const r=Math.max(0,m.current-l.current),f=Math.max(0,Math.min(e,r));t(f)},[t]),b=o(()=>{const e=i();t(e)},[i,t]),B=o(()=>{t(0)},[t]),W=o(()=>l.current,[]);return re({getViewportHeight:W,isActive:Z,scrollBy:I,scrollToBottom:b,scrollToTop:B,vimBindings:L}),te(_,()=>({getBottomOffset:i,getContentHeight:a(()=>m.current,"getContentHeight"),getItemHeight:a(e=>u.current?.getItemHeight(e)??0,"getItemHeight"),getItemPosition:a(e=>u.current?.getItemPosition(e)??null,"getItemPosition"),getScrollOffset:n,getViewportHeight:a(()=>l.current,"getViewportHeight"),remeasure:a(()=>u.current?.remeasure(),"remeasure"),remeasureItem:a(e=>u.current?.remeasureItem(e),"remeasureItem"),scrollBy:I,scrollTo:A,scrollToBottom:b,scrollToTop:B}),[i,n,I,A,b,B]),q&&j>v&&v>0?ee(oe,{flexDirection:"row",flexGrow:p.flexGrow,flexShrink:p.flexShrink,overflow:"hidden",children:[M(Y,{children:c,debug:s,onContentHeightChange:E,onItemHeightChange:O,onViewportSizeChange:$,overscan:P,ref:u,scrollOffset:d,virtualize:G,...p,flexGrow:1}),M(le,{color:J,contentHeight:j,placement:"inset",scrollOffset:d,style:K,viewportHeight:v})]}):M(Y,{children:c,debug:s,onContentHeightChange:E,onItemHeightChange:O,onViewportSizeChange:$,overscan:P,ref:u,scrollOffset:d,virtualize:G,...p})},"ScrollView");export{ge as ScrollView};
1
+ var X=Object.defineProperty;var D=(c,s)=>X(c,"name",{value:s,configurable:!0});import{jsxs as ee,jsx as M}from"react/jsx-runtime";import{useRef as g,useState as F,useCallback as o,useImperativeHandle as te}from"react";import re from"../ink/hooks/use-scroll-input.js";import{Box as oe}from"../components/box.js";import{R as ne,C as Y}from"./controlled-scroll-view-CcUS50jx.js";import{ScrollBar as le}from"./ScrollBar-U_37hlIT.js";var ie=Object.defineProperty,a=D((c,s)=>ie(c,"name",{value:s,configurable:!0}),"c");const ge=a(({children:c,debug:s=!1,followOutput:T=!1,followThreshold:V=3,keyboard:Z=!1,onContentHeightChange:y,onItemHeightChange:O,onReachEnd:x,onReachStart:H,onScroll:z,onViewportSizeChange:N,overscan:P,reachThreshold:h=5,ref:_,scrollbar:q=!1,scrollbarColor:J,scrollbarStyle:K="line",vimBindings:L=!1,virtualize:G,...p})=>{const[d,R,n]=ne(0),u=g(null),m=g(0),l=g(0),[j,Q]=F(0),[v,U]=F(0),w=g(!1),S=g(!1),i=o(()=>Math.max(0,m.current-l.current),[]),k=o(e=>{const r=i();x&&e>=r-h&&!w.current?(w.current=!0,x()):e<r-h&&(w.current=!1),H&&e<=h&&!S.current?(S.current=!0,H()):e>h&&(S.current=!1)},[x,H,h,i]),t=o(e=>{e!==n()&&(R(e),z?.(e),k(e))},[n,R,z,k]),E=o((e,r)=>{const f=n()>=i()-V;if(m.current=e,Q(e),y?.(e,r),T&&f&&e>r){const C=Math.max(0,e-l.current);t(C)}else{const C=Math.max(0,e-l.current);n()>C&&t(C)}},[y,T,V,n,i,t]),$=o((e,r)=>{l.current=e.height,U(e.height),N?.(e,r)},[N]),I=o(e=>{if(typeof e!="number"||Number.isNaN(e))return;const r=Math.max(0,m.current-l.current),f=Math.max(0,Math.min(n()+e,r));t(f)},[n,t]),A=o(e=>{if(typeof e!="number"||Number.isNaN(e))return;const r=Math.max(0,m.current-l.current),f=Math.max(0,Math.min(e,r));t(f)},[t]),b=o(()=>{const e=i();t(e)},[i,t]),B=o(()=>{t(0)},[t]),W=o(()=>l.current,[]);return re({getViewportHeight:W,isActive:Z,scrollBy:I,scrollToBottom:b,scrollToTop:B,vimBindings:L}),te(_,()=>({getBottomOffset:i,getContentHeight:a(()=>m.current,"getContentHeight"),getItemHeight:a(e=>u.current?.getItemHeight(e)??0,"getItemHeight"),getItemPosition:a(e=>u.current?.getItemPosition(e)??null,"getItemPosition"),getScrollOffset:n,getViewportHeight:a(()=>l.current,"getViewportHeight"),remeasure:a(()=>u.current?.remeasure(),"remeasure"),remeasureItem:a(e=>u.current?.remeasureItem(e),"remeasureItem"),scrollBy:I,scrollTo:A,scrollToBottom:b,scrollToTop:B}),[i,n,I,A,b,B]),q&&j>v&&v>0?ee(oe,{flexDirection:"row",flexGrow:p.flexGrow,flexShrink:p.flexShrink,overflow:"hidden",children:[M(Y,{children:c,debug:s,onContentHeightChange:E,onItemHeightChange:O,onViewportSizeChange:$,overscan:P,ref:u,scrollOffset:d,virtualize:G,...p,flexGrow:1}),M(le,{color:J,contentHeight:j,placement:"inset",scrollOffset:d,style:K,viewportHeight:v})]}):M(Y,{children:c,debug:s,onContentHeightChange:E,onItemHeightChange:O,onViewportSizeChange:$,overscan:P,ref:u,scrollOffset:d,virtualize:G,...p})},"ScrollView");export{ge as ScrollView};
@@ -0,0 +1 @@
1
+ var u=Object.defineProperty;var r=(i,t)=>u(i,"name",{value:t,configurable:!0});import{createDecMode as f,setMode as o,resetMode as d}from"@visulima/ansi";import{EventEmitter as a}from"tseep";import{Renderer as s,TerminalGuard as l}from"./Renderer-DJXooAsp.js";var w=Object.defineProperty,c=r((i,t)=>w(i,"name",{value:t,configurable:!0}),"i");const h=f(2026),g=o(h),p=d(h);class k extends a{static{r(this,"TuiApp")}static{c(this,"TuiApp")}renderer;terminal=null;backBuffer;width;height;isRunning=!1;stdoutBuffer=[];stderrBuffer=[];constructor(){super(),this.width=process.stdout.columns||80,this.height=process.stdout.rows||24,this.renderer=new s(this.width,this.height),this.backBuffer=new Uint32Array(this.width*this.height*2)}start(){this.isRunning||(this.terminal=new l(!0),this.isRunning=!0)}quit(){this.emit("quit")}stop(){this.isRunning=!1,this.terminal?.leave(),this.terminal=null,this.stdoutBuffer.length>0&&(process.stdout.write(this.stdoutBuffer.join("")),this.stdoutBuffer=[]),this.stderrBuffer.length>0&&(process.stderr.write(this.stderrBuffer.join("")),this.stderrBuffer=[])}writeStdout(t){this.isRunning?this.stdoutBuffer.push(t):process.stdout.write(t)}writeStderr(t){this.isRunning?this.stderrBuffer.push(t):process.stderr.write(t)}getBuffer(){return this.backBuffer}getSize(){return{height:this.height,width:this.width}}resize(t,e){this.width=t,this.height=e,this.renderer=new s(t,e),this.backBuffer=new Uint32Array(t*e*2)}beforeFlushListeners=[];onBeforeFlush(t){return this.beforeFlushListeners.push(t),()=>{this.beforeFlushListeners=this.beforeFlushListeners.filter(e=>e!==t)}}paintNow(t,e){if(this.isRunning){t(this.width,this.height),e(this.backBuffer,this.width,this.height);for(const n of this.beforeFlushListeners)n(this.backBuffer,this.width,this.height);this.renderer.writeRaw(g);try{this.renderer.render(this.backBuffer)}finally{this.renderer.writeRaw(p)}}}}export{k as TuiApp};
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var i=(r,e)=>c(r,"name",{value:e,configurable:!0});import{enableNormalMouse as f,enableAnyEventMouse as m,enableSgrMouse as d,disableSgrMouse as b,disableAnyEventMouse as p,disableNormalMouse as y}from"@visulima/ansi";const B={mouseButton:{off:y,on:f},mouseMotion:{off:p,on:m},mouseMotionOthers:{off:"\x1B[?1015l",on:"\x1B[?1015h"},mouseSGR:{off:b,on:d}},M=/\[<(\d+);(\d+);(\d+)(M)$/i;var x=Object.defineProperty,g=i((r,e)=>x(r,"name",{value:e,configurable:!0}),"i");const v={0:"left",1:"middle",2:"right"},N={32:"left",33:"middle",34:"right"},A=g(r=>{const e=M.exec(r);if(!e)return;const a=Number(e[1]),t=Number(e[2]),n=Number(e[3]),s=e[4]==="m",o=a&-29;if(o===64||o===65)return{direction:o===64?"scrollup":"scrolldown",type:"scroll",x:t,y:n};if(o===35)return{type:"move",x:t,y:n};const u=N[o];if(u)return{action:s?"release":"press",button:u,type:"drag",x:t,y:n};const l=v[o];if(l)return{action:s?"release":"press",button:l,type:"click",x:t,y:n}},"parseSgrMouse");export{B as M,A as a};
@@ -0,0 +1 @@
1
+ var g=Object.defineProperty;var c=(r,n)=>g(r,"name",{value:n,configurable:!0});import t from"@visulima/colorize";var f=Object.defineProperty,i=c((r,n)=>f(r,"name",{value:n,configurable:!0}),"i");const b=/^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/,d=/^ansi256\(\s?(\d+)\s?\)$/,l=i(r=>r in t,"isNamedColor"),m=i((r,n,e)=>{if(!n)return r;if(l(n)){if(e==="foreground")return t[n](r);const o=`bg${n[0].toUpperCase()+n.slice(1)}`;return t[o](r)}if(n.startsWith("#"))return e==="foreground"?t.hex(n)(r):t.bgHex(n)(r);if(n.startsWith("ansi256")){const o=d.exec(n);if(!o)return r;const s=Number(o[1]);return e==="foreground"?t.ansi256(s)(r):t.bgAnsi256(s)(r)}if(n.startsWith("rgb")){const o=b.exec(n);if(!o)return r;const s=Number(o[1]),u=Number(o[2]),a=Number(o[3]);return e==="foreground"?t.rgb(s,u,a)(r):t.bgRgb(s,u,a)(r)}return r},"colorize"),N=i(r=>{const n=m("x",r,"background");if(n!=="x")return n.split("x")[0]},"getBackgroundColorEscape");export{m as d,N as g};
@@ -1 +1 @@
1
- var N=Object.defineProperty;var g=(n,t)=>N(n,"name",{value:t,configurable:!0});import{g as m}from"./dom-CMbdnYbk.js";import{t as O}from"./measure-text-CIs55Wao.js";import{squashTextNodesWithMap as S}from"./squashTextNodesWithMap-Cpqmc45i.js";var v=Object.defineProperty,l=g((n,t)=>v(n,"name",{value:t,configurable:!0}),"f");const x=l(n=>{if(n.nodeName==="#text"){const r=O(n.nodeValue);return{charOffsetMap:new Map([[n,{end:r.length,start:0}]]),styledLine:r}}const t=new Map,e=S(n,t,{current:0}),s=O(e);return t.set(n,{end:s.length,start:0}),{charOffsetMap:t,styledLine:s}},"getPlainTextFromDomNode"),y=l((n,t)=>{if(!n.startContainer||!n.endContainer)return;const e=l((i,h)=>{const o=t.get(i);if(!o)return;if(i.nodeName==="#text")return o.start+h;const d=i;if(h>=d.childNodes.length)return o.end;const a=d.childNodes[h],u=t.get(a);if(u)return u.start;for(let f=h-1;f>=0;f--){const c=d.childNodes[f],C=t.get(c);if(C)return C.end}return o.start},"getOffset"),s=e(n.startContainer,n.startOffset),r=e(n.endContainer,n.endOffset);if(!(s===void 0||r===void 0))return{end:r,start:s}},"getRangeCharacterOffsets"),p=l((n,t,e,s)=>{if(n===e)return t===s?0:t<s?-1:1;const r=m(n),i=m(e);let h,o=0;for(;o<r.length&&o<i.length&&r[o]===i[o];)h=r[o],o++;if(!h)return 0;if(o===r.length){const c=i[o],C=n.childNodes.indexOf(c);return t<=C?-1:1}if(o===i.length){const c=r[o];return e.childNodes.indexOf(c)<s?-1:1}const d=r[o],a=i[o],u=h.childNodes.indexOf(d),f=h.childNodes.indexOf(a);return u<f?-1:1},"comparePoints");class A{static{g(this,"Range")}static{l(this,"Range")}startContainer=void 0;startOffset=0;endContainer=void 0;endOffset=0;collapsed=!0;commonAncestorContainer=void 0;setStart(t,e){this.startContainer=t,this.startOffset=e,this.updateCollapsed(),this.updateCommonAncestor()}setEnd(t,e){this.endContainer=t,this.endOffset=e,this.updateCollapsed(),this.updateCommonAncestor()}collapse(t){t?(this.endContainer=this.startContainer,this.endOffset=this.startOffset):(this.startContainer=this.endContainer,this.startOffset=this.endOffset),this.collapsed=!0,this.updateCommonAncestor()}selectNode(t){if(!t.parentNode)throw new Error("Node has no parent");const e=t.parentNode.childNodes.indexOf(t);this.setStart(t.parentNode,e),this.setEnd(t.parentNode,e+1)}selectNodeContents(t){this.setStart(t,0),t.nodeName==="#text"?this.setEnd(t,t.nodeValue.length):this.setEnd(t,t.childNodes.length)}toString(){if(this.collapsed||!this.startContainer||!this.endContainer||!this.commonAncestorContainer)return"";const{charOffsetMap:t,styledLine:e}=x(this.commonAncestorContainer),s=y(this,t);if(!s)return"";const r=e.slice(s.start,s.end);return r.getTextRange(0,r.length)}updateCollapsed(){this.collapsed=this.startContainer===this.endContainer&&this.startOffset===this.endOffset}updateCommonAncestor(){if(!this.startContainer||!this.endContainer){this.commonAncestorContainer=void 0;return}if(this.startContainer===this.endContainer){this.commonAncestorContainer=this.startContainer;return}const t=m(this.startContainer),e=m(this.endContainer);let s;for(let r=0;r<Math.min(t.length,e.length)&&t[r]===e[r];r++)s=t[r];this.commonAncestorContainer=s}}class L{static{g(this,"Selection")}static{l(this,"Selection")}anchorNode=void 0;anchorOffset=0;focusNode=void 0;focusOffset=0;isCollapsed=!0;rangeCount=0;ranges=[];listeners=new Set;onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}toString(){return this.ranges.map(t=>t.toString()).join("")}getRangeAt(t){return this.ranges[t]}addRange(t){this.ranges.includes(t)||(this.ranges.push(t),this.rangeCount=this.ranges.length,this.rangeCount===1&&(this.anchorNode=t.startContainer,this.anchorOffset=t.startOffset,this.focusNode=t.endContainer,this.focusOffset=t.endOffset,this.isCollapsed=t.collapsed),this.notifyChange())}removeRange(t){const e=this.ranges.indexOf(t);e!==-1&&(this.ranges.splice(e,1),this.rangeCount=this.ranges.length,this.rangeCount===0&&this.clearState(),this.notifyChange())}removeAllRanges(){this.ranges=[],this.rangeCount=0,this.clearState(),this.notifyChange()}collapse(t,e){this.removeAllRanges();const s=new A;s.setStart(t,e),s.setEnd(t,e),this.addRange(s)}containsNode(t,e=!1){if(!t.parentNode)return!1;const s=t.parentNode,r=s.childNodes.indexOf(t),i=s,h=r,o=s,d=r+1;return this.ranges.some(a=>{if(!a.startContainer||!a.endContainer)return!1;const u=p(a.startContainer,a.startOffset,i,h),f=p(a.endContainer,a.endOffset,o,d);if(e){const c=p(a.startContainer,a.startOffset,o,d),C=p(a.endContainer,a.endOffset,i,h);return c<0&&C>0}return u<=0&&f>=0})}clearState(){this.anchorNode=void 0,this.anchorOffset=0,this.focusNode=void 0,this.focusOffset=0,this.isCollapsed=!0}notifyChange(){for(const t of this.listeners)t()}}const T=l((n,t)=>{if(n.length===0||t.start>=t.end)return n;const e=n.clone(),s=Math.max(0,t.start),r=Math.min(n.length,t.end);for(let i=s;i<r;i++)e.setInverted(i,!0);return e},"applySelectionToStyledLine");export{A as Range,L as Selection,T as applySelectionToStyledLine,p as comparePoints};
1
+ var N=Object.defineProperty;var g=(n,t)=>N(n,"name",{value:t,configurable:!0});import{g as m}from"./dom-BG-LS10p.js";import{t as O}from"./measure-text-DDjHT1jD.js";import{squashTextNodesWithMap as S}from"./squashTextNodesWithMap-DCdi3SZ2.js";var v=Object.defineProperty,l=g((n,t)=>v(n,"name",{value:t,configurable:!0}),"f");const x=l(n=>{if(n.nodeName==="#text"){const r=O(n.nodeValue);return{charOffsetMap:new Map([[n,{end:r.length,start:0}]]),styledLine:r}}const t=new Map,e=S(n,t,{current:0}),s=O(e);return t.set(n,{end:s.length,start:0}),{charOffsetMap:t,styledLine:s}},"getPlainTextFromDomNode"),y=l((n,t)=>{if(!n.startContainer||!n.endContainer)return;const e=l((i,h)=>{const o=t.get(i);if(!o)return;if(i.nodeName==="#text")return o.start+h;const d=i;if(h>=d.childNodes.length)return o.end;const a=d.childNodes[h],u=t.get(a);if(u)return u.start;for(let f=h-1;f>=0;f--){const c=d.childNodes[f],C=t.get(c);if(C)return C.end}return o.start},"getOffset"),s=e(n.startContainer,n.startOffset),r=e(n.endContainer,n.endOffset);if(!(s===void 0||r===void 0))return{end:r,start:s}},"getRangeCharacterOffsets"),p=l((n,t,e,s)=>{if(n===e)return t===s?0:t<s?-1:1;const r=m(n),i=m(e);let h,o=0;for(;o<r.length&&o<i.length&&r[o]===i[o];)h=r[o],o++;if(!h)return 0;if(o===r.length){const c=i[o],C=n.childNodes.indexOf(c);return t<=C?-1:1}if(o===i.length){const c=r[o];return e.childNodes.indexOf(c)<s?-1:1}const d=r[o],a=i[o],u=h.childNodes.indexOf(d),f=h.childNodes.indexOf(a);return u<f?-1:1},"comparePoints");class A{static{g(this,"Range")}static{l(this,"Range")}startContainer=void 0;startOffset=0;endContainer=void 0;endOffset=0;collapsed=!0;commonAncestorContainer=void 0;setStart(t,e){this.startContainer=t,this.startOffset=e,this.updateCollapsed(),this.updateCommonAncestor()}setEnd(t,e){this.endContainer=t,this.endOffset=e,this.updateCollapsed(),this.updateCommonAncestor()}collapse(t){t?(this.endContainer=this.startContainer,this.endOffset=this.startOffset):(this.startContainer=this.endContainer,this.startOffset=this.endOffset),this.collapsed=!0,this.updateCommonAncestor()}selectNode(t){if(!t.parentNode)throw new Error("Node has no parent");const e=t.parentNode.childNodes.indexOf(t);this.setStart(t.parentNode,e),this.setEnd(t.parentNode,e+1)}selectNodeContents(t){this.setStart(t,0),t.nodeName==="#text"?this.setEnd(t,t.nodeValue.length):this.setEnd(t,t.childNodes.length)}toString(){if(this.collapsed||!this.startContainer||!this.endContainer||!this.commonAncestorContainer)return"";const{charOffsetMap:t,styledLine:e}=x(this.commonAncestorContainer),s=y(this,t);if(!s)return"";const r=e.slice(s.start,s.end);return r.getTextRange(0,r.length)}updateCollapsed(){this.collapsed=this.startContainer===this.endContainer&&this.startOffset===this.endOffset}updateCommonAncestor(){if(!this.startContainer||!this.endContainer){this.commonAncestorContainer=void 0;return}if(this.startContainer===this.endContainer){this.commonAncestorContainer=this.startContainer;return}const t=m(this.startContainer),e=m(this.endContainer);let s;for(let r=0;r<Math.min(t.length,e.length)&&t[r]===e[r];r++)s=t[r];this.commonAncestorContainer=s}}class L{static{g(this,"Selection")}static{l(this,"Selection")}anchorNode=void 0;anchorOffset=0;focusNode=void 0;focusOffset=0;isCollapsed=!0;rangeCount=0;ranges=[];listeners=new Set;onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}toString(){return this.ranges.map(t=>t.toString()).join("")}getRangeAt(t){return this.ranges[t]}addRange(t){this.ranges.includes(t)||(this.ranges.push(t),this.rangeCount=this.ranges.length,this.rangeCount===1&&(this.anchorNode=t.startContainer,this.anchorOffset=t.startOffset,this.focusNode=t.endContainer,this.focusOffset=t.endOffset,this.isCollapsed=t.collapsed),this.notifyChange())}removeRange(t){const e=this.ranges.indexOf(t);e!==-1&&(this.ranges.splice(e,1),this.rangeCount=this.ranges.length,this.rangeCount===0&&this.clearState(),this.notifyChange())}removeAllRanges(){this.ranges=[],this.rangeCount=0,this.clearState(),this.notifyChange()}collapse(t,e){this.removeAllRanges();const s=new A;s.setStart(t,e),s.setEnd(t,e),this.addRange(s)}containsNode(t,e=!1){if(!t.parentNode)return!1;const s=t.parentNode,r=s.childNodes.indexOf(t),i=s,h=r,o=s,d=r+1;return this.ranges.some(a=>{if(!a.startContainer||!a.endContainer)return!1;const u=p(a.startContainer,a.startOffset,i,h),f=p(a.endContainer,a.endOffset,o,d);if(e){const c=p(a.startContainer,a.startOffset,o,d),C=p(a.endContainer,a.endOffset,i,h);return c<0&&C>0}return u<=0&&f>=0})}clearState(){this.anchorNode=void 0,this.anchorOffset=0,this.focusNode=void 0,this.focusOffset=0,this.isCollapsed=!0}notifyChange(){for(const t of this.listeners)t()}}const T=l((n,t)=>{if(n.length===0||t.start>=t.end)return n;const e=n.clone(),s=Math.max(0,t.start),r=Math.min(n.length,t.end);for(let i=s;i<r;i++)e.setInverted(i,!0);return e},"applySelectionToStyledLine");export{A as Range,L as Selection,T as applySelectionToStyledLine,p as comparePoints};
@@ -1 +1 @@
1
- var tr=Object.defineProperty;var L=(n,o)=>tr(n,"name",{value:o,configurable:!0});import{jsx as M,jsxs as nr}from"react/jsx-runtime";import{useState as U,useRef as d,useCallback as A,useLayoutEffect as q,isValidElement as E,useImperativeHandle as cr,Fragment as G}from"react";import{P as W}from"./layout-P24eyWyL.js";import{Box as b}from"../components/box.js";var ur=Object.defineProperty,or=L((n,o)=>ur(n,"name",{value:o,configurable:!0}),"r");const Q=or(n=>{const[o,m]=U(n),s=d(n),H=A(C=>{const S=typeof C=="function"?C(s.current):C;s.current=S,m(S)},[]),v=A(()=>s.current,[]);return[o,H,v]},"useStateRef");var ir=Object.defineProperty,x=L((n,o)=>ir(n,"name",{value:o,configurable:!0}),"b");const lr=x(({children:n,index:o,measureKey:m,onMeasure:s,width:H})=>{const v=d(null);return q(()=>{if(v.current){const{height:C}=W(v.current);s(o,C)}},[o,s,H,m,n]),M(b,{flexDirection:"column",flexShrink:0,ref:v,width:"100%",children:n})},"MeasurableItem"),R=x(n=>{if(n==null)return[];if(Array.isArray(n)){const o=[];for(let m=0;m<n.length;m+=1){const s=n[m];E(s)&&s.type===G?o.push(...R(s.props.children)):o.push(s)}return o}return E(n)&&n.type===G?R(n.props.children):[n]},"toChildArray"),mr=x(({children:n,debug:o=!1,onContentHeightChange:m,onItemHeightChange:s,onViewportSizeChange:H,overscan:v=3,ref:C,scrollOffset:S,virtualize:X=!1,...Y})=>{const D=d(!1),[J,N,V]=Q({height:0,width:0}),[O,K,P]=Q(0),[Z,_]=U({}),j=d(null),T=d(0);q(()=>{O!==T.current&&(m?.(O,T.current),T.current=O)},[O,m]);const i=d({}),h=d([]),p=d([]),f=d(0),rr=A((r,e)=>{const t=h.current[r]??r;if(i.current[t]!==e){const l=i.current[t]??0;i.current={...i.current,[t]:e};let c=0;for(let a=0;a<h.current.length;a+=1){const y=h.current[a];y!=null&&(c+=i.current[y]??0)}const u=P();c!==u&&K(c),s?.(r,e,l),f.current=Math.min(f.current,r+1)}},[s,P,K]),$=A(()=>{if(j.current){const{height:r,width:e}=W(j.current),t=V();(e!==t.width||r!==t.height)&&(H?.({height:r,width:e},t),N({height:r,width:e}))}},[j,H,V,N]);q(()=>{$()});const z=d(null);if(z.current!==n){z.current=n;const r=[],e={};R(n).forEach((c,u)=>{if(!c)return;const a=(E(c)?c.key:null)??u;r[u]=a;const y=i.current[a]??0;e[a]=y}),i.current=e,h.current=r,p.current=Array.from({length:r.length}).fill(0),f.current=0;let t=0;r.forEach(c=>{t+=e[c]??0});const l=P();t!==l&&K(t)}cr(C,()=>({getBottomOffset:x(()=>Math.max(0,P()-V().height),"getBottomOffset"),getContentHeight:P,getItemHeight:x(r=>{const e=h.current[r]??r;return i.current[e]??0},"getItemHeight"),getItemPosition:x(r=>{if(r<0||r>=h.current.length)return null;if(r>=f.current){let l=0,c=0;if(f.current>0){c=f.current;const u=c-1,a=h.current[u]??u,y=i.current[a]??0;l=(p.current[u]??0)+y}for(let u=c;u<=r;u+=1){p.current[u]=l;const a=h.current[u]??u,y=i.current[a]??0;l+=y}f.current=r+1}const e=p.current[r]??0,t=h.current[r]??r;return{height:i.current[t]??0,top:e}},"getItemPosition"),getViewportHeight:x(()=>V().height,"getViewportHeight"),remeasure:$,remeasureItem:x(r=>{_(e=>({...e,[r]:(e[r]??0)+1}))},"remeasureItem")}),[$,P,V,_]);const I=R(n);!D.current&&O>0&&(D.current=!0);let w=0,g=I.length-1,B=0,F=0;const er=I.length>0&&I.every((r,e)=>{const t=h.current[e]??e;return(i.current[t]??0)>0}),k=X&&D.current&&er;if(k){const r=h.current.length;if(f.current<r){let t=0,l=0;if(f.current>0){l=f.current;const c=l-1,u=h.current[c]??c,a=i.current[u]??0;t=(p.current[c]??0)+a}for(let c=l;c<r;c+=1){p.current[c]=t;const u=h.current[c]??c;t+=i.current[u]??0}f.current=r}const e=S+J.height;w=I.length,g=-1;for(let t=0;t<r;t+=1){const l=p.current[t]??0,c=h.current[t]??t,u=i.current[c]??0;l+u>S&&l<e&&(t<w&&(w=t),g=t)}if(w>g&&(w=0,g=-1),w=Math.max(0,w-v),g=Math.min(I.length-1,Math.max(-1,g)+v),B=p.current[w]??0,g<I.length-1){const t=h.current[g]??g,l=(p.current[g]??0)+(i.current[t]??0);F=O-l}}return M(b,{...Y,children:M(b,{ref:j,width:"100%",children:M(b,{overflow:o?void 0:"hidden",width:"100%",children:nr(b,{flexDirection:"column",marginTop:-S,width:"100%",children:[k&&B>0&&M(b,{height:B}),I.map((r,e)=>!r||k&&(e<w||e>g)?null:M(lr,{index:e,measureKey:Z[e],onMeasure:rr,width:J.width,children:r},E(r)?r.key??e:e)),k&&F>0&&M(b,{height:F})]})})})})},"ControlledScrollView");export{mr as C,Q as R};
1
+ var tr=Object.defineProperty;var L=(n,o)=>tr(n,"name",{value:o,configurable:!0});import{jsx as M,jsxs as nr}from"react/jsx-runtime";import{useState as U,useRef as d,useCallback as A,useLayoutEffect as q,isValidElement as E,useImperativeHandle as cr,Fragment as G}from"react";import{P as W}from"./layout-BMo200nF.js";import{Box as b}from"../components/box.js";var ur=Object.defineProperty,or=L((n,o)=>ur(n,"name",{value:o,configurable:!0}),"r");const Q=or(n=>{const[o,m]=U(n),s=d(n),H=A(C=>{const S=typeof C=="function"?C(s.current):C;s.current=S,m(S)},[]),v=A(()=>s.current,[]);return[o,H,v]},"useStateRef");var ir=Object.defineProperty,x=L((n,o)=>ir(n,"name",{value:o,configurable:!0}),"b");const lr=x(({children:n,index:o,measureKey:m,onMeasure:s,width:H})=>{const v=d(null);return q(()=>{if(v.current){const{height:C}=W(v.current);s(o,C)}},[o,s,H,m,n]),M(b,{flexDirection:"column",flexShrink:0,ref:v,width:"100%",children:n})},"MeasurableItem"),R=x(n=>{if(n==null)return[];if(Array.isArray(n)){const o=[];for(let m=0;m<n.length;m+=1){const s=n[m];E(s)&&s.type===G?o.push(...R(s.props.children)):o.push(s)}return o}return E(n)&&n.type===G?R(n.props.children):[n]},"toChildArray"),mr=x(({children:n,debug:o=!1,onContentHeightChange:m,onItemHeightChange:s,onViewportSizeChange:H,overscan:v=3,ref:C,scrollOffset:S,virtualize:X=!1,...Y})=>{const D=d(!1),[J,N,V]=Q({height:0,width:0}),[O,K,P]=Q(0),[Z,_]=U({}),j=d(null),T=d(0);q(()=>{O!==T.current&&(m?.(O,T.current),T.current=O)},[O,m]);const i=d({}),h=d([]),p=d([]),f=d(0),rr=A((r,e)=>{const t=h.current[r]??r;if(i.current[t]!==e){const l=i.current[t]??0;i.current={...i.current,[t]:e};let c=0;for(let a=0;a<h.current.length;a+=1){const y=h.current[a];y!=null&&(c+=i.current[y]??0)}const u=P();c!==u&&K(c),s?.(r,e,l),f.current=Math.min(f.current,r+1)}},[s,P,K]),$=A(()=>{if(j.current){const{height:r,width:e}=W(j.current),t=V();(e!==t.width||r!==t.height)&&(H?.({height:r,width:e},t),N({height:r,width:e}))}},[j,H,V,N]);q(()=>{$()});const z=d(null);if(z.current!==n){z.current=n;const r=[],e={};R(n).forEach((c,u)=>{if(!c)return;const a=(E(c)?c.key:null)??u;r[u]=a;const y=i.current[a]??0;e[a]=y}),i.current=e,h.current=r,p.current=Array.from({length:r.length}).fill(0),f.current=0;let t=0;r.forEach(c=>{t+=e[c]??0});const l=P();t!==l&&K(t)}cr(C,()=>({getBottomOffset:x(()=>Math.max(0,P()-V().height),"getBottomOffset"),getContentHeight:P,getItemHeight:x(r=>{const e=h.current[r]??r;return i.current[e]??0},"getItemHeight"),getItemPosition:x(r=>{if(r<0||r>=h.current.length)return null;if(r>=f.current){let l=0,c=0;if(f.current>0){c=f.current;const u=c-1,a=h.current[u]??u,y=i.current[a]??0;l=(p.current[u]??0)+y}for(let u=c;u<=r;u+=1){p.current[u]=l;const a=h.current[u]??u,y=i.current[a]??0;l+=y}f.current=r+1}const e=p.current[r]??0,t=h.current[r]??r;return{height:i.current[t]??0,top:e}},"getItemPosition"),getViewportHeight:x(()=>V().height,"getViewportHeight"),remeasure:$,remeasureItem:x(r=>{_(e=>({...e,[r]:(e[r]??0)+1}))},"remeasureItem")}),[$,P,V,_]);const I=R(n);!D.current&&O>0&&(D.current=!0);let w=0,g=I.length-1,B=0,F=0;const er=I.length>0&&I.every((r,e)=>{const t=h.current[e]??e;return(i.current[t]??0)>0}),k=X&&D.current&&er;if(k){const r=h.current.length;if(f.current<r){let t=0,l=0;if(f.current>0){l=f.current;const c=l-1,u=h.current[c]??c,a=i.current[u]??0;t=(p.current[c]??0)+a}for(let c=l;c<r;c+=1){p.current[c]=t;const u=h.current[c]??c;t+=i.current[u]??0}f.current=r}const e=S+J.height;w=I.length,g=-1;for(let t=0;t<r;t+=1){const l=p.current[t]??0,c=h.current[t]??t,u=i.current[c]??0;l+u>S&&l<e&&(t<w&&(w=t),g=t)}if(w>g&&(w=0,g=-1),w=Math.max(0,w-v),g=Math.min(I.length-1,Math.max(-1,g)+v),B=p.current[w]??0,g<I.length-1){const t=h.current[g]??g,l=(p.current[g]??0)+(i.current[t]??0);F=O-l}}return M(b,{...Y,children:M(b,{ref:j,width:"100%",children:M(b,{overflow:o?void 0:"hidden",width:"100%",children:nr(b,{flexDirection:"column",marginTop:-S,width:"100%",children:[k&&B>0&&M(b,{height:B}),I.map((r,e)=>!r||k&&(e<w||e>g)?null:M(lr,{index:e,measureKey:Z[e],onMeasure:rr,width:J.width,children:r},E(r)?r.key??e:e)),k&&F>0&&M(b,{height:F})]})})})})},"ControlledScrollView");export{mr as C,Q as R};
@@ -0,0 +1,2 @@
1
+ var g=Object.defineProperty;var s=(i,o)=>g(i,"name",{value:o,configurable:!0});import{createDecMode as L,setMode as v,resetMode as S,BracketedPasteMode as O,cursorUp as N,cursorToColumn1 as Y,cursorHide as k,REQUEST_CURSOR_POSITION as z,cursorPosition as m,eraseLine as A,cursorShow as B}from"@visulima/ansi";import{terminalSize as C,Renderer as D}from"./Renderer-DJXooAsp.js";var G=Object.defineProperty,n=s((i,o)=>G(i,"name",{value:o,configurable:!0}),"r");const y=L(2026),_=v(y),j=S(y),H=v(O),Q=S(O);function q(i,o={}){const E=o.rows??10,P=o.fps??60,U=o.onExit??"preserve";let d=null,c=null,l=null,u=80,r=10,h=0,a=1;function e(t){c.writeRaw(t)}s(e,"e"),n(e,"write");function p(){l.fill(0),i(l,u,r,h++),e(_);try{c.render(l)}finally{e(j)}}s(p,"u"),n(p,"tick");function w(t){a=t-r,e(N(r)+Y),c.setRowOffset(a),p(),d=setInterval(()=>{p()},Math.round(1e3/P))}s(w,"E"),n(w,"startRendering");function I(){const t=C();u=t.cols;const x=t.rows;r=Math.min(E,x),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8"),c=new D(u,r),l=new Uint32Array(u*r*2),e(k),e(H),e(`
2
+ `.repeat(r)),e(z),process.on("SIGINT",f);let R="";const M=n(b=>{R+=b;const T=R.match(/\u001B\[(\d+);(\d+)R/);T&&(process.stdin.off("data",M),w(Number.parseInt(T[1],10)))},"onData");process.stdin.on("data",M)}s(I,"P"),n(I,"start");function f(){if(d&&(clearInterval(d),d=null),c){if(U==="destroy"){for(let t=0;t<r;t++)e(m(a+1+t,1)+A);e(m(a+1,1))}else e(m(a+r+1,1));e(Q),e(B)}process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause(),process.exit(0)}return s(f,"f"),n(f,"stop"),{start:I,stop:f}}s(q,"createInlineLoop");n(q,"createInlineLoop");export{q as createInlineLoop};
@@ -0,0 +1,3 @@
1
+ var u=Object.defineProperty;var n=(t,r)=>u(t,"name",{value:r,configurable:!0});import{strip as i}from"@visulima/ansi";var c=Object.defineProperty,s=n((t,r)=>c(t,"name",{value:r,configurable:!0}),"e");const m=s((t,r)=>{const a=s(e=>e===void 0?"":i(e),"clean");return{contains(e){return this.text().includes(e)},frames(){return r.map(e=>i(e))},line(e){return this.text().split(`
2
+ `)[e]??""},lines(){return this.text().split(`
3
+ `).filter(e=>e.trim()!=="")},matches(e){return e.test(this.text())},rawFrames(){return[...r]},rawText(){return t()??""},text(){return a(t())}}},"createScreen");export{m as createScreen};
@@ -0,0 +1 @@
1
+ var f=Object.defineProperty;var s=(e,t)=>f(e,"name",{value:t,configurable:!0});import p from"yoga-layout";import{e as c}from"./measure-text-DDjHT1jD.js";import m from"./squashTextNodesWithMap-DCdi3SZ2.js";import{wordWrap as C,truncate as v}from"@visulima/string";var x=Object.defineProperty,R=s((e,t)=>x(e,"name",{value:t,configurable:!0}),"R");const u={},T={hard:"STRICT_WIDTH",wrap:"BREAK_WORDS","wrap-anywhere":"BREAK_AT_CHARACTERS","wrap-preserve-words":"PRESERVE_WORDS","wrap-strict":"STRICT_WIDTH"},k=R((e,t,o)=>{const r=e+String(t)+String(o),n=u[r];if(n)return n;let d=e;const N=T[o];if(N)d=C(e,{trim:!1,width:t,wrapMode:N}).replace(/\n$/,"");else if(o.startsWith("truncate")){let i="end";o==="truncate-middle"&&(i="middle"),o==="truncate-start"&&(i="start"),d=v(e,t,{position:i})}return u[r]=d,d},"wrapText");var S=Object.defineProperty,a=s((e,t)=>S(e,"name",{value:t,configurable:!0}),"n");let b=0;const P=a(e=>{const t={attributes:{},childNodes:[],internal_accessibility:{},internal_id:b++,nodeName:e,parentNode:void 0,style:{},yogaNode:e==="ink-virtual-text"||e==="ink-cursor"?void 0:p.Node.create()};return e==="ink-text"&&t.yogaNode?.setMeasureFunc(_.bind(null,t)),t},"createNode"),l=a(e=>{g(e.nodeName==="ink-static-render"&&e.cachedRender?e.parentNode:e)},"markNodeAndParentIfStaticAsDirty"),O=a((e,t)=>{t.parentNode&&y(t.parentNode,t),t.parentNode=e,e.childNodes.push(t),t.yogaNode&&e.yogaNode?.insertChild(t.yogaNode,e.yogaNode.getChildCount()),l(e)},"appendChildNode"),V=a((e,t,o)=>{t.parentNode&&y(t.parentNode,t),t.parentNode=e;const r=e.childNodes.indexOf(o);if(r===-1)e.childNodes.push(t),t.yogaNode&&e.yogaNode?.insertChild(t.yogaNode,e.yogaNode.getChildCount());else if(e.childNodes.splice(r,0,t),t.yogaNode){const n=e.childNodes.slice(0,r).filter(d=>!!d.yogaNode).length;e.yogaNode?.insertChild(t.yogaNode,n)}l(e)},"insertBeforeNode"),y=a((e,t)=>{if(t.yogaNode){const r=t.yogaNode.getParent();r&&r.removeChild(t.yogaNode)}t.parentNode=void 0;const o=e.childNodes.indexOf(t);o!==-1&&e.childNodes.splice(o,1),l(e)},"removeChildNode"),I=a((e,t,o)=>{if(t==="internal_accessibility"){e.internal_accessibility=o;return}e.attributes[t]=o},"setAttribute"),B=a((e,t)=>{e.style=t??{}},"setStyle"),H=a(e=>{const t={nodeName:"#text",nodeValue:e,parentNode:void 0,style:{},yogaNode:void 0};return w(t,e),t},"createTextNode"),_=a(function(e,t){const o=e.nodeName==="#text"?e.nodeValue:m(e),r=c(o);if(r.width<=t||r.width>=1&&t>0&&t<1)return r;const n=e.style?.textWrap??"wrap",d=k(o,Math.floor(t),n);return c(d)},"measureTextNode"),h=a(e=>{if(e?.parentNode)return e.yogaNode??h(e.parentNode)},"findClosestYogaNode"),g=a(e=>{(e?.nodeName==="#text"||e?.nodeName==="ink-text"||e?.nodeName==="ink-virtual-text")&&h(e)?.markDirty();let t=e;for(;t;){if((t.nodeName==="ink-text"||t.nodeName==="ink-virtual-text")&&(t.internal_textCache=void 0),"childNodes"in t){if(t!==e&&t.nodeName==="ink-static-render"&&t.cachedRender)break;t.cachedRender=void 0}t=t.parentNode}},"markNodeAsDirty"),w=a((e,t)=>{typeof t!="string"&&(t=String(t)),e.nodeValue=t,g(e)},"setTextNodeValue"),$=a((e,t)=>e.nodeName!=="ink-root"?()=>{}:(e.internal_layoutListeners??=new Set,e.internal_layoutListeners.add(t),()=>{e.internal_layoutListeners?.delete(t)}),"addLayoutListener"),j=a(e=>{if(!(e.nodeName!=="ink-root"||!e.internal_layoutListeners))for(const t of e.internal_layoutListeners)t()},"emitLayoutListeners"),M=a((e,t)=>{if(e.cachedRender=t,e.yogaNode){for(e.yogaNode.setWidth(t.width),e.yogaNode.setHeight(t.height);e.yogaNode.getChildCount()>0;)e.yogaNode.removeChild(e.yogaNode.getChild(0));e.isYogaTreeDetached=!0}},"setCachedRender"),K=a(e=>{const t=[];let o=e;for(;o;)t.unshift(o),o=o.parentNode;return t},"getPathToRoot"),Y=a(e=>{let t=e;for(;t;){const{userSelect:o}=t.style;if(o==="none")return!1;if(o==="text"||o==="all")return!0;t=t.parentNode}return!0},"isNodeSelectable");export{k as T,$ as a,V as b,P as c,O as d,j as e,H as f,K as g,B as h,Y as i,I as j,M as k,g as m,y as r,w as s};
@@ -1,5 +1,8 @@
1
1
  import { Node } from 'yoga-layout';
2
- import { S as Styles } from "./styles.d-i6Mejqz2.js";
2
+ import '@visulima/colorize';
3
+ import 'cli-boxes';
4
+ import 'type-fest';
5
+ import { S as Styles } from "./styles.d-cMo36xQz.js";
3
6
  type StyleSpan = {
4
7
  bgColor?: string;
5
8
  fgColor?: string;
@@ -300,6 +303,13 @@ type DOMElement = InkNode & {
300
303
  };
301
304
  internal_layoutListeners?: Set<LayoutListener>;
302
305
  /**
306
+ * Highest scrollTop whose scrolled-off lines have already been flushed
307
+ * into the terminal's real scrollback history. Monotonic; used by the
308
+ * `overflowToBackbuffer` emission path so a given line is pushed exactly
309
+ * once and scrolling back up never re-emits.
310
+ */
311
+ internal_maxPushedScrollTop?: number;
312
+ /**
303
313
  * Maximum scrollTop ever reached, used with stableScrollback.
304
314
  */
305
315
  internal_maxScrollTop?: number;
@@ -1 +1 @@
1
- import"yoga-layout";import"./measure-text-CIs55Wao.js";import"./squashTextNodesWithMap-Cpqmc45i.js";import{a as r,d,c as i,f as m,e as N,g as l,b as p,i as c,m as h,r as n,j as u,l as y,h as L,s as b}from"./dom-CMbdnYbk.js";export{r as addLayoutListener,d as appendChildNode,i as createNode,m as createTextNode,N as emitLayoutListeners,l as getPathToRoot,p as insertBeforeNode,c as isNodeSelectable,h as markNodeAsDirty,n as removeChildNode,u as setAttribute,y as setCachedRender,L as setStyle,b as setTextNodeValue};
1
+ import"yoga-layout";import"./measure-text-DDjHT1jD.js";import"./squashTextNodesWithMap-DCdi3SZ2.js";import{a as r,d,c as i,f as m,e as N,g as l,b as p,i as c,m as h,r as n,j as u,k as y,h as L,s as b}from"./dom-BG-LS10p.js";export{r as addLayoutListener,d as appendChildNode,i as createNode,m as createTextNode,N as emitLayoutListeners,l as getPathToRoot,p as insertBeforeNode,c as isNodeSelectable,h as markNodeAsDirty,n as removeChildNode,u as setAttribute,y as setCachedRender,L as setStyle,b as setTextNodeValue};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var u=(t,e)=>p(t,"name",{value:e,configurable:!0});import l from"yoga-layout";var E=Object.defineProperty,n=u((t,e)=>E(t,"name",{value:e,configurable:!0}),"a");const S=n(t=>{const{yogaNode:e}=t;if(!e)return{scrollHeight:0,scrollWidth:0};const a=e.getComputedBorder(l.EDGE_TOP),s=e.getComputedBorder(l.EDGE_LEFT);let c=a,r=e.getComputedPadding(l.EDGE_LEFT);for(let i=0;i<e.getChildCount();i++){const o=e.getChild(i),d=o.getComputedTop()+o.getComputedHeight()+o.getComputedMargin(l.EDGE_BOTTOM);d>c&&(c=d);const g=o.getComputedLeft()+o.getComputedWidth()+o.getComputedMargin(l.EDGE_RIGHT);g>r&&(r=g)}const m=c-a+e.getComputedPadding(l.EDGE_BOTTOM),h=r-s+e.getComputedPadding(l.EDGE_RIGHT);return{scrollHeight:Math.round(m),scrollWidth:Math.round(h)}},"calculateScrollDimensions"),_=n(t=>Math.round(t.internal_scrollState?.scrollHeight??0),"getScrollHeight"),C=n(t=>Math.round(t.internal_scrollState?.scrollWidth??0),"getScrollWidth"),f=n(t=>{const{yogaNode:e}=t;if(!e)return;const{scrollHeight:a,scrollWidth:s}=S(t);let c=a;const r=Math.max(0,e.getComputedHeight()-e.getComputedBorder(l.EDGE_TOP)-e.getComputedBorder(l.EDGE_BOTTOM));if(t.style.stableScrollback&&t.style.overflowToBackbuffer){const o=Math.max(0,a-r);if(t.internal_isScrollbackDirty)t.internal_maxScrollTop=o,t.internal_isScrollbackDirty=!1;else{const d=Math.max(t.internal_maxScrollTop??0,o),{maxScrollbackLength:g}=t.style;t.internal_maxScrollTop=g===void 0?d:Math.min(d,o+Math.max(0,g))}c=Math.max(a,(t.internal_maxScrollTop??0)+r)}const m=Math.max(0,Math.min(t.style.scrollTop??0,c-r)),h=Math.max(0,e.getComputedWidth()-e.getComputedBorder(l.EDGE_LEFT)-e.getComputedBorder(l.EDGE_RIGHT)),i=Math.max(0,Math.min(t.style.scrollLeft??0,s-h));t.internal_scrollState={actualScrollHeight:a,clientHeight:r,clientWidth:h,scrollHeight:c,scrollLeft:i,scrollTop:m,scrollWidth:s}},"calculateScroll"),x=n(t=>Math.round(t.internal_scrollState?.scrollTop??0),"getScrollTop"),D=n(t=>Math.round(t.internal_scrollState?.scrollLeft??0),"getScrollLeft");export{f as calculateScroll,_ as getScrollHeight,D as getScrollLeft,x as getScrollTop,C as getScrollWidth};
@@ -0,0 +1,90 @@
1
+ import { EventEmitter } from 'tseep';
2
+ declare class TuiApp extends EventEmitter {
3
+ private renderer;
4
+ private terminal;
5
+ private backBuffer;
6
+ private width;
7
+ private height;
8
+ private isRunning;
9
+ private stdoutBuffer;
10
+ private stderrBuffer;
11
+ constructor();
12
+ /** Enters raw mode + alternate screen. Does NOT start any render loop. */
13
+ start(): void;
14
+ /** Request a clean exit — restores terminal, stops input, exits the process. */
15
+ quit(): void;
16
+ /** Exits raw mode + alternate screen, then flushes any buffered stdout/stderr. */
17
+ stop(): void;
18
+ /**
19
+ * Buffer a write to stdout. While the alternate screen is active, writing
20
+ * directly would corrupt the TUI. Buffered output is flushed on stop().
21
+ */
22
+ writeStdout(text: string): void;
23
+ /**
24
+ * Buffer a write to stderr. While the alternate screen is active, writing
25
+ * directly would corrupt the TUI. Buffered output is flushed on stop().
26
+ */
27
+ writeStderr(text: string): void;
28
+ /** Returns the shared Uint32Array back-buffer (width * height * 2 u32 cells). */
29
+ getBuffer(): Uint32Array;
30
+ /** Returns current terminal dimensions. */
31
+ getSize(): {
32
+ height: number;
33
+ width: number;
34
+ };
35
+ /** Update terminal dimensions (called on SIGWINCH). */
36
+ resize(width: number, height: number): void;
37
+ /**
38
+ * Callbacks fired on every frame after React paints the buffer but before
39
+ * the Rust diff engine flushes to stdout. Use for direct buffer painting
40
+ * that needs to overlay React output (animated graphs, overlays, FPS counters).
41
+ * Multiple listeners are supported — they fire in registration order.
42
+ */
43
+ private beforeFlushListeners;
44
+ onBeforeFlush(function_: (buffer: Uint32Array, width: number, height: number) => void): () => void;
45
+ /**
46
+ * Layout + paint synchronously. Called from the render loop on every dirty frame,
47
+ * and directly on resize for immediate response.
48
+ */
49
+ paintNow(calculateLayout: (w: number, h: number) => void, renderToBuffer: (buf: Uint32Array, w: number, h: number) => void): void;
50
+ }
51
+ interface InlineOptions {
52
+ /** Frames per second. Default: 60 */
53
+ fps?: number;
54
+ /**
55
+ * What to do with the rendered content when the loop stops.
56
+ * - 'preserve' (default) — content stays in terminal scrollback
57
+ * - 'destroy' — content is cleared, terminal looks untouched
58
+ */
59
+ onExit?: "preserve" | "destroy";
60
+ /** Number of terminal rows to reserve. Default: 10 */
61
+ rows?: number;
62
+ }
63
+ type InlinePaintFn = (buf: Uint32Array, cols: number, rows: number, frame: number) => void;
64
+ interface InlineLoop {
65
+ start: () => void;
66
+ stop: () => void;
67
+ }
68
+ /**
69
+ * Create an inline render loop. Renders `rows` lines immediately below the
70
+ * current cursor position (no alternate screen).
71
+ */
72
+ declare function createInlineLoop(paint: InlinePaintFn, options?: InlineOptions): InlineLoop;
73
+ interface MouseEvent {
74
+ button: "left" | "right" | "middle" | "scrollUp" | "scrollDown";
75
+ ctrl: boolean;
76
+ meta: boolean;
77
+ shift: boolean;
78
+ x: number;
79
+ y: number;
80
+ }
81
+ declare class InputParser extends EventEmitter {
82
+ private stdin;
83
+ private _boundHandleData;
84
+ private _pasteBuffer;
85
+ constructor(stdin: NodeJS.ReadStream);
86
+ start(): void;
87
+ stop(): void;
88
+ private handleData;
89
+ }
90
+ export { InlineLoop as I, MouseEvent as M, TuiApp as T, InlineOptions as a, InlinePaintFn as b, InputParser as c, createInlineLoop as d };
@@ -1,2 +1,2 @@
1
- var F=Object.defineProperty;var M=(t,e)=>F(t,"name",{value:e,configurable:!0});import l from"yoga-layout";import{getScrollTop as k,getScrollLeft as W}from"./getScrollHeight-BTEY8ewu.js";import Y from"./squashTextNodesWithMap-Cpqmc45i.js";var A=Object.defineProperty,c=M((t,e)=>A(t,"name",{value:e,configurable:!0}),"u");const Q=c(t=>{const e=j(t);return{height:Math.round(t.yogaNode?.getComputedHeight()??0),width:Math.round(t.yogaNode?.getComputedWidth()??0),x:Math.round(e?.x??0),y:Math.round(e?.y??0)}},"measureElement"),Z=c(t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedWidth()??0,r=e.getComputedBorder(l.EDGE_LEFT),s=e.getComputedBorder(l.EDGE_RIGHT);return Math.round(o-r-s)},"getInnerWidth"),tt=c(t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedHeight()??0,r=e.getComputedBorder(l.EDGE_TOP),s=e.getComputedBorder(l.EDGE_BOTTOM);return Math.round(o-r-s)},"getInnerHeight"),O=c(t=>{const{yogaNode:e}=t;if(!e)return{height:0,width:0,x:0,y:0};const o=e.getComputedWidth()??0,r=e.getComputedHeight()??0;let s=e.getComputedLeft(),n=e.getComputedTop(),d=t.parentNode;for(;d?.yogaNode;){if(s+=d.yogaNode.getComputedLeft(),n+=d.yogaNode.getComputedTop(),d.nodeName==="ink-box"){const a=d.style.overflow??"visible",i=d.style.overflowX??a;(d.style.overflowY??a)==="scroll"&&(n-=k(d)),i==="scroll"&&(s-=W(d))}d=d.parentNode}return{height:Math.round(r),width:Math.round(o),x:Math.round(s),y:Math.round(n)}},"getBoundingBox"),et=c(t=>{const e=t.internal_scrollState?.scrollHeight??0,o=t.internal_scrollState?.actualScrollHeight??0;return Math.max(0,e-o)},"getAddedScrollHeight"),G=c(t=>{const{axis:e,clientDimension:o,scrollbarDimension:r,scrollDimension:s,scrollPosition:n}=t,d=r*2,a=Math.max(e==="vertical"?2:1,Math.round(o/s*d)),i=s-o,g=d-a,u=i>0?Math.round(n/i*g):0,m=u,h=u+a,p=Math.floor(m/2);return{endIndex:Math.min(r,Math.ceil(h/2)),startIndex:p,thumbEndHalf:h,thumbStartHalf:m}},"calculateScrollbarThumb"),L=c(t=>{const{axis:e,clientDimension:o,hasOppositeScrollbar:r,height:s,marginBottom:n,marginRight:d,scrollDimension:a,scrollPosition:i,width:g,x:u,y:m}=t;if(a<=o)return;if(e==="vertical"){const{endIndex:x,startIndex:B,thumbEndHalf:v,thumbStartHalf:D}=G({axis:e,clientDimension:o,scrollbarDimension:s,scrollDimension:a,scrollPosition:i}),E=u+g-1-d;return{height:s,thumb:{end:x,endHalf:v,height:x-B,start:B,startHalf:D,width:1,x:E,y:m+B},width:1,x:E,y:m}}const h=g-(r?1:0),{endIndex:p,startIndex:y,thumbEndHalf:C,thumbStartHalf:f}=G({axis:e,clientDimension:o,scrollbarDimension:h,scrollDimension:a,scrollPosition:i}),T=m+s-1-n;return{height:1,thumb:{end:p,endHalf:C,height:1,start:y,startHalf:f,width:p-y,x:u+y,y:T},width:h,x:u,y:T}},"calculateScrollbarLayout"),ot=c((t,e)=>{const{yogaNode:o}=t;if(!o)return;const r=t.style.overflow??"visible";if((t.style.overflowY??r)!=="scroll")return;const s=t.internal_scrollState?.clientHeight??0,n=t.internal_scrollState?.scrollHeight??0;if(n<=s)return;const{x:d,y:a}=e??O(t),i=o.getComputedHeight()-o.getComputedBorder(l.EDGE_TOP)-o.getComputedBorder(l.EDGE_BOTTOM);return L({axis:"vertical",clientDimension:s,hasOppositeScrollbar:!1,height:i,marginBottom:o.getComputedBorder(l.EDGE_BOTTOM),marginRight:o.getComputedBorder(l.EDGE_RIGHT),scrollDimension:n,scrollPosition:t.internal_scrollState?.scrollTop??0,width:o.getComputedWidth()-o.getComputedBorder(l.EDGE_LEFT),x:d+o.getComputedBorder(l.EDGE_LEFT),y:a+o.getComputedBorder(l.EDGE_TOP)})},"getVerticalScrollbarBoundingBox"),nt=c((t,e)=>{const{yogaNode:o}=t;if(!o)return;const r=t.style.overflow??"visible";if((t.style.overflowX??r)!=="scroll")return;const s=t.internal_scrollState?.clientWidth??0,n=t.internal_scrollState?.scrollWidth??0;if(n<=s)return;const{x:d,y:a}=e??O(t),i=t.style.overflowY??r,g=t.internal_scrollState?.clientHeight??0,u=t.internal_scrollState?.scrollHeight??0,m=i==="scroll"&&u>g;return L({axis:"horizontal",clientDimension:s,hasOppositeScrollbar:m,height:o.getComputedHeight()-o.getComputedBorder(l.EDGE_TOP),marginBottom:o.getComputedBorder(l.EDGE_BOTTOM),marginRight:o.getComputedBorder(l.EDGE_RIGHT),scrollDimension:n,scrollPosition:t.internal_scrollState?.scrollLeft??0,width:o.getComputedWidth()-o.getComputedBorder(l.EDGE_LEFT)-o.getComputedBorder(l.EDGE_RIGHT),x:d+o.getComputedBorder(l.EDGE_LEFT),y:a+o.getComputedBorder(l.EDGE_TOP)})},"getHorizontalScrollbarBoundingBox"),rt=c((t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedTop(),r=t.parentNode;for(;r&&r!==e;)r.yogaNode&&(o+=r.yogaNode.getComputedTop()),r=r.parentNode;if(!(e!==void 0&&r!==e))return Math.round(o)},"getRelativeTop"),at=c((t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedLeft(),r=t.parentNode;for(;r&&r!==e;)r.yogaNode&&(o+=r.yogaNode.getComputedLeft()),r=r.parentNode;if(!(e!==void 0&&r!==e))return Math.round(o)},"getRelativeLeft"),$=c(t=>t.nodeName==="#text"?t.nodeValue:t.nodeName==="ink-text"||t.nodeName==="ink-virtual-text"?Y(t):"","getText"),V=c(t=>{const e=[],o=c((n,d,a)=>{const{visualX:i,visualY:g,x:u,y:m}=d;let h=0,p=0,y=a;const{userSelect:C}=n.style;if(C==="none"?y=!1:(C==="text"||C==="all")&&(y=!0),n.nodeName==="ink-text"||n.nodeName==="ink-virtual-text"){if(y){const f=$(n);return e.push({height:Math.round(n.yogaNode?.getComputedHeight()??0),node:n,text:f,visualX:Math.round(i),visualY:Math.round(g),width:Math.round(n.yogaNode?.getComputedWidth()??0),x:Math.round(u),y:Math.round(m)}),{h:0,hasContent:!0,v:0}}return{h:n.yogaNode?.getComputedWidth()??0,hasContent:!1,v:n.yogaNode?.getComputedHeight()??0}}if(n.nodeName==="ink-box"||n.nodeName==="ink-root"){if(!n.yogaNode||n.yogaNode.getDisplay()===l.DISPLAY_NONE)return{h:0,hasContent:!1,v:0};const f=n.yogaNode.getComputedBorder(l.EDGE_TOP),T=n.yogaNode.getComputedBorder(l.EDGE_BOTTOM),x=n.yogaNode.getComputedBorder(l.EDGE_LEFT),B=n.yogaNode.getComputedBorder(l.EDGE_RIGHT);h+=f+T,p+=x+B;const v=n.yogaNode.getFlexDirection(),D=v===l.FLEX_DIRECTION_COLUMN||v===l.FLEX_DIRECTION_COLUMN_REVERSE;let E=0,b=0,S=!1;for(const N of n.childNodes)if(N.yogaNode){const w=u+N.yogaNode.getComputedLeft()-x-E,I=m+N.yogaNode.getComputedTop()-f-b,R=i+N.yogaNode.getComputedLeft(),X=g+N.yogaNode.getComputedTop(),H=o(N,{visualX:R,visualY:X,x:w,y:I},y);H.hasContent&&(S=!0),D?b+=H.v:E+=H.h}return D?h+=b:p+=E,{h:p,hasContent:S,v:h}}return{h:0,hasContent:!1,v:0}},"collect"),{h:r,v:s}=o(t,{visualX:0,visualY:0,x:0,y:0},!0);return e.sort((n,d)=>n.y!==d.y?n.y-d.y:n.x-d.x),{fragments:e,removedHorizontal:Math.round(r),removedVertical:Math.round(s)}},"collectSortedFragments");var z=Object.defineProperty,_=M((t,e)=>z(t,"name",{value:e,configurable:!0}),"a");const P=_(t=>{let e=t,o=0,r=0;for(;e?.parentNode;){if(!e.yogaNode)return;o+=e.yogaNode.getComputedLeft(),r+=e.yogaNode.getComputedTop(),e=e.parentNode}return{x:o,y:r}},"getAbsoluteBorderPosition"),j=_(t=>P(t),"getAbsolutePosition"),it=_(t=>{const e=P(t);if(!(!e||!t.yogaNode))return{x:e.x+t.yogaNode.getComputedBorder(l.EDGE_LEFT)+t.yogaNode.getComputedPadding(l.EDGE_LEFT),y:e.y+t.yogaNode.getComputedBorder(l.EDGE_TOP)+t.yogaNode.getComputedPadding(l.EDGE_TOP)}},"getAbsoluteContentPosition"),lt=_((t,e)=>{const{initialState:o,onNewline:r,onSpace:s,onText:n}=e;if(t.nodeName!=="ink-box"&&t.nodeName!=="ink-root"&&t.nodeName!=="ink-text"&&t.nodeName!=="ink-virtual-text"||!t.yogaNode)return{lineBottom:0,state:o()};const{fragments:d}=V(t),a=o();a.currentX=0,a.lineBottom=0,a.yieldedContent=!1;for(const i of d){if(i.y>=a.lineBottom){const g=i.y-a.lineBottom,u=a.yieldedContent?1+g:g;u>0&&(r(u,a),a.currentX=0),a.lineBottom=i.y}if(i.x>a.currentX){const g=i.x-a.currentX;s(g,a),a.currentX=i.x}if(i.text.length>0&&(a.yieldedContent=!0,n(i,a)),(i.text.match(/\n/g)??[]).length>0){const g=i.text.lastIndexOf(`
1
+ var F=Object.defineProperty;var M=(t,e)=>F(t,"name",{value:e,configurable:!0});import l from"yoga-layout";import{getScrollTop as k,getScrollLeft as W}from"./getScrollHeight-ClEOyLHH.js";import Y from"./squashTextNodesWithMap-DCdi3SZ2.js";var A=Object.defineProperty,c=M((t,e)=>A(t,"name",{value:e,configurable:!0}),"u");const Q=c(t=>{const e=j(t);return{height:Math.round(t.yogaNode?.getComputedHeight()??0),width:Math.round(t.yogaNode?.getComputedWidth()??0),x:Math.round(e?.x??0),y:Math.round(e?.y??0)}},"measureElement"),Z=c(t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedWidth()??0,r=e.getComputedBorder(l.EDGE_LEFT),s=e.getComputedBorder(l.EDGE_RIGHT);return Math.round(o-r-s)},"getInnerWidth"),tt=c(t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedHeight()??0,r=e.getComputedBorder(l.EDGE_TOP),s=e.getComputedBorder(l.EDGE_BOTTOM);return Math.round(o-r-s)},"getInnerHeight"),O=c(t=>{const{yogaNode:e}=t;if(!e)return{height:0,width:0,x:0,y:0};const o=e.getComputedWidth()??0,r=e.getComputedHeight()??0;let s=e.getComputedLeft(),n=e.getComputedTop(),d=t.parentNode;for(;d?.yogaNode;){if(s+=d.yogaNode.getComputedLeft(),n+=d.yogaNode.getComputedTop(),d.nodeName==="ink-box"){const a=d.style.overflow??"visible",i=d.style.overflowX??a;(d.style.overflowY??a)==="scroll"&&(n-=k(d)),i==="scroll"&&(s-=W(d))}d=d.parentNode}return{height:Math.round(r),width:Math.round(o),x:Math.round(s),y:Math.round(n)}},"getBoundingBox"),et=c(t=>{const e=t.internal_scrollState?.scrollHeight??0,o=t.internal_scrollState?.actualScrollHeight??0;return Math.max(0,e-o)},"getAddedScrollHeight"),G=c(t=>{const{axis:e,clientDimension:o,scrollbarDimension:r,scrollDimension:s,scrollPosition:n}=t,d=r*2,a=Math.max(e==="vertical"?2:1,Math.round(o/s*d)),i=s-o,g=d-a,u=i>0?Math.round(n/i*g):0,m=u,h=u+a,p=Math.floor(m/2);return{endIndex:Math.min(r,Math.ceil(h/2)),startIndex:p,thumbEndHalf:h,thumbStartHalf:m}},"calculateScrollbarThumb"),L=c(t=>{const{axis:e,clientDimension:o,hasOppositeScrollbar:r,height:s,marginBottom:n,marginRight:d,scrollDimension:a,scrollPosition:i,width:g,x:u,y:m}=t;if(a<=o)return;if(e==="vertical"){const{endIndex:x,startIndex:B,thumbEndHalf:v,thumbStartHalf:D}=G({axis:e,clientDimension:o,scrollbarDimension:s,scrollDimension:a,scrollPosition:i}),E=u+g-1-d;return{height:s,thumb:{end:x,endHalf:v,height:x-B,start:B,startHalf:D,width:1,x:E,y:m+B},width:1,x:E,y:m}}const h=g-(r?1:0),{endIndex:p,startIndex:y,thumbEndHalf:C,thumbStartHalf:f}=G({axis:e,clientDimension:o,scrollbarDimension:h,scrollDimension:a,scrollPosition:i}),T=m+s-1-n;return{height:1,thumb:{end:p,endHalf:C,height:1,start:y,startHalf:f,width:p-y,x:u+y,y:T},width:h,x:u,y:T}},"calculateScrollbarLayout"),ot=c((t,e)=>{const{yogaNode:o}=t;if(!o)return;const r=t.style.overflow??"visible";if((t.style.overflowY??r)!=="scroll")return;const s=t.internal_scrollState?.clientHeight??0,n=t.internal_scrollState?.scrollHeight??0;if(n<=s)return;const{x:d,y:a}=e??O(t),i=o.getComputedHeight()-o.getComputedBorder(l.EDGE_TOP)-o.getComputedBorder(l.EDGE_BOTTOM);return L({axis:"vertical",clientDimension:s,hasOppositeScrollbar:!1,height:i,marginBottom:o.getComputedBorder(l.EDGE_BOTTOM),marginRight:o.getComputedBorder(l.EDGE_RIGHT),scrollDimension:n,scrollPosition:t.internal_scrollState?.scrollTop??0,width:o.getComputedWidth()-o.getComputedBorder(l.EDGE_LEFT),x:d+o.getComputedBorder(l.EDGE_LEFT),y:a+o.getComputedBorder(l.EDGE_TOP)})},"getVerticalScrollbarBoundingBox"),nt=c((t,e)=>{const{yogaNode:o}=t;if(!o)return;const r=t.style.overflow??"visible";if((t.style.overflowX??r)!=="scroll")return;const s=t.internal_scrollState?.clientWidth??0,n=t.internal_scrollState?.scrollWidth??0;if(n<=s)return;const{x:d,y:a}=e??O(t),i=t.style.overflowY??r,g=t.internal_scrollState?.clientHeight??0,u=t.internal_scrollState?.scrollHeight??0,m=i==="scroll"&&u>g;return L({axis:"horizontal",clientDimension:s,hasOppositeScrollbar:m,height:o.getComputedHeight()-o.getComputedBorder(l.EDGE_TOP),marginBottom:o.getComputedBorder(l.EDGE_BOTTOM),marginRight:o.getComputedBorder(l.EDGE_RIGHT),scrollDimension:n,scrollPosition:t.internal_scrollState?.scrollLeft??0,width:o.getComputedWidth()-o.getComputedBorder(l.EDGE_LEFT)-o.getComputedBorder(l.EDGE_RIGHT),x:d+o.getComputedBorder(l.EDGE_LEFT),y:a+o.getComputedBorder(l.EDGE_TOP)})},"getHorizontalScrollbarBoundingBox"),rt=c((t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedTop(),r=t.parentNode;for(;r&&r!==e;)r.yogaNode&&(o+=r.yogaNode.getComputedTop()),r=r.parentNode;if(!(e!==void 0&&r!==e))return Math.round(o)},"getRelativeTop"),at=c((t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedLeft(),r=t.parentNode;for(;r&&r!==e;)r.yogaNode&&(o+=r.yogaNode.getComputedLeft()),r=r.parentNode;if(!(e!==void 0&&r!==e))return Math.round(o)},"getRelativeLeft"),$=c(t=>t.nodeName==="#text"?t.nodeValue:t.nodeName==="ink-text"||t.nodeName==="ink-virtual-text"?Y(t):"","getText"),V=c(t=>{const e=[],o=c((n,d,a)=>{const{visualX:i,visualY:g,x:u,y:m}=d;let h=0,p=0,y=a;const{userSelect:C}=n.style;if(C==="none"?y=!1:(C==="text"||C==="all")&&(y=!0),n.nodeName==="ink-text"||n.nodeName==="ink-virtual-text"){if(y){const f=$(n);return e.push({height:Math.round(n.yogaNode?.getComputedHeight()??0),node:n,text:f,visualX:Math.round(i),visualY:Math.round(g),width:Math.round(n.yogaNode?.getComputedWidth()??0),x:Math.round(u),y:Math.round(m)}),{h:0,hasContent:!0,v:0}}return{h:n.yogaNode?.getComputedWidth()??0,hasContent:!1,v:n.yogaNode?.getComputedHeight()??0}}if(n.nodeName==="ink-box"||n.nodeName==="ink-root"){if(!n.yogaNode||n.yogaNode.getDisplay()===l.DISPLAY_NONE)return{h:0,hasContent:!1,v:0};const f=n.yogaNode.getComputedBorder(l.EDGE_TOP),T=n.yogaNode.getComputedBorder(l.EDGE_BOTTOM),x=n.yogaNode.getComputedBorder(l.EDGE_LEFT),B=n.yogaNode.getComputedBorder(l.EDGE_RIGHT);h+=f+T,p+=x+B;const v=n.yogaNode.getFlexDirection(),D=v===l.FLEX_DIRECTION_COLUMN||v===l.FLEX_DIRECTION_COLUMN_REVERSE;let E=0,b=0,S=!1;for(const N of n.childNodes)if(N.yogaNode){const w=u+N.yogaNode.getComputedLeft()-x-E,I=m+N.yogaNode.getComputedTop()-f-b,R=i+N.yogaNode.getComputedLeft(),X=g+N.yogaNode.getComputedTop(),H=o(N,{visualX:R,visualY:X,x:w,y:I},y);H.hasContent&&(S=!0),D?b+=H.v:E+=H.h}return D?h+=b:p+=E,{h:p,hasContent:S,v:h}}return{h:0,hasContent:!1,v:0}},"collect"),{h:r,v:s}=o(t,{visualX:0,visualY:0,x:0,y:0},!0);return e.sort((n,d)=>n.y!==d.y?n.y-d.y:n.x-d.x),{fragments:e,removedHorizontal:Math.round(r),removedVertical:Math.round(s)}},"collectSortedFragments");var z=Object.defineProperty,_=M((t,e)=>z(t,"name",{value:e,configurable:!0}),"a");const P=_(t=>{let e=t,o=0,r=0;for(;e?.parentNode;){if(!e.yogaNode)return;o+=e.yogaNode.getComputedLeft(),r+=e.yogaNode.getComputedTop(),e=e.parentNode}return{x:o,y:r}},"getAbsoluteBorderPosition"),j=_(t=>P(t),"getAbsolutePosition"),it=_(t=>{const e=P(t);if(!(!e||!t.yogaNode))return{x:e.x+t.yogaNode.getComputedBorder(l.EDGE_LEFT)+t.yogaNode.getComputedPadding(l.EDGE_LEFT),y:e.y+t.yogaNode.getComputedBorder(l.EDGE_TOP)+t.yogaNode.getComputedPadding(l.EDGE_TOP)}},"getAbsoluteContentPosition"),lt=_((t,e)=>{const{initialState:o,onNewline:r,onSpace:s,onText:n}=e;if(t.nodeName!=="ink-box"&&t.nodeName!=="ink-root"&&t.nodeName!=="ink-text"&&t.nodeName!=="ink-virtual-text"||!t.yogaNode)return{lineBottom:0,state:o()};const{fragments:d}=V(t),a=o();a.currentX=0,a.lineBottom=0,a.yieldedContent=!1;for(const i of d){if(i.y>=a.lineBottom){const g=i.y-a.lineBottom,u=a.yieldedContent?1+g:g;u>0&&(r(u,a),a.currentX=0),a.lineBottom=i.y}if(i.x>a.currentX){const g=i.x-a.currentX;s(g,a),a.currentX=i.x}if(i.text.length>0&&(a.yieldedContent=!0,n(i,a)),(i.text.match(/\n/g)??[]).length>0){const g=i.text.lastIndexOf(`
2
2
  `);a.currentX=i.text.length-g-1}else a.currentX+=i.text.length;a.lineBottom=Math.max(a.lineBottom,i.y+i.height)}return{lineBottom:a.lineBottom,state:a}},"processLayout");export{Q as P,G as a,V as b,L as c,O as d,nt as e,tt as f,et as g,Z as h,at as i,rt as j,$ as k,ot as l,it as m,j as n,lt as p};
@@ -0,0 +1,3 @@
1
+ var X=Object.defineProperty;var k=(r,t)=>X(r,"name",{value:t,configurable:!0});import{isFullwidthCodePoint as Y,getStringWidth as Z}from"@visulima/string";import{t as tt}from"./ansi-tokenizer-DqX9nJuk.js";var et=Object.defineProperty,st=k((r,t)=>et(r,"name",{value:t,configurable:!0}),"r$1");let H=class{static{k(this,"h")}static{st(this,"DataLimitedLruMap")}map;maxDataSize;maxKeys;currentDataSize=0;constructor(t,e){this.map=new Map,this.maxKeys=t,this.maxDataSize=e}get size(){return this.map.size}clear(){this.map.clear(),this.currentDataSize=0}get(t){if(!this.map.has(t))return;const e=this.map.get(t);return this.map.delete(t),this.map.set(t,e),e}set(t,e){const s=t.length;if(!(s>this.maxDataSize)){for(this.map.has(t)&&(this.map.delete(t),this.currentDataSize-=s);this.currentDataSize+s>this.maxDataSize&&this.map.size>0;){const a=this.map.keys().next().value;if(a===void 0)break;this.map.delete(a),this.currentDataSize-=a.length}for(;this.map.size>=this.maxKeys;){const a=this.map.keys().next().value;if(a===void 0)break;this.map.delete(a),this.currentDataSize-=a.length}this.map.set(t,e),this.currentDataSize+=s}}};const at=1,nt=2,K=4,j=8,R=16,M=32,V=64,x=128;var rt=Object.defineProperty,it=k((r,t)=>rt(r,"name",{value:t,configurable:!0}),"x");const p=1073741823,C=1073741824;class d{static{k(this,"StyledLine")}static{it(this,"StyledLine")}length=0;static emptyCache=new Map;text;charData;spans;_cachedTrimmedLength;static empty(t){if(t<=0)return new d;const e=d.emptyCache.get(t);if(e)return e.clone();const s=new d;s.length=t,s.text=" ".repeat(t),s.charData=Array.from({length:t});for(let a=0;a<t;a++)s.charData[a]=a;return s.spans=[{formatFlags:0,length:t}],s._cachedTrimmedLength=0,Object.freeze(s.spans[0]),Object.freeze(s.spans),Object.freeze(s),d.emptyCache.set(t,s),s.clone()}getValue(t){if(this.text===void 0||t<0||t>=this.length)return"";const e=this.charData[t]&p,s=t+1<this.length?this.charData[t+1]&p:this.text.length;return this.text.slice(e,s)}getTextRange(t,e){if(this.text===void 0||t<0||e>this.length||t>=e)return"";const s=this.charData[t]&p,a=e<this.length?this.charData[e]&p:this.text.length;return this.text.slice(s,a)}getSpan(t){if(this.spans===void 0||t<0||t>=this.length)return;let e=0;for(const s of this.spans){if(t<e+s.length)return s;e+=s.length}}getFullWidth(t){return this.charData===void 0||t<0||t>=this.length?!1:(this.charData[t]&C)!==0}hasStyles(t){const e=this.getSpan(t);return e?(e.formatFlags&~x)!==0||e.fgColor!==void 0||e.bgColor!==void 0||e.link!==void 0:!1}getFormatFlags(t){let e=this.getSpan(t)?.formatFlags??0;return this.getFullWidth(t)&&(e|=x),e}getFgColor(t){return this.getSpan(t)?.fgColor}getBgColor(t){return this.getSpan(t)?.bgColor}getLink(t){return this.getSpan(t)?.link}setInverted(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{e?s.formatFlags|=M:s.formatFlags&=~M})}setBackgroundColor(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{s.bgColor=e})}setForegroundColor(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{s.fgColor=e})}setChar(t,e,s,a,n,h){if(t<0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const i=(s&x)!==0,o=s&~x,l=this.charData[t]&p,c=t+1<this.length?this.charData[t+1]&p:this.text.length,m=c-l,b=e.length;if(this.text=this.text.slice(0,l)+e+this.text.slice(c),m!==b){const f=b-m;for(let S=t+1;S<this.length;S++){const T=this.charData[S],w=T&p,L=T&C;this.charData[S]=w+f|L}}if(this.charData[t]=l|(i?C:0),this.trySetStyleAtIndex(t,o,a,n,h))return;this.splitSpansAt(t),this.splitSpansAt(t+1);let u=0;for(let f=0;f<this.spans.length;f++){const S=this.spans[f];if(u===t&&S.length===1){this.spans[f]={bgColor:n,fgColor:a,formatFlags:o,length:1,link:h};break}u+=S.length}this.mergeSpans()}setCharFast(t,e,s,a,n,h){if(t<0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const i=(s&x)!==0,o=s&~x,l=this.charData[t]&p,c=t+1<this.length?this.charData[t+1]&p:this.text.length,m=c-l;if(e.length===m)e!==this.text.slice(l,c)&&(this.text=this.text.slice(0,l)+e+this.text.slice(c)),this.charData[t]=l|(i?C:0);else{if(this.text=this.text.slice(0,l)+e+this.text.slice(c),m!==e.length){const u=e.length-m;for(let f=t+1;f<this.length;f++){const S=this.charData[f];this.charData[f]=(S&p)+u|S&C}}this.charData[t]=l|(i?C:0)}if(this.trySetStyleAtIndex(t,o,a,n,h))return;this.splitSpansAt(t),this.splitSpansAt(t+1);let b=0;for(let u=0;u<this.spans.length;u++){const f=this.spans[u];if(b===t&&f.length===1){this.spans[u]={bgColor:n,fgColor:a,formatFlags:o,length:1,link:h};break}b+=f.length}this.mergeSpans()}writeFrom(t,e,s=0,a){const n=a??e.length-s;if(n<=0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const h=Math.min(n,this.length-t,e.length-s),i=this.charData[t]&p,o=t+h<this.length?this.charData[t+h]&p:this.text.length;let l="";for(let g=0;g<h;g++)l+=e.getValue(s+g);const c=o-i,m=l.length-c;this.text=this.text.slice(0,i)+l+this.text.slice(o);let b=i;for(let g=0;g<h;g++){const D=e.getFullWidth(s+g);this.charData[t+g]=b|(D?C:0),b+=e.getValue(s+g).length}if(m!==0)for(let g=t+h;g<this.length;g++){const D=this.charData[g];this.charData[g]=(D&p)+m|D&C}this.splitSpansAt(t),this.splitSpansAt(t+h);const u=[];let f=0;for(const g of e.getSpans()){const D=f+g.length,P=Math.max(s,f),E=Math.min(s+h,D);if(P<E&&u.push({...g,length:E-P}),f=D,f>=s+h)break}let S=0,T=0;for(let g=0;g<this.spans.length;g++){if(T===t){S=g;break}T+=this.spans[g].length}let w=0,L=0;for(let g=S;g<this.spans.length&&L<h;g++)L+=this.spans[g].length,w++;this.spans.splice(S,w,...u),this.mergeSpans()}pushChar(t,e,s,a,n){this._cachedTrimmedLength=void 0,this.ensureInitialized();const h=(e&x)!==0,i=e&~x,o=this.text.length;this.text=(this.text??"")+t,this.charData.push(o|(h?C:0));const l=this.spans.at(-1);l?.formatFlags===i&&l.fgColor===s&&l.bgColor===a&&l.link===n?l.length++:this.spans.push({bgColor:a,fgColor:s,formatFlags:i,length:1,link:n}),this.length++}clone(){if(this.charData===void 0)return new d;const t=new d;return t.length=this.length,t.text=this.text,t.charData=[...this.charData],t.spans=this.spans.map(e=>({...e})),t._cachedTrimmedLength=this._cachedTrimmedLength,t}slice(t,e){if(this.charData===void 0)return new d;const s=Math.max(0,t),a=e===void 0?this.length:Math.min(this.length,e);if(s>=a)return new d;if(s===0&&a===this.length)return this.clone();const n=new d;n.length=a-s,n.charData=Array.from({length:n.length});const h=this.charData[s]&p,i=a<this.length?this.charData[a]&p:this.text.length;n.text=this.text.slice(h,i);for(let c=0;c<n.length;c++){const m=this.charData[s+c],b=m&p,u=m&C;n.charData[c]=b-h|u}const o=[];let l=0;for(const c of this.spans){const m=l,b=l+c.length,u=Math.max(s,m),f=Math.min(a,b);if(u<f&&o.push({...c,length:f-u}),l+=c.length,l>=a)break}return n.spans=o,n.mergeSpans(),n}combine(...t){if(t.length===0)return this.clone();const e=[this,...t].filter(i=>i.length>0);if(e.length===0)return new d;if(e.length===1)return e[0].clone();let s=0;for(const i of e)s+=i.length;const a=new d;a.length=s,a.text=e.map(i=>i.getText()).join(""),a.charData=Array.from({length:s});let n=0,h=0;for(const i of e){const o=i.charData,l=i.getText();if(o)for(let c=0;c<i.length;c++){const m=o[c],b=m&p,u=m&C;a.charData[n+c]=h+b|u}else for(let c=0;c<i.length;c++)a.charData[n+c]=h+c;n+=i.length,h+=l.length}return a.spans=e.flatMap(i=>i.getSpans().map(o=>({...o}))),a.mergeSpans(),a}getTrimmedLength(){if(this._cachedTrimmedLength!==void 0)return this._cachedTrimmedLength;if(this.length===0)return this._cachedTrimmedLength=0,0;if(this.text===void 0||this.charData===void 0)return this._cachedTrimmedLength=0,0;let t=this.length-1;if(this.spans)for(let e=this.spans.length-1;e>=0;e--){const s=this.spans[e];if((s.formatFlags&~x)!==0||s.fgColor!==void 0||s.bgColor!==void 0||s.link!==void 0)return this._cachedTrimmedLength=t+1,this._cachedTrimmedLength;for(let a=0;a<s.length;a++){const n=this.charData[t]&p;if((t+1<this.length?this.charData[t+1]&p:this.text.length)-n!==1||this.text[n]!==" ")return this._cachedTrimmedLength=t+1,this._cachedTrimmedLength;t--}}return this._cachedTrimmedLength=0,0}trimEnd(){const t=this.getTrimmedLength();return t===this.length?this:t===0?new d:this.slice(0,t)}equals(t){if(this.length!==t.length)return!1;if(this.length===0)return!0;if(this.getText()!==t.getText())return!1;const e=this.getSpans(),s=t.getSpans();if(e.length!==s.length)return!1;for(const[h,i]of e.entries()){const o=i,l=s[h];if(o.length!==l.length||o.formatFlags!==l.formatFlags||o.fgColor!==l.fgColor||o.bgColor!==l.bgColor||o.link!==l.link)return!1}const a=this.charData,n=t.charData;if(a&&n){for(let h=0;h<this.length;h++)if(a[h]!==n[h])return!1}return!0}getText(){return this.text??""}getSpans(){return this.spans??[]}getValues(){return Array.from({length:this.length},(t,e)=>this.getValue(e))}*[Symbol.iterator](){if(this.length===0)return;let t=0,e=0;const s=this.getSpans();for(let a=0;a<this.length;a++){const n=s[t],h=n?n.formatFlags:0,i=this.getFullWidth(a);yield{bgColor:n?.bgColor,fgColor:n?.fgColor,formatFlags:h|(i?x:0),fullWidth:i,hasStyles:(h&~x)!==0||n?.fgColor!==void 0||n?.bgColor!==void 0||n?.link!==void 0,link:n?.link,value:this.getValue(a)},n&&(e++,e>=n.length&&(t++,e=0))}}updateSpanAt(t,e){if(t<0||t>=this.length)return;this.ensureInitialized(),this.splitSpansAt(t),this.splitSpansAt(t+1);let s=0;for(const a of this.spans){if(s===t&&a.length===1){e(a);break}s+=a.length}this.mergeSpans()}ensureWidth(t){if(t<=this.length)return;this.ensureInitialized();const e=this.length,s=t-e,a=this.text.length;for(let h=0;h<s;h++)this.charData.push(a);this.length=t;const n=this.spans.at(-1);n?.formatFlags===0&&n.fgColor===void 0&&n.bgColor===void 0&&n.link===void 0?n.length+=s:this.spans.push({formatFlags:0,length:s})}ensureInitialized(){if(this.charData===void 0&&(this.text="",this.charData=Array.from({length:this.length}),this.spans=this.length>0?[{formatFlags:0,length:this.length}]:[],this.length>0&&this.text.length===0)){this.text=" ".repeat(this.length);for(let t=0;t<this.length;t++)this.charData[t]=t}}splitSpansAt(t){if(this.spans===void 0||t<=0||t>=this.length)return;let e=0;for(let s=0;s<this.spans.length;s++){const a=this.spans[s];if(t>e&&t<e+a.length){const n=t-e,h=a.length-n;this.spans.splice(s,1,{...a,length:n},{...a,length:h});return}e+=a.length}}trySetStyleAtIndex(t,e,s,a,n){if(!this.spans)return!1;let h=0,i=-1,o;for(let l=0;l<this.spans.length;l++){const c=this.spans[l];if(h<=t&&h+c.length>t){i=l,o=c;break}h+=c.length}if(!o)return!1;if(o.formatFlags===e&&o.fgColor===s&&o.bgColor===a&&o.link===n)return!0;if(t===h&&i>0){const l=this.spans[i-1];if(l.formatFlags===e&&l.fgColor===s&&l.bgColor===a&&l.link===n)return l.length+=1,o.length===1?this.spans.splice(i,1):o.length-=1,!0}if(t===h+o.length-1&&i<this.spans.length-1){const l=this.spans[i+1];if(l.formatFlags===e&&l.fgColor===s&&l.bgColor===a&&l.link===n)return l.length+=1,o.length===1?this.spans.splice(i,1):o.length-=1,!0}return!1}mergeSpans(){if(this.spans===void 0)return;const t=[];for(const e of this.spans){if(e.length===0)continue;const s=t.at(-1);s?.formatFlags===e.formatFlags&&s.fgColor===e.fgColor&&s.bgColor===e.bgColor&&s.link===e.link?s.length+=e.length:t.push({...e})}this.spans=t}}var ht=Object.defineProperty,I=k((r,t)=>ht(r,"name",{value:t,configurable:!0}),"u$1");const G={black:0,blue:4,cyan:6,gray:8,green:2,grey:8,magenta:5,red:1,white:7,yellow:3},U={blackBright:8,blueBright:12,cyanBright:14,greenBright:10,magentaBright:13,redBright:9,whiteBright:15,yellowBright:11},q=/^ansi256\(\s?(\d+)\s?\)$/,J=/^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/,Nt=I(r=>{const t=G[r];if(t!==void 0)return t;const e=U[r];if(e!==void 0)return e;const s=q.exec(r);if(s)return Number(s[1])&255;if(r.startsWith("#")&&r.length===7){const n=Number.parseInt(r.slice(1,3),16),h=Number.parseInt(r.slice(3,5),16),i=Number.parseInt(r.slice(5,7),16);return 16+36*Math.round(n/51)+6*Math.round(h/51)+Math.round(i/51)}const a=J.exec(r);return a?16+36*Math.round(Number(a[1])/51)+6*Math.round(Number(a[2])/51)+Math.round(Number(a[3])/51):255},"colorToAnsi256"),lt=I((r,t)=>{const e=t?30:40,s=G[r];if(s!==void 0)return[e+s];const a=U[r];if(a!==void 0)return[e+60+(a-8)];if(r.startsWith("#")&&r.length===7){const i=Number.parseInt(r.slice(1,3),16),o=Number.parseInt(r.slice(3,5),16),l=Number.parseInt(r.slice(5,7),16);return[t?38:48,2,i,o,l]}const n=q.exec(r);if(n)return[t?38:48,5,Number(n[1])];const h=J.exec(r);return h?[t?38:48,2,Number(h[1]),Number(h[2]),Number(h[3])]:[]},"colorToSgrParams");I((r,t)=>{const e=lt(r,t);if(e.length!==0)return`\x1B[${e.join(";")}m`},"colorToAnsiCode");const A=I(r=>{const t=["black","red","green","yellow","blue","magenta","cyan","white"];return r>=0&&r<=7?t[r]:`ansi256(${r})`},"ansi256ToColorName");var ot=Object.defineProperty,y=k((r,t)=>ot(r,"name",{value:t,configurable:!0}),"u");const _=y(()=>({bgColor:void 0,fgColor:void 0,formatFlags:0,link:void 0}),"createSgrState"),ct=y((r,t)=>{if(t.length===0)return _();const e=(t.includes(":")?t.replaceAll(":",";"):t).split(";").filter(o=>o.length>0).map(Number);let{bgColor:s,fgColor:a,formatFlags:n,link:h}=r,i=0;for(;i<e.length;){const o=e[i];switch(o){case 0:{n=0,a=void 0,s=void 0,h=void 0;break}case 1:{n|=at;break}case 2:{n|=nt;break}case 3:{n|=K;break}case 4:{n|=j;break}case 7:{n|=M;break}case 8:{n|=V;break}case 9:{n|=R;break}case 22:{n&=-4;break}case 23:{n&=~K;break}case 24:{n&=~j;break}case 27:{n&=~M;break}case 28:{n&=~V;break}case 29:{n&=~R;break}case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:{a=A(o-30);break}case 38:{e[i+1]===5&&e[i+2]!==void 0?(a=A(e[i+2]),i+=2):e[i+1]===2&&i+4<e.length&&(a=`rgb(${e[i+2]}, ${e[i+3]}, ${e[i+4]})`,i+=4);break}case 39:{a=void 0;break}case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:{s=A(o-40);break}case 48:{e[i+1]===5&&e[i+2]!==void 0?(s=A(e[i+2]),i+=2):e[i+1]===2&&i+4<e.length&&(s=`rgb(${e[i+2]}, ${e[i+3]}, ${e[i+4]})`,i+=4);break}case 49:{s=void 0;break}case 90:case 91:case 92:case 93:case 94:case 95:case 96:case 97:{a=`ansi256(${o-90+8})`;break}case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:{s=`ansi256(${o-100+8})`;break}}i++}return{bgColor:s,fgColor:a,formatFlags:n,link:h}},"applySgrParams"),z=127462,N=127487,gt=127995,ft=127999,ut=8205,dt=917504,mt=917631,pt=new RegExp("\\p{Mark}","u"),bt=new Intl.Segmenter(void 0,{granularity:"grapheme"}),St=y((r,t)=>!!(Y(t)||r.includes("️")||t>=z&&t<=N),"isFullwidthGrapheme"),xt=/(?:\u001B\]|\u009D)8;([^;]*);(.*?)(?:\u001B\\|\u0007|\u009C)/,Ct=y(r=>{const t=xt.exec(r);return!t?.[2]||t[2].length===0?void 0:r.endsWith("\x1B\\")?`ST:${t[2]}`:t[2]},"parseOscHyperlink"),Q=y((r,t,e)=>{const s=bt.segment(r),a=[];for(const{segment:n}of s)a.push(n);for(let n=0;n<a.length;n++){let h=a[n];if(h===" "){for(let l=0;l<4;l++)t.pushChar(" ",e.formatFlags,e.fgColor,e.bgColor,e.link);continue}if(h==="\b")continue;const i=h.codePointAt(0);if(!i)continue;if(i>=z&&i<=N&&n+1<a.length){const l=a[n+1],c=l.codePointAt(0);c&&c>=z&&c<=N&&(h+=l,n++)}else for(;n+1<a.length;){const l=a[n+1],c=l.codePointAt(0);if(!c)break;const m=pt.test(String.fromCodePoint(c)),b=c>=gt&&c<=ft,u=c===ut,f=c>=dt&&c<=mt;if(!m&&!b&&!u&&!f)break;h+=l,n++,u&&n+1<a.length&&(h+=a[n+1],n++)}const o=St(h,i)?e.formatFlags|x:e.formatFlags;t.pushChar(h,o,e.fgColor,e.bgColor,e.link)}},"processTextToken"),vt=y(r=>{if(r.length===0)return new d;const t=tt(r),e=new d;let s=_();for(const a of t)switch(a.type){case"csi":{a.finalCharacter==="m"&&(s=ct(s,a.parameterString));break}case"osc":{const n=Ct(a.value);n!==void 0?s={...s,link:n}:a.value.includes("8;")&&(s={...s,link:void 0});break}case"text":{Q(a.value,e,s);break}}return e},"textToStyledLine"),kt=/^[\u0020-\u007E]*$/,$t=y(r=>{if(r.length===0)return new d;const t=new d;if(kt.test(r)){for(const e of r)t.pushChar(e,0);return t}return Q(r,t,_()),t},"plainTextToStyledLine");var Dt=Object.defineProperty,v=k((r,t)=>Dt(r,"name",{value:t,configurable:!0}),"r");const $=new H(1e4,1e6),W=new Map,F=new H(1e4,1e6);let B=!0,O=Z;const Wt=v(r=>{B=r,r||F.clear()},"setEnableStyledLineCache"),Bt=v(()=>{F.clear()},"clearStyledLineCache"),_t=v(r=>{O=r,yt()},"setStringWidthFunction"),yt=v(()=>{$.clear(),W.clear(),F.clear()},"clearStringWidthCache"),Tt=v(r=>{if(r.length===1){const s=r.codePointAt(0);if(s!==void 0&&s>=32&&s<127)return 1}const t=W.get(r);if(t!==void 0)return t;let e;try{e=O(r)}catch{e=1}return W.set(r,e),e},"inkCharacterWidth"),Ft=v(r=>{try{return O(r)}catch{return 1}},"safeGetStringWidth"),Ot=v(r=>{if(r.length===0)return{height:0,width:0};const t=$.get(r);if(t)return t;const e=r.split(`
2
+ `),s=Math.max(...e.map(n=>Ft(n))),a={height:e.length,width:s};return $.set(r,a),a},"measureText"),Pt=v(r=>{if(B){const e=F.get(r);if(e!==void 0)return e}const t=vt(r);return B&&F.set(r,t),t},"toStyledLine"),wt=v(r=>{let t=0;for(let e=0;e<r.length;e++)t+=Tt(r.getValue(e));return t},"styledLineWidth"),Lt=v(r=>{if(r.length===0)return[new d];const t=[];let e=0;for(let s=0;s<r.length;s++)r.getValue(s)===`
3
+ `&&(t.push(s>e?r.slice(e,s):new d),e=s+1);return t.push(e<r.length?r.slice(e):new d),t},"splitStyledLineByNewline"),Et=v(r=>{if(r.length===0)return{height:0,width:0};const t=Lt(r);let e=0;for(const s of t)e=Math.max(e,wt(s));return{height:t.length,width:e}},"measureStyledLine");export{at as B,nt as D,x as F,V as H,K as I,d as S,j as U,Bt as a,_t as b,yt as c,wt as d,Ot as e,M as f,R as g,lt as h,Tt as i,Nt as j,vt as k,Lt as l,Et as m,$t as p,Wt as s,Pt as t};
@@ -1 +1 @@
1
- import"yoga-layout";import{c as r,a as g,b as i,P as s,g as c,d as n,e as d,f as u,h as b,i as m,j as B,k as S,l as h}from"./layout-P24eyWyL.js";import"./getScrollHeight-BTEY8ewu.js";import"./squashTextNodesWithMap-Cpqmc45i.js";export{r as calculateScrollbarLayout,g as calculateScrollbarThumb,i as collectSortedFragments,s as default,c as getAddedScrollHeight,n as getBoundingBox,d as getHorizontalScrollbarBoundingBox,u as getInnerHeight,b as getInnerWidth,m as getRelativeLeft,B as getRelativeTop,S as getText,h as getVerticalScrollbarBoundingBox};
1
+ import"yoga-layout";import{c as r,a as g,b as i,P as s,g as c,d as n,e as d,f as u,h as b,i as m,j as B,k as S,l as h}from"./layout-BMo200nF.js";import"./getScrollHeight-ClEOyLHH.js";import"./squashTextNodesWithMap-DCdi3SZ2.js";export{r as calculateScrollbarLayout,g as calculateScrollbarThumb,i as collectSortedFragments,s as default,c as getAddedScrollHeight,n as getBoundingBox,d as getHorizontalScrollbarBoundingBox,u as getInnerHeight,b as getInnerWidth,m as getRelativeLeft,B as getRelativeTop,S as getText,h as getVerticalScrollbarBoundingBox};
@@ -0,0 +1 @@
1
+ import{a as e}from"./ansi-parser-B6uXaq65.js";export{e as parseSgrMouse};
@@ -0,0 +1 @@
1
+ import"yoga-layout";import{m as e,n as i,p as n}from"./layout-BMo200nF.js";export{e as getAbsoluteContentPosition,i as getAbsolutePosition,n as processLayout};
@@ -1 +1 @@
1
- var P=Object.defineProperty;var p=(e,t)=>P(e,"name",{value:t,configurable:!0});import{createRequire as b}from"node:module";import{version as O,createContext as F}from"react";import G from"react-reconciler";import{NoEventPriority as L,DefaultEventPriority as v}from"react-reconciler/constants.js";import{unstable_shouldYield as w,unstable_scheduleCallback as k,unstable_now as B,unstable_cancelCallback as W}from"scheduler";import n from"yoga-layout";import{b as y,d as g,s as E,m as _,e as M,r as I,f as H,c as U,h as C,j as N}from"./dom-CMbdnYbk.js";const re=b(import.meta.url),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=D;var Y=Object.defineProperty,u=p((e,t)=>Y(e,"name",{value:t,configurable:!0}),"t");const j=[["top",n.EDGE_TOP],["right",n.EDGE_RIGHT],["bottom",n.EDGE_BOTTOM],["left",n.EDGE_LEFT]],X=u((e,t)=>{if("position"in t){let r=n.POSITION_TYPE_RELATIVE;t.position==="absolute"?r=n.POSITION_TYPE_ABSOLUTE:t.position==="static"&&(r=n.POSITION_TYPE_STATIC),e.setPositionType(r)}for(const[r,s]of j){if(!(r in t))continue;const l=t[r];if(typeof l=="string"){e.setPositionPercent(s,Number.parseFloat(l));continue}e.setPosition(s,l)}},"applyPositionStyles"),V=u((e,t)=>{"margin"in t&&e.setMargin(n.EDGE_ALL,t.margin??0),"marginX"in t&&e.setMargin(n.EDGE_HORIZONTAL,t.marginX??0),"marginY"in t&&e.setMargin(n.EDGE_VERTICAL,t.marginY??0),"marginLeft"in t&&e.setMargin(n.EDGE_START,t.marginLeft||0),"marginRight"in t&&e.setMargin(n.EDGE_END,t.marginRight||0),"marginTop"in t&&e.setMargin(n.EDGE_TOP,t.marginTop||0),"marginBottom"in t&&e.setMargin(n.EDGE_BOTTOM,t.marginBottom||0)},"applyMarginStyles"),J=u((e,t)=>{"padding"in t&&e.setPadding(n.EDGE_ALL,t.padding??0),"paddingX"in t&&e.setPadding(n.EDGE_HORIZONTAL,t.paddingX??0),"paddingY"in t&&e.setPadding(n.EDGE_VERTICAL,t.paddingY??0),"paddingLeft"in t&&e.setPadding(n.EDGE_LEFT,t.paddingLeft||0),"paddingRight"in t&&e.setPadding(n.EDGE_RIGHT,t.paddingRight||0),"paddingTop"in t&&e.setPadding(n.EDGE_TOP,t.paddingTop||0),"paddingBottom"in t&&e.setPadding(n.EDGE_BOTTOM,t.paddingBottom||0)},"applyPaddingStyles"),q=u((e,t)=>{"flexGrow"in t&&e.setFlexGrow(t.flexGrow??0),"flexShrink"in t&&e.setFlexShrink(typeof t.flexShrink=="number"?t.flexShrink:1),"flexWrap"in t&&(t.flexWrap==="nowrap"&&e.setFlexWrap(n.WRAP_NO_WRAP),t.flexWrap==="wrap"&&e.setFlexWrap(n.WRAP_WRAP),t.flexWrap==="wrap-reverse"&&e.setFlexWrap(n.WRAP_WRAP_REVERSE)),"flexDirection"in t&&(t.flexDirection==="row"&&e.setFlexDirection(n.FLEX_DIRECTION_ROW),t.flexDirection==="row-reverse"&&e.setFlexDirection(n.FLEX_DIRECTION_ROW_REVERSE),t.flexDirection==="column"&&e.setFlexDirection(n.FLEX_DIRECTION_COLUMN),t.flexDirection==="column-reverse"&&e.setFlexDirection(n.FLEX_DIRECTION_COLUMN_REVERSE)),"flexBasis"in t&&(typeof t.flexBasis=="number"?e.setFlexBasis(t.flexBasis):typeof t.flexBasis=="string"?e.setFlexBasisPercent(Number.parseInt(t.flexBasis,10)):e.setFlexBasis(Number.NaN)),"alignItems"in t&&((t.alignItems==="stretch"||!t.alignItems)&&e.setAlignItems(n.ALIGN_STRETCH),t.alignItems==="flex-start"&&e.setAlignItems(n.ALIGN_FLEX_START),t.alignItems==="center"&&e.setAlignItems(n.ALIGN_CENTER),t.alignItems==="flex-end"&&e.setAlignItems(n.ALIGN_FLEX_END),t.alignItems==="baseline"&&e.setAlignItems(n.ALIGN_BASELINE)),"alignSelf"in t&&((t.alignSelf==="auto"||!t.alignSelf)&&e.setAlignSelf(n.ALIGN_AUTO),t.alignSelf==="flex-start"&&e.setAlignSelf(n.ALIGN_FLEX_START),t.alignSelf==="center"&&e.setAlignSelf(n.ALIGN_CENTER),t.alignSelf==="flex-end"&&e.setAlignSelf(n.ALIGN_FLEX_END),t.alignSelf==="stretch"&&e.setAlignSelf(n.ALIGN_STRETCH),t.alignSelf==="baseline"&&e.setAlignSelf(n.ALIGN_BASELINE)),"alignContent"in t&&((t.alignContent==="flex-start"||!t.alignContent)&&e.setAlignContent(n.ALIGN_FLEX_START),t.alignContent==="center"&&e.setAlignContent(n.ALIGN_CENTER),t.alignContent==="flex-end"&&e.setAlignContent(n.ALIGN_FLEX_END),t.alignContent==="space-between"&&e.setAlignContent(n.ALIGN_SPACE_BETWEEN),t.alignContent==="space-around"&&e.setAlignContent(n.ALIGN_SPACE_AROUND),t.alignContent==="space-evenly"&&e.setAlignContent(n.ALIGN_SPACE_EVENLY),t.alignContent==="stretch"&&e.setAlignContent(n.ALIGN_STRETCH)),"justifyContent"in t&&((t.justifyContent==="flex-start"||!t.justifyContent)&&e.setJustifyContent(n.JUSTIFY_FLEX_START),t.justifyContent==="center"&&e.setJustifyContent(n.JUSTIFY_CENTER),t.justifyContent==="flex-end"&&e.setJustifyContent(n.JUSTIFY_FLEX_END),t.justifyContent==="space-between"&&e.setJustifyContent(n.JUSTIFY_SPACE_BETWEEN),t.justifyContent==="space-around"&&e.setJustifyContent(n.JUSTIFY_SPACE_AROUND),t.justifyContent==="space-evenly"&&e.setJustifyContent(n.JUSTIFY_SPACE_EVENLY))},"applyFlexStyles"),$=u((e,t)=>{"width"in t&&(typeof t.width=="number"?e.setWidth(t.width):typeof t.width=="string"?e.setWidthPercent(Number.parseInt(t.width,10)):e.setWidthAuto()),"height"in t&&(typeof t.height=="number"?e.setHeight(t.height):typeof t.height=="string"?e.setHeightPercent(Number.parseInt(t.height,10)):e.setHeightAuto()),"minWidth"in t&&(typeof t.minWidth=="string"?e.setMinWidthPercent(Number.parseInt(t.minWidth,10)):e.setMinWidth(t.minWidth??0)),"minHeight"in t&&(typeof t.minHeight=="string"?e.setMinHeightPercent(Number.parseInt(t.minHeight,10)):e.setMinHeight(t.minHeight??0)),"maxWidth"in t&&(typeof t.maxWidth=="string"?e.setMaxWidthPercent(Number.parseInt(t.maxWidth,10)):e.setMaxWidth(t.maxWidth)),"maxHeight"in t&&(typeof t.maxHeight=="string"?e.setMaxHeightPercent(Number.parseInt(t.maxHeight,10)):e.setMaxHeight(t.maxHeight)),"aspectRatio"in t&&e.setAspectRatio(t.aspectRatio)},"applyDimensionStyles"),z=u((e,t)=>{"display"in t&&e.setDisplay(t.display==="flex"?n.DISPLAY_FLEX:n.DISPLAY_NONE)},"applyDisplayStyles"),Z=u((e,t,r)=>{if(!("borderStyle"in t||"borderTop"in t||"borderBottom"in t||"borderLeft"in t||"borderRight"in t))return;const s=r.borderStyle?1:0;e.setBorder(n.EDGE_TOP,r.borderTop===!1?0:s),e.setBorder(n.EDGE_BOTTOM,r.borderBottom===!1?0:s),e.setBorder(n.EDGE_LEFT,r.borderLeft===!1?0:s),e.setBorder(n.EDGE_RIGHT,r.borderRight===!1?0:s)},"applyBorderStyles"),K=u((e,t)=>{"gap"in t&&e.setGap(n.GUTTER_ALL,t.gap??0),"columnGap"in t&&e.setGap(n.GUTTER_COLUMN,t.columnGap??0),"rowGap"in t&&e.setGap(n.GUTTER_ROW,t.rowGap??0)},"applyGapStyles"),Q=u((e,t)=>{const r=t.overflow??"visible",s=t.overflowX??r,l=t.overflowY??r;s==="scroll"||l==="scroll"?e.setOverflow(n.OVERFLOW_SCROLL):s==="hidden"||l==="hidden"?e.setOverflow(n.OVERFLOW_HIDDEN):e.setOverflow(n.OVERFLOW_VISIBLE)},"applyOverflowStyles"),S=u((e,t={},r=t)=>{X(e,t),V(e,t),J(e,t),q(e,t),$(e,t),z(e,t),Z(e,t,r),K(e,t),Q(e,r)},"styles");var ee=Object.defineProperty,c=p((e,t)=>ee(e,"name",{value:t,configurable:!0}),"c");if(A.env.DEV==="true"){let e=!1;try{import.meta.resolve("react-devtools-core"),e=!0}catch{}e&&await import("../packem_chunks/devtools.js")}const x=c((e,t)=>{if(e===t)return;if(!e)return t;const r={};let s=!1;for(const l of Object.keys(e))(!t||!Object.hasOwn(t,l))&&(r[l]=void 0,s=!0);if(t)for(const l of Object.keys(t))t[l]!==e[l]&&(r[l]=t[l],s=!0);return s?r:void 0},"diff"),h=c(e=>{if(e){if(e.yogaNode?.unsetMeasureFunc(),"resizeObservers"in e&&e.resizeObservers?.clear(),"childNodes"in e&&e.childNodes)for(const t of e.childNodes)h(t);e.yogaNode?.free(),"cachedRender"in e&&(e.cachedRender=void 0),"childNodes"in e&&(e.childNodes=[]),e.parentNode=void 0}},"cleanupNodeTree");let m=L,T;async function R(){const e=(await import("node:fs")).readFileSync(new URL("../package.json",import.meta.url),"utf8"),t=JSON.parse(e);return{name:t?.name,version:t?.version}}p(R,"B");c(R,"loadPackageJson");let f={name:"ink",version:O};if(A.env.DEV==="true")try{const e=await R();f={name:e.name||f.name,version:e.version||f.version}}catch(e){console.warn("Failed to load package.json in development mode. Falling back to default renderer metadata.",e)}const de=G({afterActiveInstanceBlur(){},appendChild:g,appendChildToContainer:g,appendInitialChild:g,beforeActiveInstanceBlur(){},cancelCallback:W,cancelTimeout:clearTimeout,clearContainer:c(()=>!1,"clearContainer"),commitTextUpdate(e,t,r){E(e,r)},commitUpdate(e,t,r,s){T&&e.internal_static&&(T.isStaticDirty=!0);const l=x(r,s),a=x(r.style,s.style);if(!l&&!a)return;let i=!!a;if(l){for(const[o,d]of Object.entries(l))if(o!=="children"){if(o==="style"){C(e,d);continue}if(o==="internal_transform"){e.internal_transform=d,i=!0;continue}if(o==="internal_cursor"){e.internal_cursor=d,i=!0;continue}if(o==="internal_static"){e.internal_static=!0,i=!0;continue}if(o==="sticky"){e.internal_sticky=d,i=!0;continue}if(o==="internalStickyAlternate"){e.internal_stickyAlternate=d,i=!0;continue}if(o==="opaque"){e.internal_opaque=d,i=!0;continue}if(o==="scrollbar"){e.internal_scrollbar=d,i=!0;continue}if(o==="internal_terminalCursorFocus"){e.internal_terminalCursorFocus=d,i=!0;continue}if(o==="internal_terminalCursorPosition"){e.internal_terminalCursorPosition=d,i=!0;continue}if(o==="cachedRender"){e.cachedRender=d,i=!0;continue}N(e,o,d),i=!0}}a&&e.yogaNode&&S(e.yogaNode,a,s.style??{}),i&&_(e)},createInstance(e,t,r,s){if(s.isInsideText&&e==="ink-box")throw new Error("<Box> can’t be nested inside <Text> component");if(s.isInsideText&&e==="ink-cursor")throw new Error("<Cursor> can’t be nested inside <Text> component");const l=e==="ink-text"&&s.isInsideText?"ink-virtual-text":e,a=U(l);for(const[i,o]of Object.entries(t))if(i!=="children"){if(i==="style"){C(a,o),a.yogaNode&&S(a.yogaNode,o);continue}if(i==="internal_transform"){a.internal_transform=o;continue}if(i==="internal_cursor"){a.internal_cursor=o;continue}if(i==="internal_static"){T=r,a.internal_static=!0,r.isStaticDirty=!0,r.staticNode=a;continue}if(i==="sticky"){a.internal_sticky=o;continue}if(i==="internalStickyAlternate"){a.internal_stickyAlternate=o;continue}if(i==="opaque"){a.internal_opaque=o;continue}if(i==="scrollbar"){a.internal_scrollbar=o;continue}if(i==="internal_terminalCursorFocus"){a.internal_terminalCursorFocus=o;continue}if(i==="internal_terminalCursorPosition"){a.internal_terminalCursorPosition=o;continue}if(i==="internal_static"){a.internal_static=!0;continue}if(i==="cachedRender"){a.cachedRender=o;continue}N(a,i,o)}return a},createTextInstance(e,t,r){if(!r.isInsideText)throw new Error(`Text string "${e}" must be rendered inside <Text> component`);return H(e)},detachDeletedInstance(){},finalizeInitialChildren(){return!1},getChildHostContext(e,t){const r=e.isInsideText,s=t==="ink-text"||t==="ink-virtual-text";return r===s?e:{isInsideText:s}},getCurrentUpdatePriority:c(()=>m,"getCurrentUpdatePriority"),getInstanceFromNode:c(()=>null,"getInstanceFromNode"),getInstanceFromScope:c(()=>null,"getInstanceFromScope"),getPublicInstance:c(e=>e,"getPublicInstance"),getRootHostContext:c(()=>({isInsideText:!1}),"getRootHostContext"),hideInstance(e){e.internal_hidden=!0,e.yogaNode?.setDisplay(n.DISPLAY_NONE),_(e)},hideTextInstance(e){E(e,"")},HostTransitionContext:F(null),insertBefore:y,insertInContainerBefore:y,isPrimaryRenderer:!0,maySuspendCommit(){return!0},noTimeout:-1,NotPendingTransition:void 0,now:B,preloadInstance(){return!0},prepareForCommit:c(()=>null,"prepareForCommit"),preparePortalMount:c(()=>null,"preparePortalMount"),prepareScopeUpdate(){},removeChild(e,t){I(e,t),h(t)},removeChildFromContainer(e,t){I(e,t),h(t)},rendererPackageName:f.name,rendererVersion:f.version,requestPostPaintCallback(){},resetAfterCommit(e){if(typeof e.onComputeLayout=="function"&&e.onComputeLayout(),M(e),e.staticNode!==e.previousStaticNode&&(e.previousStaticNode=e.staticNode,typeof e.onStaticChange=="function"&&e.onStaticChange()),e.isStaticDirty){e.isStaticDirty=!1,typeof e.onImmediateRender=="function"&&e.onImmediateRender();return}typeof e.onRender=="function"&&e.onRender()},resetFormInstance(){},resetTextContent(){},resolveEventTimeStamp(){return-1.1},resolveEventType(){return null},resolveUpdatePriority(){return m!==L?m:v},scheduleCallback:k,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){m=e},shouldAttemptEagerTransition(){return!1},shouldSetTextContent:c(()=>!1,"shouldSetTextContent"),shouldYield:w,startSuspendingCommit(){},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance(){},trackSchedulerEvent(){},unhideInstance(e){e.internal_hidden=!1,e.yogaNode?.setDisplay(n.DISPLAY_FLEX),_(e)},unhideTextInstance(e,t){E(e,t)},waitForCommitToBeReady(){return null}});export{de as L,S as u};
1
+ var P=Object.defineProperty;var p=(e,t)=>P(e,"name",{value:t,configurable:!0});import{createRequire as b}from"node:module";import{version as O,createContext as F}from"react";import G from"react-reconciler";import{NoEventPriority as L,DefaultEventPriority as v}from"react-reconciler/constants.js";import{unstable_shouldYield as w,unstable_scheduleCallback as k,unstable_now as B,unstable_cancelCallback as W}from"scheduler";import n from"yoga-layout";import{b as y,d as g,s as E,m as _,e as M,r as I,f as H,c as U,h as C,j as N}from"./dom-BG-LS10p.js";const re=b(import.meta.url),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=D;var Y=Object.defineProperty,u=p((e,t)=>Y(e,"name",{value:t,configurable:!0}),"t");const j=[["top",n.EDGE_TOP],["right",n.EDGE_RIGHT],["bottom",n.EDGE_BOTTOM],["left",n.EDGE_LEFT]],X=u((e,t)=>{if("position"in t){let r=n.POSITION_TYPE_RELATIVE;t.position==="absolute"?r=n.POSITION_TYPE_ABSOLUTE:t.position==="static"&&(r=n.POSITION_TYPE_STATIC),e.setPositionType(r)}for(const[r,s]of j){if(!(r in t))continue;const l=t[r];if(typeof l=="string"){e.setPositionPercent(s,Number.parseFloat(l));continue}e.setPosition(s,l)}},"applyPositionStyles"),V=u((e,t)=>{"margin"in t&&e.setMargin(n.EDGE_ALL,t.margin??0),"marginX"in t&&e.setMargin(n.EDGE_HORIZONTAL,t.marginX??0),"marginY"in t&&e.setMargin(n.EDGE_VERTICAL,t.marginY??0),"marginLeft"in t&&e.setMargin(n.EDGE_START,t.marginLeft||0),"marginRight"in t&&e.setMargin(n.EDGE_END,t.marginRight||0),"marginTop"in t&&e.setMargin(n.EDGE_TOP,t.marginTop||0),"marginBottom"in t&&e.setMargin(n.EDGE_BOTTOM,t.marginBottom||0)},"applyMarginStyles"),J=u((e,t)=>{"padding"in t&&e.setPadding(n.EDGE_ALL,t.padding??0),"paddingX"in t&&e.setPadding(n.EDGE_HORIZONTAL,t.paddingX??0),"paddingY"in t&&e.setPadding(n.EDGE_VERTICAL,t.paddingY??0),"paddingLeft"in t&&e.setPadding(n.EDGE_LEFT,t.paddingLeft||0),"paddingRight"in t&&e.setPadding(n.EDGE_RIGHT,t.paddingRight||0),"paddingTop"in t&&e.setPadding(n.EDGE_TOP,t.paddingTop||0),"paddingBottom"in t&&e.setPadding(n.EDGE_BOTTOM,t.paddingBottom||0)},"applyPaddingStyles"),q=u((e,t)=>{"flexGrow"in t&&e.setFlexGrow(t.flexGrow??0),"flexShrink"in t&&e.setFlexShrink(typeof t.flexShrink=="number"?t.flexShrink:1),"flexWrap"in t&&(t.flexWrap==="nowrap"&&e.setFlexWrap(n.WRAP_NO_WRAP),t.flexWrap==="wrap"&&e.setFlexWrap(n.WRAP_WRAP),t.flexWrap==="wrap-reverse"&&e.setFlexWrap(n.WRAP_WRAP_REVERSE)),"flexDirection"in t&&(t.flexDirection==="row"&&e.setFlexDirection(n.FLEX_DIRECTION_ROW),t.flexDirection==="row-reverse"&&e.setFlexDirection(n.FLEX_DIRECTION_ROW_REVERSE),t.flexDirection==="column"&&e.setFlexDirection(n.FLEX_DIRECTION_COLUMN),t.flexDirection==="column-reverse"&&e.setFlexDirection(n.FLEX_DIRECTION_COLUMN_REVERSE)),"flexBasis"in t&&(typeof t.flexBasis=="number"?e.setFlexBasis(t.flexBasis):typeof t.flexBasis=="string"?e.setFlexBasisPercent(Number.parseInt(t.flexBasis,10)):e.setFlexBasis(Number.NaN)),"alignItems"in t&&((t.alignItems==="stretch"||!t.alignItems)&&e.setAlignItems(n.ALIGN_STRETCH),t.alignItems==="flex-start"&&e.setAlignItems(n.ALIGN_FLEX_START),t.alignItems==="center"&&e.setAlignItems(n.ALIGN_CENTER),t.alignItems==="flex-end"&&e.setAlignItems(n.ALIGN_FLEX_END),t.alignItems==="baseline"&&e.setAlignItems(n.ALIGN_BASELINE)),"alignSelf"in t&&((t.alignSelf==="auto"||!t.alignSelf)&&e.setAlignSelf(n.ALIGN_AUTO),t.alignSelf==="flex-start"&&e.setAlignSelf(n.ALIGN_FLEX_START),t.alignSelf==="center"&&e.setAlignSelf(n.ALIGN_CENTER),t.alignSelf==="flex-end"&&e.setAlignSelf(n.ALIGN_FLEX_END),t.alignSelf==="stretch"&&e.setAlignSelf(n.ALIGN_STRETCH),t.alignSelf==="baseline"&&e.setAlignSelf(n.ALIGN_BASELINE)),"alignContent"in t&&((t.alignContent==="flex-start"||!t.alignContent)&&e.setAlignContent(n.ALIGN_FLEX_START),t.alignContent==="center"&&e.setAlignContent(n.ALIGN_CENTER),t.alignContent==="flex-end"&&e.setAlignContent(n.ALIGN_FLEX_END),t.alignContent==="space-between"&&e.setAlignContent(n.ALIGN_SPACE_BETWEEN),t.alignContent==="space-around"&&e.setAlignContent(n.ALIGN_SPACE_AROUND),t.alignContent==="space-evenly"&&e.setAlignContent(n.ALIGN_SPACE_EVENLY),t.alignContent==="stretch"&&e.setAlignContent(n.ALIGN_STRETCH)),"justifyContent"in t&&((t.justifyContent==="flex-start"||!t.justifyContent)&&e.setJustifyContent(n.JUSTIFY_FLEX_START),t.justifyContent==="center"&&e.setJustifyContent(n.JUSTIFY_CENTER),t.justifyContent==="flex-end"&&e.setJustifyContent(n.JUSTIFY_FLEX_END),t.justifyContent==="space-between"&&e.setJustifyContent(n.JUSTIFY_SPACE_BETWEEN),t.justifyContent==="space-around"&&e.setJustifyContent(n.JUSTIFY_SPACE_AROUND),t.justifyContent==="space-evenly"&&e.setJustifyContent(n.JUSTIFY_SPACE_EVENLY))},"applyFlexStyles"),$=u((e,t)=>{"width"in t&&(typeof t.width=="number"?e.setWidth(t.width):typeof t.width=="string"?e.setWidthPercent(Number.parseInt(t.width,10)):e.setWidthAuto()),"height"in t&&(typeof t.height=="number"?e.setHeight(t.height):typeof t.height=="string"?e.setHeightPercent(Number.parseInt(t.height,10)):e.setHeightAuto()),"minWidth"in t&&(typeof t.minWidth=="string"?e.setMinWidthPercent(Number.parseInt(t.minWidth,10)):e.setMinWidth(t.minWidth??0)),"minHeight"in t&&(typeof t.minHeight=="string"?e.setMinHeightPercent(Number.parseInt(t.minHeight,10)):e.setMinHeight(t.minHeight??0)),"maxWidth"in t&&(typeof t.maxWidth=="string"?e.setMaxWidthPercent(Number.parseInt(t.maxWidth,10)):e.setMaxWidth(t.maxWidth)),"maxHeight"in t&&(typeof t.maxHeight=="string"?e.setMaxHeightPercent(Number.parseInt(t.maxHeight,10)):e.setMaxHeight(t.maxHeight)),"aspectRatio"in t&&e.setAspectRatio(t.aspectRatio)},"applyDimensionStyles"),z=u((e,t)=>{"display"in t&&e.setDisplay(t.display==="flex"?n.DISPLAY_FLEX:n.DISPLAY_NONE)},"applyDisplayStyles"),Z=u((e,t,r)=>{if(!("borderStyle"in t||"borderTop"in t||"borderBottom"in t||"borderLeft"in t||"borderRight"in t))return;const s=r.borderStyle?1:0;e.setBorder(n.EDGE_TOP,r.borderTop===!1?0:s),e.setBorder(n.EDGE_BOTTOM,r.borderBottom===!1?0:s),e.setBorder(n.EDGE_LEFT,r.borderLeft===!1?0:s),e.setBorder(n.EDGE_RIGHT,r.borderRight===!1?0:s)},"applyBorderStyles"),K=u((e,t)=>{"gap"in t&&e.setGap(n.GUTTER_ALL,t.gap??0),"columnGap"in t&&e.setGap(n.GUTTER_COLUMN,t.columnGap??0),"rowGap"in t&&e.setGap(n.GUTTER_ROW,t.rowGap??0)},"applyGapStyles"),Q=u((e,t)=>{const r=t.overflow??"visible",s=t.overflowX??r,l=t.overflowY??r;s==="scroll"||l==="scroll"?e.setOverflow(n.OVERFLOW_SCROLL):s==="hidden"||l==="hidden"?e.setOverflow(n.OVERFLOW_HIDDEN):e.setOverflow(n.OVERFLOW_VISIBLE)},"applyOverflowStyles"),S=u((e,t={},r=t)=>{X(e,t),V(e,t),J(e,t),q(e,t),$(e,t),z(e,t),Z(e,t,r),K(e,t),Q(e,r)},"styles");var ee=Object.defineProperty,c=p((e,t)=>ee(e,"name",{value:t,configurable:!0}),"c");if(A.env.DEV==="true"){let e=!1;try{import.meta.resolve("react-devtools-core"),e=!0}catch{}e&&await import("../packem_chunks/devtools.js")}const x=c((e,t)=>{if(e===t)return;if(!e)return t;const r={};let s=!1;for(const l of Object.keys(e))(!t||!Object.hasOwn(t,l))&&(r[l]=void 0,s=!0);if(t)for(const l of Object.keys(t))t[l]!==e[l]&&(r[l]=t[l],s=!0);return s?r:void 0},"diff"),h=c(e=>{if(e){if(e.yogaNode?.unsetMeasureFunc(),"resizeObservers"in e&&e.resizeObservers?.clear(),"childNodes"in e&&e.childNodes)for(const t of e.childNodes)h(t);e.yogaNode?.free(),"cachedRender"in e&&(e.cachedRender=void 0),"childNodes"in e&&(e.childNodes=[]),e.parentNode=void 0}},"cleanupNodeTree");let m=L,T;async function R(){const e=(await import("node:fs")).readFileSync(new URL("../package.json",import.meta.url),"utf8"),t=JSON.parse(e);return{name:t?.name,version:t?.version}}p(R,"B");c(R,"loadPackageJson");let f={name:"ink",version:O};if(A.env.DEV==="true")try{const e=await R();f={name:e.name||f.name,version:e.version||f.version}}catch(e){console.warn("Failed to load package.json in development mode. Falling back to default renderer metadata.",e)}const de=G({afterActiveInstanceBlur(){},appendChild:g,appendChildToContainer:g,appendInitialChild:g,beforeActiveInstanceBlur(){},cancelCallback:W,cancelTimeout:clearTimeout,clearContainer:c(()=>!1,"clearContainer"),commitTextUpdate(e,t,r){E(e,r)},commitUpdate(e,t,r,s){T&&e.internal_static&&(T.isStaticDirty=!0);const l=x(r,s),a=x(r.style,s.style);if(!l&&!a)return;let i=!!a;if(l){for(const[o,d]of Object.entries(l))if(o!=="children"){if(o==="style"){C(e,d);continue}if(o==="internal_transform"){e.internal_transform=d,i=!0;continue}if(o==="internal_cursor"){e.internal_cursor=d,i=!0;continue}if(o==="internal_static"){e.internal_static=!0,i=!0;continue}if(o==="sticky"){e.internal_sticky=d,i=!0;continue}if(o==="internalStickyAlternate"){e.internal_stickyAlternate=d,i=!0;continue}if(o==="opaque"){e.internal_opaque=d,i=!0;continue}if(o==="scrollbar"){e.internal_scrollbar=d,i=!0;continue}if(o==="internal_terminalCursorFocus"){e.internal_terminalCursorFocus=d,i=!0;continue}if(o==="internal_terminalCursorPosition"){e.internal_terminalCursorPosition=d,i=!0;continue}if(o==="cachedRender"){e.cachedRender=d,i=!0;continue}N(e,o,d),i=!0}}a&&e.yogaNode&&S(e.yogaNode,a,s.style??{}),i&&_(e)},createInstance(e,t,r,s){if(s.isInsideText&&e==="ink-box")throw new Error("<Box> can’t be nested inside <Text> component");if(s.isInsideText&&e==="ink-cursor")throw new Error("<Cursor> can’t be nested inside <Text> component");const l=e==="ink-text"&&s.isInsideText?"ink-virtual-text":e,a=U(l);for(const[i,o]of Object.entries(t))if(i!=="children"){if(i==="style"){C(a,o),a.yogaNode&&S(a.yogaNode,o);continue}if(i==="internal_transform"){a.internal_transform=o;continue}if(i==="internal_cursor"){a.internal_cursor=o;continue}if(i==="internal_static"){T=r,a.internal_static=!0,r.isStaticDirty=!0,r.staticNode=a;continue}if(i==="sticky"){a.internal_sticky=o;continue}if(i==="internalStickyAlternate"){a.internal_stickyAlternate=o;continue}if(i==="opaque"){a.internal_opaque=o;continue}if(i==="scrollbar"){a.internal_scrollbar=o;continue}if(i==="internal_terminalCursorFocus"){a.internal_terminalCursorFocus=o;continue}if(i==="internal_terminalCursorPosition"){a.internal_terminalCursorPosition=o;continue}if(i==="internal_static"){a.internal_static=!0;continue}if(i==="cachedRender"){a.cachedRender=o;continue}N(a,i,o)}return a},createTextInstance(e,t,r){if(!r.isInsideText)throw new Error(`Text string "${e}" must be rendered inside <Text> component`);return H(e)},detachDeletedInstance(){},finalizeInitialChildren(){return!1},getChildHostContext(e,t){const r=e.isInsideText,s=t==="ink-text"||t==="ink-virtual-text";return r===s?e:{isInsideText:s}},getCurrentUpdatePriority:c(()=>m,"getCurrentUpdatePriority"),getInstanceFromNode:c(()=>null,"getInstanceFromNode"),getInstanceFromScope:c(()=>null,"getInstanceFromScope"),getPublicInstance:c(e=>e,"getPublicInstance"),getRootHostContext:c(()=>({isInsideText:!1}),"getRootHostContext"),hideInstance(e){e.internal_hidden=!0,e.yogaNode?.setDisplay(n.DISPLAY_NONE),_(e)},hideTextInstance(e){E(e,"")},HostTransitionContext:F(null),insertBefore:y,insertInContainerBefore:y,isPrimaryRenderer:!0,maySuspendCommit(){return!0},noTimeout:-1,NotPendingTransition:void 0,now:B,preloadInstance(){return!0},prepareForCommit:c(()=>null,"prepareForCommit"),preparePortalMount:c(()=>null,"preparePortalMount"),prepareScopeUpdate(){},removeChild(e,t){I(e,t),h(t)},removeChildFromContainer(e,t){I(e,t),h(t)},rendererPackageName:f.name,rendererVersion:f.version,requestPostPaintCallback(){},resetAfterCommit(e){if(typeof e.onComputeLayout=="function"&&e.onComputeLayout(),M(e),e.staticNode!==e.previousStaticNode&&(e.previousStaticNode=e.staticNode,typeof e.onStaticChange=="function"&&e.onStaticChange()),e.isStaticDirty){e.isStaticDirty=!1,typeof e.onImmediateRender=="function"&&e.onImmediateRender();return}typeof e.onRender=="function"&&e.onRender()},resetFormInstance(){},resetTextContent(){},resolveEventTimeStamp(){return-1.1},resolveEventType(){return null},resolveUpdatePriority(){return m!==L?m:v},scheduleCallback:k,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){m=e},shouldAttemptEagerTransition(){return!1},shouldSetTextContent:c(()=>!1,"shouldSetTextContent"),shouldYield:w,startSuspendingCommit(){},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance(){},trackSchedulerEvent(){},unhideInstance(e){e.internal_hidden=!1,e.yogaNode?.setDisplay(n.DISPLAY_FLEX),_(e)},unhideTextInstance(e,t){E(e,t)},waitForCommitToBeReady(){return null}});export{de as L,S as u};
@@ -1 +1 @@
1
- var y=Object.defineProperty;var c=(e,t)=>y(e,"name",{value:t,configurable:!0});import{createContext as b}from"react";import T from"react-reconciler";import{NoEventPriority as C,DefaultEventPriority as I,DiscreteEventPriority as P}from"react-reconciler/constants.js";import{unstable_shouldYield as k,unstable_scheduleCallback as x,unstable_now as S,unstable_cancelCallback as E}from"scheduler";import{LayoutNode as f}from"./LayoutNode-Q7nU3hmO.js";import{applyStyles as h,resolveColor as g}from"./NAMED_COLORS-B9fJsYdg.js";import{a as N}from"./text-width-DSx26OmB.js";var A=Object.defineProperty,n=c((e,t)=>A(e,"name",{value:t,configurable:!0}),"o");let m=null;function _(e){m=e}c(_,"setOnAfterCommit");n(_,"setOnAfterCommit");let u=C;function p(e){const t=g(e.fg===void 0?e.color===void 0?void 0:e.color:e.fg),o=g(e.bg===void 0?e.backgroundColor===void 0?void 0:e.backgroundColor:e.bg);let r;return e.styles===void 0?(r=0,e.bold&&(r|=1),(e.dim||e.dimColor)&&(r|=2),e.italic&&(r|=4),e.underline&&(r|=8),e.blink&&(r|=16),e.inverse&&(r|=32),e.hidden&&(r|=64),e.strikethrough&&(r|=128)):r=e.styles,{bg:o,fg:t,styles:r}}c(p,"m");n(p,"resolveNodeColors");const U={afterActiveInstanceBlur:n(()=>{},"afterActiveInstanceBlur"),appendChild(e,t){e.insertChild(t,e.children.length)},appendChildToContainer(e,t){e.insertChild(t,e.children.length)},appendInitialChild(e,t){e.insertChild(t,e.children.length)},beforeActiveInstanceBlur:n(()=>{},"beforeActiveInstanceBlur"),cancelCallback:E,cancelTimeout:clearTimeout,clearContainer(e){},commitTextUpdate(e,t,o){e.text=o,e.yogaNode.markDirty()},commitUpdate(e,t,o,r,a){h(e.yogaNode,r);const{bg:i,fg:s,styles:d}=p(r);e.fg=s,e.bg=i,e.styles=d,e._style=r,e.transform=typeof r.transform=="function"?r.transform:void 0},createInstance(e,t,o,r,a){const i=new f,s={...t};s.flexDirection===void 0&&(s.flexDirection="row"),s.flexShrink===void 0&&(s.flexShrink=1),h(i.yogaNode,s);const{bg:d,fg:l,styles:v}=p(t);return i.fg=l,i.bg=d,i.styles=v,i._style=t,typeof t.transform=="function"&&(i.transform=t.transform),i},createTextInstance(e,t,o,r){const a=new f;return a.text=e,a.yogaNode.setWidth(N(e)),a.yogaNode.setHeight(1),a},detachDeletedInstance:n(e=>{e.destroy()},"detachDeletedInstance"),finalizeInitialChildren(e,t,o,r,a){return!1},getChildHostContext(e,t,o){return{isInsideText:t==="text"}},getCurrentEventPriority:n(()=>P,"getCurrentEventPriority"),getCurrentUpdatePriority:n(()=>u,"getCurrentUpdatePriority"),getInstanceFromNode:n(()=>null,"getInstanceFromNode"),getPublicInstance(e){return e},getRootHostContext(e){return{isInsideText:!1}},hideInstance(e){e._hidden=!0},hideTextInstance(e){e._hidden=!0},HostTransitionContext:b(null),insertBefore(e,t,o){t.parent&&t.remove();const r=e.children.indexOf(o);e.insertChild(t,r)},isPrimaryRenderer:!0,maySuspendCommit:n(()=>!0,"maySuspendCommit"),noTimeout:-1,NotPendingTransition:void 0,now:S,preloadInstance:n(()=>!0,"preloadInstance"),prepareForCommit(e){return null},preparePortalMount:n(()=>{},"preparePortalMount"),prepareScopeUpdate:n(()=>{},"prepareScopeUpdate"),prepareUpdate(e,t,o,r,a,i){const s=Object.keys(o).filter(l=>l!=="children"),d=Object.keys(r).filter(l=>l!=="children");if(s.length!==d.length)return!0;for(const l of d)if(o[l]!==r[l])return!0;return null},removeChild(e,t){t.remove()},removeChildFromContainer(e,t){t.remove()},requestPostPaintCallback:n(()=>{},"requestPostPaintCallback"),resetAfterCommit(e){typeof m=="function"&&m()},resolveEventTimeStamp:n(()=>-1.1,"resolveEventTimeStamp"),resolveEventType:n(()=>null,"resolveEventType"),resolveUpdatePriority(){return u!==C?u:I},scheduleCallback:x,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){u=e},shouldAttemptEagerTransition:n(()=>!1,"shouldAttemptEagerTransition"),shouldSetTextContent(e,t){return!1},shouldYield:k,startSuspendingCommit:n(()=>{},"startSuspendingCommit"),supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance:n(()=>{},"suspendInstance"),trackSchedulerEvent:n(()=>{},"trackSchedulerEvent"),unhideInstance(e,t){e._hidden=!1},unhideTextInstance(e,t){e._hidden=!1},waitForCommitToBeReady:n(()=>null,"waitForCommitToBeReady"),warnsIfNotActing:!0},j=T(U);export{j as T,_ as s};
1
+ var y=Object.defineProperty;var c=(e,t)=>y(e,"name",{value:t,configurable:!0});import{createContext as b}from"react";import T from"react-reconciler";import{NoEventPriority as C,DefaultEventPriority as I,DiscreteEventPriority as P}from"react-reconciler/constants.js";import{unstable_shouldYield as k,unstable_scheduleCallback as x,unstable_now as S,unstable_cancelCallback as E}from"scheduler";import{LayoutNode as f}from"./LayoutNode-B8zej4dm.js";import{applyStyles as h,resolveColor as g}from"./NAMED_COLORS-B9fJsYdg.js";import{a as N}from"./text-width-BU2eeTWn.js";var A=Object.defineProperty,n=c((e,t)=>A(e,"name",{value:t,configurable:!0}),"o");let m=null;function _(e){m=e}c(_,"setOnAfterCommit");n(_,"setOnAfterCommit");let u=C;function p(e){const t=g(e.fg===void 0?e.color===void 0?void 0:e.color:e.fg),o=g(e.bg===void 0?e.backgroundColor===void 0?void 0:e.backgroundColor:e.bg);let r;return e.styles===void 0?(r=0,e.bold&&(r|=1),(e.dim||e.dimColor)&&(r|=2),e.italic&&(r|=4),e.underline&&(r|=8),e.blink&&(r|=16),e.inverse&&(r|=32),e.hidden&&(r|=64),e.strikethrough&&(r|=128)):r=e.styles,{bg:o,fg:t,styles:r}}c(p,"m");n(p,"resolveNodeColors");const U={afterActiveInstanceBlur:n(()=>{},"afterActiveInstanceBlur"),appendChild(e,t){e.insertChild(t,e.children.length)},appendChildToContainer(e,t){e.insertChild(t,e.children.length)},appendInitialChild(e,t){e.insertChild(t,e.children.length)},beforeActiveInstanceBlur:n(()=>{},"beforeActiveInstanceBlur"),cancelCallback:E,cancelTimeout:clearTimeout,clearContainer(e){},commitTextUpdate(e,t,o){e.text=o,e.yogaNode.markDirty()},commitUpdate(e,t,o,r,a){h(e.yogaNode,r);const{bg:i,fg:s,styles:d}=p(r);e.fg=s,e.bg=i,e.styles=d,e._style=r,e.transform=typeof r.transform=="function"?r.transform:void 0},createInstance(e,t,o,r,a){const i=new f,s={...t};s.flexDirection===void 0&&(s.flexDirection="row"),s.flexShrink===void 0&&(s.flexShrink=1),h(i.yogaNode,s);const{bg:d,fg:l,styles:v}=p(t);return i.fg=l,i.bg=d,i.styles=v,i._style=t,typeof t.transform=="function"&&(i.transform=t.transform),i},createTextInstance(e,t,o,r){const a=new f;return a.text=e,a.yogaNode.setWidth(N(e)),a.yogaNode.setHeight(1),a},detachDeletedInstance:n(e=>{e.destroy()},"detachDeletedInstance"),finalizeInitialChildren(e,t,o,r,a){return!1},getChildHostContext(e,t,o){return{isInsideText:t==="text"}},getCurrentEventPriority:n(()=>P,"getCurrentEventPriority"),getCurrentUpdatePriority:n(()=>u,"getCurrentUpdatePriority"),getInstanceFromNode:n(()=>null,"getInstanceFromNode"),getPublicInstance(e){return e},getRootHostContext(e){return{isInsideText:!1}},hideInstance(e){e._hidden=!0},hideTextInstance(e){e._hidden=!0},HostTransitionContext:b(null),insertBefore(e,t,o){t.parent&&t.remove();const r=e.children.indexOf(o);e.insertChild(t,r)},isPrimaryRenderer:!0,maySuspendCommit:n(()=>!0,"maySuspendCommit"),noTimeout:-1,NotPendingTransition:void 0,now:S,preloadInstance:n(()=>!0,"preloadInstance"),prepareForCommit(e){return null},preparePortalMount:n(()=>{},"preparePortalMount"),prepareScopeUpdate:n(()=>{},"prepareScopeUpdate"),prepareUpdate(e,t,o,r,a,i){const s=Object.keys(o).filter(l=>l!=="children"),d=Object.keys(r).filter(l=>l!=="children");if(s.length!==d.length)return!0;for(const l of d)if(o[l]!==r[l])return!0;return null},removeChild(e,t){t.remove()},removeChildFromContainer(e,t){t.remove()},requestPostPaintCallback:n(()=>{},"requestPostPaintCallback"),resetAfterCommit(e){typeof m=="function"&&m()},resolveEventTimeStamp:n(()=>-1.1,"resolveEventTimeStamp"),resolveEventType:n(()=>null,"resolveEventType"),resolveUpdatePriority(){return u!==C?u:I},scheduleCallback:x,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){u=e},shouldAttemptEagerTransition:n(()=>!1,"shouldAttemptEagerTransition"),shouldSetTextContent(e,t){return!1},shouldYield:k,startSuspendingCommit:n(()=>{},"startSuspendingCommit"),supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance:n(()=>{},"suspendInstance"),trackSchedulerEvent:n(()=>{},"trackSchedulerEvent"),unhideInstance(e,t){e._hidden=!1},unhideTextInstance(e,t){e._hidden=!1},waitForCommitToBeReady:n(()=>null,"waitForCommitToBeReady"),warnsIfNotActing:!0},j=T(U);export{j as T,_ as s};
@@ -1 +1 @@
1
- var W=Object.defineProperty;var v=(r,s)=>W(r,"name",{value:s,configurable:!0});import l from"react";import{FocusProvider as C,useFocusManager as z}from"./FocusContext-Xy0cwJpO.js";import{TuiContext as T,useInput as B}from"./TuiContext-BoJvG3NN.js";import{LayoutNode as b}from"./LayoutNode-Q7nU3hmO.js";import{T as f,s as P}from"./reconciler-BQvF1kRj.js";import{renderTreeToBuffer as F}from"./renderTreeToBuffer-DWl5_yTW.js";import{TuiApp as j}from"./TuiApp-BSWPFrDu.js";import{InputParser as H}from"./InputParser-Cfi5GVKV.js";import{terminalSize as q}from"./Renderer-DJXooAsp.js";import{createInlineLoop as G}from"./createInlineLoop-fhXU93QT.js";var M=Object.defineProperty,e=v((r,s)=>M(r,"name",{value:s,configurable:!0}),"e");const R=e(r=>l.createElement("box",r,r.children),"_Box"),ee=e(r=>l.createElement("text",r,r.children),"_Text"),te=e(()=>l.createElement(R,{flexGrow:1}),"_Spacer"),L=e(({children:r})=>{const{disableFocus:s,enableFocus:t,focusNext:c,focusPrevious:i}=z();return B((h,a)=>{a.tab&&!a.shift&&c(),a.tab&&a.shift&&i(),a.escape&&(s(),t())}),l.createElement(l.Fragment,null,r)},"TabHandler");function A(r,s){const t=new j,c=new H(process.stdin),i=new b,{height:h,width:a}=t.getSize();i.yogaNode.setWidth(a),i.yogaNode.setHeight(h);const p=f.createContainer(i,0,null,!1,null,"",o=>console.error(o),null),d=e(o=>l.createElement(T.Provider,{value:{app:t,input:c,writeStderr:e(u=>t.writeStderr(u),"writeStderr"),writeStdout:e(u=>t.writeStdout(u),"writeStdout")}},l.createElement(C,null,l.createElement(L,null,o))),"wrap");f.updateContainer(d(r),p,null,()=>{});const x=e((o,u)=>i.calculateLayout(o,u),"calcLayout"),S=e((o,u,_)=>F(i,o,u,_),"renderBuf"),g=e(()=>t.paintNow(x,S),"paintNow");let E=!1;P(()=>{E=!0});const m=Math.round(1e3/(s?.maxFps??60)),y=setInterval(()=>{E&&(E=!1,g())},m);let N;const n=new Promise(o=>{N=o}),w=e(()=>{clearInterval(y),f.updateContainer(null,p,null,()=>{}),i.destroy(),t.stop(),c.stop(),process.off("SIGWINCH",I),N()},"cleanup");c.on("exit",()=>{w(),process.exit(0)}),t.on("quit",()=>{w(),process.exit(0)}),c.start(),t.start();const I=e(()=>{const o=process.stdout.columns||80,u=process.stdout.rows||24;t.resize(o,u),i.yogaNode.setWidth(o),i.yogaNode.setHeight(u),t.emit("resize"),g()},"onSigwinch");return process.on("SIGWINCH",I),g(),{app:t,input:c,rerender(o){f.updateContainer(d(o),p,null,()=>{})},unmount(){w()},waitUntilExit(){return n}}}v(A,"render");e(A,"render");function O(r,s){const t=q(),c=s?.rows??10,{cols:i}=t,h=Math.min(c,t.rows),a=new H(process.stdin),p=new b;p.yogaNode.setWidth(i),p.yogaNode.setHeight(h);const d=[],x=[],S={quit:e(()=>m.stop(),"quit"),writeStderr:e(n=>x.push(n),"writeStderr"),writeStdout:e(n=>d.push(n),"writeStdout")},g=f.createContainer(p,0,null,!1,null,"",n=>console.error(n),null),E=e(n=>l.createElement(T.Provider,{value:{app:S,input:a,writeStderr:S.writeStderr,writeStdout:S.writeStdout}},l.createElement(C,null,l.createElement(L,null,n))),"wrap");f.updateContainer(E(r),g,null,()=>{}),P(()=>{});const m=G((n,w,I)=>{p.calculateLayout(w,I),F(p,n,w,I)},{...s,fps:s?.maxFps??s?.fps??60,rows:h});a.on("exit",()=>m.stop());let y;const N=new Promise(n=>{y=n});return process.on("exit",()=>{d.length>0&&process.stdout.write(d.join("")),x.length>0&&process.stderr.write(x.join("")),y()}),m.start(),a.start(),{unmount(){m.stop()},waitUntilExit(){return N}}}v(O,"renderInline");e(O,"renderInline");export{R as _Box,te as _Spacer,ee as _Text,A as render,O as renderInline};
1
+ var W=Object.defineProperty;var v=(r,s)=>W(r,"name",{value:s,configurable:!0});import l from"react";import{FocusProvider as C,useFocusManager as z}from"./FocusContext-Xy0cwJpO.js";import{TuiContext as T,useInput as B}from"./TuiContext-BoJvG3NN.js";import{LayoutNode as b}from"./LayoutNode-B8zej4dm.js";import{T as f,s as P}from"./reconciler-DIfG72R9.js";import{renderTreeToBuffer as F}from"./renderTreeToBuffer-CZilzyhN.js";import{TuiApp as j}from"./TuiApp-BVDXP0Cv.js";import{InputParser as H}from"./InputParser-B_qZcN3r.js";import{terminalSize as q}from"./Renderer-DJXooAsp.js";import{createInlineLoop as G}from"./createInlineLoop-DRNZ7jqH.js";var M=Object.defineProperty,e=v((r,s)=>M(r,"name",{value:s,configurable:!0}),"e");const R=e(r=>l.createElement("box",r,r.children),"_Box"),ee=e(r=>l.createElement("text",r,r.children),"_Text"),te=e(()=>l.createElement(R,{flexGrow:1}),"_Spacer"),L=e(({children:r})=>{const{disableFocus:s,enableFocus:t,focusNext:c,focusPrevious:i}=z();return B((h,a)=>{a.tab&&!a.shift&&c(),a.tab&&a.shift&&i(),a.escape&&(s(),t())}),l.createElement(l.Fragment,null,r)},"TabHandler");function A(r,s){const t=new j,c=new H(process.stdin),i=new b,{height:h,width:a}=t.getSize();i.yogaNode.setWidth(a),i.yogaNode.setHeight(h);const p=f.createContainer(i,0,null,!1,null,"",o=>console.error(o),null),d=e(o=>l.createElement(T.Provider,{value:{app:t,input:c,writeStderr:e(u=>t.writeStderr(u),"writeStderr"),writeStdout:e(u=>t.writeStdout(u),"writeStdout")}},l.createElement(C,null,l.createElement(L,null,o))),"wrap");f.updateContainer(d(r),p,null,()=>{});const x=e((o,u)=>i.calculateLayout(o,u),"calcLayout"),S=e((o,u,_)=>F(i,o,u,_),"renderBuf"),g=e(()=>t.paintNow(x,S),"paintNow");let E=!1;P(()=>{E=!0});const m=Math.round(1e3/(s?.maxFps??60)),y=setInterval(()=>{E&&(E=!1,g())},m);let N;const n=new Promise(o=>{N=o}),w=e(()=>{clearInterval(y),f.updateContainer(null,p,null,()=>{}),i.destroy(),t.stop(),c.stop(),process.off("SIGWINCH",I),N()},"cleanup");c.on("exit",()=>{w(),process.exit(0)}),t.on("quit",()=>{w(),process.exit(0)}),c.start(),t.start();const I=e(()=>{const o=process.stdout.columns||80,u=process.stdout.rows||24;t.resize(o,u),i.yogaNode.setWidth(o),i.yogaNode.setHeight(u),t.emit("resize"),g()},"onSigwinch");return process.on("SIGWINCH",I),g(),{app:t,input:c,rerender(o){f.updateContainer(d(o),p,null,()=>{})},unmount(){w()},waitUntilExit(){return n}}}v(A,"render");e(A,"render");function O(r,s){const t=q(),c=s?.rows??10,{cols:i}=t,h=Math.min(c,t.rows),a=new H(process.stdin),p=new b;p.yogaNode.setWidth(i),p.yogaNode.setHeight(h);const d=[],x=[],S={quit:e(()=>m.stop(),"quit"),writeStderr:e(n=>x.push(n),"writeStderr"),writeStdout:e(n=>d.push(n),"writeStdout")},g=f.createContainer(p,0,null,!1,null,"",n=>console.error(n),null),E=e(n=>l.createElement(T.Provider,{value:{app:S,input:a,writeStderr:S.writeStderr,writeStdout:S.writeStdout}},l.createElement(C,null,l.createElement(L,null,n))),"wrap");f.updateContainer(E(r),g,null,()=>{}),P(()=>{});const m=G((n,w,I)=>{p.calculateLayout(w,I),F(p,n,w,I)},{...s,fps:s?.maxFps??s?.fps??60,rows:h});a.on("exit",()=>m.stop());let y;const N=new Promise(n=>{y=n});return process.on("exit",()=>{d.length>0&&process.stdout.write(d.join("")),x.length>0&&process.stderr.write(x.join("")),y()}),m.start(),a.start(),{unmount(){m.stop()},waitUntilExit(){return N}}}v(O,"renderInline");e(O,"renderInline");export{R as _Box,te as _Spacer,ee as _Text,A as render,O as renderInline};