feat(routers): add observed router inventory and scoped controls

Separate router discovery, evidence and authorized control from device runtime. Add Node/Core contracts and reusable operator surfaces.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-29 09:09:59 +03:00
parent 8b210258ca
commit 5d56237124
30 changed files with 3089 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
import {useEffect,useState} from 'react';
import type {RouterSnapshot,RouterTransport} from './contracts';
export function useRouters(transport:RouterTransport){
const [value,setValue]=useState<RouterSnapshot|null>(null),[error,setError]=useState('');
useEffect(()=>{
let active=true;let timer:ReturnType<typeof setTimeout>;
setValue(null);setError('');
async function poll(){
try{const next=await transport.read();if(active){setValue(next);setError('');}}
catch{if(active){setValue(previous=>previous?{...previous,fresh:false}:previous);setError('Не удалось обновить сведения о роутере.');}}
finally{if(active)timer=setTimeout(()=>void poll(),3000);}
}
void poll();return()=>{active=false;clearTimeout(timer);};
},[transport]);
return {value,error};
}