@camera.ui/browser 0.0.111 → 0.0.113

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 (51) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +10 -1
  3. package/dist/index.d.ts +1269 -0
  4. package/dist/index.js +4179 -0
  5. package/package.json +55 -39
  6. package/CHANGELOG.md +0 -8
  7. package/dist/bundle.js +0 -2
  8. package/dist/bundle.js.LICENSE.txt +0 -14
  9. package/dist/types/packages/client/browser/src/api.d.ts +0 -8
  10. package/dist/types/packages/client/browser/src/client.d.ts +0 -21
  11. package/dist/types/packages/client/browser/src/index.d.ts +0 -2
  12. package/dist/types/packages/client/browser/src/proxy/cameraDevice.d.ts +0 -26
  13. package/dist/types/packages/client/browser/src/proxy/coreManager.d.ts +0 -14
  14. package/dist/types/packages/client/browser/src/proxy/deviceManager.d.ts +0 -16
  15. package/dist/types/packages/client/browser/src/proxy/index.d.ts +0 -3
  16. package/dist/types/packages/client/browser/src/proxy.d.ts +0 -7
  17. package/dist/types/packages/client/browser/src/streaming/config.d.ts +0 -21
  18. package/dist/types/packages/client/browser/src/streaming/go2rts-session.d.ts +0 -286
  19. package/dist/types/packages/client/browser/src/streaming/types.d.ts +0 -38
  20. package/dist/types/packages/client/browser/src/types.d.ts +0 -56
  21. package/dist/types/packages/client/browser/src/utils.d.ts +0 -12
  22. package/dist/types/packages/common/src/utils/subscribed.d.ts +0 -18
  23. package/dist/types/packages/types/src/index.d.ts +0 -812
  24. package/dist/types/server/src/api/database/types.d.ts +0 -80
  25. package/dist/types/server/src/api/go2rtc/types.d.ts +0 -147
  26. package/dist/types/server/src/api/schemas/backup.schema.d.ts +0 -211
  27. package/dist/types/server/src/api/schemas/cameras.schema.d.ts +0 -1864
  28. package/dist/types/server/src/api/schemas/config.schema.d.ts +0 -102
  29. package/dist/types/server/src/api/schemas/go2rtc.schema.d.ts +0 -735
  30. package/dist/types/server/src/api/schemas/plugins.schema.d.ts +0 -72
  31. package/dist/types/server/src/api/schemas/storage.schema.d.ts +0 -22
  32. package/dist/types/server/src/api/schemas/system.schema.d.ts +0 -185
  33. package/dist/types/server/src/api/schemas/users.schema.d.ts +0 -857
  34. package/dist/types/server/src/api/types/index.d.ts +0 -612
  35. package/dist/types/server/src/api/websocket/types.d.ts +0 -43
  36. package/dist/types/server/src/camera/classes.d.ts +0 -2
  37. package/dist/types/server/src/camera/index.d.ts +0 -92
  38. package/dist/types/server/src/camera/interfaces.d.ts +0 -17
  39. package/dist/types/server/src/camera/iou.d.ts +0 -2
  40. package/dist/types/server/src/camera/polygon.d.ts +0 -4
  41. package/dist/types/server/src/camera/types.d.ts +0 -17
  42. package/dist/types/server/src/go2rtc/types.d.ts +0 -15
  43. package/dist/types/server/src/manager/types.d.ts +0 -15
  44. package/dist/types/server/src/plugins/schema.d.ts +0 -27
  45. package/dist/types/server/src/plugins/types.d.ts +0 -49
  46. package/dist/types/server/src/rpc/namespaces.d.ts +0 -35
  47. package/dist/types/server/src/rpc/types.d.ts +0 -111
  48. package/dist/types/server/src/services/config/defaults.d.ts +0 -12
  49. package/dist/types/server/src/services/config/types.d.ts +0 -162
  50. package/dist/types/server/src/types.d.ts +0 -34
  51. package/dist/types/shared/types/index.d.ts +0 -22
@@ -1,14 +0,0 @@
1
- /*! *****************************************************************************
2
- Copyright (C) Microsoft. All rights reserved.
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
- this file except in compliance with the License. You may obtain a copy of the
5
- License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10
- MERCHANTABLITY OR NON-INFRINGEMENT.
11
-
12
- See the Apache Version 2.0 License for specific language governing permissions
13
- and limitations under the License.
14
- ***************************************************************************** */
@@ -1,8 +0,0 @@
1
- export declare class FetchInterceptor {
2
- private baseURL;
3
- private abortControllers;
4
- constructor(endpoint: string);
5
- request(method: string, url: string, data?: any, options?: RequestInit): Promise<Response>;
6
- get(url: string, options?: RequestInit): Promise<Response>;
7
- post(url: string, data?: any, options?: RequestInit): Promise<Response>;
8
- }
@@ -1,21 +0,0 @@
1
- import { CoreManager, DeviceManager } from './proxy/index.js';
2
- import type { CameraUiClientConfig } from './types.js';
3
- export interface API {
4
- coreManager: CoreManager;
5
- deviceManager: DeviceManager;
6
- }
7
- export declare class CameraUiClient {
8
- private interceptor;
9
- private config;
10
- private logger;
11
- private proxy?;
12
- private token?;
13
- private _api?;
14
- get api(): API | undefined;
15
- constructor(config: CameraUiClientConfig);
16
- connect(): Promise<API>;
17
- disconnect(): Promise<void>;
18
- updateCredentials(newConfig: CameraUiClientConfig): Promise<void>;
19
- private login;
20
- private getNatsEndpoint;
21
- }
@@ -1,2 +0,0 @@
1
- export * from './client.js';
2
- export * from './types.js';
@@ -1,26 +0,0 @@
1
- import { BaseCameraDevice } from '../../../../../server/src/camera/index.js';
2
- import { CameraInterface } from '../../../../../server/src/camera/interfaces.js';
3
- import { Go2RTCSession } from '../streaming/go2rts-session.js';
4
- import type { Camera, CameraSource, ProbeConfig, ProbeStream } from '../../../../../shared/types/index.js';
5
- import type { Proxy } from '../proxy.js';
6
- import type { BaseLogger, CameraDevice, CameraUiClientConfig, Go2RTCSessionOptions } from '../types.js';
7
- export declare class CameraDeviceProxy extends BaseCameraDevice implements CameraDevice {
8
- private proxy;
9
- private config;
10
- private token;
11
- private subscription?;
12
- private namespaces;
13
- protected cameraInterfaces: CameraInterface;
14
- get sources(): CameraSource[];
15
- constructor(proxy: Proxy, config: CameraUiClientConfig, token: string, camera: Camera, logger: BaseLogger);
16
- init(): Promise<void>;
17
- close(): Promise<void>;
18
- createWebRTCSession(options: Go2RTCSessionOptions): Go2RTCSession;
19
- refreshStates(): Promise<void>;
20
- protected cleanup(): Promise<void>;
21
- protected snapshot(sourceId: string, forceNew?: boolean): Promise<ArrayBuffer | undefined>;
22
- probeStream(sourceId: string, probeConfig?: ProbeConfig, refresh?: boolean): Promise<ProbeStream | undefined>;
23
- private onEventMessage;
24
- private cameraControllerProxy;
25
- private disconnectRpc;
26
- }
@@ -1,14 +0,0 @@
1
- import type { CuiPlugin, FfmpegArgs, HWAccelOptions, IceServer, CoreManager as ICoreManager } from '../../../../../shared/types/index.js';
2
- import type { Proxy } from '../proxy.js';
3
- export declare class CoreManager implements ICoreManager {
4
- private proxy;
5
- private namespaces;
6
- private rpcConnections;
7
- constructor(proxy: Proxy);
8
- connectToPlugin(pluginName: string): Promise<CuiPlugin | undefined>;
9
- getFFmpegPath(): Promise<string>;
10
- getHwaccelInfo(options: HWAccelOptions): Promise<FfmpegArgs[]>;
11
- getServerAddresses(): Promise<string[]>;
12
- getIceServers(): Promise<IceServer[]>;
13
- private coreManagerProxy;
14
- }
@@ -1,16 +0,0 @@
1
- import type { Proxy } from '../proxy.js';
2
- import type { BaseLogger, CameraDevice, CameraUiClientConfig } from '../types.js';
3
- interface DeviceManagerBrowserProxyMethods {
4
- getCamera(cameraIdOrName: string): Promise<CameraDevice | undefined>;
5
- }
6
- export declare class DeviceManager implements DeviceManagerBrowserProxyMethods {
7
- private proxy;
8
- private config;
9
- private token;
10
- private logger;
11
- private namespaces;
12
- constructor(proxy: Proxy, config: CameraUiClientConfig, token: string, logger: BaseLogger);
13
- getCamera(cameraIdOrName: string): Promise<CameraDevice | undefined>;
14
- private deviceManagerProxy;
15
- }
16
- export {};
@@ -1,3 +0,0 @@
1
- export * from './cameraDevice.js';
2
- export * from './coreManager.js';
3
- export * from './deviceManager.js';
@@ -1,7 +0,0 @@
1
- import { ClientInstance } from '@camera.ui/rpc-client';
2
- import type { ClientConnectionOptions } from '@camera.ui/rpc-common';
3
- export declare class Proxy extends ClientInstance {
4
- constructor(options: ClientConnectionOptions);
5
- protected onStart(): Promise<void>;
6
- protected onStop(): Promise<void>;
7
- }
@@ -1,21 +0,0 @@
1
- export declare function createConfig(): {
2
- WEBRTC: {
3
- RECONNECT_TIMER: number;
4
- TIMEOUT_TIMER: number;
5
- ICE_SERVERS: {
6
- urls: string;
7
- }[];
8
- };
9
- QUALITY: {
10
- METRICS_INTERVAL: number;
11
- METRICS_WINDOW: number;
12
- STABILITY_PERIOD: number;
13
- PACKET_LOSS_THRESHOLD: number;
14
- FRAME_DROP_THRESHOLD: number;
15
- QUALITY_CHANGE_COOLDOWN: number;
16
- };
17
- MEDIA: {
18
- BUFFER_SIZE: number;
19
- DEFAULT_CODECS: string[];
20
- };
21
- };
@@ -1,286 +0,0 @@
1
- import type { CameraSource, StreamingRole, VideoStreamingMode } from '../../../../../shared/types/index.js';
2
- import type { CameraDeviceProxy } from '../proxy/cameraDevice.js';
3
- import type { BaseLogger, CameraUiClientConfig, Go2RTCSessionOptions } from '../types.js';
4
- /**
5
- * Manages streaming sessions using go2rtc as backend service
6
- * Supports WebRTC, MSE, and automatic mode switching
7
- */
8
- export declare class Go2RTCSession extends EventTarget {
9
- private readonly cameraDevice;
10
- private readonly logger;
11
- private readonly config;
12
- private readonly token;
13
- private readonly initialOptions;
14
- private readonly videoPlayer;
15
- private readonly CONFIG;
16
- private ws?;
17
- private pc;
18
- private micTransceiver;
19
- private mediaSource;
20
- private sourceBuffer;
21
- private buf;
22
- private bufLen;
23
- private codecList;
24
- private streamProbe?;
25
- private metrics;
26
- private metricsInterval?;
27
- private lastQualityChange;
28
- private isMonitoring;
29
- private wsReconnectTimer?;
30
- private wsReconnectTimeout?;
31
- private webrtcConnectTimeout?;
32
- private webrtcReconnectTimeout?;
33
- private firstFrameReceived;
34
- private animationFrameId?;
35
- private userRequestedMode;
36
- private internalMode;
37
- private activeMode;
38
- private isAutoSwitchingInProgress;
39
- private _closed;
40
- private _hasBackchannel;
41
- private _hasAudio;
42
- private _hasVideo;
43
- private _finishLoading;
44
- private userRequestedRole;
45
- private effectiveRole;
46
- private _streamingSource?;
47
- /**
48
- * Get current streaming source
49
- */
50
- get streamingSource(): CameraSource | undefined;
51
- /**
52
- * Is the session closed
53
- */
54
- get closed(): boolean;
55
- /**
56
- * Indicates if backchannel (two-way audio) is available
57
- */
58
- get hasBackchannel(): boolean;
59
- /**
60
- * Indicates if audio is available in the stream
61
- */
62
- get hasAudio(): boolean;
63
- /**
64
- * Indicates if video is available in the stream
65
- */
66
- get hasVideo(): boolean;
67
- /**
68
- * Indicates if loading has finished
69
- */
70
- get finishLoading(): boolean;
71
- /**
72
- * User requested streaming mode
73
- */
74
- get mode(): VideoStreamingMode;
75
- /**
76
- * Current effective mode being used (never 'auto')
77
- */
78
- get currentMode(): VideoStreamingMode;
79
- /**
80
- * Current effective resolution being used
81
- */
82
- get currentResolution(): StreamingRole;
83
- /**
84
- * Prefix for logging, includes camera name and mode
85
- */
86
- private get logPrefix();
87
- /**
88
- * WebSocket URL with proper authentication and source
89
- */
90
- private get wsUrl();
91
- /**
92
- * Creates a new Go2RTCSession
93
- */
94
- constructor(cameraDevice: CameraDeviceProxy, config: CameraUiClientConfig, token: string, logger: BaseLogger, options: Go2RTCSessionOptions);
95
- /**
96
- * Starts the streaming session
97
- * @param customMode Optional mode override for this start
98
- */
99
- start(customMode?: VideoStreamingMode): Promise<void>;
100
- /**
101
- * Closes the streaming session
102
- */
103
- close(): void;
104
- /**
105
- * Restarts the streaming session
106
- * @param customMode Optional mode override for restart
107
- * @param sourceChange Whether restart is due to source change
108
- */
109
- restart(customMode?: VideoStreamingMode, sourceChange?: boolean): Promise<void>;
110
- /**
111
- * Toggles microphone track for two-way audio
112
- * @param track Media track or null to disable
113
- */
114
- toggleMicrophone(track: MediaStreamTrack | null): Promise<void>;
115
- /**
116
- * Changes the stream resolution
117
- * @param role Target resolution or 'auto' for adaptive
118
- */
119
- toggleRole(role: StreamingRole | 'auto'): Promise<void>;
120
- /**
121
- * Changes the streaming transport mode
122
- * @param mode Target transport mode
123
- */
124
- toggleMode(mode: VideoStreamingMode): Promise<void>;
125
- /**
126
- * Initialize streaming source based on user preferences
127
- */
128
- private initializeStreamingSource;
129
- /**
130
- * Check if a stream is WebRTC compatible
131
- */
132
- private checkWebRTCCompatibility;
133
- /**
134
- * Initialize adaptive streaming if role is auto
135
- */
136
- private initializeAdaptiveStreaming;
137
- /**
138
- * Select initial mode based on codec compatibility
139
- * If we know WebRTC won't work, don't even try it
140
- */
141
- private selectInitialMode;
142
- /**
143
- * Set up WebSocket connection
144
- */
145
- private connectWs;
146
- /**
147
- * Disconnect and clean up WebSocket
148
- */
149
- private disconnectWs;
150
- /**
151
- * Reset internal state completely
152
- */
153
- private reset;
154
- /**
155
- * WebSocket open event handler
156
- */
157
- private onWsOpen;
158
- /**
159
- * WebSocket close event handler - handles reconnection
160
- */
161
- private onWsClose;
162
- /**
163
- * WebSocket message handler - routes to appropriate processor
164
- */
165
- private onWsMessage;
166
- /**
167
- * Handle streaming errors from server
168
- */
169
- private handleStreamError;
170
- /**
171
- * Request WebRTC session
172
- * @param autoMode Whether this is part of auto mode detection
173
- */
174
- private requestWebrtc;
175
- /**
176
- * Process WebRTC signaling messages
177
- */
178
- private onWebrtcData;
179
- /**
180
- * Request MSE session
181
- */
182
- private requestMse;
183
- /**
184
- * Process MSE initialization message
185
- */
186
- private onMseData;
187
- /**
188
- * Process MSE binary data
189
- */
190
- private onMseBuffer;
191
- /**
192
- * Request auto mode (tries both WebRTC and MSE)
193
- */
194
- private requestAuto;
195
- /**
196
- * Send message to WebSocket
197
- */
198
- private send;
199
- /**
200
- * Switch to WebRTC in auto mode
201
- */
202
- private switchToWebRTC;
203
- /**
204
- * Play video with automatic muting fallback if autoplay is blocked
205
- */
206
- private play;
207
- /**
208
- * Start quality monitoring for adaptive streaming
209
- */
210
- private startQualityMonitoring;
211
- /**
212
- * Stop quality monitoring
213
- */
214
- private stopQualityMonitoring;
215
- /**
216
- * Gather metrics from current connection
217
- */
218
- private gatherMetrics;
219
- /**
220
- * Analyze quality metrics to determine stability
221
- */
222
- private analyzeQualityMetrics;
223
- /**
224
- * Analyze current quality and adapt resolution if needed
225
- */
226
- private analyzeAndAdaptQuality;
227
- /**
228
- * Change stream resolution
229
- * @param resolution Target resolution
230
- * @param reason Why the change is happening (for logging)
231
- * @param initial Whether this is initial setup
232
- */
233
- private setStreamResolution;
234
- /**
235
- * Find the best source for a requested resolution
236
- */
237
- private getSourceForResolution;
238
- /**
239
- * Handle first frame received in WebRTC mode
240
- */
241
- private onFirstFrameWebrtc;
242
- /**
243
- * Handle camera device change event
244
- */
245
- private setActiveMode;
246
- /**
247
- * Handle first frame received event
248
- */
249
- private onFirstFrame;
250
- /**
251
- * Handle loaded data event from video element
252
- */
253
- private onLoadedData;
254
- /**
255
- * Mark loading as finished and dispatch event
256
- */
257
- private onFinishLoading;
258
- /**
259
- * Create a list of supported codecs based on browser
260
- */
261
- private createCodecsList;
262
- /**
263
- * Parse codecs list into string for MSE
264
- */
265
- private parseCodecs;
266
- /**
267
- * Probe stream capabilities
268
- */
269
- private probeStream;
270
- /**
271
- * Check if audio codec is WebRTC compatible
272
- */
273
- private isWebRtcCompatibleAudioCodec;
274
- /**
275
- * Check if video codec is WebRTC compatible
276
- */
277
- private isWebRtcCompatibleVideoCodec;
278
- /**
279
- * Create WebSocket source name from camera and source
280
- */
281
- private createWsSourceName;
282
- /**
283
- * Check if H.265 is supported by the browser's WebRTC implementation
284
- */
285
- private isWebRTCH265Supported;
286
- }
@@ -1,38 +0,0 @@
1
- export interface Go2RTCMessageBase {
2
- type: 'mse' | 'webrtc/candidate' | 'webrtc/answer' | 'webrtc/offer' | 'error';
3
- }
4
- export interface MSEMessage extends Go2RTCMessageBase {
5
- type: 'mse';
6
- value: string | ArrayBuffer;
7
- }
8
- export interface WebRTCAnswerMessage extends Go2RTCMessageBase {
9
- type: 'webrtc/answer';
10
- value: string;
11
- }
12
- export interface WebRTCOfferMessage extends Go2RTCMessageBase {
13
- type: 'webrtc/offer';
14
- value: string;
15
- }
16
- export interface WebRTCCandidateMessage extends Go2RTCMessageBase {
17
- type: 'webrtc/candidate';
18
- value?: string;
19
- }
20
- export type WebRTCMessage = WebRTCAnswerMessage | WebRTCCandidateMessage;
21
- export interface ErrorMessage extends Go2RTCMessageBase {
22
- type: 'error';
23
- value: string;
24
- }
25
- export type Go2RTCMessage = MSEMessage | WebRTCMessage | ErrorMessage;
26
- export type Go2RTCWsMessage = WebRTCOfferMessage | WebRTCCandidateMessage | MSEMessage;
27
- export interface NetworkMetrics {
28
- packetsLost: number;
29
- packetsReceived: number;
30
- framesDropped: number;
31
- framesReceived: number;
32
- timestamp: number;
33
- }
34
- export interface QualityMetrics {
35
- packetLossRate: number;
36
- frameDropRate: number;
37
- isStable: boolean;
38
- }
@@ -1,56 +0,0 @@
1
- import type { Observable, Subject } from 'rxjs';
2
- import type { BaseCameraDevice } from '../../../../server/src/camera/index.js';
3
- import type { StreamingRole, VideoStreamingMode } from '../../../../shared/types/index.js';
4
- import type { Go2RTCSession } from './streaming/go2rts-session.js';
5
- export * from '@camera.ui/types';
6
- export type { Go2RTCSession } from './streaming/go2rts-session.js';
7
- export type { VideoStreamingMode } from '../../../../shared/types/index.js';
8
- export type CameraUiClientConfig = WithCredentials | WithToken;
9
- export interface BasicBrowserPeerConnection {
10
- enableMicrophone(track: MediaStreamTrack): void;
11
- disableMicrophone(): void;
12
- createOffer(): Promise<RTCSessionDescriptionInit>;
13
- acceptAnswer(answer: {
14
- type: 'answer';
15
- sdp: string;
16
- }): Promise<void>;
17
- addIceCandidate(candidate: Partial<RTCIceCandidate>): Promise<void>;
18
- onIceCandidate: Subject<RTCIceCandidate>;
19
- onConnectionState: Observable<RTCPeerConnectionState>;
20
- close(): void;
21
- }
22
- export interface CameraDevice extends BaseCameraDevice {
23
- close(): Promise<void>;
24
- createWebRTCSession(options: Go2RTCSessionOptions): Go2RTCSession;
25
- }
26
- export interface Go2RTCSessionOptions {
27
- role: StreamingRole | 'auto';
28
- mode: VideoStreamingMode;
29
- videoElement: HTMLVideoElement;
30
- wsReconnectTimeout?: number;
31
- webrtcConnectTimeout?: number;
32
- }
33
- export interface BaseLogger {
34
- log: (...args: any[]) => void;
35
- error: (...args: any[]) => void;
36
- warn: (...args: any[]) => void;
37
- success: (...args: any[]) => void;
38
- debug: (...args: any[]) => void;
39
- trace: (...args: any[]) => void;
40
- attention: (...args: any[]) => void;
41
- }
42
- interface BaseConfig {
43
- endpoint: string;
44
- skipCheck?: boolean;
45
- logger?: BaseLogger;
46
- }
47
- interface WithCredentials extends BaseConfig {
48
- username: string;
49
- password: string;
50
- token?: never;
51
- }
52
- interface WithToken extends BaseConfig {
53
- username?: never;
54
- password?: never;
55
- token: string;
56
- }
@@ -1,12 +0,0 @@
1
- export declare const isMobile: () => boolean;
2
- export declare const isAndroid: () => boolean;
3
- export declare const isIphone: () => boolean;
4
- export declare const isIpad: () => boolean;
5
- export declare const isAppleMobile: () => boolean;
6
- export declare const iosVersion: () => number[] | undefined;
7
- export declare const isSafari: () => boolean;
8
- export declare const safariVersion: () => RegExpExecArray | null;
9
- export declare const isFirefox: () => boolean;
10
- export declare const isChrome: () => boolean;
11
- export declare const isTouch: () => boolean;
12
- export declare const generateUUID: () => string;
@@ -1,18 +0,0 @@
1
- import type { Subscribed as SubscribedInterface } from '@camera.ui/types';
2
- import type { Subscription } from 'rxjs';
3
- export declare class Subscribed {
4
- private readonly subscriptions;
5
- private readonly additionalSubscriptions;
6
- protected addSubscriptions(...subscriptions: Subscription[]): void;
7
- protected addAdditionalSubscriptions(...subscriptions: Subscription[]): void;
8
- protected unsubscribe(): void;
9
- protected unsubscribeAdditional(): void;
10
- }
11
- export declare class SubscribedPublic implements SubscribedInterface {
12
- private readonly subscriptions;
13
- private readonly additionalSubscriptions;
14
- addSubscriptions(...subscriptions: Subscription[]): void;
15
- addAdditionalSubscriptions(...subscriptions: Subscription[]): void;
16
- unsubscribe(): void;
17
- unsubscribeAdditional(): void;
18
- }