@evandu/super-pi 0.1.265 → 0.1.268
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/README.md +8 -1
- package/bin/super-pi.js +11 -5
- package/bin/update-receipt.js +15 -0
- package/desktop/application.cjs +78 -0
- package/desktop/icon.icns +0 -0
- package/desktop/icon.ico +0 -0
- package/desktop/launch.cjs +10 -3
- package/desktop/main.cjs +30 -10
- package/desktop/notifications.cjs +25 -0
- package/desktop/preload.cjs +7 -0
- package/desktop/relaunch.cjs +34 -0
- package/desktop/runtime.cjs +5 -4
- package/desktop/shell-entries.cjs +23 -0
- package/desktop/update-lifecycle.cjs +4 -3
- package/dist/client/.super-pi-client-sources.json +12 -10
- package/dist/client/assets/{CodeMirrorEditor-B2cHfrUS.js → CodeMirrorEditor-CtY_gf8i.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-Bl7XQIDD.js → GitDiffEditor-CtSWZrJJ.js} +1 -1
- package/dist/client/assets/index-BEIuDi2o.js +350 -0
- package/dist/client/index.html +1 -1
- package/dist/server/http-server.js +1 -1
- package/dist/server/managed-http-direct.js +14 -0
- package/dist/server/managed-http-tunnel.js +16 -1
- package/dist/server/runtime.js +5 -5
- package/dist/server/upload.d.ts +3 -1
- package/dist/server/upload.js +3 -1
- package/dist/shared/tool-frame-bridge.d.ts +2 -0
- package/dist/shared/tool-frame-bridge.js +27 -0
- package/package.json +9 -1
- package/scripts/pack-server.mjs +1 -1
- package/scripts/restart-lock.mjs +23 -0
- package/scripts/restart-server.mjs +23 -2
- package/dist/client/assets/index-DW2nd-Cf.js +0 -350
package/README.md
CHANGED
|
@@ -26,9 +26,16 @@ The full package includes the desktop app, local SSH manager, and the complete b
|
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
npm install -g @evandu/super-pi
|
|
29
|
-
super_pi
|
|
29
|
+
super_pi
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
The full package opens the desktop by default, including after `super_pi update`.
|
|
33
|
+
Use `super_pi --browser` to explicitly open the browser, or `super_pi start --no-browser`
|
|
34
|
+
to run only the service. The first launch installs Super Pi.app in `~/Applications` on macOS,
|
|
35
|
+
or creates Desktop and Start Menu shortcuts on Windows. Linux gets an application-menu entry.
|
|
36
|
+
The desktop remembers its sidebar filter, selected conversation, open tabs and unfinished drafts
|
|
37
|
+
when quit and reopened. Browser tabs retain independent working sets.
|
|
38
|
+
|
|
32
39
|
The first desktop launch prepares the Electron runtime automatically, with progress, retries,
|
|
33
40
|
an alternate mirror, and official checksum verification. It caches the runtime in the user's
|
|
34
41
|
data directory across npm upgrades; users do not need to configure a mirror. Closing the window
|
package/bin/super-pi.js
CHANGED
|
@@ -7,6 +7,7 @@ import { dirname, join, resolve } from "node:path";
|
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { pathToFileURL } from "node:url";
|
|
9
9
|
import { npmInstallPrefix } from "./npm-prefix.js";
|
|
10
|
+
import { beginCliUpdate } from "./update-receipt.js";
|
|
10
11
|
|
|
11
12
|
const execFileAsync = promisify(execFile);
|
|
12
13
|
const root = resolve(import.meta.dirname, "..");
|
|
@@ -55,7 +56,7 @@ function options(args) {
|
|
|
55
56
|
const value = {
|
|
56
57
|
port: envPort ?? (Number.isInteger(savedPort) && savedPort > 0 ? savedPort : 3080),
|
|
57
58
|
host: process.env.SUPER_PI_HOST ?? (typeof saved.host === "string" && saved.host ? saved.host : "0.0.0.0"),
|
|
58
|
-
browser:
|
|
59
|
+
browser: false,
|
|
59
60
|
};
|
|
60
61
|
for (let i = 0; i < args.length; i += 1) {
|
|
61
62
|
const arg = args[i];
|
|
@@ -295,6 +296,7 @@ const [raw, ...rest] = process.argv.slice(2);
|
|
|
295
296
|
const implicitStart = raw?.startsWith("-") ?? false;
|
|
296
297
|
const command = implicitStart ? "start" : raw?.toLowerCase();
|
|
297
298
|
const args = implicitStart ? [raw, ...rest] : rest;
|
|
299
|
+
let updateReceipt, updateStep = "installing";
|
|
298
300
|
try {
|
|
299
301
|
if (command === "__complete") { console.log((await import("./completion.js")).completionCandidates(args).join("\n")); process.exit(0); }
|
|
300
302
|
if (command === "completion") {
|
|
@@ -308,7 +310,7 @@ try {
|
|
|
308
310
|
}
|
|
309
311
|
if (command === "help" || raw === "--help" || raw === "-h") { usage(); console.log(" completion [SHELL] Print shell completion (bash, zsh, fish, powershell)"); console.log(" completion install [SHELL] Install completion without changing other profile settings"); process.exit(0); }
|
|
310
312
|
if (command === "desktop" || command === "app") { if (!existsSync(join(root, "desktop", "launch.cjs"))) throw new Error("纯服务包不包含桌面端,请在自己的电脑安装完整包 @evandu/super-pi"); const launcher = await import(pathToFileURL(join(root, "desktop", "launch.cjs")).href); await launcher.default.launchDesktop(args); process.exit(0); }
|
|
311
|
-
else if (!command) { const
|
|
313
|
+
else if (!command) { if (JSON.parse(readFileSync(join(root, "package.json"), "utf8")).name !== "@evandu/super-pi-server") { const launcher = await import(pathToFileURL(join(root, "desktop", "launch.cjs")).href); await launcher.default.launchDesktop(args); console.log("Opened Super Pi desktop"); process.exit(0); } const value = options(args); await start(value); console.log(runningBanner(`http://127.0.0.1:${value.port}`)); process.exit(0); }
|
|
312
314
|
if (command === "autostart" || command === "startup") { const action = args.shift()?.toLowerCase() ?? "status"; const value = options(args); if (action === "enable") await enable(value); else if (action === "disable") await disable(); else if (action === "status") await status(); else throw new Error("Autostart action must be enable, disable, or status."); process.exit(0); }
|
|
313
315
|
if (command === "diagnose" || command === "diagnose-latency") {
|
|
314
316
|
// Local mode isolates runtime setup; --url probes this computer's route to an existing server.
|
|
@@ -351,9 +353,13 @@ try {
|
|
|
351
353
|
}
|
|
352
354
|
if (command === "set") { process.exit(await runSet(args)); }
|
|
353
355
|
if (!["start", "stop", "restart", "update"].includes(command)) throw new Error(`Unknown command: ${command}`);
|
|
354
|
-
if (command === "update") { const packageName = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).name === "@evandu/super-pi-server" ? "@evandu/super-pi-server" : "@evandu/super-pi"; const npm = platform === "win32" ? "npm.cmd" : "npm"; const args = prefix ? ["install", "-g", "--prefix", prefix, "--fetch-timeout=900000", "--fetch-retries=8", "--fetch-retry-maxtimeout=120000", packageName] : ["install", "-g", "--fetch-timeout=900000", "--fetch-retries=8", "--fetch-retry-maxtimeout=120000", packageName]; const child = spawn(npm, args, { stdio: "inherit", shell: platform === "win32", env: process.env }); const code = await new Promise((resolve) => child.on("close", resolve)); if (code !== 0) process.exit(code ?? 1); }
|
|
355
356
|
const value = options(args);
|
|
357
|
+
if (command === "update") { const packageName = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).name === "@evandu/super-pi-server" ? "@evandu/super-pi-server" : "@evandu/super-pi"; const npm = platform === "win32" ? "npm.cmd" : "npm"; const args = prefix ? ["install", "-g", "--prefix", prefix, "--fetch-timeout=900000", "--fetch-retries=8", "--fetch-retry-maxtimeout=120000", packageName] : ["install", "-g", "--fetch-timeout=900000", "--fetch-retries=8", "--fetch-retry-maxtimeout=120000", packageName]; try { updateReceipt = beginCliUpdate(dataDir(), ownVersion().version); } catch { console.warn("无法记录升级进度,终端升级仍将继续。"); } const child = spawn(npm, args, { stdio: "inherit", shell: platform === "win32", env: process.env }); const code = await new Promise((resolve, reject) => { child.once("error", reject); child.once("close", resolve); }); if (code !== 0) { updateReceipt?.("failed", { failure: { step: "installing", message: "npm 升级失败,请查看终端输出。", code: code ?? 1 } }); process.exit(code ?? 1); } updateStep = "restarting"; updateReceipt?.("restarting", { targetVersion: ownVersion().version }); }
|
|
358
|
+
|
|
356
359
|
if (command === "stop") { console.log(await running(value.port) ? (await stop(value.port) ? `Shutdown requested on port ${value.port}.` : "Shutdown request failed.") : `Super Pi is not running on port ${value.port}.`); process.exit(0); }
|
|
357
360
|
if ((command === "restart" || command === "update") && await running(value.port)) { await stop(value.port); await new Promise((resolve) => setTimeout(resolve, 600)); }
|
|
358
|
-
await start(value); const url = `http://127.0.0.1:${value.port}`;
|
|
359
|
-
|
|
361
|
+
await start(value); updateReceipt?.("completed", { targetVersion: ownVersion().version }); const url = `http://127.0.0.1:${value.port}`;
|
|
362
|
+
const desktopAfterUpdate = (command === "update" || command === "restart") && !value.browser && !args.includes("--no-browser") && JSON.parse(readFileSync(join(root, "package.json"), "utf8")).name !== "@evandu/super-pi-server" && (platform !== "linux" || Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY));
|
|
363
|
+
if (desktopAfterUpdate) { process.env.SUPER_PI_DESKTOP_PORT = String(value.port); const launcher = await import(pathToFileURL(join(root, "desktop", "launch.cjs")).href); await launcher.default.launchDesktop([]); console.log(`Opened Super Pi desktop\n${runningBanner(url)}`); }
|
|
364
|
+
else { if (value.browser) openBrowser(url); console.log(value.browser ? `Opened ${url}\n${runningBanner(url)}` : runningBanner(url)); }
|
|
365
|
+
} catch (error) { try { updateReceipt?.("failed", { failure: { step: updateStep, message: "软件更新流程未完成,请查看终端输出并重试。" } }); } catch {} console.error(error instanceof Error ? error.message : String(error)); usage(); process.exit(1); }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync, renameSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
/** Let an already-running desktop distinguish CLI upgrades from unexpected server exits. */
|
|
6
|
+
export function beginCliUpdate(directory, fromVersion) {
|
|
7
|
+
const path = join(directory, "update-status.json");
|
|
8
|
+
const record = { id: randomUUID(), action: "update", phase: "installing", fromVersion, startedAt: new Date().toISOString(), changedAt: new Date().toISOString() };
|
|
9
|
+
const update = (phase, details = {}) => {
|
|
10
|
+
Object.assign(record, details, { phase, changedAt: new Date().toISOString() });
|
|
11
|
+
mkdirSync(directory, { recursive: true }); const temporary = `${path}.${process.pid}.tmp`;
|
|
12
|
+
writeFileSync(temporary, JSON.stringify(record), { mode: 0o600 }); renameSync(temporary, path);
|
|
13
|
+
};
|
|
14
|
+
update("installing"); return update;
|
|
15
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const fs = require('node:fs/promises');
|
|
2
|
+
const { join, resolve, dirname, sep, delimiter } = require('node:path');
|
|
3
|
+
const { homedir } = require('node:os');
|
|
4
|
+
const { createHash } = require('node:crypto');
|
|
5
|
+
const { execFile } = require('node:child_process');
|
|
6
|
+
const { promisify } = require('node:util');
|
|
7
|
+
const { ensureDesktopRuntime } = require('./runtime.cjs');
|
|
8
|
+
|
|
9
|
+
async function ensureDesktopApplication(options = {}) {
|
|
10
|
+
const root = resolve(options.packageRoot || join(__dirname, '..'));
|
|
11
|
+
const platform = options.platform || process.platform, arch = options.arch || require('@electron/get').getHostArch();
|
|
12
|
+
const pkg = JSON.parse(await fs.readFile(join(root, 'package.json'), 'utf8'));
|
|
13
|
+
const electronVersion = JSON.parse(await fs.readFile(require.resolve('electron/package.json'), 'utf8')).version;
|
|
14
|
+
const installRoot = resolve(options.installRoot || process.env.SUPER_PI_DESKTOP_APPLICATION_DIR || (platform === 'darwin' ? join(homedir(), 'Applications') : platform === 'win32' ? join(process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'), 'Programs', 'Super Pi') : join(process.env.XDG_DATA_HOME || join(homedir(), '.local', 'share'), 'super-pi', 'desktop')));
|
|
15
|
+
const manifest = join(installRoot, '.super-pi-desktop-install.json');
|
|
16
|
+
const key = createHash('sha256').update(JSON.stringify({ root, version: pkg.version, electronVersion, platform, arch, bootstrap: 1 })).digest('hex').slice(0, 20);
|
|
17
|
+
const executableRelative = platform === 'darwin' ? 'Super Pi.app/Contents/MacOS/Super Pi' : platform === 'win32' ? `versions/${key}/Super Pi.exe` : `versions/${key}/Super Pi`;
|
|
18
|
+
const executable = join(installRoot, executableRelative);
|
|
19
|
+
const ownershipMarker = directory => join(directory, ...(platform === 'darwin' ? ['Contents', 'Resources'] : []), '.super-pi-application.json');
|
|
20
|
+
const ready = async () => {
|
|
21
|
+
try { const saved = JSON.parse(await fs.readFile(manifest, 'utf8')); await fs.access(executable); return saved.key === key && saved.packageRoot === root; } catch { return false; }
|
|
22
|
+
};
|
|
23
|
+
if (await ready()) return { executable, packaged: true };
|
|
24
|
+
await fs.mkdir(installRoot, { recursive: true });
|
|
25
|
+
const lock = join(installRoot, '.super-pi-install.lock');
|
|
26
|
+
const removeOwned = async path => { if (!resolve(path).startsWith(installRoot + sep)) throw new Error('Refusing application cleanup outside the installation'); await fs.rm(path, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 }); };
|
|
27
|
+
const deadline = Date.now() + 15 * 60_000;
|
|
28
|
+
for (;;) {
|
|
29
|
+
try { await fs.mkdir(lock); await fs.writeFile(join(lock, 'owner.json'), JSON.stringify({ pid: process.pid })); break; }
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error.code !== 'EEXIST') throw error;
|
|
32
|
+
if (await ready()) return { executable, packaged: true };
|
|
33
|
+
try { const owner = JSON.parse(await fs.readFile(join(lock, 'owner.json'), 'utf8')); try { process.kill(owner.pid, 0); } catch (failure) { if (failure.code === 'ESRCH') { await removeOwned(lock); continue; } } } catch { if (Date.now() - (await fs.stat(lock)).mtimeMs > 30_000) { await removeOwned(lock); continue; } }
|
|
34
|
+
if (Date.now() > deadline) throw new Error('另一个启动仍在安装 Super Pi 应用,请稍后重试');
|
|
35
|
+
await new Promise(done => setTimeout(done, 500));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
let stage, backup;
|
|
39
|
+
try {
|
|
40
|
+
if (await ready()) return { executable, packaged: true };
|
|
41
|
+
const log = options.log || console.log;
|
|
42
|
+
log('正在安装 Super Pi 桌面应用与系统入口…');
|
|
43
|
+
stage = await fs.mkdtemp(join(installRoot, '.super-pi-build-'));
|
|
44
|
+
const input = join(stage, 'source'), zipDir = join(stage, 'archive'); await fs.mkdir(input); await fs.mkdir(zipDir);
|
|
45
|
+
await fs.writeFile(join(input, 'package.json'), JSON.stringify({ name: 'super-pi', productName: 'Super Pi', version: pkg.version, main: 'main.cjs' }));
|
|
46
|
+
const node = options.node || process.execPath, main = join(root, 'desktop', 'main.cjs');
|
|
47
|
+
await fs.writeFile(join(input, 'main.cjs'), `const fs=require('node:fs'),path=require('node:path');const node=[process.env.SUPER_PI_NODE_BINARY,${JSON.stringify(node)},'/opt/homebrew/bin/node','/usr/local/bin/node','/usr/bin/node'].find(value=>value&&fs.existsSync(value))||${JSON.stringify(node)};process.env.SUPER_PI_NODE_BINARY=node;process.env.PATH=path.dirname(node)+path.delimiter+(process.env.PATH||'');try{require(${JSON.stringify(main)})}catch(error){require('electron').dialog.showErrorBox('Super Pi','应用安装不可用,请运行 npm install -g @evandu/super-pi 修复。');require('electron').app.quit()}`);
|
|
48
|
+
const archive = options.archive || await ensureDesktopRuntime({ archiveOnly: true, platform, arch, log });
|
|
49
|
+
const zip = join(zipDir, `electron-v${electronVersion}-${platform}-${arch}.zip`);
|
|
50
|
+
try { await fs.link(archive, zip); } catch { await fs.copyFile(archive, zip); }
|
|
51
|
+
const packager = options.packager || (await import('@electron/packager')).packager;
|
|
52
|
+
const outputs = await packager({ dir: input, name: 'Super Pi', executableName: 'Super Pi', platform, arch, electronVersion, electronZipDir: zipDir, out: join(stage, 'output'), overwrite: true, prune: false, asar: false, quiet: true, appBundleId: 'com.evandu.super-pi', helperBundleId: 'com.evandu.super-pi.helper', appCategoryType: 'public.app-category.developer-tools', icon: join(root, 'desktop', platform === 'darwin' ? 'icon.icns' : platform === 'win32' ? 'icon.ico' : 'icon.png') });
|
|
53
|
+
const built = platform === 'darwin' ? join(outputs[0], 'Super Pi.app') : outputs[0];
|
|
54
|
+
await fs.writeFile(ownershipMarker(built), JSON.stringify({ key, packageRoot: root }));
|
|
55
|
+
if (platform === 'darwin' && (options.sign || process.platform === 'darwin')) await (options.sign || promisify(execFile))('/usr/bin/codesign', ['--force', '--deep', '--sign', '-', built], { windowsHide: true });
|
|
56
|
+
const target = platform === 'darwin' ? join(installRoot, 'Super Pi.app') : join(installRoot, 'versions', key);
|
|
57
|
+
await fs.mkdir(dirname(target), { recursive: true });
|
|
58
|
+
try {
|
|
59
|
+
await fs.access(target);
|
|
60
|
+
await fs.access(ownershipMarker(target));
|
|
61
|
+
backup = join(installRoot, `.super-pi-backup-${Date.now()}`); await fs.rename(target, backup);
|
|
62
|
+
} catch (error) { if (error.code !== 'ENOENT') throw error; else if (await fs.stat(target).catch(() => null)) throw new Error('已有同名应用不属于此安装,不会覆盖它'); }
|
|
63
|
+
try { await fs.rename(built, target); }
|
|
64
|
+
catch (error) { if (backup) { await fs.rename(backup, target); backup = undefined; } throw error; }
|
|
65
|
+
let previous;
|
|
66
|
+
try { previous = JSON.parse(await fs.readFile(manifest, 'utf8')).key; } catch { /* First application installation. */ }
|
|
67
|
+
const temporary = `${manifest}.tmp`; await fs.writeFile(temporary, JSON.stringify({ key, packageRoot: root, version: pkg.version, executable, platform, arch })); await fs.rename(temporary, manifest);
|
|
68
|
+
if (backup) { await removeOwned(backup); backup = undefined; }
|
|
69
|
+
if (platform !== 'darwin') for (const item of await fs.readdir(join(installRoot, 'versions'), { withFileTypes: true })) {
|
|
70
|
+
if (!item.isDirectory() || !/^[a-f0-9]{20}$/.test(item.name) || [key, previous].includes(item.name)) continue;
|
|
71
|
+
const old = join(installRoot, 'versions', item.name);
|
|
72
|
+
try { await fs.access(join(old, '.super-pi-application.json')); await removeOwned(old); } catch { /* Keep any old runtime whose files are still held by a running process. */ }
|
|
73
|
+
}
|
|
74
|
+
log(platform === 'darwin' ? '已安装到用户“应用程序”目录:Super Pi.app' : 'Super Pi 桌面应用已就绪');
|
|
75
|
+
return { executable, packaged: true };
|
|
76
|
+
} finally { if (stage) await removeOwned(stage); await removeOwned(lock); }
|
|
77
|
+
}
|
|
78
|
+
module.exports = { ensureDesktopApplication };
|
|
Binary file
|
package/desktop/icon.ico
ADDED
|
Binary file
|
package/desktop/launch.cjs
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { spawn } = require("node:child_process");
|
|
3
3
|
const { join } = require("node:path");
|
|
4
|
-
const {
|
|
4
|
+
const { homedir } = require("node:os");
|
|
5
|
+
const { mkdirSync, openSync, closeSync } = require("node:fs");
|
|
6
|
+
const { ensureDesktopApplication } = require("./application.cjs");
|
|
5
7
|
|
|
6
8
|
async function launchDesktop(args = process.argv.slice(2)) {
|
|
7
|
-
const
|
|
9
|
+
const application = await ensureDesktopApplication();
|
|
8
10
|
const env = { ...process.env }; delete env.ELECTRON_RUN_AS_NODE;
|
|
9
|
-
const
|
|
11
|
+
const logs = join(env.SUPER_PI_DATA_DIR || join(homedir(), '.super-pi'), 'logs');
|
|
12
|
+
mkdirSync(logs, { recursive: true });
|
|
13
|
+
const output = openSync(join(logs, 'desktop.log'), 'a');
|
|
14
|
+
let child;
|
|
15
|
+
try { child = spawn(application.executable, args, { detached: true, stdio: ["ignore", output, output], windowsHide: true, env }); }
|
|
16
|
+
finally { closeSync(output); }
|
|
10
17
|
await new Promise((resolve, reject) => { child.once("spawn", resolve); child.once("error", () => reject(new Error("桌面运行时已准备好,但系统未能启动桌面进程,请检查系统执行权限"))); });
|
|
11
18
|
child.unref();
|
|
12
19
|
}
|
package/desktop/main.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { app, BrowserWindow, Tray, Menu, shell, ipcMain, dialog, nativeImage, nativeTheme } = require("electron");
|
|
1
|
+
const { app, BrowserWindow, Tray, Menu, shell, ipcMain, dialog, nativeImage, nativeTheme, Notification } = require("electron");
|
|
2
2
|
const { spawn, execFile } = require("node:child_process");
|
|
3
3
|
const { promisify } = require("node:util");
|
|
4
4
|
const { readFile, writeFile, mkdir, rm, access } = require("node:fs/promises");
|
|
@@ -7,25 +7,35 @@ const { homedir } = require("node:os");
|
|
|
7
7
|
const { join, resolve } = require("node:path");
|
|
8
8
|
const { macLaunchAgent } = require("./login-item.cjs");
|
|
9
9
|
const { expectedServiceExit, shouldRestartDesktop } = require("./update-lifecycle.cjs");
|
|
10
|
+
const { createDesktopNotifications } = require("./notifications.cjs");
|
|
11
|
+
const { ensureShellEntries } = require("./shell-entries.cjs");
|
|
10
12
|
const desktopVersion = require("../package.json").version;
|
|
11
13
|
|
|
12
14
|
const exec = promisify(execFile), root = resolve(__dirname, "..");
|
|
13
15
|
const dataDir = process.env.SUPER_PI_DATA_DIR || join(homedir(), ".super-pi");
|
|
14
16
|
if (process.env.SUPER_PI_DESKTOP_PROFILE) app.setPath("userData", resolve(process.env.SUPER_PI_DESKTOP_PROFILE));
|
|
15
17
|
app.setName("Super Pi");
|
|
18
|
+
if (!process.env.SUPER_PI_DESKTOP_PROFILE) app.setPath("userData", join(app.getPath("appData"), "Super Pi"));
|
|
16
19
|
if (process.platform === "win32") app.setAppUserModelId("com.evandu.super-pi");
|
|
17
|
-
|
|
20
|
+
if (process.platform === "linux") app.setDesktopName("super-pi.desktop");
|
|
21
|
+
let mainWindow, tray, server, origin, managerHost, quitting = false, ownsServer = false;
|
|
18
22
|
let frameTheme;
|
|
19
23
|
let relaunching = false, updateMonitor;
|
|
24
|
+
const resumedOperation = process.env.SUPER_PI_DESKTOP_RESUMED_OPERATION;
|
|
20
25
|
async function diskVersion() { try { return JSON.parse(await readFile(join(root, "package.json"), "utf8")).version; } catch { return undefined; } }
|
|
21
26
|
async function updateOperation() { try { return JSON.parse(await readFile(join(dataDir, "update-status.json"), "utf8")); } catch { return undefined; } }
|
|
22
|
-
async function restartDesktop() {
|
|
27
|
+
async function restartDesktop(operation) {
|
|
23
28
|
if (relaunching) return;
|
|
24
29
|
const node = await nodeBinary();
|
|
25
30
|
relaunching = true;
|
|
26
|
-
const args = process.argv.slice(2).filter(value => value !== "--hidden");
|
|
31
|
+
const args = process.argv.slice(app.isPackaged ? 1 : 2).filter(value => value !== "--hidden");
|
|
27
32
|
if (!mainWindow?.isVisible()) args.push("--hidden");
|
|
28
|
-
|
|
33
|
+
try {
|
|
34
|
+
await mkdir(join(dataDir, "logs"), { recursive: true });
|
|
35
|
+
await access(join(root, "desktop", "relaunch.cjs"));
|
|
36
|
+
if (operation?.id) process.env.SUPER_PI_DESKTOP_RESUMED_OPERATION = operation.id;
|
|
37
|
+
app.relaunch({ execPath: node, args: [join(root, "desktop", "relaunch.cjs"), JSON.stringify({ root, dataDir, parentPid: process.pid, port: Number(new URL(origin).port), host: managerHost, args, operation })] });
|
|
38
|
+
} catch (error) { relaunching = false; throw error; }
|
|
29
39
|
quitting = true; ownsServer = false;
|
|
30
40
|
setImmediate(() => app.quit());
|
|
31
41
|
}
|
|
@@ -36,7 +46,7 @@ function monitorUpdates() {
|
|
|
36
46
|
checking = true;
|
|
37
47
|
try {
|
|
38
48
|
const [disk, operation, status] = await Promise.all([diskVersion(), updateOperation(), health(Number(new URL(origin).port))]);
|
|
39
|
-
if (shouldRestartDesktop({ desktopVersion, diskVersion: disk, health: status, operation })) await restartDesktop();
|
|
49
|
+
if (shouldRestartDesktop({ desktopVersion, diskVersion: disk, health: status, operation, handledOperation: resumedOperation })) await restartDesktop(operation);
|
|
40
50
|
} catch { /* A running workbench remains available while update status is temporarily unavailable. */ }
|
|
41
51
|
finally { checking = false; }
|
|
42
52
|
}, 1500);
|
|
@@ -57,9 +67,11 @@ async function startManager() {
|
|
|
57
67
|
const port = Number(process.env.SUPER_PI_DESKTOP_PORT || saved.port || 3080);
|
|
58
68
|
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("本地服务端口无效");
|
|
59
69
|
origin = `http://127.0.0.1:${port}`;
|
|
70
|
+
managerHost = process.env.SUPER_PI_HOST || saved.host || "0.0.0.0";
|
|
60
71
|
const running = await health(port);
|
|
61
72
|
if (running) { if (!running.manager) throw new Error(`本地 ${port} 端口正在运行不支持托管的旧服务,请先更新并重启,或选择其他本地端口`); return; }
|
|
62
73
|
const node = await nodeBinary();
|
|
74
|
+
managerHost = "127.0.0.1";
|
|
63
75
|
const env = { ...process.env, SUPER_PI_HOST: "127.0.0.1", SUPER_PI_PORT: String(port), SUPER_PI_DATA_DIR: dataDir };
|
|
64
76
|
delete env.ELECTRON_RUN_AS_NODE;
|
|
65
77
|
server = spawn(node, [join(root, "dist/server/index.js"), `--host=127.0.0.1`, `--port=${port}`], { env, windowsHide: true, stdio: "ignore" });
|
|
@@ -80,11 +92,12 @@ function trusted(event) {
|
|
|
80
92
|
if (!mainWindow || event.sender !== mainWindow.webContents || event.senderFrame !== mainWindow.webContents.mainFrame || !event.senderFrame.url.startsWith(`${origin}/`)) throw new Error("拒绝来自非主界面的桌面调用");
|
|
81
93
|
}
|
|
82
94
|
const startupFile = () => process.platform === "darwin" ? join(homedir(), "Library", "LaunchAgents", "com.evandu.super-pi.desktop.plist") : join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "autostart", "super-pi.desktop");
|
|
83
|
-
async function autoStartStatus() { return process.platform !== "win32" ? existsSync(startupFile()) : app.getLoginItemSettings({ path:
|
|
95
|
+
async function autoStartStatus() { return process.platform !== "win32" ? existsSync(startupFile()) : app.getLoginItemSettings({ path: await nodeBinary(), args: [join(__dirname, "launch.cjs"), "--hidden"] }).openAtLogin; }
|
|
84
96
|
async function setAutoStart(enabled) {
|
|
85
97
|
if (process.platform === "darwin") {
|
|
86
98
|
if (!enabled) { await rm(startupFile(), { force: true }); return; }
|
|
87
|
-
const
|
|
99
|
+
const node = await nodeBinary();
|
|
100
|
+
const content = macLaunchAgent({ executable: node, script: join(__dirname, "launch.cjs"), node, dataDir, path: process.env.PATH });
|
|
88
101
|
await exec("/bin/launchctl", ["enable", `gui/${process.getuid()}/com.evandu.super-pi.desktop`]);
|
|
89
102
|
await mkdir(resolve(startupFile(), ".."), { recursive: true });
|
|
90
103
|
await writeFile(startupFile(), content, { mode: 0o600 });
|
|
@@ -92,15 +105,22 @@ async function setAutoStart(enabled) {
|
|
|
92
105
|
if (!enabled) { await rm(startupFile(), { force: true }); return; }
|
|
93
106
|
const quote = value => `"${String(value).replace(/[\\"$`]/g, "\\$&")}"`;
|
|
94
107
|
await mkdir(resolve(startupFile(), ".."), { recursive: true });
|
|
95
|
-
await writeFile(startupFile(), `[Desktop Entry]\nType=Application\nName=Super Pi\nExec=${[
|
|
96
|
-
} else app.setLoginItemSettings({ openAtLogin: enabled, path:
|
|
108
|
+
await writeFile(startupFile(), `[Desktop Entry]\nType=Application\nName=Super Pi\nExec=${[await nodeBinary(), join(__dirname, "launch.cjs"), "--hidden"].map(quote).join(" ")}\nIcon=${join(__dirname, "icon.png")}\nX-GNOME-Autostart-enabled=true\n`);
|
|
109
|
+
} else app.setLoginItemSettings({ openAtLogin: enabled, path: await nodeBinary(), args: [join(__dirname, "launch.cjs"), "--hidden"] });
|
|
97
110
|
}
|
|
98
111
|
function show() { if (mainWindow?.isMinimized()) mainWindow.restore(); mainWindow?.show(); mainWindow?.focus(); }
|
|
99
112
|
function external(url) { try { const parsed = new URL(url); if (["http:", "https:", "mailto:"].includes(parsed.protocol) && !parsed.username && !parsed.password) void shell.openExternal(parsed.href); } catch {} }
|
|
100
113
|
async function createWindow() {
|
|
114
|
+
await ensureShellEntries({ app, shell, node: await nodeBinary(), root, dataDir });
|
|
101
115
|
const image = nativeImage.createFromPath(join(__dirname, "icon.png"));
|
|
102
116
|
if (process.platform === "darwin") app.dock?.setIcon(image);
|
|
103
117
|
mainWindow = new BrowserWindow({ title: "Super Pi", width: 1500, height: 980, minWidth: 800, minHeight: 560, show: false, icon: image, titleBarStyle: process.platform === "darwin" ? "hiddenInset" : "hidden", titleBarOverlay: process.platform === "darwin" ? undefined : { height: 38 }, trafficLightPosition: process.platform === "darwin" ? { x: 14, y: 12 } : undefined, autoHideMenuBar: true, webPreferences: { preload: join(__dirname, "preload.cjs"), contextIsolation: true, nodeIntegration: false, sandbox: true, webSecurity: true, backgroundThrottling: false } });
|
|
118
|
+
const notifications = createDesktopNotifications({ Notification, icon: join(__dirname, "icon.png"), platform: process.platform, showWindow: show, clicked: id => mainWindow?.webContents.send("super-pi-desktop:notification-click", id) });
|
|
119
|
+
app.once("will-quit", () => notifications.dispose());
|
|
120
|
+
ipcMain.handle("super-pi-desktop:notification-status", event => { trusted(event); return notifications.status(); });
|
|
121
|
+
ipcMain.handle("super-pi-desktop:notification-show", (event, value) => { trusted(event); return notifications.show(value); });
|
|
122
|
+
ipcMain.handle("super-pi-desktop:notification-close", (event, id) => { trusted(event); if (typeof id === "string") notifications.close(id); });
|
|
123
|
+
ipcMain.handle("super-pi-desktop:notification-settings", async event => { trusted(event); const target = process.platform === "win32" ? "ms-settings:notifications" : process.platform === "darwin" ? "x-apple.systempreferences:com.apple.preference.notifications" : undefined; if (!target) return { opened: false }; await shell.openExternal(target); return { opened: true }; });
|
|
104
124
|
mainWindow.on("close", event => { if (!quitting) { event.preventDefault(); mainWindow.hide(); } });
|
|
105
125
|
mainWindow.webContents.on("will-navigate", (event, url) => { if (!url.startsWith(`${origin}/`)) { event.preventDefault(); external(url); } });
|
|
106
126
|
mainWindow.webContents.on("will-attach-webview", event => event.preventDefault());
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function createDesktopNotifications({ Notification, icon, platform, showWindow, clicked }) {
|
|
2
|
+
const live = new Map(); let lastError;
|
|
3
|
+
const status = () => ({ supported: Notification.isSupported(), permission: 'system', application: 'Super Pi', platform, ...(lastError ? { lastError } : {}) });
|
|
4
|
+
const close = id => { const item = live.get(id); live.delete(id); item?.close(); };
|
|
5
|
+
const show = async value => {
|
|
6
|
+
if (!value || typeof value.id !== 'string' || !value.id || value.id.length > 512 || typeof value.title !== 'string' || value.title.length > 160 || typeof value.body !== 'string' || value.body.length > 1000) throw new Error('系统通知参数无效');
|
|
7
|
+
if (!Notification.isSupported()) throw new Error('当前操作系统不支持桌面通知');
|
|
8
|
+
close(value.id);
|
|
9
|
+
if (live.size >= 64) close(live.keys().next().value);
|
|
10
|
+
const notification = new Notification({ title: value.title, body: value.body, icon, timeoutType: 'default' });
|
|
11
|
+
live.set(value.id, notification);
|
|
12
|
+
notification.on('click', () => { showWindow(); clicked(value.id); close(value.id); });
|
|
13
|
+
notification.once('close', () => { if (live.get(value.id) === notification) live.delete(value.id); });
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
let settled = false;
|
|
16
|
+
const finish = (error, state) => { if (settled) return; settled = true; clearTimeout(timer); if (error) reject(error); else resolve({ state }); };
|
|
17
|
+
const timer = setTimeout(() => finish(undefined, 'unknown'), 5000);
|
|
18
|
+
notification.once('show', () => { lastError = undefined; finish(undefined, 'shown'); });
|
|
19
|
+
notification.once('failed', () => { lastError = '操作系统未能显示 Super Pi 通知,请检查系统通知权限及应用签名状态。'; live.delete(value.id); finish(new Error(lastError)); });
|
|
20
|
+
try { notification.show(); } catch { lastError = '桌面通知发送失败,请检查操作系统的通知设置。'; live.delete(value.id); finish(new Error(lastError)); }
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
return { status, show, close, dispose: () => { for (const id of [...live.keys()]) close(id); } };
|
|
24
|
+
}
|
|
25
|
+
module.exports = { createDesktopNotifications };
|
package/desktop/preload.cjs
CHANGED
|
@@ -6,6 +6,13 @@ if (process.isMainFrame) {
|
|
|
6
6
|
openBrowser: () => ipcRenderer.invoke("super-pi-desktop:browser"),
|
|
7
7
|
minimize: () => ipcRenderer.invoke("super-pi-desktop:minimize"),
|
|
8
8
|
restart: () => ipcRenderer.invoke("super-pi-desktop:restart"),
|
|
9
|
+
notifications: Object.freeze({
|
|
10
|
+
status: () => ipcRenderer.invoke("super-pi-desktop:notification-status"),
|
|
11
|
+
show: value => ipcRenderer.invoke("super-pi-desktop:notification-show", value),
|
|
12
|
+
close: id => ipcRenderer.invoke("super-pi-desktop:notification-close", id),
|
|
13
|
+
openSettings: () => ipcRenderer.invoke("super-pi-desktop:notification-settings"),
|
|
14
|
+
onClick: callback => { const listener = (_event, id) => callback(id); ipcRenderer.on("super-pi-desktop:notification-click", listener); return () => ipcRenderer.removeListener("super-pi-desktop:notification-click", listener); },
|
|
15
|
+
}),
|
|
9
16
|
}));
|
|
10
17
|
window.addEventListener("DOMContentLoaded", () => {
|
|
11
18
|
const root = document.documentElement;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const { spawn } = require('node:child_process');
|
|
2
|
+
const { join, resolve } = require('node:path');
|
|
3
|
+
const { mkdirSync, openSync, closeSync, appendFileSync } = require('node:fs');
|
|
4
|
+
const delay = ms => new Promise(done => setTimeout(done, ms));
|
|
5
|
+
|
|
6
|
+
async function resumeDesktop(job, dependencies = {}) {
|
|
7
|
+
const alive = dependencies.alive || (pid => { try { process.kill(pid, 0); return true; } catch { return false; } });
|
|
8
|
+
const wait = dependencies.wait || delay;
|
|
9
|
+
const deadline = Date.now() + 20_000;
|
|
10
|
+
while (alive(job.parentPid)) { if (Date.now() >= deadline) throw new Error('旧桌面进程未退出,已取消重复启动。'); await wait(100); }
|
|
11
|
+
if (job.operation?.phase === 'restarting') {
|
|
12
|
+
await (dependencies.restart || (async () => {
|
|
13
|
+
const env = { ...process.env, SUPER_PI_HOST: job.host, SUPER_PI_PORT: String(job.port), SUPER_PI_DATA_DIR: job.dataDir, SUPER_PI_UPDATE_OPERATION_ID: job.operation.id, SUPER_PI_LOG: join(job.dataDir, 'logs', 'server.log') };
|
|
14
|
+
delete env.ELECTRON_RUN_AS_NODE;
|
|
15
|
+
await new Promise((done, reject) => {
|
|
16
|
+
mkdirSync(join(job.dataDir, 'logs'), { recursive: true });
|
|
17
|
+
const log = openSync(join(job.dataDir, 'logs', 'desktop-restart.log'), 'a');
|
|
18
|
+
let helper;
|
|
19
|
+
try { helper = spawn(process.execPath, [join(job.root, 'scripts', 'restart-server.mjs')], { cwd: job.root, env, windowsHide: true, stdio: ['ignore', log, log] }); }
|
|
20
|
+
finally { closeSync(log); }
|
|
21
|
+
helper.once('error', reject); helper.once('exit', code => code === 0 ? done() : reject(new Error('服务重启失败,请查看 desktop-restart.log 和服务日志。')));
|
|
22
|
+
});
|
|
23
|
+
}))().catch(error => console.error(error.message));
|
|
24
|
+
}
|
|
25
|
+
await (dependencies.launch || (() => require(join(job.root, 'desktop', 'launch.cjs')).launchDesktop(job.args)))();
|
|
26
|
+
}
|
|
27
|
+
module.exports = { resumeDesktop };
|
|
28
|
+
if (require.main === module) {
|
|
29
|
+
const job = JSON.parse(process.argv[2]);
|
|
30
|
+
if (!Number.isInteger(job.parentPid) || job.parentPid <= 0 || !Number.isInteger(job.port) || typeof job.dataDir !== 'string' || resolve(job.root) !== resolve(__dirname, '..') || !Array.isArray(job.args)) throw new Error('Invalid desktop restart handoff');
|
|
31
|
+
mkdirSync(join(job.dataDir, 'logs'), { recursive: true });
|
|
32
|
+
console.log = console.error = (...values) => appendFileSync(join(job.dataDir, 'logs', 'desktop-restart.log'), values.map(String).join(' ') + '\n');
|
|
33
|
+
resumeDesktop(job).catch(error => { console.error(error.message); process.exitCode = 1; });
|
|
34
|
+
}
|
package/desktop/runtime.cjs
CHANGED
|
@@ -28,7 +28,7 @@ async function ensureDesktopRuntime(options = {}) {
|
|
|
28
28
|
const version = metadata.version, platform = options.platform || process.platform, arch = options.arch || getHostArch();
|
|
29
29
|
if (!/^\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(version) || !["darwin", "win32", "linux"].includes(platform) || !["x64", "arm64"].includes(arch)) throw new Error("此系统或 CPU 架构暂不支持桌面运行时");
|
|
30
30
|
const binary = executableFor(platform), dependencyRoot = dirname(metadataPath);
|
|
31
|
-
if (!options.metadata && !options.root && !process.env.SUPER_PI_DESKTOP_RUNTIME_DIR) {
|
|
31
|
+
if (!options.archiveOnly && !options.metadata && !options.root && !process.env.SUPER_PI_DESKTOP_RUNTIME_DIR) {
|
|
32
32
|
try {
|
|
33
33
|
if ((await fs.readFile(join(dependencyRoot, "dist", "version"), "utf8")).trim().replace(/^v/, "") === version && (await fs.readFile(join(dependencyRoot, "path.txt"), "utf8")).trim() === binary && existsSync(join(dependencyRoot, "dist", binary))) return join(dependencyRoot, "dist", binary);
|
|
34
34
|
} catch { /* Missing dependency-side binaries are normal on the first launch. */ }
|
|
@@ -39,7 +39,7 @@ async function ensureDesktopRuntime(options = {}) {
|
|
|
39
39
|
const ready = async () => {
|
|
40
40
|
try { const marker = JSON.parse(await fs.readFile(join(target, ".super-pi-runtime.json"), "utf8")); return marker.version === version && marker.platform === platform && marker.arch === arch && existsSync(join(target, binary)); } catch { return false; }
|
|
41
41
|
};
|
|
42
|
-
if (await ready()) return join(target, binary);
|
|
42
|
+
if (!options.archiveOnly && await ready()) return join(target, binary);
|
|
43
43
|
await fs.mkdir(root, { recursive: true });
|
|
44
44
|
const removeOwned = async path => {
|
|
45
45
|
if (!resolve(path).startsWith(root + sep)) throw new Error("拒绝清理运行时缓存以外的路径");
|
|
@@ -51,7 +51,7 @@ async function ensureDesktopRuntime(options = {}) {
|
|
|
51
51
|
try { await fs.mkdir(lock); await fs.writeFile(join(lock, "owner.json"), JSON.stringify({ pid: process.pid })); break; }
|
|
52
52
|
catch (error) {
|
|
53
53
|
if (error.code !== "EEXIST") throw error;
|
|
54
|
-
if (await ready()) return join(target, binary);
|
|
54
|
+
if (!options.archiveOnly && await ready()) return join(target, binary);
|
|
55
55
|
try { const owner = JSON.parse(await fs.readFile(join(lock, "owner.json"), "utf8")); try { process.kill(owner.pid, 0); } catch (error) { if (error.code === "ESRCH") { await removeOwned(lock); continue; } } }
|
|
56
56
|
catch { if (Date.now() - (await fs.stat(lock).catch(() => ({ mtimeMs: Date.now() }))).mtimeMs > 30_000) { await removeOwned(lock); continue; } }
|
|
57
57
|
if (Date.now() > deadline) throw new Error("另一个桌面启动仍在准备运行时,请稍后重新运行 super_pi desktop");
|
|
@@ -61,7 +61,7 @@ async function ensureDesktopRuntime(options = {}) {
|
|
|
61
61
|
}
|
|
62
62
|
let stage;
|
|
63
63
|
try {
|
|
64
|
-
if (await ready()) return join(target, binary);
|
|
64
|
+
if (!options.archiveOnly && await ready()) return join(target, binary);
|
|
65
65
|
log(`正在准备 Super Pi 桌面运行时 · ${platform}/${arch} · Electron ${version}`);
|
|
66
66
|
const checksums = options.checksums || JSON.parse(await fs.readFile(join(dependencyRoot, "checksums.json"), "utf8"));
|
|
67
67
|
let sources = options.sources || runtimeSources(version, platform, arch);
|
|
@@ -90,6 +90,7 @@ async function ensureDesktopRuntime(options = {}) {
|
|
|
90
90
|
if (archive) break;
|
|
91
91
|
}
|
|
92
92
|
if (!archive) throw new Error("桌面运行时下载失败,已自动尝试备用源。Super Pi 已正确安装,浏览器服务仍可使用;稍后重新运行 super_pi desktop 将继续准备,无需重装或手动配置镜像。");
|
|
93
|
+
if (options.archiveOnly) return archive;
|
|
93
94
|
log("校验已通过,正在安装桌面运行时…");
|
|
94
95
|
stage = await fs.mkdtemp(join(root, `${key}-install-`));
|
|
95
96
|
await extract(archive, { dir: stage });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const fs = require('node:fs/promises');
|
|
2
|
+
const { join, dirname } = require('node:path');
|
|
3
|
+
|
|
4
|
+
async function ensureShellEntries({ app, shell, node, root, dataDir, platform = process.platform, directory = process.env.SUPER_PI_DESKTOP_SHORTCUT_DIRECTORY }) {
|
|
5
|
+
const marker = join(dataDir, 'desktop', 'shell-entries.json');
|
|
6
|
+
try { if (JSON.parse(await fs.readFile(marker, 'utf8')).root === root) return; } catch { /* Install shell entries once for this package location. */ }
|
|
7
|
+
const launcher = join(root, 'desktop', 'launch.cjs');
|
|
8
|
+
if (platform === 'win32') {
|
|
9
|
+
const locations = directory ? [join(directory, 'Desktop'), join(directory, 'Programs')] : [app.getPath('desktop'), join(app.getPath('appData'), 'Microsoft', 'Windows', 'Start Menu', 'Programs')];
|
|
10
|
+
for (const folder of locations) {
|
|
11
|
+
await fs.mkdir(folder, { recursive: true });
|
|
12
|
+
const path = join(folder, 'Super Pi.lnk');
|
|
13
|
+
if (!shell.writeShortcutLink(path, { target: node, args: `"${launcher}"`, cwd: root, icon: join(root, 'desktop', 'icon.ico'), iconIndex: 0, appUserModelId: 'com.evandu.super-pi', description: 'Super Pi' })) throw new Error('无法创建 Super Pi 快捷方式');
|
|
14
|
+
}
|
|
15
|
+
} else if (platform === 'linux') {
|
|
16
|
+
const folder = directory || join(process.env.XDG_DATA_HOME || join(app.getPath('home'), '.local', 'share'), 'applications');
|
|
17
|
+
await fs.mkdir(folder, { recursive: true });
|
|
18
|
+
const quote = value => `"${value.replace(/[\\"$`]/g, '\\$&')}"`;
|
|
19
|
+
await fs.writeFile(join(folder, 'super-pi.desktop'), `[Desktop Entry]\nType=Application\nName=Super Pi\nExec=${[node, launcher].map(quote).join(' ')}\nIcon=${join(root, 'desktop', 'icon.png')}\nCategories=Development;\nTerminal=false\n`, { mode: 0o755 });
|
|
20
|
+
}
|
|
21
|
+
await fs.mkdir(dirname(marker), { recursive: true }); await fs.writeFile(marker, JSON.stringify({ root }));
|
|
22
|
+
}
|
|
23
|
+
module.exports = { ensureShellEntries };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function expectedServiceExit(operation, now = Date.now()) {
|
|
2
2
|
return operation && ["waiting", "installing", "restarting"].includes(operation.phase) && now - Date.parse(operation.changedAt) < 30 * 60_000;
|
|
3
3
|
}
|
|
4
|
-
function shouldRestartDesktop({ desktopVersion, diskVersion, health, operation }) {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
function shouldRestartDesktop({ desktopVersion, diskVersion, health, operation, handledOperation }) {
|
|
5
|
+
if (!operation?.id || operation.id === handledOperation || !expectedServiceExit({ ...operation, phase: 'restarting' })) return false;
|
|
6
|
+
return Boolean(diskVersion && operation.targetVersion === diskVersion && (operation.phase === 'restarting'
|
|
7
|
+
|| operation.phase === 'completed' && diskVersion !== desktopVersion && health?.runningVersion === diskVersion));
|
|
7
8
|
}
|
|
8
9
|
module.exports = { expectedServiceExit, shouldRestartDesktop };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"hash": "
|
|
2
|
+
"hash": "d7d9b7dc04bc8a0a4550af38204c0cac9fb1a92df3ff134e18f0f8b3f759e6f8",
|
|
3
3
|
"files": {
|
|
4
|
-
"src/client/App.tsx": "
|
|
4
|
+
"src/client/App.tsx": "f6ff4c81067f2d2082db44237f265f5ef7e0c6b1c28e856b455b18acc31482c4",
|
|
5
5
|
"src/client/CacheWarmingSettings.tsx": "cce26c4547634b76c08c681a4b9605f884d8502f554f12ff8c30cbd2fd0bd9c0",
|
|
6
6
|
"src/client/CodeMirrorEditor.tsx": "10e4444d606b731a117417b052401f27b5d14ba8d12ff518e31ee188bf66e512",
|
|
7
|
-
"src/client/DesktopPanel.tsx": "
|
|
7
|
+
"src/client/DesktopPanel.tsx": "ffe835f8c350dfc7ff8f2c6c0b820d9188156a68482c640aa59567c3f2c81ddf",
|
|
8
8
|
"src/client/ErrorBoundary.tsx": "d16376f9f6c7cc1fab8590c65a66438127642f7d6bb8023cec53d8a6cc9f3964",
|
|
9
9
|
"src/client/FeishuPanel.tsx": "3b3257da36bf863e004a33a4c1d721db364b4449fb23f0805cb74b973a2ed2da",
|
|
10
10
|
"src/client/FileMentionMenu.tsx": "d400e7afb31008eda49d4b531eceda65a926b877177d0cffd9a8056b55161c3e",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"src/client/ServerConnectionsPanel.tsx": "38cbcfc6556981f5f0370ecc1643ed79a9c95adda164e3a9d9ea4be6f2c2e41d",
|
|
32
32
|
"src/client/SidebarSection.tsx": "579c014caeddd94d21911d7b9eca4ceef930ca13c2baeb7bf5ffba59c2bb0b75",
|
|
33
33
|
"src/client/SlashCommandMenu.tsx": "8b2319da03b55827865fb9b6646f7a820aa26cc460cceeed9fb7edb20ad9ebb7",
|
|
34
|
-
"src/client/SoftwareUpdate.tsx": "
|
|
34
|
+
"src/client/SoftwareUpdate.tsx": "bec0880795bdbce885254ce8326898461b2da93ee1cb554a93bed53ddf89d83e",
|
|
35
35
|
"src/client/SshVerificationForm.tsx": "8d7968822203e2404742f9fb6dde24656c97541628999e1d8cd34c8652c1c23e",
|
|
36
36
|
"src/client/Tabs.tsx": "a6a853b0752f5a96f451de502669fbb7ad4b5c141cb3f6a9cd3b9746797b5649",
|
|
37
37
|
"src/client/TavilyPanel.css": "22d4fb4a1bc95b2e0a96c49b9650a56f1a6cf7cfc3c6bc68564417d2c268e193",
|
|
@@ -64,25 +64,27 @@
|
|
|
64
64
|
"src/client/native-tools.css": "71bbb365a91105be0925acce27f1e1ea5e0c3369aa5137060d2bc426682e113d",
|
|
65
65
|
"src/client/pending-operations.ts": "8a5f9e9711c0f875c8ed194196c218162de5270298dad4091351d41294c859d7",
|
|
66
66
|
"src/client/project-evidence.ts": "3bc5ea85f6b20a19a36cfdd4a958d83dd53b21f3d8f20fae1914a575dfbad3c4",
|
|
67
|
-
"src/client/reader-recovery.ts": "
|
|
68
|
-
"src/client/server-connections.ts": "
|
|
69
|
-
"src/client/server-scope.ts": "
|
|
67
|
+
"src/client/reader-recovery.ts": "a72b6255bc66c5585bc5ec6f9eb6ab5e3cdea0edd7582408a0c2881e6417255f",
|
|
68
|
+
"src/client/server-connections.ts": "64cdc3dd389847324e0e243e067a6a09ec800bdfc68e4204b6f6c7c051217a3d",
|
|
69
|
+
"src/client/server-scope.ts": "bac94044310b832382d981c98b2ca7ca9731ca1ce2b0b384a9a746efec6a2585",
|
|
70
70
|
"src/client/session-tree.ts": "08a14c6611fdd9a72001eb1672060479e7660de5a5d221c7e80036209fd26546",
|
|
71
71
|
"src/client/shared-read-receipts.ts": "3554e6f85c20d2c2228cca02579b1e5bc2c1c9a3fff7caa4421055d564a04e9b",
|
|
72
72
|
"src/client/slash-commands.ts": "4a2cef1eb9517628eadfdc38bca7e3663e4d48090d8b87a8a79de4bfd586e112",
|
|
73
73
|
"src/client/software-update.css": "2df7c45ba0491b8c110481065d07f18992b157ef7124f7bdb2fead8cd33793e4",
|
|
74
74
|
"src/client/styles.css": "47099ff0f5c233836ae279e33f2c6973411428c9709ea1171f8492cd55269cc4",
|
|
75
|
-
"src/client/system-notifications.ts": "
|
|
75
|
+
"src/client/system-notifications.ts": "1c87edfa9879b42f602dc74848723bb9c9a6ce3bfb0d2eaccde9f04fb16bb070",
|
|
76
76
|
"src/client/terminal-emulator.ts": "ffcc4f5fbddaf25cebcc9e03dbe5d7d0ad2c21586f5d169e57c04c82e2308b3b",
|
|
77
|
-
"src/client/theme.tsx": "
|
|
77
|
+
"src/client/theme.tsx": "24bc62a4773b134cdb0f583461024519e62dbc3d8eec2702faa5bcc382171274",
|
|
78
|
+
"src/client/tool-frame-bridge.ts": "74b8afda4fe321101124cadee6e79ada2d733f05af05d4953d0530d3ed3c2a36",
|
|
78
79
|
"src/client/tool-launcher.ts": "9699c9498c905e395bbe89e0e367721ab253b5ec1e318a8093ce6a88c2ff5c29",
|
|
79
80
|
"src/client/tool-sharing.ts": "011212825dbbffe18c8f15aca721c02938ab6273fb5607b072a1e7b8b1853640",
|
|
80
81
|
"src/client/tool-shortcuts.ts": "4422d29ba770af6acef18e66c6be05a9bc021f7323c7ca28bbe7668f26d4adb8",
|
|
81
82
|
"src/client/tools.ts": "58fe41f0edbd490e3fab7f12f258b1dbc2163b653553b03ac61caf1543618e50",
|
|
82
83
|
"src/client/types.ts": "decedc5db2c31c0f27ce5a19a873aaf6d8543ff0e01fdf4e41d3670a45ff0e9a",
|
|
83
84
|
"src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5",
|
|
85
|
+
"src/client/workbench-memory.ts": "72c9b52cc28f8c8e90636c2425f0d14c4b5af1e36bff9bf8ad272d0811e60099",
|
|
84
86
|
"src/client/workbench-navigation.ts": "3b229752a8ce4a45eba7aeff040eb33001413190141f1e9b8e5f38246a1761e2",
|
|
85
87
|
"src/client/workbench-search-panel.css": "6978c03db4f17411e9064242b0ff786a520ee8cf58fe8a9d0ea42872ba3737f0"
|
|
86
88
|
},
|
|
87
|
-
"recordedAt": "2026-11-
|
|
89
|
+
"recordedAt": "2026-11-20T10:11:37.710Z"
|
|
88
90
|
}
|