@camera.ui/browser 0.0.6 → 0.0.32

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 (50) hide show
  1. package/dist/bundle.js +1 -0
  2. package/dist/client/node/src/client.d.ts +0 -1
  3. package/dist/client/node/src/proxy/cameraDevice/cameraDevice.browser.d.ts +19 -9
  4. package/dist/client/node/src/proxy/cameraDevice/cameraDevice.node.d.ts +4 -2
  5. package/dist/client/node/src/proxy/cameraDevice/index.d.ts +0 -4
  6. package/dist/client/node/src/proxy/deviceManager.d.ts +1 -2
  7. package/dist/client/node/src/socket.d.ts +5 -1
  8. package/dist/client/node/src/types.d.ts +5 -3
  9. package/dist/shared/types/index.d.ts +2 -2
  10. package/dist/src/api/database/types.d.ts +20 -5
  11. package/dist/src/api/go2rtc/api/application.d.ts +2 -2
  12. package/dist/src/api/go2rtc/api/snapshot.d.ts +3 -2
  13. package/dist/src/api/go2rtc/api/streams.d.ts +6 -5
  14. package/dist/src/api/go2rtc/types.d.ts +14 -0
  15. package/dist/src/api/schemas/cameras.schema.d.ts +25 -29
  16. package/dist/src/api/schemas/config.schema.d.ts +2 -2
  17. package/dist/src/api/services/cameras.service.d.ts +4 -1
  18. package/dist/src/api/utils/constants.d.ts +15 -0
  19. package/dist/src/api.d.ts +4 -4
  20. package/dist/src/camera/index.d.ts +25 -13
  21. package/dist/src/camera/streaming/peer-connection.d.ts +6 -5
  22. package/dist/src/camera/streaming/streaming-session.d.ts +5 -6
  23. package/dist/src/camera/streaming/webrtc-connection.d.ts +7 -8
  24. package/dist/src/camera/types.d.ts +28 -8
  25. package/dist/src/plugins/base.d.ts +1 -1
  26. package/dist/src/plugins/index.d.ts +7 -2
  27. package/dist/src/plugins/plugin.d.ts +5 -2
  28. package/dist/src/plugins/types.d.ts +5 -1
  29. package/dist/src/plugins/worker.d.ts +1 -0
  30. package/dist/src/proxy/client/cameraDevice.d.ts +9 -14
  31. package/dist/src/proxy/client/deviceManager.d.ts +4 -12
  32. package/dist/src/proxy/client/pluginsManager.d.ts +3 -11
  33. package/dist/src/proxy/client/queue.d.ts +11 -0
  34. package/dist/src/proxy/client/systemManager.d.ts +3 -11
  35. package/dist/src/proxy/constants.d.ts +7 -0
  36. package/dist/src/proxy/index.d.ts +12 -6
  37. package/dist/src/proxy/proxies/camera.d.ts +40 -9
  38. package/dist/src/proxy/proxies/plugin.d.ts +3 -23
  39. package/dist/src/proxy/proxies/server.d.ts +6 -6
  40. package/dist/src/proxy/queue.d.ts +15 -0
  41. package/dist/src/proxy/types.d.ts +67 -6
  42. package/dist/src/proxy/ws/index.d.ts +0 -9
  43. package/dist/src/services/config/constants.d.ts +6 -0
  44. package/dist/src/services/config/index.d.ts +1 -1
  45. package/dist/src/services/logger/index.d.ts +2 -0
  46. package/package.json +8 -7
  47. package/webpack.config.ts +43 -0
  48. package/dist/bundle.browser.js +0 -1
  49. package/dist/src/api/utils/cert.d.ts +0 -17
  50. /package/dist/src/plugins/{storage.d.ts → storageController.d.ts} +0 -0
@@ -1,17 +1,34 @@
1
1
  /// <reference types="node" />
2
- import type { Camera } from '../api/database/types';
2
+ import type { Camera, CameraInput } from '../api/database/types';
3
3
  import type { BasePlugin, CameraStorage } from '../plugins/types';
4
- import type { CameraConfig, OnSetEvent, StateValues, CameraDevice } from '../camera/types';
4
+ import type { CameraConfig, OnSetEvent, StateValues, CameraDevice, FfmpegOptions, PrebufferType } from '../camera/types';
5
+ import type { IceServer } from '../services/config/types';
5
6
  export type MethodKeys<T> = {
6
7
  [K in keyof T]: T[K] extends Function ? K : never;
7
8
  }[keyof T];
9
+ export interface ClientQueueItem {
10
+ requestId: string;
11
+ message: any;
12
+ resolve: (response: any) => void;
13
+ reject: (error: Error) => void;
14
+ timeout: number;
15
+ }
16
+ export interface QueueItem {
17
+ requestType: 'router' | 'request';
18
+ targetId: string;
19
+ requestId: string;
20
+ message: any;
21
+ timeout?: number;
22
+ onResponse?: (response: any) => void;
23
+ onError?: (error: Error) => void;
24
+ }
8
25
  export interface RequestPayload {
9
26
  fn: string;
10
27
  data: Record<string, any>;
11
28
  requestId: string;
12
29
  }
13
30
  export interface QueueRequestItem {
14
- payload: RequestPayload;
31
+ payload: CameraDeviceProxyMessageStructure | ProxyMessageStructure;
15
32
  resolve: (value: any) => void;
16
33
  reject: (reason?: any) => void;
17
34
  timeout: NodeJS.Timeout;
@@ -40,7 +57,7 @@ export type CameraId = string;
40
57
  export type PluginId = string;
41
58
  export type TargetID = CameraId | PluginId | 'all';
42
59
  export interface PendingMessagePayload {
43
- replyTo: string;
60
+ requestId: string;
44
61
  response?: any;
45
62
  }
46
63
  export interface ListenerMessagePayload {
@@ -82,7 +99,9 @@ export interface ApiProxyMethods {
82
99
  pluginId: string;
83
100
  }): Promise<void>;
84
101
  }
85
- export interface SystemProxyMethods {
102
+ export interface WsManagerClientMessage {
103
+ method: ProxyMethodNames;
104
+ args: any[];
86
105
  }
87
106
  export interface DeviceManagerListenerMessagePayload {
88
107
  type: keyof DeviceManagerProxyEventCallbacks;
@@ -170,14 +189,52 @@ export interface CameraDeviceProxyMessageStructure {
170
189
  timestamp: number;
171
190
  }
172
191
  export interface CameraDeviceProxyMethods {
192
+ snapshot(data: {
193
+ sourceName: string;
194
+ cameraId: string;
195
+ pluginId: string;
196
+ }): Promise<ArrayBuffer>;
197
+ setPrebufferSource(data: {
198
+ sourceName: string;
199
+ address: string | null;
200
+ type: PrebufferType;
201
+ cameraId: string;
202
+ pluginId: string;
203
+ }): Promise<void>;
204
+ getFffmpegPath(data: {
205
+ cameraId: string;
206
+ pluginId: string;
207
+ }): string;
208
+ getIceServers(data: {
209
+ cameraId: string;
210
+ pluginId: string;
211
+ }): IceServer[];
173
212
  updateState<T extends keyof StateValues>(data: {
174
213
  stateName: T;
175
214
  eventData: OnSetEvent<T>;
176
215
  cameraId: string;
216
+ pluginId: string;
177
217
  }): void;
178
218
  refreshStates(data: {
179
219
  cameraId: string;
180
- }): StateValues | undefined;
220
+ pluginId: string;
221
+ }): {
222
+ sources: CameraInput[];
223
+ states: StateValues;
224
+ } | undefined;
225
+ streamVideo(data: {
226
+ sourceName: string;
227
+ options: FfmpegOptions;
228
+ cameraId: string;
229
+ pluginId: string;
230
+ }): Promise<void>;
231
+ recordToFile(data: {
232
+ sourceName: string;
233
+ outputPath: string;
234
+ duration?: number;
235
+ cameraId: string;
236
+ pluginId: string;
237
+ }): Promise<void>;
181
238
  }
182
239
  export type CameraDeviceProxyMethodNames = MethodKeys<CameraDeviceProxyMethods>;
183
240
  export type CameraDeviceProxyEventCallbacks = {
@@ -187,3 +244,7 @@ export interface CameraDeviceProxyGenericEvent<K extends keyof StateValues> {
187
244
  type: K;
188
245
  data: StateValues[K];
189
246
  }
247
+ export interface WsCameraDeviceClientMessage {
248
+ method: CameraDeviceProxyMethodNames;
249
+ args: any[];
250
+ }
@@ -1,14 +1,5 @@
1
1
  import type { Server, Namespace } from 'socket.io';
2
2
  import type { SocketNsp } from '../../api/ws/types';
3
- import type { ProxyMethodNames, CameraDeviceProxyMethodNames } from '../types';
4
- export interface ManagerClientMessage {
5
- method: ProxyMethodNames;
6
- args: any[];
7
- }
8
- export interface CameraDeviceClientMessage {
9
- method: CameraDeviceProxyMethodNames;
10
- args: any[];
11
- }
12
3
  export declare class ProxyBridge {
13
4
  nsp: Namespace;
14
5
  nspName: SocketNsp;
@@ -0,0 +1,6 @@
1
+ import type { RTCIceServer } from 'werift';
2
+ import type { IceServer, IConfig, Go2RtcConfig } from './types';
3
+ export declare const DEFAULT_ICE_SERVERS: IceServer[];
4
+ export declare const DEFAULT_WERIFT_ICE_SERVERS: RTCIceServer[];
5
+ export declare const DEFAULT_CONFIG: IConfig;
6
+ export declare const DEFAULT_GO2RTC_CONFIG: Go2RtcConfig;
@@ -48,7 +48,7 @@ export declare class ConfigService {
48
48
  read(): void;
49
49
  writeConfig(newConfig?: IConfig): void;
50
50
  writeGo2RtcConfig(newConfig?: Go2RtcConfig): void;
51
- mergeGo2RtcConfig: () => Promise<void>;
51
+ mergeGo2RtcConfig(): Promise<void>;
52
52
  private defaultConfig;
53
53
  private defaultGo2RtcConfig;
54
54
  private readConfig;
@@ -10,6 +10,7 @@ export declare class PluginLogger {
10
10
  log(...args: any[]): void;
11
11
  error(...args: any[]): void;
12
12
  warn(...args: any[]): void;
13
+ attention(...args: any[]): void;
13
14
  debug(...args: any[]): void;
14
15
  }
15
16
  export declare class Logger {
@@ -29,6 +30,7 @@ export declare class Logger {
29
30
  log(...args: any[]): void;
30
31
  error(...args: any[]): void;
31
32
  warn(...args: any[]): void;
33
+ attention(...args: any[]): void;
32
34
  debug(...args: any[]): void;
33
35
  verbose(...args: any[]): void;
34
36
  notify(title: string, text: string, type: LoggingLevel, link: string, socket?: Socket): Promise<void>;
package/package.json CHANGED
@@ -1,27 +1,28 @@
1
1
  {
2
2
  "name": "@camera.ui/browser",
3
- "version": "0.0.6",
3
+ "version": "0.0.32",
4
4
  "description": "camera.ui browser client",
5
5
  "author": "seydx (https://github.com/seydx/camera.ui)",
6
- "main": "./dist/bundle.browser.js",
7
- "module": "./dist/bundle.browser.js",
6
+ "main": "./dist/bundle.js",
7
+ "module": "./dist/bundle.js",
8
8
  "types": "./dist/client/node/src/index.d.ts",
9
+ "type": "commonjs",
9
10
  "exports": {
10
11
  ".": {
11
- "default": "./dist/bundle.browser.js",
12
- "import": "./dist/bundle.browser.js",
12
+ "default": "./dist/bundle.js",
13
+ "import": "./dist/bundle.js",
13
14
  "types": "./dist/client/node/src/index.d.ts"
14
15
  }
15
16
  },
16
17
  "scripts": {
17
- "build": "rimraf dist && tsc && webpack --config webpack.config.js --env browser",
18
+ "build": "rimraf dist && tsc && webpack --config webpack.config.ts",
18
19
  "update": "updates --update ./",
19
20
  "install-updates": "npm i --save",
20
21
  "prepublishOnly": "npm run build"
21
22
  },
22
23
  "dependencies": {
23
24
  "rxjs": "^7.8.1",
24
- "socket.io-client": "^4.7.3"
25
+ "socket.io-client": "^4.7.4"
25
26
  },
26
27
  "devDependencies": {
27
28
  "bufferutil": "^4.0.8",
@@ -0,0 +1,43 @@
1
+ import path from 'path';
2
+ import webpack, { type Configuration } from 'webpack';
3
+
4
+ const webpackConfiguration: Configuration = {
5
+ mode: 'production',
6
+ entry: '../node/src/index.ts',
7
+ output: {
8
+ path: path.resolve(__dirname, 'dist'),
9
+ filename: 'bundle.js',
10
+ library: {
11
+ name: 'CameraUiClient',
12
+ type: 'umd',
13
+ },
14
+ },
15
+ performance: {
16
+ hints: false,
17
+ maxEntrypointSize: 512000,
18
+ maxAssetSize: 512000,
19
+ },
20
+ optimization: {
21
+ splitChunks: {
22
+ minSize: 10000,
23
+ maxSize: 250000,
24
+ },
25
+ },
26
+ devtool: false,
27
+ resolve: {
28
+ extensions: ['.ts', '.js'],
29
+ },
30
+ target: 'web',
31
+ module: {
32
+ rules: [
33
+ {
34
+ test: /\.ts$/,
35
+ use: 'ts-loader',
36
+ exclude: /node_modules/,
37
+ },
38
+ ],
39
+ },
40
+ plugins: [new webpack.NormalModuleReplacementPlugin(/cameraDevice\.node/, path.resolve(__dirname, '../node/src/proxy/cameraDevice/cameraDevice.mock.ts'))],
41
+ };
42
+
43
+ export default webpackConfiguration;