@aaqu/fromcubes-portal-react 0.1.0-alpha.6 → 0.1.0-alpha.7
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/nodes/portal-react.js +12 -3
- package/package.json +1 -1
package/nodes/portal-react.js
CHANGED
|
@@ -291,8 +291,11 @@ module.exports = function (RED) {
|
|
|
291
291
|
})
|
|
292
292
|
: Promise.resolve("");
|
|
293
293
|
|
|
294
|
+
const contentHash = compiled.js ? hash(compiled.js) : "";
|
|
295
|
+
|
|
294
296
|
pageState[endpoint] = {
|
|
295
297
|
compiled,
|
|
298
|
+
contentHash,
|
|
296
299
|
cssHashReady,
|
|
297
300
|
pageTitle,
|
|
298
301
|
wsPath,
|
|
@@ -389,6 +392,10 @@ module.exports = function (RED) {
|
|
|
389
392
|
wsSend(ws, { type: "data", payload: lastPayload });
|
|
390
393
|
}
|
|
391
394
|
|
|
395
|
+
// Send content version for deploy-reload detection
|
|
396
|
+
const contentHash = pageState[endpoint]?.contentHash || "";
|
|
397
|
+
wsSend(ws, { type: "version", hash: contentHash });
|
|
398
|
+
|
|
392
399
|
ws.on("message", (raw) => {
|
|
393
400
|
try {
|
|
394
401
|
const msg = JSON.parse(raw.toString());
|
|
@@ -590,7 +597,7 @@ body{font-family:system-ui,-apple-system,sans-serif;background:#0a0a0a;color:#e0
|
|
|
590
597
|
<div id="__cs" class="err">disconnected</div>
|
|
591
598
|
<script>
|
|
592
599
|
window.__NR={
|
|
593
|
-
_ws:null,_listeners:new Set(),_lastData:null,_retries:0,_wasConnected:false,_user:${user ? escScript(JSON.stringify(user)) : 'null'},
|
|
600
|
+
_ws:null,_listeners:new Set(),_lastData:null,_retries:0,_wasConnected:false,_version:null,_user:${user ? escScript(JSON.stringify(user)) : 'null'},
|
|
594
601
|
connect(){
|
|
595
602
|
const p=location.protocol==='https:'?'wss:':'ws:';
|
|
596
603
|
const ws=new WebSocket(p+'//'+location.host+'${wsPath}');
|
|
@@ -601,8 +608,10 @@ window.__NR={
|
|
|
601
608
|
s.textContent='connected';s.className='ok';this._retries=0;this._wasConnected=true;
|
|
602
609
|
};
|
|
603
610
|
ws.onmessage=(e)=>{
|
|
604
|
-
try{const m=JSON.parse(e.data);
|
|
605
|
-
|
|
611
|
+
try{const m=JSON.parse(e.data);
|
|
612
|
+
if(m.type==='version'){if(this._version&&this._version!==m.hash){location.reload();return;}this._version=m.hash;}
|
|
613
|
+
if(m.type==='data'){this._lastData=m.payload;this._listeners.forEach(fn=>fn(m.payload));}
|
|
614
|
+
}catch(err){console.error('WS parse',err);}
|
|
606
615
|
};
|
|
607
616
|
ws.onclose=(e)=>{
|
|
608
617
|
s.textContent='disconnected';s.className='err';
|