fckgit 1.0.3 → 1.1.0

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 +6 -6
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)}})()})),Ys=x(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=qs():t.exports=Js()}))(),Xs=({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}=Ks(a.current);t(n,e)}},[n,t,r,i,e]),(0,Ys.jsx)(Zo,{ref:a,flexShrink:0,width:`100%`,flexDirection:`column`,children:e})};function Zs(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 Qs=(0,N.forwardRef)(({scrollOffset:e,onViewportSizeChange:t,onContentHeightChange:n,onItemHeightChange:r,debug:i=!1,children:a,...o},s)=>{let[c,l,u]=Zs({height:0,width:0}),[d,f,p]=Zs(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}=Ks(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,Ys.jsx)(Zo,{...o,children:(0,Ys.jsx)(Zo,{ref:g,width:`100%`,children:(0,Ys.jsx)(Zo,{overflow:i?void 0:`hidden`,width:`100%`,children:(0,Ys.jsx)(Zo,{ref:_,width:`100%`,flexDirection:`column`,marginTop:-e,children:N.Children.map(a,(e,t)=>e?(0,Ys.jsx)(Xs,{index:t,width:c.width,onMeasure:C,measureKey:m[t],children:e},(0,N.isValidElement)(e)&&e.key||t):null)})})})})});function $s(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 ec=(0,N.forwardRef)(({onScroll:e,onViewportSizeChange:t,onContentHeightChange:n,onItemHeightChange:r,debug:i=!1,children:a,...o},s)=>{let[c,l,u]=$s(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,Ys.jsx)(Qs,{ref:d,scrollOffset:c,onViewportSizeChange:t,onContentHeightChange:p,onItemHeightChange:r,debug:i,children:a,...o})}),tc=(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,Ys.jsx)(Qs,{ref:u,scrollOffset:y,onViewportSizeChange:x,onContentHeightChange:C,onItemHeightChange:S,...l,children:n})});function nc(...e){return f(`git`,e,{encoding:`utf8`,stdio:`pipe`}).trimEnd()}function rc(...e){return p(`git`,e,{encoding:`utf8`}).stdout?.trim()??``}function ic(){try{return nc(`branch`,`--show-current`)}catch{return null}}const ac={M:`MODIFIED`,A:`ADDED`,D:`DELETED`,R:`RENAMED`,"?":`UNTRACKED`};function oc(){try{let e=nc(`status`,`--porcelain`,`--untracked-files=all`);return e?e.split(`
381
- `).map(e=>{let t=e[0],n=e[1],r=t!==` `&&t!==`?`,i=n===`?`?`?`:r?t:n;return{path:e.slice(3),status:ac[i??``]??`-`,staged:r}}):[]}catch{return[]}}function sc(e,t,n){return n?rc(`diff`,`--no-index`,`/dev/null`,e):t?rc(`diff`,`--cached`,e):rc(`diff`,e)}function cc(e){nc(`add`,e)}function lc(e){try{nc(`restore`,`--staged`,e)}catch{nc(`rm`,`--cached`,`--force`,e)}}function uc(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 dc(){let[e,t]=(0,N.useState)(()=>uc(oc()));function n(){t(uc(oc()))}(0,N.useEffect)(()=>{let e=setInterval(n,2e3);return()=>clearInterval(e)},[]);function r(e){cc(e),n()}function i(e){lc(e),n()}return{files:e,stage:r,unstage:i}}function fc({width:e,height:t,focused:n,onSelectedFile:r}){let{files:i,stage:a,unstage:o}=dc(),s=(0,N.useMemo)(()=>process.cwd().split(`/`).pop(),[]),c=(0,N.useMemo)(()=>ic(),[]),[l,u]=(0,N.useState)(0);return(0,N.useEffect)(()=>{r(i[l])},[l,i,r]),Us((e,t)=>{if(t.upArrow&&u(e=>Math.max(0,e-1)),t.downArrow&&u(e=>Math.min(i.length-1,e+1)),e===` `){let e=i[l];if(!e)return;e.staged?o(e.path):a(e.path)}},{isActive:n}),(0,Ys.jsxs)(Zo,{flexDirection:`column`,width:e,height:t,children:[(0,Ys.jsxs)(Qo,{children:[(0,Ys.jsxs)(Qo,{bold:!0,color:n?`whiteBright`:`gray`,children:[`/`,s]}),(0,Ys.jsx)(Qo,{color:`gray`,children:` → `}),(0,Ys.jsx)(Qo,{bold:!0,color:n?`whiteBright`:`gray`,children:c})]}),(0,Ys.jsx)(Zo,{height:1}),(0,Ys.jsx)(tc,{height:t-2,selectedIndex:l,scrollAlignment:`center`,children:i.map((t,n)=>{let r=t.path.split(`/`),i=r.at(-1)??t.path,a=r.slice(0,-1).join(`/`);return(0,Ys.jsxs)(Zo,{width:e,backgroundColor:n===l?`#222`:void 0,children:[(0,Ys.jsxs)(Qo,{dimColor:!0,color:t.staged?`green`:`gray`,children:[t.staged?`●`:`○`,` `]}),(0,Ys.jsxs)(Zo,{flexGrow:1,overflow:`hidden`,children:[(0,Ys.jsx)(Qo,{children:i}),a?(0,Ys.jsxs)(Qo,{color:`gray`,children:[` `,a]}):null]}),(0,Ys.jsxs)(Qo,{color:`gray`,children:[` `,t.status[0].toLowerCase()]})]},t.path)})})]})}function pc(e){if(!e)return[{kind:`context`,text:`(no diff)`}];let t=e.split(`
381
+ `).map(e=>{let t=e[0],n=e[1],r=t!==` `&&t!==`?`,i=n===`?`?`?`:r?t:n;return{path:e.slice(3),status:ac[i??``]??`-`,staged:r}}):[]}catch{return[]}}function sc(e,t,n){return n?rc(`diff`,`--no-index`,`/dev/null`,e):t?rc(`diff`,`--cached`,e):rc(`diff`,e)}function cc(e){nc(`add`,e)}function lc(e){try{nc(`restore`,`--staged`,e)}catch{nc(`rm`,`--cached`,`--force`,e)}}function uc(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 dc(){let[e,t]=(0,N.useState)(()=>uc(oc())),[n,r]=(0,N.useState)(()=>ic());function i(){t(uc(oc())),r(ic())}(0,N.useEffect)(()=>{let e=setInterval(i,2e3);return()=>clearInterval(e)},[]);function a(e){cc(e),i()}function o(e){lc(e),i()}return{files:e,branch:n,stage:a,unstage:o}}function fc({width:e,height:t,focused:n,onSelectedFile:r}){let{files:i,branch:a,stage:o,unstage:s}=dc(),c=(0,N.useMemo)(()=>process.cwd().split(`/`).pop(),[]),[l,u]=(0,N.useState)(0);return(0,N.useEffect)(()=>{r(i[l])},[l,i,r]),Us((e,t)=>{if(t.upArrow&&u(e=>Math.max(0,e-1)),t.downArrow&&u(e=>Math.min(i.length-1,e+1)),e===` `){let e=i[l];if(!e)return;e.staged?s(e.path):o(e.path)}},{isActive:n}),(0,Ys.jsxs)(Zo,{flexDirection:`column`,width:e,height:t,children:[(0,Ys.jsxs)(Qo,{children:[(0,Ys.jsxs)(Qo,{bold:!0,color:n?`whiteBright`:`gray`,children:[`/`,c]}),(0,Ys.jsx)(Qo,{color:`gray`,children:` → `}),(0,Ys.jsx)(Qo,{bold:!0,color:n?`whiteBright`:`gray`,children:a})]}),(0,Ys.jsx)(Zo,{height:1}),(0,Ys.jsx)(tc,{height:t-2,selectedIndex:l,scrollAlignment:`center`,children:i.map((t,n)=>{let r=t.path.split(`/`),i=r.at(-1)??t.path,a=r.slice(0,-1).join(`/`);return(0,Ys.jsxs)(Zo,{width:e,backgroundColor:n===l?`#222`:void 0,children:[(0,Ys.jsxs)(Qo,{dimColor:!0,color:t.staged?`green`:`gray`,children:[t.staged?`●`:`○`,` `]}),(0,Ys.jsxs)(Zo,{flexGrow:1,overflow:`hidden`,children:[(0,Ys.jsx)(Qo,{children:i}),a?(0,Ys.jsxs)(Qo,{color:`gray`,children:[` `,a]}):null]}),(0,Ys.jsxs)(Qo,{color:`gray`,children:[` `,t.status[0].toLowerCase()]})]},t.path)})})]})}function pc(e){if(!e)return[{kind:`context`,text:`(no diff)`}];let t=e.split(`
382
382
  `),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 mc(e){if(e.kind===`add`)return`#0d2a0d`;if(e.kind===`remove`)return`#2a0d0d`}function hc({file:e,focused:t,height:n,width:r}){let[i,a]=(0,N.useState)([]),[o,s]=(0,N.useState)(0),c=(0,N.useRef)(null),l=(0,N.useRef)(void 0);(0,N.useEffect)(()=>{if(!e){a([]),c.current?.scrollToTop();return}a(pc(sc(e.path,e.staged,e.status===`UNTRACKED`))),l.current!==e.path&&(c.current?.scrollToTop(),s(0)),l.current=e.path},[e]);let u=(0,N.useMemo)(()=>Math.max(0,...i.map(e=>e.text.length)),[i]);return Us((e,t)=>{let n=Math.max(0,u-r);t.upArrow&&c.current?.scrollBy(-1),t.downArrow&&c.current?.scrollBy(1),t.leftArrow&&s(e=>Math.max(0,e-1)),t.rightArrow&&s(e=>Math.min(n,e+1))},{isActive:t}),(0,Ys.jsxs)(Zo,{flexDirection:`column`,width:r,height:n,overflow:`hidden`,children:[(0,Ys.jsx)(Qo,{bold:!0,color:t?`whiteBright`:`gray`,children:e?e.path:`(no file selected)`}),(0,Ys.jsx)(Zo,{height:1}),(0,Ys.jsx)(ec,{ref:c,height:n-2,width:r,children:i.map((e,t)=>{let n=e.text.slice(o,o+r)||` `;return(0,Ys.jsx)(Zo,{width:`100%`,backgroundColor:mc(e),children:(0,Ys.jsx)(Qo,{color:e.kind===`hunk`?`cyan`:`white`,children:n})},t)})})]})}function gc(){return(0,Ys.jsx)(Qo,{bold:!0,color:`greenBright`,children:`f*ckgit`})}function _c(){let{exit:e}=Ws(),{stdout:t}=Gs(),[n,r]=(0,N.useState)(`files`),[i,a]=(0,N.useState)(void 0);Us((t,n)=>{(t===`q`||n.ctrl&&t===`c`)&&e(),n.tab&&r(e=>e===`files`?`diff`:`files`)});let o=Math.floor(t.columns*.3),s=t.columns-o-2,c=t.rows-2;return(0,Ys.jsxs)(Zo,{flexDirection:`column`,width:t.columns,height:t.rows,padding:0,children:[(0,Ys.jsx)(gc,{}),(0,Ys.jsx)(Zo,{height:1}),(0,Ys.jsxs)(Zo,{flexDirection:`row`,children:[(0,Ys.jsx)(fc,{width:o,height:c,focused:n===`files`,onSelectedFile:a}),(0,Ys.jsx)(Zo,{width:2}),(0,Ys.jsx)(hc,{file:i,focused:n===`diff`,height:c,width:s})]})]})}process.stdout.write(`\x1B[?1049h\x1B[?25l`);const{waitUntilExit:vc,unmount:yc}=bs((0,Ys.jsx)(_c,{}),{exitOnCtrlC:!1});process.on(`SIGINT`,yc),process.on(`SIGTERM`,yc),await vc(),process.stdout.write(`\x1B[?25h\x1B[?1049l`);export{};
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "fckgit",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "A fullscreen TUI Git client",
5
5
  "keywords": [
6
- "git",
7
- "tui",
8
6
  "cli",
9
- "terminal"
7
+ "git",
8
+ "terminal",
9
+ "tui"
10
10
  ],
11
11
  "license": "ISC",
12
12
  "author": "tu4mo",
@@ -14,14 +14,14 @@
14
14
  "type": "git",
15
15
  "url": "https://github.com/tu4mo/fckgit.git"
16
16
  },
17
- "type": "module",
18
- "main": "dist/app.js",
19
17
  "bin": {
20
18
  "fckgit": "dist/app.js"
21
19
  },
22
20
  "files": [
23
21
  "dist"
24
22
  ],
23
+ "type": "module",
24
+ "main": "dist/app.js",
25
25
  "scripts": {
26
26
  "build": "rm -rf dist && rolldown --config rolldown.config.js",
27
27
  "dev": "tsx --watch src/app.tsx",