dsh-oc-desktop 0.3.9 → 0.3.10

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.
@@ -37,6 +37,10 @@ function main() {
37
37
  console.error('dsh-oc-desktop: launcher/main.js missing, reinstall the package.');
38
38
  process.exit(1);
39
39
  }
40
+ // electron.exe binary may be missing when npm global install hit its package cache
41
+ // and skipped electron's postinstall (no dist/). Re-run install.js before booting —
42
+ // it pulls from the local electron cache or the network.
43
+ ensureElectron(electron);
40
44
  // electron.exe brand icon may be lost after `npm install` (electron re-downloads its
41
45
  // exe). Re-inject before the shell starts — electron is not running yet, so the exe
42
46
  // is writable. Taskbar/TaskManager icons come from the exe, so this keeps them right.
@@ -55,6 +59,32 @@ function main() {
55
59
  // Re-inject the brand icon (and DSH Desktop version info) into electron.exe if it was
56
60
  // re-downloaded. Probe ProductName first (fast); inject when it is not 'DSH Desktop'.
57
61
  const injectScript = path.join(__dirname, '..', 'scripts', 'set-exe-icon.ps1');
62
+
63
+ // Ensure the electron binary exists before booting. `npm install -g` can skip
64
+ // electron's postinstall when the npm package cache is warm, leaving dist/ empty;
65
+ // re-running install.js fetches the binary from the local electron cache or network.
66
+ function ensureElectron(electron) {
67
+ if (fs.existsSync(electron)) return; // binary already present
68
+ console.log('dsh-oc-desktop: electron binary missing, running electron/install.js ...');
69
+ const pkgDir = path.resolve(path.dirname(electron), '..');
70
+ const installJs = path.join(pkgDir, 'install.js');
71
+ if (!fs.existsSync(installJs)) {
72
+ console.error(`dsh-oc-desktop: ${installJs} missing, reinstall the package.`);
73
+ process.exit(1);
74
+ }
75
+ try {
76
+ execFileSync(process.execPath, [installJs], { stdio: 'inherit', windowsHide: true });
77
+ } catch (e) {
78
+ console.error(`dsh-oc-desktop: failed to fetch electron binary: ${e && e.message ? e.message : e}`);
79
+ console.error('If this is a network issue, set ELECTRON_MIRROR to a mirror and retry.');
80
+ process.exit(1);
81
+ }
82
+ if (!fs.existsSync(electron)) {
83
+ console.error('dsh-oc-desktop: electron binary still missing after install.js; reinstall the package.');
84
+ process.exit(1);
85
+ }
86
+ }
87
+
58
88
  function ensureInjected(electron) {
59
89
  if (!fs.existsSync(injectScript)) return; // package missing the script — skip silently
60
90
  try {
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.9",
4
+ "version": "0.3.10",
5
5
  "description": "DeepSeek Harness 桌面端插件(Electron 启动器):自绘标题栏/托盘/通知/快捷键/崩溃自愈",
6
6
  "main": "launcher/main.js",
7
7
  "bin": {