@opentig/cli 0.1.7 → 0.2.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/THIRD_PARTY_NOTICES.md +3 -1
- package/dist/bin.mjs +2 -5
- package/dist/chunks/{cli-DCPhUVBb.mjs → cli-Bi6ET5UT.mjs} +15 -2
- package/dist/client/assets/App-BXZLGT86.js +74 -0
- package/dist/client/assets/CreatePullRequestDialog-DFonMYEx.js +2 -0
- package/dist/client/assets/DiffWorkspace-RDG_Y70N.js +26 -0
- package/dist/client/assets/EditableFileViewer-CsbifqBO.js +1 -0
- package/dist/client/assets/File-CHjvYpb2.js +1 -0
- package/dist/client/assets/FilesView-Dl8QFbFA.js +1 -0
- package/dist/client/assets/GitHubAvatar-CnBaloV0.js +1 -0
- package/dist/client/assets/HistoryView-BgCZU2JO.js +1 -0
- package/dist/client/assets/{HtmlFileViewer-C3Qylr9B.js → HtmlFileViewer-h8ULU8Gy.js} +1 -1
- package/dist/client/assets/{IconEdit-BHqlqze_.js → IconEdit-Cg8S2wqW.js} +1 -1
- package/dist/client/assets/IconFolderSymlink-BZSLX1ez.js +1 -0
- package/dist/client/assets/{ImageFileViewer-BJy0ptmR.js → ImageFileViewer-Cjw58ckv.js} +1 -1
- package/dist/client/assets/LocalRefsDialog-DNgrd7Qp.js +1 -0
- package/dist/client/assets/MarkdownFileViewer-kLiduag6.js +2 -0
- package/dist/client/assets/{PairingPage-DOPAXy3a.js → PairingPage-C97sv-8s.js} +1 -1
- package/dist/client/assets/PierreDiffViewer-eAcugmoF.js +1 -0
- package/dist/client/assets/{PierreEditBoundary-mxtF7x3F.js → PierreEditBoundary-DlGd1pqO.js} +2 -2
- package/dist/client/assets/{PierreWorkerPool-B_NFnwU-.js → PierreWorkerPool-Col4k7qz.js} +18 -18
- package/dist/client/assets/{PullRequestDiff-Bcu8Gmrf.js → PullRequestDiff-DhKTXyIF.js} +1 -1
- package/dist/client/assets/PullRequestViewer-BgI8HFMe.js +2 -0
- package/dist/client/assets/PullRequestsView-PYWLy8We.js +1 -0
- package/dist/client/assets/QuickOpenDialog-BFDDZVCL.js +1 -0
- package/dist/client/assets/RepositoryProjectsDialog-CvB8KcFp.js +1 -0
- package/dist/client/assets/SearchView-BwF_MsxK.js +1 -0
- package/dist/client/assets/SettingsDialog-DIcLmXSE.js +9 -0
- package/dist/client/assets/Viewer-o1hDU33O.js +3 -0
- package/dist/client/assets/{abnfDiagram-N423BO3Z-BxGW6tGd.js → abnfDiagram-N423BO3Z-BvrnK_R-.js} +1 -1
- package/dist/client/assets/{arc-CphVLv_F.js → arc-DLa3_7ua.js} +1 -1
- package/dist/client/assets/{architectureDiagram-T3A2C74G-D9IDzZ6u.js → architectureDiagram-T3A2C74G-BexwhnyX.js} +1 -1
- package/dist/client/assets/base-ui-CJ8ZIx3d.js +1 -0
- package/dist/client/assets/{blockDiagram-VBNYF7ZC-CzCatff9.js → blockDiagram-VBNYF7ZC-CoOttUUo.js} +1 -1
- package/dist/client/assets/{c4Diagram-5PPSVZJV-jvC7ACDE.js → c4Diagram-5PPSVZJV-Bgp6ppUh.js} +1 -1
- package/dist/client/assets/channel-1k1AYpyV.js +1 -0
- package/dist/client/assets/{checkbox-DDpujnre.js → checkbox-BRH0ZNIC.js} +1 -1
- package/dist/client/assets/{chunk-2GRJ4B5K-CNRn3w2y.js → chunk-2GRJ4B5K-C_kzp38w.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-CnTjXDS8.js → chunk-2Q5K7J3B-CysYnRkJ.js} +1 -1
- package/dist/client/assets/{chunk-5RXB4S5H-8QZZSU3J.js → chunk-5RXB4S5H-oMS6x_ag.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-B2MFN1L0.js → chunk-5VM5RSS4-C5-dW5wf.js} +1 -1
- package/dist/client/assets/{chunk-6Q2QTUOP-BRGuFKSr.js → chunk-6Q2QTUOP-DxahInnA.js} +1 -1
- package/dist/client/assets/{chunk-GF5L2VYU-CWTKyD7U.js → chunk-GF5L2VYU-D7V-3eRg.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-rGurufZY.js → chunk-JWPE2WC7-BrLmjbVP.js} +1 -1
- package/dist/client/assets/{chunk-KBJHAD2P-DOwIHyo0.js → chunk-KBJHAD2P-CyOvijwM.js} +1 -1
- package/dist/client/assets/{chunk-RYQCIY6F-qrVd0AV3.js → chunk-RYQCIY6F-BvEjVjQs.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-BGvaybJK.js → chunk-XXDRQBXY-C_IY9A64.js} +1 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-ChyNFpay.js +1 -0
- package/dist/client/assets/classDiagram-v2-OCEON4UE-ChyNFpay.js +1 -0
- package/dist/client/assets/{vb-D17OF-Vu.js → cmd-BW5THilD.js} +1 -1
- package/dist/client/assets/{cose-bilkent-JH36ORCC-CHgOt-vq.js → cose-bilkent-JH36ORCC-Cu7qZi7h.js} +1 -1
- package/dist/client/assets/{cynefin-VYW2F7L2-DX7Kb3Ft.js → cynefin-VYW2F7L2-B4M1t9lL.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-MW4NZA55-B4MgYgbV.js → cynefinDiagram-MW4NZA55-CAosOLmT.js} +1 -1
- package/dist/client/assets/{dagre-VZM6K2ZE-xG9l95NU.js → dagre-VZM6K2ZE-q354V538.js} +1 -1
- package/dist/client/assets/{diagram-7IWD3JNH-BQKb8ivh.js → diagram-7IWD3JNH-C_CzkBPt.js} +1 -1
- package/dist/client/assets/{diagram-B4RE2ZJO-CyIMrtDr.js → diagram-B4RE2ZJO-VvvYHE9c.js} +1 -1
- package/dist/client/assets/{diagram-LBJQPF4R-WuCMu4WW.js → diagram-LBJQPF4R-D8vRQwb5.js} +1 -1
- package/dist/client/assets/{diagram-Q27KOJAE--Oi1nRrR.js → diagram-Q27KOJAE-Bul4aDKg.js} +1 -1
- package/dist/client/assets/{diagram-UB23O5K3-CP1DXsa_.js → diagram-UB23O5K3-DNadEE58.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-BXEA7PRR-C-7jJg9C.js → ebnfDiagram-BXEA7PRR-Bf-68MMZ.js} +1 -1
- package/dist/client/assets/{erDiagram-JOGREHBK-FSyqgO_9.js → erDiagram-JOGREHBK-CJ-jHFsf.js} +1 -1
- package/dist/client/assets/{flowDiagram-UKHOOZJN-y2e2HZHu.js → flowDiagram-UKHOOZJN-DMOdinBU.js} +1 -1
- package/dist/client/assets/{ganttDiagram-PKOTCBZU-kZ3m3wwW.js → ganttDiagram-PKOTCBZU-DzezS3Zy.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-3Z9e4WPi.js → gitGraphDiagram-DS77QQ5N-Dftpvns8.js} +1 -1
- package/dist/client/assets/index-BfA4tAc1.css +1 -0
- package/dist/client/assets/{index-DDbUjVD9.js → index-BzmFkR37.js} +1 -1
- package/dist/client/assets/{index-ChKJF4C_.js → index-DAUK3rnz.js} +4 -4
- package/dist/client/assets/{infoDiagram-6WML65LV-TfCo0Rhw.js → infoDiagram-6WML65LV-DmgUBq17.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-DaXI89rw.js → ishikawaDiagram-WSZJBQD7-CL0PQhpQ.js} +1 -1
- package/dist/client/assets/{journeyDiagram-NVQOT4AX-C4jS6BVn.js → journeyDiagram-NVQOT4AX-Ck4pQx_A.js} +1 -1
- package/dist/client/assets/{kanban-definition-27J2QSJJ-bwOtQiC8.js → kanban-definition-27J2QSJJ-DuRZxBql.js} +1 -1
- package/dist/client/assets/{linear-DfZM9J6Z.js → linear-C2JDCaz4.js} +1 -1
- package/dist/client/assets/{mermaid.core-B-iLnCqi.js → mermaid.core-9dt2ugQA.js} +4 -4
- package/dist/client/assets/{mindmap-definition-FAOFIHXS-DAdKdypB.js → mindmap-definition-FAOFIHXS-vy0fdDF0.js} +1 -1
- package/dist/client/assets/{pegDiagram-VL7TDLO6-Bl95_ELH.js → pegDiagram-VL7TDLO6-DjVJy-Gm.js} +1 -1
- package/dist/client/assets/{pieDiagram-7S7Q4E2Y-DXf4GTLI.js → pieDiagram-7S7Q4E2Y-ATbd_8vw.js} +1 -1
- package/dist/client/assets/{platform-BMNQ8V5r.js → platform-Bqt97_Jr.js} +2 -2
- package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-CDiwouFY.js → quadrantDiagram-CIZ2JOQS-C8o6ofcl.js} +1 -1
- package/dist/client/assets/{railroadDiagram-AXF67PYL-CZAR7rja.js → railroadDiagram-AXF67PYL-Qvij9Ubo.js} +1 -1
- package/dist/client/assets/render-markdown-BtCybfvQ.js +280 -0
- package/dist/client/assets/repository-grammars-ixqpb0uW.js +1 -0
- package/dist/client/assets/{requirementDiagram-LRYGKXZP-BklWtcnl.js → requirementDiagram-LRYGKXZP-yLfrba2h.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-W5VNT64P-CpD7cM5j.js → sankeyDiagram-W5VNT64P-BTXRtTyG.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-SI44F4Z6-BnHPNl9l.js → sequenceDiagram-SI44F4Z6-BN1CCZIX.js} +1 -1
- package/dist/client/assets/{sizeCapture-X5ZJPWSS-D1eo0r-2.js → sizeCapture-X5ZJPWSS-BfXjBBYo.js} +1 -1
- package/dist/client/assets/{stateDiagram-OKZ733FA-ClTacl-d.js → stateDiagram-OKZ733FA-DMAWiBsP.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-D_ofZeaa.js +1 -0
- package/dist/client/assets/{swimlanes-SLNWSIFB-_PLbkM5u.js → swimlanes-SLNWSIFB-BD20m5cw.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-CF9m5JSB.js +8 -0
- package/dist/client/assets/{tanstack-CtfgE41X.js → tanstack-B0Sf7wNU.js} +1 -1
- package/dist/client/assets/{timeline-definition-Z64GVDOM-C9U6VikV.js → timeline-definition-Z64GVDOM-gtc0-AHB.js} +1 -1
- package/dist/client/assets/{vennDiagram-T6HMQDX7-Desj7KFU.js → vennDiagram-T6HMQDX7-Cdr4AXTp.js} +1 -1
- package/dist/client/assets/viewer-tabs-D-T0xQaq.js +1 -0
- package/dist/client/assets/{wardleyDiagram-T6FBY63Y-rlMEd5tV.js → wardleyDiagram-T6FBY63Y-BcU4vxO8.js} +1 -1
- package/dist/client/assets/{xychartDiagram-ELKLHX3M-CzFgA0NM.js → xychartDiagram-ELKLHX3M-B3Zuadj8.js} +1 -1
- package/dist/client/index.html +4 -4
- package/dist/dev.mjs +1 -4
- package/dist/manifest.json +1 -1
- package/dist/server.mjs +779 -2436
- package/dist/utility.mjs +1 -4
- package/package.json +2 -2
- package/dist/client/assets/App-CGiS2z40.js +0 -74
- package/dist/client/assets/CreatePullRequestDialog-dNbTTo9i.js +0 -2
- package/dist/client/assets/DiffWorkspace-XS025gbZ.js +0 -26
- package/dist/client/assets/EditableFileViewer-Cve4V9RS.js +0 -1
- package/dist/client/assets/File-BJuBDans.js +0 -1
- package/dist/client/assets/FilesView-BUAz46Qa.js +0 -1
- package/dist/client/assets/GitHubAvatar-Depnd_JA.js +0 -1
- package/dist/client/assets/HistoryView-Dd4Kr4KN.js +0 -1
- package/dist/client/assets/IconFolderPlus-BJIo1hfe.js +0 -1
- package/dist/client/assets/LocalRefsDialog-C1MWMkv1.js +0 -1
- package/dist/client/assets/MarkdownFileViewer-pagMxv2y.js +0 -2
- package/dist/client/assets/PierreDiffViewer-FmgbHdls.js +0 -1
- package/dist/client/assets/PullRequestViewer-oeDoq-3g.js +0 -2
- package/dist/client/assets/PullRequestsView-DpTtagTX.js +0 -1
- package/dist/client/assets/QuickOpenDialog-rjeV0l_J.js +0 -1
- package/dist/client/assets/RepositoryProjectsDialog-QYXEt7Lg.js +0 -1
- package/dist/client/assets/SearchView-C-c6oCil.js +0 -1
- package/dist/client/assets/SettingsDialog-DHmWkKYV.js +0 -9
- package/dist/client/assets/Viewer-B6qUr83C.js +0 -3
- package/dist/client/assets/base-ui-DT3JsyND.js +0 -1
- package/dist/client/assets/channel-BGbncBYv.js +0 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BoYriqPM.js +0 -1
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BoYriqPM.js +0 -1
- package/dist/client/assets/gh-utils-DxPHIkD8.js +0 -1
- package/dist/client/assets/index-WwGOu_aM.css +0 -1
- package/dist/client/assets/render-markdown-BiKX2Zdv.js +0 -280
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-DAo7Tfh9.js +0 -1
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-DHeOpgR_.js +0 -8
- package/dist/client/assets/viewer-tabs-BwMhis6Q.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,r as i,a as bt}from"./react-rd22PHbN.js";import{a as wt}from"./tanstack-CtfgE41X.js";import{a4 as Mt,a6 as vt,a8 as St,a9 as Ve,aa as Nt,Z as Rt,ab as It,ac as Et,ad as Ft,ae as Tt,af as T,G as Pt,ag as _t,j as zt,U as Oe,ah as $t,ai as Xe,aj as qe,ak as Kt,al as Lt,am as At,an as Ht,X as Ut,ao as Bt,ap as Fe,aq as Vt,ar as Xt,_ as Ze,as as qt,at as Ee,au as Yt,av as Gt,t as Ot,y as Zt,D as Wt,c as Jt,d as Qt,e as en}from"./App-CGiS2z40.js";import{c as K,d as Te,B as H,I as tn}from"./index-ChKJF4C_.js";import{m as nn,n as sn,M as on,o as rn,p as an,q as ln,S as cn}from"./base-ui-DT3JsyND.js";import{I as We}from"./IconFolderPlus-BJIo1hfe.js";import{I as dn}from"./IconEdit-BHqlqze_.js";const un=[["path",{d:"M9 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M5 10h11a4 4 0 1 1 0 8h-1",key:"svg-1"}]],hn=K("outline","arrow-back-up","ArrowBackUp",un);const pn=[["path",{d:"M15 14l4 -4l-4 -4",key:"svg-0"}],["path",{d:"M19 10h-11a4 4 0 1 0 0 8h1",key:"svg-1"}]],fn=K("outline","arrow-forward-up","ArrowForwardUp",pn);const gn=[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2",key:"svg-1"}]],Je=K("outline","clipboard","Clipboard",gn);const xn=[["path",{d:"M3 4a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-16",key:"svg-0"}],["path",{d:"M12 3v18",key:"svg-1"}]],Qe=K("outline","columns-2","Columns2",xn);const mn=[["path",{d:"M4 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-0"}],["path",{d:"M14 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-1"}],["path",{d:"M9.15 14.85l8.85 -10.85",key:"svg-2"}],["path",{d:"M6 4l8.85 10.85",key:"svg-3"}]],jn=K("outline","cut","Cut",mn);const yn=[["path",{d:"M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]],Dn=K("outline","dots","Dots",yn);const kn=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M12 11l0 6",key:"svg-2"}],["path",{d:"M9 14l6 0",key:"svg-3"}]],et=K("outline","file-plus","FilePlus",kn);const Cn=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]],bn=K("outline","file-text","FileText",Cn),wn=nn,Mn=sn;function vn({className:n,children:d,...u}){return t.jsx(on,{children:t.jsx(rn,{className:"isolate z-50 outline-none",children:t.jsx(an,{"data-slot":"context-menu-content",className:Te("min-w-44 origin-(--transform-origin) rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",n),...u,children:d})})})}function b({className:n,...d}){return t.jsx(ln,{"data-slot":"context-menu-item",className:Te("flex h-8 cursor-default items-center gap-2 rounded-md px-2 text-xs outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0",n),...d})}function oe({className:n,...d}){return t.jsx(cn,{"data-slot":"context-menu-separator",className:Te("mx-1 my-1 h-px bg-border",n),...d})}const Sn=29,xe=6,tt="files-tree-root-drop",Nn=550,Rn={duration:160,easing:"cubic-bezier(0.2, 0, 0, 1)"},Ye=6,In=n=>{const d=Kt(n),u=d.length>0?d:Lt(n),g=u.find(x=>x.id!==tt);return g?[g]:u.slice(0,1)};function nt(n,d,u=0){const g=[];for(const x of n)g.push({entry:x,depth:u}),x.type==="directory"&&d.has(x.path)&&g.push(...nt(x.children,d,u+1));return g}function En(n,d,u){const g=n.findIndex(p=>p.entry.path===d),x=n.findIndex(p=>p.entry.path===u);if(g===-1||x===-1)return[u];const[l,h]=g<=x?[g,x]:[x,g];return n.slice(l,h+1).map(p=>p.entry.path)}function me(n){return n.type==="directory"?n.path:Ze(n.path)}function Vn({active:n,initialExpandedPaths:d,files:u,filesSnapshotRevision:g,showDotEnvFiles:x,activePath:l,readOnly:h,fileClipboardAvailable:p,revealAvailable:U,historyState:L,onQuickOpen:C,onUndo:A,onRedo:B,onOpenFile:j,onLoadDirectory:w,onPersistExpandedPaths:re,onCopyPath:je,onCopyEntries:ae,onCutEntries:ie,onCopyContents:ye,onPaste:G,onMoveEntries:De,onDeleteEntries:le,onReveal:ke,onRename:Ce,onCreate:be}){const we=Mt(),O=vt(),[P,Me]=i.useState(!1),S=O?44:Sn,ce=i.useRef(null),V=i.useRef(null),[m,R]=i.useState(new Set),[de,X]=i.useState(l),[q,_]=i.useState(l),[N,Z]=i.useState(()=>new Set(d)),[ue,W]=i.useState([]),[M,z]=i.useState(null),[J,ve]=i.useState(null),[_e,st]=i.useState(null),[ot,rt]=i.useState(!1),[at,$]=i.useState(null),[he,it]=i.useState(0),[I,pe]=i.useState(new Map),lt=St(Ve(Ht,{activationConstraint:{distance:5}}),Ve(At)),ze=i.useRef(I),Q=i.useRef(new Set),$e=i.useRef(0),E=i.useRef(null),ee=i.useRef(null),Ke=i.useRef(d.join("\0")),fe=i.useMemo(()=>new Set(I.keys()),[I]),F=i.useMemo(()=>u===null?null:Nt(u,I),[u,I]),f=i.useMemo(()=>F===null?null:x?F:Rt(F),[F,x]);i.useEffect(()=>{ze.current=I},[I]),i.useEffect(()=>{st(document.getElementById(It))},[l]),i.useEffect(()=>{const e=window.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>rt(e.matches);return s(),e.addEventListener("change",s),()=>e.removeEventListener("change",s)},[]),i.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]),i.useEffect(()=>{const e=++$e.current,s=[...ze.current.keys()];s.length!==0&&Promise.all(s.map(async o=>({path:o,children:await w(o)}))).then(o=>{if(e!==$e.current)return;const r=new Map(o.map(({path:c,children:a})=>[c,a]));pe(c=>Et(c,r))})},[g,w]),i.useEffect(()=>{if(!F){Q.current.clear(),pe(e=>e.size===0?e:new Map);return}Z(e=>{const s=new Set(Ft(F,e,fe).retained);return Ge(e,s)?e:s})},[fe,F]),i.useEffect(()=>{if(!F)return;const e=Tt(F,N,fe),s=e.join("\0");s!==Ke.current&&(Ke.current=s,re(e))},[N,fe,F,re]),i.useEffect(()=>{if(!n||!f)return;let e=Math.max(0,2-Q.current.size);for(const s of N){if(e===0)break;const o=T(f,s);!o||o.type!=="directory"||o.ignored!==!0||o.children.length>0||I.has(s)||Q.current.has(s)||(Q.current.add(s),e-=1,w(s).catch(()=>[]).then(r=>{pe(c=>new Map(c).set(s,r))}).finally(()=>{Q.current.delete(s)}))}},[n,N,I,w,f]),i.useEffect(()=>{n||($(null),W([]),z(null),ve(null),E.current&&clearTimeout(E.current),E.current=null,ee.current=null)},[n]),i.useEffect(()=>{f&&(R(e=>{if(e.size===0)return e;const s=new Set([...e].filter(o=>T(f,o)));return s.size===e.size?e:s}),X(e=>e&&T(f,e)?e:null),_(e=>e&&T(f,e)?e:l&&T(f,l)?l:null))},[l,f]);const y=i.useMemo(()=>f?nt(f,N):[],[N,f]),Y=wt({enabled:n,count:y.length,getScrollElement:()=>ce.current,estimateSize:()=>S,getItemKey:e=>y[e]?.entry.path??e,overscan:12,paddingStart:xe,paddingEnd:12});i.useEffect(()=>{Y.measure()},[Y,S]),i.useEffect(()=>{!n||!l||!f||!T(f,l)||Z(e=>{const s=new Set(e);let o=!1;const r=l.split("/");let c="";for(let a=0;a<r.length-1;a+=1)c=c?`${c}/${r[a]}`:r[a],s.has(c)||(s.add(c),o=!0);return o?s:e})},[n,l,f]),i.useEffect(()=>{if(!n)return;if(!l){V.current=null;return}if(V.current===l)return;const e=y.findIndex(s=>s.entry.path===l);e>=0&&(Y.scrollToIndex(e,{align:"auto"}),V.current=l)},[n,l,y]);const Le=i.useMemo(()=>{const e=new Map;for(const s of y)e.set(s.entry.path,s);return e},[y]),te=i.useMemo(()=>{const e={headers:[],push:0};if(y.length===0||!l)return e;const s=new Set,o=l.split("/");let r="";for(let k=0;k<o.length-1;k+=1)r=r?`${r}/${o[k]}`:o[k],s.add(r);if(s.size===0)return e;const c=Math.min(y.length-1,Math.max(0,Math.floor((he-xe)/S))),a=y[c];if(!a)return e;const D=a.entry.path.split("/"),v=[];let se="";for(let k=0;k<D.length-1;k+=1){if(se=se?`${se}/${D[k]}`:D[k],!s.has(se))continue;const Ie=Le.get(se);Ie&&Ie.entry.type==="directory"&&v.push(Ie)}if(v.length>Ye&&v.splice(0,v.length-Ye),v.length===0)return e;const Dt=v[v.length-1],Ue=v.length*S;let Be=1/0;const kt=Math.ceil((he+Ue-xe)/S)+2;for(let k=c;k<y.length&&k<=kt;k+=1)if(y[k].depth<=Dt.depth){Be=xe+k*S;break}const Ct=Math.max(0,Math.min(S,Ue-(Be-he)));return{headers:v,push:Ct}},[y,Le,he,l,S]);if(f===null)return t.jsx("div",{className:"view-loading",role:"status",hidden:!n,children:t.jsx(Pt,{text:"Loading files…"})});const ct=P||m.size>0?m:l?new Set([l]):new Set,dt=m.size>0?[...m]:l?[l]:[],Se=e=>{const s=[];for(const o of e){const r=T(f,o);r&&s.push(r)}return s},Ne=e=>{R(new Set([e])),X(e),_(e)},ut=e=>{const s=y.findIndex(o=>o.entry.path===e.path);s>=0&&Y.scrollToIndex(s,{align:"start"})},ht=(e,s)=>{if(O&&P){R(o=>{const r=new Set(o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r});return}if(s.shift&&(de||q)){const o=En(y,de??q,e.path);R(new Set(o)),_(e.path);return}if(s.ctrl){R(o=>{const r=new Set(o.size===0&&l?[l]:o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r}),X(e.path),_(e.path),e.type==="file"&&j(e.path,"pinned");return}Ne(e.path),e.type==="file"?j(e.path):Ae(e.path)},pt=e=>{!(O&&P)&&e.type==="file"&&j(e.path,"pinned")},ft=e=>{m.has(e.path)||Ne(e.path)},ge=e=>m.has(e.path)&&m.size>0?Se(m):[e],gt=e=>{if(Vt(e.target))return;const s=Xt(e.nativeEvent,we);if(s==="undo"&&L.canUndo&&!h){e.preventDefault(),e.repeat||A();return}if(s==="redo"&&L.canRedo&&!h){e.preventDefault(),e.repeat||B();return}const o=(e.ctrlKey||e.metaKey)&&!e.altKey,r=e.key.toLowerCase();if(o&&r==="a"){e.preventDefault(),R(new Set(y.map(D=>D.entry.path)));return}const c=Se(dt),a=q?T(f,q):null;if(o&&r==="c"&&c.length){e.preventDefault(),ae(c);return}if(o&&r==="x"&&c.length&&!h){e.preventDefault(),ie(c);return}if(o&&r==="v"&&!h&&p){e.preventDefault();const D=a?me(a):Ze(c[0]?.path??"");G(D);return}if(e.key==="F2"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h){if(m.size===1){const D=T(f,[...m][0]);D&&(e.preventDefault(),$({mode:"rename",entry:D}))}return}e.key==="Delete"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h&&c.length&&(e.preventDefault(),le(c))},xt=async(e,s)=>{const o=Se(e);o.length&&await De(o,s)},Ae=(e,s=!1)=>{const o=!s&&N.has(e),r=o&&T(f??[],e)?.ignored===!0;Z(c=>{const a=new Set(c);if(s||!a.has(e)){if(a.has(e))return c;a.add(e)}else if(r)for(const D of a)Ee(e,D)&&a.delete(D);else a.delete(e);return Ge(c,a)?c:a}),o&&pe(c=>{const a=[...c.keys()].filter(v=>Ee(e,v));if(a.length===0)return c;const D=new Map(c);for(const v of a)D.delete(v);return D})},ne=()=>{E.current&&clearTimeout(E.current),E.current=null,ee.current=null},He=()=>{ne(),W([]),z(null),ve(null)},Re=e=>{const s=e.active.data.current;return s?.entry&&Array.isArray(s.sourcePaths)?{entry:s.entry,sourcePaths:s.sourcePaths}:null},mt=e=>{const s=Re(e);s&&(m.has(s.entry.path)||Ne(s.entry.path),W(s.sourcePaths),ve({entry:s.entry,sourcePaths:s.sourcePaths,count:s.sourcePaths.length}))},jt=e=>{const s=Re(e);if(e.over?.data.current?.openPinned===!0){z(null),ne();return}const o=e.over?.data.current?.targetDirectory;if(!s||typeof o!="string"||!qe(s.sourcePaths,o)){z(null),ne();return}z(o);const r=e.over?.data.current?.expandPath;if(typeof r!="string"||N.has(r)){ne();return}ee.current!==r&&(ne(),ee.current=r,E.current=setTimeout(()=>{Ae(r,!0),E.current=null,ee.current=null},Nn))},yt=e=>{const s=Re(e),o=e.over?.data.current?.openPinned===!0,r=e.over?.data.current?.targetDirectory;if(He(),s&&o&&Xe(s.entry,s.sourcePaths)){j(s.entry.path,"pinned");return}s&&typeof r=="string"&&qe(s.sourcePaths,r)&&xt(s.sourcePaths,r)};return t.jsxs(_t,{sensors:lt,collisionDetection:In,autoScroll:{enabled:!0,threshold:{x:.1,y:.16},acceleration:12},onDragStart:mt,onDragOver:jt,onDragCancel:He,onDragEnd:yt,children:[t.jsxs("div",{className:"files-mobile-tools",children:[t.jsxs(H,{variant:"ghost",size:"sm",onClick:C,children:[t.jsx(zt,{})," Find file"]}),t.jsx(H,{variant:"ghost",size:"sm","aria-pressed":P,onClick:()=>{Me(!P),R(new Set)},children:P?`Done (${m.size})`:"Select"}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-file",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(et,{})," New file"]}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-folder",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(We,{})," Folder"]}),p&&t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>{G("")},children:[t.jsx(Je,{})," Paste"]})]}),t.jsxs("div",{ref:ce,className:"files-view virtual-scroll",hidden:!n,onScroll:e=>it(e.currentTarget.scrollTop),children:[te.headers.length>0&&t.jsx("div",{className:"files-sticky",children:te.headers.map((e,s)=>{const o=s===te.headers.length-1;return t.jsxs("button",{type:"button",className:"file-tree-row files-sticky-row","aria-label":`Scroll to ${e.entry.path}`,style:{top:s*S-(o?te.push:0),paddingLeft:12+e.depth*14,zIndex:te.headers.length-s},onClick:()=>ut(e.entry),children:[t.jsx(Oe,{className:"folder-chevron open"}),t.jsx(Pe,{path:e.entry.path,type:"directory",expanded:!0}),t.jsx("span",{children:e.entry.name})]},e.entry.path)})}),f.length?t.jsx(Fn,{role:"tree","aria-label":"Files",className:`files-tree ${M===""&&ue.length>0?"root-drop-target":""}`,style:{height:Y.getTotalSize()},tabIndex:0,onKeyDown:gt,onPointerDown:e=>{e.target.closest(".file-tree-row, .file-touch-actions")||(R(new Set),X(null),_(null),e.currentTarget.focus())},children:Y.getVirtualItems().map(e=>{const{entry:s,depth:o}=y[e.index],r=s.type==="directory"&&N.has(s.path),c=m.has(s.path)&&m.size>1;return t.jsx("div",{className:"virtual-row",style:{height:e.size,transform:`translateY(${e.start}px)`},children:t.jsx(_n,{entry:s,depth:o,expanded:r,pendingChildren:s.type==="directory"&&s.ignored===!0&&s.children.length===0&&!I.has(s.path),selected:ct.has(s.path),active:l===s.path,multiSelected:c,readOnly:h,fileClipboardAvailable:p,revealAvailable:U,historyState:L,onUndo:A,onRedo:B,draggedPaths:ue,dropTargetPath:M,onFocus:_,onRowClick:ht,onRowDoubleClick:pt,onRowContextMenu:ft,onOpen:a=>j(a.path),onOpenPinned:a=>j(a.path,"pinned"),onCopy:a=>{ae(ge(a))},onCut:a=>{ie(ge(a))},onPasteInto:a=>{G(me(a))},onCopyPath:a=>{je(ge(a))},onCopyContents:ye,onRename:a=>$({mode:"rename",entry:a}),onNewFile:a=>$({mode:"new-file",entry:a}),onNewFolder:a=>$({mode:"new-folder",entry:a}),onReveal:ke,onDelete:a=>{le(ge(a))},dragPaths:m.has(s.path)&&m.size>0?[...m]:[s.path]})},e.key)})}):t.jsx("p",{className:"empty-list",children:"No files."}),t.jsx(zn,{state:at,onClose:()=>$(null),onRename:Ce,onCreate:be})]}),t.jsx($t,{dropAnimation:ot?null:Rn,children:J&&t.jsx(Pn,{preview:J})}),_e&&bt.createPortal(t.jsx(Tn,{visible:!!(J&&Xe(J.entry,J.sourcePaths))}),_e)]})}function Fn(n){const{setNodeRef:d}=Fe({id:tt,data:{targetDirectory:"",expandPath:null}});return t.jsx("div",{ref:d,...n})}function Tn({visible:n}){const{isOver:d,setNodeRef:u}=Fe({id:"files-open-pinned-drop",data:{openPinned:!0}});return t.jsxs("div",{ref:u,className:`open-files-drop-target ${n?"visible":""} ${n&&d?"over":""}`,"aria-hidden":"true",children:[t.jsx(Qe,{}),t.jsx("span",{children:"Drop to open beside"})]})}function Pn({preview:n}){return t.jsxs("div",{className:"file-drag-overlay",children:[t.jsx(Pe,{path:n.entry.path,type:n.entry.type,expanded:!1}),t.jsx("span",{children:n.entry.name}),n.count>1&&t.jsx("strong",{children:n.count})]})}function Ge(n,d){if(n.size!==d.size)return!1;for(const u of n)if(!d.has(u))return!1;return!0}function _n({entry:n,depth:d,expanded:u,pendingChildren:g,selected:x,active:l,multiSelected:h,readOnly:p,fileClipboardAvailable:U,revealAvailable:L,historyState:C,onUndo:A,onRedo:B,draggedPaths:j,dropTargetPath:w,onFocus:re,onRowClick:je,onRowDoubleClick:ae,onRowContextMenu:ie,onOpen:ye,onOpenPinned:G,onCopy:De,onCut:le,onPasteInto:ke,onCopyPath:Ce,onCopyContents:be,onRename:we,onNewFile:O,onNewFolder:P,onReveal:Me,onDelete:S,dragPaths:ce}){const V=i.useRef(null),m=me(n),{attributes:R,listeners:de,setNodeRef:X,isDragging:q}=qt({id:`file-drag:${n.path}`,data:{sourcePaths:ce,entry:n},disabled:p}),{setNodeRef:_}=Fe({id:`file-drop:${n.path}`,data:{targetDirectory:m,expandPath:n.type==="directory"?n.path:null}}),N=M=>{V.current=M,X(M),_(M)},Z=j.length>0&&n.type==="directory"&&w===n.path,ue=j.length>0&&w!==null&&w!==""&&w!==n.path&&Ee(w,n.path),W=t.jsxs("button",{type:"button",ref:N,...R,role:"treeitem","aria-selected":x,"aria-current":l?"true":void 0,"aria-expanded":n.type==="directory"?u:void 0,className:["file-tree-row",n.ignored?"ignored-file":"",j.includes(n.path)||q?"dragging":"",Z?"drop-target":"",ue?"drop-target-region":""].filter(Boolean).join(" "),style:{paddingLeft:12+d*14},...de,onClick:M=>je(n,{ctrl:M.ctrlKey||M.metaKey,shift:M.shiftKey}),onDoubleClick:()=>ae(n),onFocus:()=>re(n.path),onContextMenu:()=>ie(n),children:[n.type==="directory"?t.jsx(Oe,{className:`folder-chevron ${u?"open":""} ${n.children.length===0&&!g?"empty":""}`}):t.jsx("span",{className:"tree-spacer"}),t.jsx(Pe,{path:n.path,type:n.type,expanded:u}),t.jsx("span",{children:n.name})]});return t.jsxs(wn,{children:[t.jsx(Mn,{render:W}),t.jsx("button",{type:"button",className:"file-touch-actions","aria-label":`Actions for ${n.name}`,"aria-haspopup":"menu",onClick:M=>{M.stopPropagation();const z=M.currentTarget.getBoundingClientRect();V.current?.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:z.left,clientY:z.bottom}))},children:t.jsx(Dn,{})}),t.jsxs(vn,{children:[n.type==="file"&&t.jsxs(t.Fragment,{children:[t.jsxs(b,{onClick:()=>ye(n),children:[t.jsx(Yt,{"aria-hidden":"true"})," Open"]}),t.jsxs(b,{onClick:()=>G(n),children:[t.jsx(Qe,{"aria-hidden":"true"})," Open to the Side ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Click"})]}),t.jsx(oe,{})]}),t.jsxs(b,{disabled:p||!C.canUndo,onClick:()=>{A()},children:[t.jsx(hn,{"aria-hidden":"true"})," ",C.undoLabel?`Undo ${C.undoLabel}`:"Undo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Z"})]}),t.jsxs(b,{disabled:p||!C.canRedo,onClick:()=>{B()},children:[t.jsx(fn,{"aria-hidden":"true"})," ",C.redoLabel?`Redo ${C.redoLabel}`:"Redo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Shift+Z"})]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>De(n),children:[t.jsx(Gt,{"aria-hidden":"true"})," Copy ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+C"})]}),t.jsxs(b,{disabled:p,onClick:()=>le(n),children:[t.jsx(jn,{"aria-hidden":"true"})," Cut ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+X"})]}),U&&t.jsxs(b,{disabled:p,onClick:()=>ke(n),children:[t.jsx(Je,{"aria-hidden":"true"})," Paste ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+V"})]}),t.jsx(oe,{}),t.jsxs(b,{disabled:p||h,onClick:()=>we(n),children:[t.jsx(dn,{"aria-hidden":"true"})," Rename ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"F2"})]}),t.jsxs(b,{disabled:p||h,onClick:()=>O(n),children:[t.jsx(et,{"aria-hidden":"true"})," New File…"]}),t.jsxs(b,{disabled:p||h,onClick:()=>P(n),children:[t.jsx(We,{"aria-hidden":"true"})," New Folder…"]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>Ce(n),children:[t.jsx(bn,{"aria-hidden":"true"})," Copy path"]}),t.jsxs(b,{disabled:n.type!=="file"||h,onClick:()=>{be(n)},children:[t.jsx(tn,{"aria-hidden":"true"})," Copy contents"]}),L&&t.jsxs(b,{disabled:h,onClick:()=>{Me(n)},children:[t.jsx(Ot,{"aria-hidden":"true"})," Reveal in File Explorer"]}),t.jsx(oe,{}),t.jsxs(b,{className:"text-destructive data-highlighted:text-destructive",disabled:p,onClick:()=>S(n),children:[t.jsx(Zt,{"aria-hidden":"true"})," Delete ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Del"})]})]})]})}function zn({state:n,onClose:d,onRename:u,onCreate:g}){const[x,l]=i.useState("");if(i.useEffect(()=>{n&&l(n.mode==="rename"?n.entry.name:"")},[n]),!n)return null;const h=n.mode==="rename",p=n.mode==="new-folder"?"directory":"file",U=me(n.entry),L=h?"Rename":p==="directory"?"New Folder":"New File",C=x.trim(),A=C.length>0&&!/[\\/]/.test(C)&&!(h&&C===n.entry.name),B=()=>{A&&(h?u(n.entry,C):g(U,C,p),d())};return t.jsx(Wt,{open:!0,onOpenChange:j=>{j||d()},children:t.jsx(Jt,{className:"name-dialog",children:t.jsxs("form",{className:"name-dialog-content",onSubmit:j=>{j.preventDefault(),B()},children:[t.jsx(Qt,{children:L}),t.jsx(en,{children:h?t.jsxs(t.Fragment,{children:["Enter a new name for ",t.jsx("code",{children:n.entry.name}),"."]}):t.jsxs(t.Fragment,{children:["Create a new ",p==="directory"?"folder":"file"," in ",t.jsx("code",{children:U||"the repository root"}),"."]})}),t.jsx("input",{autoFocus:!0,className:"name-dialog-input",value:x,maxLength:255,placeholder:h?"New name":p==="directory"?"Folder name":"File name",onChange:j=>l(j.target.value),onFocus:j=>{if(!h)return;const w=n.entry.name.lastIndexOf(".");j.target.setSelectionRange(0,w>0?w:n.entry.name.length)}}),t.jsxs("div",{className:"name-dialog-actions",children:[t.jsx(H,{type:"button",variant:"ghost",onClick:d,children:"Cancel"}),t.jsx(H,{type:"submit",disabled:!A,children:h?"Rename":"Create"})]})]})})})}function Pe({path:n,type:d,expanded:u=!1}){const g=d==="file"?Ut(n):Bt(n,u);return t.jsx("img",{className:"vscode-tree-icon",src:g,alt:"","aria-hidden":"true"})}export{Vn as FilesView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as r,T as g,a as x,b as v,B as j,o as M,q as C}from"./index-ChKJF4C_.js";import{r as m,j as e}from"./react-rd22PHbN.js";import{u as N}from"./tanstack-CtfgE41X.js";import{M as y,x as b}from"./App-CGiS2z40.js";import{P,f as R,g as S,h as _,i as E}from"./base-ui-DT3JsyND.js";const I=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]],X=r("outline","circle-check","CircleCheck",I);const $=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M10 10l4 4m0 -4l-4 4",key:"svg-1"}]],A=r("outline","circle-x","CircleX",$);const q=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 7v5l3 3",key:"svg-1"}]],H=r("outline","clock","Clock",q);const T=[["path",{d:"M5 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M15 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M7 8l0 8",key:"svg-3"}],["path",{d:"M7 8a4 4 0 0 0 4 4h4",key:"svg-4"}]],G=r("outline","git-merge","GitMerge",T);const F=[["path",{d:"M12 4l-8 4l8 4l8 -4l-8 -4",key:"svg-0"}],["path",{d:"M4 12l8 4l8 -4",key:"svg-1"}],["path",{d:"M4 16l8 4l8 -4",key:"svg-2"}]],O=r("outline","stack-2","Stack2",F);const z=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 10a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-1"}],["path",{d:"M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855",key:"svg-2"}]],D=r("outline","user-circle","UserCircle",z);function Q({repositoryId:c,number:n,membership:o,onSelect:l}){const[d,k]=m.useState(!1),a=N({queryKey:C.pullRequestStack(c,n),queryFn:()=>M.github.getPullRequestStack(c,n),enabled:d,staleTime:0}),t=a.data,h=t?t.layers.findIndex(s=>s.number===n)+1:o.position,u=t?.layers.length??o.size,i=t?.number??o.number;return a.isSuccess&&t===null&&!d?null:e.jsxs(P,{open:d,onOpenChange:k,children:[e.jsxs(g,{children:[e.jsxs(x,{render:e.jsx(R,{render:e.jsx("button",{className:"pr-stack-trigger","aria-label":`Stack ${i}, layer ${h} of ${u}`})}),children:[e.jsx(O,{"aria-hidden":"true"})," ",h,"/",u]}),e.jsxs(v,{children:["View stack #",i," · layer ",h," of ",u]})]}),e.jsx(S,{children:e.jsx(_,{side:"bottom",align:"start",sideOffset:6,className:"isolate z-50 outline-none",children:e.jsxs(E,{className:"pr-stack-popup","aria-label":`Stack #${i}`,children:[e.jsxs("div",{className:"pr-stack-heading",children:[e.jsxs("strong",{children:["Stack #",i]}),e.jsx(j,{variant:"ghost",size:"xs",disabled:a.isFetching,onClick:()=>{a.refetch()},children:"Refresh"})]}),a.isFetching&&e.jsx("p",{className:"pr-stack-notice",role:"status",children:t?"Refreshing stack…":"Loading stack…"}),a.isError&&e.jsxs("div",{className:"pr-stack-notice",role:"status",children:[e.jsx("p",{children:t?"Could not refresh. Showing saved layers.":"Could not load the stack."}),e.jsx(j,{variant:"outline",size:"xs",onClick:()=>{a.refetch()},children:"Retry"})]}),t===null&&!a.isFetching&&!a.isError&&e.jsx("p",{className:"pr-stack-notice",children:"This PR is no longer in a stack, or stack data is unavailable."}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pr-stack-layers",children:[...t.layers].reverse().map(s=>{const p=s.isDraft&&s.state==="OPEN"?"Draft":s.state==="MERGED"?"Merged":s.state==="CLOSED"?"Closed":"Open",f=s.state==="MERGED"?G:y;return e.jsxs(g,{children:[e.jsxs(x,{render:e.jsx("button",{className:"pr-stack-layer","aria-current":s.number===n?"true":void 0,onClick:()=>{k(!1),l(s.number)}}),children:[e.jsx(f,{className:`pr-stack-state ${p.toLowerCase()}`,"aria-hidden":"true"}),e.jsxs("span",{className:"pr-stack-layer-text",children:[e.jsx("strong",{children:s.title}),e.jsxs("small",{children:["#",s.number," · ",s.headRefName," · ",p]})]}),s.number===n&&e.jsx(b,{"aria-hidden":"true"})]}),e.jsxs(v,{children:[s.title," · ",s.headRefName," · ",p]})]},s.number)})}),e.jsxs("div",{className:"pr-stack-base",children:["↳ ",t.base]})]})]})})})]})}function V({src:c,className:n}){const[o,l]=m.useState(!1);return e.jsx("span",{className:n,"aria-hidden":"true",children:c&&!o?e.jsx("img",{src:c,alt:"",onError:()=>l(!0)}):e.jsx(D,{})})}export{V as G,X as I,Q as P,A as a,H as b,G as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as w,j as e}from"./react-rd22PHbN.js";import{a as te}from"./tanstack-CtfgE41X.js";import{T as N,a as y,b as C,B as Y,o as ne,w as ae,s as X}from"./index-ChKJF4C_.js";import{k as Q,G as J,j as re,P as oe,Q as ie,R as le,U as ce,M as de,V as he,W as ue,X as me}from"./App-CGiS2z40.js";import"./base-ui-DT3JsyND.js";function pe(s){let n=[],a=s.some(i=>i.color!==void 0)?3:0,t=1;const r=new Map,j=[],l=new Map(s.map(i=>[i.oid,i])),u=new Set;let d=s[0];for(;d&&!u.has(d.oid);)u.add(d.oid),d.color!==void 0&&r.set(d.oid,d.color),d=l.get(d.parentOids[0]??"");for(const i of s){let h=n.indexOf(i.oid);const p=h>=0;h<0&&(h=n.length,n=[...n,i.oid]);const f=n,v=xe(r,i.oid,()=>i.color??a++),x=v<3?i.color??v:v;r.set(i.oid,x);const b=f.filter((g,c)=>c!==h);let M=Math.min(h,b.length);i.parentOids.forEach((g,c)=>{r.has(g)||r.set(g,c===0?x:a++),!b.includes(g)&&(b.splice(M,0,g),M+=1)});const L=[];f.forEach((g,c)=>{if(c===h){p&&L.push({fromLane:c,from:"top",toLane:h,to:"node",color:v});return}const I=b.indexOf(g);I>=0&&L.push({fromLane:c,from:"top",toLane:I,to:"bottom",color:r.get(g)??0})}),i.parentOids.forEach(g=>{const c=b.indexOf(g);c>=0&&L.push({fromLane:h,from:"node",toLane:c,to:"bottom",color:r.get(g)??x})}),t=Math.max(t,f.length,b.length),j.push({lane:h,color:x,segments:L,continuations:b.map((g,c)=>({lane:c,color:r.get(g)??0}))}),n=b}return{rows:j,laneCount:t}}function xe(s,n,a){const t=s.get(n);if(t!==void 0)return t;const r=a();return s.set(n,r),r}function je(s){const n=s.parentCount>1&&/^Merge pull request #(\d+)\b/i.exec(s.subject),a=/\(#(\d+)\)\s*$/.exec(s.subject),t=n||a;if(!t)return null;const r=Number(t[1]);return Number.isSafeInteger(r)&&r>0?{number:r,source:n?"merge":"subject"}:null}function fe(s){if(s.upstreamState==="local-only")return 0;if(s.baseState==="included")return 2;if(s.upstreamState==="published")return 1}function ge(s,n){if(!n)return s.map(l=>({commit:l,parentOids:l.parentOids,grouped:[]}));const a=new Map(s.map(l=>[l.oid,l])),t=new Map;s.forEach(l=>l.parentOids.forEach(u=>{const d=t.get(u)??new Set;d.add(l.oid),t.set(u,d)}));const r=new Set,j=[];for(const l of s){if(r.has(l.oid))continue;const u={commit:l,parentOids:l.parentOids,grouped:[]};if(j.push(u),l.parentOids.length!==2)continue;const d=new Set;let i=a.get(l.parentOids[0]);for(;i&&!d.has(i.oid);)d.add(i.oid),i=a.get(i.parentOids[0]??"");let h=l.parentOids[1];const p=[],f=new Set;for(;!d.has(h);){const x=a.get(h);if(!x||f.has(h)||r.has(h)||x.isHead||x.parentOids.length!==1)break;f.add(h),p.push(x),h=x.parentOids[0]}if(!d.has(h)||p.length===0)continue;const v=new Set([l.oid,...p.map(x=>x.oid)]);p.some(x=>[...t.get(x.oid)??[]].some(b=>!v.has(b)))||p.some(x=>j.some(b=>b.commit.oid===x.oid))||(u.grouped=p,u.parentOids=[l.parentOids[0]],p.forEach(x=>r.add(x.oid)))}return j}function K(s,n){const a=n.trim().toLocaleLowerCase();return a.length>0&&[s.subject,s.author,s.oid,...s.decorations].some(t=>t.toLocaleLowerCase().includes(a))}function Re({repositoryId:s,upstream:n,readOnly:a,operation:t,canPublish:r,pushBusy:j,onPublish:l,commits:u,nextCursor:d,loading:i,undoing:h,baseRef:p,activeOid:f,onSelectReference:v,onSelectCommit:x,onSelectFile:b,onUndo:M,onMore:L}){const g=w.useRef(null),[c,I]=w.useState(new Set),[$,z]=w.useState(!0),[k,A]=w.useState(!1),[E,P]=w.useState(""),[V,R]=w.useState(-1),F=$?42:56,o=w.useMemo(()=>ge(u??[],k&&!E.trim()),[u,k,E]),O=w.useMemo(()=>pe(o.map(({commit:m,parentOids:S})=>({oid:m.oid,parentOids:S,color:fe(m)}))),[o]),H=w.useMemo(()=>o.flatMap(({commit:m},S)=>K(m,E)?[S]:[]),[o,E]),ee=ye(O.laneCount),T=te({count:o.length,getScrollElement:()=>g.current,estimateSize:()=>F,getItemKey:m=>o[m].commit.oid,overscan:8});w.useEffect(()=>{T.measure()},[T,$,k,E]);const B=()=>{if(!H.length)return;const m=(V+1)%H.length;R(m),T.scrollToIndex(H[m],{align:"center"})};if(u===null)return e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(Q,{className:"spinner"})," ",e.jsx(J,{text:"Loading history…"})]});const q=u.filter(m=>m.upstreamState==="local-only").length;return e.jsxs("div",{className:"history-list",style:{"--history-row-height":`${F}px`},children:[e.jsxs("div",{className:"history-toolbar",children:[e.jsxs("label",{className:"history-search",children:[e.jsx(re,{"aria-hidden":"true"}),e.jsx("input",{type:"search","aria-label":"Search loaded commits",placeholder:"Find commit…",value:E,onChange:m=>{P(m.target.value),R(-1)},onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),B())}})]}),E&&e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"history-next-match",onClick:B,disabled:!H.length,"aria-label":"Next matching commit"}),children:e.jsx(oe,{})}),e.jsx(C,{children:"Next match in loaded history (Enter)"})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"history-option","aria-pressed":k,disabled:!u.some(m=>m.parentCount>1),onClick:()=>A(!k)}),children:"Group merges"}),e.jsx(C,{children:"Collapse complete merge branches. Searching reveals their commits."})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"history-option","aria-pressed":$,onClick:()=>z(!$)}),children:$?"Compact":"Comfortable"}),e.jsx(C,{children:"Change row density without moving the diff viewer"})]})]}),!n&&u.length>0&&e.jsxs("div",{className:"history-upstream-notice",role:"status",children:[e.jsx("span",{children:"Publish this branch to configure an upstream and distinguish local from published commits."}),r&&e.jsx(Y,{variant:"outline",size:"xs",disabled:j||a||!!t,onClick:l,children:j?"Publishing…":"Publish branch"})]}),n&&q>0&&e.jsxs("div",{className:"history-local-summary",children:["↑ ",q," ",q===1?"local commit":"local commits"," in loaded history"]}),e.jsx("div",{ref:g,className:"history-scroll",role:"list","aria-label":"Commit history",children:o.length===0?e.jsx("p",{className:"empty-list",children:"This repository has no commits yet."}):e.jsxs("div",{className:"virtual-list",style:{height:T.getTotalSize()+(d?52:0)},children:[T.getVirtualItems().map(m=>{const{commit:S,grouped:W}=o[m.index];return e.jsx("div",{ref:T.measureElement,"data-index":m.index,className:"virtual-row",style:{transform:`translateY(${m.start}px)`},children:e.jsx(be,{repositoryId:s,upstream:n,baseRef:p,commit:S,graphRow:O.rows[m.index],graphWidth:ee,rowHeight:F,active:f===S.oid||W.some(U=>U.oid===f),match:K(S,E),groupedCount:W.length,onRevealGroup:()=>A(!1),onSelectReference:v,expanded:c.has(S.oid),onExpandedChange:U=>I(se=>{const _=new Set(se);return U?_.add(S.oid):_.delete(S.oid),_}),canUndo:!a&&!t&&!h&&S.upstreamState==="local-only"&&S.isHead&&S.parentCount===1,onSelectCommit:x,onSelectFile:b,onUndo:M})},m.key)}),d&&e.jsx(Y,{variant:"ghost",className:"history-more",style:{top:T.getTotalSize()},disabled:i,onClick:L,children:i?"Loading…":"Load more"})]})}),u.length>0&&e.jsxs("div",{className:"history-legend",children:[e.jsxs("span",{children:[e.jsx("i",{"data-color":"local"}),"Local"]}),e.jsxs("span",{children:[e.jsx("i",{"data-color":"published"}),"Published"]}),p&&e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("span",{className:"history-base-label"}),children:[e.jsx("i",{"data-color":"base"}),p]}),e.jsxs(C,{children:["Primary-line commits reachable from ",p,", using the latest known local refs. Side branches use the published color."]})]}),e.jsx("span",{className:"history-count",role:"status",children:E?`${H.length} matches in ${u.length} loaded`:`${u.length} loaded`})]})]})}function be({repositoryId:s,upstream:n,baseRef:a,commit:t,graphRow:r,graphWidth:j,rowHeight:l,active:u,match:d,groupedCount:i,onRevealGroup:h,onSelectReference:p,expanded:f,onExpandedChange:v,canUndo:x,onSelectCommit:b,onSelectFile:M,onUndo:L}){const g=`${s}:${t.oid}`,[c,I]=w.useState(()=>ie(g)??null),[$,z]=w.useState(null);w.useEffect(()=>{if(!f||c||$)return;let o=!0;return ne.commits.files(s,t.oid).then(O=>{o&&(le(g,O),I(O))}).catch(O=>{o&&z(Te(O))}),()=>{o=!1}},[g,t.oid,f,c,$,s]);const k=je(t),A=Se(t.decorations),E=A.slice(0,3),P=A.slice(3),V=c?.reduce((o,O)=>o+O.additions,0)??0,R=c?.reduce((o,O)=>o+O.deletions,0)??0,F=async()=>{try{await ae(t.oid),X.success({title:"Hash copied",description:t.oid})}catch{X.error({title:"Could not copy hash"})}};return e.jsxs("div",{className:`commit-item${u?" active":""}${d?" search-match":""}`,role:"listitem",children:[e.jsxs("div",{className:"commit-header",children:[e.jsx(Ce,{graph:r,width:j,height:l,merge:t.parentCount>1,head:t.isHead}),e.jsx("button",{className:"commit-expand","aria-expanded":f,"aria-label":f?"Collapse commit":"Expand commit",onClick:()=>v(!f),children:e.jsx(ce,{className:`folder-chevron ${f?"open":""}`})}),e.jsxs("div",{className:"commit-main",children:[e.jsxs("span",{className:"commit-title-row",children:[e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"commit-subject","aria-pressed":u,onClick:()=>b(t)}),children:t.subject||"(no subject)"}),e.jsxs(C,{side:"right",children:[t.subject||"(no subject)",e.jsx("br",{}),"Open the full commit diff"]})]}),k&&e.jsxs(N,{children:[e.jsxs(y,{render:p?e.jsx("button",{className:"ref-chip commit-pr",onClick:()=>p(k.number),"aria-label":`Open pull request #${k.number}`}):e.jsx("span",{className:"ref-chip commit-pr"}),children:[e.jsx(de,{"aria-hidden":"true"}),"#",k.number]}),e.jsxs(C,{children:[k.source==="merge"?"Pull request reference from the merge message.":"Reference from the commit subject; it may identify a pull request or issue.",p?" Open as a pull request in the right-hand viewer.":""," No merge method is inferred from the number."]})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:"commit-date"}),children:Ee(t.date)}),e.jsx(C,{children:Oe(t.date)})]})]}),e.jsxs("span",{className:"commit-meta",children:[(A.length>0||t.parentCount>1||t.upstreamState==="local-only")&&e.jsxs("span",{className:"commit-refs",children:[t.upstreamState==="local-only"&&e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:"ref-chip local-only"}),children:"Local"}),e.jsx(C,{children:t.isHead?`Not in ${n??"the upstream"} according to the latest known remote state.`:"Not published. To avoid rewriting multiple commits, only the latest can be undone."})]}),t.parentCount>1&&e.jsx("span",{className:"ref-chip merge",children:"merge"}),E.map(o=>e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:`ref-chip ${o.kind}`,"data-base":o.label===a||o.label.endsWith("/HEAD")&&t.baseState==="included"}),children:o.label}),e.jsx(C,{children:o.label})]},`${o.kind}:${o.label}`)),P.length>0&&e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("span",{className:"ref-chip more"}),children:["+",P.length]}),e.jsx(C,{children:P.map(o=>o.label).join(" · ")})]})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"commit-oid",onClick:()=>{F()},"aria-label":`Copiar hash ${t.shortOid}`}),children:t.shortOid}),e.jsx(C,{children:"Copy full hash"})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:"commit-author"}),children:t.author}),e.jsx(C,{children:t.author})]}),i>0&&e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("button",{className:"commit-group-count",onClick:h}),children:[i," grouped"]}),e.jsxs(C,{children:["Show the ",i," commits in this merge branch"]})]})]})]}),x&&e.jsxs(N,{children:[e.jsx(y,{render:e.jsx(Y,{variant:"ghost",size:"icon-xs",className:"change-action-button commit-undo",onClick:o=>{o.stopPropagation(),L(t)},"aria-label":`Undo commit ${t.shortOid}`}),children:e.jsx(he,{})}),e.jsx(C,{children:"Undo commit and keep its changes staged"})]})]}),f&&r.continuations.length>0&&e.jsx(we,{graph:r,width:j}),f&&e.jsxs("div",{className:"commit-files",style:{paddingLeft:j+31},children:[t.body&&e.jsx("p",{className:"commit-description",children:t.body}),$&&e.jsx("div",{className:"commit-files-message error",children:$}),!c&&!$&&e.jsxs("div",{className:"commit-files-message",children:[e.jsx(Q,{className:"spinner"})," ",e.jsx(J,{text:"Loading files…"})]}),c&&c.length===0&&e.jsx("div",{className:"commit-files-message",children:"This commit does not modify its own files (merge)."}),c&&c.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"commit-files-summary",children:[c.length," ",c.length===1?"file":"files",(V>0||R>0)&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"add",children:["+",V]})," ",e.jsxs("span",{className:"del",children:["−",R]})]})]}),c.map(o=>e.jsx(ve,{file:o,onSelect:()=>M(t.oid,o)},o.path))]})]})]})}const Z=14,Ne=["var(--history-local)","var(--history-published)","var(--history-base)"];function ye(s){return 14+Math.max(0,s-1)*Z}function D(s){return 7+s*Z}function G(s){return Ne[s]??"var(--history-published)"}function Ce({graph:s,width:n,height:a,merge:t,head:r}){const j=a/2;return e.jsxs("svg",{className:"commit-graph",width:n,height:a,viewBox:`0 0 ${n} ${a}`,"aria-hidden":"true",children:[s.segments.map((l,u)=>{const d=D(l.fromLane),i=D(l.toLane),h=l.from==="top"?0:j,p=l.to==="node"?j:a,f=(h+p)/2,v=d===i?`M ${d} ${h} L ${i} ${p}`:`M ${d} ${h} C ${d} ${f}, ${i} ${f}, ${i} ${p}`;return e.jsx("path",{d:v,stroke:G(l.color)},`${u}:${v}`)}),e.jsx("circle",{cx:D(s.lane),cy:j,r:t||r?4.5:3,fill:t||r?"var(--sidebar)":G(s.color),stroke:G(s.color)}),t&&e.jsx("circle",{cx:D(s.lane),cy:j,r:"1.6",fill:G(s.color)})]})}function we({graph:s,width:n}){return e.jsx("svg",{className:"commit-graph-continuation",width:n,viewBox:`0 0 ${n} 100`,preserveAspectRatio:"none","aria-hidden":"true",children:s.continuations.map(a=>e.jsx("line",{x1:D(a.lane),y1:"0",x2:D(a.lane),y2:"100",stroke:G(a.color)},a.lane))})}function ve({file:s,onSelect:n}){const a=w.useRef(null),t=s.path.lastIndexOf("/"),r=t<0?s.path:s.path.slice(t+1),j=s.oldPath?.split("/").pop();return e.jsxs("div",{ref:a,className:"commit-file-row",children:[e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("button",{className:"commit-file-label",onClick:n,"aria-label":`Ver el diff de ${s.path}`}),children:[e.jsx(Le,{path:s.path,type:"file"}),e.jsxs("span",{className:"commit-file-text",children:[e.jsx("span",{children:r}),j&&e.jsxs("small",{className:"commit-file-rename",children:[j," →"]})]})]}),e.jsx(C,{anchor:a,side:"right",sideOffset:10,children:s.oldPath?`${s.oldPath} → ${s.path}`:s.path})]}),e.jsx("span",{className:"commit-file-stats",children:s.binary?e.jsx("span",{className:"binary",children:"bin"}):e.jsxs(e.Fragment,{children:[s.additions>0&&e.jsxs("span",{className:"add",children:["+",s.additions]}),s.deletions>0&&e.jsxs("span",{className:"del",children:["−",s.deletions]})]})}),e.jsx("span",{className:"status-code","data-kind":s.kind,children:ue(s.kind)})]})}function Se(s){return s.map(n=>n.startsWith("tag: ")?{label:n.slice(5),kind:"tag"}:n.startsWith("HEAD -> ")?{label:n.slice(8),kind:"head"}:n==="HEAD"?{label:"HEAD",kind:"head"}:{label:n,kind:n.includes("/")?"remote":"branch"})}const $e=new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"narrow"}),ke=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]];function Ee(s){const n=new Date(s);if(Number.isNaN(n.getTime()))return s;const a=Math.round((n.getTime()-Date.now())/1e3);for(const[t,r]of ke)if(Math.abs(a)>=r)return $e.format(Math.trunc(a/r),t);return"right now"}function Oe(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"}).format(n)}function Le({path:s}){return e.jsx("img",{className:"vscode-tree-icon",src:me(s),alt:"","aria-hidden":"true",draggable:!1})}function Te(s){return s instanceof Error?s.message:"An unexpected error occurred."}export{Re as HistoryView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as o}from"./index-ChKJF4C_.js";const e=[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]],a=o("outline","folder-plus","FolderPlus",e);export{a as I};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,j as e}from"./react-rd22PHbN.js";import{u as W}from"./tanstack-CtfgE41X.js";import{f as ve,a as Ne,b as F,w as B,n as ie,D as Ce,c as De,d as Te,e as Fe,g as he,I as de,h as M,i as se,j as Be,k as H,l as Se,m as O,o as Ee,p as U,q as ue,B as Ie,r as Re,s as Ge,t as be,u as Pe,v as Ae,x as Oe,y as me,z as Le}from"./App-CGiS2z40.js";import{q as K,B as f,T as X,a as J,b as V,I as $e,w as ze,o as S}from"./index-ChKJF4C_.js";import{C as qe}from"./checkbox-DDpujnre.js";import{o as We}from"./gh-utils-DxPHIkD8.js";import"./base-ui-DT3JsyND.js";function rr(r){const{open:n,tab:a,repositoryId:t,onMutated:b,onBusyChange:j}=r,[o,p]=l.useState(""),[k,c]=l.useState(!1),[i,w]=l.useState(null),[g,E]=l.useState(null),[v,x]=l.useState(null),[d,I]=l.useState(null),[L,N]=l.useState(null),[fe,$]=l.useState(!1),ne=l.useRef(null);l.useEffect(()=>{c(!1)},[n,t]);const D=W({queryKey:K.localRefs(t),queryFn:()=>S.refs.localRefsSnapshot(t),enabled:n}),m=D.data??null,z=D.isFetching,le=D.error?Q(D.error):null,Z=l.useMemo(()=>ve(m?.branches??[],o),[m,o]),_=l.useMemo(()=>Ne(m?.worktrees??[],o),[m,o]),R=Z.find(s=>F(s)===i)??null,G=_.find(s=>B(s)===g)??null,te=W({queryKey:K.branchDetails(t,R?.fullName??""),queryFn:()=>S.refs.branchDetails({repositoryId:t,fullName:R.fullName}),enabled:n&&a==="branches"&&R!==null}),y=te.data??null,je=W({queryKey:K.branchPullRequest(t,y?.name??""),queryFn:()=>S.github.findPullRequestForBranch(t,y.name),enabled:n&&a==="branches"&&y!==null&&(y.deletion==="unknown"||y.deletion==="unmerged")}).data??null,oe=W({queryKey:K.worktreeDetails(t,G?.path??""),queryFn:()=>S.refs.worktreeDetails({repositoryId:t,path:G.path}),enabled:n&&a==="worktrees"&&G!==null}),C=oe.data??null,ee=a==="branches"?te:oe,q=ee.isFetching,P=ee.error?Q(ee.error):null,A=l.useCallback(async()=>{await D.refetch()},[D]);l.useEffect(()=>{if(!m)return;const s=ne.current;ne.current=m,w(h=>ie(m.branches.map(F),(s?.branches??[]).map(F),h)),E(h=>ie(m.worktrees.map(B),(s?.worktrees??[]).map(B),h))},[m]),l.useEffect(()=>{n||(p(""),x(null),N(null),$(!1))},[n]),l.useEffect(()=>{x(null),N(null),$(!1)},[a,i,g]);const ce=async(s,h)=>{I(s),j(!0),N(null);try{await h()&&x(null)}catch(T){N(Q(T))}finally{I(null),j(!1)}},pe=(s,h)=>ce("delete-branch",async()=>{const T=await S.refs.deleteBranch({repositoryId:t,fullName:s.fullName,expectedOid:s.oid,force:h});return T.status!=="deleted"?(N(He(T.status)),await A(),!1):(b(null),await A(),!0)}),we=(s,h,T)=>ce("remove-worktree",async()=>{const re=await S.refs.removeWorktree({repositoryId:t,path:s.path,expectedOid:s.oid,force:h,deleteBranch:T});return re.status!=="removed"?(N(Me(re.status)),await A(),!1):(b(re.recentRepositories),await A(),!0)}),ge=async s=>{try{await ze(s),$(!0),window.setTimeout(()=>$(!1),1600)}catch(h){N(Q(h))}},ke={branches:m?.branches.length??0,worktrees:m?.worktrees.length??0},ye=a==="branches"?Z.length===0:_.length===0;return e.jsx(Ce,{open:n,onOpenChange:r.onOpenChange,children:e.jsxs(De,{className:"local-refs-dialog",children:[e.jsxs("header",{className:"local-refs-header",children:[e.jsxs("div",{children:[e.jsx(Te,{children:"Local branches and worktrees"}),e.jsx(Fe,{children:"Inspect what this repository holds locally, and retire what Git can safely remove."})]}),e.jsx(he,{render:e.jsx(f,{variant:"ghost",size:"icon-sm","aria-label":"Close the local refs manager"}),children:e.jsx(de,{})})]}),e.jsxs("div",{className:"local-refs-toolbar",children:[e.jsx("div",{className:"local-refs-tabs",role:"tablist","aria-label":"Local refs",children:["branches","worktrees"].map(s=>e.jsxs("button",{type:"button",role:"tab",id:`local-refs-tab-${s}`,"aria-selected":a===s,"aria-controls":`local-refs-panel-${s}`,className:"local-refs-tab",onClick:()=>{r.onTabChange(s),c(!1)},children:[s==="branches"?e.jsx(M,{"aria-hidden":"true"}):e.jsx(se,{"aria-hidden":"true"}),e.jsx("span",{children:s==="branches"?"Branches":"Worktrees"}),e.jsx("small",{children:ke[s]})]},s))}),e.jsxs("div",{className:"local-refs-search",children:[e.jsx(Be,{"aria-hidden":"true"}),e.jsxs("label",{className:"sr-only",htmlFor:"local-refs-search-input",children:["Search ",a]}),e.jsx("input",{id:"local-refs-search-input",value:o,onChange:s=>p(s.target.value),placeholder:a==="branches"?"Search branches…":"Search worktrees…",autoComplete:"off",spellCheck:!1}),o&&e.jsx(f,{variant:"ghost",size:"icon-xs","aria-label":"Clear search",onClick:()=>p(""),children:e.jsx(de,{})})]}),e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{A()},disabled:z||!!d,children:[z?e.jsx(H,{className:"animate-spin"}):e.jsx(Se,{})," Refresh"]})]}),le&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:le})]}),k&&e.jsxs("button",{type:"button",className:"local-refs-mobile-back",onClick:()=>c(!1),children:["← Back to ",a]}),e.jsxs("div",{className:"local-refs-body","data-mobile-detail":k,role:"tabpanel",id:`local-refs-panel-${a}`,"aria-labelledby":`local-refs-tab-${a}`,children:[e.jsxs("div",{className:"local-refs-list",role:"listbox","aria-label":a==="branches"?"Local branches":"Worktrees",tabIndex:-1,children:[z&&!m&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(H,{className:"animate-spin","aria-hidden":"true"})," Reading the repository…"]}),!z&&ye&&e.jsx("p",{className:"local-refs-placeholder",children:o?"No matches for this search.":`This repository has no ${a==="branches"?"local branches":"worktrees"}.`}),a==="branches"&&Z.map(s=>e.jsxs(X,{children:[e.jsxs(J,{render:e.jsx("button",{type:"button",role:"option","aria-selected":F(s)===i,className:"local-refs-row",onClick:()=>{w(F(s)),c(!0)}}),children:[e.jsxs("span",{className:"local-refs-row-head",children:[e.jsx(M,{"aria-hidden":"true"}),e.jsx("strong",{children:s.name}),e.jsx(Y,{badges:Ee(s)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("code",{children:s.shortOid}),s.subject&&e.jsx("span",{children:s.subject}),s.date&&e.jsx("time",{dateTime:s.date,children:ae(s.date)})]})]}),e.jsxs(V,{children:[s.name,s.subject?` — ${s.subject}`:""]})]},F(s))),a==="worktrees"&&_.map(s=>e.jsxs(X,{children:[e.jsxs(J,{render:e.jsx("button",{type:"button",role:"option","aria-selected":B(s)===g,className:"local-refs-row",onClick:()=>{E(B(s)),c(!0)}}),children:[e.jsxs("span",{className:"local-refs-row-head",children:[e.jsx(se,{"aria-hidden":"true"}),e.jsx("strong",{children:U(s.path)}),e.jsx(Y,{badges:ue(s)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("span",{className:"local-refs-row-branch",children:s.branch?`${s.branch}`:"Detached HEAD"}),e.jsx("span",{children:s.path})]})]}),e.jsxs(V,{children:[U(s.path)," — ",s.path]})]},B(s)))]}),e.jsxs("div",{className:"local-refs-detail",children:[P&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:P})]}),q&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(H,{className:"animate-spin","aria-hidden":"true"})," Loading details…"]}),!q&&!P&&a==="branches"&&y&&R&&e.jsx(Ke,{details:y,pullRequest:je,busy:d==="delete-branch",anyBusy:!!d,confirming:v==="delete-branch",actionError:L,onConfirm:()=>x("delete-branch"),onCancel:()=>x(null),onDelete:s=>{pe(y,s)}}),!q&&!P&&a==="worktrees"&&C&&G&&e.jsx(Qe,{details:C,busy:d==="remove-worktree",anyBusy:!!d,confirming:v==="remove-worktree",actionError:L,copied:fe,onConfirm:()=>x("remove-worktree"),onCancel:()=>x(null),onRemove:(s,h)=>{we(C,s,h)},onCopyPath:()=>{ge(C.path)},onOpen:()=>r.onOpenWorktree(C.path),onShowBranch:()=>{C.branch&&(w(`refs/heads/${C.branch}`),r.onTabChange("branches"))}}),!q&&!P&&!R&&!G&&e.jsxs("p",{className:"local-refs-placeholder",children:["Select a ",a==="branches"?"branch":"worktree"," to see its details."]})]})]},a),e.jsxs("footer",{className:"local-refs-footer",children:[e.jsx("small",{children:"Deleting a branch and removing a worktree are separate actions. A worktree removes its branch only when explicitly selected."}),e.jsx(he,{render:e.jsx(f,{variant:"outline",size:"sm",disabled:!!d}),children:"Done"})]})]})})}function Ke({details:r,pullRequest:n,busy:a,anyBusy:t,confirming:b,actionError:j,onConfirm:o,onCancel:p,onDelete:k}){const c=Re(r,n),i=c.forceAllowed===!0,w=c.allowed||i;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(M,{"aria-hidden":"true"}),e.jsxs(X,{children:[e.jsx(J,{render:e.jsx("span",{}),children:r.name}),e.jsx(V,{children:r.name})]})]}),e.jsx(Y,{badges:Ge(r)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(u,{label:"Full ref",children:e.jsx("code",{className:"local-refs-selectable",children:r.fullName})}),e.jsxs(u,{label:"Tip",children:[e.jsx("code",{children:r.shortOid})," ",r.subject]}),e.jsx(u,{label:"Author",children:r.author||"—"}),e.jsx(u,{label:"Last commit",children:r.date?ae(r.date,!0):"—"}),e.jsx(u,{label:"Upstream",children:r.upstream?`${r.upstream} · ↑${r.ahead} ↓${r.behind}`:"Not configured"}),e.jsx(u,{label:"Compared with",children:r.comparisonBase??"Not compared"}),n&&e.jsx(u,{label:"GitHub PR",children:e.jsxs("button",{type:"button",className:"local-refs-pr-link",onClick:()=>We(n.url),children:["#",n.number," · ",n.state==="MERGED"?`Merged into ${n.baseRefName}`:n.state==="OPEN"?"Open":"Closed"," ",e.jsx(be,{"aria-hidden":"true"})]})})]}),e.jsx(xe,{tone:c.allowed?"ready":"blocked",reason:c.reason,actionError:j,confirming:b,busy:a,anyBusy:t,actionLabel:i?"Force delete branch":"Delete branch",confirmLabel:a?"Deleting…":i?"Permanently delete":"Delete branch",allowed:w,confirmation:i?e.jsxs(e.Fragment,{children:["Force-delete the local branch ",e.jsx("strong",{children:r.name}),"? This keeps any remote branch and pull request, but commits found only on this local branch may become inaccessible. ",n?.state==="MERGED"?e.jsxs(e.Fragment,{children:["GitHub reports PR ",e.jsxs("strong",{children:["#",n.number]})," as merged into ",e.jsx("strong",{children:n.baseRefName}),", although local Git cannot verify the ancestry."]}):null]}):e.jsxs(e.Fragment,{children:["Delete the local branch ",e.jsx("strong",{children:r.name}),"? This removes only the local branch, keeping every worktree and any remote copy. Git confirmed it is fully merged into ",e.jsx("strong",{children:r.comparisonBase}),"."]}),onConfirm:o,onCancel:p,onAct:()=>k(i)})]})}function Qe({details:r,busy:n,anyBusy:a,confirming:t,actionError:b,copied:j,onConfirm:o,onCancel:p,onRemove:k,onCopyPath:c,onOpen:i,onShowBranch:w}){const[g,E]=l.useState(!1),v=Pe(r),x=Ae(r),d=v.forceAllowed===!0,I=v.allowed||d;return l.useEffect(()=>E(!1),[r.path]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(se,{"aria-hidden":"true"}),e.jsxs(X,{children:[e.jsx(J,{render:e.jsx("span",{}),children:U(r.path)}),e.jsx(V,{children:U(r.path)})]})]}),e.jsx(Y,{badges:ue(r)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(u,{label:"Folder",children:e.jsx("span",{className:"local-refs-path local-refs-selectable",children:r.path})}),e.jsx(u,{label:"Branch",children:r.branch??"Detached HEAD"}),e.jsx(u,{label:"HEAD",children:r.lastCommit?e.jsxs(e.Fragment,{children:[e.jsx("code",{children:r.lastCommit.shortOid})," ",r.lastCommit.subject]}):e.jsx("code",{children:r.oid?r.oid.slice(0,7):"—"})}),e.jsx(u,{label:"Committed",children:r.lastCommit?.date?ae(r.lastCommit.date,!0):"—"}),e.jsx(u,{label:"Local changes",children:r.available?x??"None":"Not readable"})]}),e.jsxs("div",{className:"local-refs-detail-actions",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:c,disabled:a,children:[j?e.jsx(Oe,{}):e.jsx($e,{})," ",j?"Copied":"Copy path"]}),!r.current&&r.available&&!r.locked&&e.jsxs(f,{variant:"outline",size:"sm",onClick:i,disabled:a,children:[e.jsx(be,{})," Open worktree"]}),r.branch&&e.jsxs(f,{variant:"ghost",size:"sm",onClick:w,disabled:a,children:[e.jsx(M,{})," Show branch"]})]}),r.branch&&I&&e.jsxs("label",{htmlFor:"remove-worktree-delete-branch",className:"local-refs-delete-branch",children:[e.jsx(qe,{id:"remove-worktree-delete-branch",checked:g,onCheckedChange:L=>E(L===!0),disabled:a}),e.jsxs("span",{children:["Also delete branch ",e.jsx("strong",{children:r.branch})]})]}),e.jsx(xe,{tone:v.allowed?"ready":"blocked",reason:v.reason,actionError:b,confirming:t,busy:n,anyBusy:a,actionLabel:d?"Force remove worktree":"Remove worktree",confirmLabel:n?"Removing…":d?"Permanently remove":"Remove worktree",allowed:I,confirmation:e.jsxs(e.Fragment,{children:[d?e.jsxs(e.Fragment,{children:["Permanently remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:r.path}),"? ",e.jsx("strong",{children:x??`The ${r.operation??"current Git operation"}`})," and every uncommitted file will be lost. The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}):e.jsxs(e.Fragment,{children:["Remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:r.path}),"? The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}),g&&r.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:r.branch})," will also be force-deleted. Commits found only on that branch may become inaccessible."]}):r.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:r.branch})," and its commits stay in the repository."]}):"No branch is deleted."]}),onConfirm:o,onCancel:p,onAct:()=>k(d,g)})]})}function xe({tone:r,reason:n,actionError:a,confirming:t,busy:b,anyBusy:j,allowed:o,actionLabel:p,confirmLabel:k,confirmation:c,onConfirm:i,onCancel:w,onAct:g}){return e.jsxs("div",{className:`local-refs-danger ${r}`,children:[a&&e.jsxs("p",{className:"local-refs-danger-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:a})]}),t&&o?e.jsxs("div",{className:"local-refs-confirm",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("p",{children:c}),e.jsxs("span",{className:"local-refs-confirm-actions",children:[e.jsxs(f,{variant:"destructive",size:"sm",onClick:g,disabled:b,children:[b?e.jsx(H,{className:"animate-spin"}):e.jsx(me,{})," ",k]}),e.jsx(f,{variant:"ghost",size:"sm",onClick:w,disabled:b,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"local-refs-reason",children:[r==="ready"?e.jsx(Le,{"aria-hidden":"true"}):e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:n})]}),o&&e.jsxs(f,{variant:"destructive",size:"sm",onClick:i,disabled:j,children:[e.jsx(me,{})," ",p]})]})]})}function Y({badges:r}){return r.length===0?null:e.jsx("span",{className:"local-refs-badges",children:r.map(n=>e.jsx(Ie,{variant:n.tone==="current"?"default":n.tone==="warning"?"destructive":"outline",children:n.label},n.label))})}function u({label:r,children:n}){return e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:r}),e.jsx("dd",{children:n})]})}function He(r){switch(r){case"stale":return"The branch moved since this view loaded. It was refreshed; check the new state before deleting.";case"current":return"This branch is now checked out here, so Git will not delete it.";case"checked-out":return"Another worktree now has this branch checked out.";case"unmerged":return"Git found commits that are not in the comparison base, so the branch was kept.";case"unknown":return"The comparison base is not available locally, so the branch was kept.";default:return"The branch no longer exists."}}function Me(r){switch(r){case"stale":return"The worktree moved since this view loaded. It was refreshed; check the new state before removing.";case"main":return"Git can never remove the main worktree.";case"current":return"OpenTig has this worktree open. Switch to another one first.";case"dirty":return"The worktree has local changes or an operation in progress, so it was kept.";case"locked":return"The worktree is locked. Unlock it in Git first.";case"prunable":return"Git can no longer find this worktree on disk.";case"bare":return"This entry is a bare repository, not a removable worktree.";default:return"The worktree no longer exists."}}function Q(r){return r instanceof Error?r.message:String(r)}function ae(r,n=!1){const a=new Date(r);return Number.isNaN(a.getTime())?r:new Intl.DateTimeFormat("en",n?{dateStyle:"medium",timeStyle:"short"}:{dateStyle:"medium"}).format(a)}export{rr as LocalRefsDialog};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-B-iLnCqi.js","assets/index-ChKJF4C_.js","assets/react-rd22PHbN.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-WwGOu_aM.css","assets/render-markdown-BiKX2Zdv.js","assets/App-CGiS2z40.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as t,j as e,a as oe}from"./react-rd22PHbN.js";import{c as B,_ as ae,w as se,s as ie,e as le,T as H,a as U,b as z}from"./index-ChKJF4C_.js";import{G as ce}from"./App-CGiS2z40.js";import{V as ue,a as de,b as K}from"./viewer-tabs-BwMhis6Q.js";import{u as pe,s as me,F as fe,S as he}from"./EditableFileViewer-Cve4V9RS.js";import{r as we}from"./render-markdown-BiKX2Zdv.js";/* empty css */import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./PierreWorkerPool-B_NFnwU-.js";import"./platform-BMNQ8V5r.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-BJuBDans.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";const ge=[["path",{d:"M3 12h7l-3 -3",key:"svg-0"}],["path",{d:"M7 15l3 -3",key:"svg-1"}],["path",{d:"M21 12h-7l3 -3",key:"svg-2"}],["path",{d:"M17 15l-3 -3",key:"svg-3"}],["path",{d:"M9 6v-1a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M9 18v1a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],ve=B("outline","viewport-narrow","ViewportNarrow",ge);const be=[["path",{d:"M10 12h-7l3 -3",key:"svg-0"}],["path",{d:"M6 15l-3 -3",key:"svg-1"}],["path",{d:"M14 12h7l-3 -3",key:"svg-2"}],["path",{d:"M18 15l3 -3",key:"svg-3"}],["path",{d:"M3 6v-1a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M3 18v1a2 2 0 0 0 2 2h14a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],ke=B("outline","viewport-wide","ViewportWide",be);function q(o,f){const l=f.trim();if(!l||l.startsWith("#")||l.startsWith("//")||/^[a-z][a-z\d+.-]*:/i.test(l))return null;const u=l.split(/[?#]/,1)[0];if(!u)return null;let p;try{p=decodeURIComponent(u).replaceAll("\\","/")}catch{return null}const d=p.startsWith("/")?[]:o.replaceAll("\\","/").split("/").slice(0,-1).filter(Boolean);for(const a of p.split("/"))if(!(!a||a===".")){if(a===".."){if(d.length===0)return null;d.pop();continue}if(Ce(a))return null;d.push(a)}return d.length>0?d.join("/"):null}function Ce(o){return[...o].some(f=>f.charCodeAt(0)<32||f.charCodeAt(0)===127)}let ye=0;function G(){return document.documentElement.classList.contains("dark")?"dark":"default"}function xe(o,f,l){const[u,p]=t.useState(G);t.useEffect(()=>{const a=new MutationObserver(()=>p(G()));return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[]);const d=t.useCallback(async a=>{if(!o.current)return;const h=Array.from(o.current.querySelectorAll(".mermaid"));if(h.length!==0)try{const{default:c}=await ae(async()=>{const{default:i}=await import("./mermaid.core-B-iLnCqi.js").then(m=>m.bo);return{default:i}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(a()||!o.current)return;c.initialize({startOnLoad:!1,theme:u,securityLevel:"strict"});for(const i of h){const m=i.dataset.mermaidSource;if(m){i.removeAttribute("data-mermaid-error");try{const T=decodeURIComponent(m),y=`mermaid-diagram-${ye++}`,{svg:R,bindFunctions:b}=await c.render(y,T,i);if(a()||!i.isConnected)return;i.innerHTML=R,i.dataset.processed="true",b?.(i)}catch{!a()&&i.isConnected&&(i.textContent=decodeURIComponent(m),i.dataset.mermaidError="Could not render diagram")}}}}catch{for(const c of h)!a()&&c.isConnected&&(c.dataset.mermaidError="Could not load Mermaid")}},[f,o,u]);t.useEffect(()=>{let a=!1;return d(()=>a),()=>{a=!0}},[l,d])}const X="opentig:markdown-content-width",$=/^([a-z][a-z0-9+.-]*:)?\/\//i,Te={conflictTitle:"Markdown was changed outside OpenTig",successTitle:"Markdown saved",errorTitle:"Could not save Markdown"};function Me(){try{return window.localStorage.getItem(X)==="fit"?"fit":"reading"}catch{return"reading"}}function Se({html:o,onClick:f,onLinkHover:l}){const u=t.useRef(null),p=t.useRef(null);t.useLayoutEffect(()=>{u.current&&(u.current.innerHTML=o),p.current=null,l(null)},[o,l]),xe(u,!0,o);const d=t.useCallback(h=>{const c=h.target.closest("a[href]");!c||c===p.current||(p.current=c,l(c))},[l]),a=t.useCallback(h=>{const c=p.current;if(!c)return;const i=h.relatedTarget;i&&c.contains(i)||(p.current=null,l(null))},[l]);return e.jsx("div",{ref:u,className:"markdown-prose",onClick:f,onMouseOver:d,onMouseOut:a})}function Ke({file:o,initialContent:f,revision:l,themeType:u,wrapLines:p,readOnly:d,onOpenFile:a,onDirtyChange:h,onDraftChange:c,onSave:i}){const[m,T]=t.useState("preview"),[y,R]=t.useState(Me),[b,I]=t.useState(""),[_,F]=t.useState(!0),[Y,V]=t.useState(!1),[x,g]=t.useState(null),M=t.useRef(0),k=t.useRef(null),N=t.useRef(null),A=t.useRef(null),C=t.useRef(null),S=t.useRef(null),{draft:P,updateDraft:J,dirty:j,saving:O,save:Q}=pe({file:o,initialContent:f,readOnly:d,messages:Te,onDirtyChange:h,onDraftChange:c,onSave:i});t.useEffect(()=>{S.current?.(),C.current=null,T("preview")},[o.path]);const Z=t.useCallback(n=>{if(n!==m){if(S.current?.(),m==="preview"){const r=N.current,s=r?r.scrollHeight-r.clientHeight:0;C.current=r&&s>0?r.scrollTop/s:0}else C.current=A.current?.getScrollFraction()??0;T(n)}},[m]);t.useLayoutEffect(()=>{const n=C.current;if(n==null)return;if(m==="code"){C.current=null,A.current?.scrollToFraction(n);return}const r=N.current;!r||_&&!b||(C.current=null,S.current=me({getScrollRange:()=>Math.max(0,r.scrollHeight-r.clientHeight),getScrollTop:()=>r.scrollTop,getContentHeight:()=>r.scrollHeight,scrollTo:s=>{r.scrollTop=s}},n))},[b,_,m]),t.useEffect(()=>()=>S.current?.(),[]),t.useEffect(()=>{const n=++M.current;F(!0);const r=window.setTimeout(()=>{const s=window.__opentigPerformanceAutomation?performance.now():null;we(P).then(w=>{n===M.current&&(I(w),s!==null&&(window.__opentigPerformanceResults??=[],window.__opentigPerformanceResults.push({kind:"markdown-render",durationMs:Math.round((performance.now()-s)*100)/100})))}).catch(()=>{n===M.current&&I("<p>Could not render Markdown.</p>")}).finally(()=>{n===M.current&&F(!1)})},j?120:0);return()=>window.clearTimeout(r)},[j,P,o.mtimeMs,o.path,l,u]),t.useEffect(()=>()=>{k.current&&window.clearTimeout(k.current.timer)},[]);const ee=t.useCallback(async n=>{const r=n.target,s=r.closest("[data-copy-code]");if(s){const W=s.dataset.copyCode;if(!W)return;try{const re=decodeURIComponent(W);await se(re);const E=k.current;E&&(window.clearTimeout(E.timer),delete E.button.dataset.copyState,E.button.setAttribute("aria-label","Copy code")),s.dataset.copyState="copied",s.setAttribute("aria-label","Copied"),V(!0);const ne=window.setTimeout(()=>{k.current?.button===s&&(delete s.dataset.copyState,s.setAttribute("aria-label","Copy code"),k.current=null,V(!1))},2e3);k.current={button:s,timer:ne}}catch{ie.error({title:"Could not copy code"})}return}const w=r.closest("a[href]"),v=w?.getAttribute("href");if(!w||!v)return;if(n.preventDefault(),v.startsWith("#")){n.currentTarget.querySelector(`#${CSS.escape(v.slice(1))}`)?.scrollIntoView({behavior:"smooth",block:"start"});return}if($.test(v)||v.startsWith("mailto:")){try{le(v)}catch{}return}const D=q(o.path,v);D&&a(D)},[o.path,a]),te=t.useCallback(n=>{if(!n){g(null);return}const r=n.getAttribute("href");if(!r||r.startsWith("#")){g(null);return}const s=n.getBoundingClientRect(),w={top:s.bottom+6,left:s.left};if(r.startsWith("mailto:")){g({...w,label:"Open in mail app",href:r.replace(/^mailto:/,"")});return}if($.test(r)){g({...w,label:"Open in browser",href:r});return}if(q(o.path,r)){g({...w,label:"Open file",href:r});return}g(null)},[o.path]),L=n=>{R(n);try{window.localStorage.setItem(X,n)}catch{}};return e.jsxs(ue,{value:m,onValueChange:n=>Z(n),className:"markdown-viewer","data-content-width":y,children:[e.jsxs("div",{className:"file-viewer-pill markdown-viewer-toolbar",children:[e.jsx(de,{label:"Markdown view",className:"file-viewer-tabs markdown-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:e.jsxs(e.Fragment,{children:["Code ",j&&e.jsx("span",{className:"markdown-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),e.jsx(fe,{dirty:j,saving:O,readOnly:d,onSave:()=>{Q()}}),e.jsxs("div",{className:"markdown-width-toggle",role:"group","aria-label":"Markdown content width",children:[e.jsxs(H,{children:[e.jsx(U,{render:e.jsx("button",{type:"button","aria-label":"Reading width","aria-pressed":y==="reading",onClick:()=>L("reading")}),children:e.jsx(ve,{"aria-hidden":"true"})}),e.jsx(z,{children:"Reading width"})]}),e.jsxs(H,{children:[e.jsx(U,{render:e.jsx("button",{type:"button","aria-label":"Fit to width","aria-pressed":y==="fit",onClick:()=>L("fit")}),children:e.jsx(ke,{"aria-hidden":"true"})}),e.jsx(z,{children:"Fit to width"})]})]})]}),e.jsxs(K,{ref:N,value:"preview",className:"markdown-preview-scroll",onScroll:()=>g(null),children:[_&&!b?e.jsx("div",{className:"viewer-message",children:e.jsx(ce,{text:"Rendering Markdown…"})}):e.jsx(Se,{html:b,onClick:n=>{ee(n)},onLinkHover:te}),e.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:Y?"Code copied":""}),x?oe.createPortal(e.jsxs("div",{className:"markdown-link-tooltip",style:{top:x.top,left:x.left},role:"tooltip",children:[e.jsx("span",{className:"markdown-link-tooltip-label",children:x.label}),e.jsx("span",{className:"markdown-link-tooltip-href",children:x.href})]}),document.body):null]}),e.jsx(K,{value:"code",className:"markdown-code-view","data-theme":u,children:e.jsx(he,{ref:A,path:o.path,cacheKey:o.path,value:P,themeType:u,wrapLines:p,readOnly:d||O,onChange:J})})]})}export{Ke as MarkdownFileViewer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as k,j as g}from"./react-rd22PHbN.js";import{q as w,a5 as E,m as Q,a6 as j,a7 as O,A as X,d as M,D as Y,z as ee,a2 as ne,Z as te,a3 as R,a4 as ie,P as oe,a as re,V as T,O as U}from"./PierreWorkerPool-B_NFnwU-.js";import{F as se}from"./File-BJuBDans.js";import{D as q,b as $,f as le}from"./platform-BMNQ8V5r.js";import{a as ce,g as V,b as Z,F as de,p as b,c as ae,s as ue,r as fe,D as he}from"./DiffWorkspace-XS025gbZ.js";import{a as P}from"./EditContext-CvJWfVl1.js";import{B as D}from"./index-ChKJF4C_.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./App-CGiS2z40.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";var H=class extends ce{pendingConflictActions=[];pendingMarkerRows=[];injectedRows=new Map;options;constructor(e={theme:q},n,t){super(void 0,n,t),this.options=e}setConflictState(e,n,t){this.pendingConflictActions=e,this.pendingMarkerRows=n,this.syncInjectedRows(e,n,t)}syncInjectedRows(e,n,t){this.injectedRows.clear();for(const i of e){const r=i!=null?V(i,t):void 0;if(i==null||r==null)continue;const o={type:"actions",hunkIndex:r.hunkIndex,lineIndex:r.lineIndex,conflictIndex:i.conflictIndex};this.addInjectedRow(o)}for(const i of n)this.addInjectedRow(i)}addInjectedRow(e){const n=`${e.hunkIndex}:${e.lineIndex}`,t=this.injectedRows.get(n);t==null?this.injectedRows.set(n,[e]):t.push(e)}renderDiff(e,n=$){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=$){return this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.asyncRender(e,n)}createPreElement(e,n){return super.createPreElement(e,n,{"data-has-merge-conflict":""})}getUnifiedLineDecoration({type:e,lineType:n}){const t=e==="change"?n==="change-deletion"?"current":"incoming":void 0;return{gutterLineType:e==="change"?"context":n,gutterProperties:_(t),contentProperties:B(e,t)}}getSplitLineDecoration({side:e,type:n}){const t=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:_(t),contentProperties:B(n,t)}}getUnifiedInjectedRowsForLine=e=>{const n=this.injectedRows.get(`${e.hunkIndex}:${e.lineIndex}`);if(n==null||n.length===0)return;const{mergeConflictActionsType:t}=this.getOptionsWithDefaults(),i=[],r=[];for(const o of n){if(o.type==="actions"){i.push({content:pe({row:o,includeDefaultActions:t==="default",includeSlot:!0}),gutter:W("action")});continue}(o.type==="marker-end"?r:i).push({content:Ce(o),gutter:W("marker",o.type)})}return{before:i.length>0?i:void 0,after:r.length>0?r:void 0}};getOptionsWithDefaults(){const e=super.getOptionsWithDefaults();return e.diffStyle="unified",e.lineDiffType="none",e.mergeConflictActionsType=this.options.mergeConflictActionsType??"default",e}};function _(e){return e!=null?{"data-merge-conflict":e}:void 0}function B(e,n){if(n!=null){if(e==="change")return n==="current"||n==="incoming"?{"data-line-type":"context","data-merge-conflict":n}:void 0;if(n==="marker-start"||n==="marker-base"||n==="marker-separator"||n==="marker-end")return{"data-merge-conflict":n}}}function W(e,n){const t=Q(void 0,"annotation",1);return t.properties["data-gutter-buffer"]=e==="action"?"merge-conflict-action":`merge-conflict-${n??"marker"}`,t}function pe({row:e,includeDefaultActions:n,includeSlot:t}){const i=n?me(e.conflictIndex):[];return i.push(w({tagName:"slot",properties:{name:Z({hunkIndex:e.hunkIndex,lineIndex:e.lineIndex,conflictIndex:e.conflictIndex}),"data-merge-conflict-action-slot":""}})),w({tagName:"div",properties:{"data-merge-conflict-actions":""},children:[w({tagName:"div",properties:{"data-merge-conflict-actions-content":""},children:i})]})}function Ce(e){return w({tagName:"div",properties:{"data-merge-conflict":e.type,"data-merge-conflict-marker-row":""},children:[E(e.lineText.replace(/(?:\r\n|\n|\r)$/,""))]})}function me(e){return[y({resolution:"current",label:"Accept current change",conflictIndex:e}),z(),y({resolution:"incoming",label:"Accept incoming change",conflictIndex:e}),z(),y({resolution:"both",label:"Accept both",conflictIndex:e})]}function y({resolution:e,label:n,conflictIndex:t}){return w({tagName:"button",properties:{type:"button","data-merge-conflict-action":e,"data-merge-conflict-conflict-index":`${t}`},children:[E(n)]})}function z(){return w({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[E("|")]})}function xe(e,n){return e.hunkIndex===n.hunkIndex&&e.startContentIndex===n.startContentIndex&&e.endContentIndex===n.endContentIndex&&e.currentContentIndex===n.currentContentIndex&&e.baseContentIndex===n.baseContentIndex&&e.incomingContentIndex===n.incomingContentIndex&&e.endMarkerContentIndex===n.endMarkerContentIndex&&e.conflictIndex===n.conflictIndex&&ge(e.conflict,n.conflict)}function ge(e,n){return e.conflictIndex===n.conflictIndex&&e.startLineIndex===n.startLineIndex&&e.startLineNumber===n.startLineNumber&&e.separatorLineIndex===n.separatorLineIndex&&e.separatorLineNumber===n.separatorLineNumber&&e.endLineIndex===n.endLineIndex&&e.endLineNumber===n.endLineNumber&&e.baseMarkerLineIndex===n.baseMarkerLineIndex&&e.baseMarkerLineNumber===n.baseMarkerLineNumber}function Le(e){const n=typeof e=="string"?e:e.type;return n==="accept"||n==="incoming"?"additions":n==="reject"||n==="current"?"deletions":"both"}function Ie(e,n){const{resolution:t,hunkIndex:i,startContentIndex:r,endContentIndex:o,indexesToDelete:s=new Set}=n,l=e.hunks[i];if(l==null)throw console.error({diff:e,hunkIndex:i}),new Error(`resolveRegion: Invalid hunk index: ${i}`);if(r<0||o>=l.hunkContent.length||r>o)throw new Error(`resolveRegion: Invalid content range, ${r}, ${o}`);const{hunks:d,additionLines:a,deletionLines:f}=e,h={...e,hunks:[],deletionLines:[],additionLines:[],splitLineCount:0,unifiedLineCount:0,cacheKey:e.cacheKey!=null?`${e.cacheKey}:${t[0]}-${i}:${r}-${o}`:void 0},u={nextAdditionLineIndex:0,nextDeletionLineIndex:0,nextAdditionStart:1,nextDeletionStart:1,splitLineCount:0,unifiedLineCount:0},L=i===d.length-1&&o===l.hunkContent.length-1,A=!e.isPartial;for(const[p,x]of d.entries()){ve(e,h,u,j(x.deletionStart,x.deletionCount)-x.collapsedBefore,j(x.additionStart,x.additionCount)-x.collapsedBefore,x.collapsedBefore,A);const c={...x,hunkContent:[],additionStart:u.nextAdditionStart,deletionStart:u.nextDeletionStart,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex,additionCount:0,deletionCount:0,deletionLines:0,additionLines:0,splitLineStart:u.splitLineCount,unifiedLineStart:u.unifiedLineCount,splitLineCount:0,unifiedLineCount:0};for(const[m,C]of x.hunkContent.entries())if(p!==i||m<r||m>o){G(C,h,f,a);const v={...C,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex};c.hunkContent.push(v),S(v,u,c)}else if(s.has(m))c.hunkContent.push({type:"context",lines:0,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex});else if(C.type==="context"){G(C,h,f,a);const v={...C,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}else{ke(t,C,h,f,a);const v={type:"context",lines:t==="deletions"?C.deletions:t==="additions"?C.additions:C.deletions+C.additions,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}if(p===i&&L){const m=t==="deletions"?x.noEOFCRDeletions:x.noEOFCRAdditions;c.noEOFCRAdditions=m,c.noEOFCRDeletions=m}c.additionCount===0&&(c.additionStart--,e.isPartial||c.additionLineIndex--),c.deletionCount===0&&(c.deletionStart--,e.isPartial||c.deletionLineIndex--),h.hunks.push(c)}const I=d.at(-1);if(I!=null&&!e.isPartial){const p=O(I.deletionStart,I.deletionCount),x=O(I.additionStart,I.additionCount),c=Math.min(f.length-p,a.length-x);J(h,f,a,p,x,c),u.splitLineCount+=c,u.unifiedLineCount+=c}return h.splitLineCount=u.splitLineCount,h.unifiedLineCount=u.unifiedLineCount,h}function J(e,n,t,i,r,o){for(let s=0;s<o;s++){const l=n[i+s],d=t[r+s];if(l==null||d==null)throw new Error("pushCollapsedContextLines: missing collapsed context line");e.deletionLines.push(l),e.additionLines.push(d)}}function ve(e,n,t,i,r,o,s){o<=0||(s&&(J(n,e.deletionLines,e.additionLines,i,r,o),t.nextAdditionLineIndex+=o,t.nextDeletionLineIndex+=o),t.nextAdditionStart+=o,t.nextDeletionStart+=o,t.splitLineCount+=o,t.unifiedLineCount+=o)}function G(e,n,t,i){if(e.type==="context")for(let r=0;r<e.lines;r++){const o=i[e.additionLineIndex+r];if(o==null)throw console.error({additionLines:i,content:e,i:r}),new Error("pushContentLinesToDiff: Context line does not exist");n.deletionLines.push(o),n.additionLines.push(o)}else{const r=Math.max(e.deletions,e.additions);for(let o=0;o<r;o++){if(o<e.deletions){const s=t[e.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:t,content:e,i:o}),new Error("pushContentLinesToDiff: Deletion line does not exist");n.deletionLines.push(s)}if(o<e.additions){const s=i[e.additionLineIndex+o];if(s==null)throw console.error({additionLines:i,content:e,i:o}),new Error("pushContentLinesToDiff: Addition line does not exist");n.additionLines.push(s)}}}}function ke(e,n,t,i,r){if(e==="deletions"||e==="both")for(let o=0;o<n.deletions;o++){const s=i[n.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:i,content:n,i:o}),new Error("pushResolveLinesToDiff: Deletion line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}if(e==="additions"||e==="both")for(let o=0;o<n.additions;o++){const s=r[n.additionLineIndex+o];if(s==null)throw console.error({additionLines:r,content:n,i:o}),new Error("pushResolveLinesToDiff: Addition line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}}function S(e,n,t){e.type==="context"?(n.nextAdditionLineIndex+=e.lines,n.nextDeletionLineIndex+=e.lines,n.nextAdditionStart+=e.lines,n.nextDeletionStart+=e.lines,n.splitLineCount+=e.lines,n.unifiedLineCount+=e.lines,t.additionCount+=e.lines,t.deletionCount+=e.lines,t.splitLineCount+=e.lines,t.unifiedLineCount+=e.lines):(n.nextAdditionLineIndex+=e.additions,n.nextDeletionLineIndex+=e.deletions,n.nextAdditionStart+=e.additions,n.nextDeletionStart+=e.deletions,n.splitLineCount+=Math.max(e.deletions,e.additions),n.unifiedLineCount+=e.deletions+e.additions,t.deletionCount+=e.deletions,t.deletionLines+=e.deletions,t.additionCount+=e.additions,t.additionLines+=e.additions,t.splitLineCount+=Math.max(e.deletions,e.additions),t.unifiedLineCount+=e.deletions+e.additions)}function Ae(e,n,t){return Ie(e,{resolution:Le(t),hunkIndex:n.hunkIndex,startContentIndex:n.startContentIndex,endContentIndex:n.endContentIndex,indexesToDelete:we(n)})}function we(e){const n=new Set;return e.baseContentIndex!=null&&n.add(e.baseContentIndex),e.endMarkerContentIndex!==e.endContentIndex&&n.add(e.endMarkerContentIndex),n}let Re=-1;var De=class extends de{options;__id=`unresolved-file:${++Re}`;type="unresolved-file";computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0};conflictActions=[];markerRows=[];conflictActionCache=new Map;constructor(n={theme:q},t,i=!1){super(void 0,t,i),this.options=n,this.setOptions(n)}setOptions(n){if(n!=null){if(n.onMergeConflictAction!=null&&n.onMergeConflictResolve!=null)throw new Error("UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.");this.options=n,this.hunksRenderer.setOptions(this.getHunksRendererOptions(n)),this.syncInteractionOptions()}}syncInteractionOptions(){this.interactionManager.setOptions(X(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex,this.handleMergeConflictActionClick))}createHunksRenderer(n){return new H(this.getHunksRendererOptions(n),this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(n){return Oe(n,this.options)}applyPreNodeAttributes(n,t){super.applyPreNodeAttributes(n,t,{"data-has-merge-conflict":""})}cleanUp(){this.emitPostRender(!0),this.clearMergeConflictActionCache(),this.computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0},this.conflictActions=[],super.cleanUp()}getOrComputeDiff({file:n,fileDiff:t,actions:i,markerRows:r}){const{maxContextLines:o,onMergeConflictAction:s}=this.options;e:if(s!=null){const l=t!=null;if(l!==(i!=null)||l!==(r!=null))throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together");if(t!=null&&i!=null&&r!=null){this.computedCache={file:n??this.computedCache.file,fileDiff:t,actions:i,markerRows:r};break e}else if(n!=null||this.computedCache.file!=null){if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file)&&this.computedCache.fileDiff!=null&&this.computedCache.actions!=null)throw new Error("UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.");if(n??=this.computedCache.file,n==null)throw new Error("UnresolvedFile.getOrComputeDiff: file is null, should be impossible");if(!M(n,this.computedCache.file)||this.computedCache.fileDiff==null||this.computedCache.actions==null){const d=b(n,o);this.computedCache={file:n,fileDiff:d.fileDiff,actions:d.actions,markerRows:d.markerRows}}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}else{t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}}else{if(t!=null||i!=null||r!=null)throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`");if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file))throw new Error("UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.");if(this.computedCache.file??=n,this.computedCache.fileDiff==null&&this.computedCache.file!=null){const l=b(this.computedCache.file,o);this.computedCache.fileDiff=l.fileDiff,this.computedCache.actions=l.actions,this.computedCache.markerRows=l.markerRows}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}if(!(t==null||i==null||r==null))return{fileDiff:t,actions:i,markerRows:r}}hydrate(n){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,fileContainer:l,prerenderedHTML:d,preventEmit:a=!1}=n,f=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});f!=null&&(this.hydrateElements(l,d),this.setActiveMergeConflictState(f.actions,f.markerRows),Ne(this.pre,f.fileDiff,this.options.collapsed)||je(this.headerElement,f.fileDiff,this.options.disableFileHeader)?this.render({...n,preventEmit:!0}):(this.hydrationSetup({fileDiff:f.fileDiff,lineAnnotations:s}),this.pre!=null&&this.renderMergeConflictActionSlots()),a||this.emitPostRender())}rerender(){!this.enabled||this.fileDiff==null||this.render({forceRender:!0,renderRange:this.renderRange})}render(n={}){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,preventEmit:l=!1,...d}=n,a=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});if(a==null)return!1;this.setActiveMergeConflictState(a.actions,a.markerRows);const f=super.render({...d,fileDiff:a.fileDiff,lineAnnotations:s,preventEmit:!0});return f&&(this.renderMergeConflictActionSlots(),l||this.emitPostRender()),f}resolveConflict(n,t,i=this.computedCache.fileDiff){const r=this.conflictActions[n];if(i==null||r==null)return;if(r.conflictIndex!==n)throw console.error({conflictIndex:n,action:r}),new Error("UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match");const o=Ae(i,r,t),s=this.computedCache.file,{file:l,actions:d,markerRows:a}=Me({fileDiff:o,previousActions:this.conflictActions,resolvedConflictIndex:n,previousFile:s,resolution:t});return{file:l,fileDiff:o,actions:d,markerRows:a}}resolveConflictAndRender(n,t){const i=this.conflictActions[n];if(i==null)return;if(i.conflictIndex!==n)throw console.error({conflictIndex:n,action:i}),new Error("UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match");const r={resolution:t,conflict:i.conflict},{file:o,fileDiff:s,actions:l,markerRows:d}=this.resolveConflict(n,t)??{};o==null||s==null||l==null||d==null||(this.computedCache={file:o,fileDiff:s,actions:l,markerRows:d},this.setActiveMergeConflictState(l,d),this.workerManager!=null?this.hunksRenderer.renderDiff(s):this.render({forceRender:!0}),this.options.onMergeConflictResolve?.(o,r))}setActiveMergeConflictState(n=this.conflictActions,t=this.markerRows){this.conflictActions=n,this.markerRows=t,this.computedCache.fileDiff!=null&&this.hunksRenderer instanceof H&&this.hunksRenderer.setConflictState(this.options.mergeConflictActionsType==="none"?[]:n,t,this.computedCache.fileDiff)}handleMergeConflictActionClick=n=>{const t=this.conflictActions[n.conflictIndex];if(t==null)return;if(t.conflictIndex!==n.conflictIndex)throw console.error({conflictIndex:n.conflictIndex,action:t}),new Error("UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match");const i={resolution:n.resolution,conflict:t.conflict};if(this.options.onMergeConflictAction!=null){this.options.onMergeConflictAction(i,this);return}this.resolveConflictAndRender(n.conflictIndex,n.resolution)};renderMergeConflictActionSlots(){const{fileDiff:n}=this.computedCache;if(this.isContainerManaged||this.fileContainer==null||typeof this.options.mergeConflictActionsType!="function"||this.conflictActions.length===0||n==null){this.clearMergeConflictActionCache();return}const t=new Map(this.conflictActionCache);for(let i=0;i<this.conflictActions.length;i++){const r=this.conflictActions[i];if(r==null)continue;if(r.conflictIndex!==i)throw console.error({conflictIndex:i,action:r}),new Error("UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match");const o=V(r,n);if(o==null)continue;const s=r.conflictIndex,l=Z({hunkIndex:o.hunkIndex,lineIndex:o.lineIndex,conflictIndex:s}),d=`${i}-${l}`;let a=this.conflictActionCache.get(d);if(a==null||!xe(a.action,r)){a?.element.remove();const f=this.renderMergeConflictAction(r);if(f==null)continue;const h=Y(l);h.appendChild(f),this.fileContainer.appendChild(h),a={element:h,action:r},this.conflictActionCache.set(d,a)}t.delete(d)}for(const[i,{element:r}]of t.entries())this.conflictActionCache.delete(i),r.remove()}renderMergeConflictAction(n){if(typeof this.options.mergeConflictActionsType!="function")return;const t=this.options.mergeConflictActionsType(n,this);if(t!=null){if(t instanceof HTMLElement)return t;if(typeof DocumentFragment<"u"&&t instanceof DocumentFragment){const i=document.createElement("div");return i.style.display="contents",i.appendChild(t),i}}}clearMergeConflictActionCache(){for(const{element:n}of this.conflictActionCache.values())n.remove();this.conflictActionCache.clear()}};function Me({fileDiff:e,previousActions:n,resolvedConflictIndex:t,previousFile:i,resolution:r}){const o=n[t];if(o==null)throw new Error("rebuildFileAndActions: missing resolved action for unresolved file rebuild");const s=be(n,t,o,r),l=ae(e,s);return{file:ye({fileDiff:e,resolvedAction:o,resolvedConflictIndex:t,previousFile:i,resolution:r}),actions:s,markerRows:l}}function ye({resolvedAction:e,resolvedConflictIndex:n,previousFile:t,fileDiff:i,resolution:r}){const o=ue(t?.contents??""),{conflict:s}=e,l=Se(o,s,r),d=[...o.slice(0,s.startLineIndex),...l,...o.slice(s.endLineIndex+1)].join("");return{name:t?.name??i.name,contents:d,cacheKey:t?.cacheKey!=null?`${t.cacheKey}:mc-${n}-${r}`:void 0}}function Se(e,n,t){const i=e.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),r=e.slice(n.separatorLineIndex+1,n.endLineIndex);return t==="current"?i:t==="incoming"?r:[...i,...r]}function be(e,n,t,i){const r=Ee(t.conflict,i);return e.map((o,s)=>{if(s!==n&&o!=null)return o.conflict.startLineIndex>t.conflict.endLineIndex?{...o,conflict:Fe(o.conflict,r)}:o})}function Ee(e,n){const t=(e.baseMarkerLineIndex??e.separatorLineIndex)-e.startLineIndex-1,i=e.endLineIndex-e.separatorLineIndex-1;return(n==="current"?t:n==="incoming"?i:t+i)-(e.endLineIndex-e.startLineIndex+1)}function Fe(e,n){return{...e,startLineIndex:e.startLineIndex+n,startLineNumber:e.startLineNumber+n,separatorLineIndex:e.separatorLineIndex+n,separatorLineNumber:e.separatorLineNumber+n,endLineIndex:e.endLineIndex+n,endLineNumber:e.endLineNumber+n,baseMarkerLineIndex:e.baseMarkerLineIndex!=null?e.baseMarkerLineIndex+n:void 0,baseMarkerLineNumber:e.baseMarkerLineNumber!=null?e.baseMarkerLineNumber+n:void 0}}function Ne(e,n,t=!1){return!t&&e==null&&n!=null}function je(e,n,t=!1){return e==null&&n!=null&&!t}function Oe(e,n){const t={...n,...e};return{...t,useTokenTransformer:ee(t),hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,mergeConflictActionsType:typeof e?.mergeConflictActionsType=="function"?"custom":e?.mergeConflictActionsType}}const Te=typeof window>"u"?k.useEffect:k.useLayoutEffect;function Ue({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:r,hasConflictUtility:o,hasGutterRenderUtility:s,hasCustomHeader:l,disableWorkerPool:d}){const[{fileDiff:a,actions:f,markerRows:h},u]=k.useState(()=>{const{fileDiff:c,actions:m,markerRows:C}=b(e,n?.maxContextLines);return{fileDiff:c,actions:m,markerRows:C}}),L=P((c,m)=>{u(C=>{const{fileDiff:v,actions:F,markerRows:N}=m.resolveConflict(c.conflict.conflictIndex,c.resolution,C.fileDiff)??{};return v==null||F==null||N==null?C:{fileDiff:v,actions:F,markerRows:N}})}),A=i!==void 0,I=k.useContext(ne),p=k.useRef(null),x=P(c=>{if(c!=null){if(p.current!=null)throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");p.current=new De(K({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),d?void 0:I,!0),p.current.hydrate({fileDiff:a,actions:f,markerRows:h,fileContainer:c,lineAnnotations:t,prerenderedHTML:r})}else{if(p.current==null)throw new Error("useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting");p.current.cleanUp(),p.current=null}});return Te(()=>{if(p.current==null)return;const c=p.current,m=K({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),C=m!==void 0&&!te(c.options,m);c.setOptions(m),c.render({fileDiff:a,actions:f,markerRows:h,lineAnnotations:t,forceRender:C}),i!==void 0&&c.setSelectedLines(i)}),{ref:x,getHoveredLine:k.useCallback(()=>p.current?.getHoveredLine(),[]),fileDiff:a,actions:f,markerRows:h,getInstance:k.useCallback(()=>p.current??void 0,[])}}function K({options:e,controlledSelection:n,onMergeConflictAction:t,hasConflictUtility:i,hasCustomHeader:r,hasGutterRenderUtility:o}){return{...e,controlledSelection:n,onMergeConflictAction:t,hunkSeparators:e?.hunkSeparators==="custom"?R:e?.hunkSeparators,mergeConflictActionsType:i||e?.mergeConflictActionsType==="custom"?R:e?.mergeConflictActionsType,renderCustomHeader:r?R:void 0,renderGutterUtility:o?R:void 0}}function $e({file:e,options:n,lineAnnotations:t,selectedLines:i,className:r,style:o,prerenderedHTML:s,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderGutterUtility:u,renderMergeConflictUtility:L,disableWorkerPool:A=!1}){const{ref:I,getHoveredLine:p,fileDiff:x,actions:c,getInstance:m}=Ue({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:s,hasConflictUtility:L!=null,hasGutterRenderUtility:u!=null,hasCustomHeader:d!=null,disableWorkerPool:A});return g.jsx(le,{ref:I,className:r,style:o,children:ie(fe({fileDiff:x,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderAnnotation:l,renderGutterUtility:u,lineAnnotations:t,getHoveredLine:p,actions:c,renderMergeConflictUtility:L,getInstance:m}),s)})}function Pe(e){return{draft:e,persistedContent:e,revision:0}}function He(e,n){return n===e.draft?e:{...e,draft:n,revision:e.revision+1}}function _e(e,n){return e.persistedContent===n?e:{...e,persistedContent:n}}function Be(e,n){return n===e.persistedContent?e:{draft:n,persistedContent:n,revision:e.revision+1}}function cn(e){return g.jsx(oe,{children:g.jsx("div",{className:"viewer-transition",children:e.kind==="diff"?g.jsx(We,{...e}):g.jsx(ze,{file:e.file,themeType:e.themeType,overflow:e.overflow,onUpdate:e.onUpdate,onResolve:e.onResolve},e.file.path)},e.contentKey)})}function We({contentKey:e,value:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f}){return g.jsx(he,{contentKey:e,diff:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f},e)}function ze({file:e,themeType:n,overflow:t,onUpdate:i,onResolve:r}){const[o,s]=k.useState(()=>Pe(e.content)),[l,d]=k.useState(!1),[a,f]=k.useState(!1),h=o.draft,u=o.revision,L=Ge(h);k.useEffect(()=>{s(p=>Be(p,e.content))},[e.content]);const A=async(p,x)=>{if(l)return;d(!0);const c=o,m=Ke(h,p,x);s(C=>He(C,m));try{await i(e.path,m)?s(C=>_e(C,m)):s(C=>C.draft===m?c:C)}finally{d(!1)}},I=async()=>{if(!(L>0||a)){f(!0);try{await r(e.path,h)}finally{f(!1)}}};return g.jsxs("div",{className:"conflict-viewer",children:[g.jsxs("div",{className:"conflict-viewer-toolbar",children:[g.jsxs("div",{children:[g.jsx("strong",{children:"Conflict resolution"}),g.jsx("span",{children:L>0?`${L} ${L===1?"pending block":"pending blocks"}`:"All blocks are resolved"})]}),g.jsx(D,{size:"sm",disabled:L>0||a,onClick:()=>{I()},children:a?"Saving…":"Mark as resolved"})]}),g.jsx(re,{className:"viewer-scroll",contentClassName:"viewer-content",children:L>0?g.jsx($e,{file:{name:e.path,contents:h,cacheKey:`${e.path}:conflict:${u}`},disableWorkerPool:h.length>5e5,options:{themeType:n,theme:U,diffIndicators:"classic",overflow:t,mergeConflictActionsType:"none",unsafeCSS:T},renderMergeConflictUtility:p=>g.jsxs("div",{className:"conflict-actions",children:[g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"current")},children:"Accept current"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"incoming")},children:"Accept incoming"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"both")},children:"Accept both"})]})},`${e.path}:${u}`):g.jsx(se,{file:{name:e.path,contents:h,cacheKey:`${e.path}:resolved:${u}`},options:{themeType:n,theme:U,overflow:t,unsafeCSS:T}})})]})}function Ge(e){return e.split(/\r?\n/).filter(n=>/^<{7}(?: |$)/.test(n)).length}function Ke(e,n,t){const i=e.match(/[^\n]*\n|[^\n]+$/g)??[],r=i.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),o=i.slice(n.separatorLineIndex+1,n.endLineIndex),s=t==="current"?r:t==="incoming"?o:[...r,...o];return[...i.slice(0,n.startLineIndex),...s,...i.slice(n.endLineIndex+1)].join("")}export{cn as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PullRequestDiff-Bcu8Gmrf.js","assets/react-rd22PHbN.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-ChKJF4C_.js","assets/index-WwGOu_aM.css","assets/App-CGiS2z40.js","assets/DiffWorkspace-XS025gbZ.js","assets/PierreWorkerPool-B_NFnwU-.js","assets/platform-BMNQ8V5r.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js","assets/index-CtEztN1P.js","assets/EditContext-CvJWfVl1.js","assets/render-markdown-BiKX2Zdv.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as D,B as k,T as H,a as F,b as M,_ as L,o as C,q}from"./index-ChKJF4C_.js";import{r as j,j as e}from"./react-rd22PHbN.js";import{G as T,P as V,I as $,a as O,b as B}from"./GitHubAvatar-Depnd_JA.js";import{u as R}from"./tanstack-CtfgE41X.js";import{l as z,k as h,G as p,B as _,h as K,t as Q,z as U}from"./App-CGiS2z40.js";import{V as X,a as J,b as x}from"./viewer-tabs-BwMhis6Q.js";import{p as W,r as Y,o as Z}from"./gh-utils-DxPHIkD8.js";/* empty css */import"./base-ui-DT3JsyND.js";const ee=[["path",{d:"M6.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3",key:"svg-1"}]],se=D("outline","tag","Tag",ee),ae=j.lazy(()=>L(()=>import("./PullRequestDiff-Bcu8Gmrf.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])));function he({repositoryId:r,prNumber:i,diffView:n,themeType:d,wrapLines:l,onDiffViewChange:m,onWrapLinesChange:c,onClose:P,onSelectPullRequest:E}){const[v,S]=j.useState("summary"),t=R({queryKey:q.pullRequest(r,i),queryFn:async()=>{const a=await C.github.getPullRequest(r,i),A=a.body.trim()?await L(async()=>{const{renderMarkdown:u}=await import("./render-markdown-BiKX2Zdv.js").then(G=>G.a);return{renderMarkdown:u}},__vite__mapDeps([14,6,4,1,2,3,5,10,11])).then(({renderMarkdown:u})=>u(a.body)).catch(()=>"<p>Could not render the description.</p>"):"";return{details:a,bodyHtml:A}}}),s=t.data?.details??null,f=t.data?.bodyHtml??"",N=t.error instanceof Error?t.error.message:t.error?"Could not load the pull request.":null,o=R({queryKey:q.pullRequestDiff(r,i),queryFn:()=>C.github.getPullRequestDiff(r,i),enabled:v==="diff"&&s!==null}),b=o.data??null,g=o.error instanceof Error?o.error.message:o.error?"Could not load the diff.":null;if(N)return e.jsxs("div",{className:"viewer-message flex-col gap-3",children:[e.jsx("p",{className:"text-destructive",children:N}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{t.refetch()},children:[e.jsx(z,{})," Try again"]})]});if(!s)return e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:`Loading pull request #${i}…`})]});const w=W(s),y=Y(s.reviewDecision);return e.jsxs(X,{value:v,onValueChange:a=>S(a),className:"pr-viewer",children:[e.jsxs("header",{className:"pr-viewer-header",children:[e.jsxs("div",{className:"pr-viewer-overview",children:[e.jsxs("div",{className:"pr-viewer-title",children:[e.jsx(_,{variant:s.state==="OPEN"&&!s.isDraft?"default":"secondary",className:`pr-state-badge ${w.toLowerCase().replace(/\s+/g,"-")}`,children:w}),e.jsxs("h2",{children:[s.title||"(no title)"," ",e.jsxs("span",{className:"pr-number",children:["#",s.number]})]})]}),e.jsxs("div",{className:"pr-viewer-meta",children:[e.jsxs("span",{className:"pr-author-with-avatar",children:[e.jsx(T,{src:s.authorAvatarUrl,className:"pr-author-avatar"},s.authorAvatarUrl),e.jsx("span",{className:"pr-author",children:s.author})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:["updated ",I(s.updatedAt)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-branches",children:[e.jsx(K,{"aria-hidden":"true"})," ",s.headRefName," → ",s.baseRefName]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-counters",children:[s.changedFiles," ",s.changedFiles===1?"file":"files"," ",e.jsxs("span",{className:"add",children:["+",s.additions]})," ",e.jsxs("span",{className:"del",children:["−",s.deletions]})]}),e.jsx(re,{state:s.checksState}),y&&e.jsx(_,{variant:"outline",className:"pr-review-badge",children:y}),s.stack&&e.jsx(V,{repositoryId:r,number:i,membership:s.stack,onSelect:E}),e.jsx("span",{className:"pr-viewer-actions",children:e.jsxs(k,{variant:"outline",size:"xs",onClick:()=>Z(s.url),children:[e.jsx(Q,{})," Open on GitHub"]})})]}),s.labels.length>0&&e.jsxs("div",{className:"pr-labels","aria-label":"Pull request labels",children:[e.jsx(se,{"aria-hidden":"true"}),s.labels.map(a=>e.jsx("span",{className:"pr-label",style:{borderColor:`#${a.color}`,backgroundColor:`#${a.color}22`},children:a.name},`${a.name}-${a.color}`))]})]}),e.jsx(J,{label:"Pull request view",className:"markdown-viewer-tabs pr-viewer-tabs",items:[{value:"summary",label:"Summary"},{value:"timeline",label:"Timeline"},{value:"diff",label:"Code"}]})]}),e.jsx(x,{value:"summary",className:"markdown-preview-scroll pr-description-scroll",children:e.jsx("section",{className:"pr-summary-section",children:f?e.jsx("div",{className:"markdown-prose",dangerouslySetInnerHTML:{__html:f}}):e.jsx("p",{className:"pr-empty-description",children:"This pull request has no description."})})}),e.jsx(x,{value:"timeline",className:"markdown-preview-scroll pr-description-scroll",children:e.jsxs("section",{className:"pr-timeline standalone","aria-label":"Commit timeline",children:[e.jsxs("h3",{children:[e.jsx(U,{"aria-hidden":"true"})," Commits ",e.jsx("span",{children:s.commits.length})]}),s.commits.length?s.commits.map(a=>e.jsxs("article",{className:"pr-timeline-item",children:[e.jsx("span",{className:"pr-timeline-rail",children:e.jsx("span",{})}),e.jsx(T,{src:a.authorAvatarUrl,className:"pr-commit-avatar"}),e.jsxs("span",{className:"pr-commit-content",children:[e.jsx("strong",{children:a.messageHeadline||"(no commit message)"}),e.jsxs("span",{children:[e.jsx("b",{children:a.author})," committed ",I(a.authoredAt)]})]}),e.jsxs(H,{children:[e.jsx(F,{render:e.jsx("code",{}),children:a.oid.slice(0,7)}),e.jsx(M,{children:a.oid})]})]},a.oid)):e.jsx("p",{className:"pr-empty-description",children:"No commits were returned by GitHub."})]})}),e.jsx(x,{value:"diff",className:"pr-diff-panel",children:g?e.jsx("div",{className:"viewer-message text-destructive",children:g}):b?e.jsx(j.Suspense,{fallback:e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:"Loading diff viewer…"})]}),children:e.jsx(ae,{diff:b,prNumber:s.number,repositoryId:r,commits:s.commits,diffView:n,themeType:d,wrapLines:l,onDiffViewChange:m,onWrapLinesChange:c,onClose:P})}):e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:"Loading diff…"})]})})]})}function re({state:r}){if(r==="NONE")return null;const i=r==="PASSING"?$:r==="FAILING"?O:B,n=r==="PASSING"?"Checks passing":r==="FAILING"?"Checks failing":"Checks pending";return e.jsxs("span",{className:`pr-checks ${r.toLowerCase()}`,children:[e.jsx(i,{"aria-hidden":"true"})," ",n]})}function I(r){const i=Date.parse(r);if(!Number.isFinite(i))return r;const n=Math.round((i-Date.now())/1e3),d=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]],l=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});for(const[m,c]of d)if(Math.abs(n)>=c)return l.format(Math.round(n/c),m);return l.format(n,"second")}export{he as PullRequestViewer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,r as v}from"./react-rd22PHbN.js";import{c as p,G as k,P as I,I as P,a as S,b as w}from"./GitHubAvatar-Depnd_JA.js";import{a as R}from"./tanstack-CtfgE41X.js";import{c as b,B as t,I as N,T as c,a as o,b as u}from"./index-ChKJF4C_.js";import{C as y}from"./checkbox-DDpujnre.js";import{k as h,G as x,l as j,Y as E,M as G,t as L}from"./App-CGiS2z40.js";import{o as O}from"./gh-utils-DxPHIkD8.js";import{P as D,f as T,g as q,h as z,i as M}from"./base-ui-DT3JsyND.js";const $=[["path",{d:"M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5",key:"svg-0"}]],d=b("outline","brand-github","BrandGithub",$);const A=[["path",{d:"M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227",key:"svg-0"}]],H=b("outline","filter","Filter",A);function ae(s){return s.info===null?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Checking repository…"})]}):s.info.isGitHub?s.ghStatus===null?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Checking GitHub CLI…"})]}):s.ghStatus.installed?s.ghStatus.authStatus==="unauthenticated"?e.jsxs(m,{icon:e.jsx(d,{}),title:"Sign in to GitHub CLI",children:["Run ",e.jsx("code",{children:"gh auth login"})," in a terminal to authenticate, then check again.",e.jsxs("span",{className:"pulls-notice-actions",children:[e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>s.onCopyCommand("gh auth login"),children:[e.jsx(N,{})," Copy command"]}),e.jsxs(t,{variant:"ghost",size:"sm",onClick:s.onRefresh,children:[e.jsx(j,{})," Check again"]})]})]}):e.jsx(F,{...s,nameWithOwner:s.info.nameWithOwner??""}):e.jsxs(m,{icon:e.jsx(d,{}),title:"GitHub CLI is required",children:["OpenTig uses your local ",e.jsx("code",{children:"gh"})," session to read and create pull requests. It does not copy or store credentials.",e.jsxs("span",{className:"pulls-notice-actions",children:[e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>s.onCopyCommand("winget install GitHub.cli"),children:[e.jsx(N,{})," Copy install command"]}),e.jsxs(t,{variant:"ghost",size:"sm",onClick:s.onRefresh,children:[e.jsx(j,{})," Check again"]})]}),e.jsx("small",{children:"Download from cli.github.com, then check again."})]}):e.jsxs(m,{icon:e.jsx(d,{}),title:"Not a GitHub repository",children:["The ",e.jsx("code",{children:"origin"})," remote does not point to github.com, so pull requests are unavailable here."]})}function F(s){const a=v.useRef(null),l=s.pulls,i=R({count:l?.length??0,getScrollElement:()=>a.current,estimateSize:()=>68,getItemKey:n=>l?.[n]?.number??n,overscan:8});return e.jsxs("div",{className:"pulls-view",children:[e.jsxs("div",{className:"pulls-toolbar",children:[e.jsxs(c,{children:[e.jsxs(o,{render:e.jsx("span",{className:"pulls-repo"}),children:[e.jsx(d,{"aria-hidden":"true"})," ",s.nameWithOwner]}),e.jsx(u,{children:s.nameWithOwner})]}),e.jsxs(c,{children:[e.jsx(o,{render:e.jsx(t,{variant:"ghost",size:"icon-xs",className:"change-action-button",disabled:s.loading,onClick:s.onRefresh,"aria-label":"Refresh pull requests"}),children:s.loading?e.jsx(h,{className:"animate-spin"}):e.jsx(j,{})}),e.jsx(u,{children:"Refresh pull requests"})]}),e.jsxs(D,{children:[e.jsx(T,{render:e.jsx(t,{variant:f(s.states)?"ghost":"secondary",size:"icon-xs",className:"change-action-button","aria-label":"Filter pull requests","aria-pressed":!f(s.states)}),children:e.jsx(H,{})}),e.jsx(q,{children:e.jsx(z,{side:"bottom",align:"end",sideOffset:4,className:"isolate z-50 outline-none",children:e.jsxs(M,{className:"pulls-filter-popup",children:[e.jsx("span",{className:"pulls-filter-title",children:"State"}),["OPEN","CLOSED","MERGED"].map(n=>e.jsxs("label",{htmlFor:`pulls-state-${n.toLowerCase()}`,className:"pulls-filter-option",children:[e.jsx(y,{id:`pulls-state-${n.toLowerCase()}`,checked:s.states.includes(n),onCheckedChange:r=>s.onStateChange(n,r===!0)}),e.jsx(C,{state:n,className:n.toLowerCase()}),e.jsx("span",{children:n==="OPEN"?"Open":n==="CLOSED"?"Closed":"Merged"})]},n))]})})})]}),e.jsxs(c,{children:[e.jsxs(o,{render:e.jsx(t,{variant:"outline",size:"xs",disabled:!!s.createDisabledReason||s.loading,onClick:s.onCreate,"aria-label":"Create pull request"}),children:[e.jsx(E,{})," New"]}),e.jsx(u,{children:s.createDisabledReason??"Create a pull request from the current branch"})]})]}),s.error&&e.jsxs("div",{className:"pulls-error",role:"alert",children:[e.jsx("span",{children:s.error}),e.jsx(t,{variant:"ghost",size:"xs",onClick:s.onRefresh,children:"Retry"})]}),e.jsx("div",{ref:a,className:"pulls-scroll",role:"list","aria-label":`${s.states.map(g).join(", ")||"No"} pull requests`,children:l===null&&!s.error?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Loading pull requests…"})]}):l!==null&&l.length===0?e.jsx("p",{className:"empty-list",children:s.states.length?`No ${s.states.map(n=>g(n).toLowerCase()).join(", ")} pull requests.`:"Select at least one PR state."}):l!==null&&e.jsx("div",{className:"virtual-list",style:{height:i.getTotalSize()},children:i.getVirtualItems().map(n=>{const r=l[n.index];return e.jsx("div",{ref:i.measureElement,"data-index":n.index,className:"virtual-row",style:{transform:`translateY(${n.start}px)`},children:e.jsx(V,{repositoryId:s.repositoryId,pr:r,active:s.activeNumber===r.number,onSelect:s.onSelect})},n.key)})})})]})}function V({repositoryId:s,pr:a,active:l,onSelect:i}){const n=a.state.toLowerCase(),r=W(a.updatedAt);return e.jsxs("div",{className:`pull-item ${l?"active":""}`,role:"listitem",children:[e.jsxs("button",{className:"pull-main",onClick:()=>i(a.number),"aria-label":`View pull request #${a.number}`,children:[e.jsx("span",{className:`pull-state-icon ${n}${a.isDraft?" draft":""}`,"aria-label":a.isDraft?"Draft":g(a.state),children:e.jsx(C,{state:a.state})}),e.jsxs("span",{className:"pull-content",children:[e.jsx("span",{className:"pull-title",children:a.title||"(no title)"}),e.jsxs("span",{className:"pull-meta",children:[e.jsxs("span",{className:"pull-number",children:["#",a.number]}),e.jsx(k,{src:a.authorAvatarUrl,className:"pull-avatar"}),e.jsx("span",{className:"pull-author",children:a.author}),e.jsx(_,{state:a.checksState}),a.isDraft&&e.jsx("span",{className:"pull-draft-label",children:"Draft"})]})]}),e.jsxs("span",{className:"pull-row-aside",children:[r&&e.jsx("span",{children:r}),e.jsxs("span",{className:"pull-line-stats",children:[e.jsxs("span",{className:"add",children:["+",a.additions]})," ",e.jsxs("span",{className:"del",children:["−",a.deletions]})]})]})]}),a.stack&&e.jsx(I,{repositoryId:s,number:a.number,membership:a.stack,onSelect:i}),e.jsxs(c,{children:[e.jsx(o,{render:e.jsx(t,{variant:"ghost",size:"icon-xs",className:"change-action-button pull-open-external",onClick:()=>O(a.url),"aria-label":`Open #${a.number} on GitHub`}),children:e.jsx(L,{})}),e.jsx(u,{children:"Open on GitHub"})]})]})}function C({state:s,className:a}){return s==="MERGED"?e.jsx(p,{"aria-hidden":"true",className:a}):e.jsx(G,{"aria-hidden":"true",className:a})}function _({state:s}){if(s==="NONE")return null;const a=s==="PASSING"?"Checks passing":s==="FAILING"?"Checks failing":"Checks pending",l=s==="PASSING"?P:s==="FAILING"?S:w;return e.jsx("span",{className:`pull-checks ${s.toLowerCase()}`,"aria-label":a,children:e.jsx(l,{"aria-hidden":"true"})})}function g(s){return s==="OPEN"?"Open":s==="CLOSED"?"Closed":"Merged"}function f(s){return s.length===1&&s[0]==="OPEN"}function m({icon:s,title:a,children:l}){return e.jsxs("div",{className:"pulls-notice",children:[e.jsx("span",{className:"pulls-notice-icon","aria-hidden":"true",children:s}),e.jsx("strong",{children:a}),e.jsx("p",{children:l})]})}const B=new Intl.RelativeTimeFormat("en",{numeric:"auto"}),U=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]];function W(s){const a=new Date(s);if(Number.isNaN(a.getTime()))return null;const l=Math.round((a.getTime()-Date.now())/1e3);for(const[i,n]of U)if(Math.abs(l)>=n)return B.format(Math.trunc(l/n),i);return"right now"}export{ae as PullRequestsView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as f,j as e}from"./react-rd22PHbN.js";import{Z as y,_ as N,D as v,c as R,d as C,e as D,j as F,k as S,G as b,X as I}from"./App-CGiS2z40.js";import{c as M}from"./index-ChKJF4C_.js";import{A as q,j as w,k as z,l as L}from"./base-ui-DT3JsyND.js";import"./tanstack-CtfgE41X.js";const O=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M12 21h-5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v4.5",key:"svg-1"}],["path",{d:"M14 17.5a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0",key:"svg-2"}],["path",{d:"M18.5 19.5l2.5 2.5",key:"svg-3"}]],Q=M("outline","file-search","FileSearch",O);function E(t,s){const n=[],r=c=>{for(const i of c)i.type==="directory"?r(i.children):n.push({path:i.path,name:i.name,parentPath:N(i.path)})};return r(s?t:y(t)),n}function T(t,s,{includeIgnored:n,activePath:r=null,limit:c=100}){const i=E(t,n),h=x(s).trim(),l=Math.max(0,Math.floor(c));if(!h)return i.sort((a,p)=>a.path===r?-1:p.path===r?1:k(a.path,p.path)).slice(0,l);const u=h.replace(/\s+/g,"");return i.map(a=>{const p=x(a.name),m=x(a.path),o=A(p,m,h,u);return o?{...a,rank:o}:null}).filter(a=>a!==null).sort((a,p)=>P(a.rank,p.rank)||j(a.path)-j(p.path)||k(a.path,p.path)).slice(0,l).map(a=>({path:a.path,name:a.name,parentPath:a.parentPath}))}function A(t,s,n,r){if(t===n)return[0,0,0,0];if(t.startsWith(n))return[1,0,t.length-n.length,0];const c=t.indexOf(n);if(c>=0)return[2,c,t.length-n.length,0];const i=s.indexOf(n);if(i>=0)return[3,i,s.length-n.length,0];const h=g(t,r);if(h)return[4,...h];const l=g(s,r);return l?[5,...l]:null}function g(t,s){if(!s)return null;let n=-1,r=-1,c=0,i=0;for(const h of s){const l=t.indexOf(h,n+1);if(l<0)return null;r<0&&(r=l),n>=0&&(c+=l-n-1,l===n+1&&(i+=1)),n=l}return[c,-i,r,t.length-s.length]}function P(t,s){for(let n=0;n<Math.max(t.length,s.length);n+=1){const r=(t[n]??0)-(s[n]??0);if(r!==0)return r}return 0}function x(t){return t.replace(/\\/g,"/").toLocaleLowerCase()}function j(t){return t.split("/").length}function k(t,s){return t.localeCompare(s,void 0,{sensitivity:"base"})||t.localeCompare(s)}function U({open:t,files:s,includeIgnored:n,activePath:r,onOpenChange:c,onOpenFile:i}){const[h,l]=f.useState(""),u=f.useRef(null),a=f.useMemo(()=>s?T(s,h,{includeIgnored:n,activePath:r,limit:100}):[],[r,s,n,h]);f.useEffect(()=>{t&&(l(""),window.requestAnimationFrame(()=>u.current?.focus()))},[t]);const p=o=>{i(o)&&c(!1)},m=h.trim();return e.jsx(v,{open:t,onOpenChange:c,children:e.jsxs(R,{className:"quick-open-dialog top-[max(64px,12vh)] w-[min(640px,calc(100vw-2.5rem))] -translate-y-0",children:[e.jsx(C,{className:"sr-only",children:"Open file"}),e.jsx(D,{className:"sr-only",children:"Search files in the current repository."}),e.jsxs(q,{items:a,value:h,onValueChange:l,itemToStringValue:o=>o.path,mode:"none",inline:!0,open:t,autoHighlight:"always",onOpenChange:(o,d)=>{!o&&d.reason!=="item-press"&&c(!1)},children:[e.jsxs("div",{className:"quick-open-input-shell",children:[e.jsx(F,{"aria-hidden":"true"}),e.jsx(w,{ref:u,"aria-label":"Search files by name or path",autoComplete:"off",spellCheck:!1,placeholder:"Search files by name or path"})]}),e.jsx(z,{"aria-label":"Repository files",className:"quick-open-results",children:s===null?e.jsxs("div",{className:"quick-open-status loading",role:"status",children:[e.jsx(S,{className:"spinner","aria-hidden":"true"})," ",e.jsx(b,{text:"Loading files…"})]}):a.length===0?e.jsxs("div",{className:"quick-open-status",role:"status",children:[e.jsx(Q,{"aria-hidden":"true"}),e.jsx("strong",{children:"No matching files"}),e.jsx("p",{children:m?e.jsxs(e.Fragment,{children:["Nothing matches ",e.jsx("em",{children:m})," in this repository."]}):"This repository has no files to open."})]}):a.map((o,d)=>e.jsxs(L,{value:o,index:d,className:"quick-open-result",onClick:()=>p(o.path),children:[e.jsx("img",{className:"quick-open-icon",src:I(o.path),alt:"","aria-hidden":"true",draggable:!1}),e.jsx("span",{className:"quick-open-name",children:o.name}),e.jsx("span",{className:"quick-open-parent",children:o.parentPath||"Repository root"})]},o.path))})]}),e.jsxs("footer",{className:"quick-open-footer",children:[e.jsxs("span",{className:"quick-open-hints",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"↑"}),e.jsx("kbd",{children:"↓"})," navigate"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"↵"})," open"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"Esc"})," close"]})]}),s!==null&&e.jsx("span",{className:"quick-open-count",children:a.length===100?"Top 100 matches":`${a.length} ${a.length===1?"file":"files"}`})]})]})})}export{U as QuickOpenDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as o,j as e}from"./react-rd22PHbN.js";import{D as q,c as Q,d as Z,e as ee,g as I,I as se,m as k,$ as P,k as z,a0 as _,y as E,a1 as ne,S as ae,C as ie,A as re,E as oe,F as O,a2 as te}from"./App-CGiS2z40.js";import{c as M,B as r,T as w,a as C,b as R,o as h}from"./index-ChKJF4C_.js";import{I as le}from"./IconFolderPlus-BJIo1hfe.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";const ce=[["path",{d:"M3 21v-4a3 3 0 0 1 3 -3h5",key:"svg-0"}],["path",{d:"M8 17l3 -3l-3 -3",key:"svg-1"}],["path",{d:"M3 11v-5a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8",key:"svg-2"}]],de=M("outline","folder-symlink","FolderSymlink",ce);const me=[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]],he=M("outline","pencil","Pencil",me),B="__opentig_no_project__";function ve({open:l,projects:c,repositories:v,onOpenChange:L,onOrganizationChange:A,onForgetRepository:G,onRelocateRepository:S}){const[J,u]=o.useState(null),[x,f]=o.useState(null),[N,D]=o.useState(""),[g,d]=o.useState(null),[b,T]=o.useState(""),[K,p]=o.useState(null),[n,y]=o.useState(null),[$,m]=o.useState(null),V=o.useMemo(()=>new Map(c.flatMap(s=>s.repositoryKeys.map(a=>[a,s.id]))),[c]);o.useEffect(()=>{l||(u(null),f(null),d(null),p(null),m(null))},[l]);const j=async(s,a)=>{y(s),m(null);try{const t=await a();return A(t),!0}catch(t){return m(F(t)),!1}finally{y(null)}},W=async s=>{s.preventDefault();const a=N.trim();!a||n||await j("create",()=>h.projects.create(a))&&D("")},X=async s=>{s.preventDefault();const a=b.trim();!g||!a||n||await j(`rename:${g}`,()=>h.projects.rename(g,a))&&d(null)},H=async s=>{n||await j(`remove:${s}`,()=>h.projects.remove(s))&&p(null)},U=async(s,a)=>{n||await j(`assign:${s}`,()=>h.projects.assign(s,a))},Y=async s=>{if(!n){if(m(null),!window.opentigDesktop){f(s);return}y(`relocate:${s.key}`);try{const a=await h.repository.select(`Relocate ${s.name}`);a&&await S(s,a)}catch(a){m(F(a))}finally{y(null)}}};return e.jsxs(q,{open:l,onOpenChange:s=>{n||L(s)},children:[e.jsxs(Q,{className:"repository-projects-dialog w-[min(660px,calc(100vw-2.5rem))]",children:[e.jsxs("header",{className:"repository-projects-header",children:[e.jsxs("div",{children:[e.jsx(Z,{children:"Manage projects"}),e.jsx(ee,{children:"Group repositories, update their locations, or remove them from OpenTig. Files stay on disk."})]}),e.jsx(I,{render:e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":"Close project management",disabled:!!n}),children:e.jsx(se,{})})]}),e.jsxs("div",{className:"repository-projects-body",children:[$&&e.jsxs("div",{className:"repository-projects-error",role:"alert",children:[e.jsx(k,{"aria-hidden":"true"}),e.jsx("span",{children:$})]}),e.jsxs("section",{className:"repository-projects-section","aria-labelledby":"projects-heading",children:[e.jsxs("div",{className:"repository-projects-section-heading",children:[e.jsxs("h3",{id:"projects-heading",children:["Projects ",e.jsx("span",{children:c.length})]}),e.jsxs("form",{className:"repository-project-create",onSubmit:s=>{W(s)},children:[e.jsx("label",{className:"sr-only",htmlFor:"new-project-name",children:"Project name"}),e.jsx("input",{id:"new-project-name",value:N,maxLength:P,onChange:s=>D(s.target.value),placeholder:"New project name",disabled:!!n}),e.jsxs(r,{type:"submit",size:"sm",disabled:!N.trim()||!!n,children:[n==="create"?e.jsx(z,{className:"animate-spin"}):e.jsx(le,{})," Create"]})]})]}),e.jsxs("div",{className:"repository-project-list",children:[c.length===0&&e.jsx("p",{className:"repository-projects-empty",children:"No projects yet. Create one to group related repositories."}),c.map(s=>{const a=s.repositoryKeys.length,t=n===`rename:${s.id}`||n===`remove:${s.id}`;return e.jsx("div",{className:"repository-project-row","aria-busy":t||void 0,children:g===s.id?e.jsxs("form",{className:"repository-inline-form",onSubmit:i=>{X(i)},onKeyDown:i=>{i.key==="Escape"&&d(null)},children:[e.jsxs("label",{className:"sr-only",htmlFor:`rename-project-${s.id}`,children:["Rename ",s.name]}),e.jsx("input",{id:`rename-project-${s.id}`,autoFocus:!0,value:b,maxLength:P,onChange:i=>T(i.target.value),disabled:!!n}),e.jsx(r,{type:"submit",size:"xs",disabled:!b.trim()||!!n,children:"Save"}),e.jsx(r,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(null),disabled:!!n,children:"Cancel"})]}):K===s.id?e.jsxs("div",{className:"repository-project-confirm",role:"alert",children:[e.jsx(k,{"aria-hidden":"true"}),e.jsxs("span",{children:["Delete ",e.jsx("strong",{children:s.name}),"? Its repositories stay available, just ungrouped."]}),e.jsx(r,{variant:"destructive",size:"xs",disabled:!!n,onClick:()=>{H(s.id)},children:"Delete"}),e.jsx(r,{variant:"ghost",size:"xs",disabled:!!n,onClick:()=>p(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"repository-project-icon","aria-hidden":"true",children:e.jsx(_,{})}),e.jsxs("span",{className:"repository-project-copy",children:[e.jsx("strong",{children:s.name}),e.jsxs("small",{children:[a," ",a===1?"repository":"repositories"]})]}),e.jsxs("span",{className:"repository-row-actions",children:[e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${s.name}`,disabled:!!n,onClick:()=>{d(s.id),T(s.name),p(null)},children:e.jsx(he,{})}),e.jsx(r,{variant:"ghost",size:"icon-sm",className:"repository-row-delete","aria-label":`Delete ${s.name}`,disabled:!!n,onClick:()=>{p(s.id),d(null)},children:e.jsx(E,{})})]})]})},s.id)})]})]}),e.jsxs("section",{className:"repository-projects-section","aria-labelledby":"repository-assignments-heading",children:[e.jsxs("div",{className:"repository-projects-section-heading",children:[e.jsxs("h3",{id:"repository-assignments-heading",children:["Repositories ",e.jsx("span",{children:v.length})]}),e.jsx("p",{children:"One project per repository"})]}),e.jsxs("div",{className:"repository-assignment-list",children:[v.length===0&&e.jsx("p",{className:"repository-projects-empty",children:"No recent repositories to assign yet."}),v.map(s=>{const a=V.get(s.key)??B,t=n?.endsWith(`:${s.key}`);return e.jsx("div",{className:"repository-assignment-row","aria-busy":t||void 0,children:J===s.key?e.jsxs("div",{className:"repository-project-confirm",role:"alert",children:[e.jsx(k,{"aria-hidden":"true"}),e.jsxs("span",{children:["Remove ",e.jsx("strong",{children:s.name})," and its worktrees from OpenTig? Their folders and files stay on disk. You can open them again later."]}),e.jsx(r,{variant:"destructive",size:"xs",disabled:!!n,onClick:()=>{j(`forget:${s.key}`,()=>G(s)).then(i=>{i&&u(null)})},children:"Remove"}),e.jsx(r,{variant:"ghost",size:"xs",disabled:!!n,onClick:()=>u(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx(_,{"aria-hidden":"true"}),e.jsxs("span",{className:"repository-assignment-copy",children:[e.jsx("strong",{children:s.name}),e.jsxs(w,{children:[e.jsx(C,{render:e.jsx("small",{}),children:ne(s.rootPath,4)}),e.jsx(R,{children:s.rootPath})]})]}),t&&e.jsx(z,{className:"repository-assignment-busy animate-spin","aria-hidden":"true"}),e.jsxs(ae,{value:a,onValueChange:i=>{U(s.key,i===B?null:i)},disabled:!!n,children:[e.jsx(ie,{size:"sm","aria-label":`Project for ${s.name}`,children:e.jsx(re,{children:c.find(i=>i.id===a)?.name??"No project"})}),e.jsxs(oe,{align:"end",alignItemWithTrigger:!1,children:[e.jsx(O,{value:B,children:"No project"}),c.map(i=>e.jsx(O,{value:i.id,children:i.name},i.id))]})]}),e.jsxs("span",{className:"repository-management-actions",children:[e.jsxs(w,{children:[e.jsx(C,{render:e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":`Relocate ${s.name}`,disabled:!!n,onClick:()=>{Y(s)}}),children:e.jsx(de,{})}),e.jsx(R,{children:"Relocate repository"})]}),e.jsxs(w,{children:[e.jsx(C,{render:e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${s.name} from OpenTig`,disabled:!!n,onClick:()=>{u(s.key),m(null)}}),children:e.jsx(E,{})}),e.jsx(R,{children:"Remove from OpenTig"})]})]})]})},s.key)})]})]})]}),e.jsx("footer",{className:"repository-projects-footer",children:e.jsx(I,{render:e.jsx(r,{variant:"outline",size:"sm",disabled:!!n}),children:"Done"})})]}),e.jsx(te,{open:x!==null,onOpenChange:s=>{s||f(null)},title:"Relocate repository",description:`Choose the existing server folder for ${x?.name??"this repository"}. This updates its saved location; it does not move files.`,confirmLabel:"Use this folder",onBrowse:h.repository.browseDirectories,onOpen:async s=>{x&&await S(x,s)}})]})}function F(l){return l instanceof Error?l.message:String(l)}export{ve as RepositoryProjectsDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,j as e}from"./react-rd22PHbN.js";import{a6 as pe,a7 as A,U as P,j as fe,G as Y,k as me}from"./App-CGiS2z40.js";import{u as xe,a as ve}from"./tanstack-CtfgE41X.js";import{c as x,B as k,T as W,a as D,b as O,s as m,o as J,q as je}from"./index-ChKJF4C_.js";import"./base-ui-DT3JsyND.js";const ye=[["path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828",key:"svg-0"}],["path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87",key:"svg-1"}],["path",{d:"M3 3l18 18",key:"svg-2"}]],X=x("outline","eye-off","EyeOff",ye);const ke=[["path",{d:"M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0 -7 0",key:"svg-0"}],["path",{d:"M3 19v-10.5a3.5 3.5 0 0 1 7 0v10.5",key:"svg-1"}],["path",{d:"M3 13h7",key:"svg-2"}],["path",{d:"M21 12v7",key:"svg-3"}]],Me=x("outline","letter-case","LetterCase",ke);const Ne=[["path",{d:"M6.5 15a2.5 2.5 0 1 1 0 5a2.5 2.5 0 0 1 0 -5",key:"svg-0"}],["path",{d:"M17 7.875l3 -1.687",key:"svg-1"}],["path",{d:"M17 7.875v3.375",key:"svg-2"}],["path",{d:"M17 7.875l-3 -1.687",key:"svg-3"}],["path",{d:"M17 7.875l3 1.688",key:"svg-4"}],["path",{d:"M17 4.5v3.375",key:"svg-5"}],["path",{d:"M17 7.875l-3 1.688",key:"svg-6"}]],be=x("outline","regex","Regex",Ne);const we=[["path",{d:"M3 4a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-0"}],["path",{d:"M15 16a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-1"}],["path",{d:"M21 11v-3a2 2 0 0 0 -2 -2h-6l3 3m0 -6l-3 3",key:"svg-2"}],["path",{d:"M3 13v3a2 2 0 0 0 2 2h6l-3 -3m0 6l3 -3",key:"svg-3"}]],Z=x("outline","replace","Replace",we);const Se=[["path",{d:"M4 6l10 0",key:"svg-0"}],["path",{d:"M4 18l10 0",key:"svg-1"}],["path",{d:"M4 12h17l-3 -3m0 6l3 -3",key:"svg-2"}]],$e=x("outline","text-wrap-disabled","TextWrapDisabled",Se);const Re=[["path",{d:"M8 2h-4a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2 -2v-4a2 2 0 0 0 -2 -2z",key:"svg-0"}],["path",{d:"M20 14h-4a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2 -2v-4a2 2 0 0 0 -2 -2z",key:"svg-1"}],["path",{d:"M16.707 2.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.293 1.293h3.586a3 3 0 0 1 2.995 2.824l.005 .176v3a1 1 0 0 1 -1.993 .117l-.007 -.117v-3a1 1 0 0 0 -.883 -.993l-.117 -.007h-3.585l1.292 1.293a1 1 0 0 1 -1.32 1.497l-.094 -.083l-3 -3a.98 .98 0 0 1 -.28 -.872l.036 -.146l.04 -.104c.058 -.126 .14 -.24 .245 -.334l2.959 -2.958a1 1 0 0 1 1.414 0z",key:"svg-2"}],["path",{d:"M3 12a1 1 0 0 1 .993 .883l.007 .117v3a1 1 0 0 0 .883 .993l.117 .007h3.585l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083l.094 .083l3 3a.98 .98 0 0 1 .28 .872l-.036 .146l-.04 .104a1.02 1.02 0 0 1 -.245 .334l-2.959 2.958a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.291 -1.293h-3.584a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-3a1 1 0 0 1 1 -1z",key:"svg-3"}]],ee=x("filled","replace-filled","ReplaceFilled",Re);function Ce(l){return l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(l){if(!l.query)return null;const c=l.regex?l.query:Ce(l.query),i=l.wholeWord?`\\b(?:${c})\\b`:c;try{return new RegExp(i,l.matchCase?"g":"gi")}catch{return null}}const Te=250,Ee=28,_e=24;function He({repositoryId:l,active:c,revision:i,onOpenFile:h,unsavedPathsAmong:g,onReplaced:o}){const B=pe(),[f,ae]=t.useState(""),[M,se]=t.useState(!1),[N,te]=t.useState(!1),[b,le]=t.useState(!1),[p,ne]=t.useState(!1),[H,re]=t.useState(""),[w,ce]=t.useState(!1),[S,ie]=t.useState(!1),[$,G]=t.useState(!1),[oe,he]=t.useState(0),[L,Q]=t.useState(()=>new Set),K=t.useRef(null),U=t.useRef(null),R=t.useMemo(()=>({query:f,matchCase:M,wholeWord:N,regex:b,includeIgnored:w}),[f,M,N,b,w]),de=t.useMemo(()=>Ie(R),[R]),v=f.trim(),C=ze(v,Te),d=xe({queryKey:je.search(l,{query:C,matchCase:M,wholeWord:N,regex:b,includeIgnored:w,revision:i,replaceRevision:oe}),queryFn:()=>J.repository.search(l,{...R,query:C}),enabled:c&&C.length>0,placeholderData:(a,s)=>s?.queryKey[1]===l?a:void 0}),n=v?d.data??null:null,z=!!v&&(C!==v||d.isFetching),V=v&&d.error?d.error instanceof Error?d.error.message:"The search failed.":null;t.useEffect(()=>{c&&K.current?.focus()},[c]),t.useEffect(()=>{d.data&&Q(new Set(d.data.files.filter(a=>a.ignored).map(a=>a.path)))},[d.data]);const I=t.useMemo(()=>{if(!n)return[];const a=[];for(const s of n.files){const u=!L.has(s.path);if(a.push({kind:"file",file:s,open:u}),u)for(const E of s.matches)a.push({kind:"match",file:s,match:E})}return a},[L,n]),T=ve({count:I.length,getScrollElement:()=>U.current,estimateSize:a=>B?44:I[a]?.kind==="file"?Ee:_e,getItemKey:a=>{const s=I[a];return s?s.kind==="file"?`file:${s.file.path}`:`match:${s.file.path}:${s.match.line}:${s.match.column??1}`:a},overscan:12});t.useEffect(()=>{T.measure()},[T,B]);const ue=a=>Q(s=>{const u=new Set(s);return u.delete(a)||u.add(a),u}),j=n?.files.filter(a=>a.ignored).length??0,y=n?.files.filter(a=>!!a.revision&&(S||!a.ignored))??[],q=async a=>{if(!n||$)return;const s=a==="all"?{kind:"all",files:y.map(r=>({path:r.path,revision:r.revision}))}:"match"in a?{kind:"match",path:a.file.path,revision:a.file.revision,line:a.match.line,column:a.match.column}:{kind:"file",path:a.path,revision:a.revision};if(s.kind==="all"){if(n.truncated){m.info({title:"Narrow the search before replacing all",description:"The current result set is truncated."});return}const r=y.reduce((F,ge)=>F+ge.matches.length,0);if(!r||!window.confirm(`Replace ${r} ${r===1?"occurrence":"occurrences"} in ${y.length} ${y.length===1?"file":"files"}?`))return}else if(s.kind==="file"&&a!=="all"&&!("match"in a)&&a.truncatedMatches&&!window.confirm(`${a.path} has more matches than the ${a.matches.length} listed. Replace every occurrence in the file?`))return;const u=s.kind==="all"?s.files.map(r=>r.path):[s.path],E=g(u);if(E.length>0){m.error({title:"Save open files before replacing in them",description:E.join(", "),duration:1e4});return}G(!0);try{const r=await J.repository.replaceSearch(l,{options:{...R,query:f.trim()},replacement:H,scope:s});r.status==="stale"?m.error({title:"Files changed before replacement",description:"Search results were refreshed without overwriting anything."}):r.status==="no-match"?m.info({title:"No matching text to replace"}):(m.success({title:`Replaced ${r.replacements} ${r.replacements===1?"occurrence":"occurrences"}`,description:`${r.files.length} ${r.files.length===1?"file":"files"} changed`}),o(r.files)),he(F=>F+1)}catch(r){m.error({title:"Could not replace search results",description:r instanceof Error?r.message:"Unknown error",duration:1e4})}finally{G(!1)}};return e.jsxs("div",{className:"search-view",children:[e.jsxs("div",{className:"search-controls",children:[e.jsxs("div",{className:"search-query-row",children:[e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-toggle","aria-label":p?"Hide replace":"Show replace","aria-expanded":p,onClick:()=>ne(a=>!a),children:p?e.jsx(A,{}):e.jsx(P,{})}),e.jsxs("div",{className:"search-input",children:[e.jsx(fe,{"aria-hidden":"true"}),e.jsx("input",{ref:K,type:"text",value:f,spellCheck:!1,placeholder:"Search in repository","aria-label":"Search in repository",onChange:a=>ae(a.target.value)}),e.jsxs("span",{className:"search-toggles",children:[e.jsx(_,{label:"Match case",active:M,onToggle:()=>se(a=>!a),children:e.jsx(Me,{})}),e.jsx(_,{label:"Match whole word",active:N,onToggle:()=>te(a=>!a),children:e.jsx($e,{})}),e.jsx(_,{label:"Use regular expression",active:b,onToggle:()=>le(a=>!a),children:e.jsx(be,{})}),e.jsx(_,{label:"Search Git-ignored files",active:w,onToggle:()=>ce(a=>!a),children:e.jsx(X,{})})]})]})]}),p&&e.jsxs("div",{className:"search-replace-row",children:[e.jsx(Z,{"aria-hidden":"true"}),e.jsx("input",{value:H,spellCheck:!1,placeholder:"Replace","aria-label":"Replace with",onChange:a=>re(a.target.value)}),e.jsxs(W,{children:[e.jsx(D,{render:e.jsx(k,{variant:"ghost",size:"icon-xs",disabled:$||y.length===0||!!n?.truncated,"aria-label":"Replace all search results",onClick:()=>{q("all")}}),children:e.jsx(ee,{})}),e.jsx(O,{children:n?.truncated?"Narrow the search to replace all":"Replace all"})]})]}),p&&j>0&&e.jsxs("label",{className:"search-include-ignored",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:a=>ie(a.target.checked)})," Include ignored files when replacing"]}),f.trim()!==""&&(n!==null||!z)&&e.jsx("div",{className:"search-summary",children:z?e.jsx(Y,{text:"Searching…"}):V?e.jsx("span",{className:"search-error",children:V}):n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:n.totalMatches===0?"No results":`${n.totalMatches-n.ignoredMatches}${n.truncated?"+":""} ${n.totalMatches-n.ignoredMatches===1?"result":"results"} in ${n.files.length-j} ${n.files.length-j===1?"file":"files"}`}),n.ignoredMatches>0&&e.jsxs("span",{className:"search-summary-ignored",children:["· ",n.ignoredMatches," in ",j," ignored ",j===1?"file":"files"]})]})})]}),e.jsxs("div",{ref:U,className:"search-results",children:[z&&!n&&e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(me,{className:"spinner"})," ",e.jsx(Y,{text:"Searching…"})]}),e.jsx("div",{className:"search-rows virtual-list",style:{height:T.getTotalSize()},children:T.getVirtualItems().map(a=>{const s=I[a.index];return s?e.jsx("div",{className:"virtual-row",style:{height:a.size,transform:`translateY(${a.start}px)`},children:s.kind==="file"?e.jsxs("div",{className:`search-file-heading ${s.file.ignored?"ignored":""}`,children:[e.jsxs("button",{className:"search-file-toggle",onClick:()=>ue(s.file.path),"aria-expanded":s.open,children:[s.open?e.jsx(A,{}):e.jsx(P,{}),e.jsx("span",{className:"search-file-name",children:s.file.path}),s.file.ignored&&e.jsxs(W,{children:[e.jsx(D,{render:e.jsx("span",{className:"search-file-ignored-badge"}),children:e.jsx(X,{})}),e.jsx(O,{children:"Ignored by Git"})]}),e.jsx("span",{className:"search-file-count",children:s.file.matches.length})]}),p&&s.file.revision&&(!s.file.ignored||S)&&e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-action",disabled:$,"aria-label":`Replace all in ${s.file.path}`,onClick:()=>{q(s.file)},children:e.jsx(ee,{})})]}):e.jsxs("div",{className:"search-match",children:[e.jsxs("button",{className:"search-match-open",onClick:()=>h(s.file.path),children:[e.jsxs("span",{className:"search-match-line",children:[s.match.line,":",s.match.column??1]}),e.jsx("span",{className:"search-match-text",children:qe(s.match.text,de)})]}),p&&s.file.revision&&s.match.column&&(!s.file.ignored||S)&&e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-action",disabled:$,"aria-label":`Replace match on line ${s.match.line}`,onClick:()=>{q({file:s.file,match:s.match})},children:e.jsx(Z,{})})]})},a.key):null})})]})]})}function ze(l,c){const[i,h]=t.useState(l);return t.useEffect(()=>{const g=window.setTimeout(()=>h(l),c);return()=>window.clearTimeout(g)},[c,l]),i}function _({label:l,active:c,onToggle:i,children:h}){return e.jsxs(W,{children:[e.jsx(D,{render:e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-toggle","aria-label":l,"aria-pressed":c,onClick:i}),children:h}),e.jsx(O,{children:l})]})}function qe(l,c){const i=l.replace(/^\s+/,"");if(!c)return i;c.lastIndex=0;const h=[];let g=0;for(let o=c.exec(i);o!==null;o=c.exec(i)){if(o[0]===""){c.lastIndex+=1;continue}h.push(e.jsx(t.Fragment,{children:i.slice(g,o.index)},`${o.index}-plain`),e.jsx("mark",{children:o[0]},`${o.index}-hit`)),g=o.index+o[0].length}return h.length===0?i:(h.push(e.jsx(t.Fragment,{children:i.slice(g)},"tail")),h)}export{He as SearchView};
|