@camera.ui/browser 0.0.68 → 0.0.70
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.
- package/dist/bundle.js +1 -1
- package/dist/types/packages/client/browser/src/client.d.ts +2 -2
- package/dist/types/packages/client/browser/src/index.d.ts +2 -2
- package/dist/types/packages/client/browser/src/proxy/cameraDevice.d.ts +4 -5
- package/dist/types/packages/client/browser/src/proxy/deviceManager.d.ts +3 -3
- package/dist/types/packages/client/browser/src/proxy/index.d.ts +4 -4
- package/dist/types/packages/client/browser/src/proxy/pluginsManager.d.ts +2 -2
- package/dist/types/packages/client/browser/src/proxy/systemManager.d.ts +2 -2
- package/dist/types/packages/client/browser/src/socket.d.ts +1 -1
- package/dist/types/packages/client/browser/src/types.d.ts +3 -3
- package/dist/types/server/bin/python.d.ts +43 -0
- package/dist/types/server/src/api/database/index.d.ts +24 -0
- package/dist/types/server/src/api/database/types.d.ts +13 -35
- package/dist/types/server/src/api/go2rtc/api/application.d.ts +9 -0
- package/dist/types/server/src/api/go2rtc/api/config.d.ts +9 -0
- package/dist/types/server/src/api/go2rtc/api/index.d.ts +2 -0
- package/dist/types/server/src/api/go2rtc/api/snapshot.d.ts +8 -0
- package/dist/types/server/src/api/go2rtc/api/streams.d.ts +11 -0
- package/dist/types/server/src/api/go2rtc/index.d.ts +13 -0
- package/dist/types/server/src/api/go2rtc/queue.d.ts +10 -0
- package/dist/types/server/src/api/middlewares/socketAuth.middleware.d.ts +41 -0
- package/dist/types/server/src/api/schemas/backup.schema.d.ts +2 -2
- package/dist/types/server/src/api/schemas/cameras.schema.d.ts +1 -1
- package/dist/types/server/src/api/schemas/config.schema.d.ts +1 -1
- package/dist/types/server/src/api/schemas/go2rtc.schema.d.ts +1 -1
- package/dist/types/server/src/api/schemas/users.schema.d.ts +2 -2
- package/dist/types/server/src/api/services/auth.service.d.ts +20 -0
- package/dist/types/server/src/api/services/cameras.service.d.ts +54 -0
- package/dist/types/server/src/api/services/plugins.service.d.ts +25 -0
- package/dist/types/server/src/api/services/users.service.d.ts +13 -0
- package/dist/types/server/src/api/types/index.d.ts +12 -12
- package/dist/types/server/src/api/utils/constants.d.ts +15 -0
- package/dist/types/server/src/api/websocket/index.d.ts +15 -0
- package/dist/types/server/src/api/websocket/nsp/frame.d.ts +10 -0
- package/dist/types/server/src/api/websocket/nsp/logs.d.ts +11 -0
- package/dist/types/server/src/api/websocket/nsp/metrics.d.ts +33 -0
- package/dist/types/server/src/api/websocket/nsp/notifications.d.ts +11 -0
- package/dist/types/server/src/api/websocket/nsp/plugins.d.ts +13 -0
- package/dist/types/server/src/api/websocket/nsp/server.d.ts +9 -0
- package/dist/types/server/src/api/websocket/nsp/status.d.ts +20 -0
- package/dist/types/server/src/api/websocket/nsp/streams.d.ts +15 -0
- package/dist/types/server/src/api/{ws → websocket}/types.d.ts +3 -3
- package/dist/types/server/src/api.d.ts +44 -0
- package/dist/types/server/src/camera/base/cameraDevice.d.ts +6 -5
- package/dist/types/server/src/camera/base/cameraDeviceBrowser.d.ts +3 -2
- package/dist/types/server/src/camera/base/index.d.ts +18 -3
- package/dist/types/server/src/camera/controller.d.ts +27 -0
- package/dist/types/server/src/camera/streaming/browser/browser-peer-connection.d.ts +4 -4
- package/dist/types/server/src/camera/streaming/browser/browser-streaming-session.d.ts +4 -4
- package/dist/types/server/src/camera/streaming/browser/webrtc-browser-connection.d.ts +5 -5
- package/dist/types/server/src/camera/streaming/peer-connection.d.ts +4 -4
- package/dist/types/server/src/camera/streaming/streaming-session.d.ts +4 -4
- package/dist/types/server/src/camera/streaming/webrtc-connection.d.ts +5 -5
- package/dist/types/server/src/camera/types.d.ts +29 -22
- package/dist/types/server/src/decoder/index.d.ts +11 -0
- package/dist/types/server/src/decoder/types.d.ts +7 -3
- package/dist/types/server/src/decoder/worker/index.d.ts +3 -0
- package/dist/types/server/src/decoder/worker/runtime/base/index.d.ts +36 -0
- package/dist/types/server/src/decoder/worker/runtime/child-process/index.d.ts +17 -0
- package/dist/types/server/src/decoder/worker/runtime/worker-thread/index.d.ts +22 -0
- package/dist/types/server/src/go2rtc/index.d.ts +25 -0
- package/dist/types/server/src/nats/constants.d.ts +1 -0
- package/dist/types/server/src/nats/index.d.ts +34 -0
- package/dist/types/server/src/nats/proxy/cameraDevice.d.ts +96 -0
- package/dist/types/server/src/nats/proxy/deviceManager.d.ts +31 -0
- package/dist/types/server/src/nats/proxy/index.d.ts +4 -0
- package/dist/types/server/src/nats/proxy/pluginsManager.d.ts +12 -0
- package/dist/types/server/src/nats/proxy/systemManager.d.ts +8 -0
- package/dist/types/server/src/nats/queue.d.ts +17 -0
- package/dist/types/server/src/nats/server.d.ts +33 -0
- package/dist/types/server/src/nats/types.d.ts +21 -13
- package/dist/types/server/src/nats/utils.d.ts +4 -0
- package/dist/types/server/src/nats/websocket.d.ts +22 -0
- package/dist/types/server/src/plugins/base.d.ts +7 -0
- package/dist/types/server/src/plugins/index.d.ts +29 -0
- package/dist/types/server/src/plugins/node/api.d.ts +42 -0
- package/dist/types/server/src/plugins/node/cameraStorage.d.ts +108 -0
- package/dist/types/server/src/plugins/node/config.d.ts +104 -0
- package/dist/types/server/src/plugins/node/logger.d.ts +14 -0
- package/dist/types/server/src/plugins/node/proxy/cameraDevice.d.ts +44 -0
- package/dist/types/server/src/plugins/node/proxy/deviceManager.d.ts +47 -0
- package/dist/types/server/src/plugins/node/proxy/index.d.ts +4 -0
- package/dist/types/server/src/plugins/node/proxy/pluginsManager.d.ts +38 -0
- package/dist/types/server/src/plugins/node/proxy/queue.d.ts +18 -0
- package/dist/types/server/src/plugins/node/proxy/systemManager.d.ts +36 -0
- package/dist/types/server/src/plugins/node/schema.d.ts +268 -0
- package/dist/types/server/src/plugins/node/storageController.d.ts +28 -0
- package/dist/types/server/src/plugins/plugin.d.ts +42 -0
- package/dist/types/server/src/plugins/types.d.ts +3 -3
- package/dist/types/server/src/plugins/worker-ipc.d.ts +22 -0
- package/dist/types/server/src/plugins/worker.d.ts +30 -0
- package/dist/types/server/src/services/config/constants.d.ts +6 -0
- package/dist/types/server/src/services/config/index.d.ts +60 -0
- package/dist/types/server/src/services/logger/index.d.ts +28 -0
- package/dist/types/server/src/utils/index.d.ts +6 -0
- package/dist/types/shared/types/index.d.ts +12 -12
- package/package.json +6 -5
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type { Camera } from '../../api/database/types.js';
|
|
3
|
+
import type { CameraDelegate, CameraPrebufferDelegate, FfmpegOptions, OnSetEvent, PrebufferType, StateValues, StreamInfo } from '../../camera/types.js';
|
|
4
|
+
import type { FrameMetadata, FrameSession } from '../../decoder/types.js';
|
|
5
|
+
import type { IceServer } from '../../services/config/types.js';
|
|
6
|
+
import type { MessageQueue } from '../queue.js';
|
|
7
|
+
import type { CameraDeviceProxyMethods, ProxyMessageStructure } from '../types.js';
|
|
8
|
+
export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
|
|
9
|
+
private api;
|
|
10
|
+
private configService;
|
|
11
|
+
private camerasService;
|
|
12
|
+
private pluginsService;
|
|
13
|
+
private socketService;
|
|
14
|
+
private messageQueue;
|
|
15
|
+
constructor(messageQueue: MessageQueue);
|
|
16
|
+
connect(data: {
|
|
17
|
+
cameraId: string;
|
|
18
|
+
pluginId: string;
|
|
19
|
+
}): void;
|
|
20
|
+
disconnect(data: {
|
|
21
|
+
cameraId: string;
|
|
22
|
+
pluginId: string;
|
|
23
|
+
}): void;
|
|
24
|
+
reboot(data: {
|
|
25
|
+
cameraId: string;
|
|
26
|
+
pluginId: string;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
getStreamInfo(data: {
|
|
29
|
+
sourceName: string;
|
|
30
|
+
cameraId: string;
|
|
31
|
+
pluginId: string;
|
|
32
|
+
}): Promise<StreamInfo | undefined>;
|
|
33
|
+
isPrebuffering(data: {
|
|
34
|
+
sourceName: string;
|
|
35
|
+
type: PrebufferType;
|
|
36
|
+
cameraId: string;
|
|
37
|
+
pluginId: string;
|
|
38
|
+
}): Promise<boolean>;
|
|
39
|
+
getPrebufferRawUrl(data: {
|
|
40
|
+
sourceName: string;
|
|
41
|
+
type: PrebufferType;
|
|
42
|
+
cameraId: string;
|
|
43
|
+
pluginId: string;
|
|
44
|
+
}): Promise<string | undefined>;
|
|
45
|
+
getFrameMetadata(data: {
|
|
46
|
+
cameraId: string;
|
|
47
|
+
pluginId: string;
|
|
48
|
+
}): Promise<FrameMetadata>;
|
|
49
|
+
getFrameSession(data: {
|
|
50
|
+
cameraId: string;
|
|
51
|
+
pluginId: string;
|
|
52
|
+
}): Promise<FrameSession>;
|
|
53
|
+
getFfmpegPath(): string;
|
|
54
|
+
getIceServers(): IceServer[];
|
|
55
|
+
snapshot(data: {
|
|
56
|
+
forceNew?: boolean;
|
|
57
|
+
cameraId: string;
|
|
58
|
+
pluginId: string;
|
|
59
|
+
}): Promise<ArrayBuffer>;
|
|
60
|
+
streamVideo(data: {
|
|
61
|
+
sourceName: string;
|
|
62
|
+
options: FfmpegOptions;
|
|
63
|
+
cameraId: string;
|
|
64
|
+
pluginId: string;
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
recordToFile(data: {
|
|
67
|
+
sourceName: string;
|
|
68
|
+
outputPath: string;
|
|
69
|
+
duration?: number;
|
|
70
|
+
cameraId: string;
|
|
71
|
+
pluginId: string;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
updateState<T extends keyof StateValues>(data: {
|
|
74
|
+
stateName: T;
|
|
75
|
+
eventData: OnSetEvent<T>;
|
|
76
|
+
cameraId: string;
|
|
77
|
+
pluginId: string;
|
|
78
|
+
}): Promise<void>;
|
|
79
|
+
refreshStates(data: {
|
|
80
|
+
cameraId: string;
|
|
81
|
+
pluginId: string;
|
|
82
|
+
}): {
|
|
83
|
+
camera: Camera;
|
|
84
|
+
states: StateValues;
|
|
85
|
+
cameraState: boolean;
|
|
86
|
+
};
|
|
87
|
+
onRequestReboot(pluginId: string, cameraId: string, ...args: Parameters<CameraDelegate['reboot']>): Promise<Buffer>;
|
|
88
|
+
onRequestGetStreamInfo(pluginId: string, cameraId: string, ...args: Parameters<CameraPrebufferDelegate['getStreamInfo']>): Promise<StreamInfo | undefined>;
|
|
89
|
+
onRequestIsPrebuffering(pluginId: string, cameraId: string, ...args: Parameters<CameraPrebufferDelegate['isPrebuffering']>): Promise<boolean>;
|
|
90
|
+
onRequestGetRawUrl(pluginId: string, cameraId: string, ...args: Parameters<CameraPrebufferDelegate['getPrebufferRawUrl']>): Promise<string | undefined>;
|
|
91
|
+
onRequestSnapshotRequest(pluginId: string, cameraId: string, ...args: Parameters<CameraDelegate['snapshotRequest']>): Promise<Buffer>;
|
|
92
|
+
onRequestPrepareStream(pluginId: string, cameraId: string, ...args: Parameters<CameraDelegate['prepareStream']>): Promise<void>;
|
|
93
|
+
onRequestWebRTCOffer(pluginId: string, cameraId: string, ...args: Parameters<CameraDelegate['onOffer']>): Promise<string>;
|
|
94
|
+
onRequestWebRTCIceCandidates(pluginId: string, cameraId: string, ...args: Parameters<CameraDelegate['onCandidates']>): Promise<void>;
|
|
95
|
+
handleMessage(message: ProxyMessageStructure): Promise<void>;
|
|
96
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Camera } from '../../api/database/types.js';
|
|
2
|
+
import type { CameraConfig } from '../../camera/types.js';
|
|
3
|
+
import type { MessageQueue } from '../queue.js';
|
|
4
|
+
import type { DeviceManagerServerProxyMethods, ProxyMessageStructure } from '../types.js';
|
|
5
|
+
export declare class DeviceManagerProxy implements DeviceManagerServerProxyMethods {
|
|
6
|
+
private camerasService;
|
|
7
|
+
private pluginsService;
|
|
8
|
+
private messageQueue;
|
|
9
|
+
constructor(messageQueue: MessageQueue);
|
|
10
|
+
getCameraByName(data: {
|
|
11
|
+
name: string;
|
|
12
|
+
pluginId: string;
|
|
13
|
+
}): Camera | undefined;
|
|
14
|
+
getCameraById(data: {
|
|
15
|
+
id: string;
|
|
16
|
+
pluginId: string;
|
|
17
|
+
}): Camera | void;
|
|
18
|
+
createCamera(data: {
|
|
19
|
+
camera: CameraConfig;
|
|
20
|
+
pluginId: string;
|
|
21
|
+
}): Promise<Camera>;
|
|
22
|
+
removeCameraByName(data: {
|
|
23
|
+
name: string;
|
|
24
|
+
pluginId: string;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
removeCameraById(data: {
|
|
27
|
+
id: string;
|
|
28
|
+
pluginId: string;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
handleMessage(message: ProxyMessageStructure): Promise<void>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BasePlugin } from '../../plugins/base.js';
|
|
2
|
+
import type { CameraStorage } from '../../plugins/node/cameraStorage.js';
|
|
3
|
+
import type { MessageQueue } from '../queue.js';
|
|
4
|
+
import type { CallablePluginMethods, CallablePluginStorageMethods, PluginsManagerServerProxyMethods, ProxyMessageStructure } from '../types.js';
|
|
5
|
+
export declare class PluginsManagerProxy implements PluginsManagerServerProxyMethods {
|
|
6
|
+
private pluginsService;
|
|
7
|
+
private messageQueue;
|
|
8
|
+
constructor(messageQueue: MessageQueue);
|
|
9
|
+
onRequestPluginFn<K extends keyof CallablePluginMethods>(pluginId: string, fn: K, ...args: Parameters<BasePlugin[K]>): Promise<ReturnType<BasePlugin[K]>>;
|
|
10
|
+
onRequestStorageFn<K extends keyof CallablePluginStorageMethods>(pluginId: string, cameraId: string, fn: K, ...args: Parameters<CameraStorage[K]>): Promise<Awaited<ReturnType<CameraStorage[K]>>>;
|
|
11
|
+
handleMessage(message: ProxyMessageStructure): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MessageQueue } from '../queue.js';
|
|
2
|
+
import type { ProxyMessageStructure, SystemManagerServerProxyMethods } from '../types.js';
|
|
3
|
+
export declare class SystemManagerProxy implements SystemManagerServerProxyMethods {
|
|
4
|
+
private pluginsService;
|
|
5
|
+
private messageQueue;
|
|
6
|
+
constructor(messageQueue: MessageQueue);
|
|
7
|
+
handleMessage(message: ProxyMessageStructure): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ProxyServer } from './index.js';
|
|
2
|
+
import type { ProxyMessageStructure } from './types.js';
|
|
3
|
+
export declare class MessageQueue {
|
|
4
|
+
private logger;
|
|
5
|
+
private proxyServer;
|
|
6
|
+
private publisher;
|
|
7
|
+
private subscriber;
|
|
8
|
+
private aborted;
|
|
9
|
+
private isProcessing;
|
|
10
|
+
private queue;
|
|
11
|
+
private pendingResponses;
|
|
12
|
+
constructor(proxyServer: ProxyServer);
|
|
13
|
+
abortQueue(): void;
|
|
14
|
+
enqueue(message: ProxyMessageStructure): Promise<any>;
|
|
15
|
+
private processQueue;
|
|
16
|
+
private listenToMessages;
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { RUNTIME_STATUS } from '../services/config/types.js';
|
|
2
|
+
import type { ProxyAuth } from './types.js';
|
|
3
|
+
export declare class NatsServer {
|
|
4
|
+
readonly serverPort = 4222;
|
|
5
|
+
readonly websocketPort = 8223;
|
|
6
|
+
private readonly clusterAmount;
|
|
7
|
+
private readonly serverClusterPort;
|
|
8
|
+
private readonly auth;
|
|
9
|
+
private serverProcess?;
|
|
10
|
+
private clusterProcesses;
|
|
11
|
+
private logger;
|
|
12
|
+
private configService;
|
|
13
|
+
private tmpDir;
|
|
14
|
+
private manuallyKilled;
|
|
15
|
+
private shuttingDown;
|
|
16
|
+
private _status;
|
|
17
|
+
get status(): RUNTIME_STATUS;
|
|
18
|
+
constructor(auth: ProxyAuth);
|
|
19
|
+
start(): Promise<void>;
|
|
20
|
+
private startServer;
|
|
21
|
+
private startClusterServer;
|
|
22
|
+
private setupProcess;
|
|
23
|
+
stop(): Promise<void>;
|
|
24
|
+
restart(): Promise<void>;
|
|
25
|
+
getPID(): number;
|
|
26
|
+
private writeConfigFile;
|
|
27
|
+
private stringifyConfig;
|
|
28
|
+
private kill;
|
|
29
|
+
private handleClose;
|
|
30
|
+
private setStatus;
|
|
31
|
+
private processLogger;
|
|
32
|
+
private isIgnorableString;
|
|
33
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { Camera } from '../api/database/types';
|
|
2
|
-
import type { CameraDevice } from '../camera/base/cameraDevice';
|
|
3
|
-
import type { BrowserCameraDevice } from '../camera/base/cameraDeviceBrowser';
|
|
4
|
-
import type { CameraConfig, FfmpegOptions, OnSetEvent, PrebufferType, StateValues, StreamInfo } from '../camera/types';
|
|
5
|
-
import type { FrameMetadata } from '../decoder/types';
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
1
|
+
import type { Camera } from '../api/database/types.js';
|
|
2
|
+
import type { CameraDevice } from '../camera/base/cameraDevice.js';
|
|
3
|
+
import type { BrowserCameraDevice } from '../camera/base/cameraDeviceBrowser.js';
|
|
4
|
+
import type { CameraConfig, FfmpegOptions, OnSetEvent, PrebufferType, StateValues, StreamInfo } from '../camera/types.js';
|
|
5
|
+
import type { FrameMetadata, FrameSession } from '../decoder/types.js';
|
|
6
|
+
import type { BasePlugin } from '../plugins/base.js';
|
|
7
|
+
import type { CameraStorage } from '../plugins/node/cameraStorage.js';
|
|
8
|
+
import type { CameraExtension } from '../plugins/types.js';
|
|
9
|
+
import type { IceServer } from '../services/config/types.js';
|
|
8
10
|
export type MethodKeys<T> = {
|
|
9
11
|
[K in keyof T]: T[K] extends Function ? K : never;
|
|
10
12
|
}[keyof T];
|
|
@@ -60,11 +62,11 @@ export interface DeviceManagerServerProxyMethods {
|
|
|
60
62
|
getCameraByName(data: {
|
|
61
63
|
name: string;
|
|
62
64
|
pluginId: string;
|
|
63
|
-
}):
|
|
65
|
+
}): Camera | void;
|
|
64
66
|
getCameraById(data: {
|
|
65
67
|
id: string;
|
|
66
68
|
pluginId: string;
|
|
67
|
-
}):
|
|
69
|
+
}): Camera | void;
|
|
68
70
|
removeCameraByName(data: {
|
|
69
71
|
name: string;
|
|
70
72
|
pluginId: string;
|
|
@@ -82,11 +84,11 @@ export interface CameraDeviceProxyMethods {
|
|
|
82
84
|
connect(data: {
|
|
83
85
|
cameraId: string;
|
|
84
86
|
pluginId: string;
|
|
85
|
-
}):
|
|
87
|
+
}): void;
|
|
86
88
|
disconnect(data: {
|
|
87
89
|
cameraId: string;
|
|
88
90
|
pluginId: string;
|
|
89
|
-
}):
|
|
91
|
+
}): void;
|
|
90
92
|
reboot(data: {
|
|
91
93
|
cameraId: string;
|
|
92
94
|
pluginId: string;
|
|
@@ -112,6 +114,10 @@ export interface CameraDeviceProxyMethods {
|
|
|
112
114
|
cameraId: string;
|
|
113
115
|
pluginId: string;
|
|
114
116
|
}): Promise<FrameMetadata>;
|
|
117
|
+
getFrameSession(data: {
|
|
118
|
+
cameraId: string;
|
|
119
|
+
pluginId: string;
|
|
120
|
+
}): Promise<FrameSession>;
|
|
115
121
|
getFfmpegPath(data: {
|
|
116
122
|
cameraId: string;
|
|
117
123
|
pluginId: string;
|
|
@@ -147,11 +153,11 @@ export interface CameraDeviceProxyMethods {
|
|
|
147
153
|
refreshStates(data: {
|
|
148
154
|
cameraId: string;
|
|
149
155
|
pluginId: string;
|
|
150
|
-
}):
|
|
156
|
+
}): {
|
|
151
157
|
camera: Camera;
|
|
152
158
|
states: StateValues;
|
|
153
159
|
cameraState: boolean;
|
|
154
|
-
}
|
|
160
|
+
};
|
|
155
161
|
}
|
|
156
162
|
export type CameraDeviceProxyMethodNames = MethodKeys<CameraDeviceProxyMethods>;
|
|
157
163
|
export interface DeviceManagerListenerMessagePayload {
|
|
@@ -235,6 +241,8 @@ export interface PluginsManagerProxyGenericEvent<K extends keyof PluginsManagerP
|
|
|
235
241
|
type: K;
|
|
236
242
|
data: PluginsManagerProxyEvents[K];
|
|
237
243
|
}
|
|
244
|
+
export type CallablePluginStorageMethods = Pick<CameraStorage, 'getConfig' | 'setConfig'>;
|
|
245
|
+
export type CallablePluginMethods = Pick<BasePlugin, 'onFormSubmit'>;
|
|
238
246
|
export interface CameraDeviceListenerStatePayload<K extends keyof StateValues> {
|
|
239
247
|
stateName: K;
|
|
240
248
|
data: {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Namespace, Server } from 'socket.io';
|
|
2
|
+
import type { SocketNsp } from '../api/websocket/types.js';
|
|
3
|
+
import { StateValues } from '../camera/types.js';
|
|
4
|
+
import type { CameraDeviceListenerMessagePayload } from './types.js';
|
|
5
|
+
export declare class WebsocketProxy {
|
|
6
|
+
nsp: Namespace;
|
|
7
|
+
nspName: SocketNsp;
|
|
8
|
+
private proxy;
|
|
9
|
+
constructor(io: Server);
|
|
10
|
+
init(): void;
|
|
11
|
+
publishCameraEvent<K extends keyof StateValues>(cameraId: string, stateName: K, data: {
|
|
12
|
+
newEvent: StateValues[K];
|
|
13
|
+
oldEvent: StateValues[K];
|
|
14
|
+
}): void;
|
|
15
|
+
publishCameraEvent(cameraId: string, type: CameraDeviceListenerMessagePayload['type'], data?: any): void;
|
|
16
|
+
private setupEventListeners;
|
|
17
|
+
private isSystemManagerMethod;
|
|
18
|
+
private isDeviceManagerMethod;
|
|
19
|
+
private isPluginsManagerMethod;
|
|
20
|
+
private isCameraManagerMethod;
|
|
21
|
+
private isCameraState;
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CameraDevice } from '../camera/base/cameraDevice.js';
|
|
2
|
+
export declare abstract class BasePlugin {
|
|
3
|
+
abstract onFormSubmit(actionId: string, payload: any): Promise<{
|
|
4
|
+
toast?: string;
|
|
5
|
+
}>;
|
|
6
|
+
abstract configureCameras(cameras: CameraDevice[]): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Plugin } from './plugin.js';
|
|
3
|
+
import { PluginWorker } from './worker.js';
|
|
4
|
+
import type { IPackageJson } from '../api/types/index.js';
|
|
5
|
+
export declare class PluginManager {
|
|
6
|
+
private logger;
|
|
7
|
+
private api;
|
|
8
|
+
private configService;
|
|
9
|
+
plugins: Map<string, Plugin>;
|
|
10
|
+
pluginWorkers: Map<string, PluginWorker>;
|
|
11
|
+
searchPaths: Set<string>;
|
|
12
|
+
constructor();
|
|
13
|
+
static isQualifiedPluginIdentifier(pluginName: string): boolean;
|
|
14
|
+
static extractPluginScope(pluginName: string): string;
|
|
15
|
+
static extractPluginName(pluginName: string): string;
|
|
16
|
+
static transformDisplaName(pluginName: string): string;
|
|
17
|
+
static loadPackageJSON(installPath: string): IPackageJson;
|
|
18
|
+
initializeInstalledPlugins(): Promise<void>;
|
|
19
|
+
initializeInstalledPlugin(plugin: Plugin): Promise<void>;
|
|
20
|
+
loadPlugin(absolutePath: string, pluginId?: string, storagePath?: string): Promise<Plugin>;
|
|
21
|
+
removePlugin(plugin: Plugin, removeFromDb?: boolean, removeStorage?: boolean): Promise<void>;
|
|
22
|
+
startPluginChild(pluginName: string): Promise<void>;
|
|
23
|
+
stopPluginChild(pluginName: string): Promise<void>;
|
|
24
|
+
initializePlugins(): Promise<void>;
|
|
25
|
+
private loadInstalledPlugins;
|
|
26
|
+
private removeOrphanedPlugins;
|
|
27
|
+
private loadDefaultPaths;
|
|
28
|
+
private addNpmPrefixToSearchPaths;
|
|
29
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
import { DeviceManager, PluginsManager, SystemManager } from './proxy/index.js';
|
|
4
|
+
import { StorageController } from './storageController.js';
|
|
5
|
+
import type { BasePlugin } from '../base.js';
|
|
6
|
+
import type { Plugin } from '../plugin.js';
|
|
7
|
+
import type { PluginConfigService } from './config.js';
|
|
8
|
+
import type { PluginLogger } from './logger.js';
|
|
9
|
+
export declare interface API {
|
|
10
|
+
on(event: 'finishLaunching', listener: () => void): this;
|
|
11
|
+
on(event: 'shutdown', listener: () => void): this;
|
|
12
|
+
once(event: 'finishLaunching', listener: () => void): this;
|
|
13
|
+
once(event: 'shutdown', listener: () => void): this;
|
|
14
|
+
off(event: 'finishLaunching', listener: () => void): this;
|
|
15
|
+
off(event: 'shutdown', listener: () => void): this;
|
|
16
|
+
removeListener(event: 'finishLaunching', listener: () => void): this;
|
|
17
|
+
removeListener(event: 'shutdown', listener: () => void): this;
|
|
18
|
+
removeAllListeners(event?: string): this;
|
|
19
|
+
readonly deviceManager: DeviceManager;
|
|
20
|
+
readonly pluginsManager: PluginsManager;
|
|
21
|
+
readonly systemManager: SystemManager;
|
|
22
|
+
readonly storageController: StorageController;
|
|
23
|
+
readonly configService: PluginConfigService;
|
|
24
|
+
readonly storagePath: string;
|
|
25
|
+
readonly configFile: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class PluginAPI extends EventEmitter implements API {
|
|
28
|
+
private initialized;
|
|
29
|
+
readonly deviceManager: DeviceManager;
|
|
30
|
+
readonly pluginsManager: PluginsManager;
|
|
31
|
+
readonly systemManager: SystemManager;
|
|
32
|
+
readonly storageController: StorageController;
|
|
33
|
+
readonly configService: PluginConfigService;
|
|
34
|
+
readonly storagePath: string;
|
|
35
|
+
readonly configFile: string;
|
|
36
|
+
readonly plugin: BasePlugin;
|
|
37
|
+
constructor(plugin: Plugin, logger: PluginLogger, auth: {
|
|
38
|
+
user: string;
|
|
39
|
+
pass: string;
|
|
40
|
+
});
|
|
41
|
+
init(): Promise<void>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { PluginJsonSchema, PluginJsonSchemaForm, SchemaConfig } from '../types.js';
|
|
2
|
+
import type { PluginAPI } from './api.js';
|
|
3
|
+
export declare class CameraStorage {
|
|
4
|
+
private cameraId;
|
|
5
|
+
private instance;
|
|
6
|
+
private api;
|
|
7
|
+
private db;
|
|
8
|
+
private _schema;
|
|
9
|
+
private _values;
|
|
10
|
+
get values(): Record<string, any>;
|
|
11
|
+
constructor(api: PluginAPI, instance: any, cameraId: string, schema?: PluginJsonSchemaForm);
|
|
12
|
+
/**
|
|
13
|
+
* Initialize the storage.
|
|
14
|
+
* This will load the configuration from the database.
|
|
15
|
+
*/
|
|
16
|
+
initializeStorage(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Get a value from the configuration by its key/path.
|
|
19
|
+
* If the schema has an onGet function, the onGet function will be called.
|
|
20
|
+
* If the onGet functions is undefined, the value from the configuration will be returned.
|
|
21
|
+
* If the schema has a default value, and the configuration value is undefined, the default value will be returned.
|
|
22
|
+
*
|
|
23
|
+
* @param path - The path to the configuration value.
|
|
24
|
+
* @returns The value from the configuration.
|
|
25
|
+
*/
|
|
26
|
+
getValue<T = string>(path: string): Promise<T> | undefined;
|
|
27
|
+
getValue<T = string>(path: string, defaultValue: T): Promise<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Set a new value for a given key/path in the configuration.
|
|
30
|
+
* If the schema of the value has an onSet function, and the value has changed, the onSet function will be called.
|
|
31
|
+
* If the schema of the value is declared as storable, the value will be saved to the database.
|
|
32
|
+
*
|
|
33
|
+
* @param path - The path to the configuration value.
|
|
34
|
+
* @param newValue - The new value to set.
|
|
35
|
+
*/
|
|
36
|
+
setValue<T = string>(path: string, newValue: T): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a value exists by its config path/key.
|
|
39
|
+
*
|
|
40
|
+
* @param path - The path to the value to check.
|
|
41
|
+
* @returns True if the value exists, false otherwise.
|
|
42
|
+
*/
|
|
43
|
+
hasValue(path: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get the root schema and configuration.
|
|
46
|
+
* This will also call the onGet functions for the schema.
|
|
47
|
+
*
|
|
48
|
+
* @returns The root schema and configuration.
|
|
49
|
+
*/
|
|
50
|
+
getConfig(): Promise<SchemaConfig>;
|
|
51
|
+
/**
|
|
52
|
+
* Set a new configuration.
|
|
53
|
+
* If the schema of a value which has been changed has an onSet function, the onSet function will be called.
|
|
54
|
+
*
|
|
55
|
+
* @param newConfig - The new configuration to set.
|
|
56
|
+
*/
|
|
57
|
+
setConfig(newConfig: Record<string, any>): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Add a new schema to the existing schema.
|
|
60
|
+
* It will also add the value to the configuration.
|
|
61
|
+
* If the schema is declared as storable, the value will be saved to the database.
|
|
62
|
+
*
|
|
63
|
+
* @param schema - The new schema to add.
|
|
64
|
+
* @param path - The path to the schema to add.
|
|
65
|
+
*/
|
|
66
|
+
addSchema(schema: PluginJsonSchemaForm): Promise<void>;
|
|
67
|
+
addSchema(path: string, schema: PluginJsonSchema): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Remove a schema by its config path/key from the existing schema.
|
|
70
|
+
* It will also remove the value from the configuration.
|
|
71
|
+
* If the schema is declared as storable, the value will be removed from the database.
|
|
72
|
+
*
|
|
73
|
+
* @param path - The path to the schema to remove.
|
|
74
|
+
*/
|
|
75
|
+
removeSchema(path: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Change a schema by its config path/key from the existing schema.
|
|
78
|
+
* It will also change the value from the configuration.
|
|
79
|
+
* If the schema is declared as storable, the value will be saved to the database.
|
|
80
|
+
*
|
|
81
|
+
* @param path - The path to the schema to change.
|
|
82
|
+
* @param schema - The new schema to set.
|
|
83
|
+
*/
|
|
84
|
+
changeSchema(path: string, newSchema: Partial<PluginJsonSchema>): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Get a schema by its config path/key.
|
|
87
|
+
*
|
|
88
|
+
* @param path - The path to the schema to get.
|
|
89
|
+
* @returns The schema.
|
|
90
|
+
*/
|
|
91
|
+
getSchema<T>(path: string): T | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Check if a schema exists by its config path/key.
|
|
94
|
+
*
|
|
95
|
+
* @param path - The path to the schema to check.
|
|
96
|
+
* @returns True if the schema exists, false otherwise.
|
|
97
|
+
*/
|
|
98
|
+
hasSchema(path: string): boolean;
|
|
99
|
+
private resolveOnGetFunctions;
|
|
100
|
+
private resolveOnGetFunctionsForObject;
|
|
101
|
+
private resolveOnGetFunctionsForSchema;
|
|
102
|
+
private triggerOnSetForChanges;
|
|
103
|
+
private filterStorableValues;
|
|
104
|
+
private containsStorableSchema;
|
|
105
|
+
private saveDb;
|
|
106
|
+
private removeDb;
|
|
107
|
+
private close;
|
|
108
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type Path } from 'object-path';
|
|
2
|
+
import type { JSONValue, PluginConfig } from '../types.js';
|
|
3
|
+
export declare class PluginConfigService {
|
|
4
|
+
private config;
|
|
5
|
+
private configFile;
|
|
6
|
+
constructor(configFile: string);
|
|
7
|
+
/**
|
|
8
|
+
* Get key (Path) from config.json
|
|
9
|
+
*
|
|
10
|
+
* @param key - Key to lookup for
|
|
11
|
+
* @param defaultValue - Default value if `key` not exist
|
|
12
|
+
* @param validate - Validate the value of the `key` and replace with `defaultValue` if it is not valid
|
|
13
|
+
* @param refresh - Re-Read config.json before lookup for the `key`
|
|
14
|
+
* @param writeIfNotValid - Optional parameter, if true, the changes will be written to the file, if the value of the `key` is not valid and is replaced by the `defaultValue`
|
|
15
|
+
*
|
|
16
|
+
* @returns `value` for the given `key` or `defaultValue`
|
|
17
|
+
*/
|
|
18
|
+
get(key: Path, defaultValue: JSONValue, validate: Function, refresh?: boolean, writeIfNotValid?: boolean): any;
|
|
19
|
+
get(key: Path, defaultValue?: unknown, validate?: Function, refresh?: boolean, writeIfNotValid?: boolean): any;
|
|
20
|
+
/**
|
|
21
|
+
* Test key (Path) existence
|
|
22
|
+
*
|
|
23
|
+
* @param key - Key to lookup for
|
|
24
|
+
* @param refresh - Re-Read config.json before lookup for the `key`
|
|
25
|
+
*/
|
|
26
|
+
has(key: Path, refresh?: boolean): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Set a value if it doesn't exist, do nothing if it does
|
|
29
|
+
*
|
|
30
|
+
* @param key - Key whose existence is to be checked
|
|
31
|
+
* @param defaultValue - Default value if `key` not exist
|
|
32
|
+
* @param write - Optional parameter, if true, the changes will be written to the file.
|
|
33
|
+
*/
|
|
34
|
+
ensureExists(key: Path, defaultValue: JSONValue, write?: boolean): void;
|
|
35
|
+
/**
|
|
36
|
+
* Set a key (Path) to a value
|
|
37
|
+
*
|
|
38
|
+
* @param key - Key
|
|
39
|
+
* @param value - Value to set for they given `key`
|
|
40
|
+
* @param write - Optional parameter, if true, the changes will be written to the file.
|
|
41
|
+
*/
|
|
42
|
+
set(key: Path, value: any, write?: boolean): void;
|
|
43
|
+
/**
|
|
44
|
+
* Insert an item in an array path
|
|
45
|
+
*
|
|
46
|
+
* @param key - Key to the array
|
|
47
|
+
* @param value - Value to insert in the array
|
|
48
|
+
* @param at - Index
|
|
49
|
+
* @param write - Optional parameter, if true, the changes will be written to the file.
|
|
50
|
+
*/
|
|
51
|
+
insert(key: Path, value: any, at?: number, write?: boolean): void;
|
|
52
|
+
/**
|
|
53
|
+
* Create (if path isn't an array) and push the value to it. Can push unlimited number of values
|
|
54
|
+
*
|
|
55
|
+
* @param key - Key to the array
|
|
56
|
+
* @param write - Optional parameter, if true, the changes will be written to the file.
|
|
57
|
+
* @param items - Values to push in to the array
|
|
58
|
+
*/
|
|
59
|
+
push(key: Path, write?: boolean, ...items: any[]): void;
|
|
60
|
+
/**
|
|
61
|
+
* Deletes a member from object or array
|
|
62
|
+
*
|
|
63
|
+
* @param key - Key to lookup for
|
|
64
|
+
* @param write - Optional parameter, if true, the changes will be written to the file.
|
|
65
|
+
*/
|
|
66
|
+
delete(key: Path, write?: boolean): void;
|
|
67
|
+
/**
|
|
68
|
+
* @param refresh - Re-Read config.json
|
|
69
|
+
*
|
|
70
|
+
* @returns config.json
|
|
71
|
+
*/
|
|
72
|
+
all(refresh?: boolean): PluginConfig;
|
|
73
|
+
/**
|
|
74
|
+
* @param config - New config.json
|
|
75
|
+
* @param write - Optional parameter, if true, the changes will be written to the file.
|
|
76
|
+
*/
|
|
77
|
+
replace(config: PluginConfig, write?: boolean): void;
|
|
78
|
+
/**
|
|
79
|
+
* Updates a specific value in a nested object structure by a given path and key.
|
|
80
|
+
*
|
|
81
|
+
* @param path - The path to the nested object.
|
|
82
|
+
* @param searchKey - The key to search for.
|
|
83
|
+
* @param searchValue - The value to match the searchKey.
|
|
84
|
+
* @param targetKey - The key of the value to be updated.
|
|
85
|
+
* @param newValue - The new value to be set.
|
|
86
|
+
* @param write - Optional parameter, if true, the changes will be written to the file.
|
|
87
|
+
*/
|
|
88
|
+
updateValue(path: string, searchKey: string, searchValue: any, targetKey: string, newValue: any, write?: boolean): void;
|
|
89
|
+
/**
|
|
90
|
+
* Replaces a specific item in a nested object structure by a given path and key.
|
|
91
|
+
* If the item does not exist, it will be added.
|
|
92
|
+
* If the path does not exist, it will be created.
|
|
93
|
+
*
|
|
94
|
+
* @param path - The path to the nested object.
|
|
95
|
+
* @param searchKey - The key to search for.
|
|
96
|
+
* @param searchValue - The value to match the searchKey.
|
|
97
|
+
* @param newItem - The new item to replace the old one. If the item does not exist, it will be added.
|
|
98
|
+
* @param write - Optional parameter, if true, the changes will be written to the file.
|
|
99
|
+
*/
|
|
100
|
+
replaceOrAddItem(path: string, searchKey: string, searchValue: any, newItem: any, write?: boolean): void;
|
|
101
|
+
private init;
|
|
102
|
+
private read;
|
|
103
|
+
private write;
|
|
104
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class PluginLogger {
|
|
2
|
+
private _prefix;
|
|
3
|
+
private _loggerPrefix;
|
|
4
|
+
private _disableTimestamps;
|
|
5
|
+
private get prefix();
|
|
6
|
+
constructor(prefix: string, disableTimestamps: boolean);
|
|
7
|
+
log(...args: any[]): void;
|
|
8
|
+
error(...args: any[]): void;
|
|
9
|
+
warn(...args: any[]): void;
|
|
10
|
+
attention(...args: any[]): void;
|
|
11
|
+
debug(...args: any[]): void;
|
|
12
|
+
trace(...args: any[]): void;
|
|
13
|
+
private formatDateTime;
|
|
14
|
+
}
|