@camera.ui/browser 0.0.147 → 0.0.148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +82 -42
- package/dist/index.js +177 -102
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ import { TemperatureProperty } from '@camera.ui/sdk';
|
|
|
86
86
|
import { WatchSource } from 'vue';
|
|
87
87
|
import { WsTransport } from '@camera.ui/transport/transports/ws';
|
|
88
88
|
|
|
89
|
-
export declare function acquireSensorManager(
|
|
89
|
+
export declare function acquireSensorManager(rpcOrContext: RPCClient | ReactiveCameraDeviceContext): CachedSensorManager;
|
|
90
90
|
|
|
91
91
|
export declare interface ActivityMode extends ActivityModeState, ActivityModeActions {
|
|
92
92
|
}
|
|
@@ -288,7 +288,7 @@ export declare function createCameraUiPlugin(input: CameraUiContext | CameraUiPl
|
|
|
288
288
|
|
|
289
289
|
export declare function createReactiveCameraDevice(rpcOrContext: RPCClient | ReactiveCameraDeviceContext, initialCamera: Camera): Promise<ReactiveCameraDevice>;
|
|
290
290
|
|
|
291
|
-
export declare function createSensorManager(rpcOrContext: RPCClient | ReactiveCameraDeviceContext
|
|
291
|
+
export declare function createSensorManager(rpcOrContext: RPCClient | ReactiveCameraDeviceContext): ReactiveSensorManager;
|
|
292
292
|
|
|
293
293
|
declare interface DBCamera extends BaseCamera {
|
|
294
294
|
sources: CameraInputSettings[];
|
|
@@ -394,6 +394,12 @@ export declare const isReactiveTemperatureInfo: (sensor: ReactiveSensor<any>) =>
|
|
|
394
394
|
|
|
395
395
|
/* Excluded from this release type: LeakSensorProperties */
|
|
396
396
|
|
|
397
|
+
/** @deprecated stub window for pre-standalone plugins, remove in the first minor after the standalone-sensors release */
|
|
398
|
+
declare interface LegacySensorNamespaces {
|
|
399
|
+
sensorSubject: string;
|
|
400
|
+
sensorRpc: string;
|
|
401
|
+
}
|
|
402
|
+
|
|
397
403
|
/* Excluded from this release type: LicensePlateProperty */
|
|
398
404
|
|
|
399
405
|
/* Excluded from this release type: LicensePlateSensorProperties */
|
|
@@ -468,29 +474,42 @@ export declare class NamespaceManager {
|
|
|
468
474
|
};
|
|
469
475
|
}
|
|
470
476
|
|
|
471
|
-
static pluginSensorNamespaces(pluginId: string,
|
|
477
|
+
static pluginSensorNamespaces(pluginId: string, sensorId: string): PluginSensorNamespaces {
|
|
472
478
|
return {
|
|
473
|
-
sensorStorageRpc: `plugin.${pluginId}.
|
|
479
|
+
sensorStorageRpc: `plugin.${pluginId}.sensor.${sensorId}.storage.rpc`,
|
|
474
480
|
};
|
|
475
481
|
}
|
|
476
482
|
|
|
477
|
-
static
|
|
483
|
+
static sensorRegistryNamespaces(): SensorRegistryNamespaces {
|
|
484
|
+
return {
|
|
485
|
+
sensorsSubject: 'sensors.subject',
|
|
486
|
+
sensorsRpc: 'sensors.rpc',
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
static sensorCameraViewNamespaces(cameraId: string): SensorCameraViewNamespaces {
|
|
478
491
|
return {
|
|
479
|
-
sensorSubject: `camera.${cameraId}.sensors.subject`,
|
|
480
|
-
sensorRpc: `camera.${cameraId}.sensors.rpc`,
|
|
481
492
|
sensorWriteSubject: `camera.${cameraId}.sensors.writes`,
|
|
482
493
|
};
|
|
483
494
|
}
|
|
484
495
|
|
|
485
|
-
static sensorEventNamespaces(
|
|
496
|
+
static sensorEventNamespaces(sensorId: string): SensorEventNamespaces {
|
|
486
497
|
return {
|
|
487
|
-
sensorSubject: `
|
|
498
|
+
sensorSubject: `sensor.${sensorId}.subject`,
|
|
488
499
|
};
|
|
489
500
|
}
|
|
490
501
|
|
|
491
|
-
static sensorProviderNamespaces(pluginId: string,
|
|
502
|
+
static sensorProviderNamespaces(pluginId: string, sensorId: string): SensorProviderNamespaces {
|
|
492
503
|
return {
|
|
493
|
-
sensorRpc: `plugin.${pluginId}.
|
|
504
|
+
sensorRpc: `plugin.${pluginId}.sensor.${sensorId}.rpc`,
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/** @deprecated stub window for pre-standalone plugins, remove in the first minor after the standalone-sensors release */
|
|
509
|
+
static legacySensorNamespaces(cameraId: string): LegacySensorNamespaces {
|
|
510
|
+
return {
|
|
511
|
+
sensorSubject: `camera.${cameraId}.sensors.subject`,
|
|
512
|
+
sensorRpc: `camera.${cameraId}.sensors.rpc`,
|
|
494
513
|
};
|
|
495
514
|
}
|
|
496
515
|
|
|
@@ -506,10 +525,6 @@ export declare class NamespaceManager {
|
|
|
506
525
|
};
|
|
507
526
|
}
|
|
508
527
|
|
|
509
|
-
static sensorControllerRpc(cameraId: string): string {
|
|
510
|
-
return `camera.${cameraId}.sensors.controller.rpc`;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
528
|
static terminalManagerNamespaces(): TerminalManagerNamespaces {
|
|
514
529
|
return {
|
|
515
530
|
terminalManagerSubject: 'terminalManager.subscriber',
|
|
@@ -784,7 +799,11 @@ export declare interface ReactiveSensor<TProperties extends object = Record<stri
|
|
|
784
799
|
readonly type: SensorType;
|
|
785
800
|
readonly name: string;
|
|
786
801
|
readonly displayName: Ref<string>;
|
|
802
|
+
readonly nativeId?: string;
|
|
787
803
|
readonly pluginId: string;
|
|
804
|
+
readonly assignedCameraIds: Ref<string[]>;
|
|
805
|
+
readonly exposed: Ref<boolean>;
|
|
806
|
+
readonly connected: Ref<boolean>;
|
|
788
807
|
readonly capabilities: Ref<string[]>;
|
|
789
808
|
readonly properties: TProperties;
|
|
790
809
|
getProperty<T = unknown>(property: string): T | undefined;
|
|
@@ -886,7 +905,7 @@ declare interface RefreshedStates {
|
|
|
886
905
|
sensorStates: Record<string, SensorRefreshedState>;
|
|
887
906
|
}
|
|
888
907
|
|
|
889
|
-
export declare function releaseSensorManager(
|
|
908
|
+
export declare function releaseSensorManager(): void;
|
|
890
909
|
|
|
891
910
|
export declare function resetClientState(): void;
|
|
892
911
|
|
|
@@ -908,50 +927,57 @@ export { RPCClient }
|
|
|
908
927
|
/* Excluded from this release type: SecuritySystemProperty */
|
|
909
928
|
|
|
910
929
|
declare interface SensorAddedEvent {
|
|
911
|
-
cameraId: string;
|
|
912
930
|
sensor: StoredSensorData;
|
|
913
931
|
state: SensorRefreshedState;
|
|
914
932
|
}
|
|
915
933
|
|
|
916
|
-
declare interface
|
|
934
|
+
declare interface SensorAssignmentChangedEvent {
|
|
935
|
+
sensorId: string;
|
|
936
|
+
sensorType: SensorType;
|
|
917
937
|
cameraId: string;
|
|
938
|
+
assigned: boolean;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
export declare interface SensorCameraViewNamespaces {
|
|
942
|
+
sensorWriteSubject: string;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
declare interface SensorCapabilitiesChangedEvent {
|
|
918
946
|
sensorId: string;
|
|
919
947
|
capabilities: string[];
|
|
920
948
|
}
|
|
921
949
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
950
|
+
declare interface SensorConnectedChangedEvent {
|
|
951
|
+
sensorId: string;
|
|
952
|
+
sensorType: SensorType;
|
|
953
|
+
connected: boolean;
|
|
926
954
|
}
|
|
927
955
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
getSensorByType(sensorType: SensorType): StoredSensorData | undefined;
|
|
932
|
-
getSensorsByType(sensorType: SensorType): StoredSensorData[];
|
|
933
|
-
getSensorState(sensorId: string): SensorRefreshedState;
|
|
934
|
-
getSensorStates(): Record<string, SensorRefreshedState>;
|
|
935
|
-
getPropertyValue(sensorId: string, property: string): unknown;
|
|
936
|
-
getAllPropertyValues(sensorId: string): Record<string, unknown>;
|
|
937
|
-
setDisplayName(sensorId: string, displayName: string): void;
|
|
956
|
+
declare interface SensorDeletedEvent {
|
|
957
|
+
sensorId: string;
|
|
958
|
+
sensorType: SensorType;
|
|
938
959
|
}
|
|
939
960
|
|
|
940
961
|
declare interface SensorDisplayNameChangedEvent {
|
|
941
|
-
cameraId: string;
|
|
942
962
|
sensorId: string;
|
|
943
963
|
displayName: string;
|
|
944
964
|
}
|
|
945
965
|
|
|
946
966
|
export declare interface SensorEventMessage {
|
|
947
|
-
type: 'property:changed' | 'sensor:added' | 'sensor:
|
|
948
|
-
data: PropertyChangedEvent | SensorAddedEvent |
|
|
967
|
+
type: 'property:changed' | 'sensor:added' | 'sensor:deleted' | 'sensor:connected:changed' | 'sensor:displayName:changed' | 'sensor:capabilities:changed' | 'sensor:assignment:changed' | 'sensor:exposed:changed';
|
|
968
|
+
data: PropertyChangedEvent | SensorAddedEvent | SensorDeletedEvent | SensorConnectedChangedEvent | SensorDisplayNameChangedEvent | SensorCapabilitiesChangedEvent | SensorAssignmentChangedEvent | SensorExposedChangedEvent;
|
|
949
969
|
}
|
|
950
970
|
|
|
951
971
|
export declare interface SensorEventNamespaces {
|
|
952
972
|
sensorSubject: string;
|
|
953
973
|
}
|
|
954
974
|
|
|
975
|
+
declare interface SensorExposedChangedEvent {
|
|
976
|
+
sensorId: string;
|
|
977
|
+
sensorType: SensorType;
|
|
978
|
+
exposed: boolean;
|
|
979
|
+
}
|
|
980
|
+
|
|
955
981
|
export declare interface SensorProviderNamespaces {
|
|
956
982
|
sensorRpc: string;
|
|
957
983
|
}
|
|
@@ -963,10 +989,19 @@ export declare interface SensorRefreshedState {
|
|
|
963
989
|
displayName?: string;
|
|
964
990
|
}
|
|
965
991
|
|
|
966
|
-
declare interface
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
992
|
+
export declare interface SensorRegistryNamespaces {
|
|
993
|
+
sensorsSubject: string;
|
|
994
|
+
sensorsRpc: string;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
export declare interface SensorRegistryRPC {
|
|
998
|
+
getSensors(): StoredSensorData[];
|
|
999
|
+
getSensorRpc(sensorId: string): StoredSensorData | undefined;
|
|
1000
|
+
getSensorState(sensorId: string): SensorRefreshedState;
|
|
1001
|
+
getSensorStates(): Record<string, SensorRefreshedState>;
|
|
1002
|
+
getPropertyValue(sensorId: string, property: string): unknown;
|
|
1003
|
+
getAllPropertyValues(sensorId: string): Record<string, unknown>;
|
|
1004
|
+
setDisplayName(sensorId: string, displayName: string): void;
|
|
970
1005
|
}
|
|
971
1006
|
|
|
972
1007
|
/* Excluded from this release type: SirenControlProperties */
|
|
@@ -995,12 +1030,15 @@ export declare interface StorageRPC {
|
|
|
995
1030
|
|
|
996
1031
|
export declare interface StoredSensorData {
|
|
997
1032
|
id: string;
|
|
998
|
-
stableId: string;
|
|
999
|
-
globalId: string;
|
|
1000
1033
|
type: SensorType;
|
|
1001
1034
|
name: string;
|
|
1002
1035
|
displayName: string;
|
|
1036
|
+
nativeId?: string;
|
|
1003
1037
|
pluginId: string;
|
|
1038
|
+
assignedCameraIds: string[];
|
|
1039
|
+
boundCameraId?: string;
|
|
1040
|
+
exposed: boolean;
|
|
1041
|
+
connected: boolean;
|
|
1004
1042
|
properties: Record<string, unknown>;
|
|
1005
1043
|
capabilities: string[];
|
|
1006
1044
|
requiresFrames?: boolean;
|
|
@@ -1077,6 +1115,8 @@ export declare interface TerminalSessionInfo {
|
|
|
1077
1115
|
dimensions: { cols: number; rows: number };
|
|
1078
1116
|
}
|
|
1079
1117
|
|
|
1118
|
+
export declare function useAllSensors(): UseSensorsReturn;
|
|
1119
|
+
|
|
1080
1120
|
export declare function useAudioSensor(camera: CameraIdentifier): UseSensorTypedReturn<ReactiveAudioSensor>;
|
|
1081
1121
|
|
|
1082
1122
|
export declare function useCameraById(cameraIdOrName: MaybeRefOrGetter<string>): UseCameraByIdReturn;
|
|
@@ -1212,7 +1252,7 @@ export declare interface UseSensorsReturn {
|
|
|
1212
1252
|
error: Ref<Error | undefined>;
|
|
1213
1253
|
}
|
|
1214
1254
|
|
|
1215
|
-
export declare function useSensorStorage(
|
|
1255
|
+
export declare function useSensorStorage(sensorId: MaybeRefOrGetter<string | undefined>, pluginId: MaybeRefOrGetter<string | undefined>): UseStorageReturn;
|
|
1216
1256
|
|
|
1217
1257
|
export declare interface UseSensorsTypedReturn<T extends ReactiveSensor<any> = ReactiveSensor> {
|
|
1218
1258
|
sensors: ComputedRef<T[]>;
|
package/dist/index.js
CHANGED
|
@@ -149,21 +149,30 @@ var NamespaceManager = class {
|
|
|
149
149
|
cameraImplRpc: `plugin.${pluginId}.camera.${cameraId}.impl.rpc`
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
static pluginSensorNamespaces(pluginId,
|
|
153
|
-
return { sensorStorageRpc: `plugin.${pluginId}.
|
|
152
|
+
static pluginSensorNamespaces(pluginId, sensorId) {
|
|
153
|
+
return { sensorStorageRpc: `plugin.${pluginId}.sensor.${sensorId}.storage.rpc` };
|
|
154
154
|
}
|
|
155
|
-
static
|
|
155
|
+
static sensorRegistryNamespaces() {
|
|
156
156
|
return {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
sensorWriteSubject: `camera.${cameraId}.sensors.writes`
|
|
157
|
+
sensorsSubject: "sensors.subject",
|
|
158
|
+
sensorsRpc: "sensors.rpc"
|
|
160
159
|
};
|
|
161
160
|
}
|
|
162
|
-
static
|
|
163
|
-
return {
|
|
161
|
+
static sensorCameraViewNamespaces(cameraId) {
|
|
162
|
+
return { sensorWriteSubject: `camera.${cameraId}.sensors.writes` };
|
|
163
|
+
}
|
|
164
|
+
static sensorEventNamespaces(sensorId) {
|
|
165
|
+
return { sensorSubject: `sensor.${sensorId}.subject` };
|
|
164
166
|
}
|
|
165
|
-
static sensorProviderNamespaces(pluginId,
|
|
166
|
-
return { sensorRpc: `plugin.${pluginId}.
|
|
167
|
+
static sensorProviderNamespaces(pluginId, sensorId) {
|
|
168
|
+
return { sensorRpc: `plugin.${pluginId}.sensor.${sensorId}.rpc` };
|
|
169
|
+
}
|
|
170
|
+
/** @deprecated stub window for pre-standalone plugins, remove in the first minor after the standalone-sensors release */
|
|
171
|
+
static legacySensorNamespaces(cameraId) {
|
|
172
|
+
return {
|
|
173
|
+
sensorSubject: `camera.${cameraId}.sensors.subject`,
|
|
174
|
+
sensorRpc: `camera.${cameraId}.sensors.rpc`
|
|
175
|
+
};
|
|
167
176
|
}
|
|
168
177
|
static frameWorkerDetectionNamespaces(cameraId) {
|
|
169
178
|
return { detectionRpc: `camera.${cameraId}.frameWorker.detection.rpc` };
|
|
@@ -171,9 +180,6 @@ var NamespaceManager = class {
|
|
|
171
180
|
static detectionEventNamespaces(cameraId) {
|
|
172
181
|
return { detectionEventSubject: `camera.${cameraId}.events.subject` };
|
|
173
182
|
}
|
|
174
|
-
static sensorControllerRpc(cameraId) {
|
|
175
|
-
return `camera.${cameraId}.sensors.controller.rpc`;
|
|
176
|
-
}
|
|
177
183
|
static terminalManagerNamespaces() {
|
|
178
184
|
return {
|
|
179
185
|
terminalManagerSubject: "terminalManager.subscriber",
|
|
@@ -602,7 +608,7 @@ function useSnapshot(cameraIdOrName) {
|
|
|
602
608
|
//#region src/composables/useCamera.ts
|
|
603
609
|
async function createReactiveCameraDevice(rpcOrContext, initialCamera) {
|
|
604
610
|
const cameraNamespaces = NamespaceManager.cameraNamespaces(initialCamera._id);
|
|
605
|
-
const sensorNamespaces = NamespaceManager.
|
|
611
|
+
const sensorNamespaces = NamespaceManager.sensorRegistryNamespaces();
|
|
606
612
|
const ctx = "rpc" in rpcOrContext && "value" in rpcOrContext.rpc ? rpcOrContext : void 0;
|
|
607
613
|
const rpcRef = ctx ? ctx.rpc : shallowRef(rpcOrContext);
|
|
608
614
|
let closeSubscription;
|
|
@@ -696,30 +702,47 @@ async function createReactiveCameraDevice(rpcOrContext, initialCamera) {
|
|
|
696
702
|
case "frameWorkerState":
|
|
697
703
|
frameWorkerConnected.value = event.data;
|
|
698
704
|
break;
|
|
699
|
-
case "snapshot:updated":
|
|
700
|
-
setSnapshot(initialCamera._id, event.data.snapshot, Date.now());
|
|
701
|
-
break;
|
|
705
|
+
case "snapshot:updated": setSnapshot(initialCamera._id, event.data.snapshot, Date.now());
|
|
702
706
|
}
|
|
703
707
|
}
|
|
704
708
|
function handleSensorEvent(event) {
|
|
705
709
|
if (event.type === "sensor:added") {
|
|
706
710
|
const addedEvent = event.data;
|
|
711
|
+
if (!addedEvent.sensor.assignedCameraIds.includes(initialCamera._id)) return;
|
|
712
|
+
if (!addedEvent.sensor.connected) return;
|
|
707
713
|
sensorStates.value = {
|
|
708
714
|
...sensorStates.value,
|
|
709
715
|
[addedEvent.sensor.id]: addedEvent.state
|
|
710
716
|
};
|
|
711
|
-
} else if (event.type === "sensor:
|
|
712
|
-
const
|
|
717
|
+
} else if (event.type === "sensor:deleted") {
|
|
718
|
+
const deletedEvent = event.data;
|
|
713
719
|
const newStates = { ...sensorStates.value };
|
|
714
|
-
delete newStates[
|
|
720
|
+
delete newStates[deletedEvent.sensorId];
|
|
715
721
|
sensorStates.value = newStates;
|
|
722
|
+
} else if (event.type === "sensor:connected:changed") {
|
|
723
|
+
const connectedEvent = event.data;
|
|
724
|
+
if (connectedEvent.connected) refreshStates().catch(() => {});
|
|
725
|
+
else {
|
|
726
|
+
const newStates = { ...sensorStates.value };
|
|
727
|
+
delete newStates[connectedEvent.sensorId];
|
|
728
|
+
sensorStates.value = newStates;
|
|
729
|
+
}
|
|
730
|
+
} else if (event.type === "sensor:assignment:changed") {
|
|
731
|
+
const assignmentEvent = event.data;
|
|
732
|
+
if (assignmentEvent.cameraId !== initialCamera._id) return;
|
|
733
|
+
if (assignmentEvent.assigned) refreshStates().catch(() => {});
|
|
734
|
+
else {
|
|
735
|
+
const newStates = { ...sensorStates.value };
|
|
736
|
+
delete newStates[assignmentEvent.sensorId];
|
|
737
|
+
sensorStates.value = newStates;
|
|
738
|
+
}
|
|
716
739
|
}
|
|
717
740
|
}
|
|
718
741
|
async function init() {
|
|
719
742
|
closeSubscription?.();
|
|
720
743
|
closeSensorSubscription?.();
|
|
721
744
|
closeSubscription = await rpcCall(rpcRef, (client) => client.subscribe(cameraNamespaces.cameraSubject, handleCameraEvent));
|
|
722
|
-
closeSensorSubscription = await rpcCall(rpcRef, (client) => client.subscribe(sensorNamespaces.
|
|
745
|
+
closeSensorSubscription = await rpcCall(rpcRef, (client) => client.subscribe(sensorNamespaces.sensorsSubject, handleSensorEvent));
|
|
723
746
|
await refreshStates();
|
|
724
747
|
}
|
|
725
748
|
async function close() {
|
|
@@ -1112,9 +1135,12 @@ var isReactiveOccupancySensor = createSensorTypeGuard(SensorType.Occupancy);
|
|
|
1112
1135
|
var isReactiveSmokeSensor = createSensorTypeGuard(SensorType.Smoke);
|
|
1113
1136
|
var isReactiveLeakSensor = createSensorTypeGuard(SensorType.Leak);
|
|
1114
1137
|
var isReactiveGarageControl = createSensorTypeGuard(SensorType.Garage);
|
|
1115
|
-
function createReactiveSensor(data, state, rpcRef
|
|
1138
|
+
function createReactiveSensor(data, state, rpcRef) {
|
|
1116
1139
|
const displayName = ref(state.displayName ?? data.displayName ?? data.name);
|
|
1117
1140
|
const capabilities = ref(state.capabilities ?? data.capabilities ?? []);
|
|
1141
|
+
const assignedCameraIds = ref([...data.assignedCameraIds]);
|
|
1142
|
+
const exposed = ref(data.exposed);
|
|
1143
|
+
const connected = ref(data.connected);
|
|
1118
1144
|
const properties = reactive({ ...state.properties });
|
|
1119
1145
|
const capabilityCallbacks = [];
|
|
1120
1146
|
return {
|
|
@@ -1122,19 +1148,23 @@ function createReactiveSensor(data, state, rpcRef, cameraId) {
|
|
|
1122
1148
|
type: data.type,
|
|
1123
1149
|
name: data.name,
|
|
1124
1150
|
displayName,
|
|
1151
|
+
nativeId: data.nativeId,
|
|
1125
1152
|
pluginId: data.pluginId,
|
|
1153
|
+
assignedCameraIds,
|
|
1154
|
+
exposed,
|
|
1155
|
+
connected,
|
|
1126
1156
|
capabilities,
|
|
1127
1157
|
properties,
|
|
1128
1158
|
getProperty(property) {
|
|
1129
1159
|
return properties[property];
|
|
1130
1160
|
},
|
|
1131
1161
|
async setProperty(property, value) {
|
|
1132
|
-
const sensorNamespace = `plugin.${data.pluginId}.
|
|
1162
|
+
const sensorNamespace = `plugin.${data.pluginId}.sensor.${data.id}.rpc`;
|
|
1133
1163
|
await rpcCall(rpcRef, (client) => client.createProxy(sensorNamespace).updateValue(property, value));
|
|
1134
1164
|
},
|
|
1135
1165
|
async setDisplayName(newDisplayName) {
|
|
1136
|
-
const namespace = NamespaceManager.
|
|
1137
|
-
await rpcCall(rpcRef, (client) => client.createProxy(namespace.
|
|
1166
|
+
const namespace = NamespaceManager.sensorRegistryNamespaces();
|
|
1167
|
+
await rpcCall(rpcRef, (client) => client.createProxy(namespace.sensorsRpc).setDisplayName(data.id, newDisplayName));
|
|
1138
1168
|
},
|
|
1139
1169
|
hasCapability(capability) {
|
|
1140
1170
|
return capabilities.value.includes(capability);
|
|
@@ -1151,7 +1181,8 @@ function createReactiveSensor(data, state, rpcRef, cameraId) {
|
|
|
1151
1181
|
}
|
|
1152
1182
|
};
|
|
1153
1183
|
}
|
|
1154
|
-
function createSensorManager(rpcOrContext
|
|
1184
|
+
function createSensorManager(rpcOrContext) {
|
|
1185
|
+
const { sensorsSubject, sensorsRpc } = NamespaceManager.sensorRegistryNamespaces();
|
|
1155
1186
|
const ctx = "rpc" in rpcOrContext && "value" in rpcOrContext.rpc ? rpcOrContext : void 0;
|
|
1156
1187
|
const rpcRef = ctx ? ctx.rpc : shallowRef(rpcOrContext);
|
|
1157
1188
|
const sensorMap = shallowRef(/* @__PURE__ */ new Map());
|
|
@@ -1176,7 +1207,7 @@ function createSensorManager(rpcOrContext, cameraId, sensorSubjectNamespace, sen
|
|
|
1176
1207
|
}
|
|
1177
1208
|
async function subscribeToSensorEvents(sensorId) {
|
|
1178
1209
|
if (sensorSubscriptions.has(sensorId)) return;
|
|
1179
|
-
const namespace = NamespaceManager.sensorEventNamespaces(
|
|
1210
|
+
const namespace = NamespaceManager.sensorEventNamespaces(sensorId);
|
|
1180
1211
|
const unsubscribe = await rpcCall(rpcRef, (c) => c.subscribe(namespace.sensorSubject, (msg) => handlePerSensorEvent(sensorId, msg)));
|
|
1181
1212
|
sensorSubscriptions.set(sensorId, unsubscribe);
|
|
1182
1213
|
}
|
|
@@ -1191,17 +1222,33 @@ function createSensorManager(rpcOrContext, cameraId, sensorSubjectNamespace, sen
|
|
|
1191
1222
|
if (message.type === "sensor:added") {
|
|
1192
1223
|
const event = message.data;
|
|
1193
1224
|
if (sensorMap.value.has(event.sensor.id)) return;
|
|
1194
|
-
const reactiveSensor = createReactiveSensor(event.sensor, event.state, rpcRef
|
|
1225
|
+
const reactiveSensor = createReactiveSensor(event.sensor, event.state, rpcRef);
|
|
1195
1226
|
const newMap = new Map(sensorMap.value);
|
|
1196
1227
|
newMap.set(event.sensor.id, reactiveSensor);
|
|
1197
1228
|
sensorMap.value = newMap;
|
|
1198
1229
|
subscribeToSensorEvents(event.sensor.id);
|
|
1199
|
-
} else if (message.type === "sensor:
|
|
1230
|
+
} else if (message.type === "sensor:deleted") {
|
|
1200
1231
|
const event = message.data;
|
|
1201
1232
|
unsubscribeFromSensorEvents(event.sensorId);
|
|
1202
1233
|
const newMap = new Map(sensorMap.value);
|
|
1203
1234
|
newMap.delete(event.sensorId);
|
|
1204
1235
|
sensorMap.value = newMap;
|
|
1236
|
+
} else if (message.type === "sensor:connected:changed") {
|
|
1237
|
+
const event = message.data;
|
|
1238
|
+
const sensor = sensorMap.value.get(event.sensorId);
|
|
1239
|
+
if (sensor) sensor.connected.value = event.connected;
|
|
1240
|
+
} else if (message.type === "sensor:assignment:changed") {
|
|
1241
|
+
const event = message.data;
|
|
1242
|
+
const sensor = sensorMap.value.get(event.sensorId);
|
|
1243
|
+
if (!sensor) return;
|
|
1244
|
+
const cameras = new Set(sensor.assignedCameraIds.value);
|
|
1245
|
+
if (event.assigned) cameras.add(event.cameraId);
|
|
1246
|
+
else cameras.delete(event.cameraId);
|
|
1247
|
+
sensor.assignedCameraIds.value = [...cameras];
|
|
1248
|
+
} else if (message.type === "sensor:exposed:changed") {
|
|
1249
|
+
const event = message.data;
|
|
1250
|
+
const sensor = sensorMap.value.get(event.sensorId);
|
|
1251
|
+
if (sensor) sensor.exposed.value = event.exposed;
|
|
1205
1252
|
}
|
|
1206
1253
|
}
|
|
1207
1254
|
async function doInit() {
|
|
@@ -1211,12 +1258,12 @@ function createSensorManager(rpcOrContext, cameraId, sensorSubjectNamespace, sen
|
|
|
1211
1258
|
sensorSubscriptions.clear();
|
|
1212
1259
|
sensorMap.value = /* @__PURE__ */ new Map();
|
|
1213
1260
|
let pendingEvents = [];
|
|
1214
|
-
globalUnsubscribe = await rpcCall(rpcRef, (c) => c.subscribe(
|
|
1261
|
+
globalUnsubscribe = await rpcCall(rpcRef, (c) => c.subscribe(sensorsSubject, (msg) => {
|
|
1215
1262
|
if (pendingEvents) pendingEvents.push(msg);
|
|
1216
1263
|
else handleGlobalSensorEvent(msg);
|
|
1217
1264
|
}));
|
|
1218
1265
|
const [sensors, states] = await rpcCall(rpcRef, async (c) => {
|
|
1219
|
-
const proxy = c.createProxy(
|
|
1266
|
+
const proxy = c.createProxy(sensorsRpc);
|
|
1220
1267
|
return Promise.all([proxy.getSensors(), proxy.getSensorStates()]);
|
|
1221
1268
|
});
|
|
1222
1269
|
const newMap = /* @__PURE__ */ new Map();
|
|
@@ -1225,7 +1272,7 @@ function createSensorManager(rpcOrContext, cameraId, sensorSubjectNamespace, sen
|
|
|
1225
1272
|
properties: {},
|
|
1226
1273
|
capabilities: [],
|
|
1227
1274
|
type: sensor.type
|
|
1228
|
-
}, rpcRef
|
|
1275
|
+
}, rpcRef);
|
|
1229
1276
|
newMap.set(sensor.id, reactiveSensor);
|
|
1230
1277
|
}
|
|
1231
1278
|
sensorMap.value = newMap;
|
|
@@ -1281,7 +1328,7 @@ function createSensorManager(rpcOrContext, cameraId, sensorSubjectNamespace, sen
|
|
|
1281
1328
|
return sensors.value.some((s) => s.type === type);
|
|
1282
1329
|
},
|
|
1283
1330
|
async setDisplayName(sensorId, displayName) {
|
|
1284
|
-
await rpcCall(rpcRef, (c) => c.createProxy(
|
|
1331
|
+
await rpcCall(rpcRef, (c) => c.createProxy(sensorsRpc).setDisplayName(sensorId, displayName));
|
|
1285
1332
|
},
|
|
1286
1333
|
ensureInitialized,
|
|
1287
1334
|
reconnect,
|
|
@@ -1300,33 +1347,29 @@ function reconnectAllSensorManagers() {
|
|
|
1300
1347
|
cached.initPromise = cached.manager.reconnect();
|
|
1301
1348
|
});
|
|
1302
1349
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
return { manager: createSensorManager(rpcOrContext, cameraId, namespaces.sensorSubject, namespaces.sensorRpc) };
|
|
1307
|
-
});
|
|
1350
|
+
var GLOBAL_SENSOR_MANAGER_KEY = "sensors";
|
|
1351
|
+
function acquireSensorManager(rpcOrContext) {
|
|
1352
|
+
return sensorManagerCache.acquire(GLOBAL_SENSOR_MANAGER_KEY, () => ({ manager: createSensorManager(rpcOrContext) }));
|
|
1308
1353
|
}
|
|
1309
|
-
function releaseSensorManager(
|
|
1310
|
-
sensorManagerCache.release(
|
|
1354
|
+
function releaseSensorManager() {
|
|
1355
|
+
sensorManagerCache.release(GLOBAL_SENSOR_MANAGER_KEY);
|
|
1311
1356
|
}
|
|
1312
1357
|
function createSensorComposableState() {
|
|
1313
1358
|
return {
|
|
1314
|
-
|
|
1359
|
+
acquired: false,
|
|
1315
1360
|
cachedManager: void 0
|
|
1316
1361
|
};
|
|
1317
1362
|
}
|
|
1318
|
-
|
|
1363
|
+
function sensorsForCamera(manager, cameraId) {
|
|
1364
|
+
return manager.sensors.value.filter((sensor) => sensor.assignedCameraIds.value.includes(cameraId));
|
|
1365
|
+
}
|
|
1366
|
+
async function ensureSensorManager(state, cameraUi, isConnected, isLoading, error) {
|
|
1319
1367
|
if (!cameraUi.rpc.value || !isConnected) return void 0;
|
|
1320
|
-
if (state.currentCameraId && state.currentCameraId !== cameraId) {
|
|
1321
|
-
releaseSensorManager(state.currentCameraId);
|
|
1322
|
-
state.currentCameraId = void 0;
|
|
1323
|
-
state.cachedManager = void 0;
|
|
1324
|
-
}
|
|
1325
1368
|
isLoading.value = true;
|
|
1326
1369
|
error.value = void 0;
|
|
1327
1370
|
try {
|
|
1328
|
-
const cached = acquireSensorManager(
|
|
1329
|
-
state.
|
|
1371
|
+
const cached = acquireSensorManager(cameraUi);
|
|
1372
|
+
state.acquired = true;
|
|
1330
1373
|
state.cachedManager = cached.manager;
|
|
1331
1374
|
if (!cached.initPromise) cached.initPromise = cached.manager.ensureInitialized();
|
|
1332
1375
|
await cached.initPromise;
|
|
@@ -1339,9 +1382,9 @@ async function ensureSensorManager(state, cameraUi, isConnected, cameraId, isLoa
|
|
|
1339
1382
|
}
|
|
1340
1383
|
}
|
|
1341
1384
|
function cleanupSensorComposable(state) {
|
|
1342
|
-
if (state.
|
|
1343
|
-
releaseSensorManager(
|
|
1344
|
-
state.
|
|
1385
|
+
if (state.acquired) {
|
|
1386
|
+
releaseSensorManager();
|
|
1387
|
+
state.acquired = false;
|
|
1345
1388
|
state.cachedManager = void 0;
|
|
1346
1389
|
}
|
|
1347
1390
|
}
|
|
@@ -1359,7 +1402,7 @@ function useSensorById(camera, sensorId) {
|
|
|
1359
1402
|
() => toValue(sensorId)
|
|
1360
1403
|
], async ([connected, camId, senId]) => {
|
|
1361
1404
|
if (connected && camId && senId) {
|
|
1362
|
-
const manager = await ensureSensorManager(state, cameraUi, connected,
|
|
1405
|
+
const manager = await ensureSensorManager(state, cameraUi, connected, _isLoading, error);
|
|
1363
1406
|
sensor.value = manager?.getSensor(senId);
|
|
1364
1407
|
initialLoadDone.value = true;
|
|
1365
1408
|
} else {
|
|
@@ -1391,8 +1434,8 @@ function useSensorByType(camera, sensorType) {
|
|
|
1391
1434
|
() => toValue(sensorType)
|
|
1392
1435
|
], async ([connected, camId, type]) => {
|
|
1393
1436
|
if (connected && camId) {
|
|
1394
|
-
const manager = await ensureSensorManager(state, cameraUi, connected,
|
|
1395
|
-
sensor.value = manager
|
|
1437
|
+
const manager = await ensureSensorManager(state, cameraUi, connected, _isLoading, error);
|
|
1438
|
+
sensor.value = manager ? sensorsForCamera(manager, camId).find((s) => s.type === type) : void 0;
|
|
1396
1439
|
initialLoadDone.value = true;
|
|
1397
1440
|
} else {
|
|
1398
1441
|
cleanupSensorComposable(state);
|
|
@@ -1424,9 +1467,9 @@ function useSensorsByType(camera, sensorType) {
|
|
|
1424
1467
|
() => toValue(sensorType)
|
|
1425
1468
|
], async ([connected, camId, type]) => {
|
|
1426
1469
|
if (connected && camId) {
|
|
1427
|
-
const manager = await ensureSensorManager(state, cameraUi, connected,
|
|
1470
|
+
const manager = await ensureSensorManager(state, cameraUi, connected, _isLoading, error);
|
|
1428
1471
|
cachedManager.value = manager;
|
|
1429
|
-
sensorsRef.value = manager
|
|
1472
|
+
sensorsRef.value = manager ? sensorsForCamera(manager, camId).filter((s) => s.type === type) : [];
|
|
1430
1473
|
initialLoadDone.value = true;
|
|
1431
1474
|
} else {
|
|
1432
1475
|
cleanupSensorComposable(state);
|
|
@@ -1436,8 +1479,10 @@ function useSensorsByType(camera, sensorType) {
|
|
|
1436
1479
|
}, { immediate: true });
|
|
1437
1480
|
const sensors = computed(() => {
|
|
1438
1481
|
if (!cachedManager.value) return [];
|
|
1482
|
+
const camId = extractCameraId(toValue(camera));
|
|
1439
1483
|
const type = toValue(sensorType);
|
|
1440
|
-
|
|
1484
|
+
if (!camId) return [];
|
|
1485
|
+
return sensorsForCamera(cachedManager.value, camId).filter((s) => s.type === type);
|
|
1441
1486
|
});
|
|
1442
1487
|
tryOnScopeDispose(() => {
|
|
1443
1488
|
cleanupSensorComposable(state);
|
|
@@ -1460,9 +1505,9 @@ function useSensors(camera) {
|
|
|
1460
1505
|
const state = createSensorComposableState();
|
|
1461
1506
|
watch([isConnected, () => extractCameraId(toValue(camera))], async ([connected, camId]) => {
|
|
1462
1507
|
if (connected && camId) {
|
|
1463
|
-
const manager = await ensureSensorManager(state, cameraUi, connected,
|
|
1508
|
+
const manager = await ensureSensorManager(state, cameraUi, connected, _isLoading, error);
|
|
1464
1509
|
cachedManager.value = manager;
|
|
1465
|
-
sensorsRef.value = manager
|
|
1510
|
+
sensorsRef.value = manager ? sensorsForCamera(manager, camId) : [];
|
|
1466
1511
|
initialLoadDone.value = true;
|
|
1467
1512
|
} else {
|
|
1468
1513
|
cleanupSensorComposable(state);
|
|
@@ -1470,7 +1515,12 @@ function useSensors(camera) {
|
|
|
1470
1515
|
cachedManager.value = void 0;
|
|
1471
1516
|
}
|
|
1472
1517
|
}, { immediate: true });
|
|
1473
|
-
const sensors = computed(() =>
|
|
1518
|
+
const sensors = computed(() => {
|
|
1519
|
+
if (!cachedManager.value) return [];
|
|
1520
|
+
const camId = extractCameraId(toValue(camera));
|
|
1521
|
+
if (!camId) return [];
|
|
1522
|
+
return sensorsForCamera(cachedManager.value, camId);
|
|
1523
|
+
});
|
|
1474
1524
|
tryOnScopeDispose(() => {
|
|
1475
1525
|
cleanupSensorComposable(state);
|
|
1476
1526
|
sensorsRef.value = [];
|
|
@@ -1481,6 +1531,33 @@ function useSensors(camera) {
|
|
|
1481
1531
|
error
|
|
1482
1532
|
};
|
|
1483
1533
|
}
|
|
1534
|
+
function useAllSensors() {
|
|
1535
|
+
const cameraUi = useCameraUi();
|
|
1536
|
+
const { isConnected } = cameraUi;
|
|
1537
|
+
const cachedManager = shallowRef();
|
|
1538
|
+
const _isLoading = ref(false);
|
|
1539
|
+
const initialLoadDone = ref(false);
|
|
1540
|
+
const error = ref();
|
|
1541
|
+
const state = createSensorComposableState();
|
|
1542
|
+
watch([isConnected], async ([connected]) => {
|
|
1543
|
+
if (connected) {
|
|
1544
|
+
cachedManager.value = await ensureSensorManager(state, cameraUi, connected, _isLoading, error);
|
|
1545
|
+
initialLoadDone.value = true;
|
|
1546
|
+
} else {
|
|
1547
|
+
cleanupSensorComposable(state);
|
|
1548
|
+
cachedManager.value = void 0;
|
|
1549
|
+
}
|
|
1550
|
+
}, { immediate: true });
|
|
1551
|
+
const sensors = computed(() => cachedManager.value?.sensors.value ?? []);
|
|
1552
|
+
tryOnScopeDispose(() => {
|
|
1553
|
+
cleanupSensorComposable(state);
|
|
1554
|
+
});
|
|
1555
|
+
return {
|
|
1556
|
+
sensors,
|
|
1557
|
+
isLoading: computed(() => _isLoading.value || !initialLoadDone.value),
|
|
1558
|
+
error
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1484
1561
|
function useTypedSensor(camera, sensorType) {
|
|
1485
1562
|
const cameraUi = useCameraUi();
|
|
1486
1563
|
const { isConnected } = cameraUi;
|
|
@@ -1492,9 +1569,9 @@ function useTypedSensor(camera, sensorType) {
|
|
|
1492
1569
|
const state = createSensorComposableState();
|
|
1493
1570
|
watch([isConnected, () => extractCameraId(toValue(camera))], async ([connected, camId]) => {
|
|
1494
1571
|
if (connected && camId) {
|
|
1495
|
-
const manager = await ensureSensorManager(state, cameraUi, connected,
|
|
1572
|
+
const manager = await ensureSensorManager(state, cameraUi, connected, _isLoading, error);
|
|
1496
1573
|
cachedManager.value = manager;
|
|
1497
|
-
sensor.value = manager
|
|
1574
|
+
sensor.value = manager ? sensorsForCamera(manager, camId).find((s) => s.type === sensorType) : void 0;
|
|
1498
1575
|
initialLoadDone.value = true;
|
|
1499
1576
|
} else {
|
|
1500
1577
|
cleanupSensorComposable(state);
|
|
@@ -1503,11 +1580,13 @@ function useTypedSensor(camera, sensorType) {
|
|
|
1503
1580
|
}, { immediate: true });
|
|
1504
1581
|
watch(() => {
|
|
1505
1582
|
if (!cachedManager.value) return void 0;
|
|
1506
|
-
|
|
1583
|
+
const camId = extractCameraId(toValue(camera));
|
|
1584
|
+
if (!camId) return void 0;
|
|
1585
|
+
return sensorsForCamera(cachedManager.value, camId).find((s) => s.type === sensorType)?.id;
|
|
1507
1586
|
}, () => {
|
|
1508
1587
|
if (cachedManager.value) {
|
|
1509
|
-
const
|
|
1510
|
-
sensor.value =
|
|
1588
|
+
const camId = extractCameraId(toValue(camera));
|
|
1589
|
+
sensor.value = camId ? sensorsForCamera(cachedManager.value, camId).find((s) => s.type === sensorType) : void 0;
|
|
1511
1590
|
}
|
|
1512
1591
|
});
|
|
1513
1592
|
tryOnScopeDispose(() => {
|
|
@@ -1549,9 +1628,9 @@ function useClassifierSensors(camera) {
|
|
|
1549
1628
|
const state = createSensorComposableState();
|
|
1550
1629
|
watch([isConnected, () => extractCameraId(toValue(camera))], async ([connected, camId]) => {
|
|
1551
1630
|
if (connected && camId) {
|
|
1552
|
-
const manager = await ensureSensorManager(state, cameraUi, connected,
|
|
1631
|
+
const manager = await ensureSensorManager(state, cameraUi, connected, _isLoading, error);
|
|
1553
1632
|
cachedManager.value = manager;
|
|
1554
|
-
sensorsRef.value = manager
|
|
1633
|
+
sensorsRef.value = manager ? sensorsForCamera(manager, camId).filter((s) => s.type === SensorType.Classifier) : [];
|
|
1555
1634
|
initialLoadDone.value = true;
|
|
1556
1635
|
} else {
|
|
1557
1636
|
cleanupSensorComposable(state);
|
|
@@ -1559,7 +1638,12 @@ function useClassifierSensors(camera) {
|
|
|
1559
1638
|
cachedManager.value = void 0;
|
|
1560
1639
|
}
|
|
1561
1640
|
}, { immediate: true });
|
|
1562
|
-
const sensors = computed(() =>
|
|
1641
|
+
const sensors = computed(() => {
|
|
1642
|
+
if (!cachedManager.value) return [];
|
|
1643
|
+
const camId = extractCameraId(toValue(camera));
|
|
1644
|
+
if (!camId) return [];
|
|
1645
|
+
return sensorsForCamera(cachedManager.value, camId).filter((s) => s.type === SensorType.Classifier);
|
|
1646
|
+
});
|
|
1563
1647
|
tryOnScopeDispose(() => {
|
|
1564
1648
|
cleanupSensorComposable(state);
|
|
1565
1649
|
sensorsRef.value = [];
|
|
@@ -1663,8 +1747,8 @@ function getPluginStorageKey(pluginId) {
|
|
|
1663
1747
|
function getCameraStorageKey(pluginId, cameraId) {
|
|
1664
1748
|
return `plugin:${pluginId}:camera:${cameraId}`;
|
|
1665
1749
|
}
|
|
1666
|
-
function getSensorStorageKey(pluginId,
|
|
1667
|
-
return `plugin:${pluginId}:
|
|
1750
|
+
function getSensorStorageKey(pluginId, sensorId) {
|
|
1751
|
+
return `plugin:${pluginId}:sensor:${sensorId}`;
|
|
1668
1752
|
}
|
|
1669
1753
|
function acquireStorage(key, createProxy) {
|
|
1670
1754
|
return storageCache.acquire(key, () => {
|
|
@@ -1874,7 +1958,7 @@ function useCameraStorage(camera, pluginName) {
|
|
|
1874
1958
|
submitValue: operations.submitValue
|
|
1875
1959
|
};
|
|
1876
1960
|
}
|
|
1877
|
-
function useSensorStorage(
|
|
1961
|
+
function useSensorStorage(sensorId, pluginId) {
|
|
1878
1962
|
const { rpc, isConnected: clientConnected } = useCameraUi();
|
|
1879
1963
|
const config = shallowRef();
|
|
1880
1964
|
const _isLoading = ref(false);
|
|
@@ -1883,14 +1967,14 @@ function useSensorStorage(camera, sensorId, pluginId) {
|
|
|
1883
1967
|
const isConnected = ref(false);
|
|
1884
1968
|
const state = createStorageState();
|
|
1885
1969
|
const operations = createStorageOperations(state, config, _isLoading, error);
|
|
1886
|
-
function connect(
|
|
1970
|
+
function connect(senId, plugId) {
|
|
1887
1971
|
if (!rpc.value || !clientConnected.value) return false;
|
|
1888
1972
|
try {
|
|
1889
|
-
const storageKey = getSensorStorageKey(plugId,
|
|
1973
|
+
const storageKey = getSensorStorageKey(plugId, senId);
|
|
1890
1974
|
if (state.currentStorageKey && state.currentStorageKey !== storageKey) releaseStorage(state.currentStorageKey);
|
|
1891
1975
|
state.currentStorageKey = storageKey;
|
|
1892
1976
|
state.cachedStorage = acquireStorage(storageKey, () => {
|
|
1893
|
-
const namespaces = NamespaceManager.pluginSensorNamespaces(plugId,
|
|
1977
|
+
const namespaces = NamespaceManager.pluginSensorNamespaces(plugId, senId);
|
|
1894
1978
|
return rpc.value.createProxy(namespaces.sensorStorageRpc);
|
|
1895
1979
|
});
|
|
1896
1980
|
isConnected.value = true;
|
|
@@ -1902,23 +1986,21 @@ function useSensorStorage(camera, sensorId, pluginId) {
|
|
|
1902
1986
|
}
|
|
1903
1987
|
}
|
|
1904
1988
|
async function getConfig() {
|
|
1905
|
-
const cameraId = extractCameraId(toValue(camera));
|
|
1906
1989
|
const senId = toValue(sensorId);
|
|
1907
1990
|
const plugId = toValue(pluginId);
|
|
1908
|
-
if (!
|
|
1991
|
+
if (!senId || !plugId) return void 0;
|
|
1909
1992
|
if (!state.cachedStorage) {
|
|
1910
|
-
if (!connect(
|
|
1993
|
+
if (!connect(senId, plugId)) return void 0;
|
|
1911
1994
|
}
|
|
1912
1995
|
return operations.getConfig();
|
|
1913
1996
|
}
|
|
1914
1997
|
watch([
|
|
1915
1998
|
clientConnected,
|
|
1916
|
-
() => extractCameraId(toValue(camera)),
|
|
1917
1999
|
() => toValue(sensorId),
|
|
1918
2000
|
() => toValue(pluginId)
|
|
1919
|
-
], ([connected,
|
|
1920
|
-
if (connected &&
|
|
1921
|
-
connect(
|
|
2001
|
+
], ([connected, senId, plugId]) => {
|
|
2002
|
+
if (connected && senId && plugId) {
|
|
2003
|
+
connect(senId, plugId);
|
|
1922
2004
|
operations.getConfig();
|
|
1923
2005
|
} else cleanupStorage(state, isConnected, config);
|
|
1924
2006
|
initialSetupDone.value = true;
|
|
@@ -2106,14 +2188,12 @@ function createActivityMode(options) {
|
|
|
2106
2188
|
startIdleTimer();
|
|
2107
2189
|
}
|
|
2108
2190
|
break;
|
|
2109
|
-
case "activity":
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
}, resolvedConfig.activityTimeout);
|
|
2116
|
-
break;
|
|
2191
|
+
case "activity": if (hasActivity.value) {
|
|
2192
|
+
inStandby.value = false;
|
|
2193
|
+
if (!isStreamPlaying()) onStreamStart();
|
|
2194
|
+
} else activityTimeout = setTimeout(() => {
|
|
2195
|
+
if (mode.value === "activity" && !hasActivity.value) goToStandby();
|
|
2196
|
+
}, resolvedConfig.activityTimeout);
|
|
2117
2197
|
}
|
|
2118
2198
|
}
|
|
2119
2199
|
function startIdleTimer() {
|
|
@@ -2154,7 +2234,6 @@ function createActivityMode(options) {
|
|
|
2154
2234
|
if (!hasActivity.value) activityTimeout = setTimeout(() => {
|
|
2155
2235
|
goToStandby();
|
|
2156
2236
|
}, resolvedConfig.activityTimeout);
|
|
2157
|
-
break;
|
|
2158
2237
|
}
|
|
2159
2238
|
}
|
|
2160
2239
|
function resetIdleTimer() {
|
|
@@ -2293,7 +2372,7 @@ var STREAM_CONFIG = {
|
|
|
2293
2372
|
ICE_SERVERS: [{ urls: "stun:stun.l.google.com:19302" }]
|
|
2294
2373
|
},
|
|
2295
2374
|
MSE: {
|
|
2296
|
-
BUFFER_SIZE:
|
|
2375
|
+
BUFFER_SIZE: 2097152,
|
|
2297
2376
|
BUFFER_WINDOW: 5
|
|
2298
2377
|
},
|
|
2299
2378
|
CODECS: {
|
|
@@ -2755,9 +2834,7 @@ async function processWebRTCMessage(handler, msg) {
|
|
|
2755
2834
|
case "webrtc/answer":
|
|
2756
2835
|
await handler.handleAnswer(msg.value);
|
|
2757
2836
|
break;
|
|
2758
|
-
case "webrtc/candidate":
|
|
2759
|
-
if (msg.value) await handler.handleCandidate(msg.value);
|
|
2760
|
-
break;
|
|
2837
|
+
case "webrtc/candidate": if (msg.value) await handler.handleCandidate(msg.value);
|
|
2761
2838
|
}
|
|
2762
2839
|
}
|
|
2763
2840
|
//#endregion
|
|
@@ -3390,12 +3467,10 @@ var StreamConnection = class {
|
|
|
3390
3467
|
case "mse":
|
|
3391
3468
|
if (this.mseHandler && typeof msg.value === "string") this.mseHandler.initializeBuffer(msg.value);
|
|
3392
3469
|
break;
|
|
3393
|
-
case "error":
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
}
|
|
3398
|
-
break;
|
|
3470
|
+
case "error": if (this.requestedMode.value !== "auto") {
|
|
3471
|
+
this.error.value = new Error(msg.value);
|
|
3472
|
+
this.status.value = "error";
|
|
3473
|
+
}
|
|
3399
3474
|
}
|
|
3400
3475
|
}
|
|
3401
3476
|
async startWebRTC(mode) {
|
|
@@ -4575,4 +4650,4 @@ function useTerminal() {
|
|
|
4575
4650
|
};
|
|
4576
4651
|
}
|
|
4577
4652
|
//#endregion
|
|
4578
|
-
export { CAMERA_UI_INJECTION_KEY, NamespaceManager, STREAM_CONFIG, acquireSensorManager, clearCameraCache, clearOAuthCache, clearPluginCache, clearSensorCache, clearSnapshotCache, clearStorageCache, createActivityMode, createCameraUiPlugin, createReactiveCameraDevice, createSensorManager, getSnapshotUrl, isReactiveAudioSensor, isReactiveBatteryInfo, isReactiveClassifierSensor, isReactiveContactSensor, isReactiveDoorbellTrigger, isReactiveFaceSensor, isReactiveGarageControl, isReactiveHumidityInfo, isReactiveLeakSensor, isReactiveLicensePlateSensor, isReactiveLightControl, isReactiveLockControl, isReactiveMotionSensor, isReactiveObjectSensor, isReactiveOccupancySensor, isReactivePTZControl, isReactiveSecuritySystem, isReactiveSirenControl, isReactiveSmokeSensor, isReactiveSwitchControl, isReactiveTemperatureInfo, refreshClientSubscriptions, releaseSensorManager, resetClientState, rpcCall, useAudioSensor, useCameraById, useCameraStorage, useCameraStream, useCameraUi, useClassifierSensors, useCoreManager, useCuiFullscreen, useDeviceManager, useFaceSensor, useLicensePlateSensor, useMotionSensor, useOAuth, useObjectSensor, usePTZControl, usePlugin, usePluginStorage, useRpcCall, useRpcSubscription, useSensorById, useSensorByType, useSensorStorage, useSensors, useSensorsByType, useSnapshot, useTabVisibility, useTerminal, useTopmostFullscreenElement };
|
|
4653
|
+
export { CAMERA_UI_INJECTION_KEY, NamespaceManager, STREAM_CONFIG, acquireSensorManager, clearCameraCache, clearOAuthCache, clearPluginCache, clearSensorCache, clearSnapshotCache, clearStorageCache, createActivityMode, createCameraUiPlugin, createReactiveCameraDevice, createSensorManager, getSnapshotUrl, isReactiveAudioSensor, isReactiveBatteryInfo, isReactiveClassifierSensor, isReactiveContactSensor, isReactiveDoorbellTrigger, isReactiveFaceSensor, isReactiveGarageControl, isReactiveHumidityInfo, isReactiveLeakSensor, isReactiveLicensePlateSensor, isReactiveLightControl, isReactiveLockControl, isReactiveMotionSensor, isReactiveObjectSensor, isReactiveOccupancySensor, isReactivePTZControl, isReactiveSecuritySystem, isReactiveSirenControl, isReactiveSmokeSensor, isReactiveSwitchControl, isReactiveTemperatureInfo, refreshClientSubscriptions, releaseSensorManager, resetClientState, rpcCall, useAllSensors, useAudioSensor, useCameraById, useCameraStorage, useCameraStream, useCameraUi, useClassifierSensors, useCoreManager, useCuiFullscreen, useDeviceManager, useFaceSensor, useLicensePlateSensor, useMotionSensor, useOAuth, useObjectSensor, usePTZControl, usePlugin, usePluginStorage, useRpcCall, useRpcSubscription, useSensorById, useSensorByType, useSensorStorage, useSensors, useSensorsByType, useSnapshot, useTabVisibility, useTerminal, useTopmostFullscreenElement };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camera.ui/browser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.148",
|
|
4
4
|
"description": "camera.ui browser client",
|
|
5
5
|
"author": "seydx (https://github.com/cameraui/clients)",
|
|
6
6
|
"type": "module",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@camera.ui/logger": ">=0.0.2",
|
|
33
33
|
"@camera.ui/rpc": ">=1.0.10",
|
|
34
|
-
"@camera.ui/sdk": ">=
|
|
34
|
+
"@camera.ui/sdk": ">=1.2.0",
|
|
35
35
|
"@camera.ui/transport": ">=0.0.1",
|
|
36
|
-
"@vueuse/core": ">=14.
|
|
36
|
+
"@vueuse/core": ">=14.4.0",
|
|
37
37
|
"vue": ">=3.5.40"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@camera.ui/logger": "file:../../packages/logger",
|
|
41
41
|
"@camera.ui/rpc": "^1.0.10",
|
|
42
|
-
"@camera.ui/sdk": "~
|
|
42
|
+
"@camera.ui/sdk": "~1.2.0",
|
|
43
43
|
"@camera.ui/transport": "file:../../packages/transport",
|
|
44
44
|
"@eneris/push-receiver": "^4.3.1",
|
|
45
45
|
"@microsoft/api-extractor": "^7.58.12",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@vue/eslint-config-typescript": "^14.9.0",
|
|
52
52
|
"@vue/language-core": "^3.3.8",
|
|
53
53
|
"@vue/tsconfig": "^0.9.1",
|
|
54
|
-
"@vueuse/core": "^14.
|
|
54
|
+
"@vueuse/core": "^14.4.0",
|
|
55
55
|
"@webgpu/types": "^0.1.71",
|
|
56
56
|
"eslint": "9.39.2",
|
|
57
57
|
"eslint-plugin-vue": "^10.10.0",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"typescript": "5.9.3",
|
|
62
62
|
"typescript-eslint": "^8.65.0",
|
|
63
63
|
"unplugin-dts": "^1.0.3",
|
|
64
|
-
"updates": "^17.
|
|
65
|
-
"vite": "^8.
|
|
64
|
+
"updates": "^17.20.1",
|
|
65
|
+
"vite": "^8.2.0",
|
|
66
66
|
"vitest": "^4.1.10",
|
|
67
67
|
"vue": "^3.5.40",
|
|
68
68
|
"vue-tsc": "^3.3.8"
|