@100mslive/hms-video-store 0.2.64 → 0.2.65

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.64",
2
+ "version": "0.2.65",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -55,11 +55,11 @@
55
55
  "zustand": "3.5.7"
56
56
  },
57
57
  "peerDependencies": {
58
- "@100mslive/hms-video": "^0.0.210",
58
+ "@100mslive/hms-video": "^0.1.0",
59
59
  "events": "^3.3.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@100mslive/hms-video": "^0.0.210",
62
+ "@100mslive/hms-video": "^0.1.0",
63
63
  "@size-limit/file": "^5.0.3",
64
64
  "events": "^3.3.0",
65
65
  "husky": "^6.0.0",
@@ -731,8 +731,8 @@ export class HMSSDKActions implements IHMSActions {
731
731
  track: SDKHMSTrack,
732
732
  peer: sdkTypes.HMSPeer,
733
733
  ) {
734
- // this check is needed because for track removed case, the store does not have
735
- // the track info to be sent as notification
734
+ // this check is needed because for track removed case, the notification needs to
735
+ // be send before the track is removed from store
736
736
  if (type === sdkTypes.HMSTrackUpdate.TRACK_REMOVED) {
737
737
  this.hmsNotifications.sendTrackUpdate(type, track.trackId);
738
738
  this.handleTrackRemove(track, peer);
@@ -1124,7 +1124,6 @@ export class HMSSDKActions implements IHMSActions {
1124
1124
  track: SDKHMSTrack,
1125
1125
  peer: sdkTypes.HMSPeer,
1126
1126
  ) => {
1127
- console.time('trackUpdate');
1128
1127
  this.setState(draftStore => {
1129
1128
  let draftPeer = draftStore.peers[peer.peerId];
1130
1129
  /**
@@ -1,27 +1,28 @@
1
1
  import {
2
- HMSTrack as SDKHMSTrack,
3
- HMSLocalVideoTrack as SDKHMSLocalVideoTrack,
4
2
  HMSLocalAudioTrack as SDKHMSLocalAudioTrack,
3
+ HMSLocalVideoTrack as SDKHMSLocalVideoTrack,
5
4
  HMSRemoteAudioTrack as SDKHMSRemoteAudioTrack,
6
5
  HMSRemoteVideoTrack as SDKHMSRemoteVideoTrack,
7
6
  HMSRoleChangeRequest as SDKHMSRoleChangeRequest,
7
+ HMSTrack as SDKHMSTrack,
8
8
  } from '@100mslive/hms-video';
9
9
  import {
10
- HMSPeer,
11
- HMSMessage,
12
- HMSTrack,
13
- HMSRoom,
14
- HMSRoleChangeStoreRequest,
15
- HMSException,
16
10
  HMSDeviceChangeEvent,
11
+ HMSException,
12
+ HMSMessage,
13
+ HMSPeer,
14
+ HMSPeerID,
17
15
  HMSPlaylistItem,
18
16
  HMSPlaylistType,
19
- HMSPeerID,
17
+ HMSRole,
18
+ HMSRoleChangeStoreRequest,
19
+ HMSRoleName,
20
+ HMSRoom,
21
+ HMSTrack,
20
22
  } from '../schema';
21
23
 
22
24
  import * as sdkTypes from './sdkTypes';
23
25
  import { areArraysEqual } from './sdkUtils/storeMergeUtils';
24
- import { HMSRole, HMSRoleName } from '../schema';
25
26
 
26
27
  export class SDKToHMS {
27
28
  static convertPeer(sdkPeer: sdkTypes.HMSPeer): Partial<HMSPeer> & Pick<HMSPeer, 'id'> {
@@ -61,10 +62,10 @@ export class SDKToHMS {
61
62
  track.width = mediaSettings.width;
62
63
  track.deviceID = mediaSettings.deviceId;
63
64
  if (sdkTrack instanceof SDKHMSRemoteAudioTrack) {
64
- const volume = sdkTrack.getVolume() || 0;
65
- track.volume = volume;
65
+ track.volume = sdkTrack.getVolume() || 0;
66
66
  }
67
67
  SDKToHMS.enrichVideoTrack(track, sdkTrack);
68
+ SDKToHMS.enrichPluginsDetails(track, sdkTrack);
68
69
  }
69
70
 
70
71
  static enrichVideoTrack(track: HMSTrack, sdkTrack: SDKHMSTrack) {
@@ -75,6 +76,9 @@ export class SDKToHMS {
75
76
  track.layerDefinitions = sdkTrack.getSimulcastDefinitions();
76
77
  }
77
78
  }
79
+ }
80
+
81
+ static enrichPluginsDetails(track: HMSTrack, sdkTrack: SDKHMSTrack) {
78
82
  if (sdkTrack instanceof SDKHMSLocalVideoTrack || sdkTrack instanceof SDKHMSLocalAudioTrack) {
79
83
  if (!areArraysEqual(sdkTrack.getPlugins(), track.plugins)) {
80
84
  track.plugins = sdkTrack.getPlugins();
@@ -44,6 +44,7 @@ export const mergeNewTracksInDraft = (
44
44
  const oldTrack = draftTracks[trackID];
45
45
  const newTrack = newTracks[trackID];
46
46
  if (isEntityUpdated(oldTrack, newTrack)) {
47
+ mergeTrackArrayFields(oldTrack, newTrack);
47
48
  Object.assign(oldTrack, newTrack);
48
49
  } else if (isEntityRemoved(oldTrack, newTrack)) {
49
50
  delete draftTracks[trackID];
@@ -53,13 +54,28 @@ export const mergeNewTracksInDraft = (
53
54
  }
54
55
  };
55
56
 
57
+ /**
58
+ * array's are usually created with new reference, avoid that update if both arrays are same
59
+ */
60
+ const mergeTrackArrayFields = (oldTrack: HMSTrack, newTrack: Partial<HMSTrack>) => {
61
+ if (oldTrack.plugins && areArraysEqual(oldTrack.plugins, newTrack.plugins)) {
62
+ newTrack.plugins = oldTrack.plugins;
63
+ }
64
+ if (
65
+ oldTrack.layerDefinitions &&
66
+ areArraysEqual(oldTrack.layerDefinitions, newTrack.layerDefinitions)
67
+ ) {
68
+ newTrack.layerDefinitions = oldTrack.layerDefinitions;
69
+ }
70
+ };
71
+
56
72
  const isEntityUpdated = <T>(oldItem: T, newItem: T) => oldItem && newItem;
57
73
  const isEntityRemoved = <T>(oldItem: T, newItem: T) => oldItem && !newItem;
58
74
  const isEntityAdded = <T>(oldItem: T, newItem: T) => !oldItem && newItem;
59
75
 
60
76
  // eslint-disable-next-line complexity
61
77
  export const areArraysEqual = <T>(arr1: T[], arr2?: T[]): boolean => {
62
- if (arr1 === arr2) {
78
+ if (arr1 === arr2 || (arr1.length === 0 && arr2?.length === 0)) {
63
79
  // reference check
64
80
  return true;
65
81
  }