pi-webapp 0.1.57 → 0.1.58-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension.js +71 -71
- package/dist/hosted-recovery.js +2 -2
- package/dist/hosted-worker.js +2 -2
- package/docs/desktop.md +16 -5
- package/package.json +3 -2
- package/web/dist/.vite/manifest.json +80 -64
- package/web/dist/assets/{MarkdownText-Ca6_qCyr.js → MarkdownText-BmWua1fx.js} +11 -11
- package/web/dist/assets/WorkspacePanel.module-q1UBTZQr.js +2 -0
- package/web/dist/assets/app-Bl_vjH4f.js +53 -0
- package/web/dist/assets/app.css +1 -1
- package/web/dist/assets/app.js +4 -4
- package/web/dist/assets/{code-editor-B5kVAtku.js → code-editor-bWuZTiS2.js} +4 -4
- package/web/dist/assets/{icons-D8yiYkWB.js → code-file-types-BZAEsqNG.js} +3 -3
- package/web/dist/assets/{dist-CWWynAS-.js → dist-B8Mp_VTU.js} +2 -2
- package/web/dist/assets/{dist-o-4nubru.js → dist-BD_2QeWa.js} +2 -2
- package/web/dist/assets/{dist-Im2q9dJ0.js → dist-C2WSXtwq.js} +2 -2
- package/web/dist/assets/{dist-BRYLL4VU.js → dist-C7kRRV1b.js} +2 -2
- package/web/dist/assets/{dist-CaNhruaD.js → dist-CCfANS3F.js} +2 -2
- package/web/dist/assets/{dist-BFhI7cEI.js → dist-CP5SBgQB.js} +2 -2
- package/web/dist/assets/{dist-DAlictfL.js → dist-CmPE8_f_.js} +2 -2
- package/web/dist/assets/{dist-CszBAiM6.js → dist-D-nx7RRS.js} +2 -2
- package/web/dist/assets/{dist-BYJ4SXpR.js → dist-DFTCmV51.js} +2 -2
- package/web/dist/assets/{dist-CsFhAvz7.js → dist-Dr0qO3Zr.js} +2 -2
- package/web/dist/assets/{dist-CqXTRhJp.js → dist-Nlb4zANG.js} +2 -2
- package/web/dist/assets/{graphql-Cz1_wnUp.js → graphql-B5jxVvgN.js} +2 -2
- package/web/dist/assets/{http-CTlzQwRP.js → http-C6M1fy61.js} +2 -2
- package/web/dist/assets/{php-BHNgHgMp.js → php-B61pLHqK.js} +2 -2
- package/web/dist/assets/{plugin-D1z0mcl1.js → plugin-CE1WaS8V.js} +4 -4
- package/web/dist/assets/plugin-CsVaeNQM.js +6 -0
- package/web/dist/assets/plugin-Cyidq4oP.js +2 -0
- package/web/dist/assets/plugin-Gwwlx9MU.js +4 -0
- package/web/dist/assets/plugin.css +1 -1
- package/web/dist/assets/plugin2.css +1 -1
- package/web/dist/assets/plugin3.css +1 -0
- package/web/dist/assets/{rst-BdGjFUxD.js → rst-950N-2sy.js} +2 -2
- package/web/dist/assets/{ruby-D7-ny0V-.js → ruby-Qm2HAXfx.js} +2 -2
- package/web/dist/assets/{svelte-DoD3sicb.js → svelte-CoZSSs0h.js} +2 -2
- package/web/dist/assets/{vue-BYLUelN7.js → vue-as6FrWIW.js} +2 -2
- package/web/dist/assets/WorkspacePanel.module-V6gI-nG1.js +0 -2
- package/web/dist/assets/app-CIlV3hYO.js +0 -49
- package/web/dist/assets/plugin-CZx51rmJ.js +0 -6
- package/web/dist/assets/plugin-CvqNiFRV.js +0 -4
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/code-editor-B5kVAtku.js","assets/rolldown-runtime-CgmABjMJ.js","assets/dist-IkQ96Etc.js","assets/app.js","assets/app-CIlV3hYO.js","assets/react-CLFE7TFE.js","assets/icons-D8yiYkWB.js","assets/clsx-DQAHfk8w.js","assets/WorkspacePanel.module-V6gI-nG1.js","assets/WorkspacePanel.css","assets/app.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`4a6ac633-a73b-4972-8f4a-643ef772cd14`,e._sentryDebugIdIdentifier=`sentry-dbid-4a6ac633-a73b-4972-8f4a-643ef772cd14`)}catch{}})();import{r as e}from"./rolldown-runtime-CgmABjMJ.js";import{a as t,c as n,d as r,h as i,m as a,n as o,o as s,p as c,s as l}from"./app-CIlV3hYO.js";import{a as u,c as d,o as f,t as p}from"./WorkspacePanel.module-V6gI-nG1.js";import{t as m}from"./react-CLFE7TFE.js";import{F as h,S as g,g as _,x as v}from"./icons-D8yiYkWB.js";import{a as y,s as b}from"./app.js";import{n as x}from"./clsx-DQAHfk8w.js";var S={id:l.files,kind:`builtin`,version:`1.0.0`,name:{zh:`工作区文件`,en:`Workspace files`},description:{zh:`浏览、搜索工作区文件,预览代码、Markdown 与图片,并编辑文本文件。`,en:`Browse and search workspace files, preview code, Markdown and images, and edit text files.`}},C=e(m(),1);function w(e,t,n){if(!t)return null;let r=t.split(`/`).at(-1)??t,i=n?n.from===n.to?`L${n.from}`:`L${n.from}–${n.to}`:``,a=`${e.replace(/[\\/]+$/u,``)}/${t}`;return{detail:i?`${r} · ${i}`:r,reference:`Open file: ${t} (absolute: ${a}).${n?` Selected lines ${n.from}–${n.to}.`:``}`}}async function T(e,n,r,i){return s(await t(`/api/workspace/files/${e}`,{method:`POST`,headers:{Authorization:`Bearer ${b()}`,"Content-Type":`application/json`},body:JSON.stringify({sessionId:n,...r}),signal:i}))}async function E(e,n,r){let i=await t(`/api/workspace/files/raw`,{method:`POST`,headers:{Authorization:`Bearer ${b()}`,"Content-Type":`application/json`},body:JSON.stringify({sessionId:e,path:n}),signal:r});return i.response.ok?i.response.blob():s(i)}var D={raw:E,list:(e,t,n)=>T(`list`,e,{path:t},n),preview:(e,t,n)=>T(`preview`,e,{path:t},n),write:(e,t,n,r)=>T(`write`,e,{path:t,text:n,version:r}),status:(e,t)=>T(`status`,e,{},t),search:(e,t,n,r)=>T(`search`,e,{query:t,mode:n},r)},O=x(),k,A=()=>k??=y(()=>import(`./code-editor-B5kVAtku.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]));function ee({text:e,filename:t,label:n,reveal:r,autoFocus:a,onChange:o,onSave:s,onSelection:c}){let l=(0,C.useRef)(null),[u,d]=(0,C.useState)(),[f,m]=(0,C.useState)(!1),h=(0,C.useRef)({onChange:o,onSave:s,onSelection:c});(0,C.useLayoutEffect)(()=>{h.current={onChange:o,onSave:s,onSelection:c}});let g=(0,C.useRef)(e);return(0,C.useEffect)(()=>{let e,r=!1;return A().then(({createCodeEditor:i})=>{!r&&l.current&&(e=i(l.current,{text:g.current,filename:t,label:n,onChange:e=>h.current.onChange(e),onSave:()=>h.current.onSave(),onSelection:e=>h.current.onSelection?.(e)}),d(e))}).catch(()=>{r||m(!0)}),()=>{r=!0,e?.destroy(),h.current.onSelection?.(null)}},[t,n]),(0,C.useEffect)(()=>{u?.setText(e)},[u,e]),(0,C.useEffect)(()=>{u&&r&&u.reveal(r.line)},[u,r]),(0,C.useEffect)(()=>{u&&a&&u.focus()},[u,a]),f?(0,O.jsx)(`p`,{className:p.state,role:`status`,children:i(`编辑器加载失败,请重新读取文件。`,`The editor could not load. Reload the file to try again.`)}):(0,O.jsx)(`div`,{ref:l,className:p.codeEditor,"aria-busy":!u,children:!u&&(0,O.jsx)(`p`,{className:p.state,children:i(`正在打开编辑器…`,`Opening the editor…`)})})}function te(e,t){let n=t.replace(/[?#].*$/u,``);try{n=decodeURI(n)}catch{}if(n===``||n.includes(`\\`)||n.includes(`\0`)||/^[a-z][a-z\d+.-]*:/iu.test(n)||n.startsWith(`//`))return;let r=n.startsWith(`/`)?[]:e.split(`/`).slice(0,-1);for(let e of n.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(r.pop()===void 0)return}else r.push(e)}return r.length?r.join(`/`):void 0}var ne=e=>e.replace(/\r\n/gu,`
|
|
3
|
-
`),j=(0,C.memo)(function({sessionId:e,path:t,renderMarkdown:a,breadcrumb:o,trailing:s,refresh:c=0,reveal:l,onDirtyChange:u,onSaved:d,onSelection:f}){let[m,h]=(0,C.useState)(null),[g,_]=(0,C.useState)(!0),[y,b]=(0,C.useState)(!1),[x,S]=(0,C.useState)(0),[w,T]=(0,C.useState)(!1),[E,k]=(0,C.useState)(!1),[A,j]=(0,C.useState)(null),[M,N]=(0,C.useState)(!1),[P,F]=(0,C.useState)(!1),[I,L]=(0,C.useState)(null);(0,C.useEffect)(()=>{let n=new AbortController;return _(!0),b(!1),k(!1),T(!1),D.preview(e,t,n.signal).then(e=>{n.signal.aborted||(h(e),_(!1))}).catch(()=>{n.signal.aborted||(b(!0),_(!1))}),()=>n.abort()},[e,t,x]);let R=A!==null,z=(0,C.useRef)(R);(0,C.useLayoutEffect)(()=>{z.current=R});let B=(0,C.useRef)(c);(0,C.useEffect)(()=>{c===B.current||z.current||S(e=>e+1)},[c]);let V=/\.(?:md|markdown|mdown)$/i.test(t),H=t.split(`/`).at(-1),[U,W]=(0,C.useState)(0),G=(0,C.useRef)(new Map);(0,C.useEffect)(()=>{let e=G.current;return e.clear(),()=>{for(let t of e.values())t&&URL.revokeObjectURL(t);e.clear()}},[e,t,x]);let K=(0,C.useMemo)(()=>({resolve(n){let r=te(t,n);if(r===void 0)return;let i=G.current,a=i.get(r);if(a!==void 0)return a??void 0;i.set(r,null),D.raw(e,r,new AbortController().signal).then(e=>{G.current===i&&i.get(r)===null&&(i.set(r,URL.createObjectURL(e)),W(e=>e+1))}).catch(()=>{})}}),[e,t,x,U]),q=m?.kind===`text`?m:null,J=q?ne(q.text):``,Y=A??J,X=q!==null&&(!V||M);(0,C.useEffect)(()=>{u?.(R)},[R,u]),(0,C.useEffect)(()=>()=>u?.(!1),[u]),(0,C.useEffect)(()=>{l&&V&&N(!0)},[l,V]);let re=()=>!R||window.confirm(i(`放弃未保存的更改?`,`Discard unsaved changes?`)),Z=()=>{re()&&(j(null),L(null),S(e=>e+1))},Q=async(r=!1)=>{if(q&&A!==null&&!P){F(!0),L(null);try{let n=q.version;if(r){let r=await D.preview(e,t,new AbortController().signal);if(r.kind!==`text`)throw Error(`not text`);n=r.version}let i=q.text.includes(`\r
|
|
4
|
-
`)?A.replace(/\n/gu,`\r
|
|
5
|
-
`):A,a=await D.write(e,t,i,n);h({...q,text:i,version:a.version,size:a.size}),j(null),d?.()}catch(e){e instanceof n&&e.status===409&&e.reason===`conflict`?L({kind:`conflict`}):e instanceof n&&e.status===413?L({kind:`error`,message:i(`内容过大,无法保存(最多 5 MB、200,000 行)。`,`Too large to save (5 MB or 200,000 lines at most).`)}):e instanceof n&&e.status===409?L({kind:`error`,message:i(`会话已切换,未保存。`,`The session changed, so nothing was saved.`)}):L({kind:`error`,message:i(`保存失败,文件可能已移动、删除或无权写入。`,`Could not save. The file may have moved, been deleted, or be read-only.`)})}finally{F(!1)}}},$=(0,C.useMemo)(()=>m?.kind===`image`?`data:${m.mimeType};base64,${m.data}`:null,[m]);return(0,O.jsxs)(`div`,{className:p.body,children:[(0,O.jsxs)(`div`,{className:p.toolbar,children:[o??(0,O.jsx)(`span`,{className:p.path,title:t,children:t}),R&&(0,O.jsx)(`span`,{className:p.unsaved,role:`status`,children:i(`未保存`,`Unsaved`)}),!q&&(0,O.jsx)(`span`,{className:p.readonly,children:i(`只读`,`Read only`)}),V&&q&&(0,O.jsx)(`button`,{type:`button`,className:p.textButton,"aria-pressed":M,onClick:()=>N(e=>!e),children:M?i(`预览`,`Preview`):i(`编辑`,`Edit`)}),q&&(0,O.jsx)(`button`,{type:`button`,className:`${p.textButton} ${p.primaryButton}`,disabled:!R||P,title:i(`保存(⌘/Ctrl+S)`,`Save (⌘/Ctrl+S)`),onClick:()=>void Q(),children:P?i(`正在保存…`,`Saving…`):i(`保存`,`Save`)}),(0,O.jsx)(`button`,{type:`button`,className:p.iconButton,"aria-label":i(`重新读取文件`,`Reload file`),title:i(`重新读取文件`,`Reload file`),onClick:Z,children:(0,O.jsx)(v,{})}),s]}),I&&(0,O.jsx)(`div`,{className:p.saveProblem,role:`alert`,children:I.kind===`conflict`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{children:i(`文件在你编辑期间已在磁盘上更改。`,`This file changed on disk while you were editing.`)}),(0,O.jsx)(`button`,{type:`button`,className:p.textButton,onClick:()=>{j(null),L(null),S(e=>e+1)},children:i(`放弃我的更改并重新读取`,`Discard mine and reload`)}),(0,O.jsx)(`button`,{type:`button`,className:p.textButton,onClick:()=>void Q(!0),children:i(`覆盖`,`Overwrite`)})]}):(0,O.jsx)(`span`,{children:I.message})}),(0,O.jsx)(`div`,{className:p.preview,"aria-busy":g,children:g&&!m?(0,O.jsx)(`p`,{className:p.state,role:`status`,children:i(`正在读取…`,`Reading…`)}):y?(0,O.jsxs)(`div`,{className:p.state,role:`status`,children:[(0,O.jsx)(`p`,{children:i(`文件读取失败,可能已移动、删除或无权访问。`,`Could not read this file. It may have moved, been deleted, or be inaccessible.`)}),(0,O.jsx)(`button`,{type:`button`,className:p.textButton,onClick:Z,children:i(`重试`,`Retry`)})]}):m?m.kind===`too-large`?(0,O.jsx)(`p`,{className:p.state,children:m.unit===`lines`?i(`文件行数过多,最多打开 ${m.limit.toLocaleString()} 行。`,`File has too many lines. Limit: ${m.limit.toLocaleString()} lines.`):i(`文件过大,无法打开。大小上限:${m.limit/1024/1024} MB`,`File is too large to open. Limit: ${m.limit/1024/1024} MB`)}):m.kind===`unsupported`?(0,O.jsx)(`p`,{className:p.state,children:i(`暂不支持预览此文件类型。`,`Preview is unavailable for this file type.`)}):m.kind===`image`&&$?E?(0,O.jsx)(`p`,{className:p.state,children:i(`图片无法解码。`,`This image could not be decoded.`)}):(0,O.jsx)(`button`,{type:`button`,className:p.imageButton,"aria-label":i(`放大图片`,`Enlarge image`),onClick:()=>T(!0),children:(0,O.jsx)(`img`,{className:p.image,src:$,alt:H,onError:()=>k(!0)})}):m.kind===`text`?X?(0,O.jsx)(ee,{text:Y,filename:H,label:i(`编辑 ${H}`,`Edit ${H}`),reveal:l,autoFocus:V,onChange:e=>j(e===J?null:e),onSave:()=>void Q(),onSelection:f}):Y.trim()===``?(0,O.jsx)(`p`,{className:p.state,children:i(`空文件`,`Empty file`)}):(0,O.jsx)(`div`,{className:p.markdown,children:a(Y,K)}):null:null}),w&&$&&(0,O.jsx)(r,{src:$,alt:H,labels:{dialog:i(`图片预览`,`Image preview`),close:i(`关闭图片预览`,`Close image preview`)},onClose:()=>T(!1)})]})}),M=h(),N={ignored:0,untracked:1,added:2,modified:3,conflict:4},P={of:()=>void 0};function F(e){let t=new Map,n=[],r=new Map,i=(e,t)=>{let n=r.get(e);(n===void 0||N[t]>N[n])&&r.set(e,t)};for(let{path:r,state:a}of e.entries){let e=a===`deleted`?`modified`:a,o=r.endsWith(`/`),s=o?r.slice(0,-1):r;if(o?n.push([s,e]):a!==`deleted`&&t.set(s,e),e===`ignored`)continue;let c=s.split(`/`);for(let t=1;t<c.length;t++)i(c.slice(0,t).join(`/`),e)}return{of(e){let i=t.get(e);if(i)return i;for(let[t,r]of n)if(e===t||e.startsWith(`${t}/`))return r;return r.get(e)}}}var I=(e,t)=>({modified:t(`已修改`,`Modified`),added:t(`已添加`,`Added`),untracked:t(`未跟踪`,`Untracked`),conflict:t(`有冲突`,`Conflict`),ignored:t(`已忽略`,`Ignored`)})[e];function L({size:e,className:t}){return(0,O.jsxs)(`svg`,{width:e,height:e,className:t,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,O.jsx)(`path`,{d:`M2.9 2.26h2.3c.55 0 1.06.27 1.37.73l.46.7c.15.23.41.37.69.37h4.58a1.95 1.95 0 0 1 1.95 1.95v5.83a1.95 1.95 0 0 1-1.95 1.95H2.9A1.95 1.95 0 0 1 .95 11.84V4.21A1.95 1.95 0 0 1 2.9 2.26Z`,fill:`currentColor`,fillOpacity:`.2`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinejoin:`round`}),(0,O.jsx)(`path`,{d:`M1.2 6.45h13.6`,stroke:`currentColor`,strokeWidth:`1.3`})]})}function R({path:e,depth:t,tree:n}){let[r,o]=(0,C.useState)(()=>n.levels.get(e)),[s,c]=(0,C.useState)(!0),[l,u]=(0,C.useState)(!1),[d,m]=(0,C.useState)(0);(0,C.useEffect)(()=>{let t=new AbortController;return c(!0),u(!1),D.list(n.sessionId,e,t.signal).then(r=>{t.signal.aborted||(n.levels.set(e,r),o(r),c(!1))}).catch(()=>{t.signal.aborted||(u(!0),c(!1))}),()=>t.abort()},[n.sessionId,n.levels,e,n.revision,d]);let h=n.compact?14:16,g=n.status??P;return(0,O.jsxs)(O.Fragment,{children:[s&&!r&&(0,O.jsx)(`li`,{role:`none`,className:p.state,"aria-live":`polite`,children:i(`正在读取…`,`Reading…`)}),l&&(0,O.jsxs)(`li`,{role:`none`,className:p.state,children:[(0,O.jsx)(`span`,{role:`status`,children:i(`目录读取失败,可能已移动、删除或无权访问。`,`Could not read this directory. It may have moved, been deleted, or be inaccessible.`)}),` `,(0,O.jsx)(`button`,{type:`button`,className:p.textButton,onClick:()=>m(e=>e+1),children:i(`重试`,`Retry`)})]}),!s&&!l&&r?.entries.length===0&&(0,O.jsx)(`li`,{role:`none`,className:p.state,children:i(`空目录`,`Empty directory`)}),r?.entries.map(e=>{let r=e.kind===`directory`,o=r&&n.expanded.has(e.path),s=e.kind===`other`,c=g.of(e.path);return(0,O.jsxs)(`li`,{role:`treeitem`,tabIndex:s?-1:0,"aria-label":e.name,"aria-level":t,"aria-expanded":r?o:void 0,"aria-disabled":s||void 0,"aria-description":c&&I(c,i),"data-git-status":c,"aria-selected":r||s?void 0:e.path===n.selected,"data-files-path":e.path,children:[(0,O.jsxs)(`div`,{className:p.row,style:{paddingInlineStart:`${(n.compact?8:10)+(t-1)*(n.compact?12:14)}px`},title:s?i(`此条目不可访问或位于工作区之外`,`This entry is unavailable or outside the workspace`):e.path,onClick:t=>{s||(t.currentTarget.parentElement?.focus(),r?n.toggle(e.path):n.open(e.path))},children:[r?o?(0,O.jsx)(a,{size:h,className:p.folderIcon}):(0,O.jsx)(L,{size:h,className:p.folderIcon}):(0,O.jsx)(f,{path:e.name,size:h}),(0,O.jsx)(`span`,{className:p.name,children:e.name}),c&&c!==`ignored`&&(0,O.jsx)(`span`,{className:p.statusDot,"aria-hidden":`true`})]}),o&&(0,O.jsx)(`ul`,{role:`group`,className:p.level,children:(0,O.jsx)(R,{path:e.path,depth:t+1,tree:n})})]},e.path)}),r?.truncated&&(0,O.jsx)(`li`,{role:`none`,className:p.state,children:i(`条目太多,只显示前 1000 项。`,`Too many entries. Showing the first 1,000.`)})]})}function z({root:e,label:t,...n}){let{toggle:r,open:i}=n;return(0,O.jsx)(`ul`,{role:`tree`,"aria-label":t,className:p.tree,onKeyDown:e=>{let t=e.target;if(t.getAttribute(`role`)!==`treeitem`||t.getAttribute(`aria-disabled`)===`true`)return;let n=t.dataset.filesPath,a=t.hasAttribute(`aria-expanded`),o=t.getAttribute(`aria-expanded`)===`true`,s=[...e.currentTarget.querySelectorAll(`[role="treeitem"]:not([aria-disabled="true"])`)],c=s.indexOf(t),l;switch(e.key){case`ArrowDown`:l=s[c+1];break;case`ArrowUp`:l=s[c-1];break;case`Home`:l=s[0];break;case`End`:l=s.at(-1);break;case`ArrowRight`:a&&!o?r(n):o&&(l=s[c+1]);break;case`ArrowLeft`:o?r(n):l=t.parentElement?.closest(`[role="treeitem"]`)??void 0;break;case`Enter`:case` `:a?r(n):i(n);break;default:return}e.preventDefault(),e.stopPropagation(),l?.focus()},children:(0,O.jsx)(R,{path:e,depth:1,tree:n})})}var B=4,V=8,H=360;function U(e,t){let n=t?.split(`/`).slice(0,-1)??[],r=n.map((e,t)=>n.slice(0,t+1).join(`/`));return new Set(r.filter(t=>e===``||t.startsWith(`${e}/`)))}function W({anchor:e,segment:t,sessionId:n,levels:r,selected:a,onOpen:o,onDismiss:s}){let c=(0,C.useRef)(null),[l,f]=(0,C.useState)(()=>U(t.path,a)),[m,h]=(0,C.useState)();(0,C.useLayoutEffect)(()=>{let t=c.current,n=e.getBoundingClientRect(),r=n.bottom+B,i=Math.max(V,Math.min(n.left,window.innerWidth-t.offsetWidth-V));h({top:r,left:i,maxHeight:Math.min(H,Math.max(160,window.innerHeight-r-V))}),u(t)},[e]),(0,C.useEffect)(()=>{let t=t=>{t.target instanceof Node&&(c.current?.contains(t.target)||e.contains(t.target))||s()},n=t=>{if(t.key!==`Escape`||t.isComposing||t.defaultPrevented||t.ctrlKey||t.altKey||t.metaKey||t.shiftKey)return;t.preventDefault(),t.stopPropagation();let n=c.current?.contains(document.activeElement)||document.activeElement===document.body||document.activeElement===e;s(),n&&u(e)};return window.addEventListener(`pointerdown`,t,!0),window.addEventListener(`resize`,s),document.addEventListener(`keydown`,n,!0),()=>{window.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`resize`,s),document.removeEventListener(`keydown`,n,!0)}},[e,s]);let g=e=>f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),_=i(`${t.name} 中的文件`,`Files in ${t.name}`),{maxHeight:v,...y}=m??{visibility:`hidden`,top:0,left:0};return(0,M.createPortal)((0,O.jsx)(d,{ref:c,role:`dialog`,"aria-label":_,tabIndex:-1,className:p.crumbMenu,style:y,onKeyDown:e=>{e.target===c.current&&e.key===`ArrowDown`&&(e.preventDefault(),c.current.querySelector(`[role="treeitem"]:not([aria-disabled="true"])`)?.focus())},children:(0,O.jsx)(`div`,{className:p.crumbMenuScroll,style:{maxHeight:v},children:(0,O.jsx)(z,{root:t.path,label:_,sessionId:n,levels:r,revision:0,compact:!0,expanded:l,selected:a,toggle:g,open:e=>{s(),o(e)}})})}),document.body)}function G({sessionId:e,cwd:t,path:n,levels:r,onOpen:a}){let[o,s]=(0,C.useState)(null),c=`${t}\0${n??``}`,l=o?.target===c?o:null,u=n?.split(`/`)??[],d=u.length?u.at(-1):void 0,f=[{name:t.split(/[\\/]/u).filter(Boolean).at(-1)??t,path:``,title:t},...u.slice(0,-1).map((e,t)=>{let n=u.slice(0,t+1).join(`/`);return{name:e,path:n,title:n}})],m=(0,C.useRef)(()=>s(null)).current;return(0,O.jsxs)(`nav`,{className:p.crumbs,"aria-label":i(`文件路径`,`File path`),children:[(0,O.jsxs)(`ol`,{children:[f.map((e,t)=>(0,O.jsxs)(`li`,{children:[t>0&&(0,O.jsx)(`span`,{className:p.crumbSeparator,"aria-hidden":`true`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,className:p.crumb,title:e.title,"aria-haspopup":`dialog`,"aria-expanded":l?.segment.path===e.path,onClick:t=>{let n=t.currentTarget;s(t=>t?.target===c&&t.segment.path===e.path?null:{segment:e,anchor:n,target:c})},children:e.name})]},e.path)),d&&(0,O.jsxs)(`li`,{className:p.crumbFile,children:[(0,O.jsx)(`span`,{className:p.crumbSeparator,"aria-hidden":`true`,children:`/`}),(0,O.jsx)(`span`,{className:p.crumbCurrent,title:n,"aria-current":`page`,children:d})]})]}),l&&(0,O.jsx)(W,{anchor:l.anchor,segment:l.segment,sessionId:e,levels:r,selected:n,onOpen:a,onDismiss:m},l.segment.path)]})}function K(e){return e.startsWith(`?`)?{mode:`content`,text:e.slice(1).trim()}:{mode:`name`,text:e.trim()}}function q(e,t){let n=e.toLowerCase().indexOf(t.toLowerCase());return!t||n<0?e:(0,O.jsxs)(O.Fragment,{children:[e.slice(0,n),(0,O.jsx)(`mark`,{className:p.match,children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function J(e,t){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let n=[...e.currentTarget.querySelectorAll(`button[data-search-result]`)],r=n.indexOf(document.activeElement),i=e.key===`ArrowDown`?n[r+1]:r<=0?t:n[r-1];i&&(e.preventDefault(),i.focus())}function Y({sessionId:e,query:t,input:n,onOpen:r}){let{mode:a,text:o}=K(t),[s,c]=(0,C.useState)(null),[l,u]=(0,C.useState)(`idle`);if((0,C.useEffect)(()=>{if(!o||a===`content`&&o.length<2){c(null),u(`idle`);return}let t=new AbortController;u(`loading`);let n=window.setTimeout(()=>{D.search(e,o,a,t.signal).then(e=>{t.signal.aborted||(c(e),u(`idle`))}).catch(()=>{t.signal.aborted||u(`error`)})},a===`content`?300:150);return()=>{t.abort(),window.clearTimeout(n)}},[e,a,o]),!o||a===`content`&&o.length<2)return a===`content`?(0,O.jsx)(`p`,{className:p.state,children:i(`输入至少 2 个字符,在文件内容中搜索。`,`Type at least 2 characters to search file contents.`)}):null;if(l===`error`)return(0,O.jsx)(`p`,{className:p.state,role:`status`,children:i(`搜索失败,请重试。`,`Search failed. Try again.`)});if(!s||s.kind!==a)return(0,O.jsx)(`p`,{className:p.state,role:`status`,children:i(`正在搜索…`,`Searching…`)});if(!s.results.length)return(0,O.jsx)(`p`,{className:p.state,role:`status`,children:i(`没有匹配的结果。`,`No matches.`)});let d=s.truncated&&(0,O.jsx)(`p`,{className:p.state,children:i(`结果太多,只显示一部分。请输入更具体的内容。`,`Showing some results only. Type something more specific.`)});if(s.kind===`name`)return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`ul`,{className:p.results,"aria-label":i(`匹配的文件`,`Matching files`),onKeyDown:e=>J(e,n),children:s.results.map(({path:e})=>{let t=e.lastIndexOf(`/`);return(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,"data-search-result":!0,className:p.result,title:e,onClick:()=>r(e),children:[(0,O.jsx)(f,{path:e,size:16}),(0,O.jsx)(`span`,{className:p.name,children:q(e.slice(t+1),o)}),t>0&&(0,O.jsx)(`span`,{className:p.resultDirectory,children:e.slice(0,t)})]})},e)})}),d]});let m=new Map;for(let e of s.results)m.set(e.path,[...m.get(e.path)??[],e]);return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`ul`,{className:p.results,"aria-label":i(`内容匹配`,`Content matches`),onKeyDown:e=>J(e,n),children:[...m].map(([e,t])=>(0,O.jsxs)(`li`,{children:[(0,O.jsxs)(`div`,{className:p.resultFile,title:e,children:[(0,O.jsx)(f,{path:e,size:14}),(0,O.jsx)(`span`,{className:p.name,children:e}),(0,O.jsx)(`span`,{className:p.resultCount,children:t.length})]}),(0,O.jsx)(`ul`,{children:t.map(t=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,"data-search-result":!0,className:p.resultLine,"aria-label":i(`${e} 第 ${t.line} 行:${t.text}`,`${e} line ${t.line}: ${t.text}`),onClick:()=>r(e,t.line),children:[(0,O.jsx)(`span`,{className:p.lineNumber,children:t.line}),(0,O.jsx)(`span`,{className:p.lineText,children:q(t.text,o)})]})},t.line))})]},e))}),d]})}var X=()=>({expanded:new Set,levels:new Map,scrollTop:0,selected:null,treeOpen:!0,query:``,status:P}),re=420;function Z(e,t,n){let[r,i]=(0,C.useState)(null);return(0,C.useEffect)(()=>{i(null)},[t]),(0,C.useEffect)(()=>{n?.(w(e,t,r))},[n,e,t,r]),(0,C.useEffect)(()=>()=>n?.(null),[n]),(0,C.useCallback)(e=>i(t=>t?.from===e?.from&&t?.to===e?.to?t:e),[])}function Q({open:e,controls:t,onToggle:n}){let r=e?i(`隐藏文件目录`,`Hide file tree`):i(`显示文件目录`,`Show file tree`);return(0,O.jsx)(`button`,{type:`button`,className:`${p.iconButton} ${p.treeToggle}`,"aria-label":r,title:r,"aria-expanded":e,"aria-controls":t,onClick:n,children:(0,O.jsx)(_,{})})}var $=(0,C.memo)(function({sessionId:e,cwd:t,idle:n,state:r,renderMarkdown:a,reportContext:o}){let[s,l]=(0,C.useState)(()=>new Set(r.expanded)),[u,d]=(0,C.useState)(()=>r.selected),[f,m]=(0,C.useState)(r.treeOpen),[h,_]=(0,C.useState)(0),[y,b]=(0,C.useState)(!1),[x,S]=(0,C.useState)(r.query),[w,T]=(0,C.useState)(r.status),[E,k]=(0,C.useState)(),[A,ee]=(0,C.useState)(null),te=(0,C.useRef)(null),ne=(0,C.useRef)(!1),M=(0,C.useCallback)(e=>{ne.current=e},[]),N=(0,C.useRef)(null),P=(0,C.useCallback)(()=>{N.current?.abort();let t=new AbortController;N.current=t,D.status(e,t.signal).then(e=>{if(t.signal.aborted)return;let n=F(e);r.status=n,T(n)}).catch(()=>{})},[e,r]);(0,C.useEffect)(()=>(P(),()=>N.current?.abort()),[P]);let I=(0,C.useCallback)(()=>{_(e=>e+1),P()},[P]),L=(0,C.useRef)(n);(0,C.useEffect)(()=>{n&&!L.current&&I(),L.current=n},[n,I]);let R=P,B=e=>{r.query=e,S(e)},V=`files-tree-${e}`,H=u?.cwd===t?u.path:void 0,U=Z(t,H,o),W=(0,C.useCallback)(e=>{e&&(e.scrollTop=r.scrollTop)},[r]);(0,C.useLayoutEffect)(()=>{let e=te.current;if(!e)return;let t=()=>b(e.clientWidth<re);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let K=e=>l(t=>{let n=e(t);return r.expanded=n,n}),q=e=>K(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),J=e=>{r.treeOpen=e,m(e)},X=(e,n)=>{if(e!==H&&ne.current&&!window.confirm(i(`放弃未保存的更改?`,`Discard unsaved changes?`)))return;k(n?{line:n}:void 0);let a={cwd:t,path:e};r.selected=a,d(a);let o=e.split(`/`).slice(0,-1);o.length&&K(e=>{let t=o.map((e,t)=>o.slice(0,t+1).join(`/`));return t.every(t=>e.has(t))?e:new Set([...e,...t])}),y&&J(!1)},$=(0,O.jsx)(G,{sessionId:e,cwd:t,path:H,levels:r.levels,onOpen:X}),ie=!f&&(0,O.jsx)(Q,{open:!1,controls:V,onToggle:()=>J(!0)});return(0,O.jsxs)(`div`,{ref:te,className:p.files,"data-narrow":y||void 0,"data-tree-open":f||void 0,children:[(0,O.jsx)(`div`,{className:p.filesMain,children:H?(0,O.jsx)(j,{sessionId:e,path:H,renderMarkdown:a,breadcrumb:$,trailing:ie,refresh:h,reveal:E,onDirtyChange:M,onSaved:R,onSelection:U},H):(0,O.jsxs)(`div`,{className:p.body,children:[(0,O.jsxs)(`div`,{className:p.toolbar,children:[$,ie]}),(0,O.jsxs)(`div`,{className:p.emptyFile,children:[(0,O.jsx)(c,{size:28,className:p.emptyFileIcon}),(0,O.jsx)(`p`,{className:p.emptyFileTitle,children:i(`打开的文件显示在这里`,`Open files appear here`)}),(0,O.jsx)(`p`,{className:p.emptyFileHint,children:i(`请在目录树中选择一个文件,或在对话中点击文件路径。`,`Choose a file in the tree, or click a file path in the chat.`)})]})]})}),f&&(0,O.jsxs)(`aside`,{id:V,className:p.filesSide,"aria-label":i(`文件目录`,`File tree`),children:[(0,O.jsxs)(`div`,{className:p.toolbar,children:[(0,O.jsxs)(`label`,{className:p.search,title:t,children:[(0,O.jsx)(g,{}),(0,O.jsx)(`input`,{ref:ee,type:`search`,value:x,placeholder:i(`筛选,或输入 ? 在文件中搜索`,`Filter, or type ? to search in files`),"aria-label":i(`筛选文件,或以 ? 开头在文件内容中搜索`,`Filter files, or start with ? to search file contents`),onChange:e=>B(e.target.value),onKeyDown:e=>{if(e.key===`Escape`&&x)e.preventDefault(),e.stopPropagation(),B(``);else if(e.key===`Enter`||e.key===`ArrowDown`){let t=e.currentTarget.closest(`aside`)?.querySelector(`button[data-search-result]`);if(!t)return;e.preventDefault(),e.key===`Enter`?t.click():t.focus()}}})]}),(0,O.jsx)(`button`,{type:`button`,className:p.iconButton,"aria-label":i(`重新读取文件列表`,`Reload files`),title:i(`重新读取文件列表`,`Reload files`),onClick:I,children:(0,O.jsx)(v,{})}),(0,O.jsx)(Q,{open:!0,controls:V,onToggle:()=>J(!1)})]}),x.trim()?(0,O.jsx)(`div`,{className:p.scroll,children:(0,O.jsx)(Y,{sessionId:e,query:x,input:A,onOpen:X},h)}):(0,O.jsx)(`div`,{ref:W,className:p.scroll,onScroll:e=>{r.scrollTop=e.currentTarget.scrollTop},children:(0,O.jsx)(z,{root:``,label:i(`工作区文件`,`Workspace files`),sessionId:e,levels:r.levels,revision:h,expanded:s,selected:H,status:w,toggle:q,open:X})})]})]})});function ie({sessionId:e,cwd:t,path:n,levels:r,renderMarkdown:i,open:a,reportContext:o}){let s=Z(t,n,o),c=(0,C.useRef)(a);(0,C.useLayoutEffect)(()=>{c.current=a});let l=(0,C.useCallback)(e=>c.current(e),[]),u=(0,C.useMemo)(()=>(0,O.jsx)(G,{sessionId:e,cwd:t,path:n,levels:r,onOpen:l}),[e,t,n,r,l]);return(0,O.jsx)(j,{sessionId:e,path:n,renderMarkdown:i,breadcrumb:u,onSelection:s})}var ae=o({id:S.id,apiVersion:1,activate(){},workbench:{apiVersion:1,entry:{label:S.name,panelTitle:{zh:`文件`,en:`Files`},description:{zh:`浏览当前会话的文件并打开预览`,en:`Browse this session’s files and open previews`},kind:`files`,icon:({size:e})=>(0,O.jsx)(f,{kind:`folder`,size:e})},panels:[{kind:`files`,component:e=>(0,O.jsx)($,{sessionId:e.session.sessionId,cwd:e.session.cwd,idle:e.session.idle,state:e.resource(X),renderMarkdown:e.renderMarkdown,reportContext:e.reportContext})},{kind:`file-preview`,title:(e,t)=>(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(f,{path:e,size:16}),(0,O.jsx)(`span`,{children:t})]}),component:e=>(0,O.jsx)(ie,{sessionId:e.session.sessionId,cwd:e.session.cwd,path:e.contentId,renderMarkdown:e.renderMarkdown,levels:e.resource(()=>new Map),open:t=>e.open(`file-preview`,t,t.split(`/`).at(-1)),reportContext:e.reportContext})}]}});export{ae as default};
|
|
6
|
-
//# debugId=4a6ac633-a73b-4972-8f4a-643ef772cd14
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`567b9866-b37b-4ceb-b041-67015b67779e`,e._sentryDebugIdIdentifier=`sentry-dbid-567b9866-b37b-4ceb-b041-67015b67779e`)}catch{}})();import{r as e}from"./rolldown-runtime-CgmABjMJ.js";import{a as t,c as n,g as r,h as i,n as a,o,s}from"./app-CIlV3hYO.js";import{a as c,i as l,n as u,x as d,y as f}from"./icons-D8yiYkWB.js";import{t as p}from"./react-CLFE7TFE.js";import{c as m,i as h,o as g,r as _,t as v}from"./WorkspacePanel.module-V6gI-nG1.js";import{s as y}from"./app.js";import{n as b}from"./clsx-DQAHfk8w.js";var x=e(p(),1);function S(e){let t={stage:[`已暂存文件。`,`File staged.`],unstage:[`已取消暂存,工作区内容保留。`,`File unstaged. Working content preserved.`],commit:[`提交成功。`,`Commit created.`],"create-branch":[`分支已创建。`,`Branch created.`],"switch-branch":[`已切换分支。`,`Branch switched.`],state_changed:[`仓库状态已变化,已刷新;请检查后重新操作。`,`Repository changed. Review the refreshed state before trying again.`],busy:[`Git 操作正在进行,请稍后刷新。`,`A Git operation is in progress. Refresh shortly.`],agent_busy:[`共用此工作树的聊天正在运行,请等待回复结束。`,`A chat sharing this working tree is running. Wait for it to finish.`],session_changed:[`聊天已切换,请返回原聊天检查仓库状态。`,`Chat switched. Return to the original chat to check the repository.`],root_required:[`提交和切换分支请在仓库根目录工作区操作。`,`Open the repository root workspace to commit or switch branches.`],operation_in_progress:[`请先在终端完成冲突处理或正在进行的 Git 操作。`,`Finish conflict resolution or the ongoing Git operation in the terminal first.`],index_locked:[`Git 锁被占用,请等待其他 Git 操作完成。`,`Git is locked. Wait for other Git operations to finish.`],too_many_changes:[`仓库改动或分支过多,请在终端操作。`,`Too many changes or branches. Use the terminal for this operation.`],dirty_worktree:[`切换分支前请先提交或处理全部改动,包括未跟踪文件。`,`Commit or resolve all changes, including untracked files, before switching branches.`],nothing_staged:[`请先暂存要提交的文件。`,`Stage files before committing.`],identity_missing:[`请先在终端配置 Git user.name 和 user.email。`,`Configure Git user.name and user.email in the terminal first.`],invalid_branch:[`分支名称无效,请检查后重试。`,`Invalid branch name. Check the name and try again.`],branch_exists:[`同名分支已存在。`,`A branch with this name already exists.`],branch_in_use:[`该分支正在其他工作树中使用。`,`This branch is checked out in another worktree.`],no_commits:[`创建分支前请先完成首次提交。`,`Create an initial commit before creating a branch.`],invalid_path:[`该文件不支持此操作,请刷新检查。`,`This file cannot be changed here. Refresh and check it.`],invalid_message:[`请填写提交说明(最多 8 KB)。`,`Enter a commit message (up to 8 KB).`],git_failed:[`Git 操作失败。请检查仓库、身份、签名或 hooks 配置,再刷新确认。`,`Git operation failed. Check repository, identity, signing or hooks configuration, then refresh.`],outcome_unknown:[`未能确认操作结果。请刷新检查暂存区、历史和分支,确认前不要重复提交。`,`Operation outcome is unknown. Refresh and check staging, history and branches before repeating it.`]},n=t[e]??t.git_failed;return i(...n)}async function C(e,n,r,i){return o(await t(`/api/workspace/git/${e}`,{method:`POST`,headers:{Authorization:`Bearer ${y()}`,"Content-Type":`application/json`},body:JSON.stringify({sessionId:n,...r}),signal:i}))}var w={control:(e,t)=>C(`control`,e,{},t),write:(e,t)=>C(`write`,e,t),status:(e,t)=>C(`status`,e,{},t),diff:(e,t,n,r)=>C(`diff`,e,{path:t,area:n},r),history:(e,t,n)=>C(`history`,e,{cursor:t},n),commit:(e,t,n,r)=>C(`commit-detail`,e,{hash:t,parentIndex:n},r),commitDiff:(e,t,n,r,i)=>C(`commit-diff`,e,{hash:t,path:n,parentIndex:r},i)};function T(e,t,n,r=!0){let[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!0),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(0),f=(0,x.useCallback)(()=>{s(!0),d(e=>e+1)},[]);return(0,x.useEffect)(()=>{if(!t)return;let n=!1,i=!1,o=!1,c=new AbortController,u=async()=>{if(!(n||document.visibilityState===`hidden`)){if(i)o=!0;else{i=!0,s(!0);try{let t=await e(c.signal);n||(a(e=>JSON.stringify(e)===JSON.stringify(t)?e:t),l(!1))}catch{n||l(!0)}finally{i=!1,n||(s(!1),o&&(o=!1,u()))}}}};u();let d=r?window.setInterval(()=>{u()},5e3):void 0,f=()=>{u()};return window.addEventListener(`focus`,f),window.addEventListener(`pi-workspace-git-changed`,f),document.addEventListener(`visibilitychange`,f),()=>{n=!0,c.abort(),window.clearInterval(d),window.removeEventListener(`pi-workspace-git-changed`,f),window.removeEventListener(`focus`,f),document.removeEventListener(`visibilitychange`,f)}},[e,t,n,u,r]),{value:i,loading:o,error:c,refresh:f}}var E={panel:`_panel_1ndkv_2`,viewSwitch:`_viewSwitch_1ndkv_3`,viewButton:`_viewButton_1ndkv_4`,repoBar:`_repoBar_1ndkv_5`,branchPicker:`_branchPicker_1ndkv_6`,branchTrigger:`_branchTrigger_1ndkv_7`,repoName:`_repoName_1ndkv_11`,divergence:`_divergence_1ndkv_12`,count:`_count_1ndkv_13`,scope:`_scope_1ndkv_14`,changesScroll:`_changesScroll_1ndkv_15`,groupHeading:`_groupHeading_1ndkv_16`,list:`_list_1ndkv_18`,changeRow:`_changeRow_1ndkv_19`,change:`_change_1ndkv_15`,diffScroll:`_diffScroll_1ndkv_23`,filename:`_filename_1ndkv_25`,status:`_status_1ndkv_27`,added:`_added_1ndkv_28`,removed:`_removed_1ndkv_29`,fileAction:`_fileAction_1ndkv_30`,commitFooter:`_commitFooter_1ndkv_32`,commitForm:`_commitForm_1ndkv_33`,rootHint:`_rootHint_1ndkv_36`,actionRow:`_actionRow_1ndkv_37`,hint:`_hint_1ndkv_38`,feedback:`_feedback_1ndkv_38`,feedbackRow:`_feedbackRow_1ndkv_41`,actionButton:`_actionButton_1ndkv_44`,branchPopover:`_branchPopover_1ndkv_46`,pickerHeader:`_pickerHeader_1ndkv_47`,branchSearch:`_branchSearch_1ndkv_49`,field:`_field_1ndkv_49`,branchList:`_branchList_1ndkv_50`,branchOption:`_branchOption_1ndkv_52`,newBranch:`_newBranch_1ndkv_56`,form:`_form_1ndkv_58`,checkbox:`_checkbox_1ndkv_60`,diffSummary:`_diffSummary_1ndkv_64`,stats:`_stats_1ndkv_65`,diff:`_diff_1ndkv_23`,diffLine:`_diffLine_1ndkv_68`,lineNumber:`_lineNumber_1ndkv_69`,lineText:`_lineText_1ndkv_70`,diffHunk:`_diffHunk_1ndkv_74`,diffNotice:`_diffNotice_1ndkv_75`,noNewline:`_noNewline_1ndkv_76`,reviewLayout:`_reviewLayout_1ndkv_79`,inlinePreview:`_inlinePreview_1ndkv_81`,inlineDiffToolbar:`_inlineDiffToolbar_1ndkv_83`,diffIdentity:`_diffIdentity_1ndkv_84`,diffDetails:`_diffDetails_1ndkv_85`,diffArea:`_diffArea_1ndkv_86`,diffNavigation:`_diffNavigation_1ndkv_88`,diffPosition:`_diffPosition_1ndkv_89`,diffViewport:`_diffViewport_1ndkv_91`},D=b();function O({children:e,preview:t,selectionKey:n,onClose:r}){let a=(0,x.useRef)(null),o=!!t;return(0,x.useEffect)(()=>{o&&n&&a.current?.querySelector(`[data-git-file][aria-pressed="true"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[n,o]),(0,D.jsxs)(`div`,{className:E.reviewLayout,"data-preview":o,ref:a,children:[e,t&&(0,D.jsx)(`div`,{className:E.inlinePreview,role:`region`,"aria-label":i(`差异预览`,`Diff preview`),onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&!e.defaultPrevented&&(e.preventDefault(),r())},children:t})]})}function k(e){return e===`staged`?i(`已暂存`,`Staged`):e===`unstaged`?i(`未暂存`,`Unstaged`):i(`未跟踪`,`Untracked`)}function A(e){let t=0,n=0,r=!1,i=e.split(`
|
|
2
|
-
`);return i.at(-1)===``&&i.pop(),i.map(e=>{let i=e.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(e.startsWith(`diff --git `)&&(r=!1),i&&(t=Number(i[1]),n=Number(i[2]),r=!0),r&&!i){if(e.startsWith(`+`))return{kind:`add`,text:e,oldLine:null,newLine:n++};if(e.startsWith(`-`))return{kind:`remove`,text:e,oldLine:t++,newLine:null};if(e.startsWith(` `))return{kind:`context`,text:e,oldLine:t++,newLine:n++}}return{kind:`meta`,text:e,oldLine:null,newLine:null}})}function j(e){let t=[],n=[],r=[],i=null,a=``,o=``,s=``;for(let c of A(e)){if(c.kind!==`meta`){c.kind===`context`?i=null:i===null&&(i=n.length,n.push(t.length)),t.push({...c,kind:c.kind,change:i});continue}let e=c.text.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@\s?(.*)$/);if(e)i=null,t.push({kind:`hunk`,oldLine:Number(e[1]),newLine:Number(e[2]),text:e[3],change:null});else if(c.text===`\`){let e=t.at(-1);e&&e.kind!==`hunk`&&(e.noNewline=!0)}else c.text.startsWith(`diff --git `)?(i=null,a=o=s=``):c.text.startsWith(`old mode `)?a=c.text.slice(9):c.text.startsWith(`new mode `)?r.push({kind:`mode`,from:a,to:c.text.slice(9)}):c.text.startsWith(`rename from `)?o=c.text.slice(12):c.text.startsWith(`rename to `)?r.push({kind:`rename`,from:o,to:c.text.slice(10)}):c.text.startsWith(`copy from `)?s=c.text.slice(10):c.text.startsWith(`copy to `)?r.push({kind:`copy`,from:s,to:c.text.slice(8)}):c.text.startsWith(`new file mode `)?r.push({kind:`added`,from:``,to:c.text.slice(14)}):c.text.startsWith(`deleted file mode `)&&r.push({kind:`deleted`,from:c.text.slice(18),to:``})}return{lines:t,changes:n,notices:r.filter(e=>!n.length||e.kind!==`added`&&e.kind!==`deleted`)}}function M({path:e,label:t,value:n,loading:r,error:a,refresh:o,onClose:s}){let u=n?.kind===`text`?n.patch:``,f=(0,x.useMemo)(()=>j(u),[u,e]),{lines:p,changes:m,notices:h}=f,g=(0,x.useRef)(null),[_,y]=(0,x.useState)(null),b=_?.preview===f?_.index:-1;(0,x.useEffect)(()=>{g.current?.scrollTo({top:0,left:0})},[f]);let S=e=>{if(r||a||e<0||e>=m.length)return;let t=g.current,n=t?.querySelector(`[data-change="${e}"][data-change-start="true"]`);t&&n&&(t.scrollTo({top:t.scrollTop+n.getBoundingClientRect().top-t.getBoundingClientRect().top,left:t.scrollLeft}),y({preview:f,index:e}))},C=p.filter(e=>e.kind===`add`).length,w=p.filter(e=>e.kind===`remove`).length,T=n?.kind===`text`&&(0,D.jsxs)(`span`,{className:E.stats,children:[(0,D.jsxs)(`span`,{className:E.added,children:[`+`,C]}),(0,D.jsxs)(`span`,{className:E.removed,children:[`−`,w]})]}),O={empty:i(`此文件在所选范围内没有文本差异,或已不在改动列表中。`,`No text differences in this scope, or this file is no longer changed.`),binary:i(`二进制文件不支持文本差异预览。`,`Text diff is unavailable for binary files.`),"too-large":i(`差异过大,最多显示 512 KB / 10000 行。`,`Diff exceeds the preview limit of 512 KB / 10000 lines.`),unsupported:i(`此文件类型不支持差异预览。`,`Diff is unavailable for this file type.`),conflict:i(`此文件存在未解决的合并冲突,请在工作区文件或终端中检查。`,`This file has unresolved merge conflicts. Inspect it in workspace files or the terminal.`),submodule:i(`子模块已发生变化,请在子模块工作区中查看具体差异。`,`Submodule changed. Open its workspace to inspect the changes.`)};return(0,D.jsxs)(`div`,{className:v.body,children:[(0,D.jsxs)(`div`,{className:s?E.inlineDiffToolbar:v.toolbar,children:[s?(0,D.jsxs)(`div`,{className:E.diffIdentity,children:[(0,D.jsx)(`span`,{className:v.path,title:e,children:e}),(0,D.jsxs)(`div`,{className:E.diffDetails,children:[(0,D.jsx)(`span`,{className:E.diffArea,title:t,children:t}),T]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:v.path,title:e,children:e}),(0,D.jsx)(`span`,{className:v.readonly,children:i(`只读`,`Read only`)})]}),(0,D.jsxs)(`div`,{className:E.diffNavigation,role:`group`,"aria-label":i(`改动跳转`,`Change navigation`),children:[(0,D.jsx)(`button`,{type:`button`,className:v.iconButton,"aria-label":i(`上一处改动`,`Previous change`),title:i(`上一处改动`,`Previous change`),disabled:r||a||b<=0,onClick:()=>S(b-1),children:(0,D.jsx)(c,{})}),(0,D.jsxs)(`span`,{className:E.diffPosition,role:`status`,"aria-label":i(`改动位置`,`Change position`),"aria-live":`polite`,"aria-atomic":`true`,title:i(`第 ${b+1} / ${m.length} 处改动`,`Change ${b+1} of ${m.length}`),children:[b+1,`/`,m.length]}),(0,D.jsx)(`button`,{type:`button`,className:v.iconButton,"aria-label":i(`下一处改动`,`Next change`),title:i(`下一处改动`,`Next change`),disabled:r||a||b+1>=m.length,onClick:()=>S(b+1),children:(0,D.jsx)(l,{})})]}),(0,D.jsx)(`button`,{type:`button`,className:v.iconButton,"aria-label":i(`刷新差异`,`Refresh diff`),title:i(`刷新差异`,`Refresh diff`),onClick:o,children:(0,D.jsx)(d,{})}),s&&(0,D.jsx)(`button`,{type:`button`,className:v.iconButton,"aria-label":i(`关闭差异预览`,`Close diff preview`),title:i(`关闭差异预览 · Esc`,`Close diff preview · Esc`),onClick:s,children:`×`})]}),!s&&(0,D.jsxs)(`div`,{className:E.diffSummary,children:[(0,D.jsx)(`span`,{children:t}),T]}),a&&(0,D.jsxs)(`div`,{className:v.state,role:`status`,children:[i(`差异读取失败,请重试。`,`Could not read this diff. Try again.`),` `,(0,D.jsx)(`button`,{type:`button`,className:v.textButton,onClick:o,children:i(`重试`,`Retry`)})]}),(0,D.jsxs)(`div`,{className:`${v.preview} ${E.diffViewport}`,"aria-busy":r,children:[!n&&!a&&(0,D.jsx)(`p`,{className:v.state,role:`status`,children:i(`正在读取差异…`,`Reading diff…`)}),n&&n.kind!==`text`&&(0,D.jsx)(`p`,{className:v.state,role:`status`,children:O[n.kind]}),n?.kind===`text`&&(0,D.jsxs)(`div`,{ref:g,className:E.diffScroll,tabIndex:0,role:`region`,"aria-label":i(`文件差异`,`File diff`),children:[h.map((e,t)=>(0,D.jsx)(`p`,{className:E.diffNotice,children:N(e)},t)),!p.length&&!h.length&&(0,D.jsx)(`p`,{className:v.state,children:O.empty}),(0,D.jsx)(`pre`,{className:E.diff,children:(0,D.jsx)(`code`,{children:p.map((e,t)=>e.kind===`hunk`?(0,D.jsxs)(`span`,{className:E.diffHunk,"data-kind":`hunk`,children:[(0,D.jsx)(`span`,{"aria-hidden":`true`,children:`···`}),(0,D.jsxs)(`span`,{children:[i(`行 ${e.oldLine} / ${e.newLine}`,`Lines ${e.oldLine} / ${e.newLine}`),e.text&&` · ${e.text}`]})]},t):(0,D.jsxs)(`span`,{className:E.diffLine,"data-kind":e.kind,"data-change":e.change??void 0,"data-change-start":e.change!==null&&m[e.change]===t?`true`:void 0,"data-active":e.change!==null&&b===e.change?`true`:void 0,children:[(0,D.jsx)(`span`,{className:E.lineNumber,"aria-hidden":`true`,children:e.oldLine}),(0,D.jsx)(`span`,{className:E.lineNumber,"aria-hidden":`true`,children:e.newLine}),(0,D.jsxs)(`span`,{className:E.lineText,children:[e.text||` `,e.noNewline&&(0,D.jsx)(`span`,{className:E.noNewline,title:i(`文件末尾无换行`,`No newline at end of file`),"aria-label":i(`文件末尾无换行`,`No newline at end of file`),children:`↵`})]})]},t))})})]})]})]})}function N(e){switch(e.kind){case`mode`:return i(`文件权限:${e.from} → ${e.to}`,`File mode: ${e.from} → ${e.to}`);case`rename`:return i(`重命名:${e.from} → ${e.to}`,`Renamed: ${e.from} → ${e.to}`);case`copy`:return i(`复制:${e.from} → ${e.to}`,`Copied: ${e.from} → ${e.to}`);case`added`:return i(`新增空文件`,`Empty file added`);case`deleted`:return i(`删除空文件`,`Empty file deleted`)}}var P=(0,x.memo)(function({sessionId:e,path:t,area:n,visible:i,idle:a,onClose:o}){r();let s=T((0,x.useCallback)(r=>w.diff(e,t,n,r),[e,t,n]),i,a);return(0,D.jsx)(M,{path:t,label:k(n),onClose:o,...s})});function F(e,t){if(!e)return null;let n=t.find(t=>t.path===e.path);if(!n)return null;let r=n.conflict?[`unstaged`]:n.untracked?[`untracked`]:[...n.worktree===`.`?[]:[`unstaged`],...n.index===`.`?[]:[`staged`]];return r.includes(e.area)?e:r[0]?{path:e.path,area:r[0]}:null}function I({branch:e,control:t,disabled:n,model:r,open:a,onOpenChange:o,onDraftChange:s,onWrite:c}){let d=(0,x.useRef)(null),p=(0,x.useRef)(null),h=(0,x.useRef)(null),[g,y]=(0,x.useState)(!1),[b,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(``);_(p,a,()=>o(!1)),(0,x.useEffect)(()=>{if(!a){y(!1),T(``),C(!1);return}let e=e=>{e.target instanceof Node&&!d.current?.contains(e.target)&&o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a,o]),(0,x.useEffect)(()=>{g&&h.current?.focus()},[g]);let O=t?.scope?`root_required`:t?.dirty?`dirty_worktree`:null,k=t?.branches.filter(e=>e.name.toLocaleLowerCase().includes(w.toLocaleLowerCase()))??[],A=async(e,t)=>{C(!0),await c(e,t)&&o(!1)};return(0,D.jsxs)(`div`,{ref:d,className:E.branchPicker,children:[(0,D.jsxs)(`button`,{type:`button`,className:E.branchTrigger,disabled:!t,"aria-label":i(`管理分支`,`Manage branches`),"aria-haspopup":`dialog`,"aria-expanded":a,title:e??i(`分离 HEAD`,`Detached HEAD`),onClick:()=>o(!a),children:[(0,D.jsx)(u,{}),(0,D.jsx)(`span`,{children:e??i(`分离 HEAD`,`Detached HEAD`)}),(0,D.jsx)(l,{})]}),a&&(0,D.jsxs)(m,{ref:p,className:E.branchPopover,compact:!0,role:`dialog`,"aria-modal":`true`,"aria-label":i(`管理分支`,`Manage branches`),children:[(0,D.jsxs)(`div`,{className:E.pickerHeader,children:[(0,D.jsx)(`span`,{children:g?i(`新建分支`,`New branch`):i(`本地分支`,`Local branches`)}),(0,D.jsx)(`button`,{type:`button`,className:v.iconButton,"aria-label":i(`关闭分支面板`,`Close branches`),onClick:()=>o(!1),children:`×`})]}),g?(0,D.jsxs)(`form`,{className:E.form,"aria-label":i(`创建分支`,`Create branch`),onSubmit:e=>{e.preventDefault(),!n&&r.branch.trim()&&t?.head&&!(r.checkout&&O)&&A(`create-branch`,{branch:r.branch,checkout:r.checkout})},children:[(0,D.jsxs)(`label`,{className:E.field,children:[i(`分支名称`,`Branch name`),(0,D.jsx)(`input`,{ref:h,"aria-label":i(`新分支名称`,`New branch name`),maxLength:256,value:r.branch,disabled:r.pending,placeholder:`feature/name`,onChange:e=>{r.branch=e.target.value,s()}})]}),(0,D.jsxs)(`label`,{className:E.checkbox,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:r.checkout,disabled:r.pending,onChange:e=>{r.checkout=e.target.checked,s()}}),i(`创建后切换`,`Switch after creating`)]}),r.checkout&&O&&(0,D.jsx)(`p`,{className:E.hint,children:S(O)}),(0,D.jsxs)(`div`,{className:E.actionRow,children:[(0,D.jsx)(`button`,{type:`button`,className:v.textButton,onClick:()=>y(!1),children:i(`返回`,`Back`)}),(0,D.jsx)(`button`,{className:E.actionButton,type:`submit`,disabled:n||!r.branch.trim()||!t?.head||r.checkout&&!!O,children:i(`创建分支`,`Create branch`)})]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`input`,{className:E.branchSearch,type:`search`,"data-modal-autofocus":!0,"aria-label":i(`搜索分支`,`Search branches`),value:w,placeholder:i(`搜索分支…`,`Search branches…`),onChange:e=>T(e.target.value)}),(0,D.jsxs)(`div`,{className:E.branchList,role:`group`,"aria-label":i(`本地分支`,`Local branches`),children:[k.map(e=>(0,D.jsxs)(`button`,{type:`button`,className:E.branchOption,title:e.name,disabled:n||!!O||e.current||e.occupied||!t?.head,"aria-label":i(`切换到分支:${e.name}`,`Switch to branch: ${e.name}`),onClick:()=>{A(`switch-branch`,{branch:e.name})},children:[(0,D.jsx)(u,{}),(0,D.jsx)(`span`,{children:e.name}),(e.current||e.occupied)&&(0,D.jsx)(`small`,{children:e.current?i(`当前`,`Current`):i(`其他工作树`,`Other worktree`)})]},e.name)),k.length===0&&(0,D.jsx)(`p`,{className:E.hint,children:i(`没有匹配的分支。`,`No matching branches.`)})]}),O&&(0,D.jsx)(`p`,{className:E.hint,children:S(O)}),(0,D.jsxs)(`button`,{type:`button`,className:E.newBranch,disabled:r.pending||!t?.head,"aria-label":i(`新建分支`,`New branch`),onClick:()=>y(!0),children:[(0,D.jsx)(f,{}),i(`新建分支…`,`New branch…`)]})]}),!t?.head&&(0,D.jsx)(`p`,{className:E.hint,children:S(`no_commits`)}),r.pending&&(0,D.jsx)(`p`,{className:E.hint,role:`status`,children:i(`正在执行…`,`Running…`)}),t?.blocked&&(0,D.jsx)(`p`,{className:E.hint,children:S(t.blocked)}),b&&r.outcome&&!r.outcome.ok&&(0,D.jsx)(`p`,{className:E.feedback,"data-error":`true`,role:`status`,children:S(r.outcome.reason)})]})]})}function L(e){let t=[],n=0,r=1,i=[];for(let a of e){let e=t.findIndex(e=>e.hash===a.hash),o=e<0?t.length:e,s=e<0?n++%4:t[o].color,c=[...t];e>=0&&t.splice(e,1);let l=Math.min(o,t.length),u=[...new Set(a.parents)];for(let[e,r]of u.entries())t.some(e=>e.hash===r)||t.splice(l++,0,{hash:r,color:e===0?s:n++%4});i.push({lane:o,color:s,incoming:e>=0,rails:c.flatMap((e,n)=>e.hash===a.hash?[]:[{from:n,to:t.findIndex(t=>t.hash===e.hash),color:e.color}]),parents:u.map(e=>{let n=t.findIndex(t=>t.hash===e);return{hash:e,from:o,to:n,color:t[n].color}})}),r=Math.max(r,o+1,c.length,t.length)}return{rows:i,width:r*16+16}}var R={history:`_history_1fyyf_1`,historyToolbar:`_historyToolbar_1fyyf_2`,graphScroll:`_graphScroll_1fyyf_3`,historyList:`_historyList_1fyyf_4`,commitRow:`_commitRow_1fyyf_5`,loadMore:`_loadMore_1fyyf_7`,parentLink:`_parentLink_1fyyf_7`,graph:`_graph_1fyyf_3`,commitCopy:`_commitCopy_1fyyf_15`,subject:`_subject_1fyyf_16`,refLine:`_refLine_1fyyf_17`,ref:`_ref_1fyyf_17`,merge:`_merge_1fyyf_20`,commitMeta:`_commitMeta_1fyyf_21`,detail:`_detail_1fyyf_27`,message:`_message_1fyyf_33`,parentList:`_parentList_1fyyf_35`,parentSelect:`_parentSelect_1fyyf_36`,fileStats:`_fileStats_1fyyf_38`},z=(0,x.memo)(function({sessionId:e,visible:t,idle:n,model:a,onCommit:o}){let s=r(),{value:c,loading:l,error:u,refresh:d}=T((0,x.useCallback)(t=>w.history(e,void 0,t),[e]),t,n),[f,p]=(0,x.useState)(a.history),[m,h]=(0,x.useState)(a.selected),[g,_]=(0,x.useState)(!1),[y,b]=(0,x.useState)(!1),S=()=>{b(!1),d()},C=(0,x.useRef)(null);(0,x.useEffect)(()=>{c&&(a.history?.snapshot===c.snapshot&&a.history.commits.length||(C.current?.abort(),_(!1),b(!1),a.history=c,p(c)))},[c,a]),(0,x.useEffect)(()=>(t||(C.current?.abort(),_(!1)),()=>C.current?.abort()),[t]);let E=async()=>{let t=a.history;if(!t?.nextCursor||g)return;let n=new AbortController;C.current=n,_(!0),b(!1);try{let r=await w.history(e,t.nextCursor,n.signal);if(n.signal.aborted||a.history?.snapshot!==r.snapshot||a.history.nextCursor!==t.nextCursor)return;let i=new Set(t.commits.map(e=>e.hash)),o={...r,commits:[...t.commits,...r.commits.filter(e=>!i.has(e.hash))]};a.history=o,p(o)}catch{n.signal.aborted||b(!0)}finally{n.signal.aborted||_(!1)}},O=(0,x.useMemo)(()=>L(f?.commits??[]),[f?.commits]),k=e=>e*16+12,A=e=>{a.selected=e,h(e),o(e)},j={"--git-graph-width":`${O.width}px`};return(0,D.jsxs)(`div`,{className:R.history,"aria-busy":l||g,children:[(0,D.jsxs)(`div`,{className:R.historyToolbar,children:[(0,D.jsx)(`span`,{children:i(`提交历史与分支图`,`Commit history & graph`)}),(0,D.jsx)(`button`,{className:v.textButton,type:`button`,onClick:S,"aria-label":i(`刷新提交历史`,`Refresh history`),children:i(`刷新`,`Refresh`)})]}),f?.scope&&(0,D.jsxs)(`p`,{className:v.state,children:[i(`展示仓库提交关系;文件差异仅限当前目录:`,`Repository history; file diffs are limited to: `),f.scope]}),(u||y)&&(0,D.jsxs)(`p`,{className:v.state,role:`status`,children:[i(`历史读取失败或分支已变化,请刷新历史。`,`Could not read history, or refs changed. Refresh history.`),` `,(0,D.jsx)(`button`,{className:v.textButton,type:`button`,onClick:S,children:i(`重试`,`Retry`)})]}),!f&&!u&&(0,D.jsx)(`p`,{className:v.state,role:`status`,children:i(`正在读取历史…`,`Reading history…`)}),f?.kind===`not-repository`&&(0,D.jsx)(`p`,{className:v.state,children:i(`当前工作区不在 Git 仓库中。`,`This workspace is not in a Git repository.`)}),f?.kind===`unavailable`&&(0,D.jsx)(`p`,{className:v.state,children:i(`Git 不可用。`,`Git is unavailable.`)}),f?.kind===`repository`&&f.commits.length===0&&(0,D.jsx)(`p`,{className:v.state,role:`status`,children:i(`仓库尚无提交。`,`This repository has no commits yet.`)}),(0,D.jsx)(`div`,{className:R.graphScroll,children:(0,D.jsx)(`ol`,{className:R.historyList,style:j,"aria-label":i(`提交历史`,`Commit history`),children:f?.commits.map((e,t)=>{let n=O.rows[t],r=f.refs.filter(t=>t.hash===e.hash),a=new Date(e.authoredAt),o=Number.isNaN(a.getTime())?e.authoredAt:a.toLocaleDateString(s===`zh`?`zh-CN`:`en-US`);return(0,D.jsx)(`li`,{children:(0,D.jsxs)(`button`,{type:`button`,className:R.commitRow,"data-commit":e.hash,"aria-current":m===e.hash?`true`:void 0,"aria-label":i(`查看提交 ${e.hash.slice(0,7)}:${e.subject}`,`View commit ${e.hash.slice(0,7)}: ${e.subject}`),onClick:()=>A(e.hash),children:[(0,D.jsxs)(`svg`,{width:O.width,height:84,className:R.graph,"aria-hidden":`true`,"data-git-graph-row":e.hash,children:[n.rails.map((e,t)=>(0,D.jsx)(`path`,{"data-color":e.color,d:`M${k(e.from)} 0 L${k(e.from)} 42 C${k(e.from)} 64 ${k(e.to)} 64 ${k(e.to)} 84`},`r${t}`)),n.incoming&&(0,D.jsx)(`path`,{"data-color":n.color,d:`M${k(n.lane)} 0 V42`}),n.parents.map(e=>(0,D.jsx)(`path`,{"data-parent":e.hash,"data-color":e.color,d:`M${k(n.lane)} 42 C${k(n.lane)} 64 ${k(e.to)} 64 ${k(e.to)} 84`},e.hash)),(0,D.jsx)(`circle`,{"data-color":n.color,cx:k(n.lane),cy:42,r:4})]}),(0,D.jsxs)(`span`,{className:R.commitCopy,children:[(0,D.jsx)(`span`,{className:R.subject,children:e.subject||i(`(无提交说明)`,`(No subject)`)}),(0,D.jsxs)(`span`,{className:R.refLine,title:r.map(e=>`${e.kind}: ${e.name}`).join(` · `),children:[f.head===e.hash&&(0,D.jsx)(`span`,{className:R.ref,"data-kind":`head`,children:`HEAD`}),r.map(e=>(0,D.jsxs)(`span`,{className:R.ref,"data-kind":e.kind,children:[e.kind===`tag`?`${i(`标签`,`tag`)}: `:e.kind===`remote`?`${i(`远端`,`remote`)}: `:``,e.name]},`${e.kind}/${e.name}`)),e.parents.length>1&&(0,D.jsx)(`span`,{className:R.merge,children:i(`合并`,`Merge`)})]}),(0,D.jsxs)(`span`,{className:R.commitMeta,children:[(0,D.jsx)(`code`,{children:e.hash.slice(0,7)}),(0,D.jsx)(`span`,{children:e.author}),(0,D.jsx)(`time`,{dateTime:e.authoredAt,title:e.authoredAt,children:o})]})]})]})},e.hash)})})}),f?.nextCursor&&(0,D.jsx)(`button`,{type:`button`,className:R.loadMore,disabled:g||l||f.snapshot!==c?.snapshot,onClick:()=>{E()},children:g?i(`正在加载…`,`Loading…`):i(`加载更多提交`,`Load more commits`)})]})});function B(e){return{A:i(`新增`,`Added`),M:i(`修改`,`Modified`),D:i(`删除`,`Deleted`),R:i(`重命名`,`Renamed`),C:i(`复制`,`Copied`),T:i(`类型变化`,`Type changed`),U:i(`冲突`,`Conflict`),"?":i(`未跟踪`,`Untracked`)}[e]??e}var V=(0,x.memo)(function({sessionId:e,visible:t,idle:a,model:o,onCommit:s}){r();let c=(0,x.useRef)(null),[l,u]=(0,x.useState)(o.selection),f=(0,x.useCallback)(e=>{o.selection=e,u(e)},[o]),p=(0,x.useCallback)(()=>{let e=c.current?.querySelector(`[data-git-file][aria-pressed="true"]`);f(null),requestAnimationFrame(()=>e?.focus({preventScroll:!0}))},[f]),[m,_]=(0,x.useState)(o.view),y=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!t)return;let e=h(document);return y.current=e,()=>{e.dispose(),y.current=null}},[t]);let{value:b,loading:C,error:A}=T((0,x.useCallback)(t=>w.status(e,t),[e]),t&&m===`changes`,a),{value:j,loading:M,error:N}=T((0,x.useCallback)(t=>w.control(e,t),[e]),t&&m===`changes`,a),[L,R]=(0,x.useState)(!1);(0,x.useEffect)(()=>{t&&m===`changes`||R(!1)},[t,m]);let[,V]=(0,x.useReducer)(e=>e+1,0);(0,x.useEffect)(()=>{let e=()=>V();return window.addEventListener(`pi-workspace-git-changed`,e),()=>window.removeEventListener(`pi-workspace-git-changed`,e)},[]);let H=()=>window.dispatchEvent(new Event(`pi-workspace-git-changed`)),U=a?j?.blocked:`agent_busy`,W=o.pending||!j?.version||M||N||A||!!U,G=async(t,r={})=>{if(W||o.pending||!j)return!1;o.pending=!0,o.outcome=null,V();try{return await w.write(e,{action:t,expected:j.version,...r}),o.outcome={ok:!0,reason:t},t===`commit`&&o.message===r.message&&(o.message=``),t===`create-branch`&&o.branch===r.branch&&(o.branch=``),!0}catch(e){return o.outcome={ok:!1,reason:e instanceof n?e.reason??(e.status<500?`git_failed`:`outcome_unknown`):`outcome_unknown`},!1}finally{o.pending=!1,window.dispatchEvent(new Event(`pi-workspace-git-changed`))}},K=b?.kind===`repository`?b:null;(0,x.useEffect)(()=>{if(!t||m!==`changes`||C||A||!b)return;let e=F(o.selection,b.kind===`repository`?b.entries:[]);e!==o.selection&&(o.selection=e,u(e))},[b,C,A,t,m,o]);let q=K?[{title:i(`冲突`,`Conflicts`),area:`unstaged`,changes:K.entries.filter(e=>e.conflict),conflict:!0},{title:k(`staged`),area:`staged`,changes:K.entries.filter(e=>!e.conflict&&!e.untracked&&e.index!==`.`)},{title:k(`unstaged`),area:`unstaged`,changes:K.entries.filter(e=>!e.conflict&&!e.untracked&&e.worktree!==`.`)},{title:k(`untracked`),area:`untracked`,changes:K.entries.filter(e=>e.untracked)}]:[],J=!W&&!K?.scope&&!!j?.staged&&!!o.message.trim(),Y=K?.root.split(/[\\/]/).at(-1)??``,X=K?[K.root,K.head,K.upstream??i(`未设置上游分支`,`No upstream branch`)].filter(Boolean).join(`
|
|
3
|
-
`):``;return(0,D.jsxs)(`div`,{ref:c,className:`${v.body} ${E.panel}`,children:[(0,D.jsxs)(`div`,{className:v.toolbar,children:[(0,D.jsx)(`div`,{className:E.viewSwitch,role:`group`,"aria-label":i(`Git 视图`,`Git view`),children:[`changes`,`history`].map(e=>(0,D.jsx)(`button`,{type:`button`,className:`${v.textButton} ${E.viewButton}`,"aria-pressed":m===e,onClick:()=>{o.view=e,_(e)},children:e===`changes`?i(`改动`,`Changes`):i(`历史`,`History`)},e))}),m===`history`&&(0,D.jsx)(`span`,{className:v.readonly,children:i(`只读`,`Read only`)}),m===`changes`&&(0,D.jsx)(`button`,{type:`button`,className:v.iconButton,"aria-label":i(`刷新 Git 状态`,`Refresh Git status`),title:i(`刷新 Git 状态`,`Refresh Git status`),onClick:H,children:(0,D.jsx)(d,{})})]}),m===`history`?(0,D.jsx)(`div`,{className:v.scroll,children:(0,D.jsx)(z,{sessionId:e,visible:t,idle:a,model:o,onCommit:s})}):(0,D.jsxs)(D.Fragment,{children:[K&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:E.repoBar,children:[(0,D.jsx)(I,{branch:K.branch,control:j,disabled:W,model:o,open:L,onOpenChange:R,onDraftChange:V,onWrite:G}),(0,D.jsx)(`span`,{className:E.repoName,title:X,children:Y}),K.upstream&&K.ahead!==null&&(0,D.jsxs)(`span`,{className:E.divergence,title:i(`上游差异(本地记录)`,`Upstream divergence (local refs)`),children:[`↑`,K.ahead,` ↓`,K.behind]}),(0,D.jsxs)(`span`,{className:E.count,title:i(`改动文件`,`Changed files`),children:[K.entries.length,K.truncated?`+`:``]})]}),K.scope&&(0,D.jsxs)(`div`,{className:E.scope,title:K.scope,children:[i(`当前目录:`,`Directory: `),K.scope]})]}),(0,D.jsx)(O,{selectionKey:l?JSON.stringify(l):null,onClose:p,preview:l&&K?(0,D.jsx)(P,{sessionId:e,path:l.path,area:l.area,visible:t&&m===`changes`,idle:a,onClose:p},JSON.stringify([e,l])):null,children:(0,D.jsxs)(`div`,{className:`${v.scroll} ${E.changesScroll}`,"aria-busy":C,role:`region`,"aria-label":i(`改动文件`,`Changed files`),children:[A&&(0,D.jsxs)(`div`,{className:v.state,role:`status`,children:[i(`Git 读取失败,请检查仓库或重试。`,`Could not read Git. Check the repository or try again.`),` `,(0,D.jsx)(`button`,{type:`button`,className:v.textButton,onClick:H,children:i(`重试`,`Retry`)})]}),!b&&!A&&(0,D.jsx)(`p`,{className:v.state,role:`status`,children:i(`正在读取仓库…`,`Reading repository…`)}),b?.kind===`not-repository`&&(0,D.jsx)(`p`,{className:v.state,role:`status`,children:i(`当前工作区不在 Git 仓库中。`,`This workspace is not in a Git repository.`)}),b?.kind===`unavailable`&&(0,D.jsx)(`p`,{className:v.state,role:`status`,children:i(`Git 不可用,请在 Pi 所在机器安装 Git。`,`Git is unavailable. Install Git on the machine running Pi.`)}),K&&(0,D.jsxs)(D.Fragment,{children:[K.entries.length===0&&(0,D.jsx)(`p`,{className:v.state,role:`status`,children:K.scope?i(`当前目录没有未提交改动。`,`No uncommitted changes in this directory.`):i(`工作区干净,没有未提交改动。`,`Working tree clean. No uncommitted changes.`)}),q.filter(e=>e.changes.length>0).map(e=>(0,D.jsxs)(`section`,{"aria-label":e.title,children:[(0,D.jsxs)(`h3`,{className:E.groupHeading,children:[e.title,(0,D.jsx)(`span`,{children:e.changes.length})]}),(0,D.jsx)(`ul`,{className:E.list,children:e.changes.map(t=>{let n=e.conflict?`U`:e.area===`staged`?t.index:t.worktree;return(0,D.jsxs)(`li`,{className:E.changeRow,children:[(0,D.jsxs)(`button`,{type:`button`,className:E.change,title:t.originalPath?`${t.originalPath} → ${t.path}`:t.path,"data-git-file":JSON.stringify([e.area,t.path]),"aria-pressed":l?.path===t.path&&l.area===e.area,onClick:()=>f({path:t.path,area:e.area}),"aria-label":`${t.path}, ${B(n)}`,children:[(0,D.jsx)(g,{path:t.path,size:16}),(0,D.jsxs)(`span`,{className:E.filename,children:[t.path,t.originalPath&&(0,D.jsxs)(`small`,{children:[t.originalPath,` → `,t.path]})]}),(0,D.jsx)(`span`,{className:E.status,"data-status":n,"aria-hidden":`true`,children:n})]}),!e.conflict&&!t.submodule&&(0,D.jsx)(`button`,{type:`button`,className:E.fileAction,disabled:W,"aria-label":e.area===`staged`?i(`取消暂存 ${t.path}`,`Unstage ${t.path}`):i(`暂存 ${t.path}`,`Stage ${t.path}`),title:e.area===`staged`?i(`取消暂存`,`Unstage`):i(`暂存`,`Stage`),onClick:()=>{G(e.area===`staged`?`unstage`:`stage`,{path:t.path})},children:e.area===`staged`?`−`:`+`})]},t.path)})})]},e.title)),K.truncated&&(0,D.jsx)(`p`,{className:v.state,children:i(`仅显示前 1000 个改动文件,请缩小工作区范围。`,`Showing the first 1000 changed files. Open a smaller workspace to see more.`)})]})]})}),K&&(0,D.jsxs)(`div`,{className:E.commitFooter,"aria-busy":o.pending,children:[U&&(0,D.jsx)(`p`,{className:E.hint,role:`status`,children:S(U)}),N&&(0,D.jsx)(`p`,{className:E.hint,role:`status`,children:i(`操作状态读取失败,请刷新。`,`Could not read operation state. Refresh to retry.`)}),o.pending&&!L&&(0,D.jsx)(`p`,{className:E.hint,role:`status`,children:i(`正在执行 Git 操作…`,`Running Git operation…`)}),o.outcome&&!L&&(0,D.jsxs)(`div`,{className:E.feedbackRow,children:[(0,D.jsx)(`p`,{className:E.feedback,"data-error":!o.outcome.ok,role:`status`,children:S(o.outcome.reason)}),(0,D.jsx)(`button`,{type:`button`,className:v.iconButton,"aria-label":i(`关闭 Git 提示`,`Dismiss Git message`),onClick:()=>{o.outcome=null,V()},children:`×`})]}),K.scope?(0,D.jsx)(`p`,{className:E.rootHint,title:S(`root_required`),children:i(`提交请打开仓库根目录`,`Commit from repository root`)}):(0,D.jsxs)(`form`,{className:E.commitForm,"aria-label":i(`创建提交`,`Create commit`),onSubmit:e=>{e.preventDefault(),J&&G(`commit`,{message:o.message})},children:[(0,D.jsx)(`textarea`,{"aria-label":i(`提交说明`,`Commit message`),rows:1,maxLength:8192,disabled:o.pending,value:o.message,placeholder:i(`提交说明…`,`Commit message…`),onChange:e=>{o.message=e.target.value,V()},onKeyDown:e=>{let t=y.current?.guards(e.nativeEvent)??e.nativeEvent.isComposing;e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!t&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,D.jsxs)(`div`,{className:E.actionRow,children:[(0,D.jsx)(`span`,{className:E.hint,children:j?.staged?i(`仅暂存区 · ${j.staged} 个文件`,`Staged only · ${j.staged} files`):i(`先暂存要提交的文件`,`Stage files to commit`)}),(0,D.jsx)(`button`,{className:E.actionButton,type:`submit`,disabled:!J,title:i(`仅提交暂存区 · ⌘/Ctrl+Enter`,`Commit staged files · ⌘/Ctrl+Enter`),children:i(`提交`,`Commit`)})]})]})]})]})]})}),H=(0,x.memo)(function({sessionId:e,hash:t,visible:n,idle:a,onCommit:o}){r();let s=(0,x.useRef)(null),[c,l]=(0,x.useState)(null),u=()=>{let e=s.current?.querySelector(`[data-git-file][aria-pressed="true"]`);l(null),requestAnimationFrame(()=>e?.focus({preventScroll:!0}))},[f,p]=(0,x.useState)(0),{value:m,loading:h,error:_,refresh:y}=T((0,x.useCallback)(n=>w.commit(e,t,f,n),[e,t,f]),n,a,!1),b=m?.parentIndex===f?m:null;return(0,x.useEffect)(()=>{b&&c&&!b.files.some(e=>e.path===c)&&l(null)},[b,c]),(0,D.jsxs)(`div`,{className:`${v.body} ${E.panel}`,ref:s,children:[(0,D.jsxs)(`div`,{className:v.toolbar,children:[(0,D.jsxs)(`span`,{className:v.path,children:[i(`提交详情`,`Commit details`),` · `,t.slice(0,7)]}),(0,D.jsx)(`span`,{className:v.readonly,children:i(`只读`,`Read only`)}),(0,D.jsx)(`button`,{className:v.iconButton,type:`button`,onClick:y,"aria-label":i(`刷新提交详情`,`Refresh commit`),children:(0,D.jsx)(d,{})})]}),(0,D.jsx)(O,{selectionKey:c,onClose:u,preview:c&&b?(0,D.jsx)(U,{sessionId:e,hash:t,path:c,parentIndex:f,visible:n,idle:a,onClose:u},JSON.stringify([e,t,f,c])):null,children:(0,D.jsxs)(`div`,{className:v.scroll,"aria-busy":h,children:[_&&(0,D.jsxs)(`p`,{className:v.state,role:`status`,children:[i(`提交读取失败,可能已不可达。`,`Could not read this commit. It may no longer be reachable.`),` `,(0,D.jsx)(`button`,{className:v.textButton,type:`button`,onClick:y,children:i(`重试`,`Retry`)})]}),!m&&!_&&(0,D.jsx)(`p`,{className:v.state,role:`status`,children:i(`正在读取提交…`,`Reading commit…`)}),m&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:R.detail,children:[(0,D.jsx)(`h2`,{children:m.subject||i(`(无提交说明)`,`(No subject)`)}),(0,D.jsxs)(`dl`,{children:[(0,D.jsx)(`dt`,{children:i(`提交`,`Commit`)}),(0,D.jsx)(`dd`,{children:(0,D.jsx)(`code`,{children:m.hash})}),(0,D.jsx)(`dt`,{children:i(`作者`,`Author`)}),(0,D.jsxs)(`dd`,{children:[m.author,` <`,m.email,`>`]}),(0,D.jsx)(`dt`,{children:i(`创作时间`,`Authored`)}),(0,D.jsx)(`dd`,{children:(0,D.jsx)(`time`,{dateTime:m.authoredAt,children:m.authoredAt})}),(0,D.jsx)(`dt`,{children:i(`提交者`,`Committer`)}),(0,D.jsxs)(`dd`,{children:[m.committer,` <`,m.committerEmail,`>`]}),(0,D.jsx)(`dt`,{children:i(`提交时间`,`Committed`)}),(0,D.jsx)(`dd`,{children:(0,D.jsx)(`time`,{dateTime:m.committedAt,children:m.committedAt})}),(0,D.jsx)(`dt`,{children:i(`父提交`,`Parents`)}),(0,D.jsx)(`dd`,{className:R.parentList,children:m.parents.length?m.parents.map((e,t)=>(0,D.jsx)(`button`,{type:`button`,className:R.parentLink,onClick:()=>o(e),"aria-label":i(`打开父提交 ${t+1}:${e.slice(0,7)}`,`Open parent ${t+1}: ${e.slice(0,7)}`),children:(0,D.jsx)(`code`,{children:e.slice(0,7)})},e)):i(`根提交`,`Root commit`)})]}),(0,D.jsx)(`div`,{className:R.message,"aria-label":i(`完整提交说明`,`Full commit message`),children:m.message}),m.scope&&(0,D.jsxs)(`p`,{className:v.state,children:[i(`文件改动仅限:`,`File changes limited to: `),m.scope]})]}),m.parents.length>1?(0,D.jsxs)(`label`,{className:R.parentSelect,children:[i(`比较基准`,`Compare against`),(0,D.jsx)(`select`,{"aria-label":i(`比较父提交`,`Compare parent`),value:f,onChange:e=>{l(null),p(Number(e.target.value))},children:m.parents.map((e,t)=>(0,D.jsxs)(`option`,{value:t,children:[i(`父提交 ${t+1}`,`Parent ${t+1}`),` · `,e.slice(0,7)]},`${t}/${e}`))})]}):(0,D.jsx)(`p`,{className:v.state,children:m.parents.length?i(`与父提交比较`,`Compared with parent`):i(`与空目录比较`,`Compared with empty tree`)}),!b&&!_&&(0,D.jsx)(`p`,{className:v.state,role:`status`,children:i(`正在读取文件改动…`,`Reading changed files…`)}),b&&(0,D.jsxs)(`section`,{"aria-label":i(`提交文件`,`Commit files`),children:[(0,D.jsxs)(`h3`,{className:E.groupHeading,children:[i(`改动文件`,`Changed files`),(0,D.jsxs)(`span`,{children:[b.files.length,b.truncated?`+`:``]})]}),b.files.length===0&&(0,D.jsx)(`p`,{className:v.state,children:i(`所选比较在当前目录中没有文件改动。`,`No file changes in this directory for this comparison.`)}),(0,D.jsx)(`ul`,{className:E.list,children:b.files.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(`button`,{className:E.change,type:`button`,"data-git-file":e.path,"aria-pressed":c===e.path,onClick:()=>l(e.path),"aria-label":i(`查看提交差异:${e.path}`,`View commit diff: ${e.path}`),children:[(0,D.jsx)(g,{path:e.path,size:16}),(0,D.jsx)(`span`,{className:E.filename,children:e.path}),(0,D.jsx)(`span`,{className:R.fileStats,children:e.additions===null?i(`二进制`,`Binary`):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:E.added,children:[`+`,e.additions]}),(0,D.jsxs)(`span`,{className:E.removed,children:[`−`,e.deletions]})]})}),(0,D.jsx)(`span`,{className:E.status,"data-status":e.status,children:e.status})]})},e.path))}),b.truncated&&(0,D.jsx)(`p`,{className:v.state,children:i(`仅显示前 1000 个文件。`,`Showing the first 1000 files.`)})]})]})]})})]})}),U=(0,x.memo)(function({sessionId:e,hash:t,path:n,parentIndex:a,visible:o,idle:s,onClose:c}){r();let l=T((0,x.useCallback)(r=>w.commitDiff(e,t,n,a,r),[e,t,n,a]),o,s,!1),u=l.value?l.value.parentHash?`${i(`父提交`,`Parent`)} ${l.value.parentHash.slice(0,7)}`:i(`空目录`,`Empty tree`):``;return(0,D.jsx)(M,{onClose:c,path:n,label:`${t.slice(0,7)}${u?` · ${u}`:``}`,...l})}),W=()=>({selection:null,view:`changes`,history:null,selected:null,message:``,branch:``,checkout:!0,pending:!1,outcome:null}),G={id:s.git,kind:`builtin`,version:`1.0.0`,name:{zh:`Git`,en:`Git`},description:{zh:`审阅工作区改动与提交历史,暂存文件、提交并管理本地分支。`,en:`Review workspace changes and history, stage files, commit and manage local branches.`}},K=a({id:G.id,apiVersion:1,activate(){},workbench:{apiVersion:1,entry:{label:{zh:`Git 改动`,en:`Git changes`},description:{zh:`查看分支、工作区改动与文件差异`,en:`Review branches, workspace changes and file diffs`},kind:`git`,icon:u},panels:[{kind:`git`,title:()=>(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(u,{size:16}),(0,D.jsx)(`span`,{children:`Git`})]}),component:e=>(0,D.jsx)(V,{sessionId:e.session.sessionId,visible:e.visible,idle:e.session.idle,model:e.resource(W),onCommit:t=>e.open(`git-commit`,t,t.slice(0,7))})},{kind:`git-commit`,component:e=>(0,D.jsx)(H,{sessionId:e.session.sessionId,hash:e.contentId,visible:e.visible,idle:e.session.idle,onCommit:t=>e.open(`git-commit`,t,t.slice(0,7))})},{kind:`git-diff`,component:e=>{let[t,n]=JSON.parse(e.contentId);return(0,D.jsx)(P,{sessionId:e.session.sessionId,area:t,path:n,visible:e.visible,idle:e.session.idle})}},{kind:`git-commit-diff`,component:e=>{let[t,n,r]=JSON.parse(e.contentId);return(0,D.jsx)(U,{sessionId:e.session.sessionId,hash:t,parentIndex:n,path:r,visible:e.visible,idle:e.session.idle})}}]}});export{K as default};
|
|
4
|
-
//# debugId=567b9866-b37b-4ceb-b041-67015b67779e
|