30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import type {ComponentType} from 'react';
|
|
import type {IconName} from '@nodedc/ui-react';
|
|
import type {Sensor, SensorTransport} from './contracts';
|
|
import type {EnrollmentTransport} from './enrollment';
|
|
import type {RerunHostFactory} from './rerunHost';
|
|
|
|
export interface SensorDetailProps {
|
|
device:Sensor; transport:SensorTransport; enabled:boolean;
|
|
back:()=>void; refresh:()=>Promise<void>; failure:(error:unknown)=>void;
|
|
createRerunHost?:RerunHostFactory;
|
|
}
|
|
export interface SensorEnrollmentProps {
|
|
transport:EnrollmentTransport; onClose:()=>void; onChange:()=>void;
|
|
}
|
|
export interface SensorUiContribution {
|
|
kind:string;
|
|
Detail:ComponentType<SensorDetailProps>;
|
|
icon:IconName;
|
|
retainOffline:boolean;
|
|
supportsPreparation:boolean;
|
|
}
|
|
|
|
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;
|
|
}
|