@camera.ui/browser 0.0.34 → 0.0.36

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.js +1 -1
  2. package/dist/client/node/src/proxy/cameraDevice/cameraDevice.browser.d.ts +27 -15
  3. package/dist/client/node/src/proxy/cameraDevice/cameraDevice.node.d.ts +12 -7
  4. package/dist/src/api/database/types.d.ts +37 -27
  5. package/dist/src/api/go2rtc/api/application.d.ts +4 -3
  6. package/dist/src/api/go2rtc/api/config.d.ts +4 -3
  7. package/dist/src/api/go2rtc/api/snapshot.d.ts +4 -3
  8. package/dist/src/api/go2rtc/api/streams.d.ts +5 -5
  9. package/dist/src/api/go2rtc/index.d.ts +13 -4
  10. package/dist/src/api/go2rtc/queue.d.ts +10 -0
  11. package/dist/src/api/schemas/cameras.schema.d.ts +475 -13
  12. package/dist/src/api/schemas/config.schema.d.ts +12 -9
  13. package/dist/src/api/services/cameras.service.d.ts +16 -7
  14. package/dist/src/api/services/plugins.service.d.ts +2 -0
  15. package/dist/src/api/types/index.d.ts +22 -3
  16. package/dist/src/api/ws/nsp/status.d.ts +10 -2
  17. package/dist/src/api/ws/nsp/streams.d.ts +0 -15
  18. package/dist/src/api/ws/types.d.ts +14 -0
  19. package/dist/src/api.d.ts +3 -2
  20. package/dist/src/camera/index.d.ts +32 -19
  21. package/dist/src/camera/streaming/peer-connection.d.ts +5 -7
  22. package/dist/src/camera/streaming/streaming-session.d.ts +3 -3
  23. package/dist/src/camera/streaming/webrtc-connection.d.ts +4 -4
  24. package/dist/src/camera/types.d.ts +77 -19
  25. package/dist/src/go2rtc/index.d.ts +1 -0
  26. package/dist/src/plugins/cameraStorage.d.ts +4 -1
  27. package/dist/src/plugins/index.d.ts +0 -3
  28. package/dist/src/plugins/plugin.d.ts +1 -1
  29. package/dist/src/plugins/schema.d.ts +3 -3
  30. package/dist/src/plugins/types.d.ts +23 -13
  31. package/dist/src/proxy/client/cameraDevice.d.ts +20 -14
  32. package/dist/src/proxy/client/deviceManager.d.ts +13 -12
  33. package/dist/src/proxy/client/pluginsManager.d.ts +9 -12
  34. package/dist/src/proxy/client/queue.d.ts +10 -7
  35. package/dist/src/proxy/client/systemManager.d.ts +9 -9
  36. package/dist/src/proxy/index.d.ts +13 -7
  37. package/dist/src/proxy/proxies/camera.d.ts +62 -34
  38. package/dist/src/proxy/proxies/plugin.d.ts +5 -4
  39. package/dist/src/proxy/proxies/server.d.ts +4 -9
  40. package/dist/src/proxy/queue.d.ts +8 -9
  41. package/dist/src/proxy/types.d.ts +81 -106
  42. package/dist/src/services/config/index.d.ts +0 -1
  43. package/dist/src/services/config/types.d.ts +2 -1
  44. package/dist/src/services/logger/index.d.ts +5 -4
  45. package/package.json +4 -4
  46. /package/dist/src/camera/{subscribed.d.ts → utils/subscribed.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
- import type { DBCamera, Camera } from '../database/types';
2
1
  import { type CameraExtension } from '../../plugins/types';
2
+ import type { DBCamera, Camera, CameraZone } from '../database/types';
3
3
  type DeepPartial<T> = T extends object ? {
4
4
  [P in keyof T]?: DeepPartial<T[P]>;
5
5
  } : T;
@@ -8,19 +8,23 @@ export default class CamerasService {
8
8
  private api;
9
9
  private dbs;
10
10
  private proxy;
11
+ private go2rtcApi;
11
12
  private usersService;
12
13
  private pluginsService;
13
14
  constructor();
14
15
  createCamera(cameraData: DBCamera): Promise<DBCamera>;
15
- createCameraSource(cameraName: string, sourceName: string, address: string): Promise<void>;
16
- resetCameraSource(cameraName: string, sourceName: string): Promise<void>;
17
16
  createTransformedCamera(cameraData: DBCamera): Promise<Camera>;
17
+ createZone(cameraname: string, zoneData: CameraZone, zoneType: 'motion' | 'object'): Promise<DBCamera | undefined>;
18
+ patchZoneByName(cameraname: string, zonename: string, zoneData: CameraZone, zoneType: 'motion' | 'object'): Promise<DBCamera | undefined>;
19
+ removeZoneByName(cameraname: string, zonename: string, zoneType: 'motion' | 'object'): Promise<void>;
20
+ createCameraSource(cameraname: string, sourceName: string, address: string): Promise<void>;
21
+ resetCameraSource(cameraname: string, sourceName: string): Promise<void>;
18
22
  list(): Promise<DBCamera[]>;
19
23
  listTransformed(): Promise<Camera[]>;
20
24
  listByPluginId(pluginId: string): Promise<DBCamera[]>;
21
25
  listTransformedByPluginId(pluginId: string): Promise<Camera[]>;
22
26
  listByExtension(pluginName: string): Promise<DBCamera[]>;
23
- listTransformedByExtension(pluginName: string): Promise<Camera[]>;
27
+ listTransformedByExtension(pluginName: string, extensions: CameraExtension[]): Promise<Camera[]>;
24
28
  findById(id: string): Promise<DBCamera | undefined>;
25
29
  findTransformedById(id: string): Promise<Camera | undefined>;
26
30
  findByName(cameraname: string): Promise<DBCamera | undefined>;
@@ -28,8 +32,8 @@ export default class CamerasService {
28
32
  findByPluginAndName(cameraname: string, pluginId: string): Promise<DBCamera | undefined>;
29
33
  findTransformedByPluginAndName(cameraname: string, pluginId: string): Promise<Camera | undefined>;
30
34
  patchCameraByName(cameraname: string, cameraData: DeepPartial<DBCamera>): Promise<DBCamera | undefined>;
31
- enableExtensionByName(cameraname: string, pluginName: string, type?: CameraExtension): Promise<DBCamera | undefined>;
32
- disableExtensionByName(cameraname: string, pluginName: string, type?: CameraExtension): Promise<DBCamera | undefined>;
35
+ enableExtensionByName(cameraname: string, pluginName: string, extensionType: CameraExtension): Promise<DBCamera | undefined>;
36
+ disableExtensionByName(cameraname: string, pluginName: string, extensionType: CameraExtension): Promise<DBCamera | undefined>;
33
37
  addExtensionByName(cameraname: string, pluginName: string): Promise<DBCamera | undefined>;
34
38
  removeExtensionByName(cameraname: string, pluginName: string): Promise<DBCamera | undefined>;
35
39
  removeExtension(pluginName: string): Promise<void>;
@@ -39,8 +43,13 @@ export default class CamerasService {
39
43
  removeByPluginIdAndName(cameraname: string, pluginId: string): Promise<void>;
40
44
  removeAll(): Promise<void>;
41
45
  transformCamera(camera: DBCamera): Camera;
46
+ cameraSourcesChanged(oldCamera: DBCamera, newCamera: DBCamera): boolean;
42
47
  private addCameraSources;
43
48
  private removeCameraSources;
44
- private sourceIsPrebuffering;
49
+ private generateWsUrls;
50
+ private generateRTSPUrls;
51
+ private generateFFmpegUrls;
52
+ private generateWWWUrls;
53
+ private extensionIsEnabled;
45
54
  }
46
55
  export {};
@@ -6,6 +6,8 @@ export default class PluginsService {
6
6
  private dbs;
7
7
  private pluginManager;
8
8
  constructor();
9
+ listPlugins(): Plugin[];
10
+ listPluginProcesses(): PluginWorker[];
9
11
  getPluginByName(pluginName: string): Plugin | undefined;
10
12
  getPluginById(id: string): Plugin | undefined;
11
13
  getPluginProcessByName(pluginName: string): PluginWorker | undefined;
@@ -9,7 +9,7 @@ import type { RestoreBackupInput } from '../schemas/backup.schema';
9
9
  import type { PatchGo2RtcConfigInput } from '../schemas/go2rtc.schema';
10
10
  import type { LoggingLevel } from '../../services/config/types';
11
11
  import type { ApplicationResponse } from '../go2rtc/types';
12
- import type { DBRoles, DBCamera, DBUser, DBCamviewLayout, CameraExtensions } from '../database/types';
12
+ import type { DBRoles, DBCamera, DBUser, DBCamviewLayout, CameraExtensions, CameraZone } from '../database/types';
13
13
  import type { CameraExtension, PluginContract, PluginRootSchema } from '../../plugins/types';
14
14
  export interface BusboyFileStream extends Readable {
15
15
  truncated: boolean;
@@ -124,8 +124,9 @@ export interface CamerasResponse {
124
124
  export interface PluginExtension {
125
125
  pluginName: string;
126
126
  displayName: string;
127
- type: CameraExtension;
127
+ type: CameraExtension[];
128
128
  builtIn?: boolean;
129
+ externPlugin?: boolean;
129
130
  }
130
131
  export interface PluginExtensionConfig extends PluginExtension {
131
132
  rootSchema?: PluginRootSchema;
@@ -232,6 +233,11 @@ export type CamerasParamsRequest = {
232
233
  cameraname: string;
233
234
  };
234
235
  };
236
+ export type CameraZonesParamsRequest = {
237
+ Params: {
238
+ zonename: string;
239
+ };
240
+ };
235
241
  export type CamerasExtensionsParamsRequest = {
236
242
  Params: {
237
243
  cameraname: string;
@@ -241,9 +247,17 @@ export type CamerasExtensionsParamsRequest = {
241
247
  };
242
248
  export type CamerasExtensionsRequest = {
243
249
  Querystring: {
244
- type?: CameraExtension;
250
+ type: CameraExtension;
251
+ };
252
+ };
253
+ export type CameraZonesTypeRequest = {
254
+ Querystring: {
255
+ type: 'motion' | 'object';
245
256
  };
246
257
  };
258
+ export type CameraZoneInsertPatchRequest = {
259
+ Body: CameraZone;
260
+ };
247
261
  export type CamerasInsertRequest = {
248
262
  Body: CreateCameraInput;
249
263
  };
@@ -330,6 +344,11 @@ export type BackupCreateRequest = {
330
344
  localStorage: Partial<UiLocalStorage>;
331
345
  };
332
346
  };
347
+ export type StreamsParamsNameRequest = {
348
+ Params: {
349
+ id: string;
350
+ };
351
+ };
333
352
  export interface BackupInfo {
334
353
  backupDirectory: string;
335
354
  backupFile: string;
@@ -1,3 +1,5 @@
1
+ import { RUNTIME_STATUS } from '../../../services/config/types';
2
+ import { PLUGIN_STATUS } from '../../../plugins/types';
1
3
  import type { Server, Namespace, Socket } from 'socket.io';
2
4
  import type { SocketNsp } from '../types';
3
5
  export declare class Status {
@@ -7,6 +9,12 @@ export declare class Status {
7
9
  private pluginManager;
8
10
  private go2rtc;
9
11
  constructor(io: Server);
10
- watchStats(socket: Socket): Promise<void>;
11
- watchPluginStats(socket: Socket): Promise<void>;
12
+ watchStats(socket: Socket, payload: any, callback?: Function): {
13
+ name: string;
14
+ status: RUNTIME_STATUS;
15
+ }[];
16
+ watchPluginStats(socket: Socket, payload: any, callback?: Function): {
17
+ name: string;
18
+ status: PLUGIN_STATUS;
19
+ }[];
12
20
  }
@@ -1,20 +1,5 @@
1
- import ws from 'ws';
2
1
  import type { Server, Namespace } from 'socket.io';
3
2
  import type { SocketNsp } from '../types';
4
- import type { VideoStreamingMode } from '../../database/types';
5
- export interface StreamPayload {
6
- type: VideoStreamingMode;
7
- value: string;
8
- }
9
- export type Go2RtcWsState = 'open' | 'closed' | 'connecting';
10
- export interface Go2RtcWs {
11
- id: string;
12
- ws?: ws;
13
- state: Go2RtcWsState;
14
- connect: () => void;
15
- reconnect: () => void;
16
- close: (destroy?: boolean) => void;
17
- }
18
3
  export declare class Streams {
19
4
  nsp: Namespace;
20
5
  nspName: SocketNsp;
@@ -1,5 +1,7 @@
1
1
  import { PLUGIN_STATUS } from '../../plugins/types';
2
2
  import type { Namespace } from 'socket.io';
3
+ import type { WebSocket } from 'ws';
4
+ import type { VideoStreamingMode } from '../database/types';
3
5
  export type SocketNsp = '/camera.ui' | '/metrics' | '/logs' | '/status' | '/notifications' | '/streams' | '/plugins' | '/proxy';
4
6
  export interface SocketNspMap {
5
7
  nsp: Namespace;
@@ -80,3 +82,15 @@ export interface PluginRuntime {
80
82
  name: string;
81
83
  status: PLUGIN_STATUS;
82
84
  }
85
+ export interface StreamPayload {
86
+ type: Exclude<VideoStreamingMode, 'webrtc' | 'webrtc/tcp'> | 'webrtc/offer' | 'webrtc/candidate';
87
+ value: string;
88
+ }
89
+ export interface Go2RtcWs {
90
+ id: string;
91
+ ws?: WebSocket;
92
+ connect: () => void;
93
+ reconnect: () => void;
94
+ close: (destroy?: boolean) => void;
95
+ send: (data: StreamPayload) => void;
96
+ }
package/dist/src/api.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import EventEmitter from 'events';
3
- import { CameraDeviceHub } from './camera';
3
+ import { CameraController } from './camera';
4
4
  import type { PluginLogger } from './services/logger';
5
5
  import type { PluginContract } from './plugins/types';
6
6
  import type { PluginConfigService } from './plugins/config';
@@ -54,7 +54,8 @@ export declare class CameraUiAPI extends EventEmitter implements API {
54
54
  constructor();
55
55
  configureCameras(): Promise<void>;
56
56
  addCamera(camera: Camera): void;
57
- getCamera(cameraId: string): CameraDeviceHub | undefined;
57
+ getCamera(cameraId: string): CameraController | undefined;
58
+ getCameras(): CameraController[];
58
59
  updateCamera(cameraData: Camera): void;
59
60
  removeCamera(cameraId: string): Promise<void>;
60
61
  }
@@ -1,11 +1,12 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { StreamingSession } from './streaming/streaming-session';
3
- import type { Camera, CameraInput, CameraPublicProperties } from '../api/database/types';
3
+ import type { Camera, CameraPublicProperties, CameraZone, CameraType, CameraInformation } from '../api/database/types';
4
4
  import type { ProxyServer } from '../proxy';
5
- import type { CameraDevice, BaseLogger } from './types';
5
+ import type { CameraDevice, BaseLogger, CameraDelegate, CameraPrebufferDelegate } from './types';
6
6
  import type { IceServer } from '../services/config/types';
7
- import type { StateValues, OnSetEvent, LightState, MotionState, AudioState, ObjectState, DoorbellState, SirenState, StreamingConnectionOptions, FfmpegOptions, PrebufferType } from './types';
8
- export declare class CameraDeviceHub implements CameraDevice {
7
+ import type { StateValues, OnSetEvent, LightState, MotionState, AudioState, ObjectState, DoorbellState, SirenState, BatteryState, StreamingConnectionOptions, FfmpegOptions, CameraSource } from './types';
8
+ export declare class CameraController implements CameraDevice {
9
+ private log;
9
10
  private proxy?;
10
11
  private cameraSubject;
11
12
  private lightState;
@@ -14,49 +15,61 @@ export declare class CameraDeviceHub implements CameraDevice {
14
15
  private objectState;
15
16
  private doorbellState;
16
17
  private sirenState;
17
- onLightDetected: Observable<LightState>;
18
+ private batteryState;
19
+ private snapshotCache;
20
+ onLightSwitched: Observable<LightState>;
18
21
  onMotionDetected: Observable<MotionState>;
19
22
  onAudioDetected: Observable<AudioState>;
20
23
  onObjectDetected: Observable<ObjectState>;
21
24
  onDoorbellPressed: Observable<DoorbellState>;
22
25
  onSirenDetected: Observable<SirenState>;
23
- logger: BaseLogger;
26
+ onBatteryChanged: Observable<BatteryState>;
27
+ delegate?: CameraDelegate;
28
+ prebufferDelegate?: CameraPrebufferDelegate;
24
29
  get id(): string;
25
30
  get nativeId(): string | undefined;
31
+ get pluginId(): string;
26
32
  get disabled(): boolean;
27
33
  get name(): string;
28
- get type(): string;
29
- get model(): string;
34
+ get type(): CameraType;
35
+ get info(): CameraInformation;
30
36
  get isCloud(): boolean;
31
37
  get hasLight(): boolean;
32
38
  get hasSiren(): boolean;
39
+ get hasBinarySensor(): boolean;
40
+ get hasBattery(): boolean;
33
41
  get hasMotionDetector(): boolean;
34
42
  get hasAudioDetector(): boolean;
35
43
  get hasObjectDetector(): boolean;
36
44
  get hasPtz(): boolean;
37
- get sources(): CameraInput[];
38
- constructor(camera: Camera, logger?: BaseLogger, proxy?: ProxyServer);
39
- snapshot(sourceName?: string, prebuffer?: boolean): Promise<ArrayBuffer>;
40
- setPrebufferSource(sourceName: string, address: string, type: PrebufferType): Promise<void>;
41
- removePrebufferSource(sourceName: string, type: 'recording' | 'stream'): Promise<void>;
42
- removePrebufferSources(): Promise<void>;
45
+ get motionZones(): CameraZone[];
46
+ get objectZones(): CameraZone[];
47
+ get sources(): CameraSource[];
48
+ constructor(camera: Camera, logger: BaseLogger, proxy?: ProxyServer);
49
+ reboot(): Promise<void>;
50
+ getStreamSource(): CameraSource;
51
+ getSnapshotSource(): CameraSource;
52
+ getRecordingSource(): CameraSource;
53
+ getDetectionSource(): CameraSource;
54
+ configureDelegate(delegate: CameraDelegate): void;
55
+ configurePrebufferDelegate(delegate: CameraPrebufferDelegate): void;
56
+ snapshot(forceNew?: boolean): Promise<ArrayBuffer>;
43
57
  getFfmpegPath(): Promise<string>;
44
58
  getIceServers(): Promise<IceServer[]>;
45
- getValue<T extends keyof StateValues>(stateName: T): StateValues[T];
46
59
  createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
47
60
  streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
48
61
  recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
62
+ getValue<T extends keyof StateValues>(stateName: T): StateValues[T];
49
63
  updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
50
64
  onStateChange<T extends keyof StateValues>(stateName: T): Observable<{
51
65
  newState: StateValues[T];
52
66
  oldState: StateValues[T];
53
67
  }>;
54
68
  onPropertyChange<T extends keyof CameraPublicProperties>(property: T): Observable<{
55
- oldState: Camera[T];
56
- newState: Camera[T];
69
+ oldData: Camera[T];
70
+ newData: Camera[T];
57
71
  }>;
58
- updateCamera(camera: Camera): void;
59
- updateSources(sources: CameraInput[]): void;
72
+ updateCamera(updatedCamera: Camera): void;
60
73
  removeCamera(): void;
61
74
  removeAllListeners(): void;
62
75
  private createStateObservable;
@@ -1,9 +1,8 @@
1
1
  import { ReplaySubject, Subject } from 'rxjs';
2
2
  import { MediaStreamTrack, RTCSessionDescription } from 'werift';
3
- import { Subscribed } from '../subscribed';
4
- import type { WebSocket } from 'ws';
3
+ import { Subscribed } from '../utils/subscribed';
5
4
  import type { RtpPacket, RtcpPacket, RTCIceCandidate } from 'werift';
6
- import type { BasicPeerConnection, CameraDevice } from '../types';
5
+ import type { BasicPeerConnection, BaseLogger, CameraDevice } from '../types';
7
6
  import type { IceServer } from '../../services/config/types';
8
7
  export declare class WeriftPeerConnection extends Subscribed implements BasicPeerConnection {
9
8
  onAudioRtp: Subject<RtpPacket>;
@@ -13,12 +12,11 @@ export declare class WeriftPeerConnection extends Subscribed implements BasicPee
13
12
  onIceCandidate: Subject<RTCIceCandidate>;
14
13
  onConnectionState: ReplaySubject<"closed" | "failed" | "disconnected" | "new" | "connecting" | "connected">;
15
14
  returnAudioTrack: MediaStreamTrack;
16
- private pc;
17
- private ws?;
15
+ private onRequestKeyFrame;
18
16
  private cameraDevice;
19
17
  private logger;
20
- private onRequestKeyFrame;
21
- constructor(cameraDevice: CameraDevice, iceServers: IceServer[], ws?: WebSocket);
18
+ private pc;
19
+ constructor(cameraDevice: CameraDevice, iceServers: IceServer[], logger: BaseLogger);
22
20
  createOffer(): Promise<RTCSessionDescription>;
23
21
  acceptAnswer(answer: {
24
22
  type: 'answer';
@@ -1,8 +1,8 @@
1
1
  import { RtpPacket } from 'werift';
2
2
  import { ReplaySubject, Subject } from 'rxjs';
3
- import { Subscribed } from '../subscribed';
3
+ import { Subscribed } from '../utils/subscribed';
4
4
  import type { WebrtcConnection } from './webrtc-connection';
5
- import type { FfmpegOptions, SpawnInput, CameraDevice } from '../types';
5
+ import type { FfmpegOptions, SpawnInput, BaseLogger, CameraDevice } from '../types';
6
6
  export declare class StreamingSession extends Subscribed {
7
7
  readonly onCallEnded: ReplaySubject<void>;
8
8
  readonly onVideoRtp: Subject<RtpPacket>;
@@ -16,7 +16,7 @@ export declare class StreamingSession extends Subscribed {
16
16
  private connection;
17
17
  private logger;
18
18
  get isUsingOpus(): Promise<boolean>;
19
- constructor(cameraDevice: CameraDevice, connection: WebrtcConnection);
19
+ constructor(cameraDevice: CameraDevice, logger: BaseLogger, connection: WebrtcConnection);
20
20
  reservePort(bufferPorts?: number): Promise<number>;
21
21
  startTranscoding(ffmpegOptions: FfmpegOptions): Promise<void>;
22
22
  transcodeReturnAudio(ffmpegOptions: {
@@ -1,7 +1,7 @@
1
1
  import { ReplaySubject, Subject, type Observable } from 'rxjs';
2
- import { Subscribed } from '../subscribed';
2
+ import { Subscribed } from '../utils/subscribed';
3
3
  import type { RtpPacket } from 'werift';
4
- import type { StreamingConnectionOptions, CameraDevice } from '../types';
4
+ import type { StreamingConnectionOptions, BaseLogger, CameraDevice } from '../types';
5
5
  import type { IceServer } from '../../services/config/types';
6
6
  export declare class WebrtcConnection extends Subscribed {
7
7
  readonly onCameraConnected: ReplaySubject<void>;
@@ -18,9 +18,9 @@ export declare class WebrtcConnection extends Subscribed {
18
18
  private readonly ws;
19
19
  private readonly onOfferSent;
20
20
  private hasEnded;
21
- private logger;
22
21
  private cameraDevice;
23
- constructor(cameraDevice: CameraDevice, sourceName: string, iceServers: IceServer[], options: StreamingConnectionOptions);
22
+ private logger;
23
+ constructor(cameraDevice: CameraDevice, sourceName: string, iceServers: IceServer[], logger: BaseLogger, options: StreamingConnectionOptions);
24
24
  sendAudioPacket(rtp: RtpPacket): void;
25
25
  stop(): void;
26
26
  requestKeyFrame(): void;
@@ -1,14 +1,22 @@
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, CameraInput, CameraType, CameraInformation } 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';
9
+ export interface CameraSource extends CameraInput {
10
+ isPrebuffering(type: PrebufferType): Promise<boolean>;
11
+ getPrebufferRawUrl(type: PrebufferType): Promise<string | undefined>;
12
+ getStreamInfo(): Promise<StreamInfo | undefined>;
13
+ }
7
14
  export interface BaseLogger {
8
15
  log: (...args: any[]) => void;
9
16
  error: (...args: any[]) => void;
10
17
  warn: (...args: any[]) => void;
11
18
  debug: (...args: any[]) => void;
19
+ trace: (...args: any[]) => void;
12
20
  }
13
21
  export interface FfmpegOptions {
14
22
  input?: SpawnInput[];
@@ -35,47 +43,86 @@ export interface BasicPeerConnection {
35
43
  }
36
44
  export interface CameraDevice {
37
45
  id: string;
46
+ pluginId: string;
47
+ nativeId?: string;
38
48
  disabled: boolean;
39
49
  name: string;
40
- nativeId?: string;
50
+ type: CameraType;
51
+ info: CameraInformation;
52
+ sources: CameraSource[];
53
+ motionZones: CameraZone[];
54
+ objectZones: CameraZone[];
41
55
  isCloud: boolean;
42
56
  hasLight: boolean;
43
57
  hasSiren: boolean;
58
+ hasBinarySensor: boolean;
59
+ hasBattery: boolean;
44
60
  hasMotionDetector: boolean;
45
61
  hasAudioDetector: boolean;
46
62
  hasObjectDetector: boolean;
47
63
  hasPtz: boolean;
48
- type: string;
49
- model: string;
50
- sources: CameraInput[];
51
- logger: BaseLogger;
52
- onLightDetected: Observable<LightState>;
64
+ onLightSwitched: Observable<LightState>;
53
65
  onMotionDetected: Observable<MotionState>;
54
66
  onAudioDetected: Observable<AudioState>;
55
67
  onObjectDetected: Observable<ObjectState>;
56
68
  onDoorbellPressed: Observable<DoorbellState>;
57
69
  onSirenDetected: Observable<SirenState>;
58
- snapshot(sourceName?: string, prebuffer?: boolean): Promise<ArrayBuffer>;
59
- setPrebufferSource(sourceName: string, address: string, type: 'recording' | 'stream'): Promise<void>;
60
- removePrebufferSource(sourceName: string, type: 'recording' | 'stream'): Promise<void>;
61
- removePrebufferSources(): Promise<void>;
70
+ onBatteryChanged: Observable<BatteryState>;
71
+ reboot(): Promise<void>;
72
+ getStreamSource(): CameraSource;
73
+ getSnapshotSource(): CameraSource;
74
+ getRecordingSource(): CameraSource;
75
+ getDetectionSource(): CameraSource;
76
+ configureDelegate(delegate: CameraDelegate): void;
77
+ configurePrebufferDelegate(delegate: CameraPrebufferDelegate): void;
62
78
  getFfmpegPath(): Promise<string>;
63
79
  getIceServers(): Promise<RTCIceServer[]>;
64
- getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
80
+ snapshot(forceNew?: boolean): Promise<ArrayBuffer>;
65
81
  createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
66
82
  streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
67
83
  recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
84
+ getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
68
85
  updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
69
86
  onStateChange<T extends keyof StateValues>(stateName: T): Observable<{
70
87
  newState: StateValues[T];
71
88
  oldState: StateValues[T];
72
89
  }>;
73
90
  onPropertyChange<T extends keyof CameraPublicProperties>(property: T): Observable<{
74
- oldState: Camera[T];
75
- newState: Camera[T];
91
+ oldData: Camera[T];
92
+ newData: Camera[T];
76
93
  }>;
77
94
  removeAllListeners(): void;
78
95
  }
96
+ export interface CameraDelegate {
97
+ snapshotRequest(requestId: string): Promise<Buffer>;
98
+ prepareStream(requestId: string): Promise<void>;
99
+ onOffer(requestId: string, sdp: string): Promise<string>;
100
+ onCandidates(requestId: string, candidates: string): Promise<void>;
101
+ reboot(): Promise<void>;
102
+ }
103
+ export interface CameraPrebufferDelegate {
104
+ isPrebuffering(sourceName: string, type: PrebufferType): Promise<boolean>;
105
+ getPrebufferRawUrl(sourceName: string, type: PrebufferType): Promise<string | undefined>;
106
+ getStreamInfo(sourceName: string): Promise<StreamInfo | undefined>;
107
+ }
108
+ export interface AudioStreamOptions {
109
+ enabled?: boolean;
110
+ codec?: string;
111
+ bitrate?: number;
112
+ sampleRate?: number;
113
+ }
114
+ export interface VideoStreamOptions {
115
+ codec?: string;
116
+ width?: number;
117
+ height?: number;
118
+ bitrate?: number;
119
+ fps?: number;
120
+ idrInterval?: number;
121
+ }
122
+ export interface StreamInfo {
123
+ audio: AudioStreamOptions;
124
+ video: VideoStreamOptions;
125
+ }
79
126
  export type Sdp = string;
80
127
  export type IceCandiate = string;
81
128
  export interface Go2RtcOfferMessage {
@@ -96,16 +143,22 @@ export interface ErrorMessage {
96
143
  }
97
144
  export type Go2RtcIncomingMessage = Go2RtcAnswerMessage | Go2RtcIceCandidateMessage | ErrorMessage;
98
145
  export type Go2RtcOutgoingMessage = Go2RtcOfferMessage | Go2RtcIceCandidateMessage;
99
- export interface CameraConfig {
146
+ export interface BaseCameraConfig {
100
147
  name: string;
101
148
  nativeId?: string;
102
149
  isCloud?: boolean;
103
150
  hasLight?: boolean;
104
151
  hasSiren?: boolean;
152
+ hasBinarySensor?: boolean;
153
+ hasBattery?: boolean;
105
154
  disabled?: boolean;
106
- model?: string;
107
- sources: CameraInputSettings[];
155
+ info?: Partial<CameraInformation>;
108
156
  }
157
+ export type CameraConfig = (BaseCameraConfig & {
158
+ sources?: Omit<CameraInputSettings, '_id'>[];
159
+ }) | (BaseCameraConfig & {
160
+ delegate?: CameraDelegate;
161
+ });
109
162
  export interface BaseState {
110
163
  timestamp: number;
111
164
  lastTriggered: number;
@@ -129,6 +182,9 @@ export interface DoorbellSetEvent {
129
182
  export interface SirenSetEvent {
130
183
  state: boolean;
131
184
  }
185
+ export interface BatterySetEvent {
186
+ state: number;
187
+ }
132
188
  export interface DeviceSetEvent {
133
189
  }
134
190
  export type LightState = BaseState & LightSetEvent;
@@ -137,7 +193,8 @@ export type AudioState = BaseState & AudioSetEvent;
137
193
  export type DoorbellState = BaseState & DoorbellSetEvent;
138
194
  export type SirenState = BaseState & SirenSetEvent;
139
195
  export type ObjectState = BaseState & ObjectSetEvent;
140
- export type State = LightState | MotionState | AudioState | ObjectState | DoorbellState | SirenState;
196
+ export type BatteryState = BaseState & BatterySetEvent;
197
+ export type State = LightState | MotionState | AudioState | ObjectState | DoorbellState | SirenState | BatteryState;
141
198
  export interface StateValues {
142
199
  light: LightState;
143
200
  motion: MotionState;
@@ -145,10 +202,11 @@ export interface StateValues {
145
202
  object: ObjectState;
146
203
  doorbell: DoorbellState;
147
204
  siren: SirenState;
205
+ battery: BatteryState;
148
206
  }
149
207
  export type CameraStateCallbacks = {
150
208
  [K in keyof StateValues]: (event: StateValues[K]) => void;
151
209
  };
152
210
  export type StateValue<T extends keyof StateValues> = StateValues[T];
153
- 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 : ObjectSetEvent;
211
+ 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;
154
212
  export type OnChangeCallback<T extends keyof StateValues> = (newEvent: StateValues[T], oldEvent: StateValues[T]) => void;
@@ -21,4 +21,5 @@ export declare class Go2Rtc {
21
21
  private handleClose;
22
22
  private setStatus;
23
23
  private processLogger;
24
+ private isIgnorableString;
24
25
  }
@@ -7,6 +7,7 @@ export declare class CameraStorage implements CameraStorageMethods {
7
7
  private db;
8
8
  private _schema;
9
9
  private _values;
10
+ get values(): Record<string, any>;
10
11
  constructor(api: API, instance: any, cameraId: string, schema?: PluginJsonSchemaForm);
11
12
  /**
12
13
  * Initialize the storage.
@@ -22,7 +23,8 @@ export declare class CameraStorage implements CameraStorageMethods {
22
23
  * @param path - The path to the configuration value.
23
24
  * @returns The value from the configuration.
24
25
  */
25
- getValue<T = string>(path: string): Promise<T> | undefined;
26
+ getValue<T = string>(path: string, defaultValue: T): Promise<T> | T;
27
+ getValue<T = string>(path: string, defaultValue?: T): Promise<T> | T | undefined;
26
28
  /**
27
29
  * Set a new value for a given key/path in the configuration.
28
30
  * If the schema of the value has an onSet function, and the value has changed, the onSet function will be called.
@@ -101,4 +103,5 @@ export declare class CameraStorage implements CameraStorageMethods {
101
103
  private filterStorableValues;
102
104
  private containsStorableSchema;
103
105
  private saveDb;
106
+ private removeDb;
104
107
  }
@@ -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;
@@ -18,8 +18,8 @@ type OptionalZodZobject = z.ZodOptional<z.ZodObject<Record<string, z.ZodTypeAny>
18
18
  [x: string]: any;
19
19
  }> | z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>> | z.ZodRecord<z.ZodString, z.ZodAny>;
20
20
  type OptionalZodArray = z.ZodOptional<z.ZodType<any, any, any>> | z.ZodType<any, any, any>;
21
- type OptionalZodEnum = z.ZodOptional<z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>> | z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>;
22
- type OptionalZodEnumMultiple = z.ZodOptional<z.ZodArray<z.ZodUnion<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>, 'many'>> | z.ZodArray<z.ZodUnion<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>, 'many'>;
21
+ type OptionalZodEnum = z.ZodOptional<z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>> | z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]> | z.ZodEffects<z.ZodAny, any, any> | z.ZodUnion<any>;
22
+ type OptionalZodEnumMultiple = z.ZodOptional<z.ZodArray<z.ZodUnion<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>, 'many'>> | z.ZodArray<z.ZodUnion<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>, 'many'> | z.ZodEffects<z.ZodAny, any, any> | z.ZodUnion<any>;
23
23
  type ZodAny = z.ZodType<any, any, any>;
24
24
  /**
25
25
  * Generate root JSON schema from value.
@@ -137,7 +137,7 @@ export declare const generateStringSchema: (value: string) => JsonSchemaString;
137
137
  * @param type - The type of the enum.
138
138
  * @returns - The generated JSON schema for the enum.
139
139
  */
140
- export declare const generateEnumSchema: (value: (string | number | boolean)[], type: 'string' | 'number' | 'boolean') => JsonSchemaEnum;
140
+ export declare const generateEnumSchema: (value: string[]) => JsonSchemaEnum;
141
141
  /**
142
142
  * Generates a JSON schema for an object.
143
143
  *