@visulima/tui 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE.md +130 -1
  3. package/dist/components/box.d.ts +735 -3
  4. package/dist/components/box.js +1 -1
  5. package/dist/components/canvas.js +1 -1
  6. package/dist/components/cursor.d.ts +2 -3
  7. package/dist/components/cursor.js +1 -1
  8. package/dist/components/error-overview.js +1 -1
  9. package/dist/components/spacer.js +1 -1
  10. package/dist/components/static-render.d.ts +2 -3
  11. package/dist/components/static-render.js +1 -1
  12. package/dist/components/static.d.ts +1 -3
  13. package/dist/components/static.js +1 -1
  14. package/dist/components/text.d.ts +1 -3
  15. package/dist/components/text.js +1 -1
  16. package/dist/components/transform.js +1 -1
  17. package/dist/core/index.js +1 -1
  18. package/dist/ink/canvas/index.d.ts +14 -1
  19. package/dist/ink/canvas/index.js +1 -1
  20. package/dist/ink/hooks/use-animation.js +1 -1
  21. package/dist/ink/hooks/use-app.d.ts +1 -2
  22. package/dist/ink/hooks/use-app.js +1 -1
  23. package/dist/ink/hooks/use-box-metrics.d.ts +2 -3
  24. package/dist/ink/hooks/use-box-metrics.js +1 -1
  25. package/dist/ink/hooks/use-clipboard.js +1 -1
  26. package/dist/ink/hooks/use-color-blindness.js +1 -1
  27. package/dist/ink/hooks/use-console-capture.js +1 -1
  28. package/dist/ink/hooks/use-cursor.d.ts +0 -1
  29. package/dist/ink/hooks/use-cursor.js +1 -1
  30. package/dist/ink/hooks/use-focus-manager.d.ts +0 -1
  31. package/dist/ink/hooks/use-focus-manager.js +1 -1
  32. package/dist/ink/hooks/use-focus.js +1 -1
  33. package/dist/ink/hooks/use-form.js +1 -1
  34. package/dist/ink/hooks/use-hotkey.js +1 -1
  35. package/dist/ink/hooks/use-input.js +2 -2
  36. package/dist/ink/hooks/use-interval.js +1 -1
  37. package/dist/ink/hooks/use-key-bindings.js +1 -1
  38. package/dist/ink/hooks/use-key-chord.js +1 -1
  39. package/dist/ink/hooks/use-paste.js +1 -1
  40. package/dist/ink/hooks/use-persistent-state.js +2 -2
  41. package/dist/ink/hooks/use-scroll-acceleration.js +1 -1
  42. package/dist/ink/hooks/use-scroll-input.js +1 -1
  43. package/dist/ink/hooks/use-stderr.d.ts +0 -1
  44. package/dist/ink/hooks/use-stderr.js +1 -1
  45. package/dist/ink/hooks/use-stdin.d.ts +0 -1
  46. package/dist/ink/hooks/use-stdin.js +1 -1
  47. package/dist/ink/hooks/use-stdout.d.ts +0 -1
  48. package/dist/ink/hooks/use-stdout.js +1 -1
  49. package/dist/ink/hooks/use-stopwatch.js +1 -1
  50. package/dist/ink/hooks/use-terminal-palette.d.ts +1 -1
  51. package/dist/ink/hooks/use-terminal-palette.js +1 -1
  52. package/dist/ink/hooks/use-text-buffer.js +4 -4
  53. package/dist/ink/hooks/use-text-selection.d.ts +3 -4
  54. package/dist/ink/hooks/use-text-selection.js +1 -1
  55. package/dist/ink/hooks/use-timeout.js +1 -1
  56. package/dist/ink/hooks/use-timer.js +1 -1
  57. package/dist/ink/hooks/use-window-size.js +1 -1
  58. package/dist/ink/index.d.ts +23 -15
  59. package/dist/ink/index.js +1 -1
  60. package/dist/ink/mouse/use-element-position.d.ts +2 -3
  61. package/dist/ink/mouse/use-element-position.js +1 -1
  62. package/dist/ink/mouse/use-mouse-action.d.ts +1 -2
  63. package/dist/ink/mouse/use-mouse-action.js +1 -1
  64. package/dist/ink/mouse/use-mouse-position.d.ts +1 -2
  65. package/dist/ink/mouse/use-mouse-position.js +1 -1
  66. package/dist/ink/mouse/use-mouse.d.ts +1 -2
  67. package/dist/ink/mouse/use-mouse.js +1 -1
  68. package/dist/ink/mouse/use-on-mouse-click.d.ts +3 -4
  69. package/dist/ink/mouse/use-on-mouse-click.js +1 -1
  70. package/dist/ink/mouse/use-on-mouse-hover.d.ts +2 -3
  71. package/dist/ink/mouse/use-on-mouse-hover.js +1 -1
  72. package/dist/ink/mouse/use-on-mouse-state.d.ts +2 -3
  73. package/dist/ink/mouse/use-on-mouse-state.js +1 -1
  74. package/dist/ink/public/cursor.d.ts +22 -1
  75. package/dist/ink/public/cursor.js +1 -1
  76. package/dist/ink/public/dom.d.ts +2 -3
  77. package/dist/ink/public/highlighter.d.ts +49 -3
  78. package/dist/ink/public/highlighter.js +1 -1
  79. package/dist/ink/public/input.d.ts +19 -1
  80. package/dist/ink/public/styles.d.ts +1 -3
  81. package/dist/ink/public/utils.d.ts +8 -1
  82. package/dist/ink/public/utils.js +1 -1
  83. package/dist/packem_shared/COLOR_BLINDNESS_COMPENSATION-CaI93Rjj.js +1 -0
  84. package/dist/packem_shared/Cell-CbDQUAjW.js +1 -0
  85. package/dist/packem_shared/DevTools-DKYxA_wO.js +1 -0
  86. package/dist/packem_shared/FocusContext-mWFBWdli.js +1 -0
  87. package/dist/packem_shared/Fullscreen-DKKMVbkg.js +1 -0
  88. package/dist/packem_shared/{IMECompositionBuffer-VhC9HRCv.js → IMECompositionBuffer-uYiAz3jI.js} +1 -1
  89. package/dist/packem_shared/{InputParser-CUAGWKQQ.js → InputParser-O4nyWUuQ.js} +2 -2
  90. package/dist/packem_shared/{KEY-C--kOw41.js → KEY-DGV_trPu.js} +1 -1
  91. package/dist/packem_shared/LayoutNode-D4i45GQM.js +1 -0
  92. package/dist/packem_shared/MouseProvider-BSTuFqG9.js +1 -0
  93. package/dist/packem_shared/NAMED_COLORS-DvfPALxN.js +1 -0
  94. package/dist/packem_shared/Range-CMqYzhij.js +1 -0
  95. package/dist/packem_shared/Renderer-Dg5_-6TF.js +1 -0
  96. package/dist/packem_shared/ResizeObserver-ClWoCtGV.js +1 -0
  97. package/dist/packem_shared/Static-sqw4n2Fv.js +1 -0
  98. package/dist/packem_shared/{TuiApp-CCVaiKbf.js → TuiApp-D1How6sn.js} +1 -1
  99. package/dist/packem_shared/TuiContext-Bbq9JRCu.js +3 -0
  100. package/dist/packem_shared/animation-context-Icwf5tBE.js +1 -0
  101. package/dist/packem_shared/ansi-parser-CysVDsNz.js +1 -0
  102. package/dist/packem_shared/ansi-tokenizer-D5k5LzXg.js +1 -0
  103. package/dist/packem_shared/{app-context-DTm1_XBA.js → app-context-CfgsW0CV.js} +1 -1
  104. package/dist/packem_shared/{app-context.d-DMLw5Nxy.d.ts → app-context.d-DAF6oxKX.d.ts} +0 -1
  105. package/dist/packem_shared/{boxes-DyY_LXCi.js → boxes-CidWUOVk.js} +1 -1
  106. package/dist/packem_shared/buildCursorOnlySequence-D24o0D7-.js +1 -0
  107. package/dist/packem_shared/calculateScroll-jdxVlcmq.js +1 -0
  108. package/dist/packem_shared/calculateScrollbarLayout-DCVwJ0Cl.js +1 -0
  109. package/dist/packem_shared/clearOsc52-olbKg5Nw.js +1 -0
  110. package/dist/packem_shared/clearStringWidthCache-EWeHQcEb.js +1 -0
  111. package/dist/packem_shared/colorize-Dsbi0Wr0.js +1 -0
  112. package/dist/packem_shared/createBrailleGrid-B5uefhi4.js +1 -0
  113. package/dist/packem_shared/createCanvasBuffer-C7w6bGe4.js +1 -0
  114. package/dist/packem_shared/createInlineLoop-BPlBAXqd.js +2 -0
  115. package/dist/packem_shared/createScreen-BBvF-ZyU.js +3 -0
  116. package/dist/packem_shared/cursor-context-wLwblh2o.js +1 -0
  117. package/dist/packem_shared/{disposeHighlighter-D9OkrhwX.js → disposeHighlighter-BS4lDPP8.js} +1 -1
  118. package/dist/packem_shared/dom-xpeZzKuf.js +1 -0
  119. package/dist/packem_shared/{dom.d-CLGlidfI.d.ts → dom.d-BV2bnRcH.d.ts} +2 -3
  120. package/dist/packem_shared/{focus-context-CsT69klR.js → focus-context-8h3hmNxy.js} +1 -1
  121. package/dist/packem_shared/formatDuration-DcLMLZro.js +1 -0
  122. package/dist/packem_shared/getPathToRoot-DBqZKIzf.js +1 -0
  123. package/dist/packem_shared/index-7Qq5uu0d.js +75 -0
  124. package/dist/packem_shared/isIntersecting-C8tJIsvH.js +1 -0
  125. package/dist/packem_shared/isTerminalPaletteQuerySupported-X6YXYjSp.js +1 -0
  126. package/dist/packem_shared/kittyFlags-jpd_IAFL.js +1 -0
  127. package/dist/packem_shared/load-native-root-binding-B1WunHs4.js +1 -0
  128. package/dist/packem_shared/measure-element-pHwUPovG.js +1 -0
  129. package/dist/packem_shared/measure-text-DtlK6gar.js +3 -0
  130. package/dist/packem_shared/mouse-context-BEnaR3tG.js +1 -0
  131. package/dist/packem_shared/{mouse-context.d-W-nszUps.d.ts → mouse-context.d-5TGeZyIF.d.ts} +1 -2
  132. package/dist/packem_shared/parseSgrMouse-CHYo9gs6.js +1 -0
  133. package/dist/packem_shared/probe-terminal-mMqobBjP.js +1 -0
  134. package/dist/packem_shared/processLayout-DYdx6C3A.js +2 -0
  135. package/dist/packem_shared/reconciler-BPm7fZa6.js +1 -0
  136. package/dist/packem_shared/reconciler-DXp9qy6k.js +1 -0
  137. package/dist/packem_shared/render-B_NqU7AH.js +1 -0
  138. package/dist/packem_shared/render-DGiSemZa.js +22 -0
  139. package/dist/packem_shared/{render.d-DjQhFsiN.d.ts → render.d-tqP_-Le_.d.ts} +43 -43
  140. package/dist/packem_shared/renderToString-BLr8QvYq.js +2 -0
  141. package/dist/packem_shared/renderToString-D66vRHLQ.js +4 -0
  142. package/dist/packem_shared/renderToken-DFWLdYz_.js +1 -0
  143. package/dist/packem_shared/renderTreeToBuffer-MEHvKJc-.js +2 -0
  144. package/dist/packem_shared/renderer-D97BmOBO.js +17 -0
  145. package/dist/packem_shared/{selection.d-BSAWa4ey.d.ts → selection.d-DCMpXtpU.d.ts} +1 -1
  146. package/dist/packem_shared/squashTextNodesWithMap-CUJZZeW3.js +1 -0
  147. package/dist/packem_shared/stderr-context-Xeacf3Ir.js +1 -0
  148. package/dist/packem_shared/stdin-context-Ceh-YuU1.js +1 -0
  149. package/dist/packem_shared/stdout-context-BhxOwdNK.js +1 -0
  150. package/dist/packem_shared/{styles.d-CKGQFfm4.d.ts → styles.d-BCZOPl_g.d.ts} +37 -3
  151. package/dist/packem_shared/terminal-palette.d-DSgSpnMs.d.ts +44 -0
  152. package/dist/packem_shared/text-width-BXmBaLDv.js +2 -0
  153. package/dist/packem_shared/utils-BlDbvbdr.js +1 -0
  154. package/dist/packem_shared/waitFor-BjdYqkin.js +4 -0
  155. package/dist/packem_shared/wrapOrTruncateStyledLine-Gm21gYDr.js +3 -0
  156. package/dist/react/index.d.ts +1 -1
  157. package/dist/react/index.js +1 -1
  158. package/dist/testing/index.d.ts +4 -6
  159. package/dist/testing/index.js +1 -1
  160. package/index.js +26 -26
  161. package/package.json +13 -13
  162. package/dist/packem_shared/COLOR_BLINDNESS_COMPENSATION-Ilnoyeqc.js +0 -1
  163. package/dist/packem_shared/Cell-BrXn3jxY.js +0 -1
  164. package/dist/packem_shared/DevTools-CZ-O0Ckm.js +0 -1
  165. package/dist/packem_shared/FocusContext-BWFqf9kb.js +0 -1
  166. package/dist/packem_shared/Fullscreen-BRhuBLBh.js +0 -1
  167. package/dist/packem_shared/LayoutNode-LPYsuzBg.js +0 -1
  168. package/dist/packem_shared/MouseProvider-DOcWCRVq.js +0 -1
  169. package/dist/packem_shared/NAMED_COLORS-82DpREQV.js +0 -1
  170. package/dist/packem_shared/Range-BsVYNWtg.js +0 -1
  171. package/dist/packem_shared/Renderer-BeS49FNq.js +0 -1
  172. package/dist/packem_shared/ResizeObserver-BI9bDy-j.js +0 -1
  173. package/dist/packem_shared/Static-DSzsElz4.js +0 -1
  174. package/dist/packem_shared/TuiContext-BNmP0lMY.js +0 -3
  175. package/dist/packem_shared/animation-context-DW3p-vpk.js +0 -1
  176. package/dist/packem_shared/ansi-parser-DlgLtOYO.js +0 -1
  177. package/dist/packem_shared/ansi-tokenizer-BU67A126.js +0 -1
  178. package/dist/packem_shared/buildCursorOnlySequence-CerkmjWt.js +0 -1
  179. package/dist/packem_shared/calculateScroll-D4Y_JR4H.js +0 -1
  180. package/dist/packem_shared/calculateScrollbarLayout-Lf6i24c9.js +0 -1
  181. package/dist/packem_shared/clearOsc52-BUpnQOav.js +0 -1
  182. package/dist/packem_shared/clearStringWidthCache-DKFjfJuB.js +0 -1
  183. package/dist/packem_shared/colorize-DU4YZkp3.js +0 -1
  184. package/dist/packem_shared/createBrailleGrid-BTOQrujS.js +0 -1
  185. package/dist/packem_shared/createCanvasBuffer-CL6sAM-A.js +0 -1
  186. package/dist/packem_shared/createInlineLoop-BMDYJkRp.js +0 -2
  187. package/dist/packem_shared/createScreen-DoYpyL0V.js +0 -3
  188. package/dist/packem_shared/cursor-context-CFviBqPX.js +0 -1
  189. package/dist/packem_shared/dom-rphpG0kf.js +0 -1
  190. package/dist/packem_shared/formatDuration-Bdx4ZgRh.js +0 -1
  191. package/dist/packem_shared/getPathToRoot-PDJeqiEH.js +0 -1
  192. package/dist/packem_shared/index-Dl9I2_QH.js +0 -75
  193. package/dist/packem_shared/isIntersecting-Bo2npvMR.js +0 -1
  194. package/dist/packem_shared/isTerminalPaletteQuerySupported-BYzmqq9-.js +0 -1
  195. package/dist/packem_shared/kittyFlags-g8ALyoCU.js +0 -1
  196. package/dist/packem_shared/load-native-root-binding-CxJnHcac.js +0 -1
  197. package/dist/packem_shared/measure-element-D4M9iSYp.js +0 -1
  198. package/dist/packem_shared/measure-text-B7juNq4Y.js +0 -3
  199. package/dist/packem_shared/mouse-context-DaARgUu1.js +0 -1
  200. package/dist/packem_shared/parseSgrMouse-bUrqPrh-.js +0 -1
  201. package/dist/packem_shared/processLayout-I83k6vXE.js +0 -2
  202. package/dist/packem_shared/reconciler-D4fi5NfR.js +0 -1
  203. package/dist/packem_shared/reconciler-DkwOtC5B.js +0 -1
  204. package/dist/packem_shared/render-CPVY5vpQ.js +0 -1
  205. package/dist/packem_shared/render-CvhjGwOg.js +0 -24
  206. package/dist/packem_shared/renderToString-B1LgWcJe.js +0 -4
  207. package/dist/packem_shared/renderToString-Df6HST7u.js +0 -2
  208. package/dist/packem_shared/renderToken-DjiQ6dfv.js +0 -1
  209. package/dist/packem_shared/renderTreeToBuffer-BpSD0sBJ.js +0 -2
  210. package/dist/packem_shared/renderer-Cs0KEr1o.js +0 -17
  211. package/dist/packem_shared/squashTextNodesWithMap-BmUSBPfc.js +0 -1
  212. package/dist/packem_shared/stderr-context-CR2LLec6.js +0 -1
  213. package/dist/packem_shared/stdin-context-BjMA9Sbi.js +0 -1
  214. package/dist/packem_shared/stdout-context-DAAlQct2.js +0 -1
  215. package/dist/packem_shared/terminal-palette.d-JbWHISW-.d.ts +0 -19
  216. package/dist/packem_shared/text-width-e49vlbQH.js +0 -2
  217. package/dist/packem_shared/utils-CVgM8kTn.js +0 -1
  218. package/dist/packem_shared/waitFor-CTAki32d.js +0 -4
  219. package/dist/packem_shared/wrapOrTruncateStyledLine-46W8bTtv.js +0 -3
@@ -0,0 +1,22 @@
1
+ import{createRequire as Fe}from"node:module";import{jsx as L}from"react/jsx-runtime";import{cursorShow as ft,setMode as le,BracketedPasteMode as de,resetMode as he,eraseLines as st,cursorHide as Rt,cursorUp as Vt,cursorNextLine as We,cursorTo as Ae,eraseLineEnd as Ue,createDecMode as He,ALT_SCREEN_ON as $t,clearScreenAndHomeCursor as Ke,ALT_SCREEN_OFF as Qt}from"@visulima/ansi";import{wordWrap as Ge}from"@visulima/string";import{ConcurrentRoot as Ye,LegacyRoot as qe}from"react-reconciler/constants.js";import M from"yoga-layout";import{a as je}from"./accessibility-context-DDyHTwmA.js";import{useState as ct,useRef as C,useCallback as v,useEffect as lt,useMemo as A}from"react";import{a as Ve}from"./animation-context-Icwf5tBE.js";import{A as $e}from"./app-context-CfgsW0CV.js";import{C as Qe}from"./cursor-context-wLwblh2o.js";import Xe from"../components/error-boundary.js";import{F as Ze}from"./focus-context-8h3hmNxy.js";import{S as Je}from"./stderr-context-Xeacf3Ir.js";import{S as ti}from"./stdin-context-Ceh-YuU1.js";import{S as ei}from"./stdout-context-BhxOwdNK.js";import{O as ii,a as si,b as ni,r as ri}from"./renderer-D97BmOBO.js";import{c as oi,e as ai}from"./dom-xpeZzKuf.js";import{resolveFlags as Xt}from"./kittyFlags-jpd_IAFL.js";import{buildReturnToBottomPrefix as Zt,buildCursorSuffix as Et,cursorPositionChanged as Jt,buildCursorOnlySequence as ui,buildCursorShapeSequence as te}from"./buildCursorOnlySequence-D24o0D7-.js";import{l as ci}from"./load-native-root-binding-B1WunHs4.js";import{a as li}from"./measure-text-DtlK6gar.js";import{r as di}from"./probe-terminal-mMqobBjP.js";import{r as I,s as hi}from"./reconciler-BPm7fZa6.js";import{measureAndExtractObservers as fi}from"./ResizeObserver-ClWoCtGV.js";import{calculateScroll as pi}from"./calculateScroll-jdxVlcmq.js";import{g as q}from"./utils-BlDbvbdr.js";let Me;const Be=i=>(Me??=Fe(import.meta.url))(i),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,mt=i=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[t,e]=V.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return V.getBuiltinModule(i)}return Be(i)},E=V,{env:vt}=E,{PassThrough:jt,Stream:De}=mt("node:stream"),{Buffer:zt}=mt("node:buffer"),{Console:_e}=mt("node:console"),{EventEmitter:ze}=mt("node:events"),ee=i=>i in vt&&vt[i]!=="0"&&vt[i]!=="false",fe=ee("CI")||ee("CONTINUOUS_INTEGRATION"),ie=["assert","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"];let bt={};const mi=i=>{const t=new jt,e=new jt;t.write=n=>{i("stdout",n)},e.write=n=>{i("stderr",n)};const s=new console.Console(t,e);for(const n of ie)bt[n]=console[n],console[n]=s[n];return()=>{for(const n of ie)console[n]=bt[n];bt={}}},$=[];$.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&$.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&$.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const ht=i=>!!i&&!0&&typeof i.removeListener=="function"&&typeof i.emit=="function"&&typeof i.reallyExit=="function"&&typeof i.listeners=="function"&&typeof i.kill=="function"&&typeof i.pid=="number"&&typeof i.on=="function",yt=Symbol.for("signal-exit emitter"),wt=globalThis,gi=Object.defineProperty.bind(Object);class vi{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(wt[yt])return wt[yt];gi(wt,yt,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,e){this.listeners[t].push(e)}removeListener(t,e){const s=this.listeners[t],n=s.indexOf(e);n!==-1&&(n===0&&s.length===1?s.length=0:s.splice(n,1))}emit(t,e,s){if(this.emitted[t])return!1;this.emitted[t]=!0;let n=!1;for(const r of this.listeners[t])n=r(e,s)===!0||n;return t==="exit"&&(n=this.emit("afterExit",e,s)||n),n}}class pe{}const bi=i=>({onExit(t,e){return i.onExit(t,e)},load(){return i.load()},unload(){return i.unload()}});class yi extends pe{onExit(){return()=>{}}load(){}unload(){}}class wi extends pe{#o=Tt.platform==="win32"?"SIGINT":"SIGHUP";#e=new vi;#t;#n;#r;#s={};#i=!1;constructor(t){super(),this.#t=t,this.#s={};for(const e of $)this.#s[e]=()=>{const s=this.#t.listeners(e);let{count:n}=this.#e;const r=t;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(n+=r.__signal_exit_emitter__.count),s.length===n){this.unload();const u=this.#e.emit("exit",null,e),o=e==="SIGHUP"?this.#o:e;u||t.kill(t.pid,o)}};this.#r=t.reallyExit,this.#n=t.emit}onExit(t,e){if(!ht(this.#t))return()=>{};this.#i===!1&&this.load();const s=e?.alwaysLast?"afterExit":"exit";return this.#e.on(s,t),()=>{this.#e.removeListener(s,t),this.#e.listeners.exit.length===0&&this.#e.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#i){this.#i=!0,this.#e.count+=1;for(const t of $)try{const e=this.#s[t];e&&this.#t.on(t,e)}catch{}this.#t.emit=(t,...e)=>this.#u(t,...e),this.#t.reallyExit=t=>this.#a(t)}}unload(){this.#i&&(this.#i=!1,$.forEach(t=>{const e=this.#s[t];if(!e)throw new Error("Listener not defined for signal: "+t);try{this.#t.removeListener(t,e)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#r,this.#e.count-=1)}#a(t){return ht(this.#t)?(this.#t.exitCode=t||0,this.#e.emit("exit",this.#t.exitCode,null),this.#r.call(this.#t,this.#t.exitCode)):0}#u(t,...e){const s=this.#n;if(t==="exit"&&ht(this.#t)){typeof e[0]=="number"&&(this.#t.exitCode=e[0]);const n=s.call(this.#t,t,...e);return this.#e.emit("exit",this.#t.exitCode,null),n}else return s.call(this.#t,t,...e)}}const Tt=globalThis.process,{onExit:Si}=bi(ht(Tt)?new wi(Tt):new yi),pt="\x1B",me="\x1B[200~",se="\x1B[201~",xi=i=>i>=48&&i<=63,Ri=i=>i>=32&&i<=47,ge=i=>i>=64&&i<=126,Ti=(i,t,e)=>{const s=t+e+1;let n=s;for(;n<i.length;n++){const r=i.codePointAt(n);if(r===void 0)return"pending";if(!(xi(r)||Ri(r))&&!(r===91&&n===s))return ge(r)?{nextIndex:n+1,sequence:i.slice(t,n+1)}:void 0}return"pending"},Ci=(i,t,e)=>{const s=t+e+2;if(s>i.length)return"pending";const n=i.codePointAt(s-1);if(!(n===void 0||!ge(n)))return{nextIndex:s,sequence:i.slice(t,s)}},ne=(i,t,e)=>{const s=i[t+e];if(s===void 0)return"pending";if(s==="[")return Ti(i,t,e);if(s==="O")return Ci(i,t,e)},Ei=(i,t)=>{const e=i.codePointAt(t+1),s=e!==void 0&&e>65535?2:1,n=t+1+s;return{nextIndex:n,sequence:i.slice(t,n)}},Pi=(i,t)=>{if(t===i.length-1)return"pending";if(i[t+1]===pt){if(t+2>=i.length)return"pending";const n=ne(i,t,2);return n==="pending"?"pending":n||{nextIndex:t+2,sequence:i.slice(t,t+2)}}const s=ne(i,t,1);return s==="pending"?"pending":s||Ei(i,t)},re=(i,t)=>{let e=0;for(let s=0;s<i.length;s++){const n=i[s];(n===""||n==="\b")&&(s>e&&t.push(i.slice(e,s)),t.push(n),e=s+1)}e<i.length&&t.push(i.slice(e))},Oi=i=>{const t=[];let e=0;const s=n=>({events:t,pending:i.slice(n)});for(;e<i.length;){const n=i.indexOf(pt,e);if(n===-1)return re(i.slice(e),t),{events:t,pending:""};n>e&&re(i.slice(e,n),t);const r=Pi(i,n);if(r==="pending")return s(n);if(r.sequence===me){const u=r.nextIndex,o=i.indexOf(se,u);if(o===-1)return s(n);t.push({paste:i.slice(u,o)}),e=o+se.length;continue}t.push(r.sequence),e=r.nextIndex}return{events:t,pending:""}},Ii=()=>{let i="";return{flushPendingEscape(){if(!i.startsWith(pt))return;const t=i;return i="",t},hasPendingEscape(){return i.startsWith(pt)&&!i.startsWith(me)&&i!=="\x1B[200"},push(t){const e=Oi(i+t);return i=e.pending,e.events},reset(){i=""}}},Ni=" ",ki="\x1B[Z",Li="\x1B",oe=le(de),St=he(de),ve=({children:i,exitOnCtrlC:t,interactive:e,onExit:s,onRegisterInputControl:n,onSuspendTerminal:r,onWaitUntilRenderFlush:u,renderThrottleMs:o,setCursorPosition:d,stderr:l,stdin:c,stdout:h,writeToStderr:y,writeToStdout:S})=>{const[m,b]=ct(!0),[g,w]=ct(void 0),[,P]=ct([]),O=C(0),T=C([]),B=C(new Map),Q=C(void 0),D=C(0),F=C(!1),W=C(0),[N]=ct(()=>{const a=new ze;return a.setMaxListeners(1/0),a}),X=C(void 0),Z=C(void 0);Z.current??=Ii();const J=C(void 0),Pt=C(!1),Re=20,H=v(()=>{J.current&&(clearTimeout(J.current),J.current=void 0)},[]),K=v(()=>{Q.current&&(clearTimeout(Q.current),Q.current=void 0)},[]),rt=v(()=>{if(K(),B.current.size===0)return;let a=Number.POSITIVE_INFINITY;for(const f of B.current.values())a=Math.min(a,f.nextDueTime);const p=Math.max(0,a-performance.now());Q.current=setTimeout(()=>{Q.current=void 0;const f=performance.now(),x=[...B.current.values()];for(const R of x){if(f<R.nextDueTime)continue;R.callback(f);const ke=f-R.startTime,Le=Math.floor(ke/R.interval)+1;R.nextDueTime=R.startTime+Le*R.interval}rt()},p)},[K]),Ot=v((a,p)=>{const f=performance.now();return B.current.set(a,{callback:a,interval:p,nextDueTime:f+p,startTime:f}),rt(),{startTime:f,unsubscribe(){if(B.current.delete(a),B.current.size===0){K();return}rt()}}},[K,rt]);lt(()=>()=>{K()},[K]);const k=c.isTTY,It=v(()=>{X.current&&(c.removeListener("readable",X.current),X.current=void 0)},[c]),G=v(()=>{Z.current?.reset(),H(),It()},[H,It]),Y=v(()=>{F.current=!1,c.setRawMode(!1),c.unref(),D.current=0,G()},[c,G]),tt=v(a=>{k&&(D.current>0||F.current)&&Y(),s(a)},[k,Y,s]),Nt=v(a=>{if(a.includes("")&&t){tt();return}a===Li&&m&&w(p=>{if(!p)return p})},[t,tt,m]),et=v(a=>{Nt(a),N.emit("input",a)},[Nt,N]),kt=v(()=>{H(),J.current=setTimeout(()=>{J.current=void 0;const a=Z.current.flushPendingEscape();a&&et(a)},Re)},[H,et]),gt=v(()=>{H();let a;for(;(a=c.read())!==null;){const p=Z.current.push(a);for(const f of p)if(typeof f=="string")et(f);else{if(N.listenerCount("paste")===0){Pt.current||(Pt.current=!0,y(`Warning: useInput() received bracketed paste because no usePaste() handler is active. This fallback is deprecated and will be removed in the next major version. Migrate paste handling to usePaste().
2
+ `)),et(f.paste);continue}N.emit("paste",f.paste)}}Z.current.hasPendingEscape()&&kt()},[c,et,H,kt,y,N]),ot=v(()=>{X.current||(X.current=gt,c.addListener("readable",gt))},[c,gt]),Lt=v(a=>{if(!k)throw c===E.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
3
+ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`):new Error(`Raw mode is not supported on the stdin provided to Ink.
4
+ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(c.setEncoding("utf8"),a){if(D.current===0){const p=F.current;F.current=!1,p||(c.ref(),c.setRawMode(!0)),ot()}D.current++;return}D.current!==0&&--D.current===0&&(G(),F.current=!0,queueMicrotask(()=>{F.current&&Y()}))},[k,c,ot,G,Y]),Ft=v(a=>{if(h.isTTY){if(a){W.current===0&&h.write(oe),W.current++;return}W.current!==0&&--W.current===0&&h.write(St)}},[h]),Mt=C({bracketedPaste:!1,rawMode:!1}),Bt=v(()=>{const a=k&&(D.current>0||F.current),p=W.current>0;Mt.current={bracketedPaste:p,rawMode:a},p&&h.isTTY&&h.write(St),a&&(F.current=!1,G(),c.setRawMode(!1),c.unref())},[k,h,c,G]),Dt=v(()=>{const{bracketedPaste:a,rawMode:p}=Mt.current;p&&(c.ref(),c.setRawMode(!0),c.setEncoding("utf8"),ot()),a&&h.isTTY&&h.write(oe)},[c,h,ot]);lt(()=>{n(Bt,Dt)},[n,Bt,Dt]);const _t=v((a,p)=>{const f=a.findIndex(x=>x.id===p);for(let x=f+1;x<a.length;x++){const R=a[x];if(R?.isActive)return R.id}},[]),Wt=v((a,p)=>{const f=a.findIndex(x=>x.id===p);for(let x=f-1;x>=0;x--){const R=a[x];if(R?.isActive)return R.id}},[]),at=v(()=>{const a=T.current;w(p=>{const f=a.find(R=>R.isActive)?.id;return _t(a,p)??f})},[_t]),ut=v(()=>{const a=T.current;w(p=>{const f=a.findLast(R=>R.isActive)?.id;return Wt(a,p)??f})},[Wt]);lt(()=>{const a=f=>{!m||O.current===0||(f===Ni&&at(),f===ki&&ut())};N.on("input",a);const p=N;return()=>{p.off("input",a)}},[m,at,ut,N]);const At=v(()=>{b(!0)},[]),Ut=v(()=>{b(!1)},[]),Ht=v(a=>{T.current.some(f=>f?.id===a)&&w(a)},[]),Kt=v((a,{autoFocus:p})=>{const f=[...T.current,{id:a,isActive:!0}];O.current=f.length,T.current=f,P(f),p&&w(x=>x||a)},[]),Gt=v(a=>{w(f=>{if(f!==a)return f});const p=T.current.filter(f=>f.id!==a);O.current=p.length,T.current=p,P(p)},[]),Yt=v(a=>{const p=T.current.map(f=>f.id!==a?f:{id:a,isActive:!0});T.current=p,P(p)},[]),qt=v(a=>{w(f=>{if(f!==a)return f});const p=T.current.map(f=>f.id!==a?f:{id:a,isActive:!1});T.current=p,P(p)},[]);lt(()=>()=>{const a=!h.destroyed&&!h.writableEnded;e&&a&&h.write(ft),k&&(D.current>0||F.current)&&Y(),W.current>0&&(h.isTTY&&a&&h.write(St),W.current=0)},[h,k,Y,e]);const Te=A(()=>({exit:tt,suspendTerminal:r,waitUntilRenderFlush:u}),[tt,r,u]),Ce=A(()=>({internal_eventEmitter:N,internal_exitOnCtrlC:t,isRawModeSupported:k,setBracketedPasteMode:Ft,setRawMode:Lt,stdin:c}),[c,Lt,Ft,k,t,N]),Ee=A(()=>({stdout:h,write:S}),[h,S]),Pe=A(()=>({stderr:l,write:y}),[l,y]),Oe=A(()=>({setCursorPosition:d}),[d]),Ie=A(()=>({activate:Yt,activeId:g,add:Kt,deactivate:qt,disableFocus:Ut,enableFocus:At,focus:Ht,focusNext:at,focusPrevious:ut,remove:Gt}),[g,Kt,Gt,Yt,qt,At,Ut,at,ut,Ht]),Ne=A(()=>({renderThrottleMs:o,subscribe:Ot}),[Ot,o]);return L($e.Provider,{value:Te,children:L(ti.Provider,{value:Ce,children:L(ei.Provider,{value:Ee,children:L(Je.Provider,{value:Pe,children:L(Ze.Provider,{value:Ie,children:L(Ve.Provider,{value:Ne,children:L(Qe.Provider,{value:Oe,children:L(Xe,{onError:tt,children:i})})})})})})})})};ve.displayName="InternalApp";const Fi=(i,t,e)=>{if(e<=0||!i.yogaNode)return"";const{yogaNode:s}=i,n=s.getComputedBorder(M.EDGE_LEFT),r=s.getComputedBorder(M.EDGE_RIGHT),u=s.getComputedBorder(M.EDGE_TOP),o=s.getComputedPadding(M.EDGE_LEFT),d=s.getComputedPadding(M.EDGE_RIGHT),l=s.getComputedPadding(M.EDGE_TOP),c=Math.round(s.getComputedWidth()-n-r-o-d);if(c<=0)return"";const h=new ii({height:e,width:c}),S=-(i.internal_scrollState?.scrollLeft??0)-n-o,m=-t-u-l;for(const b of i.childNodes)si(b,h,{absoluteOffsetX:S,absoluteOffsetY:m,offsetX:S,offsetY:m,skipStaticElements:!1});return h.get().output},Ct=new WeakMap,j=i=>i??"default",Mi=()=>{let i,t;return{consumeDelta:()=>{if(j(t)===j(i))return"";const e=j(t);return i=t,te(e)},consumeRestoreOnDone:()=>{const e=j(i)!=="default";return i=void 0,t=void 0,e?te("default"):""},isDirty:()=>j(t)!==j(i),setPending:e=>{t=e}}},nt=(i,t)=>t.endsWith(`
5
+ `)?i.length-1:i.length,be=i=>i.rows||1/0,ye=(i,t)=>Math.min(i,be(t)),we=(i,t)=>{const{activeCursor:e,content:s,contentLines:n,previousLines:r,returnPrefix:u,shapeDelta:o}=i,d=Et(nt(n,s),e);t.write(o+u+st(ye(r.length,t))+s+d)},Bi=(i,t)=>{const{activeCursor:e,content:s,contentLines:n,previous:r,previousLines:u,returnPrefix:o,shapeDelta:d}=i,l=nt(n,s);if(s===`
6
+ `||r.length===0){we(i,t);return}const c=nt(u,r),h=s.endsWith(`
7
+ `),y=[d,o],S=be(t);if(l<c){const b=r.endsWith(`
8
+ `)?1:0;y.push(st(Math.min(c-l+b,S)),Vt(Math.min(l,S-1)))}else y.push(Vt(Math.min(c-1,S-1)));for(let m=0;m<l;m+=1){const b=m===l-1;if(n[m]===u[m]){(!b||h)&&y.push(We());continue}y.push(Ae(0)+n[m]+Ue+(b&&!h?"":`
9
+ `))}y.push(Et(l,e)),t.write(y.join(""))},Di=(i,{showCursor:t=!1},e)=>{let s=[],n="",r=!1,u,o=!1,d,l=!1;const c=Mi(),h=()=>o?u:void 0,y=(g,w)=>{const P=Jt(w,d);return g!==n||P||c.isDirty()},S=g=>{d=g?{...g}:void 0,l=g!==void 0},m=()=>{n="",s=[],d=void 0,l=!1},b=g=>{!t&&!r&&(i.write(Rt),r=!0);const w=h();o=!1;const P=Jt(w,d);if(!y(g,w))return!1;const O=c.consumeDelta(),T=g.split(`
10
+ `),B=nt(T,g);return g===n&&P?(i.write(O+ui({cursorPosition:w,cursorWasShown:l,previousCursorPosition:d,previousLineCount:s.length,visibleLineCount:B})),S(w),!0):g===n&&O!==""?(i.write(O),S(w),!0):(e({activeCursor:w,content:g,contentLines:T,previous:n,previousLines:s,returnPrefix:Zt(l,s.length,d),shapeDelta:O},i),n=g,s=T,S(w),!0)};return b.clear=()=>{const g=Zt(l,s.length,d);i.write(g+st(ye(s.length,i))),m()},b.done=()=>{m();const g=c.consumeRestoreOnDone();g!==""&&i.write(g),t||(i.write(ft),r=!1)},b.reset=m,b.sync=g=>{const w=h();o=!1;const P=g.split(`
11
+ `);n=g,s=P;const O=c.consumeDelta();O!==""&&i.write(O),!w&&l&&i.write(Rt),w&&i.write(Et(nt(P,g),w)),S(w)},b.setCursorPosition=g=>{u=g,o=!0},b.setCursorShape=c.setPending,b.isCursorDirty=()=>o||c.isDirty(),b.willRender=g=>y(g,h()),b},_i=(i,{incremental:t=!1,showCursor:e=!1}={})=>Di(i,{showCursor:e},t?Bi:we),Wi={create:_i},Se=He(2026),U=le(Se),_=he(Se);function Ai(i,t){return"isTTY"in i&&i.isTTY&&(t??!fe)}let z;const Ui=()=>{if(z!==!1){if(z!==void 0)return z;try{return z=ci(import.meta.url).Renderer,z}catch{z=!1;return}}},Hi=i=>{const t=Ui();if(!t)return;let e,s=0,n=0;const r=(u,o)=>{(!e||s!==u||n!==o)&&(e?e.resize(u,o):e=new t(u,o),s=u,n=o)};return{clear(){if(e){const u=new Uint32Array(s*n*2),o=65535;for(let d=0;d<u.length;d+=2)u[d]=32,u[d+1]=o;e.render(u)}},destroy(){e=void 0},render(u,o,d){if(r(o,d),!!e){i.isTTY&&e.writeRaw(U);try{e.render(u)}finally{i.isTTY&&e.writeRaw(_)}}},resize(u,o){r(u,o)}}};function ae(i,t=0,e={}){const s=e.leading??!0,n=e.trailing??!0;let r,u,o,d;const l=()=>{if(u===void 0)return;const m=u;u=void 0,d=i(...m)},c=()=>{r!==void 0&&(clearTimeout(r),r=void 0)},h=()=>{r=void 0,n&&l(),u=void 0,o=void 0},y=()=>{c(),r=setTimeout(h,t)},S=function(...b){const g=Date.now();if(o??=g,g-o>=t)return u=b,l(),o=g,y(),d;u=b;const w=r===void 0;return y(),s&&w&&l(),d};return S.cancel=()=>{c(),u=void 0,o=void 0},S.flush=()=>(c(),l(),o=void 0,d),S}console.Console||(console.Console=_e);const it=()=>{},ue=async()=>new Promise(i=>{setImmediate(i)}),Ki=27,Gi=91,Yi=63,qi=117,ji=48,zi=57,Vi=i=>i>=ji&&i<=zi,xe=(i,t)=>{if(i[t]!==Ki||i[t+1]!==Gi||i[t+2]!==Yi)return;let e=t+3;const s=e;for(;e<i.length&&Vi(i[e]);)e++;if(e!==s){if(e===i.length)return{state:"partial"};if(i[e]===qi)return{endIndex:e,state:"complete"}}},$i=i=>{for(let t=0;t<i.length;t++)if(xe(i,t)?.state==="complete")return!0;return!1},Qi=i=>{const t=[];let e=0;for(;e<i.length;){const s=xe(i,e);if(s?.state==="complete"){e=s.endIndex+1;continue}if(s?.state==="partial")break;t.push(i[e]),e++}return t},Xi=({isTty:i,isUnmounting:t,isWindows:e,nextOutputHeight:s,previousOutputHeight:n,viewportRows:r})=>{if(!i)return!1;const u=n>0,o=n>=r,d=s>=r,l=n>r,c=s>r,h=o&&s<r;return l||c&&u||h||t&&o||e&&(d||o)},xt=i=>i instanceof Error||Object.prototype.toString.call(i)==="[object Error]",ce=i=>{const t=!i.destroyed&&!i.writableEnded&&(i.writable??!0),e=i._writableState!==void 0||i.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:e}},dt=(i,t)=>{if(!i||typeof i.flush!="function")return;const e=i;t?e.flush():typeof e.cancel=="function"&&e.cancel()};class Zi{isConcurrent;options;log;manualCursorPosition;renderedCursorPosition;renderedCursorRequested;throttledLog;isScreenReaderEnabled;interactive;renderThrottleMs;alternateScreen;isUnmounted;isUnmounting;lastOutput;lastOutputToRender;lastOutputHeight;lastTerminalWidth;nativeLog;useNativeRenderer;container;rootNode;fullStaticOutput;backbufferNode;backbufferMultiWarned=!1;exitPromise;exitResult;beforeExitHandler;restoreConsole;unsubscribeResize;throttledOnRender;hasPendingThrottledRender=!1;kittyProtocolEnabled=!1;kittyFlags;isSuspended=!1;pauseInput;resumeInput;cancelKittyDetection;nextRenderCommit;deferredInitDone=!1;constructor(t){this.options=t,this.rootNode=oi("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??E.env.INK_SCREEN_READER==="true",this.interactive=this.resolveInteractiveOption(t.interactive),this.alternateScreen=!1;const e=t.debug||this.isScreenReaderEnabled,s=t.maxFps??30,n=s>0?Math.max(1,Math.ceil(1e3/s)):0;this.renderThrottleMs=e?0:n;const r=e?this.onRender:(()=>{const o=ae(this.onRender,n,{leading:!0,trailing:!0});return this.throttledOnRender=o,()=>{this.hasPendingThrottledRender=!0,o()}})();if(e&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let o=!1;const d=()=>{o||(o=!0,queueMicrotask(()=>{o=!1,this.onRender()}))};this.rootNode.onRender=d,this.rootNode.onImmediateRender=d}else this.rootNode.onRender=r,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=Wi.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=Hi(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=e?this.log:ae(o=>{const d=this.log.willRender(o),l=this.shouldSync();l&&d&&this.options.stdout.write(U),this.log(o),l&&d&&this.options.stdout.write(_)},void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.isUnmounting=!1,this.isConcurrent=t.concurrent??!1,this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.lastTerminalWidth=q(this.options.stdout).columns,this.fullStaticOutput="";const u=t.concurrent?Ye:qe;this.container=I.createContainer(this.rootNode,u,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=Si(this.unmount,{alwaysLast:!1}),this.setAlternateScreen(!!t.alternateScreen),t.patchConsole&&this.patchConsole(),this.interactive&&(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)}),this.initImmediateKittyKeyboard(),E.env.DEV==="true"&&I.injectIntoDevTools(),this.exitPromise=new Promise((o,d)=>{this.resolveExitPromise=o,this.rejectExitPromise=d}),this.exitPromise.catch(it)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=()=>{const t=q(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),li(),this.calculateLayout(),ai(this.rootNode),this.onRender(),this.lastTerminalWidth=t};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};handleAppExit=t=>{if(!(this.isUnmounted||this.isUnmounting)){if(xt(t)){this.unmount(t);return}this.exitResult=t,this.unmount()}};getActiveCursorPosition=()=>this.renderedCursorRequested?this.renderedCursorPosition:this.manualCursorPosition;setCursorPosition=t=>{this.manualCursorPosition=t,this.log.setCursorPosition(this.getActiveCursorPosition())};restoreLastOutput=()=>{this.interactive&&(this.log.setCursorPosition(this.getActiveCursorPosition()),this.log(this.lastOutputToRender||`${this.lastOutput}
12
+ `))};calculateLayout=()=>{const t=s=>{const n=new Map;this.calculateScrollAndTriggerObservers(s,n);for(const[r,u]of n)r.internalTrigger(u)};this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const e=q(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(e),this.rootNode.yogaNode.calculateLayout(void 0,void 0,M.DIRECTION_LTR),t(this.rootNode)};calculateScrollAndTriggerObservers(t,e){if(t.nodeName==="ink-box"){const{style:s}=t,n=s.overflow??"visible",r=s.overflowX??n,u=s.overflowY??n;r==="scroll"||u==="scroll"?(pi(t),s.overflowToBackbuffer&&(this.backbufferNode&&this.backbufferNode!==t&&!this.backbufferMultiWarned&&(this.backbufferMultiWarned=!0,console.warn("[@visulima/tui] Multiple scrollable regions have `overflowToBackbuffer` enabled; only one is supported. The last one in render order wins.")),this.backbufferNode=t)):t.internal_scrollState&&delete t.internal_scrollState}if(fi(t,e),!t.internal_static)for(const s of t.childNodes)s.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(s,e)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,e){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),hi(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let s=0;for(const n of t.childNodes){const r=n;n.nodeName!=="#text"&&r.yogaNode&&(t.yogaNode.insertChild(r.yogaNode,s),s++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const s of t.childNodes)s.nodeName!=="#text"&&this.prepareYogaTree(s,e);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const s=q(this.options.stdout).columns,{width:n}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof n=="number"?n:s),t.yogaNode.calculateLayout(void 0,void 0,M.DIRECTION_LTR)),e(t),ni(t,{skipStaticElements:!1,trackSelection:this.options.trackSelection}),t.internal_onRendered?.()}}markAllTextNodesDirty(t){if(!t.cachedRender){t.nodeName==="ink-text"&&t.yogaNode&&t.yogaNode.markDirty();for(const e of t.childNodes)e.nodeName!=="#text"&&this.markAllTextNodesDirty(e)}}handleStaticChange=()=>{this.fullStaticOutput=""};computeBackbufferOutput(){const t=this.backbufferNode;if(!t?.internal_scrollState||!this.interactive||!this.options.stdout.isTTY||this.alternateScreen||this.isScreenReaderEnabled||this.options.debug)return"";const e=Math.round(t.internal_scrollState.scrollTop),s=t.yogaNode?.getComputedPadding(M.EDGE_TOP)??0,n=Math.max(0,e-Math.round(s)),r=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:u}=t.style,o=u===void 0?r:Math.max(r,n-Math.max(0,u)),d=n-o;if(d<=0)return"";const l=Fi(t,o,d);return l===""?"":(t.internal_maxPushedScrollTop=n,`${l}\x1B[0m
13
+ `)}onRender=()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=ri(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:e,cursorRequested:s,cursorShape:n,output:r,outputBuffer:u,outputHeight:o,outputWidth:d,staticOutput:l}=t;this.renderedCursorRequested=s,this.renderedCursorPosition=e,this.log.setCursorShape(s?n:void 0);const c=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&u&&d){l&&l!==`
14
+ `&&this.options.stdout.write(l),c&&this.options.stdout.write(c),this.nativeLog.render(u,d,o),this.lastOutputHeight=o;return}s&&this.log.setCursorPosition(this.getActiveCursorPosition());const h=l&&l!==`
15
+ `;if(this.options.debug){h&&(this.fullStaticOutput+=l),this.lastOutput=r,this.lastOutputToRender=r,this.lastOutputHeight=o,this.options.stdout.write(this.fullStaticOutput+r);return}if(!this.interactive){h&&this.options.stdout.write(l),this.lastOutput=r,this.lastOutputToRender=`${r}
16
+ `,this.lastOutputHeight=o;return}if(this.isScreenReaderEnabled){const y=this.shouldSync();if(y&&this.options.stdout.write(U),h){const b=this.lastOutputHeight>0?st(this.lastOutputHeight):"";this.options.stdout.write(b+l),this.lastOutputHeight=0}if(r===this.lastOutput&&!h){y&&this.options.stdout.write(_);return}const S=q(this.options.stdout).columns,m=Ge(r,{trim:!1,width:S,wrapMode:"BREAK_WORDS"}).replace(/\n$/,"");if(h)this.options.stdout.write(m);else{const b=this.lastOutputHeight>0?st(this.lastOutputHeight):"";this.options.stdout.write(b+m)}this.lastOutput=r,this.lastOutputToRender=m,this.lastOutputHeight=m===""?0:m.split(`
17
+ `).length,y&&this.options.stdout.write(_);return}h&&(this.fullStaticOutput+=l),this.renderInteractiveFrame(r,o,h?l:"",c)};accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const e=L(je.Provider,{value:this.accessibilityContextValue,children:L(ve,{exitOnCtrlC:this.options.exitOnCtrlC,interactive:this.interactive,onExit:this.handleAppExit,onRegisterInputControl:this.registerInputControl,onSuspendTerminal:this.suspendTerminal,onWaitUntilRenderFlush:this.waitUntilRenderFlush,renderThrottleMs:this.renderThrottleMs,setCursorPosition:this.setCursorPosition,stderr:this.options.stderr,stdin:this.options.stdin,stdout:this.options.stdout,writeToStderr:this.writeToStderr,writeToStdout:this.writeToStdout,children:t})});this.options.concurrent?I.updateContainer(e,this.container,null,it):(I.updateContainerSync(e,this.container,null,it),I.flushSyncWork())}writeToStdout=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stdout.write(t);return}const e=this.shouldSync();e&&this.options.stdout.write(U),this.log.clear(),this.options.stdout.write(t),this.restoreLastOutput(),e&&this.options.stdout.write(_)};writeToStderr=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stderr.write(t);return}const e=this.shouldSync();e&&this.options.stdout.write(U),this.log.clear(),this.options.stderr.write(t),this.restoreLastOutput(),e&&this.options.stdout.write(_)};unmount=t=>{if(this.isUnmounted||this.isUnmounting)return;this.isUnmounting=!0,this.beforeExitHandler&&(E.off("beforeExit",this.beforeExitHandler),this.beforeExitHandler=void 0);const e=this.options.stdout,{canWriteToStdout:s,hasWritableState:n}=ce(e);dt(this.throttledOnRender,s),s&&!this.alternateScreen&&(!this.throttledOnRender||!this.hasPendingThrottledRender&&this.fullStaticOutput==="")&&(this.calculateLayout(),this.onRender()),this.isUnmounted=!0,this.unsubscribeExit(),dt(this.throttledLog,s),typeof this.restoreConsole=="function"&&this.restoreConsole();const r=()=>{typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),this.cancelKittyDetection&&this.cancelKittyDetection(),s&&(this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen?(this.log.clear(),this.log.done(),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.fullStaticOutput="",this.writeBestEffort(this.options.stdout,Qt),this.writeBestEffort(this.options.stdout,ft),this.alternateScreen=!1):this.interactive?this.options.debug||this.log.done():this.options.stdout.write(this.options.debug?`
18
+ `:`${this.lastOutput}
19
+ `)),this.kittyProtocolEnabled=!1,Ct.delete(this.options.stdout);const{exitResult:o}=this,d=()=>{xt(t)?this.rejectExitPromise(t):this.resolveExitPromise(o)};t!==void 0&&!xt(t)?d():s&&n?this.options.stdout.write("",d):setImmediate(d)},u=I;this.options.concurrent?(I.updateContainerSync(null,this.container,null,it),I.flushSyncWork(),u.flushPassiveEffects?.(),r()):(I.updateContainerSync(null,this.container,null,it),I.flushSyncWork(),r())};async waitUntilExit(){return this.beforeExitHandler||(this.beforeExitHandler=()=>{this.unmount()},E.on("beforeExit",this.beforeExitHandler)),this.exitPromise}async waitUntilRenderFlush(){if(this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(await ue(),this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(this.isConcurrent&&this.hasPendingConcurrentWork()&&(await Promise.race([this.awaitNextRender(),this.awaitExit()]),this.isUnmounted||this.isUnmounting)){this.nextRenderCommit=void 0,await this.awaitExit();return}I.flushSyncWork();const t=this.options.stdout,{canWriteToStdout:e,hasWritableState:s}=ce(t);if(dt(this.throttledOnRender,e),dt(this.throttledLog,e),e&&s){await new Promise(n=>{this.options.stdout.write("",()=>{n()})});return}await ue()}clear(){!this.interactive||this.options.debug||(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
20
+ `))}patchConsole(){this.options.debug||(this.restoreConsole=mi((t,e)=>{t==="stdout"&&this.writeToStdout(e),t==="stderr"&&(e.startsWith("The above error occurred")||this.writeToStderr(e))}))}setAlternateScreen(t){this.alternateScreen=this.resolveAlternateScreenOption(t,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,$t),this.writeBestEffort(this.options.stdout,Rt))}resolveInteractiveOption(t){return t??(!fe&&this.options.stdout.isTTY)}resolveAlternateScreenOption(t,e){return!!t&&e&&this.options.stdout.isTTY}shouldSync(){return Ai(this.options.stdout,this.interactive)}writeBestEffort(t,e){try{t.write(e)}catch{}}async awaitExit(){try{await this.exitPromise}catch{}}hasPendingConcurrentWork(){const t=this.container;return(t.pendingLanes??0)!==0&&t.callbackNode!==void 0&&t.callbackNode!==null}async awaitNextRender(){if(!this.nextRenderCommit){let t;const e=new Promise(s=>{t=s});this.nextRenderCommit={promise:e,resolve:t}}return this.nextRenderCommit.promise}renderInteractiveFrame(t,e,s,n=""){const r=s+n,u=r!=="",o=this.options.stdout.isTTY,d=o?q(this.options.stdout).rows:24,l=o&&e>=d,c=l?t:`${t}
21
+ `,h=E.platform==="win32",y=o&&h&&(l||this.lastOutputHeight>=d);if(Xi({isTty:o,isUnmounting:this.isUnmounting,isWindows:h,nextOutputHeight:e,previousOutputHeight:this.lastOutputHeight,viewportRows:d})){if(this.options.incrementalRendering&&!y){u&&(this.log.clear(),this.options.stdout.write(r)),(t!==this.lastOutput||this.log.isCursorDirty()||u)&&this.throttledLog(c),this.lastOutput=t,this.lastOutputToRender=c,this.lastOutputHeight=e;return}const m=this.shouldSync();m&&this.options.stdout.write(U),this.options.stdout.write(Ke+this.fullStaticOutput+n+c),this.lastOutput=t,this.lastOutputToRender=c,this.lastOutputHeight=e,this.log.sync(c),m&&this.options.stdout.write(_);return}if(u){const m=this.shouldSync();m&&this.options.stdout.write(U),this.log.clear(),this.options.stdout.write(r),this.log(c),m&&this.options.stdout.write(_)}else(t!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(c);this.lastOutput=t,this.lastOutputToRender=c,this.lastOutputHeight=e}initImmediateKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="enabled")return;const s=t.flags??["disambiguateEscapeCodes"];this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(s)}initDeferredKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="auto")return;const s=t.flags??["disambiguateEscapeCodes"];!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(s)}confirmKittySupport(t){di(this.options.stdin,async()=>this.runKittySupportQuery(t))}async runKittySupportQuery(t){const{stdin:e,stdout:s}=this.options;let n=[],r,u;const o=()=>{this.cancelKittyDetection=void 0,r&&clearTimeout(r),e.removeListener("data",d);const l=Qi(n);n=[],l.length>0&&e.unshift(zt.from(l))},d=l=>{const c=typeof l=="string"?zt.from(l):l;for(const h of c)n.push(h);$i(n)&&(o(),this.isUnmounted||this.enableKittyProtocol(t),u?.())};return e.on("data",d),s.write("\x1B[?u"),new Promise(l=>{u=l,r=setTimeout(()=>{o(),l()},200),this.cancelKittyDetection=()=>{o(),l()}})}registerInputControl=(t,e)=>{this.pauseInput=t,this.resumeInput=e};suspendTerminal=(async t=>{if(this.beginSuspend(),t){try{await t()}finally{await this.endSuspend()}return}const e=async()=>{await this.endSuspend()};return{resume:e,[Symbol.asyncDispose]:e}});beginSuspend(){if(this.isSuspended)throw new Error("The terminal is already suspended. Resume the current suspension before suspending again.");if(this.isSuspended=!0,!(!this.interactive||this.isUnmounted||this.isUnmounting))try{this.log.clear(),this.log.done(),this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,Qt),this.writeBestEffort(this.options.stdout,ft)),this.pauseInput?.()}catch(t){this.isSuspended=!1;try{this.resumeInput?.()}catch{}throw t}}async endSuspend(){if(this.isSuspended&&(this.isSuspended=!1,this.resumeInput?.(),!(!this.interactive||this.isUnmounted||this.isUnmounting))){this.alternateScreen&&this.writeBestEffort(this.options.stdout,$t),this.kittyProtocolEnabled&&this.kittyFlags&&this.writeBestEffort(this.options.stdout,`\x1B[>${Xt(this.kittyFlags)}u`),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.log.reset();try{this.calculateLayout(),this.onRender(),await this.waitUntilRenderFlush()}catch{}}}enableKittyProtocol(t){this.kittyFlags=t,this.options.stdout.write(`\x1B[>${Xt(t)}u`),this.kittyProtocolEnabled=!0}}const Os=(i,t)=>{const e={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:E.stderr,stdin:E.stdin,stdout:E.stdout,...Ji(t)},s=ts(e.stdout,()=>new Zi(e));return s.render(i),{cleanup(){s.unmount()},clear(){s.clear()},rerender(n){s.render(n)},rootNode:s.rootNode,unmount(){s.unmount()},waitUntilExit(){return s.waitUntilExit()},waitUntilRenderFlush(){return s.waitUntilRenderFlush()}}},Ji=(i={})=>i instanceof De?{stdin:E.stdin,stdout:i}:i,ts=(i,t)=>{const e=Ct.get(i);if(e===void 0){const s=t();return Ct.set(i,s),s}return E.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
22
+ `),e};export{Os as default};
@@ -1,7 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import { D as DOMElement } from "./dom.d-CLGlidfI.js";
3
- import { T as TerminalSuspension } from "./app-context.d-DMLw5Nxy.js";
4
- import 'node:stream';
2
+ import { D as DOMElement } from "./dom.d-BV2bnRcH.js";
3
+ import { T as TerminalSuspension } from "./app-context.d-DAF6oxKX.js";
5
4
  import { CursorPosition } from "../ink/public/cursor.js";
6
5
  declare const kittyFlags: {
7
6
  readonly disambiguateEscapeCodes: 1;
@@ -36,53 +35,53 @@ type RenderMetrics = {
36
35
  };
37
36
  type Options = {
38
37
  /**
39
- * Render the app in the terminal's alternate screen buffer. When enabled, the app renders on a separate screen, and the original terminal content is restored when the app exits. This is the same mechanism used by programs like vim, htop, and less.
40
- *
41
- * Note: The terminal's scrollback buffer is not available while in the alternate screen. This is standard terminal behavior; programs like vim use the alternate screen specifically to avoid polluting the user's scrollback history.
42
- *
43
- * Note: Ink intentionally treats alternate-screen teardown output as disposable. It does not preserve or replay teardown-time frames, hook writes, or `console.*` output after restoring the primary screen.
44
- *
45
- Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
46
-
47
- Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
48
-
49
- @default false
50
-
51
- @see {@link RenderOptions.alternateScreen}
52
- */
38
+ * Render the app in the terminal's alternate screen buffer. When enabled, the app renders on a separate screen, and the original terminal content is restored when the app exits. This is the same mechanism used by programs like vim, htop, and less.
39
+ *
40
+ * Note: The terminal's scrollback buffer is not available while in the alternate screen. This is standard terminal behavior; programs like vim use the alternate screen specifically to avoid polluting the user's scrollback history.
41
+ *
42
+ * Note: Ink intentionally treats alternate-screen teardown output as disposable. It does not preserve or replay teardown-time frames, hook writes, or `console.*` output after restoring the primary screen.
43
+ *
44
+ * Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
45
+ *
46
+ * Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
47
+ *
48
+ * @default false
49
+ *
50
+ * @see {@link RenderOptions.alternateScreen}
51
+ */
53
52
  alternateScreen?: boolean;
54
53
  /**
55
- * Enable React Concurrent Rendering mode.
56
- *
57
- * When enabled:
58
- * - Suspense boundaries work correctly with async data
59
- * - `useTransition` and `useDeferredValue` are fully functional
60
- - Updates can be interrupted for higher priority work
61
-
62
- Note: Concurrent mode changes the timing of renders. Some tests may need to use `act()` to properly await updates. Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change the rendering mode or create a fresh instance.
63
-
64
- @default false
65
- @experimental
66
- */
54
+ * Enable React Concurrent Rendering mode.
55
+ *
56
+ * When enabled:
57
+ * - Suspense boundaries work correctly with async data
58
+ * - `useTransition` and `useDeferredValue` are fully functional
59
+ * - Updates can be interrupted for higher priority work
60
+ *
61
+ * Note: Concurrent mode changes the timing of renders. Some tests may need to use `act()` to properly await updates. Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change the rendering mode or create a fresh instance.
62
+ *
63
+ * @default false
64
+ * @experimental
65
+ */
67
66
  concurrent?: boolean;
68
67
  debug: boolean;
69
68
  exitOnCtrlC: boolean;
70
69
  incrementalRendering?: boolean;
71
70
  /**
72
- * Override automatic interactive mode detection.
73
- *
74
- * By default, Ink detects whether the environment is interactive based on CI detection (via [`is-in-ci`](https://github.com/sindresorhus/is-in-ci)) and `stdout.isTTY`. Most users should not need to set this.
75
- *
76
- * When non-interactive, Ink disables ANSI erase sequences, cursor manipulation, synchronized output, resize handling, and kitty keyboard auto-detection, writing only the final frame at unmount.
77
- *
78
- Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
79
-
80
- Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
81
-
82
- @default true (false if in CI or `stdout.isTTY` is falsy)
83
-
84
- @see {@link RenderOptions.interactive}
85
- */
71
+ * Override automatic interactive mode detection.
72
+ *
73
+ * By default, Ink detects whether the environment is interactive based on CI detection (via [`is-in-ci`](https://github.com/sindresorhus/is-in-ci)) and `stdout.isTTY`. Most users should not need to set this.
74
+ *
75
+ * When non-interactive, Ink disables ANSI erase sequences, cursor manipulation, synchronized output, resize handling, and kitty keyboard auto-detection, writing only the final frame at unmount.
76
+ *
77
+ * Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
78
+ *
79
+ * Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
80
+ *
81
+ * @default true (false if in CI or `stdout.isTTY` is falsy)
82
+ *
83
+ * @see {@link RenderOptions.interactive}
84
+ */
86
85
  interactive?: boolean;
87
86
  isScreenReaderEnabled?: boolean;
88
87
  kittyKeyboard?: KittyKeyboardOptions;
@@ -232,6 +231,7 @@ declare class Ink {
232
231
  */
233
232
  private initDeferredKittyKeyboard;
234
233
  private confirmKittySupport;
234
+ private runKittySupportQuery;
235
235
  registerInputControl: (pauseInput: () => void, resumeInput: () => void) => void;
236
236
  /**
237
237
  * Hand terminal control to a child process, then restore Ink's rendering.
@@ -0,0 +1,2 @@
1
+ import p from"react";import{FocusProvider as w}from"./FocusContext-mWFBWdli.js";import{TuiContext as S}from"./TuiContext-Bbq9JRCu.js";import{LayoutNode as g}from"./LayoutNode-D4i45GQM.js";import{T as l}from"./reconciler-DXp9qy6k.js";import{renderTreeToBuffer as C}from"./renderTreeToBuffer-MEHvKJc-.js";import{Cell as T}from"./Cell-CbDQUAjW.js";function P(d,i){const o=i?.columns??80,e=i?.rows??24,t=new g;t.yogaNode.setWidth(o),t.yogaNode.setHeight(e);const f={app:null,input:null,writeStderr:n=>{},writeStdout:n=>{}},h=p.createElement(S.Provider,{value:f},p.createElement(w,null,d)),u=l.createContainer(t,0,null,!1,null,"renderToString",()=>{},null);l.updateContainerSync(h,u,null,()=>{}),l.flushSyncWork(),t.calculateLayout(o,e);const a=new Uint32Array(o*e*2);C(t,a,o,e);const r=[];for(let n=0;n<e;n++){let s="";for(let c=0;c<o;c++){const y=a[(n*o+c)*2],m=T.getChar(y);s+=m===""?" ":m}r.push(s.trimEnd())}for(;r.length>0&&r.at(-1)==="";)r.pop();return l.updateContainerSync(null,u,null,()=>{}),l.flushSyncWork(),t.destroy(),r.join(`
2
+ `)}export{P as renderToString};
@@ -0,0 +1,4 @@
1
+ import{LegacyRoot as p}from"react-reconciler/constants.js";import g from"yoga-layout";import{c as v}from"./dom-xpeZzKuf.js";import{r as c}from"./reconciler-BPm7fZa6.js";import{r as s}from"./renderer-D97BmOBO.js";import{calculateScroll as N}from"./calculateScroll-jdxVlcmq.js";const E=(u,f)=>{const d=f?.columns??80,t=v("ink-root");let l="";t.onComputeLayout=()=>{t.yogaNode.setWidth(d),t.yogaNode.calculateLayout(void 0,void 0,g.DIRECTION_LTR);const o=r=>{if(r.nodeName==="ink-box"){const n=r.style.overflow??"visible",y=r.style.overflowX??n,m=r.style.overflowY??n;(y==="scroll"||m==="scroll")&&N(r)}for(const n of r.childNodes)n.nodeName!=="#text"&&o(n)};o(t)},t.onImmediateRender=()=>{const{staticOutput:o}=s(t,!1);o&&o!==`
2
+ `&&(l+=o)};let e;const a=c.createContainer(t,p,null,!1,null,"render-to-string",o=>{e??=o},()=>{},()=>{},()=>{});let i=!1;try{c.updateContainerSync(u,a,null,()=>{}),c.flushSyncWork();const{output:o}=s(t,!1);if(c.updateContainerSync(null,a,null,()=>{}),c.flushSyncWork(),i=!0,t.yogaNode.free(),e!==void 0)throw e instanceof Error?e:new Error(String(e));const r=l.endsWith(`
3
+ `)?l.slice(0,-1):l;return r&&o?`${r}
4
+ ${o}`:r||o}finally{if(!i&&t.yogaNode)try{t.yogaNode.freeRecursive()}catch{}}};export{E as default};
@@ -0,0 +1 @@
1
+ import{jsx as n,Fragment as S,jsxs as a}from"react/jsx-runtime";import{Box as g}from"../components/box.js";import{Text as i}from"../components/text.js";const f=1,p=2,E=4,N=8,m=(o,t)=>{const r=o.fontStyle??0;return n(i,{backgroundColor:o.bgColor,bold:(r&p)!==0,color:o.color,italic:(r&f)!==0,strikethrough:(r&N)!==0,underline:(r&E)!==0,children:o.content},t)},x=o=>n(S,{children:o.map((t,r)=>m(t,r))}),C=(o,t={})=>{const{highlightLines:r,showLineNumbers:l=!1,startLine:c=1}=t,T=l?String(c+o.length-1).length:0;return n(g,{flexDirection:"column",children:o.map((s,h)=>{const d=c+h,e=r?.has(d)??!1;return a(g,{children:[l?a(i,{color:e?"yellow":void 0,dimColor:!e,children:[String(d).padStart(T)," "]}):void 0,n(i,{backgroundColor:e?"#3a3a00":void 0,children:s.length>0?s.map((L,u)=>m(L,u)):""})]},h)})})};export{m as renderToken,x as renderTokenLine,C as tokenLinesToElements};
@@ -0,0 +1,2 @@
1
+ import{c as W}from"./boxes-CidWUOVk.js";import{resolveColor as k}from"./NAMED_COLORS-DvfPALxN.js";import{a as F}from"./text-width-BXmBaLDv.js";const j=1114112,I=9608,X=9600,D=9604;function H(t){const o=t?.borderStyle?1:0;return{bottom:t?.borderBottom===!1?0:o,left:t?.borderLeft===!1?0:o,right:t?.borderRight===!1?0:o,top:t?.borderTop===!1?0:o}}function V(t){let o=0;for(const s of t.children){const p=s.getLayout(),r=p.top+p.height;r>o&&(o=r)}const c=t._style,n=c?.paddingBottom??c?.paddingY??c?.padding??0;return o+n}function q(t,o,c,n,s,p,r,x,_,T,g,y){const e=H(y),a=x-e.top-e.bottom,m=y.scrollTop??0,d=V(t),C=a;if(d<=C||a<=0)return;const i=a*2,h=Math.max(2,Math.round(C/d*i)),l=d-C,b=i-h,R=l>0?Math.round(m/l*b):0,f=typeof y.scrollbarThumbColor=="string"?k(y.scrollbarThumbColor):_,u=s+r-1-e.right,O=T<<16|65280|f;for(let M=0;M<a;M++){const P=M*2,E=P+1,S=P>=R&&P<R+h,L=E>=R&&E<R+h;if(!S&&!L)continue;let B=I;S&&!L?B=X:!S&&L&&(B=D),v(o,c,n,u,p+e.top+M,B,O,g)}}function z(t,o,c,n,s,p,r,x,_,T,g,y,e,a){const m=H(a),d=a.scrollTop??0,C=p+m.top;for(const i of t.children){if(!i._style?.sticky)continue;const h=i.getLayout();if(h.top>=d)continue;const b=i.parent;if(b&&b!==t){const M=b.getLayout();if(M.top+M.height<=d)continue}const R=C,f=i.fg===255?_:i.fg,u=i.bg===255?T:i.bg,O=i.styles===0?g:i.styles;N(i,o,c,n,s-h.left,R-h.top,f,u,O,y,e)}}function $(t,o,c,n){for(let r=0;r<o.length;r+=2)o[r]=32,o[r+1]=65535;const s=[],p={x0:0,x1:c,y0:0,y1:n};try{N(t,o,c,n,0,0,t.fg,t.bg,t.styles,s,p);for(const r of s)G(r.node,o,c,n,r.absX,r.absY,r.w,r.h,r.fg,r.bg,r.styles,r.clip)}catch(r){console.error("Renderer Error:",r)}}function v(t,o,c,n,s,p,r,x){if(n<x.x0||n>=x.x1||s<x.y0||s>=x.y1||n<0||n>=o||s<0||s>=c)return;const _=(s*o+n)*2;t[_]=p,t[_+1]=r}function G(t,o,c,n,s,p,r,x,_,T,g,y){if(!t._style?.borderStyle||r<=0||x<=0)return;const e=W[t._style.borderStyle],a=t._style.borderColor===void 0?_:k(t._style.borderColor),m=g<<16|T<<8|a,d=t._style.borderTop!==!1,C=t._style.borderBottom!==!1,i=t._style.borderLeft!==!1,h=t._style.borderRight!==!1,l=C&&(x>1||!d);if(d)for(let f=0;f<r;f++){let u;r===1?u=i&&h?e.left:i?e.topLeft:h?e.topRight:e.top:f===0&&i?u=e.topLeft:f===r-1&&h?u=e.topRight:u=e.top,v(o,c,n,s+f,p,u.codePointAt(0),m,y)}if(l)for(let f=0;f<r;f++){let u;r===1?u=i&&h?e.left:i?e.bottomLeft:h?e.bottomRight:e.bottom:f===0&&i?u=e.bottomLeft:f===r-1&&h?u=e.bottomRight:u=e.bottom,v(o,c,n,s+f,p+x-1,u.codePointAt(0),m,y)}const b=d?1:0,R=l?x-1:x;for(let f=b;f<R;f++)i&&v(o,c,n,s,p+f,e.left.codePointAt(0),m,y),h&&v(o,c,n,s+r-1,p+f,e.right.codePointAt(0),m,y)}function U(t){if(t._hidden)return"";if(t.text!==void 0)return t.text;const o=t.children.map(U).join("");return typeof t.transform=="function"?t.transform(o,0):o}function Y(t,o,c,n,s,p,r,x,_,T){if(r<=0||x<=0)return;let g=0,y=0;for(const e of t){if(e===`
2
+ `){g=0,y++;continue}const a=e.codePointAt(0)??32,m=F(e);if(g+m>r&&(g=0,y++),y>=x)break;if(m>r){v(o,c,n,s+g,p+y,32,_,T),g+=1;continue}v(o,c,n,s+g,p+y,a,_,T),m===2&&g+1<r&&v(o,c,n,s+g+1,p+y,j,_,T),g+=m}}function N(t,o,c,n,s,p,r,x,_,T,g){if(t._hidden)return;const y=t.getLayout(),e=Math.round(s+y.left),a=Math.round(p+y.top),m=Math.round(y.width),d=Math.round(y.height),C=t.fg===255?r:t.fg,i=t.bg===255?x:t.bg,h=t.styles===0?_:t.styles,l={x0:Math.max(g.x0,e),x1:Math.min(g.x1,e+m),y0:Math.max(g.y0,a),y1:Math.min(g.y1,a+d)};if(l.x0>=l.x1||l.y0>=l.y1)return;if(typeof t.transform=="function"){const L=U(t),B=t.transform(L,0),A=h<<16|i<<8|C;Y(B,o,c,n,e,a,m,d,A,l);return}if(t.text===void 0){if(i!==255||h!==0){const L=h<<16|i<<8|C;for(let B=0;B<d;B++)for(let A=0;A<m;A++)v(o,c,n,e+A,a+B,32,L,l)}t._style?.borderStyle&&T.push({absX:e,absY:a,bg:i,clip:l,fg:C,h:d,node:t,styles:h,w:m})}else{const L=h<<16|i<<8|C;if(t.bg!==255)for(let B=0;B<d;B++)for(let A=0;A<m;A++)v(o,c,n,e+A,a+B,32,L,l);Y(t.text,o,c,n,e,a,m,d,L,l)}const b=t._style,R=b?.overflow??"visible",f=b?.overflowX??R,u=b?.overflowY??R,O=f==="hidden"||f==="scroll",M=u==="hidden"||u==="scroll";let P=l,E=0,S=0;if(O||M){const L=H(b);P={x0:O?Math.max(l.x0,e+L.left):l.x0,x1:O?Math.min(l.x1,e+m-L.right):l.x1,y0:M?Math.max(l.y0,a+L.top):l.y0,y1:M?Math.min(l.y1,a+d-L.bottom):l.y1},u==="scroll"&&typeof b?.scrollTop=="number"&&(S=-b.scrollTop),f==="scroll"&&typeof b?.scrollLeft=="number"&&(E=-b.scrollLeft)}for(const L of t.children)L._style?.internalStickyAlternate||N(L,o,c,n,e+E,a+S,C,i,h,T,P);(u==="scroll"||f==="scroll")&&b?.scrollbar!==!1&&q(t,o,c,n,e,a,m,d,C,h,l,b),u==="scroll"&&typeof b?.scrollTop=="number"&&z(t,o,c,n,e,a,m,d,C,i,h,T,P,b)}export{$ as renderTreeToBuffer};
@@ -0,0 +1,17 @@
1
+ import{w as xt,i as kt}from"./dom-xpeZzKuf.js";import{getStringWidth as J,isFullwidthCodePoint as Bt,indent as wt}from"@visulima/string";import{B as W,D as P,I as z,U as X,e as $,H as U,f as K,g as it,F as A,h as st,S as Mt,j as Lt,p as Rt}from"./measure-text-DtlK6gar.js";import B from"yoga-layout";import{j as F,i as _t,n as nt,c as lt}from"./measure-element-pHwUPovG.js";import{g as Ot,c as j}from"./colorize-Dsbi0Wr0.js";import Ht from"@visulima/colorize";import{c as Dt}from"./boxes-CidWUOVk.js";import{getScrollTop as vt}from"./calculateScroll-jdxVlcmq.js";import Nt from"./squashTextNodesWithMap-CUJZZeW3.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ const require = __cjs_mod__.createRequire(import.meta.url);
3
+ const It=1114112,Wt=1,Pt=2,Gt=3,At=4,Ft=7,Yt=8,zt=9,ct=22,at=23,ut=24,ht=27,dt=28,ft=29,gt=39,pt=49,Xt="\x1B[",N=o=>o.length===0?"":`${Xt}${o.join(";")}m`,$t=o=>{if(o.length===0)return"";let e="",t=0,r,s,l,i=!1,h=0;const p=o.getSpans();for(const f of p){const d=f.formatFlags&127,{fgColor:n}=f,{bgColor:c}=f,{link:u}=f,a=d;if(a!==t||n!==r||c!==s||u!==l){if(u!==l&&(l&&(e+=l.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),u)){const y=u.startsWith("ST:");e+=`\x1B]8;;${y?u.slice(3):u}${y?"\x1B\\":"\x07"}`}const g=t&(W|P),m=a&(W|P);if(g!==m){const y=t&W&&!(a&W),C=t&P&&!(a&P);(y||C)&&(e+=N([ct])),a&W&&(!(t&W)||C)&&(e+=N([Wt])),a&P&&(!(t&P)||y)&&(e+=N([Pt]))}a&z&&!(t&z)?e+=N([Gt]):!(a&z)&&t&z&&(e+=N([at])),a&X&&!(t&X)?e+=N([At]):!(a&X)&&t&X&&(e+=N([ut])),a&$&&!(t&$)?e+=N([Ft]):!(a&$)&&t&$&&(e+=N([ht])),a&U&&!(t&U)?e+=N([Yt]):!(a&U)&&t&U&&(e+=N([dt])),a&K&&!(t&K)?e+=N([zt]):!(a&K)&&t&K&&(e+=N([ft])),n!==r&&(e+=N(n?it(n,!0):[gt])),c!==s&&(e+=N(c?it(c,!1):[pt])),i=a!==0||n!==void 0||c!==void 0,t=a,r=n,s=c,l=u}e+=o.getTextRange(h,h+f.length),h+=f.length}return i&&(t&(W|P)&&(e+=N([ct])),t&z&&(e+=N([at])),t&X&&(e+=N([ut])),t&$&&(e+=N([ht])),t&U&&(e+=N([dt])),t&K&&(e+=N([ft])),r!==void 0&&(e+=N([gt])),s!==void 0&&(e+=N([pt]))),l&&(e+=l.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),e};class Z{widths=new Map;blockWidths=new Map;styledLines=new Map;lines=new Map;maxEntries;pruneToFactor;constructor(e={}){const{maxEntries:t=3e4,pruneToFactor:r=.8}=e;this.maxEntries=Math.max(1,t),this.pruneToFactor=Math.min(.99,Math.max(.1,r))}getStyledLine(e){let t=this.styledLines.get(e);return t===void 0&&(t=this.hasAnsiControlMarker(e)?Lt(e):Rt(e),this.setCacheEntry(this.styledLines,e,t)),t}getStringWidth(e){let t=this.widths.get(e);return t===void 0&&(t=J(e),this.setCacheEntry(this.widths,e,t)),t}getWidestLine(e){let t=this.blockWidths.get(e);if(t===void 0){let r=0;for(const s of this.getLines(e))r=Math.max(r,this.getStringWidth(s));t=r,this.setCacheEntry(this.blockWidths,e,t)}return t}getLines(e){let t=this.lines.get(e);return t===void 0&&(t=e.split(`
4
+ `),this.setCacheEntry(this.lines,e,t)),t}hasAnsiControlMarker(e){for(const t of e){const r=t.codePointAt(0);if(Ut.has(r))return!0}return!1}setCacheEntry(e,t,r){!e.has(t)&&e.size>=this.maxEntries&&this.pruneCache(e),e.set(t,r)}pruneCache(e){const t=Math.floor(this.maxEntries*this.pruneToFactor);for(const r of e.keys())if(e.delete(r),e.size<=t)break}}const Ut=new Set([27,144,152,155,157,158,159]),Kt=.6,Vt=30;class tt{width;height;caches;grid;clipStack=[];previousLines=[];previousRenderedLines=[];lineMemoizationEnabled=!0;memoizationProbeCountdown=0;constructor(e){const{caches:t,height:r,width:s}=e;this.width=Math.round(s),this.height=Math.round(r),this.caches=t??new Z,this.grid=this.createGrid(this.width,this.height)}reset(e,t){this.width=Math.round(e),this.height=Math.round(t),this.clipStack.length=0,this.grid=this.createGrid(this.width,this.height)}startChildRegion(e,t,r,s){const l=Math.round(e),i=Math.round(t);this.clipStack.push({x1:l,x2:l+Math.round(r),y1:i,y2:i+Math.round(s)})}endChildRegion(){this.clipStack.pop()}write(e,t,r,s){if(!r)return;const{transformers:l}=s,i=this.clipStack.at(-1),h=this.caches.getLines(r),p=l.length>0;for(const[f,d]of h.entries()){const n=t+f;if(n<0||n>=this.grid.length||i&&(n<i.y1||n>=i.y2))continue;let c=d;if(p)for(const R of l)c=R(c,f);if(c.length===0)continue;const u=this.grid[n],a=this.caches.getStyledLine(c);let g=e;const m=i?Math.min(i.x2,u.length):1/0,y=a.getSpans();let C=0,E=y[0]?.length??0;for(let R=0;R<a.length;R++){for(;C<y.length&&R>=E;)C++,E+=y[C]?.length??0;if(g>=m)break;if(i&&(g<i.x1||g>=i.x2)){g++,a.getFullWidth(R)&&g++;continue}if(g>=0){g>=u.length&&u.ensureWidth(g+2);const v=y[C],M=a.getFullWidth(R),S=(v?.formatFlags??0)|(M?A:0);u.setCharFast(g,a.getValue(R),S,v?.fgColor,v?.bgColor,v?.link),M&&(g++,g>=u.length&&u.ensureWidth(g+1),u.setCharFast(g,"",S&~A,v?.fgColor,v?.bgColor,v?.link))}g++}}}writeStyledLine(e,t,r){if(r.length===0||t<0||t>=this.grid.length)return;const s=this.clipStack.at(-1);s&&(t<s.y1||t>=s.y2)||this.writeStyledLineToRow(this.grid[t],e,r,this.width,s)}getRootLines(){return this.grid}getCurrentClip(){return this.clipStack.at(-1)}addRegionTree(e,t,r){for(let s=0;s<e.height;s++){const l=r+s;if(l<0||l>=this.grid.length)continue;const i=e.lines[s];if(!i)continue;const h=this.grid[l],p=i.getSpans();let f=0,d=p[0]?.length??0;for(let n=0;n<i.length;n++){for(;f<p.length&&n>=d;)f++,d+=p[f]?.length??0;const c=t+n;if(c<0||c>=h.length)continue;const u=i.getValue(n),a=p[f],g=a!==void 0&&(a.formatFlags&~A)!==0||a?.fgColor!==void 0||a?.bgColor!==void 0||a?.link!==void 0;if(u!==" "||g){const m=(a?.formatFlags??0)|(i.getFullWidth(n)?A:0);h.setCharFast(c,u,m,a?.fgColor,a?.bgColor,a?.link)}}}for(const s of e.children)this.addRegionTree(s,t+s.x,r+s.y)}writeStyledLineToRow(e,t,r,s,l){let i=t;const h=l?Math.min(l.x2,s):1/0,p=r.getSpans();let f=0,d=p[0]?.length??0;for(let n=0;n<r.length;n++){for(;f<p.length&&n>=d;)f++,d+=p[f]?.length??0;if(i>=h)break;if(l&&(i<l.x1||i>=l.x2)){i++,r.getFullWidth(n)&&i++;continue}if(i>=0){i>=e.length&&e.ensureWidth(i+2);const c=p[f],u=r.getFullWidth(n),a=(c?.formatFlags??0)|(u?A:0);e.setCharFast(i,r.getValue(n),a,c?.fgColor,c?.bgColor,c?.link),u&&(i++,i>=e.length&&e.ensureWidth(i+1),e.setCharFast(i,"",a&~A,c?.fgColor,c?.bgColor,c?.link))}i++}}get(){const e=this.grid;this.lineMemoizationEnabled||(this.memoizationProbeCountdown>0?this.memoizationProbeCountdown--:this.lineMemoizationEnabled=!0);const t=this.lineMemoizationEnabled,r=this.previousLines.length>0,s=t&&r&&this.previousLines.length===e.length&&this.previousRenderedLines.length===e.length;this.previousLines.length>e.length&&(this.previousLines.length=e.length),this.previousRenderedLines.length>e.length&&(this.previousRenderedLines.length=e.length);const l=Array.from({length:e.length});let i=0;for(const[h,p]of e.entries()){const f=p;if(s&&this.previousLines[h]?.equals(f)){l[h]=this.previousRenderedLines[h]??"";continue}i++;const d=f.trimEnd(),n=$t(d);l[h]=n,t&&(this.previousRenderedLines[h]=n,this.previousLines[h]=f.clone())}return t&&s&&e.length>0&&i/e.length>Kt&&this.disableLineMemoization(),{height:e.length,output:l.join(`
5
+ `)}}getBuffer(){const e=this.grid,t=e.length,r=new Uint32Array(this.width*t*2),s=65535;for(let l=0;l<r.length;l+=2)r[l]=32,r[l+1]=s;for(let l=0;l<t;l++){const i=e[l],h=i.getSpans();let p=0,f=h[0]?.length??0;for(let d=0;d<i.length&&d<this.width;d++){for(;p<h.length&&d>=f;)p++,f+=h[p]?.length??0;const n=i.getValue(d);if(n.length===0)continue;const c=n.codePointAt(0)??32,u=(l*this.width+d)*2,a=h[p],g=a?.formatFlags??0,m=a?.fgColor,y=a?.bgColor,C=m?st(m):255,E=y?st(y):255,v=(g&255)<<16|(E&255)<<8|C&255;if(r[u]=c,r[u+1]=v,i.getFullWidth(d)&&d+1<this.width){const M=u+2;r[M]=It,r[M+1]=v,d++}}}return{buffer:r,height:t}}createGrid(e,t){const r=[];for(let s=0;s<t;s++)r.push(Mt.empty(e));return r}disableLineMemoization(){this.lineMemoizationEnabled=!1,this.memoizationProbeCountdown=Vt,this.previousLines.length=0,this.previousRenderedLines.length=0}}const qt=o=>Math.round(o.getComputedWidth()-Math.max(0,o.getComputedLeft()+o.getComputedWidth()-(o.getParent()?.getComputedWidth()??o.getComputedWidth()))-o.getComputedPadding(B.EDGE_LEFT)-o.getComputedPadding(B.EDGE_RIGHT)-o.getComputedBorder(B.EDGE_LEFT)-o.getComputedBorder(B.EDGE_RIGHT)),jt=(o,e,t,r)=>{if(!t.style.backgroundColor)return;const s=Math.round(t.yogaNode.getComputedWidth()),l=Math.round(t.yogaNode.getComputedHeight()),i=t.style.borderStyle&&t.style.borderLeft!==!1?1:0,h=t.style.borderStyle&&t.style.borderRight!==!1?1:0,p=t.style.borderStyle&&t.style.borderTop!==!1?1:0,f=t.style.borderStyle&&t.style.borderBottom!==!1?1:0,d=s-i-h,n=l-p-f;if(!(d>0&&n>0))return;const c=Ot(t.style.backgroundColor);if(!c)return;const u=`${c}${" ".repeat(d)}\x1B[49m`;for(let a=0;a<n;a++)r.write(o+i,e+p+a,u,{transformers:[]})},D=(o,e,t,r)=>{let s=j(o,e,"foreground");return s=j(s,t,"background"),r&&(s=Ht.dim(s)),s},mt=(o,e,t,r,s,l,i,h)=>{if(!t&&!s)return D(o.repeat(e),l,i,h);const p=t?` ${t} `:"",f=s?` ${s} `:"",d=p.length,n=f.length,c=r??"left";if(d+n>=e){if(d>=e)return`${p.slice(0,e-1)}…`;const m=e-d;return m>3?p+f.slice(0,m):p+D(o.repeat(e-d),l,i,h)}const u=e-d-n;if(c==="left"||s)return p+D(o.repeat(u),l,i,h)+f;if(c==="right"){const m=e-d;return D(o.repeat(m),l,i,h)+p}const a=Math.floor(u/2),g=u-a;return D(o.repeat(a),l,i,h)+p+D(o.repeat(g),l,i,h)},Jt=(o,e,t,r)=>{if(t.style.borderStyle){const s=Math.round(t.yogaNode.getComputedWidth()),l=Math.round(t.yogaNode.getComputedHeight()),i=typeof t.style.borderStyle=="string"?Dt[t.style.borderStyle]:t.style.borderStyle,h=t.style.borderTopColor??t.style.borderColor,p=t.style.borderBottomColor??t.style.borderColor,f=t.style.borderLeftColor??t.style.borderColor,d=t.style.borderRightColor??t.style.borderColor,n=t.style.borderTopBackgroundColor??t.style.borderBackgroundColor,c=t.style.borderBottomBackgroundColor??t.style.borderBackgroundColor,u=t.style.borderLeftBackgroundColor??t.style.borderBackgroundColor,a=t.style.borderRightBackgroundColor??t.style.borderBackgroundColor,g=t.style.borderTopDimColor??t.style.borderDimColor,m=t.style.borderBottomDimColor??t.style.borderDimColor,y=t.style.borderLeftDimColor??t.style.borderDimColor,C=t.style.borderRightDimColor??t.style.borderDimColor,E=t.style.borderTop!==!1,R=t.style.borderBottom!==!1,v=t.style.borderLeft!==!1,M=t.style.borderRight!==!1,S=Math.max(0,s-(v?1:0)-(M?1:0));let T;if(E){const L=v?D(i.topLeft,h,n,g):"",O=M?D(i.topRight,h,n,g):"",H=mt(i.top,S,t.style.borderTopTitle,t.style.borderTopTitleAlignment,t.style.borderTopRightTitle,h,n,g);T=L+H+O}let b=l;E&&(b-=1),R&&(b-=1),b=Math.max(0,b);let x="";v&&(x=`${D(i.left,f,u,y)}
6
+ `.repeat(b));let _="";M&&(_=`${D(i.right,d,a,C)}
7
+ `.repeat(b));let w;if(R){const L=v?D(i.bottomLeft,p,c,m):"",O=M?D(i.bottomRight,p,c,m):"",H=mt(i.bottom,S,t.style.borderBottomTitle,t.style.borderBottomTitleAlignment,void 0,p,c,m);w=L+H+O}const k=E?1:0;T&&r.write(o,e,T,{transformers:[]}),x&&r.write(o,e+k,x,{transformers:[]}),_&&r.write(o+s-1,e+k,_,{transformers:[]}),w&&r.write(o,e+l-1,w,{transformers:[]})}},yt=[],Ct=({axis:o,color:e,layout:t,output:r})=>{const{thumb:{end:s,endHalf:l,start:i,startHalf:h},x:p,y:f}=t;if(o==="vertical")for(let d=i;d<s;d++){let n="█";const c=2*d>=h&&2*d<l,u=2*d+1>=h&&2*d+1<l;c&&!u?n="▀":!c&&u&&(n="▄");const a=e?j(n,e,"foreground"):n;r.write(p,f+d,a,{transformers:yt})}else for(let d=i;d<s;d++){let n="█";const c=2*d>=h&&2*d<l,u=2*d+1>=h&&2*d+1<l;c&&!u?n="▌":!c&&u&&(n="▐");const a=e?j(n,e,"foreground"):n;r.write(p+d,f,a,{transformers:yt})}},bt=(o,e=[])=>{for(const t of o.childNodes){if(t.nodeName==="#text")continue;const r=t;if(!r.internal_stickyAlternate)if(r.internal_sticky)e.push({node:r,type:r.internal_sticky==="bottom"?"bottom":"top"});else{const s=r.style.overflow??"visible",l=r.style.overflowX??s,i=r.style.overflowY??s;!(l==="scroll"||i==="scroll")&&r.childNodes&&bt(r,e)}}return e},Qt=(o,e,t,r)=>{let s,l=-1,i,h=-1;for(const[f,d]of o.entries()){const{node:n,type:c}=d;if(!n.yogaNode)continue;const u=F(n,e)??0,a=Math.round(n.yogaNode.getComputedHeight()),g=u+a,m=n.parentNode;let y=0,C=Number.MAX_SAFE_INTEGER;m?.yogaNode&&(y=F(m,e)??0,C=Math.round(m.yogaNode.getComputedHeight())),c==="top"&&u<t&&y+C>t&&(s=d,l=f),c==="bottom"&&Math.floor(g)>Math.floor(r)&&y<r&&(i=d,h=f)}const p=[];if(s){let f;for(let d=l+1;d<o.length;d++){const n=o[d];if(n.type!=="bottom"){f=n;break}}p.push({nextStickyNodeInfo:f,stickyNode:s.node,type:"top"})}if(i){let f;for(let d=h-1;d>=0;d--){const n=o[d];if(n.type==="bottom"){f=n;break}}p.push({nextStickyNodeInfo:f,stickyNode:i.node,type:"bottom"})}return p},Zt=(o,e,t,r,s)=>{const{newTransformers:l,renderNodeToOutput:i,skipStaticElements:h,x:p,y:f}=s,{yogaNode:d}=e;if(!d)return;const n=d.getComputedBorder(B.EDGE_TOP),c=d.getComputedBorder(B.EDGE_LEFT),u=vt(e),a=e.internal_scrollState?.clientHeight??0;for(const{nextStickyNodeInfo:g,stickyNode:m,type:y}of o){if(!m.yogaNode)continue;const C=F(m,e)??0,E=Math.round(m.yogaNode.getComputedHeight()),R=p+(_t(m,e)??0),v=m.parentNode;let M=0,S=Number.MAX_SAFE_INTEGER;v?.yogaNode&&(M=F(v,e)??0,S=Math.round(v.yogaNode.getComputedHeight()));let T;if(y==="top"){const w=v?.yogaNode?.getComputedBorder(B.EDGE_BOTTOM)??0,k=M+S-w;let L=f-u+k-E;const O=f-u+C,H=f+n;if(g?.node?.yogaNode){const I=F(g.node,e)??0,q=f-u+I-E;q<L&&(L=q)}T=Math.min(Math.max(H,O),L)}else{const w=v?.yogaNode?.getComputedBorder(B.EDGE_TOP)??0;let k=f-u+M+w;const L=f-u+C,O=f+n+a-E;if(g?.node?.yogaNode){const H=Math.round(g.node.yogaNode.getComputedHeight()),I=F(g.node,e)??0,G=f-u+I+H;G>k&&(k=G)}T=Math.max(Math.min(O,L),k)}const b=r({height:E,width:Math.round(m.yogaNode.getComputedWidth())});i(m,b,{offsetX:-Math.round(m.yogaNode.getComputedLeft()),offsetY:-Math.round(m.yogaNode.getComputedTop()),skipStaticElements:h,transformers:l});const _=b.get().output.split(`
8
+ `);for(const[w,k]of _.entries())k&&k.length>0&&t.write(R-(p+c),T-(f+n)+w,k,{transformers:[]})}},te=(o,e)=>{const t=o.childNodes[0]?.yogaNode;if(t){const r=Math.round(t.getComputedLeft()),s=Math.round(t.getComputedTop());e=`
9
+ `.repeat(s)+wt(e,r)}return e},ee=31,oe=127,re=128,ie=159,se=(o,e)=>{if(!Number.isFinite(e))return!1;if(e<0)return!0;let t=0;for(const r of o){if(r===`
10
+ `){if(t>e)return!0;t=0;continue}const s=r.codePointAt(0);if(s<=ee||s===oe||s>=re&&s<=ie||Bt(s)||(t++,t>e))return!0}return!1},ne=o=>(o.internal_hidden??!1)||o.yogaNode?.getDisplay()===B.DISPLAY_NONE,le=o=>{let e=o;for(;e;){if(ne(e))return!0;e=e.parentNode}return!1},Q=(o,e={})=>{if(e.skipStaticElements&&o.internal_static||o.internal_hidden||o.internal_stickyAlternate||o.yogaNode?.getDisplay()===B.DISPLAY_NONE)return"";let t="";if(o.nodeName==="ink-text")t=Nt(o);else if(o.nodeName==="ink-box"||o.nodeName==="ink-root"){const r=o.style.flexDirection==="row"||o.style.flexDirection==="row-reverse"?" ":`
11
+ `;t=(o.style.flexDirection==="row-reverse"||o.style.flexDirection==="column-reverse"?o.childNodes.toReversed():[...o.childNodes]).map(l=>Q(l,{parentRole:o.internal_accessibility?.role,skipStaticElements:e.skipStaticElements})).filter(Boolean).join(r)}if(o.internal_accessibility){const{role:r,state:s}=o.internal_accessibility;if(s){const i=Object.keys(s).filter(h=>s[h]).join(", ");i&&(t=`(${i}) ${t}`)}r&&r!==e.parentRole&&(t=`${r}: ${t}`)}return t},V=(o,e,t)=>{const{absoluteOffsetX:r,absoluteOffsetY:s,offsetX:l=0,offsetY:i=0,renderState:h,selectionMap:p,skipStaticElements:f,transformers:d=[]}=t;if(f&&o.internal_static||o.internal_hidden)return;if(o.cachedRender){const c=Math.round(l+(o.yogaNode?.getComputedLeft()??0)),u=Math.round(i+(o.yogaNode?.getComputedTop()??0));e.addRegionTree(o.cachedRender,c,u);return}if(o.nodeName==="ink-cursor"){if(!h)return;h.cursorRequested=!0;const c=o.internal_cursor;if(!c){h.cursorPosition=void 0;return}if(h.cursorShape=c.shape,c.inline){if(h.lastTextWriteEnd)h.cursorPosition={x:h.lastTextWriteEnd.x,y:h.lastTextWriteEnd.y};else{const g=o.parentNode?nt(o.parentNode):void 0;h.cursorPosition=g?{x:g.x,y:g.y}:void 0}return}const u=c.anchorRef?c.anchorRef.current:o.parentNode;if(!u){h.cursorPosition=void 0;return}if(c.anchorRef&&le(u)){h.cursorPosition=void 0;return}const a=nt(u);if(!a){h.cursorPosition=void 0;return}h.cursorPosition={x:a.x+c.x,y:a.y+c.y};return}const{yogaNode:n}=o;if(n){if(n.getDisplay()===B.DISPLAY_NONE)return;const c=n.getComputedLeft(),u=n.getComputedTop(),a=Math.round(l+c),g=Math.round(i+u),m=Math.round((r??l)+c),y=Math.round((s??i)+u),C=e.getCurrentClip();if(C){const S=Math.round(n.getComputedWidth()),T=Math.round(n.getComputedHeight()),b=m+S,x=y+T,_=C.x1??-1/0,w=C.x2??1/0,k=C.y1??-1/0,L=C.y2??1/0;if(b<=_||m>=w||x<=k||y>=L)return}let E=d;if(typeof o.internal_transform=="function"&&(E=[o.internal_transform,...d]),o.nodeName==="ink-text"){let S=Nt(o);if(S.length>0){const T=qt(n);if(se(S,T)&&Math.max(...S.split(`
12
+ `).map(x=>J(x)))>T){const x=o.style.textWrap??"wrap";S=xt(S,Math.floor(T),x)}if(S=te(o,S),e.write(a,g,S,{transformers:E}),h){const b=S.split(`
13
+ `),x=b.at(-1)??"";h.lastTextWriteEnd={x:a+J(x),y:g+b.length-1}}}return}let R=!1,v=0,M=0;if(o.nodeName==="ink-box"){jt(a,g,o,e),Jt(a,g,o,e);const S=o.style.overflow??"visible",T=o.style.overflowX??S,b=o.style.overflowY??S,x=T==="hidden"||T==="scroll",_=b==="hidden"||b==="scroll";if(x||_){const w=Math.round(n.getComputedWidth()),k=Math.round(n.getComputedHeight()),L=x?a+n.getComputedBorder(B.EDGE_LEFT):a,O=x?w-n.getComputedBorder(B.EDGE_LEFT)-n.getComputedBorder(B.EDGE_RIGHT):w,H=_?g+n.getComputedBorder(B.EDGE_TOP):g,I=_?k-n.getComputedBorder(B.EDGE_TOP)-n.getComputedBorder(B.EDGE_BOTTOM):k;e.startChildRegion(L,H,Math.max(0,O),Math.max(0,I)),R=!0,b==="scroll"&&o.internal_scrollState&&(M=-o.internal_scrollState.scrollTop),T==="scroll"&&o.internal_scrollState&&(v=-o.internal_scrollState.scrollLeft)}}if(o.nodeName==="ink-root"||o.nodeName==="ink-box"||o.nodeName==="ink-static-render"){for(const S of o.childNodes)V(S,e,{absoluteOffsetX:m+v,absoluteOffsetY:y+M,offsetX:a+v,offsetY:g+M,renderState:h,selectionMap:p,skipStaticElements:f,transformers:E});if(o.nodeName==="ink-box"&&o.internal_scrollState){const S=bt(o);if(S.length>0){const T=vt(o),b=o.internal_scrollState.clientHeight,x=T+b,_=Qt(S,o,T,x);_.length>0&&Zt(_,o,e,k=>new tt(k),{newTransformers:E,renderNodeToOutput:V,skipStaticElements:f,x:a,y:g})}}if(o.nodeName==="ink-box"&&o.internal_scrollState){const S=o.style.overflow??"visible",T=o.style.overflowX??S,b=o.style.overflowY??S,x=n.getComputedBorder(B.EDGE_LEFT),_=n.getComputedBorder(B.EDGE_RIGHT),w=n.getComputedBorder(B.EDGE_TOP),k=n.getComputedBorder(B.EDGE_BOTTOM),L=Math.round(n.getComputedWidth()-x-_),O=Math.round(n.getComputedHeight()-w-k),{clientHeight:H,clientWidth:I,scrollHeight:G,scrollLeft:q,scrollTop:Et,scrollWidth:et}=o.internal_scrollState,ot=b==="scroll"&&G>H,Tt=T==="scroll"&&et>I,rt=o.internal_scrollbar!==!1;if(ot&&rt){const Y=lt({axis:"vertical",clientDimension:H,hasOppositeScrollbar:!1,height:O,marginBottom:0,marginRight:0,scrollDimension:G,scrollPosition:Et,width:L,x:a+x,y:g+w});Y&&Ct({axis:"vertical",color:o.style.scrollbarThumbColor,layout:Y,output:e})}if(Tt&&rt){const Y=lt({axis:"horizontal",clientDimension:I,hasOppositeScrollbar:ot,height:O,marginBottom:0,marginRight:0,scrollDimension:et,scrollPosition:q,width:L,x:a+x,y:g+w});Y&&Ct({axis:"horizontal",color:o.style.scrollbarThumbColor,layout:Y,output:e})}}R&&e.endChildRegion()}}},Ee=(o,e)=>{if(!o.yogaNode)return;const t=Math.round(o.yogaNode.getComputedWidth()),r=Math.round(o.yogaNode.getComputedHeight());if(t<=0||r<=0)return;const{setCachedRender:s}=require("./dom"),l=new tt({height:r,width:t});for(const h of o.childNodes)V(h,l,{skipStaticElements:e?.skipStaticElements});const i={children:[],cursorPosition:void 0,height:r,id:o.internalId??"static",isScrollable:!1,lines:[...l.getRootLines()],selectableSpans:[],stickyHeaders:[],styledOutput:[...l.getRootLines()],width:t,x:0,y:0};s(o,i)},ce=(o,e)=>{const t=new Map;if(e.rangeCount===0)return t;const r=e.getRangeAt(0),{endContainer:s,endOffset:l,startContainer:i,startOffset:h}=r;if(!i||!s)return t;let p=!1,f=!1;const d=(c,u,a,g,m,y)=>{if(c.nodeName==="#text"){const{length:C}=c.nodeValue;i===c&&(m.value=!0,a.value=u.value+h),s===c&&(y.value=!0,g.value=u.value+l),u.value+=C}else if("childNodes"in c){for(const C of c.childNodes)c===i&&(m.value=!0,a.value=u.value),c===s&&(y.value=!0,g.value=u.value),d(C,u,a,g,m,y);c===i&&h===c.childNodes.length&&(m.value=!0,a.value=u.value),c===s&&l===c.childNodes.length&&(y.value=!0,g.value=u.value)}},n=c=>{if(c.nodeName==="ink-text"){if(!kt(c))return;const u={value:0},a={value:-1},g={value:-1},m={value:!1},y={value:!1};for(const C of c.childNodes)c===i&&(m.value=!0,a.value=u.value),c===s&&(y.value=!0,g.value=u.value),d(C,u,a,g,m,y);if(c===i&&h===c.childNodes.length&&(m.value=!0,a.value=u.value),c===s&&l===c.childNodes.length&&(y.value=!0,g.value=u.value),(p||m.value)&&(!f||y.value)){const C=m.value?a.value:0,E=y.value?g.value:u.value;C!==-1&&E!==-1&&C<E&&t.set(c,{end:E,start:C})}m.value&&(p=!0),y.value&&(f=!0)}else{const{childNodes:u}=c;if(u){for(const a of u)c===i&&(p=!0),c===s&&(f=!0),n(a);c===i&&h===u.length&&(p=!0),c===s&&l===u.length&&(f=!0)}}};return n(o),t},ae=new Z,ue=new Z,he=new WeakMap,de=new WeakMap,St=({caches:o,height:e,node:t,outputs:r,width:s})=>{let l=r.get(t);return l||(l=new tt({caches:o,height:e,width:s}),r.set(t,l)),l.reset(s,e),l},Te=(o,e,t)=>{if(o.yogaNode){if(e){const f=Q(o,{skipStaticElements:!0}),d=f===""?0:f.split(`
14
+ `).length;let n="";return o.staticNode&&(n=Q(o.staticNode,{skipStaticElements:!1})),{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:f,outputHeight:d,staticOutput:n?`${n}
15
+ `:""}}const r=t?.selection&&t.selection.rangeCount>0?ce(o,t.selection):void 0,s=St({caches:ae,height:o.yogaNode.getComputedHeight(),node:o,outputs:he,width:o.yogaNode.getComputedWidth()}),l={cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0};V(o,s,{renderState:l,selectionMap:r,skipStaticElements:!0});let i;if(o.staticNode?.yogaNode&&(i=St({caches:ue,height:o.staticNode.yogaNode.getComputedHeight(),node:o,outputs:de,width:o.staticNode.yogaNode.getComputedWidth()}),V(o.staticNode,i,{skipStaticElements:!1})),t?.useNativeRenderer){const{buffer:f,height:d}=s.getBuffer();return{cursorPosition:l.cursorPosition,cursorRequested:l.cursorRequested,cursorShape:l.cursorShape,output:"",outputBuffer:f,outputHeight:d,outputWidth:s.width,staticOutput:i?`${i.get().output}
16
+ `:""}}const{height:h,output:p}=s.get();return{cursorPosition:l.cursorPosition,cursorRequested:l.cursorRequested,cursorShape:l.cursorShape,output:p,outputHeight:h,staticOutput:i?`${i.get().output}
17
+ `:""}}return{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:"",outputHeight:0,staticOutput:""}};export{tt as O,V as a,Ee as b,Te as r};
@@ -1,4 +1,4 @@
1
- import { b as DOMNode, e as StyledLine } from "./dom.d-CLGlidfI.js";
1
+ import { a as DOMNode, S as StyledLine } from "./dom.d-BV2bnRcH.js";
2
2
  /**
3
3
  * Compare the document position of two points in the DOM tree.
4
4
  * Returns -1 if A is before B, 0 if equal, 1 if A is after B.
@@ -0,0 +1 @@
1
+ import{h as d,t as u}from"./ansi-tokenizer-D5k5LzXg.js";const h=/^[\d:;]*$/,f="\x1B]8;",x="8;",m=n=>n.startsWith(f)||n.startsWith(x),p=n=>{if(!d(n))return n;let i="";for(const t of u(n)){if(t.type==="text"){i+=t.value;continue}if(t.type==="osc"&&m(t.value)){i+=t.value;continue}t.type==="csi"&&t.finalCharacter==="m"&&t.intermediateString===""&&h.test(t.parameterString)&&(i+=t.value)}return i},N=n=>{let i="";for(let t=0;t<n.childNodes.length;t++){const r=n.childNodes[t];if(r===void 0)continue;let s="";r.nodeName==="#text"?s=r.nodeValue:((r.nodeName==="ink-text"||r.nodeName==="ink-virtual-text")&&(s=N(r)),s.length>0&&typeof r.internal_transform=="function"&&(s=r.internal_transform(s,t))),i+=s}return p(i)},g=(n,i,t)=>{if(n.internal_textCache){const{map:o,text:e}=n.internal_textCache;for(const[a,c]of o.entries())i.set(a,{end:c.end+t.current,start:c.start+t.current});return t.current+=e.length,e}let r="";const s=new Map,l={current:0};for(let o=0;o<n.childNodes.length;o++){const e=n.childNodes[o];if(e===void 0)continue;let a="";const c=l.current;e.nodeName==="#text"?(a=e.nodeValue,s.set(e,{end:c+a.length,start:c}),l.current+=a.length):((e.nodeName==="ink-text"||e.nodeName==="ink-virtual-text")&&(a=g(e,s,l),s.set(e,{end:l.current,start:c})),a.length>0&&typeof e.internal_transform=="function"&&(a=e.internal_transform(a,o))),r+=a}n.internal_textCache={map:s,text:r};for(const[o,e]of s.entries())i.set(o,{end:e.end+t.current,start:e.start+t.current});return t.current+=r.length,r};export{N as default,g as squashTextNodesWithMap};
@@ -0,0 +1 @@
1
+ import{createRequire as c}from"node:module";import{createContext as t}from"react";const r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:e,e=r,s=t({stderr:e.stderr,write(){}});s.displayName="InternalStderrContext";export{s as S};
@@ -0,0 +1 @@
1
+ import{createRequire as o}from"node:module";import{createContext as l}from"react";let i;const a=t=>(i??=o(import.meta.url))(t),e=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:r,c=t=>{if(typeof e<"u"&&e.versions&&e.versions.node){const[n,s]=e.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return e.getBuiltinModule(t)}return a(t)},{EventEmitter:d}=c("node:events"),r=e,u=l({internal_eventEmitter:new d,internal_exitOnCtrlC:!0,isRawModeSupported:!1,setBracketedPasteMode(){},setRawMode(){},stdin:r.stdin});u.displayName="InternalStdinContext";export{u as S};
@@ -0,0 +1 @@
1
+ import{createRequire as c}from"node:module";import{createContext as o}from"react";const t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:e,e=t,s=o({stdout:e.stdout,write(){}});s.displayName="InternalStdoutContext";export{s as S};
@@ -1,6 +1,40 @@
1
1
  import { AnsiColors } from '@visulima/colorize';
2
- import { LiteralUnion } from 'type-fest';
3
- import 'yoga-layout';
2
+ /**
3
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
4
+
5
+ @category Type
6
+ */
7
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
8
+ /**
9
+ Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
10
+
11
+ Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
12
+
13
+ This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
14
+
15
+ @example
16
+ ```
17
+ import type {LiteralUnion} from 'type-fest';
18
+
19
+ // Before
20
+
21
+ type Pet = 'dog' | 'cat' | string;
22
+
23
+ const petWithoutAutocomplete: Pet = '';
24
+ // Start typing in your TypeScript-enabled IDE.
25
+ // You **will not** get auto-completion for `dog` and `cat` literals.
26
+
27
+ // After
28
+
29
+ type Pet2 = LiteralUnion<'dog' | 'cat', string>;
30
+
31
+ const petWithAutoComplete: Pet2 = '';
32
+ // You **will** get auto-completion for `dog` and `cat` literals.
33
+ ```
34
+
35
+ @category Type
36
+ */
37
+ type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
4
38
  /**
5
39
  Style of the box border.
6
40
  */
@@ -482,4 +516,4 @@ type Styles = {
482
516
  */
483
517
  readonly width?: number | string;
484
518
  };
485
- export { Styles as S };
519
+ export { LiteralUnion as L, Styles as S };
@@ -0,0 +1,44 @@
1
+ import { Writable } from 'node:stream';
2
+ type TerminalPalette = {
3
+ readonly background: string;
4
+ readonly colors: ReadonlyArray<string>;
5
+ readonly cursor: string;
6
+ readonly foreground: string;
7
+ };
8
+ /**
9
+ * Check if the terminal likely supports OSC palette queries.
10
+ * @returns Whether a palette query is worth attempting.
11
+ */
12
+ declare const isTerminalPaletteQuerySupported: () => boolean;
13
+ /**
14
+ * The slice of a readable stream a probe needs.
15
+ *
16
+ * Narrower than `NodeJS.ReadableStream` so a caller can hand in any object with these four members
17
+ * — a test double included — without asserting it is a full stream.
18
+ */
19
+ interface ProbeStdin {
20
+ listenerCount: (event: string) => number;
21
+ on: (event: "data", listener: (chunk: Buffer | string) => void) => unknown;
22
+ pause: () => unknown;
23
+ removeListener: (event: "data", listener: (chunk: Buffer | string) => void) => unknown;
24
+ unshift: (chunk: string) => void;
25
+ }
26
+ /**
27
+ * Query the terminal for its current color palette.
28
+ *
29
+ * All queries go out in a single write and are answered against one listener, so an unresponsive
30
+ * terminal costs one `timeout` rather than one per query. The probe is shared per output stream:
31
+ * concurrent callers collapse onto one round trip, and the answer is reused for the process
32
+ * lifetime because a terminal's palette does not change underneath a running program.
33
+ *
34
+ * `signal` unsubscribes *this* caller; it does not cancel the shared probe, so a component
35
+ * unmounting mid-flight cannot discard the answer every other component is waiting for.
36
+ * @param stdin Readable stream (typically process.stdin in raw mode)
37
+ * @param stdout Writable stream (typically process.stdout)
38
+ * @param timeout Timeout in milliseconds for the whole batch (default: 500). Ignored when a probe
39
+ * for this stream is already in flight.
40
+ * @param signal Stops waiting; resolves with an empty palette
41
+ * @returns The colours the terminal reported. Missing entries mean it did not answer.
42
+ */
43
+ declare const queryTerminalPalette: (stdin: ProbeStdin, stdout: Writable, timeout?: number, signal?: AbortSignal) => Promise<Partial<TerminalPalette>>;
44
+ export { TerminalPalette as T, isTerminalPaletteQuerySupported as i, queryTerminalPalette as q };
@@ -0,0 +1,2 @@
1
+ import{getStringWidth as a}from"@visulima/string";const c={ambiguousIsNarrow:!0,emojiWidth:1};function u(t){return Math.max(1,a(t,c))}function f(t){return a(t,c)}function g(t,o){if(o<=0)return 0;if(t.length===0)return 1;let e=1,n=0;for(const i of t){const r=Math.min(u(i),o);n+r>o&&(e++,n=0),n+=r}return e}function l(t,o){const e=t.split(`
2
+ `);let n=0,i=0;for(const r of e){const s=f(r);s>n&&(n=s),i+=o>0?g(r,o):0}return{maxLineWidth:n,wrappedRows:i}}export{u as a,f as g,l as m};
@@ -0,0 +1 @@
1
+ import{createRequire as _}from"node:module";let g;const w=t=>(g??=_(import.meta.url))(t),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:n,f=t=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,s]=o.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return o.getBuiltinModule(t)}return w(t)},n=o,{execFileSync:b}=f("node:child_process"),c=f("node:fs"),y=f("node:tty"),d=80,p=24,l=(t,e,{shell:s,env:r}={})=>b(t,e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:s,env:r}).trim(),u=(t,e)=>({columns:Number.parseInt(t,10),rows:Number.parseInt(e,10)}),N=(t,e)=>{const{columns:s,rows:r}=u(t,e);if(!(Number.isNaN(s)||Number.isNaN(r))&&!(s===d&&r===p))return{columns:s,rows:r}},h=()=>{if(n.platform!=="linux")return!0;try{const t=c.readFileSync("/proc/self/stat","utf8"),e=t.lastIndexOf(") ");if(e===-1)return!1;const s=t.slice(e+2).trim().split(/\s+/),r=Number.parseInt(s[2],10),i=Number.parseInt(s[5],10);return Number.isNaN(r)||Number.isNaN(i)||i<=0?!1:r===i}catch{return!1}};function I(){const{env:t,stdout:e,stderr:s}=n;if(e?.columns&&e?.rows)return u(e.columns,e.rows);if(s?.columns&&s?.rows)return u(s.columns,s.rows);if(t.COLUMNS&&t.LINES)return u(t.COLUMNS,t.LINES);const r={columns:d,rows:p};return n.platform==="win32"?a()??r:n.platform==="darwin"?m()??a()??r:m()??a()??O()??r}const m=()=>{try{const t=n.platform==="darwin"?c.constants.O_EVTONLY|c.constants.O_NONBLOCK:c.constants.O_NONBLOCK,{columns:e,rows:s}=y.WriteStream(c.openSync("/dev/tty",t));return{columns:e,rows:s}}catch{}},a=()=>{try{const t=l("tput",["cols"],{env:{TERM:"dumb",...n.env}}),e=l("tput",["lines"],{env:{TERM:"dumb",...n.env}});if(t&&e)return N(t,e)}catch{}},O=()=>{try{if(!h())return;const t=l("resize",["-u"]).match(/\d+/g);if(t.length===2)return N(t[0],t[1])}catch{}},v=t=>{const{columns:e,rows:s}=t;if(e&&s)return{columns:e,rows:s};const r=I();return{columns:e||r.columns||80,rows:s||r.rows||24}};export{v as g};
@@ -0,0 +1,4 @@
1
+ const i=async(r,a,o={})=>{const c=o.timeout??3e3,s=o.interval??50,w=Date.now();let e=new Error("waitFor timed out");const n=()=>{if(typeof r=="string"){const t=a();if(!t.includes(r))throw new Error(`Timed out waiting for text: "${r}"
2
+
3
+ Screen content:
4
+ ${t}`)}else r()};for(;Date.now()-w<c;){try{n();return}catch(t){e=t}await new Promise(t=>{setTimeout(t,s)})}try{n();return}catch(t){e=t}throw e};export{i as waitFor};
@@ -0,0 +1,3 @@
1
+ import{S as w,d as V,i as g}from"./measure-text-DtlK6gar.js";const S=(t,a,l="end")=>{if(a<1)return new w;if(V(t)<=a)return t;const c=new w;if(c.pushChar("…",0),a===1)return c;if(l==="start"){let s=0,e=t.length;for(let f=t.length-1;f>=0&&(s+=g(t.getValue(f)),!(s>a-1));f--)e=f;return c.combine(t.slice(e))}if(l==="middle"){const s=Math.ceil(a/2),e=a-s;let f=0,i=0;for(let u=0;u<t.length;u++){const o=g(t.getValue(u));if(i+o>s-1)break;i+=o,f=u+1}let d=t.length;i=0;for(let u=t.length-1;u>=0&&(i+=g(t.getValue(u)),!(i>e));u--)d=u;return t.slice(0,f).combine(c,t.slice(d))}let n=0,r=0;for(let s=0;s<t.length;s++){const e=g(t.getValue(s));if(r+e>a-1)break;r+=e,n=s+1}return t.slice(0,n).combine(c)},p=(t,a)=>{const l=[];let h=0,c=0,n=!0,r=0;for(;r<t.length;){const s=t.getValue(r);if(s===`
2
+ `){l.push(t.slice(h,r)),h=r+1,c=0,n=!0,r++;continue}let e=r,f=0;if(s===" ")f=g(" "),e=r+1;else for(;e<t.length&&t.getValue(e)!==" "&&t.getValue(e)!==`
3
+ `;)f+=g(t.getValue(e)),e++;if(c+f>a&&c>0){if(s===" "&&!n&&!t.hasStyles(r)){r=e;continue}let i=r;for(;i>h&&t.getValue(i-1)===" "&&!t.hasStyles(i-1);)i--;l.push(t.slice(h,i)),h=r,c=0;continue}if(c===0&&f>a){let i=r,d=0;for(;i<e;){const u=g(t.getValue(i));d+u>a&&d>0&&(l.push(t.slice(h,i)),h=i,d=0),d+=u,i++}c=d,r=e,n=!1}else c+=f,r=e,s!==" "&&(n=!1)}return(h<t.length||l.length===0)&&l.push(t.slice(h)),l},k=(t,a,l="wrap")=>{if(l.startsWith("truncate")){let h="end";return l==="truncate-middle"?h="middle":l==="truncate-start"&&(h="start"),[S(t,a,h)]}return p(t,a)};export{k as wrapOrTruncateStyledLine};
@@ -1,6 +1,6 @@
1
1
  import React, { Context, RefObject, ReactNode } from 'react';
2
- import { M as MouseEvent, T as TuiApp, c as InputParser, a as InlineOptions } from "../packem_shared/input.d-CL_4MfL-.js";
3
2
  import Yoga from 'yoga-layout';
3
+ import { M as MouseEvent, T as TuiApp, c as InputParser, a as InlineOptions } from "../packem_shared/input.d-CL_4MfL-.js";
4
4
  interface DevToolsProps {
5
5
  children: React.ReactNode;
6
6
  /** Show/hide the HUD without unmounting (default: true) */
@@ -1 +1 @@
1
- import{DevTools as o}from"../packem_shared/DevTools-CZ-O0Ckm.js";import{FocusContext as u,FocusProvider as s,useFocus as n,useFocusManager as p}from"../packem_shared/FocusContext-BWFqf9kb.js";import{TuiContext as d,measureElement as f,useApp as l,useBoxMetrics as m,useCursor as a,useInput as i,useIsScreenReaderEnabled as S,useMouse as c,usePaste as T,useScrollable as C,useStderr as F,useStdin as I,useStdout as M,useTextInput as v,useTuiContext as y,useWindowSize as E}from"../packem_shared/TuiContext-BNmP0lMY.js";import{render as g,renderInline as A}from"../packem_shared/render-CPVY5vpQ.js";import{renderToString as D}from"../packem_shared/renderToString-Df6HST7u.js";import{Static as N}from"../packem_shared/Static-DSzsElz4.js";import{LayoutNode as P}from"../packem_shared/LayoutNode-LPYsuzBg.js";import{NAMED_COLORS as w,applyStyles as z,resolveColor as W}from"../packem_shared/NAMED_COLORS-82DpREQV.js";import{renderTreeToBuffer as h}from"../packem_shared/renderTreeToBuffer-BpSD0sBJ.js";export{o as DevTools,u as FocusContext,s as FocusProvider,P as LayoutNode,w as NAMED_COLORS,N as Static,d as TuiContext,z as applyStyles,f as measureElement,g as render,A as renderInline,D as renderToString,h as renderTreeToBuffer,W as resolveColor,l as useApp,m as useBoxMetrics,a as useCursor,n as useFocus,p as useFocusManager,i as useInput,S as useIsScreenReaderEnabled,c as useMouse,T as usePaste,C as useScrollable,F as useStderr,I as useStdin,M as useStdout,v as useTextInput,y as useTuiContext,E as useWindowSize};
1
+ import{DevTools as o}from"../packem_shared/DevTools-DKYxA_wO.js";import{FocusContext as u,FocusProvider as s,useFocus as n,useFocusManager as p}from"../packem_shared/FocusContext-mWFBWdli.js";import{TuiContext as d,measureElement as f,useApp as l,useBoxMetrics as m,useCursor as a,useInput as i,useIsScreenReaderEnabled as S,useMouse as c,usePaste as T,useScrollable as C,useStderr as F,useStdin as I,useStdout as M,useTextInput as v,useTuiContext as y,useWindowSize as E}from"../packem_shared/TuiContext-Bbq9JRCu.js";import{render as g,renderInline as A}from"../packem_shared/render-B_NqU7AH.js";import{renderToString as D}from"../packem_shared/renderToString-BLr8QvYq.js";import{Static as N}from"../packem_shared/Static-sqw4n2Fv.js";import{LayoutNode as P}from"../packem_shared/LayoutNode-D4i45GQM.js";import{NAMED_COLORS as w,applyStyles as z,resolveColor as W}from"../packem_shared/NAMED_COLORS-DvfPALxN.js";import{renderTreeToBuffer as h}from"../packem_shared/renderTreeToBuffer-MEHvKJc-.js";export{o as DevTools,u as FocusContext,s as FocusProvider,P as LayoutNode,w as NAMED_COLORS,N as Static,d as TuiContext,z as applyStyles,f as measureElement,g as render,A as renderInline,D as renderToString,h as renderTreeToBuffer,W as resolveColor,l as useApp,m as useBoxMetrics,a as useCursor,n as useFocus,p as useFocusManager,i as useInput,S as useIsScreenReaderEnabled,c as useMouse,T as usePaste,C as useScrollable,F as useStderr,I as useStdin,M as useStdout,v as useTextInput,y as useTuiContext,E as useWindowSize};
@@ -1,13 +1,11 @@
1
1
  import { ReactElement } from 'react';
2
- import { R as RenderOptions } from "../packem_shared/render.d-DjQhFsiN.js";
3
- import "../packem_shared/dom.d-CLGlidfI.js";
2
+ import { R as RenderOptions } from "../packem_shared/render.d-tqP_-Le_.js";
3
+ import "../packem_shared/dom.d-BV2bnRcH.js";
4
4
  import 'yoga-layout';
5
5
  import "../ink/public/cursor.js";
6
+ import "../packem_shared/styles.d-BCZOPl_g.js";
6
7
  import '@visulima/colorize';
7
- import "../packem_shared/styles.d-CKGQFfm4.js";
8
- import 'type-fest';
9
- import "../packem_shared/app-context.d-DMLw5Nxy.js";
10
- import 'node:stream';
8
+ import "../packem_shared/app-context.d-DAF6oxKX.js";
11
9
  declare const KEY: {
12
10
  readonly backspace: "";
13
11
  readonly ctrlC: "";
@@ -1 +1 @@
1
- import{createRequire as _}from"node:module";import x from"../packem_shared/render-CvhjGwOg.js";import{createKeySender as y}from"../packem_shared/KEY-C--kOw41.js";import{KEY as Y}from"../packem_shared/KEY-C--kOw41.js";import{createScreen as T}from"../packem_shared/createScreen-DoYpyL0V.js";import{waitFor as b}from"../packem_shared/waitFor-CTAki32d.js";let g;const w=t=>(g??=_(import.meta.url))(t),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,F=t=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,n]=a.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return a.getBuiltinModule(t)}return w(t)},m=F("node:events");class j extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class v extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class R extends m{isTTY=!0;pendingData;write=e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0);read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const u=[],S=(t,e={})=>{const{columns:n,options:d}=e,s=new j(n),c=new v(n),o=new R,i=x(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:c,stdin:o,stdout:s,...d});u.push(i);const l=T(()=>s.lastFrame(),s.frames),p=y(r=>o.write(r)),f=async()=>{await new Promise(r=>{setTimeout(r,0)}),await new Promise(r=>{setTimeout(r,0)})};return{cleanup:i.cleanup,flush:f,get frames(){return s.frames},keys:p,lastFrame:()=>s.lastFrame(),rerender:i.rerender,screen:l,stderr:c,stdin:o,stdout:s,unmount:i.unmount,async waitFor(r,h){await b(r,()=>l.text(),h)}}},B=()=>{for(const t of u)t.cleanup();u.length=0};export{Y as KEY,B as cleanup,y as createKeySender,T as createScreen,S as render,b as waitFor};
1
+ import{createRequire as _}from"node:module";import x from"../packem_shared/render-DGiSemZa.js";import{createKeySender as y}from"../packem_shared/KEY-DGV_trPu.js";import{KEY as O}from"../packem_shared/KEY-DGV_trPu.js";import{createScreen as T}from"../packem_shared/createScreen-BBvF-ZyU.js";import{waitFor as b}from"../packem_shared/waitFor-BjdYqkin.js";let g;const w=t=>(g??=_(import.meta.url))(t),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,F=t=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,n]=a.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return a.getBuiltinModule(t)}return w(t)},c=F("node:events");class j extends c{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class v extends c{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class R extends c{isTTY=!0;pendingData;write=e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0);read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const u=[],M=(t,e={})=>{const{columns:n,options:d}=e,s=new j(n),m=new v(n),i=new R,o=x(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:m,stdin:i,stdout:s,...d});u.push(o);const l=T(()=>s.lastFrame(),s.frames),p=y(r=>i.write(r)),h=async()=>{await new Promise(r=>{setTimeout(r,0)}),await new Promise(r=>{setTimeout(r,0)})};return{cleanup:o.cleanup,flush:h,get frames(){return s.frames},keys:p,lastFrame:()=>s.lastFrame(),rerender:o.rerender,screen:l,stderr:m,stdin:i,stdout:s,unmount:o.unmount,async waitFor(r,f){await b(r,()=>l.text(),f)}}},P=()=>{for(const t of u)t.cleanup();u.length=0};export{O as KEY,P as cleanup,y as createKeySender,T as createScreen,M as render,b as waitFor};