@evandu/super-pi 0.1.234 → 0.1.235
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 -6
- package/dist/client/assets/{CodeMirrorEditor-Bghp-U4C.js → CodeMirrorEditor-DBSi0y5V.js} +2 -2
- package/dist/client/assets/{dist-Zo5WaMe0.js → dist-0NfztBk-.js} +1 -1
- package/dist/client/assets/{dist-C7Frt-j5.js → dist-AFzBxMiM.js} +1 -1
- package/dist/client/assets/{dist-CWI_J8Y8.js → dist-AuOQsEQB.js} +1 -1
- package/dist/client/assets/{dist-qY4JuH16.js → dist-BFIiLPLD.js} +1 -1
- package/dist/client/assets/{dist-DzEYlfwN.js → dist-BIJ9NGer.js} +1 -1
- package/dist/client/assets/{dist-Bs7CHuCU.js → dist-BYCGZ2pA.js} +1 -1
- package/dist/client/assets/{dist-BNTyu0GR.js → dist-BzVCaLha.js} +1 -1
- package/dist/client/assets/{dist-Ka-oeqiz.js → dist-BzkoHuGc.js} +1 -1
- package/dist/client/assets/{dist-gzowmwC2.js → dist-CCS69OpS.js} +1 -1
- package/dist/client/assets/{dist-CpJDmC2s.js → dist-CKnqkrKG.js} +1 -1
- package/dist/client/assets/{dist-pz-FtJ-_.js → dist-CMmqt5Ls.js} +1 -1
- package/dist/client/assets/{dist-BOLAeWpo.js → dist-CN_srcoq.js} +1 -1
- package/dist/client/assets/{dist-DDQEsi6d.js → dist-ClI_GbBL.js} +1 -1
- package/dist/client/assets/{dist-BfJ86nxw.js → dist-Ctqsash1.js} +1 -1
- package/dist/client/assets/{dist-DkGaMCuB.js → dist-CvBx0FR6.js} +1 -1
- package/dist/client/assets/{dist-CeyskXU5.js → dist-DOhnZjPv.js} +1 -1
- package/dist/client/assets/{dist-BESOLyaG.js → dist-DREIvqD0.js} +1 -1
- package/dist/client/assets/{dist-CXgcMgdt.js → dist-DTKai_jj.js} +1 -1
- package/dist/client/assets/{dist-jtZ_yT6e.js → dist-DnxKnc-T.js} +1 -1
- package/dist/client/assets/{dist-B8NaV9Cv.js → dist-o5ICDbri.js} +1 -1
- package/dist/client/assets/{dist-vqHBACjg.js → dist-od0aIXVf.js} +1 -1
- package/dist/client/assets/{dist-BXS7H8-R.js → dist-yUsZ_PQw.js} +1 -1
- package/dist/client/assets/{index-CYevEn2Z.css → index-D-s-Xog1.css} +1 -1
- package/dist/client/assets/{index-_JUMqd3d.js → index-GRdiKmhS.js} +50 -50
- package/dist/client/index.html +2 -2
- package/dist/server/git.d.ts +3 -3
- package/dist/server/git.js +36 -14
- package/dist/server/http-server.js +6 -5
- package/package.json +1 -1
package/dist/client/index.html
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
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="stylesheet" crossorigin href="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-GRdiKmhS.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D-s-Xog1.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|
package/dist/server/git.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare function gitLog(root: string, limit: number, cwd?: string, query?
|
|
|
28
28
|
}>;
|
|
29
29
|
export declare function gitGraph(root: string, limit: number, offset: number, snapshot: string, after: string): Promise<GitGraphPage>;
|
|
30
30
|
export declare function gitCommit(root: string, cwd: string, hash: string): Promise<GitCommitDetail>;
|
|
31
|
-
export declare function gitCommitDiff(root: string, cwd: string, hash: string, path: string): Promise<{
|
|
31
|
+
export declare function gitCommitDiff(root: string, cwd: string, hash: string, path: string, fullContext?: boolean): Promise<{
|
|
32
32
|
path: string;
|
|
33
33
|
staged: boolean;
|
|
34
34
|
kind: "binary" | "text";
|
|
@@ -86,7 +86,7 @@ export declare function inspectGitWorktree(path: string, base: GitWorktree | und
|
|
|
86
86
|
files: GitFile[];
|
|
87
87
|
};
|
|
88
88
|
}>;
|
|
89
|
-
export declare function gitWorktreeCommittedDiff(root: string, base: GitWorktree | undefined, path: string): Promise<{
|
|
89
|
+
export declare function gitWorktreeCommittedDiff(root: string, base: GitWorktree | undefined, path: string, fullContext?: boolean): Promise<{
|
|
90
90
|
path: string;
|
|
91
91
|
staged: boolean;
|
|
92
92
|
kind: "text";
|
|
@@ -122,7 +122,7 @@ export declare function gitStagedDraftInput(root: string, cwd: string): Promise<
|
|
|
122
122
|
patch: string;
|
|
123
123
|
truncated: boolean;
|
|
124
124
|
}>;
|
|
125
|
-
export declare function gitDiff(root: string, path: string, staged: boolean): Promise<{
|
|
125
|
+
export declare function gitDiff(root: string, path: string, staged: boolean, fullContext?: boolean): Promise<{
|
|
126
126
|
path: string;
|
|
127
127
|
staged: boolean;
|
|
128
128
|
diff: null;
|
package/dist/server/git.js
CHANGED
|
@@ -140,17 +140,39 @@ export async function gitGraph(root, limit, offset, snapshot, after) {
|
|
|
140
140
|
throw changed();
|
|
141
141
|
return { commits: commits.slice(0, size), snapshot: version, hasMore: commits.length > size };
|
|
142
142
|
}
|
|
143
|
-
const
|
|
144
|
-
|
|
143
|
+
const PATCH_OPTIONS = ["--no-color", "--no-ext-diff", "--no-textconv", "--submodule=short", "--full-index"];
|
|
144
|
+
const HISTORY_DIFF_OPTIONS = [...PATCH_OPTIONS, "--find-renames"];
|
|
145
|
+
const FULL_DIFF_MAX_BYTES = 2 * 1024 * 1024;
|
|
146
|
+
const FULL_DIFF_MAX_LINES = 12_000;
|
|
147
|
+
function patchContext(fullContext) {
|
|
148
|
+
// Any file that fits the full view limits fits within this unified context.
|
|
149
|
+
return fullContext ? "--unified=1000000" : "--unified=3";
|
|
150
|
+
}
|
|
151
|
+
async function readGitDiff(repo, args, fullContext = false) {
|
|
152
|
+
const tooLarge = () => fullContext
|
|
153
|
+
? gitFailure("文件太大,无法一次展开全文。仍可查看改动。", "diff_context_too_large")
|
|
154
|
+
: gitFailure("差异或文件列表超过了查看上限。", "commit_diff_too_large");
|
|
155
|
+
let stdout;
|
|
145
156
|
try {
|
|
146
|
-
|
|
157
|
+
({ stdout } = await git(repo, args, { timeout: 12_000, maxBuffer: fullContext ? FULL_DIFF_MAX_BYTES : undefined }));
|
|
147
158
|
}
|
|
148
159
|
catch (error) {
|
|
149
160
|
if (error.code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") {
|
|
150
|
-
throw
|
|
161
|
+
throw tooLarge();
|
|
151
162
|
}
|
|
152
163
|
throw error;
|
|
153
164
|
}
|
|
165
|
+
if (fullContext) {
|
|
166
|
+
let offset = -1;
|
|
167
|
+
for (let line = 0; line < FULL_DIFF_MAX_LINES; line++) {
|
|
168
|
+
offset = stdout.indexOf("\n", offset + 1);
|
|
169
|
+
if (offset < 0)
|
|
170
|
+
return stdout;
|
|
171
|
+
}
|
|
172
|
+
if (offset < stdout.length - 1)
|
|
173
|
+
throw tooLarge();
|
|
174
|
+
}
|
|
175
|
+
return stdout;
|
|
154
176
|
}
|
|
155
177
|
async function commitSnapshot(root, cwd, revision) {
|
|
156
178
|
if (!COMMIT_HASH.test(revision))
|
|
@@ -164,7 +186,7 @@ async function commitSnapshot(root, cwd, revision) {
|
|
|
164
186
|
const type = await git(repo, ["cat-file", "-t", hash], { timeout: 12_000 }).then(result => result.stdout.trim()).catch(() => "");
|
|
165
187
|
if (type !== "commit")
|
|
166
188
|
throw gitFailure("找不到这个 Git 提交。", "not_found");
|
|
167
|
-
const raw = await
|
|
189
|
+
const raw = await readGitDiff(repo, ["cat-file", "commit", hash]);
|
|
168
190
|
const messageOffset = raw.indexOf("\n\n");
|
|
169
191
|
const message = messageOffset < 0 ? "" : raw.slice(messageOffset + 2).trimEnd();
|
|
170
192
|
const parents = (messageOffset < 0 ? raw : raw.slice(0, messageOffset)).split("\n")
|
|
@@ -172,14 +194,14 @@ async function commitSnapshot(root, cwd, revision) {
|
|
|
172
194
|
if (parents.some(parent => !COMMIT_HASH.test(parent)))
|
|
173
195
|
throw gitFailure("这个提交的父版本记录无效。", "bad_revision");
|
|
174
196
|
const firstParent = parents[0];
|
|
175
|
-
const diff = (options, paths, exact = false) => {
|
|
197
|
+
const diff = (options, paths, exact = false, fullContext = false) => {
|
|
176
198
|
const flags = [...HISTORY_DIFF_OPTIONS, scope ? `--relative=${scope}` : "--no-relative", ...options];
|
|
177
199
|
// An escaped glob matches the file itself, even when that path was a directory in one tree.
|
|
178
200
|
const specs = exact ? paths.map(path => `:(top,glob)${path.replace(/[^/]/gu, "\\$&")}`) : paths;
|
|
179
201
|
const args = firstParent
|
|
180
202
|
? ["diff", ...flags, firstParent, hash, "--", ...specs]
|
|
181
203
|
: ["diff-tree", "--root", "--no-commit-id", "-r", ...flags, hash, "--", ...specs];
|
|
182
|
-
return
|
|
204
|
+
return readGitDiff(repo, exact ? ["--no-literal-pathspecs", ...args] : args, fullContext);
|
|
183
205
|
};
|
|
184
206
|
// Read the parent from the stored commit. A shallow boundary is not a root commit.
|
|
185
207
|
if (firstParent && !await git(repo, ["cat-file", "-e", firstParent], { timeout: 12_000 }).then(() => true, () => false)) {
|
|
@@ -202,7 +224,7 @@ async function commitSnapshot(root, cwd, revision) {
|
|
|
202
224
|
export async function gitCommit(root, cwd, hash) {
|
|
203
225
|
return (await commitSnapshot(root, cwd, hash)).detail;
|
|
204
226
|
}
|
|
205
|
-
export async function gitCommitDiff(root, cwd, hash, path) {
|
|
227
|
+
export async function gitCommitDiff(root, cwd, hash, path, fullContext = false) {
|
|
206
228
|
if (!path || path.includes("\0"))
|
|
207
229
|
throw gitFailure("请选择提交中的变更文件。", "path");
|
|
208
230
|
const { detail, scope, diff } = await commitSnapshot(root, cwd, hash);
|
|
@@ -212,7 +234,7 @@ export async function gitCommitDiff(root, cwd, hash, path) {
|
|
|
212
234
|
throw gitFailure("这个提交在当前目录内没有该文件的差异。", "not_found");
|
|
213
235
|
const paths = (file.previousPath === undefined ? [file.path] : [file.previousPath, file.path])
|
|
214
236
|
.map(name => scope ? `${scope}/${name}` : name);
|
|
215
|
-
const patch = await diff(["--patch"], paths, true);
|
|
237
|
+
const patch = await diff(["--patch", patchContext(fullContext)], paths, true, fullContext);
|
|
216
238
|
const binary = /^Binary files .* differ$/m.test(patch);
|
|
217
239
|
return { path, staged: false, kind: binary ? "binary" : "text", diff: binary ? null : patch };
|
|
218
240
|
}
|
|
@@ -377,12 +399,12 @@ export async function inspectGitWorktree(path, base) {
|
|
|
377
399
|
}
|
|
378
400
|
return { status, comparison: { base: reference.label, ahead, behind, commits: commits.slice(0, WORKTREE_COMMIT_LIMIT), truncated: commits.length > WORKTREE_COMMIT_LIMIT, files } };
|
|
379
401
|
}
|
|
380
|
-
export async function gitWorktreeCommittedDiff(root, base, path) {
|
|
402
|
+
export async function gitWorktreeCommittedDiff(root, base, path, fullContext = false) {
|
|
381
403
|
safePath(root, path);
|
|
382
404
|
const reference = await worktreeComparisonBase(root, base);
|
|
383
405
|
if (!reference)
|
|
384
406
|
return { path, staged: false, kind: "text", diff: "" };
|
|
385
|
-
const
|
|
407
|
+
const stdout = await readGitDiff(root, ["diff", ...PATCH_OPTIONS, patchContext(fullContext), reference.mergeBase, reference.target, "--", path], fullContext);
|
|
386
408
|
if (/^Binary files .* differ$/m.test(stdout))
|
|
387
409
|
return { path, staged: false, kind: "binary", diff: null };
|
|
388
410
|
return { path, staged: false, kind: "text", diff: stdout };
|
|
@@ -461,7 +483,7 @@ export async function gitStagedDraftInput(root, cwd) {
|
|
|
461
483
|
throw gitFailure("没有已暂存的更改", "empty_index");
|
|
462
484
|
return { patch: Buffer.concat(chunks).toString("utf8"), truncated };
|
|
463
485
|
}
|
|
464
|
-
export async function gitDiff(root, path, staged) {
|
|
486
|
+
export async function gitDiff(root, path, staged, fullContext = false) {
|
|
465
487
|
const safe = resolve(root, path);
|
|
466
488
|
if (!safe.startsWith(resolve(root) + sep) || path.includes("\0"))
|
|
467
489
|
throw Object.assign(new Error("文件路径无效"), { code: "path" });
|
|
@@ -471,8 +493,8 @@ export async function gitDiff(root, path, staged) {
|
|
|
471
493
|
throw Object.assign(new Error("文件路径无效"), { code: "path" });
|
|
472
494
|
if (!tracked)
|
|
473
495
|
return { path, staged, diff: null, kind: "untracked" };
|
|
474
|
-
const
|
|
475
|
-
return { path, staged, diff:
|
|
496
|
+
const patch = await readGitDiff(root, ["diff", ...PATCH_OPTIONS, patchContext(fullContext), ...(staged ? ["--cached"] : []), "--", path], fullContext);
|
|
497
|
+
return { path, staged, diff: patch, kind: /^Binary files .* differ$/m.test(patch) ? "binary" : "text" };
|
|
476
498
|
}
|
|
477
499
|
/**
|
|
478
500
|
* The content of a file AS IT WAS COMMITTED, or `null` when there is no such version.
|
|
@@ -1278,6 +1278,7 @@ export function createHttpServer(options) {
|
|
|
1278
1278
|
}
|
|
1279
1279
|
const op = url.searchParams.get("op") ?? "status";
|
|
1280
1280
|
const requestedCwd = url.searchParams.get("cwd");
|
|
1281
|
+
const fullDiff = url.searchParams.get("context") === "full";
|
|
1281
1282
|
if (op.startsWith("worktree") && requestedCwd !== null)
|
|
1282
1283
|
await resolveFileCwd(workspace.path, requestedCwd);
|
|
1283
1284
|
if (op === "worktree-manage") {
|
|
@@ -1330,8 +1331,8 @@ export function createHttpServer(options) {
|
|
|
1330
1331
|
}
|
|
1331
1332
|
const path = await workspacePathFromSession(checkout.path, checkout.path, file);
|
|
1332
1333
|
json(200, url.searchParams.get("comparison") === "committed"
|
|
1333
|
-
? await gitWorktreeCommittedDiff(checkout.path, checkout.base, path)
|
|
1334
|
-
: await gitDiff(checkout.path, path, url.searchParams.get("staged") === "1"));
|
|
1334
|
+
? await gitWorktreeCommittedDiff(checkout.path, checkout.base, path, fullDiff)
|
|
1335
|
+
: await gitDiff(checkout.path, path, url.searchParams.get("staged") === "1", fullDiff));
|
|
1335
1336
|
return;
|
|
1336
1337
|
}
|
|
1337
1338
|
const sessionRoot = await resolveFileCwd(workspace.path, requestedCwd);
|
|
@@ -1350,7 +1351,7 @@ export function createHttpServer(options) {
|
|
|
1350
1351
|
const directory = worktreeId ? "" : cwd;
|
|
1351
1352
|
const hash = url.searchParams.get("hash") ?? "";
|
|
1352
1353
|
json(200, op === "commit-detail" ? await gitCommit(root, directory, hash)
|
|
1353
|
-
: await gitCommitDiff(root, directory, hash, url.searchParams.get("path") ?? ""));
|
|
1354
|
+
: await gitCommitDiff(root, directory, hash, url.searchParams.get("path") ?? "", fullDiff));
|
|
1354
1355
|
return;
|
|
1355
1356
|
}
|
|
1356
1357
|
// Blame is a read with a GET shape: every other verb is refused HERE, before the POST branch
|
|
@@ -1454,7 +1455,7 @@ export function createHttpServer(options) {
|
|
|
1454
1455
|
json(400, { error: "diff 需要 path", code: "bad_path" });
|
|
1455
1456
|
return;
|
|
1456
1457
|
}
|
|
1457
|
-
json(200, await gitDiff(workspace.path, await workspacePathFromSession(workspace.path, sessionRoot, path), url.searchParams.get("staged") === "1"));
|
|
1458
|
+
json(200, await gitDiff(workspace.path, await workspacePathFromSession(workspace.path, sessionRoot, path), url.searchParams.get("staged") === "1", fullDiff));
|
|
1458
1459
|
}
|
|
1459
1460
|
else if (op === "blame") {
|
|
1460
1461
|
const path = url.searchParams.get("path");
|
|
@@ -1487,7 +1488,7 @@ export function createHttpServer(options) {
|
|
|
1487
1488
|
}
|
|
1488
1489
|
else if (code === "not_found")
|
|
1489
1490
|
json(404, { error: message, code: "not_found" });
|
|
1490
|
-
else if (code === "commit_diff_too_large")
|
|
1491
|
+
else if (code === "commit_diff_too_large" || code === "diff_context_too_large")
|
|
1491
1492
|
json(413, { error: message, code });
|
|
1492
1493
|
else if (code === "graph_changed")
|
|
1493
1494
|
json(409, { error: message, code });
|