fckgit 1.1.3 → 1.1.5

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 +2 -2
  2. package/package.json +1 -1
package/dist/app.js CHANGED
@@ -378,5 +378,5 @@ process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return
378
378
  React keys must be passed directly to JSX without using spread:
379
379
  let props = %s;
380
380
  <%s key={someKey} {...props} />`,o,p,m,p),ae[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=O(),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),k=Symbol.for(`react.client.reference`),ee=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,te=Array.isArray,j=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var ne,M={},re=m.react_stack_bottom_frame.bind(m,o)(),ie=j(i(o)),ae={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>ee.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):re,r?j(i(e)):ie)},e.jsxs=function(e,t,n){var r=1e4>ee.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):re,r?j(i(e)):ie)}})()})),H=x(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=Zs():t.exports=Qs()}))(),$s=({children:e,onMeasure:t,index:n,width:r,measureKey:i})=>{let a=(0,N.useRef)(null);return(0,N.useLayoutEffect)(()=>{if(a.current){let{height:e}=Xs(a.current);t(n,e)}},[n,t,r,i,e]),(0,H.jsx)(Qo,{ref:a,flexShrink:0,width:`100%`,flexDirection:`column`,children:e})};function ec(e){let[t,n]=(0,N.useState)(e),r=(0,N.useRef)(e);return[t,(0,N.useCallback)(e=>{let t=typeof e==`function`?e(r.current):e;r.current=t,n(t)},[]),(0,N.useCallback)(()=>r.current,[])]}var tc=(0,N.forwardRef)(({scrollOffset:e,onViewportSizeChange:t,onContentHeightChange:n,onItemHeightChange:r,debug:i=!1,children:a,...o},s)=>{let[c,l,u]=ec({height:0,width:0}),[d,f,p]=ec(0),[m,h]=(0,N.useState)({}),g=(0,N.useRef)(null),_=(0,N.useRef)(null),v=(0,N.useRef)(0);(0,N.useLayoutEffect)(()=>{d!==v.current&&(n?.(d,v.current),v.current=d)},[d,n]);let y=(0,N.useRef)({}),b=(0,N.useRef)([]),x=(0,N.useRef)([]),S=(0,N.useRef)(0),C=(0,N.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,N.useCallback)(()=>{if(g.current){let{width:e,height:n}=Xs(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,N.useLayoutEffect)(()=>{w()});let T=(0,N.useRef)(null);if(T.current!==a){T.current=a;let e=[],t={};N.Children.forEach(a,(n,r)=>{if(!n)return;let i=(0,N.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,N.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,H.jsx)(Qo,{...o,children:(0,H.jsx)(Qo,{ref:g,width:`100%`,children:(0,H.jsx)(Qo,{overflow:i?void 0:`hidden`,width:`100%`,children:(0,H.jsx)(Qo,{ref:_,width:`100%`,flexDirection:`column`,marginTop:-e,children:N.Children.map(a,(e,t)=>e?(0,H.jsx)($s,{index:t,width:c.width,onMeasure:C,measureKey:m[t],children:e},(0,N.isValidElement)(e)&&e.key||t):null)})})})})});function nc(e){let[t,n]=(0,N.useState)(e),r=(0,N.useRef)(e);return[t,(0,N.useCallback)(e=>{let t=typeof e==`function`?e(r.current):e;r.current=t,n(t)},[]),(0,N.useCallback)(()=>r.current,[])]}var rc=(0,N.forwardRef)(({onScroll:e,onViewportSizeChange:t,onContentHeightChange:n,onItemHeightChange:r,debug:i=!1,children:a,...o},s)=>{let[c,l,u]=nc(0),d=(0,N.useRef)(null),f=(0,N.useRef)(0),p=(0,N.useCallback)((t,r)=>{f.current=t,n?.(t,r),u()>t&&(l(t),e?.(t))},[n,e,u,l]),m=(0,N.useCallback)(()=>Math.max(0,f.current-(d.current?.getViewportHeight()||0)),[]);return(0,N.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,H.jsx)(tc,{ref:d,scrollOffset:c,onViewportSizeChange:t,onContentHeightChange:p,onItemHeightChange:r,debug:i,children:a,...o})});function ic(e){if(!e)return[{kind:`context`,text:`(no diff)`}];let t=e.split(`
381
- `),n=t.findIndex(e=>e.startsWith(`@@`));return n===-1?[{kind:`context`,text:`(no diff)`}]:t.slice(n).map(e=>e.startsWith(`@@`)?{kind:`hunk`,text:e}:e.startsWith(`+`)?{kind:`add`,text:e.slice(1)}:e.startsWith(`-`)?{kind:`remove`,text:e.slice(1)}:{kind:`context`,text:e.slice(1)})}function ac(...e){return f(`git`,e,{encoding:`utf8`,stdio:`pipe`}).trimEnd()}function oc(...e){return p(`git`,e,{encoding:`utf8`}).stdout?.trim()??``}function sc(){try{return ac(`branch`,`--show-current`)}catch{return null}}const cc={M:`MODIFIED`,A:`ADDED`,D:`DELETED`,R:`RENAMED`,"?":`UNTRACKED`};function lc(){try{let e=ac(`status`,`--porcelain`,`--untracked-files=all`);return e?e.split(`
382
- `).map(e=>{let t=e[0],n=e[1],r=t!==` `&&t!==`?`,i=n===`?`?`?`:r?t:n;return{path:e.slice(3),status:cc[i??``]??`-`,staged:r}}):[]}catch{return[]}}function uc(e,t,n){return n?oc(`diff`,`--no-index`,`/dev/null`,e):t?oc(`diff`,`--cached`,e):oc(`diff`,e)}function dc(e){ac(`add`,e)}function fc(e){try{ac(`restore`,`--staged`,e)}catch{ac(`rm`,`--cached`,`--force`,e)}}function pc(e){if(e.kind===`add`)return`#0d2a0d`;if(e.kind===`remove`)return`#2a0d0d`}function mc({file:e,focused:t,width:n}){let[r,i]=(0,N.useState)([]),[a,o]=(0,N.useState)(0),s=(0,N.useRef)(null),c=(0,N.useRef)(void 0),l=(0,N.useRef)(null),{width:u,height:d}=Ys(l);(0,N.useEffect)(()=>{if(!e){i([]),s.current?.scrollToTop();return}i(ic(uc(e.path,e.staged,e.status===`UNTRACKED`))),c.current!==e.path&&(s.current?.scrollToTop(),o(0)),c.current=e.path},[e]);let f=(0,N.useMemo)(()=>Math.max(0,...r.map(e=>e.text.length)),[r]);return Ws((e,t)=>{let n=Math.max(0,f-u);t.upArrow&&s.current?.scrollBy(-1),t.downArrow&&s.current?.scrollBy(1),t.leftArrow&&o(e=>Math.max(0,e-1)),t.rightArrow&&o(e=>Math.min(n,e+1))},{isActive:t}),(0,H.jsxs)(Qo,{flexDirection:`column`,width:n,ref:l,children:[(0,H.jsx)(Qo,{marginLeft:1,children:(0,H.jsx)($o,{bold:!0,color:t?`whiteBright`:`gray`,children:e?e.path:`no file selected`})}),(0,H.jsx)(rc,{borderColor:t?`white`:`gray`,borderStyle:`round`,flexGrow:1,height:d,ref:s,children:r.map((e,t)=>{let n=e.text.slice(a,a+u-2)||` `;return(0,H.jsx)(Qo,{width:`100%`,backgroundColor:pc(e),children:(0,H.jsx)($o,{wrap:`hard`,color:e.kind===`hunk`?`cyan`:`white`,children:n})},t)})})]})}var hc=(0,N.forwardRef)((e,t)=>{let{children:n,selectedIndex:r,scrollAlignment:i=`auto`,onScroll:a,onViewportSizeChange:o,onContentHeightChange:s,onItemHeightChange:c,...l}=e,u=(0,N.useRef)(null),[d,f]=(0,N.useState)(0),p=(0,N.useRef)(0);(0,N.useEffect)(()=>{p.current=d},[d]);let m=(0,N.useCallback)(e=>{e!==p.current&&(f(e),a?.(e))},[a]),h=(0,N.useRef)(r);h.current=r;let g=(0,N.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,N.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,N.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,N.useEffect)(()=>{y!==d&&m(y)},[y,d,m]);let b=(0,N.useCallback)((e,t=i,n)=>{m(v(e,d,t,n))},[v,d,i,m]),x=(0,N.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,N.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,N.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,N.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,H.jsx)(tc,{ref:u,scrollOffset:y,onViewportSizeChange:x,onContentHeightChange:C,onItemHeightChange:S,...l,children:n})});function gc(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 _c(){let[e,t]=(0,N.useState)(()=>gc(lc())),[n,r]=(0,N.useState)(()=>sc());function i(){t(gc(lc())),r(sc())}(0,N.useEffect)(()=>{let e=setInterval(i,2e3);return()=>clearInterval(e)},[]);function a(e){dc(e),i()}function o(e){fc(e),i()}return{files:e,branch:n,stage:a,unstage:o}}const vc={MODIFIED:`ᵐ`,ADDED:`ᵃ`,DELETED:`ᵈ`,RENAMED:`ʳ`,UNTRACKED:`ᵘ`,"-":`⁻`};function yc({width:e,focused:t,onSelectedFile:n}){let{files:r,branch:i,stage:a,unstage:o}=_c(),[s,c]=(0,N.useState)(0);return(0,N.useEffect)(()=>{n(r[s])},[s,r,n]),Ws((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.staged?o(e.path):a(e.path)}},{isActive:t}),(0,H.jsxs)(Qo,{flexDirection:`column`,width:e,children:[(0,H.jsx)(Qo,{marginLeft:1,children:(0,H.jsx)($o,{bold:!0,color:t?`whiteBright`:`gray`,children:i})}),(0,H.jsx)(Qo,{borderColor:t?`white`:`gray`,borderStyle:`round`,flexGrow:1,children:(0,H.jsx)(hc,{height:`100%`,selectedIndex:s,width:`100%`,children:r.map((e,t)=>{let n=e.path.split(`/`),r=n.at(-1)??e.path,i=n.slice(0,-1).join(`/`);return(0,H.jsxs)(Qo,{backgroundColor:t===s?`#222`:void 0,paddingX:1,height:1,children:[(0,H.jsxs)($o,{color:e.staged?`green`:`gray`,children:[e.staged?`●`:`○`,` `]}),(0,H.jsx)(Qo,{flexGrow:1,overflow:`hidden`,children:(0,H.jsxs)($o,{wrap:`hard`,children:[(0,H.jsx)($o,{children:r}),i?(0,H.jsxs)($o,{color:`gray`,children:[` `,i]}):null]})}),(0,H.jsxs)($o,{color:`gray`,children:[` `,vc[e.status]]})]},e.path)})})})]})}function bc(){let e=(0,N.useMemo)(()=>process.cwd().split(`/`).pop(),[]);return(0,H.jsxs)(Qo,{backgroundColor:`green`,paddingX:1,marginBottom:1,justifyContent:`space-between`,children:[(0,H.jsx)($o,{bold:!0,color:`black`,children:`f*ckgit`}),(0,H.jsx)($o,{color:`black`,children:e})]})}function xc(){let{exit:e}=Gs(),{stdout:t}=Ks(),[n,r]=(0,N.useState)(`files`),[i,a]=(0,N.useState)(void 0);return Ws((t,n)=>{(t===`q`||n.ctrl&&t===`c`)&&e(),n.tab&&r(e=>e===`files`?`diff`:`files`)}),(0,H.jsxs)(Qo,{flexDirection:`column`,width:t.columns,height:t.rows,padding:0,children:[(0,H.jsx)(bc,{}),(0,H.jsxs)(Qo,{flexDirection:`row`,flexGrow:1,children:[(0,H.jsx)(yc,{width:`30%`,focused:n===`files`,onSelectedFile:a}),(0,H.jsx)(mc,{file:i,focused:n===`diff`,width:`70%`})]})]})}process.stdout.write(`\x1B[?1049h\x1B[?25l`);const{waitUntilExit:Sc,unmount:Cc}=xs((0,H.jsx)(xc,{}),{exitOnCtrlC:!1});process.on(`SIGINT`,Cc),process.on(`SIGTERM`,Cc),await Sc(),process.stdout.write(`\x1B[?25h\x1B[?1049l`);export{};
381
+ `),n=t.findIndex(e=>e.startsWith(`@@`));return n===-1?[{kind:`context`,text:`(no diff)`}]:t.slice(n).map(e=>e.startsWith(`@@`)?{kind:`hunk`,text:e}:e.startsWith(`+`)?{kind:`add`,text:e.slice(1)}:e.startsWith(`-`)?{kind:`remove`,text:e.slice(1)}:{kind:`context`,text:e.slice(1)})}const ac=f(`git`,[`rev-parse`,`--show-toplevel`],{encoding:`utf8`,stdio:`pipe`}).trimEnd();function oc(...e){return f(`git`,e,{encoding:`utf8`,stdio:`pipe`,cwd:ac}).trimEnd()}function sc(...e){return p(`git`,e,{encoding:`utf8`,cwd:ac}).stdout?.trim()??``}function cc(){try{return oc(`branch`,`--show-current`)}catch{return null}}const lc={M:`MODIFIED`,A:`ADDED`,D:`DELETED`,R:`RENAMED`,"?":`UNTRACKED`};function uc(){try{let e=oc(`status`,`--porcelain`,`--untracked-files=all`);return e?e.split(`
382
+ `).map(e=>{let t=e[0],n=e[1],r=t!==` `&&t!==`?`,i=n===`?`?`?`:r?t:n;return{path:e.slice(3),status:lc[i??``]??`-`,staged:r}}):[]}catch{return[]}}function dc(e,t,n){return n?sc(`diff`,`--no-index`,`/dev/null`,e):t?sc(`diff`,`--cached`,e):sc(`diff`,e)}function fc(e){oc(`add`,e)}function pc(e){try{oc(`restore`,`--staged`,e)}catch{oc(`rm`,`--cached`,`--force`,e)}}function mc(e){if(e.kind===`add`)return`#0d2a0d`;if(e.kind===`remove`)return`#2a0d0d`}function hc({file:e,focused:t,width:n}){let[r,i]=(0,N.useState)([]),[a,o]=(0,N.useState)(0),s=(0,N.useRef)(null),c=(0,N.useRef)(void 0),l=(0,N.useRef)(null),{width:u,height:d}=Ys(l);(0,N.useEffect)(()=>{if(!e){i([]),s.current?.scrollToTop();return}i(ic(dc(e.path,e.staged,e.status===`UNTRACKED`))),c.current!==e.path&&(s.current?.scrollToTop(),o(0)),c.current=e.path},[e]);let f=(0,N.useMemo)(()=>Math.max(0,...r.map(e=>e.text.length)),[r]);return Ws((e,t)=>{let n=Math.max(0,f-u);t.upArrow&&s.current?.scrollBy(-1),t.downArrow&&s.current?.scrollBy(1),t.leftArrow&&o(e=>Math.max(0,e-1)),t.rightArrow&&o(e=>Math.min(n,e+1))},{isActive:t}),(0,H.jsxs)(Qo,{flexDirection:`column`,width:n,ref:l,children:[(0,H.jsx)(Qo,{marginLeft:1,children:(0,H.jsx)($o,{bold:!0,color:t?`whiteBright`:`gray`,wrap:`truncate-middle`,children:e?e.path:`no file selected`})}),(0,H.jsx)(rc,{borderColor:t?`white`:`gray`,borderStyle:`round`,flexGrow:1,height:d,ref:s,children:r.map((e,t)=>{let n=e.text.slice(a,a+u-2)||` `;return(0,H.jsx)(Qo,{width:`100%`,backgroundColor:mc(e),children:(0,H.jsx)($o,{wrap:`hard`,color:e.kind===`hunk`?`cyan`:`white`,children:n})},t)})})]})}var gc=(0,N.forwardRef)((e,t)=>{let{children:n,selectedIndex:r,scrollAlignment:i=`auto`,onScroll:a,onViewportSizeChange:o,onContentHeightChange:s,onItemHeightChange:c,...l}=e,u=(0,N.useRef)(null),[d,f]=(0,N.useState)(0),p=(0,N.useRef)(0);(0,N.useEffect)(()=>{p.current=d},[d]);let m=(0,N.useCallback)(e=>{e!==p.current&&(f(e),a?.(e))},[a]),h=(0,N.useRef)(r);h.current=r;let g=(0,N.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,N.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,N.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,N.useEffect)(()=>{y!==d&&m(y)},[y,d,m]);let b=(0,N.useCallback)((e,t=i,n)=>{m(v(e,d,t,n))},[v,d,i,m]),x=(0,N.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,N.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,N.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,N.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,H.jsx)(tc,{ref:u,scrollOffset:y,onViewportSizeChange:x,onContentHeightChange:C,onItemHeightChange:S,...l,children:n})});function _c(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 vc(){let[e,t]=(0,N.useState)(()=>_c(uc())),[n,r]=(0,N.useState)(()=>cc());function i(){t(_c(uc())),r(cc())}(0,N.useEffect)(()=>{let e=setInterval(i,2e3);return()=>clearInterval(e)},[]);function a(e){fc(e),i()}function o(e){pc(e),i()}return{files:e,branch:n,stage:a,unstage:o}}const yc={MODIFIED:`ᵐ`,ADDED:`ᵃ`,DELETED:`ᵈ`,RENAMED:`ʳ`,UNTRACKED:`ᵘ`,"-":`⁻`};function bc({width:e,focused:t,onSelectedFile:n}){let{files:r,branch:i,stage:a,unstage:o}=vc(),[s,c]=(0,N.useState)(0);return(0,N.useEffect)(()=>{n(r[s])},[s,r,n]),Ws((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.staged?o(e.path):a(e.path)}},{isActive:t}),(0,H.jsxs)(Qo,{flexDirection:`column`,width:e,children:[(0,H.jsx)(Qo,{marginLeft:1,children:(0,H.jsx)($o,{bold:!0,color:t?`whiteBright`:`gray`,children:i})}),(0,H.jsx)(Qo,{borderColor:t?`white`:`gray`,borderStyle:`round`,flexGrow:1,children:(0,H.jsx)(gc,{height:`100%`,selectedIndex:s,width:`100%`,children:r.map((e,t)=>{let n=e.path.split(`/`),r=n.at(-1)??e.path,i=n.slice(0,-1).join(`/`);return(0,H.jsxs)(Qo,{backgroundColor:t===s?`#222`:void 0,paddingX:1,height:1,children:[(0,H.jsxs)($o,{color:e.staged?`green`:`gray`,children:[e.staged?`●`:`○`,` `]}),(0,H.jsx)(Qo,{flexGrow:1,overflow:`hidden`,children:(0,H.jsxs)($o,{wrap:`hard`,children:[(0,H.jsx)($o,{children:r}),i?(0,H.jsxs)($o,{color:`gray`,children:[` `,i]}):null]})}),(0,H.jsxs)($o,{color:`gray`,children:[` `,yc[e.status]]})]},e.path)})})})]})}function xc(){let e=(0,N.useMemo)(()=>process.cwd().split(`/`).pop(),[]);return(0,H.jsxs)(Qo,{backgroundColor:`green`,paddingX:1,marginBottom:1,justifyContent:`space-between`,children:[(0,H.jsx)($o,{bold:!0,color:`black`,children:`f*ckgit`}),(0,H.jsx)($o,{color:`black`,children:e})]})}function Sc(){let{exit:e}=Gs(),{stdout:t}=Ks(),[n,r]=(0,N.useState)(`files`),[i,a]=(0,N.useState)(void 0);return Ws((t,n)=>{(t===`q`||n.ctrl&&t===`c`)&&e(),n.tab&&r(e=>e===`files`?`diff`:`files`)}),(0,H.jsxs)(Qo,{flexDirection:`column`,width:t.columns,height:t.rows,padding:0,children:[(0,H.jsx)(xc,{}),(0,H.jsxs)(Qo,{flexDirection:`row`,flexGrow:1,children:[(0,H.jsx)(bc,{width:`30%`,focused:n===`files`,onSelectedFile:a}),(0,H.jsx)(hc,{file:i,focused:n===`diff`,width:`70%`})]})]})}process.stdout.write(`\x1B[?1049h\x1B[?25l`);const{waitUntilExit:Cc,unmount:wc}=xs((0,H.jsx)(Sc,{}),{exitOnCtrlC:!1});process.on(`SIGINT`,wc),process.on(`SIGTERM`,wc),await Cc(),process.stdout.write(`\x1B[?25h\x1B[?1049l`);export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fckgit",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "A fullscreen TUI Git client",
5
5
  "keywords": [
6
6
  "cli",