@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const n=({element:e,mouse:{x:t,y:o}})=>{const s=t<e.left||t>=e.left+e.width,l=o<e.top||o>=e.top+e.height;return!s&&!l};export{n as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const u=e=>{const r=/rgb:([\da-f]{2,4})\/([\da-f]{2,4})\/([\da-f]{2,4})/i.exec(e);if(!r)return null;const n=s=>s.length<=2?s.padStart(2,"0"):s.slice(0,2);return`#${n(r[1])}${n(r[2])}${n(r[3])}`},d=()=>{const e=process.env.TERM_PROGRAM??"";return new Set(["Alacritty","contour","foot","Ghostty","iTerm2","iTerm.app","kitty","rio","WezTerm"]).has(e)?!0:(process.env.TERM??"").startsWith("xterm")||!!process.env.WT_SESSION},f=(e,r,n,s=500)=>new Promise(a=>{let o="",i;const c=()=>{i&&clearTimeout(i),e.removeListener("data",t)},t=l=>{if(o+=l.toString(),o.length>256){c(),a(null);return}(o.includes("\x07")||o.includes("\x1B\\"))&&(c(),a(o))};i=setTimeout(()=>{c(),a(null)},s),e.on("data",t),r.write(n)}),m=async(e,r,n=500)=>{const s={},a=await f(e,r,"\x1B]10;?\x07",n);if(a){const t=u(a);t&&(s.foreground=t)}const o=await f(e,r,"\x1B]11;?\x07",n);if(o){const t=u(o);t&&(s.background=t)}const i=await f(e,r,"\x1B]12;?\x07",n);if(i){const t=u(i);t&&(s.cursor=t)}const c=[];for(let t=0;t<16;t++){const l=await f(e,r,`\x1B]4;${t};?\x07`,n);if(l){const x=u(l);c.push(x??"")}else c.push("")}return c.some(t=>t.length>0)&&(s.colors=c),s};export{d as isTerminalPaletteQuerySupported,m as queryTerminalPalette};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const o={disambiguateEscapeCodes:1,reportAllKeysAsEscapeCodes:8,reportAlternateKeys:4,reportAssociatedText:16,reportEventTypes:2};function r(t){let e=0;for(const s of t)e|=o[s];return e}const a={alt:2,capsLock:64,ctrl:4,hyper:16,meta:32,numLock:128,shift:1,super:8};export{o as kittyFlags,a as kittyModifiers,r as resolveFlags};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as l}from"node:module";let _;const f=e=>(_??=l(import.meta.url))(e),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,i=e=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[o,n]=t.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return t.getBuiltinModule(e)}return f(e)},{existsSync:d}=i("node:fs"),{createRequire:p}=i("node:module"),{dirname:a,join:r}=i("node:path"),{fileURLToPath:j}=i("node:url"),m=12,h=e=>{const o=p(e),n=a(j(e));let s=n;for(let c=0;c<m;c+=1){if(d(r(s,"package.json"))&&d(r(s,"index.js")))return o(r(s,"index.js"));const u=a(s);if(u===s)break;s=u}return o(r(n,"..","index.js"))};export{h as p};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import d from"yoga-layout";import{getScrollTop as P,getScrollLeft as R}from"./calculateScroll-D4Y_JR4H.js";import F from"./squashTextNodesWithMap-BmUSBPfc.js";const G=t=>{let e=t,o=0,n=0;for(;e?.parentNode;){if(!e.yogaNode)return;o+=e.yogaNode.getComputedLeft(),n+=e.yogaNode.getComputedTop(),e=e.parentNode}return{x:o,y:n}},W=t=>G(t),V=t=>{const e=G(t);if(!(!e||!t.yogaNode))return{x:e.x+t.yogaNode.getComputedBorder(d.EDGE_LEFT)+t.yogaNode.getComputedPadding(d.EDGE_LEFT),y:e.y+t.yogaNode.getComputedBorder(d.EDGE_TOP)+t.yogaNode.getComputedPadding(d.EDGE_TOP)}},z=t=>{const e=W(t);return{height:Math.round(t.yogaNode?.getComputedHeight()??0),width:Math.round(t.yogaNode?.getComputedWidth()??0),x:Math.round(e?.x??0),y:Math.round(e?.y??0)}},A=t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedWidth()??0,n=e.getComputedBorder(d.EDGE_LEFT),i=e.getComputedBorder(d.EDGE_RIGHT);return Math.round(o-n-i)},U=t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedHeight()??0,n=e.getComputedBorder(d.EDGE_TOP),i=e.getComputedBorder(d.EDGE_BOTTOM);return Math.round(o-n-i)},S=t=>{const{yogaNode:e}=t;if(!e)return{height:0,width:0,x:0,y:0};const o=e.getComputedWidth()??0,n=e.getComputedHeight()??0;let i=e.getComputedLeft(),r=e.getComputedTop(),a=t.parentNode;for(;a?.yogaNode;){if(i+=a.yogaNode.getComputedLeft(),r+=a.yogaNode.getComputedTop(),a.nodeName==="ink-box"){const l=a.style.overflow??"visible",s=a.style.overflowX??l;(a.style.overflowY??l)==="scroll"&&(r-=P(a)),s==="scroll"&&(i-=R(a))}a=a.parentNode}return{height:Math.round(n),width:Math.round(o),x:Math.round(i),y:Math.round(r)}},j=t=>{const e=t.internal_scrollState?.scrollHeight??0,o=t.internal_scrollState?.actualScrollHeight??0;return Math.max(0,e-o)},H=t=>{const{axis:e,clientDimension:o,scrollbarDimension:n,scrollDimension:i,scrollPosition:r}=t,a=n*2,l=Math.max(e==="vertical"?2:1,Math.round(o/i*a)),s=i-o,h=a-l,g=s>0?Math.round(r/s*h):0,u=g,m=g+l,c=Math.floor(u/2);return{endIndex:Math.min(n,Math.ceil(m/2)),startIndex:c,thumbEndHalf:m,thumbStartHalf:u}},b=t=>{const{axis:e,clientDimension:o,hasOppositeScrollbar:n,height:i,marginBottom:r,marginRight:a,scrollDimension:l,scrollPosition:s,width:h,x:g,y:u}=t;if(l<=o)return;if(e==="vertical"){const{endIndex:N,startIndex:x,thumbEndHalf:T,thumbStartHalf:_}=H({axis:e,clientDimension:o,scrollbarDimension:i,scrollDimension:l,scrollPosition:s}),E=g+h-1-a;return{height:i,thumb:{end:N,endHalf:T,height:N-x,start:x,startHalf:_,width:1,x:E,y:u+x},width:1,x:E,y:u}}const m=h-(n?1:0),{endIndex:c,startIndex:p,thumbEndHalf:C,thumbStartHalf:y}=H({axis:e,clientDimension:o,scrollbarDimension:m,scrollDimension:l,scrollPosition:s}),D=u+i-1-r;return{height:1,thumb:{end:c,endHalf:C,height:1,start:p,startHalf:y,width:c-p,x:g+p,y:D},width:m,x:g,y:D}},q=(t,e)=>{const{yogaNode:o}=t;if(!o)return;const n=t.style.overflow??"visible";if((t.style.overflowY??n)!=="scroll")return;const i=t.internal_scrollState?.clientHeight??0,r=t.internal_scrollState?.scrollHeight??0;if(r<=i)return;const{x:a,y:l}=e??S(t),s=o.getComputedHeight()-o.getComputedBorder(d.EDGE_TOP)-o.getComputedBorder(d.EDGE_BOTTOM);return b({axis:"vertical",clientDimension:i,hasOppositeScrollbar:!1,height:s,marginBottom:o.getComputedBorder(d.EDGE_BOTTOM),marginRight:o.getComputedBorder(d.EDGE_RIGHT),scrollDimension:r,scrollPosition:t.internal_scrollState?.scrollTop??0,width:o.getComputedWidth()-o.getComputedBorder(d.EDGE_LEFT),x:a+o.getComputedBorder(d.EDGE_LEFT),y:l+o.getComputedBorder(d.EDGE_TOP)})},J=(t,e)=>{const{yogaNode:o}=t;if(!o)return;const n=t.style.overflow??"visible";if((t.style.overflowX??n)!=="scroll")return;const i=t.internal_scrollState?.clientWidth??0,r=t.internal_scrollState?.scrollWidth??0;if(r<=i)return;const{x:a,y:l}=e??S(t),s=t.style.overflowY??n,h=t.internal_scrollState?.clientHeight??0,g=t.internal_scrollState?.scrollHeight??0,u=s==="scroll"&&g>h;return b({axis:"horizontal",clientDimension:i,hasOppositeScrollbar:u,height:o.getComputedHeight()-o.getComputedBorder(d.EDGE_TOP),marginBottom:o.getComputedBorder(d.EDGE_BOTTOM),marginRight:o.getComputedBorder(d.EDGE_RIGHT),scrollDimension:r,scrollPosition:t.internal_scrollState?.scrollLeft??0,width:o.getComputedWidth()-o.getComputedBorder(d.EDGE_LEFT)-o.getComputedBorder(d.EDGE_RIGHT),x:a+o.getComputedBorder(d.EDGE_LEFT),y:l+o.getComputedBorder(d.EDGE_TOP)})},K=(t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedTop(),n=t.parentNode;for(;n&&n!==e;)n.yogaNode&&(o+=n.yogaNode.getComputedTop()),n=n.parentNode;if(!(e!==void 0&&n!==e))return Math.round(o)},Q=(t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedLeft(),n=t.parentNode;for(;n&&n!==e;)n.yogaNode&&(o+=n.yogaNode.getComputedLeft()),n=n.parentNode;if(!(e!==void 0&&n!==e))return Math.round(o)},k=t=>t.nodeName==="#text"?t.nodeValue:t.nodeName==="ink-text"||t.nodeName==="ink-virtual-text"?F(t):"",Z=t=>{const e=[],o=(r,a,l)=>{const{visualX:s,visualY:h,x:g,y:u}=a;let m=0,c=0,p=l;const{userSelect:C}=r.style;if(C==="none"?p=!1:(C==="text"||C==="all")&&(p=!0),r.nodeName==="ink-text"||r.nodeName==="ink-virtual-text"){if(p){const y=k(r);return e.push({height:Math.round(r.yogaNode?.getComputedHeight()??0),node:r,text:y,visualX:Math.round(s),visualY:Math.round(h),width:Math.round(r.yogaNode?.getComputedWidth()??0),x:Math.round(g),y:Math.round(u)}),{h:0,hasContent:!0,v:0}}return{h:r.yogaNode?.getComputedWidth()??0,hasContent:!1,v:r.yogaNode?.getComputedHeight()??0}}if(r.nodeName==="ink-box"||r.nodeName==="ink-root"){if(!r.yogaNode||r.yogaNode.getDisplay()===d.DISPLAY_NONE)return{h:0,hasContent:!1,v:0};const y=r.yogaNode.getComputedBorder(d.EDGE_TOP),D=r.yogaNode.getComputedBorder(d.EDGE_BOTTOM),N=r.yogaNode.getComputedBorder(d.EDGE_LEFT),x=r.yogaNode.getComputedBorder(d.EDGE_RIGHT);m+=y+D,c+=N+x;const T=r.yogaNode.getFlexDirection(),_=T===d.FLEX_DIRECTION_COLUMN||T===d.FLEX_DIRECTION_COLUMN_REVERSE;let E=0,v=0,M=!1;for(const f of r.childNodes)if(f.yogaNode){const O=g+f.yogaNode.getComputedLeft()-N-E,L=u+f.yogaNode.getComputedTop()-y-v,w=s+f.yogaNode.getComputedLeft(),I=h+f.yogaNode.getComputedTop(),B=o(f,{visualX:w,visualY:I,x:O,y:L},p);B.hasContent&&(M=!0),_?v+=B.v:E+=B.h}return _?m+=v:c+=E,{h:c,hasContent:M,v:m}}return{h:0,hasContent:!1,v:0}},{h:n,v:i}=o(t,{visualX:0,visualY:0,x:0,y:0},!0);return e.sort((r,a)=>r.y!==a.y?r.y-a.y:r.x-a.x),{fragments:e,removedHorizontal:Math.round(n),removedVertical:Math.round(i)}};export{z as R,H as a,Z as b,b as c,S as d,J as e,U as f,j as g,A as h,Q as i,K as j,k,q as l,V as u};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{isFullwidthCodePoint as G,getStringWidth as q}from"@visulima/string";import{t as J}from"./ansi-tokenizer-BU67A126.js";let N=class{map;maxDataSize;maxKeys;currentDataSize=0;constructor(t,e){this.map=new Map,this.maxKeys=t,this.maxDataSize=e}get size(){return this.map.size}clear(){this.map.clear(),this.currentDataSize=0}get(t){if(!this.map.has(t))return;const e=this.map.get(t);return this.map.delete(t),this.map.set(t,e),e}set(t,e){const s=t.length;if(!(s>this.maxDataSize)){for(this.map.has(t)&&(this.map.delete(t),this.currentDataSize-=s);this.currentDataSize+s>this.maxDataSize&&this.map.size>0;){const n=this.map.keys().next().value;if(n===void 0)break;this.map.delete(n),this.currentDataSize-=n.length}for(;this.map.size>=this.maxKeys;){const n=this.map.keys().next().value;if(n===void 0)break;this.map.delete(n),this.currentDataSize-=n.length}this.map.set(t,e),this.currentDataSize+=s}}};const Q=1,X=2,K=4,E=8,O=16,A=32,R=64,x=128,d=1073741823,k=1073741824;class m{length=0;static emptyCache=new Map;text;charData;spans;_cachedTrimmedLength;static empty(t){if(t<=0)return new m;const e=m.emptyCache.get(t);if(e)return e.clone();const s=new m;s.length=t,s.text=" ".repeat(t),s.charData=Array.from({length:t});for(let n=0;n<t;n++)s.charData[n]=n;return s.spans=[{formatFlags:0,length:t}],s._cachedTrimmedLength=0,Object.freeze(s.spans[0]),Object.freeze(s.spans),Object.freeze(s),m.emptyCache.set(t,s),s.clone()}getValue(t){if(this.text===void 0||t<0||t>=this.length)return"";const e=this.charData[t]&d,s=t+1<this.length?this.charData[t+1]&d:this.text.length;return this.text.slice(e,s)}getTextRange(t,e){if(this.text===void 0||t<0||e>this.length||t>=e)return"";const s=this.charData[t]&d,n=e<this.length?this.charData[e]&d:this.text.length;return this.text.slice(s,n)}getSpan(t){if(this.spans===void 0||t<0||t>=this.length)return;let e=0;for(const s of this.spans){if(t<e+s.length)return s;e+=s.length}}getFullWidth(t){return this.charData===void 0||t<0||t>=this.length?!1:(this.charData[t]&k)!==0}hasStyles(t){const e=this.getSpan(t);return e?(e.formatFlags&~x)!==0||e.fgColor!==void 0||e.bgColor!==void 0||e.link!==void 0:!1}getFormatFlags(t){let e=this.getSpan(t)?.formatFlags??0;return this.getFullWidth(t)&&(e|=x),e}getFgColor(t){return this.getSpan(t)?.fgColor}getBgColor(t){return this.getSpan(t)?.bgColor}getLink(t){return this.getSpan(t)?.link}setInverted(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{e?s.formatFlags|=A:s.formatFlags&=~A})}setBackgroundColor(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{s.bgColor=e})}setForegroundColor(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{s.fgColor=e})}setChar(t,e,s,n,a,h){if(t<0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const i=(s&x)!==0,o=s&~x,l=this.charData[t]&d,c=t+1<this.length?this.charData[t+1]&d:this.text.length,p=c-l,b=e.length;if(this.text=this.text.slice(0,l)+e+this.text.slice(c),p!==b){const f=b-p;for(let C=t+1;C<this.length;C++){const S=this.charData[C],F=S&d,T=S&k;this.charData[C]=F+f|T}}if(this.charData[t]=l|(i?k:0),this.trySetStyleAtIndex(t,o,n,a,h))return;this.splitSpansAt(t),this.splitSpansAt(t+1);let u=0;for(let f=0;f<this.spans.length;f++){const C=this.spans[f];if(u===t&&C.length===1){this.spans[f]={bgColor:a,fgColor:n,formatFlags:o,length:1,link:h};break}u+=C.length}this.mergeSpans()}setCharFast(t,e,s,n,a,h){if(t<0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const i=(s&x)!==0,o=s&~x,l=this.charData[t]&d,c=t+1<this.length?this.charData[t+1]&d:this.text.length,p=c-l;if(e.length===p)e!==this.text.slice(l,c)&&(this.text=this.text.slice(0,l)+e+this.text.slice(c)),this.charData[t]=l|(i?k:0);else{if(this.text=this.text.slice(0,l)+e+this.text.slice(c),p!==e.length){const u=e.length-p;for(let f=t+1;f<this.length;f++){const C=this.charData[f];this.charData[f]=(C&d)+u|C&k}}this.charData[t]=l|(i?k:0)}if(this.trySetStyleAtIndex(t,o,n,a,h))return;this.splitSpansAt(t),this.splitSpansAt(t+1);let b=0;for(let u=0;u<this.spans.length;u++){const f=this.spans[u];if(b===t&&f.length===1){this.spans[u]={bgColor:a,fgColor:n,formatFlags:o,length:1,link:h};break}b+=f.length}this.mergeSpans()}writeFrom(t,e,s=0,n){const a=n??e.length-s;if(a<=0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const h=Math.min(a,this.length-t,e.length-s),i=this.charData[t]&d,o=t+h<this.length?this.charData[t+h]&d:this.text.length;let l="";for(let g=0;g<h;g++)l+=e.getValue(s+g);const c=o-i,p=l.length-c;this.text=this.text.slice(0,i)+l+this.text.slice(o);let b=i;for(let g=0;g<h;g++){const D=e.getFullWidth(s+g);this.charData[t+g]=b|(D?k:0),b+=e.getValue(s+g).length}if(p!==0)for(let g=t+h;g<this.length;g++){const D=this.charData[g];this.charData[g]=(D&d)+p|D&k}this.splitSpansAt(t),this.splitSpansAt(t+h);const u=[];let f=0;for(const g of e.getSpans()){const D=f+g.length,$=Math.max(s,f),W=Math.min(s+h,D);if($<W&&u.push({...g,length:W-$}),f=D,f>=s+h)break}let C=0,S=0;for(let g=0;g<this.spans.length;g++){if(S===t){C=g;break}S+=this.spans[g].length}let F=0,T=0;for(let g=C;g<this.spans.length&&T<h;g++)T+=this.spans[g].length,F++;this.spans.splice(C,F,...u),this.mergeSpans()}pushChar(t,e,s,n,a){this._cachedTrimmedLength=void 0,this.ensureInitialized();const h=(e&x)!==0,i=e&~x,o=this.text.length;this.text=(this.text??"")+t,this.charData.push(o|(h?k:0));const l=this.spans.at(-1);l?.formatFlags===i&&l.fgColor===s&&l.bgColor===n&&l.link===a?l.length++:this.spans.push({bgColor:n,fgColor:s,formatFlags:i,length:1,link:a}),this.length++}clone(){if(this.charData===void 0)return new m;const t=new m;return t.length=this.length,t.text=this.text,t.charData=[...this.charData],t.spans=this.spans.map(e=>({...e})),t._cachedTrimmedLength=this._cachedTrimmedLength,t}slice(t,e){if(this.charData===void 0)return new m;const s=Math.max(0,t),n=e===void 0?this.length:Math.min(this.length,e);if(s>=n)return new m;if(s===0&&n===this.length)return this.clone();const a=new m;a.length=n-s,a.charData=Array.from({length:a.length});const h=this.charData[s]&d,i=n<this.length?this.charData[n]&d:this.text.length;a.text=this.text.slice(h,i);for(let c=0;c<a.length;c++){const p=this.charData[s+c],b=p&d,u=p&k;a.charData[c]=b-h|u}const o=[];let l=0;for(const c of this.spans){const p=l,b=l+c.length,u=Math.max(s,p),f=Math.min(n,b);if(u<f&&o.push({...c,length:f-u}),l+=c.length,l>=n)break}return a.spans=o,a.mergeSpans(),a}combine(...t){if(t.length===0)return this.clone();const e=[this,...t].filter(i=>i.length>0);if(e.length===0)return new m;if(e.length===1)return e[0].clone();let s=0;for(const i of e)s+=i.length;const n=new m;n.length=s,n.text=e.map(i=>i.getText()).join(""),n.charData=Array.from({length:s});let a=0,h=0;for(const i of e){const o=i.charData,l=i.getText();if(o)for(let c=0;c<i.length;c++){const p=o[c],b=p&d,u=p&k;n.charData[a+c]=h+b|u}else for(let c=0;c<i.length;c++)n.charData[a+c]=h+c;a+=i.length,h+=l.length}return n.spans=e.flatMap(i=>i.getSpans().map(o=>({...o}))),n.mergeSpans(),n}getTrimmedLength(){if(this._cachedTrimmedLength!==void 0)return this._cachedTrimmedLength;if(this.length===0)return this._cachedTrimmedLength=0,0;if(this.text===void 0||this.charData===void 0)return this._cachedTrimmedLength=0,0;let t=this.length-1;if(this.spans)for(let e=this.spans.length-1;e>=0;e--){const s=this.spans[e];if((s.formatFlags&~x)!==0||s.fgColor!==void 0||s.bgColor!==void 0||s.link!==void 0)return this._cachedTrimmedLength=t+1,this._cachedTrimmedLength;for(let n=0;n<s.length;n++){const a=this.charData[t]&d;if((t+1<this.length?this.charData[t+1]&d:this.text.length)-a!==1||this.text[a]!==" ")return this._cachedTrimmedLength=t+1,this._cachedTrimmedLength;t--}}return this._cachedTrimmedLength=0,0}trimEnd(){const t=this.getTrimmedLength();return t===this.length?this:t===0?new m:this.slice(0,t)}equals(t){if(this.length!==t.length)return!1;if(this.length===0)return!0;if(this.getText()!==t.getText())return!1;const e=this.getSpans(),s=t.getSpans();if(e.length!==s.length)return!1;for(const[h,i]of e.entries()){const o=i,l=s[h];if(o.length!==l.length||o.formatFlags!==l.formatFlags||o.fgColor!==l.fgColor||o.bgColor!==l.bgColor||o.link!==l.link)return!1}const n=this.charData,a=t.charData;if(n&&a){for(let h=0;h<this.length;h++)if(n[h]!==a[h])return!1}return!0}getText(){return this.text??""}getSpans(){return this.spans??[]}getValues(){return Array.from({length:this.length},(t,e)=>this.getValue(e))}*[Symbol.iterator](){if(this.length===0)return;let t=0,e=0;const s=this.getSpans();for(let n=0;n<this.length;n++){const a=s[t],h=a?a.formatFlags:0,i=this.getFullWidth(n);yield{bgColor:a?.bgColor,fgColor:a?.fgColor,formatFlags:h|(i?x:0),fullWidth:i,hasStyles:(h&~x)!==0||a?.fgColor!==void 0||a?.bgColor!==void 0||a?.link!==void 0,link:a?.link,value:this.getValue(n)},a&&(e++,e>=a.length&&(t++,e=0))}}updateSpanAt(t,e){if(t<0||t>=this.length)return;this.ensureInitialized(),this.splitSpansAt(t),this.splitSpansAt(t+1);let s=0;for(const n of this.spans){if(s===t&&n.length===1){e(n);break}s+=n.length}this.mergeSpans()}ensureWidth(t){if(t<=this.length)return;this.ensureInitialized();const e=this.length,s=t-e,n=this.text.length;for(let h=0;h<s;h++)this.charData.push(n);this.length=t;const a=this.spans.at(-1);a?.formatFlags===0&&a.fgColor===void 0&&a.bgColor===void 0&&a.link===void 0?a.length+=s:this.spans.push({formatFlags:0,length:s})}ensureInitialized(){if(this.charData===void 0&&(this.text="",this.charData=Array.from({length:this.length}),this.spans=this.length>0?[{formatFlags:0,length:this.length}]:[],this.length>0&&this.text.length===0)){this.text=" ".repeat(this.length);for(let t=0;t<this.length;t++)this.charData[t]=t}}splitSpansAt(t){if(this.spans===void 0||t<=0||t>=this.length)return;let e=0;for(let s=0;s<this.spans.length;s++){const n=this.spans[s];if(t>e&&t<e+n.length){const a=t-e,h=n.length-a;this.spans.splice(s,1,{...n,length:a},{...n,length:h});return}e+=n.length}}trySetStyleAtIndex(t,e,s,n,a){if(!this.spans)return!1;let h=0,i=-1,o;for(let l=0;l<this.spans.length;l++){const c=this.spans[l];if(h<=t&&h+c.length>t){i=l,o=c;break}h+=c.length}if(!o)return!1;if(o.formatFlags===e&&o.fgColor===s&&o.bgColor===n&&o.link===a)return!0;if(t===h&&i>0){const l=this.spans[i-1];if(l.formatFlags===e&&l.fgColor===s&&l.bgColor===n&&l.link===a)return l.length+=1,o.length===1?this.spans.splice(i,1):o.length-=1,!0}if(t===h+o.length-1&&i<this.spans.length-1){const l=this.spans[i+1];if(l.formatFlags===e&&l.fgColor===s&&l.bgColor===n&&l.link===a)return l.length+=1,o.length===1?this.spans.splice(i,1):o.length-=1,!0}return!1}mergeSpans(){if(this.spans===void 0)return;const t=[];for(const e of this.spans){if(e.length===0)continue;const s=t.at(-1);s?.formatFlags===e.formatFlags&&s.fgColor===e.fgColor&&s.bgColor===e.bgColor&&s.link===e.link?s.length+=e.length:t.push({...e})}this.spans=t}}const V={black:0,blue:4,cyan:6,gray:8,green:2,grey:8,magenta:5,red:1,white:7,yellow:3},P={blackBright:8,blueBright:12,cyanBright:14,greenBright:10,magentaBright:13,redBright:9,whiteBright:15,yellowBright:11},H=/^ansi256\(\s?(\d+)\s?\)$/,j=/^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/,xt=r=>{const t=V[r];if(t!==void 0)return t;const e=P[r];if(e!==void 0)return e;const s=H.exec(r);if(s)return Number(s[1])&255;if(r.startsWith("#")&&r.length===7){const a=Number.parseInt(r.slice(1,3),16),h=Number.parseInt(r.slice(3,5),16),i=Number.parseInt(r.slice(5,7),16);return 16+36*Math.round(a/51)+6*Math.round(h/51)+Math.round(i/51)}const n=j.exec(r);return n?16+36*Math.round(Number(n[1])/51)+6*Math.round(Number(n[2])/51)+Math.round(Number(n[3])/51):255},kt=(r,t)=>{const e=t?30:40,s=V[r];if(s!==void 0)return[e+s];const n=P[r];if(n!==void 0)return[e+60+(n-8)];if(r.startsWith("#")&&r.length===7){const i=Number.parseInt(r.slice(1,3),16),o=Number.parseInt(r.slice(3,5),16),l=Number.parseInt(r.slice(5,7),16);return[t?38:48,2,i,o,l]}const a=H.exec(r);if(a)return[t?38:48,5,Number(a[1])];const h=j.exec(r);return h?[t?38:48,2,Number(h[1]),Number(h[2]),Number(h[3])]:[]},w=r=>{const t=["black","red","green","yellow","blue","magenta","cyan","white"];return r>=0&&r<=7?t[r]:`ansi256(${r})`},_=()=>({bgColor:void 0,fgColor:void 0,formatFlags:0,link:void 0}),Y=(r,t)=>{if(t.length===0)return _();const e=(t.includes(":")?t.replaceAll(":",";"):t).split(";").filter(o=>o.length>0).map(Number);let{bgColor:s,fgColor:n,formatFlags:a,link:h}=r,i=0;for(;i<e.length;){const o=e[i];switch(o){case 0:{a=0,n=void 0,s=void 0,h=void 0;break}case 1:{a|=Q;break}case 2:{a|=X;break}case 3:{a|=K;break}case 4:{a|=E;break}case 7:{a|=A;break}case 8:{a|=R;break}case 9:{a|=O;break}case 22:{a&=-4;break}case 23:{a&=~K;break}case 24:{a&=~E;break}case 27:{a&=~A;break}case 28:{a&=~R;break}case 29:{a&=~O;break}case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:{n=w(o-30);break}case 38:{e[i+1]===5&&e[i+2]!==void 0?(n=w(e[i+2]),i+=2):e[i+1]===2&&i+4<e.length&&(n=`rgb(${e[i+2]}, ${e[i+3]}, ${e[i+4]})`,i+=4);break}case 39:{n=void 0;break}case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:{s=w(o-40);break}case 48:{e[i+1]===5&&e[i+2]!==void 0?(s=w(e[i+2]),i+=2):e[i+1]===2&&i+4<e.length&&(s=`rgb(${e[i+2]}, ${e[i+3]}, ${e[i+4]})`,i+=4);break}case 49:{s=void 0;break}case 90:case 91:case 92:case 93:case 94:case 95:case 96:case 97:{n=`ansi256(${o-90+8})`;break}case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:{s=`ansi256(${o-100+8})`;break}}i++}return{bgColor:s,fgColor:n,formatFlags:a,link:h}},y=127462,L=127487,Z=127995,tt=127999,et=8205,st=917504,nt=917631,at=new RegExp("\\p{Mark}","u"),rt=new Intl.Segmenter(void 0,{granularity:"grapheme"}),it=(r,t)=>!!(G(t)||r.includes("️")||t>=y&&t<=L),ht=/(?:\u001B\]|\u009D)8;([^;]*);(.*?)(?:\u001B\\|\u0007|\u009C)/,lt=r=>{const t=ht.exec(r);return!t?.[2]||t[2].length===0?void 0:r.endsWith("\x1B\\")?`ST:${t[2]}`:t[2]},U=(r,t,e)=>{const s=rt.segment(r),n=[];for(const{segment:a}of s)n.push(a);for(let a=0;a<n.length;a++){let h=n[a];if(h===" "){for(let l=0;l<4;l++)t.pushChar(" ",e.formatFlags,e.fgColor,e.bgColor,e.link);continue}if(h==="\b")continue;const i=h.codePointAt(0);if(!i)continue;if(i>=y&&i<=L&&a+1<n.length){const l=n[a+1],c=l.codePointAt(0);c&&c>=y&&c<=L&&(h+=l,a++)}else for(;a+1<n.length;){const l=n[a+1],c=l.codePointAt(0);if(!c)break;const p=at.test(String.fromCodePoint(c)),b=c>=Z&&c<=tt,u=c===et,f=c>=st&&c<=nt;if(!p&&!b&&!u&&!f)break;h+=l,a++,u&&a+1<n.length&&(h+=n[a+1],a++)}const o=it(h,i)?e.formatFlags|x:e.formatFlags;t.pushChar(h,o,e.fgColor,e.bgColor,e.link)}},ot=r=>{if(r.length===0)return new m;const t=J(r),e=new m;let s=_();for(const n of t)switch(n.type){case"csi":{n.finalCharacter==="m"&&(s=Y(s,n.parameterString));break}case"osc":{const a=lt(n.value);a!==void 0?s={...s,link:a}:n.value.includes("8;")&&(s={...s,link:void 0});break}case"text":{U(n.value,e,s);break}}return e},ct=/^[\u0020-\u007E]*$/,Dt=r=>{if(r.length===0)return new m;const t=new m;if(ct.test(r)){for(const e of r)t.pushChar(e,0);return t}return U(r,t,_()),t},I=new N(1e4,1e6),M=new N(1e4,1e6),v=new N(1e4,1e6);let z=!0,B=q;const St=r=>{z=r,r||v.clear()},vt=()=>{v.clear()},Ft=r=>{B=r,gt()},gt=()=>{I.clear(),M.clear(),v.clear()},ft=r=>{if(r.length===1){const s=r.codePointAt(0);if(s!==void 0&&s>=32&&s<127)return 1}const t=M.get(r);if(t!==void 0)return t;let e;try{e=B(r)}catch{e=1}return M.set(r,e),e},ut=r=>{try{return B(r)}catch{return 1}},Tt=r=>{if(r.length===0)return{height:0,width:0};const t=I.get(r);if(t)return t;const e=r.split(`
|
|
2
|
-
`);let s=0;for(const a of e){const h=ut(a);h>s&&(s=h)}const n={height:e.length,width:s};return I.set(r,n),n},wt=r=>{if(z){const e=v.get(r);if(e!==void 0)return e}const t=ot(r);return z&&v.set(r,t),t},mt=r=>{let t=0;for(let e=0;e<r.length;e++)t+=ft(r.getValue(e));return t},pt=r=>{if(r.length===0)return[new m];const t=[];let e=0;for(let s=0;s<r.length;s++)r.getValue(s)===`
|
|
3
|
-
`&&(t.push(s>e?r.slice(e,s):new m),e=s+1);return t.push(e<r.length?r.slice(e):new m),t},At=r=>{if(r.length===0)return{height:0,width:0};const t=pt(r);let e=0;for(const s of t)e=Math.max(e,mt(s));return{height:t.length,width:e}};export{Q as B,X as D,x as F,R as H,K as I,m as S,E as U,vt as a,Ft as b,gt as c,mt as d,A as e,O as f,kt as g,xt as h,ft as i,ot as j,pt as k,At as m,Dt as p,St as s,wt as t,Tt as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createContext as o}from"react";const t=o(null);t.displayName="MouseContext";export{t as o};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as o}from"./ansi-parser-DlgLtOYO.js";export{o as parseSgrMouse};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as x}from"./measure-element-D4M9iSYp.js";const u=(o,l)=>{const{initialState:r,onNewline:a,onSpace:c,onText:m}=l;if(o.nodeName!=="ink-box"&&o.nodeName!=="ink-root"&&o.nodeName!=="ink-text"&&o.nodeName!=="ink-virtual-text"||!o.yogaNode)return{lineBottom:0,state:r()};const{fragments:s}=x(o),t=r();t.currentX=0,t.lineBottom=0,t.yieldedContent=!1;for(const e of s){if(e.y>=t.lineBottom){const n=e.y-t.lineBottom,i=t.yieldedContent?1+n:n;i>0&&(a(i,t),t.currentX=0),t.lineBottom=e.y}if(e.x>t.currentX){const n=e.x-t.currentX;c(n,t),t.currentX=e.x}if(e.text.length>0&&(t.yieldedContent=!0,m(e,t)),(e.text.match(/\n/g)??[]).length>0){const n=e.text.lastIndexOf(`
|
|
2
|
-
`);t.currentX=e.text.length-n-1}else t.currentX+=e.text.length;t.lineBottom=Math.max(t.lineBottom,e.y+e.height)}return{lineBottom:t.lineBottom,state:t}};export{u as processLayout};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createContext as C}from"react";import y from"react-reconciler";import{NoEventPriority as h,DiscreteEventPriority as v,DefaultEventPriority as b}from"react-reconciler/constants.js";import{unstable_shouldYield as T,unstable_scheduleCallback as x,unstable_now as k,unstable_cancelCallback as I}from"scheduler";import{LayoutNode as c}from"./LayoutNode-LPYsuzBg.js";import{applyStyles as m,resolveColor as f}from"./NAMED_COLORS-82DpREQV.js";import{g as P}from"./text-width-e49vlbQH.js";const u=new WeakMap;function M(e,t){u.set(e,t)}function H(e){u.delete(e)}let d=h;function p(e){const t=f(e.fg===void 0?e.color===void 0?void 0:e.color:e.fg),n=f(e.bg===void 0?e.backgroundColor===void 0?void 0:e.backgroundColor:e.bg);let r;return e.styles===void 0?(r=0,e.bold&&(r|=1),(e.dim||e.dimColor)&&(r|=2),e.italic&&(r|=4),e.underline&&(r|=8),e.blink&&(r|=16),e.inverse&&(r|=32),e.hidden&&(r|=64),e.strikethrough&&(r|=128)):r=e.styles,{bg:n,fg:t,styles:r}}const S={afterActiveInstanceBlur:()=>{},appendChild(e,t){e.insertChild(t,e.children.length)},appendChildToContainer(e,t){e.insertChild(t,e.children.length)},appendInitialChild(e,t){e.insertChild(t,e.children.length)},beforeActiveInstanceBlur:()=>{},cancelCallback:I,cancelTimeout:clearTimeout,clearContainer(e){},commitTextUpdate(e,t,n){e.text=n,e.yogaNode.markDirty()},commitUpdate(e,t,n,r,s){m(e.yogaNode,r);const{bg:o,fg:i,styles:a}=p(r);e.fg=i,e.bg=o,e.styles=a,e._style=r,e.transform=typeof r.transform=="function"?r.transform:void 0},createInstance(e,t,n,r,s){const o=new c,i={...t};i.flexDirection===void 0&&(i.flexDirection="row"),i.flexShrink===void 0&&(i.flexShrink=1),m(o.yogaNode,i);const{bg:a,fg:l,styles:g}=p(t);return o.fg=l,o.bg=a,o.styles=g,o._style=t,typeof t.transform=="function"&&(o.transform=t.transform),o},createTextInstance(e,t,n,r){const s=new c;return s.text=e,s.yogaNode.setWidth(P(e)),s.yogaNode.setHeight(1),s},detachDeletedInstance:e=>{e.destroy()},finalizeInitialChildren(e,t,n,r,s){return!1},getChildHostContext(e,t,n){return{isInsideText:t==="text"}},getCurrentEventPriority:()=>v,getCurrentUpdatePriority:()=>d,getInstanceFromNode:()=>null,getPublicInstance(e){return e},getRootHostContext(e){return{isInsideText:!1}},hideInstance(e){e._hidden=!0},hideTextInstance(e){e._hidden=!0},HostTransitionContext:C(null),insertBefore(e,t,n){t.parent&&t.remove();const r=e.children.indexOf(n);e.insertChild(t,r)},isPrimaryRenderer:!0,maySuspendCommit:()=>!0,noTimeout:-1,NotPendingTransition:void 0,now:k,preloadInstance:()=>!0,prepareForCommit(e){return null},preparePortalMount:()=>{},prepareScopeUpdate:()=>{},prepareUpdate(e,t,n,r,s,o){if(n===r)return null;let i=0;for(const l of Object.keys(n))l!=="children"&&(i+=1);let a=0;for(const l of Object.keys(r))if(l!=="children"&&(a+=1,n[l]!==r[l]))return!0;return i===a?null:!0},removeChild(e,t){t.remove()},removeChildFromContainer(e,t){t.remove()},requestPostPaintCallback:()=>{},resetAfterCommit(e){const t=u.get(e);if(typeof t=="function"){t();return}},resolveEventTimeStamp:()=>-1.1,resolveEventType:()=>null,resolveUpdatePriority(){return d!==h?d:b},scheduleCallback:x,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){d=e},shouldAttemptEagerTransition:()=>!1,shouldSetTextContent(e,t){return!1},shouldYield:T,startSuspendingCommit:()=>{},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance:()=>{},trackSchedulerEvent:()=>{},unhideInstance(e,t){e._hidden=!1},unhideTextInstance(e,t){e._hidden=!1},waitForCommitToBeReady:()=>null,warnsIfNotActing:!0},B=y(S);export{B as T,M as r,H as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as $}from"node:module";import{version as S,createContext as L}from"react";import R from"react-reconciler";import{NoEventPriority as A,DefaultEventPriority as b}from"react-reconciler/constants.js";import{unstable_shouldYield as P,unstable_scheduleCallback as D,unstable_now as O,unstable_cancelCallback as G}from"scheduler";import n from"yoga-layout";import{b as _,d as f,s as m,m as p,e as F,r as h,f as v,c as w,h as T,j as I}from"./dom-rphpG0kf.js";const x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=x,W=[["top",n.EDGE_TOP],["right",n.EDGE_RIGHT],["bottom",n.EDGE_BOTTOM],["left",n.EDGE_LEFT]],k=(t,e)=>{if("position"in e){let r=n.POSITION_TYPE_RELATIVE;e.position==="absolute"?r=n.POSITION_TYPE_ABSOLUTE:e.position==="static"&&(r=n.POSITION_TYPE_STATIC),t.setPositionType(r)}for(const[r,s]of W){if(!(r in e))continue;const l=e[r];if(typeof l=="string"){t.setPositionPercent(s,Number.parseFloat(l));continue}t.setPosition(s,l)}},B=(t,e)=>{"margin"in e&&t.setMargin(n.EDGE_ALL,e.margin??0),"marginX"in e&&t.setMargin(n.EDGE_HORIZONTAL,e.marginX??0),"marginY"in e&&t.setMargin(n.EDGE_VERTICAL,e.marginY??0),"marginLeft"in e&&t.setMargin(n.EDGE_START,e.marginLeft||0),"marginRight"in e&&t.setMargin(n.EDGE_END,e.marginRight||0),"marginTop"in e&&t.setMargin(n.EDGE_TOP,e.marginTop||0),"marginBottom"in e&&t.setMargin(n.EDGE_BOTTOM,e.marginBottom||0)},H=(t,e)=>{"padding"in e&&t.setPadding(n.EDGE_ALL,e.padding??0),"paddingX"in e&&t.setPadding(n.EDGE_HORIZONTAL,e.paddingX??0),"paddingY"in e&&t.setPadding(n.EDGE_VERTICAL,e.paddingY??0),"paddingLeft"in e&&t.setPadding(n.EDGE_LEFT,e.paddingLeft||0),"paddingRight"in e&&t.setPadding(n.EDGE_RIGHT,e.paddingRight||0),"paddingTop"in e&&t.setPadding(n.EDGE_TOP,e.paddingTop||0),"paddingBottom"in e&&t.setPadding(n.EDGE_BOTTOM,e.paddingBottom||0)},M=(t,e)=>{"flexGrow"in e&&t.setFlexGrow(e.flexGrow??0),"flexShrink"in e&&t.setFlexShrink(typeof e.flexShrink=="number"?e.flexShrink:1),"flexWrap"in e&&(e.flexWrap==="nowrap"&&t.setFlexWrap(n.WRAP_NO_WRAP),e.flexWrap==="wrap"&&t.setFlexWrap(n.WRAP_WRAP),e.flexWrap==="wrap-reverse"&&t.setFlexWrap(n.WRAP_WRAP_REVERSE)),"flexDirection"in e&&(e.flexDirection==="row"&&t.setFlexDirection(n.FLEX_DIRECTION_ROW),e.flexDirection==="row-reverse"&&t.setFlexDirection(n.FLEX_DIRECTION_ROW_REVERSE),e.flexDirection==="column"&&t.setFlexDirection(n.FLEX_DIRECTION_COLUMN),e.flexDirection==="column-reverse"&&t.setFlexDirection(n.FLEX_DIRECTION_COLUMN_REVERSE)),"flexBasis"in e&&(typeof e.flexBasis=="number"?t.setFlexBasis(e.flexBasis):typeof e.flexBasis=="string"?t.setFlexBasisPercent(Number.parseInt(e.flexBasis,10)):t.setFlexBasis(Number.NaN)),"alignItems"in e&&((e.alignItems==="stretch"||!e.alignItems)&&t.setAlignItems(n.ALIGN_STRETCH),e.alignItems==="flex-start"&&t.setAlignItems(n.ALIGN_FLEX_START),e.alignItems==="center"&&t.setAlignItems(n.ALIGN_CENTER),e.alignItems==="flex-end"&&t.setAlignItems(n.ALIGN_FLEX_END),e.alignItems==="baseline"&&t.setAlignItems(n.ALIGN_BASELINE)),"alignSelf"in e&&((e.alignSelf==="auto"||!e.alignSelf)&&t.setAlignSelf(n.ALIGN_AUTO),e.alignSelf==="flex-start"&&t.setAlignSelf(n.ALIGN_FLEX_START),e.alignSelf==="center"&&t.setAlignSelf(n.ALIGN_CENTER),e.alignSelf==="flex-end"&&t.setAlignSelf(n.ALIGN_FLEX_END),e.alignSelf==="stretch"&&t.setAlignSelf(n.ALIGN_STRETCH),e.alignSelf==="baseline"&&t.setAlignSelf(n.ALIGN_BASELINE)),"alignContent"in e&&((e.alignContent==="flex-start"||!e.alignContent)&&t.setAlignContent(n.ALIGN_FLEX_START),e.alignContent==="center"&&t.setAlignContent(n.ALIGN_CENTER),e.alignContent==="flex-end"&&t.setAlignContent(n.ALIGN_FLEX_END),e.alignContent==="space-between"&&t.setAlignContent(n.ALIGN_SPACE_BETWEEN),e.alignContent==="space-around"&&t.setAlignContent(n.ALIGN_SPACE_AROUND),e.alignContent==="space-evenly"&&t.setAlignContent(n.ALIGN_SPACE_EVENLY),e.alignContent==="stretch"&&t.setAlignContent(n.ALIGN_STRETCH)),"justifyContent"in e&&((e.justifyContent==="flex-start"||!e.justifyContent)&&t.setJustifyContent(n.JUSTIFY_FLEX_START),e.justifyContent==="center"&&t.setJustifyContent(n.JUSTIFY_CENTER),e.justifyContent==="flex-end"&&t.setJustifyContent(n.JUSTIFY_FLEX_END),e.justifyContent==="space-between"&&t.setJustifyContent(n.JUSTIFY_SPACE_BETWEEN),e.justifyContent==="space-around"&&t.setJustifyContent(n.JUSTIFY_SPACE_AROUND),e.justifyContent==="space-evenly"&&t.setJustifyContent(n.JUSTIFY_SPACE_EVENLY))},U=(t,e)=>{"width"in e&&(typeof e.width=="number"?t.setWidth(e.width):typeof e.width=="string"?t.setWidthPercent(Number.parseInt(e.width,10)):t.setWidthAuto()),"height"in e&&(typeof e.height=="number"?t.setHeight(e.height):typeof e.height=="string"?t.setHeightPercent(Number.parseInt(e.height,10)):t.setHeightAuto()),"minWidth"in e&&(typeof e.minWidth=="string"?t.setMinWidthPercent(Number.parseInt(e.minWidth,10)):t.setMinWidth(e.minWidth??0)),"minHeight"in e&&(typeof e.minHeight=="string"?t.setMinHeightPercent(Number.parseInt(e.minHeight,10)):t.setMinHeight(e.minHeight??0)),"maxWidth"in e&&(typeof e.maxWidth=="string"?t.setMaxWidthPercent(Number.parseInt(e.maxWidth,10)):t.setMaxWidth(e.maxWidth)),"maxHeight"in e&&(typeof e.maxHeight=="string"?t.setMaxHeightPercent(Number.parseInt(e.maxHeight,10)):t.setMaxHeight(e.maxHeight)),"aspectRatio"in e&&t.setAspectRatio(e.aspectRatio)},Y=(t,e)=>{"display"in e&&t.setDisplay(e.display==="flex"?n.DISPLAY_FLEX:n.DISPLAY_NONE)},j=(t,e,r)=>{if(!("borderStyle"in e||"borderTop"in e||"borderBottom"in e||"borderLeft"in e||"borderRight"in e))return;const s=r.borderStyle?1:0;t.setBorder(n.EDGE_TOP,r.borderTop===!1?0:s),t.setBorder(n.EDGE_BOTTOM,r.borderBottom===!1?0:s),t.setBorder(n.EDGE_LEFT,r.borderLeft===!1?0:s),t.setBorder(n.EDGE_RIGHT,r.borderRight===!1?0:s)},X=(t,e)=>{"gap"in e&&t.setGap(n.GUTTER_ALL,e.gap??0),"columnGap"in e&&t.setGap(n.GUTTER_COLUMN,e.columnGap??0),"rowGap"in e&&t.setGap(n.GUTTER_ROW,e.rowGap??0)},V=(t,e)=>{const r=e.overflow??"visible",s=e.overflowX??r,l=e.overflowY??r;s==="scroll"||l==="scroll"?t.setOverflow(n.OVERFLOW_SCROLL):s==="hidden"||l==="hidden"?t.setOverflow(n.OVERFLOW_HIDDEN):t.setOverflow(n.OVERFLOW_VISIBLE)},C=(t,e={},r=e)=>{k(t,e),B(t,e),H(t,e),M(t,e),U(t,e),Y(t,e),j(t,e,r),X(t,e),V(t,r)};if(y.env.DEV==="true"){let t=!1;try{import.meta.resolve("react-devtools-core"),t=!0}catch{}t&&await import("../packem_chunks/devtools.js")}const N=(t,e)=>{if(t===e)return;if(!t)return e;const r={};let s=!1;for(const l of Object.keys(t))(!e||!Object.hasOwn(e,l))&&(r[l]=void 0,s=!0);if(e)for(const l of Object.keys(e))e[l]!==t[l]&&(r[l]=e[l],s=!0);return s?r:void 0},E=t=>{if(t){if(t.yogaNode?.unsetMeasureFunc(),"resizeObservers"in t&&t.resizeObservers?.clear(),"childNodes"in t&&t.childNodes)for(const e of t.childNodes)E(e);t.yogaNode?.free(),"cachedRender"in t&&(t.cachedRender=void 0),"childNodes"in t&&(t.childNodes=[]),t.parentNode=void 0}};let u=A,g;async function J(){const t=(await import("node:fs")).readFileSync(new URL("../package.json",import.meta.url),"utf8"),e=JSON.parse(t);return{name:e?.name,version:e?.version}}let d={name:"ink",version:S};if(y.env.DEV==="true")try{const t=await J();d={name:t.name||d.name,version:t.version||d.version}}catch(t){console.warn("Failed to load package.json in development mode. Falling back to default renderer metadata.",t)}const nt=R({afterActiveInstanceBlur(){},appendChild:f,appendChildToContainer:f,appendInitialChild:f,beforeActiveInstanceBlur(){},cancelCallback:G,cancelTimeout:clearTimeout,clearContainer:()=>!1,commitTextUpdate(t,e,r){m(t,r)},commitUpdate(t,e,r,s){g&&t.internal_static&&(g.isStaticDirty=!0);const l=N(r,s),a=N(r.style,s.style);if(!l&&!a)return;let i=!!a;if(l){for(const[o,c]of Object.entries(l))if(o!=="children"){if(o==="style"){T(t,c);continue}if(o==="internal_transform"){t.internal_transform=c,i=!0;continue}if(o==="internal_cursor"){t.internal_cursor=c,i=!0;continue}if(o==="internal_static"){t.internal_static=!0,i=!0;continue}if(o==="sticky"){t.internal_sticky=c,i=!0;continue}if(o==="internalStickyAlternate"){t.internal_stickyAlternate=c,i=!0;continue}if(o==="opaque"){t.internal_opaque=c,i=!0;continue}if(o==="scrollbar"){t.internal_scrollbar=c,i=!0;continue}if(o==="internal_terminalCursorFocus"){t.internal_terminalCursorFocus=c,i=!0;continue}if(o==="internal_terminalCursorPosition"){t.internal_terminalCursorPosition=c,i=!0;continue}if(o==="cachedRender"){t.cachedRender=c,i=!0;continue}I(t,o,c),i=!0}}a&&t.yogaNode&&C(t.yogaNode,a,s.style??{}),i&&p(t)},createInstance(t,e,r,s){if(s.isInsideText&&t==="ink-box")throw new Error("<Box> can’t be nested inside <Text> component");if(s.isInsideText&&t==="ink-cursor")throw new Error("<Cursor> can’t be nested inside <Text> component");const l=t==="ink-text"&&s.isInsideText?"ink-virtual-text":t,a=w(l);for(const[i,o]of Object.entries(e))if(i!=="children"){if(i==="style"){T(a,o),a.yogaNode&&C(a.yogaNode,o);continue}if(i==="internal_transform"){a.internal_transform=o;continue}if(i==="internal_cursor"){a.internal_cursor=o;continue}if(i==="internal_static"){g=r,a.internal_static=!0,r.isStaticDirty=!0,r.staticNode=a;continue}if(i==="sticky"){a.internal_sticky=o;continue}if(i==="internalStickyAlternate"){a.internal_stickyAlternate=o;continue}if(i==="opaque"){a.internal_opaque=o;continue}if(i==="scrollbar"){a.internal_scrollbar=o;continue}if(i==="internal_terminalCursorFocus"){a.internal_terminalCursorFocus=o;continue}if(i==="internal_terminalCursorPosition"){a.internal_terminalCursorPosition=o;continue}if(i==="internal_static"){a.internal_static=!0;continue}if(i==="cachedRender"){a.cachedRender=o;continue}I(a,i,o)}return a},createTextInstance(t,e,r){if(!r.isInsideText)throw new Error(`Text string "${t}" must be rendered inside <Text> component`);return v(t)},detachDeletedInstance(){},finalizeInitialChildren(){return!1},getChildHostContext(t,e){const r=t.isInsideText,s=e==="ink-text"||e==="ink-virtual-text";return r===s?t:{isInsideText:s}},getCurrentUpdatePriority:()=>u,getInstanceFromNode:()=>null,getInstanceFromScope:()=>null,getPublicInstance:t=>t,getRootHostContext:()=>({isInsideText:!1}),hideInstance(t){t.internal_hidden=!0,t.yogaNode?.setDisplay(n.DISPLAY_NONE),p(t)},hideTextInstance(t){m(t,"")},HostTransitionContext:L(null),insertBefore:_,insertInContainerBefore:_,isPrimaryRenderer:!0,maySuspendCommit(){return!0},noTimeout:-1,NotPendingTransition:void 0,now:O,preloadInstance(){return!0},prepareForCommit:()=>null,preparePortalMount:()=>null,prepareScopeUpdate(){},removeChild(t,e){h(t,e),E(e)},removeChildFromContainer(t,e){h(t,e),E(e)},rendererPackageName:d.name,rendererVersion:d.version,requestPostPaintCallback(){},resetAfterCommit(t){if(typeof t.onComputeLayout=="function"&&t.onComputeLayout(),F(t),t.staticNode!==t.previousStaticNode&&(t.previousStaticNode=t.staticNode,typeof t.onStaticChange=="function"&&t.onStaticChange()),t.isStaticDirty){t.isStaticDirty=!1,typeof t.onImmediateRender=="function"&&t.onImmediateRender();return}typeof t.onRender=="function"&&t.onRender()},resetFormInstance(){},resetTextContent(){},resolveEventTimeStamp(){return-1.1},resolveEventType(){return null},resolveUpdatePriority(){return u!==A?u:b},scheduleCallback:D,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(t){u=t},shouldAttemptEagerTransition(){return!1},shouldSetTextContent:()=>!1,shouldYield:P,startSuspendingCommit(){},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance(){},trackSchedulerEvent(){},unhideInstance(t){t.internal_hidden=!1,t.yogaNode?.setDisplay(n.DISPLAY_FLEX),p(t)},unhideTextInstance(t,e){m(t,e)},waitForCommitToBeReady(){return null}});export{C as c,nt as j};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import u from"react";import{FocusProvider as N,useFocusManager as z}from"./FocusContext-BWFqf9kb.js";import{TuiContext as v,useInput as L}from"./TuiContext-BNmP0lMY.js";import{LayoutNode as I}from"./LayoutNode-LPYsuzBg.js";import{T as d,r as T,u as F}from"./reconciler-D4fi5NfR.js";import{renderTreeToBuffer as P}from"./renderTreeToBuffer-BpSD0sBJ.js";import{TuiApp as A}from"./TuiApp-CCVaiKbf.js";import{InputParser as b}from"./InputParser-CUAGWKQQ.js";import{terminalSize as G}from"./Renderer-BeS49FNq.js";import{createInlineLoop as M}from"./createInlineLoop-BMDYJkRp.js";const R=l=>u.createElement("box",l,l.children),Q=l=>u.createElement("text",l,l.children),V=()=>u.createElement(R,{flexGrow:1}),H=({children:l})=>{const{disableFocus:c,enableFocus:t,focusNext:a,focusPrevious:r}=z();return L((w,s)=>{s.tab&&!s.shift&&a(),s.tab&&s.shift&&r(),s.escape&&(c(),t())}),u.createElement(u.Fragment,null,l)};function X(l,c){const t=new A,a=new b(process.stdin),r=new I,{height:w,width:s}=t.getSize();r.yogaNode.setWidth(s),r.yogaNode.setHeight(w);const i=d.createContainer(r,0,null,!1,null,"",e=>console.error(e),null),m=e=>u.createElement(v.Provider,{value:{app:t,input:a,writeStderr:n=>t.writeStderr(n),writeStdout:n=>t.writeStdout(n)}},u.createElement(N,null,u.createElement(H,null,e)));d.updateContainer(m(l),i,null,()=>{});const h=(e,n)=>r.calculateLayout(e,n),g=(e,n,W)=>P(r,e,n,W),f=()=>t.paintNow(h,g);let x=!1;T(r,()=>{x=!0});const C=Math.round(1e3/(c?.maxFps??60)),E=setInterval(()=>{x&&(x=!1,f())},C);let S;const y=new Promise(e=>{S=e}),p=()=>{clearInterval(E),F(r),d.updateContainer(null,i,null,()=>{}),r.destroy(),t.stop(),a.stop(),process.off("SIGWINCH",o),S()};a.on("exit",()=>{p(),process.exit(0)}),t.on("quit",()=>{p(),process.exit(0)}),a.start(),t.start();const o=()=>{const e=process.stdout.columns||80,n=process.stdout.rows||24;t.resize(e,n),r.yogaNode.setWidth(e),r.yogaNode.setHeight(n),t.emit("resize"),f()};return process.on("SIGWINCH",o),f(),{app:t,input:a,rerender(e){d.updateContainer(m(e),i,null,()=>{})},unmount(){p()},waitUntilExit(){return y}}}function Y(l,c){const t=G(),a=c?.rows??10,{cols:r}=t,w=Math.min(a,t.rows),s=new b(process.stdin),i=new I;i.yogaNode.setWidth(r),i.yogaNode.setHeight(w);const m=[],h=[],g={quit:()=>p.stop(),writeStderr:o=>h.push(o),writeStdout:o=>m.push(o)},f=d.createContainer(i,0,null,!1,null,"",o=>console.error(o),null),x=o=>u.createElement(v.Provider,{value:{app:g,input:s,writeStderr:g.writeStderr,writeStdout:g.writeStdout}},u.createElement(N,null,u.createElement(H,null,o)));d.updateContainer(x(l),f,null,()=>{}),T(i,()=>{});let C;const E=new Promise(o=>{C=o});let S=!1;const y=()=>{S||(S=!0,F(i),d.updateContainer(null,f,null,()=>{}),i.destroy(),s.stop(),m.length>0&&process.stdout.write(m.join("")),h.length>0&&process.stderr.write(h.join("")),C())},p=M((o,e,n)=>{i.calculateLayout(e,n),P(i,o,e,n)},{...c,fps:c?.maxFps??c?.fps??60,onStop:y,rows:w});return s.on("exit",()=>p.stop()),p.start(),s.start(),{unmount(){p.stop()},waitUntilExit(){return E}}}export{R as _Box,V as _Spacer,Q as _Text,X as render,Y as renderInline};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import{createRequire as Le}from"node:module";import{jsx as M}from"react/jsx-runtime";import{cursorShow as nt,setMode as de,BracketedPasteMode as ce,resetMode as he,eraseLines as F,cursorHide as ut,cursorUp as Xt,cursorNextLine as $e,cursorTo as Ae,eraseLineEnd as Be,createDecMode as He,ALT_SCREEN_ON as Jt,clearScreenAndHomeCursor as Fe,ALT_SCREEN_OFF as Qt}from"@visulima/ansi";import{wordWrap as Ge}from"@visulima/string";import{ConcurrentRoot as Ye,LegacyRoot as Ke}from"react-reconciler/constants.js";import $ from"yoga-layout";import{a as je}from"./accessibility-context-DDyHTwmA.js";import{useState as ht,useRef as I,useCallback as v,useEffect as ft,useMemo as B}from"react";import{e as ze}from"./animation-context-DW3p-vpk.js";import{e as Ve}from"./app-context-DTm1_XBA.js";import{o as Xe}from"./cursor-context-CFviBqPX.js";import Je from"../components/error-boundary.js";import{o as Qe}from"./focus-context-CsT69klR.js";import{t as Ze}from"./stderr-context-CR2LLec6.js";import{e as ti}from"./stdin-context-BjMA9Sbi.js";import{t as ei}from"./stdout-context-DAAlQct2.js";import{I as ii,_ as si,r as ri,H as oi}from"./renderer-Cs0KEr1o.js";import{c as ni,e as ui}from"./dom-rphpG0kf.js";import{resolveFlags as Zt}from"./kittyFlags-g8ALyoCU.js";import{buildReturnToBottomPrefix as gt,buildCursorSuffix as rt,buildCursorOnlySequence as fe,cursorPositionChanged as wt,buildCursorShapeSequence as te}from"./buildCursorOnlySequence-CerkmjWt.js";import{p as ai}from"./load-native-root-binding-CxJnHcac.js";import{a as li}from"./measure-text-B7juNq4Y.js";import{j as L,c as di}from"./reconciler-DkwOtC5B.js";import{measureAndExtractObservers as ci}from"./ResizeObserver-BI9bDy-j.js";import{calculateScroll as hi}from"./calculateScroll-D4Y_JR4H.js";import{g as q}from"./utils-CVgM8kTn.js";let De;const Me=i=>(De??=Le(import.meta.url))(i),X=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,bt=i=>{if(typeof X<"u"&&X.versions&&X.versions.node){const[t,e]=X.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return X.getBuiltinModule(i)}return Me(i)},k=X,{env:xt}=k,{PassThrough:zt,Stream:Ue}=bt("node:stream"),{Buffer:Vt}=bt("node:buffer"),{Console:We}=bt("node:console"),{EventEmitter:qe}=bt("node:events"),ee=i=>i in xt&&xt[i]!=="0"&&xt[i]!=="false",pe=ee("CI")||ee("CONTINUOUS_INTEGRATION"),ie=["assert","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"];let Tt={};const fi=i=>{const t=new zt,e=new zt;t.write=r=>{i("stdout",r)},e.write=r=>{i("stderr",r)};const s=new console.Console(t,e);for(const r of ie)Tt[r]=console[r],console[r]=s[r];return()=>{for(const r of ie)console[r]=Tt[r];Tt={}}},J=[];J.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&J.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&J.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",St=Symbol.for("signal-exit emitter"),Rt=globalThis,pi=Object.defineProperty.bind(Object);let mi=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Rt[St])return Rt[St];pi(Rt,St,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,e){this.listeners[t].push(e)}removeListener(t,e){const s=this.listeners[t],r=s.indexOf(e);r!==-1&&(r===0&&s.length===1?s.length=0:s.splice(r,1))}emit(t,e,s){if(this.emitted[t])return!1;this.emitted[t]=!0;let r=!1;for(const n of this.listeners[t])r=n(e,s)===!0||r;return t==="exit"&&(r=this.emit("afterExit",e,s)||r),r}},me=class{};const gi=i=>({onExit(t,e){return i.onExit(t,e)},load(){return i.load()},unload(){return i.unload()}});class wi extends me{onExit(){return()=>{}}load(){}unload(){}}let vi=class extends me{#n=Ot.platform==="win32"?"SIGINT":"SIGHUP";#e=new mi;#t;#r;#o;#s={};#i=!1;constructor(t){super(),this.#t=t,this.#s={};for(const e of J)this.#s[e]=()=>{const s=this.#t.listeners(e);let{count:r}=this.#e;const n=t;if(typeof n.__signal_exit_emitter__=="object"&&typeof n.__signal_exit_emitter__.count=="number"&&(r+=n.__signal_exit_emitter__.count),s.length===r){this.unload();const a=this.#e.emit("exit",null,e),o=e==="SIGHUP"?this.#n:e;a||t.kill(t.pid,o)}};this.#o=t.reallyExit,this.#r=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 J)try{const e=this.#s[t];e&&this.#t.on(t,e)}catch{}this.#t.emit=(t,...e)=>this.#a(t,...e),this.#t.reallyExit=t=>this.#u(t)}}unload(){this.#i&&(this.#i=!1,J.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.#r,this.#t.reallyExit=this.#o,this.#e.count-=1)}#u(t){return mt(this.#t)?(this.#t.exitCode=t||0,this.#e.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#a(t,...e){const s=this.#r;if(t==="exit"&&mt(this.#t)){typeof e[0]=="number"&&(this.#t.exitCode=e[0]);const r=s.call(this.#t,t,...e);return this.#e.emit("exit",this.#t.exitCode,null),r}else return s.call(this.#t,t,...e)}};const Ot=globalThis.process,{onExit:bi}=gi(mt(Ot)?new vi(Ot):new wi),ge="\x1B[200~",se="\x1B[201~",yi=i=>i>=48&&i<=63,xi=i=>i>=32&&i<=47,we=i=>i>=64&&i<=126,Ti=(i,t,e)=>{const s=t+e+1;let r=s;for(;r<i.length;r++){const n=i.codePointAt(r);if(n===void 0)return"pending";if(!(yi(n)||xi(n))&&!(n===91&&r===s))return we(n)?{nextIndex:r+1,sequence:i.slice(t,r+1)}:void 0}return"pending"},Si=(i,t,e)=>{const s=t+e+2;if(s>i.length)return"pending";const r=i.codePointAt(s-1);if(!(r===void 0||!we(r)))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 Ti(i,t,e);if(s==="O")return Si(i,t,e)},Ri=(i,t)=>{const e=i.codePointAt(t+1),s=e!==void 0&&e>65535?2:1,r=t+1+s;return{nextIndex:r,sequence:i.slice(t,r)}},Ci=(i,t)=>{if(t===i.length-1)return"pending";if(i[t+1]==="\x1B"){if(t+2>=i.length)return"pending";const s=re(i,t,2);return s==="pending"?"pending":s||{nextIndex:t+2,sequence:i.slice(t,t+2)}}const e=re(i,t,1);return e==="pending"?"pending":e||Ri(i,t)},oe=(i,t)=>{let e=0;for(let s=0;s<i.length;s++){const r=i[s];(r===""||r==="\b")&&(s>e&&t.push(i.slice(e,s)),t.push(r),e=s+1)}e<i.length&&t.push(i.slice(e))},Ei=i=>{const t=[];let e=0;const s=r=>({events:t,pending:i.slice(r)});for(;e<i.length;){const r=i.indexOf("\x1B",e);if(r===-1)return oe(i.slice(e),t),{events:t,pending:""};r>e&&oe(i.slice(e,r),t);const n=Ci(i,r);if(n==="pending")return s(r);if(n.sequence===ge){const a=n.nextIndex,o=i.indexOf(se,a);if(o===-1)return s(r);t.push({paste:i.slice(a,o)}),e=o+se.length;continue}t.push(n.sequence),e=n.nextIndex}return{events:t,pending:""}},Oi=()=>{let i="";return{flushPendingEscape(){if(!i.startsWith("\x1B"))return;const t=i;return i="",t},hasPendingEscape(){return i.startsWith("\x1B")&&!i.startsWith(ge)&&i!=="\x1B[200"},push(t){const e=Ei(i+t);return i=e.pending,e.events},reset(){i=""}}},Pi=" ",Ni="\x1B[Z",Ii="\x1B",ne=de(ce),Ct=he(ce),ve=({children:i,exitOnCtrlC:t,interactive:e,onExit:s,onRegisterInputControl:r,onSuspendTerminal:n,onWaitUntilRenderFlush:a,renderThrottleMs:o,setCursorPosition:u,stderr:f,stdin:h,stdout:m,writeToStderr:w,writeToStdout:d})=>{const[c,b]=ht(!0),[y,S]=ht(void 0),[,R]=ht([]),U=I(0),C=I([]),W=I(new Map),P=I(void 0),N=I(0),_=I(!1),T=I(0),[E]=ht(()=>{const l=new qe;return l.setMaxListeners(1/0),l}),Q=I(void 0),Z=I(void 0);Z.current??=Oi();const tt=I(void 0),Nt=I(!1),Se=20,G=v(()=>{tt.current&&(clearTimeout(tt.current),tt.current=void 0)},[]),Y=v(()=>{P.current&&(clearTimeout(P.current),P.current=void 0)},[]),at=v(()=>{if(Y(),W.current.size===0)return;let l=Number.POSITIVE_INFINITY;for(const p of W.current.values())l=Math.min(l,p.nextDueTime);const g=Math.max(0,l-performance.now());P.current=setTimeout(()=>{P.current=void 0;const p=performance.now(),x=[...W.current.values()];for(const O of x){if(p<O.nextDueTime)continue;O.callback(p);const ke=p-O.startTime,_e=Math.floor(ke/O.interval)+1;O.nextDueTime=O.startTime+_e*O.interval}at()},g)},[Y]),It=v((l,g)=>{const p=performance.now();return W.current.set(l,{callback:l,interval:g,nextDueTime:p+g,startTime:p}),at(),{startTime:p,unsubscribe(){if(W.current.delete(l),W.current.size===0){Y();return}at()}}},[Y,at]);ft(()=>()=>{Y()},[Y]);const D=h.isTTY,kt=v(()=>{Q.current&&(h.removeListener("readable",Q.current),Q.current=void 0)},[h]),K=v(()=>{Z.current?.reset(),G(),kt()},[G,kt]),j=v(()=>{_.current=!1,h.setRawMode(!1),h.unref(),N.current=0,K()},[h,K]),et=v(l=>{D&&(N.current>0||_.current)&&j(),s(l)},[D,j,s]),_t=v(l=>{if(l.includes("")&&t){et();return}l===Ii&&c&&S(g=>{if(!g)return g})},[t,et,c]),it=v(l=>{_t(l),E.emit("input",l)},[_t,E]),Lt=v(()=>{G(),tt.current=setTimeout(()=>{tt.current=void 0;const l=Z.current.flushPendingEscape();l&&it(l)},Se)},[G,it]),yt=v(()=>{G();let l;for(;(l=h.read())!==null;){const g=Z.current.push(l);for(const p of g)if(typeof p=="string")it(p);else{if(E.listenerCount("paste")===0){Nt.current||(Nt.current=!0,w(`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}E.emit("paste",p.paste)}}Z.current.hasPendingEscape()&&Lt()},[h,it,G,Lt,w,E]),lt=v(()=>{Q.current||(Q.current=yt,h.addListener("readable",yt))},[h,yt]),Dt=v(l=>{if(!D)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"),l){if(N.current===0){const g=_.current;_.current=!1,g||(h.ref(),h.setRawMode(!0)),lt()}N.current++;return}N.current!==0&&--N.current===0&&(K(),_.current=!0,queueMicrotask(()=>{_.current&&j()}))},[D,h,lt,K,j]),Mt=v(l=>{if(m.isTTY){if(l){T.current===0&&m.write(ne),T.current++;return}T.current!==0&&--T.current===0&&m.write(Ct)}},[m]),Ut=I({bracketedPaste:!1,rawMode:!1}),Wt=v(()=>{const l=D&&(N.current>0||_.current),g=T.current>0;Ut.current={bracketedPaste:g,rawMode:l},g&&m.isTTY&&m.write(Ct),l&&(_.current=!1,K(),h.setRawMode(!1),h.unref())},[D,m,h,K]),$t=v(()=>{const{bracketedPaste:l,rawMode:g}=Ut.current;g&&(h.ref(),h.setRawMode(!0),h.setEncoding("utf8"),lt()),l&&m.isTTY&&m.write(ne)},[h,m,lt]);ft(()=>{r(Wt,$t)},[r,Wt,$t]);const At=v((l,g)=>{const p=l.findIndex(x=>x.id===g);for(let x=p+1;x<l.length;x++){const O=l[x];if(O?.isActive)return O.id}},[]),Bt=v((l,g)=>{const p=l.findIndex(x=>x.id===g);for(let x=p-1;x>=0;x--){const O=l[x];if(O?.isActive)return O.id}},[]),dt=v(()=>{const l=C.current;S(g=>{const p=l.find(x=>x.isActive)?.id;return At(l,g)??p})},[At]),ct=v(()=>{const l=C.current;S(g=>{const p=l.findLast(x=>x.isActive)?.id;return Bt(l,g)??p})},[Bt]);ft(()=>{const l=p=>{!c||U.current===0||(p===Pi&&dt(),p===Ni&&ct())};E.on("input",l);const g=E;return()=>{g.off("input",l)}},[c,dt,ct,E]);const Ht=v(()=>{b(!0)},[]),Ft=v(()=>{b(!1)},[]),Gt=v(l=>{C.current.some(g=>g?.id===l)&&S(l)},[]),Yt=v((l,{autoFocus:g})=>{const p=[...C.current,{id:l,isActive:!0}];U.current=p.length,C.current=p,R(p),g&&S(x=>x||l)},[]),Kt=v(l=>{S(p=>{if(p!==l)return p});const g=C.current.filter(p=>p.id!==l);U.current=g.length,C.current=g,R(g)},[]),jt=v(l=>{const g=C.current.map(p=>p.id!==l?p:{id:l,isActive:!0});C.current=g,R(g)},[]),qt=v(l=>{S(p=>{if(p!==l)return p});const g=C.current.map(p=>p.id!==l?p:{id:l,isActive:!1});C.current=g,R(g)},[]);ft(()=>()=>{const l=!m.destroyed&&!m.writableEnded;e&&l&&m.write(nt),D&&(N.current>0||_.current)&&j(),T.current>0&&(m.isTTY&&l&&m.write(Ct),T.current=0)},[m,D,j,e]);const Re=B(()=>({exit:et,suspendTerminal:n,waitUntilRenderFlush:a}),[et,n,a]),Ce=B(()=>({internal_eventEmitter:E,internal_exitOnCtrlC:t,isRawModeSupported:D,setBracketedPasteMode:Mt,setRawMode:Dt,stdin:h}),[h,Dt,Mt,D,t,E]),Ee=B(()=>({stdout:m,write:d}),[m,d]),Oe=B(()=>({stderr:f,write:w}),[f,w]),Pe=B(()=>({setCursorPosition:u}),[u]),Ne=B(()=>({activate:jt,activeId:y,add:Yt,deactivate:qt,disableFocus:Ft,enableFocus:Ht,focus:Gt,focusNext:dt,focusPrevious:ct,remove:Kt}),[y,Yt,Kt,jt,qt,Ht,Ft,dt,ct,Gt]),Ie=B(()=>({renderThrottleMs:o,subscribe:It}),[It,o]);return M(Ve.Provider,{value:Re,children:M(ti.Provider,{value:Ce,children:M(ei.Provider,{value:Ee,children:M(Ze.Provider,{value:Oe,children:M(Qe.Provider,{value:Ne,children:M(ze.Provider,{value:Ie,children:M(Xe.Provider,{value:Pe,children:M(Je,{onError:et,children:i})})})})})})})})};ve.displayName="InternalApp";const ki=(i,t,e)=>{if(e<=0||!i.yogaNode)return"";const{yogaNode:s}=i,r=s.getComputedBorder($.EDGE_LEFT),n=s.getComputedBorder($.EDGE_RIGHT),a=s.getComputedBorder($.EDGE_TOP),o=s.getComputedPadding($.EDGE_LEFT),u=s.getComputedPadding($.EDGE_RIGHT),f=s.getComputedPadding($.EDGE_TOP),h=Math.round(s.getComputedWidth()-r-n-o-u);if(h<=0)return"";const m=new ii({height:e,width:h}),w=-(i.internal_scrollState?.scrollLeft??0)-r-o,d=-t-a-f;for(const c of i.childNodes)si(c,m,{absoluteOffsetX:w,absoluteOffsetY:d,offsetX:w,offsetY:d,skipStaticElements:!1});return m.get().output},Pt=new WeakMap,z=i=>i??"default",be=()=>{let i,t;return{consumeDelta:()=>{if(z(t)===z(i))return"";const e=z(t);return i=t,te(e)},consumeRestoreOnDone:()=>{const e=z(i)!=="default";return i=void 0,t=void 0,e?te("default"):""},isDirty:()=>z(t)!==z(i),setPending:e=>{t=e}}},ot=(i,t)=>t.endsWith(`
|
|
5
|
-
`)?i.length-1:i.length,ye=i=>i.rows||1/0,vt=(i,t)=>Math.min(i,ye(t)),_i=(i,{showCursor:t=!1}={})=>{let e=0,s="",r=!1,n,a=!1,o,u=!1;const f=be(),h=()=>a?n:void 0,m=(d,c)=>{const b=wt(c,o);return d!==s||b||f.isDirty()},w=d=>{!t&&!r&&(i.write(ut),r=!0);const c=h();a=!1;const b=wt(c,o);if(!m(d,c))return!1;const y=f.consumeDelta(),S=d.split(`
|
|
6
|
-
`),R=ot(S,d),U=rt(R,c);if(d===s&&b)i.write(y+fe({cursorPosition:c,cursorWasShown:u,previousCursorPosition:o,previousLineCount:e,visibleLineCount:R}));else if(d===s&&y!=="")i.write(y);else{s=d;const C=gt(u,e,o);i.write(y+C+F(vt(e,i))+d+U),e=S.length}return o=c?{...c}:void 0,u=c!==void 0,!0};return w.clear=()=>{const d=gt(u,e,o);i.write(d+F(vt(e,i))),s="",e=0,o=void 0,u=!1},w.done=()=>{s="",e=0,o=void 0,u=!1;const d=f.consumeRestoreOnDone();d!==""&&i.write(d),t||(i.write(nt),r=!1)},w.reset=()=>{s="",e=0,o=void 0,u=!1},w.sync=d=>{const c=a?n:void 0;a=!1;const b=d.split(`
|
|
7
|
-
`);s=d,e=b.length;const y=f.consumeDelta();y!==""&&i.write(y),!c&&u&&i.write(ut),c&&i.write(rt(ot(b,d),c)),o=c?{...c}:void 0,u=c!==void 0},w.setCursorPosition=d=>{n=d,a=!0},w.setCursorShape=f.setPending,w.isCursorDirty=()=>a||f.isDirty(),w.willRender=d=>m(d,h()),w},Li=(i,{showCursor:t=!1}={})=>{let e=[],s="",r=!1,n,a=!1,o,u=!1;const f=be(),h=()=>a?n:void 0,m=(d,c)=>{const b=wt(c,o);return d!==s||b||f.isDirty()},w=d=>{!t&&!r&&(i.write(ut),r=!0);const c=h();a=!1;const b=wt(c,o);if(!m(d,c))return!1;const y=f.consumeDelta(),S=d.split(`
|
|
8
|
-
`),R=ot(S,d),U=ot(e,s);if(d===s&&b)return i.write(y+fe({cursorPosition:c,cursorWasShown:u,previousCursorPosition:o,previousLineCount:e.length,visibleLineCount:R})),o=c?{...c}:void 0,u=c!==void 0,!0;if(d===s&&y!=="")return i.write(y),!0;const C=gt(u,e.length,o);if(d===`
|
|
9
|
-
`||s.length===0){const T=rt(R,c);return i.write(y+C+F(vt(e.length,i))+d+T),u=c!==void 0,o=c?{...c}:void 0,s=d,e=S,!0}const W=d.endsWith(`
|
|
10
|
-
`),P=[y,C],N=ye(i);if(R<U){const T=s.endsWith(`
|
|
11
|
-
`)?1:0;P.push(F(Math.min(U-R+T,N)),Xt(Math.min(R,N-1)))}else P.push(Xt(Math.min(U-1,N-1)));for(let T=0;T<R;T++){const E=T===R-1;if(S[T]===e[T]){(!E||W)&&P.push($e());continue}P.push(Ae(0)+S[T]+Be+(E&&!W?"":`
|
|
12
|
-
`))}const _=rt(R,c);return P.push(_),i.write(P.join("")),u=c!==void 0,o=c?{...c}:void 0,s=d,e=S,!0};return w.clear=()=>{const d=gt(u,e.length,o);i.write(d+F(vt(e.length,i))),s="",e=[],o=void 0,u=!1},w.done=()=>{s="",e=[],o=void 0,u=!1;const d=f.consumeRestoreOnDone();d!==""&&i.write(d),t||(i.write(nt),r=!1)},w.reset=()=>{s="",e=[],o=void 0,u=!1},w.sync=d=>{const c=a?n:void 0;a=!1;const b=d.split(`
|
|
13
|
-
`);s=d,e=b;const y=f.consumeDelta();y!==""&&i.write(y),!c&&u&&i.write(ut),c&&i.write(rt(ot(b,d),c)),o=c?{...c}:void 0,u=c!==void 0},w.setCursorPosition=d=>{n=d,a=!0},w.setCursorShape=f.setPending,w.isCursorDirty=()=>a||f.isDirty(),w.willRender=d=>m(d,h()),w},Di=(i,{incremental:t=!1,showCursor:e=!1}={})=>t?Li(i,{showCursor:e}):_i(i,{showCursor:e}),Mi={create:Di},xe=He(2026),H=de(xe),A=he(xe);function Ui(i,t){return"isTTY"in i&&i.isTTY&&(t??!pe)}let V;const Wi=()=>{if(V!==!1){if(V!==void 0)return V;try{return V=ai(import.meta.url).Renderer,V}catch{V=!1;return}}},$i=i=>{const t=Wi();if(!t)return;let e,s=0,r=0;const n=(a,o)=>{(!e||s!==a||r!==o)&&(e?e.resize(a,o):e=new t(a,o),s=a,r=o)};return{clear(){if(e){const a=new Uint32Array(s*r*2),o=65535;for(let u=0;u<a.length;u+=2)a[u]=32,a[u+1]=o;e.render(a)}},destroy(){e=void 0},render(a,o,u){if(n(o,u),!!e){i.isTTY&&e.writeRaw(H);try{e.render(a)}finally{i.isTTY&&e.writeRaw(A)}}},resize(a,o){n(a,o)}}};function ue(i,t=0,e={}){const s=e.leading??!0,r=e.trailing??!0;let n,a,o,u;const f=()=>{if(a===void 0)return;const c=a;a=void 0,u=i(...c)},h=()=>{n!==void 0&&(clearTimeout(n),n=void 0)},m=()=>{n=void 0,r&&f(),a=void 0,o=void 0},w=()=>{h(),n=setTimeout(m,t)},d=function(...c){const b=Date.now();if(o??=b,b-o>=t)return a=c,f(),o=b,w(),u;a=c;const y=n===void 0;return w(),s&&y&&f(),u};return d.cancel=()=>{h(),a=void 0,o=void 0},d.flush=()=>(h(),f(),o=void 0,u),d}console.Console||(console.Console=We);const st=()=>{},ae=async()=>new Promise(i=>{setImmediate(i)}),Ai=27,Bi=91,Hi=63,Fi=117,Gi=48,Yi=57,Ki=i=>i>=Gi&&i<=Yi,Te=(i,t)=>{if(i[t]!==Ai||i[t+1]!==Bi||i[t+2]!==Hi)return;let e=t+3;const s=e;for(;e<i.length&&Ki(i[e]);)e++;if(e!==s){if(e===i.length)return{state:"partial"};if(i[e]===Fi)return{endIndex:e,state:"complete"}}},ji=i=>{for(let t=0;t<i.length;t++)if(Te(i,t)?.state==="complete")return!0;return!1},qi=i=>{const t=[];let e=0;for(;e<i.length;){const s=Te(i,e);if(s?.state==="complete"){e=s.endIndex+1;continue}if(s?.state==="partial")break;t.push(i[e]),e++}return t},zi=({isTty:i,isUnmounting:t,isWindows:e,nextOutputHeight:s,previousOutputHeight:r,viewportRows:n})=>{if(!i)return!1;const a=r>0,o=r>=n,u=s>=n,f=r>n,h=s>n,m=o&&s<n;return f||h&&a||m||t&&o||e&&(u||o)},Et=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 Vi{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=ni("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,r=s>0?Math.max(1,Math.ceil(1e3/s)):0;this.renderThrottleMs=e?0:r;const n=e?this.onRender:(()=>{const o=ue(this.onRender,r,{leading:!0,trailing:!0});return this.throttledOnRender=o,()=>{this.hasPendingThrottledRender=!0,o()}})();if(e&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let o=!1;const u=()=>{o||(o=!0,queueMicrotask(()=>{o=!1,this.onRender()}))};this.rootNode.onRender=u,this.rootNode.onImmediateRender=u}else this.rootNode.onRender=n,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=Mi.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=$i(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=e?this.log:ue(o=>{const u=this.log.willRender(o),f=this.shouldSync();f&&u&&this.options.stdout.write(H),this.log(o),f&&u&&this.options.stdout.write(A)},void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.isUnmounting=!1,this.isConcurrent=t.concurrent??!1,this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.lastTerminalWidth=q(this.options.stdout).columns,this.fullStaticOutput="";const a=t.concurrent?Ye:Ke;this.container=L.createContainer(this.rootNode,a,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=bi(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"&&L.injectIntoDevTools(),this.exitPromise=new Promise((o,u)=>{this.resolveExitPromise=o,this.rejectExitPromise=u}),this.exitPromise.catch(st)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=()=>{const t=q(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),li(),this.calculateLayout(),ui(this.rootNode),this.onRender(),this.lastTerminalWidth=t};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};handleAppExit=t=>{if(!(this.isUnmounted||this.isUnmounting)){if(Et(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 r=new Map;this.calculateScrollAndTriggerObservers(s,r);for(const[n,a]of r)n.internalTrigger(a)};this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const e=q(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(e),this.rootNode.yogaNode.calculateLayout(void 0,void 0,$.DIRECTION_LTR),t(this.rootNode)};calculateScrollAndTriggerObservers(t,e){if(t.nodeName==="ink-box"){const{style:s}=t,r=s.overflow??"visible",n=s.overflowX??r,a=s.overflowY??r;n==="scroll"||a==="scroll"?(hi(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(ci(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 r of t.childNodes){const n=r;r.nodeName!=="#text"&&n.yogaNode&&(t.yogaNode.insertChild(n.yogaNode,s),s++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const s of t.childNodes)s.nodeName!=="#text"&&this.prepareYogaTree(s,e);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const s=q(this.options.stdout).columns,{width:r}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof r=="number"?r:s),t.yogaNode.calculateLayout(void 0,void 0,$.DIRECTION_LTR)),e(t),ri(t,{skipStaticElements:!1}),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($.EDGE_TOP)??0,r=Math.max(0,e-Math.round(s)),n=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:a}=t.style,o=a===void 0?n:Math.max(n,r-Math.max(0,a)),u=r-o;if(u<=0)return"";const f=ki(t,o,u);return f===""?"":(t.internal_maxPushedScrollTop=r,`${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:r,output:n,outputBuffer:a,outputHeight:o,outputWidth:u,staticOutput:f}=t;this.renderedCursorRequested=s,this.renderedCursorPosition=e,this.log.setCursorShape(s?r:void 0);const h=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&a&&u){f&&f!==`
|
|
16
|
-
`&&this.options.stdout.write(f),h&&this.options.stdout.write(h),this.nativeLog.render(a,u,o),this.lastOutputHeight=o;return}s&&this.log.setCursorPosition(this.getActiveCursorPosition());const m=f&&f!==`
|
|
17
|
-
`;if(this.options.debug){m&&(this.fullStaticOutput+=f),this.lastOutput=n,this.lastOutputToRender=n,this.lastOutputHeight=o,this.options.stdout.write(this.fullStaticOutput+n);return}if(!this.interactive){m&&this.options.stdout.write(f),this.lastOutput=n,this.lastOutputToRender=`${n}
|
|
18
|
-
`,this.lastOutputHeight=o;return}if(this.isScreenReaderEnabled){const w=this.shouldSync();if(w&&this.options.stdout.write(H),m){const b=this.lastOutputHeight>0?F(this.lastOutputHeight):"";this.options.stdout.write(b+f),this.lastOutputHeight=0}if(n===this.lastOutput&&!m){w&&this.options.stdout.write(A);return}const d=q(this.options.stdout).columns,c=Ge(n,{trim:!1,width:d,wrapMode:"BREAK_WORDS"}).replace(/\n$/,"");if(m)this.options.stdout.write(c);else{const b=this.lastOutputHeight>0?F(this.lastOutputHeight):"";this.options.stdout.write(b+c)}this.lastOutput=n,this.lastOutputToRender=c,this.lastOutputHeight=c===""?0:c.split(`
|
|
19
|
-
`).length,w&&this.options.stdout.write(A);return}m&&(this.fullStaticOutput+=f),this.renderInteractiveFrame(n,o,m?f:"",h)};accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const e=M(je.Provider,{value:this.accessibilityContextValue,children:M(ve,{exitOnCtrlC:this.options.exitOnCtrlC,interactive:this.interactive,onExit:this.handleAppExit,onRegisterInputControl:this.registerInputControl,onSuspendTerminal:this.suspendTerminal,onWaitUntilRenderFlush:this.waitUntilRenderFlush,renderThrottleMs:this.renderThrottleMs,setCursorPosition:this.setCursorPosition,stderr:this.options.stderr,stdin:this.options.stdin,stdout:this.options.stdout,writeToStderr:this.writeToStderr,writeToStdout:this.writeToStdout,children:t})});this.options.concurrent?L.updateContainer(e,this.container,null,st):(L.updateContainerSync(e,this.container,null,st),L.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(A)};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(A)};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:r}=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 n=()=>{typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),this.cancelKittyDetection&&this.cancelKittyDetection(),s&&(this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen?(this.log.clear(),this.log.done(),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.fullStaticOutput="",this.writeBestEffort(this.options.stdout,Qt),this.writeBestEffort(this.options.stdout,nt),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,Pt.delete(this.options.stdout);const{exitResult:o}=this,u=()=>{Et(t)?this.rejectExitPromise(t):this.resolveExitPromise(o)};t!==void 0&&!Et(t)?u():s&&r?this.options.stdout.write("",u):setImmediate(u)},a=L;this.options.concurrent?(L.updateContainerSync(null,this.container,null,st),L.flushSyncWork(),a.flushPassiveEffects?.(),n()):(L.updateContainerSync(null,this.container,null,st),L.flushSyncWork(),n())};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 ae(),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}L.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(r=>{this.options.stdout.write("",()=>{r()})});return}await ae()}clear(){this.interactive&&!this.options.debug&&(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
|
|
22
|
-
`))}patchConsole(){this.options.debug||(this.restoreConsole=fi((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,Jt),this.writeBestEffort(this.options.stdout,ut))}resolveInteractiveOption(t){return t??(!pe&&!!this.options.stdout.isTTY)}resolveAlternateScreenOption(t,e){return!!t&&e&&!!this.options.stdout.isTTY}shouldSync(){return Ui(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,r=""){const n=s+r,a=n!=="",o=this.options.stdout.isTTY,u=o?q(this.options.stdout).rows:24,f=o&&e>=u,h=f?t:`${t}
|
|
23
|
-
`,m=k.platform==="win32",w=o&&m&&(f||this.lastOutputHeight>=u);if(zi({isTty:o,isUnmounting:this.isUnmounting,isWindows:m,nextOutputHeight:e,previousOutputHeight:this.lastOutputHeight,viewportRows:u})){if(this.options.incrementalRendering&&!w){a&&(this.log.clear(),this.options.stdout.write(n)),(t!==this.lastOutput||this.log.isCursorDirty()||a)&&this.throttledLog(h),this.lastOutput=t,this.lastOutputToRender=h,this.lastOutputHeight=e;return}const d=this.shouldSync();d&&this.options.stdout.write(H),this.options.stdout.write(Fe+this.fullStaticOutput+r+h),this.lastOutput=t,this.lastOutputToRender=h,this.lastOutputHeight=e,this.log.sync(h),d&&this.options.stdout.write(A);return}if(a){const d=this.shouldSync();d&&this.options.stdout.write(H),this.log.clear(),this.options.stdout.write(n),this.log(h),d&&this.options.stdout.write(A)}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 e=t.flags??["disambiguateEscapeCodes"];this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(e)}initDeferredKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="auto")return;const e=t.flags??["disambiguateEscapeCodes"];!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(e)}confirmKittySupport(t){const{stdin:e,stdout:s}=this.options;let r=[];const n=()=>{this.cancelKittyDetection=void 0,clearTimeout(o),e.removeListener("data",a);const u=qi(r);r=[],u.length>0&&e.unshift(Vt.from(u))},a=u=>{const f=typeof u=="string"?Vt.from(u):u;for(const h of f)r.push(h);ji(r)&&(n(),this.isUnmounted||this.enableKittyProtocol(t))};e.on("data",a);const o=setTimeout(n,200);this.cancelKittyDetection=n,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,Qt),this.writeBestEffort(this.options.stdout,nt)),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,Jt),this.kittyProtocolEnabled&&this.kittyFlags&&this.writeBestEffort(this.options.stdout,`\x1B[>${Zt(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[>${Zt(t)}u`),this.kittyProtocolEnabled=!0}}const Os=(i,t)=>{const e={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:k.stderr,stdin:k.stdin,stdout:k.stdout,...Xi(t)},s=Ji(e.stdout,()=>new Vi(e));return s.render(i),{cleanup(){s.unmount()},clear(){s.clear()},rerender(r){s.render(r)},rootNode:s.rootNode,unmount(){s.unmount()},waitUntilExit(){return s.waitUntilExit()},waitUntilRenderFlush(){return s.waitUntilRenderFlush()}}},Xi=(i={})=>i instanceof Ue?{stdin:k.stdin,stdout:i}:i,Ji=(i,t)=>{const e=Pt.get(i);if(e===void 0){const s=t();return Pt.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{Os as default};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{LegacyRoot as p}from"react-reconciler/constants.js";import N from"yoga-layout";import{c as g}from"./dom-rphpG0kf.js";import{j as l}from"./reconciler-DkwOtC5B.js";import{H as i}from"./renderer-Cs0KEr1o.js";import{calculateScroll as v}from"./calculateScroll-D4Y_JR4H.js";const L=(f,u)=>{const d=u?.columns??80,e=g("ink-root");let a="";e.onComputeLayout=()=>{e.yogaNode.setWidth(d),e.yogaNode.calculateLayout(void 0,void 0,N.DIRECTION_LTR);const o=t=>{if(t.nodeName==="ink-box"){const n=t.style.overflow??"visible",m=t.style.overflowX??n,y=t.style.overflowY??n;(m==="scroll"||y==="scroll")&&v(t)}for(const n of t.childNodes)n.nodeName!=="#text"&&o(n)};o(e)},e.onImmediateRender=()=>{const{staticOutput:o}=i(e,!1);o&&o!==`
|
|
2
|
-
`&&(a+=o)};let r;const c=l.createContainer(e,p,null,!1,null,"render-to-string",o=>{r??=o},()=>{},()=>{},()=>{});let s=!1;try{l.updateContainerSync(f,c,null,()=>{}),l.flushSyncWork();const{output:o}=i(e,!1);if(l.updateContainerSync(null,c,null,()=>{}),l.flushSyncWork(),s=!0,e.yogaNode.free(),r!==void 0)throw r instanceof Error?r:new Error(String(r));const t=a.endsWith(`
|
|
3
|
-
`)?a.slice(0,-1):a;return t&&o?`${t}
|
|
4
|
-
${o}`:t||o}finally{if(!s&&e.yogaNode)try{e.yogaNode.freeRecursive()}catch{}}};export{L as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import s from"react";import{FocusProvider as S}from"./FocusContext-BWFqf9kb.js";import{TuiContext as h}from"./TuiContext-BNmP0lMY.js";import{LayoutNode as T}from"./LayoutNode-LPYsuzBg.js";import{T as l}from"./reconciler-D4fi5NfR.js";import{renderTreeToBuffer as C}from"./renderTreeToBuffer-BpSD0sBJ.js";import{Cell as w}from"./Cell-BrXn3jxY.js";function P(p,i){const r=i?.columns??80,o=i?.rows??24,e=new T;e.yogaNode.setWidth(r),e.yogaNode.setHeight(o);const d={app:null,input:null,writeStderr:n=>{},writeStdout:n=>{}},y=s.createElement(h.Provider,{value:d},s.createElement(S,null,p)),a=l.createContainer(e,0,null,!1,null,"renderToString",()=>{},null);l.updateContainerSync(y,a,null,()=>{}),l.flushSyncWork(),e.calculateLayout(r,o);const c=new Uint32Array(r*o*2);C(e,c,r,o);const t=[];for(let n=0;n<o;n++){let m="";for(let u=0;u<r;u++){const g=c[(n*r+u)*2],f=w.getChar(g);m+=f===""?" ":f}t.push(m.trimEnd())}for(;t.length>0&&t.at(-1)==="";)t.pop();return l.updateContainerSync(null,a,null,()=>{}),l.flushSyncWork(),e.destroy(),t.join(`
|
|
2
|
-
`)}export{P as renderToString};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e,Fragment as p,jsxs as h}from"react/jsx-runtime";import{Box as g}from"../components/box.js";import{Text as l}from"../components/text.js";const x=1,L=2,b=4,C=8,m=(o,n)=>{const r=o.fontStyle??0;return e(l,{backgroundColor:o.bgColor,bold:(r&L)!==0,color:o.color,italic:(r&x)!==0,strikethrough:(r&C)!==0,underline:(r&b)!==0,children:o.content},n)},j=o=>e(p,{children:o.map((n,r)=>m(n,r))}),w=(o,n={})=>{const{highlightLines:r,showLineNumbers:i=!1,startLine:c=1}=n,u=i?String(c+o.length-1).length:0;return e(g,{flexDirection:"column",children:o.map((s,a)=>{const d=c+a,t=r?.has(d)??!1;return h(g,{children:[i?h(l,{color:t?"yellow":void 0,dimColor:!t,children:[String(d).padStart(u)," "]}):void 0,e(l,{backgroundColor:t?"#3a3a00":void 0,children:s.length>0?s.map((f,k)=>m(f,k)):""})]},a)})})};export{m as renderToken,j as renderTokenLine,w as tokenLinesToElements};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as q}from"./boxes-DyY_LXCi.js";import{resolveColor as O}from"./NAMED_COLORS-82DpREQV.js";import{a as z}from"./text-width-e49vlbQH.js";const D=1114112,E=9608,F=9600,H=9604;function k(o){const t=o?.borderStyle?1:0;return{bottom:o?.borderBottom===!1?0:t,left:o?.borderLeft===!1?0:t,right:o?.borderRight===!1?0:t,top:o?.borderTop===!1?0:t}}function I(o){let t=0;for(const i of o.children){const b=i.getLayout(),e=b.top+b.height;e>t&&(t=e)}const n=o._style,l=n?.paddingBottom??n?.paddingY??n?.padding??0;return t+l}function N(o,t,n,l,i,b,e,m,_,R,p,u){const r=k(u),a=m-r.top-r.bottom,d=u.scrollTop??0,g=I(o),M=a;if(g<=M||a<=0)return;const s=a*2,y=Math.max(2,Math.round(M/g*s)),f=g-M,x=s-y,A=f>0?Math.round(d/f*x):0,c=typeof u.scrollbarThumbColor=="string"?O(u.scrollbarThumbColor):_,h=i+e-1-r.right,w=R<<16|65280|c;for(let B=0;B<a;B++){const T=B*2,Y=T+1,S=T>=A&&T<A+y,L=Y>=A&&Y<A+y;if(!S&&!L)continue;let v=E;S&&!L?v=F:!S&&L&&(v=H),C(t,n,l,h,b+r.top+B,v,w,p)}}function V(o,t,n,l,i,b,e,m,_,R,p,u,r,a){const d=k(a),g=a.scrollTop??0,M=b+d.top;for(const s of o.children){if(!s._style?.sticky)continue;const y=s.getLayout();if(y.top>=g)continue;const f=s.parent;if(f&&f!==o){const w=f.getLayout();if(w.top+w.height<=g)continue}const x=M,A=s.fg===255?_:s.fg,c=s.bg===255?R:s.bg,h=s.styles===0?p:s.styles;X(s,t,n,l,i-y.left,x-y.top,A,c,h,u,r)}}function Q(o,t,n,l){for(let e=0;e<t.length;e+=2)t[e]=32,t[e+1]=65535;const i=[],b={x0:0,x1:n,y0:0,y1:l};try{X(o,t,n,l,0,0,o.fg,o.bg,o.styles,i,b);for(const e of i)W(e.node,t,n,l,e.absX,e.absY,e.w,e.h,e.fg,e.bg,e.styles,e.clip)}catch(e){console.error("Renderer Error:",e)}}function C(o,t,n,l,i,b,e,m){if(l<m.x0||l>=m.x1||i<m.y0||i>=m.y1||l<0||l>=t||i<0||i>=n)return;const _=(i*t+l)*2;o[_]=b,o[_+1]=e}function W(o,t,n,l,i,b,e,m,_,R,p,u){if(!o._style?.borderStyle||e<=0||m<=0)return;const r=q[o._style.borderStyle],a=o._style.borderColor===void 0?_:O(o._style.borderColor),d=p<<16|R<<8|a,g=o._style.borderTop!==!1,M=o._style.borderBottom!==!1,s=o._style.borderLeft!==!1,y=o._style.borderRight!==!1,f=M&&(m>1||!g);if(g)for(let c=0;c<e;c++){let h;e===1?h=s&&y?r.left:s?r.topLeft:y?r.topRight:r.top:c===0&&s?h=r.topLeft:c===e-1&&y?h=r.topRight:h=r.top,C(t,n,l,i+c,b,h.codePointAt(0),d,u)}if(f)for(let c=0;c<e;c++){let h;e===1?h=s&&y?r.left:s?r.bottomLeft:y?r.bottomRight:r.bottom:c===0&&s?h=r.bottomLeft:c===e-1&&y?h=r.bottomRight:h=r.bottom,C(t,n,l,i+c,b+m-1,h.codePointAt(0),d,u)}const x=g?1:0,A=f?m-1:m;for(let c=x;c<A;c++)s&&C(t,n,l,i,b+c,r.left.codePointAt(0),d,u),y&&C(t,n,l,i+e-1,b+c,r.right.codePointAt(0),d,u)}function U(o){if(o._hidden)return"";if(o.text!==void 0)return o.text;const t=o.children.map(U).join("");return typeof o.transform=="function"?o.transform(t,0):t}function j(o,t,n,l,i,b,e,m,_,R){if(e<=0||m<=0)return;let p=0,u=0;for(const r of o){if(r===`
|
|
2
|
-
`){p=0,u++;continue}const a=r.codePointAt(0)??32,d=z(r);if(p+d>e&&(p=0,u++),u>=m)break;if(d>e){C(t,n,l,i+p,b+u,32,_,R),p+=1;continue}C(t,n,l,i+p,b+u,a,_,R),d===2&&p+1<e&&C(t,n,l,i+p+1,b+u,D,_,R),p+=d}}function X(o,t,n,l,i,b,e,m,_,R,p){if(o._hidden)return;const u=o.getLayout(),r=Math.round(i+u.left),a=Math.round(b+u.top),d=Math.round(u.width),g=Math.round(u.height),M=o.fg===255?e:o.fg,s=o.bg===255?m:o.bg,y=o.styles===0?_:o.styles,f={x0:Math.max(p.x0,r),x1:Math.min(p.x1,r+d),y0:Math.max(p.y0,a),y1:Math.min(p.y1,a+g)};if(f.x0>=f.x1||f.y0>=f.y1)return;if(typeof o.transform=="function"){const L=U(o),v=o.transform(L,0),P=y<<16|s<<8|M;j(v,t,n,l,r,a,d,g,P,f);return}if(o.text===void 0){if(s!==255||y!==0){const L=y<<16|s<<8|M;for(let v=0;v<g;v++)for(let P=0;P<d;P++)C(t,n,l,r+P,a+v,32,L,f)}o._style?.borderStyle&&R.push({absX:r,absY:a,bg:s,clip:f,fg:M,h:g,node:o,styles:y,w:d})}else{const L=y<<16|s<<8|M;if(o.bg!==255)for(let v=0;v<g;v++)for(let P=0;P<d;P++)C(t,n,l,r+P,a+v,32,L,f);j(o.text,t,n,l,r,a,d,g,L,f)}const x=o._style,A=x?.overflow??"visible",c=x?.overflowX??A,h=x?.overflowY??A,w=c==="hidden"||c==="scroll",B=h==="hidden"||h==="scroll";let T=f,Y=0,S=0;if(w||B){const L=k(x);T={x0:w?Math.max(f.x0,r+L.left):f.x0,x1:w?Math.min(f.x1,r+d-L.right):f.x1,y0:B?Math.max(f.y0,a+L.top):f.y0,y1:B?Math.min(f.y1,a+g-L.bottom):f.y1},h==="scroll"&&typeof x?.scrollTop=="number"&&(S=-x.scrollTop),c==="scroll"&&typeof x?.scrollLeft=="number"&&(Y=-x.scrollLeft)}for(const L of o.children)L._style?.internalStickyAlternate||X(L,t,n,l,r+Y,a+S,M,s,y,R,T);(h==="scroll"||c==="scroll")&&x?.scrollbar!==!1&&N(o,t,n,l,r,a,d,g,M,y,f,x),h==="scroll"&&typeof x?.scrollTop=="number"&&V(o,t,n,l,r,a,d,g,M,s,y,R,T,x)}export{Q as renderTreeToBuffer};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{l as Me,i as xe}from"./dom-rphpG0kf.js";import{getStringWidth as V,isFullwidthCodePoint as Te,indent as ke}from"@visulima/string";import{B as H,D as A,I,U as z,e as Y,H as q,f as K,g as oe,F,h as re,S as we,j as Le,p as Re}from"./measure-text-B7juNq4Y.js";import x from"yoga-layout";import{j as $,i as _e,u as ie,c as se}from"./measure-element-D4M9iSYp.js";import{g as Be,a as j}from"./colorize-DU4YZkp3.js";import De from"@visulima/colorize";import{o as We}from"./boxes-DyY_LXCi.js";import{getScrollTop as Ce}from"./calculateScroll-D4Y_JR4H.js";import be from"./squashTextNodesWithMap-BmUSBPfc.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
3
|
-
const Oe=1114112,Pe=1,He=2,Ae=3,Fe=4,$e=7,Ge=8,Ie=9,ne=22,le=23,ae=24,de=27,he=28,ue=29,ce=39,ge=49,ze="\x1B[",M=o=>o.length===0?"":`${ze}${o.join(";")}m`,Ye=o=>{if(o.length===0)return"";let t="",e=0,r,i,l,n=!1,c=0;const f=o.getSpans();for(const g of f){const s=g.formatFlags&127,{fgColor:h}=g,{bgColor:u}=g,{link:a}=g,d=s;if(d!==e||h!==r||u!==i||a!==l){if(a!==l&&(l&&(t+=l.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),a)){const y=a.startsWith("ST:");t+=`\x1B]8;;${y?a.slice(3):a}${y?"\x1B\\":"\x07"}`}const p=e&(H|A),m=d&(H|A);if(p!==m){const y=e&H&&!(d&H),b=e&A&&!(d&A);(y||b)&&(t+=M([ne])),d&H&&(!(e&H)||b)&&(t+=M([Pe])),d&A&&(!(e&A)||y)&&(t+=M([He]))}d&I&&!(e&I)?t+=M([Ae]):!(d&I)&&e&I&&(t+=M([le])),d&z&&!(e&z)?t+=M([Fe]):!(d&z)&&e&z&&(t+=M([ae])),d&Y&&!(e&Y)?t+=M([$e]):!(d&Y)&&e&Y&&(t+=M([de])),d&q&&!(e&q)?t+=M([Ge]):!(d&q)&&e&q&&(t+=M([he])),d&K&&!(e&K)?t+=M([Ie]):!(d&K)&&e&K&&(t+=M([ue])),h!==r&&(t+=M(h?oe(h,!0):[ce])),u!==i&&(t+=M(u?oe(u,!1):[ge])),n=d!==0||h!==void 0||u!==void 0,e=d,r=h,i=u,l=a}t+=o.getTextRange(c,c+g.length),c+=g.length}return n&&(e&(H|A)&&(t+=M([ne])),e&I&&(t+=M([le])),e&z&&(t+=M([ae])),e&Y&&(t+=M([de])),e&q&&(t+=M([he])),e&K&&(t+=M([ue])),r!==void 0&&(t+=M([ce])),i!==void 0&&(t+=M([ge]))),l&&(t+=l.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),t};class J{widths=new Map;blockWidths=new Map;styledLines=new Map;lines=new Map;maxEntries;pruneToFactor;constructor(t={}){const{maxEntries:e=3e4,pruneToFactor:r=.8}=t;this.maxEntries=Math.max(1,e),this.pruneToFactor=Math.min(.99,Math.max(.1,r))}getStyledLine(t){let e=this.styledLines.get(t);return e===void 0&&(e=this.hasAnsiControlMarker(t)?Le(t):Re(t),this.setCacheEntry(this.styledLines,t,e)),e}getStringWidth(t){let e=this.widths.get(t);return e===void 0&&(e=V(t),this.setCacheEntry(this.widths,t,e)),e}getWidestLine(t){let e=this.blockWidths.get(t);if(e===void 0){let r=0;for(const i of this.getLines(t))r=Math.max(r,this.getStringWidth(i));e=r,this.setCacheEntry(this.blockWidths,t,e)}return e}getLines(t){let e=this.lines.get(t);return e===void 0&&(e=t.split(`
|
|
4
|
-
`),this.setCacheEntry(this.lines,t,e)),e}hasAnsiControlMarker(t){for(const e of t){const r=e.codePointAt(0);if(qe.has(r))return!0}return!1}setCacheEntry(t,e,r){!t.has(e)&&t.size>=this.maxEntries&&this.pruneCache(t),t.set(e,r)}pruneCache(t){const e=Math.floor(this.maxEntries*this.pruneToFactor);for(const r of t.keys())if(t.delete(r),t.size<=e)break}}const qe=new Set([27,144,152,155,157,158,159]),Ke=.6,Xe=30;class Q{width;height;caches;grid;clipStack=[];previousLines=[];previousRenderedLines=[];lineMemoizationEnabled=!0;memoizationProbeCountdown=0;constructor(t){const{caches:e,height:r,width:i}=t;this.width=Math.round(i),this.height=Math.round(r),this.caches=e??new J,this.grid=this.createGrid(this.width,this.height)}reset(t,e){this.width=Math.round(t),this.height=Math.round(e),this.clipStack.length=0,this.grid=this.createGrid(this.width,this.height)}startChildRegion(t,e,r,i){const l=Math.round(t),n=Math.round(e);this.clipStack.push({x1:l,x2:l+Math.round(r),y1:n,y2:n+Math.round(i)})}endChildRegion(){this.clipStack.pop()}write(t,e,r,i){if(!r)return;const{transformers:l}=i,n=this.clipStack.at(-1),c=this.caches.getLines(r),f=l.length>0;for(const[g,s]of c.entries()){const h=e+g;if(h<0||h>=this.grid.length||n&&(h<n.y1||h>=n.y2))continue;let u=s;if(f)for(const k of l)u=k(u,g);if(u.length===0)continue;const a=this.grid[h],d=this.caches.getStyledLine(u);let p=t;const m=n?Math.min(n.x2,a.length):1/0,y=d.getSpans();let b=0,T=y[0]?.length??0;for(let k=0;k<d.length;k++){for(;b<y.length&&k>=T;)b++,T+=y[b]?.length??0;if(p>=m)break;if(n&&(p<n.x1||p>=n.x2)){p++,d.getFullWidth(k)&&p++;continue}if(p>=0){p>=a.length&&a.ensureWidth(p+2);const v=y[b],C=d.getFullWidth(k),S=(v?.formatFlags??0)|(C?F:0);a.setCharFast(p,d.getValue(k),S,v?.fgColor,v?.bgColor,v?.link),C&&(p++,p>=a.length&&a.ensureWidth(p+1),a.setCharFast(p,"",S&~F,v?.fgColor,v?.bgColor,v?.link))}p++}}}writeStyledLine(t,e,r){if(r.length===0||e<0||e>=this.grid.length)return;const i=this.clipStack.at(-1);i&&(e<i.y1||e>=i.y2)||this.writeStyledLineToRow(this.grid[e],t,r,this.width,i)}getRootLines(){return this.grid}getCurrentClip(){return this.clipStack.at(-1)}addRegionTree(t,e,r){for(let i=0;i<t.height;i++){const l=r+i;if(l<0||l>=this.grid.length)continue;const n=t.lines[i];if(!n)continue;const c=this.grid[l],f=n.getSpans();let g=0,s=f[0]?.length??0;for(let h=0;h<n.length;h++){for(;g<f.length&&h>=s;)g++,s+=f[g]?.length??0;const u=e+h;if(u<0||u>=c.length)continue;const a=n.getValue(h),d=f[g],p=d!==void 0&&(d.formatFlags&~F)!==0||d?.fgColor!==void 0||d?.bgColor!==void 0||d?.link!==void 0;if(a!==" "||p){const m=(d?.formatFlags??0)|(n.getFullWidth(h)?F:0);c.setCharFast(u,a,m,d?.fgColor,d?.bgColor,d?.link)}}}for(const i of t.children)this.addRegionTree(i,e+i.x,r+i.y)}writeStyledLineToRow(t,e,r,i,l){let n=e;const c=l?Math.min(l.x2,i):1/0,f=r.getSpans();let g=0,s=f[0]?.length??0;for(let h=0;h<r.length;h++){for(;g<f.length&&h>=s;)g++,s+=f[g]?.length??0;if(n>=c)break;if(l&&(n<l.x1||n>=l.x2)){n++,r.getFullWidth(h)&&n++;continue}if(n>=0){n>=t.length&&t.ensureWidth(n+2);const u=f[g],a=r.getFullWidth(h),d=(u?.formatFlags??0)|(a?F:0);t.setCharFast(n,r.getValue(h),d,u?.fgColor,u?.bgColor,u?.link),a&&(n++,n>=t.length&&t.ensureWidth(n+1),t.setCharFast(n,"",d&~F,u?.fgColor,u?.bgColor,u?.link))}n++}}get(){const t=this.grid;this.lineMemoizationEnabled||(this.memoizationProbeCountdown>0?this.memoizationProbeCountdown--:this.lineMemoizationEnabled=!0);const e=this.lineMemoizationEnabled,r=this.previousLines.length>0,i=e&&r&&this.previousLines.length===t.length&&this.previousRenderedLines.length===t.length;this.previousLines.length>t.length&&(this.previousLines.length=t.length),this.previousRenderedLines.length>t.length&&(this.previousRenderedLines.length=t.length);const l=Array.from({length:t.length});let n=0;for(const[c,f]of t.entries()){const g=f;if(i&&this.previousLines[c]?.equals(g)){l[c]=this.previousRenderedLines[c]??"";continue}n++;const s=g.trimEnd(),h=Ye(s);l[c]=h,e&&(this.previousRenderedLines[c]=h,this.previousLines[c]=g.clone())}return e&&i&&t.length>0&&n/t.length>Ke&&this.disableLineMemoization(),{height:t.length,output:l.join(`
|
|
5
|
-
`)}}getBuffer(){const t=this.grid,e=t.length,r=new Uint32Array(this.width*e*2),i=65535;for(let l=0;l<r.length;l+=2)r[l]=32,r[l+1]=i;for(let l=0;l<e;l++){const n=t[l],c=n.getSpans();let f=0,g=c[0]?.length??0;for(let s=0;s<n.length&&s<this.width;s++){for(;f<c.length&&s>=g;)f++,g+=c[f]?.length??0;const h=n.getValue(s);if(h.length===0)continue;const u=h.codePointAt(0)??32,a=(l*this.width+s)*2,d=c[f],p=d?.formatFlags??0,m=d?.fgColor,y=d?.bgColor,b=m?re(m):255,T=y?re(y):255,k=(p&255)<<16|(T&255)<<8|b&255;if(r[a]=u,r[a+1]=k,n.getFullWidth(s)&&s+1<this.width){const v=a+2;r[v]=Oe,r[v+1]=k,s++}}}return{buffer:r,height:e}}createGrid(t,e){const r=[];for(let i=0;i<e;i++)r.push(we.empty(t));return r}disableLineMemoization(){this.lineMemoizationEnabled=!1,this.memoizationProbeCountdown=Xe,this.previousLines.length=0,this.previousRenderedLines.length=0}}const je=o=>Math.round(o.getComputedWidth()-Math.max(0,o.getComputedLeft()+o.getComputedWidth()-(o.getParent()?.getComputedWidth()??o.getComputedWidth()))-o.getComputedPadding(x.EDGE_LEFT)-o.getComputedPadding(x.EDGE_RIGHT)-o.getComputedBorder(x.EDGE_LEFT)-o.getComputedBorder(x.EDGE_RIGHT)),Ve=(o,t,e,r)=>{if(!e.style.backgroundColor)return;const i=Math.round(e.yogaNode.getComputedWidth()),l=Math.round(e.yogaNode.getComputedHeight()),n=e.style.borderStyle&&e.style.borderLeft!==!1?1:0,c=e.style.borderStyle&&e.style.borderRight!==!1?1:0,f=e.style.borderStyle&&e.style.borderTop!==!1?1:0,g=e.style.borderStyle&&e.style.borderBottom!==!1?1:0,s=i-n-c,h=l-f-g;if(!(s>0&&h>0))return;const u=Be(e.style.backgroundColor);if(!u)return;const a=`${u}${" ".repeat(s)}\x1B[49m`;for(let d=0;d<h;d++)r.write(o+n,t+f+d,a,{transformers:[]})},O=(o,t,e,r)=>{let i=j(o,t,"foreground");return i=j(i,e,"background"),r&&(i=De.dim(i)),i},fe=(o,t,e,r,i,l,n,c)=>{if(!e&&!i)return O(o.repeat(t),l,n,c);const f=e?` ${e} `:"",g=i?` ${i} `:"",s=f.length,h=g.length,u=r??"left";if(s+h>=t){if(s>=t)return`${f.slice(0,t-1)}…`;const m=t-s;return m>3?f+g.slice(0,m):f+O(o.repeat(t-s),l,n,c)}const a=t-s-h;if(u==="left"||i)return f+O(o.repeat(a),l,n,c)+g;if(u==="right"){const m=t-s;return O(o.repeat(m),l,n,c)+f}const d=Math.floor(a/2),p=a-d;return O(o.repeat(d),l,n,c)+f+O(o.repeat(p),l,n,c)},Ue=(o,t,e,r)=>{if(e.style.borderStyle){const i=Math.round(e.yogaNode.getComputedWidth()),l=Math.round(e.yogaNode.getComputedHeight()),n=typeof e.style.borderStyle=="string"?We[e.style.borderStyle]:e.style.borderStyle,c=e.style.borderTopColor??e.style.borderColor,f=e.style.borderBottomColor??e.style.borderColor,g=e.style.borderLeftColor??e.style.borderColor,s=e.style.borderRightColor??e.style.borderColor,h=e.style.borderTopBackgroundColor??e.style.borderBackgroundColor,u=e.style.borderBottomBackgroundColor??e.style.borderBackgroundColor,a=e.style.borderLeftBackgroundColor??e.style.borderBackgroundColor,d=e.style.borderRightBackgroundColor??e.style.borderBackgroundColor,p=e.style.borderTopDimColor??e.style.borderDimColor,m=e.style.borderBottomDimColor??e.style.borderDimColor,y=e.style.borderLeftDimColor??e.style.borderDimColor,b=e.style.borderRightDimColor??e.style.borderDimColor,T=e.style.borderTop!==!1,k=e.style.borderBottom!==!1,v=e.style.borderLeft!==!1,C=e.style.borderRight!==!1,S=Math.max(0,i-(v?1:0)-(C?1:0));let N;if(T){const B=v?O(n.topLeft,c,h,p):"",D=C?O(n.topRight,c,h,p):"",W=fe(n.top,S,e.style.borderTopTitle,e.style.borderTopTitleAlignment,e.style.borderTopRightTitle,c,h,p);N=B+W+D}let E=l;T&&(E-=1),k&&(E-=1),E=Math.max(0,E);let R="";v&&(R=`${O(n.left,g,a,y)}
|
|
6
|
-
`.repeat(E));let w="";C&&(w=`${O(n.right,s,d,b)}
|
|
7
|
-
`.repeat(E));let L;if(k){const B=v?O(n.bottomLeft,f,u,m):"",D=C?O(n.bottomRight,f,u,m):"",W=fe(n.bottom,S,e.style.borderBottomTitle,e.style.borderBottomTitleAlignment,void 0,f,u,m);L=B+W+D}const _=T?1:0;N&&r.write(o,t,N,{transformers:[]}),R&&r.write(o,t+_,R,{transformers:[]}),w&&r.write(o+i-1,t+_,w,{transformers:[]}),L&&r.write(o,t+l-1,L,{transformers:[]})}},pe=[],me=({axis:o,color:t,layout:e,output:r})=>{const{thumb:{end:i,endHalf:l,start:n,startHalf:c},x:f,y:g}=e;if(o==="vertical")for(let s=n;s<i;s++){let h="█";const u=2*s>=c&&2*s<l,a=2*s+1>=c&&2*s+1<l;u&&!a?h="▀":!u&&a&&(h="▄");const d=t?j(h,t,"foreground"):h;r.write(f,g+s,d,{transformers:pe})}else for(let s=n;s<i;s++){let h="█";const u=2*s>=c&&2*s<l,a=2*s+1>=c&&2*s+1<l;u&&!a?h="▌":!u&&a&&(h="▐");const d=t?j(h,t,"foreground"):h;r.write(f+s,g,d,{transformers:pe})}},ve=(o,t=[])=>{for(const e of o.childNodes){if(e.nodeName==="#text")continue;const r=e;if(!r.internal_stickyAlternate)if(r.internal_sticky)t.push({node:r,type:r.internal_sticky==="bottom"?"bottom":"top"});else{const i=r.style.overflow??"visible",l=r.style.overflowX??i,n=r.style.overflowY??i;!(l==="scroll"||n==="scroll")&&r.childNodes&&ve(r,t)}}return t},Je=(o,t,e,r)=>{let i,l=-1,n,c=-1;for(const[g,s]of o.entries()){const{node:h,type:u}=s;if(!h.yogaNode)continue;const a=$(h,t)??0,d=Math.round(h.yogaNode.getComputedHeight()),p=a+d,m=h.parentNode;let y=0,b=Number.MAX_SAFE_INTEGER;m?.yogaNode&&(y=$(m,t)??0,b=Math.round(m.yogaNode.getComputedHeight())),u==="top"&&a<e&&y+b>e&&(i=s,l=g),u==="bottom"&&Math.floor(p)>Math.floor(r)&&y<r&&(n=s,c=g)}const f=[];if(i){let g;for(let s=l+1;s<o.length;s++){const h=o[s];if(h.type!=="bottom"){g=h;break}}f.push({nextStickyNodeInfo:g,stickyNode:i.node,type:"top"})}if(n){let g;for(let s=c-1;s>=0;s--){const h=o[s];if(h.type==="bottom"){g=h;break}}f.push({nextStickyNodeInfo:g,stickyNode:n.node,type:"bottom"})}return f},Qe=(o,t,e,r,i)=>{const{newTransformers:l,renderNodeToOutput:n,skipStaticElements:c,x:f,y:g}=i,{yogaNode:s}=t;if(!s)return;const h=s.getComputedBorder(x.EDGE_TOP),u=s.getComputedBorder(x.EDGE_LEFT),a=Ce(t),d=t.internal_scrollState?.clientHeight??0;for(const{nextStickyNodeInfo:p,stickyNode:m,type:y}of o){if(!m.yogaNode)continue;const b=$(m,t)??0,T=Math.round(m.yogaNode.getComputedHeight()),k=f+(_e(m,t)??0),v=m.parentNode;let C=0,S=Number.MAX_SAFE_INTEGER;v?.yogaNode&&(C=$(v,t)??0,S=Math.round(v.yogaNode.getComputedHeight()));let N;if(y==="top"){const w=v?.yogaNode?.getComputedBorder(x.EDGE_BOTTOM)??0,L=C+S-w;let _=g-a+L-T;const B=g-a+b,D=g+h;if(p?.node?.yogaNode){const W=$(p.node,t)??0,P=g-a+W-T;P<_&&(_=P)}N=Math.min(Math.max(D,B),_)}else{const w=v?.yogaNode?.getComputedBorder(x.EDGE_TOP)??0;let L=g-a+C+w;const _=g-a+b,B=g+h+d-T;if(p?.node?.yogaNode){const D=Math.round(p.node.yogaNode.getComputedHeight()),W=$(p.node,t)??0,P=g-a+W+D;P>L&&(L=P)}N=Math.max(Math.min(B,_),L)}const E=r({height:T,width:Math.round(m.yogaNode.getComputedWidth())});n(m,E,{offsetX:-Math.round(m.yogaNode.getComputedLeft()),offsetY:-Math.round(m.yogaNode.getComputedTop()),skipStaticElements:c,transformers:l});const R=E.get().output.split(`
|
|
8
|
-
`);for(const[w,L]of R.entries())L&&L.length>0&&e.write(k-(f+u),N-(g+h)+w,L,{transformers:[]})}},Ze=(o,t)=>{const e=o.childNodes[0]?.yogaNode;if(e){const r=Math.round(e.getComputedLeft()),i=Math.round(e.getComputedTop());t=`
|
|
9
|
-
`.repeat(i)+ke(t,r)}return t},et=31,tt=127,ot=128,rt=159,it=(o,t)=>{if(!Number.isFinite(t))return!1;if(t<0)return!0;let e=0;for(const r of o){if(r===`
|
|
10
|
-
`){if(e>t)return!0;e=0;continue}const i=r.codePointAt(0);if(i<=et||i===tt||i>=ot&&i<=rt||Te(i)||(e++,e>t))return!0}return!1},st=o=>(o.internal_hidden??!1)||o.yogaNode?.getDisplay()===x.DISPLAY_NONE,nt=o=>{let t=o;for(;t;){if(st(t))return!0;t=t.parentNode}return!1},U=(o,t={})=>{if(t.skipStaticElements&&o.internal_static||o.internal_hidden||o.internal_stickyAlternate||o.yogaNode?.getDisplay()===x.DISPLAY_NONE)return"";let e="";if(o.nodeName==="ink-text")e=be(o);else if(o.nodeName==="ink-box"||o.nodeName==="ink-root"){const r=o.style.flexDirection==="row"||o.style.flexDirection==="row-reverse"?" ":`
|
|
11
|
-
`;e=(o.style.flexDirection==="row-reverse"||o.style.flexDirection==="column-reverse"?o.childNodes.toReversed():[...o.childNodes]).map(i=>U(i,{parentRole:o.internal_accessibility?.role,skipStaticElements:t.skipStaticElements})).filter(Boolean).join(r)}if(o.internal_accessibility){const{role:r,state:i}=o.internal_accessibility;if(i){const l=Object.keys(i).filter(n=>i[n]).join(", ");l&&(e=`(${l}) ${e}`)}r&&r!==t.parentRole&&(e=`${r}: ${e}`)}return e},X=(o,t,e)=>{const{absoluteOffsetX:r,absoluteOffsetY:i,offsetX:l=0,offsetY:n=0,renderState:c,skipStaticElements:f,transformers:g=[]}=e;if(f&&o.internal_static||o.internal_hidden)return;if(o.cachedRender){const h=Math.round(l+(o.yogaNode?.getComputedLeft()??0)),u=Math.round(n+(o.yogaNode?.getComputedTop()??0));t.addRegionTree(o.cachedRender,h,u);return}if(o.nodeName==="ink-cursor"){if(!c)return;c.cursorRequested=!0;const h=o.internal_cursor;if(!h){c.cursorPosition=void 0;return}if(c.cursorShape=h.shape,h.inline){if(c.lastTextWriteEnd)c.cursorPosition={x:c.lastTextWriteEnd.x,y:c.lastTextWriteEnd.y};else{const d=o.parentNode?ie(o.parentNode):void 0;c.cursorPosition=d?{x:d.x,y:d.y}:void 0}return}const u=h.anchorRef?h.anchorRef.current:o.parentNode;if(!u){c.cursorPosition=void 0;return}if(h.anchorRef&&nt(u)){c.cursorPosition=void 0;return}const a=ie(u);if(!a){c.cursorPosition=void 0;return}c.cursorPosition={x:a.x+h.x,y:a.y+h.y};return}const{yogaNode:s}=o;if(s){if(s.getDisplay()===x.DISPLAY_NONE)return;const h=s.getComputedLeft(),u=s.getComputedTop(),a=Math.round(l+h),d=Math.round(n+u),p=Math.round((r??l)+h),m=Math.round((i??n)+u),y=t.getCurrentClip();if(y){const C=Math.round(s.getComputedWidth()),S=Math.round(s.getComputedHeight()),N=p+C,E=m+S,R=y.x1??-1/0,w=y.x2??1/0,L=y.y1??-1/0,_=y.y2??1/0;if(N<=R||p>=w||E<=L||m>=_)return}let b=g;if(typeof o.internal_transform=="function"&&(b=[o.internal_transform,...g]),o.nodeName==="ink-text"){let C=be(o);if(C.length>0){const S=je(s);if(it(C,S)&&Math.max(...C.split(`
|
|
12
|
-
`).map(N=>V(N)))>S){const N=o.style.textWrap??"wrap";C=Me(C,Math.floor(S),N)}if(C=Ze(o,C),t.write(a,d,C,{transformers:b}),c){const N=C.split(`
|
|
13
|
-
`),E=N.at(-1)??"";c.lastTextWriteEnd={x:a+V(E),y:d+N.length-1}}}return}let T=!1,k=0,v=0;if(o.nodeName==="ink-box"){Ve(a,d,o,t),Ue(a,d,o,t);const C=o.style.overflow??"visible",S=o.style.overflowX??C,N=o.style.overflowY??C,E=S==="hidden"||S==="scroll",R=N==="hidden"||N==="scroll";if(E||R){const w=Math.round(s.getComputedWidth()),L=Math.round(s.getComputedHeight()),_=E?a+s.getComputedBorder(x.EDGE_LEFT):a,B=E?w-s.getComputedBorder(x.EDGE_LEFT)-s.getComputedBorder(x.EDGE_RIGHT):w,D=R?d+s.getComputedBorder(x.EDGE_TOP):d,W=R?L-s.getComputedBorder(x.EDGE_TOP)-s.getComputedBorder(x.EDGE_BOTTOM):L;t.startChildRegion(_,D,Math.max(0,B),Math.max(0,W)),T=!0,N==="scroll"&&o.internal_scrollState&&(v=-o.internal_scrollState.scrollTop),S==="scroll"&&o.internal_scrollState&&(k=-o.internal_scrollState.scrollLeft)}}if(o.nodeName==="ink-root"||o.nodeName==="ink-box"||o.nodeName==="ink-static-render"){for(const C of o.childNodes)X(C,t,{absoluteOffsetX:p+k,absoluteOffsetY:m+v,offsetX:a+k,offsetY:d+v,renderState:c,skipStaticElements:f,transformers:b});if(o.nodeName==="ink-box"&&o.internal_scrollState){const C=ve(o);if(C.length>0){const S=Ce(o),N=o.internal_scrollState.clientHeight,E=S+N,R=Je(C,o,S,E);R.length>0&&Qe(R,o,t,w=>new Q(w),{newTransformers:b,renderNodeToOutput:X,skipStaticElements:f,x:a,y:d})}}if(o.nodeName==="ink-box"&&o.internal_scrollState){const C=o.style.overflow??"visible",S=o.style.overflowX??C,N=o.style.overflowY??C,E=s.getComputedBorder(x.EDGE_LEFT),R=s.getComputedBorder(x.EDGE_RIGHT),w=s.getComputedBorder(x.EDGE_TOP),L=s.getComputedBorder(x.EDGE_BOTTOM),_=Math.round(s.getComputedWidth()-E-R),B=Math.round(s.getComputedHeight()-w-L),{clientHeight:D,clientWidth:W,scrollHeight:P,scrollLeft:Ne,scrollTop:Se,scrollWidth:Z}=o.internal_scrollState,ee=N==="scroll"&&P>D,Ee=S==="scroll"&&Z>W,te=o.internal_scrollbar!==!1;if(ee&&te){const G=se({axis:"vertical",clientDimension:D,hasOppositeScrollbar:!1,height:B,marginBottom:0,marginRight:0,scrollDimension:P,scrollPosition:Se,width:_,x:a+E,y:d+w});G&&me({axis:"vertical",color:o.style.scrollbarThumbColor,layout:G,output:t})}if(Ee&&te){const G=se({axis:"horizontal",clientDimension:W,hasOppositeScrollbar:ee,height:B,marginBottom:0,marginRight:0,scrollDimension:Z,scrollPosition:Ne,width:_,x:a+E,y:d+w});G&&me({axis:"horizontal",color:o.style.scrollbarThumbColor,layout:G,output:t})}}T&&t.endChildRegion()}}},St=(o,t)=>{if(!o.yogaNode)return;const e=Math.round(o.yogaNode.getComputedWidth()),r=Math.round(o.yogaNode.getComputedHeight());if(e<=0||r<=0)return;const{setCachedRender:i}=require("./dom"),l=new Q({height:r,width:e});for(const c of o.childNodes)X(c,l,{skipStaticElements:t?.skipStaticElements});const n={children:[],cursorPosition:void 0,height:r,id:o.internalId??"static",isScrollable:!1,lines:[...l.getRootLines()],selectableSpans:[],stickyHeaders:[],styledOutput:[...l.getRootLines()],width:e,x:0,y:0};i(o,n)},lt=(o,t)=>{const e=new Map;if(t.rangeCount===0)return e;const r=t.getRangeAt(0),{endContainer:i,endOffset:l,startContainer:n,startOffset:c}=r;if(!n||!i)return e;let f=!1,g=!1;const s=(u,a,d,p,m,y)=>{if(u.nodeName==="#text"){const{length:b}=u.nodeValue;n===u&&(m.value=!0,d.value=a.value+c),i===u&&(y.value=!0,p.value=a.value+l),a.value+=b}else if("childNodes"in u){for(const b of u.childNodes)u===n&&(m.value=!0,d.value=a.value),u===i&&(y.value=!0,p.value=a.value),s(b,a,d,p,m,y);u===n&&c===u.childNodes.length&&(m.value=!0,d.value=a.value),u===i&&l===u.childNodes.length&&(y.value=!0,p.value=a.value)}},h=u=>{if(u.nodeName==="ink-text"){if(!xe(u))return;const a={value:0},d={value:-1},p={value:-1},m={value:!1},y={value:!1};for(const b of u.childNodes)u===n&&(m.value=!0,d.value=a.value),u===i&&(y.value=!0,p.value=a.value),s(b,a,d,p,m,y);if(u===n&&c===u.childNodes.length&&(m.value=!0,d.value=a.value),u===i&&l===u.childNodes.length&&(y.value=!0,p.value=a.value),(f||m.value)&&(!g||y.value)){const b=m.value?d.value:0,T=y.value?p.value:a.value;b!==-1&&T!==-1&&b<T&&e.set(u,{end:T,start:b})}m.value&&(f=!0),y.value&&(g=!0)}else{const{childNodes:a}=u;if(a){for(const d of a)u===n&&(f=!0),u===i&&(g=!0),h(d);u===n&&c===a.length&&(f=!0),u===i&&l===a.length&&(g=!0)}}};return h(o),e},at=new J,dt=new J,ht=new WeakMap,ut=new WeakMap,ye=({caches:o,height:t,node:e,outputs:r,width:i})=>{let l=r.get(e);return l||(l=new Q({caches:o,height:t,width:i}),r.set(e,l)),l.reset(i,t),l},Et=(o,t,e)=>{if(o.yogaNode){if(t){const f=U(o,{skipStaticElements:!0}),g=f===""?0:f.split(`
|
|
14
|
-
`).length;let s="";return o.staticNode&&(s=U(o.staticNode,{skipStaticElements:!1})),{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:f,outputHeight:g,staticOutput:s?`${s}
|
|
15
|
-
`:""}}e?.selection&&e.selection.rangeCount>0&<(o,e.selection);const r=ye({caches:at,height:o.yogaNode.getComputedHeight(),node:o,outputs:ht,width:o.yogaNode.getComputedWidth()}),i={cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0};X(o,r,{renderState:i,skipStaticElements:!0});let l;if(o.staticNode?.yogaNode&&(l=ye({caches:dt,height:o.staticNode.yogaNode.getComputedHeight(),node:o,outputs:ut,width:o.staticNode.yogaNode.getComputedWidth()}),X(o.staticNode,l,{skipStaticElements:!1})),e?.useNativeRenderer){const{buffer:f,height:g}=r.getBuffer();return{cursorPosition:i.cursorPosition,cursorRequested:i.cursorRequested,cursorShape:i.cursorShape,output:"",outputBuffer:f,outputHeight:g,outputWidth:r.width,staticOutput:l?`${l.get().output}
|
|
16
|
-
`:""}}const{height:n,output:c}=r.get();return{cursorPosition:i.cursorPosition,cursorRequested:i.cursorRequested,cursorShape:i.cursorShape,output:c,outputHeight:n,staticOutput:l?`${l.get().output}
|
|
17
|
-
`:""}}return{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:"",outputHeight:0,staticOutput:""}};export{Et as H,Q as I,X as _,St as r};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as u,t as d}from"./ansi-tokenizer-BU67A126.js";const f=/^[\d:;]*$/,h="\x1B]8;",m="8;",x=n=>n.startsWith(h)||n.startsWith(m),p=n=>{if(!u(n))return n;let s="";for(const t of d(n)){if(t.type==="text"){s+=t.value;continue}if(t.type==="osc"&&x(t.value)){s+=t.value;continue}t.type==="csi"&&t.finalCharacter==="m"&&t.intermediateString===""&&f.test(t.parameterString)&&(s+=t.value)}return s},N=n=>{let s="";for(let t=0;t<n.childNodes.length;t++){const r=n.childNodes[t];if(r===void 0)continue;let a="";r.nodeName==="#text"?a=r.nodeValue:((r.nodeName==="ink-text"||r.nodeName==="ink-virtual-text")&&(a=N(r)),a.length>0&&typeof r.internal_transform=="function"&&(a=r.internal_transform(a,t))),s+=a}return p(s)},g=(n,s,t)=>{if(n.internal_textCache){const{map:o,text:e}=n.internal_textCache;for(const[i,c]of o.entries())s.set(i,{end:c.end+t.current,start:c.start+t.current});return t.current+=e.length,e}let r="";const a=new Map,l={current:0};for(let o=0;o<n.childNodes.length;o++){const e=n.childNodes[o];if(e===void 0)continue;let i="";const c=l.current;e.nodeName==="#text"?(i=e.nodeValue,a.set(e,{end:c+i.length,start:c}),l.current+=i.length):((e.nodeName==="ink-text"||e.nodeName==="ink-virtual-text")&&(i=g(e,a,l),a.set(e,{end:l.current,start:c})),i.length>0&&typeof e.internal_transform=="function"&&(i=e.internal_transform(i,o))),r+=i}n.internal_textCache={map:a,text:r};for(const[o,e]of a.entries())s.set(o,{end:e.end+t.current,start:e.start+t.current});return t.current+=r.length,r};export{N as default,g as squashTextNodesWithMap};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as c}from"node:module";import{createContext as t}from"react";const e=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,r=e,s=t({stderr:r.stderr,write(){}});s.displayName="InternalStderrContext";export{s as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as s}from"node:module";import{createContext as l}from"react";let o;const i=t=>(o??=s(import.meta.url))(t),e=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,c=t=>{if(typeof e<"u"&&e.versions&&e.versions.node){const[n,r]=e.versions.node.split(".").map(Number);if(n>22||n===22&&r>=3||n===20&&r>=16)return e.getBuiltinModule(t)}return i(t)},{EventEmitter:a}=c("node:events"),d=e,u=l({internal_eventEmitter:new a,internal_exitOnCtrlC:!0,isRawModeSupported:!1,setBracketedPasteMode(){},setRawMode(){},stdin:d.stdin});u.displayName="InternalStdinContext";export{u as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as c}from"node:module";import{createContext as o}from"react";const e=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,t=e,r=o({stdout:t.stdout,write(){}});r.displayName="InternalStdoutContext";export{r as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{getStringWidth as u}from"@visulima/string";const a={ambiguousIsNarrow:!0,emojiWidth:1};function c(t){return Math.max(1,u(t,a))}function f(t){return u(t,a)}function g(t,o){if(o<=0)return 0;if(t.length===0)return 1;let i=1,n=0;for(const r of t){const e=Math.min(c(r),o);n+e>o&&(i++,n=0),n+=e}return i}function d(t,o){const i=t.split(`
|
|
2
|
-
`);let n=0,r=0;for(const e of i){const s=f(e);s>n&&(n=s),r+=o>0?g(e,o):0}return{maxLineWidth:n,wrappedRows:r}}export{c as a,f as g,d as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as w}from"node:module";let _;const b=e=>(_??=w(import.meta.url))(e),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,m=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[r,s]=o.versions.node.split(".").map(Number);if(r>22||r===22&&s>=3||r===20&&s>=16)return o.getBuiltinModule(e)}return b(e)},n=o,{execFileSync:g}=m("node:child_process"),c=m("node:fs"),h=m("node:tty"),d=80,p=24,a=(e,r,{shell:s,env:t}={})=>g(e,r,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:s,env:t}).trim(),u=(e,r)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(r,10)}),N=(e,r)=>{const{columns:s,rows:t}=u(e,r);if(!(Number.isNaN(s)||Number.isNaN(t))&&!(s===d&&t===p))return{columns:s,rows:t}},y=()=>{if(n.platform!=="linux")return!0;try{const e=c.readFileSync("/proc/self/stat","utf8"),r=e.lastIndexOf(") ");if(r===-1)return!1;const s=e.slice(r+2).trim().split(/\s+/),t=Number.parseInt(s[2],10),i=Number.parseInt(s[5],10);return Number.isNaN(t)||Number.isNaN(i)||i<=0?!1:t===i}catch{return!1}};function v(){const{env:e,stdout:r,stderr:s}=n;if(r?.columns&&r?.rows)return u(r.columns,r.rows);if(s?.columns&&s?.rows)return u(s.columns,s.rows);if(e.COLUMNS&&e.LINES)return u(e.COLUMNS,e.LINES);const t={columns:d,rows:p};return n.platform==="win32"?l()??t:n.platform==="darwin"?f()??l()??t:f()??l()??O()??t}const f=()=>{try{const e=n.platform==="darwin"?c.constants.O_EVTONLY|c.constants.O_NONBLOCK:c.constants.O_NONBLOCK,{columns:r,rows:s}=h.WriteStream(c.openSync("/dev/tty",e));return{columns:r,rows:s}}catch{}},l=()=>{try{const e=a("tput",["cols"],{env:{TERM:"dumb",...n.env}}),r=a("tput",["lines"],{env:{TERM:"dumb",...n.env}});if(e&&r)return N(e,r)}catch{}},O=()=>{try{if(!y())return;const e=a("resize",["-u"]).match(/\d+/g);if(e.length===2)return N(e[0],e[1])}catch{}},I=e=>{const{columns:r,rows:s}=e;if(r&&s)return{columns:r,rows:s};const t=v();return{columns:r||t.columns||80,rows:s||t.rows||24}};export{I as g};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const w=async(e,i,o={})=>{const c=o.timeout??3e3,a=o.interval??50,s=Date.now();let r=new Error("waitFor timed out");const n=()=>{if(typeof e=="string"){const t=i();if(!t.includes(e))throw new Error(`Timed out waiting for text: "${e}"
|
|
2
|
-
|
|
3
|
-
Screen content:
|
|
4
|
-
${t}`)}else e()};for(;Date.now()-s<c;){try{n();return}catch(t){r=t}await new Promise(t=>{setTimeout(t,a)})}try{n();return}catch(t){r=t}throw r};export{w as waitFor};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{S as V,d as p,i as o}from"./measure-text-B7juNq4Y.js";const m=(e,i,u="end")=>{if(i<1)return new V;if(p(e)<=i)return e;const t=new V;if(t.pushChar("…",0),i===1)return t;if(u==="start"){let l=0,a=e.length;for(let n=e.length-1;n>=0&&(l+=o(e.getValue(n)),!(l>i-1));n--)a=n;return t.combine(e.slice(a))}if(u==="middle"){const l=Math.ceil(i/2),a=i-l;let n=0,c=0;for(let r=0;r<e.length;r++){const g=o(e.getValue(r));if(c+g>l-1)break;c+=g,n=r+1}let s=e.length;c=0;for(let r=e.length-1;r>=0&&(c+=o(e.getValue(r)),!(c>a));r--)s=r;return e.slice(0,n).combine(t,e.slice(s))}let f=0,h=0;for(let l=0;l<e.length;l++){const a=o(e.getValue(l));if(h+a>i-1)break;h+=a,f=l+1}return e.slice(0,f).combine(t)},y=(e,i)=>{const u=[];let t=0,f=0,h=!0,l=0;for(;l<e.length;){const a=e.getValue(l);if(a===`
|
|
2
|
-
`){u.push(e.slice(t,l)),t=l+1,f=0,h=!0,l++;continue}let n=l,c=0;if(a===" ")c=o(" "),n=l+1;else for(;n<e.length&&e.getValue(n)!==" "&&e.getValue(n)!==`
|
|
3
|
-
`;)c+=o(e.getValue(n)),n++;if(f+c>i&&f>0){if(a===" "&&!h&&!e.hasStyles(l)){l=n;continue}let s=l;for(;s>t&&e.getValue(s-1)===" "&&!e.hasStyles(s-1);)s--;u.push(e.slice(t,s)),t=l,f=0;continue}if(f===0&&c>i){let s=l,r=0;for(;s<n;){const g=o(e.getValue(s));r+g>i&&r>0&&(u.push(e.slice(t,s)),t=s,r=0),r+=g,s++}f=r,l=n,h=!1}else f+=c,l=n,a!==" "&&(h=!1)}return(t<e.length||u.length===0)&&u.push(e.slice(t)),u},d=(e,i,u="wrap")=>{if(u.startsWith("truncate")){let t="end";return u==="truncate-middle"?t="middle":u==="truncate-start"&&(t="start"),[m(e,i,t)]}return y(e,i)};export{d as wrapOrTruncateStyledLine};
|