@evandu/super-pi 0.1.245 → 0.1.247
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/super-pi-task/index.ts +7 -58
- package/agents/super-pi-task/workflow-schema.ts +34 -0
- package/dist/client/.super-pi-client-sources.json +6 -5
- package/dist/client/assets/{CodeMirrorEditor-DXz3TlpL.js → CodeMirrorEditor-CfRZBw_k.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-8bvWRIwo.js → GitDiffEditor-CxVEErgk.js} +1 -1
- package/dist/client/assets/{index-CU4rNgq5.js → index-D-5yq-Mj.js} +13 -13
- package/dist/client/assets/index-oGFfK21_.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/application/conversation-service.js +5 -0
- package/dist/server/application/workspace-service.d.ts +2 -0
- package/dist/server/application/workspace-service.js +57 -5
- package/dist/server/command-handler.js +7 -0
- package/dist/server/runtime.js +4 -1
- package/dist/server/store.d.ts +5 -0
- package/dist/server/store.js +41 -0
- package/dist/server/thinking-level-discovery.js +25 -1
- package/dist/server/types.d.ts +10 -0
- package/package.json +1 -1
- package/dist/.super-pi-check-inputs.json +0 -4
- package/dist/client/assets/index-E2qh6Qge.css +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { workflowNodeSchema } from "./workflow-schema.ts";
|
|
2
3
|
import { PROJECT_TOOL_NAME, PROJECT_DESCRIPTION, TEAM_COORDINATION_DESCRIPTION, TEAM_CONTEXT_SECTION_KEY, loadTeamContext, readProjectConfig, executeProject } from "./core.ts";
|
|
3
4
|
import {
|
|
4
5
|
SUPER_PI_CAPABILITIES_SECTION,
|
|
@@ -153,66 +154,14 @@ type ExtensionToolDefinition = {
|
|
|
153
154
|
* gets for a bad value is better written by the side that knows the real options.
|
|
154
155
|
*/
|
|
155
156
|
/**
|
|
156
|
-
* THE
|
|
157
|
+
* THE PROVIDER-FACING WORKFLOW NODE SCHEMA.
|
|
157
158
|
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* `
|
|
162
|
-
* **1.3.27**. That version has `Type.Unsafe`, `Type.Ref` and `Type.Any`, but it does NOT have
|
|
163
|
-
* `Type.Recursive`: the function arrived in typebox 0.34 and the 1.x line dropped it.
|
|
164
|
-
*
|
|
165
|
-
* Using it anyway fails at LOAD time, not at call time, and it fails for everything:
|
|
166
|
-
*
|
|
167
|
-
* Failed to load extension ".../agents/super-pi-task/index.ts":
|
|
168
|
-
* Failed to load extension: _typebox.Type.Recursive is not a function
|
|
169
|
-
*
|
|
170
|
-
* An extension that does not load takes Pi's whole extension host with it - every Super Pi tool
|
|
171
|
-
* disappears, not just this one. So the schema is written as the JSON Schema it actually is,
|
|
172
|
-
* with a `$ref` back to its own `$id`, which is what `Type.Recursive` would have produced anyway.
|
|
173
|
-
*
|
|
174
|
-
* `$defs` is not used: the `$ref` is relative to the root of THIS schema, and the root carries the
|
|
175
|
-
* `$id` the reference names.
|
|
159
|
+
* Some OpenAI-compatible providers reject recursive `$ref` and object `anyOf` schemas before a
|
|
160
|
+
* request reaches the model. Keep this description provider-portable and leave strict recursive
|
|
161
|
+
* validation to the Super Pi workflow endpoint, which owns the actual runtime roster and limits.
|
|
162
|
+
* The nested `do` items stay open objects so loop and foreach bodies can still be recursive.
|
|
176
163
|
*/
|
|
177
|
-
const WorkflowNodeParameters = Type.Unsafe(
|
|
178
|
-
$id: "WorkflowNode",
|
|
179
|
-
type: "object",
|
|
180
|
-
required: ["kind"],
|
|
181
|
-
properties: {
|
|
182
|
-
kind: { type: "string", enum: ["step", "loop", "foreach"] },
|
|
183
|
-
},
|
|
184
|
-
anyOf: [
|
|
185
|
-
{
|
|
186
|
-
type: "object",
|
|
187
|
-
required: ["kind", "agentId", "prompt"],
|
|
188
|
-
properties: {
|
|
189
|
-
kind: { const: "step" },
|
|
190
|
-
agentId: { type: "string", description: "The dispatchable sub-agent type to run, e.g. scout" },
|
|
191
|
-
label: { type: "string", description: "3-4 words saying what this step is FOR, shown to the user only" },
|
|
192
|
-
prompt: { type: "string", description: "The instruction for this step. Supports {{item}}, {{last}}, {{previous}} and {{history}} substitutions." },
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
type: "object",
|
|
197
|
-
required: ["kind", "until", "do"],
|
|
198
|
-
properties: {
|
|
199
|
-
kind: { const: "loop" },
|
|
200
|
-
until: { type: "string", description: "Exact conclusion line to match after trimming the final output line, e.g. 通过" },
|
|
201
|
-
max: { type: "integer", minimum: 1, maximum: 100, description: "Maximum rounds; defaults to 8" },
|
|
202
|
-
do: { type: "array", minItems: 1, items: { $ref: "WorkflowNode" }, description: "One or more nodes to rerun before each until check" },
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
type: "object",
|
|
207
|
-
required: ["kind", "items", "do"],
|
|
208
|
-
properties: {
|
|
209
|
-
kind: { const: "foreach" },
|
|
210
|
-
items: { type: "array", minItems: 1, items: { type: "string" }, description: "Explicit list supplied by the primary agent; the server never discovers it" },
|
|
211
|
-
do: { type: "array", minItems: 1, items: { $ref: "WorkflowNode" }, description: "One or more nodes to run once per item; prompts may use {{item}}" },
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
});
|
|
164
|
+
const WorkflowNodeParameters = Type.Unsafe(workflowNodeSchema());
|
|
216
165
|
|
|
217
166
|
const WorkflowParameters = Type.Object({
|
|
218
167
|
summary: Type.String({ description: "One line saying what this whole plan is for, shown to the user above the timeline" }),
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type JsonSchema = Record<string, any>;
|
|
2
|
+
|
|
3
|
+
const NODE_KINDS = ["step", "loop", "foreach"];
|
|
4
|
+
const MAX_DESCRIBED_NESTING = 8;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Builds a finite provider-portable schema for recursive workflow nodes.
|
|
8
|
+
*
|
|
9
|
+
* Some OpenAI-compatible APIs reject recursive `$ref` and object `anyOf` schemas. The workflow
|
|
10
|
+
* endpoint still validates the full recursive input; this schema describes common nested plans
|
|
11
|
+
* without sending those unsupported keywords to the provider.
|
|
12
|
+
*/
|
|
13
|
+
export function workflowNodeSchema(depth = MAX_DESCRIBED_NESTING): JsonSchema {
|
|
14
|
+
const properties: JsonSchema = {
|
|
15
|
+
kind: { type: "string", enum: NODE_KINDS, description: "step needs agentId and prompt; loop needs until and do; foreach needs items and do" },
|
|
16
|
+
agentId: { type: "string", description: "Required for step nodes: the sub-agent to run" },
|
|
17
|
+
label: { type: "string", description: "Optional short label for a step" },
|
|
18
|
+
prompt: { type: "string", description: "Required for step nodes: the instruction for that step" },
|
|
19
|
+
until: { type: "string", description: "Required for loop nodes: exact conclusion line to match" },
|
|
20
|
+
max: { type: "integer", minimum: 1, maximum: 100, description: "Optional loop limit; defaults to 8" },
|
|
21
|
+
items: { type: "array", minItems: 1, items: { type: "string" }, description: "Required for foreach nodes: explicit items supplied by the primary agent" },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
properties.do = {
|
|
25
|
+
type: "array",
|
|
26
|
+
minItems: 1,
|
|
27
|
+
items: depth > 0
|
|
28
|
+
? workflowNodeSchema(depth - 1)
|
|
29
|
+
: { type: "object", description: "A nested workflow node with the same kind-specific fields" },
|
|
30
|
+
description: "Required for loop and foreach nodes: nested workflow nodes",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return { type: "object", required: ["kind"], properties };
|
|
34
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"hash": "
|
|
2
|
+
"hash": "519d585e9fca579a4579d76e6b91cc5ed24a8c732543013491fdcc9ffc22ba0c",
|
|
3
3
|
"files": {
|
|
4
|
-
"src/client/App.tsx": "
|
|
4
|
+
"src/client/App.tsx": "6a270bafd6dd1d34ab2caaf0a5709141687416a8da2879dec5677ba2961c8125",
|
|
5
5
|
"src/client/CacheWarmingSettings.tsx": "6a810dcaff04eecd6546b442168b257b21f442bf5b2909180a7ad914325f5a72",
|
|
6
6
|
"src/client/CodeMirrorEditor.tsx": "f6cbdcc7edd2713ff720159b871e3af545ba1a160a946e67840ed66bc1a04596",
|
|
7
7
|
"src/client/ErrorBoundary.tsx": "d16376f9f6c7cc1fab8590c65a66438127642f7d6bb8023cec53d8a6cc9f3964",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"src/client/WorkbenchSearch.tsx": "83a52a45d561bc31f19ae0c76708572cde73cb952ef69e60247e638c0abe57f2",
|
|
37
37
|
"src/client/WorkbenchSplit.tsx": "7afc0e435ad8eae95f95a28563034e3bf09eef070f47bd3366d9b8eff9bc229e",
|
|
38
38
|
"src/client/WorkflowCard.tsx": "8ce5458537a3b02dcbb9bbb4c7afacb07e0f41857ed250aa4cde0cbc8d4bde6c",
|
|
39
|
+
"src/client/WorkspaceBulkSettings.tsx": "859cb5159f1aff91b8e7a7987c569d67df8bbacb3f24c6cc4c47b5ebe17f253c",
|
|
39
40
|
"src/client/WorkspaceExplorerActions.tsx": "20b04fd1e9c3488bbe70f6c43f21d3f9df0e2f30e09c09eb21601cc47c81d212",
|
|
40
41
|
"src/client/WorkspaceFilePreview.tsx": "1a09e2fede74efa455ae447e6a471edbc19f511b6ca76226d8ad892bf30d160b",
|
|
41
42
|
"src/client/archive-confirm.ts": "a559c1d251e2e3495519d009c50e3adcaaae5859566290c6b8ffef554ddf268c",
|
|
@@ -58,16 +59,16 @@
|
|
|
58
59
|
"src/client/session-tree.ts": "08a14c6611fdd9a72001eb1672060479e7660de5a5d221c7e80036209fd26546",
|
|
59
60
|
"src/client/slash-commands.ts": "4a2cef1eb9517628eadfdc38bca7e3663e4d48090d8b87a8a79de4bfd586e112",
|
|
60
61
|
"src/client/software-update.css": "a4ec1565b70008b55618197a8d88db51a79fb932b9a69bfe4318a62774e8020a",
|
|
61
|
-
"src/client/styles.css": "
|
|
62
|
+
"src/client/styles.css": "772fb2ff71a6329001b9ed4b1ac87597f4d99ea3de50e2ca2e3a9569b218409e",
|
|
62
63
|
"src/client/terminal-emulator.ts": "ffcc4f5fbddaf25cebcc9e03dbe5d7d0ad2c21586f5d169e57c04c82e2308b3b",
|
|
63
64
|
"src/client/theme.tsx": "ff2681b4d4451cfee93e3fd6c9cfbf717ef0c43ae802e1af6326a743bd1aa518",
|
|
64
65
|
"src/client/tool-launcher.ts": "40fb4974362bbc8c73ecd651da1abce251fc28857564a9321037adcfdb0bfe24",
|
|
65
66
|
"src/client/tool-sharing.ts": "011212825dbbffe18c8f15aca721c02938ab6273fb5607b072a1e7b8b1853640",
|
|
66
67
|
"src/client/tool-shortcuts.ts": "cbd89186776cab19b8b3ec40b8a755c4fc2a47d1c03653eca55e6b23b865c3b6",
|
|
67
68
|
"src/client/tools.ts": "58fe41f0edbd490e3fab7f12f258b1dbc2163b653553b03ac61caf1543618e50",
|
|
68
|
-
"src/client/types.ts": "
|
|
69
|
+
"src/client/types.ts": "0013ac8051c91fca4762b58300a66e76fc632adedc9efc9d2536c857e2ae9218",
|
|
69
70
|
"src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5",
|
|
70
71
|
"src/client/workbench-navigation.ts": "3b229752a8ce4a45eba7aeff040eb33001413190141f1e9b8e5f38246a1761e2"
|
|
71
72
|
},
|
|
72
|
-
"recordedAt": "2026-11-
|
|
73
|
+
"recordedAt": "2026-11-19T04:20:10.572Z"
|
|
73
74
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-BUCp8C1J.js","assets/dist-Dobw-6kL.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-KYkkwisQ.js","assets/dist-Cus6_oaF.js","assets/dist-B8HMl2sC.js","assets/dist-BXAOrsjq.js","assets/dist-BaqnkrBt.js","assets/dist-BOxW9j9f.js","assets/dist-DMNSi_OW.js","assets/dist-BZcQqwK2.js","assets/dist-MjzwBrDE.js","assets/dist-EZTF454G.js","assets/dist-CDdAirBD.js","assets/dist-CsOcBQZU.js","assets/dist-rWx2sy4G.js","assets/dist-Bd_1wEMo.js","assets/dist-blcD_RX0.js","assets/dist-DfYcl24C.js","assets/dist-BJ4DyKpr.js","assets/dist-DDX_kEXl.js","assets/dist-DDMxAmWr.js","assets/dist-KRvDAowe.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{l as t,n,o as r,r as i,t as a}from"./index-CU4rNgq5.js";var o=e(t(),1);async function s(e,t){let[{StreamLanguage:n},r]=await Promise.all([i(()=>import(`./dist-BUCp8C1J.js`),__vite__mapDeps([0,1,2,3,4])),e()]),a=r[t]??r.default??r;return n.define(a)}var c={cpp:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),cc:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),cxx:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),hpp:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),hh:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),hxx:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),c:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),h:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),cu:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),cuh:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),js:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,2,1,3,4,0,6,8])),jsx:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([7,2,1,3,4,0,6,8])),mjs:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,2,1,3,4,0,6,8])),cjs:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,2,1,3,4,0,6,8])),ts:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,2,1,3,4,0,6,8])),tsx:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([7,2,1,3,4,0,6,8])),mts:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,2,1,3,4,0,6,8])),cts:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,2,1,3,4,0,6,8])),py:()=>i(()=>import(`./dist-DMNSi_OW.js`).then(e=>e.python()),__vite__mapDeps([9,4,2,0,1,3,6,8])),pyi:()=>i(()=>import(`./dist-DMNSi_OW.js`).then(e=>e.python()),__vite__mapDeps([9,4,2,0,1,3,6,8])),java:()=>i(()=>import(`./dist-BZcQqwK2.js`).then(e=>e.java()),__vite__mapDeps([10,4,2,0,1,3,6])),php:()=>i(()=>import(`./dist-MjzwBrDE.js`).then(e=>e.php()),__vite__mapDeps([11,4,2,0,1,3,6,12,13,7,8])),sql:()=>i(()=>import(`./dist-CsOcBQZU.js`).then(e=>e.sql()),__vite__mapDeps([14,4,2,0,1,3,6,8])),yaml:()=>i(()=>import(`./dist-rWx2sy4G.js`).then(e=>e.yaml()),__vite__mapDeps([15,4,2,0,1,3,6])),yml:()=>i(()=>import(`./dist-rWx2sy4G.js`).then(e=>e.yaml()),__vite__mapDeps([15,4,2,0,1,3,6])),xml:()=>i(()=>import(`./dist-Bd_1wEMo.js`).then(e=>e.xml()),__vite__mapDeps([16,1,2,3,4,0,6])),json:()=>i(()=>import(`./dist-blcD_RX0.js`).then(e=>e.json()),__vite__mapDeps([17,4,2,0,1,3,6])),jsonc:()=>i(()=>import(`./dist-blcD_RX0.js`).then(e=>e.json()),__vite__mapDeps([17,4,2,0,1,3,6])),json5:()=>i(()=>import(`./dist-blcD_RX0.js`).then(e=>e.json()),__vite__mapDeps([17,4,2,0,1,3,6])),html:()=>i(()=>import(`./dist-EZTF454G.js`).then(e=>e.html()),__vite__mapDeps([12,1,2,3,4,0,6,13,7,8])),htm:()=>i(()=>import(`./dist-EZTF454G.js`).then(e=>e.html()),__vite__mapDeps([12,1,2,3,4,0,6,13,7,8])),vue:()=>i(()=>import(`./dist-EZTF454G.js`).then(e=>e.html()),__vite__mapDeps([12,1,2,3,4,0,6,13,7,8])),svelte:()=>i(()=>import(`./dist-EZTF454G.js`).then(e=>e.html()),__vite__mapDeps([12,1,2,3,4,0,6,13,7,8])),css:()=>i(()=>import(`./dist-CDdAirBD.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([13,2,4,0,1,3,6])),md:()=>i(()=>import(`./dist-DfYcl24C.js`).then(e=>e.markdown()),__vite__mapDeps([18,1,2,3,4,0,8,12,6,13,7])),markdown:()=>i(()=>import(`./dist-DfYcl24C.js`).then(e=>e.markdown()),__vite__mapDeps([18,1,2,3,4,0,8,12,6,13,7])),mdx:()=>i(()=>import(`./dist-DfYcl24C.js`).then(e=>e.markdown()),__vite__mapDeps([18,1,2,3,4,0,8,12,6,13,7])),rs:()=>i(()=>import(`./dist-BJ4DyKpr.js`).then(e=>e.rust()),__vite__mapDeps([19,4,2,0,1,3,6])),go:()=>i(()=>import(`./dist-DDX_kEXl.js`).then(e=>e.go()),__vite__mapDeps([20,4,2,0,1,3,6,8])),sh:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>s(()=>i(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>s(()=>i(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>s(()=>i(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>s(()=>i(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>s(()=>i(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>s(()=>i(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>s(()=>i(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>s(()=>i(()=>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=r(),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:r,jumpToLine:s,onSave:c,workspaceId:l,blame:g,onPosition:v,readOnly:y=!1}){let 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)(null),D=(0,o.useRef)(null),O=(0,o.useRef)(r),k=(0,o.useRef)(c);O.current=r,k.current=c;let[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)(!1),[P,F]=(0,o.useState)(`0,0`),[I,L]=(0,o.useState)(0);(0,o.useEffect)(()=>{let r=!1,a,o,s,c,l;return(async()=>{try{let d=h(e),f=u(d),[m,g,v,A,M,P,I,R]=await Promise.all([i(()=>import(`./dist-Dobw-6kL.js`).then(e=>e.x),__vite__mapDeps([1,2])),i(()=>import(`./dist-KYkkwisQ.js`).then(e=>e.s),__vite__mapDeps([3,2,1])),i(()=>import(`./dist-DDMxAmWr.js`),__vite__mapDeps([21,1,2,3,4,0])),i(()=>import(`./dist-KRvDAowe.js`),__vite__mapDeps([22,1,2,3])),i(()=>import(`./dist-BUCp8C1J.js`),__vite__mapDeps([0,1,2,3,4])),i(()=>import(`./dist-Cus6_oaF.js`).then(e=>e.n),__vite__mapDeps([4,2])),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(r||!b.current)return;c=M,l=P,C.current=m.Annotation.define(),w.current=m.Transaction.addToHistory;let z=t.length<=p&&I!==null;o=new m.Compartment;let B=[g.lineNumbers(),g.highlightActiveLine(),g.drawSelection(),v.history(),g.keymap.of([v.indentWithTab,...v.defaultKeymap,...v.historyKeymap,...A.searchKeymap,{key:`Mod-s`,run:()=>(k.current(),!0)}]),g.EditorView.updateListener.of(e=>{e.docChanged&&!(C.current&&e.transactions.some(e=>e.annotation(C.current)===!0))&&O.current(e.state.doc.toString()),e.selectionSet&&F(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),g.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(y&&B.push(m.EditorState.readOnly.of(!0),g.EditorView.editable.of(!1)),R&&!y&&(s=new m.Compartment,B.splice(1,0,s.of([])),B.push(R.base)),I)try{B.push(I)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),z=!1}if(z&&o&&c&&l)try{B.push(o.of(c.syntaxHighlighting(_(c,l))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),z=!1}if(a=new g.EditorView({state:m.EditorState.create({doc:t,extensions:B}),parent:b.current}),r){a.destroy();return}x.current=a,j(z),N(!0),T.current=R,E.current=s??null,D.current=null,L(e=>e+1);let V=new MutationObserver(()=>{let e=x.current;if(e&&z&&o&&c&&l)try{e.dispatch({effects:o.reconfigure(c.syntaxHighlighting(_(c,l)))})}catch{}});S.current=V,V.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),r||N(!0)}})(),()=>{r=!0,S.current?.disconnect(),S.current=null,a?.destroy(),x.current=null,N(!1),b.current&&(b.current.textContent=``)}},[e,y]),(0,o.useEffect)(()=>{let e=x.current;if(!e)return;let n=e.state.doc.toString();n!==t&&e.dispatch({changes:{from:0,to:n.length,insert:t},annotations:C.current?C.current.of(!0):void 0})},[t]),(0,o.useEffect)(()=>{let e=x.current;if(!e||!s)return;let t=e.state.doc.line(Math.min(Math.max(1,s.line),e.state.doc.lines)),n=Math.min(t.to,t.from+(s.column??1)-1);e.dispatch({selection:{anchor:t.to,head:n},scrollIntoView:!0}),e.focus()},[s,M]);let R=!!(g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l);(0,o.useEffect)(()=>{let t=x.current,n=T.current,r=E.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;D.current!==o&&(D.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[g?.state,g?.response,g?.path,g?.workspaceId,e,l,I]);let z=x.current?.state.doc.toString()??t,B=z.length<=m?z:z.slice(0,m),V=h(e),H=d(V),U=x.current?.state,W=U?.selection.main.head,G=W===void 0?void 0:U?.doc.lineAt(W),K=G?.number,q=W!==void 0&&G?W-G.from+1:void 0;return(0,o.useEffect)(()=>{M&&K!==void 0&&q!==void 0&&v?.({line:K,column:q,language:A&&H||`纯文本`,highlight:A?V:`plain`})},[M,K,q,A,H,V,v]),(0,o.useEffect)(()=>()=>v?.(),[v]),(0,f.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":B,"data-file-content-truncated":z.length>m?`1`:`0`,"data-file-selection":P,"data-file-editor-ready":M?`1`:`0`,"data-file-blame-gutter":R?`1`:void 0,onMouseDown:()=>x.current?.focus(),children:[(0,f.jsx)(`div`,{className:`file-cm`,ref:b,"aria-label":`${y?`查看`:`编辑`} ${e}`}),(!M||!v)&&(0,f.jsxs)(`div`,{className:`file-editor-status`,children:[!M&&(0,f.jsx)(`span`,{"data-file-editor-loading":`1`,children:`正在加载编辑器…`}),M&&W!==void 0&&G&&(0,f.jsxs)(`span`,{children:[`第 `,G.number,` 行,第 `,W-G.from+1,` 列`]}),M&&!A&&(0,f.jsx)(`span`,{"data-file-highlight-status":`plain`,children:`纯文本`}),M&&A&&H&&(0,f.jsx)(`span`,{"data-file-highlight-status":V,children:H})]})]})}export{v as CodeMirrorEditor};
|
|
2
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{l as t,n,o as r,r as i,t as a}from"./index-D-5yq-Mj.js";var o=e(t(),1);async function s(e,t){let[{StreamLanguage:n},r]=await Promise.all([i(()=>import(`./dist-BUCp8C1J.js`),__vite__mapDeps([0,1,2,3,4])),e()]),a=r[t]??r.default??r;return n.define(a)}var c={cpp:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),cc:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),cxx:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),hpp:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),hh:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),hxx:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),c:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),h:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),cu:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),cuh:()=>i(()=>import(`./dist-B8HMl2sC.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,2,0,1,3,6])),js:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,2,1,3,4,0,6,8])),jsx:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([7,2,1,3,4,0,6,8])),mjs:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,2,1,3,4,0,6,8])),cjs:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,2,1,3,4,0,6,8])),ts:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,2,1,3,4,0,6,8])),tsx:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([7,2,1,3,4,0,6,8])),mts:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,2,1,3,4,0,6,8])),cts:()=>i(()=>import(`./dist-BaqnkrBt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,2,1,3,4,0,6,8])),py:()=>i(()=>import(`./dist-DMNSi_OW.js`).then(e=>e.python()),__vite__mapDeps([9,4,2,0,1,3,6,8])),pyi:()=>i(()=>import(`./dist-DMNSi_OW.js`).then(e=>e.python()),__vite__mapDeps([9,4,2,0,1,3,6,8])),java:()=>i(()=>import(`./dist-BZcQqwK2.js`).then(e=>e.java()),__vite__mapDeps([10,4,2,0,1,3,6])),php:()=>i(()=>import(`./dist-MjzwBrDE.js`).then(e=>e.php()),__vite__mapDeps([11,4,2,0,1,3,6,12,13,7,8])),sql:()=>i(()=>import(`./dist-CsOcBQZU.js`).then(e=>e.sql()),__vite__mapDeps([14,4,2,0,1,3,6,8])),yaml:()=>i(()=>import(`./dist-rWx2sy4G.js`).then(e=>e.yaml()),__vite__mapDeps([15,4,2,0,1,3,6])),yml:()=>i(()=>import(`./dist-rWx2sy4G.js`).then(e=>e.yaml()),__vite__mapDeps([15,4,2,0,1,3,6])),xml:()=>i(()=>import(`./dist-Bd_1wEMo.js`).then(e=>e.xml()),__vite__mapDeps([16,1,2,3,4,0,6])),json:()=>i(()=>import(`./dist-blcD_RX0.js`).then(e=>e.json()),__vite__mapDeps([17,4,2,0,1,3,6])),jsonc:()=>i(()=>import(`./dist-blcD_RX0.js`).then(e=>e.json()),__vite__mapDeps([17,4,2,0,1,3,6])),json5:()=>i(()=>import(`./dist-blcD_RX0.js`).then(e=>e.json()),__vite__mapDeps([17,4,2,0,1,3,6])),html:()=>i(()=>import(`./dist-EZTF454G.js`).then(e=>e.html()),__vite__mapDeps([12,1,2,3,4,0,6,13,7,8])),htm:()=>i(()=>import(`./dist-EZTF454G.js`).then(e=>e.html()),__vite__mapDeps([12,1,2,3,4,0,6,13,7,8])),vue:()=>i(()=>import(`./dist-EZTF454G.js`).then(e=>e.html()),__vite__mapDeps([12,1,2,3,4,0,6,13,7,8])),svelte:()=>i(()=>import(`./dist-EZTF454G.js`).then(e=>e.html()),__vite__mapDeps([12,1,2,3,4,0,6,13,7,8])),css:()=>i(()=>import(`./dist-CDdAirBD.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([13,2,4,0,1,3,6])),md:()=>i(()=>import(`./dist-DfYcl24C.js`).then(e=>e.markdown()),__vite__mapDeps([18,1,2,3,4,0,8,12,6,13,7])),markdown:()=>i(()=>import(`./dist-DfYcl24C.js`).then(e=>e.markdown()),__vite__mapDeps([18,1,2,3,4,0,8,12,6,13,7])),mdx:()=>i(()=>import(`./dist-DfYcl24C.js`).then(e=>e.markdown()),__vite__mapDeps([18,1,2,3,4,0,8,12,6,13,7])),rs:()=>i(()=>import(`./dist-BJ4DyKpr.js`).then(e=>e.rust()),__vite__mapDeps([19,4,2,0,1,3,6])),go:()=>i(()=>import(`./dist-DDX_kEXl.js`).then(e=>e.go()),__vite__mapDeps([20,4,2,0,1,3,6,8])),sh:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>s(()=>i(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>s(()=>i(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>s(()=>i(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>s(()=>i(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>s(()=>i(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>s(()=>i(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>s(()=>i(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>s(()=>i(()=>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=r(),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:r,jumpToLine:s,onSave:c,workspaceId:l,blame:g,onPosition:v,readOnly:y=!1}){let 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)(null),D=(0,o.useRef)(null),O=(0,o.useRef)(r),k=(0,o.useRef)(c);O.current=r,k.current=c;let[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)(!1),[P,F]=(0,o.useState)(`0,0`),[I,L]=(0,o.useState)(0);(0,o.useEffect)(()=>{let r=!1,a,o,s,c,l;return(async()=>{try{let d=h(e),f=u(d),[m,g,v,A,M,P,I,R]=await Promise.all([i(()=>import(`./dist-Dobw-6kL.js`).then(e=>e.x),__vite__mapDeps([1,2])),i(()=>import(`./dist-KYkkwisQ.js`).then(e=>e.s),__vite__mapDeps([3,2,1])),i(()=>import(`./dist-DDMxAmWr.js`),__vite__mapDeps([21,1,2,3,4,0])),i(()=>import(`./dist-KRvDAowe.js`),__vite__mapDeps([22,1,2,3])),i(()=>import(`./dist-BUCp8C1J.js`),__vite__mapDeps([0,1,2,3,4])),i(()=>import(`./dist-Cus6_oaF.js`).then(e=>e.n),__vite__mapDeps([4,2])),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(r||!b.current)return;c=M,l=P,C.current=m.Annotation.define(),w.current=m.Transaction.addToHistory;let z=t.length<=p&&I!==null;o=new m.Compartment;let B=[g.lineNumbers(),g.highlightActiveLine(),g.drawSelection(),v.history(),g.keymap.of([v.indentWithTab,...v.defaultKeymap,...v.historyKeymap,...A.searchKeymap,{key:`Mod-s`,run:()=>(k.current(),!0)}]),g.EditorView.updateListener.of(e=>{e.docChanged&&!(C.current&&e.transactions.some(e=>e.annotation(C.current)===!0))&&O.current(e.state.doc.toString()),e.selectionSet&&F(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),g.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(y&&B.push(m.EditorState.readOnly.of(!0),g.EditorView.editable.of(!1)),R&&!y&&(s=new m.Compartment,B.splice(1,0,s.of([])),B.push(R.base)),I)try{B.push(I)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),z=!1}if(z&&o&&c&&l)try{B.push(o.of(c.syntaxHighlighting(_(c,l))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),z=!1}if(a=new g.EditorView({state:m.EditorState.create({doc:t,extensions:B}),parent:b.current}),r){a.destroy();return}x.current=a,j(z),N(!0),T.current=R,E.current=s??null,D.current=null,L(e=>e+1);let V=new MutationObserver(()=>{let e=x.current;if(e&&z&&o&&c&&l)try{e.dispatch({effects:o.reconfigure(c.syntaxHighlighting(_(c,l)))})}catch{}});S.current=V,V.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),r||N(!0)}})(),()=>{r=!0,S.current?.disconnect(),S.current=null,a?.destroy(),x.current=null,N(!1),b.current&&(b.current.textContent=``)}},[e,y]),(0,o.useEffect)(()=>{let e=x.current;if(!e)return;let n=e.state.doc.toString();n!==t&&e.dispatch({changes:{from:0,to:n.length,insert:t},annotations:C.current?C.current.of(!0):void 0})},[t]),(0,o.useEffect)(()=>{let e=x.current;if(!e||!s)return;let t=e.state.doc.line(Math.min(Math.max(1,s.line),e.state.doc.lines)),n=Math.min(t.to,t.from+(s.column??1)-1);e.dispatch({selection:{anchor:t.to,head:n},scrollIntoView:!0}),e.focus()},[s,M]);let R=!!(g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l);(0,o.useEffect)(()=>{let t=x.current,n=T.current,r=E.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;D.current!==o&&(D.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[g?.state,g?.response,g?.path,g?.workspaceId,e,l,I]);let z=x.current?.state.doc.toString()??t,B=z.length<=m?z:z.slice(0,m),V=h(e),H=d(V),U=x.current?.state,W=U?.selection.main.head,G=W===void 0?void 0:U?.doc.lineAt(W),K=G?.number,q=W!==void 0&&G?W-G.from+1:void 0;return(0,o.useEffect)(()=>{M&&K!==void 0&&q!==void 0&&v?.({line:K,column:q,language:A&&H||`纯文本`,highlight:A?V:`plain`})},[M,K,q,A,H,V,v]),(0,o.useEffect)(()=>()=>v?.(),[v]),(0,f.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":B,"data-file-content-truncated":z.length>m?`1`:`0`,"data-file-selection":P,"data-file-editor-ready":M?`1`:`0`,"data-file-blame-gutter":R?`1`:void 0,onMouseDown:()=>x.current?.focus(),children:[(0,f.jsx)(`div`,{className:`file-cm`,ref:b,"aria-label":`${y?`查看`:`编辑`} ${e}`}),(!M||!v)&&(0,f.jsxs)(`div`,{className:`file-editor-status`,children:[!M&&(0,f.jsx)(`span`,{"data-file-editor-loading":`1`,children:`正在加载编辑器…`}),M&&W!==void 0&&G&&(0,f.jsxs)(`span`,{children:[`第 `,G.number,` 行,第 `,W-G.from+1,` 列`]}),M&&!A&&(0,f.jsx)(`span`,{"data-file-highlight-status":`plain`,children:`纯文本`}),M&&A&&H&&(0,f.jsx)(`span`,{"data-file-highlight-status":V,children:H})]})]})}export{v as CodeMirrorEditor};
|