@visulima/tui 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/LICENSE.md +130 -1
- package/dist/components/box.d.ts +735 -3
- package/dist/components/box.js +1 -1
- package/dist/components/canvas.js +1 -1
- package/dist/components/cursor.d.ts +2 -3
- package/dist/components/cursor.js +1 -1
- package/dist/components/error-overview.js +1 -1
- package/dist/components/spacer.js +1 -1
- package/dist/components/static-render.d.ts +2 -3
- package/dist/components/static-render.js +1 -1
- package/dist/components/static.d.ts +1 -3
- package/dist/components/static.js +1 -1
- package/dist/components/text.d.ts +1 -3
- package/dist/components/text.js +1 -1
- package/dist/components/transform.js +1 -1
- package/dist/core/index.js +1 -1
- package/dist/ink/canvas/index.d.ts +14 -1
- package/dist/ink/canvas/index.js +1 -1
- package/dist/ink/hooks/use-animation.js +1 -1
- package/dist/ink/hooks/use-app.d.ts +1 -2
- package/dist/ink/hooks/use-app.js +1 -1
- package/dist/ink/hooks/use-box-metrics.d.ts +2 -3
- package/dist/ink/hooks/use-box-metrics.js +1 -1
- package/dist/ink/hooks/use-clipboard.js +1 -1
- package/dist/ink/hooks/use-color-blindness.js +1 -1
- package/dist/ink/hooks/use-console-capture.js +1 -1
- package/dist/ink/hooks/use-cursor.d.ts +0 -1
- package/dist/ink/hooks/use-cursor.js +1 -1
- package/dist/ink/hooks/use-focus-manager.d.ts +0 -1
- package/dist/ink/hooks/use-focus-manager.js +1 -1
- package/dist/ink/hooks/use-focus.js +1 -1
- package/dist/ink/hooks/use-form.js +1 -1
- package/dist/ink/hooks/use-hotkey.js +1 -1
- package/dist/ink/hooks/use-input.js +2 -2
- package/dist/ink/hooks/use-interval.js +1 -1
- package/dist/ink/hooks/use-key-bindings.js +1 -1
- package/dist/ink/hooks/use-key-chord.js +1 -1
- package/dist/ink/hooks/use-paste.js +1 -1
- package/dist/ink/hooks/use-persistent-state.js +2 -2
- package/dist/ink/hooks/use-scroll-acceleration.js +1 -1
- package/dist/ink/hooks/use-scroll-input.js +1 -1
- package/dist/ink/hooks/use-stderr.d.ts +0 -1
- package/dist/ink/hooks/use-stderr.js +1 -1
- package/dist/ink/hooks/use-stdin.d.ts +0 -1
- package/dist/ink/hooks/use-stdin.js +1 -1
- package/dist/ink/hooks/use-stdout.d.ts +0 -1
- package/dist/ink/hooks/use-stdout.js +1 -1
- package/dist/ink/hooks/use-stopwatch.js +1 -1
- package/dist/ink/hooks/use-terminal-palette.js +1 -1
- package/dist/ink/hooks/use-text-buffer.js +4 -4
- package/dist/ink/hooks/use-text-selection.d.ts +3 -4
- package/dist/ink/hooks/use-text-selection.js +1 -1
- package/dist/ink/hooks/use-timeout.js +1 -1
- package/dist/ink/hooks/use-timer.js +1 -1
- package/dist/ink/hooks/use-window-size.js +1 -1
- package/dist/ink/index.d.ts +23 -15
- package/dist/ink/index.js +1 -1
- package/dist/ink/mouse/use-element-position.d.ts +2 -3
- package/dist/ink/mouse/use-element-position.js +1 -1
- package/dist/ink/mouse/use-mouse-action.d.ts +1 -2
- package/dist/ink/mouse/use-mouse-action.js +1 -1
- package/dist/ink/mouse/use-mouse-position.d.ts +1 -2
- package/dist/ink/mouse/use-mouse-position.js +1 -1
- package/dist/ink/mouse/use-mouse.d.ts +1 -2
- package/dist/ink/mouse/use-mouse.js +1 -1
- package/dist/ink/mouse/use-on-mouse-click.d.ts +3 -4
- package/dist/ink/mouse/use-on-mouse-click.js +1 -1
- package/dist/ink/mouse/use-on-mouse-hover.d.ts +2 -3
- package/dist/ink/mouse/use-on-mouse-hover.js +1 -1
- package/dist/ink/mouse/use-on-mouse-state.d.ts +2 -3
- package/dist/ink/mouse/use-on-mouse-state.js +1 -1
- package/dist/ink/public/cursor.d.ts +22 -1
- package/dist/ink/public/cursor.js +1 -1
- package/dist/ink/public/dom.d.ts +2 -3
- package/dist/ink/public/highlighter.d.ts +49 -3
- package/dist/ink/public/highlighter.js +1 -1
- package/dist/ink/public/input.d.ts +19 -1
- package/dist/ink/public/styles.d.ts +1 -3
- package/dist/ink/public/utils.d.ts +8 -1
- package/dist/ink/public/utils.js +1 -1
- package/dist/packem_shared/COLOR_BLINDNESS_COMPENSATION-CaI93Rjj.js +1 -0
- package/dist/packem_shared/Cell-CbDQUAjW.js +1 -0
- package/dist/packem_shared/DevTools-DKYxA_wO.js +1 -0
- package/dist/packem_shared/FocusContext-mWFBWdli.js +1 -0
- package/dist/packem_shared/Fullscreen-DKKMVbkg.js +1 -0
- package/dist/packem_shared/{IMECompositionBuffer-VhC9HRCv.js → IMECompositionBuffer-uYiAz3jI.js} +1 -1
- package/dist/packem_shared/{InputParser-CUAGWKQQ.js → InputParser-O4nyWUuQ.js} +2 -2
- package/dist/packem_shared/{KEY-C--kOw41.js → KEY-DGV_trPu.js} +1 -1
- package/dist/packem_shared/LayoutNode-D4i45GQM.js +1 -0
- package/dist/packem_shared/MouseProvider-BSTuFqG9.js +1 -0
- package/dist/packem_shared/NAMED_COLORS-DvfPALxN.js +1 -0
- package/dist/packem_shared/Range-CMqYzhij.js +1 -0
- package/dist/packem_shared/Renderer-Dg5_-6TF.js +1 -0
- package/dist/packem_shared/ResizeObserver-ClWoCtGV.js +1 -0
- package/dist/packem_shared/Static-sqw4n2Fv.js +1 -0
- package/dist/packem_shared/{TuiApp-CCVaiKbf.js → TuiApp-D1How6sn.js} +1 -1
- package/dist/packem_shared/TuiContext-Bbq9JRCu.js +3 -0
- package/dist/packem_shared/animation-context-Icwf5tBE.js +1 -0
- package/dist/packem_shared/ansi-parser-CysVDsNz.js +1 -0
- package/dist/packem_shared/ansi-tokenizer-D5k5LzXg.js +1 -0
- package/dist/packem_shared/{app-context-DTm1_XBA.js → app-context-CfgsW0CV.js} +1 -1
- package/dist/packem_shared/{app-context.d-DMLw5Nxy.d.ts → app-context.d-DAF6oxKX.d.ts} +0 -1
- package/dist/packem_shared/{boxes-DyY_LXCi.js → boxes-CidWUOVk.js} +1 -1
- package/dist/packem_shared/buildCursorOnlySequence-D24o0D7-.js +1 -0
- package/dist/packem_shared/calculateScroll-jdxVlcmq.js +1 -0
- package/dist/packem_shared/calculateScrollbarLayout-DCVwJ0Cl.js +1 -0
- package/dist/packem_shared/clearOsc52-olbKg5Nw.js +1 -0
- package/dist/packem_shared/clearStringWidthCache-EWeHQcEb.js +1 -0
- package/dist/packem_shared/colorize-Dsbi0Wr0.js +1 -0
- package/dist/packem_shared/createBrailleGrid-B5uefhi4.js +1 -0
- package/dist/packem_shared/createCanvasBuffer-C7w6bGe4.js +1 -0
- package/dist/packem_shared/createInlineLoop-BPlBAXqd.js +2 -0
- package/dist/packem_shared/createScreen-BBvF-ZyU.js +3 -0
- package/dist/packem_shared/cursor-context-wLwblh2o.js +1 -0
- package/dist/packem_shared/{disposeHighlighter-D9OkrhwX.js → disposeHighlighter-BS4lDPP8.js} +1 -1
- package/dist/packem_shared/dom-xpeZzKuf.js +1 -0
- package/dist/packem_shared/{dom.d-CLGlidfI.d.ts → dom.d-BV2bnRcH.d.ts} +2 -3
- package/dist/packem_shared/{focus-context-CsT69klR.js → focus-context-8h3hmNxy.js} +1 -1
- package/dist/packem_shared/formatDuration-DcLMLZro.js +1 -0
- package/dist/packem_shared/getPathToRoot-DBqZKIzf.js +1 -0
- package/dist/packem_shared/index-7Qq5uu0d.js +75 -0
- package/dist/packem_shared/isIntersecting-C8tJIsvH.js +1 -0
- package/dist/packem_shared/isTerminalPaletteQuerySupported-DwJPJ8_h.js +1 -0
- package/dist/packem_shared/kittyFlags-jpd_IAFL.js +1 -0
- package/dist/packem_shared/load-native-root-binding-B1WunHs4.js +1 -0
- package/dist/packem_shared/measure-element-pHwUPovG.js +1 -0
- package/dist/packem_shared/measure-text-DtlK6gar.js +3 -0
- package/dist/packem_shared/mouse-context-BEnaR3tG.js +1 -0
- package/dist/packem_shared/{mouse-context.d-W-nszUps.d.ts → mouse-context.d-5TGeZyIF.d.ts} +1 -2
- package/dist/packem_shared/parseSgrMouse-CHYo9gs6.js +1 -0
- package/dist/packem_shared/processLayout-DYdx6C3A.js +2 -0
- package/dist/packem_shared/reconciler-BPm7fZa6.js +1 -0
- package/dist/packem_shared/reconciler-DXp9qy6k.js +1 -0
- package/dist/packem_shared/render-B_NqU7AH.js +1 -0
- package/dist/packem_shared/render-DrIzCc0i.js +24 -0
- package/dist/packem_shared/{render.d-DjQhFsiN.d.ts → render.d-dEKhpngX.d.ts} +2 -3
- package/dist/packem_shared/renderToString-BLr8QvYq.js +2 -0
- package/dist/packem_shared/renderToString-D66vRHLQ.js +4 -0
- package/dist/packem_shared/renderToken-DFWLdYz_.js +1 -0
- package/dist/packem_shared/renderTreeToBuffer-MEHvKJc-.js +2 -0
- package/dist/packem_shared/renderer-D97BmOBO.js +17 -0
- package/dist/packem_shared/{selection.d-BSAWa4ey.d.ts → selection.d-DCMpXtpU.d.ts} +1 -1
- package/dist/packem_shared/squashTextNodesWithMap-CUJZZeW3.js +1 -0
- package/dist/packem_shared/stderr-context-Xeacf3Ir.js +1 -0
- package/dist/packem_shared/stdin-context-Ceh-YuU1.js +1 -0
- package/dist/packem_shared/stdout-context-BhxOwdNK.js +1 -0
- package/dist/packem_shared/{styles.d-CKGQFfm4.d.ts → styles.d-BCZOPl_g.d.ts} +37 -3
- package/dist/packem_shared/text-width-BXmBaLDv.js +2 -0
- package/dist/packem_shared/utils-BlDbvbdr.js +1 -0
- package/dist/packem_shared/waitFor-BjdYqkin.js +4 -0
- package/dist/packem_shared/wrapOrTruncateStyledLine-Gm21gYDr.js +3 -0
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/testing/index.d.ts +4 -6
- package/dist/testing/index.js +1 -1
- package/index.js +26 -26
- package/package.json +12 -12
- package/dist/packem_shared/COLOR_BLINDNESS_COMPENSATION-Ilnoyeqc.js +0 -1
- package/dist/packem_shared/Cell-BrXn3jxY.js +0 -1
- package/dist/packem_shared/DevTools-CZ-O0Ckm.js +0 -1
- package/dist/packem_shared/FocusContext-BWFqf9kb.js +0 -1
- package/dist/packem_shared/Fullscreen-BRhuBLBh.js +0 -1
- package/dist/packem_shared/LayoutNode-LPYsuzBg.js +0 -1
- package/dist/packem_shared/MouseProvider-DOcWCRVq.js +0 -1
- package/dist/packem_shared/NAMED_COLORS-82DpREQV.js +0 -1
- package/dist/packem_shared/Range-BsVYNWtg.js +0 -1
- package/dist/packem_shared/Renderer-BeS49FNq.js +0 -1
- package/dist/packem_shared/ResizeObserver-BI9bDy-j.js +0 -1
- package/dist/packem_shared/Static-DSzsElz4.js +0 -1
- package/dist/packem_shared/TuiContext-BNmP0lMY.js +0 -3
- package/dist/packem_shared/animation-context-DW3p-vpk.js +0 -1
- package/dist/packem_shared/ansi-parser-DlgLtOYO.js +0 -1
- package/dist/packem_shared/ansi-tokenizer-BU67A126.js +0 -1
- package/dist/packem_shared/buildCursorOnlySequence-CerkmjWt.js +0 -1
- package/dist/packem_shared/calculateScroll-D4Y_JR4H.js +0 -1
- package/dist/packem_shared/calculateScrollbarLayout-Lf6i24c9.js +0 -1
- package/dist/packem_shared/clearOsc52-BUpnQOav.js +0 -1
- package/dist/packem_shared/clearStringWidthCache-DKFjfJuB.js +0 -1
- package/dist/packem_shared/colorize-DU4YZkp3.js +0 -1
- package/dist/packem_shared/createBrailleGrid-BTOQrujS.js +0 -1
- package/dist/packem_shared/createCanvasBuffer-CL6sAM-A.js +0 -1
- package/dist/packem_shared/createInlineLoop-BMDYJkRp.js +0 -2
- package/dist/packem_shared/createScreen-DoYpyL0V.js +0 -3
- package/dist/packem_shared/cursor-context-CFviBqPX.js +0 -1
- package/dist/packem_shared/dom-rphpG0kf.js +0 -1
- package/dist/packem_shared/formatDuration-Bdx4ZgRh.js +0 -1
- package/dist/packem_shared/getPathToRoot-PDJeqiEH.js +0 -1
- package/dist/packem_shared/index-Dl9I2_QH.js +0 -75
- package/dist/packem_shared/isIntersecting-Bo2npvMR.js +0 -1
- package/dist/packem_shared/isTerminalPaletteQuerySupported-BYzmqq9-.js +0 -1
- package/dist/packem_shared/kittyFlags-g8ALyoCU.js +0 -1
- package/dist/packem_shared/load-native-root-binding-CxJnHcac.js +0 -1
- package/dist/packem_shared/measure-element-D4M9iSYp.js +0 -1
- package/dist/packem_shared/measure-text-B7juNq4Y.js +0 -3
- package/dist/packem_shared/mouse-context-DaARgUu1.js +0 -1
- package/dist/packem_shared/parseSgrMouse-bUrqPrh-.js +0 -1
- package/dist/packem_shared/processLayout-I83k6vXE.js +0 -2
- package/dist/packem_shared/reconciler-D4fi5NfR.js +0 -1
- package/dist/packem_shared/reconciler-DkwOtC5B.js +0 -1
- package/dist/packem_shared/render-CPVY5vpQ.js +0 -1
- package/dist/packem_shared/render-CvhjGwOg.js +0 -24
- package/dist/packem_shared/renderToString-B1LgWcJe.js +0 -4
- package/dist/packem_shared/renderToString-Df6HST7u.js +0 -2
- package/dist/packem_shared/renderToken-DjiQ6dfv.js +0 -1
- package/dist/packem_shared/renderTreeToBuffer-BpSD0sBJ.js +0 -2
- package/dist/packem_shared/renderer-Cs0KEr1o.js +0 -17
- package/dist/packem_shared/squashTextNodesWithMap-BmUSBPfc.js +0 -1
- package/dist/packem_shared/stderr-context-CR2LLec6.js +0 -1
- package/dist/packem_shared/stdin-context-BjMA9Sbi.js +0 -1
- package/dist/packem_shared/stdout-context-DAAlQct2.js +0 -1
- package/dist/packem_shared/text-width-e49vlbQH.js +0 -2
- package/dist/packem_shared/utils-CVgM8kTn.js +0 -1
- package/dist/packem_shared/waitFor-CTAki32d.js +0 -4
- package/dist/packem_shared/wrapOrTruncateStyledLine-46W8bTtv.js +0 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import{createRequire as Me}from"node:module";import{jsx as B}from"react/jsx-runtime";import{cursorShow as ot,setMode as de,BracketedPasteMode as he,resetMode as fe,eraseLines as G,cursorHide as at,cursorUp as Xt,cursorNextLine as Ue,cursorTo as _e,eraseLineEnd as He,createDecMode as Ge,ALT_SCREEN_ON as Zt,clearScreenAndHomeCursor as Ke,ALT_SCREEN_OFF as Jt}from"@visulima/ansi";import{wordWrap as Ye}from"@visulima/string";import{ConcurrentRoot as qe,LegacyRoot as je}from"react-reconciler/constants.js";import W from"yoga-layout";import{a as ze}from"./accessibility-context-DDyHTwmA.js";import{useState as ht,useRef as N,useCallback as w,useEffect as ft,useMemo as _}from"react";import{a as $e}from"./animation-context-Icwf5tBE.js";import{A as Qe}from"./app-context-CfgsW0CV.js";import{C as Xe}from"./cursor-context-wLwblh2o.js";import Ze from"../components/error-boundary.js";import{F as Je}from"./focus-context-8h3hmNxy.js";import{S as ti}from"./stderr-context-Xeacf3Ir.js";import{S as ei}from"./stdin-context-Ceh-YuU1.js";import{S as ii}from"./stdout-context-BhxOwdNK.js";import{O as si,a as ni,b as ri,r as oi}from"./renderer-D97BmOBO.js";import{c as ai,e as ui}from"./dom-xpeZzKuf.js";import{resolveFlags as te}from"./kittyFlags-jpd_IAFL.js";import{buildReturnToBottomPrefix as gt,buildCursorSuffix as nt,cursorPositionChanged as vt,buildCursorOnlySequence as pe,buildCursorShapeSequence as ee}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 D,s as di}from"./reconciler-BPm7fZa6.js";import{measureAndExtractObservers as hi}from"./ResizeObserver-ClWoCtGV.js";import{calculateScroll as fi}from"./calculateScroll-jdxVlcmq.js";import{g as z}from"./utils-BlDbvbdr.js";let Be;const Fe=i=>(Be??=Me(import.meta.url))(i),Q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,yt=i=>{if(typeof Q<"u"&&Q.versions&&Q.versions.node){const[t,e]=Q.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return Q.getBuiltinModule(i)}return Fe(i)},k=Q,{env:xt}=k,{PassThrough:$t,Stream:Ae}=yt("node:stream"),{Buffer:Qt}=yt("node:buffer"),{Console:We}=yt("node:console"),{EventEmitter:Ve}=yt("node:events"),ie=i=>i in xt&&xt[i]!=="0"&&xt[i]!=="false",me=ie("CI")||ie("CONTINUOUS_INTEGRATION"),se=["assert","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"];let Rt={};const pi=i=>{const t=new $t,e=new $t;t.write=n=>{i("stdout",n)},e.write=n=>{i("stderr",n)};const s=new console.Console(t,e);for(const n of se)Rt[n]=console[n],console[n]=s[n];return()=>{for(const n of se)console[n]=Rt[n];Rt={}}},X=[];X.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&X.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&X.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const mt=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",Tt=Symbol.for("signal-exit emitter"),Ct=globalThis,mi=Object.defineProperty.bind(Object);class gi{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Ct[Tt])return Ct[Tt];mi(Ct,Tt,{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 o of this.listeners[t])n=o(e,s)===!0||n;return t==="exit"&&(n=this.emit("afterExit",e,s)||n),n}}class ge{}const vi=i=>({onExit(t,e){return i.onExit(t,e)},load(){return i.load()},unload(){return i.unload()}});class wi extends ge{onExit(){return()=>{}}load(){}unload(){}}class bi extends ge{#o=Ot.platform==="win32"?"SIGINT":"SIGHUP";#e=new gi;#t;#n;#r;#s={};#i=!1;constructor(t){super(),this.#t=t,this.#s={};for(const e of X)this.#s[e]=()=>{const s=this.#t.listeners(e);let{count:n}=this.#e;const o=t;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(n+=o.__signal_exit_emitter__.count),s.length===n){this.unload();const u=this.#e.emit("exit",null,e),r=e==="SIGHUP"?this.#o:e;u||t.kill(t.pid,r)}};this.#r=t.reallyExit,this.#n=t.emit}onExit(t,e){if(!mt(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 X)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,X.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 mt(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"&&mt(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 Ot=globalThis.process,{onExit:yi}=vi(mt(Ot)?new bi(Ot):new wi),wt="\x1B",ve="\x1B[200~",ne="\x1B[201~",Si=i=>i>=48&&i<=63,xi=i=>i>=32&&i<=47,we=i=>i>=64&&i<=126,Ri=(i,t,e)=>{const s=t+e+1;let n=s;for(;n<i.length;n++){const o=i.codePointAt(n);if(o===void 0)return"pending";if(!(Si(o)||xi(o))&&!(o===91&&n===s))return we(o)?{nextIndex:n+1,sequence:i.slice(t,n+1)}:void 0}return"pending"},Ti=(i,t,e)=>{const s=t+e+2;if(s>i.length)return"pending";const n=i.codePointAt(s-1);if(!(n===void 0||!we(n)))return{nextIndex:s,sequence:i.slice(t,s)}},re=(i,t,e)=>{const s=i[t+e];if(s===void 0)return"pending";if(s==="[")return Ri(i,t,e);if(s==="O")return Ti(i,t,e)},Ci=(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)}},Ei=(i,t)=>{if(t===i.length-1)return"pending";if(i[t+1]===wt){if(t+2>=i.length)return"pending";const n=re(i,t,2);return n==="pending"?"pending":n||{nextIndex:t+2,sequence:i.slice(t,t+2)}}const s=re(i,t,1);return s==="pending"?"pending":s||Ci(i,t)},oe=(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))},Pi=i=>{const t=[];let e=0;const s=n=>({events:t,pending:i.slice(n)});for(;e<i.length;){const n=i.indexOf(wt,e);if(n===-1)return oe(i.slice(e),t),{events:t,pending:""};n>e&&oe(i.slice(e,n),t);const o=Ei(i,n);if(o==="pending")return s(n);if(o.sequence===ve){const u=o.nextIndex,r=i.indexOf(ne,u);if(r===-1)return s(n);t.push({paste:i.slice(u,r)}),e=r+ne.length;continue}t.push(o.sequence),e=o.nextIndex}return{events:t,pending:""}},Oi=()=>{let i="";return{flushPendingEscape(){if(!i.startsWith(wt))return;const t=i;return i="",t},hasPendingEscape(){return i.startsWith(wt)&&!i.startsWith(ve)&&i!=="\x1B[200"},push(t){const e=Pi(i+t);return i=e.pending,e.events},reset(){i=""}}},Ii=" ",Ni="\x1B[Z",ki="\x1B",ae=de(he),Et=fe(he),be=({children:i,exitOnCtrlC:t,interactive:e,onExit:s,onRegisterInputControl:n,onSuspendTerminal:o,onWaitUntilRenderFlush:u,renderThrottleMs:r,setCursorPosition:a,stderr:f,stdin:h,stdout:m,writeToStderr:v,writeToStdout:d})=>{const[l,b]=ht(!0),[y,S]=ht(void 0),[,C]=ht([]),F=N(0),E=N([]),A=N(new Map),O=N(void 0),I=N(0),L=N(!1),R=N(0),[P]=ht(()=>{const c=new Ve;return c.setMaxListeners(1/0),c}),Z=N(void 0),J=N(void 0);J.current??=Oi();const tt=N(void 0),Nt=N(!1),Te=20,K=w(()=>{tt.current&&(clearTimeout(tt.current),tt.current=void 0)},[]),Y=w(()=>{O.current&&(clearTimeout(O.current),O.current=void 0)},[]),ut=w(()=>{if(Y(),A.current.size===0)return;let c=Number.POSITIVE_INFINITY;for(const p of A.current.values())c=Math.min(c,p.nextDueTime);const g=Math.max(0,c-performance.now());O.current=setTimeout(()=>{O.current=void 0;const p=performance.now(),x=[...A.current.values()];for(const T of x){if(p<T.nextDueTime)continue;T.callback(p);const Le=p-T.startTime,De=Math.floor(Le/T.interval)+1;T.nextDueTime=T.startTime+De*T.interval}ut()},g)},[Y]),kt=w((c,g)=>{const p=performance.now();return A.current.set(c,{callback:c,interval:g,nextDueTime:p+g,startTime:p}),ut(),{startTime:p,unsubscribe(){if(A.current.delete(c),A.current.size===0){Y();return}ut()}}},[Y,ut]);ft(()=>()=>{Y()},[Y]);const M=h.isTTY,Lt=w(()=>{Z.current&&(h.removeListener("readable",Z.current),Z.current=void 0)},[h]),q=w(()=>{J.current?.reset(),K(),Lt()},[K,Lt]),j=w(()=>{L.current=!1,h.setRawMode(!1),h.unref(),I.current=0,q()},[h,q]),et=w(c=>{M&&(I.current>0||L.current)&&j(),s(c)},[M,j,s]),Dt=w(c=>{if(c.includes("")&&t){et();return}c===ki&&l&&S(g=>{if(!g)return g})},[t,et,l]),it=w(c=>{Dt(c),P.emit("input",c)},[Dt,P]),Mt=w(()=>{K(),tt.current=setTimeout(()=>{tt.current=void 0;const c=J.current.flushPendingEscape();c&&it(c)},Te)},[K,it]),St=w(()=>{K();let c;for(;(c=h.read())!==null;){const g=J.current.push(c);for(const p of g)if(typeof p=="string")it(p);else{if(P.listenerCount("paste")===0){Nt.current||(Nt.current=!0,v(`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
|
+
`)),it(p.paste);continue}P.emit("paste",p.paste)}}J.current.hasPendingEscape()&&Mt()},[h,it,K,Mt,v,P]),ct=w(()=>{Z.current||(Z.current=St,h.addListener("readable",St))},[h,St]),Bt=w(c=>{if(!M)throw h===k.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(h.setEncoding("utf8"),c){if(I.current===0){const g=L.current;L.current=!1,g||(h.ref(),h.setRawMode(!0)),ct()}I.current++;return}I.current!==0&&--I.current===0&&(q(),L.current=!0,queueMicrotask(()=>{L.current&&j()}))},[M,h,ct,q,j]),Ft=w(c=>{if(m.isTTY){if(c){R.current===0&&m.write(ae),R.current++;return}R.current!==0&&--R.current===0&&m.write(Et)}},[m]),At=N({bracketedPaste:!1,rawMode:!1}),Wt=w(()=>{const c=M&&(I.current>0||L.current),g=R.current>0;At.current={bracketedPaste:g,rawMode:c},g&&m.isTTY&&m.write(Et),c&&(L.current=!1,q(),h.setRawMode(!1),h.unref())},[M,m,h,q]),Ut=w(()=>{const{bracketedPaste:c,rawMode:g}=At.current;g&&(h.ref(),h.setRawMode(!0),h.setEncoding("utf8"),ct()),c&&m.isTTY&&m.write(ae)},[h,m,ct]);ft(()=>{n(Wt,Ut)},[n,Wt,Ut]);const _t=w((c,g)=>{const p=c.findIndex(x=>x.id===g);for(let x=p+1;x<c.length;x++){const T=c[x];if(T?.isActive)return T.id}},[]),Ht=w((c,g)=>{const p=c.findIndex(x=>x.id===g);for(let x=p-1;x>=0;x--){const T=c[x];if(T?.isActive)return T.id}},[]),lt=w(()=>{const c=E.current;S(g=>{const p=c.find(T=>T.isActive)?.id;return _t(c,g)??p})},[_t]),dt=w(()=>{const c=E.current;S(g=>{const p=c.findLast(T=>T.isActive)?.id;return Ht(c,g)??p})},[Ht]);ft(()=>{const c=p=>{!l||F.current===0||(p===Ii&<(),p===Ni&&dt())};P.on("input",c);const g=P;return()=>{g.off("input",c)}},[l,lt,dt,P]);const Gt=w(()=>{b(!0)},[]),Kt=w(()=>{b(!1)},[]),Yt=w(c=>{E.current.some(p=>p?.id===c)&&S(c)},[]),qt=w((c,{autoFocus:g})=>{const p=[...E.current,{id:c,isActive:!0}];F.current=p.length,E.current=p,C(p),g&&S(x=>x||c)},[]),jt=w(c=>{S(p=>{if(p!==c)return p});const g=E.current.filter(p=>p.id!==c);F.current=g.length,E.current=g,C(g)},[]),zt=w(c=>{const g=E.current.map(p=>p.id!==c?p:{id:c,isActive:!0});E.current=g,C(g)},[]),Vt=w(c=>{S(p=>{if(p!==c)return p});const g=E.current.map(p=>p.id!==c?p:{id:c,isActive:!1});E.current=g,C(g)},[]);ft(()=>()=>{const c=!m.destroyed&&!m.writableEnded;e&&c&&m.write(ot),M&&(I.current>0||L.current)&&j(),R.current>0&&(m.isTTY&&c&&m.write(Et),R.current=0)},[m,M,j,e]);const Ce=_(()=>({exit:et,suspendTerminal:o,waitUntilRenderFlush:u}),[et,o,u]),Ee=_(()=>({internal_eventEmitter:P,internal_exitOnCtrlC:t,isRawModeSupported:M,setBracketedPasteMode:Ft,setRawMode:Bt,stdin:h}),[h,Bt,Ft,M,t,P]),Pe=_(()=>({stdout:m,write:d}),[m,d]),Oe=_(()=>({stderr:f,write:v}),[f,v]),Ie=_(()=>({setCursorPosition:a}),[a]),Ne=_(()=>({activate:zt,activeId:y,add:qt,deactivate:Vt,disableFocus:Kt,enableFocus:Gt,focus:Yt,focusNext:lt,focusPrevious:dt,remove:jt}),[y,qt,jt,zt,Vt,Gt,Kt,lt,dt,Yt]),ke=_(()=>({renderThrottleMs:r,subscribe:kt}),[kt,r]);return B(Qe.Provider,{value:Ce,children:B(ei.Provider,{value:Ee,children:B(ii.Provider,{value:Pe,children:B(ti.Provider,{value:Oe,children:B(Je.Provider,{value:Ne,children:B($e.Provider,{value:ke,children:B(Xe.Provider,{value:Ie,children:B(Ze,{onError:et,children:i})})})})})})})})};be.displayName="InternalApp";const Li=(i,t,e)=>{if(e<=0||!i.yogaNode)return"";const{yogaNode:s}=i,n=s.getComputedBorder(W.EDGE_LEFT),o=s.getComputedBorder(W.EDGE_RIGHT),u=s.getComputedBorder(W.EDGE_TOP),r=s.getComputedPadding(W.EDGE_LEFT),a=s.getComputedPadding(W.EDGE_RIGHT),f=s.getComputedPadding(W.EDGE_TOP),h=Math.round(s.getComputedWidth()-n-o-r-a);if(h<=0)return"";const m=new si({height:e,width:h}),d=-(i.internal_scrollState?.scrollLeft??0)-n-r,l=-t-u-f;for(const b of i.childNodes)ni(b,m,{absoluteOffsetX:d,absoluteOffsetY:l,offsetX:d,offsetY:l,skipStaticElements:!1});return m.get().output},It=new WeakMap,V=i=>i??"default",ye=()=>{let i,t;return{consumeDelta:()=>{if(V(t)===V(i))return"";const e=V(t);return i=t,ee(e)},consumeRestoreOnDone:()=>{const e=V(i)!=="default";return i=void 0,t=void 0,e?ee("default"):""},isDirty:()=>V(t)!==V(i),setPending:e=>{t=e}}},rt=(i,t)=>t.endsWith(`
|
|
5
|
+
`)?i.length-1:i.length,Se=i=>i.rows||1/0,bt=(i,t)=>Math.min(i,Se(t)),Di=(i,{showCursor:t=!1}={})=>{let e=0,s="",n=!1,o,u=!1,r,a=!1;const f=ye(),h=()=>u?o:void 0,m=(d,l)=>{const b=vt(l,r);return d!==s||b||f.isDirty()},v=d=>{!t&&!n&&(i.write(at),n=!0);const l=h();u=!1;const b=vt(l,r);if(!m(d,l))return!1;const y=f.consumeDelta(),S=d.split(`
|
|
6
|
+
`),C=rt(S,d),F=nt(C,l);if(d===s&&b)i.write(y+pe({cursorPosition:l,cursorWasShown:a,previousCursorPosition:r,previousLineCount:e,visibleLineCount:C}));else if(d===s&&y!=="")i.write(y);else{s=d;const E=gt(a,e,r);i.write(y+E+G(bt(e,i))+d+F),e=S.length}return r=l?{...l}:void 0,a=l!==void 0,!0};return v.clear=()=>{const d=gt(a,e,r);i.write(d+G(bt(e,i))),s="",e=0,r=void 0,a=!1},v.done=()=>{s="",e=0,r=void 0,a=!1;const d=f.consumeRestoreOnDone();d!==""&&i.write(d),t||(i.write(ot),n=!1)},v.reset=()=>{s="",e=0,r=void 0,a=!1},v.sync=d=>{const l=u?o:void 0;u=!1;const b=d.split(`
|
|
7
|
+
`);s=d,e=b.length;const y=f.consumeDelta();y!==""&&i.write(y),!l&&a&&i.write(at),l&&i.write(nt(rt(b,d),l)),r=l?{...l}:void 0,a=l!==void 0},v.setCursorPosition=d=>{o=d,u=!0},v.setCursorShape=f.setPending,v.isCursorDirty=()=>u||f.isDirty(),v.willRender=d=>m(d,h()),v},Mi=(i,{showCursor:t=!1}={})=>{let e=[],s="",n=!1,o,u=!1,r,a=!1;const f=ye(),h=()=>u?o:void 0,m=(d,l)=>{const b=vt(l,r);return d!==s||b||f.isDirty()},v=d=>{!t&&!n&&(i.write(at),n=!0);const l=h();u=!1;const b=vt(l,r);if(!m(d,l))return!1;const y=f.consumeDelta(),S=d.split(`
|
|
8
|
+
`),C=rt(S,d),F=rt(e,s);if(d===s&&b)return i.write(y+pe({cursorPosition:l,cursorWasShown:a,previousCursorPosition:r,previousLineCount:e.length,visibleLineCount:C})),r=l?{...l}:void 0,a=l!==void 0,!0;if(d===s&&y!=="")return i.write(y),!0;const E=gt(a,e.length,r);if(d===`
|
|
9
|
+
`||s.length===0){const R=nt(C,l);return i.write(y+E+G(bt(e.length,i))+d+R),a=l!==void 0,r=l?{...l}:void 0,s=d,e=S,!0}const A=d.endsWith(`
|
|
10
|
+
`),O=[y,E],I=Se(i);if(C<F){const P=s.endsWith(`
|
|
11
|
+
`)?1:0;O.push(G(Math.min(F-C+P,I)),Xt(Math.min(C,I-1)))}else O.push(Xt(Math.min(F-1,I-1)));for(let R=0;R<C;R++){const P=R===C-1;if(S[R]===e[R]){(!P||A)&&O.push(Ue());continue}O.push(_e(0)+S[R]+He+(P&&!A?"":`
|
|
12
|
+
`))}const L=nt(C,l);return O.push(L),i.write(O.join("")),a=l!==void 0,r=l?{...l}:void 0,s=d,e=S,!0};return v.clear=()=>{const d=gt(a,e.length,r);i.write(d+G(bt(e.length,i))),s="",e=[],r=void 0,a=!1},v.done=()=>{s="",e=[],r=void 0,a=!1;const d=f.consumeRestoreOnDone();d!==""&&i.write(d),t||(i.write(ot),n=!1)},v.reset=()=>{s="",e=[],r=void 0,a=!1},v.sync=d=>{const l=u?o:void 0;u=!1;const b=d.split(`
|
|
13
|
+
`);s=d,e=b;const y=f.consumeDelta();y!==""&&i.write(y),!l&&a&&i.write(at),l&&i.write(nt(rt(b,d),l)),r=l?{...l}:void 0,a=l!==void 0},v.setCursorPosition=d=>{o=d,u=!0},v.setCursorShape=f.setPending,v.isCursorDirty=()=>u||f.isDirty(),v.willRender=d=>m(d,h()),v},Bi=(i,{incremental:t=!1,showCursor:e=!1}={})=>t?Mi(i,{showCursor:e}):Di(i,{showCursor:e}),Fi={create:Bi},xe=Ge(2026),H=de(xe),U=fe(xe);function Ai(i,t){return"isTTY"in i&&i.isTTY&&(t??!me)}let $;const Wi=()=>{if($!==!1){if($!==void 0)return $;try{return $=ci(import.meta.url).Renderer,$}catch{$=!1;return}}},Ui=i=>{const t=Wi();if(!t)return;let e,s=0,n=0;const o=(u,r)=>{(!e||s!==u||n!==r)&&(e?e.resize(u,r):e=new t(u,r),s=u,n=r)};return{clear(){if(e){const u=new Uint32Array(s*n*2),r=65535;for(let a=0;a<u.length;a+=2)u[a]=32,u[a+1]=r;e.render(u)}},destroy(){e=void 0},render(u,r,a){if(o(r,a),!!e){i.isTTY&&e.writeRaw(H);try{e.render(u)}finally{i.isTTY&&e.writeRaw(U)}}},resize(u,r){o(u,r)}}};function ue(i,t=0,e={}){const s=e.leading??!0,n=e.trailing??!0;let o,u,r,a;const f=()=>{if(u===void 0)return;const l=u;u=void 0,a=i(...l)},h=()=>{o!==void 0&&(clearTimeout(o),o=void 0)},m=()=>{o=void 0,n&&f(),u=void 0,r=void 0},v=()=>{h(),o=setTimeout(m,t)},d=function(...b){const y=Date.now();if(r??=y,y-r>=t)return u=b,f(),r=y,v(),a;u=b;const S=o===void 0;return v(),s&&S&&f(),a};return d.cancel=()=>{h(),u=void 0,r=void 0},d.flush=()=>(h(),f(),r=void 0,a),d}console.Console||(console.Console=We);const st=()=>{},ce=async()=>new Promise(i=>{setImmediate(i)}),_i=27,Hi=91,Gi=63,Ki=117,Yi=48,qi=57,ji=i=>i>=Yi&&i<=qi,Re=(i,t)=>{if(i[t]!==_i||i[t+1]!==Hi||i[t+2]!==Gi)return;let e=t+3;const s=e;for(;e<i.length&&ji(i[e]);)e++;if(e!==s){if(e===i.length)return{state:"partial"};if(i[e]===Ki)return{endIndex:e,state:"complete"}}},zi=i=>{for(let t=0;t<i.length;t++)if(Re(i,t)?.state==="complete")return!0;return!1},Vi=i=>{const t=[];let e=0;for(;e<i.length;){const s=Re(i,e);if(s?.state==="complete"){e=s.endIndex+1;continue}if(s?.state==="partial")break;t.push(i[e]),e++}return t},$i=({isTty:i,isUnmounting:t,isWindows:e,nextOutputHeight:s,previousOutputHeight:n,viewportRows:o})=>{if(!i)return!1;const u=n>0,r=n>=o,a=s>=o,f=n>o,h=s>o,m=r&&s<o;return f||h&&u||m||t&&r||e&&(a||r)},Pt=i=>i instanceof Error||Object.prototype.toString.call(i)==="[object Error]",le=i=>{const t=!i.destroyed&&!i.writableEnded&&(i.writable??!0),e=i._writableState!==void 0||i.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:e}},pt=(i,t)=>{if(!i||typeof i.flush!="function")return;const e=i;t?e.flush():typeof e.cancel=="function"&&e.cancel()};class Qi{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=ai("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??k.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 o=e?this.onRender:(()=>{const r=ue(this.onRender,n,{leading:!0,trailing:!0});return this.throttledOnRender=r,()=>{this.hasPendingThrottledRender=!0,r()}})();if(e&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let r=!1;const a=()=>{r||(r=!0,queueMicrotask(()=>{r=!1,this.onRender()}))};this.rootNode.onRender=a,this.rootNode.onImmediateRender=a}else this.rootNode.onRender=o,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=Fi.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=Ui(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=e?this.log:ue(r=>{const a=this.log.willRender(r),f=this.shouldSync();f&&a&&this.options.stdout.write(H),this.log(r),f&&a&&this.options.stdout.write(U)},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=z(this.options.stdout).columns,this.fullStaticOutput="";const u=t.concurrent?qe:je;this.container=D.createContainer(this.rootNode,u,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=yi(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(),k.env.DEV==="true"&&D.injectIntoDevTools(),this.exitPromise=new Promise((r,a)=>{this.resolveExitPromise=r,this.rejectExitPromise=a}),this.exitPromise.catch(st)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=()=>{const t=z(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),li(),this.calculateLayout(),ui(this.rootNode),this.onRender(),this.lastTerminalWidth=t};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};handleAppExit=t=>{if(!(this.isUnmounted||this.isUnmounting)){if(Pt(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}
|
|
14
|
+
`))};calculateLayout=()=>{const t=s=>{const n=new Map;this.calculateScrollAndTriggerObservers(s,n);for(const[o,u]of n)o.internalTrigger(u)};this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const e=z(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(e),this.rootNode.yogaNode.calculateLayout(void 0,void 0,W.DIRECTION_LTR),t(this.rootNode)};calculateScrollAndTriggerObservers(t,e){if(t.nodeName==="ink-box"){const{style:s}=t,n=s.overflow??"visible",o=s.overflowX??n,u=s.overflowY??n;o==="scroll"||u==="scroll"?(fi(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(hi(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(),di(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let s=0;for(const n of t.childNodes){const o=n;n.nodeName!=="#text"&&o.yogaNode&&(t.yogaNode.insertChild(o.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=z(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,W.DIRECTION_LTR)),e(t),ri(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(W.EDGE_TOP)??0,n=Math.max(0,e-Math.round(s)),o=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:u}=t.style,r=u===void 0?o:Math.max(o,n-Math.max(0,u)),a=n-r;if(a<=0)return"";const f=Li(t,r,a);return f===""?"":(t.internal_maxPushedScrollTop=n,`${f}\x1B[0m
|
|
15
|
+
`)}onRender=()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=oi(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:e,cursorRequested:s,cursorShape:n,output:o,outputBuffer:u,outputHeight:r,outputWidth:a,staticOutput:f}=t;this.renderedCursorRequested=s,this.renderedCursorPosition=e,this.log.setCursorShape(s?n:void 0);const h=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&u&&a){f&&f!==`
|
|
16
|
+
`&&this.options.stdout.write(f),h&&this.options.stdout.write(h),this.nativeLog.render(u,a,r),this.lastOutputHeight=r;return}s&&this.log.setCursorPosition(this.getActiveCursorPosition());const m=f&&f!==`
|
|
17
|
+
`;if(this.options.debug){m&&(this.fullStaticOutput+=f),this.lastOutput=o,this.lastOutputToRender=o,this.lastOutputHeight=r,this.options.stdout.write(this.fullStaticOutput+o);return}if(!this.interactive){m&&this.options.stdout.write(f),this.lastOutput=o,this.lastOutputToRender=`${o}
|
|
18
|
+
`,this.lastOutputHeight=r;return}if(this.isScreenReaderEnabled){const v=this.shouldSync();if(v&&this.options.stdout.write(H),m){const b=this.lastOutputHeight>0?G(this.lastOutputHeight):"";this.options.stdout.write(b+f),this.lastOutputHeight=0}if(o===this.lastOutput&&!m){v&&this.options.stdout.write(U);return}const d=z(this.options.stdout).columns,l=Ye(o,{trim:!1,width:d,wrapMode:"BREAK_WORDS"}).replace(/\n$/,"");if(m)this.options.stdout.write(l);else{const b=this.lastOutputHeight>0?G(this.lastOutputHeight):"";this.options.stdout.write(b+l)}this.lastOutput=o,this.lastOutputToRender=l,this.lastOutputHeight=l===""?0:l.split(`
|
|
19
|
+
`).length,v&&this.options.stdout.write(U);return}m&&(this.fullStaticOutput+=f),this.renderInteractiveFrame(o,r,m?f:"",h)};accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const e=B(ze.Provider,{value:this.accessibilityContextValue,children:B(be,{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?D.updateContainer(e,this.container,null,st):(D.updateContainerSync(e,this.container,null,st),D.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(H),this.log.clear(),this.options.stdout.write(t),this.restoreLastOutput(),e&&this.options.stdout.write(U)};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(H),this.log.clear(),this.options.stderr.write(t),this.restoreLastOutput(),e&&this.options.stdout.write(U)};unmount=t=>{if(this.isUnmounted||this.isUnmounting)return;this.isUnmounting=!0,this.beforeExitHandler&&(k.off("beforeExit",this.beforeExitHandler),this.beforeExitHandler=void 0);const e=this.options.stdout,{canWriteToStdout:s,hasWritableState:n}=le(e);pt(this.throttledOnRender,s),s&&!this.alternateScreen&&(!this.throttledOnRender||!this.hasPendingThrottledRender&&this.fullStaticOutput==="")&&(this.calculateLayout(),this.onRender()),this.isUnmounted=!0,this.unsubscribeExit(),pt(this.throttledLog,s),typeof this.restoreConsole=="function"&&this.restoreConsole();const o=()=>{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,Jt),this.writeBestEffort(this.options.stdout,ot),this.alternateScreen=!1):this.interactive?this.options.debug||this.log.done():this.options.stdout.write(this.options.debug?`
|
|
20
|
+
`:`${this.lastOutput}
|
|
21
|
+
`)),this.kittyProtocolEnabled=!1,It.delete(this.options.stdout);const{exitResult:r}=this,a=()=>{Pt(t)?this.rejectExitPromise(t):this.resolveExitPromise(r)};t!==void 0&&!Pt(t)?a():s&&n?this.options.stdout.write("",a):setImmediate(a)},u=D;this.options.concurrent?(D.updateContainerSync(null,this.container,null,st),D.flushSyncWork(),u.flushPassiveEffects?.(),o()):(D.updateContainerSync(null,this.container,null,st),D.flushSyncWork(),o())};async waitUntilExit(){return this.beforeExitHandler||(this.beforeExitHandler=()=>{this.unmount()},k.on("beforeExit",this.beforeExitHandler)),this.exitPromise}async waitUntilRenderFlush(){if(this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(await ce(),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}D.flushSyncWork();const t=this.options.stdout,{canWriteToStdout:e,hasWritableState:s}=le(t);if(pt(this.throttledOnRender,e),pt(this.throttledLog,e),e&&s){await new Promise(n=>{this.options.stdout.write("",()=>{n()})});return}await ce()}clear(){this.interactive&&!this.options.debug&&(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
|
|
22
|
+
`))}patchConsole(){this.options.debug||(this.restoreConsole=pi((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,Zt),this.writeBestEffort(this.options.stdout,at))}resolveInteractiveOption(t){return t??(!me&&!!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 o=s+n,u=o!=="",r=this.options.stdout.isTTY,a=r?z(this.options.stdout).rows:24,f=r&&e>=a,h=f?t:`${t}
|
|
23
|
+
`,m=k.platform==="win32",v=r&&m&&(f||this.lastOutputHeight>=a);if($i({isTty:r,isUnmounting:this.isUnmounting,isWindows:m,nextOutputHeight:e,previousOutputHeight:this.lastOutputHeight,viewportRows:a})){if(this.options.incrementalRendering&&!v){u&&(this.log.clear(),this.options.stdout.write(o)),(t!==this.lastOutput||this.log.isCursorDirty()||u)&&this.throttledLog(h),this.lastOutput=t,this.lastOutputToRender=h,this.lastOutputHeight=e;return}const l=this.shouldSync();l&&this.options.stdout.write(H),this.options.stdout.write(Ke+this.fullStaticOutput+n+h),this.lastOutput=t,this.lastOutputToRender=h,this.lastOutputHeight=e,this.log.sync(h),l&&this.options.stdout.write(U);return}if(u){const l=this.shouldSync();l&&this.options.stdout.write(H),this.log.clear(),this.options.stdout.write(o),this.log(h),l&&this.options.stdout.write(U)}else(t!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(h);this.lastOutput=t,this.lastOutputToRender=h,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){const{stdin:e,stdout:s}=this.options;let n=[];const o=()=>{this.cancelKittyDetection=void 0,clearTimeout(r),e.removeListener("data",u);const a=Vi(n);n=[],a.length>0&&e.unshift(Qt.from(a))},u=a=>{const f=typeof a=="string"?Qt.from(a):a;for(const h of f)n.push(h);zi(n)&&(o(),this.isUnmounted||this.enableKittyProtocol(t))};e.on("data",u);const r=setTimeout(o,200);this.cancelKittyDetection=o,s.write("\x1B[?u")}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,Jt),this.writeBestEffort(this.options.stdout,ot)),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,Zt),this.kittyProtocolEnabled&&this.kittyFlags&&this.writeBestEffort(this.options.stdout,`\x1B[>${te(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[>${te(t)}u`),this.kittyProtocolEnabled=!0}}const Cs=(i,t)=>{const e={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:k.stderr,stdin:k.stdin,stdout:k.stdout,...Xi(t)},s=Zi(e.stdout,()=>new Qi(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()}}},Xi=(i={})=>i instanceof Ae?{stdin:k.stdin,stdout:i}:i,Zi=(i,t)=>{const e=It.get(i);if(e===void 0){const s=t();return It.set(i,s),s}return k.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.
|
|
24
|
+
`),e};export{Cs as default};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { D as DOMElement } from "./dom.d-
|
|
3
|
-
import { T as TerminalSuspension } from "./app-context.d-
|
|
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;
|
|
@@ -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 {
|
|
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
|
-
|
|
3
|
-
|
|
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,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};
|
package/dist/react/index.d.ts
CHANGED
|
@@ -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) */
|
package/dist/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DevTools as o}from"../packem_shared/DevTools-
|
|
1
|
+
import{DevTools as o}from"../packem_shared/DevTools-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};
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { R as RenderOptions } from "../packem_shared/render.d-
|
|
3
|
-
import "../packem_shared/dom.d-
|
|
2
|
+
import { R as RenderOptions } from "../packem_shared/render.d-dEKhpngX.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/
|
|
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: "";
|
package/dist/testing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import x from"../packem_shared/render-
|
|
1
|
+
import{createRequire as _}from"node:module";import x from"../packem_shared/render-DrIzCc0i.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};
|