@evandu/super-pi 0.1.252 → 0.1.254
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/.super-pi-client-sources.json +7 -7
- package/dist/client/assets/{CodeMirrorEditor-CpItrI-Y.js → CodeMirrorEditor-DdxPcLjw.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-d3aMI5Ft.js → GitDiffEditor-CNCMPKVv.js} +3 -3
- package/dist/client/assets/{index-CAB3S_vd.css → index-BvAvBj_1.css} +1 -1
- package/dist/client/assets/{index-D2IVVBA_.js → index-WcUajwk6.js} +7 -7
- package/dist/client/index.html +2 -2
- package/dist/server/http-server.js +36 -5
- package/package.json +1 -1
package/dist/client/index.html
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
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-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-WcUajwk6.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BvAvBj_1.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<div id="root"></div>
|
|
@@ -1602,11 +1602,34 @@ export function createHttpServer(options) {
|
|
|
1602
1602
|
json(403, { error: "Git 写操作只允许来自本机或局域网的请求。" });
|
|
1603
1603
|
return;
|
|
1604
1604
|
}
|
|
1605
|
-
const asked = await readRequestText(request, 512000);
|
|
1605
|
+
const asked = await readRequestText(request, op === "diff-edit-save" ? MAX_FILE_BYTES * 2 : 512000);
|
|
1606
1606
|
if (asked.tooLarge) {
|
|
1607
1607
|
json(413, { error: "请求过大" });
|
|
1608
1608
|
return;
|
|
1609
1609
|
}
|
|
1610
|
+
if (op === "diff-edit-save") {
|
|
1611
|
+
const body = asked.text ? JSON.parse(asked.text) : {};
|
|
1612
|
+
if (!body || typeof body !== "object" || Array.isArray(body)
|
|
1613
|
+
|| typeof body.path !== "string" || typeof body.content !== "string"
|
|
1614
|
+
|| typeof body.baseEtag !== "string") {
|
|
1615
|
+
json(400, { error: "差异保存需要 path、content 和 baseEtag", code: "bad_request" });
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
const worktreeId = url.searchParams.get("worktreeId");
|
|
1619
|
+
if (worktreeId !== null && !/^[a-f0-9]{64}$/.test(worktreeId)) {
|
|
1620
|
+
json(400, { error: "请先选择有效工作树", code: "bad_worktree" });
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
const checkout = worktreeId ? await resolveGitWorktree(workspace.path, worktreeId) : undefined;
|
|
1624
|
+
const editRoot = checkout?.path ?? workspace.path;
|
|
1625
|
+
const editSession = checkout?.path ?? sessionRoot;
|
|
1626
|
+
await explorerPath(editRoot, editSession, body.path, true);
|
|
1627
|
+
const path = await workspacePathFromSession(editRoot, editSession, body.path);
|
|
1628
|
+
const saved = await serializeWorkspaceWrite(workspace.path, () => writeWorkspaceFile(editRoot, path, body.content, body.baseEtag));
|
|
1629
|
+
broadcaster.broadcast({ type: "files.invalidated", workspaceId: workspace.id, paths: checkout ? [] : [path] });
|
|
1630
|
+
json(200, saved);
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1610
1633
|
if (op === "draft") {
|
|
1611
1634
|
if (!context.runtime?.askOnce) {
|
|
1612
1635
|
json(503, { error: "未配置可生成提交说明的模型" });
|
|
@@ -1690,11 +1713,19 @@ export function createHttpServer(options) {
|
|
|
1690
1713
|
json(400, { error: "差异编辑需要 path", code: "bad_path" });
|
|
1691
1714
|
return;
|
|
1692
1715
|
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1716
|
+
const worktreeId = url.searchParams.get("worktreeId");
|
|
1717
|
+
if (worktreeId !== null && !/^[a-f0-9]{64}$/.test(worktreeId)) {
|
|
1718
|
+
json(400, { error: "请先选择有效工作树", code: "bad_worktree" });
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
const checkout = worktreeId ? await resolveGitWorktree(workspace.path, worktreeId) : undefined;
|
|
1722
|
+
const editRoot = checkout?.path ?? workspace.path;
|
|
1723
|
+
const editSession = checkout?.path ?? sessionRoot;
|
|
1724
|
+
await explorerPath(editRoot, editSession, requested, true);
|
|
1725
|
+
const path = await workspacePathFromSession(editRoot, editSession, requested);
|
|
1695
1726
|
const [original, file] = await Promise.all([
|
|
1696
|
-
gitIndexFileContent(
|
|
1697
|
-
readWorkspaceFile(
|
|
1727
|
+
gitIndexFileContent(editRoot, path),
|
|
1728
|
+
readWorkspaceFile(editRoot, path),
|
|
1698
1729
|
]);
|
|
1699
1730
|
json(200, { path: file.path, original, content: file.content, eol: file.eol, bom: file.bom, meta: file.meta });
|
|
1700
1731
|
}
|