@100mslive/hms-video-store 0.2.82-alpha.1 → 0.2.82-alpha.13

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 (55) hide show
  1. package/dist/core/IHMSActions.d.ts +1 -1
  2. package/dist/core/hmsSDKStore/HMSSDKActions.d.ts +1 -1
  3. package/dist/core/hmsSDKStore/sdkTypes.d.ts +3 -3
  4. package/dist/core/index.d.ts +2 -2
  5. package/dist/core/selectors/selectors.d.ts +3 -9
  6. package/dist/core/selectors/selectorsByID.d.ts +1 -1
  7. package/dist/core/selectors/selectorsByReference.d.ts +1 -1
  8. package/dist/hms-video-store.cjs.js +1 -1
  9. package/dist/hms-video-store.esm.js +1 -1
  10. package/package.json +5 -36
  11. package/src/common/ui-logger.ts +0 -88
  12. package/src/core/IHMSActions.ts +0 -317
  13. package/src/core/IHMSNotifications.ts +0 -16
  14. package/src/core/IHMSStore.ts +0 -59
  15. package/src/core/hmsSDKStore/HMSNotifications.ts +0 -170
  16. package/src/core/hmsSDKStore/HMSPlaylist.ts +0 -77
  17. package/src/core/hmsSDKStore/HMSReactiveStore.ts +0 -262
  18. package/src/core/hmsSDKStore/HMSSDKActions.ts +0 -1113
  19. package/src/core/hmsSDKStore/adapter.ts +0 -234
  20. package/src/core/hmsSDKStore/common/mapping.ts +0 -32
  21. package/src/core/hmsSDKStore/internalTypes.ts +0 -8
  22. package/src/core/hmsSDKStore/sdkTypes.ts +0 -51
  23. package/src/core/hmsSDKStore/sdkUtils/ActionBatcher.ts +0 -60
  24. package/src/core/hmsSDKStore/sdkUtils/sdkUtils.ts +0 -5
  25. package/src/core/hmsSDKStore/sdkUtils/storeMergeUtils.ts +0 -95
  26. package/src/core/index.ts +0 -16
  27. package/src/core/schema/device-change.ts +0 -14
  28. package/src/core/schema/error.ts +0 -13
  29. package/src/core/schema/index.ts +0 -11
  30. package/src/core/schema/message.ts +0 -35
  31. package/src/core/schema/notification.ts +0 -41
  32. package/src/core/schema/peer.ts +0 -72
  33. package/src/core/schema/playlist.ts +0 -114
  34. package/src/core/schema/requests.ts +0 -36
  35. package/src/core/schema/role.ts +0 -5
  36. package/src/core/schema/room.ts +0 -26
  37. package/src/core/schema/schema.ts +0 -94
  38. package/src/core/schema/settings.ts +0 -5
  39. package/src/core/selectors/derivedSelectors.ts +0 -75
  40. package/src/core/selectors/index.ts +0 -5
  41. package/src/core/selectors/playlistselectors.ts +0 -71
  42. package/src/core/selectors/selectorUtils.ts +0 -63
  43. package/src/core/selectors/selectors.ts +0 -347
  44. package/src/core/selectors/selectorsByID.ts +0 -370
  45. package/src/core/selectors/selectorsByReference.ts +0 -34
  46. package/src/index.ts +0 -1
  47. package/src/test/fakeStore.ts +0 -272
  48. package/src/test/fixtures.ts +0 -22
  49. package/src/test/integration/.gitkeep +0 -0
  50. package/src/test/unit/HMSNotifications.test.ts +0 -105
  51. package/src/test/unit/reactiveStore.test.ts +0 -129
  52. package/src/test/unit/roleSelectors.test.ts +0 -78
  53. package/src/test/unit/selectors.test.ts +0 -316
  54. package/src/test/unit/selectorsByReference.test.ts +0 -23
  55. package/src/test/unit/storeMergeUtils.test.ts +0 -165
@@ -1,234 +0,0 @@
1
- import {
2
- HMSLocalAudioTrack as SDKHMSLocalAudioTrack,
3
- HMSLocalVideoTrack as SDKHMSLocalVideoTrack,
4
- HMSRemoteAudioTrack as SDKHMSRemoteAudioTrack,
5
- HMSRemoteVideoTrack as SDKHMSRemoteVideoTrack,
6
- HMSRoleChangeRequest as SDKHMSRoleChangeRequest,
7
- HMSTrack as SDKHMSTrack,
8
- } from '@100mslive/hms-video';
9
- import {
10
- HMSDeviceChangeEvent,
11
- HMSException,
12
- HMSMessage,
13
- HMSPeer,
14
- HMSPeerID,
15
- HMSPlaylistItem,
16
- HMSPlaylistType,
17
- HMSRole,
18
- HMSRoleChangeStoreRequest,
19
- HMSRoleName,
20
- HMSRoom,
21
- HMSTrack,
22
- } from '../schema';
23
-
24
- import * as sdkTypes from './sdkTypes';
25
- import { areArraysEqual } from './sdkUtils/storeMergeUtils';
26
-
27
- export class SDKToHMS {
28
- static convertPeer(sdkPeer: sdkTypes.HMSPeer): Partial<HMSPeer> & Pick<HMSPeer, 'id'> {
29
- return {
30
- id: sdkPeer.peerId,
31
- name: sdkPeer.name,
32
- roleName: sdkPeer.role?.name,
33
- isLocal: sdkPeer.isLocal,
34
- videoTrack: sdkPeer.videoTrack?.trackId,
35
- audioTrack: sdkPeer.audioTrack?.trackId,
36
- auxiliaryTracks: sdkPeer.auxiliaryTracks.map(track => track.trackId),
37
- customerUserId: sdkPeer.customerUserId,
38
- customerDescription: sdkPeer.metadata,
39
- metadata: sdkPeer.metadata,
40
- };
41
- }
42
-
43
- static convertTrack(sdkTrack: SDKHMSTrack, peerId?: HMSPeerID): HMSTrack {
44
- const track: HMSTrack = {
45
- id: sdkTrack.trackId,
46
- source: sdkTrack.source,
47
- type: sdkTrack.type,
48
- enabled: sdkTrack.enabled,
49
- displayEnabled: sdkTrack.enabled,
50
- peerId: sdkTrack.peerId || peerId,
51
- };
52
- this.enrichTrack(track, sdkTrack);
53
- return track;
54
- }
55
-
56
- static enrichTrack(track: HMSTrack, sdkTrack: SDKHMSTrack) {
57
- const mediaSettings = sdkTrack.getMediaTrackSettings();
58
- if (track.source === 'screen' && track.type === 'video') {
59
- // @ts-ignore
60
- track.displaySurface = mediaSettings.displaySurface;
61
- }
62
- track.height = mediaSettings.height;
63
- track.width = mediaSettings.width;
64
- if (sdkTrack instanceof SDKHMSRemoteAudioTrack) {
65
- track.volume = sdkTrack.getVolume() || 0;
66
- }
67
- SDKToHMS.updateDeviceID(track, sdkTrack);
68
- SDKToHMS.enrichVideoTrack(track, sdkTrack);
69
- SDKToHMS.enrichPluginsDetails(track, sdkTrack);
70
- }
71
-
72
- static updateDeviceID(track: HMSTrack, sdkTrack: SDKHMSTrack) {
73
- if (sdkTrack instanceof SDKHMSLocalVideoTrack || sdkTrack instanceof SDKHMSLocalAudioTrack) {
74
- track.deviceID = sdkTrack.settings.deviceId;
75
- } else {
76
- track.deviceID = sdkTrack.getMediaTrackSettings()?.deviceId;
77
- }
78
- }
79
-
80
- static enrichVideoTrack(track: HMSTrack, sdkTrack: SDKHMSTrack) {
81
- if (sdkTrack instanceof SDKHMSRemoteVideoTrack) {
82
- track.layer = sdkTrack.getSimulcastLayer();
83
- track.degraded = sdkTrack.degraded;
84
- if (!areArraysEqual(sdkTrack.getSimulcastDefinitions(), track.layerDefinitions)) {
85
- track.layerDefinitions = sdkTrack.getSimulcastDefinitions();
86
- }
87
- }
88
- }
89
-
90
- static enrichPluginsDetails(track: HMSTrack, sdkTrack: SDKHMSTrack) {
91
- if (sdkTrack instanceof SDKHMSLocalVideoTrack || sdkTrack instanceof SDKHMSLocalAudioTrack) {
92
- if (!areArraysEqual(sdkTrack.getPlugins(), track.plugins)) {
93
- track.plugins = sdkTrack.getPlugins();
94
- }
95
- }
96
- }
97
-
98
- static convertRoom(sdkRoom: sdkTypes.HMSRoom): Partial<HMSRoom> {
99
- return {
100
- id: sdkRoom.id,
101
- name: sdkRoom.name,
102
- localPeer: sdkRoom.localPeer?.peerId ?? '',
103
- hasWaitingRoom: sdkRoom.hasWaitingRoom,
104
- shareableLink: sdkRoom.shareableLink,
105
- recording: {
106
- browser: {
107
- running: !!sdkRoom.recording?.browser.running,
108
- },
109
- server: { running: !!sdkRoom.recording?.server.running },
110
- },
111
- rtmp: { running: !!sdkRoom.rtmp?.running },
112
- };
113
- }
114
-
115
- static convertMessage(sdkMessage: sdkTypes.HMSMessage): Partial<HMSMessage> & Pick<HMSMessage, 'sender'> {
116
- return {
117
- sender: sdkMessage.sender.peerId,
118
- senderName: sdkMessage.sender.name,
119
- senderRole: sdkMessage.sender.role?.name,
120
- senderUserId: sdkMessage.sender.customerUserId,
121
- recipientPeer: sdkMessage.recipientPeer?.peerId,
122
- recipientRoles: sdkMessage.recipientRoles?.map(role => role.name),
123
- time: sdkMessage.time,
124
- type: sdkMessage.type,
125
- message: sdkMessage.message,
126
- };
127
- }
128
-
129
- static convertRoles(sdkRoles: HMSRole[]): Record<HMSRoleName, HMSRole> {
130
- const roles: Record<HMSRoleName, HMSRole> = {};
131
- if (sdkRoles) {
132
- sdkRoles.forEach(role => {
133
- roles[role.name] = role;
134
- });
135
- }
136
- return roles;
137
- }
138
-
139
- static convertRoleChangeRequest(req: SDKHMSRoleChangeRequest): HMSRoleChangeStoreRequest {
140
- return {
141
- requestedBy: req.requestedBy.peerId,
142
- roleName: req.role.name,
143
- token: req.token,
144
- };
145
- }
146
-
147
- static convertException(sdkException: sdkTypes.HMSException): HMSException {
148
- return {
149
- code: sdkException.code,
150
- action: sdkException.action,
151
- name: sdkException.name,
152
- message: sdkException.message,
153
- description: sdkException.description,
154
- isTerminal: sdkException.isTerminal,
155
- nativeError: sdkException.nativeError,
156
- timestamp: new Date(),
157
- };
158
- }
159
-
160
- static convertDeviceChangeUpdate(sdkDeviceChangeEvent: sdkTypes.HMSDeviceChangeEvent): HMSDeviceChangeEvent {
161
- const convertedData: HMSDeviceChangeEvent = {
162
- devices: sdkDeviceChangeEvent.devices,
163
- selection: sdkDeviceChangeEvent.selection,
164
- type: sdkDeviceChangeEvent.type,
165
- };
166
- if (sdkDeviceChangeEvent.error) {
167
- convertedData.error = this.convertException(sdkDeviceChangeEvent.error);
168
- }
169
- return convertedData;
170
- }
171
-
172
- static convertPlaylist(playlistManager: sdkTypes.HMSPlaylistManager) {
173
- const audioPlaylist = this.getConvertedPlaylistType(playlistManager, HMSPlaylistType.audio);
174
- const videoPlaylist = this.getConvertedPlaylistType(playlistManager, HMSPlaylistType.video);
175
- return { audio: audioPlaylist, video: videoPlaylist };
176
- }
177
-
178
- static convertPlaylistItem<T>(
179
- playlistManager: sdkTypes.HMSPlaylistManager,
180
- playlistItem: sdkTypes.HMSPlaylistItem<T>,
181
- ): HMSPlaylistItem<T> {
182
- const type = playlistItem.type;
183
- const currentSelection = playlistManager.getCurrentSelection(type);
184
- const isPlaying = playlistManager.isPlaying(type);
185
- const isSelected = playlistItem.url === currentSelection?.url;
186
-
187
- return {
188
- ...playlistItem,
189
- type: playlistItem.type as HMSPlaylistType,
190
- selected: isSelected,
191
- playing: isSelected && isPlaying,
192
- };
193
- }
194
-
195
- private static getConvertedPlaylistType(playlistManager: sdkTypes.HMSPlaylistManager, type: HMSPlaylistType) {
196
- const convertedPlaylist: Record<string, HMSPlaylistItem<any>> = {};
197
- const currentSelection = playlistManager.getCurrentSelection(type);
198
- const progress = playlistManager.getCurrentProgress(type);
199
- const volume = playlistManager.getVolume(type);
200
- const list = playlistManager.getList(type);
201
- const currentIndex = playlistManager.getCurrentIndex(type);
202
-
203
- playlistManager.getList(type).forEach(playlistItem => {
204
- convertedPlaylist[playlistItem.id] = SDKToHMS.convertPlaylistItem(playlistManager, playlistItem);
205
- });
206
- return {
207
- list: convertedPlaylist,
208
- selection: {
209
- id: currentSelection?.id,
210
- hasPrevious: currentIndex > 0,
211
- hasNext: currentIndex < list.length - 1,
212
- },
213
- progress,
214
- volume,
215
- currentTime: playlistManager.getCurrentTime(type),
216
- playbackRate: playlistManager.getPlaybackRate(type),
217
- };
218
- }
219
-
220
- static convertRecordingRTMPState(
221
- recording: sdkTypes.HMSRecording | undefined,
222
- rtmp: sdkTypes.HMSRTMP | undefined,
223
- ): { recording: sdkTypes.HMSRecording; rtmp: sdkTypes.HMSRTMP } {
224
- return {
225
- recording: {
226
- browser: {
227
- running: !!recording?.browser?.running,
228
- },
229
- server: { running: !!recording?.server?.running },
230
- },
231
- rtmp: { running: !!rtmp?.running },
232
- };
233
- }
234
- }
@@ -1,32 +0,0 @@
1
- import * as sdkTypes from '../sdkTypes';
2
- import { HMSNotificationTypes } from '../../schema';
3
-
4
- interface notifcationMap {
5
- [key: number]: string;
6
- }
7
-
8
- export const PEER_NOTIFICATION_TYPES: notifcationMap = {
9
- [sdkTypes.HMSPeerUpdate.PEER_JOINED]: HMSNotificationTypes.PEER_JOINED,
10
- [sdkTypes.HMSPeerUpdate.PEER_LEFT]: HMSNotificationTypes.PEER_LEFT,
11
- [sdkTypes.HMSPeerUpdate.ROLE_UPDATED]: HMSNotificationTypes.ROLE_UPDATED,
12
- [sdkTypes.HMSPeerUpdate.AUDIO_TOGGLED]: 'PEER_AUDIO_UPDATED',
13
- [sdkTypes.HMSPeerUpdate.VIDEO_TOGGLED]: 'PEER_VIDEO_UPDATED',
14
- [sdkTypes.HMSPeerUpdate.NAME_UPDATED]: HMSNotificationTypes.NAME_UPDATED,
15
- [sdkTypes.HMSPeerUpdate.METADATA_UPDATED]: HMSNotificationTypes.METADATA_UPDATED,
16
- };
17
-
18
- export const TRACK_NOTIFICATION_TYPES: notifcationMap = {
19
- [sdkTypes.HMSTrackUpdate.TRACK_ADDED]: HMSNotificationTypes.TRACK_ADDED,
20
- [sdkTypes.HMSTrackUpdate.TRACK_REMOVED]: HMSNotificationTypes.TRACK_REMOVED,
21
- [sdkTypes.HMSTrackUpdate.TRACK_MUTED]: HMSNotificationTypes.TRACK_MUTED,
22
- [sdkTypes.HMSTrackUpdate.TRACK_UNMUTED]: HMSNotificationTypes.TRACK_UNMUTED,
23
- [sdkTypes.HMSTrackUpdate.TRACK_DEGRADED]: HMSNotificationTypes.TRACK_DEGRADED,
24
- [sdkTypes.HMSTrackUpdate.TRACK_RESTORED]: HMSNotificationTypes.TRACK_RESTORED,
25
- };
26
-
27
- export const ACTION_TYPES: notifcationMap = {
28
- [sdkTypes.HMSPeerUpdate.PEER_JOINED]: 'peerJoined',
29
- [sdkTypes.HMSPeerUpdate.PEER_LEFT]: 'peerLeft',
30
- [sdkTypes.HMSPeerUpdate.NAME_UPDATED]: 'peerNameUpdated',
31
- [sdkTypes.HMSPeerUpdate.METADATA_UPDATED]: 'peerMetadataUpdated',
32
- };
@@ -1,8 +0,0 @@
1
- import { PartialState, State } from 'zustand/vanilla';
2
-
3
- export type NamedSetState<T extends State> = {
4
- <K1 extends keyof T, K2 extends keyof T = K1, K3 extends keyof T = K2, K4 extends keyof T = K3>(
5
- partial: PartialState<T, K1, K2, K3, K4>,
6
- name?: string,
7
- ): void;
8
- };
@@ -1,51 +0,0 @@
1
- import {
2
- HMSException,
3
- HMSSimulcastLayer,
4
- HMSPeerUpdate,
5
- HMSRoomUpdate,
6
- HMSTrackUpdate,
7
- HMSAudioTrackSettings,
8
- HMSVideoTrackSettings,
9
- HMSPeer,
10
- HMSRoom,
11
- HMSMessage,
12
- HMSConfig,
13
- HMSSpeaker,
14
- HMSRole,
15
- HMSLocalPeer,
16
- HMSRemotePeer,
17
- SimulcastLayerDefinition,
18
- DeviceMap,
19
- HMSLogLevel,
20
- HMSDeviceChangeEvent,
21
- HMSPlaylistItem,
22
- HMSPlaylistManager,
23
- HMSPlaylistProgressEvent,
24
- RTMPRecordingConfig,
25
- HMSRecording,
26
- HMSRTMP,
27
- } from '@100mslive/hms-video';
28
-
29
- export { HMSException, HMSSimulcastLayer, HMSRoomUpdate, HMSPeerUpdate, HMSTrackUpdate, HMSLogLevel };
30
-
31
- export type {
32
- DeviceMap,
33
- HMSPeer,
34
- HMSRoom,
35
- HMSMessage,
36
- HMSSpeaker,
37
- HMSConfig,
38
- HMSAudioTrackSettings,
39
- HMSVideoTrackSettings,
40
- HMSRole,
41
- HMSLocalPeer,
42
- HMSRemotePeer,
43
- SimulcastLayerDefinition,
44
- HMSDeviceChangeEvent,
45
- HMSPlaylistItem,
46
- HMSPlaylistManager,
47
- HMSPlaylistProgressEvent,
48
- RTMPRecordingConfig,
49
- HMSRecording,
50
- HMSRTMP,
51
- };
@@ -1,60 +0,0 @@
1
- import { HMSStore } from '../../schema';
2
- import { IHMSStore } from '../../IHMSStore';
3
- import { HMSLogger } from '../../../common/ui-logger';
4
-
5
- type ActionName = string;
6
- type SetTimeOutId = number;
7
- type SetState = (store: HMSStore) => void;
8
-
9
- /**
10
- * pass in an action and an update function, the update functions will be batched and run such that
11
- * store updates are limited to only one action in a time interval
12
- *
13
- */
14
- export class ActionBatcher {
15
- private queuedUpdates: Record<ActionName, SetState[]> = {};
16
- private timers: Record<ActionName, SetTimeOutId> = {};
17
- private DEFAULT_INTERVAL_MS = 50;
18
- private store: IHMSStore;
19
- constructor(store: IHMSStore) {
20
- this.store = store;
21
- }
22
-
23
- setState(fn: SetState, action: ActionName) {
24
- this.queuedUpdates[action] = this.queuedUpdates[action] || [];
25
- this.queuedUpdates[action].push(fn);
26
- if (this.timers[action]) {
27
- return;
28
- }
29
- // set a future timeout if a timer is not there already
30
- if (window) {
31
- this.timers[action] = window.setTimeout(() => this.setStateBatched(action), this.DEFAULT_INTERVAL_MS);
32
- } else {
33
- // nodejs, ignore batching for now
34
- this.setStateBatched(action);
35
- }
36
- }
37
-
38
- private setStateBatched(action: ActionName) {
39
- if (this.queuedUpdates[action]?.length > 0) {
40
- const batchedFn = (draftStore: HMSStore) => {
41
- this.queuedUpdates[action].forEach(fn => {
42
- try {
43
- fn(draftStore);
44
- } catch (err) {
45
- HMSLogger.w('failed to update store', err);
46
- }
47
- });
48
- };
49
- console.time(`timed-${action}`);
50
- this.store.namedSetState(batchedFn, action);
51
- console.timeEnd(`timed-${action}`);
52
- }
53
- // cleanup
54
- delete this.queuedUpdates[action];
55
- if (window && this.timers[action]) {
56
- window.clearTimeout(this.timers[action]);
57
- delete this.timers[action];
58
- }
59
- }
60
- }
@@ -1,5 +0,0 @@
1
- import { HMSTrack, HMSRemoteAudioTrack, HMSRemoteVideoTrack } from '@100mslive/hms-video';
2
-
3
- export function isRemoteTrack(track: HMSTrack) {
4
- return track instanceof HMSRemoteAudioTrack || track instanceof HMSRemoteVideoTrack;
5
- }
@@ -1,95 +0,0 @@
1
- import { HMSPeer, HMSPeerID, HMSTrack, HMSTrackID } from '../../schema';
2
-
3
- /**
4
- * updates draftPeers with newPeers ensuring minimal reference changes
5
- * @remarks
6
- * This is mutable and impure function, it modifies the passed in data to ensure
7
- * minimal reference changes
8
- * @param draftPeers the current peers object in store, an immer draft object
9
- * @param newPeers the latest update which needs to be stored
10
- * @param newHmsTracks this will be update if required
11
- * @param newHmsSDkTracks this is future value of local hms tacks map
12
- */
13
- export const mergeNewPeersInDraft = (
14
- draftPeers: Record<HMSPeerID, HMSPeer>,
15
- newPeers: Record<HMSPeerID, Partial<HMSPeer>>,
16
- ) => {
17
- const peerIDs = union(Object.keys(draftPeers), Object.keys(newPeers));
18
- for (const peerID of peerIDs) {
19
- const oldPeer = draftPeers[peerID];
20
- const newPeer = newPeers[peerID];
21
- if (isEntityUpdated(oldPeer, newPeer)) {
22
- if (areArraysEqual(oldPeer.auxiliaryTracks, newPeer.auxiliaryTracks)) {
23
- newPeer.auxiliaryTracks = oldPeer.auxiliaryTracks;
24
- }
25
- Object.assign(oldPeer, newPeer);
26
- } else if (isEntityRemoved(oldPeer, newPeer)) {
27
- delete draftPeers[peerID];
28
- } else if (isEntityAdded(oldPeer, newPeer)) {
29
- draftPeers[peerID] = newPeer as HMSPeer;
30
- }
31
- }
32
- };
33
-
34
- export const mergeNewTracksInDraft = (
35
- draftTracks: Record<HMSTrackID, HMSTrack>,
36
- newTracks: Record<HMSTrackID, Partial<HMSTrack>>,
37
- ) => {
38
- const trackIDs = union(Object.keys(draftTracks), Object.keys(newTracks));
39
- for (const trackID of trackIDs) {
40
- const oldTrack = draftTracks[trackID];
41
- const newTrack = newTracks[trackID];
42
- if (isEntityUpdated(oldTrack, newTrack)) {
43
- mergeTrackArrayFields(oldTrack, newTrack);
44
- Object.assign(oldTrack, newTrack);
45
- } else if (isEntityRemoved(oldTrack, newTrack)) {
46
- delete draftTracks[trackID];
47
- } else if (isEntityAdded(oldTrack, newTrack)) {
48
- draftTracks[trackID] = newTrack as HMSTrack;
49
- }
50
- }
51
- };
52
-
53
- /**
54
- * array's are usually created with new reference, avoid that update if both arrays are same
55
- */
56
- const mergeTrackArrayFields = (oldTrack: HMSTrack, newTrack: Partial<HMSTrack>) => {
57
- if (oldTrack.plugins && areArraysEqual(oldTrack.plugins, newTrack.plugins)) {
58
- newTrack.plugins = oldTrack.plugins;
59
- }
60
- if (oldTrack.layerDefinitions && areArraysEqual(oldTrack.layerDefinitions, newTrack.layerDefinitions)) {
61
- newTrack.layerDefinitions = oldTrack.layerDefinitions;
62
- }
63
- };
64
-
65
- const isEntityUpdated = <T>(oldItem: T, newItem: T) => oldItem && newItem;
66
- const isEntityRemoved = <T>(oldItem: T, newItem: T) => oldItem && !newItem;
67
- const isEntityAdded = <T>(oldItem: T, newItem: T) => !oldItem && newItem;
68
-
69
- // eslint-disable-next-line complexity
70
- export const areArraysEqual = <T>(arr1: T[], arr2?: T[]): boolean => {
71
- if (arr1 === arr2 || (arr1.length === 0 && arr2?.length === 0)) {
72
- // reference check
73
- return true;
74
- }
75
- if (!arr1 || !arr2 || !(arr1.length === arr2.length)) {
76
- return false;
77
- }
78
- for (let i = 0; i < arr1.length; i++) {
79
- if (arr1[i] !== arr2[i]) {
80
- return false;
81
- }
82
- }
83
- return true;
84
- };
85
-
86
- const union = <T>(arr1: T[], arr2: T[]): T[] => {
87
- const set: Set<T> = new Set();
88
- for (const elem of arr1) {
89
- set.add(elem);
90
- }
91
- for (const elem of arr2) {
92
- set.add(elem);
93
- }
94
- return Array.from(set);
95
- };
package/src/core/index.ts DELETED
@@ -1,16 +0,0 @@
1
- export type { IHMSStore, IHMSStoreReadOnly as HMSStoreWrapper } from './IHMSStore';
2
- export type { IHMSActions as HMSActions } from './IHMSActions';
3
- export type { IHMSNotifications as HMSNotifications } from './IHMSNotifications';
4
- export { HMSReactiveStore } from './hmsSDKStore/HMSReactiveStore';
5
- export * from './schema';
6
- export * from './selectors';
7
- export type { HMSLogLevel, RTMPRecordingConfig, HMSRecording, HMSRTMP } from './hmsSDKStore/sdkTypes';
8
-
9
- export type {
10
- HMSConfig,
11
- HMSAudioTrackSettings,
12
- HMSVideoTrackSettings,
13
- HMSSimulcastLayer,
14
- SimulcastLayerDefinition,
15
- DeviceMap,
16
- } from './hmsSDKStore/sdkTypes';
@@ -1,14 +0,0 @@
1
- import { DeviceMap } from '../hmsSDKStore/sdkTypes';
2
- import { HMSException } from './error';
3
-
4
- /**
5
- * Test fails when adding InputDeviceInfo[error TS2304: Cannot find name 'InputDeviceInfo'.]
6
- * InputDeviceInfo extends MediaDeviceInfo. See https://w3c.github.io/mediacapture-main/#input-specific-device-info
7
- * So, `selection?: MediaDeviceInfo` instead of `selection?: InputDeviceInfo | MediaDeviceInfo` is valid
8
- */
9
- export interface HMSDeviceChangeEvent {
10
- error?: HMSException;
11
- devices: DeviceMap;
12
- selection?: MediaDeviceInfo;
13
- type: 'audioOutput' | 'audioInput' | 'video';
14
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * any mid call error notification will be in this format
3
- */
4
- export interface HMSException {
5
- code: number;
6
- action: string;
7
- name: string;
8
- message: string;
9
- description: string;
10
- isTerminal: boolean;
11
- timestamp: Date;
12
- nativeError?: Error;
13
- }
@@ -1,11 +0,0 @@
1
- export * from './schema';
2
- export * from './room';
3
- export * from './peer';
4
- export * from './message';
5
- export * from './settings';
6
- export * from './notification';
7
- export * from './role';
8
- export * from './error';
9
- export * from './requests';
10
- export * from './device-change';
11
- export * from './playlist';
@@ -1,35 +0,0 @@
1
- import { HMSPeerID } from './peer';
2
- import { HMSRoleName } from './role';
3
-
4
- export type HMSMessageID = string;
5
-
6
- /**
7
- * @internal
8
- */
9
- export enum HMSMessageType {
10
- CHAT = 'chat',
11
- }
12
-
13
- export interface HMSMessage {
14
- id: HMSMessageID;
15
- sender: HMSPeerID;
16
- senderName: string;
17
- senderUserId?: string;
18
- senderRole?: string;
19
- recipientPeer?: HMSPeerID;
20
- recipientRoles?: HMSRoleName[];
21
- time: Date;
22
- read: boolean;
23
- type: string;
24
- message: any;
25
- }
26
-
27
- /**
28
- * @internal
29
- */
30
- export interface HMSMessageInput {
31
- recipientPeer?: HMSPeerID;
32
- recipientRoles?: HMSRoleName[];
33
- type?: string;
34
- message: any;
35
- }
@@ -1,41 +0,0 @@
1
- export interface HMSNotification {
2
- id: number;
3
- type: string;
4
- message: string;
5
- /**
6
- * HMSPeer | HMSTrack | HMSMessage | HMSException
7
- */
8
- data?: any;
9
- severity?: HMSNotificationSeverity;
10
- }
11
- export enum HMSNotificationSeverity {
12
- INFO = 'info',
13
- ERROR = 'error',
14
- CRITICAL = 'critical',
15
- }
16
-
17
- export enum HMSNotificationTypes {
18
- PEER_JOINED = 'PEER_JOINED',
19
- PEER_LEFT = 'PEER_LEFT',
20
- PEER_LIST = 'PEER_LIST',
21
- NEW_MESSAGE = 'NEW_MESSAGE',
22
- ERROR = 'ERROR',
23
- RECONNECTING = 'RECONNECTING',
24
- RECONNECTED = 'RECONNECTED',
25
- TRACK_ADDED = 'TRACK_ADDED',
26
- TRACK_REMOVED = 'TRACK_REMOVED',
27
- TRACK_MUTED = 'TRACK_MUTED',
28
- TRACK_UNMUTED = 'TRACK_UNMUTED',
29
- TRACK_DEGRADED = 'TRACK_DEGRADED',
30
- TRACK_RESTORED = 'TRACK_RESTORED',
31
- ROLE_CHANGE_REQUEST = 'ROLE_CHANGE_REQUEST',
32
- ROLE_UPDATED = 'ROLE_UPDATED',
33
- CHANGE_TRACK_STATE_REQUEST = 'CHANGE_TRACK_STATE_REQUEST',
34
- CHANGE_MULTI_TRACK_STATE_REQUEST = 'CHANGE_MULTI_TRACK_STATE_REQUEST',
35
- ROOM_ENDED = 'ROOM_ENDED',
36
- REMOVED_FROM_ROOM = 'REMOVED_FROM_ROOM',
37
- DEVICE_CHANGE_UPDATE = 'DEVICE_CHANGE_UPDATE',
38
- PLAYLIST_TRACK_ENDED = 'PLAYLIST_TRACK_ENDED',
39
- NAME_UPDATED = 'NAME_UPDATED',
40
- METADATA_UPDATED = 'METADATA_UPDATED',
41
- }