@evandu/super-pi 0.1.251 → 0.1.252

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-Oui62h72.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-D2IVVBA_.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
13
- <link rel="stylesheet" crossorigin href="/assets/index-Dmv5LIfM.css">
13
+ <link rel="stylesheet" crossorigin href="/assets/index-CAB3S_vd.css">
14
14
  </head>
15
15
  <body>
16
16
  <div id="root"></div>
@@ -27,7 +27,7 @@ import { GroupChatNotFoundError } from "./application/group-chat-service.js";
27
27
  import { MAX_FEISHU_REQUEST_BYTES } from "./application/feishu-service.js";
28
28
  import { MAX_WEB_REQUEST_BYTES } from "./web.js";
29
29
  import { MAX_TOOL_BODY_BYTES } from "./tool-registry.js";
30
- import { claimUpdateSlot, packageUpdateArgs, releaseUpdateSlot, shellArgs } from "./update.js";
30
+ import { claimUpdateSlot, fetchLatestPackageVersion, packageUpdateArgs, releaseUpdateSlot, shellArgs } from "./update.js";
31
31
  import { UpdateTracker } from "./update-status.js";
32
32
  import { updateIsActive } from "../shared/update-status.js";
33
33
  import { FileIndex, refreshWorkspaceIndex } from "./file-index.js";
@@ -1456,13 +1456,7 @@ export function createHttpServer(options) {
1456
1456
  return;
1457
1457
  }
1458
1458
  try {
1459
- const response = await fetch("https://registry.npmjs.org/@evandu/super-pi/latest", { signal: AbortSignal.timeout(10_000) });
1460
- if (!response.ok)
1461
- throw new Error(`npm registry HTTP ${response.status}`);
1462
- const remoteVersion = await response.json();
1463
- const latestVersion = typeof remoteVersion.version === "string" ? remoteVersion.version : undefined;
1464
- if (!latestVersion)
1465
- throw new Error("npm registry did not report a version");
1459
+ const latestVersion = await fetchLatestPackageVersion();
1466
1460
  const status = updateStatus();
1467
1461
  json(200, { ...status, latestVersion, updateAvailable: !status.updating && latestVersion !== status.diskVersion });
1468
1462
  }
@@ -14,6 +14,8 @@
14
14
  export declare function quoteForShell(value: string): string;
15
15
  /** The arguments to hand to npm, quoted for the shell when the shell is what runs them. */
16
16
  export declare function shellArgs(args: string[]): string[];
17
+ /** Check the release registry with a package-sized timeout and bounded retries for transient failures. */
18
+ export declare function fetchLatestPackageVersion(): Promise<string>;
17
19
  /**
18
20
  * Return npm's install arguments for the package that is actually running.
19
21
  *
@@ -19,6 +19,28 @@ export function quoteForShell(value) {
19
19
  export function shellArgs(args) {
20
20
  return process.platform === "win32" ? args.map(quoteForShell) : args;
21
21
  }
22
+ /** Check the release registry with a package-sized timeout and bounded retries for transient failures. */
23
+ export async function fetchLatestPackageVersion() {
24
+ let lastError;
25
+ for (let attempt = 0; attempt < 3; attempt++) {
26
+ try {
27
+ const response = await fetch("https://registry.npmjs.org/@evandu/super-pi/latest", { signal: AbortSignal.timeout(20_000) });
28
+ if (!response.ok)
29
+ throw new Error(`npm registry HTTP ${response.status}`);
30
+ const payload = await response.json();
31
+ if (typeof payload.version !== "string" || !/^\d+\.\d+\.\d+(?:-[a-z0-9.-]+)?(?:\+[a-z0-9.-]+)?$/iu.test(payload.version)) {
32
+ throw new Error("npm registry did not report a valid version");
33
+ }
34
+ return payload.version;
35
+ }
36
+ catch (error) {
37
+ lastError = error;
38
+ if (attempt < 2)
39
+ await new Promise((resolve) => setTimeout(resolve, 750 * (attempt + 1)));
40
+ }
41
+ }
42
+ throw lastError instanceof Error ? lastError : new Error("npm registry request failed");
43
+ }
22
44
  /**
23
45
  * Return npm's install arguments for the package that is actually running.
24
46
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evandu/super-pi",
3
- "version": "0.1.251",
3
+ "version": "0.1.252",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",