cicy-desktop 2.1.85 → 2.1.87

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/cicy-desktop CHANGED
@@ -40,10 +40,73 @@ function globalElectronBin() {
40
40
  return _globalElectronBin;
41
41
  }
42
42
 
43
+ // Pinned electron version = the one cicy-desktop is built against (package.json
44
+ // dependency). NEVER install "latest": its native extract-zip prebuild is
45
+ // unpublished for win32-x64 → `npm i -g electron` dies with "Cannot find native
46
+ // binding". 41.x downloads fine.
47
+ const ELECTRON_VERSION = (() => {
48
+ try {
49
+ const pj = require("../package.json");
50
+ const v = (pj.dependencies && pj.dependencies.electron) ||
51
+ (pj.devDependencies && pj.devDependencies.electron) || "";
52
+ return String(v).replace(/^[\^~>=\s]*/, "").trim() || "41.0.3";
53
+ } catch { return "41.0.3"; }
54
+ })();
55
+
56
+ // True iff <electronDir> has a downloaded, runnable binary (path.txt → dist/exe).
57
+ function electronBinaryHealthy(electronDir) {
58
+ if (!electronDir) return false;
59
+ try {
60
+ const exe = fs.readFileSync(path.join(electronDir, "path.txt"), "utf8").trim();
61
+ return !!exe && fs.existsSync(path.join(electronDir, "dist", exe));
62
+ } catch { return false; }
63
+ }
64
+
65
+ // The GLOBAL electron's package dir for the current npm prefix (null if none).
66
+ function globalElectronDir() {
67
+ try {
68
+ const prefix = execSync("npm prefix -g", { stdio: ["ignore", "pipe", "ignore"] }).toString().trim();
69
+ if (!prefix) return null;
70
+ return isWindows
71
+ ? path.join(prefix, "node_modules", "electron") // win: <prefix>\node_modules\electron
72
+ : path.join(prefix, "lib", "node_modules", "electron"); // unix: <prefix>/lib/node_modules/electron
73
+ } catch { return null; }
74
+ }
75
+
76
+ // Make sure a USABLE electron exists before spawning the worker. Prefer a shared
77
+ // GLOBAL electron (downloaded once, survives npx-cache eviction, and
78
+ // resolveElectronSpawn() picks it first). If nothing healthy is found anywhere,
79
+ // auto-install the PINNED version GLOBALLY with the npmmirror mirror — i.e. do the
80
+ // `npm i -g electron@<pin>` step for the user, so a fresh `npx cicy-desktop`
81
+ // self-provisions electron and starts first-try. Runs once per process.
82
+ let _electronEnsured = false;
83
+ function ensureElectron() {
84
+ if (_electronEnsured) return;
85
+ _electronEnsured = true;
86
+ // Already usable (global, or the resolvable bundled/npx copy)? nothing to do.
87
+ if (electronBinaryHealthy(globalElectronDir())) return;
88
+ let bundledDir = null;
89
+ try { bundledDir = path.dirname(require.resolve("electron/package.json", { paths: [PACKAGE_ROOT] })); } catch {}
90
+ if (electronBinaryHealthy(bundledDir)) return;
91
+ // None usable → install the pinned electron globally (with the mirror).
92
+ console.log(`⚙️ No usable Electron — installing electron@${ELECTRON_VERSION} -g (mirror), one-time…`);
93
+ try {
94
+ execSync(`npm i -g electron@${ELECTRON_VERSION} --registry=${NPM_REGISTRY}`, {
95
+ stdio: "inherit",
96
+ env: { ...process.env, ELECTRON_MIRROR, npm_config_registry: NPM_REGISTRY },
97
+ });
98
+ _globalElectronBin = undefined; // bust the memo so resolveElectronSpawn re-finds the new global bin
99
+ } catch (e) {
100
+ console.warn(`⚠️ Global electron install failed: ${e.message}`);
101
+ console.warn(` Fix manually: set ELECTRON_MIRROR=${ELECTRON_MIRROR} && npm i -g electron@${ELECTRON_VERSION}`);
102
+ }
103
+ }
104
+
43
105
  // Resolve the electron binary to spawn. Order: (C) a shared GLOBAL electron,
44
106
  // then the project-local copy, then `npx electron` as a last resort.
45
107
  // Windows uses `npx.cmd electron` to handle the shim correctly.
46
108
  function resolveElectronSpawn() {
109
+ ensureElectron();
47
110
  const g = globalElectronBin();
48
111
  if (g) return { cmd: g, prefixArgs: [] };
49
112
  if (isWindows) return { cmd: "npx.cmd", prefixArgs: ["electron"] };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cicy-desktop",
3
- "version": "2.1.85",
3
+ "version": "2.1.87",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {
@@ -133,11 +133,11 @@
133
133
  },
134
134
  "//optionalDependencies": "Runtime Bundle v1 (主人指令): platform binaries delivered by `npm i -g cicy-desktop` itself — npm installs only the current-platform subpackage (os/cpu pinned in each), so first start seeds the runtime store with ZERO network, ZERO npx. Windows packages are named *-windows-* (npm spam filter 403s new names containing win32). cicy-msys2 added once published.",
135
135
  "optionalDependencies": {
136
- "cicy-code-darwin-x64": "2.3.4",
137
- "cicy-code-darwin-arm64": "2.3.4",
138
- "cicy-code-linux-x64": "2.3.4",
139
- "cicy-code-linux-arm64": "2.3.4",
140
- "cicy-code-windows-x64": "2.3.4",
136
+ "cicy-code-darwin-x64": "2.3.7",
137
+ "cicy-code-darwin-arm64": "2.3.7",
138
+ "cicy-code-linux-x64": "2.3.7",
139
+ "cicy-code-linux-arm64": "2.3.7",
140
+ "cicy-code-windows-x64": "2.3.7",
141
141
  "cicy-mihomo-darwin-x64": "1.10.4",
142
142
  "cicy-mihomo-darwin-arm64": "1.10.4",
143
143
  "cicy-mihomo-linux-x64": "1.10.4",
@@ -223,7 +223,7 @@ contextBridge.exposeInMainWorld("cicy", {
223
223
  localTeams: {
224
224
  list: (opts) => logInvoke("localTeams:list", opts),
225
225
  open: (id) => logInvoke("localTeams:open", id),
226
- reload: (id) => logInvoke("localTeams:reload", id),
226
+ reload: (id, opts) => logInvoke("localTeams:reload", id, opts),
227
227
  add: (spec) => logInvoke("localTeams:add", spec),
228
228
  remove: (id) => logInvoke("localTeams:remove", id),
229
229
  update: (id, patch) => logInvoke("localTeams:update", { id, patch }),