@camera.ui/browser 0.0.69 → 0.0.71

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.
Files changed (78) hide show
  1. package/dist/bundle.js +1 -1
  2. package/dist/types/packages/client/browser/src/proxy/cameraDevice.d.ts +3 -4
  3. package/dist/types/server/src/api/database/index.d.ts +24 -0
  4. package/dist/types/server/src/api/database/types.d.ts +12 -34
  5. package/dist/types/server/src/api/go2rtc/api/application.d.ts +9 -0
  6. package/dist/types/server/src/api/go2rtc/api/config.d.ts +9 -0
  7. package/dist/types/server/src/api/go2rtc/api/index.d.ts +2 -0
  8. package/dist/types/server/src/api/go2rtc/api/snapshot.d.ts +8 -0
  9. package/dist/types/server/src/api/go2rtc/api/streams.d.ts +11 -0
  10. package/dist/types/server/src/api/go2rtc/index.d.ts +13 -0
  11. package/dist/types/server/src/api/go2rtc/queue.d.ts +10 -0
  12. package/dist/types/server/src/api/middlewares/socketAuth.middleware.d.ts +41 -0
  13. package/dist/types/server/src/api/services/auth.service.d.ts +20 -0
  14. package/dist/types/server/src/api/services/cameras.service.d.ts +54 -0
  15. package/dist/types/server/src/api/services/plugins.service.d.ts +25 -0
  16. package/dist/types/server/src/api/services/users.service.d.ts +13 -0
  17. package/dist/types/server/src/api/utils/constants.d.ts +15 -0
  18. package/dist/types/server/src/api/websocket/index.d.ts +15 -0
  19. package/dist/types/server/src/api/websocket/nsp/frame.d.ts +10 -0
  20. package/dist/types/server/src/api/websocket/nsp/logs.d.ts +11 -0
  21. package/dist/types/server/src/api/websocket/nsp/metrics.d.ts +33 -0
  22. package/dist/types/server/src/api/websocket/nsp/notifications.d.ts +11 -0
  23. package/dist/types/server/src/api/websocket/nsp/plugins.d.ts +13 -0
  24. package/dist/types/server/src/api/websocket/nsp/server.d.ts +9 -0
  25. package/dist/types/server/src/api/websocket/nsp/status.d.ts +20 -0
  26. package/dist/types/server/src/api/websocket/nsp/streams.d.ts +15 -0
  27. package/dist/types/server/src/api/{ws → websocket}/types.d.ts +1 -1
  28. package/dist/types/server/src/api.d.ts +44 -0
  29. package/dist/types/server/src/camera/base/cameraDevice.d.ts +2 -1
  30. package/dist/types/server/src/camera/base/cameraDeviceBrowser.d.ts +1 -0
  31. package/dist/types/server/src/camera/base/index.d.ts +18 -2
  32. package/dist/types/server/src/camera/controller.d.ts +27 -0
  33. package/dist/types/server/src/camera/types.d.ts +37 -21
  34. package/dist/types/server/src/decoder/index.d.ts +11 -0
  35. package/dist/types/server/src/decoder/types.d.ts +4 -0
  36. package/dist/types/server/src/decoder/worker/index.d.ts +3 -0
  37. package/dist/types/server/src/decoder/worker/runtime/base/index.d.ts +36 -0
  38. package/dist/types/server/src/decoder/worker/runtime/child-process/index.d.ts +17 -0
  39. package/dist/types/server/src/decoder/worker/runtime/worker-thread/index.d.ts +22 -0
  40. package/dist/types/server/src/go2rtc/index.d.ts +25 -0
  41. package/dist/types/server/src/nats/constants.d.ts +1 -0
  42. package/dist/types/server/src/nats/index.d.ts +34 -0
  43. package/dist/types/server/src/nats/proxy/cameraDevice.d.ts +96 -0
  44. package/dist/types/server/src/nats/proxy/deviceManager.d.ts +31 -0
  45. package/dist/types/server/src/nats/proxy/index.d.ts +4 -0
  46. package/dist/types/server/src/nats/proxy/pluginsManager.d.ts +12 -0
  47. package/dist/types/server/src/nats/proxy/systemManager.d.ts +8 -0
  48. package/dist/types/server/src/nats/queue.d.ts +17 -0
  49. package/dist/types/server/src/nats/server.d.ts +33 -0
  50. package/dist/types/server/src/nats/types.d.ts +18 -10
  51. package/dist/types/server/src/nats/utils.d.ts +4 -0
  52. package/dist/types/server/src/nats/websocket.d.ts +22 -0
  53. package/dist/types/server/src/plugins/base.d.ts +7 -0
  54. package/dist/types/server/src/plugins/index.d.ts +31 -0
  55. package/dist/types/server/src/plugins/node/api.d.ts +42 -0
  56. package/dist/types/server/src/plugins/node/cameraStorage.d.ts +108 -0
  57. package/dist/types/server/src/plugins/node/config.d.ts +104 -0
  58. package/dist/types/server/src/plugins/node/logger.d.ts +14 -0
  59. package/dist/types/server/src/plugins/node/proxy/cameraDevice.d.ts +45 -0
  60. package/dist/types/server/src/plugins/node/proxy/deviceManager.d.ts +47 -0
  61. package/dist/types/server/src/plugins/node/proxy/index.d.ts +4 -0
  62. package/dist/types/server/src/plugins/node/proxy/pluginsManager.d.ts +38 -0
  63. package/dist/types/server/src/plugins/node/proxy/queue.d.ts +18 -0
  64. package/dist/types/server/src/plugins/node/proxy/systemManager.d.ts +36 -0
  65. package/dist/types/server/src/plugins/node/schema.d.ts +268 -0
  66. package/dist/types/server/src/plugins/node/storageController.d.ts +28 -0
  67. package/dist/types/server/src/plugins/plugin.d.ts +42 -0
  68. package/dist/types/server/src/plugins/types.d.ts +2 -2
  69. package/dist/types/server/src/plugins/worker-ipc.d.ts +22 -0
  70. package/dist/types/server/src/plugins/worker.d.ts +30 -0
  71. package/dist/types/server/src/services/config/constants.d.ts +6 -0
  72. package/dist/types/server/src/services/config/index.d.ts +60 -0
  73. package/dist/types/server/src/services/logger/index.d.ts +28 -0
  74. package/dist/types/server/src/utils/pythonInstaller.d.ts +47 -0
  75. package/dist/types/server/src/utils/utils.d.ts +6 -0
  76. package/dist/types/shared/types/index.d.ts +1 -1
  77. package/package.json +4 -3
  78. package/.eslintrc.cjs +0 -44
@@ -0,0 +1,27 @@
1
+ import { CameraDevice } from './base/cameraDevice.js';
2
+ import type { Camera } from '../api/database/types.js';
3
+ import type { Frame } from '../decoder/types.js';
4
+ import type { ProxyServer } from '../nats/index.js';
5
+ import type { IceServer } from '../services/config/types.js';
6
+ import type { BaseLogger } from './types.js';
7
+ export declare class CameraController extends CameraDevice {
8
+ private proxy;
9
+ private motionTimeout?;
10
+ private doorbellTimeout?;
11
+ private doorbellTimeoutDuration;
12
+ constructor(camera: Camera, logger: BaseLogger, proxy: ProxyServer);
13
+ connect(): Promise<void>;
14
+ disconnect(): Promise<void>;
15
+ reboot(): Promise<void>;
16
+ generateFrames(): AsyncIterableIterator<Frame>;
17
+ getFfmpegPath(): Promise<string>;
18
+ getIceServers(): Promise<IceServer[]>;
19
+ updateCamera(updatedCamera: Camera): void;
20
+ cleanup(): void;
21
+ private subscribeToCameraState;
22
+ private subscribeToMotionState;
23
+ private subscribeToDoorbellState;
24
+ private subscribeToCameraChanges;
25
+ private subscribeToStateChanges;
26
+ private triggerProxyEvent;
27
+ }
@@ -100,25 +100,31 @@ export type CameraConfig = (BaseCameraConfig & {
100
100
  }) | (BaseCameraConfig & {
101
101
  delegate?: CameraDelegate;
102
102
  });
103
- export interface BaseState {
104
- timestamp: number;
105
- lastTriggered: number;
106
- }
107
- export interface Detections {
103
+ export interface BaseDetection {
108
104
  id?: string;
109
- label?: string;
105
+ }
106
+ export interface MotionDetection extends BaseDetection {
107
+ label: string;
110
108
  boundingBox: [number, number, number, number];
111
109
  }
110
+ export interface ObjectDetection extends BaseDetection {
111
+ lebel: string;
112
+ boundingBox: [number, number, number, number];
113
+ }
114
+ export interface BaseState<T extends LightState | AudioState | MotionState | ObjectState | SirenState | BatteryState | DoorbellState> {
115
+ timestamp: number;
116
+ lastEvent?: Omit<T, 'lastEvent'>;
117
+ }
112
118
  export interface MotionSetEvent {
113
119
  state: boolean;
114
- detections: Detections[];
120
+ detections: MotionDetection[];
115
121
  }
116
122
  export interface AudioSetEvent {
117
123
  state: boolean;
124
+ db?: number;
118
125
  }
119
126
  export interface ObjectSetEvent {
120
- state: boolean;
121
- detections: Detections[];
127
+ detections: ObjectDetection[];
122
128
  }
123
129
  export interface LightSetEvent {
124
130
  state: boolean;
@@ -128,19 +134,20 @@ export interface DoorbellSetEvent {
128
134
  }
129
135
  export interface SirenSetEvent {
130
136
  state: boolean;
137
+ level?: number;
131
138
  }
132
139
  export interface BatterySetEvent {
133
- state: number;
134
- }
135
- export interface DeviceSetEvent {
136
- }
137
- export type LightState = BaseState & LightSetEvent;
138
- export type MotionState = BaseState & MotionSetEvent;
139
- export type AudioState = BaseState & AudioSetEvent;
140
- export type DoorbellState = BaseState & DoorbellSetEvent;
141
- export type SirenState = BaseState & SirenSetEvent;
142
- export type ObjectState = BaseState & ObjectSetEvent;
143
- export type BatteryState = BaseState & BatterySetEvent;
140
+ level: number;
141
+ lowBattery?: boolean;
142
+ charging?: boolean;
143
+ }
144
+ export type LightState = BaseState<LightState> & LightSetEvent;
145
+ export type MotionState = BaseState<MotionState> & MotionSetEvent;
146
+ export type AudioState = BaseState<AudioState> & AudioSetEvent;
147
+ export type DoorbellState = BaseState<DoorbellState> & DoorbellSetEvent;
148
+ export type SirenState = BaseState<SirenState> & SirenSetEvent;
149
+ export type ObjectState = BaseState<ObjectState> & ObjectSetEvent;
150
+ export type BatteryState = BaseState<BatteryState> & BatterySetEvent;
144
151
  export type State = LightState | MotionState | AudioState | ObjectState | DoorbellState | SirenState | BatteryState;
145
152
  export interface StateValues {
146
153
  light: LightState;
@@ -151,9 +158,18 @@ export interface StateValues {
151
158
  siren: SirenState;
152
159
  battery: BatteryState;
153
160
  }
161
+ export interface SetValues {
162
+ light: LightSetEvent;
163
+ motion: MotionSetEvent;
164
+ audio: AudioSetEvent;
165
+ object: ObjectSetEvent;
166
+ doorbell: DoorbellSetEvent;
167
+ siren: SirenSetEvent;
168
+ battery: BatterySetEvent;
169
+ }
154
170
  export type CameraStateCallbacks = {
155
171
  [K in keyof StateValues]: (event: StateValues[K]) => void;
156
172
  };
157
173
  export type StateValue<T extends keyof StateValues> = StateValues[T];
158
- export type OnSetEvent<T extends keyof StateValues> = T extends 'light' ? LightSetEvent : T extends 'motion' ? MotionSetEvent : T extends 'audio' ? AudioSetEvent : T extends 'doorbell' ? DoorbellSetEvent : T extends 'siren' ? SirenSetEvent : T extends 'battery' ? BatterySetEvent : ObjectSetEvent;
174
+ export type SetValue<T extends keyof SetValues> = SetValues[T];
159
175
  export type OnChangeCallback<T extends keyof StateValues> = (newEvent: StateValues[T], oldEvent: StateValues[T]) => void;
@@ -0,0 +1,11 @@
1
+ import type { CameraController } from '../camera/controller.js';
2
+ import type { StreamManager } from './worker/index.js';
3
+ export declare class Decoder {
4
+ streamManagers: Map<string, StreamManager<any>>;
5
+ private api;
6
+ private proxyServer;
7
+ private startAsWorker;
8
+ constructor();
9
+ addCamera(camera: CameraController): Promise<StreamManager>;
10
+ removeCamera(camera: CameraController): Promise<void>;
11
+ }
@@ -7,6 +7,10 @@ export interface FrameMetadata {
7
7
  width: number;
8
8
  height: number;
9
9
  }
10
+ export interface FrameSession {
11
+ token: string;
12
+ wsPort: number;
13
+ }
10
14
  export interface Frame {
11
15
  metadata: FrameMetadata;
12
16
  data: Buffer;
@@ -0,0 +1,3 @@
1
+ export { StreamManager } from './runtime/base/index.js';
2
+ export { StreamProcess } from './runtime/child-process/index.js';
3
+ export { StreamWorker } from './runtime/worker-thread/index.js';
@@ -0,0 +1,36 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import { Subscribed } from '../../../../camera/utils/subscribed.js';
4
+ import type { ChildProcess } from 'node:child_process';
5
+ import type { Worker } from 'node:worker_threads';
6
+ import type { CameraController } from '../../../../camera/controller.js';
7
+ import type { ConfigService } from '../../../../services/config/index.js';
8
+ import type { Logger } from '../../../../services/logger/index.js';
9
+ import type { FrameMetadata, MainMessage, MainToWorkerMessage, MainToWorkerResponse, WorkerToMainMessage } from '../../../types.js';
10
+ export declare abstract class StreamManager<T extends Worker | ChildProcess = any> extends Subscribed {
11
+ token: string;
12
+ protected readonly logger: Logger;
13
+ protected readonly configService: ConfigService;
14
+ protected readonly camera: CameraController;
15
+ protected frameWorker?: T;
16
+ protected stopped: boolean;
17
+ protected auth: {
18
+ user: string;
19
+ pass: string;
20
+ };
21
+ constructor(camera: CameraController, auth: {
22
+ user: string;
23
+ pass: string;
24
+ });
25
+ abstract listen(): Promise<void>;
26
+ abstract close(): Promise<void>;
27
+ abstract workerPID(): number;
28
+ getMetadata(): Promise<FrameMetadata>;
29
+ startVideoSession(): Promise<void>;
30
+ stopVideoSession(): Promise<void>;
31
+ protected onMessage(workerMessage: WorkerToMainMessage): Promise<void>;
32
+ protected abstract sendMessage(message: MainMessage, skipResponse?: boolean, data?: Record<string, any>): Promise<any>;
33
+ protected abstract sendReponse(response: MainToWorkerResponse): void;
34
+ protected abstract send(message: MainToWorkerMessage | MainToWorkerResponse): void;
35
+ protected getLogPrefix(): string;
36
+ }
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { ChildProcess } from 'node:child_process';
3
+ import { StreamManager } from '../base/index.js';
4
+ import type { CameraController } from '../../../../camera/controller.js';
5
+ import type { MainMessage, MainToWorkerMessage, MainToWorkerResponse } from '../../../types.js';
6
+ export declare class StreamProcess extends StreamManager<ChildProcess> {
7
+ constructor(camera: CameraController, auth: {
8
+ user: string;
9
+ pass: string;
10
+ });
11
+ listen(): Promise<void>;
12
+ close(): Promise<void>;
13
+ workerPID(): number;
14
+ protected sendMessage(message: MainMessage, skipResponse?: boolean, data?: Record<string, any>): Promise<any>;
15
+ protected sendReponse(response: MainToWorkerResponse): void;
16
+ protected send(message: MainToWorkerMessage | MainToWorkerResponse): void;
17
+ }
@@ -0,0 +1,22 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { Worker } from 'node:worker_threads';
3
+ import { StreamManager } from '../base/index.js';
4
+ import type { CameraController } from '../../../../camera/controller.js';
5
+ import type { MainMessage, MainToWorkerMessage, MainToWorkerResponse } from '../../../types.js';
6
+ export declare class StreamWorker extends StreamManager<Worker> {
7
+ private channel1;
8
+ private channel2;
9
+ private messageFromMain;
10
+ private messageToMain;
11
+ private responseToMain;
12
+ constructor(camera: CameraController, auth: {
13
+ user: string;
14
+ pass: string;
15
+ });
16
+ listen(): Promise<void>;
17
+ close(): Promise<void>;
18
+ workerPID(): number;
19
+ protected sendMessage(message: MainMessage, skipResponse?: boolean, data?: Record<string, any>): Promise<any>;
20
+ protected sendReponse(response: MainToWorkerResponse): void;
21
+ protected send(message: MainToWorkerMessage | MainToWorkerResponse): void;
22
+ }
@@ -0,0 +1,25 @@
1
+ import { RUNTIME_STATUS } from '../services/config/types.js';
2
+ export declare class Go2Rtc {
3
+ private go2rtcProcess?;
4
+ private api;
5
+ private logger;
6
+ private configService;
7
+ version: string;
8
+ os: string;
9
+ private started;
10
+ private restarting;
11
+ private manuallyKilled;
12
+ private shuttingDown;
13
+ private _status;
14
+ get status(): RUNTIME_STATUS;
15
+ constructor();
16
+ start(): Promise<void>;
17
+ stop(): Promise<void>;
18
+ restart(): Promise<void>;
19
+ getPID(): number;
20
+ private kill;
21
+ private handleClose;
22
+ private setStatus;
23
+ private processLogger;
24
+ private isIgnorableString;
25
+ }
@@ -0,0 +1 @@
1
+ export declare const NATS_SERVER_SUBJECT = "camera.ui-server";
@@ -0,0 +1,34 @@
1
+ import { type NatsConnection, type Subscription } from 'nats';
2
+ import { CameraDeviceProxy } from './proxy/cameraDevice.js';
3
+ import { DeviceManagerProxy, PluginsManagerProxy, SystemManagerProxy } from './proxy/index.js';
4
+ import { NatsServer } from './server.js';
5
+ import type { StateValues } from '../camera/types.js';
6
+ import type { CameraDeviceListenerMessagePayload, DeviceManagerProxyEvents, PluginsManagerProxyEvents, ProxyAuth, SystemManagerProxyEvents } from './types.js';
7
+ import type { WebsocketProxy } from './websocket.js';
8
+ export declare class ProxyServer {
9
+ private api;
10
+ private logger;
11
+ deviceManagerProxy?: DeviceManagerProxy;
12
+ pluginsManagerProxy?: PluginsManagerProxy;
13
+ systemManagerProxy?: SystemManagerProxy;
14
+ cameraDeviceProxy?: CameraDeviceProxy;
15
+ websocketProxy?: WebsocketProxy;
16
+ server: NatsServer;
17
+ publisher?: NatsConnection;
18
+ subscriber?: Subscription;
19
+ private messageQueue;
20
+ private initialized;
21
+ auth: ProxyAuth;
22
+ constructor();
23
+ initialize(): Promise<void>;
24
+ close(): Promise<void>;
25
+ publishDeviceManagerEvent<K extends keyof DeviceManagerProxyEvents>(targetId: string, type: K, data: DeviceManagerProxyEvents[K]): void;
26
+ publishSystemManagerEvent<K extends keyof SystemManagerProxyEvents>(targetId: string, type: K, data: SystemManagerProxyEvents[K]): void;
27
+ publishPluginsManagerEvent<K extends keyof PluginsManagerProxyEvents>(targetId: string, type: K, data: PluginsManagerProxyEvents[K]): void;
28
+ publishCameraEvent<K extends keyof StateValues>(cameraId: string, stateName: K, data: {
29
+ newEvent: StateValues[K];
30
+ oldEvent: StateValues[K];
31
+ }, targetId?: string): void;
32
+ publishCameraEvent(cameraId: string, type: CameraDeviceListenerMessagePayload['type'], data?: any, targetId?: string): void;
33
+ private isCameraState;
34
+ }
@@ -0,0 +1,96 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import type { Camera } from '../../api/database/types.js';
3
+ import type { CameraDelegate, CameraPrebufferDelegate, FfmpegOptions, PrebufferType, SetValues, StateValues, StreamInfo } from '../../camera/types.js';
4
+ import type { FrameMetadata, FrameSession } from '../../decoder/types.js';
5
+ import type { IceServer } from '../../services/config/types.js';
6
+ import type { MessageQueue } from '../queue.js';
7
+ import type { CameraDeviceProxyMethods, ProxyMessageStructure } from '../types.js';
8
+ export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
9
+ private api;
10
+ private configService;
11
+ private camerasService;
12
+ private pluginsService;
13
+ private socketService;
14
+ private messageQueue;
15
+ constructor(messageQueue: MessageQueue);
16
+ connect(data: {
17
+ cameraId: string;
18
+ pluginId: string;
19
+ }): void;
20
+ disconnect(data: {
21
+ cameraId: string;
22
+ pluginId: string;
23
+ }): void;
24
+ reboot(data: {
25
+ cameraId: string;
26
+ pluginId: string;
27
+ }): Promise<void>;
28
+ getStreamInfo(data: {
29
+ sourceName: string;
30
+ cameraId: string;
31
+ pluginId: string;
32
+ }): Promise<StreamInfo | undefined>;
33
+ isPrebuffering(data: {
34
+ sourceName: string;
35
+ type: PrebufferType;
36
+ cameraId: string;
37
+ pluginId: string;
38
+ }): Promise<boolean>;
39
+ getPrebufferRawUrl(data: {
40
+ sourceName: string;
41
+ type: PrebufferType;
42
+ cameraId: string;
43
+ pluginId: string;
44
+ }): Promise<string | undefined>;
45
+ getFrameMetadata(data: {
46
+ cameraId: string;
47
+ pluginId: string;
48
+ }): Promise<FrameMetadata>;
49
+ getFrameSession(data: {
50
+ cameraId: string;
51
+ pluginId: string;
52
+ }): Promise<FrameSession>;
53
+ getFfmpegPath(): string;
54
+ getIceServers(): IceServer[];
55
+ snapshot(data: {
56
+ forceNew?: boolean;
57
+ cameraId: string;
58
+ pluginId: string;
59
+ }): Promise<ArrayBuffer>;
60
+ streamVideo(data: {
61
+ sourceName: string;
62
+ options: FfmpegOptions;
63
+ cameraId: string;
64
+ pluginId: string;
65
+ }): Promise<void>;
66
+ recordToFile(data: {
67
+ sourceName: string;
68
+ outputPath: string;
69
+ duration?: number;
70
+ cameraId: string;
71
+ pluginId: string;
72
+ }): Promise<void>;
73
+ updateState<T extends keyof SetValues>(data: {
74
+ stateName: T;
75
+ eventData: SetValues[T];
76
+ cameraId: string;
77
+ pluginId: string;
78
+ }): Promise<void>;
79
+ refreshStates(data: {
80
+ cameraId: string;
81
+ pluginId: string;
82
+ }): {
83
+ camera: Camera;
84
+ states: StateValues;
85
+ cameraState: boolean;
86
+ };
87
+ onRequestReboot(pluginId: string, cameraId: string, ...args: Parameters<CameraDelegate['reboot']>): Promise<Buffer>;
88
+ onRequestGetStreamInfo(pluginId: string, cameraId: string, ...args: Parameters<CameraPrebufferDelegate['getStreamInfo']>): Promise<StreamInfo | undefined>;
89
+ onRequestIsPrebuffering(pluginId: string, cameraId: string, ...args: Parameters<CameraPrebufferDelegate['isPrebuffering']>): Promise<boolean>;
90
+ onRequestGetRawUrl(pluginId: string, cameraId: string, ...args: Parameters<CameraPrebufferDelegate['getPrebufferRawUrl']>): Promise<string | undefined>;
91
+ onRequestSnapshotRequest(pluginId: string, cameraId: string, ...args: Parameters<CameraDelegate['snapshotRequest']>): Promise<Buffer>;
92
+ onRequestPrepareStream(pluginId: string, cameraId: string, ...args: Parameters<CameraDelegate['prepareStream']>): Promise<void>;
93
+ onRequestWebRTCOffer(pluginId: string, cameraId: string, ...args: Parameters<CameraDelegate['onOffer']>): Promise<string>;
94
+ onRequestWebRTCIceCandidates(pluginId: string, cameraId: string, ...args: Parameters<CameraDelegate['onCandidates']>): Promise<void>;
95
+ handleMessage(message: ProxyMessageStructure): Promise<void>;
96
+ }
@@ -0,0 +1,31 @@
1
+ import type { Camera } from '../../api/database/types.js';
2
+ import type { CameraConfig } from '../../camera/types.js';
3
+ import type { MessageQueue } from '../queue.js';
4
+ import type { DeviceManagerServerProxyMethods, ProxyMessageStructure } from '../types.js';
5
+ export declare class DeviceManagerProxy implements DeviceManagerServerProxyMethods {
6
+ private camerasService;
7
+ private pluginsService;
8
+ private messageQueue;
9
+ constructor(messageQueue: MessageQueue);
10
+ getCameraByName(data: {
11
+ name: string;
12
+ pluginId: string;
13
+ }): Camera | undefined;
14
+ getCameraById(data: {
15
+ id: string;
16
+ pluginId: string;
17
+ }): Camera | void;
18
+ createCamera(data: {
19
+ camera: CameraConfig;
20
+ pluginId: string;
21
+ }): Promise<Camera>;
22
+ removeCameraByName(data: {
23
+ name: string;
24
+ pluginId: string;
25
+ }): Promise<void>;
26
+ removeCameraById(data: {
27
+ id: string;
28
+ pluginId: string;
29
+ }): Promise<void>;
30
+ handleMessage(message: ProxyMessageStructure): Promise<void>;
31
+ }
@@ -0,0 +1,4 @@
1
+ export { CameraDeviceProxy } from './cameraDevice.js';
2
+ export { DeviceManagerProxy } from './deviceManager.js';
3
+ export { PluginsManagerProxy } from './pluginsManager.js';
4
+ export { SystemManagerProxy } from './systemManager.js';
@@ -0,0 +1,12 @@
1
+ import type { BasePlugin } from '../../plugins/base.js';
2
+ import type { CameraStorage } from '../../plugins/node/cameraStorage.js';
3
+ import type { MessageQueue } from '../queue.js';
4
+ import type { CallablePluginMethods, CallablePluginStorageMethods, PluginsManagerServerProxyMethods, ProxyMessageStructure } from '../types.js';
5
+ export declare class PluginsManagerProxy implements PluginsManagerServerProxyMethods {
6
+ private pluginsService;
7
+ private messageQueue;
8
+ constructor(messageQueue: MessageQueue);
9
+ onRequestPluginFn<K extends keyof CallablePluginMethods>(pluginId: string, fn: K, ...args: Parameters<BasePlugin[K]>): Promise<ReturnType<BasePlugin[K]>>;
10
+ onRequestStorageFn<K extends keyof CallablePluginStorageMethods>(pluginId: string, cameraId: string, fn: K, ...args: Parameters<CameraStorage[K]>): Promise<Awaited<ReturnType<CameraStorage[K]>>>;
11
+ handleMessage(message: ProxyMessageStructure): Promise<void>;
12
+ }
@@ -0,0 +1,8 @@
1
+ import type { MessageQueue } from '../queue.js';
2
+ import type { ProxyMessageStructure, SystemManagerServerProxyMethods } from '../types.js';
3
+ export declare class SystemManagerProxy implements SystemManagerServerProxyMethods {
4
+ private pluginsService;
5
+ private messageQueue;
6
+ constructor(messageQueue: MessageQueue);
7
+ handleMessage(message: ProxyMessageStructure): Promise<void>;
8
+ }
@@ -0,0 +1,17 @@
1
+ import type { ProxyServer } from './index.js';
2
+ import type { ProxyMessageStructure } from './types.js';
3
+ export declare class MessageQueue {
4
+ private logger;
5
+ private proxyServer;
6
+ private publisher;
7
+ private subscriber;
8
+ private aborted;
9
+ private isProcessing;
10
+ private queue;
11
+ private pendingResponses;
12
+ constructor(proxyServer: ProxyServer);
13
+ abortQueue(): void;
14
+ enqueue(message: ProxyMessageStructure): Promise<any>;
15
+ private processQueue;
16
+ private listenToMessages;
17
+ }
@@ -0,0 +1,33 @@
1
+ import { RUNTIME_STATUS } from '../services/config/types.js';
2
+ import type { ProxyAuth } from './types.js';
3
+ export declare class NatsServer {
4
+ readonly serverPort = 4222;
5
+ readonly websocketPort = 8223;
6
+ private readonly clusterAmount;
7
+ private readonly serverClusterPort;
8
+ private readonly auth;
9
+ private serverProcess?;
10
+ private clusterProcesses;
11
+ private logger;
12
+ private configService;
13
+ private tmpDir;
14
+ private manuallyKilled;
15
+ private shuttingDown;
16
+ private _status;
17
+ get status(): RUNTIME_STATUS;
18
+ constructor(auth: ProxyAuth);
19
+ start(): Promise<void>;
20
+ private startServer;
21
+ private startClusterServer;
22
+ private setupProcess;
23
+ stop(): Promise<void>;
24
+ restart(): Promise<void>;
25
+ getPID(): number;
26
+ private writeConfigFile;
27
+ private stringifyConfig;
28
+ private kill;
29
+ private handleClose;
30
+ private setStatus;
31
+ private processLogger;
32
+ private isIgnorableString;
33
+ }
@@ -1,8 +1,10 @@
1
1
  import type { Camera } from '../api/database/types.js';
2
2
  import type { CameraDevice } from '../camera/base/cameraDevice.js';
3
3
  import type { BrowserCameraDevice } from '../camera/base/cameraDeviceBrowser.js';
4
- import type { CameraConfig, FfmpegOptions, OnSetEvent, PrebufferType, StateValues, StreamInfo } from '../camera/types.js';
5
- import type { FrameMetadata } from '../decoder/types.js';
4
+ import type { CameraConfig, FfmpegOptions, PrebufferType, SetValues, StateValues, StreamInfo } from '../camera/types.js';
5
+ import type { FrameMetadata, FrameSession } from '../decoder/types.js';
6
+ import type { BasePlugin } from '../plugins/base.js';
7
+ import type { CameraStorage } from '../plugins/node/cameraStorage.js';
6
8
  import type { CameraExtension } from '../plugins/types.js';
7
9
  import type { IceServer } from '../services/config/types.js';
8
10
  export type MethodKeys<T> = {
@@ -60,11 +62,11 @@ export interface DeviceManagerServerProxyMethods {
60
62
  getCameraByName(data: {
61
63
  name: string;
62
64
  pluginId: string;
63
- }): Promise<Camera | undefined>;
65
+ }): Camera | void;
64
66
  getCameraById(data: {
65
67
  id: string;
66
68
  pluginId: string;
67
- }): Promise<Camera | undefined>;
69
+ }): Camera | void;
68
70
  removeCameraByName(data: {
69
71
  name: string;
70
72
  pluginId: string;
@@ -82,11 +84,11 @@ export interface CameraDeviceProxyMethods {
82
84
  connect(data: {
83
85
  cameraId: string;
84
86
  pluginId: string;
85
- }): Promise<void>;
87
+ }): void;
86
88
  disconnect(data: {
87
89
  cameraId: string;
88
90
  pluginId: string;
89
- }): Promise<void>;
91
+ }): void;
90
92
  reboot(data: {
91
93
  cameraId: string;
92
94
  pluginId: string;
@@ -112,6 +114,10 @@ export interface CameraDeviceProxyMethods {
112
114
  cameraId: string;
113
115
  pluginId: string;
114
116
  }): Promise<FrameMetadata>;
117
+ getFrameSession(data: {
118
+ cameraId: string;
119
+ pluginId: string;
120
+ }): Promise<FrameSession>;
115
121
  getFfmpegPath(data: {
116
122
  cameraId: string;
117
123
  pluginId: string;
@@ -138,20 +144,20 @@ export interface CameraDeviceProxyMethods {
138
144
  cameraId: string;
139
145
  pluginId: string;
140
146
  }): Promise<void>;
141
- updateState<T extends keyof StateValues>(data: {
147
+ updateState<T extends keyof SetValues>(data: {
142
148
  stateName: T;
143
- eventData: OnSetEvent<T>;
149
+ eventData: SetValues[T];
144
150
  cameraId: string;
145
151
  pluginId: string;
146
152
  }): void;
147
153
  refreshStates(data: {
148
154
  cameraId: string;
149
155
  pluginId: string;
150
- }): Promise<{
156
+ }): {
151
157
  camera: Camera;
152
158
  states: StateValues;
153
159
  cameraState: boolean;
154
- }>;
160
+ };
155
161
  }
156
162
  export type CameraDeviceProxyMethodNames = MethodKeys<CameraDeviceProxyMethods>;
157
163
  export interface DeviceManagerListenerMessagePayload {
@@ -235,6 +241,8 @@ export interface PluginsManagerProxyGenericEvent<K extends keyof PluginsManagerP
235
241
  type: K;
236
242
  data: PluginsManagerProxyEvents[K];
237
243
  }
244
+ export type CallablePluginStorageMethods = Pick<CameraStorage, 'getConfig' | 'setConfig'>;
245
+ export type CallablePluginMethods = Pick<BasePlugin, 'onFormSubmit'>;
238
246
  export interface CameraDeviceListenerStatePayload<K extends keyof StateValues> {
239
247
  stateName: K;
240
248
  data: {
@@ -0,0 +1,4 @@
1
+ export declare function generateSecureCredentials(): {
2
+ user: string;
3
+ pass: string;
4
+ };
@@ -0,0 +1,22 @@
1
+ import type { Namespace, Server } from 'socket.io';
2
+ import type { SocketNsp } from '../api/websocket/types.js';
3
+ import type { StateValues } from '../camera/types.js';
4
+ import type { CameraDeviceListenerMessagePayload } from './types.js';
5
+ export declare class WebsocketProxy {
6
+ nsp: Namespace;
7
+ nspName: SocketNsp;
8
+ private proxy;
9
+ constructor(io: Server);
10
+ init(): void;
11
+ publishCameraEvent<K extends keyof StateValues>(cameraId: string, stateName: K, data: {
12
+ newEvent: StateValues[K];
13
+ oldEvent: StateValues[K];
14
+ }): void;
15
+ publishCameraEvent(cameraId: string, type: CameraDeviceListenerMessagePayload['type'], data?: any): void;
16
+ private setupEventListeners;
17
+ private isSystemManagerMethod;
18
+ private isDeviceManagerMethod;
19
+ private isPluginsManagerMethod;
20
+ private isCameraManagerMethod;
21
+ private isCameraState;
22
+ }
@@ -0,0 +1,7 @@
1
+ import type { CameraDevice } from '../camera/base/cameraDevice.js';
2
+ export declare abstract class BasePlugin {
3
+ abstract onFormSubmit(actionId: string, payload: any): Promise<{
4
+ toast?: string;
5
+ }>;
6
+ abstract configureCameras(cameras: CameraDevice[]): Promise<void>;
7
+ }
@@ -0,0 +1,31 @@
1
+ import 'reflect-metadata';
2
+ import { Plugin } from './plugin.js';
3
+ import { PluginWorker } from './worker.js';
4
+ import type { IPackageJson } from '../api/types/index.js';
5
+ export declare class PluginManager {
6
+ private logger;
7
+ private api;
8
+ private configService;
9
+ private pythonVersionsToInstall;
10
+ plugins: Map<string, Plugin>;
11
+ pluginWorkers: Map<string, PluginWorker>;
12
+ searchPaths: Set<string>;
13
+ constructor();
14
+ static isQualifiedPluginIdentifier(pluginName: string): boolean;
15
+ static extractPluginScope(pluginName: string): string;
16
+ static extractPluginName(pluginName: string): string;
17
+ static transformDisplaName(pluginName: string): string;
18
+ static loadPackageJSON(installPath: string): IPackageJson;
19
+ initializeInstalledPlugins(): Promise<void>;
20
+ initializeInstalledPlugin(plugin: Plugin): Promise<void>;
21
+ loadPlugin(absolutePath: string, pluginId?: string, storagePath?: string): Promise<Plugin>;
22
+ removePlugin(plugin: Plugin, removeFromDb?: boolean, removeStorage?: boolean): Promise<void>;
23
+ startPluginChild(pluginName: string): Promise<void>;
24
+ stopPluginChild(pluginName: string): Promise<void>;
25
+ initializePlugins(): Promise<void>;
26
+ installRequiredPythonEnvs(): Promise<void>;
27
+ private loadInstalledPlugins;
28
+ private removeOrphanedPlugins;
29
+ private loadDefaultPaths;
30
+ private addNpmPrefixToSearchPaths;
31
+ }