fckgit 1.2.2 → 1.3.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.
- package/dist/app.js +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})});const ic=s(`git`,[`rev-parse`,`--show-toplevel`],{encoding:`utf8`,stdio:`pipe`}).trimEnd();function ac(...e){return s(`git`,e,{encoding:`utf8`,stdio:`pipe`,cwd:ic}).trimEnd()}function oc(...e){return c(`git`,e,{encoding:`utf8`,cwd:ic}).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(`
|
|
381
|
-
`).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(ic,o)),status:cc[a??``]??`-`,stagedStatus:i}}):[]}catch{return[]}}function uc({path:e,mode:t}){return t===`untracked`?oc(`diff
|
|
382
|
-
`),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 mc(e){if(e.stagedStatus===`PARTIAL`){let
|
|
381
|
+
`).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(ic,o)),status:cc[a??``]??`-`,stagedStatus:i}}):[]}catch{return[]}}function uc({path:e,mode:t,contextLines:n=3}){let r=`-U${n}`;return t===`untracked`?oc(`diff`,r,`--no-index`,`/dev/null`,e):t===`staged`?oc(`diff`,r,`--cached`,e):oc(`diff`,r,e)}function dc(e){ac(`add`,e)}function fc(e){try{ac(`restore`,`--staged`,e)}catch{ac(`rm`,`--cached`,`--force`,e)}}function pc({raw:e,staged:t}){if(!e)return[];let n=e.split(`
|
|
382
|
+
`),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 mc(e,t=3){if(e.stagedStatus===`PARTIAL`){let n=n=>pc({raw:uc({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 pc({raw:uc({path:e.path,mode:r,contextLines:t}),staged:n})}function hc({children:e,watchValue:t,duration:n=1e3}){let[r,i]=(0,N.useState)(!1),a=(0,N.useRef)(null),o=(0,N.useRef)(!0);return(0,N.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 gc(e){if(e.kind===`add`)return`#052e16`;if(e.kind===`remove`)return`#450a0a`}function _c({file:e,focused:t,width:n}){let[r,i]=(0,N.useState)([]),[a,o]=(0,N.useState)(0),[s,c]=(0,N.useState)(3),l=(0,N.useRef)(null),u=(0,N.useRef)(void 0),d=(0,N.useRef)(null),{width:f,height:p}=Ys(d);(0,N.useEffect)(()=>{if(!e){i([]),l.current?.scrollToTop();return}i(mc(e,s)),u.current!==e.path&&(l.current?.scrollToTop(),o(0),c(3)),u.current=e.path},[e,s]);let m=(0,N.useMemo)(()=>Math.max(0,...r.map(e=>e.text.length)),[r]);return Ws((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,H.jsxs)(Qo,{flexDirection:`column`,width:n,ref:d,children:[(0,H.jsxs)(Qo,{marginX:1,gap:1,justifyContent:`space-between`,children:[(0,H.jsx)($o,{bold:!0,color:t?`whiteBright`:`gray`,wrap:`truncate-middle`,children:e?e.displayPath:`no file selected`}),(0,H.jsx)(hc,{watchValue:s,children:(0,H.jsxs)($o,{color:`gray`,children:[s,` lines`]})})]}),(0,H.jsx)(rc,{borderColor:t?`white`:`gray`,borderStyle:`round`,flexGrow:1,height:p,ref:l,children:r.map((e,t)=>{if(e.kind===`separator`)return(0,H.jsx)(Qo,{width:`100%`,backgroundColor:`#222`,justifyContent:`center`,children:(0,H.jsx)($o,{color:`#555`,children:e.text})},t);let n=e.text.slice(a,a+f-2)||` `;return(0,H.jsx)(Qo,{width:`100%`,backgroundColor:gc(e),children:(0,H.jsx)($o,{wrap:`hard`,color:`white`,children:n})},t)})})]})}var vc=(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 yc(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 bc(){let[e,t]=(0,N.useState)(()=>yc(lc())),[n,r]=(0,N.useState)(()=>sc());function i(){t(yc(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 xc={NONE:`gray`,PARTIAL:`yellow`,FULL:`green`},Sc={MODIFIED:{symbol:`ᵐ`,color:`yellow`},ADDED:{symbol:`ᵃ`,color:`green`},DELETED:{symbol:`ᵈ`,color:`red`},RENAMED:{symbol:`ʳ`,color:`cyan`},UNTRACKED:{symbol:`ᵘ`,color:`gray`},"-":{symbol:`⁻`,color:`gray`}};function Cc({width:e,focused:t,onSelectedFile:n}){let{files:r,branch:i,stage:a,unstage:o}=bc(),[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.stagedStatus===`FULL`?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)(vc,{height:`100%`,selectedIndex:s,width:`100%`,children:r.map((e,t)=>{let n=p.basename(e.displayPath),r=p.dirname(e.displayPath)===`.`?``:p.dirname(e.displayPath);return(0,H.jsxs)(Qo,{backgroundColor:t===s?`#222`:void 0,paddingX:1,height:1,children:[(0,H.jsxs)($o,{color:xc[e.stagedStatus],children:[e.stagedStatus===`NONE`?`○`:`●`,` `]}),(0,H.jsx)(Qo,{flexGrow:1,overflow:`hidden`,children:(0,H.jsxs)($o,{wrap:`hard`,children:[(0,H.jsx)($o,{children:n}),r?(0,H.jsxs)($o,{color:`gray`,children:[` `,r]}):null]})}),(0,H.jsx)(Qo,{flexShrink:0,marginLeft:1,children:(0,H.jsx)($o,{color:Sc[e.status].color,children:Sc[e.status].symbol})})]},e.path)})})})]})}const wc={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 Tc({focusedPane:e}){return(0,H.jsx)(Qo,{gap:2,paddingX:1,height:1,overflow:`hidden`,children:wc[e].map(({key:e,label:t})=>(0,H.jsxs)(Qo,{gap:1,flexShrink:0,children:[(0,H.jsx)($o,{bold:!0,color:`white`,children:e}),(0,H.jsx)($o,{color:`gray`,children:t})]},e))})}function U(){let e=(0,N.useMemo)(()=>process.cwd().split(`/`).pop(),[]);return(0,H.jsxs)(Qo,{backgroundColor:`green`,paddingX:1,justifyContent:`space-between`,marginBottom:1,children:[(0,H.jsx)($o,{bold:!0,color:`black`,children:`f*ckgit`}),(0,H.jsx)($o,{color:`black`,children:e})]})}function Ec(){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,children:[(0,H.jsx)(U,{}),(0,H.jsxs)(Qo,{flexDirection:`row`,flexGrow:1,children:[(0,H.jsx)(Cc,{width:`30%`,focused:n===`files`,onSelectedFile:a}),(0,H.jsx)(_c,{file:i,focused:n===`diff`,width:`70%`})]}),(0,H.jsx)(Tc,{focusedPane:n})]})}xs((0,H.jsx)(Ec,{}),{alternateScreen:!0});export{};
|