@camera.ui/browser 0.0.34 → 0.0.35

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 (34) hide show
  1. package/dist/bundle.js +1 -1
  2. package/dist/client/node/src/proxy/cameraDevice/cameraDevice.browser.d.ts +20 -10
  3. package/dist/src/api/database/types.d.ts +49 -21
  4. package/dist/src/api/go2rtc/api/application.d.ts +4 -3
  5. package/dist/src/api/go2rtc/api/config.d.ts +4 -3
  6. package/dist/src/api/go2rtc/api/snapshot.d.ts +4 -3
  7. package/dist/src/api/go2rtc/api/streams.d.ts +5 -5
  8. package/dist/src/api/go2rtc/index.d.ts +13 -4
  9. package/dist/src/api/go2rtc/queue.d.ts +10 -0
  10. package/dist/src/api/schemas/cameras.schema.d.ts +363 -7
  11. package/dist/src/api/schemas/config.schema.d.ts +3 -0
  12. package/dist/src/api/services/cameras.service.d.ts +17 -7
  13. package/dist/src/api/services/plugins.service.d.ts +2 -0
  14. package/dist/src/api/types/index.d.ts +22 -3
  15. package/dist/src/camera/index.d.ts +22 -11
  16. package/dist/src/camera/types.d.ts +32 -12
  17. package/dist/src/plugins/cameraStorage.d.ts +3 -1
  18. package/dist/src/plugins/index.d.ts +0 -3
  19. package/dist/src/plugins/plugin.d.ts +1 -1
  20. package/dist/src/plugins/types.d.ts +16 -6
  21. package/dist/src/proxy/client/cameraDevice.d.ts +9 -8
  22. package/dist/src/proxy/client/deviceManager.d.ts +13 -12
  23. package/dist/src/proxy/client/pluginsManager.d.ts +9 -12
  24. package/dist/src/proxy/client/queue.d.ts +8 -7
  25. package/dist/src/proxy/client/systemManager.d.ts +9 -9
  26. package/dist/src/proxy/index.d.ts +13 -7
  27. package/dist/src/proxy/proxies/camera.d.ts +40 -20
  28. package/dist/src/proxy/proxies/plugin.d.ts +5 -4
  29. package/dist/src/proxy/proxies/server.d.ts +4 -9
  30. package/dist/src/proxy/queue.d.ts +6 -9
  31. package/dist/src/proxy/types.d.ts +58 -87
  32. package/dist/src/services/config/index.d.ts +0 -1
  33. package/dist/src/services/config/types.d.ts +1 -0
  34. package/package.json +2 -2
@@ -1,6 +1,8 @@
1
+ /// <reference types="pouchdb-core" />
2
+ /// <reference types="node" />
1
3
  import type { Observable, Subject } from 'rxjs';
2
4
  import type { ConnectionState, RTCIceCandidate } from 'werift';
3
- import type { CameraInput, Camera, CameraPublicProperties, CameraInputSettings } from '../api/database/types';
5
+ import type { Camera, CameraPublicProperties, CameraInputSettings, CameraZone, CameraSource } from '../api/database/types';
4
6
  import type { StreamingSession } from './streaming/streaming-session';
5
7
  export type SpawnInput = string | number;
6
8
  export type PrebufferType = 'recording' | 'stream';
@@ -35,9 +37,16 @@ export interface BasicPeerConnection {
35
37
  }
36
38
  export interface CameraDevice {
37
39
  id: string;
40
+ pluginId: string;
41
+ nativeId?: string;
38
42
  disabled: boolean;
39
43
  name: string;
40
- nativeId?: string;
44
+ type: string;
45
+ model: string;
46
+ sources: CameraSource[];
47
+ motionZones: CameraZone[];
48
+ objectZones: CameraZone[];
49
+ logger: BaseLogger;
41
50
  isCloud: boolean;
42
51
  hasLight: boolean;
43
52
  hasSiren: boolean;
@@ -45,37 +54,44 @@ export interface CameraDevice {
45
54
  hasAudioDetector: boolean;
46
55
  hasObjectDetector: boolean;
47
56
  hasPtz: boolean;
48
- type: string;
49
- model: string;
50
- sources: CameraInput[];
51
- logger: BaseLogger;
52
57
  onLightDetected: Observable<LightState>;
53
58
  onMotionDetected: Observable<MotionState>;
54
59
  onAudioDetected: Observable<AudioState>;
55
60
  onObjectDetected: Observable<ObjectState>;
56
61
  onDoorbellPressed: Observable<DoorbellState>;
57
62
  onSirenDetected: Observable<SirenState>;
58
- snapshot(sourceName?: string, prebuffer?: boolean): Promise<ArrayBuffer>;
63
+ getStreamSource(): CameraSource;
64
+ getSnapshotSource(): CameraSource;
65
+ getRecordingSource(): CameraSource;
66
+ getDetectionSource(): CameraSource;
67
+ configureDelegate(delegate: CameraDelegate): void;
68
+ snapshot(prebuffer?: boolean): Promise<ArrayBuffer>;
59
69
  setPrebufferSource(sourceName: string, address: string, type: 'recording' | 'stream'): Promise<void>;
60
70
  removePrebufferSource(sourceName: string, type: 'recording' | 'stream'): Promise<void>;
61
71
  removePrebufferSources(): Promise<void>;
62
72
  getFfmpegPath(): Promise<string>;
63
73
  getIceServers(): Promise<RTCIceServer[]>;
64
- getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
65
74
  createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
66
75
  streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
67
76
  recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
77
+ getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
68
78
  updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
69
79
  onStateChange<T extends keyof StateValues>(stateName: T): Observable<{
70
80
  newState: StateValues[T];
71
81
  oldState: StateValues[T];
72
82
  }>;
73
83
  onPropertyChange<T extends keyof CameraPublicProperties>(property: T): Observable<{
74
- oldState: Camera[T];
75
- newState: Camera[T];
84
+ oldData: Camera[T];
85
+ newData: Camera[T];
76
86
  }>;
77
87
  removeAllListeners(): void;
78
88
  }
89
+ export interface CameraDelegate {
90
+ snapshotRequest(requestId: string): Promise<Buffer>;
91
+ prepareStream(requestId: string): Promise<void>;
92
+ onOffer(requestId: string, sdp: string): Promise<string>;
93
+ onCandidates(requestId: string, candidates: string): Promise<void>;
94
+ }
79
95
  export type Sdp = string;
80
96
  export type IceCandiate = string;
81
97
  export interface Go2RtcOfferMessage {
@@ -96,7 +112,7 @@ export interface ErrorMessage {
96
112
  }
97
113
  export type Go2RtcIncomingMessage = Go2RtcAnswerMessage | Go2RtcIceCandidateMessage | ErrorMessage;
98
114
  export type Go2RtcOutgoingMessage = Go2RtcOfferMessage | Go2RtcIceCandidateMessage;
99
- export interface CameraConfig {
115
+ export interface BaseCameraConfig {
100
116
  name: string;
101
117
  nativeId?: string;
102
118
  isCloud?: boolean;
@@ -104,8 +120,12 @@ export interface CameraConfig {
104
120
  hasSiren?: boolean;
105
121
  disabled?: boolean;
106
122
  model?: string;
107
- sources: CameraInputSettings[];
108
123
  }
124
+ export type CameraConfig = (BaseCameraConfig & {
125
+ sources?: Omit<CameraInputSettings, '_id'>[];
126
+ }) | (BaseCameraConfig & {
127
+ delegate?: CameraDelegate;
128
+ });
109
129
  export interface BaseState {
110
130
  timestamp: number;
111
131
  lastTriggered: number;
@@ -22,7 +22,8 @@ export declare class CameraStorage implements CameraStorageMethods {
22
22
  * @param path - The path to the configuration value.
23
23
  * @returns The value from the configuration.
24
24
  */
25
- getValue<T = string>(path: string): Promise<T> | undefined;
25
+ getValue<T = string>(path: string, defaultValue: T): Promise<T> | T;
26
+ getValue<T = string>(path: string, defaultValue?: T): Promise<T> | T | undefined;
26
27
  /**
27
28
  * Set a new value for a given key/path in the configuration.
28
29
  * If the schema of the value has an onSet function, and the value has changed, the onSet function will be called.
@@ -101,4 +102,5 @@ export declare class CameraStorage implements CameraStorageMethods {
101
102
  private filterStorableValues;
102
103
  private containsStorableSchema;
103
104
  private saveDb;
105
+ private removeDb;
104
106
  }
@@ -31,9 +31,6 @@ export declare class PluginManager {
31
31
  stopPluginChild(pluginName: string): Promise<void>;
32
32
  private loadInstalledPlugins;
33
33
  private removeOrphanedPlugins;
34
- private buildDependencyGraph;
35
- private groupPlugins;
36
- private topologicalSort;
37
34
  private handlePluginRegistration;
38
35
  private loadDefaultPaths;
39
36
  private addNpmPrefixToSearchPaths;
@@ -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
+ private _disabled;
20
20
  private logger;
21
21
  private configService;
22
22
  private _info;
@@ -26,14 +26,21 @@ export interface JSONObject {
26
26
  }
27
27
  export type JSONArray = JSONValue[];
28
28
  export type PluginConfig = Record<string, any>;
29
- export type CameraExtension = 'hub' | 'prebuffer' | 'motionDetection' | 'objectDetection' | 'audioDetection' | 'ptz';
30
29
  export declare const CAMERA_EXTENSIONS: CameraExtension[];
31
- export interface PluginContract {
30
+ export type CameraExtension = 'hub' | 'prebuffer' | 'motionDetection' | 'objectDetection' | 'audioDetection' | 'ptz';
31
+ type ExtensionOrSupport = {
32
+ extension: CameraExtension;
33
+ supportAdditionalCameras?: never;
34
+ } | {
35
+ extension?: never;
36
+ supportAdditionalCameras?: boolean;
37
+ };
38
+ export interface PluginContractBase {
32
39
  pluginName: string;
33
- builtIns?: CameraExtension[];
34
- extension?: CameraExtension;
40
+ builtIns?: Exclude<CameraExtension, 'hub'>[];
35
41
  dependencies?: string[];
36
42
  }
43
+ export type PluginContract = PluginContractBase & ExtensionOrSupport;
37
44
  export declare const enum PLUGIN_STATUS {
38
45
  READY = "ready",
39
46
  STARTING = "starting",
@@ -54,7 +61,6 @@ export interface PluginStorage {
54
61
  }
55
62
  export interface ZmqInfo {
56
63
  zmqRouterAddress: string;
57
- zmqReqAddress: string;
58
64
  zmqPubAddress: string;
59
65
  zmqPublicKey: string;
60
66
  }
@@ -87,7 +93,7 @@ export interface JsonBaseSchema<T = any> {
87
93
  }
88
94
  export interface PluginJsonBaseSchema<T = any> extends JsonBaseSchema<T> {
89
95
  store?: boolean;
90
- onSet?: (newValue: any, oldValue: any) => void | Promise<void>;
96
+ onSet?: (newValue: any, oldValue: any) => Promise<void> | void;
91
97
  onGet?: () => any | Promise<any>;
92
98
  }
93
99
  export interface JsonSchemaString extends JsonBaseSchema<string> {
@@ -130,10 +136,12 @@ export interface PluginJsonSchemaEnum extends PluginJsonBaseSchema<string | numb
130
136
  }
131
137
  export interface JsonSchemaObject extends JsonBaseSchema {
132
138
  type: 'object';
139
+ opened?: boolean;
133
140
  properties?: JsonSchemaForm;
134
141
  }
135
142
  export interface PluginJsonSchemaObject extends PluginJsonBaseSchema {
136
143
  type: 'object';
144
+ opened?: boolean;
137
145
  properties?: PluginJsonSchemaForm;
138
146
  }
139
147
  export interface JsonSchemaObjectWithButtons extends JsonSchemaObject {
@@ -144,6 +152,7 @@ export interface JsonSchemaAnyOf {
144
152
  }
145
153
  export interface JsonSchemaArray extends JsonBaseSchema {
146
154
  type: 'array';
155
+ opened?: boolean;
147
156
  items?: JsonSchema | JsonSchemaAnyOf;
148
157
  }
149
158
  export interface JsonSchemaButton {
@@ -164,3 +173,4 @@ export interface RootSchema {
164
173
  export interface PluginRootSchema {
165
174
  schema: PluginJsonSchemaForm;
166
175
  }
176
+ export {};
@@ -1,19 +1,19 @@
1
1
  import { CameraDeviceHub } from '../../camera';
2
2
  import type { Camera } from '../../api/database/types';
3
- import type { StateValues, OnSetEvent, BaseLogger, PrebufferType } from '../../camera/types';
3
+ import type { StateValues, OnSetEvent, PrebufferType, CameraDelegate } from '../../camera/types';
4
4
  import type { IceServer } from '../../services/config/types';
5
5
  export declare class CameraDeviceClientProxy extends CameraDeviceHub {
6
- private targetId;
7
- private targetName;
8
- private clientTargetId;
9
- private subTargetId;
10
- private pluginId;
6
+ private removed;
11
7
  private api;
12
- private client;
8
+ private dealer;
13
9
  private subscriber;
14
10
  private messageQueue;
11
+ private dealerId;
12
+ private subscriberId;
13
+ private pluginID;
15
14
  private close?;
16
- constructor(camera: Camera, logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string);
15
+ constructor(camera: Camera, pluginId: string, pluginName: string, routerAddress: string, publisherAddress: string, serverPublicKey: string);
16
+ configureDelegate(delegate: CameraDelegate): void;
17
17
  setPrebufferSource(sourceName: string, address: string | null, type: PrebufferType): Promise<void>;
18
18
  removePrebufferSource(sourceName: string, type: 'recording' | 'stream'): Promise<void>;
19
19
  removePrebufferSources(): Promise<void>;
@@ -21,6 +21,7 @@ export declare class CameraDeviceClientProxy extends CameraDeviceHub {
21
21
  getIceServers(): Promise<IceServer[]>;
22
22
  updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
23
23
  refreshStates(): Promise<void>;
24
+ private handleRouterRequest;
24
25
  private listenToSubscriberEvents;
25
26
  private onRequest;
26
27
  }
@@ -1,23 +1,23 @@
1
1
  import { CameraDeviceClientProxy } from '../client/cameraDevice';
2
- import type { CameraConfig, CameraDevice, BaseLogger } from '../../camera/types';
3
- import type { DeviceManagerProxyMethods, DeviceManagerProxyEventCallbacks } from '../types';
4
- export declare class DeviceManager implements DeviceManagerProxyMethods {
5
- private pluginId;
6
- private pluginName;
7
- private clientTargetId;
8
- private subTargetId;
2
+ import type { CameraConfig, CameraDevice } from '../../camera/types';
3
+ import type { DeviceManagerProxyMethods, DeviceManagerProxyEventCallbacks, DeviceManagerProxyMethodsListener } from '../types';
4
+ export declare class DeviceManager implements DeviceManagerProxyMethods, DeviceManagerProxyMethodsListener {
9
5
  private api;
10
6
  private logger;
11
- private client;
7
+ private dealer;
12
8
  private subscriber;
13
9
  private messageQueue;
14
- private reqServerAddress;
15
- private pubServerAddress;
10
+ private routerAddress;
11
+ private publisherAddress;
16
12
  private serverPublicKey;
13
+ private pluginId;
14
+ private pluginName;
15
+ private dealerId;
16
+ private subscriberId;
17
17
  private MAX_LISTENERS_PER_EVENT;
18
18
  private devices;
19
19
  private eventListeners;
20
- constructor(logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string, cameraDevices?: CameraDeviceClientProxy[]);
20
+ constructor(pluginId: string, pluginName: string, routerAddress: string, publisherAddress: string, serverPublicKey: string, cameraDevices?: CameraDeviceClientProxy[]);
21
21
  getCameraById(id: string): Promise<CameraDevice | undefined>;
22
22
  getCameraByName(name: string): Promise<CameraDevice | undefined>;
23
23
  createCamera(cameraConfig: CameraConfig): Promise<CameraDevice>;
@@ -26,7 +26,8 @@ export declare class DeviceManager implements DeviceManagerProxyMethods {
26
26
  listen<E extends keyof DeviceManagerProxyEventCallbacks>(eventType: E, callback: DeviceManagerProxyEventCallbacks[E]): void;
27
27
  removeListener<E extends keyof DeviceManagerProxyEventCallbacks>(eventType: E, callbackToRemove: DeviceManagerProxyEventCallbacks[E]): void;
28
28
  removeAllListeners<E extends keyof DeviceManagerProxyEventCallbacks>(eventType?: E): void;
29
+ private handleRouterRequest;
29
30
  private listenToSubscriberEvents;
30
31
  private onRequest;
31
- private addCamera;
32
+ private addOrGetCamera;
32
33
  }
@@ -1,26 +1,23 @@
1
- import type { BaseLogger } from '../../camera/types';
2
- import type { PluginsManagerProxyMethods, PluginsManagerProxyEventCallbacks } from '../types';
3
- export declare class PluginsManager implements PluginsManagerProxyMethods {
4
- private pluginId;
5
- private pluginName;
6
- private clientTargetId;
7
- private subTargetId;
8
- private dealerTargetId;
1
+ import type { PluginsManagerProxyMethods, PluginsManagerProxyMethodsListener, PluginsManagerProxyEventCallbacks } from '../types';
2
+ export declare class PluginsManager implements PluginsManagerProxyMethods, PluginsManagerProxyMethodsListener {
9
3
  private api;
10
4
  private logger;
11
5
  private plugin?;
12
- private client;
13
- private subscriber;
14
6
  private dealer;
7
+ private subscriber;
15
8
  private messageQueue;
9
+ private pluginId;
10
+ private pluginName;
11
+ private dealerId;
12
+ private subscriberId;
16
13
  private MAX_LISTENERS_PER_EVENT;
17
14
  private eventListeners;
18
- constructor(logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, routerAddress: string, serverPublicKey: string);
15
+ constructor(pluginId: string, pluginName: string, routerAddress: string, publisherAddress: string, serverPublicKey: string);
19
16
  listen<E extends keyof PluginsManagerProxyEventCallbacks>(eventType: E, callback: PluginsManagerProxyEventCallbacks[E]): void;
20
17
  removeListener<E extends keyof PluginsManagerProxyEventCallbacks>(eventType: E, callbackToRemove: PluginsManagerProxyEventCallbacks[E]): void;
21
18
  removeAllListeners<E extends keyof PluginsManagerProxyEventCallbacks>(eventType?: E): void;
19
+ private handleRouterRequest;
22
20
  private listenToSubscriberEvents;
23
- private listenToRouterRequests;
24
21
  private onRequest;
25
22
  private isPluginMessage;
26
23
  private isStorageMessage;
@@ -1,13 +1,14 @@
1
- import { Request } from 'zeromq';
2
- import type { BaseLogger } from '../../camera/types';
1
+ import { Dealer } from 'zeromq';
2
+ import type { ProxyMessageStructure } from '../types';
3
3
  export declare class ClientMessageQueue {
4
4
  private logger;
5
- private requestClient;
6
- private queue;
5
+ private dealer;
6
+ private requestHandler;
7
7
  private isProcessing;
8
+ private queue;
8
9
  private pendingResponses;
9
- constructor(requestClient: Request, logger: BaseLogger);
10
- enqueue(message: any, timeout?: number): Promise<any>;
10
+ constructor(requestHandler: (message: ProxyMessageStructure) => void, dealer: Dealer);
11
+ enqueue(message: ProxyMessageStructure): Promise<any>;
11
12
  private processQueue;
12
- private listenToReplies;
13
+ private listenToRouter;
13
14
  }
@@ -1,21 +1,21 @@
1
- import type { BaseLogger } from '../../camera/types';
2
- import type { SystemManagerProxyMethods, SystemManagerProxyEventCallbacks } from '../types';
3
- export declare class SystemManager implements SystemManagerProxyMethods {
4
- private pluginId;
5
- private pluginName;
6
- private clientTargetId;
7
- private subTargetId;
1
+ import type { SystemManagerProxyMethods, SystemManagerProxyMethodsListener, SystemManagerProxyEventCallbacks } from '../types';
2
+ export declare class SystemManager implements SystemManagerProxyMethods, SystemManagerProxyMethodsListener {
8
3
  private api;
9
4
  private logger;
10
- private client;
5
+ private dealer;
11
6
  private subscriber;
12
7
  private messageQueue;
8
+ private pluginId;
9
+ private pluginName;
10
+ private dealerId;
11
+ private subscriberId;
13
12
  private MAX_LISTENERS_PER_EVENT;
14
13
  private eventListeners;
15
- constructor(logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string);
14
+ constructor(pluginId: string, pluginName: string, routerAddress: string, publisherAddress: string, serverPublicKey: string);
16
15
  listen<E extends keyof SystemManagerProxyEventCallbacks>(eventType: E, callback: SystemManagerProxyEventCallbacks[E]): void;
17
16
  removeListener<E extends keyof SystemManagerProxyEventCallbacks>(eventType: E, callbackToRemove: SystemManagerProxyEventCallbacks[E]): void;
18
17
  removeAllListeners<E extends keyof SystemManagerProxyEventCallbacks>(eventType?: E): void;
18
+ private handleRouterRequest;
19
19
  private listenToSubscriberEvents;
20
20
  private onRequest;
21
21
  }
@@ -1,23 +1,29 @@
1
- import { Reply, Router, Publisher } from 'zeromq';
1
+ import { Router, Publisher } from 'zeromq';
2
2
  import { ServerProxy } from './proxies/server';
3
3
  import { CameraDeviceProxy } from './proxies/camera';
4
4
  import { PluginProxy } from './proxies/plugin';
5
5
  import type { ProxyBridge } from './ws';
6
- import type { ProxyEvents, TargetID, QueueItem } from './types';
6
+ import type { StateValues } from '../camera/types';
7
+ import type { DeviceManagerProxyEvents, SystemManagerProxyEvents, PluginsManagerProxyEvents, CameraDeviceListenerMessagePayload } from './types';
7
8
  export declare class ProxyServer {
8
9
  server?: ServerProxy;
9
10
  camera?: CameraDeviceProxy;
10
11
  plugin?: PluginProxy;
11
- private logger;
12
12
  private configService;
13
13
  router: Router;
14
- reqServer: Reply;
15
- pubServer: Publisher;
14
+ publisher: Publisher;
16
15
  socketBridge?: ProxyBridge;
17
16
  private messageQueue;
18
17
  constructor();
19
18
  initialize(): Promise<void>;
20
19
  close(): Promise<void>;
21
- sendMessage(item: QueueItem): Promise<void>;
22
- publishEvent<K extends keyof ProxyEvents>(targetId: TargetID, type: K, data: ProxyEvents[K]): Promise<void>;
20
+ publishDeviceManagerEvent<K extends keyof DeviceManagerProxyEvents>(targetId: string, type: K, data: DeviceManagerProxyEvents[K]): Promise<void>;
21
+ publishSystemManagerEvent<K extends keyof SystemManagerProxyEvents>(targetId: string, type: K, data: SystemManagerProxyEvents[K]): Promise<void>;
22
+ publishPluginsManagerEvent<K extends keyof PluginsManagerProxyEvents>(targetId: string, type: K, data: PluginsManagerProxyEvents[K]): Promise<void>;
23
+ publishCameraEvent<K extends keyof StateValues>(cameraId: string, stateName: K, data: {
24
+ newEvent: StateValues[K];
25
+ oldEvent: StateValues[K];
26
+ }): Promise<void>;
27
+ publishCameraEvent(cameraId: string, type: CameraDeviceListenerMessagePayload['type'], data?: any): Promise<void>;
28
+ private isCameraState;
23
29
  }
@@ -1,21 +1,24 @@
1
- import type { CameraInput } from '../../api/database/types';
1
+ /// <reference types="pouchdb-core" />
2
+ /// <reference types="node" />
2
3
  import type { OnSetEvent, StateValues } from '../../camera/types';
3
4
  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
+ import type { FfmpegOptions, PrebufferType, CameraDelegate } from '../../camera/types';
6
+ import type { CameraDeviceProxyMethods, ProxyMessageStructure } from '../types';
7
+ import type { MessageQueue } from '../queue';
8
+ import type { CameraDeviceHub } from '../../camera';
9
+ import type { Camera } from '../../api/database/types';
7
10
  export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
8
11
  private api;
9
12
  private configService;
10
13
  private camerasService;
11
14
  private pluginsService;
12
- private proxyServer;
13
- constructor(proxyServer: ProxyServer);
15
+ private messageQueue;
16
+ constructor(messageQueue: MessageQueue);
14
17
  snapshot(data: {
15
- sourceName: string;
16
18
  prebuffer?: boolean;
17
19
  cameraId: string;
18
20
  pluginId: string;
21
+ ws?: boolean;
19
22
  }): Promise<ArrayBuffer>;
20
23
  setPrebufferSource(data: {
21
24
  sourceName: string;
@@ -23,46 +26,63 @@ export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
23
26
  type: PrebufferType;
24
27
  cameraId: string;
25
28
  pluginId: string;
29
+ ws?: boolean;
26
30
  }): Promise<void>;
27
31
  removePrebufferSource(data: {
28
32
  sourceName: string;
29
33
  type: PrebufferType;
30
34
  cameraId: string;
31
35
  pluginId: string;
36
+ ws?: boolean;
32
37
  }): Promise<void>;
33
38
  removePrebufferSources(data: {
34
39
  cameraId: string;
35
40
  pluginId: string;
41
+ ws?: boolean;
36
42
  }): Promise<void>;
37
- getFffmpegPath(): string;
38
- getIceServers(): IceServer[];
43
+ getFffmpegPath(data: {
44
+ cameraId: string;
45
+ pluginId: string;
46
+ ws?: boolean;
47
+ }): string;
48
+ getIceServers(data: {
49
+ cameraId: string;
50
+ pluginId: string;
51
+ ws?: boolean;
52
+ }): IceServer[];
39
53
  updateState<T extends keyof StateValues>(data: {
40
54
  stateName: T;
41
55
  eventData: OnSetEvent<T>;
42
56
  cameraId: string;
43
- }): void;
57
+ pluginId: string;
58
+ ws?: boolean;
59
+ }): Promise<void>;
44
60
  refreshStates(data: {
45
61
  cameraId: string;
46
- }): {
47
- sources: CameraInput[];
62
+ pluginId: string;
63
+ ws?: boolean;
64
+ }): Promise<{
65
+ camera: Camera;
48
66
  states: StateValues;
49
- } | undefined;
67
+ }>;
50
68
  streamVideo(data: {
51
69
  sourceName: string;
52
70
  options: FfmpegOptions;
53
71
  cameraId: string;
72
+ pluginId: string;
73
+ ws?: boolean;
54
74
  }): Promise<void>;
55
75
  recordToFile(data: {
56
76
  sourceName: string;
57
77
  outputPath: string;
58
78
  duration?: number;
59
79
  cameraId: string;
80
+ pluginId: string;
81
+ ws?: boolean;
60
82
  }): Promise<void>;
61
- handleMessage(msg: CameraDeviceProxyMessageStructure): Promise<void>;
62
- publishCameraMessage<K extends keyof StateValues>(cameraId: CameraId, stateName: K, data: {
63
- newEvent: StateValues[K];
64
- oldEvent: StateValues[K];
65
- }): Promise<void>;
66
- publishCameraMessage(cameraId: CameraId, type: CameraDeviceListenerMessagePayload['type'], data?: any): Promise<void>;
67
- private isCameraState;
83
+ onRequestSnapshotRequest(cameraDevice: CameraDeviceHub, ...args: Parameters<CameraDelegate['snapshotRequest']>): Promise<Buffer>;
84
+ onRequestPrepareStream(cameraDevice: CameraDeviceHub, ...args: Parameters<CameraDelegate['prepareStream']>): Promise<void>;
85
+ onRequestWebRTCOffer(cameraDevice: CameraDeviceHub, ...args: Parameters<CameraDelegate['onOffer']>): Promise<string>;
86
+ onRequestWebRTCIceCandidates(cameraDevice: CameraDeviceHub, ...args: Parameters<CameraDelegate['onCandidates']>): Promise<void>;
87
+ handleMessage(message: ProxyMessageStructure): Promise<void>;
68
88
  }
@@ -1,10 +1,11 @@
1
1
  import { type CameraStorage, type BasePlugin } from '../../plugins/types';
2
- import type { ProxyServer } from '..';
3
- import type { MethodKeys } from '../types';
2
+ import type { MethodKeys, ProxyMessageStructure } from '../types';
3
+ import type { MessageQueue } from '../queue';
4
4
  export declare class PluginProxy {
5
5
  private pluginsService;
6
- private proxyServer;
7
- constructor(proxyServer: ProxyServer);
6
+ private messageQueue;
7
+ constructor(messageQueue: MessageQueue);
8
8
  onRequestPluginFn<K extends Exclude<MethodKeys<BasePlugin>, 'configureCameras'>>(pluginId: string, fn: K, ...args: Parameters<BasePlugin[K]>): Promise<ReturnType<BasePlugin[K]>>;
9
9
  onRequestStorageFn<K extends MethodKeys<CameraStorage>>(pluginId: string, cameraId: string, fn: K, ...args: Parameters<CameraStorage[K]>): Promise<ReturnType<CameraStorage[K]>>;
10
+ handleMessage(message: ProxyMessageStructure): Promise<void>;
10
11
  }
@@ -1,17 +1,12 @@
1
- import type { ProxyServer } from '..';
2
1
  import type { ApiProxyMethods, ProxyMessageStructure } from '../types';
3
2
  import type { Camera } from '../../api/database/types';
4
3
  import type { CameraConfig } from '../../camera/types';
5
- export declare interface ServerProxy {
6
- listen(): any;
7
- removeListener(): any;
8
- removeAllListeners(): any;
9
- }
4
+ import type { MessageQueue } from '../queue';
10
5
  export declare class ServerProxy implements ApiProxyMethods {
11
6
  private camerasService;
12
7
  private pluginsService;
13
- private proxyServer;
14
- constructor(proxyServer: ProxyServer);
8
+ private messageQueue;
9
+ constructor(messageQueue: MessageQueue);
15
10
  getCameraByName(data: {
16
11
  name: string;
17
12
  }): Promise<Camera | undefined>;
@@ -30,5 +25,5 @@ export declare class ServerProxy implements ApiProxyMethods {
30
25
  id: string;
31
26
  pluginId: string;
32
27
  }): Promise<void>;
33
- handleMessage(msg: ProxyMessageStructure): Promise<void>;
28
+ handleMessage(message: ProxyMessageStructure): Promise<void>;
34
29
  }
@@ -1,17 +1,14 @@
1
- import type { QueueItem } from './types';
1
+ import type { ProxyMessageStructure } from './types';
2
2
  import type { ProxyServer } from '.';
3
3
  export declare class MessageQueue {
4
4
  private logger;
5
- private queue;
6
- private isProcessing;
7
- private pendingResponses;
8
5
  private proxyServer;
9
- private reqServer;
10
6
  private router;
7
+ private isProcessing;
8
+ private queue;
9
+ private pendingResponses;
11
10
  constructor(proxyServer: ProxyServer);
12
- addToQueue(item: QueueItem): Promise<void>;
11
+ enqueue(message: ProxyMessageStructure): Promise<any>;
13
12
  private processQueue;
14
- private listenToRouterMessages;
15
- private listenToRequestMessages;
16
- private isProxyMessage;
13
+ private listenToDealer;
17
14
  }