dsh-desktop-enhance 0.9.0 → 0.9.2
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/lib/index.js +21 -14
- package/lib/installer.mjs +8 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import * as nodeInspector from "node:inspector";
|
|
6
6
|
import { spawn } from "node:child_process";
|
|
7
|
-
import { createWriteStream } from "node:fs";
|
|
7
|
+
import { createWriteStream, rmSync } from "node:fs";
|
|
8
8
|
import { mkdir, readFile, realpath, rm } from "node:fs/promises";
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import { basename, dirname, join } from "node:path";
|
|
@@ -3497,6 +3497,19 @@ const FEED_URL = "https://download.deepseek.com/dsh-desk/feeds/mac-arm64/nightly
|
|
|
3497
3497
|
function errorCode(error, fallback) {
|
|
3498
3498
|
return error instanceof Error && /^[A-Z][A-Z0-9_]+$/u.test(error.message) ? error.message : fallback;
|
|
3499
3499
|
}
|
|
3500
|
+
function removeStageDir(target) {
|
|
3501
|
+
const proc = process;
|
|
3502
|
+
const previous = proc.noAsar;
|
|
3503
|
+
proc.noAsar = true;
|
|
3504
|
+
try {
|
|
3505
|
+
rmSync(target, {
|
|
3506
|
+
recursive: true,
|
|
3507
|
+
force: true
|
|
3508
|
+
});
|
|
3509
|
+
} finally {
|
|
3510
|
+
proc.noAsar = previous;
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3500
3513
|
function createUpdateEngine(deps) {
|
|
3501
3514
|
let state = {
|
|
3502
3515
|
phase: "idle",
|
|
@@ -3562,10 +3575,7 @@ function createUpdateEngine(deps) {
|
|
|
3562
3575
|
try {
|
|
3563
3576
|
if (!entry.url) throw new Error("FEED_WITHOUT_URL");
|
|
3564
3577
|
if (!entry.sha512) throw new Error("FEED_WITHOUT_SHA512");
|
|
3565
|
-
|
|
3566
|
-
recursive: true,
|
|
3567
|
-
force: true
|
|
3568
|
-
});
|
|
3578
|
+
removeStageDir(deps.stageDir);
|
|
3569
3579
|
await mkdir(deps.stageDir, {
|
|
3570
3580
|
recursive: true,
|
|
3571
3581
|
mode: 448
|
|
@@ -3595,10 +3605,7 @@ function createUpdateEngine(deps) {
|
|
|
3595
3605
|
});
|
|
3596
3606
|
} catch (error) {
|
|
3597
3607
|
try {
|
|
3598
|
-
|
|
3599
|
-
recursive: true,
|
|
3600
|
-
force: true
|
|
3601
|
-
});
|
|
3608
|
+
removeStageDir(deps.stageDir);
|
|
3602
3609
|
} catch {
|
|
3603
3610
|
return set({
|
|
3604
3611
|
...state,
|
|
@@ -3789,7 +3796,8 @@ function productionDeps(ctx, currentVersion, locations = defaultLocations()) {
|
|
|
3789
3796
|
cwd: dirname(app),
|
|
3790
3797
|
env: {
|
|
3791
3798
|
...process.env,
|
|
3792
|
-
ELECTRON_RUN_AS_NODE: "1"
|
|
3799
|
+
ELECTRON_RUN_AS_NODE: "1",
|
|
3800
|
+
ELECTRON_NO_ASAR: "1"
|
|
3793
3801
|
}
|
|
3794
3802
|
});
|
|
3795
3803
|
let settled = false;
|
|
@@ -3847,10 +3855,9 @@ function json(body, status = 200) {
|
|
|
3847
3855
|
}
|
|
3848
3856
|
function registerUpdateRoute(ctx, load = async () => {
|
|
3849
3857
|
const locations = defaultLocations();
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
}).catch(() => {});
|
|
3858
|
+
try {
|
|
3859
|
+
removeStageDir(locations.stageDir);
|
|
3860
|
+
} catch {}
|
|
3854
3861
|
return createUpdateEngine(productionDeps(ctx, await readInstalledVersion(locations.app), locations));
|
|
3855
3862
|
}) {
|
|
3856
3863
|
const connection = ctx.get("connection");
|
package/lib/installer.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { spawn } from 'node:child_process'
|
|
|
4
4
|
import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path'
|
|
5
5
|
import { fileURLToPath } from 'node:url'
|
|
6
6
|
|
|
7
|
+
process.noAsar = true
|
|
7
8
|
const CODES = new Set(['INVALID_INPUT', 'INVALID_VERSION', 'INVALID_PATH', 'APP_MISSING', 'STAGED_MISSING', 'STAGED_VERSION_MISMATCH', 'STAGING_CROSS_DEVICE', 'SIGNATURE_IDENTITY_UNAVAILABLE', 'INSTALLED_SIGNATURE_INVALID', 'STAGED_SIGNATURE_INVALID', 'BACKUP_EXISTS', 'FAILED_EXISTS', 'LOG_UNAVAILABLE', 'IPC_FAILED', 'INSTALL_NOT_COMMITTED', 'COMMIT_TIMEOUT', 'INVALID_COMMIT', 'APP_QUERY_FAILED', 'APP_DID_NOT_EXIT', 'STOP_FAILED', 'BACKUP_FAILED', 'REPLACE_FAILED', 'NEW_APP_NOT_READY', 'ROLLED_BACK', 'ROLLBACK_STOP_FAILED', 'ROLLBACK_RESTORE_FAILED', 'ROLLBACK_LAUNCH_FAILED', 'INSTALL_FAILED'])
|
|
8
9
|
const failure = code => Object.assign(new Error(code), { code })
|
|
9
10
|
const errorCode = (error, fallback = 'INSTALL_FAILED') => CODES.has(error?.code) ? error.code : fallback
|
|
@@ -25,9 +26,10 @@ async function canonicalPath(path, mayCreate = false) {
|
|
|
25
26
|
if (await realpath(ancestor) !== ancestor) throw failure('INVALID_PATH')
|
|
26
27
|
return path
|
|
27
28
|
}
|
|
29
|
+
const cleanEnv = Object.fromEntries(Object.entries(process.env).filter(([key]) => !/^(?:ELECTRON_|DSH_|NODE_)/u.test(key)))
|
|
28
30
|
function run(command, args, timeoutMs = 30000) {
|
|
29
31
|
return new Promise(resolve => {
|
|
30
|
-
const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'pipe'] })
|
|
32
|
+
const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'pipe'], env: cleanEnv })
|
|
31
33
|
let stdout = '', stderr = ''
|
|
32
34
|
const timer = setTimeout(() => child.kill('SIGKILL'), timeoutMs)
|
|
33
35
|
child.stdout.on('data', chunk => { stdout += chunk })
|
|
@@ -84,7 +86,7 @@ async function handoff() {
|
|
|
84
86
|
}
|
|
85
87
|
async function appPids(app) {
|
|
86
88
|
const pattern = `${app}/Contents/`.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&')
|
|
87
|
-
const result = await run('pgrep', ['-f', pattern])
|
|
89
|
+
const result = await run('pgrep', ['-a', '-f', pattern])
|
|
88
90
|
if (result.code === 1) return []
|
|
89
91
|
if (result.code !== 0) throw failure('APP_QUERY_FAILED')
|
|
90
92
|
const pids = result.stdout.trim().split('\n').filter(Boolean).map(Number)
|
|
@@ -142,6 +144,10 @@ async function install(input, emit) {
|
|
|
142
144
|
if (replaced) {
|
|
143
145
|
if (await exists(input.failed)) throw failure('ROLLBACK_RESTORE_FAILED')
|
|
144
146
|
await rename(input.app, input.failed)
|
|
147
|
+
try {
|
|
148
|
+
const staging = await lstat(input.stageDir)
|
|
149
|
+
if (staging.dev === input.stagingDirectory.dev && staging.ino === input.stagingDirectory.ino && await realpath(input.stageDir) === input.stageDir) await rm(input.stageDir, { recursive: true })
|
|
150
|
+
} catch {}
|
|
145
151
|
}
|
|
146
152
|
if (backedUp) await rename(input.backup, input.app)
|
|
147
153
|
} catch { return { ok: false, code: 'ROLLBACK_RESTORE_FAILED' } }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-desktop-enhance",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "DSH Desktop 界面增强:页内查找(Cmd+F)、轮次编号、上下文压缩行常显、建议、每步耗时、折叠文件夹状态计数、会话信息(含上下文注入 C1 视图)、工具管理、Skill 管理、独立远程接入与手机体验,以及智能建议、会话能力和远程接入的持久诊断日志。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "./icon.svg",
|