pi-webapp 0.1.55 → 0.1.56-alpha.2
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 +42 -42
- package/dist/hosted-recovery.js +2 -2
- package/dist/hosted-worker.js +2 -2
- package/package.json +2 -2
- package/web/dist/.vite/manifest.json +33 -33
- package/web/dist/assets/{MarkdownText-B0lTkHnh.js → MarkdownText-paPGy70d.js} +4 -4
- package/web/dist/assets/app-DJSrK_Zp.js +47 -0
- package/web/dist/assets/app.css +1 -1
- package/web/dist/assets/app.js +4 -4
- package/web/dist/assets/{code-editor-C6H898SO.js → code-editor-B8TlHSZ2.js} +4 -4
- package/web/dist/assets/{dist-BC5rhbA9.js → dist-BaIxDEhr.js} +2 -2
- package/web/dist/assets/{dist-DJHsuvn-.js → dist-C9IQx5Hu.js} +2 -2
- package/web/dist/assets/{dist-B13-0-xd.js → dist-CKAzjWVl.js} +2 -2
- package/web/dist/assets/{dist-B7el5Xxf.js → dist-COZ-qI6c.js} +2 -2
- package/web/dist/assets/{dist-tUJ9MRsj.js → dist-CbdvIpQm.js} +2 -2
- package/web/dist/assets/{dist-CJ51vQxV.js → dist-ChpeI5sm.js} +2 -2
- package/web/dist/assets/{dist-Bk-i0mDA.js → dist-DAt6qRRZ.js} +2 -2
- package/web/dist/assets/{dist-CsB02yZG.js → dist-DSjz0NBU.js} +2 -2
- package/web/dist/assets/{dist-BDYcNjGw.js → dist-DtXr2huq.js} +2 -2
- package/web/dist/assets/{dist-CCRolIbm.js → dist-Vw-Le9ug.js} +2 -2
- package/web/dist/assets/{dist-B0PC9_Nt.js → dist-rBe9wuZZ.js} +2 -2
- package/web/dist/assets/{graphql-BF2oJ7rL.js → graphql-BnPNCaAx.js} +2 -2
- package/web/dist/assets/{http-DAsDLqNF.js → http-BHenJU6v.js} +2 -2
- package/web/dist/assets/{php-9gqNKxQq.js → php-CSISLp2r.js} +2 -2
- package/web/dist/assets/{plugin-Brtr3RkZ.js → plugin-BKKu8P5i.js} +3 -3
- package/web/dist/assets/{plugin-DmtAnobQ.js → plugin-CbtUZ7SO.js} +2 -2
- package/web/dist/assets/{plugin-11j8L285.js → plugin-Cf84Pl1e.js} +2 -2
- package/web/dist/assets/{rst-C7qSPPW4.js → rst-DJndqjRb.js} +2 -2
- package/web/dist/assets/{ruby-oaMY0UVj.js → ruby-CLM38Wvm.js} +2 -2
- package/web/dist/assets/{svelte-P19aQrs9.js → svelte-B7f1JlvH.js} +2 -2
- package/web/dist/assets/{vue-BXooeCPT.js → vue-Cv4DFyTm.js} +2 -2
- package/web/dist/assets/app-BmaB_3Fk.js +0 -47
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/code-editor-
|
|
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]=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/code-editor-B8TlHSZ2.js","assets/rolldown-runtime-CgmABjMJ.js","assets/dist-IkQ96Etc.js","assets/app.js","assets/app-DJSrK_Zp.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]=`be8b0fe5-3ea2-40ee-826d-c84a3e2dea04`,e._sentryDebugIdIdentifier=`sentry-dbid-be8b0fe5-3ea2-40ee-826d-c84a3e2dea04`)}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-DJSrK_Zp.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-B8TlHSZ2.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
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
4
|
`)?A.replace(/\n/gu,`\r
|
|
5
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=
|
|
6
|
+
//# debugId=be8b0fe5-3ea2-40ee-826d-c84a3e2dea04
|
|
@@ -1,4 +1,4 @@
|
|
|
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]=`8fcb444c-d5e4-4533-9ac1-436ecaa397f2`,e._sentryDebugIdIdentifier=`sentry-dbid-8fcb444c-d5e4-4533-9ac1-436ecaa397f2`)}catch{}})();import{r as e}from"./rolldown-runtime-CgmABjMJ.js";import{a as t,c as n,f as r,g as i,h as a,n as o,o as s,r as c,s as l}from"./app-BmaB_3Fk.js";import{o as u,s as d}from"./app.js";import{t as f}from"./react-CLFE7TFE.js";import{n as p}from"./clsx-DQAHfk8w.js";var m={id:l.terminal,kind:`builtin`,version:`1.0.0`,name:{zh:`终端`,en:`Terminal`},description:{zh:`在工作区运行交互式 Shell。停用会结束此服务的所有终端进程。`,en:`Run an interactive shell in the workspace. Disabling ends all terminals on this service.`}},h=`terminal-input`,g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,ee=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?_(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&g(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),te=`Terminal input`,ne={get:()=>te,set:e=>te=e},re=`Too much output to announce, navigate to rows manually to read`,ie={get:()=>re,set:e=>re=e};function ae(e){return e.replace(/\r?\n/g,`\r`)}function oe(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function b(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function se(e,t,n,r){e.stopPropagation(),e.clipboardData&&x(e.clipboardData.getData(`text/plain`),t,n,r)}function x(e,t,n,r){e=ae(e),e=oe(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ce(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function le(e,t,n,r,i){ce(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ue(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function S(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var de=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},fe=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},pe=``,me=` `,he=class e{constructor(){this.fg=0,this.bg=0,this.extended=new ge}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ge=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},C=class e extends he{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ge,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ue(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},w=`di$target`,_e=`di$dependencies`,ve=new Map;function ye(e){return e[_e]||[]}function T(e){if(ve.has(e))return ve.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);be(t,e,r)};return t._id=e,ve.set(e,t),t}function be(e,t,n){t[w]===t?t[_e].push({id:e,index:n}):(t[_e]=[{id:e,index:n}],t[w]=t)}var E=T(`BufferService`),xe=T(`CoreMouseService`),D=T(`CoreService`),Se=T(`CharsetService`),Ce=T(`InstantiationService`),we=T(`LogService`),O=T(`OptionsService`),Te=T(`OscLinkService`),Ee=T(`UnicodeService`),De=T(`DecorationService`),Oe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new C,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):ke(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Oe=v([y(0,E),y(1,O),y(2,Te)],Oe);function ke(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
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]=`b31d0e26-2ed1-4b7b-80ac-32e853b758ad`,e._sentryDebugIdIdentifier=`sentry-dbid-b31d0e26-2ed1-4b7b-80ac-32e853b758ad`)}catch{}})();import{r as e}from"./rolldown-runtime-CgmABjMJ.js";import{a as t,c as n,f as r,g as i,h as a,n as o,o as s,r as c,s as l}from"./app-DJSrK_Zp.js";import{o as u,s as d}from"./app.js";import{t as f}from"./react-CLFE7TFE.js";import{n as p}from"./clsx-DQAHfk8w.js";var m={id:l.terminal,kind:`builtin`,version:`1.0.0`,name:{zh:`终端`,en:`Terminal`},description:{zh:`在工作区运行交互式 Shell。停用会结束此服务的所有终端进程。`,en:`Run an interactive shell in the workspace. Disabling ends all terminals on this service.`}},h=`terminal-input`,g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,ee=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?_(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&g(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),te=`Terminal input`,ne={get:()=>te,set:e=>te=e},re=`Too much output to announce, navigate to rows manually to read`,ie={get:()=>re,set:e=>re=e};function ae(e){return e.replace(/\r?\n/g,`\r`)}function oe(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function b(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function se(e,t,n,r){e.stopPropagation(),e.clipboardData&&x(e.clipboardData.getData(`text/plain`),t,n,r)}function x(e,t,n,r){e=ae(e),e=oe(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ce(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function le(e,t,n,r,i){ce(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ue(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function S(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var de=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},fe=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},pe=``,me=` `,he=class e{constructor(){this.fg=0,this.bg=0,this.extended=new ge}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ge=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},C=class e extends he{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ge,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ue(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},w=`di$target`,_e=`di$dependencies`,ve=new Map;function ye(e){return e[_e]||[]}function T(e){if(ve.has(e))return ve.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);be(t,e,r)};return t._id=e,ve.set(e,t),t}function be(e,t,n){t[w]===t?t[_e].push({id:e,index:n}):(t[_e]=[{id:e,index:n}],t[w]=t)}var E=T(`BufferService`),xe=T(`CoreMouseService`),D=T(`CoreService`),Se=T(`CharsetService`),Ce=T(`InstantiationService`),we=T(`LogService`),O=T(`OptionsService`),Te=T(`OscLinkService`),Ee=T(`UnicodeService`),De=T(`DecorationService`),Oe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new C,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):ke(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Oe=v([y(0,E),y(1,O),y(2,Te)],Oe);function ke(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
2
2
|
|
|
3
3
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ae=T(`CharSizeService`),je=T(`CoreBrowserService`),Me=T(`MouseService`),Ne=T(`RenderService`),Pe=T(`SelectionService`),Fe=T(`CharacterJoinerService`),Ie=T(`ThemeService`),Le=T(`LinkProviderService`),Re=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?We.isErrorNoTelemetry(e)?new We(e.message+`
|
|
4
4
|
|
|
@@ -15,4 +15,4 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
15
15
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===is+1&&(this._liveRegion.textContent+=ie.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};as=v([y(1,Ce),y(2,je),y(3,Ne)],as);var os=class extends A{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new N),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new N),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(k(()=>{nt(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(P(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(P(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(P(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(P(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){this._activeLine!==e.y||this._wasResized?(this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1):this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){this._activeProviderReplies&&t||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&ss(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,nt(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};os=v([y(1,Me),y(2,Ne),y(3,E),y(4,Le)],os);function ss(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var cs=class extends Jo{constructor(e={}){super(e),this._linkifier=this._register(new ot),this.browser=Ei,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ot),this._onCursorMove=this._register(new N),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new N),this.onKey=this._onKey.event,this._onRender=this._register(new N),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new N),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new N),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new N),this.onBell=this._onBell.event,this._onFocus=this._register(new N),this._onBlur=this._register(new N),this._onA11yCharEmitter=this._register(new N),this._onA11yTabEmitter=this._register(new N),this._onWillOpen=this._register(new N),this._setup(),this._decorationService=this._instantiationService.createInstance(es),this._instantiationService.setService(De,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(xi),this._instantiationService.setService(Le,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Oe)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(M.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(M.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(M.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(M.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(k(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=U.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${L.ESC}]${n};${Mo(r)}${Ur.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=H.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=H.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(as,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(L.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(L.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(P(this.element,`copy`,e=>{this.hasSelection()&&b(e,this._selectionService)}));let e=e=>se(e,this.textarea,this.coreService,this.optionsService);this._register(P(this.textarea,`paste`,e)),this._register(P(this.element,`paste`,e)),Ai?this._register(P(this.element,`mousedown`,e=>{e.button===2&&le(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(P(this.element,`contextmenu`,e=>{le(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Ri&&this._register(P(this.element,`auxclick`,e=>{e.button===1&&ce(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(P(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(P(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(P(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(P(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(P(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(P(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(P(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(P(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,ne.get()),zi||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(yi,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(je,this._coreBrowserService),this._register(P(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(P(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(hi,this._document,this._helperContainer),this._instantiationService.setService(Ae,this._charSizeService),this._themeService=this._instantiationService.createInstance(Sa),this._instantiationService.setService(Ie,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Xr),this._instantiationService.setService(Fe,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Gi,this.rows,this.screenElement)),this._instantiationService.setService(Ne,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(Wr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(wi),this._instantiationService.setService(Me,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(os,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Fr,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(pa,this.element,this.screenElement,r)),this._instantiationService.setService(Pe,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(M.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Ir,this.screenElement)),this._register(P(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(as,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Vr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Vr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(mi,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(P(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(P(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=L.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){x(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=Xo(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===L.ETX||n.key===L.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(ls(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Y));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(L.ESC+`[I`):this.coreService.triggerDataEvent(L.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${L.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${L.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function ls(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var us=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},ds=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new C)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},fs=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new ds(t)}getNullCell(){return new C}},ps=class extends A{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new N),this.onBufferChange=this._onBufferChange.event,this._normal=new fs(this._core.buffers.normal,`normal`),this._alternate=new fs(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},ms=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},hs=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},gs=[`cols`,`rows`],_s=0,vs=class extends A{constructor(e){super(),this._core=this._register(new cs(e)),this._addonManager=this._register(new us),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(gs.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new ms(this._core),this._parser}get unicode(){return this._checkProposedApi(),new hs(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new ps(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
16
16
|
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return ne.get()},set promptLabel(e){ne.set(e)},get tooMuchOutput(){return ie.get()},set tooMuchOutput(e){ie.set(e)}}}_verifyIntegers(...e){for(_s of e)if(_s===1/0||isNaN(_s)||_s%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(_s of e)if(_s&&(_s===1/0||isNaN(_s)||_s%1!=0||_s<0))throw Error(`This API only accepts positive integers`)}},ys=2,bs=1,xs=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(ys,Math.floor(u/e.css.cell.width)),rows:Math.max(bs,Math.floor(l/e.css.cell.height))}}};function Ss(e,t){let n=document.querySelector(`meta[name="pi-style-nonce"]`)?.content,r=document.createElement;document.createElement=function(e,t){let i=r.call(document,e,t);return n&&i instanceof HTMLStyleElement&&(i.nonce=n),i};try{e.open(t)}finally{document.createElement=r}}async function Cs(e,n,r){await s(await t(`/api/plugin-interaction`,{method:`POST`,headers:{Authorization:`Bearer ${d()}`,"Content-Type":`application/json`},body:JSON.stringify({sessionId:e,pluginId:m.id,requestId:n,value:r})}))}var ws=class{element=document.createElement(`div`);terminal=new vs({cursorBlink:!0,scrollback:2e3,fontSize:13,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,minimumContrastRatio:4.5,macOptionClickForcesSelection:!0});fit=new xs;state={phase:`starting`};listeners=new Set;lifetime;retry;opened=!1;created=!1;disposed=!1;commands=Promise.resolve();queued=0;active=!0;creation;offline=()=>{this.state.phase!==`exited`&&this.state.phase!==`failed`&&(this.lifetime?.abort(),this.patch({phase:`disconnected`}))};online=()=>{this.connect()};id;sessionId;constructor(e,t){this.id=e,this.sessionId=t,this.element.style.cssText=`width:100%;height:100%;min-width:0;overflow:hidden`,this.terminal.loadAddon(this.fit),window.addEventListener(`offline`,this.offline),window.addEventListener(`online`,this.online),this.terminal.attachCustomKeyEventHandler(e=>e.type===`keydown`&&(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`c`&&this.terminal.hasSelection()?(r(this.terminal.getSelection()),!1):!0),this.terminal.onData(e=>this.input(e)),this.terminal.onResize(e=>{this.state.phase===`connected`&&this.active&&this.enqueue(`resize`,e)})}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;patch(e){this.state=e,this.terminal.options.disableStdin=e.phase!==`connected`||!this.active;for(let e of this.listeners)e()}activate(e){this.active=e,this.terminal.options.disableStdin=!e||this.state.phase!==`connected`,e&&this.opened&&!this.lifetime&&this.state.phase===`disconnected`&&this.connect()}mount(e){e.append(this.element),this.opened||(this.opened=!0,Ss(this.terminal,this.element),this.terminal.textarea?.setAttribute(`aria-label`,`Terminal input`),this.connect())}measure(){if(!this.element.isConnected||!this.element.clientWidth||!this.element.clientHeight||this.element.closest(`[aria-hidden=true]`))return;let e=document.body.hasAttribute(`data-ds-dark-theme`);this.terminal.options.theme=e?{background:`#151618`,foreground:`#e5e5e5`,cursor:`#e5e5e5`,selectionBackground:`#264f78`,selectionInactiveBackground:`#3a3d41`}:{background:`#ffffff`,foreground:`#242424`,cursor:`#242424`,selectionBackground:`#add6ff`,selectionInactiveBackground:`#e5ebf1`};let t=this.fit.proposeDimensions();t&&this.terminal.resize(Math.min(500,Math.max(2,t.cols)),Math.min(300,Math.max(1,t.rows)))}async request(e,n,r){return t(`/api/terminal/${e}`,{method:`POST`,headers:{Authorization:`Bearer ${d()}`,"Content-Type":`application/json`},body:JSON.stringify({sessionId:this.sessionId,id:this.id,...n}),signal:r},{expectedNetworkFailure:!0})}async connect(){if(this.disposed||this.lifetime||!this.active||!navigator.onLine||this.state.phase===`exited`)return;clearTimeout(this.retry);let e=new AbortController;this.lifetime=e,this.patch({phase:this.created?`disconnected`:`starting`});try{if(this.created||=(this.creation=this.request(`create`,{cols:this.terminal.cols,rows:this.terminal.rows}).then(s),await this.creation,!0),this.disposed)return;let t=await this.request(`attach`,{},e.signal);t.response.ok||await s(t);let n=t.response.body.getReader();try{let e=new TextDecoder,t=``;for(;!this.disposed;){let{done:r,value:i}=await n.read();if(r)break;if(t+=e.decode(i,{stream:!0}),t.length>2097152)throw Error(`Terminal stream overflow`);let a;for(;(a=t.indexOf(`
|
|
17
17
|
`))>=0;){let e=JSON.parse(t.slice(0,a));if(t=t.slice(a+1),e.type===`snapshot`)this.terminal.reset(),this.terminal.resize(e.cols,e.rows),await new Promise(t=>this.terminal.write(e.screen,t)),this.patch({phase:`connected`}),this.measure(),this.active&&this.enqueue(`resize`,{cols:this.terminal.cols,rows:this.terminal.rows});else if(e.type===`output`)await new Promise(t=>this.terminal.write(e.data,t));else if(e.type===`resize`)continue;else if(e.type===`exit`){this.patch({phase:`exited`,exitCode:e.exitCode});return}}}throw Error(`Terminal disconnected`)}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}catch(e){if(this.disposed)return;let t=e instanceof n&&e.status!==409&&e.status<500;this.patch({phase:t?`failed`:`disconnected`,reason:e instanceof n?e.reason:void 0}),t||(this.retry=setTimeout(()=>{this.connect()},1500))}finally{this.lifetime===e&&(this.lifetime=void 0)}}input(e){if(this.state.phase!==`connected`||!this.active)return;if(this.queued+e.length>65536){this.lifetime?.abort();return}let t=``;for(let n of e)t+=n,t.length>=4e3&&(this.enqueue(`input`,{data:t}),t=``);t&&this.enqueue(`input`,{data:t})}enqueue(e,t){let r=this.lifetime,i=t.data?.length??0;this.queued+=i,this.commands=this.commands.then(async()=>{this.disposed||!this.active||this.state.phase!==`connected`||r!==this.lifetime||r?.signal.aborted||await s(await this.request(e,t,r?.signal))}).catch(e=>{e instanceof n&&e.status===409||r?.abort()}).finally(()=>{this.queued-=i})}dispose(){this.disposed=!0,clearTimeout(this.retry),this.lifetime?.abort(),window.removeEventListener(`offline`,this.offline),window.removeEventListener(`online`,this.online),(async()=>{try{await this.creation,this.created&&await s(await this.request(`close`,{}))}catch{}this.terminal.dispose(),this.element.remove(),this.listeners.clear()})()}},Ts=e(f(),1),Es={card:`_card_1cq3g_1`,overlay:`_overlay_1cq3g_2`,title:`_title_1cq3g_3`,command:`_command_1cq3g_4`,enter:`_enter_1cq3g_5`,hint:`_hint_1cq3g_6`,error:`_error_1cq3g_7`,actions:`_actions_1cq3g_8`},$=p();function Ds(e){if(!e||e.pluginId!==m.id||e.kind!==`terminal-input`)return null;let t=e.data;return!t||typeof t.terminalId!=`string`||typeof t.text!=`string`||typeof t.enter!=`boolean`?null:{requestId:e.requestId,terminalId:t.terminalId,text:t.text,enter:t.enter}}var Os={zh:{title:`Pi 想在终端中输入`,hint:`允许后会在你的终端里执行,与你亲自输入相同。`,noEnter:`(不按回车)`,allow:`允许`,deny:`拒绝`,failed:`未能提交决定,请重试。`},en:{title:`Pi wants to type into the terminal`,hint:`If you allow it, it runs in your shell as if you typed it.`,noEnter:`(without pressing Enter)`,allow:`Allow`,deny:`Deny`,failed:`Could not submit your decision. Try again.`}};function ks({approval:e,locale:t,decide:n,overlay:r=!1}){let i=Os[t],[a,o]=(0,Ts.useState)(!1),[s,l]=(0,Ts.useState)(!1),u=e=>{o(!0),l(!1),n({allow:e}).catch(()=>{l(!0),o(!1)})};return(0,$.jsxs)(`section`,{role:`alertdialog`,"aria-label":i.title,"data-terminal-approval":e.terminalId,"data-approval-place":r?`terminal`:`composer`,className:r?`${Es.card} ${Es.overlay}`:Es.card,children:[(0,$.jsx)(`strong`,{className:Es.title,children:i.title}),(0,$.jsxs)(`pre`,{className:Es.command,children:[e.text,e.enter?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:Es.enter,children:` ⏎`}):null]}),!e.enter&&(0,$.jsx)(`span`,{className:Es.hint,children:i.noEnter}),(0,$.jsx)(`span`,{className:Es.hint,children:i.hint}),s&&(0,$.jsx)(`span`,{role:`alert`,className:Es.error,children:i.failed}),(0,$.jsxs)(`div`,{className:Es.actions,children:[(0,$.jsx)(c,{size:`sm`,variant:`outline`,disabled:a,onClick:()=>u(!1),children:i.deny}),(0,$.jsx)(c,{size:`sm`,variant:`primary`,disabled:a,onClick:()=>u(!0),children:i.allow})]})]})}var As={root:`_root_1p0pc_1`,screen:`_screen_1p0pc_3`,status:`_status_1p0pc_4`};function js(e){switch(e){case`terminal_shell_unavailable`:return a(`终端不可用:默认 shell 不存在或不可执行。请修正 SHELL(Windows 为 COMSPEC)后重启应用。`,`Terminal unavailable: the default shell is missing or not executable. Correct SHELL (COMSPEC on Windows) and restart the app.`);case`terminal_workspace_unavailable`:return a(`终端不可用:工作区目录不存在或不可访问。请切换到有效工作区后新建终端。`,`Terminal unavailable: the workspace directory is missing or inaccessible. Select a valid workspace, then open a new terminal.`);case`terminal_runtime_unavailable`:return a(`终端不可用:本机终端组件启动失败。请重新安装或修复应用的 node-pty 依赖后重启。`,`Terminal unavailable: the native terminal component failed to start. Reinstall or repair the app's node-pty dependency, then restart.`);case`terminal_limit`:return a(`终端数量已达上限,请关闭不用的终端后重试。`,`Terminal limit reached. Close unused terminals and try again.`);default:return a(`终端不可用,请检查默认 shell 和工作区目录后重新打开。`,`Terminal unavailable. Check the default shell and workspace directory, then open a new terminal.`)}}function Ms({model:e,visible:t,onNew:n,sessionId:r,interactions:o}){let s=e,l=a(`终端输入`,`Terminal input`),u=(0,Ts.useRef)(null),d=(0,Ts.useSyncExternalStore)(e.subscribe,e.getSnapshot);(0,Ts.useLayoutEffect)(()=>{let e=u.current;s.mount(e);let t=new ResizeObserver(()=>s.measure());t.observe(e);let n=new MutationObserver(()=>s.measure());return n.observe(document.body,{attributes:!0,attributeFilter:[`data-ds-dark-theme`]}),()=>{t.disconnect(),n.disconnect(),s.element.remove()}},[e]),(0,Ts.useLayoutEffect)(()=>{e.terminal.textarea?.setAttribute(`aria-label`,l),t&&(e.measure(),e.terminal.focus())},[e,t,d.phase,l]);let f=i(),p=o?.map(Ds).find(t=>t?.terminalId===e.id)??null;return(0,$.jsxs)(`section`,{className:As.root,"data-workspace-terminal":e.id,"data-terminal-phase":d.phase,children:[d.phase!==`connected`&&(0,$.jsxs)(`div`,{className:As.status,role:`status`,children:[(0,$.jsx)(`span`,{children:d.phase===`starting`?a(`正在启动终端…`,`Starting terminal…`):d.phase===`disconnected`?a(`连接断开,正在重连…`,`Disconnected. Reconnecting…`):d.phase===`exited`?a(`进程已退出(${d.exitCode})`,`Process exited (${d.exitCode})`):js(d.reason)}),(d.phase===`failed`||d.phase===`exited`)&&(0,$.jsx)(c,{size:`sm`,onClick:n,children:a(`新建终端`,`New terminal`)})]}),(0,$.jsx)(`div`,{className:As.screen,ref:u}),p&&(0,$.jsx)(ks,{overlay:!0,approval:p,locale:f,decide:e=>Cs(r,p.requestId,e)},p.requestId)]})}var Ns=o({id:m.id,apiVersion:1,activate(){},interactions:[{kind:h,component:e=>{let t=Ds(e.interaction);return t&&(0,$.jsx)(ks,{approval:t,locale:e.locale,decide:t=>e.resolveInteraction(t)})}}],workbench:{apiVersion:1,entry:{label:{zh:`打开终端`,en:`Open terminal`},panelTitle:m.name,description:{zh:`在当前工作区中运行交互式 Shell`,en:`Run an interactive shell in this workspace`},kind:`terminal`,multiple:!0,icon:()=>(0,$.jsx)(`span`,{"aria-hidden":`true`,style:{fontFamily:`monospace`,fontSize:24},children:`›_`})},panels:[{kind:`terminal`,component:e=>(0,$.jsx)(Ms,{model:e.resource(()=>new ws(e.contentId,e.session.sessionId),e=>e.dispose(),(e,t)=>e.activate(t)),visible:e.visible,sessionId:e.session.sessionId,interactions:e.session.interactions,onNew:()=>e.open(`terminal`,u(),e.locale===`zh`?`终端`:`Terminal`)})}]}});export{Ns as default};
|
|
18
|
-
//# debugId=
|
|
18
|
+
//# debugId=b31d0e26-2ed1-4b7b-80ac-32e853b758ad
|
|
@@ -1,4 +1,4 @@
|
|
|
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]=`
|
|
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]=`f9065d1c-2098-4bd4-b0e6-391f4606b9b1`,e._sentryDebugIdIdentifier=`sentry-dbid-f9065d1c-2098-4bd4-b0e6-391f4606b9b1`)}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-DJSrK_Zp.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
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
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=
|
|
4
|
+
//# debugId=f9065d1c-2098-4bd4-b0e6-391f4606b9b1
|
|
@@ -1,2 +1,2 @@
|
|
|
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]=`f1bf6b70-51e3-4f88-83b6-ab312c0a88c5`,e._sentryDebugIdIdentifier=`sentry-dbid-f1bf6b70-51e3-4f88-83b6-ab312c0a88c5`)}catch{}})();import{t as e}from"./html-derivative-Di3X0LuZ.js";import t from"./cpp-DKT7ktbv.js";import n from"./python-_UfA4Rpn.js";import{t as r}from"./javascript-qRALF4mN.js";import{r as i}from"./MarkdownText-B0lTkHnh.js";import a from"./yaml-BOAQTz6b.js";import o from"./cmake-Cf85PuIk.js";import s from"./ruby-oaMY0UVj.js";var c=Object.freeze(JSON.parse('{"displayName":"reStructuredText","name":"rst","patterns":[{"include":"#body"}],"repository":{"anchor":{"match":"^\\\\.{2}\\\\s+(_[^:]+:)\\\\s*","name":"entity.name.tag.anchor"},"block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+\\\\S+::)(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"variable"}},"end":"^(?!\\\\1\\\\s|\\\\s*$)","patterns":[{"include":"#block-param"},{"include":"#body"}]},"block-comment":{"begin":"^(\\\\s*)\\\\.{2}(\\\\s+|$)","end":"^(?:(?=\\\\S)|\\\\s*$)","name":"comment.block","patterns":[{"begin":"^\\\\s{3,}(?=\\\\S)","name":"comment.block","while":"^(?:\\\\s{3}.*|\\\\s*$)"}]},"block-param":{"patterns":[{"captures":{"1":{"name":"keyword.control"},"2":{"name":"variable.parameter"}},"match":"(:param\\\\s+(.+?):)(?:\\\\s|$)"},{"captures":{"1":{"name":"keyword.control"},"2":{"patterns":[{"match":"\\\\b(0x[A-Fa-f\\\\d]+|\\\\d+)\\\\b","name":"constant.numeric"},{"include":"#inline-markup"}]}},"match":"(:.+?:)(?:$|\\\\s+(.*))"}]},"blocks":{"patterns":[{"include":"#domains"},{"include":"#doctest"},{"include":"#code-block-cpp"},{"include":"#code-block-py"},{"include":"#code-block-console"},{"include":"#code-block-javascript"},{"include":"#code-block-yaml"},{"include":"#code-block-cmake"},{"include":"#code-block-kconfig"},{"include":"#code-block-ruby"},{"include":"#code-block-dts"},{"include":"#code-block"},{"include":"#doctest-block"},{"include":"#raw-html"},{"include":"#block"},{"include":"#literal-block"},{"include":"#block-comment"}]},"body":{"patterns":[{"include":"#title"},{"include":"#inline-markup"},{"include":"#anchor"},{"include":"#line-block"},{"include":"#replace-include"},{"include":"#footnote"},{"include":"#substitution"},{"include":"#blocks"},{"include":"#table"},{"include":"#simple-table"},{"include":"#options-list"}]},"bold":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)\\\\*{2}[^*\\\\s]","end":"\\\\*{2}|^\\\\s*$","name":"markup.bold"},"citation":{"applyEndPatternLast":0,"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)`[^`\\\\s]","end":"`_{0,2}|^\\\\s*$","name":"entity.name.tag"},"code-block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)","beginCaptures":{"2":{"name":"keyword.control"}},"patterns":[{"include":"#block-param"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-cmake":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(cmake)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.cmake"}},"patterns":[{"include":"#block-param"},{"include":"source.cmake"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-console":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(console|shell|bash)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.console"}},"patterns":[{"include":"#block-param"},{"include":"source.shell"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-cpp":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(c|c\\\\+\\\\+|cpp|C|C\\\\+\\\\+|CPP|Cpp)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.cpp"}},"patterns":[{"include":"#block-param"},{"include":"source.cpp"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-dts":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(dts|DTS|devicetree)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.dts"}},"patterns":[{"include":"#block-param"},{"include":"source.dts"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-javascript":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(javascript)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.js"}},"patterns":[{"include":"#block-param"},{"include":"source.js"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-kconfig":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*([Kk]config)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.kconfig"}},"patterns":[{"include":"#block-param"},{"include":"source.kconfig"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-py":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(python)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.py"}},"patterns":[{"include":"#block-param"},{"include":"source.python"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-ruby":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(ruby)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.ruby"}},"patterns":[{"include":"#block-param"},{"include":"source.ruby"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-yaml":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(ya?ml)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.yaml"}},"patterns":[{"include":"#block-param"},{"include":"source.yaml"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"doctest":{"begin":"^(>>>)\\\\s*(.*)","beginCaptures":{"1":{"name":"keyword.control"},"2":{"patterns":[{"include":"source.python"}]}},"end":"^\\\\s*$"},"doctest-block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+doctest::)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"}},"patterns":[{"include":"#block-param"},{"include":"source.python"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-auto":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+auto(?:class|module|exception|function|decorator|data|method|attribute|property)::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control.py"},"3":{"patterns":[{"include":"source.python"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-cpp":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+c(?:pp|):(?:class|struct|function|member|var|type|enum|enum-struct|enum-class|enumerator|union|concept)::)\\\\s*(?:(@\\\\w+)|(.*))","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"entity.name.tag"},"4":{"patterns":[{"include":"source.cpp"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-js":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+js:\\\\w+::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"patterns":[{"include":"source.js"}]}},"end":"^(?!\\\\1[\\\\t ]|$)","patterns":[{"include":"#block-param"},{"include":"#body"}]},"domain-py":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+py:(?:module|function|data|exception|class|attribute|property|method|staticmethod|classmethod|decorator|decoratormethod)::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"patterns":[{"include":"source.python"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domains":{"patterns":[{"include":"#domain-cpp"},{"include":"#domain-py"},{"include":"#domain-auto"},{"include":"#domain-js"}]},"escaped":{"match":"\\\\\\\\.","name":"constant.character.escape"},"footnote":{"match":"^\\\\s*\\\\.{2}\\\\s+\\\\[(?:[-.\\\\w]+|[#*]|#\\\\w+)]\\\\s+","name":"entity.name.tag"},"footnote-ref":{"match":"\\\\[(?:[-.\\\\w]+|[#*])]_","name":"entity.name.tag"},"ignore":{"patterns":[{"match":"\'[*`]+\'"},{"match":"<[*`]+>"},{"match":"\\\\{[*`]+}"},{"match":"\\\\([*`]+\\\\)"},{"match":"\\\\[[*`]+]"},{"match":"\\"[*`]+\\""}]},"inline-markup":{"patterns":[{"include":"#escaped"},{"include":"#ignore"},{"include":"#ref"},{"include":"#literal"},{"include":"#monospaced"},{"include":"#citation"},{"include":"#bold"},{"include":"#italic"},{"include":"#list"},{"include":"#macro"},{"include":"#reference"},{"include":"#footnote-ref"}]},"italic":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)\\\\*[^*\\\\s]","end":"\\\\*|^\\\\s*$","name":"markup.italic"},"line-block":{"match":"^\\\\|\\\\s+","name":"keyword.control"},"list":{"match":"^\\\\s*(\\\\d+\\\\.|\\\\* -|[#A-Za-z]\\\\.|[CIMVXcimvx]+\\\\.|\\\\(\\\\d+\\\\)|\\\\d+\\\\)|[-*+])\\\\s+","name":"keyword.control"},"literal":{"captures":{"1":{"name":"keyword.control"},"2":{"name":"entity.name.tag"}},"match":"(:\\\\S+:)(`.*?`\\\\\\\\?)"},"literal-block":{"begin":"^(\\\\s*)(.*)(::)\\\\s*$","beginCaptures":{"2":{"patterns":[{"include":"#inline-markup"}]},"3":{"name":"keyword.control"}},"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"macro":{"match":"\\\\|[^|]+\\\\|","name":"entity.name.tag"},"monospaced":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)``[^`\\\\s]","end":"``|^\\\\s*$","name":"string.interpolated"},"options-list":{"match":"(?:(?:^|,\\\\s+)(?:[-+]\\\\w|--?[A-Za-z][-\\\\w]+|/\\\\w+)(?:[ =](?:\\\\w+|<[^<>]+?>))?)+(?= |\\\\t|$)","name":"variable.parameter"},"raw-html":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+raw\\\\s*::)\\\\s+(html)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"variable.parameter.html"}},"patterns":[{"include":"#block-param"},{"include":"text.html.derivative"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"ref":{"begin":"(:ref:)`","beginCaptures":{"1":{"name":"keyword.control"}},"end":"`|^\\\\s*$","name":"entity.name.tag","patterns":[{"match":"<.*?>","name":"markup.underline.link"}]},"reference":{"match":"[-\\\\w]*[-A-Za-z\\\\d]__?\\\\b","name":"entity.name.tag"},"replace-include":{"captures":{"1":{"name":"keyword.control"},"2":{"name":"entity.name.tag"},"3":{"name":"keyword.control"}},"match":"^\\\\s*(\\\\.{2})\\\\s+(\\\\|[^|]+\\\\|)\\\\s+(replace::)"},"simple-table":{"match":"^[=\\\\s]+$","name":"keyword.control.table"},"substitution":{"match":"^\\\\.{2}\\\\s*\\\\|([^|]+)\\\\|","name":"entity.name.tag"},"table":{"begin":"^\\\\s*\\\\+[-+=]+\\\\+\\\\s*$","beginCaptures":{"0":{"name":"keyword.control.table"}},"end":"^(?![+|])","patterns":[{"match":"[-+=|]","name":"keyword.control.table"}]},"title":{"match":"^(\\\\*{3,}|#{3,}|={3,}|~{3,}|\\\\+{3,}|-{3,}|`{3,}|\\\\^{3,}|:{3,}|\\"{3,}|_{3,}|\'{3,})$","name":"markup.heading"}},"scopeName":"source.rst","embeddedLangs":["html-derivative","cpp","python","javascript","shellscript","yaml","cmake","ruby"]}')),l=[...e,...t,...n,...r,...i,...a,...o,...s,c];export{l as default};
|
|
2
|
-
//# debugId=
|
|
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]=`1450ea4f-dee4-4580-9e9b-c7baa2e77ca0`,e._sentryDebugIdIdentifier=`sentry-dbid-1450ea4f-dee4-4580-9e9b-c7baa2e77ca0`)}catch{}})();import{t as e}from"./html-derivative-Di3X0LuZ.js";import t from"./cpp-DKT7ktbv.js";import n from"./python-_UfA4Rpn.js";import{t as r}from"./javascript-qRALF4mN.js";import{r as i}from"./MarkdownText-paPGy70d.js";import a from"./yaml-BOAQTz6b.js";import o from"./cmake-Cf85PuIk.js";import s from"./ruby-CLM38Wvm.js";var c=Object.freeze(JSON.parse('{"displayName":"reStructuredText","name":"rst","patterns":[{"include":"#body"}],"repository":{"anchor":{"match":"^\\\\.{2}\\\\s+(_[^:]+:)\\\\s*","name":"entity.name.tag.anchor"},"block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+\\\\S+::)(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"variable"}},"end":"^(?!\\\\1\\\\s|\\\\s*$)","patterns":[{"include":"#block-param"},{"include":"#body"}]},"block-comment":{"begin":"^(\\\\s*)\\\\.{2}(\\\\s+|$)","end":"^(?:(?=\\\\S)|\\\\s*$)","name":"comment.block","patterns":[{"begin":"^\\\\s{3,}(?=\\\\S)","name":"comment.block","while":"^(?:\\\\s{3}.*|\\\\s*$)"}]},"block-param":{"patterns":[{"captures":{"1":{"name":"keyword.control"},"2":{"name":"variable.parameter"}},"match":"(:param\\\\s+(.+?):)(?:\\\\s|$)"},{"captures":{"1":{"name":"keyword.control"},"2":{"patterns":[{"match":"\\\\b(0x[A-Fa-f\\\\d]+|\\\\d+)\\\\b","name":"constant.numeric"},{"include":"#inline-markup"}]}},"match":"(:.+?:)(?:$|\\\\s+(.*))"}]},"blocks":{"patterns":[{"include":"#domains"},{"include":"#doctest"},{"include":"#code-block-cpp"},{"include":"#code-block-py"},{"include":"#code-block-console"},{"include":"#code-block-javascript"},{"include":"#code-block-yaml"},{"include":"#code-block-cmake"},{"include":"#code-block-kconfig"},{"include":"#code-block-ruby"},{"include":"#code-block-dts"},{"include":"#code-block"},{"include":"#doctest-block"},{"include":"#raw-html"},{"include":"#block"},{"include":"#literal-block"},{"include":"#block-comment"}]},"body":{"patterns":[{"include":"#title"},{"include":"#inline-markup"},{"include":"#anchor"},{"include":"#line-block"},{"include":"#replace-include"},{"include":"#footnote"},{"include":"#substitution"},{"include":"#blocks"},{"include":"#table"},{"include":"#simple-table"},{"include":"#options-list"}]},"bold":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)\\\\*{2}[^*\\\\s]","end":"\\\\*{2}|^\\\\s*$","name":"markup.bold"},"citation":{"applyEndPatternLast":0,"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)`[^`\\\\s]","end":"`_{0,2}|^\\\\s*$","name":"entity.name.tag"},"code-block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)","beginCaptures":{"2":{"name":"keyword.control"}},"patterns":[{"include":"#block-param"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-cmake":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(cmake)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.cmake"}},"patterns":[{"include":"#block-param"},{"include":"source.cmake"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-console":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(console|shell|bash)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.console"}},"patterns":[{"include":"#block-param"},{"include":"source.shell"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-cpp":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(c|c\\\\+\\\\+|cpp|C|C\\\\+\\\\+|CPP|Cpp)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.cpp"}},"patterns":[{"include":"#block-param"},{"include":"source.cpp"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-dts":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(dts|DTS|devicetree)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.dts"}},"patterns":[{"include":"#block-param"},{"include":"source.dts"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-javascript":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(javascript)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.js"}},"patterns":[{"include":"#block-param"},{"include":"source.js"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-kconfig":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*([Kk]config)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.kconfig"}},"patterns":[{"include":"#block-param"},{"include":"source.kconfig"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-py":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(python)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.py"}},"patterns":[{"include":"#block-param"},{"include":"source.python"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-ruby":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(ruby)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.ruby"}},"patterns":[{"include":"#block-param"},{"include":"source.ruby"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-yaml":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(ya?ml)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.yaml"}},"patterns":[{"include":"#block-param"},{"include":"source.yaml"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"doctest":{"begin":"^(>>>)\\\\s*(.*)","beginCaptures":{"1":{"name":"keyword.control"},"2":{"patterns":[{"include":"source.python"}]}},"end":"^\\\\s*$"},"doctest-block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+doctest::)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"}},"patterns":[{"include":"#block-param"},{"include":"source.python"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-auto":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+auto(?:class|module|exception|function|decorator|data|method|attribute|property)::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control.py"},"3":{"patterns":[{"include":"source.python"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-cpp":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+c(?:pp|):(?:class|struct|function|member|var|type|enum|enum-struct|enum-class|enumerator|union|concept)::)\\\\s*(?:(@\\\\w+)|(.*))","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"entity.name.tag"},"4":{"patterns":[{"include":"source.cpp"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-js":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+js:\\\\w+::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"patterns":[{"include":"source.js"}]}},"end":"^(?!\\\\1[\\\\t ]|$)","patterns":[{"include":"#block-param"},{"include":"#body"}]},"domain-py":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+py:(?:module|function|data|exception|class|attribute|property|method|staticmethod|classmethod|decorator|decoratormethod)::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"patterns":[{"include":"source.python"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domains":{"patterns":[{"include":"#domain-cpp"},{"include":"#domain-py"},{"include":"#domain-auto"},{"include":"#domain-js"}]},"escaped":{"match":"\\\\\\\\.","name":"constant.character.escape"},"footnote":{"match":"^\\\\s*\\\\.{2}\\\\s+\\\\[(?:[-.\\\\w]+|[#*]|#\\\\w+)]\\\\s+","name":"entity.name.tag"},"footnote-ref":{"match":"\\\\[(?:[-.\\\\w]+|[#*])]_","name":"entity.name.tag"},"ignore":{"patterns":[{"match":"\'[*`]+\'"},{"match":"<[*`]+>"},{"match":"\\\\{[*`]+}"},{"match":"\\\\([*`]+\\\\)"},{"match":"\\\\[[*`]+]"},{"match":"\\"[*`]+\\""}]},"inline-markup":{"patterns":[{"include":"#escaped"},{"include":"#ignore"},{"include":"#ref"},{"include":"#literal"},{"include":"#monospaced"},{"include":"#citation"},{"include":"#bold"},{"include":"#italic"},{"include":"#list"},{"include":"#macro"},{"include":"#reference"},{"include":"#footnote-ref"}]},"italic":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)\\\\*[^*\\\\s]","end":"\\\\*|^\\\\s*$","name":"markup.italic"},"line-block":{"match":"^\\\\|\\\\s+","name":"keyword.control"},"list":{"match":"^\\\\s*(\\\\d+\\\\.|\\\\* -|[#A-Za-z]\\\\.|[CIMVXcimvx]+\\\\.|\\\\(\\\\d+\\\\)|\\\\d+\\\\)|[-*+])\\\\s+","name":"keyword.control"},"literal":{"captures":{"1":{"name":"keyword.control"},"2":{"name":"entity.name.tag"}},"match":"(:\\\\S+:)(`.*?`\\\\\\\\?)"},"literal-block":{"begin":"^(\\\\s*)(.*)(::)\\\\s*$","beginCaptures":{"2":{"patterns":[{"include":"#inline-markup"}]},"3":{"name":"keyword.control"}},"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"macro":{"match":"\\\\|[^|]+\\\\|","name":"entity.name.tag"},"monospaced":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)``[^`\\\\s]","end":"``|^\\\\s*$","name":"string.interpolated"},"options-list":{"match":"(?:(?:^|,\\\\s+)(?:[-+]\\\\w|--?[A-Za-z][-\\\\w]+|/\\\\w+)(?:[ =](?:\\\\w+|<[^<>]+?>))?)+(?= |\\\\t|$)","name":"variable.parameter"},"raw-html":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+raw\\\\s*::)\\\\s+(html)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"variable.parameter.html"}},"patterns":[{"include":"#block-param"},{"include":"text.html.derivative"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"ref":{"begin":"(:ref:)`","beginCaptures":{"1":{"name":"keyword.control"}},"end":"`|^\\\\s*$","name":"entity.name.tag","patterns":[{"match":"<.*?>","name":"markup.underline.link"}]},"reference":{"match":"[-\\\\w]*[-A-Za-z\\\\d]__?\\\\b","name":"entity.name.tag"},"replace-include":{"captures":{"1":{"name":"keyword.control"},"2":{"name":"entity.name.tag"},"3":{"name":"keyword.control"}},"match":"^\\\\s*(\\\\.{2})\\\\s+(\\\\|[^|]+\\\\|)\\\\s+(replace::)"},"simple-table":{"match":"^[=\\\\s]+$","name":"keyword.control.table"},"substitution":{"match":"^\\\\.{2}\\\\s*\\\\|([^|]+)\\\\|","name":"entity.name.tag"},"table":{"begin":"^\\\\s*\\\\+[-+=]+\\\\+\\\\s*$","beginCaptures":{"0":{"name":"keyword.control.table"}},"end":"^(?![+|])","patterns":[{"match":"[-+=|]","name":"keyword.control.table"}]},"title":{"match":"^(\\\\*{3,}|#{3,}|={3,}|~{3,}|\\\\+{3,}|-{3,}|`{3,}|\\\\^{3,}|:{3,}|\\"{3,}|_{3,}|\'{3,})$","name":"markup.heading"}},"scopeName":"source.rst","embeddedLangs":["html-derivative","cpp","python","javascript","shellscript","yaml","cmake","ruby"]}')),l=[...e,...t,...n,...r,...i,...a,...o,...s,c];export{l as default};
|
|
2
|
+
//# debugId=1450ea4f-dee4-4580-9e9b-c7baa2e77ca0
|