dsh-oc-desktop 0.3.13 → 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.
@@ -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
- try {
76
- // Default to the npmmirror mirror unless the user set ELECTRON_MIRROR already.
77
- const env = Object.assign({}, process.env);
78
- if (!env.ELECTRON_MIRROR) env.ELECTRON_MIRROR = 'https://npmmirror.com/mirrors/electron/';
79
- execFileSync(process.execPath, [installJs], { stdio: 'inherit', windowsHide: true, env });
80
- } catch (e) {
81
- console.error(`dsh-oc-desktop: failed to fetch electron binary: ${e && e.message ? e.message : e}`);
82
- console.error('If this is a network issue, set ELECTRON_MIRROR to a mirror and retry.');
83
- process.exit(1);
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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-oc-desktop",
3
3
  "productName": "DeepSeek Harness Desktop",
4
- "version": "0.3.13",
4
+ "version": "0.3.14",
5
5
  "description": "DeepSeek Harness 桌面端插件(Electron 启动器):自绘标题栏/托盘/通知/快捷键/崩溃自愈",
6
6
  "main": "launcher/main.js",
7
7
  "bin": {
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/FeiJi-9527/dsh"
12
+ "url": "git+https://github.com/FeiJi-9527/dsh.git"
13
13
  },
14
14
  "publishConfig": {
15
15
  "access": "public"
@@ -23,6 +23,11 @@
23
23
  "dependencies": {
24
24
  "electron": "^43.4.0"
25
25
  },
26
- "files": ["launcher", "bin", "assets", "scripts"],
26
+ "files": [
27
+ "launcher",
28
+ "bin",
29
+ "assets",
30
+ "scripts"
31
+ ],
27
32
  "license": "MIT"
28
33
  }
@@ -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 ELECTRON_MIRROR_DEFAULT = 'https://npmmirror.com/mirrors/electron/';
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 (mirror) ...');
20
- const env = Object.assign({}, process.env);
21
- if (!env.ELECTRON_MIRROR) env.ELECTRON_MIRROR = ELECTRON_MIRROR_DEFAULT;
22
- const r = spawnSync(process.execPath, [path.join(electronDir, 'install.js')], { stdio: 'inherit', env, windowsHide: true });
23
- if (r.status !== 0 || !fs.existsSync(exe)) {
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);