Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@100mslive/hms-video-store

Package Overview
Dependencies
Maintainers
12
Versions
730
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@100mslive/hms-video-store - npm Package Compare versions

Comparing version 0.1.10 to 0.1.11

14

dist/core/selectors/selectorsByID.d.ts
import { HMSStore, HMSTrack } from '../schema';
export declare const selectPeerByID: (id: string) => (store: HMSStore) => import("../schema").HMSPeer | null;
export declare const selectPeerNameByID: (id: string) => (store: HMSStore) => string | undefined;
export declare const selectPeerAudioByID: (id: string) => (store: HMSStore) => number;
export declare const selectScreenShareByPeerID: (id: string) => (store: HMSStore) => HMSTrack | undefined;
export declare const selectCameraStreamByPeerID: (id: string) => (store: HMSStore) => HMSTrack | undefined;
export declare const selectIsPeerAudioEnabled: (id: string) => (store: HMSStore) => boolean;
export declare const selectIsPeerVideoEnabled: (id: string) => (store: HMSStore) => boolean;
export declare const selectPeerByID: (id?: string | undefined) => (store: HMSStore) => import("../schema").HMSPeer | null;
export declare const selectPeerNameByID: (id?: string | undefined) => (store: HMSStore) => string | undefined;
export declare const selectPeerAudioByID: (id?: string | undefined) => (store: HMSStore) => number;
export declare const selectScreenShareByPeerID: (id?: string | undefined) => (store: HMSStore) => HMSTrack | undefined;
export declare const selectCameraStreamByPeerID: (id?: string | undefined) => (store: HMSStore) => HMSTrack | undefined;
export declare const selectIsPeerAudioEnabled: (id?: string | undefined) => (store: HMSStore) => boolean;
export declare const selectIsPeerVideoEnabled: (id?: string | undefined) => (store: HMSStore) => boolean;

@@ -1,2 +0,2 @@

import { HMSPeer, HMSStore, HMSTrack } from "../schema";
import { HMSPeer, HMSStore, HMSTrack } from '../schema';
export declare function isScreenSharing(store: HMSStore, peer: HMSPeer): boolean;

@@ -3,0 +3,0 @@ export declare function isScreenShare(track: HMSTrack | undefined): boolean | undefined;

{
"version": "0.1.10",
"version": "0.1.11",
"license": "MIT",

@@ -19,2 +19,3 @@ "main": "dist/index.js",

"lint": "tsdx lint",
"lint:fix": "tsdx lint --fix",
"prepare": "tsdx build",

@@ -21,0 +22,0 @@ "size": "size-limit",

@@ -1,4 +0,4 @@

import {HMSMessage, HMSPeer, HMSPeerID, HMSRoom, HMSStore} from '../schema';
import { HMSMessage, HMSPeer, HMSPeerID, HMSRoom, HMSStore } from '../schema';
import { createSelector } from 'reselect';
import {isScreenSharing, isTrackDisplayEnabled, isTrackEnabled} from "./selectorUtils";
import { isScreenSharing, isTrackDisplayEnabled, isTrackEnabled } from './selectorUtils';

@@ -15,25 +15,25 @@ const selectRoom = (store: HMSStore): HMSRoom => store.room;

export const selectMaxTilesCount = createSelector(
selectLocalMediaSettings,
settings => settings.maxTileCount,
selectLocalMediaSettings,
settings => settings.maxTileCount,
);
const selectSpeakers = (store: HMSStore) => {
return store.speakers;
return store.speakers;
};
export const selectIsConnectedToRoom = createSelector(
[selectRoom],
room => room && room.isConnected,
[selectRoom],
room => room && room.isConnected,
);
export const selectPeers = createSelector([selectRoom, selectPeersMap], (room, storePeers) => {
return room.peers.map(peerID => storePeers[peerID]);
return room.peers.map(peerID => storePeers[peerID]);
});
export const selectLocalPeer = createSelector(selectPeers, peers => {
return peers.filter(p => p.isLocal)[0];
return peers.filter(p => p.isLocal)[0];
});
export const selectLocalPeerID = createSelector(selectLocalPeer, peer => {
return peer.id;
return peer.id;
});

@@ -45,81 +45,78 @@

export const selectRemotePeers = createSelector(selectPeers, peers => {
return peers.filter(p => !p.isLocal);
return peers.filter(p => !p.isLocal);
});
export const selectDominantSpeakerName = createSelector(
selectPeersMap,
selectSpeakers,
(peersMap, speakers) => {
// sort in descending order by audio level
const speakersInOrder = Object.entries(speakers).sort((s1, s2) => {
const s1Level = s1[1]?.audioLevel || 0;
const s2Level = s2[1]?.audioLevel || 0;
return s2Level > s1Level ? 1 : -1;
});
if (
speakersInOrder.length > 0 &&
speakersInOrder[0][1].audioLevel &&
speakersInOrder[0][1].audioLevel > 0
) {
const peerID = speakersInOrder[0][0];
if (peerID in peersMap) {
return peersMap[peerID].name;
}
}
return null;
},
selectPeersMap,
selectSpeakers,
(peersMap, speakers) => {
// sort in descending order by audio level
const speakersInOrder = Object.entries(speakers).sort((s1, s2) => {
const s1Level = s1[1]?.audioLevel || 0;
const s2Level = s2[1]?.audioLevel || 0;
return s2Level > s1Level ? 1 : -1;
});
if (
speakersInOrder.length > 0 &&
speakersInOrder[0][1].audioLevel &&
speakersInOrder[0][1].audioLevel > 0
) {
const peerID = speakersInOrder[0][0];
if (peerID in peersMap) {
return peersMap[peerID].name;
}
}
return null;
},
);
export const selectIsLocalAudioEnabled = (store: HMSStore) => {
const localPeer = selectLocalPeer(store);
return isTrackEnabled(store, localPeer?.audioTrack);
const localPeer = selectLocalPeer(store);
return isTrackEnabled(store, localPeer?.audioTrack);
};
export const selectIsLocalVideoEnabled = (store: HMSStore) => {
const localPeer = selectLocalPeer(store);
return isTrackEnabled(store, localPeer?.videoTrack);
const localPeer = selectLocalPeer(store);
return isTrackEnabled(store, localPeer?.videoTrack);
};
export const selectIsLocalVideoDisplayEnabled = (store: HMSStore) => {
const localPeer = selectLocalPeer(store);
return isTrackDisplayEnabled(store, localPeer?.videoTrack);
const localPeer = selectLocalPeer(store);
return isTrackDisplayEnabled(store, localPeer?.videoTrack);
};
export const selectIsLocalScreenShared = (store: HMSStore): boolean => {
const localPeer = selectLocalPeer(store);
return isScreenSharing(store, localPeer);
const localPeer = selectLocalPeer(store);
return isScreenSharing(store, localPeer);
};
export const selectIsSomeoneScreenSharing = (store: HMSStore): boolean => {
const peers = selectPeers(store);
return peers.some(peer => isScreenSharing(store, peer));
const peers = selectPeers(store);
return peers.some(peer => isScreenSharing(store, peer));
};
export const selectPeerScreenSharing = (store: HMSStore): HMSPeer | undefined => {
const peers = selectPeers(store);
return peers.find(peer => isScreenSharing(store, peer));
const peers = selectPeers(store);
return peers.find(peer => isScreenSharing(store, peer));
};
export const selectHMSMessagesCount = createSelector(
selectMessageIDsInOrder,
messageIDs => messageIDs.length,
selectMessageIDsInOrder,
messageIDs => messageIDs.length,
);
export const selectUnreadHMSMessagesCount = createSelector(selectMessagesMap, messages => {
return Object.values(messages).filter(m => !m.read).length;
return Object.values(messages).filter(m => !m.read).length;
});
export const selectHMSMessages = createSelector(
selectMessageIDsInOrder,
selectMessagesMap,
(msgIDs, msgMap) => {
const messages: HMSMessage[] = [];
msgIDs.forEach(msgId => {
messages.push(msgMap[msgId]);
});
return messages;
},
selectMessageIDsInOrder,
selectMessagesMap,
(msgIDs, msgMap) => {
const messages: HMSMessage[] = [];
msgIDs.forEach(msgId => {
messages.push(msgMap[msgId]);
});
return messages;
},
);

@@ -6,3 +6,3 @@ import { createSelector } from 'reselect';

type byIDSelector<T> = (store: HMSStore, id: string) => T;
type byIDSelector<T> = (store: HMSStore, id?: string) => T;

@@ -14,4 +14,4 @@ /**

*/
function byIDCurry<T>(selector: byIDSelector<T>): (id: string) => (store: HMSStore) => T {
return (id: string) => {
function byIDCurry<T>(selector: byIDSelector<T>): (id?: string) => (store: HMSStore) => T {
return (id?: string) => {
return (store: HMSStore) => selector(store, id);

@@ -39,3 +39,3 @@ };

export const selectScreenShareByPeerID = byIDCurry((store: HMSStore, peerID: HMSPeerID):
export const selectScreenShareByPeerID = byIDCurry((store: HMSStore, peerID?: HMSPeerID):
| HMSTrack

@@ -51,3 +51,3 @@ | undefined => {

export const selectCameraStreamByPeerID = byIDCurry((store: HMSStore, peerID: HMSPeerID):
export const selectCameraStreamByPeerID = byIDCurry((store: HMSStore, peerID?: HMSPeerID):
| HMSTrack

@@ -62,3 +62,3 @@ | undefined => {

export const selectIsPeerAudioEnabled = byIDCurry((store: HMSStore, peerID: string) => {
export const selectIsPeerAudioEnabled = byIDCurry((store: HMSStore, peerID?: string) => {
const peer = selectPeerByIDBare(store, peerID);

@@ -68,5 +68,5 @@ return isTrackEnabled(store, peer?.audioTrack);

export const selectIsPeerVideoEnabled = byIDCurry((store: HMSStore, peerID: string) => {
export const selectIsPeerVideoEnabled = byIDCurry((store: HMSStore, peerID?: string) => {
const peer = selectPeerByIDBare(store, peerID);
return isTrackEnabled(store, peer?.videoTrack);
});

@@ -1,25 +0,25 @@

import {HMSPeer, HMSStore, HMSTrack} from "../schema";
import { HMSPeer, HMSStore, HMSTrack } from '../schema';
export function isScreenSharing(store: HMSStore, peer: HMSPeer) {
return (
peer &&
peer.auxiliaryTracks.some(trackID => {
if (trackID && store.tracks[trackID]) {
const track = store.tracks[trackID];
return isScreenShare(track);
}
return false;
})
);
return (
peer &&
peer.auxiliaryTracks.some(trackID => {
if (trackID && store.tracks[trackID]) {
const track = store.tracks[trackID];
return isScreenShare(track);
}
return false;
})
);
}
export function isScreenShare(track: HMSTrack | undefined) {
return track && track.type === 'video' && track.source === 'screen';
return track && track.type === 'video' && track.source === 'screen';
}
export function isTrackEnabled(store: HMSStore, trackID?: string) {
if (trackID && store.tracks[trackID]) {
return store.tracks[trackID].enabled;
}
return false;
if (trackID && store.tracks[trackID]) {
return store.tracks[trackID].enabled;
}
return false;
}

@@ -31,6 +31,6 @@

export function isTrackDisplayEnabled(store: HMSStore, trackID?: string) {
if (trackID && store.tracks[trackID]) {
return store.tracks[trackID].displayEnabled;
}
return false;
if (trackID && store.tracks[trackID]) {
return store.tracks[trackID].displayEnabled;
}
return false;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc