@sailingrotevista/rotevista-dash 6.0.14 → 6.1.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.
Files changed (2) hide show
  1. package/app.js +25 -50
  2. package/package.json +1 -1
package/app.js CHANGED
@@ -22,12 +22,12 @@ let CONFIG = {
22
22
  minSpeed: 0.5,
23
23
  stabilityBreakout: 15
24
24
  },
25
- graphs: { reef1: 10, reef2: 15, historyMinutes: 10, samples: 60 },
25
+ graphs: { reef1: 5, reef2: 10, historyMinutes: 10, samples: 60 },
26
26
  scales: {
27
27
  stw: { stdMax: 4, hercSpan: 2, step: 1 },
28
28
  sog: { stdMax: 4, hercSpan: 2, step: 1 },
29
29
  tws: { stdMax: 15, hercSpan: 2, step: 1 },
30
- depth: { stdMax: 8, hercSpan: 1, step: 1 }
30
+ depth: { stdMax: 5, hercSpan: 2, step: 1 }
31
31
  },
32
32
  server: { fallbackIp: "192.168.111.240:3000" }
33
33
  };
@@ -1501,56 +1501,31 @@ window.addEventListener('contextmenu', e => e.preventDefault(), true);
1501
1501
  async function init() {
1502
1502
  loadDashboardState();
1503
1503
 
1504
- // Proviamo un primo caricamento configurazioni
1505
- await fetchServerConfig();
1506
- startDisplayLoop();
1507
- connect();
1508
-
1509
- setInterval(watchConfigChanges, 10000);
1504
+ // Rileviamo se siamo sul Mac tramite file:// (Ambiente di sviluppo locale)
1505
+ const isLocalFile = (window.location.protocol === 'file:');
1510
1506
 
1511
- // ==========================================================================
1512
- // RICONNESSIONE RAPIDA AL RISVEGLIO (VISIBILITY WATCHDOG)
1513
- // ==========================================================================
1514
-
1515
- // Quando sblocchi l'iPad o riapri la scheda, sincronizziamo in modo intelligente
1516
- document.addEventListener('visibilitychange', () => {
1517
- if (document.visibilityState === 'visible') {
1518
- // 1. Se la connessione è già attiva e sana, scarichiamo solo lo storico senza disconnetterci
1519
- if (socket && socket.readyState === WebSocket.OPEN) {
1520
- console.log("⏰ Schermo sbloccato: connessione attiva, sincronizzazione dello storico.");
1521
- fetchServerHistory().then(() => {
1522
- ['stw', 'sog', 'depth', 'tws'].forEach(refreshGraph);
1523
- }).catch(err => {});
1524
- }
1525
- // 2. Se la connessione è persa o morta, forzatura riconnessione rapida
1526
- else {
1527
- console.log("⏰ Schermo sbloccato: connessione assente, forzatura riconnessione rapida.");
1528
- if (socket) {
1529
- try {
1530
- socket.close();
1531
- } catch (e) {
1532
- connect();
1533
- }
1534
- } else {
1535
- connect();
1536
- }
1537
- }
1538
- }
1539
- });
1507
+ // 1. CARICAMENTO STORICO GRAFICI REALI DAL CERBO GX
1508
+ try {
1509
+ await fetchServerHistory();
1510
+ } catch (err) {
1511
+ console.warn("⚠️ Impossibile caricare lo storico reale dal server.");
1512
+ }
1540
1513
 
1541
- // Rileva se il dispositivo è andato in sospensione misurando il ritardo dei secondi
1542
- let lastHeartbeat = Date.now();
1543
- setInterval(() => {
1544
- const now = Date.now();
1545
- const diff = now - lastHeartbeat;
1546
- lastHeartbeat = now;
1547
-
1548
- // Se passano più di 6 secondi tra un ciclo e l'altro (invece di 1 secondo),
1549
- // significa che il PC era in sospensione. Avviamo il risveglio.
1550
- if (diff > 6000) {
1551
- handleWakeUp();
1552
- }
1553
- }, 1000);
1514
+ // 2. CARICAMENTO CONFIGURAZIONI REALI (Bypassato su Mac per preservare i tuoi test!)
1515
+ if (!isLocalFile) {
1516
+ await fetchServerConfig();
1517
+ } else {
1518
+ // Mantiene la CONFIG locale di app.js per farti fare le prove delle scale sul Mac
1519
+ console.log("🎮 Esecuzione locale file://: utilizzo delle calibrazioni di CONFIG locali di debug.");
1520
+ }
1521
+
1522
+ startDisplayLoop();
1523
+ connect(); // Si collegherà in tempo reale al WebSocket reale della barca
1524
+
1525
+ // Controlla le modifiche di configurazione sul Cerbo solo se non siamo sul Mac via file://
1526
+ if (!isLocalFile) {
1527
+ setInterval(watchConfigChanges, 10000);
1528
+ }
1554
1529
  }
1555
1530
 
1556
1531
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailingrotevista/rotevista-dash",
3
- "version": "6.0.14",
3
+ "version": "6.1.1",
4
4
  "description": "Wind Dashboard with navigation and course aids",
5
5
  "main": "index.js",
6
6
  "publishConfig": {