import type {ComponentType} from 'react'; import type {Sensor,SensorTransport} from './contracts'; import type {RerunHostFactory} from './rerunHost'; export interface SensorObservationView {id:string;label:string;layers?:{value:string;label:string}[]} /** Stable host slots let a session update its header without moving its media. */ export interface ObservationHeaderTargets {statusTarget:HTMLElement;actionsTarget:HTMLElement} export interface SensorObservationProps { device:Sensor;transport:SensorTransport;enabled:boolean;createRerunHost:RerunHostFactory; views:({id:string;layer:string;target:HTMLElement}&ObservationHeaderTargets)[]; } export interface SensorObservationContribution { views:(device:Sensor)=>SensorObservationView[]; Session:ComponentType; catalog?:{label:string;views:SensorObservationView[]}; } export const sensorLayerLabels:Record={color:'RGB',depth:'Глубина',infrared1:'ИК · 1',infrared2:'ИК · 2',points:'Облако точек',motion:'Движение'}; export function cameraObservationViews(device:Sensor):SensorObservationView[] { const published=device.layers.length?device.layers:/^RealSense D455$/i.test(device.model??'')?['color','depth','infrared1','infrared2','points','motion']:[]; const layers=published.filter(value=>Object.hasOwn(sensorLayerLabels,value)).map(value=>({value,label:sensorLayerLabels[value]})); layers.sort((a,b)=>Number(b.value==='color')-Number(a.value==='color')); return layers.length?[{id:'camera',label:device.name,layers}]:[]; } export function observationKey(deviceID:string,viewID:string):string {return JSON.stringify([deviceID,viewID]);}