@p4code/cli 0.2.25 → 0.2.27
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/{NodeSqliteClient-CRS7rg24.mjs → NodeSqliteClient-BxR7Cn_r.mjs} +2 -2
- package/dist/bin.mjs +16269 -16266
- package/dist/client/assets/{DiffPanel-Clrv5Oc9.js → DiffPanel-Jfn-nZ2P.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-CPswWlzH.js → FilePreviewPanel-OQEQEdrB.js} +2 -2
- package/dist/client/assets/{PreviewPanel-AIlEywQK.js → PreviewPanel-CwhD6R8I.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-DJgw64uV.js → PullRequestCodeTab-BQOkugtK.js} +2 -2
- package/dist/client/assets/arrow-right-Bu5WkIYh.js +2 -0
- package/dist/client/assets/{fileCommentAnnotations-DSyTaqP7.js → fileCommentAnnotations-BAZwrcFy.js} +2 -2
- package/dist/client/assets/{index-CbyMk5N4.css → index-BOMxG-b0.css} +1 -1
- package/dist/client/assets/{index-ChiJJUm2.js → index-IA1MLjyL.js} +212 -203
- package/dist/client/assets/previewAssetResource-JdwqlhCI.js +48 -0
- package/dist/client/assets/{renderFileChildren-BFvLnmNZ.js → renderFileChildren-BvCC5Y3x.js} +2 -2
- package/dist/client/assets/{toggle-group-DkLWU3bB.js → toggle-group-4XK-wLB0.js} +2 -2
- package/dist/client/index.html +3 -3
- package/package.json +1 -1
- package/dist/client/assets/arrow-right-CW83eQ9E.js +0 -2
- package/dist/client/assets/previewAssetResource-kDlikuCq.js +0 -48
package/dist/client/assets/{PullRequestCodeTab-DJgw64uV.js → PullRequestCodeTab-BQOkugtK.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{Er as i,Et as a,Hc as o,Na as s,Pa as c,Qc as l,Ta as u,Uc as d,Xc as f,Yc as p,Zc as m,_a as h,ba as g,dt as _,gt as v,ht as y,jl as b,pl as x,qc as S,v as C,vt as w,wa as T,x as E,yt as D,zr as O}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{Er as i,Et as a,Hc as o,Na as s,Pa as c,Qc as l,Ta as u,Uc as d,Xc as f,Yc as p,Zc as m,_a as h,ba as g,dt as _,gt as v,ht as y,jl as b,pl as x,qc as S,v as C,vt as w,wa as T,x as E,yt as D,zr as O}from"./previewAssetResource-JdwqlhCI.js";import{a as k,n as A,o as j,r as M,s as N,t as P}from"./toggle-group-4XK-wLB0.js";import{B as F,Fr as ee,G as te,Gr as ne,H as re,Ir as ie,J as ae,K as oe,Lr as se,Qr as ce,Rr as le,U as ue,V as de,W as fe,X as I,Xr as pe,Yr as me,_ as he,ai as ge,ct as _e,ir as ve,it as ye,lt as L,nr as be,nt as xe,oi as Se,ot as Ce,q as we,rr as Te,rt as Ee,si as De,st as Oe,ut as ke,xr as Ae}from"./index-IA1MLjyL.js";var je=l(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Me=l(`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`}]]),R=e(n(),1),Ne=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),Pe=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),z=new Set([`__tests__`,`tests`,`test`]),B=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function Fe(e){let t=e.split(`/`),n=t.at(-1)??``;return Ne.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>Pe.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>z.has(e))?`test`:`source`}function Ie(e){let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(0,t):e}function Le(e){return Ie(e.split(`/`).at(-1)??``)}function Re(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 ze=/(?:\bfrom|\bimport|\brequire\s*\()\s*\(?\s*["']([^"']+)["']/g;function Be(e,t,n,r){let i=new Set;for(let a of t){ze.lastIndex=0;let t=ze.exec(a);for(;t!==null;){let o=t[1]??``,s=o.startsWith(`.`)?Re(e,o):o,c=B.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(Le(l));u!==void 0&&u!==e&&i.add(u),t=ze.exec(a)}}return i}function Ve(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 V(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function He(e){let t=new Map;for(let n of e)t.set(L(n),n);let n=new Map;for(let e of t.keys())n.set(e,Fe(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(Ie(e),e);let t=Le(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,Be(e,[...n.additionLines,...n.deletionLines],i,o))}let c=Ve(r,s),l=new Map;c.forEach((e,t)=>{let n=Le(e);l.has(n)||l.set(n,t)});let u=[...t.keys()].filter(e=>n.get(e)===`test`).sort((e,t)=>(l.get(V(e))??2**53-1)-(l.get(V(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 Ue(e,t){return async n=>{let r=L(n),i=n.prevName?L({...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 We(e,t){return Ue(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 b(a);return a.value},t.cacheKey)}var H=r();function U(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var W=t();function Ge(e){let t=(0,H.c)(43),{kind:n,rangeLabel:r,text:i,onTextChange:a,onCancel:o,onComment:s,onDelete:c,placeholder:l,submitLabel:u,pending:d,secondaryAction:f}=e,p=l===void 0?`Add a comment…`:l,m=u===void 0?`Comment`:u,g=d===void 0?!1:d,[_,v]=(0,R.useState)(``),y=n===`draft`&&!a?_:i,b;t[0]===y?b=t[1]:(b=y.trim(),t[0]=y,t[1]=b);let x=b;if(n===`comment`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,W.jsx)(pe,{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]===y?n=t[4]:(n=(0,W.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5`,children:y}),t[3]=y,t[4]=n);let r;t[5]===c?r=t[6]:(r=c?(0,W.jsx)(h,{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,W.jsx)(ie,{className:`size-3`})}):null,t[5]=c,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,W.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:q,children:[e,n,r]}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}let S=`Comment on lines ${r}`,w;t[10]===a?w=t[11]:(w=e=>(a??v)(e.target.value),t[10]=a,t[11]=w);let T;t[12]!==o||t[13]!==s||t[14]!==g||t[15]!==x?(T=e=>{e.key===`Escape`&&(e.preventDefault(),o()),U(e,x,g)&&(e.preventDefault(),s(x))},t[12]=o,t[13]=s,t[14]=g,t[15]=x,t[16]=T):T=t[16];let E;t[17]!==y||t[18]!==p||t[19]!==S||t[20]!==w||t[21]!==T?(E=(0,W.jsx)(C,{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:y,placeholder:p,"aria-label":S,onChange:w,onFocus:G,onKeyDown:T}),t[17]=y,t[18]=p,t[19]=S,t[20]=w,t[21]=T,t[22]=E):E=t[22];let D;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,W.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground/70`,children:`⌘/Ctrl Enter to send`}),t[23]=D):D=t[23];let O;t[24]===o?O=t[25]:(O=(0,W.jsx)(h,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:o,children:`Cancel`}),t[24]=o,t[25]=O);let k;t[26]!==f||t[27]!==x?(k=f?(0,W.jsxs)(h,{size:`xs`,variant:`outline`,disabled:!f.allowEmpty&&!x,onClick:()=>f.onAction(x),children:[f.icon,f.label]}):null,t[26]=f,t[27]=x,t[28]=k):k=t[28];let A=g||!x,j;t[29]!==s||t[30]!==x?(j=()=>s(x),t[29]=s,t[30]=x,t[31]=j):j=t[31];let M;t[32]!==m||t[33]!==A||t[34]!==j?(M=(0,W.jsx)(h,{size:`xs`,disabled:A,onClick:j,children:m}),t[32]=m,t[33]=A,t[34]=j,t[35]=M):M=t[35];let N;t[36]!==O||t[37]!==k||t[38]!==M?(N=(0,W.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1`,children:[D,O,k,M]}),t[36]=O,t[37]=k,t[38]=M,t[39]=N):N=t[39];let P;return t[40]!==N||t[41]!==E?(P=(0,W.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:K,children:[E,N]}),t[40]=N,t[41]=E,t[42]=P):P=t[42],P}function G(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function K(e){return e.stopPropagation()}function q(e){return e.stopPropagation()}var J=`${xe}
|
|
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:l,pendingFinding:m,fixFindingLabel:b=`Fix in a thread`,onFixFinding:S,onAskAboutSelection:C,onRefresh:O,refreshToken:k=0}){let{resolvedTheme:F}=E(),te=ee(),[ne,re]=(0,R.useState)(()=>new Set),[ie,ce]=(0,R.useState)(ft),[de,pe]=(0,R.useState)(null),[ge,xe]=(0,R.useState)(`stacked`),[Ae,je]=(0,R.useState)(te.wordWrap),[Ne,Pe]=(0,R.useState)(null),[z,B]=(0,R.useState)(null),[Fe,Ie]=(0,R.useState)(!1),[Le,Re]=(0,R.useState)(!1),[ze,Be]=(0,R.useState)(!1),[Ve,V]=(0,R.useState)({key:``,cursor:null,slices:mt}),Ue=(0,R.useRef)(new Map),H=et(t),U=r,G=U===null?H:`${H}@${U}`;(0,R.useEffect)(()=>{B(null),Pe(null),re(new Set),pe(null),ce(ft),Re(!1),V({key:G,cursor:null,slices:mt}),Ue.current.clear()},[G]);let K=Ve.key===G?Ve.slices:mt,q=Ve.key===G?Ve.cursor:null,J=a(I.diff({environmentId:e,input:{...t,...q===null?{}:{cursor:q},...U===null?{}:{commit:U}}}));(0,R.useEffect)(()=>{let e=J.data;e!==null&&V(t=>{let n=t.key===G?t.slices:mt,r={cursor:q,patch:e.patch,truncated:e.truncated,nextCursor:e.nextCursor,omittedFileStats:e.omittedFileStats??[]},i=n.findIndex(e=>e.cursor===q);if(i===-1)return{key:G,cursor:q,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:G,cursor:q,slices:[...n.slice(0,i),r]}})},[q,J.data,G]);let qe=x(I.diff({environmentId:e,input:{...t,...U===null?{}:{commit:U}}})),Je=(0,R.useRef)(k);(0,R.useEffect)(()=>{Je.current!==k&&(Je.current=k,V({key:G,cursor:null,slices:mt}),qe())},[k,G,qe]);let Xe=H,Qe=nt(t),tt=Y(e=>e.addComment),rt=Y(e=>e.removeComment),at=D(I.replyToThread,{reportFailure:!1}),ot=D(I.setThreadResolution,{reportFailure:!1}),st=D(I.updateComment,{reportFailure:!1}),ct=D(I.diffFileContents),lt=(0,R.useMemo)(()=>We(ct,{environmentId:e,reference:t,commit:U,cacheKey:`pull-request:${H}:${n.updatedAt}:${U??`all`}`}),[U,n.updatedAt,e,ct,t,H]),X=(0,R.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&&U===null,vt=(0,R.useMemo)(()=>K.map(e=>{let t=`pull-request:${G}:${F}:${e.cursor??`first`}:${ye(e.patch)}`,n=Ue.current.get(t);if(n)return n;let r=Oe(e.patch,t,{compactPartialHunkOffsets:!0});return r&&Ue.current.set(t,r),r}),[K,F,G]),Z=(0,R.useMemo)(()=>vt.flatMap(e=>e?.kind===`files`?He(e.files):[]),[vt]),Q=K.at(-1)?.nextCursor??null,yt=K.some(e=>e.truncated)||vt.some(e=>e?.kind===`raw`),bt=(0,R.useMemo)(()=>{let e=new Set;if(U!==null)return e;for(let t of Z){let r=L(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},[U,n.reviewThreads,Z]),$=(0,R.useMemo)(()=>Z.map(e=>{let t=Ee(e),r=L(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(U===null)for(let e of Qe)e.path===r&&a(e.side,e.line).pending.push(e);z?.fileKey===t&&(a(z.side,z.line).draft=!0);let o=dt(t,de,ne),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:ye(`${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(`|`)}`)}}),[U,n.reviewThreads,z,Z,de,Qe,bt,ne]),xt=(0,R.useMemo)(()=>Ce(Z),[Z]),St=(0,R.useMemo)(()=>new Map(K.flatMap(e=>e.omittedFileStats.map(e=>[e.path,e]))),[K]),Ct=(0,R.useMemo)(()=>$.map(e=>e.id),[$]),wt=(0,R.useMemo)(()=>new Set($.filter(e=>e.collapsed===!0).map(e=>e.id)),[$]),Tt=M(Ct,wt),[Et,Dt]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(Et===null||Q===null||Q===q||J.isPending||J.error!==null)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&V(e=>({...e,cursor:Q}))},{rootMargin:`240px`});return e.observe(Et),()=>e.disconnect()},[q,J.error,J.isPending,Q,Et]);let Ot=(0,R.useCallback)(e=>re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),kt=()=>{pe(M(Ct,wt)?`expanded`:`folded`),re(new Set)},At=(0,R.useMemo)(()=>n.commits.toSorted((e,t)=>Date.parse(t.committedDate)-Date.parse(e.committedDate)),[n.commits]),jt=(0,R.useCallback)((e,t)=>{if(!e||!_t)return;let n=t.item;if(n.type!==`diff`)return;let r=Z.find(e=>Ee(e)===n.id);if(!r)return;let i=L(r),a=ke(r);B({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,R.useCallback)((e,t)=>{let r=Z.find(t=>Ee(t)===e.fileKey),a=r===void 0?null:i({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});B(null),Pe(null),!(a===null||!C)&&C({comment:a,question:t})},[n.number,Z,C]),Nt=(0,R.useCallback)(()=>Q===null?null:(0,W.jsx)(`div`,{ref:Dt,className:`flex items-center justify-center gap-2 py-2 text-xs text-muted-foreground`,children:J.error===null?J.isPending?`Loading more files...`:null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`The rest of this diff could not be loaded.`}),(0,W.jsx)(h,{size:`xs`,variant:`outline`,onClick:()=>J.refresh(),children:`Retry`})]})}),[Q,J.error,J.isPending,J.refresh]),Pt=(0,R.useCallback)(e=>{let t=e.collapsed===!0;return(0,W.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand diff`:`Collapse diff`,className:c(`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,W.jsx)(p,{className:`size-4`}):(0,W.jsx)(f,{className:`size-4`})})},[Ot]),Ft=(0,R.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(L(e.fileDiff));r&&({additions:t,deletions:n}=r)}return(0,W.jsx)(oe,{additions:t,deletions:n,className:`font-mono text-[11px]`})},[St]),It=(0,R.useMemo)(()=>({diffStyle:ge===`split`?`split`:`unified`,lineDiffType:`none`,overflow:Ae?`wrap`:`scroll`,theme:_e(F),themeType:F,stickyHeaders:!0,loadDiffFiles:lt,enableGutterUtility:_t&&z===null,enableLineSelection:_t&&z===null,onGutterUtilityClick:jt,onLineSelectionEnd:jt}),[ge,Ae,F,lt,_t,z,jt]),Lt=(0,R.useCallback)(async(e,t)=>{if(Fe)return!1;Ie(!0);let n=await t();return Ie(!1),n._tag===`Failure`?(_.add({type:`error`,title:e}),!1):(O(),!0)},[O,Fe]),Rt=(0,R.useCallback)(r=>(0,W.jsx)(Ze,{thread:r,workspaceRoot:n.workspaceRoot,canReply:X.reply,canResolve:X.resolve,canReact:n.capabilities.reactions===!0,environmentId:e,reference:t,pending:Fe,fixPending:m===fe({kind:`thread`,thread:r}),fixLabel:b,...S?{onFix:()=>S({kind:`thread`,thread:r})}:{},onReply:n=>Lt(`Reply could not be posted`,()=>at({environmentId:e,input:{...t,threadId:r.id,body:n}})),canEditComment:e=>ue(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:O},`${t.projectId}#${t.number}:${r.id}`),[n,e,b,O,S,m,t,at,X.reply,X.resolve,Lt,ot,Fe,st]),zt=(0,R.useCallback)(e=>(0,W.jsxs)(`div`,{className:`py-1 font-sans text-foreground`,children:[e.metadata.threads.map(Rt),e.metadata.pending.map(e=>(0,W.jsx)(Ye,{comment:e,onRemove:()=>rt(Xe,e.id)},e.id)),e.metadata.draft&&z?(0,W.jsx)(Ge,{kind:`draft`,rangeLabel:`${z.path}:${z.line}`,text:``,submitLabel:`Add to review`,...C?{secondaryAction:{label:`Ask`,icon:(0,W.jsx)(le,{className:`size-3`}),allowEmpty:!0,onAction:e=>Mt(z,e)}}:{},onCancel:()=>{B(null),Pe(null)},onComment:e=>{tt(Xe,{id:$e(),path:z.path,...z.oldPath===null?{}:{oldPath:z.oldPath},line:z.line,side:z.side,body:e}),B(null),Pe(null)}}):null]}),[tt,Mt,z,C,rt,Rt,Xe]),Bt=X.verdicts.length===0?null:(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:ze?(0,W.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,W.jsx)(h,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close review`,className:`absolute right-2 top-2`,onClick:()=>Be(!1),children:(0,W.jsx)(o,{className:`size-3.5`})}),(0,W.jsx)(it,{environmentId:e,reference:t,verdicts:X.verdicts,onSubmitted:()=>{O(),Be(!1)}})]}):(0,W.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:()=>Be(!0),children:[(0,W.jsx)(me,{className:`size-3.5`}),`Review`,Qe.length>0?(0,W.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground`,children:Qe.length}):null]})}),Vt=At.find(e=>e.oid===U);(0,R.useEffect)(()=>{U!==null&&Vt===void 0&&l(null)},[U,l,Vt]);let Ht=Vt?Vt.messageHeadline:`All commits`,Ut=(0,W.jsxs)(`div`,{className:`surface-subheader justify-between gap-2 px-4 text-xs text-muted-foreground`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[At.length>0?(0,W.jsxs)(g,{children:[(0,W.jsxs)(s,{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,W.jsx)(`span`,{className:`truncate`,children:Ht}),(0,W.jsx)(f,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,W.jsxs)(u,{align:`start`,className:`w-80`,children:[(0,W.jsx)(T,{className:U===null?`bg-foreground/[0.08]`:void 0,onClick:()=>l(null),children:(0,W.jsx)(`span`,{children:`All commits`})}),At.slice(0,ie).map(e=>(0,W.jsxs)(T,{className:e.oid===U?`bg-foreground/[0.08]`:void 0,onClick:()=>l(e.oid),children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:e.messageHeadline,children:e.messageHeadline}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-xs text-muted-foreground`,children:e.oid.slice(0,7)})]},e.oid)),At.length>ie?(0,W.jsx)(T,{closeOnClick:!1,onClick:()=>ce(e=>e+ft),children:(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Show more (`,At.length-ie,` left)`]})}):null]})]}):null,(0,W.jsxs)(we,{children:[(0,W.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[Z.length,` `,Z.length===1?`file`:`files`,Q===null?``:`+`]}),yt?(0,W.jsxs)(y,{children:[(0,W.jsx)(w,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(d,{"aria-label":`Some of this diff was not shown`,className:`size-3.5 text-amber-600 dark:text-amber-500`})}),(0,W.jsx)(v,{side:`bottom`,children:`The host withheld part of this diff — a binary file, or a change too large to inline.`})]}):null,U!==null&&X.inlineComment?(0,W.jsxs)(y,{children:[(0,W.jsx)(w,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(Me,{"aria-label":`Line comments are written from the whole change`,className:`size-3.5`})}),(0,W.jsx)(v,{side:`bottom`,children:`A comment is anchored to the whole change, so switch to All commits to write one.`})]}):null]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(oe,{additions:xt.additions,deletions:xt.deletions,className:`mr-1`}),Ct.length>0?(0,W.jsxs)(y,{children:[(0,W.jsx)(w,{render:(0,W.jsx)(h,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":Tt?`Expand all files`:`Collapse all files`,onClick:kt}),children:Tt?(0,W.jsx)(Se,{className:`size-3.5`}):(0,W.jsx)(De,{className:`size-3.5`})}),(0,W.jsx)(v,{side:`top`,children:Tt?`Expand all files`:`Collapse all files`})]}):null,(0,W.jsxs)(A,{className:`shrink-0 gap-1`,size:`sm`,value:[ge],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&xe(t)},children:[(0,W.jsx)(P,{"aria-label":`Stacked diff view`,value:`stacked`,variant:`ghost`,children:(0,W.jsx)(j,{className:`size-3.5`})}),(0,W.jsx)(P,{"aria-label":`Split diff view`,value:`split`,variant:`ghost`,children:(0,W.jsx)(N,{className:`size-3.5`})})]}),(0,W.jsxs)(y,{children:[(0,W.jsx)(w,{render:(0,W.jsx)(P,{"aria-label":Ae?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`ghost`,size:`sm`,pressed:Ae,onPressedChange:e=>{je(!!e)}}),children:(0,W.jsx)(se,{className:`size-3.5`})}),(0,W.jsx)(v,{side:`top`,children:Ae?`Disable line wrapping`:`Enable line wrapping`})]})]})]}),Wt=e=>(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ut,(0,W.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`h-full overflow-auto`,children:e}),Bt]})]});if(J.isPending&&K.length===0)return Wt((0,W.jsx)(ae,{label:`Loading pull request diff...`}));if(J.error&&K.length===0)return Wt((0,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:J.error}));let Gt=Q===null?vt.flatMap(e=>e?.kind===`raw`?[e]:[]):[];if(Z.length===0&&Gt.length>0)return Wt((0,W.jsx)(`div`,{className:`space-y-4 px-4 py-5`,children:Gt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.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,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:U===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,W.jsx)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-5`,children:Gt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))});return(0,W.jsx)(he,{children:(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ut,qt.size>0?(0,W.jsxs)(be,{className:`shrink-0 border-b border-border/60`,open:Le,onOpenChange:Re,children:[(0,W.jsx)(`h2`,{children:(0,W.jsxs)(ve,{className:`flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:Q===null?`Conversations not on the current diff`:`Conversations not on the diff loaded so far`}),(0,W.jsx)(p,{"aria-hidden":!0,className:c(`size-3.5 transition-transform`,Le&&`rotate-90`)}),(0,W.jsx)(`span`,{"aria-hidden":!0,className:`tabular-nums`,children:Kt.length}),(0,W.jsx)(`span`,{className:`sr-only`,children:Kt.length===1?`1 conversation`:`${Kt.length} conversations`})]})}),(0,W.jsx)(Te,{children:(0,W.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-auto px-4 pb-3`,children:[...qt].map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`truncate px-3 text-xs text-muted-foreground`,title:e,children:e}),(0,W.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,W.jsxs)(`div`,{children:[e.line===null?null:(0,W.jsxs)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:[`Line `,e.line]}),Rt(e)]},e.id))})]},e))})})]}):null,(0,W.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=>L(e.fileDiff)===t);n!==void 0&&Ot(n.id);return}}},children:[(0,W.jsx)(Ke,{className:`h-full overflow-auto [scrollbar-gutter:stable]`,items:$,selectedLines:Ne,onSelectedLinesChange:Pe,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-BQOkugtK.js.map
|
package/dist/client/assets/{fileCommentAnnotations-DSyTaqP7.js → fileCommentAnnotations-BAZwrcFy.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{_a 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{_a as i,v as a}from"./previewAssetResource-JdwqlhCI.js";import{Ir as o,Xr as s}from"./index-IA1MLjyL.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-BAZwrcFy.js.map
|