cicy-desktop 2.1.128 → 2.1.130

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
@@ -170,19 +170,42 @@ function provisionElectronFromMirror(bundledDir) {
170
170
  // into the bundled npx copy straight from the R2 mirror — NO `npm i -g`, NO
171
171
  // GitHub, NO @electron/get. This is what lets a single `npx cicy-desktop`
172
172
  // self-provision electron and start first-try. Runs once per process.
173
+ // The electron dir we provision into: the real electron npm package if it's
174
+ // installed, otherwise a self-managed dir under our own node_modules. `npx
175
+ // cicy-desktop` does NOT pull electron (it's not a runtime dep), so on a fresh
176
+ // machine require.resolve('electron') fails — we must NOT give up there.
177
+ function bundledElectronDir() {
178
+ try { return path.dirname(require.resolve("electron/package.json", { paths: [PACKAGE_ROOT] })); } catch {}
179
+ return path.join(PACKAGE_ROOT, "node_modules", "electron");
180
+ }
181
+ // Make `dir` a resolvable electron package (package.json + index.js that reads
182
+ // path.txt) so provisionElectronFromMirror's layout + a spawned require('electron')
183
+ // both work — WITHOUT ever running electron's own installer. Only fills in missing
184
+ // files, so a real electron package is left untouched.
185
+ function ensureMinimalElectronPkg(dir) {
186
+ fs.mkdirSync(dir, { recursive: true });
187
+ const pj = path.join(dir, "package.json");
188
+ if (!fs.existsSync(pj)) fs.writeFileSync(pj, JSON.stringify({ name: "electron", version: ELECTRON_VERSION, main: "index.js" }));
189
+ const ij = path.join(dir, "index.js");
190
+ if (!fs.existsSync(ij)) fs.writeFileSync(ij,
191
+ "const fs=require('fs'),path=require('path');const p=path.join(__dirname,'path.txt');" +
192
+ "module.exports=fs.existsSync(p)?path.join(__dirname,'dist',fs.readFileSync(p,'utf8').trim()):null;\n");
193
+ }
194
+
173
195
  let _electronEnsured = false;
174
196
  function ensureElectron() {
175
197
  if (_electronEnsured) return;
176
198
  _electronEnsured = true;
177
- // Already usable (a shared global, or the resolvable bundled/npx copy)? done.
199
+ // Already usable (a shared global, or an already-provisioned bundled copy)? done.
178
200
  if (electronBinaryHealthy(globalElectronDir())) return;
179
- let bundledDir = null;
180
- try { bundledDir = path.dirname(require.resolve("electron/package.json", { paths: [PACKAGE_ROOT] })); } catch {}
201
+ const bundledDir = bundledElectronDir();
181
202
  if (electronBinaryHealthy(bundledDir)) return;
182
- if (!bundledDir) {
183
- console.warn(`⚠️ electron package not resolvable under ${PACKAGE_ROOT}; cannot self-provision.`);
184
- return;
185
- }
203
+ // Set up the dir (create minimal pkg if electron isn't installed) then download
204
+ // the binary straight from the mirror — bypassing electron's own installer,
205
+ // which is broken on win32 + node 24 (@electron-internal extract-zip native
206
+ // binding "intentionally not published" → "Cannot find native binding").
207
+ try { ensureMinimalElectronPkg(bundledDir); }
208
+ catch (e) { console.warn(`⚠️ could not set up electron dir ${bundledDir}: ${e.message}`); return; }
186
209
  console.log(`⚙️ Fetching Electron ${ELECTRON_VERSION} from mirror (one-time)…`);
187
210
  try {
188
211
  provisionElectronFromMirror(bundledDir);
@@ -200,9 +223,17 @@ function resolveElectronSpawn() {
200
223
  ensureElectron();
201
224
  const g = globalElectronBin();
202
225
  if (g) return { cmd: g, prefixArgs: [] };
203
- if (isWindows) return { cmd: "npx.cmd", prefixArgs: ["electron"] };
226
+ // Spawn the self-provisioned binary DIRECTLY (mirror download → <dir>/dist/<exe>).
227
+ // Critically: prefer this over `npx electron` — electron's own installer is
228
+ // broken on win32 + node 24, so the npx fallback below just crashes there.
229
+ try {
230
+ const { exe } = electronArtifact();
231
+ const bin = path.join(bundledElectronDir(), "dist", exe);
232
+ if (fs.existsSync(bin)) return { cmd: bin, prefixArgs: [] };
233
+ } catch {}
204
234
  const local = path.join(PACKAGE_ROOT, "node_modules", ".bin", "electron");
205
235
  if (fs.existsSync(local)) return { cmd: local, prefixArgs: [] };
236
+ if (isWindows) return { cmd: "npx.cmd", prefixArgs: ["electron"] };
206
237
  return { cmd: "npx", prefixArgs: ["electron"] };
207
238
  }
208
239
  const PROJECT_COMMAND_FILE = path.join(PACKAGE_ROOT, "cicy-dektop.command");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cicy-desktop",
3
- "version": "2.1.128",
3
+ "version": "2.1.130",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {