Files
NODEDC_MISSION_CORE/packages/sensor-ui/src/extensions.ts
T
DCCONSTRUCTIONS fa8bde584f feat(video): recover camera previews and reduce encoding and playout cost
Improve camera recovery, shared preview lifecycle and receiver playout diagnostics. Preserve qualified X4 runtime changes and restore async admission in loopback media tests.
2026-10-29 09:10:01 +03:00

58 lines
2.6 KiB
TypeScript

import type {ComponentType,ReactNode} from 'react';
import type {IconName} from '@nodedc/ui-react';
import type {Sensor, SensorInventory, SensorTransport} from './contracts';
import type {EnrollmentTransport} from './enrollment';
import type {RerunHostFactory} from './rerunHost';
export interface SensorDetailProps {
device:Sensor; transport:SensorTransport; enabled:boolean; previewEnabled?:boolean;
back:()=>void; navigationTarget?:HTMLElement|null; refresh:()=>Promise<void>; failure:(error:unknown)=>void;
createRerunHost?:RerunHostFactory; reconnect?:()=>void;
generalSettings?:{supportsPreparation:boolean;supportsRenaming?:boolean;facts?:readonly {id:string;label:string;value:string}[]};
}
export interface SensorEnrollmentProps {
transport:EnrollmentTransport; onClose:()=>void; onChange:()=>void;
onComplete:(sessionId:string,signal?:AbortSignal)=>Promise<void>;
renderWindow:(view:{content:ReactNode;actions?:ReactNode;busy?:boolean})=>ReactNode;
}
export interface SensorUiContribution {
BoardSettings?:ComponentType<SensorBoardSettingsProps>;
observation?:import('./observation').SensorObservationContribution;
kind:string;
Detail:ComponentType<SensorDetailProps>;
icon:IconName;
retainOffline:boolean;
supportsPreparation:boolean;
supportsRenaming?:boolean;
detailLabel?:string;
detailPresentation?:'modal';
/** The detail modal includes generic settings and owns the single gear entry. */
settingsInDetail?:boolean;
settingsFacts?:(device:Sensor)=>readonly {id:string;label:string;value:string}[];
rowActions?:(device:Sensor)=>readonly SensorRowAction[];
status?:(device:Sensor,fresh:boolean)=>{label:string;tone:'neutral'|'success'|'warning'|'danger'};
wirelessEnrollment?:{label:string;View:ComponentType<SensorEnrollmentProps>};
}
export interface SensorBoardSettingsProps {
inventory:SensorInventory|null;transport:SensorTransport;enabled:boolean;
refresh:()=>Promise<void>;failure:(error:unknown)=>void;openDevice:(id:string)=>void;
}
export interface SensorRowAction {
actionId:string; label:string; description?:string; disabled?:boolean;
parameters?:Record<string,unknown>;
}
export function wirelessContributions(contributions:readonly SensorUiContribution[]):SensorUiContribution[] {
return contributions.filter(value=>value.wirelessEnrollment&&contributions.filter(other=>other.kind===value.kind).length===1);
}
export function sensorContribution(
contributions:readonly SensorUiContribution[], device:Sensor,
):SensorUiContribution|undefined {
const matches=contributions.filter(value=>value.kind===device.kind);
// An ambiguous renderer must not acquire authority over a device.
return matches.length===1?matches[0]:undefined;
}