@p4code/cli 0.2.15 → 0.2.17
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/bin.mjs +112 -21
- package/dist/client/assets/{DiffPanel-CS8LWBsp.js → DiffPanel-4_108eR0.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-Detgmcd-.js → FilePreviewPanel-9vOdvTvQ.js} +2 -2
- package/dist/client/assets/{PreviewPanel-C94P3oPz.js → PreviewPanel-CXgirZ3z.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-q9KPgGC-.js → PullRequestCodeTab-CNPFlQyk.js} +2 -2
- package/dist/client/assets/arrow-right-DSU5D6Bb.js +2 -0
- package/dist/client/assets/{fileCommentAnnotations-Dh8Om-Nh.js → fileCommentAnnotations-DmPfXSsw.js} +2 -2
- package/dist/client/assets/{index-BPZitrC3.js → index-BBTuAu9J.js} +251 -234
- package/dist/client/assets/index-BlFyp86j.css +1 -0
- package/dist/client/assets/previewAssetResource-bmHagfYU.js +47 -0
- package/dist/client/assets/{renderFileChildren-fTTWkGkN.js → renderFileChildren-o__qQL5P.js} +2 -2
- package/dist/client/assets/{toggle-group-BZtpL0SP.js → toggle-group-B_Cx35Ek.js} +2 -2
- package/dist/client/index.html +3 -3
- package/package.json +1 -1
- package/dist/client/assets/arrow-right-C_Eu_J71.js +0 -2
- package/dist/client/assets/index-Dd_1sMU1.css +0 -1
- package/dist/client/assets/previewAssetResource-BEwdA2I3.js +0 -47
package/dist/client/assets/{PullRequestCodeTab-q9KPgGC-.js → PullRequestCodeTab-CNPFlQyk.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{Ac as i,Cc as a,Dc as o,Mc as s,Q as c,Sc as l,Z as u,Zi as d,aa as f,b as p,br as m,ct as ee,dl as h,ea as te,et as g,ia as _,jc as v,kc as y,ma as b,pa as x,q as S,qc as C,sr as w,tt as T,v as E}from"./previewAssetResource-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{Ac as i,Cc as a,Dc as o,Mc as s,Q as c,Sc as l,Z as u,Zi as d,aa as f,b as p,br as m,ct as ee,dl as h,ea as te,et as g,ia as _,jc as v,kc as y,ma as b,pa as x,q as S,qc as C,sr as w,tt as T,v as E}from"./previewAssetResource-bmHagfYU.js";import{a as D,n as O,o as k,r as A,s as j,t as M}from"./toggle-group-B_Cx35Ek.js";import{B as N,Fr as ne,G as re,Gr as ie,H as ae,Ir as oe,J as se,K as ce,Lr as le,Qr as ue,Rr as de,U as fe,V as pe,W as me,X as P,Xr as he,Yr as ge,_ as _e,ai as ve,ct as ye,ir as be,it as xe,lt as F,nr as Se,nt as Ce,oi as we,ot as Te,q as Ee,rr as De,rt as Oe,si as ke,st as Ae,ut as je,xr as I}from"./index-BBTuAu9J.js";var Me=s(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ne=s(`message-square-off`,[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]),L=e(n(),1),Pe=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),Fe=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),R=new Set([`__tests__`,`tests`,`test`]),Ie=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function Le(e){let t=e.split(`/`),n=t.at(-1)??``;return Pe.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>Fe.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>R.has(e))?`test`:`source`}function Re(e){let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(0,t):e}function ze(e){return Re(e.split(`/`).at(-1)??``)}function Be(e,t){let n=e.split(`/`).slice(0,-1);for(let e of t.split(`/`))e===`.`||e===``||(e===`..`?n.pop():n.push(e));return n.join(`/`)}var Ve=/(?:\bfrom|\bimport|\brequire\s*\()\s*\(?\s*["']([^"']+)["']/g;function He(e,t,n,r){let i=new Set;for(let a of t){Ve.lastIndex=0;let t=Ve.exec(a);for(;t!==null;){let o=t[1]??``,s=o.startsWith(`.`)?Be(e,o):o,c=Ie.find(e=>s.endsWith(e)),l=c===void 0?s:s.slice(0,-c.length),u=n.get(l)??n.get(`${l}/index`)??r.get(ze(l));u!==void 0&&u!==e&&i.add(u),t=Ve.exec(a)}}return i}function Ue(e,t){let n=new Set(e),r=[],i=[...e].sort((e,t)=>e.localeCompare(t));for(;n.size>0;){let e=i.filter(e=>n.has(e)),a=e.find(e=>[...t.get(e)??[]].every(e=>!n.has(e)))??e[0];n.delete(a),r.push(a)}return r}function z(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function We(e){let t=new Map;for(let n of e)t.set(F(n),n);let n=new Map;for(let e of t.keys())n.set(e,Le(e));let r=[...t.keys()].filter(e=>n.get(e)===`source`),i=new Map,a=new Set,o=new Map;for(let e of r){i.set(Re(e),e);let t=ze(e);o.has(t)&&a.add(t),o.set(t,e)}for(let e of a)o.delete(e);let s=new Map;for(let e of r){let n=t.get(e);s.set(e,He(e,[...n.additionLines,...n.deletionLines],i,o))}let c=Ue(r,s),l=new Map;c.forEach((e,t)=>{let n=ze(e);l.has(n)||l.set(n,t)});let u=[...t.keys()].filter(e=>n.get(e)===`test`).sort((e,t)=>(l.get(z(e))??2**53-1)-(l.get(z(t))??2**53-1)||e.localeCompare(t)),d=[...t.keys()].filter(e=>n.get(e)===`generated`).sort((e,t)=>e.localeCompare(t));return[...c,...u,...d].map(e=>t.get(e))}function Ge(e,t){return async n=>{let r=F(n),i=n.prevName?F({...n,name:n.prevName}):r,a=await e({changeType:n.type,oldPath:i,newPath:r}),o={name:r,contents:a.newContents,cacheKey:`${t}:new:${r}`};return n.type===`rename-pure`?{oldFile:null,newFile:o}:{oldFile:{name:i,contents:a.oldContents,cacheKey:`${t}:old:${i}`},newFile:o}}}function Ke(e,t){return Ge(async({changeType:n,oldPath:r,newPath:i})=>{let a=await e({environmentId:t.environmentId,input:{...t.reference,...t.commit===null?{}:{commit:t.commit},changeType:n,oldPath:r,newPath:i}});if(a._tag!==`Success`)throw h(a);return a.value},t.cacheKey)}var B=r();function V(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var H=t();function qe(e){let t=(0,B.c)(43),{kind:n,rangeLabel:r,text:i,onTextChange:a,onCancel:o,onComment:s,onDelete:c,placeholder:l,submitLabel:u,pending:f,secondaryAction:p}=e,m=l===void 0?`Add a comment…`:l,ee=u===void 0?`Comment`:u,h=f===void 0?!1:f,[te,g]=(0,L.useState)(``),_=n===`draft`&&!a?te:i,v;t[0]===_?v=t[1]:(v=_.trim(),t[0]=_,t[1]=v);let y=v;if(n===`comment`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(he,{className:`mt-0.5 size-3.5 shrink-0 text-primary/70`,"aria-hidden":`true`}),t[2]=e):e=t[2];let n;t[3]===_?n=t[4]:(n=(0,H.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5`,children:_}),t[3]=_,t[4]=n);let r;t[5]===c?r=t[6]:(r=c?(0,H.jsx)(d,{className:`-my-1 -mr-1 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/comment:opacity-100 focus-visible:opacity-100 max-sm:opacity-100`,variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:c,children:(0,H.jsx)(oe,{className:`size-3`})}):null,t[5]=c,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,H.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`group/comment flex min-w-0 items-start gap-2.5 border-s-2 border-primary/55 bg-primary/[0.045] px-3 py-2.5 font-sans text-foreground`,contentEditable:!1,onPointerDown:G,children:[e,n,r]}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}let b=`Comment on lines ${r}`,x;t[10]===a?x=t[11]:(x=e=>(a??g)(e.target.value),t[10]=a,t[11]=x);let S;t[12]!==o||t[13]!==s||t[14]!==h||t[15]!==y?(S=e=>{e.key===`Escape`&&(e.preventDefault(),o()),V(e,y,h)&&(e.preventDefault(),s(y))},t[12]=o,t[13]=s,t[14]=h,t[15]=y,t[16]=S):S=t[16];let C;t[17]!==_||t[18]!==m||t[19]!==b||t[20]!==x||t[21]!==S?(C=(0,H.jsx)(E,{autoFocus:!0,unstyled:!0,className:`relative inline-flex w-full rounded-md border border-border/50 bg-background/20 font-sans text-foreground transition-colors focus-within:border-border/70 [&_[data-slot=textarea]]:min-h-12 [&_[data-slot=textarea]]:cursor-text [&_[data-slot=textarea]]:px-2.5 [&_[data-slot=textarea]]:py-1.5 [&_[data-slot=textarea]]:font-sans [&_[data-slot=textarea]]:text-xs [&_[data-slot=textarea]]:leading-5 max-sm:[&_[data-slot=textarea]]:min-h-12`,size:`sm`,value:_,placeholder:m,"aria-label":b,onChange:x,onFocus:U,onKeyDown:S}),t[17]=_,t[18]=m,t[19]=b,t[20]=x,t[21]=S,t[22]=C):C=t[22];let w;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,H.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground/70`,children:`⌘/Ctrl Enter to send`}),t[23]=w):w=t[23];let T;t[24]===o?T=t[25]:(T=(0,H.jsx)(d,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:o,children:`Cancel`}),t[24]=o,t[25]=T);let D;t[26]!==p||t[27]!==y?(D=p?(0,H.jsxs)(d,{size:`xs`,variant:`outline`,disabled:!p.allowEmpty&&!y,onClick:()=>p.onAction(y),children:[p.icon,p.label]}):null,t[26]=p,t[27]=y,t[28]=D):D=t[28];let O=h||!y,k;t[29]!==s||t[30]!==y?(k=()=>s(y),t[29]=s,t[30]=y,t[31]=k):k=t[31];let A;t[32]!==ee||t[33]!==O||t[34]!==k?(A=(0,H.jsx)(d,{size:`xs`,disabled:O,onClick:k,children:ee}),t[32]=ee,t[33]=O,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==T||t[37]!==D||t[38]!==A?(j=(0,H.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1`,children:[w,T,D,A]}),t[36]=T,t[37]=D,t[38]=A,t[39]=j):j=t[39];let M;return t[40]!==j||t[41]!==C?(M=(0,H.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:W,children:[C,j]}),t[40]=j,t[41]=C,t[42]=M):M=t[42],M}function U(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function W(e){return e.stopPropagation()}function G(e){return e.stopPropagation()}var K=`${Ce}
|
|
2
2
|
:is(
|
|
3
3
|
[data-line],
|
|
4
4
|
[data-line-annotation],
|
|
@@ -248,4 +248,4 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
|
|
|
248
248
|
[data-diffs-header] [data-deletions-count] {
|
|
249
249
|
display: none !important;
|
|
250
250
|
}`,mt=[];function ht(e){return e===`left`?`deletions`:`additions`}function gt(e){return e===`deletions`?`left`:`right`}function X({environmentId:e,reference:t,detail:n,selectedCommitOid:r,onSelectedCommitChange:o,pendingFinding:s,fixFindingLabel:m=`Fix in a thread`,onFixFinding:h,onAskAboutSelection:v,onRefresh:E,refreshToken:D=0}){let{resolvedTheme:N}=p(),re=ne(),[ie,ae]=(0,L.useState)(()=>new Set),[oe,ue]=(0,L.useState)(ft),[pe,he]=(0,L.useState)(null),[ve,Ce]=(0,L.useState)(`stacked`),[I,Me]=(0,L.useState)(re.wordWrap),[Pe,Fe]=(0,L.useState)(null),[R,Ie]=(0,L.useState)(null),[Le,Re]=(0,L.useState)(!1),[ze,Be]=(0,L.useState)(!1),[Ve,He]=(0,L.useState)(!1),[Ue,z]=(0,L.useState)({key:``,cursor:null,slices:mt}),Ge=(0,L.useRef)(new Map),B=tt(t),V=r,U=V===null?B:`${B}@${V}`;(0,L.useEffect)(()=>{Ie(null),Fe(null),ae(new Set),he(null),ue(ft),Be(!1),z({key:U,cursor:null,slices:mt}),Ge.current.clear()},[U]);let W=Ue.key===U?Ue.slices:mt,G=Ue.key===U?Ue.cursor:null,K=ee(P.diff({environmentId:e,input:{...t,...G===null?{}:{cursor:G},...V===null?{}:{commit:V}}}));(0,L.useEffect)(()=>{let e=K.data;e!==null&&z(t=>{let n=t.key===U?t.slices:mt,r={cursor:G,patch:e.patch,truncated:e.truncated,nextCursor:e.nextCursor,omittedFileStats:e.omittedFileStats??[]},i=n.findIndex(e=>e.cursor===G);if(i===-1)return{key:U,cursor:G,slices:[...n,r]};let a=n[i];return a!==void 0&&a.patch===r.patch&&a.truncated===r.truncated&&a.nextCursor===r.nextCursor&&a.omittedFileStats.length===r.omittedFileStats.length&&a.omittedFileStats.every((e,t)=>{let n=r.omittedFileStats[t];return n!==void 0&&n.path===e.path&&n.additions===e.additions&&n.deletions===e.deletions})?t:{key:U,cursor:G,slices:[...n.slice(0,i),r]}})},[G,K.data,U]);let Ye=C(P.diff({environmentId:e,input:{...t,...V===null?{}:{commit:V}}})),Xe=(0,L.useRef)(D);(0,L.useEffect)(()=>{Xe.current!==D&&(Xe.current=D,z({key:U,cursor:null,slices:mt}),Ye())},[D,U,Ye]);let Qe=B,q=nt(t),J=Y(e=>e.addComment),rt=Y(e=>e.removeComment),at=T(P.replyToThread,{reportFailure:!1}),ot=T(P.setThreadResolution,{reportFailure:!1}),st=T(P.updateComment,{reportFailure:!1}),ct=T(P.diffFileContents),lt=(0,L.useMemo)(()=>Ke(ct,{environmentId:e,reference:t,commit:V,cacheKey:`pull-request:${B}:${n.updatedAt}:${V??`all`}`}),[V,n.updatedAt,e,ct,t,B]),X=(0,L.useMemo)(()=>{let e=n.capabilities.review,t=n.viewerPermissions;return{inlineComment:e.inlineComment&&t.comment,reply:e.reply&&t.comment,resolve:e.resolve&&t.resolve,verdicts:e.verdicts.filter(e=>t.verdicts.includes(e))}},[n.capabilities.review,n.viewerPermissions]),_t=X.inlineComment&&V===null,vt=(0,L.useMemo)(()=>W.map(e=>{let t=`pull-request:${U}:${N}:${e.cursor??`first`}:${xe(e.patch)}`,n=Ge.current.get(t);if(n)return n;let r=Ae(e.patch,t,{compactPartialHunkOffsets:!0});return r&&Ge.current.set(t,r),r}),[W,N,U]),Z=(0,L.useMemo)(()=>vt.flatMap(e=>e?.kind===`files`?We(e.files):[]),[vt]),Q=W.at(-1)?.nextCursor??null,yt=W.some(e=>e.truncated)||vt.some(e=>e?.kind===`raw`),bt=(0,L.useMemo)(()=>{let e=new Set;if(V!==null)return e;for(let t of Z){let r=F(t);for(let i of n.reviewThreads)i.path===r&&i.line!==null&&ut(t,i.side,i.line)&&e.add(i.id)}return e},[V,n.reviewThreads,Z]),$=(0,L.useMemo)(()=>Z.map(e=>{let t=Oe(e),r=F(e),i=new Map,a=(e,t)=>{let n=`${e}:${t}`,r=i.get(n);if(r)return r;let a={side:e,line:t,threads:[],pending:[],draft:!1};return i.set(n,a),a};for(let e of n.reviewThreads)e.path!==r||e.line===null||bt.has(e.id)&&a(e.side,e.line).threads.push(e);if(V===null)for(let e of q)e.path===r&&a(e.side,e.line).pending.push(e);R?.fileKey===t&&(a(R.side,R.line).draft=!0);let o=dt(t,pe,ie),s=[...i.values()].map(e=>({side:ht(e.side),lineNumber:e.line,metadata:{threads:e.threads,pending:e.pending,draft:e.draft}}));return{id:t,type:`diff`,fileDiff:e,annotations:s,collapsed:o,version:xe(`${o?`1`:`0`}:${s.map(({side:e,lineNumber:t,metadata:n})=>`${e}:${t}:${n.draft?`d`:``}:${n.pending.map(e=>`${e.id}:${e.body}`).join(`,`)}:${n.threads.map(e=>`${e.id}:${e.isResolved?`r`:``}:${e.isOutdated?`o`:``}:${e.comments.map(e=>`${e.id}:${e.author?.login??``}:${e.createdAt}:${e.body}:${(e.reactions??[]).map(e=>`${e.content}:${e.count}:${e.viewerHasReacted?`v`:``}`).join(`,`)}`).join(`;`)}`).join(`,`)}`).join(`|`)}`)}}),[V,n.reviewThreads,R,Z,pe,q,bt,ie]),xt=(0,L.useMemo)(()=>Te(Z),[Z]),St=(0,L.useMemo)(()=>new Map(W.flatMap(e=>e.omittedFileStats.map(e=>[e.path,e]))),[W]),Ct=(0,L.useMemo)(()=>$.map(e=>e.id),[$]),wt=(0,L.useMemo)(()=>new Set($.filter(e=>e.collapsed===!0).map(e=>e.id)),[$]),Tt=A(Ct,wt),[Et,Dt]=(0,L.useState)(null);(0,L.useEffect)(()=>{if(Et===null||Q===null||Q===G||K.isPending||K.error!==null)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&z(e=>({...e,cursor:Q}))},{rootMargin:`240px`});return e.observe(Et),()=>e.disconnect()},[G,K.error,K.isPending,Q,Et]);let Ot=(0,L.useCallback)(e=>ae(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),kt=()=>{he(A(Ct,wt)?`expanded`:`folded`),ae(new Set)},At=(0,L.useMemo)(()=>n.commits.toSorted((e,t)=>Date.parse(t.committedDate)-Date.parse(e.committedDate)),[n.commits]),jt=(0,L.useCallback)((e,t)=>{if(!e||!_t)return;let n=t.item;if(n.type!==`diff`)return;let r=Z.find(e=>Oe(e)===n.id);if(!r)return;let i=F(r),a=je(r);Ie({fileKey:n.id,path:i,oldPath:a===i?null:a,line:e.end,side:gt(e.endSide??e.side),range:e})},[_t,Z]),Mt=(0,L.useCallback)((e,t)=>{let r=Z.find(t=>Oe(t)===e.fileKey),i=r===void 0?null:w({id:`pull-request-selection:${e.fileKey}:${e.range.start}:${e.range.end}`,sectionId:`pull-request:${n.number}`,sectionTitle:`PR #${n.number} review`,filePath:e.path,fileDiff:r,range:e.range,text:t});Ie(null),Fe(null),!(i===null||!v)&&v({comment:i,question:t})},[n.number,Z,v]),Nt=(0,L.useCallback)(()=>Q===null?null:(0,H.jsx)(`div`,{ref:Dt,className:`flex items-center justify-center gap-2 py-2 text-xs text-muted-foreground`,children:K.error===null?K.isPending?`Loading more files...`:null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`The rest of this diff could not be loaded.`}),(0,H.jsx)(d,{size:`xs`,variant:`outline`,onClick:()=>K.refresh(),children:`Retry`})]})}),[Q,K.error,K.isPending,K.refresh]),Pt=(0,L.useCallback)(e=>{let t=e.collapsed===!0;return(0,H.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand diff`:`Collapse diff`,className:b(`mr-1 inline-flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground`),onClick:t=>{t.stopPropagation(),Ot(e.id)},children:t?(0,H.jsx)(y,{className:`size-4`}):(0,H.jsx)(i,{className:`size-4`})})},[Ot]),Ft=(0,L.useCallback)(e=>{if(e.type!==`diff`)return null;let t=0,n=0;for(let r of e.fileDiff.hunks)t+=r.additionLines,n+=r.deletionLines;if(t===0&&n===0){let r=St.get(F(e.fileDiff));r&&({additions:t,deletions:n}=r)}return(0,H.jsx)(ce,{additions:t,deletions:n,className:`font-mono text-[11px]`})},[St]),It=(0,L.useMemo)(()=>({diffStyle:ve===`split`?`split`:`unified`,lineDiffType:`none`,overflow:I?`wrap`:`scroll`,theme:ye(N),themeType:N,stickyHeaders:!0,loadDiffFiles:lt,enableGutterUtility:_t&&R===null,enableLineSelection:_t&&R===null,onGutterUtilityClick:jt,onLineSelectionEnd:jt}),[ve,I,N,lt,_t,R,jt]),Lt=(0,L.useCallback)(async(e,t)=>{if(Le)return!1;Re(!0);let n=await t();return Re(!1),n._tag===`Failure`?(S.add({type:`error`,title:e}),!1):(E(),!0)},[E,Le]),Rt=(0,L.useCallback)(r=>(0,H.jsx)($e,{thread:r,workspaceRoot:n.workspaceRoot,canReply:X.reply,canResolve:X.resolve,canReact:n.capabilities.reactions===!0,environmentId:e,reference:t,pending:Le,fixPending:s===me({kind:`thread`,thread:r}),fixLabel:m,...h?{onFix:()=>h({kind:`thread`,thread:r})}:{},onReply:n=>Lt(`Reply could not be posted`,()=>at({environmentId:e,input:{...t,threadId:r.id,body:n}})),canEditComment:e=>fe(n,{author:e.author,kind:`review-comment`}),onEditComment:(n,r)=>Lt(`The comment could not be saved`,()=>st({environmentId:e,input:{...t,commentId:n,kind:`review-comment`,body:r}})),onToggleResolved:()=>void Lt(`The conversation could not be updated`,()=>ot({environmentId:e,input:{...t,threadId:r.id,resolved:!r.isResolved}})),onReacted:E},`${t.projectId}#${t.number}:${r.id}`),[n,e,m,E,h,s,t,at,X.reply,X.resolve,Lt,ot,Le,st]),zt=(0,L.useCallback)(e=>(0,H.jsxs)(`div`,{className:`py-1 font-sans text-foreground`,children:[e.metadata.threads.map(Rt),e.metadata.pending.map(e=>(0,H.jsx)(Ze,{comment:e,onRemove:()=>rt(Qe,e.id)},e.id)),e.metadata.draft&&R?(0,H.jsx)(qe,{kind:`draft`,rangeLabel:`${R.path}:${R.line}`,text:``,submitLabel:`Add to review`,...v?{secondaryAction:{label:`Ask`,icon:(0,H.jsx)(de,{className:`size-3`}),allowEmpty:!0,onAction:e=>Mt(R,e)}}:{},onCancel:()=>{Ie(null),Fe(null)},onComment:e=>{J(Qe,{id:et(),path:R.path,...R.oldPath===null?{}:{oldPath:R.oldPath},line:R.line,side:R.side,body:e}),Ie(null),Fe(null)}}):null]}),[J,Mt,R,v,rt,Rt,Qe]),Bt=X.verdicts.length===0?null:(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:Ve?(0,H.jsxs)(`div`,{className:`chat-composer-glass pointer-events-auto absolute inset-x-3 bottom-3 rounded-xl border border-border/60 shadow-lg`,children:[(0,H.jsx)(d,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close review`,className:`absolute right-2 top-2`,onClick:()=>He(!1),children:(0,H.jsx)(l,{className:`size-3.5`})}),(0,H.jsx)(it,{environmentId:e,reference:t,verdicts:X.verdicts,onSubmitted:()=>{E(),He(!1)}})]}):(0,H.jsxs)(`button`,{type:`button`,className:`chat-composer-glass pointer-events-auto absolute bottom-3 right-4 flex items-center gap-1.5 rounded-full border border-border/60 px-3 py-1.5 text-xs font-medium shadow-lg`,onClick:()=>He(!0),children:[(0,H.jsx)(ge,{className:`size-3.5`}),`Review`,q.length>0?(0,H.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground`,children:q.length}):null]})}),Vt=At.find(e=>e.oid===V);(0,L.useEffect)(()=>{V!==null&&Vt===void 0&&o(null)},[V,o,Vt]);let Ht=Vt?Vt.messageHeadline:`All commits`,Ut=(0,H.jsxs)(`div`,{className:`surface-subheader justify-between gap-2 px-4 text-xs text-muted-foreground`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[At.length>0?(0,H.jsxs)(te,{children:[(0,H.jsxs)(x,{className:`inline-flex h-6 max-w-64 items-center gap-1 rounded-md bg-accent px-2 text-xs font-medium text-accent-foreground outline-none transition-colors hover:bg-accent/80 focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${Ht}`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:Ht}),(0,H.jsx)(i,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,H.jsxs)(f,{align:`start`,className:`w-80`,children:[(0,H.jsx)(_,{className:V===null?`bg-foreground/[0.08]`:void 0,onClick:()=>o(null),children:(0,H.jsx)(`span`,{children:`All commits`})}),At.slice(0,oe).map(e=>(0,H.jsxs)(_,{className:e.oid===V?`bg-foreground/[0.08]`:void 0,onClick:()=>o(e.oid),children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,title:e.messageHeadline,children:e.messageHeadline}),(0,H.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-xs text-muted-foreground`,children:e.oid.slice(0,7)})]},e.oid)),At.length>oe?(0,H.jsx)(_,{closeOnClick:!1,onClick:()=>ue(e=>e+ft),children:(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Show more (`,At.length-oe,` left)`]})}):null]})]}):null,(0,H.jsxs)(Ee,{children:[(0,H.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[Z.length,` `,Z.length===1?`file`:`files`,Q===null?``:`+`]}),yt?(0,H.jsxs)(u,{children:[(0,H.jsx)(g,{render:(0,H.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,H.jsx)(a,{"aria-label":`Some of this diff was not shown`,className:`size-3.5 text-amber-600 dark:text-amber-500`})}),(0,H.jsx)(c,{side:`bottom`,children:`The host withheld part of this diff — a binary file, or a change too large to inline.`})]}):null,V!==null&&X.inlineComment?(0,H.jsxs)(u,{children:[(0,H.jsx)(g,{render:(0,H.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,H.jsx)(Ne,{"aria-label":`Line comments are written from the whole change`,className:`size-3.5`})}),(0,H.jsx)(c,{side:`bottom`,children:`A comment is anchored to the whole change, so switch to All commits to write one.`})]}):null]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(ce,{additions:xt.additions,deletions:xt.deletions,className:`mr-1`}),Ct.length>0?(0,H.jsxs)(u,{children:[(0,H.jsx)(g,{render:(0,H.jsx)(d,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":Tt?`Expand all files`:`Collapse all files`,onClick:kt}),children:Tt?(0,H.jsx)(we,{className:`size-3.5`}):(0,H.jsx)(ke,{className:`size-3.5`})}),(0,H.jsx)(c,{side:`top`,children:Tt?`Expand all files`:`Collapse all files`})]}):null,(0,H.jsxs)(O,{className:`shrink-0 gap-1`,size:`sm`,value:[ve],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&Ce(t)},children:[(0,H.jsx)(M,{"aria-label":`Stacked diff view`,value:`stacked`,variant:`ghost`,children:(0,H.jsx)(k,{className:`size-3.5`})}),(0,H.jsx)(M,{"aria-label":`Split diff view`,value:`split`,variant:`ghost`,children:(0,H.jsx)(j,{className:`size-3.5`})})]}),(0,H.jsxs)(u,{children:[(0,H.jsx)(g,{render:(0,H.jsx)(M,{"aria-label":I?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`ghost`,size:`sm`,pressed:I,onPressedChange:e=>{Me(!!e)}}),children:(0,H.jsx)(le,{className:`size-3.5`})}),(0,H.jsx)(c,{side:`top`,children:I?`Disable line wrapping`:`Enable line wrapping`})]})]})]}),Wt=e=>(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ut,(0,H.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`h-full overflow-auto`,children:e}),Bt]})]});if(K.isPending&&W.length===0)return Wt((0,H.jsx)(se,{label:`Loading pull request diff...`}));if(K.error&&W.length===0)return Wt((0,H.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:K.error}));let Gt=Q===null?vt.flatMap(e=>e?.kind===`raw`?[e]:[]):[];if(Z.length===0&&Gt.length>0)return Wt((0,H.jsx)(`div`,{className:`space-y-4 px-4 py-5`,children:Gt.map(e=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,H.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))}));if($.length===0&&Q===null)return Wt((0,H.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:V===null?`This pull request has no file changes.`:`This commit has no file changes.`}));let Kt=n.reviewThreads.filter(e=>!bt.has(e.id)),qt=new Map;for(let e of Kt){let t=qt.get(e.path);t?t.push(e):qt.set(e.path,[e])}let Jt=Gt.length===0?null:(0,H.jsx)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-5`,children:Gt.map(e=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,H.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))});return(0,H.jsx)(_e,{children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ut,qt.size>0?(0,H.jsxs)(Se,{className:`shrink-0 border-b border-border/60`,open:ze,onOpenChange:Be,children:[(0,H.jsx)(`h2`,{children:(0,H.jsxs)(be,{className:`flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:Q===null?`Conversations not on the current diff`:`Conversations not on the diff loaded so far`}),(0,H.jsx)(y,{"aria-hidden":!0,className:b(`size-3.5 transition-transform`,ze&&`rotate-90`)}),(0,H.jsx)(`span`,{"aria-hidden":!0,className:`tabular-nums`,children:Kt.length}),(0,H.jsx)(`span`,{className:`sr-only`,children:Kt.length===1?`1 conversation`:`${Kt.length} conversations`})]})}),(0,H.jsx)(De,{children:(0,H.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-auto px-4 pb-3`,children:[...qt].map(([e,t])=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`truncate px-3 text-xs text-muted-foreground`,title:e,children:e}),(0,H.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,H.jsxs)(`div`,{children:[e.line===null?null:(0,H.jsxs)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:[`Line `,e.line]}),Rt(e)]},e.id))})]},e))})})]}):null,(0,H.jsxs)(`div`,{className:`relative min-h-0 flex-1`,onClickCapture:e=>{let t=e.nativeEvent.composedPath?.()??[];for(let e of t)if(e instanceof HTMLElement){if(e instanceof HTMLButtonElement||e instanceof HTMLAnchorElement)return;if(e.hasAttribute(`data-diffs-header`)){let t=e.querySelector(`[data-title]`)?.textContent?.trim();if(t===void 0||t===``)return;let n=$.find(e=>F(e.fileDiff)===t);n!==void 0&&Ot(n.id);return}}},children:[(0,H.jsx)(Je,{className:`h-full overflow-auto [scrollbar-gutter:stable]`,items:$,selectedLines:Pe,onSelectedLinesChange:Fe,options:It,renderCodeViewFooter:Nt,renderHeaderPrefix:Pt,renderHeaderMetadata:Ft,renderAnnotation:zt,unsafeCSSExtra:pt}),Bt]}),Jt]})})}export{X as PullRequestCodeTab,X as default};
|
|
251
|
-
//# sourceMappingURL=PullRequestCodeTab-
|
|
251
|
+
//# sourceMappingURL=PullRequestCodeTab-CNPFlQyk.js.map
|
package/dist/client/assets/{fileCommentAnnotations-Dh8Om-Nh.js → fileCommentAnnotations-DmPfXSsw.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{Zi as i,v as a}from"./previewAssetResource-
|
|
2
|
-
//# sourceMappingURL=fileCommentAnnotations-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{Zi as i,v as a}from"./previewAssetResource-bmHagfYU.js";import{Ir as o,Xr as s}from"./index-BBTuAu9J.js";var c=r(),l=e(n(),1),u=t();function d(e){let t=(0,c.c)(44),{kind:n,rangeLabel:r,text:d,onCancel:m,onComment:h,onDelete:g}=e,[_,v]=(0,l.useState)(``);if(n===`comment`){let e,n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,u.jsx)(s,{className:`size-4 text-muted-foreground`}),n=(0,u.jsx)(`span`,{className:`text-xs font-medium`,children:`Local comment`}),t[0]=e,t[1]=n):(e=t[0],n=t[1]);let a;t[2]===r?a=t[3]:(a=(0,u.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:r}),t[2]=r,t[3]=a);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,u.jsx)(o,{className:`size-3.5`}),t[4]=c):c=t[4];let l;t[5]===g?l=t[6]:(l=(0,u.jsx)(i,{variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:g,children:c}),t[5]=g,t[6]=l);let f;t[7]!==a||t[8]!==l?(f=(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e,n,a,l]}),t[7]=a,t[8]=l,t[9]=f):f=t[9];let m;t[10]===d?m=t[11]:(m=(0,u.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:d}),t[10]=d,t[11]=m);let h;return t[12]!==f||t[13]!==m?(h=(0,u.jsxs)(`div`,{"data-file-comment-annotation":!0,className:`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 shadow-sm`,contentEditable:!1,onPointerDown:p,children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14],h}let y;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(s,{className:`size-4 text-muted-foreground`}),(0,u.jsx)(`span`,{className:`text-sm font-medium`,children:`Local comment`})]}),t[15]=y):y=t[15];let b;t[16]===r?b=t[17]:(b=(0,u.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Comment on lines `,r]}),t[16]=r,t[17]=b);let x=`Comment on lines ${r}`,S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>v(e.target.value),t[18]=S):S=t[18];let C;t[19]!==m||t[20]!==h||t[21]!==_?(C=e=>{e.key===`Escape`&&(e.preventDefault(),m()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&_.trim()&&(e.preventDefault(),h(_.trim()))},t[19]=m,t[20]=h,t[21]=_,t[22]=C):C=t[22];let w;t[23]!==x||t[24]!==C||t[25]!==_?(w=(0,u.jsx)(a,{autoFocus:!0,className:`mt-3`,size:`sm`,value:_,placeholder:`Request change`,"aria-label":x,onChange:S,onKeyDown:C}),t[23]=x,t[24]=C,t[25]=_,t[26]=w):w=t[26];let T;t[27]===m?T=t[28]:(T=(0,u.jsx)(i,{variant:`ghost`,size:`sm`,onClick:m,children:`Cancel`}),t[27]=m,t[28]=T);let E;t[29]===_?E=t[30]:(E=_.trim(),t[29]=_,t[30]=E);let D=!E,O;t[31]!==h||t[32]!==_?(O=()=>h(_.trim()),t[31]=h,t[32]=_,t[33]=O):O=t[33];let k;t[34]!==O||t[35]!==D?(k=(0,u.jsx)(i,{size:`sm`,disabled:D,onClick:O,children:`Comment`}),t[34]=O,t[35]=D,t[36]=k):k=t[36];let A;t[37]!==k||t[38]!==T?(A=(0,u.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[T,k]}),t[37]=k,t[38]=T,t[39]=A):A=t[39];let j;return t[40]!==A||t[41]!==b||t[42]!==w?(j=(0,u.jsxs)(`div`,{"data-file-comment-annotation":!0,className:`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 shadow-lg`,contentEditable:!1,onPointerDown:f,children:[y,b,w,A]}),t[40]=A,t[41]=b,t[42]=w,t[43]=j):j=t[43],j}function f(e){return e.stopPropagation()}function p(e){return e.stopPropagation()}var m=0;function h(){return m+=1,`file-comment-${Date.now()}-${m}`}function g(e){return{startLine:Math.min(e.start,e.end),endLine:Math.max(e.start,e.end)}}function _(e,t){return e===t?`L${e}`:`L${e} to L${t}`}function v(e){return e.map(e=>({...e,metadata:{entries:e.metadata.entries.map(t=>{let n=t.endLine-t.startLine;return{...t,endLine:e.lineNumber,startLine:Math.max(1,e.lineNumber-n)}})}}))}export{d as a,v as i,h as n,g as r,_ as t};
|
|
2
|
+
//# sourceMappingURL=fileCommentAnnotations-DmPfXSsw.js.map
|