fckgit 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/app.js +1 -1
  2. package/package.json +1 -1
package/dist/app.js CHANGED
@@ -116,4 +116,4 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
116
116
  */
117
117
  var Ws=x((e=>{var t=Symbol.for(`react.transitional.element`);function n(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.jsx=n,e.jsxs=n})),G=x(((e,t)=>{t.exports=Ws()}))(),Gs=({children:e,onMeasure:t,index:n,width:r,measureKey:i})=>{let a=(0,j.useRef)(null);return(0,j.useLayoutEffect)(()=>{if(a.current){let{height:e}=Us(a.current);t(n,e)}},[n,t,r,i,e]),(0,G.jsx)(W,{ref:a,flexShrink:0,width:`100%`,flexDirection:`column`,children:e})};function Ks(e){let[t,n]=(0,j.useState)(e),r=(0,j.useRef)(e);return[t,(0,j.useCallback)(e=>{let t=typeof e==`function`?e(r.current):e;r.current=t,n(t)},[]),(0,j.useCallback)(()=>r.current,[])]}var qs=(0,j.forwardRef)(({scrollOffset:e,onViewportSizeChange:t,onContentHeightChange:n,onItemHeightChange:r,debug:i=!1,children:a,...o},s)=>{let[c,l,u]=Ks({height:0,width:0}),[d,f,p]=Ks(0),[m,h]=(0,j.useState)({}),g=(0,j.useRef)(null),_=(0,j.useRef)(null),v=(0,j.useRef)(0);(0,j.useLayoutEffect)(()=>{d!==v.current&&(n?.(d,v.current),v.current=d)},[d,n]);let y=(0,j.useRef)({}),b=(0,j.useRef)([]),x=(0,j.useRef)([]),S=(0,j.useRef)(0),C=(0,j.useCallback)((e,t)=>{let n=b.current[e]||e;if(y.current[n]!==t){let i=y.current[n]||0;y.current={...y.current,[n]:t};let a=0;for(let e of b.current)a+=y.current[e]||0;let o=p();a!==o&&f(a),r?.(e,t,i),S.current=Math.min(S.current,e+1)}},[r,n,p,f]),w=(0,j.useCallback)(()=>{if(g.current){let{width:e,height:n}=Us(g.current),r=u();(e!==r.width||n!==r.height)&&(t?.({width:e,height:n},r),l({width:e,height:n}))}},[g,t,u,l]);(0,j.useLayoutEffect)(()=>{w()});let T=(0,j.useRef)(null);if(T.current!==a){T.current=a;let e=[],t={};j.Children.forEach(a,(n,r)=>{if(!n)return;let i=(0,j.isValidElement)(n)?n.key:null,a=i===null?r:i;e[r]=a,t[a]=y.current[a]||0}),y.current=t,b.current=e,x.current=Array(e.length).fill(0),S.current=0;let n=0;e.forEach(e=>{n+=t[e]||0});let r=p();n!==r&&f(n)}return(0,j.useImperativeHandle)(s,()=>({getContentHeight:p,getViewportHeight:()=>u().height,getBottomOffset:()=>Math.max(0,p()-u().height),getItemHeight:e=>{let t=b.current[e]||e;return y.current[t]||0},remeasure:w,remeasureItem:e=>h(t=>({...t,[e]:(t[e]||0)+1})),getItemPosition:e=>{if(e<0||e>=b.current.length)return null;if(e>=S.current){let t=0,n=0;if(S.current>0){n=S.current;let e=n-1,r=b.current[e]||e,i=y.current[r]||0;t=(x.current[e]??0)+i}for(let r=n;r<=e;r++){x.current[r]=t;let e=b.current[r]||r,n=y.current[e]||0;t+=n}S.current=e+1}let t=x.current[e]??0,n=b.current[e]||e;return{top:t,height:y.current[n]||0}}}),[]),(0,G.jsx)(W,{...o,children:(0,G.jsx)(W,{ref:g,width:`100%`,children:(0,G.jsx)(W,{overflow:i?void 0:`hidden`,width:`100%`,children:(0,G.jsx)(W,{ref:_,width:`100%`,flexDirection:`column`,marginTop:-e,children:j.Children.map(a,(e,t)=>e?(0,G.jsx)(Gs,{index:t,width:c.width,onMeasure:C,measureKey:m[t],children:e},(0,j.isValidElement)(e)&&e.key||t):null)})})})})});function Js(e){let[t,n]=(0,j.useState)(e),r=(0,j.useRef)(e);return[t,(0,j.useCallback)(e=>{let t=typeof e==`function`?e(r.current):e;r.current=t,n(t)},[]),(0,j.useCallback)(()=>r.current,[])]}var Ys=(0,j.forwardRef)(({onScroll:e,onViewportSizeChange:t,onContentHeightChange:n,onItemHeightChange:r,debug:i=!1,children:a,...o},s)=>{let[c,l,u]=Js(0),d=(0,j.useRef)(null),f=(0,j.useRef)(0),p=(0,j.useCallback)((t,r)=>{f.current=t,n?.(t,r),u()>t&&(l(t),e?.(t))},[n,e,u,l]),m=(0,j.useCallback)(()=>Math.max(0,f.current-(d.current?.getViewportHeight()||0)),[]);return(0,j.useImperativeHandle)(s,()=>({scrollTo:t=>{if(typeof t!=`number`||isNaN(t))return;let n=f.current,r=Math.max(0,Math.min(t,n));r!==u()&&(l(r),e?.(r))},scrollBy:t=>{if(typeof t!=`number`||isNaN(t))return;let n=f.current,r=Math.max(0,Math.min(u()+t,n));r!==u()&&(l(r),e?.(r))},scrollToTop:()=>{u()!==0&&(l(0),e?.(0))},scrollToBottom:()=>{let t=m();u()!==t&&(l(t),e?.(t))},getScrollOffset:u,getContentHeight:()=>f.current,getViewportHeight:()=>d.current?.getViewportHeight()||0,getBottomOffset:m,getItemHeight:e=>d.current?.getItemHeight(e)||0,getItemPosition:e=>d.current?.getItemPosition(e)||null,remeasure:()=>d.current?.remeasure(),remeasureItem:e=>d.current?.remeasureItem(e)}),[e,m,u,l]),(0,G.jsx)(qs,{ref:d,scrollOffset:c,onViewportSizeChange:t,onContentHeightChange:p,onItemHeightChange:r,debug:i,children:a,...o})});const Xs=s(`git`,[`rev-parse`,`--show-toplevel`],{encoding:`utf8`,stdio:`pipe`}).trimEnd();function Zs(...e){return s(`git`,e,{encoding:`utf8`,stdio:`pipe`,cwd:Xs}).trimEnd()}function Qs(...e){return c(`git`,e,{encoding:`utf8`,cwd:Xs}).stdout?.trim()??``}function $s(){try{return Zs(`branch`,`--show-current`)}catch{return null}}const ec={M:`MODIFIED`,A:`ADDED`,D:`DELETED`,R:`RENAMED`,"?":`UNTRACKED`};function tc(){try{let e=Zs(`status`,`--porcelain`,`--untracked-files=all`);return e?e.split(`
118
118
  `).map(e=>{let[t,n]=e,r=t!==` `&&t!==`?`,i=r?n!==` `&&n!==`?`?`PARTIAL`:`FULL`:`NONE`,a=n===`?`?`?`:r?t:n,o=e.slice(3);return{path:o,displayPath:p.relative(process.cwd(),p.join(Xs,o)),status:ec[a??``]??`-`,stagedStatus:i}}):[]}catch{return[]}}function nc({path:e,mode:t,contextLines:n=3}){let r=`-U${n}`;return t===`untracked`?Qs(`diff`,r,`--no-index`,`/dev/null`,e):t===`staged`?Qs(`diff`,r,`--cached`,e):Qs(`diff`,r,e)}function rc(e){Zs(`add`,e)}function ic(e){try{Zs(`restore`,`--staged`,e)}catch{Zs(`rm`,`--cached`,`--force`,e)}}function ac({raw:e,staged:t}){if(!e)return[];let n=e.split(`
119
- `),r=n.findIndex(e=>e.startsWith(`@@`));if(r===-1)return[];let i=!0;return n.slice(r).flatMap(e=>e.startsWith(`@@`)?i?(i=!1,[]):[{kind:`separator`,text:`···`,staged:t}]:e.startsWith(`+`)?[{kind:`add`,text:e.slice(1),staged:t}]:e.startsWith(`-`)?[{kind:`remove`,text:e.slice(1),staged:t}]:[{kind:`context`,text:e.slice(1),staged:t}])}function oc(e,t=3){if(e.stagedStatus===`PARTIAL`){let n=n=>ac({raw:nc({path:e.path,mode:n?`staged`:`unstaged`,contextLines:t}),staged:n}),r=n(!0),i=n(!1),a={kind:`separator`,text:`unstaged`,staged:!1};return[...r,...r.length&&i.length?[a]:[],...i]}let n=e.stagedStatus!==`NONE`,r=e.status===`UNTRACKED`?`untracked`:n?`staged`:`unstaged`;return ac({raw:nc({path:e.path,mode:r,contextLines:t}),staged:n})}function sc({children:e,watchValue:t,duration:n=1e3}){let[r,i]=(0,j.useState)(!1),a=(0,j.useRef)(null),o=(0,j.useRef)(!0);return(0,j.useEffect)(()=>{if(o.current){o.current=!1;return}return i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),n),()=>{a.current&&clearTimeout(a.current)}},[t,n]),r?e:null}function cc(e){if(e.kind===`add`)return`#052e16`;if(e.kind===`remove`)return`#450a0a`}function lc({file:e,focused:t,width:n}){let[r,i]=(0,j.useState)([]),[a,o]=(0,j.useState)(0),[s,c]=(0,j.useState)(3),l=(0,j.useRef)(null),u=(0,j.useRef)(void 0),d=(0,j.useRef)(null),{width:f,height:p}=Hs(d);(0,j.useEffect)(()=>{if(!e){i([]),l.current?.scrollToTop();return}i(oc(e,s)),u.current!==e.path&&(l.current?.scrollToTop(),o(0),c(3)),u.current=e.path},[e,s]);let m=(0,j.useMemo)(()=>Math.max(0,...r.map(e=>e.text.length)),[r]);return Ls((e,t)=>{let n=Math.max(0,m-f);t.upArrow&&l.current?.scrollBy(-1),t.downArrow&&l.current?.scrollBy(1),t.leftArrow&&o(e=>Math.max(0,e-1)),t.rightArrow&&o(e=>Math.min(n,e+1)),e===`+`&&c(e=>e+1),e===`-`&&c(e=>Math.max(0,e-1))},{isActive:t}),(0,G.jsxs)(W,{flexDirection:`column`,width:n,ref:d,children:[(0,G.jsxs)(W,{marginX:1,gap:1,justifyContent:`space-between`,children:[(0,G.jsx)(Ko,{bold:!0,color:t?`whiteBright`:`gray`,wrap:`truncate-middle`,children:e?e.displayPath:`no file selected`}),(0,G.jsx)(sc,{watchValue:s,children:(0,G.jsxs)(Ko,{color:`gray`,children:[s,` lines`]})})]}),(0,G.jsx)(Ys,{borderColor:t?`white`:`gray`,borderStyle:`round`,flexGrow:1,height:p,ref:l,children:r.map((e,t)=>{if(e.kind===`separator`)return(0,G.jsx)(W,{width:`100%`,backgroundColor:`#222`,justifyContent:`center`,children:(0,G.jsx)(Ko,{color:`#555`,children:e.text})},t);let n=e.text.slice(a,a+f-2)||` `;return(0,G.jsx)(W,{width:`100%`,backgroundColor:cc(e),children:(0,G.jsx)(Ko,{wrap:`hard`,color:`white`,children:n})},t)})})]})}var uc=(0,j.forwardRef)((e,t)=>{let{children:n,selectedIndex:r,scrollAlignment:i=`auto`,onScroll:a,onViewportSizeChange:o,onContentHeightChange:s,onItemHeightChange:c,...l}=e,u=(0,j.useRef)(null),[d,f]=(0,j.useState)(0),p=(0,j.useRef)(0);(0,j.useEffect)(()=>{p.current=d},[d]);let m=(0,j.useCallback)(e=>{e!==p.current&&(f(e),a?.(e))},[a]),h=(0,j.useRef)(r);h.current=r;let g=(0,j.useCallback)(()=>{let e=h.current;if(e===void 0||e<0)return null;let t=u.current?.getItemPosition(e);if(!t)return null;let n=u.current?.getViewportHeight()??0,r=u.current?.getContentHeight()??0,i=t.top+t.height-n,a=t.top;i>a&&([i,a]=[a,i]);let o=Math.max(0,r-n);return{min:Math.max(0,i),max:Math.min(o,a)}},[]),_=(0,j.useCallback)(e=>{let t=u.current?.getContentHeight()??0,n=u.current?.getViewportHeight()??0,r=Math.max(0,t-n),i=Math.max(0,Math.min(e,r)),a=g();return a&&(i=Math.max(a.min,Math.min(i,a.max))),i},[g]),v=(0,j.useCallback)((e,t,n,r)=>{let i=u.current?.getItemPosition(e);if(!i)return t;let a=r??u.current?.getViewportHeight()??0,o=u.current?.getContentHeight()??0,s=t;if(n===`top`)s=i.top;else if(n===`bottom`)s=i.top+i.height-a;else if(n===`center`)s=i.top+i.height/2-a/2;else{let e=i.top+i.height;i.top<=t&&e>=t+a?s=t:i.top<t?s=i.top:e>t+a&&(s=e-a)}let c=Math.max(0,o-a);return Math.max(0,Math.min(s,c))},[]),y=d;r!==void 0&&r>=0&&(y=v(r,d,i)),(0,j.useEffect)(()=>{y!==d&&m(y)},[y,d,m]);let b=(0,j.useCallback)((e,t=i,n)=>{m(v(e,d,t,n))},[v,d,i,m]),x=(0,j.useCallback)((e,t)=>{h.current!==void 0&&h.current>=0&&m(v(h.current,d,i,e.height)),o?.(e,t)},[o,b]),S=(0,j.useCallback)((e,t,n)=>{let r=h.current;r!==void 0&&r>=0&&(e<r?m(_(d+(t-n))):e===r&&m(v(e,d,i))),c?.(e,t,n)},[c,c,v,i,d,_,m]),C=(0,j.useCallback)((e,t)=>{h.current!==void 0&&h.current>=0&&(b(h.current),m(v(h.current,d,i))),s?.(e,t)},[s,b]);return(0,j.useImperativeHandle)(t,()=>({scrollTo:e=>{m(_(e))},scrollBy:e=>{let t=p.current;m(_(t+e))},scrollToTop:()=>{m(_(0))},scrollToBottom:()=>{let e=u.current?.getContentHeight()??0,t=u.current?.getViewportHeight()??0;m(_(Math.max(0,e-t)))},getScrollOffset:()=>p.current,getContentHeight:()=>u.current?.getContentHeight()??0,getViewportHeight:()=>u.current?.getViewportHeight()??0,getBottomOffset:()=>u.current?.getBottomOffset()??0,getItemHeight:e=>u.current?.getItemHeight(e)??0,getItemPosition:e=>u.current?.getItemPosition(e)??null,remeasure:()=>u.current?.remeasure(),remeasureItem:e=>u.current?.remeasureItem(e)}),[]),(0,G.jsx)(qs,{ref:u,scrollOffset:y,onViewportSizeChange:x,onContentHeightChange:C,onItemHeightChange:S,...l,children:n})});function dc(e){return e.slice().sort((e,t)=>{let n=e.path.split(`/`).slice(0,-1).join(`/`),r=t.path.split(`/`).slice(0,-1).join(`/`);return n===r?e.path.localeCompare(t.path):n.localeCompare(r)})}function fc(){let[e,t]=(0,j.useState)(()=>dc(tc())),[n,r]=(0,j.useState)(()=>$s());function i(){t(dc(tc())),r($s())}(0,j.useEffect)(()=>{let e=setInterval(i,2e3);return()=>clearInterval(e)},[]);function a(e){rc(e),i()}function o(e){ic(e),i()}return{files:e,branch:n,stage:a,unstage:o}}const pc={NONE:`gray`,PARTIAL:`yellow`,FULL:`green`},mc={MODIFIED:{symbol:`ᵐ`,color:`yellow`},ADDED:{symbol:`ᵃ`,color:`green`},DELETED:{symbol:`ᵈ`,color:`red`},RENAMED:{symbol:`ʳ`,color:`cyan`},UNTRACKED:{symbol:`ᵘ`,color:`gray`},"-":{symbol:`⁻`,color:`gray`}};function hc({width:e,focused:t,onSelectedFile:n}){let{files:r,branch:i,stage:a,unstage:o}=fc(),[s,c]=(0,j.useState)(0),l=(0,j.useMemo)(()=>process.cwd().split(`/`).pop(),[]);return(0,j.useEffect)(()=>{n(r[s])},[s,r,n]),Ls((e,t)=>{if(t.upArrow&&c(e=>Math.max(0,e-1)),t.downArrow&&c(e=>Math.min(r.length-1,e+1)),e===` `){let e=r[s];if(!e)return;e.stagedStatus===`FULL`?o(e.path):a(e.path)}},{isActive:t}),(0,G.jsxs)(W,{flexDirection:`column`,width:e,children:[(0,G.jsxs)(W,{marginX:1,overflow:`hidden`,gap:1,children:[(0,G.jsx)(W,{overflow:`hidden`,minWidth:3,children:(0,G.jsx)(Ko,{bold:!0,color:t?`whiteBright`:`gray`,wrap:`truncate-middle`,children:l})}),(0,G.jsx)(W,{flexShrink:0,children:(0,G.jsx)(Ko,{color:`gray`,children:`⌥`})}),(0,G.jsx)(W,{overflow:`hidden`,minWidth:3,children:(0,G.jsx)(Ko,{color:t?`whiteBright`:`gray`,wrap:`truncate-middle`,children:i})})]}),(0,G.jsx)(W,{borderColor:t?`white`:`gray`,borderStyle:`round`,flexGrow:1,children:(0,G.jsx)(uc,{height:`100%`,selectedIndex:s,width:`100%`,children:r.map((e,t)=>{let n=t===s,r=p.basename(e.displayPath),i=p.dirname(e.displayPath)===`.`?``:p.dirname(e.displayPath);return(0,G.jsxs)(W,{backgroundColor:n?`gray`:void 0,paddingX:1,height:1,children:[(0,G.jsxs)(Ko,{color:pc[e.stagedStatus],children:[e.stagedStatus===`NONE`?`○`:`●`,` `]}),(0,G.jsx)(W,{flexGrow:1,overflow:`hidden`,children:(0,G.jsxs)(Ko,{wrap:`hard`,children:[(0,G.jsx)(Ko,{color:`whiteBright`,children:r}),i?(0,G.jsxs)(Ko,{color:`gray`,children:[` `,i]}):null]})}),(0,G.jsx)(W,{flexShrink:0,marginLeft:1,children:(0,G.jsx)(Ko,{color:mc[e.status].color,children:mc[e.status].symbol})})]},e.path)})})})]})}const gc={files:[{key:`↑↓`,label:`navigate`},{key:`space`,label:`stage/unstage`},{key:`tab`,label:`switch pane`},{key:`q`,label:`quit`}],diff:[{key:`↑↓`,label:`scroll`},{key:`←→`,label:`pan`},{key:`+/-`,label:`context`},{key:`tab`,label:`switch pane`},{key:`q`,label:`quit`}]};function _c({focusedPane:e}){return(0,G.jsx)(W,{gap:2,paddingX:1,height:1,overflow:`hidden`,children:gc[e].map(({key:e,label:t})=>(0,G.jsxs)(W,{gap:1,flexShrink:0,children:[(0,G.jsx)(Ko,{bold:!0,color:`white`,children:e}),(0,G.jsx)(Ko,{color:`gray`,children:t})]},e))})}function vc(){let{exit:e}=Rs(),{stdout:t}=zs(),[n,r]=(0,j.useState)(`files`),[i,a]=(0,j.useState)(void 0);return Ls((t,n)=>{(t===`q`||n.ctrl&&t===`c`)&&e(),n.tab&&r(e=>e===`files`?`diff`:`files`)}),(0,G.jsxs)(W,{flexDirection:`column`,width:t.columns,height:t.rows,children:[(0,G.jsxs)(W,{flexDirection:`row`,flexGrow:1,children:[(0,G.jsx)(hc,{width:`30%`,focused:n===`files`,onSelectedFile:a}),(0,G.jsx)(lc,{file:i,focused:n===`diff`,width:`70%`})]}),(0,G.jsx)(_c,{focusedPane:n})]})}ms((0,G.jsx)(vc,{}),{alternateScreen:!0});export{};
119
+ `),r=n.findIndex(e=>e.startsWith(`@@`));if(r===-1)return[];let i=!0;return n.slice(r).flatMap(e=>e.startsWith(`@@`)?i?(i=!1,[]):[{kind:`separator`,text:`···`,staged:t}]:e.startsWith(`+`)?[{kind:`add`,text:e.slice(1),staged:t}]:e.startsWith(`-`)?[{kind:`remove`,text:e.slice(1),staged:t}]:[{kind:`context`,text:e.slice(1),staged:t}])}function oc(e,t=3){if(e.stagedStatus===`PARTIAL`){let n=n=>ac({raw:nc({path:e.path,mode:n?`staged`:`unstaged`,contextLines:t}),staged:n}),r=n(!0),i=n(!1),a={kind:`separator`,text:`unstaged`,staged:!1};return[...r,...r.length&&i.length?[a]:[],...i]}let n=e.stagedStatus!==`NONE`,r=e.status===`UNTRACKED`?`untracked`:n?`staged`:`unstaged`;return ac({raw:nc({path:e.path,mode:r,contextLines:t}),staged:n})}function sc({children:e,watchValue:t,duration:n=1e3}){let[r,i]=(0,j.useState)(!1),a=(0,j.useRef)(null),o=(0,j.useRef)(!0);return(0,j.useEffect)(()=>{if(o.current){o.current=!1;return}return i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),n),()=>{a.current&&clearTimeout(a.current)}},[t,n]),r?e:null}function cc(e){if(e.kind===`add`)return`#052e16`;if(e.kind===`remove`)return`#450a0a`}function lc({file:e,focused:t,width:n}){let[r,i]=(0,j.useState)([]),[a,o]=(0,j.useState)(0),[s,c]=(0,j.useState)(3),l=(0,j.useRef)(null),u=(0,j.useRef)(void 0),d=(0,j.useRef)(null),{width:f,height:p}=Hs(d);(0,j.useEffect)(()=>{if(!e){i([]),l.current?.scrollToTop();return}i(oc(e,s)),u.current!==e.path&&(l.current?.scrollToTop(),o(0),c(3)),u.current=e.path},[e,s]);let m=(0,j.useMemo)(()=>Math.max(0,...r.map(e=>e.text.length)),[r]);return Ls((e,t)=>{let n=Math.max(0,m-f);t.upArrow&&l.current?.scrollBy(-1),t.downArrow&&l.current?.scrollBy(1),t.leftArrow&&o(e=>Math.max(0,e-1)),t.rightArrow&&o(e=>Math.min(n,e+1)),e===`+`&&c(e=>e+1),e===`-`&&c(e=>Math.max(0,e-1))},{isActive:t}),(0,G.jsxs)(W,{flexDirection:`column`,width:n,ref:d,children:[(0,G.jsxs)(W,{marginX:1,gap:1,justifyContent:`space-between`,children:[(0,G.jsx)(Ko,{bold:!0,color:t?`whiteBright`:`gray`,wrap:`truncate-middle`,children:e?e.displayPath:`no file selected`}),(0,G.jsx)(sc,{watchValue:s,children:(0,G.jsxs)(Ko,{color:`gray`,children:[s,` lines`]})})]}),(0,G.jsx)(Ys,{borderColor:t?`white`:`gray`,borderStyle:`round`,flexGrow:1,height:p,ref:l,children:r.map((e,t)=>{if(e.kind===`separator`)return(0,G.jsx)(W,{width:`100%`,backgroundColor:`#222`,justifyContent:`center`,children:(0,G.jsx)(Ko,{color:`#555`,children:e.text})},t);let n=e.text.slice(a,a+f-2)||` `;return(0,G.jsx)(W,{width:`100%`,backgroundColor:cc(e),children:(0,G.jsx)(Ko,{wrap:`hard`,color:`white`,children:n})},t)})})]})}var uc=(0,j.forwardRef)((e,t)=>{let{children:n,selectedIndex:r,scrollAlignment:i=`auto`,onScroll:a,onViewportSizeChange:o,onContentHeightChange:s,onItemHeightChange:c,...l}=e,u=(0,j.useRef)(null),[d,f]=(0,j.useState)(0),p=(0,j.useRef)(0);(0,j.useEffect)(()=>{p.current=d},[d]);let m=(0,j.useCallback)(e=>{e!==p.current&&(f(e),a?.(e))},[a]),h=(0,j.useRef)(r);h.current=r;let g=(0,j.useCallback)(()=>{let e=h.current;if(e===void 0||e<0)return null;let t=u.current?.getItemPosition(e);if(!t)return null;let n=u.current?.getViewportHeight()??0,r=u.current?.getContentHeight()??0,i=t.top+t.height-n,a=t.top;i>a&&([i,a]=[a,i]);let o=Math.max(0,r-n);return{min:Math.max(0,i),max:Math.min(o,a)}},[]),_=(0,j.useCallback)(e=>{let t=u.current?.getContentHeight()??0,n=u.current?.getViewportHeight()??0,r=Math.max(0,t-n),i=Math.max(0,Math.min(e,r)),a=g();return a&&(i=Math.max(a.min,Math.min(i,a.max))),i},[g]),v=(0,j.useCallback)((e,t,n,r)=>{let i=u.current?.getItemPosition(e);if(!i)return t;let a=r??u.current?.getViewportHeight()??0,o=u.current?.getContentHeight()??0,s=t;if(n===`top`)s=i.top;else if(n===`bottom`)s=i.top+i.height-a;else if(n===`center`)s=i.top+i.height/2-a/2;else{let e=i.top+i.height;i.top<=t&&e>=t+a?s=t:i.top<t?s=i.top:e>t+a&&(s=e-a)}let c=Math.max(0,o-a);return Math.max(0,Math.min(s,c))},[]),y=d;r!==void 0&&r>=0&&(y=v(r,d,i)),(0,j.useEffect)(()=>{y!==d&&m(y)},[y,d,m]);let b=(0,j.useCallback)((e,t=i,n)=>{m(v(e,d,t,n))},[v,d,i,m]),x=(0,j.useCallback)((e,t)=>{h.current!==void 0&&h.current>=0&&m(v(h.current,d,i,e.height)),o?.(e,t)},[o,b]),S=(0,j.useCallback)((e,t,n)=>{let r=h.current;r!==void 0&&r>=0&&(e<r?m(_(d+(t-n))):e===r&&m(v(e,d,i))),c?.(e,t,n)},[c,c,v,i,d,_,m]),C=(0,j.useCallback)((e,t)=>{h.current!==void 0&&h.current>=0&&(b(h.current),m(v(h.current,d,i))),s?.(e,t)},[s,b]);return(0,j.useImperativeHandle)(t,()=>({scrollTo:e=>{m(_(e))},scrollBy:e=>{let t=p.current;m(_(t+e))},scrollToTop:()=>{m(_(0))},scrollToBottom:()=>{let e=u.current?.getContentHeight()??0,t=u.current?.getViewportHeight()??0;m(_(Math.max(0,e-t)))},getScrollOffset:()=>p.current,getContentHeight:()=>u.current?.getContentHeight()??0,getViewportHeight:()=>u.current?.getViewportHeight()??0,getBottomOffset:()=>u.current?.getBottomOffset()??0,getItemHeight:e=>u.current?.getItemHeight(e)??0,getItemPosition:e=>u.current?.getItemPosition(e)??null,remeasure:()=>u.current?.remeasure(),remeasureItem:e=>u.current?.remeasureItem(e)}),[]),(0,G.jsx)(qs,{ref:u,scrollOffset:y,onViewportSizeChange:x,onContentHeightChange:C,onItemHeightChange:S,...l,children:n})});function dc(e){return e.slice().sort((e,t)=>{let n=e.path.split(`/`).slice(0,-1).join(`/`),r=t.path.split(`/`).slice(0,-1).join(`/`);return n===r?e.path.localeCompare(t.path):n.localeCompare(r)})}function fc(){let[e,t]=(0,j.useState)(()=>dc(tc())),[n,r]=(0,j.useState)(()=>$s());function i(){t(dc(tc())),r($s())}(0,j.useEffect)(()=>{let e=setInterval(i,2e3);return()=>clearInterval(e)},[]);function a(e){rc(e),i()}function o(e){ic(e),i()}return{files:e,branch:n,stage:a,unstage:o}}const pc={NONE:`white`,PARTIAL:`yellow`,FULL:`green`},mc={MODIFIED:{symbol:`ᵐ`,color:`yellow`},ADDED:{symbol:`ᵃ`,color:`green`},DELETED:{symbol:`ᵈ`,color:`red`},RENAMED:{symbol:`ʳ`,color:`cyan`},UNTRACKED:{symbol:`ᵘ`,color:`gray`},"-":{symbol:`⁻`,color:`gray`}};function hc({width:e,focused:t,onSelectedFile:n}){let{files:r,branch:i,stage:a,unstage:o}=fc(),[s,c]=(0,j.useState)(0),l=(0,j.useMemo)(()=>process.cwd().split(`/`).pop(),[]);return(0,j.useEffect)(()=>{n(r[s])},[s,r,n]),Ls((e,t)=>{if(t.upArrow&&c(e=>Math.max(0,e-1)),t.downArrow&&c(e=>Math.min(r.length-1,e+1)),e===` `){let e=r[s];if(!e)return;e.stagedStatus===`FULL`?o(e.path):a(e.path)}},{isActive:t}),(0,G.jsxs)(W,{flexDirection:`column`,width:e,children:[(0,G.jsxs)(W,{marginX:1,overflow:`hidden`,gap:1,children:[(0,G.jsx)(W,{overflow:`hidden`,minWidth:3,children:(0,G.jsx)(Ko,{bold:!0,color:t?`whiteBright`:`gray`,wrap:`truncate-middle`,children:l})}),(0,G.jsx)(W,{flexShrink:0,children:(0,G.jsx)(Ko,{color:`gray`,children:`⌥`})}),(0,G.jsx)(W,{overflow:`hidden`,minWidth:3,children:(0,G.jsx)(Ko,{color:t?`whiteBright`:`gray`,wrap:`truncate-middle`,children:i})})]}),(0,G.jsx)(W,{borderColor:t?`white`:`gray`,borderStyle:`round`,flexGrow:1,children:(0,G.jsx)(uc,{height:`100%`,selectedIndex:s,width:`100%`,children:r.map((e,t)=>{let n=t===s,r=p.basename(e.displayPath),i=p.dirname(e.displayPath)===`.`?``:p.dirname(e.displayPath);return(0,G.jsxs)(W,{backgroundColor:n?`gray`:void 0,paddingX:1,height:1,children:[(0,G.jsxs)(Ko,{color:pc[e.stagedStatus],children:[e.stagedStatus===`NONE`?`○`:`●`,` `]}),(0,G.jsx)(W,{flexGrow:1,overflow:`hidden`,children:(0,G.jsxs)(Ko,{wrap:`hard`,children:[(0,G.jsx)(Ko,{color:`whiteBright`,children:r}),i?(0,G.jsxs)(Ko,{color:n?`white`:`gray`,children:[` `,i]}):null]})}),(0,G.jsx)(W,{flexShrink:0,marginLeft:1,children:(0,G.jsx)(Ko,{color:mc[e.status].color,children:mc[e.status].symbol})})]},e.path)})})})]})}const gc={files:[{key:`↑↓`,label:`navigate`},{key:`space`,label:`stage/unstage`},{key:`tab`,label:`switch pane`},{key:`q`,label:`quit`}],diff:[{key:`↑↓`,label:`scroll`},{key:`←→`,label:`pan`},{key:`+/-`,label:`context`},{key:`tab`,label:`switch pane`},{key:`q`,label:`quit`}]};function _c({focusedPane:e}){return(0,G.jsx)(W,{gap:2,paddingX:1,height:1,overflow:`hidden`,children:gc[e].map(({key:e,label:t})=>(0,G.jsxs)(W,{gap:1,flexShrink:0,children:[(0,G.jsx)(Ko,{bold:!0,color:`white`,children:e}),(0,G.jsx)(Ko,{color:`gray`,children:t})]},e))})}function vc(){let{exit:e}=Rs(),{stdout:t}=zs(),[n,r]=(0,j.useState)(`files`),[i,a]=(0,j.useState)(void 0);return Ls((t,n)=>{(t===`q`||n.ctrl&&t===`c`)&&e(),n.tab&&r(e=>e===`files`?`diff`:`files`)}),(0,G.jsxs)(W,{flexDirection:`column`,width:t.columns,height:t.rows,children:[(0,G.jsxs)(W,{flexDirection:`row`,flexGrow:1,children:[(0,G.jsx)(hc,{width:`30%`,focused:n===`files`,onSelectedFile:a}),(0,G.jsx)(lc,{file:i,focused:n===`diff`,width:`70%`})]}),(0,G.jsx)(_c,{focusedPane:n})]})}ms((0,G.jsx)(vc,{}),{alternateScreen:!0});export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fckgit",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "A fullscreen TUI Git client",
5
5
  "keywords": [
6
6
  "cli",