4 Commits

Author SHA1 Message Date
davide 1a43864919 chore: rimuove script e dipendenze inutilizzati in dev
- Rimuove script preview e start (duplicati di serve)
- Rimuove dipendenza concurrently (mai usata)
- Aggiunge persistenza stato al plugin dev WebSocket
2026-05-12 14:17:19 +02:00
davide 15dac9f965 feat(persist): salva stato su .segnapunti/state.json ad ogni azione
All'avvio il server carica lo stato dal file se esiste; ad ogni azione
lo riscrive. Il riavvio del server riprende dall'ultimo punto salvato.
2026-05-12 14:08:10 +02:00
davide 0ba49ead5d chore: rimuove dipendenze e file inutilizzati
- Rimuove wave-ui e vue-router (mai usati nell'app)
- Elimina playwright.config.ts (duplicato di .cjs)
- Elimina asset template Vite (vite.svg, vue.svg, serve.png)
- Sostituisce favicon con segnap-192x192.png
- Aggiunge dev-dist/ a .gitignore
- Rimuove selettori CSS .w-input__* (morti senza wave-ui)
2026-05-12 14:00:16 +02:00
davide c900153eed refactor(striscia): nuova struttura array-di-set, elimina storicoServizio
La striscia diventa un array di set: ogni elemento è { serv, r[] }
dove r è la sequenza di scorer ('home'|'guest') del set.

- Un rally = un elemento in r: minimo non-derivabile
- Tutti i set (passati e corrente) sono conservati nell'array
- Dal set corrente si derivano: punteggio, servizio, cambio palla, rotazione
- Dal set completo si derivano: vincitore (r.at(-1)), score finale (count)
- storicoServizio eliminato: l'undo legge l'entry precedente di r

DisplayPage calcola le strip visive (home/guest) tramite computed
da striscia.at(-1).r senza dati ridondanti nel modello.
2026-05-12 13:49:51 +02:00
20 changed files with 111 additions and 509 deletions
+2
View File
@@ -13,6 +13,8 @@ currentCommit.txt
node_modules node_modules
dist dist
dist-ssr dist-ssr
dev-dist
.segnapunti
*.local *.local
# Editor directories and files # Editor directories and files
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/png" href="/segnap-192x192.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Segnapunti - Controller</title> <title>Segnapunti - Controller</title>
</head> </head>
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/png" href="/segnap-192x192.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Segnapunti - Anto</title> <title>Segnapunti - Anto</title>
</head> </head>
-296
View File
@@ -10,8 +10,6 @@
"dependencies": { "dependencies": {
"express": "^5.2.1", "express": "^5.2.1",
"vue": "^3.2.47", "vue": "^3.2.47",
"vue-router": "^4.6.4",
"wave-ui": "^3.3.0",
"ws": "^8.19.0" "ws": "^8.19.0"
}, },
"devDependencies": { "devDependencies": {
@@ -21,7 +19,6 @@
"@vitejs/plugin-vue": "^6.0.5", "@vitejs/plugin-vue": "^6.0.5",
"@vitest/ui": "^4.0.18", "@vitest/ui": "^4.0.18",
"@vue/test-utils": "^2.4.6", "@vue/test-utils": "^2.4.6",
"concurrently": "^9.2.1",
"happy-dom": "^20.6.1", "happy-dom": "^20.6.1",
"jsdom": "^28.0.0", "jsdom": "^28.0.0",
"vite": "^7.3.1", "vite": "^7.3.1",
@@ -3318,11 +3315,6 @@
"@vue/shared": "3.5.28" "@vue/shared": "3.5.28"
} }
}, },
"node_modules/@vue/devtools-api": {
"version": "6.6.4",
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.4.tgz",
"integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g=="
},
"node_modules/@vue/reactivity": { "node_modules/@vue/reactivity": {
"version": "3.5.28", "version": "3.5.28",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.28.tgz", "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.28.tgz",
@@ -3722,20 +3714,6 @@
"node": ">=18" "node": ">=18"
} }
}, },
"node_modules/cliui": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
"dev": true,
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.1",
"wrap-ansi": "^7.0.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/commander": { "node_modules/commander": {
"version": "2.20.3", "version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
@@ -3757,115 +3735,6 @@
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true "dev": true
}, },
"node_modules/concurrently": {
"version": "9.2.1",
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.1.tgz",
"integrity": "sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==",
"dev": true,
"dependencies": {
"chalk": "4.1.2",
"rxjs": "7.8.2",
"shell-quote": "1.8.3",
"supports-color": "8.1.1",
"tree-kill": "1.2.2",
"yargs": "17.7.2"
},
"bin": {
"conc": "dist/bin/concurrently.js",
"concurrently": "dist/bin/concurrently.js"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/open-cli-tools/concurrently?sponsor=1"
}
},
"node_modules/concurrently/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/concurrently/node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/concurrently/node_modules/chalk/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/concurrently/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/concurrently/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/concurrently/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/concurrently/node_modules/supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/config-chain": { "node_modules/config-chain": {
"version": "1.1.13", "version": "1.1.13",
"resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz", "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz",
@@ -4669,15 +4538,6 @@
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true,
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/get-intrinsic": { "node_modules/get-intrinsic": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
@@ -6285,15 +6145,6 @@
"jsesc": "bin/jsesc" "jsesc": "bin/jsesc"
} }
}, },
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/require-from-string": { "node_modules/require-from-string": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
@@ -6351,15 +6202,6 @@
"node": ">= 18" "node": ">= 18"
} }
}, },
"node_modules/rxjs": {
"version": "7.8.2",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz",
"integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==",
"dev": true,
"dependencies": {
"tslib": "^2.1.0"
}
},
"node_modules/safe-regex-test": { "node_modules/safe-regex-test": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz",
@@ -6480,18 +6322,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/shell-quote": {
"version": "1.8.3",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz",
"integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==",
"dev": true,
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel": { "node_modules/side-channel": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
@@ -6998,21 +6828,6 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"node_modules/tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
"dev": true,
"bin": {
"tree-kill": "cli.js"
}
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"dev": true
},
"node_modules/type-fest": { "node_modules/type-fest": {
"version": "0.16.0", "version": "0.16.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.16.0.tgz", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.16.0.tgz",
@@ -7547,20 +7362,6 @@
"integrity": "sha512-YbGqHZ5/eW4SnkPNR44mKVc6ZKQoRs/Rux1sxC6rdwXb4qpbOSYfDr9DsTHolOTGmIKgM9j141mZbBeg05R1pw==", "integrity": "sha512-YbGqHZ5/eW4SnkPNR44mKVc6ZKQoRs/Rux1sxC6rdwXb4qpbOSYfDr9DsTHolOTGmIKgM9j141mZbBeg05R1pw==",
"dev": true "dev": true
}, },
"node_modules/vue-router": {
"version": "4.6.4",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.6.4.tgz",
"integrity": "sha512-Hz9q5sa33Yhduglwz6g9skT8OBPii+4bFn88w6J+J4MfEo4KRRpmiNG/hHHkdbRFlLBOqxN8y8gf2Fb0MTUgVg==",
"dependencies": {
"@vue/devtools-api": "^6.6.4"
},
"funding": {
"url": "https://github.com/sponsors/posva"
},
"peerDependencies": {
"vue": "^3.5.0"
}
},
"node_modules/w3c-xmlserializer": { "node_modules/w3c-xmlserializer": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz",
@@ -7573,17 +7374,6 @@
"node": ">=18" "node": ">=18"
} }
}, },
"node_modules/wave-ui": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/wave-ui/-/wave-ui-3.3.0.tgz",
"integrity": "sha512-z4hBt/tOFMwG3S+pNE1+is+6diSSgll7zeYOwr84v4+mdE1o+u1M4zTRwqYx1NvLE9DqeXD3iplCjhrxEjsziA==",
"funding": {
"url": "https://github.com/sponsors/antoniandre"
},
"peerDependencies": {
"vue": "^2.6.14 || ^3.2.0"
}
},
"node_modules/webidl-conversions": { "node_modules/webidl-conversions": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz",
@@ -7896,23 +7686,6 @@
"workbox-core": "7.4.0" "workbox-core": "7.4.0"
} }
}, },
"node_modules/wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"dev": true,
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/wrap-ansi-cjs": { "node_modules/wrap-ansi-cjs": {
"name": "wrap-ansi", "name": "wrap-ansi",
"version": "7.0.0", "version": "7.0.0",
@@ -7964,39 +7737,6 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true "dev": true
}, },
"node_modules/wrap-ansi/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/wrap-ansi/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/wrap-ansi/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/wrappy": { "node_modules/wrappy": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
@@ -8037,47 +7777,11 @@
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
"dev": true "dev": true
}, },
"node_modules/y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
"dev": true,
"engines": {
"node": ">=10"
}
},
"node_modules/yallist": { "node_modules/yallist": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
"dev": true "dev": true
},
"node_modules/yargs": {
"version": "17.7.2",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
"dev": true,
"dependencies": {
"cliui": "^8.0.1",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"require-directory": "^2.1.1",
"string-width": "^4.2.3",
"y18n": "^5.0.5",
"yargs-parser": "^21.1.1"
},
"engines": {
"node": ">=12"
}
},
"node_modules/yargs-parser": {
"version": "21.1.1",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
"dev": true,
"engines": {
"node": ">=12"
}
} }
} }
} }
-5
View File
@@ -6,8 +6,6 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"preview": "node server.js",
"start": "node server.js",
"serve": "vite build && node server.js", "serve": "vite build && node server.js",
"cli": "node cli.js", "cli": "node cli.js",
"cli:dev": "node cli.js 5173", "cli:dev": "node cli.js 5173",
@@ -24,8 +22,6 @@
"dependencies": { "dependencies": {
"express": "^5.2.1", "express": "^5.2.1",
"vue": "^3.2.47", "vue": "^3.2.47",
"vue-router": "^4.6.4",
"wave-ui": "^3.3.0",
"ws": "^8.19.0" "ws": "^8.19.0"
}, },
"overrides": { "overrides": {
@@ -38,7 +34,6 @@
"@vitejs/plugin-vue": "^6.0.5", "@vitejs/plugin-vue": "^6.0.5",
"@vitest/ui": "^4.0.18", "@vitest/ui": "^4.0.18",
"@vue/test-utils": "^2.4.6", "@vue/test-utils": "^2.4.6",
"concurrently": "^9.2.1",
"happy-dom": "^20.6.1", "happy-dom": "^20.6.1",
"jsdom": "^28.0.0", "jsdom": "^28.0.0",
"vite": "^7.3.1", "vite": "^7.3.1",
-76
View File
@@ -1,76 +0,0 @@
import { defineConfig, devices } from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests/e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('')`. */
// baseURL: 'http://localhost:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
/* Test against mobile viewports. */
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],
/* Run your local dev server before starting the tests */
webServer: {
command: 'npm run serve',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
});
-1
View File
@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

+2 -1
View File
@@ -5,6 +5,7 @@ import { fileURLToPath } from 'url'
import { dirname, join } from 'path' import { dirname, join } from 'path'
import { setupWebSocketHandler } from './src/websocket-handler.js' import { setupWebSocketHandler } from './src/websocket-handler.js'
import { printServerInfo } from './src/server-utils.js' import { printServerInfo } from './src/server-utils.js'
import { loadState, saveState } from './src/persist.js'
const __filename = fileURLToPath(import.meta.url) const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename) const __dirname = dirname(__filename)
@@ -26,7 +27,7 @@ app.get(['/controller', '/controller/*splat'], (_req, res) => {
const server = createServer(app) const server = createServer(app)
const wss = new WebSocketServer({ noServer: true }) const wss = new WebSocketServer({ noServer: true })
setupWebSocketHandler(wss) setupWebSocketHandler(wss, { initialState: loadState(), onStateChange: saveState })
server.on('upgrade', (request, socket, head) => { server.on('upgrade', (request, socket, head) => {
const pathname = new URL(request.url, `http://${request.headers.host}`).pathname const pathname = new URL(request.url, `http://${request.headers.host}`).pathname
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

-1
View File
@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

Before

Width:  |  Height:  |  Size: 496 B

+1 -2
View File
@@ -224,7 +224,7 @@ export default {
visuStriscia: true, visuStriscia: true,
modalitaPartita: "3/5", modalitaPartita: "3/5",
sp: { sp: {
striscia: { home: [0], guest: [0] }, striscia: [{ serv: 'home', r: [] }],
servHome: true, servHome: true,
punt: { home: 0, guest: 0 }, punt: { home: 0, guest: 0 },
set: { home: 0, guest: 0 }, set: { home: 0, guest: 0 },
@@ -233,7 +233,6 @@ export default {
home: ["1", "2", "3", "4", "5", "6"], home: ["1", "2", "3", "4", "5", "6"],
guest: ["1", "2", "3", "4", "5", "6"], guest: ["1", "2", "3", "4", "5", "6"],
}, },
storicoServizio: [],
}, },
}, },
} }
+22 -17
View File
@@ -92,16 +92,16 @@
<div class="striscia" v-if="state.visuStriscia"> <div class="striscia" v-if="state.visuStriscia">
<span class="striscia-nome text-bold">{{ state.sp.nomi.home }}</span> <span class="striscia-nome text-bold">{{ state.sp.nomi.home }}</span>
<div class="striscia-items" ref="homeItems"> <div class="striscia-items" ref="homeItems">
<div v-for="(h, i) in state.sp.striscia.home" :key="'sh'+i" <div v-for="(h, i) in stricciaStrip.home" :key="'sh'+i"
class="item" :class="{ 'item-vuoto': String(h).trim() === '' }"> class="item" :class="{ 'item-vuoto': h === ' ' }">
{{ String(h) }} {{ h }}
</div> </div>
</div> </div>
<span class="striscia-nome text-bold guest-striscia">{{ state.sp.nomi.guest }}</span> <span class="striscia-nome text-bold guest-striscia">{{ state.sp.nomi.guest }}</span>
<div class="striscia-items guest-striscia" ref="guestItems"> <div class="striscia-items guest-striscia" ref="guestItems">
<div v-for="(h, i) in state.sp.striscia.guest" :key="'sg'+i" <div v-for="(h, i) in stricciaStrip.guest" :key="'sg'+i"
class="item" :class="{ 'item-vuoto': String(h).trim() === '' }"> class="item" :class="{ 'item-vuoto': h === ' ' }">
{{ String(h) }} {{ h }}
</div> </div>
</div> </div>
</div> </div>
@@ -132,7 +132,7 @@ export default {
visuStriscia: true, visuStriscia: true,
modalitaPartita: "3/5", modalitaPartita: "3/5",
sp: { sp: {
striscia: { home: [0], guest: [0] }, striscia: [{ serv: 'home', r: [] }],
servHome: true, servHome: true,
punt: { home: 0, guest: 0 }, punt: { home: 0, guest: 0 },
set: { home: 0, guest: 0 }, set: { home: 0, guest: 0 },
@@ -141,7 +141,6 @@ export default {
home: ["1", "2", "3", "4", "5", "6"], home: ["1", "2", "3", "4", "5", "6"],
guest: ["1", "2", "3", "4", "5", "6"], guest: ["1", "2", "3", "4", "5", "6"],
}, },
storicoServizio: [],
}, },
}, },
} }
@@ -192,23 +191,29 @@ export default {
this.ws = null this.ws = null
} }
}, },
computed: {
stricciaStrip() {
const currentSet = this.state.sp.striscia.at(-1)
if (!currentSet) return { home: [], guest: [] }
let h = 0, g = 0
const home = [], guest = []
for (const scorer of currentSet.r) {
if (scorer === 'home') { h++; home.push(h); guest.push(' ') }
else { g++; guest.push(g); home.push(' ') }
}
return { home, guest }
},
},
watch: { watch: {
'state.sp.striscia.home': { 'state.sp.striscia': {
deep: true, deep: true,
handler() { handler() {
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.homeItems) this.$refs.homeItems.scrollLeft = this.$refs.homeItems.scrollWidth if (this.$refs.homeItems) this.$refs.homeItems.scrollLeft = this.$refs.homeItems.scrollWidth
})
}
},
'state.sp.striscia.guest': {
deep: true,
handler() {
this.$nextTick(() => {
if (this.$refs.guestItems) this.$refs.guestItems.scrollLeft = this.$refs.guestItems.scrollWidth if (this.$refs.guestItems) this.$refs.guestItems.scrollLeft = this.$refs.guestItems.scrollWidth
}) })
} }
} },
}, },
methods: { methods: {
isMobile() { isMobile() {
-3
View File
@@ -1,9 +1,6 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import './style.css' import './style.css'
import WaveUI from 'wave-ui'
import 'wave-ui/dist/wave-ui.css'
import ControllerPage from './components/ControllerPage.vue' import ControllerPage from './components/ControllerPage.vue'
const app = createApp(ControllerPage) const app = createApp(ControllerPage)
app.use(WaveUI)
app.mount('#app') app.mount('#app')
+24 -51
View File
@@ -1,8 +1,3 @@
/**
* Logica di gioco condivisa per il segnapunti.
* Utilizzata sia dal server WebSocket sia dal client per l'anteprima locale.
*/
export function createInitialState() { export function createInitialState() {
return { return {
order: true, order: true,
@@ -10,7 +5,7 @@ export function createInitialState() {
visuStriscia: true, visuStriscia: true,
modalitaPartita: "3/5", modalitaPartita: "3/5",
sp: { sp: {
striscia: { home: [0], guest: [0] }, striscia: [{ serv: 'home', r: [] }],
servHome: true, servHome: true,
punt: { home: 0, guest: 0 }, punt: { home: 0, guest: 0 },
set: { home: 0, guest: 0 }, set: { home: 0, guest: 0 },
@@ -19,7 +14,6 @@ export function createInitialState() {
home: ["1", "2", "3", "4", "5", "6"], home: ["1", "2", "3", "4", "5", "6"],
guest: ["1", "2", "3", "4", "5", "6"], guest: ["1", "2", "3", "4", "5", "6"],
}, },
storicoServizio: [],
}, },
} }
} }
@@ -31,22 +25,11 @@ export function checkVittoria(state) {
const setGuest = state.sp.set.guest const setGuest = state.sp.set.guest
const totSet = setHome + setGuest const totSet = setHome + setGuest
let isSetDecisivo = false const isSetDecisivo = state.modalitaPartita === "2/3" ? totSet >= 2 : totSet >= 4
if (state.modalitaPartita === "2/3") {
isSetDecisivo = totSet >= 2
} else {
isSetDecisivo = totSet >= 4
}
const punteggioVittoria = isSetDecisivo ? 15 : 25 const punteggioVittoria = isSetDecisivo ? 15 : 25
if (puntHome >= punteggioVittoria && puntHome - puntGuest >= 2) { if (puntHome >= punteggioVittoria && puntHome - puntGuest >= 2) return true
return true if (puntGuest >= punteggioVittoria && puntGuest - puntHome >= 2) return true
}
if (puntGuest >= punteggioVittoria && puntGuest - puntHome >= 2) {
return true
}
return false return false
} }
@@ -59,16 +42,8 @@ export function applyAction(state, action) {
if (checkVittoria(s)) break if (checkVittoria(s)) break
const cambioPalla = (team === "home") !== s.sp.servHome const cambioPalla = (team === "home") !== s.sp.servHome
s.sp.storicoServizio.push({ servHome: s.sp.servHome, cambioPalla })
s.sp.punt[team]++ s.sp.punt[team]++
if (team === "home") { s.sp.striscia.at(-1).r.push(team)
s.sp.striscia.home.push(s.sp.punt.home)
s.sp.striscia.guest.push(" ")
} else {
s.sp.striscia.guest.push(s.sp.punt.guest)
s.sp.striscia.home.push(" ")
}
if (cambioPalla) { if (cambioPalla) {
s.sp.form[team].push(s.sp.form[team].shift()) s.sp.form[team].push(s.sp.form[team].shift())
@@ -79,23 +54,22 @@ export function applyAction(state, action) {
} }
case "decPunt": { case "decPunt": {
if (s.sp.storicoServizio.length > 0) { const currentSet = s.sp.striscia.at(-1)
const tmpHome = s.sp.striscia.home.pop() if (currentSet.r.length === 0) break
s.sp.striscia.guest.pop()
const statoServizio = s.sp.storicoServizio.pop()
if (tmpHome === " ") { const lastScorer = currentSet.r[currentSet.r.length - 1]
s.sp.punt.guest-- const prevServer = currentSet.r.length >= 2
if (statoServizio.cambioPalla) { ? currentSet.r[currentSet.r.length - 2]
s.sp.form.guest.unshift(s.sp.form.guest.pop()) : currentSet.serv
}
} else { const wasCambioPalla = lastScorer !== prevServer
s.sp.punt.home--
if (statoServizio.cambioPalla) { currentSet.r.pop()
s.sp.form.home.unshift(s.sp.form.home.pop()) s.sp.punt[lastScorer]--
} s.sp.servHome = prevServer === 'home'
}
s.sp.servHome = statoServizio.servHome if (wasCambioPalla) {
s.sp.form[lastScorer].unshift(s.sp.form[lastScorer].pop())
} }
break break
} }
@@ -116,8 +90,8 @@ export function applyAction(state, action) {
s.sp.set[team]++ s.sp.set[team]++
s.sp.punt.home = 0 s.sp.punt.home = 0
s.sp.punt.guest = 0 s.sp.punt.guest = 0
s.sp.striscia = { home: [0], guest: [0] } s.sp.servHome = team === 'home'
s.sp.storicoServizio = [] s.sp.striscia.push({ serv: team, r: [] })
s.sp.form = { s.sp.form = {
home: ["1", "2", "3", "4", "5", "6"], home: ["1", "2", "3", "4", "5", "6"],
guest: ["1", "2", "3", "4", "5", "6"], guest: ["1", "2", "3", "4", "5", "6"],
@@ -128,7 +102,7 @@ export function applyAction(state, action) {
case "cambiaPalla": { case "cambiaPalla": {
if (s.sp.punt.home === 0 && s.sp.punt.guest === 0) { if (s.sp.punt.home === 0 && s.sp.punt.guest === 0) {
s.sp.servHome = !s.sp.servHome s.sp.servHome = !s.sp.servHome
s.sp.striscia = { home: [0], guest: [0] } s.sp.striscia.at(-1).serv = s.sp.servHome ? 'home' : 'guest'
} }
break break
} }
@@ -143,8 +117,7 @@ export function applyAction(state, action) {
home: ["1", "2", "3", "4", "5", "6"], home: ["1", "2", "3", "4", "5", "6"],
guest: ["1", "2", "3", "4", "5", "6"], guest: ["1", "2", "3", "4", "5", "6"],
} }
s.sp.striscia = { home: [0], guest: [0] } s.sp.striscia = [{ serv: s.sp.servHome ? 'home' : 'guest', r: [] }]
s.sp.storicoServizio = []
break break
} }
-6
View File
@@ -1,12 +1,6 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import './style.css' import './style.css'
import App from './App.vue'
import WaveUI from 'wave-ui'
import 'wave-ui/dist/wave-ui.css'
import DisplayPage from './components/DisplayPage.vue' import DisplayPage from './components/DisplayPage.vue'
// In modalità display-only, non serve il router.
// Il display viene montato direttamente.
const app = createApp(DisplayPage) const app = createApp(DisplayPage)
app.use(WaveUI)
app.mount('#app') app.mount('#app')
+26
View File
@@ -0,0 +1,26 @@
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs'
import { join, dirname } from 'path'
import { fileURLToPath } from 'url'
import { createInitialState } from './gameState.js'
const STATE_PATH = join(dirname(fileURLToPath(import.meta.url)), '..', '.segnapunti', 'state.json')
export function loadState() {
try {
if (existsSync(STATE_PATH)) {
return JSON.parse(readFileSync(STATE_PATH, 'utf8'))
}
} catch (err) {
console.warn('[Persist] Stato non leggibile, si riparte da zero:', err.message)
}
return createInitialState()
}
export function saveState(state) {
try {
mkdirSync(dirname(STATE_PATH), { recursive: true })
writeFileSync(STATE_PATH, JSON.stringify(state), 'utf8')
} catch (err) {
console.error('[Persist] Salvataggio fallito:', err.message)
}
}
+4 -12
View File
@@ -248,9 +248,7 @@ button:focus-visible {
max-width: 64px; max-width: 64px;
} }
.cambi-input input, .cambi-input input {
.cambi-input .w-input__input,
.cambi-input .w-input__field {
border: 2px solid rgba(255, 255, 255, 0.35); border: 2px solid rgba(255, 255, 255, 0.35);
border-radius: 8px; border-radius: 8px;
padding: 6px 10px; padding: 6px 10px;
@@ -259,21 +257,15 @@ button:focus-visible {
box-sizing: border-box; box-sizing: border-box;
} }
.cambi-in input, .cambi-in input {
.cambi-in .w-input__input,
.cambi-in .w-input__field {
background: rgba(120, 200, 120, 0.4); background: rgba(120, 200, 120, 0.4);
} }
.cambi-out input, .cambi-out input {
.cambi-out .w-input__input,
.cambi-out .w-input__field {
background: rgba(200, 120, 120, 0.4); background: rgba(200, 120, 120, 0.4);
} }
.cambi-input input:focus, .cambi-input input:focus {
.cambi-input .w-input__input:focus,
.cambi-input .w-input__field:focus {
border-color: rgba(255, 255, 255, 0.7); border-color: rgba(255, 255, 255, 0.7);
outline: none; outline: none;
} }
+3 -2
View File
@@ -5,9 +5,9 @@ import { createInitialState, applyAction } from './gameState.js'
* @param {WebSocketServer} wss - Istanza del server WebSocket. * @param {WebSocketServer} wss - Istanza del server WebSocket.
* @returns {Object} Oggetto con metodi di gestione dello stato. * @returns {Object} Oggetto con metodi di gestione dello stato.
*/ */
export function setupWebSocketHandler(wss) { export function setupWebSocketHandler(wss, options = {}) {
// Stato globale della partita. // Stato globale della partita.
let gameState = createInitialState() let gameState = options.initialState ?? createInitialState()
// Mappa dei ruoli associati ai client connessi. // Mappa dei ruoli associati ai client connessi.
const clients = new Map() // ws -> { role: 'display' | 'controller' } const clients = new Map() // ws -> { role: 'display' | 'controller' }
@@ -100,6 +100,7 @@ export function setupWebSocketHandler(wss) {
// Propaga il nuovo stato a tutti i client connessi. // Propaga il nuovo stato a tutti i client connessi.
broadcastState() broadcastState()
options.onStateChange?.(gameState)
} }
/** /**
+23 -33
View File
@@ -31,13 +31,10 @@ describe('Game Logic (gameState.js)', () => {
expect(state.sp.form.guest).toEqual(["1", "2", "3", "4", "5", "6"]) expect(state.sp.form.guest).toEqual(["1", "2", "3", "4", "5", "6"])
}) })
it('dovrebbe avere la striscia iniziale a [0]', () => { it('dovrebbe avere la striscia iniziale con un set vuoto', () => {
expect(state.sp.striscia.home).toEqual([0]) expect(state.sp.striscia).toHaveLength(1)
expect(state.sp.striscia.guest).toEqual([0]) expect(state.sp.striscia[0].serv).toBe('home')
}) expect(state.sp.striscia[0].r).toEqual([])
it('dovrebbe avere storico servizio vuoto', () => {
expect(state.sp.storicoServizio).toEqual([])
}) })
it('dovrebbe avere modalità 3/5 di default', () => { it('dovrebbe avere modalità 3/5 di default', () => {
@@ -116,21 +113,19 @@ describe('Game Logic (gameState.js)', () => {
it('dovrebbe aggiornare la striscia per punto Home', () => { it('dovrebbe aggiornare la striscia per punto Home', () => {
const s = applyAction(state, { type: 'incPunt', team: 'home' }) const s = applyAction(state, { type: 'incPunt', team: 'home' })
expect(s.sp.striscia.home).toEqual([0, 1]) expect(s.sp.striscia.at(-1).r).toEqual(['home'])
expect(s.sp.striscia.guest).toEqual([0, " "])
}) })
it('dovrebbe aggiornare la striscia per punto Guest', () => { it('dovrebbe aggiornare la striscia per punto Guest', () => {
const s = applyAction(state, { type: 'incPunt', team: 'guest' }) const s = applyAction(state, { type: 'incPunt', team: 'guest' })
expect(s.sp.striscia.guest).toEqual([0, 1]) expect(s.sp.striscia.at(-1).r).toEqual(['guest'])
expect(s.sp.striscia.home).toEqual([0, " "])
}) })
it('dovrebbe registrare lo storico servizio', () => { it('dovrebbe registrare scorer nella striscia', () => {
const s = applyAction(state, { type: 'incPunt', team: 'home' }) let s = applyAction(state, { type: 'incPunt', team: 'home' })
expect(s.sp.storicoServizio).toHaveLength(1) s = applyAction(s, { type: 'incPunt', team: 'guest' })
expect(s.sp.storicoServizio[0]).toHaveProperty('servHome') s = applyAction(s, { type: 'incPunt', team: 'home' })
expect(s.sp.storicoServizio[0]).toHaveProperty('cambioPalla') expect(s.sp.striscia.at(-1).r).toEqual(['home', 'guest', 'home'])
}) })
it('non dovrebbe incrementare i punti dopo vittoria', () => { it('non dovrebbe incrementare i punti dopo vittoria', () => {
@@ -185,7 +180,7 @@ describe('Game Logic (gameState.js)', () => {
it('dovrebbe ripristinare la striscia', () => { it('dovrebbe ripristinare la striscia', () => {
const s1 = applyAction(state, { type: 'incPunt', team: 'home' }) const s1 = applyAction(state, { type: 'incPunt', team: 'home' })
const s2 = applyAction(s1, { type: 'decPunt' }) const s2 = applyAction(s1, { type: 'decPunt' })
expect(s2.sp.striscia.home).toEqual([0]) expect(s2.sp.striscia.at(-1).r).toEqual([])
}) })
it('dovrebbe gestire undo multipli in sequenza', () => { it('dovrebbe gestire undo multipli in sequenza', () => {
@@ -250,16 +245,17 @@ describe('Game Logic (gameState.js)', () => {
expect(s.sp.punt.guest).toBe(0) expect(s.sp.punt.guest).toBe(0)
}) })
it('dovrebbe resettare la striscia', () => { it('dovrebbe aggiungere un nuovo set vuoto alla striscia', () => {
state.sp.punt.home = 25
const s = applyAction(state, { type: 'nuovoSet', team: 'home' }) const s = applyAction(state, { type: 'nuovoSet', team: 'home' })
expect(s.sp.striscia).toEqual({ home: [0], guest: [0] }) expect(s.sp.striscia).toHaveLength(2)
expect(s.sp.striscia.at(-1).r).toEqual([])
expect(s.sp.striscia.at(-1).serv).toBe('home')
}) })
it('dovrebbe resettare lo storico servizio', () => { it('dovrebbe conservare il set precedente nella striscia', () => {
state.sp.storicoServizio = [{ servHome: true, cambioPalla: false }] state.sp.striscia[0].r = ['home', 'guest', 'home']
const s = applyAction(state, { type: 'nuovoSet', team: 'home' }) const s = applyAction(state, { type: 'nuovoSet', team: 'home' })
expect(s.sp.storicoServizio).toEqual([]) expect(s.sp.striscia[0].r).toEqual(['home', 'guest', 'home'])
}) })
it('dovrebbe resettare le formazioni', () => { it('dovrebbe resettare le formazioni', () => {
@@ -664,17 +660,11 @@ describe('Game Logic (gameState.js)', () => {
expect(s.sp.form.guest).toEqual(["1", "2", "3", "4", "5", "6"]) expect(s.sp.form.guest).toEqual(["1", "2", "3", "4", "5", "6"])
}) })
it('dovrebbe resettare la striscia', () => { it('dovrebbe resettare la striscia a un set vuoto', () => {
state.sp.striscia = { home: [0, 1, 2, 3], guest: [0, " ", " ", 1] } state.sp.striscia = [{ serv: 'home', r: ['home', 'guest', 'home'] }, { serv: 'home', r: ['guest'] }]
const s = applyAction(state, { type: 'resetta' }) const s = applyAction(state, { type: 'resetta' })
expect(s.sp.striscia.home).toEqual([0]) expect(s.sp.striscia).toHaveLength(1)
expect(s.sp.striscia.guest).toEqual([0]) expect(s.sp.striscia[0].r).toEqual([])
})
it('dovrebbe resettare lo storico servizio', () => {
state.sp.storicoServizio = [{ servHome: true, cambioPalla: false }]
const s = applyAction(state, { type: 'resetta' })
expect(s.sp.storicoServizio).toEqual([])
}) })
it('dovrebbe impostare visuForm a false', () => { it('dovrebbe impostare visuForm a false', () => {
+2 -1
View File
@@ -1,13 +1,14 @@
import { WebSocketServer } from 'ws' import { WebSocketServer } from 'ws'
import { setupWebSocketHandler } from './src/websocket-handler.js' import { setupWebSocketHandler } from './src/websocket-handler.js'
import { printServerInfo } from './src/server-utils.js' import { printServerInfo } from './src/server-utils.js'
import { loadState, saveState } from './src/persist.js'
export default function websocketPlugin() { export default function websocketPlugin() {
return { return {
name: 'vite-plugin-websocket', name: 'vite-plugin-websocket',
configureServer(server) { configureServer(server) {
const wss = new WebSocketServer({ noServer: true }) const wss = new WebSocketServer({ noServer: true })
setupWebSocketHandler(wss) setupWebSocketHandler(wss, { initialState: loadState(), onStateChange: saveState })
// Rewrite /display → / (index.html) e /controller → /controller.html // Rewrite /display → / (index.html) e /controller → /controller.html
server.middlewares.use((req, _res, next) => { server.middlewares.use((req, _res, next) => {