@camera.ui/sdk / plugin / BasePlugin
Abstract Class: BasePlugin<T> ​
Defined in: plugin/interfaces.ts:166
Base class every plugin extends. It wires up the three dependencies the host injects (logger, PluginAPI, DeviceStorage) and declares the lifecycle methods the host calls on the plugin.
The host calls configureCameras() once at startup with every camera already assigned to this plugin, then onCameraAdded() / onCameraReleased() as the user adds or removes cameras at runtime. The generic T types storage.values so plugin code gets autocompletion for its own settings shape.
Example ​
export default class MyPlugin extends BasePlugin<MyStorage> {
private state = new Map<string, MyState>();
async configureCameras(cameras: CameraDevice[]): Promise<void> {
for (const camera of cameras) await this.onCameraAdded(camera);
}
async onCameraAdded(camera: CameraDevice): Promise<void> {
this.state.set(camera.id, await this.attach(camera));
}
async onCameraReleased(cameraId: string): Promise<void> {
this.state.get(cameraId)?.dispose();
}
}Extended by ​
Type Parameters ​
T ​
T extends Record<string, any> = Record<string, any>
Constructors ​
Constructor ​
new BasePlugin<
T>(logger,api,storage):BasePlugin<T>
Defined in: plugin/interfaces.ts:167
Parameters ​
logger ​
api ​
storage ​
Returns ​
BasePlugin<T>
Properties ​
api ​
api:
PluginAPI
Defined in: plugin/interfaces.ts:169
logger ​
logger:
LoggerService
Defined in: plugin/interfaces.ts:168
storage ​
storage:
DeviceStorage<T>
Defined in: plugin/interfaces.ts:170
Accessors ​
storageSchema ​
Get Signature ​
get storageSchema():
JsonSchema[]
Defined in: plugin/interfaces.ts:174
Override to register a JSON schema for the plugin-level settings form rendered in the UI. Default: no schema.
Returns ​
Methods ​
configureCameras() ​
abstractconfigureCameras(cameras):Promise<void>
Defined in: plugin/interfaces.ts:185
Called once on startup with every camera that is already assigned to this plugin. Attach handlers, open vendor sessions, warm up models here. A rejection aborts plugin startup.
Parameters ​
cameras ​
Cameras already assigned to this plugin.
Returns ​
Promise<void>
configureSensors()? ​
optionalconfigureSensors(sensors):Promise<void>
Defined in: plugin/interfaces.ts:215
Called once on startup with every sensor this plugin may consume: sensors whose type is listed in contract.consumes and that are exposed. Each sensor carries type, assignedCameraIds, assignmentLocked and connected, so consumers decide rendering purely from that data. Optional, only bridge plugins implement it.
Parameters ​
sensors ​
Consumable sensors known at startup.
Returns ​
Promise<void>
onCameraAdded() ​
abstractonCameraAdded(camera):Promise<void>
Defined in: plugin/interfaces.ts:195
Called whenever a camera is assigned to this plugin at runtime, after a discovery adoption (DiscoveryProvider.onAdoptCamera) or after the user re-assigns an existing camera. Set up the same per-camera state as in configureCameras().
Parameters ​
camera ​
The camera device that was added.
Returns ​
Promise<void>
onCameraReleased() ​
abstractonCameraReleased(cameraId):Promise<void>
Defined in: plugin/interfaces.ts:204
Called when a camera is unassigned from this plugin or deleted from the system. Release per-camera resources (sessions, timers, decoders) before resolving.
Parameters ​
cameraId ​
string
ID of the camera that was released.
Returns ​
Promise<void>
onSensorAdded()? ​
optionalonSensorAdded(sensor):Promise<void>
Defined in: plugin/interfaces.ts:223
Called when a sensor enters this plugin's consumable view at runtime: it was created, became exposed, or its type became consumable.
Parameters ​
sensor ​
The sensor that appeared.
Returns ​
Promise<void>
onSensorReleased()? ​
optionalonSensorReleased(sensorId):Promise<void>
Defined in: plugin/interfaces.ts:232
Called when a sensor permanently leaves the consumable view: it was deleted or unexposed. Plugin connectivity does NOT fire this, watch sensor.onConnectedChanged for that.
Parameters ​
sensorId ​
string
Persistent id of the sensor that left.
Returns ​
Promise<void>