fantasta 0.3.0 → 0.3.1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "fantasta",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Asta di Fantacalcio in LAN senza server: avvia la regia come vera app desktop e i partecipanti si collegano dal telefono. Nessuna installazione richiesta.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
Binary file
Binary file
@@ -1,4 +1,4 @@
1
- const { app, BrowserWindow, dialog, ipcMain, safeStorage, session, shell, utilityProcess } = require("electron");
1
+ const { app, BrowserWindow, dialog, ipcMain, nativeImage, safeStorage, session, shell, utilityProcess } = require("electron");
2
2
  const { spawn } = require("node:child_process");
3
3
  const { readFile, writeFile, mkdir, copyFile, rename, unlink, access } = require("node:fs/promises");
4
4
  const { randomUUID } = require("node:crypto");
@@ -249,8 +249,12 @@ async function startRendererService() {
249
249
  // Il renderer deve essere raggiungibile dalla LAN: il QR del wizard punta a
250
250
  // http://<IP-locale>:47822, dove i telefoni caricano la vista partecipante.
251
251
  // (In sviluppo il renderer è esposto con `next dev --hostname 0.0.0.0`.)
252
- rendererService = spawn(process.execPath, [entrypoint], {
253
- env: { ...process.env, ELECTRON_RUN_AS_NODE: "1", HOSTNAME: "0.0.0.0", PORT: port },
252
+ // utilityProcess.fork, come per il server locale, evita la seconda icona
253
+ // "exec" nel Dock di macOS (spawn del binario Electron con RUN_AS_NODE la
254
+ // creerebbe).
255
+ rendererService = utilityProcess.fork(entrypoint, [], {
256
+ cwd: path.join(resourcesRoot, "web"),
257
+ env: { ...process.env, HOSTNAME: "0.0.0.0", PORT: port },
254
258
  stdio: "inherit",
255
259
  });
256
260
  await waitForRenderer(rendererOrigin);
@@ -267,6 +271,22 @@ async function resolveAdminSession() {
267
271
  return payload.sessionId;
268
272
  }
269
273
 
274
+ // Icona dell'app quando si gira dal bundle Electron generico (modalità npm).
275
+ // Nel pacchetto .dmg/.exe l'icona arriva già dal bundle, qui va impostata a mano.
276
+ function applyAppIcon(window) {
277
+ if (process.platform === "darwin") {
278
+ try {
279
+ const image = nativeImage.createFromPath(path.join(__dirname, "..", "build", "icon.icns"));
280
+ if (!image.isEmpty() && app.dock) app.dock.setIcon(image);
281
+ } catch { /* icona opzionale */ }
282
+ } else if (window) {
283
+ const icon = process.platform === "win32"
284
+ ? path.join(__dirname, "..", "build", "icon.ico")
285
+ : path.join(__dirname, "..", "build", "icon.icns");
286
+ try { window.setIcon(nativeImage.createFromPath(icon)); } catch { /* icona opzionale */ }
287
+ }
288
+ }
289
+
270
290
  function createWindow(adminSession) {
271
291
  const rendererUrl = assertLoopback(rendererOrigin, "FANTASTA_RENDERER_URL");
272
292
  const serverUrl = assertLoopback(localServerUrl, "FANTASTA_LOCAL_SERVER_URL");
@@ -288,6 +308,7 @@ function createWindow(adminSession) {
288
308
  spellcheck: true,
289
309
  },
290
310
  });
311
+ if (npmMode) applyAppIcon(window);
291
312
  // L'app si apre sempre dalla home: da lì si crea una nuova asta oppure si
292
313
  // rientra in regia con la card "Entra nella tua asta" (se c'è una lega salvata).
293
314
  const target = new URL("/local/home", rendererUrl);
@@ -314,12 +335,12 @@ function createWindow(adminSession) {
314
335
 
315
336
  if (!app.requestSingleInstanceLock()) app.quit();
316
337
  else {
338
+ // Da npm l'app gira come binario "Electron": rinominare subito fa sì che
339
+ // userData (e quindi il database) finisca in ~/Library/Application Support/
340
+ // Fantasta, come per l'app installata, non in ".../Electron".
341
+ if (npmMode) app.setName("Fantasta");
317
342
  app.on("second-instance", () => BrowserWindow.getAllWindows()[0]?.focus());
318
343
  app.whenReady().then(async () => {
319
- // Da npm l'app gira come binario "Electron": rinominare subito fa sì che
320
- // userData (e quindi il database) finisca in ~/Library/Application Support/
321
- // Fantasta, come per l'app installata, non in ".../Electron".
322
- if (npmMode) app.setName("Fantasta");
323
344
  app.setAboutPanelOptions({
324
345
  applicationName: "Fantasta",
325
346
  applicationVersion: app.getVersion(),