dsh-oc-desktop 0.3.12 → 0.3.14
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/bin/dsh-desktop.cjs +23 -14
- package/launcher/main.js +10 -1
- package/package.json +15 -2
- package/scripts/postinstall.js +18 -6
package/bin/dsh-desktop.cjs
CHANGED
|
@@ -60,32 +60,41 @@ function main() {
|
|
|
60
60
|
// re-downloaded. Probe ProductName first (fast); inject when it is not 'DSH Desktop'.
|
|
61
61
|
const injectScript = path.join(__dirname, '..', 'scripts', 'set-exe-icon.ps1');
|
|
62
62
|
|
|
63
|
+
// Ordered candidate mirrors; npmmirror can lag a new electron release and 404, so
|
|
64
|
+
// fall back to the official GitHub source. A user-set ELECTRON_MIRROR is tried first.
|
|
65
|
+
function electronMirrors(env) {
|
|
66
|
+
const out = [];
|
|
67
|
+
const push = (m) => { if (m && out.indexOf(m) < 0) out.push(m); };
|
|
68
|
+
push(env && env.ELECTRON_MIRROR);
|
|
69
|
+
push('https://npmmirror.com/mirrors/electron/');
|
|
70
|
+
push('https://github.com/electron/electron/releases/download/');
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
|
|
63
74
|
// Ensure the electron binary exists before booting. `npm install -g` can skip
|
|
64
75
|
// electron's postinstall when the npm package cache is warm, leaving dist/ empty;
|
|
65
76
|
// re-running install.js fetches the binary from the local electron cache or network.
|
|
66
77
|
function ensureElectron(electron) {
|
|
67
78
|
if (fs.existsSync(electron)) return; // binary already present
|
|
68
|
-
console.log('dsh-oc-desktop: electron binary missing, running electron/install.js ...');
|
|
69
79
|
const pkgDir = path.resolve(path.dirname(electron), '..');
|
|
70
80
|
const installJs = path.join(pkgDir, 'install.js');
|
|
71
81
|
if (!fs.existsSync(installJs)) {
|
|
72
82
|
console.error(`dsh-oc-desktop: ${installJs} missing, reinstall the package.`);
|
|
73
83
|
process.exit(1);
|
|
74
84
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
if (!fs.existsSync(electron)) {
|
|
86
|
-
console.error('dsh-oc-desktop: electron binary still missing after install.js; reinstall the package.');
|
|
87
|
-
process.exit(1);
|
|
85
|
+
const mirrors = electronMirrors(process.env);
|
|
86
|
+
let lastErr = null;
|
|
87
|
+
for (const mirror of mirrors) {
|
|
88
|
+
console.log(`dsh-oc-desktop: electron binary missing, trying mirror ${mirror}`);
|
|
89
|
+
const env = Object.assign({}, process.env, { ELECTRON_MIRROR: mirror });
|
|
90
|
+
try {
|
|
91
|
+
execFileSync(process.execPath, [installJs], { stdio: 'inherit', windowsHide: true, env });
|
|
92
|
+
if (fs.existsSync(electron)) return;
|
|
93
|
+
} catch (e) { lastErr = e; }
|
|
88
94
|
}
|
|
95
|
+
console.error(`dsh-oc-desktop: failed to fetch electron binary: ${(lastErr && lastErr.message) ? lastErr.message : 'unknown'}`);
|
|
96
|
+
console.error('Check network / ELECTRON_MIRROR, then retry.');
|
|
97
|
+
process.exit(1);
|
|
89
98
|
}
|
|
90
99
|
|
|
91
100
|
function ensureInjected(electron) {
|
package/launcher/main.js
CHANGED
|
@@ -862,7 +862,16 @@ ipcMain.on('set-window-bg', (_e, color) => {
|
|
|
862
862
|
// 无单独更新:引擎有新版时兼容插件随引擎一起更新,不兼容插件保留;更新前备份旧引擎,可回滚。
|
|
863
863
|
function runCommand(cmd, args) {
|
|
864
864
|
return new Promise((resolve, reject) => {
|
|
865
|
-
|
|
865
|
+
// npx / npm 等是 .cmd shim,Node 的 spawn 在 Windows 无法直接执行(报 ENOENT),
|
|
866
|
+
// 须经 cmd /c 运行(与 spawnEngine / autoBootstrapSource 同款:仅含空白参数加引号)。
|
|
867
|
+
let command = cmd;
|
|
868
|
+
let spawnArgs = args;
|
|
869
|
+
if (process.platform === 'win32') {
|
|
870
|
+
const line = [cmd, ...args].map((a) => (/\s/.test(String(a)) ? `"${String(a).replace(/"/g, '""')}"` : String(a))).join(' ');
|
|
871
|
+
command = process.env.ComSpec || 'cmd.exe';
|
|
872
|
+
spawnArgs = ['/d', '/s', '/c', line];
|
|
873
|
+
}
|
|
874
|
+
const p = spawn(command, spawnArgs, { windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
866
875
|
let out = '';
|
|
867
876
|
p.stdout.on('data', (d) => { out += d; });
|
|
868
877
|
p.stderr.on('data', (d) => { out += d; });
|
package/package.json
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-oc-desktop",
|
|
3
3
|
"productName": "DeepSeek Harness Desktop",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.14",
|
|
5
5
|
"description": "DeepSeek Harness 桌面端插件(Electron 启动器):自绘标题栏/托盘/通知/快捷键/崩溃自愈",
|
|
6
6
|
"main": "launcher/main.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"dsh-desktop": "bin/dsh-desktop.cjs"
|
|
9
9
|
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/FeiJi-9527/dsh.git"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"author": "feiji9527",
|
|
10
18
|
"scripts": {
|
|
11
19
|
"start": "electron .",
|
|
12
20
|
"postinstall": "node scripts/postinstall.js",
|
|
@@ -15,6 +23,11 @@
|
|
|
15
23
|
"dependencies": {
|
|
16
24
|
"electron": "^43.4.0"
|
|
17
25
|
},
|
|
18
|
-
"files": [
|
|
26
|
+
"files": [
|
|
27
|
+
"launcher",
|
|
28
|
+
"bin",
|
|
29
|
+
"assets",
|
|
30
|
+
"scripts"
|
|
31
|
+
],
|
|
19
32
|
"license": "MIT"
|
|
20
33
|
}
|
package/scripts/postinstall.js
CHANGED
|
@@ -9,18 +9,30 @@ const fs = require('node:fs');
|
|
|
9
9
|
const path = require('node:path');
|
|
10
10
|
const { spawnSync } = require('node:child_process');
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const ELECTRON_MIRRORS = [
|
|
13
|
+
'https://npmmirror.com/mirrors/electron/',
|
|
14
|
+
'https://github.com/electron/electron/releases/download/',
|
|
15
|
+
];
|
|
13
16
|
|
|
14
17
|
const electronDir = path.join(__dirname, '..', 'node_modules', 'electron');
|
|
15
18
|
if (!fs.existsSync(path.join(electronDir, 'install.js'))) process.exit(0);
|
|
16
19
|
const exe = path.join(electronDir, 'dist', process.platform === 'win32' ? 'electron.exe' : 'electron');
|
|
17
20
|
if (fs.existsSync(exe)) process.exit(0);
|
|
18
21
|
|
|
19
|
-
console.log('dsh-oc-desktop: electron binary missing, downloading
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
22
|
+
console.log('dsh-oc-desktop: electron binary missing, downloading ...');
|
|
23
|
+
// Try a user-set ELECTRON_MIRROR first, then npmmirror, then the official GitHub source
|
|
24
|
+
// (npmmirror can lag a new electron release and 404). Never fail the install.
|
|
25
|
+
const mirrors = [];
|
|
26
|
+
const push = (m) => { if (m && mirrors.indexOf(m) < 0) mirrors.push(m); };
|
|
27
|
+
push(process.env.ELECTRON_MIRROR);
|
|
28
|
+
for (const m of ELECTRON_MIRRORS) push(m);
|
|
29
|
+
for (const mirror of mirrors) {
|
|
30
|
+
if (fs.existsSync(exe)) break;
|
|
31
|
+
const env = Object.assign({}, process.env, { ELECTRON_MIRROR: mirror });
|
|
32
|
+
const r = spawnSync(process.execPath, [path.join(electronDir, 'install.js')], { stdio: 'inherit', env, windowsHide: true });
|
|
33
|
+
if (r.status === 0 && fs.existsSync(exe)) break;
|
|
34
|
+
}
|
|
35
|
+
if (!fs.existsSync(exe)) {
|
|
24
36
|
console.warn('dsh-oc-desktop: electron binary fetch failed; it will self-heal on first launch.');
|
|
25
37
|
}
|
|
26
38
|
process.exit(0);
|