@camera.ui/browser 0.0.36 → 0.0.37

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.
@@ -1,10 +1,12 @@
1
1
  import { Observable } from 'rxjs';
2
+ import { BrowserStreamingSession } from '../../../../../shared/types';
2
3
  import type { SocketService } from '../../socket';
3
- import type { Camera, CameraDevice, StateValue, StateValues, OnSetEvent, LightState, MotionState, AudioState, ObjectState, DoorbellState, SirenState, BatteryState, BaseLogger, FfmpegOptions, CameraDelegate, CameraZone, CameraSource, CameraPublicProperties, CameraType, CameraInformation, CameraPrebufferDelegate } from '../../../../../shared/types';
4
+ import type { Camera, CameraDevice, StateValue, StateValues, OnSetEvent, LightState, MotionState, AudioState, ObjectState, DoorbellState, SirenState, BatteryState, BaseLogger, FfmpegOptions, CameraDelegate, CameraZone, CameraSource, CameraPublicProperties, CameraType, CameraInformation, CameraPrebufferDelegate, IceServer } from '../../../../../shared/types';
4
5
  export declare class CameraDeviceClient implements CameraDevice {
5
6
  private log;
6
7
  private socketService;
7
8
  private cameraSubject;
9
+ private cameraState;
8
10
  private lightState;
9
11
  private motionState;
10
12
  private audioState;
@@ -12,6 +14,7 @@ export declare class CameraDeviceClient implements CameraDevice {
12
14
  private doorbellState;
13
15
  private sirenState;
14
16
  private batteryState;
17
+ onStarted: Observable<boolean>;
15
18
  onLightSwitched: Observable<LightState>;
16
19
  onMotionDetected: Observable<MotionState>;
17
20
  onAudioDetected: Observable<AudioState>;
@@ -19,11 +22,12 @@ export declare class CameraDeviceClient implements CameraDevice {
19
22
  onDoorbellPressed: Observable<DoorbellState>;
20
23
  onSirenDetected: Observable<SirenState>;
21
24
  onBatteryChanged: Observable<BatteryState>;
22
- delegate?: CameraDelegate;
23
- prebufferDelegate?: CameraPrebufferDelegate;
25
+ private _delegate?;
26
+ private _prebufferDelegate?;
24
27
  get id(): string;
25
28
  get nativeId(): string | undefined;
26
29
  get pluginId(): string;
30
+ get state(): boolean;
27
31
  get disabled(): boolean;
28
32
  get name(): string;
29
33
  get type(): CameraType;
@@ -40,18 +44,23 @@ export declare class CameraDeviceClient implements CameraDevice {
40
44
  get motionZones(): CameraZone[];
41
45
  get objectZones(): CameraZone[];
42
46
  get sources(): CameraSource[];
47
+ get streamSource(): CameraSource;
48
+ get snapshotSource(): CameraSource;
49
+ get recordingSource(): CameraSource;
50
+ get detectionSource(): CameraSource;
51
+ get delegate(): CameraDelegate | undefined;
52
+ set delegate(delegate: CameraDelegate);
53
+ get prebufferDelegate(): CameraPrebufferDelegate | undefined;
54
+ set prebufferDelegate(delegate: CameraPrebufferDelegate);
43
55
  constructor(camera: Camera, socketService: SocketService, logger: BaseLogger);
56
+ connect(): Promise<void>;
57
+ disconnect(): Promise<void>;
44
58
  reboot(): Promise<void>;
45
- getStreamSource(): CameraSource;
46
- getSnapshotSource(): CameraSource;
47
- getRecordingSource(): CameraSource;
48
- getDetectionSource(): CameraSource;
49
- configureDelegate(delegate: CameraDelegate): void;
50
- configurePrebufferDelegate(delegate: CameraPrebufferDelegate): void;
51
59
  snapshot(forceNew?: boolean): Promise<ArrayBuffer>;
52
60
  getFfmpegPath(): Promise<string>;
53
- getIceServers(): Promise<RTCIceServer[]>;
61
+ getIceServers(): Promise<IceServer[]>;
54
62
  createSession(): Promise<any>;
63
+ createBrowserSession(sourceName: string): Promise<BrowserStreamingSession>;
55
64
  streamVideo(sourceName: string, options: FfmpegOptions): Promise<any>;
56
65
  recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
57
66
  getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
@@ -67,6 +76,7 @@ export declare class CameraDeviceClient implements CameraDevice {
67
76
  removeAllListeners(): void;
68
77
  refreshStates(): Promise<void>;
69
78
  private updateCamera;
79
+ updateCameraState(state: boolean): void;
70
80
  private unsubscribe;
71
81
  private createStateObservable;
72
82
  private listenToChanges;
@@ -1,19 +1,17 @@
1
1
  import { CameraController } from '../../../../../src/camera';
2
- import { StreamingSession } from '../../../../../src/camera/streaming/streaming-session';
3
2
  import type { SocketService } from '../../socket';
4
- import type { Camera, StateValues, OnSetEvent, BaseLogger, IceServer, StreamingConnectionOptions, FfmpegOptions, CameraSource } from '../../../../../shared/types';
3
+ import type { Camera, StateValues, OnSetEvent, BaseLogger, IceServer, CameraSource } from '../../../../../shared/types';
5
4
  export declare class CameraDeviceClient extends CameraController {
6
5
  private socketService;
7
6
  private logger;
8
7
  get sources(): CameraSource[];
9
8
  constructor(camera: Camera, socketService: SocketService, logger: BaseLogger);
9
+ connect(): Promise<void>;
10
+ disconnect(): Promise<void>;
10
11
  reboot(): Promise<void>;
11
12
  getFfmpegPath(): Promise<string>;
12
13
  getIceServers(): Promise<IceServer[]>;
13
14
  snapshot(forceNew?: boolean | undefined): Promise<ArrayBuffer>;
14
- createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
15
- streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
16
- recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
17
15
  updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
18
16
  refreshStates(): Promise<void>;
19
17
  private close;
@@ -6,3 +6,5 @@ export * from '../../src/api/ws/types';
6
6
  export * from '../../src/go2rtc/types';
7
7
  export * from '../../src/camera/types';
8
8
  export * from '../../src/proxy/types';
9
+ export * from '../../src/camera/streaming/browser/browser-streaming-session';
10
+ export * from '../../src/camera/streaming/browser/webrtc-browser-connection';
package/dist/src/api.d.ts CHANGED
@@ -2,60 +2,32 @@
2
2
  import EventEmitter from 'events';
3
3
  import { CameraController } from './camera';
4
4
  import type { PluginLogger } from './services/logger';
5
- import type { PluginContract } from './plugins/types';
6
- import type { PluginConfigService } from './plugins/config';
5
+ import type { API } from './plugins/api';
7
6
  import type { BasePlugin } from './plugins/base';
8
- import type { Storage } from './plugins/storageController';
9
7
  import type { Camera } from './api/database/types';
10
- import type { DeviceManager, PluginsManager, SystemManager } from './proxy/client';
11
- export interface PluginInitializer {
12
- (api: API): void | Promise<void>;
13
- }
8
+ import type { PluginContract } from './plugins/types';
14
9
  export interface PluginConstructor {
15
- new (pluginId: string, log: PluginLogger, config: PluginConfigService, storage: Storage, api: API): BasePlugin;
10
+ contract: PluginContract;
11
+ new (pluginId: string, log: PluginLogger, api: API): BasePlugin;
16
12
  }
17
13
  export declare const enum API_EVENT {
18
14
  FINISH_LAUNCHING = "finishLaunching",
19
15
  SHUTDOWN = "shutdown"
20
16
  }
21
- export declare const enum INTERNAL_API_EVENT {
22
- REGISTER_PLUGIN = "registerPlugin"
23
- }
24
- export interface API {
25
- on(event: 'finishLaunching', listener: () => void): this;
26
- on(event: 'shutdown', listener: () => void): this;
27
- deviceManager: DeviceManager;
28
- pluginsManager: PluginsManager;
29
- systemManager: SystemManager;
30
- registerPlugin(constructor: PluginConstructor, contract: PluginContract): void;
31
- storage(): {
32
- storagePath: string;
33
- configFile: string;
34
- };
35
- }
36
17
  export declare interface CameraUiAPI {
37
18
  on(event: 'finishLaunching', listener: () => void): this;
38
19
  on(event: 'shutdown', listener: () => void): this;
39
- deviceManager: DeviceManager;
40
- pluginsManager: PluginsManager;
41
- systemManager: SystemManager;
42
- registerPlugin(constructor: PluginConstructor, contract: PluginContract): void;
43
- storage(): {
44
- storagePath: string;
45
- configFile: string;
46
- };
47
- on(event: INTERNAL_API_EVENT.REGISTER_PLUGIN, listener: (constructor: PluginConstructor, contract: PluginContract) => void): this;
48
20
  emit(event: 'finishLaunching'): boolean;
49
21
  emit(event: 'shutdown'): boolean;
50
- emit(event: INTERNAL_API_EVENT.REGISTER_PLUGIN, constructor: PluginConstructor, contract: PluginContract): boolean;
51
22
  }
52
- export declare class CameraUiAPI extends EventEmitter implements API {
23
+ export declare class CameraUiAPI extends EventEmitter {
53
24
  private devices;
54
25
  constructor();
55
26
  configureCameras(): Promise<void>;
56
27
  addCamera(camera: Camera): void;
57
28
  getCamera(cameraId: string): CameraController | undefined;
58
- getCameras(): CameraController[];
29
+ getCameras(pluginId?: string): CameraController[];
30
+ stopCamera(cameraId: string): void;
59
31
  updateCamera(cameraData: Camera): void;
60
32
  removeCamera(cameraId: string): Promise<void>;
61
33
  }
@@ -1,5 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { StreamingSession } from './streaming/streaming-session';
3
+ import { BrowserStreamingSession } from './streaming/browser/browser-streaming-session';
3
4
  import type { Camera, CameraPublicProperties, CameraZone, CameraType, CameraInformation } from '../api/database/types';
4
5
  import type { ProxyServer } from '../proxy';
5
6
  import type { CameraDevice, BaseLogger, CameraDelegate, CameraPrebufferDelegate } from './types';
@@ -9,6 +10,7 @@ export declare class CameraController implements CameraDevice {
9
10
  private log;
10
11
  private proxy?;
11
12
  private cameraSubject;
13
+ private cameraState;
12
14
  private lightState;
13
15
  private motionState;
14
16
  private audioState;
@@ -17,6 +19,7 @@ export declare class CameraController implements CameraDevice {
17
19
  private sirenState;
18
20
  private batteryState;
19
21
  private snapshotCache;
22
+ onStarted: Observable<boolean>;
20
23
  onLightSwitched: Observable<LightState>;
21
24
  onMotionDetected: Observable<MotionState>;
22
25
  onAudioDetected: Observable<AudioState>;
@@ -24,11 +27,12 @@ export declare class CameraController implements CameraDevice {
24
27
  onDoorbellPressed: Observable<DoorbellState>;
25
28
  onSirenDetected: Observable<SirenState>;
26
29
  onBatteryChanged: Observable<BatteryState>;
27
- delegate?: CameraDelegate;
28
- prebufferDelegate?: CameraPrebufferDelegate;
30
+ private _delegate?;
31
+ private _prebufferDelegate?;
29
32
  get id(): string;
30
33
  get nativeId(): string | undefined;
31
34
  get pluginId(): string;
35
+ get state(): boolean;
32
36
  get disabled(): boolean;
33
37
  get name(): string;
34
38
  get type(): CameraType;
@@ -45,18 +49,23 @@ export declare class CameraController implements CameraDevice {
45
49
  get motionZones(): CameraZone[];
46
50
  get objectZones(): CameraZone[];
47
51
  get sources(): CameraSource[];
52
+ get streamSource(): CameraSource;
53
+ get snapshotSource(): CameraSource;
54
+ get recordingSource(): CameraSource;
55
+ get detectionSource(): CameraSource;
56
+ get delegate(): CameraDelegate | undefined;
57
+ set delegate(delegate: CameraDelegate);
58
+ get prebufferDelegate(): CameraPrebufferDelegate | undefined;
59
+ set prebufferDelegate(delegate: CameraPrebufferDelegate);
48
60
  constructor(camera: Camera, logger: BaseLogger, proxy?: ProxyServer);
61
+ connect(): Promise<void>;
62
+ disconnect(): Promise<void>;
49
63
  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
64
  snapshot(forceNew?: boolean): Promise<ArrayBuffer>;
57
65
  getFfmpegPath(): Promise<string>;
58
66
  getIceServers(): Promise<IceServer[]>;
59
67
  createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
68
+ createBrowserSession(): Promise<BrowserStreamingSession>;
60
69
  streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
61
70
  recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
62
71
  getValue<T extends keyof StateValues>(stateName: T): StateValues[T];
@@ -70,9 +79,11 @@ export declare class CameraController implements CameraDevice {
70
79
  newData: Camera[T];
71
80
  }>;
72
81
  updateCamera(updatedCamera: Camera): void;
82
+ updateCameraState(state: boolean): void;
73
83
  removeCamera(): void;
74
84
  removeAllListeners(): void;
75
85
  private createStateObservable;
86
+ private subscribeToCameraState;
76
87
  private subscribeToCameraChanges;
77
88
  private subscribeToStateChanges;
78
89
  private triggerProxyEvent;
@@ -0,0 +1,22 @@
1
+ import { ReplaySubject, Subject } from 'rxjs';
2
+ import { Subscribed } from '../../utils/subscribed';
3
+ import type { BasicBrowserPeerConnection, BaseLogger, CameraDevice } from '../../types';
4
+ import type { IceServer } from '../../../services/config/types';
5
+ export declare class BrowserPeerConnection extends Subscribed implements BasicBrowserPeerConnection {
6
+ onIceCandidate: Subject<RTCIceCandidate>;
7
+ onConnectionState: ReplaySubject<RTCPeerConnectionState>;
8
+ videoTransceiver: RTCRtpTransceiver;
9
+ audioTransceiver: RTCRtpTransceiver;
10
+ private cameraDevice;
11
+ private logger;
12
+ private pc;
13
+ constructor(cameraDevice: CameraDevice, iceServers: IceServer[], logger: BaseLogger);
14
+ createOffer(): Promise<RTCSessionDescriptionInit>;
15
+ acceptAnswer(answer: {
16
+ type: 'answer';
17
+ sdp: string;
18
+ }): Promise<void>;
19
+ addIceCandidate(candidate: RTCIceCandidateInit): Promise<void>;
20
+ close(): void;
21
+ private createPeerCoonection;
22
+ }
@@ -0,0 +1,17 @@
1
+ import { ReplaySubject } from 'rxjs';
2
+ import { Subscribed } from '../../utils/subscribed';
3
+ import type { BaseLogger, CameraDevice } from '../../types';
4
+ import type { WebrtcBrowserConnection } from './webrtc-browser-connection';
5
+ export declare class BrowserStreamingSession extends Subscribed {
6
+ readonly onCallEnded: ReplaySubject<void>;
7
+ private readonly onUsingOpus;
8
+ private hasEnded;
9
+ private cameraDevice;
10
+ private connection;
11
+ private logger;
12
+ get isUsingOpus(): Promise<boolean>;
13
+ constructor(cameraDevice: CameraDevice, logger: BaseLogger, connection: WebrtcBrowserConnection);
14
+ stop(): void;
15
+ private bindToConnection;
16
+ private callEnded;
17
+ }
@@ -0,0 +1,26 @@
1
+ import { ReplaySubject, type Observable } from 'rxjs';
2
+ import { Subscribed } from '../../utils/subscribed';
3
+ import type { CameraDevice, BaseLogger } from '../../types';
4
+ import type { IceServer } from '../../../services/config/types';
5
+ export declare class WebrtcBrowserConnection extends Subscribed {
6
+ readonly onCameraConnected: ReplaySubject<void>;
7
+ readonly onCallAnswered: ReplaySubject<string>;
8
+ readonly onCallEnded: ReplaySubject<void>;
9
+ readonly onError: ReplaySubject<void>;
10
+ readonly onMessage: ReplaySubject<{
11
+ method: string;
12
+ }>;
13
+ readonly onWsOpen: Observable<unknown>;
14
+ private readonly pc;
15
+ private readonly ws;
16
+ private readonly onOfferSent;
17
+ private hasEnded;
18
+ private cameraDevice;
19
+ private logger;
20
+ constructor(cameraDevice: CameraDevice, sourceName: string, iceServers: IceServer[], logger: BaseLogger);
21
+ stop(): void;
22
+ private initiateCall;
23
+ private handleMessage;
24
+ private sendMessage;
25
+ private callEnded;
26
+ }
@@ -1,9 +1,11 @@
1
1
  /// <reference types="pouchdb-core" />
2
2
  /// <reference types="node" />
3
3
  import type { Observable, Subject } from 'rxjs';
4
- import type { ConnectionState, RTCIceCandidate } from 'werift';
4
+ import type { ConnectionState, RTCIceCandidate as WeriftRTCICECandidate, RTCSessionDescription } from 'werift';
5
5
  import type { Camera, CameraPublicProperties, CameraInputSettings, CameraZone, CameraInput, CameraType, CameraInformation } from '../api/database/types';
6
+ import type { IceServer } from '../services/config/types';
6
7
  import type { StreamingSession } from './streaming/streaming-session';
8
+ import type { BrowserStreamingSession } from './streaming/browser/browser-streaming-session';
7
9
  export type SpawnInput = string | number;
8
10
  export type PrebufferType = 'recording' | 'stream';
9
11
  export interface CameraSource extends CameraInput {
@@ -28,23 +30,33 @@ export interface StreamingConnectionOptions {
28
30
  createPeerConnection?: () => BasicPeerConnection;
29
31
  }
30
32
  export interface BasicPeerConnection {
31
- createOffer(): Promise<{
33
+ createOffer(): Promise<RTCSessionDescription>;
34
+ acceptAnswer(answer: {
35
+ type: 'answer';
32
36
  sdp: string;
33
- }>;
37
+ }): Promise<void>;
38
+ addIceCandidate(candidate: Partial<WeriftRTCICECandidate>): Promise<void>;
39
+ onIceCandidate: Subject<WeriftRTCICECandidate>;
40
+ onConnectionState: Observable<ConnectionState>;
41
+ close(): void;
42
+ requestKeyFrame?: () => void;
43
+ }
44
+ export interface BasicBrowserPeerConnection {
45
+ createOffer(): Promise<RTCSessionDescriptionInit>;
34
46
  acceptAnswer(answer: {
35
47
  type: 'answer';
36
48
  sdp: string;
37
49
  }): Promise<void>;
38
50
  addIceCandidate(candidate: Partial<RTCIceCandidate>): Promise<void>;
39
51
  onIceCandidate: Subject<RTCIceCandidate>;
40
- onConnectionState: Observable<ConnectionState>;
52
+ onConnectionState: Observable<RTCPeerConnectionState>;
41
53
  close(): void;
42
- requestKeyFrame?: () => void;
43
54
  }
44
55
  export interface CameraDevice {
45
56
  id: string;
46
57
  pluginId: string;
47
58
  nativeId?: string;
59
+ state: boolean;
48
60
  disabled: boolean;
49
61
  name: string;
50
62
  type: CameraType;
@@ -61,6 +73,7 @@ export interface CameraDevice {
61
73
  hasAudioDetector: boolean;
62
74
  hasObjectDetector: boolean;
63
75
  hasPtz: boolean;
76
+ onStarted: Observable<boolean>;
64
77
  onLightSwitched: Observable<LightState>;
65
78
  onMotionDetected: Observable<MotionState>;
66
79
  onAudioDetected: Observable<AudioState>;
@@ -68,17 +81,20 @@ export interface CameraDevice {
68
81
  onDoorbellPressed: Observable<DoorbellState>;
69
82
  onSirenDetected: Observable<SirenState>;
70
83
  onBatteryChanged: Observable<BatteryState>;
84
+ streamSource: CameraSource;
85
+ snapshotSource: CameraSource;
86
+ recordingSource: CameraSource;
87
+ detectionSource: CameraSource;
88
+ delegate?: CameraDelegate;
89
+ prebufferDelegate?: CameraPrebufferDelegate;
90
+ connect(): Promise<void>;
91
+ disconnect(): Promise<void>;
71
92
  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;
78
93
  getFfmpegPath(): Promise<string>;
79
- getIceServers(): Promise<RTCIceServer[]>;
94
+ getIceServers(): Promise<IceServer[]>;
80
95
  snapshot(forceNew?: boolean): Promise<ArrayBuffer>;
81
96
  createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
97
+ createBrowserSession(sourceName: string): Promise<BrowserStreamingSession>;
82
98
  streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
83
99
  recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
84
100
  getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
@@ -0,0 +1,31 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from 'events';
3
+ import { DeviceManager, PluginsManager, SystemManager } from '../proxy/client';
4
+ import { StorageController } from './storageController';
5
+ import type { ZmqInfo } from './types';
6
+ import type { Plugin } from './plugin';
7
+ import type { PluginLogger } from '../services/logger';
8
+ import type { BasePlugin } from './base';
9
+ import type { PluginConfigService } from './config';
10
+ export interface API {
11
+ on(event: 'finishLaunching', listener: () => void): this;
12
+ on(event: 'shutdown', listener: () => void): this;
13
+ readonly deviceManager: DeviceManager;
14
+ readonly pluginsManager: PluginsManager;
15
+ readonly systemManager: SystemManager;
16
+ readonly storageController: StorageController;
17
+ readonly configService: PluginConfigService;
18
+ readonly storagePath: string;
19
+ readonly configFile: string;
20
+ }
21
+ export declare class PluginAPI extends EventEmitter implements API {
22
+ readonly deviceManager: DeviceManager;
23
+ readonly pluginsManager: PluginsManager;
24
+ readonly systemManager: SystemManager;
25
+ readonly storageController: StorageController;
26
+ readonly configService: PluginConfigService;
27
+ readonly storagePath: string;
28
+ readonly configFile: string;
29
+ readonly plugin: BasePlugin;
30
+ constructor(plugin: Plugin, logger: PluginLogger, proxyData: ZmqInfo);
31
+ }
@@ -1,19 +1,15 @@
1
- import type { API } from '../api';
1
+ import type { API } from './api';
2
2
  import type { CameraDevice } from '../camera/types';
3
3
  import type { PluginLogger } from '../services/logger';
4
- import type { PluginConfigService } from './config';
5
- import type { BasePlugin as BasePluginMethods } from './types';
6
- import type { Storage } from './storageController';
7
- export declare class BasePlugin implements BasePluginMethods {
4
+ import type { PluginContract } from './types';
5
+ export declare abstract class BasePlugin {
6
+ static contract: PluginContract;
8
7
  id: string;
9
8
  api: API;
10
- configService: PluginConfigService;
11
9
  logger: PluginLogger;
12
- storage: Storage;
13
- cameras: Map<string, CameraDevice>;
14
- constructor(pluginId: string, log: PluginLogger, configService: PluginConfigService, storage: Storage, api: API);
15
- onFormSubmit(actionId: string, payload: any): Promise<{
10
+ constructor(pluginId: string, log: PluginLogger, api: API);
11
+ abstract onFormSubmit(actionId: string, payload: any): Promise<{
16
12
  toast?: string;
17
13
  } | void>;
18
- configureCameras(cameras: CameraDevice[]): void;
14
+ abstract configureCameras(cameras: CameraDevice[]): void;
19
15
  }
@@ -1,6 +1,6 @@
1
- import type { API } from '../api';
2
- import type { PluginJsonSchemaForm, PluginJsonSchema, CameraStorage as CameraStorageMethods, SchemaConfig } from './types';
3
- export declare class CameraStorage implements CameraStorageMethods {
1
+ import type { API } from './api';
2
+ import type { PluginJsonSchemaForm, PluginJsonSchema, SchemaConfig } from './types';
3
+ export declare class CameraStorage {
4
4
  private cameraId;
5
5
  private instance;
6
6
  private api;
@@ -23,8 +23,8 @@ export declare class CameraStorage implements CameraStorageMethods {
23
23
  * @param path - The path to the configuration value.
24
24
  * @returns The value from the configuration.
25
25
  */
26
+ getValue<T = string>(path: string): Promise<T> | T | undefined;
26
27
  getValue<T = string>(path: string, defaultValue: T): Promise<T> | T;
27
- getValue<T = string>(path: string, defaultValue?: T): Promise<T> | T | undefined;
28
28
  /**
29
29
  * Set a new value for a given key/path in the configuration.
30
30
  * If the schema of the value has an onSet function, and the value has changed, the onSet function will be called.
@@ -12,9 +12,7 @@ export declare class PluginManager {
12
12
  plugins: Map<string, Plugin>;
13
13
  pluginWorkers: Map<string, PluginWorker>;
14
14
  searchPaths: Set<string>;
15
- private api;
16
15
  private configService;
17
- private currentInitializingPlugin?;
18
16
  constructor();
19
17
  static isQualifiedPluginIdentifier(pluginName: string): boolean;
20
18
  static extractPluginScope(pluginName: string): string;
@@ -23,7 +21,6 @@ export declare class PluginManager {
23
21
  static loadPackageJSON(installPath: string): IPackageJson;
24
22
  initializeInstalledPlugins(): Promise<void>;
25
23
  initializeInstalledPlugin(plugin: Plugin, insertDb?: boolean): Promise<void>;
26
- initializePlugin(plugin: Plugin, pluginName: string): Promise<void>;
27
24
  loadPlugin(absolutePath: string, pluginId?: string, storagePath?: string): Promise<Plugin>;
28
25
  removePlugin(plugin: Plugin, removeFromDb?: boolean, removeStorage?: boolean): Promise<void>;
29
26
  startPluginChilds(): Promise<void>;
@@ -31,7 +28,6 @@ export declare class PluginManager {
31
28
  stopPluginChild(pluginName: string): Promise<void>;
32
29
  private loadInstalledPlugins;
33
30
  private removeOrphanedPlugins;
34
- private handlePluginRegistration;
35
31
  private loadDefaultPaths;
36
32
  private addNpmPrefixToSearchPaths;
37
33
  private isDependencyForOthers;
@@ -5,7 +5,7 @@
5
5
  *
6
6
  **/
7
7
  import { PluginConfigService } from './config';
8
- import type { CameraUiAPI, PluginConstructor } from '../api';
8
+ import type { PluginConstructor } from '../api';
9
9
  import type { IPackageJson, CameraUiPlugin } from '../api/types';
10
10
  import type { PluginContract } from './types';
11
11
  export interface Context {
@@ -33,18 +33,14 @@ export declare class Plugin {
33
33
  readonly storagePath: string;
34
34
  private readonly main;
35
35
  private loadContext?;
36
- private pluginInitializer?;
37
- private pluginConstructor;
36
+ pluginConstructor?: PluginConstructor;
38
37
  get contract(): PluginContract;
39
38
  get info(): CameraUiPlugin;
40
39
  set info(value: CameraUiPlugin);
41
40
  get disabled(): boolean;
42
41
  set disabled(value: boolean);
43
42
  constructor(pluginName: string, installPath: string, packageJSON: IPackageJson, pluginId: string, scope?: string, storagePath?: string);
44
- getPluginConstructor(pluginName: string): PluginConstructor;
45
- initialize(api: CameraUiAPI): void | Promise<void>;
46
43
  load(): Promise<void>;
47
- registerPlugin(constructor: PluginConstructor, contract: PluginContract): void;
48
44
  reparsePackageJson(): CameraUiPlugin;
49
45
  private parsePackageJson;
50
46
  }
@@ -1,7 +1,7 @@
1
1
  import { CameraStorage } from './cameraStorage';
2
- import type { API } from '../api';
2
+ import type { API } from './api';
3
3
  import type { PluginJsonSchemaForm } from './types';
4
- export declare class Storage {
4
+ export declare class StorageController {
5
5
  private api;
6
6
  private cameraStorages;
7
7
  constructor(api: API);
@@ -1,5 +1,4 @@
1
1
  import type { Camera } from '../api/database/types';
2
- import type { CameraDevice } from '../camera/types';
3
2
  export type PluginGraph = Map<string, string[]>;
4
3
  export type PluginCycles = Map<string, string[]>;
5
4
  export type PluginGroups = Map<string, string[]>;
@@ -7,18 +6,6 @@ export interface SchemaConfig {
7
6
  rootSchema: PluginRootSchema;
8
7
  config: Record<string, any>;
9
8
  }
10
- export interface CameraStorage {
11
- setValue<T = string>(path: string, newValue: T): Promise<void>;
12
- getValue<T = string>(path: string): T | Promise<T> | undefined;
13
- getConfig(): Promise<SchemaConfig>;
14
- setConfig(config: Record<string, any>): Promise<void>;
15
- }
16
- export interface BasePlugin {
17
- onFormSubmit(actionId: string, payload: any): Promise<{
18
- toast?: string;
19
- } | void>;
20
- configureCameras(cameras: CameraDevice[]): void;
21
- }
22
9
  export declare const PLUGIN_IDENTIFIER_PATTERN: RegExp;
23
10
  export type JSONValue = string | number | boolean | JSONObject | JSONArray;
24
11
  export interface JSONObject {
@@ -8,13 +8,11 @@ export declare class PluginWorker {
8
8
  private configService;
9
9
  private socketService;
10
10
  private started;
11
- private manuallyKilled;
12
11
  private shuttingDown;
13
12
  private _status;
14
13
  get status(): PLUGIN_STATUS;
15
14
  constructor(plugin: Plugin);
16
15
  start(): Promise<void>;
17
- stop(): Promise<void>;
18
16
  teardown(): Promise<void>;
19
17
  restart(): Promise<void>;
20
18
  getPID(): number;
@@ -1,8 +1,9 @@
1
1
  import { CameraController } from '../../camera';
2
- import { StreamingSession } from '../../camera/streaming/streaming-session';
3
2
  import type { Camera } from '../../api/database/types';
4
- import type { StateValues, OnSetEvent, StreamingConnectionOptions, FfmpegOptions, CameraSource } from '../../camera/types';
5
3
  import type { IceServer } from '../../services/config/types';
4
+ import type { ZmqInfo } from '../../plugins/types';
5
+ import type { PluginAPI } from '../../plugins/api';
6
+ import type { StateValues, OnSetEvent, CameraSource } from '../../camera/types';
6
7
  export declare class CameraDeviceClientProxy extends CameraController {
7
8
  private api;
8
9
  private logger;
@@ -15,14 +16,13 @@ export declare class CameraDeviceClientProxy extends CameraController {
15
16
  private routerAddress;
16
17
  private publisherAddress;
17
18
  get sources(): CameraSource[];
18
- constructor(camera: Camera, pluginId: string, pluginName: string, routerAddress: string, publisherAddress: string, serverPublicKey: string);
19
+ constructor(api: PluginAPI, camera: Camera, pluginId: string, pluginName: string, proxy: ZmqInfo);
20
+ connect(): Promise<void>;
21
+ disconnect(): Promise<void>;
19
22
  reboot(): Promise<void>;
20
23
  getFfmpegPath(): Promise<string>;
21
24
  getIceServers(): Promise<IceServer[]>;
22
25
  snapshot(forceNew?: boolean): Promise<ArrayBuffer>;
23
- createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
24
- streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
25
- recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
26
26
  updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
27
27
  refreshStates(): Promise<void>;
28
28
  close(): void;