@camera.ui/browser 0.0.90 → 0.0.92

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 (66) hide show
  1. package/dist/bundle.js +1 -1
  2. package/dist/types/packages/client/browser/src/proxy/cameraDevice.d.ts +6 -6
  3. package/dist/types/packages/client/browser/src/proxy/coreManager.d.ts +2 -1
  4. package/dist/types/packages/client/browser/src/proxy/deviceManager.d.ts +1 -2
  5. package/dist/types/packages/client/browser/src/types.d.ts +11 -3
  6. package/dist/types/packages/common/src/messaging/index.d.ts +48 -0
  7. package/dist/types/packages/common/src/nats/index.d.ts +30 -0
  8. package/dist/types/{server/src → packages/plugineer/src/polyglot/node}/camera/index.d.ts +4 -9
  9. package/dist/types/packages/plugineer/src/polyglot/node/camera/interfaces/camera.d.ts +8 -0
  10. package/dist/types/packages/plugineer/src/polyglot/node/camera/interfaces/prebuffer.d.ts +9 -0
  11. package/dist/types/{server/src → packages/plugineer/src/polyglot/node}/camera/interfaces/ptz.d.ts +3 -5
  12. package/dist/types/{server/src → packages/plugineer/src/polyglot/node}/camera/iou.d.ts +1 -1
  13. package/dist/types/{server/src → packages/plugineer/src/polyglot/node}/camera/polygon.d.ts +1 -2
  14. package/dist/types/{server → packages/plugineer}/src/polyglot/node/plugins/schema.d.ts +2 -2
  15. package/dist/types/server/src/api/database/constants.d.ts +8 -0
  16. package/dist/types/server/src/api/database/index.d.ts +0 -8
  17. package/dist/types/server/src/api/database/types.d.ts +6 -6
  18. package/dist/types/server/src/api/schemas/cameras.schema.d.ts +117 -117
  19. package/dist/types/server/src/api/schemas/config.schema.d.ts +6 -6
  20. package/dist/types/server/src/api/schemas/go2rtc.schema.d.ts +84 -84
  21. package/dist/types/server/src/api/schemas/users.schema.d.ts +150 -150
  22. package/dist/types/server/src/api/types/index.d.ts +1 -1
  23. package/dist/types/server/src/api/websocket/nsp/metrics.d.ts +5 -1
  24. package/dist/types/server/src/api.d.ts +1 -7
  25. package/dist/types/server/src/camera/controller.d.ts +4 -9
  26. package/dist/types/server/src/camera/types.d.ts +27 -22
  27. package/dist/types/server/src/decoder/worker.d.ts +1 -1
  28. package/dist/types/server/src/nats/index.d.ts +3 -4
  29. package/dist/types/server/src/nats/proxy/cameraDevice.d.ts +3 -4
  30. package/dist/types/server/src/nats/proxy/coreManager.d.ts +3 -3
  31. package/dist/types/server/src/nats/proxy/deviceManager.d.ts +5 -5
  32. package/dist/types/server/src/nats/types.d.ts +6 -42
  33. package/dist/types/server/src/plugins/interfaces/base.d.ts +1 -1
  34. package/dist/types/server/src/plugins/plugin.d.ts +1 -1
  35. package/dist/types/server/src/plugins/types.d.ts +36 -3
  36. package/dist/types/server/src/services/config/index.d.ts +3 -2
  37. package/dist/types/server/src/services/logger/index.d.ts +4 -16
  38. package/dist/types/shared/types/index.d.ts +5 -3
  39. package/package.json +5 -3
  40. package/dist/types/server/src/camera/device.d.ts +0 -29
  41. package/dist/types/server/src/camera/interfaces/camera.d.ts +0 -10
  42. package/dist/types/server/src/camera/interfaces/prebuffer.d.ts +0 -11
  43. package/dist/types/server/src/camera/streaming/peer-connection.d.ts +0 -54
  44. package/dist/types/server/src/camera/streaming/webrtc-connection.d.ts +0 -35
  45. package/dist/types/server/src/camera/streaming/werift-session.d.ts +0 -41
  46. package/dist/types/server/src/camera/videoFrame.d.ts +0 -24
  47. package/dist/types/server/src/nats/connection.d.ts +0 -17
  48. package/dist/types/server/src/nats/constants.d.ts +0 -1
  49. package/dist/types/server/src/nats/error.d.ts +0 -9
  50. package/dist/types/server/src/nats/messageQueue.d.ts +0 -20
  51. package/dist/types/server/src/nats/subscription.d.ts +0 -12
  52. package/dist/types/server/src/polyglot/node/plugins/cameraStorage.d.ts +0 -107
  53. package/dist/types/server/src/polyglot/node/plugins/configService.d.ts +0 -104
  54. package/dist/types/server/src/polyglot/node/plugins/pluginApi.d.ts +0 -35
  55. package/dist/types/server/src/polyglot/node/plugins/pluginLogger.d.ts +0 -18
  56. package/dist/types/server/src/polyglot/node/plugins/proxy/cameraDevice.d.ts +0 -69
  57. package/dist/types/server/src/polyglot/node/plugins/proxy/coreManager.d.ts +0 -40
  58. package/dist/types/server/src/polyglot/node/plugins/proxy/deviceManager.d.ts +0 -47
  59. package/dist/types/server/src/polyglot/node/plugins/storageController.d.ts +0 -30
  60. package/dist/types/server/src/utils/ffmpeg.d.ts +0 -2
  61. package/dist/types/server/src/utils/network.d.ts +0 -12
  62. package/dist/types/server/src/utils/npm.d.ts +0 -1
  63. package/dist/types/server/src/utils/pythonInstaller.d.ts +0 -48
  64. package/dist/types/server/src/utils/utils.d.ts +0 -10
  65. /package/dist/types/{server/src/utils/packer.d.ts → packages/common/src/packer/index.d.ts} +0 -0
  66. /package/dist/types/{server → packages/common}/src/utils/subscribed.d.ts +0 -0
@@ -50,7 +50,7 @@ export interface ClientData {
50
50
  address?: string;
51
51
  device?: string;
52
52
  }
53
- export declare enum REFRESH_TOKEN {
53
+ export declare const enum REFRESH_TOKEN {
54
54
  EXPIRES_IN = "7d"
55
55
  }
56
56
  export declare const PAGINATION_DEFAULTS: PaginationQuery;
@@ -1,5 +1,5 @@
1
1
  import type { Namespace, Server } from 'socket.io';
2
- import type { ServerProcesses, SocketNsp, WorkerProcesses } from '../types.js';
2
+ import type { ProcessInfo, ServerProcesses, SocketNsp, WorkerProcesses } from '../types.js';
3
3
  export declare class MetricsNamespace {
4
4
  nsp: Namespace;
5
5
  nspName: SocketNsp;
@@ -12,9 +12,13 @@ export declare class MetricsNamespace {
12
12
  private processNatHistory;
13
13
  private processPluginsHistory;
14
14
  private processFrameWorkerHistory;
15
+ private systemHistory;
15
16
  constructor(io: Server);
17
+ getSystemInfos(payload: any, callback?: Function): Promise<ProcessInfo[]>;
16
18
  getServerProcessesInfos(payload: any, callback?: Function): Promise<ServerProcesses>;
17
19
  getPluginsProcessesInfo(payload: any, callback?: Function): Promise<WorkerProcesses>;
18
20
  getFrameWorkerProcessesInfo(payload: any, callback?: Function): Promise<WorkerProcesses>;
19
21
  private getProcesses;
22
+ private getSystemLoad;
23
+ private getSystemLoadAlt;
20
24
  }
@@ -3,14 +3,8 @@ import { EventEmitter } from 'node:events';
3
3
  import { CameraController } from './camera/controller.js';
4
4
  import type { Camera, CameraExtensions } from './api/database/types.js';
5
5
  import type { FrameWorker } from './decoder/worker.js';
6
- import type { BasePlugin } from './plugins/interfaces/base.js';
7
6
  import type { CameraExtension } from './plugins/types.js';
8
- import type { API } from './polyglot/node/plugins/pluginApi.js';
9
- import type { PluginLogger } from './polyglot/node/plugins/pluginLogger.js';
10
- export interface PluginConstructor {
11
- new (logger: PluginLogger, api: API): BasePlugin;
12
- }
13
- export declare const enum API_EVENT {
7
+ export declare enum API_EVENT {
14
8
  FINISH_LAUNCHING = "finishLaunching",
15
9
  SHUTDOWN = "shutdown"
16
10
  }
@@ -1,10 +1,9 @@
1
- import { CameraDevice } from './device.js';
2
- import { CameraPrebufferInterface } from './interfaces/prebuffer.js';
3
- import { CameraPTZInterface } from './interfaces/ptz.js';
1
+ import { CameraDevice, CameraPrebufferInterface, CameraPTZInterface } from '@camera.ui/plugineer';
2
+ import type { Logger } from '@camera.ui/common/logger';
4
3
  import type { Camera } from '../api/database/types.js';
5
4
  import type { MotionFrame, VideoFrame } from '../decoder/types.js';
6
5
  import type { ProxyServer } from '../nats/index.js';
7
- import type { BaseLogger, CameraConfigInputSettings, CameraDelegate, CameraSource, Container, PrebufferState, SetValues } from './types.js';
6
+ import type { CameraConfigInputSettings, CameraDelegate, CameraSource, SetValues } from './types.js';
8
7
  export declare class CameraController extends CameraDevice {
9
8
  proxy: ProxyServer;
10
9
  private motionTimeout?;
@@ -12,13 +11,12 @@ export declare class CameraController extends CameraDevice {
12
11
  private objectTimeoutDuration;
13
12
  private doorbellTimeout?;
14
13
  private doorbellTimeoutDuration;
15
- private prebufferStateSubscriptions;
16
14
  protected cameraDelegate: CameraDelegate;
17
15
  protected ptzDelegate: CameraPTZInterface;
18
16
  protected prebufferDelegate: CameraPrebufferInterface;
19
17
  get camera(): Camera;
20
18
  get sources(): CameraSource[];
21
- constructor(camera: Camera, logger: BaseLogger, proxy: ProxyServer);
19
+ constructor(camera: Camera, logger: Logger, proxy: ProxyServer);
22
20
  setDelegate(): void;
23
21
  getFrames(): AsyncIterableIterator<VideoFrame>;
24
22
  getMotionFrames(): AsyncIterableIterator<MotionFrame>;
@@ -29,11 +27,8 @@ export declare class CameraController extends CameraDevice {
29
27
  updateCameraSource(sourceId: string, source: Partial<CameraConfigInputSettings>): Promise<void>;
30
28
  removeCameraSource(sourceId: string): Promise<void>;
31
29
  updateCamera(updatedCamera: Camera): void;
32
- updatePrebuffer(sourceId: string, container: Container, state: PrebufferState): void;
33
- cameraSourcePrebufferState(sourceId: string, container: Container): PrebufferState;
34
30
  cleanup(): void;
35
31
  private subscribeToCameraState;
36
- private subscribeToCameraSourcesState;
37
32
  private subscribeToCameraChanges;
38
33
  private subscribeToStateChanges;
39
34
  private subscribeToMotionState;
@@ -1,22 +1,12 @@
1
- import type { BehaviorSubject, Observable } from 'rxjs';
1
+ import type { CameraInterface, CameraPrebufferInterface, CameraPTZInterface } from '@camera.ui/plugineer';
2
2
  import type { CameraInformation, CameraInput, CameraInputSettings, Point, ZoneFilter, ZoneType } from '../api/database/types.js';
3
3
  import type { FrameData, FrameMetadata } from '../decoder/types.js';
4
- import type { CameraInterface } from './interfaces/camera.js';
5
- import type { CameraPrebufferInterface } from './interfaces/prebuffer.js';
6
- import type { CameraPTZInterface } from './interfaces/ptz.js';
7
- export interface BaseLogger {
8
- log: (...args: any[]) => void;
9
- error: (...args: any[]) => void;
10
- warn: (...args: any[]) => void;
11
- debug: (...args: any[]) => void;
12
- trace: (...args: any[]) => void;
13
- attention: (...args: any[]) => void;
14
- }
4
+ import type { JsonSchema, JsonSchemaForm, SchemaConfig } from '../plugins/types.js';
15
5
  export type SpawnInput = string | number;
16
6
  export interface FfmpegOptions {
17
7
  ffmpegPath: string;
18
8
  input?: SpawnInput[];
19
- video?: SpawnInput[] | false;
9
+ video?: SpawnInput[];
20
10
  audio?: SpawnInput[];
21
11
  output: SpawnInput[];
22
12
  }
@@ -33,9 +23,7 @@ export interface PrebufferStateFalse extends BasePrebufferState {
33
23
  }
34
24
  export type PrebufferState = PrebufferStateTrue | PrebufferStateFalse;
35
25
  export interface CameraSource extends CameraInput {
36
- updatePrebufferingState(container: Container, state: PrebufferState): Promise<void>;
37
- getPrebufferingState(container: Container): PrebufferState;
38
- onPrebuffering(container: Container): Observable<PrebufferState>;
26
+ getPrebufferingState(container: Container): Promise<PrebufferState | undefined>;
39
27
  getStreamInfo(): Promise<StreamInfo | undefined>;
40
28
  }
41
29
  export interface StreamInfo {
@@ -173,12 +161,6 @@ export interface SetValues {
173
161
  siren: SirenSetEvent;
174
162
  battery: BatterySetEvent;
175
163
  }
176
- export interface PrebufferSubject {
177
- [sourceId: string]: {
178
- mp4: BehaviorSubject<PrebufferState>;
179
- mpegts: BehaviorSubject<PrebufferState>;
180
- };
181
- }
182
164
  export type CameraStateCallbacks = {
183
165
  [K in keyof StateValues]: (event: StateValues[K]) => void;
184
166
  };
@@ -190,6 +172,7 @@ export declare abstract class CameraDelegate {
190
172
  }
191
173
  export declare abstract class CameraPrebufferDelegate {
192
174
  abstract getStreamInfo(sourceName: string): Promise<StreamInfo | undefined>;
175
+ abstract getPrebufferingState(sourceName: string, container: Container): Promise<PrebufferState | undefined>;
193
176
  }
194
177
  export declare abstract class CameraPTZDelegate {
195
178
  abstract moveAbsolute(pan: number, tilt: number, zoom: number): Promise<void>;
@@ -207,3 +190,25 @@ export interface CameraDelegates {
207
190
  readonly prebufferDelegate: CameraPrebufferDelegate;
208
191
  readonly ptzDelegate: CameraPTZDelegate;
209
192
  }
193
+ export interface CameraStorage<T extends Record<string, any> = Record<string, any>> {
194
+ schema: JsonSchemaForm;
195
+ values: T;
196
+ initializeStorage(): void;
197
+ getValue<U = string>(path: string): Promise<U> | undefined;
198
+ getValue<U = string>(path: string, defaultValue: U): Promise<U>;
199
+ setValue<U = string>(path: string, newValue: U): Promise<void>;
200
+ hasValue(path: string): boolean;
201
+ getConfig(): Promise<SchemaConfig>;
202
+ setConfig(newConfig: T): Promise<void>;
203
+ addSchema(schema: JsonSchemaForm): Promise<void>;
204
+ addSchema(path: string, schema: JsonSchema): Promise<void>;
205
+ removeSchema(path: string): void;
206
+ changeSchema(path: string, newSchema: Partial<JsonSchema>): Promise<void>;
207
+ getSchema<U>(path: string): U | undefined;
208
+ hasSchema(path: string): boolean;
209
+ }
210
+ export interface StorageController {
211
+ createCameraStorage<T extends Record<string, any> = Record<string, any>>(instance: any, cameraId: string, schema?: JsonSchemaForm): CameraStorage<T>;
212
+ getCameraStorage<T extends Record<string, any> = Record<string, any>>(cameraId: string): CameraStorage<T> | undefined;
213
+ removeCameraStorage(cameraId: string): void;
214
+ }
@@ -1,5 +1,5 @@
1
+ import { Subscribed } from '@camera.ui/common';
1
2
  import { PLUGIN_STATUS } from '../plugins/types.js';
2
- import { Subscribed } from '../utils/subscribed.js';
3
3
  import type { CameraController } from '../camera/controller.js';
4
4
  import type { AuthConfig } from './types.js';
5
5
  export declare class FrameWorker extends Subscribed {
@@ -1,12 +1,11 @@
1
- import { ProxyConnection } from './connection.js';
1
+ import { ProxyConnection } from '@camera.ui/common';
2
2
  import { CameraDeviceProxy } from './proxy/cameraDevice.js';
3
3
  import { CoreManagerProxy } from './proxy/coreManager.js';
4
4
  import { DeviceManagerProxy } from './proxy/deviceManager.js';
5
5
  import { NatsServer } from './server.js';
6
- import type { StateValues } from '../camera/types.js';
7
- import type { CameraStorage } from '../polyglot/node/plugins/cameraStorage.js';
6
+ import type { ProxySubscription } from '@camera.ui/common';
7
+ import type { CameraStorage, StateValues } from '../camera/types.js';
8
8
  import type { MethodKeys, MethodType } from '../types.js';
9
- import type { ProxySubscription } from './subscription.js';
10
9
  import type { CameraDeviceListenerMessagePayload, CoreManagerProxyEvents, DeviceManagerProxyEvents, PluginMap, ProxyAuth } from './types.js';
11
10
  import type { WebsocketProxy } from './websocket.js';
12
11
  export declare class ProxyServer {
@@ -1,7 +1,7 @@
1
- import type { CameraConfigInputSettings, CameraInterfaces, Container, PrebufferState, SetValues } from '../../camera/types.js';
1
+ import type { MessageQueue, ProxyMessageStructure } from '@camera.ui/common/messaging';
2
+ import type { CameraConfigInputSettings, CameraInterfaces, SetValues } from '../../camera/types.js';
2
3
  import type { MethodKeys, MethodType } from '../../types.js';
3
- import type { MessageQueue } from '../messageQueue.js';
4
- import type { CameraDeviceProxyMethods, ProxyMessageStructure, RefreshedStates } from '../types.js';
4
+ import type { CameraDeviceProxyMethods, RefreshedStates } from '../types.js';
5
5
  export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
6
6
  private api;
7
7
  private configService;
@@ -12,7 +12,6 @@ export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
12
12
  connect(cameraId: string, pluginId: string): void;
13
13
  disconnect(cameraId: string, pluginId: string): void;
14
14
  updateState<T extends keyof SetValues>(stateName: T, eventData: SetValues[T], cameraId: string, pluginId: string): Promise<void>;
15
- updatePrebufferState(sourceId: string, container: Container, state: PrebufferState, cameraId: string, pluginId: string): Promise<void>;
16
15
  addCameraSource(source: CameraConfigInputSettings, cameraId: string, pluginId: string): Promise<void>;
17
16
  updateCameraSource(sourceId: string, source: Partial<CameraConfigInputSettings>, cameraId: string, pluginId: string): Promise<void>;
18
17
  removeCameraSource(sourceId: string, cameraId: string, pluginId: string): Promise<void>;
@@ -1,7 +1,7 @@
1
+ import type { MessageQueue, ProxyMessageStructure } from '@camera.ui/common/messaging';
1
2
  import type { IceServer } from '../../services/config/types.js';
2
- import type { MessageQueue } from '../messageQueue.js';
3
- import type { CoreManagerProxyMethods, ProxyMessageStructure } from '../types.js';
4
- export declare class CoreManagerProxy implements CoreManagerProxyMethods {
3
+ import type { CoreManager } from '../types.js';
4
+ export declare class CoreManagerProxy implements CoreManager {
5
5
  private configService;
6
6
  private pluginsService;
7
7
  private systemService;
@@ -1,14 +1,14 @@
1
+ import type { MessageQueue, ProxyMessageStructure } from '@camera.ui/common/messaging';
1
2
  import type { Camera } from '../../api/database/types.js';
2
3
  import type { CameraConfig } from '../../camera/types.js';
3
- import type { MessageQueue } from '../messageQueue.js';
4
- import type { DeviceManagerServerProxyMethods, ProxyMessageStructure } from '../types.js';
5
- export declare class DeviceManagerProxy implements DeviceManagerServerProxyMethods {
4
+ import type { DeviceManager } from '../types.js';
5
+ export declare class DeviceManagerProxy implements DeviceManager {
6
6
  private camerasService;
7
7
  private pluginsService;
8
8
  private messageQueue;
9
9
  constructor(messageQueue: MessageQueue);
10
- getCameraByName(cameraName: string): Camera | undefined;
11
- getCameraById(cameraId: string): Camera | void;
10
+ getCameraByName(cameraName: string): Promise<any>;
11
+ getCameraById(cameraId: string): Promise<any>;
12
12
  createCamera(cameraConfig: CameraConfig, pluginId: string): Promise<Camera>;
13
13
  removeCameraByName(cameraName: string, pluginId: string): Promise<void>;
14
14
  removeCameraById(cameraId: string, pluginId: string): Promise<void>;
@@ -1,6 +1,6 @@
1
+ import type { CameraDevice } from '@camera.ui/plugineer';
1
2
  import type { Camera, DBSystem, VideoStreamingMode } from '../api/database/types.js';
2
- import type { CameraDevice } from '../camera/device.js';
3
- import type { CameraConfig, CameraConfigInputSettings, CameraDelegates, Container, PrebufferState, SetValues, StateValues } from '../camera/types.js';
3
+ import type { CameraConfig, CameraConfigInputSettings, SetValues, StateValues } from '../camera/types.js';
4
4
  import type { AuthConfig } from '../decoder/types.js';
5
5
  import type { AudioDetectionPlugin } from '../plugins/interfaces/audioDetection.js';
6
6
  import type { BasePlugin } from '../plugins/interfaces/base.js';
@@ -8,28 +8,6 @@ import type { MotionDetectionPlugin } from '../plugins/interfaces/motionDetectio
8
8
  import type { ObjectDetectionPlugin } from '../plugins/interfaces/objectDetection.js';
9
9
  import type { CameraExtension } from '../plugins/types.js';
10
10
  import type { IceServer } from '../services/config/types.js';
11
- import type { DeserializedError, RemoteError } from './error.js';
12
- export interface QueueItem {
13
- message: ProxyMessageStructure;
14
- resolve: (response: any) => void;
15
- reject: (error: RemoteError) => void;
16
- }
17
- export interface ProxyMessageStructure {
18
- requestId: string;
19
- cameraId?: string;
20
- targetId: string;
21
- targetName?: string;
22
- pluginId: string;
23
- type: 'request' | 'reply';
24
- proxy: 'device' | 'camera' | 'plugin' | 'core';
25
- client: 'cameraFn' | 'pluginFn' | 'deviceFn' | 'storageFn' | 'coreFn' | keyof CameraDelegates;
26
- fn: string;
27
- args: any[];
28
- timeout: number;
29
- timestamp: number;
30
- response?: any;
31
- error?: DeserializedError;
32
- }
33
11
  export interface ProxyAuth {
34
12
  cluster: AuthConfig;
35
13
  server: AuthConfig;
@@ -43,18 +21,11 @@ export interface RefreshedStates {
43
21
  camera: Camera;
44
22
  states: StateValues;
45
23
  cameraState: boolean;
46
- prebufferStates: {
47
- [key: string]: {
48
- mp4: PrebufferState;
49
- mpegts: PrebufferState;
50
- };
51
- };
52
24
  }
53
25
  export interface CameraDeviceProxyMethods {
54
26
  connect(): void;
55
27
  disconnect(): void;
56
28
  updateState<T extends keyof SetValues>(stateName: T, eventData: SetValues[T]): void;
57
- updatePrebufferState(sourceId: string, container: Container, state: PrebufferState): Promise<void>;
58
29
  refreshStates(): RefreshedStates;
59
30
  addCameraSource(source: CameraConfigInputSettings): Promise<void>;
60
31
  updateCameraSource(sourceId: string, source: Partial<CameraConfigInputSettings>): Promise<void>;
@@ -68,20 +39,13 @@ export interface CameraDeviceListenerStatePayload<K extends keyof StateValues> {
68
39
  };
69
40
  }
70
41
  export interface CameraDeviceListenerMessagePayload {
71
- type: 'removed' | 'updated' | 'cameraState' | 'prebufferState';
42
+ type: 'removed' | 'updated' | 'cameraState';
72
43
  data?: any;
73
44
  }
74
- export interface DeviceManagerServerProxyMethods {
75
- createCamera(camera: CameraConfig): Promise<Camera>;
76
- getCameraByName(name: string): Camera | void;
77
- getCameraById(id: string): Camera | void;
78
- removeCameraByName(name: string): Promise<void>;
79
- removeCameraById(id: string): Promise<void>;
80
- }
81
- export interface DeviceManagerProxyMethods {
45
+ export interface DeviceManager {
46
+ createCamera(cameraConfig: CameraConfig): Promise<CameraDevice>;
82
47
  getCameraByName(cameraName: string): Promise<CameraDevice | undefined>;
83
48
  getCameraById(cameraId: string): Promise<CameraDevice | undefined>;
84
- createCamera(cameraConfig: CameraConfig): Promise<CameraDevice>;
85
49
  removeCameraByName(cameraName: string): Promise<void>;
86
50
  removeCameraById(cameraId: string): Promise<void>;
87
51
  }
@@ -107,7 +71,7 @@ export interface DeviceManagerProxyGenericEvent<K extends keyof DeviceManagerPro
107
71
  type: K;
108
72
  data: DeviceManagerProxyEvents[K];
109
73
  }
110
- export interface CoreManagerProxyMethods {
74
+ export interface CoreManager {
111
75
  getFFmpegPath(): Promise<string>;
112
76
  getServerAddresses(): Promise<string[]>;
113
77
  getIceServers(): Promise<IceServer[]>;
@@ -1,4 +1,4 @@
1
- import type { CameraDevice } from '../../camera/device.js';
1
+ import type { CameraDevice } from '@camera.ui/plugineer';
2
2
  import type { FormSubmitResponse } from '../types.js';
3
3
  export declare abstract class BasePlugin {
4
4
  abstract onFormSubmit(actionId: string, payload: any): Promise<FormSubmitResponse | void>;
@@ -1,4 +1,4 @@
1
- import { PythonInstaller } from '../utils/pythonInstaller.js';
1
+ import { PythonInstaller } from '@camera.ui/common/python';
2
2
  import type { CameraUiPlugin, IPackageJson } from '../api/types/index.js';
3
3
  import type { PluginContract } from './types.js';
4
4
  export declare class Plugin {
@@ -1,5 +1,7 @@
1
+ import type { Path } from 'object-path';
1
2
  import type { Camera } from '../api/database/types.js';
2
- import type { Detection } from '../camera/types.js';
3
+ import type { Detection, StorageController } from '../camera/types.js';
4
+ import type { CoreManager, DeviceManager } from '../nats/types.js';
3
5
  export interface Context {
4
6
  engines?: Record<string, string>;
5
7
  dependencies?: Record<string, string>;
@@ -31,7 +33,7 @@ export interface PluginContractBase {
31
33
  pythonVersion?: string;
32
34
  }
33
35
  export type PluginContract = PluginContractBase & ExtensionOrSupport;
34
- export declare const enum PLUGIN_STATUS {
36
+ export declare enum PLUGIN_STATUS {
35
37
  READY = "ready",
36
38
  STARTING = "starting",
37
39
  STARTED = "started",
@@ -40,7 +42,7 @@ export declare const enum PLUGIN_STATUS {
40
42
  UNKNOWN = "unknown",
41
43
  DISABLED = "disabled"
42
44
  }
43
- export declare const enum PLUGIN_COMMAND {
45
+ export declare enum PLUGIN_COMMAND {
44
46
  START = "start",
45
47
  STOP = "stop"
46
48
  }
@@ -151,4 +153,35 @@ export interface ObjectDetectionPluginResponse {
151
153
  export interface AudioDetectionPluginResponse {
152
154
  detected: boolean;
153
155
  }
156
+ export interface PluginAPI {
157
+ on(event: 'finishLaunching', listener: () => void): this;
158
+ on(event: 'shutdown', listener: () => void): this;
159
+ once(event: 'finishLaunching', listener: () => void): this;
160
+ once(event: 'shutdown', listener: () => void): this;
161
+ off(event: 'finishLaunching', listener: () => void): this;
162
+ off(event: 'shutdown', listener: () => void): this;
163
+ removeListener(event: 'finishLaunching', listener: () => void): this;
164
+ removeListener(event: 'shutdown', listener: () => void): this;
165
+ removeAllListeners(event?: string): this;
166
+ readonly coreManager: CoreManager;
167
+ readonly deviceManager: DeviceManager;
168
+ readonly storageController: StorageController;
169
+ readonly configService: PluginConfigService;
170
+ readonly storagePath: string;
171
+ readonly configFile: string;
172
+ }
173
+ export interface PluginConfigService {
174
+ get(key: Path, defaultValue: JSONValue, validate: Function, refresh?: boolean, writeIfNotValid?: boolean): any;
175
+ get(key: Path, defaultValue?: unknown, validate?: Function, refresh?: boolean, writeIfNotValid?: boolean): any;
176
+ has(key: Path, refresh?: boolean): boolean;
177
+ ensureExists(key: Path, defaultValue: JSONValue, write?: boolean): void;
178
+ set(key: Path, value: any, write?: boolean): void;
179
+ insert(key: Path, value: any, at?: number, write?: boolean): void;
180
+ push(key: Path, write?: boolean, ...items: any[]): void;
181
+ delete(key: Path, write?: boolean): void;
182
+ all(refresh?: boolean): PluginConfig;
183
+ replace(config: PluginConfig, write?: boolean): void;
184
+ updateValue(path: string, searchKey: string, searchValue: any, targetKey: string, newValue: any, write?: boolean): void;
185
+ replaceOrAddItem(path: string, searchKey: string, searchValue: any, newItem: any, write?: boolean): void;
186
+ }
154
187
  export {};
@@ -1,4 +1,5 @@
1
1
  import 'reflect-metadata';
2
+ import type { LoggerOptions } from '@camera.ui/common/logger';
2
3
  import type { DeepPartial } from '../../types.js';
3
4
  import type { Go2RtcConfig, IConfig, Secrets } from './types.js';
4
5
  export declare class ConfigService {
@@ -11,9 +12,9 @@ export declare class ConfigService {
11
12
  static get VERSION(): string;
12
13
  static readonly NODE_VERSION: string;
13
14
  static readonly MIN_NODE_VERSION: string;
15
+ static readonly INSTALL_PATH: string | null;
14
16
  static readonly SERVER_PATH: string;
15
17
  static readonly INTERFACE_PATH: string;
16
- static readonly INSTALL_PATH: string | null;
17
18
  private logger;
18
19
  private _config;
19
20
  private _go2rtcConfig;
@@ -38,6 +39,7 @@ export declare class ConfigService {
38
39
  set config(newConfig: IConfig);
39
40
  get go2rtcConfig(): Go2RtcConfig;
40
41
  set go2rtcConfig(newConfig: Go2RtcConfig);
42
+ get loggerOptions(): LoggerOptions;
41
43
  constructor(homePath?: string);
42
44
  static extractVersion(str: string): string | null;
43
45
  read(): void;
@@ -57,5 +59,4 @@ export declare class ConfigService {
57
59
  private safetyEnsureDir;
58
60
  private safetyEmptyDir;
59
61
  private safetyEnsureFile;
60
- private getUserHomeDir;
61
62
  }
@@ -1,23 +1,11 @@
1
1
  import 'reflect-metadata';
2
+ import { Logger } from '@camera.ui/common/logger';
3
+ import type { LoggerOptions } from '@camera.ui/common/logger';
2
4
  import type { UiNotification } from '../../api/types/index.js';
3
5
  import type { LoggingLevel } from '../config/types.js';
4
- export declare class Logger {
5
- private _loggerPrefix;
6
- debugEnabled: boolean;
7
- traceEnabled: boolean;
8
- disableTimestamps: boolean;
6
+ export declare class LoggerService extends Logger {
9
7
  notifications: UiNotification[];
10
- get prefix(): string;
11
- constructor();
12
- log(...args: any[]): void;
13
- error(...args: any[]): void;
14
- warn(...args: any[]): void;
15
- attention(...args: any[]): void;
16
- debug(...args: any[]): void;
17
- trace(...args: any[]): void;
8
+ constructor(options?: LoggerOptions);
18
9
  notify(title: string, text: string, type: LoggingLevel, link: string): Promise<void>;
19
- formatMessage(level: 'log' | 'warn' | 'error' | 'debug' | 'trace' | 'attention', ...args: any[]): string[];
20
- private formattedArgs;
21
- private formatDateTime;
22
10
  private checkIfNotificationExists;
23
11
  }
@@ -1,3 +1,7 @@
1
+ export type * from '../../packages/common/src/messaging/index.js';
2
+ export * from '../../packages/common/src/utils/subscribed.js';
3
+ export * from '../../packages/plugineer/src/polyglot/node/camera/polygon.js';
4
+ export * from '../../packages/plugineer/src/polyglot/node/plugins/schema.js';
1
5
  export type * from '../../server/src/api/database/types.js';
2
6
  export * from '../../server/src/api/schemas/cameras.schema.js';
3
7
  export * from '../../server/src/api/schemas/plugins.schema.js';
@@ -5,14 +9,12 @@ export * from '../../server/src/api/schemas/system.schema.js';
5
9
  export * from '../../server/src/api/schemas/users.schema.js';
6
10
  export type * from '../../server/src/api/types/index.js';
7
11
  export type * from '../../server/src/api/websocket/types.js';
8
- export * from '../../server/src/camera/polygon.js';
9
12
  export type * from '../../server/src/camera/types.js';
10
13
  export type * from '../../server/src/decoder/types.js';
11
14
  export * from '../../server/src/go2rtc/types.js';
12
15
  export type * from '../../server/src/nats/types.js';
16
+ export * from '../../server/src/plugins/interfaces/base.js';
13
17
  export * from '../../server/src/plugins/types.js';
14
- export * from '../../server/src/polyglot/node/plugins/schema.js';
15
18
  export * from '../../server/src/services/config/types.js';
16
19
  export type * from '../../server/src/types.js';
17
20
  export { names as cocoLabels } from '../../server/src/utils/cocoLabels.json';
18
- export * from '../../server/src/utils/subscribed.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camera.ui/browser",
3
- "version": "0.0.90",
3
+ "version": "0.0.92",
4
4
  "description": "camera.ui browser client",
5
5
  "author": "seydx (https://github.com/seydx/camera.ui)",
6
6
  "module": "./dist/bundle.js",
@@ -20,6 +20,8 @@
20
20
  "lint": "eslint --fix --ext .js,.ts .",
21
21
  "update": "updates --update ./",
22
22
  "install-updates": "npm i --save",
23
+ "prebuild": "rimraf dist",
24
+ "postbuild": "echo Build completed successfully!",
23
25
  "prepublishOnly": "npm i --package-lock-only && npm run lint && npm run format && npm run build"
24
26
  },
25
27
  "dependencies": {
@@ -31,8 +33,8 @@
31
33
  "@rushstack/eslint-patch": "^1.10.4",
32
34
  "@swc/register": "^0.1.10",
33
35
  "@types/webrtc": "^0.0.43",
34
- "@typescript-eslint/eslint-plugin": "^8.3.0",
35
- "@typescript-eslint/parser": "^8.3.0",
36
+ "@typescript-eslint/eslint-plugin": "^8.4.0",
37
+ "@typescript-eslint/parser": "^8.4.0",
36
38
  "bufferutil": "^4.0.8",
37
39
  "eslint": "^8.57.0",
38
40
  "eslint-config-prettier": "^9.1.0",
@@ -1,29 +0,0 @@
1
- import { BehaviorSubject } from 'rxjs';
2
- import { BaseCameraDevice } from './index.js';
3
- import { WeriftSession } from './streaming/werift-session.js';
4
- import type { Observable } from 'rxjs';
5
- import type { MotionFrame, VideoFrame } from '../decoder/types.js';
6
- import type { StreamingConnectionOptions } from './streaming/peer-connection.js';
7
- import type { AudioSetEvent, BatterySetEvent, CameraConfigInputSettings, CameraDelegates, DoorbellSetEvent, FrameState, LightSetEvent, MotionSetEvent, ObjectSetEvent, SirenSetEvent } from './types.js';
8
- export declare abstract class CameraDevice extends BaseCameraDevice {
9
- protected readonly frameState: BehaviorSubject<FrameState>;
10
- protected readonly onFrame: Observable<FrameState>;
11
- abstract setDelegate<T extends keyof CameraDelegates>(name: T, delegate: CameraDelegates[T]): void;
12
- abstract connect(): Promise<void>;
13
- abstract disconnect(): Promise<void>;
14
- abstract getFrames(prebufferDuration?: number): AsyncIterableIterator<VideoFrame>;
15
- abstract getMotionFrames(): AsyncIterableIterator<MotionFrame>;
16
- abstract updateState(stateName: 'light', eventData: LightSetEvent): Promise<void>;
17
- abstract updateState(stateName: 'motion', eventData: MotionSetEvent, frame?: VideoFrame): Promise<void>;
18
- abstract updateState(stateName: 'audio', eventData: AudioSetEvent): Promise<void>;
19
- abstract updateState(stateName: 'object', eventData: ObjectSetEvent): Promise<void>;
20
- abstract updateState(stateName: 'doorbell', eventData: DoorbellSetEvent): Promise<void>;
21
- abstract updateState(stateName: 'siren', eventData: SirenSetEvent): Promise<void>;
22
- abstract updateState(stateName: 'battery', eventData: BatterySetEvent): Promise<void>;
23
- abstract addCameraSource(source: CameraConfigInputSettings): Promise<void>;
24
- abstract updateCameraSource(sourceId: string, source: Partial<CameraConfigInputSettings>): Promise<void>;
25
- abstract removeCameraSource(sourceId: string): Promise<void>;
26
- createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<WeriftSession>;
27
- protected removeAllListeners(): void;
28
- private createMotionFrameObservable;
29
- }
@@ -1,10 +0,0 @@
1
- import { CameraDelegate } from '../types.js';
2
- import type { BaseLogger } from '../types.js';
3
- export declare class CameraInterface extends CameraDelegate {
4
- delegate?: CameraDelegate;
5
- private onRequest;
6
- private logger;
7
- constructor(onRequest: (client: any, fn: string, args?: any[], timeout?: number) => Promise<any>, logger: BaseLogger);
8
- snapshot(): Promise<ArrayBuffer | undefined>;
9
- private _onRequest;
10
- }
@@ -1,11 +0,0 @@
1
- import { CameraPrebufferDelegate } from '../types.js';
2
- import type { BaseLogger, Container, PrebufferState, StreamInfo } from '../types.js';
3
- export declare class CameraPrebufferInterface extends CameraPrebufferDelegate {
4
- delegate?: CameraPrebufferDelegate;
5
- private onRequest;
6
- private logger;
7
- constructor(onRequest: (client: any, fn: string, args?: any[], timeout?: number) => Promise<any>, logger: BaseLogger);
8
- getStreamInfo(sourceName: string): Promise<StreamInfo | undefined>;
9
- updatePrebufferState(sourceId: string, container: Container, state: PrebufferState): Promise<void>;
10
- private _onRequest;
11
- }
@@ -1,54 +0,0 @@
1
- import { ReplaySubject, Subject } from 'rxjs';
2
- import { MediaStreamTrack } from 'werift';
3
- import { Subscribed } from '../../utils/subscribed.js';
4
- import type { Observable } from 'rxjs';
5
- import type { ConnectionState, RTCIceCandidate, RTCSessionDescription, RtcpPacket, RtpPacket, RTCIceCandidate as WeriftRTCICECandidate } from 'werift';
6
- import type { IceServer } from '../../services/config/types.js';
7
- import type { CameraDevice } from '../device.js';
8
- import type { BaseLogger } from '../types.js';
9
- export interface BasicPeerConnection {
10
- createOffer(): Promise<RTCSessionDescription>;
11
- acceptAnswer(answer: {
12
- type: 'answer';
13
- sdp: string;
14
- }): Promise<void>;
15
- addIceCandidate(candidate: Partial<WeriftRTCICECandidate>): Promise<void>;
16
- onIceCandidate: Subject<WeriftRTCICECandidate>;
17
- onConnectionState: Observable<ConnectionState>;
18
- close(): void;
19
- requestKeyFrame?: () => void;
20
- }
21
- export type PeerConnectionAudioCodecs = 'opus' | 'g722' | 'pcmu' | 'pcma';
22
- export type PeerConnectionVideoCodecs = 'vp8' | 'vp9' | 'h264' | 'av1';
23
- export interface StreamingConnectionOptions {
24
- createPeerConnection?: () => BasicPeerConnection;
25
- iceServers?: IceServer[];
26
- preferredAudioCodecs?: PeerConnectionAudioCodecs[];
27
- preferredVideoCodecs?: PeerConnectionVideoCodecs[];
28
- }
29
- export declare class WeriftPeerConnection extends Subscribed implements BasicPeerConnection {
30
- onAudioRtp: Subject<RtpPacket>;
31
- onAudioRtcp: Subject<RtcpPacket>;
32
- onVideoRtp: Subject<RtpPacket>;
33
- onVideoRtcp: Subject<RtcpPacket>;
34
- onIceCandidate: Subject<RTCIceCandidate>;
35
- onConnectionState: ReplaySubject<"connected" | "disconnected" | "closed" | "failed" | "new" | "connecting">;
36
- returnAudioTrack: MediaStreamTrack;
37
- private onRequestKeyFrame;
38
- private cameraDevice;
39
- private sourceName;
40
- private logger;
41
- private options;
42
- private pc;
43
- private get logPrefix();
44
- constructor(cameraDevice: CameraDevice, options: StreamingConnectionOptions, logger: BaseLogger, sourceName: string);
45
- createOffer(): Promise<RTCSessionDescription>;
46
- acceptAnswer(answer: {
47
- type: 'answer';
48
- sdp: string;
49
- }): Promise<void>;
50
- addIceCandidate(candidate: RTCIceCandidate): Promise<void>;
51
- requestKeyFrame(): void;
52
- close(): void;
53
- private createPeerCoonection;
54
- }