@camera.ui/browser 0.0.6 → 0.0.30

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 (46) hide show
  1. package/dist/bundle.browser.js +1 -1
  2. package/dist/client/node/src/client.d.ts +0 -1
  3. package/dist/client/node/src/proxy/cameraDevice/cameraDevice.browser.d.ts +19 -9
  4. package/dist/client/node/src/proxy/cameraDevice/cameraDevice.node.d.ts +4 -2
  5. package/dist/client/node/src/proxy/deviceManager.d.ts +1 -2
  6. package/dist/client/node/src/socket.d.ts +5 -1
  7. package/dist/client/node/src/types.d.ts +1 -2
  8. package/dist/src/api/database/types.d.ts +20 -5
  9. package/dist/src/api/go2rtc/api/application.d.ts +2 -2
  10. package/dist/src/api/go2rtc/api/snapshot.d.ts +3 -2
  11. package/dist/src/api/go2rtc/api/streams.d.ts +6 -5
  12. package/dist/src/api/go2rtc/types.d.ts +14 -0
  13. package/dist/src/api/schemas/cameras.schema.d.ts +25 -29
  14. package/dist/src/api/schemas/config.schema.d.ts +2 -2
  15. package/dist/src/api/services/cameras.service.d.ts +4 -1
  16. package/dist/src/api/utils/constants.d.ts +15 -0
  17. package/dist/src/api.d.ts +4 -4
  18. package/dist/src/camera/index.d.ts +25 -13
  19. package/dist/src/camera/streaming/peer-connection.d.ts +6 -5
  20. package/dist/src/camera/streaming/streaming-session.d.ts +5 -6
  21. package/dist/src/camera/streaming/webrtc-connection.d.ts +7 -8
  22. package/dist/src/camera/types.d.ts +28 -8
  23. package/dist/src/plugins/base.d.ts +1 -1
  24. package/dist/src/plugins/index.d.ts +7 -2
  25. package/dist/src/plugins/plugin.d.ts +5 -2
  26. package/dist/src/plugins/types.d.ts +5 -1
  27. package/dist/src/plugins/worker.d.ts +1 -0
  28. package/dist/src/proxy/client/cameraDevice.d.ts +9 -14
  29. package/dist/src/proxy/client/deviceManager.d.ts +4 -12
  30. package/dist/src/proxy/client/pluginsManager.d.ts +3 -11
  31. package/dist/src/proxy/client/queue.d.ts +11 -0
  32. package/dist/src/proxy/client/systemManager.d.ts +3 -11
  33. package/dist/src/proxy/constants.d.ts +7 -0
  34. package/dist/src/proxy/index.d.ts +12 -6
  35. package/dist/src/proxy/proxies/camera.d.ts +35 -9
  36. package/dist/src/proxy/proxies/plugin.d.ts +3 -23
  37. package/dist/src/proxy/proxies/server.d.ts +6 -6
  38. package/dist/src/proxy/queue.d.ts +15 -0
  39. package/dist/src/proxy/types.d.ts +62 -6
  40. package/dist/src/proxy/ws/index.d.ts +0 -9
  41. package/dist/src/services/config/constants.d.ts +6 -0
  42. package/dist/src/services/config/index.d.ts +1 -1
  43. package/dist/src/services/logger/index.d.ts +2 -0
  44. package/package.json +2 -2
  45. package/dist/src/api/utils/cert.d.ts +0 -17
  46. /package/dist/src/plugins/{storage.d.ts → storageController.d.ts} +0 -0
@@ -1,8 +1,8 @@
1
1
  import { ReplaySubject, Subject, type Observable } from 'rxjs';
2
2
  import { Subscribed } from '../subscribed';
3
3
  import type { RtpPacket } from 'werift';
4
- import type { CameraInput } from '../../api/database/types';
5
- import type { StreamingConnectionOptions, BaseLogger } from '../types';
4
+ import type { StreamingConnectionOptions, CameraDevice } from '../types';
5
+ import type { IceServer } from '../../services/config/types';
6
6
  export declare class WebrtcConnection extends Subscribed {
7
7
  readonly onCameraConnected: ReplaySubject<void>;
8
8
  readonly onCallAnswered: ReplaySubject<string>;
@@ -19,14 +19,13 @@ export declare class WebrtcConnection extends Subscribed {
19
19
  private readonly onOfferSent;
20
20
  private hasEnded;
21
21
  private logger;
22
- private cameraName;
23
- private cameraInput;
24
- constructor(cameraName: string, cameraInput: CameraInput, options: StreamingConnectionOptions, logger: BaseLogger);
22
+ private cameraDevice;
23
+ constructor(cameraDevice: CameraDevice, sourceName: string, iceServers: IceServer[], options: StreamingConnectionOptions);
24
+ sendAudioPacket(rtp: RtpPacket): void;
25
+ stop(): void;
26
+ requestKeyFrame(): void;
25
27
  private initiateCall;
26
28
  private handleMessage;
27
29
  private sendMessage;
28
- sendAudioPacket(rtp: RtpPacket): void;
29
30
  private callEnded;
30
- stop(): void;
31
- requestKeyFrame(): void;
32
31
  }
@@ -1,8 +1,9 @@
1
1
  import type { Observable, Subject } from 'rxjs';
2
2
  import type { ConnectionState, RTCIceCandidate } from 'werift';
3
- import type { CameraInputSettings, CameraInput, Camera } from '../api/database/types';
3
+ import type { CameraInput, Camera, CameraPublicProperties, CameraInputSettings } from '../api/database/types';
4
4
  import type { StreamingSession } from './streaming/streaming-session';
5
5
  export type SpawnInput = string | number;
6
+ export type PrebufferType = 'recording' | 'stream';
6
7
  export interface BaseLogger {
7
8
  log: (...args: any[]) => void;
8
9
  error: (...args: any[]) => void;
@@ -34,28 +35,40 @@ export interface BasicPeerConnection {
34
35
  }
35
36
  export interface CameraDevice {
36
37
  id: string;
38
+ disabled: boolean;
37
39
  name: string;
38
- pluginId: string;
39
40
  nativeId?: string;
41
+ isCloud: boolean;
42
+ hasLight: boolean;
43
+ hasSiren: boolean;
44
+ hasMotionDetector: boolean;
45
+ hasAudioDetector: boolean;
46
+ hasObjectDetector: boolean;
47
+ hasPtz: boolean;
40
48
  type: string;
41
49
  model: string;
42
- sources: CameraInput[];
50
+ sources: Input[];
51
+ logger: BaseLogger;
43
52
  onLightDetected: Observable<LightState>;
44
53
  onMotionDetected: Observable<MotionState>;
45
54
  onAudioDetected: Observable<AudioState>;
46
55
  onObjectDetected: Observable<ObjectState>;
47
56
  onDoorbellPressed: Observable<DoorbellState>;
48
57
  onSirenDetected: Observable<SirenState>;
58
+ snapshot(): Promise<ArrayBuffer>;
59
+ setPrebufferSource(sourceName: string, address: string | null, type: 'recording' | 'stream'): Promise<void>;
60
+ getFfmpegPath(): Promise<string>;
61
+ getIceServers(): Promise<RTCIceServer[]>;
49
62
  getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
50
- createSession(cameraInput: CameraInput, options?: StreamingConnectionOptions): Promise<StreamingSession>;
51
- streamVideo(cameraInput: CameraInput, options: FfmpegOptions): Promise<StreamingSession>;
52
- recordToFile(cameraInput: CameraInput, outputPath: string, duration?: number): Promise<void>;
53
- updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): void;
63
+ createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
64
+ streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
65
+ recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
66
+ updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
54
67
  onStateChange<T extends keyof StateValues>(stateName: T): Observable<{
55
68
  newState: StateValues[T];
56
69
  oldState: StateValues[T];
57
70
  }>;
58
- onPropertyChange<T extends keyof Camera>(property: T): Observable<{
71
+ onPropertyChange<T extends keyof CameraPublicProperties>(property: T): Observable<{
59
72
  oldState: Camera[T];
60
73
  newState: Camera[T];
61
74
  }>;
@@ -84,10 +97,17 @@ export type Go2RtcOutgoingMessage = Go2RtcOfferMessage | Go2RtcIceCandidateMessa
84
97
  export interface CameraConfig {
85
98
  name: string;
86
99
  nativeId?: string;
100
+ isCloud?: boolean;
101
+ hasLight?: boolean;
102
+ hasSiren?: boolean;
87
103
  disabled?: boolean;
88
104
  model?: string;
89
105
  sources: CameraInputSettings[];
90
106
  }
107
+ export interface Input extends CameraInput {
108
+ readonly isStreamPrebuffering?: boolean;
109
+ readonly isRecordingPrebuffering?: boolean;
110
+ }
91
111
  export interface BaseState {
92
112
  timestamp: number;
93
113
  lastTriggered: number;
@@ -3,7 +3,7 @@ import type { CameraDevice } from '../camera/types';
3
3
  import type { PluginLogger } from '../services/logger';
4
4
  import type { PluginConfigService } from './config';
5
5
  import type { BasePlugin as BasePluginMethods } from './types';
6
- import type { Storage } from './storage';
6
+ import type { Storage } from './storageController';
7
7
  export declare class BasePlugin implements BasePluginMethods {
8
8
  id: string;
9
9
  api: API;
@@ -26,11 +26,16 @@ export declare class PluginManager {
26
26
  initializePlugin(plugin: Plugin, pluginName: string): Promise<void>;
27
27
  loadPlugin(absolutePath: string, pluginId?: string, storagePath?: string): Promise<Plugin>;
28
28
  removePlugin(plugin: Plugin, removeFromDb?: boolean, removeStorage?: boolean): Promise<void>;
29
- startPluginChild(pluginName: string): Promise<void>;
30
29
  startPluginChilds(): Promise<void>;
30
+ startPluginChild(pluginName: string): Promise<void>;
31
+ stopPluginChild(pluginName: string): Promise<void>;
31
32
  private loadInstalledPlugins;
32
- private loadDefaultPaths;
33
33
  private removeOrphanedPlugins;
34
+ private buildDependencyGraph;
35
+ private groupPlugins;
36
+ private topologicalSort;
34
37
  private handlePluginRegistration;
38
+ private loadDefaultPaths;
35
39
  private addNpmPrefixToSearchPaths;
40
+ private isDependencyForOthers;
36
41
  }
@@ -16,7 +16,7 @@ export interface Context {
16
16
  * Represents a loaded camera.ui plugin.
17
17
  */
18
18
  export declare class Plugin {
19
- disabled: boolean;
19
+ _disabled: boolean;
20
20
  private logger;
21
21
  private configService;
22
22
  private _info;
@@ -35,8 +35,11 @@ export declare class Plugin {
35
35
  private loadContext?;
36
36
  private pluginInitializer?;
37
37
  private pluginConstructor;
38
- get info(): CameraUiPlugin;
39
38
  get contract(): PluginContract;
39
+ get info(): CameraUiPlugin;
40
+ set info(value: CameraUiPlugin);
41
+ get disabled(): boolean;
42
+ set disabled(value: boolean);
40
43
  constructor(pluginName: string, installPath: string, packageJSON: IPackageJson, pluginId: string, scope?: string, storagePath?: string);
41
44
  getPluginConstructor(pluginName: string): PluginConstructor;
42
45
  initialize(api: CameraUiAPI): void | Promise<void>;
@@ -1,5 +1,8 @@
1
1
  import type { Camera } from '../api/database/types';
2
2
  import type { CameraDevice } from '../camera/types';
3
+ export type PluginGraph = Map<string, string[]>;
4
+ export type PluginCycles = Map<string, string[]>;
5
+ export type PluginGroups = Map<string, string[]>;
3
6
  export interface SchemaConfig {
4
7
  rootSchema: PluginRootSchema;
5
8
  config: Record<string, any>;
@@ -23,12 +26,13 @@ export interface JSONObject {
23
26
  }
24
27
  export type JSONArray = JSONValue[];
25
28
  export type PluginConfig = Record<string, any>;
26
- export type CameraExtension = 'hub' | 'prebuffer' | 'motionDetection' | 'objectDetection' | 'soundDetection' | 'intercom' | 'ptz';
29
+ export type CameraExtension = 'hub' | 'prebuffer' | 'motionDetection' | 'objectDetection' | 'audioDetection' | 'ptz';
27
30
  export declare const CAMERA_EXTENSIONS: CameraExtension[];
28
31
  export interface PluginContract {
29
32
  pluginName: string;
30
33
  builtIns?: CameraExtension[];
31
34
  extension?: CameraExtension;
35
+ dependencies?: string[];
32
36
  }
33
37
  export declare const enum PLUGIN_STATUS {
34
38
  READY = "ready",
@@ -18,6 +18,7 @@ export declare class PluginWorker {
18
18
  teardown(): Promise<void>;
19
19
  restart(): Promise<void>;
20
20
  getPID(): number;
21
+ isRunning(): boolean;
21
22
  private gatherDevices;
22
23
  private kill;
23
24
  private setStatus;
@@ -1,29 +1,24 @@
1
1
  import { CameraDeviceHub } from '../../camera';
2
2
  import type { Camera } from '../../api/database/types';
3
- import type { StateValues, OnSetEvent } from '../../camera/types';
4
- import type { Logger, PluginLogger } from '../../services/logger';
5
- export declare class CameraDeviceProxy extends CameraDeviceHub {
3
+ import type { StateValues, OnSetEvent, BaseLogger, PrebufferType } from '../../camera/types';
4
+ import type { IceServer } from '../../services/config/types';
5
+ export declare class CameraDeviceClientProxy extends CameraDeviceHub {
6
6
  private targetId;
7
7
  private targetName;
8
8
  private clientTargetId;
9
9
  private subTargetId;
10
+ private pluginId;
10
11
  private api;
11
- private log;
12
12
  private client;
13
13
  private subscriber;
14
- private timeout;
15
- private requestIdCounter;
16
- private pendingRequests;
17
- private requestQueue;
18
- private isProcessing;
14
+ private messageQueue;
19
15
  private close?;
20
- constructor(camera: Camera, logger: Logger | PluginLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string);
16
+ constructor(camera: Camera, logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string);
17
+ setPrebufferSource(sourceName: string, address: string | null, type: PrebufferType): Promise<void>;
18
+ getFfmpegPath(): Promise<string>;
19
+ getIceServers(): Promise<IceServer[]>;
21
20
  updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
22
21
  refreshStates(): Promise<void>;
23
22
  private listenToSubscriberEvents;
24
23
  private onRequest;
25
- private enqueueAndProcessRequest;
26
- private processNextRequest;
27
- private onReply;
28
- private resolveRequest;
29
24
  }
@@ -1,6 +1,6 @@
1
+ import { CameraDeviceClientProxy } from '../client/cameraDevice';
2
+ import type { CameraConfig, CameraDevice, BaseLogger } from '../../camera/types';
1
3
  import type { DeviceManagerProxyMethods, DeviceManagerProxyEventCallbacks } from '../types';
2
- import type { Logger, PluginLogger } from '../../services/logger';
3
- import type { CameraConfig, CameraDevice } from '../../camera/types';
4
4
  export declare class DeviceManager implements DeviceManagerProxyMethods {
5
5
  private pluginId;
6
6
  private pluginName;
@@ -10,18 +10,14 @@ export declare class DeviceManager implements DeviceManagerProxyMethods {
10
10
  private logger;
11
11
  private client;
12
12
  private subscriber;
13
+ private messageQueue;
13
14
  private reqServerAddress;
14
15
  private pubServerAddress;
15
16
  private serverPublicKey;
16
17
  private MAX_LISTENERS_PER_EVENT;
17
- private timeout;
18
- private requestIdCounter;
19
- private pendingRequests;
20
- private requestQueue;
21
- private isProcessing;
22
18
  private devices;
23
19
  private eventListeners;
24
- constructor(logger: Logger | PluginLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string);
20
+ constructor(logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string, cameraDevices?: CameraDeviceClientProxy[]);
25
21
  getCameraById(id: string): Promise<CameraDevice | undefined>;
26
22
  getCameraByName(name: string): Promise<CameraDevice | undefined>;
27
23
  createCamera(cameraConfig: CameraConfig): Promise<CameraDevice>;
@@ -32,9 +28,5 @@ export declare class DeviceManager implements DeviceManagerProxyMethods {
32
28
  removeAllListeners<E extends keyof DeviceManagerProxyEventCallbacks>(eventType?: E): void;
33
29
  private listenToSubscriberEvents;
34
30
  private onRequest;
35
- private enqueueAndProcessRequest;
36
- private processNextRequest;
37
- private onReply;
38
- private resolveRequest;
39
31
  private addCamera;
40
32
  }
@@ -1,5 +1,5 @@
1
+ import type { BaseLogger } from '../../camera/types';
1
2
  import type { PluginsManagerProxyMethods, PluginsManagerProxyEventCallbacks } from '../types';
2
- import type { Logger, PluginLogger } from '../../services/logger';
3
3
  export declare class PluginsManager implements PluginsManagerProxyMethods {
4
4
  private pluginId;
5
5
  private pluginName;
@@ -12,24 +12,16 @@ export declare class PluginsManager implements PluginsManagerProxyMethods {
12
12
  private client;
13
13
  private subscriber;
14
14
  private dealer;
15
+ private messageQueue;
15
16
  private MAX_LISTENERS_PER_EVENT;
16
- private timeout;
17
- private requestIdCounter;
18
- private pendingRequests;
19
- private requestQueue;
20
- private isProcessing;
21
17
  private eventListeners;
22
- constructor(logger: Logger | PluginLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, routerAddress: string, serverPublicKey: string);
18
+ constructor(logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, routerAddress: string, serverPublicKey: string);
23
19
  listen<E extends keyof PluginsManagerProxyEventCallbacks>(eventType: E, callback: PluginsManagerProxyEventCallbacks[E]): void;
24
20
  removeListener<E extends keyof PluginsManagerProxyEventCallbacks>(eventType: E, callbackToRemove: PluginsManagerProxyEventCallbacks[E]): void;
25
21
  removeAllListeners<E extends keyof PluginsManagerProxyEventCallbacks>(eventType?: E): void;
26
22
  private listenToSubscriberEvents;
27
23
  private listenToRouterRequests;
28
24
  private onRequest;
29
- private enqueueAndProcessRequest;
30
- private processNextRequest;
31
- private onReply;
32
- private resolveRequest;
33
25
  private isPluginMessage;
34
26
  private isStorageMessage;
35
27
  }
@@ -0,0 +1,11 @@
1
+ import { Request } from 'zeromq';
2
+ export declare class ClientMessageQueue {
3
+ private requestClient;
4
+ private queue;
5
+ private isProcessing;
6
+ private pendingResponses;
7
+ constructor(requestClient: Request);
8
+ enqueue(message: any, timeout?: number): Promise<any>;
9
+ private processQueue;
10
+ private listenToReplies;
11
+ }
@@ -1,5 +1,5 @@
1
+ import type { BaseLogger } from '../../camera/types';
1
2
  import type { SystemManagerProxyMethods, SystemManagerProxyEventCallbacks } from '../types';
2
- import type { Logger, PluginLogger } from '../../services/logger';
3
3
  export declare class SystemManager implements SystemManagerProxyMethods {
4
4
  private pluginId;
5
5
  private pluginName;
@@ -9,21 +9,13 @@ export declare class SystemManager implements SystemManagerProxyMethods {
9
9
  private logger;
10
10
  private client;
11
11
  private subscriber;
12
+ private messageQueue;
12
13
  private MAX_LISTENERS_PER_EVENT;
13
- private timeout;
14
- private requestIdCounter;
15
- private pendingRequests;
16
- private requestQueue;
17
- private isProcessing;
18
14
  private eventListeners;
19
- constructor(logger: Logger | PluginLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string);
15
+ constructor(logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string);
20
16
  listen<E extends keyof SystemManagerProxyEventCallbacks>(eventType: E, callback: SystemManagerProxyEventCallbacks[E]): void;
21
17
  removeListener<E extends keyof SystemManagerProxyEventCallbacks>(eventType: E, callbackToRemove: SystemManagerProxyEventCallbacks[E]): void;
22
18
  removeAllListeners<E extends keyof SystemManagerProxyEventCallbacks>(eventType?: E): void;
23
19
  private listenToSubscriberEvents;
24
20
  private onRequest;
25
- private enqueueAndProcessRequest;
26
- private processNextRequest;
27
- private onReply;
28
- private resolveRequest;
29
21
  }
@@ -0,0 +1,7 @@
1
+ import type { SocketOptions, Router, Reply, Publisher, Request, Dealer, Subscriber } from 'zeromq';
2
+ export declare const ROUTER_OPTIONS: SocketOptions<Router>;
3
+ export declare const REPLY_OPTIONS: SocketOptions<Reply>;
4
+ export declare const PUBLISHER_OPTIONS: SocketOptions<Publisher>;
5
+ export declare const REQUEST_OPTIONS: SocketOptions<Request>;
6
+ export declare const SUBSCRIBER_OPTIONS: SocketOptions<Subscriber>;
7
+ export declare const DEALER_OPTIONS: SocketOptions<Dealer>;
@@ -1,20 +1,26 @@
1
+ import { Reply, Router, Publisher } from 'zeromq';
1
2
  import { ServerProxy } from './proxies/server';
2
3
  import { CameraDeviceProxy } from './proxies/camera';
3
4
  import { PluginProxy } from './proxies/plugin';
4
- import type { ProxyEvents, TargetID } from './types';
5
+ import type { ProxyBridge } from './ws';
6
+ import type { ProxyEvents, TargetID, QueueItem } from './types';
5
7
  export declare class ProxyServer {
6
8
  server?: ServerProxy;
7
9
  camera?: CameraDeviceProxy;
8
10
  plugin?: PluginProxy;
9
11
  private logger;
10
12
  private configService;
11
- private router;
12
- private reqServer;
13
- private pubServer;
14
- private socketBridge?;
13
+ router: Router;
14
+ reqServer: Reply;
15
+ pubServer: Publisher;
16
+ socketBridge?: ProxyBridge;
17
+ private messageQueue;
15
18
  constructor();
16
19
  initialize(): Promise<void>;
17
20
  close(): Promise<void>;
21
+ sendMessage(item: QueueItem): Promise<void>;
18
22
  publishEvent<K extends keyof ProxyEvents>(targetId: TargetID, type: K, data: ProxyEvents[K]): Promise<void>;
19
- private reqMessages;
23
+ private listenToRequestMessages;
24
+ private listenToRouterMessages;
25
+ private isProxyMessage;
20
26
  }
@@ -1,13 +1,25 @@
1
- import type { Publisher, Reply } from 'zeromq';
2
- import type { CameraDeviceProxyMessageStructure, CameraDeviceProxyMethods, CameraDeviceListenerMessagePayload, CameraId } from '../types';
1
+ import type { CameraInput } from '../../api/database/types';
3
2
  import type { OnSetEvent, StateValues } from '../../camera/types';
4
- import type { ProxyBridge } from '../ws';
3
+ import type { IceServer } from '../../services/config/types';
4
+ import type { FfmpegOptions, PrebufferType } from '../../camera/types';
5
+ import type { ProxyServer } from '..';
6
+ import type { CameraDeviceProxyMessageStructure, CameraDeviceProxyMethods, CameraDeviceListenerMessagePayload, CameraId } from '../types';
5
7
  export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
6
8
  private api;
7
- private reqServer;
8
- private pubServer;
9
- private socketBridge;
10
- constructor(reqServer: Reply, pubServer: Publisher, socketBridge: ProxyBridge);
9
+ private configService;
10
+ private camerasService;
11
+ private pluginsService;
12
+ private proxyServer;
13
+ constructor(proxyServer: ProxyServer);
14
+ setPrebufferSource(data: {
15
+ sourceName: string;
16
+ address: string | null;
17
+ type: PrebufferType;
18
+ cameraId: string;
19
+ pluginId: string;
20
+ }): Promise<void>;
21
+ getFffmpegPath(): string;
22
+ getIceServers(): IceServer[];
11
23
  updateState<T extends keyof StateValues>(data: {
12
24
  stateName: T;
13
25
  eventData: OnSetEvent<T>;
@@ -15,8 +27,22 @@ export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
15
27
  }): void;
16
28
  refreshStates(data: {
17
29
  cameraId: string;
18
- }): StateValues | undefined;
19
- reqMessages(msg: CameraDeviceProxyMessageStructure): Promise<void>;
30
+ }): {
31
+ sources: CameraInput[];
32
+ states: StateValues;
33
+ } | undefined;
34
+ streamVideo(data: {
35
+ sourceName: string;
36
+ options: FfmpegOptions;
37
+ cameraId: string;
38
+ }): Promise<void>;
39
+ recordToFile(data: {
40
+ sourceName: string;
41
+ outputPath: string;
42
+ duration?: number;
43
+ cameraId: string;
44
+ }): Promise<void>;
45
+ handleMessage(msg: CameraDeviceProxyMessageStructure): Promise<void>;
20
46
  publishCameraMessage<K extends keyof StateValues>(cameraId: CameraId, stateName: K, data: {
21
47
  newEvent: StateValues[K];
22
48
  oldEvent: StateValues[K];
@@ -1,30 +1,10 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- /// <reference types="node" />
6
- import type { Router } from 'zeromq';
7
1
  import { type CameraStorage, type BasePlugin } from '../../plugins/types';
2
+ import type { ProxyServer } from '..';
8
3
  import type { MethodKeys } from '../types';
9
4
  export declare class PluginProxy {
10
- private logger;
11
5
  private pluginsService;
12
- private router;
13
- private timeout;
14
- private pluginRequestIdCounter;
15
- private storageRequestIdCounter;
16
- pendingRequests: Map<string, {
17
- resolve: (value: unknown) => void;
18
- reject: (reason?: any) => void;
19
- timeout: NodeJS.Timeout;
20
- }>;
21
- private requestQueue;
22
- private isProcessing;
23
- constructor(router: Router);
6
+ private proxyServer;
7
+ constructor(proxyServer: ProxyServer);
24
8
  onRequestPluginFn<K extends Exclude<MethodKeys<BasePlugin>, 'configureCameras'>>(pluginId: string, fn: K, ...args: Parameters<BasePlugin[K]>): Promise<ReturnType<BasePlugin[K]>>;
25
9
  onRequestStorageFn<K extends MethodKeys<CameraStorage>>(pluginId: string, cameraId: string, fn: K, ...args: Parameters<CameraStorage[K]>): Promise<ReturnType<CameraStorage[K]>>;
26
- private enqueueAndProcessRequest;
27
- private processNextRequest;
28
- private onReply;
29
- private resolveRequest;
30
10
  }
@@ -1,5 +1,5 @@
1
- import type { Reply } from 'zeromq';
2
- import type { ApiProxyMethods, SystemProxyMethods, ProxyMessageStructure } from '../types';
1
+ import type { ProxyServer } from '..';
2
+ import type { ApiProxyMethods, ProxyMessageStructure } from '../types';
3
3
  import type { Camera } from '../../api/database/types';
4
4
  import type { CameraConfig } from '../../camera/types';
5
5
  export declare interface ServerProxy {
@@ -7,11 +7,11 @@ export declare interface ServerProxy {
7
7
  removeListener(): any;
8
8
  removeAllListeners(): any;
9
9
  }
10
- export declare class ServerProxy implements ApiProxyMethods, SystemProxyMethods {
10
+ export declare class ServerProxy implements ApiProxyMethods {
11
11
  private camerasService;
12
12
  private pluginsService;
13
- private reqServer;
14
- constructor(reqServer: Reply);
13
+ private proxyServer;
14
+ constructor(proxyServer: ProxyServer);
15
15
  getCameraByName(data: {
16
16
  name: string;
17
17
  }): Promise<Camera | undefined>;
@@ -30,5 +30,5 @@ export declare class ServerProxy implements ApiProxyMethods, SystemProxyMethods
30
30
  id: string;
31
31
  pluginId: string;
32
32
  }): Promise<void>;
33
- reqMessages(msg: ProxyMessageStructure): Promise<void>;
33
+ handleMessage(msg: ProxyMessageStructure): Promise<void>;
34
34
  }
@@ -0,0 +1,15 @@
1
+ import type { Reply, Router } from 'zeromq';
2
+ import type { QueueItem } from './types';
3
+ export declare class MessageQueue {
4
+ private queue;
5
+ private isProcessing;
6
+ private pendingResponses;
7
+ private reqServer;
8
+ private router;
9
+ constructor(reqServer: Reply, router: Router);
10
+ addToQueue(item: QueueItem): Promise<void>;
11
+ receiveResponse(requestId: string, response: any): void;
12
+ receiveError(requestId: string, error: Error): void;
13
+ private processQueue;
14
+ private sendMessage;
15
+ }
@@ -1,17 +1,34 @@
1
1
  /// <reference types="node" />
2
- import type { Camera } from '../api/database/types';
2
+ import type { Camera, CameraInput } from '../api/database/types';
3
3
  import type { BasePlugin, CameraStorage } from '../plugins/types';
4
- import type { CameraConfig, OnSetEvent, StateValues, CameraDevice } from '../camera/types';
4
+ import type { CameraConfig, OnSetEvent, StateValues, CameraDevice, FfmpegOptions, PrebufferType } from '../camera/types';
5
+ import type { IceServer } from '../services/config/types';
5
6
  export type MethodKeys<T> = {
6
7
  [K in keyof T]: T[K] extends Function ? K : never;
7
8
  }[keyof T];
9
+ export interface ClientQueueItem {
10
+ requestId: string;
11
+ message: any;
12
+ resolve: (response: any) => void;
13
+ reject: (error: Error) => void;
14
+ timeout: number;
15
+ }
16
+ export interface QueueItem {
17
+ requestType: 'router' | 'request';
18
+ targetId: string;
19
+ requestId: string;
20
+ message: any;
21
+ timeout?: number;
22
+ onResponse?: (response: any) => void;
23
+ onError?: (error: Error) => void;
24
+ }
8
25
  export interface RequestPayload {
9
26
  fn: string;
10
27
  data: Record<string, any>;
11
28
  requestId: string;
12
29
  }
13
30
  export interface QueueRequestItem {
14
- payload: RequestPayload;
31
+ payload: CameraDeviceProxyMessageStructure | ProxyMessageStructure;
15
32
  resolve: (value: any) => void;
16
33
  reject: (reason?: any) => void;
17
34
  timeout: NodeJS.Timeout;
@@ -40,7 +57,7 @@ export type CameraId = string;
40
57
  export type PluginId = string;
41
58
  export type TargetID = CameraId | PluginId | 'all';
42
59
  export interface PendingMessagePayload {
43
- replyTo: string;
60
+ requestId: string;
44
61
  response?: any;
45
62
  }
46
63
  export interface ListenerMessagePayload {
@@ -82,7 +99,9 @@ export interface ApiProxyMethods {
82
99
  pluginId: string;
83
100
  }): Promise<void>;
84
101
  }
85
- export interface SystemProxyMethods {
102
+ export interface WsManagerClientMessage {
103
+ method: ProxyMethodNames;
104
+ args: any[];
86
105
  }
87
106
  export interface DeviceManagerListenerMessagePayload {
88
107
  type: keyof DeviceManagerProxyEventCallbacks;
@@ -170,14 +189,47 @@ export interface CameraDeviceProxyMessageStructure {
170
189
  timestamp: number;
171
190
  }
172
191
  export interface CameraDeviceProxyMethods {
192
+ setPrebufferSource(data: {
193
+ sourceName: string;
194
+ address: string | null;
195
+ type: PrebufferType;
196
+ cameraId: string;
197
+ pluginId: string;
198
+ }): Promise<void>;
199
+ getFffmpegPath(data: {
200
+ cameraId: string;
201
+ pluginId: string;
202
+ }): string;
203
+ getIceServers(data: {
204
+ cameraId: string;
205
+ pluginId: string;
206
+ }): IceServer[];
173
207
  updateState<T extends keyof StateValues>(data: {
174
208
  stateName: T;
175
209
  eventData: OnSetEvent<T>;
176
210
  cameraId: string;
211
+ pluginId: string;
177
212
  }): void;
178
213
  refreshStates(data: {
179
214
  cameraId: string;
180
- }): StateValues | undefined;
215
+ pluginId: string;
216
+ }): {
217
+ sources: CameraInput[];
218
+ states: StateValues;
219
+ } | undefined;
220
+ streamVideo(data: {
221
+ sourceName: string;
222
+ options: FfmpegOptions;
223
+ cameraId: string;
224
+ pluginId: string;
225
+ }): Promise<void>;
226
+ recordToFile(data: {
227
+ sourceName: string;
228
+ outputPath: string;
229
+ duration?: number;
230
+ cameraId: string;
231
+ pluginId: string;
232
+ }): Promise<void>;
181
233
  }
182
234
  export type CameraDeviceProxyMethodNames = MethodKeys<CameraDeviceProxyMethods>;
183
235
  export type CameraDeviceProxyEventCallbacks = {
@@ -187,3 +239,7 @@ export interface CameraDeviceProxyGenericEvent<K extends keyof StateValues> {
187
239
  type: K;
188
240
  data: StateValues[K];
189
241
  }
242
+ export interface WsCameraDeviceClientMessage {
243
+ method: CameraDeviceProxyMethodNames;
244
+ args: any[];
245
+ }