@evandu/super-pi 0.1.207 → 0.1.209
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/agents/project-leader.md +5 -3
- package/agents/super-pi-task/core.ts +1 -1
- package/dist/client/.super-pi-client-sources.json +7 -7
- package/dist/client/assets/{CodeMirrorEditor-KQDBvdAI.js → CodeMirrorEditor-D0DLvjrs.js} +2 -2
- package/dist/client/assets/{dist-KL5ywpxl.js → dist-B0m_IAGL.js} +1 -1
- package/dist/client/assets/{dist-B015qWBZ.js → dist-B5tfuaLb.js} +1 -1
- package/dist/client/assets/{dist-J3S-elPb.js → dist-B7RsNXnt.js} +1 -1
- package/dist/client/assets/{dist-DWD02ase.js → dist-BOXmH3i1.js} +1 -1
- package/dist/client/assets/{dist-xcgc6bsN.js → dist-BVVnv5AJ.js} +1 -1
- package/dist/client/assets/{dist-EZxvaEWE.js → dist-BWVLHjVR.js} +1 -1
- package/dist/client/assets/{dist-Bim285Uv.js → dist-BkjACtBI.js} +1 -1
- package/dist/client/assets/{dist-3nL837Fs.js → dist-BpxB4Bv8.js} +1 -1
- package/dist/client/assets/{dist-BN2UnOQ2.js → dist-C8QTA4LG.js} +1 -1
- package/dist/client/assets/{dist-DNFTA8eK.js → dist-CUUPt1_7.js} +1 -1
- package/dist/client/assets/{dist-DYys59TX.js → dist-D6ddLLmt.js} +1 -1
- package/dist/client/assets/{dist-CA6dRqYD.js → dist-D8m7BNyE.js} +1 -1
- package/dist/client/assets/{dist-Ce0_mKRX.js → dist-DAWXHOWp.js} +1 -1
- package/dist/client/assets/{dist-DpFdyk4c.js → dist-DGrM2Tzj.js} +1 -1
- package/dist/client/assets/{dist-3UazBQPy.js → dist-DKsFQEo0.js} +1 -1
- package/dist/client/assets/{dist-B-wznWiJ.js → dist-DknCNZc2.js} +1 -1
- package/dist/client/assets/{dist-50OrOetK.js → dist-DlAxGaOJ.js} +1 -1
- package/dist/client/assets/{dist-CWwcn5gh.js → dist-DnzyresE.js} +1 -1
- package/dist/client/assets/{dist-DNjtMha0.js → dist-Dqu0sUt9.js} +1 -1
- package/dist/client/assets/{dist-B2DwIkxS.js → dist-DrI3iWqO.js} +1 -1
- package/dist/client/assets/{dist-Bz8mBVYg.js → dist-KiGuiwPf.js} +1 -1
- package/dist/client/assets/{dist-1vBvKRAO.js → dist-vaeFQOVz.js} +1 -1
- package/dist/client/assets/{index-DcuTYCZ-.css → index-1gs_N5Ez.css} +1 -1
- package/dist/client/assets/{index-Bmx2_cFl.js → index-AoOQKqJN.js} +29 -29
- package/dist/client/index.html +2 -2
- package/dist/server/application/project-service.d.ts +5 -3
- package/dist/server/application/project-service.js +54 -25
- package/dist/server/team-context.d.ts +2 -2
- package/dist/server/team-context.js +2 -1
- package/dist/server/types.d.ts +4 -0
- package/dist/shared/project-overview.d.ts +50 -0
- package/dist/shared/project-overview.js +24 -0
- package/dist/shared/project-presentation.d.ts +52 -0
- package/dist/shared/project-presentation.js +103 -0
- package/dist/shared/team-context-view.d.ts +33 -0
- package/dist/shared/team-context-view.js +49 -0
- package/dist/shared/team-context.d.ts +7 -0
- package/package.json +5 -1
package/agents/project-leader.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: 项目负责人
|
|
3
3
|
mode: primary
|
|
4
|
-
description:
|
|
4
|
+
description: 协调敏捷开发中的实现与交付,适合项目根 Leader 或分支 Leader;按可交付改动分工,复用已有发现,轻量项目可亲自执行。
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
你是负责协调实现与交付的编程助手。目标是敏捷开发、快速迭代:先交付可用的小改动,再根据反馈推进。按可交付改动分工,不按公司岗位搭组织;只在独立工作确实能同时推进时创建多个会话。小而可逆的任务优先现有轻量模式,不要求用户配置角色、阅读关系图或走管理流程。需要独立核验的交付使用标准模式,已选择标准模式时保留独立验收。记录必要的决定、证据和下一步,让用户能迅速判断成果。
|
|
8
|
+
|
|
9
|
+
用户是顶层决策者,不是日常调度员。你自己吸收子会话的汇报和普通技术决策,排查阻塞、处理返工并安排后续工作;不要逐条转发或让用户替你管理协作。对用户汇总进展和交付,只有必须由用户提供的目标取舍、授权范围或外部资源才带着已排查的事实与建议上收。内部记录保留可追溯性,不代表用户必须阅读。
|
|
8
10
|
|
|
9
11
|
协调时先处理自己层级能解决的问题,不把下属原话逐条转给 Boss。标准项目安排其他会话独立复核自己的整合产物,自己重读一遍不算独立复核。项目外可以整理方案与交接材料,只有收到项目身份和任务后才按下面的流程操作。
|
|
10
12
|
|
|
@@ -18,7 +20,7 @@ description: 项目负责人兼秘书,适合项目根 Leader 或分支 Leader
|
|
|
18
20
|
执行或聚合交付必须调用 `project(action="submit", projectId, taskId, output, evidenceRefs)`,不能自行宣布完成;退回后按 `review.summary` 修正再 `submit`。
|
|
19
21
|
轻量项目只登记执行任务,经 `dispatch` 后亲自执行并 `submit`,不拆子任务、不调用 `request_review`,明确交付为自评。
|
|
20
22
|
用 `resolve_escalation` 处理收件人为自己的直属升级并记录决定;Boss 级事项不能自行关闭。
|
|
21
|
-
遇到阻塞用 `project(action="report", kind="blocked", ...)`
|
|
23
|
+
遇到阻塞用 `project(action="report", kind="blocked", ...)` 上报:分支报直接上级;根负责人先自行排查处理,普通阻塞不变成用户待办。
|
|
22
24
|
需要更高层决策时用 `escalate`,分支收件人自动是直接上级;只有根负责人判断需要 Boss 决策时才向 Boss 升级。
|
|
23
25
|
不要用 `question` 直接问 Boss;分支让上级逐级代问,根负责人用升级记录需要 Boss 决定的问题。
|
|
24
26
|
按项目分工与汇报线委派任务,不要用 `session_spawn` / `session_dispatch` / `task` / `workflow` 绕开项目职责与汇报线;派发后等待子会话自动回传,不要轮询。
|
|
@@ -1156,7 +1156,7 @@ export async function executeProject(params: Record<string, unknown>, config: Re
|
|
|
1156
1156
|
} catch (error) { return result(`Project request failed: ${error instanceof Error ? error.message : "unknown error"}`, true); }
|
|
1157
1157
|
}
|
|
1158
1158
|
|
|
1159
|
-
export const TEAM_COORDINATION_DESCRIPTION = `Team context is delivered automatically at dispatch and refreshed before each new turn. Reuse published findings and the supervisor's file navigation index, then verify the code relevant to your task; do not repeat broad discovery without a stated gap. Publish concise findings with evidence through sharedContext on create/add_task/dispatch/submit/report/message, or action="share_context". sharedContext is an array of {title,content,kind?:finding|decision|pitfall|hypothesis,evidenceRefs?,taskIds?,paths?,id?,expectedRevision?,status?:active|withdrawn}. Hypotheses are not facts. Updating or withdrawing an existing entry requires id and expectedRevision; retain the source and cite changed evidence. action="get_context" returns the current scoped snapshot (projectId may be omitted to use your own project); contextIds reads exact entries, including withdrawn ones for audit. Publish discoveries before dispatch in the SAME call, not after starting workers. handoffNote gives task-specific implementation guidance; ownedPaths declares workspace-relative files/directories you will write (no globs); readOnly=true is for research/review work. Unknown scopes do not reserve the entire workspace. Overlapping declared paths of active writers are refused with the responsible task; choose disjoint paths or dependencies. This is scheduling coordination, not an OS file lock. dispatch accepts taskIds to start several independent tasks asynchronously in one call; started and failed are separate and partial failure is not success. Own distinct modules, preserve others' changes, return output and evidence, publish reusable findings, and report blockers to your direct supervisor. Use action="message" with taskId, content and deliveryMode=queue|steer to give your DIRECT task's existing worker/reviewer follow-up instructions with the latest snapshot. targetConversationId may select that task's reviewer; it never targets another task. steer takes effect at a tool boundary without restarting or killing tools. Publish important new findings with sharedContext in the same message call. Follow up with the existing task session for rework instead of spawning duplicate workers. Small projects can use lightweight mode.`;
|
|
1159
|
+
export const TEAM_COORDINATION_DESCRIPTION = `Team context is delivered automatically at dispatch and refreshed before each new turn. Reuse published findings and the supervisor's file navigation index, then verify the code relevant to your task; do not repeat broad discovery without a stated gap. Publish concise findings with evidence through sharedContext on create/add_task/dispatch/submit/report/message, or action="share_context". sharedContext is an array of {title,content,kind?:finding|decision|pitfall|hypothesis,evidenceRefs?,taskIds?,paths?,id?,expectedRevision?,status?:active|withdrawn}. Hypotheses are not facts. Updating or withdrawing an existing entry requires id and expectedRevision; retain the source and cite changed evidence. action="get_context" returns the current scoped snapshot (projectId may be omitted to use your own project); contextIds reads exact entries, including withdrawn ones for audit. Publish discoveries before dispatch in the SAME call, not after starting workers. handoffNote gives task-specific implementation guidance; ownedPaths declares workspace-relative files/directories you will write (no globs); readOnly=true is for research/review work. Unknown scopes do not reserve the entire workspace. Overlapping declared paths of active writers are refused with the responsible task; choose disjoint paths or dependencies. This is scheduling coordination, not an OS file lock. dispatch accepts taskIds to start several independent tasks asynchronously in one call; started and failed are separate and partial failure is not success. Own distinct modules, preserve others' changes, return output and evidence, publish reusable findings, and report blockers to your direct supervisor. Use action="message" with taskId, content and deliveryMode=queue|steer to give your DIRECT task's existing worker/reviewer follow-up instructions with the latest snapshot. targetConversationId may select that task's reviewer; it never targets another task. steer takes effect at a tool boundary without restarting or killing tools. Publish important new findings with sharedContext in the same message call. Follow up with the existing task session for rework instead of spawning duplicate workers. Handle routine blocks, interrupted work, review assignment and rework yourself using the coordination hints in each scoped get_context snapshot; they suggest existing actions, not extra required steps. Only escalate a decision that truly requires the user. Present owner summaries, deliverables and necessary decisions to the user, not internal management records. Small projects can use lightweight mode.`;
|
|
1160
1160
|
|
|
1161
1161
|
/** Snapshot I/O runs at turn start, outside the process-global extension environment lock. */
|
|
1162
1162
|
export async function loadTeamContext(config: ReturnType<typeof readProjectConfig>, signal?: AbortSignal): Promise<string> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"hash": "
|
|
2
|
+
"hash": "d5fe8ee80e7e16787a21b6da4e8b206572b5774bd24bfd3a78fab18ce580826f",
|
|
3
3
|
"files": {
|
|
4
|
-
"src/client/App.tsx": "
|
|
4
|
+
"src/client/App.tsx": "cef2fb0e279704480d47ea2d54b43cbc88b634fcf5be80438e2cc65e20f50bd2",
|
|
5
5
|
"src/client/CodeMirrorEditor.tsx": "b6b6479effa1482eda710f04a26f3af843515526e129ca5bc70692cca9074b09",
|
|
6
6
|
"src/client/ErrorBoundary.tsx": "d16376f9f6c7cc1fab8590c65a66438127642f7d6bb8023cec53d8a6cc9f3964",
|
|
7
7
|
"src/client/FeishuPanel.tsx": "52f116eba265bfde683338f5893107ad5559fd2f7d4a9e0df935507a46862a3b",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"src/client/HelpWindow.tsx": "a52005240894911eb8a35efab78aa6ddcda9fef6dca976aafc4255a4f635ca76",
|
|
11
11
|
"src/client/KnowledgeFilePicker.tsx": "8f7eb7e9f70265aed09cc0892b091827976757d8f2a2d736d6ca170fcdd871e7",
|
|
12
12
|
"src/client/KnowledgePanel.tsx": "4f7230cfe610cd86d63aa143c82f6195b3c4208ef0bea703f92104ef27237704",
|
|
13
|
-
"src/client/MarkdownView.tsx": "
|
|
13
|
+
"src/client/MarkdownView.tsx": "e1e26c599b024f8908cad24cc85c640c9bc82ae10cd2060d5e795588b907ee7d",
|
|
14
14
|
"src/client/MemoryPanel.tsx": "59a74f5789f43708245b6f62ba3b873ad91804f64c1e352403d5b7dffd478fdc",
|
|
15
15
|
"src/client/MessageMedia.tsx": "fdcd7e06cdaabfbf29ed38a45280b6f0a68bcec1b6af1cfc5415e2ad9b28ded2",
|
|
16
|
-
"src/client/ProjectControlPanel.tsx": "
|
|
17
|
-
"src/client/ProjectExecutionTools.tsx": "56e2868633bfb50d1921b4813b7428ddfa19098d0b8e17a9ed9c61e3b33b0b39",
|
|
16
|
+
"src/client/ProjectControlPanel.tsx": "0f6f2687f8a6928a2530262fe163583b048e0e5c9e005001db6b625f497cf31a",
|
|
18
17
|
"src/client/ScheduledTasksPanel.tsx": "74f8bea76cbe540b4eb22163ba28ed56920643de5948d1c5c8c37604f52368c3",
|
|
19
18
|
"src/client/SlashCommandMenu.tsx": "69cd0a9d5e35f41f703e91a845e5bd750c952d2957be03b5528e156e60bf6ecb",
|
|
20
19
|
"src/client/Tabs.tsx": "87b2154b614b6593b3fd75577f6e8356a32d80506165c301eb99db3cec520abe",
|
|
20
|
+
"src/client/TeamHandoffCard.tsx": "925284ab81c7845c5cfdcfa1f631e124bb02d7d86b03ede8f3fbabc194c32dca",
|
|
21
21
|
"src/client/TerminalPanel.tsx": "89db360a96c47e4afa7d84bbeada7ab765794a6a28b8c1260f15a71fbf948201",
|
|
22
22
|
"src/client/WorkflowCard.tsx": "8ce5458537a3b02dcbb9bbb4c7afacb07e0f41857ed250aa4cde0cbc8d4bde6c",
|
|
23
23
|
"src/client/editor-blame.ts": "d03669f945aca09ff77d100ef0d4f0129af4f8ccef81963c3ce00f8f6fb034c2",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"src/client/project-evidence.ts": "3bc5ea85f6b20a19a36cfdd4a958d83dd53b21f3d8f20fae1914a575dfbad3c4",
|
|
32
32
|
"src/client/session-tree.ts": "08a14c6611fdd9a72001eb1672060479e7660de5a5d221c7e80036209fd26546",
|
|
33
33
|
"src/client/slash-commands.ts": "b792018fb67bd9e6f777397b0720b8b3aa565a4d8f7a76f94fec097ddf749480",
|
|
34
|
-
"src/client/styles.css": "
|
|
34
|
+
"src/client/styles.css": "10a9d1e02a99b7406e8be7ad1d4b5041e6499e6b8db084d938cfdf72628dc43d",
|
|
35
35
|
"src/client/terminal-emulator.ts": "ffcc4f5fbddaf25cebcc9e03dbe5d7d0ad2c21586f5d169e57c04c82e2308b3b",
|
|
36
36
|
"src/client/theme.tsx": "df10e163ee61c2cc96c8f63da2dfd314b5db33adb0377d66a422143bb2cb9ab5",
|
|
37
37
|
"src/client/tool-launcher.ts": "40fb4974362bbc8c73ecd651da1abce251fc28857564a9321037adcfdb0bfe24",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"src/client/types.ts": "0d32fd568f188507ce2b48266f44fa20da1bcf436090893b1ff0c164ed0f3132",
|
|
42
42
|
"src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5"
|
|
43
43
|
},
|
|
44
|
-
"recordedAt": "2026-11-
|
|
44
|
+
"recordedAt": "2026-11-13T11:28:37.841Z"
|
|
45
45
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-
|
|
2
|
-
import{a as e,i as t,n,r,s as i,t as a}from"./index-Bmx2_cFl.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-1vBvKRAO.js`),__vite__mapDeps([0,1,2,3,4,5])),e()]),a=i[t]??i.default??i;return n.define(a)}var c={cpp:()=>r(()=>import(`./dist-CA6dRqYD.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-CA6dRqYD.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-CA6dRqYD.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-CA6dRqYD.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-CA6dRqYD.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-CA6dRqYD.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-CA6dRqYD.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-CA6dRqYD.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-CA6dRqYD.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-CA6dRqYD.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-KL5ywpxl.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-KL5ywpxl.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mjs:()=>r(()=>import(`./dist-KL5ywpxl.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-KL5ywpxl.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-KL5ywpxl.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),tsx:()=>r(()=>import(`./dist-KL5ywpxl.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mts:()=>r(()=>import(`./dist-KL5ywpxl.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cts:()=>r(()=>import(`./dist-KL5ywpxl.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),py:()=>r(()=>import(`./dist-DNFTA8eK.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-DNFTA8eK.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-B2DwIkxS.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-DNjtMha0.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-3UazBQPy.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-DYys59TX.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-DYys59TX.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-B-wznWiJ.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-BN2UnOQ2.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-BN2UnOQ2.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-BN2UnOQ2.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-CWwcn5gh.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-CWwcn5gh.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-CWwcn5gh.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-CWwcn5gh.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-Bz8mBVYg.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-Bim285Uv.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-Bim285Uv.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-Bim285Uv.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-DWD02ase.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-J3S-elPb.js`).then(e=>e.go()),__vite__mapDeps([21,5,2,3,0,1,4,7,9])),sh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>s(()=>r(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>s(()=>r(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>s(()=>r(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>s(()=>r(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`)},l={cpp:`C++`,cc:`C++`,cxx:`C++`,hpp:`C++`,hh:`C++`,hxx:`C++`,cu:`CUDA C++`,cuh:`CUDA C++`,c:`C`,h:`C/C++ Header`,js:`JavaScript`,jsx:`JSX`,mjs:`JavaScript`,cjs:`JavaScript`,ts:`TypeScript`,tsx:`TSX`,mts:`TypeScript`,cts:`TypeScript`,py:`Python`,pyi:`Python Stub`,java:`Java`,php:`PHP`,sql:`SQL`,yaml:`YAML`,yml:`YAML`,xml:`XML`,json:`JSON`,jsonc:`JSON with Comments`,json5:`JSON5`,css:`CSS`,md:`Markdown`,markdown:`Markdown`,mdx:`MDX`,rs:`Rust`,go:`Go`,html:`HTML`,htm:`HTML`,vue:`Vue`,svelte:`Svelte`,sh:`Shell`,bash:`Bash`,zsh:`Zsh`,fish:`Fish`,ps1:`PowerShell`,psm1:`PowerShell`,rb:`Ruby`,swift:`Swift`,toml:`TOML`,ini:`INI`,cfg:`Config`,conf:`Config`,properties:`Properties`,dockerfile:`Dockerfile`,diff:`Diff`,patch:`Patch`};function u(e){return c[e.toLowerCase()]}function d(e){return l[e.toLowerCase()]}var f=t(),p=262144,m=131072;function h(e){return e.split(`.`).pop()?.toLowerCase()??``}function g(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function _(e,t){return e.HighlightStyle.define([{tag:t.tags.keyword,color:g(`--cm-keyword`)},{tag:t.tags.string,color:g(`--cm-string`)},{tag:t.tags.number,color:g(`--cm-number`)},{tag:t.tags.comment,color:g(`--cm-comment`),fontStyle:`italic`},{tag:t.tags.function(t.tags.variableName),color:g(`--cm-function`)},{tag:t.tags.typeName,color:g(`--cm-type`)},{tag:t.tags.className,color:g(`--cm-type`)},{tag:t.tags.propertyName,color:g(`--cm-property`)},{tag:t.tags.operator,color:g(`--cm-operator`)},{tag:t.tags.variableName,color:g(`--cm-variable`)}])}function v({path:e,value:t,onChange:i,jumpToLine:s,onSave:c,workspaceId:l,blame:g}){let v=(0,o.useRef)(null),y=(0,o.useRef)(null),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)(null),C=(0,o.useRef)(null),w=(0,o.useRef)(null),T=(0,o.useRef)(null),E=(0,o.useRef)(i),D=(0,o.useRef)(c);E.current=i,D.current=c;let[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)(`0,0`),[P,F]=(0,o.useState)(0);(0,o.useEffect)(()=>{let i=!1,a,o,s,c,l;return(async()=>{try{let d=h(e),f=u(d),[m,g,O,A,M,P,I,L]=await Promise.all([r(()=>import(`./dist-B015qWBZ.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-EZxvaEWE.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-xcgc6bsN.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-DpFdyk4c.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-1vBvKRAO.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-3nL837Fs.js`).then(e=>e.n),__vite__mapDeps([5,2,3])),f?f().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${d}:`,e),null)):Promise.resolve(null),n().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null))]);if(i||!v.current)return;c=M,l=P,x.current=m.Annotation.define(),S.current=m.Transaction.addToHistory;let R=t.length<=p&&I!==null;o=new m.Compartment;let z=[g.lineNumbers(),g.highlightActiveLine(),g.drawSelection(),O.history(),g.keymap.of([O.indentWithTab,...O.defaultKeymap,...O.historyKeymap,...A.searchKeymap,{key:`Mod-s`,run:()=>(D.current(),!0)}]),g.EditorView.updateListener.of(e=>{e.docChanged&&!(x.current&&e.transactions.some(e=>e.annotation(x.current)===!0))&&E.current(e.state.doc.toString()),e.selectionSet&&N(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),g.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(L&&(s=new m.Compartment,z.splice(1,0,s.of([])),z.push(L.base)),I)try{z.push(I)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),R=!1}if(R&&o&&c&&l)try{z.push(o.of(c.syntaxHighlighting(_(c,l))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),R=!1}if(a=new g.EditorView({state:m.EditorState.create({doc:t,extensions:z}),parent:v.current}),i){a.destroy();return}y.current=a,k(R),j(!0),C.current=L,w.current=s??null,T.current=null,F(e=>e+1);let B=new MutationObserver(()=>{let e=y.current;if(e&&R&&o&&c&&l)try{e.dispatch({effects:o.reconfigure(c.syntaxHighlighting(_(c,l)))})}catch{}});b.current=B,B.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),i||j(!0)}})(),()=>{i=!0,b.current?.disconnect(),b.current=null,a?.destroy(),y.current=null,j(!1),v.current&&(v.current.textContent=``)}},[e]),(0,o.useEffect)(()=>{let e=y.current;if(!e)return;let n=e.state.doc.toString();n!==t&&e.dispatch({changes:{from:0,to:n.length,insert:t},annotations:x.current?x.current.of(!0):void 0})},[t]),(0,o.useEffect)(()=>{let e=y.current;if(!e||!s)return;let t=e.state.doc.line(Math.min(Math.max(1,s.line),e.state.doc.lines));e.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0}),e.focus()},[s,A]);let I=!!(g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l);(0,o.useEffect)(()=>{let t=y.current,n=C.current,r=w.current;if(!t||!n||!r)return;let i=g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l?g.response:null,o=i?a(i):null;T.current!==o&&(T.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[g?.state,g?.response,g?.path,g?.workspaceId,e,l,P]);let L=y.current?.state.doc.toString()??t,R=L.length<=m?L:L.slice(0,m),z=h(e),B=d(z);return(0,f.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":R,"data-file-content-truncated":L.length>m?`1`:`0`,"data-file-selection":M,"data-file-editor-ready":A?`1`:`0`,"data-file-blame-gutter":I?`1`:void 0,onMouseDown:()=>y.current?.focus(),children:[(0,f.jsx)(`div`,{className:`file-cm`,ref:v,"aria-label":`编辑 ${e}`}),!A&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`}),A&&!O&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-highlight-status":`plain`,children:`纯文本`}),A&&O&&B&&(0,f.jsx)(`span`,{className:`file-cm-status file-cm-status-lang`,"data-file-highlight-status":z,children:B})]})}export{v as CodeMirrorEditor};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-vaeFQOVz.js","assets/dist-B5tfuaLb.js","assets/index-AoOQKqJN.js","assets/index-1gs_N5Ez.css","assets/dist-BWVLHjVR.js","assets/dist-BpxB4Bv8.js","assets/dist-D8m7BNyE.js","assets/dist-DlAxGaOJ.js","assets/dist-B0m_IAGL.js","assets/dist-DAWXHOWp.js","assets/dist-CUUPt1_7.js","assets/dist-DrI3iWqO.js","assets/dist-Dqu0sUt9.js","assets/dist-DnzyresE.js","assets/dist-KiGuiwPf.js","assets/dist-DKsFQEo0.js","assets/dist-D6ddLLmt.js","assets/dist-DknCNZc2.js","assets/dist-C8QTA4LG.js","assets/dist-BkjACtBI.js","assets/dist-BOXmH3i1.js","assets/dist-B7RsNXnt.js","assets/dist-BVVnv5AJ.js","assets/dist-DGrM2Tzj.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,i as t,n,r,s as i,t as a}from"./index-AoOQKqJN.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-vaeFQOVz.js`),__vite__mapDeps([0,1,2,3,4,5])),e()]),a=i[t]??i.default??i;return n.define(a)}var c={cpp:()=>r(()=>import(`./dist-D8m7BNyE.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-D8m7BNyE.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-D8m7BNyE.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-D8m7BNyE.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-D8m7BNyE.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-D8m7BNyE.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-D8m7BNyE.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-D8m7BNyE.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-D8m7BNyE.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-D8m7BNyE.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-B0m_IAGL.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-B0m_IAGL.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mjs:()=>r(()=>import(`./dist-B0m_IAGL.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-B0m_IAGL.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-B0m_IAGL.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),tsx:()=>r(()=>import(`./dist-B0m_IAGL.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mts:()=>r(()=>import(`./dist-B0m_IAGL.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cts:()=>r(()=>import(`./dist-B0m_IAGL.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),py:()=>r(()=>import(`./dist-CUUPt1_7.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-CUUPt1_7.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-DrI3iWqO.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-Dqu0sUt9.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-DKsFQEo0.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-D6ddLLmt.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-D6ddLLmt.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-DknCNZc2.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-C8QTA4LG.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-C8QTA4LG.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-C8QTA4LG.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-DnzyresE.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-DnzyresE.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-DnzyresE.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-DnzyresE.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-KiGuiwPf.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-BkjACtBI.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-BkjACtBI.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-BkjACtBI.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-BOXmH3i1.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-B7RsNXnt.js`).then(e=>e.go()),__vite__mapDeps([21,5,2,3,0,1,4,7,9])),sh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>s(()=>r(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>s(()=>r(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>s(()=>r(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>s(()=>r(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`)},l={cpp:`C++`,cc:`C++`,cxx:`C++`,hpp:`C++`,hh:`C++`,hxx:`C++`,cu:`CUDA C++`,cuh:`CUDA C++`,c:`C`,h:`C/C++ Header`,js:`JavaScript`,jsx:`JSX`,mjs:`JavaScript`,cjs:`JavaScript`,ts:`TypeScript`,tsx:`TSX`,mts:`TypeScript`,cts:`TypeScript`,py:`Python`,pyi:`Python Stub`,java:`Java`,php:`PHP`,sql:`SQL`,yaml:`YAML`,yml:`YAML`,xml:`XML`,json:`JSON`,jsonc:`JSON with Comments`,json5:`JSON5`,css:`CSS`,md:`Markdown`,markdown:`Markdown`,mdx:`MDX`,rs:`Rust`,go:`Go`,html:`HTML`,htm:`HTML`,vue:`Vue`,svelte:`Svelte`,sh:`Shell`,bash:`Bash`,zsh:`Zsh`,fish:`Fish`,ps1:`PowerShell`,psm1:`PowerShell`,rb:`Ruby`,swift:`Swift`,toml:`TOML`,ini:`INI`,cfg:`Config`,conf:`Config`,properties:`Properties`,dockerfile:`Dockerfile`,diff:`Diff`,patch:`Patch`};function u(e){return c[e.toLowerCase()]}function d(e){return l[e.toLowerCase()]}var f=t(),p=262144,m=131072;function h(e){return e.split(`.`).pop()?.toLowerCase()??``}function g(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function _(e,t){return e.HighlightStyle.define([{tag:t.tags.keyword,color:g(`--cm-keyword`)},{tag:t.tags.string,color:g(`--cm-string`)},{tag:t.tags.number,color:g(`--cm-number`)},{tag:t.tags.comment,color:g(`--cm-comment`),fontStyle:`italic`},{tag:t.tags.function(t.tags.variableName),color:g(`--cm-function`)},{tag:t.tags.typeName,color:g(`--cm-type`)},{tag:t.tags.className,color:g(`--cm-type`)},{tag:t.tags.propertyName,color:g(`--cm-property`)},{tag:t.tags.operator,color:g(`--cm-operator`)},{tag:t.tags.variableName,color:g(`--cm-variable`)}])}function v({path:e,value:t,onChange:i,jumpToLine:s,onSave:c,workspaceId:l,blame:g}){let v=(0,o.useRef)(null),y=(0,o.useRef)(null),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)(null),C=(0,o.useRef)(null),w=(0,o.useRef)(null),T=(0,o.useRef)(null),E=(0,o.useRef)(i),D=(0,o.useRef)(c);E.current=i,D.current=c;let[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)(`0,0`),[P,F]=(0,o.useState)(0);(0,o.useEffect)(()=>{let i=!1,a,o,s,c,l;return(async()=>{try{let d=h(e),f=u(d),[m,g,O,A,M,P,I,L]=await Promise.all([r(()=>import(`./dist-B5tfuaLb.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-BWVLHjVR.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-BVVnv5AJ.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-DGrM2Tzj.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-vaeFQOVz.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-BpxB4Bv8.js`).then(e=>e.n),__vite__mapDeps([5,2,3])),f?f().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${d}:`,e),null)):Promise.resolve(null),n().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null))]);if(i||!v.current)return;c=M,l=P,x.current=m.Annotation.define(),S.current=m.Transaction.addToHistory;let R=t.length<=p&&I!==null;o=new m.Compartment;let z=[g.lineNumbers(),g.highlightActiveLine(),g.drawSelection(),O.history(),g.keymap.of([O.indentWithTab,...O.defaultKeymap,...O.historyKeymap,...A.searchKeymap,{key:`Mod-s`,run:()=>(D.current(),!0)}]),g.EditorView.updateListener.of(e=>{e.docChanged&&!(x.current&&e.transactions.some(e=>e.annotation(x.current)===!0))&&E.current(e.state.doc.toString()),e.selectionSet&&N(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),g.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(L&&(s=new m.Compartment,z.splice(1,0,s.of([])),z.push(L.base)),I)try{z.push(I)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),R=!1}if(R&&o&&c&&l)try{z.push(o.of(c.syntaxHighlighting(_(c,l))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),R=!1}if(a=new g.EditorView({state:m.EditorState.create({doc:t,extensions:z}),parent:v.current}),i){a.destroy();return}y.current=a,k(R),j(!0),C.current=L,w.current=s??null,T.current=null,F(e=>e+1);let B=new MutationObserver(()=>{let e=y.current;if(e&&R&&o&&c&&l)try{e.dispatch({effects:o.reconfigure(c.syntaxHighlighting(_(c,l)))})}catch{}});b.current=B,B.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),i||j(!0)}})(),()=>{i=!0,b.current?.disconnect(),b.current=null,a?.destroy(),y.current=null,j(!1),v.current&&(v.current.textContent=``)}},[e]),(0,o.useEffect)(()=>{let e=y.current;if(!e)return;let n=e.state.doc.toString();n!==t&&e.dispatch({changes:{from:0,to:n.length,insert:t},annotations:x.current?x.current.of(!0):void 0})},[t]),(0,o.useEffect)(()=>{let e=y.current;if(!e||!s)return;let t=e.state.doc.line(Math.min(Math.max(1,s.line),e.state.doc.lines));e.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0}),e.focus()},[s,A]);let I=!!(g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l);(0,o.useEffect)(()=>{let t=y.current,n=C.current,r=w.current;if(!t||!n||!r)return;let i=g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l?g.response:null,o=i?a(i):null;T.current!==o&&(T.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[g?.state,g?.response,g?.path,g?.workspaceId,e,l,P]);let L=y.current?.state.doc.toString()??t,R=L.length<=m?L:L.slice(0,m),z=h(e),B=d(z);return(0,f.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":R,"data-file-content-truncated":L.length>m?`1`:`0`,"data-file-selection":M,"data-file-editor-ready":A?`1`:`0`,"data-file-blame-gutter":I?`1`:void 0,onMouseDown:()=>y.current?.focus(),children:[(0,f.jsx)(`div`,{className:`file-cm`,ref:v,"aria-label":`编辑 ${e}`}),!A&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`}),A&&!O&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-highlight-status":`plain`,children:`纯文本`}),A&&O&&B&&(0,f.jsx)(`span`,{className:`file-cm-status file-cm-status-lang`,"data-file-highlight-status":z,children:B})]})}export{v as CodeMirrorEditor};
|