zidane-gui 7.0.7 → 7.0.9

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zidane-gui",
3
3
  "productName": "Zidane",
4
- "version": "7.0.7",
4
+ "version": "7.0.9",
5
5
  "description": "Zidane Desktop",
6
6
  "author": "StackBlitz",
7
7
  "type": "module",
@@ -59,7 +59,7 @@
59
59
  "shiki": "^4.1.0",
60
60
  "electron": "^41.7.0",
61
61
  "tippy.js": "^6.3.7",
62
- "zidane": "7.0.7",
62
+ "zidane": "7.0.9",
63
63
  "zod": "^4.4.3"
64
64
  },
65
65
  "devDependencies": {
@@ -229,6 +229,16 @@ function installLinuxApp(pkgDir, electron) {
229
229
  * install.js is idempotent (skips when dist/ is already populated), so
230
230
  * its later run becomes a no-op.
231
231
  */
232
+ /**
233
+ * Download the Electron binary by running its own `install.js`. ONLY for the
234
+ * CLI (`zidane-gui`, `zidane-gui install-app`), never from postinstall: npm
235
+ * runs a package's postinstall CONCURRENTLY with its dependencies' (observed
236
+ * in the npm debug log), so during `npm i -g zidane-gui` Electron's own
237
+ * install.js is already extracting. Spawning a second one races it in the
238
+ * same `dist/` — benign with the old JS extract-zip, fatal with the Rust
239
+ * extractor Electron ships since 41.8 (`failed to create directory
240
+ * 'dist/Electron.app': File exists (os error 17)`).
241
+ */
232
242
  function ensureElectron(pkgDir) {
233
243
  const resolved = resolveElectron(pkgDir);
234
244
  if (resolved) return resolved;
@@ -242,13 +252,34 @@ function ensureElectron(pkgDir) {
242
252
  return resolveElectron(pkgDir);
243
253
  }
244
254
 
245
- /** Install the launcher app. Returns the installed path, or null (no-op). */
246
- export function installApp(pkgDir = packageDir()) {
255
+ /**
256
+ * The postinstall counterpart of `ensureElectron`: WAIT for Electron's own
257
+ * postinstall (running alongside ours, see above) to write `path.txt`
258
+ * instead of downloading ourselves. npm does not finish until Electron's
259
+ * script does, so waiting costs the user nothing; the cap only matters when
260
+ * that script never runs (`--ignore-scripts`, a blocked install hook), in
261
+ * which case we give up and the CLI's `install-app` takes over later.
262
+ */
263
+ export async function waitForElectron(pkgDir = packageDir(), { timeoutMs = 240_000, pollMs = 500 } = {}) {
264
+ const deadline = Date.now() + timeoutMs;
265
+ for (;;) {
266
+ const resolved = resolveElectron(pkgDir);
267
+ if (resolved) return resolved;
268
+ if (Date.now() >= deadline) return null;
269
+ await new Promise((r) => setTimeout(r, pollMs));
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Install the launcher app. Returns the installed path, or null (no-op).
275
+ * Pass `electron` when the caller already resolved it (postinstall, after
276
+ * `waitForElectron`); otherwise the binary is downloaded if missing.
277
+ */
278
+ export function installApp(pkgDir = packageDir(), electron = ensureElectron(pkgDir)) {
247
279
  // `sudo npm install -g` runs this as root: the artifacts would land in
248
280
  // /root, invisible to the actual user. They can run `zidane-gui
249
281
  // install-app` unprivileged instead.
250
282
  if (process.getuid?.() === 0) return null;
251
- const electron = ensureElectron(pkgDir);
252
283
  if (!electron) return null;
253
284
  if (process.platform === 'darwin') return installMacApp(pkgDir, electron);
254
285
  if (process.platform === 'linux') return installLinuxApp(pkgDir, electron);
@@ -25,8 +25,11 @@ if (existsSync(join(root, 'src'))) {
25
25
  // prunable node_modules. Opt in with `zidane-gui install-app`.
26
26
  } else {
27
27
  try {
28
- const { installApp } = await import('./app-installer.mjs');
29
- const installed = installApp();
28
+ const { installApp, packageDir, waitForElectron } = await import('./app-installer.mjs');
29
+ // Electron's postinstall runs concurrently with this one — wait for its
30
+ // binary rather than downloading a second copy into the same dist/.
31
+ const electron = await waitForElectron();
32
+ const installed = electron ? installApp(packageDir(), electron) : null;
30
33
  if (installed) {
31
34
  console.log(`[zidane-gui] launcher app installed: ${installed}`);
32
35
  } else {