@stream-io/video-client 0.0.1-alpha.169 → 0.0.1-alpha.170

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.1-alpha.170](https://github.com/GetStream/stream-video-js/compare/client0.0.1-alpha.169...client0.0.1-alpha.170) (2023-05-22)
6
+
7
+
8
+ ### Features
9
+
10
+ * missing WS events and endpoints ([#527](https://github.com/GetStream/stream-video-js/issues/527)) ([1bb49f4](https://github.com/GetStream/stream-video-js/commit/1bb49f479485007dcc505066694d2e463ab00777))
11
+
12
+
13
+
5
14
  ## [0.0.1-alpha.169](https://github.com/GetStream/stream-video-js/compare/client0.0.1-alpha.168...client0.0.1-alpha.169) (2023-05-22)
6
15
 
7
16
 
@@ -7115,7 +7115,9 @@ const watchCallEnded = (call) => {
7115
7115
  return __awaiter(this, void 0, void 0, function* () {
7116
7116
  if (event.type !== 'call.ended')
7117
7117
  return;
7118
- if (call.state.callingState === CallingState.RINGING) {
7118
+ if (call.state.callingState === CallingState.RINGING ||
7119
+ call.state.callingState === CallingState.JOINED ||
7120
+ call.state.callingState === CallingState.JOINING) {
7119
7121
  yield call.leave();
7120
7122
  }
7121
7123
  });
@@ -7425,7 +7427,91 @@ const watchUnblockedUser = (state) => (event) => {
7425
7427
  });
7426
7428
  };
7427
7429
 
7430
+ /**
7431
+ * Watches for `call.live_started` events.
7432
+ */
7433
+ const watchCallLiveStarted = (state) => {
7434
+ return function onCallLiveStarted(event) {
7435
+ if (event.type !== 'call.live_started')
7436
+ return;
7437
+ state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { backstage: false })));
7438
+ };
7439
+ };
7440
+
7441
+ /**
7442
+ * Watches for `call.member_added` events.
7443
+ */
7444
+ const watchCallMemberAdded = (state) => {
7445
+ return function onCallMemberAdded(event) {
7446
+ if (event.type !== 'call.member_added')
7447
+ return;
7448
+ state.setMembers((members) => [...members, ...event.members]);
7449
+ };
7450
+ };
7451
+ /**
7452
+ * Watches for `call.member_removed` events.
7453
+ */
7454
+ const watchCallMemberRemoved = (state) => {
7455
+ return function onCallMemberRemoved(event) {
7456
+ if (event.type !== 'call.member_removed')
7457
+ return;
7458
+ state.setMembers((members) => members.filter((m) => event.members.indexOf(m.user_id) === -1));
7459
+ };
7460
+ };
7461
+ /**
7462
+ * Watches for `call.member_updated_permission` events.
7463
+ */
7464
+ const watchCallMemberUpdatedPermission = (state) => {
7465
+ return function onCallMemberUpdated(event) {
7466
+ if (event.type !== 'call.member_updated_permission')
7467
+ return;
7468
+ state.setMembers((members) => members.map((member) => {
7469
+ const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
7470
+ if (memberUpdate) {
7471
+ member.user.role = memberUpdate.role;
7472
+ member = Object.assign({}, member);
7473
+ }
7474
+ return member;
7475
+ }));
7476
+ };
7477
+ };
7478
+ /**
7479
+ * Watches for `call.member_updated` events.
7480
+ */
7481
+ const watchCallMemberUpdated = (state) => {
7482
+ return function onCallMemberUpdated(event) {
7483
+ if (event.type !== 'call.member_updated')
7484
+ return;
7485
+ state.setMembers((members) => members.map((member) => {
7486
+ const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
7487
+ return memberUpdate ? memberUpdate : member;
7488
+ }));
7489
+ };
7490
+ };
7491
+
7428
7492
  const registerEventHandlers = (call, state, dispatcher) => {
7493
+ const coordinatorEvents = {
7494
+ 'call.blocked_user': watchBlockedUser(state),
7495
+ 'call.broadcasting_started': watchCallBroadcastingStarted(state),
7496
+ 'call.broadcasting_stopped': watchCallBroadcastingStopped(state),
7497
+ 'call.ended': watchCallEnded(call),
7498
+ 'call.live_started': watchCallLiveStarted(state),
7499
+ 'call.member_added': watchCallMemberAdded(state),
7500
+ 'call.member_removed': watchCallMemberRemoved(state),
7501
+ 'call.member_updated': watchCallMemberUpdated(state),
7502
+ 'call.member_updated_permission': watchCallMemberUpdatedPermission(state),
7503
+ 'call.permission_request': watchCallPermissionRequest(state),
7504
+ 'call.permissions_updated': watchCallPermissionsUpdated(state),
7505
+ 'call.reaction_new': watchNewReactions(state),
7506
+ 'call.recording_started': watchCallRecordingStarted(state),
7507
+ 'call.recording_stopped': watchCallRecordingStopped(state),
7508
+ 'call.session_ended': (event) => console.log(`Received ${event.type} event`, event),
7509
+ 'call.session_participant_joined': (event) => console.log(`Received ${event.type} event`, event),
7510
+ 'call.session_participant_left': (event) => console.log(`Received ${event.type} event`, event),
7511
+ 'call.session_started': (event) => console.log(`Received ${event.type} event`, event),
7512
+ 'call.unblocked_user': watchUnblockedUser(state),
7513
+ 'call.updated': watchCallUpdated(state),
7514
+ };
7429
7515
  const eventHandlers = [
7430
7516
  watchChangePublishQuality(dispatcher, call),
7431
7517
  watchConnectionQualityChanged(dispatcher, state),
@@ -7436,18 +7522,12 @@ const registerEventHandlers = (call, state, dispatcher) => {
7436
7522
  watchTrackUnpublished(dispatcher, state),
7437
7523
  watchAudioLevelChanged(dispatcher, state),
7438
7524
  watchDominantSpeakerChanged(dispatcher, state),
7439
- call.on('call.updated', watchCallUpdated(state)),
7440
- call.on('call.blocked_user', watchBlockedUser(state)),
7441
- call.on('call.unblocked_user', watchUnblockedUser(state)),
7442
- call.on('call.reaction_new', watchNewReactions(state)),
7443
- call.on('call.recording_started', watchCallRecordingStarted(state)),
7444
- call.on('call.recording_stopped', watchCallRecordingStopped(state)),
7445
- call.on('call.broadcasting_started', watchCallBroadcastingStarted(state)),
7446
- call.on('call.broadcasting_stopped', watchCallBroadcastingStopped(state)),
7447
- call.on('call.permission_request', watchCallPermissionRequest(state)),
7448
- call.on('call.permissions_updated', watchCallPermissionsUpdated(state)),
7449
7525
  call.on('callGrantsUpdated', watchCallGrantsUpdated(state)),
7450
7526
  ];
7527
+ Object.keys(coordinatorEvents).forEach((event) => {
7528
+ const eventName = event;
7529
+ eventHandlers.push(call.on(eventName, coordinatorEvents[eventName]));
7530
+ });
7451
7531
  if (call.ringing) {
7452
7532
  // these events are only relevant when the call is ringing
7453
7533
  eventHandlers.push(registerRingingCallEventHandlers(call));
@@ -7457,11 +7537,14 @@ const registerEventHandlers = (call, state, dispatcher) => {
7457
7537
  };
7458
7538
  };
7459
7539
  const registerRingingCallEventHandlers = (call) => {
7460
- const eventHandlers = [
7461
- call.on('call.accepted', watchCallAccepted(call)),
7462
- call.on('call.rejected', watchCallRejected(call)),
7463
- call.on('call.ended', watchCallEnded(call)),
7464
- ];
7540
+ const coordinatorRingEvents = {
7541
+ 'call.accepted': watchCallAccepted(call),
7542
+ 'call.rejected': watchCallRejected(call),
7543
+ };
7544
+ const eventHandlers = Object.keys(coordinatorRingEvents).map((event) => {
7545
+ const eventName = event;
7546
+ return call.on(eventName, coordinatorRingEvents[eventName]);
7547
+ });
7465
7548
  return () => {
7466
7549
  eventHandlers.forEach((unsubscribe) => unsubscribe());
7467
7550
  };
@@ -8047,6 +8130,7 @@ class Call {
8047
8130
  */
8048
8131
  this.leave = ({ reject = false } = {}) => __awaiter(this, void 0, void 0, function* () {
8049
8132
  var _a, _b, _c, _d;
8133
+ // TODO: handle case when leave is called during JOINING
8050
8134
  const callingState = this.state.callingState;
8051
8135
  if (callingState === CallingState.LEFT) {
8052
8136
  throw new Error('Cannot leave call that has already been left.');
@@ -8306,7 +8390,10 @@ class Call {
8306
8390
  // this is a throw-away SDP that the SFU will use to determine
8307
8391
  // the capabilities of the client (codec support, etc.)
8308
8392
  .then(() => getGenericSdp('recvonly', isRedEnabled, this.streamClient.options.preferredVideoCodec))
8309
- .then((sdp) => sfuClient.join({ subscriberSdp: sdp || '' }));
8393
+ .then((sdp) => sfuClient.join({
8394
+ subscriberSdp: sdp || '',
8395
+ clientDetails,
8396
+ }));
8310
8397
  // 2. in parallel, wait for the SFU to send us the "joinResponse"
8311
8398
  // this will throw an error if the SFU rejects the join request or
8312
8399
  // fails to respond in time
@@ -8827,6 +8914,14 @@ class Call {
8827
8914
  pinnedAt,
8828
8915
  });
8829
8916
  };
8917
+ /**
8918
+ * Query call members with filter query. The result won't be stored in call state.
8919
+ * @param request
8920
+ * @returns
8921
+ */
8922
+ this.queryMembers = (request) => {
8923
+ return this.streamClient.post('/call/members', Object.assign(Object.assign({}, request), { id: this.id, type: this.type }));
8924
+ };
8830
8925
  this.scheduleAutoDrop = () => {
8831
8926
  const subscription = this.state.metadata$
8832
8927
  .pipe(pairwise(), tap(([prevMeta, currentMeta]) => {
@@ -10627,7 +10722,7 @@ class StreamClient {
10627
10722
  }
10628
10723
  getUserAgent() {
10629
10724
  return (this.userAgent ||
10630
- `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.1-alpha.168"}`);
10725
+ `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.1-alpha.169"}`);
10631
10726
  }
10632
10727
  setUserAgent(userAgent) {
10633
10728
  this.userAgent = userAgent;