@stream-io/video-client 1.5.0-0 → 1.5.0

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 (76) hide show
  1. package/CHANGELOG.md +6 -230
  2. package/dist/index.browser.es.js +1498 -1963
  3. package/dist/index.browser.es.js.map +1 -1
  4. package/dist/index.cjs.js +1495 -1961
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.es.js +1498 -1963
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/src/Call.d.ts +9 -93
  9. package/dist/src/StreamSfuClient.d.ts +56 -72
  10. package/dist/src/StreamVideoClient.d.ts +10 -2
  11. package/dist/src/coordinator/connection/client.d.ts +4 -3
  12. package/dist/src/coordinator/connection/types.d.ts +1 -5
  13. package/dist/src/devices/InputMediaDeviceManager.d.ts +0 -4
  14. package/dist/src/devices/MicrophoneManager.d.ts +1 -1
  15. package/dist/src/events/callEventHandlers.d.ts +3 -1
  16. package/dist/src/events/internal.d.ts +0 -4
  17. package/dist/src/gen/video/sfu/event/events.d.ts +4 -106
  18. package/dist/src/gen/video/sfu/models/models.d.ts +65 -64
  19. package/dist/src/logger.d.ts +0 -1
  20. package/dist/src/rpc/createClient.d.ts +0 -2
  21. package/dist/src/rpc/index.d.ts +0 -1
  22. package/dist/src/rtc/Dispatcher.d.ts +1 -1
  23. package/dist/src/rtc/IceTrickleBuffer.d.ts +1 -0
  24. package/dist/src/rtc/Publisher.d.ts +25 -24
  25. package/dist/src/rtc/Subscriber.d.ts +11 -12
  26. package/dist/src/rtc/flows/join.d.ts +20 -0
  27. package/dist/src/rtc/helpers/tracks.d.ts +3 -3
  28. package/dist/src/rtc/signal.d.ts +1 -1
  29. package/dist/src/store/CallState.d.ts +2 -46
  30. package/package.json +3 -3
  31. package/src/Call.ts +562 -615
  32. package/src/StreamSfuClient.ts +246 -277
  33. package/src/StreamVideoClient.ts +65 -15
  34. package/src/coordinator/connection/client.ts +8 -25
  35. package/src/coordinator/connection/connection.ts +0 -1
  36. package/src/coordinator/connection/token_manager.ts +1 -1
  37. package/src/coordinator/connection/types.ts +0 -6
  38. package/src/devices/BrowserPermission.ts +1 -5
  39. package/src/devices/CameraManager.ts +1 -1
  40. package/src/devices/InputMediaDeviceManager.ts +3 -12
  41. package/src/devices/MicrophoneManager.ts +3 -3
  42. package/src/devices/devices.ts +1 -1
  43. package/src/events/__tests__/mutes.test.ts +13 -10
  44. package/src/events/__tests__/participant.test.ts +0 -75
  45. package/src/events/callEventHandlers.ts +7 -4
  46. package/src/events/internal.ts +3 -20
  47. package/src/events/mutes.ts +3 -5
  48. package/src/events/participant.ts +15 -48
  49. package/src/gen/video/sfu/event/events.ts +8 -451
  50. package/src/gen/video/sfu/models/models.ts +204 -211
  51. package/src/logger.ts +1 -3
  52. package/src/rpc/createClient.ts +0 -21
  53. package/src/rpc/index.ts +0 -1
  54. package/src/rtc/Dispatcher.ts +2 -6
  55. package/src/rtc/IceTrickleBuffer.ts +2 -2
  56. package/src/rtc/Publisher.ts +163 -127
  57. package/src/rtc/Subscriber.ts +155 -94
  58. package/src/rtc/__tests__/Publisher.test.ts +95 -18
  59. package/src/rtc/__tests__/Subscriber.test.ts +99 -63
  60. package/src/rtc/__tests__/videoLayers.test.ts +2 -2
  61. package/src/rtc/flows/join.ts +65 -0
  62. package/src/rtc/helpers/tracks.ts +7 -27
  63. package/src/rtc/signal.ts +3 -3
  64. package/src/rtc/videoLayers.ts +10 -1
  65. package/src/stats/SfuStatsReporter.ts +0 -1
  66. package/src/store/CallState.ts +2 -109
  67. package/src/store/__tests__/CallState.test.ts +37 -48
  68. package/dist/src/helpers/ensureExhausted.d.ts +0 -1
  69. package/dist/src/helpers/withResolvers.d.ts +0 -14
  70. package/dist/src/rpc/retryable.d.ts +0 -23
  71. package/dist/src/rtc/helpers/rtcConfiguration.d.ts +0 -2
  72. package/src/helpers/ensureExhausted.ts +0 -5
  73. package/src/helpers/withResolvers.ts +0 -43
  74. package/src/rpc/__tests__/retryable.test.ts +0 -72
  75. package/src/rpc/retryable.ts +0 -57
  76. package/src/rtc/helpers/rtcConfiguration.ts +0 -11
@@ -1,13 +1,13 @@
1
1
  import { Publisher, Subscriber } from './rtc';
2
+ import { TrackType } from './gen/video/sfu/models/models';
2
3
  import { CallState } from './store';
3
- import type { AcceptCallResponse, BlockUserResponse, CollectUserFeedbackResponse, EndCallResponse, GetCallResponse, GetCallStatsResponse, GetOrCreateCallRequest, GetOrCreateCallResponse, GoLiveRequest, GoLiveResponse, JoinCallResponse, ListRecordingsResponse, ListTranscriptionsResponse, MuteUsersResponse, PinRequest, PinResponse, QueryCallMembersRequest, QueryCallMembersResponse, RejectCallResponse, RequestPermissionRequest, RequestPermissionResponse, SendCallEventResponse, SendReactionRequest, SendReactionResponse, StartHLSBroadcastingResponse, StartRecordingRequest, StartRecordingResponse, StartTranscriptionRequest, StartTranscriptionResponse, StopHLSBroadcastingResponse, StopLiveResponse, StopRecordingResponse, StopTranscriptionResponse, UnblockUserResponse, UnpinRequest, UnpinResponse, UpdateCallMembersRequest, UpdateCallMembersResponse, UpdateCallRequest, UpdateCallResponse, UpdateUserPermissionsRequest, UpdateUserPermissionsResponse } from './gen/coordinator';
4
+ import { AcceptCallResponse, BlockUserResponse, CollectUserFeedbackResponse, EndCallResponse, GetCallResponse, GetCallStatsResponse, GetOrCreateCallRequest, GetOrCreateCallResponse, GoLiveRequest, GoLiveResponse, ListRecordingsResponse, ListTranscriptionsResponse, MuteUsersResponse, PinRequest, PinResponse, QueryCallMembersRequest, QueryCallMembersResponse, RejectCallResponse, RequestPermissionRequest, RequestPermissionResponse, SendCallEventResponse, SendReactionRequest, SendReactionResponse, StartHLSBroadcastingResponse, StartRecordingRequest, StartRecordingResponse, StartTranscriptionRequest, StartTranscriptionResponse, StopHLSBroadcastingResponse, StopLiveResponse, StopRecordingResponse, StopTranscriptionResponse, UnblockUserResponse, UnpinRequest, UnpinResponse, UpdateCallMembersRequest, UpdateCallMembersResponse, UpdateCallRequest, UpdateCallResponse, UpdateUserPermissionsRequest, UpdateUserPermissionsResponse } from './gen/coordinator';
4
5
  import { AudioTrackType, CallConstructor, CallLeaveOptions, DebounceType, JoinCallData, PublishOptions, SubscriptionChanges, TrackMuteType, VideoTrackType } from './types';
5
6
  import { VideoLayerSetting } from './gen/video/sfu/event/events';
6
- import { TrackType } from './gen/video/sfu/models/models';
7
7
  import { DynascaleManager } from './helpers/DynascaleManager';
8
8
  import { PermissionsContext } from './permissions';
9
9
  import { StreamClient } from './coordinator/connection/client';
10
- import type { AllCallEvents, CallEventListener, Logger, RejectReason } from './coordinator/connection/types';
10
+ import { AllCallEvents, CallEventListener, Logger, RejectReason } from './coordinator/connection/types';
11
11
  import { CameraManager, MicrophoneManager, ScreenShareManager, SpeakerManager } from './devices';
12
12
  /**
13
13
  * An object representation of a `Call`.
@@ -77,18 +77,9 @@ export declare class Call {
77
77
  private readonly clientStore;
78
78
  readonly streamClient: StreamClient;
79
79
  private sfuClient?;
80
- private sfuClientTag;
81
- private readonly reconnectConcurrencyTag;
82
80
  private reconnectAttempts;
83
- private reconnectStrategy;
84
- private fastReconnectDeadlineSeconds;
85
- private lastOfflineTimestamp;
86
- private networkAvailableTask;
87
- private trackPublishOrder;
88
- private joinCallData?;
89
- private hasJoinedOnce;
90
- private deviceSettingsAppliedOnce;
91
- private credentials?;
81
+ private maxReconnectAttempts;
82
+ private isLeaving;
92
83
  private initialized;
93
84
  private readonly joinLeaveConcurrencyTag;
94
85
  /**
@@ -109,7 +100,6 @@ export declare class Call {
109
100
  constructor({ type, id, streamClient, members, ownCapabilities, sortParticipantsBy, clientStore, ringing, watching, }: CallConstructor);
110
101
  private setup;
111
102
  private registerEffects;
112
- private handleOwnCapabilitiesUpdated;
113
103
  /**
114
104
  * You can subscribe to WebSocket events provided by the API. To remove a subscription, call the `off` method.
115
105
  * Please note that subscribing to WebSocket events is an advanced use-case.
@@ -200,81 +190,7 @@ export declare class Call {
200
190
  * @returns a promise which resolves once the call join-flow has finished.
201
191
  */
202
192
  join: (data?: JoinCallData) => Promise<void>;
203
- /**
204
- * Prepares Reconnect Details object.
205
- * @internal
206
- */
207
- private getReconnectDetails;
208
- /**
209
- * Performs an ICE restart on both the Publisher and Subscriber Peer Connections.
210
- * Uses the provided SFU client to restore the ICE connection.
211
- *
212
- * This method can throw an error if the ICE restart fails.
213
- * This error should be handled by the reconnect loop,
214
- * and a new reconnection shall be attempted.
215
- *
216
- * @internal
217
- */
218
- private restoreICE;
219
- /**
220
- * Initializes the Publisher and Subscriber Peer Connections.
221
- * @internal
222
- */
223
- private initPublisherAndSubscriber;
224
- /**
225
- * Retrieves credentials for joining the call.
226
- *
227
- * @internal
228
- *
229
- * @param data the join call data.
230
- */
231
- doJoinRequest: (data?: JoinCallData) => Promise<JoinCallResponse>;
232
- /**
233
- * Handles the closing of the SFU signal connection.
234
- *
235
- * @internal
236
- * @param sfuClient the SFU client instance that was closed.
237
- */
238
- private handleSfuSignalClose;
239
- /**
240
- * Handles the reconnection flow.
241
- *
242
- * @internal
243
- *
244
- * @param strategy the reconnection strategy to use.
245
- */
246
- private reconnect;
247
- /**
248
- * Initiates the reconnection flow with the "fast" strategy.
249
- * @internal
250
- */
251
- private reconnectFast;
252
- /**
253
- * Initiates the reconnection flow with the "rejoin" strategy.
254
- * @internal
255
- */
256
- private reconnectRejoin;
257
- /**
258
- * Initiates the reconnection flow with the "migrate" strategy.
259
- * @internal
260
- */
261
- private reconnectMigrate;
262
- /**
263
- * Registers the various event handlers for reconnection.
264
- *
265
- * @internal
266
- */
267
- private registerReconnectHandlers;
268
- /**
269
- * Restores the published tracks after a reconnection.
270
- * @internal
271
- */
272
- private restorePublishedTracks;
273
- /**
274
- * Restores the subscribed tracks after a reconnection.
275
- * @internal
276
- */
277
- private restoreSubscribedTracks;
193
+ private waitForJoinResponse;
278
194
  /**
279
195
  * Starts publishing the given video stream to the call.
280
196
  * The stream will be stopped if the user changes an input device, or if the user leaves the call.
@@ -335,7 +251,7 @@ export declare class Call {
335
251
  * @param changes the list of subscription changes to do.
336
252
  * @param type the debounce type to use for the update.
337
253
  */
338
- updateSubscriptionsPartial: (trackType: VideoTrackType, changes: SubscriptionChanges, type?: DebounceType) => void;
254
+ updateSubscriptionsPartial: (trackType: VideoTrackType | "video" | "screen", changes: SubscriptionChanges, type?: DebounceType) => void;
339
255
  private updateSubscriptions;
340
256
  /**
341
257
  * Will enhance the reported stats with additional participant-specific information (`callStatsReport$` state [store variable](./StreamVideoClient.md/#readonlystatestore)).
@@ -370,7 +286,7 @@ export declare class Call {
370
286
  * @param enabledLayers the list of layers to enable.
371
287
  */
372
288
  updatePublishQuality: (enabledLayers: VideoLayerSetting[]) => Promise<void | undefined>;
373
- private waitUntilCallJoined;
289
+ private assertCallJoined;
374
290
  /**
375
291
  * Sends a reaction to the other call participants.
376
292
  *
@@ -597,7 +513,7 @@ export declare class Call {
597
513
  *
598
514
  * @internal
599
515
  */
600
- applyDeviceConfig: (status: boolean) => Promise<void>;
516
+ applyDeviceConfig: () => Promise<void>;
601
517
  private initCamera;
602
518
  private initMic;
603
519
  /**
@@ -1,35 +1,28 @@
1
+ import type { WebSocket } from 'ws';
2
+ import type { FinishedUnaryCall } from '@protobuf-ts/runtime-rpc';
1
3
  import { Dispatcher, IceTrickleBuffer } from './rtc';
2
- import { JoinRequest, JoinResponse } from './gen/video/sfu/event/events';
4
+ import { JoinRequest, SfuRequest } from './gen/video/sfu/event/events';
3
5
  import { ICERestartRequest, SendAnswerRequest, SendStatsRequest, SetPublisherRequest, TrackSubscriptionDetails, UpdateMuteStatesRequest } from './gen/video/sfu/signal_rpc/signal';
4
6
  import { ICETrickle, TrackType } from './gen/video/sfu/models/models';
5
- import { Credentials } from './gen/coordinator';
7
+ import { SFUResponse } from './gen/coordinator';
6
8
  export type StreamSfuClientConstructor = {
7
9
  /**
8
10
  * The event dispatcher instance to use.
9
11
  */
10
12
  dispatcher: Dispatcher;
11
13
  /**
12
- * The credentials to use for the connection.
14
+ * The SFU server to connect to.
13
15
  */
14
- credentials: Credentials;
16
+ sfuServer: SFUResponse;
15
17
  /**
16
- * `sessionId` to use for the connection.
18
+ * The JWT token to use for authentication.
17
19
  */
18
- sessionId?: string;
19
- /**
20
- * A log tag to use for logging. Useful for debugging multiple instances.
21
- */
22
- logTag: string;
20
+ token: string;
23
21
  /**
24
- * The timeout in milliseconds for waiting for the `joinResponse`.
25
- * Defaults to 5000ms.
22
+ * An optional `sessionId` to use for the connection.
23
+ * If not provided, a random UUIDv4 will be generated.
26
24
  */
27
- joinResponseTimeout?: number;
28
- /**
29
- * Callback for when the WebSocket connection is closed.
30
- * @param event the event.
31
- */
32
- onSignalClose?: (event: CloseEvent) => void;
25
+ sessionId?: string;
33
26
  };
34
27
  /**
35
28
  * The client used for exchanging information with the SFU.
@@ -37,7 +30,7 @@ export type StreamSfuClientConstructor = {
37
30
  export declare class StreamSfuClient {
38
31
  /**
39
32
  * A buffer for ICE Candidates that are received before
40
- * the Publisher and Subscriber Peer Connections are ready to handle them.
33
+ * the PeerConnections are ready to handle them.
41
34
  */
42
35
  readonly iceTrickleBuffer: IceTrickleBuffer;
43
36
  /**
@@ -48,48 +41,40 @@ export declare class StreamSfuClient {
48
41
  * The `edgeName` representing the edge the client is connected to.
49
42
  */
50
43
  readonly edgeName: string;
44
+ /**
45
+ * The current token used for authenticating against the SFU.
46
+ */
47
+ readonly token: string;
48
+ /**
49
+ * The SFU server details the current client is connected to.
50
+ */
51
+ readonly sfuServer: SFUResponse;
51
52
  /**
52
53
  * Holds the current WebSocket connection to the SFU.
53
54
  */
54
- private signalWs;
55
+ signalWs: WebSocket;
55
56
  /**
56
57
  * Promise that resolves when the WebSocket connection is ready (open).
57
58
  */
58
- private signalReady;
59
+ signalReady: Promise<WebSocket>;
59
60
  /**
60
- * Flag to indicate if the client is in the process of leaving the call.
61
- * This is set to `true` when the user initiates the leave process.
61
+ * A flag indicating whether the client is currently migrating away
62
+ * from this SFU.
62
63
  */
63
- isLeaving: boolean;
64
+ isMigratingAway: boolean;
65
+ /**
66
+ * A flag indicating that the client connection is broken for the current
67
+ * client and that a fast-reconnect with a new client should be attempted.
68
+ */
69
+ isFastReconnecting: boolean;
64
70
  private readonly rpc;
65
71
  private keepAliveInterval?;
66
72
  private connectionCheckTimeout?;
67
- private migrateAwayTimeout?;
68
73
  private pingIntervalInMs;
69
74
  private unhealthyTimeoutInMs;
70
75
  private lastMessageTimestamp?;
71
- private readonly restoreWebSocketConcurrencyTag;
72
76
  private readonly unsubscribeIceTrickle;
73
- private readonly onSignalClose;
74
77
  private readonly logger;
75
- private readonly logTag;
76
- private readonly credentials;
77
- private readonly dispatcher;
78
- private readonly joinResponseTimeout?;
79
- /**
80
- * Promise that resolves when the JoinResponse is received.
81
- * Rejects after a certain threshold if the response is not received.
82
- */
83
- private joinResponseTask;
84
- /**
85
- * Promise that resolves when the migration is complete.
86
- * Rejects after a certain threshold if the migration is not complete.
87
- */
88
- private migrationTask?;
89
- /**
90
- * A controller to abort the current requests.
91
- */
92
- private readonly abortController;
93
78
  /**
94
79
  * The normal closure code. Used for controlled shutdowns.
95
80
  */
@@ -101,34 +86,33 @@ export declare class StreamSfuClient {
101
86
  */
102
87
  static ERROR_CONNECTION_UNHEALTHY: number;
103
88
  /**
104
- * Constructs a new SFU client.
89
+ * The error code used when the SFU connection is broken.
90
+ * Usually, this means that the WS connection has been closed unexpectedly.
91
+ * This error code is used to announce a fast-reconnect.
105
92
  */
106
- constructor({ dispatcher, credentials, sessionId, logTag, joinResponseTimeout, onSignalClose, }: StreamSfuClientConstructor);
107
- private createWebSocket;
108
- private cleanUpWebSocket;
109
- private restoreWebSocket;
110
- get isHealthy(): boolean;
111
- private handleWebSocketClose;
112
- close: (code?: number, reason?: string) => void;
113
- dispose: () => void;
114
- leaveAndClose: (reason: string) => Promise<void>;
115
- updateSubscriptions: (tracks: TrackSubscriptionDetails[]) => Promise<import("@protobuf-ts/runtime-rpc").FinishedUnaryCall<import("./gen/video/sfu/signal_rpc/signal").UpdateSubscriptionsRequest, import("./gen/video/sfu/signal_rpc/signal").UpdateSubscriptionsResponse>>;
116
- setPublisher: (data: Omit<SetPublisherRequest, "sessionId">) => Promise<import("@protobuf-ts/runtime-rpc").FinishedUnaryCall<SetPublisherRequest, import("./gen/video/sfu/signal_rpc/signal").SetPublisherResponse>>;
117
- sendAnswer: (data: Omit<SendAnswerRequest, "sessionId">) => Promise<import("@protobuf-ts/runtime-rpc").FinishedUnaryCall<SendAnswerRequest, import("./gen/video/sfu/signal_rpc/signal").SendAnswerResponse>>;
118
- iceTrickle: (data: Omit<ICETrickle, "sessionId">) => Promise<import("@protobuf-ts/runtime-rpc").FinishedUnaryCall<ICETrickle, import("./gen/video/sfu/signal_rpc/signal").ICETrickleResponse>>;
119
- iceRestart: (data: Omit<ICERestartRequest, "sessionId">) => Promise<import("@protobuf-ts/runtime-rpc").FinishedUnaryCall<ICERestartRequest, import("./gen/video/sfu/signal_rpc/signal").ICERestartResponse>>;
120
- updateMuteState: (trackType: TrackType, muted: boolean) => Promise<import("@protobuf-ts/runtime-rpc").FinishedUnaryCall<UpdateMuteStatesRequest, import("./gen/video/sfu/signal_rpc/signal").UpdateMuteStatesResponse>>;
121
- updateMuteStates: (data: Omit<UpdateMuteStatesRequest, "sessionId">) => Promise<import("@protobuf-ts/runtime-rpc").FinishedUnaryCall<UpdateMuteStatesRequest, import("./gen/video/sfu/signal_rpc/signal").UpdateMuteStatesResponse>>;
122
- sendStats: (stats: Omit<SendStatsRequest, "sessionId">) => Promise<import("@protobuf-ts/runtime-rpc").FinishedUnaryCall<SendStatsRequest, import("./gen/video/sfu/signal_rpc/signal").SendStatsResponse>>;
123
- startNoiseCancellation: () => Promise<import("@protobuf-ts/runtime-rpc").FinishedUnaryCall<import("./gen/video/sfu/signal_rpc/signal").StartNoiseCancellationRequest, import("./gen/video/sfu/signal_rpc/signal").StartNoiseCancellationResponse>>;
124
- stopNoiseCancellation: () => Promise<import("@protobuf-ts/runtime-rpc").FinishedUnaryCall<import("./gen/video/sfu/signal_rpc/signal").StopNoiseCancellationRequest, import("./gen/video/sfu/signal_rpc/signal").StopNoiseCancellationResponse>>;
125
- enterMigration: (opts?: {
126
- timeout?: number;
127
- }) => Promise<void>;
128
- join: (data: Omit<JoinRequest, "sessionId" | "token">) => Promise<JoinResponse>;
129
- ping: () => Promise<void>;
130
- private notifyLeave;
131
- private send;
93
+ static ERROR_CONNECTION_BROKEN: number;
94
+ /**
95
+ * Constructs a new SFU client.
96
+ *
97
+ * @param dispatcher the event dispatcher to use.
98
+ * @param sfuServer the SFU server to connect to.
99
+ * @param token the JWT token to use for authentication.
100
+ * @param sessionId the `sessionId` of the currently connected participant.
101
+ */
102
+ constructor({ dispatcher, sfuServer, token, sessionId, }: StreamSfuClientConstructor);
103
+ close: (code: number, reason: string) => void;
104
+ updateSubscriptions: (subscriptions: TrackSubscriptionDetails[]) => Promise<FinishedUnaryCall<import("./gen/video/sfu/signal_rpc/signal").UpdateSubscriptionsRequest, import("./gen/video/sfu/signal_rpc/signal").UpdateSubscriptionsResponse>>;
105
+ setPublisher: (data: Omit<SetPublisherRequest, "sessionId">) => Promise<FinishedUnaryCall<SetPublisherRequest, import("./gen/video/sfu/signal_rpc/signal").SetPublisherResponse>>;
106
+ sendAnswer: (data: Omit<SendAnswerRequest, "sessionId">) => Promise<FinishedUnaryCall<SendAnswerRequest, import("./gen/video/sfu/signal_rpc/signal").SendAnswerResponse>>;
107
+ iceTrickle: (data: Omit<ICETrickle, "sessionId">) => Promise<FinishedUnaryCall<ICETrickle, import("./gen/video/sfu/signal_rpc/signal").ICETrickleResponse>>;
108
+ iceRestart: (data: Omit<ICERestartRequest, "sessionId">) => Promise<FinishedUnaryCall<ICERestartRequest, import("./gen/video/sfu/signal_rpc/signal").ICERestartResponse>>;
109
+ updateMuteState: (trackType: TrackType, muted: boolean) => Promise<FinishedUnaryCall<UpdateMuteStatesRequest, import("./gen/video/sfu/signal_rpc/signal").UpdateMuteStatesResponse>>;
110
+ updateMuteStates: (data: Omit<UpdateMuteStatesRequest, "sessionId">) => Promise<FinishedUnaryCall<UpdateMuteStatesRequest, import("./gen/video/sfu/signal_rpc/signal").UpdateMuteStatesResponse>>;
111
+ sendStats: (stats: Omit<SendStatsRequest, "sessionId">) => Promise<FinishedUnaryCall<SendStatsRequest, import("./gen/video/sfu/signal_rpc/signal").SendStatsResponse>>;
112
+ startNoiseCancellation: () => Promise<FinishedUnaryCall<import("./gen/video/sfu/signal_rpc/signal").StartNoiseCancellationRequest, import("./gen/video/sfu/signal_rpc/signal").StartNoiseCancellationResponse>>;
113
+ stopNoiseCancellation: () => Promise<FinishedUnaryCall<import("./gen/video/sfu/signal_rpc/signal").StopNoiseCancellationRequest, import("./gen/video/sfu/signal_rpc/signal").StopNoiseCancellationResponse>>;
114
+ join: (data: Omit<JoinRequest, "sessionId" | "token">) => Promise<void>;
115
+ send: (message: SfuRequest) => Promise<void>;
132
116
  private keepAlive;
133
117
  private scheduleConnectionCheck;
134
118
  }
@@ -18,6 +18,7 @@ export declare class StreamVideoClient {
18
18
  protected eventHandlersToUnregister: Array<() => void>;
19
19
  protected connectionPromise: Promise<void | ConnectedEvent> | undefined;
20
20
  protected disconnectionPromise: Promise<void> | undefined;
21
+ private static _instanceMap;
21
22
  /**
22
23
  * You should create only one instance of `StreamVideoClient`.
23
24
  */
@@ -29,6 +30,13 @@ export declare class StreamVideoClient {
29
30
  token?: string;
30
31
  tokenProvider?: TokenProvider;
31
32
  });
33
+ static getOrCreateInstance(args: {
34
+ apiKey: string;
35
+ user: User;
36
+ token?: string;
37
+ tokenProvider?: TokenProvider;
38
+ options?: StreamClientOptions;
39
+ }): StreamVideoClient;
32
40
  /**
33
41
  * Return the reactive state store, use this if you want to be notified about changes to the client state
34
42
  */
@@ -41,7 +49,7 @@ export declare class StreamVideoClient {
41
49
  * @param user the user to connect.
42
50
  * @param token a token or a function that returns a token.
43
51
  */
44
- connectUser: (user: User, token?: TokenOrProvider) => Promise<void | ConnectedEvent>;
52
+ connectUser(user: User, token?: TokenOrProvider): Promise<void | ConnectedEvent>;
45
53
  /**
46
54
  * Disconnects the currently connected user from the client.
47
55
  *
@@ -121,7 +129,7 @@ export declare class StreamVideoClient {
121
129
  * @param {string} push_provider_name user provided push provider name
122
130
  * @param {string} [userID] the user id (defaults to current user)
123
131
  */
124
- addVoipDevice: (id: string, push_provider: string, push_provider_name: string, userID?: string) => Promise<CreateDeviceRequest>;
132
+ addVoipDevice(id: string, push_provider: string, push_provider_name: string, userID?: string): Promise<CreateDeviceRequest>;
125
133
  /**
126
134
  * getDevices - Returns the devices associated with a current user
127
135
  * @param {string} [userID] User ID. Only works on serverside
@@ -167,7 +167,8 @@ export declare class StreamClient {
167
167
  * @returns json string
168
168
  */
169
169
  _buildWSPayload: (client_request_id?: string) => string;
170
- updateNetworkConnectionStatus: (event: {
171
- type: "online" | "offline";
172
- } | Event) => void;
170
+ /**
171
+ * creates an abort controller that will be used by the next HTTP Request.
172
+ */
173
+ createAbortControllerForNextRequest: () => AbortController;
173
174
  }
@@ -43,10 +43,6 @@ export type ConnectionChangedEvent = {
43
43
  type: 'connection.changed';
44
44
  online: boolean;
45
45
  };
46
- export type NetworkChangedEvent = {
47
- type: 'network.changed';
48
- online: boolean;
49
- };
50
46
  export type TransportChangedEvent = {
51
47
  type: 'transport.changed';
52
48
  mode: 'longpoll';
@@ -54,7 +50,7 @@ export type TransportChangedEvent = {
54
50
  export type ConnectionRecoveredEvent = {
55
51
  type: 'connection.recovered';
56
52
  };
57
- export type StreamVideoEvent = (WSEvent | NetworkChangedEvent | ConnectionChangedEvent | TransportChangedEvent | ConnectionRecoveredEvent) & {
53
+ export type StreamVideoEvent = (WSEvent | ConnectionChangedEvent | TransportChangedEvent | ConnectionRecoveredEvent) & {
58
54
  received_at?: string | Date;
59
55
  };
60
56
  export type StreamCallEvent = Extract<StreamVideoEvent, {
@@ -27,10 +27,6 @@ export declare abstract class InputMediaDeviceManager<T extends InputMediaDevice
27
27
  * @returns an Observable that will be updated if a device is connected or disconnected
28
28
  */
29
29
  listDevices(): Observable<MediaDeviceInfo[]>;
30
- /**
31
- * Returns `true` when this device is in enabled state.
32
- */
33
- get enabled(): boolean;
34
30
  /**
35
31
  * Starts stream.
36
32
  */
@@ -12,7 +12,7 @@ export declare class MicrophoneManager extends InputMediaDeviceManager<Microphon
12
12
  private noiseCancellation;
13
13
  private noiseCancellationChangeUnsubscribe;
14
14
  private noiseCancellationRegistration?;
15
- private unregisterNoiseCancellation?;
15
+ private uregisterNoiseCancellation?;
16
16
  constructor(call: Call, disableMode?: TrackDisableMode);
17
17
  /**
18
18
  * Enables noise cancellation for the microphone.
@@ -1,12 +1,14 @@
1
1
  import { Call } from '../Call';
2
2
  import { Dispatcher } from '../rtc';
3
+ import { CallState } from '../store';
3
4
  /**
4
5
  * Registers the default event handlers for a call during its lifecycle.
5
6
  *
6
7
  * @param call the call to register event handlers for.
8
+ * @param state the call state.
7
9
  * @param dispatcher the dispatcher.
8
10
  */
9
- export declare const registerEventHandlers: (call: Call, dispatcher: Dispatcher) => () => void;
11
+ export declare const registerEventHandlers: (call: Call, state: CallState, dispatcher: Dispatcher) => () => void;
10
12
  /**
11
13
  * Registers event handlers for a call that is of ringing type.
12
14
  *
@@ -22,7 +22,3 @@ export declare const watchSfuErrorReports: (dispatcher: Dispatcher) => () => voi
22
22
  * in the call.
23
23
  */
24
24
  export declare const watchPinsUpdated: (state: CallState) => (e: PinsChanged) => void;
25
- /**
26
- * Watches for `callEnded` events.
27
- */
28
- export declare const watchSfuCallEnded: (call: Call) => () => void;
@@ -193,23 +193,10 @@ export interface SfuEvent {
193
193
  * @generated from protobuf field: stream.video.sfu.event.ParticipantUpdated participant_updated = 24;
194
194
  */
195
195
  participantUpdated: ParticipantUpdated;
196
- } | {
197
- oneofKind: 'participantMigrationComplete';
198
- /**
199
- * ParticipantMigrationComplete is sent when the participant migration is complete
200
- *
201
- * @generated from protobuf field: stream.video.sfu.event.ParticipantMigrationComplete participant_migration_complete = 25;
202
- */
203
- participantMigrationComplete: ParticipantMigrationComplete;
204
196
  } | {
205
197
  oneofKind: undefined;
206
198
  };
207
199
  }
208
- /**
209
- * @generated from protobuf message stream.video.sfu.event.ParticipantMigrationComplete
210
- */
211
- export interface ParticipantMigrationComplete {
212
- }
213
200
  /**
214
201
  * @generated from protobuf message stream.video.sfu.event.PinsChanged
215
202
  */
@@ -280,29 +267,10 @@ export interface SfuRequest {
280
267
  * @generated from protobuf field: stream.video.sfu.event.HealthCheckRequest health_check_request = 2;
281
268
  */
282
269
  healthCheckRequest: HealthCheckRequest;
283
- } | {
284
- oneofKind: 'leaveCallRequest';
285
- /**
286
- * @generated from protobuf field: stream.video.sfu.event.LeaveCallRequest leave_call_request = 3;
287
- */
288
- leaveCallRequest: LeaveCallRequest;
289
270
  } | {
290
271
  oneofKind: undefined;
291
272
  };
292
273
  }
293
- /**
294
- * @generated from protobuf message stream.video.sfu.event.LeaveCallRequest
295
- */
296
- export interface LeaveCallRequest {
297
- /**
298
- * @generated from protobuf field: string session_id = 1;
299
- */
300
- sessionId: string;
301
- /**
302
- * @generated from protobuf field: string reason = 2;
303
- */
304
- reason: string;
305
- }
306
274
  /**
307
275
  * @generated from protobuf message stream.video.sfu.event.HealthCheckRequest
308
276
  */
@@ -398,10 +366,10 @@ export interface JoinRequest {
398
366
  */
399
367
  clientDetails?: ClientDetails;
400
368
  /**
401
- * Deprecated: use ReconnectDetails instead
369
+ * TODO: we should know if this is going to be
370
+ * - publishing and subscribing, or just subscribing for future routing
402
371
  *
403
- * @deprecated
404
- * @generated from protobuf field: stream.video.sfu.event.Migration migration = 5 [deprecated = true];
372
+ * @generated from protobuf field: stream.video.sfu.event.Migration migration = 5;
405
373
  */
406
374
  migration?: Migration;
407
375
  /**
@@ -415,45 +383,9 @@ export interface JoinRequest {
415
383
  * cached, the client state is not in sync and hence it must be cleaned up before
416
384
  * proceeding further.
417
385
  *
418
- * @deprecated
419
- * @generated from protobuf field: bool fast_reconnect = 6 [deprecated = true];
386
+ * @generated from protobuf field: bool fast_reconnect = 6;
420
387
  */
421
388
  fastReconnect: boolean;
422
- /**
423
- * @generated from protobuf field: stream.video.sfu.event.ReconnectDetails reconnect_details = 7;
424
- */
425
- reconnectDetails?: ReconnectDetails;
426
- }
427
- /**
428
- * @generated from protobuf message stream.video.sfu.event.ReconnectDetails
429
- */
430
- export interface ReconnectDetails {
431
- /**
432
- * @generated from protobuf field: stream.video.sfu.models.WebsocketReconnectStrategy strategy = 1;
433
- */
434
- strategy: WebsocketReconnectStrategy;
435
- /**
436
- * @generated from protobuf field: repeated stream.video.sfu.models.TrackInfo announced_tracks = 3;
437
- */
438
- announcedTracks: TrackInfo[];
439
- /**
440
- * @generated from protobuf field: repeated stream.video.sfu.signal.TrackSubscriptionDetails subscriptions = 4;
441
- */
442
- subscriptions: TrackSubscriptionDetails[];
443
- /**
444
- * @generated from protobuf field: uint32 reconnect_attempt = 5;
445
- */
446
- reconnectAttempt: number;
447
- /**
448
- * @generated from protobuf field: string from_sfu_id = 6;
449
- */
450
- fromSfuId: string;
451
- /**
452
- * only set in case of rejoin
453
- *
454
- * @generated from protobuf field: string previous_session_id = 7;
455
- */
456
- previousSessionId: string;
457
389
  }
458
390
  /**
459
391
  * @generated from protobuf message stream.video.sfu.event.Migration
@@ -484,10 +416,6 @@ export interface JoinResponse {
484
416
  * @generated from protobuf field: bool reconnected = 2;
485
417
  */
486
418
  reconnected: boolean;
487
- /**
488
- * @generated from protobuf field: int32 fast_reconnect_deadline_seconds = 3;
489
- */
490
- fastReconnectDeadlineSeconds: number;
491
419
  }
492
420
  /**
493
421
  * ParticipantJoined is fired when a user joins a call
@@ -829,16 +757,6 @@ declare class SfuEvent$Type extends MessageType<SfuEvent> {
829
757
  * @generated MessageType for protobuf message stream.video.sfu.event.SfuEvent
830
758
  */
831
759
  export declare const SfuEvent: SfuEvent$Type;
832
- declare class ParticipantMigrationComplete$Type extends MessageType<ParticipantMigrationComplete> {
833
- constructor();
834
- create(value?: PartialMessage<ParticipantMigrationComplete>): ParticipantMigrationComplete;
835
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ParticipantMigrationComplete): ParticipantMigrationComplete;
836
- internalBinaryWrite(message: ParticipantMigrationComplete, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
837
- }
838
- /**
839
- * @generated MessageType for protobuf message stream.video.sfu.event.ParticipantMigrationComplete
840
- */
841
- export declare const ParticipantMigrationComplete: ParticipantMigrationComplete$Type;
842
760
  declare class PinsChanged$Type extends MessageType<PinsChanged> {
843
761
  constructor();
844
762
  create(value?: PartialMessage<PinsChanged>): PinsChanged;
@@ -889,16 +807,6 @@ declare class SfuRequest$Type extends MessageType<SfuRequest> {
889
807
  * @generated MessageType for protobuf message stream.video.sfu.event.SfuRequest
890
808
  */
891
809
  export declare const SfuRequest: SfuRequest$Type;
892
- declare class LeaveCallRequest$Type extends MessageType<LeaveCallRequest> {
893
- constructor();
894
- create(value?: PartialMessage<LeaveCallRequest>): LeaveCallRequest;
895
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: LeaveCallRequest): LeaveCallRequest;
896
- internalBinaryWrite(message: LeaveCallRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
897
- }
898
- /**
899
- * @generated MessageType for protobuf message stream.video.sfu.event.LeaveCallRequest
900
- */
901
- export declare const LeaveCallRequest: LeaveCallRequest$Type;
902
810
  declare class HealthCheckRequest$Type extends MessageType<HealthCheckRequest> {
903
811
  constructor();
904
812
  create(value?: PartialMessage<HealthCheckRequest>): HealthCheckRequest;
@@ -949,16 +857,6 @@ declare class JoinRequest$Type extends MessageType<JoinRequest> {
949
857
  * @generated MessageType for protobuf message stream.video.sfu.event.JoinRequest
950
858
  */
951
859
  export declare const JoinRequest: JoinRequest$Type;
952
- declare class ReconnectDetails$Type extends MessageType<ReconnectDetails> {
953
- constructor();
954
- create(value?: PartialMessage<ReconnectDetails>): ReconnectDetails;
955
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ReconnectDetails): ReconnectDetails;
956
- internalBinaryWrite(message: ReconnectDetails, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
957
- }
958
- /**
959
- * @generated MessageType for protobuf message stream.video.sfu.event.ReconnectDetails
960
- */
961
- export declare const ReconnectDetails: ReconnectDetails$Type;
962
860
  declare class Migration$Type extends MessageType<Migration> {
963
861
  constructor();
964
862
  create(value?: PartialMessage<Migration>): Migration;