@evandu/super-pi 0.1.292 → 0.1.293

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.
@@ -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-Cwt3-oUx.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-MxsSEfDh.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
13
- <link rel="stylesheet" crossorigin href="/assets/index-C3aSjjM8.css">
13
+ <link rel="stylesheet" crossorigin href="/assets/index-B2HH9caF.css">
14
14
  </head>
15
15
  <body>
16
16
  <div id="root"></div>
@@ -86,9 +86,9 @@ function parseGitCommits(raw) {
86
86
  }
87
87
  const COMMIT_HASH = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i;
88
88
  export async function gitGraph(root, limit, offset, snapshot, after, knownSnapshot = "") {
89
- const size = pageNumber(limit, 50, 1, 100);
90
- const start = pageNumber(offset, 0, 0, 2_147_483_647);
91
- const repo = await worktreeRoot(root);
89
+ return readGitGraph(root, limit, offset, snapshot, after, knownSnapshot, 1);
90
+ }
91
+ async function graphSnapshot(repo) {
92
92
  const [refs, checkout] = await Promise.all([
93
93
  git(repo, ["for-each-ref", "--format=%(refname)%00%(objectname)%00%(*objectname)%00%(symref)"], { maxBuffer: 32 * 1024 * 1024, timeout: 12_000 }),
94
94
  gitWorktrees(repo),
@@ -96,6 +96,13 @@ export async function gitGraph(root, limit, offset, snapshot, after, knownSnapsh
96
96
  const worktrees = checkout.worktrees.filter(entry => !entry.missing && COMMIT_HASH.test(entry.head) && !/^0+$/.test(entry.head));
97
97
  const heads = worktrees.map(({ id, branch, head, current, name }) => ({ id, branch, head, current, name }));
98
98
  const version = createHash("sha256").update(refs.stdout).update(JSON.stringify(heads)).digest("hex");
99
+ return { refs, worktrees, version };
100
+ }
101
+ async function readGitGraph(root, limit, offset, snapshot, after, knownSnapshot, retries) {
102
+ const size = pageNumber(limit, 50, 1, 100);
103
+ const start = pageNumber(offset, 0, 0, 2_147_483_647);
104
+ const repo = await worktreeRoot(root);
105
+ const { refs, worktrees, version } = await graphSnapshot(repo);
99
106
  const changed = () => gitFailure("提交图已变化,请刷新后继续查看。", "graph_changed");
100
107
  if (start && snapshot !== version)
101
108
  throw changed();
@@ -134,6 +141,12 @@ export async function gitGraph(root, limit, offset, snapshot, after, knownSnapsh
134
141
  const format = "--format=%H%x00%h%x00%P%x00%s%x00%an%x00%aI";
135
142
  const { stdout } = await git(repo, ["-c", "log.showSignature=false", "log", "--all", "--topo-order", "--no-notes", "--no-decorate",
136
143
  "--no-patch", "--encoding=UTF-8", "-z", `--skip=${start - overlap}`, `-${size + 1 + overlap}`, format, ...detached, "--"], { timeout: 12_000 });
144
+ // Git refs may change between separate commands; never cache a mixed snapshot.
145
+ if ((await graphSnapshot(repo)).version !== version) {
146
+ if (!start && retries > 0)
147
+ return readGitGraph(root, limit, offset, snapshot, after, knownSnapshot, retries - 1);
148
+ throw changed();
149
+ }
137
150
  const parts = stdout.split("\0");
138
151
  const commits = [];
139
152
  for (let index = 0; index + 5 < parts.length; index += 6) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "superPi": {
4
4
  "managedDirectListener": true
5
5
  },
6
- "version": "0.1.292",
6
+ "version": "0.1.293",
7
7
  "description": "Web control plane and companion for Pi",
8
8
  "license": "MIT",
9
9
  "type": "module",
@@ -1,4 +0,0 @@
1
- {
2
- "hash": "fbeb24e67e46a763464b1eac1c2dd31bde1876ff35269f98e4d69b3abc268910",
3
- "recordedAt": "2026-11-25T05:54:55.034Z"
4
- }