@evandu/super-pi 0.1.324 → 0.1.325
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/desktop/main.cjs +23 -3
- package/desktop/preload.cjs +7 -0
- package/dist/client/.super-pi-client-sources.json +35 -32
- package/dist/client/assets/CodeMirrorEditor-Dptza6ow.js +2 -0
- package/dist/client/assets/GitDiffEditor-BB3gQt45.js +31 -0
- package/dist/client/assets/GitHistoricalFile-DvMDll--.js +1 -0
- package/dist/client/assets/{dist-BXqtlD7O.js → dist-B-mG2iY2.js} +1 -1
- package/dist/client/assets/{dist-D978o95T.js → dist-BNv34mUE.js} +1 -1
- package/dist/client/assets/{dist-DTIPfQj7.js → dist-BXu_3prg.js} +1 -1
- package/dist/client/assets/dist-BbaUXjJ-.js +23 -0
- package/dist/client/assets/{dist-dybF9Ag8.js → dist-BdxRZGXx.js} +1 -1
- package/dist/client/assets/dist-BrRbrWQ9.js +2 -0
- package/dist/client/assets/dist-BvUXYJ8T.js +3 -0
- package/dist/client/assets/{dist-699T9mBC.js → dist-CFyI2sZh.js} +1 -1
- package/dist/client/assets/{dist-BqSTJyq9.js → dist-CKfkgouw.js} +1 -1
- package/dist/client/assets/{dist-CAlPBcem.js → dist-Cb33yP2e.js} +1 -1
- package/dist/client/assets/{dist-B2l9cUU9.js → dist-DGppcLCl.js} +1 -1
- package/dist/client/assets/{dist-DLNOWOmk.js → dist-DV1tNG-p.js} +1 -1
- package/dist/client/assets/{dist-S5ntGzJB.js → dist-DemGm2bb.js} +1 -1
- package/dist/client/assets/{dist-gDvn1xVj.js → dist-DtL03oMV.js} +1 -1
- package/dist/client/assets/{dist-X4BHLQqs.js → dist-DtR0Z34F.js} +1 -1
- package/dist/client/assets/{dist-BX5MJasK.js → dist-DtVj3pKW.js} +1 -1
- package/dist/client/assets/{dist-BXAOrsjq.js → dist-Dy5baLB7.js} +1 -1
- package/dist/client/assets/dist-OQbeuazo.js +1 -0
- package/dist/client/assets/{dist-Qjm1p8SR.js → dist-VqwcT4Z_.js} +1 -1
- package/dist/client/assets/{dist-CVPY8uK1.js → dist-erqcpmy2.js} +1 -1
- package/dist/client/assets/dist-hAqEmQDF.js +1 -0
- package/dist/client/assets/{dist-Dfhu-vbV.js → dist-roKXy-A5.js} +1 -1
- package/dist/client/assets/editor-blame-C7m05nPJ.js +15 -0
- package/dist/client/assets/editor-blame-PLncD0eu.css +1 -0
- package/dist/client/assets/index-CSO4Ah28.js +350 -0
- package/dist/client/assets/index-lnAcux4Q.css +1 -0
- package/dist/client/index.html +4 -3
- package/dist/server/git.d.ts +5 -0
- package/dist/server/git.js +21 -1
- package/dist/server/http-server.js +5 -3
- package/package.json +1 -1
- package/dist/.super-pi-check-inputs.json +0 -4
- package/dist/client/assets/CodeMirrorEditor-eVHUQY8Y.js +0 -2
- package/dist/client/assets/GitDiffEditor-Cebgkg-9.js +0 -31
- package/dist/client/assets/dist-BJHpSQV1.js +0 -1
- package/dist/client/assets/dist-BUY8ZNeZ.js +0 -23
- package/dist/client/assets/dist-Cus6_oaF.js +0 -2
- package/dist/client/assets/dist-DP4hrTBF.js +0 -3
- package/dist/client/assets/dist-Jg3fJuzH.js +0 -1
- package/dist/client/assets/index-A2acEU1u.css +0 -1
- package/dist/client/assets/index-D9r6d2wH.js +0 -363
- package/dist/client/assets/rolldown-runtime-XKyaHtl9.js +0 -1
package/dist/client/index.html
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
<link rel="alternate icon" href="/favicon.ico" />
|
|
9
9
|
<link rel="apple-touch-icon" href="/favicon.svg" />
|
|
10
10
|
<title>Super Pi</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-CSO4Ah28.js"></script>
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/editor-blame-C7m05nPJ.js">
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/editor-blame-PLncD0eu.css">
|
|
14
|
+
<link rel="stylesheet" crossorigin href="/assets/index-lnAcux4Q.css">
|
|
14
15
|
</head>
|
|
15
16
|
<body>
|
|
16
17
|
<div id="root"></div>
|
|
17
18
|
|
package/dist/server/git.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ export declare function gitLog(root: string, limit: number, cwd?: string, query?
|
|
|
29
29
|
}>;
|
|
30
30
|
export declare function gitGraph(root: string, limit: number, offset: number, snapshot: string, after: string, knownSnapshot?: string): Promise<GitGraphResponse>;
|
|
31
31
|
export declare function gitCommit(root: string, cwd: string, hash: string): Promise<GitCommitDetail>;
|
|
32
|
+
export declare function gitCommitFile(root: string, cwd: string, hash: string, path: string): Promise<{
|
|
33
|
+
path: string;
|
|
34
|
+
revision: string;
|
|
35
|
+
content: string;
|
|
36
|
+
}>;
|
|
32
37
|
export declare function gitCommitDiff(root: string, cwd: string, hash: string, path: string, fullContext?: boolean): Promise<{
|
|
33
38
|
path: string;
|
|
34
39
|
staged: boolean;
|
package/dist/server/git.js
CHANGED
|
@@ -246,11 +246,31 @@ async function commitSnapshot(root, cwd, revision) {
|
|
|
246
246
|
files.push({ status, path: firstPath });
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
return { detail: { hash, parents, message, files }, scope, diff };
|
|
249
|
+
return { detail: { hash, parents, message, files }, repo, scope, diff };
|
|
250
250
|
}
|
|
251
251
|
export async function gitCommit(root, cwd, hash) {
|
|
252
252
|
return (await commitSnapshot(root, cwd, hash)).detail;
|
|
253
253
|
}
|
|
254
|
+
export async function gitCommitFile(root, cwd, hash, path) {
|
|
255
|
+
const { detail, repo, scope } = await commitSnapshot(root, cwd, hash);
|
|
256
|
+
const file = detail.files.find(entry => entry.path === path);
|
|
257
|
+
if (!file)
|
|
258
|
+
throw gitFailure("这个提交没有该文件的改动。", "not_found");
|
|
259
|
+
const revision = file.status.startsWith("D") ? detail.parents[0] : detail.hash;
|
|
260
|
+
if (!revision)
|
|
261
|
+
throw gitFailure("找不到该文件版本。", "not_found");
|
|
262
|
+
const object = `${revision}:${[scope, path].filter(Boolean).join("/")}`;
|
|
263
|
+
const { stdout: metadata } = await git(repo, ["cat-file", "-t", object], { timeout: 12_000 });
|
|
264
|
+
if (metadata.trim() !== "blob")
|
|
265
|
+
throw gitFailure("此 Git 条目无法作为文件打开。", "not_found");
|
|
266
|
+
const { stdout: bytes } = await git(repo, ["cat-file", "-s", object], { timeout: 12_000 });
|
|
267
|
+
if (Number(bytes.trim()) > MAX_FILE_BYTES)
|
|
268
|
+
throw gitFailure("历史文件过大,无法在编辑器中打开。", "file_too_large");
|
|
269
|
+
const { stdout: content } = await git(repo, ["cat-file", "blob", object], { timeout: 12_000, maxBuffer: MAX_FILE_BYTES * 2 });
|
|
270
|
+
if (content.includes("\0"))
|
|
271
|
+
throw gitFailure("此历史版本为二进制文件,无法作为文本打开。", "binary");
|
|
272
|
+
return { path, revision, content };
|
|
273
|
+
}
|
|
254
274
|
export async function gitCommitDiff(root, cwd, hash, path, fullContext = false) {
|
|
255
275
|
if (!path || path.includes("\0"))
|
|
256
276
|
throw gitFailure("请选择提交中的变更文件。", "path");
|
|
@@ -20,7 +20,7 @@ import { describe as describeFilesError, FilesError, fileMeta, listDirectory, MA
|
|
|
20
20
|
import { findUploadFile, MAX_UPLOAD_BODY_BYTES, saveUpload } from "./upload.js";
|
|
21
21
|
import { describeThrown } from "./failure-text.js";
|
|
22
22
|
import { checkDiskVersion, readPackageVersion } from "./version.js";
|
|
23
|
-
import { gitBlame, gitBranches, gitCommit, gitCommitDiff, gitDiff, gitIndexFileContent, gitGraph, gitLog, gitMutate, gitStagedDraftInput, gitStashes, gitStatus, gitWorktrees, resolveGitWorktree, inspectGitWorktree, gitWorktreeCommittedDiff } from "./git.js";
|
|
23
|
+
import { gitBlame, gitBranches, gitCommit, gitCommitDiff, gitCommitFile, gitDiff, gitIndexFileContent, gitGraph, gitLog, gitMutate, gitStagedDraftInput, gitStashes, gitStatus, gitWorktrees, resolveGitWorktree, inspectGitWorktree, gitWorktreeCommittedDiff } from "./git.js";
|
|
24
24
|
import { computeFileDiff } from "./file-diff.js";
|
|
25
25
|
import { verifyCapability } from "./capability.js";
|
|
26
26
|
import { FileReviewThreads } from "./file-review-threads.js";
|
|
@@ -2103,7 +2103,7 @@ export function createHttpServer(options) {
|
|
|
2103
2103
|
}
|
|
2104
2104
|
const sessionRoot = await resolveFileCwd(workspace.path, requestedCwd);
|
|
2105
2105
|
const cwd = relative(resolve(workspace.path), sessionRoot).replaceAll("\\", "/");
|
|
2106
|
-
if (op === "commit-detail" || op === "commit-diff") {
|
|
2106
|
+
if (op === "commit-detail" || op === "commit-diff" || op === "commit-file") {
|
|
2107
2107
|
if (request.method !== "GET") {
|
|
2108
2108
|
json(405, { error: "查看提交需要 GET 请求", code: "method" });
|
|
2109
2109
|
return;
|
|
@@ -2116,8 +2116,10 @@ export function createHttpServer(options) {
|
|
|
2116
2116
|
const root = worktreeId ? (await resolveGitWorktree(workspace.path, worktreeId)).path : workspace.path;
|
|
2117
2117
|
const directory = worktreeId ? "" : cwd;
|
|
2118
2118
|
const hash = url.searchParams.get("hash") ?? "";
|
|
2119
|
+
const path = url.searchParams.get("path") ?? "";
|
|
2119
2120
|
json(200, op === "commit-detail" ? await gitCommit(root, directory, hash)
|
|
2120
|
-
: await
|
|
2121
|
+
: op === "commit-file" ? await gitCommitFile(root, directory, hash, path)
|
|
2122
|
+
: await gitCommitDiff(root, directory, hash, path, fullDiff));
|
|
2121
2123
|
return;
|
|
2122
2124
|
}
|
|
2123
2125
|
// Blame is a read with a GET shape: every other verb is refused HERE, before the POST branch
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D978o95T.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-DTIPfQj7.js","assets/dist-S5ntGzJB.js","assets/dist-Cus6_oaF.js","assets/dist-DP4hrTBF.js","assets/dist-Qjm1p8SR.js","assets/dist-BJHpSQV1.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{C as t,E as n,S as r,T as i,c as a,d as o,f as s,i as c,l,r as u,s as d,u as f,w as p}from"./index-D9r6d2wH.js";var m=e(n(),1);function ee(e,t,n,r){return[n.EditorView.decorations.compute([`selection`,`doc`],e=>n.Decoration.set(e.selection.ranges.filter(e=>!e.empty).map(e=>n.Decoration.mark({class:`cm-workbench-selectedText`}).range(e.from,e.to)),!0)),n.ViewPlugin.define(e=>{let n=null,i,a=!1,s=e=>{n&&(e===`expanded`?(a=!a,l()):n.querySelector(`input[name="${e===`caseSensitive`?`case`:e===`wholeWord`?`word`:`re`}"]`)?.click())},c=e=>{let t=f(e);t&&(e.preventDefault(),e.stopPropagation(),s(t))},l=()=>{if(!n||!i)return;let r=t.getSearchQuery(e.state);if(n.dataset.editorSearchExpanded=String(a),i.update({caseSensitive:r.caseSensitive,wholeWord:r.wholeWord,regexp:r.regexp,expanded:a}),n.querySelector(`[data-find-error]`)?.remove(),r.search&&!r.valid){let e=document.createElement(`output`);e.dataset.findError=``,e.setAttribute(`role`,`alert`),e.textContent=`正则表达式无效`,n.append(e)}},u=()=>{let u=r.querySelector(`.cm-panel.cm-search`);if(u===n)return;if(n?.removeEventListener(`keydown`,c,!0),i?.destroy(),n=u,!n){i=void 0;return}for(let[e,t,r]of[[`next`,`↓`,`下一处`],[`prev`,`↑`,`上一处`]]){let i=n.querySelector(`button[name="${e}"]`);i&&(i.textContent=t,i.setAttribute(`aria-label`,r),i.title=r)}let d=document.createElement(`span`);d.dataset.findControls=``,n.prepend(d);let f=t.getSearchQuery(e.state);a=!1,i=o(d,{...f,expanded:a},s),n.addEventListener(`keydown`,c,!0),l()},d=new MutationObserver(u);return d.observe(r,{childList:!0,subtree:!0}),u(),{update(){l()},destroy(){d.disconnect(),n?.removeEventListener(`keydown`,c,!0),i?.destroy()}}}),e.Prec.highest(n.keymap.of([{key:`Mod-Shift-l`,run:t.selectSelectionMatches},{key:`Mod-h`,scope:`editor search-panel`,run:e=>(t.searchPanelOpen(e.state)||t.openSearchPanel(e),requestAnimationFrame(()=>{e.dom.isConnected&&r.querySelector(`[data-editor-search-options][aria-expanded="false"]`)?.click()}),!0)},...[`c`,`w`,`r`].map(e=>({key:`Alt-${e}`,run:n=>{t.searchPanelOpen(n.state)||t.openSearchPanel(n);let r=t.getSearchQuery(n.state);return n.dispatch({effects:t.setSearchQuery.of(new t.SearchQuery({...r,...e===`c`?{caseSensitive:!r.caseSensitive}:e===`w`?{wholeWord:!r.wholeWord}:{regexp:!r.regexp}}))}),!0}}))])),n.panels({topContainer:r}),n.EditorView.scrollMargins.of(()=>({top:r.querySelector(`.cm-search`)?Math.min(r.getBoundingClientRect().height+8,Math.max(0,(r.parentElement?.clientHeight??0)-32)):0})),t.highlightSelectionMatches({wholeWords:!0,minSelectionLength:1,maxMatches:1e3}),t.search({top:!0}),e.EditorState.phrases.of({Find:`查找`,Replace:`替换为`,next:`下一处`,previous:`上一处`,all:`全部选中`,"match case":`区分大小写`,regexp:`正则表达式`,"by word":`全词匹配`,replace:`替换`,"replace all":`全部替换`,close:`关闭查找`,"current match":`当前匹配`,"on line":`所在行`})]}function te(e,t,n,r,i){let o=new e.Compartment,s=()=>{let r=d();return[e.EditorState.tabSize.of(r.tabSize),n.indentUnit.of(r.indent===`tabs`?` `:` `.repeat(r.tabSize)),r.wrap?t.EditorView.lineWrapping:[],r.whitespace?[t.highlightWhitespace(),t.highlightTrailingWhitespace()]:[]]};return[e.EditorState.allowMultipleSelections.of(!0),t.rectangularSelection(),t.crosshairCursor({key:`Alt`}),e.EditorState.phrases.of({"folded code":`已折叠代码`,unfold:`展开代码`,"Fold line":`折叠代码`,"Unfold line":`展开代码`}),t.highlightActiveLineGutter(),t.highlightSpecialChars(),t.dropCursor(),n.bracketMatching(),n.indentOnInput(),n.foldGutter(),r.closeBrackets(),e.Prec.highest(t.keymap.of([...r.closeBracketsKeymap,...n.foldKeymap,{key:`Alt-z`,run:()=>(a({wrap:!d().wrap}),!0)},{key:`Mod-Shift-z`,run:i.redo},{key:`Mod-y`,run:i.redo}])),o.of(s()),t.ViewPlugin.define(e=>({destroy:l(()=>{e.dispatch({effects:o.reconfigure(s())})})}))]}var h=new Map;function ne(e){let t=h.get(e);return t&&(h.delete(e),h.set(e,t)),t}function g(e,t){h.delete(e),h.set(e,t);let n=[...h.values()].reduce((e,t)=>e+t.state.doc.length,0);for(;h.size>32||n>16777216;){let e=h.keys().next().value;n-=h.get(e).state.doc.length,h.delete(e)}}var _=i(),re=262144,v=131072;function ie(e){return e.split(`.`).pop()?.toLowerCase()??``}function y(e,t,n=!1){let r=e=>n?`var(--git-diff-${e.slice(5)}, var(${e}))`:`var(${e})`;return e.HighlightStyle.define([{tag:t.tags.keyword,color:r(`--cm-keyword`)},{tag:t.tags.string,color:r(`--cm-string`)},{tag:t.tags.number,color:r(`--cm-number`)},{tag:t.tags.comment,color:r(`--cm-comment`),fontStyle:`italic`},{tag:t.tags.function(t.tags.variableName),color:r(`--cm-function`)},{tag:t.tags.typeName,color:r(`--cm-type`)},{tag:t.tags.className,color:r(`--cm-type`)},{tag:t.tags.propertyName,color:r(`--cm-property`)},{tag:t.tags.operator,color:r(`--cm-operator`)},{tag:t.tags.variableName,color:r(`--cm-variable`)}])}function b({path:e,value:n,onChange:i,jumpToLine:a,onSave:o,workspaceId:l,cwd:d=``,blame:f,onPosition:h,onView:b,readOnly:x=!1,languageOverride:S,onReviewLine:C}){let w=(0,m.useRef)(null),T=(0,m.useRef)(null),E=(0,m.useRef)(null),ae=(0,m.useRef)(null),D=JSON.stringify([l,d,e]),O=(0,m.useRef)(void 0),k=(0,m.useRef)(null),A=(0,m.useRef)(null),oe=(0,m.useRef)(null),j=(0,m.useRef)(null),M=(0,m.useRef)(null),N=(0,m.useRef)(null),P=(0,m.useRef)(i),F=(0,m.useRef)(o),I=(0,m.useRef)(n);I.current=n;let L=(0,m.useRef)(!1),R=(0,m.useRef)(b);R.current=b;let z=(0,m.useRef)(C);z.current=C;let B=!!C;P.current=i,F.current=o;let[V,se]=(0,m.useState)(!1),[H,U]=(0,m.useState)(!1),[W,ce]=(0,m.useState)(`0,0`),[G,le]=(0,m.useState)(0),[K,ue]=(0,m.useState)(1);(0,m.useEffect)(()=>{let r=!1,i,a,o,l,u;return(async()=>{try{let d=S??ie(e),f=t(d),[m,h,g,_,v,b,C,V,H]=await Promise.all([p(()=>import(`./dist-D978o95T.js`).then(e=>e.S),__vite__mapDeps([0,1])),p(()=>import(`./dist-DTIPfQj7.js`).then(e=>e.s),__vite__mapDeps([2,1,0])),p(()=>import(`./dist-S5ntGzJB.js`),__vite__mapDeps([3,0,1,2,4,5])),p(()=>import(`./dist-Qjm1p8SR.js`),__vite__mapDeps([6,0,1,2])),p(()=>import(`./dist-DP4hrTBF.js`).then(e=>e.d),__vite__mapDeps([5,1,0,2,4])),p(()=>import(`./dist-Cus6_oaF.js`).then(e=>e.n),__vite__mapDeps([4,1])),f?f().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${d}:`,e),null)):Promise.resolve(null),c().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null)),p(()=>import(`./dist-BJHpSQV1.js`).then(e=>e.r),__vite__mapDeps([7,1,0,2,5,4]))]);if(r||!w.current||!T.current)return;ae.current=h.EditorView,l=v,u=b,A.current=m.Annotation.define(),oe.current=m.Transaction.addToHistory;let W=n.length<=re&&C!==null;a=new m.Compartment;let G=[h.lineNumbers(),h.highlightActiveLine(),h.drawSelection(),g.history(),h.keymap.of([g.indentWithTab,...g.defaultKeymap,...g.historyKeymap,..._.searchKeymap,{key:`Mod-s`,run:()=>(F.current(),!0)}]),h.EditorView.updateListener.of(e=>{e.docChanged&&!(A.current&&e.transactions.some(e=>e.annotation(A.current)===!0))&&P.current(e.state.doc.toString()),e.selectionSet&&ce(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),h.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(B&&G.push(s(h,e=>z.current?.(e),`file`)),G.push(h.EditorView.updateListener.of(e=>{e.selectionSet&&ue(e.state.selection.ranges.length),e.docChanged?L.current=!1:e.selectionSet&&(L.current=e.transactions.some(e=>e.isUserEvent(`select.search`)||e.isUserEvent(`select.pointer`)))}),ee(m,_,h,T.current),te(m,h,v,H,g)),x&&G.push(m.EditorState.readOnly.of(!0),h.EditorView.editable.of(!1),h.EditorView.contentAttributes.of({tabindex:`0`})),V&&!x&&(o=new m.Compartment,G.splice(1,0,o.of([])),G.push(V.base)),C)try{G.push(C)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),W=!1}if(W&&a&&l&&u)try{G.push(a.of(l.syntaxHighlighting(y(l,u))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),W=!1}let K=ne(D),q=K&&K.state.doc.toString()===I.current,J=q?K.state.update({effects:m.StateEffect.reconfigure.of(G)}).state:m.EditorState.create({doc:I.current,extensions:G});if(i=new h.EditorView({state:J,parent:w.current}),O.current=q?K.jump:void 0,ue(i.state.selection.ranges.length),ce(`${i.state.selection.main.from},${i.state.selection.main.to}`),q&&(i.scrollDOM.scrollTop=K.top,i.scrollDOM.scrollLeft=K.left,O.current=K.jump),r){i.destroy();return}E.current=i,R.current?.(i),se(W),U(!0),j.current=V,M.current=o??null,N.current=null,le(e=>e+1);let Y=new MutationObserver(()=>{let e=E.current;if(e&&W&&a&&l&&u)try{e.dispatch({effects:a.reconfigure(l.syntaxHighlighting(y(l,u)))})}catch{}});k.current=Y,Y.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),r||U(!0)}})(),()=>{r=!0,k.current?.disconnect(),k.current=null,i&&g(D,{state:i.state,top:i.scrollDOM.scrollTop,left:i.scrollDOM.scrollLeft,jump:O.current}),i?.destroy(),E.current=null,R.current?.(),U(!1),w.current&&(w.current.textContent=``)}},[D,x,S,B]),(0,m.useEffect)(()=>{let e=E.current;if(!e)return;let t=e.state.doc.toString();t!==n&&e.dispatch({changes:{from:0,to:t.length,insert:n},annotations:A.current?A.current.of(!0):void 0})},[n,H]),(0,m.useEffect)(()=>{let e=E.current;if(!e||!a||O.current===a.request)return;O.current=a.request;let t=e.state.doc.line(Math.min(Math.max(1,a.line),e.state.doc.lines)),n=Math.min(t.to,t.from+(a.column??1)-1);e.dispatch({selection:{anchor:t.to,head:n},effects:ae.current?.scrollIntoView(n,{y:`start`,yMargin:Math.round(e.scrollDOM.clientHeight/3)})}),e.focus()},[a,H]);let q=!!(f&&f.state===`ready`&&f.response&&f.path===e&&f.workspaceId===l);(0,m.useEffect)(()=>{let t=E.current,n=j.current,r=M.current;if(!t||!n||!r)return;let i=f&&f.state===`ready`&&f.response&&f.path===e&&f.workspaceId===l?f.response:null,a=i?u(i):null;N.current!==a&&(N.current=a,t.dispatch({effects:[n.setBlame.of(a),r.reconfigure(a?n.gutter:[])]}))},[f?.state,f?.response,f?.path,f?.workspaceId,e,l,G]);let J=E.current?.state.doc.toString()??n,Y=J.length<=v?J:J.slice(0,v),X=S??ie(e),Z=r(X),de=E.current?.state,Q=de?.selection.main.head,$=Q===void 0?void 0:de?.doc.lineAt(Q),fe=$?.number,pe=Q!==void 0&&$?Q-$.from+1:void 0;return(0,m.useEffect)(()=>{let e=E.current;if(H&&e&&(!a||O.current===a.request)){let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);h?.({line:n.number,column:t-n.from+1,language:V&&Z||`纯文本`,highlight:V?X:`plain`,navigation:L.current,selections:e.state.selection.ranges.length})}},[H,fe,pe,V,Z,X,h,K,a?.request]),(0,m.useEffect)(()=>()=>h?.(),[h]),(0,_.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":Y,"data-file-content-truncated":J.length>v?`1`:`0`,"data-file-selection":W,"data-editor-selection-count":K,"data-file-editor-ready":H?`1`:`0`,"data-file-blame-gutter":q?`1`:void 0,onMouseDown:e=>{e.target.closest(`.cm-panels`)||E.current?.focus()},children:[(0,_.jsx)(`div`,{className:`file-cm`,ref:w,"aria-label":`${x?`查看`:`编辑`} ${e}`}),(0,_.jsx)(`div`,{className:`workbench-editor-search`,ref:T,"data-editor-find-host":`file`}),(!H||!h)&&(0,_.jsxs)(`div`,{className:`file-editor-status`,children:[!H&&(0,_.jsx)(`span`,{"data-file-editor-loading":`1`,children:`正在加载编辑器…`}),H&&Q!==void 0&&$&&(0,_.jsxs)(`span`,{children:[`第 `,$.number,` 行,第 `,Q-$.from+1,` 列`]}),H&&!V&&(0,_.jsx)(`span`,{"data-file-highlight-status":`plain`,children:`纯文本`}),H&&V&&Z&&(0,_.jsx)(`span`,{"data-file-highlight-status":X,children:Z})]})]})}export{b as CodeMirrorEditor,ee as n,te as t,y as themeHighlightStyle};
|