@sailingrotevista/rotevista-dash 6.0.11 → 6.0.12

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 +43 -21
  2. package/package.json +1 -1
package/app.js CHANGED
@@ -116,11 +116,13 @@ function getShortestRotation(curr, target) {
116
116
  }
117
117
 
118
118
  /**
119
- * Scrive il testo nel DOM solo se il valore è realmente cambiato (Evita layout reflow inutili)
119
+ * Scrive il testo nel DOM/SVG solo se il valore è realmente cambiato.
120
+ * Utilizza innerHTML perché è l'unico metodo sicuro al 100% per forzare il ridisegno dei testi negli SVG.
120
121
  */
121
122
  function safeSetText(el, text) {
122
- if (el && el.innerText !== text) {
123
- el.innerText = text;
123
+ if (!el) return;
124
+ if (el.innerHTML !== text) {
125
+ el.innerHTML = text;
124
126
  }
125
127
  }
126
128
 
@@ -609,17 +611,18 @@ function startDisplayLoop() {
609
611
  ui.status.className = (socket && socket.readyState === WebSocket.OPEN) ? "online" : "offline";
610
612
 
611
613
  // --- WATCHDOG: CONTROLLO TIMEOUT ---
612
- const watch = {
613
- "navigation.speedThroughWater": ui.stw, "navigation.speedOverGround": ui.sog,
614
- "navigation.headingTrue": ui.hdg, "navigation.courseOverGroundTrue": ui.cog,
615
- "environment.wind.speedApparent": ui.awsSvg, "environment.depth.belowTransducer": ui.depth,
616
- "environment.wind.speedTrue": ui.tws
617
- };
618
- for (let p in watch) {
619
- if (!store.timestamps[p] || (now - store.timestamps[p] > TIMEOUT_MS)) {
620
- watch[p].innerText = "---"; delete store.raw[p];
614
+ const watch = {
615
+ "navigation.speedThroughWater": ui.stw, "navigation.speedOverGround": ui.sog,
616
+ "navigation.headingTrue": ui.hdg, "navigation.courseOverGroundTrue": ui.cog,
617
+ "environment.wind.speedApparent": ui.awsSvg, "environment.depth.belowTransducer": ui.depth,
618
+ "environment.wind.speedTrue": ui.tws
619
+ };
620
+ for (let p in watch) {
621
+ if (!store.timestamps[p] || (now - store.timestamps[p] > TIMEOUT_MS)) {
622
+ safeSetText(watch[p], "---"); // Sostituito innerText con la funzione protetta!
623
+ delete store.raw[p];
624
+ }
621
625
  }
622
- }
623
626
 
624
627
  // --- AGGIORNAMENTO VELOCITÀ SULL'ACQUA (STW) ---
625
628
  if (store.raw["navigation.speedThroughWater"] !== undefined) {
@@ -664,14 +667,20 @@ function startDisplayLoop() {
664
667
  manageHistory('depth', store.raw["environment.depth.belowTransducer"]);
665
668
  }
666
669
 
667
- // --- GESTIONE VENTO (TWS / AWS SWITCH) ---
668
- const twsVal = store.raw["environment.wind.speedTrue"] ? msToKts(store.raw["environment.wind.speedTrue"]) : 0;
669
- const awsVal = store.raw["environment.wind.speedApparent"] ? msToKts(store.raw["environment.wind.speedApparent"]) : 0;
670
+ // --- GESTIONE VENTO (TWS / AWS SWITCH & BUSSOLA) ---
671
+
672
+ // Estrazione dati sicura: controlliamo esplicitamente se il dato esiste, altrimenti 0
673
+ const rawTws = store.raw["environment.wind.speedTrue"];
674
+ const rawAws = store.raw["environment.wind.speedApparent"];
675
+
676
+ const twsVal = (rawTws !== undefined && rawTws !== null) ? msToKts(rawTws) : 0;
677
+ const awsVal = (rawAws !== undefined && rawAws !== null) ? msToKts(rawAws) : 0;
670
678
 
671
- if (store.raw["environment.wind.speedTrue"] !== undefined) manageHistory('tws', twsVal);
672
- if (store.raw["environment.wind.speedApparent"] !== undefined) manageHistory('aws', awsVal);
679
+ if (rawTws !== undefined && rawTws !== null) manageHistory('tws', twsVal);
680
+ if (rawAws !== undefined && rawAws !== null) manageHistory('aws', awsVal);
673
681
 
674
- if (store.raw["environment.wind.speedTrue"] !== undefined || store.raw["environment.wind.speedApparent"] !== undefined) {
682
+ // Disegno testo casella destra (TWS o AWS)
683
+ if (rawTws !== undefined || rawAws !== undefined) {
675
684
  const labelWind = document.getElementById('tws-aws-label');
676
685
  const currentWind = (displayModeTws === 'AWS') ? awsVal : twsVal;
677
686
 
@@ -692,8 +701,21 @@ function startDisplayLoop() {
692
701
  }
693
702
  }
694
703
 
695
- if (store.raw["environment.wind.speedApparent"] !== undefined) {
696
- safeSetText(ui.awsSvg, awsVal.toFixed(1));
704
+ // --- SBLOCCO FORZATO TESTO BUSSOLA (AWS) ---
705
+ if (rawAws !== undefined && rawAws !== null && !isNaN(awsVal)) {
706
+ const strVal = awsVal.toFixed(1);
707
+ // Recupero robusto dell'elemento
708
+ let awsSvgEl = document.getElementById('aws-val-svg');
709
+
710
+ if (awsSvgEl) {
711
+ // Trucco anti-congelamento SVG: se il testo non combacia, lo forziamo usando
712
+ // textContent (standard SVG) invece di innerHTML (standard HTML).
713
+ if (awsSvgEl.textContent !== strVal) {
714
+ awsSvgEl.textContent = strVal;
715
+ }
716
+ } else {
717
+ console.error("ERRORE: Elemento SVG bussola ('aws-val-svg') non trovato nel documento!");
718
+ }
697
719
  }
698
720
 
699
721
  // --- PUNTATORI ANALOGICI ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailingrotevista/rotevista-dash",
3
- "version": "6.0.11",
3
+ "version": "6.0.12",
4
4
  "description": "Wind Dashboard with navigation and course aids",
5
5
  "main": "index.js",
6
6
  "publishConfig": {